1import { MonoTypeOperatorFunction } from 'rxjs'; 2 3import { DataFrame, Field } from './dataFrame'; 4import { RegistryItemWithOptions } from '../utils/Registry'; 5 6/** 7 * Function that transform data frames (AKA transformer) 8 * 9 * @public 10 */ 11export interface DataTransformerInfo<TOptions = any> extends RegistryItemWithOptions { 12 /** 13 * Function that configures transformation and returns a transformer 14 * @param options 15 */ 16 operator: (options: TOptions) => MonoTypeOperatorFunction<DataFrame[]>; 17} 18 19/** 20 * Many transformations can be called with a simple synchronous function. 21 * When a transformer is defined, it should have identical behavior to using the operator 22 * 23 * @public 24 */ 25export interface SynchronousDataTransformerInfo<TOptions = any> extends DataTransformerInfo<TOptions> { 26 transformer: (options: TOptions) => (frames: DataFrame[]) => DataFrame[]; 27} 28 29/** 30 * @public 31 */ 32export interface DataTransformerConfig<TOptions = any> { 33 /** 34 * Unique identifier of transformer 35 */ 36 id: string; 37 /** 38 * Disabled transformations are skipped 39 */ 40 disabled?: boolean; 41 /** 42 * Options to be passed to the transformer 43 */ 44 options: TOptions; 45} 46 47export type FrameMatcher = (frame: DataFrame) => boolean; 48export type FieldMatcher = (field: Field, frame: DataFrame, allFrames: DataFrame[]) => boolean; 49 50/** 51 * Value matcher type to describe the matcher function 52 * @public 53 */ 54export type ValueMatcher = (valueIndex: number, field: Field, frame: DataFrame, allFrames: DataFrame[]) => boolean; 55 56export interface FieldMatcherInfo<TOptions = any> extends RegistryItemWithOptions<TOptions> { 57 get: (options: TOptions) => FieldMatcher; 58} 59 60export interface FrameMatcherInfo<TOptions = any> extends RegistryItemWithOptions<TOptions> { 61 get: (options: TOptions) => FrameMatcher; 62} 63 64/** 65 * Registry item to represent all the different valu matchers supported 66 * in the Grafana platform. 67 * @public 68 */ 69export interface ValueMatcherInfo<TOptions = any> extends RegistryItemWithOptions<TOptions> { 70 get: (options: TOptions) => ValueMatcher; 71 isApplicable: (field: Field) => boolean; 72 getDefaultOptions: (field: Field) => TOptions; 73} 74export interface MatcherConfig<TOptions = any> { 75 id: string; 76 options?: TOptions; 77} 78