drizzle-cube 0.3.13 → 0.3.16

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 (182) hide show
  1. package/dist/adapters/express/index.cjs +1 -1
  2. package/dist/adapters/express/index.d.ts +8 -1
  3. package/dist/adapters/express/index.js +162 -99
  4. package/dist/adapters/fastify/index.cjs +1 -1
  5. package/dist/adapters/fastify/index.d.ts +8 -1
  6. package/dist/adapters/fastify/index.js +183 -96
  7. package/dist/adapters/hono/index.cjs +1 -1
  8. package/dist/adapters/hono/index.d.ts +8 -1
  9. package/dist/adapters/hono/index.js +198 -142
  10. package/dist/adapters/nextjs/index.cjs +1 -1
  11. package/dist/adapters/nextjs/index.d.ts +29 -1
  12. package/dist/adapters/nextjs/index.js +251 -132
  13. package/dist/adapters/utils.d.ts +100 -1
  14. package/dist/adapters/validation-Bgauxvm6.cjs +214 -0
  15. package/dist/adapters/{compiler-DTOU8IsK.js → validation-_UkKJ2pC.js} +9582 -5295
  16. package/dist/client/adapters/index.d.ts +2 -0
  17. package/dist/client/adapters/retentionModeAdapter.d.ts +3 -0
  18. package/dist/client/charts.js +12 -12
  19. package/dist/client/chunks/RetentionCombinedChart-DirfDaZH.js +256 -0
  20. package/dist/client/chunks/RetentionCombinedChart-DirfDaZH.js.map +1 -0
  21. package/dist/client/chunks/RetentionCombinedChart.config-C-ILIaEb.js +47 -0
  22. package/dist/client/chunks/RetentionCombinedChart.config-C-ILIaEb.js.map +1 -0
  23. package/dist/client/chunks/RetentionHeatmap-Bofadstm.js +178 -0
  24. package/dist/client/chunks/RetentionHeatmap-Bofadstm.js.map +1 -0
  25. package/dist/client/chunks/RetentionHeatmap.config-CIvhc-GT.js +28 -0
  26. package/dist/client/chunks/RetentionHeatmap.config-CIvhc-GT.js.map +1 -0
  27. package/dist/client/chunks/analysis-builder-APeCxkEH.js +6939 -0
  28. package/dist/client/chunks/analysis-builder-APeCxkEH.js.map +1 -0
  29. package/dist/client/chunks/analysis-builder-shared-DEovRjrp.js +2779 -0
  30. package/dist/client/chunks/analysis-builder-shared-DEovRjrp.js.map +1 -0
  31. package/dist/client/chunks/{chart-activity-grid-CuPARsr1.js → chart-activity-grid-BnweuBvr.js} +11 -11
  32. package/dist/client/chunks/{chart-activity-grid-CuPARsr1.js.map → chart-activity-grid-BnweuBvr.js.map} +1 -1
  33. package/dist/client/chunks/{chart-area-cPrJnhLj.js → chart-area-DLmXFWWy.js} +2 -2
  34. package/dist/client/chunks/{chart-area-cPrJnhLj.js.map → chart-area-DLmXFWWy.js.map} +1 -1
  35. package/dist/client/chunks/{chart-bar-D68HFPpa.js → chart-bar-7y0-F27Q.js} +2 -2
  36. package/dist/client/chunks/{chart-bar-D68HFPpa.js.map → chart-bar-7y0-F27Q.js.map} +1 -1
  37. package/dist/client/chunks/{chart-bubble-CquyYfNO.js → chart-bubble-3jYKCA2B.js} +2 -2
  38. package/dist/client/chunks/{chart-bubble-CquyYfNO.js.map → chart-bubble-3jYKCA2B.js.map} +1 -1
  39. package/dist/client/chunks/{chart-config-activity-grid-Bkvx0F-G.js → chart-config-activity-grid-BBSNCbkb.js} +2 -2
  40. package/dist/client/chunks/{chart-config-activity-grid-Bkvx0F-G.js.map → chart-config-activity-grid-BBSNCbkb.js.map} +1 -1
  41. package/dist/client/chunks/{chart-config-area-OApsRaYC.js → chart-config-area-CyyJOO2T.js} +2 -2
  42. package/dist/client/chunks/{chart-config-area-OApsRaYC.js.map → chart-config-area-CyyJOO2T.js.map} +1 -1
  43. package/dist/client/chunks/{chart-config-bar-Dy21oaIA.js → chart-config-bar-BJKGnfLt.js} +2 -2
  44. package/dist/client/chunks/{chart-config-bar-Dy21oaIA.js.map → chart-config-bar-BJKGnfLt.js.map} +1 -1
  45. package/dist/client/chunks/{chart-config-bubble-Chv0SoFm.js → chart-config-bubble-CuSsCHZ4.js} +2 -2
  46. package/dist/client/chunks/{chart-config-bubble-Chv0SoFm.js.map → chart-config-bubble-CuSsCHZ4.js.map} +1 -1
  47. package/dist/client/chunks/{chart-config-data-table-DTIdC35a.js → chart-config-data-table-BhgqwoqT.js} +2 -2
  48. package/dist/client/chunks/{chart-config-data-table-DTIdC35a.js.map → chart-config-data-table-BhgqwoqT.js.map} +1 -1
  49. package/dist/client/chunks/{chart-config-funnel-f17Livgr.js → chart-config-funnel-BlSQYng0.js} +4 -4
  50. package/dist/client/chunks/{chart-config-funnel-f17Livgr.js.map → chart-config-funnel-BlSQYng0.js.map} +1 -1
  51. package/dist/client/chunks/{chart-config-heat-map-DPhNICha.js → chart-config-heat-map-DHQGFZhX.js} +2 -2
  52. package/dist/client/chunks/{chart-config-heat-map-DPhNICha.js.map → chart-config-heat-map-DHQGFZhX.js.map} +1 -1
  53. package/dist/client/chunks/{chart-config-kpi-delta-CCl1d-St.js → chart-config-kpi-delta-yTA5ug_l.js} +2 -2
  54. package/dist/client/chunks/{chart-config-kpi-delta-CCl1d-St.js.map → chart-config-kpi-delta-yTA5ug_l.js.map} +1 -1
  55. package/dist/client/chunks/{chart-config-kpi-number-DkE3eSwH.js → chart-config-kpi-number-nVAwDXzq.js} +2 -2
  56. package/dist/client/chunks/{chart-config-kpi-number-DkE3eSwH.js.map → chart-config-kpi-number-nVAwDXzq.js.map} +1 -1
  57. package/dist/client/chunks/{chart-config-kpi-text-BMbgdxZm.js → chart-config-kpi-text-DZjqsx-b.js} +2 -2
  58. package/dist/client/chunks/{chart-config-kpi-text-BMbgdxZm.js.map → chart-config-kpi-text-DZjqsx-b.js.map} +1 -1
  59. package/dist/client/chunks/{chart-config-line-BnLlRUQE.js → chart-config-line-DR0ThxZy.js} +2 -2
  60. package/dist/client/chunks/{chart-config-line-BnLlRUQE.js.map → chart-config-line-DR0ThxZy.js.map} +1 -1
  61. package/dist/client/chunks/{chart-config-markdown-DIaMFC0Z.js → chart-config-markdown-DZxdGNVQ.js} +2 -2
  62. package/dist/client/chunks/{chart-config-markdown-DIaMFC0Z.js.map → chart-config-markdown-DZxdGNVQ.js.map} +1 -1
  63. package/dist/client/chunks/{chart-config-pie-O9y_T0BQ.js → chart-config-pie-BM5lgH-w.js} +2 -2
  64. package/dist/client/chunks/{chart-config-pie-O9y_T0BQ.js.map → chart-config-pie-BM5lgH-w.js.map} +1 -1
  65. package/dist/client/chunks/{chart-config-radar-CXa0354h.js → chart-config-radar-BBAVIF0S.js} +2 -2
  66. package/dist/client/chunks/{chart-config-radar-CXa0354h.js.map → chart-config-radar-BBAVIF0S.js.map} +1 -1
  67. package/dist/client/chunks/{chart-config-radial-bar-BppJU8-Q.js → chart-config-radial-bar-CTwjDRnB.js} +2 -2
  68. package/dist/client/chunks/{chart-config-radial-bar-BppJU8-Q.js.map → chart-config-radial-bar-CTwjDRnB.js.map} +1 -1
  69. package/dist/client/chunks/{chart-config-sankey-BfBHgL4x.js → chart-config-sankey-CNAgsMQ4.js} +2 -2
  70. package/dist/client/chunks/{chart-config-sankey-BfBHgL4x.js.map → chart-config-sankey-CNAgsMQ4.js.map} +1 -1
  71. package/dist/client/chunks/{chart-config-scatter-BTt8a10R.js → chart-config-scatter-CWvN2E-X.js} +2 -2
  72. package/dist/client/chunks/{chart-config-scatter-BTt8a10R.js.map → chart-config-scatter-CWvN2E-X.js.map} +1 -1
  73. package/dist/client/chunks/{chart-config-sunburst-DNmQpIIx.js → chart-config-sunburst-W_SKwaj0.js} +4 -4
  74. package/dist/client/chunks/{chart-config-sunburst-DNmQpIIx.js.map → chart-config-sunburst-W_SKwaj0.js.map} +1 -1
  75. package/dist/client/chunks/{chart-config-tree-map-HVgG4oa0.js → chart-config-tree-map-CLmRvvMR.js} +2 -2
  76. package/dist/client/chunks/{chart-config-tree-map-HVgG4oa0.js.map → chart-config-tree-map-CLmRvvMR.js.map} +1 -1
  77. package/dist/client/chunks/{chart-data-table-D4WDqbM0.js → chart-data-table-rUFLqysu.js} +4 -4
  78. package/dist/client/chunks/{chart-data-table-D4WDqbM0.js.map → chart-data-table-rUFLqysu.js.map} +1 -1
  79. package/dist/client/chunks/{chart-funnel-Csdn4FbN.js → chart-funnel-C7zGBfSw.js} +2 -2
  80. package/dist/client/chunks/{chart-funnel-Csdn4FbN.js.map → chart-funnel-C7zGBfSw.js.map} +1 -1
  81. package/dist/client/chunks/{chart-heat-map-v1afxnjq.js → chart-heat-map-B-l8hK8b.js} +2 -2
  82. package/dist/client/chunks/{chart-heat-map-v1afxnjq.js.map → chart-heat-map-B-l8hK8b.js.map} +1 -1
  83. package/dist/client/chunks/chart-kpi-delta-sfZEvQZm.js +351 -0
  84. package/dist/client/chunks/chart-kpi-delta-sfZEvQZm.js.map +1 -0
  85. package/dist/client/chunks/chart-kpi-number-BxGNOtzI.js +473 -0
  86. package/dist/client/chunks/chart-kpi-number-BxGNOtzI.js.map +1 -0
  87. package/dist/client/chunks/{chart-kpi-text-CRp8QWYG.js → chart-kpi-text-BLQ_CWQP.js} +3 -3
  88. package/dist/client/chunks/{chart-kpi-text-CRp8QWYG.js.map → chart-kpi-text-BLQ_CWQP.js.map} +1 -1
  89. package/dist/client/chunks/{chart-line-DqqE7ky9.js → chart-line-FSEpBk6Y.js} +5 -5
  90. package/dist/client/chunks/{chart-line-DqqE7ky9.js.map → chart-line-FSEpBk6Y.js.map} +1 -1
  91. package/dist/client/chunks/{chart-pie-B5WBzIRH.js → chart-pie-BRQEH9e-.js} +2 -2
  92. package/dist/client/chunks/{chart-pie-B5WBzIRH.js.map → chart-pie-BRQEH9e-.js.map} +1 -1
  93. package/dist/client/chunks/{chart-radar-DL_dvhA-.js → chart-radar-DgsFyiIP.js} +2 -2
  94. package/dist/client/chunks/{chart-radar-DL_dvhA-.js.map → chart-radar-DgsFyiIP.js.map} +1 -1
  95. package/dist/client/chunks/{chart-radial-bar-DDRo6nz-.js → chart-radial-bar-CUMoXyl9.js} +2 -2
  96. package/dist/client/chunks/{chart-radial-bar-DDRo6nz-.js.map → chart-radial-bar-CUMoXyl9.js.map} +1 -1
  97. package/dist/client/chunks/{chart-sankey-C_bgIfg-.js → chart-sankey-IAKDEe7A.js} +2 -2
  98. package/dist/client/chunks/{chart-sankey-C_bgIfg-.js.map → chart-sankey-IAKDEe7A.js.map} +1 -1
  99. package/dist/client/chunks/{chart-scatter-DjmJRlK0.js → chart-scatter-D6XwOD2W.js} +15 -15
  100. package/dist/client/chunks/{chart-scatter-DjmJRlK0.js.map → chart-scatter-D6XwOD2W.js.map} +1 -1
  101. package/dist/client/chunks/{chart-sunburst-CbMEnaes.js → chart-sunburst-CP_pnj0S.js} +2 -2
  102. package/dist/client/chunks/{chart-sunburst-CbMEnaes.js.map → chart-sunburst-CP_pnj0S.js.map} +1 -1
  103. package/dist/client/chunks/{chart-tree-map-DEfJtJVC.js → chart-tree-map-DQMsn47a.js} +30 -30
  104. package/dist/client/chunks/{chart-tree-map-DEfJtJVC.js.map → chart-tree-map-DQMsn47a.js.map} +1 -1
  105. package/dist/client/chunks/chartConfigRegistry-BumUIPw4.js +44 -0
  106. package/dist/client/chunks/{chartConfigRegistry-CiOq-PqX.js.map → chartConfigRegistry-BumUIPw4.js.map} +1 -1
  107. package/dist/client/chunks/charts-Dk_9XrA7.js +230 -0
  108. package/dist/client/chunks/charts-Dk_9XrA7.js.map +1 -0
  109. package/dist/client/chunks/{charts-core-CXrhEEVF.js → charts-core-CjQZBxmv.js} +10 -10
  110. package/dist/client/chunks/{charts-core-CXrhEEVF.js.map → charts-core-CjQZBxmv.js.map} +1 -1
  111. package/dist/client/chunks/{charts-loader-BtsnUO4Q.js → charts-loader-ChTUa_-G.js} +30 -28
  112. package/dist/client/chunks/charts-loader-ChTUa_-G.js.map +1 -0
  113. package/dist/client/chunks/{components-BDrlf9Er.js → components-BKZ7EAg0.js} +3575 -3208
  114. package/dist/client/chunks/components-BKZ7EAg0.js.map +1 -0
  115. package/dist/client/chunks/{core-B8zw0qRf.js → core-BRC075EG.js} +2 -2
  116. package/dist/client/chunks/{core-B8zw0qRf.js.map → core-BRC075EG.js.map} +1 -1
  117. package/dist/client/chunks/hooks-D7APQ8uS.js +150 -0
  118. package/dist/client/chunks/{hooks-B8Zw5PfL.js.map → hooks-D7APQ8uS.js.map} +1 -1
  119. package/dist/client/chunks/{icons-NzFHtqeM.js → icons-DRreo6m8.js} +128 -112
  120. package/dist/client/chunks/{icons-NzFHtqeM.js.map → icons-DRreo6m8.js.map} +1 -1
  121. package/dist/client/chunks/{providers-CqCiJTEj.js → providers-Cj7PQfXn.js} +2 -2
  122. package/dist/client/chunks/{providers-CqCiJTEj.js.map → providers-Cj7PQfXn.js.map} +1 -1
  123. package/dist/client/chunks/retention-CzCo8262.js +120 -0
  124. package/dist/client/chunks/retention-CzCo8262.js.map +1 -0
  125. package/dist/client/chunks/{useDirtyStateTracking-C_mitVwh.js → useDirtyStateTracking-ZSi3voVl.js} +101 -99
  126. package/dist/client/chunks/useDirtyStateTracking-ZSi3voVl.js.map +1 -0
  127. package/dist/client/chunks/{vendor-DzzxS7Ay.js → vendor-cTQhZ_G3.js} +549 -541
  128. package/dist/client/chunks/vendor-cTQhZ_G3.js.map +1 -0
  129. package/dist/client/components/AnalysisBuilder/AnalysisTypeSelector.d.ts +3 -1
  130. package/dist/client/components/AnalysisBuilder/RetentionConfigPanel.d.ts +36 -0
  131. package/dist/client/components/AnalysisBuilder/RetentionModeContent.d.ts +71 -0
  132. package/dist/client/components/AnalysisBuilder/types.d.ts +99 -0
  133. package/dist/client/components/DebugModal.d.ts +2 -1
  134. package/dist/client/components/charts/RetentionCombinedChart.config.d.ts +2 -0
  135. package/dist/client/components/charts/RetentionCombinedChart.d.ts +14 -0
  136. package/dist/client/components/charts/RetentionHeatmap.config.d.ts +2 -0
  137. package/dist/client/components/charts/RetentionHeatmap.d.ts +7 -0
  138. package/dist/client/components.js +2 -2
  139. package/dist/client/hooks/queries/index.d.ts +2 -1
  140. package/dist/client/hooks/queries/useDryRunQuery.d.ts +26 -0
  141. package/dist/client/hooks/queries/useExplainQuery.d.ts +3 -1
  142. package/dist/client/hooks/queries/useFlowQuery.d.ts +5 -0
  143. package/dist/client/hooks/queries/useRetentionQuery.d.ts +67 -0
  144. package/dist/client/hooks/useAnalysisBuilderHook.d.ts +61 -0
  145. package/dist/client/hooks/useAnalysisQueryExecution.d.ts +42 -1
  146. package/dist/client/hooks.js +3 -3
  147. package/dist/client/icons/customIcons.d.ts +7 -0
  148. package/dist/client/icons/types.d.ts +1 -0
  149. package/dist/client/icons.js +1 -1
  150. package/dist/client/index.js +11 -11
  151. package/dist/client/providers.js +1 -1
  152. package/dist/client/stores/analysisBuilderStore.d.ts +86 -1
  153. package/dist/client/stores/dashboardStore.d.ts +2 -1
  154. package/dist/client/stores/slices/index.d.ts +2 -0
  155. package/dist/client/stores/slices/retentionSlice.d.ts +66 -0
  156. package/dist/client/styles.css +1 -1
  157. package/dist/client/types/analysisConfig.d.ts +29 -4
  158. package/dist/client/types/funnel.d.ts +5 -0
  159. package/dist/client/types/retention.d.ts +301 -0
  160. package/dist/client/types.d.ts +6 -3
  161. package/dist/client-bundle-stats.html +1 -1
  162. package/dist/server/index.cjs +101 -79
  163. package/dist/server/index.d.ts +427 -0
  164. package/dist/server/index.js +9140 -4934
  165. package/package.json +5 -2
  166. package/dist/adapters/compiler-CO13DaEb.cjs +0 -192
  167. package/dist/client/chunks/analysis-builder-Dc9NrG_N.js +0 -6013
  168. package/dist/client/chunks/analysis-builder-Dc9NrG_N.js.map +0 -1
  169. package/dist/client/chunks/analysis-builder-shared-B3-UWqQ2.js +0 -2540
  170. package/dist/client/chunks/analysis-builder-shared-B3-UWqQ2.js.map +0 -1
  171. package/dist/client/chunks/chart-kpi-delta-Bs5R5xr4.js +0 -435
  172. package/dist/client/chunks/chart-kpi-delta-Bs5R5xr4.js.map +0 -1
  173. package/dist/client/chunks/chart-kpi-number-Cf4Pgkm9.js +0 -392
  174. package/dist/client/chunks/chart-kpi-number-Cf4Pgkm9.js.map +0 -1
  175. package/dist/client/chunks/chartConfigRegistry-CiOq-PqX.js +0 -44
  176. package/dist/client/chunks/charts-loader-BtsnUO4Q.js.map +0 -1
  177. package/dist/client/chunks/charts-xNubY0vm.js +0 -226
  178. package/dist/client/chunks/charts-xNubY0vm.js.map +0 -1
  179. package/dist/client/chunks/components-BDrlf9Er.js.map +0 -1
  180. package/dist/client/chunks/hooks-B8Zw5PfL.js +0 -123
  181. package/dist/client/chunks/useDirtyStateTracking-C_mitVwh.js.map +0 -1
  182. package/dist/client/chunks/vendor-DzzxS7Ay.js.map +0 -1
@@ -1,7 +1,7 @@
1
- import { Hono as x } from "hono";
2
- import { S as Q, f as j, h as v, a as b, b as w, c as g } from "../compiler-DTOU8IsK.js";
3
- var A = (q) => {
4
- const u = {
1
+ import { Hono as C } from "hono";
2
+ import { S as b, f as p, h as Q, a as E, b as w, c as x, d as A, e as S, g as $, i as R } from "../validation-_UkKJ2pC.js";
3
+ var L = (q) => {
4
+ const c = {
5
5
  ...{
6
6
  origin: "*",
7
7
  allowMethods: ["GET", "HEAD", "PUT", "POST", "DELETE", "PATCH"],
@@ -9,216 +9,272 @@ var A = (q) => {
9
9
  exposeHeaders: []
10
10
  },
11
11
  ...q
12
- }, p = /* @__PURE__ */ ((i) => typeof i == "string" ? i === "*" ? () => i : (n) => i === n ? n : null : typeof i == "function" ? i : (n) => i.includes(n) ? n : null)(u.origin), y = ((i) => typeof i == "function" ? i : Array.isArray(i) ? () => i : () => [])(u.allowMethods);
13
- return async function(n, d) {
14
- function f(o, e) {
15
- n.res.headers.set(o, e);
12
+ }, m = /* @__PURE__ */ ((u) => typeof u == "string" ? u === "*" ? () => u : (a) => u === a ? a : null : typeof u == "function" ? u : (a) => u.includes(a) ? a : null)(c.origin), d = ((u) => typeof u == "function" ? u : Array.isArray(u) ? () => u : () => [])(c.allowMethods);
13
+ return async function(a, y) {
14
+ function f(i, s) {
15
+ a.res.headers.set(i, s);
16
16
  }
17
- const c = await p(n.req.header("origin") || "", n);
18
- if (c && f("Access-Control-Allow-Origin", c), u.credentials && f("Access-Control-Allow-Credentials", "true"), u.exposeHeaders?.length && f("Access-Control-Expose-Headers", u.exposeHeaders.join(",")), n.req.method === "OPTIONS") {
19
- u.origin !== "*" && f("Vary", "Origin"), u.maxAge != null && f("Access-Control-Max-Age", u.maxAge.toString());
20
- const o = await y(n.req.header("origin") || "", n);
21
- o.length && f("Access-Control-Allow-Methods", o.join(","));
22
- let e = u.allowHeaders;
23
- if (!e?.length) {
24
- const r = n.req.header("Access-Control-Request-Headers");
25
- r && (e = r.split(/\s*,\s*/));
17
+ const g = await m(a.req.header("origin") || "", a);
18
+ if (g && f("Access-Control-Allow-Origin", g), c.credentials && f("Access-Control-Allow-Credentials", "true"), c.exposeHeaders?.length && f("Access-Control-Expose-Headers", c.exposeHeaders.join(",")), a.req.method === "OPTIONS") {
19
+ c.origin !== "*" && f("Vary", "Origin"), c.maxAge != null && f("Access-Control-Max-Age", c.maxAge.toString());
20
+ const i = await d(a.req.header("origin") || "", a);
21
+ i.length && f("Access-Control-Allow-Methods", i.join(","));
22
+ let s = c.allowHeaders;
23
+ if (!s?.length) {
24
+ const r = a.req.header("Access-Control-Request-Headers");
25
+ r && (s = r.split(/\s*,\s*/));
26
26
  }
27
- return e?.length && (f("Access-Control-Allow-Headers", e.join(",")), n.res.headers.append("Vary", "Access-Control-Request-Headers")), n.res.headers.delete("Content-Length"), n.res.headers.delete("Content-Type"), new Response(null, {
28
- headers: n.res.headers,
27
+ return s?.length && (f("Access-Control-Allow-Headers", s.join(",")), a.res.headers.append("Vary", "Access-Control-Request-Headers")), a.res.headers.delete("Content-Length"), a.res.headers.delete("Content-Type"), new Response(null, {
28
+ headers: a.res.headers,
29
29
  status: 204,
30
30
  statusText: "No Content"
31
31
  });
32
32
  }
33
- await d(), u.origin !== "*" && n.header("Vary", "Origin", { append: !0 });
33
+ await y(), c.origin !== "*" && a.header("Vary", "Origin", { append: !0 });
34
34
  };
35
35
  };
36
- function E(q) {
36
+ function H(q) {
37
37
  const {
38
- cubes: m,
39
- drizzle: u,
40
- schema: p,
41
- extractSecurityContext: y,
42
- engineType: i,
43
- cors: n,
44
- basePath: d = "/cubejs-api/v1",
45
- cache: f
38
+ cubes: j,
39
+ drizzle: c,
40
+ schema: m,
41
+ extractSecurityContext: d,
42
+ engineType: u,
43
+ cors: a,
44
+ basePath: y = "/cubejs-api/v1",
45
+ cache: f,
46
+ mcp: g = { enabled: !0 }
46
47
  } = q;
47
- if (!m || m.length === 0)
48
+ if (!j || j.length === 0)
48
49
  throw new Error("At least one cube must be provided in the cubes array");
49
- const c = new x();
50
- n && c.use("/*", A(n));
51
- const o = new Q({
52
- drizzle: u,
53
- schema: p,
54
- engineType: i,
50
+ const i = new C();
51
+ a && i.use("/*", L(a));
52
+ const s = new b({
53
+ drizzle: c,
54
+ schema: m,
55
+ engineType: u,
55
56
  cache: f
56
57
  });
57
- return m.forEach((e) => {
58
- o.registerCube(e);
59
- }), c.post(`${d}/load`, async (e) => {
58
+ if (j.forEach((r) => {
59
+ s.registerCube(r);
60
+ }), i.post(`${y}/load`, async (r) => {
60
61
  try {
61
- const r = await e.req.json(), t = r.query || r, a = await y(e), s = o.validateQuery(t);
62
- if (!s.isValid)
63
- return e.json({
64
- error: `Query validation failed: ${s.errors.join(", ")}`
62
+ const e = await r.req.json(), o = e.query || e, t = await d(r), n = s.validateQuery(o);
63
+ if (!n.isValid)
64
+ return r.json({
65
+ error: `Query validation failed: ${n.errors.join(", ")}`
65
66
  }, 400);
66
- const l = e.req.header("x-cache-control") === "no-cache", h = await o.executeMultiCubeQuery(t, a, { skipCache: l });
67
- return e.json(j(t, h, o));
68
- } catch (r) {
69
- return console.error("Query execution error:", r), e.json({
70
- error: r instanceof Error ? r.message : "Query execution failed"
67
+ const l = r.req.header("x-cache-control") === "no-cache", h = await s.executeMultiCubeQuery(o, t, { skipCache: l });
68
+ return r.json(p(o, h, s));
69
+ } catch (e) {
70
+ return console.error("Query execution error:", e), r.json({
71
+ error: e instanceof Error ? e.message : "Query execution failed"
71
72
  }, 500);
72
73
  }
73
- }), c.get(`${d}/load`, async (e) => {
74
+ }), i.get(`${y}/load`, async (r) => {
74
75
  try {
75
- const r = e.req.query("query");
76
- if (!r)
77
- return e.json({
76
+ const e = r.req.query("query");
77
+ if (!e)
78
+ return r.json({
78
79
  error: "Query parameter is required"
79
80
  }, 400);
80
- let t;
81
+ let o;
81
82
  try {
82
- t = JSON.parse(r);
83
+ o = JSON.parse(e);
83
84
  } catch {
84
- return e.json({
85
+ return r.json({
85
86
  error: "Invalid JSON in query parameter"
86
87
  }, 400);
87
88
  }
88
- const a = await y(e), s = o.validateQuery(t);
89
- if (!s.isValid)
90
- return e.json({
91
- error: `Query validation failed: ${s.errors.join(", ")}`
89
+ const t = await d(r), n = s.validateQuery(o);
90
+ if (!n.isValid)
91
+ return r.json({
92
+ error: `Query validation failed: ${n.errors.join(", ")}`
92
93
  }, 400);
93
- const l = e.req.header("x-cache-control") === "no-cache", h = await o.executeMultiCubeQuery(t, a, { skipCache: l });
94
- return e.json(j(t, h, o));
95
- } catch (r) {
96
- return console.error("Query execution error:", r), e.json({
97
- error: r instanceof Error ? r.message : "Query execution failed"
94
+ const l = r.req.header("x-cache-control") === "no-cache", h = await s.executeMultiCubeQuery(o, t, { skipCache: l });
95
+ return r.json(p(o, h, s));
96
+ } catch (e) {
97
+ return console.error("Query execution error:", e), r.json({
98
+ error: e instanceof Error ? e.message : "Query execution failed"
98
99
  }, 500);
99
100
  }
100
- }), c.post(`${d}/batch`, async (e) => {
101
+ }), i.post(`${y}/batch`, async (r) => {
101
102
  try {
102
- const r = await e.req.json(), { queries: t } = r;
103
- if (!t || !Array.isArray(t))
104
- return e.json({
103
+ const e = await r.req.json(), { queries: o } = e;
104
+ if (!o || !Array.isArray(o))
105
+ return r.json({
105
106
  error: 'Request body must contain a "queries" array'
106
107
  }, 400);
107
- if (t.length === 0)
108
- return e.json({
108
+ if (o.length === 0)
109
+ return r.json({
109
110
  error: "Queries array cannot be empty"
110
111
  }, 400);
111
- const a = await y(e), s = e.req.header("x-cache-control") === "no-cache", l = await v(t, a, o, { skipCache: s });
112
- return e.json(l);
113
- } catch (r) {
114
- return console.error("Batch execution error:", r), e.json({
115
- error: r instanceof Error ? r.message : "Batch execution failed"
112
+ const t = await d(r), n = r.req.header("x-cache-control") === "no-cache", l = await Q(o, t, s, { skipCache: n });
113
+ return r.json(l);
114
+ } catch (e) {
115
+ return console.error("Batch execution error:", e), r.json({
116
+ error: e instanceof Error ? e.message : "Batch execution failed"
116
117
  }, 500);
117
118
  }
118
- }), c.get(`${d}/meta`, (e) => {
119
+ }), i.get(`${y}/meta`, (r) => {
119
120
  try {
120
- const r = o.getMetadata();
121
- return e.json(b(r));
122
- } catch (r) {
123
- return console.error("Metadata error:", r), e.json({
124
- error: r instanceof Error ? r.message : "Failed to fetch metadata"
121
+ const e = s.getMetadata();
122
+ return r.json(E(e));
123
+ } catch (e) {
124
+ return console.error("Metadata error:", e), r.json({
125
+ error: e instanceof Error ? e.message : "Failed to fetch metadata"
125
126
  }, 500);
126
127
  }
127
- }), c.post(`${d}/sql`, async (e) => {
128
+ }), i.post(`${y}/sql`, async (r) => {
128
129
  try {
129
- const r = await e.req.json(), t = await y(e), a = o.validateQuery(r);
130
- if (!a.isValid)
131
- return e.json({
132
- error: `Query validation failed: ${a.errors.join(", ")}`
130
+ const e = await r.req.json(), o = await d(r), t = s.validateQuery(e);
131
+ if (!t.isValid)
132
+ return r.json({
133
+ error: `Query validation failed: ${t.errors.join(", ")}`
133
134
  }, 400);
134
- const s = r.measures?.[0] || r.dimensions?.[0];
135
- if (!s)
136
- return e.json({
135
+ const n = e.measures?.[0] || e.dimensions?.[0];
136
+ if (!n)
137
+ return r.json({
137
138
  error: "No measures or dimensions specified"
138
139
  }, 400);
139
- const l = s.split(".")[0], h = await o.generateSQL(l, r, t);
140
- return e.json(w(r, h));
141
- } catch (r) {
142
- return console.error("SQL generation error:", r), e.json({
143
- error: r instanceof Error ? r.message : "SQL generation failed"
140
+ const l = n.split(".")[0], h = await s.generateSQL(l, e, o);
141
+ return r.json(w(e, h));
142
+ } catch (e) {
143
+ return console.error("SQL generation error:", e), r.json({
144
+ error: e instanceof Error ? e.message : "SQL generation failed"
144
145
  }, 500);
145
146
  }
146
- }), c.get(`${d}/sql`, async (e) => {
147
+ }), i.get(`${y}/sql`, async (r) => {
147
148
  try {
148
- const r = e.req.query("query");
149
- if (!r)
150
- return e.json({
149
+ const e = r.req.query("query");
150
+ if (!e)
151
+ return r.json({
151
152
  error: "Query parameter is required"
152
153
  }, 400);
153
- const t = JSON.parse(r), a = await y(e), s = o.validateQuery(t);
154
- if (!s.isValid)
155
- return e.json({
156
- error: `Query validation failed: ${s.errors.join(", ")}`
154
+ const o = JSON.parse(e), t = await d(r), n = s.validateQuery(o);
155
+ if (!n.isValid)
156
+ return r.json({
157
+ error: `Query validation failed: ${n.errors.join(", ")}`
157
158
  }, 400);
158
- const l = t.measures?.[0] || t.dimensions?.[0];
159
+ const l = o.measures?.[0] || o.dimensions?.[0];
159
160
  if (!l)
160
- return e.json({
161
+ return r.json({
161
162
  error: "No measures or dimensions specified"
162
163
  }, 400);
163
- const h = l.split(".")[0], C = await o.generateSQL(h, t, a);
164
- return e.json(w(t, C));
165
- } catch (r) {
166
- return console.error("SQL generation error:", r), e.json({
167
- error: r instanceof Error ? r.message : "SQL generation failed"
164
+ const h = l.split(".")[0], v = await s.generateSQL(h, o, t);
165
+ return r.json(w(o, v));
166
+ } catch (e) {
167
+ return console.error("SQL generation error:", e), r.json({
168
+ error: e instanceof Error ? e.message : "SQL generation failed"
168
169
  }, 500);
169
170
  }
170
- }), c.post(`${d}/dry-run`, async (e) => {
171
+ }), i.post(`${y}/dry-run`, async (r) => {
171
172
  try {
172
- const r = await e.req.json(), t = r.query || r, a = await y(e), s = await g(t, a, o);
173
- return e.json(s);
174
- } catch (r) {
175
- return console.error("Dry-run error:", r), e.json({
176
- error: r instanceof Error ? r.message : "Dry-run validation failed",
173
+ const e = await r.req.json(), o = e.query || e, t = await d(r), n = await x(o, t, s);
174
+ return r.json(n);
175
+ } catch (e) {
176
+ return console.error("Dry-run error:", e), r.json({
177
+ error: e instanceof Error ? e.message : "Dry-run validation failed",
177
178
  valid: !1
178
179
  }, 400);
179
180
  }
180
- }), c.get(`${d}/dry-run`, async (e) => {
181
+ }), i.get(`${y}/dry-run`, async (r) => {
181
182
  try {
182
- const r = e.req.query("query");
183
- if (!r)
184
- return e.json({
183
+ const e = r.req.query("query");
184
+ if (!e)
185
+ return r.json({
185
186
  error: "Query parameter is required",
186
187
  valid: !1
187
188
  }, 400);
188
- const t = JSON.parse(r), a = await y(e), s = await g(t, a, o);
189
- return e.json(s);
190
- } catch (r) {
191
- return console.error("Dry-run error:", r), e.json({
192
- error: r instanceof Error ? r.message : "Dry-run validation failed",
189
+ const o = JSON.parse(e), t = await d(r), n = await x(o, t, s);
190
+ return r.json(n);
191
+ } catch (e) {
192
+ return console.error("Dry-run error:", e), r.json({
193
+ error: e instanceof Error ? e.message : "Dry-run validation failed",
193
194
  valid: !1
194
195
  }, 400);
195
196
  }
196
- }), c.post(`${d}/explain`, async (e) => {
197
+ }), i.post(`${y}/explain`, async (r) => {
197
198
  try {
198
- const r = await e.req.json(), t = r.query || r, a = r.options || {}, s = await y(e), l = o.validateQuery(t);
199
+ const e = await r.req.json(), o = e.query || e, t = e.options || {}, n = await d(r), l = s.validateQuery(o);
199
200
  if (!l.isValid)
200
- return e.json({
201
+ return r.json({
201
202
  error: `Query validation failed: ${l.errors.join(", ")}`
202
203
  }, 400);
203
- const h = await o.explainQuery(t, s, a);
204
- return e.json(h);
205
- } catch (r) {
206
- return console.error("Explain error:", r), e.json({
207
- error: r instanceof Error ? r.message : "Explain query failed"
204
+ const h = await s.explainQuery(o, n, t);
205
+ return r.json(h);
206
+ } catch (e) {
207
+ return console.error("Explain error:", e), r.json({
208
+ error: e instanceof Error ? e.message : "Explain query failed"
208
209
  }, 500);
209
210
  }
210
- }), c;
211
+ }), g.enabled !== !1) {
212
+ const r = g.tools || ["discover", "suggest", "validate", "load"], e = g.basePath ?? "/mcp";
213
+ r.includes("discover") && i.post(`${e}/discover`, async (o) => {
214
+ try {
215
+ const t = await o.req.json(), n = await A(s, t);
216
+ return o.json(n);
217
+ } catch (t) {
218
+ return console.error("Discover error:", t), o.json({
219
+ error: t instanceof Error ? t.message : "Discovery failed"
220
+ }, 500);
221
+ }
222
+ }), r.includes("suggest") && i.post(`${e}/suggest`, async (o) => {
223
+ try {
224
+ const t = await o.req.json();
225
+ if (!t.naturalLanguage)
226
+ return o.json({
227
+ error: "naturalLanguage field is required"
228
+ }, 400);
229
+ const n = await S(s, t);
230
+ return o.json(n);
231
+ } catch (t) {
232
+ return console.error("Suggest error:", t), o.json({
233
+ error: t instanceof Error ? t.message : "Query suggestion failed"
234
+ }, 500);
235
+ }
236
+ }), r.includes("validate") && i.post(`${e}/validate`, async (o) => {
237
+ try {
238
+ const t = await o.req.json();
239
+ if (!t.query)
240
+ return o.json({
241
+ error: "query field is required"
242
+ }, 400);
243
+ const n = await $(s, t);
244
+ return o.json(n);
245
+ } catch (t) {
246
+ return console.error("Validate error:", t), o.json({
247
+ error: t instanceof Error ? t.message : "Query validation failed"
248
+ }, 500);
249
+ }
250
+ }), r.includes("load") && i.post(`${e}/load`, async (o) => {
251
+ try {
252
+ const t = await o.req.json();
253
+ if (!t.query)
254
+ return o.json({
255
+ error: "query field is required"
256
+ }, 400);
257
+ const n = await d(o), l = await R(s, n, t);
258
+ return o.json(l);
259
+ } catch (t) {
260
+ return console.error("Load error:", t), o.json({
261
+ error: t instanceof Error ? t.message : "Query execution failed"
262
+ }, 500);
263
+ }
264
+ });
265
+ }
266
+ return i;
211
267
  }
212
- function S(q, m) {
213
- const u = E(m);
214
- return q.route("/", u), q;
268
+ function D(q, j) {
269
+ const c = H(j);
270
+ return q.route("/", c), q;
215
271
  }
216
- function H(q) {
217
- const m = new x();
218
- return S(m, q);
272
+ function P(q) {
273
+ const j = new C();
274
+ return D(j, q);
219
275
  }
220
276
  export {
221
- H as createCubeApp,
222
- E as createCubeRoutes,
223
- S as mountCubeRoutes
277
+ P as createCubeApp,
278
+ H as createCubeRoutes,
279
+ D as mountCubeRoutes
224
280
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("next/server"),c=require("../compiler-CO13DaEb.cjs");function h(t){const{cubes:n,drizzle:a,schema:o,engineType:f,cache:r}=t;if(!n||n.length===0)throw new Error("At least one cube must be provided in the cubes array");const i=new c.SemanticLayerCompiler({drizzle:a,schema:o,engineType:f,cache:r});return n.forEach(e=>{i.registerCube(e)}),i}function p(t,n){const a=t.headers.get("origin"),o={};return n.origin&&(typeof n.origin=="string"?o["Access-Control-Allow-Origin"]=n.origin:Array.isArray(n.origin)?a&&n.origin.includes(a)&&(o["Access-Control-Allow-Origin"]=a):typeof n.origin=="function"&&a&&n.origin(a)&&(o["Access-Control-Allow-Origin"]=a)),n.methods&&(o["Access-Control-Allow-Methods"]=n.methods.join(", ")),n.allowedHeaders&&(o["Access-Control-Allow-Headers"]=n.allowedHeaders.join(", ")),n.credentials&&(o["Access-Control-Allow-Credentials"]="true"),o}function S(t){return async function(a){const o=p(a,t);return new Response(null,{status:200,headers:o})}}function N(t){const{extractSecurityContext:n,cors:a}=t,o=h(t);return async function(r,i){try{let e;if(r.method==="POST"){const m=await r.json();e=m.query||m}else if(r.method==="GET"){const m=r.nextUrl.searchParams.get("query");if(!m)return s.NextResponse.json(c.formatErrorResponse("Query parameter is required",400),{status:400});try{e=JSON.parse(m)}catch{return s.NextResponse.json(c.formatErrorResponse("Invalid JSON in query parameter",400),{status:400})}}else return s.NextResponse.json(c.formatErrorResponse("Method not allowed",405),{status:405});const u=await n(r,i),d=o.validateQuery(e);if(!d.isValid)return s.NextResponse.json(c.formatErrorResponse(`Query validation failed: ${d.errors.join(", ")}`,400),{status:400});const l=r.headers.get("x-cache-control")==="no-cache",y=await o.executeMultiCubeQuery(e,u,{skipCache:l}),x=c.formatCubeResponse(e,y,o);return s.NextResponse.json(x,{headers:a?p(r,a):{}})}catch(e){return process.env.NODE_ENV!=="test"&&console.error("Next.js load handler error:",e),s.NextResponse.json(c.formatErrorResponse(e instanceof Error?e.message:"Query execution failed",500),{status:500})}}}function j(t){const{cors:n}=t,a=h(t);return async function(f,r){try{const i=a.getMetadata(),e=c.formatMetaResponse(i);return s.NextResponse.json(e,{headers:n?p(f,n):{}})}catch(i){return process.env.NODE_ENV!=="test"&&console.error("Next.js meta handler error:",i),s.NextResponse.json(c.formatErrorResponse(i instanceof Error?i.message:"Failed to fetch metadata",500),{status:500})}}}function E(t){const{extractSecurityContext:n,cors:a}=t,o=h(t);return async function(r,i){try{let e;if(r.method==="POST"){const R=await r.json();e=R.query||R}else if(r.method==="GET"){const R=r.nextUrl.searchParams.get("query");if(!R)return s.NextResponse.json(c.formatErrorResponse("Query parameter is required",400),{status:400});try{e=JSON.parse(R)}catch{return s.NextResponse.json(c.formatErrorResponse("Invalid JSON in query parameter",400),{status:400})}}else return s.NextResponse.json(c.formatErrorResponse("Method not allowed",405),{status:405});const u=await n(r,i),d=o.validateQuery(e);if(!d.isValid)return s.NextResponse.json(c.formatErrorResponse(`Query validation failed: ${d.errors.join(", ")}`,400),{status:400});const l=e.measures?.[0]||e.dimensions?.[0];if(!l)return s.NextResponse.json(c.formatErrorResponse("No measures or dimensions specified",400),{status:400});const y=l.split(".")[0],x=await o.generateSQL(y,e,u),m=c.formatSqlResponse(e,x);return s.NextResponse.json(m,{headers:a?p(r,a):{}})}catch(e){return process.env.NODE_ENV!=="test"&&console.error("Next.js SQL handler error:",e),s.NextResponse.json(c.formatErrorResponse(e instanceof Error?e.message:"SQL generation failed",500),{status:500})}}}function g(t){const{extractSecurityContext:n,cors:a}=t,o=h(t);return async function(r,i){try{let e;if(r.method==="POST"){const l=await r.json();e=l.query||l}else if(r.method==="GET"){const l=r.nextUrl.searchParams.get("query");if(!l)return s.NextResponse.json({error:"Query parameter is required",valid:!1},{status:400});try{e=JSON.parse(l)}catch{return s.NextResponse.json({error:"Invalid JSON in query parameter",valid:!1},{status:400})}}else return s.NextResponse.json({error:"Method not allowed",valid:!1},{status:405});const u=await n(r,i),d=await c.handleDryRun(e,u,o);return s.NextResponse.json(d,{headers:a?p(r,a):{}})}catch(e){return process.env.NODE_ENV!=="test"&&console.error("Next.js dry-run handler error:",e),s.NextResponse.json({error:e instanceof Error?e.message:"Dry-run validation failed",valid:!1},{status:400})}}}function w(t){const{extractSecurityContext:n,cors:a}=t,o=h(t);return async function(r,i){try{if(r.method!=="POST")return s.NextResponse.json(c.formatErrorResponse("Method not allowed - use POST",405),{status:405});const e=await r.json(),{queries:u}=e;if(!u||!Array.isArray(u))return s.NextResponse.json(c.formatErrorResponse('Request body must contain a "queries" array',400),{status:400});if(u.length===0)return s.NextResponse.json(c.formatErrorResponse("Queries array cannot be empty",400),{status:400});const d=await n(r,i),l=r.headers.get("x-cache-control")==="no-cache",y=await c.handleBatchRequest(u,d,o,{skipCache:l});return s.NextResponse.json(y,{headers:a?p(r,a):{}})}catch(e){return process.env.NODE_ENV!=="test"&&console.error("Next.js batch handler error:",e),s.NextResponse.json(c.formatErrorResponse(e instanceof Error?e.message:"Batch execution failed",500),{status:500})}}}function H(t){const{extractSecurityContext:n,cors:a}=t,o=h(t);return async function(r,i){try{if(r.method!=="POST")return s.NextResponse.json({error:"Method not allowed"},{status:405});const e=await r.json(),u=e.query||e,d=e.options||{},l=await n(r,i),y=o.validateQuery(u);if(!y.isValid)return s.NextResponse.json({error:`Query validation failed: ${y.errors.join(", ")}`},{status:400});const x=await o.explainQuery(u,l,d);return s.NextResponse.json(x,{headers:a?p(r,a):{}})}catch(e){return process.env.NODE_ENV!=="test"&&console.error("Next.js explain handler error:",e),s.NextResponse.json({error:e instanceof Error?e.message:"Explain query failed"},{status:500})}}}function v(t){return{load:N(t),meta:j(t),sql:E(t),dryRun:g(t),batch:w(t),explain:H(t)}}exports.createBatchHandler=w;exports.createCubeHandlers=v;exports.createDryRunHandler=g;exports.createExplainHandler=H;exports.createLoadHandler=N;exports.createMetaHandler=j;exports.createOptionsHandler=S;exports.createSqlHandler=E;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("next/server"),i=require("../validation-Bgauxvm6.cjs");function m(r){const{cubes:t,drizzle:o,schema:c,engineType:l,cache:n}=r;if(!t||t.length===0)throw new Error("At least one cube must be provided in the cubes array");const a=new i.SemanticLayerCompiler({drizzle:o,schema:c,engineType:l,cache:n});return t.forEach(e=>{a.registerCube(e)}),a}function y(r,t){const o=r.headers.get("origin"),c={};return t.origin&&(typeof t.origin=="string"?c["Access-Control-Allow-Origin"]=t.origin:Array.isArray(t.origin)?o&&t.origin.includes(o)&&(c["Access-Control-Allow-Origin"]=o):typeof t.origin=="function"&&o&&t.origin(o)&&(c["Access-Control-Allow-Origin"]=o)),t.methods&&(c["Access-Control-Allow-Methods"]=t.methods.join(", ")),t.allowedHeaders&&(c["Access-Control-Allow-Headers"]=t.allowedHeaders.join(", ")),t.credentials&&(c["Access-Control-Allow-Credentials"]="true"),c}function O(r){return async function(o){const c=y(o,r);return new Response(null,{status:200,headers:c})}}function N(r){const{extractSecurityContext:t,cors:o}=r,c=m(r);return async function(n,a){try{let e;if(n.method==="POST"){const h=await n.json();e=h.query||h}else if(n.method==="GET"){const h=n.nextUrl.searchParams.get("query");if(!h)return s.NextResponse.json(i.formatErrorResponse("Query parameter is required",400),{status:400});try{e=JSON.parse(h)}catch{return s.NextResponse.json(i.formatErrorResponse("Invalid JSON in query parameter",400),{status:400})}}else return s.NextResponse.json(i.formatErrorResponse("Method not allowed",405),{status:405});const u=await t(n,a),f=c.validateQuery(e);if(!f.isValid)return s.NextResponse.json(i.formatErrorResponse(`Query validation failed: ${f.errors.join(", ")}`,400),{status:400});const d=n.headers.get("x-cache-control")==="no-cache",p=await c.executeMultiCubeQuery(e,u,{skipCache:d}),x=i.formatCubeResponse(e,p,c);return s.NextResponse.json(x,{headers:o?y(n,o):{}})}catch(e){return process.env.NODE_ENV!=="test"&&console.error("Next.js load handler error:",e),s.NextResponse.json(i.formatErrorResponse(e instanceof Error?e.message:"Query execution failed",500),{status:500})}}}function j(r){const{cors:t}=r,o=m(r);return async function(l,n){try{const a=o.getMetadata(),e=i.formatMetaResponse(a);return s.NextResponse.json(e,{headers:t?y(l,t):{}})}catch(a){return process.env.NODE_ENV!=="test"&&console.error("Next.js meta handler error:",a),s.NextResponse.json(i.formatErrorResponse(a instanceof Error?a.message:"Failed to fetch metadata",500),{status:500})}}}function E(r){const{extractSecurityContext:t,cors:o}=r,c=m(r);return async function(n,a){try{let e;if(n.method==="POST"){const R=await n.json();e=R.query||R}else if(n.method==="GET"){const R=n.nextUrl.searchParams.get("query");if(!R)return s.NextResponse.json(i.formatErrorResponse("Query parameter is required",400),{status:400});try{e=JSON.parse(R)}catch{return s.NextResponse.json(i.formatErrorResponse("Invalid JSON in query parameter",400),{status:400})}}else return s.NextResponse.json(i.formatErrorResponse("Method not allowed",405),{status:405});const u=await t(n,a),f=c.validateQuery(e);if(!f.isValid)return s.NextResponse.json(i.formatErrorResponse(`Query validation failed: ${f.errors.join(", ")}`,400),{status:400});const d=e.measures?.[0]||e.dimensions?.[0];if(!d)return s.NextResponse.json(i.formatErrorResponse("No measures or dimensions specified",400),{status:400});const p=d.split(".")[0],x=await c.generateSQL(p,e,u),h=i.formatSqlResponse(e,x);return s.NextResponse.json(h,{headers:o?y(n,o):{}})}catch(e){return process.env.NODE_ENV!=="test"&&console.error("Next.js SQL handler error:",e),s.NextResponse.json(i.formatErrorResponse(e instanceof Error?e.message:"SQL generation failed",500),{status:500})}}}function g(r){const{extractSecurityContext:t,cors:o}=r,c=m(r);return async function(n,a){try{let e;if(n.method==="POST"){const d=await n.json();e=d.query||d}else if(n.method==="GET"){const d=n.nextUrl.searchParams.get("query");if(!d)return s.NextResponse.json({error:"Query parameter is required",valid:!1},{status:400});try{e=JSON.parse(d)}catch{return s.NextResponse.json({error:"Invalid JSON in query parameter",valid:!1},{status:400})}}else return s.NextResponse.json({error:"Method not allowed",valid:!1},{status:405});const u=await t(n,a),f=await i.handleDryRun(e,u,c);return s.NextResponse.json(f,{headers:o?y(n,o):{}})}catch(e){return process.env.NODE_ENV!=="test"&&console.error("Next.js dry-run handler error:",e),s.NextResponse.json({error:e instanceof Error?e.message:"Dry-run validation failed",valid:!1},{status:400})}}}function v(r){const{extractSecurityContext:t,cors:o}=r,c=m(r);return async function(n,a){try{if(n.method!=="POST")return s.NextResponse.json(i.formatErrorResponse("Method not allowed - use POST",405),{status:405});const e=await n.json(),{queries:u}=e;if(!u||!Array.isArray(u))return s.NextResponse.json(i.formatErrorResponse('Request body must contain a "queries" array',400),{status:400});if(u.length===0)return s.NextResponse.json(i.formatErrorResponse("Queries array cannot be empty",400),{status:400});const f=await t(n,a),d=n.headers.get("x-cache-control")==="no-cache",p=await i.handleBatchRequest(u,f,c,{skipCache:d});return s.NextResponse.json(p,{headers:o?y(n,o):{}})}catch(e){return process.env.NODE_ENV!=="test"&&console.error("Next.js batch handler error:",e),s.NextResponse.json(i.formatErrorResponse(e instanceof Error?e.message:"Batch execution failed",500),{status:500})}}}function w(r){const{extractSecurityContext:t,cors:o}=r,c=m(r);return async function(n,a){try{if(n.method!=="POST")return s.NextResponse.json({error:"Method not allowed"},{status:405});const e=await n.json(),u=e.query||e,f=e.options||{},d=await t(n,a),p=c.validateQuery(u);if(!p.isValid)return s.NextResponse.json({error:`Query validation failed: ${p.errors.join(", ")}`},{status:400});const x=await c.explainQuery(u,d,f);return s.NextResponse.json(x,{headers:o?y(n,o):{}})}catch(e){return process.env.NODE_ENV!=="test"&&console.error("Next.js explain handler error:",e),s.NextResponse.json({error:e instanceof Error?e.message:"Explain query failed"},{status:500})}}}function H(r){const{cors:t}=r,o=m(r);return async function(l,n){try{if(l.method!=="POST")return s.NextResponse.json(i.formatErrorResponse("Method not allowed - use POST",405),{status:405});const a=await l.json(),e=await i.handleDiscover(o,a);return s.NextResponse.json(e,{headers:t?y(l,t):{}})}catch(a){return process.env.NODE_ENV!=="test"&&console.error("Next.js discover handler error:",a),s.NextResponse.json(i.formatErrorResponse(a instanceof Error?a.message:"Discovery failed",500),{status:500})}}}function S(r){const{cors:t}=r,o=m(r);return async function(l,n){try{if(l.method!=="POST")return s.NextResponse.json(i.formatErrorResponse("Method not allowed - use POST",405),{status:405});const a=await l.json();if(!a.naturalLanguage)return s.NextResponse.json(i.formatErrorResponse("naturalLanguage field is required",400),{status:400});const e=await i.handleSuggest(o,a);return s.NextResponse.json(e,{headers:t?y(l,t):{}})}catch(a){return process.env.NODE_ENV!=="test"&&console.error("Next.js suggest handler error:",a),s.NextResponse.json(i.formatErrorResponse(a instanceof Error?a.message:"Query suggestion failed",500),{status:500})}}}function b(r){const{cors:t}=r,o=m(r);return async function(l,n){try{if(l.method!=="POST")return s.NextResponse.json(i.formatErrorResponse("Method not allowed - use POST",405),{status:405});const a=await l.json();if(!a.query)return s.NextResponse.json(i.formatErrorResponse("query field is required",400),{status:400});const e=await i.handleValidate(o,a);return s.NextResponse.json(e,{headers:t?y(l,t):{}})}catch(a){return process.env.NODE_ENV!=="test"&&console.error("Next.js validate handler error:",a),s.NextResponse.json(i.formatErrorResponse(a instanceof Error?a.message:"Query validation failed",500),{status:500})}}}function C(r){const{extractSecurityContext:t,cors:o}=r,c=m(r);return async function(n,a){try{if(n.method!=="POST")return s.NextResponse.json(i.formatErrorResponse("Method not allowed - use POST",405),{status:405});const e=await n.json();if(!e.query)return s.NextResponse.json(i.formatErrorResponse("query field is required",400),{status:400});const u=await t(n,a),f=await i.handleLoad(c,u,e);return s.NextResponse.json(f,{headers:o?y(n,o):{}})}catch(e){return process.env.NODE_ENV!=="test"&&console.error("Next.js MCP load handler error:",e),s.NextResponse.json(i.formatErrorResponse(e instanceof Error?e.message:"Query execution failed",500),{status:500})}}}function L(r){const{mcp:t={enabled:!0}}=r,o=t.tools||["discover","suggest","validate","load"],c={load:N(r),meta:j(r),sql:E(r),dryRun:g(r),batch:v(r),explain:w(r)};return t.enabled!==!1&&(o.includes("discover")&&(c.discover=H(r)),o.includes("suggest")&&(c.suggest=S(r)),o.includes("validate")&&(c.validate=b(r)),o.includes("load")&&(c.mcpLoad=C(r))),c}exports.createBatchHandler=v;exports.createCubeHandlers=L;exports.createDiscoverHandler=H;exports.createDryRunHandler=g;exports.createExplainHandler=w;exports.createLoadHandler=N;exports.createMcpLoadHandler=C;exports.createMetaHandler=j;exports.createOptionsHandler=O;exports.createSqlHandler=E;exports.createSuggestHandler=S;exports.createValidateHandler=b;
@@ -3,6 +3,7 @@ import { SemanticQuery, SecurityContext, DatabaseExecutor, DrizzleDatabase, Cube
3
3
  import { PostgresJsDatabase } from 'drizzle-orm/postgres-js';
4
4
  import { MySql2Database } from 'drizzle-orm/mysql2';
5
5
  import { BetterSQLite3Database } from 'drizzle-orm/better-sqlite3';
6
+ import { MCPOptions } from '../utils';
6
7
  export interface NextCorsOptions {
7
8
  /**
8
9
  * Allowed origins for CORS
@@ -65,7 +66,7 @@ export interface NextAdapterOptions {
65
66
  /**
66
67
  * Database engine type (optional - auto-detected if not provided)
67
68
  */
68
- engineType?: 'postgres' | 'mysql' | 'sqlite';
69
+ engineType?: 'postgres' | 'mysql' | 'sqlite' | 'singlestore' | 'duckdb';
69
70
  /**
70
71
  * CORS configuration (optional)
71
72
  */
@@ -80,6 +81,12 @@ export interface NextAdapterOptions {
80
81
  * When provided, query results will be cached using the specified provider
81
82
  */
82
83
  cache?: CacheConfig;
84
+ /**
85
+ * MCP (AI-Ready) endpoint configuration
86
+ * Enables AI agents to discover and query your data
87
+ * @default { enabled: true }
88
+ */
89
+ mcp?: MCPOptions;
83
90
  }
84
91
  export interface RouteContext {
85
92
  params?: Record<string, string | string[]>;
@@ -92,6 +99,10 @@ export interface CubeHandlers {
92
99
  dryRun: RouteHandler;
93
100
  batch: RouteHandler;
94
101
  explain: RouteHandler;
102
+ discover?: RouteHandler;
103
+ suggest?: RouteHandler;
104
+ validate?: RouteHandler;
105
+ mcpLoad?: RouteHandler;
95
106
  }
96
107
  /**
97
108
  * Create OPTIONS handler for CORS preflight requests
@@ -123,6 +134,23 @@ export declare function createBatchHandler(options: NextAdapterOptions): RouteHa
123
134
  * Returns normalized EXPLAIN output across PostgreSQL, MySQL, and SQLite
124
135
  */
125
136
  export declare function createExplainHandler(options: NextAdapterOptions): RouteHandler;
137
+ /**
138
+ * Create discover handler - Find relevant cubes based on topic/intent
139
+ */
140
+ export declare function createDiscoverHandler(options: NextAdapterOptions): RouteHandler;
141
+ /**
142
+ * Create suggest handler - Generate query from natural language
143
+ */
144
+ export declare function createSuggestHandler(options: NextAdapterOptions): RouteHandler;
145
+ /**
146
+ * Create validate handler - Validate query with helpful corrections
147
+ */
148
+ export declare function createValidateHandler(options: NextAdapterOptions): RouteHandler;
149
+ /**
150
+ * Create MCP load handler - Execute a query and return results
151
+ * Completes the AI workflow: discover → suggest → validate → load
152
+ */
153
+ export declare function createMcpLoadHandler(options: NextAdapterOptions): RouteHandler;
126
154
  /**
127
155
  * Convenience function to create all route handlers
128
156
  *