@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,111 @@
1
+ /**
2
+ * The `grafana` namespace in `chant.config.ts` (#2946): which Grafana each
3
+ * chant environment observes, exports from and (#2948) applies to.
4
+ *
5
+ * ```ts
6
+ * import type { ChantConfig } from "@intentius/chant/config";
7
+ * import "@intentius/chant-lexicon-grafana"; // brings the `grafana` key into ChantConfig
8
+ *
9
+ * export default {
10
+ * lexicons: ["grafana"],
11
+ * grafana: {
12
+ * profiles: {
13
+ * staging: { url: "https://grafana.staging.example.com", token: { env: "GRAFANA_STAGING_TOKEN" } },
14
+ * prod: { url: "https://grafana.example.com", token: { env: "GRAFANA_PROD_TOKEN" }, orgId: 2 },
15
+ * },
16
+ * },
17
+ * } satisfies ChantConfig;
18
+ * ```
19
+ *
20
+ * A profile is keyed by chant environment, as `k8s.profiles.<env>` is.
21
+ * Credentials are named by their environment variable, never written in
22
+ * the config. An environment with no profile falls back to `GRAFANA_URL`
23
+ * with `GRAFANA_TOKEN`, or `GRAFANA_USER` and `GRAFANA_PASSWORD` (see
24
+ * `resolveGrafanaTarget`).
25
+ *
26
+ * One schema, three consumers, as in the fountain lexicon: core validates the
27
+ * namespace against it at load, the type is derived from it, and that type
28
+ * augments `ChantConfig`.
29
+ */
30
+ import { z } from "zod";
31
+ import type { ChantConfig } from "@intentius/chant/config";
32
+ import type { GrafanaTarget } from "./api/client.js";
33
+ export declare const grafanaProfileSchema: z.ZodObject<{
34
+ /** Base URL of the Grafana instance. */
35
+ url: z.ZodString;
36
+ /** A service account token, named by its environment variable. */
37
+ token: z.ZodOptional<z.ZodObject<{
38
+ env: z.ZodString;
39
+ }, z.core.$strict>>;
40
+ /** Basic auth, each half named by its environment variable. For a local instance; use a token elsewhere. */
41
+ basicAuth: z.ZodOptional<z.ZodObject<{
42
+ user: z.ZodObject<{
43
+ env: z.ZodString;
44
+ }, z.core.$strict>;
45
+ password: z.ZodObject<{
46
+ env: z.ZodString;
47
+ }, z.core.$strict>;
48
+ }, z.core.$strict>>;
49
+ /** Organisation id. Defaults to 1. */
50
+ orgId: z.ZodOptional<z.ZodNumber>;
51
+ /** The `dashboard.grafana.app` namespace, when it is not `default` / `org-<id>` (Grafana Cloud: `stacks-<id>`). */
52
+ namespace: z.ZodOptional<z.ZodString>;
53
+ }, z.core.$strict>;
54
+ export declare const grafanaConfigSchema: z.ZodObject<{
55
+ /** One Grafana per chant environment. */
56
+ profiles: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
57
+ /** Base URL of the Grafana instance. */
58
+ url: z.ZodString;
59
+ /** A service account token, named by its environment variable. */
60
+ token: z.ZodOptional<z.ZodObject<{
61
+ env: z.ZodString;
62
+ }, z.core.$strict>>;
63
+ /** Basic auth, each half named by its environment variable. For a local instance; use a token elsewhere. */
64
+ basicAuth: z.ZodOptional<z.ZodObject<{
65
+ user: z.ZodObject<{
66
+ env: z.ZodString;
67
+ }, z.core.$strict>;
68
+ password: z.ZodObject<{
69
+ env: z.ZodString;
70
+ }, z.core.$strict>;
71
+ }, z.core.$strict>>;
72
+ /** Organisation id. Defaults to 1. */
73
+ orgId: z.ZodOptional<z.ZodNumber>;
74
+ /** The `dashboard.grafana.app` namespace, when it is not `default` / `org-<id>` (Grafana Cloud: `stacks-<id>`). */
75
+ namespace: z.ZodOptional<z.ZodString>;
76
+ }, z.core.$strict>>>;
77
+ }, z.core.$strict>;
78
+ export type GrafanaProfile = z.infer<typeof grafanaProfileSchema>;
79
+ export type GrafanaConfig = z.infer<typeof grafanaConfigSchema>;
80
+ declare module "@intentius/chant/config" {
81
+ interface ChantConfig {
82
+ grafana?: GrafanaConfig;
83
+ }
84
+ }
85
+ /** Compile-time proof that the augmentation reaches `ChantConfig`. */
86
+ export type GrafanaConfigNamespace = NonNullable<ChantConfig["grafana"]>;
87
+ /** Why no target could be resolved, in the observation vocabulary. */
88
+ export interface UnresolvedTarget {
89
+ readonly reason: "no-binding" | "no-credentials";
90
+ readonly detail: string;
91
+ }
92
+ declare function isUnresolved(v: GrafanaTarget | UnresolvedTarget): v is UnresolvedTarget;
93
+ export { isUnresolved as isUnresolvedTarget };
94
+ /**
95
+ * The Grafana an environment reads from. Pure: `config` and `env` are
96
+ * passed in.
97
+ *
98
+ * 1. `grafana.profiles.<environment>`. A profile that names a credential
99
+ * variable which is not set is `no-credentials`, not an anonymous read:
100
+ * the profile said how to authenticate.
101
+ * 2. `GRAFANA_URL`, with `GRAFANA_TOKEN`, or `GRAFANA_USER` and
102
+ * `GRAFANA_PASSWORD`, or neither (an instance with anonymous access; a
103
+ * refused read is then `no-credentials`).
104
+ * 3. Otherwise `no-binding`.
105
+ */
106
+ export declare function resolveGrafanaTarget(input: {
107
+ environment?: string;
108
+ config?: Pick<ChantConfig, "grafana">;
109
+ env?: Record<string, string | undefined>;
110
+ }): GrafanaTarget | UnresolvedTarget;
111
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,KAAK,EAAe,aAAa,EAAE,MAAM,cAAc,CAAC;AAI/D,eAAO,MAAM,oBAAoB;IAC/B,wCAAwC;;IAExC,kEAAkE;;;;IAElE,4GAA4G;;;;;;;;;IAE5G,sCAAsC;;IAEtC,mHAAmH;;kBAEnH,CAAC;AAEH,eAAO,MAAM,mBAAmB;IAC9B,yCAAyC;;QAbzC,wCAAwC;;QAExC,kEAAkE;;;;QAElE,4GAA4G;;;;;;;;;QAE5G,sCAAsC;;QAEtC,mHAAmH;;;kBAOnH,CAAC;AAEH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAClE,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAEhE,OAAO,QAAQ,yBAAyB,CAAC;IACvC,UAAU,WAAW;QACnB,OAAO,CAAC,EAAE,aAAa,CAAC;KACzB;CACF;AAED,sEAAsE;AACtE,MAAM,MAAM,sBAAsB,GAAG,WAAW,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC,CAAC;AAEzE,sEAAsE;AACtE,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,MAAM,EAAE,YAAY,GAAG,gBAAgB,CAAC;IACjD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED,iBAAS,YAAY,CAAC,CAAC,EAAE,aAAa,GAAG,gBAAgB,GAAG,CAAC,IAAI,gBAAgB,CAEhF;AAED,OAAO,EAAE,YAAY,IAAI,kBAAkB,EAAE,CAAC;AAE9C;;;;;;;;;;;GAWG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE;IAC1C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,IAAI,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;IACtC,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;CAC1C,GAAG,aAAa,GAAG,gBAAgB,CA2CnC"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * The contact point settings Grafana stores encrypted, per integration: the
3
+ * options marked `secure` by `GET /api/alert-notifiers?version=2` on
4
+ * `grafana/grafana:13.2.2` (commit 1bea008f; the same list on 12.4.11).
5
+ * Nested settings are dotted paths (`tlsConfig.clientKey`).
6
+ *
7
+ * GRAF002 flags a literal at one of these paths, and the importer replaces
8
+ * the `[REDACTED]` that an export without secrets writes there.
9
+ */
10
+ export declare const CONTACT_POINT_SECRET_SETTINGS: Readonly<Record<string, readonly string[]>>;
11
+ /** How Grafana provisioning reads a value from outside the file: `$VAR`, `${VAR}`, `$__env{…}`, `$__file{…}`, `$__vault{…}`. */
12
+ export declare const EXPANDED_VALUE: RegExp;
13
+ /** What an export without secrets writes in place of each one. */
14
+ export declare const REDACTED = "[REDACTED]";
15
+ /** The secret settings of one receiver present in `settings`, with their values: `[path, value]`. */
16
+ export declare function secretSettings(type: string, settings: Record<string, unknown>): Array<[string, unknown]>;
17
+ //# sourceMappingURL=contact-point-secrets.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contact-point-secrets.d.ts","sourceRoot":"","sources":["../src/contact-point-secrets.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,eAAO,MAAM,6BAA6B,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC,CAoCpF,CAAC;AAEH,gIAAgI;AAChI,eAAO,MAAM,cAAc,QAAsF,CAAC;AAElH,kEAAkE;AAClE,eAAO,MAAM,QAAQ,eAAe,CAAC;AAErC,qGAAqG;AACrG,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,KAAK,CAAC,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAQxG"}
@@ -39,6 +39,13 @@ export interface DashboardProps {
39
39
  graphTooltip?: "default" | "sharedCrosshair" | "sharedTooltip";
40
40
  /** Whether users may edit it in the UI. Defaults to true, as in Grafana. */
41
41
  editable?: boolean;
42
+ /**
43
+ * The dashboard schema version the JSON is written at. Leave it out for
44
+ * the pinned one (`DASHBOARD_SCHEMA_VERSION`). `chant import` sets it for
45
+ * a dashboard saved by an older Grafana, so Grafana still runs its
46
+ * migrations when it loads the rebuilt JSON.
47
+ */
48
+ schemaVersion?: number;
42
49
  variables?: VariableEntity<any>[];
43
50
  /** Panels and rows, top to bottom. A row's own `panels` follow it. */
44
51
  panels?: Array<PanelEntity<any, any> | RowEntity>;
@@ -46,7 +53,10 @@ export interface DashboardProps {
46
53
  /**
47
54
  * The Grafana folder to provision it into. Written as a subdirectory of
48
55
  * `dashboards/`, which the provider maps to folders
49
- * (`foldersFromFilesStructure`). Leave it out for the General folder.
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.
50
60
  */
51
61
  folder?: string;
52
62
  }
@@ -63,7 +73,11 @@ export interface DashboardProviderProps {
63
73
  /** Provider name, unique in the provisioning file. */
64
74
  name: string;
65
75
  orgId?: number;
66
- /** Folder for dashboards not in a subdirectory. */
76
+ /**
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).
80
+ */
67
81
  folder?: string;
68
82
  folderUid?: string;
69
83
  /** Where the `dashboards/` output is mounted in the Grafana container. Defaults to `/var/lib/grafana/dashboards`. */
@@ -1 +1 @@
1
- {"version":3,"file":"dashboard.d.ts","sourceRoot":"","sources":["../src/dashboard.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACvD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,KAAK,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,wBAAw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,CAAC,KAAK,EAAE,cAAc,CAAC;CAChC;AAED,eAAO,MAAM,cAAc,uBAAuB,CAAC;AAInD,2BAA2B;AAC3B,eAAO,MAAM,SAAS,EAEN,KAAK,KAAK,EAAE,cAAc,KAAK,eAAe,CAAC;AAG/D,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,eAAe,CAO1E;AAED,oFAAoF;AACpF,eAAO,MAAM,uBAAuB,gCAAgC,CAAC;AAErE,MAAM,WAAW,sBAAsB;IACrC,sDAAsD;IACtD,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,qHAAqH;IACrH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,+GAA+G;IAC/G,yBAAyB,CAAC,EAAE,OAAO,CAAC;IACpC,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,qBAAqB,CAAC,EAAE,MAAM,CAAC;CAChC;AAED,MAAM,WAAW,uBAAwB,SAAQ,UAAU;IACzD,QAAQ,CAAC,KAAK,EAAE,sBAAsB,CAAC;CACxC;AAED,eAAO,MAAM,uBAAuB,+BAA+B,CAAC;AAOpE,6GAA6G;AAC7G,eAAO,MAAM,iBAAiB,EAEd,KAAK,KAAK,EAAE,sBAAsB,KAAK,uBAAuB,CAAC;AAG/E,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,uBAAuB,CAO1F"}
@@ -0,0 +1,95 @@
1
+ /**
2
+ * Which datasource each panel, query and query variable in built dashboard
3
+ * JSON sends its request to.
4
+ *
5
+ * GRAF101 and GRAF102 use this to check references against the datasources
6
+ * a build knows about: the ones it provisions (`Datasource`) and the ones it
7
+ * only references (`ExternalDatasource`). Any other check that needs to know
8
+ * which plugin runs a query (a PromQL syntax check only wants the queries
9
+ * that reach a Prometheus) can call `datasourceUses()` and read
10
+ * `resolved.type`.
11
+ */
12
+ import type { ExternalDatasourceRecord, ProvisionedDatasource } from "./build.js";
13
+ type Json = Record<string, unknown>;
14
+ /** A `{ type, uid }` datasource reference as dashboard JSON holds it. */
15
+ export interface DatasourceRefJson {
16
+ type?: string;
17
+ uid?: string;
18
+ }
19
+ /** A datasource the build knows by uid: provisioned by it, or declared external. */
20
+ export interface KnownDatasource {
21
+ uid: string;
22
+ type: string;
23
+ name?: string;
24
+ /** Declared with `ExternalDatasource`: referenced, not provisioned. */
25
+ external: boolean;
26
+ }
27
+ /**
28
+ * Where a reference leads.
29
+ *
30
+ * - `declared`: a known datasource; `type` is its plugin type.
31
+ * - `variable`: a `${name}` uid; `type` is the datasource variable's plugin type, else the ref's own.
32
+ * - `builtin`: one of Grafana's pseudo-datasources (`-- Mixed --`, `-- Dashboard --`, `grafana`).
33
+ * - `undeclared`: a uid the build does not know; `type` is whatever the ref says.
34
+ * - `default`: no uid, so Grafana picks its default datasource; `type` is the ref's, if it has one.
35
+ */
36
+ export type ResolvedDatasource = {
37
+ kind: "declared";
38
+ type: string;
39
+ datasource: KnownDatasource;
40
+ } | {
41
+ kind: "variable";
42
+ type?: string;
43
+ variable: string;
44
+ declared: boolean;
45
+ } | {
46
+ kind: "builtin";
47
+ type?: string;
48
+ } | {
49
+ kind: "undeclared";
50
+ type?: string;
51
+ uid: string;
52
+ } | {
53
+ kind: "default";
54
+ type?: string;
55
+ };
56
+ /** One place a dashboard names, or inherits, a datasource. */
57
+ export interface DatasourceUse {
58
+ /** A panel's own `datasource`, one of its queries (`targets`), or a query variable. */
59
+ kind: "panel" | "query" | "variable";
60
+ /** A human description, e.g. `panel "Latency" (id 3) query B`. */
61
+ where: string;
62
+ panel?: Json;
63
+ target?: Json;
64
+ variable?: Json;
65
+ /** The ref written on this panel, query or variable; unset when a query inherits its panel's. */
66
+ ref?: DatasourceRefJson;
67
+ /** Where the request goes: the query's own ref, else its panel's. */
68
+ resolved: ResolvedDatasource;
69
+ }
70
+ /** Every datasource a build knows by uid. A provisioned one wins over an external one of the same uid (GRAF104 reports the clash). */
71
+ export declare function knownDatasources(datasources: readonly ProvisionedDatasource[], external?: readonly ExternalDatasourceRecord[]): Map<string, KnownDatasource>;
72
+ export interface PanelInfo {
73
+ panel: Json;
74
+ /** Panels inside a collapsed row are laid out in their own group. */
75
+ group: string;
76
+ }
77
+ /** Every panel of a dashboard, including those inside collapsed rows, and the rows themselves. */
78
+ export declare function panelsOf(dashboard: Json): PanelInfo[];
79
+ export declare function describePanel(panel: Json): string;
80
+ /** A dashboard's `templating.list`. */
81
+ export declare function variablesOf(dashboard: Json): Json[];
82
+ /** Every variable name referenced in a string. */
83
+ export declare function variableReferences(text: string): string[];
84
+ /** Grafana's own pseudo-datasources, which no build declares. */
85
+ export declare function isPseudoRef(ref: DatasourceRefJson): boolean;
86
+ /** Where one reference leads, given the dashboard's datasource variables and the known datasources. */
87
+ export declare function resolveDatasourceRef(ref: DatasourceRefJson | undefined, dsVariables: ReadonlyMap<string, Json>, known: ReadonlyMap<string, KnownDatasource>): ResolvedDatasource;
88
+ /**
89
+ * Every place a dashboard names or inherits a datasource: each panel's own
90
+ * ref, each query (with its own ref, or its panel's when it has none), and
91
+ * each query variable. Rows are left out; their panels carry the ref.
92
+ */
93
+ export declare function datasourceUses(dashboard: Json, known: ReadonlyMap<string, KnownDatasource>): DatasourceUse[];
94
+ export {};
95
+ //# sourceMappingURL=datasource-refs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"datasource-refs.d.ts","sourceRoot":"","sources":["../src/datasource-refs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,wBAAwB,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAG/E,KAAK,IAAI,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAEpC,yEAAyE;AACzE,MAA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B,gBAAgB,CAC9B,WAAW,EAAE,SAAS,qBAAqB,EAAE,EAC7C,QAAQ,GAAE,SAAS,wBAAwB,EAAO,GACjD,GAAG,CAAC,MAAM,EAAE,eAAe,CAAC,CAK9B;AAED,MAAM,WAAW,SAAS;IACxB,KAAK,EAAE,IAAI,CAAC;IACZ,qEAAqE;IACrE,KAAK,EAAE,MAAM,CAAC;CACf;AAED,kGAAkG;AAClG,wBAAgB,QAAQ,CAAC,SAAS,EAAE,IAAI,GAAG,SAAS,EAAE,CAWrD;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,IAAI,GAAG,MAAM,CAGjD;AAED,uCAAuC;AACvC,wBAAgB,WAAW,CAAC,SAAS,EAAE,IAAI,GAAG,IAAI,EAAE,CAGnD;AAID,kDAAkD;AAClD,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAIzD;AAMD,iEAAiE;AACjE,wBAAgB,WAAW,CAAC,GAAG,EAAE,iBAAiB,GAAG,OAAO,CAE3D;AAOD,uGAAuG;AACvG,wBAAgB,oBAAoB,CAClC,GAAG,EAAE,iBAAiB,GAAG,SAAS,EAClC,WAAW,EAAE,WAAW,CAAC,MAAM,EAAE,IAAI,CAAC,EACtC,KAAK,EAAE,WAAW,CAAC,MAAM,EAAE,eAAe,CAAC,GAC1C,kBAAkB,CAapB;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,WAAW,CAAC,MAAM,EAAE,eAAe,CAAC,GAAG,aAAa,EAAE,CAmC5G"}
@@ -57,6 +57,35 @@ export interface DatasourceConstructor {
57
57
  /** A Grafana datasource, provisioned from `provisioning/datasources/chant.yaml`. */
58
58
  export declare const Datasource: DatasourceConstructor;
59
59
  export declare function isDatasourceEntity(value: unknown): value is DatasourceEntity;
60
+ export declare const EXTERNAL_DATASOURCE_TYPE = "Grafana::ExternalDatasource";
61
+ export interface ExternalDatasourceProps<T extends string = string> {
62
+ /** The datasource plugin id, e.g. `prometheus`. */
63
+ type: T;
64
+ /** The uid the datasource already has in Grafana. */
65
+ uid: string;
66
+ /** Its display name in Grafana, for messages and for a `DatasourceVariable` `regex`. */
67
+ name?: string;
68
+ }
69
+ export interface ExternalDatasourceEntity<T extends string = string> extends Declarable {
70
+ readonly props: ExternalDatasourceProps<T>;
71
+ /** The plugin id. */
72
+ readonly datasourceType: T;
73
+ /** The uid panels will reference. */
74
+ readonly uid: string;
75
+ }
76
+ export interface ExternalDatasourceConstructor {
77
+ new <T extends string>(props: ExternalDatasourceProps<T>): ExternalDatasourceEntity<T>;
78
+ }
79
+ /**
80
+ * A datasource that already exists in Grafana: provisioned by hand, by
81
+ * another build root, or by another tool. It is never written to the
82
+ * provisioning file. Panels, queries and variables use it like a
83
+ * `Datasource`, and GRAF101/GRAF102 check references against it.
84
+ */
85
+ export declare const ExternalDatasource: ExternalDatasourceConstructor;
86
+ export declare function isExternalDatasource(value: unknown): value is ExternalDatasourceEntity;
87
+ /** A declared or an external datasource: anything a panel can hold that has a fixed uid. */
88
+ export declare function isDatasourceDeclaration(value: unknown): value is DatasourceEntity | ExternalDatasourceEntity;
60
89
  /** A datasource declared somewhere this build can't see, named by its Grafana ref. */
61
90
  export interface DatasourceRef<T extends string = string> {
62
91
  type: T;
@@ -1 +1 @@
1
- {"version":3,"file":"datasource.d.ts","sourceRoot":"","sources":["../src/datasource.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAG9D,2GAA2G;AAC3G,MAAM,MAAM,mBAAmB,GAAG,YAAY,GAAG,OAAO,GAAG,MAAM,CAAC;AAElE,wGAAwG;AACxG,MAAM,MAAM,gBAAgB,GAAG,OAAO,GAAG,QAAQ,CAAC;AAElD,MAAM,WAAW,eAAe,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM;IACxD,4DAA4D;IAC5D,IAAI,EAAE,MAAM,CAAC;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,KAAK,CAAC,SAAS,MAAM,EAAE,KAAK,EAAE,uBAAuB,CAAC,CAAC,CAAC,GAAG,wBAAwB,CAAC,CAAC,CAAC,CAAC;CACxF;AAED;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,EAIf,6BAA6B,CAAC;AAG9C,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,wBAAwB,CAOtF;AAED,4FAA4F;AAC5F,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,gBAAgB,GAAG,wBAAwB,CAE5G;AAED,sFAAsF;AACtF,MAAM,WAAW,aAAa,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM;IACtD,IAAI,EAAE,CAAC,CAAC;IACR,GAAG,EAAE,MAAM,CAAC;CACb;AAED,mEAAmE;AACnE,eAAO,MAAM,uBAAuB,EAAE,WAAW,CAAC,MAAM,CAA2E,CAAC"}
@@ -0,0 +1,64 @@
1
+ /**
2
+ * grafana deep-observation noise rules (#2946).
3
+ *
4
+ * Plain data on the plugin, because core applies the same rules to the
5
+ * declared tree (a `Dashboard`'s props, panels and queries inlined), which
6
+ * no reader touches. The live tree is the stored dashboard put back into the
7
+ * same vocabulary by the importer (./import/live-export.ts), so what is left
8
+ * to name here is what the translation cannot decide: values the build
9
+ * wrote that the author did not, values Grafana adds or drops on save, and
10
+ * values an author wrote out that are also what happens when they are left
11
+ * out.
12
+ *
13
+ * Measured against Grafana 12.4.11 and 13.2.2 (the e2e in
14
+ * ./observe.e2e.test.ts): read over `/api/dashboards/uid`, a stored dashboard
15
+ * differs from the built one only by the `id` and `version` Grafana adds
16
+ * (../test/e2e/stored-model.ts). Read over `/apis/dashboard.grafana.app`, its
17
+ * spec has no `id` or `version`, but it carries the built-in "Annotations &
18
+ * Alerts" annotation, and empty `options` and `fieldConfig` and every `null`
19
+ * are gone. The rest of this table is the build's own choices: panel ids,
20
+ * grid positions, query refIds, a panel's datasource taken from its queries.
21
+ *
22
+ * Every rule is one of four kinds, and they are in this order below:
23
+ *
24
+ * 1. **Never compared**, on either side: Grafana's bookkeeping.
25
+ * 2. **Empty is absent**, on both sides: `null`, `{}` and `[]` mean the same
26
+ * as leaving a key out, everywhere in a dashboard or datasource. The cost
27
+ * is that values added where the declaration wrote `[]` are reported as
28
+ * unclaimed rather than as drift.
29
+ * 3. **Build-derived**, on the live side where the declaration has nothing:
30
+ * the build filled it in, so it cannot disagree with what was declared.
31
+ * 4. **Default written out**, on the declared side where the live side has
32
+ * nothing: the author wrote the value Grafana assumes, which the
33
+ * translation leaves out.
34
+ *
35
+ * Rules 3 and 4 are gated on `counterpart === "absent"`, so a value the
36
+ * author did declare is always compared, and a change away from it is drift.
37
+ * (That relies on core walking a panel's props when it lists the declared
38
+ * paths, which #2946 fixed in `deepPathSet`.)
39
+ */
40
+ import type { DeepNormalizationHooks } from "@intentius/chant/deep-observation";
41
+ type Json = Record<string, unknown>;
42
+ /** Where a node sits in a dashboard tree, from its index-erased pattern. */
43
+ type Level = "dashboard" | "panel" | "target" | "variable" | "link";
44
+ /**
45
+ * Defaults in the props vocabulary: a key an author may write at this value,
46
+ * and the translation leaves out because Grafana assumes it. The dashboard
47
+ * and panel entries mirror `DASHBOARD_DEFAULTS` and `PANEL_DEFAULTS` in
48
+ * ./import/normalize.ts, with `graphTooltip` spelled as `Dashboard` takes it.
49
+ */
50
+ export declare const PROP_DEFAULTS: Readonly<Record<Level, Readonly<Json>>>;
51
+ /**
52
+ * Keys the build fills in when a declaration leaves them out, by level:
53
+ * the dashboard's uid (from its export name) and schema version, a panel's
54
+ * id, grid position and datasource (from its queries), a query's refId.
55
+ * Grafana keeps what the build wrote, so undeclared, they read back as the
56
+ * build's choice rather than as anybody's edit.
57
+ *
58
+ * `timezone` is here as a value, not a key: chant writes `browser` for a
59
+ * dashboard that names none, where Grafana's own default is `""`.
60
+ */
61
+ export declare const BUILD_DERIVED: Readonly<Record<Level, ReadonlySet<string>>>;
62
+ export declare const grafanaDeepNormalizationHooks: DeepNormalizationHooks;
63
+ export {};
64
+ //# sourceMappingURL=deep-observe-hooks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deep-observe-hooks.d.ts","sourceRoot":"","sources":["../src/deep-observe-hooks.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AAEH,OAAO,KAAK,EAA8B,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AAQ5G,KAAK,IAAI,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAEpC,4EAA4E;AAC5E,KAAK,KAAK,GAAG,WAAW,GAAG,OAAO,GAAG,QAAQ,GAAG,UAAU,GAAG,MAAM,CAAC;AAoBpE;;;;;GAKG;AACH,eAAO,MAAM,aAAa,EAAE,QAAQ,CAAC,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC,CA+CjE,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,aAAa,EAAE,QAAQ,CAAC,MAAM,CAAC,KAAK,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC,CAOtE,CAAC;AAkFF,eAAO,MAAM,6BAA6B,EAAE,sBA0B3C,CAAC"}
@@ -0,0 +1,42 @@
1
+ /**
2
+ * grafana deep observation (#2946): the property tree of each declared
3
+ * dashboard and datasource as Grafana holds it, so a dashboard edited in the
4
+ * UI shows up in `chant lifecycle diff --live` path by path.
5
+ *
6
+ * The read is the thin read's (./describe-resources.ts): same binding, same
7
+ * discovered API, same uid. What differs is what is done with the answer.
8
+ *
9
+ * - A dashboard's stored JSON goes through the importer
10
+ * (./import/live-export.ts `dashboardTree`), which puts it into the
11
+ * vocabulary its declaration is written in: `graphTooltip:
12
+ * "sharedCrosshair"` rather than `1`, rows holding their panels, queries
13
+ * without the refIds the build numbered. Core then diffs that against the
14
+ * declaration's props, normalized on both sides by
15
+ * ./deep-observe-hooks.ts.
16
+ * - A dashboard Grafana stores as v2 is read at v2 and converted to the
17
+ * classic JSON the importer makes of it (#2947), so the tree is
18
+ * diffed against the declaration: a tab added in the UI is a row that
19
+ * the declaration does not have.
20
+ * - The folder is not in the JSON. It is read from the resource's folder
21
+ * and written as its title, the form `Dashboard.folder` takes; when the
22
+ * declaration's folder name is one the build had to rewrite to make a
23
+ * directory (`Ops/Team` becomes `Ops-Team`), the declared spelling is
24
+ * kept, since the two name the same folder.
25
+ * - A datasource's API payload is put into `DatasourceProps` vocabulary,
26
+ * secrets as key names only.
27
+ *
28
+ * Tri-state, one level down: a dashboard that is not there is left out (the
29
+ * thin read reports it missing); one that cannot be read (a failed
30
+ * request, withheld by `owned`, a v2-stored dashboard the server cannot
31
+ * serve at v2) is NOT-OBSERVED with its reason; a
32
+ * provider has no API and is `unsupported-kind`. Nothing unreadable comes
33
+ * back as a clean tree. A declared panel, row, query or variable has no tree
34
+ * of its own (./members.ts): its properties are in its dashboard's.
35
+ */
36
+ import type { DeepObservationResult } from "@intentius/chant/lexicon";
37
+ import { grafanaDeepNormalizationHooks } from "./deep-observe-hooks.js";
38
+ import { type GrafanaObserveOptions } from "./describe-resources.js";
39
+ export { grafanaDeepNormalizationHooks };
40
+ /** Read the live property tree of every declared grafana entity. */
41
+ export declare function observeResourcesDeepGrafana(options: GrafanaObserveOptions): Promise<DeepObservationResult>;
42
+ //# sourceMappingURL=deep-observe.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deep-observe.d.ts","sourceRoot":"","sources":["../src/deep-observe.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAEH,OAAO,KAAK,EAAE,qBAAqB,EAA6C,MAAM,0BAA0B,CAAC;AASjH,OAAO,EAAE,6BAA6B,EAAE,MAAM,sBAAsB,CAAC;AACrE,OAAO,EAAqD,KAAK,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAKrH,OAAO,EAAE,6BAA6B,EAAE,CAAC;AAwDzC,oEAAoE;AACpE,wBAAsB,2BAA2B,CAAC,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAuDhH"}
@@ -0,0 +1,49 @@
1
+ /**
2
+ * `describeResources()` for grafana (#2946): does each declared dashboard
3
+ * and datasource exist in the environment's Grafana, and whose is it.
4
+ *
5
+ * Runs on core's observer harness. `bind()` resolves the environment's
6
+ * Grafana (`grafana.profiles.<env>`, else `GRAFANA_URL`) and discovers which
7
+ * dashboard API it serves; each entity is one GET, by the uid the build gives
8
+ * it. Verdicts:
9
+ *
10
+ * | Entity | Read | 404 | Not readable |
11
+ * |---|---|---|---|
12
+ * | `Dashboard` | `/apis/dashboard.grafana.app/<v>/.../dashboards/<uid>` (Grafana 11: `/api/dashboards/uid/<uid>`) | absent | a v2-stored dashboard the server does not serve at v2: `unsupported-kind` |
13
+ * | `Datasource`, `ExternalDatasource` | `/api/datasources/uid/<uid>` | absent | |
14
+ * | a panel, row, query or variable | its dashboard's read (./members.ts) | its dashboard's | its dashboard's |
15
+ * | `DashboardProvider` | none: a provisioning-file setting Grafana serves no API for | | `unsupported-kind` |
16
+ *
17
+ * A dashboard Grafana stores as v2 is read at v2 and converted (#2947);
18
+ * its metadata says `schema: "v2"` and lists what the classic form cannot
19
+ * hold under `v2Lossy`.
20
+ *
21
+ * A refused token is `no-credentials` for every entity, a missing binding
22
+ * `no-binding`, anything else `read-failed`, never absent.
23
+ *
24
+ * Ownership is read where Grafana has a channel (./ownership.ts): a
25
+ * dashboard over `/apis` resolves `owned` or `foreign`; a dashboard over the
26
+ * legacy API and every datasource say `unknown`, and an `owned: true` read
27
+ * withholds them as `filtered`, since it cannot show they are chant's.
28
+ */
29
+ import { type DescribeResourcesResult } from "@intentius/chant/observation";
30
+ import { type BindOptions } from "./api/bind.js";
31
+ export interface GrafanaObserveOptions extends Omit<BindOptions, "environment"> {
32
+ environment: string;
33
+ buildOutput?: string;
34
+ entityNames: string[];
35
+ entities: Map<string, {
36
+ entityType: string;
37
+ props: Record<string, unknown>;
38
+ }>;
39
+ owned?: boolean;
40
+ }
41
+ /** The uid a declared dashboard or datasource has in Grafana: the one the build gives it. */
42
+ export declare function declaredUid(name: string, entityType: string, props: Record<string, unknown>): string | undefined;
43
+ /** What `unsupported-kind` says about a provider. */
44
+ export declare const PROVIDER_NOT_OBSERVABLE = "a dashboard provider is a setting in Grafana's provisioning file, which Grafana serves no API for; its dashboards are observed instead";
45
+ /** What `unsupported-kind` says about a panel, row, query or variable that no declared dashboard holds. */
46
+ export declare const ORPHAN_PART = "panels, rows, queries and variables exist in Grafana only inside a dashboard, and no declared dashboard holds this one";
47
+ /** Observe every declared grafana entity against the environment's Grafana. */
48
+ export declare function describeResources(options: GrafanaObserveOptions): Promise<DescribeResourcesResult>;
49
+ //# sourceMappingURL=describe-resources.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"describe-resources.d.ts","sourceRoot":"","sources":["../src/describe-resources.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAGH,OAAO,EAGL,KAAK,uBAAuB,EAG7B,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAuC,KAAK,WAAW,EAAE,MAAM,YAAY,CAAC;AAUnF,MAAM,WAAW,qBAAsB,SAAQ,IAAI,CAAC,WAAW,EAAE,aAAa,CAAC;IAC7E,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE,CAAC,CAAC;IAC9E,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,6FAA6F;AAC7F,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,GAAG,SAAS,CAKhH;AAED,qDAAqD;AACrD,eAAO,MAAM,uBAAuB,2IACsG,CAAC;AAE3I,2GAA2G;AAC3G,eAAO,MAAM,WAAW,2HACkG,CAAC;AAkI3H,+EAA+E;AAC/E,wBAAsB,iBAAiB,CAAC,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAQxG"}
package/dist/detect.d.ts CHANGED
@@ -5,6 +5,21 @@
5
5
  */
6
6
  /** Dashboard JSON: a `panels` array plus a `schemaVersion` or a `templating` block. */
7
7
  export declare function looksLikeDashboard(data: unknown): data is Record<string, unknown>;
8
+ /** A dashboard saved before Grafana 5.0: panels inside a top-level `rows` list. */
9
+ export declare function looksLikeLegacyRowsDashboard(data: unknown): data is Record<string, unknown>;
10
+ /** A dashboard as the `dashboard.grafana.app` API serves it: `apiVersion`, `kind: Dashboard` and a `spec`. */
11
+ export declare function looksLikeDashboardResource(data: unknown): data is {
12
+ apiVersion: string;
13
+ kind: "Dashboard";
14
+ spec: Record<string, unknown>;
15
+ };
16
+ /** A v2 dashboard: a `dashboard.grafana.app/v2*` resource, or a bare v2 spec (`elements` and `layout`). */
17
+ export declare function looksLikeV2Dashboard(data: unknown): boolean;
18
+ /** What `GET /api/dashboards/uid/<uid>` returns: `{ dashboard, meta }`. */
19
+ export declare function looksLikeDashboardApiResponse(data: unknown): data is {
20
+ dashboard: Record<string, unknown>;
21
+ meta: unknown;
22
+ };
8
23
  /** A datasource provisioning file: `apiVersion` and a `datasources` list. */
9
24
  export declare function looksLikeDatasourceProvisioning(data: unknown): data is {
10
25
  apiVersion: unknown;
@@ -15,6 +30,18 @@ export declare function looksLikeDashboardProvisioning(data: unknown): data is {
15
30
  apiVersion: unknown;
16
31
  providers: unknown[];
17
32
  };
18
- /** Template detection for `chant import` and friends: any of the three. */
33
+ /**
34
+ * An alerting provisioning file (`provisioning/alerting/*.yaml`, or what
35
+ * `/api/v1/provisioning/*\/export` writes): at least one of the alerting
36
+ * lists at the top level and nothing but those and `apiVersion`. A `groups`
37
+ * list must hold Grafana rule groups, so a Prometheus rule file (`groups:`
38
+ * of `name` and `rules` with `expr`) is not mistaken for one.
39
+ */
40
+ export declare function looksLikeAlertingProvisioning(data: unknown): data is Record<string, unknown>;
41
+ /**
42
+ * Template detection for `chant import` and friends: dashboard JSON in any
43
+ * of the shapes above (v2 included, #2947), or a datasource, dashboard or
44
+ * alerting provisioning file.
45
+ */
19
46
  export declare function detectTemplate(data: unknown): boolean;
20
47
  //# sourceMappingURL=detect.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"detect.d.ts","sourceRoot":"","sources":["../src/detect.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH,uFAAuF;AACvF,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAGjF;AAED,6EAA6E;AAC7E,wBAAgB,+BAA+B,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI;IAAE,UAAU,EAAE,OAAO,CAAC;IAAC,WAAW,EAAE,OAAO,EAAE,CAAA;CAAE,CAEtH;AAED,0EAA0E;AAC1E,wBAAgB,8BAA8B,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI;IAAE,UAAU,EAAE,OAAO,CAAC;IAAC,SAAS,EAAE,OAAO,EAAE,CAAA;CAAE,CAEnH;AAED,2EAA2E;AAC3E,wBAAgB,cAAc,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAErD"}
1
+ {"version":3,"file":"detect.d.ts","sourceRoot":"","sources":["../src/detect.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH,uFAAuF;AACvF,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAGjF;AAED,mFAAmF;AACnF,wBAAgB,4BAA4B,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAE3F;AAED,8GAA8G;AAC9G,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,WAAW,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAAE,CAQ1I;AAED,2GAA2G;AAC3G,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAG3D;AAED,2EAA2E;AAC3E,wBAAgB,6BAA6B,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI;IAAE,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAAC,IAAI,EAAE,OAAO,CAAA;CAAE,CAE1H;AAED,6EAA6E;AAC7E,wBAAgB,+BAA+B,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI;IAAE,UAAU,EAAE,OAAO,CAAC;IAAC,WAAW,EAAE,OAAO,EAAE,CAAA;CAAE,CAEtH;AAED,0EAA0E;AAC1E,wBAAgB,8BAA8B,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI;IAAE,UAAU,EAAE,OAAO,CAAC;IAAC,SAAS,EAAE,OAAO,EAAE,CAAA;CAAE,CAEnH;AAuBD;;;;;;GAMG;AACH,wBAAgB,6BAA6B,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAO5F;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAWrD"}
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Live export for grafana (#2946): `chant import --from <env>` writes the
3
+ * environment's dashboards and datasources as chant TypeScript.
4
+ *
5
+ * All I/O is here; the mapping is pure in ./import/live-export.ts, and the
6
+ * IR it builds is the importer's own (#2945), so a dashboard exported from
7
+ * Grafana and the same dashboard's JSON given to `chant import` generate the
8
+ * same source through the same `GrafanaGenerator`.
9
+ *
10
+ * - Every dashboard in the organisation is listed over the API the thin
11
+ * read uses (`/apis/dashboard.grafana.app`, or `/api/search` plus
12
+ * `/api/dashboards/uid` on Grafana 11). A dashboard stored as v2 is read at
13
+ * v2 and exported through its classic form, with a warning for each thing
14
+ * the classic form cannot hold (#2947).
15
+ * - Every datasource is read by uid, for `secureJsonFields`; secrets come
16
+ * back as key names only (see `datasourceProps`).
17
+ * - `selector.type` is `Grafana::Dashboard` or `Grafana::Datasource`;
18
+ * `selector.name` is a uid.
19
+ * - `owned` keeps only dashboards that are chant's (./ownership.ts), and
20
+ * leaves datasources out, since their ownership cannot be read. There is no
21
+ * project here to name its providers, so a file-provisioned dashboard is
22
+ * chant's when its provider is the default one, `chant`.
23
+ * - `verbatim` keeps datasource keys at the API's "not set" values. A
24
+ * dashboard is always planned by the importer, which leaves out keys at
25
+ * Grafana's defaults either way.
26
+ */
27
+ import type { ExportedTemplate, ResourceSelector } from "@intentius/chant/lexicon";
28
+ import { type BindOptions } from "./api/bind.js";
29
+ export interface GrafanaExportOptions extends Omit<BindOptions, "environment"> {
30
+ environment: string;
31
+ stack?: string;
32
+ region?: string;
33
+ selector?: ResourceSelector;
34
+ owned?: boolean;
35
+ verbatim?: boolean;
36
+ }
37
+ export declare function exportResources(options: GrafanaExportOptions): Promise<ExportedTemplate>;
38
+ //# sourceMappingURL=export-resources.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"export-resources.d.ts","sourceRoot":"","sources":["../src/export-resources.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AACnF,OAAO,EAAe,KAAK,WAAW,EAAE,MAAM,YAAY,CAAC;AAU3D,MAAM,WAAW,oBAAqB,SAAQ,IAAI,CAAC,WAAW,EAAE,aAAa,CAAC;IAC5E,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,gBAAgB,CAAC;IAC5B,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,wBAAsB,eAAe,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAoC9F"}