{"version":3,"file":"dataSourceSrv.mjs","sources":["../../../src/services/dataSourceSrv.ts"],"sourcesContent":["import {\n  type ScopedVars,\n  type DataSourceApi,\n  type DataSourceInstanceSettings,\n  type DataSourceRef,\n} from '@grafana/data';\n\nimport { type RuntimeDataSource } from './RuntimeDataSource';\n\n/**\n * This is the entry point for communicating with a datasource that is added as\n * a plugin (both external and internal). Via this service you will get access\n * to the {@link @grafana/data#DataSourceApi | DataSourceApi} that have a rich API for\n * communicating with the datasource.\n *\n * @public\n */\nexport interface DataSourceSrv {\n  /**\n   * Returns the requested dataSource. If it cannot be found it rejects the promise.\n   * @param ref - The datasource identifier, it can be a name, UID or DataSourceRef (an object with UID),\n   * @param scopedVars - variables used to interpolate a templated passed as name.\n   */\n  get(ref?: DataSourceRef | string | null, scopedVars?: ScopedVars): Promise<DataSourceApi>;\n\n  /**\n   * Get a list of data sources\n   */\n  getList(filters?: GetDataSourceListFilters): DataSourceInstanceSettings[];\n\n  /**\n   * Get settings and plugin metadata by name or uid\n   */\n  getInstanceSettings(\n    ref?: DataSourceRef | string | null,\n    scopedVars?: ScopedVars\n  ): DataSourceInstanceSettings | undefined;\n\n  /**\n   * Reloads the DataSourceSrv\n   */\n  reload(): void;\n\n  /**\n   * Registers a runtime data source. Make sure your data source uid is unique.\n   */\n  registerRuntimeDataSource(entry: RuntimeDataSourceRegistration): void;\n}\n\nexport interface RuntimeDataSourceRegistration {\n  dataSource: RuntimeDataSource;\n}\n\n/** @public */\nexport interface GetDataSourceListFilters {\n  /** Include mixed data source by setting this to true */\n  mixed?: boolean;\n\n  /** Only return data sources that support metrics response */\n  metrics?: boolean;\n\n  /** Only return data sources that support tracing response */\n  tracing?: boolean;\n\n  /** Only return data sources that support logging response */\n  logs?: boolean;\n\n  /** Only return data sources that support annotations */\n  annotations?: boolean;\n\n  /** Only filter data sources that support alerting */\n  alerting?: boolean;\n\n  /**\n   * By default only data sources that can be queried will be returned. Meaning they have tracing,\n   * metrics, logs or annotations flag set in plugin.json file\n   * */\n  all?: boolean;\n\n  /** Set to true to return dashboard data source */\n  dashboard?: boolean;\n\n  /** Set to true to return data source variables */\n  variables?: boolean;\n\n  /** filter list by plugin  */\n  pluginId?: string;\n\n  /** apply a function to filter */\n  filter?: (dataSource: DataSourceInstanceSettings) => boolean;\n\n  /** Only returns datasources matching the specified types (ie. Loki, Prometheus) */\n  type?: string | string[];\n}\n\nlet singletonInstance: DataSourceSrv;\n\n/**\n * Used during startup by Grafana to set the DataSourceSrv so it is available\n * via the {@link getDataSourceSrv} to the rest of the application.\n *\n * @internal\n */\nexport function setDataSourceSrv(instance: DataSourceSrv) {\n  singletonInstance = instance;\n}\n\n/**\n * Used to retrieve the {@link DataSourceSrv} that is the entry point for communicating with\n * a datasource that is added as a plugin (both external and internal).\n *\n * @public\n */\nexport function getDataSourceSrv(): DataSourceSrv {\n  return singletonInstance;\n}\n"],"names":[],"mappings":";AA+FA,IAAI,iBAAA;AAQG,SAAS,iBAAiB,QAAA,EAAyB;AACxD,EAAA,iBAAA,GAAoB,QAAA;AACtB;AAQO,SAAS,gBAAA,GAAkC;AAChD,EAAA,OAAO,iBAAA;AACT;;;;"}