@intentius/chant-lexicon-grafana 0.99.0 → 0.100.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.
Files changed (224) hide show
  1. package/README.md +12 -6
  2. package/dist/annotations.d.ts +61 -0
  3. package/dist/annotations.d.ts.map +1 -0
  4. package/dist/api/apply.d.ts +8 -4
  5. package/dist/api/apply.d.ts.map +1 -1
  6. package/dist/api/fake-grafana.d.ts +2 -0
  7. package/dist/api/fake-grafana.d.ts.map +1 -1
  8. package/dist/api/folders.d.ts +53 -17
  9. package/dist/api/folders.d.ts.map +1 -1
  10. package/dist/build.d.ts +26 -5
  11. package/dist/build.d.ts.map +1 -1
  12. package/dist/catalog.d.ts +1 -1
  13. package/dist/catalog.d.ts.map +1 -1
  14. package/dist/codegen/docs.d.ts.map +1 -1
  15. package/dist/codegen/generate.d.ts +7 -1
  16. package/dist/codegen/generate.d.ts.map +1 -1
  17. package/dist/composites/shared.d.ts +4 -3
  18. package/dist/composites/shared.d.ts.map +1 -1
  19. package/dist/dashboard.d.ts +42 -14
  20. package/dist/dashboard.d.ts.map +1 -1
  21. package/dist/datasource-refs.d.ts +9 -5
  22. package/dist/datasource-refs.d.ts.map +1 -1
  23. package/dist/datasource-settings.d.ts +834 -0
  24. package/dist/datasource-settings.d.ts.map +1 -0
  25. package/dist/datasource.d.ts +53 -11
  26. package/dist/datasource.d.ts.map +1 -1
  27. package/dist/deep-observe-hooks.d.ts +1 -1
  28. package/dist/deep-observe-hooks.d.ts.map +1 -1
  29. package/dist/deep-observe.d.ts +9 -4
  30. package/dist/deep-observe.d.ts.map +1 -1
  31. package/dist/describe-resources.d.ts +1 -0
  32. package/dist/describe-resources.d.ts.map +1 -1
  33. package/dist/detect.d.ts +4 -2
  34. package/dist/detect.d.ts.map +1 -1
  35. package/dist/folder.d.ts +68 -0
  36. package/dist/folder.d.ts.map +1 -0
  37. package/dist/import/generator.d.ts.map +1 -1
  38. package/dist/import/mappings.d.ts +12 -6
  39. package/dist/import/mappings.d.ts.map +1 -1
  40. package/dist/import/model.d.ts +7 -0
  41. package/dist/import/model.d.ts.map +1 -1
  42. package/dist/import/normalize.d.ts.map +1 -1
  43. package/dist/import/parser.d.ts +16 -1
  44. package/dist/import/parser.d.ts.map +1 -1
  45. package/dist/import/testdata/fixtures.d.ts +6 -0
  46. package/dist/import/testdata/fixtures.d.ts.map +1 -1
  47. package/dist/import/v2.d.ts +4 -3
  48. package/dist/import/v2.d.ts.map +1 -1
  49. package/dist/index.d.ts +11 -9
  50. package/dist/index.d.ts.map +1 -1
  51. package/dist/init-templates.d.ts +27 -0
  52. package/dist/init-templates.d.ts.map +1 -0
  53. package/dist/integrity.json +11 -9
  54. package/dist/lint/audit-catalog.d.ts +1 -1
  55. package/dist/lint/audit-catalog.d.ts.map +1 -1
  56. package/dist/lint/post-synth/graf101.d.ts +1 -1
  57. package/dist/lint/post-synth/graf104.d.ts +2 -2
  58. package/dist/lint/post-synth/graf106.d.ts +2 -2
  59. package/dist/lint/post-synth/graf110.d.ts +8 -0
  60. package/dist/lint/post-synth/graf110.d.ts.map +1 -0
  61. package/dist/lint/post-synth/grafana-helpers.d.ts.map +1 -1
  62. package/dist/lint/post-synth/index.d.ts.map +1 -1
  63. package/dist/manifest.json +1 -1
  64. package/dist/meta.json +70 -0
  65. package/dist/okf/index.md +18 -3
  66. package/dist/okf/rules/GRAF101.md +2 -2
  67. package/dist/okf/rules/GRAF104.md +2 -2
  68. package/dist/okf/rules/GRAF106.md +2 -2
  69. package/dist/okf/rules/GRAF110.md +11 -0
  70. package/dist/okf/types/AdhocVariable.md +9 -0
  71. package/dist/okf/types/AzureMonitorQuery.md +9 -0
  72. package/dist/okf/types/BigQueryQuery.md +9 -0
  73. package/dist/okf/types/CloudMonitoringQuery.md +9 -0
  74. package/dist/okf/types/CloudWatchQuery.md +9 -0
  75. package/dist/okf/types/Dashboard.md +1 -1
  76. package/dist/okf/types/Datasource.md +1 -1
  77. package/dist/okf/types/DatasourceProvisioning.md +9 -0
  78. package/dist/okf/types/ElasticsearchQuery.md +9 -0
  79. package/dist/okf/types/ExternalDatasource.md +1 -1
  80. package/dist/okf/types/Folder.md +9 -0
  81. package/dist/okf/types/GroupByVariable.md +9 -0
  82. package/dist/okf/types/MSSQLQuery.md +9 -0
  83. package/dist/okf/types/MySQLQuery.md +9 -0
  84. package/dist/okf/types/PostgresQuery.md +9 -0
  85. package/dist/okf/types/PyroscopeQuery.md +9 -0
  86. package/dist/okf/types/SwitchVariable.md +9 -0
  87. package/dist/op/activities/grafana-apply.d.ts +11 -0
  88. package/dist/op/activities/grafana-apply.d.ts.map +1 -1
  89. package/dist/op/activities/index.d.ts +1 -1
  90. package/dist/op/activities/index.d.ts.map +1 -1
  91. package/dist/ownership.d.ts +11 -0
  92. package/dist/ownership.d.ts.map +1 -1
  93. package/dist/pin.d.ts +1 -1
  94. package/dist/pin.d.ts.map +1 -1
  95. package/dist/plugin.d.ts.map +1 -1
  96. package/dist/promql-check.d.ts.map +1 -1
  97. package/dist/query-models.d.ts +95 -0
  98. package/dist/query-models.d.ts.map +1 -0
  99. package/dist/query.d.ts +107 -10
  100. package/dist/query.d.ts.map +1 -1
  101. package/dist/rules/graf101.ts +2 -2
  102. package/dist/rules/graf104.ts +3 -3
  103. package/dist/rules/graf106.ts +3 -3
  104. package/dist/rules/graf110.ts +17 -0
  105. package/dist/rules/grafana-helpers.ts +13 -3
  106. package/dist/schema/azuremonitor.gen.d.ts +354 -0
  107. package/dist/schema/azuremonitor.gen.d.ts.map +1 -0
  108. package/dist/schema/bigquery.gen.d.ts +93 -0
  109. package/dist/schema/bigquery.gen.d.ts.map +1 -0
  110. package/dist/schema/cloudwatch.gen.d.ts +394 -0
  111. package/dist/schema/cloudwatch.gen.d.ts.map +1 -0
  112. package/dist/schema/elasticsearch.gen.d.ts +444 -0
  113. package/dist/schema/elasticsearch.gen.d.ts.map +1 -0
  114. package/dist/schema/googlecloudmonitoring.gen.d.ts +312 -0
  115. package/dist/schema/googlecloudmonitoring.gen.d.ts.map +1 -0
  116. package/dist/schema/grafanapyroscope.gen.d.ts +60 -0
  117. package/dist/schema/grafanapyroscope.gen.d.ts.map +1 -0
  118. package/dist/schema/index.d.ts +6 -0
  119. package/dist/schema/index.d.ts.map +1 -1
  120. package/dist/schema/table.gen.d.ts +13 -0
  121. package/dist/schema/table.gen.d.ts.map +1 -1
  122. package/dist/schema-validate.d.ts +9 -0
  123. package/dist/schema-validate.d.ts.map +1 -1
  124. package/dist/skill-defs.d.ts.map +1 -1
  125. package/dist/skills/chant-grafana-operations.md +108 -0
  126. package/dist/skills/chant-grafana.md +5 -4
  127. package/dist/spec/schemas.d.ts +9 -7
  128. package/dist/spec/schemas.d.ts.map +1 -1
  129. package/dist/spec/schemas.gen.d.ts +3 -0
  130. package/dist/spec/schemas.gen.d.ts.map +1 -0
  131. package/dist/validate-alerting.d.ts.map +1 -1
  132. package/dist/validate-output.d.ts +15 -2
  133. package/dist/validate-output.d.ts.map +1 -1
  134. package/dist/validate.d.ts.map +1 -1
  135. package/dist/validation.d.ts +14 -0
  136. package/dist/validation.d.ts.map +1 -0
  137. package/dist/variables.d.ts +102 -5
  138. package/dist/variables.d.ts.map +1 -1
  139. package/package.json +2 -2
  140. package/src/annotations.ts +84 -0
  141. package/src/api/apply.test.ts +19 -1
  142. package/src/api/apply.ts +18 -8
  143. package/src/api/fake-grafana.ts +6 -2
  144. package/src/api/folders.ts +106 -32
  145. package/src/build.test.ts +142 -6
  146. package/src/build.ts +126 -24
  147. package/src/catalog.ts +20 -2
  148. package/src/codegen/docs.ts +13 -6
  149. package/src/codegen/generate.ts +27 -1
  150. package/src/composites/shared.ts +3 -2
  151. package/src/dashboard.ts +59 -14
  152. package/src/datasource-refs.ts +30 -6
  153. package/src/datasource-settings.test.ts +106 -0
  154. package/src/datasource-settings.ts +941 -0
  155. package/src/datasource.ts +71 -11
  156. package/src/deep-observe-hooks.ts +16 -1
  157. package/src/deep-observe.test.ts +47 -1
  158. package/src/deep-observe.ts +36 -13
  159. package/src/describe-resources.test.ts +16 -0
  160. package/src/describe-resources.ts +36 -1
  161. package/src/detect.ts +3 -3
  162. package/src/folder.ts +118 -0
  163. package/src/generated/lexicon-grafana.json +70 -0
  164. package/src/import/generated-types.e2e.test.ts +15 -3
  165. package/src/import/generator.ts +2 -1
  166. package/src/import/mappings.ts +98 -26
  167. package/src/import/model.ts +7 -0
  168. package/src/import/normalize.ts +32 -3
  169. package/src/import/parser.test.ts +97 -21
  170. package/src/import/parser.ts +169 -18
  171. package/src/import/roundtrip.test.ts +104 -9
  172. package/src/import/testdata/fixtures.ts +8 -0
  173. package/src/import/v2.ts +4 -3
  174. package/src/index.ts +122 -13
  175. package/src/init-templates.test.ts +74 -0
  176. package/src/init-templates.ts +349 -0
  177. package/src/lint/audit-catalog.ts +9 -1
  178. package/src/lint/post-synth/graf101.ts +2 -2
  179. package/src/lint/post-synth/graf104.ts +3 -3
  180. package/src/lint/post-synth/graf106.ts +3 -3
  181. package/src/lint/post-synth/graf110.ts +17 -0
  182. package/src/lint/post-synth/grafana-helpers.ts +13 -3
  183. package/src/lint/post-synth/index.ts +2 -0
  184. package/src/lint/post-synth/post-synth.test.ts +99 -2
  185. package/src/load-cost.test.ts +35 -0
  186. package/src/op/activities/grafana-apply.e2e.test.ts +14 -5
  187. package/src/op/activities/grafana-apply.test.ts +16 -2
  188. package/src/op/activities/grafana-apply.ts +29 -3
  189. package/src/op/activities/index.ts +1 -1
  190. package/src/ownership.ts +19 -0
  191. package/src/panels.test.ts +3 -1
  192. package/src/pin.ts +12 -0
  193. package/src/plugin.test.ts +9 -2
  194. package/src/plugin.ts +9 -0
  195. package/src/promql-check.ts +5 -1
  196. package/src/query-models.ts +94 -0
  197. package/src/query.test.ts +166 -0
  198. package/src/query.ts +177 -12
  199. package/src/schema/azuremonitor.gen.ts +381 -0
  200. package/src/schema/bigquery.gen.ts +110 -0
  201. package/src/schema/cloudwatch.gen.ts +423 -0
  202. package/src/schema/elasticsearch.gen.ts +508 -0
  203. package/src/schema/googlecloudmonitoring.gen.ts +330 -0
  204. package/src/schema/grafanapyroscope.gen.ts +66 -0
  205. package/src/schema/index.ts +6 -0
  206. package/src/schema/table.gen.ts +14 -0
  207. package/src/schema-validate.ts +58 -7
  208. package/src/skill-defs.ts +17 -0
  209. package/src/skills/chant-grafana-operations.md +108 -0
  210. package/src/skills/chant-grafana.md +5 -4
  211. package/src/spec/overlay/table.overlay.json +19 -0
  212. package/src/spec/schemas/azuremonitor.jsonschema.json +679 -0
  213. package/src/spec/schemas/bigquery.jsonschema.json +290 -0
  214. package/src/spec/schemas/cloudwatch.jsonschema.json +721 -0
  215. package/src/spec/schemas/elasticsearch.jsonschema.json +1695 -0
  216. package/src/spec/schemas/googlecloudmonitoring.jsonschema.json +488 -0
  217. package/src/spec/schemas/grafanapyroscope.jsonschema.json +93 -0
  218. package/src/spec/schemas.gen.ts +40 -0
  219. package/src/spec/schemas.ts +9 -7
  220. package/src/validate-alerting.ts +4 -2
  221. package/src/validate-output.ts +96 -4
  222. package/src/validate.ts +14 -0
  223. package/src/validation.ts +27 -0
  224. package/src/variables.ts +113 -6
package/README.md CHANGED
@@ -21,12 +21,14 @@ export { prometheus, rate, requests, overview };
21
21
  |---|---|
22
22
  | dashboards | `Dashboard`, `Row`, `DashboardProvider` |
23
23
  | panels | `TimeSeriesPanel`, `StatPanel`, `GaugePanel`, `TablePanel`, `LogsPanel`, `TracesPanel`, `HeatmapPanel`, `TextPanel`, `BarChartPanel`, `BarGaugePanel`, `PieChartPanel`, `StateTimelinePanel`, `StatusHistoryPanel`, `HistogramPanel`, `NodeGraphPanel`, `XYChartPanel`, `TrendPanel`, `CanvasPanel`, `GeomapPanel`, `FlameGraphPanel`, `AlertListPanel` |
24
- | queries | `PromQuery` (PromQL), `TempoQuery` (TraceQL), `LokiQuery` (LogQL) |
25
- | variables | `QueryVariable`, `CustomVariable`, `IntervalVariable`, `DatasourceVariable`, `ConstantVariable`, `TextboxVariable` |
24
+ | queries | `PromQuery` (PromQL), `TempoQuery` (TraceQL), `LokiQuery` (LogQL), `ElasticsearchQuery`, `CloudWatchQuery`, `AzureMonitorQuery`, `CloudMonitoringQuery`, `BigQueryQuery`, `PyroscopeQuery`, `PostgresQuery`, `MySQLQuery`, `MSSQLQuery` |
25
+ | variables | `QueryVariable`, `CustomVariable`, `IntervalVariable`, `DatasourceVariable`, `ConstantVariable`, `TextboxVariable`, `AdhocVariable`, `GroupByVariable`, `SwitchVariable` |
26
26
  | datasources | `Datasource`, generic in its plugin type |
27
27
  | alerting | `AlertRuleGroup`, `AlertRule`, `AlertQuery`, the expressions `ReduceExpression`, `MathExpression`, `ThresholdExpression`, `ResampleExpression`, `ClassicConditionsExpression`, `SqlExpression`, and `ContactPoint`, `NotificationPolicy`, `MuteTiming`, `NotificationTemplate`, written to `provisioning/alerting/chant.yaml` |
28
28
 
29
- Panel options, field config and query fields are generated from Grafana's JSON Schemas as published by `grafana/grafana-foundation-sdk`, vendored in `src/spec/schemas/`, pinned by commit and digest in `GRAFANA_SCHEMA_PIN`, and corrected against Grafana's CUE by a checked-in overlay in `src/spec/overlay/`. They track Grafana 12.4 and 13.x. `definePanel` and `defineQuery` add plugins chant doesn't ship.
29
+ Panel options, field config and query fields are generated from Grafana's JSON Schemas as published by `grafana/grafana-foundation-sdk`, vendored in `src/spec/schemas/`, pinned by commit and digest in `GRAFANA_SCHEMA_PIN`, and corrected against Grafana's CUE by a checked-in overlay in `src/spec/overlay/`. They track Grafana 12.4 and 13.x, and the tests validate real exports from Grafana 12.4.11 and 13.2.2. `definePanel` and `defineQuery` add plugins chant doesn't ship.
30
+
31
+ Dashboards are written in the classic (v1) JSON model. Grafana 13's v2 model (tabs, auto grids, conditional rendering) cannot be declared yet. Import, drift and live export read a v2 dashboard by converting it to the classic model the way Grafana's own v1 read does, with a warning for each thing the conversion loses.
30
32
 
31
33
  ## Dashboards from other declarations
32
34
 
@@ -40,15 +42,19 @@ export const agents = AgentDashboard({ genAi: genAiMetrics(), datasource: promet
40
42
 
41
43
  ## Importing existing dashboards
42
44
 
43
- `chant import dashboard.json --output src` turns dashboard JSON exported from Grafana (with or without "Export for sharing externally") into this lexicon's TypeScript, in a directory named after the dashboard's uid: variables, one module per row with its panels and their queries, and the `Dashboard`. Panel ids, positions and refIds are kept, datasources named by uid become `ExternalDatasource`s, and `__inputs` datasources become `DatasourceVariable`s of the same name. A panel or datasource type chant has no class for is declared with `definePanel` or `defineQuery`. What the lexicon cannot express yet (annotations, library panels, ad hoc variables) is printed as a warning. A v2 dashboard is reported and not imported (#2947). `chant build` on the result gives back the same dashboard: the round-trip tests in `src/import/roundtrip.test.ts` hold Grafana 12.4.11 and 13.2.2 UI exports, community dashboards from grafana.com such as Node Exporter Full, and the examples' output to that. Datasource and dashboard provisioning files import too.
45
+ `chant import dashboard.json --output src` turns dashboard JSON exported from Grafana (with or without "Export for sharing externally") into this lexicon's TypeScript, in a directory named after the dashboard's uid: variables, one module per row with its panels and their queries, and the `Dashboard`. Panel ids, positions and refIds are kept, datasources named by uid become `ExternalDatasource`s, and `__inputs` datasources become `DatasourceVariable`s of the same name. A panel or datasource type chant has no class for is declared with `definePanel` or `defineQuery`. What the lexicon cannot express yet (library panels, keys no prop takes) is printed as a warning. A v2 dashboard is converted to the classic model first, with a warning for each thing it loses. `chant build` on the result gives back the same dashboard: the round-trip tests in `src/import/roundtrip.test.ts` hold Grafana 12.4.11 and 13.2.2 UI exports, community dashboards from grafana.com such as Node Exporter Full, and the examples' output to that. Datasource and dashboard provisioning files import too.
44
46
 
45
47
  ## Drift and live export
46
48
 
47
49
  With `grafana.profiles.<env>` in `chant.config.ts` (a URL, and a service account token named by its environment variable), or `GRAFANA_URL` and `GRAFANA_TOKEN`, `chant lifecycle diff <env> --live` reads each declared dashboard and datasource from Grafana 12.4 or 13.x over `/apis/dashboard.grafana.app` (Grafana 11 over `/api/dashboards/uid`) and reports a dashboard edited in the UI as drift, at the path it was declared under (`panels[0].panels[1].title: Errors → 5xx`). The stored dashboard is read back through the importer, so what the build fills in (ids, grid positions, refIds) and what Grafana adds (the built-in annotation) is not reported. A dashboard is `owned` when one of the project's providers loaded it or its labels carry `app.kubernetes.io/managed-by: chant`. `chant import --from <env>` writes the environment's dashboards and datasources as TypeScript, through the same generator as `chant import`. The e2e in `src/observe.e2e.test.ts` runs both against Grafana 12.4.11 and 13.2.2.
48
50
 
51
+ ## Applying over the API
52
+
53
+ `grafanaApply` writes a build to a running Grafana over its HTTP API instead of through provisioning files: folders, library panels an exported dashboard carries, and dashboards, labelled as the project's. With `prune` it deletes the project's dashboards and folders that the build no longer declares.
54
+
49
55
  ## Checks
50
56
 
51
- GRAF001 and GRAF002 run on source (uid and variable-name syntax, literal secrets). The GRAF1xx checks run after a build: undeclared or mistyped datasources, undeclared variables, duplicate uids and ids, panels off the grid or overlapping, uids Grafana rejects, validation against the pinned dashboard, panel and query schemas (an unknown key is a warning), a PromQL syntax check on every query sent to a Prometheus (GRAF108), dashboard providers that load a dashboard twice or not into its declared folder (GRAF109), and a check that every panel unit is one Grafana knows or a custom `suffix:`/`prefix:`-style unit (GRAF115).
57
+ GRAF001 and GRAF002 run on source (uid and variable-name syntax, literal secrets). The GRAF1xx checks run after a build: undeclared or mistyped datasources, undeclared variables, duplicate uids and ids, panels off the grid or overlapping, uids Grafana rejects, validation against the pinned dashboard, panel and query schemas (an unknown key is a warning), a PromQL syntax check on every query sent to a Prometheus (GRAF108), dashboard providers that load a dashboard twice or not into its declared folder (GRAF109), a panel or row repeated over a variable that only ever holds one value (GRAF110), and a check that every panel unit is one Grafana knows or a custom `suffix:`/`prefix:`-style unit (GRAF115). For alerting: rules whose condition or expressions name no query (GRAF111), queries to undeclared datasources (GRAF112), routes to undeclared contact points or mute timings (GRAF113), and uids, intervals and duplicates Grafana refuses (GRAF114).
52
58
 
53
59
  GRAF101 and GRAF102 compare dashboards with the datasources declared in the same build root (chant #1939); keep them together, and declare a datasource that already exists in Grafana with `ExternalDatasource`, which the checks count and the build never provisions.
54
60
 
@@ -57,4 +63,4 @@ GRAF101 and GRAF102 compare dashboards with the datasources declared in the same
57
63
  - `buildGrafana(entities)` and `grafanaFiles(entities)` render every file by path, for embedding in another lexicon's output (a ConfigMap, a volume).
58
64
  - `GrafanaConfigMaps` and `grafanaVolumes` from `@intentius/chant-lexicon-grafana/k8s` deliver dashboards and provisioning to Kubernetes as ConfigMaps labelled for the Grafana Helm chart's sidecar (`grafana_dashboard`, `grafana_datasource`), or mounted into a plain Grafana Deployment.
59
65
  - `renderDashboard(dashboard)` and `dashboardJson(dashboard)` render one dashboard.
60
- - `validateGrafanaOutput({ dashboards, datasources })` and `validateDashboardSchema(json)` run the checks without a build.
66
+ - `validateGrafanaOutput({ dashboards, datasources })` and `validateDashboardSchema(json)`, from `@intentius/chant-lexicon-grafana/validation`, run the checks without a build. They are not on the package root, so declaring dashboards does not load them; ajv loads the first time a schema is checked.
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Dashboard annotations: the queries in a dashboard's `annotations.list`
3
+ * whose events Grafana draws on time series panels (deploy markers,
4
+ * incidents, alert state changes).
5
+ *
6
+ * An annotation is plain data on `Dashboard.annotations`, typed from
7
+ * Grafana's `AnnotationQuery`, except that its `datasource` takes the same
8
+ * values a panel's does (a `Datasource`, an `ExternalDatasource`, a
9
+ * `DatasourceVariable` or a `{ type, uid }` ref) and its `target` may be a
10
+ * query entity (`new PromQuery({ expr })`). What a datasource plugin keeps
11
+ * beside the common keys (Prometheus's legacy `expr`, `step`,
12
+ * `titleFormat`) is written as given.
13
+ *
14
+ * Grafana adds its built-in "Annotations & Alerts" query (`builtIn: 1`, the
15
+ * `-- Grafana --` datasource) to any dashboard without one, so a dashboard
16
+ * leaves it out unless it changes it (hides the toggle, turns it off).
17
+ */
18
+ import type { AnnotationEventFieldMapping, AnnotationPanelFilter, AnnotationQuery, AnnotationQueryPlacement, DataSourceRef } from "./schema/dashboard.gen.js";
19
+ import { type DatasourceInput, type QueryEntity } from "./query.js";
20
+ /** One annotation query on a dashboard. */
21
+ export interface AnnotationInput {
22
+ /** The name shown on its toggle, unique on the dashboard. */
23
+ name: string;
24
+ /** Where its events come from. Leave it out for Grafana's default datasource. */
25
+ datasource?: DatasourceInput;
26
+ /** Whether it runs when the dashboard loads. Defaults to true. */
27
+ enable?: boolean;
28
+ /** Hide its toggle in the dashboard's controls. */
29
+ hide?: boolean;
30
+ /** The colour of its markers. Defaults to `red`, as Grafana's editor does. */
31
+ iconColor?: string;
32
+ /** Only draw its events on these panels, or on every panel but these. */
33
+ filter?: AnnotationPanelFilter;
34
+ /** The query, in the datasource plugin's own shape, or a query entity of that plugin. */
35
+ target?: Record<string, unknown> | QueryEntity;
36
+ /** For the `-- Grafana --` datasource: `dashboard` or `tags`. */
37
+ type?: string;
38
+ /** 1 for Grafana's own "Annotations & Alerts" query. */
39
+ builtIn?: number;
40
+ placement?: AnnotationQueryPlacement;
41
+ /** Prometheus's legacy query fields, kept beside `target` by dashboards saved before Grafana 10. */
42
+ expr?: string;
43
+ textFormat?: string;
44
+ titleFormat?: string;
45
+ tagKeys?: string;
46
+ step?: string;
47
+ useValueForTime?: boolean;
48
+ /** How the fields of the query's result become an event's time, text and tags. */
49
+ mappings?: Record<string, AnnotationEventFieldMapping>;
50
+ /** Anything else a datasource plugin reads from its annotation query. */
51
+ [key: string]: unknown;
52
+ }
53
+ /** The refId Grafana gives an annotation query's target. */
54
+ export declare const ANNOTATION_REF_ID = "Anno";
55
+ /**
56
+ * One annotation as the entry Grafana stores in `annotations.list`.
57
+ * `datasourceRef` resolves the datasource the same way a panel's is (it is
58
+ * build.ts's, passed in so this module needs nothing from the build).
59
+ */
60
+ export declare function annotationJson(input: AnnotationInput, datasourceRef: (d: DatasourceInput | undefined) => DataSourceRef | undefined): AnnotationQuery;
61
+ //# sourceMappingURL=annotations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"annotations.d.ts","sourceRoot":"","sources":["../src/annotations.ts"],"names":[],"mappings":"AAAA;;;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AIG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,CAAC,CAAC,EAAE,eAAe,GAAG,SAAS,KAAK,aAAa,GAAG,SAAS,GAAG,eAAe,CAmBpJ"}
@@ -72,18 +72,22 @@ export interface GrafanaApplyPlan {
72
72
  detail: string;
73
73
  }>;
74
74
  }
75
- /** A dashboard as the build hands it over: its JSON and the folder title it names. */
75
+ /** A dashboard as the build hands it over: its JSON, the folder path it names, and that folder's uid when the build resolved it. */
76
76
  export interface BuiltDashboardInput {
77
77
  readonly json: Json;
78
78
  readonly folder?: string;
79
+ readonly folderUid?: string;
79
80
  }
80
81
  /**
81
- * Turn built dashboards into an apply plan: the folders they name, the
82
+ * Turn built dashboards into an apply plan: the folders they name (each
83
+ * level of a path, with its parent) and the build's own `folders` (its
84
+ * index lists every one, `Folder`s holding no dashboard included), the
82
85
  * library panels their `__elements` carry, and the dashboards themselves.
83
86
  * 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.
87
+ * dashboards with one uid, two folders with one uid, or one library panel
88
+ * uid with two models.
85
89
  */
86
- export declare function planFromDashboards(dashboards: readonly BuiltDashboardInput[]): GrafanaApplyPlan;
90
+ export declare function planFromDashboards(dashboards: readonly BuiltDashboardInput[], declaredFolders?: readonly FolderPlan[]): GrafanaApplyPlan;
87
91
  /** Every resource in a plan, as `{ kind, name }`: what the result must account for. */
88
92
  export declare function planRefs(plan: GrafanaApplyPlan): Array<{
89
93
  kind: string;
@@ -1 +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,KAA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IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,CAmCrD;AAcD;;;;GAIG;AACH,wBAAsB,YAAY,CAAC,MAAM,EAAE,aAAa,EAAE,IAAI,EAAE,gBAAgB,EAAE,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"}
@@ -31,6 +31,8 @@ export interface FakeGrafanaState {
31
31
  dashboards: Record<string, FakeDashboard>;
32
32
  datasources?: Record<string, Json>;
33
33
  folders?: Record<string, string>;
34
+ /** A folder's parent uid, by folder uid, for nested folders. */
35
+ folderParents?: Record<string, string>;
34
36
  /** Answer every request with this status (a refused token: 401). */
35
37
  status?: number;
36
38
  namespace?: string;
@@ -1 +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,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAEpC,MAAM,WAAW,aAAa;IAC5B,6EAA6E;IAC7E,IAAI,EAAE,IAAI,CAAC;IACX,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACrC,sGAAsG;IACtG,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;;OAIG;IACH,EAAE,CAAC,EAAE,IAAI,CAAC;IACV,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,gBAAgB;IAC/B,4GAA4G;IAC5G,GAAG,EAAE,IAAI,GAAG,SAAS,GAAG,QAAQ,CAAC;IACjC,UAAU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ier (#2948). Every folder decision the applier
3
- * makes is in this module: which folders a build needs, the uid each gets,
4
- * how one is read, written, listed and deleted, and on which API.
2
+ * Folders: the one place a build's folders become uids and parents, and how
3
+ * the API applier (#2948) and observation read and write them.
5
4
  *
6
- * ## What the lexicon models today
5
+ * ## What a build declares
7
6
  *
8
- * A dashboard names its folder by title (`Dashboard.folder`), and a title
9
- * holds no nesting (the build flattens `/` in it). So the applier derives
10
- * one root-level folder per distinct title, with a stable uid made from the
11
- * title ({@link folderUidFor}), and a second apply finds it again by that
12
- * uid. {@link FolderPlan} already carries `parentUid`, and the writers
13
- * already send it, so #2953 (folder uid and nesting on the declaration) only
14
- * has to change {@link foldersForDashboards}.
7
+ * A dashboard names its folder as a path (`Dashboard.folder:
8
+ * "Platform/Kubernetes"`) or as a `Folder` (../folder.ts), and a `Folder`
9
+ * may be declared on its own. {@link resolveFolders} turns all of it into
10
+ * one {@link FolderPlan} per folder: every level of every path, the uid a
11
+ * `Folder` pins or {@link folderUidFor} of its path, and its parent's uid.
12
+ * The build calls it and writes the result to its index (`folders`, and a
13
+ * `folderUid` on each dashboard); the applier reads the index and calls it
14
+ * again, which also covers an index written before folders were listed.
15
+ * Two folders at one path with different uids, or two paths with one uid,
16
+ * throw: no delivery could make both.
15
17
  *
16
18
  * ## Which API
17
19
  *
@@ -24,6 +26,8 @@
24
26
  * there cannot be told apart from anyone else's, so it is never pruned.
25
27
  */
26
28
  import { type GrafanaClient } from "./client.js";
29
+ import { folderUidFor } from "../folder.js";
30
+ export { folderUidFor };
27
31
  export declare const FOLDER_GROUP = "folder.grafana.app";
28
32
  /** Folder API versions chant writes, newest first. */
29
33
  export declare const FOLDER_VERSIONS: readonly string[];
@@ -42,6 +46,8 @@ export interface FolderPlan {
42
46
  readonly title: string;
43
47
  /** The parent folder's uid; absent for a root-level folder. */
44
48
  readonly parentUid?: string;
49
+ /** Its titles from the root, joined with `/`: the directory file provisioning reads it from. */
50
+ readonly path?: string;
45
51
  }
46
52
  /** A folder as Grafana holds it. */
47
53
  export interface LiveFolder {
@@ -50,24 +56,48 @@ export interface LiveFolder {
50
56
  readonly parentUid?: string;
51
57
  /** `metadata.labels`; empty on the legacy API. */
52
58
  readonly labels: Readonly<Record<string, string>>;
59
+ /** `metadata.annotations`; empty on the legacy API. */
60
+ readonly annotations?: Readonly<Record<string, string>>;
53
61
  readonly via: "apis" | "legacy";
54
62
  /** The request path it lives at. */
55
63
  readonly address: string;
56
64
  /** The legacy folder's `version`, which its update needs. */
57
65
  readonly version?: number;
58
66
  }
67
+ /** The folders a build resolves to, and the uid of each path. */
68
+ export interface ResolvedFolders {
69
+ /** One per folder, sorted by path, so a parent comes before its children. */
70
+ readonly folders: FolderPlan[];
71
+ /** The uid of the folder at `path` (any spelling `folderLevels` reads the same); undefined for the General folder. */
72
+ uidOf(path: string | undefined): string | undefined;
73
+ }
59
74
  /**
60
- * The uid chant gives the folder a dashboard names by title. Stable, so a
61
- * second apply finds the folder the first one made; Grafana's own limit is
62
- * 40 characters, which `slugUid` keeps to.
75
+ * Every folder a build needs, with its uid and parent: the folders declared
76
+ * with a uid (`Folder`s, or dashboards already resolved), and every level of
77
+ * every path a dashboard names. A level no declaration pins gets
78
+ * {@link folderUidFor} of its path. Throws when two declarations put
79
+ * different uids at one path, and when two paths would get one uid unless
80
+ * `duplicateUids` is `keep`: the build keeps both and GRAF104 reports them,
81
+ * since file provisioning, which gives folders uids of its own, can still
82
+ * deliver them.
63
83
  */
64
- export declare function folderUidFor(title: string): string;
84
+ export declare function resolveFolders(input: {
85
+ declared?: Iterable<{
86
+ uid: string;
87
+ path: string;
88
+ }>;
89
+ paths?: Iterable<string | undefined>;
90
+ }, options?: {
91
+ duplicateUids?: "throw" | "keep";
92
+ }): ResolvedFolders;
65
93
  /**
66
- * The folders a set of dashboards needs, one per distinct title, sorted by
67
- * uid. The one place a dashboard's folder becomes a folder plan.
94
+ * The folders a set of dashboards needs: every level of every folder they
95
+ * name, sorted by path. A dashboard that already carries its `folderUid`
96
+ * pins its folder's uid.
68
97
  */
69
98
  export declare function foldersForDashboards(dashboards: Iterable<{
70
99
  folder?: string;
100
+ folderUid?: string;
71
101
  }>): FolderPlan[];
72
102
  /** The folder API the server behind `client` serves, discovered once per client. */
73
103
  export declare function folderApi(client: GrafanaClient): Promise<FolderApi>;
@@ -75,6 +105,12 @@ export declare function folderApi(client: GrafanaClient): Promise<FolderApi>;
75
105
  export declare function folderPath(api: FolderApi, namespace: string, uid: string): string;
76
106
  /** Read one folder; undefined when there is none with that uid. */
77
107
  export declare function readFolder(client: GrafanaClient, uid: string): Promise<LiveFolder | undefined>;
108
+ /**
109
+ * The path of the folder with this uid, its titles from the root joined with
110
+ * `/`, the form `Dashboard.folder` takes. One read per folder per client;
111
+ * undefined when the folder, or one of its parents, cannot be found.
112
+ */
113
+ export declare function liveFolderPath(client: GrafanaClient, uid: string): Promise<string | undefined>;
78
114
  /** Every folder in the organisation over `/apis`, paged. The legacy API has no labels to list by, so it is not listed. */
79
115
  export declare function listFolders(client: GrafanaClient): Promise<LiveFolder[]>;
80
116
  /** Send one write; throws {@link GrafanaApiError} on anything but a 2xx. */
@@ -1 +1 @@
1
- {"version":3,"file":"folders.d.ts","sourceRoot":"","sources":["../../src/api/folders.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,EAAmB,KAAK,aAAa,EAAE,MAAM,UAAU,CAAC;AAc/D,eAAO,MAAM,YAAY,uBAAuB,CAAC;AAEjD,sDAAsD;AACtD,eAAO,MAAM,eAAe,EAAE,SAAS,MAAM,EAAsB,CAAC;AAEpE,wFAAwF;AACxF,eAAO,MAAM,iBAAiB,uBAAuB,CAAC;AAEtD,sCAAsC;AACtC,MAAM,MAAM,SAAS,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CA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AG,OAAO,CAAC,UAAU,EAAE,CAAC,CAkB9E;AAED,4EAA4E;AAC5E,wBAAsB,IAAI,CAAC,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAIhH;AAMD;;;;GAIG;AACH,wBAAsB,YAAY,CAChC,MAAM,EAAE,aAAa,EACrB,IAAI,EAAE,UAAU,EAChB,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GACvC,OAAO,CAAC;IAAE,MAAM,EAAE,SAAS,GAAG,SAAS,GAAG,WAAW,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,GAAG,QAAQ,CAAA;CAAE,CAAC,CA6BnG;AAED;;;;GAIG;AACH,wBAAsB,kBAAkB,CAAC,MAAM,EAAE,aAAa,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAI5F;AAED;;;;;GAKG;AACH,wBAAsB,YAAY,CAAC,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC,CAM9F;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,SAAS,UAAU,EAAE,GAAG,UAAU,EAAE,CAS1E"}
package/dist/build.d.ts CHANGED
@@ -8,8 +8,9 @@
8
8
  * `buildGrafana()`.
9
9
  */
10
10
  import type { Declarable } from "@intentius/chant/declarable";
11
- import { type DatasourceEntity, type ExternalDatasourceEntity } from "./datasource.js";
12
- import { type DashboardEntity, type DashboardProviderProps } from "./dashboard.js";
11
+ import { type DatasourceEntity, type DatasourceProvisioningProps, type DeletedDatasource, type ExternalDatasourceEntity } from "./datasource.js";
12
+ import { type DashboardEntity, type DashboardProviderEntityProps } from "./dashboard.js";
13
+ import { type FolderPlan } from "./api/folders.js";
13
14
  import { type PanelEntity, type RowEntity } from "./panels.js";
14
15
  import { type QueryEntity, type DatasourceInput } from "./query.js";
15
16
  import { type VariableEntity } from "./variables.js";
@@ -41,6 +42,11 @@ export interface ProvisionedDatasource {
41
42
  orgId?: number;
42
43
  version?: number;
43
44
  }
45
+ /** The settings of the datasource provisioning file besides its datasources. */
46
+ export interface DatasourceFileSettings {
47
+ prune: boolean;
48
+ deleteDatasources: DeletedDatasource[];
49
+ }
44
50
  /** One entry of `providers:` in a dashboard provisioning file. */
45
51
  export interface ProvisionedProvider {
46
52
  name: string;
@@ -60,6 +66,8 @@ export interface BuiltDashboard {
60
66
  uid: string;
61
67
  title: string;
62
68
  folder?: string;
69
+ /** The uid of its folder, when it is in one. */
70
+ folderUid?: string;
63
71
  /** Path of its JSON file, relative to the output directory. */
64
72
  file: string;
65
73
  json: DashboardJson;
@@ -70,6 +78,10 @@ export interface BuiltGrafana {
70
78
  /** `ExternalDatasource` declarations: the checks count them, the provisioning file leaves them out. */
71
79
  externalDatasources: ExternalDatasourceRecord[];
72
80
  providers: ProvisionedProvider[];
81
+ /** Every folder the dashboards and `Folder`s name, each level of a path its own, sorted by path. */
82
+ folders: FolderPlan[];
83
+ /** `prune` and `deleteDatasources` of the datasource provisioning file. */
84
+ datasourceFile: DatasourceFileSettings;
73
85
  /** The alerting provisioning file, when the build declares any alerting. */
74
86
  alerting?: AlertingFile;
75
87
  /** Every output file by path, ready to write. */
@@ -83,8 +95,11 @@ export interface GrafanaIndex {
83
95
  uid: string;
84
96
  title: string;
85
97
  folder?: string;
98
+ folderUid?: string;
86
99
  file: string;
87
100
  }>;
101
+ /** The folders the dashboards are in, and any `Folder` declared: what the API applier creates, parents first. */
102
+ folders?: FolderPlan[];
88
103
  datasources: Array<{
89
104
  name: string;
90
105
  type: string;
@@ -132,9 +147,15 @@ export declare function provisionedDatasource(ds: DatasourceEntity): Provisioned
132
147
  /** One `ExternalDatasource` as the checks and the index see it. */
133
148
  export declare function externalDatasourceRecord(ds: ExternalDatasourceEntity): ExternalDatasourceRecord;
134
149
  /** One dashboard provider as a provisioning entry. */
135
- export declare function provisionedProvider(p: DashboardProviderProps): ProvisionedProvider;
136
- /** The datasource provisioning file for these datasources. */
137
- export declare function datasourcesYaml(datasources: ProvisionedDatasource[]): string;
150
+ export declare function provisionedProvider(p: DashboardProviderEntityProps): ProvisionedProvider;
151
+ /** `prune` and `deleteDatasources` as a build writes them: pruning on unless a `DatasourceProvisioning` turns it off. */
152
+ export declare function datasourceFileSettings(props: DatasourceProvisioningProps | undefined): DatasourceFileSettings;
153
+ /**
154
+ * The datasource provisioning file for these datasources. It prunes by
155
+ * default (`prune: true`), so a datasource removed from the build is removed
156
+ * from Grafana; `deleteDatasources` comes first, as Grafana runs it first.
157
+ */
158
+ export declare function datasourcesYaml(datasources: ProvisionedDatasource[], settings?: DatasourceFileSettings): string;
138
159
  /** The dashboard provisioning file for these providers. */
139
160
  export declare function dashboardProvidersYaml(providers: ProvisionedProvider[]): string;
140
161
  /** Everything the grafana entities in a build render to. */
@@ -1 +1 @@
1
- {"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../src/build.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAqE,KAAK,gBAAgB,EAAsB,KAAK,wBAAwB,EAAE,MAAM,cAAc,CAAC;AAC3K,OAAO,EAIL,KAAK,eAAe,EAEpB,KAAK,sBAAsB,EAC5B,MAAM,aAAa,CAAC;AACrB,OAAO,EAA8B,KAAK,WAAW,EAAE,KAAK,SAAS,EAAkB,MAAM,UAAU,CAAC;AACxG,OAAO,EAAiB,KAAK,WAAW,EAAE,KAAK,eAAe,EAAE,MAAM,SAAS,CAAC;AAChF,OAAO,EAA0C,KAAK,cAAc,EAAqB,MAAM,aAAa,CAAC;AAC7G,OAAO,KAAK,EACV,SAAS,IAAI,aAAa,EAE1B,aAAa,EAEb,KAAK,IAAI,SAA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,wBAAgB,YAAY,CAAC,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAC,UAAU,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAE7G"}
package/dist/catalog.d.ts CHANGED
@@ -4,7 +4,7 @@
4
4
  * completions and hover, and the docs.
5
5
  */
6
6
  import type { LexiconEntry } from "@intentius/chant/lsp/lexicon-providers";
7
- export type CatalogKind = "dashboard" | "datasource" | "provider" | "panel" | "row" | "query" | "variable" | "alerting" | "expression";
7
+ export type CatalogKind = "dashboard" | "folder" | "datasource" | "provider" | "panel" | "row" | "query" | "variable" | "alerting" | "expression";
8
8
  export interface CatalogEntry {
9
9
  className: string;
10
10
  entityType: string;
@@ -1 +1 @@
1
- {"version":3,"file":"catalog.d.ts","sourceRoot":"","sources":["../src/catalog.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wCAAwC,CAAC;AAiB3E,MAAM,MAAM,WAAW,GAAG,WAAW,GAAG,YAAY,GAAG,UAAU,GAAG,OAAO,GAAG,KAAK,GAAG,OAAO,GAAG,UAAU,GAAG,UAAU,GAAG,YAAY,CAAC;AAEvI,MAAM,WAAW,YAAY;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,WAAW,CAAC;IAClB,wEAAwE;IACxE,UAAU,EAAE,UAAU,GAAG,UAAU,CAAC;IACpC,qDAAqD;IACrD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;CACrB;AA8CD,eAAO,MAAM,eAAe,EAAE,YAAY,EAyGzC,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,eAAe,IAAI,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAM9D"}
1
+ {"version":3,"file":"catalog.d.ts","sourceRoot":"","sources":["../src/catalog.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wCAAwC,CAAC;AAkB3E,MAAM,MAAM,WAAW,GAAG,WAAW,GAAG,QAAQ,GAAG,YAAY,GAAG,UAAU,GAAG,OAAO,GAAG,KAAK,GAAG,OAAO,GAAG,UAAU,GAAG,UAAU,GAAG,YAAY,CAAC;AAElJ,MAAM,WAAW,YAAY;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,WAAW,CAAC;IAClB,wEAAwE;IACxE,UAAU,EAAE,UAAU,GAAG,UAAU,CAAC;IACpC,qDAAqD;IACrD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;CACrB;AAiDD,eAAO,MAAM,eAAe,EAAE,YAAY,EAuHzC,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,eAAe,IAAI,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAM9D"}
@@ -1 +1 @@
1
- {"version":3,"file":"docs.d.ts","sourceRoot":"","sources":["../../src/codegen/docs.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAuGH,wBAAsB,YAAY,CAAC,IAAI,CAAC,EAAE;IAAE,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAuB9E"}
1
+ {"version":3,"file":"docs.d.ts","sourceRoot":"","sources":["../../src/codegen/docs.ts"],"names":[],"mappings":"AAAA;;;GAGG;AA8GH,wBAAsB,YAAY,CAAC,IAAI,CAAC,EAAE;IAAE,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAuB9E"}
@@ -4,12 +4,18 @@
4
4
  * 1. `src/schema/<name>.gen.ts` from each vendored schema in `src/spec/schemas/`
5
5
  * (see `src/pin.ts`). These are committed, and a test fails when they
6
6
  * drift from what this step would write.
7
- * 2. `src/generated/lexicon-grafana.json`, the registry of entity classes
7
+ * 2. `src/spec/schemas.gen.ts`, the same schemas with the overlay applied, as
8
+ * JSON text. Validation (GRAF107, the `/validation` subpath) reads them
9
+ * from there rather than from the files, so it needs no filesystem access
10
+ * and works bundled. Committed and checked the same way.
11
+ * 3. `src/generated/lexicon-grafana.json`, the registry of entity classes
8
12
  * the package exports, derived from the catalog so the packaged
9
13
  * `dist/meta.json` cannot disagree with the classes.
10
14
  */
11
15
  import type { GenerateResult } from "@intentius/chant/codegen/generate";
12
16
  export type { GenerateResult };
17
+ /** `src/spec/schemas.gen.ts`: each schema validation uses, overlay applied, as one line of JSON text. */
18
+ export declare function schemaDataModule(): string;
13
19
  /** Every generated schema module, keyed by path relative to the package root. */
14
20
  export declare function schemaModules(): Record<string, string>;
15
21
  export declare function generate(opts?: {
@@ -1 +1 @@
1
- {"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../src/codegen/generate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAKH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AAKxE,YAAY,EAAE,cAAc,EAAE,CAAC;AAY/B,iFAAiF;AACjF,wBAAgB,aAAa,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAQtD;AAQD,wBAAsB,QAAQ,CAAC,IAAI,CAAC,EAAE;IAAE,OAAO,CAAC,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,OAAO,CAAC,cAAc,CAAC,CA2BrG;AAED,mGAAmG;AACnG,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,cAAc,GAAG,IAAI,CAIhE"}
1
+ {"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../src/codegen/generate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAKH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AAKxE,YAAY,EAAE,cAAc,EAAE,CAAC;AAY/B,yGAAyG;AACzG,wBAAgB,gBAAgB,IAAI,MAAM,CAkBzC;AAED,iFAAiF;AACjF,wBAAgB,aAAa,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAStD;AAQD,wBAAsB,QAAQ,CAAC,IAAI,CAAC,EAAE;IAAE,OAAO,CAAC,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,OAAO,CAAC,cAAc,CAAC,CA2BrG;AAED,mGAAmG;AACnG,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,cAAc,GAAG,IAAI,CAIhE"}
@@ -4,6 +4,7 @@
4
4
  */
5
5
  import type { DatasourceInput } from "../query.js";
6
6
  import type { DashboardLinkInput } from "../dashboard.js";
7
+ import type { FolderEntity } from "../folder.js";
7
8
  import type { ThresholdsConfig } from "../schema/dashboard.gen.js";
8
9
  /** Dashboard settings every composite takes; each has a default derived from what it reads. */
9
10
  export interface DashboardOptions {
@@ -14,8 +15,8 @@ export interface DashboardOptions {
14
15
  uid?: string;
15
16
  description?: string;
16
17
  tags?: string[];
17
- /** The Grafana folder to provision it into. */
18
- folder?: string;
18
+ /** The Grafana folder to provision it into: a path, or a `Folder` to pin its uid. */
19
+ folder?: string | FolderEntity;
19
20
  /** Initial time range. */
20
21
  time?: {
21
22
  from: string;
@@ -58,7 +59,7 @@ export declare function dashboardProps(o: DashboardOptions, defaults: {
58
59
  tags: string[];
59
60
  }): {
60
61
  links?: DashboardLinkInput[] | undefined;
61
- folder?: string | undefined;
62
+ folder?: string | FolderEntity | undefined;
62
63
  graphTooltip: "sharedCrosshair";
63
64
  refresh: string;
64
65
  title: string;
@@ -1 +1 @@
1
- {"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../src/composites/shared.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAChD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,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,EAAE,MAAM,GAAG,MAAM,CAErC;AAED,yCAAyC;AACzC,wBAAgB,YAAY,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAE9C;AAED,wDAAwD;AACxD,wBAAgB,MAAM,CAAC,GAAG,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,CAElD;AAED,wEAAwE;AACxE,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAE7D;AAED,0EAA0E;AAC1E,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GAAG,gBAAgB,CAEzF;AAED,0FAA0F;AAC1F,wBAAgB,cAAc,CAAC,CAAC,EAAE,gBAAgB,EAAE,QAAQ,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,EAAE,CAAA;CAAE;;;;;;;;;;cA9DhH,MAAM;YAAM,MAAM;;EA0ElC;AAED,uDAAuD;AACvD,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,EAAE,EAAE,EAAE,OAAO,GAAG,IAAI,CAMtE"}
@@ -10,6 +10,8 @@ import type { Declarable } from "@intentius/chant/declarable";
10
10
  import type { PanelEntity, RowEntity } from "./panels.js";
11
11
  import type { VariableEntity } from "./variables.js";
12
12
  import type { DashboardLink, TimePickerConfig } from "./schema/dashboard.gen.js";
13
+ import { type FolderEntity } from "./folder.js";
14
+ import type { AnnotationInput } from "./annotations.js";
13
15
  /** A dashboard link: `title` and `type` required, the rest defaulted as Grafana's editor would. */
14
16
  export type DashboardLinkInput = Partial<DashboardLink> & Pick<DashboardLink, "title" | "type">;
15
17
  export interface DashboardProps {
@@ -51,20 +53,39 @@ export interface DashboardProps {
51
53
  panels?: Array<PanelEntity<any, any> | RowEntity>;
52
54
  links?: DashboardLinkInput[];
53
55
  /**
54
- * The Grafana folder to provision it into. Written as a subdirectory of
55
- * `dashboards/`, which the provider maps to folders
56
- * (`foldersFromFilesStructure`). `"Platform/Kubernetes"` nests one
57
- * directory in another, which Grafana 13.1 and later make a Kubernetes
58
- * folder inside Platform; earlier versions use only the last level
59
- * (GRAF109 warns). Leave it out for the General folder.
56
+ * Annotation queries: events drawn on the dashboard's time series panels
57
+ * (deploys, incidents), each from a datasource. Grafana adds its own
58
+ * "Annotations & Alerts" query to every dashboard that has none with
59
+ * `builtIn: 1`, so leave that one out unless you change it.
60
60
  */
61
- folder?: string;
61
+ annotations?: AnnotationInput[];
62
+ /**
63
+ * The Grafana folder: a path (`"Platform/Kubernetes"`) or a `Folder`,
64
+ * which pins the folder's uid. Written as a subdirectory of `dashboards/`,
65
+ * which the provider maps to folders (`foldersFromFilesStructure`); a path
66
+ * nests one directory in another, which Grafana 13.1 and later make a
67
+ * Kubernetes folder inside Platform, and earlier versions use only the
68
+ * last level (GRAF109 warns). The API applier creates each level with its
69
+ * uid. Leave it out for the General folder.
70
+ */
71
+ folder?: string | FolderEntity;
62
72
  }
73
+ /** A dashboard's props as the entity holds them: `folder` is always the path, and a `Folder` given for it is `folderEntity`. */
74
+ export type DashboardEntityProps = Omit<DashboardProps, "folder"> & {
75
+ folder?: string;
76
+ };
63
77
  export interface DashboardEntity extends Declarable {
64
- readonly props: DashboardProps;
78
+ readonly props: DashboardEntityProps;
79
+ /** The `Folder` the dashboard was given, when it was given one rather than a path. */
80
+ readonly folderEntity?: FolderEntity;
65
81
  }
66
82
  export declare const DASHBOARD_TYPE = "Grafana::Dashboard";
67
- /** A Grafana dashboard. */
83
+ /**
84
+ * A Grafana dashboard. A `Folder` given as its `folder` is held as the
85
+ * folder's path, so everything that reads the dashboard's props (the build,
86
+ * the checks, observation's diff) sees one form; the `Folder` itself, for its
87
+ * uid, is `folderEntity`.
88
+ */
68
89
  export declare const Dashboard: new (props: DashboardProps) => DashboardEntity;
69
90
  export declare function isDashboardEntity(value: unknown): value is DashboardEntity;
70
91
  /** Where Grafana finds the dashboard files by default: mount `dashboards/` here. */
@@ -74,11 +95,14 @@ export interface DashboardProviderProps {
74
95
  name: string;
75
96
  orgId?: number;
76
97
  /**
77
- * Put every dashboard this provider loads in this folder. Setting it (or
78
- * `folderUid`) turns `foldersFromFilesStructure` off by default, so each
79
- * dashboard's own `folder` is ignored (GRAF109 warns).
98
+ * Put every dashboard this provider loads in this folder: a title, or a
99
+ * root-level `Folder`, whose title and uid are written as `folder` and
100
+ * `folderUid` (Grafana creates a provider's folder at the root, so a
101
+ * nested `Folder` is refused). Setting it (or `folderUid`) turns
102
+ * `foldersFromFilesStructure` off by default, so each dashboard's own
103
+ * `folder` is ignored (GRAF109 warns).
80
104
  */
81
- folder?: string;
105
+ folder?: string | FolderEntity;
82
106
  folderUid?: string;
83
107
  /** Where the `dashboards/` output is mounted in the Grafana container. Defaults to `/var/lib/grafana/dashboards`. */
84
108
  path?: string;
@@ -88,8 +112,12 @@ export interface DashboardProviderProps {
88
112
  allowUiUpdates?: boolean;
89
113
  updateIntervalSeconds?: number;
90
114
  }
115
+ /** A provider's props as the entity holds them: a `Folder` given for `folder` is written out as `folder` and `folderUid`. */
116
+ export type DashboardProviderEntityProps = Omit<DashboardProviderProps, "folder"> & {
117
+ folder?: string;
118
+ };
91
119
  export interface DashboardProviderEntity extends Declarable {
92
- readonly props: DashboardProviderProps;
120
+ readonly props: DashboardProviderEntityProps;
93
121
  }
94
122
  export declare const DASHBOARD_PROVIDER_TYPE = "Grafana::DashboardProvider";
95
123
  /** An entry in the dashboard provisioning file. Optional: a default one is written when none is declared. */