The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
grafana/packages/grafana-runtime/src/services/pluginExtensions/extensions.ts

34 lines
851 B

import { getPluginsExtensionRegistry, PluginsExtension } from './registry';
export type GetPluginExtensionsOptions = {
target: string;
};
export type PluginExtensionsResult = {
extensions: PluginsExtension[];
error?: Error;
};
export class PluginExtensionsMissingError extends Error {
readonly target: string;
constructor(target: string) {
super(`Could not find extensions for '${target}'`);
this.target = target;
this.name = PluginExtensionsMissingError.name;
}
}
export function getPluginExtensions({ target }: GetPluginExtensionsOptions): PluginExtensionsResult {
const registry = getPluginsExtensionRegistry();
const extensions = registry[target];
if (!Array.isArray(extensions)) {
return {
extensions: [],
error: new PluginExtensionsMissingError(target),
};
}
return { extensions };
}