@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,40 @@
1
+ /**
2
+ * An alerting provisioning file -> a `Plan`, for `chant import`.
3
+ *
4
+ * Accepts what Grafana's file provisioner reads and what
5
+ * `GET /api/v1/provisioning/*\/export` writes (the same format at v12.4.11
6
+ * and v13.2.2): rule groups, contact points, notification policies, mute
7
+ * timings and templates, in one file or split across several.
8
+ *
9
+ * - A rule group becomes an `AlertRuleGroup`, each rule an `AlertRule`,
10
+ * each entry of a rule's `data` a declaration of its own: a server-side
11
+ * expression as its typed class (`ReduceExpression`, `ThresholdExpression`,
12
+ * ...), and a datasource query as an `AlertQuery` holding its model as it
13
+ * is, so nothing a plugin stores is lost.
14
+ * - A datasource uid a query names becomes an `ExternalDatasource` when the
15
+ * file says its plugin type (`model.datasource.type`), so the checks can
16
+ * see it (GRAF108 parses Prometheus queries). When the type has to be
17
+ * inferred from the model, the import says so; when it cannot be told,
18
+ * the query keeps the bare uid and the import says that too.
19
+ * - A contact point, policy, mute timing or template becomes its class;
20
+ * a receiver or timing named in the same file is referenced by variable.
21
+ * - `deleteRules`, `deleteContactPoints`, `resetPolicies`, `deleteMuteTimes`
22
+ * and `deleteTemplates` are not carried, with a warning.
23
+ *
24
+ * Grafana's editor writes keys into expression models that the expression
25
+ * does not read (a `conditions` block on reduce and math, `operator`,
26
+ * `query`, `reducer` and `type` in a threshold's conditions, `type` and
27
+ * `reducer.params` in classic conditions). They are left out as edits without a warning:
28
+ * Grafana evaluates the rule the same without them.
29
+ */
30
+ import { type ImportEdit } from "./edits.js";
31
+ import { type Plan } from "./model.js";
32
+ type Json = Record<string, unknown>;
33
+ /** Plan an alerting provisioning file. `edits` applied to the file give what the rebuilt file should equal (see `normalizeAlerting`). */
34
+ export declare function planAlertingProvisioning(doc: Json): {
35
+ plan: Plan;
36
+ edits: ImportEdit[];
37
+ warnings: string[];
38
+ };
39
+ export {};
40
+ //# sourceMappingURL=alerting.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"alerting.d.ts","sourceRoot":"","sources":["../../src/import/alerting.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,EAAW,KAAK,UAAU,EAAE,MAAM,SAAS,CAAC;AAEnD,OAAO,EAA2C,KAAK,IAAI,EAAE,MAAM,SAAS,CAAC;AAO7E,KAAK,IAAI,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAucpC,yIAAyI;AACzI,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,IAAI,GAAG;IAAE,IAAI,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,UAAU,EAAE,CAAC;IAAC,QAAQ,EAAE,MAAM,EAAE,CAAA;CAAE,CAI3G"}
@@ -0,0 +1,47 @@
1
+ /**
2
+ * What the importer did to a dashboard on the way to TypeScript, as edits
3
+ * to its JSON.
4
+ *
5
+ * Every key the importer leaves out, and every value it writes in another
6
+ * form, is one edit, and every edit that changes what Grafana does comes
7
+ * with an import warning. The round-trip test applies the edits to the
8
+ * source dashboard and expects the rebuilt dashboard to equal the result
9
+ * (after `normalizeDashboard`), which is how it checks that nothing is
10
+ * dropped without a warning.
11
+ */
12
+ type Json = Record<string, unknown>;
13
+ export type ImportEdit =
14
+ /** The value at `path` (a JSON pointer) is not carried. */
15
+ {
16
+ readonly op: "remove";
17
+ readonly path: string;
18
+ }
19
+ /** The value at `path` is written as `value`. */
20
+ | {
21
+ readonly op: "replace";
22
+ readonly path: string;
23
+ readonly value: unknown;
24
+ }
25
+ /** Every string in the dashboard has `from` replaced by `to` (an `__inputs` constant filled in). */
26
+ | {
27
+ readonly op: "substitute";
28
+ readonly from: string;
29
+ readonly to: string;
30
+ }
31
+ /** `value` is added at the front of `templating.list` (an `__inputs` datasource as a variable). */
32
+ | {
33
+ readonly op: "prependVariable";
34
+ readonly value: Json;
35
+ };
36
+ /** `/a/b/0` as its unescaped segments. */
37
+ export declare function pointerSegments(path: string): string[];
38
+ /** A JSON pointer from segments. */
39
+ export declare function pointer(...segments: Array<string | number>): string;
40
+ /**
41
+ * The dashboard with the edits applied: substitutions first, then
42
+ * replacements and removals (all by pointers into the original), then the
43
+ * prepended variables.
44
+ */
45
+ export declare function applyEdits(dashboard: Json, edits: readonly ImportEdit[]): Json;
46
+ export {};
47
+ //# sourceMappingURL=edits.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"edits.d.ts","sourceRoot":"","sources":["../../src/import/edits.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH,KAAK,IAAI,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAEpC,MAAM,MAAM,UAAU;AACpB,2DAA2D;AACzD;IAAE,QAAQ,CAAC,EAAE,EAAE,QAAQ,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE;AAClD,iDAAiD;GAC/C;IAAE,QAAQ,CAAC,EAAE,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAA;CAAE;AAC5E,oGAAoG;GAClG;IAAE,QAAQ,CAAC,EAAE,EAAE,YAAY,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;CAAE;AAC3E,mGAAmG;GACjG;IAAE,QAAQ,CAAC,EAAE,EAAE,iBAAiB,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAA;CAAE,CAAC;AAE7D,0CAA0C;AAC1C,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAMtD;AAED,oCAAoC;AACpC,wBAAgB,OAAO,CAAC,GAAG,QAAQ,EAAE,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,GAAG,MAAM,CAEnE;AA+BD;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,UAAU,EAAE,GAAG,IAAI,CAoB9E"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Dashboard JSON embedded in another lexicon's resource, for `chant import`
3
+ * (#2962): a k8s ConfigMap holding a dashboard, as the Grafana dashboard
4
+ * sidecar (the `grafana_dashboard` label) and file provisioning both mount
5
+ * them. Matching is by content, so a dashboard in an unlabelled ConfigMap
6
+ * is imported too.
7
+ *
8
+ * The dashboard is imported exactly as `chant import dashboard.json` would
9
+ * import it, into a directory of its own, and the host's value becomes
10
+ * `dashboardJson(dashboard)`, the JSON text the grafana serializer writes.
11
+ */
12
+ import type { EmbeddedContentImporter } from "@intentius/chant/import/embedded";
13
+ export declare const dashboardImporter: EmbeddedContentImporter;
14
+ //# sourceMappingURL=embedded.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"embedded.d.ts","sourceRoot":"","sources":["../../src/import/embedded.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,uBAAuB,EAAkB,MAAM,kCAAkC,CAAC;AAOhG,eAAO,MAAM,iBAAiB,EAAE,uBA2B/B,CAAC"}
@@ -0,0 +1,60 @@
1
+ /**
2
+ * `TemplateIR` -> TypeScript, for `chant import`.
3
+ *
4
+ * The parser has already decided what every declaration is (./model.ts);
5
+ * this module decides only how the plan is written, the way the lexicon's
6
+ * examples are written:
7
+ *
8
+ * - one constant per declaration, named from its title (`CPU Busy` becomes
9
+ * `cpuBusy`; a panel's queries take its name and their refId, `cpuBusyA`);
10
+ * - a nested value lifted into a named const typed by the class's props
11
+ * (`const cpuBusyOptions: PropsOf<typeof GaugePanel>["options"] = …`),
12
+ * which is what COR001 asks;
13
+ * - at most eight declarables per module (COR009): a module group with
14
+ * more is split into `<file>-1.ts`, `<file>-2.ts`, …, keeping a panel with
15
+ * its queries;
16
+ * - an `export { … }` list at the end of each module (COR004), naming what
17
+ * another module imports, and the dashboard;
18
+ * - classes the plan declares (`definePanel`, `defineQuery`) in their own
19
+ * module, imported where they are used.
20
+ *
21
+ * A dashboard's modules go in a directory of their own (`plan.directory`),
22
+ * so importing a second dashboard into the same project does not collide
23
+ * with the first.
24
+ *
25
+ * Extension points:
26
+ *
27
+ * - `generatePlan(plan)` is the entry point for anything that builds a
28
+ * plan without the parser (live export, #2946).
29
+ * - `DECLARABLES_PER_FILE` is COR009's limit.
30
+ * - Everything Grafana-specific lives in the parser's tables
31
+ * (./mappings.ts); a new class needs no change here.
32
+ */
33
+ import type { GeneratedFile, TypeScriptGenerator } from "@intentius/chant/import/generator";
34
+ import type { TemplateIR } from "@intentius/chant/import/parser";
35
+ import { type Plan } from "./model.js";
36
+ /** COR009's default: at most this many declarables per file. */
37
+ export declare const DECLARABLES_PER_FILE = 8;
38
+ /** A value as a TypeScript expression, starting at column `col`, indented by `indent` spaces. */
39
+ export declare function tsLiteral(v: unknown, indent: number, col?: number): string;
40
+ /** The TypeScript for one plan: its modules, in the order they should be read. */
41
+ export declare function generatePlan(plan: Plan): GeneratedFile[];
42
+ /**
43
+ * The TypeScript for one plan, and where each declaration the plan exports
44
+ * is declared: its module's path and variable (#2962: a ConfigMap holding
45
+ * the dashboard refers to it).
46
+ */
47
+ export declare function generatePlanModules(plan: Plan): {
48
+ files: GeneratedFile[];
49
+ exported: Map<string, {
50
+ path: string;
51
+ name: string;
52
+ }>;
53
+ };
54
+ /** The Grafana TypeScript generator `chant import` runs. */
55
+ export declare class GrafanaGenerator implements TypeScriptGenerator {
56
+ /** Core writes exactly the files returned: a dashboard's modules refer to each other and live in its own directory. */
57
+ readonly ownsLayout = true;
58
+ generate(ir: TemplateIR): GeneratedFile[];
59
+ }
60
+ //# sourceMappingURL=generator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../../src/import/generator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AAC5F,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAA8D,KAAK,IAAI,EAAE,MAAM,SAAS,CAAC;AAKhG,gEAAgE;AAChE,eAAO,MAAM,oBAAoB,IAAI,CAAC;AA6FtC,iGAAiG;AACjG,wBAAgB,SAAS,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,SAAS,GAAG,MAAM,CAwB1E;AAoKD,kFAAkF;AAClF,wBAAgB,YAAY,CAAC,IAAI,EAAE,IAAI,GAAG,aAAa,EAAE,CAExD;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,IAAI,GAAG;IAC/C,KAAK,EAAE,aAAa,EAAE,CAAC;IACvB,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACvD,CA4GA;AAED,4DAA4D;AAC5D,qBAAa,gBAAiB,YAAW,mBAAmB;IAC1D,uHAAuH;IACvH,QAAQ,CAAC,UAAU,QAAQ;IAE3B,QAAQ,CAAC,EAAE,EAAE,UAAU,GAAG,aAAa,EAAE;CAU1C"}
@@ -0,0 +1,108 @@
1
+ /**
2
+ * Live Grafana objects -> chant's vocabulary, pure (#2946).
3
+ *
4
+ * Two consumers, one mapping:
5
+ *
6
+ * - live export (`../export-resources.ts`) turns dashboards and
7
+ * datasources read over the API into `TemplateIR` that feeds
8
+ * `templateGenerator()` unchanged;
9
+ * - deep observation (`../deep-observe.ts`) turns one live dashboard into
10
+ * the property tree core diffs against the declaration.
11
+ *
12
+ * Both go through the importer (`./parser.ts`), so a dashboard read from
13
+ * Grafana and a dashboard file given to `chant import` become the same
14
+ * declarations. The importer is not changed here; this module only reads
15
+ * the plan it makes.
16
+ *
17
+ * ## Why the drift tree is in chant's vocabulary, not Grafana's
18
+ *
19
+ * Core diffs a declaration's `props` (with property-kind declarables, which
20
+ * panels, rows, queries and variables are, inlined as their own props)
21
+ * against the tree a reader returns. A `Dashboard`'s props are what the
22
+ * author wrote: `graphTooltip: "sharedCrosshair"`, `panels: [Row, ...]`, a
23
+ * query with no `refId`. The JSON Grafana stores is what the build wrote
24
+ * from them: `graphTooltip: 1`, a flat panel list, `refId: "A"`. So the
25
+ * live side has to be put into the author's vocabulary, and the importer
26
+ * is exactly that translation, already tested to round-trip. Reading the
27
+ * plan back as one tree (every reference replaced by what it refers to)
28
+ * gives the live counterpart of the declared tree.
29
+ *
30
+ * What the translation cannot decide on its own (a panel `id` the build
31
+ * numbered, a `gridPos` it laid out, the built-in annotation Grafana adds)
32
+ * is noise, and noise is named in `../deep-observe-hooks.ts`, which core
33
+ * applies to both trees.
34
+ */
35
+ import type { TemplateIR } from "@intentius/chant/import/parser";
36
+ import { type Plan } from "./model.js";
37
+ type Json = Record<string, unknown>;
38
+ /**
39
+ * The dashboard declaration of a plan as one property tree: each reference
40
+ * replaced by the props (or, for a `DatasourceRef` const, the value) of the
41
+ * declaration it names, the way core inlines a property-kind declarable.
42
+ */
43
+ export declare function planTree(plan: Plan): Json;
44
+ /** One live dashboard (classic JSON) as the property tree core diffs a `Dashboard` declaration against. */
45
+ export declare function dashboardTree(dashboard: Json): {
46
+ tree: Json;
47
+ warnings: string[];
48
+ };
49
+ /** The keys a datasource's props take (`DatasourceProps`), in the order they are written. */
50
+ export declare const DATASOURCE_PROP_KEYS: readonly string[];
51
+ /**
52
+ * Grafana's value for a datasource key the API always returns, where it
53
+ * means "not set". Export leaves these out so the generated source says what
54
+ * somebody chose, as a provisioning file would.
55
+ */
56
+ export declare const DATASOURCE_API_DEFAULTS: Readonly<Json>;
57
+ /**
58
+ * One datasource from `GET /api/datasources[/uid/<uid>]` in `DatasourceProps`
59
+ * vocabulary.
60
+ *
61
+ * - `readOnly` (the API's word) becomes `editable` (the provisioning file's).
62
+ * - `secureJsonFields` names which secrets are set and never their values;
63
+ * they become `secureJsonData` keys whose value is `[REDACTED]`, so the
64
+ * key set compares and nothing secret is ever held.
65
+ * - `id`, `orgId`, `version`, `typeName`, `typeLogoUrl`, `apiVersion` and the
66
+ * rest are the server's own and are left out.
67
+ *
68
+ * `keepDefaults` keeps keys at the API's "not set" value (`--verbatim`).
69
+ */
70
+ export declare function datasourceProps(live: Json, options?: {
71
+ keepDefaults?: boolean;
72
+ }): Json;
73
+ /**
74
+ * A dashboard plan whose `ExternalDatasource`s for the given uids are
75
+ * written as plain `{ type, uid }` refs instead.
76
+ *
77
+ * The importer declares an `ExternalDatasource` for each datasource a
78
+ * dashboard names, because a dashboard file alone does not say where its
79
+ * datasources come from. A live export does know, when it exports the
80
+ * datasources too: they become `Datasource` declarations, and an
81
+ * `ExternalDatasource` with the same uid beside them fails the build (two
82
+ * datasources, one uid). A plain ref is what the importer itself writes when
83
+ * it cannot declare an external one (`settleExternals`), and GRAF101 still
84
+ * checks it against the declared `Datasource`.
85
+ */
86
+ export declare function referDeclaredDatasources(plan: Plan, uids: ReadonlySet<string>): Plan;
87
+ /**
88
+ * Live dashboards and datasources as import IR, for `chant import --from`.
89
+ *
90
+ * Each dashboard is planned by the importer exactly as a dashboard file
91
+ * would be, so the generated TypeScript is what `chant import` writes for
92
+ * the same JSON, except that a datasource exported alongside it is referred
93
+ * to by `{ type, uid }` (see `referDeclaredDatasources`). The datasources are
94
+ * planned as one provisioning file, with
95
+ * the secrets Grafana holds written as `[REDACTED]`: the generated source
96
+ * shows which secrets are set and must be filled in by hand (as
97
+ * `$__env{NAME}` references, which GRAF002 asks for).
98
+ */
99
+ export declare function exportTemplate(input: {
100
+ dashboards: Array<{
101
+ json: Json;
102
+ warnings?: string[];
103
+ }>;
104
+ datasources: Json[];
105
+ keepDefaults?: boolean;
106
+ }): TemplateIR;
107
+ export {};
108
+ //# sourceMappingURL=live-export.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"live-export.d.ts","sourceRoot":"","sources":["../../src/import/live-export.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH,OAAO,KAAK,EAAc,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAC7E,OAAO,EAA+B,KAAK,IAAI,EAAE,MAAM,SAAS,CAAC;AAUjE,KAAK,IAAI,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAMpC;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,CAuBzC;AAED,2GAA2G;AAC3G,wBAAgB,aAAa,CAAC,SAAS,EAAE,IAAI,GAAG;IAAE,IAAI,EAAE,IAAI,CAAC;IAAC,QAAQ,EAAE,MAAM,EAAE,CAAA;CAAE,CAGjF;AAED,6FAA6F;AAC7F,eAAO,MAAM,oBAAoB,EAAE,SAAS,MAAM,EAiBjD,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,uBAAuB,EAAE,QAAQ,CAAC,IAAI,CASlD,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,GAAE;IAAE,YAAY,CAAC,EAAE,OAAO,CAAA;CAAO,GAAG,IAAI,CAgB1F;AAQD;;;;;;;;;;;;GAYG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,IAAI,CAmBpF;AAQD;;;;;;;;;;;GAWG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE;IACpC,UAAU,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,IAAI,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC,CAAC;IACvD,WAAW,EAAE,IAAI,EAAE,CAAC;IACpB,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB,GAAG,UAAU,CA8Cb"}
@@ -0,0 +1,83 @@
1
+ /**
2
+ * What each piece of classic dashboard JSON becomes: the tables the
3
+ * importer's parser reads. They are the extension points for the issues
4
+ * that teach the importer more of Grafana.
5
+ *
6
+ * - Panel types (#2950): a built-in panel class is found in the panel
7
+ * registry (`registeredPanels()`), so a class added with `builtin: true`
8
+ * in `panels.ts` is used by the importer with no change here. Any other
9
+ * type is declared in the imported source with `definePanel`.
10
+ * - Query types (#2951): the same, through `registeredQueries()`, keyed by
11
+ * datasource plugin type; any other type gets a `defineQuery`.
12
+ * - Variable types (#2952): `VARIABLE_MAPPINGS` has one entry per type the
13
+ * lexicon has a class for. A type with no entry (adhoc, groupby, switch)
14
+ * is reported and left out. Add an entry when the class lands.
15
+ * - Dashboard and panel fields (#2953 annotations, and any new prop):
16
+ * `DASHBOARD_FIELDS`, `PANEL_FIELDS` and `ROW_FIELDS` list the JSON keys
17
+ * copied onto a prop as they are. A key in none of the tables, and not
18
+ * handled by the parser, is reported and left out, unless it is at the
19
+ * value Grafana assumes when it is missing (see `./normalize.ts`).
20
+ */
21
+ import { type PanelDefinition } from "../panels.js";
22
+ import { type QueryDefinition } from "../query.js";
23
+ import type { VariableHide } from "../variables.js";
24
+ import { splitValues } from "./normalize.js";
25
+ type Json = Record<string, unknown>;
26
+ /** Dashboard JSON keys carried onto the `Dashboard` prop of the same name, as they are. */
27
+ export declare const DASHBOARD_FIELDS: readonly string[];
28
+ /** Panel JSON keys carried onto the panel prop of the same name, as they are. */
29
+ export declare const PANEL_FIELDS: readonly string[];
30
+ /**
31
+ * Row JSON keys carried onto the `Row` prop of the same name. A row's
32
+ * `gridPos` is not among them: only its `y` is carried (Grafana draws a row
33
+ * header full width and one line high), so the row stays on its line even
34
+ * where the build would place it elsewhere, such as below an empty band.
35
+ */
36
+ export declare const ROW_FIELDS: readonly string[];
37
+ /** `graphTooltip` as Grafana stores it, and as `Dashboard` takes it. */
38
+ export declare const GRAPH_TOOLTIP: Readonly<Record<number, "default" | "sharedCrosshair" | "sharedTooltip">>;
39
+ /** A variable's `hide` as Grafana stores it, and as the variable classes take it. */
40
+ export declare const VARIABLE_HIDE: Readonly<Record<number, VariableHide>>;
41
+ /** A query variable's `refresh` as Grafana stores it, and as `QueryVariable` takes it. */
42
+ export declare const QUERY_REFRESH: Readonly<Record<number, "never" | "onLoad" | "onTimeRangeChange">>;
43
+ /** The class a panel of this plugin type is declared with, when chant ships one. */
44
+ export declare function builtinPanelFor(type: string): PanelDefinition | undefined;
45
+ /** The class a query to a datasource of this plugin type is declared with, when chant ships one. */
46
+ export declare function builtinQueryFor(datasourceType: string): QueryDefinition | undefined;
47
+ /**
48
+ * The datasource type a query with no datasource of its own, on a panel
49
+ * with none, is declared under. Grafana sends it to the default datasource;
50
+ * the class exists only to hold the query model.
51
+ */
52
+ export declare const DEFAULT_DATASOURCE_TYPE = "default";
53
+ /** What converting one variable needs from the rest of the import. */
54
+ export interface VariableContext {
55
+ /** The variable's JSON. */
56
+ readonly json: Json;
57
+ /** Its JSON pointer, for edits. */
58
+ readonly path: string;
59
+ /** Resolve a `datasource` value to a prop value, reporting what cannot be resolved. */
60
+ datasource(value: unknown, path: string): unknown;
61
+ /** Report a key that is not carried; `why` is the end of the sentence, after "not carried". */
62
+ drop(key: string, why?: string): void;
63
+ /** Report the whole variable as not carried. */
64
+ dropVariable(why: string): void;
65
+ /** Record that `key` is written differently but means the same, or with the given warning. */
66
+ replace(key: string, value: unknown, why?: string): void;
67
+ }
68
+ /** One variable type the lexicon has a class for: which class, and how its JSON becomes props. */
69
+ export interface VariableMapping {
70
+ readonly className: string;
71
+ /** JSON keys the mapping reads, whether it carries them or derives them. Any other key is reported. */
72
+ readonly keys: readonly string[];
73
+ /** The type-specific props, or undefined when the variable cannot be carried (after `ctx.dropVariable`). */
74
+ convert(ctx: VariableContext): Json | undefined;
75
+ }
76
+ /** Split a custom or interval variable's `query` the way Grafana does: on commas not escaped as `\\,`, trimmed. */
77
+ export declare const valuesOf: typeof splitValues;
78
+ /** Per Grafana variable type, the class and props it becomes. */
79
+ export declare const VARIABLE_MAPPINGS: Readonly<Record<string, VariableMapping>>;
80
+ /** Keys every variable type reads: the ones `CommonVariableProps` has, and `type`. */
81
+ export declare const COMMON_VARIABLE_KEYS: readonly string[];
82
+ export {};
83
+ //# sourceMappingURL=mappings.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mappings.d.ts","sourceRoot":"","sources":["../../src/import/mappings.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAoB,KAAK,eAAe,EAAE,MAAM,WAAW,CAAC;AACnE,OAAO,EAAqB,KAAK,eAAe,EAAE,MAAM,UAAU,CAAC;AACnE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,KAAK,IAAI,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAEpC,2FAA2F;AAC3F,eAAO,MAAM,gBAAgB,EAAE,SAAS,MAAM,EAc7C,CAAC;AAEF,iFAAiF;AACjF,eAAO,MAAM,YAAY,EAAE,SAAS,MAAM,EAkBzC,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,UAAU,EAAE,SAAS,MAAM,EAAiC,CAAC;AAE1E,wEAAwE;AACxE,eAAO,MAAM,aAAa,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,GAAG,iBAAiB,GAAG,eAAe,CAAC,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AE,eAAe,GAAG,IAAI,GAAG,SAAS,CAAC;CACjD;AAaD,mHAAmH;AACnH,eAAO,MAAM,QAAQ,oBAAc,CAAC;AAgBpC,iEAAiE;AACjE,eAAO,MAAM,iBAAiB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAkGvE,CAAC;AAEF,sFAAsF;AACtF,eAAO,MAAM,oBAAoB,EAAE,SAAS,MAAM,EAAoE,CAAC"}
@@ -0,0 +1,98 @@
1
+ /**
2
+ * The plan `chant import` hands from the parser to the generator: the
3
+ * declarations one dashboard becomes, with the references between them.
4
+ *
5
+ * The parser decides what each piece of dashboard JSON becomes (which
6
+ * class, which props, what cannot be carried) using the tables in
7
+ * `./mappings.ts`. The generator decides only how the plan is written:
8
+ * names, modules, imports, lifted consts. It knows nothing about Grafana,
9
+ * so live export (#2946) can build a plan from a dashboard read over the
10
+ * API and write it with the same generator.
11
+ */
12
+ /** A value in a declaration's props that refers to another declaration, written as that declaration's variable. */
13
+ export interface DeclRef {
14
+ readonly $decl: string;
15
+ }
16
+ export declare function declRef(id: string): DeclRef;
17
+ export declare function isDeclRef(v: unknown): v is DeclRef;
18
+ /**
19
+ * A value written as a call to a function the package exports, e.g.
20
+ * `customTransformation("sortBy", { ... })` for a transformation the typed
21
+ * form can't hold. The arguments are values like any other.
22
+ */
23
+ export interface CallValue {
24
+ readonly $call: string;
25
+ readonly args: readonly unknown[];
26
+ }
27
+ export declare function callValue(fn: string, args: readonly unknown[]): CallValue;
28
+ export declare function isCallValue(v: unknown): v is CallValue;
29
+ /** Where a declaration's variable name comes from: a text to camelCase, or another declaration's name plus a suffix. */
30
+ export type NameHint = string | {
31
+ readonly of: string;
32
+ readonly suffix: string;
33
+ };
34
+ /**
35
+ * One declaration.
36
+ *
37
+ * - `new`: `const name = new ClassName(props);`, a declarable.
38
+ * - `value`: `const name: type = value;`, a plain value other declarations
39
+ * refer to (a `DatasourceRef`).
40
+ */
41
+ export interface Declaration {
42
+ /** Unique in the plan, e.g. `panel:4`, `query:4:A`, `variable:job`, `datasource:prometheus:prom`, `dashboard`. */
43
+ readonly id: string;
44
+ readonly kind: "new" | "value";
45
+ /** For `new`: the class. A package export unless `customClass` says the import declares it. */
46
+ readonly className?: string;
47
+ /** For `new`: the id of the `CustomClass` declaring `className`, when it is not a package export. */
48
+ readonly customClass?: string;
49
+ /** For `new`: the constructor's props, in source order. */
50
+ readonly props?: Record<string, unknown>;
51
+ /** For `value`: the value, and its type annotation with the package types it names. */
52
+ readonly value?: unknown;
53
+ readonly type?: {
54
+ readonly text: string;
55
+ readonly imports: readonly string[];
56
+ };
57
+ readonly name: NameHint;
58
+ /** The module group it is written to (see `Plan.modules`). */
59
+ readonly module: string;
60
+ /**
61
+ * Declarations with the same unit stay in the same file when a module is
62
+ * split (a panel and its queries). Defaults to the id.
63
+ */
64
+ readonly unit?: string;
65
+ /** Comment lines written above it. */
66
+ readonly comment?: readonly string[];
67
+ }
68
+ /** A panel or query class the import declares, for a plugin chant has no class for. */
69
+ export interface CustomClass {
70
+ /** e.g. `panel-class:grafana-clock-panel`, `query-class:elasticsearch`. */
71
+ readonly id: string;
72
+ readonly className: string;
73
+ /** `definePanel` or `defineQuery`. */
74
+ readonly factory: "definePanel" | "defineQuery";
75
+ /** The definition object passed to the factory. */
76
+ readonly definition: Record<string, unknown>;
77
+ readonly comment: readonly string[];
78
+ }
79
+ /** One module group: a base file name and the doc comment at its top. */
80
+ export interface ModuleSpec {
81
+ readonly key: string;
82
+ /** File name without `.ts`; `-1`, `-2`, ... is added when the group is split. */
83
+ readonly file: string;
84
+ readonly summary: string;
85
+ }
86
+ /** Everything one dashboard becomes. */
87
+ export interface Plan {
88
+ /** The directory its modules are written to, relative to the output directory. `""` for none. */
89
+ readonly directory: string;
90
+ /** Modules in the order they are written. */
91
+ readonly modules: readonly ModuleSpec[];
92
+ /** Declarations in dependency order: a declaration only refers to ones before it. */
93
+ readonly declarations: readonly Declaration[];
94
+ readonly customClasses: readonly CustomClass[];
95
+ /** Declarations exported even when no other module imports them (the dashboard). */
96
+ readonly exports: readonly string[];
97
+ }
98
+ //# sourceMappingURL=model.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../src/import/model.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,mHAAmH;AACnH,MAAM,WAAW,OAAO;IACtB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB;AAED,wBAAgB,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAE3C;AAED,wBAAgB,SAAS,CAAC,CAAC,EAAE,OAAO,GAAG,CAAC,IAAI,OAAO,CAElD;AAED;;;;GAIG;AACH,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,SAAS,OAAO,EAAE,CAAC;CACnC;AAED,wBAAgB,SAAS,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,OAAO,EAAE,GAAG,SAAS,CAEzE;AAED,wBAAgB,WAAW,CAAC,CAAC,EAAE,OAAO,GAAG,CAAC,IAAI,SAAS,CAEtD;AAED,wHAAwH;AACxH,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG;IAAE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAEjF;;;;;;GAMG;AACH,MAAM,WAAW,WAAW;IAC1B,kHAAkH;IAClH,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,IAAI,EAAE,KAAK,GAAG,OAAO,CAAC;IAC/B,+FAA+F;IAC/F,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,qGAAqG;IACrG,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,2DAA2D;IAC3D,QAAQ,CAAC,KAAK,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;IACxC,qFAAqF;IACrF,QAAQ,CAAC,YAAY,EAAE,SAAS,WAAW,EAAE,CAAC;IAC9C,QAAQ,CAAC,aAAa,EAAE,SAAS,WAAW,EAAE,CAAC;IAC/C,oFAAoF;IACpF,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;CACrC"}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * An alerting provisioning file in a canonical form, so two files Grafana
3
+ * provisions the same way compare equal. The round-trip tests compare the
4
+ * source (with the importer's edits applied) and the rebuilt file through
5
+ * this.
6
+ *
7
+ * What it treats as equal, each from Grafana's file reader
8
+ * (`pkg/services/provisioning/alerting/*_types.go`, v12.4.11 and v13.2.2):
9
+ *
10
+ * - `orgId: 1` and no `orgId` (a value below 1 reads as 1);
11
+ * - a rule's `noDataState: NoData`, `execErrState: Alerting`, `for: 0s`,
12
+ * `keepFiringFor: 0s`, `isPaused: false`, `panelId: 0`, empty `labels`
13
+ * and `annotations`, and the same left out;
14
+ * - a query's `queryType: ""`, and a `relativeTimeRange` of 0 to 0, and
15
+ * the same left out;
16
+ * - an expression model's `datasource` of `__expr__` and a `refId` equal
17
+ * to the query's, and the same left out (Grafana sets both);
18
+ * - `disableResolveMessage: false` and none;
19
+ * - the order of rule groups, contact points, mute timings and templates,
20
+ * which chant writes sorted.
21
+ */
22
+ type Json = Record<string, unknown>;
23
+ /** The file in canonical form. */
24
+ export declare function normalizeAlerting(file: Json): Json;
25
+ export {};
26
+ //# sourceMappingURL=normalize-alerting.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalize-alerting.d.ts","sourceRoot":"","sources":["../../src/import/normalize-alerting.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAKH,KAAK,IAAI,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AA4CpC,kCAAkC;AAClC,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,CA8BlD"}
@@ -0,0 +1,74 @@
1
+ /**
2
+ * Classic dashboard JSON in a canonical form, so two dashboards Grafana
3
+ * treats the same compare equal.
4
+ *
5
+ * Grafana fills in a default for most keys a dashboard leaves out, derives
6
+ * some keys from others (a custom variable's `options` from its `query`),
7
+ * and resolves a query without a datasource to its panel's. A dashboard it
8
+ * exported and the same dashboard rebuilt by chant differ in exactly those
9
+ * ways, so both are put through `normalizeDashboard` before they are
10
+ * compared: keys at their default are removed, derived keys are removed,
11
+ * and references are written one way.
12
+ *
13
+ * The import round trip compares with it, the importer asks `isDefault`
14
+ * whether a key it cannot carry is worth a warning (a key at its default is
15
+ * not), and drift detection (#2946) can compare a stored dashboard with a
16
+ * built one the same way.
17
+ *
18
+ * Only the dashboard, panel, row, target, variable and link levels are
19
+ * touched. Nothing inside `options`, `fieldConfig`, `transformations` or a
20
+ * query model is: a `null` in there (a threshold step's base value) means
21
+ * something.
22
+ */
23
+ type Json = Record<string, unknown>;
24
+ /** Grafana's value for a dashboard key the JSON leaves out. */
25
+ export declare const DASHBOARD_DEFAULTS: Readonly<Json>;
26
+ /** Grafana's value for a panel key the JSON leaves out. */
27
+ export declare const PANEL_DEFAULTS: Readonly<Json>;
28
+ /** Grafana's value for a row key the JSON leaves out. */
29
+ export declare const ROW_DEFAULTS: Readonly<Json>;
30
+ /** Grafana's value for a variable key the JSON leaves out, whatever the variable's type. */
31
+ export declare const VARIABLE_DEFAULTS: Readonly<Json>;
32
+ /** Per variable type, Grafana's value for a key the JSON leaves out, over `VARIABLE_DEFAULTS`. */
33
+ export declare const VARIABLE_TYPE_DEFAULTS: Readonly<Record<string, Json>>;
34
+ /** The defaults chant writes into a dashboard or panel link, which Grafana reads as unset. */
35
+ export declare const LINK_DEFAULTS: Readonly<Json>;
36
+ /** The annotation Grafana adds to every dashboard that has none: annotations and alerts from its own database. */
37
+ export declare const BUILTIN_ANNOTATION: Readonly<Json>;
38
+ /** Keys of a stored dashboard that belong to that copy (its database id, save counter), not to the dashboard. */
39
+ export declare const BOOKKEEPING_KEYS: readonly string[];
40
+ /** The panel datasource Grafana writes when a panel's queries go to different datasources. */
41
+ export declare const MIXED_UID = "-- Mixed --";
42
+ export declare function isObject(v: unknown): v is Json;
43
+ export declare function deepEqual(a: unknown, b: unknown): boolean;
44
+ /** True when `value` is what Grafana assumes for `key` when it is left out (a `null` counts as left out). */
45
+ export declare function isDefault(defaults: Readonly<Json>, key: string, value: unknown): boolean;
46
+ /** Defaults for one variable type. */
47
+ export declare function variableDefaults(type: unknown): Json;
48
+ /** The refId Grafana (and chant) gives the query at `index` when it has none: A, B, … Z, AA, AB, … */
49
+ export declare function refIdAt(i: number): string;
50
+ /** `$name` and `[[name]]` written as `${name}`, the form a datasource variable's reference takes. */
51
+ export declare function canonicalVariableUid(uid: string): string;
52
+ /** A custom or interval variable's `query` as the list of values Grafana splits it into. */
53
+ export declare function splitValues(query: string): string[];
54
+ /**
55
+ * Per datasource type, a query key's value when the target leaves it out.
56
+ * A Tempo query without `filters` has no search filters, which `TempoQuery`
57
+ * writes as `filters: []`.
58
+ */
59
+ export declare const TARGET_DEFAULTS: Readonly<Record<string, Readonly<Json>>>;
60
+ /**
61
+ * True for the annotation Grafana adds to every dashboard (annotations and
62
+ * alerts from its own database), in any of the forms Grafana versions have
63
+ * written it: a dashboard with it and one without are the same dashboard.
64
+ */
65
+ export declare function isBuiltinAnnotation(a: unknown): boolean;
66
+ /**
67
+ * The dashboard in canonical form: bookkeeping keys and keys at their
68
+ * default removed, derived keys removed, every query with its datasource and
69
+ * refId, every panel with the datasource its queries share. Returns a copy;
70
+ * key order is not canonicalised (compare with `deepEqual` or `toEqual`).
71
+ */
72
+ export declare function normalizeDashboard(dashboard: Json): Json;
73
+ export {};
74
+ //# sourceMappingURL=normalize.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalize.d.ts","sourceRoot":"","sources":["../../src/import/normalize.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAIH,K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