mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
DataSourceApi: convert interface to abstract class (#16979)
* DataSourceApi as class * add diff signature * Prometheus: moved directUrl to jsonData
This commit is contained in:
committed by
Torkel Ödegaard
parent
5573d28582
commit
1d7bb2a763
@@ -117,15 +117,30 @@ export interface DataSourceConstructor<
|
||||
/**
|
||||
* The main data source abstraction interface, represents an instance of a data source
|
||||
*/
|
||||
export interface DataSourceApi<
|
||||
export abstract class DataSourceApi<
|
||||
TQuery extends DataQuery = DataQuery,
|
||||
TOptions extends DataSourceJsonData = DataSourceJsonData
|
||||
> {
|
||||
/**
|
||||
* Set in constructor
|
||||
*/
|
||||
readonly name: string;
|
||||
|
||||
/**
|
||||
* Set in constructor
|
||||
*/
|
||||
readonly id: number;
|
||||
|
||||
/**
|
||||
* min interval range
|
||||
*/
|
||||
interval?: string;
|
||||
|
||||
constructor(instanceSettings: DataSourceInstanceSettings<TOptions>) {
|
||||
this.name = instanceSettings.name;
|
||||
this.id = instanceSettings.id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Imports queries from a different datasource
|
||||
*/
|
||||
@@ -139,12 +154,12 @@ export interface DataSourceApi<
|
||||
/**
|
||||
* Main metrics / data query action
|
||||
*/
|
||||
query(options: DataQueryRequest<TQuery>, observer?: DataStreamObserver): Promise<DataQueryResponse>;
|
||||
abstract query(options: DataQueryRequest<TQuery>, observer?: DataStreamObserver): Promise<DataQueryResponse>;
|
||||
|
||||
/**
|
||||
* Test & verify datasource settings & connection details
|
||||
*/
|
||||
testDatasource(): Promise<any>;
|
||||
abstract testDatasource(): Promise<any>;
|
||||
|
||||
/**
|
||||
* Get hints for query improvements
|
||||
@@ -156,16 +171,6 @@ export interface DataSourceApi<
|
||||
*/
|
||||
getQueryDisplayText?(query: TQuery): string;
|
||||
|
||||
/**
|
||||
* Set after constructor is called by Grafana
|
||||
*/
|
||||
name?: string;
|
||||
|
||||
/**
|
||||
* Set after constructor is called by Grafana
|
||||
*/
|
||||
id?: number;
|
||||
|
||||
/**
|
||||
* Set after constructor call, as the data source instance is the most common thing to pass around
|
||||
* we attach the components to this instance for easy access
|
||||
@@ -178,7 +183,7 @@ export interface DataSourceApi<
|
||||
meta?: DataSourcePluginMeta;
|
||||
}
|
||||
|
||||
export interface ExploreDataSourceApi<
|
||||
export abstract class ExploreDataSourceApi<
|
||||
TQuery extends DataQuery = DataQuery,
|
||||
TOptions extends DataSourceJsonData = DataSourceJsonData
|
||||
> extends DataSourceApi<TQuery, TOptions> {
|
||||
|
||||
@@ -59,6 +59,7 @@ export interface DateTime extends Object {
|
||||
subtract: (amount?: DateTimeInput, unit?: DurationUnit) => DateTime;
|
||||
toDate: () => Date;
|
||||
toISOString: () => string;
|
||||
diff: (amount: DateTimeInput, unit?: DurationUnit, truncate?: boolean) => number;
|
||||
valueOf: () => number;
|
||||
unix: () => number;
|
||||
utc: () => DateTime;
|
||||
|
||||
Reference in New Issue
Block a user