@perses-dev/plugin-system 0.54.0-beta.1 → 0.54.0-beta.10
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.
- package/dist/cjs/components/Annotations/AnnotationEditorForm/AnnotationEditorForm.js +283 -0
- package/dist/cjs/components/Annotations/AnnotationEditorForm/AnnotationPreview.js +197 -0
- package/dist/cjs/components/Annotations/AnnotationEditorForm/index.js +30 -0
- package/dist/cjs/components/Annotations/constants.js +23 -0
- package/dist/cjs/components/Annotations/index.js +31 -0
- package/dist/cjs/components/MultiQueryEditor/QueryEditorContainer.js +97 -12
- package/dist/cjs/components/MultiQueryEditor/index.js +1 -0
- package/dist/cjs/components/MultiQueryEditor/utils.js +36 -0
- package/dist/cjs/components/PanelSpecEditor/PanelSpecEditor.js +3 -6
- package/dist/cjs/components/PluginRegistry/PluginRegistry.js +11 -15
- package/dist/cjs/components/PluginRegistry/getPluginSearchHelper.js +92 -0
- package/dist/cjs/components/PluginRegistry/plugin-indexes.js +16 -13
- package/dist/cjs/components/Variables/variable-model.js +115 -29
- package/dist/cjs/components/index.js +1 -0
- package/dist/cjs/context/ValidationProvider.js +10 -4
- package/dist/cjs/model/alerts-queries.js +16 -0
- package/dist/cjs/model/annotations.js +16 -0
- package/dist/cjs/model/index.js +3 -0
- package/dist/cjs/model/log-volume-utils.js +10 -10
- package/dist/cjs/model/plugin-loading.js +24 -8
- package/dist/cjs/model/plugins.js +10 -0
- package/dist/cjs/model/silences-queries.js +16 -0
- package/dist/cjs/remote/PluginRuntime.js +46 -10
- package/dist/cjs/remote/remotePluginLoader.js +28 -5
- package/dist/cjs/runtime/DataQueriesProvider/DataQueriesProvider.js +33 -24
- package/dist/cjs/runtime/DataQueriesProvider/model.js +3 -93
- package/dist/cjs/runtime/UsageMetricsProvider.js +2 -2
- package/dist/cjs/runtime/alerts-queries.js +101 -0
- package/dist/cjs/runtime/annotations.js +148 -0
- package/dist/cjs/runtime/index.js +3 -1
- package/dist/cjs/runtime/item-actions.js +3 -3
- package/dist/cjs/runtime/log-queries.js +4 -1
- package/dist/cjs/runtime/plugin-registry.js +12 -3
- package/dist/cjs/runtime/profile-queries.js +4 -1
- package/dist/cjs/runtime/silences-queries.js +101 -0
- package/dist/cjs/runtime/time-series-queries.js +4 -1
- package/dist/cjs/runtime/trace-queries.js +4 -1
- package/dist/cjs/test/mock-data.js +51 -0
- package/dist/cjs/test/test-plugins/bert/index.js +9 -12
- package/dist/cjs/test/test-plugins/ernie/index.js +9 -12
- package/dist/cjs/test/test-plugins/index.js +2 -2
- package/dist/cjs/test-utils/mock-plugin-registry.js +8 -2
- package/dist/components/Annotations/AnnotationEditorForm/AnnotationEditorForm.d.ts +16 -0
- package/dist/components/Annotations/AnnotationEditorForm/AnnotationEditorForm.d.ts.map +1 -0
- package/dist/components/Annotations/AnnotationEditorForm/AnnotationEditorForm.js +270 -0
- package/dist/components/Annotations/AnnotationEditorForm/AnnotationEditorForm.js.map +1 -0
- package/dist/components/Annotations/AnnotationEditorForm/AnnotationPreview.d.ts +8 -0
- package/dist/components/Annotations/AnnotationEditorForm/AnnotationPreview.d.ts.map +1 -0
- package/dist/components/Annotations/AnnotationEditorForm/AnnotationPreview.js +184 -0
- package/dist/components/Annotations/AnnotationEditorForm/AnnotationPreview.js.map +1 -0
- package/dist/components/Annotations/AnnotationEditorForm/index.d.ts +2 -0
- package/dist/components/Annotations/AnnotationEditorForm/index.d.ts.map +1 -0
- package/dist/{runtime/QueryCountProvider.js → components/Annotations/AnnotationEditorForm/index.js} +2 -13
- package/dist/components/Annotations/AnnotationEditorForm/index.js.map +1 -0
- package/dist/components/Annotations/constants.d.ts +2 -0
- package/dist/components/Annotations/constants.d.ts.map +1 -0
- package/dist/components/Annotations/constants.js +15 -0
- package/dist/components/Annotations/constants.js.map +1 -0
- package/dist/components/Annotations/index.d.ts +3 -0
- package/dist/components/Annotations/index.d.ts.map +1 -0
- package/dist/components/Annotations/index.js +16 -0
- package/dist/components/Annotations/index.js.map +1 -0
- package/dist/components/CalculationSelector/CalculationSelector.js +1 -1
- package/dist/components/CalculationSelector/CalculationSelector.js.map +1 -1
- package/dist/components/DatasourceEditorForm/DatasourceEditorForm.d.ts +1 -2
- package/dist/components/DatasourceEditorForm/DatasourceEditorForm.d.ts.map +1 -1
- package/dist/components/DatasourceEditorForm/DatasourceEditorForm.js +1 -1
- package/dist/components/DatasourceEditorForm/DatasourceEditorForm.js.map +1 -1
- package/dist/components/DatasourceSelect/DatasourceSelect.js +2 -2
- package/dist/components/DatasourceSelect/DatasourceSelect.js.map +1 -1
- package/dist/components/HTTPSettingsEditor/HTTPSettingsEditor.d.ts +1 -1
- package/dist/components/HTTPSettingsEditor/HTTPSettingsEditor.d.ts.map +1 -1
- package/dist/components/HTTPSettingsEditor/HTTPSettingsEditor.js +2 -2
- package/dist/components/HTTPSettingsEditor/HTTPSettingsEditor.js.map +1 -1
- package/dist/components/ItemSelectionActionsOptionsEditor/ItemSelectionActionsOptionsEditor.js +1 -1
- package/dist/components/ItemSelectionActionsOptionsEditor/ItemSelectionActionsOptionsEditor.js.map +1 -1
- package/dist/components/LegendOptionsEditor/LegendOptionsEditor.js +1 -1
- package/dist/components/LegendOptionsEditor/LegendOptionsEditor.js.map +1 -1
- package/dist/components/MetricLabelInput/MetricLabelInput.js +1 -1
- package/dist/components/MetricLabelInput/MetricLabelInput.js.map +1 -1
- package/dist/components/MultiQueryEditor/MultiQueryEditor.js +1 -1
- package/dist/components/MultiQueryEditor/MultiQueryEditor.js.map +1 -1
- package/dist/components/MultiQueryEditor/QueryEditorContainer.d.ts.map +1 -1
- package/dist/components/MultiQueryEditor/QueryEditorContainer.js +100 -15
- package/dist/components/MultiQueryEditor/QueryEditorContainer.js.map +1 -1
- package/dist/components/MultiQueryEditor/index.d.ts +1 -0
- package/dist/components/MultiQueryEditor/index.d.ts.map +1 -1
- package/dist/components/MultiQueryEditor/index.js +1 -0
- package/dist/components/MultiQueryEditor/index.js.map +1 -1
- package/dist/components/MultiQueryEditor/utils.d.ts +8 -0
- package/dist/components/MultiQueryEditor/utils.d.ts.map +1 -0
- package/dist/components/MultiQueryEditor/utils.js +23 -0
- package/dist/components/MultiQueryEditor/utils.js.map +1 -0
- package/dist/components/OptionsEditorRadios/OptionsEditorRadios.js +1 -1
- package/dist/components/OptionsEditorRadios/OptionsEditorRadios.js.map +1 -1
- package/dist/components/OptionsEditorTabPanel/OptionsEditorTabPanel.js +1 -1
- package/dist/components/OptionsEditorTabPanel/OptionsEditorTabPanel.js.map +1 -1
- package/dist/components/OptionsEditorTabs/OptionsEditorTabs.js +1 -1
- package/dist/components/OptionsEditorTabs/OptionsEditorTabs.js.map +1 -1
- package/dist/components/PanelSpecEditor/PanelSpecEditor.d.ts.map +1 -1
- package/dist/components/PanelSpecEditor/PanelSpecEditor.js +5 -8
- package/dist/components/PanelSpecEditor/PanelSpecEditor.js.map +1 -1
- package/dist/components/PluginEditor/PluginEditor.js +1 -1
- package/dist/components/PluginEditor/PluginEditor.js.map +1 -1
- package/dist/components/PluginKindSelect/PluginKindSelect.js +1 -1
- package/dist/components/PluginKindSelect/PluginKindSelect.js.map +1 -1
- package/dist/components/PluginRegistry/PluginRegistry.d.ts.map +1 -1
- package/dist/components/PluginRegistry/PluginRegistry.js +12 -16
- package/dist/components/PluginRegistry/PluginRegistry.js.map +1 -1
- package/dist/components/PluginRegistry/getPluginSearchHelper.d.ts +12 -0
- package/dist/components/PluginRegistry/getPluginSearchHelper.d.ts.map +1 -0
- package/dist/components/PluginRegistry/getPluginSearchHelper.js +88 -0
- package/dist/components/PluginRegistry/getPluginSearchHelper.js.map +1 -0
- package/dist/components/PluginRegistry/plugin-indexes.d.ts +4 -6
- package/dist/components/PluginRegistry/plugin-indexes.d.ts.map +1 -1
- package/dist/components/PluginRegistry/plugin-indexes.js +15 -13
- package/dist/components/PluginRegistry/plugin-indexes.js.map +1 -1
- package/dist/components/PluginSpecEditor/PluginSpecEditor.d.ts.map +1 -1
- package/dist/components/PluginSpecEditor/PluginSpecEditor.js +1 -1
- package/dist/components/PluginSpecEditor/PluginSpecEditor.js.map +1 -1
- package/dist/components/SelectionOptionsEditor/SelectionOptionsEditor.js +1 -1
- package/dist/components/SelectionOptionsEditor/SelectionOptionsEditor.js.map +1 -1
- package/dist/components/TimeRangeControls/TimeRangeControls.js +1 -1
- package/dist/components/TimeRangeControls/TimeRangeControls.js.map +1 -1
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts +1 -1
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts.map +1 -1
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js +1 -1
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js.map +1 -1
- package/dist/components/Variables/VariableEditorForm/VariablePreview.js +1 -1
- package/dist/components/Variables/VariableEditorForm/VariablePreview.js.map +1 -1
- package/dist/components/Variables/variable-model.d.ts +9 -1
- package/dist/components/Variables/variable-model.d.ts.map +1 -1
- package/dist/components/Variables/variable-model.js +117 -31
- package/dist/components/Variables/variable-model.js.map +1 -1
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +1 -0
- package/dist/components/index.js.map +1 -1
- package/dist/context/ValidationProvider.d.ts +4 -2
- package/dist/context/ValidationProvider.d.ts.map +1 -1
- package/dist/context/ValidationProvider.js +10 -4
- package/dist/context/ValidationProvider.js.map +1 -1
- package/dist/model/alerts-queries.d.ts +33 -0
- package/dist/model/alerts-queries.d.ts.map +1 -0
- package/dist/model/alerts-queries.js +15 -0
- package/dist/model/alerts-queries.js.map +1 -0
- package/dist/model/annotations.d.ts +28 -0
- package/dist/model/annotations.d.ts.map +1 -0
- package/dist/model/annotations.js +17 -0
- package/dist/model/annotations.js.map +1 -0
- package/dist/model/datasource.d.ts +1 -8
- package/dist/model/datasource.d.ts.map +1 -1
- package/dist/model/datasource.js +1 -1
- package/dist/model/datasource.js.map +1 -1
- package/dist/model/index.d.ts +3 -0
- package/dist/model/index.d.ts.map +1 -1
- package/dist/model/index.js +3 -0
- package/dist/model/index.js.map +1 -1
- package/dist/model/log-queries.d.ts +2 -1
- package/dist/model/log-queries.d.ts.map +1 -1
- package/dist/model/log-queries.js.map +1 -1
- package/dist/model/plugin-loading.d.ts.map +1 -1
- package/dist/model/plugin-loading.js +24 -8
- package/dist/model/plugin-loading.js.map +1 -1
- package/dist/model/plugins.d.ts +23 -0
- package/dist/model/plugins.d.ts.map +1 -1
- package/dist/model/plugins.js +4 -1
- package/dist/model/plugins.js.map +1 -1
- package/dist/model/silences-queries.d.ts +33 -0
- package/dist/model/silences-queries.d.ts.map +1 -0
- package/dist/model/silences-queries.js +15 -0
- package/dist/model/silences-queries.js.map +1 -0
- package/dist/model/trace-queries.d.ts +2 -3
- package/dist/model/trace-queries.d.ts.map +1 -1
- package/dist/model/trace-queries.js.map +1 -1
- package/dist/remote/PersesPlugin.types.d.ts +2 -0
- package/dist/remote/PersesPlugin.types.d.ts.map +1 -1
- package/dist/remote/PersesPlugin.types.js.map +1 -1
- package/dist/remote/PluginLoaderComponent.js +1 -1
- package/dist/remote/PluginLoaderComponent.js.map +1 -1
- package/dist/remote/PluginRuntime.d.ts +7 -1
- package/dist/remote/PluginRuntime.d.ts.map +1 -1
- package/dist/remote/PluginRuntime.js +46 -10
- package/dist/remote/PluginRuntime.js.map +1 -1
- package/dist/remote/remotePluginLoader.d.ts.map +1 -1
- package/dist/remote/remotePluginLoader.js +28 -5
- package/dist/remote/remotePluginLoader.js.map +1 -1
- package/dist/runtime/DataQueriesProvider/DataQueriesProvider.d.ts.map +1 -1
- package/dist/runtime/DataQueriesProvider/DataQueriesProvider.js +35 -26
- package/dist/runtime/DataQueriesProvider/DataQueriesProvider.js.map +1 -1
- package/dist/runtime/DataQueriesProvider/model.d.ts +4 -4
- package/dist/runtime/DataQueriesProvider/model.d.ts.map +1 -1
- package/dist/runtime/DataQueriesProvider/model.js +0 -82
- package/dist/runtime/DataQueriesProvider/model.js.map +1 -1
- package/dist/runtime/RouterProvider.js +1 -1
- package/dist/runtime/RouterProvider.js.map +1 -1
- package/dist/runtime/TimeRangeProvider/TimeRangeProvider.js +1 -1
- package/dist/runtime/TimeRangeProvider/TimeRangeProvider.js.map +1 -1
- package/dist/runtime/TimeRangeProvider/TimeRangeSettingsProvider.js +1 -1
- package/dist/runtime/TimeRangeProvider/TimeRangeSettingsProvider.js.map +1 -1
- package/dist/runtime/UsageMetricsProvider.js +2 -2
- package/dist/runtime/UsageMetricsProvider.js.map +1 -1
- package/dist/runtime/alerts-queries.d.ts +11 -0
- package/dist/runtime/alerts-queries.d.ts.map +1 -0
- package/dist/runtime/alerts-queries.js +89 -0
- package/dist/runtime/alerts-queries.js.map +1 -0
- package/dist/runtime/annotations.d.ts +6 -0
- package/dist/runtime/annotations.d.ts.map +1 -0
- package/dist/runtime/annotations.js +129 -0
- package/dist/runtime/annotations.js.map +1 -0
- package/dist/runtime/datasources.d.ts +6 -0
- package/dist/runtime/datasources.d.ts.map +1 -1
- package/dist/runtime/datasources.js.map +1 -1
- package/dist/runtime/index.d.ts +3 -1
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/runtime/index.js +3 -1
- package/dist/runtime/index.js.map +1 -1
- package/dist/runtime/item-actions.js +1 -1
- package/dist/runtime/item-actions.js.map +1 -1
- package/dist/runtime/log-queries.js +4 -1
- package/dist/runtime/log-queries.js.map +1 -1
- package/dist/runtime/plugin-registry.d.ts +2 -2
- package/dist/runtime/plugin-registry.d.ts.map +1 -1
- package/dist/runtime/plugin-registry.js +12 -3
- package/dist/runtime/plugin-registry.js.map +1 -1
- package/dist/runtime/profile-queries.js +4 -1
- package/dist/runtime/profile-queries.js.map +1 -1
- package/dist/runtime/silences-queries.d.ts +11 -0
- package/dist/runtime/silences-queries.d.ts.map +1 -0
- package/dist/runtime/silences-queries.js +89 -0
- package/dist/runtime/silences-queries.js.map +1 -0
- package/dist/runtime/time-series-queries.js +4 -1
- package/dist/runtime/time-series-queries.js.map +1 -1
- package/dist/runtime/trace-queries.js +4 -1
- package/dist/runtime/trace-queries.js.map +1 -1
- package/dist/test/mock-data.d.ts +3 -1
- package/dist/test/mock-data.d.ts.map +1 -1
- package/dist/test/mock-data.js +45 -0
- package/dist/test/mock-data.js.map +1 -1
- package/dist/test/render.js +1 -1
- package/dist/test/render.js.map +1 -1
- package/dist/test/test-plugins/bert/index.d.ts +12 -6
- package/dist/test/test-plugins/bert/index.d.ts.map +1 -1
- package/dist/test/test-plugins/bert/index.js +6 -2
- package/dist/test/test-plugins/bert/index.js.map +1 -1
- package/dist/test/test-plugins/ernie/index.d.ts +8 -6
- package/dist/test/test-plugins/ernie/index.d.ts.map +1 -1
- package/dist/test/test-plugins/ernie/index.js +6 -2
- package/dist/test/test-plugins/ernie/index.js.map +1 -1
- package/dist/test/test-plugins/index.js +2 -2
- package/dist/test/test-plugins/index.js.map +1 -1
- package/dist/test/utils.js +1 -1
- package/dist/test/utils.js.map +1 -1
- package/dist/test-utils/mock-plugin-registry.d.ts.map +1 -1
- package/dist/test-utils/mock-plugin-registry.js +8 -2
- package/dist/test-utils/mock-plugin-registry.js.map +1 -1
- package/package.json +7 -6
- package/dist/cjs/runtime/QueryCountProvider.js +0 -83
- package/dist/runtime/QueryCountProvider.d.ts +0 -9
- package/dist/runtime/QueryCountProvider.d.ts.map +0 -1
- package/dist/runtime/QueryCountProvider.js.map +0 -1
|
@@ -0,0 +1,16 @@
|
|
|
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
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
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
|
+
});
|
package/dist/cjs/model/index.js
CHANGED
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", {
|
|
15
15
|
value: true
|
|
16
16
|
});
|
|
17
|
+
_export_star(require("./annotations"), exports);
|
|
17
18
|
_export_star(require("./datasource"), exports);
|
|
18
19
|
_export_star(require("./legend"), exports);
|
|
19
20
|
_export_star(require("./log-queries"), exports);
|
|
@@ -27,6 +28,8 @@ _export_star(require("./trace-queries"), exports);
|
|
|
27
28
|
_export_star(require("./profile-queries"), exports);
|
|
28
29
|
_export_star(require("./variables"), exports);
|
|
29
30
|
_export_star(require("./calculations"), exports);
|
|
31
|
+
_export_star(require("./alerts-queries"), exports);
|
|
32
|
+
_export_star(require("./silences-queries"), exports);
|
|
30
33
|
function _export_star(from, to) {
|
|
31
34
|
Object.keys(from).forEach(function(k) {
|
|
32
35
|
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "calculateVolumeInterval", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return calculateVolumeInterval;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
1
11
|
// Copyright The Perses Authors
|
|
2
12
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
13
|
// you may not use this file except in compliance with the License.
|
|
@@ -11,16 +21,6 @@
|
|
|
11
21
|
// See the License for the specific language governing permissions and
|
|
12
22
|
// limitations under the License.
|
|
13
23
|
// Target number of bars for log volume histogram
|
|
14
|
-
"use strict";
|
|
15
|
-
Object.defineProperty(exports, "__esModule", {
|
|
16
|
-
value: true
|
|
17
|
-
});
|
|
18
|
-
Object.defineProperty(exports, "calculateVolumeInterval", {
|
|
19
|
-
enumerable: true,
|
|
20
|
-
get: function() {
|
|
21
|
-
return calculateVolumeInterval;
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
24
|
const TARGET_HISTOGRAM_BARS = 40;
|
|
25
25
|
// Standard intervals for histogram calculations (in milliseconds)
|
|
26
26
|
const STANDARD_INTERVALS = [
|
|
@@ -20,21 +20,37 @@ Object.defineProperty(exports, "dynamicImportPluginLoader", {
|
|
|
20
20
|
return dynamicImportPluginLoader;
|
|
21
21
|
}
|
|
22
22
|
});
|
|
23
|
+
const _plugins = require("./plugins");
|
|
23
24
|
function dynamicImportPluginLoader(plugins) {
|
|
24
|
-
const importMap = new Map(
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
const importMap = new Map();
|
|
26
|
+
for (const p of plugins){
|
|
27
|
+
const { resource, resource: { kind, metadata: { name, registry, version } }, importPlugin } = p;
|
|
28
|
+
importMap.set((0, _plugins.getPluginModuleCompoundKey)({
|
|
29
|
+
kind,
|
|
30
|
+
name,
|
|
31
|
+
registry,
|
|
32
|
+
version
|
|
33
|
+
}), {
|
|
34
|
+
resource,
|
|
35
|
+
importPlugin
|
|
36
|
+
});
|
|
37
|
+
}
|
|
28
38
|
return {
|
|
29
39
|
async getInstalledPlugins () {
|
|
30
|
-
return Promise.resolve(Array.from(importMap.
|
|
40
|
+
return Promise.resolve(Array.from(importMap.values()).map((v)=>v.resource));
|
|
31
41
|
},
|
|
32
42
|
importPluginModule (resource) {
|
|
33
|
-
const
|
|
34
|
-
|
|
43
|
+
const { kind, metadata: { name, version, registry } } = resource;
|
|
44
|
+
const { importPlugin } = importMap.get((0, _plugins.getPluginModuleCompoundKey)({
|
|
45
|
+
kind,
|
|
46
|
+
name,
|
|
47
|
+
registry,
|
|
48
|
+
version
|
|
49
|
+
})) || {};
|
|
50
|
+
if (importPlugin === undefined) {
|
|
35
51
|
throw new Error('Plugin not found');
|
|
36
52
|
}
|
|
37
|
-
return
|
|
53
|
+
return importPlugin();
|
|
38
54
|
}
|
|
39
55
|
};
|
|
40
56
|
}
|
|
@@ -14,3 +14,13 @@
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", {
|
|
15
15
|
value: true
|
|
16
16
|
});
|
|
17
|
+
Object.defineProperty(exports, "getPluginModuleCompoundKey", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: function() {
|
|
20
|
+
return getPluginModuleCompoundKey;
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
function getPluginModuleCompoundKey(compoundKey) {
|
|
24
|
+
const { kind, name, registry, version } = compoundKey;
|
|
25
|
+
return `${kind}:${name}:${registry ?? ''}:${version ?? ''}`;
|
|
26
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
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
|
+
});
|
|
@@ -147,7 +147,14 @@ const getPluginRuntime = ()=>{
|
|
|
147
147
|
requiredVersion: '^5.5.0'
|
|
148
148
|
}
|
|
149
149
|
},
|
|
150
|
-
|
|
150
|
+
'@perses-dev/spec': {
|
|
151
|
+
version: '0.2.0-beta.2',
|
|
152
|
+
lib: ()=>require('@perses-dev/spec'),
|
|
153
|
+
shareConfig: {
|
|
154
|
+
singleton: true,
|
|
155
|
+
requiredVersion: '^0.2.0-beta.2'
|
|
156
|
+
}
|
|
157
|
+
},
|
|
151
158
|
'@perses-dev/core': {
|
|
152
159
|
version: '0.53.1',
|
|
153
160
|
lib: ()=>require('@perses-dev/core'),
|
|
@@ -156,6 +163,14 @@ const getPluginRuntime = ()=>{
|
|
|
156
163
|
requiredVersion: '^0.53.1'
|
|
157
164
|
}
|
|
158
165
|
},
|
|
166
|
+
'@perses-dev/client': {
|
|
167
|
+
version: '0.54.0-beta.1',
|
|
168
|
+
lib: ()=>require('@perses-dev/client'),
|
|
169
|
+
shareConfig: {
|
|
170
|
+
singleton: true,
|
|
171
|
+
requiredVersion: '^0.54.0-beta.1'
|
|
172
|
+
}
|
|
173
|
+
},
|
|
159
174
|
'@perses-dev/components': {
|
|
160
175
|
version: '0.53.1',
|
|
161
176
|
lib: ()=>require('@perses-dev/components'),
|
|
@@ -268,28 +283,49 @@ const getPluginRuntime = ()=>{
|
|
|
268
283
|
}
|
|
269
284
|
return instance;
|
|
270
285
|
};
|
|
271
|
-
|
|
286
|
+
function getModuleFederationRemoteName(name, registry, version) {
|
|
287
|
+
return `${name}:${registry ?? ''}:${version ?? ''}`;
|
|
288
|
+
}
|
|
289
|
+
const registerRemote = (name, registry, version, baseURL)=>{
|
|
272
290
|
const pluginRuntime = getPluginRuntime();
|
|
273
|
-
const
|
|
291
|
+
const registryName = getModuleFederationRemoteName(name, registry, version);
|
|
292
|
+
const existingRemote = pluginRuntime.options.remotes.find((remote)=>remote.name === registryName);
|
|
274
293
|
if (!existingRemote) {
|
|
275
|
-
const
|
|
294
|
+
const nameVersionRegistry = [
|
|
295
|
+
name,
|
|
296
|
+
version,
|
|
297
|
+
registry
|
|
298
|
+
].filter(Boolean).join('~');
|
|
299
|
+
const prefix = baseURL || '/plugins';
|
|
300
|
+
const remoteEntryURL = `${prefix}/${nameVersionRegistry}/mf-manifest.json`;
|
|
276
301
|
pluginRuntime.registerRemotes([
|
|
277
302
|
{
|
|
278
|
-
name,
|
|
303
|
+
name: registryName,
|
|
279
304
|
entry: remoteEntryURL,
|
|
280
|
-
alias:
|
|
305
|
+
alias: registryName
|
|
281
306
|
}
|
|
282
307
|
]);
|
|
283
308
|
}
|
|
284
309
|
};
|
|
285
|
-
const loadPlugin = async (
|
|
286
|
-
|
|
310
|
+
const loadPlugin = async (target)=>{
|
|
311
|
+
const { moduleName, pluginName, registry, version, baseURL } = target;
|
|
312
|
+
registerRemote(moduleName, registry, version, baseURL);
|
|
287
313
|
const pluginRuntime = getPluginRuntime();
|
|
288
|
-
|
|
314
|
+
const registryName = getModuleFederationRemoteName(moduleName, registry, version);
|
|
315
|
+
return pluginRuntime.loadRemote(`${registryName}/${pluginName}`);
|
|
289
316
|
};
|
|
290
317
|
function usePluginRuntime({ plugin }) {
|
|
291
318
|
return {
|
|
292
319
|
pluginRuntime: getPluginRuntime(),
|
|
293
|
-
loadPlugin: ()=>
|
|
320
|
+
loadPlugin: ()=>{
|
|
321
|
+
const { moduleName, name: pluginName, registry, version, baseURL } = plugin;
|
|
322
|
+
return loadPlugin({
|
|
323
|
+
moduleName,
|
|
324
|
+
pluginName,
|
|
325
|
+
registry,
|
|
326
|
+
version,
|
|
327
|
+
baseURL
|
|
328
|
+
});
|
|
329
|
+
}
|
|
294
330
|
};
|
|
295
331
|
}
|
|
@@ -20,6 +20,7 @@ Object.defineProperty(exports, "remotePluginLoader", {
|
|
|
20
20
|
return remotePluginLoader;
|
|
21
21
|
}
|
|
22
22
|
});
|
|
23
|
+
const _pluginsystem = require("@perses-dev/plugin-system");
|
|
23
24
|
const _PluginRuntime = require("./PluginRuntime");
|
|
24
25
|
const isPluginMetadata = (plugin)=>{
|
|
25
26
|
return typeof plugin === 'object' && plugin !== null && 'kind' in plugin && 'spec' in plugin && typeof plugin.spec === 'object' && plugin.spec !== null && 'name' in plugin.spec;
|
|
@@ -59,17 +60,39 @@ function remotePluginLoader(options) {
|
|
|
59
60
|
return pluginModules;
|
|
60
61
|
},
|
|
61
62
|
importPluginModule: async (resource)=>{
|
|
62
|
-
const pluginModuleName = resource.metadata
|
|
63
|
+
const { name: pluginModuleName, version, registry } = resource.metadata;
|
|
63
64
|
const pluginModule = {};
|
|
64
|
-
|
|
65
|
-
const remotePluginModule = await (0, _PluginRuntime.loadPlugin)(
|
|
65
|
+
const loadPromises = resource.spec.plugins.map(async (plugin)=>{
|
|
66
|
+
const remotePluginModule = await (0, _PluginRuntime.loadPlugin)({
|
|
67
|
+
moduleName: pluginModuleName,
|
|
68
|
+
pluginName: plugin.spec.name,
|
|
69
|
+
registry,
|
|
70
|
+
version,
|
|
71
|
+
baseURL: pluginsAssetsPath
|
|
72
|
+
});
|
|
66
73
|
const remotePlugin = remotePluginModule?.[plugin.spec.name];
|
|
67
74
|
if (remotePlugin) {
|
|
68
|
-
|
|
75
|
+
return {
|
|
76
|
+
kind: plugin.kind,
|
|
77
|
+
name: plugin.spec.name,
|
|
78
|
+
remotePlugin
|
|
79
|
+
};
|
|
69
80
|
} else {
|
|
70
81
|
console.error(`RemotePluginLoader: Error loading plugin ${plugin.spec.name}`);
|
|
82
|
+
return null;
|
|
71
83
|
}
|
|
72
|
-
}
|
|
84
|
+
});
|
|
85
|
+
const loadedPlugins = await Promise.all(loadPromises);
|
|
86
|
+
loadedPlugins.forEach((item)=>{
|
|
87
|
+
if (item?.remotePlugin) {
|
|
88
|
+
pluginModule[(0, _pluginsystem.getPluginModuleCompoundKey)({
|
|
89
|
+
kind: item.kind,
|
|
90
|
+
name: item.name,
|
|
91
|
+
registry,
|
|
92
|
+
version
|
|
93
|
+
})] = item.remotePlugin;
|
|
94
|
+
}
|
|
95
|
+
});
|
|
73
96
|
return pluginModule;
|
|
74
97
|
}
|
|
75
98
|
};
|
|
@@ -39,6 +39,8 @@ const _react = require("react");
|
|
|
39
39
|
const _timeseriesqueries = require("../time-series-queries");
|
|
40
40
|
const _tracequeries = require("../trace-queries");
|
|
41
41
|
const _profilequeries = require("../profile-queries");
|
|
42
|
+
const _alertsqueries = require("../alerts-queries");
|
|
43
|
+
const _silencesqueries = require("../silences-queries");
|
|
42
44
|
const _UsageMetricsProvider = require("../UsageMetricsProvider");
|
|
43
45
|
const _logqueries = require("../log-queries");
|
|
44
46
|
const _model = require("./model");
|
|
@@ -52,60 +54,61 @@ function useDataQueriesContext() {
|
|
|
52
54
|
}
|
|
53
55
|
function useDataQueries(queryType) {
|
|
54
56
|
const ctx = useDataQueriesContext();
|
|
57
|
+
// Filter query definitions based on the specified query type
|
|
58
|
+
const filteredQueryDefinitions = ctx.queryDefinitions.filter((definition)=>definition.kind === queryType);
|
|
55
59
|
// Filter the query results based on the specified query type
|
|
56
60
|
const filteredQueryResults = ctx.queryResults.filter((queryResult)=>queryResult?.definition?.kind === queryType);
|
|
57
61
|
// Filter the errors based on the specified query type
|
|
58
62
|
const filteredErrors = ctx.errors.filter((errors, index)=>ctx.queryResults[index]?.definition?.kind === queryType);
|
|
59
63
|
// Create a new context object with the filtered results and errors
|
|
60
|
-
|
|
64
|
+
return {
|
|
65
|
+
queryDefinitions: filteredQueryDefinitions,
|
|
61
66
|
queryResults: filteredQueryResults,
|
|
62
67
|
isFetching: filteredQueryResults.some((result)=>result.isFetching),
|
|
63
68
|
isLoading: filteredQueryResults.some((result)=>result.isLoading),
|
|
64
69
|
refetchAll: ctx.refetchAll,
|
|
65
70
|
errors: filteredErrors
|
|
66
71
|
};
|
|
67
|
-
return filteredCtx;
|
|
68
72
|
}
|
|
69
73
|
function DataQueriesProvider(props) {
|
|
70
74
|
const { definitions, options, children, queryOptions } = props;
|
|
71
|
-
// Returns a query kind, for example "TimeSeriesQuery" = getQueryType("PrometheusTimeSeriesQuery")
|
|
72
|
-
const getQueryType = (0, _model.useQueryType)();
|
|
73
|
-
const queryDefinitions = definitions.map((definition)=>{
|
|
74
|
-
const type = getQueryType(definition.kind);
|
|
75
|
-
return {
|
|
76
|
-
kind: type,
|
|
77
|
-
spec: {
|
|
78
|
-
plugin: definition
|
|
79
|
-
}
|
|
80
|
-
};
|
|
81
|
-
});
|
|
82
75
|
const usageMetrics = (0, _UsageMetricsProvider.useUsageMetrics)();
|
|
83
76
|
// Filter definitions for time series query and other future query plugins
|
|
84
|
-
const timeSeriesQueries =
|
|
77
|
+
const timeSeriesQueries = definitions.filter((definition)=>definition.kind === 'TimeSeriesQuery');
|
|
85
78
|
const timeSeriesResults = (0, _timeseriesqueries.useTimeSeriesQueries)(timeSeriesQueries, options, queryOptions);
|
|
86
|
-
const traceQueries =
|
|
79
|
+
const traceQueries = definitions.filter((definition)=>definition.kind === 'TraceQuery');
|
|
87
80
|
const traceResults = (0, _tracequeries.useTraceQueries)(traceQueries);
|
|
88
|
-
const profileQueries =
|
|
81
|
+
const profileQueries = definitions.filter((definition)=>definition.kind === 'ProfileQuery');
|
|
89
82
|
const profileResults = (0, _profilequeries.useProfileQueries)(profileQueries);
|
|
90
|
-
const logQueries =
|
|
83
|
+
const logQueries = definitions.filter((definition)=>definition.kind === 'LogQuery');
|
|
91
84
|
const logResults = (0, _logqueries.useLogQueries)(logQueries);
|
|
85
|
+
const alertsQueries = definitions.filter((definition)=>definition.kind === 'AlertsQuery');
|
|
86
|
+
const alertsResults = (0, _alertsqueries.useAlertsQueries)(alertsQueries);
|
|
87
|
+
const silencesQueries = definitions.filter((definition)=>definition.kind === 'SilencesQuery');
|
|
88
|
+
const silencesResults = (0, _silencesqueries.useSilencesQueries)(silencesQueries);
|
|
92
89
|
const refetchAll = (0, _react.useCallback)(()=>{
|
|
93
90
|
timeSeriesResults.forEach((result)=>result.refetch());
|
|
94
91
|
traceResults.forEach((result)=>result.refetch());
|
|
95
92
|
profileResults.forEach((result)=>result.refetch());
|
|
96
93
|
logResults.forEach((result)=>result.refetch());
|
|
94
|
+
alertsResults.forEach((result)=>result.refetch());
|
|
95
|
+
silencesResults.forEach((result)=>result.refetch());
|
|
97
96
|
}, [
|
|
98
97
|
timeSeriesResults,
|
|
99
98
|
traceResults,
|
|
100
99
|
profileResults,
|
|
101
|
-
logResults
|
|
100
|
+
logResults,
|
|
101
|
+
alertsResults,
|
|
102
|
+
silencesResults
|
|
102
103
|
]);
|
|
103
104
|
const ctx = (0, _react.useMemo)(()=>{
|
|
104
105
|
const mergedQueryResults = [
|
|
105
106
|
...(0, _model.transformQueryResults)(timeSeriesResults, timeSeriesQueries),
|
|
106
107
|
...(0, _model.transformQueryResults)(traceResults, traceQueries),
|
|
107
108
|
...(0, _model.transformQueryResults)(profileResults, profileQueries),
|
|
108
|
-
...(0, _model.transformQueryResults)(logResults, logQueries)
|
|
109
|
+
...(0, _model.transformQueryResults)(logResults, logQueries),
|
|
110
|
+
...(0, _model.transformQueryResults)(alertsResults, alertsQueries),
|
|
111
|
+
...(0, _model.transformQueryResults)(silencesResults, silencesQueries)
|
|
109
112
|
];
|
|
110
113
|
if (queryOptions?.enabled) {
|
|
111
114
|
for (const result of mergedQueryResults){
|
|
@@ -119,6 +122,7 @@ function DataQueriesProvider(props) {
|
|
|
119
122
|
}
|
|
120
123
|
}
|
|
121
124
|
return {
|
|
125
|
+
queryDefinitions: definitions,
|
|
122
126
|
queryResults: mergedQueryResults,
|
|
123
127
|
isFetching: mergedQueryResults.some((result)=>result.isFetching),
|
|
124
128
|
isLoading: mergedQueryResults.some((result)=>result.isLoading),
|
|
@@ -126,16 +130,21 @@ function DataQueriesProvider(props) {
|
|
|
126
130
|
errors: mergedQueryResults.map((result)=>result.error)
|
|
127
131
|
};
|
|
128
132
|
}, [
|
|
133
|
+
alertsQueries,
|
|
134
|
+
alertsResults,
|
|
135
|
+
logQueries,
|
|
136
|
+
logResults,
|
|
137
|
+
profileQueries,
|
|
138
|
+
profileResults,
|
|
139
|
+
silencesQueries,
|
|
140
|
+
silencesResults,
|
|
129
141
|
timeSeriesQueries,
|
|
130
142
|
timeSeriesResults,
|
|
131
143
|
traceQueries,
|
|
132
144
|
traceResults,
|
|
133
|
-
|
|
134
|
-
profileResults,
|
|
135
|
-
logQueries,
|
|
136
|
-
logResults,
|
|
137
|
-
refetchAll,
|
|
145
|
+
definitions,
|
|
138
146
|
queryOptions?.enabled,
|
|
147
|
+
refetchAll,
|
|
139
148
|
usageMetrics
|
|
140
149
|
]);
|
|
141
150
|
return /*#__PURE__*/ (0, _jsxruntime.jsx)(DataQueriesContext.Provider, {
|
|
@@ -14,22 +14,12 @@
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", {
|
|
15
15
|
value: true
|
|
16
16
|
});
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
get: Object.getOwnPropertyDescriptor(all, name).get
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
_export(exports, {
|
|
24
|
-
get transformQueryResults () {
|
|
17
|
+
Object.defineProperty(exports, "transformQueryResults", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: function() {
|
|
25
20
|
return transformQueryResults;
|
|
26
|
-
},
|
|
27
|
-
get useQueryType () {
|
|
28
|
-
return useQueryType;
|
|
29
21
|
}
|
|
30
22
|
});
|
|
31
|
-
const _react = require("react");
|
|
32
|
-
const _pluginregistry = require("../plugin-registry");
|
|
33
23
|
function transformQueryResults(results, definitions) {
|
|
34
24
|
return results.map(({ data, isFetching, isLoading, refetch, error }, i)=>{
|
|
35
25
|
return {
|
|
@@ -42,83 +32,3 @@ function transformQueryResults(results, definitions) {
|
|
|
42
32
|
};
|
|
43
33
|
});
|
|
44
34
|
}
|
|
45
|
-
function useQueryType() {
|
|
46
|
-
const { data: timeSeriesQueryPlugins, isLoading: isTimeSeriesQueryLoading } = (0, _pluginregistry.useListPluginMetadata)([
|
|
47
|
-
'TimeSeriesQuery'
|
|
48
|
-
]);
|
|
49
|
-
const { data: traceQueryPlugins, isLoading: isTraceQueryPluginLoading } = (0, _pluginregistry.useListPluginMetadata)([
|
|
50
|
-
'TraceQuery'
|
|
51
|
-
]);
|
|
52
|
-
const { data: profileQueryPlugins, isLoading: isProfileQueryPluginLoading } = (0, _pluginregistry.useListPluginMetadata)([
|
|
53
|
-
'ProfileQuery'
|
|
54
|
-
]);
|
|
55
|
-
const { data: logQueries, isLoading: isLogQueryPluginLoading } = (0, _pluginregistry.useListPluginMetadata)([
|
|
56
|
-
'LogQuery'
|
|
57
|
-
]);
|
|
58
|
-
// For example, `map: {"TimeSeriesQuery":["PrometheusTimeSeriesQuery"],"TraceQuery":["TempoTraceQuery"]}`
|
|
59
|
-
const queryTypeMap = (0, _react.useMemo)(()=>{
|
|
60
|
-
const map = {
|
|
61
|
-
TimeSeriesQuery: [],
|
|
62
|
-
TraceQuery: [],
|
|
63
|
-
ProfileQuery: [],
|
|
64
|
-
LogQuery: []
|
|
65
|
-
};
|
|
66
|
-
if (timeSeriesQueryPlugins) {
|
|
67
|
-
timeSeriesQueryPlugins.forEach((plugin)=>{
|
|
68
|
-
map[plugin.kind]?.push(plugin.spec.name);
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
if (traceQueryPlugins) {
|
|
72
|
-
traceQueryPlugins.forEach((plugin)=>{
|
|
73
|
-
map[plugin.kind]?.push(plugin.spec.name);
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
if (profileQueryPlugins) {
|
|
77
|
-
profileQueryPlugins.forEach((plugin)=>{
|
|
78
|
-
map[plugin.kind]?.push(plugin.spec.name);
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
if (logQueries) {
|
|
82
|
-
logQueries.forEach((plugin)=>{
|
|
83
|
-
map[plugin.kind]?.push(plugin.spec.name);
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
return map;
|
|
87
|
-
}, [
|
|
88
|
-
timeSeriesQueryPlugins,
|
|
89
|
-
traceQueryPlugins,
|
|
90
|
-
profileQueryPlugins,
|
|
91
|
-
logQueries
|
|
92
|
-
]);
|
|
93
|
-
const getQueryType = (0, _react.useCallback)((pluginKind)=>{
|
|
94
|
-
const isLoading = (pluginKind)=>{
|
|
95
|
-
switch(pluginKind){
|
|
96
|
-
case 'PrometheusTimeSeriesQuery':
|
|
97
|
-
return isTimeSeriesQueryLoading;
|
|
98
|
-
case 'TempoTraceQuery':
|
|
99
|
-
return isTraceQueryPluginLoading;
|
|
100
|
-
case 'PyroscopeProfileQuery':
|
|
101
|
-
return isProfileQueryPluginLoading;
|
|
102
|
-
case 'LokiLogQuery':
|
|
103
|
-
return isLogQueryPluginLoading;
|
|
104
|
-
}
|
|
105
|
-
return isTraceQueryPluginLoading || isTimeSeriesQueryLoading || isProfileQueryPluginLoading || isLogQueryPluginLoading;
|
|
106
|
-
};
|
|
107
|
-
if (isLoading(pluginKind)) {
|
|
108
|
-
return undefined;
|
|
109
|
-
}
|
|
110
|
-
for(const queryType in queryTypeMap){
|
|
111
|
-
if (queryTypeMap[queryType]?.includes(pluginKind)) {
|
|
112
|
-
return queryType;
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
throw new Error(`Unable to determine the query type: ${pluginKind}`);
|
|
116
|
-
}, [
|
|
117
|
-
queryTypeMap,
|
|
118
|
-
isTimeSeriesQueryLoading,
|
|
119
|
-
isTraceQueryPluginLoading,
|
|
120
|
-
isProfileQueryPluginLoading,
|
|
121
|
-
isLogQueryPluginLoading
|
|
122
|
-
]);
|
|
123
|
-
return getQueryType;
|
|
124
|
-
}
|
|
@@ -35,7 +35,7 @@ _export(exports, {
|
|
|
35
35
|
}
|
|
36
36
|
});
|
|
37
37
|
const _jsxruntime = require("react/jsx-runtime");
|
|
38
|
-
const
|
|
38
|
+
const _client = require("@perses-dev/client");
|
|
39
39
|
const _react = require("react");
|
|
40
40
|
const UsageMetricsContext = /*#__PURE__*/ (0, _react.createContext)(undefined);
|
|
41
41
|
const useUsageMetricsContext = ()=>{
|
|
@@ -70,7 +70,7 @@ const useUsageMetrics = ()=>{
|
|
|
70
70
|
};
|
|
71
71
|
};
|
|
72
72
|
const submitMetrics = async (stats)=>{
|
|
73
|
-
await (0,
|
|
73
|
+
await (0, _client.fetch)(`${stats.apiPrefix ?? ''}/api/v1/view`, {
|
|
74
74
|
method: 'POST',
|
|
75
75
|
headers: {
|
|
76
76
|
'Content-Type': 'application/json'
|
|
@@ -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
|
+
}
|