@intentius/chant-lexicon-grafana 0.97.0 → 0.99.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -5
- package/dist/actions/grafana.d.ts +24 -0
- package/dist/actions/grafana.d.ts.map +1 -0
- package/dist/actions/index.d.ts +2 -0
- package/dist/actions/index.d.ts.map +1 -0
- package/dist/alerting-build.d.ts +128 -0
- package/dist/alerting-build.d.ts.map +1 -0
- package/dist/alerting.d.ts +273 -0
- package/dist/alerting.d.ts.map +1 -0
- package/dist/api/apply.d.ts +156 -0
- package/dist/api/apply.d.ts.map +1 -0
- package/dist/api/bind.d.ts +32 -0
- package/dist/api/bind.d.ts.map +1 -0
- package/dist/api/client.d.ts +76 -0
- package/dist/api/client.d.ts.map +1 -0
- package/dist/api/converge.d.ts +33 -0
- package/dist/api/converge.d.ts.map +1 -0
- package/dist/api/dashboards.d.ts +102 -0
- package/dist/api/dashboards.d.ts.map +1 -0
- package/dist/api/datasources.d.ts +26 -0
- package/dist/api/datasources.d.ts.map +1 -0
- package/dist/api/fake-grafana-writes.d.ts +41 -0
- package/dist/api/fake-grafana-writes.d.ts.map +1 -0
- package/dist/api/fake-grafana.d.ts +61 -0
- package/dist/api/fake-grafana.d.ts.map +1 -0
- package/dist/api/folders.d.ts +110 -0
- package/dist/api/folders.d.ts.map +1 -0
- package/dist/api/library-panels.d.ts +52 -0
- package/dist/api/library-panels.d.ts.map +1 -0
- package/dist/build.d.ts +30 -2
- package/dist/build.d.ts.map +1 -1
- package/dist/catalog.d.ts +1 -1
- package/dist/catalog.d.ts.map +1 -1
- package/dist/codegen/docs.d.ts.map +1 -1
- package/dist/codegen/schema-types.d.ts +3 -3
- package/dist/codegen/schema-types.d.ts.map +1 -1
- package/dist/composites/agent-dashboard.d.ts.map +1 -1
- package/dist/composites/catalog.d.ts.map +1 -1
- package/dist/composites/index.d.ts +4 -2
- package/dist/composites/index.d.ts.map +1 -1
- package/dist/composites/red-dashboard.d.ts +21 -2
- package/dist/composites/red-dashboard.d.ts.map +1 -1
- package/dist/composites/shared.d.ts +7 -0
- package/dist/composites/shared.d.ts.map +1 -1
- package/dist/composites/slo-alert-rules.d.ts +92 -0
- package/dist/composites/slo-alert-rules.d.ts.map +1 -0
- package/dist/config.d.ts +111 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/contact-point-secrets.d.ts +17 -0
- package/dist/contact-point-secrets.d.ts.map +1 -0
- package/dist/dashboard.d.ts +16 -2
- package/dist/dashboard.d.ts.map +1 -1
- package/dist/datasource-refs.d.ts +95 -0
- package/dist/datasource-refs.d.ts.map +1 -0
- package/dist/datasource.d.ts +29 -0
- package/dist/datasource.d.ts.map +1 -1
- package/dist/deep-observe-hooks.d.ts +64 -0
- package/dist/deep-observe-hooks.d.ts.map +1 -0
- package/dist/deep-observe.d.ts +42 -0
- package/dist/deep-observe.d.ts.map +1 -0
- package/dist/describe-resources.d.ts +49 -0
- package/dist/describe-resources.d.ts.map +1 -0
- package/dist/detect.d.ts +28 -1
- package/dist/detect.d.ts.map +1 -1
- package/dist/export-resources.d.ts +38 -0
- package/dist/export-resources.d.ts.map +1 -0
- package/dist/import/alerting.d.ts +40 -0
- package/dist/import/alerting.d.ts.map +1 -0
- package/dist/import/edits.d.ts +47 -0
- package/dist/import/edits.d.ts.map +1 -0
- package/dist/import/embedded.d.ts +14 -0
- package/dist/import/embedded.d.ts.map +1 -0
- package/dist/import/generator.d.ts +60 -0
- package/dist/import/generator.d.ts.map +1 -0
- package/dist/import/live-export.d.ts +108 -0
- package/dist/import/live-export.d.ts.map +1 -0
- package/dist/import/mappings.d.ts +83 -0
- package/dist/import/mappings.d.ts.map +1 -0
- package/dist/import/model.d.ts +98 -0
- package/dist/import/model.d.ts.map +1 -0
- package/dist/import/normalize-alerting.d.ts +26 -0
- package/dist/import/normalize-alerting.d.ts.map +1 -0
- package/dist/import/normalize.d.ts +74 -0
- package/dist/import/normalize.d.ts.map +1 -0
- package/dist/import/parser.d.ts +110 -0
- package/dist/import/parser.d.ts.map +1 -0
- package/dist/import/report.d.ts +26 -0
- package/dist/import/report.d.ts.map +1 -0
- package/dist/import/testdata/fixtures.d.ts +35 -0
- package/dist/import/testdata/fixtures.d.ts.map +1 -0
- package/dist/import/v2.d.ts +72 -0
- package/dist/import/v2.d.ts.map +1 -0
- package/dist/index.d.ts +26 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/integrity.json +18 -10
- package/dist/k8s.d.ts +107 -0
- package/dist/k8s.d.ts.map +1 -0
- package/dist/lint/audit-catalog.d.ts +2 -1
- package/dist/lint/audit-catalog.d.ts.map +1 -1
- package/dist/lint/post-synth/graf101.d.ts +2 -2
- package/dist/lint/post-synth/graf102.d.ts +1 -1
- package/dist/lint/post-synth/graf107.d.ts +1 -1
- package/dist/lint/post-synth/graf108.d.ts +8 -0
- package/dist/lint/post-synth/graf108.d.ts.map +1 -0
- package/dist/lint/post-synth/graf109.d.ts +8 -0
- package/dist/lint/post-synth/graf109.d.ts.map +1 -0
- package/dist/lint/post-synth/graf111.d.ts +8 -0
- package/dist/lint/post-synth/graf111.d.ts.map +1 -0
- package/dist/lint/post-synth/graf112.d.ts +8 -0
- package/dist/lint/post-synth/graf112.d.ts.map +1 -0
- package/dist/lint/post-synth/graf113.d.ts +8 -0
- package/dist/lint/post-synth/graf113.d.ts.map +1 -0
- package/dist/lint/post-synth/graf114.d.ts +8 -0
- package/dist/lint/post-synth/graf114.d.ts.map +1 -0
- package/dist/lint/post-synth/graf115.d.ts +8 -0
- package/dist/lint/post-synth/graf115.d.ts.map +1 -0
- package/dist/lint/post-synth/grafana-helpers.d.ts +7 -5
- package/dist/lint/post-synth/grafana-helpers.d.ts.map +1 -1
- package/dist/lint/post-synth/index.d.ts.map +1 -1
- package/dist/lint/rules/literal-secret.d.ts +7 -3
- package/dist/lint/rules/literal-secret.d.ts.map +1 -1
- package/dist/lsp/hover.d.ts.map +1 -1
- package/dist/manifest.json +1 -1
- package/dist/members.d.ts +27 -0
- package/dist/members.d.ts.map +1 -0
- package/dist/meta.json +135 -0
- package/dist/okf/index.md +36 -2
- package/dist/okf/rules/GRAF002.md +3 -2
- package/dist/okf/rules/GRAF101.md +3 -2
- package/dist/okf/rules/GRAF102.md +1 -0
- package/dist/okf/rules/GRAF108.md +11 -0
- package/dist/okf/rules/GRAF109.md +15 -0
- package/dist/okf/rules/GRAF111.md +11 -0
- package/dist/okf/rules/GRAF112.md +16 -0
- package/dist/okf/rules/GRAF113.md +16 -0
- package/dist/okf/rules/GRAF114.md +11 -0
- package/dist/okf/rules/GRAF115.md +11 -0
- package/dist/okf/types/AlertListPanel.md +9 -0
- package/dist/okf/types/AlertQuery.md +9 -0
- package/dist/okf/types/AlertRule.md +9 -0
- package/dist/okf/types/AlertRuleGroup.md +9 -0
- package/dist/okf/types/BarChartPanel.md +9 -0
- package/dist/okf/types/BarGaugePanel.md +9 -0
- package/dist/okf/types/CanvasPanel.md +9 -0
- package/dist/okf/types/ClassicConditionsExpression.md +9 -0
- package/dist/okf/types/ContactPoint.md +14 -0
- package/dist/okf/types/Dashboard.md +1 -0
- package/dist/okf/types/Datasource.md +3 -2
- package/dist/okf/types/ExternalDatasource.md +15 -0
- package/dist/okf/types/FlameGraphPanel.md +9 -0
- package/dist/okf/types/GeomapPanel.md +9 -0
- package/dist/okf/types/HistogramPanel.md +9 -0
- package/dist/okf/types/MathExpression.md +9 -0
- package/dist/okf/types/MuteTiming.md +13 -0
- package/dist/okf/types/NodeGraphPanel.md +9 -0
- package/dist/okf/types/NotificationPolicy.md +9 -0
- package/dist/okf/types/NotificationTemplate.md +9 -0
- package/dist/okf/types/PieChartPanel.md +9 -0
- package/dist/okf/types/ReduceExpression.md +9 -0
- package/dist/okf/types/ResampleExpression.md +9 -0
- package/dist/okf/types/SqlExpression.md +9 -0
- package/dist/okf/types/StateTimelinePanel.md +9 -0
- package/dist/okf/types/StatusHistoryPanel.md +9 -0
- package/dist/okf/types/ThresholdExpression.md +9 -0
- package/dist/okf/types/TrendPanel.md +9 -0
- package/dist/okf/types/XYChartPanel.md +9 -0
- package/dist/op/activities/grafana-apply.d.ts +75 -0
- package/dist/op/activities/grafana-apply.d.ts.map +1 -0
- package/dist/op/activities/index.d.ts +9 -0
- package/dist/op/activities/index.d.ts.map +1 -0
- package/dist/op/builders.d.ts +24 -0
- package/dist/op/builders.d.ts.map +1 -0
- package/dist/ownership.d.ts +67 -0
- package/dist/ownership.d.ts.map +1 -0
- package/dist/panel-options.d.ts +65 -0
- package/dist/panel-options.d.ts.map +1 -0
- package/dist/panels.d.ts +46 -9
- package/dist/panels.d.ts.map +1 -1
- package/dist/pin.d.ts +29 -7
- package/dist/pin.d.ts.map +1 -1
- package/dist/plugin.d.ts.map +1 -1
- package/dist/promql-check.d.ts +51 -0
- package/dist/promql-check.d.ts.map +1 -0
- package/dist/query.d.ts +9 -8
- package/dist/query.d.ts.map +1 -1
- package/dist/rules/graf101.ts +3 -3
- package/dist/rules/graf102.ts +1 -1
- package/dist/rules/graf107.ts +1 -1
- package/dist/rules/graf108.ts +17 -0
- package/dist/rules/graf109.ts +17 -0
- package/dist/rules/graf111.ts +17 -0
- package/dist/rules/graf112.ts +17 -0
- package/dist/rules/graf113.ts +17 -0
- package/dist/rules/graf114.ts +17 -0
- package/dist/rules/graf115.ts +17 -0
- package/dist/rules/grafana-helpers.ts +15 -8
- package/dist/rules/literal-secret.ts +60 -6
- package/dist/schema/barchart.gen.d.ts +198 -0
- package/dist/schema/barchart.gen.d.ts.map +1 -0
- package/dist/schema/bargauge.gen.d.ts +97 -0
- package/dist/schema/bargauge.gen.d.ts.map +1 -0
- package/dist/schema/canvas.gen.d.ts +152 -0
- package/dist/schema/canvas.gen.d.ts.map +1 -0
- package/dist/schema/dashboard.gen.d.ts +196 -21
- package/dist/schema/dashboard.gen.d.ts.map +1 -1
- package/dist/schema/expr.gen.d.ts +606 -0
- package/dist/schema/expr.gen.d.ts.map +1 -0
- package/dist/schema/gauge.gen.d.ts.map +1 -1
- package/dist/schema/geomap.gen.d.ts +100 -0
- package/dist/schema/geomap.gen.d.ts.map +1 -0
- package/dist/schema/heatmap.gen.d.ts.map +1 -1
- package/dist/schema/histogram.gen.d.ts +132 -0
- package/dist/schema/histogram.gen.d.ts.map +1 -0
- package/dist/schema/index.d.ts +12 -0
- package/dist/schema/index.d.ts.map +1 -1
- package/dist/schema/logs.gen.d.ts +1 -0
- package/dist/schema/logs.gen.d.ts.map +1 -1
- package/dist/schema/loki.gen.d.ts.map +1 -1
- package/dist/schema/nodegraph.gen.d.ts +49 -0
- package/dist/schema/nodegraph.gen.d.ts.map +1 -0
- package/dist/schema/piechart.gen.d.ts +127 -0
- package/dist/schema/piechart.gen.d.ts.map +1 -0
- package/dist/schema/prometheus.gen.d.ts.map +1 -1
- package/dist/schema/stat.gen.d.ts.map +1 -1
- package/dist/schema/statetimeline.gen.d.ts +124 -0
- package/dist/schema/statetimeline.gen.d.ts.map +1 -0
- package/dist/schema/statushistory.gen.d.ts +114 -0
- package/dist/schema/statushistory.gen.d.ts.map +1 -0
- package/dist/schema/table.gen.d.ts +22 -3
- package/dist/schema/table.gen.d.ts.map +1 -1
- package/dist/schema/tempo.gen.d.ts.map +1 -1
- package/dist/schema/text.gen.d.ts.map +1 -1
- package/dist/schema/timeseries.gen.d.ts +5 -1
- package/dist/schema/timeseries.gen.d.ts.map +1 -1
- package/dist/schema/trend.gen.d.ts +180 -0
- package/dist/schema/trend.gen.d.ts.map +1 -0
- package/dist/schema/xychart.gen.d.ts +145 -0
- package/dist/schema/xychart.gen.d.ts.map +1 -0
- package/dist/schema-validate.d.ts +30 -4
- package/dist/schema-validate.d.ts.map +1 -1
- package/dist/serializer.d.ts +11 -3
- package/dist/serializer.d.ts.map +1 -1
- package/dist/skill-defs.d.ts.map +1 -1
- package/dist/skills/chant-grafana-alerting.md +49 -0
- package/dist/skills/chant-grafana-provisioning.md +3 -3
- package/dist/skills/chant-grafana.md +12 -6
- package/dist/spec/fetch-units-cli.d.ts +3 -0
- package/dist/spec/fetch-units-cli.d.ts.map +1 -0
- package/dist/spec/overlay.d.ts +43 -0
- package/dist/spec/overlay.d.ts.map +1 -0
- package/dist/spec/schemas.d.ts +13 -7
- package/dist/spec/schemas.d.ts.map +1 -1
- package/dist/spec/units.d.ts +35 -0
- package/dist/spec/units.d.ts.map +1 -0
- package/dist/spec/units.gen.d.ts +2 -0
- package/dist/spec/units.gen.d.ts.map +1 -0
- package/dist/transformations.d.ts +459 -0
- package/dist/transformations.d.ts.map +1 -0
- package/dist/util.d.ts +6 -0
- package/dist/util.d.ts.map +1 -1
- package/dist/validate-alerting.d.ts +65 -0
- package/dist/validate-alerting.d.ts.map +1 -0
- package/dist/validate-output.d.ts +49 -9
- package/dist/validate-output.d.ts.map +1 -1
- package/dist/validate.d.ts.map +1 -1
- package/dist/variables.d.ts +7 -2
- package/dist/variables.d.ts.map +1 -1
- package/package.json +12 -4
- package/src/actions/actions.test.ts +24 -0
- package/src/actions/grafana.ts +40 -0
- package/src/actions/index.ts +1 -0
- package/src/alerting-build.ts +376 -0
- package/src/alerting.e2e.test.ts +212 -0
- package/src/alerting.test.ts +272 -0
- package/src/alerting.ts +435 -0
- package/src/api/apply.test.ts +238 -0
- package/src/api/apply.ts +384 -0
- package/src/api/bind.ts +58 -0
- package/src/api/client.ts +148 -0
- package/src/api/converge.ts +63 -0
- package/src/api/dashboards.ts +247 -0
- package/src/api/datasources.ts +33 -0
- package/src/api/fake-grafana-writes.ts +201 -0
- package/src/api/fake-grafana.ts +186 -0
- package/src/api/folders.ts +265 -0
- package/src/api/library-panels.ts +101 -0
- package/src/build.test.ts +210 -5
- package/src/build.ts +180 -43
- package/src/catalog.ts +86 -2
- package/src/codegen/docs.ts +42 -9
- package/src/codegen/schema-types.ts +16 -6
- package/src/composites/agent-dashboard.ts +6 -3
- package/src/composites/catalog.test.ts +2 -2
- package/src/composites/catalog.ts +82 -0
- package/src/composites/composites.test.ts +73 -9
- package/src/composites/index.ts +4 -2
- package/src/composites/queries.e2e.test.ts +374 -0
- package/src/composites/red-dashboard.ts +83 -12
- package/src/composites/shared.ts +11 -0
- package/src/composites/slo-alert-rules.ts +149 -0
- package/src/config.test.ts +61 -0
- package/src/config.ts +138 -0
- package/src/contact-point-secrets.ts +63 -0
- package/src/dashboard.ts +16 -2
- package/src/datasource-refs.test.ts +56 -0
- package/src/datasource-refs.ts +189 -0
- package/src/datasource.ts +52 -0
- package/src/deep-observe-hooks.ts +252 -0
- package/src/deep-observe.test.ts +265 -0
- package/src/deep-observe.ts +164 -0
- package/src/describe-resources.test.ts +255 -0
- package/src/describe-resources.ts +209 -0
- package/src/detect.ts +79 -2
- package/src/export-resources.test.ts +129 -0
- package/src/export-resources.ts +84 -0
- package/src/generated/lexicon-grafana.json +135 -0
- package/src/import/alerting-roundtrip.test.ts +161 -0
- package/src/import/alerting.ts +500 -0
- package/src/import/edits.ts +95 -0
- package/src/import/embedded.test.ts +45 -0
- package/src/import/embedded.ts +47 -0
- package/src/import/generated-types.e2e.test.ts +118 -0
- package/src/import/generator.test.ts +210 -0
- package/src/import/generator.ts +462 -0
- package/src/import/live-export.ts +264 -0
- package/src/import/mappings.ts +264 -0
- package/src/import/model.ts +110 -0
- package/src/import/normalize-alerting.ts +101 -0
- package/src/import/normalize.test.ts +117 -0
- package/src/import/normalize.ts +364 -0
- package/src/import/parser.test.ts +440 -0
- package/src/import/parser.ts +1236 -0
- package/src/import/report.ts +62 -0
- package/src/import/roundtrip.test.ts +468 -0
- package/src/import/testdata/fixtures.ts +129 -0
- package/src/import/v2.test.ts +292 -0
- package/src/import/v2.ts +803 -0
- package/src/import.e2e.test.ts +31 -84
- package/src/import.test.ts +9 -3
- package/src/index.ts +190 -5
- package/src/k8s.test.ts +98 -0
- package/src/k8s.ts +197 -0
- package/src/lint/audit-catalog.ts +60 -3
- package/src/lint/core-lint.test.ts +43 -0
- package/src/lint/post-synth/graf101.ts +3 -3
- package/src/lint/post-synth/graf102.ts +1 -1
- package/src/lint/post-synth/graf107.ts +1 -1
- package/src/lint/post-synth/graf108.ts +17 -0
- package/src/lint/post-synth/graf109.ts +17 -0
- package/src/lint/post-synth/graf111.ts +17 -0
- package/src/lint/post-synth/graf112.ts +17 -0
- package/src/lint/post-synth/graf113.ts +17 -0
- package/src/lint/post-synth/graf114.ts +17 -0
- package/src/lint/post-synth/graf115.ts +17 -0
- package/src/lint/post-synth/grafana-helpers.ts +15 -8
- package/src/lint/post-synth/index.ts +14 -0
- package/src/lint/post-synth/post-synth.test.ts +235 -11
- package/src/lint/rules/literal-secret.ts +60 -6
- package/src/lint/rules/rules.test.ts +27 -0
- package/src/lsp/completions.test.ts +5 -0
- package/src/lsp/hover.test.ts +7 -0
- package/src/lsp/hover.ts +8 -1
- package/src/members.ts +68 -0
- package/src/observe.e2e.test.ts +255 -0
- package/src/op/activities/grafana-apply.e2e.test.ts +175 -0
- package/src/op/activities/grafana-apply.test.ts +229 -0
- package/src/op/activities/grafana-apply.ts +171 -0
- package/src/op/activities/index.ts +8 -0
- package/src/op/builders.test.ts +40 -0
- package/src/op/builders.ts +34 -0
- package/src/ownership.ts +103 -0
- package/src/panel-options.ts +66 -0
- package/src/panels.test.ts +51 -0
- package/src/panels.ts +148 -10
- package/src/pin.ts +57 -6
- package/src/plugin.test.ts +5 -2
- package/src/plugin.ts +66 -0
- package/src/promql-check.test.ts +108 -0
- package/src/promql-check.ts +189 -0
- package/src/query.ts +13 -8
- package/src/schema/barchart.gen.ts +221 -0
- package/src/schema/bargauge.gen.ts +111 -0
- package/src/schema/canvas.gen.ts +176 -0
- package/src/schema/dashboard.gen.ts +206 -22
- package/src/schema/expr.gen.ts +618 -0
- package/src/schema/gauge.gen.ts +2 -1
- package/src/schema/geomap.gen.ts +112 -0
- package/src/schema/heatmap.gen.ts +2 -1
- package/src/schema/histogram.gen.ts +151 -0
- package/src/schema/index.ts +12 -0
- package/src/schema/logs.gen.ts +3 -1
- package/src/schema/loki.gen.ts +2 -1
- package/src/schema/nodegraph.gen.ts +58 -0
- package/src/schema/piechart.gen.ts +146 -0
- package/src/schema/prometheus.gen.ts +2 -1
- package/src/schema/stat.gen.ts +2 -1
- package/src/schema/statetimeline.gen.ts +143 -0
- package/src/schema/statushistory.gen.ts +132 -0
- package/src/schema/table.gen.ts +27 -4
- package/src/schema/tempo.gen.ts +2 -1
- package/src/schema/text.gen.ts +2 -1
- package/src/schema/timeseries.gen.ts +7 -2
- package/src/schema/trend.gen.ts +208 -0
- package/src/schema/xychart.gen.ts +167 -0
- package/src/schema-overlay.test.ts +282 -0
- package/src/schema-validate.ts +141 -50
- package/src/schema.test.ts +4 -2
- package/src/serializer.test.ts +13 -1
- package/src/serializer.ts +11 -3
- package/src/skill-defs.ts +17 -0
- package/src/skills/chant-grafana-alerting.md +49 -0
- package/src/skills/chant-grafana-provisioning.md +3 -3
- package/src/skills/chant-grafana.md +12 -6
- package/src/spec/fetch-cli.ts +3 -3
- package/src/spec/fetch-units-cli.ts +37 -0
- package/src/spec/overlay/canvas.overlay.json +142 -0
- package/src/spec/overlay/dashboard.overlay.json +378 -0
- package/src/spec/overlay/expr.overlay.json +14 -0
- package/src/spec/overlay/geomap.overlay.json +35 -0
- package/src/spec/overlay/logs.overlay.json +14 -0
- package/src/spec/overlay/nodegraph.overlay.json +31 -0
- package/src/spec/overlay/piechart.overlay.json +17 -0
- package/src/spec/overlay/table.overlay.json +84 -0
- package/src/spec/overlay/timeseries.overlay.json +21 -0
- package/src/spec/overlay/trend.overlay.json +17 -0
- package/src/spec/overlay/xychart.overlay.json +16 -0
- package/src/spec/overlay.ts +105 -0
- package/src/spec/schemas/barchart.jsonschema.json +419 -0
- package/src/spec/schemas/bargauge.jsonschema.json +224 -0
- package/src/spec/schemas/canvas.jsonschema.json +356 -0
- package/src/spec/schemas/dashboardv2.jsonschema.json +3387 -0
- package/src/spec/schemas/expr.jsonschema.json +987 -0
- package/src/spec/schemas/geomap.jsonschema.json +220 -0
- package/src/spec/schemas/histogram.jsonschema.json +308 -0
- package/src/spec/schemas/nodegraph.jsonschema.json +77 -0
- package/src/spec/schemas/piechart.jsonschema.json +275 -0
- package/src/spec/schemas/statetimeline.jsonschema.json +324 -0
- package/src/spec/schemas/statushistory.jsonschema.json +292 -0
- package/src/spec/schemas/trend.jsonschema.json +449 -0
- package/src/spec/schemas/xychart.jsonschema.json +428 -0
- package/src/spec/schemas.ts +22 -10
- package/src/spec/units.gen.ts +281 -0
- package/src/spec/units.ts +77 -0
- package/src/transformations.test.ts +65 -0
- package/src/transformations.ts +574 -0
- package/src/util.ts +8 -0
- package/src/validate-alerting.test.ts +255 -0
- package/src/validate-alerting.ts +428 -0
- package/src/validate-output.ts +332 -101
- package/src/validate.ts +14 -0
- package/src/variables.ts +7 -2
|
@@ -0,0 +1,574 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Panel transformations, typed per transformer.
|
|
3
|
+
*
|
|
4
|
+
* The dashboard schema types a transformation as `{ id: string; options:
|
|
5
|
+
* {} }`: foundation-sdk v0.0.20 has no schema for any transformer's options.
|
|
6
|
+
* The option types below are transcribed from the transformers Grafana
|
|
7
|
+
* v13.2.2 registers (tag v13.2.2, commit
|
|
8
|
+
* 3db12332b66497c31f8ad2a5fb0eb0fe0ca05a7e):
|
|
9
|
+
*
|
|
10
|
+
* - `packages/grafana-data/src/transformations/transformers/<id>.ts` for the
|
|
11
|
+
* standard transformers, `transformers/ids.ts` for their ids;
|
|
12
|
+
* - `public/app/features/transformers/**` for the ones the app registers
|
|
13
|
+
* (heatmap, extractFields, configFromData, rowsToFields, joinByLabels,
|
|
14
|
+
* partitionByValues, prepareTimeSeries, timeSeriesTable, regression,
|
|
15
|
+
* smoothing, spatial, fieldLookup);
|
|
16
|
+
* - enums from `fieldReducer.ts` (ReducerID), `utils/binaryOperators.ts`,
|
|
17
|
+
* `utils/unaryOperators.ts`, `types/dataFrame.ts` (FieldType,
|
|
18
|
+
* EnumFieldConfig), `types/data.ts` (NullValueMode),
|
|
19
|
+
* `types/transformations.ts` (SpecialValue),
|
|
20
|
+
* `transformers/joinShared.ts` (JoinMode) and
|
|
21
|
+
* `matchers/nameMatcher.ts` (RegexpOrNamesMatcherOptions).
|
|
22
|
+
*
|
|
23
|
+
* Every top-level option is optional: Grafana spreads each transformer's
|
|
24
|
+
* `defaultOptions` under the stored options before it runs
|
|
25
|
+
* (`transformDataFrame`), so a dashboard stores only what was set. Nested
|
|
26
|
+
* objects keep Grafana's required fields.
|
|
27
|
+
*
|
|
28
|
+
* A transformation whose id Grafana doesn't register (a plugin's), or whose
|
|
29
|
+
* options this file doesn't know, goes through `customTransformation()`.
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
import type { MatcherConfig } from "./schema/dashboard.gen";
|
|
33
|
+
import type { HeatmapCalculationOptions } from "./schema/heatmap.gen";
|
|
34
|
+
import type { FrameGeometrySource } from "./schema/geomap.gen";
|
|
35
|
+
|
|
36
|
+
// ── Shared enums (as the string values Grafana stores) ──────────
|
|
37
|
+
|
|
38
|
+
/** `ReducerID` in `fieldReducer.ts`. */
|
|
39
|
+
export type ReducerId =
|
|
40
|
+
| "sum"
|
|
41
|
+
| "max"
|
|
42
|
+
| "min"
|
|
43
|
+
| "logmin"
|
|
44
|
+
| "mean"
|
|
45
|
+
| "variance"
|
|
46
|
+
| "stdDev"
|
|
47
|
+
| "last"
|
|
48
|
+
| "median"
|
|
49
|
+
| "first"
|
|
50
|
+
| "count"
|
|
51
|
+
| "countAll"
|
|
52
|
+
| "range"
|
|
53
|
+
| "diff"
|
|
54
|
+
| "diffperc"
|
|
55
|
+
| "delta"
|
|
56
|
+
| "step"
|
|
57
|
+
| "firstNotNull"
|
|
58
|
+
| "lastNotNull"
|
|
59
|
+
| "changeCount"
|
|
60
|
+
| "distinctCount"
|
|
61
|
+
| "allIsZero"
|
|
62
|
+
| "allIsNull"
|
|
63
|
+
| "allValues"
|
|
64
|
+
| "uniqueValues"
|
|
65
|
+
| `p${Percentile}`;
|
|
66
|
+
|
|
67
|
+
type Digit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9";
|
|
68
|
+
type NonZeroDigit = Exclude<Digit, "0">;
|
|
69
|
+
/** p1 to p99. */
|
|
70
|
+
type Percentile = NonZeroDigit | `${NonZeroDigit}${Digit}`;
|
|
71
|
+
|
|
72
|
+
/** `FieldType` in `types/dataFrame.ts`. */
|
|
73
|
+
export type FieldTypeId = "time" | "number" | "string" | "boolean" | "trace" | "geo" | "enum" | "other" | "frame" | "nestedFrames";
|
|
74
|
+
|
|
75
|
+
/** `SpecialValue` in `types/transformations.ts`. */
|
|
76
|
+
export type SpecialValue = "true" | "false" | "null" | "empty" | "zero";
|
|
77
|
+
|
|
78
|
+
/** `NullValueMode` in `types/data.ts`. */
|
|
79
|
+
export type NullValueMode = "null" | "connected" | "null as zero";
|
|
80
|
+
|
|
81
|
+
/** `RegexpOrNamesMatcherOptions` in `matchers/nameMatcher.ts`. */
|
|
82
|
+
export interface RegexpOrNamesMatcherOptions {
|
|
83
|
+
pattern?: string;
|
|
84
|
+
names?: string[];
|
|
85
|
+
variable?: string;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// ── Standard transformers (packages/grafana-data) ───────────────
|
|
89
|
+
|
|
90
|
+
/** `calculateField.ts`. */
|
|
91
|
+
export interface CalculateFieldOptions {
|
|
92
|
+
timeSeries?: boolean;
|
|
93
|
+
mode?: "reduceRow" | "cumulativeFunctions" | "windowFunctions" | "binary" | "unary" | "index";
|
|
94
|
+
reduce?: { include?: string[]; reducer: ReducerId; nullValueMode?: NullValueMode };
|
|
95
|
+
window?: {
|
|
96
|
+
field?: string;
|
|
97
|
+
reducer: ReducerId;
|
|
98
|
+
windowSize?: number;
|
|
99
|
+
windowSizeMode?: "percentage" | "fixed";
|
|
100
|
+
windowAlignment?: "trailing" | "centered";
|
|
101
|
+
};
|
|
102
|
+
cumulative?: { field?: string; reducer: ReducerId };
|
|
103
|
+
binary?: { left: CalculateFieldBinaryValue; operator: "+" | "-" | "/" | "*"; right: CalculateFieldBinaryValue };
|
|
104
|
+
unary?: { operator: "abs" | "exp" | "ln" | "round" | "floor" | "ceil" | "percent"; fieldName: string };
|
|
105
|
+
index?: { asPercentile: boolean };
|
|
106
|
+
replaceFields?: boolean;
|
|
107
|
+
alias?: string;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* One side of a binary calculation. Grafana 10.3 and later store
|
|
112
|
+
* `{ fixed }` or `{ matcher: { id: "byName", options } }`; older
|
|
113
|
+
* dashboards store the field name or number as a plain string, which
|
|
114
|
+
* Grafana still reads.
|
|
115
|
+
*/
|
|
116
|
+
export type CalculateFieldBinaryValue = string | { fixed?: string; matcher?: { id?: string; options?: string } };
|
|
117
|
+
|
|
118
|
+
/** `concat.ts`. */
|
|
119
|
+
export interface ConcatenateOptions {
|
|
120
|
+
frameNameMode?: "drop" | "field" | "label";
|
|
121
|
+
frameNameLabel?: string;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/** `convertFieldType.ts`. */
|
|
125
|
+
export interface ConvertFieldTypeOptions {
|
|
126
|
+
conversions?: Array<{
|
|
127
|
+
targetField?: string;
|
|
128
|
+
destinationType?: FieldTypeId;
|
|
129
|
+
dateFormat?: string;
|
|
130
|
+
joinWith?: string;
|
|
131
|
+
timezone?: string;
|
|
132
|
+
enumConfig?: { text?: string[]; color?: string[]; icon?: string[]; description?: string[] };
|
|
133
|
+
}>;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/** `convertFrameType.ts`. */
|
|
137
|
+
export interface ConvertFrameTypeOptions {
|
|
138
|
+
targetType?: "exemplar" | "timeRegion" | "annotation";
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/** `filter.ts` (filterFields and filterFrames). */
|
|
142
|
+
export interface FilterOptions {
|
|
143
|
+
include?: MatcherConfig;
|
|
144
|
+
exclude?: MatcherConfig;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/** `filterByName.ts`. */
|
|
148
|
+
export interface FilterFieldsByNameOptions {
|
|
149
|
+
include?: RegexpOrNamesMatcherOptions;
|
|
150
|
+
exclude?: RegexpOrNamesMatcherOptions;
|
|
151
|
+
byVariable?: boolean;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/** `filterByRefId.ts`. */
|
|
155
|
+
export interface FilterByRefIdOptions {
|
|
156
|
+
include?: string;
|
|
157
|
+
exclude?: string;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/** `filterByValue.ts`. `config` is a value matcher: `{ id: "greater", options: { value: 10 } }`. */
|
|
161
|
+
export interface FilterByValueOptions {
|
|
162
|
+
filters?: Array<{ fieldName: string; config: MatcherConfig }>;
|
|
163
|
+
type?: "exclude" | "include";
|
|
164
|
+
match?: "all" | "any";
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/** `formatString.ts`. */
|
|
168
|
+
export interface FormatStringOptions {
|
|
169
|
+
stringField?: string;
|
|
170
|
+
substringStart?: number;
|
|
171
|
+
substringEnd?: number;
|
|
172
|
+
outputFormat?:
|
|
173
|
+
| "Upper Case"
|
|
174
|
+
| "Lower Case"
|
|
175
|
+
| "Sentence Case"
|
|
176
|
+
| "Title Case"
|
|
177
|
+
| "Pascal Case"
|
|
178
|
+
| "Camel Case"
|
|
179
|
+
| "Snake Case"
|
|
180
|
+
| "Kebab Case"
|
|
181
|
+
| "Trim"
|
|
182
|
+
| "Substring";
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/** `formatTime.ts`. `useTimezone` is in its `defaultOptions`. */
|
|
186
|
+
export interface FormatTimeOptions {
|
|
187
|
+
timeField?: string;
|
|
188
|
+
outputFormat?: string;
|
|
189
|
+
timezone?: string;
|
|
190
|
+
useTimezone?: boolean;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/** `groupBy.ts`, per field. */
|
|
194
|
+
export interface GroupByFieldOptions {
|
|
195
|
+
aggregations: ReducerId[];
|
|
196
|
+
operation: "aggregate" | "groupby" | null;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/** `groupBy.ts`. */
|
|
200
|
+
export interface GroupByOptions {
|
|
201
|
+
fields?: Record<string, GroupByFieldOptions>;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/** `groupToNestedTable.ts`: per-field options, or (V2) matcher rules. */
|
|
205
|
+
export interface GroupToNestedTableOptions {
|
|
206
|
+
showSubframeHeaders?: boolean;
|
|
207
|
+
expandAllRows?: boolean;
|
|
208
|
+
fields?: Record<string, GroupByFieldOptions>;
|
|
209
|
+
rules?: Array<{
|
|
210
|
+
matcher: MatcherConfig;
|
|
211
|
+
operation: "aggregate" | "groupby" | null;
|
|
212
|
+
aggregations: ReducerId[];
|
|
213
|
+
keepNestedField?: boolean;
|
|
214
|
+
}>;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/** `groupingToMatrix.ts`. */
|
|
218
|
+
export interface GroupingToMatrixOptions {
|
|
219
|
+
columnField?: string;
|
|
220
|
+
rowField?: string;
|
|
221
|
+
valueField?: string;
|
|
222
|
+
emptyValue?: SpecialValue;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/** `histogram.ts`. The editor stores sizes and offsets as numbers or strings. */
|
|
226
|
+
export interface HistogramOptions {
|
|
227
|
+
bucketCount?: number;
|
|
228
|
+
bucketSize?: number | string;
|
|
229
|
+
bucketOffset?: number | string;
|
|
230
|
+
combine?: boolean;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/** `joinByField.ts` (and the deprecated `seriesToColumns`). */
|
|
234
|
+
export interface JoinByFieldOptions {
|
|
235
|
+
byField?: string;
|
|
236
|
+
mode?: "outer" | "inner" | "outerTabular";
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
/** `labelsToFields.ts`. */
|
|
240
|
+
export interface LabelsToFieldsOptions {
|
|
241
|
+
mode?: "columns" | "rows";
|
|
242
|
+
keepLabels?: string[];
|
|
243
|
+
valueLabel?: string;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
/** `limit.ts`. A string is a variable reference. */
|
|
247
|
+
export interface LimitOptions {
|
|
248
|
+
limitField?: number | string;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
/** `order.ts`. */
|
|
252
|
+
export interface OrderOptions {
|
|
253
|
+
indexByName?: Record<string, number>;
|
|
254
|
+
orderByMode?: "manual" | "auto";
|
|
255
|
+
orderBy?: Array<{ type: "name" | "label"; name?: string; desc?: boolean }>;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
/** `rename.ts`. */
|
|
259
|
+
export interface RenameOptions {
|
|
260
|
+
renameByName?: Record<string, string>;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/** `organize.ts`: order, rename and exclude in one. */
|
|
264
|
+
export interface OrganizeOptions extends OrderOptions, RenameOptions {
|
|
265
|
+
excludeByName?: Record<string, boolean>;
|
|
266
|
+
includeByName?: Record<string, boolean>;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
/** `reduce.ts`. `fields` limits which fields are reduced. */
|
|
270
|
+
export interface ReduceOptions {
|
|
271
|
+
reducers?: ReducerId[];
|
|
272
|
+
fields?: MatcherConfig;
|
|
273
|
+
mode?: "seriesToRows" | "reduceFields";
|
|
274
|
+
includeTimeField?: boolean;
|
|
275
|
+
labelsToFields?: boolean;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
/** `renameByRegex.ts`. */
|
|
279
|
+
export interface RenameByRegexOptions {
|
|
280
|
+
regex?: string;
|
|
281
|
+
renamePattern?: string;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
/** `sortBy.ts`. Grafana uses only the first entry. */
|
|
285
|
+
export interface SortByOptions {
|
|
286
|
+
sort?: Array<{ field: string; desc?: boolean; index?: number }>;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
/** `transpose.ts`. */
|
|
290
|
+
export interface TransposeOptions {
|
|
291
|
+
firstFieldName?: string;
|
|
292
|
+
restFieldsName?: string;
|
|
293
|
+
emptyValue?: SpecialValue;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
/** A transformer that takes no options (merge, noop, seriesToRows, ensureColumns). */
|
|
297
|
+
export type NoOptions = Record<string, never>;
|
|
298
|
+
|
|
299
|
+
// ── Transformers the app registers (public/app/features/transformers) ──
|
|
300
|
+
|
|
301
|
+
/** `fieldToConfigMapping/fieldToConfigMapping.ts`. */
|
|
302
|
+
export interface FieldToConfigMapping {
|
|
303
|
+
fieldName: string;
|
|
304
|
+
reducerId?: ReducerId;
|
|
305
|
+
handlerKey: string | null;
|
|
306
|
+
handlerArguments?: { threshold?: { color?: string } };
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
/** `configFromQuery/configFromQuery.ts`. */
|
|
310
|
+
export interface ConfigFromDataOptions {
|
|
311
|
+
configRefId?: string;
|
|
312
|
+
mappings?: FieldToConfigMapping[];
|
|
313
|
+
applyTo?: MatcherConfig;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
/** `extractFields/types.ts`. */
|
|
317
|
+
export interface ExtractFieldsOptions {
|
|
318
|
+
source?: string;
|
|
319
|
+
jsonPaths?: Array<{ path: string; alias?: string }>;
|
|
320
|
+
delimiter?: string;
|
|
321
|
+
regExp?: string;
|
|
322
|
+
format?: "json" | "kvp" | "auto" | "regexp" | "delimiter";
|
|
323
|
+
replace?: boolean;
|
|
324
|
+
keepTime?: boolean;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
/** `lookupGazetteer/fieldLookup.ts`. */
|
|
328
|
+
export interface FieldLookupOptions {
|
|
329
|
+
lookupField?: string;
|
|
330
|
+
gazetteer?: string;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
/** `calculateHeatmap/heatmap.ts`: the heatmap panel's calculation options, plus `keepOriginalData`. */
|
|
334
|
+
export interface HeatmapTransformOptions extends HeatmapCalculationOptions {
|
|
335
|
+
keepOriginalData?: boolean;
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
/** `joinByLabels/joinByLabels.ts`. */
|
|
339
|
+
export interface JoinByLabelsOptions {
|
|
340
|
+
value?: string;
|
|
341
|
+
join?: string[];
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
/** `partitionByValues/partitionByValues.ts`. */
|
|
345
|
+
export interface PartitionByValuesOptions {
|
|
346
|
+
fields?: string[];
|
|
347
|
+
naming?: { asLabels?: boolean; append?: boolean; withNames?: boolean; separator1?: string; separator2?: string };
|
|
348
|
+
keepFields?: boolean;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
/** `prepareTimeSeries/prepareTimeSeries.ts`. */
|
|
352
|
+
export interface PrepareTimeSeriesOptions {
|
|
353
|
+
format?: "wide" | "long" | "multi" | "many";
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
/** `regression/regression.ts`. */
|
|
357
|
+
export interface RegressionOptions {
|
|
358
|
+
modelType?: "linear" | "polynomial";
|
|
359
|
+
degree?: number;
|
|
360
|
+
xFieldName?: string;
|
|
361
|
+
yFieldName?: string;
|
|
362
|
+
predictionCount?: number;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
/** `rowsToFields/rowsToFields.ts`. */
|
|
366
|
+
export interface RowsToFieldsOptions {
|
|
367
|
+
nameField?: string;
|
|
368
|
+
valueField?: string;
|
|
369
|
+
mappings?: FieldToConfigMapping[];
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
/** `smoothing/smoothing.ts`. */
|
|
373
|
+
export interface SmoothingOptions {
|
|
374
|
+
resolution?: number;
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
/** `spatial/models.gen.ts`. */
|
|
378
|
+
export interface SpatialOptions {
|
|
379
|
+
action?: "prepare" | "calculate" | "modify";
|
|
380
|
+
source?: FrameGeometrySource;
|
|
381
|
+
calculate?: { calc?: "heading" | "distance" | "area"; field?: string };
|
|
382
|
+
modify?: { op: "asLine" | "lineBuilder"; target?: FrameGeometrySource };
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
/** `timeSeriesTable/timeSeriesTableTransformer.ts`: per query refId. */
|
|
386
|
+
export type TimeSeriesTableOptions = Record<string, { stat?: ReducerId; timeField?: string; inlineStat?: boolean }>;
|
|
387
|
+
|
|
388
|
+
// ── The id -> options map ───────────────────────────────────────
|
|
389
|
+
|
|
390
|
+
/** Every transformer Grafana v13.2.2 registers, by the id a dashboard stores, and its options. */
|
|
391
|
+
export interface TransformationOptionsById {
|
|
392
|
+
calculateField: CalculateFieldOptions;
|
|
393
|
+
concatenate: ConcatenateOptions;
|
|
394
|
+
configFromData: ConfigFromDataOptions;
|
|
395
|
+
convertFieldType: ConvertFieldTypeOptions;
|
|
396
|
+
convertFrameType: ConvertFrameTypeOptions;
|
|
397
|
+
ensureColumns: NoOptions;
|
|
398
|
+
extractFields: ExtractFieldsOptions;
|
|
399
|
+
fieldLookup: FieldLookupOptions;
|
|
400
|
+
filterByRefId: FilterByRefIdOptions;
|
|
401
|
+
filterByValue: FilterByValueOptions;
|
|
402
|
+
filterFields: FilterOptions;
|
|
403
|
+
filterFieldsByName: FilterFieldsByNameOptions;
|
|
404
|
+
filterFrames: FilterOptions;
|
|
405
|
+
formatString: FormatStringOptions;
|
|
406
|
+
formatTime: FormatTimeOptions;
|
|
407
|
+
groupBy: GroupByOptions;
|
|
408
|
+
groupToNestedTable: GroupToNestedTableOptions;
|
|
409
|
+
groupingToMatrix: GroupingToMatrixOptions;
|
|
410
|
+
heatmap: HeatmapTransformOptions;
|
|
411
|
+
histogram: HistogramOptions;
|
|
412
|
+
joinByField: JoinByFieldOptions;
|
|
413
|
+
joinByLabels: JoinByLabelsOptions;
|
|
414
|
+
labelsToFields: LabelsToFieldsOptions;
|
|
415
|
+
limit: LimitOptions;
|
|
416
|
+
merge: NoOptions;
|
|
417
|
+
noop: NoOptions;
|
|
418
|
+
order: OrderOptions;
|
|
419
|
+
organize: OrganizeOptions;
|
|
420
|
+
partitionByValues: PartitionByValuesOptions;
|
|
421
|
+
prepareTimeSeries: PrepareTimeSeriesOptions;
|
|
422
|
+
reduce: ReduceOptions;
|
|
423
|
+
regression: RegressionOptions;
|
|
424
|
+
rename: RenameOptions;
|
|
425
|
+
renameByRegex: RenameByRegexOptions;
|
|
426
|
+
rowsToFields: RowsToFieldsOptions;
|
|
427
|
+
/** Deprecated in Grafana for `joinByField`, which takes the same options. */
|
|
428
|
+
seriesToColumns: JoinByFieldOptions;
|
|
429
|
+
seriesToRows: NoOptions;
|
|
430
|
+
smoothing: SmoothingOptions;
|
|
431
|
+
sortBy: SortByOptions;
|
|
432
|
+
spatial: SpatialOptions;
|
|
433
|
+
timeSeriesTable: TimeSeriesTableOptions;
|
|
434
|
+
transpose: TransposeOptions;
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
export type TransformationId = keyof TransformationOptionsById;
|
|
438
|
+
|
|
439
|
+
/** The fields every transformation has besides its id and options (`DataTransformerConfig`). */
|
|
440
|
+
export interface TransformationCommon {
|
|
441
|
+
/** A disabled transformation is skipped. */
|
|
442
|
+
disabled?: boolean;
|
|
443
|
+
/** Apply it only to the frames this matcher selects. */
|
|
444
|
+
filter?: MatcherConfig;
|
|
445
|
+
/** Where its input frames come from. */
|
|
446
|
+
topic?: "series" | "annotations" | "alertStates";
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
/** A transformation Grafana registers, with its options typed. */
|
|
450
|
+
export type KnownTransformation = {
|
|
451
|
+
[K in TransformationId]: TransformationCommon & { id: K; options?: TransformationOptionsById[K] };
|
|
452
|
+
}[TransformationId];
|
|
453
|
+
|
|
454
|
+
declare const custom: unique symbol;
|
|
455
|
+
|
|
456
|
+
/** A transformation built by `customTransformation()`: any id, untyped options. */
|
|
457
|
+
export interface CustomTransformation extends TransformationCommon {
|
|
458
|
+
id: string;
|
|
459
|
+
options: Record<string, unknown>;
|
|
460
|
+
/** Type-only: a plain object literal can't pose as one, so a typo in a known id or option is still an error. */
|
|
461
|
+
readonly [custom]: true;
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
/** What a panel's `transformations` takes. */
|
|
465
|
+
export type Transformation = KnownTransformation | CustomTransformation;
|
|
466
|
+
|
|
467
|
+
/**
|
|
468
|
+
* A transformation Grafana registers, typed by its id:
|
|
469
|
+
*
|
|
470
|
+
* ```ts
|
|
471
|
+
* transformation("organize", { excludeByName: { Time: true }, renameByName: { Value: "Requests" } })
|
|
472
|
+
* ```
|
|
473
|
+
*
|
|
474
|
+
* The same as writing `{ id: "organize", options: { ... } }` in `transformations`.
|
|
475
|
+
*/
|
|
476
|
+
export function transformation<K extends TransformationId>(
|
|
477
|
+
id: K,
|
|
478
|
+
options: TransformationOptionsById[K] = {} as TransformationOptionsById[K],
|
|
479
|
+
common: TransformationCommon = {},
|
|
480
|
+
): Extract<KnownTransformation, { id: K }> {
|
|
481
|
+
return { id, options, ...common } as Extract<KnownTransformation, { id: K }>;
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
/**
|
|
485
|
+
* A transformation with any id and options, for a plugin's transformer, or
|
|
486
|
+
* options newer than the ones typed here. Written to the dashboard as given,
|
|
487
|
+
* with any other keys in `common` beside them.
|
|
488
|
+
*/
|
|
489
|
+
export function customTransformation(
|
|
490
|
+
id: string,
|
|
491
|
+
options: Record<string, unknown> = {},
|
|
492
|
+
common: TransformationCommon & Record<string, unknown> = {},
|
|
493
|
+
): CustomTransformation {
|
|
494
|
+
return { id, options, ...common } as CustomTransformation;
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
// ── Runtime tables, for the importer ─────────────────────────────
|
|
498
|
+
|
|
499
|
+
type KeysOf<T> = { [P in keyof Required<T>]: true };
|
|
500
|
+
|
|
501
|
+
/**
|
|
502
|
+
* The top-level option keys of each transformer. Typed so that a key added
|
|
503
|
+
* to or removed from an options interface above must be changed here too.
|
|
504
|
+
*/
|
|
505
|
+
const OPTION_KEYS: { [K in TransformationId]: KeysOf<TransformationOptionsById[K]> | "any" } = {
|
|
506
|
+
calculateField: { timeSeries: true, mode: true, reduce: true, window: true, cumulative: true, binary: true, unary: true, index: true, replaceFields: true, alias: true },
|
|
507
|
+
concatenate: { frameNameMode: true, frameNameLabel: true },
|
|
508
|
+
configFromData: { configRefId: true, mappings: true, applyTo: true },
|
|
509
|
+
convertFieldType: { conversions: true },
|
|
510
|
+
convertFrameType: { targetType: true },
|
|
511
|
+
ensureColumns: {},
|
|
512
|
+
extractFields: { source: true, jsonPaths: true, delimiter: true, regExp: true, format: true, replace: true, keepTime: true },
|
|
513
|
+
fieldLookup: { lookupField: true, gazetteer: true },
|
|
514
|
+
filterByRefId: { include: true, exclude: true },
|
|
515
|
+
filterByValue: { filters: true, type: true, match: true },
|
|
516
|
+
filterFields: { include: true, exclude: true },
|
|
517
|
+
filterFieldsByName: { include: true, exclude: true, byVariable: true },
|
|
518
|
+
filterFrames: { include: true, exclude: true },
|
|
519
|
+
formatString: { stringField: true, substringStart: true, substringEnd: true, outputFormat: true },
|
|
520
|
+
formatTime: { timeField: true, outputFormat: true, timezone: true, useTimezone: true },
|
|
521
|
+
groupBy: { fields: true },
|
|
522
|
+
groupToNestedTable: { showSubframeHeaders: true, expandAllRows: true, fields: true, rules: true },
|
|
523
|
+
groupingToMatrix: { columnField: true, rowField: true, valueField: true, emptyValue: true },
|
|
524
|
+
heatmap: { xBuckets: true, yBuckets: true, keepOriginalData: true },
|
|
525
|
+
histogram: { bucketCount: true, bucketSize: true, bucketOffset: true, combine: true },
|
|
526
|
+
joinByField: { byField: true, mode: true },
|
|
527
|
+
joinByLabels: { value: true, join: true },
|
|
528
|
+
labelsToFields: { mode: true, keepLabels: true, valueLabel: true },
|
|
529
|
+
limit: { limitField: true },
|
|
530
|
+
merge: {},
|
|
531
|
+
noop: {},
|
|
532
|
+
order: { indexByName: true, orderByMode: true, orderBy: true },
|
|
533
|
+
organize: { indexByName: true, orderByMode: true, orderBy: true, renameByName: true, excludeByName: true, includeByName: true },
|
|
534
|
+
partitionByValues: { fields: true, naming: true, keepFields: true },
|
|
535
|
+
prepareTimeSeries: { format: true },
|
|
536
|
+
reduce: { reducers: true, fields: true, mode: true, includeTimeField: true, labelsToFields: true },
|
|
537
|
+
regression: { modelType: true, degree: true, xFieldName: true, yFieldName: true, predictionCount: true },
|
|
538
|
+
rename: { renameByName: true },
|
|
539
|
+
renameByRegex: { regex: true, renamePattern: true },
|
|
540
|
+
rowsToFields: { nameField: true, valueField: true, mappings: true },
|
|
541
|
+
seriesToColumns: { byField: true, mode: true },
|
|
542
|
+
seriesToRows: {},
|
|
543
|
+
smoothing: { resolution: true },
|
|
544
|
+
sortBy: { sort: true },
|
|
545
|
+
spatial: { action: true, source: true, calculate: true, modify: true },
|
|
546
|
+
// Keyed by query refId.
|
|
547
|
+
timeSeriesTable: "any",
|
|
548
|
+
transpose: { firstFieldName: true, restFieldsName: true, emptyValue: true },
|
|
549
|
+
};
|
|
550
|
+
|
|
551
|
+
export const TRANSFORMATION_IDS: readonly TransformationId[] = Object.keys(OPTION_KEYS) as TransformationId[];
|
|
552
|
+
|
|
553
|
+
const COMMON_KEYS = new Set(["id", "options", "disabled", "filter", "topic"]);
|
|
554
|
+
|
|
555
|
+
/**
|
|
556
|
+
* Why a transformation as stored can't be written as a typed one, or
|
|
557
|
+
* undefined when it can: an id Grafana doesn't register, a key beside
|
|
558
|
+
* `options` the config doesn't have, or an option key its transformer
|
|
559
|
+
* doesn't take.
|
|
560
|
+
*/
|
|
561
|
+
export function untypedTransformationReason(t: Record<string, unknown>): string | undefined {
|
|
562
|
+
const id = t.id;
|
|
563
|
+
if (typeof id !== "string" || !(id in OPTION_KEYS)) return `"${String(id)}" is not a transformer Grafana v13.2.2 registers`;
|
|
564
|
+
const extra = Object.keys(t).filter((k) => !COMMON_KEYS.has(k));
|
|
565
|
+
if (extra.length > 0) return `it has ${extra.map((k) => `"${k}"`).join(", ")} beside its id and options`;
|
|
566
|
+
const options = t.options;
|
|
567
|
+
if (options === undefined) return undefined;
|
|
568
|
+
if (typeof options !== "object" || options === null || Array.isArray(options)) return "its options are not an object";
|
|
569
|
+
const keys = OPTION_KEYS[id as TransformationId];
|
|
570
|
+
if (keys === "any") return undefined;
|
|
571
|
+
const unknown = Object.keys(options).filter((k) => !(k in keys));
|
|
572
|
+
if (unknown.length > 0) return `the ${id} transformer takes no option${unknown.length > 1 ? "s" : ""} ${unknown.map((k) => `"${k}"`).join(", ")}`;
|
|
573
|
+
return undefined;
|
|
574
|
+
}
|
package/src/util.ts
CHANGED
|
@@ -7,6 +7,14 @@ export type DeepPartial<T> = T extends (infer U)[]
|
|
|
7
7
|
? { [K in keyof T]?: DeepPartial<T[K]> }
|
|
8
8
|
: T;
|
|
9
9
|
|
|
10
|
+
/**
|
|
11
|
+
* The props a declaration class takes: `PropsOf<typeof TimeSeriesPanel>["options"]`
|
|
12
|
+
* types a const that is passed as a panel's `options`. The TypeScript
|
|
13
|
+
* `chant import` writes annotates its lifted consts this way.
|
|
14
|
+
*/
|
|
15
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
16
|
+
export type PropsOf<C extends abstract new (props: any) => unknown> = NonNullable<ConstructorParameters<C>[0]>;
|
|
17
|
+
|
|
10
18
|
/** Grafana's uid alphabet: letters, digits, `-` and `_`, at most 40 characters. */
|
|
11
19
|
export const UID_PATTERN = /^[A-Za-z0-9_-]{1,40}$/;
|
|
12
20
|
|