All files server/types/query.ts

0% Statements 0/0
0% Branches 0/0
0% Functions 0/0
0% Lines 0/0

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                                                                                                                                                                                           
/**
 * Query-related types for the semantic layer
 * Includes query definitions, filters, and time dimensions
 */
 
import type { TimeGranularity } from './core'
 
/**
 * Semantic query structure (Cube.js compatible)
 */
export interface SemanticQuery {
  measures?: string[]
  dimensions?: string[]
  filters?: Array<Filter>
  timeDimensions?: Array<TimeDimension>
  limit?: number
  offset?: number
  order?: Record<string, 'asc' | 'desc'>
  /**
   * Default value to fill missing time series gaps with.
   * Used when fillMissingDates is enabled on time dimensions.
   * Default: 0
   */
  fillMissingDatesValue?: number | null
}
 
/**
 * Filter definitions with logical operators
 */
export type Filter = FilterCondition | LogicalFilter
 
export interface FilterCondition {
  member: string
  operator: FilterOperator
  values: any[]
  dateRange?: string | string[]
}
 
export interface LogicalFilter {
  and?: Filter[]
  or?: Filter[]
}
 
/**
 * Time dimension with granularity
 */
export interface TimeDimension {
  dimension: string
  granularity?: TimeGranularity
  dateRange?: string | string[]
  /**
   * Fill missing dates in time series with the fill value.
   * Requires both granularity and dateRange to be set.
   * Default: true (enabled)
   */
  fillMissingDates?: boolean
}
 
/**
 * Supported filter operators
 */
export type FilterOperator = 
  | 'equals' 
  | 'notEquals' 
  | 'contains' 
  | 'notContains'
  | 'startsWith'
  | 'notStartsWith'
  | 'endsWith'
  | 'notEndsWith'
  | 'gt'
  | 'gte'
  | 'lt'
  | 'lte'
  | 'set'
  | 'notSet'
  | 'inDateRange'
  | 'beforeDate'
  | 'afterDate'
  | 'between'
  | 'notBetween'
  | 'in'
  | 'notIn'
  | 'like'
  | 'notLike'
  | 'ilike'
  | 'regex'
  | 'notRegex'
  | 'isEmpty'
  | 'isNotEmpty'
  // PostgreSQL array operators
  | 'arrayContains'
  | 'arrayOverlaps'
  | 'arrayContained'