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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (400) hide show
  1. package/dist/cjs/components/DatasourceEditorForm/DatasourceEditorForm.js +82 -162
  2. package/dist/cjs/components/DatasourceSelect.js +8 -13
  3. package/dist/cjs/components/HTTPSettingsEditor/HTTPSettingsEditor.js +528 -0
  4. package/dist/cjs/components/{TimeSeriesQueryEditor → HTTPSettingsEditor}/index.js +2 -2
  5. package/dist/cjs/components/LegendOptionsEditor/LegendOptionsEditor.js +8 -7
  6. package/dist/cjs/components/MetricLabelInput/MetricLabelInput.js +41 -0
  7. package/dist/cjs/components/{TraceQueryEditor → MetricLabelInput}/index.js +2 -2
  8. package/dist/cjs/components/{TimeSeriesQueryEditor/TimeSeriesQueryEditor.js → MultiQueryEditor/MultiQueryEditor.js} +22 -18
  9. package/dist/cjs/components/{TimeSeriesQueryEditor/TimeSeriesQueryInput.js → MultiQueryEditor/QueryEditorContainer.js} +23 -11
  10. package/dist/cjs/{validation/duration.js → components/MultiQueryEditor/index.js} +14 -9
  11. package/dist/cjs/components/PanelSpecEditor/PanelSpecEditor.js +51 -59
  12. package/dist/cjs/components/PluginEditor/PluginEditor.js +16 -13
  13. package/dist/cjs/components/PluginEditor/plugin-editor-api.js +43 -32
  14. package/dist/cjs/components/PluginKindSelect/PluginKindSelect.js +55 -7
  15. package/dist/cjs/components/PluginRegistry/PluginRegistry.js +8 -9
  16. package/dist/cjs/components/PluginRegistry/plugin-indexes.js +17 -14
  17. package/dist/cjs/components/PluginSpecEditor/PluginSpecEditor.js +1 -1
  18. package/dist/cjs/components/ProjectSelect.js +5 -5
  19. package/dist/cjs/components/TimeRangeControls/TimeRangeControls.js +10 -71
  20. package/dist/cjs/components/Variables/VariableEditorForm/VariableEditorForm.js +391 -442
  21. package/dist/cjs/components/Variables/VariableEditorForm/VariablePreview.js +7 -7
  22. package/dist/cjs/components/Variables/VariableEditorForm/variable-editor-form-model.js +6 -11
  23. package/dist/cjs/components/Variables/variable-model.js +26 -27
  24. package/dist/cjs/components/index.js +3 -1
  25. package/dist/cjs/context/ProjectStoreProvider.js +7 -4
  26. package/dist/cjs/context/ValidationProvider.js +69 -0
  27. package/dist/cjs/context/index.js +1 -0
  28. package/dist/cjs/index.js +1 -1
  29. package/dist/{components/TraceQueryEditor/index.js → cjs/model/explore.js} +4 -3
  30. package/dist/cjs/remote/PersesPlugin.types.js +16 -0
  31. package/dist/cjs/remote/PluginLoaderComponent.js +75 -0
  32. package/dist/cjs/remote/PluginRuntime.js +267 -0
  33. package/dist/cjs/{validation → remote}/index.js +2 -5
  34. package/dist/cjs/remote/remotePluginLoader.js +61 -0
  35. package/dist/cjs/runtime/DataQueriesProvider/DataQueriesProvider.js +18 -9
  36. package/dist/cjs/runtime/DataQueriesProvider/model.js +9 -8
  37. package/dist/cjs/runtime/QueryCountProvider.js +83 -0
  38. package/dist/cjs/runtime/TimeRangeProvider/TimeRangeProvider.js +17 -4
  39. package/dist/cjs/runtime/TimeRangeProvider/TimeRangeSettingsProvider.js +100 -0
  40. package/dist/cjs/runtime/TimeRangeProvider/index.js +2 -1
  41. package/dist/cjs/runtime/TimeRangeProvider/query-params.js +4 -7
  42. package/dist/cjs/runtime/UsageMetricsProvider.js +99 -0
  43. package/dist/cjs/runtime/builtin-variables.js +2 -2
  44. package/dist/cjs/runtime/datasources.js +23 -14
  45. package/dist/cjs/runtime/index.js +4 -2
  46. package/dist/cjs/runtime/plugin-registry.js +36 -24
  47. package/dist/cjs/runtime/time-series-queries.js +23 -28
  48. package/dist/cjs/runtime/trace-queries.js +6 -3
  49. package/dist/cjs/runtime/{template-variables.js → variables.js} +29 -47
  50. package/dist/cjs/stories/shared-utils/decorators/WithDataQueries.js +1 -1
  51. package/dist/cjs/stories/shared-utils/decorators/WithPluginRegistry.js +1 -67
  52. package/dist/cjs/stories/shared-utils/decorators/WithPluginSystemBuiltinVariables.js +1 -1
  53. package/dist/cjs/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.js +4 -4
  54. package/dist/cjs/stories/shared-utils/decorators/{WithPluginSystemTemplateVariables.js → WithPluginSystemVariables.js} +9 -9
  55. package/dist/cjs/stories/shared-utils/decorators/WithTimeRange.js +1 -1
  56. package/dist/cjs/stories/shared-utils/decorators/index.js +2 -2
  57. package/dist/cjs/test/mock-data.js +25 -4
  58. package/dist/cjs/test/render.js +2 -11
  59. package/dist/cjs/test/test-plugins/bert/index.js +20 -19
  60. package/dist/cjs/test-utils/mock-plugin-registry.js +10 -10
  61. package/dist/cjs/utils/variables.js +24 -24
  62. package/dist/components/CalculationSelector/CalculationSelector.d.ts +2 -1
  63. package/dist/components/CalculationSelector/CalculationSelector.d.ts.map +1 -1
  64. package/dist/components/CalculationSelector/CalculationSelector.js.map +1 -1
  65. package/dist/components/DatasourceEditorForm/DatasourceEditorForm.d.ts +6 -5
  66. package/dist/components/DatasourceEditorForm/DatasourceEditorForm.d.ts.map +1 -1
  67. package/dist/components/DatasourceEditorForm/DatasourceEditorForm.js +85 -165
  68. package/dist/components/DatasourceEditorForm/DatasourceEditorForm.js.map +1 -1
  69. package/dist/components/DatasourceSelect.d.ts +3 -2
  70. package/dist/components/DatasourceSelect.d.ts.map +1 -1
  71. package/dist/components/DatasourceSelect.js +8 -13
  72. package/dist/components/DatasourceSelect.js.map +1 -1
  73. package/dist/components/HTTPSettingsEditor/HTTPSettingsEditor.d.ts +11 -0
  74. package/dist/components/HTTPSettingsEditor/HTTPSettingsEditor.d.ts.map +1 -0
  75. package/dist/components/HTTPSettingsEditor/HTTPSettingsEditor.js +474 -0
  76. package/dist/components/HTTPSettingsEditor/HTTPSettingsEditor.js.map +1 -0
  77. package/dist/components/HTTPSettingsEditor/index.d.ts +2 -0
  78. package/dist/components/HTTPSettingsEditor/index.d.ts.map +1 -0
  79. package/dist/{validation/duration.js → components/HTTPSettingsEditor/index.js} +2 -4
  80. package/dist/components/HTTPSettingsEditor/index.js.map +1 -0
  81. package/dist/components/LegendOptionsEditor/LegendOptionsEditor.d.ts +3 -1
  82. package/dist/components/LegendOptionsEditor/LegendOptionsEditor.d.ts.map +1 -1
  83. package/dist/components/LegendOptionsEditor/LegendOptionsEditor.js +10 -9
  84. package/dist/components/LegendOptionsEditor/LegendOptionsEditor.js.map +1 -1
  85. package/dist/components/MetricLabelInput/MetricLabelInput.d.ts +7 -0
  86. package/dist/components/MetricLabelInput/MetricLabelInput.d.ts.map +1 -0
  87. package/dist/components/MetricLabelInput/MetricLabelInput.js +33 -0
  88. package/dist/components/MetricLabelInput/MetricLabelInput.js.map +1 -0
  89. package/dist/components/MetricLabelInput/index.d.ts +2 -0
  90. package/dist/components/MetricLabelInput/index.d.ts.map +1 -0
  91. package/dist/components/MetricLabelInput/index.js +15 -0
  92. package/dist/components/MetricLabelInput/index.js.map +1 -0
  93. package/dist/components/MultiQueryEditor/MultiQueryEditor.d.ts +17 -0
  94. package/dist/components/MultiQueryEditor/MultiQueryEditor.d.ts.map +1 -0
  95. package/dist/components/{TimeSeriesQueryEditor/TimeSeriesQueryEditor.js → MultiQueryEditor/MultiQueryEditor.js} +29 -18
  96. package/dist/components/MultiQueryEditor/MultiQueryEditor.js.map +1 -0
  97. package/dist/components/MultiQueryEditor/QueryEditorContainer.d.ts +29 -0
  98. package/dist/components/MultiQueryEditor/QueryEditorContainer.d.ts.map +1 -0
  99. package/dist/components/{TimeSeriesQueryEditor/TimeSeriesQueryInput.js → MultiQueryEditor/QueryEditorContainer.js} +33 -10
  100. package/dist/components/MultiQueryEditor/QueryEditorContainer.js.map +1 -0
  101. package/dist/components/MultiQueryEditor/index.d.ts +2 -0
  102. package/dist/components/MultiQueryEditor/index.d.ts.map +1 -0
  103. package/dist/components/MultiQueryEditor/index.js +15 -0
  104. package/dist/components/{TraceQueryEditor → MultiQueryEditor}/index.js.map +1 -1
  105. package/dist/components/OptionsEditorRadios/OptionsEditorRadios.d.ts +2 -2
  106. package/dist/components/OptionsEditorRadios/OptionsEditorRadios.d.ts.map +1 -1
  107. package/dist/components/OptionsEditorRadios/OptionsEditorRadios.js.map +1 -1
  108. package/dist/components/OptionsEditorTabPanel/OptionsEditorTabPanel.d.ts +2 -2
  109. package/dist/components/OptionsEditorTabPanel/OptionsEditorTabPanel.d.ts.map +1 -1
  110. package/dist/components/OptionsEditorTabPanel/OptionsEditorTabPanel.js.map +1 -1
  111. package/dist/components/OptionsEditorTabs/OptionsEditorTabs.d.ts +3 -3
  112. package/dist/components/OptionsEditorTabs/OptionsEditorTabs.d.ts.map +1 -1
  113. package/dist/components/OptionsEditorTabs/OptionsEditorTabs.js.map +1 -1
  114. package/dist/components/PanelSpecEditor/PanelSpecEditor.d.ts +5 -2
  115. package/dist/components/PanelSpecEditor/PanelSpecEditor.d.ts.map +1 -1
  116. package/dist/components/PanelSpecEditor/PanelSpecEditor.js +53 -61
  117. package/dist/components/PanelSpecEditor/PanelSpecEditor.js.map +1 -1
  118. package/dist/components/PluginEditor/PluginEditor.d.ts +2 -1
  119. package/dist/components/PluginEditor/PluginEditor.d.ts.map +1 -1
  120. package/dist/components/PluginEditor/PluginEditor.js +16 -13
  121. package/dist/components/PluginEditor/PluginEditor.js.map +1 -1
  122. package/dist/components/PluginEditor/plugin-editor-api.d.ts +15 -8
  123. package/dist/components/PluginEditor/plugin-editor-api.d.ts.map +1 -1
  124. package/dist/components/PluginEditor/plugin-editor-api.js +43 -32
  125. package/dist/components/PluginEditor/plugin-editor-api.js.map +1 -1
  126. package/dist/components/PluginKindSelect/PluginKindSelect.d.ts +10 -4
  127. package/dist/components/PluginKindSelect/PluginKindSelect.d.ts.map +1 -1
  128. package/dist/components/PluginKindSelect/PluginKindSelect.js +61 -10
  129. package/dist/components/PluginKindSelect/PluginKindSelect.js.map +1 -1
  130. package/dist/components/PluginRegistry/PluginRegistry.d.ts +2 -2
  131. package/dist/components/PluginRegistry/PluginRegistry.d.ts.map +1 -1
  132. package/dist/components/PluginRegistry/PluginRegistry.js +8 -9
  133. package/dist/components/PluginRegistry/PluginRegistry.js.map +1 -1
  134. package/dist/components/PluginRegistry/plugin-indexes.d.ts +4 -4
  135. package/dist/components/PluginRegistry/plugin-indexes.d.ts.map +1 -1
  136. package/dist/components/PluginRegistry/plugin-indexes.js +17 -14
  137. package/dist/components/PluginRegistry/plugin-indexes.js.map +1 -1
  138. package/dist/components/PluginSpecEditor/PluginSpecEditor.d.ts +5 -4
  139. package/dist/components/PluginSpecEditor/PluginSpecEditor.d.ts.map +1 -1
  140. package/dist/components/PluginSpecEditor/PluginSpecEditor.js +1 -1
  141. package/dist/components/PluginSpecEditor/PluginSpecEditor.js.map +1 -1
  142. package/dist/components/ProjectSelect.d.ts +2 -1
  143. package/dist/components/ProjectSelect.d.ts.map +1 -1
  144. package/dist/components/ProjectSelect.js +5 -5
  145. package/dist/components/ProjectSelect.js.map +1 -1
  146. package/dist/components/TimeRangeControls/TimeRangeControls.d.ts +3 -2
  147. package/dist/components/TimeRangeControls/TimeRangeControls.d.ts.map +1 -1
  148. package/dist/components/TimeRangeControls/TimeRangeControls.js +12 -70
  149. package/dist/components/TimeRangeControls/TimeRangeControls.js.map +1 -1
  150. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts +4 -3
  151. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts.map +1 -1
  152. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js +395 -446
  153. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js.map +1 -1
  154. package/dist/components/Variables/VariableEditorForm/VariablePreview.d.ts +3 -2
  155. package/dist/components/Variables/VariableEditorForm/VariablePreview.d.ts.map +1 -1
  156. package/dist/components/Variables/VariableEditorForm/VariablePreview.js +7 -7
  157. package/dist/components/Variables/VariableEditorForm/VariablePreview.js.map +1 -1
  158. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.d.ts +2 -2
  159. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.d.ts.map +1 -1
  160. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js +6 -11
  161. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js.map +1 -1
  162. package/dist/components/Variables/variable-model.d.ts +2 -1
  163. package/dist/components/Variables/variable-model.d.ts.map +1 -1
  164. package/dist/components/Variables/variable-model.js +27 -28
  165. package/dist/components/Variables/variable-model.js.map +1 -1
  166. package/dist/components/index.d.ts +3 -1
  167. package/dist/components/index.d.ts.map +1 -1
  168. package/dist/components/index.js +3 -1
  169. package/dist/components/index.js.map +1 -1
  170. package/dist/context/ProjectStoreProvider.d.ts +4 -4
  171. package/dist/context/ProjectStoreProvider.d.ts.map +1 -1
  172. package/dist/context/ProjectStoreProvider.js +7 -4
  173. package/dist/context/ProjectStoreProvider.js.map +1 -1
  174. package/dist/context/ValidationProvider.d.ts +19 -0
  175. package/dist/context/ValidationProvider.d.ts.map +1 -0
  176. package/dist/context/ValidationProvider.js +52 -0
  177. package/dist/context/ValidationProvider.js.map +1 -0
  178. package/dist/context/index.d.ts +1 -0
  179. package/dist/context/index.d.ts.map +1 -1
  180. package/dist/context/index.js +1 -0
  181. package/dist/context/index.js.map +1 -1
  182. package/dist/context/query-params.d.ts.map +1 -1
  183. package/dist/context/query-params.js.map +1 -1
  184. package/dist/index.d.ts +1 -1
  185. package/dist/index.d.ts.map +1 -1
  186. package/dist/index.js +1 -1
  187. package/dist/index.js.map +1 -1
  188. package/dist/model/explore.d.ts +13 -0
  189. package/dist/model/explore.d.ts.map +1 -0
  190. package/dist/{validation/index.js → model/explore.js} +4 -6
  191. package/dist/model/explore.js.map +1 -0
  192. package/dist/model/legend.d.ts.map +1 -1
  193. package/dist/model/legend.js.map +1 -1
  194. package/dist/model/panels.d.ts +16 -4
  195. package/dist/model/panels.d.ts.map +1 -1
  196. package/dist/model/panels.js.map +1 -1
  197. package/dist/model/plugin-loading.js.map +1 -1
  198. package/dist/model/plugins.d.ts +31 -17
  199. package/dist/model/plugins.d.ts.map +1 -1
  200. package/dist/model/plugins.js.map +1 -1
  201. package/dist/model/time-series-queries.d.ts +2 -1
  202. package/dist/model/time-series-queries.d.ts.map +1 -1
  203. package/dist/model/time-series-queries.js.map +1 -1
  204. package/dist/remote/PersesPlugin.types.d.ts +7 -0
  205. package/dist/remote/PersesPlugin.types.d.ts.map +1 -0
  206. package/dist/remote/PersesPlugin.types.js +15 -0
  207. package/dist/remote/PersesPlugin.types.js.map +1 -0
  208. package/dist/remote/PluginLoaderComponent.d.ts +10 -0
  209. package/dist/remote/PluginLoaderComponent.d.ts.map +1 -0
  210. package/dist/remote/PluginLoaderComponent.js +67 -0
  211. package/dist/remote/PluginLoaderComponent.js.map +1 -0
  212. package/dist/remote/PluginRuntime.d.ts +11 -0
  213. package/dist/remote/PluginRuntime.d.ts.map +1 -0
  214. package/dist/remote/PluginRuntime.js +202 -0
  215. package/dist/remote/PluginRuntime.js.map +1 -0
  216. package/dist/remote/index.d.ts +3 -0
  217. package/dist/remote/index.d.ts.map +1 -0
  218. package/dist/{components/TimeSeriesQueryEditor → remote}/index.js +2 -1
  219. package/dist/remote/index.js.map +1 -0
  220. package/dist/remote/remotePluginLoader.d.ts +3 -0
  221. package/dist/remote/remotePluginLoader.d.ts.map +1 -0
  222. package/dist/remote/remotePluginLoader.js +53 -0
  223. package/dist/remote/remotePluginLoader.js.map +1 -0
  224. package/dist/runtime/DataQueriesProvider/DataQueriesProvider.d.ts +2 -2
  225. package/dist/runtime/DataQueriesProvider/DataQueriesProvider.d.ts.map +1 -1
  226. package/dist/runtime/DataQueriesProvider/DataQueriesProvider.js +18 -9
  227. package/dist/runtime/DataQueriesProvider/DataQueriesProvider.js.map +1 -1
  228. package/dist/runtime/DataQueriesProvider/model.d.ts +5 -6
  229. package/dist/runtime/DataQueriesProvider/model.d.ts.map +1 -1
  230. package/dist/runtime/DataQueriesProvider/model.js +9 -8
  231. package/dist/runtime/DataQueriesProvider/model.js.map +1 -1
  232. package/dist/runtime/QueryCountProvider.d.ts +9 -0
  233. package/dist/runtime/QueryCountProvider.d.ts.map +1 -0
  234. package/dist/{validation/datasource.js → runtime/QueryCountProvider.js} +14 -10
  235. package/dist/runtime/QueryCountProvider.js.map +1 -0
  236. package/dist/runtime/TimeRangeProvider/TimeRangeProvider.d.ts +2 -2
  237. package/dist/runtime/TimeRangeProvider/TimeRangeProvider.d.ts.map +1 -1
  238. package/dist/runtime/TimeRangeProvider/TimeRangeProvider.js +17 -4
  239. package/dist/runtime/TimeRangeProvider/TimeRangeProvider.js.map +1 -1
  240. package/dist/runtime/TimeRangeProvider/TimeRangeProviderWithQueryParams.d.ts +2 -2
  241. package/dist/runtime/TimeRangeProvider/TimeRangeProviderWithQueryParams.d.ts.map +1 -1
  242. package/dist/runtime/TimeRangeProvider/TimeRangeProviderWithQueryParams.js.map +1 -1
  243. package/dist/runtime/TimeRangeProvider/TimeRangeSettingsProvider.d.ts +32 -0
  244. package/dist/runtime/TimeRangeProvider/TimeRangeSettingsProvider.d.ts.map +1 -0
  245. package/dist/runtime/TimeRangeProvider/TimeRangeSettingsProvider.js +82 -0
  246. package/dist/runtime/TimeRangeProvider/TimeRangeSettingsProvider.js.map +1 -0
  247. package/dist/runtime/TimeRangeProvider/index.d.ts +1 -0
  248. package/dist/runtime/TimeRangeProvider/index.d.ts.map +1 -1
  249. package/dist/runtime/TimeRangeProvider/index.js +2 -1
  250. package/dist/runtime/TimeRangeProvider/index.js.map +1 -1
  251. package/dist/runtime/TimeRangeProvider/query-params.d.ts.map +1 -1
  252. package/dist/runtime/TimeRangeProvider/query-params.js +4 -7
  253. package/dist/runtime/TimeRangeProvider/query-params.js.map +1 -1
  254. package/dist/runtime/TimeRangeProvider/refresh-interval.d.ts.map +1 -1
  255. package/dist/runtime/TimeRangeProvider/refresh-interval.js.map +1 -1
  256. package/dist/runtime/UsageMetricsProvider.d.ts +25 -0
  257. package/dist/runtime/UsageMetricsProvider.d.ts.map +1 -0
  258. package/dist/runtime/UsageMetricsProvider.js +77 -0
  259. package/dist/runtime/UsageMetricsProvider.js.map +1 -0
  260. package/dist/runtime/builtin-variables.d.ts +1 -1
  261. package/dist/runtime/builtin-variables.d.ts.map +1 -1
  262. package/dist/runtime/builtin-variables.js +2 -2
  263. package/dist/runtime/builtin-variables.js.map +1 -1
  264. package/dist/runtime/datasources.d.ts +5 -4
  265. package/dist/runtime/datasources.d.ts.map +1 -1
  266. package/dist/runtime/datasources.js +23 -14
  267. package/dist/runtime/datasources.js.map +1 -1
  268. package/dist/runtime/index.d.ts +3 -1
  269. package/dist/runtime/index.d.ts.map +1 -1
  270. package/dist/runtime/index.js +4 -2
  271. package/dist/runtime/index.js.map +1 -1
  272. package/dist/runtime/plugin-registry.d.ts +10 -10
  273. package/dist/runtime/plugin-registry.d.ts.map +1 -1
  274. package/dist/runtime/plugin-registry.js +36 -24
  275. package/dist/runtime/plugin-registry.js.map +1 -1
  276. package/dist/runtime/time-series-queries.d.ts +5 -4
  277. package/dist/runtime/time-series-queries.d.ts.map +1 -1
  278. package/dist/runtime/time-series-queries.js +23 -28
  279. package/dist/runtime/time-series-queries.js.map +1 -1
  280. package/dist/runtime/trace-queries.d.ts +4 -3
  281. package/dist/runtime/trace-queries.d.ts.map +1 -1
  282. package/dist/runtime/trace-queries.js +7 -4
  283. package/dist/runtime/trace-queries.js.map +1 -1
  284. package/dist/runtime/{template-variables.d.ts → variables.d.ts} +4 -4
  285. package/dist/runtime/variables.d.ts.map +1 -0
  286. package/dist/runtime/{template-variables.js → variables.js} +28 -45
  287. package/dist/runtime/variables.js.map +1 -0
  288. package/dist/stories/shared-utils/decorators/WithDataQueries.d.ts +2 -1
  289. package/dist/stories/shared-utils/decorators/WithDataQueries.d.ts.map +1 -1
  290. package/dist/stories/shared-utils/decorators/WithDataQueries.js +1 -1
  291. package/dist/stories/shared-utils/decorators/WithDataQueries.js.map +1 -1
  292. package/dist/stories/shared-utils/decorators/WithPluginRegistry.d.ts +2 -1
  293. package/dist/stories/shared-utils/decorators/WithPluginRegistry.d.ts.map +1 -1
  294. package/dist/stories/shared-utils/decorators/WithPluginRegistry.js +2 -22
  295. package/dist/stories/shared-utils/decorators/WithPluginRegistry.js.map +1 -1
  296. package/dist/stories/shared-utils/decorators/WithPluginSystemBuiltinVariables.d.ts +2 -1
  297. package/dist/stories/shared-utils/decorators/WithPluginSystemBuiltinVariables.d.ts.map +1 -1
  298. package/dist/stories/shared-utils/decorators/WithPluginSystemBuiltinVariables.js +1 -1
  299. package/dist/stories/shared-utils/decorators/WithPluginSystemBuiltinVariables.js.map +1 -1
  300. package/dist/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.d.ts +2 -1
  301. package/dist/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.d.ts.map +1 -1
  302. package/dist/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.js +4 -4
  303. package/dist/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.js.map +1 -1
  304. package/dist/stories/shared-utils/decorators/WithPluginSystemVariables.d.ts +13 -0
  305. package/dist/stories/shared-utils/decorators/WithPluginSystemVariables.d.ts.map +1 -0
  306. package/dist/stories/shared-utils/decorators/{WithPluginSystemTemplateVariables.js → WithPluginSystemVariables.js} +10 -10
  307. package/dist/stories/shared-utils/decorators/WithPluginSystemVariables.js.map +1 -0
  308. package/dist/stories/shared-utils/decorators/WithTimeRange.d.ts +2 -1
  309. package/dist/stories/shared-utils/decorators/WithTimeRange.d.ts.map +1 -1
  310. package/dist/stories/shared-utils/decorators/WithTimeRange.js +1 -1
  311. package/dist/stories/shared-utils/decorators/WithTimeRange.js.map +1 -1
  312. package/dist/stories/shared-utils/decorators/index.d.ts +1 -1
  313. package/dist/stories/shared-utils/decorators/index.d.ts.map +1 -1
  314. package/dist/stories/shared-utils/decorators/index.js +2 -2
  315. package/dist/stories/shared-utils/decorators/index.js.map +1 -1
  316. package/dist/test/mock-data.d.ts.map +1 -1
  317. package/dist/test/mock-data.js +25 -4
  318. package/dist/test/mock-data.js.map +1 -1
  319. package/dist/test/render.d.ts +3 -3
  320. package/dist/test/render.d.ts.map +1 -1
  321. package/dist/test/render.js +2 -11
  322. package/dist/test/render.js.map +1 -1
  323. package/dist/test/test-plugins/bert/index.d.ts.map +1 -1
  324. package/dist/test/test-plugins/bert/index.js +20 -19
  325. package/dist/test/test-plugins/bert/index.js.map +1 -1
  326. package/dist/test-utils/mock-plugin-registry.d.ts +5 -3
  327. package/dist/test-utils/mock-plugin-registry.d.ts.map +1 -1
  328. package/dist/test-utils/mock-plugin-registry.js +10 -10
  329. package/dist/test-utils/mock-plugin-registry.js.map +1 -1
  330. package/dist/utils/variables.d.ts +4 -4
  331. package/dist/utils/variables.d.ts.map +1 -1
  332. package/dist/utils/variables.js +19 -19
  333. package/dist/utils/variables.js.map +1 -1
  334. package/package.json +7 -6
  335. package/dist/cjs/components/TraceQueryEditor/TraceQueryEditor.js +0 -143
  336. package/dist/cjs/components/TraceQueryEditor/TraceQueryInput.js +0 -96
  337. package/dist/cjs/validation/datasource.js +0 -30
  338. package/dist/cjs/validation/resource.js +0 -24
  339. package/dist/cjs/validation/role.js +0 -86
  340. package/dist/cjs/validation/rolebinding.js +0 -55
  341. package/dist/cjs/validation/secret.js +0 -176
  342. package/dist/cjs/validation/user.js +0 -46
  343. package/dist/cjs/validation/variable.js +0 -48
  344. package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryEditor.d.ts +0 -7
  345. package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryEditor.d.ts.map +0 -1
  346. package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryEditor.js.map +0 -1
  347. package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryInput.d.ts +0 -12
  348. package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryInput.d.ts.map +0 -1
  349. package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryInput.js.map +0 -1
  350. package/dist/components/TimeSeriesQueryEditor/index.d.ts +0 -2
  351. package/dist/components/TimeSeriesQueryEditor/index.d.ts.map +0 -1
  352. package/dist/components/TimeSeriesQueryEditor/index.js.map +0 -1
  353. package/dist/components/TraceQueryEditor/TraceQueryEditor.d.ts +0 -8
  354. package/dist/components/TraceQueryEditor/TraceQueryEditor.d.ts.map +0 -1
  355. package/dist/components/TraceQueryEditor/TraceQueryEditor.js +0 -130
  356. package/dist/components/TraceQueryEditor/TraceQueryEditor.js.map +0 -1
  357. package/dist/components/TraceQueryEditor/TraceQueryInput.d.ts +0 -12
  358. package/dist/components/TraceQueryEditor/TraceQueryInput.d.ts.map +0 -1
  359. package/dist/components/TraceQueryEditor/TraceQueryInput.js +0 -83
  360. package/dist/components/TraceQueryEditor/TraceQueryInput.js.map +0 -1
  361. package/dist/components/TraceQueryEditor/index.d.ts +0 -2
  362. package/dist/components/TraceQueryEditor/index.d.ts.map +0 -1
  363. package/dist/runtime/template-variables.d.ts.map +0 -1
  364. package/dist/runtime/template-variables.js.map +0 -1
  365. package/dist/stories/shared-utils/decorators/WithPluginSystemTemplateVariables.d.ts +0 -12
  366. package/dist/stories/shared-utils/decorators/WithPluginSystemTemplateVariables.d.ts.map +0 -1
  367. package/dist/stories/shared-utils/decorators/WithPluginSystemTemplateVariables.js.map +0 -1
  368. package/dist/validation/datasource.d.ts +0 -19
  369. package/dist/validation/datasource.d.ts.map +0 -1
  370. package/dist/validation/datasource.js.map +0 -1
  371. package/dist/validation/duration.d.ts +0 -3
  372. package/dist/validation/duration.d.ts.map +0 -1
  373. package/dist/validation/duration.js.map +0 -1
  374. package/dist/validation/index.d.ts +0 -6
  375. package/dist/validation/index.d.ts.map +0 -1
  376. package/dist/validation/index.js.map +0 -1
  377. package/dist/validation/resource.d.ts +0 -3
  378. package/dist/validation/resource.d.ts.map +0 -1
  379. package/dist/validation/resource.js +0 -16
  380. package/dist/validation/resource.js.map +0 -1
  381. package/dist/validation/role.d.ts +0 -228
  382. package/dist/validation/role.d.ts.map +0 -1
  383. package/dist/validation/role.js +0 -67
  384. package/dist/validation/role.js.map +0 -1
  385. package/dist/validation/rolebinding.d.ts +0 -137
  386. package/dist/validation/rolebinding.d.ts.map +0 -1
  387. package/dist/validation/rolebinding.js +0 -47
  388. package/dist/validation/rolebinding.js.map +0 -1
  389. package/dist/validation/secret.d.ts +0 -964
  390. package/dist/validation/secret.d.ts.map +0 -1
  391. package/dist/validation/secret.js +0 -157
  392. package/dist/validation/secret.js.map +0 -1
  393. package/dist/validation/user.d.ts +0 -93
  394. package/dist/validation/user.d.ts.map +0 -1
  395. package/dist/validation/user.js +0 -38
  396. package/dist/validation/user.js.map +0 -1
  397. package/dist/validation/variable.d.ts +0 -96
  398. package/dist/validation/variable.d.ts.map +0 -1
  399. package/dist/validation/variable.js +0 -40
  400. package/dist/validation/variable.js.map +0 -1
@@ -0,0 +1,77 @@
1
+ // Copyright 2023 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ import { jsx as _jsx } from "react/jsx-runtime";
14
+ import { fetch } from '@perses-dev/core';
15
+ import { createContext, useContext } from 'react';
16
+ export const UsageMetricsContext = /*#__PURE__*/ createContext(undefined);
17
+ export const useUsageMetricsContext = ()=>{
18
+ return useContext(UsageMetricsContext);
19
+ };
20
+ export const useUsageMetrics = ()=>{
21
+ const ctx = useUsageMetricsContext();
22
+ return {
23
+ markQuery: (definition, newState)=>{
24
+ if (ctx === undefined) {
25
+ return;
26
+ }
27
+ const definitionKey = JSON.stringify(definition);
28
+ if (ctx.pendingQueries.has(definitionKey) && newState === 'pending') {
29
+ // Never allow transitions back to pending, to avoid re-sending stats on a re-render.
30
+ return;
31
+ }
32
+ if (ctx.pendingQueries.get(definitionKey) !== newState) {
33
+ ctx.pendingQueries.set(definitionKey, newState);
34
+ if (newState === 'error') {
35
+ ctx.renderErrorCount += 1;
36
+ }
37
+ const allDone = [
38
+ ...ctx.pendingQueries.values()
39
+ ].every((p)=>p !== 'pending');
40
+ if (ctx.renderDurationMs === 0 && allDone) {
41
+ ctx.renderDurationMs = Date.now() - ctx.startRenderTime;
42
+ submitMetrics(ctx);
43
+ }
44
+ }
45
+ }
46
+ };
47
+ };
48
+ const submitMetrics = async (stats)=>{
49
+ await fetch('/api/v1/view', {
50
+ method: 'POST',
51
+ headers: {
52
+ 'Content-Type': 'application/json'
53
+ },
54
+ body: JSON.stringify({
55
+ project: stats.project,
56
+ dashboard: stats.dashboard,
57
+ render_time: stats.renderDurationMs / 1000,
58
+ render_errors: stats.renderErrorCount
59
+ })
60
+ });
61
+ };
62
+ export const UsageMetricsProvider = ({ project, dashboard, children })=>{
63
+ const ctx = {
64
+ project: project,
65
+ dashboard: dashboard,
66
+ renderErrorCount: 0,
67
+ startRenderTime: Date.now(),
68
+ renderDurationMs: 0,
69
+ pendingQueries: new Map()
70
+ };
71
+ return /*#__PURE__*/ _jsx(UsageMetricsContext.Provider, {
72
+ value: ctx,
73
+ children: children
74
+ });
75
+ };
76
+
77
+ //# sourceMappingURL=UsageMetricsProvider.js.map
@@ -0,0 +1 @@
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,6 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  import { BuiltinVariableDefinition } from '@perses-dev/core';
3
- import { VariableStateMap } from './template-variables';
3
+ import { VariableStateMap } from './variables';
4
4
  export type BuiltinVariableSrv = {
5
5
  variables: BuiltinVariableDefinition[];
6
6
  };
@@ -1 +1 @@
1
- {"version":3,"file":"builtin-variables.d.ts","sourceRoot":"","sources":["../../src/runtime/builtin-variables.ts"],"names":[],"mappings":";AAcA,OAAO,EAAE,yBAAyB,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAExD,MAAM,MAAM,kBAAkB,GAAG;IAC/B,SAAS,EAAE,yBAAyB,EAAE,CAAC;CACxC,CAAC;AAEF,eAAO,MAAM,sBAAsB,yDAA2D,CAAC;AAE/F,wBAAgB,yBAAyB,uBAMxC;AAED,wBAAgB,wBAAwB,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,GAAG,gBAAgB,CA0B3E;AAED,wBAAgB,6BAA6B,IAAI,yBAAyB,EAAE,CAG3E"}
1
+ {"version":3,"file":"builtin-variables.d.ts","sourceRoot":"","sources":["../../src/runtime/builtin-variables.ts"],"names":[],"mappings":";AAcA,OAAO,EAAE,yBAAyB,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C,MAAM,MAAM,kBAAkB,GAAG;IAC/B,SAAS,EAAE,yBAAyB,EAAE,CAAC;CACxC,CAAC;AAEF,eAAO,MAAM,sBAAsB,yDAA2D,CAAC;AAE/F,wBAAgB,yBAAyB,IAAI,kBAAkB,CAM9D;AAED,wBAAgB,wBAAwB,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,GAAG,gBAAgB,CA0B3E;AAED,wBAAgB,6BAA6B,IAAI,yBAAyB,EAAE,CAG3E"}
@@ -1,4 +1,4 @@
1
- // Copyright 2023 The Perses Authors
1
+ // Copyright 2024 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -35,7 +35,7 @@ export function useBuiltinVariableValues(names) {
35
35
  ]);
36
36
  const values = useMemo(()=>{
37
37
  const values = {};
38
- names === null || names === void 0 ? void 0 : names.forEach((name)=>{
38
+ names?.forEach((name)=>{
39
39
  const s = states[name];
40
40
  if (s) {
41
41
  values[name] = s;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/runtime/builtin-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 { createContext, useContext, useMemo } from 'react';\nimport { BuiltinVariableDefinition } from '@perses-dev/core';\nimport { VariableStateMap } from './template-variables';\n\nexport type BuiltinVariableSrv = {\n variables: BuiltinVariableDefinition[];\n};\n\nexport const BuiltinVariableContext = createContext<BuiltinVariableSrv | undefined>(undefined);\n\nexport function useBuiltinVariableContext() {\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,kBAAAA,4BAAAA,MAAOS,OAAO,CAAC,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
+ {"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,5 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  import { DatasourceSelector, DatasourceSpec } from '@perses-dev/core';
3
+ import { UseQueryResult } from '@tanstack/react-query';
3
4
  export interface DatasourceStore {
4
5
  getDatasource(selector: DatasourceSelector): Promise<DatasourceSpec>;
5
6
  /**
@@ -9,7 +10,7 @@ export interface DatasourceStore {
9
10
  /**
10
11
  * Gets a list of datasource selection items for a plugin kind.
11
12
  */
12
- listDatasourceSelectItems(datasourcePluginKind: string): Promise<DatasourceSelectItemGroup[]>;
13
+ listDatasourceSelectItems(datasourcePluginName: string): Promise<DatasourceSelectItemGroup[]>;
13
14
  /**
14
15
  * Gets the list of datasources defined in the dashboard
15
16
  */
@@ -55,10 +56,10 @@ export declare function useDatasourceStore(): DatasourceStore;
55
56
  * Lists all available Datasource selection items for a given datasource plugin kind.
56
57
  * Returns a list, with all information that can be used in a datasource selection context (group, name, selector, kind, ...)
57
58
  */
58
- export declare function useListDatasourceSelectItems(datasourcePluginKind: string, project?: string): import("@tanstack/react-query").UseQueryResult<DatasourceSelectItemGroup[], unknown>;
59
+ export declare function useListDatasourceSelectItems(datasourcePluginName: string, project?: string): UseQueryResult<DatasourceSelectItemGroup[]>;
59
60
  /**
60
61
  * Provides a convenience hook for getting a DatasourceClient for a given DatasourceSelector.
61
62
  */
62
- export declare function useDatasourceClient<Client>(selector: DatasourceSelector): import("@tanstack/react-query").UseQueryResult<Client, unknown>;
63
- export declare function useDatasource(selector: DatasourceSelector): import("@tanstack/react-query").UseQueryResult<DatasourceSpec<import("@perses-dev/core").UnknownSpec>, unknown>;
63
+ export declare function useDatasourceClient<Client>(selector: DatasourceSelector): UseQueryResult<Client>;
64
+ export declare function useDatasource(selector: DatasourceSelector): UseQueryResult<DatasourceSpec>;
64
65
  //# sourceMappingURL=datasources.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"datasources.d.ts","sourceRoot":"","sources":["../../src/runtime/datasources.ts"],"names":[],"mappings":";AAaA,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAItE,MAAM,WAAW,eAAe;IAE9B,aAAa,CAAC,QAAQ,EAAE,kBAAkB,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;IAErE;;OAEG;IACH,mBAAmB,CAAC,MAAM,EAAE,QAAQ,EAAE,kBAAkB,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAE3E;;OAEG;IACH,yBAAyB,CAAC,oBAAoB,EAAE,MAAM,GAAG,OAAO,CAAC,yBAAyB,EAAE,CAAC,CAAC;IAE9F;;OAEG;IACH,mBAAmB,IAAI,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IAEtD;;OAEG;IACH,mBAAmB,CAAC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,GAAG,IAAI,CAAC;IAEvE;;OAEG;IACH,mBAAmB,IAAI,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IAEtD;;OAEG;IACH,mBAAmB,CAAC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,GAAG,IAAI,CAAC;CACxE;AAED,MAAM,WAAW,yBAAyB;IACxC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,oBAAoB,EAAE,CAAC;CAC/B;AAED,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,QAAQ,EAAE,4BAA4B,CAAC;CACxC;AAED;;GAEG;AACH,MAAM,WAAW,4BAA6B,SAAQ,kBAAkB;IACtE;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,eAAO,MAAM,sBAAsB,sDAAwD,CAAC;AAE5F,wBAAgB,kBAAkB,oBAMjC;AAED;;;GAGG;AACH,wBAAgB,4BAA4B,CAAC,oBAAoB,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,wFAK1F;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,QAAQ,EAAE,kBAAkB,mEAGvE;AAED,wBAAgB,aAAa,CAAC,QAAQ,EAAE,kBAAkB,mHAGzD"}
1
+ {"version":3,"file":"datasources.d.ts","sourceRoot":"","sources":["../../src/runtime/datasources.ts"],"names":[],"mappings":";AAaA,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,EAAY,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAGjE,MAAM,WAAW,eAAe;IAE9B,aAAa,CAAC,QAAQ,EAAE,kBAAkB,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;IAErE;;OAEG;IACH,mBAAmB,CAAC,MAAM,EAAE,QAAQ,EAAE,kBAAkB,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAE3E;;OAEG;IACH,yBAAyB,CAAC,oBAAoB,EAAE,MAAM,GAAG,OAAO,CAAC,yBAAyB,EAAE,CAAC,CAAC;IAE9F;;OAEG;IACH,mBAAmB,IAAI,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IAEtD;;OAEG;IACH,mBAAmB,CAAC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,GAAG,IAAI,CAAC;IAEvE;;OAEG;IACH,mBAAmB,IAAI,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IAEtD;;OAEG;IACH,mBAAmB,CAAC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,GAAG,IAAI,CAAC;CACxE;AAED,MAAM,WAAW,yBAAyB;IACxC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,oBAAoB,EAAE,CAAC;CAC/B;AAED,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,QAAQ,EAAE,4BAA4B,CAAC;CACxC;AAED;;GAEG;AACH,MAAM,WAAW,4BAA6B,SAAQ,kBAAkB;IACtE;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,eAAO,MAAM,sBAAsB,sDAAwD,CAAC;AAE5F,wBAAgB,kBAAkB,IAAI,eAAe,CAMpD;AAED;;;GAGG;AACH,wBAAgB,4BAA4B,CAC1C,oBAAoB,EAAE,MAAM,EAC5B,OAAO,CAAC,EAAE,MAAM,GACf,cAAc,CAAC,yBAAyB,EAAE,CAAC,CAM7C;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,QAAQ,EAAE,kBAAkB,GAAG,cAAc,CAAC,MAAM,CAAC,CAMhG;AAED,wBAAgB,aAAa,CAAC,QAAQ,EAAE,kBAAkB,GAAG,cAAc,CAAC,cAAc,CAAC,CAM1F"}
@@ -23,29 +23,38 @@ export function useDatasourceStore() {
23
23
  /**
24
24
  * Lists all available Datasource selection items for a given datasource plugin kind.
25
25
  * Returns a list, with all information that can be used in a datasource selection context (group, name, selector, kind, ...)
26
- */ export function useListDatasourceSelectItems(datasourcePluginKind, project) {
26
+ */ export function useListDatasourceSelectItems(datasourcePluginName, project) {
27
27
  const { listDatasourceSelectItems } = useDatasourceStore();
28
- return useQuery([
29
- 'listDatasourceSelectItems',
30
- datasourcePluginKind,
31
- project
32
- ], ()=>listDatasourceSelectItems(datasourcePluginKind));
28
+ return useQuery({
29
+ queryKey: [
30
+ 'listDatasourceSelectItems',
31
+ datasourcePluginName,
32
+ project
33
+ ],
34
+ queryFn: ()=>listDatasourceSelectItems(datasourcePluginName)
35
+ });
33
36
  }
34
37
  /**
35
38
  * Provides a convenience hook for getting a DatasourceClient for a given DatasourceSelector.
36
39
  */ export function useDatasourceClient(selector) {
37
40
  const store = useDatasourceStore();
38
- return useQuery([
39
- 'getDatasourceClient',
40
- selector
41
- ], ()=>store.getDatasourceClient(selector));
41
+ return useQuery({
42
+ queryKey: [
43
+ 'getDatasourceClient',
44
+ selector
45
+ ],
46
+ queryFn: ()=>store.getDatasourceClient(selector)
47
+ });
42
48
  }
43
49
  export function useDatasource(selector) {
44
50
  const store = useDatasourceStore();
45
- return useQuery([
46
- 'getDatasource',
47
- selector
48
- ], ()=>store.getDatasource(selector));
51
+ return useQuery({
52
+ queryKey: [
53
+ 'getDatasource',
54
+ selector
55
+ ],
56
+ queryFn: ()=>store.getDatasource(selector)
57
+ });
49
58
  }
50
59
 
51
60
  //# sourceMappingURL=datasources.js.map
@@ -1 +1 @@
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 } 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(datasourcePluginKind: 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() {\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(datasourcePluginKind: string, project?: string) {\n const { listDatasourceSelectItems } = useDatasourceStore();\n return useQuery(['listDatasourceSelectItems', datasourcePluginKind, project], () =>\n listDatasourceSelectItems(datasourcePluginKind)\n );\n}\n\n/**\n * Provides a convenience hook for getting a DatasourceClient for a given DatasourceSelector.\n */\nexport function useDatasourceClient<Client>(selector: DatasourceSelector) {\n const store = useDatasourceStore();\n return useQuery<Client>(['getDatasourceClient', selector], () => store.getDatasourceClient<Client>(selector));\n}\n\nexport function useDatasource(selector: DatasourceSelector) {\n const store = useDatasourceStore();\n return useQuery(['getDatasource', selector], () => store.getDatasource(selector));\n}\n"],"names":["useQuery","createContext","useContext","DatasourceStoreContext","undefined","useDatasourceStore","ctx","Error","useListDatasourceSelectItems","datasourcePluginKind","project","listDatasourceSelectItems","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,QAAQ,wBAAwB;AACjD,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,6BAA6BC,oBAA4B,EAAEC,OAAgB;IACzF,MAAM,EAAEC,yBAAyB,EAAE,GAAGN;IACtC,OAAOL,SAAS;QAAC;QAA6BS;QAAsBC;KAAQ,EAAE,IAC5EC,0BAA0BF;AAE9B;AAEA;;CAEC,GACD,OAAO,SAASG,oBAA4BC,QAA4B;IACtE,MAAMC,QAAQT;IACd,OAAOL,SAAiB;QAAC;QAAuBa;KAAS,EAAE,IAAMC,MAAMC,mBAAmB,CAASF;AACrG;AAEA,OAAO,SAASG,cAAcH,QAA4B;IACxD,MAAMC,QAAQT;IACd,OAAOL,SAAS;QAAC;QAAiBa;KAAS,EAAE,IAAMC,MAAMG,aAAa,CAACJ;AACzE"}
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,9 +1,11 @@
1
1
  export * from './builtin-variables';
2
2
  export * from './datasources';
3
3
  export * from './plugin-registry';
4
- export * from './template-variables';
4
+ export * from './variables';
5
5
  export * from './TimeRangeProvider';
6
6
  export * from './time-series-queries';
7
7
  export * from './trace-queries';
8
8
  export * from './DataQueriesProvider';
9
+ export * from './QueryCountProvider';
10
+ export * from './UsageMetricsProvider';
9
11
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/runtime/index.ts"],"names":[],"mappings":"AAaA,cAAc,qBAAqB,CAAC;AACpC,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/runtime/index.ts"],"names":[],"mappings":"AAaA,cAAc,qBAAqB,CAAC;AACpC,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC"}
@@ -1,4 +1,4 @@
1
- // Copyright 2023 The Perses Authors
1
+ // Copyright 2024 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -13,10 +13,12 @@
13
13
  export * from './builtin-variables';
14
14
  export * from './datasources';
15
15
  export * from './plugin-registry';
16
- export * from './template-variables';
16
+ export * from './variables';
17
17
  export * from './TimeRangeProvider';
18
18
  export * from './time-series-queries';
19
19
  export * from './trace-queries';
20
20
  export * from './DataQueriesProvider';
21
+ export * from './QueryCountProvider';
22
+ export * from './UsageMetricsProvider';
21
23
 
22
24
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/runtime/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 './builtin-variables';\nexport * from './datasources';\nexport * from './plugin-registry';\nexport * from './template-variables';\nexport * from './TimeRangeProvider';\nexport * from './time-series-queries';\nexport * from './trace-queries';\nexport * from './DataQueriesProvider';\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,uBAAuB;AACrC,cAAc,sBAAsB;AACpC,cAAc,wBAAwB;AACtC,cAAc,kBAAkB;AAChC,cAAc,wBAAwB"}
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 './DataQueriesProvider';\nexport * from './QueryCountProvider';\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,wBAAwB;AACtC,cAAc,uBAAuB;AACrC,cAAc,yBAAyB"}
@@ -1,10 +1,10 @@
1
1
  /// <reference types="react" />
2
- import { UseQueryOptions } from '@tanstack/react-query';
3
2
  import { BuiltinVariableDefinition } from '@perses-dev/core';
4
- import { DefaultPluginKinds, PluginImplementation, PluginMetadata, PluginType } from '../model';
3
+ import { UseQueryOptions, UseQueryResult } from '@tanstack/react-query';
4
+ import { DefaultPluginKinds, PluginImplementation, PluginMetadataWithModule, PluginType } from '../model';
5
5
  export interface PluginRegistryContextType {
6
- getPlugin<T extends PluginType>(pluginType: T, kind: string): Promise<PluginImplementation<T>>;
7
- listPluginMetadata(pluginType: PluginType): Promise<PluginMetadata[]>;
6
+ getPlugin<T extends PluginType>(kind: T, name: string): Promise<PluginImplementation<T>>;
7
+ listPluginMetadata(pluginTypes: string[]): Promise<PluginMetadataWithModule[]>;
8
8
  defaultPluginKinds?: DefaultPluginKinds;
9
9
  }
10
10
  export declare const PluginRegistryContext: import("react").Context<PluginRegistryContextType | undefined>;
@@ -13,22 +13,22 @@ export declare const PluginRegistryContext: import("react").Context<PluginRegist
13
13
  * be using `usePlugin` or `useListPluginMetadata` instead.
14
14
  */
15
15
  export declare function usePluginRegistry(): PluginRegistryContextType;
16
- type UsePluginOptions<T extends PluginType> = Omit<UseQueryOptions<PluginImplementation<T>, Error, PluginImplementation<T>, [string, PluginType, string]>, 'queryKey' | 'queryFn'>;
16
+ type UsePluginOptions<T extends PluginType> = Omit<UseQueryOptions<PluginImplementation<T>, Error, PluginImplementation<T>, [string, PluginType | undefined, string]>, 'queryKey' | 'queryFn'>;
17
17
  /**
18
18
  * Loads a plugin and returns the plugin implementation, along with loading/error state.
19
19
  */
20
- export declare function usePlugin<T extends PluginType>(pluginType: T, kind: string, options?: UsePluginOptions<T>): import("@tanstack/react-query").UseQueryResult<PluginImplementation<T>, Error>;
20
+ export declare function usePlugin<T extends PluginType>(pluginType: T | undefined, kind: string, options?: UsePluginOptions<T>): UseQueryResult<PluginImplementation<T>, Error>;
21
21
  /**
22
22
  * Loads a list of plugins and returns the plugin implementation, along with loading/error state.
23
23
  */
24
24
  export declare function usePlugins<T extends PluginType>(pluginType: T, plugins: Array<{
25
25
  kind: string;
26
- }>): import("@tanstack/react-query").UseQueryResult<PluginImplementation<T>, unknown>[];
27
- type UseListPluginMetadataOptions = Omit<UseQueryOptions<PluginMetadata[], Error, PluginMetadata[], [string, PluginType]>, 'queryKey' | 'queryFn'>;
26
+ }>): Array<UseQueryResult<PluginImplementation<T>>>;
27
+ type UseListPluginMetadataOptions = Omit<UseQueryOptions<PluginMetadataWithModule[], Error, PluginMetadataWithModule[], [string, string[]]>, 'queryKey' | 'queryFn'>;
28
28
  /**
29
29
  * Gets a list of plugin metadata for the specified plugin type and returns it, along with loading/error state.
30
30
  */
31
- export declare function useListPluginMetadata(pluginType: PluginType, options?: UseListPluginMetadataOptions): import("@tanstack/react-query").UseQueryResult<PluginMetadata[], Error>;
32
- export declare function usePluginBuiltinVariableDefinitions(): import("@tanstack/react-query").UseQueryResult<BuiltinVariableDefinition[], unknown>;
31
+ export declare function useListPluginMetadata(pluginTypes: string[], options?: UseListPluginMetadataOptions): UseQueryResult<PluginMetadataWithModule[]>;
32
+ export declare function usePluginBuiltinVariableDefinitions(): UseQueryResult<BuiltinVariableDefinition[]>;
33
33
  export {};
34
34
  //# sourceMappingURL=plugin-registry.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"plugin-registry.d.ts","sourceRoot":"","sources":["../../src/runtime/plugin-registry.ts"],"names":[],"mappings":";AAcA,OAAO,EAAwB,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC9E,OAAO,EAAE,yBAAyB,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAEhG,MAAM,WAAW,yBAAyB;IACxC,SAAS,CAAC,CAAC,SAAS,UAAU,EAAE,UAAU,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC;IAC/F,kBAAkB,CAAC,UAAU,EAAE,UAAU,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC,CAAC;IACtE,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;CACzC;AAED,eAAO,MAAM,qBAAqB,gEAAkE,CAAC;AAErG;;;GAGG;AACH,wBAAgB,iBAAiB,8BAMhC;AAGD,KAAK,gBAAgB,CAAC,CAAC,SAAS,UAAU,IAAI,IAAI,CAChD,eAAe,CAAC,oBAAoB,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,oBAAoB,CAAC,CAAC,CAAC,EAAE,CAAC,MAAM,EAAE,UAAU,EAAE,MAAM,CAAC,CAAC,EACtG,UAAU,GAAG,SAAS,CACvB,CAAC;AAEF;;GAEG;AACH,wBAAgB,SAAS,CAAC,CAAC,SAAS,UAAU,EAAE,UAAU,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,gBAAgB,CAAC,CAAC,CAAC,kFAQzG;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,CAAC,SAAS,UAAU,EAAE,UAAU,EAAE,CAAC,EAAE,OAAO,EAAE,KAAK,CAAC;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,sFAU/F;AAGD,KAAK,4BAA4B,GAAG,IAAI,CACtC,eAAe,CAAC,cAAc,EAAE,EAAE,KAAK,EAAE,cAAc,EAAE,EAAE,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,EAChF,UAAU,GAAG,SAAS,CACvB,CAAC;AAEF;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,UAAU,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE,4BAA4B,2EAGnG;AAED,wBAAgB,mCAAmC,yFAelD"}
1
+ {"version":3,"file":"plugin-registry.d.ts","sourceRoot":"","sources":["../../src/runtime/plugin-registry.ts"],"names":[],"mappings":";AAaA,OAAO,EAAE,yBAAyB,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAwB,eAAe,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAE9F,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,wBAAwB,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAE1G,MAAM,WAAW,yBAAyB;IACxC,SAAS,CAAC,CAAC,SAAS,UAAU,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC;IACzF,kBAAkB,CAAC,WAAW,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,wBAAwB,EAAE,CAAC,CAAC;IAC/E,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;CACzC;AAED,eAAO,MAAM,qBAAqB,gEAAkE,CAAC;AAErG;;;GAGG;AACH,wBAAgB,iBAAiB,IAAI,yBAAyB,CAM7D;AAGD,KAAK,gBAAgB,CAAC,CAAC,SAAS,UAAU,IAAI,IAAI,CAChD,eAAe,CAAC,oBAAoB,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,oBAAoB,CAAC,CAAC,CAAC,EAAE,CAAC,MAAM,EAAE,UAAU,GAAG,SAAS,EAAE,MAAM,CAAC,CAAC,EAClH,UAAU,GAAG,SAAS,CACvB,CAAC;AAEF;;GAEG;AACH,wBAAgB,SAAS,CAAC,CAAC,SAAS,UAAU,EAC5C,UAAU,EAAE,CAAC,GAAG,SAAS,EACzB,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,gBAAgB,CAAC,CAAC,CAAC,GAC5B,cAAc,CAAC,oBAAoB,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,CAYhD;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,CAAC,SAAS,UAAU,EAC7C,UAAU,EAAE,CAAC,EACb,OAAO,EAAE,KAAK,CAAC;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,GAC/B,KAAK,CAAC,cAAc,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC,CAUhD;AAGD,KAAK,4BAA4B,GAAG,IAAI,CACtC,eAAe,CAAC,wBAAwB,EAAE,EAAE,KAAK,EAAE,wBAAwB,EAAE,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC,EAClG,UAAU,GAAG,SAAS,CACvB,CAAC;AAEF;;GAEG;AACH,wBAAgB,qBAAqB,CACnC,WAAW,EAAE,MAAM,EAAE,EACrB,OAAO,CAAC,EAAE,4BAA4B,GACrC,cAAc,CAAC,wBAAwB,EAAE,CAAC,CAO5C;AAED,wBAAgB,mCAAmC,IAAI,cAAc,CAAC,yBAAyB,EAAE,CAAC,CAkBjG"}
@@ -10,8 +10,8 @@
10
10
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
11
  // See the License for the specific language governing permissions and
12
12
  // limitations under the License.
13
+ import { useQueries, useQuery } from '@tanstack/react-query';
13
14
  import { createContext, useContext } from 'react';
14
- import { useQuery, useQueries } from '@tanstack/react-query';
15
15
  export const PluginRegistryContext = createContext(undefined);
16
16
  /**
17
17
  * Use the PluginRegistry context directly. This is meant as an escape hatch for custom async flows. You should probably
@@ -26,18 +26,21 @@ export const PluginRegistryContext = createContext(undefined);
26
26
  /**
27
27
  * Loads a plugin and returns the plugin implementation, along with loading/error state.
28
28
  */ export function usePlugin(pluginType, kind, options) {
29
- var _options_enabled;
30
29
  // We never want to ask for a plugin when the kind isn't set yet, so disable those queries automatically
31
30
  options = {
32
31
  ...options,
33
- enabled: ((_options_enabled = options === null || options === void 0 ? void 0 : options.enabled) !== null && _options_enabled !== void 0 ? _options_enabled : true) && kind !== ''
32
+ enabled: (options?.enabled ?? true) && pluginType !== undefined && kind !== ''
34
33
  };
35
34
  const { getPlugin } = usePluginRegistry();
36
- return useQuery([
37
- 'getPlugin',
38
- pluginType,
39
- kind
40
- ], ()=>getPlugin(pluginType, kind), options);
35
+ return useQuery({
36
+ queryKey: [
37
+ 'getPlugin',
38
+ pluginType,
39
+ kind
40
+ ],
41
+ queryFn: ()=>getPlugin(pluginType, kind),
42
+ ...options
43
+ });
41
44
  }
42
45
  /**
43
46
  * Loads a list of plugins and returns the plugin implementation, along with loading/error state.
@@ -58,28 +61,37 @@ export const PluginRegistryContext = createContext(undefined);
58
61
  }
59
62
  /**
60
63
  * Gets a list of plugin metadata for the specified plugin type and returns it, along with loading/error state.
61
- */ export function useListPluginMetadata(pluginType, options) {
64
+ */ export function useListPluginMetadata(pluginTypes, options) {
62
65
  const { listPluginMetadata } = usePluginRegistry();
63
- return useQuery([
64
- 'listPluginMetadata',
65
- pluginType
66
- ], ()=>listPluginMetadata(pluginType), options);
66
+ return useQuery({
67
+ queryKey: [
68
+ 'listPluginMetadata',
69
+ pluginTypes
70
+ ],
71
+ queryFn: ()=>listPluginMetadata(pluginTypes),
72
+ ...options
73
+ });
67
74
  }
68
75
  export function usePluginBuiltinVariableDefinitions() {
69
76
  const { getPlugin, listPluginMetadata } = usePluginRegistry();
70
- return useQuery([
71
- 'usePluginBuiltinVariableDefinitions'
72
- ], async ()=>{
73
- const datasources = await listPluginMetadata('Datasource');
74
- const datasourceKinds = new Set(datasources.map((datasource)=>datasource.kind));
75
- const result = [];
76
- for (const kind of datasourceKinds){
77
- const plugin = await getPlugin('Datasource', kind);
78
- if (plugin.getBuiltinVariableDefinitions) {
79
- plugin.getBuiltinVariableDefinitions().forEach((definition)=>result.push(definition));
77
+ return useQuery({
78
+ queryKey: [
79
+ 'usePluginBuiltinVariableDefinitions'
80
+ ],
81
+ queryFn: async ()=>{
82
+ const datasources = await listPluginMetadata([
83
+ 'Datasource'
84
+ ]);
85
+ const datasourceNames = new Set(datasources.map((datasource)=>datasource.spec.name));
86
+ const result = [];
87
+ for (const name of datasourceNames){
88
+ const plugin = await getPlugin('Datasource', name);
89
+ if (plugin.getBuiltinVariableDefinitions) {
90
+ plugin.getBuiltinVariableDefinitions().forEach((definition)=>result.push(definition));
91
+ }
80
92
  }
93
+ return result;
81
94
  }
82
- return result;
83
95
  });
84
96
  }
85
97
 
@@ -1 +1 @@
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 { createContext, useContext } from 'react';\nimport { useQuery, useQueries, UseQueryOptions } from '@tanstack/react-query';\nimport { BuiltinVariableDefinition } from '@perses-dev/core';\nimport { DefaultPluginKinds, PluginImplementation, PluginMetadata, PluginType } from '../model';\n\nexport interface PluginRegistryContextType {\n getPlugin<T extends PluginType>(pluginType: T, kind: string): Promise<PluginImplementation<T>>;\n listPluginMetadata(pluginType: PluginType): Promise<PluginMetadata[]>;\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() {\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, 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>(pluginType: T, kind: string, options?: UsePluginOptions<T>) {\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) && kind !== '',\n };\n const { getPlugin } = usePluginRegistry();\n return useQuery(['getPlugin', pluginType, kind], () => getPlugin(pluginType, kind), options);\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>(pluginType: T, plugins: Array<{ kind: string }>) {\n const { getPlugin } = usePluginRegistry();\n return useQueries({\n queries: plugins.map((p) => {\n return {\n queryKey: ['getPlugin', pluginType, p.kind],\n queryFn: () => getPlugin(pluginType, p.kind),\n };\n }),\n });\n}\n\n// Allow consumers to pass useQuery options from react-query when listing metadata\ntype UseListPluginMetadataOptions = Omit<\n UseQueryOptions<PluginMetadata[], Error, PluginMetadata[], [string, PluginType]>,\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(pluginType: PluginType, options?: UseListPluginMetadataOptions) {\n const { listPluginMetadata } = usePluginRegistry();\n return useQuery(['listPluginMetadata', pluginType], () => listPluginMetadata(pluginType), options);\n}\n\nexport function usePluginBuiltinVariableDefinitions() {\n const { getPlugin, listPluginMetadata } = usePluginRegistry();\n\n return useQuery(['usePluginBuiltinVariableDefinitions'], async () => {\n const datasources = await listPluginMetadata('Datasource');\n const datasourceKinds = new Set(datasources.map((datasource) => datasource.kind));\n const result: BuiltinVariableDefinition[] = [];\n for (const kind of datasourceKinds) {\n const plugin = await getPlugin('Datasource', kind);\n if (plugin.getBuiltinVariableDefinitions) {\n plugin.getBuiltinVariableDefinitions().forEach((definition) => result.push(definition));\n }\n }\n return result;\n });\n}\n"],"names":["createContext","useContext","useQuery","useQueries","PluginRegistryContext","undefined","usePluginRegistry","ctx","Error","usePlugin","pluginType","kind","options","enabled","getPlugin","usePlugins","plugins","queries","map","p","queryKey","queryFn","useListPluginMetadata","listPluginMetadata","usePluginBuiltinVariableDefinitions","datasources","datasourceKinds","Set","datasource","result","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;AAEjC,SAASA,aAAa,EAAEC,UAAU,QAAQ,QAAQ;AAClD,SAASC,QAAQ,EAAEC,UAAU,QAAyB,wBAAwB;AAU9E,OAAO,MAAMC,wBAAwBJ,cAAqDK,WAAW;AAErG;;;CAGC,GACD,OAAO,SAASC;IACd,MAAMC,MAAMN,WAAWG;IACvB,IAAIG,QAAQF,WAAW;QACrB,MAAM,IAAIG,MAAM;IAClB;IACA,OAAOD;AACT;AAQA;;CAEC,GACD,OAAO,SAASE,UAAgCC,UAAa,EAAEC,IAAY,EAAEC,OAA6B;QAI5FA;IAHZ,wGAAwG;IACxGA,UAAU;QACR,GAAGA,OAAO;QACVC,SAAS,AAACD,CAAAA,CAAAA,mBAAAA,oBAAAA,8BAAAA,QAASC,OAAO,cAAhBD,8BAAAA,mBAAoB,IAAG,KAAMD,SAAS;IAClD;IACA,MAAM,EAAEG,SAAS,EAAE,GAAGR;IACtB,OAAOJ,SAAS;QAAC;QAAaQ;QAAYC;KAAK,EAAE,IAAMG,UAAUJ,YAAYC,OAAOC;AACtF;AAEA;;CAEC,GACD,OAAO,SAASG,WAAiCL,UAAa,EAAEM,OAAgC;IAC9F,MAAM,EAAEF,SAAS,EAAE,GAAGR;IACtB,OAAOH,WAAW;QAChBc,SAASD,QAAQE,GAAG,CAAC,CAACC;YACpB,OAAO;gBACLC,UAAU;oBAAC;oBAAaV;oBAAYS,EAAER,IAAI;iBAAC;gBAC3CU,SAAS,IAAMP,UAAUJ,YAAYS,EAAER,IAAI;YAC7C;QACF;IACF;AACF;AAQA;;CAEC,GACD,OAAO,SAASW,sBAAsBZ,UAAsB,EAAEE,OAAsC;IAClG,MAAM,EAAEW,kBAAkB,EAAE,GAAGjB;IAC/B,OAAOJ,SAAS;QAAC;QAAsBQ;KAAW,EAAE,IAAMa,mBAAmBb,aAAaE;AAC5F;AAEA,OAAO,SAASY;IACd,MAAM,EAAEV,SAAS,EAAES,kBAAkB,EAAE,GAAGjB;IAE1C,OAAOJ,SAAS;QAAC;KAAsC,EAAE;QACvD,MAAMuB,cAAc,MAAMF,mBAAmB;QAC7C,MAAMG,kBAAkB,IAAIC,IAAIF,YAAYP,GAAG,CAAC,CAACU,aAAeA,WAAWjB,IAAI;QAC/E,MAAMkB,SAAsC,EAAE;QAC9C,KAAK,MAAMlB,QAAQe,gBAAiB;YAClC,MAAMI,SAAS,MAAMhB,UAAU,cAAcH;YAC7C,IAAImB,OAAOC,6BAA6B,EAAE;gBACxCD,OAAOC,6BAA6B,GAAGC,OAAO,CAAC,CAACC,aAAeJ,OAAOK,IAAI,CAACD;YAC7E;QACF;QACA,OAAOJ;IACT;AACF"}
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: string[]): 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 return useQueries({\n queries: plugins.map((p) => {\n return {\n queryKey: ['getPlugin', pluginType, p.kind],\n queryFn: () => getPlugin(pluginType, p.kind),\n };\n }),\n });\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: string[],\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","queries","map","p","useListPluginMetadata","pluginTypes","listPluginMetadata","usePluginBuiltinVariableDefinitions","datasources","datasourceNames","Set","datasource","spec","name","result","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;IACvB,IAAIG,QAAQF,WAAW;QACrB,MAAM,IAAIG,MAAM;IAClB;IACA,OAAOD;AACT;AAQA;;CAEC,GACD,OAAO,SAASE,UACdC,UAAyB,EACzBC,IAAY,EACZC,OAA6B;IAE7B,wGAAwG;IACxGA,UAAU;QACR,GAAGA,OAAO;QACVC,SAAS,AAACD,CAAAA,SAASC,WAAW,IAAG,KAAMH,eAAeL,aAAaM,SAAS;IAC9E;IACA,MAAM,EAAEG,SAAS,EAAE,GAAGR;IACtB,OAAOL,SAAS;QACdc,UAAU;YAAC;YAAaL;YAAYC;SAAK;QACzCK,SAAS,IAAMF,UAAUJ,YAAaC;QACtC,GAAGC,OAAO;IACZ;AACF;AAEA;;CAEC,GACD,OAAO,SAASK,WACdP,UAAa,EACbQ,OAAgC;IAEhC,MAAM,EAAEJ,SAAS,EAAE,GAAGR;IACtB,OAAON,WAAW;QAChBmB,SAASD,QAAQE,GAAG,CAAC,CAACC;YACpB,OAAO;gBACLN,UAAU;oBAAC;oBAAaL;oBAAYW,EAAEV,IAAI;iBAAC;gBAC3CK,SAAS,IAAMF,UAAUJ,YAAYW,EAAEV,IAAI;YAC7C;QACF;IACF;AACF;AAQA;;CAEC,GACD,OAAO,SAASW,sBACdC,WAAqB,EACrBX,OAAsC;IAEtC,MAAM,EAAEY,kBAAkB,EAAE,GAAGlB;IAC/B,OAAOL,SAAS;QACdc,UAAU;YAAC;YAAsBQ;SAAY;QAC7CP,SAAS,IAAMQ,mBAAmBD;QAClC,GAAGX,OAAO;IACZ;AACF;AAEA,OAAO,SAASa;IACd,MAAM,EAAEX,SAAS,EAAEU,kBAAkB,EAAE,GAAGlB;IAE1C,OAAOL,SAAS;QACdc,UAAU;YAAC;SAAsC;QACjDC,SAAS;YACP,MAAMU,cAAc,MAAMF,mBAAmB;gBAAC;aAAa;YAC3D,MAAMG,kBAAkB,IAAIC,IAAIF,YAAYN,GAAG,CAAC,CAACS,aAAeA,WAAWC,IAAI,CAACC,IAAI;YACpF,MAAMC,SAAsC,EAAE;YAC9C,KAAK,MAAMD,QAAQJ,gBAAiB;gBAClC,MAAMM,SAAS,MAAMnB,UAAU,cAAciB;gBAC7C,IAAIE,OAAOC,6BAA6B,EAAE;oBACxCD,OAAOC,6BAA6B,GAAGC,OAAO,CAAC,CAACC,aAAeJ,OAAOK,IAAI,CAACD;gBAC7E;YACF;YACA,OAAOJ;QACT;IACF;AACF"}
@@ -1,18 +1,19 @@
1
- import { QueryCache, QueryObserverOptions } from '@tanstack/react-query';
1
+ import { QueryCache, QueryObserverOptions, UseQueryResult } from '@tanstack/react-query';
2
2
  import { TimeSeriesQueryDefinition, TimeSeriesData } from '@perses-dev/core';
3
- import { TimeSeriesDataQuery } from '../model';
3
+ import { TimeSeriesDataQuery, TimeSeriesQueryMode } from '../model';
4
4
  export interface UseTimeSeriesQueryOptions {
5
5
  suggestedStepMs?: number;
6
+ mode?: TimeSeriesQueryMode;
6
7
  }
7
8
  export declare const TIME_SERIES_QUERY_KEY = "TimeSeriesQuery";
8
9
  /**
9
10
  * Runs a time series query using a plugin and returns the results.
10
11
  */
11
- export declare const useTimeSeriesQuery: (definition: TimeSeriesQueryDefinition, options?: UseTimeSeriesQueryOptions, queryOptions?: QueryObserverOptions) => import("@tanstack/react-query").UseQueryResult<TimeSeriesData, unknown>;
12
+ export declare const useTimeSeriesQuery: (definition: TimeSeriesQueryDefinition, options?: UseTimeSeriesQueryOptions, queryOptions?: QueryObserverOptions<TimeSeriesData>) => UseQueryResult<TimeSeriesData>;
12
13
  /**
13
14
  * Runs multiple time series queries using plugins and returns the results.
14
15
  */
15
- export declare function useTimeSeriesQueries(definitions: TimeSeriesQueryDefinition[], options?: UseTimeSeriesQueryOptions, queryOptions?: QueryObserverOptions): import("@tanstack/react-query").UseQueryResult<TimeSeriesData, unknown>[];
16
+ export declare function useTimeSeriesQueries(definitions: TimeSeriesQueryDefinition[], options?: UseTimeSeriesQueryOptions, queryOptions?: Omit<QueryObserverOptions, 'queryKey'>): Array<UseQueryResult<TimeSeriesData>>;
16
17
  /**
17
18
  * Get active time series queries for query results summary
18
19
  */
@@ -1 +1 @@
1
- {"version":3,"file":"time-series-queries.d.ts","sourceRoot":"","sources":["../../src/runtime/time-series-queries.ts"],"names":[],"mappings":"AAaA,OAAO,EAKL,UAAU,EAEV,oBAAoB,EACrB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,yBAAyB,EAAe,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC1F,OAAO,EAAE,mBAAmB,EAAiD,MAAM,UAAU,CAAC;AAM9F,MAAM,WAAW,yBAAyB;IACxC,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,eAAO,MAAM,qBAAqB,oBAAoB,CAAC;AAmDvD;;GAEG;AACH,eAAO,MAAM,kBAAkB,eACjB,yBAAyB,YAC3B,yBAAyB,iBACpB,oBAAoB,4EAoBpC,CAAC;AAEF;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,WAAW,EAAE,yBAAyB,EAAE,EACxC,OAAO,CAAC,EAAE,yBAAyB,EACnC,YAAY,CAAC,EAAE,oBAAoB,6EA4BpC;AAmBD;;GAEG;AACH,wBAAgB,0BAA0B,0BAIzC;AAED;;GAEG;AACH,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,UAAU,yBAW3D"}
1
+ {"version":3,"file":"time-series-queries.d.ts","sourceRoot":"","sources":["../../src/runtime/time-series-queries.ts"],"names":[],"mappings":"AAaA,OAAO,EAKL,UAAU,EAEV,oBAAoB,EACpB,cAAc,EACf,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,yBAAyB,EAAe,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC1F,OAAO,EAAE,mBAAmB,EAA0B,mBAAmB,EAAyB,MAAM,UAAU,CAAC;AAMnH,MAAM,WAAW,yBAAyB;IACxC,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,IAAI,CAAC,EAAE,mBAAmB,CAAC;CAC5B;AAED,eAAO,MAAM,qBAAqB,oBAAoB,CAAC;AA8DvD;;GAEG;AACH,eAAO,MAAM,kBAAkB,eACjB,yBAAyB,YAC3B,yBAAyB,iBACpB,qBAAqB,cAAc,CAAC,KAClD,eAAe,cAAc,CAkB/B,CAAC;AAEF;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,WAAW,EAAE,yBAAyB,EAAE,EACxC,OAAO,CAAC,EAAE,yBAAyB,EACnC,YAAY,CAAC,EAAE,IAAI,CAAC,oBAAoB,EAAE,UAAU,CAAC,GACpD,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC,CAAC,CAiCvC;AAkBD;;GAEG;AACH,wBAAgB,0BAA0B,IAAI,mBAAmB,EAAE,CAIlE;AAED;;GAEG;AACH,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,UAAU,GAAG,mBAAmB,EAAE,CAWnF"}