drizzle-cube 0.4.13 → 0.4.14
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/README.md +1 -0
- package/dist/adapters/express/index.cjs +6 -6
- package/dist/adapters/express/index.js +73 -72
- package/dist/adapters/fastify/index.cjs +5 -5
- package/dist/adapters/fastify/index.js +110 -109
- package/dist/adapters/{handler-CQkIwtxp.js → handler-DZnCbydH.js} +719 -272
- package/dist/adapters/handler-ZDYlokiM.cjs +25 -0
- package/dist/adapters/hono/index.cjs +6 -6
- package/dist/adapters/hono/index.js +121 -120
- package/dist/adapters/nextjs/index.cjs +5 -5
- package/dist/adapters/nextjs/index.js +92 -91
- package/dist/client/charts.js +67 -59
- package/dist/client/charts.js.map +1 -1
- package/dist/client/chunks/{RetentionCombinedChart-CEI8KQ3t.js → RetentionCombinedChart-CLq89aOJ.js} +2 -2
- package/dist/client/chunks/{RetentionCombinedChart-CEI8KQ3t.js.map → RetentionCombinedChart-CLq89aOJ.js.map} +1 -1
- package/dist/client/chunks/{analysis-builder-BMmWeFPr.js → analysis-builder-C5e52Z3p.js} +419 -411
- package/dist/client/chunks/analysis-builder-C5e52Z3p.js.map +1 -0
- package/dist/client/chunks/{analysis-builder-shared-D56zYeV0.js → analysis-builder-shared-EnM-8plh.js} +2 -2
- package/dist/client/chunks/{analysis-builder-shared-D56zYeV0.js.map → analysis-builder-shared-EnM-8plh.js.map} +1 -1
- package/dist/client/chunks/{chart-activity-grid-CE7xGFQo.js → chart-activity-grid-CPGcTSuh.js} +2 -2
- package/dist/client/chunks/{chart-activity-grid-CE7xGFQo.js.map → chart-activity-grid-CPGcTSuh.js.map} +1 -1
- package/dist/client/chunks/{chart-area-BJAgusst.js → chart-area-ByJQ7NZd.js} +3 -3
- package/dist/client/chunks/{chart-area-BJAgusst.js.map → chart-area-ByJQ7NZd.js.map} +1 -1
- package/dist/client/chunks/{chart-bar-Blypx8O4.js → chart-bar-dj14frMt.js} +2 -2
- package/dist/client/chunks/{chart-bar-Blypx8O4.js.map → chart-bar-dj14frMt.js.map} +1 -1
- package/dist/client/chunks/chart-box-plot-ZatBpatq.js +322 -0
- package/dist/client/chunks/chart-box-plot-ZatBpatq.js.map +1 -0
- package/dist/client/chunks/{chart-bubble-Bf42A1-B.js → chart-bubble-CemotLx-.js} +2 -2
- package/dist/client/chunks/{chart-bubble-Bf42A1-B.js.map → chart-bubble-CemotLx-.js.map} +1 -1
- package/dist/client/chunks/chart-candlestick-BIR4uGGt.js +269 -0
- package/dist/client/chunks/chart-candlestick-BIR4uGGt.js.map +1 -0
- package/dist/client/chunks/chart-config-box-plot-D_E_SSc2.js +38 -0
- package/dist/client/chunks/chart-config-box-plot-D_E_SSc2.js.map +1 -0
- package/dist/client/chunks/chart-config-candlestick-CRCpD43-.js +70 -0
- package/dist/client/chunks/chart-config-candlestick-CRCpD43-.js.map +1 -0
- package/dist/client/chunks/chart-config-gauge-CQx9w3d4.js +64 -0
- package/dist/client/chunks/chart-config-gauge-CQx9w3d4.js.map +1 -0
- package/dist/client/chunks/chart-config-measure-profile-ZYaMrtws.js +70 -0
- package/dist/client/chunks/chart-config-measure-profile-ZYaMrtws.js.map +1 -0
- package/dist/client/chunks/chart-config-waterfall-DTyXV_fo.js +60 -0
- package/dist/client/chunks/chart-config-waterfall-DTyXV_fo.js.map +1 -0
- package/dist/client/chunks/{chart-data-table-Ba_6tuJw.js → chart-data-table-D5G8nMnb.js} +2 -2
- package/dist/client/chunks/{chart-data-table-Ba_6tuJw.js.map → chart-data-table-D5G8nMnb.js.map} +1 -1
- package/dist/client/chunks/{chart-funnel-C9kenCpp.js → chart-funnel-dofnhD24.js} +2 -2
- package/dist/client/chunks/{chart-funnel-C9kenCpp.js.map → chart-funnel-dofnhD24.js.map} +1 -1
- package/dist/client/chunks/chart-gauge-CKJJ8m3b.js +374 -0
- package/dist/client/chunks/chart-gauge-CKJJ8m3b.js.map +1 -0
- package/dist/client/chunks/{chart-heat-map-CYGemyPB.js → chart-heat-map-BVuPUKHT.js} +2 -2
- package/dist/client/chunks/{chart-heat-map-CYGemyPB.js.map → chart-heat-map-BVuPUKHT.js.map} +1 -1
- package/dist/client/chunks/{chart-kpi-delta-D9XJoKuA.js → chart-kpi-delta-Dgg2eYRl.js} +3 -3
- package/dist/client/chunks/{chart-kpi-delta-D9XJoKuA.js.map → chart-kpi-delta-Dgg2eYRl.js.map} +1 -1
- package/dist/client/chunks/{chart-kpi-number-C29Vj2g8.js → chart-kpi-number-DkoO99c1.js} +2 -2
- package/dist/client/chunks/{chart-kpi-number-C29Vj2g8.js.map → chart-kpi-number-DkoO99c1.js.map} +1 -1
- package/dist/client/chunks/{chart-kpi-text-CgjjrurK.js → chart-kpi-text-1O6_lmz7.js} +3 -3
- package/dist/client/chunks/{chart-kpi-text-CgjjrurK.js.map → chart-kpi-text-1O6_lmz7.js.map} +1 -1
- package/dist/client/chunks/{chart-line-zi6olZet.js → chart-line-DzyZkugh.js} +3 -3
- package/dist/client/chunks/{chart-line-zi6olZet.js.map → chart-line-DzyZkugh.js.map} +1 -1
- package/dist/client/chunks/chart-measure-profile-C2IkBG3V.js +114 -0
- package/dist/client/chunks/chart-measure-profile-C2IkBG3V.js.map +1 -0
- package/dist/client/chunks/{chart-pie-C4SuxKSN.js → chart-pie-akbfRfb9.js} +2 -2
- package/dist/client/chunks/{chart-pie-C4SuxKSN.js.map → chart-pie-akbfRfb9.js.map} +1 -1
- package/dist/client/chunks/{chart-radar-BW3Z_-Ly.js → chart-radar-BaN-Kjww.js} +2 -2
- package/dist/client/chunks/{chart-radar-BW3Z_-Ly.js.map → chart-radar-BaN-Kjww.js.map} +1 -1
- package/dist/client/chunks/{chart-radial-bar-0Fa3aeP5.js → chart-radial-bar-DpptEL3s.js} +2 -2
- package/dist/client/chunks/{chart-radial-bar-0Fa3aeP5.js.map → chart-radial-bar-DpptEL3s.js.map} +1 -1
- package/dist/client/chunks/{chart-sankey-DBghfbg1.js → chart-sankey-CG-3hHmX.js} +2 -2
- package/dist/client/chunks/{chart-sankey-DBghfbg1.js.map → chart-sankey-CG-3hHmX.js.map} +1 -1
- package/dist/client/chunks/{chart-scatter-DOVu1TNq.js → chart-scatter-l_yTVxF3.js} +2 -2
- package/dist/client/chunks/{chart-scatter-DOVu1TNq.js.map → chart-scatter-l_yTVxF3.js.map} +1 -1
- package/dist/client/chunks/{chart-sunburst-LfNthFlZ.js → chart-sunburst-KhDcKhmZ.js} +2 -2
- package/dist/client/chunks/{chart-sunburst-LfNthFlZ.js.map → chart-sunburst-KhDcKhmZ.js.map} +1 -1
- package/dist/client/chunks/{chart-tree-map-DZtQPyWX.js → chart-tree-map-CBbiaBXV.js} +2 -2
- package/dist/client/chunks/{chart-tree-map-DZtQPyWX.js.map → chart-tree-map-CBbiaBXV.js.map} +1 -1
- package/dist/client/chunks/chart-waterfall-CX3vx_lI.js +191 -0
- package/dist/client/chunks/chart-waterfall-CX3vx_lI.js.map +1 -0
- package/dist/client/chunks/{charts-core-DmGfleFz.js → charts-core-CU9u_HtL.js} +2 -1
- package/dist/client/chunks/charts-core-CU9u_HtL.js.map +1 -0
- package/dist/client/chunks/{charts-loader-CH0_S06T.js → charts-loader-AW3T1nv5.js} +58 -42
- package/dist/client/chunks/charts-loader-AW3T1nv5.js.map +1 -0
- package/dist/client/chunks/{components-ClQziOcT.js → components-BkeSy9xv.js} +4 -4
- package/dist/client/chunks/components-BkeSy9xv.js.map +1 -0
- package/dist/client/components/AgenticNotebook/AgentChatPanel.d.ts +10 -0
- package/dist/client/components/AgenticNotebook/ChatMessage.d.ts +2 -0
- package/dist/client/components/AgenticNotebook/index.d.ts +11 -1
- package/dist/client/components/LoadingIndicator.d.ts +2 -2
- package/dist/client/components/charts/BoxPlotChart.config.d.ts +1 -7
- package/dist/client/components/charts/CandlestickChart.config.d.ts +5 -0
- package/dist/client/components/charts/CandlestickChart.d.ts +4 -0
- package/dist/client/components/charts/GaugeChart.config.d.ts +5 -0
- package/dist/client/components/charts/GaugeChart.d.ts +4 -0
- package/dist/client/components/charts/MeasureProfileChart.config.d.ts +5 -0
- package/dist/client/components/charts/MeasureProfileChart.d.ts +4 -0
- package/dist/client/components/charts/WaterfallChart.config.d.ts +5 -0
- package/dist/client/components/charts/WaterfallChart.d.ts +4 -0
- package/dist/client/components/charts/index.d.ts +4 -0
- package/dist/client/components.js +1 -1
- package/dist/client/hooks/useAgentChat.d.ts +20 -2
- package/dist/client/index.js +583 -522
- package/dist/client/index.js.map +1 -1
- package/dist/client/styles.css +1 -1
- package/dist/client/types.d.ts +19 -1
- package/dist/client/utils.js +4 -4
- package/dist/client-bundle-stats.html +1 -1
- package/dist/server/index.cjs +47 -45
- package/dist/server/index.d.ts +37 -0
- package/dist/server/index.js +1745 -1298
- package/package.json +4 -1
- package/dist/adapters/handler-dnkqpznh.cjs +0 -23
- package/dist/client/chunks/analysis-builder-BMmWeFPr.js.map +0 -1
- package/dist/client/chunks/chart-box-plot-Dja4LS3O.js +0 -313
- package/dist/client/chunks/chart-box-plot-Dja4LS3O.js.map +0 -1
- package/dist/client/chunks/chart-config-box-plot-D3DA7_pr.js +0 -85
- package/dist/client/chunks/chart-config-box-plot-D3DA7_pr.js.map +0 -1
- package/dist/client/chunks/charts-core-DmGfleFz.js.map +0 -1
- package/dist/client/chunks/charts-loader-CH0_S06T.js.map +0 -1
- package/dist/client/chunks/components-ClQziOcT.js.map +0 -1
|
@@ -1,19 +1,19 @@
|
|
|
1
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-m1X1GtwG.js";
|
|
2
|
-
import { formatErrorResponse as
|
|
2
|
+
import { formatErrorResponse as u, formatCubeResponse as A, handleBatchRequest as X, formatMetaResponse as G, formatSqlResponse as I, handleDryRun as M } from "../utils.js";
|
|
3
3
|
const N = function(i, k, R) {
|
|
4
4
|
const {
|
|
5
5
|
cubes: S,
|
|
6
6
|
drizzle: O,
|
|
7
7
|
schema: J,
|
|
8
|
-
extractSecurityContext:
|
|
8
|
+
extractSecurityContext: y,
|
|
9
9
|
engineType: L,
|
|
10
10
|
cors: q,
|
|
11
|
-
basePath:
|
|
12
|
-
bodyLimit:
|
|
11
|
+
basePath: p = "/cubejs-api/v1",
|
|
12
|
+
bodyLimit: m = 10485760,
|
|
13
13
|
// 10MB
|
|
14
14
|
cache: H,
|
|
15
|
-
mcp:
|
|
16
|
-
agent:
|
|
15
|
+
mcp: f = { enabled: !0 },
|
|
16
|
+
agent: v
|
|
17
17
|
} = k;
|
|
18
18
|
if (!S || S.length === 0)
|
|
19
19
|
return R(new Error("At least one cube must be provided in the cubes array"));
|
|
@@ -28,8 +28,8 @@ const N = function(i, k, R) {
|
|
|
28
28
|
});
|
|
29
29
|
if (S.forEach((t) => {
|
|
30
30
|
c.registerCube(t);
|
|
31
|
-
}), i.post(`${
|
|
32
|
-
bodyLimit:
|
|
31
|
+
}), i.post(`${p}/load`, {
|
|
32
|
+
bodyLimit: m,
|
|
33
33
|
schema: {
|
|
34
34
|
body: {
|
|
35
35
|
type: "object",
|
|
@@ -38,21 +38,21 @@ const N = function(i, k, R) {
|
|
|
38
38
|
}
|
|
39
39
|
}, async (t, r) => {
|
|
40
40
|
try {
|
|
41
|
-
const e = t.body, a = e.query || e, n = await
|
|
42
|
-
if (!
|
|
43
|
-
return r.status(400).send(
|
|
44
|
-
`Query validation failed: ${
|
|
41
|
+
const e = t.body, a = e.query || e, n = await y(t), s = c.validateQuery(a);
|
|
42
|
+
if (!s.isValid)
|
|
43
|
+
return r.status(400).send(u(
|
|
44
|
+
`Query validation failed: ${s.errors.join(", ")}`,
|
|
45
45
|
400
|
|
46
46
|
));
|
|
47
|
-
const
|
|
47
|
+
const o = t.headers["x-cache-control"] === "no-cache", l = await c.executeMultiCubeQuery(a, n, { skipCache: o });
|
|
48
48
|
return A(a, l, c);
|
|
49
49
|
} catch (e) {
|
|
50
|
-
return t.log.error(e, "Query execution error"), r.status(500).send(
|
|
50
|
+
return t.log.error(e, "Query execution error"), r.status(500).send(u(
|
|
51
51
|
e instanceof Error ? e.message : "Query execution failed",
|
|
52
52
|
500
|
|
53
53
|
));
|
|
54
54
|
}
|
|
55
|
-
}), i.get(`${
|
|
55
|
+
}), i.get(`${p}/load`, {
|
|
56
56
|
schema: {
|
|
57
57
|
querystring: {
|
|
58
58
|
type: "object",
|
|
@@ -69,27 +69,27 @@ const N = function(i, k, R) {
|
|
|
69
69
|
try {
|
|
70
70
|
a = JSON.parse(e);
|
|
71
71
|
} catch {
|
|
72
|
-
return r.status(400).send(
|
|
72
|
+
return r.status(400).send(u(
|
|
73
73
|
"Invalid JSON in query parameter",
|
|
74
74
|
400
|
|
75
75
|
));
|
|
76
76
|
}
|
|
77
|
-
const n = await
|
|
78
|
-
if (!
|
|
79
|
-
return r.status(400).send(
|
|
80
|
-
`Query validation failed: ${
|
|
77
|
+
const n = await y(t), s = c.validateQuery(a);
|
|
78
|
+
if (!s.isValid)
|
|
79
|
+
return r.status(400).send(u(
|
|
80
|
+
`Query validation failed: ${s.errors.join(", ")}`,
|
|
81
81
|
400
|
|
82
82
|
));
|
|
83
|
-
const
|
|
83
|
+
const o = t.headers["x-cache-control"] === "no-cache", l = await c.executeMultiCubeQuery(a, n, { skipCache: o });
|
|
84
84
|
return A(a, l, c);
|
|
85
85
|
} catch (e) {
|
|
86
|
-
return t.log.error(e, "Query execution error"), r.status(500).send(
|
|
86
|
+
return t.log.error(e, "Query execution error"), r.status(500).send(u(
|
|
87
87
|
e instanceof Error ? e.message : "Query execution failed",
|
|
88
88
|
500
|
|
89
89
|
));
|
|
90
90
|
}
|
|
91
|
-
}), i.post(`${
|
|
92
|
-
bodyLimit:
|
|
91
|
+
}), i.post(`${p}/batch`, {
|
|
92
|
+
bodyLimit: m,
|
|
93
93
|
schema: {
|
|
94
94
|
body: {
|
|
95
95
|
type: "object",
|
|
@@ -106,35 +106,35 @@ const N = function(i, k, R) {
|
|
|
106
106
|
try {
|
|
107
107
|
const { queries: e } = t.body;
|
|
108
108
|
if (!e || !Array.isArray(e))
|
|
109
|
-
return r.status(400).send(
|
|
109
|
+
return r.status(400).send(u(
|
|
110
110
|
'Request body must contain a "queries" array',
|
|
111
111
|
400
|
|
112
112
|
));
|
|
113
113
|
if (e.length === 0)
|
|
114
|
-
return r.status(400).send(
|
|
114
|
+
return r.status(400).send(u(
|
|
115
115
|
"Queries array cannot be empty",
|
|
116
116
|
400
|
|
117
117
|
));
|
|
118
|
-
const a = await
|
|
118
|
+
const a = await y(t), n = t.headers["x-cache-control"] === "no-cache";
|
|
119
119
|
return await X(e, a, c, { skipCache: n });
|
|
120
120
|
} catch (e) {
|
|
121
|
-
return t.log.error(e, "Batch execution error"), r.status(500).send(
|
|
121
|
+
return t.log.error(e, "Batch execution error"), r.status(500).send(u(
|
|
122
122
|
e instanceof Error ? e.message : "Batch execution failed",
|
|
123
123
|
500
|
|
124
124
|
));
|
|
125
125
|
}
|
|
126
|
-
}), i.get(`${
|
|
126
|
+
}), i.get(`${p}/meta`, async (t, r) => {
|
|
127
127
|
try {
|
|
128
128
|
const e = c.getMetadata();
|
|
129
129
|
return G(e);
|
|
130
130
|
} catch (e) {
|
|
131
|
-
return t.log.error(e, "Metadata error"), r.status(500).send(
|
|
131
|
+
return t.log.error(e, "Metadata error"), r.status(500).send(u(
|
|
132
132
|
e instanceof Error ? e.message : "Failed to fetch metadata",
|
|
133
133
|
500
|
|
134
134
|
));
|
|
135
135
|
}
|
|
136
|
-
}), i.post(`${
|
|
137
|
-
bodyLimit:
|
|
136
|
+
}), i.post(`${p}/sql`, {
|
|
137
|
+
bodyLimit: m,
|
|
138
138
|
schema: {
|
|
139
139
|
body: {
|
|
140
140
|
type: "object",
|
|
@@ -143,27 +143,27 @@ const N = function(i, k, R) {
|
|
|
143
143
|
}
|
|
144
144
|
}, async (t, r) => {
|
|
145
145
|
try {
|
|
146
|
-
const e = t.body, a = await
|
|
146
|
+
const e = t.body, a = await y(t), n = c.validateQuery(e);
|
|
147
147
|
if (!n.isValid)
|
|
148
|
-
return r.status(400).send(
|
|
148
|
+
return r.status(400).send(u(
|
|
149
149
|
`Query validation failed: ${n.errors.join(", ")}`,
|
|
150
150
|
400
|
|
151
151
|
));
|
|
152
|
-
const
|
|
153
|
-
if (!
|
|
154
|
-
return r.status(400).send(
|
|
152
|
+
const s = e.measures?.[0] || e.dimensions?.[0];
|
|
153
|
+
if (!s)
|
|
154
|
+
return r.status(400).send(u(
|
|
155
155
|
"No measures or dimensions specified",
|
|
156
156
|
400
|
|
157
157
|
));
|
|
158
|
-
const
|
|
158
|
+
const o = s.split(".")[0], l = await c.generateSQL(o, e, a);
|
|
159
159
|
return I(e, l);
|
|
160
160
|
} catch (e) {
|
|
161
|
-
return t.log.error(e, "SQL generation error"), r.status(500).send(
|
|
161
|
+
return t.log.error(e, "SQL generation error"), r.status(500).send(u(
|
|
162
162
|
e instanceof Error ? e.message : "SQL generation failed",
|
|
163
163
|
500
|
|
164
164
|
));
|
|
165
165
|
}
|
|
166
|
-
}), i.get(`${
|
|
166
|
+
}), i.get(`${p}/sql`, {
|
|
167
167
|
schema: {
|
|
168
168
|
querystring: {
|
|
169
169
|
type: "object",
|
|
@@ -175,28 +175,28 @@ const N = function(i, k, R) {
|
|
|
175
175
|
}
|
|
176
176
|
}, async (t, r) => {
|
|
177
177
|
try {
|
|
178
|
-
const { query: e } = t.query, a = JSON.parse(e), n = await
|
|
179
|
-
if (!
|
|
180
|
-
return r.status(400).send(
|
|
181
|
-
`Query validation failed: ${
|
|
178
|
+
const { query: e } = t.query, a = JSON.parse(e), n = await y(t), s = c.validateQuery(a);
|
|
179
|
+
if (!s.isValid)
|
|
180
|
+
return r.status(400).send(u(
|
|
181
|
+
`Query validation failed: ${s.errors.join(", ")}`,
|
|
182
182
|
400
|
|
183
183
|
));
|
|
184
|
-
const
|
|
185
|
-
if (!
|
|
186
|
-
return r.status(400).send(
|
|
184
|
+
const o = a.measures?.[0] || a.dimensions?.[0];
|
|
185
|
+
if (!o)
|
|
186
|
+
return r.status(400).send(u(
|
|
187
187
|
"No measures or dimensions specified",
|
|
188
188
|
400
|
|
189
189
|
));
|
|
190
|
-
const l =
|
|
191
|
-
return I(a,
|
|
190
|
+
const l = o.split(".")[0], g = await c.generateSQL(l, a, n);
|
|
191
|
+
return I(a, g);
|
|
192
192
|
} catch (e) {
|
|
193
|
-
return t.log.error(e, "SQL generation error"), r.status(500).send(
|
|
193
|
+
return t.log.error(e, "SQL generation error"), r.status(500).send(u(
|
|
194
194
|
e instanceof Error ? e.message : "SQL generation failed",
|
|
195
195
|
500
|
|
196
196
|
));
|
|
197
197
|
}
|
|
198
|
-
}), i.post(`${
|
|
199
|
-
bodyLimit:
|
|
198
|
+
}), i.post(`${p}/dry-run`, {
|
|
199
|
+
bodyLimit: m,
|
|
200
200
|
schema: {
|
|
201
201
|
body: {
|
|
202
202
|
type: "object",
|
|
@@ -205,7 +205,7 @@ const N = function(i, k, R) {
|
|
|
205
205
|
}
|
|
206
206
|
}, async (t, r) => {
|
|
207
207
|
try {
|
|
208
|
-
const e = t.body, a = e.query || e, n = await
|
|
208
|
+
const e = t.body, a = e.query || e, n = await y(t);
|
|
209
209
|
return await M(a, n, c);
|
|
210
210
|
} catch (e) {
|
|
211
211
|
return t.log.error(e, "Dry-run error"), r.status(400).send({
|
|
@@ -213,7 +213,7 @@ const N = function(i, k, R) {
|
|
|
213
213
|
valid: !1
|
|
214
214
|
});
|
|
215
215
|
}
|
|
216
|
-
}), i.get(`${
|
|
216
|
+
}), i.get(`${p}/dry-run`, {
|
|
217
217
|
schema: {
|
|
218
218
|
querystring: {
|
|
219
219
|
type: "object",
|
|
@@ -225,7 +225,7 @@ const N = function(i, k, R) {
|
|
|
225
225
|
}
|
|
226
226
|
}, async (t, r) => {
|
|
227
227
|
try {
|
|
228
|
-
const { query: e } = t.query, a = JSON.parse(e), n = await
|
|
228
|
+
const { query: e } = t.query, a = JSON.parse(e), n = await y(t);
|
|
229
229
|
return await M(a, n, c);
|
|
230
230
|
} catch (e) {
|
|
231
231
|
return t.log.error(e, "Dry-run error"), r.status(400).send({
|
|
@@ -233,8 +233,8 @@ const N = function(i, k, R) {
|
|
|
233
233
|
valid: !1
|
|
234
234
|
});
|
|
235
235
|
}
|
|
236
|
-
}), i.post(`${
|
|
237
|
-
bodyLimit:
|
|
236
|
+
}), i.post(`${p}/explain`, {
|
|
237
|
+
bodyLimit: m,
|
|
238
238
|
schema: {
|
|
239
239
|
body: {
|
|
240
240
|
type: "object",
|
|
@@ -243,17 +243,17 @@ const N = function(i, k, R) {
|
|
|
243
243
|
}
|
|
244
244
|
}, async (t, r) => {
|
|
245
245
|
try {
|
|
246
|
-
const e = t.body, a = e.query || e, n = e.options || {},
|
|
247
|
-
return
|
|
248
|
-
error: `Query validation failed: ${
|
|
246
|
+
const e = t.body, a = e.query || e, n = e.options || {}, s = await y(t), o = c.validateQuery(a);
|
|
247
|
+
return o.isValid ? await c.explainQuery(a, s, n) : r.status(400).send({
|
|
248
|
+
error: `Query validation failed: ${o.errors.join(", ")}`
|
|
249
249
|
});
|
|
250
250
|
} catch (e) {
|
|
251
251
|
return t.log.error(e, "Explain error"), r.status(500).send({
|
|
252
252
|
error: e instanceof Error ? e.message : "Explain query failed"
|
|
253
253
|
});
|
|
254
254
|
}
|
|
255
|
-
}),
|
|
256
|
-
bodyLimit:
|
|
255
|
+
}), v && i.post(`${p}/agent/chat`, {
|
|
256
|
+
bodyLimit: m,
|
|
257
257
|
schema: {
|
|
258
258
|
body: {
|
|
259
259
|
type: "object",
|
|
@@ -262,43 +262,44 @@ const N = function(i, k, R) {
|
|
|
262
262
|
}
|
|
263
263
|
}, async (t, r) => {
|
|
264
264
|
try {
|
|
265
|
-
const { handleAgentChat: e } = await import("../handler-
|
|
265
|
+
const { handleAgentChat: e } = await import("../handler-DZnCbydH.js"), a = t.body, { message: n, sessionId: s, history: o } = a;
|
|
266
266
|
if (!n || typeof n != "string")
|
|
267
267
|
return r.status(400).send({ error: "message is required and must be a string" });
|
|
268
|
-
let
|
|
269
|
-
if (
|
|
270
|
-
const
|
|
271
|
-
|
|
268
|
+
let l = (v.apiKey || "").trim();
|
|
269
|
+
if (v.allowClientApiKey) {
|
|
270
|
+
const d = t.headers["x-agent-api-key"];
|
|
271
|
+
d && (l = d.trim());
|
|
272
272
|
}
|
|
273
|
-
if (!
|
|
273
|
+
if (!l)
|
|
274
274
|
return r.status(401).send({
|
|
275
275
|
error: "No API key configured. Set agent.apiKey in server config or send X-Agent-Api-Key header."
|
|
276
276
|
});
|
|
277
|
-
const
|
|
277
|
+
const g = await y(t);
|
|
278
278
|
r.raw.writeHead(200, {
|
|
279
279
|
"Content-Type": "text/event-stream",
|
|
280
280
|
"Cache-Control": "no-cache",
|
|
281
281
|
Connection: "keep-alive"
|
|
282
282
|
});
|
|
283
283
|
try {
|
|
284
|
-
const
|
|
284
|
+
const d = e({
|
|
285
285
|
message: n,
|
|
286
|
-
sessionId:
|
|
286
|
+
sessionId: s,
|
|
287
|
+
history: o,
|
|
287
288
|
semanticLayer: c,
|
|
288
|
-
securityContext:
|
|
289
|
-
agentConfig:
|
|
290
|
-
apiKey:
|
|
289
|
+
securityContext: g,
|
|
290
|
+
agentConfig: v,
|
|
291
|
+
apiKey: l
|
|
291
292
|
});
|
|
292
|
-
for await (const
|
|
293
|
-
r.raw.write(`data: ${JSON.stringify(
|
|
293
|
+
for await (const h of d)
|
|
294
|
+
r.raw.write(`data: ${JSON.stringify(h)}
|
|
294
295
|
|
|
295
296
|
`);
|
|
296
|
-
} catch (
|
|
297
|
-
const
|
|
297
|
+
} catch (d) {
|
|
298
|
+
const h = {
|
|
298
299
|
type: "error",
|
|
299
|
-
data: { message:
|
|
300
|
+
data: { message: d instanceof Error ? d.message : "Stream failed" }
|
|
300
301
|
};
|
|
301
|
-
r.raw.write(`data: ${JSON.stringify(
|
|
302
|
+
r.raw.write(`data: ${JSON.stringify(h)}
|
|
302
303
|
|
|
303
304
|
`);
|
|
304
305
|
} finally {
|
|
@@ -310,10 +311,10 @@ const N = function(i, k, R) {
|
|
|
310
311
|
error: e instanceof Error ? e.message : "Agent chat failed"
|
|
311
312
|
});
|
|
312
313
|
}
|
|
313
|
-
}),
|
|
314
|
-
const t =
|
|
314
|
+
}), f.enabled !== !1) {
|
|
315
|
+
const t = f.basePath ?? "/mcp";
|
|
315
316
|
i.post(`${t}`, {
|
|
316
|
-
bodyLimit:
|
|
317
|
+
bodyLimit: m,
|
|
317
318
|
schema: {
|
|
318
319
|
body: {
|
|
319
320
|
type: "object",
|
|
@@ -323,40 +324,40 @@ const N = function(i, k, R) {
|
|
|
323
324
|
}, async (r, e) => {
|
|
324
325
|
const a = K(
|
|
325
326
|
r.headers.origin,
|
|
326
|
-
|
|
327
|
+
f.allowedOrigins ? { allowedOrigins: f.allowedOrigins } : {}
|
|
327
328
|
);
|
|
328
329
|
if (!a.valid)
|
|
329
330
|
return e.status(403).send(x(null, -32600, a.reason));
|
|
330
331
|
const n = r.headers.accept;
|
|
331
332
|
if (!T(n))
|
|
332
333
|
return e.status(400).send(x(null, -32600, "Accept header must include both application/json and text/event-stream"));
|
|
333
|
-
const
|
|
334
|
-
if (!
|
|
334
|
+
const s = V(r.headers);
|
|
335
|
+
if (!s.ok)
|
|
335
336
|
return e.status(426).send({
|
|
336
337
|
error: "Unsupported MCP protocol version",
|
|
337
|
-
supported:
|
|
338
|
+
supported: s.supported
|
|
338
339
|
});
|
|
339
|
-
const
|
|
340
|
-
if (!
|
|
340
|
+
const o = z(r.body);
|
|
341
|
+
if (!o)
|
|
341
342
|
return e.status(400).send(x(null, -32600, "Invalid JSON-RPC 2.0 request"));
|
|
342
|
-
const l = _(n),
|
|
343
|
+
const l = _(n), g = o.method === "initialize";
|
|
343
344
|
try {
|
|
344
|
-
const
|
|
345
|
-
|
|
346
|
-
|
|
345
|
+
const d = await B(
|
|
346
|
+
o.method,
|
|
347
|
+
o.params,
|
|
347
348
|
{
|
|
348
349
|
semanticLayer: c,
|
|
349
|
-
extractSecurityContext:
|
|
350
|
+
extractSecurityContext: y,
|
|
350
351
|
rawRequest: r,
|
|
351
352
|
rawResponse: e,
|
|
352
|
-
negotiatedProtocol:
|
|
353
|
+
negotiatedProtocol: s.negotiated
|
|
353
354
|
}
|
|
354
355
|
);
|
|
355
|
-
if (j(
|
|
356
|
+
if (j(o))
|
|
356
357
|
return e.status(202).send();
|
|
357
|
-
const
|
|
358
|
-
|
|
359
|
-
const C = U(
|
|
358
|
+
const h = g && d && typeof d == "object" && "sessionId" in d ? d.sessionId : void 0;
|
|
359
|
+
h && e.header(F, h);
|
|
360
|
+
const C = U(o.id ?? null, d);
|
|
360
361
|
if (l) {
|
|
361
362
|
const w = E();
|
|
362
363
|
e.header("Content-Type", "text/event-stream").header("Cache-Control", "no-cache").header("Connection", "keep-alive").send(`id: ${w}
|
|
@@ -365,11 +366,11 @@ ${P(C, w)}`);
|
|
|
365
366
|
return;
|
|
366
367
|
}
|
|
367
368
|
return e.send(C);
|
|
368
|
-
} catch (
|
|
369
|
-
if (j(
|
|
370
|
-
return r.log.error(
|
|
371
|
-
r.log.error(
|
|
372
|
-
const
|
|
369
|
+
} catch (d) {
|
|
370
|
+
if (j(o))
|
|
371
|
+
return r.log.error(d, "MCP notification processing error"), e.status(202).send();
|
|
372
|
+
r.log.error(d, "MCP RPC error");
|
|
373
|
+
const h = d?.code ?? -32603, C = d?.data, w = d.message || "MCP request failed", Q = x(o.id ?? null, h, w, C);
|
|
373
374
|
if (l) {
|
|
374
375
|
const $ = E();
|
|
375
376
|
e.header("Content-Type", "text/event-stream").header("Cache-Control", "no-cache").header("Connection", "keep-alive").send(`id: ${$}
|
|
@@ -403,17 +404,17 @@ ${P(Q, $)}`);
|
|
|
403
404
|
i.setErrorHandler(async (t, r, e) => {
|
|
404
405
|
r.log.error(t, "Fastify cube adapter error"), e.statusCode < 400 && e.status(500);
|
|
405
406
|
const a = t instanceof Error ? t : String(t);
|
|
406
|
-
return
|
|
407
|
+
return u(a, e.statusCode);
|
|
407
408
|
}), R();
|
|
408
409
|
};
|
|
409
|
-
async function Z(
|
|
410
|
-
await
|
|
410
|
+
async function Z(b, i) {
|
|
411
|
+
await b.register(N, i);
|
|
411
412
|
}
|
|
412
|
-
function ee(
|
|
413
|
+
function ee(b) {
|
|
413
414
|
const i = require("fastify")({
|
|
414
415
|
logger: !0
|
|
415
416
|
});
|
|
416
|
-
return i.register(N,
|
|
417
|
+
return i.register(N, b), i;
|
|
417
418
|
}
|
|
418
419
|
export {
|
|
419
420
|
ee as createCubeApp,
|