@perses-dev/plugin-system 0.54.0-beta.0 → 0.54.0-beta.10

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 (290) hide show
  1. package/dist/cjs/components/Annotations/AnnotationEditorForm/AnnotationEditorForm.js +283 -0
  2. package/dist/cjs/components/Annotations/AnnotationEditorForm/AnnotationPreview.js +197 -0
  3. package/dist/cjs/components/Annotations/AnnotationEditorForm/index.js +30 -0
  4. package/dist/cjs/components/Annotations/constants.js +23 -0
  5. package/dist/cjs/components/Annotations/index.js +31 -0
  6. package/dist/cjs/components/CalculationSelector/CalculationSelector.js +3 -3
  7. package/dist/cjs/components/DatasourceEditorForm/DatasourceEditorForm.js +2 -3
  8. package/dist/cjs/components/LegendOptionsEditor/LegendOptionsEditor.js +4 -5
  9. package/dist/cjs/components/MultiQueryEditor/QueryEditorContainer.js +97 -12
  10. package/dist/cjs/components/MultiQueryEditor/index.js +1 -0
  11. package/dist/cjs/{utils/action.js → components/MultiQueryEditor/utils.js} +8 -15
  12. package/dist/cjs/components/PanelSpecEditor/PanelSpecEditor.js +3 -6
  13. package/dist/cjs/components/PluginRegistry/PluginRegistry.js +11 -15
  14. package/dist/cjs/components/PluginRegistry/getPluginSearchHelper.js +92 -0
  15. package/dist/cjs/components/PluginRegistry/plugin-indexes.js +16 -13
  16. package/dist/cjs/components/Variables/VariableEditorForm/VariableEditorForm.js +2 -3
  17. package/dist/cjs/components/Variables/variable-model.js +115 -29
  18. package/dist/cjs/components/index.js +1 -0
  19. package/dist/cjs/context/ValidationProvider.js +10 -4
  20. package/dist/cjs/model/alerts-queries.js +16 -0
  21. package/dist/cjs/model/annotations.js +16 -0
  22. package/dist/cjs/model/calculations.js +178 -0
  23. package/dist/cjs/model/index.js +4 -0
  24. package/dist/cjs/model/legend.js +6 -5
  25. package/dist/cjs/model/log-volume-utils.js +10 -10
  26. package/dist/cjs/model/plugin-loading.js +24 -8
  27. package/dist/cjs/model/plugins.js +10 -0
  28. package/dist/cjs/model/silences-queries.js +16 -0
  29. package/dist/cjs/model/time-series-queries.js +10 -0
  30. package/dist/cjs/remote/PluginRuntime.js +46 -10
  31. package/dist/cjs/remote/remotePluginLoader.js +28 -5
  32. package/dist/cjs/runtime/DataQueriesProvider/DataQueriesProvider.js +33 -24
  33. package/dist/cjs/runtime/DataQueriesProvider/model.js +3 -93
  34. package/dist/cjs/runtime/UsageMetricsProvider.js +2 -2
  35. package/dist/cjs/runtime/alerts-queries.js +101 -0
  36. package/dist/cjs/runtime/annotations.js +148 -0
  37. package/dist/cjs/runtime/index.js +3 -1
  38. package/dist/cjs/runtime/item-actions.js +3 -3
  39. package/dist/cjs/runtime/log-queries.js +4 -1
  40. package/dist/cjs/runtime/plugin-registry.js +12 -3
  41. package/dist/cjs/runtime/profile-queries.js +4 -1
  42. package/dist/cjs/runtime/silences-queries.js +101 -0
  43. package/dist/cjs/runtime/time-series-queries.js +4 -1
  44. package/dist/cjs/runtime/trace-queries.js +4 -1
  45. package/dist/cjs/test/mock-data.js +51 -0
  46. package/dist/cjs/test/test-plugins/bert/index.js +9 -12
  47. package/dist/cjs/test/test-plugins/ernie/index.js +9 -12
  48. package/dist/cjs/test/test-plugins/index.js +2 -2
  49. package/dist/cjs/test/utils.js +2 -2
  50. package/dist/cjs/test-utils/mock-plugin-registry.js +8 -2
  51. package/dist/cjs/utils/index.js +0 -1
  52. package/dist/components/Annotations/AnnotationEditorForm/AnnotationEditorForm.d.ts +16 -0
  53. package/dist/components/Annotations/AnnotationEditorForm/AnnotationEditorForm.d.ts.map +1 -0
  54. package/dist/components/Annotations/AnnotationEditorForm/AnnotationEditorForm.js +270 -0
  55. package/dist/components/Annotations/AnnotationEditorForm/AnnotationEditorForm.js.map +1 -0
  56. package/dist/components/Annotations/AnnotationEditorForm/AnnotationPreview.d.ts +8 -0
  57. package/dist/components/Annotations/AnnotationEditorForm/AnnotationPreview.d.ts.map +1 -0
  58. package/dist/components/Annotations/AnnotationEditorForm/AnnotationPreview.js +184 -0
  59. package/dist/components/Annotations/AnnotationEditorForm/AnnotationPreview.js.map +1 -0
  60. package/dist/components/Annotations/AnnotationEditorForm/index.d.ts +2 -0
  61. package/dist/components/Annotations/AnnotationEditorForm/index.d.ts.map +1 -0
  62. package/dist/{runtime/QueryCountProvider.js → components/Annotations/AnnotationEditorForm/index.js} +2 -13
  63. package/dist/components/Annotations/AnnotationEditorForm/index.js.map +1 -0
  64. package/dist/components/Annotations/constants.d.ts +2 -0
  65. package/dist/components/Annotations/constants.d.ts.map +1 -0
  66. package/dist/components/Annotations/constants.js +15 -0
  67. package/dist/components/Annotations/constants.js.map +1 -0
  68. package/dist/components/Annotations/index.d.ts +3 -0
  69. package/dist/components/Annotations/index.d.ts.map +1 -0
  70. package/dist/components/Annotations/index.js +16 -0
  71. package/dist/components/Annotations/index.js.map +1 -0
  72. package/dist/components/CalculationSelector/CalculationSelector.d.ts +1 -1
  73. package/dist/components/CalculationSelector/CalculationSelector.d.ts.map +1 -1
  74. package/dist/components/CalculationSelector/CalculationSelector.js +2 -2
  75. package/dist/components/CalculationSelector/CalculationSelector.js.map +1 -1
  76. package/dist/components/DatasourceEditorForm/DatasourceEditorForm.d.ts +1 -1
  77. package/dist/components/DatasourceEditorForm/DatasourceEditorForm.d.ts.map +1 -1
  78. package/dist/components/DatasourceEditorForm/DatasourceEditorForm.js +2 -3
  79. package/dist/components/DatasourceEditorForm/DatasourceEditorForm.js.map +1 -1
  80. package/dist/components/DatasourceSelect/DatasourceSelect.js +2 -2
  81. package/dist/components/DatasourceSelect/DatasourceSelect.js.map +1 -1
  82. package/dist/components/HTTPSettingsEditor/HTTPSettingsEditor.d.ts +1 -1
  83. package/dist/components/HTTPSettingsEditor/HTTPSettingsEditor.d.ts.map +1 -1
  84. package/dist/components/HTTPSettingsEditor/HTTPSettingsEditor.js +2 -2
  85. package/dist/components/HTTPSettingsEditor/HTTPSettingsEditor.js.map +1 -1
  86. package/dist/components/ItemSelectionActionsOptionsEditor/ItemSelectionActionsOptionsEditor.js +1 -1
  87. package/dist/components/ItemSelectionActionsOptionsEditor/ItemSelectionActionsOptionsEditor.js.map +1 -1
  88. package/dist/components/LegendOptionsEditor/LegendOptionsEditor.d.ts.map +1 -1
  89. package/dist/components/LegendOptionsEditor/LegendOptionsEditor.js +2 -3
  90. package/dist/components/LegendOptionsEditor/LegendOptionsEditor.js.map +1 -1
  91. package/dist/components/MetricLabelInput/MetricLabelInput.js +1 -1
  92. package/dist/components/MetricLabelInput/MetricLabelInput.js.map +1 -1
  93. package/dist/components/MultiQueryEditor/MultiQueryEditor.d.ts +1 -1
  94. package/dist/components/MultiQueryEditor/MultiQueryEditor.js +1 -1
  95. package/dist/components/MultiQueryEditor/MultiQueryEditor.js.map +1 -1
  96. package/dist/components/MultiQueryEditor/QueryEditorContainer.d.ts.map +1 -1
  97. package/dist/components/MultiQueryEditor/QueryEditorContainer.js +100 -15
  98. package/dist/components/MultiQueryEditor/QueryEditorContainer.js.map +1 -1
  99. package/dist/components/MultiQueryEditor/index.d.ts +1 -0
  100. package/dist/components/MultiQueryEditor/index.d.ts.map +1 -1
  101. package/dist/components/MultiQueryEditor/index.js +1 -0
  102. package/dist/components/MultiQueryEditor/index.js.map +1 -1
  103. package/dist/components/MultiQueryEditor/utils.d.ts +8 -0
  104. package/dist/components/MultiQueryEditor/utils.d.ts.map +1 -0
  105. package/dist/{utils/action.js → components/MultiQueryEditor/utils.js} +8 -12
  106. package/dist/components/MultiQueryEditor/utils.js.map +1 -0
  107. package/dist/components/OptionsEditorRadios/OptionsEditorRadios.js +1 -1
  108. package/dist/components/OptionsEditorRadios/OptionsEditorRadios.js.map +1 -1
  109. package/dist/components/OptionsEditorTabPanel/OptionsEditorTabPanel.js +1 -1
  110. package/dist/components/OptionsEditorTabPanel/OptionsEditorTabPanel.js.map +1 -1
  111. package/dist/components/OptionsEditorTabs/OptionsEditorTabs.js +1 -1
  112. package/dist/components/OptionsEditorTabs/OptionsEditorTabs.js.map +1 -1
  113. package/dist/components/PanelSpecEditor/PanelSpecEditor.d.ts.map +1 -1
  114. package/dist/components/PanelSpecEditor/PanelSpecEditor.js +5 -8
  115. package/dist/components/PanelSpecEditor/PanelSpecEditor.js.map +1 -1
  116. package/dist/components/PluginEditor/PluginEditor.js +1 -1
  117. package/dist/components/PluginEditor/PluginEditor.js.map +1 -1
  118. package/dist/components/PluginKindSelect/PluginKindSelect.js +1 -1
  119. package/dist/components/PluginKindSelect/PluginKindSelect.js.map +1 -1
  120. package/dist/components/PluginRegistry/PluginRegistry.d.ts.map +1 -1
  121. package/dist/components/PluginRegistry/PluginRegistry.js +12 -16
  122. package/dist/components/PluginRegistry/PluginRegistry.js.map +1 -1
  123. package/dist/components/PluginRegistry/getPluginSearchHelper.d.ts +12 -0
  124. package/dist/components/PluginRegistry/getPluginSearchHelper.d.ts.map +1 -0
  125. package/dist/components/PluginRegistry/getPluginSearchHelper.js +88 -0
  126. package/dist/components/PluginRegistry/getPluginSearchHelper.js.map +1 -0
  127. package/dist/components/PluginRegistry/plugin-indexes.d.ts +4 -6
  128. package/dist/components/PluginRegistry/plugin-indexes.d.ts.map +1 -1
  129. package/dist/components/PluginRegistry/plugin-indexes.js +15 -13
  130. package/dist/components/PluginRegistry/plugin-indexes.js.map +1 -1
  131. package/dist/components/PluginSpecEditor/PluginSpecEditor.d.ts.map +1 -1
  132. package/dist/components/PluginSpecEditor/PluginSpecEditor.js +1 -1
  133. package/dist/components/PluginSpecEditor/PluginSpecEditor.js.map +1 -1
  134. package/dist/components/SelectionOptionsEditor/SelectionOptionsEditor.js +1 -1
  135. package/dist/components/SelectionOptionsEditor/SelectionOptionsEditor.js.map +1 -1
  136. package/dist/components/TimeRangeControls/TimeRangeControls.js +1 -1
  137. package/dist/components/TimeRangeControls/TimeRangeControls.js.map +1 -1
  138. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts +1 -1
  139. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts.map +1 -1
  140. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js +2 -3
  141. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js.map +1 -1
  142. package/dist/components/Variables/VariableEditorForm/VariablePreview.js +1 -1
  143. package/dist/components/Variables/VariableEditorForm/VariablePreview.js.map +1 -1
  144. package/dist/components/Variables/variable-model.d.ts +9 -1
  145. package/dist/components/Variables/variable-model.d.ts.map +1 -1
  146. package/dist/components/Variables/variable-model.js +117 -31
  147. package/dist/components/Variables/variable-model.js.map +1 -1
  148. package/dist/components/index.d.ts +1 -0
  149. package/dist/components/index.d.ts.map +1 -1
  150. package/dist/components/index.js +1 -0
  151. package/dist/components/index.js.map +1 -1
  152. package/dist/context/ValidationProvider.d.ts +4 -2
  153. package/dist/context/ValidationProvider.d.ts.map +1 -1
  154. package/dist/context/ValidationProvider.js +10 -4
  155. package/dist/context/ValidationProvider.js.map +1 -1
  156. package/dist/model/alerts-queries.d.ts +33 -0
  157. package/dist/model/alerts-queries.d.ts.map +1 -0
  158. package/dist/model/alerts-queries.js +15 -0
  159. package/dist/model/alerts-queries.js.map +1 -0
  160. package/dist/model/annotations.d.ts +28 -0
  161. package/dist/model/annotations.d.ts.map +1 -0
  162. package/dist/model/annotations.js +17 -0
  163. package/dist/model/annotations.js.map +1 -0
  164. package/dist/model/calculations.d.ts +45 -0
  165. package/dist/model/calculations.d.ts.map +1 -0
  166. package/dist/model/calculations.js +165 -0
  167. package/dist/model/calculations.js.map +1 -0
  168. package/dist/model/index.d.ts +4 -0
  169. package/dist/model/index.d.ts.map +1 -1
  170. package/dist/model/index.js +4 -0
  171. package/dist/model/index.js.map +1 -1
  172. package/dist/model/legend.d.ts +3 -2
  173. package/dist/model/legend.d.ts.map +1 -1
  174. package/dist/model/legend.js +2 -1
  175. package/dist/model/legend.js.map +1 -1
  176. package/dist/model/log-queries.d.ts +2 -1
  177. package/dist/model/log-queries.d.ts.map +1 -1
  178. package/dist/model/log-queries.js.map +1 -1
  179. package/dist/model/plugin-loading.d.ts.map +1 -1
  180. package/dist/model/plugin-loading.js +24 -8
  181. package/dist/model/plugin-loading.js.map +1 -1
  182. package/dist/model/plugins.d.ts +23 -0
  183. package/dist/model/plugins.d.ts.map +1 -1
  184. package/dist/model/plugins.js +4 -1
  185. package/dist/model/plugins.js.map +1 -1
  186. package/dist/model/silences-queries.d.ts +33 -0
  187. package/dist/model/silences-queries.d.ts.map +1 -0
  188. package/dist/model/silences-queries.js +15 -0
  189. package/dist/model/silences-queries.js.map +1 -0
  190. package/dist/model/time-series-queries.d.ts +11 -1
  191. package/dist/model/time-series-queries.d.ts.map +1 -1
  192. package/dist/model/time-series-queries.js +4 -1
  193. package/dist/model/time-series-queries.js.map +1 -1
  194. package/dist/model/trace-queries.d.ts +2 -3
  195. package/dist/model/trace-queries.d.ts.map +1 -1
  196. package/dist/model/trace-queries.js.map +1 -1
  197. package/dist/remote/PersesPlugin.types.d.ts +2 -0
  198. package/dist/remote/PersesPlugin.types.d.ts.map +1 -1
  199. package/dist/remote/PersesPlugin.types.js.map +1 -1
  200. package/dist/remote/PluginLoaderComponent.js +1 -1
  201. package/dist/remote/PluginLoaderComponent.js.map +1 -1
  202. package/dist/remote/PluginRuntime.d.ts +7 -1
  203. package/dist/remote/PluginRuntime.d.ts.map +1 -1
  204. package/dist/remote/PluginRuntime.js +46 -10
  205. package/dist/remote/PluginRuntime.js.map +1 -1
  206. package/dist/remote/remotePluginLoader.d.ts.map +1 -1
  207. package/dist/remote/remotePluginLoader.js +28 -5
  208. package/dist/remote/remotePluginLoader.js.map +1 -1
  209. package/dist/runtime/DataQueriesProvider/DataQueriesProvider.d.ts.map +1 -1
  210. package/dist/runtime/DataQueriesProvider/DataQueriesProvider.js +35 -26
  211. package/dist/runtime/DataQueriesProvider/DataQueriesProvider.js.map +1 -1
  212. package/dist/runtime/DataQueriesProvider/model.d.ts +4 -4
  213. package/dist/runtime/DataQueriesProvider/model.d.ts.map +1 -1
  214. package/dist/runtime/DataQueriesProvider/model.js +0 -82
  215. package/dist/runtime/DataQueriesProvider/model.js.map +1 -1
  216. package/dist/runtime/RouterProvider.js +1 -1
  217. package/dist/runtime/RouterProvider.js.map +1 -1
  218. package/dist/runtime/TimeRangeProvider/TimeRangeProvider.js +1 -1
  219. package/dist/runtime/TimeRangeProvider/TimeRangeProvider.js.map +1 -1
  220. package/dist/runtime/TimeRangeProvider/TimeRangeSettingsProvider.js +1 -1
  221. package/dist/runtime/TimeRangeProvider/TimeRangeSettingsProvider.js.map +1 -1
  222. package/dist/runtime/UsageMetricsProvider.js +2 -2
  223. package/dist/runtime/UsageMetricsProvider.js.map +1 -1
  224. package/dist/runtime/alerts-queries.d.ts +11 -0
  225. package/dist/runtime/alerts-queries.d.ts.map +1 -0
  226. package/dist/runtime/alerts-queries.js +89 -0
  227. package/dist/runtime/alerts-queries.js.map +1 -0
  228. package/dist/runtime/annotations.d.ts +6 -0
  229. package/dist/runtime/annotations.d.ts.map +1 -0
  230. package/dist/runtime/annotations.js +129 -0
  231. package/dist/runtime/annotations.js.map +1 -0
  232. package/dist/runtime/datasources.d.ts +6 -0
  233. package/dist/runtime/datasources.d.ts.map +1 -1
  234. package/dist/runtime/datasources.js.map +1 -1
  235. package/dist/runtime/index.d.ts +3 -1
  236. package/dist/runtime/index.d.ts.map +1 -1
  237. package/dist/runtime/index.js +3 -1
  238. package/dist/runtime/index.js.map +1 -1
  239. package/dist/runtime/item-actions.js +1 -1
  240. package/dist/runtime/item-actions.js.map +1 -1
  241. package/dist/runtime/log-queries.js +4 -1
  242. package/dist/runtime/log-queries.js.map +1 -1
  243. package/dist/runtime/plugin-registry.d.ts +2 -2
  244. package/dist/runtime/plugin-registry.d.ts.map +1 -1
  245. package/dist/runtime/plugin-registry.js +12 -3
  246. package/dist/runtime/plugin-registry.js.map +1 -1
  247. package/dist/runtime/profile-queries.js +4 -1
  248. package/dist/runtime/profile-queries.js.map +1 -1
  249. package/dist/runtime/silences-queries.d.ts +11 -0
  250. package/dist/runtime/silences-queries.d.ts.map +1 -0
  251. package/dist/runtime/silences-queries.js +89 -0
  252. package/dist/runtime/silences-queries.js.map +1 -0
  253. package/dist/runtime/time-series-queries.js +4 -1
  254. package/dist/runtime/time-series-queries.js.map +1 -1
  255. package/dist/runtime/trace-queries.js +4 -1
  256. package/dist/runtime/trace-queries.js.map +1 -1
  257. package/dist/test/mock-data.d.ts +3 -1
  258. package/dist/test/mock-data.d.ts.map +1 -1
  259. package/dist/test/mock-data.js +45 -0
  260. package/dist/test/mock-data.js.map +1 -1
  261. package/dist/test/render.js +1 -1
  262. package/dist/test/render.js.map +1 -1
  263. package/dist/test/test-plugins/bert/index.d.ts +12 -6
  264. package/dist/test/test-plugins/bert/index.d.ts.map +1 -1
  265. package/dist/test/test-plugins/bert/index.js +6 -2
  266. package/dist/test/test-plugins/bert/index.js.map +1 -1
  267. package/dist/test/test-plugins/ernie/index.d.ts +8 -6
  268. package/dist/test/test-plugins/ernie/index.d.ts.map +1 -1
  269. package/dist/test/test-plugins/ernie/index.js +6 -2
  270. package/dist/test/test-plugins/ernie/index.js.map +1 -1
  271. package/dist/test/test-plugins/index.js +2 -2
  272. package/dist/test/test-plugins/index.js.map +1 -1
  273. package/dist/test/utils.d.ts.map +1 -1
  274. package/dist/test/utils.js +2 -2
  275. package/dist/test/utils.js.map +1 -1
  276. package/dist/test-utils/mock-plugin-registry.d.ts.map +1 -1
  277. package/dist/test-utils/mock-plugin-registry.js +8 -2
  278. package/dist/test-utils/mock-plugin-registry.js.map +1 -1
  279. package/dist/utils/index.d.ts +0 -1
  280. package/dist/utils/index.d.ts.map +1 -1
  281. package/dist/utils/index.js +0 -1
  282. package/dist/utils/index.js.map +1 -1
  283. package/package.json +7 -6
  284. package/dist/cjs/runtime/QueryCountProvider.js +0 -83
  285. package/dist/runtime/QueryCountProvider.d.ts +0 -9
  286. package/dist/runtime/QueryCountProvider.d.ts.map +0 -1
  287. package/dist/runtime/QueryCountProvider.js.map +0 -1
  288. package/dist/utils/action.d.ts +0 -4
  289. package/dist/utils/action.d.ts.map +0 -1
  290. package/dist/utils/action.js.map +0 -1
@@ -1,3 +1,4 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
1
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.
@@ -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 } from "react/jsx-runtime";
14
14
  import React, { createContext, useContext, useMemo } from 'react';
15
15
  import { Link as RouterLink, useNavigate } from 'react-router-dom';
16
16
  export const RouterContext = /*#__PURE__*/ createContext(undefined);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/runtime/RouterProvider.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 React, { createContext, useContext, ReactNode, ReactElement, useMemo } from 'react';\nimport { Link as RouterLink, useNavigate } from 'react-router-dom';\n\ninterface LinkProps extends React.AnchorHTMLAttributes<HTMLAnchorElement> {\n to: string;\n}\n\nexport interface RouterContextType {\n RouterComponent?: (props: LinkProps & React.RefAttributes<HTMLAnchorElement>) => ReactNode;\n navigate?: (to: string) => void;\n}\n\nexport const RouterContext = createContext<RouterContextType | undefined>(undefined);\n\nexport function useRouterContext(): RouterContextType {\n const ctx = useContext(RouterContext);\n if (ctx === undefined) {\n console.warn('No RouterContext found. Did you forget a <RouterProvider>?');\n return {};\n }\n return ctx;\n}\n\ninterface RouterProviderProps {\n RouterComponent: RouterContextType['RouterComponent'];\n navigate: RouterContextType['navigate'];\n children?: React.ReactNode;\n}\n\n/**\n * Some panel plugins (TraceTable, ScatterPlot, TracingGanttChart) support linking to other pages,\n * e.g. clicking on a trace in the TraceTable should navigate to the TracingGanttChart.\n *\n * We can't use react-router in the panel, because panels might be embedded into React applications\n * which use a different routing library, or a different major version of react-router.\n *\n * This provider abstracts the basic routing functionality, to remove the dependency on the exact version of react-router.\n */\nexport function RouterProvider(props: RouterProviderProps): ReactElement {\n const { RouterComponent, navigate, children } = props;\n\n const ctx = useMemo(() => {\n return { RouterComponent, navigate };\n }, [RouterComponent, navigate]);\n\n return <RouterContext.Provider value={ctx}>{children}</RouterContext.Provider>;\n}\n\ninterface ReactRouterProviderProps {\n children?: React.ReactNode;\n}\n\n/** An implementation of RouterProvider for using the react-router library, shipped with Perses */\nexport function ReactRouterProvider(props: ReactRouterProviderProps): ReactElement {\n const { children } = props;\n const navigate = useNavigate();\n\n return (\n <RouterProvider RouterComponent={RouterLink} navigate={navigate}>\n {children}\n </RouterProvider>\n );\n}\n"],"names":["React","createContext","useContext","useMemo","Link","RouterLink","useNavigate","RouterContext","undefined","useRouterContext","ctx","console","warn","RouterProvider","props","RouterComponent","navigate","children","Provider","value","ReactRouterProvider"],"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,OAAOA,SAASC,aAAa,EAAEC,UAAU,EAA2BC,OAAO,QAAQ,QAAQ;AAC3F,SAASC,QAAQC,UAAU,EAAEC,WAAW,QAAQ,mBAAmB;AAWnE,OAAO,MAAMC,8BAAgBN,cAA6CO,WAAW;AAErF,OAAO,SAASC;IACd,MAAMC,MAAMR,WAAWK;IACvB,IAAIG,QAAQF,WAAW;QACrBG,QAAQC,IAAI,CAAC;QACb,OAAO,CAAC;IACV;IACA,OAAOF;AACT;AAQA;;;;;;;;CAQC,GACD,OAAO,SAASG,eAAeC,KAA0B;IACvD,MAAM,EAAEC,eAAe,EAAEC,QAAQ,EAAEC,QAAQ,EAAE,GAAGH;IAEhD,MAAMJ,MAAMP,QAAQ;QAClB,OAAO;YAAEY;YAAiBC;QAAS;IACrC,GAAG;QAACD;QAAiBC;KAAS;IAE9B,qBAAO,KAACT,cAAcW,QAAQ;QAACC,OAAOT;kBAAMO;;AAC9C;AAMA,gGAAgG,GAChG,OAAO,SAASG,oBAAoBN,KAA+B;IACjE,MAAM,EAAEG,QAAQ,EAAE,GAAGH;IACrB,MAAME,WAAWV;IAEjB,qBACE,KAACO;QAAeE,iBAAiBV;QAAYW,UAAUA;kBACpDC;;AAGP"}
1
+ {"version":3,"sources":["../../src/runtime/RouterProvider.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 React, { createContext, useContext, ReactNode, ReactElement, useMemo } from 'react';\nimport { Link as RouterLink, useNavigate } from 'react-router-dom';\n\ninterface LinkProps extends React.AnchorHTMLAttributes<HTMLAnchorElement> {\n to: string;\n}\n\nexport interface RouterContextType {\n RouterComponent?: (props: LinkProps & React.RefAttributes<HTMLAnchorElement>) => ReactNode;\n navigate?: (to: string) => void;\n}\n\nexport const RouterContext = createContext<RouterContextType | undefined>(undefined);\n\nexport function useRouterContext(): RouterContextType {\n const ctx = useContext(RouterContext);\n if (ctx === undefined) {\n console.warn('No RouterContext found. Did you forget a <RouterProvider>?');\n return {};\n }\n return ctx;\n}\n\ninterface RouterProviderProps {\n RouterComponent: RouterContextType['RouterComponent'];\n navigate: RouterContextType['navigate'];\n children?: React.ReactNode;\n}\n\n/**\n * Some panel plugins (TraceTable, ScatterPlot, TracingGanttChart) support linking to other pages,\n * e.g. clicking on a trace in the TraceTable should navigate to the TracingGanttChart.\n *\n * We can't use react-router in the panel, because panels might be embedded into React applications\n * which use a different routing library, or a different major version of react-router.\n *\n * This provider abstracts the basic routing functionality, to remove the dependency on the exact version of react-router.\n */\nexport function RouterProvider(props: RouterProviderProps): ReactElement {\n const { RouterComponent, navigate, children } = props;\n\n const ctx = useMemo(() => {\n return { RouterComponent, navigate };\n }, [RouterComponent, navigate]);\n\n return <RouterContext.Provider value={ctx}>{children}</RouterContext.Provider>;\n}\n\ninterface ReactRouterProviderProps {\n children?: React.ReactNode;\n}\n\n/** An implementation of RouterProvider for using the react-router library, shipped with Perses */\nexport function ReactRouterProvider(props: ReactRouterProviderProps): ReactElement {\n const { children } = props;\n const navigate = useNavigate();\n\n return (\n <RouterProvider RouterComponent={RouterLink} navigate={navigate}>\n {children}\n </RouterProvider>\n );\n}\n"],"names":["React","createContext","useContext","useMemo","Link","RouterLink","useNavigate","RouterContext","undefined","useRouterContext","ctx","console","warn","RouterProvider","props","RouterComponent","navigate","children","Provider","value","ReactRouterProvider"],"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,OAAOA,SAASC,aAAa,EAAEC,UAAU,EAA2BC,OAAO,QAAQ,QAAQ;AAC3F,SAASC,QAAQC,UAAU,EAAEC,WAAW,QAAQ,mBAAmB;AAWnE,OAAO,MAAMC,8BAAgBN,cAA6CO,WAAW;AAErF,OAAO,SAASC;IACd,MAAMC,MAAMR,WAAWK;IACvB,IAAIG,QAAQF,WAAW;QACrBG,QAAQC,IAAI,CAAC;QACb,OAAO,CAAC;IACV;IACA,OAAOF;AACT;AAQA;;;;;;;;CAQC,GACD,OAAO,SAASG,eAAeC,KAA0B;IACvD,MAAM,EAAEC,eAAe,EAAEC,QAAQ,EAAEC,QAAQ,EAAE,GAAGH;IAEhD,MAAMJ,MAAMP,QAAQ;QAClB,OAAO;YAAEY;YAAiBC;QAAS;IACrC,GAAG;QAACD;QAAiBC;KAAS;IAE9B,qBAAO,KAACT,cAAcW,QAAQ;QAACC,OAAOT;kBAAMO;;AAC9C;AAMA,gGAAgG,GAChG,OAAO,SAASG,oBAAoBN,KAA+B;IACjE,MAAM,EAAEG,QAAQ,EAAE,GAAGH;IACrB,MAAME,WAAWV;IAEjB,qBACE,KAACO;QAAeE,iBAAiBV;QAAYW,UAAUA;kBACpDC;;AAGP"}
@@ -1,3 +1,4 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
1
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.
@@ -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 } from "react/jsx-runtime";
14
14
  import React, { createContext, useCallback, useContext, useEffect, useMemo, useState } from 'react';
15
15
  import { isRelativeTimeRange, toAbsoluteTimeRange, getSuggestedStepMs } from '@perses-dev/spec';
16
16
  import { useQueryClient } from '@tanstack/react-query';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/runtime/TimeRangeProvider/TimeRangeProvider.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 React, { createContext, ReactElement, useCallback, useContext, useEffect, useMemo, useState } from 'react';\nimport {\n AbsoluteTimeRange,\n DurationString,\n TimeRangeValue,\n isRelativeTimeRange,\n toAbsoluteTimeRange,\n getSuggestedStepMs,\n} from '@perses-dev/spec';\nimport { useQueryClient } from '@tanstack/react-query';\nimport { getRefreshIntervalInMs } from './refresh-interval';\n\nexport interface TimeRangeProviderProps {\n timeRange: TimeRangeValue;\n refreshInterval?: DurationString;\n setTimeRange: (value: TimeRangeValue) => void;\n setRefreshInterval: (value: DurationString) => void;\n children?: React.ReactNode;\n}\n\nexport interface TimeRange {\n timeRange: TimeRangeValue;\n absoluteTimeRange: AbsoluteTimeRange; // resolved absolute time for plugins to use\n setTimeRange: (value: TimeRangeValue) => void;\n refresh: () => void;\n refreshInterval?: DurationString;\n refreshIntervalInMs: number;\n setRefreshInterval: (value: DurationString) => void;\n}\n\nexport const TimeRangeContext = createContext<TimeRange | undefined>(undefined);\n\nexport function useTimeRangeContext(): TimeRange {\n const ctx = useContext(TimeRangeContext);\n if (ctx === undefined) {\n throw new Error('No TimeRangeContext found. Did you forget a Provider?');\n }\n return ctx;\n}\n\n/**\n * Get and set the current resolved time range at runtime.\n */\nexport function useTimeRange(): TimeRange {\n return useTimeRangeContext();\n}\n\n/**\n * Gets the suggested step for a graph query in ms for the currently selected time range.\n */\nexport function useSuggestedStepMs(width?: number): number {\n const { absoluteTimeRange } = useTimeRange();\n if (width === undefined) return 0;\n return getSuggestedStepMs(absoluteTimeRange, width);\n}\n\n/**\n * Provider implementation that supplies the time range state at runtime.\n */\nexport function TimeRangeProvider(props: TimeRangeProviderProps): ReactElement {\n const { timeRange, refreshInterval, children, setTimeRange, setRefreshInterval } = props;\n\n const queryClient = useQueryClient();\n const [absoluteTimeRange, setAbsoluteTimeRange] = useState<AbsoluteTimeRange>(\n isRelativeTimeRange(timeRange) ? toAbsoluteTimeRange(timeRange) : timeRange\n );\n\n const handleSetTimeRange = useCallback(\n (value: TimeRangeValue) => {\n setTimeRange(value);\n setAbsoluteTimeRange(isRelativeTimeRange(value) ? toAbsoluteTimeRange(value) : value);\n },\n [setTimeRange]\n );\n\n // Refresh is called when clicking on the refresh button, it refreshes all queries including variables\n const refresh = useCallback(() => {\n setAbsoluteTimeRange(isRelativeTimeRange(timeRange) ? toAbsoluteTimeRange(timeRange) : timeRange);\n queryClient\n .invalidateQueries({ queryKey: ['query'] })\n .finally(() => queryClient.removeQueries({ queryKey: ['query'], type: 'inactive' }));\n queryClient\n .invalidateQueries({ queryKey: ['variable'] })\n .finally(() => queryClient.removeQueries({ queryKey: ['variable'], type: 'inactive' }));\n }, [queryClient, timeRange]);\n\n // Auto refresh is only refreshing queries of panels\n const autoRefresh = useCallback(() => {\n setAbsoluteTimeRange(isRelativeTimeRange(timeRange) ? toAbsoluteTimeRange(timeRange) : timeRange);\n queryClient.invalidateQueries({ queryKey: ['query'] }).finally(() => {\n queryClient.removeQueries({ queryKey: ['query'], type: 'inactive' });\n queryClient.removeQueries({ queryKey: ['variable'], type: 'inactive' }); // Timerange is in queryKey, can lead to memory leak when using relative timerange\n });\n }, [queryClient, timeRange]);\n\n const refreshIntervalInMs = useMemo(() => getRefreshIntervalInMs(refreshInterval), [refreshInterval]);\n useEffect(() => {\n if (refreshIntervalInMs > 0) {\n const interval = setInterval(() => {\n autoRefresh();\n }, refreshIntervalInMs);\n\n return (): void => clearInterval(interval);\n }\n }, [autoRefresh, refreshIntervalInMs]);\n\n const ctx = useMemo(() => {\n return {\n timeRange: timeRange,\n setTimeRange: handleSetTimeRange,\n absoluteTimeRange: absoluteTimeRange,\n refresh,\n refreshInterval: refreshInterval,\n refreshIntervalInMs: refreshIntervalInMs,\n setRefreshInterval: setRefreshInterval,\n };\n }, [\n absoluteTimeRange,\n handleSetTimeRange,\n refresh,\n refreshInterval,\n refreshIntervalInMs,\n setRefreshInterval,\n timeRange,\n ]);\n\n return <TimeRangeContext.Provider value={ctx}>{children}</TimeRangeContext.Provider>;\n}\n"],"names":["React","createContext","useCallback","useContext","useEffect","useMemo","useState","isRelativeTimeRange","toAbsoluteTimeRange","getSuggestedStepMs","useQueryClient","getRefreshIntervalInMs","TimeRangeContext","undefined","useTimeRangeContext","ctx","Error","useTimeRange","useSuggestedStepMs","width","absoluteTimeRange","TimeRangeProvider","props","timeRange","refreshInterval","children","setTimeRange","setRefreshInterval","queryClient","setAbsoluteTimeRange","handleSetTimeRange","value","refresh","invalidateQueries","queryKey","finally","removeQueries","type","autoRefresh","refreshIntervalInMs","interval","setInterval","clearInterval","Provider"],"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,OAAOA,SAASC,aAAa,EAAgBC,WAAW,EAAEC,UAAU,EAAEC,SAAS,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,QAAQ;AAClH,SAIEC,mBAAmB,EACnBC,mBAAmB,EACnBC,kBAAkB,QACb,mBAAmB;AAC1B,SAASC,cAAc,QAAQ,wBAAwB;AACvD,SAASC,sBAAsB,QAAQ,qBAAqB;AAoB5D,OAAO,MAAMC,iCAAmBX,cAAqCY,WAAW;AAEhF,OAAO,SAASC;IACd,MAAMC,MAAMZ,WAAWS;IACvB,IAAIG,QAAQF,WAAW;QACrB,MAAM,IAAIG,MAAM;IAClB;IACA,OAAOD;AACT;AAEA;;CAEC,GACD,OAAO,SAASE;IACd,OAAOH;AACT;AAEA;;CAEC,GACD,OAAO,SAASI,mBAAmBC,KAAc;IAC/C,MAAM,EAAEC,iBAAiB,EAAE,GAAGH;IAC9B,IAAIE,UAAUN,WAAW,OAAO;IAChC,OAAOJ,mBAAmBW,mBAAmBD;AAC/C;AAEA;;CAEC,GACD,OAAO,SAASE,kBAAkBC,KAA6B;IAC7D,MAAM,E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UAAU;QACR,IAAImC,sBAAsB,GAAG;YAC3B,MAAMC,WAAWC,YAAY;gBAC3BH;YACF,GAAGC;YAEH,OAAO,IAAYG,cAAcF;QACnC;IACF,GAAG;QAACF;QAAaC;KAAoB;IAErC,MAAMxB,MAAMV,QAAQ;QAClB,OAAO;YACLkB,WAAWA;YACXG,cAAcI;YACdV,mBAAmBA;YACnBY;YACAR,iBAAiBA;YACjBe,qBAAqBA;YACrBZ,oBAAoBA;QACtB;IACF,GAAG;QACDP;QACAU;QACAE;QACAR;QACAe;QACAZ;QACAJ;KACD;IAED,qBAAO,KAACX,iBAAiB+B,QAAQ;QAACZ,OAAOhB;kBAAMU;;AACjD"}
1
+ {"version":3,"sources":["../../../src/runtime/TimeRangeProvider/TimeRangeProvider.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 React, { createContext, ReactElement, useCallback, useContext, useEffect, useMemo, useState } from 'react';\nimport {\n AbsoluteTimeRange,\n DurationString,\n TimeRangeValue,\n isRelativeTimeRange,\n toAbsoluteTimeRange,\n getSuggestedStepMs,\n} from '@perses-dev/spec';\nimport { useQueryClient } from '@tanstack/react-query';\nimport { getRefreshIntervalInMs } from './refresh-interval';\n\nexport interface TimeRangeProviderProps {\n timeRange: TimeRangeValue;\n refreshInterval?: DurationString;\n setTimeRange: (value: TimeRangeValue) => void;\n setRefreshInterval: (value: DurationString) => void;\n children?: React.ReactNode;\n}\n\nexport interface TimeRange {\n timeRange: TimeRangeValue;\n absoluteTimeRange: AbsoluteTimeRange; // resolved absolute time for plugins to use\n setTimeRange: (value: TimeRangeValue) => void;\n refresh: () => void;\n refreshInterval?: DurationString;\n refreshIntervalInMs: number;\n setRefreshInterval: (value: DurationString) => void;\n}\n\nexport const TimeRangeContext = createContext<TimeRange | undefined>(undefined);\n\nexport function useTimeRangeContext(): TimeRange {\n const ctx = useContext(TimeRangeContext);\n if (ctx === undefined) {\n throw new Error('No TimeRangeContext found. Did you forget a Provider?');\n }\n return ctx;\n}\n\n/**\n * Get and set the current resolved time range at runtime.\n */\nexport function useTimeRange(): TimeRange {\n return useTimeRangeContext();\n}\n\n/**\n * Gets the suggested step for a graph query in ms for the currently selected time range.\n */\nexport function useSuggestedStepMs(width?: number): number {\n const { absoluteTimeRange } = useTimeRange();\n if (width === undefined) return 0;\n return getSuggestedStepMs(absoluteTimeRange, width);\n}\n\n/**\n * Provider implementation that supplies the time range state at runtime.\n */\nexport function TimeRangeProvider(props: TimeRangeProviderProps): ReactElement {\n const { timeRange, refreshInterval, children, setTimeRange, setRefreshInterval } = props;\n\n const queryClient = useQueryClient();\n const [absoluteTimeRange, setAbsoluteTimeRange] = useState<AbsoluteTimeRange>(\n isRelativeTimeRange(timeRange) ? toAbsoluteTimeRange(timeRange) : timeRange\n );\n\n const handleSetTimeRange = useCallback(\n (value: TimeRangeValue) => {\n setTimeRange(value);\n setAbsoluteTimeRange(isRelativeTimeRange(value) ? toAbsoluteTimeRange(value) : value);\n },\n [setTimeRange]\n );\n\n // Refresh is called when clicking on the refresh button, it refreshes all queries including variables\n const refresh = useCallback(() => {\n setAbsoluteTimeRange(isRelativeTimeRange(timeRange) ? toAbsoluteTimeRange(timeRange) : timeRange);\n queryClient\n .invalidateQueries({ queryKey: ['query'] })\n .finally(() => queryClient.removeQueries({ queryKey: ['query'], type: 'inactive' }));\n queryClient\n .invalidateQueries({ queryKey: ['variable'] })\n .finally(() => queryClient.removeQueries({ queryKey: ['variable'], type: 'inactive' }));\n }, [queryClient, timeRange]);\n\n // Auto refresh is only refreshing queries of panels\n const autoRefresh = useCallback(() => {\n setAbsoluteTimeRange(isRelativeTimeRange(timeRange) ? toAbsoluteTimeRange(timeRange) : timeRange);\n queryClient.invalidateQueries({ queryKey: ['query'] }).finally(() => {\n queryClient.removeQueries({ queryKey: ['query'], type: 'inactive' });\n queryClient.removeQueries({ queryKey: ['variable'], type: 'inactive' }); // Timerange is in queryKey, can lead to memory leak when using relative timerange\n });\n }, [queryClient, timeRange]);\n\n const refreshIntervalInMs = useMemo(() => getRefreshIntervalInMs(refreshInterval), [refreshInterval]);\n useEffect(() => {\n if (refreshIntervalInMs > 0) {\n const interval = setInterval(() => {\n autoRefresh();\n }, refreshIntervalInMs);\n\n return (): void => clearInterval(interval);\n }\n }, [autoRefresh, refreshIntervalInMs]);\n\n const ctx = useMemo(() => {\n return {\n timeRange: timeRange,\n setTimeRange: handleSetTimeRange,\n absoluteTimeRange: absoluteTimeRange,\n refresh,\n refreshInterval: refreshInterval,\n refreshIntervalInMs: refreshIntervalInMs,\n setRefreshInterval: setRefreshInterval,\n };\n }, [\n absoluteTimeRange,\n handleSetTimeRange,\n refresh,\n refreshInterval,\n refreshIntervalInMs,\n setRefreshInterval,\n timeRange,\n ]);\n\n return <TimeRangeContext.Provider value={ctx}>{children}</TimeRangeContext.Provider>;\n}\n"],"names":["React","createContext","useCallback","useContext","useEffect","useMemo","useState","isRelativeTimeRange","toAbsoluteTimeRange","getSuggestedStepMs","useQueryClient","getRefreshIntervalInMs","TimeRangeContext","undefined","useTimeRangeContext","ctx","Error","useTimeRange","useSuggestedStepMs","width","absoluteTimeRange","TimeRangeProvider","props","timeRange","refreshInterval","children","setTimeRange","setRefreshInterval","queryClient","setAbsoluteTimeRange","handleSetTimeRange","value","refresh","invalidateQueries","queryKey","finally","removeQueries","type","autoRefresh","refreshIntervalInMs","interval","setInterval","clearInterval","Provider"],"mappings":";AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE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
  // Licensed under the Apache License, Version 2.0 (the "License");
3
4
  // you may not use this file except in compliance with the License.
@@ -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 } from "react/jsx-runtime";
14
14
  import { createContext, useContext, useMemo } from 'react';
15
15
  import { buildRelativeTimeOption } from '@perses-dev/components';
16
16
  const DEFAULT_OPTIONS = [
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/runtime/TimeRangeProvider/TimeRangeSettingsProvider.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 { createContext, ReactElement, ReactNode, useContext, useMemo } from 'react';\nimport { buildRelativeTimeOption, TimeOption } from '@perses-dev/components';\nimport { DurationString } from '@perses-dev/spec';\n\nconst DEFAULT_OPTIONS: DurationString[] = ['5m', '15m', '30m', '1h', '6h', '12h', '24h', '7d', '14d'];\nconst defaultTimeRangeSettings: TimeRangeSettings = {\n showCustom: true,\n showZoomButtons: true,\n options: DEFAULT_OPTIONS.map((duration) => buildRelativeTimeOption(duration)),\n};\n\nexport interface TimeRangeSettingsProviderProps {\n showCustom?: boolean;\n showZoomButtons?: boolean;\n options?: TimeOption[];\n children: ReactNode;\n}\n\nexport interface TimeRangeSettings {\n showCustom: boolean;\n showZoomButtons: boolean;\n options: TimeOption[];\n}\n\nexport const TimeRangeSettingsContext = createContext<TimeRangeSettings>(defaultTimeRangeSettings);\n\nexport function useTimeRangeSettingsContext(): TimeRangeSettings {\n const ctx = useContext(TimeRangeSettingsContext);\n if (ctx === undefined) {\n throw new Error('No TimeRangeContext found. Did you forget a Provider?');\n }\n return ctx;\n}\n\n/**\n * Get and set the current resolved time range at runtime.\n */\nexport function useTimeRangeSettings(): TimeRangeSettings {\n return useTimeRangeSettingsContext();\n}\n\n/**\n * Get the current value of the showCustom setting.\n * @param override If set, the value of the provider will be overridden by this value.\n */\nexport function useShowCustomTimeRangeSetting(override?: boolean): boolean {\n const showCustomTimeRange = useTimeRangeSettings().showCustom;\n if (override !== undefined) {\n return override;\n }\n return showCustomTimeRange;\n}\n\n/**\n * Get the current value of the showZoomButtons setting.\n * @param override If set, the value of the provider will be overridden by this value.\n */\nexport function useShowZoomRangeSetting(override?: boolean): boolean {\n const showZoomTimeRange = useTimeRangeSettings().showZoomButtons;\n if (override !== undefined) {\n return override;\n }\n return showZoomTimeRange;\n}\n\n/**\n * Get the current value of the options setting.\n * @param override If set, the value of the provider will be overridden by this value.\n */\nexport function useTimeRangeOptionsSetting(override?: TimeOption[]): TimeOption[] {\n const showCustomTimeRange = useTimeRangeSettings().options;\n if (override !== undefined) {\n return override;\n }\n return showCustomTimeRange;\n}\n\n/**\n * Provider implementation that supplies the time range state at runtime.\n */\nexport function TimeRangeSettingsProvider(props: TimeRangeSettingsProviderProps): ReactElement {\n const ctx = useMemo(() => {\n return {\n showCustom: props.showCustom === undefined ? defaultTimeRangeSettings.showCustom : props.showCustom,\n showZoomButtons:\n props.showZoomButtons === undefined ? defaultTimeRangeSettings.showZoomButtons : props.showZoomButtons,\n options: props.options === undefined ? defaultTimeRangeSettings.options : props.options,\n };\n }, [props.showCustom, props.showZoomButtons, props.options]);\n\n return <TimeRangeSettingsContext.Provider value={ctx}>{props.children}</TimeRangeSettingsContext.Provider>;\n}\n"],"names":["createContext","useContext","useMemo","buildRelativeTimeOption","DEFAULT_OPTIONS","defaultTimeRangeSettings","showCustom","showZoomButtons","options","map","duration","TimeRangeSettingsContext","useTimeRangeSettingsContext","ctx","undefined","Error","useTimeRangeSettings","useShowCustomTimeRangeSetting","override","showCustomTimeRange","useShowZoomRangeSetting","showZoomTimeRange","useTimeRangeOptionsSetting","TimeRangeSettingsProvider","props","Provider","value","children"],"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,aAAa,EAA2BC,UAAU,EAAEC,OAAO,QAAQ,QAAQ;AACpF,SAASC,uBAAuB,QAAoB,yBAAyB;AAG7E,MAAMC,kBAAoC;IAAC;IAAM;IAAO;IAAO;IAAM;IAAM;IAAO;IAAO;IAAM;CAAM;AACrG,MAAMC,2BAA8C;IAClDC,YAAY;IACZC,iBAAiB;IACjBC,SAASJ,gBAAgBK,GAAG,CAAC,CAACC,WAAaP,wBAAwBO;AACrE;AAeA,OAAO,MAAMC,yCAA2BX,cAAiCK,0BAA0B;AAEnG,OAAO,SAASO;IACd,MAAMC,MAAMZ,WAAWU;IACvB,IAAIE,QAAQC,WAAW;QACrB,MAAM,IAAIC,MAAM;IAClB;IACA,OAAOF;AACT;AAEA;;CAEC,GACD,OAAO,SAASG;IACd,OAAOJ;AACT;AAEA;;;CAGC,GACD,OAAO,SAASK,8BAA8BC,QAAkB;IAC9D,MAAMC,sBAAsBH,uBAAuBV,UAAU;IAC7D,IAAIY,aAAaJ,WAAW;QAC1B,OAAOI;IACT;IACA,OAAOC;AACT;AAEA;;;CAGC,GACD,OAAO,SAASC,wBAAwBF,QAAkB;IACxD,MAAMG,oBAAoBL,uBAAuBT,eAAe;IAChE,IAAIW,aAAaJ,WAAW;QAC1B,OAAOI;IACT;IACA,OAAOG;AACT;AAEA;;;CAGC,GACD,OAAO,SAASC,2BAA2BJ,QAAuB;IAChE,MAAMC,sBAAsBH,uBAAuBR,OAAO;IAC1D,IAAIU,aAAaJ,WAAW;QAC1B,OAAOI;IACT;IACA,OAAOC;AACT;AAEA;;CAEC,GACD,OAAO,SAASI,0BAA0BC,KAAqC;IAC7E,MAAMX,MAAMX,QAAQ;QAClB,OAAO;YACLI,YAAYkB,MAAMlB,UAAU,KAAKQ,YAAYT,yBAAyBC,UAAU,GAAGkB,MAAMlB,UAAU;YACnGC,iBACEiB,MAAMjB,eAAe,KAAKO,YAAYT,yBAAyBE,eAAe,GAAGiB,MAAMjB,eAAe;YACxGC,SAASgB,MAAMhB,OAAO,KAAKM,YAAYT,yBAAyBG,OAAO,GAAGgB,MAAMhB,OAAO;QACzF;IACF,GAAG;QAACgB,MAAMlB,UAAU;QAAEkB,MAAMjB,eAAe;QAAEiB,MAAMhB,OAAO;KAAC;IAE3D,qBAAO,KAACG,yBAAyBc,QAAQ;QAACC,OAAOb;kBAAMW,MAAMG,QAAQ;;AACvE"}
1
+ {"version":3,"sources":["../../../src/runtime/TimeRangeProvider/TimeRangeSettingsProvider.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 { createContext, ReactElement, ReactNode, useContext, useMemo } from 'react';\nimport { buildRelativeTimeOption, TimeOption } from '@perses-dev/components';\nimport { DurationString } from '@perses-dev/spec';\n\nconst DEFAULT_OPTIONS: DurationString[] = ['5m', '15m', '30m', '1h', '6h', '12h', '24h', '7d', '14d'];\nconst defaultTimeRangeSettings: TimeRangeSettings = {\n showCustom: true,\n showZoomButtons: true,\n options: DEFAULT_OPTIONS.map((duration) => buildRelativeTimeOption(duration)),\n};\n\nexport interface TimeRangeSettingsProviderProps {\n showCustom?: boolean;\n showZoomButtons?: boolean;\n options?: TimeOption[];\n children: ReactNode;\n}\n\nexport interface TimeRangeSettings {\n showCustom: boolean;\n showZoomButtons: boolean;\n options: TimeOption[];\n}\n\nexport const TimeRangeSettingsContext = createContext<TimeRangeSettings>(defaultTimeRangeSettings);\n\nexport function useTimeRangeSettingsContext(): TimeRangeSettings {\n const ctx = useContext(TimeRangeSettingsContext);\n if (ctx === undefined) {\n throw new Error('No TimeRangeContext found. Did you forget a Provider?');\n }\n return ctx;\n}\n\n/**\n * Get and set the current resolved time range at runtime.\n */\nexport function useTimeRangeSettings(): TimeRangeSettings {\n return useTimeRangeSettingsContext();\n}\n\n/**\n * Get the current value of the showCustom setting.\n * @param override If set, the value of the provider will be overridden by this value.\n */\nexport function useShowCustomTimeRangeSetting(override?: boolean): boolean {\n const showCustomTimeRange = useTimeRangeSettings().showCustom;\n if (override !== undefined) {\n return override;\n }\n return showCustomTimeRange;\n}\n\n/**\n * Get the current value of the showZoomButtons setting.\n * @param override If set, the value of the provider will be overridden by this value.\n */\nexport function useShowZoomRangeSetting(override?: boolean): boolean {\n const showZoomTimeRange = useTimeRangeSettings().showZoomButtons;\n if (override !== undefined) {\n return override;\n }\n return showZoomTimeRange;\n}\n\n/**\n * Get the current value of the options setting.\n * @param override If set, the value of the provider will be overridden by this value.\n */\nexport function useTimeRangeOptionsSetting(override?: TimeOption[]): TimeOption[] {\n const showCustomTimeRange = useTimeRangeSettings().options;\n if (override !== undefined) {\n return override;\n }\n return showCustomTimeRange;\n}\n\n/**\n * Provider implementation that supplies the time range state at runtime.\n */\nexport function TimeRangeSettingsProvider(props: TimeRangeSettingsProviderProps): ReactElement {\n const ctx = useMemo(() => {\n return {\n showCustom: props.showCustom === undefined ? defaultTimeRangeSettings.showCustom : props.showCustom,\n showZoomButtons:\n props.showZoomButtons === undefined ? defaultTimeRangeSettings.showZoomButtons : props.showZoomButtons,\n options: props.options === undefined ? defaultTimeRangeSettings.options : props.options,\n };\n }, [props.showCustom, props.showZoomButtons, props.options]);\n\n return <TimeRangeSettingsContext.Provider value={ctx}>{props.children}</TimeRangeSettingsContext.Provider>;\n}\n"],"names":["createContext","useContext","useMemo","buildRelativeTimeOption","DEFAULT_OPTIONS","defaultTimeRangeSettings","showCustom","showZoomButtons","options","map","duration","TimeRangeSettingsContext","useTimeRangeSettingsContext","ctx","undefined","Error","useTimeRangeSettings","useShowCustomTimeRangeSetting","override","showCustomTimeRange","useShowZoomRangeSetting","showZoomTimeRange","useTimeRangeOptionsSetting","TimeRangeSettingsProvider","props","Provider","value","children"],"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,aAAa,EAA2BC,UAAU,EAAEC,OAAO,QAAQ,QAAQ;AACpF,SAASC,uBAAuB,QAAoB,yBAAyB;AAG7E,MAAMC,kBAAoC;IAAC;IAAM;IAAO;IAAO;IAAM;IAAM;IAAO;IAAO;IAAM;CAAM;AACrG,MAAMC,2BAA8C;IAClDC,YAAY;IACZC,iBAAiB;IACjBC,SAASJ,gBAAgBK,GAAG,CAAC,CAACC,WAAaP,wBAAwBO;AACrE;AAeA,OAAO,MAAMC,yCAA2BX,cAAiCK,0BAA0B;AAEnG,OAAO,SAASO;IACd,MAAMC,MAAMZ,WAAWU;IACvB,IAAIE,QAAQC,WAAW;QACrB,MAAM,IAAIC,MAAM;IAClB;IACA,OAAOF;AACT;AAEA;;CAEC,GACD,OAAO,SAASG;IACd,OAAOJ;AACT;AAEA;;;CAGC,GACD,OAAO,SAASK,8BAA8BC,QAAkB;IAC9D,MAAMC,sBAAsBH,uBAAuBV,UAAU;IAC7D,IAAIY,aAAaJ,WAAW;QAC1B,OAAOI;IACT;IACA,OAAOC;AACT;AAEA;;;CAGC,GACD,OAAO,SAASC,wBAAwBF,QAAkB;IACxD,MAAMG,oBAAoBL,uBAAuBT,eAAe;IAChE,IAAIW,aAAaJ,WAAW;QAC1B,OAAOI;IACT;IACA,OAAOG;AACT;AAEA;;;CAGC,GACD,OAAO,SAASC,2BAA2BJ,QAAuB;IAChE,MAAMC,sBAAsBH,uBAAuBR,OAAO;IAC1D,IAAIU,aAAaJ,WAAW;QAC1B,OAAOI;IACT;IACA,OAAOC;AACT;AAEA;;CAEC,GACD,OAAO,SAASI,0BAA0BC,KAAqC;IAC7E,MAAMX,MAAMX,QAAQ;QAClB,OAAO;YACLI,YAAYkB,MAAMlB,UAAU,KAAKQ,YAAYT,yBAAyBC,UAAU,GAAGkB,MAAMlB,UAAU;YACnGC,iBACEiB,MAAMjB,eAAe,KAAKO,YAAYT,yBAAyBE,eAAe,GAAGiB,MAAMjB,eAAe;YACxGC,SAASgB,MAAMhB,OAAO,KAAKM,YAAYT,yBAAyBG,OAAO,GAAGgB,MAAMhB,OAAO;QACzF;IACF,GAAG;QAACgB,MAAMlB,UAAU;QAAEkB,MAAMjB,eAAe;QAAEiB,MAAMhB,OAAO;KAAC;IAE3D,qBAAO,KAACG,yBAAyBc,QAAQ;QAACC,OAAOb;kBAAMW,MAAMG,QAAQ;;AACvE"}
@@ -1,3 +1,4 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
1
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.
@@ -10,8 +11,7 @@
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 } from "react/jsx-runtime";
14
- import { fetch } from '@perses-dev/core'; // TODO
14
+ import { fetch } from '@perses-dev/client';
15
15
  import { createContext, useContext } from 'react';
16
16
  export const UsageMetricsContext = /*#__PURE__*/ createContext(undefined);
17
17
  export const useUsageMetricsContext = ()=>{
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/runtime/UsageMetricsProvider.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 { fetch } from '@perses-dev/core'; // TODO\nimport { QueryDefinition } from '@perses-dev/spec';\nimport { createContext, ReactElement, ReactNode, useContext } from 'react';\n\ntype QueryState = 'pending' | 'success' | 'error';\n\ninterface UsageMetrics {\n project: string;\n dashboard: string;\n startRenderTime: number;\n renderDurationMs: number;\n renderErrorCount: number;\n pendingQueries: Map<string, QueryState>;\n apiPrefix?: string;\n}\n\ninterface UsageMetricsProps {\n project: string;\n dashboard: string;\n apiPrefix?: string;\n children: ReactNode;\n}\n\ninterface UseUsageMetricsResults {\n markQuery: (definition: QueryDefinition, state: QueryState) => void;\n}\n\nexport const UsageMetricsContext = createContext<UsageMetrics | undefined>(undefined);\n\nexport const useUsageMetricsContext = (): UsageMetrics | undefined => {\n return useContext(UsageMetricsContext);\n};\n\nexport const useUsageMetrics = (): UseUsageMetricsResults => {\n const ctx = useUsageMetricsContext();\n\n return {\n markQuery: (definition: QueryDefinition, newState: QueryState): void => {\n if (ctx === undefined) {\n return;\n }\n\n const definitionKey = JSON.stringify(definition);\n if (ctx.pendingQueries.has(definitionKey) && newState === 'pending') {\n // Never allow transitions back to pending, to avoid re-sending stats on a re-render.\n return;\n }\n\n if (ctx.pendingQueries.get(definitionKey) !== newState) {\n ctx.pendingQueries.set(definitionKey, newState);\n if (newState === 'error') {\n ctx.renderErrorCount += 1;\n }\n\n const allDone = [...ctx.pendingQueries.values()].every((p) => p !== 'pending');\n if (ctx.renderDurationMs === 0 && allDone) {\n ctx.renderDurationMs = Date.now() - ctx.startRenderTime;\n submitMetrics(ctx);\n }\n }\n },\n };\n};\n\nconst submitMetrics = async (stats: UsageMetrics): Promise<void> => {\n await fetch(`${stats.apiPrefix ?? ''}/api/v1/view`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({\n project: stats.project,\n dashboard: stats.dashboard,\n render_time: stats.renderDurationMs / 1000,\n render_errors: stats.renderErrorCount,\n }),\n });\n};\n\nexport const UsageMetricsProvider = ({ apiPrefix, project, dashboard, children }: UsageMetricsProps): ReactElement => {\n const ctx: UsageMetrics = {\n project: project,\n dashboard: dashboard,\n renderErrorCount: 0,\n startRenderTime: Date.now(),\n renderDurationMs: 0,\n pendingQueries: new Map(),\n apiPrefix,\n };\n\n return <UsageMetricsContext.Provider value={ctx}>{children}</UsageMetricsContext.Provider>;\n};\n"],"names":["fetch","createContext","useContext","UsageMetricsContext","undefined","useUsageMetricsContext","useUsageMetrics","ctx","markQuery","definition","newState","definitionKey","JSON","stringify","pendingQueries","has","get","set","renderErrorCount","allDone","values","every","p","renderDurationMs","Date","now","startRenderTime","submitMetrics","stats","apiPrefix","method","headers","body","project","dashboard","render_time","render_errors","UsageMetricsProvider","children","Map","Provider","value"],"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,QAAQ,mBAAmB,CAAC,OAAO;AAEjD,SAASC,aAAa,EAA2BC,UAAU,QAAQ,QAAQ;AAyB3E,OAAO,MAAMC,oCAAsBF,cAAwCG,WAAW;AAEtF,OAAO,MAAMC,yBAAyB;IACpC,OAAOH,WAAWC;AACpB,EAAE;AAEF,OAAO,MAAMG,kBAAkB;IAC7B,MAAMC,MAAMF;IAEZ,OAAO;QACLG,WAAW,CAACC,YAA6BC;YACvC,IAAI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B;;AACpD,EAAE"}
1
+ {"version":3,"sources":["../../src/runtime/UsageMetricsProvider.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 { fetch } from '@perses-dev/client';\nimport { QueryDefinition } from '@perses-dev/spec';\nimport { createContext, ReactElement, ReactNode, useContext } from 'react';\n\ntype QueryState = 'pending' | 'success' | 'error';\n\ninterface UsageMetrics {\n project: string;\n dashboard: string;\n startRenderTime: number;\n renderDurationMs: number;\n renderErrorCount: number;\n pendingQueries: Map<string, QueryState>;\n apiPrefix?: string;\n}\n\ninterface UsageMetricsProps {\n project: string;\n dashboard: string;\n apiPrefix?: string;\n children: ReactNode;\n}\n\ninterface UseUsageMetricsResults {\n markQuery: (definition: QueryDefinition, state: QueryState) => void;\n}\n\nexport const UsageMetricsContext = createContext<UsageMetrics | undefined>(undefined);\n\nexport const useUsageMetricsContext = (): UsageMetrics | undefined => {\n return useContext(UsageMetricsContext);\n};\n\nexport const useUsageMetrics = (): UseUsageMetricsResults => {\n const ctx = useUsageMetricsContext();\n\n return {\n markQuery: (definition: QueryDefinition, newState: QueryState): void => {\n if (ctx === undefined) {\n return;\n }\n\n const definitionKey = JSON.stringify(definition);\n if (ctx.pendingQueries.has(definitionKey) && newState === 'pending') {\n // Never allow transitions back to pending, to avoid re-sending stats on a re-render.\n return;\n }\n\n if (ctx.pendingQueries.get(definitionKey) !== newState) {\n ctx.pendingQueries.set(definitionKey, newState);\n if (newState === 'error') {\n ctx.renderErrorCount += 1;\n }\n\n const allDone = [...ctx.pendingQueries.values()].every((p) => p !== 'pending');\n if (ctx.renderDurationMs === 0 && allDone) {\n ctx.renderDurationMs = Date.now() - ctx.startRenderTime;\n submitMetrics(ctx);\n }\n }\n },\n };\n};\n\nconst submitMetrics = async (stats: UsageMetrics): Promise<void> => {\n await fetch(`${stats.apiPrefix ?? ''}/api/v1/view`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({\n project: stats.project,\n dashboard: stats.dashboard,\n render_time: stats.renderDurationMs / 1000,\n render_errors: stats.renderErrorCount,\n }),\n });\n};\n\nexport const UsageMetricsProvider = ({ apiPrefix, project, dashboard, children }: UsageMetricsProps): ReactElement => {\n const ctx: UsageMetrics = {\n project: project,\n dashboard: dashboard,\n renderErrorCount: 0,\n startRenderTime: Date.now(),\n renderDurationMs: 0,\n pendingQueries: new Map(),\n apiPrefix,\n };\n\n return <UsageMetricsContext.Provider value={ctx}>{children}</UsageMetricsContext.Provider>;\n};\n"],"names":["fetch","createContext","useContext","UsageMetricsContext","undefined","useUsageMetricsContext","useUsageMetrics","ctx","markQuery","definition","newState","definitionKey","JSON","stringify","pendingQueries","has","get","set","renderErrorCount","allDone","values","every","p","renderDurationMs","Date","now","startRenderTime","submitMetrics","stats","apiPrefix","method","headers","body","project","dashboard","render_time","render_errors","UsageMetricsProvider","children","Map","Provider","value"],"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,QAAQ,qBAAqB;AAE3C,SAASC,aAAa,EAA2BC,UAAU,QAAQ,QAAQ;AAyB3E,OAAO,MAAMC,oCAAsBF,cAAwCG,WAAW;AAEtF,OAAO,MAAMC,yBAAyB;IACpC,OAAOH,WAAWC;AACpB,EAAE;AAEF,OAAO,MAAMG,kBAAkB;IAC7B,MAAMC,MAAMF;IAEZ,OAAO;QACLG,WAAW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AQ;QAACC,OAAOlC;kBAAM+B;;AACpD,EAAE"}
@@ -0,0 +1,11 @@
1
+ import { AlertsData, QueryDefinition, UnknownSpec } from '@perses-dev/spec';
2
+ import { UseQueryResult } from '@tanstack/react-query';
3
+ export type AlertsQueryDefinition<PluginSpec = UnknownSpec> = QueryDefinition<'AlertsQuery', PluginSpec>;
4
+ export declare const ALERTS_QUERY_KEY = "AlertsQuery";
5
+ /**
6
+ * Run an alerts query using an AlertsQuery plugin and return the results.
7
+ * Alerts represent current state and are NOT time-range dependent.
8
+ * @param definitions: dashboard definition for an alerts query
9
+ */
10
+ export declare function useAlertsQueries(definitions: AlertsQueryDefinition[]): Array<UseQueryResult<AlertsData>>;
11
+ //# sourceMappingURL=alerts-queries.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"alerts-queries.d.ts","sourceRoot":"","sources":["../../src/runtime/alerts-queries.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC5E,OAAO,EAAwB,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAO7E,MAAM,MAAM,qBAAqB,CAAC,UAAU,GAAG,WAAW,IAAI,eAAe,CAAC,aAAa,EAAE,UAAU,CAAC,CAAC;AACzG,eAAO,MAAM,gBAAgB,gBAAgB,CAAC;AAE9C;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,qBAAqB,EAAE,GAAG,KAAK,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC,CA6BxG"}
@@ -0,0 +1,89 @@
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.
13
+ import { useQueries } from '@tanstack/react-query';
14
+ import { useDatasourceStore } from './datasources';
15
+ import { usePluginRegistry, usePlugins } from './plugin-registry';
16
+ import { useAllVariableValues } from './variables';
17
+ import { filterVariableStateMap, getVariableValuesKey } from './utils';
18
+ export const ALERTS_QUERY_KEY = 'AlertsQuery';
19
+ /**
20
+ * Run an alerts query using an AlertsQuery plugin and return the results.
21
+ * Alerts represent current state and are NOT time-range dependent.
22
+ * @param definitions: dashboard definition for an alerts query
23
+ */ export function useAlertsQueries(definitions) {
24
+ const { getPlugin } = usePluginRegistry();
25
+ const context = useAlertsQueryContext();
26
+ const pluginLoaderResponse = usePlugins('AlertsQuery', definitions.map((d)=>({
27
+ kind: d.spec.plugin.kind
28
+ })));
29
+ return useQueries({
30
+ queries: definitions.map((definition, idx)=>{
31
+ const plugin = pluginLoaderResponse[idx]?.data;
32
+ const { queryEnabled, queryKey } = getQueryOptions({
33
+ context,
34
+ definition,
35
+ plugin
36
+ });
37
+ const alertsQueryKind = definition?.spec?.plugin?.kind;
38
+ return {
39
+ enabled: queryEnabled,
40
+ queryKey: queryKey,
41
+ refetchOnMount: false,
42
+ refetchOnWindowFocus: false,
43
+ refetchOnReconnect: false,
44
+ staleTime: 60_000,
45
+ queryFn: async ({ signal })=>{
46
+ const plugin = await getPlugin({
47
+ kind: ALERTS_QUERY_KEY,
48
+ name: alertsQueryKind
49
+ });
50
+ const data = await plugin.getAlertsData(definition.spec.plugin.spec, context, signal);
51
+ return data;
52
+ }
53
+ };
54
+ })
55
+ });
56
+ }
57
+ function getQueryOptions({ plugin, definition, context }) {
58
+ const { variableState } = context;
59
+ const dependencies = plugin?.dependsOn ? plugin.dependsOn(definition.spec.plugin.spec, context) : {};
60
+ const variableDependencies = dependencies?.variables;
61
+ const filteredVariabledState = filterVariableStateMap(variableState, variableDependencies);
62
+ const variablesValueKey = getVariableValuesKey(filteredVariabledState);
63
+ // Note: no absoluteTimeRange in query key since alerts are current state
64
+ const queryKey = [
65
+ 'query',
66
+ ALERTS_QUERY_KEY,
67
+ definition,
68
+ variablesValueKey
69
+ ];
70
+ let waitToLoad = false;
71
+ if (variableDependencies) {
72
+ waitToLoad = variableDependencies.some((v)=>variableState[v]?.loading);
73
+ }
74
+ const queryEnabled = plugin !== undefined && !waitToLoad;
75
+ return {
76
+ queryKey,
77
+ queryEnabled
78
+ };
79
+ }
80
+ function useAlertsQueryContext() {
81
+ const variableState = useAllVariableValues();
82
+ const datasourceStore = useDatasourceStore();
83
+ return {
84
+ variableState,
85
+ datasourceStore
86
+ };
87
+ }
88
+
89
+ //# sourceMappingURL=alerts-queries.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/runtime/alerts-queries.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 { AlertsData, QueryDefinition, UnknownSpec } from '@perses-dev/spec';\nimport { QueryKey, useQueries, UseQueryResult } from '@tanstack/react-query';\nimport { AlertsQueryContext, AlertsQueryPlugin } from '../model';\nimport { useDatasourceStore } from './datasources';\nimport { usePluginRegistry, usePlugins } from './plugin-registry';\nimport { useAllVariableValues } from './variables';\nimport { filterVariableStateMap, getVariableValuesKey } from './utils';\n\nexport type AlertsQueryDefinition<PluginSpec = UnknownSpec> = QueryDefinition<'AlertsQuery', PluginSpec>;\nexport const ALERTS_QUERY_KEY = 'AlertsQuery';\n\n/**\n * Run an alerts query using an AlertsQuery plugin and return the results.\n * Alerts represent current state and are NOT time-range dependent.\n * @param definitions: dashboard definition for an alerts query\n */\nexport function useAlertsQueries(definitions: AlertsQueryDefinition[]): Array<UseQueryResult<AlertsData>> {\n const { getPlugin } = usePluginRegistry();\n const context = useAlertsQueryContext();\n\n const pluginLoaderResponse = usePlugins(\n 'AlertsQuery',\n definitions.map((d) => ({ kind: d.spec.plugin.kind }))\n );\n\n return useQueries({\n queries: definitions.map((definition, idx) => {\n const plugin = pluginLoaderResponse[idx]?.data;\n const { queryEnabled, queryKey } = getQueryOptions({ context, definition, plugin });\n const alertsQueryKind = definition?.spec?.plugin?.kind;\n return {\n enabled: queryEnabled,\n queryKey: queryKey,\n refetchOnMount: false,\n refetchOnWindowFocus: false,\n refetchOnReconnect: false,\n staleTime: 60_000,\n queryFn: async ({ signal }: { signal?: AbortSignal }): Promise<AlertsData> => {\n const plugin = await getPlugin({ kind: ALERTS_QUERY_KEY, name: alertsQueryKind });\n const data = await plugin.getAlertsData(definition.spec.plugin.spec, context, signal);\n return data;\n },\n };\n }),\n });\n}\n\nfunction getQueryOptions({\n plugin,\n definition,\n context,\n}: {\n plugin?: AlertsQueryPlugin;\n definition: AlertsQueryDefinition;\n context: AlertsQueryContext;\n}): {\n queryKey: QueryKey;\n queryEnabled: boolean;\n} {\n const { variableState } = context;\n\n const dependencies = plugin?.dependsOn ? plugin.dependsOn(definition.spec.plugin.spec, context) : {};\n const variableDependencies = dependencies?.variables;\n\n const filteredVariabledState = filterVariableStateMap(variableState, variableDependencies);\n const variablesValueKey = getVariableValuesKey(filteredVariabledState);\n // Note: no absoluteTimeRange in query key since alerts are current state\n const queryKey = ['query', ALERTS_QUERY_KEY, definition, variablesValueKey] as const;\n\n let waitToLoad = false;\n if (variableDependencies) {\n waitToLoad = variableDependencies.some((v) => variableState[v]?.loading);\n }\n\n const queryEnabled = plugin !== undefined && !waitToLoad;\n return {\n queryKey,\n queryEnabled,\n };\n}\n\nfunction useAlertsQueryContext(): AlertsQueryContext {\n const variableState = useAllVariableValues();\n const datasourceStore = useDatasourceStore();\n\n return {\n variableState,\n datasourceStore,\n };\n}\n"],"names":["useQueries","useDatasourceStore","usePluginRegistry","usePlugins","useAllVariableValues","filterVariableStateMap","getVariableValuesKey","ALERTS_QUERY_KEY","useAlertsQueries","definitions","getPlugin","context","useAlertsQueryContext","pluginLoaderResponse","map","d","kind","spec","plugin","queries","definition","idx","data","queryEnabled","queryKey","getQueryOptions","alertsQueryKind","enabled","refetchOnMount","refetchOnWindowFocus","refetchOnReconnect","staleTime","queryFn","signal","name","getAlertsData","variableState","dependencies","dependsOn","variableDependencies","variables","filteredVariabledState","variablesValueKey","waitToLoad","some","v","loading","undefined","datasourceStore"],"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,SAAmBA,UAAU,QAAwB,wBAAwB;AAE7E,SAASC,kBAAkB,QAAQ,gBAAgB;AACnD,SAASC,iBAAiB,EAAEC,UAAU,QAAQ,oBAAoB;AAClE,SAASC,oBAAoB,QAAQ,cAAc;AACnD,SAASC,sBAAsB,EAAEC,oBAAoB,QAAQ,UAAU;AAGvE,OAAO,MAAMC,mBAAmB,cAAc;AAE9C;;;;CAIC,GACD,OAAO,SAASC,iBAAiBC,WAAoC;IACnE,MAAM,EAAEC,SAAS,EAAE,GAAGR;IACtB,MAAMS,UAAUC;IAEhB,MAAMC,uBAAuBV,WAC3B,eACAM,YAAYK,GAAG,CAAC,CAACC,IAAO,CAAA;YAAEC,MAAMD,EAAEE,IAAI,CAACC,MAAM,CAACF,IAAI;QAAC,CAAA;IAGrD,OAAOhB,WAAW;QAChBmB,SAASV,YAAYK,GAAG,CAAC,CAACM,YAAYC;YACpC,MAAMH,SAASL,oBAAoB,CAACQ,IAAI,EAAEC;YAC1C,MAAM,EAAEC,YAAY,EAAEC,QAAQ,EAAE,GAAGC,gBAAgB;gBAAEd;gBAASS;gBAAYF;YAAO;YACjF,MAAMQ,kBAAkBN,YAAYH,MAAMC,QAAQF;YAClD,OAAO;gBACLW,SAASJ;gBACTC,UAAUA;gBACVI,gBAAgB;gBAChBC,sBAAsB;gBACtBC,oBAAoB;gBACpBC,WAAW;gBACXC,SAAS,OAAO,EAAEC,MAAM,EAA4B;oBAClD,MAAMf,SAAS,MAAMR,UAAU;wBAAEM,MAAMT;wBAAkB2B,MAAMR;oBAAgB;oBAC/E,MAAMJ,OAAO,MAAMJ,OAAOiB,aAAa,CAACf,WAAWH,IAAI,CAACC,MAAM,CAACD,IAAI,EAAEN,SAASsB;oBAC9E,OAAOX;gBACT;YACF;QACF;IACF;AACF;AAEA,SAASG,gBAAgB,EACvBP,MAAM,EACNE,UAAU,EACVT,OAAO,EAKR;IAIC,MAAM,EAAEyB,aAAa,EAAE,GAAGzB;IAE1B,MAAM0B,eAAenB,QAAQoB,YAAYpB,OAAOoB,SAAS,CAAClB,WAAWH,IAAI,CAACC,MAAM,CAACD,IAAI,EAAEN,WAAW,CAAC;IACnG,MAAM4B,uBAAuBF,cAAcG;IAE3C,MAAMC,yBAAyBpC,uBAAuB+B,eAAeG;IACrE,MAAMG,oBAAoBpC,qBAAqBmC;IAC/C,yEAAyE;IACzE,MAAMjB,WAAW;QAAC;QAASjB;QAAkBa;QAAYsB;KAAkB;IAE3E,IAAIC,aAAa;IACjB,IAAIJ,sBAAsB;QACxBI,aAAaJ,qBAAqBK,IAAI,CAAC,CAACC,IAAMT,aAAa,CAACS,EAAE,EAAEC;IAClE;IAEA,MAAMvB,eAAeL,WAAW6B,aAAa,CAACJ;IAC9C,OAAO;QACLnB;QACAD;IACF;AACF;AAEA,SAASX;IACP,MAAMwB,gBAAgBhC;IACtB,MAAM4C,kBAAkB/C;IAExB,OAAO;QACLmC;QACAY;IACF;AACF"}
@@ -0,0 +1,6 @@
1
+ import { AnnotationData, AnnotationSpec } from '@perses-dev/spec';
2
+ import { UseQueryResult } from '@tanstack/react-query';
3
+ export declare const ANNOTATION_KEY = "Annotation";
4
+ export declare function useAnnotations(definitions: AnnotationSpec[]): Array<UseQueryResult<AnnotationData[]>>;
5
+ export declare function useAnnotationData(spec: AnnotationSpec): UseQueryResult<AnnotationData[]>;
6
+ //# sourceMappingURL=annotations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"annotations.d.ts","sourceRoot":"","sources":["../../src/runtime/annotations.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClE,OAAO,EAAkC,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAQvF,eAAO,MAAM,cAAc,eAAe,CAAC;AA+C3C,wBAAgB,cAAc,CAAC,WAAW,EAAE,cAAc,EAAE,GAAG,KAAK,CAAC,cAAc,CAAC,cAAc,EAAE,CAAC,CAAC,CA8BrG;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,cAAc,GAAG,cAAc,CAAC,cAAc,EAAE,CAAC,CAsCxF"}
@@ -0,0 +1,129 @@
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.
13
+ import { useQueries, useQuery } from '@tanstack/react-query';
14
+ import { usePlugin, usePluginRegistry, usePlugins } from './plugin-registry';
15
+ import { useTimeRange } from './TimeRangeProvider';
16
+ import { useAllVariableValues } from './variables';
17
+ import { useDatasourceStore } from './datasources';
18
+ import { filterVariableStateMap, getVariableValuesKey } from './utils';
19
+ export const ANNOTATION_KEY = 'Annotation';
20
+ function useAnnotationContext() {
21
+ const { absoluteTimeRange } = useTimeRange();
22
+ const variableState = useAllVariableValues();
23
+ const datasourceStore = useDatasourceStore();
24
+ return {
25
+ variableState,
26
+ datasourceStore,
27
+ absoluteTimeRange
28
+ };
29
+ }
30
+ function getQueryOptions({ plugin, definition, context }) {
31
+ const { variableState, absoluteTimeRange } = context;
32
+ const dependencies = plugin?.dependsOn ? plugin.dependsOn(definition.plugin.spec, context) : {};
33
+ const variableDependencies = dependencies?.variables;
34
+ const filteredVariableState = filterVariableStateMap(variableState, variableDependencies);
35
+ const variablesValueKey = getVariableValuesKey(filteredVariableState);
36
+ const queryKey = [
37
+ ANNOTATION_KEY,
38
+ definition,
39
+ absoluteTimeRange,
40
+ variablesValueKey
41
+ ];
42
+ let waitToLoad = false;
43
+ if (variableDependencies) {
44
+ waitToLoad = variableDependencies.some((v)=>variableState[v]?.loading);
45
+ }
46
+ const queryEnabled = plugin !== undefined && !waitToLoad;
47
+ return {
48
+ queryKey,
49
+ queryEnabled
50
+ };
51
+ }
52
+ export function useAnnotations(definitions) {
53
+ const { getPlugin } = usePluginRegistry();
54
+ const context = useAnnotationContext();
55
+ const pluginLoaderResponse = usePlugins('Annotation', definitions.map((d)=>({
56
+ kind: d.plugin.kind
57
+ })));
58
+ // useQueries() handles data fetching from query plugins
59
+ return useQueries({
60
+ queries: definitions.map((definition, idx)=>{
61
+ const plugin = pluginLoaderResponse[idx]?.data;
62
+ const { queryEnabled, queryKey } = getQueryOptions({
63
+ context,
64
+ definition,
65
+ plugin
66
+ });
67
+ const annotationKind = definition?.plugin?.kind;
68
+ return {
69
+ enabled: queryEnabled,
70
+ queryKey: queryKey,
71
+ refetchOnMount: false,
72
+ refetchOnWindowFocus: false,
73
+ refetchOnReconnect: false,
74
+ staleTime: Infinity,
75
+ queryFn: async ({ signal })=>{
76
+ const plugin = await getPlugin({
77
+ kind: ANNOTATION_KEY,
78
+ name: annotationKind
79
+ });
80
+ const data = await plugin.getAnnotationData(definition.plugin.spec, context, signal);
81
+ return data;
82
+ }
83
+ };
84
+ })
85
+ });
86
+ }
87
+ export function useAnnotationData(spec) {
88
+ const { data: annotationPlugin } = usePlugin('Annotation', spec.plugin.kind);
89
+ const datasourceStore = useDatasourceStore();
90
+ const allVariables = useAllVariableValues();
91
+ const { absoluteTimeRange: timeRange } = useTimeRange();
92
+ const variablePluginCtx = {
93
+ absoluteTimeRange: timeRange,
94
+ datasourceStore,
95
+ variableState: allVariables
96
+ };
97
+ let dependsOnVariables = Object.keys(allVariables); // Default to all variables
98
+ if (annotationPlugin?.dependsOn) {
99
+ const dependencies = annotationPlugin.dependsOn(spec.plugin.spec, variablePluginCtx);
100
+ dependsOnVariables = dependencies.variables ? dependencies.variables : dependsOnVariables;
101
+ }
102
+ const variables = useAllVariableValues(dependsOnVariables);
103
+ let waitToLoad = false;
104
+ if (dependsOnVariables) {
105
+ waitToLoad = dependsOnVariables.some((v)=>variables[v]?.loading);
106
+ }
107
+ const variablesValueKey = getVariableValuesKey(variables);
108
+ return useQuery({
109
+ queryKey: [
110
+ 'annotation',
111
+ spec,
112
+ timeRange,
113
+ variablesValueKey
114
+ ],
115
+ queryFn: async ({ signal })=>{
116
+ const resp = await annotationPlugin?.getAnnotationData(spec.plugin.spec, {
117
+ ...variablePluginCtx,
118
+ variableState: variables
119
+ }, signal);
120
+ if (!resp?.length) {
121
+ return [];
122
+ }
123
+ return resp;
124
+ },
125
+ enabled: !!annotationPlugin || waitToLoad
126
+ });
127
+ }
128
+
129
+ //# sourceMappingURL=annotations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/runtime/annotations.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 { AnnotationData, AnnotationSpec } from '@perses-dev/spec';\nimport { QueryKey, useQueries, useQuery, UseQueryResult } from '@tanstack/react-query';\nimport { AnnotationContext, AnnotationPlugin } from '../model';\nimport { usePlugin, usePluginRegistry, usePlugins } from './plugin-registry';\nimport { useTimeRange } from './TimeRangeProvider';\nimport { useAllVariableValues } from './variables';\nimport { useDatasourceStore } from './datasources';\nimport { filterVariableStateMap, getVariableValuesKey } from './utils';\n\nexport const ANNOTATION_KEY = 'Annotation';\n\nfunction useAnnotationContext(): AnnotationContext {\n const { absoluteTimeRange } = useTimeRange();\n const variableState = useAllVariableValues();\n const datasourceStore = useDatasourceStore();\n\n return {\n variableState,\n datasourceStore,\n absoluteTimeRange,\n };\n}\n\nfunction getQueryOptions({\n plugin,\n definition,\n context,\n}: {\n plugin?: AnnotationPlugin;\n definition: AnnotationSpec;\n context: AnnotationContext;\n}): {\n queryKey: QueryKey;\n queryEnabled: boolean;\n} {\n const { variableState, absoluteTimeRange } = context;\n\n const dependencies = plugin?.dependsOn ? plugin.dependsOn(definition.plugin.spec, context) : {};\n const variableDependencies = dependencies?.variables;\n\n const filteredVariableState = filterVariableStateMap(variableState, variableDependencies);\n const variablesValueKey = getVariableValuesKey(filteredVariableState);\n const queryKey = [ANNOTATION_KEY, definition, absoluteTimeRange, variablesValueKey] as const;\n\n let waitToLoad = false;\n if (variableDependencies) {\n waitToLoad = variableDependencies.some((v) => variableState[v]?.loading);\n }\n\n const queryEnabled = plugin !== undefined && !waitToLoad;\n return {\n queryKey,\n queryEnabled,\n };\n}\n\nexport function useAnnotations(definitions: AnnotationSpec[]): Array<UseQueryResult<AnnotationData[]>> {\n const { getPlugin } = usePluginRegistry();\n const context = useAnnotationContext();\n\n const pluginLoaderResponse = usePlugins(\n 'Annotation',\n definitions.map((d) => ({ kind: d.plugin.kind }))\n );\n\n // useQueries() handles data fetching from query plugins\n return useQueries({\n queries: definitions.map((definition, idx) => {\n const plugin = pluginLoaderResponse[idx]?.data;\n const { queryEnabled, queryKey } = getQueryOptions({ context, definition, plugin });\n const annotationKind = definition?.plugin?.kind;\n return {\n enabled: queryEnabled,\n queryKey: queryKey,\n refetchOnMount: false,\n refetchOnWindowFocus: false,\n refetchOnReconnect: false,\n staleTime: Infinity,\n queryFn: async ({ signal }: { signal?: AbortSignal }): Promise<AnnotationData[]> => {\n const plugin = await getPlugin({ kind: ANNOTATION_KEY, name: annotationKind });\n const data = await plugin.getAnnotationData(definition.plugin.spec, context, signal);\n return data;\n },\n };\n }),\n });\n}\n\nexport function useAnnotationData(spec: AnnotationSpec): UseQueryResult<AnnotationData[]> {\n const { data: annotationPlugin } = usePlugin('Annotation', spec.plugin.kind);\n\n const datasourceStore = useDatasourceStore();\n const allVariables = useAllVariableValues();\n const { absoluteTimeRange: timeRange } = useTimeRange();\n const variablePluginCtx = { absoluteTimeRange: timeRange, datasourceStore, variableState: allVariables };\n\n let dependsOnVariables: string[] = Object.keys(allVariables); // Default to all variables\n if (annotationPlugin?.dependsOn) {\n const dependencies = annotationPlugin.dependsOn(spec.plugin.spec, variablePluginCtx);\n dependsOnVariables = dependencies.variables ? dependencies.variables : dependsOnVariables;\n }\n\n const variables = useAllVariableValues(dependsOnVariables);\n\n let waitToLoad = false;\n if (dependsOnVariables) {\n waitToLoad = dependsOnVariables.some((v) => variables[v]?.loading);\n }\n\n const variablesValueKey = getVariableValuesKey(variables);\n\n return useQuery({\n queryKey: ['annotation', spec, timeRange, variablesValueKey],\n queryFn: async ({ signal }) => {\n const resp = await annotationPlugin?.getAnnotationData(\n spec.plugin.spec,\n { ...variablePluginCtx, variableState: variables },\n signal\n );\n if (!resp?.length) {\n return [];\n }\n return resp;\n },\n enabled: !!annotationPlugin || waitToLoad,\n });\n}\n"],"names":["useQueries","useQuery","usePlugin","usePluginRegistry","usePlugins","useTimeRange","useAllVariableValues","useDatasourceStore","filterVariableStateMap","getVariableValuesKey","ANNOTATION_KEY","useAnnotationContext","absoluteTimeRange","variableState","datasourceStore","getQueryOptions","plugin","definition","context","dependencies","dependsOn","spec","variableDependencies","variables","filteredVariableState","variablesValueKey","queryKey","waitToLoad","some","v","loading","queryEnabled","undefined","useAnnotations","definitions","getPlugin","pluginLoaderResponse","map","d","kind","queries","idx","data","annotationKind","enabled","refetchOnMount","refetchOnWindowFocus","refetchOnReconnect","staleTime","Infinity","queryFn","signal","name","getAnnotationData","useAnnotationData","annotationPlugin","allVariables","timeRange","variablePluginCtx","dependsOnVariables","Object","keys","resp","length"],"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,SAAmBA,UAAU,EAAEC,QAAQ,QAAwB,wBAAwB;AAEvF,SAASC,SAAS,EAAEC,iBAAiB,EAAEC,UAAU,QAAQ,oBAAoB;AAC7E,SAASC,YAAY,QAAQ,sBAAsB;AACnD,SAASC,oBAAoB,QAAQ,cAAc;AACnD,SAASC,kBAAkB,QAAQ,gBAAgB;AACnD,SAASC,sBAAsB,EAAEC,oBAAoB,QAAQ,UAAU;AAEvE,OAAO,MAAMC,iBAAiB,aAAa;AAE3C,SAASC;IACP,MAAM,EAAEC,iBAAiB,EAAE,GAAGP;IAC9B,MAAMQ,gBAAgBP;IACtB,MAAMQ,kBAAkBP;IAExB,OAAO;QACLM;QACAC;QACAF;IACF;AACF;AAEA,SAASG,gBAAgB,EACvBC,MAAM,EACNC,UAAU,EACVC,OAAO,EAKR;IAIC,MAAM,EAAEL,aAAa,EAAED,iBAAiB,EAAE,GAAGM;IAE7C,MAAMC,eAAeH,QAAQI,YAAYJ,OAAOI,SAAS,CAACH,WAAWD,MAAM,CAACK,IAAI,EAAEH,WAAW,CAAC;IAC9F,MAAMI,uBAAuBH,cAAcI;IAE3C,MAAMC,wBAAwBhB,uBAAuBK,eAA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rD,UAAU,cAAcmB,KAAKL,MAAM,CAACuB,IAAI;IAE3E,MAAMzB,kBAAkBP;IACxB,MAAMiD,eAAelD;IACrB,MAAM,EAAEM,mBAAmB6C,SAAS,EAAE,GAAGpD;IACzC,MAAMqD,oBAAoB;QAAE9C,mBAAmB6C;QAAW3C;QAAiBD,eAAe2C;IAAa;IAEvG,IAAIG,qBAA+BC,OAAOC,IAAI,CAACL,eAAe,2BAA2B;IACzF,IAAID,kBAAkBnC,WAAW;QAC/B,MAAMD,eAAeoC,iBAAiBnC,SAAS,CAACC,KAAKL,MAAM,CAACK,IAAI,EAAEqC;QAClEC,qBAAqBxC,aAAaI,SAAS,GAAGJ,aAAaI,SAAS,GAAGoC;IACzE;IAEA,MAAMpC,YAAYjB,qBAAqBqD;IAEvC,IAAIhC,aAAa;IACjB,IAAIgC,oBAAoB;QACtBhC,aAAagC,mBAAmB/B,IAAI,CAAC,CAACC,IAAMN,SAAS,CAACM,EAAE,EAAEC;IAC5D;IAEA,MAAML,oBAAoBhB,qBAAqBc;IAE/C,OAAOtB,SAAS;QACdyB,UAAU;YAAC;YAAcL;YAAMoC;YAAWhC;SAAkB;QAC5DyB,SAAS,OAAO,EAAEC,MAAM,EAAE;YACxB,MAAMW,OAAO,MAAMP,kBAAkBF,kBACnChC,KAAKL,MAAM,CAACK,IAAI,EAChB;gBAAE,GAAGqC,iBAAiB;gBAAE7C,eAAeU;YAAU,GACjD4B;YAEF,IAAI,CAACW,MAAMC,QAAQ;gBACjB,OAAO,EAAE;YACX;YACA,OAAOD;QACT;QACAlB,SAAS,CAAC,CAACW,oBAAoB5B;IACjC;AACF"}
@@ -3,6 +3,12 @@ import { DatasourceSelector, DatasourceSpec } from '@perses-dev/spec';
3
3
  import { UseQueryResult } from '@tanstack/react-query';
4
4
  export interface DatasourceStore {
5
5
  getDatasource(selector: DatasourceSelector): Promise<DatasourceSpec>;
6
+ /**
7
+ * Gets a cached datasource spec synchronously if available.
8
+ * Used by variable dependency resolution to avoid async calls in dependsOn().
9
+ * Returns undefined if the spec is not cached.
10
+ */
11
+ getDatasourceSpecSync?(selector: DatasourceSelector): DatasourceSpec | undefined;
6
12
  /**
7
13
  * Given a DatasourceSelector, gets a `Client` object from the corresponding Datasource plugin.
8
14
  */
@@ -1 +1 @@
1
- {"version":3,"file":"datasources.d.ts","sourceRoot":"","sources":["../../src/runtime/datasources.ts"],"names":[],"mappings":";AAaA,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,EAAY,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAGjE,MAAM,WAAW,eAAe;IAE9B,aAAa,CAAC,QAAQ,EAAE,kBAAkB,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;IAErE;;OAEG;IACH,mBAAmB,CAAC,MAAM,EAAE,QAAQ,EAAE,kBAAkB,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAE3E;;OAEG;IACH,yBAAyB,CAAC,oBAAoB,EAAE,MAAM,GAAG,OAAO,CAAC,yBAAyB,EAAE,CAAC,CAAC;IAE9F;;OAEG;IACH,mBAAmB,IAAI,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IAEtD;;OAEG;IACH,mBAAmB,CAAC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,GAAG,IAAI,CAAC;IAEvE;;OAEG;IACH,mBAAmB,IAAI,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IAEtD;;OAEG;IACH,mBAAmB,CAAC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,GAAG,IAAI,CAAC;CACxE;AAED,MAAM,WAAW,yBAAyB;IACxC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,oBAAoB,EAAE,CAAC;CAC/B;AAED,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,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,cAAc,CAAC,CAM1F"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/runtime/datasources.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, DatasourceSpec } from '@perses-dev/spec';\nimport { useQuery, UseQueryResult } from '@tanstack/react-query';\nimport { createContext, useContext } from 'react';\n\nexport interface DatasourceStore {\n // TODO: Do we even need this method?\n getDatasource(selector: DatasourceSelector): Promise<DatasourceSpec>;\n\n /**\n * Given a DatasourceSelector, gets a `Client` object from the corresponding Datasource plugin.\n */\n getDatasourceClient<Client>(selector: DatasourceSelector): Promise<Client>;\n\n /**\n * Gets a list of datasource selection items for a plugin kind.\n */\n listDatasourceSelectItems(datasourcePluginName: string): Promise<DatasourceSelectItemGroup[]>;\n\n /**\n * Gets the list of datasources defined in the dashboard\n */\n getLocalDatasources(): Record<string, DatasourceSpec>;\n\n /**\n * Sets the list of datasources defined in the dashboard\n */\n setLocalDatasources(datasources: Record<string, DatasourceSpec>): void;\n\n /**\n * Gets the list of datasources that are available in the dashboard (i.e. dashboards that have been created on the server side that we can use).\n */\n getSavedDatasources(): Record<string, DatasourceSpec>;\n\n /**\n * Sets the list of datasources that are saved in the dashboard\n */\n setSavedDatasources(datasources: Record<string, DatasourceSpec>): void;\n}\n\nexport interface DatasourceSelectItemGroup {\n group?: string;\n editLink?: string;\n items: DatasourceSelectItem[];\n}\n\nexport interface DatasourceSelectItem {\n name: string;\n overridden?: boolean;\n overriding?: boolean;\n saved?: boolean;\n selector: DatasourceSelectItemSelector;\n}\n\n/**\n * Datasource Selector used by the frontend only to differentiate datasources coming from different group.\n */\nexport interface DatasourceSelectItemSelector extends DatasourceSelector {\n /**\n * Group of the datasource.\n * Omit it if you don't store datasource by group.\n */\n group?: string;\n}\n\nexport const DatasourceStoreContext = createContext<DatasourceStore | undefined>(undefined);\n\nexport function useDatasourceStore(): DatasourceStore {\n const ctx = useContext(DatasourceStoreContext);\n if (ctx === undefined) {\n throw new Error('No DatasourceStoreContext found. Did you forget a Provider?');\n }\n return ctx;\n}\n\n/**\n * Lists all available Datasource selection items for a given datasource plugin kind.\n * Returns a list, with all information that can be used in a datasource selection context (group, name, selector, kind, ...)\n */\nexport function useListDatasourceSelectItems(\n datasourcePluginName: string,\n project?: string\n): UseQueryResult<DatasourceSelectItemGroup[]> {\n const { listDatasourceSelectItems } = useDatasourceStore();\n return useQuery<DatasourceSelectItemGroup[]>({\n queryKey: ['listDatasourceSelectItems', datasourcePluginName, project],\n queryFn: () => listDatasourceSelectItems(datasourcePluginName),\n });\n}\n\n/**\n * Provides a convenience hook for getting a DatasourceClient for a given DatasourceSelector.\n */\nexport function useDatasourceClient<Client>(selector: DatasourceSelector): UseQueryResult<Client> {\n const store = useDatasourceStore();\n return useQuery<Client>({\n queryKey: ['getDatasourceClient', selector],\n queryFn: () => store.getDatasourceClient<Client>(selector),\n });\n}\n\nexport function useDatasource(selector: DatasourceSelector): UseQueryResult<DatasourceSpec> {\n const store = useDatasourceStore();\n return useQuery<DatasourceSpec>({\n queryKey: ['getDatasource', selector],\n queryFn: () => store.getDatasource(selector),\n });\n}\n"],"names":["useQuery","createContext","useContext","DatasourceStoreContext","undefined","useDatasourceStore","ctx","Error","useListDatasourceSelectItems","datasourcePluginName","project","listDatasourceSelectItems","queryKey","queryFn","useDatasourceClient","selector","store","getDatasourceClient","useDatasource","getDatasource"],"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,SAASA,QAAQ,QAAwB,wBAAwB;AACjE,SAASC,aAAa,EAAEC,UAAU,QAAQ,QAAQ;AA8DlD,OAAO,MAAMC,yBAAyBF,cAA2CG,WAAW;AAE5F,OAAO,SAASC;IACd,MAAMC,MAAMJ,WAAWC;IACvB,IAAIG,QAAQF,WAAW;QACrB,MAAM,IAAIG,MAAM;IAClB;IACA,OAAOD;AACT;AAEA;;;CAGC,GACD,OAAO,SAASE,6BACdC,oBAA4B,EAC5BC,OAAgB;IAEhB,MAAM,EAAEC,yBAAyB,EAAE,GAAGN;IACtC,OAAOL,SAAsC;QAC3CY,UAAU;YAAC;YAA6BH;YAAsBC;SAAQ;QACtEG,SAAS,IAAMF,0BAA0BF;IAC3C;AACF;AAEA;;CAEC,GACD,OAAO,SAASK,oBAA4BC,QAA4B;IACtE,MAAMC,QAAQX;IACd,OAAOL,SAAiB;QACtBY,UAAU;YAAC;YAAuBG;SAAS;QAC3CF,SAAS,IAAMG,MAAMC,mBAAmB,CAASF;IACnD;AACF;AAEA,OAAO,SAASG,cAAcH,QAA4B;IACxD,MAAMC,QAAQX;IACd,OAAOL,SAAyB;QAC9BY,UAAU;YAAC;YAAiBG;SAAS;QACrCF,SAAS,IAAMG,MAAMG,aAAa,CAACJ;IACrC;AACF"}
1
+ {"version":3,"sources":["../../src/runtime/datasources.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, DatasourceSpec } from '@perses-dev/spec';\nimport { useQuery, UseQueryResult } from '@tanstack/react-query';\nimport { createContext, useContext } from 'react';\n\nexport interface DatasourceStore {\n // TODO: Do we even need this method?\n getDatasource(selector: DatasourceSelector): Promise<DatasourceSpec>;\n\n /**\n * Gets a cached datasource spec synchronously if available.\n * Used by variable dependency resolution to avoid async calls in dependsOn().\n * Returns undefined if the spec is not cached.\n */\n getDatasourceSpecSync?(selector: DatasourceSelector): DatasourceSpec | undefined;\n\n /**\n * Given a DatasourceSelector, gets a `Client` object from the corresponding Datasource plugin.\n */\n getDatasourceClient<Client>(selector: DatasourceSelector): Promise<Client>;\n\n /**\n * Gets a list of datasource selection items for a plugin kind.\n */\n listDatasourceSelectItems(datasourcePluginName: string): Promise<DatasourceSelectItemGroup[]>;\n\n /**\n * Gets the list of datasources defined in the dashboard\n */\n getLocalDatasources(): Record<string, DatasourceSpec>;\n\n /**\n * Sets the list of datasources defined in the dashboard\n */\n setLocalDatasources(datasources: Record<string, DatasourceSpec>): void;\n\n /**\n * Gets the list of datasources that are available in the dashboard (i.e. dashboards that have been created on the server side that we can use).\n */\n getSavedDatasources(): Record<string, DatasourceSpec>;\n\n /**\n * Sets the list of datasources that are saved in the dashboard\n */\n setSavedDatasources(datasources: Record<string, DatasourceSpec>): void;\n}\n\nexport interface DatasourceSelectItemGroup {\n group?: string;\n editLink?: string;\n items: DatasourceSelectItem[];\n}\n\nexport interface DatasourceSelectItem {\n name: string;\n overridden?: boolean;\n overriding?: boolean;\n saved?: boolean;\n selector: DatasourceSelectItemSelector;\n}\n\n/**\n * Datasource Selector used by the frontend only to differentiate datasources coming from different group.\n */\nexport interface DatasourceSelectItemSelector extends DatasourceSelector {\n /**\n * Group of the datasource.\n * Omit it if you don't store datasource by group.\n */\n group?: string;\n}\n\nexport const DatasourceStoreContext = createContext<DatasourceStore | undefined>(undefined);\n\nexport function useDatasourceStore(): DatasourceStore {\n const ctx = useContext(DatasourceStoreContext);\n if (ctx === undefined) {\n throw new Error('No DatasourceStoreContext found. Did you forget a Provider?');\n }\n return ctx;\n}\n\n/**\n * Lists all available Datasource selection items for a given datasource plugin kind.\n * Returns a list, with all information that can be used in a datasource selection context (group, name, selector, kind, ...)\n */\nexport function useListDatasourceSelectItems(\n datasourcePluginName: string,\n project?: string\n): UseQueryResult<DatasourceSelectItemGroup[]> {\n const { listDatasourceSelectItems } = useDatasourceStore();\n return useQuery<DatasourceSelectItemGroup[]>({\n queryKey: ['listDatasourceSelectItems', datasourcePluginName, project],\n queryFn: () => listDatasourceSelectItems(datasourcePluginName),\n });\n}\n\n/**\n * Provides a convenience hook for getting a DatasourceClient for a given DatasourceSelector.\n */\nexport function useDatasourceClient<Client>(selector: DatasourceSelector): UseQueryResult<Client> {\n const store = useDatasourceStore();\n return useQuery<Client>({\n queryKey: ['getDatasourceClient', selector],\n queryFn: () => store.getDatasourceClient<Client>(selector),\n });\n}\n\nexport function useDatasource(selector: DatasourceSelector): UseQueryResult<DatasourceSpec> {\n const store = useDatasourceStore();\n return useQuery<DatasourceSpec>({\n queryKey: ['getDatasource', selector],\n queryFn: () => store.getDatasource(selector),\n });\n}\n"],"names":["useQuery","createContext","useContext","DatasourceStoreContext","undefined","useDatasourceStore","ctx","Error","useListDatasourceSelectItems","datasourcePluginName","project","listDatasourceSelectItems","queryKey","queryFn","useDatasourceClient","selector","store","getDatasourceClient","useDatasource","getDatasource"],"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,SAASA,QAAQ,QAAwB,wBAAwB;AACjE,SAASC,aAAa,EAAEC,UAAU,QAAQ,QAAQ;AAqElD,OAAO,MAAMC,yBAAyBF,cAA2CG,WAAW;AAE5F,OAAO,SAASC;IACd,MAAMC,MAAMJ,WAAWC;IACvB,IAAIG,QAAQF,WAAW;QACrB,MAAM,IAAIG,MAAM;IAClB;IACA,OAAOD;AACT;AAEA;;;CAGC,GACD,OAAO,SAASE,6BACdC,oBAA4B,EAC5BC,OAAgB;IAEhB,MAAM,EAAEC,yBAAyB,EAAE,GAAGN;IACtC,OAAOL,SAAsC;QAC3CY,UAAU;YAAC;YAA6BH;YAAsBC;SAAQ;QACtEG,SAAS,IAAMF,0BAA0BF;IAC3C;AACF;AAEA;;CAEC,GACD,OAAO,SAASK,oBAA4BC,QAA4B;IACtE,MAAMC,QAAQX;IACd,OAAOL,SAAiB;QACtBY,UAAU;YAAC;YAAuBG;SAAS;QAC3CF,SAAS,IAAMG,MAAMC,mBAAmB,CAASF;IACnD;AACF;AAEA,OAAO,SAASG,cAAcH,QAA4B;IACxD,MAAMC,QAAQX;IACd,OAAOL,SAAyB;QAC9BY,UAAU;YAAC;YAAiBG;SAAS;QACrCF,SAAS,IAAMG,MAAMG,aAAa,CAACJ;IACrC;AACF"}
@@ -1,3 +1,4 @@
1
+ export * from './annotations';
1
2
  export * from './builtin-variables';
2
3
  export * from './datasources';
3
4
  export * from './plugin-registry';
@@ -6,9 +7,10 @@ export * from './TimeRangeProvider';
6
7
  export * from './time-series-queries';
7
8
  export * from './trace-queries';
8
9
  export * from './profile-queries';
10
+ export * from './alerts-queries';
11
+ export * from './silences-queries';
9
12
  export * from './item-actions';
10
13
  export * from './DataQueriesProvider';
11
- export * from './QueryCountProvider';
12
14
  export * from './RouterProvider';
13
15
  export * from './UsageMetricsProvider';
14
16
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/runtime/index.ts"],"names":[],"mappings":"AAaA,cAAc,qBAAqB,CAAC;AACpC,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,wBAAwB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/runtime/index.ts"],"names":[],"mappings":"AAaA,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,kBAAkB,CAAC;AACjC,cAAc,wBAAwB,CAAC"}
@@ -10,6 +10,7 @@
10
10
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
11
  // See the License for the specific language governing permissions and
12
12
  // limitations under the License.
13
+ export * from './annotations';
13
14
  export * from './builtin-variables';
14
15
  export * from './datasources';
15
16
  export * from './plugin-registry';
@@ -18,9 +19,10 @@ export * from './TimeRangeProvider';
18
19
  export * from './time-series-queries';
19
20
  export * from './trace-queries';
20
21
  export * from './profile-queries';
22
+ export * from './alerts-queries';
23
+ export * from './silences-queries';
21
24
  export * from './item-actions';
22
25
  export * from './DataQueriesProvider';
23
- export * from './QueryCountProvider';
24
26
  export * from './RouterProvider';
25
27
  export * from './UsageMetricsProvider';
26
28
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/runtime/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 './builtin-variables';\nexport * from './datasources';\nexport * from './plugin-registry';\nexport * from './variables';\nexport * from './TimeRangeProvider';\nexport * from './time-series-queries';\nexport * from './trace-queries';\nexport * from './profile-queries';\nexport * from './item-actions';\nexport * from './DataQueriesProvider';\nexport * from './QueryCountProvider';\nexport * from './RouterProvider';\nexport * from './UsageMetricsProvider';\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,sBAAsB;AACpC,cAAc,gBAAgB;AAC9B,cAAc,oBAAoB;AAClC,cAAc,cAAc;AAC5B,cAAc,sBAAsB;AACpC,cAAc,wBAAwB;AACtC,cAAc,kBAAkB;AAChC,cAAc,oBAAoB;AAClC,cAAc,iBAAiB;AAC/B,cAAc,wBAAwB;AACtC,cAAc,uBAAuB;AACrC,cAAc,mBAAmB;AACjC,cAAc,yBAAyB"}
1
+ {"version":3,"sources":["../../src/runtime/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 './annotations';\nexport * from './builtin-variables';\nexport * from './datasources';\nexport * from './plugin-registry';\nexport * from './variables';\nexport * from './TimeRangeProvider';\nexport * from './time-series-queries';\nexport * from './trace-queries';\nexport * from './profile-queries';\nexport * from './alerts-queries';\nexport * from './silences-queries';\nexport * from './item-actions';\nexport * from './DataQueriesProvider';\nexport * from './RouterProvider';\nexport * from './UsageMetricsProvider';\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,gBAAgB;AAC9B,cAAc,sBAAsB;AACpC,cAAc,gBAAgB;AAC9B,cAAc,oBAAoB;AAClC,cAAc,cAAc;AAC5B,cAAc,sBAAsB;AACpC,cAAc,wBAAwB;AACtC,cAAc,kBAAkB;AAChC,cAAc,oBAAoB;AAClC,cAAc,mBAAmB;AACjC,cAAc,qBAAqB;AACnC,cAAc,iBAAiB;AAC/B,cAAc,wBAAwB;AACtC,cAAc,mBAAmB;AACjC,cAAc,yBAAyB"}
@@ -11,7 +11,7 @@
11
11
  // See the License for the specific language governing permissions and
12
12
  // limitations under the License.
13
13
  import { interpolateSelectionBatch, interpolateSelectionIndividual } from '@perses-dev/components';
14
- import { fetch } from '@perses-dev/core'; // TODO should be part of an utils package
14
+ import { fetch } from '@perses-dev/client';
15
15
  const BODY_METHODS = new Set([
16
16
  'POST',
17
17
  'PUT',