@perses-dev/plugin-system 0.54.0-beta.0 → 0.54.0-beta.2

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 (225) hide show
  1. package/dist/cjs/components/CalculationSelector/CalculationSelector.js +3 -3
  2. package/dist/cjs/components/DatasourceEditorForm/DatasourceEditorForm.js +2 -3
  3. package/dist/cjs/components/LegendOptionsEditor/LegendOptionsEditor.js +4 -5
  4. package/dist/cjs/components/PluginRegistry/PluginRegistry.js +11 -15
  5. package/dist/cjs/components/PluginRegistry/getPluginSearchHelper.js +92 -0
  6. package/dist/cjs/components/PluginRegistry/plugin-indexes.js +16 -13
  7. package/dist/cjs/components/Variables/VariableEditorForm/VariableEditorForm.js +2 -3
  8. package/dist/cjs/components/Variables/variable-model.js +115 -29
  9. package/dist/cjs/context/ValidationProvider.js +3 -3
  10. package/dist/cjs/model/alerts-queries.js +16 -0
  11. package/dist/cjs/model/calculations.js +178 -0
  12. package/dist/cjs/model/index.js +3 -0
  13. package/dist/cjs/model/legend.js +6 -5
  14. package/dist/cjs/model/log-volume-utils.js +10 -10
  15. package/dist/cjs/model/plugin-loading.js +24 -8
  16. package/dist/cjs/model/plugins.js +10 -0
  17. package/dist/cjs/model/silences-queries.js +16 -0
  18. package/dist/cjs/model/time-series-queries.js +10 -0
  19. package/dist/cjs/remote/PluginRuntime.js +38 -9
  20. package/dist/cjs/remote/remotePluginLoader.js +28 -5
  21. package/dist/cjs/runtime/DataQueriesProvider/DataQueriesProvider.js +18 -2
  22. package/dist/cjs/runtime/DataQueriesProvider/model.js +30 -4
  23. package/dist/cjs/runtime/UsageMetricsProvider.js +2 -2
  24. package/dist/cjs/runtime/alerts-queries.js +101 -0
  25. package/dist/cjs/runtime/index.js +2 -0
  26. package/dist/cjs/runtime/item-actions.js +3 -3
  27. package/dist/cjs/runtime/log-queries.js +4 -1
  28. package/dist/cjs/runtime/plugin-registry.js +12 -3
  29. package/dist/cjs/runtime/profile-queries.js +4 -1
  30. package/dist/cjs/runtime/silences-queries.js +101 -0
  31. package/dist/cjs/runtime/time-series-queries.js +4 -1
  32. package/dist/cjs/runtime/trace-queries.js +4 -1
  33. package/dist/cjs/test/mock-data.js +51 -0
  34. package/dist/cjs/test/test-plugins/bert/index.js +9 -12
  35. package/dist/cjs/test/test-plugins/ernie/index.js +9 -12
  36. package/dist/cjs/test/test-plugins/index.js +2 -2
  37. package/dist/cjs/test/utils.js +2 -2
  38. package/dist/cjs/test-utils/mock-plugin-registry.js +8 -2
  39. package/dist/cjs/utils/index.js +0 -1
  40. package/dist/components/CalculationSelector/CalculationSelector.d.ts +1 -1
  41. package/dist/components/CalculationSelector/CalculationSelector.d.ts.map +1 -1
  42. package/dist/components/CalculationSelector/CalculationSelector.js +2 -2
  43. package/dist/components/CalculationSelector/CalculationSelector.js.map +1 -1
  44. package/dist/components/DatasourceEditorForm/DatasourceEditorForm.d.ts +2 -1
  45. package/dist/components/DatasourceEditorForm/DatasourceEditorForm.d.ts.map +1 -1
  46. package/dist/components/DatasourceEditorForm/DatasourceEditorForm.js +2 -3
  47. package/dist/components/DatasourceEditorForm/DatasourceEditorForm.js.map +1 -1
  48. package/dist/components/DatasourceSelect/DatasourceSelect.js +2 -2
  49. package/dist/components/DatasourceSelect/DatasourceSelect.js.map +1 -1
  50. package/dist/components/HTTPSettingsEditor/HTTPSettingsEditor.d.ts +1 -1
  51. package/dist/components/HTTPSettingsEditor/HTTPSettingsEditor.d.ts.map +1 -1
  52. package/dist/components/HTTPSettingsEditor/HTTPSettingsEditor.js +1 -1
  53. package/dist/components/HTTPSettingsEditor/HTTPSettingsEditor.js.map +1 -1
  54. package/dist/components/ItemSelectionActionsOptionsEditor/ItemSelectionActionsOptionsEditor.js +1 -1
  55. package/dist/components/ItemSelectionActionsOptionsEditor/ItemSelectionActionsOptionsEditor.js.map +1 -1
  56. package/dist/components/LegendOptionsEditor/LegendOptionsEditor.d.ts.map +1 -1
  57. package/dist/components/LegendOptionsEditor/LegendOptionsEditor.js +2 -3
  58. package/dist/components/LegendOptionsEditor/LegendOptionsEditor.js.map +1 -1
  59. package/dist/components/MetricLabelInput/MetricLabelInput.js +1 -1
  60. package/dist/components/MetricLabelInput/MetricLabelInput.js.map +1 -1
  61. package/dist/components/MultiQueryEditor/MultiQueryEditor.d.ts +1 -1
  62. package/dist/components/MultiQueryEditor/MultiQueryEditor.js +1 -1
  63. package/dist/components/MultiQueryEditor/MultiQueryEditor.js.map +1 -1
  64. package/dist/components/MultiQueryEditor/QueryEditorContainer.js +1 -1
  65. package/dist/components/MultiQueryEditor/QueryEditorContainer.js.map +1 -1
  66. package/dist/components/OptionsEditorRadios/OptionsEditorRadios.js +1 -1
  67. package/dist/components/OptionsEditorRadios/OptionsEditorRadios.js.map +1 -1
  68. package/dist/components/OptionsEditorTabPanel/OptionsEditorTabPanel.js +1 -1
  69. package/dist/components/OptionsEditorTabPanel/OptionsEditorTabPanel.js.map +1 -1
  70. package/dist/components/OptionsEditorTabs/OptionsEditorTabs.js +1 -1
  71. package/dist/components/OptionsEditorTabs/OptionsEditorTabs.js.map +1 -1
  72. package/dist/components/PanelSpecEditor/PanelSpecEditor.js +1 -1
  73. package/dist/components/PanelSpecEditor/PanelSpecEditor.js.map +1 -1
  74. package/dist/components/PluginEditor/PluginEditor.js +1 -1
  75. package/dist/components/PluginEditor/PluginEditor.js.map +1 -1
  76. package/dist/components/PluginKindSelect/PluginKindSelect.js +1 -1
  77. package/dist/components/PluginKindSelect/PluginKindSelect.js.map +1 -1
  78. package/dist/components/PluginRegistry/PluginRegistry.d.ts.map +1 -1
  79. package/dist/components/PluginRegistry/PluginRegistry.js +12 -16
  80. package/dist/components/PluginRegistry/PluginRegistry.js.map +1 -1
  81. package/dist/components/PluginRegistry/getPluginSearchHelper.d.ts +12 -0
  82. package/dist/components/PluginRegistry/getPluginSearchHelper.d.ts.map +1 -0
  83. package/dist/components/PluginRegistry/getPluginSearchHelper.js +88 -0
  84. package/dist/components/PluginRegistry/getPluginSearchHelper.js.map +1 -0
  85. package/dist/components/PluginRegistry/plugin-indexes.d.ts +4 -6
  86. package/dist/components/PluginRegistry/plugin-indexes.d.ts.map +1 -1
  87. package/dist/components/PluginRegistry/plugin-indexes.js +15 -13
  88. package/dist/components/PluginRegistry/plugin-indexes.js.map +1 -1
  89. package/dist/components/PluginSpecEditor/PluginSpecEditor.d.ts.map +1 -1
  90. package/dist/components/PluginSpecEditor/PluginSpecEditor.js +1 -1
  91. package/dist/components/PluginSpecEditor/PluginSpecEditor.js.map +1 -1
  92. package/dist/components/SelectionOptionsEditor/SelectionOptionsEditor.js +1 -1
  93. package/dist/components/SelectionOptionsEditor/SelectionOptionsEditor.js.map +1 -1
  94. package/dist/components/TimeRangeControls/TimeRangeControls.js +1 -1
  95. package/dist/components/TimeRangeControls/TimeRangeControls.js.map +1 -1
  96. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts +1 -1
  97. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts.map +1 -1
  98. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js +2 -3
  99. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js.map +1 -1
  100. package/dist/components/Variables/VariableEditorForm/VariablePreview.js +1 -1
  101. package/dist/components/Variables/VariableEditorForm/VariablePreview.js.map +1 -1
  102. package/dist/components/Variables/variable-model.d.ts +9 -1
  103. package/dist/components/Variables/variable-model.d.ts.map +1 -1
  104. package/dist/components/Variables/variable-model.js +117 -31
  105. package/dist/components/Variables/variable-model.js.map +1 -1
  106. package/dist/context/ValidationProvider.d.ts +1 -1
  107. package/dist/context/ValidationProvider.d.ts.map +1 -1
  108. package/dist/context/ValidationProvider.js +2 -2
  109. package/dist/context/ValidationProvider.js.map +1 -1
  110. package/dist/model/alerts-queries.d.ts +33 -0
  111. package/dist/model/alerts-queries.d.ts.map +1 -0
  112. package/dist/{utils/action.js → model/alerts-queries.js} +2 -14
  113. package/dist/model/alerts-queries.js.map +1 -0
  114. package/dist/model/calculations.d.ts +45 -0
  115. package/dist/model/calculations.d.ts.map +1 -0
  116. package/dist/model/calculations.js +165 -0
  117. package/dist/model/calculations.js.map +1 -0
  118. package/dist/model/index.d.ts +3 -0
  119. package/dist/model/index.d.ts.map +1 -1
  120. package/dist/model/index.js +3 -0
  121. package/dist/model/index.js.map +1 -1
  122. package/dist/model/legend.d.ts +3 -2
  123. package/dist/model/legend.d.ts.map +1 -1
  124. package/dist/model/legend.js +2 -1
  125. package/dist/model/legend.js.map +1 -1
  126. package/dist/model/plugin-loading.d.ts.map +1 -1
  127. package/dist/model/plugin-loading.js +24 -8
  128. package/dist/model/plugin-loading.js.map +1 -1
  129. package/dist/model/plugins.d.ts +21 -0
  130. package/dist/model/plugins.d.ts.map +1 -1
  131. package/dist/model/plugins.js +4 -1
  132. package/dist/model/plugins.js.map +1 -1
  133. package/dist/model/silences-queries.d.ts +33 -0
  134. package/dist/model/silences-queries.d.ts.map +1 -0
  135. package/dist/model/silences-queries.js +15 -0
  136. package/dist/model/silences-queries.js.map +1 -0
  137. package/dist/model/time-series-queries.d.ts +11 -1
  138. package/dist/model/time-series-queries.d.ts.map +1 -1
  139. package/dist/model/time-series-queries.js +4 -1
  140. package/dist/model/time-series-queries.js.map +1 -1
  141. package/dist/remote/PersesPlugin.types.d.ts +2 -0
  142. package/dist/remote/PersesPlugin.types.d.ts.map +1 -1
  143. package/dist/remote/PersesPlugin.types.js.map +1 -1
  144. package/dist/remote/PluginLoaderComponent.js +1 -1
  145. package/dist/remote/PluginLoaderComponent.js.map +1 -1
  146. package/dist/remote/PluginRuntime.d.ts +7 -1
  147. package/dist/remote/PluginRuntime.d.ts.map +1 -1
  148. package/dist/remote/PluginRuntime.js +38 -9
  149. package/dist/remote/PluginRuntime.js.map +1 -1
  150. package/dist/remote/remotePluginLoader.d.ts.map +1 -1
  151. package/dist/remote/remotePluginLoader.js +28 -5
  152. package/dist/remote/remotePluginLoader.js.map +1 -1
  153. package/dist/runtime/DataQueriesProvider/DataQueriesProvider.d.ts.map +1 -1
  154. package/dist/runtime/DataQueriesProvider/DataQueriesProvider.js +19 -3
  155. package/dist/runtime/DataQueriesProvider/DataQueriesProvider.js.map +1 -1
  156. package/dist/runtime/DataQueriesProvider/model.d.ts.map +1 -1
  157. package/dist/runtime/DataQueriesProvider/model.js +30 -4
  158. package/dist/runtime/DataQueriesProvider/model.js.map +1 -1
  159. package/dist/runtime/QueryCountProvider.js +1 -1
  160. package/dist/runtime/QueryCountProvider.js.map +1 -1
  161. package/dist/runtime/RouterProvider.js +1 -1
  162. package/dist/runtime/RouterProvider.js.map +1 -1
  163. package/dist/runtime/TimeRangeProvider/TimeRangeProvider.js +1 -1
  164. package/dist/runtime/TimeRangeProvider/TimeRangeProvider.js.map +1 -1
  165. package/dist/runtime/TimeRangeProvider/TimeRangeSettingsProvider.js +1 -1
  166. package/dist/runtime/TimeRangeProvider/TimeRangeSettingsProvider.js.map +1 -1
  167. package/dist/runtime/UsageMetricsProvider.js +2 -2
  168. package/dist/runtime/UsageMetricsProvider.js.map +1 -1
  169. package/dist/runtime/alerts-queries.d.ts +11 -0
  170. package/dist/runtime/alerts-queries.d.ts.map +1 -0
  171. package/dist/runtime/alerts-queries.js +89 -0
  172. package/dist/runtime/alerts-queries.js.map +1 -0
  173. package/dist/runtime/index.d.ts +2 -0
  174. package/dist/runtime/index.d.ts.map +1 -1
  175. package/dist/runtime/index.js +2 -0
  176. package/dist/runtime/index.js.map +1 -1
  177. package/dist/runtime/item-actions.js +1 -1
  178. package/dist/runtime/item-actions.js.map +1 -1
  179. package/dist/runtime/log-queries.js +4 -1
  180. package/dist/runtime/log-queries.js.map +1 -1
  181. package/dist/runtime/plugin-registry.d.ts +2 -1
  182. package/dist/runtime/plugin-registry.d.ts.map +1 -1
  183. package/dist/runtime/plugin-registry.js +12 -3
  184. package/dist/runtime/plugin-registry.js.map +1 -1
  185. package/dist/runtime/profile-queries.js +4 -1
  186. package/dist/runtime/profile-queries.js.map +1 -1
  187. package/dist/runtime/silences-queries.d.ts +11 -0
  188. package/dist/runtime/silences-queries.d.ts.map +1 -0
  189. package/dist/runtime/silences-queries.js +89 -0
  190. package/dist/runtime/silences-queries.js.map +1 -0
  191. package/dist/runtime/time-series-queries.js +4 -1
  192. package/dist/runtime/time-series-queries.js.map +1 -1
  193. package/dist/runtime/trace-queries.js +4 -1
  194. package/dist/runtime/trace-queries.js.map +1 -1
  195. package/dist/test/mock-data.d.ts +3 -1
  196. package/dist/test/mock-data.d.ts.map +1 -1
  197. package/dist/test/mock-data.js +45 -0
  198. package/dist/test/mock-data.js.map +1 -1
  199. package/dist/test/render.js +1 -1
  200. package/dist/test/render.js.map +1 -1
  201. package/dist/test/test-plugins/bert/index.d.ts +12 -6
  202. package/dist/test/test-plugins/bert/index.d.ts.map +1 -1
  203. package/dist/test/test-plugins/bert/index.js +6 -2
  204. package/dist/test/test-plugins/bert/index.js.map +1 -1
  205. package/dist/test/test-plugins/ernie/index.d.ts +8 -6
  206. package/dist/test/test-plugins/ernie/index.d.ts.map +1 -1
  207. package/dist/test/test-plugins/ernie/index.js +6 -2
  208. package/dist/test/test-plugins/ernie/index.js.map +1 -1
  209. package/dist/test/test-plugins/index.js +2 -2
  210. package/dist/test/test-plugins/index.js.map +1 -1
  211. package/dist/test/utils.d.ts.map +1 -1
  212. package/dist/test/utils.js +2 -2
  213. package/dist/test/utils.js.map +1 -1
  214. package/dist/test-utils/mock-plugin-registry.d.ts.map +1 -1
  215. package/dist/test-utils/mock-plugin-registry.js +8 -2
  216. package/dist/test-utils/mock-plugin-registry.js.map +1 -1
  217. package/dist/utils/index.d.ts +0 -1
  218. package/dist/utils/index.d.ts.map +1 -1
  219. package/dist/utils/index.js +0 -1
  220. package/dist/utils/index.js.map +1 -1
  221. package/package.json +6 -5
  222. package/dist/cjs/utils/action.js +0 -43
  223. package/dist/utils/action.d.ts +0 -4
  224. package/dist/utils/action.d.ts.map +0 -1
  225. package/dist/utils/action.js.map +0 -1
@@ -0,0 +1,101 @@
1
+ // Copyright The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ "use strict";
14
+ Object.defineProperty(exports, "__esModule", {
15
+ value: true
16
+ });
17
+ function _export(target, all) {
18
+ for(var name in all)Object.defineProperty(target, name, {
19
+ enumerable: true,
20
+ get: Object.getOwnPropertyDescriptor(all, name).get
21
+ });
22
+ }
23
+ _export(exports, {
24
+ get ALERTS_QUERY_KEY () {
25
+ return ALERTS_QUERY_KEY;
26
+ },
27
+ get useAlertsQueries () {
28
+ return useAlertsQueries;
29
+ }
30
+ });
31
+ const _reactquery = require("@tanstack/react-query");
32
+ const _datasources = require("./datasources");
33
+ const _pluginregistry = require("./plugin-registry");
34
+ const _variables = require("./variables");
35
+ const _utils = require("./utils");
36
+ const ALERTS_QUERY_KEY = 'AlertsQuery';
37
+ function useAlertsQueries(definitions) {
38
+ const { getPlugin } = (0, _pluginregistry.usePluginRegistry)();
39
+ const context = useAlertsQueryContext();
40
+ const pluginLoaderResponse = (0, _pluginregistry.usePlugins)('AlertsQuery', definitions.map((d)=>({
41
+ kind: d.spec.plugin.kind
42
+ })));
43
+ return (0, _reactquery.useQueries)({
44
+ queries: definitions.map((definition, idx)=>{
45
+ const plugin = pluginLoaderResponse[idx]?.data;
46
+ const { queryEnabled, queryKey } = getQueryOptions({
47
+ context,
48
+ definition,
49
+ plugin
50
+ });
51
+ const alertsQueryKind = definition?.spec?.plugin?.kind;
52
+ return {
53
+ enabled: queryEnabled,
54
+ queryKey: queryKey,
55
+ refetchOnMount: false,
56
+ refetchOnWindowFocus: false,
57
+ refetchOnReconnect: false,
58
+ staleTime: 60_000,
59
+ queryFn: async ({ signal })=>{
60
+ const plugin = await getPlugin({
61
+ kind: ALERTS_QUERY_KEY,
62
+ name: alertsQueryKind
63
+ });
64
+ const data = await plugin.getAlertsData(definition.spec.plugin.spec, context, signal);
65
+ return data;
66
+ }
67
+ };
68
+ })
69
+ });
70
+ }
71
+ function getQueryOptions({ plugin, definition, context }) {
72
+ const { variableState } = context;
73
+ const dependencies = plugin?.dependsOn ? plugin.dependsOn(definition.spec.plugin.spec, context) : {};
74
+ const variableDependencies = dependencies?.variables;
75
+ const filteredVariabledState = (0, _utils.filterVariableStateMap)(variableState, variableDependencies);
76
+ const variablesValueKey = (0, _utils.getVariableValuesKey)(filteredVariabledState);
77
+ // Note: no absoluteTimeRange in query key since alerts are current state
78
+ const queryKey = [
79
+ 'query',
80
+ ALERTS_QUERY_KEY,
81
+ definition,
82
+ variablesValueKey
83
+ ];
84
+ let waitToLoad = false;
85
+ if (variableDependencies) {
86
+ waitToLoad = variableDependencies.some((v)=>variableState[v]?.loading);
87
+ }
88
+ const queryEnabled = plugin !== undefined && !waitToLoad;
89
+ return {
90
+ queryKey,
91
+ queryEnabled
92
+ };
93
+ }
94
+ function useAlertsQueryContext() {
95
+ const variableState = (0, _variables.useAllVariableValues)();
96
+ const datasourceStore = (0, _datasources.useDatasourceStore)();
97
+ return {
98
+ variableState,
99
+ datasourceStore
100
+ };
101
+ }
@@ -22,6 +22,8 @@ _export_star(require("./TimeRangeProvider"), exports);
22
22
  _export_star(require("./time-series-queries"), exports);
23
23
  _export_star(require("./trace-queries"), exports);
24
24
  _export_star(require("./profile-queries"), exports);
25
+ _export_star(require("./alerts-queries"), exports);
26
+ _export_star(require("./silences-queries"), exports);
25
27
  _export_star(require("./item-actions"), exports);
26
28
  _export_star(require("./DataQueriesProvider"), exports);
27
29
  _export_star(require("./QueryCountProvider"), exports);
@@ -21,7 +21,7 @@ Object.defineProperty(exports, "executeAction", {
21
21
  }
22
22
  });
23
23
  const _components = require("@perses-dev/components");
24
- const _core = require("@perses-dev/core");
24
+ const _client = require("@perses-dev/client");
25
25
  const BODY_METHODS = new Set([
26
26
  'POST',
27
27
  'PUT',
@@ -174,7 +174,7 @@ function buildWebhookHeaders(action) {
174
174
  body = bodyResult.text;
175
175
  }
176
176
  // Make the request
177
- const response = await (0, _core.fetch)(urlResult.text, {
177
+ const response = await (0, _client.fetch)(urlResult.text, {
178
178
  method: action.method,
179
179
  headers: buildWebhookHeaders(action),
180
180
  body: body
@@ -239,7 +239,7 @@ function buildWebhookHeaders(action) {
239
239
  body = bodyResult.text;
240
240
  }
241
241
  // Make the request
242
- const response = await (0, _core.fetch)(urlResult.text, {
242
+ const response = await (0, _client.fetch)(urlResult.text, {
243
243
  method: action.method,
244
244
  headers: buildWebhookHeaders(action),
245
245
  body: body
@@ -62,7 +62,10 @@ function useLogQueries(definitions) {
62
62
  refetchOnReconnect: false,
63
63
  staleTime: Infinity,
64
64
  queryFn: async ({ signal })=>{
65
- const plugin = await getPlugin(LOG_QUERY_KEY, logQueryKind);
65
+ const plugin = await getPlugin({
66
+ kind: LOG_QUERY_KEY,
67
+ name: logQueryKind
68
+ });
66
69
  const data = await plugin.getLogData(definition.spec.plugin.spec, context, signal);
67
70
  return data;
68
71
  },
@@ -63,7 +63,10 @@ function usePlugin(pluginType, kind, options) {
63
63
  pluginType,
64
64
  kind
65
65
  ],
66
- queryFn: ()=>getPlugin(pluginType, kind),
66
+ queryFn: ()=>getPlugin({
67
+ kind: pluginType,
68
+ name: kind
69
+ }),
67
70
  ...options
68
71
  });
69
72
  }
@@ -84,7 +87,10 @@ function usePlugins(pluginType, plugins) {
84
87
  pluginType,
85
88
  kind
86
89
  ],
87
- queryFn: ()=>getPlugin(pluginType, kind)
90
+ queryFn: ()=>getPlugin({
91
+ kind: pluginType,
92
+ name: kind
93
+ })
88
94
  };
89
95
  })
90
96
  });
@@ -115,7 +121,10 @@ function usePluginBuiltinVariableDefinitions() {
115
121
  const datasourceNames = new Set(datasources.map((datasource)=>datasource.spec.name));
116
122
  const result = [];
117
123
  for (const name of datasourceNames){
118
- const plugin = await getPlugin('Datasource', name);
124
+ const plugin = await getPlugin({
125
+ kind: 'Datasource',
126
+ name
127
+ });
119
128
  if (plugin.getBuiltinVariableDefinitions) {
120
129
  plugin.getBuiltinVariableDefinitions().forEach((definition)=>result.push(definition));
121
130
  }
@@ -59,7 +59,10 @@ function useProfileQueries(definitions) {
59
59
  refetchOnReconnect: false,
60
60
  staleTime: Infinity,
61
61
  queryFn: async ({ signal })=>{
62
- const plugin = await getPlugin(PROFILE_QUERY_KEY, profileQueryKind);
62
+ const plugin = await getPlugin({
63
+ kind: PROFILE_QUERY_KEY,
64
+ name: profileQueryKind
65
+ });
63
66
  const data = await plugin.getProfileData(definition.spec.plugin.spec, context, signal);
64
67
  return data;
65
68
  },
@@ -0,0 +1,101 @@
1
+ // Copyright The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ "use strict";
14
+ Object.defineProperty(exports, "__esModule", {
15
+ value: true
16
+ });
17
+ function _export(target, all) {
18
+ for(var name in all)Object.defineProperty(target, name, {
19
+ enumerable: true,
20
+ get: Object.getOwnPropertyDescriptor(all, name).get
21
+ });
22
+ }
23
+ _export(exports, {
24
+ get SILENCES_QUERY_KEY () {
25
+ return SILENCES_QUERY_KEY;
26
+ },
27
+ get useSilencesQueries () {
28
+ return useSilencesQueries;
29
+ }
30
+ });
31
+ const _reactquery = require("@tanstack/react-query");
32
+ const _datasources = require("./datasources");
33
+ const _pluginregistry = require("./plugin-registry");
34
+ const _variables = require("./variables");
35
+ const _utils = require("./utils");
36
+ const SILENCES_QUERY_KEY = 'SilencesQuery';
37
+ function useSilencesQueries(definitions) {
38
+ const { getPlugin } = (0, _pluginregistry.usePluginRegistry)();
39
+ const context = useSilencesQueryContext();
40
+ const pluginLoaderResponse = (0, _pluginregistry.usePlugins)('SilencesQuery', definitions.map((d)=>({
41
+ kind: d.spec.plugin.kind
42
+ })));
43
+ return (0, _reactquery.useQueries)({
44
+ queries: definitions.map((definition, idx)=>{
45
+ const plugin = pluginLoaderResponse[idx]?.data;
46
+ const { queryEnabled, queryKey } = getQueryOptions({
47
+ context,
48
+ definition,
49
+ plugin
50
+ });
51
+ const silencesQueryKind = definition?.spec?.plugin?.kind;
52
+ return {
53
+ enabled: queryEnabled,
54
+ queryKey: queryKey,
55
+ refetchOnMount: false,
56
+ refetchOnWindowFocus: false,
57
+ refetchOnReconnect: false,
58
+ staleTime: 60_000,
59
+ queryFn: async ({ signal })=>{
60
+ const plugin = await getPlugin({
61
+ kind: SILENCES_QUERY_KEY,
62
+ name: silencesQueryKind
63
+ });
64
+ const data = await plugin.getSilencesData(definition.spec.plugin.spec, context, signal);
65
+ return data;
66
+ }
67
+ };
68
+ })
69
+ });
70
+ }
71
+ function getQueryOptions({ plugin, definition, context }) {
72
+ const { variableState } = context;
73
+ const dependencies = plugin?.dependsOn ? plugin.dependsOn(definition.spec.plugin.spec, context) : {};
74
+ const variableDependencies = dependencies?.variables;
75
+ const filteredVariabledState = (0, _utils.filterVariableStateMap)(variableState, variableDependencies);
76
+ const variablesValueKey = (0, _utils.getVariableValuesKey)(filteredVariabledState);
77
+ // Note: no absoluteTimeRange in query key since silences are current state
78
+ const queryKey = [
79
+ 'query',
80
+ SILENCES_QUERY_KEY,
81
+ definition,
82
+ variablesValueKey
83
+ ];
84
+ let waitToLoad = false;
85
+ if (variableDependencies) {
86
+ waitToLoad = variableDependencies.some((v)=>variableState[v]?.loading);
87
+ }
88
+ const queryEnabled = plugin !== undefined && !waitToLoad;
89
+ return {
90
+ queryKey,
91
+ queryEnabled
92
+ };
93
+ }
94
+ function useSilencesQueryContext() {
95
+ const variableState = (0, _variables.useAllVariableValues)();
96
+ const datasourceStore = (0, _datasources.useDatasourceStore)();
97
+ return {
98
+ variableState,
99
+ datasourceStore
100
+ };
101
+ }
@@ -123,7 +123,10 @@ function useTimeSeriesQueries(definitions, options, queryOptions) {
123
123
  staleTime: Infinity,
124
124
  queryKey: queryKey,
125
125
  queryFn: async ({ signal })=>{
126
- const plugin = await getPlugin(TIME_SERIES_QUERY_KEY, definition.spec.plugin.kind);
126
+ const plugin = await getPlugin({
127
+ kind: TIME_SERIES_QUERY_KEY,
128
+ name: definition.spec.plugin.kind
129
+ });
127
130
  const data = await plugin.getTimeSeriesData(definition.spec.plugin.spec, context, signal);
128
131
  return data;
129
132
  }
@@ -60,7 +60,10 @@ function useTraceQueries(definitions) {
60
60
  refetchOnReconnect: false,
61
61
  staleTime: Infinity,
62
62
  queryFn: async ({ signal })=>{
63
- const plugin = await getPlugin(TRACE_QUERY_KEY, traceQueryKind);
63
+ const plugin = await getPlugin({
64
+ kind: TRACE_QUERY_KEY,
65
+ name: traceQueryKind
66
+ });
64
67
  const data = await plugin.getTraceData(definition.spec.plugin.spec, context, signal);
65
68
  return data;
66
69
  }
@@ -21,6 +21,9 @@ function _export(target, all) {
21
21
  });
22
22
  }
23
23
  _export(exports, {
24
+ get MOCK_ALERTS_DATA () {
25
+ return MOCK_ALERTS_DATA;
26
+ },
24
27
  get MOCK_EMPTY_PLUGIN_MODULE () {
25
28
  return MOCK_EMPTY_PLUGIN_MODULE;
26
29
  },
@@ -45,6 +48,9 @@ _export(exports, {
45
48
  get MOCK_REMOTE_PLUGIN_MODULE () {
46
49
  return MOCK_REMOTE_PLUGIN_MODULE;
47
50
  },
51
+ get MOCK_SILENCES_DATA () {
52
+ return MOCK_SILENCES_DATA;
53
+ },
48
54
  get MOCK_TIME_SERIES_DATA () {
49
55
  return MOCK_TIME_SERIES_DATA;
50
56
  },
@@ -170,6 +176,51 @@ const MOCK_PROFILE_DATA = {
170
176
  name: 'cpu'
171
177
  }
172
178
  };
179
+ const MOCK_ALERTS_DATA = {
180
+ alerts: [
181
+ {
182
+ id: 'abc123',
183
+ name: 'HighErrorRate',
184
+ state: 'firing',
185
+ labels: {
186
+ alertname: 'HighErrorRate',
187
+ severity: 'critical',
188
+ service: 'backend'
189
+ },
190
+ annotations: {
191
+ summary: 'High error rate detected'
192
+ },
193
+ severity: 'critical',
194
+ startsAt: '2024-01-01T00:00:00Z',
195
+ endsAt: '2024-01-02T00:00:00Z',
196
+ updatedAt: '2024-01-01T12:00:00Z',
197
+ receivers: [
198
+ 'cluster-01'
199
+ ]
200
+ }
201
+ ]
202
+ };
203
+ const MOCK_SILENCES_DATA = {
204
+ silences: [
205
+ {
206
+ id: 'silence-1',
207
+ state: 'active',
208
+ matchers: [
209
+ {
210
+ name: 'alertname',
211
+ value: 'HighErrorRate',
212
+ isRegex: false,
213
+ isEqual: true
214
+ }
215
+ ],
216
+ startsAt: '2024-01-01T00:00:00Z',
217
+ endsAt: '2024-01-02T00:00:00Z',
218
+ createdBy: 'admin',
219
+ comment: 'Maintenance window',
220
+ updatedAt: '2024-01-01T00:00:00Z'
221
+ }
222
+ ]
223
+ };
173
224
  const MOCK_VALID_PLUGIN_METADATA = {
174
225
  kind: 'Panel',
175
226
  spec: {
@@ -14,18 +14,10 @@
14
14
  Object.defineProperty(exports, "__esModule", {
15
15
  value: true
16
16
  });
17
- function _export(target, all) {
18
- for(var name in all)Object.defineProperty(target, name, {
19
- enumerable: true,
20
- get: Object.getOwnPropertyDescriptor(all, name).get
21
- });
22
- }
23
- _export(exports, {
24
- get BertPanel1 () {
25
- return BertPanel1;
26
- },
27
- get BertPanel2 () {
28
- return BertPanel2;
17
+ Object.defineProperty(exports, "plugins", {
18
+ enumerable: true,
19
+ get: function() {
20
+ return plugins;
29
21
  }
30
22
  });
31
23
  const _jsxruntime = require("react/jsx-runtime");
@@ -48,6 +40,7 @@ function BertPanel1Editor({ value, onChange }) {
48
40
  ]
49
41
  });
50
42
  }
43
+ // Dummy plugins to test loading
51
44
  const BertPanel1 = {
52
45
  PanelComponent: ()=>null,
53
46
  panelOptionsEditorComponents: [
@@ -100,3 +93,7 @@ const BertPanel2 = {
100
93
  }),
101
94
  hideQueryEditor: true
102
95
  };
96
+ const plugins = {
97
+ 'Panel:BertPanel1::1.0.0': BertPanel1,
98
+ 'Panel:BertPanel2::1.0.0': BertPanel2
99
+ };
@@ -14,18 +14,10 @@
14
14
  Object.defineProperty(exports, "__esModule", {
15
15
  value: true
16
16
  });
17
- function _export(target, all) {
18
- for(var name in all)Object.defineProperty(target, name, {
19
- enumerable: true,
20
- get: Object.getOwnPropertyDescriptor(all, name).get
21
- });
22
- }
23
- _export(exports, {
24
- get ErnieVariable1 () {
25
- return ErnieVariable1;
26
- },
27
- get ErnieVariable2 () {
28
- return ErnieVariable2;
17
+ Object.defineProperty(exports, "plugins", {
18
+ enumerable: true,
19
+ get: function() {
20
+ return plugins;
29
21
  }
30
22
  });
31
23
  const _jsxruntime = require("react/jsx-runtime");
@@ -39,6 +31,7 @@ const data = [
39
31
  value: 'Snuffleupagus'
40
32
  }
41
33
  ];
34
+ // Dummy plugin to test loading
42
35
  const ErnieVariable1 = {
43
36
  getVariableOptions: async ()=>({
44
37
  data
@@ -93,3 +86,7 @@ const ErnieVariable2 = {
93
86
  variableOption2: ''
94
87
  })
95
88
  };
89
+ const plugins = {
90
+ 'Variable:ErnieVariable1::1.0.0': ErnieVariable1,
91
+ 'Variable:ErnieVariable2::1.0.0': ErnieVariable2
92
+ };
@@ -72,10 +72,10 @@ function _interop_require_wildcard(obj, nodeInterop) {
72
72
  const testPluginLoader = (0, _model.dynamicImportPluginLoader)([
73
73
  {
74
74
  resource: _pluginjson.default,
75
- importPlugin: ()=>Promise.resolve().then(()=>/*#__PURE__*/ _interop_require_wildcard(require("./bert")))
75
+ importPlugin: ()=>Promise.resolve().then(()=>/*#__PURE__*/ _interop_require_wildcard(require("./bert"))).then((m)=>m.plugins)
76
76
  },
77
77
  {
78
78
  resource: _pluginjson1.default,
79
- importPlugin: ()=>Promise.resolve().then(()=>/*#__PURE__*/ _interop_require_wildcard(require("./ernie")))
79
+ importPlugin: ()=>Promise.resolve().then(()=>/*#__PURE__*/ _interop_require_wildcard(require("./ernie"))).then((m)=>m.plugins)
80
80
  }
81
81
  ]);
@@ -22,7 +22,6 @@ Object.defineProperty(exports, "getTestContextWrapper", {
22
22
  });
23
23
  const _jsxruntime = require("react/jsx-runtime");
24
24
  const _reactquery = require("@tanstack/react-query");
25
- const _core = require("@perses-dev/core");
26
25
  const _components = require("../components");
27
26
  const _runtime = require("../runtime");
28
27
  const _testplugins = require("./test-plugins");
@@ -36,8 +35,9 @@ function getTestContextWrapper(contextOptions) {
36
35
  }
37
36
  }
38
37
  });
38
+ const DEFAULT_DASHBOARD_DURATION = '1h';
39
39
  const timeRange = {
40
- start: new Date(Date.now() - Number(_core.DEFAULT_DASHBOARD_DURATION)),
40
+ start: new Date(Date.now() - Number(DEFAULT_DASHBOARD_DURATION)),
41
41
  end: new Date()
42
42
  };
43
43
  return function Wrapper({ children }) {
@@ -28,12 +28,13 @@ _export(exports, {
28
28
  return mockPluginRegistry;
29
29
  }
30
30
  });
31
+ const _model = require("../model");
31
32
  function mockPluginRegistry(...mockPlugins) {
32
33
  const mockPluginResource = {
33
34
  kind: 'PluginModule',
34
35
  metadata: {
35
36
  name: 'Fake Plugin Module for Tests',
36
- version: '0'
37
+ version: '1.0.0'
37
38
  },
38
39
  spec: {
39
40
  // Add metadata for all mock plugins
@@ -51,7 +52,12 @@ function mockPluginRegistry(...mockPlugins) {
51
52
  const mockPluginModule = {};
52
53
  for (const mockPlugin of mockPlugins){
53
54
  // "Export" on the module under the same name as the kind the plugin handles
54
- mockPluginModule[mockPlugin.spec.name] = mockPlugin.plugin;
55
+ mockPluginModule[(0, _model.getPluginModuleCompoundKey)({
56
+ kind: mockPlugin.kind,
57
+ name: mockPlugin.spec.name,
58
+ registry: mockPluginResource.metadata.registry,
59
+ version: mockPluginResource.metadata.version
60
+ })] = mockPlugin.plugin;
55
61
  }
56
62
  const pluginLoader = {
57
63
  getInstalledPlugins () {
@@ -14,7 +14,6 @@
14
14
  Object.defineProperty(exports, "__esModule", {
15
15
  value: true
16
16
  });
17
- _export_star(require("./action"), exports);
18
17
  _export_star(require("./event"), exports);
19
18
  _export_star(require("./variables"), exports);
20
19
  _export_star(require("./csv-export"), exports);
@@ -1,5 +1,5 @@
1
- import { CalculationType } from '@perses-dev/core';
2
1
  import { ReactElement } from 'react';
2
+ import { CalculationType } from '../../model';
3
3
  export interface CalculationSelectorProps {
4
4
  value: CalculationType;
5
5
  onChange: (unit: CalculationType) => void;
@@ -1 +1 @@
1
- {"version":3,"file":"CalculationSelector.d.ts","sourceRoot":"","sources":["../../../src/components/CalculationSelector/CalculationSelector.tsx"],"names":[],"mappings":"AAcA,OAAO,EAA0C,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAC3F,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAUrC,MAAM,WAAW,wBAAwB;IACvC,KAAK,EAAE,eAAe,CAAC;IACvB,QAAQ,EAAE,CAAC,IAAI,EAAE,eAAe,KAAK,IAAI,CAAC;CAC3C;AAED,wBAAgB,mBAAmB,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,wBAAwB,GAAG,YAAY,CAuB/F"}
1
+ {"version":3,"file":"CalculationSelector.d.ts","sourceRoot":"","sources":["../../../src/components/CalculationSelector/CalculationSelector.tsx"],"names":[],"mappings":"AAcA,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AACrC,OAAO,EAA0C,eAAe,EAAE,MAAM,aAAa,CAAC;AAUtF,MAAM,WAAW,wBAAwB;IACvC,KAAK,EAAE,eAAe,CAAC;IACvB,QAAQ,EAAE,CAAC,IAAI,EAAE,eAAe,KAAK,IAAI,CAAC;CAC3C;AAED,wBAAgB,mBAAmB,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,wBAAwB,GAAG,YAAY,CAuB/F"}
@@ -1,3 +1,4 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
1
2
  // Copyright The Perses Authors
2
3
  // Licensed under the Apache License, Version 2.0 (the "License");
3
4
  // you may not use this file except in compliance with the License.
@@ -10,9 +11,8 @@
10
11
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
12
  // See the License for the specific language governing permissions and
12
13
  // limitations under the License.
13
- import { jsx as _jsx } from "react/jsx-runtime";
14
14
  import { OptionsEditorControl, SettingsAutocomplete } from '@perses-dev/components';
15
- import { CALCULATIONS_CONFIG } from '@perses-dev/core'; // TODO weird this is part of the model from the core package ...
15
+ import { CALCULATIONS_CONFIG } from '../../model'; // TODO weird this is part of the model from the core package ...
16
16
  const CALC_OPTIONS = Object.entries(CALCULATIONS_CONFIG).map(([id, config])=>{
17
17
  return {
18
18
  id: id,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/CalculationSelector/CalculationSelector.tsx"],"sourcesContent":["// Copyright 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 { OptionsEditorControl, SettingsAutocomplete } from '@perses-dev/components';\nimport { CALCULATIONS_CONFIG, CalculationConfig, CalculationType } from '@perses-dev/core'; // TODO weird this is part of the model from the core package ...\nimport { ReactElement } from 'react';\n\ntype AutocompleteCalculationOption = CalculationConfig & { id: CalculationType };\nconst CALC_OPTIONS: AutocompleteCalculationOption[] = Object.entries(CALCULATIONS_CONFIG).map(([id, config]) => {\n return {\n id: id as CalculationType,\n ...config,\n };\n});\n\nexport interface CalculationSelectorProps {\n value: CalculationType;\n onChange: (unit: CalculationType) => void;\n}\n\nexport function CalculationSelector({ value, onChange }: CalculationSelectorProps): ReactElement {\n const handleCalculationChange = (_: unknown, newValue: AutocompleteCalculationOption): void => {\n onChange(newValue.id);\n };\n\n const calcConfig = CALCULATIONS_CONFIG[value];\n\n return (\n <OptionsEditorControl\n label=\"Calculation\"\n control={\n <SettingsAutocomplete\n value={{\n ...calcConfig,\n id: value,\n }}\n options={CALC_OPTIONS}\n onChange={handleCalculationChange}\n disableClearable\n />\n }\n />\n );\n}\n"],"names":["OptionsEditorControl","SettingsAutocomplete","CALCULATIONS_CONFIG","CALC_OPTIONS","Object","entries","map","id","config","CalculationSelector","value","onChange","handleCalculationChange","_","newValue","calcConfig","label","control","options","disableClearable"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,SAASA,oBAAoB,EAAEC,oBAAoB,QAAQ,yBAAyB;AACpF,SAASC,mBAAmB,QAA4C,mBAAmB,CAAC,iEAAiE;AAI7J,MAAMC,eAAgDC,OAAOC,OAAO,CAACH,qBAAqBI,GAAG,CAAC,CAAC,CAACC,IAAIC,OAAO;IACzG,OAAO;QACLD,IAAIA;QACJ,GAAGC,MAAM;IACX;AACF;AAOA,OAAO,SAASC,oBAAoB,EAAEC,KAAK,EAAEC,QAAQ,EAA4B;IAC/E,MAAMC,0BAA0B,CAACC,GAAYC;QAC3CH,SAASG,SAASP,EAAE;IACtB;IAEA,MAAMQ,aAAab,mBAAmB,CAACQ,MAAM;IAE7C,qBACE,KAACV;QACCgB,OAAM;QACNC,uBACE,KAAChB;YACCS,OAAO;gBACL,GAAGK,UAAU;gBACbR,IAAIG;YACN;YACAQ,SAASf;YACTQ,UAAUC;YACVO,gBAAgB;;;AAK1B"}
1
+ {"version":3,"sources":["../../../src/components/CalculationSelector/CalculationSelector.tsx"],"sourcesContent":["// Copyright 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 { OptionsEditorControl, SettingsAutocomplete } from '@perses-dev/components';\nimport { ReactElement } from 'react';\nimport { CALCULATIONS_CONFIG, CalculationConfig, CalculationType } from '../../model'; // TODO weird this is part of the model from the core package ...\n\ntype AutocompleteCalculationOption = CalculationConfig & { id: CalculationType };\nconst CALC_OPTIONS: AutocompleteCalculationOption[] = Object.entries(CALCULATIONS_CONFIG).map(([id, config]) => {\n return {\n id: id as CalculationType,\n ...config,\n };\n});\n\nexport interface CalculationSelectorProps {\n value: CalculationType;\n onChange: (unit: CalculationType) => void;\n}\n\nexport function CalculationSelector({ value, onChange }: CalculationSelectorProps): ReactElement {\n const handleCalculationChange = (_: unknown, newValue: AutocompleteCalculationOption): void => {\n onChange(newValue.id);\n };\n\n const calcConfig = CALCULATIONS_CONFIG[value];\n\n return (\n <OptionsEditorControl\n label=\"Calculation\"\n control={\n <SettingsAutocomplete\n value={{\n ...calcConfig,\n id: value,\n }}\n options={CALC_OPTIONS}\n onChange={handleCalculationChange}\n disableClearable\n />\n }\n />\n );\n}\n"],"names":["OptionsEditorControl","SettingsAutocomplete","CALCULATIONS_CONFIG","CALC_OPTIONS","Object","entries","map","id","config","CalculationSelector","value","onChange","handleCalculationChange","_","newValue","calcConfig","label","control","options","disableClearable"],"mappings":";AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,oBAAoB,EAAEC,oBAAoB,QAAQ,yBAAyB;AAEpF,SAASC,mBAAmB,QAA4C,cAAc,CAAC,iEAAiE;AAGxJ,MAAMC,eAAgDC,OAAOC,OAAO,CAACH,qBAAqBI,GAAG,CAAC,CAAC,CAACC,IAAIC,OAAO;IACzG,OAAO;QACLD,IAAIA;QACJ,GAAGC,MAAM;IACX;AACF;AAOA,OAAO,SAASC,oBAAoB,EAAEC,KAAK,EAAEC,QAAQ,EAA4B;IAC/E,MAAMC,0BAA0B,CAACC,GAAYC;QAC3CH,SAASG,SAASP,EAAE;IACtB;IAEA,MAAMQ,aAAab,mBAAmB,CAACQ,MAAM;IAE7C,qBACE,KAACV;QACCgB,OAAM;QACNC,uBACE,KAAChB;YACCS,OAAO;gBACL,GAAGK,UAAU;gBACbR,IAAIG;YACN;YACAQ,SAASf;YACTQ,UAAUC;YACVO,gBAAgB;;;AAK1B"}
@@ -1,5 +1,6 @@
1
- import { Action, DatasourceDefinition } from '@perses-dev/core';
1
+ import { Action } from '@perses-dev/components';
2
2
  import { DispatchWithoutAction, ReactElement } from 'react';
3
+ import { DatasourceDefinition } from '@perses-dev/client';
3
4
  interface DatasourceEditorFormProps {
4
5
  initialDatasourceDefinition: DatasourceDefinition;
5
6
  action: Action;
@@ -1 +1 @@
1
- {"version":3,"file":"DatasourceEditorForm.d.ts","sourceRoot":"","sources":["../../../src/components/DatasourceEditorForm/DatasourceEditorForm.tsx"],"names":[],"mappings":"AAgBA,OAAO,EAAE,MAAM,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAChE,OAAO,EAAE,qBAAqB,EAAE,YAAY,EAAY,MAAM,OAAO,CAAC;AAMtE,UAAU,yBAAyB;IACjC,2BAA2B,EAAE,oBAAoB,CAAC;IAClD,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IAC1C,MAAM,EAAE,CAAC,GAAG,EAAE,oBAAoB,KAAK,IAAI,CAAC;IAC5C,OAAO,EAAE,qBAAqB,CAAC;IAC/B,QAAQ,CAAC,EAAE,qBAAqB,CAAC;CAClC;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,yBAAyB,GAAG,YAAY,CA8MnF"}
1
+ {"version":3,"file":"DatasourceEditorForm.d.ts","sourceRoot":"","sources":["../../../src/components/DatasourceEditorForm/DatasourceEditorForm.tsx"],"names":[],"mappings":"AAeA,OAAO,EAGL,MAAM,EAGP,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,qBAAqB,EAAE,YAAY,EAAY,MAAM,OAAO,CAAC;AAEtE,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAI1D,UAAU,yBAAyB;IACjC,2BAA2B,EAAE,oBAAoB,CAAC;IAClD,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IAC1C,MAAM,EAAE,CAAC,GAAG,EAAE,oBAAoB,KAAK,IAAI,CAAC;IAC5C,OAAO,EAAE,qBAAqB,CAAC;IAC/B,QAAQ,CAAC,EAAE,qBAAqB,CAAC;CAClC;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,yBAAyB,GAAG,YAAY,CA8MnF"}
@@ -1,3 +1,4 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
2
  // Copyright The Perses Authors
2
3
  // Licensed under the Apache License, Version 2.0 (the "License");
3
4
  // you may not use this file except in compliance with the License.
@@ -10,14 +11,12 @@
10
11
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
12
  // See the License for the specific language governing permissions and
12
13
  // limitations under the License.
13
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
14
14
  import { zodResolver } from '@hookform/resolvers/zod';
15
15
  import { Box, Divider, FormControlLabel, Grid, Stack, Switch, TextField, Typography } from '@mui/material';
16
- import { DiscardChangesConfirmationDialog, FormActions } from '@perses-dev/components';
16
+ import { DiscardChangesConfirmationDialog, FormActions, getSubmitText, getTitleAction } from '@perses-dev/components';
17
17
  import { useState } from 'react';
18
18
  import { Controller, FormProvider, useForm } from 'react-hook-form';
19
19
  import { useValidationSchemas } from '../../context';
20
- import { getSubmitText, getTitleAction } from '../../utils';
21
20
  import { PluginEditor } from '../PluginEditor';
22
21
  export function DatasourceEditorForm(props) {
23
22
  const { initialDatasourceDefinition, action, isDraft, isReadonly, onActionChange, onSave, onClose, onDelete } = props;