@perses-dev/plugin-system 0.0.0-snapshot-ts-panel-actions-76080ec → 0.0.0-snapshot-reverse-proxy-75afbd7
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/DatasourceEditorForm/DatasourceEditorForm.js +1 -0
- package/dist/cjs/components/{DatasourceSelect.js → DatasourceSelect/DatasourceSelect.js} +4 -3
- package/dist/cjs/components/DatasourceSelect/index.js +30 -0
- package/dist/cjs/components/LegendOptionsEditor/LegendOptionsEditor.js +117 -90
- package/dist/cjs/components/MultiQueryEditor/MultiQueryEditor.js +5 -2
- package/dist/cjs/components/MultiQueryEditor/QueryEditorContainer.js +14 -4
- package/dist/cjs/components/PanelSpecEditor/PanelSpecEditor.js +7 -5
- package/dist/cjs/components/PluginEditor/PluginEditor.js +57 -17
- package/dist/cjs/components/PluginKindSelect/PluginKindSelect.js +6 -3
- package/dist/cjs/components/PluginSpecEditor/PluginSpecEditor.js +13 -9
- package/dist/cjs/components/Variables/VariableEditorForm/VariableEditorForm.js +62 -120
- package/dist/cjs/components/Variables/VariableEditorForm/VariablePreview.js +42 -33
- package/dist/cjs/components/Variables/VariableEditorForm/index.js +1 -0
- package/dist/cjs/components/Variables/VariableEditorForm/variable-editor-form-model.js +47 -0
- package/dist/cjs/components/Variables/variable-model.js +3 -3
- package/dist/cjs/components/index.js +0 -1
- package/dist/cjs/context/index.js +0 -1
- package/dist/cjs/model/legend.js +13 -0
- package/dist/cjs/model/log-queries.js +16 -0
- package/dist/cjs/remote/PluginRuntime.js +3 -2
- package/dist/cjs/remote/remotePluginLoader.js +19 -4
- package/dist/cjs/runtime/DataQueriesProvider/DataQueriesProvider.js +10 -2
- package/dist/cjs/runtime/DataQueriesProvider/model.js +17 -4
- package/dist/cjs/runtime/RouterProvider.js +114 -0
- package/dist/cjs/runtime/TimeRangeProvider/TimeRangeProvider.js +6 -1
- package/dist/cjs/runtime/UsageMetricsProvider.js +4 -3
- package/dist/cjs/runtime/index.js +1 -0
- package/dist/cjs/runtime/log-queries.js +68 -0
- package/dist/cjs/runtime/time-series-queries.js +4 -4
- package/dist/cjs/runtime/variables.js +15 -0
- package/dist/cjs/test/mock-data.js +182 -0
- package/dist/cjs/test/utils.js +17 -8
- package/dist/cjs/utils/variables.js +109 -14
- package/dist/components/DatasourceEditorForm/DatasourceEditorForm.d.ts.map +1 -1
- package/dist/components/DatasourceEditorForm/DatasourceEditorForm.js +1 -0
- package/dist/components/DatasourceEditorForm/DatasourceEditorForm.js.map +1 -1
- package/dist/components/{DatasourceSelect.d.ts → DatasourceSelect/DatasourceSelect.d.ts} +1 -1
- package/dist/components/DatasourceSelect/DatasourceSelect.d.ts.map +1 -0
- package/dist/components/{DatasourceSelect.js → DatasourceSelect/DatasourceSelect.js} +4 -3
- package/dist/components/DatasourceSelect/DatasourceSelect.js.map +1 -0
- package/dist/components/DatasourceSelect/index.d.ts +2 -0
- package/dist/components/DatasourceSelect/index.d.ts.map +1 -0
- package/dist/components/DatasourceSelect/index.js +15 -0
- package/dist/components/DatasourceSelect/index.js.map +1 -0
- package/dist/components/LegendOptionsEditor/LegendOptionsEditor.d.ts +2 -1
- package/dist/components/LegendOptionsEditor/LegendOptionsEditor.d.ts.map +1 -1
- package/dist/components/LegendOptionsEditor/LegendOptionsEditor.js +120 -93
- package/dist/components/LegendOptionsEditor/LegendOptionsEditor.js.map +1 -1
- package/dist/components/MultiQueryEditor/MultiQueryEditor.d.ts +3 -2
- package/dist/components/MultiQueryEditor/MultiQueryEditor.d.ts.map +1 -1
- package/dist/components/MultiQueryEditor/MultiQueryEditor.js +6 -3
- package/dist/components/MultiQueryEditor/MultiQueryEditor.js.map +1 -1
- package/dist/components/MultiQueryEditor/QueryEditorContainer.d.ts +3 -2
- package/dist/components/MultiQueryEditor/QueryEditorContainer.d.ts.map +1 -1
- package/dist/components/MultiQueryEditor/QueryEditorContainer.js +14 -4
- package/dist/components/MultiQueryEditor/QueryEditorContainer.js.map +1 -1
- package/dist/components/PanelSpecEditor/PanelSpecEditor.d.ts +3 -2
- package/dist/components/PanelSpecEditor/PanelSpecEditor.d.ts.map +1 -1
- package/dist/components/PanelSpecEditor/PanelSpecEditor.js +7 -5
- package/dist/components/PanelSpecEditor/PanelSpecEditor.js.map +1 -1
- package/dist/components/PluginEditor/PluginEditor.d.ts +3 -3
- package/dist/components/PluginEditor/PluginEditor.d.ts.map +1 -1
- package/dist/components/PluginEditor/PluginEditor.js +57 -17
- package/dist/components/PluginEditor/PluginEditor.js.map +1 -1
- package/dist/components/PluginEditor/plugin-editor-api.d.ts +5 -0
- package/dist/components/PluginEditor/plugin-editor-api.d.ts.map +1 -1
- package/dist/components/PluginEditor/plugin-editor-api.js.map +1 -1
- package/dist/components/PluginKindSelect/PluginKindSelect.d.ts.map +1 -1
- package/dist/components/PluginKindSelect/PluginKindSelect.js +7 -4
- package/dist/components/PluginKindSelect/PluginKindSelect.js.map +1 -1
- package/dist/components/PluginSpecEditor/PluginSpecEditor.d.ts.map +1 -1
- package/dist/components/PluginSpecEditor/PluginSpecEditor.js +13 -9
- package/dist/components/PluginSpecEditor/PluginSpecEditor.js.map +1 -1
- package/dist/components/TimeRangeControls/TimeRangeControls.js.map +1 -1
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts.map +1 -1
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js +63 -80
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js.map +1 -1
- package/dist/components/Variables/VariableEditorForm/VariablePreview.d.ts +2 -2
- package/dist/components/Variables/VariableEditorForm/VariablePreview.d.ts.map +1 -1
- package/dist/components/Variables/VariableEditorForm/VariablePreview.js +43 -34
- package/dist/components/Variables/VariableEditorForm/VariablePreview.js.map +1 -1
- package/dist/components/Variables/VariableEditorForm/index.d.ts +1 -0
- package/dist/components/Variables/VariableEditorForm/index.d.ts.map +1 -1
- package/dist/components/Variables/VariableEditorForm/index.js +1 -0
- package/dist/components/Variables/VariableEditorForm/index.js.map +1 -1
- package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.d.ts +6 -0
- package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.d.ts.map +1 -1
- package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js +44 -0
- package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js.map +1 -1
- package/dist/components/Variables/variable-model.js +3 -3
- package/dist/components/Variables/variable-model.js.map +1 -1
- package/dist/components/index.d.ts +0 -1
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +0 -1
- package/dist/components/index.js.map +1 -1
- package/dist/context/index.d.ts +0 -1
- package/dist/context/index.d.ts.map +1 -1
- package/dist/context/index.js +0 -1
- package/dist/context/index.js.map +1 -1
- package/dist/model/legend.d.ts +3 -1
- package/dist/model/legend.d.ts.map +1 -1
- package/dist/model/legend.js +10 -0
- package/dist/model/legend.js.map +1 -1
- package/dist/model/log-queries.d.ts +24 -0
- package/dist/model/log-queries.d.ts.map +1 -0
- package/dist/model/log-queries.js +15 -0
- package/dist/model/log-queries.js.map +1 -0
- package/dist/model/plugin-base.d.ts +6 -1
- package/dist/model/plugin-base.d.ts.map +1 -1
- package/dist/model/plugin-base.js.map +1 -1
- package/dist/model/plugins.d.ts +2 -0
- package/dist/model/plugins.d.ts.map +1 -1
- package/dist/model/plugins.js.map +1 -1
- package/dist/model/time-series-queries.d.ts +1 -1
- package/dist/model/time-series-queries.d.ts.map +1 -1
- package/dist/model/time-series-queries.js.map +1 -1
- package/dist/model/variables.d.ts +1 -1
- package/dist/model/variables.d.ts.map +1 -1
- package/dist/model/variables.js.map +1 -1
- package/dist/remote/PluginRuntime.d.ts +2 -2
- package/dist/remote/PluginRuntime.d.ts.map +1 -1
- package/dist/remote/PluginRuntime.js +4 -3
- package/dist/remote/PluginRuntime.js.map +1 -1
- package/dist/remote/remotePluginLoader.d.ts +18 -1
- package/dist/remote/remotePluginLoader.d.ts.map +1 -1
- package/dist/remote/remotePluginLoader.js +22 -4
- package/dist/remote/remotePluginLoader.js.map +1 -1
- package/dist/runtime/DataQueriesProvider/DataQueriesProvider.d.ts.map +1 -1
- package/dist/runtime/DataQueriesProvider/DataQueriesProvider.js +10 -2
- package/dist/runtime/DataQueriesProvider/DataQueriesProvider.js.map +1 -1
- package/dist/runtime/DataQueriesProvider/model.d.ts.map +1 -1
- package/dist/runtime/DataQueriesProvider/model.js +17 -4
- package/dist/runtime/DataQueriesProvider/model.js.map +1 -1
- package/dist/runtime/RouterProvider.d.ts +32 -0
- package/dist/runtime/RouterProvider.d.ts.map +1 -0
- package/dist/runtime/RouterProvider.js +59 -0
- package/dist/runtime/RouterProvider.js.map +1 -0
- package/dist/runtime/TimeRangeProvider/TimeRangeProvider.d.ts.map +1 -1
- package/dist/runtime/TimeRangeProvider/TimeRangeProvider.js +6 -1
- package/dist/runtime/TimeRangeProvider/TimeRangeProvider.js.map +1 -1
- package/dist/runtime/TimeRangeProvider/query-params.d.ts.map +1 -1
- package/dist/runtime/TimeRangeProvider/query-params.js.map +1 -1
- package/dist/runtime/UsageMetricsProvider.d.ts +3 -1
- package/dist/runtime/UsageMetricsProvider.d.ts.map +1 -1
- package/dist/runtime/UsageMetricsProvider.js +4 -3
- package/dist/runtime/UsageMetricsProvider.js.map +1 -1
- package/dist/runtime/index.d.ts +1 -0
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/runtime/index.js +1 -0
- package/dist/runtime/index.js.map +1 -1
- package/dist/runtime/log-queries.d.ts +7 -0
- package/dist/runtime/log-queries.d.ts.map +1 -0
- package/dist/runtime/log-queries.js +52 -0
- package/dist/runtime/log-queries.js.map +1 -0
- package/dist/runtime/time-series-queries.d.ts.map +1 -1
- package/dist/runtime/time-series-queries.js +4 -4
- package/dist/runtime/time-series-queries.js.map +1 -1
- package/dist/runtime/variables.d.ts +1 -0
- package/dist/runtime/variables.d.ts.map +1 -1
- package/dist/runtime/variables.js +13 -0
- package/dist/runtime/variables.js.map +1 -1
- package/dist/test/mock-data.d.ts +136 -1
- package/dist/test/mock-data.d.ts.map +1 -1
- package/dist/test/mock-data.js +156 -0
- package/dist/test/mock-data.js.map +1 -1
- package/dist/test/utils.d.ts.map +1 -1
- package/dist/test/utils.js +17 -8
- package/dist/test/utils.js.map +1 -1
- package/dist/utils/variables.d.ts +24 -2
- package/dist/utils/variables.d.ts.map +1 -1
- package/dist/utils/variables.js +102 -14
- package/dist/utils/variables.js.map +1 -1
- package/package.json +7 -7
- package/dist/cjs/components/ProjectSelect.js +0 -96
- package/dist/cjs/context/ProjectStoreProvider.js +0 -81
- package/dist/cjs/context/query-params.js +0 -49
- package/dist/components/DatasourceSelect.d.ts.map +0 -1
- package/dist/components/DatasourceSelect.js.map +0 -1
- package/dist/components/ProjectSelect.d.ts +0 -15
- package/dist/components/ProjectSelect.d.ts.map +0 -1
- package/dist/components/ProjectSelect.js +0 -91
- package/dist/components/ProjectSelect.js.map +0 -1
- package/dist/context/ProjectStoreProvider.d.ts +0 -16
- package/dist/context/ProjectStoreProvider.d.ts.map +0 -1
- package/dist/context/ProjectStoreProvider.js +0 -59
- package/dist/context/ProjectStoreProvider.js.map +0 -1
- package/dist/context/query-params.d.ts +0 -5
- package/dist/context/query-params.d.ts.map +0 -1
- package/dist/context/query-params.js +0 -41
- package/dist/context/query-params.js.map +0 -1
|
@@ -52,12 +52,16 @@ function useQueryType() {
|
|
|
52
52
|
const { data: profileQueryPlugins, isLoading: isProfileQueryPluginLoading } = (0, _pluginregistry.useListPluginMetadata)([
|
|
53
53
|
'ProfileQuery'
|
|
54
54
|
]);
|
|
55
|
+
const { data: logQueries, isLoading: isLogQueryPluginLoading } = (0, _pluginregistry.useListPluginMetadata)([
|
|
56
|
+
'LogQuery'
|
|
57
|
+
]);
|
|
55
58
|
// For example, `map: {"TimeSeriesQuery":["PrometheusTimeSeriesQuery"],"TraceQuery":["TempoTraceQuery"]}`
|
|
56
59
|
const queryTypeMap = (0, _react.useMemo)(()=>{
|
|
57
60
|
const map = {
|
|
58
61
|
TimeSeriesQuery: [],
|
|
59
62
|
TraceQuery: [],
|
|
60
|
-
ProfileQuery: []
|
|
63
|
+
ProfileQuery: [],
|
|
64
|
+
LogQuery: []
|
|
61
65
|
};
|
|
62
66
|
if (timeSeriesQueryPlugins) {
|
|
63
67
|
timeSeriesQueryPlugins.forEach((plugin)=>{
|
|
@@ -74,11 +78,17 @@ function useQueryType() {
|
|
|
74
78
|
map[plugin.kind]?.push(plugin.spec.name);
|
|
75
79
|
});
|
|
76
80
|
}
|
|
81
|
+
if (logQueries) {
|
|
82
|
+
logQueries.forEach((plugin)=>{
|
|
83
|
+
map[plugin.kind]?.push(plugin.spec.name);
|
|
84
|
+
});
|
|
85
|
+
}
|
|
77
86
|
return map;
|
|
78
87
|
}, [
|
|
79
88
|
timeSeriesQueryPlugins,
|
|
80
89
|
traceQueryPlugins,
|
|
81
|
-
profileQueryPlugins
|
|
90
|
+
profileQueryPlugins,
|
|
91
|
+
logQueries
|
|
82
92
|
]);
|
|
83
93
|
const getQueryType = (0, _react.useCallback)((pluginKind)=>{
|
|
84
94
|
const isLoading = (pluginKind)=>{
|
|
@@ -89,8 +99,10 @@ function useQueryType() {
|
|
|
89
99
|
return isTraceQueryPluginLoading;
|
|
90
100
|
case 'PyroscopeProfileQuery':
|
|
91
101
|
return isProfileQueryPluginLoading;
|
|
102
|
+
case 'LokiLogQuery':
|
|
103
|
+
return isLogQueryPluginLoading;
|
|
92
104
|
}
|
|
93
|
-
return isTraceQueryPluginLoading || isTimeSeriesQueryLoading || isProfileQueryPluginLoading;
|
|
105
|
+
return isTraceQueryPluginLoading || isTimeSeriesQueryLoading || isProfileQueryPluginLoading || isLogQueryPluginLoading;
|
|
94
106
|
};
|
|
95
107
|
if (isLoading(pluginKind)) {
|
|
96
108
|
return undefined;
|
|
@@ -105,7 +117,8 @@ function useQueryType() {
|
|
|
105
117
|
queryTypeMap,
|
|
106
118
|
isTimeSeriesQueryLoading,
|
|
107
119
|
isTraceQueryPluginLoading,
|
|
108
|
-
isProfileQueryPluginLoading
|
|
120
|
+
isProfileQueryPluginLoading,
|
|
121
|
+
isLogQueryPluginLoading
|
|
109
122
|
]);
|
|
110
123
|
return getQueryType;
|
|
111
124
|
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
// Copyright 2025 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: all[name]
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
_export(exports, {
|
|
24
|
+
ReactRouterProvider: function() {
|
|
25
|
+
return ReactRouterProvider;
|
|
26
|
+
},
|
|
27
|
+
RouterContext: function() {
|
|
28
|
+
return RouterContext;
|
|
29
|
+
},
|
|
30
|
+
RouterProvider: function() {
|
|
31
|
+
return RouterProvider;
|
|
32
|
+
},
|
|
33
|
+
useRouterContext: function() {
|
|
34
|
+
return useRouterContext;
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
const _jsxruntime = require("react/jsx-runtime");
|
|
38
|
+
const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
|
|
39
|
+
const _reactrouterdom = require("react-router-dom");
|
|
40
|
+
function _getRequireWildcardCache(nodeInterop) {
|
|
41
|
+
if (typeof WeakMap !== "function") return null;
|
|
42
|
+
var cacheBabelInterop = new WeakMap();
|
|
43
|
+
var cacheNodeInterop = new WeakMap();
|
|
44
|
+
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
45
|
+
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
46
|
+
})(nodeInterop);
|
|
47
|
+
}
|
|
48
|
+
function _interop_require_wildcard(obj, nodeInterop) {
|
|
49
|
+
if (!nodeInterop && obj && obj.__esModule) {
|
|
50
|
+
return obj;
|
|
51
|
+
}
|
|
52
|
+
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
53
|
+
return {
|
|
54
|
+
default: obj
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
var cache = _getRequireWildcardCache(nodeInterop);
|
|
58
|
+
if (cache && cache.has(obj)) {
|
|
59
|
+
return cache.get(obj);
|
|
60
|
+
}
|
|
61
|
+
var newObj = {
|
|
62
|
+
__proto__: null
|
|
63
|
+
};
|
|
64
|
+
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
65
|
+
for(var key in obj){
|
|
66
|
+
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
67
|
+
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
68
|
+
if (desc && (desc.get || desc.set)) {
|
|
69
|
+
Object.defineProperty(newObj, key, desc);
|
|
70
|
+
} else {
|
|
71
|
+
newObj[key] = obj[key];
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
newObj.default = obj;
|
|
76
|
+
if (cache) {
|
|
77
|
+
cache.set(obj, newObj);
|
|
78
|
+
}
|
|
79
|
+
return newObj;
|
|
80
|
+
}
|
|
81
|
+
const RouterContext = /*#__PURE__*/ (0, _react.createContext)(undefined);
|
|
82
|
+
function useRouterContext() {
|
|
83
|
+
const ctx = (0, _react.useContext)(RouterContext);
|
|
84
|
+
if (ctx === undefined) {
|
|
85
|
+
console.warn('No RouterContext found. Did you forget a <RouterProvider>?');
|
|
86
|
+
return {};
|
|
87
|
+
}
|
|
88
|
+
return ctx;
|
|
89
|
+
}
|
|
90
|
+
function RouterProvider(props) {
|
|
91
|
+
const { RouterComponent, navigate, children } = props;
|
|
92
|
+
const ctx = (0, _react.useMemo)(()=>{
|
|
93
|
+
return {
|
|
94
|
+
RouterComponent,
|
|
95
|
+
navigate
|
|
96
|
+
};
|
|
97
|
+
}, [
|
|
98
|
+
RouterComponent,
|
|
99
|
+
navigate
|
|
100
|
+
]);
|
|
101
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(RouterContext.Provider, {
|
|
102
|
+
value: ctx,
|
|
103
|
+
children: children
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
function ReactRouterProvider(props) {
|
|
107
|
+
const { children } = props;
|
|
108
|
+
const navigate = (0, _reactrouterdom.useNavigate)();
|
|
109
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(RouterProvider, {
|
|
110
|
+
RouterComponent: _reactrouterdom.Link,
|
|
111
|
+
navigate: navigate,
|
|
112
|
+
children: children
|
|
113
|
+
});
|
|
114
|
+
}
|
|
@@ -100,7 +100,12 @@ function useSuggestedStepMs(width) {
|
|
|
100
100
|
}
|
|
101
101
|
function TimeRangeProvider(props) {
|
|
102
102
|
const { timeRange, refreshInterval, children, setTimeRange, setRefreshInterval } = props;
|
|
103
|
-
|
|
103
|
+
/**
|
|
104
|
+
* TODO: The hook needs refactor. There is a bug here with refreshKey. If the refreshInterval is not set,
|
|
105
|
+
* refreshKey string includes an undefined xx:yy:zz:undefined:0
|
|
106
|
+
* I think exposing refresh functionality also is very risky. A careless usage of refresh may cause
|
|
107
|
+
* infinite rendering loop.
|
|
108
|
+
*/ const [localTimeRange, setLocalTimeRange] = (0, _react.useState)(timeRange);
|
|
104
109
|
const [localRefreshInterval, setLocalRefreshInterval] = (0, _react.useState)(refreshInterval);
|
|
105
110
|
const [refreshCounter, setRefreshCounter] = (0, _react.useState)(0);
|
|
106
111
|
(0, _react.useEffect)(()=>{
|
|
@@ -70,7 +70,7 @@ const useUsageMetrics = ()=>{
|
|
|
70
70
|
};
|
|
71
71
|
};
|
|
72
72
|
const submitMetrics = async (stats)=>{
|
|
73
|
-
await (0, _core.fetch)('/api/v1/view
|
|
73
|
+
await (0, _core.fetch)(`${stats.apiPrefix ?? ''}/api/v1/view`, {
|
|
74
74
|
method: 'POST',
|
|
75
75
|
headers: {
|
|
76
76
|
'Content-Type': 'application/json'
|
|
@@ -83,14 +83,15 @@ const submitMetrics = async (stats)=>{
|
|
|
83
83
|
})
|
|
84
84
|
});
|
|
85
85
|
};
|
|
86
|
-
const UsageMetricsProvider = ({ project, dashboard, children })=>{
|
|
86
|
+
const UsageMetricsProvider = ({ apiPrefix, project, dashboard, children })=>{
|
|
87
87
|
const ctx = {
|
|
88
88
|
project: project,
|
|
89
89
|
dashboard: dashboard,
|
|
90
90
|
renderErrorCount: 0,
|
|
91
91
|
startRenderTime: Date.now(),
|
|
92
92
|
renderDurationMs: 0,
|
|
93
|
-
pendingQueries: new Map()
|
|
93
|
+
pendingQueries: new Map(),
|
|
94
|
+
apiPrefix
|
|
94
95
|
};
|
|
95
96
|
return /*#__PURE__*/ (0, _jsxruntime.jsx)(UsageMetricsContext.Provider, {
|
|
96
97
|
value: ctx,
|
|
@@ -24,6 +24,7 @@ _export_star(require("./trace-queries"), exports);
|
|
|
24
24
|
_export_star(require("./profile-queries"), exports);
|
|
25
25
|
_export_star(require("./DataQueriesProvider"), exports);
|
|
26
26
|
_export_star(require("./QueryCountProvider"), exports);
|
|
27
|
+
_export_star(require("./RouterProvider"), exports);
|
|
27
28
|
_export_star(require("./UsageMetricsProvider"), exports);
|
|
28
29
|
function _export_star(from, to) {
|
|
29
30
|
Object.keys(from).forEach(function(k) {
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
// Copyright 2025 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: all[name]
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
_export(exports, {
|
|
24
|
+
LOG_QUERY_KEY: function() {
|
|
25
|
+
return LOG_QUERY_KEY;
|
|
26
|
+
},
|
|
27
|
+
useLogQueries: function() {
|
|
28
|
+
return useLogQueries;
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
const _reactquery = require("@tanstack/react-query");
|
|
32
|
+
const _datasources = require("./datasources");
|
|
33
|
+
const _pluginregistry = require("./plugin-registry");
|
|
34
|
+
const _TimeRangeProvider = require("./TimeRangeProvider");
|
|
35
|
+
const _variables = require("./variables");
|
|
36
|
+
const LOG_QUERY_KEY = 'LogQuery';
|
|
37
|
+
function useLogQueries(definitions) {
|
|
38
|
+
const { getPlugin } = (0, _pluginregistry.usePluginRegistry)();
|
|
39
|
+
const datasourceStore = (0, _datasources.useDatasourceStore)();
|
|
40
|
+
const { absoluteTimeRange } = (0, _TimeRangeProvider.useTimeRange)();
|
|
41
|
+
const variableValues = (0, _variables.useVariableValues)();
|
|
42
|
+
const context = {
|
|
43
|
+
timeRange: absoluteTimeRange,
|
|
44
|
+
variableState: variableValues,
|
|
45
|
+
datasourceStore,
|
|
46
|
+
refreshKey: ''
|
|
47
|
+
};
|
|
48
|
+
return (0, _reactquery.useQueries)({
|
|
49
|
+
queries: definitions.map((definition)=>{
|
|
50
|
+
const queryKey = [
|
|
51
|
+
definition,
|
|
52
|
+
datasourceStore,
|
|
53
|
+
absoluteTimeRange,
|
|
54
|
+
variableValues
|
|
55
|
+
];
|
|
56
|
+
const logQueryKind = definition?.spec?.plugin?.kind;
|
|
57
|
+
return {
|
|
58
|
+
queryKey: queryKey,
|
|
59
|
+
queryFn: async ()=>{
|
|
60
|
+
const plugin = await getPlugin(LOG_QUERY_KEY, logQueryKind);
|
|
61
|
+
const data = await plugin.getLogData(definition.spec.plugin.spec, context);
|
|
62
|
+
return data;
|
|
63
|
+
},
|
|
64
|
+
structuralSharing: false
|
|
65
|
+
};
|
|
66
|
+
})
|
|
67
|
+
});
|
|
68
|
+
}
|
|
@@ -82,7 +82,7 @@ const useTimeSeriesQuery = (definition, options, queryOptions)=>{
|
|
|
82
82
|
return (0, _reactquery.useQuery)({
|
|
83
83
|
enabled: (queryOptions?.enabled ?? true) || queryEnabled,
|
|
84
84
|
queryKey: queryKey,
|
|
85
|
-
queryFn: ()=>{
|
|
85
|
+
queryFn: ({ signal })=>{
|
|
86
86
|
// The 'enabled' option should prevent this from happening, but make TypeScript happy by checking
|
|
87
87
|
if (plugin === undefined) {
|
|
88
88
|
throw new Error('Expected plugin to be loaded');
|
|
@@ -92,7 +92,7 @@ const useTimeSeriesQuery = (definition, options, queryOptions)=>{
|
|
|
92
92
|
...context,
|
|
93
93
|
suggestedStepMs: options?.suggestedStepMs
|
|
94
94
|
};
|
|
95
|
-
return plugin.getTimeSeriesData(definition.spec.plugin.spec, ctx);
|
|
95
|
+
return plugin.getTimeSeriesData(definition.spec.plugin.spec, ctx, signal);
|
|
96
96
|
}
|
|
97
97
|
});
|
|
98
98
|
};
|
|
@@ -118,14 +118,14 @@ function useTimeSeriesQueries(definitions, options, queryOptions) {
|
|
|
118
118
|
...queryOptions,
|
|
119
119
|
enabled: (queryOptions?.enabled ?? true) && queryEnabled,
|
|
120
120
|
queryKey: queryKey,
|
|
121
|
-
queryFn: async ()=>{
|
|
121
|
+
queryFn: async ({ signal })=>{
|
|
122
122
|
const ctx = {
|
|
123
123
|
...context,
|
|
124
124
|
// Keep suggested step changes out of the query key, so we don´t have to run again query when it changes
|
|
125
125
|
suggestedStepMs: options?.suggestedStepMs
|
|
126
126
|
};
|
|
127
127
|
const plugin = await getPlugin(TIME_SERIES_QUERY_KEY, definition.spec.plugin.kind);
|
|
128
|
-
const data = await plugin.getTimeSeriesData(definition.spec.plugin.spec, ctx);
|
|
128
|
+
const data = await plugin.getTimeSeriesData(definition.spec.plugin.spec, ctx, signal);
|
|
129
129
|
return data;
|
|
130
130
|
}
|
|
131
131
|
};
|
|
@@ -27,6 +27,9 @@ _export(exports, {
|
|
|
27
27
|
VariableStoreStateMap: function() {
|
|
28
28
|
return VariableStoreStateMap;
|
|
29
29
|
},
|
|
30
|
+
replaceVariablesInString: function() {
|
|
31
|
+
return replaceVariablesInString;
|
|
32
|
+
},
|
|
30
33
|
useAllVariableValues: function() {
|
|
31
34
|
return useAllVariableValues;
|
|
32
35
|
},
|
|
@@ -137,6 +140,18 @@ function useAllVariableValues(names) {
|
|
|
137
140
|
builtinVariableValues
|
|
138
141
|
]);
|
|
139
142
|
}
|
|
143
|
+
function replaceVariablesInString(text, variableValues, extraVariables) {
|
|
144
|
+
const vars = {
|
|
145
|
+
...variableValues
|
|
146
|
+
}; // shallow clone to avoid modifying the original object
|
|
147
|
+
for (const [key, value] of Object.entries(extraVariables ?? {})){
|
|
148
|
+
vars[key] = {
|
|
149
|
+
value,
|
|
150
|
+
loading: false
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
return (0, _utils.replaceVariables)(text, vars);
|
|
154
|
+
}
|
|
140
155
|
function useReplaceVariablesInString(str) {
|
|
141
156
|
const variablesInString = str ? (0, _utils.parseVariables)(str) : [];
|
|
142
157
|
const variableValues = useAllVariableValues(variablesInString);
|
|
@@ -21,14 +21,41 @@ function _export(target, all) {
|
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
23
|
_export(exports, {
|
|
24
|
+
MOCK_EMPTY_PLUGIN_MODULE: function() {
|
|
25
|
+
return MOCK_EMPTY_PLUGIN_MODULE;
|
|
26
|
+
},
|
|
27
|
+
MOCK_INVALID_PLUGIN_MODULE: function() {
|
|
28
|
+
return MOCK_INVALID_PLUGIN_MODULE;
|
|
29
|
+
},
|
|
30
|
+
MOCK_LOG_DATA: function() {
|
|
31
|
+
return MOCK_LOG_DATA;
|
|
32
|
+
},
|
|
33
|
+
MOCK_MIXED_VALIDITY_PLUGIN_MODULES: function() {
|
|
34
|
+
return MOCK_MIXED_VALIDITY_PLUGIN_MODULES;
|
|
35
|
+
},
|
|
36
|
+
MOCK_MULTI_PLUGIN_MODULE: function() {
|
|
37
|
+
return MOCK_MULTI_PLUGIN_MODULE;
|
|
38
|
+
},
|
|
39
|
+
MOCK_PARTIAL_FAILURE_MODULE: function() {
|
|
40
|
+
return MOCK_PARTIAL_FAILURE_MODULE;
|
|
41
|
+
},
|
|
24
42
|
MOCK_PROFILE_DATA: function() {
|
|
25
43
|
return MOCK_PROFILE_DATA;
|
|
26
44
|
},
|
|
45
|
+
MOCK_REMOTE_PLUGIN_MODULE: function() {
|
|
46
|
+
return MOCK_REMOTE_PLUGIN_MODULE;
|
|
47
|
+
},
|
|
27
48
|
MOCK_TIME_SERIES_DATA: function() {
|
|
28
49
|
return MOCK_TIME_SERIES_DATA;
|
|
29
50
|
},
|
|
30
51
|
MOCK_TRACE_DATA: function() {
|
|
31
52
|
return MOCK_TRACE_DATA;
|
|
53
|
+
},
|
|
54
|
+
MOCK_VALID_PLUGIN_METADATA: function() {
|
|
55
|
+
return MOCK_VALID_PLUGIN_METADATA;
|
|
56
|
+
},
|
|
57
|
+
MOCK_VALID_PLUGIN_MODULE_RESOURCE: function() {
|
|
58
|
+
return MOCK_VALID_PLUGIN_MODULE_RESOURCE;
|
|
32
59
|
}
|
|
33
60
|
});
|
|
34
61
|
const MOCK_TIME_SERIES_DATA = {
|
|
@@ -102,6 +129,27 @@ const MOCK_TRACE_DATA = {
|
|
|
102
129
|
executedQueryString: '{ duration > 1000ms }'
|
|
103
130
|
}
|
|
104
131
|
};
|
|
132
|
+
const MOCK_LOG_DATA = {
|
|
133
|
+
totalCount: 2,
|
|
134
|
+
entries: [
|
|
135
|
+
{
|
|
136
|
+
timestamp: 1666479357903,
|
|
137
|
+
line: 'Error: Something went wrong',
|
|
138
|
+
labels: {
|
|
139
|
+
level: 'error',
|
|
140
|
+
service: 'backend'
|
|
141
|
+
}
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
timestamp: 1666479382282,
|
|
145
|
+
line: 'Info: Request processed successfully',
|
|
146
|
+
labels: {
|
|
147
|
+
level: 'info',
|
|
148
|
+
service: 'frontend'
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
]
|
|
152
|
+
};
|
|
105
153
|
const MOCK_PROFILE_DATA = {
|
|
106
154
|
profile: {
|
|
107
155
|
stackTrace: {
|
|
@@ -122,3 +170,137 @@ const MOCK_PROFILE_DATA = {
|
|
|
122
170
|
name: 'cpu'
|
|
123
171
|
}
|
|
124
172
|
};
|
|
173
|
+
const MOCK_VALID_PLUGIN_METADATA = {
|
|
174
|
+
kind: 'Panel',
|
|
175
|
+
spec: {
|
|
176
|
+
name: 'testPlugin',
|
|
177
|
+
display: {
|
|
178
|
+
name: 'Test Plugin',
|
|
179
|
+
description: 'A test plugin for unit testing'
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
const MOCK_VALID_PLUGIN_MODULE_RESOURCE = {
|
|
184
|
+
kind: 'PluginModule',
|
|
185
|
+
metadata: {
|
|
186
|
+
name: 'test-module',
|
|
187
|
+
version: '1.0.0'
|
|
188
|
+
},
|
|
189
|
+
spec: {
|
|
190
|
+
plugins: [
|
|
191
|
+
MOCK_VALID_PLUGIN_METADATA
|
|
192
|
+
]
|
|
193
|
+
}
|
|
194
|
+
};
|
|
195
|
+
const MOCK_INVALID_PLUGIN_MODULE = {
|
|
196
|
+
// Missing required fields
|
|
197
|
+
metadata: {
|
|
198
|
+
name: 'invalid-module'
|
|
199
|
+
},
|
|
200
|
+
spec: {
|
|
201
|
+
plugins: [
|
|
202
|
+
{
|
|
203
|
+
// Missing required fields
|
|
204
|
+
kind: 'Panel'
|
|
205
|
+
}
|
|
206
|
+
]
|
|
207
|
+
}
|
|
208
|
+
};
|
|
209
|
+
const MOCK_MIXED_VALIDITY_PLUGIN_MODULES = [
|
|
210
|
+
MOCK_VALID_PLUGIN_MODULE_RESOURCE,
|
|
211
|
+
MOCK_INVALID_PLUGIN_MODULE,
|
|
212
|
+
{
|
|
213
|
+
kind: 'PluginModule',
|
|
214
|
+
metadata: {
|
|
215
|
+
name: 'another-valid-module',
|
|
216
|
+
version: '2.0.0'
|
|
217
|
+
},
|
|
218
|
+
spec: {
|
|
219
|
+
plugins: [
|
|
220
|
+
{
|
|
221
|
+
kind: 'Variable',
|
|
222
|
+
spec: {
|
|
223
|
+
name: 'anotherPlugin',
|
|
224
|
+
display: {
|
|
225
|
+
name: 'Another Plugin'
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
]
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
];
|
|
233
|
+
const MOCK_REMOTE_PLUGIN_MODULE = {
|
|
234
|
+
testPlugin: {
|
|
235
|
+
component: ()=>null,
|
|
236
|
+
createDefaultOptions: ()=>({})
|
|
237
|
+
}
|
|
238
|
+
};
|
|
239
|
+
const MOCK_MULTI_PLUGIN_MODULE = {
|
|
240
|
+
kind: 'PluginModule',
|
|
241
|
+
metadata: {
|
|
242
|
+
name: 'multi-plugin-module',
|
|
243
|
+
version: '1.0.0'
|
|
244
|
+
},
|
|
245
|
+
spec: {
|
|
246
|
+
plugins: [
|
|
247
|
+
{
|
|
248
|
+
kind: 'Panel',
|
|
249
|
+
spec: {
|
|
250
|
+
name: 'plugin1',
|
|
251
|
+
display: {
|
|
252
|
+
name: 'Plugin 1'
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
},
|
|
256
|
+
{
|
|
257
|
+
kind: 'Variable',
|
|
258
|
+
spec: {
|
|
259
|
+
name: 'plugin2',
|
|
260
|
+
display: {
|
|
261
|
+
name: 'Plugin 2'
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
]
|
|
266
|
+
}
|
|
267
|
+
};
|
|
268
|
+
const MOCK_PARTIAL_FAILURE_MODULE = {
|
|
269
|
+
kind: 'PluginModule',
|
|
270
|
+
metadata: {
|
|
271
|
+
name: 'partial-failure-module',
|
|
272
|
+
version: '1.0.0'
|
|
273
|
+
},
|
|
274
|
+
spec: {
|
|
275
|
+
plugins: [
|
|
276
|
+
{
|
|
277
|
+
kind: 'Panel',
|
|
278
|
+
spec: {
|
|
279
|
+
name: 'workingPlugin',
|
|
280
|
+
display: {
|
|
281
|
+
name: 'Working Plugin'
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
},
|
|
285
|
+
{
|
|
286
|
+
kind: 'Variable',
|
|
287
|
+
spec: {
|
|
288
|
+
name: 'failingPlugin',
|
|
289
|
+
display: {
|
|
290
|
+
name: 'Failing Plugin'
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
]
|
|
295
|
+
}
|
|
296
|
+
};
|
|
297
|
+
const MOCK_EMPTY_PLUGIN_MODULE = {
|
|
298
|
+
kind: 'PluginModule',
|
|
299
|
+
metadata: {
|
|
300
|
+
name: 'empty-module',
|
|
301
|
+
version: '1.0.0'
|
|
302
|
+
},
|
|
303
|
+
spec: {
|
|
304
|
+
plugins: []
|
|
305
|
+
}
|
|
306
|
+
};
|
package/dist/cjs/test/utils.js
CHANGED
|
@@ -22,7 +22,9 @@ 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");
|
|
25
26
|
const _components = require("../components");
|
|
27
|
+
const _runtime = require("../runtime");
|
|
26
28
|
const _testplugins = require("./test-plugins");
|
|
27
29
|
function getTestContextWrapper(contextOptions) {
|
|
28
30
|
// Create a new QueryClient for each test to avoid caching issues
|
|
@@ -34,15 +36,22 @@ function getTestContextWrapper(contextOptions) {
|
|
|
34
36
|
}
|
|
35
37
|
}
|
|
36
38
|
});
|
|
39
|
+
const timeRange = {
|
|
40
|
+
start: new Date(Date.now() - Number(_core.DEFAULT_DASHBOARD_DURATION)),
|
|
41
|
+
end: new Date()
|
|
42
|
+
};
|
|
37
43
|
return function Wrapper({ children }) {
|
|
38
|
-
return /*#__PURE__*/ (0, _jsxruntime.jsx)(
|
|
39
|
-
|
|
40
|
-
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_runtime.TimeRangeProvider, {
|
|
45
|
+
timeRange: timeRange,
|
|
46
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_reactquery.QueryClientProvider, {
|
|
47
|
+
client: queryClient,
|
|
48
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.PluginRegistry, {
|
|
49
|
+
pluginLoader: _testplugins.testPluginLoader,
|
|
50
|
+
defaultPluginKinds: contextOptions?.defaultPluginKinds ?? {
|
|
51
|
+
TimeSeriesQuery: 'PrometheusTimeSeriesQuery'
|
|
52
|
+
},
|
|
53
|
+
children: children
|
|
54
|
+
})
|
|
46
55
|
})
|
|
47
56
|
});
|
|
48
57
|
};
|