@intentius/chant-lexicon-grafana 0.97.0 → 0.99.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (451) hide show
  1. package/README.md +15 -5
  2. package/dist/actions/grafana.d.ts +24 -0
  3. package/dist/actions/grafana.d.ts.map +1 -0
  4. package/dist/actions/index.d.ts +2 -0
  5. package/dist/actions/index.d.ts.map +1 -0
  6. package/dist/alerting-build.d.ts +128 -0
  7. package/dist/alerting-build.d.ts.map +1 -0
  8. package/dist/alerting.d.ts +273 -0
  9. package/dist/alerting.d.ts.map +1 -0
  10. package/dist/api/apply.d.ts +156 -0
  11. package/dist/api/apply.d.ts.map +1 -0
  12. package/dist/api/bind.d.ts +32 -0
  13. package/dist/api/bind.d.ts.map +1 -0
  14. package/dist/api/client.d.ts +76 -0
  15. package/dist/api/client.d.ts.map +1 -0
  16. package/dist/api/converge.d.ts +33 -0
  17. package/dist/api/converge.d.ts.map +1 -0
  18. package/dist/api/dashboards.d.ts +102 -0
  19. package/dist/api/dashboards.d.ts.map +1 -0
  20. package/dist/api/datasources.d.ts +26 -0
  21. package/dist/api/datasources.d.ts.map +1 -0
  22. package/dist/api/fake-grafana-writes.d.ts +41 -0
  23. package/dist/api/fake-grafana-writes.d.ts.map +1 -0
  24. package/dist/api/fake-grafana.d.ts +61 -0
  25. package/dist/api/fake-grafana.d.ts.map +1 -0
  26. package/dist/api/folders.d.ts +110 -0
  27. package/dist/api/folders.d.ts.map +1 -0
  28. package/dist/api/library-panels.d.ts +52 -0
  29. package/dist/api/library-panels.d.ts.map +1 -0
  30. package/dist/build.d.ts +30 -2
  31. package/dist/build.d.ts.map +1 -1
  32. package/dist/catalog.d.ts +1 -1
  33. package/dist/catalog.d.ts.map +1 -1
  34. package/dist/codegen/docs.d.ts.map +1 -1
  35. package/dist/codegen/schema-types.d.ts +3 -3
  36. package/dist/codegen/schema-types.d.ts.map +1 -1
  37. package/dist/composites/agent-dashboard.d.ts.map +1 -1
  38. package/dist/composites/catalog.d.ts.map +1 -1
  39. package/dist/composites/index.d.ts +4 -2
  40. package/dist/composites/index.d.ts.map +1 -1
  41. package/dist/composites/red-dashboard.d.ts +21 -2
  42. package/dist/composites/red-dashboard.d.ts.map +1 -1
  43. package/dist/composites/shared.d.ts +7 -0
  44. package/dist/composites/shared.d.ts.map +1 -1
  45. package/dist/composites/slo-alert-rules.d.ts +92 -0
  46. package/dist/composites/slo-alert-rules.d.ts.map +1 -0
  47. package/dist/config.d.ts +111 -0
  48. package/dist/config.d.ts.map +1 -0
  49. package/dist/contact-point-secrets.d.ts +17 -0
  50. package/dist/contact-point-secrets.d.ts.map +1 -0
  51. package/dist/dashboard.d.ts +16 -2
  52. package/dist/dashboard.d.ts.map +1 -1
  53. package/dist/datasource-refs.d.ts +95 -0
  54. package/dist/datasource-refs.d.ts.map +1 -0
  55. package/dist/datasource.d.ts +29 -0
  56. package/dist/datasource.d.ts.map +1 -1
  57. package/dist/deep-observe-hooks.d.ts +64 -0
  58. package/dist/deep-observe-hooks.d.ts.map +1 -0
  59. package/dist/deep-observe.d.ts +42 -0
  60. package/dist/deep-observe.d.ts.map +1 -0
  61. package/dist/describe-resources.d.ts +49 -0
  62. package/dist/describe-resources.d.ts.map +1 -0
  63. package/dist/detect.d.ts +28 -1
  64. package/dist/detect.d.ts.map +1 -1
  65. package/dist/export-resources.d.ts +38 -0
  66. package/dist/export-resources.d.ts.map +1 -0
  67. package/dist/import/alerting.d.ts +40 -0
  68. package/dist/import/alerting.d.ts.map +1 -0
  69. package/dist/import/edits.d.ts +47 -0
  70. package/dist/import/edits.d.ts.map +1 -0
  71. package/dist/import/embedded.d.ts +14 -0
  72. package/dist/import/embedded.d.ts.map +1 -0
  73. package/dist/import/generator.d.ts +60 -0
  74. package/dist/import/generator.d.ts.map +1 -0
  75. package/dist/import/live-export.d.ts +108 -0
  76. package/dist/import/live-export.d.ts.map +1 -0
  77. package/dist/import/mappings.d.ts +83 -0
  78. package/dist/import/mappings.d.ts.map +1 -0
  79. package/dist/import/model.d.ts +98 -0
  80. package/dist/import/model.d.ts.map +1 -0
  81. package/dist/import/normalize-alerting.d.ts +26 -0
  82. package/dist/import/normalize-alerting.d.ts.map +1 -0
  83. package/dist/import/normalize.d.ts +74 -0
  84. package/dist/import/normalize.d.ts.map +1 -0
  85. package/dist/import/parser.d.ts +110 -0
  86. package/dist/import/parser.d.ts.map +1 -0
  87. package/dist/import/report.d.ts +26 -0
  88. package/dist/import/report.d.ts.map +1 -0
  89. package/dist/import/testdata/fixtures.d.ts +35 -0
  90. package/dist/import/testdata/fixtures.d.ts.map +1 -0
  91. package/dist/import/v2.d.ts +72 -0
  92. package/dist/import/v2.d.ts.map +1 -0
  93. package/dist/index.d.ts +26 -9
  94. package/dist/index.d.ts.map +1 -1
  95. package/dist/integrity.json +18 -10
  96. package/dist/k8s.d.ts +107 -0
  97. package/dist/k8s.d.ts.map +1 -0
  98. package/dist/lint/audit-catalog.d.ts +2 -1
  99. package/dist/lint/audit-catalog.d.ts.map +1 -1
  100. package/dist/lint/post-synth/graf101.d.ts +2 -2
  101. package/dist/lint/post-synth/graf102.d.ts +1 -1
  102. package/dist/lint/post-synth/graf107.d.ts +1 -1
  103. package/dist/lint/post-synth/graf108.d.ts +8 -0
  104. package/dist/lint/post-synth/graf108.d.ts.map +1 -0
  105. package/dist/lint/post-synth/graf109.d.ts +8 -0
  106. package/dist/lint/post-synth/graf109.d.ts.map +1 -0
  107. package/dist/lint/post-synth/graf111.d.ts +8 -0
  108. package/dist/lint/post-synth/graf111.d.ts.map +1 -0
  109. package/dist/lint/post-synth/graf112.d.ts +8 -0
  110. package/dist/lint/post-synth/graf112.d.ts.map +1 -0
  111. package/dist/lint/post-synth/graf113.d.ts +8 -0
  112. package/dist/lint/post-synth/graf113.d.ts.map +1 -0
  113. package/dist/lint/post-synth/graf114.d.ts +8 -0
  114. package/dist/lint/post-synth/graf114.d.ts.map +1 -0
  115. package/dist/lint/post-synth/graf115.d.ts +8 -0
  116. package/dist/lint/post-synth/graf115.d.ts.map +1 -0
  117. package/dist/lint/post-synth/grafana-helpers.d.ts +7 -5
  118. package/dist/lint/post-synth/grafana-helpers.d.ts.map +1 -1
  119. package/dist/lint/post-synth/index.d.ts.map +1 -1
  120. package/dist/lint/rules/literal-secret.d.ts +7 -3
  121. package/dist/lint/rules/literal-secret.d.ts.map +1 -1
  122. package/dist/lsp/hover.d.ts.map +1 -1
  123. package/dist/manifest.json +1 -1
  124. package/dist/members.d.ts +27 -0
  125. package/dist/members.d.ts.map +1 -0
  126. package/dist/meta.json +135 -0
  127. package/dist/okf/index.md +36 -2
  128. package/dist/okf/rules/GRAF002.md +3 -2
  129. package/dist/okf/rules/GRAF101.md +3 -2
  130. package/dist/okf/rules/GRAF102.md +1 -0
  131. package/dist/okf/rules/GRAF108.md +11 -0
  132. package/dist/okf/rules/GRAF109.md +15 -0
  133. package/dist/okf/rules/GRAF111.md +11 -0
  134. package/dist/okf/rules/GRAF112.md +16 -0
  135. package/dist/okf/rules/GRAF113.md +16 -0
  136. package/dist/okf/rules/GRAF114.md +11 -0
  137. package/dist/okf/rules/GRAF115.md +11 -0
  138. package/dist/okf/types/AlertListPanel.md +9 -0
  139. package/dist/okf/types/AlertQuery.md +9 -0
  140. package/dist/okf/types/AlertRule.md +9 -0
  141. package/dist/okf/types/AlertRuleGroup.md +9 -0
  142. package/dist/okf/types/BarChartPanel.md +9 -0
  143. package/dist/okf/types/BarGaugePanel.md +9 -0
  144. package/dist/okf/types/CanvasPanel.md +9 -0
  145. package/dist/okf/types/ClassicConditionsExpression.md +9 -0
  146. package/dist/okf/types/ContactPoint.md +14 -0
  147. package/dist/okf/types/Dashboard.md +1 -0
  148. package/dist/okf/types/Datasource.md +3 -2
  149. package/dist/okf/types/ExternalDatasource.md +15 -0
  150. package/dist/okf/types/FlameGraphPanel.md +9 -0
  151. package/dist/okf/types/GeomapPanel.md +9 -0
  152. package/dist/okf/types/HistogramPanel.md +9 -0
  153. package/dist/okf/types/MathExpression.md +9 -0
  154. package/dist/okf/types/MuteTiming.md +13 -0
  155. package/dist/okf/types/NodeGraphPanel.md +9 -0
  156. package/dist/okf/types/NotificationPolicy.md +9 -0
  157. package/dist/okf/types/NotificationTemplate.md +9 -0
  158. package/dist/okf/types/PieChartPanel.md +9 -0
  159. package/dist/okf/types/ReduceExpression.md +9 -0
  160. package/dist/okf/types/ResampleExpression.md +9 -0
  161. package/dist/okf/types/SqlExpression.md +9 -0
  162. package/dist/okf/types/StateTimelinePanel.md +9 -0
  163. package/dist/okf/types/StatusHistoryPanel.md +9 -0
  164. package/dist/okf/types/ThresholdExpression.md +9 -0
  165. package/dist/okf/types/TrendPanel.md +9 -0
  166. package/dist/okf/types/XYChartPanel.md +9 -0
  167. package/dist/op/activities/grafana-apply.d.ts +75 -0
  168. package/dist/op/activities/grafana-apply.d.ts.map +1 -0
  169. package/dist/op/activities/index.d.ts +9 -0
  170. package/dist/op/activities/index.d.ts.map +1 -0
  171. package/dist/op/builders.d.ts +24 -0
  172. package/dist/op/builders.d.ts.map +1 -0
  173. package/dist/ownership.d.ts +67 -0
  174. package/dist/ownership.d.ts.map +1 -0
  175. package/dist/panel-options.d.ts +65 -0
  176. package/dist/panel-options.d.ts.map +1 -0
  177. package/dist/panels.d.ts +46 -9
  178. package/dist/panels.d.ts.map +1 -1
  179. package/dist/pin.d.ts +29 -7
  180. package/dist/pin.d.ts.map +1 -1
  181. package/dist/plugin.d.ts.map +1 -1
  182. package/dist/promql-check.d.ts +51 -0
  183. package/dist/promql-check.d.ts.map +1 -0
  184. package/dist/query.d.ts +9 -8
  185. package/dist/query.d.ts.map +1 -1
  186. package/dist/rules/graf101.ts +3 -3
  187. package/dist/rules/graf102.ts +1 -1
  188. package/dist/rules/graf107.ts +1 -1
  189. package/dist/rules/graf108.ts +17 -0
  190. package/dist/rules/graf109.ts +17 -0
  191. package/dist/rules/graf111.ts +17 -0
  192. package/dist/rules/graf112.ts +17 -0
  193. package/dist/rules/graf113.ts +17 -0
  194. package/dist/rules/graf114.ts +17 -0
  195. package/dist/rules/graf115.ts +17 -0
  196. package/dist/rules/grafana-helpers.ts +15 -8
  197. package/dist/rules/literal-secret.ts +60 -6
  198. package/dist/schema/barchart.gen.d.ts +198 -0
  199. package/dist/schema/barchart.gen.d.ts.map +1 -0
  200. package/dist/schema/bargauge.gen.d.ts +97 -0
  201. package/dist/schema/bargauge.gen.d.ts.map +1 -0
  202. package/dist/schema/canvas.gen.d.ts +152 -0
  203. package/dist/schema/canvas.gen.d.ts.map +1 -0
  204. package/dist/schema/dashboard.gen.d.ts +196 -21
  205. package/dist/schema/dashboard.gen.d.ts.map +1 -1
  206. package/dist/schema/expr.gen.d.ts +606 -0
  207. package/dist/schema/expr.gen.d.ts.map +1 -0
  208. package/dist/schema/gauge.gen.d.ts.map +1 -1
  209. package/dist/schema/geomap.gen.d.ts +100 -0
  210. package/dist/schema/geomap.gen.d.ts.map +1 -0
  211. package/dist/schema/heatmap.gen.d.ts.map +1 -1
  212. package/dist/schema/histogram.gen.d.ts +132 -0
  213. package/dist/schema/histogram.gen.d.ts.map +1 -0
  214. package/dist/schema/index.d.ts +12 -0
  215. package/dist/schema/index.d.ts.map +1 -1
  216. package/dist/schema/logs.gen.d.ts +1 -0
  217. package/dist/schema/logs.gen.d.ts.map +1 -1
  218. package/dist/schema/loki.gen.d.ts.map +1 -1
  219. package/dist/schema/nodegraph.gen.d.ts +49 -0
  220. package/dist/schema/nodegraph.gen.d.ts.map +1 -0
  221. package/dist/schema/piechart.gen.d.ts +127 -0
  222. package/dist/schema/piechart.gen.d.ts.map +1 -0
  223. package/dist/schema/prometheus.gen.d.ts.map +1 -1
  224. package/dist/schema/stat.gen.d.ts.map +1 -1
  225. package/dist/schema/statetimeline.gen.d.ts +124 -0
  226. package/dist/schema/statetimeline.gen.d.ts.map +1 -0
  227. package/dist/schema/statushistory.gen.d.ts +114 -0
  228. package/dist/schema/statushistory.gen.d.ts.map +1 -0
  229. package/dist/schema/table.gen.d.ts +22 -3
  230. package/dist/schema/table.gen.d.ts.map +1 -1
  231. package/dist/schema/tempo.gen.d.ts.map +1 -1
  232. package/dist/schema/text.gen.d.ts.map +1 -1
  233. package/dist/schema/timeseries.gen.d.ts +5 -1
  234. package/dist/schema/timeseries.gen.d.ts.map +1 -1
  235. package/dist/schema/trend.gen.d.ts +180 -0
  236. package/dist/schema/trend.gen.d.ts.map +1 -0
  237. package/dist/schema/xychart.gen.d.ts +145 -0
  238. package/dist/schema/xychart.gen.d.ts.map +1 -0
  239. package/dist/schema-validate.d.ts +30 -4
  240. package/dist/schema-validate.d.ts.map +1 -1
  241. package/dist/serializer.d.ts +11 -3
  242. package/dist/serializer.d.ts.map +1 -1
  243. package/dist/skill-defs.d.ts.map +1 -1
  244. package/dist/skills/chant-grafana-alerting.md +49 -0
  245. package/dist/skills/chant-grafana-provisioning.md +3 -3
  246. package/dist/skills/chant-grafana.md +12 -6
  247. package/dist/spec/fetch-units-cli.d.ts +3 -0
  248. package/dist/spec/fetch-units-cli.d.ts.map +1 -0
  249. package/dist/spec/overlay.d.ts +43 -0
  250. package/dist/spec/overlay.d.ts.map +1 -0
  251. package/dist/spec/schemas.d.ts +13 -7
  252. package/dist/spec/schemas.d.ts.map +1 -1
  253. package/dist/spec/units.d.ts +35 -0
  254. package/dist/spec/units.d.ts.map +1 -0
  255. package/dist/spec/units.gen.d.ts +2 -0
  256. package/dist/spec/units.gen.d.ts.map +1 -0
  257. package/dist/transformations.d.ts +459 -0
  258. package/dist/transformations.d.ts.map +1 -0
  259. package/dist/util.d.ts +6 -0
  260. package/dist/util.d.ts.map +1 -1
  261. package/dist/validate-alerting.d.ts +65 -0
  262. package/dist/validate-alerting.d.ts.map +1 -0
  263. package/dist/validate-output.d.ts +49 -9
  264. package/dist/validate-output.d.ts.map +1 -1
  265. package/dist/validate.d.ts.map +1 -1
  266. package/dist/variables.d.ts +7 -2
  267. package/dist/variables.d.ts.map +1 -1
  268. package/package.json +12 -4
  269. package/src/actions/actions.test.ts +24 -0
  270. package/src/actions/grafana.ts +40 -0
  271. package/src/actions/index.ts +1 -0
  272. package/src/alerting-build.ts +376 -0
  273. package/src/alerting.e2e.test.ts +212 -0
  274. package/src/alerting.test.ts +272 -0
  275. package/src/alerting.ts +435 -0
  276. package/src/api/apply.test.ts +238 -0
  277. package/src/api/apply.ts +384 -0
  278. package/src/api/bind.ts +58 -0
  279. package/src/api/client.ts +148 -0
  280. package/src/api/converge.ts +63 -0
  281. package/src/api/dashboards.ts +247 -0
  282. package/src/api/datasources.ts +33 -0
  283. package/src/api/fake-grafana-writes.ts +201 -0
  284. package/src/api/fake-grafana.ts +186 -0
  285. package/src/api/folders.ts +265 -0
  286. package/src/api/library-panels.ts +101 -0
  287. package/src/build.test.ts +210 -5
  288. package/src/build.ts +180 -43
  289. package/src/catalog.ts +86 -2
  290. package/src/codegen/docs.ts +42 -9
  291. package/src/codegen/schema-types.ts +16 -6
  292. package/src/composites/agent-dashboard.ts +6 -3
  293. package/src/composites/catalog.test.ts +2 -2
  294. package/src/composites/catalog.ts +82 -0
  295. package/src/composites/composites.test.ts +73 -9
  296. package/src/composites/index.ts +4 -2
  297. package/src/composites/queries.e2e.test.ts +374 -0
  298. package/src/composites/red-dashboard.ts +83 -12
  299. package/src/composites/shared.ts +11 -0
  300. package/src/composites/slo-alert-rules.ts +149 -0
  301. package/src/config.test.ts +61 -0
  302. package/src/config.ts +138 -0
  303. package/src/contact-point-secrets.ts +63 -0
  304. package/src/dashboard.ts +16 -2
  305. package/src/datasource-refs.test.ts +56 -0
  306. package/src/datasource-refs.ts +189 -0
  307. package/src/datasource.ts +52 -0
  308. package/src/deep-observe-hooks.ts +252 -0
  309. package/src/deep-observe.test.ts +265 -0
  310. package/src/deep-observe.ts +164 -0
  311. package/src/describe-resources.test.ts +255 -0
  312. package/src/describe-resources.ts +209 -0
  313. package/src/detect.ts +79 -2
  314. package/src/export-resources.test.ts +129 -0
  315. package/src/export-resources.ts +84 -0
  316. package/src/generated/lexicon-grafana.json +135 -0
  317. package/src/import/alerting-roundtrip.test.ts +161 -0
  318. package/src/import/alerting.ts +500 -0
  319. package/src/import/edits.ts +95 -0
  320. package/src/import/embedded.test.ts +45 -0
  321. package/src/import/embedded.ts +47 -0
  322. package/src/import/generated-types.e2e.test.ts +118 -0
  323. package/src/import/generator.test.ts +210 -0
  324. package/src/import/generator.ts +462 -0
  325. package/src/import/live-export.ts +264 -0
  326. package/src/import/mappings.ts +264 -0
  327. package/src/import/model.ts +110 -0
  328. package/src/import/normalize-alerting.ts +101 -0
  329. package/src/import/normalize.test.ts +117 -0
  330. package/src/import/normalize.ts +364 -0
  331. package/src/import/parser.test.ts +440 -0
  332. package/src/import/parser.ts +1236 -0
  333. package/src/import/report.ts +62 -0
  334. package/src/import/roundtrip.test.ts +468 -0
  335. package/src/import/testdata/fixtures.ts +129 -0
  336. package/src/import/v2.test.ts +292 -0
  337. package/src/import/v2.ts +803 -0
  338. package/src/import.e2e.test.ts +31 -84
  339. package/src/import.test.ts +9 -3
  340. package/src/index.ts +190 -5
  341. package/src/k8s.test.ts +98 -0
  342. package/src/k8s.ts +197 -0
  343. package/src/lint/audit-catalog.ts +60 -3
  344. package/src/lint/core-lint.test.ts +43 -0
  345. package/src/lint/post-synth/graf101.ts +3 -3
  346. package/src/lint/post-synth/graf102.ts +1 -1
  347. package/src/lint/post-synth/graf107.ts +1 -1
  348. package/src/lint/post-synth/graf108.ts +17 -0
  349. package/src/lint/post-synth/graf109.ts +17 -0
  350. package/src/lint/post-synth/graf111.ts +17 -0
  351. package/src/lint/post-synth/graf112.ts +17 -0
  352. package/src/lint/post-synth/graf113.ts +17 -0
  353. package/src/lint/post-synth/graf114.ts +17 -0
  354. package/src/lint/post-synth/graf115.ts +17 -0
  355. package/src/lint/post-synth/grafana-helpers.ts +15 -8
  356. package/src/lint/post-synth/index.ts +14 -0
  357. package/src/lint/post-synth/post-synth.test.ts +235 -11
  358. package/src/lint/rules/literal-secret.ts +60 -6
  359. package/src/lint/rules/rules.test.ts +27 -0
  360. package/src/lsp/completions.test.ts +5 -0
  361. package/src/lsp/hover.test.ts +7 -0
  362. package/src/lsp/hover.ts +8 -1
  363. package/src/members.ts +68 -0
  364. package/src/observe.e2e.test.ts +255 -0
  365. package/src/op/activities/grafana-apply.e2e.test.ts +175 -0
  366. package/src/op/activities/grafana-apply.test.ts +229 -0
  367. package/src/op/activities/grafana-apply.ts +171 -0
  368. package/src/op/activities/index.ts +8 -0
  369. package/src/op/builders.test.ts +40 -0
  370. package/src/op/builders.ts +34 -0
  371. package/src/ownership.ts +103 -0
  372. package/src/panel-options.ts +66 -0
  373. package/src/panels.test.ts +51 -0
  374. package/src/panels.ts +148 -10
  375. package/src/pin.ts +57 -6
  376. package/src/plugin.test.ts +5 -2
  377. package/src/plugin.ts +66 -0
  378. package/src/promql-check.test.ts +108 -0
  379. package/src/promql-check.ts +189 -0
  380. package/src/query.ts +13 -8
  381. package/src/schema/barchart.gen.ts +221 -0
  382. package/src/schema/bargauge.gen.ts +111 -0
  383. package/src/schema/canvas.gen.ts +176 -0
  384. package/src/schema/dashboard.gen.ts +206 -22
  385. package/src/schema/expr.gen.ts +618 -0
  386. package/src/schema/gauge.gen.ts +2 -1
  387. package/src/schema/geomap.gen.ts +112 -0
  388. package/src/schema/heatmap.gen.ts +2 -1
  389. package/src/schema/histogram.gen.ts +151 -0
  390. package/src/schema/index.ts +12 -0
  391. package/src/schema/logs.gen.ts +3 -1
  392. package/src/schema/loki.gen.ts +2 -1
  393. package/src/schema/nodegraph.gen.ts +58 -0
  394. package/src/schema/piechart.gen.ts +146 -0
  395. package/src/schema/prometheus.gen.ts +2 -1
  396. package/src/schema/stat.gen.ts +2 -1
  397. package/src/schema/statetimeline.gen.ts +143 -0
  398. package/src/schema/statushistory.gen.ts +132 -0
  399. package/src/schema/table.gen.ts +27 -4
  400. package/src/schema/tempo.gen.ts +2 -1
  401. package/src/schema/text.gen.ts +2 -1
  402. package/src/schema/timeseries.gen.ts +7 -2
  403. package/src/schema/trend.gen.ts +208 -0
  404. package/src/schema/xychart.gen.ts +167 -0
  405. package/src/schema-overlay.test.ts +282 -0
  406. package/src/schema-validate.ts +141 -50
  407. package/src/schema.test.ts +4 -2
  408. package/src/serializer.test.ts +13 -1
  409. package/src/serializer.ts +11 -3
  410. package/src/skill-defs.ts +17 -0
  411. package/src/skills/chant-grafana-alerting.md +49 -0
  412. package/src/skills/chant-grafana-provisioning.md +3 -3
  413. package/src/skills/chant-grafana.md +12 -6
  414. package/src/spec/fetch-cli.ts +3 -3
  415. package/src/spec/fetch-units-cli.ts +37 -0
  416. package/src/spec/overlay/canvas.overlay.json +142 -0
  417. package/src/spec/overlay/dashboard.overlay.json +378 -0
  418. package/src/spec/overlay/expr.overlay.json +14 -0
  419. package/src/spec/overlay/geomap.overlay.json +35 -0
  420. package/src/spec/overlay/logs.overlay.json +14 -0
  421. package/src/spec/overlay/nodegraph.overlay.json +31 -0
  422. package/src/spec/overlay/piechart.overlay.json +17 -0
  423. package/src/spec/overlay/table.overlay.json +84 -0
  424. package/src/spec/overlay/timeseries.overlay.json +21 -0
  425. package/src/spec/overlay/trend.overlay.json +17 -0
  426. package/src/spec/overlay/xychart.overlay.json +16 -0
  427. package/src/spec/overlay.ts +105 -0
  428. package/src/spec/schemas/barchart.jsonschema.json +419 -0
  429. package/src/spec/schemas/bargauge.jsonschema.json +224 -0
  430. package/src/spec/schemas/canvas.jsonschema.json +356 -0
  431. package/src/spec/schemas/dashboardv2.jsonschema.json +3387 -0
  432. package/src/spec/schemas/expr.jsonschema.json +987 -0
  433. package/src/spec/schemas/geomap.jsonschema.json +220 -0
  434. package/src/spec/schemas/histogram.jsonschema.json +308 -0
  435. package/src/spec/schemas/nodegraph.jsonschema.json +77 -0
  436. package/src/spec/schemas/piechart.jsonschema.json +275 -0
  437. package/src/spec/schemas/statetimeline.jsonschema.json +324 -0
  438. package/src/spec/schemas/statushistory.jsonschema.json +292 -0
  439. package/src/spec/schemas/trend.jsonschema.json +449 -0
  440. package/src/spec/schemas/xychart.jsonschema.json +428 -0
  441. package/src/spec/schemas.ts +22 -10
  442. package/src/spec/units.gen.ts +281 -0
  443. package/src/spec/units.ts +77 -0
  444. package/src/transformations.test.ts +65 -0
  445. package/src/transformations.ts +574 -0
  446. package/src/util.ts +8 -0
  447. package/src/validate-alerting.test.ts +255 -0
  448. package/src/validate-alerting.ts +428 -0
  449. package/src/validate-output.ts +332 -101
  450. package/src/validate.ts +14 -0
  451. 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,IAAI,CAAC;IACpB,QAAQ,CAAC,SAAS,CAAC,EAAE,MA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C,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>;
75
+ }
76
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/api/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,kHAAkH;AAClH,MAAM,MAAM,WAAW,GAAG;IAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC;AAE5G,iGAAiG;AACjG,MAAM,WAAW,aAAa;IAC5B,yEAAyE;IACzE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,IAAI,CAAC,EAAE,WAAW,CAAC;IAC5B,oGAAoG;IACpG,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB;;;OAGG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,4GAA4G;IAC5G,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,mEAAmE;IACnE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;CACxB;AAED,+EAA+E;AAC/E,MAAM,MAAM,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G,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":"","sources":["../../src/api/dashboards.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAIH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAE9C,KAAK,IAAI,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAWpC,eAAO,MAAM,eAAe,0BAA0B,CAAC;AAEvD,kEAAkE;AAClE,eAAO,MAAM,0BAA0B,EAAE,SAAS,MAAM,EAAkC,CAAC;AAE3F,uFAAuF;AACvF,eAAO,MAAM,qBAAqB,EAAE,SAAS,MAAM,EAAsB,CAAC;AAE1E;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAA;CAAE,CAAC;AAE1I,uFAAuF;AACvF,wBAAgB,YAAY,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AE,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,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,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