drizzle-cube 0.3.28 → 0.3.31

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.
Files changed (84) hide show
  1. package/dist/adapters/express/index.cjs +1 -1
  2. package/dist/adapters/express/index.js +1 -1
  3. package/dist/adapters/fastify/index.cjs +1 -1
  4. package/dist/adapters/fastify/index.js +1 -1
  5. package/dist/adapters/hono/index.cjs +1 -1
  6. package/dist/adapters/hono/index.js +1 -1
  7. package/dist/adapters/{mcp-transport-CXGL1hg7.js → mcp-transport-D4KrudfS.js} +282 -277
  8. package/dist/adapters/{mcp-transport-ConlvewL.cjs → mcp-transport-Dn7sKoBD.cjs} +7 -7
  9. package/dist/adapters/nextjs/index.cjs +1 -1
  10. package/dist/adapters/nextjs/index.js +1 -1
  11. package/dist/adapters/utils.cjs +1 -1
  12. package/dist/adapters/utils.js +3 -3
  13. package/dist/client/charts.js +12 -12
  14. package/dist/client/chunks/{DashboardEditModal-t5XeTZom.js → DashboardEditModal-rLcmZpe_.js} +8 -8
  15. package/dist/client/chunks/{DashboardEditModal-t5XeTZom.js.map → DashboardEditModal-rLcmZpe_.js.map} +1 -1
  16. package/dist/client/chunks/{RetentionCombinedChart-SsBGHJWi.js → RetentionCombinedChart-7bGP_ozM.js} +2 -2
  17. package/dist/client/chunks/{RetentionCombinedChart-SsBGHJWi.js.map → RetentionCombinedChart-7bGP_ozM.js.map} +1 -1
  18. package/dist/client/chunks/{analysis-builder-CKVYG9jJ.js → analysis-builder-DCt5C58c.js} +8 -8
  19. package/dist/client/chunks/{analysis-builder-CKVYG9jJ.js.map → analysis-builder-DCt5C58c.js.map} +1 -1
  20. package/dist/client/chunks/{analysis-builder-shared-CF8Vx1oD.js → analysis-builder-shared-ysrRYGiU.js} +7 -7
  21. package/dist/client/chunks/{analysis-builder-shared-CF8Vx1oD.js.map → analysis-builder-shared-ysrRYGiU.js.map} +1 -1
  22. package/dist/client/chunks/{chart-activity-grid-Bpu_-8uT.js → chart-activity-grid-sUkuCJzm.js} +2 -2
  23. package/dist/client/chunks/{chart-activity-grid-Bpu_-8uT.js.map → chart-activity-grid-sUkuCJzm.js.map} +1 -1
  24. package/dist/client/chunks/{chart-area-DcvLkvGb.js → chart-area-C4DIi9k_.js} +3 -3
  25. package/dist/client/chunks/{chart-area-DcvLkvGb.js.map → chart-area-C4DIi9k_.js.map} +1 -1
  26. package/dist/client/chunks/{chart-bar-CNfm5iMY.js → chart-bar-7ZleGCsN.js} +2 -2
  27. package/dist/client/chunks/{chart-bar-CNfm5iMY.js.map → chart-bar-7ZleGCsN.js.map} +1 -1
  28. package/dist/client/chunks/{chart-bubble-KA-RYWR8.js → chart-bubble-D-auWIjP.js} +2 -2
  29. package/dist/client/chunks/{chart-bubble-KA-RYWR8.js.map → chart-bubble-D-auWIjP.js.map} +1 -1
  30. package/dist/client/chunks/{chart-data-table-Cq14arji.js → chart-data-table-DW6VNGeW.js} +3 -3
  31. package/dist/client/chunks/{chart-data-table-Cq14arji.js.map → chart-data-table-DW6VNGeW.js.map} +1 -1
  32. package/dist/client/chunks/{chart-funnel-DFKWS49U.js → chart-funnel-eUJApzmA.js} +2 -2
  33. package/dist/client/chunks/{chart-funnel-DFKWS49U.js.map → chart-funnel-eUJApzmA.js.map} +1 -1
  34. package/dist/client/chunks/{chart-heat-map-D2g0dbKz.js → chart-heat-map-DR3O3GXx.js} +2 -2
  35. package/dist/client/chunks/{chart-heat-map-D2g0dbKz.js.map → chart-heat-map-DR3O3GXx.js.map} +1 -1
  36. package/dist/client/chunks/{chart-kpi-delta-Cc-jiBd0.js → chart-kpi-delta-Bp9Yrgyc.js} +3 -3
  37. package/dist/client/chunks/{chart-kpi-delta-Cc-jiBd0.js.map → chart-kpi-delta-Bp9Yrgyc.js.map} +1 -1
  38. package/dist/client/chunks/{chart-kpi-number-BXolYaZA.js → chart-kpi-number-B3yvgbr-.js} +2 -2
  39. package/dist/client/chunks/{chart-kpi-number-BXolYaZA.js.map → chart-kpi-number-B3yvgbr-.js.map} +1 -1
  40. package/dist/client/chunks/{chart-kpi-text-PA8oyypA.js → chart-kpi-text-D0TsUiaO.js} +3 -3
  41. package/dist/client/chunks/{chart-kpi-text-PA8oyypA.js.map → chart-kpi-text-D0TsUiaO.js.map} +1 -1
  42. package/dist/client/chunks/{chart-line-BOrtUdOD.js → chart-line-C7VStgaJ.js} +3 -3
  43. package/dist/client/chunks/{chart-line-BOrtUdOD.js.map → chart-line-C7VStgaJ.js.map} +1 -1
  44. package/dist/client/chunks/{chart-pie-B-Sbsvd2.js → chart-pie-DPdYJSM3.js} +2 -2
  45. package/dist/client/chunks/{chart-pie-B-Sbsvd2.js.map → chart-pie-DPdYJSM3.js.map} +1 -1
  46. package/dist/client/chunks/{chart-radar-CezgvXhm.js → chart-radar-DF6VNSiC.js} +2 -2
  47. package/dist/client/chunks/{chart-radar-CezgvXhm.js.map → chart-radar-DF6VNSiC.js.map} +1 -1
  48. package/dist/client/chunks/{chart-radial-bar-COBPiBxm.js → chart-radial-bar-7Ttfz-kO.js} +2 -2
  49. package/dist/client/chunks/{chart-radial-bar-COBPiBxm.js.map → chart-radial-bar-7Ttfz-kO.js.map} +1 -1
  50. package/dist/client/chunks/{chart-sankey-O4WQBRDk.js → chart-sankey-D86RYk9B.js} +2 -2
  51. package/dist/client/chunks/{chart-sankey-O4WQBRDk.js.map → chart-sankey-D86RYk9B.js.map} +1 -1
  52. package/dist/client/chunks/{chart-scatter-BVF0n9DR.js → chart-scatter-BUnIiLr_.js} +2 -2
  53. package/dist/client/chunks/{chart-scatter-BVF0n9DR.js.map → chart-scatter-BUnIiLr_.js.map} +1 -1
  54. package/dist/client/chunks/{chart-sunburst-DZzVj_6S.js → chart-sunburst-CsHlHfZQ.js} +2 -2
  55. package/dist/client/chunks/{chart-sunburst-DZzVj_6S.js.map → chart-sunburst-CsHlHfZQ.js.map} +1 -1
  56. package/dist/client/chunks/{chart-tree-map-CeEtNuo6.js → chart-tree-map-DFAbkeo1.js} +2 -2
  57. package/dist/client/chunks/{chart-tree-map-CeEtNuo6.js.map → chart-tree-map-DFAbkeo1.js.map} +1 -1
  58. package/dist/client/chunks/{charts-core-DF99lItO.js → charts-core-DAF1iT_h.js} +2 -2
  59. package/dist/client/chunks/{charts-core-DF99lItO.js.map → charts-core-DAF1iT_h.js.map} +1 -1
  60. package/dist/client/chunks/{charts-loader-AkRviD9H.js → charts-loader-7pEaEz-f.js} +20 -20
  61. package/dist/client/chunks/{charts-loader-AkRviD9H.js.map → charts-loader-7pEaEz-f.js.map} +1 -1
  62. package/dist/client/chunks/{core-Bso4ultM.js → core-DGLxd5v5.js} +2 -2
  63. package/dist/client/chunks/{core-Bso4ultM.js.map → core-DGLxd5v5.js.map} +1 -1
  64. package/dist/client/chunks/{hooks-B69r8rwU.js → hooks-CdyIO1-j.js} +4 -4
  65. package/dist/client/chunks/{hooks-B69r8rwU.js.map → hooks-CdyIO1-j.js.map} +1 -1
  66. package/dist/client/chunks/{providers-CxlSRYvE.js → providers-D2xswCYu.js} +2 -2
  67. package/dist/client/chunks/{providers-CxlSRYvE.js.map → providers-D2xswCYu.js.map} +1 -1
  68. package/dist/client/chunks/{syntaxHighlighting-yTdSle2t.js → syntaxHighlighting-DAT9C6Ss.js} +2 -2
  69. package/dist/client/chunks/{syntaxHighlighting-yTdSle2t.js.map → syntaxHighlighting-DAT9C6Ss.js.map} +1 -1
  70. package/dist/client/chunks/{useDirtyStateTracking-GZtwGRu7.js → useDirtyStateTracking-CTS_m9mg.js} +3 -3
  71. package/dist/client/chunks/{useDirtyStateTracking-GZtwGRu7.js.map → useDirtyStateTracking-CTS_m9mg.js.map} +1 -1
  72. package/dist/client/chunks/{vendor-B_H-VRhj.js → vendor-DfDLOfBe.js} +2 -2
  73. package/dist/client/chunks/vendor-DfDLOfBe.js.map +1 -0
  74. package/dist/client/components.js +2 -2
  75. package/dist/client/hooks.js +3 -3
  76. package/dist/client/index.js +9 -9
  77. package/dist/client/providers.js +1 -1
  78. package/dist/client/styles.css +1 -1
  79. package/dist/client/utils.js +6 -6
  80. package/dist/client-bundle-stats.html +34 -33
  81. package/dist/server/index.cjs +5 -5
  82. package/dist/server/index.js +230 -225
  83. package/package.json +1 -1
  84. package/dist/client/chunks/vendor-B_H-VRhj.js.map +0 -1
@@ -136,10 +136,10 @@ class j {
136
136
  this.value = Array.isArray(e) ? e : [e];
137
137
  }
138
138
  getSQL() {
139
- return new F([this]);
139
+ return new O([this]);
140
140
  }
141
141
  }
142
- class F {
142
+ class O {
143
143
  constructor(e) {
144
144
  this.queryChunks = e;
145
145
  for (const t of e)
@@ -193,7 +193,7 @@ class F {
193
193
  m.push(f), p < l.length - 1 && m.push(new j(", "));
194
194
  return m.push(new j(")")), this.buildQueryFromSourceParams(m, n);
195
195
  }
196
- if (L(l, F))
196
+ if (L(l, O))
197
197
  return this.buildQueryFromSourceParams(l.queryChunks, {
198
198
  ...n,
199
199
  inlineParams: u || l.shouldInlineParams
@@ -226,14 +226,14 @@ class F {
226
226
  if (L(l.value, ce))
227
227
  return { sql: r(c.value++, l), params: [l], typings: ["none"] };
228
228
  const m = l.value === null ? null : l.encoder.mapToDriverValue(l.value);
229
- if (L(m, F))
229
+ if (L(m, O))
230
230
  return this.buildQueryFromSourceParams([m], n);
231
231
  if (u)
232
232
  return { sql: this.mapInlineParam(m, n), params: [] };
233
233
  let p = ["none"];
234
234
  return a && (p = [a(l.encoder)]), { sql: r(c.value++, m), params: [m], typings: p };
235
235
  }
236
- return L(l, ce) ? { sql: r(c.value++, l), params: [l], typings: ["none"] } : L(l, F.Aliased) && l.fieldAlias !== void 0 ? { sql: i(l.fieldAlias), params: [] } : L(l, Ze) ? l._.isWith ? { sql: i(l._.alias), params: [] } : this.buildQueryFromSourceParams([
236
+ return L(l, ce) ? { sql: r(c.value++, l), params: [l], typings: ["none"] } : L(l, O.Aliased) && l.fieldAlias !== void 0 ? { sql: i(l.fieldAlias), params: [] } : L(l, Ze) ? l._.isWith ? { sql: i(l._.alias), params: [] } : this.buildQueryFromSourceParams([
237
237
  new j("("),
238
238
  l._.sql,
239
239
  new j(") "),
@@ -262,7 +262,7 @@ class F {
262
262
  return this;
263
263
  }
264
264
  as(e) {
265
- return e === void 0 ? this : new F.Aliased(this, e);
265
+ return e === void 0 ? this : new O.Aliased(this, e);
266
266
  }
267
267
  mapWith(e) {
268
268
  return this.decoder = typeof e == "function" ? { mapFromDriverValue: e } : e, this;
@@ -287,7 +287,7 @@ class Ne {
287
287
  static [x] = "Name";
288
288
  brand;
289
289
  getSQL() {
290
- return new F([this]);
290
+ return new O([this]);
291
291
  }
292
292
  }
293
293
  function wt(d) {
@@ -313,7 +313,7 @@ class le {
313
313
  static [x] = "Param";
314
314
  brand;
315
315
  getSQL() {
316
- return new F([this]);
316
+ return new O([this]);
317
317
  }
318
318
  }
319
319
  function o(d, ...e) {
@@ -321,26 +321,26 @@ function o(d, ...e) {
321
321
  (e.length > 0 || d.length > 0 && d[0] !== "") && t.push(new j(d[0]));
322
322
  for (const [n, s] of e.entries())
323
323
  t.push(s, new j(d[n + 1]));
324
- return new F(t);
324
+ return new O(t);
325
325
  }
326
326
  ((d) => {
327
327
  function e() {
328
- return new F([]);
328
+ return new O([]);
329
329
  }
330
330
  d.empty = e;
331
331
  function t(u) {
332
- return new F(u);
332
+ return new O(u);
333
333
  }
334
334
  d.fromList = t;
335
335
  function n(u) {
336
- return new F([new j(u)]);
336
+ return new O([new j(u)]);
337
337
  }
338
338
  d.raw = n;
339
339
  function s(u, c) {
340
340
  const l = [];
341
341
  for (const [m, p] of u.entries())
342
342
  m > 0 && c !== void 0 && l.push(c), l.push(p);
343
- return new F(l);
343
+ return new O(l);
344
344
  }
345
345
  d.join = s;
346
346
  function i(u) {
@@ -373,14 +373,14 @@ function o(d, ...e) {
373
373
  }
374
374
  }
375
375
  d.Aliased = e;
376
- })(F || (F = {}));
376
+ })(O || (O = {}));
377
377
  class ce {
378
378
  constructor(e) {
379
379
  this.name = e;
380
380
  }
381
381
  static [x] = "Placeholder";
382
382
  getSQL() {
383
- return new F([this]);
383
+ return new O([this]);
384
384
  }
385
385
  }
386
386
  const $t = /* @__PURE__ */ Symbol.for("drizzle:IsDrizzleView");
@@ -402,28 +402,28 @@ class st {
402
402
  };
403
403
  }
404
404
  getSQL() {
405
- return new F([this]);
405
+ return new O([this]);
406
406
  }
407
407
  }
408
408
  te.prototype.getSQL = function() {
409
- return new F([this]);
409
+ return new O([this]);
410
410
  };
411
411
  B.prototype.getSQL = function() {
412
- return new F([this]);
412
+ return new O([this]);
413
413
  };
414
414
  Ze.prototype.getSQL = function() {
415
- return new F([this]);
415
+ return new O([this]);
416
416
  };
417
417
  function U(d, e) {
418
418
  return wt(e) && !et(d) && !L(d, le) && !L(d, ce) && !L(d, te) && !L(d, B) && !L(d, st) ? new le(d, e) : d;
419
419
  }
420
- const P = (d, e) => o`${d} = ${U(e, d)}`, Me = (d, e) => o`${d} <> ${U(e, d)}`;
421
- function A(...d) {
420
+ const Q = (d, e) => o`${d} = ${U(e, d)}`, Me = (d, e) => o`${d} <> ${U(e, d)}`;
421
+ function D(...d) {
422
422
  const e = d.filter(
423
423
  (t) => t !== void 0
424
424
  );
425
425
  if (e.length !== 0)
426
- return e.length === 1 ? new F(e) : new F([
426
+ return e.length === 1 ? new O(e) : new O([
427
427
  new j("("),
428
428
  o.join(e, new j(" and ")),
429
429
  new j(")")
@@ -434,14 +434,14 @@ function ie(...d) {
434
434
  (t) => t !== void 0
435
435
  );
436
436
  if (e.length !== 0)
437
- return e.length === 1 ? new F(e) : new F([
437
+ return e.length === 1 ? new O(e) : new O([
438
438
  new j("("),
439
439
  o.join(e, new j(" or ")),
440
440
  new j(")")
441
441
  ]);
442
442
  }
443
443
  const we = (d, e) => o`${d} > ${U(e, d)}`, Y = (d, e) => o`${d} >= ${U(e, d)}`, $e = (d, e) => o`${d} < ${U(e, d)}`, X = (d, e) => o`${d} <= ${U(e, d)}`;
444
- function Ee(d, e) {
444
+ function Te(d, e) {
445
445
  return Array.isArray(e) ? e.length === 0 ? o`false` : o`${d} in ${e.map((t) => U(t, d))}` : o`${d} in ${U(e, d)}`;
446
446
  }
447
447
  function je(d, e) {
@@ -453,7 +453,7 @@ function Ue(d) {
453
453
  function ke(d) {
454
454
  return o`${d} is not null`;
455
455
  }
456
- function Et(d, e) {
456
+ function Tt(d, e) {
457
457
  if (Array.isArray(e)) {
458
458
  if (e.length === 0)
459
459
  throw new Error("arrayContains requires at least one value");
@@ -462,7 +462,7 @@ function Et(d, e) {
462
462
  }
463
463
  return o`${d} @> ${U(e, d)}`;
464
464
  }
465
- function Tt(d, e) {
465
+ function Et(d, e) {
466
466
  if (Array.isArray(e)) {
467
467
  if (e.length === 0)
468
468
  throw new Error("arrayContained requires at least one value");
@@ -492,7 +492,7 @@ function De(d) {
492
492
  function Dt(d) {
493
493
  return o`count(distinct ${d})`.mapWith(Number);
494
494
  }
495
- function W(d) {
495
+ function K(d) {
496
496
  return o`sum(${d})`.mapWith(String);
497
497
  }
498
498
  function V(d) {
@@ -2509,7 +2509,7 @@ function Qe(d, e, t) {
2509
2509
  return Be(d, e);
2510
2510
  throw new Error("Unable to determine database engine type. Please specify engineType parameter.");
2511
2511
  }
2512
- function K(d) {
2512
+ function P(d) {
2513
2513
  return typeof d == "function" ? d() : d;
2514
2514
  }
2515
2515
  function Ae(d, e) {
@@ -2543,12 +2543,12 @@ function Jt(d, e) {
2543
2543
  throw new Error("expandBelongsToManyJoin can only be called on belongsToMany relationships with through configuration");
2544
2544
  const { table: t, sourceKey: n, targetKey: s, securitySql: i } = d.through, r = [];
2545
2545
  for (const l of n) {
2546
- const m = l.as || P;
2546
+ const m = l.as || Q;
2547
2547
  r.push(m(l.source, l.target));
2548
2548
  }
2549
2549
  const a = [];
2550
2550
  for (const l of s) {
2551
- const m = l.as || P;
2551
+ const m = l.as || Q;
2552
2552
  a.push(m(l.source, l.target));
2553
2553
  }
2554
2554
  let u;
@@ -2562,13 +2562,13 @@ function Jt(d, e) {
2562
2562
  {
2563
2563
  joinType: c,
2564
2564
  table: t,
2565
- condition: A(...r)
2565
+ condition: D(...r)
2566
2566
  },
2567
2567
  {
2568
2568
  joinType: c,
2569
2569
  table: t,
2570
2570
  // This will be replaced with target cube table in query planner
2571
- condition: A(...a)
2571
+ condition: D(...a)
2572
2572
  }
2573
2573
  ],
2574
2574
  junctionSecurityConditions: u
@@ -2663,7 +2663,7 @@ function Ht(d) {
2663
2663
  return {
2664
2664
  measures: d.measures ? [...d.measures].sort() : void 0,
2665
2665
  dimensions: d.dimensions ? [...d.dimensions].sort() : void 0,
2666
- filters: d.filters ? Q(d.filters) : void 0,
2666
+ filters: d.filters ? W(d.filters) : void 0,
2667
2667
  timeDimensions: d.timeDimensions ? en(d.timeDimensions) : void 0,
2668
2668
  limit: d.limit,
2669
2669
  offset: d.offset,
@@ -2685,7 +2685,7 @@ function Yt(d) {
2685
2685
  steps: d.steps.map((e) => {
2686
2686
  const t = {
2687
2687
  name: e.name,
2688
- filter: e.filter ? Array.isArray(e.filter) ? Q(e.filter) : Q([e.filter])[0] : void 0,
2688
+ filter: e.filter ? Array.isArray(e.filter) ? W(e.filter) : W([e.filter])[0] : void 0,
2689
2689
  timeToConvert: e.timeToConvert
2690
2690
  };
2691
2691
  return "cube" in e && e.cube && (t.cube = e.cube), t;
@@ -2702,7 +2702,7 @@ function Xt(d) {
2702
2702
  // Normalize starting step - sort filters for consistent hashing
2703
2703
  startingStep: {
2704
2704
  name: d.startingStep.name,
2705
- filter: d.startingStep.filter ? Array.isArray(d.startingStep.filter) ? Q(d.startingStep.filter) : Q([d.startingStep.filter])[0] : void 0
2705
+ filter: d.startingStep.filter ? Array.isArray(d.startingStep.filter) ? W(d.startingStep.filter) : W([d.startingStep.filter])[0] : void 0
2706
2706
  },
2707
2707
  // CRITICAL: Include step counts in cache key
2708
2708
  stepsBefore: d.stepsBefore,
@@ -2724,18 +2724,18 @@ function Zt(d) {
2724
2724
  periods: d.periods,
2725
2725
  retentionType: d.retentionType,
2726
2726
  // Normalize filters for consistent hashing
2727
- cohortFilters: d.cohortFilters ? Array.isArray(d.cohortFilters) ? Q(d.cohortFilters) : Q([d.cohortFilters])[0] : void 0,
2728
- activityFilters: d.activityFilters ? Array.isArray(d.activityFilters) ? Q(d.activityFilters) : Q([d.activityFilters])[0] : void 0,
2727
+ cohortFilters: d.cohortFilters ? Array.isArray(d.cohortFilters) ? W(d.cohortFilters) : W([d.cohortFilters])[0] : void 0,
2728
+ activityFilters: d.activityFilters ? Array.isArray(d.activityFilters) ? W(d.activityFilters) : W([d.activityFilters])[0] : void 0,
2729
2729
  // Include breakdown dimensions for cache key
2730
2730
  breakdownDimensions: d.breakdownDimensions
2731
2731
  };
2732
2732
  }
2733
- function Q(d) {
2733
+ function W(d) {
2734
2734
  return [...d].map((e) => {
2735
2735
  if ("and" in e && e.and)
2736
- return { and: Q(e.and) };
2736
+ return { and: W(e.and) };
2737
2737
  if ("or" in e && e.or)
2738
- return { or: Q(e.or) };
2738
+ return { or: W(e.or) };
2739
2739
  const t = e;
2740
2740
  return {
2741
2741
  ...t,
@@ -2775,7 +2775,7 @@ class ne {
2775
2775
  */
2776
2776
  buildTimeDimensionExpression(e, t, n) {
2777
2777
  const s = v(e, n);
2778
- return t ? this.databaseAdapter.buildTimeDimension(t, s) : s instanceof F ? s : o`${s}`;
2778
+ return t ? this.databaseAdapter.buildTimeDimension(t, s) : s instanceof O ? s : o`${s}`;
2779
2779
  }
2780
2780
  /**
2781
2781
  * Build date range condition for time dimensions
@@ -2790,7 +2790,7 @@ class ne {
2790
2790
  const i = typeof s == "number" ? new Date(s * (this.databaseAdapter.getEngineType() === "sqlite" ? 1e3 : 1)) : new Date(s), r = new Date(i);
2791
2791
  r.setUTCHours(23, 59, 59, 999), this.databaseAdapter.isTimestampInteger() ? s = this.databaseAdapter.getEngineType() === "sqlite" ? Math.floor(r.getTime() / 1e3) : r.getTime() : s = r.toISOString();
2792
2792
  }
2793
- return A(
2793
+ return D(
2794
2794
  Y(e, n),
2795
2795
  X(e, s)
2796
2796
  );
@@ -2799,7 +2799,7 @@ class ne {
2799
2799
  const n = this.parseRelativeDateRange(t);
2800
2800
  if (n) {
2801
2801
  let l, m;
2802
- return this.databaseAdapter.isTimestampInteger() ? this.databaseAdapter.getEngineType() === "sqlite" ? (l = Math.floor(n.start.getTime() / 1e3), m = Math.floor(n.end.getTime() / 1e3)) : (l = n.start.getTime(), m = n.end.getTime()) : (l = n.start.toISOString(), m = n.end.toISOString()), A(
2802
+ return this.databaseAdapter.isTimestampInteger() ? this.databaseAdapter.getEngineType() === "sqlite" ? (l = Math.floor(n.start.getTime() / 1e3), m = Math.floor(n.end.getTime() / 1e3)) : (l = n.start.getTime(), m = n.end.getTime()) : (l = n.start.toISOString(), m = n.end.toISOString()), D(
2803
2803
  Y(e, l),
2804
2804
  X(e, m)
2805
2805
  );
@@ -2811,7 +2811,7 @@ class ne {
2811
2811
  const a = new Date(i);
2812
2812
  a.setUTCHours(23, 59, 59, 999);
2813
2813
  let u, c;
2814
- return this.databaseAdapter.isTimestampInteger() ? this.databaseAdapter.getEngineType() === "sqlite" ? (u = Math.floor(r.getTime() / 1e3), c = Math.floor(a.getTime() / 1e3)) : (u = r.getTime(), c = a.getTime()) : (u = r.toISOString(), c = a.toISOString()), A(
2814
+ return this.databaseAdapter.isTimestampInteger() ? this.databaseAdapter.getEngineType() === "sqlite" ? (u = Math.floor(r.getTime() / 1e3), c = Math.floor(a.getTime() / 1e3)) : (u = r.getTime(), c = a.getTime()) : (u = r.toISOString(), c = a.toISOString()), D(
2815
2815
  Y(e, u),
2816
2816
  X(e, c)
2817
2817
  );
@@ -2957,12 +2957,12 @@ class he {
2957
2957
  if (r.length > 1) {
2958
2958
  if (s?.type === "time") {
2959
2959
  const u = r.map((c) => this.dateTimeBuilder.normalizeDate(c) || c);
2960
- return Ee(e, u);
2960
+ return Te(e, u);
2961
2961
  }
2962
- return Ee(e, r);
2962
+ return Te(e, r);
2963
2963
  } else if (r.length === 1) {
2964
2964
  const u = s?.type === "time" && this.dateTimeBuilder.normalizeDate(a) || a;
2965
- return P(e, u);
2965
+ return Q(e, u);
2966
2966
  }
2967
2967
  return this.databaseAdapter.buildBooleanLiteral(!1);
2968
2968
  case "notEquals":
@@ -2997,7 +2997,7 @@ class he {
2997
2997
  const m = typeof c == "number" ? new Date(c * (this.databaseAdapter.getEngineType() === "sqlite" ? 1e3 : 1)) : new Date(c), p = new Date(m);
2998
2998
  p.setUTCHours(23, 59, 59, 999), this.databaseAdapter.isTimestampInteger() ? c = this.databaseAdapter.getEngineType() === "sqlite" ? Math.floor(p.getTime() / 1e3) : p.getTime() : c = p.toISOString();
2999
2999
  }
3000
- return A(
3000
+ return D(
3001
3001
  Y(e, u),
3002
3002
  X(e, c)
3003
3003
  );
@@ -3013,7 +3013,7 @@ class he {
3013
3013
  return u ? we(e, u) : null;
3014
3014
  }
3015
3015
  case "between":
3016
- return r.length >= 2 ? A(
3016
+ return r.length >= 2 ? D(
3017
3017
  Y(e, r[0]),
3018
3018
  X(e, r[1])
3019
3019
  ) : null;
@@ -3023,7 +3023,7 @@ class he {
3023
3023
  we(e, r[1])
3024
3024
  ) : null;
3025
3025
  case "in":
3026
- return r.length > 0 ? Ee(e, r) : null;
3026
+ return r.length > 0 ? Te(e, r) : null;
3027
3027
  case "notIn":
3028
3028
  return r.length > 0 ? je(e, r) : null;
3029
3029
  case "like":
@@ -3039,21 +3039,21 @@ class he {
3039
3039
  case "isEmpty":
3040
3040
  return ie(
3041
3041
  Ue(e),
3042
- P(e, "")
3042
+ Q(e, "")
3043
3043
  );
3044
3044
  case "isNotEmpty":
3045
- return A(
3045
+ return D(
3046
3046
  ke(e),
3047
3047
  Me(e, "")
3048
3048
  );
3049
3049
  // PostgreSQL array operators - silent no-op for other databases
3050
3050
  // These use Drizzle's built-in array operator functions
3051
3051
  case "arrayContains":
3052
- return this.databaseAdapter.getEngineType() === "postgres" ? Et(e, r) : null;
3052
+ return this.databaseAdapter.getEngineType() === "postgres" ? Tt(e, r) : null;
3053
3053
  case "arrayOverlaps":
3054
3054
  return this.databaseAdapter.getEngineType() === "postgres" ? St(e, r) : null;
3055
3055
  case "arrayContained":
3056
- return this.databaseAdapter.getEngineType() === "postgres" ? Tt(e, r) : null;
3056
+ return this.databaseAdapter.getEngineType() === "postgres" ? Et(e, r) : null;
3057
3057
  default:
3058
3058
  return null;
3059
3059
  }
@@ -3065,7 +3065,7 @@ class he {
3065
3065
  buildLogicalFilter(e, t, n) {
3066
3066
  if ("and" in e && e.and) {
3067
3067
  const s = e.and.map((i) => this.buildSingleFilter(i, t, n)).filter((i) => i !== null);
3068
- return s.length > 0 ? s.length === 1 ? s[0] : A(...s) : null;
3068
+ return s.length > 0 ? s.length === 1 ? s[0] : D(...s) : null;
3069
3069
  }
3070
3070
  if ("or" in e && e.or) {
3071
3071
  const s = e.or.map((i) => this.buildSingleFilter(i, t, n)).filter((i) => i !== null);
@@ -3327,7 +3327,7 @@ function tn(d, e) {
3327
3327
  throw new Error(
3328
3328
  `Cannot substitute {${p}}: measure '${b}' not resolved yet. Ensure measures are resolved in dependency order.`
3329
3329
  );
3330
- const _ = w(), $ = o`${_}`;
3330
+ const A = w(), $ = o`${A}`;
3331
3331
  r.set(p, $);
3332
3332
  }
3333
3333
  const a = [], u = [];
@@ -3392,7 +3392,7 @@ function nn(d) {
3392
3392
  errors: e
3393
3393
  };
3394
3394
  }
3395
- function Te(d, e) {
3395
+ function Ee(d, e) {
3396
3396
  const t = Re(d), n = /* @__PURE__ */ new Set();
3397
3397
  for (const s of t) {
3398
3398
  const r = `${s.cubeName || e}.${s.fieldName}`;
@@ -3428,11 +3428,11 @@ class I {
3428
3428
  g && u.add(g);
3429
3429
  continue;
3430
3430
  }
3431
- G.isCalculatedMeasure(h) ? (a.push(l), Te(h.calculatedSql, m).forEach((b) => u.add(b)), c.getAllDependencies(l).forEach((b) => {
3432
- const [w, _] = b.split("."), $ = t.get(w);
3433
- if ($ && $.measures[_]) {
3434
- const C = $.measures[_];
3435
- G.isCalculatedMeasure(C) && Te(C.calculatedSql, w).forEach((T) => u.add(T));
3431
+ G.isCalculatedMeasure(h) ? (a.push(l), Ee(h.calculatedSql, m).forEach((b) => u.add(b)), c.getAllDependencies(l).forEach((b) => {
3432
+ const [w, A] = b.split("."), $ = t.get(w);
3433
+ if ($ && $.measures[A]) {
3434
+ const C = $.measures[A];
3435
+ G.isCalculatedMeasure(C) && Ee(C.calculatedSql, w).forEach((E) => u.add(E));
3436
3436
  }
3437
3437
  })) : r.push(l);
3438
3438
  }
@@ -3504,7 +3504,7 @@ class I {
3504
3504
  throw new Error(
3505
3505
  `Calculated measure '${t.name}.${e.name || "unknown"}' missing calculatedSql property`
3506
3506
  );
3507
- const r = /* @__PURE__ */ new Map(), a = Te(e.calculatedSql, t.name);
3507
+ const r = /* @__PURE__ */ new Map(), a = Ee(e.calculatedSql, t.name);
3508
3508
  for (const u of a) {
3509
3509
  const [c, l] = u.split("."), m = s.get(c);
3510
3510
  if (m && m.measures[l]) {
@@ -3516,7 +3516,7 @@ class I {
3516
3516
  case "count":
3517
3517
  case "countDistinct":
3518
3518
  case "sum":
3519
- h = W(f);
3519
+ h = K(f);
3520
3520
  break;
3521
3521
  case "avg":
3522
3522
  h = this.databaseAdapter.buildAvg(f);
@@ -3528,10 +3528,10 @@ class I {
3528
3528
  h = V(f);
3529
3529
  break;
3530
3530
  case "number":
3531
- h = W(f);
3531
+ h = K(f);
3532
3532
  break;
3533
3533
  default:
3534
- h = W(f);
3534
+ h = K(f);
3535
3535
  }
3536
3536
  r.set(u, () => h);
3537
3537
  }
@@ -3573,7 +3573,7 @@ class I {
3573
3573
  case "count":
3574
3574
  case "countDistinct":
3575
3575
  case "sum":
3576
- return W(a);
3576
+ return K(a);
3577
3577
  case "avg":
3578
3578
  return this.databaseAdapter.buildAvg(a);
3579
3579
  case "min":
@@ -3581,9 +3581,9 @@ class I {
3581
3581
  case "max":
3582
3582
  return V(a);
3583
3583
  case "number":
3584
- return W(a);
3584
+ return K(a);
3585
3585
  default:
3586
- return W(a);
3586
+ return K(a);
3587
3587
  }
3588
3588
  }
3589
3589
  }
@@ -3617,7 +3617,7 @@ class I {
3617
3617
  return a ? o`(${a})` : void 0;
3618
3618
  }).filter(Boolean);
3619
3619
  if (i.length > 0) {
3620
- const r = i.length === 1 ? i[0] : A(...i);
3620
+ const r = i.length === 1 ? i[0] : D(...i);
3621
3621
  s = this.databaseAdapter.buildCaseWhen([
3622
3622
  { when: r, then: s }
3623
3623
  ]);
@@ -3629,7 +3629,7 @@ class I {
3629
3629
  case "countDistinct":
3630
3630
  return Dt(s);
3631
3631
  case "sum":
3632
- return W(s);
3632
+ return K(s);
3633
3633
  case "avg":
3634
3634
  return this.databaseAdapter.buildAvg(s);
3635
3635
  case "min":
@@ -4148,7 +4148,7 @@ class rn {
4148
4148
  const f = e;
4149
4149
  if (f.and) {
4150
4150
  const h = f.and.map((g) => this.processFilter(g, t, n, s, i)).filter((g) => g !== null);
4151
- return h.length > 0 ? A(...h) : null;
4151
+ return h.length > 0 ? D(...h) : null;
4152
4152
  }
4153
4153
  if (f.or) {
4154
4154
  const h = f.or.map((g) => this.processFilter(g, t, n, s, i)).filter((g) => g !== null);
@@ -4321,7 +4321,7 @@ class oe {
4321
4321
  const { cube: u, path: c } = r.shift(), l = this.cubes.get(u);
4322
4322
  if (l?.joins)
4323
4323
  for (const [, m] of Object.entries(l.joins)) {
4324
- const f = K(m.targetCube).name;
4324
+ const f = P(m.targetCube).name;
4325
4325
  if (a.has(f))
4326
4326
  continue;
4327
4327
  const h = [
@@ -4401,7 +4401,7 @@ class oe {
4401
4401
  const l = this.cubes.get(a);
4402
4402
  if (l?.joins)
4403
4403
  for (const [, m] of Object.entries(l.joins)) {
4404
- const f = K(m.targetCube).name;
4404
+ const f = P(m.targetCube).name;
4405
4405
  if (c.has(f))
4406
4406
  continue;
4407
4407
  const h = [
@@ -4449,10 +4449,10 @@ class oe {
4449
4449
  buildJoinCondition(e, t, n) {
4450
4450
  const s = [];
4451
4451
  for (const i of e.on) {
4452
- const r = t ? o`${o.identifier(t)}.${o.identifier(i.source.name)}` : _e(i.source), a = n ? o`${o.identifier(n)}.${o.identifier(i.target.name)}` : _e(i.target), u = i.as || P;
4452
+ const r = t ? o`${o.identifier(t)}.${o.identifier(i.source.name)}` : _e(i.source), a = n ? o`${o.identifier(n)}.${o.identifier(i.target.name)}` : _e(i.target), u = i.as || Q;
4453
4453
  s.push(u(r, a));
4454
4454
  }
4455
- return A(...s);
4455
+ return D(...s);
4456
4456
  }
4457
4457
  /**
4458
4458
  * Get all reachable cubes from a starting cube
@@ -4467,7 +4467,7 @@ class oe {
4467
4467
  const s = n.shift(), i = this.cubes.get(s);
4468
4468
  if (i?.joins)
4469
4469
  for (const [, r] of Object.entries(i.joins)) {
4470
- const u = K(r.targetCube).name;
4470
+ const u = P(r.targetCube).name;
4471
4471
  t.has(u) || (t.add(u), n.push(u));
4472
4472
  }
4473
4473
  }
@@ -4674,11 +4674,11 @@ class at {
4674
4674
  // No source alias needed - use the actual column
4675
4675
  null
4676
4676
  // No target alias needed - use the actual column
4677
- ), _ = Ae(y.relationship, y.sqlJoinType);
4677
+ ), A = Ae(y.relationship, y.sqlJoinType);
4678
4678
  a.push({
4679
4679
  cube: b,
4680
4680
  alias: `${g.toLowerCase()}_cube`,
4681
- joinType: _,
4681
+ joinType: A,
4682
4682
  joinCondition: w
4683
4683
  });
4684
4684
  }
@@ -4738,37 +4738,37 @@ class at {
4738
4738
  if (y.length === 0)
4739
4739
  continue;
4740
4740
  const b = this.analyzeJoinPathToPrimary(e, t, l.name, i);
4741
- let w, _;
4741
+ let w, A;
4742
4742
  if (b?.hasIntermediateHasMany && b.intermediateJoins.length > 0)
4743
- w = b.correctJoinKeys, _ = b.intermediateJoins;
4743
+ w = b.correctJoinKeys, A = b.intermediateJoins;
4744
4744
  else {
4745
4745
  const S = p ? this.findJoinInfoToCube(e, t.name) : this.findJoinInfoForCube(e, t, l.name);
4746
4746
  if (!S)
4747
4747
  continue;
4748
- w = p ? S.joinDef.on.map((D) => ({
4749
- sourceColumn: D.target.name,
4750
- targetColumn: D.source.name,
4751
- sourceColumnObj: D.target,
4752
- targetColumnObj: D.source
4753
- })) : S.joinDef.on.map((D) => ({
4754
- sourceColumn: D.source.name,
4755
- targetColumn: D.target.name,
4756
- sourceColumnObj: D.source,
4757
- targetColumnObj: D.target
4758
- })), _ = void 0;
4759
- }
4760
- const $ = this.findPropagatingFilters(s, l, e), C = /* @__PURE__ */ new Map([[l.name, l]]), { aggregateMeasures: E, requiredBaseMeasures: T } = I.categorizeForPostAggregation(
4748
+ w = p || "reversed" in S && S.reversed ? S.joinDef.on.map((_) => ({
4749
+ sourceColumn: _.target.name,
4750
+ targetColumn: _.source.name,
4751
+ sourceColumnObj: _.target,
4752
+ targetColumnObj: _.source
4753
+ })) : S.joinDef.on.map((_) => ({
4754
+ sourceColumn: _.source.name,
4755
+ targetColumn: _.target.name,
4756
+ sourceColumnObj: _.source,
4757
+ targetColumnObj: _.target
4758
+ })), A = void 0;
4759
+ }
4760
+ const $ = this.findPropagatingFilters(s, l, e), C = /* @__PURE__ */ new Map([[l.name, l]]), { aggregateMeasures: T, requiredBaseMeasures: E } = I.categorizeForPostAggregation(
4761
4761
  y,
4762
4762
  C
4763
4763
  ), N = [.../* @__PURE__ */ new Set([
4764
- ...E,
4765
- ...Array.from(T).filter((S) => S.startsWith(l.name + "."))
4764
+ ...T,
4765
+ ...Array.from(E).filter((S) => S.startsWith(l.name + "."))
4766
4766
  ])];
4767
4767
  if (N.length > 0) {
4768
4768
  const S = this.expandCalculatedMeasureDependencies(
4769
4769
  l,
4770
4770
  N
4771
- ), D = this.findDownstreamJoinKeys(
4771
+ ), R = this.findDownstreamJoinKeys(
4772
4772
  l,
4773
4773
  s,
4774
4774
  e
@@ -4780,8 +4780,8 @@ class at {
4780
4780
  joinKeys: w,
4781
4781
  measures: S,
4782
4782
  propagatingFilters: $.length > 0 ? $ : void 0,
4783
- downstreamJoinKeys: D.length > 0 ? D : void 0,
4784
- intermediateJoins: _ && _.length > 0 ? _ : void 0,
4783
+ downstreamJoinKeys: R.length > 0 ? R : void 0,
4784
+ intermediateJoins: A && A.length > 0 ? A : void 0,
4785
4785
  cteType: "aggregate",
4786
4786
  cteReason: f
4787
4787
  });
@@ -4797,7 +4797,7 @@ class at {
4797
4797
  for (const [, n] of e)
4798
4798
  if (n.name !== t && n.joins) {
4799
4799
  for (const [, s] of Object.entries(n.joins))
4800
- if (K(s.targetCube).name === t)
4800
+ if (P(s.targetCube).name === t)
4801
4801
  return { sourceCube: n, joinDef: s };
4802
4802
  }
4803
4803
  return null;
@@ -4837,13 +4837,13 @@ class at {
4837
4837
  for (let f = 0; f < a.length - 1; f++) {
4838
4838
  const h = a[f], g = a[f + 1], y = e.get(h.toCube);
4839
4839
  if (!y) continue;
4840
- const w = y.sql(s).where, _ = g.joinDef.on[0]?.source, $ = h.joinDef.on[0]?.target;
4840
+ const w = y.sql(s).where, A = g.joinDef.on[0]?.source, $ = h.joinDef.on[0]?.target;
4841
4841
  l.push({
4842
4842
  cube: y,
4843
4843
  joinDef: g.joinDef,
4844
4844
  securityFilter: w,
4845
4845
  primaryJoinColumn: $,
4846
- cteJoinColumn: _
4846
+ cteJoinColumn: A
4847
4847
  });
4848
4848
  }
4849
4849
  const p = a[0].joinDef.on.map((f) => ({
@@ -4882,7 +4882,7 @@ class at {
4882
4882
  if (!i.has(a) && (i.add(a), !!u.joins)) {
4883
4883
  for (const [, c] of Object.entries(u.joins))
4884
4884
  if (c.relationship === "hasMany") {
4885
- const l = K(c.targetCube);
4885
+ const l = P(c.targetCube);
4886
4886
  (r.has(a) || r.has(l.name)) && s.push({
4887
4887
  fromCube: a,
4888
4888
  toCube: l.name,
@@ -4922,15 +4922,21 @@ class at {
4922
4922
  */
4923
4923
  findJoinInfoForCube(e, t, n) {
4924
4924
  if (t.joins) {
4925
- for (const [, s] of Object.entries(t.joins))
4926
- if (K(s.targetCube).name === n)
4927
- return { sourceCube: t, joinDef: s };
4928
- }
4929
- for (const [, s] of e)
4930
- if (s.name !== t.name && s.joins) {
4931
- for (const [, i] of Object.entries(s.joins))
4932
- if (K(i.targetCube).name === n)
4933
- return { sourceCube: s, joinDef: i };
4925
+ for (const [, i] of Object.entries(t.joins))
4926
+ if (P(i.targetCube).name === n)
4927
+ return { sourceCube: t, joinDef: i };
4928
+ }
4929
+ const s = e.get(n);
4930
+ if (s?.joins) {
4931
+ for (const [, i] of Object.entries(s.joins))
4932
+ if (P(i.targetCube).name === t.name)
4933
+ return { sourceCube: s, joinDef: i, reversed: !0 };
4934
+ }
4935
+ for (const [, i] of e)
4936
+ if (!(i.name === t.name || i.name === n) && i.joins) {
4937
+ for (const [, r] of Object.entries(i.joins))
4938
+ if (P(r.targetCube).name === n)
4939
+ return { sourceCube: i, joinDef: r };
4934
4940
  }
4935
4941
  return null;
4936
4942
  }
@@ -4961,7 +4967,7 @@ class at {
4961
4967
  }
4962
4968
  if (e.joins)
4963
4969
  for (const [, r] of Object.entries(e.joins)) {
4964
- const u = K(r.targetCube).name;
4970
+ const u = P(r.targetCube).name;
4965
4971
  if (i.has(u)) {
4966
4972
  const c = r.on.map((l) => ({
4967
4973
  sourceColumn: l.source.name,
@@ -5017,7 +5023,7 @@ class at {
5017
5023
  if (!e.joins)
5018
5024
  return null;
5019
5025
  for (const [, n] of Object.entries(e.joins))
5020
- if (K(n.targetCube).name === t && n.relationship === "hasMany")
5026
+ if (P(n.targetCube).name === t && n.relationship === "hasMany")
5021
5027
  return n;
5022
5028
  return null;
5023
5029
  }
@@ -5045,7 +5051,7 @@ class at {
5045
5051
  const a = n.get(r);
5046
5052
  if (a?.joins) {
5047
5053
  for (const [, u] of Object.entries(a.joins))
5048
- if (K(u.targetCube).name === t.name && u.relationship === "hasMany") {
5054
+ if (P(u.targetCube).name === t.name && u.relationship === "hasMany") {
5049
5055
  const l = this.extractFiltersForCube(e.filters, r), m = this.extractTimeDimensionFiltersForCube(e, r), p = [...l, ...m];
5050
5056
  p.length > 0 && u.on.length > 0 && s.push({
5051
5057
  sourceCube: a,
@@ -5439,48 +5445,48 @@ class on {
5439
5445
  buildPreAggregationCTE(e, t, n, s, i) {
5440
5446
  const r = e.cube, a = r.sql(n), u = e.intermediateJoins && e.intermediateJoins.length > 0, c = {};
5441
5447
  if (u && e.intermediateJoins) {
5442
- const E = e.intermediateJoins[0].primaryJoinColumn;
5443
- if (E) {
5444
- const T = E.name;
5445
- c[T] = E;
5448
+ const T = e.intermediateJoins[0].primaryJoinColumn;
5449
+ if (T) {
5450
+ const E = T.name;
5451
+ c[E] = T;
5446
5452
  }
5447
5453
  } else
5448
5454
  for (const C of e.joinKeys)
5449
5455
  if (C.targetColumnObj) {
5450
5456
  c[C.targetColumn] = C.targetColumnObj;
5451
- for (const [E, T] of Object.entries(r.dimensions || {}))
5452
- T.sql === C.targetColumnObj && E !== C.targetColumn && (c[E] = o`${C.targetColumnObj}`.as(E));
5457
+ for (const [T, E] of Object.entries(r.dimensions || {}))
5458
+ E.sql === C.targetColumnObj && T !== C.targetColumn && (c[T] = o`${C.targetColumnObj}`.as(T));
5453
5459
  }
5454
5460
  if (e.downstreamJoinKeys)
5455
5461
  for (const C of e.downstreamJoinKeys)
5456
- for (const E of C.joinKeys)
5457
- E.sourceColumnObj && (c[E.sourceColumn] = E.sourceColumnObj);
5462
+ for (const T of C.joinKeys)
5463
+ T.sourceColumnObj && (c[T.sourceColumn] = T.sourceColumnObj);
5458
5464
  const l = r.name, m = /* @__PURE__ */ new Map([[l, r]]), p = this.queryBuilder.buildResolvedMeasures(
5459
5465
  e.measures,
5460
5466
  m,
5461
5467
  n
5462
5468
  );
5463
5469
  for (const C of e.measures) {
5464
- const [, E] = C.split("."), T = p.get(C);
5465
- if (T) {
5466
- const N = T();
5467
- c[E] = o`${N}`.as(E);
5470
+ const [, T] = C.split("."), E = p.get(C);
5471
+ if (E) {
5472
+ const N = E();
5473
+ c[T] = o`${N}`.as(T);
5468
5474
  }
5469
5475
  }
5470
5476
  if (t.dimensions)
5471
5477
  for (const C of t.dimensions) {
5472
- const [E, T] = C.split(".");
5473
- if (E === l && r.dimensions && r.dimensions[T]) {
5474
- const N = r.dimensions[T], S = this.queryBuilder.buildMeasureExpression({ sql: N.sql, type: "number" }, n);
5475
- c[T] = o`${S}`.as(T);
5478
+ const [T, E] = C.split(".");
5479
+ if (T === l && r.dimensions && r.dimensions[E]) {
5480
+ const N = r.dimensions[E], S = this.queryBuilder.buildMeasureExpression({ sql: N.sql, type: "number" }, n);
5481
+ c[E] = o`${S}`.as(E);
5476
5482
  }
5477
5483
  }
5478
5484
  if (t.timeDimensions)
5479
5485
  for (const C of t.timeDimensions) {
5480
- const [E, T] = C.dimension.split(".");
5481
- if (E === l && r.dimensions && r.dimensions[T]) {
5482
- const N = r.dimensions[T], S = this.queryBuilder.buildTimeDimensionExpression(N.sql, C.granularity, n);
5483
- c[T] = o`${S}`.as(T);
5486
+ const [T, E] = C.dimension.split(".");
5487
+ if (T === l && r.dimensions && r.dimensions[E]) {
5488
+ const N = r.dimensions[E], S = this.queryBuilder.buildTimeDimensionExpression(N.sql, C.granularity, n);
5489
+ c[E] = o`${S}`.as(E);
5484
5490
  }
5485
5491
  }
5486
5492
  if (Object.keys(c).length === 0)
@@ -5488,10 +5494,10 @@ class on {
5488
5494
  let f = n.db.select(c).from(a.from);
5489
5495
  if (u && e.intermediateJoins)
5490
5496
  for (const C of e.intermediateJoins) {
5491
- const E = C.cube.sql(n), N = [P(C.cteJoinColumn, C.joinDef.on[0]?.target)];
5497
+ const T = C.cube.sql(n), N = [Q(C.cteJoinColumn, C.joinDef.on[0]?.target)];
5492
5498
  C.securityFilter && N.push(C.securityFilter), f = f.leftJoin(
5493
- E.from,
5494
- A(...N)
5499
+ T.from,
5500
+ D(...N)
5495
5501
  );
5496
5502
  }
5497
5503
  const h = s ? {
@@ -5500,41 +5506,41 @@ class on {
5500
5506
  } : void 0, g = this.queryBuilder.buildWhereConditions(r, t, n, h, i), y = [];
5501
5507
  if (t.timeDimensions)
5502
5508
  for (const C of t.timeDimensions) {
5503
- const [E, T] = C.dimension.split(".");
5504
- if (E === l && r.dimensions && r.dimensions[T] && C.dateRange) {
5505
- const N = r.dimensions[T], S = this.queryBuilder.buildMeasureExpression({ sql: N.sql, type: "number" }, n), D = this.queryBuilder.buildDateRangeCondition(S, C.dateRange);
5506
- D && y.push(D);
5509
+ const [T, E] = C.dimension.split(".");
5510
+ if (T === l && r.dimensions && r.dimensions[E] && C.dateRange) {
5511
+ const N = r.dimensions[E], S = this.queryBuilder.buildMeasureExpression({ sql: N.sql, type: "number" }, n), R = this.queryBuilder.buildDateRangeCondition(S, C.dateRange);
5512
+ R && y.push(R);
5507
5513
  }
5508
5514
  }
5509
5515
  if (t.filters) {
5510
5516
  for (const C of t.filters)
5511
5517
  if (!("and" in C) && !("or" in C) && "member" in C && "operator" in C) {
5512
- const E = C, [T, N] = E.member.split(".");
5513
- if (T === l && r.dimensions && r.dimensions[N]) {
5518
+ const T = C, [E, N] = T.member.split(".");
5519
+ if (E === l && r.dimensions && r.dimensions[N]) {
5514
5520
  const S = r.dimensions[N];
5515
- if (E.operator === "inDateRange") {
5516
- const D = this.queryBuilder.buildMeasureExpression({ sql: S.sql, type: "number" }, n), O = this.queryBuilder.buildDateRangeCondition(D, E.values);
5517
- O && y.push(O);
5521
+ if (T.operator === "inDateRange") {
5522
+ const R = this.queryBuilder.buildMeasureExpression({ sql: S.sql, type: "number" }, n), _ = this.queryBuilder.buildDateRangeCondition(R, T.values);
5523
+ _ && y.push(_);
5518
5524
  }
5519
5525
  }
5520
5526
  }
5521
5527
  }
5522
5528
  if (e.propagatingFilters && e.propagatingFilters.length > 0)
5523
5529
  for (const C of e.propagatingFilters) {
5524
- const E = this.buildPropagatingFilterSubquery(
5530
+ const T = this.buildPropagatingFilterSubquery(
5525
5531
  C,
5526
5532
  n
5527
5533
  );
5528
- E && y.push(E);
5534
+ T && y.push(T);
5529
5535
  }
5530
5536
  const b = [];
5531
5537
  if (a.where && b.push(a.where), b.push(...g, ...y), b.length > 0) {
5532
- const C = b.length === 1 ? b[0] : A(...b);
5538
+ const C = b.length === 1 ? b[0] : D(...b);
5533
5539
  f = f.where(C);
5534
5540
  }
5535
- const w = [], _ = /* @__PURE__ */ new Set(), $ = (C) => {
5536
- const E = C?.name || (typeof C == "string" ? C : null);
5537
- E && !_.has(E) ? (_.add(E), w.push(C)) : E || w.push(C);
5541
+ const w = [], A = /* @__PURE__ */ new Set(), $ = (C) => {
5542
+ const T = C?.name || (typeof C == "string" ? C : null);
5543
+ T && !A.has(T) ? (A.add(T), w.push(C)) : T || w.push(C);
5538
5544
  };
5539
5545
  if (u && e.intermediateJoins) {
5540
5546
  const C = e.intermediateJoins[0];
@@ -5544,21 +5550,21 @@ class on {
5544
5550
  C.targetColumnObj && $(C.targetColumnObj);
5545
5551
  if (e.downstreamJoinKeys)
5546
5552
  for (const C of e.downstreamJoinKeys)
5547
- for (const E of C.joinKeys)
5548
- E.sourceColumnObj && $(E.sourceColumnObj);
5553
+ for (const T of C.joinKeys)
5554
+ T.sourceColumnObj && $(T.sourceColumnObj);
5549
5555
  if (t.dimensions)
5550
5556
  for (const C of t.dimensions) {
5551
- const [E, T] = C.split(".");
5552
- if (E === l && r.dimensions && r.dimensions[T]) {
5553
- const N = r.dimensions[T], S = v(N.sql, n);
5557
+ const [T, E] = C.split(".");
5558
+ if (T === l && r.dimensions && r.dimensions[E]) {
5559
+ const N = r.dimensions[E], S = v(N.sql, n);
5554
5560
  w.push(S);
5555
5561
  }
5556
5562
  }
5557
5563
  if (t.timeDimensions)
5558
5564
  for (const C of t.timeDimensions) {
5559
- const [E, T] = C.dimension.split(".");
5560
- if (E === l && r.dimensions && r.dimensions[T]) {
5561
- const N = r.dimensions[T], S = this.queryBuilder.buildTimeDimensionExpression(N.sql, C.granularity, n);
5565
+ const [T, E] = C.dimension.split(".");
5566
+ if (T === l && r.dimensions && r.dimensions[E]) {
5567
+ const N = r.dimensions[E], S = this.queryBuilder.buildTimeDimensionExpression(N.sql, C.granularity, n);
5562
5568
  w.push(S);
5563
5569
  }
5564
5570
  }
@@ -5582,13 +5588,13 @@ class on {
5582
5588
  const i = [];
5583
5589
  if (s.intermediateJoins && s.intermediateJoins.length > 0) {
5584
5590
  const r = s.intermediateJoins[0], a = s.joinKeys[0]?.sourceColumnObj, u = o`${o.identifier(t)}.${o.identifier(r.primaryJoinColumn.name)}`;
5585
- i.push(P(a, u));
5591
+ i.push(Q(a, u));
5586
5592
  } else
5587
5593
  for (const r of s.joinKeys) {
5588
5594
  const a = r.sourceColumnObj || o.identifier(r.sourceColumn), u = o`${o.identifier(t)}.${o.identifier(r.targetColumn)}`;
5589
- i.push(P(a, u));
5595
+ i.push(Q(a, u));
5590
5596
  }
5591
- return i.length === 1 ? i[0] : A(...i);
5597
+ return i.length === 1 ? i[0] : D(...i);
5592
5598
  }
5593
5599
  /**
5594
5600
  * Build a subquery filter for propagating filters from related cubes.
@@ -5617,12 +5623,12 @@ class on {
5617
5623
  }
5618
5624
  if (i.length === 0)
5619
5625
  return null;
5620
- const r = i.length === 1 ? i[0] : A(...i), a = e.joinConditions;
5626
+ const r = i.length === 1 ? i[0] : D(...i), a = e.joinConditions;
5621
5627
  if (a.length === 1) {
5622
5628
  const { source: u, target: c } = a[0], l = t.db.select({ pk: u }).from(s.from).where(r);
5623
5629
  return o`${c} IN ${l}`;
5624
5630
  } else {
5625
- const u = a.map((m) => P(m.source, m.target)), c = A(
5631
+ const u = a.map((m) => Q(m.source, m.target)), c = D(
5626
5632
  ...u,
5627
5633
  r
5628
5634
  ), l = t.db.select({ one: o`1` }).from(s.from).where(c);
@@ -6217,19 +6223,19 @@ class pn {
6217
6223
  const b = e;
6218
6224
  y = b.type === "and";
6219
6225
  for (const w of b.filters || []) {
6220
- const _ = this.buildFilterCondition(w, t, n, s);
6221
- _ && g.push(_);
6226
+ const A = this.buildFilterCondition(w, t, n, s);
6227
+ A && g.push(A);
6222
6228
  }
6223
6229
  } else {
6224
6230
  const b = e;
6225
6231
  y = "and" in b && !!b.and;
6226
6232
  const w = b.and || b.or || [];
6227
- for (const _ of w) {
6228
- const $ = this.buildFilterCondition(_, t, n, s);
6233
+ for (const A of w) {
6234
+ const $ = this.buildFilterCondition(A, t, n, s);
6229
6235
  $ && g.push($);
6230
6236
  }
6231
6237
  }
6232
- return g.length === 0 ? null : g.length === 1 ? g[0] : y ? A(...g) : o`(${o.join(g, o` OR `)})`;
6238
+ return g.length === 0 ? null : g.length === 1 ? g[0] : y ? D(...g) : o`(${o.join(g, o` OR `)})`;
6233
6239
  }
6234
6240
  const a = e, [u, c] = a.member.split("."), l = a.dateRange !== void 0;
6235
6241
  if (a.operator !== "set" && a.operator !== "notSet" && !l && (!a.values || a.values.length === 0 || a.values[0] === void 0 || a.values[0] === ""))
@@ -6285,7 +6291,7 @@ class pn {
6285
6291
  step_time: o`MIN(${e.timeExpr})`.as("step_time")
6286
6292
  }).from(s.from);
6287
6293
  if (r = this.addCrossJoinsToQuery(r, e, t, i), i.length > 0) {
6288
- const a = i.length === 1 ? i[0] : A(...i);
6294
+ const a = i.length === 1 ? i[0] : D(...i);
6289
6295
  r = r.where(a);
6290
6296
  }
6291
6297
  return r = r.groupBy(e.bindingKeyExpr), t.db.$with(n).as(r);
@@ -6318,7 +6324,7 @@ class pn {
6318
6324
  o`${e.bindingKeyExpr} = ${o.identifier(i)}.binding_key`
6319
6325
  );
6320
6326
  if (l = this.addCrossJoinsToQuery(l, e, t, a), a.length > 0) {
6321
- const m = a.length === 1 ? a[0] : A(...a);
6327
+ const m = a.length === 1 ? a[0] : D(...a);
6322
6328
  l = l.where(m);
6323
6329
  }
6324
6330
  return l = l.groupBy(e.bindingKeyExpr), t.db.$with(s).as(l);
@@ -6334,8 +6340,8 @@ class pn {
6334
6340
  for (const r of i.joinPath) {
6335
6341
  const a = r.joinDef, u = [];
6336
6342
  for (const p of a.on)
6337
- p.as ? u.push(p.as(p.source, p.target)) : u.push(P(p.source, p.target));
6338
- const c = u.length === 1 ? u[0] : A(...u), m = i.cube.sql(n);
6343
+ p.as ? u.push(p.as(p.source, p.target)) : u.push(Q(p.source, p.target));
6344
+ const c = u.length === 1 ? u[0] : D(...u), m = i.cube.sql(n);
6339
6345
  e = e.leftJoin(m.from, c), m.where && s.push(m.where);
6340
6346
  }
6341
6347
  return e;
@@ -6644,7 +6650,7 @@ class hn {
6644
6650
  const p = this.buildFilterCondition(m, t, n);
6645
6651
  p && c.push(p);
6646
6652
  }
6647
- return c.length === 0 ? null : c.length === 1 ? c[0] : "and" in e ? A(...c) : o`(${o.join(c, o` OR `)})`;
6653
+ return c.length === 0 ? null : c.length === 1 ? c[0] : "and" in e ? D(...c) : o`(${o.join(c, o` OR `)})`;
6648
6654
  }
6649
6655
  if ("type" in e && "filters" in e) {
6650
6656
  const u = e, c = [];
@@ -6652,7 +6658,7 @@ class hn {
6652
6658
  const m = this.buildFilterCondition(l, t, n);
6653
6659
  m && c.push(m);
6654
6660
  }
6655
- return c.length === 0 ? null : c.length === 1 ? c[0] : u.type === "and" ? A(...c) : o`(${o.join(c, o` OR `)})`;
6661
+ return c.length === 0 ? null : c.length === 1 ? c[0] : u.type === "and" ? D(...c) : o`(${o.join(c, o` OR `)})`;
6656
6662
  }
6657
6663
  const s = e, [, i] = s.member.split("."), r = t.dimensions?.[i];
6658
6664
  if (!r) return null;
@@ -6684,7 +6690,7 @@ class hn {
6684
6690
  event_path: o`${a}`.as("event_path")
6685
6691
  }).from(s.from);
6686
6692
  if (c.length > 0) {
6687
- const m = c.length === 1 ? c[0] : A(...c);
6693
+ const m = c.length === 1 ? c[0] : D(...c);
6688
6694
  l = l.where(m);
6689
6695
  }
6690
6696
  return l = l.groupBy(i, a), e.entityLimit && (l = l.limit(e.entityLimit)), n.db.$with("starting_entities").as(l);
@@ -6701,7 +6707,7 @@ class hn {
6701
6707
  o`${i} = ${o.identifier(m)}.binding_key`,
6702
6708
  o`${r} < ${o.identifier(m)}.${o.identifier(p)}`
6703
6709
  );
6704
- const g = h.length === 1 ? h[0] : A(...h), y = c ? o`${a} || ${"→"} || ${o.identifier(m)}.event_path` : o`${a}`, b = n.db.select({
6710
+ const g = h.length === 1 ? h[0] : D(...h), y = c ? o`${a} || ${"→"} || ${o.identifier(m)}.event_path` : o`${a}`, b = n.db.select({
6705
6711
  binding_key: o`${i}`.as("binding_key"),
6706
6712
  step_time: o`${r}`.as("step_time"),
6707
6713
  event_type: o`${a}`.as("event_type"),
@@ -6730,7 +6736,7 @@ class hn {
6730
6736
  o`${i} = ${o.identifier(m)}.binding_key`,
6731
6737
  o`${r} > ${o.identifier(m)}.${o.identifier(p)}`
6732
6738
  );
6733
- const g = h.length === 1 ? h[0] : A(...h), y = c ? o`${o.identifier(m)}.event_path || ${"→"} || ${a}` : o`${a}`, b = n.db.select({
6739
+ const g = h.length === 1 ? h[0] : D(...h), y = c ? o`${o.identifier(m)}.event_path || ${"→"} || ${a}` : o`${a}`, b = n.db.select({
6734
6740
  binding_key: o`${i}`.as("binding_key"),
6735
6741
  step_time: o`${r}`.as("step_time"),
6736
6742
  event_type: o`${a}`.as("event_type"),
@@ -6761,7 +6767,7 @@ class hn {
6761
6767
  s.where && h.push(s.where), h.push(
6762
6768
  o`${r} < ${o.identifier(m)}.${o.identifier(p)}`
6763
6769
  );
6764
- const g = h.length === 1 ? h[0] : A(...h), y = c ? o`${a} || ${"→"} || ${o.identifier(m)}.event_path` : o`${a}`, b = n.db.select({
6770
+ const g = h.length === 1 ? h[0] : D(...h), y = c ? o`${a} || ${"→"} || ${o.identifier(m)}.event_path` : o`${a}`, b = n.db.select({
6765
6771
  binding_key: o`${i}`.as("binding_key"),
6766
6772
  step_time: o`${r}`.as("step_time"),
6767
6773
  event_type: o`${a}`.as("event_type"),
@@ -6794,7 +6800,7 @@ class hn {
6794
6800
  s.where && h.push(s.where), h.push(
6795
6801
  o`${r} > ${o.identifier(m)}.${o.identifier(p)}`
6796
6802
  );
6797
- const g = h.length === 1 ? h[0] : A(...h), y = c ? o`${o.identifier(m)}.event_path || ${"→"} || ${a}` : o`${a}`, b = n.db.select({
6803
+ const g = h.length === 1 ? h[0] : D(...h), y = c ? o`${o.identifier(m)}.event_path || ${"→"} || ${a}` : o`${a}`, b = n.db.select({
6798
6804
  binding_key: o`${i}`.as("binding_key"),
6799
6805
  step_time: o`${r}`.as("step_time"),
6800
6806
  event_type: o`${a}`.as("event_type"),
@@ -7230,7 +7236,7 @@ class gn {
7230
7236
  const y = this.buildSingleFilterCondition(g, t, n, s);
7231
7237
  y && p.push(y);
7232
7238
  }
7233
- return p.length === 0 ? null : p.length === 1 ? p[0] : f ? A(...p) : o`(${o.join(p, o` OR `)})`;
7239
+ return p.length === 0 ? null : p.length === 1 ? p[0] : f ? D(...p) : o`(${o.join(p, o` OR `)})`;
7234
7240
  }
7235
7241
  const i = e, [r, a] = i.member.split("."), u = n.get(r);
7236
7242
  if (!u) return null;
@@ -7272,7 +7278,7 @@ class gn {
7272
7278
  }
7273
7279
  let u = n.db.select(a).from(s.from);
7274
7280
  if (i.length > 0) {
7275
- const l = i.length === 1 ? i[0] : A(...i);
7281
+ const l = i.length === 1 ? i[0] : D(...i);
7276
7282
  u = u.where(l);
7277
7283
  }
7278
7284
  const c = [t.bindingKeyExpr];
@@ -7327,7 +7333,7 @@ class gn {
7327
7333
  o`${t.bindingKeyExpr} = cohort_base.binding_key`
7328
7334
  );
7329
7335
  if (i.length > 0) {
7330
- const m = i.length === 1 ? i[0] : A(...i);
7336
+ const m = i.length === 1 ? i[0] : D(...i);
7331
7337
  c = c.where(m);
7332
7338
  }
7333
7339
  const l = [
@@ -7516,14 +7522,14 @@ class J {
7516
7522
  const c = this.buildUnifiedQuery(u, t, a), l = this.queryBuilder.collectNumericFields(e, t), m = await this.dbExecutor.execute(c, l), p = Array.isArray(m) ? m.map((b) => {
7517
7523
  const w = { ...b };
7518
7524
  if (t.timeDimensions) {
7519
- for (const _ of t.timeDimensions)
7520
- if (_.dimension in w) {
7521
- let $ = w[_.dimension];
7525
+ for (const A of t.timeDimensions)
7526
+ if (A.dimension in w) {
7527
+ let $ = w[A.dimension];
7522
7528
  if (typeof $ == "string" && $.match(/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/)) {
7523
- const C = $.replace(" ", "T"), E = !C.endsWith("Z") && !C.includes("+") ? C + "Z" : C;
7524
- $ = new Date(E);
7529
+ const C = $.replace(" ", "T"), T = !C.endsWith("Z") && !C.includes("+") ? C + "Z" : C;
7530
+ $ = new Date(T);
7525
7531
  }
7526
- $ = this.databaseAdapter.convertTimeDimensionResult($), w[_.dimension] = $;
7532
+ $ = this.databaseAdapter.convertTimeDimensionResult($), w[A.dimension] = $;
7527
7533
  }
7528
7534
  }
7529
7535
  return w;
@@ -7805,8 +7811,8 @@ class J {
7805
7811
  if (y.dimension in g) {
7806
7812
  let b = g[y.dimension];
7807
7813
  if (typeof b == "string" && b.match(/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/)) {
7808
- const w = b.replace(" ", "T"), _ = !w.endsWith("Z") && !w.includes("+") ? w + "Z" : w;
7809
- b = new Date(_);
7814
+ const w = b.replace(" ", "T"), A = !w.endsWith("Z") && !w.includes("+") ? w + "Z" : w;
7815
+ b = new Date(A);
7810
7816
  }
7811
7817
  b = this.databaseAdapter.convertTimeDimensionResult(b), g[y.dimension] = b;
7812
7818
  }
@@ -7856,19 +7862,19 @@ class J {
7856
7862
  for (const $ of e.preAggregationCTEs)
7857
7863
  if ($.propagatingFilters && $.propagatingFilters.length > 0)
7858
7864
  for (const C of $.propagatingFilters) {
7859
- const E = C.sourceCube.name;
7860
- if (!s.has(E)) {
7865
+ const T = C.sourceCube.name;
7866
+ if (!s.has(T)) {
7861
7867
  const N = {
7862
7868
  filters: C.filters
7863
- }, S = /* @__PURE__ */ new Map([[E, C.sourceCube]]), D = this.queryBuilder.buildWhereConditions(
7869
+ }, S = /* @__PURE__ */ new Map([[T, C.sourceCube]]), R = this.queryBuilder.buildWhereConditions(
7864
7870
  S,
7865
7871
  N,
7866
7872
  n
7867
7873
  );
7868
- s.set(E, D);
7874
+ s.set(T, R);
7869
7875
  }
7870
- const T = s.get(E);
7871
- T && T.length > 0 && (C.preBuiltFilterSQL = T.length === 1 ? T[0] : A(...T));
7876
+ const E = s.get(T);
7877
+ E && E.length > 0 && (C.preBuiltFilterSQL = E.length === 1 ? E[0] : D(...E));
7872
7878
  }
7873
7879
  }
7874
7880
  const i = [], r = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map();
@@ -7876,10 +7882,10 @@ class J {
7876
7882
  for (const $ of e.preAggregationCTEs) {
7877
7883
  const C = this.cteBuilder.buildPreAggregationCTE($, t, n, e, s);
7878
7884
  if (C && (i.push(C), r.set($.cube.name, $.cteAlias), $.downstreamJoinKeys))
7879
- for (const E of $.downstreamJoinKeys)
7880
- a.set(E.targetCubeName, {
7885
+ for (const T of $.downstreamJoinKeys)
7886
+ a.set(T.targetCubeName, {
7881
7887
  cteAlias: $.cteAlias,
7882
- joinKeys: E.joinKeys
7888
+ joinKeys: T.joinKeys
7883
7889
  });
7884
7890
  }
7885
7891
  const u = e.primaryCube.sql(n), c = e.joinCubes.length > 0 ? this.getCubesFromPlan(e) : /* @__PURE__ */ new Map([[e.primaryCube.name, e.primaryCube]]), m = { ...this.queryBuilder.buildSelections(
@@ -7891,14 +7897,14 @@ class J {
7891
7897
  if (e.preAggregationCTEs)
7892
7898
  for (const $ of e.preAggregationCTEs) {
7893
7899
  const C = $.cube.name;
7894
- for (const E of $.measures)
7895
- if (m[E]) {
7896
- const [, T] = E.split("."), N = c.get(C);
7897
- if (N && N.measures && N.measures[T]) {
7898
- const S = N.measures[T], D = o`${o.identifier($.cteAlias)}.${o.identifier(T)}`;
7899
- let O;
7900
+ for (const T of $.measures)
7901
+ if (m[T]) {
7902
+ const [, E] = T.split("."), N = c.get(C);
7903
+ if (N && N.measures && N.measures[E]) {
7904
+ const S = N.measures[E], R = o`${o.identifier($.cteAlias)}.${o.identifier(E)}`;
7905
+ let _;
7900
7906
  if (S.type === "calculated" && S.calculatedSql)
7901
- O = this.queryBuilder.buildCTECalculatedMeasure(
7907
+ _ = this.queryBuilder.buildCTECalculatedMeasure(
7902
7908
  S,
7903
7909
  N,
7904
7910
  $,
@@ -7906,77 +7912,77 @@ class J {
7906
7912
  n
7907
7913
  );
7908
7914
  else {
7909
- const R = $.cteReason === "fanOutPrevention", k = this.shouldUseMaxForHasManyAtJoinKeyGrain(
7915
+ const F = $.cteReason === "fanOutPrevention", k = this.shouldUseMaxForHasManyAtJoinKeyGrain(
7910
7916
  $,
7911
7917
  t,
7912
7918
  c
7913
- ), M = R || k;
7919
+ ), M = F || k;
7914
7920
  switch (S.type) {
7915
7921
  case "count":
7916
7922
  case "countDistinct":
7917
7923
  case "sum":
7918
- O = M ? V(D) : W(D);
7924
+ _ = M ? V(R) : K(R);
7919
7925
  break;
7920
7926
  case "avg":
7921
- O = M ? V(D) : this.databaseAdapter.buildAvg(D);
7927
+ _ = M ? V(R) : this.databaseAdapter.buildAvg(R);
7922
7928
  break;
7923
7929
  case "min":
7924
- O = re(D);
7930
+ _ = re(R);
7925
7931
  break;
7926
7932
  case "max":
7927
- O = V(D);
7933
+ _ = V(R);
7928
7934
  break;
7929
7935
  case "number":
7930
- O = M ? V(D) : W(D);
7936
+ _ = M ? V(R) : K(R);
7931
7937
  break;
7932
7938
  default:
7933
- O = M ? V(D) : W(D);
7939
+ _ = M ? V(R) : K(R);
7934
7940
  }
7935
7941
  }
7936
- m[E] = o`${O}`.as(E);
7942
+ m[T] = o`${_}`.as(T);
7937
7943
  }
7938
7944
  }
7939
- for (const E in m) {
7940
- const [T, N] = E.split(".");
7941
- if (T === C) {
7942
- const S = c.get(C), D = S && S.dimensions?.[N], O = E.startsWith(C + ".");
7943
- if (D || O) {
7944
- let R = $.joinKeys.find((k) => k.targetColumn === N);
7945
- if (!R && S?.dimensions?.[N]) {
7945
+ for (const T in m) {
7946
+ const [E, N] = T.split(".");
7947
+ if (E === C) {
7948
+ const S = c.get(C), R = S && S.dimensions?.[N], _ = T.startsWith(C + ".");
7949
+ if (R || _) {
7950
+ let F = $.joinKeys.find((k) => k.targetColumn === N);
7951
+ if (!F && S?.dimensions?.[N]) {
7946
7952
  const k = S.dimensions[N].sql;
7947
- R = $.joinKeys.find((M) => M.targetColumnObj === k);
7953
+ F = $.joinKeys.find((M) => M.targetColumnObj === k);
7948
7954
  }
7949
- R ? m[E] = o`${o.identifier($.cteAlias)}.${o.identifier(N)}`.as(E) : O && S?.dimensions?.[N] && (m[E] = o`${o.identifier($.cteAlias)}.${o.identifier(N)}`.as(E));
7955
+ F ? m[T] = o`${o.identifier($.cteAlias)}.${o.identifier(N)}`.as(T) : _ && S?.dimensions?.[N] && (m[T] = o`${o.identifier($.cteAlias)}.${o.identifier(N)}`.as(T));
7950
7956
  }
7951
7957
  }
7952
7958
  }
7953
7959
  }
7954
7960
  if (t.measures)
7955
7961
  for (const $ of t.measures) {
7956
- const [C, E] = $.split("."), T = c.get(C);
7957
- if (T?.measures?.[E]) {
7958
- const N = T.measures[E];
7962
+ const [C, T] = $.split("."), E = c.get(C);
7963
+ if (E?.measures?.[T]) {
7964
+ const N = E.measures[T];
7959
7965
  if (I.isPostAggregationWindow(N)) {
7960
7966
  const S = I.getWindowBaseMeasure(N, C);
7961
7967
  if (S) {
7962
- const [D, O] = S.split("."), R = c.get(D);
7963
- if (R?.measures?.[O]) {
7964
- const k = R.measures[O], M = e.preAggregationCTEs?.find(
7965
- (H) => H.cube?.name === D && H.measures?.includes(S)
7968
+ const [R, _] = S.split("."), F = c.get(R);
7969
+ if (F?.measures?.[_]) {
7970
+ const k = F.measures[_], M = e.preAggregationCTEs?.find(
7971
+ (H) => H.cube?.name === R && H.measures?.includes(S)
7966
7972
  );
7967
7973
  let z;
7968
7974
  if (M) {
7969
- const H = o`${o.identifier(M.cteAlias)}.${o.identifier(O)}`;
7975
+ const H = o`${o.identifier(M.cteAlias)}.${o.identifier(_)}`;
7970
7976
  z = o`sum(${H})`;
7971
7977
  } else
7972
- z = this.queryBuilder.buildMeasureExpression(k, n, R);
7978
+ z = this.queryBuilder.buildMeasureExpression(k, n, F);
7973
7979
  m[S] || (m[S] = o`${z}`.as(S));
7974
7980
  const se = this.buildPostAggregationWindowExpression(
7975
7981
  N,
7976
7982
  z,
7977
7983
  t,
7978
7984
  n,
7979
- T,
7985
+ E,
7980
7986
  e
7981
7987
  );
7982
7988
  se && (m[$] = o`${se}`.as($));
@@ -8015,61 +8021,61 @@ class J {
8015
8021
  const C = $.cube.name;
8016
8022
  if (g.has(C) && !r.has(C))
8017
8023
  continue;
8018
- const E = r.get($.cube.name);
8024
+ const T = r.get($.cube.name);
8019
8025
  if ($.junctionTable) {
8020
- const R = $.junctionTable, k = [];
8021
- if (R.securitySql) {
8022
- const M = R.securitySql(n.securityContext);
8026
+ const F = $.junctionTable, k = [];
8027
+ if (F.securitySql) {
8028
+ const M = F.securitySql(n.securityContext);
8023
8029
  Array.isArray(M) ? k.push(...M) : k.push(M);
8024
8030
  }
8025
8031
  try {
8026
- switch (R.joinType || "left") {
8032
+ switch (F.joinType || "left") {
8027
8033
  case "left":
8028
- f = f.leftJoin(R.table, R.joinCondition);
8034
+ f = f.leftJoin(F.table, F.joinCondition);
8029
8035
  break;
8030
8036
  case "inner":
8031
- f = f.innerJoin(R.table, R.joinCondition);
8037
+ f = f.innerJoin(F.table, F.joinCondition);
8032
8038
  break;
8033
8039
  case "right":
8034
- f = f.rightJoin(R.table, R.joinCondition);
8040
+ f = f.rightJoin(F.table, F.joinCondition);
8035
8041
  break;
8036
8042
  case "full":
8037
- f = f.fullJoin(R.table, R.joinCondition);
8043
+ f = f.fullJoin(F.table, F.joinCondition);
8038
8044
  break;
8039
8045
  }
8040
8046
  k.length > 0 && p.push(...k);
8041
8047
  } catch {
8042
8048
  }
8043
8049
  }
8044
- let T, N, S;
8045
- if (E)
8046
- T = o`${o.identifier(E)}`, N = this.cteBuilder.buildCTEJoinCondition($, E, e), S = void 0;
8050
+ let E, N, S;
8051
+ if (T)
8052
+ E = o`${o.identifier(T)}`, N = this.cteBuilder.buildCTEJoinCondition($, T, e), S = void 0;
8047
8053
  else {
8048
- const R = a.get($.cube.name), k = $.cube.sql(n);
8049
- if (T = k.from, S = k.where, R) {
8054
+ const F = a.get($.cube.name), k = $.cube.sql(n);
8055
+ if (E = k.from, S = k.where, F) {
8050
8056
  const M = [];
8051
- for (const z of R.joinKeys) {
8052
- const se = o`${o.identifier(R.cteAlias)}.${o.identifier(z.sourceColumn)}`, H = z.targetColumnObj || o.identifier(z.targetColumn);
8053
- M.push(P(se, H));
8057
+ for (const z of F.joinKeys) {
8058
+ const se = o`${o.identifier(F.cteAlias)}.${o.identifier(z.sourceColumn)}`, H = z.targetColumnObj || o.identifier(z.targetColumn);
8059
+ M.push(Q(se, H));
8054
8060
  }
8055
- N = M.length === 1 ? M[0] : A(...M);
8061
+ N = M.length === 1 ? M[0] : D(...M);
8056
8062
  } else
8057
8063
  N = $.joinCondition;
8058
8064
  }
8059
- const D = $.joinType || "left", O = D !== "inner" && S ? A(N, S) : N;
8065
+ const R = $.joinType || "left", _ = R !== "inner" && S ? D(N, S) : N;
8060
8066
  try {
8061
- switch (D) {
8067
+ switch (R) {
8062
8068
  case "left":
8063
- f = f.leftJoin(T, O), S && h.add($.cube.name);
8069
+ f = f.leftJoin(E, _), S && h.add($.cube.name);
8064
8070
  break;
8065
8071
  case "inner":
8066
- f = f.innerJoin(T, N);
8072
+ f = f.innerJoin(E, N);
8067
8073
  break;
8068
8074
  case "right":
8069
- f = f.rightJoin(T, O), S && h.add($.cube.name);
8075
+ f = f.rightJoin(E, _), S && h.add($.cube.name);
8070
8076
  break;
8071
8077
  case "full":
8072
- f = f.fullJoin(T, O), S && h.add($.cube.name);
8078
+ f = f.fullJoin(E, _), S && h.add($.cube.name);
8073
8079
  break;
8074
8080
  }
8075
8081
  } catch {
@@ -8080,8 +8086,8 @@ class J {
8080
8086
  const C = $.cube.name;
8081
8087
  if (r.get(C) || g.has(C) || h.has(C))
8082
8088
  continue;
8083
- const T = $.cube.sql(n);
8084
- T.where && p.push(T.where);
8089
+ const E = $.cube.sql(n);
8090
+ E.where && p.push(E.where);
8085
8091
  }
8086
8092
  const y = this.queryBuilder.buildWhereConditions(
8087
8093
  e.joinCubes.length > 0 ? this.getCubesFromPlan(e) : e.primaryCube,
@@ -8094,7 +8100,7 @@ class J {
8094
8100
  // Reuse pre-built filters for parameter deduplication
8095
8101
  );
8096
8102
  if (y.length > 0 && p.push(...y), p.length > 0) {
8097
- const $ = p.length === 1 ? p[0] : A(...p);
8103
+ const $ = p.length === 1 ? p[0] : D(...p);
8098
8104
  f = f.where($);
8099
8105
  }
8100
8106
  const b = this.queryBuilder.buildGroupByFields(
@@ -8115,11 +8121,11 @@ class J {
8115
8121
  // Pass the queryPlan to handle CTE scenarios
8116
8122
  );
8117
8123
  if (w.length > 0) {
8118
- const $ = w.length === 1 ? w[0] : A(...w);
8124
+ const $ = w.length === 1 ? w[0] : D(...w);
8119
8125
  f = f.having($);
8120
8126
  }
8121
- const _ = this.queryBuilder.buildOrderBy(t);
8122
- return _.length > 0 && (f = f.orderBy(..._)), f = this.queryBuilder.applyLimitAndOffset(f, t), f;
8127
+ const A = this.queryBuilder.buildOrderBy(t);
8128
+ return A.length > 0 && (f = f.orderBy(...A)), f = this.queryBuilder.applyLimitAndOffset(f, t), f;
8123
8129
  }
8124
8130
  /**
8125
8131
  * Convert query plan to cube map for QueryBuilder methods
@@ -8377,15 +8383,15 @@ class J {
8377
8383
  const h = f.field.includes(".") ? f.field.split(".")[1] : f.field;
8378
8384
  if (n.timeDimensions)
8379
8385
  for (const b of n.timeDimensions) {
8380
- const [w, _] = b.dimension.split(".");
8381
- if (_ === h) {
8386
+ const [w, A] = b.dimension.split(".");
8387
+ if (A === h) {
8382
8388
  const $ = u(w, h);
8383
8389
  if ($)
8384
8390
  return {
8385
8391
  field: $,
8386
8392
  direction: f.direction
8387
8393
  };
8388
- const C = i.dimensions?.[_];
8394
+ const C = i.dimensions?.[A];
8389
8395
  if (C)
8390
8396
  return {
8391
8397
  field: this.queryBuilder.buildTimeDimensionExpression(
@@ -8812,7 +8818,7 @@ const bn = {
8812
8818
  Cn,
8813
8819
  wn
8814
8820
  ];
8815
- function En() {
8821
+ function Tn() {
8816
8822
  return $n;
8817
8823
  }
8818
8824
  class lt {
@@ -8856,7 +8862,7 @@ class lt {
8856
8862
  * Validates calculated measures during registration
8857
8863
  */
8858
8864
  registerCube(e) {
8859
- e.meta && console.log(`[DEBUG] registerCube: ${e.name} has meta:`, JSON.stringify(e.meta)), this.validateCalculatedMeasures(e), new G(this.cubes).populateDependencies(e), this.cubes.set(e.name, e), this.invalidateMetadataCache();
8865
+ this.validateCalculatedMeasures(e), new G(this.cubes).populateDependencies(e), this.cubes.set(e.name, e), this.invalidateMetadataCache();
8860
8866
  }
8861
8867
  /**
8862
8868
  * Validate calculated measures in a cube
@@ -9043,7 +9049,7 @@ ${t.join(`
9043
9049
  // Convert level names to full qualified names
9044
9050
  levels: c.levels.map((l) => l.includes(".") ? l : `${e.name}.${l}`)
9045
9051
  });
9046
- const u = {
9052
+ return {
9047
9053
  name: e.name,
9048
9054
  title: e.title || e.name,
9049
9055
  description: e.description,
@@ -9056,7 +9062,6 @@ ${t.join(`
9056
9062
  hierarchies: a.length > 0 ? a : void 0,
9057
9063
  meta: e.meta
9058
9064
  };
9059
- return e.meta && console.log(`[DEBUG] Cube ${e.name} has meta:`, JSON.stringify(e.meta)), u;
9060
9065
  }
9061
9066
  /**
9062
9067
  * Get SQL for a query without executing it (debugging)
@@ -9210,7 +9215,7 @@ function ct(d, e) {
9210
9215
  return { isValid: t.length === 0, errors: t };
9211
9216
  }
9212
9217
  if (e.retention !== void 0 && e.retention.timeDimension != null && e.retention.bindingKey != null) {
9213
- const s = Tn(e.retention.timeDimension);
9218
+ const s = En(e.retention.timeDimension);
9214
9219
  s && !d.has(s) && t.push(`Retention cube not found: ${s}`);
9215
9220
  const i = e.retention.bindingKey;
9216
9221
  if (typeof i == "string") {
@@ -9304,7 +9309,7 @@ function dt(d, e, t, n) {
9304
9309
  }
9305
9310
  !r.dimensions[i] && !r.measures[i] && t.push(`Filter field '${i}' not found on cube '${s}' (must be a dimension or measure)`);
9306
9311
  }
9307
- function Tn(d) {
9312
+ function En(d) {
9308
9313
  if (typeof d == "string") {
9309
9314
  const [e] = d.split(".");
9310
9315
  return e || null;
@@ -9623,7 +9628,7 @@ function Se(d) {
9623
9628
  isError: !1
9624
9629
  };
9625
9630
  }
9626
- const ft = En(), pt = [
9631
+ const ft = Tn(), pt = [
9627
9632
  {
9628
9633
  uri: "drizzle-cube://quickstart",
9629
9634
  name: "Drizzle Cube MCP Quickstart",