{"version":3,"file":"dataFrame.cjs","sources":["../../../src/types/dataFrame.ts"],"sourcesContent":["import { HideSeriesConfig } from '@grafana/schema';\n\nimport { ScopedVars } from './ScopedVars';\nimport { Action } from './action';\nimport { QueryResultBase, Labels, NullValueMode } from './data';\nimport { DataLink, LinkModel } from './dataLink';\nimport { DecimalCount, DisplayProcessor, DisplayValue, DisplayValueAlignmentFactors } from './displayValue';\nimport { FieldColor } from './fieldColor';\nimport { ThresholdsConfig } from './thresholds';\nimport { ValueMapping } from './valueMapping';\n\n/** @public */\nexport enum FieldType {\n  time = 'time', // or date\n  number = 'number',\n  string = 'string',\n  boolean = 'boolean',\n\n  // Used to detect that the value is some kind of trace data to help with the visualisation and processing.\n  trace = 'trace',\n  geo = 'geo',\n  enum = 'enum',\n  other = 'other', // Object, Array, etc\n  frame = 'frame', // DataFrame\n\n  // @alpha Nested DataFrames. This is for example used with tables where expanding a row will show a nested table.\n  // The value should be DataFrame[] even if it is a single frame.\n  nestedFrames = 'nestedFrames',\n}\n\n/**\n * @public\n * Every property is optional\n *\n * Plugins may extend this with additional properties. Something like series overrides\n */\nexport interface FieldConfig<TOptions = any> {\n  /**\n   * The display value for this field.  This supports template variables blank is auto.\n   * If you are a datasource plugin, do not set this. Use `field.value` and if that\n   * is not enough, use `field.config.displayNameFromDS`.\n   */\n  displayName?: string;\n\n  /**\n   * This can be used by data sources that need to customize how values are named.\n   * When this property is configured, this value is used rather than the default naming strategy.\n   */\n  displayNameFromDS?: string;\n\n  /**\n   * Human readable field metadata\n   */\n  description?: string;\n\n  /**\n   * An explicit path to the field in the datasource.  When the frame meta includes a path,\n   * This will default to `${frame.meta.path}/${field.name}\n   *\n   * When defined, this value can be used as an identifier within the datasource scope, and\n   * may be used to update the results\n   */\n  path?: string;\n\n  /**\n   * True if data source can write a value to the path.  Auth/authz are supported separately\n   */\n  writeable?: boolean;\n\n  /**\n   * True if data source field supports ad-hoc filters\n   */\n  filterable?: boolean;\n\n  // Numeric Options\n  unit?: string;\n  decimals?: DecimalCount; // Significant digits (for display)\n  min?: number | null;\n  max?: number | null;\n\n  // Interval indicates the expected regular step between values in the series.\n  // When an interval exists, consumers can identify \"missing\" values when the expected value is not present.\n  // The grafana timeseries visualization will render disconnected values when missing values are found it the time field.\n  // The interval uses the same units as the values.  For time.Time, this is defined in milliseconds.\n  interval?: number | null;\n\n  // Convert input values into a display string\n  mappings?: ValueMapping[];\n\n  // Map numeric values to states\n  thresholds?: ThresholdsConfig;\n\n  // Map values to a display color\n  color?: FieldColor;\n\n  // Used when reducing field values\n  nullValueMode?: NullValueMode;\n\n  // The behavior when clicking on a result\n  links?: DataLink[];\n\n  actions?: Action[];\n\n  // Alternative to empty string\n  noValue?: string;\n\n  // The field type may map to specific config\n  type?: FieldTypeConfig;\n\n  // Panel Specific Values\n  custom?: TOptions;\n\n  // Calculate min max per field\n  fieldMinMax?: boolean;\n}\n\nexport interface FieldTypeConfig {\n  enum?: EnumFieldConfig;\n}\n\nexport interface EnumFieldConfig {\n  text?: string[];\n  color?: string[];\n  icon?: string[];\n  description?: string[];\n}\n\n/** @public */\nexport interface ValueLinkConfig {\n  /**\n   * Result of field reduction\n   */\n  calculatedValue?: DisplayValue;\n  /**\n   * Index of the value row within Field. Should be provided only when value is not a result of a reduction\n   */\n  valueRowIndex?: number;\n}\n\nexport interface Field<T = any> {\n  /**\n   * Name of the field (column)\n   */\n  name: string;\n  /**\n   *  Field value type (string, number, etc)\n   */\n  type: FieldType;\n  /**\n   *  Meta info about how field and how to display it\n   */\n  config: FieldConfig;\n\n  /**\n   * The raw field values\n   */\n  values: T[];\n\n  /**\n   * When type === FieldType.Time, this can optionally store\n   * the nanosecond-precision fractions as integers between\n   * 0 and 999999.\n   */\n  nanos?: number[];\n\n  labels?: Labels;\n\n  /**\n   * Cached values with appropriate display and id values\n   */\n  state?: FieldState | null;\n\n  /**\n   * Convert a value for display\n   */\n  display?: DisplayProcessor;\n\n  /**\n   * Get value data links with variables interpolated\n   */\n  getLinks?: (config: ValueLinkConfig) => Array<LinkModel<Field>>;\n}\n\n/** @alpha */\nexport interface FieldState {\n  /**\n   * An appropriate name for the field (does not include frame info)\n   */\n  displayName?: string | null;\n\n  /**\n   * Cache of reduced values\n   */\n  calcs?: FieldCalcs;\n\n  /**\n   * The numeric range for values in this field.  This value will respect the min/max\n   * set in field config, or when set to `auto` this will have the min/max for all data\n   * in the response\n   */\n  range?: NumericRange;\n\n  /**\n   * Appropriate values for templating\n   */\n  scopedVars?: ScopedVars;\n\n  /**\n   * Series index is index for this field in a larger data set that can span multiple DataFrames\n   * Useful for assigning color to series by looking up a color in a palette using this index\n   */\n  seriesIndex?: number;\n\n  /**\n   * Location of this field within the context frames results\n   *\n   * @internal -- we will try to make this unnecessary\n   */\n  origin?: DataFrameFieldIndex;\n\n  /**\n   * Boolean value is true if field is in a larger data set with multiple frames.\n   * This is only related to the cached displayName property above.\n   */\n  multipleFrames?: boolean;\n\n  /**\n   * Boolean value is true if a null filling threshold has been applied\n   * against the frame of the field. This is used to avoid cases in which\n   * this would applied more than one time.\n   */\n  nullThresholdApplied?: boolean;\n\n  /**\n   * Can be used by visualizations to cache max display value lengths to aid alignment.\n   * It's up to each visualization to calculate and set this.\n   */\n  alignmentFactors?: DisplayValueAlignmentFactors;\n\n  /**\n   * This is the current ad-hoc state of whether this series is hidden in viz, tooltip, and legend.\n   *\n   * Currently this will match field.config.custom.hideFrom because fieldOverrides applies the special __system\n   * override to the actual config during toggle via legend. This should go away once we have a unified system\n   * for layering ad hoc field overrides and options but still being able to get the stateless fieldConfig and panel options\n   */\n  hideFrom?: HideSeriesConfig;\n}\n\n/** @public */\nexport interface NumericRange {\n  min?: number | null;\n  max?: number | null;\n  delta: number;\n}\n\nexport interface DataFrame extends QueryResultBase {\n  name?: string;\n  fields: Field[]; // All fields of equal length\n\n  // The number of rows\n  length: number;\n}\n\n// Data frame that include aggregate value, for use by timeSeriesTableTransformer / chart cell type\nexport interface DataFrameWithValue extends DataFrame {\n  value: number | null;\n}\n\n/**\n * @public\n * Like a field, but properties are optional and values may be a simple array\n */\nexport interface FieldDTO<T = any> {\n  name: string; // The column name\n  type?: FieldType;\n  config?: FieldConfig;\n  values?: T[];\n  labels?: Labels;\n}\n\n/**\n * @public\n * Like a DataFrame, but fields may be a FieldDTO\n */\nexport interface DataFrameDTO extends QueryResultBase {\n  name?: string;\n  fields: Array<FieldDTO | Field>;\n}\n\nexport interface FieldCalcs extends Record<string, any> {}\n\n/** @deprecated check data plane docs: https://grafana.com/developers/dataplane/heatmap **/\nexport const TIME_SERIES_VALUE_FIELD_NAME = 'Value';\nexport const TIME_SERIES_TIME_FIELD_NAME = 'Time';\nexport const TIME_SERIES_METRIC_FIELD_NAME = 'Metric';\n\n/**\n * Describes where a specific data frame field is located within a\n * dataset of type DataFrame[]\n *\n * @internal -- we will try to make this unnecessary\n */\nexport interface DataFrameFieldIndex {\n  frameIndex: number;\n  fieldIndex: number;\n}\n"],"names":["FieldType"],"mappings":";;;;;AAYO,IAAK,SAAA,qBAAAA,UAAAA,KAAL;AACL,EAAAA,WAAA,MAAA,CAAA,GAAO,MAAA;AACP,EAAAA,WAAA,QAAA,CAAA,GAAS,QAAA;AACT,EAAAA,WAAA,QAAA,CAAA,GAAS,QAAA;AACT,EAAAA,WAAA,SAAA,CAAA,GAAU,SAAA;AAGV,EAAAA,WAAA,OAAA,CAAA,GAAQ,OAAA;AACR,EAAAA,WAAA,KAAA,CAAA,GAAM,KAAA;AACN,EAAAA,WAAA,MAAA,CAAA,GAAO,MAAA;AACP,EAAAA,WAAA,OAAA,CAAA,GAAQ,OAAA;AACR,EAAAA,WAAA,OAAA,CAAA,GAAQ,OAAA;AAIR,EAAAA,WAAA,cAAA,CAAA,GAAe,cAAA;AAfL,EAAA,OAAAA,UAAAA;AAAA,CAAA,EAAA,SAAA,IAAA,EAAA;AAyRL,MAAM,4BAAA,GAA+B;AACrC,MAAM,2BAAA,GAA8B;AACpC,MAAM,6BAAA,GAAgC;;;;;;;"}