drizzle-cube 0.4.53 → 0.5.1

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 (277) hide show
  1. package/dist/adapters/express/index.cjs +2 -2
  2. package/dist/adapters/express/index.js +109 -96
  3. package/dist/adapters/fastify/index.cjs +2 -2
  4. package/dist/adapters/fastify/index.js +148 -134
  5. package/dist/adapters/{handler-RItnSaEl.js → handler-3LGcjLtr.js} +617 -612
  6. package/dist/adapters/handler-BzzbVpcl.cjs +25 -0
  7. package/dist/adapters/hono/index.cjs +1 -1
  8. package/dist/adapters/hono/index.js +103 -99
  9. package/dist/adapters/{compiler-S6KHiOY6.js → locale-DTnJrxm1.js} +1700 -1563
  10. package/dist/adapters/locale-DueXjqMh.cjs +198 -0
  11. package/dist/adapters/locale.d.ts +8 -0
  12. package/dist/adapters/mcp-tools.cjs +1 -1
  13. package/dist/adapters/mcp-tools.d.ts +7 -3
  14. package/dist/adapters/mcp-tools.js +27 -27
  15. package/dist/adapters/mcp-transport-C7VLf4T5.js +579 -0
  16. package/dist/adapters/mcp-transport-poPHl_2j.cjs +39 -0
  17. package/dist/adapters/mcp-transport.d.ts +25 -2
  18. package/dist/adapters/nextjs/index.cjs +1 -1
  19. package/dist/adapters/nextjs/index.js +152 -132
  20. package/dist/adapters/utils-DNrj-ryp.cjs +17 -0
  21. package/dist/adapters/{utils-IH1ePsBd.js → utils-DOg9oGdt.js} +2341 -819
  22. package/dist/adapters/utils.cjs +1 -1
  23. package/dist/adapters/utils.d.ts +45 -2
  24. package/dist/adapters/utils.js +1 -1
  25. package/dist/client/charts.js +12 -12
  26. package/dist/client/chunks/{DashboardEditModal-BTdV528l.js → DashboardEditModal-cSSIAZGy.js} +1968 -1973
  27. package/dist/client/chunks/DashboardEditModal-cSSIAZGy.js.map +1 -0
  28. package/dist/client/chunks/{FieldSearchModal-D75vy4Wb.js → FieldSearchModal-CZNo4pNK.js} +550 -536
  29. package/dist/client/chunks/FieldSearchModal-CZNo4pNK.js.map +1 -0
  30. package/dist/client/chunks/KpiDelta-Dll_eCV1.js +2 -0
  31. package/dist/client/chunks/KpiNumber-BPlR92hI.js +2 -0
  32. package/dist/client/chunks/KpiText-BIxq7Jso.js +2 -0
  33. package/dist/client/chunks/{RetentionCombinedChart-DIhK5pD8.js → RetentionCombinedChart-BD8tGeM_.js} +96 -96
  34. package/dist/client/chunks/RetentionCombinedChart-BD8tGeM_.js.map +1 -0
  35. package/dist/client/chunks/{RetentionHeatmap-CyREolyP.js → RetentionHeatmap-B_5sewwi.js} +77 -77
  36. package/dist/client/chunks/RetentionHeatmap-B_5sewwi.js.map +1 -0
  37. package/dist/client/chunks/SchemaVisualization-CCICjhvv.js +2 -0
  38. package/dist/client/chunks/SchemaVisualizationLazy-DraGsMx6.js +2 -0
  39. package/dist/client/chunks/af-ZA-xDmO5F0s.js +1431 -0
  40. package/dist/client/chunks/af-ZA-xDmO5F0s.js.map +1 -0
  41. package/dist/client/chunks/{analysis-builder-C1CJ0c7L.js → analysis-builder-BeVZhiQ5.js} +1519 -1507
  42. package/dist/client/chunks/analysis-builder-BeVZhiQ5.js.map +1 -0
  43. package/dist/client/chunks/{analysis-builder-shared-rkjJfWLT.js → analysis-builder-shared-BWc7ZZnG.js} +925 -954
  44. package/dist/client/chunks/analysis-builder-shared-BWc7ZZnG.js.map +1 -0
  45. package/dist/client/chunks/chart-activity-grid-CWT0gLv4.js +2376 -0
  46. package/dist/client/chunks/chart-activity-grid-CWT0gLv4.js.map +1 -0
  47. package/dist/client/chunks/{chart-area-BwYaflNk.js → chart-area-D63kG8OT.js} +157 -157
  48. package/dist/client/chunks/chart-area-D63kG8OT.js.map +1 -0
  49. package/dist/client/chunks/{chart-bar-BiENfFgE.js → chart-bar-BEfsCLjl.js} +78 -78
  50. package/dist/client/chunks/chart-bar-BEfsCLjl.js.map +1 -0
  51. package/dist/client/chunks/{chart-box-plot-BJF1tBXC.js → chart-box-plot-o-h9MRX5.js} +111 -114
  52. package/dist/client/chunks/chart-box-plot-o-h9MRX5.js.map +1 -0
  53. package/dist/client/chunks/{chart-bubble-DQQhGVDJ.js → chart-bubble-CMDp4Pfm.js} +121 -121
  54. package/dist/client/chunks/chart-bubble-CMDp4Pfm.js.map +1 -0
  55. package/dist/client/chunks/chart-candlestick-WyANJ0Ky.js +303 -0
  56. package/dist/client/chunks/chart-candlestick-WyANJ0Ky.js.map +1 -0
  57. package/dist/client/chunks/chart-config-activity-grid-C-EkgYoa.js +51 -0
  58. package/dist/client/chunks/chart-config-activity-grid-C-EkgYoa.js.map +1 -0
  59. package/dist/client/chunks/chart-config-area-CMZpbIah.js +93 -0
  60. package/dist/client/chunks/chart-config-area-CMZpbIah.js.map +1 -0
  61. package/dist/client/chunks/chart-config-bar-B8_V4YLg.js +87 -0
  62. package/dist/client/chunks/chart-config-bar-B8_V4YLg.js.map +1 -0
  63. package/dist/client/chunks/chart-config-box-plot-Dwj7sEbU.js +35 -0
  64. package/dist/client/chunks/chart-config-box-plot-Dwj7sEbU.js.map +1 -0
  65. package/dist/client/chunks/chart-config-bubble-B0w0ZVp4.js +82 -0
  66. package/dist/client/chunks/chart-config-bubble-B0w0ZVp4.js.map +1 -0
  67. package/dist/client/chunks/chart-config-candlestick-Bvo3zeIn.js +72 -0
  68. package/dist/client/chunks/chart-config-candlestick-Bvo3zeIn.js.map +1 -0
  69. package/dist/client/chunks/{chart-config-data-table-Bhdx5Hem.js → chart-config-data-table-BQXSn4b_.js} +9 -9
  70. package/dist/client/chunks/chart-config-data-table-BQXSn4b_.js.map +1 -0
  71. package/dist/client/chunks/chart-config-funnel-BzEsHmjR.js +93 -0
  72. package/dist/client/chunks/chart-config-funnel-BzEsHmjR.js.map +1 -0
  73. package/dist/client/chunks/chart-config-gauge-C5ZiyZy7.js +64 -0
  74. package/dist/client/chunks/chart-config-gauge-C5ZiyZy7.js.map +1 -0
  75. package/dist/client/chunks/chart-config-heat-map-Cv8qNnVP.js +91 -0
  76. package/dist/client/chunks/chart-config-heat-map-Cv8qNnVP.js.map +1 -0
  77. package/dist/client/chunks/chart-config-kpi-delta-BraHQc2E.js +94 -0
  78. package/dist/client/chunks/chart-config-kpi-delta-BraHQc2E.js.map +1 -0
  79. package/dist/client/chunks/chart-config-kpi-number-CeCkx7mC.js +75 -0
  80. package/dist/client/chunks/chart-config-kpi-number-CeCkx7mC.js.map +1 -0
  81. package/dist/client/chunks/chart-config-kpi-text-CImM3SvH.js +47 -0
  82. package/dist/client/chunks/chart-config-kpi-text-CImM3SvH.js.map +1 -0
  83. package/dist/client/chunks/chart-config-line-BVKapAQK.js +104 -0
  84. package/dist/client/chunks/chart-config-line-BVKapAQK.js.map +1 -0
  85. package/dist/client/chunks/chart-config-markdown-C-_g_8te.js +117 -0
  86. package/dist/client/chunks/chart-config-markdown-C-_g_8te.js.map +1 -0
  87. package/dist/client/chunks/chart-config-measure-profile-KTVV1gO3.js +82 -0
  88. package/dist/client/chunks/chart-config-measure-profile-KTVV1gO3.js.map +1 -0
  89. package/dist/client/chunks/chart-config-pie-BZxVl25X.js +68 -0
  90. package/dist/client/chunks/chart-config-pie-BZxVl25X.js.map +1 -0
  91. package/dist/client/chunks/chart-config-radar-B7FByX3t.js +49 -0
  92. package/dist/client/chunks/chart-config-radar-B7FByX3t.js.map +1 -0
  93. package/dist/client/chunks/chart-config-radial-bar-UfW_3yyX.js +38 -0
  94. package/dist/client/chunks/chart-config-radial-bar-UfW_3yyX.js.map +1 -0
  95. package/dist/client/chunks/chart-config-sankey-DGAThN9i.js +66 -0
  96. package/dist/client/chunks/chart-config-sankey-DGAThN9i.js.map +1 -0
  97. package/dist/client/chunks/chart-config-scatter-BVVJuOnt.js +61 -0
  98. package/dist/client/chunks/chart-config-scatter-BVVJuOnt.js.map +1 -0
  99. package/dist/client/chunks/chart-config-sunburst-utejM2YS.js +45 -0
  100. package/dist/client/chunks/chart-config-sunburst-utejM2YS.js.map +1 -0
  101. package/dist/client/chunks/chart-config-tree-map-IHp97OyV.js +51 -0
  102. package/dist/client/chunks/chart-config-tree-map-IHp97OyV.js.map +1 -0
  103. package/dist/client/chunks/chart-config-waterfall-BdqG1V-x.js +59 -0
  104. package/dist/client/chunks/chart-config-waterfall-BdqG1V-x.js.map +1 -0
  105. package/dist/client/chunks/{chart-data-table-2iCsn0CF.js → chart-data-table-C3Xh9jwL.js} +1083 -1086
  106. package/dist/client/chunks/chart-data-table-C3Xh9jwL.js.map +1 -0
  107. package/dist/client/chunks/{chart-funnel-poyOf7-e.js → chart-funnel-C7pgktN5.js} +132 -132
  108. package/dist/client/chunks/chart-funnel-C7pgktN5.js.map +1 -0
  109. package/dist/client/chunks/{chart-gauge-D5J4gRky.js → chart-gauge-D2r2B_AR.js} +150 -150
  110. package/dist/client/chunks/chart-gauge-D2r2B_AR.js.map +1 -0
  111. package/dist/client/chunks/{chart-heat-map-BAMVhLGG.js → chart-heat-map-Dw2yjwfO.js} +75 -80
  112. package/dist/client/chunks/chart-heat-map-Dw2yjwfO.js.map +1 -0
  113. package/dist/client/chunks/{chart-kpi-delta-KQjUIeal.js → chart-kpi-delta-CYE0S1x_.js} +117 -117
  114. package/dist/client/chunks/chart-kpi-delta-CYE0S1x_.js.map +1 -0
  115. package/dist/client/chunks/chart-kpi-number-BlZ79xHW.js +321 -0
  116. package/dist/client/chunks/chart-kpi-number-BlZ79xHW.js.map +1 -0
  117. package/dist/client/chunks/chart-kpi-text-DY1BnxPe.js +148 -0
  118. package/dist/client/chunks/chart-kpi-text-DY1BnxPe.js.map +1 -0
  119. package/dist/client/chunks/{chart-line-B5_WntY5.js → chart-line-CBsTThTv.js} +123 -123
  120. package/dist/client/chunks/chart-line-CBsTThTv.js.map +1 -0
  121. package/dist/client/chunks/chart-markdown-BWaWVkuz.js +3474 -0
  122. package/dist/client/chunks/chart-markdown-BWaWVkuz.js.map +1 -0
  123. package/dist/client/chunks/chart-measure-profile-B41qCTBG.js +179 -0
  124. package/dist/client/chunks/chart-measure-profile-B41qCTBG.js.map +1 -0
  125. package/dist/client/chunks/chart-pie-Djbu8x2v.js +172 -0
  126. package/dist/client/chunks/chart-pie-Djbu8x2v.js.map +1 -0
  127. package/dist/client/chunks/chart-radar-BsTcKV0K.js +154 -0
  128. package/dist/client/chunks/chart-radar-BsTcKV0K.js.map +1 -0
  129. package/dist/client/chunks/chart-radial-bar-Du7XNnwE.js +148 -0
  130. package/dist/client/chunks/chart-radial-bar-Du7XNnwE.js.map +1 -0
  131. package/dist/client/chunks/{chart-sankey-BOyxfG1Q.js → chart-sankey-WwkZAhLy.js} +73 -73
  132. package/dist/client/chunks/chart-sankey-WwkZAhLy.js.map +1 -0
  133. package/dist/client/chunks/chart-scatter-D8krEYsA.js +255 -0
  134. package/dist/client/chunks/chart-scatter-D8krEYsA.js.map +1 -0
  135. package/dist/client/chunks/{chart-sunburst-D9lGEOCc.js → chart-sunburst-CIDB_pTl.js} +66 -66
  136. package/dist/client/chunks/chart-sunburst-CIDB_pTl.js.map +1 -0
  137. package/dist/client/chunks/chart-tree-map-C5C2iaWM.js +298 -0
  138. package/dist/client/chunks/chart-tree-map-C5C2iaWM.js.map +1 -0
  139. package/dist/client/chunks/{chart-waterfall-BCdUx4DC.js → chart-waterfall-BGdPrJ5Y.js} +80 -80
  140. package/dist/client/chunks/chart-waterfall-BGdPrJ5Y.js.map +1 -0
  141. package/dist/client/chunks/{charts-core-C5Yokk-x.js → charts-core-BXOqaYFn.js} +92 -92
  142. package/dist/client/chunks/charts-core-BXOqaYFn.js.map +1 -0
  143. package/dist/client/chunks/en-US-5xPTdCXg.js +35 -0
  144. package/dist/client/chunks/en-US-5xPTdCXg.js.map +1 -0
  145. package/dist/client/chunks/nl-NL-vCifBijs.js +1491 -0
  146. package/dist/client/chunks/nl-NL-vCifBijs.js.map +1 -0
  147. package/dist/client/chunks/{schema-visualization-t1KiOORo.js → schema-visualization-Xp60Ff2W.js} +352 -364
  148. package/dist/client/chunks/schema-visualization-Xp60Ff2W.js.map +1 -0
  149. package/dist/client/chunks/{useDebounce-CKqkM42n.js → useDebounce-CfmUMFau.js} +85 -85
  150. package/dist/client/chunks/useDebounce-CfmUMFau.js.map +1 -0
  151. package/dist/client/chunks/{useExplainAI-DBIfYwz-.js → useExplainAI-BKGmejIj.js} +4 -4
  152. package/dist/client/chunks/{useExplainAI-DBIfYwz-.js.map → useExplainAI-BKGmejIj.js.map} +1 -1
  153. package/dist/client/chunks/{utils--qCr8Yn5.js → utils-BldkcRHv.js} +2 -2
  154. package/dist/client/chunks/{utils--qCr8Yn5.js.map → utils-BldkcRHv.js.map} +1 -1
  155. package/dist/client/chunks/{vendor-BRlsCGnK.js → vendor-ClXpIiea.js} +2 -2
  156. package/dist/client/chunks/{vendor-BRlsCGnK.js.map → vendor-ClXpIiea.js.map} +1 -1
  157. package/dist/client/components/AnalysisBuilder/types.d.ts +6 -6
  158. package/dist/client/components.js +3 -3
  159. package/dist/client/hooks/useTranslation.d.ts +21 -0
  160. package/dist/client/hooks.js +3 -3
  161. package/dist/client/icons.js +1 -1
  162. package/dist/client/index.js +493 -488
  163. package/dist/client/index.js.map +1 -1
  164. package/dist/client/providers/CubeApiProvider.d.ts +2 -1
  165. package/dist/client/providers/CubeProvider.d.ts +7 -1
  166. package/dist/client/providers/I18nProvider.d.ts +18 -0
  167. package/dist/client/providers.js +1 -1
  168. package/dist/client/schema.js +1 -1
  169. package/dist/client/shared/types.d.ts +5 -20
  170. package/dist/client/styles.css +1 -1
  171. package/dist/client/utils.js +5 -5
  172. package/dist/client-bundle-stats.html +1 -1
  173. package/dist/mcp-app/mcp-app.html +40 -36
  174. package/dist/server/index.cjs +42 -40
  175. package/dist/server/index.js +3311 -1672
  176. package/package.json +5 -2
  177. package/dist/adapters/compiler-CRgLzmSn.cjs +0 -198
  178. package/dist/adapters/handler-DumFgnNM.cjs +0 -25
  179. package/dist/adapters/mcp-transport-C6bsIOSV.js +0 -545
  180. package/dist/adapters/mcp-transport-DMhuYmFp.cjs +0 -39
  181. package/dist/adapters/utils-CyBt-as9.cjs +0 -15
  182. package/dist/client/chunks/DashboardEditModal-BTdV528l.js.map +0 -1
  183. package/dist/client/chunks/FieldSearchModal-D75vy4Wb.js.map +0 -1
  184. package/dist/client/chunks/KpiDelta-Bk8bzKYM.js +0 -2
  185. package/dist/client/chunks/KpiNumber-CKF-8e_T.js +0 -2
  186. package/dist/client/chunks/KpiText-Iz1vIvu_.js +0 -2
  187. package/dist/client/chunks/RetentionCombinedChart-DIhK5pD8.js.map +0 -1
  188. package/dist/client/chunks/RetentionHeatmap-CyREolyP.js.map +0 -1
  189. package/dist/client/chunks/SchemaVisualization-B1GUT-FM.js +0 -2
  190. package/dist/client/chunks/SchemaVisualizationLazy-DymwT34e.js +0 -2
  191. package/dist/client/chunks/analysis-builder-C1CJ0c7L.js.map +0 -1
  192. package/dist/client/chunks/analysis-builder-shared-rkjJfWLT.js.map +0 -1
  193. package/dist/client/chunks/chart-activity-grid-DLktOINm.js +0 -806
  194. package/dist/client/chunks/chart-activity-grid-DLktOINm.js.map +0 -1
  195. package/dist/client/chunks/chart-area-BwYaflNk.js.map +0 -1
  196. package/dist/client/chunks/chart-bar-BiENfFgE.js.map +0 -1
  197. package/dist/client/chunks/chart-box-plot-BJF1tBXC.js.map +0 -1
  198. package/dist/client/chunks/chart-bubble-DQQhGVDJ.js.map +0 -1
  199. package/dist/client/chunks/chart-candlestick-C2UuXbLe.js +0 -306
  200. package/dist/client/chunks/chart-candlestick-C2UuXbLe.js.map +0 -1
  201. package/dist/client/chunks/chart-config-activity-grid-DJOU3TEz.js +0 -51
  202. package/dist/client/chunks/chart-config-activity-grid-DJOU3TEz.js.map +0 -1
  203. package/dist/client/chunks/chart-config-area-CWnWVT6a.js +0 -93
  204. package/dist/client/chunks/chart-config-area-CWnWVT6a.js.map +0 -1
  205. package/dist/client/chunks/chart-config-bar-C-7Dr1Ho.js +0 -87
  206. package/dist/client/chunks/chart-config-bar-C-7Dr1Ho.js.map +0 -1
  207. package/dist/client/chunks/chart-config-box-plot-mVOwmLdu.js +0 -35
  208. package/dist/client/chunks/chart-config-box-plot-mVOwmLdu.js.map +0 -1
  209. package/dist/client/chunks/chart-config-bubble-BPE2CeiD.js +0 -82
  210. package/dist/client/chunks/chart-config-bubble-BPE2CeiD.js.map +0 -1
  211. package/dist/client/chunks/chart-config-candlestick-BSB9DRy2.js +0 -72
  212. package/dist/client/chunks/chart-config-candlestick-BSB9DRy2.js.map +0 -1
  213. package/dist/client/chunks/chart-config-data-table-Bhdx5Hem.js.map +0 -1
  214. package/dist/client/chunks/chart-config-funnel-Cl-v-bm1.js +0 -93
  215. package/dist/client/chunks/chart-config-funnel-Cl-v-bm1.js.map +0 -1
  216. package/dist/client/chunks/chart-config-gauge-CdrUTJMJ.js +0 -64
  217. package/dist/client/chunks/chart-config-gauge-CdrUTJMJ.js.map +0 -1
  218. package/dist/client/chunks/chart-config-heat-map-DGE3NzoF.js +0 -91
  219. package/dist/client/chunks/chart-config-heat-map-DGE3NzoF.js.map +0 -1
  220. package/dist/client/chunks/chart-config-kpi-delta-DMrQerUW.js +0 -94
  221. package/dist/client/chunks/chart-config-kpi-delta-DMrQerUW.js.map +0 -1
  222. package/dist/client/chunks/chart-config-kpi-number-DCytCytn.js +0 -75
  223. package/dist/client/chunks/chart-config-kpi-number-DCytCytn.js.map +0 -1
  224. package/dist/client/chunks/chart-config-kpi-text-KdKQUvHo.js +0 -47
  225. package/dist/client/chunks/chart-config-kpi-text-KdKQUvHo.js.map +0 -1
  226. package/dist/client/chunks/chart-config-line-Bl9VDAdz.js +0 -104
  227. package/dist/client/chunks/chart-config-line-Bl9VDAdz.js.map +0 -1
  228. package/dist/client/chunks/chart-config-markdown-BX26b94i.js +0 -117
  229. package/dist/client/chunks/chart-config-markdown-BX26b94i.js.map +0 -1
  230. package/dist/client/chunks/chart-config-measure-profile-DwtRhEFh.js +0 -82
  231. package/dist/client/chunks/chart-config-measure-profile-DwtRhEFh.js.map +0 -1
  232. package/dist/client/chunks/chart-config-pie-BzBcqPMJ.js +0 -68
  233. package/dist/client/chunks/chart-config-pie-BzBcqPMJ.js.map +0 -1
  234. package/dist/client/chunks/chart-config-radar-6ZOgt__z.js +0 -49
  235. package/dist/client/chunks/chart-config-radar-6ZOgt__z.js.map +0 -1
  236. package/dist/client/chunks/chart-config-radial-bar-Df6Eta7N.js +0 -38
  237. package/dist/client/chunks/chart-config-radial-bar-Df6Eta7N.js.map +0 -1
  238. package/dist/client/chunks/chart-config-sankey-DgqKBFvN.js +0 -66
  239. package/dist/client/chunks/chart-config-sankey-DgqKBFvN.js.map +0 -1
  240. package/dist/client/chunks/chart-config-scatter-D5nVLDvi.js +0 -61
  241. package/dist/client/chunks/chart-config-scatter-D5nVLDvi.js.map +0 -1
  242. package/dist/client/chunks/chart-config-sunburst-Ca3FX9nW.js +0 -45
  243. package/dist/client/chunks/chart-config-sunburst-Ca3FX9nW.js.map +0 -1
  244. package/dist/client/chunks/chart-config-tree-map-Bjy4QNa3.js +0 -51
  245. package/dist/client/chunks/chart-config-tree-map-Bjy4QNa3.js.map +0 -1
  246. package/dist/client/chunks/chart-config-waterfall-C5K2eqR7.js +0 -59
  247. package/dist/client/chunks/chart-config-waterfall-C5K2eqR7.js.map +0 -1
  248. package/dist/client/chunks/chart-data-table-2iCsn0CF.js.map +0 -1
  249. package/dist/client/chunks/chart-funnel-poyOf7-e.js.map +0 -1
  250. package/dist/client/chunks/chart-gauge-D5J4gRky.js.map +0 -1
  251. package/dist/client/chunks/chart-heat-map-BAMVhLGG.js.map +0 -1
  252. package/dist/client/chunks/chart-kpi-delta-KQjUIeal.js.map +0 -1
  253. package/dist/client/chunks/chart-kpi-number-CsQgV_x3.js +0 -325
  254. package/dist/client/chunks/chart-kpi-number-CsQgV_x3.js.map +0 -1
  255. package/dist/client/chunks/chart-kpi-text-BR0IyeUU.js +0 -148
  256. package/dist/client/chunks/chart-kpi-text-BR0IyeUU.js.map +0 -1
  257. package/dist/client/chunks/chart-line-B5_WntY5.js.map +0 -1
  258. package/dist/client/chunks/chart-markdown-B6bENbel.js +0 -3473
  259. package/dist/client/chunks/chart-markdown-B6bENbel.js.map +0 -1
  260. package/dist/client/chunks/chart-measure-profile-yWk-obNb.js +0 -179
  261. package/dist/client/chunks/chart-measure-profile-yWk-obNb.js.map +0 -1
  262. package/dist/client/chunks/chart-pie-BodrUoHv.js +0 -172
  263. package/dist/client/chunks/chart-pie-BodrUoHv.js.map +0 -1
  264. package/dist/client/chunks/chart-radar-gG3zfLud.js +0 -154
  265. package/dist/client/chunks/chart-radar-gG3zfLud.js.map +0 -1
  266. package/dist/client/chunks/chart-radial-bar-C2IPCV8c.js +0 -148
  267. package/dist/client/chunks/chart-radial-bar-C2IPCV8c.js.map +0 -1
  268. package/dist/client/chunks/chart-sankey-BOyxfG1Q.js.map +0 -1
  269. package/dist/client/chunks/chart-scatter-B8OwlsAX.js +0 -255
  270. package/dist/client/chunks/chart-scatter-B8OwlsAX.js.map +0 -1
  271. package/dist/client/chunks/chart-sunburst-D9lGEOCc.js.map +0 -1
  272. package/dist/client/chunks/chart-tree-map-DZaKy9he.js +0 -298
  273. package/dist/client/chunks/chart-tree-map-DZaKy9he.js.map +0 -1
  274. package/dist/client/chunks/chart-waterfall-BCdUx4DC.js.map +0 -1
  275. package/dist/client/chunks/charts-core-C5Yokk-x.js.map +0 -1
  276. package/dist/client/chunks/schema-visualization-t1KiOORo.js.map +0 -1
  277. package/dist/client/chunks/useDebounce-CKqkM42n.js.map +0 -1
@@ -1,3 +1,3 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../utils-CyBt-as9.cjs`),t=require(`../compiler-CRgLzmSn.cjs`),n=require(`../mcp-transport-DMhuYmFp.cjs`);let r=require(`express`);r=e._(r);let i=require(`cors`);i=e._(i);function a(a){let{cubes:o,drizzle:s,schema:c,extractSecurityContext:l,engineType:u,cors:d,basePath:f=`/cubejs-api/v1`,jsonLimit:p=`10mb`,cache:m,mcp:h={enabled:!0},agent:g}=a;if(!o||o.length===0)throw Error(`At least one cube must be provided in the cubes array`);let _=(0,r.Router)();d&&_.use((0,i.default)(d)),_.use(r.default.json({limit:p})),_.use(r.default.urlencoded({extended:!0,limit:p}));let v=new t.t({drizzle:s,schema:c,engineType:u,cache:m,rlsSetup:a.rlsSetup});if(o.forEach(e=>{v.registerCube(e)}),_.post(`${f}/load`,async(t,n)=>{try{let r=t.body.query||t.body,i=await l(t,n),a=v.validateQuery(r);if(!a.isValid)return n.status(400).json(e.i(`Query validation failed: ${a.errors.join(`, `)}`,400));let o=t.headers[`x-cache-control`]===`no-cache`,s=await v.executeMultiCubeQuery(r,i,{skipCache:o});n.json(e.r(r,s,v))}catch(t){console.error(`Query execution error:`,t),n.status(500).json(e.i(t instanceof Error?t.message:`Query execution failed`,500))}}),_.get(`${f}/load`,async(t,n)=>{try{let r=t.query.query;if(!r)return n.status(400).json(e.i(`Query parameter is required`,400));let i;try{i=JSON.parse(r)}catch{return n.status(400).json(e.i(`Invalid JSON in query parameter`,400))}let a=await l(t,n),o=v.validateQuery(i);if(!o.isValid)return n.status(400).json(e.i(`Query validation failed: ${o.errors.join(`, `)}`,400));let s=t.headers[`x-cache-control`]===`no-cache`,c=await v.executeMultiCubeQuery(i,a,{skipCache:s});n.json(e.r(i,c,v))}catch(t){console.error(`Query execution error:`,t),n.status(500).json(e.i(t instanceof Error?t.message:`Query execution failed`,500))}}),_.post(`${f}/batch`,async(t,n)=>{try{let{queries:r}=t.body;if(!r||!Array.isArray(r))return n.status(400).json(e.i(`Request body must contain a "queries" array`,400));if(r.length===0)return n.status(400).json(e.i(`Queries array cannot be empty`,400));let i=await e.u(r,await l(t,n),v,{skipCache:t.headers[`x-cache-control`]===`no-cache`});n.json(i)}catch(t){console.error(`Batch execution error:`,t),n.status(500).json(e.i(t instanceof Error?t.message:`Batch execution failed`,500))}}),_.get(`${f}/meta`,(t,n)=>{try{let t=v.getMetadata();n.json(e.a(t))}catch(t){console.error(`Metadata error:`,t),n.status(500).json(e.i(t instanceof Error?t.message:`Failed to fetch metadata`,500))}}),_.post(`${f}/sql`,async(t,n)=>{try{let r=t.body,i=await l(t,n),a=v.validateQuery(r);if(!a.isValid)return n.status(400).json(e.i(`Query validation failed: ${a.errors.join(`, `)}`,400));let o=r.measures?.[0]||r.dimensions?.[0];if(!o)return n.status(400).json(e.i(`No measures or dimensions specified`,400));let s=o.split(`.`)[0],c=await v.generateSQL(s,r,i);n.json(e.o(r,c))}catch(t){console.error(`SQL generation error:`,String(t).replace(/\n|\r/g,``)),n.status(500).json(e.i(t instanceof Error?t.message:`SQL generation failed`,500))}}),_.get(`${f}/sql`,async(t,n)=>{try{let r=t.query.query;if(!r)return n.status(400).json(e.i(`Query parameter is required`,400));let i=JSON.parse(r),a=await l(t,n),o=v.validateQuery(i);if(!o.isValid)return n.status(400).json(e.i(`Query validation failed: ${o.errors.join(`, `)}`,400));let s=i.measures?.[0]||i.dimensions?.[0];if(!s)return n.status(400).json(e.i(`No measures or dimensions specified`,400));let c=s.split(`.`)[0],u=await v.generateSQL(c,i,a);n.json(e.o(i,u))}catch(t){console.error(`SQL generation error:`,String(t).replace(/\n|\r/g,``)),n.status(500).json(e.i(t instanceof Error?t.message:`SQL generation failed`,500))}}),_.post(`${f}/dry-run`,async(t,n)=>{try{let r=await e.f(t.body.query||t.body,await l(t,n),v);n.json(r)}catch(e){console.error(`Dry-run error:`,e),n.status(400).json({error:e instanceof Error?e.message:`Dry-run validation failed`,valid:!1})}}),_.get(`${f}/dry-run`,async(t,n)=>{try{let r=t.query.query;if(!r)return n.status(400).json({error:`Query parameter is required`,valid:!1});let i=await e.f(JSON.parse(r),await l(t,n),v);n.json(i)}catch(e){console.error(`Dry-run error:`,e),n.status(400).json({error:e instanceof Error?e.message:`Dry-run validation failed`,valid:!1})}}),_.post(`${f}/explain`,async(e,t)=>{try{let n=e.body.query||e.body,r=e.body.options||{},i=await l(e,t),a=v.validateQuery(n);if(!a.isValid)return t.status(400).json({error:`Query validation failed: ${a.errors.join(`, `)}`});let o=await v.explainQuery(n,i,r);t.json(o)}catch(e){console.error(`Explain error:`,e),t.status(500).json({error:e instanceof Error?e.message:`Explain query failed`})}}),g&&_.post(`${f}/agent/chat`,async(e,t)=>{try{let{handleAgentChat:n}=await Promise.resolve().then(()=>require(`../handler-DumFgnNM.cjs`)),{message:r,sessionId:i,history:a}=e.body;if(!r||typeof r!=`string`)return t.status(400).json({error:`message is required and must be a string`});let o=(g.apiKey||``).trim();if(g.allowClientApiKey){let t=e.headers[`x-agent-api-key`];t&&(o=t.trim())}if(!o)return t.status(401).json({error:`No API key configured. Set agent.apiKey in server config or send X-Agent-Api-Key header.`});let s=g.allowClientApiKey?e.headers[`x-agent-provider`]:void 0,c=g.allowClientApiKey?e.headers[`x-agent-model`]:void 0,u=g.allowClientApiKey?e.headers[`x-agent-provider-endpoint`]:void 0,d=await l(e,t),f=g.buildSystemContext?.(d);t.writeHead(200,{"Content-Type":`text/event-stream`,"Cache-Control":`no-cache`,Connection:`keep-alive`});try{let e=n({message:r,sessionId:i,history:a,semanticLayer:v,securityContext:d,agentConfig:g,apiKey:o,systemContext:f,providerOverride:s,modelOverride:c,baseURLOverride:u});for await(let n of e)t.write(`data: ${JSON.stringify(n)}\n\n`)}catch(e){let n={type:`error`,data:{message:e instanceof Error?e.message:`Stream failed`}};t.write(`data: ${JSON.stringify(n)}\n\n`)}finally{t.end()}}catch(e){console.error(`Agent chat error:`,e),t.headersSent||t.status(500).json({error:e instanceof Error?e.message:`Agent chat failed`})}}),h.enabled!==!1){let e=h.basePath??`/mcp`;_.post(`${e}`,async(e,t)=>{let r=n._(e.headers.origin,h.allowedOrigins?{allowedOrigins:h.allowedOrigins}:{});if(!r.valid)return t.status(403).json(n.i(null,-32600,r.reason));let i=e.headers.accept;if(!n.g(i))return t.status(400).json(n.i(null,-32600,`Accept header must include both application/json and text/event-stream`));let a=n.f(e.headers);if(!a.ok)return t.status(426).json({error:`Unsupported MCP protocol version`,supported:a.supported});let o=n.p(e.body);if(!o)return t.status(400).json(n.i(null,-32600,`Invalid JSON-RPC 2.0 request`));let s=n.v(i),c=o.method===`initialize`;try{let r=await n.s(o.method,o.params,{semanticLayer:v,extractSecurityContext:l,rawRequest:e,rawResponse:t,negotiatedProtocol:a.negotiated,appEnabled:!!h.app});if(n.d(o))return t.status(202).end();let i=c&&r&&typeof r==`object`&&`sessionId`in r?r.sessionId:void 0;i&&t.setHeader(n.r,i);let u=n.a(o.id??null,r);if(s){let e=n.m();return t.status(200),t.setHeader(`Content-Type`,`text/event-stream`),t.setHeader(`Cache-Control`,`no-cache`),t.setHeader(`Connection`,`keep-alive`),t.write(`id: ${e}\n\n`),t.write(n.h(u,e)),t.end()}return t.json(u)}catch(e){if(n.d(o))return console.error(`MCP notification processing error:`,String(e).replace(/\n|\r/g,``)),t.status(202).end();console.error(`MCP RPC error:`,String(e).replace(/\n|\r/g,``));let r=e?.code??-32603,i=e?.data,a=e.message||`MCP request failed`,c=n.i(o.id??null,r,a,i);if(s){let e=n.m();return t.status(200),t.setHeader(`Content-Type`,`text/event-stream`),t.setHeader(`Cache-Control`,`no-cache`),t.setHeader(`Connection`,`keep-alive`),t.write(`id: ${e}\n\n`),t.write(n.h(c,e)),t.end()}return t.status(200).json(c)}}),_.get(`${e}`,async(e,t)=>{let r=n.m();t.status(200),t.setHeader(`Content-Type`,`text/event-stream`),t.setHeader(`Cache-Control`,`no-cache`),t.setHeader(`Connection`,`keep-alive`),t.write(n.h({jsonrpc:`2.0`,method:`mcp/ready`,params:{protocol:`streamable-http`}},r,15e3));let i=setInterval(()=>{t.write(`: keep-alive
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../utils-DNrj-ryp.cjs`),t=require(`../locale-DueXjqMh.cjs`),n=require(`../mcp-transport-poPHl_2j.cjs`);let r=require(`express`);r=e.v(r);let i=require(`cors`);i=e.v(i);function a(a){let{cubes:o,drizzle:s,schema:c,extractSecurityContext:l,engineType:u,cors:d,basePath:f=`/cubejs-api/v1`,jsonLimit:p=`10mb`,cache:m,mcp:h={enabled:!0},agent:g}=a;if(!o||o.length===0)throw Error(`At least one cube must be provided in the cubes array`);let _=(0,r.Router)(),v=async(e,n)=>t.r(await l(e,n),t.n(t=>e.get(t)));if(d){let e={...d,allowedHeaders:t.t(d.allowedHeaders)};_.use((0,i.default)(e))}_.use(r.default.json({limit:p})),_.use(r.default.urlencoded({extended:!0,limit:p}));let y=new t.i({drizzle:s,schema:c,engineType:u,cache:m,rlsSetup:a.rlsSetup});if(o.forEach(e=>{y.registerCube(e)}),_.post(`${f}/load`,async(t,n)=>{try{let r=t.body.query||t.body,i=await v(t,n),a=y.validateQuery(r);if(!a.isValid)return n.status(400).json(e.i(`Query validation failed: ${a.errors.join(`, `)}`,400));let o=t.headers[`x-cache-control`]===`no-cache`,s=await y.executeMultiCubeQuery(r,i,{skipCache:o});n.json(e.r(r,s,y))}catch(t){console.error(`Query execution error:`,t),n.status(500).json(e.i(t instanceof Error?t.message:`Query execution failed`,500))}}),_.get(`${f}/load`,async(t,n)=>{try{let r=t.query.query;if(!r)return n.status(400).json(e.i(`Query parameter is required`,400));let i;try{i=JSON.parse(r)}catch{return n.status(400).json(e.i(`Invalid JSON in query parameter`,400))}let a=await v(t,n),o=y.validateQuery(i);if(!o.isValid)return n.status(400).json(e.i(`Query validation failed: ${o.errors.join(`, `)}`,400));let s=t.headers[`x-cache-control`]===`no-cache`,c=await y.executeMultiCubeQuery(i,a,{skipCache:s});n.json(e.r(i,c,y))}catch(t){console.error(`Query execution error:`,t),n.status(500).json(e.i(t instanceof Error?t.message:`Query execution failed`,500))}}),_.post(`${f}/batch`,async(t,n)=>{try{let{queries:r}=t.body;if(!r||!Array.isArray(r))return n.status(400).json(e.i(`Request body must contain a "queries" array`,400));if(r.length===0)return n.status(400).json(e.i(`Queries array cannot be empty`,400));let i=await e.u(r,await v(t,n),y,{skipCache:t.headers[`x-cache-control`]===`no-cache`});n.json(i)}catch(t){console.error(`Batch execution error:`,t),n.status(500).json(e.i(t instanceof Error?t.message:`Batch execution failed`,500))}}),_.get(`${f}/meta`,(t,n)=>{try{let t=y.getMetadata();n.json(e.a(t))}catch(t){console.error(`Metadata error:`,t),n.status(500).json(e.i(t instanceof Error?t.message:`Failed to fetch metadata`,500))}}),_.post(`${f}/sql`,async(t,n)=>{try{let r=t.body,i=await v(t,n),a=y.validateQuery(r);if(!a.isValid)return n.status(400).json(e.i(`Query validation failed: ${a.errors.join(`, `)}`,400));let o=r.measures?.[0]||r.dimensions?.[0];if(!o)return n.status(400).json(e.i(`No measures or dimensions specified`,400));let s=o.split(`.`)[0],c=await y.generateSQL(s,r,i);n.json(e.o(r,c))}catch(t){console.error(`SQL generation error:`,String(t).replace(/\n|\r/g,``)),n.status(500).json(e.i(t instanceof Error?t.message:`SQL generation failed`,500))}}),_.get(`${f}/sql`,async(t,n)=>{try{let r=t.query.query;if(!r)return n.status(400).json(e.i(`Query parameter is required`,400));let i=JSON.parse(r),a=await v(t,n),o=y.validateQuery(i);if(!o.isValid)return n.status(400).json(e.i(`Query validation failed: ${o.errors.join(`, `)}`,400));let s=i.measures?.[0]||i.dimensions?.[0];if(!s)return n.status(400).json(e.i(`No measures or dimensions specified`,400));let c=s.split(`.`)[0],l=await y.generateSQL(c,i,a);n.json(e.o(i,l))}catch(t){console.error(`SQL generation error:`,String(t).replace(/\n|\r/g,``)),n.status(500).json(e.i(t instanceof Error?t.message:`SQL generation failed`,500))}}),_.post(`${f}/dry-run`,async(t,n)=>{try{let r=await e.f(t.body.query||t.body,await v(t,n),y);n.json(r)}catch(e){console.error(`Dry-run error:`,e),n.status(400).json({error:e instanceof Error?e.message:`Dry-run validation failed`,valid:!1})}}),_.get(`${f}/dry-run`,async(t,n)=>{try{let r=t.query.query;if(!r)return n.status(400).json({error:`Query parameter is required`,valid:!1});let i=await e.f(JSON.parse(r),await v(t,n),y);n.json(i)}catch(e){console.error(`Dry-run error:`,e),n.status(400).json({error:e instanceof Error?e.message:`Dry-run validation failed`,valid:!1})}}),_.post(`${f}/explain`,async(e,t)=>{try{let n=e.body.query||e.body,r=e.body.options||{},i=await v(e,t),a=y.validateQuery(n);if(!a.isValid)return t.status(400).json({error:`Query validation failed: ${a.errors.join(`, `)}`});let o=await y.explainQuery(n,i,r);t.json(o)}catch(e){console.error(`Explain error:`,e),t.status(500).json({error:e instanceof Error?e.message:`Explain query failed`})}}),g&&_.post(`${f}/agent/chat`,async(e,t)=>{try{let{handleAgentChat:n}=await Promise.resolve().then(()=>require(`../handler-BzzbVpcl.cjs`)),{message:r,sessionId:i,history:a}=e.body;if(!r||typeof r!=`string`)return t.status(400).json({error:`message is required and must be a string`});let o=(g.apiKey||``).trim();if(g.allowClientApiKey){let t=e.headers[`x-agent-api-key`];t&&(o=t.trim())}if(!o)return t.status(401).json({error:`No API key configured. Set agent.apiKey in server config or send X-Agent-Api-Key header.`});let s=g.allowClientApiKey?e.headers[`x-agent-provider`]:void 0,c=g.allowClientApiKey?e.headers[`x-agent-model`]:void 0,l=g.allowClientApiKey?e.headers[`x-agent-provider-endpoint`]:void 0,u=await v(e,t),d=g.buildSystemContext?.(u);t.writeHead(200,{"Content-Type":`text/event-stream`,"Cache-Control":`no-cache`,Connection:`keep-alive`});try{let e=n({message:r,sessionId:i,history:a,semanticLayer:y,securityContext:u,agentConfig:g,apiKey:o,systemContext:d,providerOverride:s,modelOverride:c,baseURLOverride:l});for await(let n of e)t.write(`data: ${JSON.stringify(n)}\n\n`)}catch(e){let n={type:`error`,data:{message:e instanceof Error?e.message:`Stream failed`}};t.write(`data: ${JSON.stringify(n)}\n\n`)}finally{t.end()}}catch(e){console.error(`Agent chat error:`,e),t.headersSent||t.status(500).json({error:e instanceof Error?e.message:`Agent chat failed`})}}),h.enabled!==!1){let e=n.o(y,h.resources),t=n.v(h.prompts),r=h.basePath??`/mcp`;_.post(`${r}`,async(r,i)=>{if(h.resourceMetadataUrl&&!n.u(r.headers.authorization))return i.setHeader(`WWW-Authenticate`,n.c(h.resourceMetadataUrl)),i.status(401).json({error:`Bearer token required`});let a=n.x(r.headers.origin,h.allowedOrigins?{allowedOrigins:h.allowedOrigins}:{});if(!a.valid)return i.status(403).json(n.i(null,-32600,a.reason));let o=r.headers.accept;if(!n.b(o))return i.status(400).json(n.i(null,-32600,`Accept header must include both application/json and text/event-stream`));let s=n.h(r.headers);if(!s.ok)return i.status(426).json({error:`Unsupported MCP protocol version`,supported:s.supported});let c=n.g(r.body);if(!c)return i.status(400).json(n.i(null,-32600,`Invalid JSON-RPC 2.0 request`));let l=n.S(o),u=c.method===`initialize`;try{let a=await n.l(c.method,c.params,{semanticLayer:y,extractSecurityContext:(e,t)=>v(e,t),rawRequest:r,rawResponse:i,negotiatedProtocol:s.negotiated,resources:e,prompts:t,appEnabled:!!h.app,appConfig:typeof h.app==`object`?h.app:void 0,serverName:h.serverName});if(n.m(c))return i.status(202).end();let o=u&&a&&typeof a==`object`&&`sessionId`in a?a.sessionId:void 0;o&&i.setHeader(n.r,o);let d=n.a(c.id??null,a);if(l){let e=n._();return i.status(200),i.setHeader(`Content-Type`,`text/event-stream`),i.setHeader(`Cache-Control`,`no-cache`),i.setHeader(`Connection`,`keep-alive`),i.write(`id: ${e}\n\n`),i.write(n.y(d,e)),i.end()}return i.json(d)}catch(e){if(n.m(c))return console.error(`MCP notification processing error:`,String(e).replace(/\n|\r/g,``)),i.status(202).end();console.error(`MCP RPC error:`,String(e).replace(/\n|\r/g,``));let t=e?.code??-32603,r=e?.data,a=e.message||`MCP request failed`,o=n.i(c.id??null,t,a,r);if(l){let e=n._();return i.status(200),i.setHeader(`Content-Type`,`text/event-stream`),i.setHeader(`Cache-Control`,`no-cache`),i.setHeader(`Connection`,`keep-alive`),i.write(`id: ${e}\n\n`),i.write(n.y(o,e)),i.end()}return i.status(200).json(o)}}),_.get(`${r}`,async(e,t)=>{if(h.resourceMetadataUrl&&!n.u(e.headers.authorization))return t.setHeader(`WWW-Authenticate`,n.c(h.resourceMetadataUrl)),t.status(401).json({error:`Bearer token required`});let r=n._();t.status(200),t.setHeader(`Content-Type`,`text/event-stream`),t.setHeader(`Cache-Control`,`no-cache`),t.setHeader(`Connection`,`keep-alive`),t.write(n.y({jsonrpc:`2.0`,method:`mcp/ready`,params:{protocol:`streamable-http`}},r,15e3));let i=setInterval(()=>{t.write(`: keep-alive
2
2
 
3
- `)},15e3);e.on(`close`,()=>{clearInterval(i)})}),_.delete(`${e}`,(e,t)=>t.status(405).json({error:`Session termination not supported`}))}return _.use((t,n,r,i)=>{console.error(`Express adapter error:`,t),r.headersSent||r.status(500).json(e.i(t,500))}),_}function o(e,t){let n=a(t);return e.use(`/`,n),e}function s(e){return o((0,r.default)(),e)}exports.createCubeApp=s,exports.createCubeRouter=a,exports.mountCubeRoutes=o;
3
+ `)},15e3);e.on(`close`,()=>{clearInterval(i)})}),_.delete(`${r}`,(e,t)=>h.resourceMetadataUrl&&!n.u(e.headers.authorization)?(t.setHeader(`WWW-Authenticate`,n.c(h.resourceMetadataUrl)),t.status(401).json({error:`Bearer token required`})):t.status(405).json({error:`Session termination not supported`}))}return _.use((t,n,r,i)=>{console.error(`Express adapter error:`,t),r.headersSent||r.status(500).json(e.i(t,500))}),_}function o(e,t){let n=a(t);return e.use(`/`,n),e}function s(e){return o((0,r.default)(),e)}exports.createCubeApp=s,exports.createCubeRouter=a,exports.mountCubeRoutes=o;
@@ -1,36 +1,43 @@
1
- import { a as e, f as t, i as n, o as r, r as i, u as a } from "../utils-IH1ePsBd.js";
2
- import { t as o } from "../compiler-S6KHiOY6.js";
3
- import { _ as s, a as c, d as l, f as u, g as d, h as f, i as p, m, p as h, r as g, s as _, v } from "../mcp-transport-C6bsIOSV.js";
4
- import y, { Router as b } from "express";
5
- import x from "cors";
1
+ import { a as e, f as t, i as n, o as r, r as i, u as a } from "../utils-DOg9oGdt.js";
2
+ import { i as o, n as s, r as c, t as l } from "../locale-DTnJrxm1.js";
3
+ import { S as u, _ as d, a as f, b as p, c as m, g as h, h as g, i as _, l as v, m as y, o as b, r as x, u as S, v as C, x as w, y as T } from "../mcp-transport-C7VLf4T5.js";
4
+ import E, { Router as D } from "express";
5
+ import O from "cors";
6
6
  //#region src/adapters/express/index.ts
7
- function S(S) {
8
- let { cubes: C, drizzle: w, schema: T, extractSecurityContext: E, engineType: D, cors: O, basePath: k = "/cubejs-api/v1", jsonLimit: A = "10mb", cache: j, mcp: M = { enabled: !0 }, agent: N } = S;
9
- if (!C || C.length === 0) throw Error("At least one cube must be provided in the cubes array");
10
- let P = b();
11
- O && P.use(x(O)), P.use(y.json({ limit: A })), P.use(y.urlencoded({
7
+ function k(k) {
8
+ let { cubes: A, drizzle: j, schema: M, extractSecurityContext: N, engineType: P, cors: F, basePath: I = "/cubejs-api/v1", jsonLimit: L = "10mb", cache: R, mcp: z = { enabled: !0 }, agent: B } = k;
9
+ if (!A || A.length === 0) throw Error("At least one cube must be provided in the cubes array");
10
+ let V = D(), H = async (e, t) => c(await N(e, t), s((t) => e.get(t)));
11
+ if (F) {
12
+ let e = {
13
+ ...F,
14
+ allowedHeaders: l(F.allowedHeaders)
15
+ };
16
+ V.use(O(e));
17
+ }
18
+ V.use(E.json({ limit: L })), V.use(E.urlencoded({
12
19
  extended: !0,
13
- limit: A
20
+ limit: L
14
21
  }));
15
- let F = new o({
16
- drizzle: w,
17
- schema: T,
18
- engineType: D,
19
- cache: j,
20
- rlsSetup: S.rlsSetup
22
+ let U = new o({
23
+ drizzle: j,
24
+ schema: M,
25
+ engineType: P,
26
+ cache: R,
27
+ rlsSetup: k.rlsSetup
21
28
  });
22
- if (C.forEach((e) => {
23
- F.registerCube(e);
24
- }), P.post(`${k}/load`, async (e, t) => {
29
+ if (A.forEach((e) => {
30
+ U.registerCube(e);
31
+ }), V.post(`${I}/load`, async (e, t) => {
25
32
  try {
26
- let r = e.body.query || e.body, a = await E(e, t), o = F.validateQuery(r);
33
+ let r = e.body.query || e.body, a = await H(e, t), o = U.validateQuery(r);
27
34
  if (!o.isValid) return t.status(400).json(n(`Query validation failed: ${o.errors.join(", ")}`, 400));
28
- let s = e.headers["x-cache-control"] === "no-cache", c = await F.executeMultiCubeQuery(r, a, { skipCache: s });
29
- t.json(i(r, c, F));
35
+ let s = e.headers["x-cache-control"] === "no-cache", c = await U.executeMultiCubeQuery(r, a, { skipCache: s });
36
+ t.json(i(r, c, U));
30
37
  } catch (e) {
31
38
  console.error("Query execution error:", e), t.status(500).json(n(e instanceof Error ? e.message : "Query execution failed", 500));
32
39
  }
33
- }), P.get(`${k}/load`, async (e, t) => {
40
+ }), V.get(`${I}/load`, async (e, t) => {
34
41
  try {
35
42
  let r = e.query.query;
36
43
  if (!r) return t.status(400).json(n("Query parameter is required", 400));
@@ -40,57 +47,57 @@ function S(S) {
40
47
  } catch {
41
48
  return t.status(400).json(n("Invalid JSON in query parameter", 400));
42
49
  }
43
- let o = await E(e, t), s = F.validateQuery(a);
50
+ let o = await H(e, t), s = U.validateQuery(a);
44
51
  if (!s.isValid) return t.status(400).json(n(`Query validation failed: ${s.errors.join(", ")}`, 400));
45
- let c = e.headers["x-cache-control"] === "no-cache", l = await F.executeMultiCubeQuery(a, o, { skipCache: c });
46
- t.json(i(a, l, F));
52
+ let c = e.headers["x-cache-control"] === "no-cache", l = await U.executeMultiCubeQuery(a, o, { skipCache: c });
53
+ t.json(i(a, l, U));
47
54
  } catch (e) {
48
55
  console.error("Query execution error:", e), t.status(500).json(n(e instanceof Error ? e.message : "Query execution failed", 500));
49
56
  }
50
- }), P.post(`${k}/batch`, async (e, t) => {
57
+ }), V.post(`${I}/batch`, async (e, t) => {
51
58
  try {
52
59
  let { queries: r } = e.body;
53
60
  if (!r || !Array.isArray(r)) return t.status(400).json(n("Request body must contain a \"queries\" array", 400));
54
61
  if (r.length === 0) return t.status(400).json(n("Queries array cannot be empty", 400));
55
- let i = await a(r, await E(e, t), F, { skipCache: e.headers["x-cache-control"] === "no-cache" });
62
+ let i = await a(r, await H(e, t), U, { skipCache: e.headers["x-cache-control"] === "no-cache" });
56
63
  t.json(i);
57
64
  } catch (e) {
58
65
  console.error("Batch execution error:", e), t.status(500).json(n(e instanceof Error ? e.message : "Batch execution failed", 500));
59
66
  }
60
- }), P.get(`${k}/meta`, (t, r) => {
67
+ }), V.get(`${I}/meta`, (t, r) => {
61
68
  try {
62
- let t = F.getMetadata();
69
+ let t = U.getMetadata();
63
70
  r.json(e(t));
64
71
  } catch (e) {
65
72
  console.error("Metadata error:", e), r.status(500).json(n(e instanceof Error ? e.message : "Failed to fetch metadata", 500));
66
73
  }
67
- }), P.post(`${k}/sql`, async (e, t) => {
74
+ }), V.post(`${I}/sql`, async (e, t) => {
68
75
  try {
69
- let i = e.body, a = await E(e, t), o = F.validateQuery(i);
76
+ let i = e.body, a = await H(e, t), o = U.validateQuery(i);
70
77
  if (!o.isValid) return t.status(400).json(n(`Query validation failed: ${o.errors.join(", ")}`, 400));
71
78
  let s = i.measures?.[0] || i.dimensions?.[0];
72
79
  if (!s) return t.status(400).json(n("No measures or dimensions specified", 400));
73
- let c = s.split(".")[0], l = await F.generateSQL(c, i, a);
80
+ let c = s.split(".")[0], l = await U.generateSQL(c, i, a);
74
81
  t.json(r(i, l));
75
82
  } catch (e) {
76
83
  console.error("SQL generation error:", String(e).replace(/\n|\r/g, "")), t.status(500).json(n(e instanceof Error ? e.message : "SQL generation failed", 500));
77
84
  }
78
- }), P.get(`${k}/sql`, async (e, t) => {
85
+ }), V.get(`${I}/sql`, async (e, t) => {
79
86
  try {
80
87
  let i = e.query.query;
81
88
  if (!i) return t.status(400).json(n("Query parameter is required", 400));
82
- let a = JSON.parse(i), o = await E(e, t), s = F.validateQuery(a);
89
+ let a = JSON.parse(i), o = await H(e, t), s = U.validateQuery(a);
83
90
  if (!s.isValid) return t.status(400).json(n(`Query validation failed: ${s.errors.join(", ")}`, 400));
84
91
  let c = a.measures?.[0] || a.dimensions?.[0];
85
92
  if (!c) return t.status(400).json(n("No measures or dimensions specified", 400));
86
- let l = c.split(".")[0], u = await F.generateSQL(l, a, o);
93
+ let l = c.split(".")[0], u = await U.generateSQL(l, a, o);
87
94
  t.json(r(a, u));
88
95
  } catch (e) {
89
96
  console.error("SQL generation error:", String(e).replace(/\n|\r/g, "")), t.status(500).json(n(e instanceof Error ? e.message : "SQL generation failed", 500));
90
97
  }
91
- }), P.post(`${k}/dry-run`, async (e, n) => {
98
+ }), V.post(`${I}/dry-run`, async (e, n) => {
92
99
  try {
93
- let r = await t(e.body.query || e.body, await E(e, n), F);
100
+ let r = await t(e.body.query || e.body, await H(e, n), U);
94
101
  n.json(r);
95
102
  } catch (e) {
96
103
  console.error("Dry-run error:", e), n.status(400).json({
@@ -98,14 +105,14 @@ function S(S) {
98
105
  valid: !1
99
106
  });
100
107
  }
101
- }), P.get(`${k}/dry-run`, async (e, n) => {
108
+ }), V.get(`${I}/dry-run`, async (e, n) => {
102
109
  try {
103
110
  let r = e.query.query;
104
111
  if (!r) return n.status(400).json({
105
112
  error: "Query parameter is required",
106
113
  valid: !1
107
114
  });
108
- let i = await t(JSON.parse(r), await E(e, n), F);
115
+ let i = await t(JSON.parse(r), await H(e, n), U);
109
116
  n.json(i);
110
117
  } catch (e) {
111
118
  console.error("Dry-run error:", e), n.status(400).json({
@@ -113,26 +120,26 @@ function S(S) {
113
120
  valid: !1
114
121
  });
115
122
  }
116
- }), P.post(`${k}/explain`, async (e, t) => {
123
+ }), V.post(`${I}/explain`, async (e, t) => {
117
124
  try {
118
- let n = e.body.query || e.body, r = e.body.options || {}, i = await E(e, t), a = F.validateQuery(n);
125
+ let n = e.body.query || e.body, r = e.body.options || {}, i = await H(e, t), a = U.validateQuery(n);
119
126
  if (!a.isValid) return t.status(400).json({ error: `Query validation failed: ${a.errors.join(", ")}` });
120
- let o = await F.explainQuery(n, i, r);
127
+ let o = await U.explainQuery(n, i, r);
121
128
  t.json(o);
122
129
  } catch (e) {
123
130
  console.error("Explain error:", e), t.status(500).json({ error: e instanceof Error ? e.message : "Explain query failed" });
124
131
  }
125
- }), N && P.post(`${k}/agent/chat`, async (e, t) => {
132
+ }), B && V.post(`${I}/agent/chat`, async (e, t) => {
126
133
  try {
127
- let { handleAgentChat: n } = await import("../handler-RItnSaEl.js"), { message: r, sessionId: i, history: a } = e.body;
134
+ let { handleAgentChat: n } = await import("../handler-3LGcjLtr.js"), { message: r, sessionId: i, history: a } = e.body;
128
135
  if (!r || typeof r != "string") return t.status(400).json({ error: "message is required and must be a string" });
129
- let o = (N.apiKey || "").trim();
130
- if (N.allowClientApiKey) {
136
+ let o = (B.apiKey || "").trim();
137
+ if (B.allowClientApiKey) {
131
138
  let t = e.headers["x-agent-api-key"];
132
139
  t && (o = t.trim());
133
140
  }
134
141
  if (!o) return t.status(401).json({ error: "No API key configured. Set agent.apiKey in server config or send X-Agent-Api-Key header." });
135
- let s = N.allowClientApiKey ? e.headers["x-agent-provider"] : void 0, c = N.allowClientApiKey ? e.headers["x-agent-model"] : void 0, l = N.allowClientApiKey ? e.headers["x-agent-provider-endpoint"] : void 0, u = await E(e, t), d = N.buildSystemContext?.(u);
142
+ let s = B.allowClientApiKey ? e.headers["x-agent-provider"] : void 0, c = B.allowClientApiKey ? e.headers["x-agent-model"] : void 0, l = B.allowClientApiKey ? e.headers["x-agent-provider-endpoint"] : void 0, u = await H(e, t), d = B.buildSystemContext?.(u);
136
143
  t.writeHead(200, {
137
144
  "Content-Type": "text/event-stream",
138
145
  "Cache-Control": "no-cache",
@@ -143,9 +150,9 @@ function S(S) {
143
150
  message: r,
144
151
  sessionId: i,
145
152
  history: a,
146
- semanticLayer: F,
153
+ semanticLayer: U,
147
154
  securityContext: u,
148
- agentConfig: N,
155
+ agentConfig: B,
149
156
  apiKey: o,
150
157
  systemContext: d,
151
158
  providerOverride: s,
@@ -165,52 +172,58 @@ function S(S) {
165
172
  } catch (e) {
166
173
  console.error("Agent chat error:", e), t.headersSent || t.status(500).json({ error: e instanceof Error ? e.message : "Agent chat failed" });
167
174
  }
168
- }), M.enabled !== !1) {
169
- let e = M.basePath ?? "/mcp";
170
- P.post(`${e}`, async (e, t) => {
171
- let n = s(e.headers.origin, M.allowedOrigins ? { allowedOrigins: M.allowedOrigins } : {});
172
- if (!n.valid) return t.status(403).json(p(null, -32600, n.reason));
173
- let r = e.headers.accept;
174
- if (!d(r)) return t.status(400).json(p(null, -32600, "Accept header must include both application/json and text/event-stream"));
175
- let i = u(e.headers);
176
- if (!i.ok) return t.status(426).json({
175
+ }), z.enabled !== !1) {
176
+ let e = b(U, z.resources), t = C(z.prompts), n = z.basePath ?? "/mcp";
177
+ V.post(`${n}`, async (n, r) => {
178
+ if (z.resourceMetadataUrl && !S(n.headers.authorization)) return r.setHeader("WWW-Authenticate", m(z.resourceMetadataUrl)), r.status(401).json({ error: "Bearer token required" });
179
+ let i = w(n.headers.origin, z.allowedOrigins ? { allowedOrigins: z.allowedOrigins } : {});
180
+ if (!i.valid) return r.status(403).json(_(null, -32600, i.reason));
181
+ let a = n.headers.accept;
182
+ if (!p(a)) return r.status(400).json(_(null, -32600, "Accept header must include both application/json and text/event-stream"));
183
+ let o = g(n.headers);
184
+ if (!o.ok) return r.status(426).json({
177
185
  error: "Unsupported MCP protocol version",
178
- supported: i.supported
186
+ supported: o.supported
179
187
  });
180
- let a = h(e.body);
181
- if (!a) return t.status(400).json(p(null, -32600, "Invalid JSON-RPC 2.0 request"));
182
- let o = v(r), y = a.method === "initialize";
188
+ let s = h(n.body);
189
+ if (!s) return r.status(400).json(_(null, -32600, "Invalid JSON-RPC 2.0 request"));
190
+ let c = u(a), l = s.method === "initialize";
183
191
  try {
184
- let n = await _(a.method, a.params, {
185
- semanticLayer: F,
186
- extractSecurityContext: E,
187
- rawRequest: e,
188
- rawResponse: t,
189
- negotiatedProtocol: i.negotiated,
190
- appEnabled: !!M.app
192
+ let i = await v(s.method, s.params, {
193
+ semanticLayer: U,
194
+ extractSecurityContext: (e, t) => H(e, t),
195
+ rawRequest: n,
196
+ rawResponse: r,
197
+ negotiatedProtocol: o.negotiated,
198
+ resources: e,
199
+ prompts: t,
200
+ appEnabled: !!z.app,
201
+ appConfig: typeof z.app == "object" ? z.app : void 0,
202
+ serverName: z.serverName
191
203
  });
192
- if (l(a)) return t.status(202).end();
193
- let r = y && n && typeof n == "object" && "sessionId" in n ? n.sessionId : void 0;
194
- r && t.setHeader(g, r);
195
- let s = c(a.id ?? null, n);
196
- if (o) {
197
- let e = m();
198
- return t.status(200), t.setHeader("Content-Type", "text/event-stream"), t.setHeader("Cache-Control", "no-cache"), t.setHeader("Connection", "keep-alive"), t.write(`id: ${e}\n\n`), t.write(f(s, e)), t.end();
204
+ if (y(s)) return r.status(202).end();
205
+ let a = l && i && typeof i == "object" && "sessionId" in i ? i.sessionId : void 0;
206
+ a && r.setHeader(x, a);
207
+ let u = f(s.id ?? null, i);
208
+ if (c) {
209
+ let e = d();
210
+ return r.status(200), r.setHeader("Content-Type", "text/event-stream"), r.setHeader("Cache-Control", "no-cache"), r.setHeader("Connection", "keep-alive"), r.write(`id: ${e}\n\n`), r.write(T(u, e)), r.end();
199
211
  }
200
- return t.json(s);
212
+ return r.json(u);
201
213
  } catch (e) {
202
- if (l(a)) return console.error("MCP notification processing error:", String(e).replace(/\n|\r/g, "")), t.status(202).end();
214
+ if (y(s)) return console.error("MCP notification processing error:", String(e).replace(/\n|\r/g, "")), r.status(202).end();
203
215
  console.error("MCP RPC error:", String(e).replace(/\n|\r/g, ""));
204
- let n = e?.code ?? -32603, r = e?.data, i = e.message || "MCP request failed", s = p(a.id ?? null, n, i, r);
205
- if (o) {
206
- let e = m();
207
- return t.status(200), t.setHeader("Content-Type", "text/event-stream"), t.setHeader("Cache-Control", "no-cache"), t.setHeader("Connection", "keep-alive"), t.write(`id: ${e}\n\n`), t.write(f(s, e)), t.end();
216
+ let t = e?.code ?? -32603, n = e?.data, i = e.message || "MCP request failed", a = _(s.id ?? null, t, i, n);
217
+ if (c) {
218
+ let e = d();
219
+ return r.status(200), r.setHeader("Content-Type", "text/event-stream"), r.setHeader("Cache-Control", "no-cache"), r.setHeader("Connection", "keep-alive"), r.write(`id: ${e}\n\n`), r.write(T(a, e)), r.end();
208
220
  }
209
- return t.status(200).json(s);
221
+ return r.status(200).json(a);
210
222
  }
211
- }), P.get(`${e}`, async (e, t) => {
212
- let n = m();
213
- t.status(200), t.setHeader("Content-Type", "text/event-stream"), t.setHeader("Cache-Control", "no-cache"), t.setHeader("Connection", "keep-alive"), t.write(f({
223
+ }), V.get(`${n}`, async (e, t) => {
224
+ if (z.resourceMetadataUrl && !S(e.headers.authorization)) return t.setHeader("WWW-Authenticate", m(z.resourceMetadataUrl)), t.status(401).json({ error: "Bearer token required" });
225
+ let n = d();
226
+ t.status(200), t.setHeader("Content-Type", "text/event-stream"), t.setHeader("Cache-Control", "no-cache"), t.setHeader("Connection", "keep-alive"), t.write(T({
214
227
  jsonrpc: "2.0",
215
228
  method: "mcp/ready",
216
229
  params: { protocol: "streamable-http" }
@@ -221,18 +234,18 @@ function S(S) {
221
234
  e.on("close", () => {
222
235
  clearInterval(r);
223
236
  });
224
- }), P.delete(`${e}`, (e, t) => t.status(405).json({ error: "Session termination not supported" }));
237
+ }), V.delete(`${n}`, (e, t) => z.resourceMetadataUrl && !S(e.headers.authorization) ? (t.setHeader("WWW-Authenticate", m(z.resourceMetadataUrl)), t.status(401).json({ error: "Bearer token required" })) : t.status(405).json({ error: "Session termination not supported" }));
225
238
  }
226
- return P.use((e, t, r, i) => {
239
+ return V.use((e, t, r, i) => {
227
240
  console.error("Express adapter error:", e), r.headersSent || r.status(500).json(n(e, 500));
228
- }), P;
241
+ }), V;
229
242
  }
230
- function C(e, t) {
231
- let n = S(t);
243
+ function A(e, t) {
244
+ let n = k(t);
232
245
  return e.use("/", n), e;
233
246
  }
234
- function w(e) {
235
- return C(y(), e);
247
+ function j(e) {
248
+ return A(E(), e);
236
249
  }
237
250
  //#endregion
238
- export { w as createCubeApp, S as createCubeRouter, C as mountCubeRoutes };
251
+ export { j as createCubeApp, k as createCubeRouter, A as mountCubeRoutes };
@@ -1,3 +1,3 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../utils-CyBt-as9.cjs`),t=require(`../compiler-CRgLzmSn.cjs`),n=require(`../mcp-transport-DMhuYmFp.cjs`);var r=function(r,i,a){let{cubes:o,drizzle:s,schema:c,extractSecurityContext:l,engineType:u,cors:d,basePath:f=`/cubejs-api/v1`,bodyLimit:p=10485760,cache:m,mcp:h={enabled:!0},agent:g}=i;if(!o||o.length===0)return a(Error(`At least one cube must be provided in the cubes array`));d&&r.register(import(`@fastify/cors`),d),r.addHook(`onRequest`,async(e,t)=>{e.method===`POST`&&(e.body=void 0)});let _=new t.t({drizzle:s,schema:c,engineType:u,cache:m,rlsSetup:i.rlsSetup});if(o.forEach(e=>{_.registerCube(e)}),r.post(`${f}/load`,{bodyLimit:p,schema:{body:{type:`object`,additionalProperties:!0}}},async(t,n)=>{try{let r=t.body,i=r.query||r,a=await l(t),o=_.validateQuery(i);if(!o.isValid)return n.status(400).send(e.i(`Query validation failed: ${o.errors.join(`, `)}`,400));let s=t.headers[`x-cache-control`]===`no-cache`;return e.r(i,await _.executeMultiCubeQuery(i,a,{skipCache:s}),_)}catch(r){return t.log.error(r,`Query execution error`),n.status(500).send(e.i(r instanceof Error?r.message:`Query execution failed`,500))}}),r.get(`${f}/load`,{schema:{querystring:{type:`object`,properties:{query:{type:`string`}},required:[`query`]}}},async(t,n)=>{try{let{query:r}=t.query,i;try{i=JSON.parse(r)}catch{return n.status(400).send(e.i(`Invalid JSON in query parameter`,400))}let a=await l(t),o=_.validateQuery(i);if(!o.isValid)return n.status(400).send(e.i(`Query validation failed: ${o.errors.join(`, `)}`,400));let s=t.headers[`x-cache-control`]===`no-cache`,c=await _.executeMultiCubeQuery(i,a,{skipCache:s});return e.r(i,c,_)}catch(r){return t.log.error(r,`Query execution error`),n.status(500).send(e.i(r instanceof Error?r.message:`Query execution failed`,500))}}),r.post(`${f}/batch`,{bodyLimit:p,schema:{body:{type:`object`,required:[`queries`],properties:{queries:{type:`array`,items:{type:`object`}}}}}},async(t,n)=>{try{let{queries:r}=t.body;return!r||!Array.isArray(r)?n.status(400).send(e.i(`Request body must contain a "queries" array`,400)):r.length===0?n.status(400).send(e.i(`Queries array cannot be empty`,400)):await e.u(r,await l(t),_,{skipCache:t.headers[`x-cache-control`]===`no-cache`})}catch(r){return t.log.error(r,`Batch execution error`),n.status(500).send(e.i(r instanceof Error?r.message:`Batch execution failed`,500))}}),r.get(`${f}/meta`,async(t,n)=>{try{return e.a(_.getMetadata())}catch(r){return t.log.error(r,`Metadata error`),n.status(500).send(e.i(r instanceof Error?r.message:`Failed to fetch metadata`,500))}}),r.post(`${f}/sql`,{bodyLimit:p,schema:{body:{type:`object`,additionalProperties:!0}}},async(t,n)=>{try{let r=t.body,i=await l(t),a=_.validateQuery(r);if(!a.isValid)return n.status(400).send(e.i(`Query validation failed: ${a.errors.join(`, `)}`,400));let o=r.measures?.[0]||r.dimensions?.[0];if(!o)return n.status(400).send(e.i(`No measures or dimensions specified`,400));let s=o.split(`.`)[0];return e.o(r,await _.generateSQL(s,r,i))}catch(r){return t.log.error({err:String(r).replace(/\n|\r/g,``)},`SQL generation error`),n.status(500).send(e.i(r instanceof Error?r.message:`SQL generation failed`,500))}}),r.get(`${f}/sql`,{schema:{querystring:{type:`object`,properties:{query:{type:`string`}},required:[`query`]}}},async(t,n)=>{try{let{query:r}=t.query,i=JSON.parse(r),a=await l(t),o=_.validateQuery(i);if(!o.isValid)return n.status(400).send(e.i(`Query validation failed: ${o.errors.join(`, `)}`,400));let s=i.measures?.[0]||i.dimensions?.[0];if(!s)return n.status(400).send(e.i(`No measures or dimensions specified`,400));let c=s.split(`.`)[0];return e.o(i,await _.generateSQL(c,i,a))}catch(r){return t.log.error({err:String(r).replace(/\n|\r/g,``)},`SQL generation error`),n.status(500).send(e.i(r instanceof Error?r.message:`SQL generation failed`,500))}}),r.post(`${f}/dry-run`,{bodyLimit:p,schema:{body:{type:`object`,additionalProperties:!0}}},async(t,n)=>{try{let n=t.body;return await e.f(n.query||n,await l(t),_)}catch(e){return t.log.error(e,`Dry-run error`),n.status(400).send({error:e instanceof Error?e.message:`Dry-run validation failed`,valid:!1})}}),r.get(`${f}/dry-run`,{schema:{querystring:{type:`object`,properties:{query:{type:`string`}},required:[`query`]}}},async(t,n)=>{try{let{query:n}=t.query;return await e.f(JSON.parse(n),await l(t),_)}catch(e){return t.log.error(e,`Dry-run error`),n.status(400).send({error:e instanceof Error?e.message:`Dry-run validation failed`,valid:!1})}}),r.post(`${f}/explain`,{bodyLimit:p,schema:{body:{type:`object`,additionalProperties:!0}}},async(e,t)=>{try{let n=e.body,r=n.query||n,i=n.options||{},a=await l(e),o=_.validateQuery(r);return o.isValid?await _.explainQuery(r,a,i):t.status(400).send({error:`Query validation failed: ${o.errors.join(`, `)}`})}catch(n){return e.log.error(n,`Explain error`),t.status(500).send({error:n instanceof Error?n.message:`Explain query failed`})}}),g&&r.post(`${f}/agent/chat`,{bodyLimit:p,schema:{body:{type:`object`,additionalProperties:!0}}},async(e,t)=>{try{let{handleAgentChat:n}=await Promise.resolve().then(()=>require(`../handler-DumFgnNM.cjs`)),{message:r,sessionId:i,history:a}=e.body;if(!r||typeof r!=`string`)return t.status(400).send({error:`message is required and must be a string`});let o=(g.apiKey||``).trim();if(g.allowClientApiKey){let t=e.headers[`x-agent-api-key`];t&&(o=t.trim())}if(!o)return t.status(401).send({error:`No API key configured. Set agent.apiKey in server config or send X-Agent-Api-Key header.`});let s=g.allowClientApiKey?e.headers[`x-agent-provider`]:void 0,c=g.allowClientApiKey?e.headers[`x-agent-model`]:void 0,u=g.allowClientApiKey?e.headers[`x-agent-provider-endpoint`]:void 0,d=await l(e),f=g.buildSystemContext?.(d);t.raw.writeHead(200,{"Content-Type":`text/event-stream`,"Cache-Control":`no-cache`,Connection:`keep-alive`});try{let e=n({message:r,sessionId:i,history:a,semanticLayer:_,securityContext:d,agentConfig:g,apiKey:o,systemContext:f,providerOverride:s,modelOverride:c,baseURLOverride:u});for await(let n of e)t.raw.write(`data: ${JSON.stringify(n)}\n\n`)}catch(e){let n={type:`error`,data:{message:e instanceof Error?e.message:`Stream failed`}};t.raw.write(`data: ${JSON.stringify(n)}\n\n`)}finally{t.raw.end()}}catch(n){if(e.log.error(n,`Agent chat error`),!t.raw.headersSent)return t.status(500).send({error:n instanceof Error?n.message:`Agent chat failed`})}}),h.enabled!==!1){let e=h.basePath??`/mcp`;r.post(`${e}`,{bodyLimit:p,schema:{body:{type:`object`,additionalProperties:!0}}},async(e,t)=>{let r=n._(e.headers.origin,h.allowedOrigins?{allowedOrigins:h.allowedOrigins}:{});if(!r.valid)return t.status(403).send(n.i(null,-32600,r.reason));let i=e.headers.accept;if(!n.g(i))return t.status(400).send(n.i(null,-32600,`Accept header must include both application/json and text/event-stream`));let a=n.f(e.headers);if(!a.ok)return t.status(426).send({error:`Unsupported MCP protocol version`,supported:a.supported});let o=n.p(e.body);if(!o)return t.status(400).send(n.i(null,-32600,`Invalid JSON-RPC 2.0 request`));let s=n.v(i),c=o.method===`initialize`;try{let r=await n.s(o.method,o.params,{semanticLayer:_,extractSecurityContext:l,rawRequest:e,rawResponse:t,negotiatedProtocol:a.negotiated,appEnabled:!!h.app});if(n.d(o))return t.status(202).send();let i=c&&r&&typeof r==`object`&&`sessionId`in r?r.sessionId:void 0;i&&t.header(n.r,i);let u=n.a(o.id??null,r);if(s){let e=n.m();t.header(`Content-Type`,`text/event-stream`).header(`Cache-Control`,`no-cache`).header(`Connection`,`keep-alive`).send(`id: ${e}\n\n${n.h(u,e)}`);return}return t.send(u)}catch(r){if(n.d(o))return e.log.error({err:String(r).replace(/\n|\r/g,``)},`MCP notification processing error`),t.status(202).send();e.log.error({err:String(r).replace(/\n|\r/g,``)},`MCP RPC error`);let i=r?.code??-32603,a=r?.data,c=r.message||`MCP request failed`,l=n.i(o.id??null,i,c,a);if(s){let e=n.m();t.header(`Content-Type`,`text/event-stream`).header(`Cache-Control`,`no-cache`).header(`Connection`,`keep-alive`).send(`id: ${e}\n\n${n.h(l,e)}`);return}return t.send(l)}}),r.get(`${e}`,async(e,t)=>{let r=n.m();t.raw.writeHead(200,{"Content-Type":`text/event-stream`,"Cache-Control":`no-cache`,Connection:`keep-alive`}),t.raw.write(n.h({jsonrpc:`2.0`,method:`mcp/ready`,params:{protocol:`streamable-http`}},r,15e3));let i=setInterval(()=>{t.raw.write(`: keep-alive
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../utils-DNrj-ryp.cjs`),t=require(`../locale-DueXjqMh.cjs`),n=require(`../mcp-transport-poPHl_2j.cjs`);var r=function(r,i,a){let{cubes:o,drizzle:s,schema:c,extractSecurityContext:l,engineType:u,cors:d,basePath:f=`/cubejs-api/v1`,bodyLimit:p=10485760,cache:m,mcp:h={enabled:!0},agent:g}=i;if(!o||o.length===0)return a(Error(`At least one cube must be provided in the cubes array`));let _=async e=>t.r(await l(e),t.n(t=>e.headers[t.toLowerCase()]));if(d){let e={...d,allowedHeaders:t.t(d.allowedHeaders)};r.register(import(`@fastify/cors`),e)}r.addHook(`onRequest`,async(e,t)=>{e.method===`POST`&&(e.body=void 0)});let v=new t.i({drizzle:s,schema:c,engineType:u,cache:m,rlsSetup:i.rlsSetup});if(o.forEach(e=>{v.registerCube(e)}),r.post(`${f}/load`,{bodyLimit:p,schema:{body:{type:`object`,additionalProperties:!0}}},async(t,n)=>{try{let r=t.body,i=r.query||r,a=await _(t),o=v.validateQuery(i);if(!o.isValid)return n.status(400).send(e.i(`Query validation failed: ${o.errors.join(`, `)}`,400));let s=t.headers[`x-cache-control`]===`no-cache`;return e.r(i,await v.executeMultiCubeQuery(i,a,{skipCache:s}),v)}catch(r){return t.log.error(r,`Query execution error`),n.status(500).send(e.i(r instanceof Error?r.message:`Query execution failed`,500))}}),r.get(`${f}/load`,{schema:{querystring:{type:`object`,properties:{query:{type:`string`}},required:[`query`]}}},async(t,n)=>{try{let{query:r}=t.query,i;try{i=JSON.parse(r)}catch{return n.status(400).send(e.i(`Invalid JSON in query parameter`,400))}let a=await _(t),o=v.validateQuery(i);if(!o.isValid)return n.status(400).send(e.i(`Query validation failed: ${o.errors.join(`, `)}`,400));let s=t.headers[`x-cache-control`]===`no-cache`,c=await v.executeMultiCubeQuery(i,a,{skipCache:s});return e.r(i,c,v)}catch(r){return t.log.error(r,`Query execution error`),n.status(500).send(e.i(r instanceof Error?r.message:`Query execution failed`,500))}}),r.post(`${f}/batch`,{bodyLimit:p,schema:{body:{type:`object`,required:[`queries`],properties:{queries:{type:`array`,items:{type:`object`}}}}}},async(t,n)=>{try{let{queries:r}=t.body;return!r||!Array.isArray(r)?n.status(400).send(e.i(`Request body must contain a "queries" array`,400)):r.length===0?n.status(400).send(e.i(`Queries array cannot be empty`,400)):await e.u(r,await _(t),v,{skipCache:t.headers[`x-cache-control`]===`no-cache`})}catch(r){return t.log.error(r,`Batch execution error`),n.status(500).send(e.i(r instanceof Error?r.message:`Batch execution failed`,500))}}),r.get(`${f}/meta`,async(t,n)=>{try{return e.a(v.getMetadata())}catch(r){return t.log.error(r,`Metadata error`),n.status(500).send(e.i(r instanceof Error?r.message:`Failed to fetch metadata`,500))}}),r.post(`${f}/sql`,{bodyLimit:p,schema:{body:{type:`object`,additionalProperties:!0}}},async(t,n)=>{try{let r=t.body,i=await _(t),a=v.validateQuery(r);if(!a.isValid)return n.status(400).send(e.i(`Query validation failed: ${a.errors.join(`, `)}`,400));let o=r.measures?.[0]||r.dimensions?.[0];if(!o)return n.status(400).send(e.i(`No measures or dimensions specified`,400));let s=o.split(`.`)[0];return e.o(r,await v.generateSQL(s,r,i))}catch(r){return t.log.error({err:String(r).replace(/\n|\r/g,``)},`SQL generation error`),n.status(500).send(e.i(r instanceof Error?r.message:`SQL generation failed`,500))}}),r.get(`${f}/sql`,{schema:{querystring:{type:`object`,properties:{query:{type:`string`}},required:[`query`]}}},async(t,n)=>{try{let{query:r}=t.query,i=JSON.parse(r),a=await _(t),o=v.validateQuery(i);if(!o.isValid)return n.status(400).send(e.i(`Query validation failed: ${o.errors.join(`, `)}`,400));let s=i.measures?.[0]||i.dimensions?.[0];if(!s)return n.status(400).send(e.i(`No measures or dimensions specified`,400));let c=s.split(`.`)[0];return e.o(i,await v.generateSQL(c,i,a))}catch(r){return t.log.error({err:String(r).replace(/\n|\r/g,``)},`SQL generation error`),n.status(500).send(e.i(r instanceof Error?r.message:`SQL generation failed`,500))}}),r.post(`${f}/dry-run`,{bodyLimit:p,schema:{body:{type:`object`,additionalProperties:!0}}},async(t,n)=>{try{let n=t.body;return await e.f(n.query||n,await _(t),v)}catch(e){return t.log.error(e,`Dry-run error`),n.status(400).send({error:e instanceof Error?e.message:`Dry-run validation failed`,valid:!1})}}),r.get(`${f}/dry-run`,{schema:{querystring:{type:`object`,properties:{query:{type:`string`}},required:[`query`]}}},async(t,n)=>{try{let{query:n}=t.query;return await e.f(JSON.parse(n),await _(t),v)}catch(e){return t.log.error(e,`Dry-run error`),n.status(400).send({error:e instanceof Error?e.message:`Dry-run validation failed`,valid:!1})}}),r.post(`${f}/explain`,{bodyLimit:p,schema:{body:{type:`object`,additionalProperties:!0}}},async(e,t)=>{try{let n=e.body,r=n.query||n,i=n.options||{},a=await _(e),o=v.validateQuery(r);return o.isValid?await v.explainQuery(r,a,i):t.status(400).send({error:`Query validation failed: ${o.errors.join(`, `)}`})}catch(n){return e.log.error(n,`Explain error`),t.status(500).send({error:n instanceof Error?n.message:`Explain query failed`})}}),g&&r.post(`${f}/agent/chat`,{bodyLimit:p,schema:{body:{type:`object`,additionalProperties:!0}}},async(e,t)=>{try{let{handleAgentChat:n}=await Promise.resolve().then(()=>require(`../handler-BzzbVpcl.cjs`)),{message:r,sessionId:i,history:a}=e.body;if(!r||typeof r!=`string`)return t.status(400).send({error:`message is required and must be a string`});let o=(g.apiKey||``).trim();if(g.allowClientApiKey){let t=e.headers[`x-agent-api-key`];t&&(o=t.trim())}if(!o)return t.status(401).send({error:`No API key configured. Set agent.apiKey in server config or send X-Agent-Api-Key header.`});let s=g.allowClientApiKey?e.headers[`x-agent-provider`]:void 0,c=g.allowClientApiKey?e.headers[`x-agent-model`]:void 0,l=g.allowClientApiKey?e.headers[`x-agent-provider-endpoint`]:void 0,u=await _(e),d=g.buildSystemContext?.(u);t.raw.writeHead(200,{"Content-Type":`text/event-stream`,"Cache-Control":`no-cache`,Connection:`keep-alive`});try{let e=n({message:r,sessionId:i,history:a,semanticLayer:v,securityContext:u,agentConfig:g,apiKey:o,systemContext:d,providerOverride:s,modelOverride:c,baseURLOverride:l});for await(let n of e)t.raw.write(`data: ${JSON.stringify(n)}\n\n`)}catch(e){let n={type:`error`,data:{message:e instanceof Error?e.message:`Stream failed`}};t.raw.write(`data: ${JSON.stringify(n)}\n\n`)}finally{t.raw.end()}}catch(n){if(e.log.error(n,`Agent chat error`),!t.raw.headersSent)return t.status(500).send({error:n instanceof Error?n.message:`Agent chat failed`})}}),h.enabled!==!1){let e=n.o(v,h.resources),t=n.v(h.prompts),i=h.basePath??`/mcp`;r.post(`${i}`,{bodyLimit:p,schema:{body:{type:`object`,additionalProperties:!0}}},async(r,i)=>{if(h.resourceMetadataUrl&&!n.u(r.headers.authorization))return i.header(`WWW-Authenticate`,n.c(h.resourceMetadataUrl)),i.status(401).send({error:`Bearer token required`});let a=n.x(r.headers.origin,h.allowedOrigins?{allowedOrigins:h.allowedOrigins}:{});if(!a.valid)return i.status(403).send(n.i(null,-32600,a.reason));let o=r.headers.accept;if(!n.b(o))return i.status(400).send(n.i(null,-32600,`Accept header must include both application/json and text/event-stream`));let s=n.h(r.headers);if(!s.ok)return i.status(426).send({error:`Unsupported MCP protocol version`,supported:s.supported});let c=n.g(r.body);if(!c)return i.status(400).send(n.i(null,-32600,`Invalid JSON-RPC 2.0 request`));let l=n.S(o),u=c.method===`initialize`;try{let a=await n.l(c.method,c.params,{semanticLayer:v,extractSecurityContext:(e,t)=>_(e),rawRequest:r,rawResponse:i,negotiatedProtocol:s.negotiated,resources:e,prompts:t,appEnabled:!!h.app,appConfig:typeof h.app==`object`?h.app:void 0,serverName:h.serverName});if(n.m(c))return i.status(202).send();let o=u&&a&&typeof a==`object`&&`sessionId`in a?a.sessionId:void 0;o&&i.header(n.r,o);let d=n.a(c.id??null,a);if(l){let e=n._();i.header(`Content-Type`,`text/event-stream`).header(`Cache-Control`,`no-cache`).header(`Connection`,`keep-alive`).send(`id: ${e}\n\n${n.y(d,e)}`);return}return i.send(d)}catch(e){if(n.m(c))return r.log.error({err:String(e).replace(/\n|\r/g,``)},`MCP notification processing error`),i.status(202).send();r.log.error({err:String(e).replace(/\n|\r/g,``)},`MCP RPC error`);let t=e?.code??-32603,a=e?.data,o=e.message||`MCP request failed`,s=n.i(c.id??null,t,o,a);if(l){let e=n._();i.header(`Content-Type`,`text/event-stream`).header(`Cache-Control`,`no-cache`).header(`Connection`,`keep-alive`).send(`id: ${e}\n\n${n.y(s,e)}`);return}return i.send(s)}}),r.get(`${i}`,async(e,t)=>{if(h.resourceMetadataUrl&&!n.u(e.headers.authorization))return t.header(`WWW-Authenticate`,n.c(h.resourceMetadataUrl)),t.status(401).send({error:`Bearer token required`});let r=n._();t.raw.writeHead(200,{"Content-Type":`text/event-stream`,"Cache-Control":`no-cache`,Connection:`keep-alive`}),t.raw.write(n.y({jsonrpc:`2.0`,method:`mcp/ready`,params:{protocol:`streamable-http`}},r,15e3));let i=setInterval(()=>{t.raw.write(`: keep-alive
2
2
 
3
- `)},15e3);e.raw.on(`close`,()=>{clearInterval(i)})}),r.delete(`${e}`,async(e,t)=>t.status(405).send({error:`Session termination not supported`}))}r.setErrorHandler(async(t,n,r)=>(n.log.error(t,`Fastify cube adapter error`),r.statusCode<400&&r.status(500),e.i(t instanceof Error?t:String(t),r.statusCode))),a()};async function i(e,t){await e.register(r,t)}function a(e){let t=require(`fastify`)({logger:!0});return t.register(r,e),t}exports.createCubeApp=a,exports.cubePlugin=r,exports.registerCubeRoutes=i;
3
+ `)},15e3);e.raw.on(`close`,()=>{clearInterval(i)})}),r.delete(`${i}`,async(e,t)=>h.resourceMetadataUrl&&!n.u(e.headers.authorization)?(t.header(`WWW-Authenticate`,n.c(h.resourceMetadataUrl)),t.status(401).send({error:`Bearer token required`})):t.status(405).send({error:`Session termination not supported`}))}r.setErrorHandler(async(t,n,r)=>(n.log.error(t,`Fastify cube adapter error`),r.statusCode<400&&r.status(500),e.i(t instanceof Error?t:String(t),r.statusCode))),a()};async function i(e,t){await e.register(r,t)}function a(e){let t=require(`fastify`)({logger:!0});return t.register(r,e),t}exports.createCubeApp=a,exports.cubePlugin=r,exports.registerCubeRoutes=i;