drizzle-cube 0.3.21 → 0.3.23

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 (122) hide show
  1. package/dist/adapters/express/index.cjs +1 -1
  2. package/dist/adapters/express/index.js +1 -1
  3. package/dist/adapters/fastify/index.cjs +1 -1
  4. package/dist/adapters/fastify/index.js +1 -1
  5. package/dist/adapters/hono/index.cjs +1 -1
  6. package/dist/adapters/hono/index.js +1 -1
  7. package/dist/adapters/{mcp-transport-DHBUNdYg.js → mcp-transport-lkEjNwDH.js} +3242 -3201
  8. package/dist/adapters/mcp-transport-oPf8JYHv.cjs +275 -0
  9. package/dist/adapters/nextjs/index.cjs +1 -1
  10. package/dist/adapters/nextjs/index.js +1 -1
  11. package/dist/client/charts/chartConfigs.d.ts +21 -0
  12. package/dist/client/charts.js +14 -14
  13. package/dist/client/chunks/{RetentionCombinedChart-DsWhPI0q.js → RetentionCombinedChart-DpEKFYsd.js} +3 -3
  14. package/dist/client/chunks/RetentionCombinedChart-DpEKFYsd.js.map +1 -0
  15. package/dist/client/chunks/{analysis-builder-DcZgXtPK.js → analysis-builder-DiaxkEY-.js} +9 -9
  16. package/dist/client/chunks/{analysis-builder-DcZgXtPK.js.map → analysis-builder-DiaxkEY-.js.map} +1 -1
  17. package/dist/client/chunks/{analysis-builder-shared-ZnrPzt_d.js → analysis-builder-shared-BzM5Vwpr.js} +5 -5
  18. package/dist/client/chunks/{analysis-builder-shared-ZnrPzt_d.js.map → analysis-builder-shared-BzM5Vwpr.js.map} +1 -1
  19. package/dist/client/chunks/{chart-activity-grid-BUc21L0U.js → chart-activity-grid-CCGyWo1c.js} +116 -106
  20. package/dist/client/chunks/chart-activity-grid-CCGyWo1c.js.map +1 -0
  21. package/dist/client/chunks/chart-area-ZZp1libT.js +234 -0
  22. package/dist/client/chunks/chart-area-ZZp1libT.js.map +1 -0
  23. package/dist/client/chunks/chart-bar-B4grbo6Q.js +254 -0
  24. package/dist/client/chunks/chart-bar-B4grbo6Q.js.map +1 -0
  25. package/dist/client/chunks/{chart-bubble-CO7qvWR9.js → chart-bubble-BGGAQQUQ.js} +2 -2
  26. package/dist/client/chunks/{chart-bubble-CO7qvWR9.js.map → chart-bubble-BGGAQQUQ.js.map} +1 -1
  27. package/dist/client/chunks/{chart-config-activity-grid-BBSNCbkb.js → chart-config-activity-grid-CAlo1cHA.js} +3 -2
  28. package/dist/client/chunks/{chart-config-activity-grid-BBSNCbkb.js.map → chart-config-activity-grid-CAlo1cHA.js.map} +1 -1
  29. package/dist/client/chunks/{chart-config-bar-BJKGnfLt.js → chart-config-bar-soxw6m2o.js} +2 -1
  30. package/dist/client/chunks/chart-config-bar-soxw6m2o.js.map +1 -0
  31. package/dist/client/chunks/{chart-config-line-DR0ThxZy.js → chart-config-line-D5ME6w0v.js} +2 -1
  32. package/dist/client/chunks/chart-config-line-D5ME6w0v.js.map +1 -0
  33. package/dist/client/chunks/{chart-config-pie-BM5lgH-w.js → chart-config-pie-DlHa2jTy.js} +2 -1
  34. package/dist/client/chunks/chart-config-pie-DlHa2jTy.js.map +1 -0
  35. package/dist/client/chunks/{chart-config-tree-map-CLmRvvMR.js → chart-config-tree-map-IRAYf9YM.js} +3 -2
  36. package/dist/client/chunks/{chart-config-tree-map-CLmRvvMR.js.map → chart-config-tree-map-IRAYf9YM.js.map} +1 -1
  37. package/dist/client/chunks/{chart-data-table-bclSKgkZ.js → chart-data-table-BcH_h6kZ.js} +3 -3
  38. package/dist/client/chunks/{chart-data-table-bclSKgkZ.js.map → chart-data-table-BcH_h6kZ.js.map} +1 -1
  39. package/dist/client/chunks/{chart-funnel-FvDvq015.js → chart-funnel-DI8RMacf.js} +3 -3
  40. package/dist/client/chunks/chart-funnel-DI8RMacf.js.map +1 -0
  41. package/dist/client/chunks/{chart-heat-map-GpFE-PFB.js → chart-heat-map-D3xNV9ep.js} +2 -2
  42. package/dist/client/chunks/{chart-heat-map-GpFE-PFB.js.map → chart-heat-map-D3xNV9ep.js.map} +1 -1
  43. package/dist/client/chunks/{chart-kpi-delta-jmz-CK8X.js → chart-kpi-delta-BJMQKPor.js} +3 -3
  44. package/dist/client/chunks/{chart-kpi-delta-jmz-CK8X.js.map → chart-kpi-delta-BJMQKPor.js.map} +1 -1
  45. package/dist/client/chunks/{chart-kpi-number-DbSmomE8.js → chart-kpi-number-B8u4tWmu.js} +2 -2
  46. package/dist/client/chunks/{chart-kpi-number-DbSmomE8.js.map → chart-kpi-number-B8u4tWmu.js.map} +1 -1
  47. package/dist/client/chunks/{chart-kpi-text-erI9U7PZ.js → chart-kpi-text--r1d4zAz.js} +3 -3
  48. package/dist/client/chunks/{chart-kpi-text-erI9U7PZ.js.map → chart-kpi-text--r1d4zAz.js.map} +1 -1
  49. package/dist/client/chunks/chart-line-K0ACw4cV.js +413 -0
  50. package/dist/client/chunks/chart-line-K0ACw4cV.js.map +1 -0
  51. package/dist/client/chunks/chart-pie-DC7axSwd.js +137 -0
  52. package/dist/client/chunks/chart-pie-DC7axSwd.js.map +1 -0
  53. package/dist/client/chunks/{chart-radar-BE6xsFiF.js → chart-radar-BDKgpLw5.js} +33 -33
  54. package/dist/client/chunks/chart-radar-BDKgpLw5.js.map +1 -0
  55. package/dist/client/chunks/{chart-radial-bar-BEEwtFDc.js → chart-radial-bar-BYNng7Nz.js} +7 -6
  56. package/dist/client/chunks/chart-radial-bar-BYNng7Nz.js.map +1 -0
  57. package/dist/client/chunks/{chart-sankey-Dt3KaYrH.js → chart-sankey-CpsKerey.js} +2 -2
  58. package/dist/client/chunks/{chart-sankey-Dt3KaYrH.js.map → chart-sankey-CpsKerey.js.map} +1 -1
  59. package/dist/client/chunks/{chart-scatter-gAlYkQcW.js → chart-scatter-CXqFltJg.js} +11 -11
  60. package/dist/client/chunks/chart-scatter-CXqFltJg.js.map +1 -0
  61. package/dist/client/chunks/{chart-sunburst-D0Lvdjwu.js → chart-sunburst-DSsO2CzY.js} +2 -2
  62. package/dist/client/chunks/{chart-sunburst-D0Lvdjwu.js.map → chart-sunburst-DSsO2CzY.js.map} +1 -1
  63. package/dist/client/chunks/{chart-tree-map-Bv_PYe0c.js → chart-tree-map-D_SeBBD-.js} +77 -57
  64. package/dist/client/chunks/chart-tree-map-D_SeBBD-.js.map +1 -0
  65. package/dist/client/chunks/{chartConfigRegistry-BumUIPw4.js → chartConfigRegistry-DNEbwgTc.js} +6 -6
  66. package/dist/client/chunks/{chartConfigRegistry-BumUIPw4.js.map → chartConfigRegistry-DNEbwgTc.js.map} +1 -1
  67. package/dist/client/chunks/{charts-DqWRT0TE.js → charts-T6qNi6FO.js} +17 -17
  68. package/dist/client/chunks/charts-T6qNi6FO.js.map +1 -0
  69. package/dist/client/chunks/{charts-core-BfxnhMfd.js → charts-core-8jDh3mKC.js} +64 -63
  70. package/dist/client/chunks/charts-core-8jDh3mKC.js.map +1 -0
  71. package/dist/client/chunks/{charts-loader-DCGbL50r.js → charts-loader-DpJr9z2e.js} +20 -20
  72. package/dist/client/chunks/{charts-loader-DCGbL50r.js.map → charts-loader-DpJr9z2e.js.map} +1 -1
  73. package/dist/client/chunks/{components-NmBmOEqV.js → components-vl_fdWud.js} +3579 -2880
  74. package/dist/client/chunks/components-vl_fdWud.js.map +1 -0
  75. package/dist/client/chunks/{hooks-D7APQ8uS.js → hooks-CKYzVf_7.js} +3 -3
  76. package/dist/client/chunks/{hooks-D7APQ8uS.js.map → hooks-CKYzVf_7.js.map} +1 -1
  77. package/dist/client/chunks/{index-CBvXpG92.js → index-_2PSgbkC.js} +270 -261
  78. package/dist/client/chunks/index-_2PSgbkC.js.map +1 -0
  79. package/dist/client/chunks/{providers-Cj7PQfXn.js → providers-BBrUJB2U.js} +2 -2
  80. package/dist/client/chunks/{providers-Cj7PQfXn.js.map → providers-BBrUJB2U.js.map} +1 -1
  81. package/dist/client/chunks/{useDirtyStateTracking-ZSi3voVl.js → useDirtyStateTracking-DDQ_Lbki.js} +2 -2
  82. package/dist/client/chunks/{useDirtyStateTracking-ZSi3voVl.js.map → useDirtyStateTracking-DDQ_Lbki.js.map} +1 -1
  83. package/dist/client/components/DrillBreadcrumb.d.ts +6 -0
  84. package/dist/client/components/DrillMenu.d.ts +8 -0
  85. package/dist/client/components/charts/AngledXAxisTick.d.ts +19 -0
  86. package/dist/client/components.js +2 -2
  87. package/dist/client/hooks/useDrillInteraction.d.ts +9 -0
  88. package/dist/client/hooks.js +3 -3
  89. package/dist/client/index.js +9 -9
  90. package/dist/client/providers.js +1 -1
  91. package/dist/client/styles.css +1 -1
  92. package/dist/client/types/drill.d.ts +240 -0
  93. package/dist/client/types.d.ts +53 -2
  94. package/dist/client/utils/drillQueryBuilder.d.ts +41 -0
  95. package/dist/client-bundle-stats.html +1 -1
  96. package/dist/server/index.cjs +31 -31
  97. package/dist/server/index.d.ts +78 -0
  98. package/dist/server/index.js +2730 -2689
  99. package/package.json +6 -3
  100. package/dist/adapters/mcp-transport-B37JTeww.cjs +0 -275
  101. package/dist/client/chunks/RetentionCombinedChart-DsWhPI0q.js.map +0 -1
  102. package/dist/client/chunks/chart-activity-grid-BUc21L0U.js.map +0 -1
  103. package/dist/client/chunks/chart-area-B_64FScj.js +0 -190
  104. package/dist/client/chunks/chart-area-B_64FScj.js.map +0 -1
  105. package/dist/client/chunks/chart-bar-Ctiy2tpQ.js +0 -216
  106. package/dist/client/chunks/chart-bar-Ctiy2tpQ.js.map +0 -1
  107. package/dist/client/chunks/chart-config-bar-BJKGnfLt.js.map +0 -1
  108. package/dist/client/chunks/chart-config-line-DR0ThxZy.js.map +0 -1
  109. package/dist/client/chunks/chart-config-pie-BM5lgH-w.js.map +0 -1
  110. package/dist/client/chunks/chart-funnel-FvDvq015.js.map +0 -1
  111. package/dist/client/chunks/chart-line-B0YOZ88n.js +0 -364
  112. package/dist/client/chunks/chart-line-B0YOZ88n.js.map +0 -1
  113. package/dist/client/chunks/chart-pie-CImB6r4F.js +0 -125
  114. package/dist/client/chunks/chart-pie-CImB6r4F.js.map +0 -1
  115. package/dist/client/chunks/chart-radar-BE6xsFiF.js.map +0 -1
  116. package/dist/client/chunks/chart-radial-bar-BEEwtFDc.js.map +0 -1
  117. package/dist/client/chunks/chart-scatter-gAlYkQcW.js.map +0 -1
  118. package/dist/client/chunks/chart-tree-map-Bv_PYe0c.js.map +0 -1
  119. package/dist/client/chunks/charts-DqWRT0TE.js.map +0 -1
  120. package/dist/client/chunks/charts-core-BfxnhMfd.js.map +0 -1
  121. package/dist/client/chunks/components-NmBmOEqV.js.map +0 -1
  122. package/dist/client/chunks/index-CBvXpG92.js.map +0 -1
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const R=require("express"),M=require("cors"),r=require("../mcp-transport-B37JTeww.cjs");function S(f){const{cubes:m,drizzle:E,schema:$,extractSecurityContext:d,engineType:I,cors:g,basePath:p="/cubejs-api/v1",jsonLimit:x="10mb",cache:P,mcp:h={enabled:!0}}=f;if(!m||m.length===0)throw new Error("At least one cube must be provided in the cubes array");const u=R.Router();g&&u.use(M(g)),u.use(R.json({limit:x})),u.use(R.urlencoded({extended:!0,limit:x}));const c=new r.SemanticLayerCompiler({drizzle:E,schema:$,engineType:I,cache:P});if(m.forEach(o=>{c.registerCube(o)}),u.post(`${p}/load`,async(o,t)=>{try{const e=o.body.query||o.body,s=await d(o,t),n=c.validateQuery(e);if(!n.isValid)return t.status(400).json(r.formatErrorResponse(`Query validation failed: ${n.errors.join(", ")}`,400));const a=o.headers["x-cache-control"]==="no-cache",i=await c.executeMultiCubeQuery(e,s,{skipCache:a});t.json(r.formatCubeResponse(e,i,c))}catch(e){console.error("Query execution error:",e),t.status(500).json(r.formatErrorResponse(e instanceof Error?e.message:"Query execution failed",500))}}),u.get(`${p}/load`,async(o,t)=>{try{const e=o.query.query;if(!e)return t.status(400).json(r.formatErrorResponse("Query parameter is required",400));let s;try{s=JSON.parse(e)}catch{return t.status(400).json(r.formatErrorResponse("Invalid JSON in query parameter",400))}const n=await d(o,t),a=c.validateQuery(s);if(!a.isValid)return t.status(400).json(r.formatErrorResponse(`Query validation failed: ${a.errors.join(", ")}`,400));const i=o.headers["x-cache-control"]==="no-cache",y=await c.executeMultiCubeQuery(s,n,{skipCache:i});t.json(r.formatCubeResponse(s,y,c))}catch(e){console.error("Query execution error:",e),t.status(500).json(r.formatErrorResponse(e instanceof Error?e.message:"Query execution failed",500))}}),u.post(`${p}/batch`,async(o,t)=>{try{const{queries:e}=o.body;if(!e||!Array.isArray(e))return t.status(400).json(r.formatErrorResponse('Request body must contain a "queries" array',400));if(e.length===0)return t.status(400).json(r.formatErrorResponse("Queries array cannot be empty",400));const s=await d(o,t),n=o.headers["x-cache-control"]==="no-cache",a=await r.handleBatchRequest(e,s,c,{skipCache:n});t.json(a)}catch(e){console.error("Batch execution error:",e),t.status(500).json(r.formatErrorResponse(e instanceof Error?e.message:"Batch execution failed",500))}}),u.get(`${p}/meta`,(o,t)=>{try{const e=c.getMetadata();t.json(r.formatMetaResponse(e))}catch(e){console.error("Metadata error:",e),t.status(500).json(r.formatErrorResponse(e instanceof Error?e.message:"Failed to fetch metadata",500))}}),u.post(`${p}/sql`,async(o,t)=>{try{const e=o.body,s=await d(o,t),n=c.validateQuery(e);if(!n.isValid)return t.status(400).json(r.formatErrorResponse(`Query validation failed: ${n.errors.join(", ")}`,400));const a=e.measures?.[0]||e.dimensions?.[0];if(!a)return t.status(400).json(r.formatErrorResponse("No measures or dimensions specified",400));const i=a.split(".")[0],y=await c.generateSQL(i,e,s);t.json(r.formatSqlResponse(e,y))}catch(e){console.error("SQL generation error:",e),t.status(500).json(r.formatErrorResponse(e instanceof Error?e.message:"SQL generation failed",500))}}),u.get(`${p}/sql`,async(o,t)=>{try{const e=o.query.query;if(!e)return t.status(400).json(r.formatErrorResponse("Query parameter is required",400));const s=JSON.parse(e),n=await d(o,t),a=c.validateQuery(s);if(!a.isValid)return t.status(400).json(r.formatErrorResponse(`Query validation failed: ${a.errors.join(", ")}`,400));const i=s.measures?.[0]||s.dimensions?.[0];if(!i)return t.status(400).json(r.formatErrorResponse("No measures or dimensions specified",400));const y=i.split(".")[0],C=await c.generateSQL(y,s,n);t.json(r.formatSqlResponse(s,C))}catch(e){console.error("SQL generation error:",e),t.status(500).json(r.formatErrorResponse(e instanceof Error?e.message:"SQL generation failed",500))}}),u.post(`${p}/dry-run`,async(o,t)=>{try{const e=o.body.query||o.body,s=await d(o,t),n=await r.handleDryRun(e,s,c);t.json(n)}catch(e){console.error("Dry-run error:",e),t.status(400).json({error:e instanceof Error?e.message:"Dry-run validation failed",valid:!1})}}),u.get(`${p}/dry-run`,async(o,t)=>{try{const e=o.query.query;if(!e)return t.status(400).json({error:"Query parameter is required",valid:!1});const s=JSON.parse(e),n=await d(o,t),a=await r.handleDryRun(s,n,c);t.json(a)}catch(e){console.error("Dry-run error:",e),t.status(400).json({error:e instanceof Error?e.message:"Dry-run validation failed",valid:!1})}}),u.post(`${p}/explain`,async(o,t)=>{try{const e=o.body.query||o.body,s=o.body.options||{},n=await d(o,t),a=c.validateQuery(e);if(!a.isValid)return t.status(400).json({error:`Query validation failed: ${a.errors.join(", ")}`});const i=await c.explainQuery(e,n,s);t.json(i)}catch(e){console.error("Explain error:",e),t.status(500).json({error:e instanceof Error?e.message:"Explain query failed"})}}),h.enabled!==!1){const o=h.basePath??"/mcp";u.post(`${o}`,async(t,e)=>{const s=r.validateOriginHeader(t.headers.origin,h.allowedOrigins?{allowedOrigins:h.allowedOrigins}:{});if(!s.valid)return e.status(403).json(r.buildJsonRpcError(null,-32600,s.reason));const n=t.headers.accept;if(!r.validateAcceptHeader(n))return e.status(400).json(r.buildJsonRpcError(null,-32600,"Accept header must include both application/json and text/event-stream"));const a=r.negotiateProtocol(t.headers);if(!a.ok)return e.status(426).json({error:"Unsupported MCP protocol version",supported:a.supported});const i=r.parseJsonRpc(t.body);if(!i)return e.status(400).json(r.buildJsonRpcError(null,-32600,"Invalid JSON-RPC 2.0 request"));const y=r.wantsEventStream(n),C=i.method==="initialize";try{const l=await r.dispatchMcpMethod(i.method,i.params,{semanticLayer:c,extractSecurityContext:d,rawRequest:t,rawResponse:e,negotiatedProtocol:a.negotiated});if(r.isNotification(i))return e.status(202).end();const j=C&&l&&typeof l=="object"&&"sessionId"in l?l.sessionId:void 0;j&&e.setHeader(r.MCP_SESSION_ID_HEADER,j);const v=r.buildJsonRpcResult(i.id??null,l);if(y){const b=r.primeEventId();return e.status(200),e.setHeader("Content-Type","text/event-stream"),e.setHeader("Cache-Control","no-cache"),e.setHeader("Connection","keep-alive"),e.write(`id: ${b}
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const R=require("express"),M=require("cors"),r=require("../mcp-transport-oPf8JYHv.cjs");function S(f){const{cubes:m,drizzle:E,schema:$,extractSecurityContext:d,engineType:I,cors:g,basePath:p="/cubejs-api/v1",jsonLimit:x="10mb",cache:P,mcp:h={enabled:!0}}=f;if(!m||m.length===0)throw new Error("At least one cube must be provided in the cubes array");const u=R.Router();g&&u.use(M(g)),u.use(R.json({limit:x})),u.use(R.urlencoded({extended:!0,limit:x}));const c=new r.SemanticLayerCompiler({drizzle:E,schema:$,engineType:I,cache:P});if(m.forEach(o=>{c.registerCube(o)}),u.post(`${p}/load`,async(o,t)=>{try{const e=o.body.query||o.body,s=await d(o,t),n=c.validateQuery(e);if(!n.isValid)return t.status(400).json(r.formatErrorResponse(`Query validation failed: ${n.errors.join(", ")}`,400));const a=o.headers["x-cache-control"]==="no-cache",i=await c.executeMultiCubeQuery(e,s,{skipCache:a});t.json(r.formatCubeResponse(e,i,c))}catch(e){console.error("Query execution error:",e),t.status(500).json(r.formatErrorResponse(e instanceof Error?e.message:"Query execution failed",500))}}),u.get(`${p}/load`,async(o,t)=>{try{const e=o.query.query;if(!e)return t.status(400).json(r.formatErrorResponse("Query parameter is required",400));let s;try{s=JSON.parse(e)}catch{return t.status(400).json(r.formatErrorResponse("Invalid JSON in query parameter",400))}const n=await d(o,t),a=c.validateQuery(s);if(!a.isValid)return t.status(400).json(r.formatErrorResponse(`Query validation failed: ${a.errors.join(", ")}`,400));const i=o.headers["x-cache-control"]==="no-cache",y=await c.executeMultiCubeQuery(s,n,{skipCache:i});t.json(r.formatCubeResponse(s,y,c))}catch(e){console.error("Query execution error:",e),t.status(500).json(r.formatErrorResponse(e instanceof Error?e.message:"Query execution failed",500))}}),u.post(`${p}/batch`,async(o,t)=>{try{const{queries:e}=o.body;if(!e||!Array.isArray(e))return t.status(400).json(r.formatErrorResponse('Request body must contain a "queries" array',400));if(e.length===0)return t.status(400).json(r.formatErrorResponse("Queries array cannot be empty",400));const s=await d(o,t),n=o.headers["x-cache-control"]==="no-cache",a=await r.handleBatchRequest(e,s,c,{skipCache:n});t.json(a)}catch(e){console.error("Batch execution error:",e),t.status(500).json(r.formatErrorResponse(e instanceof Error?e.message:"Batch execution failed",500))}}),u.get(`${p}/meta`,(o,t)=>{try{const e=c.getMetadata();t.json(r.formatMetaResponse(e))}catch(e){console.error("Metadata error:",e),t.status(500).json(r.formatErrorResponse(e instanceof Error?e.message:"Failed to fetch metadata",500))}}),u.post(`${p}/sql`,async(o,t)=>{try{const e=o.body,s=await d(o,t),n=c.validateQuery(e);if(!n.isValid)return t.status(400).json(r.formatErrorResponse(`Query validation failed: ${n.errors.join(", ")}`,400));const a=e.measures?.[0]||e.dimensions?.[0];if(!a)return t.status(400).json(r.formatErrorResponse("No measures or dimensions specified",400));const i=a.split(".")[0],y=await c.generateSQL(i,e,s);t.json(r.formatSqlResponse(e,y))}catch(e){console.error("SQL generation error:",e),t.status(500).json(r.formatErrorResponse(e instanceof Error?e.message:"SQL generation failed",500))}}),u.get(`${p}/sql`,async(o,t)=>{try{const e=o.query.query;if(!e)return t.status(400).json(r.formatErrorResponse("Query parameter is required",400));const s=JSON.parse(e),n=await d(o,t),a=c.validateQuery(s);if(!a.isValid)return t.status(400).json(r.formatErrorResponse(`Query validation failed: ${a.errors.join(", ")}`,400));const i=s.measures?.[0]||s.dimensions?.[0];if(!i)return t.status(400).json(r.formatErrorResponse("No measures or dimensions specified",400));const y=i.split(".")[0],C=await c.generateSQL(y,s,n);t.json(r.formatSqlResponse(s,C))}catch(e){console.error("SQL generation error:",e),t.status(500).json(r.formatErrorResponse(e instanceof Error?e.message:"SQL generation failed",500))}}),u.post(`${p}/dry-run`,async(o,t)=>{try{const e=o.body.query||o.body,s=await d(o,t),n=await r.handleDryRun(e,s,c);t.json(n)}catch(e){console.error("Dry-run error:",e),t.status(400).json({error:e instanceof Error?e.message:"Dry-run validation failed",valid:!1})}}),u.get(`${p}/dry-run`,async(o,t)=>{try{const e=o.query.query;if(!e)return t.status(400).json({error:"Query parameter is required",valid:!1});const s=JSON.parse(e),n=await d(o,t),a=await r.handleDryRun(s,n,c);t.json(a)}catch(e){console.error("Dry-run error:",e),t.status(400).json({error:e instanceof Error?e.message:"Dry-run validation failed",valid:!1})}}),u.post(`${p}/explain`,async(o,t)=>{try{const e=o.body.query||o.body,s=o.body.options||{},n=await d(o,t),a=c.validateQuery(e);if(!a.isValid)return t.status(400).json({error:`Query validation failed: ${a.errors.join(", ")}`});const i=await c.explainQuery(e,n,s);t.json(i)}catch(e){console.error("Explain error:",e),t.status(500).json({error:e instanceof Error?e.message:"Explain query failed"})}}),h.enabled!==!1){const o=h.basePath??"/mcp";u.post(`${o}`,async(t,e)=>{const s=r.validateOriginHeader(t.headers.origin,h.allowedOrigins?{allowedOrigins:h.allowedOrigins}:{});if(!s.valid)return e.status(403).json(r.buildJsonRpcError(null,-32600,s.reason));const n=t.headers.accept;if(!r.validateAcceptHeader(n))return e.status(400).json(r.buildJsonRpcError(null,-32600,"Accept header must include both application/json and text/event-stream"));const a=r.negotiateProtocol(t.headers);if(!a.ok)return e.status(426).json({error:"Unsupported MCP protocol version",supported:a.supported});const i=r.parseJsonRpc(t.body);if(!i)return e.status(400).json(r.buildJsonRpcError(null,-32600,"Invalid JSON-RPC 2.0 request"));const y=r.wantsEventStream(n),C=i.method==="initialize";try{const l=await r.dispatchMcpMethod(i.method,i.params,{semanticLayer:c,extractSecurityContext:d,rawRequest:t,rawResponse:e,negotiatedProtocol:a.negotiated});if(r.isNotification(i))return e.status(202).end();const j=C&&l&&typeof l=="object"&&"sessionId"in l?l.sessionId:void 0;j&&e.setHeader(r.MCP_SESSION_ID_HEADER,j);const v=r.buildJsonRpcResult(i.id??null,l);if(y){const b=r.primeEventId();return e.status(200),e.setHeader("Content-Type","text/event-stream"),e.setHeader("Cache-Control","no-cache"),e.setHeader("Connection","keep-alive"),e.write(`id: ${b}
2
2
 
3
3
  `),e.write(r.serializeSseEvent(v,b)),e.end()}return e.json(v)}catch(l){if(r.isNotification(i))return console.error("MCP notification processing error:",l),e.status(202).end();console.error("MCP RPC error:",l);const j=l?.code??-32603,v=l?.data,b=l.message||"MCP request failed",w=r.buildJsonRpcError(i.id??null,j,b,v);if(y){const Q=r.primeEventId();return e.status(200),e.setHeader("Content-Type","text/event-stream"),e.setHeader("Cache-Control","no-cache"),e.setHeader("Connection","keep-alive"),e.write(`id: ${Q}
4
4
 
@@ -1,6 +1,6 @@
1
1
  import R, { Router as L } from "express";
2
2
  import A from "cors";
3
- import { S as J, o as c, f as M, h as D, a as _, b as P, c as H, v as V, d as C, e as z, n as B, p as T, w as F, g as U, k as I, M as G, l as K, m as w, s as Q } from "../mcp-transport-DHBUNdYg.js";
3
+ import { S as J, o as c, f as M, h as D, a as _, b as P, c as H, v as V, d as C, e as z, n as B, p as T, w as F, g as U, k as I, M as G, l as K, m as w, s as Q } from "../mcp-transport-lkEjNwDH.js";
4
4
  function W(f) {
5
5
  const {
6
6
  cubes: m,
@@ -1,4 +1,4 @@
1
- "use strict";var N=Object.create;var Q=Object.defineProperty;var O=Object.getOwnPropertyDescriptor;var J=Object.getOwnPropertyNames;var k=Object.getPrototypeOf,A=Object.prototype.hasOwnProperty;var L=(d,n,g,f)=>{if(n&&typeof n=="object"||typeof n=="function")for(let y of J(n))!A.call(d,y)&&y!==g&&Q(d,y,{get:()=>n[y],enumerable:!(f=O(n,y))||f.enumerable});return d};var D=(d,n,g)=>(g=d!=null?N(k(d)):{},L(n||!d||!d.__esModule?Q(g,"default",{value:d,enumerable:!0}):g,d));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("../mcp-transport-B37JTeww.cjs"),x=function(n,g,f){const{cubes:y,drizzle:$,schema:j,extractSecurityContext:m,engineType:I,cors:q,basePath:h="/cubejs-api/v1",bodyLimit:b=10485760,cache:M,mcp:v={enabled:!0}}=g;if(!y||y.length===0)return f(new Error("At least one cube must be provided in the cubes array"));q&&n.register(import("@fastify/cors"),q),n.addHook("onRequest",async(r,o)=>{r.method==="POST"&&(r.body=void 0)});const u=new t.SemanticLayerCompiler({drizzle:$,schema:j,engineType:I,cache:M});if(y.forEach(r=>{u.registerCube(r)}),n.post(`${h}/load`,{bodyLimit:b,schema:{body:{type:"object",additionalProperties:!0}}},async(r,o)=>{try{const e=r.body,s=e.query||e,a=await m(r),i=u.validateQuery(s);if(!i.isValid)return o.status(400).send(t.formatErrorResponse(`Query validation failed: ${i.errors.join(", ")}`,400));const c=r.headers["x-cache-control"]==="no-cache",l=await u.executeMultiCubeQuery(s,a,{skipCache:c});return t.formatCubeResponse(s,l,u)}catch(e){return r.log.error(e,"Query execution error"),o.status(500).send(t.formatErrorResponse(e instanceof Error?e.message:"Query execution failed",500))}}),n.get(`${h}/load`,{schema:{querystring:{type:"object",properties:{query:{type:"string"}},required:["query"]}}},async(r,o)=>{try{const{query:e}=r.query;let s;try{s=JSON.parse(e)}catch{return o.status(400).send(t.formatErrorResponse("Invalid JSON in query parameter",400))}const a=await m(r),i=u.validateQuery(s);if(!i.isValid)return o.status(400).send(t.formatErrorResponse(`Query validation failed: ${i.errors.join(", ")}`,400));const c=r.headers["x-cache-control"]==="no-cache",l=await u.executeMultiCubeQuery(s,a,{skipCache:c});return t.formatCubeResponse(s,l,u)}catch(e){return r.log.error(e,"Query execution error"),o.status(500).send(t.formatErrorResponse(e instanceof Error?e.message:"Query execution failed",500))}}),n.post(`${h}/batch`,{bodyLimit:b,schema:{body:{type:"object",required:["queries"],properties:{queries:{type:"array",items:{type:"object"}}}}}},async(r,o)=>{try{const{queries:e}=r.body;if(!e||!Array.isArray(e))return o.status(400).send(t.formatErrorResponse('Request body must contain a "queries" array',400));if(e.length===0)return o.status(400).send(t.formatErrorResponse("Queries array cannot be empty",400));const s=await m(r),a=r.headers["x-cache-control"]==="no-cache";return await t.handleBatchRequest(e,s,u,{skipCache:a})}catch(e){return r.log.error(e,"Batch execution error"),o.status(500).send(t.formatErrorResponse(e instanceof Error?e.message:"Batch execution failed",500))}}),n.get(`${h}/meta`,async(r,o)=>{try{const e=u.getMetadata();return t.formatMetaResponse(e)}catch(e){return r.log.error(e,"Metadata error"),o.status(500).send(t.formatErrorResponse(e instanceof Error?e.message:"Failed to fetch metadata",500))}}),n.post(`${h}/sql`,{bodyLimit:b,schema:{body:{type:"object",additionalProperties:!0}}},async(r,o)=>{try{const e=r.body,s=await m(r),a=u.validateQuery(e);if(!a.isValid)return o.status(400).send(t.formatErrorResponse(`Query validation failed: ${a.errors.join(", ")}`,400));const i=e.measures?.[0]||e.dimensions?.[0];if(!i)return o.status(400).send(t.formatErrorResponse("No measures or dimensions specified",400));const c=i.split(".")[0],l=await u.generateSQL(c,e,s);return t.formatSqlResponse(e,l)}catch(e){return r.log.error(e,"SQL generation error"),o.status(500).send(t.formatErrorResponse(e instanceof Error?e.message:"SQL generation failed",500))}}),n.get(`${h}/sql`,{schema:{querystring:{type:"object",properties:{query:{type:"string"}},required:["query"]}}},async(r,o)=>{try{const{query:e}=r.query,s=JSON.parse(e),a=await m(r),i=u.validateQuery(s);if(!i.isValid)return o.status(400).send(t.formatErrorResponse(`Query validation failed: ${i.errors.join(", ")}`,400));const c=s.measures?.[0]||s.dimensions?.[0];if(!c)return o.status(400).send(t.formatErrorResponse("No measures or dimensions specified",400));const l=c.split(".")[0],w=await u.generateSQL(l,s,a);return t.formatSqlResponse(s,w)}catch(e){return r.log.error(e,"SQL generation error"),o.status(500).send(t.formatErrorResponse(e instanceof Error?e.message:"SQL generation failed",500))}}),n.post(`${h}/dry-run`,{bodyLimit:b,schema:{body:{type:"object",additionalProperties:!0}}},async(r,o)=>{try{const e=r.body,s=e.query||e,a=await m(r);return await t.handleDryRun(s,a,u)}catch(e){return r.log.error(e,"Dry-run error"),o.status(400).send({error:e instanceof Error?e.message:"Dry-run validation failed",valid:!1})}}),n.get(`${h}/dry-run`,{schema:{querystring:{type:"object",properties:{query:{type:"string"}},required:["query"]}}},async(r,o)=>{try{const{query:e}=r.query,s=JSON.parse(e),a=await m(r);return await t.handleDryRun(s,a,u)}catch(e){return r.log.error(e,"Dry-run error"),o.status(400).send({error:e instanceof Error?e.message:"Dry-run validation failed",valid:!1})}}),n.post(`${h}/explain`,{bodyLimit:b,schema:{body:{type:"object",additionalProperties:!0}}},async(r,o)=>{try{const e=r.body,s=e.query||e,a=e.options||{},i=await m(r),c=u.validateQuery(s);return c.isValid?await u.explainQuery(s,i,a):o.status(400).send({error:`Query validation failed: ${c.errors.join(", ")}`})}catch(e){return r.log.error(e,"Explain error"),o.status(500).send({error:e instanceof Error?e.message:"Explain query failed"})}}),v.enabled!==!1){const r=v.basePath??"/mcp";n.post(`${r}`,{bodyLimit:b,schema:{body:{type:"object",additionalProperties:!0}}},async(o,e)=>{const s=t.validateOriginHeader(o.headers.origin,v.allowedOrigins?{allowedOrigins:v.allowedOrigins}:{});if(!s.valid)return e.status(403).send(t.buildJsonRpcError(null,-32600,s.reason));const a=o.headers.accept;if(!t.validateAcceptHeader(a))return e.status(400).send(t.buildJsonRpcError(null,-32600,"Accept header must include both application/json and text/event-stream"));const i=t.negotiateProtocol(o.headers);if(!i.ok)return e.status(426).send({error:"Unsupported MCP protocol version",supported:i.supported});const c=t.parseJsonRpc(o.body);if(!c)return e.status(400).send(t.buildJsonRpcError(null,-32600,"Invalid JSON-RPC 2.0 request"));const l=t.wantsEventStream(a),w=c.method==="initialize";try{const p=await t.dispatchMcpMethod(c.method,c.params,{semanticLayer:u,extractSecurityContext:m,rawRequest:o,rawResponse:e,negotiatedProtocol:i.negotiated});if(t.isNotification(c))return e.status(202).send();const R=w&&p&&typeof p=="object"&&"sessionId"in p?p.sessionId:void 0;R&&e.header(t.MCP_SESSION_ID_HEADER,R);const E=t.buildJsonRpcResult(c.id??null,p);if(l){const C=t.primeEventId();e.header("Content-Type","text/event-stream").header("Cache-Control","no-cache").header("Connection","keep-alive").send(`id: ${C}
1
+ "use strict";var N=Object.create;var Q=Object.defineProperty;var O=Object.getOwnPropertyDescriptor;var J=Object.getOwnPropertyNames;var k=Object.getPrototypeOf,A=Object.prototype.hasOwnProperty;var L=(d,n,g,f)=>{if(n&&typeof n=="object"||typeof n=="function")for(let y of J(n))!A.call(d,y)&&y!==g&&Q(d,y,{get:()=>n[y],enumerable:!(f=O(n,y))||f.enumerable});return d};var D=(d,n,g)=>(g=d!=null?N(k(d)):{},L(n||!d||!d.__esModule?Q(g,"default",{value:d,enumerable:!0}):g,d));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("../mcp-transport-oPf8JYHv.cjs"),x=function(n,g,f){const{cubes:y,drizzle:$,schema:j,extractSecurityContext:m,engineType:I,cors:q,basePath:h="/cubejs-api/v1",bodyLimit:b=10485760,cache:M,mcp:v={enabled:!0}}=g;if(!y||y.length===0)return f(new Error("At least one cube must be provided in the cubes array"));q&&n.register(import("@fastify/cors"),q),n.addHook("onRequest",async(r,o)=>{r.method==="POST"&&(r.body=void 0)});const u=new t.SemanticLayerCompiler({drizzle:$,schema:j,engineType:I,cache:M});if(y.forEach(r=>{u.registerCube(r)}),n.post(`${h}/load`,{bodyLimit:b,schema:{body:{type:"object",additionalProperties:!0}}},async(r,o)=>{try{const e=r.body,s=e.query||e,a=await m(r),i=u.validateQuery(s);if(!i.isValid)return o.status(400).send(t.formatErrorResponse(`Query validation failed: ${i.errors.join(", ")}`,400));const c=r.headers["x-cache-control"]==="no-cache",l=await u.executeMultiCubeQuery(s,a,{skipCache:c});return t.formatCubeResponse(s,l,u)}catch(e){return r.log.error(e,"Query execution error"),o.status(500).send(t.formatErrorResponse(e instanceof Error?e.message:"Query execution failed",500))}}),n.get(`${h}/load`,{schema:{querystring:{type:"object",properties:{query:{type:"string"}},required:["query"]}}},async(r,o)=>{try{const{query:e}=r.query;let s;try{s=JSON.parse(e)}catch{return o.status(400).send(t.formatErrorResponse("Invalid JSON in query parameter",400))}const a=await m(r),i=u.validateQuery(s);if(!i.isValid)return o.status(400).send(t.formatErrorResponse(`Query validation failed: ${i.errors.join(", ")}`,400));const c=r.headers["x-cache-control"]==="no-cache",l=await u.executeMultiCubeQuery(s,a,{skipCache:c});return t.formatCubeResponse(s,l,u)}catch(e){return r.log.error(e,"Query execution error"),o.status(500).send(t.formatErrorResponse(e instanceof Error?e.message:"Query execution failed",500))}}),n.post(`${h}/batch`,{bodyLimit:b,schema:{body:{type:"object",required:["queries"],properties:{queries:{type:"array",items:{type:"object"}}}}}},async(r,o)=>{try{const{queries:e}=r.body;if(!e||!Array.isArray(e))return o.status(400).send(t.formatErrorResponse('Request body must contain a "queries" array',400));if(e.length===0)return o.status(400).send(t.formatErrorResponse("Queries array cannot be empty",400));const s=await m(r),a=r.headers["x-cache-control"]==="no-cache";return await t.handleBatchRequest(e,s,u,{skipCache:a})}catch(e){return r.log.error(e,"Batch execution error"),o.status(500).send(t.formatErrorResponse(e instanceof Error?e.message:"Batch execution failed",500))}}),n.get(`${h}/meta`,async(r,o)=>{try{const e=u.getMetadata();return t.formatMetaResponse(e)}catch(e){return r.log.error(e,"Metadata error"),o.status(500).send(t.formatErrorResponse(e instanceof Error?e.message:"Failed to fetch metadata",500))}}),n.post(`${h}/sql`,{bodyLimit:b,schema:{body:{type:"object",additionalProperties:!0}}},async(r,o)=>{try{const e=r.body,s=await m(r),a=u.validateQuery(e);if(!a.isValid)return o.status(400).send(t.formatErrorResponse(`Query validation failed: ${a.errors.join(", ")}`,400));const i=e.measures?.[0]||e.dimensions?.[0];if(!i)return o.status(400).send(t.formatErrorResponse("No measures or dimensions specified",400));const c=i.split(".")[0],l=await u.generateSQL(c,e,s);return t.formatSqlResponse(e,l)}catch(e){return r.log.error(e,"SQL generation error"),o.status(500).send(t.formatErrorResponse(e instanceof Error?e.message:"SQL generation failed",500))}}),n.get(`${h}/sql`,{schema:{querystring:{type:"object",properties:{query:{type:"string"}},required:["query"]}}},async(r,o)=>{try{const{query:e}=r.query,s=JSON.parse(e),a=await m(r),i=u.validateQuery(s);if(!i.isValid)return o.status(400).send(t.formatErrorResponse(`Query validation failed: ${i.errors.join(", ")}`,400));const c=s.measures?.[0]||s.dimensions?.[0];if(!c)return o.status(400).send(t.formatErrorResponse("No measures or dimensions specified",400));const l=c.split(".")[0],w=await u.generateSQL(l,s,a);return t.formatSqlResponse(s,w)}catch(e){return r.log.error(e,"SQL generation error"),o.status(500).send(t.formatErrorResponse(e instanceof Error?e.message:"SQL generation failed",500))}}),n.post(`${h}/dry-run`,{bodyLimit:b,schema:{body:{type:"object",additionalProperties:!0}}},async(r,o)=>{try{const e=r.body,s=e.query||e,a=await m(r);return await t.handleDryRun(s,a,u)}catch(e){return r.log.error(e,"Dry-run error"),o.status(400).send({error:e instanceof Error?e.message:"Dry-run validation failed",valid:!1})}}),n.get(`${h}/dry-run`,{schema:{querystring:{type:"object",properties:{query:{type:"string"}},required:["query"]}}},async(r,o)=>{try{const{query:e}=r.query,s=JSON.parse(e),a=await m(r);return await t.handleDryRun(s,a,u)}catch(e){return r.log.error(e,"Dry-run error"),o.status(400).send({error:e instanceof Error?e.message:"Dry-run validation failed",valid:!1})}}),n.post(`${h}/explain`,{bodyLimit:b,schema:{body:{type:"object",additionalProperties:!0}}},async(r,o)=>{try{const e=r.body,s=e.query||e,a=e.options||{},i=await m(r),c=u.validateQuery(s);return c.isValid?await u.explainQuery(s,i,a):o.status(400).send({error:`Query validation failed: ${c.errors.join(", ")}`})}catch(e){return r.log.error(e,"Explain error"),o.status(500).send({error:e instanceof Error?e.message:"Explain query failed"})}}),v.enabled!==!1){const r=v.basePath??"/mcp";n.post(`${r}`,{bodyLimit:b,schema:{body:{type:"object",additionalProperties:!0}}},async(o,e)=>{const s=t.validateOriginHeader(o.headers.origin,v.allowedOrigins?{allowedOrigins:v.allowedOrigins}:{});if(!s.valid)return e.status(403).send(t.buildJsonRpcError(null,-32600,s.reason));const a=o.headers.accept;if(!t.validateAcceptHeader(a))return e.status(400).send(t.buildJsonRpcError(null,-32600,"Accept header must include both application/json and text/event-stream"));const i=t.negotiateProtocol(o.headers);if(!i.ok)return e.status(426).send({error:"Unsupported MCP protocol version",supported:i.supported});const c=t.parseJsonRpc(o.body);if(!c)return e.status(400).send(t.buildJsonRpcError(null,-32600,"Invalid JSON-RPC 2.0 request"));const l=t.wantsEventStream(a),w=c.method==="initialize";try{const p=await t.dispatchMcpMethod(c.method,c.params,{semanticLayer:u,extractSecurityContext:m,rawRequest:o,rawResponse:e,negotiatedProtocol:i.negotiated});if(t.isNotification(c))return e.status(202).send();const R=w&&p&&typeof p=="object"&&"sessionId"in p?p.sessionId:void 0;R&&e.header(t.MCP_SESSION_ID_HEADER,R);const E=t.buildJsonRpcResult(c.id??null,p);if(l){const C=t.primeEventId();e.header("Content-Type","text/event-stream").header("Cache-Control","no-cache").header("Connection","keep-alive").send(`id: ${C}
2
2
 
3
3
  ${t.serializeSseEvent(E,C)}`);return}return e.send(E)}catch(p){if(t.isNotification(c))return o.log.error(p,"MCP notification processing error"),e.status(202).send();o.log.error(p,"MCP RPC error");const R=p?.code??-32603,E=p?.data,C=p.message||"MCP request failed",S=t.buildJsonRpcError(c.id??null,R,C,E);if(l){const P=t.primeEventId();e.header("Content-Type","text/event-stream").header("Cache-Control","no-cache").header("Connection","keep-alive").send(`id: ${P}
4
4
 
@@ -1,4 +1,4 @@
1
- import { S as D, o as u, f as $, h as H, a as V, b as j, c as M, v as z, d as C, e as T, n as _, p as B, w as F, g as U, k as I, M as G, l as K, m as q, s as R } from "../mcp-transport-DHBUNdYg.js";
1
+ import { S as D, o as u, f as $, h as H, a as V, b as j, c as M, v as z, d as C, e as T, n as _, p as B, w as F, g as U, k as I, M as G, l as K, m as q, s as R } from "../mcp-transport-lkEjNwDH.js";
2
2
  const k = function(n, N, E) {
3
3
  const {
4
4
  cubes: w,
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const $=require("hono"),n=require("../mcp-transport-B37JTeww.cjs");var O=C=>{const d={...{origin:"*",allowMethods:["GET","HEAD","PUT","POST","DELETE","PATCH"],allowHeaders:[],exposeHeaders:[]},...C},Q=(l=>typeof l=="string"?l==="*"?()=>l:a=>l===a?a:null:typeof l=="function"?l:a=>l.includes(a)?a:null)(d.origin),y=(l=>typeof l=="function"?l:Array.isArray(l)?()=>l:()=>[])(d.allowMethods);return async function(a,f){function q(u,s){a.res.headers.set(u,s)}const w=await Q(a.req.header("origin")||"",a);if(w&&q("Access-Control-Allow-Origin",w),d.credentials&&q("Access-Control-Allow-Credentials","true"),d.exposeHeaders?.length&&q("Access-Control-Expose-Headers",d.exposeHeaders.join(",")),a.req.method==="OPTIONS"){d.origin!=="*"&&q("Vary","Origin"),d.maxAge!=null&&q("Access-Control-Max-Age",d.maxAge.toString());const u=await y(a.req.header("origin")||"",a);u.length&&q("Access-Control-Allow-Methods",u.join(","));let s=d.allowHeaders;if(!s?.length){const r=a.req.header("Access-Control-Request-Headers");r&&(s=r.split(/\s*,\s*/))}return s?.length&&(q("Access-Control-Allow-Headers",s.join(",")),a.res.headers.append("Vary","Access-Control-Request-Headers")),a.res.headers.delete("Content-Length"),a.res.headers.delete("Content-Type"),new Response(null,{headers:a.res.headers,status:204,statusText:"No Content"})}await f(),d.origin!=="*"&&a.header("Vary","Origin",{append:!0})}};function T(C){const{cubes:j,drizzle:d,schema:Q,extractSecurityContext:y,engineType:l,cors:a,basePath:f="/cubejs-api/v1",cache:q,mcp:w={enabled:!0}}=C;if(!j||j.length===0)throw new Error("At least one cube must be provided in the cubes array");const u=new $.Hono;a&&u.use("/*",O(a));const s=new n.SemanticLayerCompiler({drizzle:d,schema:Q,engineType:l,cache:q});if(j.forEach(r=>{s.registerCube(r)}),u.post(`${f}/load`,async r=>{try{const e=await r.req.json(),o=e.query||e,i=await y(r),t=s.validateQuery(o);if(!t.isValid)return r.json({error:`Query validation failed: ${t.errors.join(", ")}`},400);const c=r.req.header("x-cache-control")==="no-cache",p=await s.executeMultiCubeQuery(o,i,{skipCache:c});return r.json(n.formatCubeResponse(o,p,s))}catch(e){return console.error("Query execution error:",e),r.json({error:e instanceof Error?e.message:"Query execution failed"},500)}}),u.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 i=await y(r),t=s.validateQuery(o);if(!t.isValid)return r.json({error:`Query validation failed: ${t.errors.join(", ")}`},400);const c=r.req.header("x-cache-control")==="no-cache",p=await s.executeMultiCubeQuery(o,i,{skipCache:c});return r.json(n.formatCubeResponse(o,p,s))}catch(e){return console.error("Query execution error:",e),r.json({error:e instanceof Error?e.message:"Query execution failed"},500)}}),u.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 i=await y(r),t=r.req.header("x-cache-control")==="no-cache",c=await n.handleBatchRequest(o,i,s,{skipCache:t});return r.json(c)}catch(e){return console.error("Batch execution error:",e),r.json({error:e instanceof Error?e.message:"Batch execution failed"},500)}}),u.get(`${f}/meta`,r=>{try{const e=s.getMetadata();return r.json(n.formatMetaResponse(e))}catch(e){return console.error("Metadata error:",e),r.json({error:e instanceof Error?e.message:"Failed to fetch metadata"},500)}}),u.post(`${f}/sql`,async r=>{try{const e=await r.req.json(),o=await y(r),i=s.validateQuery(e);if(!i.isValid)return r.json({error:`Query validation failed: ${i.errors.join(", ")}`},400);const t=e.measures?.[0]||e.dimensions?.[0];if(!t)return r.json({error:"No measures or dimensions specified"},400);const c=t.split(".")[0],p=await s.generateSQL(c,e,o);return r.json(n.formatSqlResponse(e,p))}catch(e){return console.error("SQL generation error:",e),r.json({error:e instanceof Error?e.message:"SQL generation failed"},500)}}),u.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),i=await y(r),t=s.validateQuery(o);if(!t.isValid)return r.json({error:`Query validation failed: ${t.errors.join(", ")}`},400);const c=o.measures?.[0]||o.dimensions?.[0];if(!c)return r.json({error:"No measures or dimensions specified"},400);const p=c.split(".")[0],g=await s.generateSQL(p,o,i);return r.json(n.formatSqlResponse(o,g))}catch(e){return console.error("SQL generation error:",e),r.json({error:e instanceof Error?e.message:"SQL generation failed"},500)}}),u.post(`${f}/dry-run`,async r=>{try{const e=await r.req.json(),o=e.query||e,i=await y(r),t=await n.handleDryRun(o,i,s);return r.json(t)}catch(e){return console.error("Dry-run error:",e),r.json({error:e instanceof Error?e.message:"Dry-run validation failed",valid:!1},400)}}),u.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),i=await y(r),t=await n.handleDryRun(o,i,s);return r.json(t)}catch(e){return console.error("Dry-run error:",e),r.json({error:e instanceof Error?e.message:"Dry-run validation failed",valid:!1},400)}}),u.post(`${f}/explain`,async r=>{try{const e=await r.req.json(),o=e.query||e,i=e.options||{},t=await y(r),c=s.validateQuery(o);if(!c.isValid)return r.json({error:`Query validation failed: ${c.errors.join(", ")}`},400);const p=await s.explainQuery(o,t,i);return r.json(p)}catch(e){return console.error("Explain error:",e),r.json({error:e instanceof Error?e.message:"Explain query failed"},500)}}),w.enabled!==!1){const r={uri:"drizzle-cube://schema",name:"Cube Schema",description:"Current cube metadata as JSON",mimeType:"application/json",text:JSON.stringify(s.getMetadata(),null,2)},e=[...n.getDefaultResources(),r],o=n.getDefaultPrompts(),i=w.basePath??"/mcp";u.post(`${i}`,async t=>{const c=n.validateOriginHeader(t.req.header("origin"),w.allowedOrigins?{allowedOrigins:w.allowedOrigins}:{});if(!c.valid)return t.json(n.buildJsonRpcError(null,-32600,c.reason),403);const p=t.req.header("accept");if(!n.validateAcceptHeader(p))return t.json(n.buildJsonRpcError(null,-32600,"Accept header must include both application/json and text/event-stream"),400);const g=n.negotiateProtocol(t.req.header());if(!g.ok)return t.json({error:"Unsupported MCP protocol version",supported:g.supported},426);const P=await t.req.json().catch(()=>null),m=n.parseJsonRpc(P);if(!m)return t.json(n.buildJsonRpcError(null,-32600,"Invalid JSON-RPC 2.0 request"),400);const M=n.wantsEventStream(p),N=m.method==="initialize";try{const h=await n.dispatchMcpMethod(m.method,m.params,{semanticLayer:s,extractSecurityContext:y,rawRequest:t,rawResponse:null,negotiatedProtocol:g.negotiated,resources:e,prompts:o});if(n.isNotification(m))return t.body(null,202);const E=n.buildJsonRpcResult(m.id??null,h),S=N&&h&&typeof h=="object"&&"sessionId"in h?h.sessionId:void 0,v={};if(S&&(v[n.MCP_SESSION_ID_HEADER]=S),M){const b=new TextEncoder,R=n.primeEventId(),A=new ReadableStream({start(x){x.enqueue(b.encode(`id: ${R}
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const $=require("hono"),n=require("../mcp-transport-oPf8JYHv.cjs");var O=C=>{const d={...{origin:"*",allowMethods:["GET","HEAD","PUT","POST","DELETE","PATCH"],allowHeaders:[],exposeHeaders:[]},...C},Q=(l=>typeof l=="string"?l==="*"?()=>l:a=>l===a?a:null:typeof l=="function"?l:a=>l.includes(a)?a:null)(d.origin),y=(l=>typeof l=="function"?l:Array.isArray(l)?()=>l:()=>[])(d.allowMethods);return async function(a,f){function q(u,s){a.res.headers.set(u,s)}const w=await Q(a.req.header("origin")||"",a);if(w&&q("Access-Control-Allow-Origin",w),d.credentials&&q("Access-Control-Allow-Credentials","true"),d.exposeHeaders?.length&&q("Access-Control-Expose-Headers",d.exposeHeaders.join(",")),a.req.method==="OPTIONS"){d.origin!=="*"&&q("Vary","Origin"),d.maxAge!=null&&q("Access-Control-Max-Age",d.maxAge.toString());const u=await y(a.req.header("origin")||"",a);u.length&&q("Access-Control-Allow-Methods",u.join(","));let s=d.allowHeaders;if(!s?.length){const r=a.req.header("Access-Control-Request-Headers");r&&(s=r.split(/\s*,\s*/))}return s?.length&&(q("Access-Control-Allow-Headers",s.join(",")),a.res.headers.append("Vary","Access-Control-Request-Headers")),a.res.headers.delete("Content-Length"),a.res.headers.delete("Content-Type"),new Response(null,{headers:a.res.headers,status:204,statusText:"No Content"})}await f(),d.origin!=="*"&&a.header("Vary","Origin",{append:!0})}};function T(C){const{cubes:j,drizzle:d,schema:Q,extractSecurityContext:y,engineType:l,cors:a,basePath:f="/cubejs-api/v1",cache:q,mcp:w={enabled:!0}}=C;if(!j||j.length===0)throw new Error("At least one cube must be provided in the cubes array");const u=new $.Hono;a&&u.use("/*",O(a));const s=new n.SemanticLayerCompiler({drizzle:d,schema:Q,engineType:l,cache:q});if(j.forEach(r=>{s.registerCube(r)}),u.post(`${f}/load`,async r=>{try{const e=await r.req.json(),o=e.query||e,i=await y(r),t=s.validateQuery(o);if(!t.isValid)return r.json({error:`Query validation failed: ${t.errors.join(", ")}`},400);const c=r.req.header("x-cache-control")==="no-cache",p=await s.executeMultiCubeQuery(o,i,{skipCache:c});return r.json(n.formatCubeResponse(o,p,s))}catch(e){return console.error("Query execution error:",e),r.json({error:e instanceof Error?e.message:"Query execution failed"},500)}}),u.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 i=await y(r),t=s.validateQuery(o);if(!t.isValid)return r.json({error:`Query validation failed: ${t.errors.join(", ")}`},400);const c=r.req.header("x-cache-control")==="no-cache",p=await s.executeMultiCubeQuery(o,i,{skipCache:c});return r.json(n.formatCubeResponse(o,p,s))}catch(e){return console.error("Query execution error:",e),r.json({error:e instanceof Error?e.message:"Query execution failed"},500)}}),u.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 i=await y(r),t=r.req.header("x-cache-control")==="no-cache",c=await n.handleBatchRequest(o,i,s,{skipCache:t});return r.json(c)}catch(e){return console.error("Batch execution error:",e),r.json({error:e instanceof Error?e.message:"Batch execution failed"},500)}}),u.get(`${f}/meta`,r=>{try{const e=s.getMetadata();return r.json(n.formatMetaResponse(e))}catch(e){return console.error("Metadata error:",e),r.json({error:e instanceof Error?e.message:"Failed to fetch metadata"},500)}}),u.post(`${f}/sql`,async r=>{try{const e=await r.req.json(),o=await y(r),i=s.validateQuery(e);if(!i.isValid)return r.json({error:`Query validation failed: ${i.errors.join(", ")}`},400);const t=e.measures?.[0]||e.dimensions?.[0];if(!t)return r.json({error:"No measures or dimensions specified"},400);const c=t.split(".")[0],p=await s.generateSQL(c,e,o);return r.json(n.formatSqlResponse(e,p))}catch(e){return console.error("SQL generation error:",e),r.json({error:e instanceof Error?e.message:"SQL generation failed"},500)}}),u.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),i=await y(r),t=s.validateQuery(o);if(!t.isValid)return r.json({error:`Query validation failed: ${t.errors.join(", ")}`},400);const c=o.measures?.[0]||o.dimensions?.[0];if(!c)return r.json({error:"No measures or dimensions specified"},400);const p=c.split(".")[0],g=await s.generateSQL(p,o,i);return r.json(n.formatSqlResponse(o,g))}catch(e){return console.error("SQL generation error:",e),r.json({error:e instanceof Error?e.message:"SQL generation failed"},500)}}),u.post(`${f}/dry-run`,async r=>{try{const e=await r.req.json(),o=e.query||e,i=await y(r),t=await n.handleDryRun(o,i,s);return r.json(t)}catch(e){return console.error("Dry-run error:",e),r.json({error:e instanceof Error?e.message:"Dry-run validation failed",valid:!1},400)}}),u.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),i=await y(r),t=await n.handleDryRun(o,i,s);return r.json(t)}catch(e){return console.error("Dry-run error:",e),r.json({error:e instanceof Error?e.message:"Dry-run validation failed",valid:!1},400)}}),u.post(`${f}/explain`,async r=>{try{const e=await r.req.json(),o=e.query||e,i=e.options||{},t=await y(r),c=s.validateQuery(o);if(!c.isValid)return r.json({error:`Query validation failed: ${c.errors.join(", ")}`},400);const p=await s.explainQuery(o,t,i);return r.json(p)}catch(e){return console.error("Explain error:",e),r.json({error:e instanceof Error?e.message:"Explain query failed"},500)}}),w.enabled!==!1){const r={uri:"drizzle-cube://schema",name:"Cube Schema",description:"Current cube metadata as JSON",mimeType:"application/json",text:JSON.stringify(s.getMetadata(),null,2)},e=[...n.getDefaultResources(),r],o=n.getDefaultPrompts(),i=w.basePath??"/mcp";u.post(`${i}`,async t=>{const c=n.validateOriginHeader(t.req.header("origin"),w.allowedOrigins?{allowedOrigins:w.allowedOrigins}:{});if(!c.valid)return t.json(n.buildJsonRpcError(null,-32600,c.reason),403);const p=t.req.header("accept");if(!n.validateAcceptHeader(p))return t.json(n.buildJsonRpcError(null,-32600,"Accept header must include both application/json and text/event-stream"),400);const g=n.negotiateProtocol(t.req.header());if(!g.ok)return t.json({error:"Unsupported MCP protocol version",supported:g.supported},426);const P=await t.req.json().catch(()=>null),m=n.parseJsonRpc(P);if(!m)return t.json(n.buildJsonRpcError(null,-32600,"Invalid JSON-RPC 2.0 request"),400);const M=n.wantsEventStream(p),N=m.method==="initialize";try{const h=await n.dispatchMcpMethod(m.method,m.params,{semanticLayer:s,extractSecurityContext:y,rawRequest:t,rawResponse:null,negotiatedProtocol:g.negotiated,resources:e,prompts:o});if(n.isNotification(m))return t.body(null,202);const E=n.buildJsonRpcResult(m.id??null,h),S=N&&h&&typeof h=="object"&&"sessionId"in h?h.sessionId:void 0,v={};if(S&&(v[n.MCP_SESSION_ID_HEADER]=S),M){const b=new TextEncoder,R=n.primeEventId(),A=new ReadableStream({start(x){x.enqueue(b.encode(`id: ${R}
2
2
 
3
3
  `)),x.enqueue(b.encode(n.serializeSseEvent(E,R))),x.close()}});return new Response(A,{status:200,headers:{"Content-Type":"text/event-stream","Cache-Control":"no-cache",Connection:"keep-alive",...v}})}return t.json(E,200,v)}catch(h){if(n.isNotification(m))return console.error("MCP notification processing error:",h),t.body(null,202);console.error("MCP RPC error:",h);const E=h?.code??-32603,S=h?.data,v=h.message||"MCP request failed",b=n.buildJsonRpcError(m.id??null,E,v,S);if(M){const R=new TextEncoder,A=n.primeEventId(),x=new ReadableStream({start(H){H.enqueue(R.encode(`id: ${A}
4
4
 
@@ -1,5 +1,5 @@
1
1
  import { Hono as k } from "hono";
2
- import { S as L, f as I, h as V, a as B, b as N, c as O, v as z, d as Q, e as _, n as U, p as F, w as G, g as K, i as W, j as X, k as D, l as Y, M as Z, m as $, s as H } from "../mcp-transport-DHBUNdYg.js";
2
+ import { S as L, f as I, h as V, a as B, b as N, c as O, v as z, d as Q, e as _, n as U, p as F, w as G, g as K, i as W, j as X, k as D, l as Y, M as Z, m as $, s as H } from "../mcp-transport-lkEjNwDH.js";
3
3
  var ee = (q) => {
4
4
  const l = {
5
5
  ...{