drizzle-cube 0.5.1 → 0.5.4
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 +4 -0
- package/dist/adapters/express/index.cjs +2 -2
- package/dist/adapters/express/index.js +105 -104
- package/dist/adapters/fastify/index.cjs +2 -2
- package/dist/adapters/fastify/index.js +107 -106
- package/dist/adapters/{google-CBfBGU4F.js → google-CT4kgmBf.js} +1 -1
- package/dist/adapters/{google-BOAwi9Ib.cjs → google-Dgo9-Kb5.cjs} +1 -1
- package/dist/adapters/{handler-BzzbVpcl.cjs → handler-CNn3q29F.cjs} +13 -13
- package/dist/adapters/{handler-3LGcjLtr.js → handler-_TKfigrZ.js} +33 -34
- package/dist/adapters/hono/index.cjs +1 -1
- package/dist/adapters/hono/index.js +99 -98
- package/dist/adapters/{locale-DTnJrxm1.js → locale-BQQrZYhz.js} +442 -404
- package/dist/adapters/locale-Dl_3R6hP.cjs +198 -0
- package/dist/adapters/mcp-tools.cjs +1 -1
- package/dist/adapters/mcp-tools.js +2 -2
- package/dist/adapters/mcp-transport-CkyawtUT.cjs +40 -0
- package/dist/adapters/mcp-transport-DSbd6M_u.js +586 -0
- package/dist/adapters/mcp-transport.d.ts +22 -0
- package/dist/adapters/nextjs/index.cjs +1 -1
- package/dist/adapters/nextjs/index.js +136 -135
- package/dist/adapters/openai-Bgri5TJc.cjs +16 -0
- package/dist/adapters/{openai-C4BD8xnN.cjs → openai-BjLV_Wjx.cjs} +1 -1
- package/dist/{server/openai-CqZg6zYL.js → adapters/openai-CuUGrKaK.js} +824 -720
- package/dist/adapters/{openai-CaSQEduB.js → openai-DQawCWQb.js} +1 -1
- package/dist/adapters/{utils-DOg9oGdt.js → utils-DG8ti3FT.js} +1121 -687
- package/dist/adapters/utils-DrWvXf0G.cjs +128 -0
- package/dist/adapters/utils.cjs +1 -1
- package/dist/adapters/utils.d.ts +46 -4
- package/dist/adapters/utils.js +1 -1
- package/dist/cli/index.cjs +2 -2
- package/dist/client/charts.js +12 -12
- package/dist/client/chunks/{DashboardEditModal-cSSIAZGy.js → DashboardEditModal-BBcB0E2g.js} +14 -14
- package/dist/client/chunks/{DashboardEditModal-cSSIAZGy.js.map → DashboardEditModal-BBcB0E2g.js.map} +1 -1
- package/dist/client/chunks/{FieldSearchModal-CZNo4pNK.js → FieldSearchModal-CisOov-_.js} +5 -5
- package/dist/client/chunks/{FieldSearchModal-CZNo4pNK.js.map → FieldSearchModal-CisOov-_.js.map} +1 -1
- package/dist/client/chunks/KpiDelta-D09hA_UJ.js +2 -0
- package/dist/client/chunks/KpiNumber-B7F9F9fC.js +2 -0
- package/dist/client/chunks/KpiText-C3ZXOF8b.js +2 -0
- package/dist/client/chunks/{RetentionCombinedChart-BD8tGeM_.js → RetentionCombinedChart-DiyZwiPv.js} +3 -3
- package/dist/client/chunks/{RetentionCombinedChart-BD8tGeM_.js.map → RetentionCombinedChart-DiyZwiPv.js.map} +1 -1
- package/dist/client/chunks/{RetentionHeatmap-B_5sewwi.js → RetentionHeatmap-usGF7BCo.js} +2 -2
- package/dist/client/chunks/{RetentionHeatmap-B_5sewwi.js.map → RetentionHeatmap-usGF7BCo.js.map} +1 -1
- package/dist/client/chunks/SchemaVisualization-DP4k1fPp.js +2 -0
- package/dist/client/chunks/SchemaVisualizationLazy-Brqv_PY9.js +2 -0
- package/dist/client/chunks/{analysis-builder-BeVZhiQ5.js → analysis-builder-0o1W-k3K.js} +8 -8
- package/dist/client/chunks/{analysis-builder-BeVZhiQ5.js.map → analysis-builder-0o1W-k3K.js.map} +1 -1
- package/dist/client/chunks/{analysis-builder-shared-BWc7ZZnG.js → analysis-builder-shared-Cz4KAlIC.js} +9 -9
- package/dist/client/chunks/{analysis-builder-shared-BWc7ZZnG.js.map → analysis-builder-shared-Cz4KAlIC.js.map} +1 -1
- package/dist/client/chunks/{chart-activity-grid-CWT0gLv4.js → chart-activity-grid-VFFm85hC.js} +18 -3
- package/dist/client/chunks/{chart-activity-grid-CWT0gLv4.js.map → chart-activity-grid-VFFm85hC.js.map} +1 -1
- package/dist/client/chunks/{chart-area-D63kG8OT.js → chart-area-CwwIHTmK.js} +3 -3
- package/dist/client/chunks/{chart-area-D63kG8OT.js.map → chart-area-CwwIHTmK.js.map} +1 -1
- package/dist/client/chunks/{chart-bar-BEfsCLjl.js → chart-bar-Bmny922L.js} +3 -3
- package/dist/client/chunks/{chart-bar-BEfsCLjl.js.map → chart-bar-Bmny922L.js.map} +1 -1
- package/dist/client/chunks/{chart-box-plot-o-h9MRX5.js → chart-box-plot-DM7GwtCV.js} +2 -2
- package/dist/client/chunks/{chart-box-plot-o-h9MRX5.js.map → chart-box-plot-DM7GwtCV.js.map} +1 -1
- package/dist/client/chunks/{chart-bubble-CMDp4Pfm.js → chart-bubble-DJOq4IpT.js} +2 -2
- package/dist/client/chunks/{chart-bubble-CMDp4Pfm.js.map → chart-bubble-DJOq4IpT.js.map} +1 -1
- package/dist/client/chunks/{chart-candlestick-WyANJ0Ky.js → chart-candlestick-C2nzVCv1.js} +2 -2
- package/dist/client/chunks/{chart-candlestick-WyANJ0Ky.js.map → chart-candlestick-C2nzVCv1.js.map} +1 -1
- package/dist/client/chunks/{chart-data-table-C3Xh9jwL.js → chart-data-table-zZtwLf55.js} +31 -31
- package/dist/client/chunks/chart-data-table-zZtwLf55.js.map +1 -0
- package/dist/client/chunks/{chart-funnel-C7pgktN5.js → chart-funnel-COTJy8BP.js} +2 -2
- package/dist/client/chunks/{chart-funnel-C7pgktN5.js.map → chart-funnel-COTJy8BP.js.map} +1 -1
- package/dist/client/chunks/{chart-gauge-D2r2B_AR.js → chart-gauge-C8lIneI0.js} +2 -2
- package/dist/client/chunks/{chart-gauge-D2r2B_AR.js.map → chart-gauge-C8lIneI0.js.map} +1 -1
- package/dist/client/chunks/{chart-heat-map-Dw2yjwfO.js → chart-heat-map-BJXt3RMt.js} +2 -2
- package/dist/client/chunks/{chart-heat-map-Dw2yjwfO.js.map → chart-heat-map-BJXt3RMt.js.map} +1 -1
- package/dist/client/chunks/{chart-kpi-delta-CYE0S1x_.js → chart-kpi-delta-DHkNqufb.js} +4 -4
- package/dist/client/chunks/{chart-kpi-delta-CYE0S1x_.js.map → chart-kpi-delta-DHkNqufb.js.map} +1 -1
- package/dist/client/chunks/{chart-kpi-number-BlZ79xHW.js → chart-kpi-number-BrXw7m-S.js} +6 -6
- package/dist/client/chunks/{chart-kpi-number-BlZ79xHW.js.map → chart-kpi-number-BrXw7m-S.js.map} +1 -1
- package/dist/client/chunks/{chart-kpi-text-DY1BnxPe.js → chart-kpi-text-D0plngLV.js} +3 -3
- package/dist/client/chunks/{chart-kpi-text-DY1BnxPe.js.map → chart-kpi-text-D0plngLV.js.map} +1 -1
- package/dist/client/chunks/{chart-line-CBsTThTv.js → chart-line-DKvW32U-.js} +3 -3
- package/dist/client/chunks/{chart-line-CBsTThTv.js.map → chart-line-DKvW32U-.js.map} +1 -1
- package/dist/client/chunks/{chart-markdown-BWaWVkuz.js → chart-markdown-CJU2hUq3.js} +1204 -1140
- package/dist/client/chunks/chart-markdown-CJU2hUq3.js.map +1 -0
- package/dist/client/chunks/{chart-measure-profile-B41qCTBG.js → chart-measure-profile-DNT_tbh4.js} +3 -3
- package/dist/client/chunks/{chart-measure-profile-B41qCTBG.js.map → chart-measure-profile-DNT_tbh4.js.map} +1 -1
- package/dist/client/chunks/{chart-pie-Djbu8x2v.js → chart-pie-CzYnncO-.js} +3 -3
- package/dist/client/chunks/{chart-pie-Djbu8x2v.js.map → chart-pie-CzYnncO-.js.map} +1 -1
- package/dist/client/chunks/{chart-radar-BsTcKV0K.js → chart-radar-8iAt3QZl.js} +3 -3
- package/dist/client/chunks/{chart-radar-BsTcKV0K.js.map → chart-radar-8iAt3QZl.js.map} +1 -1
- package/dist/client/chunks/{chart-radial-bar-Du7XNnwE.js → chart-radial-bar-CJbG7RIe.js} +3 -3
- package/dist/client/chunks/{chart-radial-bar-Du7XNnwE.js.map → chart-radial-bar-CJbG7RIe.js.map} +1 -1
- package/dist/client/chunks/{chart-sankey-WwkZAhLy.js → chart-sankey-C-wLBUmb.js} +2 -2
- package/dist/client/chunks/{chart-sankey-WwkZAhLy.js.map → chart-sankey-C-wLBUmb.js.map} +1 -1
- package/dist/client/chunks/{chart-scatter-D8krEYsA.js → chart-scatter-NMjD1lbW.js} +3 -3
- package/dist/client/chunks/{chart-scatter-D8krEYsA.js.map → chart-scatter-NMjD1lbW.js.map} +1 -1
- package/dist/client/chunks/{chart-sunburst-CIDB_pTl.js → chart-sunburst-HtJ-LJ7n.js} +3 -3
- package/dist/client/chunks/{chart-sunburst-CIDB_pTl.js.map → chart-sunburst-HtJ-LJ7n.js.map} +1 -1
- package/dist/client/chunks/{chart-tree-map-C5C2iaWM.js → chart-tree-map-CetaLMt8.js} +3 -3
- package/dist/client/chunks/{chart-tree-map-C5C2iaWM.js.map → chart-tree-map-CetaLMt8.js.map} +1 -1
- package/dist/client/chunks/{chart-waterfall-BGdPrJ5Y.js → chart-waterfall-ontNp1Sd.js} +3 -3
- package/dist/client/chunks/{chart-waterfall-BGdPrJ5Y.js.map → chart-waterfall-ontNp1Sd.js.map} +1 -1
- package/dist/client/chunks/{charts-core-BXOqaYFn.js → charts-core-B5UXUg6_.js} +2 -2
- package/dist/client/chunks/{charts-core-BXOqaYFn.js.map → charts-core-B5UXUg6_.js.map} +1 -1
- package/dist/client/chunks/{core-DcfMGTVa.js → core-Dk6z6kC0.js} +2 -2
- package/dist/client/chunks/{core-DcfMGTVa.js.map → core-Dk6z6kC0.js.map} +1 -1
- package/dist/client/chunks/{exceljs.min-CcjgM-qg.js → exceljs.min-DaJsLlWM.js} +24 -24
- package/dist/client/chunks/{exceljs.min-CcjgM-qg.js.map → exceljs.min-DaJsLlWM.js.map} +1 -1
- package/dist/client/chunks/{nl-NL-vCifBijs.js → nl-NL-DDf0OdfW.js} +17 -2
- package/dist/client/chunks/{nl-NL-vCifBijs.js.map → nl-NL-DDf0OdfW.js.map} +1 -1
- package/dist/client/chunks/{schema-visualization-Xp60Ff2W.js → schema-visualization-cnB2xZxn.js} +9 -9
- package/dist/client/chunks/{schema-visualization-Xp60Ff2W.js.map → schema-visualization-cnB2xZxn.js.map} +1 -1
- package/dist/client/chunks/{syntaxHighlighting-CnDujqwg.js → syntaxHighlighting-D8J6Yt9j.js} +2 -2
- package/dist/client/chunks/{syntaxHighlighting-CnDujqwg.js.map → syntaxHighlighting-D8J6Yt9j.js.map} +1 -1
- package/dist/client/chunks/{useDebounce-CfmUMFau.js → useDebounce-BOBSvhHy.js} +4 -4
- package/dist/client/chunks/{useDebounce-CfmUMFau.js.map → useDebounce-BOBSvhHy.js.map} +1 -1
- package/dist/client/chunks/{useExplainAI-BKGmejIj.js → useExplainAI-B_Pi4eXW.js} +4 -4
- package/dist/client/chunks/{useExplainAI-BKGmejIj.js.map → useExplainAI-B_Pi4eXW.js.map} +1 -1
- package/dist/client/chunks/{utils-BldkcRHv.js → utils-BIuqPQuJ.js} +2 -2
- package/dist/client/chunks/{utils-BldkcRHv.js.map → utils-BIuqPQuJ.js.map} +1 -1
- package/dist/client/chunks/{vendor-ClXpIiea.js → vendor-BxLCTfvm.js} +8 -8
- package/dist/client/chunks/{vendor-ClXpIiea.js.map → vendor-BxLCTfvm.js.map} +1 -1
- package/dist/client/components.js +3 -3
- package/dist/client/hooks.js +3 -3
- package/dist/client/icons.js +1 -1
- package/dist/client/index.js +15 -15
- package/dist/client/providers.js +1 -1
- package/dist/client/schema.js +1 -1
- package/dist/client/utils.js +6 -6
- package/dist/client-bundle-stats.html +1 -1
- package/dist/mcp-app/mcp-app.html +27 -27
- package/dist/server/index.cjs +145 -144
- package/dist/server/index.js +1960 -1868
- package/dist/server/{openai-D9Zjuby1.cjs → openai-BfiZU0rG.cjs} +1 -1
- package/dist/server/openai-BwsBio1K.cjs +16 -0
- package/dist/server/{openai-rwauPzCT.js → openai-CLWSwD-D.js} +1 -1
- package/dist/{adapters/openai-BAnEZgKZ.js → server/openai-zpXlGbbF.js} +824 -720
- package/package.json +2 -2
- package/dist/adapters/locale-DueXjqMh.cjs +0 -198
- package/dist/adapters/mcp-prompts-BUFyQLHQ.js +0 -377
- package/dist/adapters/mcp-prompts-B_NvEJT_.cjs +0 -111
- package/dist/adapters/mcp-transport-C7VLf4T5.js +0 -579
- package/dist/adapters/mcp-transport-poPHl_2j.cjs +0 -39
- package/dist/adapters/openai-4JP2B6pB.cjs +0 -16
- package/dist/adapters/utils-DNrj-ryp.cjs +0 -17
- package/dist/client/chunks/KpiDelta-Dll_eCV1.js +0 -2
- package/dist/client/chunks/KpiNumber-BPlR92hI.js +0 -2
- package/dist/client/chunks/KpiText-BIxq7Jso.js +0 -2
- package/dist/client/chunks/SchemaVisualization-CCICjhvv.js +0 -2
- package/dist/client/chunks/SchemaVisualizationLazy-DraGsMx6.js +0 -2
- package/dist/client/chunks/chart-data-table-C3Xh9jwL.js.map +0 -1
- package/dist/client/chunks/chart-markdown-BWaWVkuz.js.map +0 -1
- package/dist/server/openai-DmuEbFd6.cjs +0 -16
- /package/dist/adapters/{anthropic-Cto4Jxqt.cjs → anthropic-BIva8k1r.cjs} +0 -0
- /package/dist/adapters/{anthropic-DpEbCVvF.js → anthropic-B_rg0BhK.js} +0 -0
- /package/dist/adapters/{dist-BnyV9wfA.cjs → dist-Boc63-1q.cjs} +0 -0
- /package/dist/adapters/{dist-DjVh2RFz.js → dist-De5fzUEM.js} +0 -0
|
@@ -1,46 +1,46 @@
|
|
|
1
|
-
import { a as e, f as t, i as n, o as r, r as i, u as a,
|
|
2
|
-
import { i as s, n as c, r as l, t as u } from "../locale-
|
|
3
|
-
import {
|
|
1
|
+
import { a as e, f as t, i as n, o as r, r as i, u as a, w as o } from "../utils-DG8ti3FT.js";
|
|
2
|
+
import { i as s, n as c, r as l, t as u } from "../locale-BQQrZYhz.js";
|
|
3
|
+
import { C as d, S as f, _ as p, a as m, b as h, c as g, g as _, h as v, i as y, l as b, m as x, o as S, r as C, u as w, v as T, x as E, y as D } from "../mcp-transport-DSbd6M_u.js";
|
|
4
4
|
//#region src/adapters/fastify/index.ts
|
|
5
|
-
var
|
|
6
|
-
let { cubes:
|
|
7
|
-
if (!
|
|
8
|
-
let
|
|
9
|
-
if (
|
|
5
|
+
var O = function(o, O, k) {
|
|
6
|
+
let { cubes: A, drizzle: j, schema: M, extractSecurityContext: N, engineType: P, cors: F, basePath: I = "/cubejs-api/v1", bodyLimit: L = 10485760, cache: R, mcp: z = { enabled: !0 }, agent: B } = O;
|
|
7
|
+
if (!A || A.length === 0) return k(/* @__PURE__ */ Error("At least one cube must be provided in the cubes array"));
|
|
8
|
+
let V = async (e) => l(await N(e), c((t) => e.headers[t.toLowerCase()]));
|
|
9
|
+
if (F) {
|
|
10
10
|
let e = {
|
|
11
|
-
...
|
|
12
|
-
allowedHeaders: u(
|
|
11
|
+
...F,
|
|
12
|
+
allowedHeaders: u(F.allowedHeaders)
|
|
13
13
|
};
|
|
14
14
|
o.register(import("@fastify/cors"), e);
|
|
15
15
|
}
|
|
16
16
|
o.addHook("onRequest", async (e, t) => {
|
|
17
17
|
e.method === "POST" && (e.body = void 0);
|
|
18
18
|
});
|
|
19
|
-
let
|
|
20
|
-
drizzle:
|
|
21
|
-
schema:
|
|
22
|
-
engineType:
|
|
23
|
-
cache:
|
|
24
|
-
rlsSetup:
|
|
19
|
+
let H = new s({
|
|
20
|
+
drizzle: j,
|
|
21
|
+
schema: M,
|
|
22
|
+
engineType: P,
|
|
23
|
+
cache: R,
|
|
24
|
+
rlsSetup: O.rlsSetup
|
|
25
25
|
});
|
|
26
|
-
if (
|
|
27
|
-
|
|
28
|
-
}), o.post(`${
|
|
29
|
-
bodyLimit:
|
|
26
|
+
if (A.forEach((e) => {
|
|
27
|
+
H.registerCube(e);
|
|
28
|
+
}), o.post(`${I}/load`, {
|
|
29
|
+
bodyLimit: L,
|
|
30
30
|
schema: { body: {
|
|
31
31
|
type: "object",
|
|
32
32
|
additionalProperties: !0
|
|
33
33
|
} }
|
|
34
34
|
}, async (e, t) => {
|
|
35
35
|
try {
|
|
36
|
-
let r = e.body, a = r.query || r, o = await
|
|
36
|
+
let r = e.body, a = r.query || r, o = await V(e), s = H.validateQuery(a);
|
|
37
37
|
if (!s.isValid) return t.status(400).send(n(`Query validation failed: ${s.errors.join(", ")}`, 400));
|
|
38
38
|
let c = e.headers["x-cache-control"] === "no-cache";
|
|
39
|
-
return i(a, await
|
|
39
|
+
return i(a, await H.executeMultiCubeQuery(a, o, { skipCache: c }), H);
|
|
40
40
|
} catch (r) {
|
|
41
41
|
return e.log.error(r, "Query execution error"), t.status(500).send(n(r instanceof Error ? r.message : "Query execution failed", 500));
|
|
42
42
|
}
|
|
43
|
-
}), o.get(`${
|
|
43
|
+
}), o.get(`${I}/load`, { schema: { querystring: {
|
|
44
44
|
type: "object",
|
|
45
45
|
properties: { query: { type: "string" } },
|
|
46
46
|
required: ["query"]
|
|
@@ -52,15 +52,15 @@ var D = function(o, D, O) {
|
|
|
52
52
|
} catch {
|
|
53
53
|
return t.status(400).send(n("Invalid JSON in query parameter", 400));
|
|
54
54
|
}
|
|
55
|
-
let o = await
|
|
55
|
+
let o = await V(e), s = H.validateQuery(a);
|
|
56
56
|
if (!s.isValid) return t.status(400).send(n(`Query validation failed: ${s.errors.join(", ")}`, 400));
|
|
57
|
-
let c = e.headers["x-cache-control"] === "no-cache", l = await
|
|
58
|
-
return i(a, l,
|
|
57
|
+
let c = e.headers["x-cache-control"] === "no-cache", l = await H.executeMultiCubeQuery(a, o, { skipCache: c });
|
|
58
|
+
return i(a, l, H);
|
|
59
59
|
} catch (r) {
|
|
60
60
|
return e.log.error(r, "Query execution error"), t.status(500).send(n(r instanceof Error ? r.message : "Query execution failed", 500));
|
|
61
61
|
}
|
|
62
|
-
}), o.post(`${
|
|
63
|
-
bodyLimit:
|
|
62
|
+
}), o.post(`${I}/batch`, {
|
|
63
|
+
bodyLimit: L,
|
|
64
64
|
schema: { body: {
|
|
65
65
|
type: "object",
|
|
66
66
|
required: ["queries"],
|
|
@@ -72,50 +72,50 @@ var D = function(o, D, O) {
|
|
|
72
72
|
}, async (e, t) => {
|
|
73
73
|
try {
|
|
74
74
|
let { queries: r } = e.body;
|
|
75
|
-
return !r || !Array.isArray(r) ? t.status(400).send(n("Request body must contain a \"queries\" array", 400)) : r.length === 0 ? t.status(400).send(n("Queries array cannot be empty", 400)) : await a(r, await
|
|
75
|
+
return !r || !Array.isArray(r) ? t.status(400).send(n("Request body must contain a \"queries\" array", 400)) : r.length === 0 ? t.status(400).send(n("Queries array cannot be empty", 400)) : await a(r, await V(e), H, { skipCache: e.headers["x-cache-control"] === "no-cache" });
|
|
76
76
|
} catch (r) {
|
|
77
77
|
return e.log.error(r, "Batch execution error"), t.status(500).send(n(r instanceof Error ? r.message : "Batch execution failed", 500));
|
|
78
78
|
}
|
|
79
|
-
}), o.get(`${
|
|
79
|
+
}), o.get(`${I}/meta`, async (t, r) => {
|
|
80
80
|
try {
|
|
81
|
-
return e(
|
|
81
|
+
return e(H.getMetadata());
|
|
82
82
|
} catch (e) {
|
|
83
83
|
return t.log.error(e, "Metadata error"), r.status(500).send(n(e instanceof Error ? e.message : "Failed to fetch metadata", 500));
|
|
84
84
|
}
|
|
85
|
-
}), o.post(`${
|
|
86
|
-
bodyLimit:
|
|
85
|
+
}), o.post(`${I}/sql`, {
|
|
86
|
+
bodyLimit: L,
|
|
87
87
|
schema: { body: {
|
|
88
88
|
type: "object",
|
|
89
89
|
additionalProperties: !0
|
|
90
90
|
} }
|
|
91
91
|
}, async (e, t) => {
|
|
92
92
|
try {
|
|
93
|
-
let i = e.body, a = await
|
|
93
|
+
let i = e.body, a = await V(e), o = H.validateQuery(i);
|
|
94
94
|
if (!o.isValid) return t.status(400).send(n(`Query validation failed: ${o.errors.join(", ")}`, 400));
|
|
95
95
|
let s = i.measures?.[0] || i.dimensions?.[0];
|
|
96
96
|
if (!s) return t.status(400).send(n("No measures or dimensions specified", 400));
|
|
97
97
|
let c = s.split(".")[0];
|
|
98
|
-
return r(i, await
|
|
98
|
+
return r(i, await H.generateSQL(c, i, a));
|
|
99
99
|
} catch (r) {
|
|
100
100
|
return e.log.error({ err: String(r).replace(/\n|\r/g, "") }, "SQL generation error"), t.status(500).send(n(r instanceof Error ? r.message : "SQL generation failed", 500));
|
|
101
101
|
}
|
|
102
|
-
}), o.get(`${
|
|
102
|
+
}), o.get(`${I}/sql`, { schema: { querystring: {
|
|
103
103
|
type: "object",
|
|
104
104
|
properties: { query: { type: "string" } },
|
|
105
105
|
required: ["query"]
|
|
106
106
|
} } }, async (e, t) => {
|
|
107
107
|
try {
|
|
108
|
-
let { query: i } = e.query, a = JSON.parse(i), o = await
|
|
108
|
+
let { query: i } = e.query, a = JSON.parse(i), o = await V(e), s = H.validateQuery(a);
|
|
109
109
|
if (!s.isValid) return t.status(400).send(n(`Query validation failed: ${s.errors.join(", ")}`, 400));
|
|
110
110
|
let c = a.measures?.[0] || a.dimensions?.[0];
|
|
111
111
|
if (!c) return t.status(400).send(n("No measures or dimensions specified", 400));
|
|
112
112
|
let l = c.split(".")[0];
|
|
113
|
-
return r(a, await
|
|
113
|
+
return r(a, await H.generateSQL(l, a, o));
|
|
114
114
|
} catch (r) {
|
|
115
115
|
return e.log.error({ err: String(r).replace(/\n|\r/g, "") }, "SQL generation error"), t.status(500).send(n(r instanceof Error ? r.message : "SQL generation failed", 500));
|
|
116
116
|
}
|
|
117
|
-
}), o.post(`${
|
|
118
|
-
bodyLimit:
|
|
117
|
+
}), o.post(`${I}/dry-run`, {
|
|
118
|
+
bodyLimit: L,
|
|
119
119
|
schema: { body: {
|
|
120
120
|
type: "object",
|
|
121
121
|
additionalProperties: !0
|
|
@@ -123,57 +123,57 @@ var D = function(o, D, O) {
|
|
|
123
123
|
}, async (e, n) => {
|
|
124
124
|
try {
|
|
125
125
|
let n = e.body;
|
|
126
|
-
return await t(n.query || n, await
|
|
126
|
+
return await t(n.query || n, await V(e), H);
|
|
127
127
|
} catch (t) {
|
|
128
128
|
return e.log.error(t, "Dry-run error"), n.status(400).send({
|
|
129
129
|
error: t instanceof Error ? t.message : "Dry-run validation failed",
|
|
130
130
|
valid: !1
|
|
131
131
|
});
|
|
132
132
|
}
|
|
133
|
-
}), o.get(`${
|
|
133
|
+
}), o.get(`${I}/dry-run`, { schema: { querystring: {
|
|
134
134
|
type: "object",
|
|
135
135
|
properties: { query: { type: "string" } },
|
|
136
136
|
required: ["query"]
|
|
137
137
|
} } }, async (e, n) => {
|
|
138
138
|
try {
|
|
139
139
|
let { query: n } = e.query;
|
|
140
|
-
return await t(JSON.parse(n), await
|
|
140
|
+
return await t(JSON.parse(n), await V(e), H);
|
|
141
141
|
} catch (t) {
|
|
142
142
|
return e.log.error(t, "Dry-run error"), n.status(400).send({
|
|
143
143
|
error: t instanceof Error ? t.message : "Dry-run validation failed",
|
|
144
144
|
valid: !1
|
|
145
145
|
});
|
|
146
146
|
}
|
|
147
|
-
}), o.post(`${
|
|
148
|
-
bodyLimit:
|
|
147
|
+
}), o.post(`${I}/explain`, {
|
|
148
|
+
bodyLimit: L,
|
|
149
149
|
schema: { body: {
|
|
150
150
|
type: "object",
|
|
151
151
|
additionalProperties: !0
|
|
152
152
|
} }
|
|
153
153
|
}, async (e, t) => {
|
|
154
154
|
try {
|
|
155
|
-
let n = e.body, r = n.query || n, i = n.options || {}, a = await
|
|
156
|
-
return o.isValid ? await
|
|
155
|
+
let n = e.body, r = n.query || n, i = n.options || {}, a = await V(e), o = H.validateQuery(r);
|
|
156
|
+
return o.isValid ? await H.explainQuery(r, a, i) : t.status(400).send({ error: `Query validation failed: ${o.errors.join(", ")}` });
|
|
157
157
|
} catch (n) {
|
|
158
158
|
return e.log.error(n, "Explain error"), t.status(500).send({ error: n instanceof Error ? n.message : "Explain query failed" });
|
|
159
159
|
}
|
|
160
|
-
}),
|
|
161
|
-
bodyLimit:
|
|
160
|
+
}), B && o.post(`${I}/agent/chat`, {
|
|
161
|
+
bodyLimit: L,
|
|
162
162
|
schema: { body: {
|
|
163
163
|
type: "object",
|
|
164
164
|
additionalProperties: !0
|
|
165
165
|
} }
|
|
166
166
|
}, async (e, t) => {
|
|
167
167
|
try {
|
|
168
|
-
let { handleAgentChat: n } = await import("../handler-
|
|
168
|
+
let { handleAgentChat: n } = await import("../handler-_TKfigrZ.js"), { message: r, sessionId: i, history: a } = e.body;
|
|
169
169
|
if (!r || typeof r != "string") return t.status(400).send({ error: "message is required and must be a string" });
|
|
170
|
-
let o = (
|
|
171
|
-
if (
|
|
170
|
+
let o = (B.apiKey || "").trim();
|
|
171
|
+
if (B.allowClientApiKey) {
|
|
172
172
|
let t = e.headers["x-agent-api-key"];
|
|
173
173
|
t && (o = t.trim());
|
|
174
174
|
}
|
|
175
175
|
if (!o) return t.status(401).send({ error: "No API key configured. Set agent.apiKey in server config or send X-Agent-Api-Key header." });
|
|
176
|
-
let s =
|
|
176
|
+
let s = B.allowClientApiKey ? e.headers["x-agent-provider"] : void 0, c = B.allowClientApiKey ? e.headers["x-agent-model"] : void 0, l = B.allowClientApiKey ? e.headers["x-agent-provider-endpoint"] : void 0, u = await V(e), d = B.buildSystemContext?.(u);
|
|
177
177
|
t.raw.writeHead(200, {
|
|
178
178
|
"Content-Type": "text/event-stream",
|
|
179
179
|
"Cache-Control": "no-cache",
|
|
@@ -184,9 +184,9 @@ var D = function(o, D, O) {
|
|
|
184
184
|
message: r,
|
|
185
185
|
sessionId: i,
|
|
186
186
|
history: a,
|
|
187
|
-
semanticLayer:
|
|
187
|
+
semanticLayer: H,
|
|
188
188
|
securityContext: u,
|
|
189
|
-
agentConfig:
|
|
189
|
+
agentConfig: B,
|
|
190
190
|
apiKey: o,
|
|
191
191
|
systemContext: d,
|
|
192
192
|
providerOverride: s,
|
|
@@ -206,70 +206,71 @@ var D = function(o, D, O) {
|
|
|
206
206
|
} catch (n) {
|
|
207
207
|
if (e.log.error(n, "Agent chat error"), !t.raw.headersSent) return t.status(500).send({ error: n instanceof Error ? n.message : "Agent chat failed" });
|
|
208
208
|
}
|
|
209
|
-
}),
|
|
210
|
-
let e =
|
|
211
|
-
o.post(`${
|
|
212
|
-
bodyLimit:
|
|
209
|
+
}), z.enabled !== !1) {
|
|
210
|
+
let e = S(H, z.resources), t = D(z.prompts), n = T(z.instructions), r = z.basePath ?? "/mcp";
|
|
211
|
+
o.post(`${r}`, {
|
|
212
|
+
bodyLimit: L,
|
|
213
213
|
schema: { body: {
|
|
214
214
|
type: "object",
|
|
215
215
|
additionalProperties: !0
|
|
216
216
|
} }
|
|
217
|
-
}, async (
|
|
218
|
-
if (
|
|
219
|
-
let
|
|
220
|
-
if (!
|
|
221
|
-
let
|
|
222
|
-
if (!
|
|
223
|
-
let
|
|
224
|
-
if (!
|
|
217
|
+
}, async (r, i) => {
|
|
218
|
+
if (z.resourceMetadataUrl && !w(r.headers.authorization)) return i.header("WWW-Authenticate", g(z.resourceMetadataUrl)), i.status(401).send({ error: "Bearer token required" });
|
|
219
|
+
let a = f(r.headers.origin, z.allowedOrigins ? { allowedOrigins: z.allowedOrigins } : {});
|
|
220
|
+
if (!a.valid) return i.status(403).send(y(null, -32600, a.reason));
|
|
221
|
+
let o = r.headers.accept;
|
|
222
|
+
if (!E(o)) return i.status(400).send(y(null, -32600, "Accept header must include both application/json and text/event-stream"));
|
|
223
|
+
let s = v(r.headers);
|
|
224
|
+
if (!s.ok) return i.status(426).send({
|
|
225
225
|
error: "Unsupported MCP protocol version",
|
|
226
|
-
supported:
|
|
226
|
+
supported: s.supported
|
|
227
227
|
});
|
|
228
|
-
let
|
|
229
|
-
if (!
|
|
230
|
-
let
|
|
228
|
+
let c = _(r.body);
|
|
229
|
+
if (!c) return i.status(400).send(y(null, -32600, "Invalid JSON-RPC 2.0 request"));
|
|
230
|
+
let l = d(o), u = c.method === "initialize";
|
|
231
231
|
try {
|
|
232
|
-
let
|
|
233
|
-
semanticLayer:
|
|
234
|
-
extractSecurityContext: (e, t) =>
|
|
235
|
-
rawRequest:
|
|
236
|
-
rawResponse:
|
|
237
|
-
negotiatedProtocol:
|
|
232
|
+
let a = await b(c.method, c.params, {
|
|
233
|
+
semanticLayer: H,
|
|
234
|
+
extractSecurityContext: (e, t) => V(e),
|
|
235
|
+
rawRequest: r,
|
|
236
|
+
rawResponse: i,
|
|
237
|
+
negotiatedProtocol: s.negotiated,
|
|
238
238
|
resources: e,
|
|
239
239
|
prompts: t,
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
240
|
+
instructions: n,
|
|
241
|
+
appEnabled: !!z.app,
|
|
242
|
+
appConfig: typeof z.app == "object" ? z.app : void 0,
|
|
243
|
+
serverName: z.serverName
|
|
243
244
|
});
|
|
244
|
-
if (
|
|
245
|
-
let
|
|
246
|
-
|
|
247
|
-
let
|
|
248
|
-
if (
|
|
249
|
-
let e =
|
|
250
|
-
|
|
245
|
+
if (x(c)) return i.status(202).send();
|
|
246
|
+
let o = u && a && typeof a == "object" && "sessionId" in a ? a.sessionId : void 0;
|
|
247
|
+
o && i.header(C, o);
|
|
248
|
+
let d = m(c.id ?? null, a);
|
|
249
|
+
if (l) {
|
|
250
|
+
let e = p();
|
|
251
|
+
i.header("Content-Type", "text/event-stream").header("Cache-Control", "no-cache").header("Connection", "keep-alive").send(`id: ${e}\n\n${h(d, e)}`);
|
|
251
252
|
return;
|
|
252
253
|
}
|
|
253
|
-
return
|
|
254
|
+
return i.send(d);
|
|
254
255
|
} catch (e) {
|
|
255
|
-
if (
|
|
256
|
-
|
|
257
|
-
let t = e?.code ?? -32603,
|
|
258
|
-
if (
|
|
259
|
-
let e =
|
|
260
|
-
|
|
256
|
+
if (x(c)) return r.log.error({ err: String(e).replace(/\n|\r/g, "") }, "MCP notification processing error"), i.status(202).send();
|
|
257
|
+
r.log.error({ err: String(e).replace(/\n|\r/g, "") }, "MCP RPC error");
|
|
258
|
+
let t = e?.code ?? -32603, n = e?.data, a = e.message || "MCP request failed", o = y(c.id ?? null, t, a, n);
|
|
259
|
+
if (l) {
|
|
260
|
+
let e = p();
|
|
261
|
+
i.header("Content-Type", "text/event-stream").header("Cache-Control", "no-cache").header("Connection", "keep-alive").send(`id: ${e}\n\n${h(o, e)}`);
|
|
261
262
|
return;
|
|
262
263
|
}
|
|
263
|
-
return
|
|
264
|
+
return i.send(o);
|
|
264
265
|
}
|
|
265
|
-
}), o.get(`${
|
|
266
|
-
if (
|
|
267
|
-
let n =
|
|
266
|
+
}), o.get(`${r}`, async (e, t) => {
|
|
267
|
+
if (z.resourceMetadataUrl && !w(e.headers.authorization)) return t.header("WWW-Authenticate", g(z.resourceMetadataUrl)), t.status(401).send({ error: "Bearer token required" });
|
|
268
|
+
let n = p();
|
|
268
269
|
t.raw.writeHead(200, {
|
|
269
270
|
"Content-Type": "text/event-stream",
|
|
270
271
|
"Cache-Control": "no-cache",
|
|
271
272
|
Connection: "keep-alive"
|
|
272
|
-
}), t.raw.write(
|
|
273
|
+
}), t.raw.write(h({
|
|
273
274
|
jsonrpc: "2.0",
|
|
274
275
|
method: "mcp/ready",
|
|
275
276
|
params: { protocol: "streamable-http" }
|
|
@@ -280,16 +281,16 @@ var D = function(o, D, O) {
|
|
|
280
281
|
e.raw.on("close", () => {
|
|
281
282
|
clearInterval(r);
|
|
282
283
|
});
|
|
283
|
-
}), o.delete(`${
|
|
284
|
+
}), o.delete(`${r}`, async (e, t) => z.resourceMetadataUrl && !w(e.headers.authorization) ? (t.header("WWW-Authenticate", g(z.resourceMetadataUrl)), t.status(401).send({ error: "Bearer token required" })) : t.status(405).send({ error: "Session termination not supported" }));
|
|
284
285
|
}
|
|
285
|
-
o.setErrorHandler(async (e, t, r) => (t.log.error(e, "Fastify cube adapter error"), r.statusCode < 400 && r.status(500), n(e instanceof Error ? e : String(e), r.statusCode))),
|
|
286
|
+
o.setErrorHandler(async (e, t, r) => (t.log.error(e, "Fastify cube adapter error"), r.statusCode < 400 && r.status(500), n(e instanceof Error ? e : String(e), r.statusCode))), k();
|
|
286
287
|
};
|
|
287
|
-
async function
|
|
288
|
-
await e.register(
|
|
288
|
+
async function k(e, t) {
|
|
289
|
+
await e.register(O, t);
|
|
289
290
|
}
|
|
290
|
-
function
|
|
291
|
+
function A(e) {
|
|
291
292
|
let t = o("fastify")({ logger: !0 });
|
|
292
|
-
return t.register(
|
|
293
|
+
return t.register(O, e), t;
|
|
293
294
|
}
|
|
294
295
|
//#endregion
|
|
295
|
-
export {
|
|
296
|
+
export { A as createCubeApp, O as cubePlugin, k as registerCubeRoutes };
|
|
@@ -21,7 +21,7 @@ var t = class {
|
|
|
21
21
|
try {
|
|
22
22
|
this.sdk = await import(
|
|
23
23
|
/* webpackIgnore: true */
|
|
24
|
-
"./dist-
|
|
24
|
+
"./dist-De5fzUEM.js"
|
|
25
25
|
);
|
|
26
26
|
} catch {
|
|
27
27
|
throw Error("@google/generative-ai is required for the Google provider. Install it with: npm install @google/generative-ai");
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
function e(t){let n={};for(let[r,i]of Object.entries(t))if(r===`type`&&typeof i==`string`)n[r]=i.toUpperCase();else if(r===`properties`&&typeof i==`object`&&i){let t={};for(let[n,r]of Object.entries(i))typeof r==`object`&&r?t[n]=e(r):t[n]=r;n[r]=t}else r===`items`&&typeof i==`object`&&i?n[r]=e(i):n[r]=i;return n}var t=class{apiKey;sdk;initialized=!1;constructor(e){this.apiKey=e}async ensureSDK(){if(!this.initialized){try{this.sdk=await Promise.resolve().then(()=>require(`./dist-
|
|
1
|
+
function e(t){let n={};for(let[r,i]of Object.entries(t))if(r===`type`&&typeof i==`string`)n[r]=i.toUpperCase();else if(r===`properties`&&typeof i==`object`&&i){let t={};for(let[n,r]of Object.entries(i))typeof r==`object`&&r?t[n]=e(r):t[n]=r;n[r]=t}else r===`items`&&typeof i==`object`&&i?n[r]=e(i):n[r]=i;return n}var t=class{apiKey;sdk;initialized=!1;constructor(e){this.apiKey=e}async ensureSDK(){if(!this.initialized){try{this.sdk=await Promise.resolve().then(()=>require(`./dist-Boc63-1q.cjs`))}catch{throw Error(`@google/generative-ai is required for the Google provider. Install it with: npm install @google/generative-ai`)}this.initialized=!0}}async createStream(e){await this.ensureSDK();let{GoogleGenerativeAI:t}=this.sdk,n=new t(this.apiKey).getGenerativeModel({model:e.model,systemInstruction:e.system,generationConfig:{maxOutputTokens:e.maxTokens}}),{messages:r}=this.formatMessages(e.messages,e.system),i=this.formatTools(e.tools);return(await n.generateContentStream({contents:r,tools:i.length>0?[{functionDeclarations:i}]:void 0})).stream}async*parseStreamEvents(e){let t=`stop`,n=!1;for await(let r of e){let e=r;e.usageMetadata&&(yield{type:`message_meta`,inputTokens:e.usageMetadata.promptTokenCount,outputTokens:e.usageMetadata.candidatesTokenCount,stopReason:``});let i=e.candidates?.[0];if(!i)continue;i.finishReason&&(t=i.finishReason===`STOP`?`stop`:i.finishReason===`MAX_TOKENS`?`max_tokens`:i.finishReason);let a=i.content?.parts;if(a){for(let e of a)if(e.text&&!e.thought&&(yield{type:`text_delta`,text:e.text}),e.functionCall){n=!0;let t=`gemini-tc-${Date.now()}-${Math.random().toString(36).slice(2,7)}`,r=e.thoughtSignature?{thoughtSignature:e.thoughtSignature}:void 0;yield{type:`tool_use_start`,id:t,name:e.functionCall.name,...r?{metadata:r}:{}},yield{type:`tool_input_delta`,json:JSON.stringify(e.functionCall.args||{})},yield{type:`tool_use_end`}}}}yield{type:`message_meta`,stopReason:n?`tool_use`:t}}formatTools(t){return t.map(t=>({name:t.name,description:t.description,parameters:e(t.parameters)}))}formatMessages(e,t){let n=[];for(let t of e)if(t.role===`tool_result`){let e=t._toolResults;if(e&&e.length>0)n.push({role:`user`,parts:e.map(e=>({functionResponse:{name:e.toolName||e.toolUseId,response:{content:e.content,isError:e.isError||!1}}}))});else{let e=typeof t.content==`string`?t.content:JSON.stringify(t.content);e&&n.push({role:`user`,parts:[{text:e}]})}}else if(t.role===`user`){let e=typeof t.content==`string`?t.content:JSON.stringify(t.content);n.push({role:`user`,parts:[{text:e}]})}else if(t.role===`assistant`)if(typeof t.content==`string`)n.push({role:`model`,parts:[{text:t.content}]});else{let e=t.content,r=[];for(let t of e)if(t.type===`text`&&t.text)r.push({text:t.text});else if(t.type===`tool_use`){let e={functionCall:{name:t.name,args:t.input||{}}};t.metadata?.thoughtSignature&&(e.thoughtSignature=t.metadata.thoughtSignature),r.push(e)}r.length>0&&n.push({role:`model`,parts:r})}return{messages:n}}formatToolResults(e){return{role:`tool_result`,content:e.map(e=>`${e.toolName||e.toolUseId}: ${e.content}`).join(`
|
|
2
2
|
`),_toolResults:e}}shouldContinue(e){return e===`tool_use`}formatError(e){if(!e||!(e instanceof Error))return`Something went wrong. Please try again.`;let t=e.message||``,n=e;return n.status===429?`Too many requests. Please wait a moment and try again.`:n.status===403||n.status===401?`Authentication failed. Please check your API key configuration.`:n.status===503||n.status===500?`The AI service is temporarily unavailable. Please try again in a moment.`:t.includes(`SAFETY`)?`The request was blocked by safety filters. Please rephrase your request.`:t.includes(`RECITATION`)?`The response was blocked due to recitation concerns. Please try a different query.`:t.startsWith(`{`)||t.startsWith(`[`)?`The AI service encountered an error. Please try again.`:t}};exports.GoogleProvider=t;
|