Transforms: Fix schema definition (#62619)

This commit is contained in:
Ryan McKinley
2023-01-31 10:03:08 -08:00
committed by GitHub
parent 91221bc436
commit 4186871390
9 changed files with 58 additions and 64 deletions

View File

@@ -1,6 +1,6 @@
import { MonoTypeOperatorFunction } from 'rxjs';
import { MatcherConfig } from '@grafana/schema';
import { MatcherConfig, DataTransformerConfig } from '@grafana/schema';
import { RegistryItemWithOptions } from '../utils/Registry';
@@ -41,27 +41,9 @@ export interface SynchronousDataTransformerInfo<TOptions = any> extends DataTran
}
/**
* @public
* @deprecated use TransformationConfig from schema
*/
export interface DataTransformerConfig<TOptions = any> {
/**
* Unique identifier of transformer
*/
id: string;
/**
* Disabled transformations are skipped
*/
disabled?: boolean;
/** Optional frame matcher. When missing it will be applied to all results */
filter?: MatcherConfig;
/**
* Options to be passed to the transformer
*/
options: TOptions;
}
export type { DataTransformerConfig };
export type FrameMatcher = (frame: DataFrame) => boolean;
export type FieldMatcher = (field: Field, frame: DataFrame, allFrames: DataFrame[]) => boolean;

View File

@@ -25,7 +25,6 @@ export type {
RegexMap,
SpecialValueMap,
ValueMappingResult,
Transformation,
LibraryPanelRef,
RowPanel,
GraphPanel,
@@ -44,7 +43,6 @@ export {
defaultThresholdsConfig,
MappingType,
SpecialValueMatch,
defaultTransformation,
DashboardCursorSync,
defaultDashboardCursorSync,
defaultRowPanel
@@ -63,6 +61,7 @@ export type {
Dashboard,
VariableModel,
DataSourceRef,
DataTransformerConfig,
Panel,
FieldConfigSource,
MatcherConfig,

View File

@@ -353,22 +353,27 @@ export interface ValueMappingResult {
/**
* TODO docs
* FIXME this is extremely underspecfied; wasn't obvious which typescript types corresponded to it
*/
export interface Transformation {
export interface DataTransformerConfig {
/**
* only apply to some frames
* Disabled transformations are skipped
*/
disabled?: boolean;
/**
* Optional frame matcher. When missing it will be applied to all results
*/
filter?: MatcherConfig;
hide: boolean;
/**
* Unique identifier of transformer
*/
id: string;
options: Record<string, unknown>;
/**
* Options to be passed to the transformer
* Valid options depend on the transformer id
*/
options: unknown;
}
export const defaultTransformation: Partial<Transformation> = {
hide: false,
};
/**
* 0 for no shared crosshair or tooltip (default).
* 1 for shared crosshair.
@@ -479,7 +484,7 @@ export interface Panel {
* Panel title.
*/
title?: string;
transformations: Array<Transformation>;
transformations: Array<DataTransformerConfig>;
/**
* Whether to display the panel without a background.
*/

View File

@@ -47,6 +47,10 @@ export interface MatcherConfig<TConfig = any> extends raw.MatcherConfig {
options?: TConfig;
}
export interface DataTransformerConfig<TOptions = any> extends raw.DataTransformerConfig {
options: TOptions;
}
export const defaultDashboard = raw.defaultDashboard as Dashboard;
export const defaultVariableModel = {
...raw.defaultVariableModel,