UNPKG

drizzle-cube

Version:

Drizzle ORM-first semantic layer with Cube.js compatibility. Type-safe analytics and dashboards with SQL injection protection.

97 lines (96 loc) 4.03 kB
import { DebugDataEntry, FunnelDebugDataEntry, FlowDebugDataEntry } from './queries'; import { CubeQuery, MultiQueryConfig, FunnelBindingKey, QueryMergeStrategy, AnalysisType } from '../types'; import { ExecutionStatus } from '../components/AnalysisBuilder/types'; import { ServerFunnelQuery } from '../types/funnel'; import { ServerFlowQuery, FlowChartData } from '../types/flow'; export interface UseAnalysisQueryExecutionOptions { /** Current query (for single-query mode) */ currentQuery: CubeQuery; /** All queries (for dry-run and multi-query) */ allQueries: CubeQuery[]; /** Multi-query config (null if single-query mode) */ multiQueryConfig: MultiQueryConfig | null; /** Whether in multi-query mode */ isMultiQueryMode: boolean; /** Whether current query is valid */ isValidQuery: boolean; /** Initial data (skip first fetch) */ initialData?: unknown[]; /** Merge strategy (for detecting funnel mode - legacy) */ mergeStrategy?: QueryMergeStrategy; /** Funnel binding key (required for funnel mode) */ funnelBindingKey?: FunnelBindingKey | null; /** * Whether funnel mode is properly configured (from store). * This includes filter-only step validation that isMultiQueryMode doesn't provide. * @deprecated Use analysisType === 'funnel' instead */ isFunnelModeEnabled?: boolean; /** * Analysis type for explicit mode routing. * When provided, takes precedence over legacy mode detection. */ analysisType?: AnalysisType; /** * Pre-built server funnel query from store's buildFunnelQueryFromSteps(). * Used when analysisType === 'funnel' with the new dedicated funnel state. */ serverFunnelQuery?: ServerFunnelQuery | null; /** * Pre-built server flow query from store's buildFlowQuery(). * Used when analysisType === 'flow' with the new dedicated flow state. */ serverFlowQuery?: ServerFlowQuery | null; } export interface UseAnalysisQueryExecutionResult { /** Query execution status */ executionStatus: ExecutionStatus; /** Query results (merged for multi-query) */ executionResults: unknown[] | null; /** Per-query results (for table view in multi-query mode) */ perQueryResults: (unknown[] | null)[] | null; /** Whether query is loading */ isLoading: boolean; /** Whether query is fetching (includes refetch) */ isFetching: boolean; /** Query error */ error: Error | null; /** Debug data per query (for non-funnel modes) */ debugDataPerQuery: DebugDataEntry[]; /** Whether query has been debounced (for smart defaults trigger) */ hasDebounced: boolean; /** Refetch function */ refetch: () => void; /** * In funnel mode, these are the actually executed queries with: * - Binding key dimension auto-added * - IN filter applied for steps 2+ * Use these for debug display instead of the original queries. * @deprecated Server-side funnel uses a unified query. Use funnelServerQuery instead. */ funnelExecutedQueries: CubeQuery[] | null; /** * The actual server funnel query { funnel: {...} } * This is the unified query sent to the server (not per-step queries). */ funnelServerQuery: ServerFunnelQuery | null; /** * Debug data specifically for funnel mode * Contains the funnel SQL and funnel-specific metadata */ funnelDebugData: FunnelDebugDataEntry | null; /** * The server flow query being executed (when analysisType === 'flow') */ flowServerQuery: ServerFlowQuery | null; /** * Flow chart data (nodes and links for Sankey visualization) */ flowChartData: FlowChartData | null; /** * Debug data specifically for flow mode * Contains the flow SQL and flow-specific metadata */ flowDebugData: FlowDebugDataEntry | null; } export declare function useAnalysisQueryExecution(options: UseAnalysisQueryExecutionOptions): UseAnalysisQueryExecutionResult;