UNPKG

@grafana/runtime

Version:
1,493 lines (1,464 loc) • 73.2 kB
import { Observable } from 'rxjs'; import * as _grafana_data from '@grafana/data'; import { DataQuery, DataSourceApi, DataSourceInstanceSettings, TestDataSourceResponse, DataSourceRef, ScopedVars, UrlQueryMap, TypedVariableModel, TimeRange, LiveChannelAddress, DataFrameJSON, StreamingFrameOptions, DataQueryRequest, LiveChannelEvent, DataQueryResponse, LiveChannelPresenceStatus, BusEventBase, BusEventWithPayload, GrafanaTheme2, PanelModel, EventBus, PluginExtension, PluginExtensionLink, PluginExtensionComponent, ComponentTypeWithExtensionMeta, PluginExtensionFunction, CurrentUser, Scope, AngularMeta, PluginLoadingStrategy, PluginDependencies, PluginExtensions, GrafanaConfig, PanelPluginMeta, AuthSettings, BuildInfo, BootData, OAuthSettings, GrafanaTheme, FeatureToggles, LicenseInfo, SystemDateFormatSettings, MapLayerOptions, CoreApp, PanelPlugin, DataSourceJsonData, AdHocVariableFilter, DataFrame, TimeSeries, TableData, KeyValue, DataQueryError, MetricFindValue, PanelData, FieldConfigSource, AbsoluteTimeRange, VisualizationSuggestion, QueryRunner, NavModelItem, PageLayoutType, SelectableValue, PluginMeta, WithAccessControlMetadata, DataSourceQueryType, DataSourceOptionsType, QueryEditorProps, DataLinkPostProcessor, DataLinkTransformationConfig } from '@grafana/data'; export { StreamingFrameAction, StreamingFrameOptions } from '@grafana/data'; import { auto } from 'angular'; import * as H from 'history'; import * as React$1 from 'react'; import React__default, { PureComponent } from 'react'; import { LogContext } from '@grafana/faro-web-sdk'; import * as react_jsx_runtime from 'react/jsx-runtime'; import { ActionMeta } from '@grafana/ui'; import { DataQuery as DataQuery$1, DataSourceJsonData as DataSourceJsonData$1 } from '@grafana/schema'; /** * Used to initiate a remote call via the {@link BackendSrv} * * @public */ type BackendSrvRequest = { /** * Request URL */ url: string; /** * Number of times to retry the remote call if it fails. */ retry?: number; /** * HTTP headers that should be passed along with the remote call. * Please have a look at {@link https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API | Fetch API} * for supported headers. */ headers?: Record<string, any>; /** * HTTP verb to perform in the remote call GET, POST, PUT etc. */ method?: string; /** * Set to false an success application alert box will not be shown for successful PUT, DELETE, POST requests */ showSuccessAlert?: boolean; /** * Set to false to not show an application alert box for request errors */ showErrorAlert?: boolean; /** * Provided by the initiator to identify a particular remote call. An example * of this is when a datasource plugin triggers a query. If the request id already * exist the backendSrv will try to cancel and replace the previous call with the * new one. */ requestId?: string; /** * Set to to true to not include call in query inspector */ hideFromInspector?: boolean; /** * The data to send */ data?: any; /** * Query params */ params?: Record<string, any>; /** * Define how the response object should be parsed. See: * * https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/Sending_and_Receiving_Binary_Data * * By default values are json parsed from text */ responseType?: 'json' | 'text' | 'arraybuffer' | 'blob'; /** * Used to cancel an open connection * https://developer.mozilla.org/en-US/docs/Web/API/AbortController */ abortSignal?: AbortSignal; /** * The credentials read-only property of the Request interface indicates whether the user agent should send cookies from the other domain in the case of cross-origin requests. */ credentials?: RequestCredentials; /** * @deprecated withCredentials is deprecated in favor of credentials */ withCredentials?: boolean; }; /** * Response for fetch function in {@link BackendSrv} * * @public */ interface FetchResponse<T = any> { data: T; readonly status: number; readonly statusText: string; readonly ok: boolean; readonly headers: Headers; readonly redirected: boolean; readonly type: ResponseType; readonly url: string; readonly config: BackendSrvRequest; readonly traceId?: string; } /** * Error type for fetch function in {@link BackendSrv} * * @public */ interface FetchErrorDataProps { message?: string; status?: string; error?: string | any; } /** * Error type for fetch function in {@link BackendSrv} * * @public */ interface FetchError<T = any> { status: number; statusText?: string; data: T; message?: string; cancelled?: boolean; isHandled?: boolean; config: BackendSrvRequest; traceId?: string; } declare function isFetchError<T = any>(e: unknown): e is FetchError<T>; /** * Used to communicate via http(s) to a remote backend such as the Grafana backend, * a datasource etc. The BackendSrv is using the {@link https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API | Fetch API} * under the hood to handle all the communication. * * The request function can be used to perform a remote call by specifying a {@link BackendSrvRequest}. * To make the BackendSrv a bit easier to use we have added a couple of shorthand functions that will * use default values executing the request. * * @remarks * By default, Grafana displays an error message alert if the remote call fails. To prevent this from * happening `showErrorAlert = true` on the options object. * * @public */ interface BackendSrv { get<T = any>(url: string, params?: any, requestId?: string, options?: Partial<BackendSrvRequest>): Promise<T>; delete<T = unknown>(url: string, data?: unknown, options?: Partial<BackendSrvRequest>): Promise<T>; post<T = any>(url: string, data?: unknown, options?: Partial<BackendSrvRequest>): Promise<T>; patch<T = any>(url: string, data?: unknown, options?: Partial<BackendSrvRequest>): Promise<T>; put<T = any>(url: string, data?: unknown, options?: Partial<BackendSrvRequest>): Promise<T>; /** * @deprecated Use the `.fetch()` function instead. If you prefer to work with a promise * wrap the Observable returned by fetch with the lastValueFrom function, or use the get|delete|post|patch|put methods. * This method is going to be private from Grafana 10. */ request<T = unknown>(options: BackendSrvRequest): Promise<T>; /** * Special function used to communicate with datasources that will emit core * events that the Grafana QueryInspector and QueryEditor is listening for to be able * to display datasource query information. Can be skipped by adding `option.silent` * when initializing the request. * * @deprecated Use the fetch function instead */ datasourceRequest<T = unknown>(options: BackendSrvRequest): Promise<FetchResponse<T>>; /** * Observable http request interface */ fetch<T>(options: BackendSrvRequest): Observable<FetchResponse<T>>; /** * Observe each raw chunk in the response. This is useful when reading values from * a long living HTTP connection like the kubernetes WATCH command. * * Each chunk includes the full response headers and the `data` property is filled with the chunk. */ chunked(options: BackendSrvRequest): Observable<FetchResponse<Uint8Array | undefined>>; } /** * Used during startup by Grafana to set the BackendSrv so it is available * via the {@link getBackendSrv} to the rest of the application. * * @internal */ declare const setBackendSrv: (instance: BackendSrv) => void; /** * Used to retrieve the {@link BackendSrv} that can be used to communicate * via http(s) to a remote backend such as the Grafana backend, a datasource etc. * * @public */ declare const getBackendSrv: () => BackendSrv; /** * Used to enable rendering of Angular components within a * React component without losing proper typings. * * @example * ```typescript * class Component extends PureComponent<Props> { * element: HTMLElement; * angularComponent: AngularComponent; * * componentDidMount() { * const template = '<angular-component />' // angular template here; * const scopeProps = { ctrl: angularController }; // angular scope properties here * const loader = getAngularLoader(); * this.angularComponent = loader.load(this.element, scopeProps, template); * } * * componentWillUnmount() { * if (this.angularComponent) { * this.angularComponent.destroy(); * } * } * * render() { * return ( * <div ref={element => (this.element = element)} /> * ); * } * } * ``` * * @public */ interface AngularComponent { /** * Should be called when the React component will unmount. */ destroy(): void; /** * Can be used to trigger a re-render of the Angular component. */ digest(): void; /** * Used to access the Angular scope from the React component. */ getScope(): any; } /** * Used to load an Angular component from the context of a React component. * Please see the {@link AngularComponent} for a proper example. * * @public */ interface AngularLoader { /** * * @param elem - the element that the Angular component will be loaded into. * @param scopeProps - values that will be accessed via the Angular scope. * @param template - template used by the Angular component. */ load(elem: any, scopeProps: any, template: string): AngularComponent; } /** * Used during startup by Grafana to set the AngularLoader so it is available * via the {@link getAngularLoader} to the rest of the application. * * @internal */ declare function setAngularLoader(v: AngularLoader): void; /** * Used to retrieve the {@link AngularLoader} that enables the use of Angular * components within a React component. * * Please see the {@link AngularComponent} for a proper example. * * @public */ declare function getAngularLoader(): AngularLoader; declare abstract class RuntimeDataSource<TQuery extends DataQuery = DataQuery> extends DataSourceApi<TQuery> { instanceSettings: DataSourceInstanceSettings; constructor(pluginId: string, uid: string); testDatasource(): Promise<TestDataSourceResponse>; } /** * This is the entry point for communicating with a datasource that is added as * a plugin (both external and internal). Via this service you will get access * to the {@link @grafana/data#DataSourceApi | DataSourceApi} that have a rich API for * communicating with the datasource. * * @public */ interface DataSourceSrv { /** * Returns the requested dataSource. If it cannot be found it rejects the promise. * @param ref - The datasource identifier, it can be a name, UID or DataSourceRef (an object with UID), * @param scopedVars - variables used to interpolate a templated passed as name. */ get(ref?: DataSourceRef | string | null, scopedVars?: ScopedVars): Promise<DataSourceApi>; /** * Get a list of data sources */ getList(filters?: GetDataSourceListFilters): DataSourceInstanceSettings[]; /** * Get settings and plugin metadata by name or uid */ getInstanceSettings(ref?: DataSourceRef | string | null, scopedVars?: ScopedVars): DataSourceInstanceSettings | undefined; /** * Reloads the DataSourceSrv */ reload(): void; /** * Registers a runtime data source. Make sure your data source uid is unique. */ registerRuntimeDataSource(entry: RuntimeDataSourceRegistration): void; } interface RuntimeDataSourceRegistration { dataSource: RuntimeDataSource; } /** @public */ interface GetDataSourceListFilters { /** Include mixed data source by setting this to true */ mixed?: boolean; /** Only return data sources that support metrics response */ metrics?: boolean; /** Only return data sources that support tracing response */ tracing?: boolean; /** Only return data sources that support logging response */ logs?: boolean; /** Only return data sources that support annotations */ annotations?: boolean; /** Only filter data sources that support alerting */ alerting?: boolean; /** * By default only data sources that can be queried will be returned. Meaning they have tracing, * metrics, logs or annotations flag set in plugin.json file * */ all?: boolean; /** Set to true to return dashboard data source */ dashboard?: boolean; /** Set to true to return data source variables */ variables?: boolean; /** filter list by plugin */ pluginId?: string; /** apply a function to filter */ filter?: (dataSource: DataSourceInstanceSettings) => boolean; /** Only returns datasources matching the specified types (ie. Loki, Prometheus) */ type?: string | string[]; } /** * Used during startup by Grafana to set the DataSourceSrv so it is available * via the {@link getDataSourceSrv} to the rest of the application. * * @internal */ declare function setDataSourceSrv(instance: DataSourceSrv): void; /** * Used to retrieve the {@link DataSourceSrv} that is the entry point for communicating with * a datasource that is added as a plugin (both external and internal). * * @public */ declare function getDataSourceSrv(): DataSourceSrv; /** * @public * @deprecated in favor of {@link locationService} and will be removed in Grafana 9 */ interface LocationUpdate { /** * Target path where you automatically wants to navigate the user. */ path?: string; /** * Specify this value if you want to add values to the query string of the URL. */ query?: UrlQueryMap; /** * If set to true, the query argument will be added to the existing URL. */ partial?: boolean; /** * Used internally to sync the Redux state from Angular to make sure that the Redux location * state is in sync when navigating using the Angular router. * * @remarks * Do not change this unless you are the Angular router. * * @internal */ routeParams?: UrlQueryMap; replace?: boolean; } /** * If you need to automatically navigate the user to a new place in the application this should * be done via the LocationSrv and it will make sure to update the application state accordingly. * * @public * @deprecated in favor of {@link locationService} and will be removed in Grafana 9 */ interface LocationSrv { update(options: LocationUpdate): void; } /** * Used during startup by Grafana to set the LocationSrv so it is available * via the {@link getLocationSrv} to the rest of the application. * * @internal */ declare function setLocationSrv(instance: LocationSrv): void; /** * Used to retrieve the {@link LocationSrv} that can be used to automatically navigate * the user to a new place in Grafana. * * @public * @deprecated in favor of {@link locationService} and will be removed in Grafana 9 */ declare function getLocationSrv(): LocationSrv; /** * Describes a size with width/height * * @public */ interface SizeMeta { width: number; height: number; } /** * Describes the meta information that are sent together with each event. * * @public */ interface EchoMeta { screenSize: SizeMeta; windowSize: SizeMeta; userAgent: string; url?: string; path?: string; /** * A unique browser session */ sessionId: string; /** * The current user's username used to login into Grafana e.g. email. */ userLogin: string; /** * The current user's unique identifier. */ userId: number; /** * True when user is logged in into Grafana. */ userSignedIn: boolean; /** * Current user's role */ orgRole: string | ''; /** * Current user's org */ orgId: number; /** * A millisecond epoch */ ts: number; /** * A highres timestamp since navigation start */ timeSinceNavigationStart: number; } /** * Describes echo backends that can be registered to receive of events. * * @public */ interface EchoBackend<T extends EchoEvent = any, O = any> { options: O; supportedEvents: EchoEventType[]; flush: () => void; addEvent: (event: T) => void; } /** * Describes an echo event. * * @public */ interface EchoEvent<T extends EchoEventType = any, P = any> { type: EchoEventType; /** * Event payload containing event specific data. */ payload: P; meta: EchoMeta; } /** * Supported echo event types that can be sent via the {@link EchoSrv}. * * @public */ declare enum EchoEventType { Performance = "performance", MetaAnalytics = "meta-analytics", Pageview = "pageview", Interaction = "interaction", ExperimentView = "experimentview", GrafanaJavascriptAgent = "grafana-javascript-agent" } /** * Used to send events to all the registered backends. This should be accessed via the * {@link getEchoSrv} function. Will, by default, flush events to the backends every * 10s or when the flush function is triggered. * * @public */ interface EchoSrv { /** * Call this to flush current events to the echo backends. */ flush(): void; /** * Add a new echo backend to the list of backends that will receive events. */ addBackend(backend: EchoBackend): void; /** * Call this to add event that will be sent to the echo backends upon next * flush. * * @param event - Object containing event information. * @param meta - Object that will extend/override the default meta object. */ addEvent<T extends EchoEvent>(event: Omit<T, 'meta'>, meta?: {}): void; } /** * Used during startup by Grafana to set the EchoSrv so it is available * via the {@link getEchoSrv} to the rest of the application. * * @internal */ declare function setEchoSrv(instance: EchoSrv): void; /** * Used to retrieve the {@link EchoSrv} that can be used to report events to registered * echo backends. * * @public */ declare function getEchoSrv(): EchoSrv; /** * Used to register echo backends that will receive Grafana echo events during application * runtime. * * @public */ declare const registerEchoBackend: (backend: EchoBackend) => void; declare class FakeEchoSrv implements EchoSrv { buffer: Array<{ event: Omit<EchoEvent, 'meta'>; meta?: {} | undefined; }>; flush(): void; addBackend(backend: EchoBackend): void; addEvent<T extends EchoEvent>(event: Omit<T, 'meta'>, meta?: {} | undefined): void; } /** * Can be used to gain more information about an interpolation operation */ interface VariableInterpolation { /** The full matched expression including, example: ${varName.field:regex} */ match: string; /** In the expression ${varName.field:regex} variableName is varName */ variableName: string; /** In the expression ${varName.fields[0].name:regex} the fieldPath is fields[0].name */ fieldPath?: string; /** In the expression ${varName:regex} the regex part is the format */ format?: string; /** The formatted value of the variable expresion. Will equal match when variable not found or scopedVar was undefined or null **/ value: string; found?: boolean; } /** * Via the TemplateSrv consumers get access to all the available template variables * that can be used within the current active dashboard. * * For a more in-depth description visit: https://grafana.com/docs/grafana/latest/reference/templating * @public */ interface TemplateSrv { /** * List the dashboard variables */ getVariables(): TypedVariableModel[]; /** * Replace the values within the target string. See also {@link InterpolateFunction} * * Note: interpolations array is being mutated by replace function by adding information about variables that * have been interpolated during replacement. Variables that were specified in the target but not found in * the list of available variables are also added to the array. See {@link VariableInterpolation} for more details. * * @param {VariableInterpolation[]} interpolations an optional map that is updated with interpolated variables */ replace(target?: string, scopedVars?: ScopedVars, format?: string | Function, interpolations?: VariableInterpolation[]): string; /** * Checks if a target contains template variables. */ containsTemplate(target?: string): boolean; /** * Update the current time range to be used when interpolating __from / __to variables. */ updateTimeRange(timeRange: TimeRange): void; } /** * Used during startup by Grafana to set the TemplateSrv so it is available * via the {@link getTemplateSrv} to the rest of the application. * * @internal */ declare const setTemplateSrv: (instance: TemplateSrv) => void; /** * Used to retrieve the {@link TemplateSrv} that can be used to fetch available * template variables. * * @public */ declare const getTemplateSrv: () => TemplateSrv; /** * Used during startup by Grafana to temporarily expose the angular injector to * pure javascript plugins using {@link getLegacyAngularInjector}. * * @internal */ declare const setLegacyAngularInjector: (instance: auto.IInjectorService) => void; /** * WARNING: this function provides a temporary way for plugins to access anything in the * angular injector. While the migration from angular to react continues, there are a few * options that do not yet have good alternatives. Note that use of this function will * be removed in the future. * * @beta */ declare const getLegacyAngularInjector: () => auto.IInjectorService; /** * @alpha -- experimental */ interface LiveDataFilter { fields?: string[]; } /** * @alpha */ interface LiveDataStreamOptions { addr: LiveChannelAddress; frame?: DataFrameJSON; key?: string; buffer?: Partial<StreamingFrameOptions>; filter?: LiveDataFilter; } /** * @alpha -- experimental: send a normal query request over websockt */ interface LiveQueryDataOptions { request: DataQueryRequest; body: unknown; } /** * @alpha -- experimental */ interface GrafanaLiveSrv { /** * Listen for changes to the main service */ getConnectionState(): Observable<boolean>; /** * Watch for messages in a channel */ getStream<T>(address: LiveChannelAddress): Observable<LiveChannelEvent<T>>; /** * Connect to a channel and return results as DataFrames */ getDataStream(options: LiveDataStreamOptions): Observable<DataQueryResponse>; /** * Execute a query over the live websocket and potentiall subscribe to a live channel. * * Since the initial request and subscription are on the same socket, this will support HA setups * * @alpha -- this function requires the feature toggle `queryOverLive` to be set */ getQueryData(options: LiveQueryDataOptions): Observable<DataQueryResponse>; /** * For channels that support presence, this will request the current state from the server. * * Join and leave messages will be sent to the open stream */ getPresence(address: LiveChannelAddress): Promise<LiveChannelPresenceStatus>; /** * Publish into a channel * * @alpha -- experimental */ publish(address: LiveChannelAddress, data: unknown): Promise<unknown>; } /** * Used during startup by Grafana to set the GrafanaLiveSrv so it is available * via the {@link getGrafanaLiveSrv} to the rest of the application. * * @internal */ declare const setGrafanaLiveSrv: (instance: GrafanaLiveSrv) => void; /** * Used to retrieve the GrafanaLiveSrv that allows you to subscribe to * server side events and streams * * @alpha -- experimental */ declare const getGrafanaLiveSrv: () => GrafanaLiveSrv; /** * @public * A wrapper to help work with browser location and history */ interface LocationService { partial: (query: Record<string, any>, replace?: boolean) => void; push: (location: H.Path | H.LocationDescriptor<any>) => void; replace: (location: H.Path | H.LocationDescriptor<any>) => void; reload: () => void; getLocation: () => H.Location; getHistory: () => H.History; getSearch: () => URLSearchParams; getSearchObject: () => UrlQueryMap; getLocationObservable: () => Observable<H.Location>; /** * This is from the old LocationSrv interface * @deprecated use partial, push or replace instead */ update: (update: LocationUpdate) => void; } /** @internal */ declare class HistoryWrapper implements LocationService { private readonly history; private locationObservable; constructor(history?: H.History); getLocationObservable(): Observable<H.Location<unknown>>; getHistory(): H.History<unknown>; getSearch(): URLSearchParams; partial(query: Record<string, any>, replace?: boolean): void; push(location: H.Path | H.LocationDescriptor): void; replace(location: H.Path | H.LocationDescriptor): void; reload(): void; getLocation(): H.Location<unknown>; getSearchObject(): UrlQueryMap; /** @deprecated use partial, push or replace instead */ update(options: LocationUpdate): void; } /** * @public * Parses a location search string to an object * */ declare function locationSearchToObject(search: string | number): UrlQueryMap; /** * @public */ declare let locationService: LocationService; /** * Used for tests only * @internal */ declare const setLocationService: (location: LocationService) => void; /** @internal */ declare const navigationLogger: (message?: any, ...optionalParams: any[]) => void; declare function useLocationService(): LocationService; declare const LocationServiceProvider: React__default.FC<{ service: LocationService; children: React__default.ReactNode; }>; /** * Called when a dashboard is refreshed * * @public */ declare class RefreshEvent extends BusEventBase { static type: string; } /** * Called when the theme settings change * * @public */ declare class ThemeChangedEvent extends BusEventWithPayload<GrafanaTheme2> { static type: string; } /** * Called when time range is updated * * @public */ declare class TimeRangeUpdatedEvent extends BusEventWithPayload<TimeRange> { static type: string; } /** * Called to copy a panel JSON into local storage * * @public */ declare class CopyPanelEvent extends BusEventWithPayload<PanelModel> { static type: string; } /** * Used during startup by Grafana to set the setAppEvents so it is available * via the {@link setAppEvents} to the rest of the application. * * @internal */ declare function setAppEvents(instance: EventBus): void; /** * Used to retrieve an event bus that manages application level events * * @public */ declare function getAppEvents(): EventBus; /** * This is a service that handles state and operation of a sidecar feature (sideview to render a second app in grafana). * At this moment this is highly experimental and if used should be understood to break easily with newer versions. * None of this functionality works without a feature toggle `appSidecar` being enabled. * * Right now this being in a single service is more of a practical tradeoff for easier isolation in the future these * APIs may be integrated into other services or features like app extensions, plugin system etc. * * @experimental */ declare class SidecarService_EXPERIMENTAL { private _initialContext; private sidecarLocationService; private mainLocationService; private follow; private mainLocationWhenOpened; private mainOnAllowedRoute; constructor(mainLocationService: LocationService); private assertFeatureEnabled; private updateMainLocationWhenOpened; /** * Every time the main location changes we check if we should keep the sidecar open or close it based on list * of allowed routes and also based on the follow flag when opening the app. */ private handleMainLocationChanges; /** * Get current app id of the app in sidecar. This is most probably provisional. In the future * this should be driven by URL addressing so that routing for the apps don't change. Useful just internally * to decide which app to render. * * @experimental */ get activePluginIdObservable(): Observable<string | undefined>; /** * Get initial context which is whatever data was passed when calling the 'openApp' function. This is meant as * a way for the app to initialize it's state based on some context that is passed to it from the primary app. * * @experimental */ get initialContextObservable(): Observable<unknown>; get initialContext(): unknown; /** * @experimental */ get activePluginId(): string | undefined; getLocationService(): LocationService; /** * Opens an app in a sidecar. You can also pass some context object that will be then available to the app. * @deprecated * @experimental */ openApp(pluginId: string, context?: unknown): void; /** * Opens an app in a sidecar. You can also relative path inside the app to open. * @deprecated * @experimental */ openAppV2(pluginId: string, path?: string): void; /** * Opens an app in a sidecar. You can also relative path inside the app to open. * @param options.pluginId Plugin ID of the app to open * @param options.path Relative path inside the app to open * @param options.follow If true, the sidecar will stay open even if the main location change to another app or * Grafana section * * @experimental */ openAppV3(options: { pluginId: string; path?: string; follow?: boolean; }): void; /** * @experimental */ closeApp(): void; /** * This is mainly useful inside an app extensions which are executed outside the main app context but can work * differently depending on whether their app is currently rendered or not. * * This is also true only in case a sidecar is opened. In other cases, just to check if a single app is opened * probably does not make sense. * * This means these are the states and the result of this function: * Single app is opened: false (may seem strange from considering the function name, but the main point of * this is to recognize when the app needs to do specific alteration in context of running next to second app) * 2 apps are opened and pluginId is the one in the main window: true * 2 apps are opened and pluginId is the one in the sidecar window: true * 2 apps are opened and pluginId is not one of those: false * * @experimental */ isAppOpened(pluginId: string): boolean; } declare const sidecarServiceSingleton_EXPERIMENTAL: SidecarService_EXPERIMENTAL; declare const SidecarContext_EXPERIMENTAL: React$1.Context<SidecarService_EXPERIMENTAL>; /** * This is the main way to interact with the sidecar service inside a react context. It provides a wrapper around the * service props so that even though they are observables we just pass actual values to the components. * * @experimental */ declare function useSidecar_EXPERIMENTAL(): { activePluginId: string | undefined; initialContext: unknown; locationService: LocationService; openApp: (pluginId: string, context?: unknown) => void; openAppV2: (pluginId: string, path?: string) => void; openAppV3: (options: { pluginId: string; path?: string; follow?: boolean; }) => void; closeApp: () => void; isAppOpened: (pluginId: string) => boolean; }; type GetPluginExtensions<T = PluginExtension> = (options: GetPluginExtensionsOptions) => GetPluginExtensionsResult<T>; type UsePluginExtensions<T = PluginExtension> = (options: GetPluginExtensionsOptions) => UsePluginExtensionsResult<T>; type GetPluginExtensionsOptions = { extensionPointId: string; context?: object | Record<string | symbol, unknown>; limitPerPlugin?: number; }; type GetPluginExtensionsResult<T = PluginExtension> = { extensions: T[]; }; type UsePluginExtensionsResult<T = PluginExtension> = { extensions: T[]; isLoading: boolean; }; declare function setPluginExtensionGetter(instance: GetPluginExtensions): void; declare const getPluginExtensions: GetPluginExtensions; declare const getPluginLinkExtensions: GetPluginExtensions<PluginExtensionLink>; declare const getPluginComponentExtensions: <Props = {}>(options: { extensionPointId: string; limitPerPlugin?: number; }) => { extensions: Array<PluginExtensionComponent<Props>>; }; declare function setPluginExtensionsHook(hook: UsePluginExtensions): void; /** * @deprecated Use either usePluginLinks() or usePluginComponents() instead. */ declare function usePluginExtensions(options: GetPluginExtensionsOptions): UsePluginExtensionsResult; /** * @deprecated Use usePluginLinks() instead. */ declare function usePluginLinkExtensions(options: GetPluginExtensionsOptions): UsePluginExtensionsResult<PluginExtensionLink>; /** * @deprecated Use usePluginComponents() instead. */ declare function usePluginComponentExtensions<Props = {}>(options: GetPluginExtensionsOptions): { extensions: Array<PluginExtensionComponent<Props>>; isLoading: boolean; }; type UsePluginComponent<Props extends object = {}> = (componentId: string) => UsePluginComponentResult<Props>; type UsePluginComponentResult<Props = {}> = { component: React.ComponentType<Props> | undefined | null; isLoading: boolean; }; declare function setPluginComponentHook(hook: UsePluginComponent): void; declare function usePluginComponent<Props extends object = {}>(componentId: string): UsePluginComponentResult<Props>; type UsePluginComponentsOptions = { extensionPointId: string; limitPerPlugin?: number; }; type UsePluginComponentsResult<Props = {}> = { components: Array<ComponentTypeWithExtensionMeta<Props>>; isLoading: boolean; }; type UsePluginComponents<Props extends object = {}> = (options: UsePluginComponentsOptions) => UsePluginComponentsResult<Props>; declare function setPluginComponentsHook(hook: UsePluginComponents): void; declare function usePluginComponents<Props extends object = {}>(options: UsePluginComponentsOptions): UsePluginComponentsResult<Props>; type UsePluginLinksOptions = { extensionPointId: string; context?: object | Record<string | symbol, unknown>; limitPerPlugin?: number; }; type UsePluginLinksResult = { isLoading: boolean; links: PluginExtensionLink[]; }; type UsePluginLinks = (options: UsePluginLinksOptions) => UsePluginLinksResult; declare function setPluginLinksHook(hook: UsePluginLinks): void; declare function usePluginLinks(options: UsePluginLinksOptions): UsePluginLinksResult; type UsePluginFunctionsOptions = { extensionPointId: string; limitPerPlugin?: number; }; type UsePluginFunctionsResult<Signature> = { isLoading: boolean; functions: Array<PluginExtensionFunction<Signature>>; }; type UsePluginFunctions<T> = (options: UsePluginFunctionsOptions) => UsePluginFunctionsResult<T>; declare function setPluginFunctionsHook(hook: UsePluginFunctions<unknown>): void; declare function usePluginFunctions<T>(options: UsePluginFunctionsOptions): UsePluginFunctionsResult<T>; declare function isPluginExtensionLink(extension: PluginExtension | undefined): extension is PluginExtensionLink; declare function isPluginExtensionComponent(extension: PluginExtension | undefined): extension is PluginExtensionComponent; /** * Used during startup by Grafana to set the current user so it is available * for rbac checks. * * @internal */ declare function setCurrentUser(instance: CurrentUser): void; interface ScopesContextValueState { drawerOpened: boolean; enabled: boolean; loading: boolean; readOnly: boolean; value: Scope[]; } interface ScopesContextValue { /** * Current state. */ state: ScopesContextValueState; /** * Observable that emits the current state. */ stateObservable: Observable<ScopesContextValue['state']>; /** * Change the selected scopes. The service takes care about loading them and propagating the changes. * @param scopeNames */ changeScopes(scopeNames: string[]): void; /** * Set read-only mode. * If `readOnly` is `true`, the selector will be set to read-only and the dashboards panel will be closed. */ setReadOnly(readOnly: boolean): void; /** * Enable or disable the usage of scopes. * This will hide the selector and the dashboards panel, and it will stop propagating the scopes to the query object. */ setEnabled(enabled: boolean): void; } declare const ScopesContext: React$1.Context<ScopesContextValue | undefined>; declare function useScopes(): ScopesContextValue | undefined; interface AzureSettings { cloud?: string; clouds?: AzureCloudInfo[]; managedIdentityEnabled: boolean; workloadIdentityEnabled: boolean; userIdentityEnabled: boolean; userIdentityFallbackCredentialsEnabled: boolean; azureEntraPasswordCredentialsEnabled: boolean; } interface AzureCloudInfo { name: string; displayName: string; } type AppPluginConfig = { id: string; path: string; version: string; preload: boolean; angular: AngularMeta; loadingStrategy: PluginLoadingStrategy; dependencies: PluginDependencies; extensions: PluginExtensions; moduleHash?: string; }; type PreinstalledPlugin = { id: string; version: string; }; declare class GrafanaBootConfig implements GrafanaConfig { publicDashboardAccessToken?: string; publicDashboardsEnabled: boolean; snapshotEnabled: boolean; datasources: { [str: string]: DataSourceInstanceSettings; }; panels: { [key: string]: PanelPluginMeta; }; apps: Record<string, AppPluginConfig>; auth: AuthSettings; minRefreshInterval: string; appUrl: string; appSubUrl: string; namespace: string; windowTitlePrefix: string; buildInfo: BuildInfo; newPanelTitle: string; bootData: BootData; externalUserMngLinkUrl: string; externalUserMngLinkName: string; externalUserMngInfo: string; externalUserMngAnalytics: boolean; externalUserMngAnalyticsParams: string; allowOrgCreate: boolean; feedbackLinksEnabled: boolean; disableLoginForm: boolean; defaultDatasource: string; angularSupportEnabled: boolean; authProxyEnabled: boolean; exploreEnabled: boolean; queryHistoryEnabled: boolean; helpEnabled: boolean; profileEnabled: boolean; newsFeedEnabled: boolean; ldapEnabled: boolean; jwtHeaderName: string; jwtUrlLogin: boolean; sigV4AuthEnabled: boolean; azureAuthEnabled: boolean; secureSocksDSProxyEnabled: boolean; samlEnabled: boolean; samlName: string; autoAssignOrg: boolean; verifyEmailEnabled: boolean; oauth: OAuthSettings; rbacEnabled: boolean; disableUserSignUp: boolean; loginHint: string; passwordHint: string; loginError: string | undefined; viewersCanEdit: boolean; editorsCanAdmin: boolean; disableSanitizeHtml: boolean; trustedTypesDefaultPolicyEnabled: boolean; cspReportOnlyEnabled: boolean; liveEnabled: boolean; /** @deprecated Use `theme2` instead. */ theme: GrafanaTheme; theme2: GrafanaTheme2; featureToggles: FeatureToggles; anonymousEnabled: boolean; anonymousDeviceLimit: number | undefined; licenseInfo: LicenseInfo; rendererAvailable: boolean; rendererVersion: string; rendererDefaultImageWidth: number; rendererDefaultImageHeight: number; rendererDefaultImageScale: number; secretsManagerPluginEnabled: boolean; supportBundlesEnabled: boolean; http2Enabled: boolean; dateFormats?: SystemDateFormatSettings; grafanaJavascriptAgent: { enabled: boolean; customEndpoint: string; apiKey: string; allInstrumentationsEnabled: boolean; errorInstrumentalizationEnabled: boolean; consoleInstrumentalizationEnabled: boolean; webVitalsInstrumentalizationEnabled: boolean; tracingInstrumentalizationEnabled: boolean; }; pluginCatalogURL: string; pluginAdminEnabled: boolean; pluginAdminExternalManageEnabled: boolean; pluginCatalogHiddenPlugins: string[]; pluginCatalogManagedPlugins: string[]; pluginCatalogPreinstalledPlugins: PreinstalledPlugin[]; pluginsCDNBaseURL: string; expressionsEnabled: boolean; awsAllowedAuthProviders: string[]; awsAssumeRoleEnabled: boolean; azure: AzureSettings; caching: { enabled: boolean; }; geomapDefaultBaseLayerConfig?: MapLayerOptions; geomapDisableCustomBaseLayer?: boolean; unifiedAlertingEnabled: boolean; unifiedAlerting: { minInterval: string; alertStateHistoryBackend: undefined; alertStateHistoryPrimary: undefined; }; applicationInsightsConnectionString?: string; applicationInsightsEndpointUrl?: string; recordedQueries: { enabled: boolean; }; featureHighlights: { enabled: boolean; }; reporting: { enabled: boolean; }; analytics: { enabled: boolean; }; googleAnalyticsId: undefined; googleAnalytics4Id: undefined; googleAnalytics4SendManualPageViews: boolean; rudderstackWriteKey: undefined; rudderstackDataPlaneUrl: undefined; rudderstackSdkUrl: undefined; rudderstackConfigUrl: undefined; rudderstackIntegrationsUrl: undefined; analyticsConsoleReporting: boolean; dashboardPerformanceMetrics: string[]; sqlConnectionLimits: { maxOpenConns: number; maxIdleConns: number; connMaxLifetime: number; }; defaultDatasourceManageAlertsUiToggle: boolean; tokenExpirationDayLimit: undefined; enableFrontendSandboxForPlugins: string[]; sharedWithMeFolderUID: string | undefined; rootFolderUID: string | undefined; localFileSystemAvailable: boolean | undefined; cloudMigrationIsTarget: boolean | undefined; cloudMigrationFeedbackURL: string; cloudMigrationPollIntervalMs: number; reportingStaticContext?: Record<string, string>; exploreDefaultTimeOffset: string; exploreHideLogsDownload: boolean | undefined; /** * Language used in Grafana's UI. This is after the user's preference (or deteceted locale) is resolved to one of * Grafana's supported language. */ language: string | undefined; constructor(options: GrafanaBootConfig); } /** * Use this to access the {@link GrafanaBootConfig} for the current running Grafana instance. * * @public */ declare const config: GrafanaBootConfig; /** * Describes the basic dashboard information that can be passed as the meta * analytics payload. * * @public */ interface DashboardInfo { /** @deprecated -- use UID not internal ID */ dashboardId: number; dashboardUid: string; dashboardName: string; folderName?: string; } /** * Describes the data request information passed as the meta analytics payload. * * @public */ interface DataRequestInfo extends Partial<DashboardInfo> { source?: CoreApp | string; datasourceName: string; datasourceId: number; datasourceUid: string; datasourceType: string; panelId?: number; panelPluginId?: string; panelName?: string; duration: number; error?: string; dataSize?: number; } /** * The meta analytics events that can be added to the echo service. * * @public */ declare enum MetaAnalyticsEventName { DashboardView = "dashboard-view", DataRequest = "data-request" } /** * Describes the payload of a dashboard view event. * * @public */ interface DashboardViewEventPayload extends DashboardInfo { eventName: MetaAnalyticsEventName.DashboardView; } /** * Describes the payload of a data request event. * * @public */ interface DataRequestEventPayload extends DataRequestInfo { eventName: MetaAnalyticsEventName.DataRequest; totalQueries?: number; cachedQueries?: number; } /** * Describes the meta analytics payload passed with the {@link MetaAnalyticsEvent} * * @public */ type MetaAnalyticsEventPayload = DashboardViewEventPayload | DataRequestEventPayload; /** * Describes meta analytics event with predefined {@link EchoEventType.EchoEventType} type. * * @public */ interface MetaAnalyticsEvent extends EchoEvent<EchoEventType.MetaAnalytics, MetaAnalyticsEventPayload> { } /** * Describes the payload of a pageview event. * * @public */ interface PageviewEchoEventPayload { page: string; } /** * Describes pageview event with predefined {@link EchoEventType.EchoEventType} type. * * @public */ type PageviewEchoEvent = EchoEvent<EchoEventType.Pageview, PageviewEchoEventPayload>; /** * Describes the payload of a user interaction event. * * @public */ interface InteractionEchoEventPayload { interactionName: string; properties?: Record<string, any>; } /** * Describes interaction event with predefined {@link EchoEventType.EchoEventType} type. * * @public */ type InteractionEchoEvent = EchoEvent<EchoEventType.Interaction, InteractionEchoEventPayload>; /** * Describes the payload of an experimentview event. * * @public */ interface ExperimentViewEchoEventPayload { experimentId: string; experimentGroup: string; experimentVariant: string; } /** * Describes experimentview event with predefined {@link EchoEventType.EchoEventType} type. * * @public */ type ExperimentViewEchoEvent = EchoEvent<EchoEventType.ExperimentView, ExperimentViewEchoEventPayload>; /** * Pageview event typeguard. * * @public */ declare const isPageviewEvent: (event: EchoEvent) => event is PageviewEchoEvent; /** * Interaction event typeguard. * * @public */ declare const isInteractionEvent: (event: EchoEvent) => event is InteractionEchoEvent; /** * Experimentview event typeguard. * * @public */ declare const isExperimentViewEvent: (event: EchoEvent) => event is ExperimentViewEchoEvent; /** * Option to specify a plugin css that should be applied for the dark * and the light theme. * * @public */ interface PluginCssOptions { light: string; dark: string; } /** * Use this to load css for a Grafana plugin by specifying a {@link PluginCssOptions} * containing styling for the dark and the light theme. * * @param options - plugin styling for light and dark theme. * @public */ declare function loadPluginCss(options: PluginCssOptions): Promise<System.Module | void>; interface PluginImportUtils { importPanelPlugin: (id: string) => Promise<PanelPlugin>; getPanelPluginFromCache: (id: string) => PanelPlugin | undefined; } declare function setPluginImportUtils(utils: PluginImportUtils): void; declare function getPluginImportUtils(): PluginImportUtils; /** * Helper function to report meta analytics to the {@link EchoSrv}. * * @public */ declare const reportMetaAnalytics: (payload: MetaAnalyticsEventPayload) => void; /** * Helper function to report pageview events to the {@link EchoSrv}. * * @public */ declare const reportPageview: () => void; /** * Helper function to report interaction events to the {@link EchoSrv}. * * @public */ declare const reportInteraction: (interactionName: string, properties?: Record<string, unknown>) => void; /** * Helper function to report experimentview events to the {@link EchoSrv}. * * @public */ declare const reportExperimentView: (id: string, group: string, variant: string) => void; declare const featureEnabled: (feature: string) => boolean; /** * Log a message at INFO level * @public */ declare function logInfo(message: string, contexts?: LogContext): void; /** * Log a message at WARNING level * * @public */ declare function logWarning(message: string, contexts?: LogContext): void; /** * Log a message at DEBUG level * * @public */ declare function logDebug(message: string, contexts?: LogContext): void; /** * Log an error * * @public */ declare function logError(err: Error, contexts?: LogContext): void; /** * Log a measurement * * @public */ type MeasurementValues = Record<string, number>; declare function logMeasurement(type: string, values: MeasurementValues, context?: LogContext): void; interface MonitoringLogger { logDebug: (message: string, contexts?: LogContext) => void; logInfo: (message: string, contexts?: LogContext) => void; logWarning: (message: string, contexts?: LogContext) => void; logError: (error: Error, contexts?: LogContext) => void; logMeasurement: (type: string, measurement: MeasurementValues, contexts?: LogContext) => void; } /** * Creates a monitoring logger with five levels of logging methods: `logDebug`, `logInfo`, `logWarning`, `logError`, and `logMeasurement`. * These methods use `faro.api.pushX` web SDK methods to report these logs or errors to the Faro collector. * * @param {string} source - Identifier for the source of the log messages. * @param {LogContext} [defaultContext] - Context to be included in every log message. * * @returns {MonitoringLogger} Logger object with five methods: * - `logDebug(message: string, contexts?: LogContext)`: Logs a debug message. * - `logInfo(message: string, contexts?: LogContext)`: Logs an informational message. * - `logWarning(message: string, contexts?: LogContext)`: Logs a warning message. * - `logError(error: Error, contexts?: LogContext)`: Logs an error message. * - `logMeasurement(measurement: Omit<Measureme