mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Transforms: Fix schema definition (#62619)
This commit is contained in:
parent
91221bc436
commit
4186871390
@ -575,8 +575,7 @@ exports[`better eslint`] = {
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "2"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "3"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "4"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "5"]
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "4"]
|
||||
],
|
||||
"packages/grafana-data/src/types/variables.ts:5381": [
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
|
||||
@ -974,8 +973,9 @@ exports[`better eslint`] = {
|
||||
"packages/grafana-schema/src/veneer/dashboard.types.ts:5381": [
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "2"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "3"]
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "2"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "3"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "4"]
|
||||
],
|
||||
"packages/grafana-toolkit/src/cli/tasks/component.create.ts:5381": [
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
|
||||
|
@ -283,13 +283,18 @@ lineage: seqs: [
|
||||
} @cuetsy(kind="interface")
|
||||
|
||||
// TODO docs
|
||||
// FIXME this is extremely underspecfied; wasn't obvious which typescript types corresponded to it
|
||||
#Transformation: {
|
||||
id: string
|
||||
hide: bool | *false
|
||||
// only apply to some frames
|
||||
#DataTransformerConfig: {
|
||||
@grafana(TSVeneer="type")
|
||||
|
||||
// Unique identifier of transformer
|
||||
id: string
|
||||
// Disabled transformations are skipped
|
||||
disabled?: bool
|
||||
// Optional frame matcher. When missing it will be applied to all results
|
||||
filter?: #MatcherConfig
|
||||
options: {...}
|
||||
// Options to be passed to the transformer
|
||||
// Valid options depend on the transformer id
|
||||
options: _
|
||||
} @cuetsy(kind="interface") @grafanamaturity(NeedsExpertReview)
|
||||
|
||||
// 0 for no shared crosshair or tooltip (default).
|
||||
@ -386,7 +391,7 @@ lineage: seqs: [
|
||||
// TODO docs
|
||||
timeRegions?: [...] @grafanamaturity(NeedsExpertReview)
|
||||
|
||||
transformations: [...#Transformation] @grafanamaturity(NeedsExpertReview)
|
||||
transformations: [...#DataTransformerConfig] @grafanamaturity(NeedsExpertReview)
|
||||
|
||||
// TODO docs
|
||||
// TODO tighter constraint
|
||||
|
@ -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;
|
||||
|
@ -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,
|
||||
|
@ -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.
|
||||
*/
|
||||
|
@ -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,
|
||||
|
@ -334,6 +334,20 @@ type DataSourceRef struct {
|
||||
Uid *string `json:"uid,omitempty"`
|
||||
}
|
||||
|
||||
// TODO docs
|
||||
type DataTransformerConfig struct {
|
||||
// Disabled transformations are skipped
|
||||
Disabled *bool `json:"disabled,omitempty"`
|
||||
Filter *MatcherConfig `json:"filter,omitempty"`
|
||||
|
||||
// Unique identifier of transformer
|
||||
Id string `json:"id"`
|
||||
|
||||
// Options to be passed to the transformer
|
||||
// Valid options depend on the transformer id
|
||||
Options interface{} `json:"options"`
|
||||
}
|
||||
|
||||
// DynamicConfigValue defines model for DynamicConfigValue.
|
||||
type DynamicConfigValue struct {
|
||||
Id string `json:"id"`
|
||||
@ -545,8 +559,8 @@ type Panel struct {
|
||||
TimeShift *string `json:"timeShift,omitempty"`
|
||||
|
||||
// Panel title.
|
||||
Title *string `json:"title,omitempty"`
|
||||
Transformations []Transformation `json:"transformations"`
|
||||
Title *string `json:"title,omitempty"`
|
||||
Transformations []DataTransformerConfig `json:"transformations"`
|
||||
|
||||
// Whether to display the panel without a background.
|
||||
Transparent bool `json:"transparent"`
|
||||
@ -707,15 +721,6 @@ type ThresholdsConfig struct {
|
||||
// ThresholdsMode defines model for ThresholdsMode.
|
||||
type ThresholdsMode string
|
||||
|
||||
// TODO docs
|
||||
// FIXME this is extremely underspecfied; wasn't obvious which typescript types corresponded to it
|
||||
type Transformation struct {
|
||||
Filter *MatcherConfig `json:"filter,omitempty"`
|
||||
Hide bool `json:"hide"`
|
||||
Id string `json:"id"`
|
||||
Options map[string]interface{} `json:"options"`
|
||||
}
|
||||
|
||||
// TODO docs
|
||||
type ValueMap struct {
|
||||
Options map[string]ValueMappingResult `json:"options"`
|
||||
|
@ -6,7 +6,6 @@ import {
|
||||
DataLinkBuiltInVars,
|
||||
DataQuery,
|
||||
DataSourceRef,
|
||||
DataTransformerConfig,
|
||||
FieldConfigSource,
|
||||
FieldMatcherID,
|
||||
FieldType,
|
||||
@ -26,6 +25,7 @@ import {
|
||||
import { labelsToFieldsTransformer } from '@grafana/data/src/transformations/transformers/labelsToFields';
|
||||
import { mergeTransformer } from '@grafana/data/src/transformations/transformers/merge';
|
||||
import { getDataSourceSrv, setDataSourceSrv } from '@grafana/runtime';
|
||||
import { DataTransformerConfig } from '@grafana/schema';
|
||||
import { AxisPlacement, GraphFieldConfig } from '@grafana/ui';
|
||||
import { migrateTableDisplayModeToCellOptions } from '@grafana/ui/src/components/Table/utils';
|
||||
import { getAllOptionEditors, getAllStandardFieldConfigs } from 'app/core/components/OptionsUI/registry';
|
||||
|
@ -2,14 +2,8 @@ import React, { useMemo, useState } from 'react';
|
||||
import { useObservable } from 'react-use';
|
||||
import AutoSizer from 'react-virtualized-auto-sizer';
|
||||
|
||||
import {
|
||||
ApplyFieldOverrideOptions,
|
||||
DataTransformerConfig,
|
||||
dateMath,
|
||||
FieldColorModeId,
|
||||
NavModelItem,
|
||||
PanelData,
|
||||
} from '@grafana/data';
|
||||
import { ApplyFieldOverrideOptions, dateMath, FieldColorModeId, NavModelItem, PanelData } from '@grafana/data';
|
||||
import { DataTransformerConfig } from '@grafana/schema';
|
||||
import { Button, Table } from '@grafana/ui';
|
||||
import { Page } from 'app/core/components/Page/Page';
|
||||
import { config } from 'app/core/config';
|
||||
|
Loading…
Reference in New Issue
Block a user