@perses-dev/plugin-system 0.52.0-beta.2 → 0.52.0-beta.3

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 (394) hide show
  1. package/dist/components/CalculationSelector/CalculationSelector.js.map +1 -0
  2. package/dist/{src/components/MetricLabelInput → components/CalculationSelector}/index.js.map +1 -1
  3. package/dist/components/DatasourceEditorForm/DatasourceEditorForm.js.map +1 -0
  4. package/dist/{src/components/MultiQueryEditor → components/DatasourceEditorForm}/index.js.map +1 -1
  5. package/dist/components/DatasourceSelect.js.map +1 -0
  6. package/dist/components/HTTPSettingsEditor/HTTPSettingsEditor.js.map +1 -0
  7. package/dist/components/HTTPSettingsEditor/index.js.map +1 -0
  8. package/dist/components/LegendOptionsEditor/LegendOptionsEditor.js.map +1 -0
  9. package/dist/{src/components/PanelSpecEditor → components/LegendOptionsEditor}/index.js.map +1 -1
  10. package/dist/components/MetricLabelInput/MetricLabelInput.js.map +1 -0
  11. package/dist/components/MetricLabelInput/index.js.map +1 -0
  12. package/dist/components/MultiQueryEditor/MultiQueryEditor.js.map +1 -0
  13. package/dist/components/MultiQueryEditor/QueryEditorContainer.js.map +1 -0
  14. package/dist/{src/components/PluginRegistry → components/MultiQueryEditor}/index.js.map +1 -1
  15. package/dist/components/OptionsEditorRadios/OptionsEditorRadios.js.map +1 -0
  16. package/dist/{src/runtime/DataQueriesProvider → components/OptionsEditorRadios}/index.js.map +1 -1
  17. package/dist/components/OptionsEditorTabPanel/OptionsEditorTabPanel.js.map +1 -0
  18. package/dist/{src/components/HTTPSettingsEditor → components/OptionsEditorTabPanel}/index.js.map +1 -1
  19. package/dist/components/OptionsEditorTabs/OptionsEditorTabs.js.map +1 -0
  20. package/dist/{src/runtime/TimeRangeProvider → components/OptionsEditorTabs}/index.js.map +1 -1
  21. package/dist/components/PanelSpecEditor/PanelSpecEditor.js.map +1 -0
  22. package/dist/components/PanelSpecEditor/index.js.map +1 -0
  23. package/dist/components/PluginEditor/PluginEditor.js.map +1 -0
  24. package/dist/{src/components/Variables → components/PluginEditor}/index.js.map +1 -1
  25. package/dist/components/PluginEditor/plugin-editor-api.js.map +1 -0
  26. package/dist/components/PluginKindSelect/PluginKindSelect.js.map +1 -0
  27. package/dist/components/PluginKindSelect/index.js.map +1 -0
  28. package/dist/components/PluginRegistry/PluginRegistry.js.map +1 -0
  29. package/dist/components/PluginRegistry/index.js.map +1 -0
  30. package/dist/components/PluginRegistry/plugin-indexes.js.map +1 -0
  31. package/dist/components/PluginSpecEditor/PluginSpecEditor.js.map +1 -0
  32. package/dist/components/PluginSpecEditor/index.js.map +1 -0
  33. package/dist/components/ProjectSelect.js.map +1 -0
  34. package/dist/components/TimeRangeControls/TimeRangeControls.js.map +1 -0
  35. package/dist/components/TimeRangeControls/index.js.map +1 -0
  36. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js.map +1 -0
  37. package/dist/components/Variables/VariableEditorForm/VariablePreview.js.map +1 -0
  38. package/dist/components/Variables/VariableEditorForm/index.js.map +1 -0
  39. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js.map +1 -0
  40. package/dist/components/Variables/index.js.map +1 -0
  41. package/dist/components/Variables/variable-model.js.map +1 -0
  42. package/dist/components/index.js.map +1 -0
  43. package/dist/{src/remote → constants}/index.js.map +1 -1
  44. package/dist/constants/user-interface-text.js.map +1 -0
  45. package/dist/context/ProjectStoreProvider.js.map +1 -0
  46. package/dist/context/ValidationProvider.js.map +1 -0
  47. package/dist/{src/test → context}/index.js.map +1 -1
  48. package/dist/context/query-params.js.map +1 -0
  49. package/dist/index.js.map +1 -0
  50. package/dist/model/datasource.js.map +1 -0
  51. package/dist/model/explore.js.map +1 -0
  52. package/dist/model/index.js.map +1 -0
  53. package/dist/model/legend.js.map +1 -0
  54. package/dist/model/panels.js.map +1 -0
  55. package/dist/model/plugin-base.js.map +1 -0
  56. package/dist/model/plugin-loading.js.map +1 -0
  57. package/dist/model/plugins.js.map +1 -0
  58. package/dist/model/profile-queries.js.map +1 -0
  59. package/dist/model/time-series-queries.js.map +1 -0
  60. package/dist/model/trace-queries.js.map +1 -0
  61. package/dist/model/variables.js.map +1 -0
  62. package/dist/remote/PersesPlugin.types.js.map +1 -0
  63. package/dist/remote/PluginLoaderComponent.js.map +1 -0
  64. package/dist/remote/PluginRuntime.js.map +1 -0
  65. package/dist/remote/index.js.map +1 -0
  66. package/dist/remote/remotePluginLoader.js.map +1 -0
  67. package/dist/runtime/DataQueriesProvider/DataQueriesProvider.js.map +1 -0
  68. package/dist/runtime/DataQueriesProvider/index.js.map +1 -0
  69. package/dist/runtime/DataQueriesProvider/model.js.map +1 -0
  70. package/dist/runtime/QueryCountProvider.js.map +1 -0
  71. package/dist/runtime/RouterProvider.js.map +1 -0
  72. package/dist/runtime/TimeRangeProvider/TimeRangeProvider.js.map +1 -0
  73. package/dist/runtime/TimeRangeProvider/TimeRangeProviderWithQueryParams.js.map +1 -0
  74. package/dist/runtime/TimeRangeProvider/TimeRangeSettingsProvider.js.map +1 -0
  75. package/dist/runtime/TimeRangeProvider/index.js.map +1 -0
  76. package/dist/runtime/TimeRangeProvider/query-params.js.map +1 -0
  77. package/dist/runtime/TimeRangeProvider/refresh-interval.js.map +1 -0
  78. package/dist/runtime/UsageMetricsProvider.js.map +1 -0
  79. package/dist/runtime/builtin-variables.js.map +1 -0
  80. package/dist/runtime/datasources.js.map +1 -0
  81. package/dist/runtime/index.js.map +1 -0
  82. package/dist/runtime/plugin-registry.js.map +1 -0
  83. package/dist/runtime/profile-queries.js.map +1 -0
  84. package/dist/runtime/time-series-queries.js.map +1 -0
  85. package/dist/runtime/trace-queries.js.map +1 -0
  86. package/dist/runtime/utils.js.map +1 -0
  87. package/dist/runtime/variables.js.map +1 -0
  88. package/dist/test/index.js.map +1 -0
  89. package/dist/test/mock-data.js.map +1 -0
  90. package/dist/test/render-hook.js.map +1 -0
  91. package/dist/test/render.js.map +1 -0
  92. package/dist/test/setup-tests.js.map +1 -0
  93. package/dist/test/test-plugins/bert/index.js.map +1 -0
  94. package/dist/test/test-plugins/ernie/index.js.map +1 -0
  95. package/dist/test/test-plugins/index.js.map +1 -0
  96. package/dist/test/utils.js.map +1 -0
  97. package/dist/{src/context → test-utils}/index.js.map +1 -1
  98. package/dist/test-utils/mock-plugin-registry.js.map +1 -0
  99. package/dist/utils/action.js.map +1 -0
  100. package/dist/utils/index.js.map +1 -0
  101. package/dist/utils/variables.js.map +1 -0
  102. package/package.json +5 -5
  103. package/dist/src/components/CalculationSelector/CalculationSelector.js.map +0 -1
  104. package/dist/src/components/CalculationSelector/index.js.map +0 -1
  105. package/dist/src/components/DatasourceEditorForm/DatasourceEditorForm.js.map +0 -1
  106. package/dist/src/components/DatasourceEditorForm/index.js.map +0 -1
  107. package/dist/src/components/DatasourceSelect.js.map +0 -1
  108. package/dist/src/components/HTTPSettingsEditor/HTTPSettingsEditor.js.map +0 -1
  109. package/dist/src/components/LegendOptionsEditor/LegendOptionsEditor.js.map +0 -1
  110. package/dist/src/components/LegendOptionsEditor/index.js.map +0 -1
  111. package/dist/src/components/MetricLabelInput/MetricLabelInput.js.map +0 -1
  112. package/dist/src/components/MultiQueryEditor/MultiQueryEditor.js.map +0 -1
  113. package/dist/src/components/MultiQueryEditor/QueryEditorContainer.js.map +0 -1
  114. package/dist/src/components/OptionsEditorRadios/OptionsEditorRadios.js.map +0 -1
  115. package/dist/src/components/OptionsEditorRadios/index.js.map +0 -1
  116. package/dist/src/components/OptionsEditorTabPanel/OptionsEditorTabPanel.js.map +0 -1
  117. package/dist/src/components/OptionsEditorTabPanel/index.js.map +0 -1
  118. package/dist/src/components/OptionsEditorTabs/OptionsEditorTabs.js.map +0 -1
  119. package/dist/src/components/OptionsEditorTabs/index.js.map +0 -1
  120. package/dist/src/components/PanelSpecEditor/PanelSpecEditor.js.map +0 -1
  121. package/dist/src/components/PluginEditor/PluginEditor.js.map +0 -1
  122. package/dist/src/components/PluginEditor/index.js.map +0 -1
  123. package/dist/src/components/PluginEditor/plugin-editor-api.js.map +0 -1
  124. package/dist/src/components/PluginKindSelect/PluginKindSelect.js.map +0 -1
  125. package/dist/src/components/PluginKindSelect/index.js.map +0 -1
  126. package/dist/src/components/PluginRegistry/PluginRegistry.js.map +0 -1
  127. package/dist/src/components/PluginRegistry/plugin-indexes.js.map +0 -1
  128. package/dist/src/components/PluginSpecEditor/PluginSpecEditor.js.map +0 -1
  129. package/dist/src/components/PluginSpecEditor/index.js.map +0 -1
  130. package/dist/src/components/ProjectSelect.js.map +0 -1
  131. package/dist/src/components/TimeRangeControls/TimeRangeControls.js.map +0 -1
  132. package/dist/src/components/TimeRangeControls/index.js.map +0 -1
  133. package/dist/src/components/Variables/VariableEditorForm/VariableEditorForm.js.map +0 -1
  134. package/dist/src/components/Variables/VariableEditorForm/VariablePreview.js.map +0 -1
  135. package/dist/src/components/Variables/VariableEditorForm/index.js.map +0 -1
  136. package/dist/src/components/Variables/VariableEditorForm/variable-editor-form-model.js.map +0 -1
  137. package/dist/src/components/Variables/variable-model.js.map +0 -1
  138. package/dist/src/components/index.js.map +0 -1
  139. package/dist/src/constants/index.js.map +0 -1
  140. package/dist/src/constants/user-interface-text.js.map +0 -1
  141. package/dist/src/context/ProjectStoreProvider.js.map +0 -1
  142. package/dist/src/context/ValidationProvider.js.map +0 -1
  143. package/dist/src/context/query-params.js.map +0 -1
  144. package/dist/src/index.js.map +0 -1
  145. package/dist/src/model/datasource.js.map +0 -1
  146. package/dist/src/model/explore.js.map +0 -1
  147. package/dist/src/model/index.js.map +0 -1
  148. package/dist/src/model/legend.js.map +0 -1
  149. package/dist/src/model/panels.js.map +0 -1
  150. package/dist/src/model/plugin-base.js.map +0 -1
  151. package/dist/src/model/plugin-loading.js.map +0 -1
  152. package/dist/src/model/plugins.js.map +0 -1
  153. package/dist/src/model/profile-queries.js.map +0 -1
  154. package/dist/src/model/time-series-queries.js.map +0 -1
  155. package/dist/src/model/trace-queries.js.map +0 -1
  156. package/dist/src/model/variables.js.map +0 -1
  157. package/dist/src/remote/PersesPlugin.types.js.map +0 -1
  158. package/dist/src/remote/PluginLoaderComponent.js.map +0 -1
  159. package/dist/src/remote/PluginRuntime.js.map +0 -1
  160. package/dist/src/remote/remotePluginLoader.js.map +0 -1
  161. package/dist/src/runtime/DataQueriesProvider/DataQueriesProvider.js.map +0 -1
  162. package/dist/src/runtime/DataQueriesProvider/model.js.map +0 -1
  163. package/dist/src/runtime/QueryCountProvider.js.map +0 -1
  164. package/dist/src/runtime/RouterProvider.js.map +0 -1
  165. package/dist/src/runtime/TimeRangeProvider/TimeRangeProvider.js.map +0 -1
  166. package/dist/src/runtime/TimeRangeProvider/TimeRangeProviderWithQueryParams.js.map +0 -1
  167. package/dist/src/runtime/TimeRangeProvider/TimeRangeSettingsProvider.js.map +0 -1
  168. package/dist/src/runtime/TimeRangeProvider/query-params.js.map +0 -1
  169. package/dist/src/runtime/TimeRangeProvider/refresh-interval.js.map +0 -1
  170. package/dist/src/runtime/UsageMetricsProvider.js.map +0 -1
  171. package/dist/src/runtime/builtin-variables.js.map +0 -1
  172. package/dist/src/runtime/datasources.js.map +0 -1
  173. package/dist/src/runtime/index.js.map +0 -1
  174. package/dist/src/runtime/plugin-registry.js.map +0 -1
  175. package/dist/src/runtime/profile-queries.js.map +0 -1
  176. package/dist/src/runtime/time-series-queries.js.map +0 -1
  177. package/dist/src/runtime/trace-queries.js.map +0 -1
  178. package/dist/src/runtime/utils.js.map +0 -1
  179. package/dist/src/runtime/variables.js.map +0 -1
  180. package/dist/src/test/mock-data.js.map +0 -1
  181. package/dist/src/test/render-hook.js.map +0 -1
  182. package/dist/src/test/render.js.map +0 -1
  183. package/dist/src/test/setup-tests.js.map +0 -1
  184. package/dist/src/test/test-plugins/bert/index.js.map +0 -1
  185. package/dist/src/test/test-plugins/ernie/index.js.map +0 -1
  186. package/dist/src/test/test-plugins/index.js.map +0 -1
  187. package/dist/src/test/utils.js.map +0 -1
  188. package/dist/src/test-utils/index.js.map +0 -1
  189. package/dist/src/test-utils/mock-plugin-registry.js.map +0 -1
  190. package/dist/src/utils/action.js.map +0 -1
  191. package/dist/src/utils/index.js.map +0 -1
  192. package/dist/src/utils/variables.js.map +0 -1
  193. /package/dist/cjs/{src/components → components}/CalculationSelector/CalculationSelector.js +0 -0
  194. /package/dist/cjs/{src/components → components}/CalculationSelector/index.js +0 -0
  195. /package/dist/cjs/{src/components → components}/DatasourceEditorForm/DatasourceEditorForm.js +0 -0
  196. /package/dist/cjs/{src/components → components}/DatasourceEditorForm/index.js +0 -0
  197. /package/dist/cjs/{src/components → components}/DatasourceSelect.js +0 -0
  198. /package/dist/cjs/{src/components → components}/HTTPSettingsEditor/HTTPSettingsEditor.js +0 -0
  199. /package/dist/cjs/{src/components → components}/HTTPSettingsEditor/index.js +0 -0
  200. /package/dist/cjs/{src/components → components}/LegendOptionsEditor/LegendOptionsEditor.js +0 -0
  201. /package/dist/cjs/{src/components → components}/LegendOptionsEditor/index.js +0 -0
  202. /package/dist/cjs/{src/components → components}/MetricLabelInput/MetricLabelInput.js +0 -0
  203. /package/dist/cjs/{src/components → components}/MetricLabelInput/index.js +0 -0
  204. /package/dist/cjs/{src/components → components}/MultiQueryEditor/MultiQueryEditor.js +0 -0
  205. /package/dist/cjs/{src/components → components}/MultiQueryEditor/QueryEditorContainer.js +0 -0
  206. /package/dist/cjs/{src/components → components}/MultiQueryEditor/index.js +0 -0
  207. /package/dist/cjs/{src/components → components}/OptionsEditorRadios/OptionsEditorRadios.js +0 -0
  208. /package/dist/cjs/{src/components → components}/OptionsEditorRadios/index.js +0 -0
  209. /package/dist/cjs/{src/components → components}/OptionsEditorTabPanel/OptionsEditorTabPanel.js +0 -0
  210. /package/dist/cjs/{src/components → components}/OptionsEditorTabPanel/index.js +0 -0
  211. /package/dist/cjs/{src/components → components}/OptionsEditorTabs/OptionsEditorTabs.js +0 -0
  212. /package/dist/cjs/{src/components → components}/OptionsEditorTabs/index.js +0 -0
  213. /package/dist/cjs/{src/components → components}/PanelSpecEditor/PanelSpecEditor.js +0 -0
  214. /package/dist/cjs/{src/components → components}/PanelSpecEditor/index.js +0 -0
  215. /package/dist/cjs/{src/components → components}/PluginEditor/PluginEditor.js +0 -0
  216. /package/dist/cjs/{src/components → components}/PluginEditor/index.js +0 -0
  217. /package/dist/cjs/{src/components → components}/PluginEditor/plugin-editor-api.js +0 -0
  218. /package/dist/cjs/{src/components → components}/PluginKindSelect/PluginKindSelect.js +0 -0
  219. /package/dist/cjs/{src/components → components}/PluginKindSelect/index.js +0 -0
  220. /package/dist/cjs/{src/components → components}/PluginRegistry/PluginRegistry.js +0 -0
  221. /package/dist/cjs/{src/components → components}/PluginRegistry/index.js +0 -0
  222. /package/dist/cjs/{src/components → components}/PluginRegistry/plugin-indexes.js +0 -0
  223. /package/dist/cjs/{src/components → components}/PluginSpecEditor/PluginSpecEditor.js +0 -0
  224. /package/dist/cjs/{src/components → components}/PluginSpecEditor/index.js +0 -0
  225. /package/dist/cjs/{src/components → components}/ProjectSelect.js +0 -0
  226. /package/dist/cjs/{src/components → components}/TimeRangeControls/TimeRangeControls.js +0 -0
  227. /package/dist/cjs/{src/components → components}/TimeRangeControls/index.js +0 -0
  228. /package/dist/cjs/{src/components → components}/Variables/VariableEditorForm/VariableEditorForm.js +0 -0
  229. /package/dist/cjs/{src/components → components}/Variables/VariableEditorForm/VariablePreview.js +0 -0
  230. /package/dist/cjs/{src/components → components}/Variables/VariableEditorForm/index.js +0 -0
  231. /package/dist/cjs/{src/components → components}/Variables/VariableEditorForm/variable-editor-form-model.js +0 -0
  232. /package/dist/cjs/{src/components → components}/Variables/index.js +0 -0
  233. /package/dist/cjs/{src/components → components}/Variables/variable-model.js +0 -0
  234. /package/dist/cjs/{src/components → components}/index.js +0 -0
  235. /package/dist/cjs/{src/constants → constants}/index.js +0 -0
  236. /package/dist/cjs/{src/constants → constants}/user-interface-text.js +0 -0
  237. /package/dist/cjs/{src/context → context}/ProjectStoreProvider.js +0 -0
  238. /package/dist/cjs/{src/context → context}/ValidationProvider.js +0 -0
  239. /package/dist/cjs/{src/context → context}/index.js +0 -0
  240. /package/dist/cjs/{src/context → context}/query-params.js +0 -0
  241. /package/dist/cjs/{src/index.js → index.js} +0 -0
  242. /package/dist/cjs/{src/model → model}/datasource.js +0 -0
  243. /package/dist/cjs/{src/model → model}/explore.js +0 -0
  244. /package/dist/cjs/{src/model → model}/index.js +0 -0
  245. /package/dist/cjs/{src/model → model}/legend.js +0 -0
  246. /package/dist/cjs/{src/model → model}/panels.js +0 -0
  247. /package/dist/cjs/{src/model → model}/plugin-base.js +0 -0
  248. /package/dist/cjs/{src/model → model}/plugin-loading.js +0 -0
  249. /package/dist/cjs/{src/model → model}/plugins.js +0 -0
  250. /package/dist/cjs/{src/model → model}/profile-queries.js +0 -0
  251. /package/dist/cjs/{src/model → model}/time-series-queries.js +0 -0
  252. /package/dist/cjs/{src/model → model}/trace-queries.js +0 -0
  253. /package/dist/cjs/{src/model → model}/variables.js +0 -0
  254. /package/dist/cjs/{src/remote → remote}/PersesPlugin.types.js +0 -0
  255. /package/dist/cjs/{src/remote → remote}/PluginLoaderComponent.js +0 -0
  256. /package/dist/cjs/{src/remote → remote}/PluginRuntime.js +0 -0
  257. /package/dist/cjs/{src/remote → remote}/index.js +0 -0
  258. /package/dist/cjs/{src/remote → remote}/remotePluginLoader.js +0 -0
  259. /package/dist/cjs/{src/runtime → runtime}/DataQueriesProvider/DataQueriesProvider.js +0 -0
  260. /package/dist/cjs/{src/runtime → runtime}/DataQueriesProvider/index.js +0 -0
  261. /package/dist/cjs/{src/runtime → runtime}/DataQueriesProvider/model.js +0 -0
  262. /package/dist/cjs/{src/runtime → runtime}/QueryCountProvider.js +0 -0
  263. /package/dist/cjs/{src/runtime → runtime}/RouterProvider.js +0 -0
  264. /package/dist/cjs/{src/runtime → runtime}/TimeRangeProvider/TimeRangeProvider.js +0 -0
  265. /package/dist/cjs/{src/runtime → runtime}/TimeRangeProvider/TimeRangeProviderWithQueryParams.js +0 -0
  266. /package/dist/cjs/{src/runtime → runtime}/TimeRangeProvider/TimeRangeSettingsProvider.js +0 -0
  267. /package/dist/cjs/{src/runtime → runtime}/TimeRangeProvider/index.js +0 -0
  268. /package/dist/cjs/{src/runtime → runtime}/TimeRangeProvider/query-params.js +0 -0
  269. /package/dist/cjs/{src/runtime → runtime}/TimeRangeProvider/refresh-interval.js +0 -0
  270. /package/dist/cjs/{src/runtime → runtime}/UsageMetricsProvider.js +0 -0
  271. /package/dist/cjs/{src/runtime → runtime}/builtin-variables.js +0 -0
  272. /package/dist/cjs/{src/runtime → runtime}/datasources.js +0 -0
  273. /package/dist/cjs/{src/runtime → runtime}/index.js +0 -0
  274. /package/dist/cjs/{src/runtime → runtime}/plugin-registry.js +0 -0
  275. /package/dist/cjs/{src/runtime → runtime}/profile-queries.js +0 -0
  276. /package/dist/cjs/{src/runtime → runtime}/time-series-queries.js +0 -0
  277. /package/dist/cjs/{src/runtime → runtime}/trace-queries.js +0 -0
  278. /package/dist/cjs/{src/runtime → runtime}/utils.js +0 -0
  279. /package/dist/cjs/{src/runtime → runtime}/variables.js +0 -0
  280. /package/dist/cjs/{src/test → test}/index.js +0 -0
  281. /package/dist/cjs/{src/test → test}/mock-data.js +0 -0
  282. /package/dist/cjs/{src/test → test}/render-hook.js +0 -0
  283. /package/dist/cjs/{src/test → test}/render.js +0 -0
  284. /package/dist/cjs/{src/test → test}/setup-tests.js +0 -0
  285. /package/dist/cjs/{src/test → test}/test-plugins/bert/index.js +0 -0
  286. /package/dist/cjs/{src/test → test}/test-plugins/ernie/index.js +0 -0
  287. /package/dist/cjs/{src/test → test}/test-plugins/index.js +0 -0
  288. /package/dist/cjs/{src/test → test}/utils.js +0 -0
  289. /package/dist/cjs/{src/test-utils → test-utils}/index.js +0 -0
  290. /package/dist/cjs/{src/test-utils → test-utils}/mock-plugin-registry.js +0 -0
  291. /package/dist/cjs/{src/utils → utils}/action.js +0 -0
  292. /package/dist/cjs/{src/utils → utils}/index.js +0 -0
  293. /package/dist/cjs/{src/utils → utils}/variables.js +0 -0
  294. /package/dist/{src/components → components}/CalculationSelector/CalculationSelector.js +0 -0
  295. /package/dist/{src/components → components}/CalculationSelector/index.js +0 -0
  296. /package/dist/{src/components → components}/DatasourceEditorForm/DatasourceEditorForm.js +0 -0
  297. /package/dist/{src/components → components}/DatasourceEditorForm/index.js +0 -0
  298. /package/dist/{src/components → components}/DatasourceSelect.js +0 -0
  299. /package/dist/{src/components → components}/HTTPSettingsEditor/HTTPSettingsEditor.js +0 -0
  300. /package/dist/{src/components → components}/HTTPSettingsEditor/index.js +0 -0
  301. /package/dist/{src/components → components}/LegendOptionsEditor/LegendOptionsEditor.js +0 -0
  302. /package/dist/{src/components → components}/LegendOptionsEditor/index.js +0 -0
  303. /package/dist/{src/components → components}/MetricLabelInput/MetricLabelInput.js +0 -0
  304. /package/dist/{src/components → components}/MetricLabelInput/index.js +0 -0
  305. /package/dist/{src/components → components}/MultiQueryEditor/MultiQueryEditor.js +0 -0
  306. /package/dist/{src/components → components}/MultiQueryEditor/QueryEditorContainer.js +0 -0
  307. /package/dist/{src/components → components}/MultiQueryEditor/index.js +0 -0
  308. /package/dist/{src/components → components}/OptionsEditorRadios/OptionsEditorRadios.js +0 -0
  309. /package/dist/{src/components → components}/OptionsEditorRadios/index.js +0 -0
  310. /package/dist/{src/components → components}/OptionsEditorTabPanel/OptionsEditorTabPanel.js +0 -0
  311. /package/dist/{src/components → components}/OptionsEditorTabPanel/index.js +0 -0
  312. /package/dist/{src/components → components}/OptionsEditorTabs/OptionsEditorTabs.js +0 -0
  313. /package/dist/{src/components → components}/OptionsEditorTabs/index.js +0 -0
  314. /package/dist/{src/components → components}/PanelSpecEditor/PanelSpecEditor.js +0 -0
  315. /package/dist/{src/components → components}/PanelSpecEditor/index.js +0 -0
  316. /package/dist/{src/components → components}/PluginEditor/PluginEditor.js +0 -0
  317. /package/dist/{src/components → components}/PluginEditor/index.js +0 -0
  318. /package/dist/{src/components → components}/PluginEditor/plugin-editor-api.js +0 -0
  319. /package/dist/{src/components → components}/PluginKindSelect/PluginKindSelect.js +0 -0
  320. /package/dist/{src/components → components}/PluginKindSelect/index.js +0 -0
  321. /package/dist/{src/components → components}/PluginRegistry/PluginRegistry.js +0 -0
  322. /package/dist/{src/components → components}/PluginRegistry/index.js +0 -0
  323. /package/dist/{src/components → components}/PluginRegistry/plugin-indexes.js +0 -0
  324. /package/dist/{src/components → components}/PluginSpecEditor/PluginSpecEditor.js +0 -0
  325. /package/dist/{src/components → components}/PluginSpecEditor/index.js +0 -0
  326. /package/dist/{src/components → components}/ProjectSelect.js +0 -0
  327. /package/dist/{src/components → components}/TimeRangeControls/TimeRangeControls.js +0 -0
  328. /package/dist/{src/components → components}/TimeRangeControls/index.js +0 -0
  329. /package/dist/{src/components → components}/Variables/VariableEditorForm/VariableEditorForm.js +0 -0
  330. /package/dist/{src/components → components}/Variables/VariableEditorForm/VariablePreview.js +0 -0
  331. /package/dist/{src/components → components}/Variables/VariableEditorForm/index.js +0 -0
  332. /package/dist/{src/components → components}/Variables/VariableEditorForm/variable-editor-form-model.js +0 -0
  333. /package/dist/{src/components → components}/Variables/index.js +0 -0
  334. /package/dist/{src/components → components}/Variables/variable-model.js +0 -0
  335. /package/dist/{src/components → components}/index.js +0 -0
  336. /package/dist/{src/constants → constants}/index.js +0 -0
  337. /package/dist/{src/constants → constants}/user-interface-text.js +0 -0
  338. /package/dist/{src/context → context}/ProjectStoreProvider.js +0 -0
  339. /package/dist/{src/context → context}/ValidationProvider.js +0 -0
  340. /package/dist/{src/context → context}/index.js +0 -0
  341. /package/dist/{src/context → context}/query-params.js +0 -0
  342. /package/dist/{src/index.js → index.js} +0 -0
  343. /package/dist/{src/model → model}/datasource.js +0 -0
  344. /package/dist/{src/model → model}/explore.js +0 -0
  345. /package/dist/{src/model → model}/index.js +0 -0
  346. /package/dist/{src/model → model}/legend.js +0 -0
  347. /package/dist/{src/model → model}/panels.js +0 -0
  348. /package/dist/{src/model → model}/plugin-base.js +0 -0
  349. /package/dist/{src/model → model}/plugin-loading.js +0 -0
  350. /package/dist/{src/model → model}/plugins.js +0 -0
  351. /package/dist/{src/model → model}/profile-queries.js +0 -0
  352. /package/dist/{src/model → model}/time-series-queries.js +0 -0
  353. /package/dist/{src/model → model}/trace-queries.js +0 -0
  354. /package/dist/{src/model → model}/variables.js +0 -0
  355. /package/dist/{src/remote → remote}/PersesPlugin.types.js +0 -0
  356. /package/dist/{src/remote → remote}/PluginLoaderComponent.js +0 -0
  357. /package/dist/{src/remote → remote}/PluginRuntime.js +0 -0
  358. /package/dist/{src/remote → remote}/index.js +0 -0
  359. /package/dist/{src/remote → remote}/remotePluginLoader.js +0 -0
  360. /package/dist/{src/runtime → runtime}/DataQueriesProvider/DataQueriesProvider.js +0 -0
  361. /package/dist/{src/runtime → runtime}/DataQueriesProvider/index.js +0 -0
  362. /package/dist/{src/runtime → runtime}/DataQueriesProvider/model.js +0 -0
  363. /package/dist/{src/runtime → runtime}/QueryCountProvider.js +0 -0
  364. /package/dist/{src/runtime → runtime}/RouterProvider.js +0 -0
  365. /package/dist/{src/runtime → runtime}/TimeRangeProvider/TimeRangeProvider.js +0 -0
  366. /package/dist/{src/runtime → runtime}/TimeRangeProvider/TimeRangeProviderWithQueryParams.js +0 -0
  367. /package/dist/{src/runtime → runtime}/TimeRangeProvider/TimeRangeSettingsProvider.js +0 -0
  368. /package/dist/{src/runtime → runtime}/TimeRangeProvider/index.js +0 -0
  369. /package/dist/{src/runtime → runtime}/TimeRangeProvider/query-params.js +0 -0
  370. /package/dist/{src/runtime → runtime}/TimeRangeProvider/refresh-interval.js +0 -0
  371. /package/dist/{src/runtime → runtime}/UsageMetricsProvider.js +0 -0
  372. /package/dist/{src/runtime → runtime}/builtin-variables.js +0 -0
  373. /package/dist/{src/runtime → runtime}/datasources.js +0 -0
  374. /package/dist/{src/runtime → runtime}/index.js +0 -0
  375. /package/dist/{src/runtime → runtime}/plugin-registry.js +0 -0
  376. /package/dist/{src/runtime → runtime}/profile-queries.js +0 -0
  377. /package/dist/{src/runtime → runtime}/time-series-queries.js +0 -0
  378. /package/dist/{src/runtime → runtime}/trace-queries.js +0 -0
  379. /package/dist/{src/runtime → runtime}/utils.js +0 -0
  380. /package/dist/{src/runtime → runtime}/variables.js +0 -0
  381. /package/dist/{src/test → test}/index.js +0 -0
  382. /package/dist/{src/test → test}/mock-data.js +0 -0
  383. /package/dist/{src/test → test}/render-hook.js +0 -0
  384. /package/dist/{src/test → test}/render.js +0 -0
  385. /package/dist/{src/test → test}/setup-tests.js +0 -0
  386. /package/dist/{src/test → test}/test-plugins/bert/index.js +0 -0
  387. /package/dist/{src/test → test}/test-plugins/ernie/index.js +0 -0
  388. /package/dist/{src/test → test}/test-plugins/index.js +0 -0
  389. /package/dist/{src/test → test}/utils.js +0 -0
  390. /package/dist/{src/test-utils → test-utils}/index.js +0 -0
  391. /package/dist/{src/test-utils → test-utils}/mock-plugin-registry.js +0 -0
  392. /package/dist/{src/utils → utils}/action.js +0 -0
  393. /package/dist/{src/utils → utils}/index.js +0 -0
  394. /package/dist/{src/utils → utils}/variables.js +0 -0
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/components/Variables/variable-model.ts"],"sourcesContent":["// Copyright 2024 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 { ListVariableDefinition } from '@perses-dev/core';\nimport { useQuery, UseQueryResult } from '@tanstack/react-query';\nimport { VariableOption } from '../../model';\nimport { useDatasourceStore, usePlugin, useTimeRange, useAllVariableValues, VariableStateMap } from '../../runtime';\n\nexport function filterVariableList(data: VariableOption[], capturedRegexp: RegExp): VariableOption[] {\n const result: VariableOption[] = [];\n const filteredSet = new Set<string>();\n for (const variableValue of data) {\n const matches = variableValue.value.matchAll(capturedRegexp);\n let concat = '';\n for (const match of matches) {\n for (let i = 1; i < match.length; i++) {\n const m = match[i];\n if (m !== undefined) {\n concat = `${concat}${m}`;\n }\n }\n }\n if (concat !== '' && !filteredSet.has(concat)) {\n // like that we are avoiding to have duplicating variable value\n filteredSet.add(concat);\n result.push({ label: variableValue.label, value: concat });\n }\n }\n return result;\n}\n\nexport function useListVariablePluginValues(definition: ListVariableDefinition): UseQueryResult<VariableOption[]> {\n const { data: variablePlugin } = usePlugin('Variable', definition.spec.plugin.kind);\n const datasourceStore = useDatasourceStore();\n const allVariables = useAllVariableValues();\n const { absoluteTimeRange: timeRange, refreshKey } = useTimeRange();\n\n const variablePluginCtx = { timeRange, datasourceStore, variables: allVariables };\n\n const spec = definition.spec.plugin.spec;\n const capturingRegexp =\n definition.spec.capturingRegexp !== undefined ? new RegExp(definition.spec.capturingRegexp, 'g') : undefined;\n\n let dependsOnVariables: string[] = Object.keys(allVariables); // Default to all variables\n if (variablePlugin?.dependsOn) {\n const dependencies = variablePlugin.dependsOn(spec, variablePluginCtx);\n dependsOnVariables = dependencies.variables ? dependencies.variables : dependsOnVariables;\n }\n // Exclude self variable to avoid circular dependency\n dependsOnVariables = dependsOnVariables.filter((v) => v !== definition.spec.name);\n\n const variables = useAllVariableValues(dependsOnVariables);\n\n let waitToLoad = false;\n if (dependsOnVariables) {\n waitToLoad = dependsOnVariables.some((v) => variables[v]?.loading);\n }\n\n const variablesValueKey = getVariableValuesKey(variables);\n\n return useQuery({\n queryKey: [definition, variablesValueKey, timeRange, refreshKey],\n queryFn: async () => {\n const resp = await variablePlugin?.getVariableOptions(spec, { datasourceStore, variables, timeRange });\n if (resp === undefined) {\n return [];\n }\n if (!capturingRegexp) {\n return resp.data;\n }\n return filterVariableList(resp.data, capturingRegexp);\n },\n enabled: !!variablePlugin || waitToLoad,\n });\n}\n\n/**\n * Returns a serialized string of the current state of variable values.\n */\nexport function getVariableValuesKey(v: VariableStateMap): string {\n return Object.values(v)\n .map((v) => JSON.stringify(v.value))\n .join(',');\n}\n\nexport const VARIABLE_TYPES = [\n { label: 'List', kind: 'ListVariable' },\n { label: 'Text', kind: 'TextVariable' },\n] as const;\n"],"names":["useQuery","useDatasourceStore","usePlugin","useTimeRange","useAllVariableValues","filterVariableList","data","capturedRegexp","result","filteredSet","Set","variableValue","matches","value","matchAll","concat","match","i","length","m","undefined","has","add","push","label","useListVariablePluginValues","definition","variablePlugin","spec","plugin","kind","datasourceStore","allVariables","absoluteTimeRange","timeRange","refreshKey","variablePluginCtx","variables","capturingRegexp","RegExp","dependsOnVariables","Object","keys","dependsOn","dependencies","filter","v","name","waitToLoad","some","loading","variablesValueKey","getVariableValuesKey","queryKey","queryFn","resp","getVariableOptions","enabled","values","map","JSON","stringify","join","VARIABLE_TYPES"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAGjC,SAASA,QAAQ,QAAwB,wBAAwB;AAEjE,SAASC,kBAAkB,EAAEC,SAAS,EAAEC,YAAY,EAAEC,oBAAoB,QAA0B,gBAAgB;AAEpH,OAAO,SAASC,mBAAmBC,IAAsB,EAAEC,cAAsB;IAC/E,MAAMC,SAA2B,EAAE;IACnC,MAAMC,cAAc,IAAIC;IACxB,KAAK,MAAMC,iBAAiBL,KAAM;QAChC,MAAMM,UAAUD,cAAcE,KAAK,CAACC,QAAQ,CAACP;QAC7C,IAAIQ,SAAS;QACb,KAAK,MAAMC,SAASJ,QAAS;YAC3B,IAAK,IAAIK,IAAI,GAAGA,IAAID,MAAME,MAAM,EAAED,IAAK;gBACrC,MAAME,IAAIH,KAAK,CAACC,EAAE;gBAClB,IAAIE,MAAMC,WAAW;o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IAE/C,OAAOrC,SAAS;QACdqD,UAAU;YAAC3B;YAAYyB;YAAmBjB;YAAWC;SAAW;QAChEmB,SAAS;YACP,MAAMC,OAAO,MAAM5B,gBAAgB6B,mBAAmB5B,MAAM;gBAAEG;gBAAiBM;gBAAWH;YAAU;YACpG,IAAIqB,SAASnC,WAAW;gBACtB,OAAO,EAAE;YACX;YACA,IAAI,CAACkB,iBAAiB;gBACpB,OAAOiB,KAAKjD,IAAI;YAClB;YACA,OAAOD,mBAAmBkD,KAAKjD,IAAI,EAAEgC;QACvC;QACAmB,SAAS,CAAC,CAAC9B,kBAAkBqB;IAC/B;AACF;AAEA;;CAEC,GACD,OAAO,SAASI,qBAAqBN,CAAmB;IACtD,OAAOL,OAAOiB,MAAM,CAACZ,GAClBa,GAAG,CAAC,CAACb,IAAMc,KAAKC,SAAS,CAACf,EAAEjC,KAAK,GACjCiD,IAAI,CAAC;AACV;AAEA,OAAO,MAAMC,iBAAiB;IAC5B;QAAEvC,OAAO;QAAQM,MAAM;IAAe;IACtC;QAAEN,OAAO;QAAQM,MAAM;IAAe;CACvC,CAAU"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/components/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 './CalculationSelector';\nexport * from './DatasourceEditorForm';\nexport * from './DatasourceSelect';\nexport * from './HTTPSettingsEditor';\nexport * from './LegendOptionsEditor';\nexport * from './MultiQueryEditor';\nexport * from './OptionsEditorRadios';\nexport * from './OptionsEditorTabs';\nexport * from './PanelSpecEditor';\nexport * from './PluginEditor';\nexport * from './PluginKindSelect';\nexport * from './PluginRegistry';\nexport * from './PluginSpecEditor';\nexport * from './TimeRangeControls';\nexport * from './Variables';\nexport * from './ProjectSelect';\nexport * from './MetricLabelInput';\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,yBAAyB;AACvC,cAAc,qBAAqB;AACnC,cAAc,uBAAuB;AACrC,cAAc,wBAAwB;AACtC,cAAc,qBAAqB;AACnC,cAAc,wBAAwB;AACtC,cAAc,sBAAsB;AACpC,cAAc,oBAAoB;AAClC,cAAc,iBAAiB;AAC/B,cAAc,qBAAqB;AACnC,cAAc,mBAAmB;AACjC,cAAc,qBAAqB;AACnC,cAAc,sBAAsB;AACpC,cAAc,cAAc;AAC5B,cAAc,kBAAkB;AAChC,cAAc,qBAAqB"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/constants/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 './user-interface-text';\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"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/constants/user-interface-text.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 const TOOLTIP_TEXT = {\n // Variable editor buttons\n refreshVariableValues: 'Refresh values',\n copyVariableValues: 'Copy values to clipboard',\n // Time range controls buttons\n refresh: 'Refresh',\n refreshInterval: 'Auto refresh interval',\n zoomIn: 'Zoom in',\n zoomOut: 'Zoom out',\n};\n"],"names":["TOOLTIP_TEXT","refreshVariableValues","copyVariableValues","refresh","refreshInterval","zoomIn","zoomOut"],"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,OAAO,MAAMA,eAAe;IAC1B,0BAA0B;IAC1BC,uBAAuB;IACvBC,oBAAoB;IACpB,8BAA8B;IAC9BC,SAAS;IACTC,iBAAiB;IACjBC,QAAQ;IACRC,SAAS;AACX,EAAE"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/context/ProjectStoreProvider.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 { useQuery, UseQueryResult } from '@tanstack/react-query';\nimport { ReactNode, createContext, useContext, useMemo, ReactElement } from 'react';\nimport { fetchJson, ProjectResource, StatusError } from '@perses-dev/core';\nimport { useSetProjectParams } from './query-params';\n\nexport interface ProjectStore {\n setProject: (project: ProjectResource) => void;\n project: ProjectResource;\n}\n\nexport interface ProjectStoreProviderProps {\n children?: ReactNode;\n enabledURLParams?: boolean;\n}\n\nexport const ProjectStoreContext = createContext<ProjectStore | undefined>(undefined);\n\nexport function useProjectList(): UseQueryResult<ProjectResource[], StatusError> {\n return useQuery<ProjectResource[], StatusError>({\n queryKey: ['projects'],\n queryFn: () => {\n return fetchJson<ProjectResource[]>('/api/v1/projects');\n },\n });\n}\n\nexport function useProjectStore(): ProjectStore {\n const ctx = useContext(ProjectStoreContext);\n if (ctx === undefined) {\n throw new Error('No ProjectStoreContext found. Did you forget a Provider?');\n }\n return ctx;\n}\n\nexport function ProjectStoreProvider(props: ProjectStoreProviderProps): ReactElement {\n const { children, enabledURLParams } = props;\n const { project, setProject } = useSetProjectParams(enabledURLParams);\n\n const contextValue = useMemo(\n () => ({\n project: {\n kind: 'Project',\n metadata: {\n name: project,\n },\n } as ProjectResource,\n setProject: (project: ProjectResource): void => {\n setProject(project.metadata.name);\n },\n }),\n [project, setProject]\n );\n\n return <ProjectStoreContext.Provider value={contextValue}>{children}</ProjectStoreContext.Provider>;\n}\n"],"names":["useQuery","createContext","useContext","useMemo","fetchJson","useSetProjectParams","ProjectStoreContext","undefined","useProjectList","queryKey","queryFn","useProjectStore","ctx","Error","ProjectStoreProvider","props","children","enabledURLParams","project","setProject","contextValue","kind","metadata","name","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,QAAQ,QAAwB,wBAAwB;AACjE,SAAoBC,aAAa,EAAEC,UAAU,EAAEC,OAAO,QAAsB,QAAQ;AACpF,SAASC,SAAS,QAAsC,mBAAmB;AAC3E,SAASC,mBAAmB,QAAQ,iBAAiB;AAYrD,OAAO,MAAMC,oCAAsBL,cAAwCM,WAAW;AAEtF,OAAO,SAASC;IACd,OAAOR,SAAyC;QAC9CS,UAAU;YAAC;SAAW;QACtBC,SAAS;YACP,OAAON,UAA6B;QACtC;IACF;AACF;AAEA,OAAO,SAASO;IACd,MAAMC,MAAMV,WAAWI;IACvB,IAAIM,QAAQL,WAAW;QACrB,MAAM,IAAIM,MAAM;IAClB;IACA,OAAOD;AACT;AAEA,OAAO,SAASE,qBAAqBC,KAAgC;IACnE,MAAM,EAAEC,QAAQ,EAAEC,gBAAgB,EAAE,GAAGF;IACvC,MAAM,EAAEG,OAAO,EAAEC,UAAU,EAAE,GAAGd,oBAAoBY;IAEpD,MAAMG,eAAejB,QACnB,IAAO,CAAA;YACLe,SAAS;gBACPG,MAAM;gBACNC,UAAU;oBACRC,MAAML;gBACR;YACF;YACAC,YAAY,CAACD;gBACXC,WAAWD,QAAQI,QAAQ,CAACC,IAAI;YAClC;QACF,CAAA,GACA;QAACL;QAASC;KAAW;IAGvB,qBAAO,KAACb,oBAAoBkB,QAAQ;QAACC,OAAOL;kBAAeJ;;AAC7D"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/context/ValidationProvider.tsx"],"sourcesContent":["// Copyright 2024 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { createContext, ReactElement, ReactNode, useContext, useState } from 'react';\nimport {\n DatasourceDefinition,\n PanelEditorValues,\n VariableDefinition,\n PluginSchema,\n datasourceDefinitionSchema,\n panelEditorSchema as defaultPanelEditorSchema,\n variableDefinitionSchema,\n buildDatasourceDefinitionSchema,\n buildPanelEditorSchema,\n buildVariableDefinitionSchema,\n} from '@perses-dev/core';\nimport { z } from 'zod';\n\nexport interface ValidationSchemas {\n datasourceEditorSchema: z.Schema<DatasourceDefinition>;\n panelEditorSchema: z.Schema<PanelEditorValues>;\n variableEditorSchema: z.Schema<VariableDefinition>;\n setDatasourceEditorSchemaPlugin: (pluginSchema: PluginSchema) => void;\n setPanelEditorSchemaPlugin: (pluginSchema: PluginSchema) => void;\n setVariableEditorSchemaPlugin: (pluginSchema: PluginSchema) => void;\n}\n\nexport const ValidationSchemasContext = createContext<ValidationSchemas | undefined>(undefined);\n\nexport function useValidationSchemas(): ValidationSchemas {\n const ctx = useContext(ValidationSchemasContext);\n if (ctx === undefined) {\n throw new Error('No ValidationSchemasContext found. Did you forget a Provider?');\n }\n return ctx;\n}\n\ninterface ValidationProviderProps {\n children: ReactNode;\n}\n\n/*\n * Provide validation schemas for forms handling plugins (datasources, variables, panels).\n */\nexport function ValidationProvider({ children }: ValidationProviderProps): ReactElement {\n const [datasourceEditorSchema, setDatasourceEditorSchema] =\n useState<z.Schema<DatasourceDefinition>>(datasourceDefinitionSchema);\n const [panelEditorSchema, setPanelEditorSchema] = useState<z.Schema<PanelEditorValues>>(defaultPanelEditorSchema);\n const [variableEditorSchema, setVariableEditorSchema] =\n useState<z.Schema<VariableDefinition>>(variableDefinitionSchema);\n\n function setDatasourceEditorSchemaPlugin(pluginSchema: PluginSchema): void {\n setDatasourceEditorSchema(buildDatasourceDefinitionSchema(pluginSchema));\n }\n\n function setPanelEditorSchemaPlugin(pluginSchema: PluginSchema): void {\n setPanelEditorSchema(buildPanelEditorSchema(pluginSchema));\n }\n\n function setVariableEditorSchemaPlugin(pluginSchema: PluginSchema): void {\n setVariableEditorSchema(buildVariableDefinitionSchema(pluginSchema));\n }\n\n return (\n <ValidationSchemasContext.Provider\n value={{\n datasourceEditorSchema,\n panelEditorSchema,\n variableEditorSchema,\n setDatasourceEditorSchemaPlugin,\n setPanelEditorSchemaPlugin,\n setVariableEditorSchemaPlugin,\n }}\n >\n {children}\n </ValidationSchemasContext.Provider>\n );\n}\n"],"names":["createContext","useContext","useState","datasourceDefinitionSchema","panelEditorSchema","defaultPanelEditorSchema","variableDefinitionSchema","buildDatasourceDefinitionSchema","buildPanelEditorSchema","buildVariableDefinitionSchema","ValidationSchemasContext","undefined","useValidationSchemas","ctx","Error","ValidationProvider","children","datasourceEditorSchema","setDatasourceEditorSchema","setPanelEditorSchema","variableEditorSchema","setVariableEditorSchema","setDatasourceEditorSchemaPlugin","pluginSchema","setPanelEditorSchemaPlugin","setVariableEditorSchemaPlugin","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,EAA2BC,UAAU,EAAEC,QAAQ,QAAQ,QAAQ;AACrF,SAKEC,0BAA0B,EAC1BC,qBAAqBC,wBAAwB,EAC7CC,wBAAwB,EACxBC,+BAA+B,EAC/BC,sBAAsB,EACtBC,6BAA6B,QACxB,mBAAmB;AAY1B,OAAO,MAAMC,yCAA2BV,cAA6CW,WAAW;AAEhG,OAAO,SAASC;IACd,MAAMC,MAAMZ,WAAWS;IACvB,IAAIG,QAAQF,WAAW;QACrB,MAAM,IAAIG,MAAM;IAClB;IACA,OAAOD;AACT;AAMA;;CAEC,GACD,OAAO,SAASE,mBAAmB,EAAEC,QAAQ,EAA2B;IACtE,MAAM,CAACC,wBAAwBC,0BAA0B,GACvDhB,SAAyCC;IAC3C,MAAM,CAACC,mBAAmBe,qBAAqB,GAAGjB,SAAsCG;IACxF,MAAM,CAACe,sBAAsBC,wBAAwB,GACnDnB,SAAuCI;IAEzC,SAASgB,gCAAgCC,YAA0B;QACjEL,0BAA0BX,gCAAgCgB;IAC5D;IAEA,SAASC,2BAA2BD,YAA0B;QAC5DJ,qBAAqBX,uBAAuBe;IAC9C;IAEA,SAASE,8BAA8BF,YAA0B;QAC/DF,wBAAwBZ,8BAA8Bc;IACxD;IAEA,qBACE,KAACb,yBAAyBgB,QAAQ;QAChCC,OAAO;YACLV;YACAb;YACAgB;YACAE;YACAE;YACAC;QACF;kBAECT;;AAGP"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/context/query-params.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 { useCallback, useState } from 'react';\nimport { useQueryParams } from 'use-query-params';\n\nexport function useSetProjectParams(enabledURLParams = true): {\n project: string;\n setProject: (project: string) => void;\n} {\n const [query, setQuery] = useQueryParams({ project: '' }, { updateType: 'replaceIn' });\n\n const [projectState, setProjectState] = useState<string>('none');\n\n const setProject = useCallback(\n (project: string) => {\n return setQuery({ project });\n },\n [setQuery]\n );\n\n if (enabledURLParams) {\n return {\n project: query.project || 'none',\n setProject,\n };\n }\n\n return {\n project: projectState,\n setProject: setProjectState,\n };\n}\n"],"names":["useCallback","useState","useQueryParams","useSetProjectParams","enabledURLParams","query","setQuery","project","updateType","projectState","setProjectState","setProject"],"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,WAAW,EAAEC,QAAQ,QAAQ,QAAQ;AAC9C,SAASC,cAAc,QAAQ,mBAAmB;AAElD,OAAO,SAASC,oBAAoBC,mBAAmB,IAAI;IAIzD,MAAM,CAACC,OAAOC,SAAS,GAAGJ,eAAe;QAAEK,SAAS;IAAG,GAAG;QAAEC,YAAY;IAAY;IAEpF,MAAM,CAACC,cAAcC,gBAAgB,GAAGT,SAAiB;IAEzD,MAAMU,aAAaX,YACjB,CAACO;QACC,OAAOD,SAAS;YAAEC;QAAQ;IAC5B,GACA;QAACD;KAAS;IAGZ,IAAIF,kBAAkB;QACpB,OAAO;YACLG,SAASF,MAAME,OAAO,IAAI;YAC1BI;QACF;IACF;IAEA,OAAO;QACLJ,SAASE;QACTE,YAAYD;IACd;AACF"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/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 './components';\nexport * from './constants';\nexport * from './model';\nexport * from './runtime';\nexport * from './test-utils';\nexport * from './utils';\nexport * from './context';\nexport * from './remote';\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,eAAe;AAC7B,cAAc,cAAc;AAC5B,cAAc,UAAU;AACxB,cAAc,YAAY;AAC1B,cAAc,eAAe;AAC7B,cAAc,UAAU;AACxB,cAAc,YAAY;AAC1B,cAAc,WAAW"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/model/datasource.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 { BuiltinVariableDefinition, UnknownSpec } from '@perses-dev/core';\nimport { Plugin } from './plugin-base';\n\n/**\n * Plugin that defines options for an external system that Perses talks to for data.\n */\nexport interface DatasourcePlugin<Spec = UnknownSpec, Client = unknown> extends Plugin<Spec> {\n createClient: (spec: Spec, options: DatasourceClientOptions) => Client;\n // Provide builtin variable definitions available on the datasource. Optional\n getBuiltinVariableDefinitions?: () => BuiltinVariableDefinition[];\n}\n\nexport interface DatasourceClientOptions {\n proxyUrl?: string;\n}\n\n/**\n * Common properties for all clients\n */\nexport interface DatasourceClient {\n // TODO: set kind and define healthCheck function\n kind?: string;\n healthCheck?: () => Promise<boolean>;\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;AAkBjC;;CAEC,GACD,WAIC"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/model/explore.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 { UnknownSpec } from '@perses-dev/core';\nimport { Plugin } from './plugin-base';\n\nexport interface ExploreComponentProps<Spec> {\n spec: Spec;\n}\n\n/**\n * Plugin that defines options for an external system that Perses talks to for data.\n */\nexport interface ExplorePlugin<Spec = UnknownSpec> extends Plugin<Spec> {\n ExploreComponent: React.ComponentType<ExploreComponentProps<Spec>>;\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;AASjC;;CAEC,GACD,WAEC"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/model/index.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './datasource';\nexport * from './legend';\nexport * from './panels';\nexport * from './plugins';\nexport * from './plugin-base';\nexport * from './plugin-loading';\nexport * from './time-series-queries';\nexport * from './trace-queries';\nexport * from './profile-queries';\nexport * from './variables';\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,eAAe;AAC7B,cAAc,WAAW;AACzB,cAAc,WAAW;AACzB,cAAc,YAAY;AAC1B,cAAc,gBAAgB;AAC9B,cAAc,mBAAmB;AACjC,cAAc,wBAAwB;AACtC,cAAc,kBAAkB;AAChC,cAAc,oBAAoB;AAClC,cAAc,cAAc"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/model/legend.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 {\n CALCULATIONS_CONFIG,\n CalculationType,\n LegendMode,\n LegendOptionsBase,\n LegendPositions,\n isValidLegendMode,\n isValidLegendPosition,\n LegendSize,\n isValidLegendSize,\n} from '@perses-dev/core';\n\n// This file contains legend-related model code specific to panel plugin specs.\n// See the `core` package for common/shared legend model code and the\n// `components` package for legend model code specific to the Legend component.\n\n// Explicity listing the calculations we intend to use for legend values because\n// we want them ordered in a specific way, and it may be possible in the future\n// that we only use a subset of calculations for the legend because the calculations\n// are also used by other features.\nexport const legendValues: CalculationType[] = [\n 'mean',\n 'first',\n 'first-number',\n 'last',\n 'last-number',\n 'min',\n 'max',\n 'sum',\n];\nexport type LegendValue = (typeof legendValues)[number];\n\nexport type ComparisonValues = 'abs' | 'relative';\n\nexport const comparisonLegends: Record<ComparisonValues, LegendSingleSelectConfig> = {\n abs: { label: 'Absolute', description: 'Absolute value' },\n relative: { label: 'Relative', description: 'Relative value' },\n};\n\n// Note: explicitly defining different options for the legend spec and\n// legend component that extend from some common options, so we can allow the\n// component and the spec to diverge in some upcoming work.\nexport interface LegendSpecOptions extends LegendOptionsBase {\n values?: Array<LegendValue | ComparisonValues>;\n}\n\nexport type LegendSingleSelectConfig = {\n label: string;\n description?: string;\n};\n\nexport const LEGEND_POSITIONS_CONFIG: Readonly<Record<LegendPositions, LegendSingleSelectConfig>> = {\n bottom: { label: 'Bottom' },\n right: { label: 'Right' },\n};\n\nexport const LEGEND_MODE_CONFIG: Readonly<Record<LegendMode, LegendSingleSelectConfig>> = {\n list: { label: 'List' },\n table: { label: 'Table' },\n};\n\nexport const LEGEND_SIZE_CONFIG: Readonly<Record<LegendSize, LegendSingleSelectConfig>> = {\n small: { label: 'Small' },\n medium: { label: 'Medium' },\n};\n\nexport const LEGEND_VALUE_CONFIG = legendValues.reduce(\n (config, value) => {\n config[value] = CALCULATIONS_CONFIG[value];\n\n return config;\n },\n {} as Partial<Record<LegendValue, LegendSingleSelectConfig>>\n);\n\nexport function validateLegendSpec(legend?: LegendOptionsBase): boolean {\n if (legend === undefined) {\n // undefined is valid since this is how legend is hidden by default\n return true;\n }\n if (!isValidLegendPosition(legend.position)) {\n return false;\n }\n if (legend.mode && !isValidLegendMode(legend.mode)) {\n return false;\n }\n if (legend.size && !isValidLegendSize(legend.size)) {\n return false;\n }\n\n return true;\n}\n"],"names":["CALCULATIONS_CONFIG","isValidLegendMode","isValidLegendPosition","isValidLegendSize","legendValues","comparisonLegends","abs","label","description","relative","LEGEND_POSITIONS_CONFIG","bottom","right","LEGEND_MODE_CONFIG","list","table","LEGEND_SIZE_CONFIG","small","medium","LEGEND_VALUE_CONFIG","reduce","config","value","validateLegendSpec","legend","undefined","position","mode","size"],"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,SACEA,mBAAmB,EAKnBC,iBAAiB,EACjBC,qBAA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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 from 'react';\nimport { UnknownSpec, PanelDefinition, QueryPluginType, QueryDataType, QueryDefinition } from '@perses-dev/core';\nimport { OptionsEditorTab } from '../components';\nimport { QueryOptions } from '../runtime';\nimport { OptionsEditorProps, Plugin } from './plugin-base';\n\nexport type PanelOptionsEditorComponent<T> = Pick<OptionsEditorTab, 'label'> & {\n content: React.ComponentType<OptionsEditorProps<T>>;\n};\n\nexport type PanelAction<TPanelProps> = {\n component: React.ComponentType<TPanelProps>;\n location?: string; // 'header' or other available locations\n};\n\n/**\n * Plugin the provides custom visualizations inside a Panel.\n */\nexport interface PanelPlugin<Spec = UnknownSpec, TPanelProps = PanelProps<Spec>> extends Plugin<Spec> {\n PanelComponent: React.ComponentType<TPanelProps>;\n /**\n * React components for custom tabs\n */\n panelOptionsEditorComponents?: Array<PanelOptionsEditorComponent<Spec>>;\n /**\n * Show a custom React component when the query is loading.\n * Default: <LoadingOverlay />\n */\n LoadingComponent?: React.ComponentType<TPanelProps>;\n /**\n * List of query types supported by this panel.\n * @default [] (no query types supported) only relevant if hideQueryEditor is true\n */\n supportedQueryTypes?: QueryPluginType[];\n /**\n * Static options for the queries that will be executed.\n * Each {@link QueryPluginType} implementation can have its own options.\n * For example see {@link UseTimeSeriesQueryOptions} for time series queries.\n */\n queryOptions?: QueryOptions | ((spec: Spec) => QueryOptions);\n /**\n * If true, query editor will be hidden for panel plugin\n * @default false\n */\n hideQueryEditor?: boolean;\n /**\n * List of panel actions that will be rendered in the panel header\n */\n actions?: Array<PanelAction<TPanelProps>>;\n}\n\n/**\n * The props provided by Perses to a panel plugin's PanelComponent.\n */\nexport interface PanelProps<Spec, SupportedQueryTypes = QueryDataType> {\n spec: Spec;\n contentDimensions?: {\n width: number;\n height: number;\n };\n definition?: PanelDefinition;\n queryResults: Array<PanelData<SupportedQueryTypes>>;\n}\n\nexport interface PanelData<SupportedQueryTypes = QueryDataType> {\n definition: QueryDefinition;\n data: SupportedQueryTypes;\n}\n"],"names":["React"],"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,WAAW,QAAQ"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/model/plugin-base.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 { QueryDefinition } from '@perses-dev/core';\nimport React from 'react';\n\n/**\n * Base type of all plugin implementations.\n */\nexport interface Plugin<Spec> {\n /**\n * React component for editing the plugin's options in the UI.\n */\n OptionsEditorComponent?: React.ComponentType<OptionsEditorProps<Spec>>;\n\n /**\n * Callback for creating the initial options for the plugin.\n */\n createInitialOptions: () => Spec;\n}\n\n/**\n * Common props passed to options editor components.\n */\nexport interface OptionsEditorProps<Spec> {\n // TODO: These are temporary and may not actually make sense, so replace\n // with whatever makes sense as visual editing evolves\n value: Spec;\n onChange: (next: Spec) => void;\n isReadonly?: boolean;\n}\n\n/**\n * Common props passed to query editor component\n */\nexport interface QueryEditorProps<Spec> extends OptionsEditorProps<Spec> {\n queries: QueryDefinition[];\n}\n"],"names":["React"],"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"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/model/plugin-loading.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 { PluginModuleResource } from './plugins';\n\n/**\n * A component capable of loading the resource/metadata for all available plugins, then loading individual plugins for\n * those resources on-demand.\n */\nexport interface PluginLoader {\n getInstalledPlugins: () => Promise<PluginModuleResource[]>;\n importPluginModule: (resource: PluginModuleResource) => Promise<unknown>;\n}\n\n/**\n * The dynamic import for a single plugin resource.\n */\nexport interface DynamicImportPlugin {\n resource: PluginModuleResource;\n importPlugin(): Promise<unknown>;\n}\n\n/**\n * A PluginLoader for the common pattern in Perses where we eagerly import a plugin's resource file, and then lazy load\n * the plugin itself via a dynamic `import()` statement.\n */\nexport function dynamicImportPluginLoader(plugins: DynamicImportPlugin[]): PluginLoader {\n const importMap: Map<PluginModuleResource, DynamicImportPlugin['importPlugin']> = new Map(\n plugins.map((plugin) => [plugin.resource, plugin.importPlugin])\n );\n\n return {\n async getInstalledPlugins(): Promise<PluginModuleResource[]> {\n return Promise.resolve(Array.from(importMap.keys()));\n },\n importPluginModule(resource): Promise<unknown> {\n const importFn = importMap.get(resource);\n if (importFn === undefined) {\n throw new Error('Plugin not found');\n }\n return importFn();\n },\n };\n}\n"],"names":["dynamicImportPluginLoader","plugins","importMap","Map","map","plugin","resource","importPlugin","getInstalledPlugins","Promise","resolve","Array","from","keys","importPluginModule","importFn","get","undefined","Error"],"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;AAqBjC;;;CAGC,GACD,OAAO,SAASA,0BAA0BC,OAA8B;IACtE,MAAMC,YAA4E,IAAIC,IACpFF,QAAQG,GAAG,CAAC,CAACC,SAAW;YAACA,OAAOC,QAAQ;YAAED,OAAOE,YAAY;SAAC;IAGhE,OAAO;QACL,MAAMC;YACJ,OAAOC,QAAQC,OAAO,CAACC,MAAMC,IAAI,CAACV,UAAUW,IAAI;QAClD;QACAC,oBAAmBR,QAAQ;YACzB,MAAMS,WAAWb,UAAUc,GAAG,CAACV;YAC/B,IAAIS,aAAaE,WAAW;gBAC1B,MAAM,IAAIC,MAAM;YAClB;YACA,OAAOH;QACT;IACF;AACF"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/model/plugins.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 { UnknownSpec } from '@perses-dev/core';\nimport { DatasourcePlugin } from './datasource';\nimport { PanelPlugin } from './panels';\nimport { Plugin } from './plugin-base';\nimport { TimeSeriesQueryPlugin } from './time-series-queries';\nimport { TraceQueryPlugin } from './trace-queries';\nimport { ProfileQueryPlugin } from './profile-queries';\nimport { VariablePlugin } from './variables';\nimport { ExplorePlugin } from './explore';\n\nexport interface PluginModuleSpec {\n plugins: PluginMetadata[];\n}\n\nexport interface PluginMetadataWithModule extends PluginMetadata {\n module: PluginModuleMetadata;\n}\n\n/**\n * Metadata about an individual plugin that's part of a PluginModule.\n */\nexport interface PluginMetadata {\n kind: PluginType;\n spec: {\n name: string;\n display: {\n name: string;\n description?: string;\n };\n };\n}\n\n/**\n * Metadata about a module/package that contains plugins.\n */\nexport interface PluginModuleMetadata {\n name: string;\n version: string;\n}\n\n/**\n * Information about a module/package that contains plugins.\n */\nexport interface PluginModuleResource {\n kind: 'PluginModule';\n metadata: PluginModuleMetadata;\n spec: PluginModuleSpec;\n}\n\n/**\n * All supported plugin types. A plugin's implementation must extend from `Plugin<UnknownSpec>` to be considered a valid\n * `PluginType`.\n */\nexport type PluginType = {\n // Filter out implementations on SupportedPlugins that don't extend `Plugin<UnknownSpec>`\n [K in keyof SupportedPlugins]: SupportedPlugins[K] extends Plugin<UnknownSpec> ? K : never;\n}[keyof SupportedPlugins];\n\n/**\n * Map of plugin type key/string -> implementation type. Use Typescript module augmentation to extend the plugin system\n * with new plugin types.\n */\nexport interface SupportedPlugins {\n Variable: VariablePlugin;\n Panel: PanelPlugin;\n TimeSeriesQuery: TimeSeriesQueryPlugin;\n TraceQuery: TraceQueryPlugin;\n ProfileQuery: ProfileQueryPlugin;\n Datasource: DatasourcePlugin;\n Explore: ExplorePlugin;\n}\n\n/**\n * The implementation for a given plugin type.\n */\nexport type PluginImplementation<Type extends PluginType> = SupportedPlugins[Type];\n\n/**\n * Default plugin kinds by plugin type.\n */\ntype PluginKinds = Partial<Record<PluginType, string>>;\nexport type DefaultPluginKinds = Required<Pick<PluginKinds, 'TimeSeriesQuery'>> & Omit<PluginKinds, 'TimeSeriesQuery'>;\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;AAmFjC,WAAuH"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/model/profile-queries.ts"],"sourcesContent":["// Copyright 2025 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Query, QueryKey } from '@tanstack/react-query';\nimport { UnknownSpec, ProfileData, AbsoluteTimeRange } from '@perses-dev/core';\nimport { DatasourceStore } from '../runtime';\nimport { Plugin } from './plugin-base';\n\n/**\n * A plugin for running profile queries.\n */\nexport interface ProfileQueryPlugin<Spec = UnknownSpec> extends Plugin<Spec> {\n getProfileData: (spec: Spec, ctx: ProfileQueryContext) => Promise<ProfileData>;\n}\n\n/**\n * Context available to ProfileQuery plugins at runtime.\n */\nexport interface ProfileQueryContext {\n datasourceStore: DatasourceStore;\n absoluteTimeRange?: AbsoluteTimeRange;\n}\n\nexport type ProfileDataQuery = Query<ProfileData, unknown, ProfileData, QueryKey>;\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;AAsBjC,WAAkF"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/model/time-series-queries.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 { Query, QueryKey } from '@tanstack/react-query';\nimport { AbsoluteTimeRange, UnknownSpec, TimeSeriesData } from '@perses-dev/core';\nimport { DatasourceStore, VariableStateMap } from '../runtime';\nimport { Plugin } from './plugin-base';\n\n/**\n * An object containing all the dependencies of a TimeSeriesQuery.\n */\ntype TimeSeriesQueryPluginDependencies = {\n /**\n * Returns a list of variables name this time series query depends on.\n */\n variables?: string[];\n};\n\n/**\n * A plugin for running time series queries.\n */\nexport interface TimeSeriesQueryPlugin<Spec = UnknownSpec> extends Plugin<Spec> {\n getTimeSeriesData: (spec: Spec, ctx: TimeSeriesQueryContext) => Promise<TimeSeriesData>;\n\n dependsOn?: (spec: Spec, ctx: TimeSeriesQueryContext) => TimeSeriesQueryPluginDependencies;\n}\n\nexport type TimeSeriesQueryMode = 'instant' | 'range';\n\n/**\n * Context available to TimeSeriesQuery plugins at runtime.\n */\nexport interface TimeSeriesQueryContext {\n suggestedStepMs?: number;\n mode?: TimeSeriesQueryMode;\n timeRange: AbsoluteTimeRange;\n variableState: VariableStateMap;\n datasourceStore: DatasourceStore;\n refreshKey: string;\n}\n\nexport type TimeSeriesDataQuery = Query<TimeSeriesData, unknown, TimeSeriesData, QueryKey>;\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;AAwCjC,WAA2F"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/model/trace-queries.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 { Query, QueryKey } from '@tanstack/react-query';\nimport { UnknownSpec, TraceData, AbsoluteTimeRange } from '@perses-dev/core';\nimport { DatasourceStore, VariableStateMap } from '../runtime';\nimport { Plugin } from './plugin-base';\n\n/**\n * An object containing all the dependencies of a TraceQuery.\n */\ntype TraceQueryQueryPluginDependencies = {\n /**\n * Returns a list of variables name this trace query depends on.\n */\n variables?: string[];\n};\n\n/**\n * A plugin for running trace queries.\n */\nexport interface TraceQueryPlugin<Spec = UnknownSpec> extends Plugin<Spec> {\n getTraceData: (spec: Spec, ctx: TraceQueryContext) => Promise<TraceData>;\n dependsOn?: (spec: Spec, ctx: TraceQueryContext) => TraceQueryQueryPluginDependencies;\n}\n\n/**\n * Context available to TraceQuery plugins at runtime.\n */\nexport interface TraceQueryContext {\n datasourceStore: DatasourceStore;\n absoluteTimeRange?: AbsoluteTimeRange;\n variableState: VariableStateMap;\n}\n\nexport type TraceDataQuery = Query<TraceData, unknown, TraceData, QueryKey>;\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;AAkCjC,WAA4E"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/model/variables.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 { UnknownSpec, AbsoluteTimeRange } from '@perses-dev/core';\nimport { VariableStateMap, DatasourceStore } from '../runtime';\nimport { Plugin } from './plugin-base';\n\nexport type VariableOption = { label: string; value: string };\n\nexport interface GetVariableOptionsContext {\n variables: VariableStateMap;\n datasourceStore: DatasourceStore;\n timeRange: AbsoluteTimeRange;\n}\n\n/**\n * An object containing all the dependencies of a VariablePlugin.\n */\ntype VariablePluginDependencies = {\n /**\n * Returns a list of variables name this time series query depends on.\n */\n variables?: string[];\n};\n\n/**\n * Plugin for handling custom VariableDefinitions.\n */\nexport interface VariablePlugin<Spec = UnknownSpec> extends Plugin<Spec> {\n getVariableOptions: (definition: Spec, ctx: GetVariableOptionsContext) => Promise<{ data: VariableOption[] }>;\n\n /**\n * Returns a list of variables name this variable depends on. Used to optimize fetching\n */\n dependsOn?: (definition: Spec, ctx: GetVariableOptionsContext) => VariablePluginDependencies;\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;AAwBjC;;CAEC,GACD,WAOC"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/remote/PersesPlugin.types.ts"],"sourcesContent":["// Copyright 2024 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 interface PersesPlugin {\n name: string;\n moduleName: string;\n baseURL?: string;\n}\n\nexport type RemotePluginModule = Record<string, unknown>;\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;AAQjC,WAAyD"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/remote/PluginLoaderComponent.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/ban-ts-comment */\n// Copyright 2024 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 { useEffect, useRef, useState } from 'react';\nimport { PersesPlugin, RemotePluginModule } from './PersesPlugin.types';\nimport { usePluginRuntime } from './PluginRuntime';\n\ninterface PluginLoaderProps<P> {\n plugin: PersesPlugin;\n props?: P;\n field?: string;\n}\n\nfunction PluginContainer<P>({\n pluginFn,\n props,\n}: {\n pluginFn: (props: P | undefined) => JSX.Element;\n props: P | undefined;\n}): JSX.Element {\n return pluginFn(props);\n}\n\nexport function PluginLoaderComponent<P>({ plugin, props, field }: PluginLoaderProps<P>): JSX.Element | null {\n const { loadPlugin } = usePluginRuntime({ plugin });\n const [pluginModule, setPluginModule] = useState<RemotePluginModule | null>(null);\n const [error, setError] = useState<Error | null>(null);\n\n const name = `${plugin.moduleName}-${plugin.name}`;\n const previousPluginName = useRef<string>(name);\n\n useEffect(() => {\n previousPluginName.current = name;\n setError(null);\n\n loadPlugin()\n .then((module) => {\n setPluginModule(module);\n })\n .catch((error) => {\n setPluginModule(null);\n console.error(\n `PluginLoaderComponent: Error loading plugin ${plugin.name} from module ${plugin.moduleName}:`,\n error\n );\n setError(\n new Error(`PluginLoaderComponent: Error loading plugin ${plugin.name} from module ${plugin.moduleName}`)\n );\n });\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [name]);\n\n if (error) {\n throw error;\n }\n\n if (!pluginModule) {\n return null;\n }\n\n let pluginFunction = pluginModule[plugin.name];\n\n if (field && pluginFunction && typeof pluginFunction === 'object' && field in pluginFunction) {\n pluginFunction = (pluginFunction as Record<string, unknown>)[field];\n }\n\n if (!pluginFunction) {\n throw new Error(`PluginLoaderComponent: Plugin module ${plugin.moduleName} does not have a ${plugin.name} export`);\n }\n\n if (typeof pluginFunction !== 'function') {\n throw new Error(`PluginLoaderComponent: Plugin ${plugin.name} export is not a function`);\n }\n\n // make sure to re mount the plugin when changes, to avoid mismatch in hooks ordering when re rendering\n if (previousPluginName.current !== name) {\n return null;\n }\n\n return (\n <PluginContainer key={name} pluginFn={pluginFunction as (props: P | undefined) => JSX.Element} props={props} />\n );\n}\n"],"names":["useEffect","useRef","useState","usePluginRuntime","PluginContainer","pluginFn","props","PluginLoaderComponent","plugin","field","loadPlugin","pluginModule","setPluginModule","error","setError","name","moduleName","previousPluginName","current","then","module","catch","console","Error","pluginFunction"],"mappings":"AAAA,oDAAoD,GACpD,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,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,QAAQ;AAEpD,SAASC,gBAAgB,QAAQ,kBAAkB;AAQnD,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S,mBAAmB,YAAY;QACxC,MAAM,IAAID,MAAM,CAAC,8BAA8B,EAAEf,OAAOO,IAAI,CAAC,yBAAyB,CAAC;IACzF;IAEA,uGAAuG;IACvG,IAAIE,mBAAmBC,OAAO,KAAKH,MAAM;QACvC,OAAO;IACT;IAEA,qBACE,KAACX;QAA2BC,UAAUmB;QAAyDlB,OAAOA;OAAhFS;AAE1B"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/remote/PluginRuntime.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-require-imports */\n// Copyright 2024 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 { createInstance, ModuleFederation } from '@module-federation/enhanced/runtime';\n\nimport * as ReactQuery from '@tanstack/react-query';\nimport React from 'react';\nimport ReactDOM from 'react-dom';\nimport * as ReactHookForm from 'react-hook-form';\nimport * as ReactRouterDOM from 'react-router-dom';\nimport { PersesPlugin, RemotePluginModule } from './PersesPlugin.types';\n\nlet instance: ModuleFederation | null = null;\n\nconst getPluginRuntime = (): ModuleFederation => {\n if (instance === null) {\n const pluginRuntime = createInstance({\n name: '@perses/perses-ui-host',\n remotes: [], // all remotes are loaded dynamically\n shared: {\n react: {\n version: React.version,\n lib: () => React,\n shareConfig: {\n singleton: true,\n requiredVersion: `^${React.version}`,\n },\n },\n 'react-dom': {\n version: '18.3.1',\n lib: () => ReactDOM,\n shareConfig: {\n singleton: true,\n requiredVersion: `^18.3.1`,\n },\n },\n 'react-router-dom': {\n version: '6.26.0',\n lib: () => ReactRouterDOM,\n shareConfig: {\n singleton: true,\n requiredVersion: '^6.26.0',\n },\n },\n '@tanstack/react-query': {\n version: '4.39.1',\n lib: () => ReactQuery,\n shareConfig: {\n singleton: true,\n requiredVersion: '^4.39.1',\n },\n },\n 'react-hook-form': {\n version: '7.52.2',\n lib: () => ReactHookForm,\n shareConfig: {\n singleton: true,\n requiredVersion: '^7.52.2',\n },\n },\n echarts: {\n version: '5.5.0',\n lib: () => require('echarts'),\n shareConfig: {\n singleton: true,\n requiredVersion: '^5.5.0',\n },\n },\n '@perses-dev/core': {\n version: '0.51.0-rc.1',\n lib: () => require('@perses-dev/core'),\n shareConfig: {\n singleton: true,\n requiredVersion: '^0.51.0-rc.1',\n },\n },\n '@perses-dev/components': {\n version: '0.51.0-rc.1',\n lib: () => require('@perses-dev/components'),\n shareConfig: {\n singleton: true,\n requiredVersion: '^0.51.0-rc.1',\n },\n },\n '@perses-dev/plugin-system': {\n version: '0.51.0-rc.1',\n lib: () => require('@perses-dev/plugin-system'),\n shareConfig: {\n singleton: true,\n requiredVersion: '^0.51.0-rc.1',\n },\n },\n '@perses-dev/explore': {\n version: '0.51.0-rc.1',\n lib: () => require('@perses-dev/explore'),\n shareConfig: {\n singleton: true,\n requiredVersion: '^0.51.0-rc.1',\n },\n },\n '@perses-dev/dashboards': {\n version: '0.51.0-rc.1',\n lib: () => require('@perses-dev/dashboards'),\n shareConfig: {\n singleton: true,\n requiredVersion: '^0.51.0-rc.1',\n },\n },\n // Below are the shared modules that are used by the plugins, this can be part of the SDK\n 'date-fns': {\n version: '4.1.0',\n lib: () => require('date-fns'),\n shareConfig: {\n singleton: true,\n requiredVersion: '^4.1.0',\n },\n },\n 'date-fns-tz': {\n version: '3.2.0',\n lib: () => require('date-fns-tz'),\n shareConfig: {\n singleton: true,\n requiredVersion: '^3.2.0',\n },\n },\n lodash: {\n version: '4.17.21',\n lib: () => require('lodash'),\n shareConfig: {\n singleton: true,\n requiredVersion: '^4.17.21',\n },\n },\n '@emotion/react': {\n version: '11.11.3',\n lib: () => require('@emotion/react'),\n shareConfig: {\n singleton: true,\n requiredVersion: '^11.11.3',\n },\n },\n '@emotion/styled': {\n version: '11.11.0',\n lib: () => require('@emotion/styled'),\n shareConfig: {\n singleton: true,\n requiredVersion: '^11.11.0',\n },\n },\n '@hookform/resolvers/zod': {\n version: '3.3.4',\n lib: () => require('@hookform/resolvers/zod'),\n shareConfig: {\n singleton: true,\n requiredVersion: '^3.3.4',\n },\n },\n 'use-resize-observer': {\n version: '9.1.0',\n lib: () => require('use-resize-observer'),\n shareConfig: {\n singleton: true,\n requiredVersion: '^9.1.0',\n },\n },\n 'mdi-material-ui': {\n version: '7.4.0',\n lib: () => require('mdi-material-ui'),\n shareConfig: {\n singleton: true,\n requiredVersion: '^7.4.0',\n },\n },\n immer: {\n version: '10.1.1',\n lib: () => require('immer'),\n shareConfig: {\n singleton: true,\n requiredVersion: '^10.1.1',\n },\n },\n },\n });\n\n instance = pluginRuntime;\n\n return instance;\n }\n return instance;\n};\n\nconst registerRemote = (name: string, baseURL?: string): void => {\n const pluginRuntime = getPluginRuntime();\n const existingRemote = pluginRuntime.options.remotes.find((remote) => remote.name === name);\n if (!existingRemote) {\n const remoteEntryURL = baseURL ? `${baseURL}/${name}/mf-manifest.json` : `/plugins/${name}/mf-manifest.json`;\n pluginRuntime.registerRemotes([\n {\n name,\n entry: remoteEntryURL,\n alias: name,\n },\n ]);\n }\n};\n\nexport const loadPlugin = async (\n moduleName: string,\n pluginName: string,\n baseURL?: string\n): Promise<RemotePluginModule | null> => {\n registerRemote(moduleName, baseURL);\n\n const pluginRuntime = getPluginRuntime();\n\n return pluginRuntime.loadRemote<RemotePluginModule>(`${moduleName}/${pluginName}`);\n};\n\nexport function usePluginRuntime({ plugin }: { plugin: PersesPlugin }): {\n pluginRuntime: ModuleFederation;\n loadPlugin: () => Promise<RemotePluginModule | null>;\n} {\n return {\n pluginRuntime: getPluginRuntime(),\n loadPlugin: () => loadPlugin(plugin.moduleName, plugin.name, plugin.baseURL),\n };\n}\n"],"names":["createInstance","ReactQuery","React","ReactDOM","ReactHookForm","ReactRouterDOM","instance","getPluginRuntime","pluginRuntime","name","remotes","shared","react","version","lib","shareConfig","singleton","requiredVersion","echarts","require","lodash","immer","registerRemote","baseURL","existingRemote","options","find","remote","remoteEntryURL","registerRemotes","entry","alias","loadPlugin","moduleName","pluginName","loadRemote","usePluginRuntime","plugin"],"mappings":"AAAA,wDAAwD,GACxD,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,cAAc,QAA0B,sCAAsC;AAEvF,YAAYC,gBAAgB,wBAAwB;AACpD,OAAOC,WAAW,QAAQ;AAC1B,OAAOC,cAAc,YAAY;AACjC,YAAYC,mBAAmB,kBAAkB;AACjD,YAAYC,oBAAoB,mBAAmB;AAGnD,IAAIC,WAAoC;AAExC,MAAMC,mBAAmB;IACvB,IAAID,aAAa,MAAM;QACrB,MAAME,gBAAgBR,eAAe;YACnCS,MAAM;YACNC,SAAS,EAAE;YACXC,QAAQ;gBACNC,OAAO;oBACLC,SAASX,MAAMW,OAAO;oBACtBC,KAAK,IAAMZ;oBACXa,aAAa;wBACXC,WAAW;wBACXC,iBAAiB,CAAC,CAAC,EAAEf,MAAMW,OAAO,EAAE;oBACtC;gBACF;gBACA,aAAa;oBACXA,SAAS;oBACTC,KAAK,IAAMX;oBACXY,aAAa;wBACXC,WAAW;wBACXC,iBAAiB,CAAC,OAAO,CAAC;oBAC5B;gBACF;gBACA,oBAAoB;oBAClBJ,SAAS;oBACTC,KAAK,IAAMT;oBACXU,aAAa;wBACXC,WAAW;wBACXC,iBAAiB;oBACnB;gBACF;gBACA,yBAAyB;oBACvBJ,SAAS;oBACTC,KAAK,IAAMb;oBACXc,aAAa;wBACXC,WAAW;wBACXC,iBAAiB;oBACnB;gBACF;gBACA,mBAAmB;oBACjBJ,SAAS;oB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BAAiB,EAAEC,MAAM,EAA4B;IAInE,OAAO;QACL7B,eAAeD;QACfyB,YAAY,IAAMA,WAAWK,OAAOJ,UAAU,EAAEI,OAAO5B,IAAI,EAAE4B,OAAOd,OAAO;IAC7E;AACF"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/remote/remotePluginLoader.ts"],"sourcesContent":["// Copyright 2024 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 { PluginLoader, PluginMetadata, PluginModuleResource } from '@perses-dev/plugin-system';\nimport { RemotePluginModule } from './PersesPlugin.types';\nimport { loadPlugin } from './PluginRuntime';\n\nconst isPluginMetadata = (plugin: unknown): plugin is PluginMetadata => {\n return (\n typeof plugin === 'object' &&\n plugin !== null &&\n 'kind' in plugin &&\n 'spec' in plugin &&\n typeof plugin.spec === 'object' &&\n plugin.spec !== null &&\n 'name' in plugin.spec\n );\n};\n\nconst isPluginModuleResource = (pluginModule: unknown): pluginModule is PluginModuleResource => {\n return (\n typeof pluginModule === 'object' &&\n pluginModule !== null &&\n 'metadata' in pluginModule &&\n 'spec' in pluginModule &&\n typeof pluginModule.spec === 'object' &&\n pluginModule.spec !== null &&\n 'plugins' in pluginModule.spec &&\n Array.isArray(pluginModule.spec.plugins) &&\n pluginModule.spec.plugins.every(isPluginMetadata)\n );\n};\n\nexport const remotePluginLoader = (baseURL?: string): PluginLoader => {\n return {\n getInstalledPlugins: async (): Promise<PluginModuleResource[]> => {\n const pluginsResponse = await fetch(`${baseURL ? baseURL : ''}/api/v1/plugins`);\n\n const plugins = await pluginsResponse.json();\n\n let pluginModules: PluginModuleResource[] = [];\n\n if (Array.isArray(plugins)) {\n pluginModules = plugins.filter(isPluginModuleResource);\n } else {\n console.error('RemotePluginLoader: Error loading plugins, response is not an array');\n }\n\n if (!pluginModules.length) {\n console.error('RemotePluginLoader: No valid plugins found');\n }\n\n return pluginModules;\n },\n importPluginModule: async (resource): Promise<RemotePluginModule> => {\n const pluginModuleName = resource.metadata.name;\n\n const pluginModule: RemotePluginModule = {};\n\n for (const plugin of resource.spec.plugins) {\n const remotePluginModule = await loadPlugin(pluginModuleName, plugin.spec.name);\n\n const remotePlugin = remotePluginModule?.[plugin.spec.name];\n if (remotePlugin) {\n pluginModule[plugin.spec.name] = remotePlugin;\n } else {\n console.error(`RemotePluginLoader: Error loading plugin ${plugin.spec.name}`);\n }\n }\n\n return pluginModule;\n },\n };\n};\n"],"names":["loadPlugin","isPluginMetadata","plugin","spec","isPluginModuleResource","pluginModule","Array","isArray","plugins","every","remotePluginLoader","baseURL","getInstalledPlugins","pluginsResponse","fetch","json","pluginModules","filter","console","error","length","importPluginModule","resource","pluginModuleName","metadata","name","remotePluginModule","remotePlugin"],"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;AAIjC,SAASA,UAAU,QAAQ,kBAAkB;AAE7C,MAAMC,mBAAmB,CAACC;IACxB,OACE,OAAOA,WAAW,YAClBA,WAAW,QACX,UAAUA,UACV,UAAUA,UACV,OAAOA,OAAOC,IAAI,KAAK,YACvBD,OAAOC,IAAI,KAAK,QAChB,UAAUD,OAAOC,IAAI;AAEzB;AAEA,MAAMC,yBAAyB,CAACC;IAC9B,OACE,OAAOA,iBAAiB,YACxBA,iBAAiB,QACjB,cAAcA,gBACd,UAAUA,gBACV,OAAOA,aAAaF,IAAI,KAAK,YAC7BE,aAAaF,IAAI,KAAK,QACtB,aAAaE,aAAaF,IAAI,IAC9BG,MAAMC,OAAO,CAACF,aAAaF,IAAI,CAACK,OAAO,KACvCH,aAAaF,IAAI,CAACK,OAAO,CAACC,KAAK,CAACR;AAEpC;AAEA,OAAO,MAAMS,qBAAqB,CAACC;IACjC,OAAO;QACLC,qBAAqB;YACnB,MAAMC,kBAAkB,MAAMC,MAAM,GAAGH,UAAUA,UAAU,GAAG,eAAe,CAAC;YAE9E,MAAMH,UAAU,MAAMK,gBAAgBE,IAAI;YAE1C,IAAIC,gBAAwC,EAAE;YAE9C,IAAIV,MAAMC,OAAO,CAACC,UAAU;gBAC1BQ,gBAAgBR,QAAQS,MAAM,CAACb;YACjC,OAAO;gBACLc,QAAQC,KAAK,CAAC;YAChB;YAEA,IAAI,CAACH,cAAcI,MAAM,EAAE;gBACzBF,QAAQC,KAAK,CAAC;YAChB;YAEA,OAAOH;QACT;QACAK,oBAAoB,OAAOC;YACzB,MAAMC,mBAAmBD,SAASE,QAAQ,CAACC,IAAI;YAE/C,MAAMpB,eAAmC,CAAC;YAE1C,KAAK,MAAMH,UAAUoB,SAASnB,IAAI,CAACK,OAAO,CAAE;gBAC1C,MAAMkB,qBAAqB,MAAM1B,WAAWuB,kBAAkBrB,OAAOC,IAAI,CAACsB,IAAI;gBAE9E,MAAME,eAAeD,oBAAoB,CAACxB,OAAOC,IAAI,CAACsB,IAAI,CAAC;gBAC3D,IAAIE,cAAc;oBAChBtB,YAAY,CAACH,OAAOC,IAAI,CAACsB,IAAI,CAAC,GAAGE;gBACnC,OAAO;oBACLT,QAAQC,KAAK,CAAC,CAAC,yCAAyC,EAAEjB,OAAOC,IAAI,CAACsB,IAAI,EAAE;gBAC9E;YACF;YAEA,OAAOpB;QACT;IACF;AACF,EAAE"}
@@ -1 +0,0 @@
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, ReactElement, useCallback, useContext, useMemo } from 'react';\nimport { QueryType, TimeSeriesQueryDefinition } from '@perses-dev/core';\nimport { useTimeSeriesQueries } from '../time-series-queries';\nimport { useTraceQueries, TraceQueryDefinition } from '../trace-queries';\nimport { useProfileQueries, ProfileQueryDefinition } from '../profile-queries';\n\nimport { useUsageMetrics } from '../UsageMetricsProvider';\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(): DataQueriesContextType {\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): ReactElement {\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 const usageMetrics = useUsageMetrics();\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 const traceQueries = queryDefinitions.filter(\n (definition) => definition.kind === 'TraceQuery'\n ) as TraceQueryDefinition[];\n const traceResults = useTraceQueries(traceQueries);\n const profileQueries = queryDefinitions.filter(\n (definition) => definition.kind === 'ProfileQuery'\n ) as ProfileQueryDefinition[];\n const profileResults = useProfileQueries(profileQueries);\n\n const refetchAll = useCallback(() => {\n timeSeriesResults.forEach((result) => result.refetch());\n traceResults.forEach((result) => result.refetch());\n profileResults.forEach((result) => result.refetch());\n }, [timeSeriesResults, traceResults, profileResults]);\n\n const ctx = useMemo(() => {\n const mergedQueryResults = [\n ...transformQueryResults(timeSeriesResults, timeSeriesQueries),\n ...transformQueryResults(traceResults, traceQueries),\n ...transformQueryResults(profileResults, profileQueries),\n ];\n\n if (queryOptions?.enabled) {\n for (const result of mergedQueryResults) {\n if (!result.isLoading && !result.isFetching && !result.error) {\n usageMetrics.markQuery(result.definition, 'success');\n } else if (result.error) {\n usageMetrics.markQuery(result.definition, 'error');\n } else {\n usageMetrics.markQuery(result.definition, 'pending');\n }\n }\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 }, [\n timeSeriesQueries,\n timeSeriesResults,\n traceQueries,\n traceResults,\n profileQueries,\n profileResults,\n refetchAll,\n queryOptions?.enabled,\n usageMetrics,\n ]);\n\n return <DataQueriesContext.Provider value={ctx}>{children}</DataQueriesContext.Provider>;\n}\n"],"names":["createContext","useCallback","useContext","useMemo","useTimeSeriesQueries","useTraceQueries","useProfileQueries","useUsageMetrics","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","usageMetrics","timeSeriesQueries","timeSeriesResults","traceQueries","traceResults","profileQueries","profileResults","forEach","refetch","mergedQueryResults","enabled","error","markQuery","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,EAAgBC,WAAW,EAAEC,UAAU,EAAEC,OAAO,QAAQ,QAAQ;AAEtF,SAASC,oBAAoB,QAAQ,yBAAyB;AAC9D,SAASC,eAAe,QAA8B,mBAAmB;AACzE,SAASC,iBAAiB,QAAgC,qBAAqB;AAE/E,SAASC,eAAe,QAAQ,0BAA0B;AAC1D,SAGEC,qBAAqB,EAGrBC,YAAY,QACP,UAAU;AAEjB,OAAO,MAAMC,mCAAqBV,cAAkDW,WAAW;AAE/F,OAAO,SAASC;IACd,MAAMC,MAAMX,WAAWQ;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,YAAY,CAACC,MAAM,CAClD,CAACC,cAAgBA,aAAaC,YAAYC,SAASN;IAGr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O;QAC/CF,eAAeC,OAAO,CAAC,CAACtB,SAAWA,OAAOuB,OAAO;IACnD,GAAG;QAACN;QAAmBE;QAAcE;KAAe;IAEpD,MAAMrC,MAAMV,QAAQ;QAClB,MAAMkD,qBAAqB;eACtB7C,sBAAsBsC,mBAAmBD;eACzCrC,sBAAsBwC,cAAcD;eACpCvC,sBAAsB0C,gBAAgBD;SAC1C;QAED,IAAIZ,cAAciB,SAAS;YACzB,KAAK,MAAMzB,UAAUwB,mBAAoB;gBACvC,IAAI,CAACxB,OAAOC,SAAS,IAAI,CAACD,OAAOF,UAAU,IAAI,CAACE,OAAO0B,KAAK,EAAE;oBAC5DX,aAAaY,SAAS,CAAC3B,OAAOR,UAAU,EAAE;gBAC5C,OAAO,IAAIQ,OAAO0B,KAAK,EAAE;oBACvBX,aAAaY,SAAS,CAAC3B,OAAOR,UAAU,EAAE;gBAC5C,OAAO;oBACLuB,aAAaY,SAAS,CAAC3B,OAAOR,UAAU,EAAE;gBAC5C;YACF;QACF;QAEA,OAAO;YACLH,cAAcmC;YACd1B,YAAY0B,mBAAmBzB,IAAI,CAAC,CAACC,SAAWA,OAAOF,UAAU;YACjEG,WAAWuB,mBAAmBzB,IAAI,CAAC,CAACC,SAAWA,OAAOC,SAAS;YAC/DC;YACAP,QAAQ6B,mBAAmBb,GAAG,CAAC,CAACX,SAAWA,OAAO0B,KAAK;QACzD;IACF,GAAG;QACDV;QACAC;QACAC;QACAC;QACAC;QACAC;QACAnB;QACAM,cAAciB;QACdV;KACD;IAED,qBAAO,KAAClC,mBAAmB+C,QAAQ;QAACC,OAAO7C;kBAAMuB;;AACnD"}
@@ -1 +0,0 @@
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 { ReactNode, useCallback, useMemo } from 'react';\nimport { useListPluginMetadata } from '../plugin-registry';\n\nexport type QueryOptions = Record<string, unknown>;\nexport interface DataQueriesProviderProps<QueryPluginSpec = UnknownSpec> {\n definitions: Array<Definition<QueryPluginSpec>>;\n children?: ReactNode;\n options?: QueryOptions;\n queryOptions?: Omit<QueryObserverOptions, 'queryKey'>;\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[]): QueryData[] {\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 } = useListPluginMetadata([\n 'TimeSeriesQuery',\n ]);\n const { data: traceQueryPlugins, isLoading: isTraceQueryPluginLoading } = useListPluginMetadata(['TraceQuery']);\n const { data: profileQueryPlugins, isLoading: isProfileQueryPluginLoading } = useListPluginMetadata(['ProfileQuery']);\n\n // For example, `map: {\"TimeSeriesQuery\":[\"PrometheusTimeSeriesQuery\"],\"TraceQuery\":[\"TempoTraceQuery\"]}`\n const queryTypeMap = useMemo(() => {\n const map: Record<string, string[]> = {\n TimeSeriesQuery: [],\n TraceQuery: [],\n ProfileQuery: [],\n };\n\n if (timeSeriesQueryPlugins) {\n timeSeriesQueryPlugins.forEach((plugin) => {\n map[plugin.kind]?.push(plugin.spec.name);\n });\n }\n\n if (traceQueryPlugins) {\n traceQueryPlugins.forEach((plugin) => {\n map[plugin.kind]?.push(plugin.spec.name);\n });\n }\n\n if (profileQueryPlugins) {\n profileQueryPlugins.forEach((plugin) => {\n map[plugin.kind]?.push(plugin.spec.name);\n });\n }\n return map;\n }, [timeSeriesQueryPlugins, traceQueryPlugins, profileQueryPlugins]);\n\n const getQueryType = useCallback(\n (pluginKind: string) => {\n const isLoading = (pluginKind: string): boolean => {\n switch (pluginKind) {\n case 'PrometheusTimeSeriesQuery':\n return isTimeSeriesQueryLoading;\n case 'TempoTraceQuery':\n return isTraceQueryPluginLoading;\n case 'PyroscopeProfileQuery':\n return isProfileQueryPluginLoading;\n }\n\n return isTraceQueryPluginLoading || isTimeSeriesQueryLoading || isProfileQueryPluginLoading;\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, isProfileQueryPluginLoading]\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","profileQueryPlugins","isProfileQueryPluginLoading","queryTypeMap","TimeSeriesQuery","TraceQuery","ProfileQuery","forEach","plugin","kind","push","spec","name","getQueryType","pluginKind","undefined","queryType","includes","Error"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AA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;YACvBA,oBAAoBM,OAAO,CAAC,CAACC;gBAC3BpB,GAAG,CAACoB,OAAOC,IAAI,CAAC,EAAEC,KAAKF,OAAOG,IAAI,CAACC,IAAI;YACzC;QACF;QACA,OAAOxB;IACT,GAAG;QAACS;QAAwBE;QAAmBE;KAAoB;IAEnE,MAAMY,eAAe/B,YACnB,CAACgC;QACC,MAAMvB,YAAY,CAACuB;YACjB,OAAQA;gBACN,KAAK;oBACH,OAAOhB;gBACT,KAAK;oBACH,OAAOE;gBACT,KAAK;oBACH,OAAOE;YACX;YAEA,OAAOF,6BAA6BF,4BAA4BI;QAClE;QAEA,IAAIX,UAAUuB,aAAa;YACzB,OAAOC;QACT;QAEA,IAAK,MAAMC,aAAab,aAAc;YACpC,IAAIA,YAAY,CAACa,UAAU,EAAEC,SAASH,aAAa;gBACjD,OAAOE;YACT;QACF;QAEA,MAAM,IAAIE,MAAM,CAAC,oCAAoC,EAAEJ,YAAY;IACrE,GACA;QAACX;QAAcL;QAA0BE;QAA2BE;KAA4B;IAGlG,OAAOW;AACT"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/runtime/QueryCountProvider.tsx"],"sourcesContent":["// Copyright 2024 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport React, { createContext, useContext, ReactNode } from 'react';\n\ninterface QueryCountProviderProps {\n queryCount: number;\n children: ReactNode;\n}\n\nconst QueryCountContext = createContext<number>(0);\n\nexport const QueryCountProvider: React.FC<QueryCountProviderProps> = ({ queryCount, children }) => {\n return <QueryCountContext.Provider value={queryCount}>{children}</QueryCountContext.Provider>;\n};\n\nexport const useQueryCountContext = (): number => {\n return useContext(QueryCountContext);\n};\n"],"names":["React","createContext","useContext","QueryCountContext","QueryCountProvider","queryCount","children","Provider","value","useQueryCountContext"],"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,UAAU,QAAmB,QAAQ;AAOpE,MAAMC,kCAAoBF,cAAsB;AAEhD,OAAO,MAAMG,qBAAwD,CAAC,EAAEC,UAAU,EAAEC,QAAQ,EAAE;IAC5F,qBAAO,KAACH,kBAAkBI,QAAQ;QAACC,OAAOH;kBAAaC;;AACzD,EAAE;AAEF,OAAO,MAAMG,uBAAuB;IAClC,OAAOP,WAAWC;AACpB,EAAE"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/runtime/RouterProvider.tsx"],"sourcesContent":["// Copyright 2025 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport React, { createContext, useContext, ReactNode, ReactElement, useMemo } from 'react';\nimport { Link as RouterLink, useNavigate } from 'react-router-dom';\n\ninterface LinkProps extends React.AnchorHTMLAttributes<HTMLAnchorElement> {\n to: string;\n}\n\nexport interface RouterContextType {\n RouterComponent: (props: LinkProps & React.RefAttributes<HTMLAnchorElement>) => ReactNode;\n navigate: (to: string) => void;\n}\n\nexport const RouterContext = createContext<RouterContextType | undefined>(undefined);\n\nexport function useRouterContext(): RouterContextType {\n const ctx = useContext(RouterContext);\n if (ctx === undefined) {\n throw new Error('No RouterContext found. Did you forget a <RouterProvider>?');\n }\n return ctx;\n}\n\ninterface RouterProviderProps {\n RouterComponent: RouterContextType['RouterComponent'];\n navigate: RouterContextType['navigate'];\n children?: React.ReactNode;\n}\n\n/**\n * Some panel plugins (TraceTable, ScatterPlot, TracingGanttChart) support linking to other pages,\n * e.g. clicking on a trace in the TraceTable should navigate to the TracingGanttChart.\n *\n * We can't use react-router in the panel, because panels might be embedded into React applications\n * which use a different routing library, or a different major version of react-router.\n *\n * This provider abstracts the basic routing functionality, to remove the dependency on the exact version of react-router.\n */\nexport function RouterProvider(props: RouterProviderProps): ReactElement {\n const { RouterComponent, navigate, children } = props;\n\n const ctx = useMemo(() => {\n return { RouterComponent, navigate };\n }, [RouterComponent, navigate]);\n\n return <RouterContext.Provider value={ctx}>{children}</RouterContext.Provider>;\n}\n\ninterface ReactRouterProviderProps {\n children?: React.ReactNode;\n}\n\n/** An implementation of RouterProvider for using the react-router library, shipped with Perses */\nexport function ReactRouterProvider(props: ReactRouterProviderProps): ReactElement {\n const { children } = props;\n const navigate = useNavigate();\n\n return (\n <RouterProvider RouterComponent={RouterLink} navigate={navigate}>\n {children}\n </RouterProvider>\n );\n}\n"],"names":["React","createContext","useContext","useMemo","Link","RouterLink","useNavigate","RouterContext","undefined","useRouterContext","ctx","Error","RouterProvider","props","RouterComponent","navigate","children","Provider","value","ReactRouterProvider"],"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,UAAU,EAA2BC,OAAO,QAAQ,QAAQ;AAC3F,SAASC,QAAQC,UAAU,EAAEC,WAAW,QAAQ,mBAAmB;AAWnE,OAAO,MAAMC,8BAAgBN,cAA6CO,WAAW;AAErF,OAAO,SAASC;IACd,MAAMC,MAAMR,WAAWK;IACvB,IAAIG,QAAQF,WAAW;QACrB,MAAM,IAAIG,MAAM;IAClB;IACA,OAAOD;AACT;AAQA;;;;;;;;CAQC,GACD,OAAO,SAASE,eAAeC,KAA0B;IACvD,MAAM,EAAEC,eAAe,EAAEC,QAAQ,EAAEC,QAAQ,EAAE,GAAGH;IAEhD,MAAMH,MAAMP,QAAQ;QAClB,OAAO;YAAEW;YAAiBC;QAAS;IACrC,GAAG;QAACD;QAAiBC;KAAS;IAE9B,qBAAO,KAACR,cAAcU,QAAQ;QAACC,OAAOR;kBAAMM;;AAC9C;AAMA,gGAAgG,GAChG,OAAO,SAASG,oBAAoBN,KAA+B;IACjE,MAAM,EAAEG,QAAQ,EAAE,GAAGH;IACrB,MAAME,WAAWT;IAEjB,qBACE,KAACM;QAAeE,iBAAiBT;QAAYU,UAAUA;kBACpDC;;AAGP"}
@@ -1 +0,0 @@
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, ReactElement, useCallback, useContext, useEffect, useMemo, useState } from 'react';\nimport {\n AbsoluteTimeRange,\n DurationString,\n TimeRangeValue,\n isRelativeTimeRange,\n toAbsoluteTimeRange,\n getSuggestedStepMs,\n} from '@perses-dev/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(): TimeRange {\n const ctx = useContext(TimeRangeContext);\n if (ctx === undefined) {\n throw new Error('No TimeRangeContext found. Did you forget a Provider?');\n }\n return ctx;\n}\n\n/**\n * Get and set the current resolved time range at runtime.\n */\nexport function useTimeRange(): TimeRange {\n return useTimeRangeContext();\n}\n\n/**\n * Gets the suggested step for a graph query in ms for the currently selected time range.\n */\nexport function useSuggestedStepMs(width?: number): number {\n const { absoluteTimeRange } = useTimeRange();\n if (width === undefined) return 0;\n return getSuggestedStepMs(absoluteTimeRange, width);\n}\n\n/**\n * Provider implementation that supplies the time range state at runtime.\n */\nexport function TimeRangeProvider(props: TimeRangeProviderProps): ReactElement {\n const { timeRange, refreshInterval, children, setTimeRange, setRefreshInterval } = props;\n\n const [localTimeRange, setLocalTimeRange] = useState<TimeRangeValue>(timeRange);\n const [localRefreshInterval, setLocalRefreshInterval] = useState<DurationString | undefined>(refreshInterval);\n\n const [refreshCounter, setRefreshCounter] = useState(0);\n\n useEffect(() => {\n setLocalTimeRange(timeRange);\n }, [timeRange, refreshCounter]);\n\n useEffect(() => {\n setLocalRefreshInterval(refreshInterval);\n }, [refreshInterval]);\n\n const refresh = useCallback(() => {\n setRefreshCounter((counter) => counter + 1);\n }, [setRefreshCounter]);\n\n const refreshIntervalInMs = getRefreshIntervalInMs(localRefreshInterval);\n useEffect(() => {\n if (refreshIntervalInMs > 0) {\n const interval = setInterval(() => {\n refresh();\n }, refreshIntervalInMs);\n\n return (): void => clearInterval(interval);\n }\n }, [refresh, refreshIntervalInMs]);\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: refreshIntervalInMs,\n setRefreshInterval: setRefreshInterval ?? setLocalRefreshInterval,\n };\n }, [\n localTimeRange,\n setTimeRange,\n refresh,\n localRefreshInterval,\n refreshCounter,\n refreshIntervalInMs,\n setRefreshInterval,\n ]);\n\n return <TimeRangeContext.Provider value={ctx}>{children}</TimeRangeContext.Provider>;\n}\n"],"names":["React","createContext","useCallback","useContext","useEffect","useMemo","useState","isRelativeTimeRange","toAbsoluteTimeRange","getSuggestedStepMs","getRefreshIntervalInMs","TimeRangeContext","undefined","useTimeRangeContext","ctx","Error","useTimeRange","useSuggestedStepMs","width","absoluteTimeRange","TimeRangeProvider","props","timeRange","refreshInterval","children","setTimeRange","setRefreshInterval","localTimeRange","setLocalTimeRange","localRefreshInterval","setLocalRefreshInterval","refreshCounter","setRefreshCounter","refresh","counter","refreshIntervalInMs","interval","setInterval","clearInterval","refreshKey","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,OAAOA,SAASC,aAAa,EAAgBC,WAAW,EAAEC,UAAU,EAAEC,SAAS,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,QAAQ;AAClH,SAIEC,mBAAmB,EACnBC,mBAAmB,EACnBC,kBAAkB,QACb,mBAAmB;AAC1B,SAASC,sBAAsB,QAAQ,qBAAqB;AAq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;YACAc;YACAM,YAAY,GAAGpB,kBAAkBqB,KAAK,CAAC,CAAC,EAAErB,kBAAkBsB,GAAG,CAAC,CAAC,EAAEZ,qBAAqB,CAAC,EAAEE,gBAAgB;YAC3GR,iBAAiBM;YACjBM,qBAAqBA;YACrBT,oBAAoBA,sBAAsBI;QAC5C;IACF,GAAG;QACDH;QACAF;QACAQ;QACAJ;QACAE;QACAI;QACAT;KACD;IAED,qBAAO,KAACf,iBAAiB+B,QAAQ;QAACC,OAAO7B;kBAAMU;;AACjD"}
@@ -1 +0,0 @@
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, { ReactElement } 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): ReactElement {\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,WAA6B,QAAQ;AAC5C,SAASC,iBAAiB,QAAQ,sBAAsB;AACxD,SAASC,2BAA2B,EAAEC,kBAAkB,QAAQ,iBAAiB;AAQjF,OAAO,SAASC,iCAAiCC,KAA8B;IAC7E,MAAM,EAAEC,gBAAgB,EAAEC,sBAAsB,EAAEC,QAAQ,EAAE,GAAGH;IAE/D,MAAM,EAAEI,SAAS,EAAEC,YAAY,EAAE,GAAGP,mBAAmBG;IACvD,MAAM,EAAEK,eAAe,EAAEC,kBAAkB,EAAE,GAAGV,4BAA4BK;IAE5E,qBACE,KAACN;QACCQ,WAAWA;QACXE,iBAAiBA;QACjBD,cAAcA;QACdE,oBAAoBA;kBAEnBJ;;AAGP"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/runtime/TimeRangeProvider/TimeRangeSettingsProvider.tsx"],"sourcesContent":["// Copyright 2024 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { createContext, ReactElement, ReactNode, useContext, useMemo } from 'react';\nimport { buildRelativeTimeOption, TimeOption } from '@perses-dev/components';\nimport { DurationString } from '@perses-dev/core';\n\nconst DEFAULT_OPTIONS: DurationString[] = ['5m', '15m', '30m', '1h', '6h', '12h', '24h', '7d', '14d'];\nconst defaultTimeRangeSettings: TimeRangeSettings = {\n showCustom: true,\n showZoomButtons: true,\n options: DEFAULT_OPTIONS.map((duration) => buildRelativeTimeOption(duration)),\n};\n\nexport interface TimeRangeSettingsProviderProps {\n showCustom?: boolean;\n showZoomButtons?: boolean;\n options?: TimeOption[];\n children: ReactNode;\n}\n\nexport interface TimeRangeSettings {\n showCustom: boolean;\n showZoomButtons: boolean;\n options: TimeOption[];\n}\n\nexport const TimeRangeSettingsContext = createContext<TimeRangeSettings>(defaultTimeRangeSettings);\n\nexport function useTimeRangeSettingsContext(): TimeRangeSettings {\n const ctx = useContext(TimeRangeSettingsContext);\n if (ctx === undefined) {\n throw new Error('No TimeRangeContext found. Did you forget a Provider?');\n }\n return ctx;\n}\n\n/**\n * Get and set the current resolved time range at runtime.\n */\nexport function useTimeRangeSettings(): TimeRangeSettings {\n return useTimeRangeSettingsContext();\n}\n\n/**\n * Get the current value of the showCustom setting.\n * @param override If set, the value of the provider will be overridden by this value.\n */\nexport function useShowCustomTimeRangeSetting(override?: boolean): boolean {\n const showCustomTimeRange = useTimeRangeSettings().showCustom;\n if (override !== undefined) {\n return override;\n }\n return showCustomTimeRange;\n}\n\n/**\n * Get the current value of the showZoomButtons setting.\n * @param override If set, the value of the provider will be overridden by this value.\n */\nexport function useShowZoomRangeSetting(override?: boolean): boolean {\n const showZoomTimeRange = useTimeRangeSettings().showZoomButtons;\n if (override !== undefined) {\n return override;\n }\n return showZoomTimeRange;\n}\n\n/**\n * Get the current value of the options setting.\n * @param override If set, the value of the provider will be overridden by this value.\n */\nexport function useTimeRangeOptionsSetting(override?: TimeOption[]): TimeOption[] {\n const showCustomTimeRange = useTimeRangeSettings().options;\n if (override !== undefined) {\n return override;\n }\n return showCustomTimeRange;\n}\n\n/**\n * Provider implementation that supplies the time range state at runtime.\n */\nexport function TimeRangeSettingsProvider(props: TimeRangeSettingsProviderProps): ReactElement {\n const ctx = useMemo(() => {\n return {\n showCustom: props.showCustom === undefined ? defaultTimeRangeSettings.showCustom : props.showCustom,\n showZoomButtons:\n props.showZoomButtons === undefined ? defaultTimeRangeSettings.showZoomButtons : props.showZoomButtons,\n options: props.options === undefined ? defaultTimeRangeSettings.options : props.options,\n };\n }, [props.showCustom, props.showZoomButtons, props.options]);\n\n return <TimeRangeSettingsContext.Provider value={ctx}>{props.children}</TimeRangeSettingsContext.Provider>;\n}\n"],"names":["createContext","useContext","useMemo","buildRelativeTimeOption","DEFAULT_OPTIONS","defaultTimeRangeSettings","showCustom","showZoomButtons","options","map","duration","TimeRangeSettingsContext","useTimeRangeSettingsContext","ctx","undefined","Error","useTimeRangeSettings","useShowCustomTimeRangeSetting","override","showCustomTimeRange","useShowZoomRangeSetting","showZoomTimeRange","useTimeRangeOptionsSetting","TimeRangeSettingsProvider","props","Provider","value","children"],"mappings":"AAAA,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,EAA2BC,UAAU,EAAEC,OAAO,QAAQ,QAAQ;AACpF,SAASC,uBAAuB,QAAoB,yBAAyB;AAG7E,MAAMC,kBAAoC;IAAC;IAAM;IAAO;IAAO;IAAM;IAAM;IAAO;IAAO;IAAM;CAAM;AACrG,MAAMC,2BAA8C;IAClDC,YAAY;IACZC,iBAAiB;IACjBC,SAASJ,gBAAgBK,GAAG,CAAC,CAACC,WAAaP,wBAAwBO;AACrE;AAeA,OAAO,MAAMC,yCAA2BX,cAAiCK,0BAA0B;AAEnG,OAAO,SAASO;IACd,MAAMC,MAAMZ,WAAWU;IACvB,IAAIE,QAAQC,WAAW;QACrB,MAAM,IAAIC,MAAM;IAClB;IACA,OAAOF;AACT;AAEA;;CAEC,GACD,OAAO,SAASG;IACd,OAAOJ;AACT;AAEA;;;CAGC,GACD,OAAO,SAASK,8BAA8BC,QAAkB;IAC9D,MAAMC,sBAAsBH,uBAAuBV,UAAU;IAC7D,IAAIY,aAAaJ,WAAW;QAC1B,OAAOI;IACT;IACA,OAAOC;AACT;AAEA;;;CAGC,GACD,OAAO,SAASC,wBAAwBF,QAAkB;IACxD,MAAMG,oBAAoBL,uBAAuBT,eAAe;IAChE,IAAIW,aAAaJ,WAAW;QAC1B,OAAOI;IACT;IACA,OAAOG;AACT;AAEA;;;CAGC,GACD,OAAO,SAASC,2BAA2BJ,QAAuB;IAChE,MAAMC,sBAAsBH,uBAAuBR,OAAO;IAC1D,IAAIU,aAAaJ,WAAW;QAC1B,OAAOI;IACT;IACA,OAAOC;AACT;AAEA;;CAEC,GACD,OAAO,SAASI,0BAA0BC,KAAqC;IAC7E,MAAMX,MAAMX,QAAQ;QAClB,OAAO;YACLI,YAAYkB,MAAMlB,UAAU,KAAKQ,YAAYT,yBAAyBC,UAAU,GAAGkB,MAAMlB,UAAU;YACnGC,iBACEiB,MAAMjB,eAAe,KAAKO,YAAYT,yBAAyBE,eAAe,GAAGiB,MAAMjB,eAAe;YACxGC,SAASgB,MAAMhB,OAAO,KAAKM,YAAYT,yBAAyBG,OAAO,GAAGgB,MAAMhB,OAAO;QACzF;IACF,GAAG;QAACgB,MAAMlB,UAAU;QAAEkB,MAAMjB,eAAe;QAAEiB,MAAMhB,OAAO;KAAC;IAE3D,qBAAO,KAACG,yBAAyBc,QAAQ;QAACC,OAAOb;kBAAMW,MAAMG,QAAQ;;AACvE"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/runtime/TimeRangeProvider/query-params.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 { useMemo, useCallback, useEffect, useState } from 'react';\nimport { useQueryParams, QueryParamConfig } from 'use-query-params';\nimport { getUnixTime, isDate } from 'date-fns';\nimport {\n TimeRangeValue,\n isRelativeTimeRange,\n isDurationString,\n DurationString,\n AbsoluteTimeRange,\n} from '@perses-dev/core';\nimport { TimeRange } from './TimeRangeProvider';\n\nexport type TimeOptionValue = Date | DurationString | null | undefined;\n\n/* Interprets an encoded string and returns either the string or null/undefined if not available */\nfunction getEncodedValue(\n input: string | Array<string | null> | null | undefined,\n allowEmptyString?: boolean\n): string | null | undefined {\n // '' or []\n if (!input || (input.length === 0 && (!allowEmptyString || (allowEmptyString && input !== '')))) {\n return null;\n }\n\n const str = input instanceof Array ? input[0] : input;\n if (str === null || str === undefined) {\n return str;\n }\n if (!allowEmptyString && str === '') {\n return null;\n }\n\n return str;\n}\n\n/* Encodes individual TimeRangeValue as a string, depends on whether start is relative or absolute */\nexport function encodeTimeRangeValue(timeOptionValue: TimeOptionValue): string | null | undefined {\n if (!timeOptionValue) {\n return timeOptionValue;\n }\n\n if (typeof timeOptionValue === 'string') {\n if (isDurationString(timeOptionValue)) {\n return timeOptionValue;\n }\n }\n return (getUnixTime(timeOptionValue) * 1000).toString();\n}\n\n/* Converts param input to supported relative or absolute time range format */\nexport function decodeTimeRangeValue(\n input: string | Array<string | null> | null | undefined\n): Date | DurationString | null | undefined {\n const paramString = getEncodedValue(input);\n if (!paramString) return null;\n return isDurationString(paramString) ? paramString : new Date(Number(paramString));\n}\n\n/**\n * Custom TimeRangeValue param type\n * See: https://github.com/pbeshai/use-query-params/tree/master/packages/serialize-query-params#param-types\n */\nexport const TimeRangeParam: QueryParamConfig<TimeOptionValue, TimeOptionValue> = {\n encode: encodeTimeRangeValue,\n decode: decodeTimeRangeValue,\n equals: (valueA: TimeOptionValue, valueB: TimeOptionValue) => {\n if (valueA === valueB) return true;\n if (!valueA || !valueB) return valueA === valueB;\n return valueA.valueOf() === valueB.valueOf();\n },\n};\n\nexport const timeRangeQueryConfig = {\n start: TimeRangeParam,\n end: TimeRangeParam,\n};\n\nexport const refreshIntervalQueryConfig = {\n refresh: TimeRangeParam,\n};\n\n/**\n * Gets the initial time range taking into account URL params and dashboard JSON duration\n * Sets start query param if it is empty on page load\n */\nexport function useInitialTimeRange(dashboardDuration: DurationString): TimeRangeValue {\n const [query] = useQueryParams(timeRangeQueryConfig, { updateType: 'replaceIn' });\n const { start, end } = query;\n return useMemo(() => {\n let initialTimeRange: TimeRangeValue = { pastDuration: dashboardDuration };\n if (!start) {\n return initialTimeRange;\n }\n const startStr = start.toString();\n if (isDurationString(startStr)) {\n initialTimeRange = { pastDuration: startStr };\n } else if (isDate(start) && isDate(end)) {\n initialTimeRange = { start: start, end: end } as AbsoluteTimeRange;\n }\n return initialTimeRange;\n }, [start, end, dashboardDuration]);\n}\n\n/**\n * Returns time range getter and setter, taking the URL query params.\n */\nexport function useTimeRangeParams(initialTimeRange: TimeRangeValue): Pick<TimeRange, 'timeRange' | 'setTimeRange'> {\n const [query, setQuery] = useQueryParams(timeRangeQueryConfig, { updateType: 'replaceIn' });\n\n // determine whether initial param had previously been populated to fix back btn\n const [paramsLoaded, setParamsLoaded] = useState<boolean>(false);\n\n const { start } = query;\n\n useEffect(() => {\n // when dashboard loaded with no params, default to dashboard duration\n if (!paramsLoaded && !start) {\n if (isRelativeTimeRange(initialTimeRange)) {\n setQuery({ start: initialTimeRange.pastDuration, end: undefined });\n setParamsLoaded(true);\n }\n }\n }, [initialTimeRange, paramsLoaded, start, setQuery]);\n\n const setTimeRange: TimeRange['setTimeRange'] = useCallback(\n (value: TimeRangeValue) => {\n if (isRelativeTimeRange(value)) {\n setQuery({ start: value.pastDuration, end: undefined });\n } else {\n setQuery(value);\n }\n },\n [setQuery]\n );\n\n return { timeRange: initialTimeRange, setTimeRange: setTimeRange };\n}\n\n/**\n * Gets the initial refresh interval taking into account URL params and dashboard JSON duration\n * Sets refresh query param if it is empty on page load\n */\nexport function useInitialRefreshInterval(dashboardDuration: DurationString): DurationString {\n const [query] = useQueryParams(refreshIntervalQueryConfig, { updateType: 'replaceIn' });\n const { refresh } = query;\n return useMemo(() => {\n let initialTimeRange: DurationString = dashboardDuration;\n if (!refresh) {\n return initialTimeRange;\n }\n const startStr = refresh.toString();\n if (isDurationString(startStr)) {\n initialTimeRange = startStr;\n }\n return initialTimeRange;\n }, [dashboardDuration, refresh]);\n}\n\n/**\n * Returns refresh interval getter and setter, taking the URL query params.\n */\nexport function useSetRefreshIntervalParams(\n initialRefreshInterval?: DurationString\n): Pick<TimeRange, 'refreshInterval' | 'setRefreshInterval'> {\n const [query, setQuery] = useQueryParams(refreshIntervalQueryConfig, { updateType: 'replaceIn' });\n\n // determine whether initial param had previously been populated to fix back btn\n const [paramsLoaded, setParamsLoaded] = useState<boolean>(false);\n\n const { refresh } = query;\n\n useEffect(() => {\n // when dashboard loaded with no params, default to dashboard refresh interval\n if (!paramsLoaded && !refresh) {\n setQuery({ refresh: initialRefreshInterval });\n setParamsLoaded(true);\n }\n }, [initialRefreshInterval, paramsLoaded, refresh, setQuery]);\n\n const setRefreshInterval: TimeRange['setRefreshInterval'] = useCallback(\n (refresh: DurationString) => setQuery({ refresh }),\n [setQuery]\n );\n\n return {\n refreshInterval: initialRefreshInterval,\n setRefreshInterval: setRefreshInterval,\n };\n}\n"],"names":["useMemo","useCallback","useEffect","useState","useQueryParams","getUnixTime","isDate","isRelativeTimeRange","isDurationString","getEncodedValue","input","allowEmptyString","length","str","Array","undefined","encodeTimeRangeValue","timeOptionValue","toString","decodeTimeRangeValue","paramString","Date","Number","TimeRangeParam","encode","decode","equals","valueA","valueB","valueOf","timeRangeQueryConfig","start","end","refreshIntervalQueryConfig","refresh","useInitialTimeRange","dashboardDuration","query","updateType","initialTimeRange","pastDuration","startStr","useTimeRangeParams","setQuery","paramsLoaded","setParamsLoaded","setTimeRange","value","timeRange","useInitialRefreshInterval","useSetRefreshIntervalParams","initialRefreshInterval","setRefreshInterval","refreshInterval"],"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,OAAO,EAAEC,WAAW,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,QAAQ;AAClE,SAASC,cAAc,QAA0B,mBAAmB;AACpE,SAASC,WAAW,EAAEC,MAAM,QAAQ,WAAW;AAC/C,SAEEC,mBAAmB,EACnBC,gBAAgB,QAGX,mBAAmB;AAK1B,iGAAiG,GACjG,SAASC,gBACPC,KAAuD,EACvDC,gBAA0B;IAE1B,WAAW;IACX,IAAI,CAACD,SAAUA,MAAME,MAAM,KAAK,KAAM,CAAA,CAACD,oBAAqBA,oBAAoBD,UAAU,EAAE,GAAK;QAC/F,OAAO;IACT;IAEA,MAAMG,MAAMH,iBAAiBI,QAAQJ,KAAK,CAAC,EAAE,GAAGA;IAChD,IAAIG,QAAQ,QAAQA,QAAQE,WAAW;QACrC,OAAOF;IACT;IACA,IAAI,CAACF,oBAAoBE,QAAQ,IAAI;QACnC,OAAO;IACT;IAEA,OAAOA;AACT;AAEA,mGAAmG,GACnG,OAAO,SAASG,qBAAqBC,eAAgC;IACnE,IAAI,CAACA,iBAAiB;QACpB,OAAOA;IACT;IAEA,IAAI,OAAOA,oBAAoB,UAAU;QACvC,IAAIT,iBAAiBS,kBAAkB;YACrC,OAAOA;QACT;IACF;IACA,OAAO,AAACZ,CAAAA,YAAYY,mBAAmB,IAAG,EAAGC,QAAQ;AACvD;AAEA,4EAA4E,GAC5E,OAAO,SAASC,qBACdT,KAAuD;IAEvD,MAAMU,cAAcX,gBAAgBC;IACpC,IAAI,CAAC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B;IACF,GAAG;QAACM;QAAwBP;QAAcV;QAASS;KAAS;IAE5D,MAAMS,qBAAsDnD,YAC1D,CAACiC,UAA4BS,SAAS;YAAET;QAAQ,IAChD;QAACS;KAAS;IAGZ,OAAO;QACLU,iBAAiBF;QACjBC,oBAAoBA;IACtB;AACF"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/runtime/TimeRangeProvider/refresh-interval.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 { DurationString, parseDurationString } from '@perses-dev/core';\nimport { milliseconds } from 'date-fns';\n\n/**\n * Utils function to transform a refresh interval in {@link DurationString} format into a number of ms.\n * @param refreshInterval\n */\nexport function getRefreshIntervalInMs(refreshInterval?: DurationString): number {\n if (refreshInterval !== undefined && refreshInterval !== null) {\n return milliseconds(parseDurationString(refreshInterval));\n }\n return 0;\n}\n"],"names":["parseDurationString","milliseconds","getRefreshIntervalInMs","refreshInterval","undefined"],"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,SAAyBA,mBAAmB,QAAQ,mBAAmB;AACvE,SAASC,YAAY,QAAQ,WAAW;AAExC;;;CAGC,GACD,OAAO,SAASC,uBAAuBC,eAAgC;IACrE,IAAIA,oBAAoBC,aAAaD,oBAAoB,MAAM;QAC7D,OAAOF,aAAaD,oBAAoBG;IAC1C;IACA,OAAO;AACT"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/runtime/UsageMetricsProvider.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 { fetch, QueryDefinition } from '@perses-dev/core';\nimport { createContext, ReactElement, ReactNode, useContext } from 'react';\n\ntype QueryState = 'pending' | 'success' | 'error';\n\ninterface UsageMetrics {\n project: string;\n dashboard: string;\n startRenderTime: number;\n renderDurationMs: number;\n renderErrorCount: number;\n pendingQueries: Map<string, QueryState>;\n}\n\ninterface UsageMetricsProps {\n project: string;\n dashboard: string;\n children: ReactNode;\n}\n\ninterface UseUsageMetricsResults {\n markQuery: (definition: QueryDefinition, state: QueryState) => void;\n}\n\nexport const UsageMetricsContext = createContext<UsageMetrics | undefined>(undefined);\n\nexport const useUsageMetricsContext = (): UsageMetrics | undefined => {\n return useContext(UsageMetricsContext);\n};\n\nexport const useUsageMetrics = (): UseUsageMetricsResults => {\n const ctx = useUsageMetricsContext();\n\n return {\n markQuery: (definition: QueryDefinition, newState: QueryState): void => {\n if (ctx === undefined) {\n return;\n }\n\n const definitionKey = JSON.stringify(definition);\n if (ctx.pendingQueries.has(definitionKey) && newState === 'pending') {\n // Never allow transitions back to pending, to avoid re-sending stats on a re-render.\n return;\n }\n\n if (ctx.pendingQueries.get(definitionKey) !== newState) {\n ctx.pendingQueries.set(definitionKey, newState);\n if (newState === 'error') {\n ctx.renderErrorCount += 1;\n }\n\n const allDone = [...ctx.pendingQueries.values()].every((p) => p !== 'pending');\n if (ctx.renderDurationMs === 0 && allDone) {\n ctx.renderDurationMs = Date.now() - ctx.startRenderTime;\n submitMetrics(ctx);\n }\n }\n },\n };\n};\n\nconst submitMetrics = async (stats: UsageMetrics): Promise<void> => {\n await fetch('/api/v1/view', {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({\n project: stats.project,\n dashboard: stats.dashboard,\n render_time: stats.renderDurationMs / 1000,\n render_errors: stats.renderErrorCount,\n }),\n });\n};\n\nexport const UsageMetricsProvider = ({ project, dashboard, children }: UsageMetricsProps): ReactElement => {\n const ctx = {\n project: project,\n dashboard: dashboard,\n renderErrorCount: 0,\n startRenderTime: Date.now(),\n renderDurationMs: 0,\n pendingQueries: new Map(),\n };\n\n return <UsageMetricsContext.Provider value={ctx}>{children}</UsageMetricsContext.Provider>;\n};\n"],"names":["fetch","createContext","useContext","UsageMetricsContext","undefined","useUsageMetricsContext","useUsageMetrics","ctx","markQuery","definition","newState","definitionKey","JSON","stringify","pendingQueries","has","get","set","renderErrorCount","allDone","values","every","p","renderDurationMs","Date","now","startRenderTime","submitMetrics","stats","method","headers","body","project","dashboard","render_time","render_errors","UsageMetricsProvider","children","Map","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,KAAK,QAAyB,mBAAmB;AAC1D,SAASC,aAAa,EAA2BC,UAAU,QAAQ,QAAQ;AAuB3E,OAAO,MAAMC,oCAAsBF,cAAwCG,WAAW;AAEtF,OAAO,MAAMC,yBAAyB;IACpC,OAAOH,WAAWC;AACpB,EAAE;AAEF,OAAO,MAAMG,kBAAkB;IAC7B,MAAMC,MAAMF;IAEZ,OAAO;QACLG,WAAW,CAACC,YAA6BC;YACvC,IAAIH,QAAQH,WAAW;gBACrB;YACF;YAEA,MAAMO,gBAAgBC,KAAKC,SAAS,CAACJ;YACrC,IAAIF,IAAIO,cAAc,CAACC,GAAG,CAACJ,kBAAkBD,aAAa,WAAW;gBACnE,qFAAqF;gBACrF;YACF;YAEA,IAAIH,IAAIO,cAAc,CAACE,GAAG,CAACL,mBAAmBD,UAAU;gBACtDH,IAAIO,cAAc,CAACG,GAAG,CAACN,eAAeD;gBACtC,IAAIA,aAAa,SAAS;oBACxBH,IAAIW,gBAAgB,IAAI;gBAC1B;gBAEA,MAAMC,UAAU;uBAAIZ,IAAIO,cAAc,CAACM,MAAM;iBAAG,CAACC,KAAK,CAAC,CAACC,IAAMA,MAAM;gBACpE,IAAIf,IAAIgB,gBAAgB,KAAK,KAAKJ,SAAS;oBACzCZ,IAAIgB,gBAAgB,GAAGC,KAAKC,GAAG,KAAKlB,IAAImB,eAAe;oBACvDC,cAAcpB;gBAChB;YACF;QACF;IACF;AACF,EAAE;AAEF,MAAMoB,gBAAgB,OAAOC;IAC3B,MAAM5B,MAAM,gBAAgB;QAC1B6B,QAAQ;QACRC,SAAS;YACP,gBAAgB;QAClB;QACAC,MAAMnB,KAAKC,SAAS,CAAC;YACnBmB,SAASJ,MAAMI,OAAO;YACtBC,WAAWL,MAAMK,SAAS;YAC1BC,aAAaN,MAAML,gBAAgB,GAAG;YACtCY,eAAeP,MAAMV,gBAAgB;QACvC;IACF;AACF;AAEA,OAAO,MAAMkB,uBAAuB,CAAC,EAAEJ,OAAO,EAAEC,SAAS,EAAEI,QAAQ,EAAqB;IACtF,MAAM9B,MAAM;QACVyB,SAASA;QACTC,WAAWA;QACXf,kBAAkB;QAClBQ,iBAAiBF,KAAKC,GAAG;QACzBF,kBAAkB;QAClBT,gBAAgB,IAAIwB;IACtB;IAEA,qBAAO,KAACnC,oBAAoBoC,QAAQ;QAACC,OAAOjC;kBAAM8B;;AACpD,EAAE"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/runtime/builtin-variables.ts"],"sourcesContent":["// Copyright 2024 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, useContext, useMemo } from 'react';\nimport { BuiltinVariableDefinition } from '@perses-dev/core';\nimport { VariableStateMap } from './variables';\n\nexport type BuiltinVariableSrv = {\n variables: BuiltinVariableDefinition[];\n};\n\nexport const BuiltinVariableContext = createContext<BuiltinVariableSrv | undefined>(undefined);\n\nexport function useBuiltinVariableContext(): BuiltinVariableSrv {\n const ctx = useContext(BuiltinVariableContext);\n if (ctx === undefined) {\n throw new Error('No BuiltinVariableContext found. Did you forget a Provider?');\n }\n return ctx;\n}\n\nexport function useBuiltinVariableValues(names?: string[]): VariableStateMap {\n const { variables } = useBuiltinVariableContext();\n const states = useMemo(() => {\n const values: VariableStateMap = {};\n for (const variable of variables) {\n values[variable.spec.name] = { loading: false, value: variable.spec.value() };\n }\n return values;\n }, [variables]);\n\n const values = useMemo(() => {\n const values: VariableStateMap = {};\n names?.forEach((name) => {\n const s = states[name];\n if (s) {\n values[name] = s;\n }\n });\n return values;\n }, [names, states]);\n\n if (names === undefined) {\n return states;\n }\n\n return values;\n}\n\nexport function useBuiltinVariableDefinitions(): BuiltinVariableDefinition[] {\n const { variables } = useBuiltinVariableContext();\n return variables;\n}\n"],"names":["createContext","useContext","useMemo","BuiltinVariableContext","undefined","useBuiltinVariableContext","ctx","Error","useBuiltinVariableValues","names","variables","states","values","variable","spec","name","loading","value","forEach","s","useBuiltinVariableDefinitions"],"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,UAAU,EAAEC,OAAO,QAAQ,QAAQ;AAQ3D,OAAO,MAAMC,yBAAyBH,cAA8CI,WAAW;AAE/F,OAAO,SAASC;IACd,MAAMC,MAAML,WAAWE;IACvB,IAAIG,QAAQF,WAAW;QACrB,MAAM,IAAIG,MAAM;IAClB;IACA,OAAOD;AACT;AAEA,OAAO,SAASE,yBAAyBC,KAAgB;IACvD,MAAM,EAAEC,SAAS,EAAE,GAAGL;IACtB,MAAMM,SAAST,QAAQ;QACrB,MAAMU,SAA2B,CAAC;QAClC,KAAK,MAAMC,YAAYH,UAAW;YAChCE,MAAM,CAACC,SAASC,IAAI,CAACC,IAAI,CAAC,GAAG;gBAAEC,SAAS;gBAAOC,OAAOJ,SAASC,IAAI,CAACG,KAAK;YAAG;QAC9E;QACA,OAAOL;IACT,GAAG;QAACF;KAAU;IAEd,MAAME,SAASV,QAAQ;QACrB,MAAMU,SAA2B,CAAC;QAClCH,OAAOS,QAAQ,CAACH;YACd,MAAMI,IAAIR,MAAM,CAACI,KAAK;YACtB,IAAII,GAAG;gBACLP,MAAM,CAACG,KAAK,GAAGI;YACjB;QACF;QACA,OAAOP;IACT,GAAG;QAACH;QAAOE;KAAO;IAElB,IAAIF,UAAUL,WAAW;QACvB,OAAOO;IACT;IAEA,OAAOC;AACT;AAEA,OAAO,SAASQ;IACd,MAAM,EAAEV,SAAS,EAAE,GAAGL;IACtB,OAAOK;AACT"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/runtime/datasources.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { DatasourceSelector, DatasourceSpec } from '@perses-dev/core';\nimport { useQuery, UseQueryResult } from '@tanstack/react-query';\nimport { createContext, useContext } from 'react';\n\nexport interface DatasourceStore {\n // TODO: Do we even need this method?\n getDatasource(selector: DatasourceSelector): Promise<DatasourceSpec>;\n\n /**\n * Given a DatasourceSelector, gets a `Client` object from the corresponding Datasource plugin.\n */\n getDatasourceClient<Client>(selector: DatasourceSelector): Promise<Client>;\n\n /**\n * Gets a list of datasource selection items for a plugin kind.\n */\n listDatasourceSelectItems(datasourcePluginName: string): Promise<DatasourceSelectItemGroup[]>;\n\n /**\n * Gets the list of datasources defined in the dashboard\n */\n getLocalDatasources(): Record<string, DatasourceSpec>;\n\n /**\n * Sets the list of datasources defined in the dashboard\n */\n setLocalDatasources(datasources: Record<string, DatasourceSpec>): void;\n\n /**\n * Gets the list of datasources that are available in the dashboard (i.e. dashboards that have been created on the server side that we can use).\n */\n getSavedDatasources(): Record<string, DatasourceSpec>;\n\n /**\n * Sets the list of datasources that are saved in the dashboard\n */\n setSavedDatasources(datasources: Record<string, DatasourceSpec>): void;\n}\n\nexport interface DatasourceSelectItemGroup {\n group?: string;\n editLink?: string;\n items: DatasourceSelectItem[];\n}\n\nexport interface DatasourceSelectItem {\n name: string;\n overridden?: boolean;\n overriding?: boolean;\n saved?: boolean;\n selector: DatasourceSelectItemSelector;\n}\n\n/**\n * Datasource Selector used by the frontend only to differentiate datasources coming from different group.\n */\nexport interface DatasourceSelectItemSelector extends DatasourceSelector {\n /**\n * Group of the datasource.\n * Omit it if you don't store datasource by group.\n */\n group?: string;\n}\n\nexport const DatasourceStoreContext = createContext<DatasourceStore | undefined>(undefined);\n\nexport function useDatasourceStore(): DatasourceStore {\n const ctx = useContext(DatasourceStoreContext);\n if (ctx === undefined) {\n throw new Error('No DatasourceStoreContext found. Did you forget a Provider?');\n }\n return ctx;\n}\n\n/**\n * Lists all available Datasource selection items for a given datasource plugin kind.\n * Returns a list, with all information that can be used in a datasource selection context (group, name, selector, kind, ...)\n */\nexport function useListDatasourceSelectItems(\n datasourcePluginName: string,\n project?: string\n): UseQueryResult<DatasourceSelectItemGroup[]> {\n const { listDatasourceSelectItems } = useDatasourceStore();\n return useQuery<DatasourceSelectItemGroup[]>({\n queryKey: ['listDatasourceSelectItems', datasourcePluginName, project],\n queryFn: () => listDatasourceSelectItems(datasourcePluginName),\n });\n}\n\n/**\n * Provides a convenience hook for getting a DatasourceClient for a given DatasourceSelector.\n */\nexport function useDatasourceClient<Client>(selector: DatasourceSelector): UseQueryResult<Client> {\n const store = useDatasourceStore();\n return useQuery<Client>({\n queryKey: ['getDatasourceClient', selector],\n queryFn: () => store.getDatasourceClient<Client>(selector),\n });\n}\n\nexport function useDatasource(selector: DatasourceSelector): UseQueryResult<DatasourceSpec> {\n const store = useDatasourceStore();\n return useQuery<DatasourceSpec>({\n queryKey: ['getDatasource', selector],\n queryFn: () => store.getDatasource(selector),\n });\n}\n"],"names":["useQuery","createContext","useContext","DatasourceStoreContext","undefined","useDatasourceStore","ctx","Error","useListDatasourceSelectItems","datasourcePluginName","project","listDatasourceSelectItems","queryKey","queryFn","useDatasourceClient","selector","store","getDatasourceClient","useDatasource","getDatasource"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAGjC,SAASA,QAAQ,QAAwB,wBAAwB;AACjE,SAASC,aAAa,EAAEC,UAAU,QAAQ,QAAQ;AA8DlD,OAAO,MAAMC,yBAAyBF,cAA2CG,WAAW;AAE5F,OAAO,SAASC;IACd,MAAMC,MAAMJ,WAAWC;IACvB,IAAIG,QAAQF,WAAW;QACrB,MAAM,IAAIG,MAAM;IAClB;IACA,OAAOD;AACT;AAEA;;;CAGC,GACD,OAAO,SAASE,6BACdC,oBAA4B,EAC5BC,OAAgB;IAEhB,MAAM,EAAEC,yBAAyB,EAAE,GAAGN;IACtC,OAAOL,SAAsC;QAC3CY,UAAU;YAAC;YAA6BH;YAAsBC;SAAQ;QACtEG,SAAS,IAAMF,0BAA0BF;IAC3C;AACF;AAEA;;CAEC,GACD,OAAO,SAASK,oBAA4BC,QAA4B;IACtE,MAAMC,QAAQX;IACd,OAAOL,SAAiB;QACtBY,UAAU;YAAC;YAAuBG;SAAS;QAC3CF,SAAS,IAAMG,MAAMC,mBAAmB,CAASF;IACnD;AACF;AAEA,OAAO,SAASG,cAAcH,QAA4B;IACxD,MAAMC,QAAQX;IACd,OAAOL,SAAyB;QAC9BY,UAAU;YAAC;YAAiBG;SAAS;QACrCF,SAAS,IAAMG,MAAMG,aAAa,CAACJ;IACrC;AACF"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/runtime/index.ts"],"sourcesContent":["// Copyright 2024 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './builtin-variables';\nexport * from './datasources';\nexport * from './plugin-registry';\nexport * from './variables';\nexport * from './TimeRangeProvider';\nexport * from './time-series-queries';\nexport * from './trace-queries';\nexport * from './profile-queries';\nexport * from './DataQueriesProvider';\nexport * from './QueryCountProvider';\nexport * from './RouterProvider';\nexport * from './UsageMetricsProvider';\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,gBAAgB;AAC9B,cAAc,oBAAoB;AAClC,cAAc,cAAc;AAC5B,cAAc,sBAAsB;AACpC,cAAc,wBAAwB;AACtC,cAAc,kBAAkB;AAChC,cAAc,oBAAoB;AAClC,cAAc,wBAAwB;AACtC,cAAc,uBAAuB;AACrC,cAAc,mBAAmB;AACjC,cAAc,yBAAyB"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/runtime/plugin-registry.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 { BuiltinVariableDefinition } from '@perses-dev/core';\nimport { useQueries, useQuery, UseQueryOptions, UseQueryResult } from '@tanstack/react-query';\nimport { createContext, useContext } from 'react';\nimport { DefaultPluginKinds, PluginImplementation, PluginMetadataWithModule, PluginType } from '../model';\n\nexport interface PluginRegistryContextType {\n getPlugin<T extends PluginType>(kind: T, name: string): Promise<PluginImplementation<T>>;\n listPluginMetadata(pluginTypes: PluginType[]): Promise<PluginMetadataWithModule[]>;\n defaultPluginKinds?: DefaultPluginKinds;\n}\n\nexport const PluginRegistryContext = createContext<PluginRegistryContextType | undefined>(undefined);\n\n/**\n * Use the PluginRegistry context directly. This is meant as an escape hatch for custom async flows. You should probably\n * be using `usePlugin` or `useListPluginMetadata` instead.\n */\nexport function usePluginRegistry(): PluginRegistryContextType {\n const ctx = useContext(PluginRegistryContext);\n if (ctx === undefined) {\n throw new Error('PluginRegistryContext not found. Did you forget a provider?');\n }\n return ctx;\n}\n\n// Allows consumers to pass useQuery options from react-query when loading a plugin\ntype UsePluginOptions<T extends PluginType> = Omit<\n UseQueryOptions<PluginImplementation<T>, Error, PluginImplementation<T>, [string, PluginType | undefined, string]>,\n 'queryKey' | 'queryFn'\n>;\n\n/**\n * Loads a plugin and returns the plugin implementation, along with loading/error state.\n */\nexport function usePlugin<T extends PluginType>(\n pluginType: T | undefined,\n kind: string,\n options?: UsePluginOptions<T>\n): UseQueryResult<PluginImplementation<T>, Error> {\n // We never want to ask for a plugin when the kind isn't set yet, so disable those queries automatically\n options = {\n ...options,\n enabled: (options?.enabled ?? true) && pluginType !== undefined && kind !== '',\n };\n const { getPlugin } = usePluginRegistry();\n return useQuery({\n queryKey: ['getPlugin', pluginType, kind],\n queryFn: () => getPlugin(pluginType!, kind),\n ...options,\n });\n}\n\n/**\n * Loads a list of plugins and returns the plugin implementation, along with loading/error state.\n */\nexport function usePlugins<T extends PluginType>(\n pluginType: T,\n plugins: Array<{ kind: string }>\n): Array<UseQueryResult<PluginImplementation<T>>> {\n const { getPlugin } = usePluginRegistry();\n\n // useQueries() does not support queries with duplicate keys, therefore we de-duplicate the plugin kinds before running useQueries()\n // This resolves the following warning in the JS console: \"[QueriesObserver]: Duplicate Queries found. This might result in unexpected behavior.\"\n // https://github.com/TanStack/query/issues/8224#issuecomment-2523554831\n // https://github.com/TanStack/query/issues/4187#issuecomment-1256336901\n const kinds = [...new Set(plugins.map((p) => p.kind))];\n\n const result: Array<UseQueryResult<PluginImplementation<T>>> = useQueries({\n queries: kinds.map((kind) => {\n return {\n queryKey: ['getPlugin', pluginType, kind],\n queryFn: () => getPlugin(pluginType, kind),\n };\n }),\n });\n\n // Re-assemble array in original order\n return plugins.map((p) => result[kinds.indexOf(p.kind)]!);\n}\n\n// Allow consumers to pass useQuery options from react-query when listing metadata\ntype UseListPluginMetadataOptions = Omit<\n UseQueryOptions<PluginMetadataWithModule[], Error, PluginMetadataWithModule[], [string, string[]]>,\n 'queryKey' | 'queryFn'\n>;\n\n/**\n * Gets a list of plugin metadata for the specified plugin type and returns it, along with loading/error state.\n */\nexport function useListPluginMetadata(\n pluginTypes: PluginType[],\n options?: UseListPluginMetadataOptions\n): UseQueryResult<PluginMetadataWithModule[]> {\n const { listPluginMetadata } = usePluginRegistry();\n return useQuery({\n queryKey: ['listPluginMetadata', pluginTypes],\n queryFn: () => listPluginMetadata(pluginTypes),\n ...options,\n });\n}\n\nexport function usePluginBuiltinVariableDefinitions(): UseQueryResult<BuiltinVariableDefinition[]> {\n const { getPlugin, listPluginMetadata } = usePluginRegistry();\n\n return useQuery({\n queryKey: ['usePluginBuiltinVariableDefinitions'],\n queryFn: async () => {\n const datasources = await listPluginMetadata(['Datasource']);\n const datasourceNames = new Set(datasources.map((datasource) => datasource.spec.name));\n const result: BuiltinVariableDefinition[] = [];\n for (const name of datasourceNames) {\n const plugin = await getPlugin('Datasource', name);\n if (plugin.getBuiltinVariableDefinitions) {\n plugin.getBuiltinVariableDefinitions().forEach((definition) => result.push(definition));\n }\n }\n return result;\n },\n });\n}\n"],"names":["useQueries","useQuery","createContext","useContext","PluginRegistryContext","undefined","usePluginRegistry","ctx","Error","usePlugin","pluginType","kind","options","enabled","getPlugin","queryKey","queryFn","usePlugins","plugins","kinds","Set","map","p","result","queries","indexOf","useListPluginMetadata","pluginTypes","listPluginMetadata","usePluginBuiltinVariableDefinitions","datasources","datasourceNames","datasource","spec","name","plugin","getBuiltinVariableDefinitions","forEach","definition","push"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAGjC,SAASA,UAAU,EAAEC,QAAQ,QAAyC,wBAAwB;AAC9F,SAASC,aAAa,EAAEC,UAAU,QAAQ,QAAQ;AASlD,OAAO,MAAMC,wBAAwBF,cAAqDG,WAAW;AAErG;;;CAGC,GACD,OAAO,SAASC;IACd,MAAMC,MAAMJ,WAAWC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f,SAAS,EAAEc,kBAAkB,EAAE,GAAGtB;IAE1C,OAAOL,SAAS;QACdc,UAAU;YAAC;SAAsC;QACjDC,SAAS;YACP,MAAMc,cAAc,MAAMF,mBAAmB;gBAAC;aAAa;YAC3D,MAAMG,kBAAkB,IAAIX,IAAIU,YAAYT,GAAG,CAAC,CAACW,aAAeA,WAAWC,IAAI,CAACC,IAAI;YACpF,MAAMX,SAAsC,EAAE;YAC9C,KAAK,MAAMW,QAAQH,gBAAiB;gBAClC,MAAMI,SAAS,MAAMrB,UAAU,cAAcoB;gBAC7C,IAAIC,OAAOC,6BAA6B,EAAE;oBACxCD,OAAOC,6BAA6B,GAAGC,OAAO,CAAC,CAACC,aAAef,OAAOgB,IAAI,CAACD;gBAC7E;YACF;YACA,OAAOf;QACT;IACF;AACF"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/runtime/profile-queries.tsx"],"sourcesContent":["// Copyright 2025 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { QueryDefinition, UnknownSpec, ProfileData } from '@perses-dev/core';\nimport { useQueries, UseQueryResult } from '@tanstack/react-query';\nimport { useDatasourceStore } from './datasources';\nimport { usePluginRegistry } from './plugin-registry';\nimport { useTimeRange } from './TimeRangeProvider';\nexport type ProfileQueryDefinition<PluginSpec = UnknownSpec> = QueryDefinition<'ProfileQuery', PluginSpec>;\nexport const PROFILE_QUERY_KEY = 'ProfileQuery';\n\n/**\n * Run a profile query using a ProfileQuery plugin and return the results\n * @param definitions: dashboard defintion for a profile query\n */\nexport function useProfileQueries(definitions: ProfileQueryDefinition[]): Array<UseQueryResult<ProfileData>> {\n const { getPlugin } = usePluginRegistry();\n const datasourceStore = useDatasourceStore();\n const { absoluteTimeRange } = useTimeRange();\n\n const context = {\n datasourceStore,\n absoluteTimeRange,\n };\n\n // useQueries() handles data fetching from query plugins (e.g. traceQL queries, promQL queries)\n // https://tanstack.com/query/v4/docs/react/reference/useQuery\n return useQueries({\n queries: definitions.map((definition) => {\n const queryKey = [definition, datasourceStore, absoluteTimeRange] as const; // `queryKey` watches and reruns `queryFn` if keys in the array change\n const profileQueryKind = definition?.spec?.plugin?.kind;\n return {\n queryKey: queryKey,\n queryFn: async (): Promise<ProfileData> => {\n const plugin = await getPlugin(PROFILE_QUERY_KEY, profileQueryKind);\n const data = await plugin.getProfileData(definition.spec.plugin.spec, context);\n return data;\n },\n\n structuralSharing: false,\n };\n }),\n });\n}\n"],"names":["useQueries","useDatasourceStore","usePluginRegistry","useTimeRange","PROFILE_QUERY_KEY","useProfileQueries","definitions","getPlugin","datasourceStore","absoluteTimeRange","context","queries","map","definition","queryKey","profileQueryKind","spec","plugin","kind","queryFn","data","getProfileData","structuralSharing"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAGjC,SAASA,UAAU,QAAwB,wBAAwB;AACnE,SAASC,kBAAkB,QAAQ,gBAAgB;AACnD,SAASC,iBAAiB,QAAQ,oBAAoB;AACtD,SAASC,YAAY,QAAQ,sBAAsB;AAEnD,OAAO,MAAMC,oBAAoB,eAAe;AAEhD;;;CAGC,GACD,OAAO,SAASC,kBAAkBC,WAAqC;IACrE,MAAM,EAAEC,SAAS,EAAE,GAAGL;IACtB,MAAMM,kBAAkBP;IACxB,MAAM,EAAEQ,iBAAiB,EAAE,GAAGN;IAE9B,MAAMO,UAAU;QACdF;QACAC;IACF;IAEA,+FAA+F;IAC/F,8DAA8D;IAC9D,OAAOT,WAAW;QAChBW,SAASL,YAAYM,GAAG,CAAC,CAACC;YACxB,MAAMC,WAAW;gBAACD;gBAAYL;gBAAiBC;aAAkB,EAAW,sEAAsE;YAClJ,MAAMM,mBAAmBF,YAAYG,MAAMC,QAAQC;YACnD,OAAO;gBACLJ,UAAUA;gBACVK,SAAS;oBACP,MAAMF,SAAS,MAAMV,UAAUH,mBAAmBW;oBAClD,MAAMK,OAAO,MAAMH,OAAOI,cAAc,CAACR,WAAWG,IAAI,CAACC,MAAM,CAACD,IAAI,EAAEN;oBACtE,OAAOU;gBACT;gBAEAE,mBAAmB;YACrB;QACF;IACF;AACF"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/runtime/time-series-queries.ts"],"sourcesContent":["// Copyright 2024 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 { TimeSeriesData, TimeSeriesQueryDefinition, UnknownSpec } from '@perses-dev/core';\nimport {\n Query,\n QueryCache,\n QueryKey,\n QueryObserverOptions,\n useQueries,\n useQuery,\n useQueryClient,\n UseQueryResult,\n} from '@tanstack/react-query';\nimport { TimeSeriesDataQuery, TimeSeriesQueryContext, TimeSeriesQueryMode, TimeSeriesQueryPlugin } from '../model';\nimport { useTimeRange } from './TimeRangeProvider';\nimport { useDatasourceStore } from './datasources';\nimport { usePlugin, usePluginRegistry, usePlugins } from './plugin-registry';\nimport { filterVariableStateMap, getVariableValuesKey } from './utils';\nimport { useAllVariableValues } from './variables';\n\nexport interface UseTimeSeriesQueryOptions {\n suggestedStepMs?: number;\n mode?: TimeSeriesQueryMode;\n}\n\nexport const TIME_SERIES_QUERY_KEY = 'TimeSeriesQuery';\n\nfunction getQueryOptions({\n plugin,\n definition,\n context,\n}: {\n plugin?: TimeSeriesQueryPlugin;\n definition: TimeSeriesQueryDefinition;\n context: TimeSeriesQueryContext;\n}): {\n queryKey: QueryKey;\n queryEnabled: boolean;\n} {\n const { timeRange, datasourceStore, suggestedStepMs, mode, variableState, refreshKey } = context;\n\n const dependencies = plugin?.dependsOn ? plugin.dependsOn(definition.spec.plugin.spec, context) : {};\n const variableDependencies = dependencies?.variables;\n\n // Determine queryKey\n const filteredVariabledState = filterVariableStateMap(variableState, variableDependencies);\n const variablesValueKey = getVariableValuesKey(filteredVariabledState);\n const queryKey = [\n definition,\n timeRange,\n datasourceStore,\n suggestedStepMs,\n mode,\n variablesValueKey,\n refreshKey,\n ] as const;\n\n // Determine queryEnabled\n let waitToLoad = false;\n if (variableDependencies) {\n waitToLoad = variableDependencies.some((v) => variableState[v]?.loading);\n }\n\n const queryEnabled = plugin !== undefined && !waitToLoad;\n\n return {\n queryKey,\n queryEnabled,\n };\n}\n\n/**\n * Runs a time series query using a plugin and returns the results.\n */\nexport const useTimeSeriesQuery = (\n definition: TimeSeriesQueryDefinition,\n options?: UseTimeSeriesQueryOptions,\n queryOptions?: QueryObserverOptions<TimeSeriesData>\n): UseQueryResult<TimeSeriesData> => {\n const { data: plugin } = usePlugin(TIME_SERIES_QUERY_KEY, definition.spec.plugin.kind);\n const context = useTimeSeriesQueryContext();\n\n const { queryEnabled, queryKey } = getQueryOptions({ plugin, definition, context });\n return useQuery({\n enabled: (queryOptions?.enabled ?? true) || queryEnabled,\n queryKey: queryKey,\n queryFn: () => {\n // The 'enabled' option should prevent this from happening, but make TypeScript happy by checking\n if (plugin === undefined) {\n throw new Error('Expected plugin to be loaded');\n }\n // Keep options out of query key so we don't re-run queries because suggested step changes\n const ctx: TimeSeriesQueryContext = { ...context, suggestedStepMs: options?.suggestedStepMs };\n return plugin.getTimeSeriesData(definition.spec.plugin.spec, ctx);\n },\n });\n};\n\n/**\n * Runs multiple time series queries using plugins and returns the results.\n */\nexport function useTimeSeriesQueries(\n definitions: TimeSeriesQueryDefinition[],\n options?: UseTimeSeriesQueryOptions,\n queryOptions?: Omit<QueryObserverOptions, 'queryKey'>\n): Array<UseQueryResult<TimeSeriesData>> {\n const { getPlugin } = usePluginRegistry();\n const context = {\n ...useTimeSeriesQueryContext(),\n // We need mode to be part query key because this drives the type of query done (instant VS range query)\n mode: options?.mode,\n };\n\n const pluginLoaderResponse = usePlugins(\n TIME_SERIES_QUERY_KEY,\n definitions.map((d) => ({ kind: d.spec.plugin.kind }))\n );\n\n return useQueries({\n queries: definitions.map((definition, idx) => {\n const plugin = pluginLoaderResponse[idx]?.data;\n const { queryEnabled, queryKey } = getQueryOptions({ plugin, definition, context });\n return {\n ...(queryOptions as QueryObserverOptions<TimeSeriesData>),\n enabled: (queryOptions?.enabled ?? true) && queryEnabled,\n queryKey: queryKey,\n queryFn: async (): Promise<TimeSeriesData> => {\n const ctx: TimeSeriesQueryContext = {\n ...context,\n // Keep suggested step changes out of the query key, so we don´t have to run again query when it changes\n suggestedStepMs: options?.suggestedStepMs,\n };\n const plugin = await getPlugin(TIME_SERIES_QUERY_KEY, definition.spec.plugin.kind);\n const data = await plugin.getTimeSeriesData(definition.spec.plugin.spec, ctx);\n return data;\n },\n };\n }),\n });\n}\n\n/**\n * Build the time series query context object from data available at runtime\n */\nfunction useTimeSeriesQueryContext(): TimeSeriesQueryContext {\n const { absoluteTimeRange, refreshKey } = useTimeRange();\n const variableState = useAllVariableValues();\n const datasourceStore = useDatasourceStore();\n\n return {\n timeRange: absoluteTimeRange,\n variableState,\n datasourceStore,\n refreshKey,\n };\n}\n\n/**\n * Get active time series queries for query results summary\n */\nexport function useActiveTimeSeriesQueries(): TimeSeriesDataQuery[] {\n const queryClient = useQueryClient();\n const queryCache = queryClient.getQueryCache();\n return getActiveTimeSeriesQueries(queryCache);\n}\n\n/**\n * Filter all cached queries down to only active time series queries\n */\nexport function getActiveTimeSeriesQueries(cache: QueryCache): TimeSeriesDataQuery[] {\n const queries: TimeSeriesDataQuery[] = [];\n\n for (const query of cache.findAll({ type: 'active' })) {\n const firstPart = query.queryKey?.[0] as UnknownSpec;\n if (firstPart?.kind && (firstPart.kind as string).startsWith(TIME_SERIES_QUERY_KEY)) {\n queries.push(query as Query<TimeSeriesData, unknown, TimeSeriesData, QueryKey>);\n }\n }\n\n return queries;\n}\n"],"names":["useQueries","useQuery","useQueryClient","useTimeRange","useDatasourceStore","usePlugin","usePluginRegistry","usePlugins","filterVariableStateMap","getVariableValuesKey","useAllVariableValues","TIME_SERIES_QUERY_KEY","getQueryOptions","plugin","definition","context","timeRange","datasourceStore","suggestedStepMs","mode","variableState","refreshKey","dependencies","dependsOn","spec","variableDependencies","variables","filteredVariabledState","variablesValueKey","queryKey","waitToLoad","some","v","loading","queryEnabled","undefined","useTimeSeriesQuery","options","queryOptions","data","kind","useTimeSeriesQueryContext","enabled","queryFn","Error","ctx","getTimeSeriesData","useTimeSeriesQueries","definitions","getPlugin","pluginLoaderResponse","map","d","queries","idx","absoluteTimeRange","useActiveTimeSeriesQueries","queryClient","queryCache","getQueryCache","getActiveTimeSeriesQueries","cache","query","findAll","type","firstPart","startsWith","push"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAGjC,SAKEA,UAAU,EACVC,QAAQ,EACRC,cAAc,QAET,wBAAwB;AAE/B,SAASC,YAAY,QAAQ,sBAAsB;AACnD,SAASC,kBAAkB,QAAQ,gBAAgB;AACnD,SAASC,SAAS,EAAEC,iBAAiB,EAAEC,UAAU,QAAQ,oBAAoB;AAC7E,SAASC,sBAAsB,EAAEC,oBAAoB,QAAQ,UAAU;AACvE,SAASC,oBAAoB,QAAQ,cAAc;A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IACtB,MAAMO,kBAAkBb;IAExB,OAAO;QACLY,WAAWuC;QACXnC;QACAH;QACAI;IACF;AACF;AAEA;;CAEC,GACD,OAAO,SAASmC;IACd,MAAMC,cAAcvD;IACpB,MAAMwD,aAAaD,YAAYE,aAAa;IAC5C,OAAOC,2BAA2BF;AACpC;AAEA;;CAEC,GACD,OAAO,SAASE,2BAA2BC,KAAiB;IAC1D,MAAMR,UAAiC,EAAE;IAEzC,KAAK,MAAMS,SAASD,MAAME,OAAO,CAAC;QAAEC,MAAM;IAAS,GAAI;QACrD,MAAMC,YAAYH,MAAMjC,QAAQ,EAAE,CAAC,EAAE;QACrC,IAAIoC,WAAWzB,QAAQ,AAACyB,UAAUzB,IAAI,CAAY0B,UAAU,CAACvD,wBAAwB;YACnF0C,QAAQc,IAAI,CAACL;QACf;IACF;IAEA,OAAOT;AACT"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/runtime/trace-queries.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 { getUnixTime } from 'date-fns';\nimport { QueryDefinition, UnknownSpec, AbsoluteTimeRange, TraceData } from '@perses-dev/core';\nimport { QueryKey, useQueries, UseQueryResult } from '@tanstack/react-query';\nimport { TraceQueryContext, TraceQueryPlugin } from '../model';\nimport { useDatasourceStore } from './datasources';\nimport { usePluginRegistry, usePlugins } from './plugin-registry';\nimport { useTimeRange } from './TimeRangeProvider';\nimport { useAllVariableValues } from './variables';\nimport { filterVariableStateMap, getVariableValuesKey } from './utils';\nexport type TraceQueryDefinition<PluginSpec = UnknownSpec> = QueryDefinition<'TraceQuery', PluginSpec>;\nexport const TRACE_QUERY_KEY = 'TraceQuery';\n\nexport function getUnixTimeRange(timeRange: AbsoluteTimeRange): { start: number; end: number } {\n const { start, end } = timeRange;\n return {\n start: Math.ceil(getUnixTime(start)),\n end: Math.ceil(getUnixTime(end)),\n };\n}\n\n/**\n * Run a trace query using a TraceQuery plugin and return the results\n * @param definitions: dashboard defintion for a trace query, written in Trace Query Language (TraceQL)\n * Documentation for TraceQL: https://grafana.com/docs/tempo/latest/traceql/\n */\nexport function useTraceQueries(definitions: TraceQueryDefinition[]): Array<UseQueryResult<TraceData>> {\n const { getPlugin } = usePluginRegistry();\n const context = useTraceQueryContext();\n\n const pluginLoaderResponse = usePlugins(\n 'TraceQuery',\n definitions.map((d) => ({ kind: d.spec.plugin.kind }))\n );\n\n // useQueries() handles data fetching from query plugins (e.g. traceQL queries, promQL queries)\n // https://tanstack.com/query/v4/docs/react/reference/useQuery\n return useQueries({\n queries: definitions.map((definition, idx) => {\n const plugin = pluginLoaderResponse[idx]?.data;\n const { queryEnabled, queryKey } = getQueryOptions({ context, definition, plugin });\n const traceQueryKind = definition?.spec?.plugin?.kind;\n return {\n enabled: queryEnabled,\n queryKey: queryKey,\n queryFn: async (): Promise<TraceData> => {\n const plugin = await getPlugin(TRACE_QUERY_KEY, traceQueryKind);\n const data = await plugin.getTraceData(definition.spec.plugin.spec, context);\n return data;\n },\n };\n }),\n });\n}\n\nfunction getQueryOptions({\n plugin,\n definition,\n context,\n}: {\n plugin?: TraceQueryPlugin;\n definition: TraceQueryDefinition;\n context: TraceQueryContext;\n}): {\n queryKey: QueryKey;\n queryEnabled: boolean;\n} {\n const { datasourceStore, variableState, absoluteTimeRange } = context;\n\n const dependencies = plugin?.dependsOn ? plugin.dependsOn(definition.spec.plugin.spec, context) : {};\n const variableDependencies = dependencies?.variables;\n\n const filteredVariabledState = filterVariableStateMap(variableState, variableDependencies);\n const variablesValueKey = getVariableValuesKey(filteredVariabledState);\n const queryKey = [definition, datasourceStore, absoluteTimeRange, variablesValueKey] as const;\n\n let waitToLoad = false;\n if (variableDependencies) {\n waitToLoad = variableDependencies.some((v) => variableState[v]?.loading);\n }\n\n const queryEnabled = plugin !== undefined && !waitToLoad;\n return {\n queryKey,\n queryEnabled,\n };\n}\n\nfunction useTraceQueryContext(): TraceQueryContext {\n const { absoluteTimeRange } = useTimeRange();\n const variableState = useAllVariableValues();\n const datasourceStore = useDatasourceStore();\n\n return {\n variableState,\n datasourceStore,\n absoluteTimeRange,\n };\n}\n"],"names":["getUnixTime","useQueries","useDatasourceStore","usePluginRegistry","usePlugins","useTimeRange","useAllVariableValues","filterVariableStateMap","getVariableValuesKey","TRACE_QUERY_KEY","getUnixTimeRange","timeRange","start","end","Math","ceil","useTraceQueries","definitions","getPlugin","context","useTraceQueryContext","pluginLoaderResponse","map","d","kind","spec","plugin","queries","definition","idx","data","queryEnabled","queryKey","getQueryOptions","traceQueryKind","enabled","queryFn","getTraceData","datasourceStore","variableState","absoluteTimeRange","dependencies","dependsOn","variableDependencies","variables","filteredVariabledState","variablesValueKey","waitToLoad","some","v","loading","undefined"],"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,WAAW,QAAQ,WAAW;AAEvC,SAAmBC,UAAU,QAAwB,wBAAwB;AAE7E,SAASC,kBAAkB,QAAQ,gBAAgB;AACnD,SAASC,iBAAiB,EAAEC,UAAU,QAAQ,oBAAoB;AAClE,SAASC,YAAY,QAAQ,sBAAsB;AACnD,SAASC,oBAAoB,QAAQ,cAAc;AACnD,SAASC,sBAAsB,EAAEC,oBAAoB,QAAQ,UAAU;AAEvE,OAAO,MAAMC,kBAAkB,aAAa;AAE5C,OAAO,SAASC,iBAAiBC,SAA4B;IAC3D,MAAM,EAAEC,KAA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AAMG,oBAAoBtC,qBAAqBqC;IAC/C,MAAMb,WAAW;QAACJ;QAAYU;QAAiBE;QAAmBM;KAAkB;IAEpF,IAAIC,aAAa;IACjB,IAAIJ,sBAAsB;QACxBI,aAAaJ,qBAAqBK,IAAI,CAAC,CAACC,IAAMV,aAAa,CAACU,EAAE,EAAEC;IAClE;IAEA,MAAMnB,eAAeL,WAAWyB,aAAa,CAACJ;IAC9C,OAAO;QACLf;QACAD;IACF;AACF;AAEA,SAASX;IACP,MAAM,EAAEoB,iBAAiB,EAAE,GAAGnC;IAC9B,MAAMkC,gBAAgBjC;IACtB,MAAMgC,kBAAkBpC;IAExB,OAAO;QACLqC;QACAD;QACAE;IACF;AACF"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/runtime/utils.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 { VariableStateMap } from './variables';\n\nexport function filterVariableStateMap(v: VariableStateMap, names?: string[]): VariableStateMap {\n if (!names) {\n return v;\n }\n return Object.fromEntries(Object.entries(v).filter(([name]) => names.includes(name)));\n}\n\n/**\n * Returns a serialized string of the current state of variable values.\n */\nexport function getVariableValuesKey(v: VariableStateMap): string {\n return Object.values(v)\n .map((v) => JSON.stringify(v.value))\n .join(',');\n}\n"],"names":["filterVariableStateMap","v","names","Object","fromEntries","entries","filter","name","includes","getVariableValuesKey","values","map","JSON","stringify","value","join"],"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;AAIjC,OAAO,SAASA,uBAAuBC,CAAmB,EAAEC,KAAgB;IAC1E,IAAI,CAACA,OAAO;QACV,OAAOD;IACT;IACA,OAAOE,OAAOC,WAAW,CAACD,OAAOE,OAAO,CAACJ,GAAGK,MAAM,CAAC,CAAC,CAACC,KAAK,GAAKL,MAAMM,QAAQ,CAACD;AAChF;AAEA;;CAEC,GACD,OAAO,SAASE,qBAAqBR,CAAmB;IACtD,OAAOE,OAAOO,MAAM,CAACT,GAClBU,GAAG,CAAC,CAACV,IAAMW,KAAKC,SAAS,CAACZ,EAAEa,KAAK,GACjCC,IAAI,CAAC;AACV"}