Skip to content

Instantly share code, notes, and snippets.

@sdboyer
Created September 27, 2021 04:01
Show Gist options
  • Save sdboyer/14976acfb4829d7f10f7dfa1ba23deb4 to your computer and use it in GitHub Desktop.
Save sdboyer/14976acfb4829d7f10f7dfa1ba23deb4 to your computer and use it in GitHub Desktop.
nearly there with CUE->TS codegen! this is gen results for *all* the CUE in grafana codebase so far
import * as ui from '@grafana-schema';
/////////////////////////////////////////////////////
// SOURCE CUE PATH packages/grafana-schema/src/schema/graph.cue
/////////////////////////////////////////////////////
export enum AxisPlacement {
Auto = 'auto',
Bottom = 'bottom',
Hidden = 'hidden',
Left = 'left',
Right = 'right',
Top = 'top',
}
export enum VisibilityMode {
Always = 'always',
Auto = 'auto',
Never = 'never',
}
export enum DrawStyle {
Bars = 'bars',
Line = 'line',
Points = 'points',
}
export enum LineInterpolation {
Linear = 'linear',
Smooth = 'smooth',
StepAfter = 'stepAfter',
StepBefore = 'stepBefore',
}
export enum ScaleDistribution {
Linear = 'linear',
Log = 'log',
}
export enum GraphGradientMode {
Hue = 'hue',
None = 'none',
Opacity = 'opacity',
Scheme = 'scheme',
}
export enum StackingMode {
None = 'none',
Normal = 'normal',
Percent = 'percent',
}
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 {
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;
}
export interface StackableFieldConfig {
stacking?: StackingConfig;
}
export interface HideableFieldConfig {
hideFrom?: HideSeriesConfig;
}
export enum GraphTresholdsStyleMode {
Area = 'area',
Line = 'line',
LineAndArea = 'line+area',
Off = 'off',
Series = 'series',
}
export interface GraphThresholdsStyleConfig {
mode: GraphTresholdsStyleMode;
}
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',
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, PointsConfig, AxisConfig, BarConfig, StackableFieldConfig, HideableFieldConfig {
drawStyle?: DrawStyle;
gradientMode?: GraphGradientMode;
thresholdsStyle?: GraphThresholdsStyleConfig;
}
export interface VizLegendOptions {
asTable: boolean;
calcs: string[];
displayMode: LegendDisplayMode;
isVisible: boolean;
placement: LegendPlacement;
}
export const vizLegendOptionsDefault: VizLegendOptions = {
asTable: false,
isVisible: false,
}
export enum BarGaugeDisplayMode {
Basic = 'basic',
Gradient = 'gradient',
Lcd = 'lcd',
}
export interface TableFieldOptions {
align: string;
displayMode: string;
hidden?: boolean;
width?: number;
}
export const tableFieldOptionsDefault: TableFieldOptions = {
align: 'auto',
displayMode: 'auto',
}
export interface VizTooltipOptions {
mode: TooltipDisplayMode;
}
/////////////////////////////////////////////////////
// SOURCE CUE PATH public/app/plugins/panel/barchart/models.cue
/////////////////////////////////////////////////////
export interface PanelOptions extends ui.OptionsWithLegend, ui.OptionsWithTooltip, ui.OptionsWithTextFormatting {
barWidth: number;
groupWidth: number;
orientation: string;
showValue: string;
stacking: string;
}
export const panelOptionsDefault: PanelOptions = {
stacking: 'none',
}
export interface PanelFieldConfig extends ui.AxisConfig, ui.HideableFieldConfig {
fillOpacity?: number;
gradientMode?: string;
lineWidth?: number;
}
/////////////////////////////////////////////////////
// SOURCE CUE PATH public/app/plugins/panel/bargauge/models.cue
/////////////////////////////////////////////////////
export interface PanelOptions extends ui.SingleStatBaseOptions {
displayMode: string;
showUnfilled: boolean;
}
/////////////////////////////////////////////////////
// SOURCE CUE PATH public/app/plugins/panel/canvas/models.cue
/////////////////////////////////////////////////////
export interface PanelOptions {
}
/////////////////////////////////////////////////////
// SOURCE CUE PATH public/app/plugins/panel/dashlist/models.cue
/////////////////////////////////////////////////////
export interface PanelOptions {
folderId?: number;
maxItems: number;
query: string;
showHeadings: boolean;
showRecentlyViewed: boolean;
showSearch: boolean;
showStarred: boolean;
tags: x;
}
export const panelOptionsDefault: PanelOptions = {
maxItems: 10,
query: '',
showHeadings: true,
showRecentlyViewed: false,
showSearch: false,
showStarred: true,
}
/////////////////////////////////////////////////////
// SOURCE CUE PATH public/app/plugins/panel/gauge/models.cue
/////////////////////////////////////////////////////
export interface PanelOptions extends ui.SingleStatBaseOptions {
showThresholdLabels: boolean;
showThresholdMarkers: boolean;
}
/////////////////////////////////////////////////////
// SOURCE CUE PATH public/app/plugins/panel/histogram/models.cue
/////////////////////////////////////////////////////
export interface PanelOptions extends ui.OptionsWithLegend, ui.OptionsWithTooltip {
bucketOffset: number;
bucketSize?: number;
combine?: boolean;
}
export const panelOptionsDefault: PanelOptions = {
bucketOffset: 0,
}
export interface PanelFieldConfig extends ui.GraphFieldConfig {
}
/////////////////////////////////////////////////////
// SOURCE CUE PATH public/app/plugins/panel/news/models.cue
/////////////////////////////////////////////////////
export interface PanelOptions {
feedUrl?: string;
showImage?: boolean;
useProxy?: boolean;
}
export const panelOptionsDefault: PanelOptions = {
showImage?: true,
}
/////////////////////////////////////////////////////
// SOURCE CUE PATH public/app/plugins/panel/stat/models.cue
/////////////////////////////////////////////////////
export interface PanelOptions extends ui.SingleStatBaseOptions {
colorMode: string;
graphMode: string;
justifyMode: string;
textMode: string;
}
/////////////////////////////////////////////////////
// SOURCE CUE PATH public/app/plugins/panel/state-timeline/models.cue
/////////////////////////////////////////////////////
export type TimelineValueAlignment = 'center' | 'left' | 'right';
export interface PanelOptions extends ui.OptionsWithLegend, ui.OptionsWithTooltip {
alignValue?: string;
colWidth?: number;
mergeValues?: boolean;
rowHeight: number;
showValue: string;
}
export const panelOptionsDefault: PanelOptions = {
alignValue?: 'left',
mergeValues?: true,
rowHeight: 0.9,
showValue: 'auto',
}
export interface PanelFieldConfig extends ui.HideableFieldConfig {
fillOpacity?: number;
lineWidth?: number;
}
export const panelFieldConfigDefault: PanelFieldConfig = {
fillOpacity?: 70,
lineWidth?: 0,
}
/////////////////////////////////////////////////////
// SOURCE CUE PATH public/app/plugins/panel/status-history/models.cue
/////////////////////////////////////////////////////
export interface PanelOptions extends ui.OptionsWithLegend, ui.OptionsWithTooltip {
alignValue: string;
colWidth?: number;
rowHeight: number;
showValue: string;
}
export const panelOptionsDefault: PanelOptions = {
alignValue: 'left',
}
export interface PanelFieldConfig extends ui.HideableFieldConfig {
fillOpacity?: number;
lineWidth?: number;
}
export const panelFieldConfigDefault: PanelFieldConfig = {
fillOpacity?: 70,
lineWidth?: 1,
}
/////////////////////////////////////////////////////
// SOURCE CUE PATH public/app/plugins/panel/table/models.cue
/////////////////////////////////////////////////////
export interface PanelOptions {
frameIndex: number;
showHeader: boolean;
showTypeIcons: boolean;
sortBy?: ui.TableSortByFieldState[];
}
export const panelOptionsDefault: PanelOptions = {
frameIndex: 0,
showHeader: true,
showTypeIcons: false,
}
export interface PanelFieldConfig {
align?: string;
displayMode?: string;
filterable?: boolean;
minWidth?: number;
width?: number;
}
export const panelFieldConfigDefault: PanelFieldConfig = {
align?: 'auto',
displayMode?: 'auto',
}
/////////////////////////////////////////////////////
// SOURCE CUE PATH public/app/plugins/panel/text/models.cue
/////////////////////////////////////////////////////
export interface PanelOptions {
content: string;
mode: string;
}
export const panelOptionsDefault: PanelOptions = {
content: '# Title
For markdown syntax help: [commonmark.org/help](https://commonmark.org/help/)',
mode: 'markdown',
}
/////////////////////////////////////////////////////
// SOURCE CUE PATH public/app/plugins/panel/timeseries/models.cue
/////////////////////////////////////////////////////
export interface PanelOptions {
legend: {
displayMode: legendDisplayModeDefault;
placement: legendPlacementDefault;
asTable: boolean;
isVisible: boolean;
calcs: string[];
};
tooltip: {
mode: tooltipDisplayModeDefault;
};
}
export interface PanelFieldConfig extends ui.GraphFieldConfig {
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment