@perses-dev/prometheus-plugin 0.56.0 → 0.57.0-rc.1

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 (316) hide show
  1. package/__mf/js/Prometheus.3cac2d10.js +6 -0
  2. package/__mf/js/async/1233.0ab88b51.js +1 -0
  3. package/__mf/js/async/1324.ce01eced.js +1 -0
  4. package/__mf/js/async/1432.0c3e4ed0.js +1 -0
  5. package/__mf/js/async/1605.dc180cb8.js +110 -0
  6. package/__mf/js/async/1616.7587ce79.js +1 -0
  7. package/__mf/js/async/1728.46efbfb8.js +1 -0
  8. package/__mf/js/async/1969.372d36b8.js +1 -0
  9. package/__mf/js/async/2043.d0fbb886.js +2 -0
  10. package/__mf/js/async/2186.e58838a5.js +38 -0
  11. package/__mf/js/async/2506.1e336b3b.js +1 -0
  12. package/__mf/js/async/3184.6b4ad42e.js +1 -0
  13. package/__mf/js/async/3499.bef2e2e5.js +1 -0
  14. package/__mf/js/async/3652.fc1e5f95.js +7 -0
  15. package/__mf/js/async/392.7cda691a.js +2 -0
  16. package/__mf/js/async/3963.5fef6ffb.js +1 -0
  17. package/__mf/js/async/3996.69a9c1dc.js +1 -0
  18. package/__mf/js/async/{1964.1d168a86.js → 4121.828d661d.js} +2 -2
  19. package/__mf/js/async/425.1ec8867f.js +1 -0
  20. package/__mf/js/async/4626.173e602a.js +1 -0
  21. package/__mf/js/async/4657.e3d53a21.js +2 -0
  22. package/__mf/js/async/4987.c12b89cb.js +1 -0
  23. package/__mf/js/async/{8930.700a5439.js → 5002.e4f54e8e.js} +1 -1
  24. package/__mf/js/async/5071.e1c33fa7.js +1 -0
  25. package/__mf/js/async/529.2303b01b.js +1 -0
  26. package/__mf/js/async/54.f6f480ef.js +22 -0
  27. package/__mf/js/async/5440.8ced5513.js +2 -0
  28. package/__mf/js/async/{6377.c40920f2.js.LICENSE.txt → 5440.8ced5513.js.LICENSE.txt} +3 -3
  29. package/__mf/js/async/{5214.0fca84ed.js → 5587.4d72fc35.js} +1 -1
  30. package/__mf/js/async/5763.4ba478ff.js +1 -0
  31. package/__mf/js/async/5922.d1619ac1.js +1 -0
  32. package/__mf/js/async/6274.478a68f8.js +2 -0
  33. package/__mf/js/async/6283.181cb622.js +2 -0
  34. package/__mf/js/async/6969.b959b6f8.js +1 -0
  35. package/__mf/js/async/{4062.06f48b93.js → 7177.205c9aaf.js} +1 -1
  36. package/__mf/js/async/7192.d835931b.js +1 -0
  37. package/__mf/js/async/7894.9c5245d7.js +1 -0
  38. package/__mf/js/async/7968.6ac0ce96.js +1 -0
  39. package/__mf/js/async/7978.9532d5b8.js +1 -0
  40. package/__mf/js/async/8356.789e1dfb.js +1 -0
  41. package/__mf/js/async/8470.9b14a625.js +2 -0
  42. package/__mf/js/async/873.448eab23.js +1 -0
  43. package/__mf/js/async/8888.59eb50a2.js +1 -0
  44. package/__mf/js/async/9010.15208552.js +2 -0
  45. package/__mf/js/async/9020.662dc353.js +1 -0
  46. package/__mf/js/async/9184.43a8d927.js +1 -0
  47. package/__mf/js/async/9235.36c3cd8c.js +1 -0
  48. package/__mf/js/async/9351.715f25c3.js +1 -0
  49. package/__mf/js/async/941.53b13124.js +2 -0
  50. package/__mf/js/async/9518.38e38a33.js +1 -0
  51. package/__mf/js/async/9588.9081c7de.js +1 -0
  52. package/__mf/js/async/9605.a92ec9c1.js +1 -0
  53. package/__mf/js/async/9836.00da6086.js +1 -0
  54. package/__mf/js/async/__federation_expose_PrometheusDatasource.caac7bfc.js +1 -0
  55. package/__mf/js/async/__federation_expose_PrometheusExplorer.22434cd0.js +1 -0
  56. package/__mf/js/async/__federation_expose_PrometheusLabelNamesVariable.087a9360.js +1 -0
  57. package/__mf/js/async/__federation_expose_PrometheusLabelValuesVariable.f9135d9a.js +1 -0
  58. package/__mf/js/async/__federation_expose_PrometheusPromQLVariable.d3f9f4b7.js +1 -0
  59. package/__mf/js/async/__federation_expose_PrometheusTimeSeriesQuery.95a9abcc.js +1 -0
  60. package/__mf/js/main.8eeb4292.js +6 -0
  61. package/lib/bootstrap.js +2 -2
  62. package/lib/bootstrap.js.map +1 -1
  63. package/lib/cjs/bootstrap.js +1 -1
  64. package/lib/cjs/components/PromQLEditor.js +5 -8
  65. package/lib/cjs/components/TreeNode.js +1 -1
  66. package/lib/cjs/components/index.js +1 -1
  67. package/lib/cjs/components/promql/ast.js +11 -11
  68. package/lib/cjs/components/promql/format.js +4 -4
  69. package/lib/cjs/components/promql/functionSignatures.js +1 -1
  70. package/lib/cjs/components/promql/serialize.js +1 -1
  71. package/lib/cjs/components/promql/utils.js +6 -6
  72. package/lib/cjs/components/query.js +4 -4
  73. package/lib/cjs/env.d.js +1 -1
  74. package/lib/cjs/explore/PrometheusExplorer.js +11 -7
  75. package/lib/cjs/explore/PrometheusMetricsFinder/PrometheusMetricsFinder.js +5 -5
  76. package/lib/cjs/explore/PrometheusMetricsFinder/display/MetricChip.js +1 -1
  77. package/lib/cjs/explore/PrometheusMetricsFinder/display/list/MetricList.js +4 -4
  78. package/lib/cjs/explore/PrometheusMetricsFinder/filter/FilterInputs.js +5 -5
  79. package/lib/cjs/explore/PrometheusMetricsFinder/filter/FinderFilters.js +1 -1
  80. package/lib/cjs/explore/PrometheusMetricsFinder/index.js +1 -1
  81. package/lib/cjs/explore/PrometheusMetricsFinder/overview/MetricOverview.js +4 -4
  82. package/lib/cjs/explore/PrometheusMetricsFinder/overview/tabs/JobTab.js +5 -5
  83. package/lib/cjs/explore/PrometheusMetricsFinder/overview/tabs/OverviewTab.js +5 -5
  84. package/lib/cjs/explore/PrometheusMetricsFinder/overview/tabs/SimilarTab.js +1 -1
  85. package/lib/cjs/explore/PrometheusMetricsFinder/types.js +1 -1
  86. package/lib/cjs/explore/PrometheusMetricsFinder/utils.js +6 -6
  87. package/lib/cjs/explore/index.js +12 -0
  88. package/lib/cjs/getPluginModule.js +12 -0
  89. package/lib/cjs/index-federation.js +12 -12
  90. package/lib/cjs/index.js +12 -0
  91. package/lib/cjs/model/api-types.js +1 -1
  92. package/lib/cjs/model/index.js +1 -1
  93. package/lib/cjs/model/parse-sample-values.js +4 -4
  94. package/lib/cjs/model/prometheus-client.js +30 -20
  95. package/lib/cjs/model/prometheus-selectors.js +6 -6
  96. package/lib/cjs/model/time.js +5 -5
  97. package/lib/cjs/plugins/MatcherEditor.js +1 -1
  98. package/lib/cjs/plugins/PrometheusDatasourceEditor.js +176 -3
  99. package/lib/cjs/plugins/PrometheusLabelNamesVariable.js +12 -0
  100. package/lib/cjs/plugins/PrometheusLabelValuesVariable.js +12 -0
  101. package/lib/cjs/plugins/PrometheusPromQLVariable.js +12 -0
  102. package/lib/cjs/plugins/index.js +12 -0
  103. package/lib/cjs/plugins/prometheus-datasource.js +18 -10
  104. package/lib/cjs/plugins/prometheus-time-series-query/PrometheusTimeSeriesQuery.js +1 -1
  105. package/lib/cjs/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.js +37 -2
  106. package/lib/cjs/plugins/prometheus-time-series-query/get-time-series-data.js +1 -1
  107. package/lib/cjs/plugins/prometheus-time-series-query/index.js +1 -1
  108. package/lib/cjs/plugins/prometheus-time-series-query/query-editor-model.js +5 -5
  109. package/lib/cjs/plugins/prometheus-time-series-query/replace-prom-builtin-variables.js +1 -1
  110. package/lib/cjs/plugins/prometheus-time-series-query/time-series-query-model.js +1 -1
  111. package/lib/cjs/plugins/prometheus-variables.js +53 -34
  112. package/lib/cjs/plugins/test/setup-tests.js +1 -1
  113. package/lib/cjs/plugins/types.js +1 -1
  114. package/lib/cjs/plugins/variable.js +1 -1
  115. package/lib/cjs/setup-tests.js +1 -1
  116. package/lib/cjs/utils/index.js +1 -1
  117. package/lib/cjs/utils/utils.js +5 -5
  118. package/lib/components/PromQLEditor.d.ts +5 -1
  119. package/lib/components/PromQLEditor.d.ts.map +1 -1
  120. package/lib/components/PromQLEditor.js +6 -9
  121. package/lib/components/PromQLEditor.js.map +1 -1
  122. package/lib/components/TreeNode.js +2 -2
  123. package/lib/components/TreeNode.js.map +1 -1
  124. package/lib/components/index.js +1 -1
  125. package/lib/components/index.js.map +1 -1
  126. package/lib/components/promql/ast.js +1 -1
  127. package/lib/components/promql/ast.js.map +1 -1
  128. package/lib/components/promql/format.js +2 -2
  129. package/lib/components/promql/format.js.map +1 -1
  130. package/lib/components/promql/functionSignatures.js +1 -1
  131. package/lib/components/promql/functionSignatures.js.map +1 -1
  132. package/lib/components/promql/serialize.js +1 -1
  133. package/lib/components/promql/serialize.js.map +1 -1
  134. package/lib/components/promql/utils.js +1 -1
  135. package/lib/components/promql/utils.js.map +1 -1
  136. package/lib/components/query.js +1 -1
  137. package/lib/components/query.js.map +1 -1
  138. package/lib/env.d.js +1 -1
  139. package/lib/env.d.js.map +1 -1
  140. package/lib/explore/PrometheusExplorer.d.ts.map +1 -1
  141. package/lib/explore/PrometheusExplorer.js +11 -7
  142. package/lib/explore/PrometheusExplorer.js.map +1 -1
  143. package/lib/explore/PrometheusMetricsFinder/PrometheusMetricsFinder.js +2 -2
  144. package/lib/explore/PrometheusMetricsFinder/PrometheusMetricsFinder.js.map +1 -1
  145. package/lib/explore/PrometheusMetricsFinder/display/MetricChip.js +2 -2
  146. package/lib/explore/PrometheusMetricsFinder/display/MetricChip.js.map +1 -1
  147. package/lib/explore/PrometheusMetricsFinder/display/list/MetricList.js +2 -2
  148. package/lib/explore/PrometheusMetricsFinder/display/list/MetricList.js.map +1 -1
  149. package/lib/explore/PrometheusMetricsFinder/filter/FilterInputs.js +2 -2
  150. package/lib/explore/PrometheusMetricsFinder/filter/FilterInputs.js.map +1 -1
  151. package/lib/explore/PrometheusMetricsFinder/filter/FinderFilters.js +2 -2
  152. package/lib/explore/PrometheusMetricsFinder/filter/FinderFilters.js.map +1 -1
  153. package/lib/explore/PrometheusMetricsFinder/index.js +1 -1
  154. package/lib/explore/PrometheusMetricsFinder/index.js.map +1 -1
  155. package/lib/explore/PrometheusMetricsFinder/overview/MetricOverview.js +2 -2
  156. package/lib/explore/PrometheusMetricsFinder/overview/MetricOverview.js.map +1 -1
  157. package/lib/explore/PrometheusMetricsFinder/overview/tabs/JobTab.js +1 -1
  158. package/lib/explore/PrometheusMetricsFinder/overview/tabs/JobTab.js.map +1 -1
  159. package/lib/explore/PrometheusMetricsFinder/overview/tabs/OverviewTab.js +1 -1
  160. package/lib/explore/PrometheusMetricsFinder/overview/tabs/OverviewTab.js.map +1 -1
  161. package/lib/explore/PrometheusMetricsFinder/overview/tabs/SimilarTab.js +1 -1
  162. package/lib/explore/PrometheusMetricsFinder/overview/tabs/SimilarTab.js.map +1 -1
  163. package/lib/explore/PrometheusMetricsFinder/types.js +1 -1
  164. package/lib/explore/PrometheusMetricsFinder/types.js.map +1 -1
  165. package/lib/explore/PrometheusMetricsFinder/utils.js +1 -1
  166. package/lib/explore/PrometheusMetricsFinder/utils.js.map +1 -1
  167. package/lib/explore/index.d.ts.map +1 -1
  168. package/lib/explore/index.js +12 -0
  169. package/lib/explore/index.js.map +1 -1
  170. package/lib/getPluginModule.d.ts.map +1 -1
  171. package/lib/getPluginModule.js +12 -0
  172. package/lib/getPluginModule.js.map +1 -1
  173. package/lib/index-federation.js +1 -1
  174. package/lib/index-federation.js.map +1 -1
  175. package/lib/index.d.ts.map +1 -1
  176. package/lib/index.js +12 -0
  177. package/lib/index.js.map +1 -1
  178. package/lib/model/api-types.js +1 -1
  179. package/lib/model/api-types.js.map +1 -1
  180. package/lib/model/index.js +1 -1
  181. package/lib/model/index.js.map +1 -1
  182. package/lib/model/parse-sample-values.js +1 -1
  183. package/lib/model/parse-sample-values.js.map +1 -1
  184. package/lib/model/prometheus-client.d.ts +1 -0
  185. package/lib/model/prometheus-client.d.ts.map +1 -1
  186. package/lib/model/prometheus-client.js +20 -10
  187. package/lib/model/prometheus-client.js.map +1 -1
  188. package/lib/model/prometheus-selectors.js +1 -1
  189. package/lib/model/prometheus-selectors.js.map +1 -1
  190. package/lib/model/time.js +1 -1
  191. package/lib/model/time.js.map +1 -1
  192. package/lib/plugins/MatcherEditor.js +2 -2
  193. package/lib/plugins/MatcherEditor.js.map +1 -1
  194. package/lib/plugins/PrometheusDatasourceEditor.d.ts.map +1 -1
  195. package/lib/plugins/PrometheusDatasourceEditor.js +136 -4
  196. package/lib/plugins/PrometheusDatasourceEditor.js.map +1 -1
  197. package/lib/plugins/PrometheusLabelNamesVariable.d.ts.map +1 -1
  198. package/lib/plugins/PrometheusLabelNamesVariable.js +12 -0
  199. package/lib/plugins/PrometheusLabelNamesVariable.js.map +1 -1
  200. package/lib/plugins/PrometheusLabelValuesVariable.d.ts.map +1 -1
  201. package/lib/plugins/PrometheusLabelValuesVariable.js +12 -0
  202. package/lib/plugins/PrometheusLabelValuesVariable.js.map +1 -1
  203. package/lib/plugins/PrometheusPromQLVariable.d.ts.map +1 -1
  204. package/lib/plugins/PrometheusPromQLVariable.js +12 -0
  205. package/lib/plugins/PrometheusPromQLVariable.js.map +1 -1
  206. package/lib/plugins/index.d.ts.map +1 -1
  207. package/lib/plugins/index.js +12 -0
  208. package/lib/plugins/index.js.map +1 -1
  209. package/lib/plugins/prometheus-datasource.js +18 -10
  210. package/lib/plugins/prometheus-datasource.js.map +1 -1
  211. package/lib/plugins/prometheus-time-series-query/PrometheusTimeSeriesQuery.js +1 -1
  212. package/lib/plugins/prometheus-time-series-query/PrometheusTimeSeriesQuery.js.map +1 -1
  213. package/lib/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.d.ts.map +1 -1
  214. package/lib/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.js +40 -5
  215. package/lib/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.js.map +1 -1
  216. package/lib/plugins/prometheus-time-series-query/get-time-series-data.d.ts.map +1 -1
  217. package/lib/plugins/prometheus-time-series-query/get-time-series-data.js +1 -1
  218. package/lib/plugins/prometheus-time-series-query/get-time-series-data.js.map +1 -1
  219. package/lib/plugins/prometheus-time-series-query/index.js +1 -1
  220. package/lib/plugins/prometheus-time-series-query/index.js.map +1 -1
  221. package/lib/plugins/prometheus-time-series-query/query-editor-model.js +1 -1
  222. package/lib/plugins/prometheus-time-series-query/query-editor-model.js.map +1 -1
  223. package/lib/plugins/prometheus-time-series-query/replace-prom-builtin-variables.js +1 -1
  224. package/lib/plugins/prometheus-time-series-query/replace-prom-builtin-variables.js.map +1 -1
  225. package/lib/plugins/prometheus-time-series-query/time-series-query-model.js +1 -1
  226. package/lib/plugins/prometheus-time-series-query/time-series-query-model.js.map +1 -1
  227. package/lib/plugins/prometheus-variables.d.ts.map +1 -1
  228. package/lib/plugins/prometheus-variables.js +48 -29
  229. package/lib/plugins/prometheus-variables.js.map +1 -1
  230. package/lib/plugins/test/setup-tests.js +1 -1
  231. package/lib/plugins/test/setup-tests.js.map +1 -1
  232. package/lib/plugins/types.d.ts +1 -0
  233. package/lib/plugins/types.d.ts.map +1 -1
  234. package/lib/plugins/types.js +1 -1
  235. package/lib/plugins/types.js.map +1 -1
  236. package/lib/plugins/variable.js +1 -1
  237. package/lib/plugins/variable.js.map +1 -1
  238. package/lib/setup-tests.js +1 -1
  239. package/lib/setup-tests.js.map +1 -1
  240. package/lib/utils/index.js +1 -1
  241. package/lib/utils/index.js.map +1 -1
  242. package/lib/utils/utils.js +1 -1
  243. package/lib/utils/utils.js.map +1 -1
  244. package/mf-manifest.json +270 -255
  245. package/mf-stats.json +276 -259
  246. package/package.json +7 -7
  247. package/__mf/js/Prometheus.4d0d5812.js +0 -5
  248. package/__mf/js/async/1339.194207db.js +0 -1
  249. package/__mf/js/async/1441.c735f7dd.js +0 -1
  250. package/__mf/js/async/1576.8eac7ce9.js +0 -1
  251. package/__mf/js/async/212.5fcca998.js +0 -1
  252. package/__mf/js/async/2292.57d8fd0d.js +0 -2
  253. package/__mf/js/async/3224.b63f87bf.js +0 -1
  254. package/__mf/js/async/3507.f1653337.js +0 -101
  255. package/__mf/js/async/3749.3ecd9372.js +0 -1
  256. package/__mf/js/async/3863.7192dfdf.js +0 -2
  257. package/__mf/js/async/3960.3eedafbd.js +0 -2
  258. package/__mf/js/async/3980.0b0d272c.js +0 -2
  259. package/__mf/js/async/4075.dab1b7b8.js +0 -1
  260. package/__mf/js/async/4238.c48b1950.js +0 -1
  261. package/__mf/js/async/4421.1fcb466e.js +0 -1
  262. package/__mf/js/async/4535.f24704ea.js +0 -1
  263. package/__mf/js/async/4557.f3eb9456.js +0 -2
  264. package/__mf/js/async/4576.f42daf99.js +0 -1
  265. package/__mf/js/async/4665.cad36935.js +0 -1
  266. package/__mf/js/async/4676.b7a22f90.js +0 -22
  267. package/__mf/js/async/5257.ce463cb7.js +0 -1
  268. package/__mf/js/async/5409.955ffd51.js +0 -1
  269. package/__mf/js/async/5614.cce8ba96.js +0 -1
  270. package/__mf/js/async/5724.794828e3.js +0 -1
  271. package/__mf/js/async/5774.a3fae698.js +0 -1
  272. package/__mf/js/async/5790.a9b31ca8.js +0 -1
  273. package/__mf/js/async/58.1c9a8daa.js +0 -2
  274. package/__mf/js/async/5981.eb502d27.js +0 -2
  275. package/__mf/js/async/6292.2afe0c6d.js +0 -1
  276. package/__mf/js/async/6341.20eccf91.js +0 -7
  277. package/__mf/js/async/6377.c40920f2.js +0 -2
  278. package/__mf/js/async/6770.7099bb3b.js +0 -1
  279. package/__mf/js/async/684.4495f632.js +0 -1
  280. package/__mf/js/async/694.8462a746.js +0 -1
  281. package/__mf/js/async/7272.6fa2f127.js +0 -1
  282. package/__mf/js/async/7376.2e948f2b.js +0 -1
  283. package/__mf/js/async/738.a1ffff79.js +0 -1
  284. package/__mf/js/async/7740.a8777825.js +0 -1
  285. package/__mf/js/async/8045.7f554a45.js +0 -10
  286. package/__mf/js/async/8164.bb3d3363.js +0 -1
  287. package/__mf/js/async/8216.e689c178.js +0 -1
  288. package/__mf/js/async/8488.cbbe542b.js +0 -1
  289. package/__mf/js/async/8587.40df6f5c.js +0 -1
  290. package/__mf/js/async/8706.89677575.js +0 -1
  291. package/__mf/js/async/9010.bdb2ef97.js +0 -1
  292. package/__mf/js/async/9173.915b80af.js +0 -2
  293. package/__mf/js/async/9550.642ce5ad.js +0 -38
  294. package/__mf/js/async/9817.70eae424.js +0 -1
  295. package/__mf/js/async/__federation_expose_PrometheusDatasource.45ee94e2.js +0 -1
  296. package/__mf/js/async/__federation_expose_PrometheusExplorer.b8e555e1.js +0 -1
  297. package/__mf/js/async/__federation_expose_PrometheusLabelNamesVariable.00dfb1dd.js +0 -1
  298. package/__mf/js/async/__federation_expose_PrometheusLabelValuesVariable.956ef2d0.js +0 -1
  299. package/__mf/js/async/__federation_expose_PrometheusPromQLVariable.59f2d170.js +0 -1
  300. package/__mf/js/async/__federation_expose_PrometheusTimeSeriesQuery.d7143352.js +0 -1
  301. package/__mf/js/main.afc2ee60.js +0 -5
  302. /package/__mf/css/async/{1339.d3010b86.css → 1233.d3010b86.css} +0 -0
  303. /package/__mf/css/async/{1576.d3010b86.css → 1324.d3010b86.css} +0 -0
  304. /package/__mf/css/async/{4576.d3010b86.css → 9518.d3010b86.css} +0 -0
  305. /package/__mf/js/async/{8045.7f554a45.js.LICENSE.txt → 1605.dc180cb8.js.LICENSE.txt} +0 -0
  306. /package/__mf/js/async/{2292.57d8fd0d.js.LICENSE.txt → 2043.d0fbb886.js.LICENSE.txt} +0 -0
  307. /package/__mf/js/async/{6341.20eccf91.js.LICENSE.txt → 3652.fc1e5f95.js.LICENSE.txt} +0 -0
  308. /package/__mf/js/async/{5981.eb502d27.js.LICENSE.txt → 392.7cda691a.js.LICENSE.txt} +0 -0
  309. /package/__mf/js/async/{1964.1d168a86.js.LICENSE.txt → 4121.828d661d.js.LICENSE.txt} +0 -0
  310. /package/__mf/js/async/{58.1c9a8daa.js.LICENSE.txt → 4657.e3d53a21.js.LICENSE.txt} +0 -0
  311. /package/__mf/js/async/{4676.b7a22f90.js.LICENSE.txt → 54.f6f480ef.js.LICENSE.txt} +0 -0
  312. /package/__mf/js/async/{3960.3eedafbd.js.LICENSE.txt → 6274.478a68f8.js.LICENSE.txt} +0 -0
  313. /package/__mf/js/async/{3980.0b0d272c.js.LICENSE.txt → 6283.181cb622.js.LICENSE.txt} +0 -0
  314. /package/__mf/js/async/{9173.915b80af.js.LICENSE.txt → 8470.9b14a625.js.LICENSE.txt} +0 -0
  315. /package/__mf/js/async/{4557.f3eb9456.js.LICENSE.txt → 9010.15208552.js.LICENSE.txt} +0 -0
  316. /package/__mf/js/async/{3863.7192dfdf.js.LICENSE.txt → 941.53b13124.js.LICENSE.txt} +0 -0
package/lib/index.js CHANGED
@@ -1,3 +1,15 @@
1
+ // Copyright The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the \"License\");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an \"AS IS\" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
1
13
  export * from './components';
2
14
  export * from './explore';
3
15
  export { getPluginModule } from './getPluginModule';
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export * from './components';\nexport * from './explore';\nexport { getPluginModule } from './getPluginModule';\nexport * from './model';\nexport * from './plugins';\n"],"names":["getPluginModule"],"mappings":"AAAA,cAAc,eAAe;AAC7B,cAAc,YAAY;AAC1B,SAASA,eAAe,QAAQ,oBAAoB;AACpD,cAAc,UAAU;AACxB,cAAc,YAAY"}
1
+ {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \\\"License\\\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \\\"AS IS\\\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './components';\nexport * from './explore';\nexport { getPluginModule } from './getPluginModule';\nexport * from './model';\nexport * from './plugins';\n"],"names":["getPluginModule"],"mappings":"AAAA,+BAA+B;AAC/B,oEAAoE;AACpE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,sEAAsE;AACtE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,eAAe;AAC7B,cAAc,YAAY;AAC1B,SAASA,eAAe,QAAQ,oBAAoB;AACpD,cAAc,UAAU;AACxB,cAAc,YAAY"}
@@ -1,4 +1,4 @@
1
- // Copyright 2025 The Perses Authors
1
+ // Copyright The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/model/api-types.ts"],"sourcesContent":["// Copyright 2025 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { DurationString } from '@perses-dev/core';\nimport ASTNode from '../components/promql/ast';\n\n// Just reuse dashboard model's type and re-export\nexport type { DurationString };\n\nexport interface SuccessResponse<T> {\n status: 'success';\n data: T;\n rawResponse?: Response;\n warnings?: string[];\n}\n\nexport interface ErrorResponse<T> {\n status: 'error';\n data?: T;\n errorType: string;\n error: string;\n}\n\nexport type ApiResponse<T> = SuccessResponse<T> | ErrorResponse<T>;\n\nexport type DurationSeconds = number;\n\nexport type UnixTimestampSeconds = number;\n\nexport type ValueTuple = [unixTimeSeconds: UnixTimestampSeconds, sampleValue: string];\n\nexport type BucketTuple = [bucket: number, upperBound: string, lowerBound: string, count: string];\n\nexport type HistogramValue = { count: number; sum: string; buckets?: BucketTuple[] };\n\nexport type HistogramTuple = [unixTimeSeconds: UnixTimestampSeconds, value: HistogramValue];\n\nexport type Metric = Record<string, string>;\n\nexport interface VectorData {\n resultType: 'vector';\n result: Array<{\n metric: Metric;\n value: ValueTuple;\n histogram?: HistogramTuple;\n }>;\n}\n\nexport interface MatrixData {\n resultType: 'matrix';\n result: Array<{\n metric: Metric;\n values: ValueTuple[];\n histograms?: HistogramTuple[];\n }>;\n}\n\nexport interface ScalarData {\n resultType: 'scalar';\n result: ValueTuple;\n}\n\nexport interface StringData {\n resultType: 'string';\n result: ValueTuple;\n}\n\nexport interface InstantQueryRequestParameters {\n query: string;\n time?: UnixTimestampSeconds;\n timeout?: DurationString;\n}\n\nexport type InstantQueryResultType = MatrixData | VectorData | ScalarData | StringData;\n\n// Ref https://prometheus.io/docs/prometheus/latest/querying/api/#instant-queries\nexport type InstantQueryResponse = ApiResponse<InstantQueryResultType>;\n\nexport type MonitoredInstantQueryResponse = InstantQueryResponse & {\n responseTime: number;\n};\n\nexport interface RangeQueryRequestParameters {\n query: string;\n start: UnixTimestampSeconds;\n end: UnixTimestampSeconds;\n step: DurationSeconds;\n timeout?: DurationString;\n}\n\nexport type RangeQueryResponse = ApiResponse<MatrixData>;\n\nexport interface SeriesRequestParameters {\n 'match[]': string[];\n start?: UnixTimestampSeconds;\n end?: UnixTimestampSeconds;\n limit?: number;\n}\n\nexport type SeriesResponse = ApiResponse<Metric[]>;\n\nexport interface LabelNamesRequestParameters {\n start?: UnixTimestampSeconds;\n end?: UnixTimestampSeconds;\n 'match[]'?: string[];\n limit?: number;\n}\n\nexport type LabelNamesResponse = ApiResponse<string[]>;\n\nexport interface LabelValuesRequestParameters {\n labelName: string;\n start?: UnixTimestampSeconds;\n end?: UnixTimestampSeconds;\n 'match[]'?: string[];\n limit?: number;\n}\n\nexport type LabelValuesResponse = ApiResponse<string[]>;\n\nexport interface MetricMetadata {\n type: string;\n help: string;\n unit?: string;\n}\n\nexport interface MetricMetadataRequestParameters {\n limit?: number;\n metric?: string;\n}\n\nexport type MetricMetadataResponse = ApiResponse<Record<string, MetricMetadata[]>>;\n\n// ref: https://prometheus.io/docs/prometheus/3.0/querying/api/#parsing-a-promql-expressions-into-a-abstract-syntax-tree-ast\nexport interface ParseQueryRequestParameters {\n query: string;\n}\n\nexport type ParseQueryResponse = ApiResponse<ASTNode>;\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAyIjC,WAAsD"}
1
+ {"version":3,"sources":["../../../src/model/api-types.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { DurationString } from '@perses-dev/core';\nimport ASTNode from '../components/promql/ast';\n\n// Just reuse dashboard model's type and re-export\nexport type { DurationString };\n\nexport interface SuccessResponse<T> {\n status: 'success';\n data: T;\n rawResponse?: Response;\n warnings?: string[];\n}\n\nexport interface ErrorResponse<T> {\n status: 'error';\n data?: T;\n errorType: string;\n error: string;\n}\n\nexport type ApiResponse<T> = SuccessResponse<T> | ErrorResponse<T>;\n\nexport type DurationSeconds = number;\n\nexport type UnixTimestampSeconds = number;\n\nexport type ValueTuple = [unixTimeSeconds: UnixTimestampSeconds, sampleValue: string];\n\nexport type BucketTuple = [bucket: number, upperBound: string, lowerBound: string, count: string];\n\nexport type HistogramValue = { count: number; sum: string; buckets?: BucketTuple[] };\n\nexport type HistogramTuple = [unixTimeSeconds: UnixTimestampSeconds, value: HistogramValue];\n\nexport type Metric = Record<string, string>;\n\nexport interface VectorData {\n resultType: 'vector';\n result: Array<{\n metric: Metric;\n value: ValueTuple;\n histogram?: HistogramTuple;\n }>;\n}\n\nexport interface MatrixData {\n resultType: 'matrix';\n result: Array<{\n metric: Metric;\n values: ValueTuple[];\n histograms?: HistogramTuple[];\n }>;\n}\n\nexport interface ScalarData {\n resultType: 'scalar';\n result: ValueTuple;\n}\n\nexport interface StringData {\n resultType: 'string';\n result: ValueTuple;\n}\n\nexport interface InstantQueryRequestParameters {\n query: string;\n time?: UnixTimestampSeconds;\n timeout?: DurationString;\n}\n\nexport type InstantQueryResultType = MatrixData | VectorData | ScalarData | StringData;\n\n// Ref https://prometheus.io/docs/prometheus/latest/querying/api/#instant-queries\nexport type InstantQueryResponse = ApiResponse<InstantQueryResultType>;\n\nexport type MonitoredInstantQueryResponse = InstantQueryResponse & {\n responseTime: number;\n};\n\nexport interface RangeQueryRequestParameters {\n query: string;\n start: UnixTimestampSeconds;\n end: UnixTimestampSeconds;\n step: DurationSeconds;\n timeout?: DurationString;\n}\n\nexport type RangeQueryResponse = ApiResponse<MatrixData>;\n\nexport interface SeriesRequestParameters {\n 'match[]': string[];\n start?: UnixTimestampSeconds;\n end?: UnixTimestampSeconds;\n limit?: number;\n}\n\nexport type SeriesResponse = ApiResponse<Metric[]>;\n\nexport interface LabelNamesRequestParameters {\n start?: UnixTimestampSeconds;\n end?: UnixTimestampSeconds;\n 'match[]'?: string[];\n limit?: number;\n}\n\nexport type LabelNamesResponse = ApiResponse<string[]>;\n\nexport interface LabelValuesRequestParameters {\n labelName: string;\n start?: UnixTimestampSeconds;\n end?: UnixTimestampSeconds;\n 'match[]'?: string[];\n limit?: number;\n}\n\nexport type LabelValuesResponse = ApiResponse<string[]>;\n\nexport interface MetricMetadata {\n type: string;\n help: string;\n unit?: string;\n}\n\nexport interface MetricMetadataRequestParameters {\n limit?: number;\n metric?: string;\n}\n\nexport type MetricMetadataResponse = ApiResponse<Record<string, MetricMetadata[]>>;\n\n// ref: https://prometheus.io/docs/prometheus/3.0/querying/api/#parsing-a-promql-expressions-into-a-abstract-syntax-tree-ast\nexport interface ParseQueryRequestParameters {\n query: string;\n}\n\nexport type ParseQueryResponse = ApiResponse<ASTNode>;\n"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAyIjC,WAAsD"}
@@ -1,4 +1,4 @@
1
- // Copyright 2023 The Perses Authors
1
+ // Copyright The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/model/index.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './api-types';\nexport * from './parse-sample-values';\nexport * from './prometheus-client';\nexport * from './prometheus-selectors';\nexport * from './time';\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,cAAc;AAC5B,cAAc,wBAAwB;AACtC,cAAc,sBAAsB;AACpC,cAAc,yBAAyB;AACvC,cAAc,SAAS"}
1
+ {"version":3,"sources":["../../../src/model/index.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './api-types';\nexport * from './parse-sample-values';\nexport * from './prometheus-client';\nexport * from './prometheus-selectors';\nexport * from './time';\n"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,cAAc;AAC5B,cAAc,wBAAwB;AACtC,cAAc,sBAAsB;AACpC,cAAc,yBAAyB;AACvC,cAAc,SAAS"}
@@ -1,4 +1,4 @@
1
- // Copyright 2023 The Perses Authors
1
+ // Copyright The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/model/parse-sample-values.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { ValueTuple } from './api-types';\n\n/**\n * ValueTuple from the Prom server, parsed into ms and floating point number\n */\nexport type ParsedValueTuple = [unixTimeMs: number, value: number];\n\n/**\n * Parse a ValueTuple from a PromServer response into the a millisecond-based\n * unix time and a numeric sample value.\n */\nexport function parseValueTuple(data: ValueTuple): ParsedValueTuple {\n const [unixTimeSeconds, sampleValue] = data;\n\n // Prom returns unix time in seconds, so convert to ms\n return [unixTimeSeconds * 1000, parseSampleValue(sampleValue)];\n}\n\n/**\n * Parses a string sample value from Prometheus, usually included as the\n * second member of a ValueTuple.\n */\nexport function parseSampleValue(sampleValue: ValueTuple[1]): number {\n // Account for Prometheus' representation of +/- infinity, otherwise just\n // parse the sample value as a float\n let value: number;\n switch (sampleValue) {\n case '+Inf':\n value = Number.POSITIVE_INFINITY;\n break;\n case '-Inf':\n value = Number.NEGATIVE_INFINITY;\n break;\n default:\n value = parseFloat(sampleValue);\n }\n return value;\n}\n"],"names":["parseValueTuple","data","unixTimeSeconds","sampleValue","parseSampleValue","value","Number","POSITIVE_INFINITY","NEGATIVE_INFINITY","parseFloat"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AASjC;;;CAGC,GACD,OAAO,SAASA,gBAAgBC,IAAgB;IAC9C,MAAM,CAACC,iBAAiBC,YAAY,GAAGF;IAEvC,sDAAsD;IACtD,OAAO;QAACC,kBAAkB;QAAME,iBAAiBD;KAAa;AAChE;AAEA;;;CAGC,GACD,OAAO,SAASC,iBAAiBD,WAA0B;IACzD,yEAAyE;IACzE,oCAAoC;IACpC,IAAIE;IACJ,OAAQF;QACN,KAAK;YACHE,QAAQC,OAAOC,iBAAiB;YAChC;QACF,KAAK;YACHF,QAAQC,OAAOE,iBAAiB;YAChC;QACF;YACEH,QAAQI,WAAWN;IACvB;IACA,OAAOE;AACT"}
1
+ {"version":3,"sources":["../../../src/model/parse-sample-values.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { ValueTuple } from './api-types';\n\n/**\n * ValueTuple from the Prom server, parsed into ms and floating point number\n */\nexport type ParsedValueTuple = [unixTimeMs: number, value: number];\n\n/**\n * Parse a ValueTuple from a PromServer response into the a millisecond-based\n * unix time and a numeric sample value.\n */\nexport function parseValueTuple(data: ValueTuple): ParsedValueTuple {\n const [unixTimeSeconds, sampleValue] = data;\n\n // Prom returns unix time in seconds, so convert to ms\n return [unixTimeSeconds * 1000, parseSampleValue(sampleValue)];\n}\n\n/**\n * Parses a string sample value from Prometheus, usually included as the\n * second member of a ValueTuple.\n */\nexport function parseSampleValue(sampleValue: ValueTuple[1]): number {\n // Account for Prometheus' representation of +/- infinity, otherwise just\n // parse the sample value as a float\n let value: number;\n switch (sampleValue) {\n case '+Inf':\n value = Number.POSITIVE_INFINITY;\n break;\n case '-Inf':\n value = Number.NEGATIVE_INFINITY;\n break;\n default:\n value = parseFloat(sampleValue);\n }\n return value;\n}\n"],"names":["parseValueTuple","data","unixTimeSeconds","sampleValue","parseSampleValue","value","Number","POSITIVE_INFINITY","NEGATIVE_INFINITY","parseFloat"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AASjC;;;CAGC,GACD,OAAO,SAASA,gBAAgBC,IAAgB;IAC9C,MAAM,CAACC,iBAAiBC,YAAY,GAAGF;IAEvC,sDAAsD;IACtD,OAAO;QAACC,kBAAkB;QAAME,iBAAiBD;KAAa;AAChE;AAEA;;;CAGC,GACD,OAAO,SAASC,iBAAiBD,WAA0B;IACzD,yEAAyE;IACzE,oCAAoC;IACpC,IAAIE;IACJ,OAAQF;QACN,KAAK;YACHE,QAAQC,OAAOC,iBAAiB;YAChC;QACF,KAAK;YACHF,QAAQC,OAAOE,iBAAiB;YAChC;QACF;YACEH,QAAQI,WAAWN;IACvB;IACA,OAAOE;AACT"}
@@ -19,6 +19,7 @@ export interface QueryOptions {
19
19
  datasourceUrl: string;
20
20
  headers?: RequestHeaders;
21
21
  abortSignal?: AbortSignal;
22
+ queryParams?: Record<string, string>;
22
23
  }
23
24
  /**
24
25
  * Calls the `/-/healthy` endpoint to check if the datasource is healthy.
@@ -1 +1 @@
1
- {"version":3,"file":"prometheus-client.d.ts","sourceRoot":"","sources":["../../../src/model/prometheus-client.ts"],"names":[],"mappings":"AAaA,OAAO,EAAoB,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EACL,6BAA6B,EAC7B,oBAAoB,EACpB,2BAA2B,EAC3B,kBAAkB,EAClB,4BAA4B,EAC5B,mBAAmB,EACnB,+BAA+B,EAC/B,sBAAsB,EACtB,2BAA2B,EAC3B,kBAAkB,EAClB,2BAA2B,EAC3B,kBAAkB,EAClB,uBAAuB,EACvB,cAAc,EAEf,MAAM,aAAa,CAAC;AAErB,UAAU,uBAAuB;IAC/B,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,CAAC,EAAE,cAAc,CAAC;CAC1B;AAED,MAAM,WAAW,gBAAiB,SAAQ,gBAAgB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AACH,wBAAgB,YAAY,CAC1B,MAAM,EAAE,6BAA6B,EACrC,YAAY,EAAE,YAAY,GACzB,OAAO,CAAC,oBAAoB,CAAC,CAE/B;AAED;;GAEG;AACH,wBAAgB,UAAU,CACxB,MAAM,EAAE,2BAA2B,EACnC,YAAY,EAAE,YAAY,GACzB,OAAO,CAAC,kBAAkB,CAAC,CAE7B;AAED;;GAEG;AACH,wBAAgB,UAAU,CACxB,MAAM,EAAE,2BAA2B,EACnC,YAAY,EAAE,YAAY,GACzB,OAAO,CAAC,kBAAkB,CAAC,CAE7B;AAED;;GAEG;AACH,wBAAgB,WAAW,CACzB,MAAM,EAAE,4BAA4B,EACpC,YAAY,EAAE,YAAY,GACzB,OAAO,CAAC,mBAAmB,CAAC,CAa9B;AAED;;GAEG;AACH,wBAAgB,cAAc,CAC5B,MAAM,EAAE,+BAA+B,EACvC,YAAY,EAAE,YAAY,GACzB,OAAO,CAAC,sBAAsB,CAAC,CAGjC;AAED;;GAEG;AACH,wBAAgB,MAAM,CAAC,MAAM,EAAE,uBAAuB,EAAE,YAAY,EAAE,YAAY,GAAG,OAAO,CAAC,cAAc,CAAC,CAG3G;AAED;;GAEG;AACH,wBAAgB,UAAU,CACxB,MAAM,EAAE,2BAA2B,EACnC,YAAY,EAAE,YAAY,GACzB,OAAO,CAAC,kBAAkB,CAAC,CAG7B;AAsED;;GAEG;AACH,wBAAsB,YAAY,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,UAAU,CAAC,OAAO,MAAM,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAI1F"}
1
+ {"version":3,"file":"prometheus-client.d.ts","sourceRoot":"","sources":["../../../src/model/prometheus-client.ts"],"names":[],"mappings":"AAaA,OAAO,EAAoB,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EACL,6BAA6B,EAC7B,oBAAoB,EACpB,2BAA2B,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ED;;GAEG;AACH,wBAAsB,YAAY,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,UAAU,CAAC,OAAO,MAAM,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAI1F"}
@@ -1,4 +1,4 @@
1
- // Copyright 2023 The Perses Authors
1
+ // Copyright The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -11,11 +11,25 @@
11
11
  // See the License for the specific language governing permissions and
12
12
  // limitations under the License.
13
13
  import { fetch, fetchJson } from '@perses-dev/core';
14
+ /**
15
+ * Builds a query string from datasource-level query parameters.
16
+ * Optionally merges with existing URLSearchParams.
17
+ * Returns empty string if no parameters, otherwise returns query string with leading '?'.
18
+ */ function buildQueryString(queryParams, initialParams) {
19
+ const urlParams = initialParams || new URLSearchParams();
20
+ if (queryParams) {
21
+ Object.entries(queryParams).forEach(([key, value])=>{
22
+ urlParams.set(key, value);
23
+ });
24
+ }
25
+ const queryString = urlParams.toString();
26
+ return queryString !== '' ? `?${queryString}` : '';
27
+ }
14
28
  /**
15
29
  * Calls the `/-/healthy` endpoint to check if the datasource is healthy.
16
30
  */ export function healthCheck(queryOptions) {
17
31
  return async ()=>{
18
- const url = `${queryOptions.datasourceUrl}/-/healthy`;
32
+ const url = `${queryOptions.datasourceUrl}/-/healthy${buildQueryString(queryOptions.queryParams)}`;
19
33
  try {
20
34
  const resp = await fetch(url, {
21
35
  headers: queryOptions.headers,
@@ -77,20 +91,16 @@ import { fetch, fetchJson } from '@perses-dev/core';
77
91
  return fetchWithPost(apiURI, params, queryOptions);
78
92
  }
79
93
  function fetchWithGet(apiURI, params, queryOptions) {
80
- const { datasourceUrl, headers } = queryOptions;
81
- let url = `${datasourceUrl}${apiURI}`;
82
- const urlParams = createSearchParams(params).toString();
83
- if (urlParams !== '') {
84
- url += `?${urlParams}`;
85
- }
94
+ const { datasourceUrl, headers, queryParams } = queryOptions;
95
+ const url = `${datasourceUrl}${apiURI}${buildQueryString(queryParams, createSearchParams(params))}`;
86
96
  return fetchJson(url, {
87
97
  method: 'GET',
88
98
  headers
89
99
  });
90
100
  }
91
101
  function fetchWithPost(apiURI, params, queryOptions) {
92
- const { datasourceUrl, headers, abortSignal: signal } = queryOptions;
93
- const url = `${datasourceUrl}${apiURI}`;
102
+ const { datasourceUrl, headers, abortSignal: signal, queryParams } = queryOptions;
103
+ const url = `${datasourceUrl}${apiURI}${buildQueryString(queryParams)}`;
94
104
  const init = {
95
105
  method: 'POST',
96
106
  headers: {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/model/prometheus-client.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { fetch, fetchJson, RequestHeaders } from '@perses-dev/core';\nimport { DatasourceClient } from '@perses-dev/plugin-system';\nimport {\n InstantQueryRequestParameters,\n InstantQueryResponse,\n LabelNamesRequestParameters,\n LabelNamesResponse,\n LabelValuesRequestParameters,\n LabelValuesResponse,\n MetricMetadataRequestParameters,\n MetricMetadataResponse,\n ParseQueryRequestParameters,\n ParseQueryResponse,\n RangeQueryRequestParameters,\n RangeQueryResponse,\n SeriesRequestParameters,\n SeriesResponse,\n SuccessResponse,\n} from './api-types';\n\ninterface PrometheusClientOptions {\n datasourceUrl: string;\n headers?: RequestHeaders;\n}\n\nexport interface PrometheusClient extends DatasourceClient {\n options: PrometheusClientOptions;\n instantQuery(\n params: InstantQueryRequestParameters,\n headers?: RequestHeaders,\n signal?: AbortSignal\n ): Promise<InstantQueryResponse>;\n rangeQuery(\n params: RangeQueryRequestParameters,\n headers?: RequestHeaders,\n signal?: AbortSignal\n ): Promise<RangeQueryResponse>;\n labelNames(\n params: LabelNamesRequestParameters,\n headers?: RequestHeaders,\n signal?: AbortSignal\n ): Promise<LabelNamesResponse>;\n labelValues(\n params: LabelValuesRequestParameters,\n headers?: RequestHeaders,\n signal?: AbortSignal\n ): Promise<LabelValuesResponse>;\n metricMetadata(\n params: MetricMetadataRequestParameters,\n headers?: RequestHeaders,\n signal?: AbortSignal\n ): Promise<MetricMetadataResponse>;\n series(params: SeriesRequestParameters, headers?: RequestHeaders, signal?: AbortSignal): Promise<SeriesResponse>;\n parseQuery(\n params: ParseQueryRequestParameters,\n headers?: RequestHeaders,\n signal?: AbortSignal\n ): Promise<ParseQueryResponse>;\n}\n\nexport interface QueryOptions {\n datasourceUrl: string;\n headers?: RequestHeaders;\n abortSignal?: AbortSignal;\n}\n\n/**\n * Calls the `/-/healthy` endpoint to check if the datasource is healthy.\n */\nexport function healthCheck(queryOptions: QueryOptions) {\n return async (): Promise<boolean> => {\n const url = `${queryOptions.datasourceUrl}/-/healthy`;\n\n try {\n const resp = await fetch(url, { headers: queryOptions.headers, signal: queryOptions.abortSignal });\n return resp.status === 200;\n } catch {\n return false;\n }\n };\n}\n\n/**\n * Calls the `/api/v1/query` endpoint to get metrics data.\n */\nexport function instantQuery(\n params: InstantQueryRequestParameters,\n queryOptions: QueryOptions\n): Promise<InstantQueryResponse> {\n return fetchWithPost<InstantQueryRequestParameters, InstantQueryResponse>('/api/v1/query', params, queryOptions);\n}\n\n/**\n * Calls the `/api/v1/query_range` endpoint to get metrics data.\n */\nexport function rangeQuery(\n params: RangeQueryRequestParameters,\n queryOptions: QueryOptions\n): Promise<RangeQueryResponse> {\n return fetchWithPost<RangeQueryRequestParameters, RangeQueryResponse>('/api/v1/query_range', params, queryOptions);\n}\n\n/**\n * Calls the `/api/v1/labels` endpoint to get a list of label names.\n */\nexport function labelNames(\n params: LabelNamesRequestParameters,\n queryOptions: QueryOptions\n): Promise<LabelNamesResponse> {\n return fetchWithPost<LabelNamesRequestParameters, LabelNamesResponse>('/api/v1/labels', params, queryOptions);\n}\n\n/**\n * Calls the `/api/v1/label/{labelName}/values` endpoint to get a list of values for a label.\n */\nexport function labelValues(\n params: LabelValuesRequestParameters,\n queryOptions: QueryOptions\n): Promise<LabelValuesResponse> {\n const { labelName, ...searchParams } = params;\n\n // In case label name is empty, we'll receive a 404, so we can replace it by an empty list, which is less confusing.\n // Note that an empty list is the prometheus result if the label does not exist.\n if (labelName.length === 0) {\n return new Promise((resolve) => {\n resolve({ data: [] as string[] } as SuccessResponse<string[]>);\n });\n }\n\n const apiURI = `/api/v1/label/${encodeURIComponent(labelName)}/values`;\n return fetchWithGet<typeof searchParams, LabelValuesResponse>(apiURI, searchParams, queryOptions);\n}\n\n/**\n * Calls the `/api/v1/label/{labelName}/values` endpoint to get a list of values for a label.\n */\nexport function metricMetadata(\n params: MetricMetadataRequestParameters,\n queryOptions: QueryOptions\n): Promise<MetricMetadataResponse> {\n const apiURI = `/api/v1/metadata`;\n return fetchWithGet<MetricMetadataRequestParameters, MetricMetadataResponse>(apiURI, params, queryOptions);\n}\n\n/**\n * Calls the `/api/v1/series` endpoint to finding series by label matchers.\n */\nexport function series(params: SeriesRequestParameters, queryOptions: QueryOptions): Promise<SeriesResponse> {\n const apiURI = `/api/v1/series`;\n return fetchWithPost<SeriesRequestParameters, SeriesResponse>(apiURI, params, queryOptions);\n}\n\n/**\n * Calls the `/api/v1/parse_query` to parse the given promQL expresion into an abstract syntax tree (AST).\n */\nexport function parseQuery(\n params: ParseQueryRequestParameters,\n queryOptions: QueryOptions\n): Promise<ParseQueryResponse> {\n const apiURI = `/api/v1/parse_query`;\n return fetchWithPost<ParseQueryRequestParameters, ParseQueryResponse>(apiURI, params, queryOptions);\n}\n\nfunction fetchWithGet<T extends RequestParams<T>, TResponse>(\n apiURI: string,\n params: T,\n queryOptions: QueryOptions\n): Promise<TResponse> {\n const { datasourceUrl, headers } = queryOptions;\n let url = `${datasourceUrl}${apiURI}`;\n const urlParams = createSearchParams(params).toString();\n if (urlParams !== '') {\n url += `?${urlParams}`;\n }\n return fetchJson<TResponse>(url, { method: 'GET', headers });\n}\n\nfunction fetchWithPost<T extends RequestParams<T>, TResponse>(\n apiURI: string,\n params: T,\n queryOptions: QueryOptions\n): Promise<TResponse> {\n const { datasourceUrl, headers, abortSignal: signal } = queryOptions;\n const url = `${datasourceUrl}${apiURI}`;\n const init = {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/x-www-form-urlencoded',\n ...headers,\n },\n signal,\n body: createSearchParams(params),\n };\n return fetchResults<TResponse>(url, init);\n}\n\n// Request parameter values we know how to serialize\ntype ParamValue = string | string[] | number | undefined;\n\n// Used to constrain the types that can be passed to createSearchParams to\n// just the ones we know how to serialize\ntype RequestParams<T> = {\n [K in keyof T]: ParamValue;\n};\n\n/**\n * Creates URLSearchParams from a request params object.\n */\nfunction createSearchParams<T extends RequestParams<T>>(params: T): URLSearchParams {\n const searchParams = new URLSearchParams();\n for (const key in params) {\n const value: ParamValue = params[key];\n if (value === undefined) continue;\n\n if (typeof value === 'string') {\n searchParams.append(key, value);\n continue;\n }\n\n if (typeof value === 'number') {\n searchParams.append(key, value.toString());\n continue;\n }\n\n for (const val of value) {\n searchParams.append(key, val);\n }\n }\n return searchParams;\n}\n\n/**\n * Fetch JSON and parse warnings for query inspector\n */\nexport async function fetchResults<T>(...args: Parameters<typeof global.fetch>): Promise<T> {\n const response = await fetch(...args);\n const json: T = await response.json();\n return { ...json, rawResponse: response };\n}\n"],"names":["fetch","fetchJson","healthCheck","queryOptions","url","datasourceUrl","resp","headers","signal","abortSignal","status","instantQuery","params","fetchWithPost","rangeQuery","labelNames","labelValues","labelName","searchParams","length","Promise","resolve","data","apiURI","encodeURIComponent","fetchWithGet","metricMetadata","series","parseQuery","urlParams","createSearchParams","toString","method","init","body","fetchResults","URLSearchParams","key","value","undefined","append","val","args","response","json","rawResponse"],"mappings":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UC,WAAW;QAEzB,IAAI,OAAOD,UAAU,UAAU;YAC7BpB,aAAasB,MAAM,CAACH,KAAKC;YACzB;QACF;QAEA,IAAI,OAAOA,UAAU,UAAU;YAC7BpB,aAAasB,MAAM,CAACH,KAAKC,MAAMP,QAAQ;YACvC;QACF;QAEA,KAAK,MAAMU,OAAOH,MAAO;YACvBpB,aAAasB,MAAM,CAACH,KAAKI;QAC3B;IACF;IACA,OAAOvB;AACT;AAEA;;CAEC,GACD,OAAO,eAAeiB,aAAgB,GAAGO,IAAqC;IAC5E,MAAMC,WAAW,MAAM3C,SAAS0C;IAChC,MAAME,OAAU,MAAMD,SAASC,IAAI;IACnC,OAAO;QAAE,GAAGA,IAAI;QAAEC,aAAaF;IAAS;AAC1C"}
1
+ {"version":3,"sources":["../../../src/model/prometheus-client.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { fetch, fetchJson, RequestHeaders } from '@perses-dev/core';\nimport { DatasourceClient } from '@perses-dev/plugin-system';\nimport {\n InstantQueryRequestParameters,\n InstantQueryResponse,\n LabelNamesRequestParameters,\n LabelNamesResponse,\n LabelValuesRequestParameters,\n LabelValuesResponse,\n MetricMetadataRequestParameters,\n MetricMetadataResponse,\n ParseQueryRequestParameters,\n ParseQueryResponse,\n RangeQueryRequestParameters,\n RangeQueryResponse,\n SeriesRequestParameters,\n SeriesResponse,\n SuccessResponse,\n} from './api-types';\n\ninterface PrometheusClientOptions {\n datasourceUrl: string;\n headers?: RequestHeaders;\n}\n\nexport interface PrometheusClient extends DatasourceClient {\n options: PrometheusClientOptions;\n instantQuery(\n params: InstantQueryRequestParameters,\n headers?: RequestHeaders,\n signal?: AbortSignal\n ): Promise<InstantQueryResponse>;\n rangeQuery(\n params: RangeQueryRequestParameters,\n headers?: RequestHeaders,\n signal?: AbortSignal\n ): Promise<RangeQueryResponse>;\n labelNames(\n params: LabelNamesRequestParameters,\n headers?: RequestHeaders,\n signal?: AbortSignal\n ): Promise<LabelNamesResponse>;\n labelValues(\n params: LabelValuesRequestParameters,\n headers?: RequestHeaders,\n signal?: AbortSignal\n ): Promise<LabelValuesResponse>;\n metricMetadata(\n params: MetricMetadataRequestParameters,\n headers?: RequestHeaders,\n signal?: AbortSignal\n ): Promise<MetricMetadataResponse>;\n series(params: SeriesRequestParameters, headers?: RequestHeaders, signal?: AbortSignal): Promise<SeriesResponse>;\n parseQuery(\n params: ParseQueryRequestParameters,\n headers?: RequestHeaders,\n signal?: AbortSignal\n ): Promise<ParseQueryResponse>;\n}\n\nexport interface QueryOptions {\n datasourceUrl: string;\n headers?: RequestHeaders;\n abortSignal?: AbortSignal;\n queryParams?: Record<string, string>;\n}\n\n/**\n * Builds a query string from datasource-level query parameters.\n * Optionally merges with existing URLSearchParams.\n * Returns empty string if no parameters, otherwise returns query string with leading '?'.\n */\nfunction buildQueryString(queryParams?: Record<string, string>, initialParams?: URLSearchParams): string {\n const urlParams = initialParams || new URLSearchParams();\n\n if (queryParams) {\n Object.entries(queryParams).forEach(([key, value]) => {\n urlParams.set(key, value);\n });\n }\n\n const queryString = urlParams.toString();\n return queryString !== '' ? `?${queryString}` : '';\n}\n\n/**\n * Calls the `/-/healthy` endpoint to check if the datasource is healthy.\n */\nexport function healthCheck(queryOptions: QueryOptions) {\n return async (): Promise<boolean> => {\n const url = `${queryOptions.datasourceUrl}/-/healthy${buildQueryString(queryOptions.queryParams)}`;\n\n try {\n const resp = await fetch(url, { headers: queryOptions.headers, signal: queryOptions.abortSignal });\n return resp.status === 200;\n } catch {\n return false;\n }\n };\n}\n\n/**\n * Calls the `/api/v1/query` endpoint to get metrics data.\n */\nexport function instantQuery(\n params: InstantQueryRequestParameters,\n queryOptions: QueryOptions\n): Promise<InstantQueryResponse> {\n return fetchWithPost<InstantQueryRequestParameters, InstantQueryResponse>('/api/v1/query', params, queryOptions);\n}\n\n/**\n * Calls the `/api/v1/query_range` endpoint to get metrics data.\n */\nexport function rangeQuery(\n params: RangeQueryRequestParameters,\n queryOptions: QueryOptions\n): Promise<RangeQueryResponse> {\n return fetchWithPost<RangeQueryRequestParameters, RangeQueryResponse>('/api/v1/query_range', params, queryOptions);\n}\n\n/**\n * Calls the `/api/v1/labels` endpoint to get a list of label names.\n */\nexport function labelNames(\n params: LabelNamesRequestParameters,\n queryOptions: QueryOptions\n): Promise<LabelNamesResponse> {\n return fetchWithPost<LabelNamesRequestParameters, LabelNamesResponse>('/api/v1/labels', params, queryOptions);\n}\n\n/**\n * Calls the `/api/v1/label/{labelName}/values` endpoint to get a list of values for a label.\n */\nexport function labelValues(\n params: LabelValuesRequestParameters,\n queryOptions: QueryOptions\n): Promise<LabelValuesResponse> {\n const { labelName, ...searchParams } = params;\n\n // In case label name is empty, we'll receive a 404, so we can replace it by an empty list, which is less confusing.\n // Note that an empty list is the prometheus result if the label does not exist.\n if (labelName.length === 0) {\n return new Promise((resolve) => {\n resolve({ data: [] as string[] } as SuccessResponse<string[]>);\n });\n }\n\n const apiURI = `/api/v1/label/${encodeURIComponent(labelName)}/values`;\n return fetchWithGet<typeof searchParams, LabelValuesResponse>(apiURI, searchParams, queryOptions);\n}\n\n/**\n * Calls the `/api/v1/label/{labelName}/values` endpoint to get a list of values for a label.\n */\nexport function metricMetadata(\n params: MetricMetadataRequestParameters,\n queryOptions: QueryOptions\n): Promise<MetricMetadataResponse> {\n const apiURI = `/api/v1/metadata`;\n return fetchWithGet<MetricMetadataRequestParameters, MetricMetadataResponse>(apiURI, params, queryOptions);\n}\n\n/**\n * Calls the `/api/v1/series` endpoint to finding series by label matchers.\n */\nexport function series(params: SeriesRequestParameters, queryOptions: QueryOptions): Promise<SeriesResponse> {\n const apiURI = `/api/v1/series`;\n return fetchWithPost<SeriesRequestParameters, SeriesResponse>(apiURI, params, queryOptions);\n}\n\n/**\n * Calls the `/api/v1/parse_query` to parse the given promQL expresion into an abstract syntax tree (AST).\n */\nexport function parseQuery(\n params: ParseQueryRequestParameters,\n queryOptions: QueryOptions\n): Promise<ParseQueryResponse> {\n const apiURI = `/api/v1/parse_query`;\n return fetchWithPost<ParseQueryRequestParameters, ParseQueryResponse>(apiURI, params, queryOptions);\n}\n\nfunction fetchWithGet<T extends RequestParams<T>, TResponse>(\n apiURI: string,\n params: T,\n queryOptions: QueryOptions\n): Promise<TResponse> {\n const { datasourceUrl, headers, queryParams } = queryOptions;\n const url = `${datasourceUrl}${apiURI}${buildQueryString(queryParams, createSearchParams(params))}`;\n return fetchJson<TResponse>(url, { method: 'GET', headers });\n}\n\nfunction fetchWithPost<T extends RequestParams<T>, TResponse>(\n apiURI: string,\n params: T,\n queryOptions: QueryOptions\n): Promise<TResponse> {\n const { datasourceUrl, headers, abortSignal: signal, queryParams } = queryOptions;\n const url = `${datasourceUrl}${apiURI}${buildQueryString(queryParams)}`;\n\n const init = {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/x-www-form-urlencoded',\n ...headers,\n },\n signal,\n body: createSearchParams(params),\n };\n return fetchResults<TResponse>(url, init);\n}\n\n// Request parameter values we know how to serialize\ntype ParamValue = string | string[] | number | undefined;\n\n// Used to constrain the types that can be passed to createSearchParams to\n// just the ones we know how to serialize\ntype RequestParams<T> = {\n [K in keyof T]: ParamValue;\n};\n\n/**\n * Creates URLSearchParams from a request params object.\n */\nfunction createSearchParams<T extends RequestParams<T>>(params: T): URLSearchParams {\n const searchParams = new URLSearchParams();\n for (const key in params) {\n const value: ParamValue = params[key];\n if (value === undefined) continue;\n\n if (typeof value === 'string') {\n searchParams.append(key, value);\n continue;\n }\n\n if (typeof value === 'number') {\n searchParams.append(key, value.toString());\n continue;\n }\n\n for (const val of value) {\n searchParams.append(key, val);\n }\n }\n return searchParams;\n}\n\n/**\n * Fetch JSON and parse warnings for query inspector\n */\nexport async function fetchResults<T>(...args: Parameters<typeof global.fetch>): Promise<T> {\n const response = await fetch(...args);\n const json: T = await response.json();\n return { ...json, rawResponse: response };\n}\n"],"names":["fetch","fetchJson","buildQueryString","queryParams","initialParams","urlParams","URLSearchParams","Object","entries","forEach","key","value","set","queryString","toString","healthCheck","queryOptions","url","datasourceUrl","resp","headers","signal","abortSignal","status","instantQuery","params","fetchWithPost","rangeQuery","labelNames","labelValues","labelName","searchParams","length","Promise","resolve","data","apiURI","encodeURIComponent","fetchWithGet","metricMetadata","series","parseQuery","createSearchParams","method","init","body","fetchResults","undefined","append","val","args","response","json","rawResponse"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,KAAK,EAAEC,SAAS,QAAwB,mBAAmB;AAmEpE;;;;CAIC,GACD,SAASC,iBAAiBC,WAAoC,EAAEC,aAA+B;IAC7F,MAAMC,YAAYD,iBAAiB,IAAIE;IAEvC,IAAIH,aAAa;QACfI,OAAOC,OAAO,CAACL,aAAaM,OAAO,CAAC,CAAC,CAACC,KAAKC,MAAM;YAC/CN,UAAUO,GAAG,CAACF,KAAKC;QACrB;IACF;IAEA,MAAME,cAAcR,UAAUS,QAAQ;IACtC,OAAOD,gBAAgB,KAAK,CAAC,CAAC,EAAEA,aAAa,GAAG;AAClD;AAEA;;CAEC,GACD,OAAO,SAASE,YAAYC,YAA0B;IACpD,OAAO;QACL,MAAMC,MAAM,GAAGD,aAAaE,aAAa,CAAC,UAAU,EAAEhB,iBAAiBc,aAAab,WAAW,GAAG;QAElG,IAAI;YACF,MAAMgB,OAAO,MAAMnB,MAAMiB,KAAK;gBAAEG,SAASJ,aAAaI,O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C,aAAaF;IAAS;AAC1C"}
@@ -1,4 +1,4 @@
1
- // Copyright 2023 The Perses Authors
1
+ // Copyright The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/model/prometheus-selectors.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { DatasourceSelector } from '@perses-dev/core';\nimport { DatasourceSelectValue, isVariableDatasource } from '@perses-dev/plugin-system';\n\nexport const PROM_DATASOURCE_KIND = 'PrometheusDatasource' as const;\n\n/**\n * DatasourceSelector for Prom Datasources.\n */\nexport interface PrometheusDatasourceSelector extends DatasourceSelector {\n kind: typeof PROM_DATASOURCE_KIND;\n}\n\n/**\n * A default selector that asks for the default Prom Datasource.\n */\nexport const DEFAULT_PROM: PrometheusDatasourceSelector = { kind: PROM_DATASOURCE_KIND };\n\n/**\n * Returns true if the provided datasourceSelectValue is the default PrometheusDatasourceSelector.\n */\nexport function isDefaultPromSelector(\n datasourceSelectValue: DatasourceSelectValue<PrometheusDatasourceSelector>\n): boolean {\n return !isVariableDatasource(datasourceSelectValue) && datasourceSelectValue.name === undefined;\n}\n\n/**\n * Type guard to make sure a datasourceSelectValue is a Prometheus one.\n */\nexport function isPrometheusDatasourceSelector(\n datasourceSelectValue: DatasourceSelectValue<DatasourceSelector>\n): datasourceSelectValue is PrometheusDatasourceSelector {\n return isVariableDatasource(datasourceSelectValue) || datasourceSelectValue.kind === PROM_DATASOURCE_KIND;\n}\n"],"names":["isVariableDatasource","PROM_DATASOURCE_KIND","DEFAULT_PROM","kind","isDefaultPromSelector","datasourceSelectValue","name","undefined","isPrometheusDatasourceSelector"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAGjC,SAAgCA,oBAAoB,QAAQ,4BAA4B;AAExF,OAAO,MAAMC,uBAAuB,uBAAgC;AASpE;;CAEC,GACD,OAAO,MAAMC,eAA6C;IAAEC,MAAMF;AAAqB,EAAE;AAEzF;;CAEC,GACD,OAAO,SAASG,sBACdC,qBAA0E;IAE1E,OAAO,CAACL,qBAAqBK,0BAA0BA,sBAAsBC,IAAI,KAAKC;AACxF;AAEA;;CAEC,GACD,OAAO,SAASC,+BACdH,qBAAgE;IAEhE,OAAOL,qBAAqBK,0BAA0BA,sBAAsBF,IAAI,KAAKF;AACvF"}
1
+ {"version":3,"sources":["../../../src/model/prometheus-selectors.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { DatasourceSelector } from '@perses-dev/core';\nimport { DatasourceSelectValue, isVariableDatasource } from '@perses-dev/plugin-system';\n\nexport const PROM_DATASOURCE_KIND = 'PrometheusDatasource' as const;\n\n/**\n * DatasourceSelector for Prom Datasources.\n */\nexport interface PrometheusDatasourceSelector extends DatasourceSelector {\n kind: typeof PROM_DATASOURCE_KIND;\n}\n\n/**\n * A default selector that asks for the default Prom Datasource.\n */\nexport const DEFAULT_PROM: PrometheusDatasourceSelector = { kind: PROM_DATASOURCE_KIND };\n\n/**\n * Returns true if the provided datasourceSelectValue is the default PrometheusDatasourceSelector.\n */\nexport function isDefaultPromSelector(\n datasourceSelectValue: DatasourceSelectValue<PrometheusDatasourceSelector>\n): boolean {\n return !isVariableDatasource(datasourceSelectValue) && datasourceSelectValue.name === undefined;\n}\n\n/**\n * Type guard to make sure a datasourceSelectValue is a Prometheus one.\n */\nexport function isPrometheusDatasourceSelector(\n datasourceSelectValue: DatasourceSelectValue<DatasourceSelector>\n): datasourceSelectValue is PrometheusDatasourceSelector {\n return isVariableDatasource(datasourceSelectValue) || datasourceSelectValue.kind === PROM_DATASOURCE_KIND;\n}\n"],"names":["isVariableDatasource","PROM_DATASOURCE_KIND","DEFAULT_PROM","kind","isDefaultPromSelector","datasourceSelectValue","name","undefined","isPrometheusDatasourceSelector"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAGjC,SAAgCA,oBAAoB,QAAQ,4BAA4B;AAExF,OAAO,MAAMC,uBAAuB,uBAAgC;AASpE;;CAEC,GACD,OAAO,MAAMC,eAA6C;IAAEC,MAAMF;AAAqB,EAAE;AAEzF;;CAEC,GACD,OAAO,SAASG,sBACdC,qBAA0E;IAE1E,OAAO,CAACL,qBAAqBK,0BAA0BA,sBAAsBC,IAAI,KAAKC;AACxF;AAEA;;CAEC,GACD,OAAO,SAASC,+BACdH,qBAAgE;IAEhE,OAAOL,qBAAqBK,0BAA0BA,sBAAsBF,IAAI,KAAKF;AACvF"}
package/lib/model/time.js CHANGED
@@ -1,4 +1,4 @@
1
- // Copyright 2023 The Perses Authors
1
+ // Copyright The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/model/time.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { AbsoluteTimeRange, DurationString, parseDurationString } from '@perses-dev/core';\nimport { milliseconds, getUnixTime } from 'date-fns';\nimport { UnixTimestampSeconds } from './api-types';\n\nexport interface PrometheusTimeRange {\n start: UnixTimestampSeconds;\n end: UnixTimestampSeconds;\n}\n\n/**\n * Converts an AbsoluteTimeRange to Prometheus time in Unix time (i.e. in seconds).\n */\nexport function getPrometheusTimeRange(timeRange: AbsoluteTimeRange): { start: number; end: number } {\n const { start, end } = timeRange;\n return {\n start: Math.ceil(getUnixTime(start)),\n end: Math.ceil(getUnixTime(end)),\n };\n}\n\n// Max data points to allow returning from a Prom Query, used to calculate a\n// \"safe\" step for a range query\nconst MAX_PROM_DATA_POINTS = 10000;\n\n/**\n * Gets the step to use for a Prom range query. Tries to take into account a suggested step size (probably based on the\n * width of a visualization where the data will be graphed), any minimum step/resolution set by the user, and a \"safe\"\n * step based on the max data points we want to allow returning from a Prom query.\n */\nexport function getRangeStep(\n timeRange: PrometheusTimeRange,\n minStepSeconds = 15,\n resolution = 1,\n suggestedStepMs = 0\n): number {\n const suggestedStepSeconds = suggestedStepMs / 1000;\n const queryRangeSeconds = timeRange.end - timeRange.start;\n\n let safeStep = queryRangeSeconds / MAX_PROM_DATA_POINTS;\n if (safeStep > 1) {\n safeStep = Math.ceil(safeStep);\n }\n\n return Math.max(suggestedStepSeconds * resolution, minStepSeconds, safeStep);\n}\n\n/**\n * Converts a DurationString to seconds, rounding down.\n */\nexport function getDurationStringSeconds(durationString?: DurationString): number | undefined {\n if (!durationString) return undefined;\n\n const duration = parseDurationString(durationString);\n const ms = milliseconds(duration);\n return Math.floor(ms / 1000);\n}\n"],"names":["parseDurationString","milliseconds","getUnixTime","getPrometheusTimeRange","timeRange","start","end","Math","ceil","MAX_PROM_DATA_POINTS","getRangeStep","minStepSeconds","resolution","suggestedStepMs","suggestedStepSeconds","queryRangeSeconds","safeStep","max","getDurationStringSeconds","durationString","undefined","duration","ms","floor"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAA4CA,mBAAmB,QAAQ,mBAAmB;AAC1F,SAASC,YAAY,EAAEC,WAAW,QAAQ,WAAW;AAQrD;;CAEC,GACD,OAAO,SAASC,uBAAuBC,SAA4B;IACjE,MAAM,EAAEC,KAAK,EAAEC,GAAG,EAAE,GAAGF;IACvB,OAAO;QACLC,OAAOE,KAAKC,IAAI,CAACN,YAAYG;QAC7BC,KAAKC,KAAKC,IAAI,CAACN,YAAYI;IAC7B;AACF;AAEA,4EAA4E;AAC5E,gCAAgC;AAChC,MAAMG,uBAAuB;AAE7B;;;;CAIC,GACD,OAAO,SAASC,aACdN,SAA8B,EAC9BO,iBAAiB,EAAE,EACnBC,aAAa,CAAC,EACdC,kBAAkB,CAAC;IAEnB,MAAMC,uBAAuBD,kBAAkB;IAC/C,MAAME,oBAAoBX,UAAUE,GAAG,GAAGF,UAAUC,KAAK;IAEzD,IAAIW,WAAWD,oBAAoBN;IACnC,IAAIO,WAAW,GAAG;QAChBA,WAAWT,KAAKC,IAAI,CAACQ;IACvB;IAEA,OAAOT,KAAKU,GAAG,CAACH,uBAAuBF,YAAYD,gBAAgBK;AACrE;AAEA;;CAEC,GACD,OAAO,SAASE,yBAAyBC,cAA+B;IACtE,IAAI,CAACA,gBAAgB,OAAOC;IAE5B,MAAMC,WAAWrB,oBAAoBmB;IACrC,MAAMG,KAAKrB,aAAaoB;IACxB,OAAOd,KAAKgB,KAAK,CAACD,KAAK;AACzB"}
1
+ {"version":3,"sources":["../../../src/model/time.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { AbsoluteTimeRange, DurationString, parseDurationString } from '@perses-dev/core';\nimport { milliseconds, getUnixTime } from 'date-fns';\nimport { UnixTimestampSeconds } from './api-types';\n\nexport interface PrometheusTimeRange {\n start: UnixTimestampSeconds;\n end: UnixTimestampSeconds;\n}\n\n/**\n * Converts an AbsoluteTimeRange to Prometheus time in Unix time (i.e. in seconds).\n */\nexport function getPrometheusTimeRange(timeRange: AbsoluteTimeRange): { start: number; end: number } {\n const { start, end } = timeRange;\n return {\n start: Math.ceil(getUnixTime(start)),\n end: Math.ceil(getUnixTime(end)),\n };\n}\n\n// Max data points to allow returning from a Prom Query, used to calculate a\n// \"safe\" step for a range query\nconst MAX_PROM_DATA_POINTS = 10000;\n\n/**\n * Gets the step to use for a Prom range query. Tries to take into account a suggested step size (probably based on the\n * width of a visualization where the data will be graphed), any minimum step/resolution set by the user, and a \"safe\"\n * step based on the max data points we want to allow returning from a Prom query.\n */\nexport function getRangeStep(\n timeRange: PrometheusTimeRange,\n minStepSeconds = 15,\n resolution = 1,\n suggestedStepMs = 0\n): number {\n const suggestedStepSeconds = suggestedStepMs / 1000;\n const queryRangeSeconds = timeRange.end - timeRange.start;\n\n let safeStep = queryRangeSeconds / MAX_PROM_DATA_POINTS;\n if (safeStep > 1) {\n safeStep = Math.ceil(safeStep);\n }\n\n return Math.max(suggestedStepSeconds * resolution, minStepSeconds, safeStep);\n}\n\n/**\n * Converts a DurationString to seconds, rounding down.\n */\nexport function getDurationStringSeconds(durationString?: DurationString): number | undefined {\n if (!durationString) return undefined;\n\n const duration = parseDurationString(durationString);\n const ms = milliseconds(duration);\n return Math.floor(ms / 1000);\n}\n"],"names":["parseDurationString","milliseconds","getUnixTime","getPrometheusTimeRange","timeRange","start","end","Math","ceil","MAX_PROM_DATA_POINTS","getRangeStep","minStepSeconds","resolution","suggestedStepMs","suggestedStepSeconds","queryRangeSeconds","safeStep","max","getDurationStringSeconds","durationString","undefined","duration","ms","floor"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAA4CA,mBAAmB,QAAQ,mBAAmB;AAC1F,SAASC,YAAY,EAAEC,WAAW,QAAQ,WAAW;AAQrD;;CAEC,GACD,OAAO,SAASC,uBAAuBC,SAA4B;IACjE,MAAM,EAAEC,KAAK,EAAEC,GAAG,EAAE,GAAGF;IACvB,OAAO;QACLC,OAAOE,KAAKC,IAAI,CAACN,YAAYG;QAC7BC,KAAKC,KAAKC,IAAI,CAACN,YAAYI;IAC7B;AACF;AAEA,4EAA4E;AAC5E,gCAAgC;AAChC,MAAMG,uBAAuB;AAE7B;;;;CAIC,GACD,OAAO,SAASC,aACdN,SAA8B,EAC9BO,iBAAiB,EAAE,EACnBC,aAAa,CAAC,EACdC,kBAAkB,CAAC;IAEnB,MAAMC,uBAAuBD,kBAAkB;IAC/C,MAAME,oBAAoBX,UAAUE,GAAG,GAAGF,UAAUC,KAAK;IAEzD,IAAIW,WAAWD,oBAAoBN;IACnC,IAAIO,WAAW,GAAG;QAChBA,WAAWT,KAAKC,IAAI,CAACQ;IACvB;IAEA,OAAOT,KAAKU,GAAG,CAACH,uBAAuBF,YAAYD,gBAAgBK;AACrE;AAEA;;CAEC,GACD,OAAO,SAASE,yBAAyBC,cAA+B;IACtE,IAAI,CAACA,gBAAgB,OAAOC;IAE5B,MAAMC,WAAWrB,oBAAoBmB;IACrC,MAAMG,KAAKrB,aAAaoB;IACxB,OAAOd,KAAKgB,KAAK,CAACD,KAAK;AACzB"}
@@ -1,4 +1,5 @@
1
- // Copyright 2023 The Perses Authors
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ // Copyright The Perses Authors
2
3
  // Licensed under the Apache License, Version 2.0 (the "License");
3
4
  // you may not use this file except in compliance with the License.
4
5
  // You may obtain a copy of the License at
@@ -10,7 +11,6 @@
10
11
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
12
  // See the License for the specific language governing permissions and
12
13
  // limitations under the License.
13
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
14
14
  import { Stack, TextField, Button, Box, IconButton } from '@mui/material';
15
15
  import { produce } from 'immer';
16
16
  import TrashIcon from 'mdi-material-ui/TrashCan';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/plugins/MatcherEditor.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Stack, TextField, Button, Box, IconButton } from '@mui/material';\nimport { produce } from 'immer';\nimport TrashIcon from 'mdi-material-ui/TrashCan';\nimport { ReactElement } from 'react';\n\ntype MatcherEditorProps = {\n matchers: string[];\n onChange: (matchers: string[]) => void;\n isReadonly?: boolean;\n};\n\nexport function MatcherEditor({ matchers, onChange, isReadonly }: MatcherEditorProps): ReactElement {\n return (\n <Stack spacing={1} mb={2}>\n {matchers.map((matcher, index) => (\n <Box key={index} display=\"flex\">\n <TextField\n fullWidth\n label=\"Series Selector\"\n value={matcher}\n InputProps={{\n readOnly: isReadonly,\n }}\n onChange={(e) => {\n const newMatchers = produce(matchers, (draft) => {\n draft[index] = e.target.value;\n });\n onChange(newMatchers);\n }}\n />\n <IconButton\n onClick={() => {\n const newMatchers = produce(matchers, (draft) => {\n draft.splice(index, 1);\n });\n onChange(newMatchers);\n }}\n disabled={isReadonly}\n >\n <TrashIcon />\n </IconButton>\n </Box>\n ))}\n <Box>\n <Button\n fullWidth={false}\n color=\"secondary\"\n variant=\"outlined\"\n onClick={() => {\n const newMatchers = produce(matchers, (draft) => {\n draft.push('');\n });\n onChange(newMatchers);\n }}\n disabled={isReadonly}\n >\n Add Series Selector\n </Button>\n </Box>\n </Stack>\n );\n}\n"],"names":["Stack","TextField","Button","Box","IconButton","produce","TrashIcon","MatcherEditor","matchers","onChange","isReadonly","spacing","mb","map","matcher","index","display","fullWidth","label","value","InputProps","readOnly","e","newMatchers","draft","target","onClick","splice","disabled","color","variant","push"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,SAASA,KAAK,EAAEC,SAAS,EAAEC,MAAM,EAAEC,GAAG,EAAEC,UAAU,QAAQ,gBAAgB;AAC1E,SAASC,OAAO,QAAQ,QAAQ;AAChC,OAAOC,eAAe,2BAA2B;AASjD,OAAO,SAASC,cAAc,EAAEC,QAAQ,EAAEC,QAAQ,EAAEC,UAAU,EAAsB;IAClF,qBACE,MAACV;QAAMW,SAAS;QAAGC,IAAI;;YACpBJ,SAASK,GAAG,CAAC,CAACC,SAASC,sBACtB,MAACZ;oBAAgBa,SAAQ;;sCACvB,KAACf;4BACCgB,SAAS;4BACTC,OAAM;4BACNC,OAAOL;4BACPM,YAAY;gCACVC,UAAUX;4BACZ;4BACAD,UAAU,CAACa;gCACT,MAAMC,cAAclB,QAAQG,UAAU,CAACgB;oCACrCA,KAAK,CAACT,MAAM,GAAGO,EAAEG,MAAM,CAACN,KAAK;gCAC/B;gCACAV,SAASc;4BACX;;sCAEF,KAACnB;4BACCsB,SAAS;gCACP,MAAMH,cAAclB,QAAQG,UAAU,CAACgB;oCACrCA,MAAMG,MAAM,CAACZ,OAAO;gCACtB;gCACAN,SAASc;4BACX;4BACAK,UAAUlB;sCAEV,cAAA,KAACJ;;;mBAxBKS;0BA4BZ,KAACZ;0BACC,cAAA,KAACD;oBACCe,WAAW;oBACXY,OAAM;oBACNC,SAAQ;oBACRJ,SAAS;wBACP,MAAMH,cAAclB,QAAQG,UAAU,CAACgB;4BACrCA,MAAMO,IAAI,CAAC;wBACb;wBACAtB,SAASc;oBACX;oBACAK,UAAUlB;8BACX;;;;;AAMT"}
1
+ {"version":3,"sources":["../../../src/plugins/MatcherEditor.tsx"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Stack, TextField, Button, Box, IconButton } from '@mui/material';\nimport { produce } from 'immer';\nimport TrashIcon from 'mdi-material-ui/TrashCan';\nimport { ReactElement } from 'react';\n\ntype MatcherEditorProps = {\n matchers: string[];\n onChange: (matchers: string[]) => void;\n isReadonly?: boolean;\n};\n\nexport function MatcherEditor({ matchers, onChange, isReadonly }: MatcherEditorProps): ReactElement {\n return (\n <Stack spacing={1} mb={2}>\n {matchers.map((matcher, index) => (\n <Box key={index} display=\"flex\">\n <TextField\n fullWidth\n label=\"Series Selector\"\n value={matcher}\n InputProps={{\n readOnly: isReadonly,\n }}\n onChange={(e) => {\n const newMatchers = produce(matchers, (draft) => {\n draft[index] = e.target.value;\n });\n onChange(newMatchers);\n }}\n />\n <IconButton\n onClick={() => {\n const newMatchers = produce(matchers, (draft) => {\n draft.splice(index, 1);\n });\n onChange(newMatchers);\n }}\n disabled={isReadonly}\n >\n <TrashIcon />\n </IconButton>\n </Box>\n ))}\n <Box>\n <Button\n fullWidth={false}\n color=\"secondary\"\n variant=\"outlined\"\n onClick={() => {\n const newMatchers = produce(matchers, (draft) => {\n draft.push('');\n });\n onChange(newMatchers);\n }}\n disabled={isReadonly}\n >\n Add Series Selector\n </Button>\n </Box>\n </Stack>\n );\n}\n"],"names":["Stack","TextField","Button","Box","IconButton","produce","TrashIcon","MatcherEditor","matchers","onChange","isReadonly","spacing","mb","map","matcher","index","display","fullWidth","label","value","InputProps","readOnly","e","newMatchers","draft","target","onClick","splice","disabled","color","variant","push"],"mappings":";AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,KAAK,EAAEC,SAAS,EAAEC,MAAM,EAAEC,GAAG,EAAEC,UAAU,QAAQ,gBAAgB;AAC1E,SAASC,OAAO,QAAQ,QAAQ;AAChC,OAAOC,eAAe,2BAA2B;AASjD,OAAO,SAASC,cAAc,EAAEC,QAAQ,EAAEC,QAAQ,EAAEC,UAAU,EAAsB;IAClF,qBACE,MAACV;QAAMW,SAAS;QAAGC,IAAI;;YACpBJ,SAASK,GAAG,CAAC,CAACC,SAASC,sBACtB,MAACZ;oBAAgBa,SAAQ;;sCACvB,KAACf;4BACCgB,SAAS;4BACTC,OAAM;4BACNC,OAAOL;4BACPM,YAAY;gCACVC,UAAUX;4BACZ;4BACAD,UAAU,CAACa;gCACT,MAAMC,cAAclB,QAAQG,UAAU,CAACgB;oCACrCA,KAAK,CAACT,MAAM,GAAGO,EAAEG,MAAM,CAACN,KAAK;gCAC/B;gCACAV,SAASc;4BACX;;sCAEF,KAACnB;4BACCsB,SAAS;gCACP,MAAMH,cAAclB,QAAQG,UAAU,CAACgB;oCACrCA,MAAMG,MAAM,CAACZ,OAAO;gCACtB;gCACAN,SAASc;4BACX;4BACAK,UAAUlB;sCAEV,cAAA,KAACJ;;;mBAxBKS;0BA4BZ,KAACZ;0BACC,cAAA,KAACD;oBACCe,WAAW;oBACXY,OAAM;oBACNC,SAAQ;oBACRJ,SAAS;wBACP,MAAMH,cAAclB,QAAQG,UAAU,CAACgB;4BACrCA,MAAMO,IAAI,CAAC;wBACb;wBACAtB,SAASc;oBACX;oBACAK,UAAUlB;8BACX;;;;;AAMT"}
@@ -1 +1 @@
1
- {"version":3,"file":"PrometheusDatasourceEditor.d.ts","sourceRoot":"","sources":["../../../src/plugins/PrometheusDatasourceEditor.tsx"],"names":[],"mappings":"AAgBA,OAAc,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAA2B,wBAAwB,EAAE,MAAM,SAAS,CAAC;AAE5E,MAAM,WAAW,+BAA+B;IAC9C,KAAK,EAAE,wBAAwB,CAAC;IAChC,QAAQ,EAAE,CAAC,IAAI,EAAE,wBAAwB,KAAK,IAAI,CAAC;IACnD,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,+BAA+B,GAAG,YAAY,CAwE/F"}
1
+ {"version":3,"file":"PrometheusDatasourceEditor.d.ts","sourceRoot":"","sources":["../../../src/plugins/PrometheusDatasourceEditor.tsx"],"names":[],"mappings":"AAkBA,OAAc,EAAE,YAAY,EAAoB,MAAM,OAAO,CAAC;AAC9D,OAAO,EAA2B,wBAAwB,EAAE,MAAM,SAAS,CAAC;AAS5E,MAAM,WAAW,+BAA+B;IAC9C,KAAK,EAAE,wBAAwB,CAAC;IAChC,QAAQ,EAAE,CAAC,IAAI,EAAE,wBAAwB,KAAK,IAAI,CAAC;IACnD,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,+BAA+B,GAAG,YAAY,CA6L/F"}
@@ -1,4 +1,4 @@
1
- // Copyright 2023 The Perses Authors
1
+ // Copyright The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -12,11 +12,82 @@
12
12
  // limitations under the License.
13
13
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
14
14
  import { HTTPSettingsEditor } from '@perses-dev/plugin-system';
15
- import { TextField, Typography } from '@mui/material';
16
- import React from 'react';
15
+ import { Box, TextField, Typography, IconButton } from '@mui/material';
16
+ import PlusIcon from 'mdi-material-ui/Plus';
17
+ import MinusIcon from 'mdi-material-ui/Minus';
18
+ import React, { useState, useRef } from 'react';
17
19
  import { DEFAULT_SCRAPE_INTERVAL } from './types';
18
20
  export function PrometheusDatasourceEditor(props) {
19
21
  const { value, onChange, isReadonly } = props;
22
+ // Counter for generating unique IDs
23
+ const nextIdRef = useRef(0);
24
+ // Use local state to maintain an array of entries during editing, instead of
25
+ // manipulating a map directly which causes weird UX.
26
+ const [entries, setEntries] = useState(()=>{
27
+ const queryParams = value.queryParams ?? {};
28
+ return Object.entries(queryParams).map(([key, value])=>({
29
+ id: String(nextIdRef.current++),
30
+ key,
31
+ value
32
+ }));
33
+ });
34
+ // Check for duplicate keys
35
+ const keyMap = new Map();
36
+ const duplicateKeys = new Set();
37
+ entries.forEach(({ key })=>{
38
+ if (key !== '') {
39
+ const count = (keyMap.get(key) || 0) + 1;
40
+ keyMap.set(key, count);
41
+ if (count > 1) {
42
+ duplicateKeys.add(key);
43
+ }
44
+ }
45
+ });
46
+ const hasDuplicates = duplicateKeys.size > 0;
47
+ // Convert entries array to object and trigger onChange
48
+ const syncToParent = (newEntries)=>{
49
+ const newParams = {};
50
+ newEntries.forEach(({ key, value })=>{
51
+ if (key !== '') {
52
+ newParams[key] = value;
53
+ }
54
+ });
55
+ onChange({
56
+ ...value,
57
+ queryParams: Object.keys(newParams).length > 0 ? newParams : undefined
58
+ });
59
+ };
60
+ const handleQueryParamChange = (id, field, newValue)=>{
61
+ const newEntries = entries.map((entry)=>{
62
+ if (entry.id !== id) return entry;
63
+ return field === 'key' ? {
64
+ ...entry,
65
+ key: newValue
66
+ } : {
67
+ ...entry,
68
+ value: newValue
69
+ };
70
+ });
71
+ setEntries(newEntries);
72
+ syncToParent(newEntries);
73
+ };
74
+ const addQueryParam = ()=>{
75
+ const newEntries = [
76
+ ...entries,
77
+ {
78
+ id: String(nextIdRef.current++),
79
+ key: '',
80
+ value: ''
81
+ }
82
+ ];
83
+ setEntries(newEntries);
84
+ syncToParent(newEntries);
85
+ };
86
+ const removeQueryParam = (id)=>{
87
+ const newEntries = entries.filter((entry)=>entry.id !== id);
88
+ setEntries(newEntries);
89
+ syncToParent(newEntries);
90
+ };
20
91
  const initialSpecDirect = {
21
92
  directUrl: ''
22
93
  };
@@ -67,6 +138,7 @@ export function PrometheusDatasourceEditor(props) {
67
138
  children: "General Settings"
68
139
  }),
69
140
  /*#__PURE__*/ _jsx(TextField, {
141
+ size: "small",
70
142
  fullWidth: true,
71
143
  label: "Scrape Interval",
72
144
  value: value.scrapeInterval || '',
@@ -80,7 +152,8 @@ export function PrometheusDatasourceEditor(props) {
80
152
  onChange: (e)=>onChange({
81
153
  ...value,
82
154
  scrapeInterval: e.target.value
83
- })
155
+ }),
156
+ helperText: "Set it to match the typical scrape interval used in your Prometheus instance."
84
157
  }),
85
158
  /*#__PURE__*/ _jsx(HTTPSettingsEditor, {
86
159
  value: value,
@@ -88,6 +161,65 @@ export function PrometheusDatasourceEditor(props) {
88
161
  isReadonly: isReadonly,
89
162
  initialSpecDirect: initialSpecDirect,
90
163
  initialSpecProxy: initialSpecProxy
164
+ }),
165
+ /*#__PURE__*/ _jsx(Typography, {
166
+ variant: "h5",
167
+ mt: 2,
168
+ mb: 1,
169
+ children: "Query Parameters"
170
+ }),
171
+ entries.length > 0 && /*#__PURE__*/ _jsx(_Fragment, {
172
+ children: entries.map((entry)=>/*#__PURE__*/ _jsxs(Box, {
173
+ display: "flex",
174
+ alignItems: "center",
175
+ gap: 2,
176
+ mb: 1,
177
+ children: [
178
+ /*#__PURE__*/ _jsx(TextField, {
179
+ size: "small",
180
+ label: "Key",
181
+ value: entry.key,
182
+ placeholder: "Parameter name",
183
+ disabled: isReadonly,
184
+ onChange: (e)=>handleQueryParamChange(entry.id, 'key', e.target.value),
185
+ error: duplicateKeys.has(entry.key),
186
+ sx: {
187
+ minWidth: 150
188
+ }
189
+ }),
190
+ /*#__PURE__*/ _jsx(TextField, {
191
+ size: "small",
192
+ label: "Value",
193
+ value: entry.value,
194
+ placeholder: "Parameter value",
195
+ disabled: isReadonly,
196
+ onChange: (e)=>handleQueryParamChange(entry.id, 'value', e.target.value),
197
+ sx: {
198
+ minWidth: 150,
199
+ flexGrow: 1
200
+ }
201
+ }),
202
+ !isReadonly && /*#__PURE__*/ _jsx(IconButton, {
203
+ onClick: ()=>removeQueryParam(entry.id),
204
+ children: /*#__PURE__*/ _jsx(MinusIcon, {})
205
+ })
206
+ ]
207
+ }, entry.id))
208
+ }),
209
+ hasDuplicates && /*#__PURE__*/ _jsx(Typography, {
210
+ variant: "body2",
211
+ color: "error",
212
+ mb: 1,
213
+ children: "Duplicate parameter keys detected. Each key must be unique."
214
+ }),
215
+ entries.length === 0 && /*#__PURE__*/ _jsx(Typography, {
216
+ variant: "body2",
217
+ color: "textSecondary",
218
+ children: "No query parameters configured. Use query parameters to pass additional options to Prometheus (e.g., dedup=false for Thanos)."
219
+ }),
220
+ !isReadonly && /*#__PURE__*/ _jsx(IconButton, {
221
+ onClick: addQueryParam,
222
+ children: /*#__PURE__*/ _jsx(PlusIcon, {})
91
223
  })
92
224
  ]
93
225
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/plugins/PrometheusDatasourceEditor.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { DurationString } from '@perses-dev/core';\nimport { HTTPSettingsEditor } from '@perses-dev/plugin-system';\nimport { TextField, Typography } from '@mui/material';\nimport React, { ReactElement } from 'react';\nimport { DEFAULT_SCRAPE_INTERVAL, PrometheusDatasourceSpec } from './types';\n\nexport interface PrometheusDatasourceEditorProps {\n value: PrometheusDatasourceSpec;\n onChange: (next: PrometheusDatasourceSpec) => void;\n isReadonly?: boolean;\n}\n\nexport function PrometheusDatasourceEditor(props: PrometheusDatasourceEditorProps): ReactElement {\n const { value, onChange, isReadonly } = props;\n\n const initialSpecDirect: PrometheusDatasourceSpec = {\n directUrl: '',\n };\n\n const initialSpecProxy: PrometheusDatasourceSpec = {\n proxy: {\n kind: 'HTTPProxy',\n spec: {\n allowedEndpoints: [\n // list of standard endpoints suggested by default\n {\n endpointPattern: '/api/v1/labels',\n method: 'POST',\n },\n {\n endpointPattern: '/api/v1/series',\n method: 'POST',\n },\n {\n endpointPattern: '/api/v1/metadata',\n method: 'GET',\n },\n {\n endpointPattern: '/api/v1/query',\n method: 'POST',\n },\n {\n endpointPattern: '/api/v1/query_range',\n method: 'POST',\n },\n {\n endpointPattern: '/api/v1/label/([a-zA-Z0-9_-]+)/values',\n method: 'GET',\n },\n {\n endpointPattern: '/api/v1/parse_query',\n method: 'POST',\n },\n ],\n url: '',\n },\n },\n };\n\n return (\n <>\n <Typography variant=\"h4\" mb={2}>\n General Settings\n </Typography>\n <TextField\n fullWidth\n label=\"Scrape Interval\"\n value={value.scrapeInterval || ''}\n placeholder={`Default: ${DEFAULT_SCRAPE_INTERVAL}`}\n InputProps={{\n readOnly: isReadonly,\n }}\n InputLabelProps={{ shrink: isReadonly ? true : undefined }}\n onChange={(e) => onChange({ ...value, scrapeInterval: e.target.value as DurationString })}\n />\n <HTTPSettingsEditor\n value={value}\n onChange={onChange}\n isReadonly={isReadonly}\n initialSpecDirect={initialSpecDirect}\n initialSpecProxy={initialSpecProxy}\n />\n </>\n );\n}\n"],"names":["HTTPSettingsEditor","TextField","Typography","React","DEFAULT_SCRAPE_INTERVAL","PrometheusDatasourceEditor","props","value","onChange","isReadonly","initialSpecDirect","directUrl","initialSpecProxy","proxy","kind","spec","allowedEndpoints","endpointPattern","method","url","variant","mb","fullWidth","label","scrapeInterval","placeholder","InputProps","readOnly","InputLabelProps","shrink","undefined","e","target"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAGjC,SAASA,kBAAkB,QAAQ,4BAA4B;AAC/D,SAASC,SAAS,EAAEC,UAAU,QAAQ,gBAAgB;AACtD,OAAOC,WAA6B,QAAQ;AAC5C,SAASC,uBAAuB,QAAkC,UAAU;AAQ5E,OAAO,SAASC,2BAA2BC,KAAsC;IAC/E,MAAM,EAAEC,KAAK,EAAEC,QAAQ,EAAEC,UAAU,EAAE,GAAGH;IAExC,MAAMI,oBAA8C;QAClDC,WAAW;IACb;IAEA,MAAMC,mBAA6C;QACjDC,OAAO;YACLC,MAAM;YACNC,MAAM;gBACJC,kBAAkB;oBAChB,kDAAkD;oBAClD;wBACEC,iBAAiB;wBACjBC,QAAQ;oBACV;oBACA;wBACED,iBAAiB;wBACjBC,QAAQ;oBACV;oBACA;wBACED,iBAAiB;wBACjBC,QAAQ;oBACV;oBACA;wBACED,iBAAiB;wBACjBC,QAAQ;oBACV;oBACA;wBACED,iBAAiB;wBACjBC,QAAQ;oBACV;oBACA;wBACED,iBAAiB;wBACjBC,QAAQ;oBACV;oBACA;wBACED,iBAAiB;wBACjBC,QAAQ;oBACV;iBACD;gBACDC,KAAK;YACP;QACF;IACF;IAEA,qBACE;;0BACE,KAACjB;gBAAWkB,SAAQ;gBAAKC,IAAI;0BAAG;;0BAGhC,KAACpB;gBACCqB,SAAS;gBACTC,OAAM;gBACNhB,OAAOA,MAAMiB,cAAc,IAAI;gBAC/BC,aAAa,CAAC,SAAS,EAAErB,yBAAyB;gBAClDsB,YAAY;oBACVC,UAAUlB;gBACZ;gBACAmB,iBAAiB;oBAAEC,QAAQpB,aAAa,OAAOqB;gBAAU;gBACzDtB,UAAU,CAACuB,IAAMvB,SAAS;wBAAE,GAAGD,KAAK;wBAAEiB,gBAAgBO,EAAEC,MAAM,CAACzB,KAAK;oBAAmB;;0BAEzF,KAACP;gBACCO,OAAOA;gBACPC,UAAUA;gBACVC,YAAYA;gBACZC,mBAAmBA;gBACnBE,kBAAkBA;;;;AAI1B"}
1
+ {"version":3,"sources":["../../../src/plugins/PrometheusDatasourceEditor.tsx"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { DurationString } from '@perses-dev/core';\nimport { HTTPSettingsEditor } from '@perses-dev/plugin-system';\nimport { Box, TextField, Typography, IconButton } from '@mui/material';\nimport PlusIcon from 'mdi-material-ui/Plus';\nimport MinusIcon from 'mdi-material-ui/Minus';\nimport React, { ReactElement, useState, useRef } from 'react';\nimport { DEFAULT_SCRAPE_INTERVAL, PrometheusDatasourceSpec } from './types';\n\ninterface QueryParamEntry {\n // Unique identifier for the entry, added to avoid using array index as key\n id: string;\n key: string;\n value: string;\n}\n\nexport interface PrometheusDatasourceEditorProps {\n value: PrometheusDatasourceSpec;\n onChange: (next: PrometheusDatasourceSpec) => void;\n isReadonly?: boolean;\n}\n\nexport function PrometheusDatasourceEditor(props: PrometheusDatasourceEditorProps): ReactElement {\n const { value, onChange, isReadonly } = props;\n\n // Counter for generating unique IDs\n const nextIdRef = useRef(0);\n\n // Use local state to maintain an array of entries during editing, instead of\n // manipulating a map directly which causes weird UX.\n const [entries, setEntries] = useState<QueryParamEntry[]>(() => {\n const queryParams = value.queryParams ?? {};\n return Object.entries(queryParams).map(([key, value]) => ({\n id: String(nextIdRef.current++),\n key,\n value,\n }));\n });\n\n // Check for duplicate keys\n const keyMap = new Map<string, number>();\n const duplicateKeys = new Set<string>();\n entries.forEach(({ key }) => {\n if (key !== '') {\n const count = (keyMap.get(key) || 0) + 1;\n keyMap.set(key, count);\n if (count > 1) {\n duplicateKeys.add(key);\n }\n }\n });\n const hasDuplicates = duplicateKeys.size > 0;\n\n // Convert entries array to object and trigger onChange\n const syncToParent = (newEntries: QueryParamEntry[]) => {\n const newParams: Record<string, string> = {};\n newEntries.forEach(({ key, value }) => {\n if (key !== '') {\n newParams[key] = value;\n }\n });\n\n onChange({\n ...value,\n queryParams: Object.keys(newParams).length > 0 ? newParams : undefined,\n });\n };\n\n const handleQueryParamChange = (id: string, field: 'key' | 'value', newValue: string) => {\n const newEntries = entries.map((entry) => {\n if (entry.id !== id) return entry;\n return field === 'key' ? { ...entry, key: newValue } : { ...entry, value: newValue };\n });\n setEntries(newEntries);\n syncToParent(newEntries);\n };\n\n const addQueryParam = () => {\n const newEntries = [...entries, { id: String(nextIdRef.current++), key: '', value: '' }];\n setEntries(newEntries);\n syncToParent(newEntries);\n };\n\n const removeQueryParam = (id: string) => {\n const newEntries = entries.filter((entry) => entry.id !== id);\n setEntries(newEntries);\n syncToParent(newEntries);\n };\n\n const initialSpecDirect: PrometheusDatasourceSpec = {\n directUrl: '',\n };\n\n const initialSpecProxy: PrometheusDatasourceSpec = {\n proxy: {\n kind: 'HTTPProxy',\n spec: {\n allowedEndpoints: [\n // list of standard endpoints suggested by default\n {\n endpointPattern: '/api/v1/labels',\n method: 'POST',\n },\n {\n endpointPattern: '/api/v1/series',\n method: 'POST',\n },\n {\n endpointPattern: '/api/v1/metadata',\n method: 'GET',\n },\n {\n endpointPattern: '/api/v1/query',\n method: 'POST',\n },\n {\n endpointPattern: '/api/v1/query_range',\n method: 'POST',\n },\n {\n endpointPattern: '/api/v1/label/([a-zA-Z0-9_-]+)/values',\n method: 'GET',\n },\n {\n endpointPattern: '/api/v1/parse_query',\n method: 'POST',\n },\n ],\n url: '',\n },\n },\n };\n\n return (\n <>\n <Typography variant=\"h4\" mb={2}>\n General Settings\n </Typography>\n <TextField\n size=\"small\"\n fullWidth\n label=\"Scrape Interval\"\n value={value.scrapeInterval || ''}\n placeholder={`Default: ${DEFAULT_SCRAPE_INTERVAL}`}\n InputProps={{\n readOnly: isReadonly,\n }}\n InputLabelProps={{ shrink: isReadonly ? true : undefined }}\n onChange={(e) => onChange({ ...value, scrapeInterval: e.target.value as DurationString })}\n helperText=\"Set it to match the typical scrape interval used in your Prometheus instance.\"\n />\n <HTTPSettingsEditor\n value={value}\n onChange={onChange}\n isReadonly={isReadonly}\n initialSpecDirect={initialSpecDirect}\n initialSpecProxy={initialSpecProxy}\n />\n <Typography variant=\"h5\" mt={2} mb={1}>\n Query Parameters\n </Typography>\n {entries.length > 0 && (\n <>\n {entries.map((entry) => (\n <Box key={entry.id} display=\"flex\" alignItems=\"center\" gap={2} mb={1}>\n <TextField\n size=\"small\"\n label=\"Key\"\n value={entry.key}\n placeholder=\"Parameter name\"\n disabled={isReadonly}\n onChange={(e) => handleQueryParamChange(entry.id, 'key', e.target.value)}\n error={duplicateKeys.has(entry.key)}\n sx={{ minWidth: 150 }}\n />\n <TextField\n size=\"small\"\n label=\"Value\"\n value={entry.value}\n placeholder=\"Parameter value\"\n disabled={isReadonly}\n onChange={(e) => handleQueryParamChange(entry.id, 'value', e.target.value)}\n sx={{ minWidth: 150, flexGrow: 1 }}\n />\n {!isReadonly && (\n <IconButton onClick={() => removeQueryParam(entry.id)}>\n <MinusIcon />\n </IconButton>\n )}\n </Box>\n ))}\n </>\n )}\n {hasDuplicates && (\n <Typography variant=\"body2\" color=\"error\" mb={1}>\n Duplicate parameter keys detected. Each key must be unique.\n </Typography>\n )}\n {entries.length === 0 && (\n <Typography variant=\"body2\" color=\"textSecondary\">\n No query parameters configured. Use query parameters to pass additional options to Prometheus (e.g.,\n dedup=false for Thanos).\n </Typography>\n )}\n {!isReadonly && (\n <IconButton onClick={addQueryParam}>\n <PlusIcon />\n </IconButton>\n )}\n </>\n );\n}\n"],"names":["HTTPSettingsEditor","Box","TextField","Typography","IconButton","PlusIcon","MinusIcon","React","useState","useRef","DEFAULT_SCRAPE_INTERVAL","PrometheusDatasourceEditor","props","value","onChange","isReadonly","nextIdRef","entries","setEntries","queryParams","Object","map","key","id","String","current","keyMap","Map","duplicateKeys","Set","forEach","count","get","set","add","hasDuplicates","size","syncToParent","newEntries","newParams","keys","length","undefined","handleQueryParamChange","field","newValue","entry","addQueryParam","removeQueryParam","filter","initialSpecDirect","directUrl","initialSpecProxy","proxy","kind","spec","allowedEndpoints","endpointPattern","method","url","variant","mb","fullWidth","label","scrapeInterval","placeholder","InputProps","readOnly","InputLabelProps","shrink","e","target","helperText","mt","display","alignItems","gap","disabled","error","has","sx","minWidth","flexGrow","onClick","color"],"mappings":"AAA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lD,OAAOiC,MAAMjC,KAAK;gCAClBoD,aAAY;gCACZY,UAAU9D;gCACVD,UAAU,CAACwD,IAAM3B,uBAAuBG,MAAMvB,EAAE,EAAE,SAAS+C,EAAEC,MAAM,CAAC1D,KAAK;gCACzEmE,IAAI;oCAAEC,UAAU;oCAAKC,UAAU;gCAAE;;4BAElC,CAACnE,4BACA,KAACX;gCAAW+E,SAAS,IAAMnC,iBAAiBF,MAAMvB,EAAE;0CAClD,cAAA,KAACjB;;;uBAtBGwC,MAAMvB,EAAE;;YA6BvBY,+BACC,KAAChC;gBAAWyD,SAAQ;gBAAQwB,OAAM;gBAAQvB,IAAI;0BAAG;;YAIlD5C,QAAQwB,MAAM,KAAK,mBAClB,KAACtC;gBAAWyD,SAAQ;gBAAQwB,OAAM;0BAAgB;;YAKnD,CAACrE,4BACA,KAACX;gBAAW+E,SAASpC;0BACnB,cAAA,KAAC1C;;;;AAKX"}
@@ -1 +1 @@
1
- {"version":3,"file":"PrometheusLabelNamesVariable.d.ts","sourceRoot":"","sources":["../../../src/plugins/PrometheusLabelNamesVariable.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EAMf,MAAM,2BAA2B,CAAC;AAGnC,OAAO,EAAE,mCAAmC,EAAE,MAAM,SAAS,CAAC;AAE9D,eAAO,MAAM,4BAA4B,EAAE,cAAc,CAAC,mCAAmC,CAyB5F,CAAC"}
1
+ {"version":3,"file":"PrometheusLabelNamesVariable.d.ts","sourceRoot":"","sources":["../../../src/plugins/PrometheusLabelNamesVariable.tsx"],"names":[],"mappings":"AAaA,OAAO,EACL,cAAc,EAMf,MAAM,2BAA2B,CAAC;AAGnC,OAAO,EAAE,mCAAmC,EAAE,MAAM,SAAS,CAAC;AAE9D,eAAO,MAAM,4BAA4B,EAAE,cAAc,CAAC,mCAAmC,CAyB5F,CAAC"}
@@ -1,3 +1,15 @@
1
+ // Copyright The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the \"License\");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an \"AS IS\" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
1
13
  import { replaceVariables, parseVariables, datasourceSelectValueToSelector, isVariableDatasource } from '@perses-dev/plugin-system';
2
14
  import { DEFAULT_PROM, getPrometheusTimeRange, PROM_DATASOURCE_KIND } from '../model';
3
15
  import { stringArrayToVariableOptions, PrometheusLabelNamesVariableEditor } from './prometheus-variables';