drizzle-cube 0.4.5 → 0.4.8
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 +8 -4
- package/dist/adapters/express/index.d.ts +7 -0
- package/dist/adapters/express/index.js +189 -139
- package/dist/adapters/fastify/index.cjs +8 -4
- package/dist/adapters/fastify/index.d.ts +7 -0
- package/dist/adapters/fastify/index.js +209 -150
- package/dist/adapters/handler-BLcxTuwi.cjs +23 -0
- package/dist/adapters/handler-odjn7MIB.js +1880 -0
- package/dist/adapters/hono/index.cjs +8 -4
- package/dist/adapters/hono/index.d.ts +7 -0
- package/dist/adapters/hono/index.js +202 -144
- package/dist/adapters/{mcp-transport-YHDZWKOi.js → mcp-transport-CU5g9bxj.js} +7 -3
- package/dist/adapters/{mcp-transport-BqLo4hKi.cjs → mcp-transport-KX92EgkF.cjs} +21 -21
- package/dist/adapters/nextjs/index.cjs +7 -3
- package/dist/adapters/nextjs/index.d.ts +14 -0
- package/dist/adapters/nextjs/index.js +220 -144
- package/dist/client/charts/chartConfigs.d.ts +2 -9
- package/dist/client/charts.js +72 -70
- package/dist/client/charts.js.map +1 -1
- package/dist/client/chunks/{RetentionCombinedChart.config-C-ILIaEb.js → RetentionCombinedChart.config-Bbp2ghim.js} +2 -1
- package/dist/client/chunks/RetentionCombinedChart.config-Bbp2ghim.js.map +1 -0
- package/dist/client/chunks/{RetentionHeatmap.config-CIvhc-GT.js → RetentionHeatmap.config-BWf_-vdj.js} +2 -1
- package/dist/client/chunks/RetentionHeatmap.config-BWf_-vdj.js.map +1 -0
- package/dist/client/chunks/{analysis-builder-CG5VIMYB.js → analysis-builder-Bov_gLsf.js} +1408 -1393
- package/dist/client/chunks/analysis-builder-Bov_gLsf.js.map +1 -0
- package/dist/client/chunks/{analysis-builder-shared-CjlKJgyA.js → analysis-builder-shared-NBk6y0md.js} +3 -3
- package/dist/client/chunks/{analysis-builder-shared-CjlKJgyA.js.map → analysis-builder-shared-NBk6y0md.js.map} +1 -1
- package/dist/client/chunks/{chart-activity-grid-DStNr34n.js → chart-activity-grid-CE7xGFQo.js} +2 -2
- package/dist/client/chunks/{chart-activity-grid-DStNr34n.js.map → chart-activity-grid-CE7xGFQo.js.map} +1 -1
- package/dist/client/chunks/chart-box-plot-Dja4LS3O.js +313 -0
- package/dist/client/chunks/chart-box-plot-Dja4LS3O.js.map +1 -0
- package/dist/client/chunks/{chart-config-activity-grid-CAlo1cHA.js → chart-config-activity-grid-CmOqDuOT.js} +4 -5
- package/dist/client/chunks/chart-config-activity-grid-CmOqDuOT.js.map +1 -0
- package/dist/client/chunks/{chart-config-area-CyyJOO2T.js → chart-config-area-CK_GVApT.js} +4 -5
- package/dist/client/chunks/chart-config-area-CK_GVApT.js.map +1 -0
- package/dist/client/chunks/{chart-config-bar-soxw6m2o.js → chart-config-bar-C8uzktxl.js} +4 -5
- package/dist/client/chunks/chart-config-bar-C8uzktxl.js.map +1 -0
- package/dist/client/chunks/chart-config-box-plot-D3DA7_pr.js +85 -0
- package/dist/client/chunks/chart-config-box-plot-D3DA7_pr.js.map +1 -0
- package/dist/client/chunks/{chart-config-bubble-CuSsCHZ4.js → chart-config-bubble-q3DoQX5F.js} +4 -5
- package/dist/client/chunks/chart-config-bubble-q3DoQX5F.js.map +1 -0
- package/dist/client/chunks/{chart-config-data-table-BhgqwoqT.js → chart-config-data-table-B20Y5JCm.js} +4 -5
- package/dist/client/chunks/chart-config-data-table-B20Y5JCm.js.map +1 -0
- package/dist/client/chunks/{chart-config-funnel-BlSQYng0.js → chart-config-funnel-3eYnGg8M.js} +4 -5
- package/dist/client/chunks/chart-config-funnel-3eYnGg8M.js.map +1 -0
- package/dist/client/chunks/{chart-config-heat-map-DHQGFZhX.js → chart-config-heat-map-_wEnTnRA.js} +4 -5
- package/dist/client/chunks/chart-config-heat-map-_wEnTnRA.js.map +1 -0
- package/dist/client/chunks/{chart-config-kpi-delta-yTA5ug_l.js → chart-config-kpi-delta-DLGZ2A3X.js} +4 -5
- package/dist/client/chunks/chart-config-kpi-delta-DLGZ2A3X.js.map +1 -0
- package/dist/client/chunks/{chart-config-kpi-number-nVAwDXzq.js → chart-config-kpi-number-K-wzviXF.js} +4 -5
- package/dist/client/chunks/chart-config-kpi-number-K-wzviXF.js.map +1 -0
- package/dist/client/chunks/{chart-config-kpi-text-DZjqsx-b.js → chart-config-kpi-text-BjYqwqaJ.js} +4 -5
- package/dist/client/chunks/chart-config-kpi-text-BjYqwqaJ.js.map +1 -0
- package/dist/client/chunks/{chart-config-line-D5ME6w0v.js → chart-config-line-JNagi9tf.js} +4 -5
- package/dist/client/chunks/chart-config-line-JNagi9tf.js.map +1 -0
- package/dist/client/chunks/{chart-config-markdown-BXKL5TbQ.js → chart-config-markdown-BWQSjJpy.js} +4 -5
- package/dist/client/chunks/chart-config-markdown-BWQSjJpy.js.map +1 -0
- package/dist/client/chunks/{chart-config-pie-DlHa2jTy.js → chart-config-pie-CNLXb-fr.js} +4 -5
- package/dist/client/chunks/chart-config-pie-CNLXb-fr.js.map +1 -0
- package/dist/client/chunks/{chart-config-radar-BBAVIF0S.js → chart-config-radar-oxHfRAa3.js} +4 -5
- package/dist/client/chunks/chart-config-radar-oxHfRAa3.js.map +1 -0
- package/dist/client/chunks/{chart-config-radial-bar-CTwjDRnB.js → chart-config-radial-bar-_Aw3jAEm.js} +4 -5
- package/dist/client/chunks/chart-config-radial-bar-_Aw3jAEm.js.map +1 -0
- package/dist/client/chunks/{chart-config-sankey-CNAgsMQ4.js → chart-config-sankey-C8FX9hGF.js} +4 -5
- package/dist/client/chunks/chart-config-sankey-C8FX9hGF.js.map +1 -0
- package/dist/client/chunks/{chart-config-scatter-CWvN2E-X.js → chart-config-scatter-DFKM80eO.js} +4 -5
- package/dist/client/chunks/chart-config-scatter-DFKM80eO.js.map +1 -0
- package/dist/client/chunks/{chart-config-sunburst-W_SKwaj0.js → chart-config-sunburst-BmC0NLTU.js} +4 -5
- package/dist/client/chunks/chart-config-sunburst-BmC0NLTU.js.map +1 -0
- package/dist/client/chunks/{chart-config-tree-map-IRAYf9YM.js → chart-config-tree-map-DGMbNTaa.js} +4 -5
- package/dist/client/chunks/chart-config-tree-map-DGMbNTaa.js.map +1 -0
- package/dist/client/chunks/{chart-data-table-Ch_1c1Zo.js → chart-data-table-Ba_6tuJw.js} +2 -2
- package/dist/client/chunks/{chart-data-table-Ch_1c1Zo.js.map → chart-data-table-Ba_6tuJw.js.map} +1 -1
- package/dist/client/chunks/{chart-kpi-delta-CWCmi8vL.js → chart-kpi-delta-D9XJoKuA.js} +3 -3
- package/dist/client/chunks/{chart-kpi-delta-CWCmi8vL.js.map → chart-kpi-delta-D9XJoKuA.js.map} +1 -1
- package/dist/client/chunks/{chart-kpi-number-C-5m3qt5.js → chart-kpi-number-C29Vj2g8.js} +2 -2
- package/dist/client/chunks/{chart-kpi-number-C-5m3qt5.js.map → chart-kpi-number-C29Vj2g8.js.map} +1 -1
- package/dist/client/chunks/{chart-kpi-text--t4ibPmx.js → chart-kpi-text-CgjjrurK.js} +2 -2
- package/dist/client/chunks/{chart-kpi-text--t4ibPmx.js.map → chart-kpi-text-CgjjrurK.js.map} +1 -1
- package/dist/client/chunks/chart-markdown-Du4Z2iqK.js +2695 -0
- package/dist/client/chunks/chart-markdown-Du4Z2iqK.js.map +1 -0
- package/dist/client/chunks/{charts-loader-m5Ussksz.js → charts-loader-HYQFVOo4.js} +14 -13
- package/dist/client/chunks/charts-loader-HYQFVOo4.js.map +1 -0
- package/dist/client/chunks/{components-D-5p1LVQ.js → components-O0hh7ooo.js} +6 -6
- package/dist/client/chunks/components-O0hh7ooo.js.map +1 -0
- package/dist/client/chunks/{icons-DRreo6m8.js → icons-DAeqv1iX.js} +7 -7
- package/dist/client/chunks/{icons-DRreo6m8.js.map → icons-DAeqv1iX.js.map} +1 -1
- package/dist/client/components/AgenticNotebook/AgentChatPanel.d.ts +8 -0
- package/dist/client/components/AgenticNotebook/ChatInput.d.ts +14 -0
- package/dist/client/components/AgenticNotebook/ChatMessage.d.ts +7 -0
- package/dist/client/components/AgenticNotebook/NotebookCanvas.d.ts +3 -0
- package/dist/client/components/AgenticNotebook/NotebookMarkdownBlock.d.ts +12 -0
- package/dist/client/components/AgenticNotebook/NotebookPortletBlock.d.ts +12 -0
- package/dist/client/components/AgenticNotebook/index.d.ts +34 -0
- package/dist/client/components/charts/BoxPlotChart.config.d.ts +11 -0
- package/dist/client/components/charts/BoxPlotChart.d.ts +4 -0
- package/dist/client/components/charts/index.d.ts +1 -0
- package/dist/client/components.js +1 -1
- package/dist/client/hooks/useAgentChat.d.ts +36 -0
- package/dist/client/icons.js +1 -1
- package/dist/client/index.d.ts +6 -0
- package/dist/client/index.js +923 -187
- package/dist/client/index.js.map +1 -1
- package/dist/client/stores/notebookStore.d.ts +152 -0
- package/dist/client/styles.css +1 -1
- package/dist/client/types.d.ts +1 -1
- package/dist/client/utils.js +3 -3
- package/dist/client-bundle-stats.html +4 -4
- package/dist/server/index.cjs +116 -90
- package/dist/server/index.d.ts +155 -0
- package/dist/server/index.js +7088 -4852
- package/package.json +12 -6
- package/dist/client/chunks/RetentionCombinedChart.config-C-ILIaEb.js.map +0 -1
- package/dist/client/chunks/RetentionHeatmap.config-CIvhc-GT.js.map +0 -1
- package/dist/client/chunks/analysis-builder-CG5VIMYB.js.map +0 -1
- package/dist/client/chunks/chart-config-activity-grid-CAlo1cHA.js.map +0 -1
- package/dist/client/chunks/chart-config-area-CyyJOO2T.js.map +0 -1
- package/dist/client/chunks/chart-config-bar-soxw6m2o.js.map +0 -1
- package/dist/client/chunks/chart-config-bubble-CuSsCHZ4.js.map +0 -1
- package/dist/client/chunks/chart-config-data-table-BhgqwoqT.js.map +0 -1
- package/dist/client/chunks/chart-config-funnel-BlSQYng0.js.map +0 -1
- package/dist/client/chunks/chart-config-heat-map-DHQGFZhX.js.map +0 -1
- package/dist/client/chunks/chart-config-kpi-delta-yTA5ug_l.js.map +0 -1
- package/dist/client/chunks/chart-config-kpi-number-nVAwDXzq.js.map +0 -1
- package/dist/client/chunks/chart-config-kpi-text-DZjqsx-b.js.map +0 -1
- package/dist/client/chunks/chart-config-line-D5ME6w0v.js.map +0 -1
- package/dist/client/chunks/chart-config-markdown-BXKL5TbQ.js.map +0 -1
- package/dist/client/chunks/chart-config-pie-DlHa2jTy.js.map +0 -1
- package/dist/client/chunks/chart-config-radar-BBAVIF0S.js.map +0 -1
- package/dist/client/chunks/chart-config-radial-bar-CTwjDRnB.js.map +0 -1
- package/dist/client/chunks/chart-config-sankey-CNAgsMQ4.js.map +0 -1
- package/dist/client/chunks/chart-config-scatter-CWvN2E-X.js.map +0 -1
- package/dist/client/chunks/chart-config-sunburst-W_SKwaj0.js.map +0 -1
- package/dist/client/chunks/chart-config-tree-map-IRAYf9YM.js.map +0 -1
- package/dist/client/chunks/chart-markdown-Rq6ORisB.js +0 -276
- package/dist/client/chunks/chart-markdown-Rq6ORisB.js.map +0 -1
- package/dist/client/chunks/chartConfigRegistry-C5dZm-ZK.js +0 -44
- package/dist/client/chunks/chartConfigRegistry-C5dZm-ZK.js.map +0 -1
- package/dist/client/chunks/charts-loader-m5Ussksz.js.map +0 -1
- package/dist/client/chunks/components-D-5p1LVQ.js.map +0 -1
|
@@ -1,57 +1,58 @@
|
|
|
1
|
-
import { S as D, v as
|
|
2
|
-
import { formatErrorResponse as
|
|
3
|
-
const N = function(
|
|
1
|
+
import { S as D, v as K, b as x, a as T, n as V, p as z, w as _, d as B, i as j, M as F, c as U, e as E, s as P } from "../mcp-transport-CU5g9bxj.js";
|
|
2
|
+
import { formatErrorResponse as d, formatCubeResponse as A, handleBatchRequest as X, formatMetaResponse as G, formatSqlResponse as I, handleDryRun as M } from "../utils.js";
|
|
3
|
+
const N = function(i, k, R) {
|
|
4
4
|
const {
|
|
5
|
-
cubes:
|
|
6
|
-
drizzle:
|
|
7
|
-
schema:
|
|
8
|
-
extractSecurityContext:
|
|
5
|
+
cubes: S,
|
|
6
|
+
drizzle: O,
|
|
7
|
+
schema: J,
|
|
8
|
+
extractSecurityContext: p,
|
|
9
9
|
engineType: L,
|
|
10
|
-
cors:
|
|
11
|
-
basePath:
|
|
12
|
-
bodyLimit:
|
|
10
|
+
cors: q,
|
|
11
|
+
basePath: m = "/cubejs-api/v1",
|
|
12
|
+
bodyLimit: g = 10485760,
|
|
13
13
|
// 10MB
|
|
14
|
-
cache:
|
|
15
|
-
mcp:
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
14
|
+
cache: H,
|
|
15
|
+
mcp: b = { enabled: !0 },
|
|
16
|
+
agent: f
|
|
17
|
+
} = k;
|
|
18
|
+
if (!S || S.length === 0)
|
|
19
|
+
return R(new Error("At least one cube must be provided in the cubes array"));
|
|
20
|
+
q && i.register(import("@fastify/cors"), q), i.addHook("onRequest", async (t, r) => {
|
|
21
|
+
t.method === "POST" && (t.body = void 0);
|
|
21
22
|
});
|
|
22
23
|
const c = new D({
|
|
23
|
-
drizzle:
|
|
24
|
-
schema:
|
|
24
|
+
drizzle: O,
|
|
25
|
+
schema: J,
|
|
25
26
|
engineType: L,
|
|
26
|
-
cache:
|
|
27
|
+
cache: H
|
|
27
28
|
});
|
|
28
|
-
if (
|
|
29
|
-
c.registerCube(
|
|
30
|
-
}),
|
|
31
|
-
bodyLimit:
|
|
29
|
+
if (S.forEach((t) => {
|
|
30
|
+
c.registerCube(t);
|
|
31
|
+
}), i.post(`${m}/load`, {
|
|
32
|
+
bodyLimit: g,
|
|
32
33
|
schema: {
|
|
33
34
|
body: {
|
|
34
35
|
type: "object",
|
|
35
36
|
additionalProperties: !0
|
|
36
37
|
}
|
|
37
38
|
}
|
|
38
|
-
}, async (
|
|
39
|
+
}, async (t, r) => {
|
|
39
40
|
try {
|
|
40
|
-
const e =
|
|
41
|
+
const e = t.body, a = e.query || e, n = await p(t), o = c.validateQuery(a);
|
|
41
42
|
if (!o.isValid)
|
|
42
|
-
return
|
|
43
|
+
return r.status(400).send(d(
|
|
43
44
|
`Query validation failed: ${o.errors.join(", ")}`,
|
|
44
45
|
400
|
|
45
46
|
));
|
|
46
|
-
const
|
|
47
|
-
return
|
|
47
|
+
const s = t.headers["x-cache-control"] === "no-cache", l = await c.executeMultiCubeQuery(a, n, { skipCache: s });
|
|
48
|
+
return A(a, l, c);
|
|
48
49
|
} catch (e) {
|
|
49
|
-
return
|
|
50
|
+
return t.log.error(e, "Query execution error"), r.status(500).send(d(
|
|
50
51
|
e instanceof Error ? e.message : "Query execution failed",
|
|
51
52
|
500
|
|
52
53
|
));
|
|
53
54
|
}
|
|
54
|
-
}),
|
|
55
|
+
}), i.get(`${m}/load`, {
|
|
55
56
|
schema: {
|
|
56
57
|
querystring: {
|
|
57
58
|
type: "object",
|
|
@@ -61,34 +62,34 @@ const N = function(n, O, E) {
|
|
|
61
62
|
required: ["query"]
|
|
62
63
|
}
|
|
63
64
|
}
|
|
64
|
-
}, async (
|
|
65
|
+
}, async (t, r) => {
|
|
65
66
|
try {
|
|
66
|
-
const { query: e } =
|
|
67
|
+
const { query: e } = t.query;
|
|
67
68
|
let a;
|
|
68
69
|
try {
|
|
69
70
|
a = JSON.parse(e);
|
|
70
71
|
} catch {
|
|
71
|
-
return
|
|
72
|
+
return r.status(400).send(d(
|
|
72
73
|
"Invalid JSON in query parameter",
|
|
73
74
|
400
|
|
74
75
|
));
|
|
75
76
|
}
|
|
76
|
-
const
|
|
77
|
+
const n = await p(t), o = c.validateQuery(a);
|
|
77
78
|
if (!o.isValid)
|
|
78
|
-
return
|
|
79
|
+
return r.status(400).send(d(
|
|
79
80
|
`Query validation failed: ${o.errors.join(", ")}`,
|
|
80
81
|
400
|
|
81
82
|
));
|
|
82
|
-
const
|
|
83
|
-
return
|
|
83
|
+
const s = t.headers["x-cache-control"] === "no-cache", l = await c.executeMultiCubeQuery(a, n, { skipCache: s });
|
|
84
|
+
return A(a, l, c);
|
|
84
85
|
} catch (e) {
|
|
85
|
-
return
|
|
86
|
+
return t.log.error(e, "Query execution error"), r.status(500).send(d(
|
|
86
87
|
e instanceof Error ? e.message : "Query execution failed",
|
|
87
88
|
500
|
|
88
89
|
));
|
|
89
90
|
}
|
|
90
|
-
}),
|
|
91
|
-
bodyLimit:
|
|
91
|
+
}), i.post(`${m}/batch`, {
|
|
92
|
+
bodyLimit: g,
|
|
92
93
|
schema: {
|
|
93
94
|
body: {
|
|
94
95
|
type: "object",
|
|
@@ -101,68 +102,68 @@ const N = function(n, O, E) {
|
|
|
101
102
|
}
|
|
102
103
|
}
|
|
103
104
|
}
|
|
104
|
-
}, async (
|
|
105
|
+
}, async (t, r) => {
|
|
105
106
|
try {
|
|
106
|
-
const { queries: e } =
|
|
107
|
+
const { queries: e } = t.body;
|
|
107
108
|
if (!e || !Array.isArray(e))
|
|
108
|
-
return
|
|
109
|
+
return r.status(400).send(d(
|
|
109
110
|
'Request body must contain a "queries" array',
|
|
110
111
|
400
|
|
111
112
|
));
|
|
112
113
|
if (e.length === 0)
|
|
113
|
-
return
|
|
114
|
+
return r.status(400).send(d(
|
|
114
115
|
"Queries array cannot be empty",
|
|
115
116
|
400
|
|
116
117
|
));
|
|
117
|
-
const a = await
|
|
118
|
-
return await
|
|
118
|
+
const a = await p(t), n = t.headers["x-cache-control"] === "no-cache";
|
|
119
|
+
return await X(e, a, c, { skipCache: n });
|
|
119
120
|
} catch (e) {
|
|
120
|
-
return
|
|
121
|
+
return t.log.error(e, "Batch execution error"), r.status(500).send(d(
|
|
121
122
|
e instanceof Error ? e.message : "Batch execution failed",
|
|
122
123
|
500
|
|
123
124
|
));
|
|
124
125
|
}
|
|
125
|
-
}),
|
|
126
|
+
}), i.get(`${m}/meta`, async (t, r) => {
|
|
126
127
|
try {
|
|
127
128
|
const e = c.getMetadata();
|
|
128
|
-
return
|
|
129
|
+
return G(e);
|
|
129
130
|
} catch (e) {
|
|
130
|
-
return
|
|
131
|
+
return t.log.error(e, "Metadata error"), r.status(500).send(d(
|
|
131
132
|
e instanceof Error ? e.message : "Failed to fetch metadata",
|
|
132
133
|
500
|
|
133
134
|
));
|
|
134
135
|
}
|
|
135
|
-
}),
|
|
136
|
-
bodyLimit:
|
|
136
|
+
}), i.post(`${m}/sql`, {
|
|
137
|
+
bodyLimit: g,
|
|
137
138
|
schema: {
|
|
138
139
|
body: {
|
|
139
140
|
type: "object",
|
|
140
141
|
additionalProperties: !0
|
|
141
142
|
}
|
|
142
143
|
}
|
|
143
|
-
}, async (
|
|
144
|
+
}, async (t, r) => {
|
|
144
145
|
try {
|
|
145
|
-
const e =
|
|
146
|
-
if (!
|
|
147
|
-
return
|
|
148
|
-
`Query validation failed: ${
|
|
146
|
+
const e = t.body, a = await p(t), n = c.validateQuery(e);
|
|
147
|
+
if (!n.isValid)
|
|
148
|
+
return r.status(400).send(d(
|
|
149
|
+
`Query validation failed: ${n.errors.join(", ")}`,
|
|
149
150
|
400
|
|
150
151
|
));
|
|
151
152
|
const o = e.measures?.[0] || e.dimensions?.[0];
|
|
152
153
|
if (!o)
|
|
153
|
-
return
|
|
154
|
+
return r.status(400).send(d(
|
|
154
155
|
"No measures or dimensions specified",
|
|
155
156
|
400
|
|
156
157
|
));
|
|
157
|
-
const
|
|
158
|
-
return
|
|
158
|
+
const s = o.split(".")[0], l = await c.generateSQL(s, e, a);
|
|
159
|
+
return I(e, l);
|
|
159
160
|
} catch (e) {
|
|
160
|
-
return
|
|
161
|
+
return t.log.error(e, "SQL generation error"), r.status(500).send(d(
|
|
161
162
|
e instanceof Error ? e.message : "SQL generation failed",
|
|
162
163
|
500
|
|
163
164
|
));
|
|
164
165
|
}
|
|
165
|
-
}),
|
|
166
|
+
}), i.get(`${m}/sql`, {
|
|
166
167
|
schema: {
|
|
167
168
|
querystring: {
|
|
168
169
|
type: "object",
|
|
@@ -172,47 +173,47 @@ const N = function(n, O, E) {
|
|
|
172
173
|
required: ["query"]
|
|
173
174
|
}
|
|
174
175
|
}
|
|
175
|
-
}, async (
|
|
176
|
+
}, async (t, r) => {
|
|
176
177
|
try {
|
|
177
|
-
const { query: e } =
|
|
178
|
+
const { query: e } = t.query, a = JSON.parse(e), n = await p(t), o = c.validateQuery(a);
|
|
178
179
|
if (!o.isValid)
|
|
179
|
-
return
|
|
180
|
+
return r.status(400).send(d(
|
|
180
181
|
`Query validation failed: ${o.errors.join(", ")}`,
|
|
181
182
|
400
|
|
182
183
|
));
|
|
183
|
-
const
|
|
184
|
-
if (!
|
|
185
|
-
return
|
|
184
|
+
const s = a.measures?.[0] || a.dimensions?.[0];
|
|
185
|
+
if (!s)
|
|
186
|
+
return r.status(400).send(d(
|
|
186
187
|
"No measures or dimensions specified",
|
|
187
188
|
400
|
|
188
189
|
));
|
|
189
|
-
const
|
|
190
|
-
return
|
|
190
|
+
const l = s.split(".")[0], y = await c.generateSQL(l, a, n);
|
|
191
|
+
return I(a, y);
|
|
191
192
|
} catch (e) {
|
|
192
|
-
return
|
|
193
|
+
return t.log.error(e, "SQL generation error"), r.status(500).send(d(
|
|
193
194
|
e instanceof Error ? e.message : "SQL generation failed",
|
|
194
195
|
500
|
|
195
196
|
));
|
|
196
197
|
}
|
|
197
|
-
}),
|
|
198
|
-
bodyLimit:
|
|
198
|
+
}), i.post(`${m}/dry-run`, {
|
|
199
|
+
bodyLimit: g,
|
|
199
200
|
schema: {
|
|
200
201
|
body: {
|
|
201
202
|
type: "object",
|
|
202
203
|
additionalProperties: !0
|
|
203
204
|
}
|
|
204
205
|
}
|
|
205
|
-
}, async (
|
|
206
|
+
}, async (t, r) => {
|
|
206
207
|
try {
|
|
207
|
-
const e =
|
|
208
|
-
return await
|
|
208
|
+
const e = t.body, a = e.query || e, n = await p(t);
|
|
209
|
+
return await M(a, n, c);
|
|
209
210
|
} catch (e) {
|
|
210
|
-
return
|
|
211
|
+
return t.log.error(e, "Dry-run error"), r.status(400).send({
|
|
211
212
|
error: e instanceof Error ? e.message : "Dry-run validation failed",
|
|
212
213
|
valid: !1
|
|
213
214
|
});
|
|
214
215
|
}
|
|
215
|
-
}),
|
|
216
|
+
}), i.get(`${m}/dry-run`, {
|
|
216
217
|
schema: {
|
|
217
218
|
querystring: {
|
|
218
219
|
type: "object",
|
|
@@ -222,142 +223,200 @@ const N = function(n, O, E) {
|
|
|
222
223
|
required: ["query"]
|
|
223
224
|
}
|
|
224
225
|
}
|
|
225
|
-
}, async (
|
|
226
|
+
}, async (t, r) => {
|
|
226
227
|
try {
|
|
227
|
-
const { query: e } =
|
|
228
|
-
return await
|
|
228
|
+
const { query: e } = t.query, a = JSON.parse(e), n = await p(t);
|
|
229
|
+
return await M(a, n, c);
|
|
229
230
|
} catch (e) {
|
|
230
|
-
return
|
|
231
|
+
return t.log.error(e, "Dry-run error"), r.status(400).send({
|
|
231
232
|
error: e instanceof Error ? e.message : "Dry-run validation failed",
|
|
232
233
|
valid: !1
|
|
233
234
|
});
|
|
234
235
|
}
|
|
235
|
-
}),
|
|
236
|
-
bodyLimit:
|
|
236
|
+
}), i.post(`${m}/explain`, {
|
|
237
|
+
bodyLimit: g,
|
|
237
238
|
schema: {
|
|
238
239
|
body: {
|
|
239
240
|
type: "object",
|
|
240
241
|
additionalProperties: !0
|
|
241
242
|
}
|
|
242
243
|
}
|
|
243
|
-
}, async (
|
|
244
|
+
}, async (t, r) => {
|
|
244
245
|
try {
|
|
245
|
-
const e =
|
|
246
|
-
return
|
|
247
|
-
error: `Query validation failed: ${
|
|
246
|
+
const e = t.body, a = e.query || e, n = e.options || {}, o = await p(t), s = c.validateQuery(a);
|
|
247
|
+
return s.isValid ? await c.explainQuery(a, o, n) : r.status(400).send({
|
|
248
|
+
error: `Query validation failed: ${s.errors.join(", ")}`
|
|
248
249
|
});
|
|
249
250
|
} catch (e) {
|
|
250
|
-
return
|
|
251
|
+
return t.log.error(e, "Explain error"), r.status(500).send({
|
|
251
252
|
error: e instanceof Error ? e.message : "Explain query failed"
|
|
252
253
|
});
|
|
253
254
|
}
|
|
254
|
-
}),
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
255
|
+
}), f && i.post(`${m}/agent/chat`, {
|
|
256
|
+
bodyLimit: g,
|
|
257
|
+
schema: {
|
|
258
|
+
body: {
|
|
259
|
+
type: "object",
|
|
260
|
+
additionalProperties: !0
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
}, async (t, r) => {
|
|
264
|
+
try {
|
|
265
|
+
const { handleAgentChat: e } = await import("../handler-odjn7MIB.js"), a = t.body, { message: n, sessionId: o } = a;
|
|
266
|
+
if (!n || typeof n != "string")
|
|
267
|
+
return r.status(400).send({ error: "message is required and must be a string" });
|
|
268
|
+
let s = (f.apiKey || "").trim();
|
|
269
|
+
if (f.allowClientApiKey) {
|
|
270
|
+
const y = t.headers["x-agent-api-key"];
|
|
271
|
+
y && (s = y.trim());
|
|
272
|
+
}
|
|
273
|
+
if (!s)
|
|
274
|
+
return r.status(401).send({
|
|
275
|
+
error: "No API key configured. Set agent.apiKey in server config or send X-Agent-Api-Key header."
|
|
276
|
+
});
|
|
277
|
+
const l = await p(t);
|
|
278
|
+
r.raw.writeHead(200, {
|
|
279
|
+
"Content-Type": "text/event-stream",
|
|
280
|
+
"Cache-Control": "no-cache",
|
|
281
|
+
Connection: "keep-alive"
|
|
282
|
+
});
|
|
283
|
+
try {
|
|
284
|
+
const y = e({
|
|
285
|
+
message: n,
|
|
286
|
+
sessionId: o,
|
|
287
|
+
semanticLayer: c,
|
|
288
|
+
securityContext: l,
|
|
289
|
+
agentConfig: f,
|
|
290
|
+
apiKey: s
|
|
291
|
+
});
|
|
292
|
+
for await (const u of y)
|
|
293
|
+
r.raw.write(`data: ${JSON.stringify(u)}
|
|
294
|
+
|
|
295
|
+
`);
|
|
296
|
+
} catch (y) {
|
|
297
|
+
const u = {
|
|
298
|
+
type: "error",
|
|
299
|
+
data: { message: y instanceof Error ? y.message : "Stream failed" }
|
|
300
|
+
};
|
|
301
|
+
r.raw.write(`data: ${JSON.stringify(u)}
|
|
302
|
+
|
|
303
|
+
`);
|
|
304
|
+
} finally {
|
|
305
|
+
r.raw.end();
|
|
306
|
+
}
|
|
307
|
+
} catch (e) {
|
|
308
|
+
if (t.log.error(e, "Agent chat error"), !r.raw.headersSent)
|
|
309
|
+
return r.status(500).send({
|
|
310
|
+
error: e instanceof Error ? e.message : "Agent chat failed"
|
|
311
|
+
});
|
|
312
|
+
}
|
|
313
|
+
}), b.enabled !== !1) {
|
|
314
|
+
const t = b.basePath ?? "/mcp";
|
|
315
|
+
i.post(`${t}`, {
|
|
316
|
+
bodyLimit: g,
|
|
258
317
|
schema: {
|
|
259
318
|
body: {
|
|
260
319
|
type: "object",
|
|
261
320
|
additionalProperties: !0
|
|
262
321
|
}
|
|
263
322
|
}
|
|
264
|
-
}, async (
|
|
265
|
-
const a =
|
|
266
|
-
|
|
267
|
-
|
|
323
|
+
}, async (r, e) => {
|
|
324
|
+
const a = K(
|
|
325
|
+
r.headers.origin,
|
|
326
|
+
b.allowedOrigins ? { allowedOrigins: b.allowedOrigins } : {}
|
|
268
327
|
);
|
|
269
328
|
if (!a.valid)
|
|
270
|
-
return e.status(403).send(
|
|
271
|
-
const
|
|
272
|
-
if (!
|
|
273
|
-
return e.status(400).send(
|
|
274
|
-
const o =
|
|
329
|
+
return e.status(403).send(x(null, -32600, a.reason));
|
|
330
|
+
const n = r.headers.accept;
|
|
331
|
+
if (!T(n))
|
|
332
|
+
return e.status(400).send(x(null, -32600, "Accept header must include both application/json and text/event-stream"));
|
|
333
|
+
const o = V(r.headers);
|
|
275
334
|
if (!o.ok)
|
|
276
335
|
return e.status(426).send({
|
|
277
336
|
error: "Unsupported MCP protocol version",
|
|
278
337
|
supported: o.supported
|
|
279
338
|
});
|
|
280
|
-
const
|
|
281
|
-
if (!
|
|
282
|
-
return e.status(400).send(
|
|
283
|
-
const
|
|
339
|
+
const s = z(r.body);
|
|
340
|
+
if (!s)
|
|
341
|
+
return e.status(400).send(x(null, -32600, "Invalid JSON-RPC 2.0 request"));
|
|
342
|
+
const l = _(n), y = s.method === "initialize";
|
|
284
343
|
try {
|
|
285
|
-
const
|
|
286
|
-
|
|
287
|
-
|
|
344
|
+
const u = await B(
|
|
345
|
+
s.method,
|
|
346
|
+
s.params,
|
|
288
347
|
{
|
|
289
348
|
semanticLayer: c,
|
|
290
|
-
extractSecurityContext:
|
|
291
|
-
rawRequest:
|
|
349
|
+
extractSecurityContext: p,
|
|
350
|
+
rawRequest: r,
|
|
292
351
|
rawResponse: e,
|
|
293
352
|
negotiatedProtocol: o.negotiated
|
|
294
353
|
}
|
|
295
354
|
);
|
|
296
|
-
if (
|
|
355
|
+
if (j(s))
|
|
297
356
|
return e.status(202).send();
|
|
298
|
-
const
|
|
299
|
-
|
|
300
|
-
const
|
|
301
|
-
if (
|
|
302
|
-
const
|
|
303
|
-
e.header("Content-Type", "text/event-stream").header("Cache-Control", "no-cache").header("Connection", "keep-alive").send(`id: ${
|
|
357
|
+
const v = y && u && typeof u == "object" && "sessionId" in u ? u.sessionId : void 0;
|
|
358
|
+
v && e.header(F, v);
|
|
359
|
+
const C = U(s.id ?? null, u);
|
|
360
|
+
if (l) {
|
|
361
|
+
const w = E();
|
|
362
|
+
e.header("Content-Type", "text/event-stream").header("Cache-Control", "no-cache").header("Connection", "keep-alive").send(`id: ${w}
|
|
304
363
|
|
|
305
|
-
${
|
|
364
|
+
${P(C, w)}`);
|
|
306
365
|
return;
|
|
307
366
|
}
|
|
308
|
-
return e.send(
|
|
309
|
-
} catch (
|
|
310
|
-
if (
|
|
311
|
-
return
|
|
312
|
-
|
|
313
|
-
const
|
|
314
|
-
if (
|
|
315
|
-
const
|
|
316
|
-
e.header("Content-Type", "text/event-stream").header("Cache-Control", "no-cache").header("Connection", "keep-alive").send(`id: ${
|
|
367
|
+
return e.send(C);
|
|
368
|
+
} catch (u) {
|
|
369
|
+
if (j(s))
|
|
370
|
+
return r.log.error(u, "MCP notification processing error"), e.status(202).send();
|
|
371
|
+
r.log.error(u, "MCP RPC error");
|
|
372
|
+
const v = u?.code ?? -32603, C = u?.data, w = u.message || "MCP request failed", Q = x(s.id ?? null, v, w, C);
|
|
373
|
+
if (l) {
|
|
374
|
+
const $ = E();
|
|
375
|
+
e.header("Content-Type", "text/event-stream").header("Cache-Control", "no-cache").header("Connection", "keep-alive").send(`id: ${$}
|
|
317
376
|
|
|
318
|
-
${
|
|
377
|
+
${P(Q, $)}`);
|
|
319
378
|
return;
|
|
320
379
|
}
|
|
321
|
-
return e.send(
|
|
380
|
+
return e.send(Q);
|
|
322
381
|
}
|
|
323
|
-
}),
|
|
324
|
-
const a =
|
|
382
|
+
}), i.get(`${t}`, async (r, e) => {
|
|
383
|
+
const a = E();
|
|
325
384
|
e.raw.writeHead(200, {
|
|
326
385
|
"Content-Type": "text/event-stream",
|
|
327
386
|
"Cache-Control": "no-cache",
|
|
328
387
|
Connection: "keep-alive"
|
|
329
|
-
}), e.raw.write(
|
|
388
|
+
}), e.raw.write(P({
|
|
330
389
|
jsonrpc: "2.0",
|
|
331
390
|
method: "mcp/ready",
|
|
332
391
|
params: { protocol: "streamable-http" }
|
|
333
392
|
}, a, 15e3));
|
|
334
|
-
const
|
|
393
|
+
const n = setInterval(() => {
|
|
335
394
|
e.raw.write(`: keep-alive
|
|
336
395
|
|
|
337
396
|
`);
|
|
338
397
|
}, 15e3);
|
|
339
|
-
|
|
340
|
-
clearInterval(
|
|
398
|
+
r.raw.on("close", () => {
|
|
399
|
+
clearInterval(n);
|
|
341
400
|
});
|
|
342
|
-
}),
|
|
401
|
+
}), i.delete(`${t}`, async (r, e) => e.status(405).send({ error: "Session termination not supported" }));
|
|
343
402
|
}
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
const a =
|
|
347
|
-
return
|
|
348
|
-
}),
|
|
403
|
+
i.setErrorHandler(async (t, r, e) => {
|
|
404
|
+
r.log.error(t, "Fastify cube adapter error"), e.statusCode < 400 && e.status(500);
|
|
405
|
+
const a = t instanceof Error ? t : String(t);
|
|
406
|
+
return d(a, e.statusCode);
|
|
407
|
+
}), R();
|
|
349
408
|
};
|
|
350
|
-
async function
|
|
351
|
-
await h.register(N,
|
|
409
|
+
async function Z(h, i) {
|
|
410
|
+
await h.register(N, i);
|
|
352
411
|
}
|
|
353
|
-
function
|
|
354
|
-
const
|
|
412
|
+
function ee(h) {
|
|
413
|
+
const i = require("fastify")({
|
|
355
414
|
logger: !0
|
|
356
415
|
});
|
|
357
|
-
return
|
|
416
|
+
return i.register(N, h), i;
|
|
358
417
|
}
|
|
359
418
|
export {
|
|
360
|
-
|
|
419
|
+
ee as createCubeApp,
|
|
361
420
|
N as cubePlugin,
|
|
362
|
-
|
|
421
|
+
Z as registerCubeRoutes
|
|
363
422
|
};
|