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,55 +1,56 @@
1
- import { S as R, d as c, f, h as $, a as P, b as x, c as q } from "../compiler-DTOU8IsK.js";
2
- const Q = function(s, v, b) {
1
+ import { S as R, j as c, f as v, h as P, a as L, b as x, c as q, d as D, e as N, g as M, i as V } from "../validation-_UkKJ2pC.js";
2
+ const Q = function(o, w, h) {
3
3
  const {
4
- cubes: g,
4
+ cubes: b,
5
5
  drizzle: C,
6
- schema: w,
7
- extractSecurityContext: y,
6
+ schema: j,
7
+ extractSecurityContext: d,
8
8
  engineType: E,
9
- cors: h,
10
- basePath: d = "/cubejs-api/v1",
11
- bodyLimit: m = 10485760,
9
+ cors: f,
10
+ basePath: y = "/cubejs-api/v1",
11
+ bodyLimit: l = 10485760,
12
12
  // 10MB
13
- cache: S
14
- } = v;
15
- if (!g || g.length === 0)
16
- return b(new Error("At least one cube must be provided in the cubes array"));
17
- h && s.register(import("@fastify/cors"), h), s.addHook("onRequest", async (r, t) => {
13
+ cache: S,
14
+ mcp: m = { enabled: !0 }
15
+ } = w;
16
+ if (!b || b.length === 0)
17
+ return h(new Error("At least one cube must be provided in the cubes array"));
18
+ f && o.register(import("@fastify/cors"), f), o.addHook("onRequest", async (r, a) => {
18
19
  r.method === "POST" && (r.body = void 0);
19
20
  });
20
- const o = new R({
21
+ const n = new R({
21
22
  drizzle: C,
22
- schema: w,
23
+ schema: j,
23
24
  engineType: E,
24
25
  cache: S
25
26
  });
26
- g.forEach((r) => {
27
- o.registerCube(r);
28
- }), s.post(`${d}/load`, {
29
- bodyLimit: m,
27
+ if (b.forEach((r) => {
28
+ n.registerCube(r);
29
+ }), o.post(`${y}/load`, {
30
+ bodyLimit: l,
30
31
  schema: {
31
32
  body: {
32
33
  type: "object",
33
34
  additionalProperties: !0
34
35
  }
35
36
  }
36
- }, async (r, t) => {
37
+ }, async (r, a) => {
37
38
  try {
38
- const e = r.body, a = e.query || e, n = await y(r), i = o.validateQuery(a);
39
+ const e = r.body, s = e.query || e, t = await d(r), i = n.validateQuery(s);
39
40
  if (!i.isValid)
40
- return t.status(400).send(c(
41
+ return a.status(400).send(c(
41
42
  `Query validation failed: ${i.errors.join(", ")}`,
42
43
  400
43
44
  ));
44
- const u = r.headers["x-cache-control"] === "no-cache", l = await o.executeMultiCubeQuery(a, n, { skipCache: u });
45
- return f(a, l, o);
45
+ const u = r.headers["x-cache-control"] === "no-cache", g = await n.executeMultiCubeQuery(s, t, { skipCache: u });
46
+ return v(s, g, n);
46
47
  } catch (e) {
47
- return r.log.error(e, "Query execution error"), t.status(500).send(c(
48
+ return r.log.error(e, "Query execution error"), a.status(500).send(c(
48
49
  e instanceof Error ? e.message : "Query execution failed",
49
50
  500
50
51
  ));
51
52
  }
52
- }), s.get(`${d}/load`, {
53
+ }), o.get(`${y}/load`, {
53
54
  schema: {
54
55
  querystring: {
55
56
  type: "object",
@@ -59,34 +60,34 @@ const Q = function(s, v, b) {
59
60
  required: ["query"]
60
61
  }
61
62
  }
62
- }, async (r, t) => {
63
+ }, async (r, a) => {
63
64
  try {
64
65
  const { query: e } = r.query;
65
- let a;
66
+ let s;
66
67
  try {
67
- a = JSON.parse(e);
68
+ s = JSON.parse(e);
68
69
  } catch {
69
- return t.status(400).send(c(
70
+ return a.status(400).send(c(
70
71
  "Invalid JSON in query parameter",
71
72
  400
72
73
  ));
73
74
  }
74
- const n = await y(r), i = o.validateQuery(a);
75
+ const t = await d(r), i = n.validateQuery(s);
75
76
  if (!i.isValid)
76
- return t.status(400).send(c(
77
+ return a.status(400).send(c(
77
78
  `Query validation failed: ${i.errors.join(", ")}`,
78
79
  400
79
80
  ));
80
- const u = r.headers["x-cache-control"] === "no-cache", l = await o.executeMultiCubeQuery(a, n, { skipCache: u });
81
- return f(a, l, o);
81
+ const u = r.headers["x-cache-control"] === "no-cache", g = await n.executeMultiCubeQuery(s, t, { skipCache: u });
82
+ return v(s, g, n);
82
83
  } catch (e) {
83
- return r.log.error(e, "Query execution error"), t.status(500).send(c(
84
+ return r.log.error(e, "Query execution error"), a.status(500).send(c(
84
85
  e instanceof Error ? e.message : "Query execution failed",
85
86
  500
86
87
  ));
87
88
  }
88
- }), s.post(`${d}/batch`, {
89
- bodyLimit: m,
89
+ }), o.post(`${y}/batch`, {
90
+ bodyLimit: l,
90
91
  schema: {
91
92
  body: {
92
93
  type: "object",
@@ -99,68 +100,68 @@ const Q = function(s, v, b) {
99
100
  }
100
101
  }
101
102
  }
102
- }, async (r, t) => {
103
+ }, async (r, a) => {
103
104
  try {
104
105
  const { queries: e } = r.body;
105
106
  if (!e || !Array.isArray(e))
106
- return t.status(400).send(c(
107
+ return a.status(400).send(c(
107
108
  'Request body must contain a "queries" array',
108
109
  400
109
110
  ));
110
111
  if (e.length === 0)
111
- return t.status(400).send(c(
112
+ return a.status(400).send(c(
112
113
  "Queries array cannot be empty",
113
114
  400
114
115
  ));
115
- const a = await y(r), n = r.headers["x-cache-control"] === "no-cache";
116
- return await $(e, a, o, { skipCache: n });
116
+ const s = await d(r), t = r.headers["x-cache-control"] === "no-cache";
117
+ return await P(e, s, n, { skipCache: t });
117
118
  } catch (e) {
118
- return r.log.error(e, "Batch execution error"), t.status(500).send(c(
119
+ return r.log.error(e, "Batch execution error"), a.status(500).send(c(
119
120
  e instanceof Error ? e.message : "Batch execution failed",
120
121
  500
121
122
  ));
122
123
  }
123
- }), s.get(`${d}/meta`, async (r, t) => {
124
+ }), o.get(`${y}/meta`, async (r, a) => {
124
125
  try {
125
- const e = o.getMetadata();
126
- return P(e);
126
+ const e = n.getMetadata();
127
+ return L(e);
127
128
  } catch (e) {
128
- return r.log.error(e, "Metadata error"), t.status(500).send(c(
129
+ return r.log.error(e, "Metadata error"), a.status(500).send(c(
129
130
  e instanceof Error ? e.message : "Failed to fetch metadata",
130
131
  500
131
132
  ));
132
133
  }
133
- }), s.post(`${d}/sql`, {
134
- bodyLimit: m,
134
+ }), o.post(`${y}/sql`, {
135
+ bodyLimit: l,
135
136
  schema: {
136
137
  body: {
137
138
  type: "object",
138
139
  additionalProperties: !0
139
140
  }
140
141
  }
141
- }, async (r, t) => {
142
+ }, async (r, a) => {
142
143
  try {
143
- const e = r.body, a = await y(r), n = o.validateQuery(e);
144
- if (!n.isValid)
145
- return t.status(400).send(c(
146
- `Query validation failed: ${n.errors.join(", ")}`,
144
+ const e = r.body, s = await d(r), t = n.validateQuery(e);
145
+ if (!t.isValid)
146
+ return a.status(400).send(c(
147
+ `Query validation failed: ${t.errors.join(", ")}`,
147
148
  400
148
149
  ));
149
150
  const i = e.measures?.[0] || e.dimensions?.[0];
150
151
  if (!i)
151
- return t.status(400).send(c(
152
+ return a.status(400).send(c(
152
153
  "No measures or dimensions specified",
153
154
  400
154
155
  ));
155
- const u = i.split(".")[0], l = await o.generateSQL(u, e, a);
156
- return x(e, l);
156
+ const u = i.split(".")[0], g = await n.generateSQL(u, e, s);
157
+ return x(e, g);
157
158
  } catch (e) {
158
- return r.log.error(e, "SQL generation error"), t.status(500).send(c(
159
+ return r.log.error(e, "SQL generation error"), a.status(500).send(c(
159
160
  e instanceof Error ? e.message : "SQL generation failed",
160
161
  500
161
162
  ));
162
163
  }
163
- }), s.get(`${d}/sql`, {
164
+ }), o.get(`${y}/sql`, {
164
165
  schema: {
165
166
  querystring: {
166
167
  type: "object",
@@ -170,47 +171,47 @@ const Q = function(s, v, b) {
170
171
  required: ["query"]
171
172
  }
172
173
  }
173
- }, async (r, t) => {
174
+ }, async (r, a) => {
174
175
  try {
175
- const { query: e } = r.query, a = JSON.parse(e), n = await y(r), i = o.validateQuery(a);
176
+ const { query: e } = r.query, s = JSON.parse(e), t = await d(r), i = n.validateQuery(s);
176
177
  if (!i.isValid)
177
- return t.status(400).send(c(
178
+ return a.status(400).send(c(
178
179
  `Query validation failed: ${i.errors.join(", ")}`,
179
180
  400
180
181
  ));
181
- const u = a.measures?.[0] || a.dimensions?.[0];
182
+ const u = s.measures?.[0] || s.dimensions?.[0];
182
183
  if (!u)
183
- return t.status(400).send(c(
184
+ return a.status(400).send(c(
184
185
  "No measures or dimensions specified",
185
186
  400
186
187
  ));
187
- const l = u.split(".")[0], j = await o.generateSQL(l, a, n);
188
- return x(a, j);
188
+ const g = u.split(".")[0], $ = await n.generateSQL(g, s, t);
189
+ return x(s, $);
189
190
  } catch (e) {
190
- return r.log.error(e, "SQL generation error"), t.status(500).send(c(
191
+ return r.log.error(e, "SQL generation error"), a.status(500).send(c(
191
192
  e instanceof Error ? e.message : "SQL generation failed",
192
193
  500
193
194
  ));
194
195
  }
195
- }), s.post(`${d}/dry-run`, {
196
- bodyLimit: m,
196
+ }), o.post(`${y}/dry-run`, {
197
+ bodyLimit: l,
197
198
  schema: {
198
199
  body: {
199
200
  type: "object",
200
201
  additionalProperties: !0
201
202
  }
202
203
  }
203
- }, async (r, t) => {
204
+ }, async (r, a) => {
204
205
  try {
205
- const e = r.body, a = e.query || e, n = await y(r);
206
- return await q(a, n, o);
206
+ const e = r.body, s = e.query || e, t = await d(r);
207
+ return await q(s, t, n);
207
208
  } catch (e) {
208
- return r.log.error(e, "Dry-run error"), t.status(400).send({
209
+ return r.log.error(e, "Dry-run error"), a.status(400).send({
209
210
  error: e instanceof Error ? e.message : "Dry-run validation failed",
210
211
  valid: !1
211
212
  });
212
213
  }
213
- }), s.get(`${d}/dry-run`, {
214
+ }), o.get(`${y}/dry-run`, {
214
215
  schema: {
215
216
  querystring: {
216
217
  type: "object",
@@ -220,52 +221,138 @@ const Q = function(s, v, b) {
220
221
  required: ["query"]
221
222
  }
222
223
  }
223
- }, async (r, t) => {
224
+ }, async (r, a) => {
224
225
  try {
225
- const { query: e } = r.query, a = JSON.parse(e), n = await y(r);
226
- return await q(a, n, o);
226
+ const { query: e } = r.query, s = JSON.parse(e), t = await d(r);
227
+ return await q(s, t, n);
227
228
  } catch (e) {
228
- return r.log.error(e, "Dry-run error"), t.status(400).send({
229
+ return r.log.error(e, "Dry-run error"), a.status(400).send({
229
230
  error: e instanceof Error ? e.message : "Dry-run validation failed",
230
231
  valid: !1
231
232
  });
232
233
  }
233
- }), s.post(`${d}/explain`, {
234
- bodyLimit: m,
234
+ }), o.post(`${y}/explain`, {
235
+ bodyLimit: l,
235
236
  schema: {
236
237
  body: {
237
238
  type: "object",
238
239
  additionalProperties: !0
239
240
  }
240
241
  }
241
- }, async (r, t) => {
242
+ }, async (r, a) => {
242
243
  try {
243
- const e = r.body, a = e.query || e, n = e.options || {}, i = await y(r), u = o.validateQuery(a);
244
- return u.isValid ? await o.explainQuery(a, i, n) : t.status(400).send({
244
+ const e = r.body, s = e.query || e, t = e.options || {}, i = await d(r), u = n.validateQuery(s);
245
+ return u.isValid ? await n.explainQuery(s, i, t) : a.status(400).send({
245
246
  error: `Query validation failed: ${u.errors.join(", ")}`
246
247
  });
247
248
  } catch (e) {
248
- return r.log.error(e, "Explain error"), t.status(500).send({
249
+ return r.log.error(e, "Explain error"), a.status(500).send({
249
250
  error: e instanceof Error ? e.message : "Explain query failed"
250
251
  });
251
252
  }
252
- }), s.setErrorHandler(async (r, t, e) => {
253
- t.log.error(r, "Fastify cube adapter error"), e.statusCode < 400 && e.status(500);
254
- const a = r instanceof Error ? r : String(r);
255
- return c(a, e.statusCode);
256
- }), b();
253
+ }), m.enabled !== !1) {
254
+ const r = m.tools || ["discover", "suggest", "validate", "load"], a = m.basePath ?? "/mcp";
255
+ r.includes("discover") && o.post(`${a}/discover`, {
256
+ bodyLimit: l,
257
+ schema: {
258
+ body: {
259
+ type: "object",
260
+ additionalProperties: !0
261
+ }
262
+ }
263
+ }, async (e, s) => {
264
+ try {
265
+ const t = e.body;
266
+ return await D(n, t);
267
+ } catch (t) {
268
+ return e.log.error(t, "Discover error"), s.status(500).send(c(
269
+ t instanceof Error ? t.message : "Discovery failed",
270
+ 500
271
+ ));
272
+ }
273
+ }), r.includes("suggest") && o.post(`${a}/suggest`, {
274
+ bodyLimit: l,
275
+ schema: {
276
+ body: {
277
+ type: "object",
278
+ required: ["naturalLanguage"],
279
+ properties: {
280
+ naturalLanguage: { type: "string" },
281
+ cube: { type: "string" }
282
+ }
283
+ }
284
+ }
285
+ }, async (e, s) => {
286
+ try {
287
+ const t = e.body;
288
+ return await N(n, t);
289
+ } catch (t) {
290
+ return e.log.error(t, "Suggest error"), s.status(500).send(c(
291
+ t instanceof Error ? t.message : "Query suggestion failed",
292
+ 500
293
+ ));
294
+ }
295
+ }), r.includes("validate") && o.post(`${a}/validate`, {
296
+ bodyLimit: l,
297
+ schema: {
298
+ body: {
299
+ type: "object",
300
+ required: ["query"],
301
+ properties: {
302
+ query: { type: "object" }
303
+ }
304
+ }
305
+ }
306
+ }, async (e, s) => {
307
+ try {
308
+ const t = e.body;
309
+ return await M(n, t);
310
+ } catch (t) {
311
+ return e.log.error(t, "Validate error"), s.status(500).send(c(
312
+ t instanceof Error ? t.message : "Query validation failed",
313
+ 500
314
+ ));
315
+ }
316
+ }), r.includes("load") && o.post(`${a}/load`, {
317
+ bodyLimit: l,
318
+ schema: {
319
+ body: {
320
+ type: "object",
321
+ required: ["query"],
322
+ properties: {
323
+ query: { type: "object" }
324
+ }
325
+ }
326
+ }
327
+ }, async (e, s) => {
328
+ try {
329
+ const t = e.body, i = await d(e);
330
+ return await V(n, i, t);
331
+ } catch (t) {
332
+ return e.log.error(t, "Load error"), s.status(500).send(c(
333
+ t instanceof Error ? t.message : "Query execution failed",
334
+ 500
335
+ ));
336
+ }
337
+ });
338
+ }
339
+ o.setErrorHandler(async (r, a, e) => {
340
+ a.log.error(r, "Fastify cube adapter error"), e.statusCode < 400 && e.status(500);
341
+ const s = r instanceof Error ? r : String(r);
342
+ return c(s, e.statusCode);
343
+ }), h();
257
344
  };
258
- async function N(p, s) {
259
- await p.register(Q, s);
345
+ async function O(p, o) {
346
+ await p.register(Q, o);
260
347
  }
261
- function M(p) {
262
- const s = require("fastify")({
348
+ function k(p) {
349
+ const o = require("fastify")({
263
350
  logger: !0
264
351
  });
265
- return s.register(Q, p), s;
352
+ return o.register(Q, p), o;
266
353
  }
267
354
  export {
268
- M as createCubeApp,
355
+ k as createCubeApp,
269
356
  Q as cubePlugin,
270
- N as registerCubeRoutes
357
+ O as registerCubeRoutes
271
358
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("hono"),q=require("../compiler-CO13DaEb.cjs");var b=m=>{const u={...{origin:"*",allowMethods:["GET","HEAD","PUT","POST","DELETE","PATCH"],allowHeaders:[],exposeHeaders:[]},...m},j=(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);return async function(n,d){function f(o,e){n.res.headers.set(o,e)}const c=await j(n.req.header("origin")||"",n);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"){u.origin!=="*"&&f("Vary","Origin"),u.maxAge!=null&&f("Access-Control-Max-Age",u.maxAge.toString());const o=await y(n.req.header("origin")||"",n);o.length&&f("Access-Control-Allow-Methods",o.join(","));let e=u.allowHeaders;if(!e?.length){const r=n.req.header("Access-Control-Request-Headers");r&&(e=r.split(/\s*,\s*/))}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,{headers:n.res.headers,status:204,statusText:"No Content"})}await d(),u.origin!=="*"&&n.header("Vary","Origin",{append:!0})}};function w(m){const{cubes:p,drizzle:u,schema:j,extractSecurityContext:y,engineType:i,cors:n,basePath:d="/cubejs-api/v1",cache:f}=m;if(!p||p.length===0)throw new Error("At least one cube must be provided in the cubes array");const c=new g.Hono;n&&c.use("/*",b(n));const o=new q.SemanticLayerCompiler({drizzle:u,schema:j,engineType:i,cache:f});return p.forEach(e=>{o.registerCube(e)}),c.post(`${d}/load`,async e=>{try{const r=await e.req.json(),t=r.query||r,a=await y(e),s=o.validateQuery(t);if(!s.isValid)return e.json({error:`Query validation failed: ${s.errors.join(", ")}`},400);const l=e.req.header("x-cache-control")==="no-cache",h=await o.executeMultiCubeQuery(t,a,{skipCache:l});return e.json(q.formatCubeResponse(t,h,o))}catch(r){return console.error("Query execution error:",r),e.json({error:r instanceof Error?r.message:"Query execution failed"},500)}}),c.get(`${d}/load`,async e=>{try{const r=e.req.query("query");if(!r)return e.json({error:"Query parameter is required"},400);let t;try{t=JSON.parse(r)}catch{return e.json({error:"Invalid JSON in query parameter"},400)}const a=await y(e),s=o.validateQuery(t);if(!s.isValid)return e.json({error:`Query validation failed: ${s.errors.join(", ")}`},400);const l=e.req.header("x-cache-control")==="no-cache",h=await o.executeMultiCubeQuery(t,a,{skipCache:l});return e.json(q.formatCubeResponse(t,h,o))}catch(r){return console.error("Query execution error:",r),e.json({error:r instanceof Error?r.message:"Query execution failed"},500)}}),c.post(`${d}/batch`,async e=>{try{const r=await e.req.json(),{queries:t}=r;if(!t||!Array.isArray(t))return e.json({error:'Request body must contain a "queries" array'},400);if(t.length===0)return e.json({error:"Queries array cannot be empty"},400);const a=await y(e),s=e.req.header("x-cache-control")==="no-cache",l=await q.handleBatchRequest(t,a,o,{skipCache:s});return e.json(l)}catch(r){return console.error("Batch execution error:",r),e.json({error:r instanceof Error?r.message:"Batch execution failed"},500)}}),c.get(`${d}/meta`,e=>{try{const r=o.getMetadata();return e.json(q.formatMetaResponse(r))}catch(r){return console.error("Metadata error:",r),e.json({error:r instanceof Error?r.message:"Failed to fetch metadata"},500)}}),c.post(`${d}/sql`,async e=>{try{const r=await e.req.json(),t=await y(e),a=o.validateQuery(r);if(!a.isValid)return e.json({error:`Query validation failed: ${a.errors.join(", ")}`},400);const s=r.measures?.[0]||r.dimensions?.[0];if(!s)return e.json({error:"No measures or dimensions specified"},400);const l=s.split(".")[0],h=await o.generateSQL(l,r,t);return e.json(q.formatSqlResponse(r,h))}catch(r){return console.error("SQL generation error:",r),e.json({error:r instanceof Error?r.message:"SQL generation failed"},500)}}),c.get(`${d}/sql`,async e=>{try{const r=e.req.query("query");if(!r)return e.json({error:"Query parameter is required"},400);const t=JSON.parse(r),a=await y(e),s=o.validateQuery(t);if(!s.isValid)return e.json({error:`Query validation failed: ${s.errors.join(", ")}`},400);const l=t.measures?.[0]||t.dimensions?.[0];if(!l)return e.json({error:"No measures or dimensions specified"},400);const h=l.split(".")[0],x=await o.generateSQL(h,t,a);return e.json(q.formatSqlResponse(t,x))}catch(r){return console.error("SQL generation error:",r),e.json({error:r instanceof Error?r.message:"SQL generation failed"},500)}}),c.post(`${d}/dry-run`,async e=>{try{const r=await e.req.json(),t=r.query||r,a=await y(e),s=await q.handleDryRun(t,a,o);return e.json(s)}catch(r){return console.error("Dry-run error:",r),e.json({error:r instanceof Error?r.message:"Dry-run validation failed",valid:!1},400)}}),c.get(`${d}/dry-run`,async e=>{try{const r=e.req.query("query");if(!r)return e.json({error:"Query parameter is required",valid:!1},400);const t=JSON.parse(r),a=await y(e),s=await q.handleDryRun(t,a,o);return e.json(s)}catch(r){return console.error("Dry-run error:",r),e.json({error:r instanceof Error?r.message:"Dry-run validation failed",valid:!1},400)}}),c.post(`${d}/explain`,async e=>{try{const r=await e.req.json(),t=r.query||r,a=r.options||{},s=await y(e),l=o.validateQuery(t);if(!l.isValid)return e.json({error:`Query validation failed: ${l.errors.join(", ")}`},400);const h=await o.explainQuery(t,s,a);return e.json(h)}catch(r){return console.error("Explain error:",r),e.json({error:r instanceof Error?r.message:"Explain query failed"},500)}}),c}function C(m,p){const u=w(p);return m.route("/",u),m}function Q(m){const p=new g.Hono;return C(p,m)}exports.createCubeApp=Q;exports.createCubeRoutes=w;exports.mountCubeRoutes=C;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const w=require("hono"),d=require("../validation-Bgauxvm6.cjs");var b=j=>{const c={...{origin:"*",allowMethods:["GET","HEAD","PUT","POST","DELETE","PATCH"],allowHeaders:[],exposeHeaders:[]},...j},p=(u=>typeof u=="string"?u==="*"?()=>u:a=>u===a?a:null:typeof u=="function"?u:a=>u.includes(a)?a:null)(c.origin),y=(u=>typeof u=="function"?u:Array.isArray(u)?()=>u:()=>[])(c.allowMethods);return async function(a,f){function h(i,n){a.res.headers.set(i,n)}const m=await p(a.req.header("origin")||"",a);if(m&&h("Access-Control-Allow-Origin",m),c.credentials&&h("Access-Control-Allow-Credentials","true"),c.exposeHeaders?.length&&h("Access-Control-Expose-Headers",c.exposeHeaders.join(",")),a.req.method==="OPTIONS"){c.origin!=="*"&&h("Vary","Origin"),c.maxAge!=null&&h("Access-Control-Max-Age",c.maxAge.toString());const i=await y(a.req.header("origin")||"",a);i.length&&h("Access-Control-Allow-Methods",i.join(","));let n=c.allowHeaders;if(!n?.length){const r=a.req.header("Access-Control-Request-Headers");r&&(n=r.split(/\s*,\s*/))}return n?.length&&(h("Access-Control-Allow-Headers",n.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,{headers:a.res.headers,status:204,statusText:"No Content"})}await f(),c.origin!=="*"&&a.header("Vary","Origin",{append:!0})}};function C(j){const{cubes:g,drizzle:c,schema:p,extractSecurityContext:y,engineType:u,cors:a,basePath:f="/cubejs-api/v1",cache:h,mcp:m={enabled:!0}}=j;if(!g||g.length===0)throw new Error("At least one cube must be provided in the cubes array");const i=new w.Hono;a&&i.use("/*",b(a));const n=new d.SemanticLayerCompiler({drizzle:c,schema:p,engineType:u,cache:h});if(g.forEach(r=>{n.registerCube(r)}),i.post(`${f}/load`,async r=>{try{const e=await r.req.json(),o=e.query||e,t=await y(r),s=n.validateQuery(o);if(!s.isValid)return r.json({error:`Query validation failed: ${s.errors.join(", ")}`},400);const l=r.req.header("x-cache-control")==="no-cache",q=await n.executeMultiCubeQuery(o,t,{skipCache:l});return r.json(d.formatCubeResponse(o,q,n))}catch(e){return console.error("Query execution error:",e),r.json({error:e instanceof Error?e.message:"Query execution failed"},500)}}),i.get(`${f}/load`,async r=>{try{const e=r.req.query("query");if(!e)return r.json({error:"Query parameter is required"},400);let o;try{o=JSON.parse(e)}catch{return r.json({error:"Invalid JSON in query parameter"},400)}const t=await y(r),s=n.validateQuery(o);if(!s.isValid)return r.json({error:`Query validation failed: ${s.errors.join(", ")}`},400);const l=r.req.header("x-cache-control")==="no-cache",q=await n.executeMultiCubeQuery(o,t,{skipCache:l});return r.json(d.formatCubeResponse(o,q,n))}catch(e){return console.error("Query execution error:",e),r.json({error:e instanceof Error?e.message:"Query execution failed"},500)}}),i.post(`${f}/batch`,async r=>{try{const e=await r.req.json(),{queries:o}=e;if(!o||!Array.isArray(o))return r.json({error:'Request body must contain a "queries" array'},400);if(o.length===0)return r.json({error:"Queries array cannot be empty"},400);const t=await y(r),s=r.req.header("x-cache-control")==="no-cache",l=await d.handleBatchRequest(o,t,n,{skipCache:s});return r.json(l)}catch(e){return console.error("Batch execution error:",e),r.json({error:e instanceof Error?e.message:"Batch execution failed"},500)}}),i.get(`${f}/meta`,r=>{try{const e=n.getMetadata();return r.json(d.formatMetaResponse(e))}catch(e){return console.error("Metadata error:",e),r.json({error:e instanceof Error?e.message:"Failed to fetch metadata"},500)}}),i.post(`${f}/sql`,async r=>{try{const e=await r.req.json(),o=await y(r),t=n.validateQuery(e);if(!t.isValid)return r.json({error:`Query validation failed: ${t.errors.join(", ")}`},400);const s=e.measures?.[0]||e.dimensions?.[0];if(!s)return r.json({error:"No measures or dimensions specified"},400);const l=s.split(".")[0],q=await n.generateSQL(l,e,o);return r.json(d.formatSqlResponse(e,q))}catch(e){return console.error("SQL generation error:",e),r.json({error:e instanceof Error?e.message:"SQL generation failed"},500)}}),i.get(`${f}/sql`,async r=>{try{const e=r.req.query("query");if(!e)return r.json({error:"Query parameter is required"},400);const o=JSON.parse(e),t=await y(r),s=n.validateQuery(o);if(!s.isValid)return r.json({error:`Query validation failed: ${s.errors.join(", ")}`},400);const l=o.measures?.[0]||o.dimensions?.[0];if(!l)return r.json({error:"No measures or dimensions specified"},400);const q=l.split(".")[0],x=await n.generateSQL(q,o,t);return r.json(d.formatSqlResponse(o,x))}catch(e){return console.error("SQL generation error:",e),r.json({error:e instanceof Error?e.message:"SQL generation failed"},500)}}),i.post(`${f}/dry-run`,async r=>{try{const e=await r.req.json(),o=e.query||e,t=await y(r),s=await d.handleDryRun(o,t,n);return r.json(s)}catch(e){return console.error("Dry-run error:",e),r.json({error:e instanceof Error?e.message:"Dry-run validation failed",valid:!1},400)}}),i.get(`${f}/dry-run`,async r=>{try{const e=r.req.query("query");if(!e)return r.json({error:"Query parameter is required",valid:!1},400);const o=JSON.parse(e),t=await y(r),s=await d.handleDryRun(o,t,n);return r.json(s)}catch(e){return console.error("Dry-run error:",e),r.json({error:e instanceof Error?e.message:"Dry-run validation failed",valid:!1},400)}}),i.post(`${f}/explain`,async r=>{try{const e=await r.req.json(),o=e.query||e,t=e.options||{},s=await y(r),l=n.validateQuery(o);if(!l.isValid)return r.json({error:`Query validation failed: ${l.errors.join(", ")}`},400);const q=await n.explainQuery(o,s,t);return r.json(q)}catch(e){return console.error("Explain error:",e),r.json({error:e instanceof Error?e.message:"Explain query failed"},500)}}),m.enabled!==!1){const r=m.tools||["discover","suggest","validate","load"],e=m.basePath??"/mcp";r.includes("discover")&&i.post(`${e}/discover`,async o=>{try{const t=await o.req.json(),s=await d.handleDiscover(n,t);return o.json(s)}catch(t){return console.error("Discover error:",t),o.json({error:t instanceof Error?t.message:"Discovery failed"},500)}}),r.includes("suggest")&&i.post(`${e}/suggest`,async o=>{try{const t=await o.req.json();if(!t.naturalLanguage)return o.json({error:"naturalLanguage field is required"},400);const s=await d.handleSuggest(n,t);return o.json(s)}catch(t){return console.error("Suggest error:",t),o.json({error:t instanceof Error?t.message:"Query suggestion failed"},500)}}),r.includes("validate")&&i.post(`${e}/validate`,async o=>{try{const t=await o.req.json();if(!t.query)return o.json({error:"query field is required"},400);const s=await d.handleValidate(n,t);return o.json(s)}catch(t){return console.error("Validate error:",t),o.json({error:t instanceof Error?t.message:"Query validation failed"},500)}}),r.includes("load")&&i.post(`${e}/load`,async o=>{try{const t=await o.req.json();if(!t.query)return o.json({error:"query field is required"},400);const s=await y(o),l=await d.handleLoad(n,s,t);return o.json(l)}catch(t){return console.error("Load error:",t),o.json({error:t instanceof Error?t.message:"Query execution failed"},500)}})}return i}function v(j,g){const c=C(g);return j.route("/",c),j}function Q(j){const g=new w.Hono;return v(g,j)}exports.createCubeApp=Q;exports.createCubeRoutes=C;exports.mountCubeRoutes=v;
@@ -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 HonoAdapterOptions {
7
8
  /**
8
9
  * Array of cube definitions to register
@@ -46,7 +47,7 @@ export interface HonoAdapterOptions {
46
47
  /**
47
48
  * Database engine type (optional - auto-detected if not provided)
48
49
  */
49
- engineType?: 'postgres' | 'mysql' | 'sqlite';
50
+ engineType?: 'postgres' | 'mysql' | 'sqlite' | 'singlestore' | 'duckdb';
50
51
  /**
51
52
  * CORS configuration (optional)
52
53
  */
@@ -65,6 +66,12 @@ export interface HonoAdapterOptions {
65
66
  * When provided, query results will be cached using the specified provider
66
67
  */
67
68
  cache?: CacheConfig;
69
+ /**
70
+ * MCP (AI-Ready) endpoint configuration
71
+ * Enables AI agents to discover and query your data
72
+ * @default { enabled: true }
73
+ */
74
+ mcp?: MCPOptions;
68
75
  }
69
76
  /**
70
77
  * Create Hono routes for Cube.js-compatible API