Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 | /**
* Server-side Flow Analysis Types
*
* Types for server-side flow query building and execution.
* Flow analysis explores paths BEFORE and AFTER a defined starting step (bidirectional).
*/
import type { Filter } from './query'
// ============================================================================
// Flow Query Configuration
// ============================================================================
/**
* Flow query configuration for server-side execution
* This is the configuration extracted from SemanticQuery.flow
*/
export interface FlowQueryConfig {
/**
* Binding key that identifies individual entities (e.g., userId)
* Can be a single string like 'Events.userId' or array for multi-cube
*/
bindingKey: string | { cube: string; dimension: string }[]
/**
* Time dimension used for ordering events
* Can be a single string like 'Events.timestamp' or array for multi-cube
*/
timeDimension: string | { cube: string; dimension: string }[]
/**
* The starting step from which we explore paths
* Defines the anchor point for bidirectional flow analysis
*/
startingStep: {
/** Display name for the starting step */
name: string
/** Filter(s) that identify events for this starting step */
filter?: Filter | Filter[]
}
/** Number of steps to explore BEFORE the starting step (0-5) */
stepsBefore: number
/** Number of steps to explore AFTER the starting step (0-5) */
stepsAfter: number
/**
* Event dimension that categorizes events (e.g., 'Events.eventType')
* This dimension's values become the node labels in the Sankey diagram
*/
eventDimension: string
/**
* Optional limit on the number of entities to process
* Useful for performance on large datasets
*/
entityLimit?: number
/**
* Output mode for flow data aggregation
* - 'sankey': Aggregate by (layer, event_type) - standard flow visualization where paths can converge
* - 'sunburst': Path-qualified nodes for hierarchical tree visualization where each path is unique
* @default 'sankey'
*/
outputMode?: 'sankey' | 'sunburst'
/**
* Join strategy for fetching before/after steps
* - 'auto' (default): Use lateral when supported, otherwise window
* - 'lateral': Force lateral joins (error if not supported)
* - 'window': Force window-function strategy
*/
joinStrategy?: 'auto' | 'lateral' | 'window'
}
// ============================================================================
// Sankey Result Types
// ============================================================================
/**
* A node in the Sankey diagram
* Represents an event type at a specific layer (distance from starting step)
*/
export interface SankeyNode {
/**
* Unique identifier for this node
* Format: "before_{depth}_{eventType}" or "after_{depth}_{eventType}" or "start_{eventType}"
*/
id: string
/** Display name (typically the event type value) */
name: string
/**
* Layer position in the Sankey diagram
* Negative for steps before starting step, 0 for starting step, positive for after
*/
layer: number
/** Total count of entities passing through this node */
value?: number
}
/**
* A link (edge) in the Sankey diagram
* Represents a transition between two nodes
*/
export interface SankeyLink {
/** Source node ID */
source: string
/** Target node ID */
target: string
/** Count of entities that follow this path */
value: number
}
/**
* Flow result row returned from query execution
* Contains the complete Sankey diagram data
*/
export interface FlowResultRow {
nodes: SankeyNode[]
links: SankeyLink[]
}
// ============================================================================
// Internal Processing Types
// ============================================================================
/**
* Internal representation of a resolved step during query building
*/
export interface ResolvedFlowStep {
/** Layer index (-N to +N, 0 is starting step) */
layer: number
/** Direction from starting step */
direction: 'before' | 'start' | 'after'
/** Depth from starting step (0 for start, 1+ for before/after) */
depth: number
}
/**
* Raw aggregation row from the flow CTEs
* Before transformation to SankeyNode/SankeyLink format
*/
export interface RawFlowNodeRow {
node_id: string
event_type: string
layer: number
count: number
}
/**
* Raw link row from the flow CTEs
* Before transformation to SankeyLink format
*/
export interface RawFlowLinkRow {
source_id: string
target_id: string
count: number
}
// ============================================================================
// Validation Types
// ============================================================================
/**
* Flow validation result
*/
export interface FlowValidationResult {
isValid: boolean
errors: string[]
warnings: string[]
}
// ============================================================================
// Constants
// ============================================================================
/** Minimum number of steps before/after */
export const FLOW_MIN_DEPTH = 0
/** Maximum number of steps before/after */
export const FLOW_MAX_DEPTH = 5
|