@perses-dev/plugin-system 0.0.0-snapshot-scatterplot-fix-imports-95e1b59 → 0.0.0-snapshot-histogram-types-78c5104

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 (401) 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 +534 -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} +30 -23
  9. package/dist/cjs/components/{TimeSeriesQueryEditor/TimeSeriesQueryInput.js → MultiQueryEditor/QueryEditorContainer.js} +25 -13
  10. package/dist/cjs/{stories/shared-utils → components/MultiQueryEditor}/index.js +2 -2
  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/TimeSeriesQueryEditor/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 +273 -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 +10 -9
  37. package/dist/cjs/{stories/shared-utils/decorators/WithPluginRegistry.js → runtime/QueryCountProvider.js} +22 -39
  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 +49 -28
  47. package/dist/cjs/runtime/time-series-queries.js +23 -28
  48. package/dist/cjs/runtime/trace-queries.js +1 -2
  49. package/dist/cjs/runtime/{template-variables.js → variables.js} +29 -47
  50. package/dist/cjs/test/mock-data.js +25 -4
  51. package/dist/cjs/test/render.js +2 -11
  52. package/dist/cjs/test/test-plugins/bert/index.js +20 -19
  53. package/dist/cjs/test-utils/mock-plugin-registry.js +10 -10
  54. package/dist/cjs/utils/variables.js +24 -24
  55. package/dist/components/CalculationSelector/CalculationSelector.d.ts +2 -1
  56. package/dist/components/CalculationSelector/CalculationSelector.d.ts.map +1 -1
  57. package/dist/components/CalculationSelector/CalculationSelector.js.map +1 -1
  58. package/dist/components/DatasourceEditorForm/DatasourceEditorForm.d.ts +6 -5
  59. package/dist/components/DatasourceEditorForm/DatasourceEditorForm.d.ts.map +1 -1
  60. package/dist/components/DatasourceEditorForm/DatasourceEditorForm.js +85 -165
  61. package/dist/components/DatasourceEditorForm/DatasourceEditorForm.js.map +1 -1
  62. package/dist/components/DatasourceSelect.d.ts +5 -4
  63. package/dist/components/DatasourceSelect.d.ts.map +1 -1
  64. package/dist/components/DatasourceSelect.js +8 -13
  65. package/dist/components/DatasourceSelect.js.map +1 -1
  66. package/dist/components/HTTPSettingsEditor/HTTPSettingsEditor.d.ts +11 -0
  67. package/dist/components/HTTPSettingsEditor/HTTPSettingsEditor.d.ts.map +1 -0
  68. package/dist/components/HTTPSettingsEditor/HTTPSettingsEditor.js +480 -0
  69. package/dist/components/HTTPSettingsEditor/HTTPSettingsEditor.js.map +1 -0
  70. package/dist/components/HTTPSettingsEditor/index.d.ts +2 -0
  71. package/dist/components/HTTPSettingsEditor/index.d.ts.map +1 -0
  72. package/dist/components/HTTPSettingsEditor/index.js +15 -0
  73. package/dist/components/HTTPSettingsEditor/index.js.map +1 -0
  74. package/dist/components/LegendOptionsEditor/LegendOptionsEditor.d.ts +3 -1
  75. package/dist/components/LegendOptionsEditor/LegendOptionsEditor.d.ts.map +1 -1
  76. package/dist/components/LegendOptionsEditor/LegendOptionsEditor.js +10 -9
  77. package/dist/components/LegendOptionsEditor/LegendOptionsEditor.js.map +1 -1
  78. package/dist/components/MetricLabelInput/MetricLabelInput.d.ts +7 -0
  79. package/dist/components/MetricLabelInput/MetricLabelInput.d.ts.map +1 -0
  80. package/dist/components/MetricLabelInput/MetricLabelInput.js +33 -0
  81. package/dist/components/MetricLabelInput/MetricLabelInput.js.map +1 -0
  82. package/dist/components/MetricLabelInput/index.d.ts +2 -0
  83. package/dist/components/MetricLabelInput/index.d.ts.map +1 -0
  84. package/dist/components/MetricLabelInput/index.js +15 -0
  85. package/dist/components/MetricLabelInput/index.js.map +1 -0
  86. package/dist/components/MultiQueryEditor/MultiQueryEditor.d.ts +17 -0
  87. package/dist/components/MultiQueryEditor/MultiQueryEditor.d.ts.map +1 -0
  88. package/dist/components/{TimeSeriesQueryEditor/TimeSeriesQueryEditor.js → MultiQueryEditor/MultiQueryEditor.js} +37 -23
  89. package/dist/components/MultiQueryEditor/MultiQueryEditor.js.map +1 -0
  90. package/dist/components/MultiQueryEditor/QueryEditorContainer.d.ts +29 -0
  91. package/dist/components/MultiQueryEditor/QueryEditorContainer.d.ts.map +1 -0
  92. package/dist/components/{TraceQueryEditor/TraceQueryInput.js → MultiQueryEditor/QueryEditorContainer.js} +35 -12
  93. package/dist/components/MultiQueryEditor/QueryEditorContainer.js.map +1 -0
  94. package/dist/components/MultiQueryEditor/index.d.ts +2 -0
  95. package/dist/components/MultiQueryEditor/index.d.ts.map +1 -0
  96. package/dist/components/MultiQueryEditor/index.js +15 -0
  97. package/dist/components/{TraceQueryEditor → MultiQueryEditor}/index.js.map +1 -1
  98. package/dist/components/OptionsEditorRadios/OptionsEditorRadios.d.ts +2 -2
  99. package/dist/components/OptionsEditorRadios/OptionsEditorRadios.d.ts.map +1 -1
  100. package/dist/components/OptionsEditorRadios/OptionsEditorRadios.js.map +1 -1
  101. package/dist/components/OptionsEditorTabPanel/OptionsEditorTabPanel.d.ts +2 -2
  102. package/dist/components/OptionsEditorTabPanel/OptionsEditorTabPanel.d.ts.map +1 -1
  103. package/dist/components/OptionsEditorTabPanel/OptionsEditorTabPanel.js.map +1 -1
  104. package/dist/components/OptionsEditorTabs/OptionsEditorTabs.d.ts +3 -3
  105. package/dist/components/OptionsEditorTabs/OptionsEditorTabs.d.ts.map +1 -1
  106. package/dist/components/OptionsEditorTabs/OptionsEditorTabs.js.map +1 -1
  107. package/dist/components/PanelSpecEditor/PanelSpecEditor.d.ts +5 -2
  108. package/dist/components/PanelSpecEditor/PanelSpecEditor.d.ts.map +1 -1
  109. package/dist/components/PanelSpecEditor/PanelSpecEditor.js +53 -61
  110. package/dist/components/PanelSpecEditor/PanelSpecEditor.js.map +1 -1
  111. package/dist/components/PluginEditor/PluginEditor.d.ts +2 -1
  112. package/dist/components/PluginEditor/PluginEditor.d.ts.map +1 -1
  113. package/dist/components/PluginEditor/PluginEditor.js +16 -13
  114. package/dist/components/PluginEditor/PluginEditor.js.map +1 -1
  115. package/dist/components/PluginEditor/plugin-editor-api.d.ts +15 -8
  116. package/dist/components/PluginEditor/plugin-editor-api.d.ts.map +1 -1
  117. package/dist/components/PluginEditor/plugin-editor-api.js +43 -32
  118. package/dist/components/PluginEditor/plugin-editor-api.js.map +1 -1
  119. package/dist/components/PluginKindSelect/PluginKindSelect.d.ts +10 -4
  120. package/dist/components/PluginKindSelect/PluginKindSelect.d.ts.map +1 -1
  121. package/dist/components/PluginKindSelect/PluginKindSelect.js +61 -10
  122. package/dist/components/PluginKindSelect/PluginKindSelect.js.map +1 -1
  123. package/dist/components/PluginRegistry/PluginRegistry.d.ts +2 -2
  124. package/dist/components/PluginRegistry/PluginRegistry.d.ts.map +1 -1
  125. package/dist/components/PluginRegistry/PluginRegistry.js +8 -9
  126. package/dist/components/PluginRegistry/PluginRegistry.js.map +1 -1
  127. package/dist/components/PluginRegistry/plugin-indexes.d.ts +4 -4
  128. package/dist/components/PluginRegistry/plugin-indexes.d.ts.map +1 -1
  129. package/dist/components/PluginRegistry/plugin-indexes.js +17 -14
  130. package/dist/components/PluginRegistry/plugin-indexes.js.map +1 -1
  131. package/dist/components/PluginSpecEditor/PluginSpecEditor.d.ts +5 -4
  132. package/dist/components/PluginSpecEditor/PluginSpecEditor.d.ts.map +1 -1
  133. package/dist/components/PluginSpecEditor/PluginSpecEditor.js +1 -1
  134. package/dist/components/PluginSpecEditor/PluginSpecEditor.js.map +1 -1
  135. package/dist/components/ProjectSelect.d.ts +2 -1
  136. package/dist/components/ProjectSelect.d.ts.map +1 -1
  137. package/dist/components/ProjectSelect.js +5 -5
  138. package/dist/components/ProjectSelect.js.map +1 -1
  139. package/dist/components/TimeRangeControls/TimeRangeControls.d.ts +3 -2
  140. package/dist/components/TimeRangeControls/TimeRangeControls.d.ts.map +1 -1
  141. package/dist/components/TimeRangeControls/TimeRangeControls.js +12 -70
  142. package/dist/components/TimeRangeControls/TimeRangeControls.js.map +1 -1
  143. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts +4 -3
  144. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts.map +1 -1
  145. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js +395 -446
  146. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js.map +1 -1
  147. package/dist/components/Variables/VariableEditorForm/VariablePreview.d.ts +3 -2
  148. package/dist/components/Variables/VariableEditorForm/VariablePreview.d.ts.map +1 -1
  149. package/dist/components/Variables/VariableEditorForm/VariablePreview.js +7 -7
  150. package/dist/components/Variables/VariableEditorForm/VariablePreview.js.map +1 -1
  151. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.d.ts +2 -2
  152. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.d.ts.map +1 -1
  153. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js +6 -11
  154. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js.map +1 -1
  155. package/dist/components/Variables/variable-model.d.ts +2 -1
  156. package/dist/components/Variables/variable-model.d.ts.map +1 -1
  157. package/dist/components/Variables/variable-model.js +27 -28
  158. package/dist/components/Variables/variable-model.js.map +1 -1
  159. package/dist/components/index.d.ts +3 -1
  160. package/dist/components/index.d.ts.map +1 -1
  161. package/dist/components/index.js +3 -1
  162. package/dist/components/index.js.map +1 -1
  163. package/dist/context/ProjectStoreProvider.d.ts +4 -4
  164. package/dist/context/ProjectStoreProvider.d.ts.map +1 -1
  165. package/dist/context/ProjectStoreProvider.js +7 -4
  166. package/dist/context/ProjectStoreProvider.js.map +1 -1
  167. package/dist/context/ValidationProvider.d.ts +19 -0
  168. package/dist/context/ValidationProvider.d.ts.map +1 -0
  169. package/dist/context/ValidationProvider.js +52 -0
  170. package/dist/context/ValidationProvider.js.map +1 -0
  171. package/dist/context/index.d.ts +1 -0
  172. package/dist/context/index.d.ts.map +1 -1
  173. package/dist/context/index.js +1 -0
  174. package/dist/context/index.js.map +1 -1
  175. package/dist/context/query-params.d.ts.map +1 -1
  176. package/dist/context/query-params.js.map +1 -1
  177. package/dist/index.d.ts +1 -1
  178. package/dist/index.d.ts.map +1 -1
  179. package/dist/index.js +1 -1
  180. package/dist/index.js.map +1 -1
  181. package/dist/model/explore.d.ts +13 -0
  182. package/dist/model/explore.d.ts.map +1 -0
  183. package/dist/{validation/index.js → model/explore.js} +4 -6
  184. package/dist/model/explore.js.map +1 -0
  185. package/dist/model/legend.d.ts.map +1 -1
  186. package/dist/model/legend.js.map +1 -1
  187. package/dist/model/panels.d.ts +27 -5
  188. package/dist/model/panels.d.ts.map +1 -1
  189. package/dist/model/panels.js.map +1 -1
  190. package/dist/model/plugin-loading.js.map +1 -1
  191. package/dist/model/plugins.d.ts +31 -17
  192. package/dist/model/plugins.d.ts.map +1 -1
  193. package/dist/model/plugins.js.map +1 -1
  194. package/dist/model/time-series-queries.d.ts +2 -1
  195. package/dist/model/time-series-queries.d.ts.map +1 -1
  196. package/dist/model/time-series-queries.js.map +1 -1
  197. package/dist/remote/PersesPlugin.types.d.ts +7 -0
  198. package/dist/remote/PersesPlugin.types.d.ts.map +1 -0
  199. package/dist/{stories/shared-utils/index.js → remote/PersesPlugin.types.js} +3 -3
  200. package/dist/remote/PersesPlugin.types.js.map +1 -0
  201. package/dist/remote/PluginLoaderComponent.d.ts +10 -0
  202. package/dist/remote/PluginLoaderComponent.d.ts.map +1 -0
  203. package/dist/remote/PluginLoaderComponent.js +67 -0
  204. package/dist/remote/PluginLoaderComponent.js.map +1 -0
  205. package/dist/remote/PluginRuntime.d.ts +10 -0
  206. package/dist/remote/PluginRuntime.d.ts.map +1 -0
  207. package/dist/remote/PluginRuntime.js +211 -0
  208. package/dist/remote/PluginRuntime.js.map +1 -0
  209. package/dist/remote/index.d.ts +3 -0
  210. package/dist/remote/index.d.ts.map +1 -0
  211. package/dist/{components/TraceQueryEditor → remote}/index.js +2 -1
  212. package/dist/remote/index.js.map +1 -0
  213. package/dist/remote/remotePluginLoader.d.ts +3 -0
  214. package/dist/remote/remotePluginLoader.d.ts.map +1 -0
  215. package/dist/remote/remotePluginLoader.js +53 -0
  216. package/dist/remote/remotePluginLoader.js.map +1 -0
  217. package/dist/runtime/DataQueriesProvider/DataQueriesProvider.d.ts +2 -2
  218. package/dist/runtime/DataQueriesProvider/DataQueriesProvider.d.ts.map +1 -1
  219. package/dist/runtime/DataQueriesProvider/DataQueriesProvider.js +18 -9
  220. package/dist/runtime/DataQueriesProvider/DataQueriesProvider.js.map +1 -1
  221. package/dist/runtime/DataQueriesProvider/model.d.ts +5 -6
  222. package/dist/runtime/DataQueriesProvider/model.d.ts.map +1 -1
  223. package/dist/runtime/DataQueriesProvider/model.js +10 -9
  224. package/dist/runtime/DataQueriesProvider/model.js.map +1 -1
  225. package/dist/runtime/QueryCountProvider.d.ts +9 -0
  226. package/dist/runtime/QueryCountProvider.d.ts.map +1 -0
  227. package/dist/{validation/duration.js → runtime/QueryCountProvider.js} +13 -4
  228. package/dist/runtime/QueryCountProvider.js.map +1 -0
  229. package/dist/runtime/TimeRangeProvider/TimeRangeProvider.d.ts +2 -2
  230. package/dist/runtime/TimeRangeProvider/TimeRangeProvider.d.ts.map +1 -1
  231. package/dist/runtime/TimeRangeProvider/TimeRangeProvider.js +17 -4
  232. package/dist/runtime/TimeRangeProvider/TimeRangeProvider.js.map +1 -1
  233. package/dist/runtime/TimeRangeProvider/TimeRangeProviderWithQueryParams.d.ts +2 -2
  234. package/dist/runtime/TimeRangeProvider/TimeRangeProviderWithQueryParams.d.ts.map +1 -1
  235. package/dist/runtime/TimeRangeProvider/TimeRangeProviderWithQueryParams.js.map +1 -1
  236. package/dist/runtime/TimeRangeProvider/TimeRangeSettingsProvider.d.ts +32 -0
  237. package/dist/runtime/TimeRangeProvider/TimeRangeSettingsProvider.d.ts.map +1 -0
  238. package/dist/runtime/TimeRangeProvider/TimeRangeSettingsProvider.js +82 -0
  239. package/dist/runtime/TimeRangeProvider/TimeRangeSettingsProvider.js.map +1 -0
  240. package/dist/runtime/TimeRangeProvider/index.d.ts +1 -0
  241. package/dist/runtime/TimeRangeProvider/index.d.ts.map +1 -1
  242. package/dist/runtime/TimeRangeProvider/index.js +2 -1
  243. package/dist/runtime/TimeRangeProvider/index.js.map +1 -1
  244. package/dist/runtime/TimeRangeProvider/query-params.d.ts.map +1 -1
  245. package/dist/runtime/TimeRangeProvider/query-params.js +4 -7
  246. package/dist/runtime/TimeRangeProvider/query-params.js.map +1 -1
  247. package/dist/runtime/TimeRangeProvider/refresh-interval.d.ts.map +1 -1
  248. package/dist/runtime/TimeRangeProvider/refresh-interval.js.map +1 -1
  249. package/dist/runtime/UsageMetricsProvider.d.ts +25 -0
  250. package/dist/runtime/UsageMetricsProvider.d.ts.map +1 -0
  251. package/dist/runtime/UsageMetricsProvider.js +77 -0
  252. package/dist/runtime/UsageMetricsProvider.js.map +1 -0
  253. package/dist/runtime/builtin-variables.d.ts +1 -1
  254. package/dist/runtime/builtin-variables.d.ts.map +1 -1
  255. package/dist/runtime/builtin-variables.js +2 -2
  256. package/dist/runtime/builtin-variables.js.map +1 -1
  257. package/dist/runtime/datasources.d.ts +5 -4
  258. package/dist/runtime/datasources.d.ts.map +1 -1
  259. package/dist/runtime/datasources.js +23 -14
  260. package/dist/runtime/datasources.js.map +1 -1
  261. package/dist/runtime/index.d.ts +3 -1
  262. package/dist/runtime/index.d.ts.map +1 -1
  263. package/dist/runtime/index.js +4 -2
  264. package/dist/runtime/index.js.map +1 -1
  265. package/dist/runtime/plugin-registry.d.ts +10 -10
  266. package/dist/runtime/plugin-registry.d.ts.map +1 -1
  267. package/dist/runtime/plugin-registry.js +49 -28
  268. package/dist/runtime/plugin-registry.js.map +1 -1
  269. package/dist/runtime/time-series-queries.d.ts +5 -4
  270. package/dist/runtime/time-series-queries.d.ts.map +1 -1
  271. package/dist/runtime/time-series-queries.js +23 -28
  272. package/dist/runtime/time-series-queries.js.map +1 -1
  273. package/dist/runtime/trace-queries.d.ts +4 -3
  274. package/dist/runtime/trace-queries.d.ts.map +1 -1
  275. package/dist/runtime/trace-queries.js +2 -3
  276. package/dist/runtime/trace-queries.js.map +1 -1
  277. package/dist/runtime/{template-variables.d.ts → variables.d.ts} +4 -4
  278. package/dist/runtime/variables.d.ts.map +1 -0
  279. package/dist/runtime/{template-variables.js → variables.js} +28 -45
  280. package/dist/runtime/variables.js.map +1 -0
  281. package/dist/test/mock-data.d.ts.map +1 -1
  282. package/dist/test/mock-data.js +25 -4
  283. package/dist/test/mock-data.js.map +1 -1
  284. package/dist/test/render.d.ts +3 -3
  285. package/dist/test/render.d.ts.map +1 -1
  286. package/dist/test/render.js +2 -11
  287. package/dist/test/render.js.map +1 -1
  288. package/dist/test/test-plugins/bert/index.d.ts.map +1 -1
  289. package/dist/test/test-plugins/bert/index.js +20 -19
  290. package/dist/test/test-plugins/bert/index.js.map +1 -1
  291. package/dist/test-utils/mock-plugin-registry.d.ts +5 -3
  292. package/dist/test-utils/mock-plugin-registry.d.ts.map +1 -1
  293. package/dist/test-utils/mock-plugin-registry.js +10 -10
  294. package/dist/test-utils/mock-plugin-registry.js.map +1 -1
  295. package/dist/utils/variables.d.ts +4 -4
  296. package/dist/utils/variables.d.ts.map +1 -1
  297. package/dist/utils/variables.js +19 -19
  298. package/dist/utils/variables.js.map +1 -1
  299. package/package.json +10 -11
  300. package/dist/cjs/components/TraceQueryEditor/TraceQueryEditor.js +0 -143
  301. package/dist/cjs/components/TraceQueryEditor/TraceQueryInput.js +0 -96
  302. package/dist/cjs/stories/shared-utils/decorators/WithDataQueries.js +0 -41
  303. package/dist/cjs/stories/shared-utils/decorators/WithPluginSystemBuiltinVariables.js +0 -42
  304. package/dist/cjs/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.js +0 -101
  305. package/dist/cjs/stories/shared-utils/decorators/WithPluginSystemTemplateVariables.js +0 -42
  306. package/dist/cjs/stories/shared-utils/decorators/WithTimeRange.js +0 -41
  307. package/dist/cjs/stories/shared-utils/decorators/index.js +0 -35
  308. package/dist/cjs/validation/datasource.js +0 -30
  309. package/dist/cjs/validation/duration.js +0 -25
  310. package/dist/cjs/validation/resource.js +0 -24
  311. package/dist/cjs/validation/role.js +0 -86
  312. package/dist/cjs/validation/rolebinding.js +0 -55
  313. package/dist/cjs/validation/secret.js +0 -176
  314. package/dist/cjs/validation/user.js +0 -46
  315. package/dist/cjs/validation/variable.js +0 -48
  316. package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryEditor.d.ts +0 -7
  317. package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryEditor.d.ts.map +0 -1
  318. package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryEditor.js.map +0 -1
  319. package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryInput.d.ts +0 -12
  320. package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryInput.d.ts.map +0 -1
  321. package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryInput.js +0 -83
  322. package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryInput.js.map +0 -1
  323. package/dist/components/TimeSeriesQueryEditor/index.d.ts +0 -2
  324. package/dist/components/TimeSeriesQueryEditor/index.d.ts.map +0 -1
  325. package/dist/components/TimeSeriesQueryEditor/index.js.map +0 -1
  326. package/dist/components/TraceQueryEditor/TraceQueryEditor.d.ts +0 -8
  327. package/dist/components/TraceQueryEditor/TraceQueryEditor.d.ts.map +0 -1
  328. package/dist/components/TraceQueryEditor/TraceQueryEditor.js +0 -130
  329. package/dist/components/TraceQueryEditor/TraceQueryEditor.js.map +0 -1
  330. package/dist/components/TraceQueryEditor/TraceQueryInput.d.ts +0 -12
  331. package/dist/components/TraceQueryEditor/TraceQueryInput.d.ts.map +0 -1
  332. package/dist/components/TraceQueryEditor/TraceQueryInput.js.map +0 -1
  333. package/dist/components/TraceQueryEditor/index.d.ts +0 -2
  334. package/dist/components/TraceQueryEditor/index.d.ts.map +0 -1
  335. package/dist/runtime/template-variables.d.ts.map +0 -1
  336. package/dist/runtime/template-variables.js.map +0 -1
  337. package/dist/stories/shared-utils/decorators/WithDataQueries.d.ts +0 -12
  338. package/dist/stories/shared-utils/decorators/WithDataQueries.d.ts.map +0 -1
  339. package/dist/stories/shared-utils/decorators/WithDataQueries.js +0 -33
  340. package/dist/stories/shared-utils/decorators/WithDataQueries.js.map +0 -1
  341. package/dist/stories/shared-utils/decorators/WithPluginRegistry.d.ts +0 -3
  342. package/dist/stories/shared-utils/decorators/WithPluginRegistry.d.ts.map +0 -1
  343. package/dist/stories/shared-utils/decorators/WithPluginRegistry.js +0 -46
  344. package/dist/stories/shared-utils/decorators/WithPluginRegistry.js.map +0 -1
  345. package/dist/stories/shared-utils/decorators/WithPluginSystemBuiltinVariables.d.ts +0 -12
  346. package/dist/stories/shared-utils/decorators/WithPluginSystemBuiltinVariables.d.ts.map +0 -1
  347. package/dist/stories/shared-utils/decorators/WithPluginSystemBuiltinVariables.js +0 -39
  348. package/dist/stories/shared-utils/decorators/WithPluginSystemBuiltinVariables.js.map +0 -1
  349. package/dist/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.d.ts +0 -12
  350. package/dist/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.d.ts.map +0 -1
  351. package/dist/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.js +0 -95
  352. package/dist/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.js.map +0 -1
  353. package/dist/stories/shared-utils/decorators/WithPluginSystemTemplateVariables.d.ts +0 -12
  354. package/dist/stories/shared-utils/decorators/WithPluginSystemTemplateVariables.d.ts.map +0 -1
  355. package/dist/stories/shared-utils/decorators/WithPluginSystemTemplateVariables.js +0 -39
  356. package/dist/stories/shared-utils/decorators/WithPluginSystemTemplateVariables.js.map +0 -1
  357. package/dist/stories/shared-utils/decorators/WithTimeRange.d.ts +0 -12
  358. package/dist/stories/shared-utils/decorators/WithTimeRange.d.ts.map +0 -1
  359. package/dist/stories/shared-utils/decorators/WithTimeRange.js +0 -33
  360. package/dist/stories/shared-utils/decorators/WithTimeRange.js.map +0 -1
  361. package/dist/stories/shared-utils/decorators/index.d.ts +0 -7
  362. package/dist/stories/shared-utils/decorators/index.d.ts.map +0 -1
  363. package/dist/stories/shared-utils/decorators/index.js +0 -20
  364. package/dist/stories/shared-utils/decorators/index.js.map +0 -1
  365. package/dist/stories/shared-utils/index.d.ts +0 -2
  366. package/dist/stories/shared-utils/index.d.ts.map +0 -1
  367. package/dist/stories/shared-utils/index.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 +0 -22
  371. package/dist/validation/datasource.js.map +0 -1
  372. package/dist/validation/duration.d.ts +0 -3
  373. package/dist/validation/duration.d.ts.map +0 -1
  374. package/dist/validation/duration.js.map +0 -1
  375. package/dist/validation/index.d.ts +0 -6
  376. package/dist/validation/index.d.ts.map +0 -1
  377. package/dist/validation/index.js.map +0 -1
  378. package/dist/validation/resource.d.ts +0 -3
  379. package/dist/validation/resource.d.ts.map +0 -1
  380. package/dist/validation/resource.js +0 -16
  381. package/dist/validation/resource.js.map +0 -1
  382. package/dist/validation/role.d.ts +0 -228
  383. package/dist/validation/role.d.ts.map +0 -1
  384. package/dist/validation/role.js +0 -67
  385. package/dist/validation/role.js.map +0 -1
  386. package/dist/validation/rolebinding.d.ts +0 -137
  387. package/dist/validation/rolebinding.d.ts.map +0 -1
  388. package/dist/validation/rolebinding.js +0 -47
  389. package/dist/validation/rolebinding.js.map +0 -1
  390. package/dist/validation/secret.d.ts +0 -964
  391. package/dist/validation/secret.d.ts.map +0 -1
  392. package/dist/validation/secret.js +0 -157
  393. package/dist/validation/secret.js.map +0 -1
  394. package/dist/validation/user.d.ts +0 -93
  395. package/dist/validation/user.d.ts.map +0 -1
  396. package/dist/validation/user.js +0 -38
  397. package/dist/validation/user.js.map +0 -1
  398. package/dist/validation/variable.d.ts +0 -96
  399. package/dist/validation/variable.d.ts.map +0 -1
  400. package/dist/validation/variable.js +0 -40
  401. package/dist/validation/variable.js.map +0 -1
@@ -1,4 +1,4 @@
1
- // Copyright 2023 The Perses Authors
1
+ // Copyright 2024 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -14,10 +14,10 @@
14
14
  Object.defineProperty(exports, "__esModule", {
15
15
  value: true
16
16
  });
17
- Object.defineProperty(exports, "TimeSeriesQueryEditor", {
17
+ Object.defineProperty(exports, "MultiQueryEditor", {
18
18
  enumerable: true,
19
19
  get: function() {
20
- return TimeSeriesQueryEditor;
20
+ return MultiQueryEditor;
21
21
  }
22
22
  });
23
23
  const _jsxruntime = require("react/jsx-runtime");
@@ -26,36 +26,43 @@ const _immer = require("immer");
26
26
  const _material = require("@mui/material");
27
27
  const _Plus = /*#__PURE__*/ _interop_require_default(require("mdi-material-ui/Plus"));
28
28
  const _runtime = require("../../runtime");
29
- const _TimeSeriesQueryInput = require("./TimeSeriesQueryInput");
29
+ const _QueryEditorContainer = require("./QueryEditorContainer");
30
30
  function _interop_require_default(obj) {
31
31
  return obj && obj.__esModule ? obj : {
32
32
  default: obj
33
33
  };
34
34
  }
35
- function TimeSeriesQueryEditor({ queries = [], onChange }) {
36
- var _timeSeriesPlugins_;
35
+ function useDefaultQueryDefinition(queryTypes) {
37
36
  // Build the default query plugin
37
+ // This will be used only if the queries are empty, to open a starting query
38
+ // Firs the default query type
39
+ const defaultQueryType = queryTypes[0];
40
+ // Then the default plugin kind
38
41
  // Use as default the plugin kind explicitly set as default or the first in the list
42
+ const { data: queryPlugins, isLoading } = (0, _runtime.useListPluginMetadata)(queryTypes);
39
43
  const { defaultPluginKinds } = (0, _runtime.usePluginRegistry)();
40
- const { data: timeSeriesPlugins } = (0, _runtime.useListPluginMetadata)(_runtime.TIME_SERIES_QUERY_KEY);
41
- var _defaultPluginKinds_TIME_SERIES_QUERY_KEY, _ref;
42
- const defaultTimeSeriesQueryKind = (_ref = (_defaultPluginKinds_TIME_SERIES_QUERY_KEY = defaultPluginKinds === null || defaultPluginKinds === void 0 ? void 0 : defaultPluginKinds[_runtime.TIME_SERIES_QUERY_KEY]) !== null && _defaultPluginKinds_TIME_SERIES_QUERY_KEY !== void 0 ? _defaultPluginKinds_TIME_SERIES_QUERY_KEY : timeSeriesPlugins === null || timeSeriesPlugins === void 0 ? void 0 : (_timeSeriesPlugins_ = timeSeriesPlugins[0]) === null || _timeSeriesPlugins_ === void 0 ? void 0 : _timeSeriesPlugins_.kind) !== null && _ref !== void 0 ? _ref : '';
43
- const { data: defaultQueryPlugin } = (0, _runtime.usePlugin)(_runtime.TIME_SERIES_QUERY_KEY, defaultTimeSeriesQueryKind, {
44
- useErrorBoundary: true,
44
+ const defaultQueryKind = defaultPluginKinds?.[defaultQueryType] ?? queryPlugins?.[0]?.spec.name ?? '';
45
+ const { data: defaultQueryPlugin } = (0, _runtime.usePlugin)(defaultQueryType, defaultQueryKind, {
46
+ throwOnError: true,
45
47
  enabled: true
46
48
  });
47
49
  // This default query definition is used if no query is provided initially or when we add a new query
48
- const defaultInitialQueryDefinition = {
49
- kind: _runtime.TIME_SERIES_QUERY_KEY,
50
- spec: {
51
- plugin: {
52
- kind: defaultTimeSeriesQueryKind,
53
- spec: (defaultQueryPlugin === null || defaultQueryPlugin === void 0 ? void 0 : defaultQueryPlugin.createInitialOptions()) || {}
50
+ return {
51
+ defaultInitialQueryDefinition: {
52
+ kind: defaultQueryType,
53
+ spec: {
54
+ plugin: {
55
+ kind: defaultQueryKind,
56
+ spec: defaultQueryPlugin?.createInitialOptions() || {}
57
+ }
54
58
  }
55
- }
59
+ },
60
+ isLoading
56
61
  };
62
+ }
63
+ function MultiQueryEditor({ queryTypes, queries = [], onChange }) {
64
+ const { defaultInitialQueryDefinition, isLoading } = useDefaultQueryDefinition(queryTypes);
57
65
  // State for which queries are collapsed
58
- // TODO: Would be easier if we had IDs for queries.
59
66
  const [queriesCollapsed, setQueriesCollapsed] = (0, _react.useState)(queries.map(()=>false));
60
67
  // Query handlers
61
68
  const handleQueryChange = (index, queryDef)=>{
@@ -70,7 +77,6 @@ function TimeSeriesQueryEditor({ queries = [], onChange }) {
70
77
  }));
71
78
  };
72
79
  const handleQueryAdd = ()=>{
73
- if (!defaultQueryPlugin) return;
74
80
  onChange((0, _immer.produce)(queries, (draft)=>{
75
81
  if (draft) {
76
82
  draft.push(defaultInitialQueryDefinition);
@@ -108,14 +114,15 @@ function TimeSeriesQueryEditor({ queries = [], onChange }) {
108
114
  });
109
115
  };
110
116
  // show one query input if queries is empty
111
- const queryDefinitions = queries.length ? queries : [
117
+ const queryDefinitions = queries.length ? queries : !isLoading ? [
112
118
  defaultInitialQueryDefinition
113
- ];
119
+ ] : [];
114
120
  return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_jsxruntime.Fragment, {
115
121
  children: [
116
122
  /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Stack, {
117
123
  spacing: 1,
118
- children: queryDefinitions.map((query, i)=>/*#__PURE__*/ (0, _jsxruntime.jsx)(_TimeSeriesQueryInput.TimeSeriesQueryInput, {
124
+ children: queryDefinitions.map((query, i)=>/*#__PURE__*/ (0, _jsxruntime.jsx)(_QueryEditorContainer.QueryEditorContainer, {
125
+ queryTypes: queryTypes,
119
126
  index: i,
120
127
  query: query,
121
128
  isCollapsed: !!queriesCollapsed[i],
@@ -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
@@ -14,14 +14,14 @@
14
14
  Object.defineProperty(exports, "__esModule", {
15
15
  value: true
16
16
  });
17
- Object.defineProperty(exports, "TimeSeriesQueryInput", {
17
+ Object.defineProperty(exports, "QueryEditorContainer", {
18
18
  enumerable: true,
19
19
  get: function() {
20
- return TimeSeriesQueryInput;
20
+ return QueryEditorContainer;
21
21
  }
22
22
  });
23
23
  const _jsxruntime = require("react/jsx-runtime");
24
- const _immer = /*#__PURE__*/ _interop_require_default(require("immer"));
24
+ const _immer = require("immer");
25
25
  const _material = require("@mui/material");
26
26
  const _DeleteOutline = /*#__PURE__*/ _interop_require_default(require("mdi-material-ui/DeleteOutline"));
27
27
  const _ChevronDown = /*#__PURE__*/ _interop_require_default(require("mdi-material-ui/ChevronDown"));
@@ -32,7 +32,7 @@ function _interop_require_default(obj) {
32
32
  default: obj
33
33
  };
34
34
  }
35
- const TimeSeriesQueryInput = ({ index, query, isCollapsed, onDelete, onChange, onCollapseExpand })=>{
35
+ const QueryEditorContainer = ({ queryTypes, index, query, isCollapsed, onDelete, onChange, onCollapseExpand })=>{
36
36
  return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
37
37
  spacing: 1,
38
38
  children: [
@@ -51,7 +51,7 @@ const TimeSeriesQueryInput = ({ index, query, isCollapsed, onDelete, onChange, o
51
51
  variant: "overline",
52
52
  component: "h4",
53
53
  children: [
54
- "Query ",
54
+ "Query #",
55
55
  index + 1
56
56
  ]
57
57
  }),
@@ -68,6 +68,7 @@ const TimeSeriesQueryInput = ({ index, query, isCollapsed, onDelete, onChange, o
68
68
  ]
69
69
  }),
70
70
  !isCollapsed && /*#__PURE__*/ (0, _jsxruntime.jsx)(QueryEditor, {
71
+ queryTypes: queryTypes,
71
72
  value: query,
72
73
  onChange: (next)=>onChange(index, next)
73
74
  })
@@ -75,21 +76,32 @@ const TimeSeriesQueryInput = ({ index, query, isCollapsed, onDelete, onChange, o
75
76
  }, index);
76
77
  };
77
78
  /**
78
- * Displays an editor for TimeSeriesQueryDefinition objects.
79
+ * Editor for a query definition. This component is responsible for rendering the plugin editor for the given query.
80
+ * This will allow user to select a plugin extending from the given supported query types, and then edit the plugin
81
+ * spec for this plugin.
82
+ * @param props
83
+ * @constructor
79
84
  */ function QueryEditor(props) {
80
- const { value, onChange, ...others } = props;
81
- const { spec: { plugin } } = value;
85
+ const { value, onChange, queryTypes, ...others } = props;
82
86
  const handlePluginChange = (next)=>{
83
- onChange((0, _immer.default)(value, (draft)=>{
84
- draft.spec.plugin = next;
87
+ onChange((0, _immer.produce)(value, (draft)=>{
88
+ draft.kind = next.selection.type;
89
+ draft.spec.plugin.kind = next.selection.kind;
90
+ draft.spec.plugin.spec = next.spec;
85
91
  }));
86
92
  };
87
93
  return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Box, {
88
94
  ...others,
89
95
  children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_PluginEditor.PluginEditor, {
90
- pluginType: "TimeSeriesQuery",
96
+ pluginTypes: queryTypes,
91
97
  pluginKindLabel: "Query Type",
92
- value: plugin,
98
+ value: {
99
+ selection: {
100
+ kind: value.spec.plugin.kind,
101
+ type: value.kind
102
+ },
103
+ spec: value.spec.plugin.spec
104
+ },
93
105
  onChange: handlePluginChange
94
106
  })
95
107
  });
@@ -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
@@ -14,7 +14,7 @@
14
14
  Object.defineProperty(exports, "__esModule", {
15
15
  value: true
16
16
  });
17
- _export_star(require("./decorators"), exports);
17
+ _export_star(require("./MultiQueryEditor"), exports);
18
18
  function _export_star(from, to) {
19
19
  Object.keys(from).forEach(function(k) {
20
20
  if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
@@ -22,95 +22,87 @@ Object.defineProperty(exports, "PanelSpecEditor", {
22
22
  });
23
23
  const _jsxruntime = require("react/jsx-runtime");
24
24
  const _components = require("@perses-dev/components");
25
+ const _reacthookform = require("react-hook-form");
25
26
  const _runtime = require("../../runtime");
26
27
  const _OptionsEditorTabs = require("../OptionsEditorTabs");
27
- const _TimeSeriesQueryEditor = require("../TimeSeriesQueryEditor");
28
- const _TraceQueryEditor = require("../TraceQueryEditor");
28
+ const _MultiQueryEditor = require("../MultiQueryEditor");
29
29
  function PanelSpecEditor(props) {
30
- const { panelDefinition, onJSONChange, onQueriesChange, onPluginSpecChange } = props;
30
+ const { control, panelDefinition, onJSONChange, onQueriesChange, onPluginSpecChange } = props;
31
31
  const { kind } = panelDefinition.spec.plugin;
32
- const { data: plugin, isLoading, error } = (0, _runtime.usePlugin)('Panel', kind);
32
+ const { data: plugin, isPending, error } = (0, _runtime.usePlugin)('Panel', kind);
33
33
  if (error) {
34
34
  return /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.ErrorAlert, {
35
35
  error: error
36
36
  });
37
37
  }
38
38
  // TODO: Proper loading indicator
39
- if (isLoading) {
39
+ if (isPending) {
40
40
  return null;
41
41
  }
42
42
  if (plugin === undefined) {
43
43
  throw new Error(`Missing implementation for panel plugin with kind '${kind}'`);
44
44
  }
45
- const getQueryType = ()=>{
46
- var _panelDefinition_spec, _queriesList_;
47
- const queriesList = panelDefinition === null || panelDefinition === void 0 ? void 0 : (_panelDefinition_spec = panelDefinition.spec) === null || _panelDefinition_spec === void 0 ? void 0 : _panelDefinition_spec.queries;
48
- if (queriesList === undefined) {
49
- return '';
50
- }
51
- const queryType = (_queriesList_ = queriesList[0]) === null || _queriesList_ === void 0 ? void 0 : _queriesList_.kind;
52
- return queryType;
53
- };
54
- // Get the corresponding queryEditor depending on the queryType
55
- const getQueryEditorComponent = ()=>{
56
- const queryType = getQueryType();
57
- // default case handles cause where there is no queryType yet (e.g. UI > 'editing' mode > 'Add Panel')
58
- switch(queryType){
59
- case 'TimeSeriesQuery':
60
- var _panelDefinition_spec_queries;
61
- return /*#__PURE__*/ (0, _jsxruntime.jsx)(_TimeSeriesQueryEditor.TimeSeriesQueryEditor, {
62
- queries: (_panelDefinition_spec_queries = panelDefinition.spec.queries) !== null && _panelDefinition_spec_queries !== void 0 ? _panelDefinition_spec_queries : [],
63
- onChange: onQueriesChange
64
- });
65
- case 'TraceQuery':
66
- var _panelDefinition_spec_queries1;
67
- return /*#__PURE__*/ (0, _jsxruntime.jsx)(_TraceQueryEditor.TraceQueryEditor, {
68
- queries: (_panelDefinition_spec_queries1 = panelDefinition.spec.queries) !== null && _panelDefinition_spec_queries1 !== void 0 ? _panelDefinition_spec_queries1 : [],
69
- onChange: onQueriesChange
70
- });
71
- default:
72
- // ScatterChart only handles trace queries for now
73
- if (kind === 'ScatterChart') {
74
- var _panelDefinition_spec_queries2;
75
- return /*#__PURE__*/ (0, _jsxruntime.jsx)(_TraceQueryEditor.TraceQueryEditor, {
76
- queries: (_panelDefinition_spec_queries2 = panelDefinition.spec.queries) !== null && _panelDefinition_spec_queries2 !== void 0 ? _panelDefinition_spec_queries2 : [],
77
- onChange: onQueriesChange
78
- });
79
- }
80
- var _panelDefinition_spec_queries3;
81
- return /*#__PURE__*/ (0, _jsxruntime.jsx)(_TimeSeriesQueryEditor.TimeSeriesQueryEditor, {
82
- queries: (_panelDefinition_spec_queries3 = panelDefinition.spec.queries) !== null && _panelDefinition_spec_queries3 !== void 0 ? _panelDefinition_spec_queries3 : [],
83
- onChange: onQueriesChange
84
- });
85
- }
86
- };
87
45
  const { panelOptionsEditorComponents, hideQueryEditor } = plugin;
88
46
  let tabs = [];
89
47
  if (!hideQueryEditor) {
90
48
  tabs.push({
91
49
  label: 'Query',
92
- content: getQueryEditorComponent()
50
+ content: /*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.Controller, {
51
+ control: control,
52
+ name: "panelDefinition.spec.queries",
53
+ render: ({ field })=>/*#__PURE__*/ (0, _jsxruntime.jsx)(_MultiQueryEditor.MultiQueryEditor, {
54
+ queryTypes: plugin.supportedQueryTypes ?? [],
55
+ queries: panelDefinition.spec.queries ?? [],
56
+ onChange: (queries)=>{
57
+ field.onChange(queries);
58
+ onQueriesChange(queries);
59
+ }
60
+ })
61
+ })
93
62
  });
94
63
  }
95
64
  if (panelOptionsEditorComponents !== undefined) {
96
65
  tabs = tabs.concat(panelOptionsEditorComponents.map(({ label, content: OptionsEditorComponent })=>({
97
66
  label,
98
- content: /*#__PURE__*/ (0, _jsxruntime.jsx)(OptionsEditorComponent, {
99
- value: panelDefinition.spec.plugin.spec,
100
- onChange: onPluginSpecChange
67
+ content: /*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.Controller, {
68
+ control: control,
69
+ name: "panelDefinition.spec.plugin.spec",
70
+ render: ({ field })=>/*#__PURE__*/ (0, _jsxruntime.jsx)(OptionsEditorComponent, {
71
+ value: panelDefinition.spec.plugin.spec,
72
+ onChange: (spec)=>{
73
+ field.onChange(spec);
74
+ onPluginSpecChange(spec);
75
+ }
76
+ })
101
77
  })
102
78
  })));
103
79
  }
104
- // always show json editor by default
80
+ // always show json editor and links editor by default
81
+ tabs.push({
82
+ label: 'Links',
83
+ content: /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.LinksEditor, {
84
+ control: control
85
+ })
86
+ });
105
87
  tabs.push({
106
88
  label: 'JSON',
107
- content: /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.JSONEditor, {
108
- maxHeight: "80vh",
109
- value: panelDefinition,
110
- onChange: onJSONChange
89
+ content: /*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.Controller, {
90
+ control: control,
91
+ name: "panelDefinition",
92
+ render: ({ field })=>/*#__PURE__*/ (0, _jsxruntime.jsx)(_components.JSONEditor, {
93
+ maxHeight: "80vh",
94
+ value: panelDefinition,
95
+ onChange: (json)=>{
96
+ field.onChange(JSON.parse(json));
97
+ onJSONChange(json);
98
+ }
99
+ })
111
100
  })
112
101
  });
113
- return /*#__PURE__*/ (0, _jsxruntime.jsx)(_OptionsEditorTabs.OptionsEditorTabs, {
114
- tabs: tabs
115
- }, tabs.length);
102
+ return /*#__PURE__*/ (0, _jsxruntime.jsx)(_runtime.QueryCountProvider, {
103
+ queryCount: (panelDefinition.spec.queries ?? []).length,
104
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_OptionsEditorTabs.OptionsEditorTabs, {
105
+ tabs: tabs
106
+ }, tabs.length)
107
+ });
116
108
  }
@@ -22,40 +22,43 @@ Object.defineProperty(exports, "PluginEditor", {
22
22
  });
23
23
  const _jsxruntime = require("react/jsx-runtime");
24
24
  const _material = require("@mui/material");
25
+ const _components = require("@perses-dev/components");
25
26
  const _PluginKindSelect = require("../PluginKindSelect");
26
27
  const _PluginSpecEditor = require("../PluginSpecEditor");
27
28
  const _plugineditorapi = require("./plugin-editor-api");
28
29
  function PluginEditor(props) {
29
30
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
30
- const { value, pluginType, pluginKindLabel, onChange: _, isReadonly, ...others } = props;
31
- const { pendingKind, isLoading, error, onKindChange, onSpecChange } = (0, _plugineditorapi.usePluginEditor)(props);
31
+ const { value, pluginTypes, pluginKindLabel, onChange: _, isReadonly, ...others } = props;
32
+ const { pendingSelection, isLoading, error, onSelectionChange, onSpecChange } = (0, _plugineditorapi.usePluginEditor)(props);
32
33
  return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Box, {
33
34
  ...others,
34
35
  children: [
35
36
  /*#__PURE__*/ (0, _jsxruntime.jsx)(_PluginKindSelect.PluginKindSelect, {
36
37
  fullWidth: false,
37
38
  sx: {
38
- mb: 1,
39
+ mb: 2,
39
40
  minWidth: 120
40
41
  },
41
42
  margin: "dense",
42
43
  label: pluginKindLabel,
43
- pluginType: pluginType,
44
+ pluginTypes: pluginTypes,
44
45
  disabled: isLoading,
45
- value: pendingKind !== '' ? pendingKind : value.kind,
46
+ value: pendingSelection ? pendingSelection : value.selection,
46
47
  InputProps: {
47
48
  readOnly: isReadonly
48
49
  },
49
50
  error: !!error,
50
- helperText: error === null || error === void 0 ? void 0 : error.message,
51
- onChange: onKindChange
51
+ helperText: error?.message,
52
+ onChange: onSelectionChange
52
53
  }),
53
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_PluginSpecEditor.PluginSpecEditor, {
54
- pluginType: pluginType,
55
- pluginKind: value.kind,
56
- value: value.spec,
57
- onChange: onSpecChange,
58
- isReadonly: isReadonly
54
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.ErrorBoundary, {
55
+ FallbackComponent: _components.ErrorAlert,
56
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_PluginSpecEditor.PluginSpecEditor, {
57
+ pluginSelection: value.selection,
58
+ value: value.spec,
59
+ onChange: onSpecChange,
60
+ isReadonly: isReadonly
61
+ })
59
62
  })
60
63
  ]
61
64
  });
@@ -26,84 +26,95 @@ const _immer = require("immer");
26
26
  const _runtime = require("../../runtime");
27
27
  function usePluginEditor(props) {
28
28
  // eslint-disable-next-line @typescript-eslint/no-empty-function
29
- const { pluginType, value, onHideQueryEditorChange = ()=>{} } = props; // setting onHideQueryEditorChange to empty function here because useEvent requires a function
30
- // Keep a stable reference so we don't run the effect below when we don't need to
29
+ const { pluginTypes, value, onHideQueryEditorChange = ()=>{} } = props; // setting onHideQueryEditorChange to empty function here because useEvent requires a function
30
+ // Keep a stable reference, so we don't run the effect below when we don't need to
31
31
  const onChange = (0, _core.useEvent)(props.onChange);
32
32
  const onHideQuery = (0, _core.useEvent)(onHideQueryEditorChange);
33
33
  // The previous spec state for PluginType and kind and a helper function for remembering current values
34
34
  const prevSpecState = (0, _react.useRef)({
35
- [pluginType]: {
36
- [value.kind]: value.spec
35
+ [value.selection.type]: {
36
+ [value.selection.kind]: value.spec
37
37
  }
38
38
  });
39
39
  const rememberCurrentSpecState = (0, _core.useEvent)(()=>{
40
- let byPluginType = prevSpecState.current[pluginType];
40
+ let byPluginType = prevSpecState.current[value.selection.type];
41
41
  if (byPluginType === undefined) {
42
42
  byPluginType = {};
43
- prevSpecState.current[pluginType] = byPluginType;
43
+ prevSpecState.current[value.selection.type] = byPluginType;
44
44
  }
45
- byPluginType[value.kind] = value.spec;
45
+ byPluginType[value.selection.kind] = value.spec;
46
46
  });
47
47
  // The previous hide query state for each panel kind
48
48
  const hideQueryState = (0, _react.useRef)({
49
- [value.kind]: false
49
+ [value.selection.kind]: false
50
50
  });
51
51
  const { defaultPluginKinds } = (0, _runtime.usePluginRegistry)();
52
- const defaultPluginKind = defaultPluginKinds === null || defaultPluginKinds === void 0 ? void 0 : defaultPluginKinds[pluginType];
53
- const initPendingKind = !value.kind && defaultPluginKind ? defaultPluginKind : '';
52
+ const defaultPluginType = pluginTypes[0];
53
+ const defaultPluginKind = defaultPluginType ? defaultPluginKinds?.[defaultPluginType] : undefined;
54
+ const defaultPluginSelection = defaultPluginType && defaultPluginKind ? {
55
+ type: defaultPluginType,
56
+ kind: defaultPluginKind
57
+ } : undefined;
58
+ const initPendingSelection = !value.selection && defaultPluginSelection ? defaultPluginSelection : undefined;
54
59
  // When kind changes and we haven't loaded that plugin before, we will need to enter a "pending" state so that we
55
60
  // can generate proper initial spec values that match the new plugin kind
56
- const [pendingKind, setPendingKind] = (0, _react.useState)(initPendingKind);
57
- const { data: plugin, isFetching, error } = (0, _runtime.usePlugin)(pluginType, pendingKind);
61
+ const [pendingSelection, setPendingSelection] = (0, _react.useState)(initPendingSelection);
62
+ // Take a default kind in case user write explicitly an empty kind in the initial value
63
+ (0, _react.useEffect)(()=>{
64
+ if (value.selection.kind === '') {
65
+ value.selection.kind = defaultPluginKind || '';
66
+ }
67
+ }, [
68
+ value.selection,
69
+ defaultPluginKind
70
+ ]);
71
+ const { data: plugin, isFetching, error } = (0, _runtime.usePlugin)(pendingSelection?.type, pendingSelection?.kind || '');
58
72
  (0, _react.useEffect)(()=>{
59
73
  // Nothing to do if no new plugin kind is pending
60
- if (pendingKind === '') return;
74
+ if (!pendingSelection) return;
61
75
  // Can't get spec value until we have a plugin
62
76
  if (plugin === undefined) return;
63
77
  // Fire an onChange to change to the pending kind with initial values from the plugin
64
78
  rememberCurrentSpecState();
65
79
  onChange({
66
- kind: pendingKind,
67
- spec: plugin.createInitialOptions()
80
+ selection: pendingSelection,
81
+ spec: plugin.createInitialOptions ? plugin.createInitialOptions() : {}
68
82
  });
69
- if (pluginType === 'Panel') {
83
+ if (pendingSelection.type === 'Panel') {
70
84
  const panelPlugin = plugin;
71
- hideQueryState.current[pendingKind] = !!panelPlugin.hideQueryEditor;
72
- if (!!panelPlugin.hideQueryEditor !== hideQueryState.current[value.kind]) {
85
+ hideQueryState.current[pendingSelection.kind] = !!panelPlugin.hideQueryEditor;
86
+ if (!!panelPlugin.hideQueryEditor !== hideQueryState.current[value.selection.kind]) {
73
87
  onHideQuery(!!panelPlugin.hideQueryEditor);
74
88
  }
75
89
  }
76
- setPendingKind('');
90
+ setPendingSelection(undefined);
77
91
  }, [
78
- pendingKind,
92
+ pendingSelection,
79
93
  plugin,
80
94
  rememberCurrentSpecState,
81
95
  onChange,
82
96
  onHideQuery,
83
97
  hideQueryState,
84
- pluginType,
85
- value.kind
98
+ value.selection
86
99
  ]);
87
100
  /**
88
101
  * When the user tries to change the plugin kind, make sure we have the correct spec for that plugin kind before we
89
102
  * make the switch.
90
- */ const onKindChange = (e)=>{
91
- var _prevSpecState_current_pluginType;
92
- const nextKind = e.target.value;
103
+ */ const onSelectionChange = (nextSelection)=>{
93
104
  // If we already have state for this plugin type/kind from a previous selection, just use it
94
- const previousState = (_prevSpecState_current_pluginType = prevSpecState.current[pluginType]) === null || _prevSpecState_current_pluginType === void 0 ? void 0 : _prevSpecState_current_pluginType[nextKind];
105
+ const previousState = prevSpecState.current[nextSelection.type]?.[nextSelection.kind];
95
106
  if (previousState !== undefined) {
96
107
  rememberCurrentSpecState();
97
108
  onChange({
98
- kind: nextKind,
109
+ selection: nextSelection,
99
110
  spec: previousState
100
111
  });
101
112
  } else {
102
113
  // Otherwise, kick off the async loading process
103
- setPendingKind(nextKind);
114
+ setPendingSelection(nextSelection);
104
115
  }
105
- if (pluginType === 'Panel' && hideQueryState.current[nextKind] !== undefined && hideQueryState.current[value.kind] !== hideQueryState.current[nextKind]) {
106
- onHideQuery(!!hideQueryState.current[nextKind]);
116
+ if (nextSelection.type === 'Panel' && hideQueryState.current[nextSelection.kind] !== undefined && hideQueryState.current[value.selection.kind] !== hideQueryState.current[nextSelection.kind]) {
117
+ onHideQuery(!!hideQueryState.current[nextSelection.kind]);
107
118
  }
108
119
  };
109
120
  /**
@@ -114,10 +125,10 @@ function usePluginEditor(props) {
114
125
  }));
115
126
  };
116
127
  return {
117
- pendingKind,
128
+ pendingSelection,
118
129
  isLoading: isFetching,
119
130
  error,
120
- onKindChange,
131
+ onSelectionChange,
121
132
  onSpecChange,
122
133
  rememberCurrentSpecState
123
134
  };
@@ -25,28 +25,76 @@ const _material = require("@mui/material");
25
25
  const _react = require("react");
26
26
  const _runtime = require("../../runtime");
27
27
  const PluginKindSelect = /*#__PURE__*/ (0, _react.forwardRef)((props, ref)=>{
28
- const { pluginType, value: propValue, ...others } = props;
29
- const { data, isLoading } = (0, _runtime.useListPluginMetadata)(pluginType);
28
+ const { pluginTypes, value: propValue, onChange, ...others } = props;
29
+ const { data, isLoading } = (0, _runtime.useListPluginMetadata)(pluginTypes);
30
30
  // Pass an empty value while options are still loading so MUI doesn't complain about us using an "out of range" value
31
- const value = propValue !== '' && isLoading ? '' : propValue;
31
+ const value = !propValue || isLoading ? '' : selectionToOptionValue(propValue);
32
+ const handleChange = (event)=>{
33
+ onChange?.(optionValueToSelection(event.target.value));
34
+ };
35
+ const renderValue = (0, _react.useCallback)((selected)=>{
36
+ if (selected === '') {
37
+ return '';
38
+ }
39
+ const selectedValue = optionValueToSelection(selected);
40
+ return data?.find((v)=>v.kind === selectedValue.type && v.spec.name === selectedValue.kind)?.spec.display.name;
41
+ }, [
42
+ data
43
+ ]);
32
44
  // TODO: Does this need a loading indicator of some kind?
33
45
  return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.TextField, {
34
46
  select: true,
35
47
  inputRef: ref,
36
48
  ...others,
37
49
  value: value,
50
+ "aria-label": value,
51
+ onChange: handleChange,
52
+ SelectProps: {
53
+ renderValue
54
+ },
38
55
  "data-testid": "plugin-kind-select",
39
56
  children: [
40
57
  isLoading && /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.MenuItem, {
41
58
  value: "",
42
59
  children: "Loading..."
43
60
  }),
44
- data === null || data === void 0 ? void 0 : data.map((metadata)=>/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.MenuItem, {
61
+ data?.map((metadata)=>/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.MenuItem, {
45
62
  "data-testid": "option",
46
- value: metadata.kind,
47
- children: metadata.display.name
48
- }, metadata.kind))
63
+ value: selectionToOptionValue({
64
+ type: metadata.kind,
65
+ kind: metadata.spec.name
66
+ }),
67
+ children: metadata.spec.display.name
68
+ }, metadata.kind + metadata.spec.name))
49
69
  ]
50
70
  });
51
71
  });
52
72
  PluginKindSelect.displayName = 'PluginKindSelect';
73
+ // Delimiter used to stringify/parse option values
74
+ const OPTION_VALUE_DELIMITER = '_____';
75
+ /**
76
+ * Given a PluginEditorSelection,
77
+ * returns a string value like `{type}_____{kind}` that can be used as a Select input value.
78
+ * @param selector
79
+ */ function selectionToOptionValue(selector) {
80
+ return [
81
+ selector.type,
82
+ selector.kind
83
+ ].join(OPTION_VALUE_DELIMITER);
84
+ }
85
+ /**
86
+ * Given an option value name like `{type}_____{kind}`,
87
+ * returns a PluginEditorSelection to be used by the query data model.
88
+ * @param optionValue
89
+ */ function optionValueToSelection(optionValue) {
90
+ const words = optionValue.split(OPTION_VALUE_DELIMITER);
91
+ const type = words[0];
92
+ const kind = words[1];
93
+ if (type === undefined || kind === undefined) {
94
+ throw new Error('Invalid optionValue string');
95
+ }
96
+ return {
97
+ type,
98
+ kind
99
+ };
100
+ }