{"version":3,"file":"data.cjs","sources":["../../../src/types/data.ts"],"sourcesContent":["import { DataFrameDTO, FieldConfig } from './dataFrame';\nimport { DataFrameType } from './dataFrameTypes';\nimport { ApplyFieldOverrideOptions } from './fieldOverrides';\nimport { PanelPluginDataSupport } from './panel';\nimport { DataTopic } from './query';\nimport { DataTransformerConfig } from './transformations';\n\nexport type KeyValue<T = any> = Record<string, T>;\n\n/**\n * Represent panel data loading state.\n * @public\n */\nexport enum LoadingState {\n  NotStarted = 'NotStarted',\n  Loading = 'Loading',\n  Streaming = 'Streaming',\n  Done = 'Done',\n  Error = 'Error',\n}\n\n// Should be kept in sync with grafana-plugin-sdk-go/data/frame_meta.go\nexport const preferredVisualizationTypes = [\n  'graph',\n  'table',\n  'logs',\n  'trace',\n  'nodeGraph',\n  'flamegraph',\n  'rawPrometheus',\n] as const;\nexport type PreferredVisualisationType = (typeof preferredVisualizationTypes)[number];\n\n/**\n * Should be kept in sync with https://github.com/grafana/grafana-plugin-sdk-go/blob/main/data/frame_meta.go\n * @public\n */\nexport interface QueryResultMeta {\n  type?: DataFrameType;\n\n  /**\n   * TypeVersion is the version of the Type property. Versions greater than 0.0 correspond to the dataplane\n   * contract documentation https://github.com/grafana/grafana-plugin-sdk-go/tree/main/data/contract_docs.\n   */\n  typeVersion?: [number, number];\n\n  /** DatasSource Specific Values */\n  custom?: Record<string, any>;\n\n  /** Stats */\n  stats?: QueryResultMetaStat[];\n\n  /** Meta Notices */\n  notices?: QueryResultMetaNotice[];\n\n  /** Currently used to show results in Explore only in preferred visualisation option */\n  preferredVisualisationType?: PreferredVisualisationType;\n\n  /** Set the panel plugin id to use to render the data when using Explore. If the plugin cannot be found\n   * will fall back to {@link preferredVisualisationType}.\n   *\n   * @alpha\n   */\n  preferredVisualisationPluginId?: string;\n\n  /** The path for live stream updates for this frame */\n  channel?: string;\n\n  /** Did the query response come from the cache */\n  isCachedResponse?: boolean;\n\n  /**\n   * Optionally identify which topic the frame should be assigned to.\n   * A value specified in the response will override what the request asked for.\n   */\n  dataTopic?: DataTopic;\n\n  /**\n   * This is the raw query sent to the underlying system.  All macros and templating\n   * as been applied.  When metadata contains this value, it will be shown in the query inspector\n   */\n  executedQueryString?: string;\n\n  /**\n   * A browsable path on the datasource\n   */\n  path?: string;\n\n  /**\n   * defaults to '/'\n   */\n  pathSeparator?: string;\n\n  /** A time shift metadata indicating a result of comparison */\n  timeCompare?: {\n    diffMs: number;\n    isTimeShiftQuery: boolean;\n  };\n\n  /**\n   * Legacy data source specific, should be moved to custom\n   * */\n  searchWords?: string[]; // used by log models and loki\n  limit?: number; // used by log models and loki\n  json?: boolean; // used to keep track of old json doc values\n  instant?: boolean;\n\n  /**\n   * Array of field indices which values create a unique id for each row. Ideally this should be globally unique ID\n   * but that isn't guarantied. Should help with keeping track and deduplicating rows in visualizations, especially\n   * with streaming data with frequent updates.\n   * Example: TraceID in Tempo, table name + primary key in SQL\n   */\n  uniqueRowIdFields?: number[];\n}\n\nexport interface QueryResultMetaStat extends FieldConfig {\n  displayName: string;\n  value: number;\n}\n\n/**\n * QueryResultMetaNotice is a structure that provides user notices for query result data\n * @public\n */\nexport interface QueryResultMetaNotice {\n  /**\n   * Specify the notice severity\n   */\n  severity: 'info' | 'warning' | 'error';\n\n  /**\n   * Notice descriptive text\n   */\n  text: string;\n\n  /**\n   * An optional link that may be displayed in the UI.\n   * This value may be an absolute URL or relative to grafana root\n   */\n  link?: string;\n\n  /**\n   * Optionally suggest an appropriate tab for the panel inspector\n   */\n  inspect?: 'meta' | 'error' | 'data' | 'stats';\n}\n\n/**\n * @public\n */\nexport interface QueryResultBase {\n  /**\n   * Matches the query target refId\n   */\n  refId?: string;\n\n  /**\n   * Used by some backend data sources to communicate back info about the execution (generated sql, timing)\n   */\n  meta?: QueryResultMeta;\n}\n\nexport interface Labels {\n  [key: string]: string;\n}\n\n/** @deprecated this is a very old (pre Grafana 7 + DataFrame) representation for tabular data  */\nexport interface Column {\n  text: string; // For a Column, the 'text' is the field name\n  filterable?: boolean;\n  unit?: string;\n  custom?: Record<string, any>;\n}\n\n/** @deprecated this is a very old (pre Grafana 7 + DataFrame) representation for tabular data  */\nexport interface TableData extends QueryResultBase {\n  name?: string;\n  columns: Column[];\n  rows: any[][];\n  type?: string;\n}\n\n/** @deprecated this is a very old (pre Grafana 7 + DataFrame) representation for tabular data  */\nexport type TimeSeriesValue = number | null;\n\n/** @deprecated this is a very old (pre Grafana 7 + DataFrame) representation for tabular data  */\nexport type TimeSeriesPoints = TimeSeriesValue[][];\n\n/** @deprecated this is a very old (pre Grafana 7 + DataFrame) representation for tabular data  */\nexport interface TimeSeries extends QueryResultBase {\n  target: string;\n  /**\n   * If name is manually configured via an alias / legend pattern\n   */\n  title?: string;\n  datapoints: TimeSeriesPoints;\n  unit?: string;\n  tags?: Labels;\n}\n\nexport enum NullValueMode {\n  Null = 'null',\n  Ignore = 'connected',\n  AsZero = 'null as zero',\n}\n\n/**\n * Describes and API for exposing panel specific data configurations.\n */\nexport interface DataConfigSource {\n  configRev?: number;\n  getDataSupport: () => PanelPluginDataSupport;\n  getTransformations: () => DataTransformerConfig[] | undefined;\n  getFieldOverrideOptions: () => ApplyFieldOverrideOptions | undefined;\n  snapshotData?: DataFrameDTO[];\n}\n\ntype Truthy<T> = T extends false | '' | 0 | null | undefined ? never : T;\nexport const isTruthy = <T>(value: T): value is Truthy<T> => Boolean(value);\n\n/**\n * Serves no runtime purpose - only used to make typescript check a value has been correctly\n * narrowed to an object\n */\nfunction identityObject(value: object): object {\n  return value;\n}\n\n/**\n * Utility type predicate to check if a value is typeof object, but excludes \"null\".\n *\n * We normally discourage the use of type predicates in favor of just inline typescript narrowing,\n * but this is a special case to handle null annoyingly being typeof object\n */\nexport function isObject(value: unknown): value is object {\n  if (typeof value === 'object' && value !== null) {\n    identityObject(value);\n\n    return true;\n  }\n\n  return false;\n}\n"],"names":["LoadingState","NullValueMode"],"mappings":";;;;;AAaO,IAAK,YAAA,qBAAAA,aAAAA,KAAL;AACL,EAAAA,cAAA,YAAA,CAAA,GAAa,YAAA;AACb,EAAAA,cAAA,SAAA,CAAA,GAAU,SAAA;AACV,EAAAA,cAAA,WAAA,CAAA,GAAY,WAAA;AACZ,EAAAA,cAAA,MAAA,CAAA,GAAO,MAAA;AACP,EAAAA,cAAA,OAAA,CAAA,GAAQ,OAAA;AALE,EAAA,OAAAA,aAAAA;AAAA,CAAA,EAAA,YAAA,IAAA,EAAA;AASL,MAAM,2BAAA,GAA8B;AAAA,EACzC,OAAA;AAAA,EACA,OAAA;AAAA,EACA,MAAA;AAAA,EACA,OAAA;AAAA,EACA,WAAA;AAAA,EACA,YAAA;AAAA,EACA;AACF;AA2KO,IAAK,aAAA,qBAAAC,cAAAA,KAAL;AACL,EAAAA,eAAA,MAAA,CAAA,GAAO,MAAA;AACP,EAAAA,eAAA,QAAA,CAAA,GAAS,WAAA;AACT,EAAAA,eAAA,QAAA,CAAA,GAAS,cAAA;AAHC,EAAA,OAAAA,cAAAA;AAAA,CAAA,EAAA,aAAA,IAAA,EAAA;AAkBL,MAAM,QAAA,GAAW,CAAI,KAAA,KAAiC,OAAA,CAAQ,KAAK;AAM1E,SAAS,eAAe,KAAA,EAAuB;AAC7C,EAAA,OAAO,KAAA;AACT;AAQO,SAAS,SAAS,KAAA,EAAiC;AACxD,EAAA,IAAI,OAAO,KAAA,KAAU,QAAA,IAAY,KAAA,KAAU,IAAA,EAAM;AAC/C,IAAA,cAAA,CAAe,KAAK,CAAA;AAEpB,IAAA,OAAO,IAAA;AAAA,EACT;AAEA,EAAA,OAAO,KAAA;AACT;;;;;;;;"}