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.
Files changed (140) hide show
  1. package/dist/adapters/express/index.cjs +8 -4
  2. package/dist/adapters/express/index.d.ts +7 -0
  3. package/dist/adapters/express/index.js +189 -139
  4. package/dist/adapters/fastify/index.cjs +8 -4
  5. package/dist/adapters/fastify/index.d.ts +7 -0
  6. package/dist/adapters/fastify/index.js +209 -150
  7. package/dist/adapters/handler-BLcxTuwi.cjs +23 -0
  8. package/dist/adapters/handler-odjn7MIB.js +1880 -0
  9. package/dist/adapters/hono/index.cjs +8 -4
  10. package/dist/adapters/hono/index.d.ts +7 -0
  11. package/dist/adapters/hono/index.js +202 -144
  12. package/dist/adapters/{mcp-transport-YHDZWKOi.js → mcp-transport-CU5g9bxj.js} +7 -3
  13. package/dist/adapters/{mcp-transport-BqLo4hKi.cjs → mcp-transport-KX92EgkF.cjs} +21 -21
  14. package/dist/adapters/nextjs/index.cjs +7 -3
  15. package/dist/adapters/nextjs/index.d.ts +14 -0
  16. package/dist/adapters/nextjs/index.js +220 -144
  17. package/dist/client/charts/chartConfigs.d.ts +2 -9
  18. package/dist/client/charts.js +72 -70
  19. package/dist/client/charts.js.map +1 -1
  20. package/dist/client/chunks/{RetentionCombinedChart.config-C-ILIaEb.js → RetentionCombinedChart.config-Bbp2ghim.js} +2 -1
  21. package/dist/client/chunks/RetentionCombinedChart.config-Bbp2ghim.js.map +1 -0
  22. package/dist/client/chunks/{RetentionHeatmap.config-CIvhc-GT.js → RetentionHeatmap.config-BWf_-vdj.js} +2 -1
  23. package/dist/client/chunks/RetentionHeatmap.config-BWf_-vdj.js.map +1 -0
  24. package/dist/client/chunks/{analysis-builder-CG5VIMYB.js → analysis-builder-Bov_gLsf.js} +1408 -1393
  25. package/dist/client/chunks/analysis-builder-Bov_gLsf.js.map +1 -0
  26. package/dist/client/chunks/{analysis-builder-shared-CjlKJgyA.js → analysis-builder-shared-NBk6y0md.js} +3 -3
  27. package/dist/client/chunks/{analysis-builder-shared-CjlKJgyA.js.map → analysis-builder-shared-NBk6y0md.js.map} +1 -1
  28. package/dist/client/chunks/{chart-activity-grid-DStNr34n.js → chart-activity-grid-CE7xGFQo.js} +2 -2
  29. package/dist/client/chunks/{chart-activity-grid-DStNr34n.js.map → chart-activity-grid-CE7xGFQo.js.map} +1 -1
  30. package/dist/client/chunks/chart-box-plot-Dja4LS3O.js +313 -0
  31. package/dist/client/chunks/chart-box-plot-Dja4LS3O.js.map +1 -0
  32. package/dist/client/chunks/{chart-config-activity-grid-CAlo1cHA.js → chart-config-activity-grid-CmOqDuOT.js} +4 -5
  33. package/dist/client/chunks/chart-config-activity-grid-CmOqDuOT.js.map +1 -0
  34. package/dist/client/chunks/{chart-config-area-CyyJOO2T.js → chart-config-area-CK_GVApT.js} +4 -5
  35. package/dist/client/chunks/chart-config-area-CK_GVApT.js.map +1 -0
  36. package/dist/client/chunks/{chart-config-bar-soxw6m2o.js → chart-config-bar-C8uzktxl.js} +4 -5
  37. package/dist/client/chunks/chart-config-bar-C8uzktxl.js.map +1 -0
  38. package/dist/client/chunks/chart-config-box-plot-D3DA7_pr.js +85 -0
  39. package/dist/client/chunks/chart-config-box-plot-D3DA7_pr.js.map +1 -0
  40. package/dist/client/chunks/{chart-config-bubble-CuSsCHZ4.js → chart-config-bubble-q3DoQX5F.js} +4 -5
  41. package/dist/client/chunks/chart-config-bubble-q3DoQX5F.js.map +1 -0
  42. package/dist/client/chunks/{chart-config-data-table-BhgqwoqT.js → chart-config-data-table-B20Y5JCm.js} +4 -5
  43. package/dist/client/chunks/chart-config-data-table-B20Y5JCm.js.map +1 -0
  44. package/dist/client/chunks/{chart-config-funnel-BlSQYng0.js → chart-config-funnel-3eYnGg8M.js} +4 -5
  45. package/dist/client/chunks/chart-config-funnel-3eYnGg8M.js.map +1 -0
  46. package/dist/client/chunks/{chart-config-heat-map-DHQGFZhX.js → chart-config-heat-map-_wEnTnRA.js} +4 -5
  47. package/dist/client/chunks/chart-config-heat-map-_wEnTnRA.js.map +1 -0
  48. package/dist/client/chunks/{chart-config-kpi-delta-yTA5ug_l.js → chart-config-kpi-delta-DLGZ2A3X.js} +4 -5
  49. package/dist/client/chunks/chart-config-kpi-delta-DLGZ2A3X.js.map +1 -0
  50. package/dist/client/chunks/{chart-config-kpi-number-nVAwDXzq.js → chart-config-kpi-number-K-wzviXF.js} +4 -5
  51. package/dist/client/chunks/chart-config-kpi-number-K-wzviXF.js.map +1 -0
  52. package/dist/client/chunks/{chart-config-kpi-text-DZjqsx-b.js → chart-config-kpi-text-BjYqwqaJ.js} +4 -5
  53. package/dist/client/chunks/chart-config-kpi-text-BjYqwqaJ.js.map +1 -0
  54. package/dist/client/chunks/{chart-config-line-D5ME6w0v.js → chart-config-line-JNagi9tf.js} +4 -5
  55. package/dist/client/chunks/chart-config-line-JNagi9tf.js.map +1 -0
  56. package/dist/client/chunks/{chart-config-markdown-BXKL5TbQ.js → chart-config-markdown-BWQSjJpy.js} +4 -5
  57. package/dist/client/chunks/chart-config-markdown-BWQSjJpy.js.map +1 -0
  58. package/dist/client/chunks/{chart-config-pie-DlHa2jTy.js → chart-config-pie-CNLXb-fr.js} +4 -5
  59. package/dist/client/chunks/chart-config-pie-CNLXb-fr.js.map +1 -0
  60. package/dist/client/chunks/{chart-config-radar-BBAVIF0S.js → chart-config-radar-oxHfRAa3.js} +4 -5
  61. package/dist/client/chunks/chart-config-radar-oxHfRAa3.js.map +1 -0
  62. package/dist/client/chunks/{chart-config-radial-bar-CTwjDRnB.js → chart-config-radial-bar-_Aw3jAEm.js} +4 -5
  63. package/dist/client/chunks/chart-config-radial-bar-_Aw3jAEm.js.map +1 -0
  64. package/dist/client/chunks/{chart-config-sankey-CNAgsMQ4.js → chart-config-sankey-C8FX9hGF.js} +4 -5
  65. package/dist/client/chunks/chart-config-sankey-C8FX9hGF.js.map +1 -0
  66. package/dist/client/chunks/{chart-config-scatter-CWvN2E-X.js → chart-config-scatter-DFKM80eO.js} +4 -5
  67. package/dist/client/chunks/chart-config-scatter-DFKM80eO.js.map +1 -0
  68. package/dist/client/chunks/{chart-config-sunburst-W_SKwaj0.js → chart-config-sunburst-BmC0NLTU.js} +4 -5
  69. package/dist/client/chunks/chart-config-sunburst-BmC0NLTU.js.map +1 -0
  70. package/dist/client/chunks/{chart-config-tree-map-IRAYf9YM.js → chart-config-tree-map-DGMbNTaa.js} +4 -5
  71. package/dist/client/chunks/chart-config-tree-map-DGMbNTaa.js.map +1 -0
  72. package/dist/client/chunks/{chart-data-table-Ch_1c1Zo.js → chart-data-table-Ba_6tuJw.js} +2 -2
  73. package/dist/client/chunks/{chart-data-table-Ch_1c1Zo.js.map → chart-data-table-Ba_6tuJw.js.map} +1 -1
  74. package/dist/client/chunks/{chart-kpi-delta-CWCmi8vL.js → chart-kpi-delta-D9XJoKuA.js} +3 -3
  75. package/dist/client/chunks/{chart-kpi-delta-CWCmi8vL.js.map → chart-kpi-delta-D9XJoKuA.js.map} +1 -1
  76. package/dist/client/chunks/{chart-kpi-number-C-5m3qt5.js → chart-kpi-number-C29Vj2g8.js} +2 -2
  77. package/dist/client/chunks/{chart-kpi-number-C-5m3qt5.js.map → chart-kpi-number-C29Vj2g8.js.map} +1 -1
  78. package/dist/client/chunks/{chart-kpi-text--t4ibPmx.js → chart-kpi-text-CgjjrurK.js} +2 -2
  79. package/dist/client/chunks/{chart-kpi-text--t4ibPmx.js.map → chart-kpi-text-CgjjrurK.js.map} +1 -1
  80. package/dist/client/chunks/chart-markdown-Du4Z2iqK.js +2695 -0
  81. package/dist/client/chunks/chart-markdown-Du4Z2iqK.js.map +1 -0
  82. package/dist/client/chunks/{charts-loader-m5Ussksz.js → charts-loader-HYQFVOo4.js} +14 -13
  83. package/dist/client/chunks/charts-loader-HYQFVOo4.js.map +1 -0
  84. package/dist/client/chunks/{components-D-5p1LVQ.js → components-O0hh7ooo.js} +6 -6
  85. package/dist/client/chunks/components-O0hh7ooo.js.map +1 -0
  86. package/dist/client/chunks/{icons-DRreo6m8.js → icons-DAeqv1iX.js} +7 -7
  87. package/dist/client/chunks/{icons-DRreo6m8.js.map → icons-DAeqv1iX.js.map} +1 -1
  88. package/dist/client/components/AgenticNotebook/AgentChatPanel.d.ts +8 -0
  89. package/dist/client/components/AgenticNotebook/ChatInput.d.ts +14 -0
  90. package/dist/client/components/AgenticNotebook/ChatMessage.d.ts +7 -0
  91. package/dist/client/components/AgenticNotebook/NotebookCanvas.d.ts +3 -0
  92. package/dist/client/components/AgenticNotebook/NotebookMarkdownBlock.d.ts +12 -0
  93. package/dist/client/components/AgenticNotebook/NotebookPortletBlock.d.ts +12 -0
  94. package/dist/client/components/AgenticNotebook/index.d.ts +34 -0
  95. package/dist/client/components/charts/BoxPlotChart.config.d.ts +11 -0
  96. package/dist/client/components/charts/BoxPlotChart.d.ts +4 -0
  97. package/dist/client/components/charts/index.d.ts +1 -0
  98. package/dist/client/components.js +1 -1
  99. package/dist/client/hooks/useAgentChat.d.ts +36 -0
  100. package/dist/client/icons.js +1 -1
  101. package/dist/client/index.d.ts +6 -0
  102. package/dist/client/index.js +923 -187
  103. package/dist/client/index.js.map +1 -1
  104. package/dist/client/stores/notebookStore.d.ts +152 -0
  105. package/dist/client/styles.css +1 -1
  106. package/dist/client/types.d.ts +1 -1
  107. package/dist/client/utils.js +3 -3
  108. package/dist/client-bundle-stats.html +4 -4
  109. package/dist/server/index.cjs +116 -90
  110. package/dist/server/index.d.ts +155 -0
  111. package/dist/server/index.js +7088 -4852
  112. package/package.json +12 -6
  113. package/dist/client/chunks/RetentionCombinedChart.config-C-ILIaEb.js.map +0 -1
  114. package/dist/client/chunks/RetentionHeatmap.config-CIvhc-GT.js.map +0 -1
  115. package/dist/client/chunks/analysis-builder-CG5VIMYB.js.map +0 -1
  116. package/dist/client/chunks/chart-config-activity-grid-CAlo1cHA.js.map +0 -1
  117. package/dist/client/chunks/chart-config-area-CyyJOO2T.js.map +0 -1
  118. package/dist/client/chunks/chart-config-bar-soxw6m2o.js.map +0 -1
  119. package/dist/client/chunks/chart-config-bubble-CuSsCHZ4.js.map +0 -1
  120. package/dist/client/chunks/chart-config-data-table-BhgqwoqT.js.map +0 -1
  121. package/dist/client/chunks/chart-config-funnel-BlSQYng0.js.map +0 -1
  122. package/dist/client/chunks/chart-config-heat-map-DHQGFZhX.js.map +0 -1
  123. package/dist/client/chunks/chart-config-kpi-delta-yTA5ug_l.js.map +0 -1
  124. package/dist/client/chunks/chart-config-kpi-number-nVAwDXzq.js.map +0 -1
  125. package/dist/client/chunks/chart-config-kpi-text-DZjqsx-b.js.map +0 -1
  126. package/dist/client/chunks/chart-config-line-D5ME6w0v.js.map +0 -1
  127. package/dist/client/chunks/chart-config-markdown-BXKL5TbQ.js.map +0 -1
  128. package/dist/client/chunks/chart-config-pie-DlHa2jTy.js.map +0 -1
  129. package/dist/client/chunks/chart-config-radar-BBAVIF0S.js.map +0 -1
  130. package/dist/client/chunks/chart-config-radial-bar-CTwjDRnB.js.map +0 -1
  131. package/dist/client/chunks/chart-config-sankey-CNAgsMQ4.js.map +0 -1
  132. package/dist/client/chunks/chart-config-scatter-CWvN2E-X.js.map +0 -1
  133. package/dist/client/chunks/chart-config-sunburst-W_SKwaj0.js.map +0 -1
  134. package/dist/client/chunks/chart-config-tree-map-IRAYf9YM.js.map +0 -1
  135. package/dist/client/chunks/chart-markdown-Rq6ORisB.js +0 -276
  136. package/dist/client/chunks/chart-markdown-Rq6ORisB.js.map +0 -1
  137. package/dist/client/chunks/chartConfigRegistry-C5dZm-ZK.js +0 -44
  138. package/dist/client/chunks/chartConfigRegistry-C5dZm-ZK.js.map +0 -1
  139. package/dist/client/chunks/charts-loader-m5Ussksz.js.map +0 -1
  140. package/dist/client/chunks/components-D-5p1LVQ.js.map +0 -1
@@ -1,12 +1,12 @@
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-YHDZWKOi.js";
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
- function p(s) {
5
- const { cubes: a, drizzle: n, schema: c, engineType: d, cache: o } = s;
2
+ import { e as T, s as A, v as D, b as P, a as _, n as Q, p as V, w as I, d as J, i as M, M as k, c as $, S as K } from "../mcp-transport-CU5g9bxj.js";
3
+ import { formatErrorResponse as i, formatCubeResponse as z, formatMetaResponse as G, formatSqlResponse as U, handleDryRun as q, handleBatchRequest as B, handleDiscover as F, handleSuggest as X, handleValidate as W, handleLoad as Y } from "../utils.js";
4
+ function x(n) {
5
+ const { cubes: a, drizzle: s, schema: c, engineType: d, cache: o } = n;
6
6
  if (!a || a.length === 0)
7
7
  throw new Error("At least one cube must be provided in the cubes array");
8
- const r = new $({
9
- drizzle: n,
8
+ const r = new K({
9
+ drizzle: s,
10
10
  schema: c,
11
11
  engineType: d,
12
12
  cache: o
@@ -15,36 +15,36 @@ function p(s) {
15
15
  r.registerCube(e);
16
16
  }), r;
17
17
  }
18
- function m(s, a) {
19
- const n = s.headers.get("origin"), c = {};
20
- return a.origin && (typeof a.origin == "string" ? c["Access-Control-Allow-Origin"] = a.origin : Array.isArray(a.origin) ? n && a.origin.includes(n) && (c["Access-Control-Allow-Origin"] = n) : typeof a.origin == "function" && n && a.origin(n) && (c["Access-Control-Allow-Origin"] = n)), a.methods && (c["Access-Control-Allow-Methods"] = a.methods.join(", ")), a.allowedHeaders && (c["Access-Control-Allow-Headers"] = a.allowedHeaders.join(", ")), a.credentials && (c["Access-Control-Allow-Credentials"] = "true"), c;
18
+ function g(n, a) {
19
+ const s = n.headers.get("origin"), c = {};
20
+ return a.origin && (typeof a.origin == "string" ? c["Access-Control-Allow-Origin"] = a.origin : Array.isArray(a.origin) ? s && a.origin.includes(s) && (c["Access-Control-Allow-Origin"] = s) : typeof a.origin == "function" && s && a.origin(s) && (c["Access-Control-Allow-Origin"] = s)), a.methods && (c["Access-Control-Allow-Methods"] = a.methods.join(", ")), a.allowedHeaders && (c["Access-Control-Allow-Headers"] = a.allowedHeaders.join(", ")), a.credentials && (c["Access-Control-Allow-Credentials"] = "true"), c;
21
21
  }
22
- function de(s) {
23
- return async function(n) {
24
- const c = m(n, s);
22
+ function ue(n) {
23
+ return async function(s) {
24
+ const c = g(s, n);
25
25
  return new Response(null, {
26
26
  status: 200,
27
27
  headers: c
28
28
  });
29
29
  };
30
30
  }
31
- function Z(s) {
32
- const { extractSecurityContext: a, cors: n } = s, c = p(s);
31
+ function Z(n) {
32
+ const { extractSecurityContext: a, cors: s } = n, c = x(n);
33
33
  return async function(o, r) {
34
34
  try {
35
35
  let e;
36
36
  if (o.method === "POST") {
37
- const w = await o.json();
38
- e = w.query || w;
37
+ const E = await o.json();
38
+ e = E.query || E;
39
39
  } else if (o.method === "GET") {
40
- const w = o.nextUrl.searchParams.get("query");
41
- if (!w)
40
+ const E = o.nextUrl.searchParams.get("query");
41
+ if (!E)
42
42
  return t.json(
43
43
  i("Query parameter is required", 400),
44
44
  { status: 400 }
45
45
  );
46
46
  try {
47
- e = JSON.parse(w);
47
+ e = JSON.parse(E);
48
48
  } catch {
49
49
  return t.json(
50
50
  i("Invalid JSON in query parameter", 400),
@@ -56,15 +56,15 @@ function Z(s) {
56
56
  i("Method not allowed", 405),
57
57
  { status: 405 }
58
58
  );
59
- const l = await a(o, r), y = c.validateQuery(e);
59
+ const u = await a(o, r), y = c.validateQuery(e);
60
60
  if (!y.isValid)
61
61
  return t.json(
62
62
  i(`Query validation failed: ${y.errors.join(", ")}`, 400),
63
63
  { status: 400 }
64
64
  );
65
- const u = o.headers.get("x-cache-control") === "no-cache", f = await c.executeMultiCubeQuery(e, l, { skipCache: u }), g = G(e, f, c);
66
- return t.json(g, {
67
- headers: n ? m(o, n) : {}
65
+ const l = o.headers.get("x-cache-control") === "no-cache", f = await c.executeMultiCubeQuery(e, u, { skipCache: l }), w = z(e, f, c);
66
+ return t.json(w, {
67
+ headers: s ? g(o, s) : {}
68
68
  });
69
69
  } catch (e) {
70
70
  return process.env.NODE_ENV !== "test" && console.error("Next.js load handler error:", e), t.json(
@@ -77,13 +77,13 @@ function Z(s) {
77
77
  }
78
78
  };
79
79
  }
80
- function ee(s) {
81
- const { cors: a } = s, n = p(s);
80
+ function ee(n) {
81
+ const { cors: a } = n, s = x(n);
82
82
  return async function(d, o) {
83
83
  try {
84
- const r = n.getMetadata(), e = U(r);
84
+ const r = s.getMetadata(), e = G(r);
85
85
  return t.json(e, {
86
- headers: a ? m(d, a) : {}
86
+ headers: a ? g(d, a) : {}
87
87
  });
88
88
  } catch (r) {
89
89
  return process.env.NODE_ENV !== "test" && console.error("Next.js meta handler error:", r), t.json(
@@ -96,23 +96,23 @@ function ee(s) {
96
96
  }
97
97
  };
98
98
  }
99
- function te(s) {
100
- const { extractSecurityContext: a, cors: n } = s, c = p(s);
99
+ function te(n) {
100
+ const { extractSecurityContext: a, cors: s } = n, c = x(n);
101
101
  return async function(o, r) {
102
102
  try {
103
103
  let e;
104
104
  if (o.method === "POST") {
105
- const E = await o.json();
106
- e = E.query || E;
105
+ const v = await o.json();
106
+ e = v.query || v;
107
107
  } else if (o.method === "GET") {
108
- const E = o.nextUrl.searchParams.get("query");
109
- if (!E)
108
+ const v = o.nextUrl.searchParams.get("query");
109
+ if (!v)
110
110
  return t.json(
111
111
  i("Query parameter is required", 400),
112
112
  { status: 400 }
113
113
  );
114
114
  try {
115
- e = JSON.parse(E);
115
+ e = JSON.parse(v);
116
116
  } catch {
117
117
  return t.json(
118
118
  i("Invalid JSON in query parameter", 400),
@@ -124,21 +124,21 @@ function te(s) {
124
124
  i("Method not allowed", 405),
125
125
  { status: 405 }
126
126
  );
127
- const l = await a(o, r), y = c.validateQuery(e);
127
+ const u = await a(o, r), y = c.validateQuery(e);
128
128
  if (!y.isValid)
129
129
  return t.json(
130
130
  i(`Query validation failed: ${y.errors.join(", ")}`, 400),
131
131
  { status: 400 }
132
132
  );
133
- const u = e.measures?.[0] || e.dimensions?.[0];
134
- if (!u)
133
+ const l = e.measures?.[0] || e.dimensions?.[0];
134
+ if (!l)
135
135
  return t.json(
136
136
  i("No measures or dimensions specified", 400),
137
137
  { status: 400 }
138
138
  );
139
- const f = u.split(".")[0], g = await c.generateSQL(f, e, l), w = q(e, g);
140
- return t.json(w, {
141
- headers: n ? m(o, n) : {}
139
+ const f = l.split(".")[0], w = await c.generateSQL(f, e, u), E = U(e, w);
140
+ return t.json(E, {
141
+ headers: s ? g(o, s) : {}
142
142
  });
143
143
  } catch (e) {
144
144
  return process.env.NODE_ENV !== "test" && console.error("Next.js SQL handler error:", e), t.json(
@@ -151,23 +151,23 @@ function te(s) {
151
151
  }
152
152
  };
153
153
  }
154
- function re(s) {
155
- const { extractSecurityContext: a, cors: n } = s, c = p(s);
154
+ function re(n) {
155
+ const { extractSecurityContext: a, cors: s } = n, c = x(n);
156
156
  return async function(o, r) {
157
157
  try {
158
158
  let e;
159
159
  if (o.method === "POST") {
160
- const u = await o.json();
161
- e = u.query || u;
160
+ const l = await o.json();
161
+ e = l.query || l;
162
162
  } else if (o.method === "GET") {
163
- const u = o.nextUrl.searchParams.get("query");
164
- if (!u)
163
+ const l = o.nextUrl.searchParams.get("query");
164
+ if (!l)
165
165
  return t.json(
166
166
  { error: "Query parameter is required", valid: !1 },
167
167
  { status: 400 }
168
168
  );
169
169
  try {
170
- e = JSON.parse(u);
170
+ e = JSON.parse(l);
171
171
  } catch {
172
172
  return t.json(
173
173
  { error: "Invalid JSON in query parameter", valid: !1 },
@@ -179,9 +179,9 @@ function re(s) {
179
179
  { error: "Method not allowed", valid: !1 },
180
180
  { status: 405 }
181
181
  );
182
- const l = await a(o, r), y = await B(e, l, c);
182
+ const u = await a(o, r), y = await q(e, u, c);
183
183
  return t.json(y, {
184
- headers: n ? m(o, n) : {}
184
+ headers: s ? g(o, s) : {}
185
185
  });
186
186
  } catch (e) {
187
187
  return process.env.NODE_ENV !== "test" && console.error("Next.js dry-run handler error:", e), t.json(
@@ -194,8 +194,8 @@ function re(s) {
194
194
  }
195
195
  };
196
196
  }
197
- function ne(s) {
198
- const { extractSecurityContext: a, cors: n } = s, c = p(s);
197
+ function ne(n) {
198
+ const { extractSecurityContext: a, cors: s } = n, c = x(n);
199
199
  return async function(o, r) {
200
200
  try {
201
201
  if (o.method !== "POST")
@@ -203,20 +203,20 @@ function ne(s) {
203
203
  i("Method not allowed - use POST", 405),
204
204
  { status: 405 }
205
205
  );
206
- const e = await o.json(), { queries: l } = e;
207
- if (!l || !Array.isArray(l))
206
+ const e = await o.json(), { queries: u } = e;
207
+ if (!u || !Array.isArray(u))
208
208
  return t.json(
209
209
  i('Request body must contain a "queries" array', 400),
210
210
  { status: 400 }
211
211
  );
212
- if (l.length === 0)
212
+ if (u.length === 0)
213
213
  return t.json(
214
214
  i("Queries array cannot be empty", 400),
215
215
  { status: 400 }
216
216
  );
217
- const y = await a(o, r), u = o.headers.get("x-cache-control") === "no-cache", f = await F(l, y, c, { skipCache: u });
217
+ const y = await a(o, r), l = o.headers.get("x-cache-control") === "no-cache", f = await B(u, y, c, { skipCache: l });
218
218
  return t.json(f, {
219
- headers: n ? m(o, n) : {}
219
+ headers: s ? g(o, s) : {}
220
220
  });
221
221
  } catch (e) {
222
222
  return process.env.NODE_ENV !== "test" && console.error("Next.js batch handler error:", e), t.json(
@@ -229,8 +229,8 @@ function ne(s) {
229
229
  }
230
230
  };
231
231
  }
232
- function se(s) {
233
- const { extractSecurityContext: a, cors: n } = s, c = p(s);
232
+ function se(n) {
233
+ const { extractSecurityContext: a, cors: s } = n, c = x(n);
234
234
  return async function(o, r) {
235
235
  try {
236
236
  if (o.method !== "POST")
@@ -238,19 +238,19 @@ function se(s) {
238
238
  { error: "Method not allowed" },
239
239
  { status: 405 }
240
240
  );
241
- const e = await o.json(), l = e.query || e, y = e.options || {}, u = await a(o, r), f = c.validateQuery(l);
241
+ const e = await o.json(), u = e.query || e, y = e.options || {}, l = await a(o, r), f = c.validateQuery(u);
242
242
  if (!f.isValid)
243
243
  return t.json(
244
244
  { error: `Query validation failed: ${f.errors.join(", ")}` },
245
245
  { status: 400 }
246
246
  );
247
- const g = await c.explainQuery(
248
- l,
247
+ const w = await c.explainQuery(
249
248
  u,
249
+ l,
250
250
  y
251
251
  );
252
- return t.json(g, {
253
- headers: n ? m(o, n) : {}
252
+ return t.json(w, {
253
+ headers: s ? g(o, s) : {}
254
254
  });
255
255
  } catch (e) {
256
256
  return process.env.NODE_ENV !== "test" && console.error("Next.js explain handler error:", e), t.json(
@@ -260,8 +260,8 @@ function se(s) {
260
260
  }
261
261
  };
262
262
  }
263
- function le(s) {
264
- const { cors: a } = s, n = p(s);
263
+ function le(n) {
264
+ const { cors: a } = n, s = x(n);
265
265
  return async function(d, o) {
266
266
  try {
267
267
  if (d.method !== "POST")
@@ -269,9 +269,9 @@ function le(s) {
269
269
  i("Method not allowed - use POST", 405),
270
270
  { status: 405 }
271
271
  );
272
- const r = await d.json(), e = await K(n, r);
272
+ const r = await d.json(), e = await F(s, r);
273
273
  return t.json(e, {
274
- headers: a ? m(d, a) : {}
274
+ headers: a ? g(d, a) : {}
275
275
  });
276
276
  } catch (r) {
277
277
  return process.env.NODE_ENV !== "test" && console.error("Next.js discover handler error:", r), t.json(
@@ -284,8 +284,8 @@ function le(s) {
284
284
  }
285
285
  };
286
286
  }
287
- function ue(s) {
288
- const { cors: a } = s, n = p(s);
287
+ function fe(n) {
288
+ const { cors: a } = n, s = x(n);
289
289
  return async function(d, o) {
290
290
  try {
291
291
  if (d.method !== "POST")
@@ -299,9 +299,9 @@ function ue(s) {
299
299
  i("naturalLanguage field is required", 400),
300
300
  { status: 400 }
301
301
  );
302
- const e = await W(n, r);
302
+ const e = await X(s, r);
303
303
  return t.json(e, {
304
- headers: a ? m(d, a) : {}
304
+ headers: a ? g(d, a) : {}
305
305
  });
306
306
  } catch (r) {
307
307
  return process.env.NODE_ENV !== "test" && console.error("Next.js suggest handler error:", r), t.json(
@@ -314,8 +314,8 @@ function ue(s) {
314
314
  }
315
315
  };
316
316
  }
317
- function fe(s) {
318
- const { cors: a } = s, n = p(s);
317
+ function ye(n) {
318
+ const { cors: a } = n, s = x(n);
319
319
  return async function(d, o) {
320
320
  try {
321
321
  if (d.method !== "POST")
@@ -329,9 +329,9 @@ function fe(s) {
329
329
  i("query field is required", 400),
330
330
  { status: 400 }
331
331
  );
332
- const e = await X(n, r);
332
+ const e = await W(s, r);
333
333
  return t.json(e, {
334
- headers: a ? m(d, a) : {}
334
+ headers: a ? g(d, a) : {}
335
335
  });
336
336
  } catch (r) {
337
337
  return process.env.NODE_ENV !== "test" && console.error("Next.js validate handler error:", r), t.json(
@@ -344,8 +344,8 @@ function fe(s) {
344
344
  }
345
345
  };
346
346
  }
347
- function ye(s) {
348
- const { extractSecurityContext: a, cors: n } = s, c = p(s);
347
+ function he(n) {
348
+ const { extractSecurityContext: a, cors: s } = n, c = x(n);
349
349
  return async function(o, r) {
350
350
  try {
351
351
  if (o.method !== "POST")
@@ -359,9 +359,9 @@ function ye(s) {
359
359
  i("query field is required", 400),
360
360
  { status: 400 }
361
361
  );
362
- const l = await a(o, r), y = await Y(c, l, e);
362
+ const u = await a(o, r), y = await Y(c, u, e);
363
363
  return t.json(y, {
364
- headers: n ? m(o, n) : {}
364
+ headers: s ? g(o, s) : {}
365
365
  });
366
366
  } catch (e) {
367
367
  return process.env.NODE_ENV !== "test" && console.error("Next.js MCP load handler error:", e), t.json(
@@ -374,8 +374,8 @@ function ye(s) {
374
374
  }
375
375
  };
376
376
  }
377
- function ae(s) {
378
- const { extractSecurityContext: a, cors: n, mcp: c = { enabled: !0 } } = s, d = p(s);
377
+ function ae(n) {
378
+ const { extractSecurityContext: a, cors: s, mcp: c = { enabled: !0 } } = n, d = x(n);
379
379
  return async function(r) {
380
380
  if (r.method === "DELETE")
381
381
  return t.json(
@@ -383,31 +383,31 @@ function ae(s) {
383
383
  { status: 405 }
384
384
  );
385
385
  if (r.method === "GET") {
386
- const h = new TextEncoder(), v = T(), x = new ReadableStream({
386
+ const m = new TextEncoder(), C = T(), h = new ReadableStream({
387
387
  start(j) {
388
- j.enqueue(h.encode(M({
388
+ j.enqueue(m.encode(A({
389
389
  jsonrpc: "2.0",
390
390
  method: "mcp/ready",
391
391
  params: { protocol: "streamable-http" }
392
- }, v, 15e3)));
392
+ }, C, 15e3)));
393
393
  }
394
- }), C = new Headers({
394
+ }), p = new Headers({
395
395
  "Content-Type": "text/event-stream",
396
396
  "Cache-Control": "no-cache",
397
397
  Connection: "keep-alive"
398
398
  });
399
- if (n) {
400
- const j = m(r, n);
401
- Object.entries(j).forEach(([N, H]) => C.set(N, H));
399
+ if (s) {
400
+ const j = g(r, s);
401
+ Object.entries(j).forEach(([S, H]) => p.set(S, H));
402
402
  }
403
- return new t(x, { status: 200, headers: C });
403
+ return new t(h, { status: 200, headers: p });
404
404
  }
405
405
  if (r.method !== "POST")
406
406
  return t.json(
407
407
  i("Method not allowed - use POST", 405),
408
408
  { status: 405 }
409
409
  );
410
- const e = A(
410
+ const e = D(
411
411
  r.headers.get("origin"),
412
412
  c.allowedOrigins ? { allowedOrigins: c.allowedOrigins } : {}
413
413
  );
@@ -416,36 +416,36 @@ function ae(s) {
416
416
  P(null, -32600, e.reason),
417
417
  { status: 403 }
418
418
  );
419
- const l = r.headers.get("accept");
420
- if (!Q(l))
419
+ const u = r.headers.get("accept");
420
+ if (!_(u))
421
421
  return t.json(
422
422
  P(null, -32600, "Accept header must include both application/json and text/event-stream"),
423
423
  { status: 400 }
424
424
  );
425
- const y = _(Object.fromEntries(r.headers.entries()));
425
+ const y = Q(Object.fromEntries(r.headers.entries()));
426
426
  if (!y.ok)
427
427
  return t.json({
428
428
  error: "Unsupported MCP protocol version",
429
429
  supported: y.supported
430
430
  }, { status: 426 });
431
- let u = null;
431
+ let l;
432
432
  try {
433
- u = await r.json();
433
+ l = await r.json();
434
434
  } catch {
435
- u = null;
435
+ l = null;
436
436
  }
437
- const f = V(u);
437
+ const f = V(l);
438
438
  if (!f)
439
439
  return t.json(
440
440
  P(null, -32600, "Invalid JSON-RPC 2.0 request"),
441
441
  { status: 400 }
442
442
  );
443
- const g = I(l), w = f.method === "initialize", E = (h, v = 200, x = {}) => t.json(h, {
444
- status: v,
445
- headers: { ...n ? m(r, n) : {}, ...x }
443
+ const w = I(u), E = f.method === "initialize", v = (m, C = 200, h = {}) => t.json(m, {
444
+ status: C,
445
+ headers: { ...s ? g(r, s) : {}, ...h }
446
446
  });
447
447
  try {
448
- const h = await J(
448
+ const m = await J(
449
449
  f.method,
450
450
  f.params,
451
451
  {
@@ -455,81 +455,157 @@ function ae(s) {
455
455
  rawResponse: null
456
456
  }
457
457
  );
458
- if (L(f))
458
+ if (M(f))
459
459
  return new t(null, { status: 202 });
460
- const v = w && h && typeof h == "object" && "sessionId" in h ? h.sessionId : void 0, x = {};
461
- v && (x[k] = v);
462
- const C = z(f.id ?? null, h);
463
- if (g) {
464
- const j = new TextEncoder(), N = T(), H = new ReadableStream({
465
- start(S) {
466
- S.enqueue(j.encode(`id: ${N}
460
+ const C = E && m && typeof m == "object" && "sessionId" in m ? m.sessionId : void 0, h = {};
461
+ C && (h[k] = C);
462
+ const p = $(f.id ?? null, m);
463
+ if (w) {
464
+ const j = new TextEncoder(), S = T(), H = new ReadableStream({
465
+ start(N) {
466
+ N.enqueue(j.encode(`id: ${S}
467
467
 
468
- `)), S.enqueue(j.encode(M(C, N))), S.close();
468
+ `)), N.enqueue(j.encode(A(p, S))), N.close();
469
469
  }
470
470
  }), O = new Headers({
471
471
  "Content-Type": "text/event-stream",
472
472
  "Cache-Control": "no-cache",
473
473
  Connection: "keep-alive",
474
- ...x
474
+ ...h
475
475
  });
476
- if (n) {
477
- const S = m(r, n);
478
- Object.entries(S).forEach(([b, R]) => O.set(b, R));
476
+ if (s) {
477
+ const N = g(r, s);
478
+ Object.entries(N).forEach(([b, R]) => O.set(b, R));
479
479
  }
480
480
  return new t(H, { status: 200, headers: O });
481
481
  }
482
- return E(C, 200, x);
483
- } catch (h) {
484
- if (L(f))
485
- return process.env.NODE_ENV !== "test" && console.error("Next.js MCP notification processing error:", h), new t(null, { status: 202 });
486
- process.env.NODE_ENV !== "test" && console.error("Next.js MCP RPC handler error:", h);
487
- const v = h?.code ?? -32603, x = h?.data, C = h.message || "MCP request failed", j = P(f.id ?? null, v, C, x);
488
- if (g) {
489
- const N = new TextEncoder(), H = T(), O = new ReadableStream({
482
+ return v(p, 200, h);
483
+ } catch (m) {
484
+ if (M(f))
485
+ return process.env.NODE_ENV !== "test" && console.error("Next.js MCP notification processing error:", m), new t(null, { status: 202 });
486
+ process.env.NODE_ENV !== "test" && console.error("Next.js MCP RPC handler error:", m);
487
+ const C = m?.code ?? -32603, h = m?.data, p = m.message || "MCP request failed", j = P(f.id ?? null, C, p, h);
488
+ if (w) {
489
+ const S = new TextEncoder(), H = T(), O = new ReadableStream({
490
490
  start(b) {
491
- b.enqueue(N.encode(`id: ${H}
491
+ b.enqueue(S.encode(`id: ${H}
492
492
 
493
- `)), b.enqueue(N.encode(M(j, H))), b.close();
493
+ `)), b.enqueue(S.encode(A(j, H))), b.close();
494
494
  }
495
- }), S = new Headers({
495
+ }), N = new Headers({
496
496
  "Content-Type": "text/event-stream",
497
497
  "Cache-Control": "no-cache",
498
498
  Connection: "keep-alive"
499
499
  });
500
- if (n) {
501
- const b = m(r, n);
502
- Object.entries(b).forEach(([R, D]) => S.set(R, D));
500
+ if (s) {
501
+ const b = g(r, s);
502
+ Object.entries(b).forEach(([R, L]) => N.set(R, L));
503
503
  }
504
- return new t(O, { status: 200, headers: S });
504
+ return new t(O, { status: 200, headers: N });
505
505
  }
506
- return E(j, 200);
506
+ return v(j, 200);
507
+ }
508
+ };
509
+ }
510
+ function oe(n) {
511
+ const { extractSecurityContext: a, cors: s, agent: c } = n;
512
+ if (!c)
513
+ throw new Error("agent config is required for createAgentChatHandler");
514
+ const d = x(n);
515
+ return async function(r, e) {
516
+ try {
517
+ if (r.method !== "POST")
518
+ return t.json(
519
+ { error: "Method not allowed - use POST" },
520
+ { status: 405 }
521
+ );
522
+ const { handleAgentChat: u } = await import("../handler-odjn7MIB.js"), y = await r.json(), { message: l, sessionId: f } = y;
523
+ if (!l || typeof l != "string")
524
+ return t.json(
525
+ { error: "message is required and must be a string" },
526
+ { status: 400 }
527
+ );
528
+ let w = (c.apiKey || "").trim();
529
+ if (c.allowClientApiKey) {
530
+ const h = r.headers.get("x-agent-api-key");
531
+ h && (w = h.trim());
532
+ }
533
+ if (!w)
534
+ return t.json(
535
+ { error: "No API key configured. Set agent.apiKey in server config or send X-Agent-Api-Key header." },
536
+ { status: 401 }
537
+ );
538
+ const E = await a(r, e), v = new TextEncoder(), m = new ReadableStream({
539
+ async start(h) {
540
+ try {
541
+ const p = u({
542
+ message: l,
543
+ sessionId: f,
544
+ semanticLayer: d,
545
+ securityContext: E,
546
+ agentConfig: c,
547
+ apiKey: w
548
+ });
549
+ for await (const j of p) {
550
+ const S = `data: ${JSON.stringify(j)}
551
+
552
+ `;
553
+ h.enqueue(v.encode(S));
554
+ }
555
+ } catch (p) {
556
+ const j = {
557
+ type: "error",
558
+ data: { message: p instanceof Error ? p.message : "Stream failed" }
559
+ };
560
+ h.enqueue(v.encode(`data: ${JSON.stringify(j)}
561
+
562
+ `));
563
+ } finally {
564
+ h.close();
565
+ }
566
+ }
567
+ }), C = new Headers({
568
+ "Content-Type": "text/event-stream",
569
+ "Cache-Control": "no-cache",
570
+ Connection: "keep-alive"
571
+ });
572
+ if (s) {
573
+ const h = g(r, s);
574
+ Object.entries(h).forEach(([p, j]) => C.set(p, j));
575
+ }
576
+ return new Response(m, { status: 200, headers: C });
577
+ } catch (u) {
578
+ return process.env.NODE_ENV !== "test" && console.error("Next.js agent chat handler error:", u), t.json(
579
+ { error: u instanceof Error ? u.message : "Agent chat failed" },
580
+ { status: 500 }
581
+ );
507
582
  }
508
583
  };
509
584
  }
510
- function he(s) {
511
- const { mcp: a = { enabled: !0 } } = s, n = {
512
- load: Z(s),
513
- meta: ee(s),
514
- sql: te(s),
515
- dryRun: re(s),
516
- batch: ne(s),
517
- explain: se(s)
585
+ function me(n) {
586
+ const { mcp: a = { enabled: !0 } } = n, s = {
587
+ load: Z(n),
588
+ meta: ee(n),
589
+ sql: te(n),
590
+ dryRun: re(n),
591
+ batch: ne(n),
592
+ explain: se(n)
518
593
  };
519
- return a.enabled !== !1 && (n.mcpRpc = ae(s)), n;
594
+ return a.enabled !== !1 && (s.mcpRpc = ae(n)), n.agent && (s.agentChat = oe(n)), s;
520
595
  }
521
596
  export {
597
+ oe as createAgentChatHandler,
522
598
  ne as createBatchHandler,
523
- he as createCubeHandlers,
599
+ me as createCubeHandlers,
524
600
  le as createDiscoverHandler,
525
601
  re as createDryRunHandler,
526
602
  se as createExplainHandler,
527
603
  Z as createLoadHandler,
528
- ye as createMcpLoadHandler,
604
+ he as createMcpLoadHandler,
529
605
  ae as createMcpRpcHandler,
530
606
  ee as createMetaHandler,
531
- de as createOptionsHandler,
607
+ ue as createOptionsHandler,
532
608
  te as createSqlHandler,
533
- ue as createSuggestHandler,
534
- fe as createValidateHandler
609
+ fe as createSuggestHandler,
610
+ ye as createValidateHandler
535
611
  };