drizzle-cube 0.5.7 → 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.
- package/README.md +2 -0
- package/dist/adapters/adapters/hono/agent-handler.d.ts +9 -0
- package/dist/adapters/adapters/hono/mcp-handler.d.ts +37 -0
- package/dist/adapters/adapters/mcp-tools-handlers.d.ts +18 -0
- package/dist/adapters/adapters/nextjs/mcp-handler.d.ts +36 -0
- package/dist/adapters/{utils.d.ts → adapters/utils.d.ts} +6 -81
- package/dist/adapters/express/index.cjs +1 -1
- package/dist/adapters/express/index.js +50 -50
- package/dist/adapters/fastify/index.cjs +1 -1
- package/dist/adapters/fastify/index.js +78 -78
- package/dist/adapters/google-BOnRIN1w.cjs +2 -0
- package/dist/{server/google-CFYljAOF.js → adapters/google-CvKM9yVM.js} +83 -71
- package/dist/adapters/{handler-Dz1F4iwf.js → handler-CfgE0JSL.js} +515 -578
- package/dist/adapters/handler-Cn0dOctE.cjs +25 -0
- package/dist/adapters/hono/index.cjs +2 -2
- package/dist/adapters/hono/index.js +208 -178
- package/dist/adapters/locale-DDvZDFVn.js +8114 -0
- package/dist/adapters/locale-ZLUUNUxr.cjs +166 -0
- package/dist/adapters/mcp-tools.cjs +1 -1
- package/dist/adapters/mcp-tools.js +49 -38
- package/dist/adapters/mcp-transport-Chiaj4ll.cjs +40 -0
- package/dist/adapters/mcp-transport-H96VG3WY.js +591 -0
- package/dist/adapters/nextjs/index.cjs +1 -1
- package/dist/adapters/nextjs/index.js +190 -197
- package/dist/{server/openai-y7GhJNdn.js → adapters/openai-B5jEiqiB.js} +776 -719
- package/dist/adapters/openai-D0musiYP.cjs +17 -0
- package/dist/{server/openai-DiVskd89.js → adapters/openai-cDlFSTk6.js} +61 -59
- package/dist/adapters/openai-vXvLni8v.cjs +1 -0
- package/dist/adapters/{utils-DosuoabY.js → utils-BPWZsX7k.js} +1285 -1220
- package/dist/adapters/utils-_whV4fXL.cjs +128 -0
- package/dist/adapters/utils.cjs +1 -1
- package/dist/adapters/utils.js +2 -2
- package/dist/client/charts/ChartLoader.d.ts +3 -17
- package/dist/client/charts/chartComponentRegistry.d.ts +46 -0
- package/dist/client/charts/chartConfigHelpers.d.ts +38 -0
- package/dist/client/charts.js +14 -13
- package/dist/client/chunks/{DashboardEditModal-6KRE36mm.js → DashboardEditModal-okVfH8ZK.js} +5446 -4486
- package/dist/client/chunks/DashboardEditModal-okVfH8ZK.js.map +1 -0
- package/dist/client/chunks/{RetentionCombinedChart-CCpu0C-s.js → RetentionCombinedChart-BgbDhsPz.js} +10 -10
- package/dist/client/chunks/{RetentionCombinedChart-CCpu0C-s.js.map → RetentionCombinedChart-BgbDhsPz.js.map} +1 -1
- package/dist/client/chunks/{RetentionHeatmap-B24PiIfr.js → RetentionHeatmap-DjXZaTPq.js} +5 -5
- package/dist/client/chunks/{RetentionHeatmap-B24PiIfr.js.map → RetentionHeatmap-DjXZaTPq.js.map} +1 -1
- package/dist/client/chunks/analysis-builder-DB88FojM.js +5674 -0
- package/dist/client/chunks/analysis-builder-DB88FojM.js.map +1 -0
- package/dist/client/chunks/{analysis-builder-shared-x576-O5p.js → analysis-builder-shared-BVK4TYfR.js} +1578 -1292
- package/dist/client/chunks/analysis-builder-shared-BVK4TYfR.js.map +1 -0
- package/dist/client/chunks/{chart-activity-grid-CiHrLH6Y.js → chart-activity-grid-DX0SJbxs.js} +642 -494
- package/dist/client/chunks/chart-activity-grid-DX0SJbxs.js.map +1 -0
- package/dist/client/chunks/chart-area-of01_62R.js +775 -0
- package/dist/client/chunks/chart-area-of01_62R.js.map +1 -0
- package/dist/client/chunks/chart-bar-BqelQE_I.js +194 -0
- package/dist/client/chunks/chart-bar-BqelQE_I.js.map +1 -0
- package/dist/client/chunks/{chart-box-plot-Bu9hy-17.js → chart-box-plot-kkBixZ27.js} +2 -2
- package/dist/client/chunks/{chart-box-plot-Bu9hy-17.js.map → chart-box-plot-kkBixZ27.js.map} +1 -1
- package/dist/client/chunks/chart-bubble-B2he1--4.js +221 -0
- package/dist/client/chunks/chart-bubble-B2he1--4.js.map +1 -0
- package/dist/client/chunks/{chart-candlestick-Dau5AF4E.js → chart-candlestick-DZp19Tzh.js} +2 -2
- package/dist/client/chunks/{chart-candlestick-Dau5AF4E.js.map → chart-candlestick-DZp19Tzh.js.map} +1 -1
- package/dist/client/chunks/chart-config-area-BNigHUy8.js +124 -0
- package/dist/client/chunks/chart-config-area-BNigHUy8.js.map +1 -0
- package/dist/client/chunks/chart-config-bar-DSO_LRTx.js +54 -0
- package/dist/client/chunks/chart-config-bar-DSO_LRTx.js.map +1 -0
- package/dist/client/chunks/{chart-config-box-plot-DJ-dWWXA.js → chart-config-box-plot-oW8axV2q.js} +5 -10
- package/dist/client/chunks/chart-config-box-plot-oW8axV2q.js.map +1 -0
- package/dist/client/chunks/{chart-config-gauge-DSwC04l0.js → chart-config-gauge-Dq-_H9UN.js} +5 -7
- package/dist/client/chunks/chart-config-gauge-Dq-_H9UN.js.map +1 -0
- package/dist/client/chunks/{chart-config-kpi-delta-D6BIkHL3.js → chart-config-kpi-delta-DSQbvqu_.js} +5 -10
- package/dist/client/chunks/chart-config-kpi-delta-DSQbvqu_.js.map +1 -0
- package/dist/client/chunks/{chart-config-kpi-number-Bx-V9a62.js → chart-config-kpi-number-EFSWY1We.js} +5 -7
- package/dist/client/chunks/chart-config-kpi-number-EFSWY1We.js.map +1 -0
- package/dist/client/chunks/{chart-config-kpi-text-CcqC1u-8.js → chart-config-kpi-text-KM3V5X2u.js} +5 -7
- package/dist/client/chunks/chart-config-kpi-text-KM3V5X2u.js.map +1 -0
- package/dist/client/chunks/{chart-config-line-Db3jDsWc.js → chart-config-line-D6jG8PCH.js} +9 -36
- package/dist/client/chunks/chart-config-line-D6jG8PCH.js.map +1 -0
- package/dist/client/chunks/{chart-config-pie-DD4SmRTF.js → chart-config-pie-BhzW-fdn.js} +6 -16
- package/dist/client/chunks/chart-config-pie-BhzW-fdn.js.map +1 -0
- package/dist/client/chunks/{chart-config-radar-CC2XAaGr.js → chart-config-radar-D7REP1q_.js} +6 -16
- package/dist/client/chunks/chart-config-radar-D7REP1q_.js.map +1 -0
- package/dist/client/chunks/{chart-config-radial-bar-DmxKx1R0.js → chart-config-radial-bar-Byx6qOPU.js} +6 -16
- package/dist/client/chunks/chart-config-radial-bar-Byx6qOPU.js.map +1 -0
- package/dist/client/chunks/{chart-config-tree-map-BI-oQStO.js → chart-config-tree-map-DVrvf3yQ.js} +6 -16
- package/dist/client/chunks/chart-config-tree-map-DVrvf3yQ.js.map +1 -0
- package/dist/client/chunks/{chart-config-waterfall-DSnyixbI.js → chart-config-waterfall-DmFeQdIk.js} +5 -10
- package/dist/client/chunks/chart-config-waterfall-DmFeQdIk.js.map +1 -0
- package/dist/client/chunks/{chart-data-table-Cm5jrpaw.js → chart-data-table-CKauQXme.js} +1046 -1121
- package/dist/client/chunks/chart-data-table-CKauQXme.js.map +1 -0
- package/dist/client/chunks/{chart-funnel-Eke8IPtG.js → chart-funnel-CToKSBaL.js} +184 -222
- package/dist/client/chunks/chart-funnel-CToKSBaL.js.map +1 -0
- package/dist/client/chunks/chart-gauge-DTVezSk7.js +403 -0
- package/dist/client/chunks/chart-gauge-DTVezSk7.js.map +1 -0
- package/dist/client/chunks/chart-heat-map-DTuUl0BR.js +236 -0
- package/dist/client/chunks/chart-heat-map-DTuUl0BR.js.map +1 -0
- package/dist/client/chunks/chart-kpi-delta-Dn-jjO-2.js +408 -0
- package/dist/client/chunks/chart-kpi-delta-Dn-jjO-2.js.map +1 -0
- package/dist/client/chunks/chart-kpi-number-P_WBiO5S.js +244 -0
- package/dist/client/chunks/chart-kpi-number-P_WBiO5S.js.map +1 -0
- package/dist/client/chunks/chart-kpi-text-C-Y4eb5H.js +185 -0
- package/dist/client/chunks/chart-kpi-text-C-Y4eb5H.js.map +1 -0
- package/dist/client/chunks/chart-line-DKgrQA6c.js +101 -0
- package/dist/client/chunks/chart-line-DKgrQA6c.js.map +1 -0
- package/dist/client/chunks/{chart-markdown-BPW-EAm9.js → chart-markdown-CV75S_zL.js} +1359 -1240
- package/dist/client/chunks/chart-markdown-CV75S_zL.js.map +1 -0
- package/dist/client/chunks/{chart-measure-profile-BI3kADCp.js → chart-measure-profile-Ket8fJyf.js} +7 -7
- package/dist/client/chunks/{chart-measure-profile-BI3kADCp.js.map → chart-measure-profile-Ket8fJyf.js.map} +1 -1
- package/dist/client/chunks/chart-pie-ByieAX5H.js +119 -0
- package/dist/client/chunks/chart-pie-ByieAX5H.js.map +1 -0
- package/dist/client/chunks/chart-radar-CiSwHWp4.js +138 -0
- package/dist/client/chunks/chart-radar-CiSwHWp4.js.map +1 -0
- package/dist/client/chunks/chart-radial-bar-BF6Mhl6f.js +122 -0
- package/dist/client/chunks/chart-radial-bar-BF6Mhl6f.js.map +1 -0
- package/dist/client/chunks/{chart-sankey-CFzjGvZX.js → chart-sankey-DjrvKw6K.js} +36 -39
- package/dist/client/chunks/{chart-sankey-CFzjGvZX.js.map → chart-sankey-DjrvKw6K.js.map} +1 -1
- package/dist/client/chunks/chart-scatter-Dd9WFqnS.js +258 -0
- package/dist/client/chunks/chart-scatter-Dd9WFqnS.js.map +1 -0
- package/dist/client/chunks/{chart-sunburst-91Q2tzaB.js → chart-sunburst-leGpuDj7.js} +3 -3
- package/dist/client/chunks/{chart-sunburst-91Q2tzaB.js.map → chart-sunburst-leGpuDj7.js.map} +1 -1
- package/dist/client/chunks/chart-tree-map-Ceq5sLZA.js +323 -0
- package/dist/client/chunks/chart-tree-map-Ceq5sLZA.js.map +1 -0
- package/dist/client/chunks/{chart-waterfall-DcHbbPaG.js → chart-waterfall-DyvQReN5.js} +7 -7
- package/dist/client/chunks/{chart-waterfall-DcHbbPaG.js.map → chart-waterfall-DyvQReN5.js.map} +1 -1
- package/dist/client/chunks/{charts-core-CrBDYN6N.js → charts-core-DaXSt1Dd.js} +2 -2
- package/dist/client/chunks/{charts-core-CrBDYN6N.js.map → charts-core-DaXSt1Dd.js.map} +1 -1
- package/dist/client/chunks/charts-loader-DdTeCeNo.js +84 -0
- package/dist/client/chunks/charts-loader-DdTeCeNo.js.map +1 -0
- package/dist/client/chunks/{core-DsAWNRRv.js → core-D7vPfUIe.js} +2 -2
- package/dist/client/chunks/{core-DsAWNRRv.js.map → core-D7vPfUIe.js.map} +1 -1
- package/dist/client/chunks/{nl-NL-oyr2wENY.js → nl-NL-2zTAWTej.js} +8 -2
- package/dist/client/chunks/{nl-NL-oyr2wENY.js.map → nl-NL-2zTAWTej.js.map} +1 -1
- package/dist/client/chunks/retention-ChW9jYdy.js.map +1 -1
- package/dist/client/chunks/{schema-visualization-BszcrmZX.js → schema-visualization-Cb_E9_Gd.js} +12 -12
- package/dist/client/chunks/{schema-visualization-BszcrmZX.js.map → schema-visualization-Cb_E9_Gd.js.map} +1 -1
- package/dist/client/chunks/{useDirtyStateTracking-B5wCDJSj.js → useDirtyStateTracking-MbpxH_v6.js} +95 -84
- package/dist/client/chunks/useDirtyStateTracking-MbpxH_v6.js.map +1 -0
- package/dist/client/chunks/{useExplainAI-CCeCYzDm.js → useExplainAI-evnZkjCY.js} +14 -14
- package/dist/client/chunks/{useExplainAI-CCeCYzDm.js.map → useExplainAI-evnZkjCY.js.map} +1 -1
- package/dist/client/chunks/{utils-kqa-JIMg.js → utils-3P6z1vz5.js} +3 -3
- package/dist/client/chunks/{utils-kqa-JIMg.js.map → utils-3P6z1vz5.js.map} +1 -1
- package/dist/client/chunks/{vendor-0hJNlZXQ.js → vendor-DSpR0IW6.js} +43 -43
- package/dist/client/chunks/{vendor-0hJNlZXQ.js.map → vendor-DSpR0IW6.js.map} +1 -1
- package/dist/client/components/AgenticNotebook/agentChatParts.d.ts +34 -0
- package/dist/client/components/AgenticNotebook/chatMessageParts.d.ts +39 -0
- package/dist/client/components/AgenticNotebook/useAgentChatController.d.ts +25 -0
- package/dist/client/components/AgenticNotebook/useNotebookAutosave.d.ts +12 -0
- package/dist/client/components/AnalysisBuilder/AnalysisAIPanel.d.ts +1 -1
- package/dist/client/components/AnalysisBuilder/AnalysisAxisDropZone.d.ts +1 -1
- package/dist/client/components/AnalysisBuilder/AnalysisChartConfigPanel.d.ts +1 -1
- package/dist/client/components/AnalysisBuilder/AnalysisDisplayConfigPanel.d.ts +1 -1
- package/dist/client/components/AnalysisBuilder/AnalysisFilterGroup.d.ts +1 -1
- package/dist/client/components/AnalysisBuilder/AnalysisFilterItem.d.ts +1 -1
- package/dist/client/components/AnalysisBuilder/AnalysisFilterSection.d.ts +1 -1
- package/dist/client/components/AnalysisBuilder/AnalysisModeErrorBoundary.d.ts +1 -1
- package/dist/client/components/AnalysisBuilder/AnalysisQueryPanelParts.d.ts +64 -0
- package/dist/client/components/AnalysisBuilder/AnalysisResultsHeader.d.ts +67 -0
- package/dist/client/components/AnalysisBuilder/BreakdownComparisonToggle.d.ts +13 -0
- package/dist/client/components/AnalysisBuilder/BreakdownRow.d.ts +26 -0
- package/dist/client/components/AnalysisBuilder/DisplayOptionControl.d.ts +10 -0
- package/dist/client/components/AnalysisBuilder/ExecutionPlanPanelParts.d.ts +22 -0
- package/dist/client/components/AnalysisBuilder/ExplainAIPanel.d.ts +2 -1
- package/dist/client/components/AnalysisBuilder/FieldDetailPanel.d.ts +1 -1
- package/dist/client/components/AnalysisBuilder/FieldSearchItem.d.ts +1 -1
- package/dist/client/components/AnalysisBuilder/FieldSearchModal.d.ts +1 -1
- package/dist/client/components/AnalysisBuilder/FieldSearchResults.d.ts +16 -0
- package/dist/client/components/AnalysisBuilder/FilterConfigModal.d.ts +2 -1
- package/dist/client/components/AnalysisBuilder/FilterValueInput.d.ts +63 -0
- package/dist/client/components/AnalysisBuilder/FlowDepthControls.d.ts +10 -0
- package/dist/client/components/AnalysisBuilder/FlowVisualizationPicker.d.ts +7 -0
- package/dist/client/components/AnalysisBuilder/LegacyBooleanOptions.d.ts +8 -0
- package/dist/client/components/AnalysisBuilder/LimitSection.d.ts +1 -1
- package/dist/client/components/AnalysisBuilder/MetricRow.d.ts +23 -0
- package/dist/client/components/AnalysisBuilder/SectionHeading.d.ts +1 -1
- package/dist/client/components/AnalysisBuilder/SortToggleButton.d.ts +13 -0
- package/dist/client/components/AnalysisBuilder/StringArrayInput.d.ts +17 -0
- package/dist/client/components/AnalysisBuilder/filterConfigModalUtils.d.ts +30 -0
- package/dist/client/components/AnalysisBuilder/hooks/useAnalysisBuilderImperativeHandle.d.ts +13 -0
- package/dist/client/components/AnalysisBuilder/hooks/useDragReorder.d.ts +25 -0
- package/dist/client/components/AnalysisBuilder/hooks/useFieldSearchKeyboard.d.ts +11 -0
- package/dist/client/components/AnalysisBuilder/utils/axisConfigUtils.d.ts +23 -0
- package/dist/client/components/AnalysisBuilder/utils/executionPlanMarkdown.d.ts +8 -0
- package/dist/client/components/AnalysisBuilder/utils/fieldUtils.d.ts +5 -0
- package/dist/client/components/AnalysisBuilder/utils/resultsPanelDerive.d.ts +68 -0
- package/dist/client/components/AnalysisBuilder/utils/shareStateUtils.d.ts +68 -0
- package/dist/client/components/AnalysisBuilder/utils/sortUtils.d.ts +7 -0
- package/dist/client/components/AnalyticsDashboard.d.ts +1 -1
- package/dist/client/components/AnalyticsPage.d.ts +1 -1
- package/dist/client/components/ChartErrorBoundary.d.ts +1 -1
- package/dist/client/components/ChartTypeSelector.d.ts +1 -1
- package/dist/client/components/ColorPaletteSelector.d.ts +1 -1
- package/dist/client/components/DashboardEditModal.d.ts +2 -1
- package/dist/client/components/DashboardFilters/CompactFilterBarParts.d.ts +26 -0
- package/dist/client/components/DashboardFilters/DashboardFilterConfigModal.d.ts +1 -1
- package/dist/client/components/DashboardFilters/DashboardFilterConfigModalParts.d.ts +27 -0
- package/dist/client/components/DashboardFilters/DashboardFilterItem.d.ts +1 -1
- package/dist/client/components/DashboardFilters/DashboardFilterValueInput.d.ts +39 -0
- package/dist/client/components/DashboardFilters/dashboardFilterConfigModalUtils.d.ts +21 -0
- package/dist/client/components/DashboardFilters/useCompactFilterBar.d.ts +19 -0
- package/dist/client/components/DashboardFilters/useDashboardFilterConfigModal.d.ts +69 -0
- package/dist/client/components/DashboardFilters/useDateRangeState.d.ts +19 -0
- package/dist/client/components/DashboardFilters/useFilterDropdowns.d.ts +21 -0
- package/dist/client/components/DashboardFilters/useFilterValueFetch.d.ts +23 -0
- package/dist/client/components/DashboardGrid.d.ts +1 -1
- package/dist/client/components/DashboardPortletCard.d.ts +2 -57
- package/dist/client/components/DashboardThumbnailPlaceholder.d.ts +1 -1
- package/dist/client/components/DataBrowser/DataBrowserSidebar.d.ts +1 -1
- package/dist/client/components/DataBrowser/DataBrowserToolbar.d.ts +1 -1
- package/dist/client/components/DataBrowser/index.d.ts +1 -1
- package/dist/client/components/DataHistogram.d.ts +1 -1
- package/dist/client/components/DebugModal.d.ts +1 -1
- package/dist/client/components/DrillBreadcrumb.d.ts +2 -1
- package/dist/client/components/LoadingIndicator.d.ts +1 -1
- package/dist/client/components/MobileStackedLayout.d.ts +1 -1
- package/dist/client/components/PortletAnalysisModal.d.ts +1 -1
- package/dist/client/components/PortletContainer.d.ts +1 -1
- package/dist/client/components/PortletFilterConfigModal.d.ts +6 -4
- package/dist/client/components/RowManagedLayout.d.ts +1 -1
- package/dist/client/components/ScaledGridWrapper.d.ts +1 -1
- package/dist/client/components/SchemaVisualization/CubeNode.d.ts +1 -1
- package/dist/client/components/SchemaVisualization/FieldDetailPanel.d.ts +1 -1
- package/dist/client/components/SchemaVisualization/RelationshipEdge.d.ts +1 -1
- package/dist/client/components/SchemaVisualization/SchemaVisualizationLazy.d.ts +1 -1
- package/dist/client/components/SchemaVisualization/index.d.ts +1 -1
- package/dist/client/components/TextPortletModal.d.ts +1 -1
- package/dist/client/components/analyticsPortlet/PortletChart.d.ts +31 -0
- package/dist/client/components/analyticsPortlet/PortletChartView.d.ts +35 -0
- package/dist/client/components/analyticsPortlet/PortletStates.d.ts +65 -0
- package/dist/client/components/analyticsPortlet/parsePortletQuery.d.ts +22 -0
- package/dist/client/components/analyticsPortlet/portletRenderState.d.ts +31 -0
- package/dist/client/components/analyticsPortlet/usePortletDebugData.d.ts +37 -0
- package/dist/client/components/analyticsPortlet/usePortletDrillState.d.ts +17 -0
- package/dist/client/components/analyticsPortlet/usePortletQueryResults.d.ts +37 -0
- package/dist/client/components/charts/ActivityGridChart.helpers.d.ts +33 -0
- package/dist/client/components/charts/ActivityGridChart.render.d.ts +31 -0
- package/dist/client/components/charts/AxisFormatControls.d.ts +5 -3
- package/dist/client/components/charts/BarChart.helpers.d.ts +23 -0
- package/dist/client/components/charts/BarSeries.d.ts +29 -0
- package/dist/client/components/charts/BubbleChart.helpers.d.ts +43 -0
- package/dist/client/components/charts/BubbleChart.render.d.ts +21 -0
- package/dist/client/components/charts/ChartContainer.d.ts +1 -1
- package/dist/client/components/charts/ChartLegend.d.ts +1 -1
- package/dist/client/components/charts/ChartStates.d.ts +38 -0
- package/dist/client/components/charts/ChartTooltip.d.ts +1 -1
- package/dist/client/components/charts/FunnelChart.helpers.d.ts +25 -0
- package/dist/client/components/charts/FunnelViews.d.ts +16 -0
- package/dist/client/components/charts/HeatMapCanvas.d.ts +25 -0
- package/dist/client/components/charts/HeatMapChart.helpers.d.ts +64 -0
- package/dist/client/components/charts/KpiDelta.helpers.d.ts +20 -0
- package/dist/client/components/charts/KpiNumber.helpers.d.ts +30 -0
- package/dist/client/components/charts/KpiStates.d.ts +19 -0
- package/dist/client/components/charts/MissingDependencyFallback.d.ts +1 -1
- package/dist/client/components/charts/ScatterChart.helpers.d.ts +43 -0
- package/dist/client/components/charts/ScatterSeries.d.ts +17 -0
- package/dist/client/components/charts/ScatterTooltip.d.ts +21 -0
- package/dist/client/components/charts/TreeMapChart.helpers.d.ts +37 -0
- package/dist/client/components/charts/TreeMapContent.d.ts +24 -0
- package/dist/client/components/charts/TreeMapLegend.d.ts +13 -0
- package/dist/client/components/charts/cartesianChartHelpers.d.ts +126 -0
- package/dist/client/components/charts/chartAxisResolution.d.ts +32 -0
- package/dist/client/components/charts/chartScaffolding.d.ts +77 -0
- package/dist/client/components/charts/gaugeChartHelpers.d.ts +36 -0
- package/dist/client/components/charts/kpiTextHelpers.d.ts +46 -0
- package/dist/client/components/charts/radarChartHelpers.d.ts +14 -0
- package/dist/client/components/charts/radialBarChartHelpers.d.ts +22 -0
- package/dist/client/components/charts/useChartDimensions.d.ts +20 -0
- package/dist/client/components/charts/useKpiDimensions.d.ts +30 -0
- package/dist/client/components/dashboard/DashboardContext.d.ts +2 -2
- package/dist/client/components/dashboard/DashboardCoordinator.d.ts +1 -1
- package/dist/client/components/dashboard/DashboardEditBar.d.ts +5 -0
- package/dist/client/components/dashboard/DashboardFilterBar.d.ts +1 -1
- package/dist/client/components/dashboard/DashboardGridSurface.d.ts +1 -1
- package/dist/client/components/dashboard/DashboardModals.d.ts +1 -1
- package/dist/client/components/dashboard/DashboardProvider.d.ts +1 -1
- package/dist/client/components/dashboard/DashboardToolbar.d.ts +1 -1
- package/dist/client/components/dashboard/LayoutModeToggle.d.ts +10 -0
- package/dist/client/components/dashboard/dashboardGridUtils.d.ts +1 -1
- package/dist/client/components/dashboardPortletCard/FilterFieldChip.d.ts +12 -0
- package/dist/client/components/dashboardPortletCard/PortletCardHeader.d.ts +43 -0
- package/dist/client/components/dashboardPortletCard/cardStyles.d.ts +33 -0
- package/dist/client/components/dashboardPortletCard/filterField.d.ts +12 -0
- package/dist/client/components/dashboardPortletCard/propsEqual.d.ts +55 -0
- package/dist/client/components/dashboardPortletCard/usePortletCardActions.d.ts +16 -0
- package/dist/client/components/portletAnalysisModal/saveValidation.d.ts +8 -0
- package/dist/client/components/shared/dateRangeUtils.d.ts +40 -0
- package/dist/client/components/shared/filterDisplayUtils.d.ts +10 -0
- package/dist/client/components/shared/filterItem/FilterDateRangeSelector.d.ts +17 -0
- package/dist/client/components/shared/filterItem/FilterFieldDropdown.d.ts +16 -0
- package/dist/client/components/shared/filterItem/dateRangeSync.d.ts +14 -0
- package/dist/client/components/shared/filterItem/fieldVisuals.d.ts +5 -0
- package/dist/client/components/shared/filterValueSelector/FilterValueInputs.d.ts +55 -0
- package/dist/client/components/shared/filterValueSelector/useFilterValueSelectorState.d.ts +25 -0
- package/dist/client/components/shared/queryFieldUtils.d.ts +21 -0
- package/dist/client/components/shared/utils.d.ts +4 -43
- package/dist/client/components.js +3 -3
- package/dist/client/hooks/agentChatStream.d.ts +39 -0
- package/dist/client/hooks/analysisQueryExecutionModes.d.ts +133 -0
- package/dist/client/hooks/dashboard/useDashboardController.d.ts +2 -2
- package/dist/client/hooks/drillNavigation.d.ts +25 -0
- package/dist/client/hooks/useDashboardHook.d.ts +2 -2
- package/dist/client/hooks.js +3 -3
- package/dist/client/icons.d.ts +1 -1
- package/dist/client/icons.js +2 -2
- package/dist/client/index.js +816 -669
- package/dist/client/index.js.map +1 -1
- package/dist/client/providers/CubeApiProvider.d.ts +1 -1
- package/dist/client/providers/CubeFeaturesProvider.d.ts +1 -1
- package/dist/client/providers/CubeMetaProvider.d.ts +1 -1
- package/dist/client/providers/CubeProvider.d.ts +1 -1
- package/dist/client/providers/I18nProvider.d.ts +1 -1
- package/dist/client/providers.js +3 -3
- package/dist/client/schema.js +1 -1
- package/dist/client/shared/chartConfigBuilders.d.ts +18 -0
- package/dist/client/shared/components/QueryAnalysisPanel.sections.d.ts +41 -0
- package/dist/client/shared/queryTransforms.d.ts +20 -0
- package/dist/client/shared/utils.d.ts +2 -4
- package/dist/client/stores/analysisBuilderStore.d.ts +1 -1
- package/dist/client/stores/dashboardStore.d.ts +1 -1
- package/dist/client/stores/dataBrowserStore.d.ts +1 -1
- package/dist/client/stores/notebookStore.d.ts +1 -1
- package/dist/client/stores/optionsToAnalysisConfig.d.ts +17 -0
- package/dist/client/styles.css +1 -1
- package/dist/client/types/drill.d.ts +1 -1
- package/dist/client/types.d.ts +7 -2
- package/dist/client/utils/axisValueFormatting.d.ts +32 -0
- package/dist/client/utils/drillQueryBuilder.d.ts +2 -2
- package/dist/client/utils/filterUtils.d.ts +33 -5
- package/dist/client/utils/joinReachability.d.ts +27 -0
- package/dist/client/utils/timeValueFormatting.d.ts +32 -0
- package/dist/client/utils.js +6 -6
- package/dist/client-bundle-stats.html +1 -1
- package/dist/mcp-app/mcp-app.html +55 -55
- package/dist/server/google-BOnRIN1w.cjs +2 -0
- package/dist/{adapters/google-CFYljAOF.js → server/google-CvKM9yVM.js} +83 -71
- package/dist/server/index.cjs +179 -211
- package/dist/server/index.d.ts +2 -5050
- package/dist/server/index.js +6360 -6462
- package/dist/{adapters/openai-y7GhJNdn.js → server/openai-B5jEiqiB.js} +776 -719
- package/dist/server/openai-D0musiYP.cjs +17 -0
- package/dist/{adapters/openai-DiVskd89.js → server/openai-cDlFSTk6.js} +61 -59
- package/dist/server/openai-vXvLni8v.cjs +1 -0
- package/dist/server/server/adapters/base-adapter.d.ts +332 -0
- package/dist/server/server/adapters/databend-adapter.d.ts +63 -0
- package/dist/server/server/adapters/duckdb-adapter.d.ts +68 -0
- package/dist/server/server/adapters/mysql-adapter.d.ts +65 -0
- package/dist/server/server/adapters/postgres-adapter.d.ts +55 -0
- package/dist/server/server/adapters/singlestore-adapter.d.ts +4 -0
- package/dist/server/server/adapters/snowflake-adapter.d.ts +53 -0
- package/dist/server/server/adapters/sqlite-adapter.d.ts +120 -0
- package/dist/server/server/adapters/window-function-builder.d.ts +11 -0
- package/dist/server/server/agent/chart-validation.d.ts +22 -0
- package/dist/server/server/agent/handler-steps.d.ts +37 -0
- package/dist/server/server/agent/handler.d.ts +25 -0
- package/dist/server/server/agent/index.d.ts +11 -0
- package/dist/server/server/agent/providers/anthropic.d.ts +24 -0
- package/dist/server/server/agent/providers/factory.d.ts +12 -0
- package/dist/server/server/agent/providers/google.d.ts +23 -0
- package/dist/server/server/agent/providers/index.d.ts +6 -0
- package/dist/server/server/agent/providers/openai.d.ts +26 -0
- package/dist/server/server/agent/providers/types.d.ts +95 -0
- package/dist/server/server/agent/system-prompt.d.ts +5 -0
- package/dist/server/server/agent/tools.d.ts +28 -0
- package/dist/server/server/agent/types.d.ts +192 -0
- package/dist/server/server/ai/discovery-helpers.d.ts +29 -0
- package/dist/server/server/ai/discovery.d.ts +66 -0
- package/dist/server/server/ai/index.d.ts +10 -0
- package/dist/server/server/ai/mcp-prompts.d.ts +83 -0
- package/dist/server/server/ai/query-schema.d.ts +258 -0
- package/dist/server/server/ai/schemas.d.ts +63 -0
- package/dist/server/server/ai/suggestion-helpers.d.ts +33 -0
- package/dist/server/server/ai/suggestion.d.ts +16 -0
- package/dist/server/server/ai/validation-helpers.d.ts +21 -0
- package/dist/server/server/ai/validation.d.ts +31 -0
- package/dist/server/server/builders/analysis-utils.d.ts +106 -0
- package/dist/server/server/builders/comparison-query-builder.d.ts +70 -0
- package/dist/server/server/builders/cte-builder.d.ts +108 -0
- package/dist/server/server/builders/date-time-builder.d.ts +34 -0
- package/dist/server/server/builders/date-time-helpers.d.ts +34 -0
- package/dist/server/server/builders/filter-builder.d.ts +25 -0
- package/dist/server/server/builders/filter-operators.d.ts +23 -0
- package/dist/server/server/builders/flow-query-builder.d.ts +136 -0
- package/dist/server/server/builders/funnel-query-builder.d.ts +145 -0
- package/dist/server/server/builders/group-by-builder.d.ts +38 -0
- package/dist/server/server/builders/index.d.ts +13 -0
- package/dist/server/server/builders/measure-builder.d.ts +185 -0
- package/dist/server/server/builders/retention-query-builder.d.ts +98 -0
- package/dist/server/server/cache-providers/index.d.ts +5 -0
- package/dist/server/server/cache-providers/memory.d.ts +105 -0
- package/dist/server/server/cache-utils.d.ts +85 -0
- package/dist/server/server/compiler-metadata.d.ts +11 -0
- package/dist/server/server/compiler.d.ts +212 -0
- package/dist/server/server/cube-utils.d.ts +158 -0
- package/dist/server/server/database-utils.d.ts +18 -0
- package/dist/server/server/execution/annotation-builder.d.ts +12 -0
- package/dist/server/server/execution/filter-cache-preloader.d.ts +19 -0
- package/dist/server/server/execution/mode-router.d.ts +25 -0
- package/dist/server/server/execution/query-result-cache.d.ts +21 -0
- package/dist/server/server/execution/result-post-processor.d.ts +10 -0
- package/dist/server/server/executor.d.ts +186 -0
- package/dist/server/server/executors/base-executor.d.ts +16 -0
- package/dist/server/server/executors/databend-executor.d.ts +33 -0
- package/dist/server/server/executors/duckdb-executor.d.ts +33 -0
- package/dist/server/server/executors/explain-utils.d.ts +28 -0
- package/dist/server/server/executors/index.d.ts +21 -0
- package/dist/server/server/executors/mysql-executor.d.ts +27 -0
- package/dist/server/server/executors/postgres-executor.d.ts +27 -0
- package/dist/server/server/executors/singlestore-executor.d.ts +9 -0
- package/dist/server/server/executors/snowflake-executor.d.ts +33 -0
- package/dist/server/server/executors/sqlite-executor.d.ts +28 -0
- package/dist/server/server/explain/databend-parser.d.ts +16 -0
- package/dist/server/server/explain/duckdb-parser.d.ts +28 -0
- package/dist/server/server/explain/explain-tree.d.ts +20 -0
- package/dist/server/server/explain/index.d.ts +9 -0
- package/dist/server/server/explain/mysql-parser.d.ts +38 -0
- package/dist/server/server/explain/postgres-parser.d.ts +18 -0
- package/dist/server/server/explain/snowflake-parser.d.ts +17 -0
- package/dist/server/server/explain/sqlite-parser.d.ts +23 -0
- package/dist/server/server/filter-cache.d.ts +73 -0
- package/dist/server/server/gap-filler.d.ts +48 -0
- package/dist/server/server/index.d.ts +38 -0
- package/dist/server/server/logical-plan/cte-planner-helpers.d.ts +37 -0
- package/dist/server/server/logical-plan/cte-planner.d.ts +104 -0
- package/dist/server/server/logical-plan/filter-propagation.d.ts +44 -0
- package/dist/server/server/logical-plan/index.d.ts +19 -0
- package/dist/server/server/logical-plan/join-planner.d.ts +27 -0
- package/dist/server/server/logical-plan/logical-plan-builder.d.ts +58 -0
- package/dist/server/server/logical-plan/logical-planner.d.ts +39 -0
- package/dist/server/server/logical-plan/optimiser.d.ts +34 -0
- package/dist/server/server/logical-plan/plan-analysis-reporter.d.ts +59 -0
- package/dist/server/server/logical-plan/planner-utils.d.ts +20 -0
- package/dist/server/server/logical-plan/types.d.ts +199 -0
- package/dist/server/server/measure-classification.d.ts +40 -0
- package/dist/server/server/physical-plan/drizzle-plan-builder.d.ts +50 -0
- package/dist/server/server/physical-plan/drizzle-sql-builder.d.ts +118 -0
- package/dist/server/server/physical-plan/index.d.ts +2 -0
- package/dist/server/server/physical-plan/processors/cte-processor.d.ts +6 -0
- package/dist/server/server/physical-plan/processors/index.d.ts +8 -0
- package/dist/server/server/physical-plan/processors/joins-processor.d.ts +6 -0
- package/dist/server/server/physical-plan/processors/keys-dedup-processor.d.ts +13 -0
- package/dist/server/server/physical-plan/processors/multi-fact-processor.d.ts +13 -0
- package/dist/server/server/physical-plan/processors/predicates-processor.d.ts +6 -0
- package/dist/server/server/physical-plan/processors/selection-processor.d.ts +6 -0
- package/dist/server/server/physical-plan/processors/shared.d.ts +38 -0
- package/dist/server/server/physical-plan/processors/window-processor.d.ts +6 -0
- package/dist/server/server/prompts/explain-analysis-prompt.d.ts +47 -0
- package/dist/server/server/prompts/index.d.ts +27 -0
- package/dist/server/server/prompts/single-step-prompt.d.ts +31 -0
- package/dist/server/server/prompts/step0-validation-prompt.d.ts +39 -0
- package/dist/server/server/prompts/step1-shape-prompt.d.ts +29 -0
- package/dist/server/server/prompts/step2-complete-prompt.d.ts +19 -0
- package/dist/server/server/prompts/types.d.ts +37 -0
- package/dist/server/server/query-handlers.d.ts +79 -0
- package/dist/server/server/query-modes.d.ts +28 -0
- package/dist/server/server/query-validator.d.ts +9 -0
- package/dist/server/server/resolvers/calculated-measure-resolver.d.ts +98 -0
- package/dist/server/server/resolvers/index.d.ts +6 -0
- package/dist/server/server/resolvers/join-path-resolver.d.ts +158 -0
- package/dist/server/server/sql-format.d.ts +11 -0
- package/dist/server/server/template-substitution.d.ts +57 -0
- package/dist/server/server/types/analysis.d.ts +189 -0
- package/dist/server/server/types/cache.d.ts +132 -0
- package/dist/server/server/types/core.d.ts +164 -0
- package/dist/server/server/types/cube.d.ts +544 -0
- package/dist/server/server/types/executor.d.ts +156 -0
- package/dist/server/server/types/flow.d.ts +144 -0
- package/dist/server/server/types/funnel.d.ts +118 -0
- package/dist/server/server/types/index.d.ts +11 -0
- package/dist/server/server/types/metadata.d.ts +113 -0
- package/dist/server/server/types/query.d.ts +153 -0
- package/dist/server/server/types/retention.d.ts +141 -0
- package/dist/server/server/types/utils.d.ts +11 -0
- package/dist/server/server/types/validation.d.ts +14 -0
- package/package.json +15 -8
- package/dist/adapters/google-DUlXeeDA.cjs +0 -2
- package/dist/adapters/handler-C63rJUUK.cjs +0 -25
- package/dist/adapters/locale-CTNwPVZI.cjs +0 -198
- package/dist/adapters/locale-gU_d1Wja.js +0 -8249
- package/dist/adapters/mcp-transport-C4J4SAcn.cjs +0 -40
- package/dist/adapters/mcp-transport-CVUiifEc.js +0 -579
- package/dist/adapters/openai-6wrBvAnv.cjs +0 -1
- package/dist/adapters/openai-BDwb2u7y.cjs +0 -17
- package/dist/adapters/utils-CkEkU8Bo.cjs +0 -128
- package/dist/client/chunks/DashboardEditModal-6KRE36mm.js.map +0 -1
- package/dist/client/chunks/analysis-builder-shared-x576-O5p.js.map +0 -1
- package/dist/client/chunks/analysis-builder-zd48FVJO.js +0 -5367
- package/dist/client/chunks/analysis-builder-zd48FVJO.js.map +0 -1
- package/dist/client/chunks/chart-activity-grid-CiHrLH6Y.js.map +0 -1
- package/dist/client/chunks/chart-area-CXFK-Grv.js +0 -450
- package/dist/client/chunks/chart-area-CXFK-Grv.js.map +0 -1
- package/dist/client/chunks/chart-bar-DKXfLoGG.js +0 -271
- package/dist/client/chunks/chart-bar-DKXfLoGG.js.map +0 -1
- package/dist/client/chunks/chart-bubble-DGkTQlxM.js +0 -273
- package/dist/client/chunks/chart-bubble-DGkTQlxM.js.map +0 -1
- package/dist/client/chunks/chart-config-area-Bq_UsW3x.js +0 -101
- package/dist/client/chunks/chart-config-area-Bq_UsW3x.js.map +0 -1
- package/dist/client/chunks/chart-config-bar-_JEGZnAu.js +0 -95
- package/dist/client/chunks/chart-config-bar-_JEGZnAu.js.map +0 -1
- package/dist/client/chunks/chart-config-box-plot-DJ-dWWXA.js.map +0 -1
- package/dist/client/chunks/chart-config-gauge-DSwC04l0.js.map +0 -1
- package/dist/client/chunks/chart-config-kpi-delta-D6BIkHL3.js.map +0 -1
- package/dist/client/chunks/chart-config-kpi-number-Bx-V9a62.js.map +0 -1
- package/dist/client/chunks/chart-config-kpi-text-CcqC1u-8.js.map +0 -1
- package/dist/client/chunks/chart-config-line-Db3jDsWc.js.map +0 -1
- package/dist/client/chunks/chart-config-pie-DD4SmRTF.js.map +0 -1
- package/dist/client/chunks/chart-config-radar-CC2XAaGr.js.map +0 -1
- package/dist/client/chunks/chart-config-radial-bar-DmxKx1R0.js.map +0 -1
- package/dist/client/chunks/chart-config-tree-map-BI-oQStO.js.map +0 -1
- package/dist/client/chunks/chart-config-waterfall-DSnyixbI.js.map +0 -1
- package/dist/client/chunks/chart-data-table-Cm5jrpaw.js.map +0 -1
- package/dist/client/chunks/chart-funnel-Eke8IPtG.js.map +0 -1
- package/dist/client/chunks/chart-gauge-DeRZNsyl.js +0 -424
- package/dist/client/chunks/chart-gauge-DeRZNsyl.js.map +0 -1
- package/dist/client/chunks/chart-heat-map-C86thSJ4.js +0 -231
- package/dist/client/chunks/chart-heat-map-C86thSJ4.js.map +0 -1
- package/dist/client/chunks/chart-kpi-delta-CxOYD2f1.js +0 -343
- package/dist/client/chunks/chart-kpi-delta-CxOYD2f1.js.map +0 -1
- package/dist/client/chunks/chart-kpi-number-C6gWz-x4.js +0 -322
- package/dist/client/chunks/chart-kpi-number-C6gWz-x4.js.map +0 -1
- package/dist/client/chunks/chart-kpi-text-dDONrhS-.js +0 -149
- package/dist/client/chunks/chart-kpi-text-dDONrhS-.js.map +0 -1
- package/dist/client/chunks/chart-line-r4iWevKZ.js +0 -433
- package/dist/client/chunks/chart-line-r4iWevKZ.js.map +0 -1
- package/dist/client/chunks/chart-markdown-BPW-EAm9.js.map +0 -1
- package/dist/client/chunks/chart-pie-yqH2YVEI.js +0 -172
- package/dist/client/chunks/chart-pie-yqH2YVEI.js.map +0 -1
- package/dist/client/chunks/chart-radar-B-_3v-rE.js +0 -154
- package/dist/client/chunks/chart-radar-B-_3v-rE.js.map +0 -1
- package/dist/client/chunks/chart-radial-bar-C0EgzfAF.js +0 -148
- package/dist/client/chunks/chart-radial-bar-C0EgzfAF.js.map +0 -1
- package/dist/client/chunks/chart-scatter-DZPirzwX.js +0 -255
- package/dist/client/chunks/chart-scatter-DZPirzwX.js.map +0 -1
- package/dist/client/chunks/chart-tree-map-Bi4axCvh.js +0 -298
- package/dist/client/chunks/chart-tree-map-Bi4axCvh.js.map +0 -1
- package/dist/client/chunks/useDirtyStateTracking-B5wCDJSj.js.map +0 -1
- package/dist/server/google-DUlXeeDA.cjs +0 -2
- package/dist/server/openai-6wrBvAnv.cjs +0 -1
- package/dist/server/openai-BDwb2u7y.cjs +0 -17
- /package/dist/adapters/{express → adapters/express}/index.d.ts +0 -0
- /package/dist/adapters/{fastify → adapters/fastify}/index.d.ts +0 -0
- /package/dist/adapters/{hono → adapters/hono}/index.d.ts +0 -0
- /package/dist/adapters/{locale.d.ts → adapters/locale.d.ts} +0 -0
- /package/dist/adapters/{mcp-tools.d.ts → adapters/mcp-tools.d.ts} +0 -0
- /package/dist/adapters/{mcp-transport.d.ts → adapters/mcp-transport.d.ts} +0 -0
- /package/dist/adapters/{nextjs → adapters/nextjs}/index.d.ts +0 -0
- /package/dist/adapters/{types.d.ts → adapters/types.d.ts} +0 -0
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { DatabaseAdapter } from '../adapters/base-adapter';
|
|
2
|
+
import { FunnelQueryConfig, FunnelResultRow } from '../types/funnel';
|
|
3
|
+
import { Cube, QueryContext, SemanticQuery, AnalysisConfigValidationResult } from '../types';
|
|
4
|
+
export declare class FunnelQueryBuilder {
|
|
5
|
+
private databaseAdapter;
|
|
6
|
+
private filterBuilder;
|
|
7
|
+
private dateTimeBuilder;
|
|
8
|
+
constructor(databaseAdapter: DatabaseAdapter);
|
|
9
|
+
/**
|
|
10
|
+
* Check if query contains funnel configuration
|
|
11
|
+
*/
|
|
12
|
+
hasFunnel(query: SemanticQuery): boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Validate funnel configuration
|
|
15
|
+
*/
|
|
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;
|
|
25
|
+
/**
|
|
26
|
+
* Build complete funnel query using Drizzle's query builder pattern
|
|
27
|
+
*
|
|
28
|
+
* Uses the industry-standard "sequential CTEs" pattern where each step
|
|
29
|
+
* joins to the previous step CTE. This automatically enforces funnel
|
|
30
|
+
* constraints (monotonically decreasing counts).
|
|
31
|
+
*
|
|
32
|
+
* Returns a Drizzle query builder that supports .toSQL() for dry-run
|
|
33
|
+
* and can be executed directly for results.
|
|
34
|
+
*/
|
|
35
|
+
buildFunnelQuery(config: FunnelQueryConfig, cubes: Map<string, Cube>, context: QueryContext): ReturnType<typeof context.db.select>;
|
|
36
|
+
/**
|
|
37
|
+
* Transform raw SQL result to FunnelResultRow[]
|
|
38
|
+
*/
|
|
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;
|
|
42
|
+
/**
|
|
43
|
+
* Extract cube names referenced in step filters
|
|
44
|
+
*/
|
|
45
|
+
private extractFilterCubeNames;
|
|
46
|
+
/**
|
|
47
|
+
* Resolve steps with their cube, SQL expressions, and filter conditions
|
|
48
|
+
*/
|
|
49
|
+
private resolveSteps;
|
|
50
|
+
/**
|
|
51
|
+
* Resolve the cube for a step
|
|
52
|
+
*/
|
|
53
|
+
private resolveCubeForStep;
|
|
54
|
+
/**
|
|
55
|
+
* Resolve binding key expression for a cube
|
|
56
|
+
*/
|
|
57
|
+
private resolveBindingKey;
|
|
58
|
+
/**
|
|
59
|
+
* Resolve time dimension expression for a cube
|
|
60
|
+
*/
|
|
61
|
+
private resolveTimeDimension;
|
|
62
|
+
/**
|
|
63
|
+
* Build filter conditions for a step
|
|
64
|
+
* @param step - The funnel step
|
|
65
|
+
* @param baseCube - The step's primary cube
|
|
66
|
+
* @param cubes - All cubes available for cross-cube filtering
|
|
67
|
+
* @param context - Query context with security context
|
|
68
|
+
*/
|
|
69
|
+
private buildStepFilters;
|
|
70
|
+
/**
|
|
71
|
+
* Build a single filter condition
|
|
72
|
+
* @param filter - The filter to build
|
|
73
|
+
* @param baseCube - The step's primary cube
|
|
74
|
+
* @param cubes - All cubes available for cross-cube filtering
|
|
75
|
+
* @param context - Query context with security context
|
|
76
|
+
*/
|
|
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;
|
|
82
|
+
/**
|
|
83
|
+
* Build CTE for a single step using Drizzle's $with() pattern
|
|
84
|
+
*
|
|
85
|
+
* For step 0 (entry point): queries raw data directly
|
|
86
|
+
* For subsequent steps: joins to the previous step CTE to enforce sequential progression
|
|
87
|
+
*
|
|
88
|
+
* This implements the industry-standard "sequential CTEs" pattern where each step
|
|
89
|
+
* only includes binding_keys that successfully completed the previous step.
|
|
90
|
+
*
|
|
91
|
+
* @param step - The resolved step configuration
|
|
92
|
+
* @param context - Query context with security context
|
|
93
|
+
* @param previousStepCTE - Reference to the previous step's CTE (undefined for step 0)
|
|
94
|
+
*/
|
|
95
|
+
private buildStepCTE;
|
|
96
|
+
/**
|
|
97
|
+
* Build CTE for the first step (step 0) - entry point
|
|
98
|
+
*
|
|
99
|
+
* Queries raw data directly with security context and step filters.
|
|
100
|
+
* Gets the first occurrence per binding key.
|
|
101
|
+
*/
|
|
102
|
+
private buildFirstStepCTE;
|
|
103
|
+
/**
|
|
104
|
+
* Build CTE for subsequent steps (step 1+) - joins to previous step
|
|
105
|
+
*
|
|
106
|
+
* This is the key to the sequential funnel pattern:
|
|
107
|
+
* - INNER JOINs to the previous step CTE (only includes binding_keys that completed previous step)
|
|
108
|
+
* - Applies temporal constraints (must occur after previous step)
|
|
109
|
+
* - Applies step-specific filters and time-to-convert windows
|
|
110
|
+
*
|
|
111
|
+
* This automatically ensures monotonically decreasing counts.
|
|
112
|
+
*/
|
|
113
|
+
private buildSubsequentStepCTE;
|
|
114
|
+
/**
|
|
115
|
+
* Helper to add cross-cube JOINs to a step query
|
|
116
|
+
* Extracted to avoid duplication between first and subsequent step methods
|
|
117
|
+
*/
|
|
118
|
+
private addCrossJoinsToQuery;
|
|
119
|
+
/**
|
|
120
|
+
* Build funnel results CTE that joins all step times for time metric calculation
|
|
121
|
+
*
|
|
122
|
+
* With the sequential CTE pattern, each step CTE already contains only the
|
|
123
|
+
* binding_keys that successfully completed that step. This CTE simply joins
|
|
124
|
+
* them together to enable time difference calculations.
|
|
125
|
+
*
|
|
126
|
+
* No CASE expressions needed - the temporal filtering is already done in each step CTE.
|
|
127
|
+
*/
|
|
128
|
+
private buildFunnelResultsCTE;
|
|
129
|
+
/**
|
|
130
|
+
* Build aggregation CTE with counts and optional time metrics
|
|
131
|
+
*
|
|
132
|
+
* OPTIMIZATION: Uses single-pass aggregation over funnel_joined CTE instead of
|
|
133
|
+
* multiple scalar subqueries. This reduces table scans from 13+ to 1 for a typical
|
|
134
|
+
* 3-step funnel with time metrics.
|
|
135
|
+
*
|
|
136
|
+
* - Step counts: COUNT(*) for step_0, COUNT(step_N_time) for subsequent steps
|
|
137
|
+
* - Time metrics: Uses database-specific conditional aggregation (FILTER clause for
|
|
138
|
+
* PostgreSQL, CASE WHEN for MySQL/SQLite)
|
|
139
|
+
* - Percentiles: Still use subqueries since PERCENTILE_CONT with FILTER is non-standard
|
|
140
|
+
*
|
|
141
|
+
* Important: All SQL fields must have explicit aliases via .as() for Drizzle
|
|
142
|
+
* to properly reference them when selecting from the CTE
|
|
143
|
+
*/
|
|
144
|
+
private buildAggregationCTE;
|
|
145
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { SQL, AnyColumn } from 'drizzle-orm';
|
|
2
|
+
import { Cube, SemanticQuery, QueryContext, PhysicalQueryPlan } from '../types';
|
|
3
|
+
import { DateTimeBuilder } from './date-time-builder';
|
|
4
|
+
export declare class GroupByBuilder {
|
|
5
|
+
private dateTimeBuilder;
|
|
6
|
+
constructor(dateTimeBuilder: DateTimeBuilder);
|
|
7
|
+
/**
|
|
8
|
+
* Check if a measure type is a window function
|
|
9
|
+
*/
|
|
10
|
+
isWindowFunctionType(measureType: string): boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Check if a measure type is an aggregate function (requires GROUP BY)
|
|
13
|
+
*
|
|
14
|
+
* Note: 'number' is included because users commonly define measures with raw SQL
|
|
15
|
+
* aggregations (e.g., sql`COUNT(DISTINCT ...)`) and set type: 'number' for the output.
|
|
16
|
+
* These measures still require GROUP BY when used with time dimensions.
|
|
17
|
+
*/
|
|
18
|
+
isAggregateFunctionType(measureType: string): boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Build GROUP BY fields from dimensions and time dimensions
|
|
21
|
+
* Works for both single and multi-cube queries
|
|
22
|
+
*
|
|
23
|
+
* NOTE: GROUP BY is only added when there are AGGREGATE measures.
|
|
24
|
+
* Window functions do not require GROUP BY and operate on individual rows.
|
|
25
|
+
*/
|
|
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;
|
|
38
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Builders Index
|
|
3
|
+
* Re-exports all query builder components for modular imports
|
|
4
|
+
*/
|
|
5
|
+
export { DateTimeBuilder } from './date-time-builder';
|
|
6
|
+
export { FilterBuilder } from './filter-builder';
|
|
7
|
+
export { GroupByBuilder } from './group-by-builder';
|
|
8
|
+
export { MeasureBuilder } from './measure-builder';
|
|
9
|
+
export { CTEBuilder } from './cte-builder';
|
|
10
|
+
export { ComparisonQueryBuilder } from './comparison-query-builder';
|
|
11
|
+
export { FunnelQueryBuilder } from './funnel-query-builder';
|
|
12
|
+
export { FlowQueryBuilder } from './flow-query-builder';
|
|
13
|
+
export { RetentionQueryBuilder } from './retention-query-builder';
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import { SQL } from 'drizzle-orm';
|
|
2
|
+
import { Cube, QueryContext, PhysicalQueryPlan } from '../types';
|
|
3
|
+
import { DatabaseAdapter } from '../adapters/base-adapter';
|
|
4
|
+
import { ResolvedMeasures } from '../template-substitution';
|
|
5
|
+
export declare class MeasureBuilder {
|
|
6
|
+
private databaseAdapter;
|
|
7
|
+
constructor(databaseAdapter: DatabaseAdapter);
|
|
8
|
+
/**
|
|
9
|
+
* Build resolvedMeasures map for a set of measures
|
|
10
|
+
* This centralizes the logic for building both regular and calculated measures
|
|
11
|
+
* in dependency order, avoiding duplication across main queries and CTEs
|
|
12
|
+
*
|
|
13
|
+
* @param measureNames - Array of measure names to resolve (e.g., ["Employees.count", "Employees.activePercentage"])
|
|
14
|
+
* @param cubeMap - Map of all cubes involved in the query
|
|
15
|
+
* @param context - Query context with database and security context
|
|
16
|
+
* @param customMeasureBuilder - Optional function to override how individual measures are built
|
|
17
|
+
* @returns Map of measure names to SQL builder functions
|
|
18
|
+
*/
|
|
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;
|
|
31
|
+
/**
|
|
32
|
+
* Build calculated measure expression by substituting {member} references
|
|
33
|
+
* with resolved SQL expressions
|
|
34
|
+
*/
|
|
35
|
+
buildCalculatedMeasure(measure: any, cube: Cube, allCubes: Map<string, Cube>, resolvedMeasures: ResolvedMeasures, context: QueryContext): SQL;
|
|
36
|
+
/**
|
|
37
|
+
* Build resolved measures map for a calculated measure from CTE columns
|
|
38
|
+
* This handles re-aggregating pre-aggregated CTE columns for calculated measures
|
|
39
|
+
*
|
|
40
|
+
* IMPORTANT: For calculated measures in CTEs, we cannot sum/avg pre-computed ratios.
|
|
41
|
+
* We must recalculate from the base measures that were pre-aggregated in the CTE.
|
|
42
|
+
*
|
|
43
|
+
* @param measure - The calculated measure to build
|
|
44
|
+
* @param cube - The cube containing this measure
|
|
45
|
+
* @param cteInfo - CTE metadata (alias, measures, cube reference)
|
|
46
|
+
* @param allCubes - Map of all cubes in the query
|
|
47
|
+
* @param context - Query context
|
|
48
|
+
* @returns SQL expression for the calculated measure using CTE column references
|
|
49
|
+
*/
|
|
50
|
+
buildCTECalculatedMeasure(measure: any, cube: Cube, cteInfo: {
|
|
51
|
+
cteAlias: string;
|
|
52
|
+
measures: string[];
|
|
53
|
+
cube: Cube;
|
|
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;
|
|
64
|
+
/**
|
|
65
|
+
* Build measure expression for HAVING clause, handling CTE references correctly
|
|
66
|
+
*/
|
|
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;
|
|
70
|
+
/**
|
|
71
|
+
* Build measure expression with aggregation and filters
|
|
72
|
+
* Note: This should NOT be called for calculated measures
|
|
73
|
+
*
|
|
74
|
+
* @param measure - The measure definition
|
|
75
|
+
* @param context - Query context with security context and database info
|
|
76
|
+
* @param cube - Optional cube reference for resolving dimension references (window functions)
|
|
77
|
+
*/
|
|
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;
|
|
100
|
+
/**
|
|
101
|
+
* List of measure types that are window functions
|
|
102
|
+
* Window functions require special handling in CTEs:
|
|
103
|
+
* - No GROUP BY in the CTE
|
|
104
|
+
* - No re-aggregation in outer query
|
|
105
|
+
* - Return individual rows, not grouped results
|
|
106
|
+
*/
|
|
107
|
+
static WINDOW_FUNCTION_TYPES: readonly ["lag", "lead", "rank", "denseRank", "rowNumber", "ntile", "firstValue", "lastValue", "movingAvg", "movingSum"];
|
|
108
|
+
/**
|
|
109
|
+
* Check if a measure type is a window function
|
|
110
|
+
* @param measureType - The measure type string
|
|
111
|
+
* @returns true if this is a window function type
|
|
112
|
+
*/
|
|
113
|
+
static isWindowFunction(measureType: string): boolean;
|
|
114
|
+
/**
|
|
115
|
+
* Categorize measures into window functions and regular aggregates
|
|
116
|
+
* Used by query planner to create separate CTEs for each category
|
|
117
|
+
*
|
|
118
|
+
* @param measureNames - Array of measure names (e.g., ["Productivity.rank", "Productivity.totalLines"])
|
|
119
|
+
* @param cubeMap - Map of cubes to look up measure definitions
|
|
120
|
+
* @returns Object with windowMeasures and aggregateMeasures arrays
|
|
121
|
+
*/
|
|
122
|
+
static categorizeMeasures(measureNames: string[], cubeMap: Map<string, Cube>): {
|
|
123
|
+
windowMeasures: string[];
|
|
124
|
+
aggregateMeasures: string[];
|
|
125
|
+
};
|
|
126
|
+
/**
|
|
127
|
+
* Check if a query contains any window function measures
|
|
128
|
+
* @param measureNames - Array of measure names
|
|
129
|
+
* @param cubeMap - Map of cubes
|
|
130
|
+
* @returns true if any measure is a window function
|
|
131
|
+
*/
|
|
132
|
+
static hasWindowFunctions(measureNames: string[], cubeMap: Map<string, Cube>): boolean;
|
|
133
|
+
/**
|
|
134
|
+
* Check if a measure is a post-aggregation window function.
|
|
135
|
+
* Post-aggregation windows have a `measure` reference in their windowConfig,
|
|
136
|
+
* indicating they should operate on aggregated data rather than raw rows.
|
|
137
|
+
*
|
|
138
|
+
* @param measure - The measure definition
|
|
139
|
+
* @returns true if this is a post-aggregation window function
|
|
140
|
+
*/
|
|
141
|
+
static isPostAggregationWindow(measure: any): boolean;
|
|
142
|
+
/**
|
|
143
|
+
* Get the base measure reference for a post-aggregation window function.
|
|
144
|
+
* Resolves simple names (e.g., 'totalRevenue') to fully qualified names ('Sales.totalRevenue').
|
|
145
|
+
*
|
|
146
|
+
* @param measure - The measure definition
|
|
147
|
+
* @param cubeName - The name of the cube containing this measure
|
|
148
|
+
* @returns Fully qualified base measure name, or null if not a post-agg window
|
|
149
|
+
*/
|
|
150
|
+
static getWindowBaseMeasure(measure: any, cubeName: string): string | null;
|
|
151
|
+
/**
|
|
152
|
+
* Get the default operation for a window function type.
|
|
153
|
+
* - lag/lead default to 'difference' (compare current vs previous/next)
|
|
154
|
+
* - rank/rowNumber/ntile/firstValue/lastValue default to 'raw'
|
|
155
|
+
* - movingAvg/movingSum default to 'raw'
|
|
156
|
+
*
|
|
157
|
+
* @param windowType - The window function type
|
|
158
|
+
* @returns Default operation for the window type
|
|
159
|
+
*/
|
|
160
|
+
static getDefaultWindowOperation(windowType: string): 'raw' | 'difference' | 'ratio' | 'percentChange';
|
|
161
|
+
/**
|
|
162
|
+
* Categorize measures for post-aggregation window function handling.
|
|
163
|
+
* Separates measures into:
|
|
164
|
+
* - aggregateMeasures: Regular aggregates (count, sum, avg, etc.)
|
|
165
|
+
* - postAggWindowMeasures: Window functions that reference a base measure
|
|
166
|
+
* - requiredBaseMeasures: Base measures needed by window functions (auto-added to query)
|
|
167
|
+
*
|
|
168
|
+
* @param measureNames - Array of measure names from the query
|
|
169
|
+
* @param cubeMap - Map of cubes to look up measure definitions
|
|
170
|
+
* @returns Categorized measures with base measure dependencies
|
|
171
|
+
*/
|
|
172
|
+
static categorizeForPostAggregation(measureNames: string[], cubeMap: Map<string, Cube>): {
|
|
173
|
+
aggregateMeasures: string[];
|
|
174
|
+
postAggWindowMeasures: string[];
|
|
175
|
+
requiredBaseMeasures: Set<string>;
|
|
176
|
+
};
|
|
177
|
+
/**
|
|
178
|
+
* Check if any measures in the query are post-aggregation window functions.
|
|
179
|
+
*
|
|
180
|
+
* @param measureNames - Array of measure names
|
|
181
|
+
* @param cubeMap - Map of cubes
|
|
182
|
+
* @returns true if any measure is a post-aggregation window function
|
|
183
|
+
*/
|
|
184
|
+
static hasPostAggregationWindows(measureNames: string[], cubeMap: Map<string, Cube>): boolean;
|
|
185
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { DatabaseAdapter } from '../adapters/base-adapter';
|
|
2
|
+
import { RetentionQueryConfig, RetentionResultRow } from '../types/retention';
|
|
3
|
+
import { Cube, QueryContext, SemanticQuery, AnalysisConfigValidationResult } from '../types';
|
|
4
|
+
export declare class RetentionQueryBuilder {
|
|
5
|
+
private databaseAdapter;
|
|
6
|
+
private filterBuilder;
|
|
7
|
+
private dateTimeBuilder;
|
|
8
|
+
constructor(databaseAdapter: DatabaseAdapter);
|
|
9
|
+
/**
|
|
10
|
+
* Check if query contains retention configuration
|
|
11
|
+
*/
|
|
12
|
+
hasRetention(query: SemanticQuery): boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Validate retention configuration against registered cubes
|
|
15
|
+
*/
|
|
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;
|
|
27
|
+
/**
|
|
28
|
+
* Build the retention SQL query using CTEs
|
|
29
|
+
*
|
|
30
|
+
* CTE Structure (Simplified Mixpanel-style):
|
|
31
|
+
* 1. cohort_base - Users entering the cohort (first event in date range)
|
|
32
|
+
* - When breakdown is specified, includes breakdown_value
|
|
33
|
+
* 2. activity_periods - All activity with period_number relative to cohort entry
|
|
34
|
+
* 3. cohort_sizes - Aggregate cohort sizes (per breakdown value if applicable)
|
|
35
|
+
* 4. retention_counts - Retained users per period (and breakdown value)
|
|
36
|
+
* 5. Final SELECT - Join with retention rate calculation
|
|
37
|
+
*/
|
|
38
|
+
buildRetentionQuery(config: RetentionQueryConfig, cubes: Map<string, Cube>, context: QueryContext): any;
|
|
39
|
+
/**
|
|
40
|
+
* Transform raw SQL results to RetentionResultRow[]
|
|
41
|
+
*/
|
|
42
|
+
transformResult(rawResult: unknown[], config: RetentionQueryConfig): RetentionResultRow[];
|
|
43
|
+
/**
|
|
44
|
+
* Resolve retention configuration with SQL expressions
|
|
45
|
+
* Same cube/dimension used for both cohort entry and activity detection
|
|
46
|
+
*/
|
|
47
|
+
private resolveConfig;
|
|
48
|
+
/**
|
|
49
|
+
* Build filter conditions from config filters
|
|
50
|
+
*/
|
|
51
|
+
private buildFilterConditions;
|
|
52
|
+
/**
|
|
53
|
+
* Build a single filter condition
|
|
54
|
+
*/
|
|
55
|
+
private buildSingleFilterCondition;
|
|
56
|
+
/**
|
|
57
|
+
* Build cohort_base CTE
|
|
58
|
+
* Groups users by their first activity (cohort entry) within the date range.
|
|
59
|
+
* When breakdowns are specified, includes breakdown values for each dimension.
|
|
60
|
+
*/
|
|
61
|
+
private buildCohortBaseCTE;
|
|
62
|
+
/**
|
|
63
|
+
* Build date range condition for WHERE clause
|
|
64
|
+
* Filters records to those within the specified date range
|
|
65
|
+
*/
|
|
66
|
+
private buildDateRangeCondition;
|
|
67
|
+
/**
|
|
68
|
+
* Build date range condition for HAVING clause
|
|
69
|
+
* Used to filter aggregated cohort_period values
|
|
70
|
+
*/
|
|
71
|
+
private buildDateRangeHavingCondition;
|
|
72
|
+
/**
|
|
73
|
+
* Build activity_periods CTE
|
|
74
|
+
* Joins activity events to cohort_base and calculates period_number.
|
|
75
|
+
* Includes breakdown values from cohort_base when breakdowns are specified.
|
|
76
|
+
*/
|
|
77
|
+
private buildActivityPeriodsCTE;
|
|
78
|
+
/**
|
|
79
|
+
* Build cohort_sizes CTE
|
|
80
|
+
* Aggregates the size of the cohort (or per breakdown combination if specified).
|
|
81
|
+
*/
|
|
82
|
+
private buildCohortSizesCTE;
|
|
83
|
+
/**
|
|
84
|
+
* Build retention_counts CTE
|
|
85
|
+
* Aggregates retained users per period (and breakdown combination if specified).
|
|
86
|
+
*/
|
|
87
|
+
private buildRetentionCountsCTE;
|
|
88
|
+
/**
|
|
89
|
+
* Build rolling retention counts query
|
|
90
|
+
* For rolling retention, a user is retained in period N if they were active
|
|
91
|
+
* in period N or any later period
|
|
92
|
+
*/
|
|
93
|
+
private buildRollingRetentionCountsQuery;
|
|
94
|
+
/**
|
|
95
|
+
* Build period number expression using database-specific DATE_DIFF
|
|
96
|
+
*/
|
|
97
|
+
private buildPeriodNumberExpression;
|
|
98
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { CacheProvider, CacheGetResult } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Options for MemoryCacheProvider
|
|
4
|
+
*/
|
|
5
|
+
export interface MemoryCacheProviderOptions {
|
|
6
|
+
/**
|
|
7
|
+
* Default TTL in milliseconds
|
|
8
|
+
* @default 300000 (5 minutes)
|
|
9
|
+
*/
|
|
10
|
+
defaultTtlMs?: number;
|
|
11
|
+
/**
|
|
12
|
+
* Maximum number of entries in the cache
|
|
13
|
+
* When exceeded, oldest entries are evicted (LRU)
|
|
14
|
+
* @default undefined (unlimited)
|
|
15
|
+
*/
|
|
16
|
+
maxEntries?: number;
|
|
17
|
+
/**
|
|
18
|
+
* Interval in milliseconds to run automatic cleanup
|
|
19
|
+
* Set to 0 to disable automatic cleanup
|
|
20
|
+
* @default 60000 (1 minute)
|
|
21
|
+
*/
|
|
22
|
+
cleanupIntervalMs?: number;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Simple in-memory cache provider implementing the CacheProvider interface
|
|
26
|
+
*
|
|
27
|
+
* Features:
|
|
28
|
+
* - TTL support with automatic expiration on read
|
|
29
|
+
* - Optional automatic cleanup of expired entries
|
|
30
|
+
* - Optional max entries limit with LRU eviction
|
|
31
|
+
* - Full metadata support for TTL tracking
|
|
32
|
+
*
|
|
33
|
+
* Limitations:
|
|
34
|
+
* - Not shared across processes/instances
|
|
35
|
+
* - Data lost on process restart
|
|
36
|
+
* - Not suitable for distributed deployments
|
|
37
|
+
*/
|
|
38
|
+
export declare class MemoryCacheProvider implements CacheProvider {
|
|
39
|
+
private cache;
|
|
40
|
+
private defaultTtlMs;
|
|
41
|
+
private maxEntries?;
|
|
42
|
+
private cleanupIntervalId?;
|
|
43
|
+
private accessOrder;
|
|
44
|
+
constructor(options?: MemoryCacheProviderOptions);
|
|
45
|
+
/**
|
|
46
|
+
* Get a cached value by key
|
|
47
|
+
* Returns null if not found or expired
|
|
48
|
+
* Automatically removes expired entries on access
|
|
49
|
+
*/
|
|
50
|
+
get<T>(key: string): Promise<CacheGetResult<T> | null>;
|
|
51
|
+
/**
|
|
52
|
+
* Set a value in the cache
|
|
53
|
+
* Respects maxEntries limit with LRU eviction
|
|
54
|
+
*/
|
|
55
|
+
set<T>(key: string, value: T, ttlMs?: number): Promise<void>;
|
|
56
|
+
/**
|
|
57
|
+
* Delete a specific key from the cache
|
|
58
|
+
* Returns true if key existed and was deleted
|
|
59
|
+
*/
|
|
60
|
+
delete(key: string): Promise<boolean>;
|
|
61
|
+
/**
|
|
62
|
+
* Delete all keys matching a pattern
|
|
63
|
+
* Supports glob-style patterns with trailing '*'
|
|
64
|
+
* Returns number of keys deleted
|
|
65
|
+
*/
|
|
66
|
+
deletePattern(pattern: string): Promise<number>;
|
|
67
|
+
/**
|
|
68
|
+
* Check if a key exists in the cache
|
|
69
|
+
* Returns false for expired entries
|
|
70
|
+
*/
|
|
71
|
+
has(key: string): Promise<boolean>;
|
|
72
|
+
/**
|
|
73
|
+
* Stop automatic cleanup and clear the cache
|
|
74
|
+
* Call this when the cache provider is no longer needed
|
|
75
|
+
*/
|
|
76
|
+
close(): Promise<void>;
|
|
77
|
+
/**
|
|
78
|
+
* Remove all expired entries from the cache
|
|
79
|
+
* Called automatically by cleanup interval
|
|
80
|
+
* Can also be called manually
|
|
81
|
+
*
|
|
82
|
+
* @returns Number of entries removed
|
|
83
|
+
*/
|
|
84
|
+
cleanup(): number;
|
|
85
|
+
/**
|
|
86
|
+
* Get current cache size (number of entries)
|
|
87
|
+
* Note: May include expired entries that haven't been cleaned up yet
|
|
88
|
+
*/
|
|
89
|
+
size(): number;
|
|
90
|
+
/**
|
|
91
|
+
* Clear all entries from the cache
|
|
92
|
+
*/
|
|
93
|
+
clear(): void;
|
|
94
|
+
/**
|
|
95
|
+
* Get cache statistics
|
|
96
|
+
*/
|
|
97
|
+
stats(): {
|
|
98
|
+
size: number;
|
|
99
|
+
maxEntries?: number;
|
|
100
|
+
defaultTtlMs: number;
|
|
101
|
+
};
|
|
102
|
+
private touchAccessOrder;
|
|
103
|
+
private removeFromAccessOrder;
|
|
104
|
+
private evictOldest;
|
|
105
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { SemanticQuery, SecurityContext } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Configuration for cache key generation
|
|
4
|
+
*/
|
|
5
|
+
export interface CacheKeyConfig {
|
|
6
|
+
/** Prefix for all cache keys */
|
|
7
|
+
keyPrefix?: string;
|
|
8
|
+
/** Whether to include security context in cache key */
|
|
9
|
+
includeSecurityContext?: boolean;
|
|
10
|
+
/** Custom serializer for security context */
|
|
11
|
+
securityContextSerializer?: (ctx: SecurityContext) => string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Generate a deterministic cache key from query and security context
|
|
15
|
+
*
|
|
16
|
+
* Key structure: {prefix}query:{queryHash}:ctx:{securityHash}
|
|
17
|
+
*
|
|
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.
|
|
23
|
+
*
|
|
24
|
+
* @param query - The semantic query to cache
|
|
25
|
+
* @param securityContext - Security context for tenant isolation
|
|
26
|
+
* @param config - Cache key configuration
|
|
27
|
+
* @returns Deterministic cache key string
|
|
28
|
+
*/
|
|
29
|
+
export declare function generateCacheKey(query: SemanticQuery, securityContext: SecurityContext, config?: CacheKeyConfig): string;
|
|
30
|
+
/**
|
|
31
|
+
* Normalize query for consistent hashing
|
|
32
|
+
* Sorts arrays and object keys to ensure same query = same hash
|
|
33
|
+
*
|
|
34
|
+
* @param query - The semantic query to normalize
|
|
35
|
+
* @returns Normalized query with sorted arrays and keys
|
|
36
|
+
*/
|
|
37
|
+
export declare function normalizeQuery(query: SemanticQuery): SemanticQuery;
|
|
38
|
+
/**
|
|
39
|
+
* Recursively sort object keys for deterministic serialization
|
|
40
|
+
*
|
|
41
|
+
* @param obj - Object to sort
|
|
42
|
+
* @returns Object with sorted keys (recursively)
|
|
43
|
+
*/
|
|
44
|
+
export declare function sortObject<T>(obj: T): T;
|
|
45
|
+
/**
|
|
46
|
+
* FNV-1a hash - fast, non-cryptographic 32-bit hash function
|
|
47
|
+
* Returns hex string for cache key readability
|
|
48
|
+
*
|
|
49
|
+
* Properties:
|
|
50
|
+
* - O(n) time complexity
|
|
51
|
+
* - Low collision rate for similar strings
|
|
52
|
+
* - Deterministic across runs
|
|
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
|
+
*
|
|
57
|
+
* @param str - String to hash
|
|
58
|
+
* @returns 8-character hex string
|
|
59
|
+
*/
|
|
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;
|
|
77
|
+
/**
|
|
78
|
+
* Generate invalidation pattern for a cube
|
|
79
|
+
* Used when cube data changes and all related cache entries need clearing
|
|
80
|
+
*
|
|
81
|
+
* @param cubeName - Name of the cube to invalidate
|
|
82
|
+
* @param keyPrefix - Cache key prefix
|
|
83
|
+
* @returns Glob pattern for cache invalidation
|
|
84
|
+
*/
|
|
85
|
+
export declare function getCubeInvalidationPattern(cubeName: string, keyPrefix?: string): string;
|