drizzle-cube 0.4.4 → 0.4.7
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.
- package/dist/adapters/express/index.cjs +8 -4
- package/dist/adapters/express/index.d.ts +7 -0
- package/dist/adapters/express/index.js +189 -139
- package/dist/adapters/fastify/index.cjs +8 -4
- package/dist/adapters/fastify/index.d.ts +7 -0
- package/dist/adapters/fastify/index.js +209 -150
- package/dist/adapters/handler-D6l8AbJV.cjs +7 -0
- package/dist/adapters/handler-DsNgnIPK.js +458 -0
- package/dist/adapters/hono/index.cjs +8 -4
- package/dist/adapters/hono/index.d.ts +7 -0
- package/dist/adapters/hono/index.js +202 -144
- package/dist/adapters/{mcp-transport-BqLo4hKi.cjs → mcp-transport-BB998cy5.cjs} +21 -21
- package/dist/adapters/{mcp-transport-YHDZWKOi.js → mcp-transport-DFTCWene.js} +4 -0
- package/dist/adapters/nextjs/index.cjs +7 -3
- package/dist/adapters/nextjs/index.d.ts +14 -0
- package/dist/adapters/nextjs/index.js +220 -144
- package/dist/client/charts.js +13 -13
- package/dist/client/chunks/{RetentionCombinedChart-BK8N-MOQ.js → RetentionCombinedChart-CEI8KQ3t.js} +2 -2
- package/dist/client/chunks/{RetentionCombinedChart-BK8N-MOQ.js.map → RetentionCombinedChart-CEI8KQ3t.js.map} +1 -1
- package/dist/client/chunks/{analysis-builder-CNBmAGAO.js → analysis-builder-Dn8xpgPQ.js} +6 -6
- package/dist/client/chunks/{analysis-builder-CNBmAGAO.js.map → analysis-builder-Dn8xpgPQ.js.map} +1 -1
- package/dist/client/chunks/{analysis-builder-shared-INGGwyTG.js → analysis-builder-shared-D3xYzXlh.js} +2 -2
- package/dist/client/chunks/{analysis-builder-shared-INGGwyTG.js.map → analysis-builder-shared-D3xYzXlh.js.map} +1 -1
- package/dist/client/chunks/{chart-activity-grid-DvgTYQaE.js → chart-activity-grid-DStNr34n.js} +2 -2
- package/dist/client/chunks/{chart-activity-grid-DvgTYQaE.js.map → chart-activity-grid-DStNr34n.js.map} +1 -1
- package/dist/client/chunks/{chart-area-BKjd_STS.js → chart-area-QKKboTbq.js} +3 -3
- package/dist/client/chunks/{chart-area-BKjd_STS.js.map → chart-area-QKKboTbq.js.map} +1 -1
- package/dist/client/chunks/{chart-bar-DBI41w05.js → chart-bar-HpXF42H1.js} +2 -2
- package/dist/client/chunks/{chart-bar-DBI41w05.js.map → chart-bar-HpXF42H1.js.map} +1 -1
- package/dist/client/chunks/{chart-bubble-BD-1kneU.js → chart-bubble-Bf42A1-B.js} +2 -2
- package/dist/client/chunks/{chart-bubble-BD-1kneU.js.map → chart-bubble-Bf42A1-B.js.map} +1 -1
- package/dist/client/chunks/{chart-config-markdown-6fsr-U6_.js → chart-config-markdown-BXKL5TbQ.js} +8 -1
- package/dist/client/chunks/{chart-config-markdown-6fsr-U6_.js.map → chart-config-markdown-BXKL5TbQ.js.map} +1 -1
- package/dist/client/chunks/{chart-data-table-B74HLpAx.js → chart-data-table-Ch_1c1Zo.js} +2 -2
- package/dist/client/chunks/{chart-data-table-B74HLpAx.js.map → chart-data-table-Ch_1c1Zo.js.map} +1 -1
- package/dist/client/chunks/{chart-funnel-DQ9cW6j9.js → chart-funnel-C9kenCpp.js} +2 -2
- package/dist/client/chunks/{chart-funnel-DQ9cW6j9.js.map → chart-funnel-C9kenCpp.js.map} +1 -1
- package/dist/client/chunks/{chart-heat-map-CpIr4tbs.js → chart-heat-map-CYGemyPB.js} +2 -2
- package/dist/client/chunks/{chart-heat-map-CpIr4tbs.js.map → chart-heat-map-CYGemyPB.js.map} +1 -1
- package/dist/client/chunks/{chart-kpi-delta-DPcSazD3.js → chart-kpi-delta-CWCmi8vL.js} +3 -3
- package/dist/client/chunks/{chart-kpi-delta-DPcSazD3.js.map → chart-kpi-delta-CWCmi8vL.js.map} +1 -1
- package/dist/client/chunks/{chart-kpi-number-D62PzKZ1.js → chart-kpi-number-C-5m3qt5.js} +2 -2
- package/dist/client/chunks/{chart-kpi-number-D62PzKZ1.js.map → chart-kpi-number-C-5m3qt5.js.map} +1 -1
- package/dist/client/chunks/{chart-kpi-text-B6Z5tFV1.js → chart-kpi-text--t4ibPmx.js} +3 -3
- package/dist/client/chunks/{chart-kpi-text-B6Z5tFV1.js.map → chart-kpi-text--t4ibPmx.js.map} +1 -1
- package/dist/client/chunks/{chart-line-Ds4BYA0K.js → chart-line-C7YcMWBw.js} +3 -3
- package/dist/client/chunks/{chart-line-Ds4BYA0K.js.map → chart-line-C7YcMWBw.js.map} +1 -1
- package/dist/client/chunks/chart-markdown-Du4Z2iqK.js +2695 -0
- package/dist/client/chunks/chart-markdown-Du4Z2iqK.js.map +1 -0
- package/dist/client/chunks/{chart-pie-BBrLh0iU.js → chart-pie-C4SuxKSN.js} +2 -2
- package/dist/client/chunks/{chart-pie-BBrLh0iU.js.map → chart-pie-C4SuxKSN.js.map} +1 -1
- package/dist/client/chunks/{chart-radar-vr5FgjHT.js → chart-radar-BW3Z_-Ly.js} +2 -2
- package/dist/client/chunks/{chart-radar-vr5FgjHT.js.map → chart-radar-BW3Z_-Ly.js.map} +1 -1
- package/dist/client/chunks/{chart-radial-bar-BV_3Nm5P.js → chart-radial-bar-0Fa3aeP5.js} +2 -2
- package/dist/client/chunks/{chart-radial-bar-BV_3Nm5P.js.map → chart-radial-bar-0Fa3aeP5.js.map} +1 -1
- package/dist/client/chunks/{chart-sankey-CHROzr4S.js → chart-sankey-DBghfbg1.js} +2 -2
- package/dist/client/chunks/{chart-sankey-CHROzr4S.js.map → chart-sankey-DBghfbg1.js.map} +1 -1
- package/dist/client/chunks/{chart-scatter-DbRTU3FG.js → chart-scatter-DOVu1TNq.js} +2 -2
- package/dist/client/chunks/{chart-scatter-DbRTU3FG.js.map → chart-scatter-DOVu1TNq.js.map} +1 -1
- package/dist/client/chunks/{chart-sunburst-B-aPUzYL.js → chart-sunburst-LfNthFlZ.js} +2 -2
- package/dist/client/chunks/{chart-sunburst-B-aPUzYL.js.map → chart-sunburst-LfNthFlZ.js.map} +1 -1
- package/dist/client/chunks/{chart-tree-map-qY148fiC.js → chart-tree-map-DZtQPyWX.js} +2 -2
- package/dist/client/chunks/{chart-tree-map-qY148fiC.js.map → chart-tree-map-DZtQPyWX.js.map} +1 -1
- package/dist/client/chunks/{chartConfigRegistry-Di34paQH.js → chartConfigRegistry-C5dZm-ZK.js} +2 -2
- package/dist/client/chunks/{chartConfigRegistry-Di34paQH.js.map → chartConfigRegistry-C5dZm-ZK.js.map} +1 -1
- package/dist/client/chunks/{charts-core-T8UglYyq.js → charts-core-DmGfleFz.js} +199 -187
- package/dist/client/chunks/{charts-core-T8UglYyq.js.map → charts-core-DmGfleFz.js.map} +1 -1
- package/dist/client/chunks/{charts-loader-YnhJHubD.js → charts-loader-DcFWOUeV.js} +21 -21
- package/dist/client/chunks/{charts-loader-YnhJHubD.js.map → charts-loader-DcFWOUeV.js.map} +1 -1
- package/dist/client/chunks/{components-D0i1yQsk.js → components-Bdt1AmzS.js} +3521 -3369
- package/dist/client/chunks/components-Bdt1AmzS.js.map +1 -0
- package/dist/client/components/AgenticNotebook/AgentChatPanel.d.ts +8 -0
- package/dist/client/components/AgenticNotebook/ChatInput.d.ts +14 -0
- package/dist/client/components/AgenticNotebook/ChatMessage.d.ts +7 -0
- package/dist/client/components/AgenticNotebook/NotebookCanvas.d.ts +3 -0
- package/dist/client/components/AgenticNotebook/NotebookMarkdownBlock.d.ts +12 -0
- package/dist/client/components/AgenticNotebook/NotebookPortletBlock.d.ts +12 -0
- package/dist/client/components/AgenticNotebook/index.d.ts +34 -0
- package/dist/client/components/DashboardPortletCard.d.ts +3 -2
- package/dist/client/components.js +1 -1
- package/dist/client/hooks/dashboard/layoutUtils.d.ts +7 -0
- package/dist/client/hooks/dashboard/useDashboardController.d.ts +53 -0
- package/dist/client/hooks/dashboard/useGridLayoutEngine.d.ts +10 -0
- package/dist/client/hooks/dashboard/useRowLayoutEngine.d.ts +18 -0
- package/dist/client/hooks/useAgentChat.d.ts +36 -0
- package/dist/client/index.d.ts +6 -0
- package/dist/client/index.js +923 -187
- package/dist/client/index.js.map +1 -1
- package/dist/client/stores/notebookStore.d.ts +152 -0
- package/dist/client/styles.css +1 -1
- package/dist/client/utils.js +4 -4
- package/dist/client-bundle-stats.html +1 -1
- package/dist/server/index.cjs +101 -91
- package/dist/server/index.d.ts +155 -0
- package/dist/server/index.js +4423 -3609
- package/package.json +7 -1
- package/dist/client/chunks/chart-markdown-Rq6ORisB.js +0 -276
- package/dist/client/chunks/chart-markdown-Rq6ORisB.js.map +0 -1
- package/dist/client/chunks/components-D0i1yQsk.js.map +0 -1
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
"use strict";var O=Object.create;var
|
|
1
|
+
"use strict";var O=Object.create;var j=Object.defineProperty;var k=Object.getOwnPropertyDescriptor;var J=Object.getOwnPropertyNames;var L=Object.getPrototypeOf,D=Object.prototype.hasOwnProperty;var H=(l,n,b,C)=>{if(n&&typeof n=="object"||typeof n=="function")for(let f of J(n))!D.call(l,f)&&f!==b&&j(l,f,{get:()=>n[f],enumerable:!(C=k(n,f))||C.enumerable});return l};var T=(l,n,b)=>(b=l!=null?O(L(l)):{},H(n||!l||!l.__esModule?j(b,"default",{value:l,enumerable:!0}):b,l));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("../mcp-transport-BB998cy5.cjs"),i=require("../utils.cjs"),q=function(n,b,C){const{cubes:f,drizzle:I,schema:A,extractSecurityContext:g,engineType:M,cors:P,basePath:h="/cubejs-api/v1",bodyLimit:v=10485760,cache:N,mcp:E={enabled:!0},agent:R}=b;if(!f||f.length===0)return C(new Error("At least one cube must be provided in the cubes array"));P&&n.register(import("@fastify/cors"),P),n.addHook("onRequest",async(r,t)=>{r.method==="POST"&&(r.body=void 0)});const d=new u.SemanticLayerCompiler({drizzle:I,schema:A,engineType:M,cache:N});if(f.forEach(r=>{d.registerCube(r)}),n.post(`${h}/load`,{bodyLimit:v,schema:{body:{type:"object",additionalProperties:!0}}},async(r,t)=>{try{const e=r.body,o=e.query||e,s=await g(r),c=d.validateQuery(o);if(!c.isValid)return t.status(400).send(i.formatErrorResponse(`Query validation failed: ${c.errors.join(", ")}`,400));const a=r.headers["x-cache-control"]==="no-cache",y=await d.executeMultiCubeQuery(o,s,{skipCache:a});return i.formatCubeResponse(o,y,d)}catch(e){return r.log.error(e,"Query execution error"),t.status(500).send(i.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,t)=>{try{const{query:e}=r.query;let o;try{o=JSON.parse(e)}catch{return t.status(400).send(i.formatErrorResponse("Invalid JSON in query parameter",400))}const s=await g(r),c=d.validateQuery(o);if(!c.isValid)return t.status(400).send(i.formatErrorResponse(`Query validation failed: ${c.errors.join(", ")}`,400));const a=r.headers["x-cache-control"]==="no-cache",y=await d.executeMultiCubeQuery(o,s,{skipCache:a});return i.formatCubeResponse(o,y,d)}catch(e){return r.log.error(e,"Query execution error"),t.status(500).send(i.formatErrorResponse(e instanceof Error?e.message:"Query execution failed",500))}}),n.post(`${h}/batch`,{bodyLimit:v,schema:{body:{type:"object",required:["queries"],properties:{queries:{type:"array",items:{type:"object"}}}}}},async(r,t)=>{try{const{queries:e}=r.body;if(!e||!Array.isArray(e))return t.status(400).send(i.formatErrorResponse('Request body must contain a "queries" array',400));if(e.length===0)return t.status(400).send(i.formatErrorResponse("Queries array cannot be empty",400));const o=await g(r),s=r.headers["x-cache-control"]==="no-cache";return await i.handleBatchRequest(e,o,d,{skipCache:s})}catch(e){return r.log.error(e,"Batch execution error"),t.status(500).send(i.formatErrorResponse(e instanceof Error?e.message:"Batch execution failed",500))}}),n.get(`${h}/meta`,async(r,t)=>{try{const e=d.getMetadata();return i.formatMetaResponse(e)}catch(e){return r.log.error(e,"Metadata error"),t.status(500).send(i.formatErrorResponse(e instanceof Error?e.message:"Failed to fetch metadata",500))}}),n.post(`${h}/sql`,{bodyLimit:v,schema:{body:{type:"object",additionalProperties:!0}}},async(r,t)=>{try{const e=r.body,o=await g(r),s=d.validateQuery(e);if(!s.isValid)return t.status(400).send(i.formatErrorResponse(`Query validation failed: ${s.errors.join(", ")}`,400));const c=e.measures?.[0]||e.dimensions?.[0];if(!c)return t.status(400).send(i.formatErrorResponse("No measures or dimensions specified",400));const a=c.split(".")[0],y=await d.generateSQL(a,e,o);return i.formatSqlResponse(e,y)}catch(e){return r.log.error(e,"SQL generation error"),t.status(500).send(i.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,t)=>{try{const{query:e}=r.query,o=JSON.parse(e),s=await g(r),c=d.validateQuery(o);if(!c.isValid)return t.status(400).send(i.formatErrorResponse(`Query validation failed: ${c.errors.join(", ")}`,400));const a=o.measures?.[0]||o.dimensions?.[0];if(!a)return t.status(400).send(i.formatErrorResponse("No measures or dimensions specified",400));const y=a.split(".")[0],m=await d.generateSQL(y,o,s);return i.formatSqlResponse(o,m)}catch(e){return r.log.error(e,"SQL generation error"),t.status(500).send(i.formatErrorResponse(e instanceof Error?e.message:"SQL generation failed",500))}}),n.post(`${h}/dry-run`,{bodyLimit:v,schema:{body:{type:"object",additionalProperties:!0}}},async(r,t)=>{try{const e=r.body,o=e.query||e,s=await g(r);return await i.handleDryRun(o,s,d)}catch(e){return r.log.error(e,"Dry-run error"),t.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,t)=>{try{const{query:e}=r.query,o=JSON.parse(e),s=await g(r);return await i.handleDryRun(o,s,d)}catch(e){return r.log.error(e,"Dry-run error"),t.status(400).send({error:e instanceof Error?e.message:"Dry-run validation failed",valid:!1})}}),n.post(`${h}/explain`,{bodyLimit:v,schema:{body:{type:"object",additionalProperties:!0}}},async(r,t)=>{try{const e=r.body,o=e.query||e,s=e.options||{},c=await g(r),a=d.validateQuery(o);return a.isValid?await d.explainQuery(o,c,s):t.status(400).send({error:`Query validation failed: ${a.errors.join(", ")}`})}catch(e){return r.log.error(e,"Explain error"),t.status(500).send({error:e instanceof Error?e.message:"Explain query failed"})}}),R&&n.post(`${h}/agent/chat`,{bodyLimit:v,schema:{body:{type:"object",additionalProperties:!0}}},async(r,t)=>{try{const{handleAgentChat:e}=await Promise.resolve().then(()=>require("../handler-D6l8AbJV.cjs")),o=r.body,{message:s,sessionId:c}=o;if(!s||typeof s!="string")return t.status(400).send({error:"message is required and must be a string"});let a=(R.apiKey||"").trim();if(R.allowClientApiKey){const m=r.headers["x-agent-api-key"];m&&(a=m.trim())}if(!a)return t.status(401).send({error:"No API key configured. Set agent.apiKey in server config or send X-Agent-Api-Key header."});const y=await g(r);t.raw.writeHead(200,{"Content-Type":"text/event-stream","Cache-Control":"no-cache",Connection:"keep-alive"});try{const m=e({message:s,sessionId:c,semanticLayer:d,securityContext:y,agentConfig:R,apiKey:a});for await(const p of m)t.raw.write(`data: ${JSON.stringify(p)}
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
`)}catch(m){const p={type:"error",data:{message:m instanceof Error?m.message:"Stream failed"}};t.raw.write(`data: ${JSON.stringify(p)}
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
`)}finally{t.raw.end()}}catch(e){if(r.log.error(e,"Agent chat error"),!t.raw.headersSent)return t.status(500).send({error:e instanceof Error?e.message:"Agent chat failed"})}}),E.enabled!==!1){const r=E.basePath??"/mcp";n.post(`${r}`,{bodyLimit:v,schema:{body:{type:"object",additionalProperties:!0}}},async(t,e)=>{const o=u.validateOriginHeader(t.headers.origin,E.allowedOrigins?{allowedOrigins:E.allowedOrigins}:{});if(!o.valid)return e.status(403).send(u.buildJsonRpcError(null,-32600,o.reason));const s=t.headers.accept;if(!u.validateAcceptHeader(s))return e.status(400).send(u.buildJsonRpcError(null,-32600,"Accept header must include both application/json and text/event-stream"));const c=u.negotiateProtocol(t.headers);if(!c.ok)return e.status(426).send({error:"Unsupported MCP protocol version",supported:c.supported});const a=u.parseJsonRpc(t.body);if(!a)return e.status(400).send(u.buildJsonRpcError(null,-32600,"Invalid JSON-RPC 2.0 request"));const y=u.wantsEventStream(s),m=a.method==="initialize";try{const p=await u.dispatchMcpMethod(a.method,a.params,{semanticLayer:d,extractSecurityContext:g,rawRequest:t,rawResponse:e,negotiatedProtocol:c.negotiated});if(u.isNotification(a))return e.status(202).send();const w=m&&p&&typeof p=="object"&&"sessionId"in p?p.sessionId:void 0;w&&e.header(u.MCP_SESSION_ID_HEADER,w);const x=u.buildJsonRpcResult(a.id??null,p);if(y){const S=u.primeEventId();e.header("Content-Type","text/event-stream").header("Cache-Control","no-cache").header("Connection","keep-alive").send(`id: ${S}
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
${u.serializeSseEvent(x,S)}`);return}return e.send(x)}catch(p){if(u.isNotification(a))return t.log.error(p,"MCP notification processing error"),e.status(202).send();t.log.error(p,"MCP RPC error");const w=p?.code??-32603,x=p?.data,S=p.message||"MCP request failed",Q=u.buildJsonRpcError(a.id??null,w,S,x);if(y){const $=u.primeEventId();e.header("Content-Type","text/event-stream").header("Cache-Control","no-cache").header("Connection","keep-alive").send(`id: ${$}
|
|
8
|
+
|
|
9
|
+
${u.serializeSseEvent(Q,$)}`);return}return e.send(Q)}}),n.get(`${r}`,async(t,e)=>{const o=u.primeEventId();e.raw.writeHead(200,{"Content-Type":"text/event-stream","Cache-Control":"no-cache",Connection:"keep-alive"}),e.raw.write(u.serializeSseEvent({jsonrpc:"2.0",method:"mcp/ready",params:{protocol:"streamable-http"}},o,15e3));const s=setInterval(()=>{e.raw.write(`: keep-alive
|
|
10
|
+
|
|
11
|
+
`)},15e3);t.raw.on("close",()=>{clearInterval(s)})}),n.delete(`${r}`,async(t,e)=>e.status(405).send({error:"Session termination not supported"}))}n.setErrorHandler(async(r,t,e)=>{t.log.error(r,"Fastify cube adapter error"),e.statusCode<400&&e.status(500);const o=r instanceof Error?r:String(r);return i.formatErrorResponse(o,e.statusCode)}),C()};async function z(l,n){await l.register(q,n)}function K(l){const n=require("fastify")({logger:!0});return n.register(q,l),n}exports.createCubeApp=K;exports.cubePlugin=q;exports.registerCubeRoutes=z;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { FastifyPluginCallback, FastifyRequest, FastifyInstance } from 'fastify';
|
|
2
2
|
import { FastifyCorsOptions } from '@fastify/cors';
|
|
3
3
|
import { SemanticQuery, SecurityContext, DatabaseExecutor, DrizzleDatabase, Cube, CacheConfig } from '../../server';
|
|
4
|
+
import { AgentConfig } from '../../server/agent/types';
|
|
4
5
|
import { PostgresJsDatabase } from 'drizzle-orm/postgres-js';
|
|
5
6
|
import { MySql2Database } from 'drizzle-orm/mysql2';
|
|
6
7
|
import { BetterSQLite3Database } from 'drizzle-orm/better-sqlite3';
|
|
@@ -72,6 +73,12 @@ export interface FastifyAdapterOptions {
|
|
|
72
73
|
* @default { enabled: true }
|
|
73
74
|
*/
|
|
74
75
|
mcp?: MCPOptions;
|
|
76
|
+
/**
|
|
77
|
+
* Agent configuration for the agentic AI notebook feature.
|
|
78
|
+
* When provided, enables the POST /agent/chat SSE endpoint.
|
|
79
|
+
* Requires `@anthropic-ai/sdk` as a peer dependency.
|
|
80
|
+
*/
|
|
81
|
+
agent?: AgentConfig;
|
|
75
82
|
}
|
|
76
83
|
/**
|
|
77
84
|
* Fastify plugin for Cube.js-compatible API
|