@intentius/chant-lexicon-grafana 0.98.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,156 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Grafana API applier (#2948): folders, library panels and dashboards
|
|
3
|
+
* written over Grafana's HTTP API, stamped with chant's ownership labels,
|
|
4
|
+
* and an owned-only prune.
|
|
5
|
+
*
|
|
6
|
+
* ## The API path
|
|
7
|
+
*
|
|
8
|
+
* The server's dashboard API is discovered once per client
|
|
9
|
+
* (`dashboardApi` in ./dashboards.ts, shared with observe):
|
|
10
|
+
*
|
|
11
|
+
* - **Grafana 12.4 and 13.x**: `dashboard.grafana.app` (`v1beta1` on 12.4,
|
|
12
|
+
* `v1` on 13.x). A dashboard is created with `POST` to the collection and
|
|
13
|
+
* updated with `PUT` to its name, without a `resourceVersion`, which both
|
|
14
|
+
* versions accept as an unconditional update. The resource carries the
|
|
15
|
+
* classic JSON in `spec`, chant's labels in `metadata.labels`
|
|
16
|
+
* (`grafanaOwnershipLabels`, the marker observe reads back), and its
|
|
17
|
+
* folder in the `grafana.app/folder` annotation.
|
|
18
|
+
* - **Grafana 11**: `POST /api/dashboards/db` with `overwrite: true` and the
|
|
19
|
+
* folder's uid. There is no metadata channel, so nothing is stamped and
|
|
20
|
+
* nothing is pruned: the prune reports both kinds as `not-prunable`.
|
|
21
|
+
*
|
|
22
|
+
* Folders are ./folders.ts and library panels ./library-panels.ts. The write
|
|
23
|
+
* order is folders (parents first), then library panels, then dashboards, so
|
|
24
|
+
* nothing is written before what it references.
|
|
25
|
+
*
|
|
26
|
+
* ## Unchanged
|
|
27
|
+
*
|
|
28
|
+
* Every write is preceded by a read, and a resource whose live content
|
|
29
|
+
* already covers what would be sent (./converge.ts), with the same folder
|
|
30
|
+
* and labels, is `unchanged` and not written.
|
|
31
|
+
*
|
|
32
|
+
* ## Prune
|
|
33
|
+
*
|
|
34
|
+
* Only with `prune`, and only what carries this project's marker: chant's
|
|
35
|
+
* managed-by label with the same stack and the same env (an env-less marker
|
|
36
|
+
* matches only an env-less apply). Dashboards go first, then folders, a
|
|
37
|
+
* child before its parent, and a folder that still holds anything after
|
|
38
|
+
* that (a dashboard saved into it in the UI, a library panel) is left, as
|
|
39
|
+
* `not-prunable` with what it holds. Library panels are never pruned: their
|
|
40
|
+
* API has no labels.
|
|
41
|
+
*/
|
|
42
|
+
import { type OwnershipMarker } from "@intentius/chant/ownership";
|
|
43
|
+
import type { NotAttemptedReason } from "@intentius/chant/apply";
|
|
44
|
+
import { type GrafanaClient } from "./client.js";
|
|
45
|
+
import { type FolderPlan } from "./folders.js";
|
|
46
|
+
import { type LibraryPanelPlan } from "./library-panels.js";
|
|
47
|
+
type Json = Record<string, unknown>;
|
|
48
|
+
/** The kinds the applier names in its result: Grafana's own type names. */
|
|
49
|
+
export declare const GRAFANA_APPLY_KINDS: {
|
|
50
|
+
readonly dashboard: "Dashboard";
|
|
51
|
+
readonly folder: "Folder";
|
|
52
|
+
readonly libraryPanel: "LibraryPanel";
|
|
53
|
+
/** An `__elements` entry that is not a panel (a library variable), which the applier cannot write. */
|
|
54
|
+
readonly libraryElement: "LibraryElement";
|
|
55
|
+
};
|
|
56
|
+
/** One dashboard a build needs. */
|
|
57
|
+
export interface DashboardPlan {
|
|
58
|
+
readonly uid: string;
|
|
59
|
+
/** The classic dashboard JSON, without the export-only keys. */
|
|
60
|
+
readonly json: Json;
|
|
61
|
+
readonly folderUid?: string;
|
|
62
|
+
}
|
|
63
|
+
/** Everything one apply writes, in the order it writes it. */
|
|
64
|
+
export interface GrafanaApplyPlan {
|
|
65
|
+
readonly folders: FolderPlan[];
|
|
66
|
+
readonly libraryPanels: LibraryPanelPlan[];
|
|
67
|
+
readonly dashboards: DashboardPlan[];
|
|
68
|
+
/** What the input declared that the applier has no writer for. */
|
|
69
|
+
readonly unsupported: Array<{
|
|
70
|
+
kind: string;
|
|
71
|
+
name: string;
|
|
72
|
+
detail: string;
|
|
73
|
+
}>;
|
|
74
|
+
}
|
|
75
|
+
/** A dashboard as the build hands it over: its JSON and the folder title it names. */
|
|
76
|
+
export interface BuiltDashboardInput {
|
|
77
|
+
readonly json: Json;
|
|
78
|
+
readonly folder?: string;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Turn built dashboards into an apply plan: the folders they name, the
|
|
82
|
+
* library panels their `__elements` carry, and the dashboards themselves.
|
|
83
|
+
* Throws on a plan no apply could satisfy: a dashboard with no uid, two
|
|
84
|
+
* dashboards with one uid, or one library panel uid with two models.
|
|
85
|
+
*/
|
|
86
|
+
export declare function planFromDashboards(dashboards: readonly BuiltDashboardInput[]): GrafanaApplyPlan;
|
|
87
|
+
/** Every resource in a plan, as `{ kind, name }`: what the result must account for. */
|
|
88
|
+
export declare function planRefs(plan: GrafanaApplyPlan): Array<{
|
|
89
|
+
kind: string;
|
|
90
|
+
name: string;
|
|
91
|
+
}>;
|
|
92
|
+
export type AppliedAction = "created" | "updated" | "unchanged";
|
|
93
|
+
/** What the applier did, in its own terms. `toApplyResult` projects it onto core's envelope. */
|
|
94
|
+
export interface GrafanaApplyOutcome {
|
|
95
|
+
/** Where the binding came from: `grafana.profiles.prod`, `env GRAFANA_URL`. Empty when nothing was bound. */
|
|
96
|
+
target: string;
|
|
97
|
+
/** The dashboard API written to: `apis/v1`, `apis/v1beta1` or `legacy`. Empty when nothing was written. */
|
|
98
|
+
api: string;
|
|
99
|
+
applied: Array<{
|
|
100
|
+
kind: string;
|
|
101
|
+
name: string;
|
|
102
|
+
action: AppliedAction;
|
|
103
|
+
address: string;
|
|
104
|
+
}>;
|
|
105
|
+
pruned: Array<{
|
|
106
|
+
kind: string;
|
|
107
|
+
name: string;
|
|
108
|
+
deleted: boolean;
|
|
109
|
+
address: string;
|
|
110
|
+
}>;
|
|
111
|
+
notAttempted: Array<{
|
|
112
|
+
kind: string;
|
|
113
|
+
name: string;
|
|
114
|
+
reason: NotAttemptedReason;
|
|
115
|
+
detail?: string;
|
|
116
|
+
}>;
|
|
117
|
+
/** Kinds the prune could not consider at all, and why. Empty without `prune`. */
|
|
118
|
+
notPrunable: Array<{
|
|
119
|
+
kind: string;
|
|
120
|
+
detail: string;
|
|
121
|
+
}>;
|
|
122
|
+
}
|
|
123
|
+
export interface ApplyGrafanaOptions {
|
|
124
|
+
/**
|
|
125
|
+
* The stack and env stamped on every dashboard and folder, and the only
|
|
126
|
+
* marker the prune deletes. Without it, only the managed-by label is
|
|
127
|
+
* stamped and the prune does nothing (it reports why).
|
|
128
|
+
*/
|
|
129
|
+
marker?: OwnershipMarker;
|
|
130
|
+
/** Delete this project's dashboards and folders that the plan no longer has. Off by default. */
|
|
131
|
+
prune?: boolean;
|
|
132
|
+
signal?: AbortSignal;
|
|
133
|
+
}
|
|
134
|
+
/** The labels an apply stamps: the full marker, or only managed-by when no stack is known. */
|
|
135
|
+
export declare function stampLabels(marker: OwnershipMarker | undefined): Record<string, string>;
|
|
136
|
+
/** True when `labels` carry exactly this project's marker: chant's, this stack, this env. */
|
|
137
|
+
export declare function carriesMarker(labels: Readonly<Record<string, string>>, marker: OwnershipMarker): boolean;
|
|
138
|
+
/**
|
|
139
|
+
* Create or update one dashboard. Unchanged, with nothing written, when the
|
|
140
|
+
* live dashboard already covers the JSON and sits in the same folder with
|
|
141
|
+
* the same labels.
|
|
142
|
+
*/
|
|
143
|
+
export declare function ensureDashboard(client: GrafanaClient, plan: DashboardPlan, labels: Readonly<Record<string, string>>): Promise<{
|
|
144
|
+
action: AppliedAction;
|
|
145
|
+
address: string;
|
|
146
|
+
}>;
|
|
147
|
+
/**
|
|
148
|
+
* Apply `plan` to the Grafana behind `client`. Throws `GrafanaApiError` when
|
|
149
|
+
* a write fails; a refused first read (401/403) is returned instead, with
|
|
150
|
+
* every resource `no-credentials`, since nothing was written.
|
|
151
|
+
*/
|
|
152
|
+
export declare function applyGrafana(client: GrafanaClient, plan: GrafanaApplyPlan, opts?: ApplyGrafanaOptions): Promise<GrafanaApplyOutcome>;
|
|
153
|
+
/** Parse a stored dashboard JSON file's content; throws with the file name when it is not a JSON object. */
|
|
154
|
+
export declare function parseDashboardFile(content: string, file: string): Json;
|
|
155
|
+
export {};
|
|
156
|
+
//# sourceMappingURL=apply.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apply.d.ts","sourceRoot":"","sources":["../../src/api/apply.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAEH,OAAO,EAAsB,KAAK,eAAe,EAAE,MAAM,4BAA4B,CAAC;AACtF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,EAAmB,KAAK,aAAa,EAAE,MAAM,UAAU,CAAC;AAE/D,OAAO,EAUL,KAAK,UAAU,EAChB,MAAM,WAAW,CAAC;AACnB,OAAO,EAA0D,KAAK,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAIjH,KAAK,IAAI,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAMpC,2EAA2E;AAC3E,eAAO,MAAM,mBAAmB;;;;IAI9B,sGAAsG;;CAE9F,CAAC;AAEX,mCAAmC;AACnC,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,gEAAgE;IAChE,QAAQ,CAAC,IAAI,EAAE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E,IAAI,GAAE,mBAAwB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CA4C9I;AAgDD,4GAA4G;AAC5G,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAStE"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Binding a client for one environment: the config lookup, the target, the
|
|
3
|
+
* transport. Shared by observe, export and (#2948) apply, so all three read
|
|
4
|
+
* and write the same Grafana.
|
|
5
|
+
*/
|
|
6
|
+
import type { ChantConfig } from "@intentius/chant/config";
|
|
7
|
+
import type { UnobservedReason } from "@intentius/chant/observation";
|
|
8
|
+
import { GrafanaClient, type GrafanaHttp } from "./client.js";
|
|
9
|
+
import { type UnresolvedTarget } from "../config.js";
|
|
10
|
+
/** What callers may inject: tests pass `http` (and usually `config`), the CLI passes nothing. */
|
|
11
|
+
export interface BindOptions {
|
|
12
|
+
environment?: string;
|
|
13
|
+
/** The project's config. Loaded from `cwd` (default: the working directory) when omitted. */
|
|
14
|
+
config?: Pick<ChantConfig, "grafana">;
|
|
15
|
+
cwd?: string;
|
|
16
|
+
env?: Record<string, string | undefined>;
|
|
17
|
+
/** Transport override. The target is still resolved, so a test exercises the binding too. */
|
|
18
|
+
http?: GrafanaHttp;
|
|
19
|
+
}
|
|
20
|
+
/** A target that could not be resolved, thrown by {@link bindGrafana} and classified by {@link classifyGrafanaFailure}. */
|
|
21
|
+
export declare class GrafanaBindingError extends Error {
|
|
22
|
+
readonly unresolved: UnresolvedTarget;
|
|
23
|
+
constructor(unresolved: UnresolvedTarget);
|
|
24
|
+
}
|
|
25
|
+
/** Resolve the environment's target and return a client for it. Throws {@link GrafanaBindingError} when there is none. */
|
|
26
|
+
export declare function bindGrafana(options?: BindOptions): Promise<GrafanaClient>;
|
|
27
|
+
/** What a failed bind or read means, in the observation vocabulary. */
|
|
28
|
+
export declare function classifyGrafanaFailure(err: unknown): {
|
|
29
|
+
reason: UnobservedReason;
|
|
30
|
+
detail: string;
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=bind.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bind.d.ts","sourceRoot":"","sources":["../../src/api/bind.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,EAAmB,aAAa,EAAe,KAAK,WAAW,EAAE,MAAM,UAAU,CAAC;AACzF,OAAO,EAA4C,KAAK,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAE5F,iGAAiG;AACjG,MAAM,WAAW,WAAW;IAC1B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,6FAA6F;IAC7F,MAAM,CAAC,EAAE,IAAI,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;IACtC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;IACzC,6FAA6F;IAC7F,IAAI,CAAC,EAAE,WAAW,CAAC;CACpB;AAED,2HAA2H;AAC3H,qBAAa,mBAAoB,SAAQ,KAAK;IAChC,QAAQ,CAAC,UAAU,EAAE,gBAAgB;gBAA5B,UAAU,EAAE,gBAAgB;CAIlD;AAYD,0HAA0H;AAC1H,wBAAsB,WAAW,CAAC,OAAO,GAAE,WAAgB,GAAG,OAAO,CAAC,aAAa,CAAC,CAKnF;AAED,uEAAuE;AACvE,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,OAAO,GAAG;IAAE,MAAM,EAAE,gBAAgB,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAQjG"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Grafana HTTP transport (#2946): one client for observe, export and,
|
|
3
|
+
* later, the API applier (#2948), so all three reach the same instance with
|
|
4
|
+
* the same credentials.
|
|
5
|
+
*
|
|
6
|
+
* `GrafanaHttp` is the seam. The default is `fetch` against a resolved
|
|
7
|
+
* target (./target.ts); a test hands in a function that answers by path, so
|
|
8
|
+
* nothing needs a module mock.
|
|
9
|
+
*
|
|
10
|
+
* Status mapping is in one place ({@link statusVerdict}): a 404 is the only
|
|
11
|
+
* answer that means "not there", 401/403 mean the credentials were refused,
|
|
12
|
+
* and anything else that is not a 2xx is a failed read. A reader that turned
|
|
13
|
+
* a 500 or a refused token into "absent" would have `chant lifecycle plan`
|
|
14
|
+
* propose creating a dashboard that is running.
|
|
15
|
+
*/
|
|
16
|
+
/** How the client authenticates. A service account token is the usual form; basic auth suits a local instance. */
|
|
17
|
+
export type GrafanaAuth = {
|
|
18
|
+
readonly token: string;
|
|
19
|
+
} | {
|
|
20
|
+
readonly user: string;
|
|
21
|
+
readonly password: string;
|
|
22
|
+
};
|
|
23
|
+
/** A resolved Grafana instance: where, as whom, which organisation, and where that came from. */
|
|
24
|
+
export interface GrafanaTarget {
|
|
25
|
+
/** Base URL, without a trailing slash: `https://grafana.example.com`. */
|
|
26
|
+
readonly url: string;
|
|
27
|
+
readonly auth?: GrafanaAuth;
|
|
28
|
+
/** Organisation id; 1 when not set. Selects the `X-Grafana-Org-Id` header and the API namespace. */
|
|
29
|
+
readonly orgId?: number;
|
|
30
|
+
/**
|
|
31
|
+
* The `dashboard.grafana.app` namespace. Defaults to `default` for org 1
|
|
32
|
+
* and `org-<id>` otherwise; Grafana Cloud stacks use `stacks-<id>`.
|
|
33
|
+
*/
|
|
34
|
+
readonly namespace?: string;
|
|
35
|
+
/** Where the binding came from, in the project's vocabulary: `grafana.profiles.prod`, `env GRAFANA_URL`. */
|
|
36
|
+
readonly source: string;
|
|
37
|
+
}
|
|
38
|
+
export interface GrafanaResponse {
|
|
39
|
+
readonly status: number;
|
|
40
|
+
/** The parsed body, or undefined when it was empty or not JSON. */
|
|
41
|
+
readonly json: unknown;
|
|
42
|
+
}
|
|
43
|
+
/** One request. `path` starts with `/` and is relative to the target's URL. */
|
|
44
|
+
export type GrafanaHttp = (method: string, path: string, body?: unknown) => Promise<GrafanaResponse>;
|
|
45
|
+
/** The API namespace for a target (see {@link GrafanaTarget.namespace}). */
|
|
46
|
+
export declare function namespaceOf(target: Pick<GrafanaTarget, "orgId" | "namespace">): string;
|
|
47
|
+
/** The default transport: `fetch` against the target, JSON in and out. */
|
|
48
|
+
export declare function grafanaHttp(target: GrafanaTarget, fetchImpl?: typeof fetch): GrafanaHttp;
|
|
49
|
+
/** What a status means for a read. */
|
|
50
|
+
export type StatusVerdict = "ok" | "not-found" | "refused" | "failed";
|
|
51
|
+
export declare function statusVerdict(status: number): StatusVerdict;
|
|
52
|
+
/** A non-2xx answer, with enough to classify it and to say where it came from. */
|
|
53
|
+
export declare class GrafanaApiError extends Error {
|
|
54
|
+
readonly status: number;
|
|
55
|
+
readonly method: string;
|
|
56
|
+
readonly path: string;
|
|
57
|
+
readonly verdict: StatusVerdict;
|
|
58
|
+
constructor(status: number, method: string, path: string, body: unknown);
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* A bound client: the transport, the target it reaches, and per-client
|
|
62
|
+
* caches (the API version a server serves, folder titles) so N reads do not
|
|
63
|
+
* repeat the same lookup.
|
|
64
|
+
*/
|
|
65
|
+
export declare class GrafanaClient {
|
|
66
|
+
readonly http: GrafanaHttp;
|
|
67
|
+
readonly target: GrafanaTarget;
|
|
68
|
+
private readonly memo;
|
|
69
|
+
constructor(http: GrafanaHttp, target: GrafanaTarget);
|
|
70
|
+
get namespace(): string;
|
|
71
|
+
/** GET, returning the body; undefined on 404; throws {@link GrafanaApiError} on any other non-2xx. */
|
|
72
|
+
get<T = unknown>(path: string): Promise<T | undefined>;
|
|
73
|
+
/** Run `fn` once per key for this client's lifetime; concurrent callers share the promise. */
|
|
74
|
+
once<T>(key: string, fn: () => Promise<T>): Promise<T>;
|
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wB/F;AAED,sCAAsC;AACtC,MAAM,MAAM,aAAa,GAAG,IAAI,GAAG,WAAW,GAAG,SAAS,GAAG,QAAQ,CAAC;AAEtE,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,aAAa,CAK3D;AAED,kFAAkF;AAClF,qBAAa,eAAgB,SAAQ,KAAK;IAGtC,QAAQ,CAAC,MAAM,EAAE,MAAM;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM;IAJvB,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC;gBAErB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACrB,IAAI,EAAE,OAAO;CAOhB;AAED;;;;GAIG;AACH,qBAAa,aAAa;IAItB,QAAQ,CAAC,IAAI,EAAE,WAAW;IAC1B,QAAQ,CAAC,MAAM,EAAE,aAAa;IAJhC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAuC;gBAGjD,IAAI,EAAE,WAAW,EACjB,MAAM,EAAE,aAAa;IAGhC,IAAI,SAAS,IAAI,MAAM,CAEtB;IAED,sGAAsG;IAChG,GAAG,CAAC,CAAC,GAAG,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC;IAQ5D,8FAA8F;IAC9F,IAAI,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;CAUvD"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether what Grafana holds already is what the applier would write
|
|
3
|
+
* (#2948), so a re-apply reports `unchanged` and writes nothing.
|
|
4
|
+
*
|
|
5
|
+
* Grafana does not answer this itself: a `PUT` of identical content still
|
|
6
|
+
* bumps `generation` and `resourceVersion` (measured on 12.4.11 and 13.2.2),
|
|
7
|
+
* so a no-op cannot be told from an update after the fact. And the stored
|
|
8
|
+
* dashboard is not the one sent: Grafana fills in defaults
|
|
9
|
+
* (`fiscalYearStartMonth: 0`, `links: []`, `timepicker: {}`, ...), adds the
|
|
10
|
+
* built-in annotation, drops `null`s and empty `options`, and may migrate
|
|
11
|
+
* `schemaVersion`.
|
|
12
|
+
*
|
|
13
|
+
* So the test is one-sided: every value the applier would send must be in
|
|
14
|
+
* the live object, equal, and anything Grafana added on top is ignored. An
|
|
15
|
+
* array must match element for element, since a panel added in the UI is a
|
|
16
|
+
* change. The noise is the same list the drift hooks carry (#2946):
|
|
17
|
+
*
|
|
18
|
+
* - `null` and empty objects sent are satisfied by an absent key;
|
|
19
|
+
* - the built-in "Annotations & Alerts" annotation is ignored on both sides;
|
|
20
|
+
* - `id`, `version` and `uid` at the top level are identity, not content, and
|
|
21
|
+
* `schemaVersion` is Grafana's to migrate.
|
|
22
|
+
*/
|
|
23
|
+
/** Top-level dashboard keys that are identity or Grafana-managed, never content. */
|
|
24
|
+
export declare const IDENTITY_KEYS: readonly string[];
|
|
25
|
+
/**
|
|
26
|
+
* True when `live` already holds everything in `want`. For a dashboard,
|
|
27
|
+
* the top-level identity keys ({@link IDENTITY_KEYS}) are left out of the
|
|
28
|
+
* comparison.
|
|
29
|
+
*/
|
|
30
|
+
export declare function converged(want: unknown, live: unknown, opts?: {
|
|
31
|
+
dashboard?: boolean;
|
|
32
|
+
}): boolean;
|
|
33
|
+
//# sourceMappingURL=converge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"converge.d.ts","sourceRoot":"","sources":["../../src/api/converge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAQH,oFAAoF;AACpF,eAAO,MAAM,aAAa,EAAE,SAAS,MAAM,EAA8C,CAAC;AAuB1F;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,GAAE;IAAE,SAAS,CAAC,EAAE,OAAO,CAAA;CAAO,GAAG,OAAO,CAInG"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reading dashboards (#2946).
|
|
3
|
+
*
|
|
4
|
+
* Grafana 12 and 13 serve dashboards as Kubernetes-style resources under
|
|
5
|
+
* `/apis/dashboard.grafana.app/<version>/namespaces/<ns>/dashboards/<uid>`:
|
|
6
|
+
* the classic dashboard JSON in `spec`, and who manages it in
|
|
7
|
+
* `metadata.annotations` and `metadata.labels` (./../ownership.ts). The
|
|
8
|
+
* version is discovered once per client from the API group, preferring the
|
|
9
|
+
* newest classic (v1-family) version the server serves: `v1` on 13.x,
|
|
10
|
+
* `v1beta1` on 12.x. A server without the group (Grafana 11) is read over
|
|
11
|
+
* `GET /api/dashboards/uid/<uid>`, which has the same JSON and no metadata
|
|
12
|
+
* channel.
|
|
13
|
+
*
|
|
14
|
+
* ## The version branch is one place
|
|
15
|
+
*
|
|
16
|
+
* {@link classicDashboardOf} decides how a stored dashboard is read as
|
|
17
|
+
* classic JSON. Everything downstream (observe, deep observe, export) only
|
|
18
|
+
* ever sees its answer. A dashboard Grafana stores as v2 (the layout-and-
|
|
19
|
+
* elements schema) is not read through Grafana's own v2-to-v1 conversion,
|
|
20
|
+
* which drops what v1 cannot hold with nothing to show it (the importer
|
|
21
|
+
* refuses that read too, `lossyV1Read`). Instead {@link readDashboard} and
|
|
22
|
+
* {@link listDashboards} read it again at the newest v2 version the server
|
|
23
|
+
* serves (`v2` on 13.x, `v2beta1` on 12.x), and `classicDashboardOf`
|
|
24
|
+
* converts that with the importer's v2 reader (./../import/v2.ts), which
|
|
25
|
+
* names everything v2 holds that the classic model cannot (#2947). Only a
|
|
26
|
+
* v2-stored dashboard the server cannot serve at v2, or whose conversion
|
|
27
|
+
* failed, is reported as not readable.
|
|
28
|
+
*/
|
|
29
|
+
import type { GrafanaClient } from "./client.js";
|
|
30
|
+
type Json = Record<string, unknown>;
|
|
31
|
+
export declare const DASHBOARD_GROUP = "dashboard.grafana.app";
|
|
32
|
+
/** Classic-schema versions of the dashboard API, newest first. */
|
|
33
|
+
export declare const CLASSIC_DASHBOARD_VERSIONS: readonly string[];
|
|
34
|
+
/** v2-schema versions of the dashboard API the v2 reader understands, newest first. */
|
|
35
|
+
export declare const V2_DASHBOARD_VERSIONS: readonly string[];
|
|
36
|
+
/**
|
|
37
|
+
* How this server serves dashboards: the classic version it is read at,
|
|
38
|
+
* and the v2 version a dashboard stored as v2 is read at instead (#2947).
|
|
39
|
+
*/
|
|
40
|
+
export type DashboardApi = {
|
|
41
|
+
readonly kind: "apis";
|
|
42
|
+
readonly version: string;
|
|
43
|
+
readonly v2Version?: string;
|
|
44
|
+
} | {
|
|
45
|
+
readonly kind: "legacy";
|
|
46
|
+
};
|
|
47
|
+
/** The dashboard API the server behind `client` serves, discovered once per client. */
|
|
48
|
+
export declare function dashboardApi(client: GrafanaClient): Promise<DashboardApi>;
|
|
49
|
+
/** One dashboard as Grafana holds it. */
|
|
50
|
+
export interface LiveDashboard {
|
|
51
|
+
readonly uid: string;
|
|
52
|
+
/**
|
|
53
|
+
* The stored resource as it came back: a `dashboard.grafana.app` resource
|
|
54
|
+
* (`{ metadata, spec, status }`) or, on the legacy API, `{ dashboard, meta }`.
|
|
55
|
+
* Read it through {@link classicDashboardOf}.
|
|
56
|
+
*/
|
|
57
|
+
readonly raw: Json;
|
|
58
|
+
readonly via: "apis" | "legacy";
|
|
59
|
+
/** `metadata.labels`. Empty on the legacy API, which has no labels. */
|
|
60
|
+
readonly labels: Readonly<Record<string, string>>;
|
|
61
|
+
/** `metadata.annotations`. Empty on the legacy API. */
|
|
62
|
+
readonly annotations: Readonly<Record<string, string>>;
|
|
63
|
+
/** The folder's uid, when it is in one. */
|
|
64
|
+
readonly folderUid?: string;
|
|
65
|
+
/** The folder's title, when the read returned it (the legacy API does). */
|
|
66
|
+
readonly folderTitle?: string;
|
|
67
|
+
/** The request path it was read from. */
|
|
68
|
+
readonly address: string;
|
|
69
|
+
}
|
|
70
|
+
/** A dashboard read: there, not there (404), or there but not readable as classic JSON. */
|
|
71
|
+
export type DashboardRead = {
|
|
72
|
+
readonly present: LiveDashboard;
|
|
73
|
+
} | {
|
|
74
|
+
readonly absent: true;
|
|
75
|
+
readonly address: string;
|
|
76
|
+
};
|
|
77
|
+
/** The request path for one dashboard on this API (at `version` instead of the classic one, when given). */
|
|
78
|
+
export declare function dashboardPath(api: DashboardApi, namespace: string, uid: string, version?: string): string;
|
|
79
|
+
/** Read one dashboard by uid. Throws `GrafanaApiError` for anything but a 2xx or a 404. */
|
|
80
|
+
export declare function readDashboard(client: GrafanaClient, uid: string): Promise<DashboardRead>;
|
|
81
|
+
/** Every dashboard in the organisation, paged. */
|
|
82
|
+
export declare function listDashboards(client: GrafanaClient): Promise<LiveDashboard[]>;
|
|
83
|
+
/**
|
|
84
|
+
* The stored dashboard as classic JSON, with its uid, or why it cannot be
|
|
85
|
+
* read as one. The only place the dashboard schema version branches. A v2
|
|
86
|
+
* dashboard is converted by the importer's v2 reader; `warnings` then names
|
|
87
|
+
* what v2 holds that the classic JSON does not (tabs, auto grids,
|
|
88
|
+
* conditional rendering), and is absent for a classic dashboard.
|
|
89
|
+
*/
|
|
90
|
+
export declare function classicDashboardOf(dashboard: LiveDashboard): {
|
|
91
|
+
json: Json;
|
|
92
|
+
warnings?: string[];
|
|
93
|
+
} | {
|
|
94
|
+
unsupported: string;
|
|
95
|
+
};
|
|
96
|
+
/**
|
|
97
|
+
* The title of the folder a dashboard is in, or undefined for the General
|
|
98
|
+
* folder. One `GET /api/folders/<uid>` per folder per client.
|
|
99
|
+
*/
|
|
100
|
+
export declare function folderTitleOf(client: GrafanaClient, dashboard: LiveDashboard): Promise<string | undefined>;
|
|
101
|
+
export {};
|
|
102
|
+
//# sourceMappingURL=dashboards.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dashboards.d.ts","sourceRoot":"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E,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,yCAAyC;IACzC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED,2FAA2F;AAC3F,MAAM,MAAM,aAAa,GACrB;IAAE,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAA;CAAE,GACnC;IAAE,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAExD,4GAA4G;AAC5G,wBAAgB,aAAa,CAAC,GAAG,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAKzG;AA+CD,2FAA2F;AAC3F,wBAAsB,aAAa,CAAC,MAAM,EAAE,aAAa,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAO9F;AAED,kDAAkD;AAClD,wBAAsB,cAAc,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC,CA6BpF;AAYD;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,aAAa,GAAG;IAAE,IAAI,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAA;CAAE,GAAG;IAAE,WAAW,EAAE,MAAM,CAAA;CAAE,CAwB1H;AAED;;;GAGG;AACH,wBAAsB,aAAa,CAAC,MAAM,EAAE,aAAa,EAAE,SAAS,EAAE,aAAa,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAQhH"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reading datasources (#2946), over `GET /api/datasources/uid/<uid>` and
|
|
3
|
+
* `GET /api/datasources`. Grafana 12.4 and 13.2 serve no general
|
|
4
|
+
* datasource resource under `/apis`, so this is the one datasource API both
|
|
5
|
+
* have, and it carries no labels or annotations: a datasource's ownership
|
|
6
|
+
* cannot be read (see ../ownership.ts).
|
|
7
|
+
*
|
|
8
|
+
* The API never returns secret values. `secureJsonFields` says which
|
|
9
|
+
* secrets are set, and that is all this reads of them.
|
|
10
|
+
*/
|
|
11
|
+
import type { GrafanaClient } from "./client.js";
|
|
12
|
+
type Json = Record<string, unknown>;
|
|
13
|
+
export type DatasourceRead = {
|
|
14
|
+
readonly present: Json;
|
|
15
|
+
readonly address: string;
|
|
16
|
+
} | {
|
|
17
|
+
readonly absent: true;
|
|
18
|
+
readonly address: string;
|
|
19
|
+
};
|
|
20
|
+
export declare function datasourcePath(uid: string): string;
|
|
21
|
+
/** Read one datasource by uid. Throws `GrafanaApiError` for anything but a 2xx or a 404. */
|
|
22
|
+
export declare function readDatasource(client: GrafanaClient, uid: string): Promise<DatasourceRead>;
|
|
23
|
+
/** Every datasource in the organisation. */
|
|
24
|
+
export declare function listDatasources(client: GrafanaClient): Promise<Json[]>;
|
|
25
|
+
export {};
|
|
26
|
+
//# sourceMappingURL=datasources.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"datasources.d.ts","sourceRoot":"","sources":["../../src/api/datasources.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAE9C,KAAK,IAAI,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAEpC,MAAM,MAAM,cAAc,GAAG;IAAE,QAAQ,CAAC,OAAO,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAExI,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAElD;AAED,4FAA4F;AAC5F,wBAAsB,cAAc,CAAC,MAAM,EAAE,aAAa,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,CAIhG;AAED,4CAA4C;AAC5C,wBAAsB,eAAe,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC,CAG5E"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A Grafana that remembers writes, in memory, for the applier's tests
|
|
3
|
+
* (#2948). The read-only fake (./fake-grafana.ts) serves a fixed state for
|
|
4
|
+
* observe and export; this one serves the routes the applier writes to and
|
|
5
|
+
* keeps what it was sent, so a second apply sees the first one's result.
|
|
6
|
+
*
|
|
7
|
+
* It behaves as Grafana 12.4.11 and 13.2.2 did when the applier was checked
|
|
8
|
+
* against them (../op/activities/grafana-apply.e2e.test.ts): `POST` to an
|
|
9
|
+
* existing name is a 409, `PUT` needs no `resourceVersion`, a stored
|
|
10
|
+
* dashboard gets the built-in annotation and Grafana's defaults
|
|
11
|
+
* (`storedDashboard`), a folder with anything in it cannot be deleted over
|
|
12
|
+
* `/apis`, and a library element update needs its `version`. With
|
|
13
|
+
* `api: "legacy"` it is a Grafana 11: no `/apis` groups, dashboards over
|
|
14
|
+
* `/api/dashboards/db` and `/api/dashboards/uid`, folders over `/api/folders`.
|
|
15
|
+
*/
|
|
16
|
+
import type { GrafanaHttp } from "./client.js";
|
|
17
|
+
type Json = Record<string, unknown>;
|
|
18
|
+
export interface StoredResource {
|
|
19
|
+
spec: Json;
|
|
20
|
+
labels: Record<string, string>;
|
|
21
|
+
annotations: Record<string, string>;
|
|
22
|
+
}
|
|
23
|
+
export interface WritableGrafanaState {
|
|
24
|
+
/** `v1` (13.x), `v1beta1` (12.4), or `legacy` (11.x). */
|
|
25
|
+
api: "v1" | "v1beta1" | "legacy";
|
|
26
|
+
dashboards: Record<string, StoredResource>;
|
|
27
|
+
/** Folders by uid; `spec.title` is the title and the `grafana.app/folder` annotation the parent. */
|
|
28
|
+
folders: Record<string, StoredResource>;
|
|
29
|
+
libraryElements: Record<string, Json>;
|
|
30
|
+
namespace?: string;
|
|
31
|
+
/** Answer every request with this status (a refused token: 401). */
|
|
32
|
+
status?: number;
|
|
33
|
+
}
|
|
34
|
+
export declare function emptyGrafana(api: WritableGrafanaState["api"]): WritableGrafanaState;
|
|
35
|
+
/**
|
|
36
|
+
* A {@link GrafanaHttp} over `state`, which it changes as it is written to.
|
|
37
|
+
* Every request is recorded in `calls` as `METHOD path`.
|
|
38
|
+
*/
|
|
39
|
+
export declare function writableGrafana(state: WritableGrafanaState, calls?: string[]): GrafanaHttp;
|
|
40
|
+
export {};
|
|
41
|
+
//# sourceMappingURL=fake-grafana-writes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fake-grafana-writes.d.ts","sourceRoot":"","sources":["../../src/api/fake-grafana-writes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAmB,MAAM,UAAU,CAAC;AAG7D,KAAK,IAAI,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAMpC,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,IAAI,CAAC;IACX,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/B,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACrC;AAED,MAAM,WAAW,oBAAoB;IACnC,yDAAyD;IACzD,GAAG,EAAE,IAAI,GAAG,SAAS,GAAG,QAAQ,CAAC;IACjC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IAC3C,oGAAoG;IACpG,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IACxC,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IACtC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,oEAAoE;IACpE,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,wBAAgB,YAAY,CAAC,GAAG,EAAE,oBAAoB,CAAC,KAAK,CAAC,GAAG,oBAAoB,CAEnF;AAYD;;;GAGG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB,EAAE,KAAK,GAAE,MAAM,EAAO,GAAG,WAAW,CA2I9F"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A Grafana API in memory, for the observe and export tests (#2946).
|
|
3
|
+
*
|
|
4
|
+
* Serves the routes the readers use, from a state the test sets up, in the
|
|
5
|
+
* shapes Grafana 12.4.11 and 13.2.2 return (checked against both with the
|
|
6
|
+
* e2e in ../observe.e2e.test.ts): the API group discovery, dashboard
|
|
7
|
+
* resources under `/apis`, the legacy `/api/dashboards/uid` and
|
|
8
|
+
* `/api/search`, folders, and datasources. `storedDashboard` does to a built
|
|
9
|
+
* dashboard what Grafana does when it stores one.
|
|
10
|
+
*/
|
|
11
|
+
import type { GrafanaHttp } from "./client.js";
|
|
12
|
+
type Json = Record<string, unknown>;
|
|
13
|
+
export interface FakeDashboard {
|
|
14
|
+
/** The classic JSON, as it would be stored (see {@link storedDashboard}). */
|
|
15
|
+
spec: Json;
|
|
16
|
+
labels?: Record<string, string>;
|
|
17
|
+
annotations?: Record<string, string>;
|
|
18
|
+
/** The version it is stored at: `v0alpha1` for a classic dashboard, `v2beta1` for one saved as v2. */
|
|
19
|
+
storedVersion?: string;
|
|
20
|
+
/**
|
|
21
|
+
* For a dashboard stored as v2, its v2 spec, served at the v2 versions the
|
|
22
|
+
* server has (`spec` is then the classic read's down-conversion). Without
|
|
23
|
+
* it the v2 routes answer 404.
|
|
24
|
+
*/
|
|
25
|
+
v2?: Json;
|
|
26
|
+
folderUid?: string;
|
|
27
|
+
}
|
|
28
|
+
export interface FakeGrafanaState {
|
|
29
|
+
/** `v1` (13.x), `v1beta1` (12.x), or `legacy` for a server with no `/apis/dashboard.grafana.app` (11.x). */
|
|
30
|
+
api: "v1" | "v1beta1" | "legacy";
|
|
31
|
+
dashboards: Record<string, FakeDashboard>;
|
|
32
|
+
datasources?: Record<string, Json>;
|
|
33
|
+
folders?: Record<string, string>;
|
|
34
|
+
/** Answer every request with this status (a refused token: 401). */
|
|
35
|
+
status?: number;
|
|
36
|
+
namespace?: string;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* A built dashboard as Grafana hands it back through `/apis` (measured on
|
|
40
|
+
* 12.4.11 and 13.2.2): the built-in annotation added, empty `options` and
|
|
41
|
+
* `fieldConfig` dropped, `null` values dropped, and the uid moved to the
|
|
42
|
+
* resource's name. The legacy route (`/api/dashboards/uid`) serves the
|
|
43
|
+
* built JSON plus `id` and `version`; the fake serves this model on both,
|
|
44
|
+
* which is the harder case for the legacy path.
|
|
45
|
+
*/
|
|
46
|
+
export declare function storedDashboard(built: Json): Json;
|
|
47
|
+
/** A {@link GrafanaHttp} over `state`, recording every request path in `calls`. */
|
|
48
|
+
export declare function fakeGrafana(state: FakeGrafanaState, calls?: string[]): GrafanaHttp;
|
|
49
|
+
/** A datasource as `GET /api/datasources/uid/<uid>` returns one provisioned from a file. */
|
|
50
|
+
export declare function liveDatasource(ds: {
|
|
51
|
+
name: string;
|
|
52
|
+
type: string;
|
|
53
|
+
uid: string;
|
|
54
|
+
url?: string;
|
|
55
|
+
isDefault?: boolean;
|
|
56
|
+
jsonData?: Json;
|
|
57
|
+
secure?: string[];
|
|
58
|
+
readOnly?: boolean;
|
|
59
|
+
}): Json;
|
|
60
|
+
export {};
|
|
61
|
+
//# sourceMappingURL=fake-grafana.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fake-grafana.d.ts","sourceRoot":"","sources":["../../src/api/fake-grafana.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAmB,MAAM,UAAU,CAAC;AAE7D,KAAK,IAAI,GA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