drizzle-cube 0.1.68 → 0.2.0

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 (107) hide show
  1. package/dist/adapters/{compiler-CghsDLXl.cjs → compiler-DP1pPIcg.cjs} +9 -9
  2. package/dist/adapters/{compiler-BnHK-nxh.js → compiler-gcKytLwd.js} +12 -13
  3. package/dist/adapters/express/index.cjs +1 -1
  4. package/dist/adapters/express/index.js +1 -1
  5. package/dist/adapters/fastify/index.cjs +1 -1
  6. package/dist/adapters/fastify/index.js +1 -1
  7. package/dist/adapters/hono/index.cjs +1 -1
  8. package/dist/adapters/hono/index.js +1 -1
  9. package/dist/adapters/nextjs/index.cjs +1 -1
  10. package/dist/adapters/nextjs/index.js +1 -1
  11. package/dist/client/charts/ChartLoader.d.ts +56 -0
  12. package/dist/client/charts/lazyChartConfigRegistry.d.ts +90 -0
  13. package/dist/client/charts.d.ts +6 -0
  14. package/dist/client/charts.js +38 -15
  15. package/dist/client/charts.js.map +1 -1
  16. package/dist/client/chunks/chart-activitygridchart-BRk9BNnp.js +3713 -0
  17. package/dist/client/chunks/chart-activitygridchart-BRk9BNnp.js.map +1 -0
  18. package/dist/client/chunks/chart-activitygridchart-config-D9CgNH02.js +51 -0
  19. package/dist/client/chunks/chart-activitygridchart-config-D9CgNH02.js.map +1 -0
  20. package/dist/client/chunks/chart-areachart-Beu8sO9v.js +204 -0
  21. package/dist/client/chunks/chart-areachart-Beu8sO9v.js.map +1 -0
  22. package/dist/client/chunks/chart-areachart-config-InZgxubz.js +66 -0
  23. package/dist/client/chunks/chart-areachart-config-InZgxubz.js.map +1 -0
  24. package/dist/client/chunks/chart-barchart-BzoejYkT.js +177 -0
  25. package/dist/client/chunks/chart-barchart-BzoejYkT.js.map +1 -0
  26. package/dist/client/chunks/chart-barchart-config-DxatOnVV.js +59 -0
  27. package/dist/client/chunks/chart-barchart-config-DxatOnVV.js.map +1 -0
  28. package/dist/client/chunks/chart-bubblechart-Dg7sT_Mm.js +210 -0
  29. package/dist/client/chunks/chart-bubblechart-Dg7sT_Mm.js.map +1 -0
  30. package/dist/client/chunks/chart-bubblechart-config-CcZTMTCx.js +59 -0
  31. package/dist/client/chunks/chart-bubblechart-config-CcZTMTCx.js.map +1 -0
  32. package/dist/client/chunks/chart-chartcontainer-CdwzIKP1.js +103 -0
  33. package/dist/client/chunks/chart-chartcontainer-CdwzIKP1.js.map +1 -0
  34. package/dist/client/chunks/chart-charttooltip-NrFVM1cJ.js +26 -0
  35. package/dist/client/chunks/chart-charttooltip-NrFVM1cJ.js.map +1 -0
  36. package/dist/client/chunks/chart-datatable-BvV7gLPZ.js +57 -0
  37. package/dist/client/chunks/chart-datatable-BvV7gLPZ.js.map +1 -0
  38. package/dist/client/chunks/chart-datatable-config-D7mojhYA.js +22 -0
  39. package/dist/client/chunks/chart-datatable-config-D7mojhYA.js.map +1 -0
  40. package/dist/client/chunks/chart-kpidelta-config-icJXuFxe.js +99 -0
  41. package/dist/client/chunks/chart-kpidelta-config-icJXuFxe.js.map +1 -0
  42. package/dist/client/chunks/chart-kpidelta-p1lVVG5v.js +434 -0
  43. package/dist/client/chunks/chart-kpidelta-p1lVVG5v.js.map +1 -0
  44. package/dist/client/chunks/chart-kpinumber-BFtxFeqq.js +398 -0
  45. package/dist/client/chunks/chart-kpinumber-BFtxFeqq.js.map +1 -0
  46. package/dist/client/chunks/chart-kpinumber-config-T39g03ud.js +77 -0
  47. package/dist/client/chunks/chart-kpinumber-config-T39g03ud.js.map +1 -0
  48. package/dist/client/chunks/chart-kpitext-CX1s1u8B.js +165 -0
  49. package/dist/client/chunks/chart-kpitext-CX1s1u8B.js.map +1 -0
  50. package/dist/client/chunks/chart-kpitext-config-BbJGXAVk.js +49 -0
  51. package/dist/client/chunks/chart-kpitext-config-BbJGXAVk.js.map +1 -0
  52. package/dist/client/chunks/chart-linechart-Dgb10zbj.js +155 -0
  53. package/dist/client/chunks/chart-linechart-Dgb10zbj.js.map +1 -0
  54. package/dist/client/chunks/chart-linechart-config-BS1qVC8K.js +54 -0
  55. package/dist/client/chunks/chart-linechart-config-BS1qVC8K.js.map +1 -0
  56. package/dist/client/chunks/chart-markdownchart-C3FAQFuO.js +254 -0
  57. package/dist/client/chunks/chart-markdownchart-C3FAQFuO.js.map +1 -0
  58. package/dist/client/chunks/chart-markdownchart-config-DMCD8phf.js +62 -0
  59. package/dist/client/chunks/chart-markdownchart-config-DMCD8phf.js.map +1 -0
  60. package/dist/client/chunks/chart-piechart-B-0BQh-d.js +121 -0
  61. package/dist/client/chunks/chart-piechart-B-0BQh-d.js.map +1 -0
  62. package/dist/client/chunks/chart-piechart-config-6ZK8XaSX.js +32 -0
  63. package/dist/client/chunks/chart-piechart-config-6ZK8XaSX.js.map +1 -0
  64. package/dist/client/chunks/chart-radarchart-BwZM1yTd.js +124 -0
  65. package/dist/client/chunks/chart-radarchart-BwZM1yTd.js.map +1 -0
  66. package/dist/client/chunks/chart-radarchart-config-CCWOkkwO.js +38 -0
  67. package/dist/client/chunks/chart-radarchart-config-CCWOkkwO.js.map +1 -0
  68. package/dist/client/chunks/chart-radialbarchart-CythI1zx.js +109 -0
  69. package/dist/client/chunks/chart-radialbarchart-CythI1zx.js.map +1 -0
  70. package/dist/client/chunks/chart-radialbarchart-config-DicXYrMW.js +31 -0
  71. package/dist/client/chunks/chart-radialbarchart-config-DicXYrMW.js.map +1 -0
  72. package/dist/client/chunks/chart-scatterchart-config-DgYa-5vm.js +41 -0
  73. package/dist/client/chunks/chart-scatterchart-config-DgYa-5vm.js.map +1 -0
  74. package/dist/client/chunks/chart-scatterchart-om9-qmtE.js +201 -0
  75. package/dist/client/chunks/chart-scatterchart-om9-qmtE.js.map +1 -0
  76. package/dist/client/chunks/chart-treemapchart-Dc35Miif.js +253 -0
  77. package/dist/client/chunks/chart-treemapchart-Dc35Miif.js.map +1 -0
  78. package/dist/client/chunks/chart-treemapchart-config-DGhteyBe.js +40 -0
  79. package/dist/client/chunks/chart-treemapchart-config-DGhteyBe.js.map +1 -0
  80. package/dist/client/chunks/charts-DL9XOlaK.js +286 -0
  81. package/dist/client/chunks/charts-DL9XOlaK.js.map +1 -0
  82. package/dist/client/chunks/{icons-Bky5w1eH.js → icons-D-n_woAP.js} +833 -783
  83. package/dist/client/chunks/icons-D-n_woAP.js.map +1 -0
  84. package/dist/client/chunks/index-DpEuGmcW.js +8707 -0
  85. package/dist/client/chunks/index-DpEuGmcW.js.map +1 -0
  86. package/dist/client/components/QueryBuilder/ShareWarningModal.d.ts +9 -0
  87. package/dist/client/components/QueryBuilder/shareUtils.d.ts +59 -0
  88. package/dist/client/components/QueryBuilder/types.d.ts +21 -1
  89. package/dist/client/components.js +11 -11
  90. package/dist/client/hooks.js +3 -3
  91. package/dist/client/index.d.ts +18 -1
  92. package/dist/client/index.js +9135 -39
  93. package/dist/client/index.js.map +1 -1
  94. package/dist/client/providers.js +4 -4
  95. package/dist/client/styles.css +1 -1
  96. package/dist/client-bundle-stats.html +1 -1
  97. package/dist/server/index.cjs +16 -16
  98. package/dist/server/index.d.ts +0 -286
  99. package/dist/server/index.js +767 -881
  100. package/package.json +8 -2
  101. package/dist/client/chunks/charts-jwgcWeFt.js +0 -2580
  102. package/dist/client/chunks/charts-jwgcWeFt.js.map +0 -1
  103. package/dist/client/chunks/components-fN-QOY6G.js +0 -21835
  104. package/dist/client/chunks/components-fN-QOY6G.js.map +0 -1
  105. package/dist/client/chunks/icons-Bky5w1eH.js.map +0 -1
  106. package/dist/client/chunks/providers-D7zRgZrO.js +0 -308
  107. package/dist/client/chunks/providers-D7zRgZrO.js.map +0 -1
@@ -20739,7 +20739,7 @@ function yI(T) {
20739
20739
  }
20740
20740
  return "postgres";
20741
20741
  }
20742
- async function KI(T, E, e) {
20742
+ async function gI(T, E, e) {
20743
20743
  const R = e.validateQuery(T);
20744
20744
  if (!R.isValid)
20745
20745
  throw new Error(`Query validation failed: ${R.errors.join(", ")}`);
@@ -20850,25 +20850,25 @@ function vT(T, E) {
20850
20850
  return console.warn("SQL formatting failed:", e), T;
20851
20851
  }
20852
20852
  }
20853
- function $I(T, E) {
20853
+ function KI(T, E) {
20854
20854
  return {
20855
20855
  sql: E.sql,
20856
20856
  params: E.params || [],
20857
20857
  query: T
20858
20858
  };
20859
20859
  }
20860
- function wI(T) {
20860
+ function $I(T) {
20861
20861
  return {
20862
20862
  cubes: T
20863
20863
  };
20864
20864
  }
20865
- function JI(T, E = 500) {
20865
+ function wI(T, E = 500) {
20866
20866
  return {
20867
20867
  error: T instanceof Error ? T.message : T,
20868
20868
  status: E
20869
20869
  };
20870
20870
  }
20871
- async function xI(T, E, e) {
20871
+ async function JI(T, E, e) {
20872
20872
  return { results: (await Promise.allSettled(
20873
20873
  T.map(async (S) => {
20874
20874
  const I = await e.executeMultiCubeQuery(S, E);
@@ -20884,7 +20884,7 @@ async function xI(T, E, e) {
20884
20884
  // Include the query that failed for debugging
20885
20885
  }) };
20886
20886
  }
20887
- class gI {
20887
+ class xI {
20888
20888
  cubes = /* @__PURE__ */ new Map();
20889
20889
  dbExecutor;
20890
20890
  metadataCache;
@@ -21258,13 +21258,12 @@ function ie(T, E, e, R) {
21258
21258
  }
21259
21259
  !I.dimensions[S] && !I.measures[S] && e.push(`Filter field '${S}' not found on cube '${A}' (must be a dimension or measure)`);
21260
21260
  }
21261
- new gI();
21262
21261
  export {
21263
- gI as S,
21264
- wI as a,
21265
- $I as b,
21266
- KI as c,
21267
- JI as d,
21262
+ xI as S,
21263
+ $I as a,
21264
+ KI as b,
21265
+ gI as c,
21266
+ wI as d,
21268
21267
  XI as f,
21269
- xI as h
21268
+ JI as h
21270
21269
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("express"),v=require("cors"),o=require("../compiler-CghsDLXl.cjs");function E(d){const{cubes:y,drizzle:j,schema:g,extractSecurityContext:l,engineType:h,cors:R,basePath:c="/cubejs-api/v1",jsonLimit:b="10mb"}=d;if(!y||y.length===0)throw new Error("At least one cube must be provided in the cubes array");const i=p.Router();R&&i.use(v(R)),i.use(p.json({limit:b})),i.use(p.urlencoded({extended:!0,limit:b}));const a=new o.SemanticLayerCompiler({drizzle:j,schema:g,engineType:h});return y.forEach(t=>{a.registerCube(t)}),i.post(`${c}/load`,async(t,e)=>{try{const r=t.body.query||t.body,s=await l(t,e),n=a.validateQuery(r);if(!n.isValid)return e.status(400).json(o.formatErrorResponse(`Query validation failed: ${n.errors.join(", ")}`,400));const u=await a.executeMultiCubeQuery(r,s);e.json(o.formatCubeResponse(r,u,a))}catch(r){console.error("Query execution error:",r),e.status(500).json(o.formatErrorResponse(r instanceof Error?r.message:"Query execution failed",500))}}),i.get(`${c}/load`,async(t,e)=>{try{const r=t.query.query;if(!r)return e.status(400).json(o.formatErrorResponse("Query parameter is required",400));let s;try{s=JSON.parse(r)}catch{return e.status(400).json(o.formatErrorResponse("Invalid JSON in query parameter",400))}const n=await l(t,e),u=a.validateQuery(s);if(!u.isValid)return e.status(400).json(o.formatErrorResponse(`Query validation failed: ${u.errors.join(", ")}`,400));const f=await a.executeMultiCubeQuery(s,n);e.json(o.formatCubeResponse(s,f,a))}catch(r){console.error("Query execution error:",r),e.status(500).json(o.formatErrorResponse(r instanceof Error?r.message:"Query execution failed",500))}}),i.post(`${c}/batch`,async(t,e)=>{try{const{queries:r}=t.body;if(!r||!Array.isArray(r))return e.status(400).json(o.formatErrorResponse('Request body must contain a "queries" array',400));if(r.length===0)return e.status(400).json(o.formatErrorResponse("Queries array cannot be empty",400));const s=await l(t,e),n=await o.handleBatchRequest(r,s,a);e.json(n)}catch(r){console.error("Batch execution error:",r),e.status(500).json(o.formatErrorResponse(r instanceof Error?r.message:"Batch execution failed",500))}}),i.get(`${c}/meta`,(t,e)=>{try{const r=a.getMetadata();e.json(o.formatMetaResponse(r))}catch(r){console.error("Metadata error:",r),e.status(500).json(o.formatErrorResponse(r instanceof Error?r.message:"Failed to fetch metadata",500))}}),i.post(`${c}/sql`,async(t,e)=>{try{const r=t.body,s=await l(t,e),n=a.validateQuery(r);if(!n.isValid)return e.status(400).json(o.formatErrorResponse(`Query validation failed: ${n.errors.join(", ")}`,400));const u=r.measures?.[0]||r.dimensions?.[0];if(!u)return e.status(400).json(o.formatErrorResponse("No measures or dimensions specified",400));const f=u.split(".")[0],m=await a.generateSQL(f,r,s);e.json(o.formatSqlResponse(r,m))}catch(r){console.error("SQL generation error:",r),e.status(500).json(o.formatErrorResponse(r instanceof Error?r.message:"SQL generation failed",500))}}),i.get(`${c}/sql`,async(t,e)=>{try{const r=t.query.query;if(!r)return e.status(400).json(o.formatErrorResponse("Query parameter is required",400));const s=JSON.parse(r),n=await l(t,e),u=a.validateQuery(s);if(!u.isValid)return e.status(400).json(o.formatErrorResponse(`Query validation failed: ${u.errors.join(", ")}`,400));const f=s.measures?.[0]||s.dimensions?.[0];if(!f)return e.status(400).json(o.formatErrorResponse("No measures or dimensions specified",400));const m=f.split(".")[0],Q=await a.generateSQL(m,s,n);e.json(o.formatSqlResponse(s,Q))}catch(r){console.error("SQL generation error:",r),e.status(500).json(o.formatErrorResponse(r instanceof Error?r.message:"SQL generation failed",500))}}),i.post(`${c}/dry-run`,async(t,e)=>{try{const r=t.body.query||t.body,s=await l(t,e),n=await o.handleDryRun(r,s,a);e.json(n)}catch(r){console.error("Dry-run error:",r),e.status(400).json({error:r instanceof Error?r.message:"Dry-run validation failed",valid:!1})}}),i.get(`${c}/dry-run`,async(t,e)=>{try{const r=t.query.query;if(!r)return e.status(400).json({error:"Query parameter is required",valid:!1});const s=JSON.parse(r),n=await l(t,e),u=await o.handleDryRun(s,n,a);e.json(u)}catch(r){console.error("Dry-run error:",r),e.status(400).json({error:r instanceof Error?r.message:"Dry-run validation failed",valid:!1})}}),i.use((t,e,r,s)=>{console.error("Express adapter error:",t),r.headersSent||r.status(500).json(o.formatErrorResponse(t,500))}),i}function q(d,y){const j=E(y);return d.use("/",j),d}function x(d){const y=p();return q(y,d)}exports.createCubeApp=x;exports.createCubeRouter=E;exports.mountCubeRoutes=q;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("express"),v=require("cors"),o=require("../compiler-DP1pPIcg.cjs");function E(d){const{cubes:y,drizzle:j,schema:g,extractSecurityContext:l,engineType:h,cors:R,basePath:c="/cubejs-api/v1",jsonLimit:b="10mb"}=d;if(!y||y.length===0)throw new Error("At least one cube must be provided in the cubes array");const i=p.Router();R&&i.use(v(R)),i.use(p.json({limit:b})),i.use(p.urlencoded({extended:!0,limit:b}));const a=new o.SemanticLayerCompiler({drizzle:j,schema:g,engineType:h});return y.forEach(t=>{a.registerCube(t)}),i.post(`${c}/load`,async(t,e)=>{try{const r=t.body.query||t.body,s=await l(t,e),n=a.validateQuery(r);if(!n.isValid)return e.status(400).json(o.formatErrorResponse(`Query validation failed: ${n.errors.join(", ")}`,400));const u=await a.executeMultiCubeQuery(r,s);e.json(o.formatCubeResponse(r,u,a))}catch(r){console.error("Query execution error:",r),e.status(500).json(o.formatErrorResponse(r instanceof Error?r.message:"Query execution failed",500))}}),i.get(`${c}/load`,async(t,e)=>{try{const r=t.query.query;if(!r)return e.status(400).json(o.formatErrorResponse("Query parameter is required",400));let s;try{s=JSON.parse(r)}catch{return e.status(400).json(o.formatErrorResponse("Invalid JSON in query parameter",400))}const n=await l(t,e),u=a.validateQuery(s);if(!u.isValid)return e.status(400).json(o.formatErrorResponse(`Query validation failed: ${u.errors.join(", ")}`,400));const f=await a.executeMultiCubeQuery(s,n);e.json(o.formatCubeResponse(s,f,a))}catch(r){console.error("Query execution error:",r),e.status(500).json(o.formatErrorResponse(r instanceof Error?r.message:"Query execution failed",500))}}),i.post(`${c}/batch`,async(t,e)=>{try{const{queries:r}=t.body;if(!r||!Array.isArray(r))return e.status(400).json(o.formatErrorResponse('Request body must contain a "queries" array',400));if(r.length===0)return e.status(400).json(o.formatErrorResponse("Queries array cannot be empty",400));const s=await l(t,e),n=await o.handleBatchRequest(r,s,a);e.json(n)}catch(r){console.error("Batch execution error:",r),e.status(500).json(o.formatErrorResponse(r instanceof Error?r.message:"Batch execution failed",500))}}),i.get(`${c}/meta`,(t,e)=>{try{const r=a.getMetadata();e.json(o.formatMetaResponse(r))}catch(r){console.error("Metadata error:",r),e.status(500).json(o.formatErrorResponse(r instanceof Error?r.message:"Failed to fetch metadata",500))}}),i.post(`${c}/sql`,async(t,e)=>{try{const r=t.body,s=await l(t,e),n=a.validateQuery(r);if(!n.isValid)return e.status(400).json(o.formatErrorResponse(`Query validation failed: ${n.errors.join(", ")}`,400));const u=r.measures?.[0]||r.dimensions?.[0];if(!u)return e.status(400).json(o.formatErrorResponse("No measures or dimensions specified",400));const f=u.split(".")[0],m=await a.generateSQL(f,r,s);e.json(o.formatSqlResponse(r,m))}catch(r){console.error("SQL generation error:",r),e.status(500).json(o.formatErrorResponse(r instanceof Error?r.message:"SQL generation failed",500))}}),i.get(`${c}/sql`,async(t,e)=>{try{const r=t.query.query;if(!r)return e.status(400).json(o.formatErrorResponse("Query parameter is required",400));const s=JSON.parse(r),n=await l(t,e),u=a.validateQuery(s);if(!u.isValid)return e.status(400).json(o.formatErrorResponse(`Query validation failed: ${u.errors.join(", ")}`,400));const f=s.measures?.[0]||s.dimensions?.[0];if(!f)return e.status(400).json(o.formatErrorResponse("No measures or dimensions specified",400));const m=f.split(".")[0],Q=await a.generateSQL(m,s,n);e.json(o.formatSqlResponse(s,Q))}catch(r){console.error("SQL generation error:",r),e.status(500).json(o.formatErrorResponse(r instanceof Error?r.message:"SQL generation failed",500))}}),i.post(`${c}/dry-run`,async(t,e)=>{try{const r=t.body.query||t.body,s=await l(t,e),n=await o.handleDryRun(r,s,a);e.json(n)}catch(r){console.error("Dry-run error:",r),e.status(400).json({error:r instanceof Error?r.message:"Dry-run validation failed",valid:!1})}}),i.get(`${c}/dry-run`,async(t,e)=>{try{const r=t.query.query;if(!r)return e.status(400).json({error:"Query parameter is required",valid:!1});const s=JSON.parse(r),n=await l(t,e),u=await o.handleDryRun(s,n,a);e.json(u)}catch(r){console.error("Dry-run error:",r),e.status(400).json({error:r instanceof Error?r.message:"Dry-run validation failed",valid:!1})}}),i.use((t,e,r,s)=>{console.error("Express adapter error:",t),r.headersSent||r.status(500).json(o.formatErrorResponse(t,500))}),i}function q(d,y){const j=E(y);return d.use("/",j),d}function x(d){const y=p();return q(y,d)}exports.createCubeApp=x;exports.createCubeRouter=E;exports.mountCubeRoutes=q;
@@ -1,6 +1,6 @@
1
1
  import p, { Router as C } from "express";
2
2
  import S from "cors";
3
- import { S as R, d as o, f as g, h as E, a as $, b as Q, c as q } from "../compiler-BnHK-nxh.js";
3
+ import { S as R, d as o, f as g, h as E, a as $, b as Q, c as q } from "../compiler-gcKytLwd.js";
4
4
  function L(d) {
5
5
  const {
6
6
  cubes: y,
@@ -1 +1 @@
1
- "use strict";var S=Object.create;var q=Object.defineProperty;var w=Object.getOwnPropertyDescriptor;var x=Object.getOwnPropertyNames;var j=Object.getPrototypeOf,P=Object.prototype.hasOwnProperty;var $=(n,s,m,g)=>{if(s&&typeof s=="object"||typeof s=="function")for(let d of x(s))!P.call(n,d)&&d!==m&&q(n,d,{get:()=>s[d],enumerable:!(g=w(s,d))||g.enumerable});return n};var L=(n,s,m)=>(m=n!=null?S(j(n)):{},$(s||!n||!n.__esModule?q(m,"default",{value:n,enumerable:!0}):m,n));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("../compiler-CghsDLXl.cjs"),h=function(s,m,g){const{cubes:d,drizzle:E,schema:v,extractSecurityContext:p,engineType:C,cors:R,basePath:y="/cubejs-api/v1",bodyLimit:b=10485760}=m;if(!d||d.length===0)return g(new Error("At least one cube must be provided in the cubes array"));R&&s.register(import("@fastify/cors"),R),s.addHook("onRequest",async(e,t)=>{e.method==="POST"&&(e.body=void 0)});const i=new o.SemanticLayerCompiler({drizzle:E,schema:v,engineType:C});d.forEach(e=>{i.registerCube(e)}),s.post(`${y}/load`,{bodyLimit:b,schema:{body:{type:"object",additionalProperties:!0}}},async(e,t)=>{try{const r=e.body,a=r.query||r,u=await p(e),c=i.validateQuery(a);if(!c.isValid)return t.status(400).send(o.formatErrorResponse(`Query validation failed: ${c.errors.join(", ")}`,400));const l=await i.executeMultiCubeQuery(a,u);return o.formatCubeResponse(a,l,i)}catch(r){return e.log.error(r,"Query execution error"),t.status(500).send(o.formatErrorResponse(r instanceof Error?r.message:"Query execution failed",500))}}),s.get(`${y}/load`,{schema:{querystring:{type:"object",properties:{query:{type:"string"}},required:["query"]}}},async(e,t)=>{try{const{query:r}=e.query;let a;try{a=JSON.parse(r)}catch{return t.status(400).send(o.formatErrorResponse("Invalid JSON in query parameter",400))}const u=await p(e),c=i.validateQuery(a);if(!c.isValid)return t.status(400).send(o.formatErrorResponse(`Query validation failed: ${c.errors.join(", ")}`,400));const l=await i.executeMultiCubeQuery(a,u);return o.formatCubeResponse(a,l,i)}catch(r){return e.log.error(r,"Query execution error"),t.status(500).send(o.formatErrorResponse(r instanceof Error?r.message:"Query execution failed",500))}}),s.post(`${y}/batch`,{bodyLimit:b,schema:{body:{type:"object",required:["queries"],properties:{queries:{type:"array",items:{type:"object"}}}}}},async(e,t)=>{try{const{queries:r}=e.body;if(!r||!Array.isArray(r))return t.status(400).send(o.formatErrorResponse('Request body must contain a "queries" array',400));if(r.length===0)return t.status(400).send(o.formatErrorResponse("Queries array cannot be empty",400));const a=await p(e);return await o.handleBatchRequest(r,a,i)}catch(r){return e.log.error(r,"Batch execution error"),t.status(500).send(o.formatErrorResponse(r instanceof Error?r.message:"Batch execution failed",500))}}),s.get(`${y}/meta`,async(e,t)=>{try{const r=i.getMetadata();return o.formatMetaResponse(r)}catch(r){return e.log.error(r,"Metadata error"),t.status(500).send(o.formatErrorResponse(r instanceof Error?r.message:"Failed to fetch metadata",500))}}),s.post(`${y}/sql`,{bodyLimit:b,schema:{body:{type:"object",additionalProperties:!0}}},async(e,t)=>{try{const r=e.body,a=await p(e),u=i.validateQuery(r);if(!u.isValid)return t.status(400).send(o.formatErrorResponse(`Query validation failed: ${u.errors.join(", ")}`,400));const c=r.measures?.[0]||r.dimensions?.[0];if(!c)return t.status(400).send(o.formatErrorResponse("No measures or dimensions specified",400));const l=c.split(".")[0],f=await i.generateSQL(l,r,a);return o.formatSqlResponse(r,f)}catch(r){return e.log.error(r,"SQL generation error"),t.status(500).send(o.formatErrorResponse(r instanceof Error?r.message:"SQL generation failed",500))}}),s.get(`${y}/sql`,{schema:{querystring:{type:"object",properties:{query:{type:"string"}},required:["query"]}}},async(e,t)=>{try{const{query:r}=e.query,a=JSON.parse(r),u=await p(e),c=i.validateQuery(a);if(!c.isValid)return t.status(400).send(o.formatErrorResponse(`Query validation failed: ${c.errors.join(", ")}`,400));const l=a.measures?.[0]||a.dimensions?.[0];if(!l)return t.status(400).send(o.formatErrorResponse("No measures or dimensions specified",400));const f=l.split(".")[0],Q=await i.generateSQL(f,a,u);return o.formatSqlResponse(a,Q)}catch(r){return e.log.error(r,"SQL generation error"),t.status(500).send(o.formatErrorResponse(r instanceof Error?r.message:"SQL generation failed",500))}}),s.post(`${y}/dry-run`,{bodyLimit:b,schema:{body:{type:"object",additionalProperties:!0}}},async(e,t)=>{try{const r=e.body,a=r.query||r,u=await p(e);return await o.handleDryRun(a,u,i)}catch(r){return e.log.error(r,"Dry-run error"),t.status(400).send({error:r instanceof Error?r.message:"Dry-run validation failed",valid:!1})}}),s.get(`${y}/dry-run`,{schema:{querystring:{type:"object",properties:{query:{type:"string"}},required:["query"]}}},async(e,t)=>{try{const{query:r}=e.query,a=JSON.parse(r),u=await p(e);return await o.handleDryRun(a,u,i)}catch(r){return e.log.error(r,"Dry-run error"),t.status(400).send({error:r instanceof Error?r.message:"Dry-run validation failed",valid:!1})}}),s.setErrorHandler(async(e,t,r)=>{t.log.error(e,"Fastify cube adapter error"),r.statusCode<400&&r.status(500);const a=e instanceof Error?e:String(e);return o.formatErrorResponse(a,r.statusCode)}),g()};async function M(n,s){await n.register(h,s)}function N(n){const s=require("fastify")({logger:!0});return s.register(h,n),s}exports.createCubeApp=N;exports.cubePlugin=h;exports.registerCubeRoutes=M;
1
+ "use strict";var S=Object.create;var q=Object.defineProperty;var w=Object.getOwnPropertyDescriptor;var x=Object.getOwnPropertyNames;var j=Object.getPrototypeOf,P=Object.prototype.hasOwnProperty;var $=(n,s,m,g)=>{if(s&&typeof s=="object"||typeof s=="function")for(let d of x(s))!P.call(n,d)&&d!==m&&q(n,d,{get:()=>s[d],enumerable:!(g=w(s,d))||g.enumerable});return n};var L=(n,s,m)=>(m=n!=null?S(j(n)):{},$(s||!n||!n.__esModule?q(m,"default",{value:n,enumerable:!0}):m,n));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("../compiler-DP1pPIcg.cjs"),h=function(s,m,g){const{cubes:d,drizzle:E,schema:v,extractSecurityContext:p,engineType:C,cors:R,basePath:y="/cubejs-api/v1",bodyLimit:b=10485760}=m;if(!d||d.length===0)return g(new Error("At least one cube must be provided in the cubes array"));R&&s.register(import("@fastify/cors"),R),s.addHook("onRequest",async(e,t)=>{e.method==="POST"&&(e.body=void 0)});const i=new o.SemanticLayerCompiler({drizzle:E,schema:v,engineType:C});d.forEach(e=>{i.registerCube(e)}),s.post(`${y}/load`,{bodyLimit:b,schema:{body:{type:"object",additionalProperties:!0}}},async(e,t)=>{try{const r=e.body,a=r.query||r,u=await p(e),c=i.validateQuery(a);if(!c.isValid)return t.status(400).send(o.formatErrorResponse(`Query validation failed: ${c.errors.join(", ")}`,400));const l=await i.executeMultiCubeQuery(a,u);return o.formatCubeResponse(a,l,i)}catch(r){return e.log.error(r,"Query execution error"),t.status(500).send(o.formatErrorResponse(r instanceof Error?r.message:"Query execution failed",500))}}),s.get(`${y}/load`,{schema:{querystring:{type:"object",properties:{query:{type:"string"}},required:["query"]}}},async(e,t)=>{try{const{query:r}=e.query;let a;try{a=JSON.parse(r)}catch{return t.status(400).send(o.formatErrorResponse("Invalid JSON in query parameter",400))}const u=await p(e),c=i.validateQuery(a);if(!c.isValid)return t.status(400).send(o.formatErrorResponse(`Query validation failed: ${c.errors.join(", ")}`,400));const l=await i.executeMultiCubeQuery(a,u);return o.formatCubeResponse(a,l,i)}catch(r){return e.log.error(r,"Query execution error"),t.status(500).send(o.formatErrorResponse(r instanceof Error?r.message:"Query execution failed",500))}}),s.post(`${y}/batch`,{bodyLimit:b,schema:{body:{type:"object",required:["queries"],properties:{queries:{type:"array",items:{type:"object"}}}}}},async(e,t)=>{try{const{queries:r}=e.body;if(!r||!Array.isArray(r))return t.status(400).send(o.formatErrorResponse('Request body must contain a "queries" array',400));if(r.length===0)return t.status(400).send(o.formatErrorResponse("Queries array cannot be empty",400));const a=await p(e);return await o.handleBatchRequest(r,a,i)}catch(r){return e.log.error(r,"Batch execution error"),t.status(500).send(o.formatErrorResponse(r instanceof Error?r.message:"Batch execution failed",500))}}),s.get(`${y}/meta`,async(e,t)=>{try{const r=i.getMetadata();return o.formatMetaResponse(r)}catch(r){return e.log.error(r,"Metadata error"),t.status(500).send(o.formatErrorResponse(r instanceof Error?r.message:"Failed to fetch metadata",500))}}),s.post(`${y}/sql`,{bodyLimit:b,schema:{body:{type:"object",additionalProperties:!0}}},async(e,t)=>{try{const r=e.body,a=await p(e),u=i.validateQuery(r);if(!u.isValid)return t.status(400).send(o.formatErrorResponse(`Query validation failed: ${u.errors.join(", ")}`,400));const c=r.measures?.[0]||r.dimensions?.[0];if(!c)return t.status(400).send(o.formatErrorResponse("No measures or dimensions specified",400));const l=c.split(".")[0],f=await i.generateSQL(l,r,a);return o.formatSqlResponse(r,f)}catch(r){return e.log.error(r,"SQL generation error"),t.status(500).send(o.formatErrorResponse(r instanceof Error?r.message:"SQL generation failed",500))}}),s.get(`${y}/sql`,{schema:{querystring:{type:"object",properties:{query:{type:"string"}},required:["query"]}}},async(e,t)=>{try{const{query:r}=e.query,a=JSON.parse(r),u=await p(e),c=i.validateQuery(a);if(!c.isValid)return t.status(400).send(o.formatErrorResponse(`Query validation failed: ${c.errors.join(", ")}`,400));const l=a.measures?.[0]||a.dimensions?.[0];if(!l)return t.status(400).send(o.formatErrorResponse("No measures or dimensions specified",400));const f=l.split(".")[0],Q=await i.generateSQL(f,a,u);return o.formatSqlResponse(a,Q)}catch(r){return e.log.error(r,"SQL generation error"),t.status(500).send(o.formatErrorResponse(r instanceof Error?r.message:"SQL generation failed",500))}}),s.post(`${y}/dry-run`,{bodyLimit:b,schema:{body:{type:"object",additionalProperties:!0}}},async(e,t)=>{try{const r=e.body,a=r.query||r,u=await p(e);return await o.handleDryRun(a,u,i)}catch(r){return e.log.error(r,"Dry-run error"),t.status(400).send({error:r instanceof Error?r.message:"Dry-run validation failed",valid:!1})}}),s.get(`${y}/dry-run`,{schema:{querystring:{type:"object",properties:{query:{type:"string"}},required:["query"]}}},async(e,t)=>{try{const{query:r}=e.query,a=JSON.parse(r),u=await p(e);return await o.handleDryRun(a,u,i)}catch(r){return e.log.error(r,"Dry-run error"),t.status(400).send({error:r instanceof Error?r.message:"Dry-run validation failed",valid:!1})}}),s.setErrorHandler(async(e,t,r)=>{t.log.error(e,"Fastify cube adapter error"),r.statusCode<400&&r.status(500);const a=e instanceof Error?e:String(e);return o.formatErrorResponse(a,r.statusCode)}),g()};async function M(n,s){await n.register(h,s)}function N(n){const s=require("fastify")({logger:!0});return s.register(h,n),s}exports.createCubeApp=N;exports.cubePlugin=h;exports.registerCubeRoutes=M;
@@ -1,4 +1,4 @@
1
- import { S as j, d as o, f as h, h as R, a as $, b as q, c as Q } from "../compiler-BnHK-nxh.js";
1
+ import { S as j, d as o, f as h, h as R, a as $, b as q, c as Q } from "../compiler-gcKytLwd.js";
2
2
  const v = function(a, x, p) {
3
3
  const {
4
4
  cubes: b,
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("hono"),y=require("../compiler-CghsDLXl.cjs");var b=f=>{const u={...{origin:"*",allowMethods:["GET","HEAD","PUT","POST","DELETE","PATCH"],allowHeaders:[],exposeHeaders:[]},...f},j=(i=>typeof i=="string"?i==="*"?()=>i:o=>i===o?o:null:typeof i=="function"?i:o=>i.includes(o)?o:null)(u.origin),d=(i=>typeof i=="function"?i:Array.isArray(i)?()=>i:()=>[])(u.allowMethods);return async function(o,c){function n(r,e){o.res.headers.set(r,e)}const s=await j(o.req.header("origin")||"",o);if(s&&n("Access-Control-Allow-Origin",s),u.credentials&&n("Access-Control-Allow-Credentials","true"),u.exposeHeaders?.length&&n("Access-Control-Expose-Headers",u.exposeHeaders.join(",")),o.req.method==="OPTIONS"){u.origin!=="*"&&n("Vary","Origin"),u.maxAge!=null&&n("Access-Control-Max-Age",u.maxAge.toString());const r=await d(o.req.header("origin")||"",o);r.length&&n("Access-Control-Allow-Methods",r.join(","));let e=u.allowHeaders;if(!e?.length){const t=o.req.header("Access-Control-Request-Headers");t&&(e=t.split(/\s*,\s*/))}return e?.length&&(n("Access-Control-Allow-Headers",e.join(",")),o.res.headers.append("Vary","Access-Control-Request-Headers")),o.res.headers.delete("Content-Length"),o.res.headers.delete("Content-Type"),new Response(null,{headers:o.res.headers,status:204,statusText:"No Content"})}await c(),u.origin!=="*"&&o.header("Vary","Origin",{append:!0})}};function g(f){const{cubes:q,drizzle:u,schema:j,extractSecurityContext:d,engineType:i,cors:o,basePath:c="/cubejs-api/v1"}=f;if(!q||q.length===0)throw new Error("At least one cube must be provided in the cubes array");const n=new p.Hono;o&&n.use("/*",b(o));const s=new y.SemanticLayerCompiler({drizzle:u,schema:j,engineType:i});return q.forEach(r=>{s.registerCube(r)}),n.post(`${c}/load`,async r=>{try{const e=await r.req.json(),t=e.query||e,l=await d(r),a=s.validateQuery(t);if(!a.isValid)return r.json({error:`Query validation failed: ${a.errors.join(", ")}`},400);const m=await s.executeMultiCubeQuery(t,l);return r.json(y.formatCubeResponse(t,m,s))}catch(e){return console.error("Query execution error:",e),r.json({error:e instanceof Error?e.message:"Query execution failed"},500)}}),n.get(`${c}/load`,async r=>{try{const e=r.req.query("query");if(!e)return r.json({error:"Query parameter is required"},400);let t;try{t=JSON.parse(e)}catch{return r.json({error:"Invalid JSON in query parameter"},400)}const l=await d(r),a=s.validateQuery(t);if(!a.isValid)return r.json({error:`Query validation failed: ${a.errors.join(", ")}`},400);const m=await s.executeMultiCubeQuery(t,l);return r.json(y.formatCubeResponse(t,m,s))}catch(e){return console.error("Query execution error:",e),r.json({error:e instanceof Error?e.message:"Query execution failed"},500)}}),n.post(`${c}/batch`,async r=>{try{const e=await r.req.json(),{queries:t}=e;if(!t||!Array.isArray(t))return r.json({error:'Request body must contain a "queries" array'},400);if(t.length===0)return r.json({error:"Queries array cannot be empty"},400);const l=await d(r),a=await y.handleBatchRequest(t,l,s);return r.json(a)}catch(e){return console.error("Batch execution error:",e),r.json({error:e instanceof Error?e.message:"Batch execution failed"},500)}}),n.get(`${c}/meta`,r=>{try{const e=s.getMetadata();return r.json(y.formatMetaResponse(e))}catch(e){return console.error("Metadata error:",e),r.json({error:e instanceof Error?e.message:"Failed to fetch metadata"},500)}}),n.post(`${c}/sql`,async r=>{try{const e=await r.req.json(),t=await d(r),l=s.validateQuery(e);if(!l.isValid)return r.json({error:`Query validation failed: ${l.errors.join(", ")}`},400);const a=e.measures?.[0]||e.dimensions?.[0];if(!a)return r.json({error:"No measures or dimensions specified"},400);const m=a.split(".")[0],h=await s.generateSQL(m,e,t);return r.json(y.formatSqlResponse(e,h))}catch(e){return console.error("SQL generation error:",e),r.json({error:e instanceof Error?e.message:"SQL generation failed"},500)}}),n.get(`${c}/sql`,async r=>{try{const e=r.req.query("query");if(!e)return r.json({error:"Query parameter is required"},400);const t=JSON.parse(e),l=await d(r),a=s.validateQuery(t);if(!a.isValid)return r.json({error:`Query validation failed: ${a.errors.join(", ")}`},400);const m=t.measures?.[0]||t.dimensions?.[0];if(!m)return r.json({error:"No measures or dimensions specified"},400);const h=m.split(".")[0],C=await s.generateSQL(h,t,l);return r.json(y.formatSqlResponse(t,C))}catch(e){return console.error("SQL generation error:",e),r.json({error:e instanceof Error?e.message:"SQL generation failed"},500)}}),n.post(`${c}/dry-run`,async r=>{try{const e=await r.req.json(),t=e.query||e,l=await d(r),a=await y.handleDryRun(t,l,s);return r.json(a)}catch(e){return console.error("Dry-run error:",e),r.json({error:e instanceof Error?e.message:"Dry-run validation failed",valid:!1},400)}}),n.get(`${c}/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 t=JSON.parse(e),l=await d(r),a=await y.handleDryRun(t,l,s);return r.json(a)}catch(e){return console.error("Dry-run error:",e),r.json({error:e instanceof Error?e.message:"Dry-run validation failed",valid:!1},400)}}),n}function w(f,q){const u=g(q);return f.route("/",u),f}function x(f){const q=new p.Hono;return w(q,f)}exports.createCubeApp=x;exports.createCubeRoutes=g;exports.mountCubeRoutes=w;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("hono"),y=require("../compiler-DP1pPIcg.cjs");var b=f=>{const u={...{origin:"*",allowMethods:["GET","HEAD","PUT","POST","DELETE","PATCH"],allowHeaders:[],exposeHeaders:[]},...f},j=(i=>typeof i=="string"?i==="*"?()=>i:o=>i===o?o:null:typeof i=="function"?i:o=>i.includes(o)?o:null)(u.origin),d=(i=>typeof i=="function"?i:Array.isArray(i)?()=>i:()=>[])(u.allowMethods);return async function(o,c){function n(r,e){o.res.headers.set(r,e)}const s=await j(o.req.header("origin")||"",o);if(s&&n("Access-Control-Allow-Origin",s),u.credentials&&n("Access-Control-Allow-Credentials","true"),u.exposeHeaders?.length&&n("Access-Control-Expose-Headers",u.exposeHeaders.join(",")),o.req.method==="OPTIONS"){u.origin!=="*"&&n("Vary","Origin"),u.maxAge!=null&&n("Access-Control-Max-Age",u.maxAge.toString());const r=await d(o.req.header("origin")||"",o);r.length&&n("Access-Control-Allow-Methods",r.join(","));let e=u.allowHeaders;if(!e?.length){const t=o.req.header("Access-Control-Request-Headers");t&&(e=t.split(/\s*,\s*/))}return e?.length&&(n("Access-Control-Allow-Headers",e.join(",")),o.res.headers.append("Vary","Access-Control-Request-Headers")),o.res.headers.delete("Content-Length"),o.res.headers.delete("Content-Type"),new Response(null,{headers:o.res.headers,status:204,statusText:"No Content"})}await c(),u.origin!=="*"&&o.header("Vary","Origin",{append:!0})}};function g(f){const{cubes:q,drizzle:u,schema:j,extractSecurityContext:d,engineType:i,cors:o,basePath:c="/cubejs-api/v1"}=f;if(!q||q.length===0)throw new Error("At least one cube must be provided in the cubes array");const n=new p.Hono;o&&n.use("/*",b(o));const s=new y.SemanticLayerCompiler({drizzle:u,schema:j,engineType:i});return q.forEach(r=>{s.registerCube(r)}),n.post(`${c}/load`,async r=>{try{const e=await r.req.json(),t=e.query||e,l=await d(r),a=s.validateQuery(t);if(!a.isValid)return r.json({error:`Query validation failed: ${a.errors.join(", ")}`},400);const m=await s.executeMultiCubeQuery(t,l);return r.json(y.formatCubeResponse(t,m,s))}catch(e){return console.error("Query execution error:",e),r.json({error:e instanceof Error?e.message:"Query execution failed"},500)}}),n.get(`${c}/load`,async r=>{try{const e=r.req.query("query");if(!e)return r.json({error:"Query parameter is required"},400);let t;try{t=JSON.parse(e)}catch{return r.json({error:"Invalid JSON in query parameter"},400)}const l=await d(r),a=s.validateQuery(t);if(!a.isValid)return r.json({error:`Query validation failed: ${a.errors.join(", ")}`},400);const m=await s.executeMultiCubeQuery(t,l);return r.json(y.formatCubeResponse(t,m,s))}catch(e){return console.error("Query execution error:",e),r.json({error:e instanceof Error?e.message:"Query execution failed"},500)}}),n.post(`${c}/batch`,async r=>{try{const e=await r.req.json(),{queries:t}=e;if(!t||!Array.isArray(t))return r.json({error:'Request body must contain a "queries" array'},400);if(t.length===0)return r.json({error:"Queries array cannot be empty"},400);const l=await d(r),a=await y.handleBatchRequest(t,l,s);return r.json(a)}catch(e){return console.error("Batch execution error:",e),r.json({error:e instanceof Error?e.message:"Batch execution failed"},500)}}),n.get(`${c}/meta`,r=>{try{const e=s.getMetadata();return r.json(y.formatMetaResponse(e))}catch(e){return console.error("Metadata error:",e),r.json({error:e instanceof Error?e.message:"Failed to fetch metadata"},500)}}),n.post(`${c}/sql`,async r=>{try{const e=await r.req.json(),t=await d(r),l=s.validateQuery(e);if(!l.isValid)return r.json({error:`Query validation failed: ${l.errors.join(", ")}`},400);const a=e.measures?.[0]||e.dimensions?.[0];if(!a)return r.json({error:"No measures or dimensions specified"},400);const m=a.split(".")[0],h=await s.generateSQL(m,e,t);return r.json(y.formatSqlResponse(e,h))}catch(e){return console.error("SQL generation error:",e),r.json({error:e instanceof Error?e.message:"SQL generation failed"},500)}}),n.get(`${c}/sql`,async r=>{try{const e=r.req.query("query");if(!e)return r.json({error:"Query parameter is required"},400);const t=JSON.parse(e),l=await d(r),a=s.validateQuery(t);if(!a.isValid)return r.json({error:`Query validation failed: ${a.errors.join(", ")}`},400);const m=t.measures?.[0]||t.dimensions?.[0];if(!m)return r.json({error:"No measures or dimensions specified"},400);const h=m.split(".")[0],C=await s.generateSQL(h,t,l);return r.json(y.formatSqlResponse(t,C))}catch(e){return console.error("SQL generation error:",e),r.json({error:e instanceof Error?e.message:"SQL generation failed"},500)}}),n.post(`${c}/dry-run`,async r=>{try{const e=await r.req.json(),t=e.query||e,l=await d(r),a=await y.handleDryRun(t,l,s);return r.json(a)}catch(e){return console.error("Dry-run error:",e),r.json({error:e instanceof Error?e.message:"Dry-run validation failed",valid:!1},400)}}),n.get(`${c}/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 t=JSON.parse(e),l=await d(r),a=await y.handleDryRun(t,l,s);return r.json(a)}catch(e){return console.error("Dry-run error:",e),r.json({error:e instanceof Error?e.message:"Dry-run validation failed",valid:!1},400)}}),n}function w(f,q){const u=g(q);return f.route("/",u),f}function x(f){const q=new p.Hono;return w(q,f)}exports.createCubeApp=x;exports.createCubeRoutes=g;exports.mountCubeRoutes=w;
@@ -1,5 +1,5 @@
1
1
  import { Hono as w } from "hono";
2
- import { S as x, f as j, h as Q, a as b, b as g, c as p } from "../compiler-BnHK-nxh.js";
2
+ import { S as x, f as j, h as Q, a as b, b as g, c as p } from "../compiler-gcKytLwd.js";
3
3
  var A = (y) => {
4
4
  const u = {
5
5
  ...{
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("next/server"),c=require("../compiler-CghsDLXl.cjs");function h(s){const{cubes:t,drizzle:o,schema:a,engineType:f}=s;if(!t||t.length===0)throw new Error("At least one cube must be provided in the cubes array");const r=new c.SemanticLayerCompiler({drizzle:o,schema:a,engineType:f});return t.forEach(i=>{r.registerCube(i)}),r}function m(s,t){const o=s.headers.get("origin"),a={};return t.origin&&(typeof t.origin=="string"?a["Access-Control-Allow-Origin"]=t.origin:Array.isArray(t.origin)?o&&t.origin.includes(o)&&(a["Access-Control-Allow-Origin"]=o):typeof t.origin=="function"&&o&&t.origin(o)&&(a["Access-Control-Allow-Origin"]=o)),t.methods&&(a["Access-Control-Allow-Methods"]=t.methods.join(", ")),t.allowedHeaders&&(a["Access-Control-Allow-Headers"]=t.allowedHeaders.join(", ")),t.credentials&&(a["Access-Control-Allow-Credentials"]="true"),a}function H(s){return async function(o){const a=m(o,s);return new Response(null,{status:200,headers:a})}}function N(s){const{extractSecurityContext:t,cors:o}=s,a=h(s);return async function(r,i){try{let e;if(r.method==="POST"){const y=await r.json();e=y.query||y}else if(r.method==="GET"){const y=r.nextUrl.searchParams.get("query");if(!y)return n.NextResponse.json(c.formatErrorResponse("Query parameter is required",400),{status:400});try{e=JSON.parse(y)}catch{return n.NextResponse.json(c.formatErrorResponse("Invalid JSON in query parameter",400),{status:400})}}else return n.NextResponse.json(c.formatErrorResponse("Method not allowed",405),{status:405});const u=await t(r,i),d=a.validateQuery(e);if(!d.isValid)return n.NextResponse.json(c.formatErrorResponse(`Query validation failed: ${d.errors.join(", ")}`,400),{status:400});const l=await a.executeMultiCubeQuery(e,u),R=c.formatCubeResponse(e,l,a);return n.NextResponse.json(R,{headers:o?m(r,o):{}})}catch(e){return process.env.NODE_ENV!=="test"&&console.error("Next.js load handler error:",e),n.NextResponse.json(c.formatErrorResponse(e instanceof Error?e.message:"Query execution failed",500),{status:500})}}}function j(s){const{cors:t}=s,o=h(s);return async function(f,r){try{const i=o.getMetadata(),e=c.formatMetaResponse(i);return n.NextResponse.json(e,{headers:t?m(f,t):{}})}catch(i){return process.env.NODE_ENV!=="test"&&console.error("Next.js meta handler error:",i),n.NextResponse.json(c.formatErrorResponse(i instanceof Error?i.message:"Failed to fetch metadata",500),{status:500})}}}function E(s){const{extractSecurityContext:t,cors:o}=s,a=h(s);return async function(r,i){try{let e;if(r.method==="POST"){const p=await r.json();e=p.query||p}else if(r.method==="GET"){const p=r.nextUrl.searchParams.get("query");if(!p)return n.NextResponse.json(c.formatErrorResponse("Query parameter is required",400),{status:400});try{e=JSON.parse(p)}catch{return n.NextResponse.json(c.formatErrorResponse("Invalid JSON in query parameter",400),{status:400})}}else return n.NextResponse.json(c.formatErrorResponse("Method not allowed",405),{status:405});const u=await t(r,i),d=a.validateQuery(e);if(!d.isValid)return n.NextResponse.json(c.formatErrorResponse(`Query validation failed: ${d.errors.join(", ")}`,400),{status:400});const l=e.measures?.[0]||e.dimensions?.[0];if(!l)return n.NextResponse.json(c.formatErrorResponse("No measures or dimensions specified",400),{status:400});const R=l.split(".")[0],y=await a.generateSQL(R,e,u),x=c.formatSqlResponse(e,y);return n.NextResponse.json(x,{headers:o?m(r,o):{}})}catch(e){return process.env.NODE_ENV!=="test"&&console.error("Next.js SQL handler error:",e),n.NextResponse.json(c.formatErrorResponse(e instanceof Error?e.message:"SQL generation failed",500),{status:500})}}}function g(s){const{extractSecurityContext:t,cors:o}=s,a=h(s);return async function(r,i){try{let e;if(r.method==="POST"){const l=await r.json();e=l.query||l}else if(r.method==="GET"){const l=r.nextUrl.searchParams.get("query");if(!l)return n.NextResponse.json({error:"Query parameter is required",valid:!1},{status:400});try{e=JSON.parse(l)}catch{return n.NextResponse.json({error:"Invalid JSON in query parameter",valid:!1},{status:400})}}else return n.NextResponse.json({error:"Method not allowed",valid:!1},{status:405});const u=await t(r,i),d=await c.handleDryRun(e,u,a);return n.NextResponse.json(d,{headers:o?m(r,o):{}})}catch(e){return process.env.NODE_ENV!=="test"&&console.error("Next.js dry-run handler error:",e),n.NextResponse.json({error:e instanceof Error?e.message:"Dry-run validation failed",valid:!1},{status:400})}}}function w(s){const{extractSecurityContext:t,cors:o}=s,a=h(s);return async function(r,i){try{if(r.method!=="POST")return n.NextResponse.json(c.formatErrorResponse("Method not allowed - use POST",405),{status:405});const e=await r.json(),{queries:u}=e;if(!u||!Array.isArray(u))return n.NextResponse.json(c.formatErrorResponse('Request body must contain a "queries" array',400),{status:400});if(u.length===0)return n.NextResponse.json(c.formatErrorResponse("Queries array cannot be empty",400),{status:400});const d=await t(r,i),l=await c.handleBatchRequest(u,d,a);return n.NextResponse.json(l,{headers:o?m(r,o):{}})}catch(e){return process.env.NODE_ENV!=="test"&&console.error("Next.js batch handler error:",e),n.NextResponse.json(c.formatErrorResponse(e instanceof Error?e.message:"Batch execution failed",500),{status:500})}}}function S(s){return{load:N(s),meta:j(s),sql:E(s),dryRun:g(s),batch:w(s)}}exports.createBatchHandler=w;exports.createCubeHandlers=S;exports.createDryRunHandler=g;exports.createLoadHandler=N;exports.createMetaHandler=j;exports.createOptionsHandler=H;exports.createSqlHandler=E;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("next/server"),c=require("../compiler-DP1pPIcg.cjs");function h(s){const{cubes:t,drizzle:o,schema:a,engineType:f}=s;if(!t||t.length===0)throw new Error("At least one cube must be provided in the cubes array");const r=new c.SemanticLayerCompiler({drizzle:o,schema:a,engineType:f});return t.forEach(i=>{r.registerCube(i)}),r}function m(s,t){const o=s.headers.get("origin"),a={};return t.origin&&(typeof t.origin=="string"?a["Access-Control-Allow-Origin"]=t.origin:Array.isArray(t.origin)?o&&t.origin.includes(o)&&(a["Access-Control-Allow-Origin"]=o):typeof t.origin=="function"&&o&&t.origin(o)&&(a["Access-Control-Allow-Origin"]=o)),t.methods&&(a["Access-Control-Allow-Methods"]=t.methods.join(", ")),t.allowedHeaders&&(a["Access-Control-Allow-Headers"]=t.allowedHeaders.join(", ")),t.credentials&&(a["Access-Control-Allow-Credentials"]="true"),a}function H(s){return async function(o){const a=m(o,s);return new Response(null,{status:200,headers:a})}}function N(s){const{extractSecurityContext:t,cors:o}=s,a=h(s);return async function(r,i){try{let e;if(r.method==="POST"){const y=await r.json();e=y.query||y}else if(r.method==="GET"){const y=r.nextUrl.searchParams.get("query");if(!y)return n.NextResponse.json(c.formatErrorResponse("Query parameter is required",400),{status:400});try{e=JSON.parse(y)}catch{return n.NextResponse.json(c.formatErrorResponse("Invalid JSON in query parameter",400),{status:400})}}else return n.NextResponse.json(c.formatErrorResponse("Method not allowed",405),{status:405});const u=await t(r,i),d=a.validateQuery(e);if(!d.isValid)return n.NextResponse.json(c.formatErrorResponse(`Query validation failed: ${d.errors.join(", ")}`,400),{status:400});const l=await a.executeMultiCubeQuery(e,u),R=c.formatCubeResponse(e,l,a);return n.NextResponse.json(R,{headers:o?m(r,o):{}})}catch(e){return process.env.NODE_ENV!=="test"&&console.error("Next.js load handler error:",e),n.NextResponse.json(c.formatErrorResponse(e instanceof Error?e.message:"Query execution failed",500),{status:500})}}}function j(s){const{cors:t}=s,o=h(s);return async function(f,r){try{const i=o.getMetadata(),e=c.formatMetaResponse(i);return n.NextResponse.json(e,{headers:t?m(f,t):{}})}catch(i){return process.env.NODE_ENV!=="test"&&console.error("Next.js meta handler error:",i),n.NextResponse.json(c.formatErrorResponse(i instanceof Error?i.message:"Failed to fetch metadata",500),{status:500})}}}function E(s){const{extractSecurityContext:t,cors:o}=s,a=h(s);return async function(r,i){try{let e;if(r.method==="POST"){const p=await r.json();e=p.query||p}else if(r.method==="GET"){const p=r.nextUrl.searchParams.get("query");if(!p)return n.NextResponse.json(c.formatErrorResponse("Query parameter is required",400),{status:400});try{e=JSON.parse(p)}catch{return n.NextResponse.json(c.formatErrorResponse("Invalid JSON in query parameter",400),{status:400})}}else return n.NextResponse.json(c.formatErrorResponse("Method not allowed",405),{status:405});const u=await t(r,i),d=a.validateQuery(e);if(!d.isValid)return n.NextResponse.json(c.formatErrorResponse(`Query validation failed: ${d.errors.join(", ")}`,400),{status:400});const l=e.measures?.[0]||e.dimensions?.[0];if(!l)return n.NextResponse.json(c.formatErrorResponse("No measures or dimensions specified",400),{status:400});const R=l.split(".")[0],y=await a.generateSQL(R,e,u),x=c.formatSqlResponse(e,y);return n.NextResponse.json(x,{headers:o?m(r,o):{}})}catch(e){return process.env.NODE_ENV!=="test"&&console.error("Next.js SQL handler error:",e),n.NextResponse.json(c.formatErrorResponse(e instanceof Error?e.message:"SQL generation failed",500),{status:500})}}}function g(s){const{extractSecurityContext:t,cors:o}=s,a=h(s);return async function(r,i){try{let e;if(r.method==="POST"){const l=await r.json();e=l.query||l}else if(r.method==="GET"){const l=r.nextUrl.searchParams.get("query");if(!l)return n.NextResponse.json({error:"Query parameter is required",valid:!1},{status:400});try{e=JSON.parse(l)}catch{return n.NextResponse.json({error:"Invalid JSON in query parameter",valid:!1},{status:400})}}else return n.NextResponse.json({error:"Method not allowed",valid:!1},{status:405});const u=await t(r,i),d=await c.handleDryRun(e,u,a);return n.NextResponse.json(d,{headers:o?m(r,o):{}})}catch(e){return process.env.NODE_ENV!=="test"&&console.error("Next.js dry-run handler error:",e),n.NextResponse.json({error:e instanceof Error?e.message:"Dry-run validation failed",valid:!1},{status:400})}}}function w(s){const{extractSecurityContext:t,cors:o}=s,a=h(s);return async function(r,i){try{if(r.method!=="POST")return n.NextResponse.json(c.formatErrorResponse("Method not allowed - use POST",405),{status:405});const e=await r.json(),{queries:u}=e;if(!u||!Array.isArray(u))return n.NextResponse.json(c.formatErrorResponse('Request body must contain a "queries" array',400),{status:400});if(u.length===0)return n.NextResponse.json(c.formatErrorResponse("Queries array cannot be empty",400),{status:400});const d=await t(r,i),l=await c.handleBatchRequest(u,d,a);return n.NextResponse.json(l,{headers:o?m(r,o):{}})}catch(e){return process.env.NODE_ENV!=="test"&&console.error("Next.js batch handler error:",e),n.NextResponse.json(c.formatErrorResponse(e instanceof Error?e.message:"Batch execution failed",500),{status:500})}}}function S(s){return{load:N(s),meta:j(s),sql:E(s),dryRun:g(s),batch:w(s)}}exports.createBatchHandler=w;exports.createCubeHandlers=S;exports.createDryRunHandler=g;exports.createLoadHandler=N;exports.createMetaHandler=j;exports.createOptionsHandler=H;exports.createSqlHandler=E;
@@ -1,5 +1,5 @@
1
1
  import { NextResponse as n } from "next/server";
2
- import { d as i, f as x, a as E, b as N, c as S, h as b, S as C } from "../compiler-BnHK-nxh.js";
2
+ import { d as i, f as x, a as E, b as N, c as S, h as b, S as C } from "../compiler-gcKytLwd.js";
3
3
  function j(a) {
4
4
  const { cubes: t, drizzle: s, schema: o, engineType: y } = a;
5
5
  if (!t || t.length === 0)
@@ -0,0 +1,56 @@
1
+ import { ReactNode } from 'react';
2
+ import { ChartType, ChartProps } from '../types';
3
+ /**
4
+ * Check if a chart type is supported
5
+ */
6
+ export declare function isValidChartType(chartType: string): chartType is ChartType;
7
+ export interface LazyChartProps extends ChartProps {
8
+ chartType: ChartType;
9
+ fallback?: ReactNode;
10
+ }
11
+ /**
12
+ * Lazy Chart Component
13
+ *
14
+ * Renders a chart component with React.lazy dynamic loading.
15
+ * The chart type determines which chart component is loaded.
16
+ *
17
+ * @example
18
+ * ```tsx
19
+ * <LazyChart
20
+ * chartType="bar"
21
+ * data={chartData}
22
+ * chartConfig={{ yAxis: ['value'] }}
23
+ * height={300}
24
+ * />
25
+ * ```
26
+ */
27
+ export declare function LazyChart({ chartType, fallback, height, ...chartProps }: LazyChartProps): import("react/jsx-runtime").JSX.Element;
28
+ /**
29
+ * Preload a chart type
30
+ *
31
+ * Triggers the dynamic import without rendering.
32
+ * Useful for prefetching charts that will likely be needed.
33
+ *
34
+ * @example
35
+ * ```tsx
36
+ * // Preload bar chart on hover
37
+ * onMouseEnter={() => preloadChart('bar')}
38
+ * ```
39
+ */
40
+ export declare function preloadChart(chartType: ChartType): void;
41
+ /**
42
+ * Preload multiple chart types
43
+ *
44
+ * @example
45
+ * ```tsx
46
+ * // Preload common charts on app init
47
+ * useEffect(() => {
48
+ * preloadCharts(['bar', 'line', 'pie'])
49
+ * }, [])
50
+ * ```
51
+ */
52
+ export declare function preloadCharts(chartTypes: ChartType[]): void;
53
+ /**
54
+ * Get all available chart types
55
+ */
56
+ export declare function getAvailableChartTypes(): ChartType[];
@@ -0,0 +1,90 @@
1
+ import { ChartType } from '../types';
2
+ import { ChartTypeConfig, ChartConfigRegistry } from './chartConfigs';
3
+ /**
4
+ * Get a chart config asynchronously
5
+ *
6
+ * @param chartType The chart type to load config for
7
+ * @returns The chart type config, or null if not found
8
+ *
9
+ * @example
10
+ * ```typescript
11
+ * const config = await getChartConfigAsync('bar')
12
+ * console.log(config?.dropZones)
13
+ * ```
14
+ */
15
+ export declare function getChartConfigAsync(chartType: ChartType): Promise<ChartTypeConfig | null>;
16
+ /**
17
+ * Get a chart config synchronously from cache
18
+ *
19
+ * Returns the cached config if available, otherwise returns the default config.
20
+ * Use this when you need sync access and have already preloaded the config.
21
+ *
22
+ * @param chartType The chart type to get config for
23
+ * @returns The chart type config (from cache or default)
24
+ */
25
+ export declare function getChartConfigSync(chartType: ChartType): ChartTypeConfig;
26
+ /**
27
+ * Check if a chart config is already loaded
28
+ */
29
+ export declare function isChartConfigLoaded(chartType: ChartType): boolean;
30
+ /**
31
+ * React hook for using chart config
32
+ *
33
+ * Loads the chart config asynchronously and caches it.
34
+ * Returns the default config while loading.
35
+ *
36
+ * @param chartType The chart type to load config for
37
+ * @returns Object with config, loading state, and loaded flag
38
+ *
39
+ * @example
40
+ * ```tsx
41
+ * function ChartSetup({ chartType }) {
42
+ * const { config, loading } = useChartConfig(chartType)
43
+ *
44
+ * if (loading) return <Spinner />
45
+ * return <ConfigForm config={config} />
46
+ * }
47
+ * ```
48
+ */
49
+ export declare function useChartConfig(chartType: ChartType | undefined): {
50
+ config: ChartTypeConfig;
51
+ loading: boolean;
52
+ loaded: boolean;
53
+ };
54
+ /**
55
+ * Preload a chart config
56
+ *
57
+ * Triggers the async import without needing to use the config immediately.
58
+ * Useful for prefetching configs that will likely be needed.
59
+ *
60
+ * @param chartType The chart type to preload config for
61
+ */
62
+ export declare function preloadChartConfig(chartType: ChartType): Promise<void>;
63
+ /**
64
+ * Preload multiple chart configs
65
+ *
66
+ * @param chartTypes Array of chart types to preload
67
+ */
68
+ export declare function preloadChartConfigs(chartTypes: ChartType[]): Promise<void>;
69
+ /**
70
+ * Load all chart configs and return as a registry
71
+ *
72
+ * Useful for SSR or when you need all configs upfront.
73
+ * After calling this, all configs are cached and available synchronously.
74
+ *
75
+ * @returns Complete chart config registry
76
+ *
77
+ * @example
78
+ * ```typescript
79
+ * // On server or during initialization
80
+ * const registry = await loadAllChartConfigs()
81
+ * // Now all configs are cached and getChartConfigSync works for all types
82
+ * ```
83
+ */
84
+ export declare function loadAllChartConfigs(): Promise<ChartConfigRegistry>;
85
+ /**
86
+ * Clear the config cache
87
+ *
88
+ * Useful for testing or when configs need to be reloaded.
89
+ */
90
+ export declare function clearChartConfigCache(): void;
@@ -3,8 +3,14 @@
3
3
  *
4
4
  * Chart components only - optimized for applications that only need charts
5
5
  * without the full dashboard or query builder functionality.
6
+ *
7
+ * For code splitting, use LazyChart instead of direct chart imports:
8
+ * import { LazyChart, preloadCharts } from 'drizzle-cube/client/charts'
6
9
  */
7
10
  export { RechartsBarChart, RechartsLineChart, RechartsAreaChart, RechartsPieChart, RechartsScatterChart, RechartsRadarChart, RechartsRadialBarChart, RechartsTreeMapChart, DataTable } from './components/charts';
11
+ export { LazyChart, preloadChart, preloadCharts, isValidChartType, getAvailableChartTypes } from './charts/ChartLoader';
12
+ export type { LazyChartProps } from './charts/ChartLoader';
13
+ export { getChartConfigAsync, getChartConfigSync, useChartConfig, isChartConfigLoaded, preloadChartConfig, preloadChartConfigs, loadAllChartConfigs, clearChartConfigCache } from './charts/lazyChartConfigRegistry';
8
14
  export { formatChartData } from './utils/index';
9
15
  export { CHART_COLORS, POSITIVE_COLOR, NEGATIVE_COLOR, CHART_MARGINS } from './utils/chartConstants';
10
16
  export type { ChartType, ChartAxisConfig, ChartDisplayConfig } from './types';
@@ -1,18 +1,41 @@
1
- import { v as t, C as s, D as h, N as R, I as e, A as C, B as c, a as O, P as T, R as A, b as I, S, T as L, f as _ } from "./chunks/charts-jwgcWeFt.js";
1
+ import { L as t, r as e, f as s, b as o, k as C, l as h, m as f, i as l, q as p, p as d, n as i, o as R, a as c, u as m } from "./chunks/charts-DL9XOlaK.js";
2
+ import { a as g, C as x, N as u, P as A } from "./chunks/chart-activitygridchart-BRk9BNnp.js";
3
+ import { default as L } from "./chunks/chart-barchart-BzoejYkT.js";
4
+ import { default as y } from "./chunks/chart-linechart-Dgb10zbj.js";
5
+ import { A as I } from "./chunks/chart-areachart-Beu8sO9v.js";
6
+ import { default as b } from "./chunks/chart-piechart-B-0BQh-d.js";
7
+ import { default as N } from "./chunks/chart-scatterchart-om9-qmtE.js";
8
+ import { default as V } from "./chunks/chart-radarchart-BwZM1yTd.js";
9
+ import { default as D } from "./chunks/chart-radialbarchart-CythI1zx.js";
10
+ import { default as H } from "./chunks/chart-treemapchart-Dc35Miif.js";
11
+ import { default as k } from "./chunks/chart-datatable-BvV7gLPZ.js";
2
12
  export {
3
- t as CHART_COLORS,
4
- s as CHART_MARGINS,
5
- h as DataTable,
6
- R as NEGATIVE_COLOR,
7
- e as POSITIVE_COLOR,
8
- C as RechartsAreaChart,
9
- c as RechartsBarChart,
10
- O as RechartsLineChart,
11
- T as RechartsPieChart,
12
- A as RechartsRadarChart,
13
- I as RechartsRadialBarChart,
14
- S as RechartsScatterChart,
15
- L as RechartsTreeMapChart,
16
- _ as formatChartData
13
+ g as CHART_COLORS,
14
+ x as CHART_MARGINS,
15
+ k as DataTable,
16
+ t as LazyChart,
17
+ u as NEGATIVE_COLOR,
18
+ A as POSITIVE_COLOR,
19
+ I as RechartsAreaChart,
20
+ L as RechartsBarChart,
21
+ y as RechartsLineChart,
22
+ b as RechartsPieChart,
23
+ V as RechartsRadarChart,
24
+ D as RechartsRadialBarChart,
25
+ N as RechartsScatterChart,
26
+ H as RechartsTreeMapChart,
27
+ e as clearChartConfigCache,
28
+ s as formatChartData,
29
+ o as getAvailableChartTypes,
30
+ C as getChartConfigAsync,
31
+ h as getChartConfigSync,
32
+ f as isChartConfigLoaded,
33
+ l as isValidChartType,
34
+ p as loadAllChartConfigs,
35
+ d as preloadChart,
36
+ i as preloadChartConfig,
37
+ R as preloadChartConfigs,
38
+ c as preloadCharts,
39
+ m as useChartConfig
17
40
  };
18
41
  //# sourceMappingURL=charts.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"charts.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
1
+ {"version":3,"file":"charts.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;"}