import { type DataSourceInstanceListItem, type DataSourceInstanceSettings, type DataSourceRef, type ScopedVars } from '@grafana/data'; import { type GetDataSourceListFilters } from '../dataSourceSrv'; /** * Populate the instance-settings cache from boot data. Intended to be called * exactly once at application startup via the `@grafana/runtime/internal` export. * In tests, use {@link setDataSourceInstanceSettings} instead. * * @internal */ export declare function initDataSourceInstanceSettings(settings: Record, defaultDsName: string): void; /** * Test helper — the sanctioned way to seed the instance-settings cache in tests. * Fully resets all module state (including runtime and expression data sources), * then populates the cache from a clone of `settings` so test fixtures are never * mutated. When `defaultDatasourceName` is omitted, the entry flagged with * `isDefault: true` becomes the default. Should only be called from tests. * * @internal */ export declare function setDataSourceInstanceSettings(settings: Record, defaultDatasourceName?: string): void; export declare function reloadDataSourceInstanceSettings(): Promise; interface SyncDataSourceSettings { datasources: Record; defaultDatasource: string; } /** * Sync the instance-settings cache from an already-fetched `/api/frontend/settings` * payload, without issuing another backend request. Built-in (e.g. expression) and * runtime data sources survive because `populateMaps` re-applies them. * * Transition-period helper: while both the legacy `DataSourceSrv` and the new async * datasource APIs exist, `DataSourceSrv.reload()` calls this so a single fetch updates * both caches. Remove once `DataSourceSrv` is gone. * * @internal */ export declare function syncDataSourceInstanceSettings(settings: SyncDataSourceSettings): void; /** * Look up the instance settings for a data source from the in-memory cache * populated at boot. Call {@link reloadDataSourceInstanceSettings} to refresh * the cache from the backend. * * `scopedVars` are used when `ref` contains a template variable (e.g. `$ds`). * * @public */ export declare function getDataSourceInstanceSettings(ref?: DataSourceRef | string | null, scopedVars?: ScopedVars): Promise; /** * Filters for {@link getDataSourceInstanceList} and {@link useDataSourceInstanceList}. * * Identical to {@link GetDataSourceListFilters} except the `filter` callback receives a * {@link DataSourceInstanceListItem} instead of the full {@link DataSourceInstanceSettings}. * This reflects the long-term data model: the list API will only expose the slim item shape, * so filter callbacks must not rely on settings-specific fields such as `jsonData` or `url`. * * @public */ export interface GetDataSourceInstanceListFilters extends Omit { /** Apply a function to filter the list. Receives a slim {@link DataSourceInstanceListItem}. */ filter?: (item: DataSourceInstanceListItem) => boolean; } /** * Search and filter data sources from the in-memory cache, returning a * lightweight view of each match. The heavy per-instance settings are not * included — fetch them on demand via {@link getDataSourceInstanceSettings}. * * @public */ export declare function getDataSourceInstanceList(filters?: GetDataSourceInstanceListFilters): Promise; /** * Resolve the default data source instance of a given type. Returns the instance flagged * as default, otherwise the first instance of that type, or `undefined` when none exist. * * Covers the common "get my data source" pattern (`list.find(ds => ds.isDefault) ?? list[0]`) * without exposing the full list. The heavy per-instance settings are not included — fetch * them on demand via {@link getDataSourceInstanceSettings}. * * @public */ export declare function getDefaultDataSourceInstance(type: string): Promise; /** * Check whether at least one data source instance of the given type is installed. * * Covers presence checks (`getList({ type }).length > 0`) without returning a list. * * @public */ export declare function hasDataSourceInstance(type: string): Promise; /** * Register the instance settings for a runtime data source so it is returned * by future lookups. Throws if the uid is already in use. * * @internal */ export declare function upsertRuntimeDataSourceInstanceSettings(settings: DataSourceInstanceSettings): void; /** * Test helper — resets all module state. Should only be called from tests. * * @internal */ export declare function _resetForTests(): void; export {};