Open-Source Wikis

/

Grafana

/

Packages

/

@grafana/schema

grafana/grafana

@grafana/schema

TypeScript types generated from CUE schemas. Source under packages/grafana-schema/. The CUE definitions themselves live in kinds/ and per-app under apps/<name>/kinds/.

What's generated

  • Panel options/types — every built-in panel plugin's options type (TimeSeriesPanelCfg, StatPanelCfg, …).
  • Common typesDataQuery, DataSourceRef, MatcherConfig, threshold/mapping types shared across panels.
  • Dashboard schema — fields on the dashboard JSON that aren't otherwise typed.
  • Composable kinds — frontend-side types from CUE composable kinds.

The generation step is make gen-cue (Go and TS) and the equivalent in the package's own themes-schema script.

Usage

import { TimeSeriesFieldConfig, TimeSeriesPanelCfg } from '@grafana/schema';

External plugin authors import from here when they need the canonical Grafana panel types (e.g. when a plugin extends a panel option type).

Why CUE?

CUE gives a single source of truth that produces:

  • Go structs (used by the backend).
  • TypeScript types (used by the frontend and external plugins).
  • OpenAPI fragments (used in API specs).

Editing the type by hand in TS or Go would risk drift; editing the CUE and running codegen keeps everything in sync.

Key directories

Directory Purpose
packages/grafana-schema/src/ Generated types + a few hand-written re-exports
kinds/ CUE source (panels, dashboard)
apps/<name>/kinds/ Per-app CUE sources
pkg/codegen/ Code generators that consume CUE

See also

Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.

@grafana/schema – Grafana wiki | Factory