{"version":3,"file":"transformations.cjs","sources":["../../../src/types/transformations.ts"],"sourcesContent":["import { MonoTypeOperatorFunction } from 'rxjs';\n\nimport { MatcherConfig, DataTransformerConfig } from '@grafana/schema';\n\nimport { RegistryItemWithOptions } from '../utils/Registry';\n\nimport { DataFrame, Field } from './dataFrame';\nimport { InterpolateFunction } from './panel';\n\n/** deprecated, use it from schema */\nexport type { MatcherConfig };\n\n/**\n * Context passed to transformDataFrame and to each transform operator\n */\nexport interface DataTransformContext {\n  interpolate: InterpolateFunction;\n}\n\n/**\n * We score for how applicable a given transformation is.\n * Currently :\n *  0 is considered as not-applicable\n *  1 is considered applicable\n *  2 is considered as highly applicable (i.e. should be highlighted)\n */\nexport type TransformationApplicabilityScore = number;\nexport enum TransformationApplicabilityLevels {\n  NotPossible = -1,\n  NotApplicable = 0,\n  Applicable = 1,\n  HighlyApplicable = 2,\n}\n\n/**\n * Function that transform data frames (AKA transformer)\n *\n * @public\n */\nexport interface DataTransformerInfo<TOptions = any> extends RegistryItemWithOptions {\n  /**\n   * Function that configures transformation and returns a transformer\n   * @param options\n   */\n  operator: (options: TOptions, context: DataTransformContext) => MonoTypeOperatorFunction<DataFrame[]>;\n  /**\n   * Function that is present will indicate whether a transformation is applicable\n   * given the current data.\n   * @param options\n   */\n  isApplicable?: (data: DataFrame[]) => TransformationApplicabilityScore;\n  /**\n   * A description of the applicator. Can either simply be a string\n   * or function which when given the current dataset returns a string.\n   * This way descriptions can be tailored relative to the underlying data.\n   */\n  isApplicableDescription?: string | ((data: DataFrame[]) => string);\n}\n\n/**\n * Function that returns a cutsom transform operator for transforming data frames\n *\n * @public\n */\nexport type CustomTransformOperator = (context: DataTransformContext) => MonoTypeOperatorFunction<DataFrame[]>;\n\n/**\n * Many transformations can be called with a simple synchronous function.\n * When a transformer is defined, it should have identical behavior to using the operator\n *\n * @public\n */\nexport interface SynchronousDataTransformerInfo<TOptions = any> extends DataTransformerInfo<TOptions> {\n  transformer: (options: TOptions, context: DataTransformContext) => (frames: DataFrame[]) => DataFrame[];\n}\n\n/**\n * @deprecated use TransformationConfig from schema\n */\nexport type { DataTransformerConfig };\n\nexport type FrameMatcher = (frame: DataFrame) => boolean;\nexport type FieldMatcher = (field: Field, frame: DataFrame, allFrames: DataFrame[]) => boolean;\n\n/**\n * Value matcher type to describe the matcher function\n * @public\n */\nexport type ValueMatcher = (valueIndex: number, field: Field, frame: DataFrame, allFrames: DataFrame[]) => boolean;\n\nexport interface FieldMatcherInfo<TOptions = any> extends RegistryItemWithOptions<TOptions> {\n  get: (options: TOptions) => FieldMatcher;\n}\n\nexport interface FrameMatcherInfo<TOptions = any> extends RegistryItemWithOptions<TOptions> {\n  get: (options: TOptions) => FrameMatcher;\n}\n\n/**\n * Registry item to represent all the different valu matchers supported\n * in the Grafana platform.\n * @public\n */\nexport interface ValueMatcherInfo<TOptions = any> extends RegistryItemWithOptions<TOptions> {\n  get: (options: TOptions) => ValueMatcher;\n  isApplicable: (field: Field) => boolean;\n  getDefaultOptions: (field: Field) => TOptions;\n}\n\n/**\n * @public\n */\nexport enum SpecialValue {\n  True = 'true',\n  False = 'false',\n  Null = 'null',\n  Empty = 'empty',\n  Zero = 'zero',\n}\n"],"names":["TransformationApplicabilityLevels","SpecialValue"],"mappings":";;;;;AA2BO,IAAK,iCAAA,qBAAAA,kCAAAA,KAAL;AACL,EAAAA,kCAAAA,CAAAA,kCAAAA,CAAA,iBAAc,CAAA,CAAA,CAAA,GAAd,aAAA;AACA,EAAAA,kCAAAA,CAAAA,kCAAAA,CAAA,mBAAgB,CAAA,CAAA,GAAhB,eAAA;AACA,EAAAA,kCAAAA,CAAAA,kCAAAA,CAAA,gBAAa,CAAA,CAAA,GAAb,YAAA;AACA,EAAAA,kCAAAA,CAAAA,kCAAAA,CAAA,sBAAmB,CAAA,CAAA,GAAnB,kBAAA;AAJU,EAAA,OAAAA,kCAAAA;AAAA,CAAA,EAAA,iCAAA,IAAA,EAAA;AAqFL,IAAK,YAAA,qBAAAC,aAAAA,KAAL;AACL,EAAAA,cAAA,MAAA,CAAA,GAAO,MAAA;AACP,EAAAA,cAAA,OAAA,CAAA,GAAQ,OAAA;AACR,EAAAA,cAAA,MAAA,CAAA,GAAO,MAAA;AACP,EAAAA,cAAA,OAAA,CAAA,GAAQ,OAAA;AACR,EAAAA,cAAA,MAAA,CAAA,GAAO,MAAA;AALG,EAAA,OAAAA,aAAAA;AAAA,CAAA,EAAA,YAAA,IAAA,EAAA;;;;;"}