From ff9ad7ad20c060a97a2ecd30ae0e90e82d83af68 Mon Sep 17 00:00:00 2001 From: Ryan McKinley Date: Thu, 7 Oct 2021 02:19:58 -0700 Subject: [PATCH] Schema: use the generated graph.gen.ts (#40090) * actually generate graph.gen.ts * getting closer * keep file where it is * manual fixes * Update packages/grafana-schema/src/schema/graph.gen.ts Co-authored-by: sam boyer * Docs: Whats new in 8.2 (#39945) * Added time range controls updates * Added plugins catalog update * Added enterprise images * Added community contributions highlights for 8.2 * accessibility statement * Update docs/sources/whatsnew/whats-new-in-v8-2.md Co-authored-by: Fiona Artiaga <89225282+GrafanaWriter@users.noreply.github.com> * Update docs/sources/whatsnew/whats-new-in-v8-2.md Co-authored-by: Fiona Artiaga <89225282+GrafanaWriter@users.noreply.github.com> * Update docs/sources/whatsnew/whats-new-in-v8-2.md Co-authored-by: Fiona Artiaga <89225282+GrafanaWriter@users.noreply.github.com> * Update docs/sources/whatsnew/whats-new-in-v8-2.md Co-authored-by: Fiona Artiaga <89225282+GrafanaWriter@users.noreply.github.com> * Update docs/sources/whatsnew/whats-new-in-v8-2.md Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com> * Update docs/sources/whatsnew/whats-new-in-v8-2.md Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com> * Update docs/sources/whatsnew/whats-new-in-v8-2.md Co-authored-by: Fiona Artiaga <89225282+GrafanaWriter@users.noreply.github.com> * Update docs/sources/whatsnew/whats-new-in-v8-2.md Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com> * Update docs/sources/whatsnew/whats-new-in-v8-2.md Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: Fiona Artiaga <89225282+GrafanaWriter@users.noreply.github.com> Co-authored-by: Fiona Artiaga <89225282+GrafanaWriter@users.noreply.github.com> Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com> * Live: array for Processor, Outputter and Subscriber in channel rule top level (#39677) * ReleaseNotes: Updated changelog and release notes for 8.1.7 (#40081) * more * more Co-authored-by: sam boyer Co-authored-by: Petros Kolyvas Co-authored-by: Fiona Artiaga <89225282+GrafanaWriter@users.noreply.github.com> Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com> Co-authored-by: Alexander Emelin Co-authored-by: Grot (@grafanabot) <43478413+grafanabot@users.noreply.github.com> --- packages/grafana-schema/src/index.ts | 4 - packages/grafana-schema/src/schema/graph.cue | 9 +- .../grafana-schema/src/schema/graph.gen.ts | 344 +++++++++++------- packages/grafana-schema/src/schema/legend.cue | 4 +- .../grafana-schema/src/schema/legend.gen.ts | 34 -- packages/grafana-schema/src/schema/table.cue | 3 +- .../grafana-schema/src/schema/table.gen.ts | 21 -- .../grafana-schema/src/schema/text.gen.ts | 22 -- .../grafana-schema/src/schema/tooltip.gen.ts | 27 -- 9 files changed, 223 insertions(+), 245 deletions(-) delete mode 100644 packages/grafana-schema/src/schema/legend.gen.ts delete mode 100644 packages/grafana-schema/src/schema/table.gen.ts delete mode 100644 packages/grafana-schema/src/schema/text.gen.ts delete mode 100644 packages/grafana-schema/src/schema/tooltip.gen.ts diff --git a/packages/grafana-schema/src/index.ts b/packages/grafana-schema/src/index.ts index bbd351c0757..e3c6d27dc95 100644 --- a/packages/grafana-schema/src/index.ts +++ b/packages/grafana-schema/src/index.ts @@ -3,8 +3,4 @@ * * @packageDocumentation */ -export * from './schema/legend.gen'; -export * from './schema/tooltip.gen'; -export * from './schema/text.gen'; -export * from './schema/table.gen'; export * from './schema/graph.gen'; diff --git a/packages/grafana-schema/src/schema/graph.cue b/packages/grafana-schema/src/schema/graph.cue index 9f1caaff94f..0af58f7c5b1 100644 --- a/packages/grafana-schema/src/schema/graph.cue +++ b/packages/grafana-schema/src/schema/graph.cue @@ -2,7 +2,7 @@ package schema AxisPlacement: "auto" | "top" | "right" | "bottom" | "left" | "hidden" @cuetsy(kind="enum") VisibilityMode: "auto" | "never" | "always" @cuetsy(kind="enum") -DrawStyle: "line" | "bars" | "points" @cuetsy(kind="enum") +GraphDrawStyle: "line" | "bars" | "points" @cuetsy(kind="enum") LineInterpolation: "linear" | "smooth" | "stepBefore" | "stepAfter" @cuetsy(kind="enum") ScaleDistribution: "linear" | "log" | "ordinal" @cuetsy(kind="enum") GraphGradientMode: "none" | "opacity" | "hue" | "scheme" @cuetsy(kind="enum") @@ -19,6 +19,10 @@ LineConfig: { lineWidth?: number lineInterpolation?: LineInterpolation lineStyle?: LineStyle + + // Indicate if null values should be treated as gaps or connected. + // When the value is a number, it represents the maximum delta in the + // X axis that should be considered connected. For timeseries, this is milliseconds spanNulls?: bool | number } @cuetsy(kind="interface") BarConfig: { @@ -47,6 +51,7 @@ AxisConfig: { axisWidth?: number axisSoftMin?: number axisSoftMax?: number + axisGridShow?: bool scaleDistribution?: ScaleDistributionConfig } @cuetsy(kind="interface") HideSeriesConfig: { @@ -76,7 +81,7 @@ GraphFieldConfig: { BarConfig StackableFieldConfig HideableFieldConfig - drawStyle?: DrawStyle + drawStyle?: GraphDrawStyle gradientMode?: GraphGradientMode thresholdsStyle?: GraphThresholdsStyleConfig } @cuetsy(kind="interface") diff --git a/packages/grafana-schema/src/schema/graph.gen.ts b/packages/grafana-schema/src/schema/graph.gen.ts index fc38add7062..5d9004906c0 100644 --- a/packages/grafana-schema/src/schema/graph.gen.ts +++ b/packages/grafana-schema/src/schema/graph.gen.ts @@ -1,6 +1,6 @@ //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -// NOTE: This file will be auto generated from models.cue -// It is currently hand written but will serve as the target for cuetsy +// This file was autogenerated by cuetsy from all the files in this directory, +// then hand-edited for correctness. It will be fully auto-generated Soon™. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ export enum AxisPlacement { @@ -11,185 +11,234 @@ export enum AxisPlacement { Right = 'right', Top = 'top', } + export enum VisibilityMode { - Auto = 'auto', Always = 'always', + Auto = 'auto', Never = 'never', } + export enum GraphDrawStyle { Bars = 'bars', Line = 'line', Points = 'points', } + export enum LineInterpolation { Linear = 'linear', Smooth = 'smooth', StepAfter = 'stepAfter', StepBefore = 'stepBefore', } -/** - * @alpha - */ + export enum ScaleDistribution { Linear = 'linear', Log = 'log', Ordinal = 'ordinal', } + export enum GraphGradientMode { Hue = 'hue', None = 'none', Opacity = 'opacity', Scheme = 'scheme', } -export interface LineStyle { - dash?: number[]; - fill?: 'solid' | 'dash' | 'dot' | 'square'; -} -export interface PointsConfig { - pointColor?: string; - pointSize?: number; - pointSymbol?: string; - showPoints?: VisibilityMode; -} -export interface ScaleDistributionConfig { - log?: number; - type: ScaleDistribution; -} -export interface HideSeriesConfig { - viz: boolean; - legend: boolean; - tooltip: boolean; -} -/** - * @alpha - */ -export enum BarAlignment { - Before = -1, - Center = 0, - After = 1, -} - -/** - * @alpha - */ -export enum ScaleOrientation { - Horizontal = 0, - Vertical = 1, -} - -/** - * @alpha - */ - -export enum ScaleDirection { - Up = 1, - Right = 1, - Down = -1, - Left = -1, -} - -/** - * @alpha - */ -export interface LineConfig { - lineColor?: string; - lineWidth?: number; - lineInterpolation?: LineInterpolation; - lineStyle?: LineStyle; - - /** - * Indicate if null values should be treated as gaps or connected. - * When the value is a number, it represents the maximum delta in the - * X axis that should be considered connected. For timeseries, this is milliseconds - */ - spanNulls?: boolean | number; -} - -/** - * @alpha - */ -export interface BarConfig { - barAlignment?: BarAlignment; - barWidthFactor?: number; - barMaxWidth?: number; -} - -/** - * @alpha - */ -export interface FillConfig { - fillColor?: string; - fillOpacity?: number; - fillBelowTo?: string; // name of the field -} - -/** - * @alpha - * Axis is actually unique based on the unit... not each field! - */ -export interface AxisConfig { - axisPlacement?: AxisPlacement; - axisLabel?: string; - axisWidth?: number; // pixels ideally auto? - axisSoftMin?: number; - axisSoftMax?: number; - axisGridShow?: boolean; - scaleDistribution?: ScaleDistributionConfig; -} - -/** - * @alpha - */ -export interface HideableFieldConfig { - hideFrom?: HideSeriesConfig; -} - -/** - * @alpha - */ export enum StackingMode { None = 'none', Normal = 'normal', Percent = 'percent', } -/** - * @alpha - */ -export interface StackingConfig { - mode?: StackingMode; - group?: string; +export enum BarAlignment { + After = 1, + Before = -1, + Center = 0, +} + +export enum ScaleOrientation { + Horizontal = 0, + Vertical = 1, +} + +export enum ScaleDirection { + Down = -1, + Left = -1, + Right = 1, + Up = 1, +} + +export interface LineStyle { + dash?: number[]; + fill?: 'solid' | 'dash' | 'dot' | 'square'; +} + +export interface LineConfig { + lineColor?: string; + lineInterpolation?: LineInterpolation; + lineStyle?: LineStyle; + lineWidth?: number; + spanNulls?: boolean | number; +} + +export interface BarConfig { + barAlignment?: BarAlignment; + barMaxWidth?: number; + barWidthFactor?: number; +} + +export interface FillConfig { + fillBelowTo?: string; + fillColor?: string; + fillOpacity?: number; +} + +export interface PointsConfig { + pointColor?: string; + pointSize?: number; + pointSymbol?: string; + showPoints?: VisibilityMode; +} + +export interface ScaleDistributionConfig { + log?: number; + type: ScaleDistribution; +} + +export interface AxisConfig { + axisGridShow?: boolean; + axisLabel?: string; + axisPlacement?: AxisPlacement; + axisSoftMax?: number; + axisSoftMin?: number; + axisWidth?: number; + scaleDistribution?: ScaleDistributionConfig; +} + +export interface HideSeriesConfig { + legend: boolean; + tooltip: boolean; + viz: boolean; +} + +export interface StackingConfig { + group?: string; + mode?: StackingMode; } -/** - * @alpha - */ export interface StackableFieldConfig { stacking?: StackingConfig; } -/** - * @alpha - */ +export interface HideableFieldConfig { + hideFrom?: HideSeriesConfig; +} + export enum GraphTresholdsStyleMode { - Off = 'off', - Line = 'line', Area = 'area', + Line = 'line', LineAndArea = 'line+area', + Off = 'off', Series = 'series', } -/** - * @alpha - */ export interface GraphThresholdsStyleConfig { mode: GraphTresholdsStyleMode; } -/** - * @alpha - */ +export type LegendPlacement = 'bottom' | 'right'; + +export enum LegendDisplayMode { + Hidden = 'hidden', + List = 'list', + Table = 'table', +} + +export interface TableSortByFieldState { + desc?: boolean; + displayName: string; +} + +export interface SingleStatBaseOptions extends OptionsWithTextFormatting { + orientation: VizOrientation; + reduceOptions: ReduceDataOptions; +} + +export interface ReduceDataOptions { + calcs: string[]; + fields?: string; + limit?: number; + values?: boolean; +} + +export enum VizOrientation { + Auto = 'auto', + Horizontal = 'horizontal', + Vertical = 'vertical', +} + +export interface OptionsWithTooltip { + tooltip: VizTooltipOptions; +} + +export interface OptionsWithLegend { + legend: VizLegendOptions; +} + +export interface OptionsWithTextFormatting { + text?: VizTextDisplayOptions; +} + +export enum BigValueColorMode { + Background = 'background', + None = 'none', + Value = 'value', +} + +export enum BigValueGraphMode { + Area = 'area', + Line = 'line', + None = 'none', +} + +export enum BigValueJustifyMode { + Auto = 'auto', + Center = 'center', +} + +export enum BigValueTextMode { + Auto = 'auto', + Name = 'name', + None = 'none', + Value = 'value', + Value_and_name = 'value_and_name', +} + +export type FieldTextAlignment = 'auto' | 'left' | 'right' | 'center'; + +export enum TableCellDisplayMode { + Auto = 'auto', + BasicGauge = 'basic', + ColorBackground = 'color-background', + ColorBackgroundSolid = 'color-background-solid', + ColorText = 'color-text', + GradientGauge = 'gradient-gauge', + Image = 'image', + JSONView = 'json-view', + LcdGauge = 'lcd-gauge', +} + +export interface VizTextDisplayOptions { + titleSize?: number; + valueSize?: number; +} + +export enum TooltipDisplayMode { + Multi = 'multi', + None = 'none', + Single = 'single', +} + export interface GraphFieldConfig extends LineConfig, FillConfig, @@ -202,3 +251,34 @@ export interface GraphFieldConfig gradientMode?: GraphGradientMode; thresholdsStyle?: GraphThresholdsStyleConfig; } + +export interface VizLegendOptions { + asTable?: boolean; + calcs: string[]; + displayMode: LegendDisplayMode; + isVisible?: boolean; + placement: LegendPlacement; +} + +export enum BarGaugeDisplayMode { + Basic = 'basic', + Gradient = 'gradient', + Lcd = 'lcd', +} + +export interface TableFieldOptions { + align: string; + displayMode: TableCellDisplayMode; + hidden?: boolean; + minWidth?: number; + width?: number; +} + +export const defaultTableFieldOptions: TableFieldOptions = { + align: 'auto', + displayMode: TableCellDisplayMode.Auto, +}; + +export interface VizTooltipOptions { + mode: TooltipDisplayMode; +} diff --git a/packages/grafana-schema/src/schema/legend.cue b/packages/grafana-schema/src/schema/legend.cue index 5ae354e168c..23986bd83ff 100644 --- a/packages/grafana-schema/src/schema/legend.cue +++ b/packages/grafana-schema/src/schema/legend.cue @@ -7,7 +7,7 @@ LegendDisplayMode: "list" | "table" | "hidden" @cuetsy(kind="enum") VizLegendOptions: { displayMode: LegendDisplayMode placement: LegendPlacement - asTable: bool | *false - isVisible: bool | *false + asTable?: bool + isVisible?: bool calcs: [...string] } @cuetsy(kind="interface") diff --git a/packages/grafana-schema/src/schema/legend.gen.ts b/packages/grafana-schema/src/schema/legend.gen.ts deleted file mode 100644 index 4f80864c9f3..00000000000 --- a/packages/grafana-schema/src/schema/legend.gen.ts +++ /dev/null @@ -1,34 +0,0 @@ -//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -// NOTE: This file will be auto generated from models.cue -// It is currenty hand written but will serve as the target for cuetsy -//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -/** - * @public - */ -export type LegendPlacement = 'bottom' | 'right'; - -/** - * @public - */ -export enum LegendDisplayMode { - Hidden = 'hidden', - List = 'list', - Table = 'table', -} - -/** - * @public - */ -export interface VizLegendOptions { - calcs: string[]; - displayMode: LegendDisplayMode; - placement: LegendPlacement; -} - -/** - * @public - */ -export interface OptionsWithLegend { - legend: VizLegendOptions; -} diff --git a/packages/grafana-schema/src/schema/table.cue b/packages/grafana-schema/src/schema/table.cue index 347b0de40ba..47285e8df34 100644 --- a/packages/grafana-schema/src/schema/table.cue +++ b/packages/grafana-schema/src/schema/table.cue @@ -3,10 +3,11 @@ package schema // TODO -- should not be table specific! FieldTextAlignment: "auto" | "left" | "right" | "center" @cuetsy(kind="type") -TableCellDisplayMode: "auto" | "color-text" | "color-background" | "gradient-gauge" | "lcd-gauge" | "json-view" | "basic" | "image" @cuetsy(kind="enum",memberNames="Auto|ColorText|ColorBackground|GradientGauge|LcdGauge|JSONView|BasicGauge|Image") +TableCellDisplayMode: "auto" | "color-text" | "color-background" | "color-background-solid" | "gradient-gauge" | "lcd-gauge" | "json-view" | "basic" | "image" @cuetsy(kind="enum",memberNames="Auto|ColorText|ColorBackground|ColorBackgroundSolid|GradientGauge|LcdGauge|JSONView|BasicGauge|Image") TableFieldOptions: { width?: number + minWidth?: number align: FieldTextAlignment | *"auto" displayMode: TableCellDisplayMode | *"auto" hidden?: bool // ?? default is missing or false ?? diff --git a/packages/grafana-schema/src/schema/table.gen.ts b/packages/grafana-schema/src/schema/table.gen.ts deleted file mode 100644 index 3807e27d154..00000000000 --- a/packages/grafana-schema/src/schema/table.gen.ts +++ /dev/null @@ -1,21 +0,0 @@ -export interface TableFieldOptions { - width: number; - minWidth: number; - align: FieldTextAlignment; - displayMode: TableCellDisplayMode; - hidden?: boolean; -} - -export enum TableCellDisplayMode { - Auto = 'auto', - ColorText = 'color-text', - ColorBackground = 'color-background', - ColorBackgroundSolid = 'color-background-solid', - GradientGauge = 'gradient-gauge', - LcdGauge = 'lcd-gauge', - JSONView = 'json-view', - BasicGauge = 'basic', - Image = 'image', -} - -export type FieldTextAlignment = 'auto' | 'left' | 'right' | 'center'; diff --git a/packages/grafana-schema/src/schema/text.gen.ts b/packages/grafana-schema/src/schema/text.gen.ts deleted file mode 100644 index 7c7671a9920..00000000000 --- a/packages/grafana-schema/src/schema/text.gen.ts +++ /dev/null @@ -1,22 +0,0 @@ -//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -// NOTE: This file will be auto generated from models.cue -// It is currenty hand written but will serve as the target for cuetsy -//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -/** - * Explicit control for visualization text settings - * @public - **/ -export interface VizTextDisplayOptions { - /* Explicit title text size */ - titleSize?: number; - /* Explicit value text size */ - valueSize?: number; -} - -/** - * @public - */ -export interface OptionsWithTextFormatting { - text?: VizTextDisplayOptions; -} diff --git a/packages/grafana-schema/src/schema/tooltip.gen.ts b/packages/grafana-schema/src/schema/tooltip.gen.ts deleted file mode 100644 index 11f396de538..00000000000 --- a/packages/grafana-schema/src/schema/tooltip.gen.ts +++ /dev/null @@ -1,27 +0,0 @@ -//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -// NOTE: This file will be auto generated from models.cue -// It is currenty hand written but will serve as the target for cuetsy -//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -/** - * @public - */ -export enum TooltipDisplayMode { - Single = 'single', - Multi = 'multi', - None = 'none', -} - -/** - * @public - */ -export type VizTooltipOptions = { - mode: TooltipDisplayMode; -}; - -/** - * @public - */ -export interface OptionsWithTooltip { - tooltip: VizTooltipOptions; -}