drizzle-cube 0.3.28 → 0.3.30
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.
- package/dist/adapters/express/index.cjs +1 -1
- package/dist/adapters/express/index.js +1 -1
- package/dist/adapters/fastify/index.cjs +1 -1
- package/dist/adapters/fastify/index.js +1 -1
- package/dist/adapters/hono/index.cjs +1 -1
- package/dist/adapters/hono/index.js +1 -1
- package/dist/adapters/{mcp-transport-ConlvewL.cjs → mcp-transport-BOb26Vbq.cjs} +2 -2
- package/dist/adapters/{mcp-transport-CXGL1hg7.js → mcp-transport-DkdMX4bA.js} +99 -100
- package/dist/adapters/nextjs/index.cjs +1 -1
- package/dist/adapters/nextjs/index.js +1 -1
- package/dist/adapters/utils.cjs +1 -1
- package/dist/adapters/utils.js +3 -3
- package/dist/client/charts.js +12 -12
- package/dist/client/chunks/{DashboardEditModal-t5XeTZom.js → DashboardEditModal-rLcmZpe_.js} +8 -8
- package/dist/client/chunks/{DashboardEditModal-t5XeTZom.js.map → DashboardEditModal-rLcmZpe_.js.map} +1 -1
- package/dist/client/chunks/{RetentionCombinedChart-SsBGHJWi.js → RetentionCombinedChart-7bGP_ozM.js} +2 -2
- package/dist/client/chunks/{RetentionCombinedChart-SsBGHJWi.js.map → RetentionCombinedChart-7bGP_ozM.js.map} +1 -1
- package/dist/client/chunks/{analysis-builder-CKVYG9jJ.js → analysis-builder-DCt5C58c.js} +8 -8
- package/dist/client/chunks/{analysis-builder-CKVYG9jJ.js.map → analysis-builder-DCt5C58c.js.map} +1 -1
- package/dist/client/chunks/{analysis-builder-shared-CF8Vx1oD.js → analysis-builder-shared-ysrRYGiU.js} +7 -7
- package/dist/client/chunks/{analysis-builder-shared-CF8Vx1oD.js.map → analysis-builder-shared-ysrRYGiU.js.map} +1 -1
- package/dist/client/chunks/{chart-activity-grid-Bpu_-8uT.js → chart-activity-grid-sUkuCJzm.js} +2 -2
- package/dist/client/chunks/{chart-activity-grid-Bpu_-8uT.js.map → chart-activity-grid-sUkuCJzm.js.map} +1 -1
- package/dist/client/chunks/{chart-area-DcvLkvGb.js → chart-area-C4DIi9k_.js} +3 -3
- package/dist/client/chunks/{chart-area-DcvLkvGb.js.map → chart-area-C4DIi9k_.js.map} +1 -1
- package/dist/client/chunks/{chart-bar-CNfm5iMY.js → chart-bar-7ZleGCsN.js} +2 -2
- package/dist/client/chunks/{chart-bar-CNfm5iMY.js.map → chart-bar-7ZleGCsN.js.map} +1 -1
- package/dist/client/chunks/{chart-bubble-KA-RYWR8.js → chart-bubble-D-auWIjP.js} +2 -2
- package/dist/client/chunks/{chart-bubble-KA-RYWR8.js.map → chart-bubble-D-auWIjP.js.map} +1 -1
- package/dist/client/chunks/{chart-data-table-Cq14arji.js → chart-data-table-DW6VNGeW.js} +3 -3
- package/dist/client/chunks/{chart-data-table-Cq14arji.js.map → chart-data-table-DW6VNGeW.js.map} +1 -1
- package/dist/client/chunks/{chart-funnel-DFKWS49U.js → chart-funnel-eUJApzmA.js} +2 -2
- package/dist/client/chunks/{chart-funnel-DFKWS49U.js.map → chart-funnel-eUJApzmA.js.map} +1 -1
- package/dist/client/chunks/{chart-heat-map-D2g0dbKz.js → chart-heat-map-DR3O3GXx.js} +2 -2
- package/dist/client/chunks/{chart-heat-map-D2g0dbKz.js.map → chart-heat-map-DR3O3GXx.js.map} +1 -1
- package/dist/client/chunks/{chart-kpi-delta-Cc-jiBd0.js → chart-kpi-delta-Bp9Yrgyc.js} +3 -3
- package/dist/client/chunks/{chart-kpi-delta-Cc-jiBd0.js.map → chart-kpi-delta-Bp9Yrgyc.js.map} +1 -1
- package/dist/client/chunks/{chart-kpi-number-BXolYaZA.js → chart-kpi-number-B3yvgbr-.js} +2 -2
- package/dist/client/chunks/{chart-kpi-number-BXolYaZA.js.map → chart-kpi-number-B3yvgbr-.js.map} +1 -1
- package/dist/client/chunks/{chart-kpi-text-PA8oyypA.js → chart-kpi-text-D0TsUiaO.js} +3 -3
- package/dist/client/chunks/{chart-kpi-text-PA8oyypA.js.map → chart-kpi-text-D0TsUiaO.js.map} +1 -1
- package/dist/client/chunks/{chart-line-BOrtUdOD.js → chart-line-C7VStgaJ.js} +3 -3
- package/dist/client/chunks/{chart-line-BOrtUdOD.js.map → chart-line-C7VStgaJ.js.map} +1 -1
- package/dist/client/chunks/{chart-pie-B-Sbsvd2.js → chart-pie-DPdYJSM3.js} +2 -2
- package/dist/client/chunks/{chart-pie-B-Sbsvd2.js.map → chart-pie-DPdYJSM3.js.map} +1 -1
- package/dist/client/chunks/{chart-radar-CezgvXhm.js → chart-radar-DF6VNSiC.js} +2 -2
- package/dist/client/chunks/{chart-radar-CezgvXhm.js.map → chart-radar-DF6VNSiC.js.map} +1 -1
- package/dist/client/chunks/{chart-radial-bar-COBPiBxm.js → chart-radial-bar-7Ttfz-kO.js} +2 -2
- package/dist/client/chunks/{chart-radial-bar-COBPiBxm.js.map → chart-radial-bar-7Ttfz-kO.js.map} +1 -1
- package/dist/client/chunks/{chart-sankey-O4WQBRDk.js → chart-sankey-D86RYk9B.js} +2 -2
- package/dist/client/chunks/{chart-sankey-O4WQBRDk.js.map → chart-sankey-D86RYk9B.js.map} +1 -1
- package/dist/client/chunks/{chart-scatter-BVF0n9DR.js → chart-scatter-BUnIiLr_.js} +2 -2
- package/dist/client/chunks/{chart-scatter-BVF0n9DR.js.map → chart-scatter-BUnIiLr_.js.map} +1 -1
- package/dist/client/chunks/{chart-sunburst-DZzVj_6S.js → chart-sunburst-CsHlHfZQ.js} +2 -2
- package/dist/client/chunks/{chart-sunburst-DZzVj_6S.js.map → chart-sunburst-CsHlHfZQ.js.map} +1 -1
- package/dist/client/chunks/{chart-tree-map-CeEtNuo6.js → chart-tree-map-DFAbkeo1.js} +2 -2
- package/dist/client/chunks/{chart-tree-map-CeEtNuo6.js.map → chart-tree-map-DFAbkeo1.js.map} +1 -1
- package/dist/client/chunks/{charts-core-DF99lItO.js → charts-core-DAF1iT_h.js} +2 -2
- package/dist/client/chunks/{charts-core-DF99lItO.js.map → charts-core-DAF1iT_h.js.map} +1 -1
- package/dist/client/chunks/{charts-loader-AkRviD9H.js → charts-loader-7pEaEz-f.js} +20 -20
- package/dist/client/chunks/{charts-loader-AkRviD9H.js.map → charts-loader-7pEaEz-f.js.map} +1 -1
- package/dist/client/chunks/{core-Bso4ultM.js → core-DGLxd5v5.js} +2 -2
- package/dist/client/chunks/{core-Bso4ultM.js.map → core-DGLxd5v5.js.map} +1 -1
- package/dist/client/chunks/{hooks-B69r8rwU.js → hooks-CdyIO1-j.js} +4 -4
- package/dist/client/chunks/{hooks-B69r8rwU.js.map → hooks-CdyIO1-j.js.map} +1 -1
- package/dist/client/chunks/{providers-CxlSRYvE.js → providers-D2xswCYu.js} +2 -2
- package/dist/client/chunks/{providers-CxlSRYvE.js.map → providers-D2xswCYu.js.map} +1 -1
- package/dist/client/chunks/{syntaxHighlighting-yTdSle2t.js → syntaxHighlighting-DAT9C6Ss.js} +2 -2
- package/dist/client/chunks/{syntaxHighlighting-yTdSle2t.js.map → syntaxHighlighting-DAT9C6Ss.js.map} +1 -1
- package/dist/client/chunks/{useDirtyStateTracking-GZtwGRu7.js → useDirtyStateTracking-CTS_m9mg.js} +3 -3
- package/dist/client/chunks/{useDirtyStateTracking-GZtwGRu7.js.map → useDirtyStateTracking-CTS_m9mg.js.map} +1 -1
- package/dist/client/chunks/{vendor-B_H-VRhj.js → vendor-DfDLOfBe.js} +2 -2
- package/dist/client/chunks/vendor-DfDLOfBe.js.map +1 -0
- package/dist/client/components.js +2 -2
- package/dist/client/hooks.js +3 -3
- package/dist/client/index.js +9 -9
- package/dist/client/providers.js +1 -1
- package/dist/client/styles.css +1 -1
- package/dist/client/utils.js +6 -6
- package/dist/client-bundle-stats.html +34 -33
- package/dist/server/index.cjs +3 -3
- package/dist/server/index.js +5 -6
- package/package.json +1 -1
- package/dist/client/chunks/vendor-B_H-VRhj.js.map +0 -1
|
@@ -441,7 +441,7 @@ function ie(...d) {
|
|
|
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
|
|
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
|
|
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
|
|
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");
|
|
@@ -2957,9 +2957,9 @@ 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
|
|
2960
|
+
return Te(e, u);
|
|
2961
2961
|
}
|
|
2962
|
-
return
|
|
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
2965
|
return P(e, u);
|
|
@@ -3023,7 +3023,7 @@ class he {
|
|
|
3023
3023
|
we(e, r[1])
|
|
3024
3024
|
) : null;
|
|
3025
3025
|
case "in":
|
|
3026
|
-
return r.length > 0 ?
|
|
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":
|
|
@@ -3049,11 +3049,11 @@ class he {
|
|
|
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" ?
|
|
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" ?
|
|
3056
|
+
return this.databaseAdapter.getEngineType() === "postgres" ? Et(e, r) : null;
|
|
3057
3057
|
default:
|
|
3058
3058
|
return null;
|
|
3059
3059
|
}
|
|
@@ -3392,7 +3392,7 @@ function nn(d) {
|
|
|
3392
3392
|
errors: e
|
|
3393
3393
|
};
|
|
3394
3394
|
}
|
|
3395
|
-
function
|
|
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),
|
|
3431
|
+
G.isCalculatedMeasure(h) ? (a.push(l), Ee(h.calculatedSql, m).forEach((b) => u.add(b)), c.getAllDependencies(l).forEach((b) => {
|
|
3432
3432
|
const [w, _] = b.split("."), $ = t.get(w);
|
|
3433
3433
|
if ($ && $.measures[_]) {
|
|
3434
3434
|
const C = $.measures[_];
|
|
3435
|
-
G.isCalculatedMeasure(C) &&
|
|
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 =
|
|
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]) {
|
|
@@ -4757,12 +4757,12 @@ class at {
|
|
|
4757
4757
|
targetColumnObj: D.target
|
|
4758
4758
|
})), _ = void 0;
|
|
4759
4759
|
}
|
|
4760
|
-
const $ = this.findPropagatingFilters(s, l, e), C = /* @__PURE__ */ new Map([[l.name, l]]), { aggregateMeasures:
|
|
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
|
-
...
|
|
4765
|
-
...Array.from(
|
|
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(
|
|
@@ -5439,48 +5439,48 @@ class on {
|
|
|
5439
5439
|
buildPreAggregationCTE(e, t, n, s, i) {
|
|
5440
5440
|
const r = e.cube, a = r.sql(n), u = e.intermediateJoins && e.intermediateJoins.length > 0, c = {};
|
|
5441
5441
|
if (u && e.intermediateJoins) {
|
|
5442
|
-
const
|
|
5443
|
-
if (
|
|
5444
|
-
const
|
|
5445
|
-
c[
|
|
5442
|
+
const T = e.intermediateJoins[0].primaryJoinColumn;
|
|
5443
|
+
if (T) {
|
|
5444
|
+
const E = T.name;
|
|
5445
|
+
c[E] = T;
|
|
5446
5446
|
}
|
|
5447
5447
|
} else
|
|
5448
5448
|
for (const C of e.joinKeys)
|
|
5449
5449
|
if (C.targetColumnObj) {
|
|
5450
5450
|
c[C.targetColumn] = C.targetColumnObj;
|
|
5451
|
-
for (const [
|
|
5452
|
-
|
|
5451
|
+
for (const [T, E] of Object.entries(r.dimensions || {}))
|
|
5452
|
+
E.sql === C.targetColumnObj && T !== C.targetColumn && (c[T] = o`${C.targetColumnObj}`.as(T));
|
|
5453
5453
|
}
|
|
5454
5454
|
if (e.downstreamJoinKeys)
|
|
5455
5455
|
for (const C of e.downstreamJoinKeys)
|
|
5456
|
-
for (const
|
|
5457
|
-
|
|
5456
|
+
for (const T of C.joinKeys)
|
|
5457
|
+
T.sourceColumnObj && (c[T.sourceColumn] = T.sourceColumnObj);
|
|
5458
5458
|
const l = r.name, m = /* @__PURE__ */ new Map([[l, r]]), p = this.queryBuilder.buildResolvedMeasures(
|
|
5459
5459
|
e.measures,
|
|
5460
5460
|
m,
|
|
5461
5461
|
n
|
|
5462
5462
|
);
|
|
5463
5463
|
for (const C of e.measures) {
|
|
5464
|
-
const [,
|
|
5465
|
-
if (
|
|
5466
|
-
const N =
|
|
5467
|
-
c[
|
|
5464
|
+
const [, T] = C.split("."), E = p.get(C);
|
|
5465
|
+
if (E) {
|
|
5466
|
+
const N = E();
|
|
5467
|
+
c[T] = o`${N}`.as(T);
|
|
5468
5468
|
}
|
|
5469
5469
|
}
|
|
5470
5470
|
if (t.dimensions)
|
|
5471
5471
|
for (const C of t.dimensions) {
|
|
5472
|
-
const [
|
|
5473
|
-
if (
|
|
5474
|
-
const N = r.dimensions[
|
|
5475
|
-
c[
|
|
5472
|
+
const [T, E] = C.split(".");
|
|
5473
|
+
if (T === l && r.dimensions && r.dimensions[E]) {
|
|
5474
|
+
const N = r.dimensions[E], S = this.queryBuilder.buildMeasureExpression({ sql: N.sql, type: "number" }, n);
|
|
5475
|
+
c[E] = o`${S}`.as(E);
|
|
5476
5476
|
}
|
|
5477
5477
|
}
|
|
5478
5478
|
if (t.timeDimensions)
|
|
5479
5479
|
for (const C of t.timeDimensions) {
|
|
5480
|
-
const [
|
|
5481
|
-
if (
|
|
5482
|
-
const N = r.dimensions[
|
|
5483
|
-
c[
|
|
5480
|
+
const [T, E] = C.dimension.split(".");
|
|
5481
|
+
if (T === l && r.dimensions && r.dimensions[E]) {
|
|
5482
|
+
const N = r.dimensions[E], S = this.queryBuilder.buildTimeDimensionExpression(N.sql, C.granularity, n);
|
|
5483
|
+
c[E] = o`${S}`.as(E);
|
|
5484
5484
|
}
|
|
5485
5485
|
}
|
|
5486
5486
|
if (Object.keys(c).length === 0)
|
|
@@ -5488,9 +5488,9 @@ class on {
|
|
|
5488
5488
|
let f = n.db.select(c).from(a.from);
|
|
5489
5489
|
if (u && e.intermediateJoins)
|
|
5490
5490
|
for (const C of e.intermediateJoins) {
|
|
5491
|
-
const
|
|
5491
|
+
const T = C.cube.sql(n), N = [P(C.cteJoinColumn, C.joinDef.on[0]?.target)];
|
|
5492
5492
|
C.securityFilter && N.push(C.securityFilter), f = f.leftJoin(
|
|
5493
|
-
|
|
5493
|
+
T.from,
|
|
5494
5494
|
A(...N)
|
|
5495
5495
|
);
|
|
5496
5496
|
}
|
|
@@ -5500,20 +5500,20 @@ class on {
|
|
|
5500
5500
|
} : void 0, g = this.queryBuilder.buildWhereConditions(r, t, n, h, i), y = [];
|
|
5501
5501
|
if (t.timeDimensions)
|
|
5502
5502
|
for (const C of t.timeDimensions) {
|
|
5503
|
-
const [
|
|
5504
|
-
if (
|
|
5505
|
-
const N = r.dimensions[
|
|
5503
|
+
const [T, E] = C.dimension.split(".");
|
|
5504
|
+
if (T === l && r.dimensions && r.dimensions[E] && C.dateRange) {
|
|
5505
|
+
const N = r.dimensions[E], S = this.queryBuilder.buildMeasureExpression({ sql: N.sql, type: "number" }, n), D = this.queryBuilder.buildDateRangeCondition(S, C.dateRange);
|
|
5506
5506
|
D && y.push(D);
|
|
5507
5507
|
}
|
|
5508
5508
|
}
|
|
5509
5509
|
if (t.filters) {
|
|
5510
5510
|
for (const C of t.filters)
|
|
5511
5511
|
if (!("and" in C) && !("or" in C) && "member" in C && "operator" in C) {
|
|
5512
|
-
const
|
|
5513
|
-
if (
|
|
5512
|
+
const T = C, [E, N] = T.member.split(".");
|
|
5513
|
+
if (E === l && r.dimensions && r.dimensions[N]) {
|
|
5514
5514
|
const S = r.dimensions[N];
|
|
5515
|
-
if (
|
|
5516
|
-
const D = this.queryBuilder.buildMeasureExpression({ sql: S.sql, type: "number" }, n), O = this.queryBuilder.buildDateRangeCondition(D,
|
|
5515
|
+
if (T.operator === "inDateRange") {
|
|
5516
|
+
const D = this.queryBuilder.buildMeasureExpression({ sql: S.sql, type: "number" }, n), O = this.queryBuilder.buildDateRangeCondition(D, T.values);
|
|
5517
5517
|
O && y.push(O);
|
|
5518
5518
|
}
|
|
5519
5519
|
}
|
|
@@ -5521,11 +5521,11 @@ class on {
|
|
|
5521
5521
|
}
|
|
5522
5522
|
if (e.propagatingFilters && e.propagatingFilters.length > 0)
|
|
5523
5523
|
for (const C of e.propagatingFilters) {
|
|
5524
|
-
const
|
|
5524
|
+
const T = this.buildPropagatingFilterSubquery(
|
|
5525
5525
|
C,
|
|
5526
5526
|
n
|
|
5527
5527
|
);
|
|
5528
|
-
|
|
5528
|
+
T && y.push(T);
|
|
5529
5529
|
}
|
|
5530
5530
|
const b = [];
|
|
5531
5531
|
if (a.where && b.push(a.where), b.push(...g, ...y), b.length > 0) {
|
|
@@ -5533,8 +5533,8 @@ class on {
|
|
|
5533
5533
|
f = f.where(C);
|
|
5534
5534
|
}
|
|
5535
5535
|
const w = [], _ = /* @__PURE__ */ new Set(), $ = (C) => {
|
|
5536
|
-
const
|
|
5537
|
-
|
|
5536
|
+
const T = C?.name || (typeof C == "string" ? C : null);
|
|
5537
|
+
T && !_.has(T) ? (_.add(T), w.push(C)) : T || w.push(C);
|
|
5538
5538
|
};
|
|
5539
5539
|
if (u && e.intermediateJoins) {
|
|
5540
5540
|
const C = e.intermediateJoins[0];
|
|
@@ -5544,21 +5544,21 @@ class on {
|
|
|
5544
5544
|
C.targetColumnObj && $(C.targetColumnObj);
|
|
5545
5545
|
if (e.downstreamJoinKeys)
|
|
5546
5546
|
for (const C of e.downstreamJoinKeys)
|
|
5547
|
-
for (const
|
|
5548
|
-
|
|
5547
|
+
for (const T of C.joinKeys)
|
|
5548
|
+
T.sourceColumnObj && $(T.sourceColumnObj);
|
|
5549
5549
|
if (t.dimensions)
|
|
5550
5550
|
for (const C of t.dimensions) {
|
|
5551
|
-
const [
|
|
5552
|
-
if (
|
|
5553
|
-
const N = r.dimensions[
|
|
5551
|
+
const [T, E] = C.split(".");
|
|
5552
|
+
if (T === l && r.dimensions && r.dimensions[E]) {
|
|
5553
|
+
const N = r.dimensions[E], S = v(N.sql, n);
|
|
5554
5554
|
w.push(S);
|
|
5555
5555
|
}
|
|
5556
5556
|
}
|
|
5557
5557
|
if (t.timeDimensions)
|
|
5558
5558
|
for (const C of t.timeDimensions) {
|
|
5559
|
-
const [
|
|
5560
|
-
if (
|
|
5561
|
-
const N = r.dimensions[
|
|
5559
|
+
const [T, E] = C.dimension.split(".");
|
|
5560
|
+
if (T === l && r.dimensions && r.dimensions[E]) {
|
|
5561
|
+
const N = r.dimensions[E], S = this.queryBuilder.buildTimeDimensionExpression(N.sql, C.granularity, n);
|
|
5562
5562
|
w.push(S);
|
|
5563
5563
|
}
|
|
5564
5564
|
}
|
|
@@ -7520,8 +7520,8 @@ class J {
|
|
|
7520
7520
|
if (_.dimension in w) {
|
|
7521
7521
|
let $ = w[_.dimension];
|
|
7522
7522
|
if (typeof $ == "string" && $.match(/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/)) {
|
|
7523
|
-
const C = $.replace(" ", "T"),
|
|
7524
|
-
$ = new Date(
|
|
7523
|
+
const C = $.replace(" ", "T"), T = !C.endsWith("Z") && !C.includes("+") ? C + "Z" : C;
|
|
7524
|
+
$ = new Date(T);
|
|
7525
7525
|
}
|
|
7526
7526
|
$ = this.databaseAdapter.convertTimeDimensionResult($), w[_.dimension] = $;
|
|
7527
7527
|
}
|
|
@@ -7856,19 +7856,19 @@ class J {
|
|
|
7856
7856
|
for (const $ of e.preAggregationCTEs)
|
|
7857
7857
|
if ($.propagatingFilters && $.propagatingFilters.length > 0)
|
|
7858
7858
|
for (const C of $.propagatingFilters) {
|
|
7859
|
-
const
|
|
7860
|
-
if (!s.has(
|
|
7859
|
+
const T = C.sourceCube.name;
|
|
7860
|
+
if (!s.has(T)) {
|
|
7861
7861
|
const N = {
|
|
7862
7862
|
filters: C.filters
|
|
7863
|
-
}, S = /* @__PURE__ */ new Map([[
|
|
7863
|
+
}, S = /* @__PURE__ */ new Map([[T, C.sourceCube]]), D = this.queryBuilder.buildWhereConditions(
|
|
7864
7864
|
S,
|
|
7865
7865
|
N,
|
|
7866
7866
|
n
|
|
7867
7867
|
);
|
|
7868
|
-
s.set(
|
|
7868
|
+
s.set(T, D);
|
|
7869
7869
|
}
|
|
7870
|
-
const
|
|
7871
|
-
|
|
7870
|
+
const E = s.get(T);
|
|
7871
|
+
E && E.length > 0 && (C.preBuiltFilterSQL = E.length === 1 ? E[0] : A(...E));
|
|
7872
7872
|
}
|
|
7873
7873
|
}
|
|
7874
7874
|
const i = [], r = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map();
|
|
@@ -7876,10 +7876,10 @@ class J {
|
|
|
7876
7876
|
for (const $ of e.preAggregationCTEs) {
|
|
7877
7877
|
const C = this.cteBuilder.buildPreAggregationCTE($, t, n, e, s);
|
|
7878
7878
|
if (C && (i.push(C), r.set($.cube.name, $.cteAlias), $.downstreamJoinKeys))
|
|
7879
|
-
for (const
|
|
7880
|
-
a.set(
|
|
7879
|
+
for (const T of $.downstreamJoinKeys)
|
|
7880
|
+
a.set(T.targetCubeName, {
|
|
7881
7881
|
cteAlias: $.cteAlias,
|
|
7882
|
-
joinKeys:
|
|
7882
|
+
joinKeys: T.joinKeys
|
|
7883
7883
|
});
|
|
7884
7884
|
}
|
|
7885
7885
|
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,11 +7891,11 @@ class J {
|
|
|
7891
7891
|
if (e.preAggregationCTEs)
|
|
7892
7892
|
for (const $ of e.preAggregationCTEs) {
|
|
7893
7893
|
const C = $.cube.name;
|
|
7894
|
-
for (const
|
|
7895
|
-
if (m[
|
|
7896
|
-
const [,
|
|
7897
|
-
if (N && N.measures && N.measures[
|
|
7898
|
-
const S = N.measures[
|
|
7894
|
+
for (const T of $.measures)
|
|
7895
|
+
if (m[T]) {
|
|
7896
|
+
const [, E] = T.split("."), N = c.get(C);
|
|
7897
|
+
if (N && N.measures && N.measures[E]) {
|
|
7898
|
+
const S = N.measures[E], D = o`${o.identifier($.cteAlias)}.${o.identifier(E)}`;
|
|
7899
7899
|
let O;
|
|
7900
7900
|
if (S.type === "calculated" && S.calculatedSql)
|
|
7901
7901
|
O = this.queryBuilder.buildCTECalculatedMeasure(
|
|
@@ -7933,29 +7933,29 @@ class J {
|
|
|
7933
7933
|
O = M ? V(D) : W(D);
|
|
7934
7934
|
}
|
|
7935
7935
|
}
|
|
7936
|
-
m[
|
|
7936
|
+
m[T] = o`${O}`.as(T);
|
|
7937
7937
|
}
|
|
7938
7938
|
}
|
|
7939
|
-
for (const
|
|
7940
|
-
const [
|
|
7941
|
-
if (
|
|
7942
|
-
const S = c.get(C), D = S && S.dimensions?.[N], O =
|
|
7939
|
+
for (const T in m) {
|
|
7940
|
+
const [E, N] = T.split(".");
|
|
7941
|
+
if (E === C) {
|
|
7942
|
+
const S = c.get(C), D = S && S.dimensions?.[N], O = T.startsWith(C + ".");
|
|
7943
7943
|
if (D || O) {
|
|
7944
7944
|
let R = $.joinKeys.find((k) => k.targetColumn === N);
|
|
7945
7945
|
if (!R && S?.dimensions?.[N]) {
|
|
7946
7946
|
const k = S.dimensions[N].sql;
|
|
7947
7947
|
R = $.joinKeys.find((M) => M.targetColumnObj === k);
|
|
7948
7948
|
}
|
|
7949
|
-
R ? m[
|
|
7949
|
+
R ? m[T] = o`${o.identifier($.cteAlias)}.${o.identifier(N)}`.as(T) : O && S?.dimensions?.[N] && (m[T] = o`${o.identifier($.cteAlias)}.${o.identifier(N)}`.as(T));
|
|
7950
7950
|
}
|
|
7951
7951
|
}
|
|
7952
7952
|
}
|
|
7953
7953
|
}
|
|
7954
7954
|
if (t.measures)
|
|
7955
7955
|
for (const $ of t.measures) {
|
|
7956
|
-
const [C,
|
|
7957
|
-
if (
|
|
7958
|
-
const N =
|
|
7956
|
+
const [C, T] = $.split("."), E = c.get(C);
|
|
7957
|
+
if (E?.measures?.[T]) {
|
|
7958
|
+
const N = E.measures[T];
|
|
7959
7959
|
if (I.isPostAggregationWindow(N)) {
|
|
7960
7960
|
const S = I.getWindowBaseMeasure(N, C);
|
|
7961
7961
|
if (S) {
|
|
@@ -7976,7 +7976,7 @@ class J {
|
|
|
7976
7976
|
z,
|
|
7977
7977
|
t,
|
|
7978
7978
|
n,
|
|
7979
|
-
|
|
7979
|
+
E,
|
|
7980
7980
|
e
|
|
7981
7981
|
);
|
|
7982
7982
|
se && (m[$] = o`${se}`.as($));
|
|
@@ -8015,7 +8015,7 @@ class J {
|
|
|
8015
8015
|
const C = $.cube.name;
|
|
8016
8016
|
if (g.has(C) && !r.has(C))
|
|
8017
8017
|
continue;
|
|
8018
|
-
const
|
|
8018
|
+
const T = r.get($.cube.name);
|
|
8019
8019
|
if ($.junctionTable) {
|
|
8020
8020
|
const R = $.junctionTable, k = [];
|
|
8021
8021
|
if (R.securitySql) {
|
|
@@ -8041,12 +8041,12 @@ class J {
|
|
|
8041
8041
|
} catch {
|
|
8042
8042
|
}
|
|
8043
8043
|
}
|
|
8044
|
-
let
|
|
8045
|
-
if (
|
|
8046
|
-
|
|
8044
|
+
let E, N, S;
|
|
8045
|
+
if (T)
|
|
8046
|
+
E = o`${o.identifier(T)}`, N = this.cteBuilder.buildCTEJoinCondition($, T, e), S = void 0;
|
|
8047
8047
|
else {
|
|
8048
8048
|
const R = a.get($.cube.name), k = $.cube.sql(n);
|
|
8049
|
-
if (
|
|
8049
|
+
if (E = k.from, S = k.where, R) {
|
|
8050
8050
|
const M = [];
|
|
8051
8051
|
for (const z of R.joinKeys) {
|
|
8052
8052
|
const se = o`${o.identifier(R.cteAlias)}.${o.identifier(z.sourceColumn)}`, H = z.targetColumnObj || o.identifier(z.targetColumn);
|
|
@@ -8060,16 +8060,16 @@ class J {
|
|
|
8060
8060
|
try {
|
|
8061
8061
|
switch (D) {
|
|
8062
8062
|
case "left":
|
|
8063
|
-
f = f.leftJoin(
|
|
8063
|
+
f = f.leftJoin(E, O), S && h.add($.cube.name);
|
|
8064
8064
|
break;
|
|
8065
8065
|
case "inner":
|
|
8066
|
-
f = f.innerJoin(
|
|
8066
|
+
f = f.innerJoin(E, N);
|
|
8067
8067
|
break;
|
|
8068
8068
|
case "right":
|
|
8069
|
-
f = f.rightJoin(
|
|
8069
|
+
f = f.rightJoin(E, O), S && h.add($.cube.name);
|
|
8070
8070
|
break;
|
|
8071
8071
|
case "full":
|
|
8072
|
-
f = f.fullJoin(
|
|
8072
|
+
f = f.fullJoin(E, O), S && h.add($.cube.name);
|
|
8073
8073
|
break;
|
|
8074
8074
|
}
|
|
8075
8075
|
} catch {
|
|
@@ -8080,8 +8080,8 @@ class J {
|
|
|
8080
8080
|
const C = $.cube.name;
|
|
8081
8081
|
if (r.get(C) || g.has(C) || h.has(C))
|
|
8082
8082
|
continue;
|
|
8083
|
-
const
|
|
8084
|
-
|
|
8083
|
+
const E = $.cube.sql(n);
|
|
8084
|
+
E.where && p.push(E.where);
|
|
8085
8085
|
}
|
|
8086
8086
|
const y = this.queryBuilder.buildWhereConditions(
|
|
8087
8087
|
e.joinCubes.length > 0 ? this.getCubesFromPlan(e) : e.primaryCube,
|
|
@@ -8812,7 +8812,7 @@ const bn = {
|
|
|
8812
8812
|
Cn,
|
|
8813
8813
|
wn
|
|
8814
8814
|
];
|
|
8815
|
-
function
|
|
8815
|
+
function Tn() {
|
|
8816
8816
|
return $n;
|
|
8817
8817
|
}
|
|
8818
8818
|
class lt {
|
|
@@ -8856,7 +8856,7 @@ class lt {
|
|
|
8856
8856
|
* Validates calculated measures during registration
|
|
8857
8857
|
*/
|
|
8858
8858
|
registerCube(e) {
|
|
8859
|
-
|
|
8859
|
+
this.validateCalculatedMeasures(e), new G(this.cubes).populateDependencies(e), this.cubes.set(e.name, e), this.invalidateMetadataCache();
|
|
8860
8860
|
}
|
|
8861
8861
|
/**
|
|
8862
8862
|
* Validate calculated measures in a cube
|
|
@@ -9043,7 +9043,7 @@ ${t.join(`
|
|
|
9043
9043
|
// Convert level names to full qualified names
|
|
9044
9044
|
levels: c.levels.map((l) => l.includes(".") ? l : `${e.name}.${l}`)
|
|
9045
9045
|
});
|
|
9046
|
-
|
|
9046
|
+
return {
|
|
9047
9047
|
name: e.name,
|
|
9048
9048
|
title: e.title || e.name,
|
|
9049
9049
|
description: e.description,
|
|
@@ -9056,7 +9056,6 @@ ${t.join(`
|
|
|
9056
9056
|
hierarchies: a.length > 0 ? a : void 0,
|
|
9057
9057
|
meta: e.meta
|
|
9058
9058
|
};
|
|
9059
|
-
return e.meta && console.log(`[DEBUG] Cube ${e.name} has meta:`, JSON.stringify(e.meta)), u;
|
|
9060
9059
|
}
|
|
9061
9060
|
/**
|
|
9062
9061
|
* Get SQL for a query without executing it (debugging)
|
|
@@ -9210,7 +9209,7 @@ function ct(d, e) {
|
|
|
9210
9209
|
return { isValid: t.length === 0, errors: t };
|
|
9211
9210
|
}
|
|
9212
9211
|
if (e.retention !== void 0 && e.retention.timeDimension != null && e.retention.bindingKey != null) {
|
|
9213
|
-
const s =
|
|
9212
|
+
const s = En(e.retention.timeDimension);
|
|
9214
9213
|
s && !d.has(s) && t.push(`Retention cube not found: ${s}`);
|
|
9215
9214
|
const i = e.retention.bindingKey;
|
|
9216
9215
|
if (typeof i == "string") {
|
|
@@ -9304,7 +9303,7 @@ function dt(d, e, t, n) {
|
|
|
9304
9303
|
}
|
|
9305
9304
|
!r.dimensions[i] && !r.measures[i] && t.push(`Filter field '${i}' not found on cube '${s}' (must be a dimension or measure)`);
|
|
9306
9305
|
}
|
|
9307
|
-
function
|
|
9306
|
+
function En(d) {
|
|
9308
9307
|
if (typeof d == "string") {
|
|
9309
9308
|
const [e] = d.split(".");
|
|
9310
9309
|
return e || null;
|
|
@@ -9623,7 +9622,7 @@ function Se(d) {
|
|
|
9623
9622
|
isError: !1
|
|
9624
9623
|
};
|
|
9625
9624
|
}
|
|
9626
|
-
const ft =
|
|
9625
|
+
const ft = Tn(), pt = [
|
|
9627
9626
|
{
|
|
9628
9627
|
uri: "drizzle-cube://quickstart",
|
|
9629
9628
|
name: "Drizzle Cube MCP Quickstart",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("next/server"),l=require("../mcp-transport-ConlvewL.cjs"),c=require("../utils.cjs");function R(n){const{cubes:o,drizzle:s,schema:i,engineType:d,cache:a}=n;if(!o||o.length===0)throw new Error("At least one cube must be provided in the cubes array");const t=new l.SemanticLayerCompiler({drizzle:s,schema:i,engineType:d,cache:a});return o.forEach(e=>{t.registerCube(e)}),t}function h(n,o){const s=n.headers.get("origin"),i={};return o.origin&&(typeof o.origin=="string"?i["Access-Control-Allow-Origin"]=o.origin:Array.isArray(o.origin)?s&&o.origin.includes(s)&&(i["Access-Control-Allow-Origin"]=s):typeof o.origin=="function"&&s&&o.origin(s)&&(i["Access-Control-Allow-Origin"]=s)),o.methods&&(i["Access-Control-Allow-Methods"]=o.methods.join(", ")),o.allowedHeaders&&(i["Access-Control-Allow-Headers"]=o.allowedHeaders.join(", ")),o.credentials&&(i["Access-Control-Allow-Credentials"]="true"),i}function I(n){return async function(s){const i=h(s,n);return new Response(null,{status:200,headers:i})}}function M(n){const{extractSecurityContext:o,cors:s}=n,i=R(n);return async function(a,t){try{let e;if(a.method==="POST"){const N=await a.json();e=N.query||N}else if(a.method==="GET"){const N=a.nextUrl.searchParams.get("query");if(!N)return r.NextResponse.json(c.formatErrorResponse("Query parameter is required",400),{status:400});try{e=JSON.parse(N)}catch{return r.NextResponse.json(c.formatErrorResponse("Invalid JSON in query parameter",400),{status:400})}}else return r.NextResponse.json(c.formatErrorResponse("Method not allowed",405),{status:405});const u=await o(a,t),m=i.validateQuery(e);if(!m.isValid)return r.NextResponse.json(c.formatErrorResponse(`Query validation failed: ${m.errors.join(", ")}`,400),{status:400});const p=a.headers.get("x-cache-control")==="no-cache",f=await i.executeMultiCubeQuery(e,u,{skipCache:p}),j=c.formatCubeResponse(e,f,i);return r.NextResponse.json(j,{headers:s?h(a,s):{}})}catch(e){return process.env.NODE_ENV!=="test"&&console.error("Next.js load handler error:",e),r.NextResponse.json(c.formatErrorResponse(e instanceof Error?e.message:"Query execution failed",500),{status:500})}}}function T(n){const{cors:o}=n,s=R(n);return async function(d,a){try{const t=s.getMetadata(),e=c.formatMetaResponse(t);return r.NextResponse.json(e,{headers:o?h(d,o):{}})}catch(t){return process.env.NODE_ENV!=="test"&&console.error("Next.js meta handler error:",t),r.NextResponse.json(c.formatErrorResponse(t instanceof Error?t.message:"Failed to fetch metadata",500),{status:500})}}}function L(n){const{extractSecurityContext:o,cors:s}=n,i=R(n);return async function(a,t){try{let e;if(a.method==="POST"){const w=await a.json();e=w.query||w}else if(a.method==="GET"){const w=a.nextUrl.searchParams.get("query");if(!w)return r.NextResponse.json(c.formatErrorResponse("Query parameter is required",400),{status:400});try{e=JSON.parse(w)}catch{return r.NextResponse.json(c.formatErrorResponse("Invalid JSON in query parameter",400),{status:400})}}else return r.NextResponse.json(c.formatErrorResponse("Method not allowed",405),{status:405});const u=await o(a,t),m=i.validateQuery(e);if(!m.isValid)return r.NextResponse.json(c.formatErrorResponse(`Query validation failed: ${m.errors.join(", ")}`,400),{status:400});const p=e.measures?.[0]||e.dimensions?.[0];if(!p)return r.NextResponse.json(c.formatErrorResponse("No measures or dimensions specified",400),{status:400});const f=p.split(".")[0],j=await i.generateSQL(f,e,u),N=c.formatSqlResponse(e,j);return r.NextResponse.json(N,{headers:s?h(a,s):{}})}catch(e){return process.env.NODE_ENV!=="test"&&console.error("Next.js SQL handler error:",e),r.NextResponse.json(c.formatErrorResponse(e instanceof Error?e.message:"SQL generation failed",500),{status:500})}}}function D(n){const{extractSecurityContext:o,cors:s}=n,i=R(n);return async function(a,t){try{let e;if(a.method==="POST"){const p=await a.json();e=p.query||p}else if(a.method==="GET"){const p=a.nextUrl.searchParams.get("query");if(!p)return r.NextResponse.json({error:"Query parameter is required",valid:!1},{status:400});try{e=JSON.parse(p)}catch{return r.NextResponse.json({error:"Invalid JSON in query parameter",valid:!1},{status:400})}}else return r.NextResponse.json({error:"Method not allowed",valid:!1},{status:405});const u=await o(a,t),m=await c.handleDryRun(e,u,i);return r.NextResponse.json(m,{headers:s?h(a,s):{}})}catch(e){return process.env.NODE_ENV!=="test"&&console.error("Next.js dry-run handler error:",e),r.NextResponse.json({error:e instanceof Error?e.message:"Dry-run validation failed",valid:!1},{status:400})}}}function A(n){const{extractSecurityContext:o,cors:s}=n,i=R(n);return async function(a,t){try{if(a.method!=="POST")return r.NextResponse.json(c.formatErrorResponse("Method not allowed - use POST",405),{status:405});const e=await a.json(),{queries:u}=e;if(!u||!Array.isArray(u))return r.NextResponse.json(c.formatErrorResponse('Request body must contain a "queries" array',400),{status:400});if(u.length===0)return r.NextResponse.json(c.formatErrorResponse("Queries array cannot be empty",400),{status:400});const m=await o(a,t),p=a.headers.get("x-cache-control")==="no-cache",f=await c.handleBatchRequest(u,m,i,{skipCache:p});return r.NextResponse.json(f,{headers:s?h(a,s):{}})}catch(e){return process.env.NODE_ENV!=="test"&&console.error("Next.js batch handler error:",e),r.NextResponse.json(c.formatErrorResponse(e instanceof Error?e.message:"Batch execution failed",500),{status:500})}}}function Q(n){const{extractSecurityContext:o,cors:s}=n,i=R(n);return async function(a,t){try{if(a.method!=="POST")return r.NextResponse.json({error:"Method not allowed"},{status:405});const e=await a.json(),u=e.query||e,m=e.options||{},p=await o(a,t),f=i.validateQuery(u);if(!f.isValid)return r.NextResponse.json({error:`Query validation failed: ${f.errors.join(", ")}`},{status:400});const j=await i.explainQuery(u,p,m);return r.NextResponse.json(j,{headers:s?h(a,s):{}})}catch(e){return process.env.NODE_ENV!=="test"&&console.error("Next.js explain handler error:",e),r.NextResponse.json({error:e instanceof Error?e.message:"Explain query failed"},{status:500})}}}function J(n){const{cors:o}=n,s=R(n);return async function(d,a){try{if(d.method!=="POST")return r.NextResponse.json(c.formatErrorResponse("Method not allowed - use POST",405),{status:405});const t=await d.json(),e=await c.handleDiscover(s,t);return r.NextResponse.json(e,{headers:o?h(d,o):{}})}catch(t){return process.env.NODE_ENV!=="test"&&console.error("Next.js discover handler error:",t),r.NextResponse.json(c.formatErrorResponse(t instanceof Error?t.message:"Discovery failed",500),{status:500})}}}function q(n){const{cors:o}=n,s=R(n);return async function(d,a){try{if(d.method!=="POST")return r.NextResponse.json(c.formatErrorResponse("Method not allowed - use POST",405),{status:405});const t=await d.json();if(!t.naturalLanguage)return r.NextResponse.json(c.formatErrorResponse("naturalLanguage field is required",400),{status:400});const e=await c.handleSuggest(s,t);return r.NextResponse.json(e,{headers:o?h(d,o):{}})}catch(t){return process.env.NODE_ENV!=="test"&&console.error("Next.js suggest handler error:",t),r.NextResponse.json(c.formatErrorResponse(t instanceof Error?t.message:"Query suggestion failed",500),{status:500})}}}function z(n){const{cors:o}=n,s=R(n);return async function(d,a){try{if(d.method!=="POST")return r.NextResponse.json(c.formatErrorResponse("Method not allowed - use POST",405),{status:405});const t=await d.json();if(!t.query)return r.NextResponse.json(c.formatErrorResponse("query field is required",400),{status:400});const e=await c.handleValidate(s,t);return r.NextResponse.json(e,{headers:o?h(d,o):{}})}catch(t){return process.env.NODE_ENV!=="test"&&console.error("Next.js validate handler error:",t),r.NextResponse.json(c.formatErrorResponse(t instanceof Error?t.message:"Query validation failed",500),{status:500})}}}function k(n){const{extractSecurityContext:o,cors:s}=n,i=R(n);return async function(a,t){try{if(a.method!=="POST")return r.NextResponse.json(c.formatErrorResponse("Method not allowed - use POST",405),{status:405});const e=await a.json();if(!e.query)return r.NextResponse.json(c.formatErrorResponse("query field is required",400),{status:400});const u=await o(a,t),m=await c.handleLoad(i,u,e);return r.NextResponse.json(m,{headers:s?h(a,s):{}})}catch(e){return process.env.NODE_ENV!=="test"&&console.error("Next.js MCP load handler error:",e),r.NextResponse.json(c.formatErrorResponse(e instanceof Error?e.message:"Query execution failed",500),{status:500})}}}function V(n){const{extractSecurityContext:o,cors:s,mcp:i={enabled:!0}}=n,d=R(n);return async function(t){if(t.method==="DELETE")return r.NextResponse.json({error:"Session termination not supported"},{status:405});if(t.method==="GET"){const y=new TextEncoder,g=l.primeEventId(),E=new ReadableStream({start(x){x.enqueue(y.encode(l.serializeSseEvent({jsonrpc:"2.0",method:"mcp/ready",params:{protocol:"streamable-http"}},g,15e3)))}}),S=new Headers({"Content-Type":"text/event-stream","Cache-Control":"no-cache",Connection:"keep-alive"});if(s){const x=h(t,s);Object.entries(x).forEach(([H,b])=>S.set(H,b))}return new r.NextResponse(E,{status:200,headers:S})}if(t.method!=="POST")return r.NextResponse.json(c.formatErrorResponse("Method not allowed - use POST",405),{status:405});const e=l.validateOriginHeader(t.headers.get("origin"),i.allowedOrigins?{allowedOrigins:i.allowedOrigins}:{});if(!e.valid)return r.NextResponse.json(l.buildJsonRpcError(null,-32600,e.reason),{status:403});const u=t.headers.get("accept");if(!l.validateAcceptHeader(u))return r.NextResponse.json(l.buildJsonRpcError(null,-32600,"Accept header must include both application/json and text/event-stream"),{status:400});const m=l.negotiateProtocol(Object.fromEntries(t.headers.entries()));if(!m.ok)return r.NextResponse.json({error:"Unsupported MCP protocol version",supported:m.supported},{status:426});let p=null;try{p=await t.json()}catch{p=null}const f=l.parseJsonRpc(p);if(!f)return r.NextResponse.json(l.buildJsonRpcError(null,-32600,"Invalid JSON-RPC 2.0 request"),{status:400});const j=l.wantsEventStream(u),N=f.method==="initialize",w=(y,g=200,E={})=>r.NextResponse.json(y,{status:g,headers:{...s?h(t,s):{},...E}});try{const y=await l.dispatchMcpMethod(f.method,f.params,{semanticLayer:d,extractSecurityContext:x=>o(x),rawRequest:t,rawResponse:null});if(l.isNotification(f))return new r.NextResponse(null,{status:202});const g=N&&y&&typeof y=="object"&&"sessionId"in y?y.sessionId:void 0,E={};g&&(E[l.MCP_SESSION_ID_HEADER]=g);const S=l.buildJsonRpcResult(f.id??null,y);if(j){const x=new TextEncoder,H=l.primeEventId(),b=new ReadableStream({start(v){v.enqueue(x.encode(`id: ${H}
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("next/server"),l=require("../mcp-transport-BOb26Vbq.cjs"),c=require("../utils.cjs");function R(n){const{cubes:o,drizzle:s,schema:i,engineType:d,cache:a}=n;if(!o||o.length===0)throw new Error("At least one cube must be provided in the cubes array");const t=new l.SemanticLayerCompiler({drizzle:s,schema:i,engineType:d,cache:a});return o.forEach(e=>{t.registerCube(e)}),t}function h(n,o){const s=n.headers.get("origin"),i={};return o.origin&&(typeof o.origin=="string"?i["Access-Control-Allow-Origin"]=o.origin:Array.isArray(o.origin)?s&&o.origin.includes(s)&&(i["Access-Control-Allow-Origin"]=s):typeof o.origin=="function"&&s&&o.origin(s)&&(i["Access-Control-Allow-Origin"]=s)),o.methods&&(i["Access-Control-Allow-Methods"]=o.methods.join(", ")),o.allowedHeaders&&(i["Access-Control-Allow-Headers"]=o.allowedHeaders.join(", ")),o.credentials&&(i["Access-Control-Allow-Credentials"]="true"),i}function I(n){return async function(s){const i=h(s,n);return new Response(null,{status:200,headers:i})}}function M(n){const{extractSecurityContext:o,cors:s}=n,i=R(n);return async function(a,t){try{let e;if(a.method==="POST"){const N=await a.json();e=N.query||N}else if(a.method==="GET"){const N=a.nextUrl.searchParams.get("query");if(!N)return r.NextResponse.json(c.formatErrorResponse("Query parameter is required",400),{status:400});try{e=JSON.parse(N)}catch{return r.NextResponse.json(c.formatErrorResponse("Invalid JSON in query parameter",400),{status:400})}}else return r.NextResponse.json(c.formatErrorResponse("Method not allowed",405),{status:405});const u=await o(a,t),m=i.validateQuery(e);if(!m.isValid)return r.NextResponse.json(c.formatErrorResponse(`Query validation failed: ${m.errors.join(", ")}`,400),{status:400});const p=a.headers.get("x-cache-control")==="no-cache",f=await i.executeMultiCubeQuery(e,u,{skipCache:p}),j=c.formatCubeResponse(e,f,i);return r.NextResponse.json(j,{headers:s?h(a,s):{}})}catch(e){return process.env.NODE_ENV!=="test"&&console.error("Next.js load handler error:",e),r.NextResponse.json(c.formatErrorResponse(e instanceof Error?e.message:"Query execution failed",500),{status:500})}}}function T(n){const{cors:o}=n,s=R(n);return async function(d,a){try{const t=s.getMetadata(),e=c.formatMetaResponse(t);return r.NextResponse.json(e,{headers:o?h(d,o):{}})}catch(t){return process.env.NODE_ENV!=="test"&&console.error("Next.js meta handler error:",t),r.NextResponse.json(c.formatErrorResponse(t instanceof Error?t.message:"Failed to fetch metadata",500),{status:500})}}}function L(n){const{extractSecurityContext:o,cors:s}=n,i=R(n);return async function(a,t){try{let e;if(a.method==="POST"){const w=await a.json();e=w.query||w}else if(a.method==="GET"){const w=a.nextUrl.searchParams.get("query");if(!w)return r.NextResponse.json(c.formatErrorResponse("Query parameter is required",400),{status:400});try{e=JSON.parse(w)}catch{return r.NextResponse.json(c.formatErrorResponse("Invalid JSON in query parameter",400),{status:400})}}else return r.NextResponse.json(c.formatErrorResponse("Method not allowed",405),{status:405});const u=await o(a,t),m=i.validateQuery(e);if(!m.isValid)return r.NextResponse.json(c.formatErrorResponse(`Query validation failed: ${m.errors.join(", ")}`,400),{status:400});const p=e.measures?.[0]||e.dimensions?.[0];if(!p)return r.NextResponse.json(c.formatErrorResponse("No measures or dimensions specified",400),{status:400});const f=p.split(".")[0],j=await i.generateSQL(f,e,u),N=c.formatSqlResponse(e,j);return r.NextResponse.json(N,{headers:s?h(a,s):{}})}catch(e){return process.env.NODE_ENV!=="test"&&console.error("Next.js SQL handler error:",e),r.NextResponse.json(c.formatErrorResponse(e instanceof Error?e.message:"SQL generation failed",500),{status:500})}}}function D(n){const{extractSecurityContext:o,cors:s}=n,i=R(n);return async function(a,t){try{let e;if(a.method==="POST"){const p=await a.json();e=p.query||p}else if(a.method==="GET"){const p=a.nextUrl.searchParams.get("query");if(!p)return r.NextResponse.json({error:"Query parameter is required",valid:!1},{status:400});try{e=JSON.parse(p)}catch{return r.NextResponse.json({error:"Invalid JSON in query parameter",valid:!1},{status:400})}}else return r.NextResponse.json({error:"Method not allowed",valid:!1},{status:405});const u=await o(a,t),m=await c.handleDryRun(e,u,i);return r.NextResponse.json(m,{headers:s?h(a,s):{}})}catch(e){return process.env.NODE_ENV!=="test"&&console.error("Next.js dry-run handler error:",e),r.NextResponse.json({error:e instanceof Error?e.message:"Dry-run validation failed",valid:!1},{status:400})}}}function A(n){const{extractSecurityContext:o,cors:s}=n,i=R(n);return async function(a,t){try{if(a.method!=="POST")return r.NextResponse.json(c.formatErrorResponse("Method not allowed - use POST",405),{status:405});const e=await a.json(),{queries:u}=e;if(!u||!Array.isArray(u))return r.NextResponse.json(c.formatErrorResponse('Request body must contain a "queries" array',400),{status:400});if(u.length===0)return r.NextResponse.json(c.formatErrorResponse("Queries array cannot be empty",400),{status:400});const m=await o(a,t),p=a.headers.get("x-cache-control")==="no-cache",f=await c.handleBatchRequest(u,m,i,{skipCache:p});return r.NextResponse.json(f,{headers:s?h(a,s):{}})}catch(e){return process.env.NODE_ENV!=="test"&&console.error("Next.js batch handler error:",e),r.NextResponse.json(c.formatErrorResponse(e instanceof Error?e.message:"Batch execution failed",500),{status:500})}}}function Q(n){const{extractSecurityContext:o,cors:s}=n,i=R(n);return async function(a,t){try{if(a.method!=="POST")return r.NextResponse.json({error:"Method not allowed"},{status:405});const e=await a.json(),u=e.query||e,m=e.options||{},p=await o(a,t),f=i.validateQuery(u);if(!f.isValid)return r.NextResponse.json({error:`Query validation failed: ${f.errors.join(", ")}`},{status:400});const j=await i.explainQuery(u,p,m);return r.NextResponse.json(j,{headers:s?h(a,s):{}})}catch(e){return process.env.NODE_ENV!=="test"&&console.error("Next.js explain handler error:",e),r.NextResponse.json({error:e instanceof Error?e.message:"Explain query failed"},{status:500})}}}function J(n){const{cors:o}=n,s=R(n);return async function(d,a){try{if(d.method!=="POST")return r.NextResponse.json(c.formatErrorResponse("Method not allowed - use POST",405),{status:405});const t=await d.json(),e=await c.handleDiscover(s,t);return r.NextResponse.json(e,{headers:o?h(d,o):{}})}catch(t){return process.env.NODE_ENV!=="test"&&console.error("Next.js discover handler error:",t),r.NextResponse.json(c.formatErrorResponse(t instanceof Error?t.message:"Discovery failed",500),{status:500})}}}function q(n){const{cors:o}=n,s=R(n);return async function(d,a){try{if(d.method!=="POST")return r.NextResponse.json(c.formatErrorResponse("Method not allowed - use POST",405),{status:405});const t=await d.json();if(!t.naturalLanguage)return r.NextResponse.json(c.formatErrorResponse("naturalLanguage field is required",400),{status:400});const e=await c.handleSuggest(s,t);return r.NextResponse.json(e,{headers:o?h(d,o):{}})}catch(t){return process.env.NODE_ENV!=="test"&&console.error("Next.js suggest handler error:",t),r.NextResponse.json(c.formatErrorResponse(t instanceof Error?t.message:"Query suggestion failed",500),{status:500})}}}function z(n){const{cors:o}=n,s=R(n);return async function(d,a){try{if(d.method!=="POST")return r.NextResponse.json(c.formatErrorResponse("Method not allowed - use POST",405),{status:405});const t=await d.json();if(!t.query)return r.NextResponse.json(c.formatErrorResponse("query field is required",400),{status:400});const e=await c.handleValidate(s,t);return r.NextResponse.json(e,{headers:o?h(d,o):{}})}catch(t){return process.env.NODE_ENV!=="test"&&console.error("Next.js validate handler error:",t),r.NextResponse.json(c.formatErrorResponse(t instanceof Error?t.message:"Query validation failed",500),{status:500})}}}function k(n){const{extractSecurityContext:o,cors:s}=n,i=R(n);return async function(a,t){try{if(a.method!=="POST")return r.NextResponse.json(c.formatErrorResponse("Method not allowed - use POST",405),{status:405});const e=await a.json();if(!e.query)return r.NextResponse.json(c.formatErrorResponse("query field is required",400),{status:400});const u=await o(a,t),m=await c.handleLoad(i,u,e);return r.NextResponse.json(m,{headers:s?h(a,s):{}})}catch(e){return process.env.NODE_ENV!=="test"&&console.error("Next.js MCP load handler error:",e),r.NextResponse.json(c.formatErrorResponse(e instanceof Error?e.message:"Query execution failed",500),{status:500})}}}function V(n){const{extractSecurityContext:o,cors:s,mcp:i={enabled:!0}}=n,d=R(n);return async function(t){if(t.method==="DELETE")return r.NextResponse.json({error:"Session termination not supported"},{status:405});if(t.method==="GET"){const y=new TextEncoder,g=l.primeEventId(),E=new ReadableStream({start(x){x.enqueue(y.encode(l.serializeSseEvent({jsonrpc:"2.0",method:"mcp/ready",params:{protocol:"streamable-http"}},g,15e3)))}}),S=new Headers({"Content-Type":"text/event-stream","Cache-Control":"no-cache",Connection:"keep-alive"});if(s){const x=h(t,s);Object.entries(x).forEach(([H,b])=>S.set(H,b))}return new r.NextResponse(E,{status:200,headers:S})}if(t.method!=="POST")return r.NextResponse.json(c.formatErrorResponse("Method not allowed - use POST",405),{status:405});const e=l.validateOriginHeader(t.headers.get("origin"),i.allowedOrigins?{allowedOrigins:i.allowedOrigins}:{});if(!e.valid)return r.NextResponse.json(l.buildJsonRpcError(null,-32600,e.reason),{status:403});const u=t.headers.get("accept");if(!l.validateAcceptHeader(u))return r.NextResponse.json(l.buildJsonRpcError(null,-32600,"Accept header must include both application/json and text/event-stream"),{status:400});const m=l.negotiateProtocol(Object.fromEntries(t.headers.entries()));if(!m.ok)return r.NextResponse.json({error:"Unsupported MCP protocol version",supported:m.supported},{status:426});let p=null;try{p=await t.json()}catch{p=null}const f=l.parseJsonRpc(p);if(!f)return r.NextResponse.json(l.buildJsonRpcError(null,-32600,"Invalid JSON-RPC 2.0 request"),{status:400});const j=l.wantsEventStream(u),N=f.method==="initialize",w=(y,g=200,E={})=>r.NextResponse.json(y,{status:g,headers:{...s?h(t,s):{},...E}});try{const y=await l.dispatchMcpMethod(f.method,f.params,{semanticLayer:d,extractSecurityContext:x=>o(x),rawRequest:t,rawResponse:null});if(l.isNotification(f))return new r.NextResponse(null,{status:202});const g=N&&y&&typeof y=="object"&&"sessionId"in y?y.sessionId:void 0,E={};g&&(E[l.MCP_SESSION_ID_HEADER]=g);const S=l.buildJsonRpcResult(f.id??null,y);if(j){const x=new TextEncoder,H=l.primeEventId(),b=new ReadableStream({start(v){v.enqueue(x.encode(`id: ${H}
|
|
2
2
|
|
|
3
3
|
`)),v.enqueue(x.encode(l.serializeSseEvent(S,H))),v.close()}}),O=new Headers({"Content-Type":"text/event-stream","Cache-Control":"no-cache",Connection:"keep-alive",...E});if(s){const v=h(t,s);Object.entries(v).forEach(([C,P])=>O.set(C,P))}return new r.NextResponse(b,{status:200,headers:O})}return w(S,200,E)}catch(y){if(l.isNotification(f))return process.env.NODE_ENV!=="test"&&console.error("Next.js MCP notification processing error:",y),new r.NextResponse(null,{status:202});process.env.NODE_ENV!=="test"&&console.error("Next.js MCP RPC handler error:",y);const g=y?.code??-32603,E=y?.data,S=y.message||"MCP request failed",x=l.buildJsonRpcError(f.id??null,g,S,E);if(j){const H=new TextEncoder,b=l.primeEventId(),O=new ReadableStream({start(C){C.enqueue(H.encode(`id: ${b}
|
|
4
4
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { NextResponse as t } from "next/server";
|
|
2
|
-
import { e as T, s as M, v as A, b as P, a as Q, n as _, p as V, w as I, d as J, i as L, M as k, c as z, S as $ } from "../mcp-transport-
|
|
2
|
+
import { e as T, s as M, v as A, b as P, a as Q, n as _, p as V, w as I, d as J, i as L, M as k, c as z, S as $ } from "../mcp-transport-DkdMX4bA.js";
|
|
3
3
|
import { formatErrorResponse as i, formatCubeResponse as G, formatMetaResponse as U, formatSqlResponse as q, handleDryRun as B, handleBatchRequest as F, handleDiscover as K, handleSuggest as W, handleValidate as X, handleLoad as Y } from "../utils.js";
|
|
4
4
|
function p(s) {
|
|
5
5
|
const { cubes: a, drizzle: n, schema: c, engineType: d, cache: o } = s;
|