import { DataRecord } from './QueryResponse' ; import { TimeGranularity } from '../../time-format' ; export enum AnnotationType { Event = 'EVENT' , Formula = 'FORMULA' , Interval = 'INTERVAL' , Timeseries = 'TIME_SERIES' } export enum AnnotationSourceType { Line = 'line' , Native = 'NATIVE' , Table = 'table' , Undefined = '' } export enum AnnotationOpacity { High = 'opacityHigh' , Low = 'opacityLow' , Medium = 'opacityMedium' , Undefined = '' } export enum AnnotationStyle { Dashed = 'dashed' , Dotted = 'dotted' , Solid = 'solid' , LongDashed = 'longDashed' } type BaseAnnotationLayer = { color ? : string | null ; name : string ; opacity ? : AnnotationOpacity ; show : boolean ; showLabel : boolean ; style : AnnotationStyle ; width ? : number ; } ; type AnnotationOverrides = { granularity ? : string | null ; time_grain_sqla ? : TimeGranularity | null ; time_range ? : string | null ; time_shift ? : string | null ; } ; type LineSourceAnnotationLayer = { hideLine ? : boolean ; overrides ? : AnnotationOverrides ; sourceType : AnnotationSourceType . Line ; titleColumn ? : string ; value : number ; } ; type NativeSourceAnnotationLayer = { sourceType : AnnotationSourceType . Native ; value : number ; } ; type TableSourceAnnotationLayer = { descriptionColumns ? : string [ ] ; timeColumn ? : string ; intervalEndColumn ? : string ; overrides ? : AnnotationOverrides ; sourceType : AnnotationSourceType . Table ; titleColumn ? : string ; value : number ; } ; export type EventAnnotationLayer = BaseAnnotationLayer & ( TableSourceAnnotationLayer | NativeSourceAnnotationLayer ) & { annotationType : AnnotationType . Event ; } ; export type IntervalAnnotationLayer = BaseAnnotationLayer & ( TableSourceAnnotationLayer | NativeSourceAnnotationLayer ) & { annotationType : AnnotationType . Interval ; } ; export type TableAnnotationLayer = BaseAnnotationLayer & TableSourceAnnotationLayer & { annotationType : AnnotationType . Event | AnnotationType . Interval ; } ; export type FormulaAnnotationLayer = BaseAnnotationLayer & { annotationType : AnnotationType . Formula ; sourceType ? : AnnotationSourceType . Undefined ; value : string ; } ; export type TimeseriesAnnotationLayer = BaseAnnotationLayer & LineSourceAnnotationLayer & { annotationType : AnnotationType . Timeseries ; showMarkers ? : boolean ; value : number ; } ; export type AnnotationLayer = EventAnnotationLayer | IntervalAnnotationLayer | FormulaAnnotationLayer | TimeseriesAnnotationLayer ; export function isFormulaAnnotationLayer ( layer ) { return layer . annotationType === AnnotationType . Formula ; } export function isEventAnnotationLayer ( layer ) { return layer . annotationType === AnnotationType . Event ; } export function isIntervalAnnotationLayer ( layer ) { return layer . annotationType === AnnotationType . Interval ; } export function isTimeseriesAnnotationLayer ( layer ) { return layer . annotationType === AnnotationType . Timeseries ; } export function isTableAnnotationLayer ( layer ) { return layer . sourceType === AnnotationSourceType . Table ; } export type RecordAnnotationResult = { columns : string [ ] ; records : DataRecord [ ] ; } ; export type TimeseriesAnnotationResult = [ { key : string ; values : { x : string | number ; y ? : number ; } [ ] ; } ] ; export type AnnotationResult = RecordAnnotationResult | TimeseriesAnnotationResult ; export function isTimeseriesAnnotationResult ( result ) { return Array . isArray ( result ) ; } export function isRecordAnnotationResult ( result ) { return 'columns' in result && 'records' in result ; } export type AnnotationData = { [ key ] : AnnotationResult ; } ; export type Annotation = { descriptions ? : string [ ] ; intervalEnd ? : string ; time ? : string ; title ? : string ; } ;