@perses-dev/plugin-system 0.0.0-snapshot-panel-extra-content-2-2767e21 → 0.0.0-snapshot-scatter-chart-embed-8efdfab

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 (373) hide show
  1. package/dist/cjs/components/CalculationSelector/CalculationSelector.js +6 -4
  2. package/dist/cjs/components/CalculationSelector/index.js +10 -8
  3. package/dist/cjs/components/DatasourceEditorForm/DatasourceEditorForm.js +350 -0
  4. package/dist/cjs/components/DatasourceEditorForm/index.js +30 -0
  5. package/dist/cjs/components/DatasourceSelect.js +135 -25
  6. package/dist/cjs/components/LegendOptionsEditor/LegendOptionsEditor.js +18 -16
  7. package/dist/cjs/components/LegendOptionsEditor/index.js +10 -8
  8. package/dist/cjs/components/OptionsEditorRadios/OptionsEditorRadios.js +69 -0
  9. package/dist/cjs/components/OptionsEditorRadios/index.js +30 -0
  10. package/dist/cjs/components/{OptionsEditorTabs/TabPanel.js → OptionsEditorTabPanel/OptionsEditorTabPanel.js} +8 -6
  11. package/dist/cjs/components/OptionsEditorTabPanel/index.js +30 -0
  12. package/dist/cjs/components/OptionsEditorTabs/OptionsEditorTabs.js +10 -8
  13. package/dist/cjs/components/OptionsEditorTabs/index.js +10 -8
  14. package/dist/cjs/components/PanelSpecEditor/PanelSpecEditor.js +55 -14
  15. package/dist/cjs/components/PanelSpecEditor/index.js +10 -8
  16. package/dist/cjs/components/PluginEditor/PluginEditor.js +24 -31
  17. package/dist/cjs/components/PluginEditor/index.js +11 -9
  18. package/dist/cjs/components/PluginEditor/plugin-editor-api.js +5 -3
  19. package/dist/cjs/components/PluginKindSelect/PluginKindSelect.js +23 -12
  20. package/dist/cjs/components/PluginKindSelect/index.js +10 -8
  21. package/dist/cjs/components/PluginRegistry/PluginRegistry.js +11 -9
  22. package/dist/cjs/components/PluginRegistry/index.js +10 -8
  23. package/dist/cjs/components/PluginRegistry/plugin-indexes.js +6 -2
  24. package/dist/cjs/components/PluginSpecEditor/PluginSpecEditor.js +6 -4
  25. package/dist/cjs/components/PluginSpecEditor/index.js +10 -8
  26. package/dist/cjs/components/ProjectSelect.js +96 -0
  27. package/dist/cjs/components/TimeSeriesQueryEditor/TimeSeriesQueryEditor.js +27 -23
  28. package/dist/cjs/components/TimeSeriesQueryEditor/TimeSeriesQueryInput.js +21 -19
  29. package/dist/cjs/components/TimeSeriesQueryEditor/index.js +10 -8
  30. package/dist/cjs/components/TraceQueryEditor/TraceQueryEditor.js +143 -0
  31. package/dist/cjs/components/TraceQueryEditor/TraceQueryInput.js +96 -0
  32. package/dist/cjs/components/TraceQueryEditor/index.js +30 -0
  33. package/dist/cjs/components/Variables/VariableEditorForm/VariableEditorForm.js +438 -229
  34. package/dist/cjs/components/Variables/VariableEditorForm/VariablePreview.js +32 -28
  35. package/dist/cjs/components/Variables/VariableEditorForm/index.js +11 -9
  36. package/dist/cjs/components/Variables/VariableEditorForm/variable-editor-form-model.js +35 -36
  37. package/dist/cjs/components/Variables/index.js +11 -9
  38. package/dist/cjs/components/Variables/variable-model.js +17 -9
  39. package/dist/cjs/components/index.js +23 -18
  40. package/dist/cjs/constants/index.js +10 -8
  41. package/dist/cjs/constants/user-interface-text.js +3 -1
  42. package/dist/cjs/context/ProjectStoreProvider.js +78 -0
  43. package/dist/cjs/context/index.js +30 -0
  44. package/dist/cjs/context/query-params.js +49 -0
  45. package/dist/cjs/index.js +17 -13
  46. package/dist/cjs/model/index.js +18 -15
  47. package/dist/cjs/model/legend.js +32 -20
  48. package/dist/cjs/model/panels.js +2 -2
  49. package/dist/cjs/model/plugin-base.js +2 -2
  50. package/dist/cjs/model/plugin-loading.js +3 -1
  51. package/dist/cjs/model/trace-queries.js +16 -0
  52. package/dist/cjs/runtime/DataQueriesProvider/DataQueriesProvider.js +67 -35
  53. package/dist/cjs/runtime/DataQueriesProvider/index.js +11 -9
  54. package/dist/cjs/runtime/DataQueriesProvider/model.js +81 -0
  55. package/dist/cjs/runtime/TimeRangeProvider/TimeRangeProvider.js +43 -26
  56. package/dist/cjs/runtime/TimeRangeProvider/TimeRangeProviderWithQueryParams.js +43 -0
  57. package/dist/cjs/runtime/TimeRangeProvider/index.js +12 -9
  58. package/dist/cjs/runtime/TimeRangeProvider/query-params.js +41 -55
  59. package/dist/cjs/runtime/TimeRangeProvider/refresh-interval.js +30 -0
  60. package/dist/cjs/runtime/builtin-variables.js +81 -0
  61. package/dist/cjs/runtime/datasources.js +31 -12
  62. package/dist/cjs/runtime/index.js +17 -13
  63. package/dist/cjs/runtime/plugin-registry.js +41 -11
  64. package/dist/cjs/runtime/template-variables.js +96 -4
  65. package/dist/cjs/runtime/time-series-queries.js +39 -27
  66. package/dist/cjs/runtime/trace-queries.js +76 -0
  67. package/dist/cjs/stories/shared-utils/decorators/WithDataQueries.js +7 -5
  68. package/dist/cjs/stories/shared-utils/decorators/WithPluginRegistry.js +18 -15
  69. package/dist/cjs/stories/shared-utils/decorators/WithPluginSystemBuiltinVariables.js +42 -0
  70. package/dist/cjs/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.js +31 -13
  71. package/dist/cjs/stories/shared-utils/decorators/WithPluginSystemTemplateVariables.js +6 -4
  72. package/dist/cjs/stories/shared-utils/decorators/WithTimeRange.js +9 -7
  73. package/dist/cjs/stories/shared-utils/decorators/index.js +15 -12
  74. package/dist/cjs/stories/shared-utils/index.js +10 -8
  75. package/dist/cjs/test/index.js +11 -8
  76. package/dist/cjs/test/mock-data.js +80 -0
  77. package/dist/cjs/test/render.js +13 -11
  78. package/dist/cjs/test/test-plugins/bert/index.js +14 -10
  79. package/dist/cjs/test/test-plugins/ernie/index.js +13 -9
  80. package/dist/cjs/test/test-plugins/index.js +11 -9
  81. package/dist/cjs/test-utils/index.js +10 -8
  82. package/dist/cjs/test-utils/mock-plugin-registry.js +8 -4
  83. package/dist/cjs/utils/action.js +43 -0
  84. package/dist/cjs/utils/index.js +11 -8
  85. package/dist/cjs/utils/variables.js +26 -8
  86. package/dist/cjs/validation/datasource.js +30 -0
  87. package/dist/cjs/validation/index.js +33 -0
  88. package/dist/cjs/validation/resource.js +24 -0
  89. package/dist/cjs/validation/role.js +85 -0
  90. package/dist/cjs/validation/rolebinding.js +55 -0
  91. package/dist/cjs/validation/secret.js +176 -0
  92. package/dist/cjs/validation/variable.js +48 -0
  93. package/dist/components/CalculationSelector/CalculationSelector.js.map +1 -1
  94. package/dist/components/CalculationSelector/index.js.map +1 -1
  95. package/dist/components/DatasourceEditorForm/DatasourceEditorForm.d.ts +15 -0
  96. package/dist/components/DatasourceEditorForm/DatasourceEditorForm.d.ts.map +1 -0
  97. package/dist/components/DatasourceEditorForm/DatasourceEditorForm.js +342 -0
  98. package/dist/components/DatasourceEditorForm/DatasourceEditorForm.js.map +1 -0
  99. package/dist/components/DatasourceEditorForm/index.d.ts +2 -0
  100. package/dist/components/DatasourceEditorForm/index.d.ts.map +1 -0
  101. package/dist/components/DatasourceEditorForm/index.js +15 -0
  102. package/dist/components/DatasourceEditorForm/index.js.map +1 -0
  103. package/dist/components/DatasourceSelect.d.ts +6 -0
  104. package/dist/components/DatasourceSelect.d.ts.map +1 -1
  105. package/dist/components/DatasourceSelect.js +118 -23
  106. package/dist/components/DatasourceSelect.js.map +1 -1
  107. package/dist/components/LegendOptionsEditor/LegendOptionsEditor.js +2 -2
  108. package/dist/components/LegendOptionsEditor/LegendOptionsEditor.js.map +1 -1
  109. package/dist/components/LegendOptionsEditor/index.js.map +1 -1
  110. package/dist/components/OptionsEditorRadios/OptionsEditorRadios.d.ts +16 -0
  111. package/dist/components/OptionsEditorRadios/OptionsEditorRadios.d.ts.map +1 -0
  112. package/dist/components/OptionsEditorRadios/OptionsEditorRadios.js +61 -0
  113. package/dist/components/OptionsEditorRadios/OptionsEditorRadios.js.map +1 -0
  114. package/dist/components/OptionsEditorRadios/index.d.ts +2 -0
  115. package/dist/components/OptionsEditorRadios/index.d.ts.map +1 -0
  116. package/dist/components/OptionsEditorRadios/index.js +15 -0
  117. package/dist/components/OptionsEditorRadios/index.js.map +1 -0
  118. package/dist/components/OptionsEditorTabPanel/OptionsEditorTabPanel.d.ts +9 -0
  119. package/dist/components/OptionsEditorTabPanel/OptionsEditorTabPanel.d.ts.map +1 -0
  120. package/dist/components/{OptionsEditorTabs/TabPanel.js → OptionsEditorTabPanel/OptionsEditorTabPanel.js} +2 -2
  121. package/dist/components/OptionsEditorTabPanel/OptionsEditorTabPanel.js.map +1 -0
  122. package/dist/components/OptionsEditorTabPanel/index.d.ts +2 -0
  123. package/dist/components/OptionsEditorTabPanel/index.d.ts.map +1 -0
  124. package/dist/components/OptionsEditorTabPanel/index.js +15 -0
  125. package/dist/components/OptionsEditorTabPanel/index.js.map +1 -0
  126. package/dist/components/OptionsEditorTabs/OptionsEditorTabs.js +2 -2
  127. package/dist/components/OptionsEditorTabs/OptionsEditorTabs.js.map +1 -1
  128. package/dist/components/OptionsEditorTabs/index.js.map +1 -1
  129. package/dist/components/PanelSpecEditor/PanelSpecEditor.d.ts +1 -1
  130. package/dist/components/PanelSpecEditor/PanelSpecEditor.d.ts.map +1 -1
  131. package/dist/components/PanelSpecEditor/PanelSpecEditor.js +45 -6
  132. package/dist/components/PanelSpecEditor/PanelSpecEditor.js.map +1 -1
  133. package/dist/components/PanelSpecEditor/index.js.map +1 -1
  134. package/dist/components/PluginEditor/PluginEditor.js +15 -24
  135. package/dist/components/PluginEditor/PluginEditor.js.map +1 -1
  136. package/dist/components/PluginEditor/index.js.map +1 -1
  137. package/dist/components/PluginEditor/plugin-editor-api.d.ts +2 -1
  138. package/dist/components/PluginEditor/plugin-editor-api.d.ts.map +1 -1
  139. package/dist/components/PluginEditor/plugin-editor-api.js +2 -2
  140. package/dist/components/PluginEditor/plugin-editor-api.js.map +1 -1
  141. package/dist/components/PluginKindSelect/PluginKindSelect.d.ts +3 -3
  142. package/dist/components/PluginKindSelect/PluginKindSelect.d.ts.map +1 -1
  143. package/dist/components/PluginKindSelect/PluginKindSelect.js +21 -12
  144. package/dist/components/PluginKindSelect/PluginKindSelect.js.map +1 -1
  145. package/dist/components/PluginKindSelect/index.js.map +1 -1
  146. package/dist/components/PluginRegistry/PluginRegistry.js +3 -3
  147. package/dist/components/PluginRegistry/PluginRegistry.js.map +1 -1
  148. package/dist/components/PluginRegistry/index.js.map +1 -1
  149. package/dist/components/PluginRegistry/plugin-indexes.js.map +1 -1
  150. package/dist/components/PluginSpecEditor/PluginSpecEditor.d.ts +1 -0
  151. package/dist/components/PluginSpecEditor/PluginSpecEditor.d.ts.map +1 -1
  152. package/dist/components/PluginSpecEditor/PluginSpecEditor.js.map +1 -1
  153. package/dist/components/PluginSpecEditor/index.js.map +1 -1
  154. package/dist/components/ProjectSelect.d.ts +15 -0
  155. package/dist/components/ProjectSelect.d.ts.map +1 -0
  156. package/dist/components/ProjectSelect.js +91 -0
  157. package/dist/components/ProjectSelect.js.map +1 -0
  158. package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryEditor.d.ts.map +1 -1
  159. package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryEditor.js +19 -17
  160. package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryEditor.js.map +1 -1
  161. package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryInput.js +1 -1
  162. package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryInput.js.map +1 -1
  163. package/dist/components/TimeSeriesQueryEditor/index.js.map +1 -1
  164. package/dist/components/TraceQueryEditor/TraceQueryEditor.d.ts +9 -0
  165. package/dist/components/TraceQueryEditor/TraceQueryEditor.d.ts.map +1 -0
  166. package/dist/components/TraceQueryEditor/TraceQueryEditor.js +130 -0
  167. package/dist/components/TraceQueryEditor/TraceQueryEditor.js.map +1 -0
  168. package/dist/components/TraceQueryEditor/TraceQueryInput.d.ts +13 -0
  169. package/dist/components/TraceQueryEditor/TraceQueryInput.d.ts.map +1 -0
  170. package/dist/components/TraceQueryEditor/TraceQueryInput.js +83 -0
  171. package/dist/components/TraceQueryEditor/TraceQueryInput.js.map +1 -0
  172. package/dist/components/TraceQueryEditor/index.d.ts +2 -0
  173. package/dist/components/TraceQueryEditor/index.d.ts.map +1 -0
  174. package/dist/components/TraceQueryEditor/index.js +15 -0
  175. package/dist/components/TraceQueryEditor/index.js.map +1 -0
  176. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts +10 -8
  177. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts.map +1 -1
  178. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js +391 -184
  179. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js.map +1 -1
  180. package/dist/components/Variables/VariableEditorForm/VariablePreview.js.map +1 -1
  181. package/dist/components/Variables/VariableEditorForm/index.js.map +1 -1
  182. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.d.ts +8 -19
  183. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.d.ts.map +1 -1
  184. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js +29 -34
  185. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js.map +1 -1
  186. package/dist/components/Variables/index.js.map +1 -1
  187. package/dist/components/Variables/variable-model.js +3 -3
  188. package/dist/components/Variables/variable-model.js.map +1 -1
  189. package/dist/components/index.d.ts +3 -0
  190. package/dist/components/index.d.ts.map +1 -1
  191. package/dist/components/index.js +3 -0
  192. package/dist/components/index.js.map +1 -1
  193. package/dist/constants/index.js.map +1 -1
  194. package/dist/constants/user-interface-text.js.map +1 -1
  195. package/dist/context/ProjectStoreProvider.d.ts +16 -0
  196. package/dist/context/ProjectStoreProvider.d.ts.map +1 -0
  197. package/dist/context/ProjectStoreProvider.js +56 -0
  198. package/dist/context/ProjectStoreProvider.js.map +1 -0
  199. package/dist/context/index.d.ts +2 -0
  200. package/dist/context/index.d.ts.map +1 -0
  201. package/dist/context/index.js +15 -0
  202. package/dist/context/index.js.map +1 -0
  203. package/dist/context/query-params.d.ts +5 -0
  204. package/dist/context/query-params.d.ts.map +1 -0
  205. package/dist/context/query-params.js +41 -0
  206. package/dist/context/query-params.js.map +1 -0
  207. package/dist/index.d.ts +2 -0
  208. package/dist/index.d.ts.map +1 -1
  209. package/dist/index.js +2 -0
  210. package/dist/index.js.map +1 -1
  211. package/dist/model/datasource.d.ts +2 -1
  212. package/dist/model/datasource.d.ts.map +1 -1
  213. package/dist/model/datasource.js.map +1 -1
  214. package/dist/model/index.d.ts +1 -0
  215. package/dist/model/index.d.ts.map +1 -1
  216. package/dist/model/index.js +1 -0
  217. package/dist/model/index.js.map +1 -1
  218. package/dist/model/legend.d.ts +1 -1
  219. package/dist/model/legend.d.ts.map +1 -1
  220. package/dist/model/legend.js +14 -14
  221. package/dist/model/legend.js.map +1 -1
  222. package/dist/model/panels.d.ts +2 -1
  223. package/dist/model/panels.d.ts.map +1 -1
  224. package/dist/model/panels.js.map +1 -1
  225. package/dist/model/plugin-base.d.ts +1 -0
  226. package/dist/model/plugin-base.d.ts.map +1 -1
  227. package/dist/model/plugin-base.js.map +1 -1
  228. package/dist/model/plugin-loading.js.map +1 -1
  229. package/dist/model/plugins.d.ts +2 -0
  230. package/dist/model/plugins.d.ts.map +1 -1
  231. package/dist/model/plugins.js.map +1 -1
  232. package/dist/model/trace-queries.d.ts +19 -0
  233. package/dist/model/trace-queries.d.ts.map +1 -0
  234. package/dist/model/trace-queries.js +15 -0
  235. package/dist/model/trace-queries.js.map +1 -0
  236. package/dist/runtime/DataQueriesProvider/DataQueriesProvider.d.ts +5 -5
  237. package/dist/runtime/DataQueriesProvider/DataQueriesProvider.d.ts.map +1 -1
  238. package/dist/runtime/DataQueriesProvider/DataQueriesProvider.js +52 -28
  239. package/dist/runtime/DataQueriesProvider/DataQueriesProvider.js.map +1 -1
  240. package/dist/runtime/DataQueriesProvider/index.js.map +1 -1
  241. package/dist/runtime/DataQueriesProvider/model.d.ts +17 -12
  242. package/dist/runtime/DataQueriesProvider/model.d.ts.map +1 -1
  243. package/dist/runtime/DataQueriesProvider/model.js +67 -1
  244. package/dist/runtime/DataQueriesProvider/model.js.map +1 -1
  245. package/dist/runtime/TimeRangeProvider/TimeRangeProvider.d.ts +4 -3
  246. package/dist/runtime/TimeRangeProvider/TimeRangeProvider.d.ts.map +1 -1
  247. package/dist/runtime/TimeRangeProvider/TimeRangeProvider.js +28 -19
  248. package/dist/runtime/TimeRangeProvider/TimeRangeProvider.js.map +1 -1
  249. package/dist/runtime/TimeRangeProvider/TimeRangeProviderWithQueryParams.d.ts +9 -0
  250. package/dist/runtime/TimeRangeProvider/TimeRangeProviderWithQueryParams.d.ts.map +1 -0
  251. package/dist/runtime/TimeRangeProvider/TimeRangeProviderWithQueryParams.js +30 -0
  252. package/dist/runtime/TimeRangeProvider/TimeRangeProviderWithQueryParams.js.map +1 -0
  253. package/dist/runtime/TimeRangeProvider/index.d.ts +1 -0
  254. package/dist/runtime/TimeRangeProvider/index.d.ts.map +1 -1
  255. package/dist/runtime/TimeRangeProvider/index.js +1 -0
  256. package/dist/runtime/TimeRangeProvider/index.js.map +1 -1
  257. package/dist/runtime/TimeRangeProvider/query-params.d.ts +4 -4
  258. package/dist/runtime/TimeRangeProvider/query-params.d.ts.map +1 -1
  259. package/dist/runtime/TimeRangeProvider/query-params.js +9 -41
  260. package/dist/runtime/TimeRangeProvider/query-params.js.map +1 -1
  261. package/dist/runtime/TimeRangeProvider/refresh-interval.d.ts +7 -0
  262. package/dist/runtime/TimeRangeProvider/refresh-interval.d.ts.map +1 -0
  263. package/dist/runtime/TimeRangeProvider/refresh-interval.js +25 -0
  264. package/dist/runtime/TimeRangeProvider/refresh-interval.js.map +1 -0
  265. package/dist/runtime/builtin-variables.d.ts +11 -0
  266. package/dist/runtime/builtin-variables.d.ts.map +1 -0
  267. package/dist/runtime/builtin-variables.js +59 -0
  268. package/dist/runtime/builtin-variables.js.map +1 -0
  269. package/dist/runtime/datasources.d.ts +42 -7
  270. package/dist/runtime/datasources.d.ts.map +1 -1
  271. package/dist/runtime/datasources.js +15 -7
  272. package/dist/runtime/datasources.js.map +1 -1
  273. package/dist/runtime/index.d.ts +2 -0
  274. package/dist/runtime/index.d.ts.map +1 -1
  275. package/dist/runtime/index.js +2 -0
  276. package/dist/runtime/index.js.map +1 -1
  277. package/dist/runtime/plugin-registry.d.ts +2 -0
  278. package/dist/runtime/plugin-registry.d.ts.map +1 -1
  279. package/dist/runtime/plugin-registry.js +19 -2
  280. package/dist/runtime/plugin-registry.js.map +1 -1
  281. package/dist/runtime/template-variables.d.ts +62 -2
  282. package/dist/runtime/template-variables.d.ts.map +1 -1
  283. package/dist/runtime/template-variables.js +83 -1
  284. package/dist/runtime/template-variables.js.map +1 -1
  285. package/dist/runtime/time-series-queries.d.ts +3 -3
  286. package/dist/runtime/time-series-queries.d.ts.map +1 -1
  287. package/dist/runtime/time-series-queries.js +14 -12
  288. package/dist/runtime/time-series-queries.js.map +1 -1
  289. package/dist/runtime/trace-queries.d.ts +14 -0
  290. package/dist/runtime/trace-queries.d.ts.map +1 -0
  291. package/dist/runtime/trace-queries.js +61 -0
  292. package/dist/runtime/trace-queries.js.map +1 -0
  293. package/dist/stories/shared-utils/decorators/WithDataQueries.js.map +1 -1
  294. package/dist/stories/shared-utils/decorators/WithPluginRegistry.d.ts.map +1 -1
  295. package/dist/stories/shared-utils/decorators/WithPluginRegistry.js +2 -1
  296. package/dist/stories/shared-utils/decorators/WithPluginRegistry.js.map +1 -1
  297. package/dist/stories/shared-utils/decorators/WithPluginSystemBuiltinVariables.d.ts +13 -0
  298. package/dist/stories/shared-utils/decorators/WithPluginSystemBuiltinVariables.d.ts.map +1 -0
  299. package/dist/stories/shared-utils/decorators/WithPluginSystemBuiltinVariables.js +39 -0
  300. package/dist/stories/shared-utils/decorators/WithPluginSystemBuiltinVariables.js.map +1 -0
  301. package/dist/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.d.ts.map +1 -1
  302. package/dist/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.js +23 -7
  303. package/dist/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.js.map +1 -1
  304. package/dist/stories/shared-utils/decorators/WithPluginSystemTemplateVariables.js.map +1 -1
  305. package/dist/stories/shared-utils/decorators/WithTimeRange.d.ts +2 -2
  306. package/dist/stories/shared-utils/decorators/WithTimeRange.d.ts.map +1 -1
  307. package/dist/stories/shared-utils/decorators/WithTimeRange.js +2 -2
  308. package/dist/stories/shared-utils/decorators/WithTimeRange.js.map +1 -1
  309. package/dist/stories/shared-utils/decorators/index.d.ts +1 -0
  310. package/dist/stories/shared-utils/decorators/index.d.ts.map +1 -1
  311. package/dist/stories/shared-utils/decorators/index.js +1 -0
  312. package/dist/stories/shared-utils/decorators/index.js.map +1 -1
  313. package/dist/stories/shared-utils/index.js.map +1 -1
  314. package/dist/test/index.d.ts +1 -0
  315. package/dist/test/index.d.ts.map +1 -1
  316. package/dist/test/index.js +1 -0
  317. package/dist/test/index.js.map +1 -1
  318. package/dist/test/mock-data.d.ts +4 -0
  319. package/dist/test/mock-data.d.ts.map +1 -0
  320. package/dist/test/mock-data.js +64 -0
  321. package/dist/test/mock-data.js.map +1 -0
  322. package/dist/test/render.js +2 -2
  323. package/dist/test/render.js.map +1 -1
  324. package/dist/test/setup-tests.js.map +1 -1
  325. package/dist/test/test-plugins/bert/index.js.map +1 -1
  326. package/dist/test/test-plugins/ernie/index.js.map +1 -1
  327. package/dist/test/test-plugins/index.js.map +1 -1
  328. package/dist/test-utils/index.js.map +1 -1
  329. package/dist/test-utils/mock-plugin-registry.js +2 -2
  330. package/dist/test-utils/mock-plugin-registry.js.map +1 -1
  331. package/dist/utils/action.d.ts +4 -0
  332. package/dist/utils/action.d.ts.map +1 -0
  333. package/dist/utils/action.js +27 -0
  334. package/dist/utils/action.js.map +1 -0
  335. package/dist/utils/index.d.ts +1 -0
  336. package/dist/utils/index.d.ts.map +1 -1
  337. package/dist/utils/index.js +1 -0
  338. package/dist/utils/index.js.map +1 -1
  339. package/dist/utils/variables.d.ts.map +1 -1
  340. package/dist/utils/variables.js +17 -5
  341. package/dist/utils/variables.js.map +1 -1
  342. package/dist/validation/datasource.d.ts +19 -0
  343. package/dist/validation/datasource.d.ts.map +1 -0
  344. package/dist/validation/datasource.js +22 -0
  345. package/dist/validation/datasource.js.map +1 -0
  346. package/dist/validation/index.d.ts +5 -0
  347. package/dist/validation/index.d.ts.map +1 -0
  348. package/dist/validation/index.js +18 -0
  349. package/dist/validation/index.js.map +1 -0
  350. package/dist/validation/resource.d.ts +3 -0
  351. package/dist/validation/resource.d.ts.map +1 -0
  352. package/dist/validation/resource.js +16 -0
  353. package/dist/validation/resource.js.map +1 -0
  354. package/dist/validation/role.d.ts +228 -0
  355. package/dist/validation/role.d.ts.map +1 -0
  356. package/dist/validation/role.js +66 -0
  357. package/dist/validation/role.js.map +1 -0
  358. package/dist/validation/rolebinding.d.ts +137 -0
  359. package/dist/validation/rolebinding.d.ts.map +1 -0
  360. package/dist/validation/rolebinding.js +47 -0
  361. package/dist/validation/rolebinding.js.map +1 -0
  362. package/dist/validation/secret.d.ts +964 -0
  363. package/dist/validation/secret.d.ts.map +1 -0
  364. package/dist/validation/secret.js +157 -0
  365. package/dist/validation/secret.js.map +1 -0
  366. package/dist/validation/variable.d.ts +96 -0
  367. package/dist/validation/variable.d.ts.map +1 -0
  368. package/dist/validation/variable.js +40 -0
  369. package/dist/validation/variable.js.map +1 -0
  370. package/package.json +9 -6
  371. package/dist/components/OptionsEditorTabs/TabPanel.d.ts +0 -9
  372. package/dist/components/OptionsEditorTabs/TabPanel.d.ts.map +0 -1
  373. package/dist/components/OptionsEditorTabs/TabPanel.js.map +0 -1
@@ -13,10 +13,8 @@
13
13
  import { jsx as _jsx } from "react/jsx-runtime";
14
14
  import { createContext, useCallback, useContext, useMemo } from 'react';
15
15
  import { useTimeSeriesQueries } from '../time-series-queries';
16
- export function useDataQueries() {
17
- const ctx = useDataQueriesContext();
18
- return ctx;
19
- }
16
+ import { useTraceQueries } from '../trace-queries';
17
+ import { transformQueryResults, useQueryType } from './model';
20
18
  export const DataQueriesContext = /*#__PURE__*/ createContext(undefined);
21
19
  export function useDataQueriesContext() {
22
20
  const ctx = useContext(DataQueriesContext);
@@ -25,44 +23,70 @@ export function useDataQueriesContext() {
25
23
  }
26
24
  return ctx;
27
25
  }
26
+ export function useDataQueries(queryType) {
27
+ const ctx = useDataQueriesContext();
28
+ // Filter the query results based on the specified query type
29
+ const filteredQueryResults = ctx.queryResults.filter((queryResult)=>{
30
+ var _queryResult_definition;
31
+ return (queryResult === null || queryResult === void 0 ? void 0 : (_queryResult_definition = queryResult.definition) === null || _queryResult_definition === void 0 ? void 0 : _queryResult_definition.kind) === queryType;
32
+ });
33
+ // Filter the errors based on the specified query type
34
+ const filteredErrors = ctx.errors.filter((errors, index)=>{
35
+ var _ctx_queryResults_index, _ctx_queryResults_index_definition;
36
+ return ((_ctx_queryResults_index = ctx.queryResults[index]) === null || _ctx_queryResults_index === void 0 ? void 0 : (_ctx_queryResults_index_definition = _ctx_queryResults_index.definition) === null || _ctx_queryResults_index_definition === void 0 ? void 0 : _ctx_queryResults_index_definition.kind) === queryType;
37
+ });
38
+ // Create a new context object with the filtered results and errors
39
+ const filteredCtx = {
40
+ queryResults: filteredQueryResults,
41
+ isFetching: filteredQueryResults.some((result)=>result.isFetching),
42
+ isLoading: filteredQueryResults.some((result)=>result.isLoading),
43
+ refetchAll: ctx.refetchAll,
44
+ errors: filteredErrors
45
+ };
46
+ return filteredCtx;
47
+ }
28
48
  export function DataQueriesProvider(props) {
29
- const { definitions , options , children } = props;
30
- // For now we will map each query plugin definition to TimeSeriesQueryDefinition
31
- // Later on when we add support for other query types,
32
- // we will have to map each query maps to the correct QueryDefinition
33
- const timeSeriesQueries = definitions.map((definition)=>({
34
- kind: 'TimeSeriesQuery',
49
+ const { definitions , options , children , queryOptions } = props;
50
+ // Returns a query kind, for example "TimeSeriesQuery" = getQueryType("PrometheusTimeSeriesQuery")
51
+ const getQueryType = useQueryType();
52
+ const queryDefinitions = definitions.map((definition)=>{
53
+ const type = getQueryType(definition.kind);
54
+ return {
55
+ kind: type,
35
56
  spec: {
36
57
  plugin: definition
37
58
  }
38
- }));
39
- const results = useTimeSeriesQueries(timeSeriesQueries, options);
40
- const data = results.map(({ data , isFetching , isLoading , refetch , error }, i)=>{
41
- return {
42
- definition: definitions[i],
43
- data,
44
- isFetching,
45
- isLoading,
46
- refetch,
47
- error
48
59
  };
49
60
  });
61
+ // Filter definitions for time series query and other future query plugins
62
+ const timeSeriesQueries = queryDefinitions.filter((definition)=>definition.kind === 'TimeSeriesQuery');
63
+ const timeSeriesResults = useTimeSeriesQueries(timeSeriesQueries, options, queryOptions);
64
+ const traceQueries = queryDefinitions.filter((definition)=>definition.kind === 'TraceQuery');
65
+ const traceResults = useTraceQueries(traceQueries);
50
66
  const refetchAll = useCallback(()=>{
51
- results.forEach((result)=>result.refetch());
67
+ timeSeriesResults.forEach((result)=>result.refetch());
68
+ traceResults.forEach((result)=>result.refetch());
52
69
  }, [
53
- results
70
+ timeSeriesResults,
71
+ traceResults
54
72
  ]);
55
73
  const ctx = useMemo(()=>{
74
+ const mergedQueryResults = [
75
+ ...transformQueryResults(timeSeriesResults, timeSeriesQueries),
76
+ ...transformQueryResults(traceResults, traceQueries)
77
+ ];
56
78
  return {
57
- queryResults: data,
58
- isFetching: results.some((result)=>result.isFetching),
59
- isLoading: results.some((result)=>result.isLoading),
79
+ queryResults: mergedQueryResults,
80
+ isFetching: mergedQueryResults.some((result)=>result.isFetching),
81
+ isLoading: mergedQueryResults.some((result)=>result.isLoading),
60
82
  refetchAll,
61
- errors: results.map((result)=>result.error)
83
+ errors: mergedQueryResults.map((result)=>result.error)
62
84
  };
63
85
  }, [
64
- data,
65
- results,
86
+ timeSeriesQueries,
87
+ timeSeriesResults,
88
+ traceQueries,
89
+ traceResults,
66
90
  refetchAll
67
91
  ]);
68
92
  return /*#__PURE__*/ _jsx(DataQueriesContext.Provider, {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/runtime/DataQueriesProvider/DataQueriesProvider.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { createContext, useCallback, useContext, useMemo } from 'react';\nimport { Definition, TimeSeriesQueryDefinition, UnknownSpec } from '@perses-dev/core';\nimport { useTimeSeriesQueries } from '../time-series-queries';\nimport { DataQueriesProviderProps, QueryData, UseDataQueryResults } from './model';\n\nexport function useDataQueries(): UseDataQueryResults {\n const ctx = useDataQueriesContext();\n return ctx;\n}\n\nexport const DataQueriesContext = createContext<UseDataQueryResults | undefined>(undefined);\n\nexport function useDataQueriesContext() {\n const ctx = useContext(DataQueriesContext);\n if (ctx === undefined) {\n throw new Error('No DataQueriesContext found. Did you forget a Provider?');\n }\n return ctx;\n}\n\nexport function DataQueriesProvider(props: DataQueriesProviderProps) {\n const { definitions, options, children } = props;\n\n // For now we will map each query plugin definition to TimeSeriesQueryDefinition\n // Later on when we add support for other query types,\n // we will have to map each query maps to the correct QueryDefinition\n const timeSeriesQueries = definitions.map(\n (definition) =>\n ({\n kind: 'TimeSeriesQuery',\n spec: {\n plugin: definition,\n },\n } as TimeSeriesQueryDefinition)\n );\n const results = useTimeSeriesQueries(timeSeriesQueries, options);\n\n const data = results.map(({ data, isFetching, isLoading, refetch, error }, i) => {\n return {\n definition: definitions[i],\n data,\n isFetching,\n isLoading,\n refetch,\n error,\n } as QueryData<Definition<UnknownSpec>>;\n });\n\n const refetchAll = useCallback(() => {\n results.forEach((result) => result.refetch());\n }, [results]);\n\n const ctx = useMemo(() => {\n return {\n queryResults: data,\n isFetching: results.some((result) => result.isFetching),\n isLoading: results.some((result) => result.isLoading),\n refetchAll,\n errors: results.map((result) => result.error),\n };\n }, [data, results, refetchAll]);\n\n return <DataQueriesContext.Provider value={ctx}>{children}</DataQueriesContext.Provider>;\n}\n"],"names":["createContext","useCallback","useContext","useMemo","useTimeSeriesQueries","useDataQueries","ctx","useDataQueriesContext","DataQueriesContext","undefined","Error","DataQueriesProvider","props","definitions","options","children","timeSeriesQueries","map","definition","kind","spec","plugin","results","data","isFetching","isLoading","refetch","error","i","refetchAll","forEach","result","queryResults","some","errors","Provider","value"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AAAA,SAASA,aAAa,EAAEC,WAAW,EAAEC,UAAU,EAAEC,OAAO,QAAQ,OAAO,CAAC;AAExE,SAASC,oBAAoB,QAAQ,wBAAwB,CAAC;AAG9D,OAAO,SAASC,cAAc,GAAwB;IACpD,MAAMC,GAAG,GAAGC,qBAAqB,EAAE,AAAC;IACpC,OAAOD,GAAG,CAAC;AACb,CAAC;AAED,OAAO,MAAME,kBAAkB,iBAAGR,aAAa,CAAkCS,SAAS,CAAC,CAAC;AAE5F,OAAO,SAASF,qBAAqB,GAAG;IACtC,MAAMD,GAAG,GAAGJ,UAAU,CAACM,kBAAkB,CAAC,AAAC;IAC3C,IAAIF,GAAG,KAAKG,SAAS,EAAE;QACrB,MAAM,IAAIC,KAAK,CAAC,yDAAyD,CAAC,CAAC;IAC7E,CAAC;IACD,OAAOJ,GAAG,CAAC;AACb,CAAC;AAED,OAAO,SAASK,mBAAmB,CAACC,KAA+B,EAAE;IACnE,MAAM,EAAEC,WAAW,CAAA,EAAEC,OAAO,CAAA,EAAEC,QAAQ,CAAA,EAAE,GAAGH,KAAK,AAAC;IAEjD,gFAAgF;IAChF,sDAAsD;IACtD,qEAAqE;IACrE,MAAMI,iBAAiB,GAAGH,WAAW,CA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;QAACC,KAAK,EAAE9B,GAAG;kBAAGS,QAAQ;MAA+B,CAAC;AAC3F,CAAC"}
1
+ {"version":3,"sources":["../../../src/runtime/DataQueriesProvider/DataQueriesProvider.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { createContext, useCallback, useContext, useMemo } from 'react';\nimport { QueryType, TimeSeriesQueryDefinition } from '@perses-dev/core';\nimport { useTimeSeriesQueries } from '../time-series-queries';\nimport { useTraceQueries, TraceQueryDefinition } from '../trace-queries';\n\nimport {\n DataQueriesProviderProps,\n UseDataQueryResults,\n transformQueryResults,\n DataQueriesContextType,\n QueryData,\n useQueryType,\n} from './model';\n\nexport const DataQueriesContext = createContext<DataQueriesContextType | undefined>(undefined);\n\nexport function useDataQueriesContext() {\n const ctx = useContext(DataQueriesContext);\n if (ctx === undefined) {\n throw new Error('No DataQueriesContext found. Did you forget a Provider?');\n }\n return ctx;\n}\n\nexport function useDataQueries<T extends keyof QueryType>(queryType: T): UseDataQueryResults<QueryType[T]> {\n const ctx = useDataQueriesContext();\n\n // Filter the query results based on the specified query type\n const filteredQueryResults = ctx.queryResults.filter(\n (queryResult) => queryResult?.definition?.kind === queryType\n ) as Array<QueryData<QueryType[T]>>;\n\n // Filter the errors based on the specified query type\n const filteredErrors = ctx.errors.filter((errors, index) => ctx.queryResults[index]?.definition?.kind === queryType);\n\n // Create a new context object with the filtered results and errors\n const filteredCtx = {\n queryResults: filteredQueryResults,\n isFetching: filteredQueryResults.some((result) => result.isFetching),\n isLoading: filteredQueryResults.some((result) => result.isLoading),\n refetchAll: ctx.refetchAll,\n errors: filteredErrors,\n };\n\n return filteredCtx;\n}\n\nexport function DataQueriesProvider(props: DataQueriesProviderProps) {\n const { definitions, options, children, queryOptions } = props;\n\n // Returns a query kind, for example \"TimeSeriesQuery\" = getQueryType(\"PrometheusTimeSeriesQuery\")\n const getQueryType = useQueryType();\n\n const queryDefinitions = definitions.map((definition) => {\n const type = getQueryType(definition.kind);\n return {\n kind: type,\n spec: {\n plugin: definition,\n },\n };\n });\n\n // Filter definitions for time series query and other future query plugins\n const timeSeriesQueries = queryDefinitions.filter(\n (definition) => definition.kind === 'TimeSeriesQuery'\n ) as TimeSeriesQueryDefinition[];\n const timeSeriesResults = useTimeSeriesQueries(timeSeriesQueries, options, queryOptions);\n\n const traceQueries = queryDefinitions.filter(\n (definition) => definition.kind === 'TraceQuery'\n ) as TraceQueryDefinition[];\n const traceResults = useTraceQueries(traceQueries);\n\n const refetchAll = useCallback(() => {\n timeSeriesResults.forEach((result) => result.refetch());\n traceResults.forEach((result) => result.refetch());\n }, [timeSeriesResults, traceResults]);\n\n const ctx = useMemo(() => {\n const mergedQueryResults = [\n ...transformQueryResults(timeSeriesResults, timeSeriesQueries),\n ...transformQueryResults(traceResults, traceQueries),\n ];\n\n return {\n queryResults: mergedQueryResults,\n isFetching: mergedQueryResults.some((result) => result.isFetching),\n isLoading: mergedQueryResults.some((result) => result.isLoading),\n refetchAll,\n errors: mergedQueryResults.map((result) => result.error),\n };\n }, [timeSeriesQueries, timeSeriesResults, traceQueries, traceResults, refetchAll]);\n\n return <DataQueriesContext.Provider value={ctx}>{children}</DataQueriesContext.Provider>;\n}\n"],"names":["createContext","useCallback","useContext","useMemo","useTimeSeriesQueries","useTraceQueries","transformQueryResults","useQueryType","DataQueriesContext","undefined","useDataQueriesContext","ctx","Error","useDataQueries","queryType","filteredQueryResults","queryResults","filter","queryResult","definition","kind","filteredErrors","errors","index","filteredCtx","isFetching","some","result","isLoading","refetchAll","DataQueriesProvider","props","definitions","options","children","queryOptions","getQueryType","queryDefinitions","map","type","spec","plugin","timeSeriesQueries","timeSeriesResults","traceQueries","traceResults","forEach","refetch","mergedQueryResults","error","Provider","value"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,SAASA,aAAa,EAAEC,WAAW,EAAEC,UAAU,EAAEC,OAAO,QAAQ,QAAQ;AAExE,SAASC,oBAAoB,QAAQ,yBAAyB;AAC9D,SAASC,eAAe,QAA8B,mBAAmB;AAEzE,SAGEC,qBAAqB,EAGrBC,YAAY,QACP,UAAU;AAEjB,OAAO,MAAMC,mCAAqBR,cAAkDS,WAAW;AAE/F,OAAO,SAASC;IACd,MAAMC,MAAMT,WAAWM;IACvB,IAAIG,QAAQF,WAAW;QACrB,MAAM,IAAIG,MAAM;IAClB;IACA,OAAOD;AACT;AAEA,OAAO,SAASE,eAA0CC,SAAY;IACpE,MAAMH,MAAMD;IAEZ,6DAA6D;IAC7D,MAAMK,uBAAuBJ,IAAIK,aAAaC,OAC5C,CAACC;YAAgBA;QAAAA,OAAAA,CAAAA,wBAAAA,yBAAAA,KAAAA,IAAAA,CAAAA,0BAAAA,YAAaC,wBAAbD,qCAAAA,KAAAA,IAAAA,wBAAyBE,IAAH,MAAYN;;IAGrD,sDAAsD;IACtD,MAAMO,iBAAiBV,IAAIW,OAAOL,OAAO,CAACK,QAAQC;YAAUZ;QAAAA,OAAAA,CAAAA,CAAAA,0BAAAA,IAAIK,YAAY,CAACO,MAAM,cAAvBZ,qCAAAA,KAAAA,IAAAA,sCAAAA,wBAAyBQ,wEAAzBR,KAAAA,uCAAqCS,IAAH,MAAYN;;IAE1G,mEAAmE;IACnE,MAAMU,cAAc;QAClBR,cAAcD;QACdU,YAAYV,qBAAqBW,KAAK,CAACC,SAAWA,OAAOF;QACzDG,WAAWb,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+1 @@
1
- {"version":3,"sources":["../../../src/runtime/DataQueriesProvider/index.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './DataQueriesProvider';\nexport * from './model';\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,uBAAuB,CAAC;AACtC,cAAc,SAAS,CAAC"}
1
+ {"version":3,"sources":["../../../src/runtime/DataQueriesProvider/index.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './DataQueriesProvider';\nexport * from './model';\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,wBAAwB;AACtC,cAAc,UAAU"}
@@ -1,27 +1,32 @@
1
1
  /// <reference types="react" />
2
- import { Definition, TimeSeriesData, UnknownSpec } from '@perses-dev/core';
2
+ import { Definition, QueryDefinition, UnknownSpec, QueryDataType } from '@perses-dev/core';
3
+ import { QueryObserverOptions, UseQueryResult } from '@tanstack/react-query';
3
4
  declare type QueryOptions = Record<string, unknown>;
4
- interface DataQueriesDefinitions<QueryPluginDefinition> {
5
- definitions: QueryPluginDefinition[];
6
- }
7
- export interface DataQueriesProviderProps<QueryPluginDefinition = Definition<UnknownSpec>> extends DataQueriesDefinitions<QueryPluginDefinition> {
8
- options?: QueryOptions;
5
+ export interface DataQueriesProviderProps<QueryPluginSpec = UnknownSpec> {
6
+ definitions: Array<Definition<QueryPluginSpec>>;
9
7
  children?: React.ReactNode;
8
+ options?: QueryOptions;
9
+ queryOptions?: QueryObserverOptions;
10
10
  }
11
- export interface UseDataQueryResults<QueryPluginDefinition = Definition<UnknownSpec>> {
12
- queryResults: Array<QueryData<QueryPluginDefinition>>;
11
+ export interface DataQueriesContextType {
12
+ queryResults: QueryData[];
13
13
  refetchAll: () => void;
14
14
  isFetching: boolean;
15
15
  isLoading: boolean;
16
16
  errors: unknown[];
17
17
  }
18
- export interface QueryData<QueryPluginDefinition> {
19
- data?: TimeSeriesData;
20
- definition: QueryPluginDefinition;
18
+ export interface UseDataQueryResults<T> extends Omit<DataQueriesContextType, 'queryResults'> {
19
+ queryResults: Array<QueryData<T>>;
20
+ }
21
+ export declare type QueryData<T = QueryDataType> = {
22
+ data?: T;
23
+ definition: QueryDefinition;
21
24
  error: unknown;
22
25
  isFetching: boolean;
23
26
  isLoading: boolean;
24
27
  refetch?: () => void;
25
- }
28
+ };
29
+ export declare function transformQueryResults(results: UseQueryResult[], definitions: QueryDefinition[]): QueryData<QueryDataType>[];
30
+ export declare function useQueryType(): (pluginKind: string) => string | undefined;
26
31
  export {};
27
32
  //# sourceMappingURL=model.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../../src/runtime/DataQueriesProvider/model.ts"],"names":[],"mappings":";AAaA,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE3E,aAAK,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAE5C,UAAU,sBAAsB,CAAC,qBAAqB;IACpD,WAAW,EAAE,qBAAqB,EAAE,CAAC;CACtC;AACD,MAAM,WAAW,wBAAwB,CAAC,qBAAqB,GAAG,UAAU,CAAC,WAAW,CAAC,CACvF,SAAQ,sBAAsB,CAAC,qBAAqB,CAAC;IACrD,OAAO,CAAC,EAAE,YAAY,CAAC;IACvB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AAED,MAAM,WAAW,mBAAmB,CAAC,qBAAqB,GAAG,UAAU,CAAC,WAAW,CAAC;IAClF,YAAY,EAAE,KAAK,CAAC,SAAS,CAAC,qBAAqB,CAAC,CAAC,CAAC;IACtD,UAAU,EAAE,MAAM,IAAI,CAAC;IACvB,UAAU,EAAE,OAAO,CAAC;IACpB,SAAS,EAAE,OAAO,CAAC;IACnB,MAAM,EAAE,OAAO,EAAE,CAAC;CACnB;AAED,MAAM,WAAW,SAAS,CAAC,qBAAqB;IAC9C,IAAI,CAAC,EAAE,cAAc,CAAC;IACtB,UAAU,EAAE,qBAAqB,CAAC;IAClC,KAAK,EAAE,OAAO,CAAC;IACf,UAAU,EAAE,OAAO,CAAC;IACpB,SAAS,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB"}
1
+ {"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../../src/runtime/DataQueriesProvider/model.ts"],"names":[],"mappings":";AAaA,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAC3F,OAAO,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAI7E,aAAK,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAC5C,MAAM,WAAW,wBAAwB,CAAC,eAAe,GAAG,WAAW;IACrE,WAAW,EAAE,KAAK,CAAC,UAAU,CAAC,eAAe,CAAC,CAAC,CAAC;IAChD,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,OAAO,CAAC,EAAE,YAAY,CAAC;IACvB,YAAY,CAAC,EAAE,oBAAoB,CAAC;CACrC;AAED,MAAM,WAAW,sBAAsB;IACrC,YAAY,EAAE,SAAS,EAAE,CAAC;IAC1B,UAAU,EAAE,MAAM,IAAI,CAAC;IACvB,UAAU,EAAE,OAAO,CAAC;IACpB,SAAS,EAAE,OAAO,CAAC;IACnB,MAAM,EAAE,OAAO,EAAE,CAAC;CACnB;AAED,MAAM,WAAW,mBAAmB,CAAC,CAAC,CAAE,SAAQ,IAAI,CAAC,sBAAsB,EAAE,cAAc,CAAC;IAC1F,YAAY,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;CACnC;AAED,oBAAY,SAAS,CAAC,CAAC,GAAG,aAAa,IAAI;IACzC,IAAI,CAAC,EAAE,CAAC,CAAC;IACT,UAAU,EAAE,eAAe,CAAC;IAC5B,KAAK,EAAE,OAAO,CAAC;IACf,UAAU,EAAE,OAAO,CAAC;IACpB,SAAS,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB,CAAC;AAEF,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,cAAc,EAAE,EAAE,WAAW,EAAE,eAAe,EAAE,8BAW9F;AAED,wBAAgB,YAAY,IAAI,CAAC,UAAU,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,CAsDzE"}
@@ -10,6 +10,72 @@
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 { };
13
+ import { useCallback, useMemo } from 'react';
14
+ import { useListPluginMetadata } from '../plugin-registry';
15
+ export function transformQueryResults(results, definitions) {
16
+ return results.map(({ data , isFetching , isLoading , refetch , error }, i)=>{
17
+ return {
18
+ definition: definitions[i],
19
+ data,
20
+ isFetching,
21
+ isLoading,
22
+ refetch,
23
+ error
24
+ };
25
+ });
26
+ }
27
+ export function useQueryType() {
28
+ const { data: timeSeriesQueryPlugins , isLoading: isTimeSeriesQueryLoading } = useListPluginMetadata('TimeSeriesQuery');
29
+ const { data: traceQueryPlugins , isLoading: isTraceQueryPluginLoading } = useListPluginMetadata('TraceQuery');
30
+ // For example, `map: {"TimeSeriesQuery":["PrometheusTimeSeriesQuery"],"TraceQuery":["TempoTraceQuery"]}`
31
+ const queryTypeMap = useMemo(()=>{
32
+ const map = {
33
+ TimeSeriesQuery: [],
34
+ TraceQuery: []
35
+ };
36
+ if (timeSeriesQueryPlugins) {
37
+ timeSeriesQueryPlugins.forEach((plugin)=>{
38
+ var _map_plugin_pluginType;
39
+ (_map_plugin_pluginType = map[plugin.pluginType]) === null || _map_plugin_pluginType === void 0 ? void 0 : _map_plugin_pluginType.push(plugin.kind);
40
+ });
41
+ }
42
+ if (traceQueryPlugins) {
43
+ traceQueryPlugins.forEach((plugin)=>{
44
+ var _map_plugin_pluginType;
45
+ (_map_plugin_pluginType = map[plugin.pluginType]) === null || _map_plugin_pluginType === void 0 ? void 0 : _map_plugin_pluginType.push(plugin.kind);
46
+ });
47
+ }
48
+ return map;
49
+ }, [
50
+ timeSeriesQueryPlugins,
51
+ traceQueryPlugins
52
+ ]);
53
+ const getQueryType = useCallback((pluginKind)=>{
54
+ const isLoading = (pluginKind)=>{
55
+ switch(pluginKind){
56
+ case 'PrometheusTimeSeriesQuery':
57
+ return isTimeSeriesQueryLoading;
58
+ case 'TempoTraceQuery':
59
+ return isTraceQueryPluginLoading;
60
+ }
61
+ throw new Error(`Unable to determine the query type: ${pluginKind}`);
62
+ };
63
+ if (isLoading(pluginKind)) {
64
+ return undefined;
65
+ }
66
+ for(const queryType in queryTypeMap){
67
+ var _queryTypeMap_queryType;
68
+ if ((_queryTypeMap_queryType = queryTypeMap[queryType]) === null || _queryTypeMap_queryType === void 0 ? void 0 : _queryTypeMap_queryType.includes(pluginKind)) {
69
+ return queryType;
70
+ }
71
+ }
72
+ throw new Error(`Unable to determine the query type: ${pluginKind}`);
73
+ }, [
74
+ queryTypeMap,
75
+ isTimeSeriesQueryLoading,
76
+ isTraceQueryPluginLoading
77
+ ]);
78
+ return getQueryType;
79
+ }
14
80
 
15
81
  //# sourceMappingURL=model.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/runtime/DataQueriesProvider/model.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Definition, TimeSeriesData, UnknownSpec } from '@perses-dev/core';\n\ntype QueryOptions = Record<string, unknown>;\n\ninterface DataQueriesDefinitions<QueryPluginDefinition> {\n definitions: QueryPluginDefinition[];\n}\nexport interface DataQueriesProviderProps<QueryPluginDefinition = Definition<UnknownSpec>>\n extends DataQueriesDefinitions<QueryPluginDefinition> {\n options?: QueryOptions;\n children?: React.ReactNode;\n}\n\nexport interface UseDataQueryResults<QueryPluginDefinition = Definition<UnknownSpec>> {\n queryResults: Array<QueryData<QueryPluginDefinition>>;\n refetchAll: () => void;\n isFetching: boolean;\n isLoading: boolean;\n errors: unknown[];\n}\n\nexport interface QueryData<QueryPluginDefinition> {\n data?: TimeSeriesData;\n definition: QueryPluginDefinition;\n error: unknown;\n isFetching: boolean;\n isLoading: boolean;\n refetch?: () => void;\n}\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,WA4BC"}
1
+ {"version":3,"sources":["../../../src/runtime/DataQueriesProvider/model.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Definition, QueryDefinition, UnknownSpec, QueryDataType } from '@perses-dev/core';\nimport { QueryObserverOptions, UseQueryResult } from '@tanstack/react-query';\nimport { useCallback, useMemo } from 'react';\nimport { useListPluginMetadata } from '../plugin-registry';\n\ntype QueryOptions = Record<string, unknown>;\nexport interface DataQueriesProviderProps<QueryPluginSpec = UnknownSpec> {\n definitions: Array<Definition<QueryPluginSpec>>;\n children?: React.ReactNode;\n options?: QueryOptions;\n queryOptions?: QueryObserverOptions;\n}\n\nexport interface DataQueriesContextType {\n queryResults: QueryData[];\n refetchAll: () => void;\n isFetching: boolean;\n isLoading: boolean;\n errors: unknown[];\n}\n\nexport interface UseDataQueryResults<T> extends Omit<DataQueriesContextType, 'queryResults'> {\n queryResults: Array<QueryData<T>>;\n}\n\nexport type QueryData<T = QueryDataType> = {\n data?: T;\n definition: QueryDefinition;\n error: unknown;\n isFetching: boolean;\n isLoading: boolean;\n refetch?: () => void;\n};\n\nexport function transformQueryResults(results: UseQueryResult[], definitions: QueryDefinition[]) {\n return results.map(({ data, isFetching, isLoading, refetch, error }, i) => {\n return {\n definition: definitions[i],\n data,\n isFetching,\n isLoading,\n refetch,\n error,\n } as QueryData;\n });\n}\n\nexport function useQueryType(): (pluginKind: string) => string | undefined {\n const { data: timeSeriesQueryPlugins, isLoading: isTimeSeriesQueryLoading } =\n useListPluginMetadata('TimeSeriesQuery');\n const { data: traceQueryPlugins, isLoading: isTraceQueryPluginLoading } = useListPluginMetadata('TraceQuery');\n\n // For example, `map: {\"TimeSeriesQuery\":[\"PrometheusTimeSeriesQuery\"],\"TraceQuery\":[\"TempoTraceQuery\"]}`\n const queryTypeMap = useMemo(() => {\n const map: Record<string, string[]> = {\n TimeSeriesQuery: [],\n TraceQuery: [],\n };\n\n if (timeSeriesQueryPlugins) {\n timeSeriesQueryPlugins.forEach((plugin) => {\n map[plugin.pluginType]?.push(plugin.kind);\n });\n }\n\n if (traceQueryPlugins) {\n traceQueryPlugins.forEach((plugin) => {\n map[plugin.pluginType]?.push(plugin.kind);\n });\n }\n return map;\n }, [timeSeriesQueryPlugins, traceQueryPlugins]);\n\n const getQueryType = useCallback(\n (pluginKind: string) => {\n const isLoading = (pluginKind: string) => {\n switch (pluginKind) {\n case 'PrometheusTimeSeriesQuery':\n return isTimeSeriesQueryLoading;\n case 'TempoTraceQuery':\n return isTraceQueryPluginLoading;\n }\n throw new Error(`Unable to determine the query type: ${pluginKind}`);\n };\n\n if (isLoading(pluginKind)) {\n return undefined;\n }\n\n for (const queryType in queryTypeMap) {\n if (queryTypeMap[queryType]?.includes(pluginKind)) {\n return queryType;\n }\n }\n\n throw new Error(`Unable to determine the query type: ${pluginKind}`);\n },\n [queryTypeMap, isTimeSeriesQueryLoading, isTraceQueryPluginLoading]\n );\n\n return getQueryType;\n}\n"],"names":["useCallback","useMemo","useListPluginMetadata","transformQueryResults","results","definitions","map","data","isFetching","isLoading","refetch","error","i","definition","useQueryType","timeSeriesQueryPlugins","isTimeSeriesQueryLoading","traceQueryPlugins","isTraceQueryPluginLoading","queryTypeMap","TimeSeriesQuery","TraceQuery","forEach","plugin","pluginType","push","kind","getQueryType","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;KAAkB;IAE9C,MAAMU,eAAe3B,YACnB,CAAC4B;QACC,MAAMnB,YAAY,CAACmB;YACjB,OAAQA;gBACN,KAAK;oBACH,OAAOZ;gBACT,KAAK;oBACH,OAAOE;YACX;YACA,MAAM,IAAIW,MAAM,CAAC,oCAAoC,EAAED,WAAW,CAAC;QACrE;QAEA,IAAInB,UAAUmB,aAAa;YACzB,OAAOE;QACT;QAEA,IAAK,MAAMC,aAAaZ,aAAc;gBAChCA;YAAJ,IAAIA,CAAAA,0BAAAA,YAAY,CAACY,UAAU,cAAvBZ,qCAAAA,KAAAA,IAAAA,wBAAyBa,SAASJ,aAAa;gBACjD,OAAOG;YACT;QACF;QAEA,MAAM,IAAIF,MAAM,CAAC,oCAAoC,EAAED,WAAW,CAAC;IACrE,GACA;QAACT;QAAcH;QAA0BE;KAA0B;IAGrE,OAAOS;AACT"}
@@ -1,9 +1,10 @@
1
1
  import React from 'react';
2
2
  import { AbsoluteTimeRange, DurationString, TimeRangeValue } from '@perses-dev/core';
3
3
  export interface TimeRangeProviderProps {
4
- initialTimeRange: TimeRangeValue;
5
- initialRefreshInterval?: DurationString;
6
- enabledURLParams?: boolean;
4
+ timeRange: TimeRangeValue;
5
+ refreshInterval?: DurationString;
6
+ setTimeRange?: (value: TimeRangeValue) => void;
7
+ setRefreshInterval?: (value: DurationString) => void;
7
8
  children?: React.ReactNode;
8
9
  }
9
10
  export interface TimeRange {
@@ -1 +1 @@
1
- {"version":3,"file":"TimeRangeProvider.d.ts","sourceRoot":"","sources":["../../../src/runtime/TimeRangeProvider/TimeRangeProvider.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAoE,MAAM,OAAO,CAAC;AACzF,OAAO,EACL,iBAAiB,EACjB,cAAc,EAEd,cAAc,EAEf,MAAM,kBAAkB,CAAC;AAG1B,MAAM,WAAW,sBAAsB;IACrC,gBAAgB,EAAE,cAAc,CAAC;IACjC,sBAAsB,CAAC,EAAE,cAAc,CAAC;IACxC,gBAAgB,CAAC,EA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AAC,KAAK,EAAE,cAAc,KAAK,IAAI,CAAC;IAC9C,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,CAAC,EAAE,cAAc,CAAC;IACjC,mBAAmB,EAAE,MAAM,CAAC;IAC5B,kBAAkB,EAAE,CAAC,KAAK,EAAE,cAAc,KAAK,IAAI,CAAC;CACrD;AAED,eAAO,MAAM,gBAAgB,sCAAkD,CAAC;AAEhF,wBAAgB,mBAAmB,cAMlC;AAED;;GAEG;AACH,wBAAgB,YAAY,IAAI,SAAS,CAExC;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,sBAAsB,eAqC9D"}
@@ -11,9 +11,9 @@
11
11
  // See the License for the specific language governing permissions and
12
12
  // limitations under the License.
13
13
  import { jsx as _jsx } from "react/jsx-runtime";
14
- import React, { useMemo, useState, useCallback, createContext, useContext } from 'react';
14
+ import React, { createContext, useCallback, useContext, useEffect, useMemo, useState } from 'react';
15
15
  import { isRelativeTimeRange, toAbsoluteTimeRange } from '@perses-dev/core';
16
- import { useSetRefreshIntervalParams, useSetTimeRangeParams } from './query-params';
16
+ import { getRefreshIntervalInMs } from './refresh-interval';
17
17
  export const TimeRangeContext = /*#__PURE__*/ createContext(undefined);
18
18
  export function useTimeRangeContext() {
19
19
  const ctx = useContext(TimeRangeContext);
@@ -30,34 +30,43 @@ export function useTimeRangeContext() {
30
30
  /**
31
31
  * Provider implementation that supplies the time range state at runtime.
32
32
  */ export function TimeRangeProvider(props) {
33
- const { initialTimeRange , initialRefreshInterval , enabledURLParams , children } = props;
34
- const { timeRange , setTimeRange } = useSetTimeRangeParams(initialTimeRange, enabledURLParams);
35
- const { refreshInterval , setRefreshInterval , refreshIntervalInMs } = useSetRefreshIntervalParams(initialRefreshInterval, enabledURLParams);
36
- const [refreshKey, setRefreshKey] = useState(0);
33
+ const { timeRange , refreshInterval , children , setTimeRange , setRefreshInterval } = props;
34
+ const [localTimeRange, setLocalTimeRange] = useState(timeRange);
35
+ const [localRefreshInterval, setLocalefreshInterval] = useState(refreshInterval);
36
+ const [refreshCounter, setRefreshCounter] = useState(0);
37
+ useEffect(()=>{
38
+ setLocalTimeRange(timeRange);
39
+ }, [
40
+ timeRange
41
+ ]);
42
+ useEffect(()=>{
43
+ setLocalefreshInterval(refreshInterval);
44
+ }, [
45
+ refreshInterval
46
+ ]);
37
47
  const refresh = useCallback(()=>{
38
- setRefreshKey(refreshKey + 1);
48
+ setRefreshCounter((counter)=>counter + 1);
39
49
  }, [
40
- refreshKey
50
+ setRefreshCounter
41
51
  ]);
42
52
  const ctx = useMemo(()=>{
43
- const absoluteTimeRange = isRelativeTimeRange(timeRange) ? toAbsoluteTimeRange(timeRange) : timeRange;
53
+ const absoluteTimeRange = isRelativeTimeRange(localTimeRange) ? toAbsoluteTimeRange(localTimeRange) : localTimeRange;
44
54
  return {
45
- timeRange,
46
- setTimeRange,
55
+ timeRange: localTimeRange,
56
+ setTimeRange: setTimeRange !== null && setTimeRange !== void 0 ? setTimeRange : setLocalTimeRange,
47
57
  absoluteTimeRange,
48
58
  refresh,
49
- refreshKey: `${absoluteTimeRange.start}:${absoluteTimeRange.end}:${refreshInterval}:${refreshKey}`,
50
- refreshInterval,
51
- refreshIntervalInMs,
52
- setRefreshInterval
59
+ refreshKey: `${absoluteTimeRange.start}:${absoluteTimeRange.end}:${localRefreshInterval}:${refreshCounter}`,
60
+ refreshInterval: localRefreshInterval,
61
+ refreshIntervalInMs: getRefreshIntervalInMs(localRefreshInterval),
62
+ setRefreshInterval: setRefreshInterval !== null && setRefreshInterval !== void 0 ? setRefreshInterval : setLocalefreshInterval
53
63
  };
54
64
  }, [
55
- timeRange,
65
+ localTimeRange,
56
66
  setTimeRange,
57
67
  refresh,
58
- refreshKey,
59
- refreshInterval,
60
- refreshIntervalInMs,
68
+ refreshCounter,
69
+ localRefreshInterval,
61
70
  setRefreshInterval
62
71
  ]);
63
72
  return /*#__PURE__*/ _jsx(TimeRangeContext.Provider, {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/runtime/TimeRangeProvider/TimeRangeProvider.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport React, { useMemo, useState, useCallback, createContext, useContext } from 'react';\nimport {\n AbsoluteTimeRange,\n DurationString,\n isRelativeTimeRange,\n TimeRangeValue,\n toAbsoluteTimeRange,\n} from '@perses-dev/core';\nimport { useSetRefreshIntervalParams, useSetTimeRangeParams } from './query-params';\n\nexport interface TimeRangeProviderProps {\n initialTimeRange: TimeRangeValue;\n initialRefreshInterval?: DurationString;\n enabledURLParams?: boolean;\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 refreshKey: string;\n refreshInterval?: DurationString;\n refreshIntervalInMs: number;\n setRefreshInterval: (value: DurationString) => void;\n}\n\nexport const TimeRangeContext = createContext<TimeRange | undefined>(undefined);\n\nexport function useTimeRangeContext() {\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 * Provider implementation that supplies the time range state at runtime.\n */\nexport function TimeRangeProvider(props: TimeRangeProviderProps) {\n const { initialTimeRange, initialRefreshInterval, enabledURLParams, children } = props;\n\n const { timeRange, setTimeRange } = useSetTimeRangeParams(initialTimeRange, enabledURLParams);\n const { refreshInterval, setRefreshInterval, refreshIntervalInMs } = useSetRefreshIntervalParams(\n initialRefreshInterval,\n enabledURLParams\n );\n\n const [refreshKey, setRefreshKey] = useState(0);\n\n const refresh = useCallback(() => {\n setRefreshKey(refreshKey + 1);\n }, [refreshKey]);\n\n const ctx = useMemo(() => {\n const absoluteTimeRange = isRelativeTimeRange(timeRange) ? toAbsoluteTimeRange(timeRange) : timeRange;\n return {\n timeRange,\n setTimeRange,\n absoluteTimeRange,\n refresh,\n refreshKey: `${absoluteTimeRange.start}:${absoluteTimeRange.end}:${refreshInterval}:${refreshKey}`,\n refreshInterval,\n refreshIntervalInMs,\n setRefreshInterval,\n };\n }, [timeRange, setTimeRange, refresh, refreshKey, refreshInterval, refreshIntervalInMs, setRefreshInterval]);\n\n return <TimeRangeContext.Provider value={ctx}>{children}</TimeRangeContext.Provider>;\n}\n"],"names":["React","useMemo","useState","useCallback","createContext","useContext","isRelativeTimeRange","toAbsoluteTimeRange","useSetRefreshIntervalParams","useSetTimeRangeParams","TimeRangeContext","undefined","useTimeRangeContext","ctx","Error","useTimeRange","TimeRangeProvider","props","initialTimeRange","initialRefreshInterval","enabledURLParams","children","timeRange","setTimeRange","refreshInterval","setRefreshInterval","refreshIntervalInMs","refreshKey","setRefreshKey","refresh","absoluteTimeRange","start","end","Provider","value"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AAAA,OAAOA,KAAK,IAAIC,OAAO,EAAEC,QAAQ,EAAEC,WAAW,EAAEC,aAAa,EAAEC,UAAU,QAAQ,OAAO,CAAC;AACzF,SAGEC,mBAAmB,EAEnBC,mBAAmB,QACd,kBAAkB,CAAC;AAC1B,SAASC,2BAA2B,EAAEC,qBAA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SAAS,AAAC;QACtG,OAAO;YACLA,SAAS;YACTC,YAAY;YACZO,iBAAiB;YACjBD,OAAO;YACPF,UAAU,EAAE,CAAC,EAAEG,iBAAiB,CAACC,KAAK,CAAC,CAAC,EAAED,iBAAiB,CAACE,GAAG,CAAC,CAAC,EAAER,eAAe,CAAC,CAAC,EAAEG,UAAU,CAAC,CAAC;YAClGH,eAAe;YACfE,mBAAmB;YACnBD,kBAAkB;SACnB,CAAC;IACJ,CAAC,EAAE;QAACH,SAAS;QAAEC,YAAY;QAAEM,OAAO;QAAEF,UAAU;QAAEH,eAAe;QAAEE,mBAAmB;QAAED,kBAAkB;KAAC,CAAC,AAAC;IAE7G,qBAAO,KAACf,gBAAgB,CAACuB,QAAQ;QAACC,KAAK,EAAErB,GAAG;kBAAGQ,QAAQ;MAA6B,CAAC;AACvF,CAAC"}
1
+ {"version":3,"sources":["../../../src/runtime/TimeRangeProvider/TimeRangeProvider.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport React, { createContext, useCallback, useContext, useEffect, useMemo, useState } from 'react';\nimport {\n AbsoluteTimeRange,\n DurationString,\n TimeRangeValue,\n isRelativeTimeRange,\n toAbsoluteTimeRange,\n} from '@perses-dev/core';\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 refreshKey: string;\n refreshInterval?: DurationString;\n refreshIntervalInMs: number;\n setRefreshInterval: (value: DurationString) => void;\n}\n\nexport const TimeRangeContext = createContext<TimeRange | undefined>(undefined);\n\nexport function useTimeRangeContext() {\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 * Provider implementation that supplies the time range state at runtime.\n */\nexport function TimeRangeProvider(props: TimeRangeProviderProps) {\n const { timeRange, refreshInterval, children, setTimeRange, setRefreshInterval } = props;\n\n const [localTimeRange, setLocalTimeRange] = useState<TimeRangeValue>(timeRange);\n const [localRefreshInterval, setLocalefreshInterval] = useState<DurationString | undefined>(refreshInterval);\n\n const [refreshCounter, setRefreshCounter] = useState(0);\n\n useEffect(() => {\n setLocalTimeRange(timeRange);\n }, [timeRange]);\n\n useEffect(() => {\n setLocalefreshInterval(refreshInterval);\n }, [refreshInterval]);\n\n const refresh = useCallback(() => {\n setRefreshCounter((counter) => counter + 1);\n }, [setRefreshCounter]);\n\n const ctx = useMemo(() => {\n const absoluteTimeRange = isRelativeTimeRange(localTimeRange)\n ? toAbsoluteTimeRange(localTimeRange)\n : localTimeRange;\n return {\n timeRange: localTimeRange,\n setTimeRange: setTimeRange ?? setLocalTimeRange,\n absoluteTimeRange,\n refresh,\n refreshKey: `${absoluteTimeRange.start}:${absoluteTimeRange.end}:${localRefreshInterval}:${refreshCounter}`,\n refreshInterval: localRefreshInterval,\n refreshIntervalInMs: getRefreshIntervalInMs(localRefreshInterval),\n setRefreshInterval: setRefreshInterval ?? setLocalefreshInterval,\n };\n }, [localTimeRange, setTimeRange, refresh, refreshCounter, localRefreshInterval, setRefreshInterval]);\n\n return <TimeRangeContext.Provider value={ctx}>{children}</TimeRangeContext.Provider>;\n}\n"],"names":["React","createContext","useCallback","useContext","useEffect","useMemo","useState","isRelativeTimeRange","toAbsoluteTimeRange","getRefreshIntervalInMs","TimeRangeContext","undefined","useTimeRangeContext","ctx","Error","useTimeRange","TimeRangeProvider","props","timeRange","refreshInterval","children","setTimeRange","setRefreshInterval","localTimeRange","setLocalTimeRange","localRefreshInterval","setLocalefreshInterval","refreshCounter","setRefreshCounter","refresh","counter","absoluteTimeRange","refreshKey","start","end","refreshIntervalInMs","Provider","value"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,OAAOA,SAASC,aAAa,EAAEC,WAAW,EAAEC,UAAU,EAAEC,SAAS,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,QAAQ;AACpG,SAIEC,mBAAmB,EACnBC,mBAAmB,QACd,mBAAmB;AAC1B,SAASC,sBAAsB,QAAQ,qBAAqB;AAqB5D,OAAO,MAAMC,iCAAmBT,cAAqCU,WAAW;AAEhF,OAAO,SAASC;IACd,MAAMC,MAAMV,WAAWO;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,kBAAkBC,KAA6B;IAC7D,MAAM,EAAEC,UAAS,EAAEC,gBAAe,EAAEC,SAAQ,EAAEC,aAAY,EAAEC,mBAAkB,EAAE,GAAGL;IAEnF,MAAM,CAACM,gBAAgBC,kBAAkB,GAAGlB,SAAyBY;IACrE,MAAM,CAACO,sBAAsBC,uBAAuB,GAAGpB,SAAqCa;IAE5F,MAAM,CAACQ,gBAAgBC,kBAAkB,GAAGtB,SAAS;IAErDF,UAAU;QACRoB,kBAAkBN;IACpB,GAAG;QAACA;KAAU;IAEdd,UAAU;QACRsB,uBAAuBP;IACzB,GAAG;QAACA;KAAgB;IAEpB,MAAMU,UAAU3B,YAAY;QAC1B0B,kBAAkB,CAACE,UAAYA,UAAU;IAC3C,GAAG;QAACF;KAAkB;IAEtB,MAAMf,MAAMR,QAAQ;QAClB,MAAM0B,oBAAoBxB,oBAAoBgB,kBAC1Cf,oBAAoBe,kBACpBA;QACJ,OAAO;YACLL,WAAWK;YACXF,cAAcA,yBAAAA,0BAAAA,eAAgBG;YAC9BO;YACAF;YACAG,YAAY,CAAC,EAAED,kBAAkBE,MAAM,CAAC,EAAEF,kBAAkBG,IAAI,CAAC,EAAET,qBAAqB,CAAC,EAAEE,eAAe,CAAC;YAC3GR,iBAAiBM;YACjBU,qBAAqB1B,uBAAuBgB;YAC5CH,oBAAoBA,+BAAAA,gCAAAA,qBAAsBI;QAC5C;IACF,GAAG;QAACH;QAAgBF;QAAcQ;QAASF;QAAgBF;QAAsBH;KAAmB;IAEpG,qBAAO,KAACZ,iBAAiB0B;QAASC,OAAOxB;kBAAMO;;AACjD"}
@@ -0,0 +1,9 @@
1
+ import { DurationString, TimeRangeValue } from '@perses-dev/core';
2
+ import React from 'react';
3
+ export interface TimeRangeFromQueryProps {
4
+ initialTimeRange: TimeRangeValue;
5
+ initialRefreshInterval?: DurationString;
6
+ children?: React.ReactNode;
7
+ }
8
+ export declare function TimeRangeProviderWithQueryParams(props: TimeRangeFromQueryProps): JSX.Element;
9
+ //# sourceMappingURL=TimeRangeProviderWithQueryParams.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TimeRangeProviderWithQueryParams.d.ts","sourceRoot":"","sources":["../../../src/runtime/TimeRangeProvider/TimeRangeProviderWithQueryParams.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClE,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,MAAM,WAAW,uBAAuB;IACtC,gBAAgB,EAAE,cAAc,CAAC;IACjC,sBAAsB,CAAC,EAAE,cAAc,CAAC;IACxC,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AAED,wBAAgB,gCAAgC,CAAC,KAAK,EAAE,uBAAuB,eAgB9E"}
@@ -0,0 +1,30 @@
1
+ // Copyright 2023 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 { jsx as _jsx } from "react/jsx-runtime";
14
+ import React from 'react';
15
+ import { TimeRangeProvider } from './TimeRangeProvider';
16
+ import { useSetRefreshIntervalParams, useTimeRangeParams } from './query-params';
17
+ export function TimeRangeProviderWithQueryParams(props) {
18
+ const { initialTimeRange , initialRefreshInterval , children } = props;
19
+ const { timeRange , setTimeRange } = useTimeRangeParams(initialTimeRange);
20
+ const { refreshInterval , setRefreshInterval } = useSetRefreshIntervalParams(initialRefreshInterval);
21
+ return /*#__PURE__*/ _jsx(TimeRangeProvider, {
22
+ timeRange: timeRange,
23
+ refreshInterval: refreshInterval,
24
+ setTimeRange: setTimeRange,
25
+ setRefreshInterval: setRefreshInterval,
26
+ children: children
27
+ });
28
+ }
29
+
30
+ //# sourceMappingURL=TimeRangeProviderWithQueryParams.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/runtime/TimeRangeProvider/TimeRangeProviderWithQueryParams.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { DurationString, TimeRangeValue } from '@perses-dev/core';\nimport React from 'react';\nimport { TimeRangeProvider } from './TimeRangeProvider';\nimport { useSetRefreshIntervalParams, useTimeRangeParams } from './query-params';\n\nexport interface TimeRangeFromQueryProps {\n initialTimeRange: TimeRangeValue;\n initialRefreshInterval?: DurationString;\n children?: React.ReactNode;\n}\n\nexport function TimeRangeProviderWithQueryParams(props: TimeRangeFromQueryProps) {\n const { initialTimeRange, initialRefreshInterval, children } = props;\n\n const { timeRange, setTimeRange } = useTimeRangeParams(initialTimeRange);\n const { refreshInterval, setRefreshInterval } = useSetRefreshIntervalParams(initialRefreshInterval);\n\n return (\n <TimeRangeProvider\n timeRange={timeRange}\n refreshInterval={refreshInterval}\n setTimeRange={setTimeRange}\n setRefreshInterval={setRefreshInterval}\n >\n {children}\n </TimeRangeProvider>\n );\n}\n"],"names":["React","TimeRangeProvider","useSetRefreshIntervalParams","useTimeRangeParams","TimeRangeProviderWithQueryParams","props","initialTimeRange","initialRefreshInterval","children","timeRange","setTimeRange","refreshInterval","setRefreshInterval"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAGjC,OAAOA,WAAW,QAAQ;AAC1B,SAASC,iBAAiB,QAAQ,sBAAsB;AACxD,SAASC,2BAA2B,EAAEC,kBAAkB,QAAQ,iBAAiB;AAQjF,OAAO,SAASC,iCAAiCC,KAA8B;IAC7E,MAAM,EAAEC,iBAAgB,EAAEC,uBAAsB,EAAEC,SAAQ,EAAE,GAAGH;IAE/D,MAAM,EAAEI,UAAS,EAAEC,aAAY,EAAE,GAAGP,mBAAmBG;IACvD,MAAM,EAAEK,gBAAe,EAAEC,mBAAkB,EAAE,GAAGV,4BAA4BK;IAE5E,qBACE,KAACN;QACCQ,WAAWA;QACXE,iBAAiBA;QACjBD,cAAcA;QACdE,oBAAoBA;kBAEnBJ;;AAGP"}
@@ -1,3 +1,4 @@
1
1
  export * from './TimeRangeProvider';
2
+ export * from './TimeRangeProviderWithQueryParams';
2
3
  export * from './query-params';
3
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/runtime/TimeRangeProvider/index.ts"],"names":[],"mappings":"AAaA,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/runtime/TimeRangeProvider/index.ts"],"names":[],"mappings":"AAaA,cAAc,qBAAqB,CAAC;AACpC,cAAc,oCAAoC,CAAC;AACnD,cAAc,gBAAgB,CAAC"}
@@ -11,6 +11,7 @@
11
11
  // See the License for the specific language governing permissions and
12
12
  // limitations under the License.
13
13
  export * from './TimeRangeProvider';
14
+ export * from './TimeRangeProviderWithQueryParams';
14
15
  export * from './query-params';
15
16
 
16
17
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/runtime/TimeRangeProvider/index.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './TimeRangeProvider';\nexport * from './query-params';\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC"}
1
+ {"version":3,"sources":["../../../src/runtime/TimeRangeProvider/index.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './TimeRangeProvider';\nexport * from './TimeRangeProviderWithQueryParams';\nexport * from './query-params';\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,sBAAsB;AACpC,cAAc,qCAAqC;AACnD,cAAc,iBAAiB"}
@@ -22,16 +22,16 @@ export declare const refreshIntervalQueryConfig: {
22
22
  */
23
23
  export declare function useInitialTimeRange(dashboardDuration: DurationString): TimeRangeValue;
24
24
  /**
25
- * Returns time range getter and setter, set enabledURLParams to false to disable query string serialization
25
+ * Returns time range getter and setter, taking the URL query params.
26
26
  */
27
- export declare function useSetTimeRangeParams(initialTimeRange: TimeRangeValue, enabledURLParams?: boolean): Pick<TimeRange, 'timeRange' | 'setTimeRange'>;
27
+ export declare function useTimeRangeParams(initialTimeRange: TimeRangeValue): Pick<TimeRange, 'timeRange' | 'setTimeRange'>;
28
28
  /**
29
29
  * Gets the initial refresh interval taking into account URL params and dashboard JSON duration
30
30
  * Sets refresh query param if it is empty on page load
31
31
  */
32
32
  export declare function useInitialRefreshInterval(dashboardDuration: DurationString): DurationString;
33
33
  /**
34
- * Returns refresh interval getter and setter, set enabledURLParams to false to disable query string serialization
34
+ * Returns refresh interval getter and setter, taking the URL query params.
35
35
  */
36
- export declare function useSetRefreshIntervalParams(initialRefreshInterval?: DurationString, enabledURLParams?: boolean): Pick<TimeRange, 'refreshInterval' | 'setRefreshInterval' | 'refreshIntervalInMs'>;
36
+ export declare function useSetRefreshIntervalParams(initialRefreshInterval?: DurationString): Pick<TimeRange, 'refreshInterval' | 'setRefreshInterval'>;
37
37
  //# sourceMappingURL=query-params.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"query-params.d.ts","sourceRoot":"","sources":["../../../src/runtime/TimeRangeProvider/query-params.ts"],"names":[],"mappings":"AAcA,OAAO,EAAkB,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEpE,OAAO,EACL,cAAc,EAGd,cAAc,EAGf,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAEhD,oBAAY,eAAe,GAAG,IAAI,GAAG,cAAc,GAAG,IAAI,GAAG,SAAS,CAAC;AA2BvE,wBAAgB,oBAAoB,CAAC,eAAe,EAAE,eAAe,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,CAWhG;AAGD,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,MAAM,GAAG,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,IAAI,GAAG,SAAS,GACtD,IAAI,GAAG,cAAc,GAAG,IAAI,GAAG,SAAS,CAI1C;AAED;;;GAGG;AACH,eAAO,MAAM,cAAc,EAAE,gBAAgB,CAAC,eAAe,EAAE,eAAe,CAQ7E,CAAC;AAEF,eAAO,MAAM,oBAAoB;;;CAGhC,CAAC;AA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