@perses-dev/plugin-system 0.0.0-snapshot-panel-extra-content-3-17f9c42 → 0.0.0-snapshot-scatterplot-fix-imports-95e1b59

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 (425) hide show
  1. package/dist/cjs/components/CalculationSelector/CalculationSelector.js +7 -5
  2. package/dist/cjs/components/CalculationSelector/index.js +10 -8
  3. package/dist/cjs/components/DatasourceEditorForm/DatasourceEditorForm.js +350 -0
  4. package/dist/cjs/components/DatasourceEditorForm/index.js +30 -0
  5. package/dist/cjs/components/DatasourceSelect.js +137 -25
  6. package/dist/cjs/components/LegendOptionsEditor/LegendOptionsEditor.js +19 -17
  7. package/dist/cjs/components/LegendOptionsEditor/index.js +10 -8
  8. package/dist/cjs/components/OptionsEditorRadios/OptionsEditorRadios.js +25 -30
  9. package/dist/cjs/components/OptionsEditorRadios/index.js +10 -8
  10. package/dist/cjs/components/OptionsEditorTabPanel/OptionsEditorTabPanel.js +7 -5
  11. package/dist/cjs/components/OptionsEditorTabPanel/index.js +10 -8
  12. package/dist/cjs/components/OptionsEditorTabs/OptionsEditorTabs.js +13 -11
  13. package/dist/cjs/components/OptionsEditorTabs/index.js +10 -8
  14. package/dist/cjs/components/PanelSpecEditor/PanelSpecEditor.js +60 -19
  15. package/dist/cjs/components/PanelSpecEditor/index.js +10 -8
  16. package/dist/cjs/components/PluginEditor/PluginEditor.js +25 -32
  17. package/dist/cjs/components/PluginEditor/index.js +11 -9
  18. package/dist/cjs/components/PluginEditor/plugin-editor-api.js +8 -6
  19. package/dist/cjs/components/PluginKindSelect/PluginKindSelect.js +25 -14
  20. package/dist/cjs/components/PluginKindSelect/index.js +10 -8
  21. package/dist/cjs/components/PluginRegistry/PluginRegistry.js +11 -9
  22. package/dist/cjs/components/PluginRegistry/index.js +10 -8
  23. package/dist/cjs/components/PluginRegistry/plugin-indexes.js +7 -3
  24. package/dist/cjs/components/PluginSpecEditor/PluginSpecEditor.js +9 -7
  25. package/dist/cjs/components/PluginSpecEditor/index.js +10 -8
  26. package/dist/cjs/components/ProjectSelect.js +96 -0
  27. package/dist/cjs/components/TimeRangeControls/TimeRangeControls.js +192 -0
  28. package/dist/cjs/components/TimeRangeControls/index.js +30 -0
  29. package/dist/cjs/components/TimeSeriesQueryEditor/TimeSeriesQueryEditor.js +45 -49
  30. package/dist/cjs/components/TimeSeriesQueryEditor/TimeSeriesQueryInput.js +23 -21
  31. package/dist/cjs/components/TimeSeriesQueryEditor/index.js +10 -8
  32. package/dist/cjs/components/TraceQueryEditor/TraceQueryEditor.js +143 -0
  33. package/dist/cjs/components/TraceQueryEditor/TraceQueryInput.js +96 -0
  34. package/dist/cjs/components/TraceQueryEditor/index.js +30 -0
  35. package/dist/cjs/components/Variables/VariableEditorForm/VariableEditorForm.js +445 -230
  36. package/dist/cjs/components/Variables/VariableEditorForm/VariablePreview.js +38 -32
  37. package/dist/cjs/components/Variables/VariableEditorForm/index.js +11 -9
  38. package/dist/cjs/components/Variables/VariableEditorForm/variable-editor-form-model.js +36 -37
  39. package/dist/cjs/components/Variables/index.js +11 -9
  40. package/dist/cjs/components/Variables/variable-model.js +24 -17
  41. package/dist/cjs/components/index.js +24 -19
  42. package/dist/cjs/constants/index.js +10 -8
  43. package/dist/cjs/constants/user-interface-text.js +7 -2
  44. package/dist/cjs/context/ProjectStoreProvider.js +78 -0
  45. package/dist/cjs/context/index.js +30 -0
  46. package/dist/cjs/context/query-params.js +49 -0
  47. package/dist/cjs/index.js +17 -13
  48. package/dist/cjs/model/index.js +18 -15
  49. package/dist/cjs/model/legend.js +32 -20
  50. package/dist/cjs/model/panels.js +2 -2
  51. package/dist/cjs/model/plugin-base.js +2 -2
  52. package/dist/cjs/model/plugin-loading.js +3 -1
  53. package/dist/cjs/model/trace-queries.js +16 -0
  54. package/dist/cjs/runtime/DataQueriesProvider/DataQueriesProvider.js +67 -35
  55. package/dist/cjs/runtime/DataQueriesProvider/index.js +11 -9
  56. package/dist/cjs/runtime/DataQueriesProvider/model.js +81 -0
  57. package/dist/cjs/runtime/TimeRangeProvider/TimeRangeProvider.js +55 -27
  58. package/dist/cjs/runtime/TimeRangeProvider/TimeRangeProviderWithQueryParams.js +43 -0
  59. package/dist/cjs/runtime/TimeRangeProvider/index.js +12 -9
  60. package/dist/cjs/runtime/TimeRangeProvider/query-params.js +45 -59
  61. package/dist/cjs/runtime/TimeRangeProvider/refresh-interval.js +30 -0
  62. package/dist/cjs/runtime/builtin-variables.js +81 -0
  63. package/dist/cjs/runtime/datasources.js +31 -12
  64. package/dist/cjs/runtime/index.js +17 -13
  65. package/dist/cjs/runtime/plugin-registry.js +44 -14
  66. package/dist/cjs/runtime/template-variables.js +51 -13
  67. package/dist/cjs/runtime/time-series-queries.js +43 -31
  68. package/dist/cjs/runtime/trace-queries.js +76 -0
  69. package/dist/cjs/stories/shared-utils/decorators/WithDataQueries.js +7 -5
  70. package/dist/cjs/stories/shared-utils/decorators/WithPluginRegistry.js +21 -16
  71. package/dist/cjs/stories/shared-utils/decorators/WithPluginSystemBuiltinVariables.js +42 -0
  72. package/dist/cjs/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.js +31 -13
  73. package/dist/cjs/stories/shared-utils/decorators/WithPluginSystemTemplateVariables.js +6 -4
  74. package/dist/cjs/stories/shared-utils/decorators/WithTimeRange.js +9 -7
  75. package/dist/cjs/stories/shared-utils/decorators/index.js +15 -12
  76. package/dist/cjs/stories/shared-utils/index.js +10 -8
  77. package/dist/cjs/test/index.js +11 -8
  78. package/dist/cjs/test/mock-data.js +80 -0
  79. package/dist/cjs/test/render.js +13 -11
  80. package/dist/cjs/test/test-plugins/bert/index.js +16 -12
  81. package/dist/cjs/test/test-plugins/ernie/index.js +15 -11
  82. package/dist/cjs/test/test-plugins/index.js +14 -10
  83. package/dist/cjs/test-utils/index.js +10 -8
  84. package/dist/cjs/test-utils/mock-plugin-registry.js +9 -5
  85. package/dist/cjs/utils/action.js +43 -0
  86. package/dist/cjs/utils/index.js +11 -8
  87. package/dist/cjs/utils/variables.js +26 -8
  88. package/dist/cjs/validation/datasource.js +30 -0
  89. package/dist/cjs/validation/duration.js +25 -0
  90. package/dist/cjs/validation/index.js +34 -0
  91. package/dist/cjs/validation/resource.js +24 -0
  92. package/dist/cjs/validation/role.js +86 -0
  93. package/dist/cjs/validation/rolebinding.js +55 -0
  94. package/dist/cjs/validation/secret.js +176 -0
  95. package/dist/cjs/validation/user.js +46 -0
  96. package/dist/cjs/validation/variable.js +48 -0
  97. package/dist/components/CalculationSelector/CalculationSelector.d.ts +1 -2
  98. package/dist/components/CalculationSelector/CalculationSelector.d.ts.map +1 -1
  99. package/dist/components/CalculationSelector/CalculationSelector.js +1 -1
  100. package/dist/components/CalculationSelector/CalculationSelector.js.map +1 -1
  101. package/dist/components/CalculationSelector/index.js.map +1 -1
  102. package/dist/components/DatasourceEditorForm/DatasourceEditorForm.d.ts +14 -0
  103. package/dist/components/DatasourceEditorForm/DatasourceEditorForm.d.ts.map +1 -0
  104. package/dist/components/DatasourceEditorForm/DatasourceEditorForm.js +342 -0
  105. package/dist/components/DatasourceEditorForm/DatasourceEditorForm.js.map +1 -0
  106. package/dist/components/DatasourceEditorForm/index.d.ts +2 -0
  107. package/dist/components/DatasourceEditorForm/index.d.ts.map +1 -0
  108. package/dist/components/DatasourceEditorForm/index.js +15 -0
  109. package/dist/components/DatasourceEditorForm/index.js.map +1 -0
  110. package/dist/components/DatasourceSelect.d.ts +8 -3
  111. package/dist/components/DatasourceSelect.d.ts.map +1 -1
  112. package/dist/components/DatasourceSelect.js +120 -23
  113. package/dist/components/DatasourceSelect.js.map +1 -1
  114. package/dist/components/LegendOptionsEditor/LegendOptionsEditor.d.ts +1 -2
  115. package/dist/components/LegendOptionsEditor/LegendOptionsEditor.d.ts.map +1 -1
  116. package/dist/components/LegendOptionsEditor/LegendOptionsEditor.js +3 -3
  117. package/dist/components/LegendOptionsEditor/LegendOptionsEditor.js.map +1 -1
  118. package/dist/components/LegendOptionsEditor/index.js.map +1 -1
  119. package/dist/components/OptionsEditorRadios/OptionsEditorRadios.d.ts +5 -5
  120. package/dist/components/OptionsEditorRadios/OptionsEditorRadios.d.ts.map +1 -1
  121. package/dist/components/OptionsEditorRadios/OptionsEditorRadios.js +18 -25
  122. package/dist/components/OptionsEditorRadios/OptionsEditorRadios.js.map +1 -1
  123. package/dist/components/OptionsEditorRadios/index.js.map +1 -1
  124. package/dist/components/OptionsEditorTabPanel/OptionsEditorTabPanel.d.ts +1 -1
  125. package/dist/components/OptionsEditorTabPanel/OptionsEditorTabPanel.d.ts.map +1 -1
  126. package/dist/components/OptionsEditorTabPanel/OptionsEditorTabPanel.js +1 -1
  127. package/dist/components/OptionsEditorTabPanel/OptionsEditorTabPanel.js.map +1 -1
  128. package/dist/components/OptionsEditorTabPanel/index.js.map +1 -1
  129. package/dist/components/OptionsEditorTabs/OptionsEditorTabs.d.ts +3 -3
  130. package/dist/components/OptionsEditorTabs/OptionsEditorTabs.d.ts.map +1 -1
  131. package/dist/components/OptionsEditorTabs/OptionsEditorTabs.js +3 -3
  132. package/dist/components/OptionsEditorTabs/OptionsEditorTabs.js.map +1 -1
  133. package/dist/components/OptionsEditorTabs/index.js.map +1 -1
  134. package/dist/components/PanelSpecEditor/PanelSpecEditor.d.ts +2 -3
  135. package/dist/components/PanelSpecEditor/PanelSpecEditor.d.ts.map +1 -1
  136. package/dist/components/PanelSpecEditor/PanelSpecEditor.js +50 -11
  137. package/dist/components/PanelSpecEditor/PanelSpecEditor.js.map +1 -1
  138. package/dist/components/PanelSpecEditor/index.js.map +1 -1
  139. package/dist/components/PluginEditor/PluginEditor.d.ts +1 -2
  140. package/dist/components/PluginEditor/PluginEditor.d.ts.map +1 -1
  141. package/dist/components/PluginEditor/PluginEditor.js +17 -26
  142. package/dist/components/PluginEditor/PluginEditor.js.map +1 -1
  143. package/dist/components/PluginEditor/index.js.map +1 -1
  144. package/dist/components/PluginEditor/plugin-editor-api.d.ts +3 -3
  145. package/dist/components/PluginEditor/plugin-editor-api.d.ts.map +1 -1
  146. package/dist/components/PluginEditor/plugin-editor-api.js +5 -5
  147. package/dist/components/PluginEditor/plugin-editor-api.js.map +1 -1
  148. package/dist/components/PluginKindSelect/PluginKindSelect.d.ts +3 -3
  149. package/dist/components/PluginKindSelect/PluginKindSelect.d.ts.map +1 -1
  150. package/dist/components/PluginKindSelect/PluginKindSelect.js +23 -14
  151. package/dist/components/PluginKindSelect/PluginKindSelect.js.map +1 -1
  152. package/dist/components/PluginKindSelect/index.js.map +1 -1
  153. package/dist/components/PluginRegistry/PluginRegistry.d.ts +4 -4
  154. package/dist/components/PluginRegistry/PluginRegistry.d.ts.map +1 -1
  155. package/dist/components/PluginRegistry/PluginRegistry.js +3 -3
  156. package/dist/components/PluginRegistry/PluginRegistry.js.map +1 -1
  157. package/dist/components/PluginRegistry/index.js.map +1 -1
  158. package/dist/components/PluginRegistry/plugin-indexes.js +1 -1
  159. package/dist/components/PluginRegistry/plugin-indexes.js.map +1 -1
  160. package/dist/components/PluginSpecEditor/PluginSpecEditor.d.ts +2 -2
  161. package/dist/components/PluginSpecEditor/PluginSpecEditor.d.ts.map +1 -1
  162. package/dist/components/PluginSpecEditor/PluginSpecEditor.js +3 -3
  163. package/dist/components/PluginSpecEditor/PluginSpecEditor.js.map +1 -1
  164. package/dist/components/PluginSpecEditor/index.js.map +1 -1
  165. package/dist/components/ProjectSelect.d.ts +14 -0
  166. package/dist/components/ProjectSelect.d.ts.map +1 -0
  167. package/dist/components/ProjectSelect.js +91 -0
  168. package/dist/components/ProjectSelect.js.map +1 -0
  169. package/dist/components/TimeRangeControls/TimeRangeControls.d.ts +13 -0
  170. package/dist/components/TimeRangeControls/TimeRangeControls.d.ts.map +1 -0
  171. package/dist/components/TimeRangeControls/TimeRangeControls.js +168 -0
  172. package/dist/components/TimeRangeControls/TimeRangeControls.js.map +1 -0
  173. package/dist/components/TimeRangeControls/index.d.ts +2 -0
  174. package/dist/components/TimeRangeControls/index.d.ts.map +1 -0
  175. package/dist/components/TimeRangeControls/index.js +15 -0
  176. package/dist/components/TimeRangeControls/index.js.map +1 -0
  177. package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryEditor.d.ts +1 -2
  178. package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryEditor.d.ts.map +1 -1
  179. package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryEditor.js +38 -44
  180. package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryEditor.js.map +1 -1
  181. package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryInput.d.ts +1 -2
  182. package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryInput.d.ts.map +1 -1
  183. package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryInput.js +3 -3
  184. package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryInput.js.map +1 -1
  185. package/dist/components/TimeSeriesQueryEditor/index.js.map +1 -1
  186. package/dist/components/TraceQueryEditor/TraceQueryEditor.d.ts +8 -0
  187. package/dist/components/TraceQueryEditor/TraceQueryEditor.d.ts.map +1 -0
  188. package/dist/components/TraceQueryEditor/TraceQueryEditor.js +130 -0
  189. package/dist/components/TraceQueryEditor/TraceQueryEditor.js.map +1 -0
  190. package/dist/components/TraceQueryEditor/TraceQueryInput.d.ts +12 -0
  191. package/dist/components/TraceQueryEditor/TraceQueryInput.d.ts.map +1 -0
  192. package/dist/components/TraceQueryEditor/TraceQueryInput.js +83 -0
  193. package/dist/components/TraceQueryEditor/TraceQueryInput.js.map +1 -0
  194. package/dist/components/TraceQueryEditor/index.d.ts +2 -0
  195. package/dist/components/TraceQueryEditor/index.d.ts.map +1 -0
  196. package/dist/components/TraceQueryEditor/index.js +15 -0
  197. package/dist/components/TraceQueryEditor/index.js.map +1 -0
  198. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts +10 -8
  199. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts.map +1 -1
  200. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js +395 -184
  201. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js.map +1 -1
  202. package/dist/components/Variables/VariableEditorForm/VariablePreview.d.ts +2 -3
  203. package/dist/components/Variables/VariableEditorForm/VariablePreview.d.ts.map +1 -1
  204. package/dist/components/Variables/VariableEditorForm/VariablePreview.js +4 -4
  205. package/dist/components/Variables/VariableEditorForm/VariablePreview.js.map +1 -1
  206. package/dist/components/Variables/VariableEditorForm/index.js.map +1 -1
  207. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.d.ts +8 -19
  208. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.d.ts.map +1 -1
  209. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js +30 -35
  210. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js.map +1 -1
  211. package/dist/components/Variables/index.js.map +1 -1
  212. package/dist/components/Variables/variable-model.d.ts.map +1 -1
  213. package/dist/components/Variables/variable-model.js +9 -10
  214. package/dist/components/Variables/variable-model.js.map +1 -1
  215. package/dist/components/index.d.ts +3 -0
  216. package/dist/components/index.d.ts.map +1 -1
  217. package/dist/components/index.js +3 -0
  218. package/dist/components/index.js.map +1 -1
  219. package/dist/constants/index.js.map +1 -1
  220. package/dist/constants/user-interface-text.d.ts +2 -0
  221. package/dist/constants/user-interface-text.d.ts.map +1 -1
  222. package/dist/constants/user-interface-text.js +4 -1
  223. package/dist/constants/user-interface-text.js.map +1 -1
  224. package/dist/context/ProjectStoreProvider.d.ts +16 -0
  225. package/dist/context/ProjectStoreProvider.d.ts.map +1 -0
  226. package/dist/context/ProjectStoreProvider.js +56 -0
  227. package/dist/context/ProjectStoreProvider.js.map +1 -0
  228. package/dist/context/index.d.ts +2 -0
  229. package/dist/context/index.d.ts.map +1 -0
  230. package/dist/context/index.js +15 -0
  231. package/dist/context/index.js.map +1 -0
  232. package/dist/context/query-params.d.ts +5 -0
  233. package/dist/context/query-params.d.ts.map +1 -0
  234. package/dist/context/query-params.js +41 -0
  235. package/dist/context/query-params.js.map +1 -0
  236. package/dist/index.d.ts +2 -0
  237. package/dist/index.d.ts.map +1 -1
  238. package/dist/index.js +2 -0
  239. package/dist/index.js.map +1 -1
  240. package/dist/model/datasource.d.ts +2 -1
  241. package/dist/model/datasource.d.ts.map +1 -1
  242. package/dist/model/datasource.js +3 -1
  243. package/dist/model/datasource.js.map +1 -1
  244. package/dist/model/index.d.ts +1 -0
  245. package/dist/model/index.d.ts.map +1 -1
  246. package/dist/model/index.js +1 -0
  247. package/dist/model/index.js.map +1 -1
  248. package/dist/model/legend.d.ts +3 -3
  249. package/dist/model/legend.d.ts.map +1 -1
  250. package/dist/model/legend.js +14 -14
  251. package/dist/model/legend.js.map +1 -1
  252. package/dist/model/panels.d.ts +3 -2
  253. package/dist/model/panels.d.ts.map +1 -1
  254. package/dist/model/panels.js.map +1 -1
  255. package/dist/model/plugin-base.js.map +1 -1
  256. package/dist/model/plugin-loading.js.map +1 -1
  257. package/dist/model/plugins.d.ts +6 -4
  258. package/dist/model/plugins.d.ts.map +1 -1
  259. package/dist/model/plugins.js.map +1 -1
  260. package/dist/model/time-series-queries.d.ts +2 -2
  261. package/dist/model/time-series-queries.d.ts.map +1 -1
  262. package/dist/model/time-series-queries.js.map +1 -1
  263. package/dist/model/trace-queries.d.ts +19 -0
  264. package/dist/model/trace-queries.d.ts.map +1 -0
  265. package/dist/model/trace-queries.js +15 -0
  266. package/dist/model/trace-queries.js.map +1 -0
  267. package/dist/model/variables.d.ts +2 -2
  268. package/dist/model/variables.d.ts.map +1 -1
  269. package/dist/model/variables.js +3 -1
  270. package/dist/model/variables.js.map +1 -1
  271. package/dist/runtime/DataQueriesProvider/DataQueriesProvider.d.ts +6 -6
  272. package/dist/runtime/DataQueriesProvider/DataQueriesProvider.d.ts.map +1 -1
  273. package/dist/runtime/DataQueriesProvider/DataQueriesProvider.js +52 -28
  274. package/dist/runtime/DataQueriesProvider/DataQueriesProvider.js.map +1 -1
  275. package/dist/runtime/DataQueriesProvider/index.js.map +1 -1
  276. package/dist/runtime/DataQueriesProvider/model.d.ts +18 -13
  277. package/dist/runtime/DataQueriesProvider/model.d.ts.map +1 -1
  278. package/dist/runtime/DataQueriesProvider/model.js +67 -1
  279. package/dist/runtime/DataQueriesProvider/model.js.map +1 -1
  280. package/dist/runtime/TimeRangeProvider/TimeRangeProvider.d.ts +9 -4
  281. package/dist/runtime/TimeRangeProvider/TimeRangeProvider.d.ts.map +1 -1
  282. package/dist/runtime/TimeRangeProvider/TimeRangeProvider.js +37 -20
  283. package/dist/runtime/TimeRangeProvider/TimeRangeProvider.js.map +1 -1
  284. package/dist/runtime/TimeRangeProvider/TimeRangeProviderWithQueryParams.d.ts +9 -0
  285. package/dist/runtime/TimeRangeProvider/TimeRangeProviderWithQueryParams.d.ts.map +1 -0
  286. package/dist/runtime/TimeRangeProvider/TimeRangeProviderWithQueryParams.js +30 -0
  287. package/dist/runtime/TimeRangeProvider/TimeRangeProviderWithQueryParams.js.map +1 -0
  288. package/dist/runtime/TimeRangeProvider/index.d.ts +1 -0
  289. package/dist/runtime/TimeRangeProvider/index.d.ts.map +1 -1
  290. package/dist/runtime/TimeRangeProvider/index.js +1 -0
  291. package/dist/runtime/TimeRangeProvider/index.js.map +1 -1
  292. package/dist/runtime/TimeRangeProvider/query-params.d.ts +5 -5
  293. package/dist/runtime/TimeRangeProvider/query-params.d.ts.map +1 -1
  294. package/dist/runtime/TimeRangeProvider/query-params.js +13 -45
  295. package/dist/runtime/TimeRangeProvider/query-params.js.map +1 -1
  296. package/dist/runtime/TimeRangeProvider/refresh-interval.d.ts +7 -0
  297. package/dist/runtime/TimeRangeProvider/refresh-interval.d.ts.map +1 -0
  298. package/dist/runtime/TimeRangeProvider/refresh-interval.js +25 -0
  299. package/dist/runtime/TimeRangeProvider/refresh-interval.js.map +1 -0
  300. package/dist/runtime/builtin-variables.d.ts +11 -0
  301. package/dist/runtime/builtin-variables.d.ts.map +1 -0
  302. package/dist/runtime/builtin-variables.js +59 -0
  303. package/dist/runtime/builtin-variables.js.map +1 -0
  304. package/dist/runtime/datasources.d.ts +42 -7
  305. package/dist/runtime/datasources.d.ts.map +1 -1
  306. package/dist/runtime/datasources.js +15 -7
  307. package/dist/runtime/datasources.js.map +1 -1
  308. package/dist/runtime/index.d.ts +2 -0
  309. package/dist/runtime/index.d.ts.map +1 -1
  310. package/dist/runtime/index.js +2 -0
  311. package/dist/runtime/index.js.map +1 -1
  312. package/dist/runtime/plugin-registry.d.ts +5 -3
  313. package/dist/runtime/plugin-registry.d.ts.map +1 -1
  314. package/dist/runtime/plugin-registry.js +22 -5
  315. package/dist/runtime/plugin-registry.js.map +1 -1
  316. package/dist/runtime/template-variables.d.ts +6 -5
  317. package/dist/runtime/template-variables.d.ts.map +1 -1
  318. package/dist/runtime/template-variables.js +36 -9
  319. package/dist/runtime/template-variables.js.map +1 -1
  320. package/dist/runtime/time-series-queries.d.ts +3 -3
  321. package/dist/runtime/time-series-queries.d.ts.map +1 -1
  322. package/dist/runtime/time-series-queries.js +21 -19
  323. package/dist/runtime/time-series-queries.js.map +1 -1
  324. package/dist/runtime/trace-queries.d.ts +14 -0
  325. package/dist/runtime/trace-queries.d.ts.map +1 -0
  326. package/dist/runtime/trace-queries.js +61 -0
  327. package/dist/runtime/trace-queries.js.map +1 -0
  328. package/dist/stories/shared-utils/decorators/WithDataQueries.d.ts +2 -3
  329. package/dist/stories/shared-utils/decorators/WithDataQueries.d.ts.map +1 -1
  330. package/dist/stories/shared-utils/decorators/WithDataQueries.js.map +1 -1
  331. package/dist/stories/shared-utils/decorators/WithPluginRegistry.d.ts +1 -2
  332. package/dist/stories/shared-utils/decorators/WithPluginRegistry.d.ts.map +1 -1
  333. package/dist/stories/shared-utils/decorators/WithPluginRegistry.js +2 -1
  334. package/dist/stories/shared-utils/decorators/WithPluginRegistry.js.map +1 -1
  335. package/dist/stories/shared-utils/decorators/WithPluginSystemBuiltinVariables.d.ts +12 -0
  336. package/dist/stories/shared-utils/decorators/WithPluginSystemBuiltinVariables.d.ts.map +1 -0
  337. package/dist/stories/shared-utils/decorators/WithPluginSystemBuiltinVariables.js +39 -0
  338. package/dist/stories/shared-utils/decorators/WithPluginSystemBuiltinVariables.js.map +1 -0
  339. package/dist/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.d.ts +2 -3
  340. package/dist/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.d.ts.map +1 -1
  341. package/dist/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.js +24 -8
  342. package/dist/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.js.map +1 -1
  343. package/dist/stories/shared-utils/decorators/WithPluginSystemTemplateVariables.d.ts +2 -3
  344. package/dist/stories/shared-utils/decorators/WithPluginSystemTemplateVariables.d.ts.map +1 -1
  345. package/dist/stories/shared-utils/decorators/WithPluginSystemTemplateVariables.js.map +1 -1
  346. package/dist/stories/shared-utils/decorators/WithTimeRange.d.ts +4 -5
  347. package/dist/stories/shared-utils/decorators/WithTimeRange.d.ts.map +1 -1
  348. package/dist/stories/shared-utils/decorators/WithTimeRange.js +2 -2
  349. package/dist/stories/shared-utils/decorators/WithTimeRange.js.map +1 -1
  350. package/dist/stories/shared-utils/decorators/index.d.ts +1 -0
  351. package/dist/stories/shared-utils/decorators/index.d.ts.map +1 -1
  352. package/dist/stories/shared-utils/decorators/index.js +1 -0
  353. package/dist/stories/shared-utils/decorators/index.js.map +1 -1
  354. package/dist/stories/shared-utils/index.js.map +1 -1
  355. package/dist/test/index.d.ts +1 -0
  356. package/dist/test/index.d.ts.map +1 -1
  357. package/dist/test/index.js +1 -0
  358. package/dist/test/index.js.map +1 -1
  359. package/dist/test/mock-data.d.ts +4 -0
  360. package/dist/test/mock-data.d.ts.map +1 -0
  361. package/dist/test/mock-data.js +64 -0
  362. package/dist/test/mock-data.js.map +1 -0
  363. package/dist/test/render.d.ts +1 -1
  364. package/dist/test/render.d.ts.map +1 -1
  365. package/dist/test/render.js +2 -2
  366. package/dist/test/render.js.map +1 -1
  367. package/dist/test/setup-tests.js.map +1 -1
  368. package/dist/test/test-plugins/bert/index.js +2 -2
  369. package/dist/test/test-plugins/bert/index.js.map +1 -1
  370. package/dist/test/test-plugins/ernie/index.js +2 -2
  371. package/dist/test/test-plugins/ernie/index.js.map +1 -1
  372. package/dist/test/test-plugins/index.js.map +1 -1
  373. package/dist/test-utils/index.js.map +1 -1
  374. package/dist/test-utils/mock-plugin-registry.d.ts +1 -1
  375. package/dist/test-utils/mock-plugin-registry.d.ts.map +1 -1
  376. package/dist/test-utils/mock-plugin-registry.js +3 -3
  377. package/dist/test-utils/mock-plugin-registry.js.map +1 -1
  378. package/dist/utils/action.d.ts +4 -0
  379. package/dist/utils/action.d.ts.map +1 -0
  380. package/dist/utils/action.js +27 -0
  381. package/dist/utils/action.js.map +1 -0
  382. package/dist/utils/index.d.ts +1 -0
  383. package/dist/utils/index.d.ts.map +1 -1
  384. package/dist/utils/index.js +1 -0
  385. package/dist/utils/index.js.map +1 -1
  386. package/dist/utils/variables.d.ts.map +1 -1
  387. package/dist/utils/variables.js +17 -5
  388. package/dist/utils/variables.js.map +1 -1
  389. package/dist/validation/datasource.d.ts +19 -0
  390. package/dist/validation/datasource.d.ts.map +1 -0
  391. package/dist/validation/datasource.js +22 -0
  392. package/dist/validation/datasource.js.map +1 -0
  393. package/dist/validation/duration.d.ts +3 -0
  394. package/dist/validation/duration.d.ts.map +1 -0
  395. package/dist/validation/duration.js +17 -0
  396. package/dist/validation/duration.js.map +1 -0
  397. package/dist/validation/index.d.ts +6 -0
  398. package/dist/validation/index.d.ts.map +1 -0
  399. package/dist/validation/index.js +19 -0
  400. package/dist/validation/index.js.map +1 -0
  401. package/dist/validation/resource.d.ts +3 -0
  402. package/dist/validation/resource.d.ts.map +1 -0
  403. package/dist/validation/resource.js +16 -0
  404. package/dist/validation/resource.js.map +1 -0
  405. package/dist/validation/role.d.ts +228 -0
  406. package/dist/validation/role.d.ts.map +1 -0
  407. package/dist/validation/role.js +67 -0
  408. package/dist/validation/role.js.map +1 -0
  409. package/dist/validation/rolebinding.d.ts +137 -0
  410. package/dist/validation/rolebinding.d.ts.map +1 -0
  411. package/dist/validation/rolebinding.js +47 -0
  412. package/dist/validation/rolebinding.js.map +1 -0
  413. package/dist/validation/secret.d.ts +964 -0
  414. package/dist/validation/secret.d.ts.map +1 -0
  415. package/dist/validation/secret.js +157 -0
  416. package/dist/validation/secret.js.map +1 -0
  417. package/dist/validation/user.d.ts +93 -0
  418. package/dist/validation/user.d.ts.map +1 -0
  419. package/dist/validation/user.js +38 -0
  420. package/dist/validation/user.js.map +1 -0
  421. package/dist/validation/variable.d.ts +96 -0
  422. package/dist/validation/variable.d.ts.map +1 -0
  423. package/dist/validation/variable.js +40 -0
  424. package/dist/validation/variable.js.map +1 -0
  425. package/package.json +9 -6
@@ -7,23 +7,58 @@ export interface DatasourceStore {
7
7
  */
8
8
  getDatasourceClient<Client>(selector: DatasourceSelector): Promise<Client>;
9
9
  /**
10
- * Gets a list of datasource metadata for a plugin kind.
10
+ * Gets a list of datasource selection items for a plugin kind.
11
11
  */
12
- listDatasourceMetadata(datasourcePluginKind: string): Promise<DatasourceMetadata[]>;
12
+ listDatasourceSelectItems(datasourcePluginKind: string): Promise<DatasourceSelectItemGroup[]>;
13
+ /**
14
+ * Gets the list of datasources defined in the dashboard
15
+ */
16
+ getLocalDatasources(): Record<string, DatasourceSpec>;
17
+ /**
18
+ * Sets the list of datasources defined in the dashboard
19
+ */
20
+ setLocalDatasources(datasources: Record<string, DatasourceSpec>): void;
21
+ /**
22
+ * 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).
23
+ */
24
+ getSavedDatasources(): Record<string, DatasourceSpec>;
25
+ /**
26
+ * Sets the list of datasources that are saved in the dashboard
27
+ */
28
+ setSavedDatasources(datasources: Record<string, DatasourceSpec>): void;
29
+ }
30
+ export interface DatasourceSelectItemGroup {
31
+ group?: string;
32
+ editLink?: string;
33
+ items: DatasourceSelectItem[];
13
34
  }
14
- export interface DatasourceMetadata {
35
+ export interface DatasourceSelectItem {
15
36
  name: string;
16
- selector: DatasourceSelector;
37
+ overridden?: boolean;
38
+ overriding?: boolean;
39
+ saved?: boolean;
40
+ selector: DatasourceSelectItemSelector;
41
+ }
42
+ /**
43
+ * Datasource Selector used by the frontend only to differentiate datasources coming from different group.
44
+ */
45
+ export interface DatasourceSelectItemSelector extends DatasourceSelector {
46
+ /**
47
+ * Group of the datasource.
48
+ * Omit it if you don't store datasource by group.
49
+ */
50
+ group?: string;
17
51
  }
18
52
  export declare const DatasourceStoreContext: import("react").Context<DatasourceStore | undefined>;
19
53
  export declare function useDatasourceStore(): DatasourceStore;
20
54
  /**
21
- * Lists all available Datasource instances for a given datasource plugin kind. Returns a list with the name of that
22
- * instance, as well as its DatasourceSelector for referencing it.
55
+ * Lists all available Datasource selection items for a given datasource plugin kind.
56
+ * Returns a list, with all information that can be used in a datasource selection context (group, name, selector, kind, ...)
23
57
  */
24
- export declare function useListDatasources(datasourcePluginKind: string): import("@tanstack/react-query").UseQueryResult<DatasourceMetadata[], unknown>;
58
+ export declare function useListDatasourceSelectItems(datasourcePluginKind: string, project?: string): import("@tanstack/react-query").UseQueryResult<DatasourceSelectItemGroup[], unknown>;
25
59
  /**
26
60
  * Provides a convenience hook for getting a DatasourceClient for a given DatasourceSelector.
27
61
  */
28
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>;
29
64
  //# 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,C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AmB,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"}
@@ -21,14 +21,15 @@ export function useDatasourceStore() {
21
21
  return ctx;
22
22
  }
23
23
  /**
24
- * Lists all available Datasource instances for a given datasource plugin kind. Returns a list with the name of that
25
- * instance, as well as its DatasourceSelector for referencing it.
26
- */ export function useListDatasources(datasourcePluginKind) {
27
- const { listDatasourceMetadata } = useDatasourceStore();
24
+ * Lists all available Datasource selection items for a given datasource plugin kind.
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) {
27
+ const { listDatasourceSelectItems } = useDatasourceStore();
28
28
  return useQuery([
29
- 'listDatasourceMetadata',
30
- datasourcePluginKind
31
- ], ()=>listDatasourceMetadata(datasourcePluginKind));
29
+ 'listDatasourceSelectItems',
30
+ datasourcePluginKind,
31
+ project
32
+ ], ()=>listDatasourceSelectItems(datasourcePluginKind));
32
33
  }
33
34
  /**
34
35
  * Provides a convenience hook for getting a DatasourceClient for a given DatasourceSelector.
@@ -39,5 +40,12 @@ export function useDatasourceStore() {
39
40
  selector
40
41
  ], ()=>store.getDatasourceClient(selector));
41
42
  }
43
+ export function useDatasource(selector) {
44
+ const store = useDatasourceStore();
45
+ return useQuery([
46
+ 'getDatasource',
47
+ selector
48
+ ], ()=>store.getDatasource(selector));
49
+ }
42
50
 
43
51
  //# 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 metadata for a plugin kind.\n */\n listDatasourceMetadata(datasourcePluginKind: string): Promise<DatasourceMetadata[]>;\n}\n\nexport interface DatasourceMetadata {\n name: string;\n selector: DatasourceSelector;\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 instances for a given datasource plugin kind. Returns a list with the name of that\n * instance, as well as its DatasourceSelector for referencing it.\n */\nexport function useListDatasources(datasourcePluginKind: string) {\n const { listDatasourceMetadata } = useDatasourceStore();\n return useQuery(['listDatasourceMetadata', datasourcePluginKind], () => listDatasourceMetadata(datasourcePluginKind));\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"],"names":["useQuery","createContext","useContext","DatasourceStoreContext","undefined","useDatasourceStore","ctx","Error","useListDatasources","datasourcePluginKind","listDatasourceMetadata","useDatasourceClient","selector","store","getDatasourceClient"],"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,uBAAuB,CAAC;AACjD,SAASC,aAAa,EAAEC,UAAU,QAAQ,OAAO,CAAC;AAsBlD,OAAO,MAAMC,sBAAsB,GAAGF,aAAa,CAA8BG,SAAS,CAAC,CAAC;AAE5F,OAAO,SAASC,kBAAkB,GAAG;IACnC,MAAMC,GAAG,GAAGJ,UAAU,CAACC,sBAAsB,CAAC,AAAC;IAC/C,IAAIG,GAAG,KAAKF,SAAS,EAAE;QACrB,MAAM,IAAIG,KAAK,CAAC,6DAA6D,CAAC,CAAC;IACjF,CAAC;IACD,OAAOD,GAAG,CAAC;AACb,CAAC;AAED;;;CAGC,GACD,OAAO,SAASE,kBAAkB,CAACC,oBAA4B,EAAE;IAC/D,MAAM,EAAEC,sBAAsB,CAAA,EAAE,GAAGL,kBAAkB,EAAE,AAAC;IACxD,OAAOL,QAAQ,CAAC;QAAC,wBAAwB;QAAES,oBAAoB;KAAC,EAAE,IAAMC,sBAAsB,CAACD,oBAAoB,CAAC,CAAC,CAAC;AACxH,CAAC;AAED;;CAEC,GACD,OAAO,SAASE,mBAAmB,CAASC,QAA4B,EAAE;IACxE,MAAMC,KAAK,GAAGR,kBAAkB,EAAE,AAAC;IACnC,OAAOL,QAAQ,CAAS;QAAC,qBAAqB;QAAEY,QAAQ;KAAC,EAAE,IAAMC,KAAK,CAACC,mBAAmB,CAASF,QAAQ,CAAC,CAAC,CAAC;AAChH,CAAC"}
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,7 +1,9 @@
1
+ export * from './builtin-variables';
1
2
  export * from './datasources';
2
3
  export * from './plugin-registry';
3
4
  export * from './template-variables';
4
5
  export * from './TimeRangeProvider';
5
6
  export * from './time-series-queries';
7
+ export * from './trace-queries';
6
8
  export * from './DataQueriesProvider';
7
9
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/runtime/index.ts"],"names":[],"mappings":"AAaA,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,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,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC"}
@@ -10,11 +10,13 @@
10
10
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
11
  // See the License for the specific language governing permissions and
12
12
  // limitations under the License.
13
+ export * from './builtin-variables';
13
14
  export * from './datasources';
14
15
  export * from './plugin-registry';
15
16
  export * from './template-variables';
16
17
  export * from './TimeRangeProvider';
17
18
  export * from './time-series-queries';
19
+ export * from './trace-queries';
18
20
  export * from './DataQueriesProvider';
19
21
 
20
22
  //# 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 './datasources';\nexport * from './plugin-registry';\nexport * from './template-variables';\nexport * from './TimeRangeProvider';\nexport * from './time-series-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,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC"}
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,10 +1,11 @@
1
1
  /// <reference types="react" />
2
2
  import { UseQueryOptions } from '@tanstack/react-query';
3
+ import { BuiltinVariableDefinition } from '@perses-dev/core';
3
4
  import { DefaultPluginKinds, PluginImplementation, PluginMetadata, PluginType } from '../model';
4
5
  export interface PluginRegistryContextType {
5
6
  getPlugin<T extends PluginType>(pluginType: T, kind: string): Promise<PluginImplementation<T>>;
6
7
  listPluginMetadata(pluginType: PluginType): Promise<PluginMetadata[]>;
7
- defaultPluginKinds: DefaultPluginKinds;
8
+ defaultPluginKinds?: DefaultPluginKinds;
8
9
  }
9
10
  export declare const PluginRegistryContext: import("react").Context<PluginRegistryContextType | undefined>;
10
11
  /**
@@ -12,7 +13,7 @@ export declare const PluginRegistryContext: import("react").Context<PluginRegist
12
13
  * be using `usePlugin` or `useListPluginMetadata` instead.
13
14
  */
14
15
  export declare function usePluginRegistry(): PluginRegistryContextType;
15
- declare 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, string]>, 'queryKey' | 'queryFn'>;
16
17
  /**
17
18
  * Loads a plugin and returns the plugin implementation, along with loading/error state.
18
19
  */
@@ -23,10 +24,11 @@ export declare function usePlugin<T extends PluginType>(pluginType: T, kind: str
23
24
  export declare function usePlugins<T extends PluginType>(pluginType: T, plugins: Array<{
24
25
  kind: string;
25
26
  }>): import("@tanstack/react-query").UseQueryResult<PluginImplementation<T>, unknown>[];
26
- declare type UseListPluginMetadataOptions = Omit<UseQueryOptions<PluginMetadata[], Error, PluginMetadata[], [string, PluginType]>, 'queryKey' | 'queryFn'>;
27
+ type UseListPluginMetadataOptions = Omit<UseQueryOptions<PluginMetadata[], Error, PluginMetadata[], [string, PluginType]>, 'queryKey' | 'queryFn'>;
27
28
  /**
28
29
  * Gets a list of plugin metadata for the specified plugin type and returns it, along with loading/error state.
29
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
33
  export {};
32
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,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,EAAE,kBAAkB,CAAC;CACxC;AAED,eAAO,MAAM,qBAAqB,gEAAkE,CAAC;AAErG;;;GAGG;AACH,wBAAgB,iBAAiB,8BAMhC;AAGD,aAAK,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,EA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AChD,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"}
@@ -26,13 +26,13 @@ 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 ref;
29
+ var _options_enabled;
30
30
  // We never want to ask for a plugin when the kind isn't set yet, so disable those queries automatically
31
31
  options = {
32
32
  ...options,
33
- enabled: ((ref = options === null || options === void 0 ? void 0 : options.enabled) !== null && ref !== void 0 ? ref : true) && kind !== ''
33
+ enabled: ((_options_enabled = options === null || options === void 0 ? void 0 : options.enabled) !== null && _options_enabled !== void 0 ? _options_enabled : true) && kind !== ''
34
34
  };
35
- const { getPlugin } = usePluginRegistry();
35
+ const { getPlugin } = usePluginRegistry();
36
36
  return useQuery([
37
37
  'getPlugin',
38
38
  pluginType,
@@ -42,7 +42,7 @@ export const PluginRegistryContext = createContext(undefined);
42
42
  /**
43
43
  * Loads a list of plugins and returns the plugin implementation, along with loading/error state.
44
44
  */ export function usePlugins(pluginType, plugins) {
45
- const { getPlugin } = usePluginRegistry();
45
+ const { getPlugin } = usePluginRegistry();
46
46
  return useQueries({
47
47
  queries: plugins.map((p)=>{
48
48
  return {
@@ -59,11 +59,28 @@ export const PluginRegistryContext = createContext(undefined);
59
59
  /**
60
60
  * Gets a list of plugin metadata for the specified plugin type and returns it, along with loading/error state.
61
61
  */ export function useListPluginMetadata(pluginType, options) {
62
- const { listPluginMetadata } = usePluginRegistry();
62
+ const { listPluginMetadata } = usePluginRegistry();
63
63
  return useQuery([
64
64
  'listPluginMetadata',
65
65
  pluginType
66
66
  ], ()=>listPluginMetadata(pluginType), options);
67
67
  }
68
+ export function usePluginBuiltinVariableDefinitions() {
69
+ 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));
80
+ }
81
+ }
82
+ return result;
83
+ });
84
+ }
68
85
 
69
86
  //# sourceMappingURL=plugin-registry.js.map
@@ -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 { 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"],"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"],"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,OAAO,CAAC;AAClD,SAASC,QAAQ,EAAEC,UAAU,QAAyB,uBAAuB,CAAC;AAS9E,OAAO,MAAMC,qBAAqB,GAAGJ,aAAa,CAAwCK,SAAS,CAAC,CAAC;AAErG;;;CAGC,GACD,OAAO,SAASC,iBAAiB,GAAG;IAClC,MAAMC,GAAG,GAAGN,UAAU,CAACG,qBAAqB,CAAC,AAAC;IAC9C,IAAIG,GAAG,KAAKF,SAAS,EAAE;QACrB,MAAM,IAAIG,KAAK,CAAC,6DAA6D,CAAC,CAAC;IACjF,CAAC;IACD,OAAOD,GAAG,CAAC;AACb,CAAC;AAQD;;CAEC,GACD,OAAO,SAASE,SAAS,CAAuBC,UAAa,EAAEC,IAAY,EAAEC,OAA6B,EAAE;QAI9FA,GAAgB;IAH5B,wG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"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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AE,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"}
@@ -2,7 +2,7 @@
2
2
  import { VariableValue } from '@perses-dev/core';
3
3
  import { immerable } from 'immer';
4
4
  import { VariableOption } from '../model';
5
- export declare type VariableState = {
5
+ export type VariableState = {
6
6
  value: VariableValue;
7
7
  options?: VariableOption[];
8
8
  loading: boolean;
@@ -15,13 +15,13 @@ export declare type VariableState = {
15
15
  * If a local variable is overriding an external variable, external var will have the flag ``overridden=true``.
16
16
  */
17
17
  overridden?: boolean;
18
- default_value?: VariableValue;
18
+ defaultValue?: VariableValue;
19
19
  };
20
- export declare type VariableStateMap = Record<string, VariableState>;
20
+ export type VariableStateMap = Record<string, VariableState>;
21
21
  /**
22
22
  * Structure used as key in the {@link VariableStoreStateMap}.
23
23
  */
24
- export declare type VariableStateKey = {
24
+ export type VariableStateKey = {
25
25
  /**
26
26
  * name of the variable we want to access in the state.
27
27
  */
@@ -67,10 +67,11 @@ export declare class VariableStoreStateMap {
67
67
  private _sourceName;
68
68
  private _sourceStatesOrEmpty;
69
69
  }
70
- export declare type TemplateVariableSrv = {
70
+ export type TemplateVariableSrv = {
71
71
  state: VariableStateMap;
72
72
  };
73
73
  export declare const TemplateVariableContext: import("react").Context<TemplateVariableSrv | undefined>;
74
74
  export declare function useTemplateVariableValues(names?: string[]): VariableStateMap;
75
+ export declare function useVariableValues(names?: string[]): VariableStateMap;
75
76
  export declare function useReplaceVariablesInString(str: string | undefined): string | undefined;
76
77
  //# sourceMappingURL=template-variables.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"template-variables.d.ts","sourceRoot":"","sources":["../../src/runtime/template-variables.ts"],"names":[],"mappings":";AAcA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAG1C,oBAAY,aAAa,GAAG;IAC1B,KAAK,EAAE,aAAa,CAAC;IACrB,OAAO,CAAC,EAAE,cAAc,EAAE,CAAC;IAC3B,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,KAAK,CAAC;IACd;;OAEG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;OAEG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,aAAa,CAAC,EAAE,aAAa,CAAC;CAC/B,CAAC;AAEF,oBAAY,gBAAgB,GAAG,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;AAE7D;;GAEG;AACH,oBAAY,gBAAgB,GAAG;IAC7B;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF;;GAEG;AACH,qBAAa,qBAAqB;IAChC;;;OAGG;IACH,CAAC,SAAS,CAAC,UAAQ;IAEnB,OAAO,CAAC,QAAQ,CAAC,yBAAyB,CAAM;IAChD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAqD;IAE5E;;;OAGG;IACH,GAAG,CAAC,GAAG,EAAE,gBAAgB,GAAG,aAAa,GAAG,SAAS;IAIrD;;;;OAIG;IACH,GAAG,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AAM,CAAC;IACb;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF;;GAEG;AACH,qBAAa,qBAAqB;IAChC;;;OAGG;IACH,CAAC,SAAS,CAAC,UAAQ;IAEnB,OAAO,CAAC,QAAQ,CAAC,yBAAyB,CAAM;IAChD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAqD;IAE5E;;;OAGG;IACH,GAAG,CAAC,GAAG,EAAE,gBAAgB,GAAG,aAAa,GAAG,SAAS;IAIrD;;;;OAIG;IACH,GAAG,CAAC,GAAG,EAAE,gBAAgB,EAAE,KAAK,EAAE,aAAa,GAAG,aAAa,GAAG,SAAS;IAS3E;;;OAGG;IACH,GAAG,CAAC,GAAG,EAAE,gBAAgB,GAAG,OAAO;IAInC;;;OAGG;IACH,MAAM,CAAC,GAAG,EAAE,gBAAgB,GAAG,OAAO;IAiBtC,OAAO,CAAC,WAAW;IAInB,OAAO,CAAC,oBAAoB;CAG7B;AAED,MAAM,MAAM,mBAAmB,GAAG;IAChC,KAAK,EAAE,gBAAgB,CAAC;CACzB,CAAC;AAEF,eAAO,MAAM,uBAAuB,0DAA4D,CAAC;AAUjG,wBAAgB,yBAAyB,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,GAAG,gBAAgB,CAmB5E;AAED,wBAAgB,iBAAiB,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,GAAG,gBAAgB,CAOpE;AAGD,wBAAgB,2BAA2B,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAKvF"}
@@ -10,9 +10,23 @@
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
+ function _define_property(obj, key, value) {
14
+ if (key in obj) {
15
+ Object.defineProperty(obj, key, {
16
+ value: value,
17
+ enumerable: true,
18
+ configurable: true,
19
+ writable: true
20
+ });
21
+ } else {
22
+ obj[key] = value;
23
+ }
24
+ return obj;
25
+ }
13
26
  import { createContext, useContext, useMemo } from 'react';
14
27
  import { immerable } from 'immer';
15
28
  import { parseTemplateVariables, replaceTemplateVariables } from '../utils';
29
+ import { useBuiltinVariableValues } from './builtin-variables';
16
30
  let _immerable = immerable;
17
31
  /**
18
32
  * A state map with two entry keys, materialized by {@link VariableStateKey} structure.
@@ -45,7 +59,7 @@ let _immerable = immerable;
45
59
  * Delete variable state by key.
46
60
  * @param key
47
61
  */ delete(key) {
48
- var ref;
62
+ var _Object_keys;
49
63
  const result = this.has(key);
50
64
  const sourceName = this._sourceName(key.source);
51
65
  const sourceStates = this._state[sourceName];
@@ -54,7 +68,7 @@ let _immerable = immerable;
54
68
  delete sourceStates[key.name];
55
69
  }
56
70
  // Delete source state from state if empty
57
- if (((ref = Object.keys(sourceStates !== null && sourceStates !== void 0 ? sourceStates : {})) === null || ref === void 0 ? void 0 : ref.length) === 0) {
71
+ if (((_Object_keys = Object.keys(sourceStates !== null && sourceStates !== void 0 ? sourceStates : {})) === null || _Object_keys === void 0 ? void 0 : _Object_keys.length) === 0) {
58
72
  delete this._state[sourceName];
59
73
  }
60
74
  return result;
@@ -63,16 +77,16 @@ let _immerable = immerable;
63
77
  return source !== null && source !== void 0 ? source : this.DEFAULT_LOCAL_SOURCE_NAME;
64
78
  }
65
79
  _sourceStatesOrEmpty(source) {
66
- var ref;
67
- return (ref = this._state[this._sourceName(source)]) !== null && ref !== void 0 ? ref : {};
80
+ var _this__state_this__sourceName;
81
+ return (_this__state_this__sourceName = this._state[this._sourceName(source)]) !== null && _this__state_this__sourceName !== void 0 ? _this__state_this__sourceName : {};
68
82
  }
69
83
  constructor(){
70
84
  /**
71
85
  * "Immerable" is mandatory to be able to use this class in an immer context.
72
86
  * Ref: https://docs.pmnd.rs/zustand/integrations/immer-middleware#gotchas
73
- */ this[_immerable] = true;
74
- this.DEFAULT_LOCAL_SOURCE_NAME = '';
75
- this._state = {};
87
+ */ _define_property(this, _immerable, true);
88
+ _define_property(this, "DEFAULT_LOCAL_SOURCE_NAME", '');
89
+ _define_property(this, "_state", {});
76
90
  }
77
91
  }
78
92
  export const TemplateVariableContext = createContext(undefined);
@@ -84,7 +98,7 @@ function useTemplateVariableContext() {
84
98
  return ctx;
85
99
  }
86
100
  export function useTemplateVariableValues(names) {
87
- const { state } = useTemplateVariableContext();
101
+ const { state } = useTemplateVariableContext();
88
102
  const values = useMemo(()=>{
89
103
  const values = {};
90
104
  names === null || names === void 0 ? void 0 : names.forEach((name)=>{
@@ -103,10 +117,23 @@ export function useTemplateVariableValues(names) {
103
117
  }
104
118
  return values;
105
119
  }
120
+ export function useVariableValues(names) {
121
+ const templateVariableValues = useTemplateVariableValues(names);
122
+ const builtinVariableValues = useBuiltinVariableValues(names);
123
+ return useMemo(()=>{
124
+ return {
125
+ ...templateVariableValues,
126
+ ...builtinVariableValues
127
+ };
128
+ }, [
129
+ templateVariableValues,
130
+ builtinVariableValues
131
+ ]);
132
+ }
106
133
  // Convenience hook for replacing template variables in a string
107
134
  export function useReplaceVariablesInString(str) {
108
135
  const variablesInString = str ? parseTemplateVariables(str) : [];
109
- const variableValues = useTemplateVariableValues(variablesInString);
136
+ const variableValues = useVariableValues(variablesInString);
110
137
  if (!str) return undefined;
111
138
  return replaceTemplateVariables(str, variableValues);
112
139
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/runtime/template-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 { VariableValue } from '@perses-dev/core';\nimport { immerable } from 'immer';\nimport { VariableOption } from '../model';\nimport { parseTemplateVariables, replaceTemplateVariables } from '../utils';\n\nexport type VariableState = {\n value: VariableValue;\n options?: VariableOption[];\n loading: boolean;\n error?: Error;\n /**\n * If a local variable is overriding an external variable, local var will have the flag ``overriding=true``.\n */\n overriding?: boolean;\n /**\n * If a local variable is overriding an external variable, external var will have the flag ``overridden=true``.\n */\n overridden?: boolean;\n default_value?: VariableValue;\n};\n\nexport type VariableStateMap = Record<string, VariableState>;\n\n/**\n * Structure used as key in the {@link VariableStoreStateMap}.\n */\nexport type VariableStateKey = {\n /**\n * name of the variable we want to access in the state.\n */\n name: string;\n /**\n * source of the variable we want to access in the state.\n * Defined only for external variables.\n */\n source?: string;\n};\n\n/**\n * A state map with two entry keys, materialized by {@link VariableStateKey} structure.\n */\nexport class VariableStoreStateMap {\n /**\n * \"Immerable\" is mandatory to be able to use this class in an immer context.\n * Ref: https://docs.pmnd.rs/zustand/integrations/immer-middleware#gotchas\n */\n [immerable] = true;\n\n private readonly DEFAULT_LOCAL_SOURCE_NAME = '';\n private readonly _state: Record<string, Record<string, VariableState>> = {};\n\n /**\n * Get variable state by key.\n * @param key\n */\n get(key: VariableStateKey): VariableState | undefined {\n return this._sourceStatesOrEmpty(key.source)[key.name];\n }\n\n /**\n * Set variable state by key.\n * @param key\n * @param value\n */\n set(key: VariableStateKey, value: VariableState): VariableState | undefined {\n const sourceName = this._sourceName(key.source);\n if (!this._state[sourceName]) {\n this._state[sourceName] = {};\n }\n this._sourceStatesOrEmpty(key.source)[key.name] = value;\n return value;\n }\n\n /**\n * Check presence of variable state by key.\n * @param key\n */\n has(key: VariableStateKey): boolean {\n return this._sourceStatesOrEmpty(key.source)[key.name] !== undefined;\n }\n\n /**\n * Delete variable state by key.\n * @param key\n */\n delete(key: VariableStateKey): boolean {\n const result = this.has(key);\n const sourceName = this._sourceName(key.source);\n const sourceStates = this._state[sourceName];\n\n // Delete var from source state\n if (sourceStates) {\n delete sourceStates[key.name];\n }\n\n // Delete source state from state if empty\n if (Object.keys(sourceStates ?? {})?.length === 0) {\n delete this._state[sourceName];\n }\n return result;\n }\n\n private _sourceName(source: string | undefined): string {\n return source ?? this.DEFAULT_LOCAL_SOURCE_NAME;\n }\n\n private _sourceStatesOrEmpty(source: string | undefined): Record<string, VariableState> {\n return this._state[this._sourceName(source)] ?? {};\n }\n}\n\nexport type TemplateVariableSrv = {\n state: VariableStateMap;\n};\n\nexport const TemplateVariableContext = createContext<TemplateVariableSrv | undefined>(undefined);\n\nfunction useTemplateVariableContext() {\n const ctx = useContext(TemplateVariableContext);\n if (ctx === undefined) {\n throw new Error('No TemplateVariableContext found. Did you forget a Provider?');\n }\n return ctx;\n}\n\nexport function useTemplateVariableValues(names?: string[]) {\n const { state } = useTemplateVariableContext();\n\n const values = useMemo(() => {\n const values: VariableStateMap = {};\n names?.forEach((name) => {\n const s = state[name];\n if (s) {\n values[name] = s;\n }\n });\n return values;\n }, [state, names]);\n\n if (names === undefined) {\n return state;\n }\n\n return values;\n}\n\n// Convenience hook for replacing template variables in a string\nexport function useReplaceVariablesInString(str: string | undefined): string | undefined {\n const variablesInString = str ? parseTemplateVariables(str) : [];\n const variableValues = useTemplateVariableValues(variablesInString);\n if (!str) return undefined;\n return replaceTemplateVariables(str, variableValues);\n}\n"],"names":["createContext","useContext","useMemo","immerable","parseTemplateVariables","replaceTemplateVariables","VariableStoreStateMap","get","key","_sourceStatesOrEmpty","source","name","set","value","sourceName","_sourceName","_state","has","undefined","delete","Object","result","sourceStates","keys","length","DEFAULT_LOCAL_SOURCE_NAME","TemplateVariableContext","useTemplateVariableContext","ctx","Error","useTemplateVariableValues","names","state","values","forEach","s","useReplaceVariablesInString","str","variablesInString","variableValues"],"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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,yBAAyB,CAACC,KAAgB,EAAE;IAC1D,MAAM,EAAEC,KAAK,CAAA,EAAE,GAAGL,0BAA0B,EAAE,AAAC;IAE/C,MAAMM,MAAM,GAAG/B,OAAO,CAAC,IAAM;QAC3B,MAAM+B,MAAM,GAAqB,EAAE,AAAC;QACpCF,KAAK,aAALA,KAAK,WAAS,GAAdA,KAAAA,CAAc,GAAdA,KAAK,CAAEG,OAAO,CAAC,CAACvB,IAAI,GAAK;YACvB,MAAMwB,CAAC,GAAGH,KAAK,CAACrB,IAAI,CAAC,AAAC;YACtB,IAAIwB,CAAC,EAAE;gBACLF,MAAM,CAACtB,IAAI,CAAC,GAAGwB,CAAC,CAAC;YACnB,CAAC;QACH,CAAC,CAAC,CAAC;QACH,OAAOF,MAAM,CAAC;IAChB,CAAC,EAAE;QAACD,KAAK;QAAED,KAAK;KAAC,CAAC,AAAC;IAEnB,IAAIA,KAAK,KAAKb,SAAS,EAAE;QACvB,OAAOc,KAAK,CAAC;IACf,CAAC;IAED,OAAOC,MAAM,CAAC;AAChB,CAAC;AAED,gEAAgE;AAChE,OAAO,SAASG,2BAA2B,CAACC,GAAuB,EAAsB;IACvF,MAAMC,iBAAiB,GAAGD,GAAG,GAAGjC,sBAAsB,CAACiC,GAAG,CAAC,GAAG,EAAE,AAAC;IACjE,MAAME,cAAc,GAAGT,yBAAyB,CAACQ,iBAAiB,CAAC,AAAC;IACpE,IAAI,CAACD,GAAG,EAAE,OAAOnB,SAAS,CAAC;IAC3B,OAAOb,wBAAwB,CAACgC,GAAG,EAAEE,cAAc,CAAC,CAAC;AACvD,CAAC"}
1
+ {"version":3,"sources":["../../src/runtime/template-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 { VariableValue } from '@perses-dev/core';\nimport { immerable } from 'immer';\nimport { VariableOption } from '../model';\nimport { parseTemplateVariables, replaceTemplateVariables } from '../utils';\nimport { useBuiltinVariableValues } from './builtin-variables';\n\nexport type VariableState = {\n value: VariableValue;\n options?: VariableOption[];\n loading: boolean;\n error?: Error;\n /**\n * If a local variable is overriding an external variable, local var will have the flag ``overriding=true``.\n */\n overriding?: boolean;\n /**\n * If a local variable is overriding an external variable, external var will have the flag ``overridden=true``.\n */\n overridden?: boolean;\n defaultValue?: VariableValue;\n};\n\nexport type VariableStateMap = Record<string, VariableState>;\n\n/**\n * Structure used as key in the {@link VariableStoreStateMap}.\n */\nexport type VariableStateKey = {\n /**\n * name of the variable we want to access in the state.\n */\n name: string;\n /**\n * source of the variable we want to access in the state.\n * Defined only for external variables.\n */\n source?: string;\n};\n\n/**\n * A state map with two entry keys, materialized by {@link VariableStateKey} structure.\n */\nexport class VariableStoreStateMap {\n /**\n * \"Immerable\" is mandatory to be able to use this class in an immer context.\n * Ref: https://docs.pmnd.rs/zustand/integrations/immer-middleware#gotchas\n */\n [immerable] = true;\n\n private readonly DEFAULT_LOCAL_SOURCE_NAME = '';\n private readonly _state: Record<string, Record<string, VariableState>> = {};\n\n /**\n * Get variable state by key.\n * @param key\n */\n get(key: VariableStateKey): VariableState | undefined {\n return this._sourceStatesOrEmpty(key.source)[key.name];\n }\n\n /**\n * Set variable state by key.\n * @param key\n * @param value\n */\n set(key: VariableStateKey, value: VariableState): VariableState | undefined {\n const sourceName = this._sourceName(key.source);\n if (!this._state[sourceName]) {\n this._state[sourceName] = {};\n }\n this._sourceStatesOrEmpty(key.source)[key.name] = value;\n return value;\n }\n\n /**\n * Check presence of variable state by key.\n * @param key\n */\n has(key: VariableStateKey): boolean {\n return this._sourceStatesOrEmpty(key.source)[key.name] !== undefined;\n }\n\n /**\n * Delete variable state by key.\n * @param key\n */\n delete(key: VariableStateKey): boolean {\n const result = this.has(key);\n const sourceName = this._sourceName(key.source);\n const sourceStates = this._state[sourceName];\n\n // Delete var from source state\n if (sourceStates) {\n delete sourceStates[key.name];\n }\n\n // Delete source state from state if empty\n if (Object.keys(sourceStates ?? {})?.length === 0) {\n delete this._state[sourceName];\n }\n return result;\n }\n\n private _sourceName(source: string | undefined): string {\n return source ?? this.DEFAULT_LOCAL_SOURCE_NAME;\n }\n\n private _sourceStatesOrEmpty(source: string | undefined): Record<string, VariableState> {\n return this._state[this._sourceName(source)] ?? {};\n }\n}\n\nexport type TemplateVariableSrv = {\n state: VariableStateMap;\n};\n\nexport const TemplateVariableContext = createContext<TemplateVariableSrv | undefined>(undefined);\n\nfunction useTemplateVariableContext() {\n const ctx = useContext(TemplateVariableContext);\n if (ctx === undefined) {\n throw new Error('No TemplateVariableContext found. Did you forget a Provider?');\n }\n return ctx;\n}\n\nexport function useTemplateVariableValues(names?: string[]): VariableStateMap {\n const { state } = useTemplateVariableContext();\n\n const values = useMemo(() => {\n const values: VariableStateMap = {};\n names?.forEach((name) => {\n const s = state[name];\n if (s) {\n values[name] = s;\n }\n });\n return values;\n }, [state, names]);\n\n if (names === undefined) {\n return state;\n }\n\n return values;\n}\n\nexport function useVariableValues(names?: string[]): VariableStateMap {\n const templateVariableValues = useTemplateVariableValues(names);\n const builtinVariableValues = useBuiltinVariableValues(names);\n\n return useMemo(() => {\n return { ...templateVariableValues, ...builtinVariableValues } as VariableStateMap;\n }, [templateVariableValues, builtinVariableValues]);\n}\n\n// Convenience hook for replacing template variables in a string\nexport function useReplaceVariablesInString(str: string | undefined): string | undefined {\n const variablesInString = str ? parseTemplateVariables(str) : [];\n const variableValues = useVariableValues(variablesInString);\n if (!str) return undefined;\n return replaceTemplateVariables(str, variableValues);\n}\n"],"names":["createContext","useContext","useMemo","immerable","parseTemplateVariables","replaceTemplateVariables","useBuiltinVariableValues","VariableStoreStateMap","get","key","_sourceStatesOrEmpty","source","name","set","value","sourceName","_sourceName","_state","has","undefined","delete","Object","result","sourceStates","keys","length","DEFAULT_LOCAL_SOURCE_NAME","TemplateVariableContext","useTemplateVariableContext","ctx","Error","useTemplateVariableValues","names","state","values","forEach","s","useVariableValues","templateVariableValues","builtinVariableValues","useReplaceVariablesInString","str","variablesInString","variableValues"],"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;AAE3D,SAASC,SAAS,QAAQ,QAAQ;AAElC,SAASC,sBAAsB,EAAEC,wBAAwB,QAAQ,WAAW;AAC5E,SAASC,wBAAwB,QAAQ,sBAAsB;IA2C5DH,aAAAA;AARH;;CAEC,GACD,OAAO,MAAMI;IAUX;;;GAGC,GACDC,IAAIC,GAAqB,EAA6B;QACpD,OAAO,IAAI,CAACC,oBAAoB,CAACD,IAAIE,MAAM,CAAC,CAACF,IAAIG,IAAI,CAAC;IACxD;IAEA;;;;GAIC,GACDC,IAAIJ,GAAqB,EAAEK,KAAoB,EAA6B;QAC1E,MAAMC,aAAa,IAAI,CAACC,WAAW,CAACP,IAAIE,MAAM;QAC9C,IAAI,CAAC,IAAI,CAACM,MAAM,CAACF,WAAW,EAAE;YAC5B,IAAI,CAACE,MAAM,CAACF,WAAW,GAAG,CAAC;QAC7B;QACA,IAAI,CAACL,oBAAoB,CAACD,IAAIE,MAAM,CAAC,CAACF,IAAIG,IAAI,CAAC,GAAGE;QAClD,OAAOA;IACT;IAEA;;;GAGC,GACDI,IAAIT,GAAqB,EAAW;QAClC,OAAO,IAAI,CAACC,oBAAoB,CAACD,IAAIE,MAAM,CAAC,CAACF,IA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AAK,CAACrB,KAAK;YACrB,IAAIwB,GAAG;gBACLF,MAAM,CAACtB,KAAK,GAAGwB;YACjB;QACF;QACA,OAAOF;IACT,GAAG;QAACD;QAAOD;KAAM;IAEjB,IAAIA,UAAUb,WAAW;QACvB,OAAOc;IACT;IAEA,OAAOC;AACT;AAEA,OAAO,SAASG,kBAAkBL,KAAgB;IAChD,MAAMM,yBAAyBP,0BAA0BC;IACzD,MAAMO,wBAAwBjC,yBAAyB0B;IAEvD,OAAO9B,QAAQ;QACb,OAAO;YAAE,GAAGoC,sBAAsB;YAAE,GAAGC,qBAAqB;QAAC;IAC/D,GAAG;QAACD;QAAwBC;KAAsB;AACpD;AAEA,gEAAgE;AAChE,OAAO,SAASC,4BAA4BC,GAAuB;IACjE,MAAMC,oBAAoBD,MAAMrC,uBAAuBqC,OAAO,EAAE;IAChE,MAAME,iBAAiBN,kBAAkBK;IACzC,IAAI,CAACD,KAAK,OAAOtB;IACjB,OAAOd,yBAAyBoC,KAAKE;AACvC"}
@@ -1,4 +1,4 @@
1
- import { QueryCache } from '@tanstack/react-query';
1
+ import { QueryCache, QueryObserverOptions } from '@tanstack/react-query';
2
2
  import { TimeSeriesQueryDefinition, TimeSeriesData } from '@perses-dev/core';
3
3
  import { TimeSeriesDataQuery } from '../model';
4
4
  export interface UseTimeSeriesQueryOptions {
@@ -8,11 +8,11 @@ export declare const TIME_SERIES_QUERY_KEY = "TimeSeriesQuery";
8
8
  /**
9
9
  * Runs a time series query using a plugin and returns the results.
10
10
  */
11
- export declare const useTimeSeriesQuery: (definition: TimeSeriesQueryDefinition, options?: UseTimeSeriesQueryOptions) => import("@tanstack/react-query").UseQueryResult<TimeSeriesData, unknown>;
11
+ export declare const useTimeSeriesQuery: (definition: TimeSeriesQueryDefinition, options?: UseTimeSeriesQueryOptions, queryOptions?: QueryObserverOptions) => import("@tanstack/react-query").UseQueryResult<TimeSeriesData, unknown>;
12
12
  /**
13
13
  * Runs multiple time series queries using plugins and returns the results.
14
14
  */
15
- export declare function useTimeSeriesQueries(definitions: TimeSeriesQueryDefinition[], options?: UseTimeSeriesQueryOptions): import("@tanstack/react-query").UseQueryResult<TimeSeriesData, unknown>[];
15
+ export declare function useTimeSeriesQueries(definitions: TimeSeriesQueryDefinition[], options?: UseTimeSeriesQueryOptions, queryOptions?: QueryObserverOptions): import("@tanstack/react-query").UseQueryResult<TimeSeriesData, unknown>[];
16
16
  /**
17
17
  * Get active time series queries for query results summary
18
18
  */
@@ -1 +1 @@
1
- {"version":3,"file":"time-series-queries.d.ts","sourceRoot":"","sources":["../../src/runtime/time-series-queries.ts"],"names":[],"mappings":"AAaA,OAAO,EAA+C,UAAU,EAAY,MAAM,uBAAuB,CAAC;AAC1G,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,eAAgB,yBAAyB,YAAY,yBAAyB,4EAmB5G,CAAC;AAEF;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,WAAW,EAAE,yBAAyB,EAAE,EAAE,OAAO,CAAC,EAAE,yBAAyB,6EA2BjH;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,EACrB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,yBAAyB,EAAe,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC1F,OAAO,EAAE,mBAAmB,EAAiD,MAAM,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