drizzle-cube 0.7.0 → 0.8.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.
- package/dist/adapters/ActivityGridChart.config-BQhBE_Mr.js +2 -0
- package/dist/adapters/ActivityGridChart.config-C3tSuOGV.cjs +1 -0
- package/dist/adapters/AreaChart.config-3cme8HyQ.js +2 -0
- package/dist/adapters/AreaChart.config-BSxrT52Z.cjs +1 -0
- package/dist/adapters/BarChart.config-BKS8IecE.cjs +1 -0
- package/dist/adapters/BarChart.config-lt_7PdIi.js +2 -0
- package/dist/adapters/BoxPlotChart.config-B7qvRnrF.cjs +1 -0
- package/dist/adapters/BoxPlotChart.config-Dv6ECj2j.js +2 -0
- package/dist/adapters/BubbleChart.config-BrIH7OAy.cjs +1 -0
- package/dist/adapters/BubbleChart.config-Fhotb7Pg.js +2 -0
- package/dist/adapters/CandlestickChart.config-CWH41FmF.cjs +1 -0
- package/dist/adapters/CandlestickChart.config-RPtXuxsX.js +2 -0
- package/dist/adapters/DataTable.config-71L0GzlT.js +2 -0
- package/dist/adapters/DataTable.config-BsOMQq3J.cjs +1 -0
- package/dist/adapters/FunnelChart.config-Cqte9C04.cjs +1 -0
- package/dist/adapters/FunnelChart.config-DJtwWeNz.js +2 -0
- package/dist/adapters/GaugeChart.config-WkwZ9VdS.cjs +1 -0
- package/dist/adapters/GaugeChart.config-vpVQlP5B.js +2 -0
- package/dist/adapters/HeatMapChart.config-DcmkDl07.cjs +1 -0
- package/dist/adapters/HeatMapChart.config-DsmMgGxJ.js +2 -0
- package/dist/adapters/KpiDelta.config-DVy561BH.js +2 -0
- package/dist/adapters/KpiDelta.config-dpqwLHNE.cjs +1 -0
- package/dist/adapters/KpiNumber.config-927l8nq8.js +2 -0
- package/dist/adapters/KpiNumber.config-BqFBMfPf.cjs +1 -0
- package/dist/adapters/KpiText.config-C-fZXuHq.cjs +1 -0
- package/dist/adapters/KpiText.config-CWoXuhMA.js +2 -0
- package/dist/adapters/LineChart.config-DTp7pqOY.js +2 -0
- package/dist/adapters/LineChart.config-DUGvSjcH.cjs +1 -0
- package/dist/adapters/MarkdownChart.config-23Dmv2Ty.cjs +1 -0
- package/dist/adapters/MarkdownChart.config-Cb2TnS0I.js +2 -0
- package/dist/adapters/MeasureProfileChart.config-B2qbWdhy.cjs +1 -0
- package/dist/adapters/MeasureProfileChart.config-CvBCeI5b.js +2 -0
- package/dist/adapters/PieChart.config-BzJb13QA.js +2 -0
- package/dist/adapters/PieChart.config-plCn5Ehr.cjs +1 -0
- package/dist/adapters/ProportionBarChart.config-1r-_moBH.cjs +1 -0
- package/dist/adapters/ProportionBarChart.config-CN6TtHTp.js +2 -0
- package/dist/adapters/RadarChart.config-BYhdj9M7.js +2 -0
- package/dist/adapters/RadarChart.config-CeUMP-1g.cjs +1 -0
- package/dist/adapters/RadialBarChart.config-B88yXNsq.cjs +1 -0
- package/dist/adapters/RadialBarChart.config-ZMK9HMoh.js +2 -0
- package/dist/adapters/RetentionCombinedChart.config-B5yvgUHM.cjs +1 -0
- package/dist/adapters/RetentionCombinedChart.config-Dd-YMdK8.js +2 -0
- package/dist/adapters/RetentionHeatmap.config-BYzDleoV.cjs +1 -0
- package/dist/adapters/RetentionHeatmap.config-Dvj7yTB0.js +2 -0
- package/dist/adapters/SankeyChart.config-CPFRmgFb.cjs +1 -0
- package/dist/adapters/SankeyChart.config-ClgqXM1N.js +2 -0
- package/dist/adapters/ScatterChart.config-CvJiqPa5.cjs +1 -0
- package/dist/adapters/ScatterChart.config-DLZ3rYMq.js +2 -0
- package/dist/adapters/SunburstChart.config-C_1V5hoQ.cjs +1 -0
- package/dist/adapters/SunburstChart.config-FNU75NCg.js +2 -0
- package/dist/adapters/TreeMapChart.config-CprZk_YF.js +2 -0
- package/dist/adapters/TreeMapChart.config-DNwd0ge9.cjs +1 -0
- package/dist/adapters/WaterfallChart.config-BBhcN_Fh.cjs +1 -0
- package/dist/adapters/WaterfallChart.config-H7s6SSV3.js +2 -0
- package/dist/adapters/{compiler-DAyodAnH.cjs → compiler-BaLO10VN.cjs} +7 -7
- package/dist/adapters/{compiler-Dq04wAjm.js → compiler-CQJ5GOwF.js} +286 -119
- package/dist/adapters/core/http-port.d.ts +34 -7
- package/dist/adapters/core/index.cjs +1 -1
- package/dist/adapters/core/index.d.ts +1 -0
- package/dist/adapters/core/index.js +2 -2
- package/dist/adapters/core/rest-handlers.d.ts +1 -1
- package/dist/adapters/{core-BjxfG6Uf.js → core-DXkuSUBg.js} +80 -64
- package/dist/adapters/core-DgTGXxDu.cjs +1 -0
- package/dist/adapters/express/index.cjs +2 -2
- package/dist/adapters/express/index.d.ts +11 -2
- package/dist/adapters/express/index.js +14 -14
- package/dist/adapters/fastify/index.cjs +2 -2
- package/dist/adapters/fastify/index.d.ts +11 -2
- package/dist/adapters/fastify/index.js +12 -12
- package/dist/adapters/{handler-ox6qxLw5.js → handler-CphYSZRh.js} +76 -77
- package/dist/adapters/{handler-C6Hj6_Yk.cjs → handler-DrRT6c14.cjs} +8 -8
- package/dist/adapters/hono/index.cjs +1 -1
- package/dist/adapters/hono/index.js +9 -9
- package/dist/adapters/mcp-tools-handlers.d.ts +10 -3
- package/dist/adapters/mcp-tools.cjs +1 -1
- package/dist/adapters/mcp-tools.js +18 -20
- package/dist/adapters/mcp-transport-BGkSz-ZT.cjs +40 -0
- package/dist/adapters/mcp-transport-fJud19xz.js +606 -0
- package/dist/adapters/mcp-transport.d.ts +13 -2
- package/dist/adapters/nextjs/index.cjs +1 -1
- package/dist/adapters/nextjs/index.d.ts +5 -2
- package/dist/adapters/nextjs/index.js +32 -32
- package/dist/adapters/{openai-C9LNhHfK.js → openai-CBrN4nxl.js} +2 -2
- package/dist/adapters/{openai-DlT-0VRC.cjs → openai-CI9vGKSf.cjs} +1 -1
- package/dist/adapters/{openai-BffpdO4n.cjs → openai-CSzWluuv.cjs} +1 -1
- package/dist/adapters/{openai-CmyXJWti.js → openai-D-VMcPao.js} +1 -1
- package/dist/adapters/utils-BY0-KFyI.cjs +128 -0
- package/dist/adapters/{utils-tjiwXFnP.js → utils-DkmShl5f.js} +29 -22
- package/dist/adapters/utils.cjs +1 -1
- package/dist/adapters/utils.d.ts +2 -2
- package/dist/adapters/utils.js +1 -1
- package/dist/cjs/adapters/core/http-port.d.ts +34 -7
- package/dist/cjs/adapters/core/index.d.ts +1 -0
- package/dist/cjs/adapters/core/rest-handlers.d.ts +1 -1
- package/dist/cjs/adapters/express/index.d.ts +11 -2
- package/dist/cjs/adapters/fastify/index.d.ts +11 -2
- package/dist/cjs/adapters/mcp-tools-handlers.d.ts +10 -3
- package/dist/cjs/adapters/mcp-transport.d.ts +13 -2
- package/dist/cjs/adapters/nextjs/index.d.ts +5 -2
- package/dist/cjs/adapters/utils.d.ts +2 -2
- package/dist/cjs/client/charts/chartConfigs.d.ts +1 -1
- package/dist/cjs/client/components/charts/GaugeChart.d.ts +8 -0
- package/dist/cjs/client/components/charts/gaugeChartHelpers.d.ts +117 -12
- package/dist/cjs/server/adapters/base-adapter.d.ts +46 -0
- package/dist/cjs/server/adapters/databend-adapter.d.ts +5 -0
- package/dist/cjs/server/adapters/duckdb-adapter.d.ts +5 -0
- package/dist/cjs/server/adapters/mysql-adapter.d.ts +14 -0
- package/dist/cjs/server/adapters/postgres-adapter.d.ts +15 -0
- package/dist/cjs/server/adapters/snowflake-adapter.d.ts +6 -0
- package/dist/cjs/server/adapters/sqlite-adapter.d.ts +21 -0
- package/dist/cjs/server/attribute-dimensions.d.ts +99 -0
- package/dist/cjs/server/cache-utils.d.ts +5 -1
- package/dist/cjs/server/compiler-metadata.d.ts +24 -3
- package/dist/cjs/server/compiler.d.ts +157 -10
- package/dist/cjs/server/execution/query-result-cache.d.ts +1 -1
- package/dist/cjs/server/index.d.ts +11 -3
- package/dist/cjs/server/query-handlers.d.ts +1 -1
- package/dist/cjs/server/types/core.d.ts +8 -0
- package/dist/cjs/server/types/cube.d.ts +27 -2
- package/dist/client/charts/chartConfigs.d.ts +1 -1
- package/dist/client/charts.js +12 -12
- package/dist/client/chunks/{DashboardEditModal-ByXLlXZD.js → DashboardEditModal-9An5EDAz.js} +1061 -992
- package/dist/client/chunks/{DashboardEditModal-ByXLlXZD.js.map → DashboardEditModal-9An5EDAz.js.map} +1 -1
- package/dist/client/chunks/{ProportionBarChart-lOeVz8ZC.js → ProportionBarChart-BVcbGY2C.js} +3 -3
- package/dist/client/chunks/{ProportionBarChart-lOeVz8ZC.js.map → ProportionBarChart-BVcbGY2C.js.map} +1 -1
- package/dist/client/chunks/{RetentionCombinedChart-Mcm7zHFx.js → RetentionCombinedChart-D68Rvdi-.js} +3 -3
- package/dist/client/chunks/{RetentionCombinedChart-Mcm7zHFx.js.map → RetentionCombinedChart-D68Rvdi-.js.map} +1 -1
- package/dist/client/chunks/{RetentionHeatmap-4VJx5KDM.js → RetentionHeatmap-CE7BAjrB.js} +2 -2
- package/dist/client/chunks/{RetentionHeatmap-4VJx5KDM.js.map → RetentionHeatmap-CE7BAjrB.js.map} +1 -1
- package/dist/client/chunks/{af-ZA-BTaChuqI.js → af-ZA-C0dGb_53.js} +7 -3
- package/dist/client/chunks/af-ZA-C0dGb_53.js.map +1 -0
- package/dist/client/chunks/{analysis-builder-CWTJQQtL.js → analysis-builder-D1pYvvwc.js} +9 -9
- package/dist/client/chunks/{analysis-builder-CWTJQQtL.js.map → analysis-builder-D1pYvvwc.js.map} +1 -1
- package/dist/client/chunks/{analysis-builder-shared-l-4WKVS1.js → analysis-builder-shared-BQvwUc6z.js} +9 -9
- package/dist/client/chunks/{analysis-builder-shared-l-4WKVS1.js.map → analysis-builder-shared-BQvwUc6z.js.map} +1 -1
- package/dist/client/chunks/{chart-activity-grid-DVOhLgxv.js → chart-activity-grid-DvD_4wJz.js} +12 -5
- package/dist/client/chunks/chart-activity-grid-DvD_4wJz.js.map +1 -0
- package/dist/client/chunks/{chart-area-C-5ATxvi.js → chart-area-DPp3hSOK.js} +2 -2
- package/dist/client/chunks/{chart-area-C-5ATxvi.js.map → chart-area-DPp3hSOK.js.map} +1 -1
- package/dist/client/chunks/{chart-bar-CPiLaXHP.js → chart-bar-Od3pOyZ0.js} +3 -3
- package/dist/client/chunks/{chart-bar-CPiLaXHP.js.map → chart-bar-Od3pOyZ0.js.map} +1 -1
- package/dist/client/chunks/{chart-box-plot-Bae5O9xC.js → chart-box-plot-l0iFn2n2.js} +2 -2
- package/dist/client/chunks/{chart-box-plot-Bae5O9xC.js.map → chart-box-plot-l0iFn2n2.js.map} +1 -1
- package/dist/client/chunks/{chart-bubble-BFN5WIpf.js → chart-bubble-Dl0RcP8N.js} +2 -2
- package/dist/client/chunks/{chart-bubble-BFN5WIpf.js.map → chart-bubble-Dl0RcP8N.js.map} +1 -1
- package/dist/client/chunks/{chart-candlestick-PBQKp_z7.js → chart-candlestick-DZMqbscF.js} +2 -2
- package/dist/client/chunks/{chart-candlestick-PBQKp_z7.js.map → chart-candlestick-DZMqbscF.js.map} +1 -1
- package/dist/client/chunks/{chart-config-gauge-DNafFwfS.js → chart-config-gauge-CJktdjox.js} +3 -4
- package/dist/client/chunks/chart-config-gauge-CJktdjox.js.map +1 -0
- package/dist/client/chunks/{chart-data-table-SNSqZj9B.js → chart-data-table-DgiNBOWf.js} +5 -5
- package/dist/client/chunks/chart-data-table-DgiNBOWf.js.map +1 -0
- package/dist/client/chunks/{chart-funnel-CkHSXp6h.js → chart-funnel-YLZlyN1X.js} +2 -2
- package/dist/client/chunks/{chart-funnel-CkHSXp6h.js.map → chart-funnel-YLZlyN1X.js.map} +1 -1
- package/dist/client/chunks/{chart-gauge-DHIGq3TH.js → chart-gauge-BsqE2wwF.js} +169 -116
- package/dist/client/chunks/chart-gauge-BsqE2wwF.js.map +1 -0
- package/dist/client/chunks/{chart-heat-map-Bb8L1XQr.js → chart-heat-map-BsND8RM_.js} +3 -3
- package/dist/client/chunks/{chart-heat-map-Bb8L1XQr.js.map → chart-heat-map-BsND8RM_.js.map} +1 -1
- package/dist/client/chunks/{chart-kpi-delta-BJCOXE-F.js → chart-kpi-delta-m0azuva-.js} +3 -3
- package/dist/client/chunks/{chart-kpi-delta-BJCOXE-F.js.map → chart-kpi-delta-m0azuva-.js.map} +1 -1
- package/dist/client/chunks/{chart-kpi-number-Cdqgv20g.js → chart-kpi-number-6JS15SqF.js} +5 -5
- package/dist/client/chunks/{chart-kpi-number-Cdqgv20g.js.map → chart-kpi-number-6JS15SqF.js.map} +1 -1
- package/dist/client/chunks/{chart-kpi-text-B10ZHCsI.js → chart-kpi-text-BqX8p8Jn.js} +3 -3
- package/dist/client/chunks/{chart-kpi-text-B10ZHCsI.js.map → chart-kpi-text-BqX8p8Jn.js.map} +1 -1
- package/dist/client/chunks/{chart-line-CzvVL3Be.js → chart-line-NCmpxBfE.js} +3 -3
- package/dist/client/chunks/{chart-line-CzvVL3Be.js.map → chart-line-NCmpxBfE.js.map} +1 -1
- package/dist/client/chunks/{chart-markdown-C0xxBW81.js → chart-markdown-ZOobqiiX.js} +2 -2
- package/dist/client/chunks/{chart-markdown-C0xxBW81.js.map → chart-markdown-ZOobqiiX.js.map} +1 -1
- package/dist/client/chunks/{chart-measure-profile-BSUPFZCR.js → chart-measure-profile-CBAZaicJ.js} +3 -3
- package/dist/client/chunks/{chart-measure-profile-BSUPFZCR.js.map → chart-measure-profile-CBAZaicJ.js.map} +1 -1
- package/dist/client/chunks/{chart-pie-CwRfwWWZ.js → chart-pie-ChrasEI8.js} +3 -3
- package/dist/client/chunks/{chart-pie-CwRfwWWZ.js.map → chart-pie-ChrasEI8.js.map} +1 -1
- package/dist/client/chunks/{chart-radar-Dfql2E7i.js → chart-radar-CxSVF7yL.js} +3 -3
- package/dist/client/chunks/{chart-radar-Dfql2E7i.js.map → chart-radar-CxSVF7yL.js.map} +1 -1
- package/dist/client/chunks/{chart-radial-bar-oE9OZ1IX.js → chart-radial-bar--SN0Wph0.js} +3 -3
- package/dist/client/chunks/{chart-radial-bar-oE9OZ1IX.js.map → chart-radial-bar--SN0Wph0.js.map} +1 -1
- package/dist/client/chunks/{chart-sankey-tK7Oz1bC.js → chart-sankey-CDOSGg9r.js} +2 -2
- package/dist/client/chunks/{chart-sankey-tK7Oz1bC.js.map → chart-sankey-CDOSGg9r.js.map} +1 -1
- package/dist/client/chunks/{chart-scatter-BtLfAsZb.js → chart-scatter-DgcEF-kI.js} +3 -3
- package/dist/client/chunks/{chart-scatter-BtLfAsZb.js.map → chart-scatter-DgcEF-kI.js.map} +1 -1
- package/dist/client/chunks/{chart-sunburst-B7ryWwQ1.js → chart-sunburst-MB-jlGBm.js} +3 -3
- package/dist/client/chunks/{chart-sunburst-B7ryWwQ1.js.map → chart-sunburst-MB-jlGBm.js.map} +1 -1
- package/dist/client/chunks/{chart-tree-map-DU5M3-qe.js → chart-tree-map-DeDXveVd.js} +3 -3
- package/dist/client/chunks/{chart-tree-map-DU5M3-qe.js.map → chart-tree-map-DeDXveVd.js.map} +1 -1
- package/dist/client/chunks/{chart-waterfall-CAwutpzd.js → chart-waterfall-ur4vkO1j.js} +3 -3
- package/dist/client/chunks/{chart-waterfall-CAwutpzd.js.map → chart-waterfall-ur4vkO1j.js.map} +1 -1
- package/dist/client/chunks/{charts-core-BxBB2zBE.js → charts-core-BAH5pkSB.js} +2 -2
- package/dist/client/chunks/{charts-core-BxBB2zBE.js.map → charts-core-BAH5pkSB.js.map} +1 -1
- package/dist/client/chunks/charts-loader-eToV8je7.js +85 -0
- package/dist/client/chunks/{charts-loader-0avVzeDd.js.map → charts-loader-eToV8je7.js.map} +1 -1
- package/dist/client/chunks/{exceljs.min-DWC_b8G9.js → exceljs.min-CiByP8VQ.js} +2 -3
- package/dist/client/chunks/{exceljs.min-DWC_b8G9.js.map → exceljs.min-CiByP8VQ.js.map} +1 -1
- package/dist/client/chunks/{nl-NL-BSMhprPr.js → nl-NL-CMXHDBr0.js} +10 -3
- package/dist/client/chunks/nl-NL-CMXHDBr0.js.map +1 -0
- package/dist/client/chunks/{schema-visualization-CGbnbzj_.js → schema-visualization-BEbFtUIL.js} +3 -3
- package/dist/client/chunks/{schema-visualization-CGbnbzj_.js.map → schema-visualization-BEbFtUIL.js.map} +1 -1
- package/dist/client/chunks/{useDirtyStateTracking-Dc-Si4db.js → useDirtyStateTracking-CSDg96Rw.js} +4 -4
- package/dist/client/chunks/{useDirtyStateTracking-Dc-Si4db.js.map → useDirtyStateTracking-CSDg96Rw.js.map} +1 -1
- package/dist/client/chunks/{useExplainAI-DJbc7Lu4.js → useExplainAI-BnkoZ-zS.js} +4 -4
- package/dist/client/chunks/{useExplainAI-DJbc7Lu4.js.map → useExplainAI-BnkoZ-zS.js.map} +1 -1
- package/dist/client/chunks/{vendor-cTfe9Kho.js → vendor-BmJDaduD.js} +2 -2
- package/dist/client/chunks/vendor-BmJDaduD.js.map +1 -0
- package/dist/client/components/charts/GaugeChart.d.ts +8 -0
- package/dist/client/components/charts/gaugeChartHelpers.d.ts +117 -12
- package/dist/client/components.js +1 -1
- package/dist/client/hooks.js +3 -3
- package/dist/client/icons.js +1 -1
- package/dist/client/index.js +13 -13
- package/dist/client/providers.js +1 -1
- package/dist/client/schema.js +1 -1
- package/dist/client/utils.js +4 -4
- package/dist/client-bundle-stats.html +1 -1
- package/dist/mcp-app/mcp-app.html +88 -88
- package/dist/server/adapters/base-adapter.d.ts +46 -0
- package/dist/server/adapters/databend-adapter.d.ts +5 -0
- package/dist/server/adapters/duckdb-adapter.d.ts +5 -0
- package/dist/server/adapters/mysql-adapter.d.ts +14 -0
- package/dist/server/adapters/postgres-adapter.d.ts +15 -0
- package/dist/server/adapters/snowflake-adapter.d.ts +6 -0
- package/dist/server/adapters/sqlite-adapter.d.ts +21 -0
- package/dist/server/attribute-dimensions.d.ts +99 -0
- package/dist/server/cache-utils.d.ts +5 -1
- package/dist/server/compiler-metadata.d.ts +24 -3
- package/dist/server/compiler.d.ts +157 -10
- package/dist/server/execution/query-result-cache.d.ts +1 -1
- package/dist/server/index.cjs +40 -36
- package/dist/server/index.d.ts +11 -3
- package/dist/server/index.js +681 -482
- package/dist/server/{openai-Czk1BdHa.js → openai-6uUf7h-5.js} +1 -1
- package/dist/server/{openai-DBwI1OSu.cjs → openai-BBe1XbZd.cjs} +1 -1
- package/dist/server/{openai-Cu4TXXjl.cjs → openai-BmADmD1e.cjs} +1 -1
- package/dist/server/{openai-CUf4vc3Q.js → openai-C1gLuR-0.js} +1 -1
- package/dist/server/query-handlers.d.ts +1 -1
- package/dist/server/types/core.d.ts +8 -0
- package/dist/server/types/cube.d.ts +27 -2
- package/package.json +2 -2
- package/dist/adapters/ActivityGridChart.config-DaYILvFZ.cjs +0 -1
- package/dist/adapters/ActivityGridChart.config-_SyTBEyR.js +0 -2
- package/dist/adapters/AreaChart.config-BKh6fY1_.cjs +0 -1
- package/dist/adapters/AreaChart.config-CJoxLP3Y.js +0 -2
- package/dist/adapters/BarChart.config-Bm1bfRbI.cjs +0 -1
- package/dist/adapters/BarChart.config-CGu2Bqrx.js +0 -2
- package/dist/adapters/BoxPlotChart.config-B7M9CQaE.js +0 -2
- package/dist/adapters/BoxPlotChart.config-CXQel8Hk.cjs +0 -1
- package/dist/adapters/BubbleChart.config-BJ36IuVS.cjs +0 -1
- package/dist/adapters/BubbleChart.config-CWoXeLdm.js +0 -2
- package/dist/adapters/CandlestickChart.config-CGMLZVIy.cjs +0 -1
- package/dist/adapters/CandlestickChart.config-CzOcfF1e.js +0 -2
- package/dist/adapters/DataTable.config-CdAzueTs.cjs +0 -1
- package/dist/adapters/DataTable.config-D_KmPyxV.js +0 -2
- package/dist/adapters/FunnelChart.config-D1QAUuYl.cjs +0 -1
- package/dist/adapters/FunnelChart.config-DCRHQoFc.js +0 -2
- package/dist/adapters/GaugeChart.config-DAybRXP3.js +0 -2
- package/dist/adapters/GaugeChart.config-WUPfyLP-.cjs +0 -1
- package/dist/adapters/HeatMapChart.config-CziltPnC.cjs +0 -1
- package/dist/adapters/HeatMapChart.config-DHpXNONW.js +0 -2
- package/dist/adapters/KpiDelta.config-Bw5o0ocY.js +0 -2
- package/dist/adapters/KpiDelta.config-CdAmE1pw.cjs +0 -1
- package/dist/adapters/KpiNumber.config-CQ_wq2gx.js +0 -2
- package/dist/adapters/KpiNumber.config-wxN8x4DC.cjs +0 -1
- package/dist/adapters/KpiText.config-DIRIC97F.cjs +0 -1
- package/dist/adapters/KpiText.config-eODcP6Hn.js +0 -2
- package/dist/adapters/LineChart.config-32-9zA2V.js +0 -2
- package/dist/adapters/LineChart.config-BukeFp6z.cjs +0 -1
- package/dist/adapters/MarkdownChart.config-BVsR5LDy.js +0 -2
- package/dist/adapters/MarkdownChart.config-j4veYjcZ.cjs +0 -1
- package/dist/adapters/MeasureProfileChart.config-BRDYx1hw.js +0 -2
- package/dist/adapters/MeasureProfileChart.config-CIosBxco.cjs +0 -1
- package/dist/adapters/PieChart.config-Bj8KiA0n.cjs +0 -1
- package/dist/adapters/PieChart.config-DgAj3y-I.js +0 -2
- package/dist/adapters/ProportionBarChart.config-BfFOppHY.js +0 -2
- package/dist/adapters/ProportionBarChart.config-c8GGE1aK.cjs +0 -1
- package/dist/adapters/RadarChart.config-D7iHY1v9.js +0 -2
- package/dist/adapters/RadarChart.config-ghlANG2-.cjs +0 -1
- package/dist/adapters/RadialBarChart.config-CsXIz-0v.js +0 -2
- package/dist/adapters/RadialBarChart.config-Dsvu2CPV.cjs +0 -1
- package/dist/adapters/RetentionCombinedChart.config-CdT1kXC7.js +0 -2
- package/dist/adapters/RetentionCombinedChart.config-sDjFKH9K.cjs +0 -1
- package/dist/adapters/RetentionHeatmap.config-CvKBvQmu.cjs +0 -1
- package/dist/adapters/RetentionHeatmap.config-DbM3ICwc.js +0 -2
- package/dist/adapters/SankeyChart.config-BNBcIHaD.js +0 -2
- package/dist/adapters/SankeyChart.config-DZscz3kh.cjs +0 -1
- package/dist/adapters/ScatterChart.config-BNYIddyM.cjs +0 -1
- package/dist/adapters/ScatterChart.config-CEhtoLWc.js +0 -2
- package/dist/adapters/SunburstChart.config-ClseCzji.cjs +0 -1
- package/dist/adapters/SunburstChart.config-nnphNoVO.js +0 -2
- package/dist/adapters/TreeMapChart.config-C8-75muA.js +0 -2
- package/dist/adapters/TreeMapChart.config-DoXeUg9Y.cjs +0 -1
- package/dist/adapters/WaterfallChart.config-BOF1qxY3.cjs +0 -1
- package/dist/adapters/WaterfallChart.config-uW5YyOji.js +0 -2
- package/dist/adapters/core-zV2w0hO2.cjs +0 -1
- package/dist/adapters/mcp-transport-C_t_p0wU.cjs +0 -40
- package/dist/adapters/mcp-transport-DFH9e6de.js +0 -603
- package/dist/adapters/utils-C5FLHK04.cjs +0 -128
- package/dist/client/chunks/af-ZA-BTaChuqI.js.map +0 -1
- package/dist/client/chunks/chart-activity-grid-DVOhLgxv.js.map +0 -1
- package/dist/client/chunks/chart-config-gauge-DNafFwfS.js.map +0 -1
- package/dist/client/chunks/chart-data-table-SNSqZj9B.js.map +0 -1
- package/dist/client/chunks/chart-gauge-DHIGq3TH.js.map +0 -1
- package/dist/client/chunks/charts-loader-0avVzeDd.js +0 -85
- package/dist/client/chunks/nl-NL-BSMhprPr.js.map +0 -1
- package/dist/client/chunks/vendor-cTfe9Kho.js.map +0 -1
|
@@ -111,6 +111,17 @@ export interface DatabaseAdapter {
|
|
|
111
111
|
* @returns SQL expression with type casting
|
|
112
112
|
*/
|
|
113
113
|
castToType(fieldExpr: AnyColumn | SQL, targetType: 'timestamp' | 'decimal' | 'integer'): SQL;
|
|
114
|
+
/**
|
|
115
|
+
* Cast expression to specific database type, tolerantly: unparseable input yields NULL
|
|
116
|
+
* instead of raising an error (PostgreSQL's `::`/`CAST` on bad input) or silently producing
|
|
117
|
+
* 0 (MySQL/SQLite `CAST` on non-numeric text). Intended for EAV-style schemas where a text
|
|
118
|
+
* column holds numbers/timestamps for some attributes and free text for others, so one dirty
|
|
119
|
+
* value doesn't fail the whole query or masquerade as a real 0.
|
|
120
|
+
* @param fieldExpr - The field expression to cast
|
|
121
|
+
* @param targetType - Target database type
|
|
122
|
+
* @returns SQL expression with tolerant type casting; unparseable/NULL input yields NULL
|
|
123
|
+
*/
|
|
124
|
+
tryCastToType(fieldExpr: AnyColumn | SQL, targetType: 'timestamp' | 'decimal' | 'integer'): SQL;
|
|
114
125
|
/**
|
|
115
126
|
* Build AVG aggregation expression with database-specific null handling
|
|
116
127
|
* @param fieldExpr - The field expression to average
|
|
@@ -216,6 +227,7 @@ export declare abstract class BaseDatabaseAdapter implements DatabaseAdapter {
|
|
|
216
227
|
abstract buildPeriodSeriesSubquery(maxPeriod: number): SQL;
|
|
217
228
|
abstract buildTimeDimension(granularity: TimeGranularity, fieldExpr: AnyColumn | SQL): SQL;
|
|
218
229
|
abstract castToType(fieldExpr: AnyColumn | SQL, targetType: 'timestamp' | 'decimal' | 'integer'): SQL;
|
|
230
|
+
abstract tryCastToType(fieldExpr: AnyColumn | SQL, targetType: 'timestamp' | 'decimal' | 'integer'): SQL;
|
|
219
231
|
abstract getCapabilities(): DatabaseCapabilities;
|
|
220
232
|
abstract buildPercentile(fieldExpr: AnyColumn | SQL, percentile: number): SQL | null;
|
|
221
233
|
/**
|
|
@@ -303,6 +315,40 @@ export declare abstract class BaseDatabaseAdapter implements DatabaseAdapter {
|
|
|
303
315
|
field: AnyColumn | SQL;
|
|
304
316
|
direction: 'asc' | 'desc';
|
|
305
317
|
}>, config?: WindowFunctionConfig): SQL | null;
|
|
318
|
+
/**
|
|
319
|
+
* Regex pattern for tryCastToType's decimal guard: optional leading sign, digits with an
|
|
320
|
+
* optional fractional part (or a bare fractional part like `.5`), surrounded by optional
|
|
321
|
+
* spaces; rejects everything else. Shared by PostgreSQL (`~`) and MySQL/SingleStore
|
|
322
|
+
* (`REGEXP`).
|
|
323
|
+
*
|
|
324
|
+
* Deliberately written using only POSIX ERE syntax (`[0-9]` instead of `\d`, a literal
|
|
325
|
+
* space instead of `\s`) rather than Perl/ICU shorthands. PostgreSQL's `~` always
|
|
326
|
+
* understands `\d`/`\s`, and MySQL 8.0.4+'s default ICU regex engine does too — but
|
|
327
|
+
* SingleStore's `REGEXP` is dialect-switchable via the `regexp_format` session variable
|
|
328
|
+
* ('extended' = POSIX ERE, 'advanced' = ICU/PCRE-style), and SingleStore's own docs
|
|
329
|
+
* recommend explicitly opting into 'advanced' for new regex logic, implying 'extended'
|
|
330
|
+
* (POSIX, no `\d`/`\s`) is the default. Since SingleStoreAdapter inherits this pattern
|
|
331
|
+
* unchanged from MySQLAdapter and this repo doesn't control session variables for
|
|
332
|
+
* consumers, the pattern is written as the POSIX-ERE/ICU/ARE intersection so it matches
|
|
333
|
+
* correctly regardless of which dialect is active.
|
|
334
|
+
*/
|
|
335
|
+
protected decimalTryCastPattern(): string;
|
|
336
|
+
/**
|
|
337
|
+
* Regex pattern for tryCastToType's integer guard: optional leading sign, digits only,
|
|
338
|
+
* surrounded by optional spaces. Same POSIX-ERE/ICU/ARE-portable rationale as
|
|
339
|
+
* decimalTryCastPattern().
|
|
340
|
+
*/
|
|
341
|
+
protected integerTryCastPattern(): string;
|
|
342
|
+
/**
|
|
343
|
+
* Regex pattern for tryCastToType's timestamp guard: an ISO 8601-shaped date, optionally
|
|
344
|
+
* followed by a time component (with optional seconds, fractional seconds and a UTC/offset
|
|
345
|
+
* suffix), surrounded by optional spaces. This only validates the *shape* of the input —
|
|
346
|
+
* it does not catch calendar-invalid dates (e.g. 2024-02-30) or reject strings that "look"
|
|
347
|
+
* like a timestamp but aren't (that would need engine-side parsing, which is exactly what
|
|
348
|
+
* tryCastToType is avoiding relying on for error-safety). Same POSIX-ERE/ICU/ARE-portable
|
|
349
|
+
* rationale as decimalTryCastPattern().
|
|
350
|
+
*/
|
|
351
|
+
protected timestampTryCastPattern(): string;
|
|
306
352
|
/**
|
|
307
353
|
* Helper method to build pattern for string matching
|
|
308
354
|
* Can be overridden by specific adapters if needed
|
|
@@ -45,6 +45,11 @@ export declare class DatabendAdapter extends BaseDatabaseAdapter {
|
|
|
45
45
|
* Databend supports both :: syntax and CAST() function
|
|
46
46
|
*/
|
|
47
47
|
castToType(fieldExpr: AnyColumn | SQL, targetType: 'timestamp' | 'decimal' | 'integer'): SQL;
|
|
48
|
+
/**
|
|
49
|
+
* Build Databend tolerant type casting using the native TRY_CAST function, which returns
|
|
50
|
+
* NULL on conversion failure instead of raising an error (unlike `::`/CAST).
|
|
51
|
+
*/
|
|
52
|
+
tryCastToType(fieldExpr: AnyColumn | SQL, targetType: 'timestamp' | 'decimal' | 'integer'): SQL;
|
|
48
53
|
/**
|
|
49
54
|
* Databend capabilities - start conservative
|
|
50
55
|
*/
|
|
@@ -52,6 +52,11 @@ export declare class DuckDBAdapter extends BaseDatabaseAdapter {
|
|
|
52
52
|
* DuckDB supports both :: syntax and CAST() function
|
|
53
53
|
*/
|
|
54
54
|
castToType(fieldExpr: AnyColumn | SQL, targetType: 'timestamp' | 'decimal' | 'integer'): SQL;
|
|
55
|
+
/**
|
|
56
|
+
* Build DuckDB tolerant type casting using the native TRY_CAST function, which returns
|
|
57
|
+
* NULL on conversion failure instead of raising an error (unlike `::`/CAST).
|
|
58
|
+
*/
|
|
59
|
+
tryCastToType(fieldExpr: AnyColumn | SQL, targetType: 'timestamp' | 'decimal' | 'integer'): SQL;
|
|
55
60
|
/**
|
|
56
61
|
* DuckDB has full support for statistical and window functions
|
|
57
62
|
* Note: supportsPercentileSubqueries is false because DuckDB's QUANTILE_CONT
|
|
@@ -47,6 +47,20 @@ export declare class MySQLAdapter extends BaseDatabaseAdapter {
|
|
|
47
47
|
* MySQL equivalent to PostgreSQL's :: casting syntax
|
|
48
48
|
*/
|
|
49
49
|
castToType(fieldExpr: AnyColumn | SQL, targetType: 'timestamp' | 'decimal' | 'integer'): SQL;
|
|
50
|
+
/**
|
|
51
|
+
* Build MySQL tolerant type casting: NULL on unparseable input instead of MySQL's usual
|
|
52
|
+
* lenient-but-wrong behaviour. `CAST(x AS DECIMAL/SIGNED)` parses a leading numeric prefix
|
|
53
|
+
* (or returns 0 with a warning if there's no numeric prefix at all) rather than erroring —
|
|
54
|
+
* so a dirty value like 'n/a' silently becomes 0. `CAST(x AS DATETIME)` on a string that
|
|
55
|
+
* merely looks date-shaped but is calendar-invalid can, depending on sql_mode, raise an
|
|
56
|
+
* error (strict mode, the MySQL 8 default) rather than returning NULL. Guard all three with
|
|
57
|
+
* REGEXP so we only ever attempt the cast on input that already looks like the target type;
|
|
58
|
+
* anything else short-circuits to NULL first.
|
|
59
|
+
*
|
|
60
|
+
* The timestamp guard only validates ISO 8601 *shape* — it will not catch calendar-invalid
|
|
61
|
+
* dates like 2024-02-30, which could still error under strict SQL mode.
|
|
62
|
+
*/
|
|
63
|
+
tryCastToType(fieldExpr: AnyColumn | SQL, targetType: 'timestamp' | 'decimal' | 'integer'): SQL;
|
|
50
64
|
/**
|
|
51
65
|
* MySQL AVG/STDDEV/VARIANCE use IFNULL (no COALESCE-for-zero idiom mismatch,
|
|
52
66
|
* but IFNULL is the MySQL-idiomatic null guard).
|
|
@@ -43,6 +43,21 @@ export declare class PostgresAdapter extends BaseDatabaseAdapter {
|
|
|
43
43
|
* Extracted from various locations where ::timestamp was used
|
|
44
44
|
*/
|
|
45
45
|
castToType(fieldExpr: AnyColumn | SQL, targetType: 'timestamp' | 'decimal' | 'integer'): SQL;
|
|
46
|
+
/**
|
|
47
|
+
* Build PostgreSQL tolerant type casting: NULL on unparseable input instead of an error.
|
|
48
|
+
* PostgreSQL has no TRY_CAST, and `CAST(x AS type DEFAULT NULL ON ERROR)` (added in a
|
|
49
|
+
* recent PostgreSQL release) requires a minimum server version. This repo pins no minimum
|
|
50
|
+
* PostgreSQL version anywhere (CI/dev docker-compose both run `postgres:18`, but nothing
|
|
51
|
+
* documents that as a floor for consumers), so we don't assume newer syntax is available.
|
|
52
|
+
* Instead, guard the cast with a POSIX regex (`~`) so we only ever attempt to cast values
|
|
53
|
+
* that already look like the target type; anything else short-circuits to NULL before the
|
|
54
|
+
* cast runs, so PostgreSQL never gets a chance to raise.
|
|
55
|
+
*
|
|
56
|
+
* The timestamp guard only validates ISO 8601 *shape* (see timestampTryCastPattern) — it
|
|
57
|
+
* will not catch calendar-invalid dates like 2024-02-30, which would still error. A full
|
|
58
|
+
* guarantee would need a helper SQL function (out of scope here).
|
|
59
|
+
*/
|
|
60
|
+
tryCastToType(fieldExpr: AnyColumn | SQL, targetType: 'timestamp' | 'decimal' | 'integer'): SQL;
|
|
46
61
|
/**
|
|
47
62
|
* PostgreSQL has full support for statistical and window functions
|
|
48
63
|
*/
|
|
@@ -41,6 +41,12 @@ export declare class SnowflakeAdapter extends BaseDatabaseAdapter {
|
|
|
41
41
|
* Snowflake supports both :: syntax and CAST() function
|
|
42
42
|
*/
|
|
43
43
|
castToType(fieldExpr: AnyColumn | SQL, targetType: 'timestamp' | 'decimal' | 'integer'): SQL;
|
|
44
|
+
/**
|
|
45
|
+
* Build Snowflake tolerant type casting using the native TRY_CAST function, which returns
|
|
46
|
+
* NULL on conversion failure instead of raising an error (unlike `::`/CAST). Snowflake's
|
|
47
|
+
* TRY_CAST supports VARCHAR, NUMBER-family types (including DECIMAL) and TIMESTAMP.
|
|
48
|
+
*/
|
|
49
|
+
tryCastToType(fieldExpr: AnyColumn | SQL, targetType: 'timestamp' | 'decimal' | 'integer'): SQL;
|
|
44
50
|
/**
|
|
45
51
|
* Snowflake capabilities - full SQL support
|
|
46
52
|
*/
|
|
@@ -51,6 +51,27 @@ export declare class SQLiteAdapter extends BaseDatabaseAdapter {
|
|
|
51
51
|
* SQLite has dynamic typing but supports CAST for consistency
|
|
52
52
|
*/
|
|
53
53
|
castToType(fieldExpr: AnyColumn | SQL, targetType: 'timestamp' | 'decimal' | 'integer'): SQL;
|
|
54
|
+
/**
|
|
55
|
+
* Build SQLite tolerant type casting: NULL on unparseable input instead of SQLite's usual
|
|
56
|
+
* dynamic-typing behaviour. SQLite's CAST-to-numeric applies "prefix" conversion — the
|
|
57
|
+
* longest numeric prefix of the string is used, or 0 if there is none — so `CAST('n/a' AS
|
|
58
|
+
* REAL)` silently yields 0.0 rather than erroring or returning NULL.
|
|
59
|
+
*
|
|
60
|
+
* SQLite has no REGEXP operator by default (it requires loading an extension, same
|
|
61
|
+
* limitation regexCondition() works around with GLOB). GLOB's `*`/`?`/`[...]` syntax can't
|
|
62
|
+
* express "one or more digits" directly, but the standard SQLite idiom for "string contains
|
|
63
|
+
* only characters from a set" is `NOT x GLOB '*[^set]*'` — true only if no character outside
|
|
64
|
+
* the set appears anywhere. That's what's used below to validate the trimmed value contains
|
|
65
|
+
* only the characters a valid decimal/integer/epoch-ms value could use, before attempting
|
|
66
|
+
* the cast; empty/whitespace-only strings are excluded separately.
|
|
67
|
+
*
|
|
68
|
+
* Known limitation: this is a character-set check, not a full grammar check, so a malformed
|
|
69
|
+
* value that still only uses allowed characters (e.g. '1.2.3' or '+-5') passes the guard and
|
|
70
|
+
* is then handled by SQLite's own prefix-based numeric parsing (never an error, but not
|
|
71
|
+
* necessarily NULL either). Clearly non-numeric input (letters, 'n/a', punctuation outside
|
|
72
|
+
* the allowed set) is reliably rejected to NULL, which is the case this method exists for.
|
|
73
|
+
*/
|
|
74
|
+
tryCastToType(fieldExpr: AnyColumn | SQL, targetType: 'timestamp' | 'decimal' | 'integer'): SQL;
|
|
54
75
|
/**
|
|
55
76
|
* SQLite AVG uses IFNULL rather than COALESCE for null-to-zero handling.
|
|
56
77
|
*/
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { AnyColumn, SQL } from 'drizzle-orm';
|
|
2
|
+
import { Dimension, QueryContext } from './types/index.js';
|
|
3
|
+
/** The value types a generated attribute dimension can be cast to. */
|
|
4
|
+
export type AttributeValueType = 'string' | 'number' | 'time';
|
|
5
|
+
/** One admin-defined attribute, as loaded from the application's own table. */
|
|
6
|
+
export interface AttributeDefinition {
|
|
7
|
+
/**
|
|
8
|
+
* Stable identifier. The dimension's member name is derived from this, never
|
|
9
|
+
* from the attribute's name — so renaming an attribute updates every table
|
|
10
|
+
* header without breaking saved dashboards, drill state or share links.
|
|
11
|
+
*/
|
|
12
|
+
id: string | number;
|
|
13
|
+
/** Display name. Becomes the dimension's `title`, which the client renders. */
|
|
14
|
+
name: string;
|
|
15
|
+
/**
|
|
16
|
+
* Value type, if the application's attribute table records one. Filtering and
|
|
17
|
+
* sorting happen in SQL over the whole table before any row reaches the
|
|
18
|
+
* browser, so this is not cosmetic — see {@link buildAttributeDimensions}.
|
|
19
|
+
*/
|
|
20
|
+
valueType?: AttributeValueType;
|
|
21
|
+
}
|
|
22
|
+
export interface BuildAttributeDimensionsOptions {
|
|
23
|
+
/** The attributes to generate a dimension for. */
|
|
24
|
+
attributes: AttributeDefinition[];
|
|
25
|
+
/** The junction table holding one row per (record, attribute). */
|
|
26
|
+
valueTable: unknown;
|
|
27
|
+
/** Primary key of the record being extended — e.g. `employees.id`. */
|
|
28
|
+
recordKey: AnyColumn;
|
|
29
|
+
/** Column on the junction table pointing back at the record. */
|
|
30
|
+
foreignKey: AnyColumn;
|
|
31
|
+
/** Column on the junction table identifying the attribute. */
|
|
32
|
+
attributeKey: AnyColumn;
|
|
33
|
+
/** Column on the junction table holding the value. */
|
|
34
|
+
valueColumn: AnyColumn;
|
|
35
|
+
/**
|
|
36
|
+
* Row-level security for the junction table. **Required**: the subquery reads
|
|
37
|
+
* the junction table directly, so without this a tenant sees every tenant's
|
|
38
|
+
* attribute values. It is a parameter rather than an option so that omitting
|
|
39
|
+
* it is impossible rather than merely inadvisable.
|
|
40
|
+
*/
|
|
41
|
+
security: (ctx: QueryContext) => SQL;
|
|
42
|
+
/**
|
|
43
|
+
* Per-attribute type overrides, keyed by attribute id. Wins over
|
|
44
|
+
* `AttributeDefinition.valueType`.
|
|
45
|
+
*/
|
|
46
|
+
types?: Record<string, AttributeValueType>;
|
|
47
|
+
/** Member-name prefix. Defaults to `attr_`. */
|
|
48
|
+
namePrefix?: string;
|
|
49
|
+
/** Passed through to each generated dimension's `shown`. */
|
|
50
|
+
shown?: boolean;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Build one dimension per attribute, each backed by a correlated scalar
|
|
54
|
+
* subquery against the junction table.
|
|
55
|
+
*
|
|
56
|
+
* ```ts
|
|
57
|
+
* dimensions: {
|
|
58
|
+
* ...baseDimensions,
|
|
59
|
+
* ...buildAttributeDimensions({
|
|
60
|
+
* attributes: attrs,
|
|
61
|
+
* valueTable: employeeAttributeValues,
|
|
62
|
+
* recordKey: employees.id,
|
|
63
|
+
* foreignKey: employeeAttributeValues.employeeId,
|
|
64
|
+
* attributeKey: employeeAttributeValues.attributeId,
|
|
65
|
+
* valueColumn: employeeAttributeValues.value,
|
|
66
|
+
* security: (ctx) => eq(employeeAttributeValues.organisationId, ctx.securityContext.organisationId)
|
|
67
|
+
* })
|
|
68
|
+
* }
|
|
69
|
+
* ```
|
|
70
|
+
*
|
|
71
|
+
* Three details that are easy to get wrong, and are handled here:
|
|
72
|
+
*
|
|
73
|
+
* - **Typing is mandatory, not cosmetic.** Sorting and filtering run in SQL
|
|
74
|
+
* over the whole table before a page reaches the browser, so client-side
|
|
75
|
+
* conversion cannot repair them: sorted as text, `100` sorts below `9`, and
|
|
76
|
+
* `> 50` admits `'9'` while rejecting `'100'`. A `number` attribute is cast
|
|
77
|
+
* in SQL — tolerantly, so one `n/a` yields NULL for that row instead of
|
|
78
|
+
* failing the whole query.
|
|
79
|
+
* - **`LIMIT 1`.** EAV tables rarely carry a unique constraint on
|
|
80
|
+
* (record, attribute); without it a duplicate row raises "more than one row
|
|
81
|
+
* returned by a subquery" on Postgres.
|
|
82
|
+
* - **Security inside the subquery**, not merely on the outer query.
|
|
83
|
+
*
|
|
84
|
+
* **Grouping limitation.** The subquery correlates on the record key, so a
|
|
85
|
+
* *grouped* query must also group by that key — `dimensions: ['Employees.id',
|
|
86
|
+
* 'Employees.attr_1']` is fine, `dimensions: ['Employees.attr_1']` with a
|
|
87
|
+
* measure is not. Postgres rejects the latter with "subquery uses ungrouped
|
|
88
|
+
* column … from outer query", and MySQL with `only_full_group_by`; SQLite
|
|
89
|
+
* permits it. Record-grain listings (`ungrouped: true`) — the case this exists
|
|
90
|
+
* for — are unaffected. If you need to aggregate freely by an attribute, pivot
|
|
91
|
+
* it into a real column with a view (see the performance ladder below).
|
|
92
|
+
*
|
|
93
|
+
* Performance: projection is cheap (a page of 25 rows is 25 indexed lookups per
|
|
94
|
+
* attribute), but `ORDER BY (SELECT …)` and `WHERE (SELECT …) = …` are
|
|
95
|
+
* proportional to the base table because no index serves them. At tens of
|
|
96
|
+
* thousands of rows that is fine; beyond it, pivot the attributes into real
|
|
97
|
+
* indexable columns via a view.
|
|
98
|
+
*/
|
|
99
|
+
export declare function buildAttributeDimensions(options: BuildAttributeDimensionsOptions): Record<string, Dimension>;
|
|
@@ -24,9 +24,13 @@ export interface CacheKeyConfig {
|
|
|
24
24
|
* @param query - The semantic query to cache
|
|
25
25
|
* @param securityContext - Security context for tenant isolation
|
|
26
26
|
* @param config - Cache key configuration
|
|
27
|
+
* @param cubeSetKey - Identifies the cube definitions behind the result. Always
|
|
28
|
+
* included when present: `includeSecurityContext: false` and a custom
|
|
29
|
+
* `securityContextSerializer` can each hash two tenants identically, so the
|
|
30
|
+
* security-context hash alone cannot keep differing cube sets apart.
|
|
27
31
|
* @returns Deterministic cache key string
|
|
28
32
|
*/
|
|
29
|
-
export declare function generateCacheKey(query: SemanticQuery, securityContext: SecurityContext, config?: CacheKeyConfig): string;
|
|
33
|
+
export declare function generateCacheKey(query: SemanticQuery, securityContext: SecurityContext, config?: CacheKeyConfig, cubeSetKey?: string): string;
|
|
30
34
|
/**
|
|
31
35
|
* Normalize query for consistent hashing
|
|
32
36
|
* Sorts arrays and object keys to ensure same query = same hash
|
|
@@ -1,11 +1,32 @@
|
|
|
1
1
|
import { Cube, MeasureMetadata, DimensionMetadata, CubeRelationshipMetadata, HierarchyMetadata, TimeGranularity } from './types/index.js';
|
|
2
2
|
/** Default time granularities used when a time dimension omits `granularities`. */
|
|
3
3
|
export declare const DEFAULT_TIME_GRANULARITIES: TimeGranularity[];
|
|
4
|
-
/**
|
|
4
|
+
/**
|
|
5
|
+
* Build measure metadata, normalizing drillMembers to fully-qualified names.
|
|
6
|
+
*
|
|
7
|
+
* Measures with `shown: false` are omitted from the result — matching Cube.js
|
|
8
|
+
* semantics, where a hidden measure remains fully usable in queries but is
|
|
9
|
+
* excluded from metadata/UI surfaces. `shown: undefined` means shown, so
|
|
10
|
+
* today's behaviour is preserved exactly.
|
|
11
|
+
*/
|
|
5
12
|
export declare function buildMeasureMetadata(cube: Cube): MeasureMetadata[];
|
|
6
|
-
/**
|
|
13
|
+
/**
|
|
14
|
+
* Build dimension metadata, including granularities for time dimensions.
|
|
15
|
+
*
|
|
16
|
+
* Dimensions with `shown: false` are omitted from the result — matching
|
|
17
|
+
* Cube.js semantics, where a hidden dimension remains fully usable in queries
|
|
18
|
+
* but is excluded from metadata/UI surfaces. `shown: undefined` means shown,
|
|
19
|
+
* so today's behaviour is preserved exactly.
|
|
20
|
+
*/
|
|
7
21
|
export declare function buildDimensionMetadata(cube: Cube): DimensionMetadata[];
|
|
8
22
|
/** Build relationship metadata from a cube's joins, resolving target cubes. */
|
|
9
23
|
export declare function buildRelationshipMetadata(cube: Cube, cubes: Map<string, Cube>, getColumnName: (column: any) => string): CubeRelationshipMetadata[];
|
|
10
|
-
/**
|
|
24
|
+
/**
|
|
25
|
+
* Build hierarchy metadata, qualifying level names to full member names.
|
|
26
|
+
*
|
|
27
|
+
* Levels referencing a dimension with `shown: false` are dropped, so a
|
|
28
|
+
* hierarchy never emits a dangling reference to a dimension that has been
|
|
29
|
+
* omitted from the cube's own dimension metadata. A hierarchy left with no
|
|
30
|
+
* visible levels is omitted entirely rather than published as empty.
|
|
31
|
+
*/
|
|
11
32
|
export declare function buildHierarchyMetadata(cube: Cube): HierarchyMetadata[];
|
|
@@ -1,9 +1,70 @@
|
|
|
1
1
|
import { SemanticQuery, QueryResult, SecurityContext, DatabaseExecutor, CubeMetadata, Cube, QueryAnalysis, CacheConfig, ExplainOptions, ExplainResult, ExecutionOptions, RLSSetupFn } from './types/index.js';
|
|
2
2
|
import { PlanOptimiser } from './logical-plan/index.js';
|
|
3
3
|
export { validateQueryAgainstCubes } from './query-validator.js';
|
|
4
|
+
/**
|
|
5
|
+
* Identifier of the base cube set — the cubes registered with {@link
|
|
6
|
+
* SemanticLayerCompiler.registerCube}, shared by every tenant. The empty string
|
|
7
|
+
* is used so a set id can never collide with it (`registerCubeSet` rejects it).
|
|
8
|
+
*/
|
|
9
|
+
export declare const BASE_CUBE_SET_ID = "";
|
|
10
|
+
/**
|
|
11
|
+
* Security context for deployments with no tenancy at all.
|
|
12
|
+
*
|
|
13
|
+
* Every cube-resolving method requires a `SecurityContext` so that omitting one
|
|
14
|
+
* is a compile error rather than a silent fall back to the wrong tenant's
|
|
15
|
+
* cubes. Single-tenant callers pass this constant to say "no tenancy here" out
|
|
16
|
+
* loud, instead of an anonymous `{}` that reads like an oversight.
|
|
17
|
+
*/
|
|
18
|
+
export declare const SINGLE_TENANT_CONTEXT: SecurityContext;
|
|
19
|
+
/** Reported to `onCubeSetRegistered` after each {@link SemanticLayerCompiler.registerCubeSet}. */
|
|
20
|
+
export interface CubeSetRegistrationInfo {
|
|
21
|
+
/** The set that was registered. */
|
|
22
|
+
setId: string;
|
|
23
|
+
/** Cubes in the set after merging over the base set. */
|
|
24
|
+
cubeCount: number;
|
|
25
|
+
/** Total dimensions across those cubes — the number that explains a slow boot. */
|
|
26
|
+
dimensionCount: number;
|
|
27
|
+
/**
|
|
28
|
+
* Monotonic across the whole compiler — incremented on every registration of
|
|
29
|
+
* any set, never reset. Part of the cache key, so results computed from
|
|
30
|
+
* superseded definitions can never be served.
|
|
31
|
+
*/
|
|
32
|
+
generation: number;
|
|
33
|
+
/** Wall-clock cost of this registration. */
|
|
34
|
+
durationMs: number;
|
|
35
|
+
}
|
|
36
|
+
/** Aggregate registration cost, for a single summary line after the boot loop. */
|
|
37
|
+
export interface CubeSetStats {
|
|
38
|
+
/** Number of registered sets, excluding the base set. */
|
|
39
|
+
setCount: number;
|
|
40
|
+
/** Total cubes across all sets (merged), excluding the base set. */
|
|
41
|
+
cubeCount: number;
|
|
42
|
+
/** Sum of every set's most recent registration time. */
|
|
43
|
+
totalRegistrationMs: number;
|
|
44
|
+
/** The most expensive set to register, if any sets are registered. */
|
|
45
|
+
slowestSet?: {
|
|
46
|
+
setId: string;
|
|
47
|
+
durationMs: number;
|
|
48
|
+
};
|
|
49
|
+
}
|
|
4
50
|
export declare class SemanticLayerCompiler {
|
|
5
|
-
|
|
6
|
-
private
|
|
51
|
+
/** Cubes shared by every tenant. */
|
|
52
|
+
private baseCubes;
|
|
53
|
+
/** Per-tenant overlays, keyed by cube-set id. */
|
|
54
|
+
private cubeSets;
|
|
55
|
+
/** Generated metadata per cube set (`BASE_CUBE_SET_ID` for the base set). */
|
|
56
|
+
private metadataCache;
|
|
57
|
+
/** Bumped on every base-set mutation; part of every set's cache key. */
|
|
58
|
+
private baseGeneration;
|
|
59
|
+
/**
|
|
60
|
+
* Monotonic registration counter, never reset. Used as each set's generation
|
|
61
|
+
* so that unregistering a set and registering a different one under the same
|
|
62
|
+
* id cannot reproduce an earlier cache key and serve its stale results.
|
|
63
|
+
*/
|
|
64
|
+
private registrationCounter;
|
|
65
|
+
private contextToCubeSetId?;
|
|
66
|
+
private missingCubeSet;
|
|
67
|
+
private onCubeSetRegistered?;
|
|
7
68
|
private cacheConfig?;
|
|
8
69
|
private rlsSetup?;
|
|
9
70
|
private planOptimiser?;
|
|
@@ -29,6 +90,25 @@ export declare class SemanticLayerCompiler {
|
|
|
29
90
|
* Defaults to a no-op IdentityOptimiser when omitted.
|
|
30
91
|
*/
|
|
31
92
|
planOptimiser?: PlanOptimiser;
|
|
93
|
+
/**
|
|
94
|
+
* Maps a security context to the cube set that serves it — drizzle-cube's
|
|
95
|
+
* equivalent of Cube's `contextToAppId`. Return `undefined` (or omit this
|
|
96
|
+
* option entirely) to serve the base set, which is the single-tenant
|
|
97
|
+
* behaviour and the default.
|
|
98
|
+
*/
|
|
99
|
+
contextToCubeSetId?: (securityContext: SecurityContext) => string | number | undefined;
|
|
100
|
+
/**
|
|
101
|
+
* What to do when `contextToCubeSetId` names a set that is not registered.
|
|
102
|
+
* `'base'` (default) serves the base set; `'throw'` fails the request, for
|
|
103
|
+
* deployments where every tenant is required to have its own set.
|
|
104
|
+
*/
|
|
105
|
+
missingCubeSet?: 'base' | 'throw';
|
|
106
|
+
/**
|
|
107
|
+
* Called after each `registerCubeSet` with its cost. Registering a set per
|
|
108
|
+
* tenant is real startup work, so it is reported rather than hidden; emit
|
|
109
|
+
* it to your own logger or metrics.
|
|
110
|
+
*/
|
|
111
|
+
onCubeSetRegistered?: (info: CubeSetRegistrationInfo) => void;
|
|
32
112
|
});
|
|
33
113
|
/**
|
|
34
114
|
* Set or update the database connection
|
|
@@ -65,12 +145,75 @@ export declare class SemanticLayerCompiler {
|
|
|
65
145
|
* Validates calculated measures during registration
|
|
66
146
|
*/
|
|
67
147
|
registerCube(cube: Cube): void;
|
|
148
|
+
/**
|
|
149
|
+
* Register the cubes that serve one tenant, overlaying the base set.
|
|
150
|
+
*
|
|
151
|
+
* Cubes are matched to the base set by name, so a set can either add cubes or
|
|
152
|
+
* replace a base cube with a tenant-specific version (the usual case for
|
|
153
|
+
* generated per-tenant dimensions). Call once per tenant at application boot;
|
|
154
|
+
* calling again for the same id replaces that set and invalidates its cached
|
|
155
|
+
* metadata and query results.
|
|
156
|
+
*/
|
|
157
|
+
registerCubeSet(setId: string, cubes: Cube[]): void;
|
|
158
|
+
/**
|
|
159
|
+
* Remove a tenant's cube set. That tenant then resolves to the base set (or
|
|
160
|
+
* throws, under `missingCubeSet: 'throw'`).
|
|
161
|
+
* Returns true if the set existed.
|
|
162
|
+
*/
|
|
163
|
+
unregisterCubeSet(setId: string): boolean;
|
|
164
|
+
/** Whether a cube set is registered for this id. */
|
|
165
|
+
hasCubeSet(setId: string): boolean;
|
|
166
|
+
/** Ids of every registered cube set, excluding the base set. */
|
|
167
|
+
getCubeSetIds(): string[];
|
|
168
|
+
/**
|
|
169
|
+
* Aggregate registration cost across all sets — for the single summary line
|
|
170
|
+
* worth logging after a boot loop.
|
|
171
|
+
*/
|
|
172
|
+
getCubeSetStats(): CubeSetStats;
|
|
173
|
+
/**
|
|
174
|
+
* Validate and enrich a cube ahead of registration, against the cubes that
|
|
175
|
+
* will be visible alongside it.
|
|
176
|
+
*/
|
|
177
|
+
private prepareCube;
|
|
178
|
+
/** Base cubes with an overlay applied over them, by cube name. */
|
|
179
|
+
private mergeWithBase;
|
|
180
|
+
/** Recompute every set's merged view — after any base-set mutation. */
|
|
181
|
+
private rebuildAllMergedSets;
|
|
182
|
+
/**
|
|
183
|
+
* Resolve the cube set serving this security context.
|
|
184
|
+
*
|
|
185
|
+
* Returns {@link BASE_CUBE_SET_ID} when no mapping is configured or the
|
|
186
|
+
* mapping yields nothing. A configured id that has no registered set falls
|
|
187
|
+
* back to the base set, or throws under `missingCubeSet: 'throw'`.
|
|
188
|
+
*/
|
|
189
|
+
private resolveSetId;
|
|
190
|
+
/**
|
|
191
|
+
* The cubes this security context may see.
|
|
192
|
+
*
|
|
193
|
+
* This is the only path by which cube *contents* are read for a query,
|
|
194
|
+
* metadata, validation or MCP response — so no such path can reach a cube
|
|
195
|
+
* list without a security context. The returned map must be treated as
|
|
196
|
+
* read-only; it is the live merged view, not a copy.
|
|
197
|
+
*/
|
|
198
|
+
private resolveCubes;
|
|
199
|
+
/**
|
|
200
|
+
* Cache-key component identifying which cube definitions produced a result.
|
|
201
|
+
*
|
|
202
|
+
* Appended unconditionally to every query cache key: the security-context
|
|
203
|
+
* hash is not enough, because `includeSecurityContext: false` and a custom
|
|
204
|
+
* `securityContextSerializer` can both hash two tenants identically. The
|
|
205
|
+
* generation makes re-registering a set invalidate its cached results, so a
|
|
206
|
+
* retyped or renamed dimension cannot be served stale for the TTL.
|
|
207
|
+
*/
|
|
208
|
+
private cubeSetCacheKey;
|
|
68
209
|
/**
|
|
69
210
|
* Validate that all string-based cube references in joins resolve to registered cubes.
|
|
70
211
|
* Call after all cubes are registered for strict startup validation.
|
|
71
212
|
* Throws an error listing all unresolved references.
|
|
72
213
|
*/
|
|
73
214
|
validateCubeReferences(): void;
|
|
215
|
+
/** Join targets naming a cube that is absent from the given cube scope. */
|
|
216
|
+
private unresolvedJoinRefs;
|
|
74
217
|
/**
|
|
75
218
|
* Validate calculated measures in a cube
|
|
76
219
|
* Checks template syntax, dependency existence, and circular dependencies
|
|
@@ -79,15 +222,17 @@ export declare class SemanticLayerCompiler {
|
|
|
79
222
|
/**
|
|
80
223
|
* Get a cube by name
|
|
81
224
|
*/
|
|
82
|
-
getCube(name: string): Cube | undefined;
|
|
225
|
+
getCube(name: string, securityContext: SecurityContext): Cube | undefined;
|
|
83
226
|
/**
|
|
84
227
|
* Get all registered cubes
|
|
85
228
|
*/
|
|
86
|
-
getAllCubes(): Cube[];
|
|
229
|
+
getAllCubes(securityContext: SecurityContext): Cube[];
|
|
87
230
|
/**
|
|
88
|
-
* Get all cubes as a Map for multi-cube queries
|
|
231
|
+
* Get all cubes as a Map for multi-cube queries.
|
|
232
|
+
*
|
|
233
|
+
* Returns the live merged view for this context — treat it as read-only.
|
|
89
234
|
*/
|
|
90
|
-
getAllCubesMap(): Map<string, Cube>;
|
|
235
|
+
getAllCubesMap(securityContext: SecurityContext): Map<string, Cube>;
|
|
91
236
|
/**
|
|
92
237
|
* Unified query execution method that handles both single and multi-cube queries
|
|
93
238
|
* @param options.skipCache - Skip cache lookup (but still cache the fresh result)
|
|
@@ -107,7 +252,7 @@ export declare class SemanticLayerCompiler {
|
|
|
107
252
|
* Uses caching to improve performance for repeated requests
|
|
108
253
|
* Cache is invalidated when cubes are modified (registerCube, removeCube, clearCubes)
|
|
109
254
|
*/
|
|
110
|
-
getMetadata(): CubeMetadata[];
|
|
255
|
+
getMetadata(securityContext: SecurityContext): CubeMetadata[];
|
|
111
256
|
/**
|
|
112
257
|
* Extract column name from Drizzle column reference
|
|
113
258
|
* Handles different column types and extracts the actual column name
|
|
@@ -172,7 +317,7 @@ export declare class SemanticLayerCompiler {
|
|
|
172
317
|
/**
|
|
173
318
|
* Check if a cube exists
|
|
174
319
|
*/
|
|
175
|
-
hasCube(name: string): boolean;
|
|
320
|
+
hasCube(name: string, securityContext: SecurityContext): boolean;
|
|
176
321
|
/**
|
|
177
322
|
* Unregister a cube by name.
|
|
178
323
|
* Returns true if the cube existed and was removed, false if not found.
|
|
@@ -191,15 +336,17 @@ export declare class SemanticLayerCompiler {
|
|
|
191
336
|
* Called whenever cubes are modified
|
|
192
337
|
*/
|
|
193
338
|
private invalidateMetadataCache;
|
|
339
|
+
/** Cubes for an already-resolved set id. */
|
|
340
|
+
private cubeSetId2Cubes;
|
|
194
341
|
/**
|
|
195
342
|
* Get cube names
|
|
196
343
|
*/
|
|
197
|
-
getCubeNames(): string[];
|
|
344
|
+
getCubeNames(securityContext: SecurityContext): string[];
|
|
198
345
|
/**
|
|
199
346
|
* Validate a query against registered cubes
|
|
200
347
|
* Ensures all referenced cubes and fields exist
|
|
201
348
|
*/
|
|
202
|
-
validateQuery(query: SemanticQuery): {
|
|
349
|
+
validateQuery(query: SemanticQuery, securityContext: SecurityContext): {
|
|
203
350
|
isValid: boolean;
|
|
204
351
|
errors: string[];
|
|
205
352
|
};
|
|
@@ -6,7 +6,7 @@ export declare class QueryResultCache {
|
|
|
6
6
|
* Returns the cache key when caching is enabled and a provider is configured,
|
|
7
7
|
* otherwise undefined (which disables lookup and store).
|
|
8
8
|
*/
|
|
9
|
-
generateKey(query: SemanticQuery, securityContext: SecurityContext): string | undefined;
|
|
9
|
+
generateKey(query: SemanticQuery, securityContext: SecurityContext, cubeSetKey?: string): string | undefined;
|
|
10
10
|
/**
|
|
11
11
|
* Look up a cached result. Returns the cached value (with cache metadata
|
|
12
12
|
* attached) on a hit, or undefined on miss / bypass / no-cache. Emits
|