drizzle-cube 0.5.8 → 0.6.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 (388) hide show
  1. package/README.md +2 -0
  2. package/dist/adapters/adapters/hono/agent-handler.d.ts +9 -0
  3. package/dist/adapters/adapters/hono/mcp-handler.d.ts +37 -0
  4. package/dist/adapters/adapters/mcp-tools-handlers.d.ts +18 -0
  5. package/dist/adapters/adapters/nextjs/mcp-handler.d.ts +36 -0
  6. package/dist/adapters/adapters/utils.d.ts +6 -81
  7. package/dist/adapters/express/index.cjs +1 -1
  8. package/dist/adapters/express/index.js +50 -50
  9. package/dist/adapters/fastify/index.cjs +1 -1
  10. package/dist/adapters/fastify/index.js +78 -78
  11. package/dist/adapters/google-BOnRIN1w.cjs +2 -0
  12. package/dist/adapters/{google-CFYljAOF.js → google-CvKM9yVM.js} +83 -71
  13. package/dist/adapters/{handler-Cx8QYLk6.js → handler-CfgE0JSL.js} +499 -576
  14. package/dist/adapters/handler-Cn0dOctE.cjs +25 -0
  15. package/dist/adapters/hono/index.cjs +2 -2
  16. package/dist/adapters/hono/index.js +205 -175
  17. package/dist/adapters/locale-DDvZDFVn.js +8114 -0
  18. package/dist/adapters/locale-ZLUUNUxr.cjs +166 -0
  19. package/dist/adapters/mcp-tools.cjs +1 -1
  20. package/dist/adapters/mcp-tools.js +49 -38
  21. package/dist/adapters/mcp-transport-Chiaj4ll.cjs +40 -0
  22. package/dist/adapters/mcp-transport-H96VG3WY.js +591 -0
  23. package/dist/adapters/nextjs/index.cjs +1 -1
  24. package/dist/adapters/nextjs/index.js +190 -197
  25. package/dist/adapters/{openai-BZdAA7Ji.js → openai-cDlFSTk6.js} +60 -58
  26. package/dist/adapters/openai-vXvLni8v.cjs +1 -0
  27. package/dist/adapters/{utils-D9JPLmfl.js → utils-BPWZsX7k.js} +1271 -1218
  28. package/dist/adapters/utils-_whV4fXL.cjs +128 -0
  29. package/dist/adapters/utils.cjs +1 -1
  30. package/dist/adapters/utils.js +2 -2
  31. package/dist/client/charts/ChartLoader.d.ts +2 -16
  32. package/dist/client/charts/chartComponentRegistry.d.ts +46 -0
  33. package/dist/client/charts/chartConfigHelpers.d.ts +38 -0
  34. package/dist/client/charts.js +14 -13
  35. package/dist/client/chunks/{DashboardEditModal-CjCIAT-J.js → DashboardEditModal-okVfH8ZK.js} +5296 -4544
  36. package/dist/client/chunks/DashboardEditModal-okVfH8ZK.js.map +1 -0
  37. package/dist/client/chunks/{RetentionCombinedChart-BPkfcTa8.js → RetentionCombinedChart-BgbDhsPz.js} +10 -10
  38. package/dist/client/chunks/{RetentionCombinedChart-BPkfcTa8.js.map → RetentionCombinedChart-BgbDhsPz.js.map} +1 -1
  39. package/dist/client/chunks/{RetentionHeatmap-DGzLzr7h.js → RetentionHeatmap-DjXZaTPq.js} +5 -5
  40. package/dist/client/chunks/{RetentionHeatmap-DGzLzr7h.js.map → RetentionHeatmap-DjXZaTPq.js.map} +1 -1
  41. package/dist/client/chunks/analysis-builder-DB88FojM.js +5674 -0
  42. package/dist/client/chunks/analysis-builder-DB88FojM.js.map +1 -0
  43. package/dist/client/chunks/{analysis-builder-shared-CYVwSPqt.js → analysis-builder-shared-BVK4TYfR.js} +1578 -1292
  44. package/dist/client/chunks/analysis-builder-shared-BVK4TYfR.js.map +1 -0
  45. package/dist/client/chunks/{chart-activity-grid-DmruKPab.js → chart-activity-grid-DX0SJbxs.js} +635 -492
  46. package/dist/client/chunks/chart-activity-grid-DX0SJbxs.js.map +1 -0
  47. package/dist/client/chunks/chart-area-of01_62R.js +775 -0
  48. package/dist/client/chunks/chart-area-of01_62R.js.map +1 -0
  49. package/dist/client/chunks/chart-bar-BqelQE_I.js +194 -0
  50. package/dist/client/chunks/chart-bar-BqelQE_I.js.map +1 -0
  51. package/dist/client/chunks/{chart-box-plot-DYKfyOI8.js → chart-box-plot-kkBixZ27.js} +2 -2
  52. package/dist/client/chunks/{chart-box-plot-DYKfyOI8.js.map → chart-box-plot-kkBixZ27.js.map} +1 -1
  53. package/dist/client/chunks/chart-bubble-B2he1--4.js +221 -0
  54. package/dist/client/chunks/chart-bubble-B2he1--4.js.map +1 -0
  55. package/dist/client/chunks/{chart-candlestick-Dwc92Mrj.js → chart-candlestick-DZp19Tzh.js} +2 -2
  56. package/dist/client/chunks/{chart-candlestick-Dwc92Mrj.js.map → chart-candlestick-DZp19Tzh.js.map} +1 -1
  57. package/dist/client/chunks/chart-config-area-BNigHUy8.js +124 -0
  58. package/dist/client/chunks/chart-config-area-BNigHUy8.js.map +1 -0
  59. package/dist/client/chunks/chart-config-bar-DSO_LRTx.js +54 -0
  60. package/dist/client/chunks/chart-config-bar-DSO_LRTx.js.map +1 -0
  61. package/dist/client/chunks/{chart-config-box-plot-DJ-dWWXA.js → chart-config-box-plot-oW8axV2q.js} +5 -10
  62. package/dist/client/chunks/chart-config-box-plot-oW8axV2q.js.map +1 -0
  63. package/dist/client/chunks/{chart-config-gauge-DSwC04l0.js → chart-config-gauge-Dq-_H9UN.js} +5 -7
  64. package/dist/client/chunks/chart-config-gauge-Dq-_H9UN.js.map +1 -0
  65. package/dist/client/chunks/{chart-config-kpi-delta-D6BIkHL3.js → chart-config-kpi-delta-DSQbvqu_.js} +5 -10
  66. package/dist/client/chunks/chart-config-kpi-delta-DSQbvqu_.js.map +1 -0
  67. package/dist/client/chunks/{chart-config-kpi-number-Bx-V9a62.js → chart-config-kpi-number-EFSWY1We.js} +5 -7
  68. package/dist/client/chunks/chart-config-kpi-number-EFSWY1We.js.map +1 -0
  69. package/dist/client/chunks/{chart-config-kpi-text-CcqC1u-8.js → chart-config-kpi-text-KM3V5X2u.js} +5 -7
  70. package/dist/client/chunks/chart-config-kpi-text-KM3V5X2u.js.map +1 -0
  71. package/dist/client/chunks/{chart-config-line-Db3jDsWc.js → chart-config-line-D6jG8PCH.js} +9 -36
  72. package/dist/client/chunks/chart-config-line-D6jG8PCH.js.map +1 -0
  73. package/dist/client/chunks/{chart-config-pie-DD4SmRTF.js → chart-config-pie-BhzW-fdn.js} +6 -16
  74. package/dist/client/chunks/chart-config-pie-BhzW-fdn.js.map +1 -0
  75. package/dist/client/chunks/{chart-config-radar-CC2XAaGr.js → chart-config-radar-D7REP1q_.js} +6 -16
  76. package/dist/client/chunks/chart-config-radar-D7REP1q_.js.map +1 -0
  77. package/dist/client/chunks/{chart-config-radial-bar-DmxKx1R0.js → chart-config-radial-bar-Byx6qOPU.js} +6 -16
  78. package/dist/client/chunks/chart-config-radial-bar-Byx6qOPU.js.map +1 -0
  79. package/dist/client/chunks/{chart-config-tree-map-BI-oQStO.js → chart-config-tree-map-DVrvf3yQ.js} +6 -16
  80. package/dist/client/chunks/chart-config-tree-map-DVrvf3yQ.js.map +1 -0
  81. package/dist/client/chunks/{chart-config-waterfall-DSnyixbI.js → chart-config-waterfall-DmFeQdIk.js} +5 -10
  82. package/dist/client/chunks/chart-config-waterfall-DmFeQdIk.js.map +1 -0
  83. package/dist/client/chunks/{chart-data-table-BO4sXsim.js → chart-data-table-CKauQXme.js} +1046 -1121
  84. package/dist/client/chunks/chart-data-table-CKauQXme.js.map +1 -0
  85. package/dist/client/chunks/{chart-funnel-DnWRsmnS.js → chart-funnel-CToKSBaL.js} +184 -222
  86. package/dist/client/chunks/chart-funnel-CToKSBaL.js.map +1 -0
  87. package/dist/client/chunks/chart-gauge-DTVezSk7.js +403 -0
  88. package/dist/client/chunks/chart-gauge-DTVezSk7.js.map +1 -0
  89. package/dist/client/chunks/chart-heat-map-DTuUl0BR.js +236 -0
  90. package/dist/client/chunks/chart-heat-map-DTuUl0BR.js.map +1 -0
  91. package/dist/client/chunks/chart-kpi-delta-Dn-jjO-2.js +408 -0
  92. package/dist/client/chunks/chart-kpi-delta-Dn-jjO-2.js.map +1 -0
  93. package/dist/client/chunks/chart-kpi-number-P_WBiO5S.js +244 -0
  94. package/dist/client/chunks/chart-kpi-number-P_WBiO5S.js.map +1 -0
  95. package/dist/client/chunks/chart-kpi-text-C-Y4eb5H.js +185 -0
  96. package/dist/client/chunks/chart-kpi-text-C-Y4eb5H.js.map +1 -0
  97. package/dist/client/chunks/chart-line-DKgrQA6c.js +101 -0
  98. package/dist/client/chunks/chart-line-DKgrQA6c.js.map +1 -0
  99. package/dist/client/chunks/{chart-markdown-dgUetjyM.js → chart-markdown-CV75S_zL.js} +2 -2
  100. package/dist/client/chunks/{chart-markdown-dgUetjyM.js.map → chart-markdown-CV75S_zL.js.map} +1 -1
  101. package/dist/client/chunks/{chart-measure-profile-ClfpLs4q.js → chart-measure-profile-Ket8fJyf.js} +7 -7
  102. package/dist/client/chunks/{chart-measure-profile-ClfpLs4q.js.map → chart-measure-profile-Ket8fJyf.js.map} +1 -1
  103. package/dist/client/chunks/chart-pie-ByieAX5H.js +119 -0
  104. package/dist/client/chunks/chart-pie-ByieAX5H.js.map +1 -0
  105. package/dist/client/chunks/chart-radar-CiSwHWp4.js +138 -0
  106. package/dist/client/chunks/chart-radar-CiSwHWp4.js.map +1 -0
  107. package/dist/client/chunks/chart-radial-bar-BF6Mhl6f.js +122 -0
  108. package/dist/client/chunks/chart-radial-bar-BF6Mhl6f.js.map +1 -0
  109. package/dist/client/chunks/{chart-sankey-M3XpO_ah.js → chart-sankey-DjrvKw6K.js} +36 -39
  110. package/dist/client/chunks/{chart-sankey-M3XpO_ah.js.map → chart-sankey-DjrvKw6K.js.map} +1 -1
  111. package/dist/client/chunks/chart-scatter-Dd9WFqnS.js +258 -0
  112. package/dist/client/chunks/chart-scatter-Dd9WFqnS.js.map +1 -0
  113. package/dist/client/chunks/{chart-sunburst-A_u6lqlS.js → chart-sunburst-leGpuDj7.js} +3 -3
  114. package/dist/client/chunks/{chart-sunburst-A_u6lqlS.js.map → chart-sunburst-leGpuDj7.js.map} +1 -1
  115. package/dist/client/chunks/chart-tree-map-Ceq5sLZA.js +323 -0
  116. package/dist/client/chunks/chart-tree-map-Ceq5sLZA.js.map +1 -0
  117. package/dist/client/chunks/{chart-waterfall-BuhMoagf.js → chart-waterfall-DyvQReN5.js} +7 -7
  118. package/dist/client/chunks/{chart-waterfall-BuhMoagf.js.map → chart-waterfall-DyvQReN5.js.map} +1 -1
  119. package/dist/client/chunks/{charts-core-jRtb0S2M.js → charts-core-DaXSt1Dd.js} +2 -2
  120. package/dist/client/chunks/{charts-core-jRtb0S2M.js.map → charts-core-DaXSt1Dd.js.map} +1 -1
  121. package/dist/client/chunks/charts-loader-DdTeCeNo.js +84 -0
  122. package/dist/client/chunks/charts-loader-DdTeCeNo.js.map +1 -0
  123. package/dist/client/chunks/{nl-NL-CpVs7ox3.js → nl-NL-2zTAWTej.js} +2 -1
  124. package/dist/client/chunks/{nl-NL-CpVs7ox3.js.map → nl-NL-2zTAWTej.js.map} +1 -1
  125. package/dist/client/chunks/retention-ChW9jYdy.js.map +1 -1
  126. package/dist/client/chunks/{schema-visualization-DE09kQE3.js → schema-visualization-Cb_E9_Gd.js} +12 -12
  127. package/dist/client/chunks/{schema-visualization-DE09kQE3.js.map → schema-visualization-Cb_E9_Gd.js.map} +1 -1
  128. package/dist/client/chunks/{useDirtyStateTracking-CoeQbprt.js → useDirtyStateTracking-MbpxH_v6.js} +95 -84
  129. package/dist/client/chunks/useDirtyStateTracking-MbpxH_v6.js.map +1 -0
  130. package/dist/client/chunks/{useExplainAI-DlnXWdmz.js → useExplainAI-evnZkjCY.js} +14 -14
  131. package/dist/client/chunks/{useExplainAI-DlnXWdmz.js.map → useExplainAI-evnZkjCY.js.map} +1 -1
  132. package/dist/client/chunks/{utils-CTKNaXS8.js → utils-3P6z1vz5.js} +2 -2
  133. package/dist/client/chunks/{utils-CTKNaXS8.js.map → utils-3P6z1vz5.js.map} +1 -1
  134. package/dist/client/chunks/{vendor-CPIYyeuD.js → vendor-DSpR0IW6.js} +43 -43
  135. package/dist/client/chunks/{vendor-CPIYyeuD.js.map → vendor-DSpR0IW6.js.map} +1 -1
  136. package/dist/client/components/AgenticNotebook/agentChatParts.d.ts +34 -0
  137. package/dist/client/components/AgenticNotebook/chatMessageParts.d.ts +39 -0
  138. package/dist/client/components/AgenticNotebook/useAgentChatController.d.ts +25 -0
  139. package/dist/client/components/AgenticNotebook/useNotebookAutosave.d.ts +12 -0
  140. package/dist/client/components/AnalysisBuilder/AnalysisQueryPanelParts.d.ts +64 -0
  141. package/dist/client/components/AnalysisBuilder/AnalysisResultsHeader.d.ts +67 -0
  142. package/dist/client/components/AnalysisBuilder/BreakdownComparisonToggle.d.ts +13 -0
  143. package/dist/client/components/AnalysisBuilder/BreakdownRow.d.ts +26 -0
  144. package/dist/client/components/AnalysisBuilder/DisplayOptionControl.d.ts +10 -0
  145. package/dist/client/components/AnalysisBuilder/ExecutionPlanPanelParts.d.ts +22 -0
  146. package/dist/client/components/AnalysisBuilder/FieldSearchResults.d.ts +16 -0
  147. package/dist/client/components/AnalysisBuilder/FilterValueInput.d.ts +63 -0
  148. package/dist/client/components/AnalysisBuilder/FlowDepthControls.d.ts +10 -0
  149. package/dist/client/components/AnalysisBuilder/FlowVisualizationPicker.d.ts +7 -0
  150. package/dist/client/components/AnalysisBuilder/LegacyBooleanOptions.d.ts +8 -0
  151. package/dist/client/components/AnalysisBuilder/MetricRow.d.ts +23 -0
  152. package/dist/client/components/AnalysisBuilder/SortToggleButton.d.ts +13 -0
  153. package/dist/client/components/AnalysisBuilder/StringArrayInput.d.ts +17 -0
  154. package/dist/client/components/AnalysisBuilder/filterConfigModalUtils.d.ts +30 -0
  155. package/dist/client/components/AnalysisBuilder/hooks/useAnalysisBuilderImperativeHandle.d.ts +13 -0
  156. package/dist/client/components/AnalysisBuilder/hooks/useDragReorder.d.ts +25 -0
  157. package/dist/client/components/AnalysisBuilder/hooks/useFieldSearchKeyboard.d.ts +11 -0
  158. package/dist/client/components/AnalysisBuilder/utils/axisConfigUtils.d.ts +23 -0
  159. package/dist/client/components/AnalysisBuilder/utils/executionPlanMarkdown.d.ts +8 -0
  160. package/dist/client/components/AnalysisBuilder/utils/fieldUtils.d.ts +5 -0
  161. package/dist/client/components/AnalysisBuilder/utils/resultsPanelDerive.d.ts +68 -0
  162. package/dist/client/components/AnalysisBuilder/utils/shareStateUtils.d.ts +68 -0
  163. package/dist/client/components/AnalysisBuilder/utils/sortUtils.d.ts +7 -0
  164. package/dist/client/components/DashboardFilters/CompactFilterBarParts.d.ts +26 -0
  165. package/dist/client/components/DashboardFilters/DashboardFilterConfigModalParts.d.ts +27 -0
  166. package/dist/client/components/DashboardFilters/DashboardFilterValueInput.d.ts +39 -0
  167. package/dist/client/components/DashboardFilters/dashboardFilterConfigModalUtils.d.ts +21 -0
  168. package/dist/client/components/DashboardFilters/useCompactFilterBar.d.ts +19 -0
  169. package/dist/client/components/DashboardFilters/useDashboardFilterConfigModal.d.ts +69 -0
  170. package/dist/client/components/DashboardFilters/useDateRangeState.d.ts +19 -0
  171. package/dist/client/components/DashboardFilters/useFilterDropdowns.d.ts +21 -0
  172. package/dist/client/components/DashboardFilters/useFilterValueFetch.d.ts +23 -0
  173. package/dist/client/components/DashboardPortletCard.d.ts +2 -57
  174. package/dist/client/components/analyticsPortlet/PortletChart.d.ts +31 -0
  175. package/dist/client/components/analyticsPortlet/PortletChartView.d.ts +35 -0
  176. package/dist/client/components/analyticsPortlet/PortletStates.d.ts +65 -0
  177. package/dist/client/components/analyticsPortlet/parsePortletQuery.d.ts +22 -0
  178. package/dist/client/components/analyticsPortlet/portletRenderState.d.ts +31 -0
  179. package/dist/client/components/analyticsPortlet/usePortletDebugData.d.ts +37 -0
  180. package/dist/client/components/analyticsPortlet/usePortletDrillState.d.ts +17 -0
  181. package/dist/client/components/analyticsPortlet/usePortletQueryResults.d.ts +37 -0
  182. package/dist/client/components/charts/ActivityGridChart.helpers.d.ts +33 -0
  183. package/dist/client/components/charts/ActivityGridChart.render.d.ts +31 -0
  184. package/dist/client/components/charts/AxisFormatControls.d.ts +3 -1
  185. package/dist/client/components/charts/BarChart.helpers.d.ts +23 -0
  186. package/dist/client/components/charts/BarSeries.d.ts +29 -0
  187. package/dist/client/components/charts/BubbleChart.helpers.d.ts +43 -0
  188. package/dist/client/components/charts/BubbleChart.render.d.ts +21 -0
  189. package/dist/client/components/charts/ChartStates.d.ts +38 -0
  190. package/dist/client/components/charts/FunnelChart.helpers.d.ts +25 -0
  191. package/dist/client/components/charts/FunnelViews.d.ts +16 -0
  192. package/dist/client/components/charts/HeatMapCanvas.d.ts +25 -0
  193. package/dist/client/components/charts/HeatMapChart.helpers.d.ts +64 -0
  194. package/dist/client/components/charts/KpiDelta.helpers.d.ts +20 -0
  195. package/dist/client/components/charts/KpiNumber.helpers.d.ts +30 -0
  196. package/dist/client/components/charts/KpiStates.d.ts +19 -0
  197. package/dist/client/components/charts/ScatterChart.helpers.d.ts +43 -0
  198. package/dist/client/components/charts/ScatterSeries.d.ts +17 -0
  199. package/dist/client/components/charts/ScatterTooltip.d.ts +21 -0
  200. package/dist/client/components/charts/TreeMapChart.helpers.d.ts +37 -0
  201. package/dist/client/components/charts/TreeMapContent.d.ts +24 -0
  202. package/dist/client/components/charts/TreeMapLegend.d.ts +13 -0
  203. package/dist/client/components/charts/cartesianChartHelpers.d.ts +126 -0
  204. package/dist/client/components/charts/chartAxisResolution.d.ts +32 -0
  205. package/dist/client/components/charts/chartScaffolding.d.ts +77 -0
  206. package/dist/client/components/charts/gaugeChartHelpers.d.ts +36 -0
  207. package/dist/client/components/charts/kpiTextHelpers.d.ts +46 -0
  208. package/dist/client/components/charts/radarChartHelpers.d.ts +14 -0
  209. package/dist/client/components/charts/radialBarChartHelpers.d.ts +22 -0
  210. package/dist/client/components/charts/useChartDimensions.d.ts +20 -0
  211. package/dist/client/components/charts/useKpiDimensions.d.ts +30 -0
  212. package/dist/client/components/dashboard/DashboardEditBar.d.ts +5 -0
  213. package/dist/client/components/dashboard/LayoutModeToggle.d.ts +10 -0
  214. package/dist/client/components/dashboardPortletCard/FilterFieldChip.d.ts +12 -0
  215. package/dist/client/components/dashboardPortletCard/PortletCardHeader.d.ts +43 -0
  216. package/dist/client/components/dashboardPortletCard/cardStyles.d.ts +33 -0
  217. package/dist/client/components/dashboardPortletCard/filterField.d.ts +12 -0
  218. package/dist/client/components/dashboardPortletCard/propsEqual.d.ts +55 -0
  219. package/dist/client/components/dashboardPortletCard/usePortletCardActions.d.ts +16 -0
  220. package/dist/client/components/portletAnalysisModal/saveValidation.d.ts +8 -0
  221. package/dist/client/components/shared/dateRangeUtils.d.ts +40 -0
  222. package/dist/client/components/shared/filterDisplayUtils.d.ts +10 -0
  223. package/dist/client/components/shared/filterItem/FilterDateRangeSelector.d.ts +17 -0
  224. package/dist/client/components/shared/filterItem/FilterFieldDropdown.d.ts +16 -0
  225. package/dist/client/components/shared/filterItem/dateRangeSync.d.ts +14 -0
  226. package/dist/client/components/shared/filterItem/fieldVisuals.d.ts +5 -0
  227. package/dist/client/components/shared/filterValueSelector/FilterValueInputs.d.ts +55 -0
  228. package/dist/client/components/shared/filterValueSelector/useFilterValueSelectorState.d.ts +25 -0
  229. package/dist/client/components/shared/queryFieldUtils.d.ts +21 -0
  230. package/dist/client/components/shared/utils.d.ts +4 -43
  231. package/dist/client/components.js +3 -3
  232. package/dist/client/hooks/agentChatStream.d.ts +39 -0
  233. package/dist/client/hooks/analysisQueryExecutionModes.d.ts +133 -0
  234. package/dist/client/hooks/drillNavigation.d.ts +25 -0
  235. package/dist/client/hooks.js +3 -3
  236. package/dist/client/icons.js +2 -2
  237. package/dist/client/index.js +816 -669
  238. package/dist/client/index.js.map +1 -1
  239. package/dist/client/providers.js +3 -3
  240. package/dist/client/schema.js +1 -1
  241. package/dist/client/shared/chartConfigBuilders.d.ts +18 -0
  242. package/dist/client/shared/components/QueryAnalysisPanel.sections.d.ts +41 -0
  243. package/dist/client/shared/queryTransforms.d.ts +20 -0
  244. package/dist/client/shared/utils.d.ts +2 -4
  245. package/dist/client/stores/optionsToAnalysisConfig.d.ts +17 -0
  246. package/dist/client/styles.css +1 -1
  247. package/dist/client/utils/axisValueFormatting.d.ts +32 -0
  248. package/dist/client/utils/timeValueFormatting.d.ts +32 -0
  249. package/dist/client/utils.js +6 -6
  250. package/dist/client-bundle-stats.html +1 -1
  251. package/dist/mcp-app/mcp-app.html +55 -55
  252. package/dist/server/google-BOnRIN1w.cjs +2 -0
  253. package/dist/server/{google-CFYljAOF.js → google-CvKM9yVM.js} +83 -71
  254. package/dist/server/index.cjs +179 -211
  255. package/dist/server/index.js +6330 -6458
  256. package/dist/server/{openai-BZdAA7Ji.js → openai-cDlFSTk6.js} +60 -58
  257. package/dist/server/openai-vXvLni8v.cjs +1 -0
  258. package/dist/server/server/adapters/base-adapter.d.ts +80 -35
  259. package/dist/server/server/adapters/databend-adapter.d.ts +8 -59
  260. package/dist/server/server/adapters/duckdb-adapter.d.ts +5 -59
  261. package/dist/server/server/adapters/mysql-adapter.d.ts +13 -70
  262. package/dist/server/server/adapters/postgres-adapter.d.ts +1 -65
  263. package/dist/server/server/adapters/snowflake-adapter.d.ts +5 -68
  264. package/dist/server/server/adapters/sqlite-adapter.d.ts +12 -32
  265. package/dist/server/server/adapters/window-function-builder.d.ts +11 -0
  266. package/dist/server/server/agent/chart-validation.d.ts +0 -5
  267. package/dist/server/server/agent/handler-steps.d.ts +37 -0
  268. package/dist/server/server/ai/discovery-helpers.d.ts +29 -0
  269. package/dist/server/server/ai/discovery.d.ts +4 -0
  270. package/dist/server/server/ai/suggestion-helpers.d.ts +33 -0
  271. package/dist/server/server/ai/suggestion.d.ts +0 -3
  272. package/dist/server/server/ai/validation-helpers.d.ts +21 -0
  273. package/dist/server/server/ai/validation.d.ts +0 -3
  274. package/dist/server/server/builders/analysis-utils.d.ts +106 -0
  275. package/dist/server/server/builders/cte-builder.d.ts +46 -0
  276. package/dist/server/server/builders/date-time-builder.d.ts +5 -0
  277. package/dist/server/server/builders/date-time-helpers.d.ts +34 -0
  278. package/dist/server/server/builders/filter-builder.d.ts +2 -0
  279. package/dist/server/server/builders/filter-operators.d.ts +23 -0
  280. package/dist/server/server/builders/flow-query-builder.d.ts +46 -19
  281. package/dist/server/server/builders/funnel-query-builder.d.ts +16 -5
  282. package/dist/server/server/builders/group-by-builder.d.ts +11 -0
  283. package/dist/server/server/builders/measure-builder.d.ts +43 -0
  284. package/dist/server/server/builders/retention-query-builder.d.ts +12 -14
  285. package/dist/server/server/cache-utils.d.ts +25 -5
  286. package/dist/server/server/compiler-metadata.d.ts +11 -0
  287. package/dist/server/server/compiler.d.ts +8 -14
  288. package/dist/server/server/cube-utils.d.ts +29 -4
  289. package/dist/server/server/execution/annotation-builder.d.ts +12 -0
  290. package/dist/server/server/execution/filter-cache-preloader.d.ts +19 -0
  291. package/dist/server/server/execution/mode-router.d.ts +25 -0
  292. package/dist/server/server/execution/query-result-cache.d.ts +21 -0
  293. package/dist/server/server/execution/result-post-processor.d.ts +10 -0
  294. package/dist/server/server/executor.d.ts +33 -30
  295. package/dist/server/server/executors/explain-utils.d.ts +28 -0
  296. package/dist/server/server/explain/explain-tree.d.ts +20 -0
  297. package/dist/server/server/filter-cache.d.ts +2 -2
  298. package/dist/server/server/gap-filler.d.ts +6 -0
  299. package/dist/server/server/index.d.ts +3 -1
  300. package/dist/server/server/logical-plan/cte-planner-helpers.d.ts +37 -0
  301. package/dist/server/server/logical-plan/cte-planner.d.ts +104 -0
  302. package/dist/server/server/logical-plan/filter-propagation.d.ts +44 -0
  303. package/dist/server/server/logical-plan/index.d.ts +6 -1
  304. package/dist/server/server/logical-plan/join-planner.d.ts +27 -0
  305. package/dist/server/server/logical-plan/logical-planner.d.ts +7 -200
  306. package/dist/server/server/logical-plan/optimiser.d.ts +3 -1
  307. package/dist/server/server/logical-plan/plan-analysis-reporter.d.ts +59 -0
  308. package/dist/server/server/logical-plan/planner-utils.d.ts +20 -0
  309. package/dist/server/server/logical-plan/types.d.ts +17 -9
  310. package/dist/server/server/measure-classification.d.ts +40 -0
  311. package/dist/server/server/physical-plan/drizzle-plan-builder.d.ts +21 -21
  312. package/dist/server/server/physical-plan/drizzle-sql-builder.d.ts +11 -0
  313. package/dist/server/server/physical-plan/processors/index.d.ts +2 -0
  314. package/dist/server/server/physical-plan/processors/keys-dedup-processor.d.ts +13 -0
  315. package/dist/server/server/physical-plan/processors/multi-fact-processor.d.ts +13 -0
  316. package/dist/server/server/physical-plan/processors/shared.d.ts +5 -0
  317. package/dist/server/server/query-handlers.d.ts +79 -0
  318. package/dist/server/server/query-modes.d.ts +28 -0
  319. package/dist/server/server/query-validator.d.ts +9 -0
  320. package/dist/server/server/resolvers/calculated-measure-resolver.d.ts +5 -0
  321. package/dist/server/server/resolvers/join-path-resolver.d.ts +6 -0
  322. package/dist/server/server/sql-format.d.ts +11 -0
  323. package/dist/server/server/types/cube.d.ts +18 -4
  324. package/dist/server/server/types/flow.d.ts +6 -5
  325. package/dist/server/server/types/index.d.ts +1 -1
  326. package/dist/server/server/types/validation.d.ts +14 -0
  327. package/package.json +11 -4
  328. package/dist/adapters/google-DUlXeeDA.cjs +0 -2
  329. package/dist/adapters/handler-CzbCuS6_.cjs +0 -25
  330. package/dist/adapters/locale-BPB7flIG.js +0 -8249
  331. package/dist/adapters/locale-tIMrNcCr.cjs +0 -198
  332. package/dist/adapters/mcp-transport-C2QzXm6h.cjs +0 -40
  333. package/dist/adapters/mcp-transport-D0B3S1tB.js +0 -579
  334. package/dist/adapters/openai-D_U4V0kT.cjs +0 -1
  335. package/dist/adapters/utils-KV37IBIv.cjs +0 -128
  336. package/dist/client/chunks/DashboardEditModal-CjCIAT-J.js.map +0 -1
  337. package/dist/client/chunks/analysis-builder-MuMIzoRq.js +0 -5367
  338. package/dist/client/chunks/analysis-builder-MuMIzoRq.js.map +0 -1
  339. package/dist/client/chunks/analysis-builder-shared-CYVwSPqt.js.map +0 -1
  340. package/dist/client/chunks/chart-activity-grid-DmruKPab.js.map +0 -1
  341. package/dist/client/chunks/chart-area-DHCPM4Em.js +0 -450
  342. package/dist/client/chunks/chart-area-DHCPM4Em.js.map +0 -1
  343. package/dist/client/chunks/chart-bar-KddciGDv.js +0 -271
  344. package/dist/client/chunks/chart-bar-KddciGDv.js.map +0 -1
  345. package/dist/client/chunks/chart-bubble-CfqiB538.js +0 -273
  346. package/dist/client/chunks/chart-bubble-CfqiB538.js.map +0 -1
  347. package/dist/client/chunks/chart-config-area-Bq_UsW3x.js +0 -101
  348. package/dist/client/chunks/chart-config-area-Bq_UsW3x.js.map +0 -1
  349. package/dist/client/chunks/chart-config-bar-_JEGZnAu.js +0 -95
  350. package/dist/client/chunks/chart-config-bar-_JEGZnAu.js.map +0 -1
  351. package/dist/client/chunks/chart-config-box-plot-DJ-dWWXA.js.map +0 -1
  352. package/dist/client/chunks/chart-config-gauge-DSwC04l0.js.map +0 -1
  353. package/dist/client/chunks/chart-config-kpi-delta-D6BIkHL3.js.map +0 -1
  354. package/dist/client/chunks/chart-config-kpi-number-Bx-V9a62.js.map +0 -1
  355. package/dist/client/chunks/chart-config-kpi-text-CcqC1u-8.js.map +0 -1
  356. package/dist/client/chunks/chart-config-line-Db3jDsWc.js.map +0 -1
  357. package/dist/client/chunks/chart-config-pie-DD4SmRTF.js.map +0 -1
  358. package/dist/client/chunks/chart-config-radar-CC2XAaGr.js.map +0 -1
  359. package/dist/client/chunks/chart-config-radial-bar-DmxKx1R0.js.map +0 -1
  360. package/dist/client/chunks/chart-config-tree-map-BI-oQStO.js.map +0 -1
  361. package/dist/client/chunks/chart-config-waterfall-DSnyixbI.js.map +0 -1
  362. package/dist/client/chunks/chart-data-table-BO4sXsim.js.map +0 -1
  363. package/dist/client/chunks/chart-funnel-DnWRsmnS.js.map +0 -1
  364. package/dist/client/chunks/chart-gauge-CgMeqeGb.js +0 -424
  365. package/dist/client/chunks/chart-gauge-CgMeqeGb.js.map +0 -1
  366. package/dist/client/chunks/chart-heat-map-DcGm9SWK.js +0 -231
  367. package/dist/client/chunks/chart-heat-map-DcGm9SWK.js.map +0 -1
  368. package/dist/client/chunks/chart-kpi-delta-C2wKPqCb.js +0 -343
  369. package/dist/client/chunks/chart-kpi-delta-C2wKPqCb.js.map +0 -1
  370. package/dist/client/chunks/chart-kpi-number-gWYF44ol.js +0 -322
  371. package/dist/client/chunks/chart-kpi-number-gWYF44ol.js.map +0 -1
  372. package/dist/client/chunks/chart-kpi-text-DIYtJtk4.js +0 -149
  373. package/dist/client/chunks/chart-kpi-text-DIYtJtk4.js.map +0 -1
  374. package/dist/client/chunks/chart-line-9BEGN5Ti.js +0 -433
  375. package/dist/client/chunks/chart-line-9BEGN5Ti.js.map +0 -1
  376. package/dist/client/chunks/chart-pie-BjAIhyOi.js +0 -172
  377. package/dist/client/chunks/chart-pie-BjAIhyOi.js.map +0 -1
  378. package/dist/client/chunks/chart-radar-Dgkcl2bN.js +0 -154
  379. package/dist/client/chunks/chart-radar-Dgkcl2bN.js.map +0 -1
  380. package/dist/client/chunks/chart-radial-bar-DdWJjAhK.js +0 -148
  381. package/dist/client/chunks/chart-radial-bar-DdWJjAhK.js.map +0 -1
  382. package/dist/client/chunks/chart-scatter-DaHYP_OL.js +0 -255
  383. package/dist/client/chunks/chart-scatter-DaHYP_OL.js.map +0 -1
  384. package/dist/client/chunks/chart-tree-map-uiwUU4nb.js +0 -298
  385. package/dist/client/chunks/chart-tree-map-uiwUU4nb.js.map +0 -1
  386. package/dist/client/chunks/useDirtyStateTracking-CoeQbprt.js.map +0 -1
  387. package/dist/server/google-DUlXeeDA.cjs +0 -2
  388. package/dist/server/openai-D_U4V0kT.cjs +0 -1
@@ -0,0 +1,34 @@
1
+ import { DatabaseAdapter } from '../adapters/base-adapter';
2
+ /**
3
+ * Convert a millisecond epoch to the engine's wire format:
4
+ * - SQLite: Unix seconds (integer)
5
+ * - other integer-timestamp engines: Unix milliseconds (integer)
6
+ * - PostgreSQL/MySQL: ISO string
7
+ */
8
+ export declare function epochMsToEngineValue(databaseAdapter: DatabaseAdapter, timeMs: number): string | number;
9
+ /**
10
+ * Convert a Date to the engine's wire format (see epochMsToEngineValue).
11
+ */
12
+ export declare function dateToEngineValue(databaseAdapter: DatabaseAdapter, date: Date): string | number;
13
+ /**
14
+ * Reconstruct a Date from a normalized value (the output of normalizeDate):
15
+ * a SQLite Unix-seconds integer, a millisecond integer, or an ISO string.
16
+ */
17
+ export declare function engineValueToDate(databaseAdapter: DatabaseAdapter, value: string | number): Date;
18
+ /** Detect a date-only string (YYYY-MM-DD). */
19
+ export declare function isDateOnlyString(value: unknown): value is string;
20
+ /**
21
+ * Normalize a date value to the engine's wire format, or null when falsy or
22
+ * unparseable.
23
+ */
24
+ export declare function normalizeDateValue(databaseAdapter: DatabaseAdapter, value: any): string | number | null;
25
+ type DateRange = {
26
+ start: Date;
27
+ end: Date;
28
+ };
29
+ /**
30
+ * Parse relative date range expressions like "today", "yesterday",
31
+ * "last 7 days", "this month", etc. Handles all 14 DATE_RANGE_OPTIONS.
32
+ */
33
+ export declare function parseRelativeDateRangeValue(dateRange: string): DateRange | null;
34
+ export {};
@@ -15,6 +15,8 @@ export declare class FilterBuilder {
15
15
  * This handles nested filter structures and builds combined SQL
16
16
  */
17
17
  buildLogicalFilter(filter: Filter, cubes: Map<string, Cube>, context: QueryContext): SQL | null;
18
+ /** Build + AND/OR-combine a list of sub-filters, collapsing the 0- and 1-element cases. */
19
+ private combineFilters;
18
20
  /**
19
21
  * Build SQL for a single filter condition (simple or logical)
20
22
  * Used for cache preloading to build filters independently of query context
@@ -0,0 +1,23 @@
1
+ import { SQL, AnyColumn } from 'drizzle-orm';
2
+ import { FilterOperator } from '../types';
3
+ import { DatabaseAdapter } from '../adapters/base-adapter';
4
+ import { DateTimeBuilder } from './date-time-builder';
5
+ /**
6
+ * Context passed to every operator handler. Carries the resolved field
7
+ * expression, the (already filtered/converted) value list, plus the
8
+ * collaborators a handler may need.
9
+ */
10
+ export interface FilterOperatorContext {
11
+ fieldExpr: AnyColumn | SQL;
12
+ values: any[];
13
+ filteredValues: any[];
14
+ value: any;
15
+ field?: any;
16
+ databaseAdapter: DatabaseAdapter;
17
+ dateTimeBuilder: DateTimeBuilder;
18
+ }
19
+ /**
20
+ * Dispatch a single filter operator to its handler. Returns null for any
21
+ * unknown operator (matching the original `default` case).
22
+ */
23
+ export declare function applyFilterOperator(operator: FilterOperator, ctx: FilterOperatorContext): SQL | null;
@@ -1,5 +1,6 @@
1
1
  import { DatabaseAdapter } from '../adapters/base-adapter';
2
- import { FlowQueryConfig, FlowResultRow, FlowValidationResult } from '../types/flow';
2
+ import { FlowQueryConfig, FlowResultRow } from '../types/flow';
3
+ import { AnalysisConfigValidationResult } from '../types/validation';
3
4
  import { Cube, QueryContext, SemanticQuery } from '../types';
4
5
  export declare class FlowQueryBuilder {
5
6
  private filterBuilder;
@@ -13,7 +14,21 @@ export declare class FlowQueryBuilder {
13
14
  /**
14
15
  * Validate flow configuration
15
16
  */
16
- validateConfig(config: FlowQueryConfig, cubes: Map<string, Cube>): FlowValidationResult;
17
+ validateConfig(config: FlowQueryConfig, cubes: Map<string, Cube>): AnalysisConfigValidationResult;
18
+ /**
19
+ * Validate a `Cube.dimension` member string: format, cube existence, and
20
+ * dimension existence. i18n message factories let each call site supply its
21
+ * own keys while sharing the branch structure.
22
+ */
23
+ private validateMemberDimension;
24
+ /** Validate the flow binding key (single member or per-cube mappings). */
25
+ private validateBindingKey;
26
+ /** Validate the flow starting step (required + filter + name warning). */
27
+ private validateStartingStep;
28
+ /** Validate flow step-depth bounds and emit high-depth performance warnings. */
29
+ private validateDepthBounds;
30
+ /** Validate the flow join strategy and its engine support. */
31
+ private validateJoinStrategy;
17
32
  /**
18
33
  * Build complete flow query using Drizzle's query builder pattern
19
34
  *
@@ -57,6 +72,10 @@ export declare class FlowQueryBuilder {
57
72
  * Build a single filter condition
58
73
  */
59
74
  private buildFilterCondition;
75
+ /** Build the non-null sub-conditions of a logical/group filter. */
76
+ private buildSubConditions;
77
+ /** Combine sub-conditions with AND/OR, collapsing the 0- and 1-element cases. */
78
+ private combineConditions;
60
79
  /**
61
80
  * Build the starting entities CTE
62
81
  * Finds all entities matching the starting step filter with their start time and event type
@@ -64,31 +83,39 @@ export declare class FlowQueryBuilder {
64
83
  */
65
84
  private buildStartingEntitiesCTE;
66
85
  /**
67
- * Build CTEs for steps BEFORE the starting point using LATERAL joins
68
- * Uses ORDER BY ... DESC LIMIT 1 to fetch immediate predecessor via index
86
+ * Build CTEs for steps BEFORE/AFTER the starting point using LATERAL joins
87
+ *
88
+ * Direction-parameterised: 'before' walks backwards (time `<` reference,
89
+ * ORDER BY DESC, `before_step_N` aliases, bounded by `stepsBefore`); 'after'
90
+ * walks forwards (time `>`, ORDER BY ASC, `after_step_N`, `stepsAfter`).
91
+ * Uses ORDER BY ... LIMIT 1 to fetch the immediate predecessor/successor via index.
69
92
  */
70
- private buildBeforeCTEsLateral;
93
+ private buildDirectionalCTEsLateral;
71
94
  /**
72
- * Build CTEs for steps AFTER the starting point using LATERAL joins
73
- * Uses ORDER BY ... ASC LIMIT 1 to fetch immediate successor via index
95
+ * Build CTEs for steps BEFORE/AFTER the starting point using ROW_NUMBER()
96
+ *
97
+ * Direction-parameterised: 'before' finds the immediate predecessor (time `<`
98
+ * reference, ROW_NUMBER ORDER BY DESC, `before_step_N` aliases, bounded by
99
+ * `stepsBefore`); 'after' finds the immediate successor (time `>`, ORDER BY ASC,
100
+ * `after_step_N`, `stepsAfter`). For sunburst mode, accumulates event_path
101
+ * (prepend for before, append for after).
74
102
  */
75
- private buildAfterCTEsLateral;
103
+ private buildDirectionalCTEsWindow;
76
104
  /**
77
- * Build CTEs for steps BEFORE the starting point
78
- * Each CTE finds the immediate predecessor event for entities from the previous CTE
105
+ * Build a single node-aggregation UNION arm for a before/after step.
79
106
  *
80
- * Uses ROW_NUMBER() window function to get exactly the Nth previous event
81
- * For sunburst mode, accumulates event_path by prepending to previous path
107
+ * Sankey groups by `event_type` (converging paths); sunburst groups by
108
+ * `event_path` (unique tree branches). The node-id prefix and layer are
109
+ * emitted via sql.raw() because they're hardcoded constants (not user input)
110
+ * and avoid multi-digit parameter issues in DuckDB.
82
111
  */
83
- private buildBeforeCTEsWindow;
112
+ private buildNodeArm;
84
113
  /**
85
- * Build CTEs for steps AFTER the starting point
86
- * Each CTE finds the immediate successor event for entities from the previous CTE
87
- *
88
- * Uses ROW_NUMBER() window function to get exactly the Nth following event
89
- * For sunburst mode, accumulates event_path by concatenating with previous path
114
+ * Build a single link-aggregation UNION arm between two adjacent step CTEs
115
+ * (before→before or after→after). Sankey keys transitions on `event_type`,
116
+ * sunburst on `event_path`. Source/target id prefixes are sql.raw() constants.
90
117
  */
91
- private buildAfterCTEsWindow;
118
+ private buildAdjacentLinkArm;
92
119
  /**
93
120
  * Build the nodes aggregation CTE
94
121
  * Aggregates counts per (layer, event_type) combination using UNION ALL
@@ -1,6 +1,6 @@
1
1
  import { DatabaseAdapter } from '../adapters/base-adapter';
2
2
  import { FunnelQueryConfig, FunnelResultRow } from '../types/funnel';
3
- import { Cube, QueryContext, SemanticQuery } from '../types';
3
+ import { Cube, QueryContext, SemanticQuery, AnalysisConfigValidationResult } from '../types';
4
4
  export declare class FunnelQueryBuilder {
5
5
  private databaseAdapter;
6
6
  private filterBuilder;
@@ -13,10 +13,15 @@ export declare class FunnelQueryBuilder {
13
13
  /**
14
14
  * Validate funnel configuration
15
15
  */
16
- validateConfig(config: FunnelQueryConfig, cubes: Map<string, Cube>): {
17
- isValid: boolean;
18
- errors: string[];
19
- };
16
+ validateConfig(config: FunnelQueryConfig, cubes: Map<string, Cube>): AnalysisConfigValidationResult;
17
+ /** Validate the funnel binding key (single member or per-cube mappings). */
18
+ private validateBindingKey;
19
+ /** Validate the funnel time dimension member. */
20
+ private validateTimeDimension;
21
+ /** Validate a single funnel step (name, cube, filters, timeToConvert). */
22
+ private validateStep;
23
+ /** Validate the member filters of a single funnel step. */
24
+ private validateStepFilters;
20
25
  /**
21
26
  * Build complete funnel query using Drizzle's query builder pattern
22
27
  *
@@ -32,6 +37,8 @@ export declare class FunnelQueryBuilder {
32
37
  * Transform raw SQL result to FunnelResultRow[]
33
38
  */
34
39
  transformResult(rawResult: Record<string, unknown>[], config: FunnelQueryConfig): FunnelResultRow[];
40
+ /** Attach the per-step conversion-time metrics to a funnel result row. */
41
+ private applyTimeMetrics;
35
42
  /**
36
43
  * Extract cube names referenced in step filters
37
44
  */
@@ -68,6 +75,10 @@ export declare class FunnelQueryBuilder {
68
75
  * @param context - Query context with security context
69
76
  */
70
77
  private buildFilterCondition;
78
+ /** Combine a logical/group filter's sub-conditions into a single SQL condition. */
79
+ private buildLogicalFilterCondition;
80
+ /** Build a simple (member) filter condition, validating values and cross-cube join paths. */
81
+ private buildSimpleFilterCondition;
71
82
  /**
72
83
  * Build CTE for a single step using Drizzle's $with() pattern
73
84
  *
@@ -24,4 +24,15 @@ export declare class GroupByBuilder {
24
24
  * Window functions do not require GROUP BY and operate on individual rows.
25
25
  */
26
26
  buildGroupByFields(cubes: Map<string, Cube> | Cube, query: SemanticQuery, context: QueryContext, queryPlan?: PhysicalQueryPlan): (SQL | AnyColumn)[];
27
+ /**
28
+ * Determine whether the query contains at least one aggregate (or calculated,
29
+ * or post-aggregation window over an aggregate) measure — which forces GROUP BY.
30
+ */
31
+ private hasAggregateMeasures;
32
+ /** True when `measure` is a post-aggregation window over an aggregate base measure. */
33
+ private isWindowOverAggregate;
34
+ /** Resolve a single dimension into its GROUP BY expression (CTE-aware). */
35
+ private resolveDimensionGroupField;
36
+ /** Resolve a single time dimension into its GROUP BY expression (CTE-aware). */
37
+ private resolveTimeDimensionGroupField;
27
38
  }
@@ -17,6 +17,17 @@ export declare class MeasureBuilder {
17
17
  * @returns Map of measure names to SQL builder functions
18
18
  */
19
19
  buildResolvedMeasures(measureNames: string[], cubeMap: Map<string, Cube>, context: QueryContext, customMeasureBuilder?: (measureName: string, measure: any, cube: Cube) => SQL): ResolvedMeasures;
20
+ /**
21
+ * First-pass classification of a user-requested measure: sorts it into the
22
+ * regular/calculated buckets and seeds `allMeasuresToResolve` with its
23
+ * (transitive) dependencies. Post-aggregation windows only contribute their
24
+ * base measure as a dependency.
25
+ */
26
+ private classifyRequestedMeasure;
27
+ /** Seed `allMeasuresToResolve` with the direct + transitive deps of a calculated measure. */
28
+ private collectCalculatedDependencies;
29
+ /** Second-pass classification of a dependency measure into the regular/calculated buckets. */
30
+ private classifyDependencyMeasure;
20
31
  /**
21
32
  * Build calculated measure expression by substituting {member} references
22
33
  * with resolved SQL expressions
@@ -41,10 +52,21 @@ export declare class MeasureBuilder {
41
52
  measures: string[];
42
53
  cube: Cube;
43
54
  }, allCubes: Map<string, Cube>, context: QueryContext): SQL;
55
+ /**
56
+ * Re-aggregate a pre-aggregated CTE column based on the original measure type.
57
+ * For pre-aggregated values in CTEs we re-aggregate properly:
58
+ * - count/sum/number → SUM
59
+ * - avg → AVG (ideally a weighted average, but simple AVG for now)
60
+ * - min/max → MIN/MAX
61
+ * - anything else → SUM
62
+ */
63
+ private reAggregateCteColumn;
44
64
  /**
45
65
  * Build measure expression for HAVING clause, handling CTE references correctly
46
66
  */
47
67
  buildHavingMeasureExpression(cubeName: string, fieldKey: string, measure: any, context: QueryContext, queryPlan?: PhysicalQueryPlan): SQL;
68
+ /** Build a HAVING measure expression that references a pre-aggregation CTE column. */
69
+ private buildHavingCteMeasure;
48
70
  /**
49
71
  * Build measure expression with aggregation and filters
50
72
  * Note: This should NOT be called for calculated measures
@@ -54,6 +76,27 @@ export declare class MeasureBuilder {
54
76
  * @param cube - Optional cube reference for resolving dimension references (window functions)
55
77
  */
56
78
  buildMeasureExpression(measure: any, context: QueryContext, cube?: Cube): SQL;
79
+ /**
80
+ * Wrap a base expression in a CASE WHEN for measures carrying `filters`,
81
+ * producing conditional aggregation. Returns the original expression when
82
+ * there are no filters.
83
+ */
84
+ private applyMeasureFilters;
85
+ /** Apply the aggregation function implied by `measure.type` to `baseExpr`. */
86
+ private applyAggregation;
87
+ /**
88
+ * Run a statistical-function builder, falling back to MAX(NULL) with a warning
89
+ * when the engine doesn't support it (shared by stddev/variance/percentile).
90
+ */
91
+ private buildStatistical;
92
+ /** Resolve the percentile value implied by a percentile-family measure type. */
93
+ private resolvePercentile;
94
+ /** Build a (per-row) window-function measure expression. */
95
+ private buildWindowMeasure;
96
+ /** Resolve a window function's partitionBy dimension references to SQL expressions. */
97
+ private resolveWindowPartitions;
98
+ /** Resolve a window function's orderBy dimension/measure references to SQL expressions. */
99
+ private resolveWindowOrder;
57
100
  /**
58
101
  * List of measure types that are window functions
59
102
  * Window functions require special handling in CTEs:
@@ -1,6 +1,6 @@
1
1
  import { DatabaseAdapter } from '../adapters/base-adapter';
2
2
  import { RetentionQueryConfig, RetentionResultRow } from '../types/retention';
3
- import { Cube, QueryContext, SemanticQuery } from '../types';
3
+ import { Cube, QueryContext, SemanticQuery, AnalysisConfigValidationResult } from '../types';
4
4
  export declare class RetentionQueryBuilder {
5
5
  private databaseAdapter;
6
6
  private filterBuilder;
@@ -13,10 +13,17 @@ export declare class RetentionQueryBuilder {
13
13
  /**
14
14
  * Validate retention configuration against registered cubes
15
15
  */
16
- validateConfig(config: RetentionQueryConfig, cubes: Map<string, Cube>): {
17
- isValid: boolean;
18
- errors: string[];
19
- };
16
+ validateConfig(config: RetentionQueryConfig, cubes: Map<string, Cube>): AnalysisConfigValidationResult;
17
+ /** Validate the retention time dimension (used for cohort entry and activity). */
18
+ private validateTimeDimension;
19
+ /** Validate the retention binding key (single member or per-cube mappings). */
20
+ private validateBindingKey;
21
+ /** Validate optional retention breakdown dimensions. */
22
+ private validateBreakdownDimensions;
23
+ /** Validate retention period bounds, granularity, and retention type. */
24
+ private validatePeriodsAndEnums;
25
+ /** Validate the (required) retention date range: presence, parseability, ordering. */
26
+ private validateDateRange;
20
27
  /**
21
28
  * Build the retention SQL query using CTEs
22
29
  *
@@ -38,10 +45,6 @@ export declare class RetentionQueryBuilder {
38
45
  * Same cube/dimension used for both cohort entry and activity detection
39
46
  */
40
47
  private resolveConfig;
41
- /**
42
- * Resolve binding key expression for a cube
43
- */
44
- private resolveBindingKey;
45
48
  /**
46
49
  * Build filter conditions from config filters
47
50
  */
@@ -92,9 +95,4 @@ export declare class RetentionQueryBuilder {
92
95
  * Build period number expression using database-specific DATE_DIFF
93
96
  */
94
97
  private buildPeriodNumberExpression;
95
- /**
96
- * Extract dimension name from a dimension reference
97
- * Handles both 'CubeName.dimName' and just 'dimName' formats
98
- */
99
- private extractDimensionName;
100
98
  }
@@ -15,10 +15,11 @@ export interface CacheKeyConfig {
15
15
  *
16
16
  * Key structure: {prefix}query:{queryHash}:ctx:{securityHash}
17
17
  *
18
- * Uses FNV-1a hash for:
19
- * - Speed: ~3x faster than SHA-256
20
- * - Simplicity: No dependencies required
21
- * - Sufficient collision resistance for cache keys
18
+ * Uses a 128-bit FNV-1a-based hash (see {@link strongHash}) for both the query
19
+ * and the security context. A 128-bit digest is required here for correctness,
20
+ * not just speed: the security-context hash provides tenant isolation, and a
21
+ * collision serves one tenant's cached result to another. The full input is
22
+ * hashed (no truncation) so large queries cannot collide on a shared prefix.
22
23
  *
23
24
  * @param query - The semantic query to cache
24
25
  * @param securityContext - Security context for tenant isolation
@@ -42,7 +43,7 @@ export declare function normalizeQuery(query: SemanticQuery): SemanticQuery;
42
43
  */
43
44
  export declare function sortObject<T>(obj: T): T;
44
45
  /**
45
- * FNV-1a hash - fast, non-cryptographic hash function
46
+ * FNV-1a hash - fast, non-cryptographic 32-bit hash function
46
47
  * Returns hex string for cache key readability
47
48
  *
48
49
  * Properties:
@@ -50,10 +51,29 @@ export declare function sortObject<T>(obj: T): T;
50
51
  * - Low collision rate for similar strings
51
52
  * - Deterministic across runs
52
53
  *
54
+ * Note: a 32-bit digest is too narrow to isolate tenants by itself — use
55
+ * {@link strongHash} for cache keys. Retained for backwards compatibility.
56
+ *
53
57
  * @param str - String to hash
54
58
  * @returns 8-character hex string
55
59
  */
56
60
  export declare function fnv1aHash(str: string): string;
61
+ /**
62
+ * 128-bit FNV-1a-based hash for cache keys.
63
+ *
64
+ * Computes four independent 32-bit FNV-1a lanes (distinct offset bases, each
65
+ * mixed with the byte position) and concatenates them into a 32-character hex
66
+ * digest. This widens the key space from 2^32 to 2^128 so security-context and
67
+ * query collisions are vanishingly unlikely — collisions here are not merely a
68
+ * cache miss, they are a cross-tenant data-disclosure risk.
69
+ *
70
+ * The entire input is hashed (no truncation), and the input length is mixed in
71
+ * to disambiguate shared prefixes. `Math.imul` performs a true 32-bit multiply.
72
+ *
73
+ * @param str - String to hash
74
+ * @returns 32-character hex string (128 bits)
75
+ */
76
+ export declare function strongHash(str: string): string;
57
77
  /**
58
78
  * Generate invalidation pattern for a cube
59
79
  * Used when cube data changes and all related cache entries need clearing
@@ -0,0 +1,11 @@
1
+ import { Cube, MeasureMetadata, DimensionMetadata, CubeRelationshipMetadata, HierarchyMetadata, TimeGranularity } from './types';
2
+ /** Default time granularities used when a time dimension omits `granularities`. */
3
+ export declare const DEFAULT_TIME_GRANULARITIES: TimeGranularity[];
4
+ /** Build measure metadata, normalizing drillMembers to fully-qualified names. */
5
+ export declare function buildMeasureMetadata(cube: Cube): MeasureMetadata[];
6
+ /** Build dimension metadata, including granularities for time dimensions. */
7
+ export declare function buildDimensionMetadata(cube: Cube): DimensionMetadata[];
8
+ /** Build relationship metadata from a cube's joins, resolving target cubes. */
9
+ export declare function buildRelationshipMetadata(cube: Cube, cubes: Map<string, Cube>, getColumnName: (column: any) => string): CubeRelationshipMetadata[];
10
+ /** Build hierarchy metadata, qualifying level names to full member names. */
11
+ export declare function buildHierarchyMetadata(cube: Cube): HierarchyMetadata[];
@@ -1,9 +1,12 @@
1
1
  import { SemanticQuery, QueryResult, SecurityContext, DatabaseExecutor, CubeMetadata, Cube, QueryAnalysis, CacheConfig, ExplainOptions, ExplainResult, ExecutionOptions, RLSSetupFn } from './types';
2
+ import { PlanOptimiser } from './logical-plan';
3
+ export { validateQueryAgainstCubes } from './query-validator';
2
4
  export declare class SemanticLayerCompiler {
3
5
  private cubes;
4
6
  private metadataCache?;
5
7
  private cacheConfig?;
6
8
  private rlsSetup?;
9
+ private planOptimiser?;
7
10
  private db?;
8
11
  private schema?;
9
12
  private engineType?;
@@ -21,6 +24,11 @@ export declare class SemanticLayerCompiler {
21
24
  * Dry-run/SQL generation is NOT wrapped in a transaction.
22
25
  */
23
26
  rlsSetup?: RLSSetupFn;
27
+ /**
28
+ * Optional logical-plan optimiser injected into every QueryExecutor.
29
+ * Defaults to a no-op IdentityOptimiser when omitted.
30
+ */
31
+ planOptimiser?: PlanOptimiser;
24
32
  });
25
33
  /**
26
34
  * Set or update the database connection
@@ -105,14 +113,8 @@ export declare class SemanticLayerCompiler {
105
113
  * Handles different column types and extracts the actual column name
106
114
  */
107
115
  private getColumnName;
108
- /**
109
- * Default time granularities for time dimensions (ordered from least to most granular)
110
- * Used when dimension.granularities is not specified
111
- */
112
- private static readonly DEFAULT_TIME_GRANULARITIES;
113
116
  /**
114
117
  * Generate cube metadata for API responses from cubes
115
- * Optimized version that minimizes object iterations
116
118
  * Includes drill-down support: drillMembers on measures, granularities on time dimensions, hierarchies
117
119
  */
118
120
  private generateCubeMetadata;
@@ -208,11 +210,3 @@ export declare class SemanticLayerCompiler {
208
210
  */
209
211
  analyzeQuery(query: SemanticQuery, securityContext: SecurityContext): QueryAnalysis;
210
212
  }
211
- /**
212
- * Validate a query against a cubes map
213
- * Standalone function that can be used by both compiler and executor
214
- */
215
- export declare function validateQueryAgainstCubes(cubes: Map<string, Cube>, query: SemanticQuery): {
216
- isValid: boolean;
217
- errors: string[];
218
- };
@@ -1,5 +1,5 @@
1
1
  import { SQL, AnyColumn } from 'drizzle-orm';
2
- import { Cube, CubeJoin, QueryContext, MultiCubeQueryContext, SqlExpression, SecurityContext } from './types';
2
+ import { Cube, CubeJoin, Dimension, QueryContext, MultiCubeQueryContext, SqlExpression } from './types';
3
3
  /**
4
4
  * Resolve cube reference (handles direct, lazy, and string name references)
5
5
  *
@@ -99,6 +99,18 @@ export declare function safeKey(key: string): string;
99
99
  * @returns Isolated SQL expression safe for reuse
100
100
  */
101
101
  export declare function resolveSqlExpression(expr: AnyColumn | SQL | ((ctx: QueryContext) => AnyColumn | SQL), ctx: QueryContext): AnyColumn | SQL;
102
+ /**
103
+ * Resolve a dimension's SQL expression for use in a filter condition.
104
+ *
105
+ * For non-time dimensions, use the raw column so Drizzle preserves column type
106
+ * metadata for proper parameter binding (e.g. UUID columns need type info) — this
107
+ * deliberately bypasses isolateSqlExpression. For time dimensions, keep isolated
108
+ * SQL because normalizeDate() returns strings.
109
+ *
110
+ * Centralises the filter-field resolution that was previously copy-pasted across
111
+ * the filter builder, executor, and funnel/flow/retention builders.
112
+ */
113
+ export declare function resolveFilterFieldExpr(dimension: Dimension, ctx: QueryContext): AnyColumn | SQL;
102
114
  /**
103
115
  * Helper to create multi-cube query context
104
116
  */
@@ -111,6 +123,16 @@ export declare function isFunctionSqlExpression(expr: SqlExpression): expr is (c
111
123
  * Helper function to create cubes
112
124
  */
113
125
  export declare function defineCube(name: string, definition: Omit<Cube, 'name'>): Cube;
126
+ /**
127
+ * Build the Drizzle join condition for a regular (belongsTo/hasOne/hasMany)
128
+ * join from its symbolic CubeJoin definition. Columns are isolated to prevent
129
+ * Drizzle's mutable queryChunks from corrupting reused expressions. The
130
+ * condition is symmetric, so it is correct for reversed joins as-is.
131
+ *
132
+ * This is the materialization counterpart used by DrizzlePlanBuilder; it
133
+ * mirrors JoinPathResolver.buildJoinCondition(joinDef, null, null).
134
+ */
135
+ export declare function buildRegularJoinCondition(joinDef: CubeJoin): SQL;
114
136
  /**
115
137
  * Expanded join information for belongsToMany relationships
116
138
  */
@@ -121,13 +143,16 @@ export interface ExpandedBelongsToManyJoin {
121
143
  table: any;
122
144
  condition: SQL;
123
145
  }>;
124
- /** Security conditions for junction table (if any) */
125
- junctionSecurityConditions?: SQL[];
126
146
  }
127
147
  /**
128
148
  * Expand a belongsToMany join into junction table joins
129
149
  * This converts a many-to-many relationship into two separate joins:
130
150
  * 1. Source cube -> Junction table
131
151
  * 2. Junction table -> Target cube
152
+ *
153
+ * Junction-table security is intentionally NOT materialized here: it must be
154
+ * applied (in the WHERE clause) at physical-build time from the stored
155
+ * `through.securitySql` function with the request's security context, so the
156
+ * join conditions here are a pure function of the join definition.
132
157
  */
133
- export declare function expandBelongsToManyJoin(joinDef: CubeJoin, securityContext: SecurityContext): ExpandedBelongsToManyJoin;
158
+ export declare function expandBelongsToManyJoin(joinDef: CubeJoin): ExpandedBelongsToManyJoin;
@@ -0,0 +1,12 @@
1
+ import { PhysicalQueryPlan, SemanticQuery, MeasureAnnotation, DimensionAnnotation, TimeDimensionAnnotation } from '../types';
2
+ /**
3
+ * Generate annotations for UI metadata - unified approach.
4
+ * Collects measure/dimension/timeDimension titles from every cube in the plan
5
+ * (primary + joins + multi-fact merge groups).
6
+ */
7
+ export declare function buildAnnotations(queryPlan: PhysicalQueryPlan, query: SemanticQuery): {
8
+ measures: Record<string, MeasureAnnotation>;
9
+ dimensions: Record<string, DimensionAnnotation>;
10
+ segments: Record<string, never>;
11
+ timeDimensions: Record<string, TimeDimensionAnnotation>;
12
+ };
@@ -0,0 +1,19 @@
1
+ import { Cube, SemanticQuery, QueryContext } from '../types';
2
+ import { FilterCacheManager } from '../filter-cache';
3
+ import { DrizzleSqlBuilder } from '../physical-plan/drizzle-sql-builder';
4
+ export declare class FilterCachePreloader {
5
+ private readonly queryBuilder;
6
+ constructor(queryBuilder: DrizzleSqlBuilder);
7
+ /**
8
+ * Pre-build filter SQL and store in cache for reuse across CTEs and main query
9
+ * This enables parameter deduplication - the same filter values are shared
10
+ * rather than appearing as separate parameters in different parts of the query
11
+ */
12
+ preload(query: SemanticQuery, filterCache: FilterCacheManager, cubes: Map<string, Cube>, context: QueryContext): void;
13
+ /** Resolve the dimension a filter/time-dimension member refers to, or null. */
14
+ private resolveMemberDimension;
15
+ /** Pre-build and cache the SQL for a single simple (non-logical) filter. */
16
+ private preloadRegularFilter;
17
+ /** Pre-build and cache the date-range SQL for a single time dimension. */
18
+ private preloadTimeDimensionFilter;
19
+ }
@@ -0,0 +1,25 @@
1
+ import { Cube, SemanticQuery } from '../types';
2
+ import { ComparisonQueryBuilder } from '../builders/comparison-query-builder';
3
+ import { FunnelQueryBuilder } from '../builders/funnel-query-builder';
4
+ import { FlowQueryBuilder } from '../builders/flow-query-builder';
5
+ import { RetentionQueryBuilder } from '../builders/retention-query-builder';
6
+ export type QueryExecutionMode = 'regular' | 'comparison' | 'funnel' | 'flow' | 'retention';
7
+ export interface ModeRouterBuilders {
8
+ comparison: ComparisonQueryBuilder;
9
+ funnel: FunnelQueryBuilder;
10
+ flow: FlowQueryBuilder;
11
+ retention: RetentionQueryBuilder;
12
+ }
13
+ export declare class ModeRouter {
14
+ private readonly builders;
15
+ constructor(builders: ModeRouterBuilders);
16
+ /**
17
+ * Resolve the single active execution mode for a query.
18
+ * Throws if more than one analysis mode is present.
19
+ */
20
+ resolveMode(query: SemanticQuery): QueryExecutionMode;
21
+ /**
22
+ * Validate a query for its resolved mode. Throws a translated error on failure.
23
+ */
24
+ validateForMode(mode: QueryExecutionMode, cubes: Map<string, Cube>, query: SemanticQuery): void;
25
+ }
@@ -0,0 +1,21 @@
1
+ import { SecurityContext, SemanticQuery, QueryResult, CacheConfig } from '../types';
2
+ export declare class QueryResultCache {
3
+ private readonly cacheConfig?;
4
+ constructor(cacheConfig?: CacheConfig | undefined);
5
+ /**
6
+ * Returns the cache key when caching is enabled and a provider is configured,
7
+ * otherwise undefined (which disables lookup and store).
8
+ */
9
+ generateKey(query: SemanticQuery, securityContext: SecurityContext): string | undefined;
10
+ /**
11
+ * Look up a cached result. Returns the cached value (with cache metadata
12
+ * attached) on a hit, or undefined on miss / bypass / no-cache. Emits
13
+ * hit/miss events; lookup errors are non-fatal.
14
+ */
15
+ lookup(cacheKey: string | undefined, skipCache: boolean): Promise<QueryResult | undefined>;
16
+ /**
17
+ * Store a fresh result under the given key. No-ops when caching is disabled
18
+ * or the key is undefined. Store errors are non-fatal.
19
+ */
20
+ store(cacheKey: string | undefined, result: QueryResult): Promise<void>;
21
+ }
@@ -0,0 +1,10 @@
1
+ import { SemanticQuery } from '../types';
2
+ import { DatabaseAdapter } from '../adapters/base-adapter';
3
+ /**
4
+ * Normalise time-dimension values in result rows and apply gap filling.
5
+ *
6
+ * @param data Raw rows from the database executor
7
+ * @param query The semantic query (for timeDimensions + measures)
8
+ * @param databaseAdapter Adapter used to convert engine-specific date results
9
+ */
10
+ export declare function postProcessResultRows(data: unknown, query: SemanticQuery, databaseAdapter: DatabaseAdapter): Record<string, unknown>[];