@perses-dev/plugin-system 0.0.0-snapshot-scatterplot-fix-imports-95e1b59 → 0.0.0-snapshot-explorer-plugin-c4a7621

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 (400) hide show
  1. package/dist/cjs/components/DatasourceEditorForm/DatasourceEditorForm.js +82 -162
  2. package/dist/cjs/components/DatasourceSelect.js +8 -13
  3. package/dist/cjs/components/HTTPSettingsEditor/HTTPSettingsEditor.js +528 -0
  4. package/dist/cjs/components/{TimeSeriesQueryEditor → HTTPSettingsEditor}/index.js +2 -2
  5. package/dist/cjs/components/LegendOptionsEditor/LegendOptionsEditor.js +8 -7
  6. package/dist/cjs/components/MetricLabelInput/MetricLabelInput.js +41 -0
  7. package/dist/cjs/components/{TraceQueryEditor → MetricLabelInput}/index.js +2 -2
  8. package/dist/cjs/components/{TimeSeriesQueryEditor/TimeSeriesQueryEditor.js → MultiQueryEditor/MultiQueryEditor.js} +22 -18
  9. package/dist/cjs/components/{TimeSeriesQueryEditor/TimeSeriesQueryInput.js → MultiQueryEditor/QueryEditorContainer.js} +23 -11
  10. package/dist/cjs/{validation/duration.js → components/MultiQueryEditor/index.js} +14 -9
  11. package/dist/cjs/components/PanelSpecEditor/PanelSpecEditor.js +51 -59
  12. package/dist/cjs/components/PluginEditor/PluginEditor.js +16 -13
  13. package/dist/cjs/components/PluginEditor/plugin-editor-api.js +43 -32
  14. package/dist/cjs/components/PluginKindSelect/PluginKindSelect.js +55 -7
  15. package/dist/cjs/components/PluginRegistry/PluginRegistry.js +8 -9
  16. package/dist/cjs/components/PluginRegistry/plugin-indexes.js +17 -14
  17. package/dist/cjs/components/PluginSpecEditor/PluginSpecEditor.js +1 -1
  18. package/dist/cjs/components/ProjectSelect.js +5 -5
  19. package/dist/cjs/components/TimeRangeControls/TimeRangeControls.js +10 -71
  20. package/dist/cjs/components/Variables/VariableEditorForm/VariableEditorForm.js +391 -442
  21. package/dist/cjs/components/Variables/VariableEditorForm/VariablePreview.js +7 -7
  22. package/dist/cjs/components/Variables/VariableEditorForm/variable-editor-form-model.js +6 -11
  23. package/dist/cjs/components/Variables/variable-model.js +26 -27
  24. package/dist/cjs/components/index.js +3 -1
  25. package/dist/cjs/context/ProjectStoreProvider.js +7 -4
  26. package/dist/cjs/context/ValidationProvider.js +69 -0
  27. package/dist/cjs/context/index.js +1 -0
  28. package/dist/cjs/index.js +1 -1
  29. package/dist/{components/TraceQueryEditor/index.js → cjs/model/explore.js} +4 -3
  30. package/dist/cjs/remote/PersesPlugin.types.js +16 -0
  31. package/dist/cjs/remote/PluginLoaderComponent.js +75 -0
  32. package/dist/cjs/remote/PluginRuntime.js +267 -0
  33. package/dist/cjs/{validation → remote}/index.js +2 -5
  34. package/dist/cjs/remote/remotePluginLoader.js +61 -0
  35. package/dist/cjs/runtime/DataQueriesProvider/DataQueriesProvider.js +18 -9
  36. package/dist/cjs/runtime/DataQueriesProvider/model.js +9 -8
  37. package/dist/cjs/runtime/QueryCountProvider.js +83 -0
  38. package/dist/cjs/runtime/TimeRangeProvider/TimeRangeProvider.js +17 -4
  39. package/dist/cjs/runtime/TimeRangeProvider/TimeRangeSettingsProvider.js +100 -0
  40. package/dist/cjs/runtime/TimeRangeProvider/index.js +2 -1
  41. package/dist/cjs/runtime/TimeRangeProvider/query-params.js +4 -7
  42. package/dist/cjs/runtime/UsageMetricsProvider.js +99 -0
  43. package/dist/cjs/runtime/builtin-variables.js +2 -2
  44. package/dist/cjs/runtime/datasources.js +23 -14
  45. package/dist/cjs/runtime/index.js +4 -2
  46. package/dist/cjs/runtime/plugin-registry.js +36 -24
  47. package/dist/cjs/runtime/time-series-queries.js +23 -28
  48. package/dist/cjs/runtime/trace-queries.js +6 -3
  49. package/dist/cjs/runtime/{template-variables.js → variables.js} +29 -47
  50. package/dist/cjs/stories/shared-utils/decorators/WithDataQueries.js +1 -1
  51. package/dist/cjs/stories/shared-utils/decorators/WithPluginRegistry.js +1 -67
  52. package/dist/cjs/stories/shared-utils/decorators/WithPluginSystemBuiltinVariables.js +1 -1
  53. package/dist/cjs/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.js +4 -4
  54. package/dist/cjs/stories/shared-utils/decorators/{WithPluginSystemTemplateVariables.js → WithPluginSystemVariables.js} +9 -9
  55. package/dist/cjs/stories/shared-utils/decorators/WithTimeRange.js +1 -1
  56. package/dist/cjs/stories/shared-utils/decorators/index.js +2 -2
  57. package/dist/cjs/test/mock-data.js +25 -4
  58. package/dist/cjs/test/render.js +2 -11
  59. package/dist/cjs/test/test-plugins/bert/index.js +20 -19
  60. package/dist/cjs/test-utils/mock-plugin-registry.js +10 -10
  61. package/dist/cjs/utils/variables.js +24 -24
  62. package/dist/components/CalculationSelector/CalculationSelector.d.ts +2 -1
  63. package/dist/components/CalculationSelector/CalculationSelector.d.ts.map +1 -1
  64. package/dist/components/CalculationSelector/CalculationSelector.js.map +1 -1
  65. package/dist/components/DatasourceEditorForm/DatasourceEditorForm.d.ts +6 -5
  66. package/dist/components/DatasourceEditorForm/DatasourceEditorForm.d.ts.map +1 -1
  67. package/dist/components/DatasourceEditorForm/DatasourceEditorForm.js +85 -165
  68. package/dist/components/DatasourceEditorForm/DatasourceEditorForm.js.map +1 -1
  69. package/dist/components/DatasourceSelect.d.ts +3 -2
  70. package/dist/components/DatasourceSelect.d.ts.map +1 -1
  71. package/dist/components/DatasourceSelect.js +8 -13
  72. package/dist/components/DatasourceSelect.js.map +1 -1
  73. package/dist/components/HTTPSettingsEditor/HTTPSettingsEditor.d.ts +11 -0
  74. package/dist/components/HTTPSettingsEditor/HTTPSettingsEditor.d.ts.map +1 -0
  75. package/dist/components/HTTPSettingsEditor/HTTPSettingsEditor.js +474 -0
  76. package/dist/components/HTTPSettingsEditor/HTTPSettingsEditor.js.map +1 -0
  77. package/dist/components/HTTPSettingsEditor/index.d.ts +2 -0
  78. package/dist/components/HTTPSettingsEditor/index.d.ts.map +1 -0
  79. package/dist/{validation/duration.js → components/HTTPSettingsEditor/index.js} +2 -4
  80. package/dist/components/HTTPSettingsEditor/index.js.map +1 -0
  81. package/dist/components/LegendOptionsEditor/LegendOptionsEditor.d.ts +3 -1
  82. package/dist/components/LegendOptionsEditor/LegendOptionsEditor.d.ts.map +1 -1
  83. package/dist/components/LegendOptionsEditor/LegendOptionsEditor.js +10 -9
  84. package/dist/components/LegendOptionsEditor/LegendOptionsEditor.js.map +1 -1
  85. package/dist/components/MetricLabelInput/MetricLabelInput.d.ts +7 -0
  86. package/dist/components/MetricLabelInput/MetricLabelInput.d.ts.map +1 -0
  87. package/dist/components/MetricLabelInput/MetricLabelInput.js +33 -0
  88. package/dist/components/MetricLabelInput/MetricLabelInput.js.map +1 -0
  89. package/dist/components/MetricLabelInput/index.d.ts +2 -0
  90. package/dist/components/MetricLabelInput/index.d.ts.map +1 -0
  91. package/dist/components/MetricLabelInput/index.js +15 -0
  92. package/dist/components/MetricLabelInput/index.js.map +1 -0
  93. package/dist/components/MultiQueryEditor/MultiQueryEditor.d.ts +17 -0
  94. package/dist/components/MultiQueryEditor/MultiQueryEditor.d.ts.map +1 -0
  95. package/dist/components/{TimeSeriesQueryEditor/TimeSeriesQueryEditor.js → MultiQueryEditor/MultiQueryEditor.js} +29 -18
  96. package/dist/components/MultiQueryEditor/MultiQueryEditor.js.map +1 -0
  97. package/dist/components/MultiQueryEditor/QueryEditorContainer.d.ts +29 -0
  98. package/dist/components/MultiQueryEditor/QueryEditorContainer.d.ts.map +1 -0
  99. package/dist/components/{TimeSeriesQueryEditor/TimeSeriesQueryInput.js → MultiQueryEditor/QueryEditorContainer.js} +33 -10
  100. package/dist/components/MultiQueryEditor/QueryEditorContainer.js.map +1 -0
  101. package/dist/components/MultiQueryEditor/index.d.ts +2 -0
  102. package/dist/components/MultiQueryEditor/index.d.ts.map +1 -0
  103. package/dist/components/MultiQueryEditor/index.js +15 -0
  104. package/dist/components/{TraceQueryEditor → MultiQueryEditor}/index.js.map +1 -1
  105. package/dist/components/OptionsEditorRadios/OptionsEditorRadios.d.ts +2 -2
  106. package/dist/components/OptionsEditorRadios/OptionsEditorRadios.d.ts.map +1 -1
  107. package/dist/components/OptionsEditorRadios/OptionsEditorRadios.js.map +1 -1
  108. package/dist/components/OptionsEditorTabPanel/OptionsEditorTabPanel.d.ts +2 -2
  109. package/dist/components/OptionsEditorTabPanel/OptionsEditorTabPanel.d.ts.map +1 -1
  110. package/dist/components/OptionsEditorTabPanel/OptionsEditorTabPanel.js.map +1 -1
  111. package/dist/components/OptionsEditorTabs/OptionsEditorTabs.d.ts +3 -3
  112. package/dist/components/OptionsEditorTabs/OptionsEditorTabs.d.ts.map +1 -1
  113. package/dist/components/OptionsEditorTabs/OptionsEditorTabs.js.map +1 -1
  114. package/dist/components/PanelSpecEditor/PanelSpecEditor.d.ts +5 -2
  115. package/dist/components/PanelSpecEditor/PanelSpecEditor.d.ts.map +1 -1
  116. package/dist/components/PanelSpecEditor/PanelSpecEditor.js +53 -61
  117. package/dist/components/PanelSpecEditor/PanelSpecEditor.js.map +1 -1
  118. package/dist/components/PluginEditor/PluginEditor.d.ts +2 -1
  119. package/dist/components/PluginEditor/PluginEditor.d.ts.map +1 -1
  120. package/dist/components/PluginEditor/PluginEditor.js +16 -13
  121. package/dist/components/PluginEditor/PluginEditor.js.map +1 -1
  122. package/dist/components/PluginEditor/plugin-editor-api.d.ts +15 -8
  123. package/dist/components/PluginEditor/plugin-editor-api.d.ts.map +1 -1
  124. package/dist/components/PluginEditor/plugin-editor-api.js +43 -32
  125. package/dist/components/PluginEditor/plugin-editor-api.js.map +1 -1
  126. package/dist/components/PluginKindSelect/PluginKindSelect.d.ts +10 -4
  127. package/dist/components/PluginKindSelect/PluginKindSelect.d.ts.map +1 -1
  128. package/dist/components/PluginKindSelect/PluginKindSelect.js +61 -10
  129. package/dist/components/PluginKindSelect/PluginKindSelect.js.map +1 -1
  130. package/dist/components/PluginRegistry/PluginRegistry.d.ts +2 -2
  131. package/dist/components/PluginRegistry/PluginRegistry.d.ts.map +1 -1
  132. package/dist/components/PluginRegistry/PluginRegistry.js +8 -9
  133. package/dist/components/PluginRegistry/PluginRegistry.js.map +1 -1
  134. package/dist/components/PluginRegistry/plugin-indexes.d.ts +4 -4
  135. package/dist/components/PluginRegistry/plugin-indexes.d.ts.map +1 -1
  136. package/dist/components/PluginRegistry/plugin-indexes.js +17 -14
  137. package/dist/components/PluginRegistry/plugin-indexes.js.map +1 -1
  138. package/dist/components/PluginSpecEditor/PluginSpecEditor.d.ts +5 -4
  139. package/dist/components/PluginSpecEditor/PluginSpecEditor.d.ts.map +1 -1
  140. package/dist/components/PluginSpecEditor/PluginSpecEditor.js +1 -1
  141. package/dist/components/PluginSpecEditor/PluginSpecEditor.js.map +1 -1
  142. package/dist/components/ProjectSelect.d.ts +2 -1
  143. package/dist/components/ProjectSelect.d.ts.map +1 -1
  144. package/dist/components/ProjectSelect.js +5 -5
  145. package/dist/components/ProjectSelect.js.map +1 -1
  146. package/dist/components/TimeRangeControls/TimeRangeControls.d.ts +3 -2
  147. package/dist/components/TimeRangeControls/TimeRangeControls.d.ts.map +1 -1
  148. package/dist/components/TimeRangeControls/TimeRangeControls.js +12 -70
  149. package/dist/components/TimeRangeControls/TimeRangeControls.js.map +1 -1
  150. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts +4 -3
  151. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts.map +1 -1
  152. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js +395 -446
  153. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js.map +1 -1
  154. package/dist/components/Variables/VariableEditorForm/VariablePreview.d.ts +3 -2
  155. package/dist/components/Variables/VariableEditorForm/VariablePreview.d.ts.map +1 -1
  156. package/dist/components/Variables/VariableEditorForm/VariablePreview.js +7 -7
  157. package/dist/components/Variables/VariableEditorForm/VariablePreview.js.map +1 -1
  158. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.d.ts +2 -2
  159. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.d.ts.map +1 -1
  160. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js +6 -11
  161. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js.map +1 -1
  162. package/dist/components/Variables/variable-model.d.ts +2 -1
  163. package/dist/components/Variables/variable-model.d.ts.map +1 -1
  164. package/dist/components/Variables/variable-model.js +27 -28
  165. package/dist/components/Variables/variable-model.js.map +1 -1
  166. package/dist/components/index.d.ts +3 -1
  167. package/dist/components/index.d.ts.map +1 -1
  168. package/dist/components/index.js +3 -1
  169. package/dist/components/index.js.map +1 -1
  170. package/dist/context/ProjectStoreProvider.d.ts +4 -4
  171. package/dist/context/ProjectStoreProvider.d.ts.map +1 -1
  172. package/dist/context/ProjectStoreProvider.js +7 -4
  173. package/dist/context/ProjectStoreProvider.js.map +1 -1
  174. package/dist/context/ValidationProvider.d.ts +19 -0
  175. package/dist/context/ValidationProvider.d.ts.map +1 -0
  176. package/dist/context/ValidationProvider.js +52 -0
  177. package/dist/context/ValidationProvider.js.map +1 -0
  178. package/dist/context/index.d.ts +1 -0
  179. package/dist/context/index.d.ts.map +1 -1
  180. package/dist/context/index.js +1 -0
  181. package/dist/context/index.js.map +1 -1
  182. package/dist/context/query-params.d.ts.map +1 -1
  183. package/dist/context/query-params.js.map +1 -1
  184. package/dist/index.d.ts +1 -1
  185. package/dist/index.d.ts.map +1 -1
  186. package/dist/index.js +1 -1
  187. package/dist/index.js.map +1 -1
  188. package/dist/model/explore.d.ts +13 -0
  189. package/dist/model/explore.d.ts.map +1 -0
  190. package/dist/{validation/index.js → model/explore.js} +4 -6
  191. package/dist/model/explore.js.map +1 -0
  192. package/dist/model/legend.d.ts.map +1 -1
  193. package/dist/model/legend.js.map +1 -1
  194. package/dist/model/panels.d.ts +16 -4
  195. package/dist/model/panels.d.ts.map +1 -1
  196. package/dist/model/panels.js.map +1 -1
  197. package/dist/model/plugin-loading.js.map +1 -1
  198. package/dist/model/plugins.d.ts +31 -17
  199. package/dist/model/plugins.d.ts.map +1 -1
  200. package/dist/model/plugins.js.map +1 -1
  201. package/dist/model/time-series-queries.d.ts +2 -1
  202. package/dist/model/time-series-queries.d.ts.map +1 -1
  203. package/dist/model/time-series-queries.js.map +1 -1
  204. package/dist/remote/PersesPlugin.types.d.ts +7 -0
  205. package/dist/remote/PersesPlugin.types.d.ts.map +1 -0
  206. package/dist/remote/PersesPlugin.types.js +15 -0
  207. package/dist/remote/PersesPlugin.types.js.map +1 -0
  208. package/dist/remote/PluginLoaderComponent.d.ts +10 -0
  209. package/dist/remote/PluginLoaderComponent.d.ts.map +1 -0
  210. package/dist/remote/PluginLoaderComponent.js +67 -0
  211. package/dist/remote/PluginLoaderComponent.js.map +1 -0
  212. package/dist/remote/PluginRuntime.d.ts +11 -0
  213. package/dist/remote/PluginRuntime.d.ts.map +1 -0
  214. package/dist/remote/PluginRuntime.js +202 -0
  215. package/dist/remote/PluginRuntime.js.map +1 -0
  216. package/dist/remote/index.d.ts +3 -0
  217. package/dist/remote/index.d.ts.map +1 -0
  218. package/dist/{components/TimeSeriesQueryEditor → remote}/index.js +2 -1
  219. package/dist/remote/index.js.map +1 -0
  220. package/dist/remote/remotePluginLoader.d.ts +3 -0
  221. package/dist/remote/remotePluginLoader.d.ts.map +1 -0
  222. package/dist/remote/remotePluginLoader.js +53 -0
  223. package/dist/remote/remotePluginLoader.js.map +1 -0
  224. package/dist/runtime/DataQueriesProvider/DataQueriesProvider.d.ts +2 -2
  225. package/dist/runtime/DataQueriesProvider/DataQueriesProvider.d.ts.map +1 -1
  226. package/dist/runtime/DataQueriesProvider/DataQueriesProvider.js +18 -9
  227. package/dist/runtime/DataQueriesProvider/DataQueriesProvider.js.map +1 -1
  228. package/dist/runtime/DataQueriesProvider/model.d.ts +5 -6
  229. package/dist/runtime/DataQueriesProvider/model.d.ts.map +1 -1
  230. package/dist/runtime/DataQueriesProvider/model.js +9 -8
  231. package/dist/runtime/DataQueriesProvider/model.js.map +1 -1
  232. package/dist/runtime/QueryCountProvider.d.ts +9 -0
  233. package/dist/runtime/QueryCountProvider.d.ts.map +1 -0
  234. package/dist/{validation/datasource.js → runtime/QueryCountProvider.js} +14 -10
  235. package/dist/runtime/QueryCountProvider.js.map +1 -0
  236. package/dist/runtime/TimeRangeProvider/TimeRangeProvider.d.ts +2 -2
  237. package/dist/runtime/TimeRangeProvider/TimeRangeProvider.d.ts.map +1 -1
  238. package/dist/runtime/TimeRangeProvider/TimeRangeProvider.js +17 -4
  239. package/dist/runtime/TimeRangeProvider/TimeRangeProvider.js.map +1 -1
  240. package/dist/runtime/TimeRangeProvider/TimeRangeProviderWithQueryParams.d.ts +2 -2
  241. package/dist/runtime/TimeRangeProvider/TimeRangeProviderWithQueryParams.d.ts.map +1 -1
  242. package/dist/runtime/TimeRangeProvider/TimeRangeProviderWithQueryParams.js.map +1 -1
  243. package/dist/runtime/TimeRangeProvider/TimeRangeSettingsProvider.d.ts +32 -0
  244. package/dist/runtime/TimeRangeProvider/TimeRangeSettingsProvider.d.ts.map +1 -0
  245. package/dist/runtime/TimeRangeProvider/TimeRangeSettingsProvider.js +82 -0
  246. package/dist/runtime/TimeRangeProvider/TimeRangeSettingsProvider.js.map +1 -0
  247. package/dist/runtime/TimeRangeProvider/index.d.ts +1 -0
  248. package/dist/runtime/TimeRangeProvider/index.d.ts.map +1 -1
  249. package/dist/runtime/TimeRangeProvider/index.js +2 -1
  250. package/dist/runtime/TimeRangeProvider/index.js.map +1 -1
  251. package/dist/runtime/TimeRangeProvider/query-params.d.ts.map +1 -1
  252. package/dist/runtime/TimeRangeProvider/query-params.js +4 -7
  253. package/dist/runtime/TimeRangeProvider/query-params.js.map +1 -1
  254. package/dist/runtime/TimeRangeProvider/refresh-interval.d.ts.map +1 -1
  255. package/dist/runtime/TimeRangeProvider/refresh-interval.js.map +1 -1
  256. package/dist/runtime/UsageMetricsProvider.d.ts +25 -0
  257. package/dist/runtime/UsageMetricsProvider.d.ts.map +1 -0
  258. package/dist/runtime/UsageMetricsProvider.js +77 -0
  259. package/dist/runtime/UsageMetricsProvider.js.map +1 -0
  260. package/dist/runtime/builtin-variables.d.ts +1 -1
  261. package/dist/runtime/builtin-variables.d.ts.map +1 -1
  262. package/dist/runtime/builtin-variables.js +2 -2
  263. package/dist/runtime/builtin-variables.js.map +1 -1
  264. package/dist/runtime/datasources.d.ts +5 -4
  265. package/dist/runtime/datasources.d.ts.map +1 -1
  266. package/dist/runtime/datasources.js +23 -14
  267. package/dist/runtime/datasources.js.map +1 -1
  268. package/dist/runtime/index.d.ts +3 -1
  269. package/dist/runtime/index.d.ts.map +1 -1
  270. package/dist/runtime/index.js +4 -2
  271. package/dist/runtime/index.js.map +1 -1
  272. package/dist/runtime/plugin-registry.d.ts +10 -10
  273. package/dist/runtime/plugin-registry.d.ts.map +1 -1
  274. package/dist/runtime/plugin-registry.js +36 -24
  275. package/dist/runtime/plugin-registry.js.map +1 -1
  276. package/dist/runtime/time-series-queries.d.ts +5 -4
  277. package/dist/runtime/time-series-queries.d.ts.map +1 -1
  278. package/dist/runtime/time-series-queries.js +23 -28
  279. package/dist/runtime/time-series-queries.js.map +1 -1
  280. package/dist/runtime/trace-queries.d.ts +4 -3
  281. package/dist/runtime/trace-queries.d.ts.map +1 -1
  282. package/dist/runtime/trace-queries.js +7 -4
  283. package/dist/runtime/trace-queries.js.map +1 -1
  284. package/dist/runtime/{template-variables.d.ts → variables.d.ts} +4 -4
  285. package/dist/runtime/variables.d.ts.map +1 -0
  286. package/dist/runtime/{template-variables.js → variables.js} +28 -45
  287. package/dist/runtime/variables.js.map +1 -0
  288. package/dist/stories/shared-utils/decorators/WithDataQueries.d.ts +2 -1
  289. package/dist/stories/shared-utils/decorators/WithDataQueries.d.ts.map +1 -1
  290. package/dist/stories/shared-utils/decorators/WithDataQueries.js +1 -1
  291. package/dist/stories/shared-utils/decorators/WithDataQueries.js.map +1 -1
  292. package/dist/stories/shared-utils/decorators/WithPluginRegistry.d.ts +2 -1
  293. package/dist/stories/shared-utils/decorators/WithPluginRegistry.d.ts.map +1 -1
  294. package/dist/stories/shared-utils/decorators/WithPluginRegistry.js +2 -22
  295. package/dist/stories/shared-utils/decorators/WithPluginRegistry.js.map +1 -1
  296. package/dist/stories/shared-utils/decorators/WithPluginSystemBuiltinVariables.d.ts +2 -1
  297. package/dist/stories/shared-utils/decorators/WithPluginSystemBuiltinVariables.d.ts.map +1 -1
  298. package/dist/stories/shared-utils/decorators/WithPluginSystemBuiltinVariables.js +1 -1
  299. package/dist/stories/shared-utils/decorators/WithPluginSystemBuiltinVariables.js.map +1 -1
  300. package/dist/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.d.ts +2 -1
  301. package/dist/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.d.ts.map +1 -1
  302. package/dist/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.js +4 -4
  303. package/dist/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.js.map +1 -1
  304. package/dist/stories/shared-utils/decorators/WithPluginSystemVariables.d.ts +13 -0
  305. package/dist/stories/shared-utils/decorators/WithPluginSystemVariables.d.ts.map +1 -0
  306. package/dist/stories/shared-utils/decorators/{WithPluginSystemTemplateVariables.js → WithPluginSystemVariables.js} +10 -10
  307. package/dist/stories/shared-utils/decorators/WithPluginSystemVariables.js.map +1 -0
  308. package/dist/stories/shared-utils/decorators/WithTimeRange.d.ts +2 -1
  309. package/dist/stories/shared-utils/decorators/WithTimeRange.d.ts.map +1 -1
  310. package/dist/stories/shared-utils/decorators/WithTimeRange.js +1 -1
  311. package/dist/stories/shared-utils/decorators/WithTimeRange.js.map +1 -1
  312. package/dist/stories/shared-utils/decorators/index.d.ts +1 -1
  313. package/dist/stories/shared-utils/decorators/index.d.ts.map +1 -1
  314. package/dist/stories/shared-utils/decorators/index.js +2 -2
  315. package/dist/stories/shared-utils/decorators/index.js.map +1 -1
  316. package/dist/test/mock-data.d.ts.map +1 -1
  317. package/dist/test/mock-data.js +25 -4
  318. package/dist/test/mock-data.js.map +1 -1
  319. package/dist/test/render.d.ts +3 -3
  320. package/dist/test/render.d.ts.map +1 -1
  321. package/dist/test/render.js +2 -11
  322. package/dist/test/render.js.map +1 -1
  323. package/dist/test/test-plugins/bert/index.d.ts.map +1 -1
  324. package/dist/test/test-plugins/bert/index.js +20 -19
  325. package/dist/test/test-plugins/bert/index.js.map +1 -1
  326. package/dist/test-utils/mock-plugin-registry.d.ts +5 -3
  327. package/dist/test-utils/mock-plugin-registry.d.ts.map +1 -1
  328. package/dist/test-utils/mock-plugin-registry.js +10 -10
  329. package/dist/test-utils/mock-plugin-registry.js.map +1 -1
  330. package/dist/utils/variables.d.ts +4 -4
  331. package/dist/utils/variables.d.ts.map +1 -1
  332. package/dist/utils/variables.js +19 -19
  333. package/dist/utils/variables.js.map +1 -1
  334. package/package.json +7 -6
  335. package/dist/cjs/components/TraceQueryEditor/TraceQueryEditor.js +0 -143
  336. package/dist/cjs/components/TraceQueryEditor/TraceQueryInput.js +0 -96
  337. package/dist/cjs/validation/datasource.js +0 -30
  338. package/dist/cjs/validation/resource.js +0 -24
  339. package/dist/cjs/validation/role.js +0 -86
  340. package/dist/cjs/validation/rolebinding.js +0 -55
  341. package/dist/cjs/validation/secret.js +0 -176
  342. package/dist/cjs/validation/user.js +0 -46
  343. package/dist/cjs/validation/variable.js +0 -48
  344. package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryEditor.d.ts +0 -7
  345. package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryEditor.d.ts.map +0 -1
  346. package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryEditor.js.map +0 -1
  347. package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryInput.d.ts +0 -12
  348. package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryInput.d.ts.map +0 -1
  349. package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryInput.js.map +0 -1
  350. package/dist/components/TimeSeriesQueryEditor/index.d.ts +0 -2
  351. package/dist/components/TimeSeriesQueryEditor/index.d.ts.map +0 -1
  352. package/dist/components/TimeSeriesQueryEditor/index.js.map +0 -1
  353. package/dist/components/TraceQueryEditor/TraceQueryEditor.d.ts +0 -8
  354. package/dist/components/TraceQueryEditor/TraceQueryEditor.d.ts.map +0 -1
  355. package/dist/components/TraceQueryEditor/TraceQueryEditor.js +0 -130
  356. package/dist/components/TraceQueryEditor/TraceQueryEditor.js.map +0 -1
  357. package/dist/components/TraceQueryEditor/TraceQueryInput.d.ts +0 -12
  358. package/dist/components/TraceQueryEditor/TraceQueryInput.d.ts.map +0 -1
  359. package/dist/components/TraceQueryEditor/TraceQueryInput.js +0 -83
  360. package/dist/components/TraceQueryEditor/TraceQueryInput.js.map +0 -1
  361. package/dist/components/TraceQueryEditor/index.d.ts +0 -2
  362. package/dist/components/TraceQueryEditor/index.d.ts.map +0 -1
  363. package/dist/runtime/template-variables.d.ts.map +0 -1
  364. package/dist/runtime/template-variables.js.map +0 -1
  365. package/dist/stories/shared-utils/decorators/WithPluginSystemTemplateVariables.d.ts +0 -12
  366. package/dist/stories/shared-utils/decorators/WithPluginSystemTemplateVariables.d.ts.map +0 -1
  367. package/dist/stories/shared-utils/decorators/WithPluginSystemTemplateVariables.js.map +0 -1
  368. package/dist/validation/datasource.d.ts +0 -19
  369. package/dist/validation/datasource.d.ts.map +0 -1
  370. package/dist/validation/datasource.js.map +0 -1
  371. package/dist/validation/duration.d.ts +0 -3
  372. package/dist/validation/duration.d.ts.map +0 -1
  373. package/dist/validation/duration.js.map +0 -1
  374. package/dist/validation/index.d.ts +0 -6
  375. package/dist/validation/index.d.ts.map +0 -1
  376. package/dist/validation/index.js.map +0 -1
  377. package/dist/validation/resource.d.ts +0 -3
  378. package/dist/validation/resource.d.ts.map +0 -1
  379. package/dist/validation/resource.js +0 -16
  380. package/dist/validation/resource.js.map +0 -1
  381. package/dist/validation/role.d.ts +0 -228
  382. package/dist/validation/role.d.ts.map +0 -1
  383. package/dist/validation/role.js +0 -67
  384. package/dist/validation/role.js.map +0 -1
  385. package/dist/validation/rolebinding.d.ts +0 -137
  386. package/dist/validation/rolebinding.d.ts.map +0 -1
  387. package/dist/validation/rolebinding.js +0 -47
  388. package/dist/validation/rolebinding.js.map +0 -1
  389. package/dist/validation/secret.d.ts +0 -964
  390. package/dist/validation/secret.d.ts.map +0 -1
  391. package/dist/validation/secret.js +0 -157
  392. package/dist/validation/secret.js.map +0 -1
  393. package/dist/validation/user.d.ts +0 -93
  394. package/dist/validation/user.d.ts.map +0 -1
  395. package/dist/validation/user.js +0 -38
  396. package/dist/validation/user.js.map +0 -1
  397. package/dist/validation/variable.d.ts +0 -96
  398. package/dist/validation/variable.d.ts.map +0 -1
  399. package/dist/validation/variable.js +0 -40
  400. package/dist/validation/variable.js.map +0 -1
@@ -1,4 +1,4 @@
1
- // Copyright 2023 The Perses Authors
1
+ // Copyright 2024 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -16,6 +16,7 @@ Object.defineProperty(exports, "__esModule", {
16
16
  });
17
17
  _export_star(require("./TimeRangeProvider"), exports);
18
18
  _export_star(require("./TimeRangeProviderWithQueryParams"), exports);
19
+ _export_star(require("./TimeRangeSettingsProvider"), exports);
19
20
  _export_star(require("./query-params"), exports);
20
21
  function _export_star(from, to) {
21
22
  Object.keys(from).forEach(function(k) {
@@ -54,15 +54,12 @@ const _usequeryparams = require("use-query-params");
54
54
  const _datefns = require("date-fns");
55
55
  const _core = require("@perses-dev/core");
56
56
  /* Interprets an encoded string and returns either the string or null/undefined if not available */ function getEncodedValue(input, allowEmptyString) {
57
- if (input == null) {
58
- return input;
59
- }
60
57
  // '' or []
61
- if (input.length === 0 && (!allowEmptyString || allowEmptyString && input !== '')) {
58
+ if (!input || input.length === 0 && (!allowEmptyString || allowEmptyString && input !== '')) {
62
59
  return null;
63
60
  }
64
61
  const str = input instanceof Array ? input[0] : input;
65
- if (str == null) {
62
+ if (str === null || str === undefined) {
66
63
  return str;
67
64
  }
68
65
  if (!allowEmptyString && str === '') {
@@ -83,7 +80,7 @@ function encodeTimeRangeValue(timeOptionValue) {
83
80
  }
84
81
  function decodeTimeRangeValue(input) {
85
82
  const paramString = getEncodedValue(input);
86
- if (paramString == null) return paramString;
83
+ if (!paramString) return null;
87
84
  return (0, _core.isDurationString)(paramString) ? paramString : new Date(Number(paramString));
88
85
  }
89
86
  const TimeRangeParam = {
@@ -91,7 +88,7 @@ const TimeRangeParam = {
91
88
  decode: decodeTimeRangeValue,
92
89
  equals: (valueA, valueB)=>{
93
90
  if (valueA === valueB) return true;
94
- if (valueA == null || valueB == null) return valueA === valueB;
91
+ if (!valueA || !valueB) return valueA === valueB;
95
92
  return valueA.valueOf() === valueB.valueOf();
96
93
  }
97
94
  };
@@ -0,0 +1,99 @@
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
+ "use strict";
14
+ Object.defineProperty(exports, "__esModule", {
15
+ value: true
16
+ });
17
+ function _export(target, all) {
18
+ for(var name in all)Object.defineProperty(target, name, {
19
+ enumerable: true,
20
+ get: all[name]
21
+ });
22
+ }
23
+ _export(exports, {
24
+ UsageMetricsContext: function() {
25
+ return UsageMetricsContext;
26
+ },
27
+ UsageMetricsProvider: function() {
28
+ return UsageMetricsProvider;
29
+ },
30
+ useUsageMetrics: function() {
31
+ return useUsageMetrics;
32
+ },
33
+ useUsageMetricsContext: function() {
34
+ return useUsageMetricsContext;
35
+ }
36
+ });
37
+ const _jsxruntime = require("react/jsx-runtime");
38
+ const _core = require("@perses-dev/core");
39
+ const _react = require("react");
40
+ const UsageMetricsContext = /*#__PURE__*/ (0, _react.createContext)(undefined);
41
+ const useUsageMetricsContext = ()=>{
42
+ return (0, _react.useContext)(UsageMetricsContext);
43
+ };
44
+ const useUsageMetrics = ()=>{
45
+ const ctx = useUsageMetricsContext();
46
+ return {
47
+ markQuery: (definition, newState)=>{
48
+ if (ctx === undefined) {
49
+ return;
50
+ }
51
+ const definitionKey = JSON.stringify(definition);
52
+ if (ctx.pendingQueries.has(definitionKey) && newState === 'pending') {
53
+ // Never allow transitions back to pending, to avoid re-sending stats on a re-render.
54
+ return;
55
+ }
56
+ if (ctx.pendingQueries.get(definitionKey) !== newState) {
57
+ ctx.pendingQueries.set(definitionKey, newState);
58
+ if (newState === 'error') {
59
+ ctx.renderErrorCount += 1;
60
+ }
61
+ const allDone = [
62
+ ...ctx.pendingQueries.values()
63
+ ].every((p)=>p !== 'pending');
64
+ if (ctx.renderDurationMs === 0 && allDone) {
65
+ ctx.renderDurationMs = Date.now() - ctx.startRenderTime;
66
+ submitMetrics(ctx);
67
+ }
68
+ }
69
+ }
70
+ };
71
+ };
72
+ const submitMetrics = async (stats)=>{
73
+ await (0, _core.fetch)('/api/v1/view', {
74
+ method: 'POST',
75
+ headers: {
76
+ 'Content-Type': 'application/json'
77
+ },
78
+ body: JSON.stringify({
79
+ project: stats.project,
80
+ dashboard: stats.dashboard,
81
+ render_time: stats.renderDurationMs / 1000,
82
+ render_errors: stats.renderErrorCount
83
+ })
84
+ });
85
+ };
86
+ const UsageMetricsProvider = ({ project, dashboard, children })=>{
87
+ const ctx = {
88
+ project: project,
89
+ dashboard: dashboard,
90
+ renderErrorCount: 0,
91
+ startRenderTime: Date.now(),
92
+ renderDurationMs: 0,
93
+ pendingQueries: new Map()
94
+ };
95
+ return /*#__PURE__*/ (0, _jsxruntime.jsx)(UsageMetricsContext.Provider, {
96
+ value: ctx,
97
+ children: children
98
+ });
99
+ };
@@ -1,4 +1,4 @@
1
- // Copyright 2023 The Perses Authors
1
+ // Copyright 2024 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -59,7 +59,7 @@ function useBuiltinVariableValues(names) {
59
59
  ]);
60
60
  const values = (0, _react.useMemo)(()=>{
61
61
  const values = {};
62
- names === null || names === void 0 ? void 0 : names.forEach((name)=>{
62
+ names?.forEach((name)=>{
63
63
  const s = states[name];
64
64
  if (s) {
65
65
  values[name] = s;
@@ -47,25 +47,34 @@ function useDatasourceStore() {
47
47
  }
48
48
  return ctx;
49
49
  }
50
- function useListDatasourceSelectItems(datasourcePluginKind, project) {
50
+ function useListDatasourceSelectItems(datasourcePluginName, project) {
51
51
  const { listDatasourceSelectItems } = useDatasourceStore();
52
- return (0, _reactquery.useQuery)([
53
- 'listDatasourceSelectItems',
54
- datasourcePluginKind,
55
- project
56
- ], ()=>listDatasourceSelectItems(datasourcePluginKind));
52
+ return (0, _reactquery.useQuery)({
53
+ queryKey: [
54
+ 'listDatasourceSelectItems',
55
+ datasourcePluginName,
56
+ project
57
+ ],
58
+ queryFn: ()=>listDatasourceSelectItems(datasourcePluginName)
59
+ });
57
60
  }
58
61
  function useDatasourceClient(selector) {
59
62
  const store = useDatasourceStore();
60
- return (0, _reactquery.useQuery)([
61
- 'getDatasourceClient',
62
- selector
63
- ], ()=>store.getDatasourceClient(selector));
63
+ return (0, _reactquery.useQuery)({
64
+ queryKey: [
65
+ 'getDatasourceClient',
66
+ selector
67
+ ],
68
+ queryFn: ()=>store.getDatasourceClient(selector)
69
+ });
64
70
  }
65
71
  function useDatasource(selector) {
66
72
  const store = useDatasourceStore();
67
- return (0, _reactquery.useQuery)([
68
- 'getDatasource',
69
- selector
70
- ], ()=>store.getDatasource(selector));
73
+ return (0, _reactquery.useQuery)({
74
+ queryKey: [
75
+ 'getDatasource',
76
+ selector
77
+ ],
78
+ queryFn: ()=>store.getDatasource(selector)
79
+ });
71
80
  }
@@ -1,4 +1,4 @@
1
- // Copyright 2023 The Perses Authors
1
+ // Copyright 2024 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -17,11 +17,13 @@ Object.defineProperty(exports, "__esModule", {
17
17
  _export_star(require("./builtin-variables"), exports);
18
18
  _export_star(require("./datasources"), exports);
19
19
  _export_star(require("./plugin-registry"), exports);
20
- _export_star(require("./template-variables"), exports);
20
+ _export_star(require("./variables"), exports);
21
21
  _export_star(require("./TimeRangeProvider"), exports);
22
22
  _export_star(require("./time-series-queries"), exports);
23
23
  _export_star(require("./trace-queries"), exports);
24
24
  _export_star(require("./DataQueriesProvider"), exports);
25
+ _export_star(require("./QueryCountProvider"), exports);
26
+ _export_star(require("./UsageMetricsProvider"), exports);
25
27
  function _export_star(from, to) {
26
28
  Object.keys(from).forEach(function(k) {
27
29
  if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
@@ -40,8 +40,8 @@ _export(exports, {
40
40
  return usePlugins;
41
41
  }
42
42
  });
43
- const _react = require("react");
44
43
  const _reactquery = require("@tanstack/react-query");
44
+ const _react = require("react");
45
45
  const PluginRegistryContext = (0, _react.createContext)(undefined);
46
46
  function usePluginRegistry() {
47
47
  const ctx = (0, _react.useContext)(PluginRegistryContext);
@@ -51,18 +51,21 @@ function usePluginRegistry() {
51
51
  return ctx;
52
52
  }
53
53
  function usePlugin(pluginType, kind, options) {
54
- var _options_enabled;
55
54
  // We never want to ask for a plugin when the kind isn't set yet, so disable those queries automatically
56
55
  options = {
57
56
  ...options,
58
- enabled: ((_options_enabled = options === null || options === void 0 ? void 0 : options.enabled) !== null && _options_enabled !== void 0 ? _options_enabled : true) && kind !== ''
57
+ enabled: (options?.enabled ?? true) && pluginType !== undefined && kind !== ''
59
58
  };
60
59
  const { getPlugin } = usePluginRegistry();
61
- return (0, _reactquery.useQuery)([
62
- 'getPlugin',
63
- pluginType,
64
- kind
65
- ], ()=>getPlugin(pluginType, kind), options);
60
+ return (0, _reactquery.useQuery)({
61
+ queryKey: [
62
+ 'getPlugin',
63
+ pluginType,
64
+ kind
65
+ ],
66
+ queryFn: ()=>getPlugin(pluginType, kind),
67
+ ...options
68
+ });
66
69
  }
67
70
  function usePlugins(pluginType, plugins) {
68
71
  const { getPlugin } = usePluginRegistry();
@@ -79,27 +82,36 @@ function usePlugins(pluginType, plugins) {
79
82
  })
80
83
  });
81
84
  }
82
- function useListPluginMetadata(pluginType, options) {
85
+ function useListPluginMetadata(pluginTypes, options) {
83
86
  const { listPluginMetadata } = usePluginRegistry();
84
- return (0, _reactquery.useQuery)([
85
- 'listPluginMetadata',
86
- pluginType
87
- ], ()=>listPluginMetadata(pluginType), options);
87
+ return (0, _reactquery.useQuery)({
88
+ queryKey: [
89
+ 'listPluginMetadata',
90
+ pluginTypes
91
+ ],
92
+ queryFn: ()=>listPluginMetadata(pluginTypes),
93
+ ...options
94
+ });
88
95
  }
89
96
  function usePluginBuiltinVariableDefinitions() {
90
97
  const { getPlugin, listPluginMetadata } = usePluginRegistry();
91
- return (0, _reactquery.useQuery)([
92
- 'usePluginBuiltinVariableDefinitions'
93
- ], async ()=>{
94
- const datasources = await listPluginMetadata('Datasource');
95
- const datasourceKinds = new Set(datasources.map((datasource)=>datasource.kind));
96
- const result = [];
97
- for (const kind of datasourceKinds){
98
- const plugin = await getPlugin('Datasource', kind);
99
- if (plugin.getBuiltinVariableDefinitions) {
100
- plugin.getBuiltinVariableDefinitions().forEach((definition)=>result.push(definition));
98
+ return (0, _reactquery.useQuery)({
99
+ queryKey: [
100
+ 'usePluginBuiltinVariableDefinitions'
101
+ ],
102
+ queryFn: async ()=>{
103
+ const datasources = await listPluginMetadata([
104
+ 'Datasource'
105
+ ]);
106
+ const datasourceNames = new Set(datasources.map((datasource)=>datasource.spec.name));
107
+ const result = [];
108
+ for (const name of datasourceNames){
109
+ const plugin = await getPlugin('Datasource', name);
110
+ if (plugin.getBuiltinVariableDefinitions) {
111
+ plugin.getBuiltinVariableDefinitions().forEach((definition)=>result.push(definition));
112
+ }
101
113
  }
114
+ return result;
102
115
  }
103
- return result;
104
116
  });
105
117
  }
@@ -1,4 +1,4 @@
1
- // Copyright 2023 The Perses Authors
1
+ // Copyright 2024 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -38,7 +38,7 @@ _export(exports, {
38
38
  }
39
39
  });
40
40
  const _reactquery = require("@tanstack/react-query");
41
- const _templatevariables = require("./template-variables");
41
+ const _variables = require("./variables");
42
42
  const _TimeRangeProvider = require("./TimeRangeProvider");
43
43
  const _datasources = require("./datasources");
44
44
  const _pluginregistry = require("./plugin-registry");
@@ -55,9 +55,9 @@ function filterVariableStateMap(v, names) {
55
55
  return Object.fromEntries(Object.entries(v).filter(([name])=>names.includes(name)));
56
56
  }
57
57
  function getQueryOptions({ plugin, definition, context }) {
58
- const { timeRange, datasourceStore, suggestedStepMs, variableState, refreshKey } = context;
59
- const dependencies = (plugin === null || plugin === void 0 ? void 0 : plugin.dependsOn) ? plugin.dependsOn(definition.spec.plugin.spec, context) : {};
60
- const variableDependencies = dependencies === null || dependencies === void 0 ? void 0 : dependencies.variables;
58
+ const { timeRange, datasourceStore, suggestedStepMs, mode, variableState, refreshKey } = context;
59
+ const dependencies = plugin?.dependsOn ? plugin.dependsOn(definition.spec.plugin.spec, context) : {};
60
+ const variableDependencies = dependencies?.variables;
61
61
  // Determine queryKey
62
62
  const filteredVariabledState = filterVariableStateMap(variableState, variableDependencies);
63
63
  const variablesValueKey = getVariableValuesKey(filteredVariabledState);
@@ -66,16 +66,14 @@ function getQueryOptions({ plugin, definition, context }) {
66
66
  timeRange,
67
67
  datasourceStore,
68
68
  suggestedStepMs,
69
+ mode,
69
70
  variablesValueKey,
70
71
  refreshKey
71
72
  ];
72
73
  // Determine queryEnabled
73
74
  let waitToLoad = false;
74
75
  if (variableDependencies) {
75
- waitToLoad = variableDependencies.some((v)=>{
76
- var _variableState_v;
77
- return (_variableState_v = variableState[v]) === null || _variableState_v === void 0 ? void 0 : _variableState_v.loading;
78
- });
76
+ waitToLoad = variableDependencies.some((v)=>variableState[v]?.loading);
79
77
  }
80
78
  const queryEnabled = plugin !== undefined && !waitToLoad;
81
79
  return {
@@ -91,11 +89,9 @@ const useTimeSeriesQuery = (definition, options, queryOptions)=>{
91
89
  definition,
92
90
  context
93
91
  });
94
- var _queryOptions_enabled;
95
92
  return (0, _reactquery.useQuery)({
96
- enabled: ((_queryOptions_enabled = queryOptions === null || queryOptions === void 0 ? void 0 : queryOptions.enabled) !== null && _queryOptions_enabled !== void 0 ? _queryOptions_enabled : true) || queryEnabled,
93
+ enabled: (queryOptions?.enabled ?? true) || queryEnabled,
97
94
  queryKey: queryKey,
98
- refetchInterval: context.refreshIntervalInMs > 0 ? context.refreshIntervalInMs : false,
99
95
  queryFn: ()=>{
100
96
  // The 'enabled' option should prevent this from happening, but make TypeScript happy by checking
101
97
  if (plugin === undefined) {
@@ -104,7 +100,7 @@ const useTimeSeriesQuery = (definition, options, queryOptions)=>{
104
100
  // Keep options out of query key so we don't re-run queries because suggested step changes
105
101
  const ctx = {
106
102
  ...context,
107
- suggestedStepMs: options === null || options === void 0 ? void 0 : options.suggestedStepMs
103
+ suggestedStepMs: options?.suggestedStepMs
108
104
  };
109
105
  return plugin.getTimeSeriesData(definition.spec.plugin.spec, ctx);
110
106
  }
@@ -112,29 +108,30 @@ const useTimeSeriesQuery = (definition, options, queryOptions)=>{
112
108
  };
113
109
  function useTimeSeriesQueries(definitions, options, queryOptions) {
114
110
  const { getPlugin } = (0, _pluginregistry.usePluginRegistry)();
115
- const context = useTimeSeriesQueryContext();
111
+ const context = {
112
+ ...useTimeSeriesQueryContext(),
113
+ // We need mode to be part query key because this drives the type of query done (instant VS range query)
114
+ mode: options?.mode
115
+ };
116
116
  const pluginLoaderResponse = (0, _pluginregistry.usePlugins)(TIME_SERIES_QUERY_KEY, definitions.map((d)=>({
117
117
  kind: d.spec.plugin.kind
118
118
  })));
119
119
  return (0, _reactquery.useQueries)({
120
120
  queries: definitions.map((definition, idx)=>{
121
- var _pluginLoaderResponse_idx;
122
- const plugin = (_pluginLoaderResponse_idx = pluginLoaderResponse[idx]) === null || _pluginLoaderResponse_idx === void 0 ? void 0 : _pluginLoaderResponse_idx.data;
121
+ const plugin = pluginLoaderResponse[idx]?.data;
123
122
  const { queryEnabled, queryKey } = getQueryOptions({
124
123
  plugin,
125
124
  definition,
126
125
  context
127
126
  });
128
- var _queryOptions_enabled;
129
127
  return {
130
- enabled: ((_queryOptions_enabled = queryOptions === null || queryOptions === void 0 ? void 0 : queryOptions.enabled) !== null && _queryOptions_enabled !== void 0 ? _queryOptions_enabled : true) && queryEnabled,
128
+ enabled: (queryOptions?.enabled ?? true) && queryEnabled,
131
129
  queryKey: queryKey,
132
- refetchInterval: context.refreshIntervalInMs > 0 ? context.refreshIntervalInMs : undefined,
133
130
  queryFn: async ()=>{
134
- // Keep options out of query key so we don't re-run queries because suggested step changes
135
131
  const ctx = {
136
132
  ...context,
137
- suggestedStepMs: options === null || options === void 0 ? void 0 : options.suggestedStepMs
133
+ // Keep suggested step changes out of the query key, so we don´t have to run again query when it changes
134
+ suggestedStepMs: options?.suggestedStepMs
138
135
  };
139
136
  const plugin = await getPlugin(TIME_SERIES_QUERY_KEY, definition.spec.plugin.kind);
140
137
  const data = await plugin.getTimeSeriesData(definition.spec.plugin.spec, ctx);
@@ -147,15 +144,14 @@ function useTimeSeriesQueries(definitions, options, queryOptions) {
147
144
  /**
148
145
  * Build the time series query context object from data available at runtime
149
146
  */ function useTimeSeriesQueryContext() {
150
- const { absoluteTimeRange, refreshKey, refreshIntervalInMs } = (0, _TimeRangeProvider.useTimeRange)();
151
- const variableState = (0, _templatevariables.useVariableValues)();
147
+ const { absoluteTimeRange, refreshKey } = (0, _TimeRangeProvider.useTimeRange)();
148
+ const variableState = (0, _variables.useAllVariableValues)();
152
149
  const datasourceStore = (0, _datasources.useDatasourceStore)();
153
150
  return {
154
151
  timeRange: absoluteTimeRange,
155
152
  variableState,
156
153
  datasourceStore,
157
- refreshKey,
158
- refreshIntervalInMs: refreshIntervalInMs
154
+ refreshKey
159
155
  };
160
156
  }
161
157
  function useActiveTimeSeriesQueries() {
@@ -168,9 +164,8 @@ function getActiveTimeSeriesQueries(cache) {
168
164
  for (const query of cache.findAll({
169
165
  type: 'active'
170
166
  })){
171
- var _query_queryKey;
172
- const firstPart = (_query_queryKey = query.queryKey) === null || _query_queryKey === void 0 ? void 0 : _query_queryKey[0];
173
- if ((firstPart === null || firstPart === void 0 ? void 0 : firstPart.kind) && firstPart.kind.startsWith(TIME_SERIES_QUERY_KEY)) {
167
+ const firstPart = query.queryKey?.[0];
168
+ if (firstPart?.kind && firstPart.kind.startsWith(TIME_SERIES_QUERY_KEY)) {
174
169
  queries.push(query);
175
170
  }
176
171
  }
@@ -56,20 +56,23 @@ function useTraceQueries(definitions) {
56
56
  // https://tanstack.com/query/v4/docs/react/reference/useQuery
57
57
  return (0, _reactquery.useQueries)({
58
58
  queries: definitions.map((definition)=>{
59
- var _definition_spec_plugin, _definition_spec;
60
59
  const queryKey = [
61
60
  definition,
62
61
  datasourceStore,
63
62
  absoluteTimeRange
64
63
  ]; // `queryKey` watches and reruns `queryFn` if keys in the array change
65
- const traceQueryKind = definition === null || definition === void 0 ? void 0 : (_definition_spec = definition.spec) === null || _definition_spec === void 0 ? void 0 : (_definition_spec_plugin = _definition_spec.plugin) === null || _definition_spec_plugin === void 0 ? void 0 : _definition_spec_plugin.kind;
64
+ const traceQueryKind = definition?.spec?.plugin?.kind;
66
65
  return {
67
66
  queryKey: queryKey,
68
67
  queryFn: async ()=>{
69
68
  const plugin = await getPlugin(TRACE_QUERY_KEY, traceQueryKind);
70
69
  const data = await plugin.getTraceData(definition.spec.plugin.spec, context);
71
70
  return data;
72
- }
71
+ },
72
+ // The data returned by getTraceData() contains circular dependencies (a span has a reference to the parent span, and the parent span has an array of child spans)
73
+ // Therefore structuralSharing must be turned off, otherwise the query is stuck in the 'fetching' state on re-fetch.
74
+ // Ref: https://github.com/TanStack/query/issues/6954#issuecomment-1962321426
75
+ structuralSharing: false
73
76
  };
74
77
  })
75
78
  });
@@ -1,4 +1,4 @@
1
- // Copyright 2023 The Perses Authors
1
+ // Copyright 2024 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -21,18 +21,18 @@ function _export(target, all) {
21
21
  });
22
22
  }
23
23
  _export(exports, {
24
- TemplateVariableContext: function() {
25
- return TemplateVariableContext;
24
+ VariableContext: function() {
25
+ return VariableContext;
26
26
  },
27
27
  VariableStoreStateMap: function() {
28
28
  return VariableStoreStateMap;
29
29
  },
30
+ useAllVariableValues: function() {
31
+ return useAllVariableValues;
32
+ },
30
33
  useReplaceVariablesInString: function() {
31
34
  return useReplaceVariablesInString;
32
35
  },
33
- useTemplateVariableValues: function() {
34
- return useTemplateVariableValues;
35
- },
36
36
  useVariableValues: function() {
37
37
  return useVariableValues;
38
38
  }
@@ -41,22 +41,14 @@ const _react = require("react");
41
41
  const _immer = require("immer");
42
42
  const _utils = require("../utils");
43
43
  const _builtinvariables = require("./builtin-variables");
44
- function _define_property(obj, key, value) {
45
- if (key in obj) {
46
- Object.defineProperty(obj, key, {
47
- value: value,
48
- enumerable: true,
49
- configurable: true,
50
- writable: true
51
- });
52
- } else {
53
- obj[key] = value;
54
- }
55
- return obj;
56
- }
57
- let _immerable = _immer.immerable;
58
44
  class VariableStoreStateMap {
59
45
  /**
46
+ * "Immerable" is mandatory to be able to use this class in an immer context.
47
+ * Ref: https://docs.pmnd.rs/zustand/integrations/immer-middleware#gotchas
48
+ */ [_immer.immerable] = true;
49
+ DEFAULT_LOCAL_SOURCE_NAME = '';
50
+ _state = {};
51
+ /**
60
52
  * Get variable state by key.
61
53
  * @param key
62
54
  */ get(key) {
@@ -84,7 +76,6 @@ class VariableStoreStateMap {
84
76
  * Delete variable state by key.
85
77
  * @param key
86
78
  */ delete(key) {
87
- var _Object_keys;
88
79
  const result = this.has(key);
89
80
  const sourceName = this._sourceName(key.source);
90
81
  const sourceStates = this._state[sourceName];
@@ -93,40 +84,31 @@ class VariableStoreStateMap {
93
84
  delete sourceStates[key.name];
94
85
  }
95
86
  // Delete source state from state if empty
96
- if (((_Object_keys = Object.keys(sourceStates !== null && sourceStates !== void 0 ? sourceStates : {})) === null || _Object_keys === void 0 ? void 0 : _Object_keys.length) === 0) {
87
+ if (Object.keys(sourceStates ?? {})?.length === 0) {
97
88
  delete this._state[sourceName];
98
89
  }
99
90
  return result;
100
91
  }
101
92
  _sourceName(source) {
102
- return source !== null && source !== void 0 ? source : this.DEFAULT_LOCAL_SOURCE_NAME;
93
+ return source ?? this.DEFAULT_LOCAL_SOURCE_NAME;
103
94
  }
104
95
  _sourceStatesOrEmpty(source) {
105
- var _this__state_this__sourceName;
106
- return (_this__state_this__sourceName = this._state[this._sourceName(source)]) !== null && _this__state_this__sourceName !== void 0 ? _this__state_this__sourceName : {};
107
- }
108
- constructor(){
109
- /**
110
- * "Immerable" is mandatory to be able to use this class in an immer context.
111
- * Ref: https://docs.pmnd.rs/zustand/integrations/immer-middleware#gotchas
112
- */ _define_property(this, _immerable, true);
113
- _define_property(this, "DEFAULT_LOCAL_SOURCE_NAME", '');
114
- _define_property(this, "_state", {});
96
+ return this._state[this._sourceName(source)] ?? {};
115
97
  }
116
98
  }
117
- const TemplateVariableContext = (0, _react.createContext)(undefined);
118
- function useTemplateVariableContext() {
119
- const ctx = (0, _react.useContext)(TemplateVariableContext);
99
+ const VariableContext = (0, _react.createContext)(undefined);
100
+ function useVariableContext() {
101
+ const ctx = (0, _react.useContext)(VariableContext);
120
102
  if (ctx === undefined) {
121
- throw new Error('No TemplateVariableContext found. Did you forget a Provider?');
103
+ throw new Error('No VariableContext found. Did you forget a Provider?');
122
104
  }
123
105
  return ctx;
124
106
  }
125
- function useTemplateVariableValues(names) {
126
- const { state } = useTemplateVariableContext();
107
+ function useVariableValues(names) {
108
+ const { state } = useVariableContext();
127
109
  const values = (0, _react.useMemo)(()=>{
128
110
  const values = {};
129
- names === null || names === void 0 ? void 0 : names.forEach((name)=>{
111
+ names?.forEach((name)=>{
130
112
  const s = state[name];
131
113
  if (s) {
132
114
  values[name] = s;
@@ -142,22 +124,22 @@ function useTemplateVariableValues(names) {
142
124
  }
143
125
  return values;
144
126
  }
145
- function useVariableValues(names) {
146
- const templateVariableValues = useTemplateVariableValues(names);
127
+ function useAllVariableValues(names) {
128
+ const variableValues = useVariableValues(names);
147
129
  const builtinVariableValues = (0, _builtinvariables.useBuiltinVariableValues)(names);
148
130
  return (0, _react.useMemo)(()=>{
149
131
  return {
150
- ...templateVariableValues,
132
+ ...variableValues,
151
133
  ...builtinVariableValues
152
134
  };
153
135
  }, [
154
- templateVariableValues,
136
+ variableValues,
155
137
  builtinVariableValues
156
138
  ]);
157
139
  }
158
140
  function useReplaceVariablesInString(str) {
159
- const variablesInString = str ? (0, _utils.parseTemplateVariables)(str) : [];
160
- const variableValues = useVariableValues(variablesInString);
141
+ const variablesInString = str ? (0, _utils.parseVariables)(str) : [];
142
+ const variableValues = useAllVariableValues(variablesInString);
161
143
  if (!str) return undefined;
162
- return (0, _utils.replaceTemplateVariables)(str, variableValues);
144
+ return (0, _utils.replaceVariables)(str, variableValues);
163
145
  }
@@ -33,7 +33,7 @@ const WithDataQueries = (Story, context)=>{
33
33
  definitions: []
34
34
  }
35
35
  };
36
- const props = parameter === null || parameter === void 0 ? void 0 : parameter.props;
36
+ const props = parameter?.props;
37
37
  return /*#__PURE__*/ (0, _jsxruntime.jsx)(_pluginsystem.DataQueriesProvider, {
38
38
  ...props,
39
39
  children: /*#__PURE__*/ (0, _jsxruntime.jsx)(Story, {})