@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.
- package/dist/cjs/components/CalculationSelector/CalculationSelector.js +3 -3
- package/dist/cjs/components/DatasourceEditorForm/DatasourceEditorForm.js +2 -3
- package/dist/cjs/components/LegendOptionsEditor/LegendOptionsEditor.js +4 -5
- 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/VariableEditorForm/VariableEditorForm.js +2 -3
- package/dist/cjs/components/Variables/variable-model.js +115 -29
- package/dist/cjs/context/ValidationProvider.js +3 -3
- package/dist/cjs/model/alerts-queries.js +16 -0
- package/dist/cjs/model/calculations.js +178 -0
- package/dist/cjs/model/index.js +3 -0
- package/dist/cjs/model/legend.js +6 -5
- 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/model/time-series-queries.js +10 -0
- package/dist/cjs/remote/PluginRuntime.js +38 -9
- package/dist/cjs/remote/remotePluginLoader.js +28 -5
- package/dist/cjs/runtime/DataQueriesProvider/DataQueriesProvider.js +18 -2
- package/dist/cjs/runtime/DataQueriesProvider/model.js +30 -4
- package/dist/cjs/runtime/UsageMetricsProvider.js +2 -2
- package/dist/cjs/runtime/alerts-queries.js +101 -0
- package/dist/cjs/runtime/index.js +2 -0
- 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.js +2 -2
- package/dist/cjs/test-utils/mock-plugin-registry.js +8 -2
- package/dist/cjs/utils/index.js +0 -1
- package/dist/components/CalculationSelector/CalculationSelector.d.ts +1 -1
- package/dist/components/CalculationSelector/CalculationSelector.d.ts.map +1 -1
- package/dist/components/CalculationSelector/CalculationSelector.js +2 -2
- package/dist/components/CalculationSelector/CalculationSelector.js.map +1 -1
- package/dist/components/DatasourceEditorForm/DatasourceEditorForm.d.ts +2 -1
- package/dist/components/DatasourceEditorForm/DatasourceEditorForm.d.ts.map +1 -1
- package/dist/components/DatasourceEditorForm/DatasourceEditorForm.js +2 -3
- 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 +1 -1
- 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.d.ts.map +1 -1
- package/dist/components/LegendOptionsEditor/LegendOptionsEditor.js +2 -3
- 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.d.ts +1 -1
- package/dist/components/MultiQueryEditor/MultiQueryEditor.js +1 -1
- package/dist/components/MultiQueryEditor/MultiQueryEditor.js.map +1 -1
- package/dist/components/MultiQueryEditor/QueryEditorContainer.js +1 -1
- package/dist/components/MultiQueryEditor/QueryEditorContainer.js.map +1 -1
- 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.js +1 -1
- 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 +2 -3
- 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/context/ValidationProvider.d.ts +1 -1
- package/dist/context/ValidationProvider.d.ts.map +1 -1
- package/dist/context/ValidationProvider.js +2 -2
- 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/{utils/action.js → model/alerts-queries.js} +2 -14
- package/dist/model/alerts-queries.js.map +1 -0
- package/dist/model/calculations.d.ts +45 -0
- package/dist/model/calculations.d.ts.map +1 -0
- package/dist/model/calculations.js +165 -0
- package/dist/model/calculations.js.map +1 -0
- 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/legend.d.ts +3 -2
- package/dist/model/legend.d.ts.map +1 -1
- package/dist/model/legend.js +2 -1
- package/dist/model/legend.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 +21 -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/time-series-queries.d.ts +11 -1
- package/dist/model/time-series-queries.d.ts.map +1 -1
- package/dist/model/time-series-queries.js +4 -1
- package/dist/model/time-series-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 +38 -9
- 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 +19 -3
- 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 +30 -4
- package/dist/runtime/DataQueriesProvider/model.js.map +1 -1
- package/dist/runtime/QueryCountProvider.js +1 -1
- package/dist/runtime/QueryCountProvider.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/index.d.ts +2 -0
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/runtime/index.js +2 -0
- 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 -1
- 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.d.ts.map +1 -1
- package/dist/test/utils.js +2 -2
- 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/dist/utils/index.d.ts +0 -1
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +0 -1
- package/dist/utils/index.js.map +1 -1
- package/package.json +6 -5
- package/dist/cjs/utils/action.js +0 -43
- package/dist/utils/action.d.ts +0 -4
- package/dist/utils/action.d.ts.map +0 -1
- package/dist/utils/action.js.map +0 -1
|
@@ -10,8 +10,9 @@
|
|
|
10
10
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
11
|
// See the License for the specific language governing permissions and
|
|
12
12
|
// limitations under the License.
|
|
13
|
-
import { useQuery } from '@tanstack/react-query';
|
|
14
|
-
import {
|
|
13
|
+
import { useQueries, useQuery } from '@tanstack/react-query';
|
|
14
|
+
import { useCallback, useMemo, useState } from 'react';
|
|
15
|
+
import { useAllVariableValues, useDatasourceStore, usePlugin, usePlugins, useTimeRange } from '../../runtime';
|
|
15
16
|
export function filterVariableList(data, capturedRegexp) {
|
|
16
17
|
const result = [];
|
|
17
18
|
const filteredSet = new Set();
|
|
@@ -37,54 +38,139 @@ export function filterVariableList(data, capturedRegexp) {
|
|
|
37
38
|
}
|
|
38
39
|
return result;
|
|
39
40
|
}
|
|
40
|
-
|
|
41
|
-
const { data: variablePlugin } = usePlugin('Variable', definition.spec.plugin.kind);
|
|
41
|
+
function useVariablePluginContext() {
|
|
42
42
|
const datasourceStore = useDatasourceStore();
|
|
43
43
|
const allVariables = useAllVariableValues();
|
|
44
44
|
const { absoluteTimeRange: timeRange } = useTimeRange();
|
|
45
|
-
|
|
45
|
+
return {
|
|
46
46
|
timeRange,
|
|
47
47
|
datasourceStore,
|
|
48
48
|
variables: allVariables
|
|
49
49
|
};
|
|
50
|
-
|
|
50
|
+
}
|
|
51
|
+
const getVariableQueryConfig = (definition, variablePluginCtx, variablePlugin, enabled, onFetched)=>{
|
|
51
52
|
const capturingRegexp = definition.spec.capturingRegexp !== undefined ? new RegExp(definition.spec.capturingRegexp, 'g') : undefined;
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
const dependencies = variablePlugin.dependsOn(spec, variablePluginCtx);
|
|
55
|
-
dependsOnVariables = dependencies.variables ? dependencies.variables : dependsOnVariables;
|
|
56
|
-
}
|
|
57
|
-
// Exclude self variable to avoid circular dependency
|
|
58
|
-
dependsOnVariables = dependsOnVariables.filter((v)=>v !== definition.spec.name);
|
|
59
|
-
const variables = useAllVariableValues(dependsOnVariables);
|
|
60
|
-
let waitToLoad = false;
|
|
61
|
-
if (dependsOnVariables) {
|
|
62
|
-
waitToLoad = dependsOnVariables.some((v)=>variables[v]?.loading);
|
|
63
|
-
}
|
|
64
|
-
const variablesValueKey = getVariableValuesKey(variables);
|
|
65
|
-
return useQuery({
|
|
53
|
+
const variablesValueKey = getVariableValuesKey(variablePluginCtx.variables);
|
|
54
|
+
return {
|
|
66
55
|
queryKey: [
|
|
67
56
|
'variable',
|
|
68
57
|
definition,
|
|
69
|
-
timeRange,
|
|
58
|
+
variablePluginCtx.timeRange,
|
|
70
59
|
variablesValueKey
|
|
71
60
|
],
|
|
72
61
|
queryFn: async ({ signal })=>{
|
|
73
|
-
const resp = await variablePlugin?.getVariableOptions(spec,
|
|
74
|
-
datasourceStore,
|
|
75
|
-
variables,
|
|
76
|
-
timeRange
|
|
77
|
-
}, signal);
|
|
62
|
+
const resp = await variablePlugin?.getVariableOptions(definition.spec.plugin.spec, variablePluginCtx, signal);
|
|
78
63
|
if (!resp?.data?.length) {
|
|
64
|
+
onFetched?.(definition.spec.name, [], definition);
|
|
79
65
|
return [];
|
|
80
66
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
return filterVariableList(resp.data, capturingRegexp);
|
|
67
|
+
const options = capturingRegexp ? filterVariableList(resp.data, capturingRegexp) : resp.data;
|
|
68
|
+
onFetched?.(definition.spec.name, options, definition);
|
|
69
|
+
return options;
|
|
85
70
|
},
|
|
86
|
-
enabled
|
|
71
|
+
enabled
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
function resolveDependsOnVariables(variablePlugin, variablePluginCtx, definition) {
|
|
75
|
+
if (variablePlugin?.dependsOn) {
|
|
76
|
+
const dependencies = variablePlugin.dependsOn(definition.spec.plugin.spec, variablePluginCtx);
|
|
77
|
+
return dependencies.variables ? dependencies.variables.filter((v)=>v !== definition.spec.name) : []; // Exclude self variable to avoid circular dependency and default to empty array to avoid deadlock
|
|
78
|
+
}
|
|
79
|
+
return [];
|
|
80
|
+
}
|
|
81
|
+
export function useListVariablePluginValues(definition) {
|
|
82
|
+
const { data: variablePlugin } = usePlugin('Variable', definition.spec.plugin.kind);
|
|
83
|
+
const variablePluginCtx = useVariablePluginContext();
|
|
84
|
+
const dependsOnVariables = resolveDependsOnVariables(variablePlugin, variablePluginCtx, definition);
|
|
85
|
+
const dependentVariables = useAllVariableValues(dependsOnVariables);
|
|
86
|
+
const waitToLoad = dependsOnVariables.some((v)=>dependentVariables[v]?.loading);
|
|
87
|
+
const ctx = {
|
|
88
|
+
...variablePluginCtx,
|
|
89
|
+
variables: dependentVariables
|
|
90
|
+
};
|
|
91
|
+
return useQuery(getVariableQueryConfig(definition, ctx, variablePlugin, !!variablePlugin && !waitToLoad));
|
|
92
|
+
}
|
|
93
|
+
function resolveDefaultValue(definition, options) {
|
|
94
|
+
const { defaultValue, allowMultiple } = definition.spec;
|
|
95
|
+
if (defaultValue !== undefined && defaultValue !== null) {
|
|
96
|
+
return defaultValue;
|
|
97
|
+
}
|
|
98
|
+
if (options[0]?.value) {
|
|
99
|
+
const first = options[0].value;
|
|
100
|
+
return allowMultiple ? [
|
|
101
|
+
first
|
|
102
|
+
] : first;
|
|
103
|
+
}
|
|
104
|
+
return allowMultiple ? [] : '';
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Resolves initial values for all ListVariable definitions by fetching their options in dependency order.
|
|
108
|
+
* Returns a map of variable names to their resolved default values, merging with any already-provided outer variables.
|
|
109
|
+
*/ export function useResolveListVariableValues(variableDefinitions) {
|
|
110
|
+
const { timeRange, datasourceStore, variables: outerVariableValues } = useVariablePluginContext();
|
|
111
|
+
const listVariables = useMemo(()=>variableDefinitions.filter((v)=>v.kind === 'ListVariable'), [
|
|
112
|
+
variableDefinitions
|
|
113
|
+
]);
|
|
114
|
+
const pluginResults = usePlugins('Variable', listVariables.map((d)=>({
|
|
115
|
+
kind: d.spec.plugin.kind
|
|
116
|
+
})));
|
|
117
|
+
// Resolved variable state. Updated by onFetched when queries resolve.
|
|
118
|
+
// Needed because of dependencies between variables that require multiple rounds of fetching.
|
|
119
|
+
const [resolvedVariables, setResolvedVariables] = useState({});
|
|
120
|
+
const allVariables = useMemo(()=>{
|
|
121
|
+
return {
|
|
122
|
+
...outerVariableValues,
|
|
123
|
+
...resolvedVariables
|
|
124
|
+
};
|
|
125
|
+
}, [
|
|
126
|
+
outerVariableValues,
|
|
127
|
+
resolvedVariables
|
|
128
|
+
]);
|
|
129
|
+
const onFetched = useCallback((name, options, definition)=>{
|
|
130
|
+
setResolvedVariables((prev)=>({
|
|
131
|
+
...prev,
|
|
132
|
+
[name]: {
|
|
133
|
+
value: resolveDefaultValue(definition, options),
|
|
134
|
+
loading: false,
|
|
135
|
+
options
|
|
136
|
+
}
|
|
137
|
+
}));
|
|
138
|
+
}, []);
|
|
139
|
+
const queryResults = useQueries({
|
|
140
|
+
queries: listVariables.map((definition, index)=>{
|
|
141
|
+
const plugin = pluginResults[index]?.data;
|
|
142
|
+
const isPluginLoading = pluginResults[index]?.isLoading ?? true;
|
|
143
|
+
const dependsOn = resolveDependsOnVariables(plugin, {
|
|
144
|
+
timeRange,
|
|
145
|
+
datasourceStore,
|
|
146
|
+
variables: allVariables
|
|
147
|
+
}, definition);
|
|
148
|
+
const hasPendingDeps = dependsOn.some((v)=>resolvedVariables[v] === undefined && listVariables.some((lv)=>lv.spec.name === v) || allVariables[v]?.loading);
|
|
149
|
+
const dependentVariables = {};
|
|
150
|
+
for (const v of dependsOn){
|
|
151
|
+
const state = allVariables[v];
|
|
152
|
+
if (state) {
|
|
153
|
+
dependentVariables[v] = state;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
const ctx = {
|
|
157
|
+
timeRange,
|
|
158
|
+
datasourceStore,
|
|
159
|
+
variables: dependentVariables
|
|
160
|
+
};
|
|
161
|
+
return getVariableQueryConfig(definition, ctx, plugin, !hasPendingDeps && !isPluginLoading, onFetched);
|
|
162
|
+
})
|
|
87
163
|
});
|
|
164
|
+
const initialVariableValues = useMemo(()=>Object.fromEntries(Object.entries(allVariables).filter(([, state])=>state?.value !== undefined).map(([name, state])=>[
|
|
165
|
+
name,
|
|
166
|
+
state.value
|
|
167
|
+
])), [
|
|
168
|
+
allVariables
|
|
169
|
+
]);
|
|
170
|
+
return {
|
|
171
|
+
initialVariableValues,
|
|
172
|
+
isLoading: queryResults.some((r)=>r.isLoading)
|
|
173
|
+
};
|
|
88
174
|
}
|
|
89
175
|
/**
|
|
90
176
|
* Returns a serialized string of the current state of variable values.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/Variables/variable-model.ts"],"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 { ListVariableDefinition } from '@perses-dev/spec';\nimport { useQuery, UseQueryResult } from '@tanstack/react-query';\nimport { VariableOption } from '../../model';\nimport { useDatasourceStore, usePlugin, useTimeRange, useAllVariableValues, VariableStateMap } from '../../runtime';\n\nexport function filterVariableList(data: VariableOption[], capturedRegexp: RegExp): VariableOption[] {\n const result: VariableOption[] = [];\n const filteredSet = new Set<string>();\n for (const variableValue of data) {\n const matches = variableValue.value.matchAll(capturedRegexp);\n let concat = '';\n for (const match of matches) {\n for (let i = 1; i < match.length; i++) {\n const m = match[i];\n if (m !== undefined) {\n concat = `${concat}${m}`;\n }\n }\n }\n if (concat !== '' && !filteredSet.has(concat)) {\n // like that we are avoiding to have duplicating variable value\n filteredSet.add(concat);\n result.push({ label: variableValue.label, value: concat });\n }\n }\n return result;\n}\n\nexport function useListVariablePluginValues(definition: ListVariableDefinition): UseQueryResult<VariableOption[]> {\n const { data: variablePlugin } = usePlugin('Variable', definition.spec.plugin.kind);\n const datasourceStore = useDatasourceStore();\n const allVariables = useAllVariableValues();\n const { absoluteTimeRange: timeRange } = useTimeRange();\n\n const variablePluginCtx = { timeRange, datasourceStore, variables: allVariables };\n\n const spec = definition.spec.plugin.spec;\n const capturingRegexp =\n definition.spec.capturingRegexp !== undefined ? new RegExp(definition.spec.capturingRegexp, 'g') : undefined;\n\n let dependsOnVariables: string[] = Object.keys(allVariables); // Default to all variables\n if (variablePlugin?.dependsOn) {\n const dependencies = variablePlugin.dependsOn(spec, variablePluginCtx);\n dependsOnVariables = dependencies.variables ? dependencies.variables : dependsOnVariables;\n }\n // Exclude self variable to avoid circular dependency\n dependsOnVariables = dependsOnVariables.filter((v) => v !== definition.spec.name);\n\n const variables = useAllVariableValues(dependsOnVariables);\n\n let waitToLoad = false;\n if (dependsOnVariables) {\n waitToLoad = dependsOnVariables.some((v) => variables[v]?.loading);\n }\n\n const variablesValueKey = getVariableValuesKey(variables);\n\n return useQuery({\n queryKey: ['variable', definition, timeRange, variablesValueKey],\n queryFn: async ({ signal }) => {\n const resp = await variablePlugin?.getVariableOptions(spec, { datasourceStore, variables, timeRange }, signal);\n if (!resp?.data?.length) {\n return [];\n }\n if (!capturingRegexp) {\n return resp.data;\n }\n return filterVariableList(resp.data, capturingRegexp);\n },\n enabled: !!variablePlugin || waitToLoad,\n });\n}\n\n/**\n * Returns a serialized string of the current state of variable values.\n */\nexport function getVariableValuesKey(v: VariableStateMap): string {\n return Object.values(v)\n .map((v) => JSON.stringify(v.value))\n .join(',');\n}\n\nexport const VARIABLE_TYPES = [\n { label: 'List', kind: 'ListVariable' },\n { label: 'Text', kind: 'TextVariable' },\n] as const;\n"],"names":["useQuery","useDatasourceStore","usePlugin","useTimeRange","useAllVariableValues","filterVariableList","data","capturedRegexp","result","filteredSet","Set","variableValue","matches","value","matchAll","concat","match","i","length","m","undefined","has","add","push","label","useListVariablePluginValues","definition","variablePlugin","spec","plugin","kind","datasourceStore","allVariables","absoluteTimeRange","timeRange","variablePluginCtx","variables","capturingRegexp","RegExp","dependsOnVariables","Object","keys","dependsOn","dependencies","filter","v","name","waitToLoad","some","loading","variablesValueKey","getVariableValuesKey","queryKey","queryFn","signal","resp","getVariableOptions","enabled","values","map","JSON","stringify","join","VARIABLE_TYPES"],"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;AAGjC,SAASA,QAAQ,QAAwB,wBAAwB;AAEjE,SAASC,kBAAkB,EAAEC,SAAS,EAAEC,YAAY,EAAEC,oBAAoB,QAA0B,gBAAgB;AAE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;QACpDI,qBAAqBI,aAAaP,SAAS,GAAGO,aAAaP,SAAS,GAAGG;IACzE;IACA,qDAAqD;IACrDA,qBAAqBA,mBAAmBK,MAAM,CAAC,CAACC,IAAMA,MAAMnB,WAAWE,IAAI,CAACkB,IAAI;IAEhF,MAAMV,YAAYhC,qBAAqBmC;IAEvC,IAAIQ,aAAa;IACjB,IAAIR,oBAAoB;QACtBQ,aAAaR,mBAAmBS,IAAI,CAAC,CAACH,IAAMT,SAAS,CAACS,EAAE,EAAEI;IAC5D;IAEA,MAAMC,oBAAoBC,qBAAqBf;IAE/C,OAAOpC,SAAS;QACdoD,UAAU;YAAC;YAAY1B;YAAYQ;YAAWgB;SAAkB;QAChEG,SAAS,OAAO,EAAEC,MAAM,EAAE;YACxB,MAAMC,OAAO,MAAM5B,gBAAgB6B,mBAAmB5B,MAAM;gBAAEG;gBAAiBK;gBAAWF;YAAU,GAAGoB;YACvG,IAAI,CAACC,MAAMjD,MAAMY,QAAQ;gBACvB,OAAO,EAAE;YACX;YACA,IAAI,CAACmB,iBAAiB;gBACpB,OAAOkB,KAAKjD,IAAI;YAClB;YACA,OAAOD,mBAAmBkD,KAAKjD,IAAI,EAAE+B;QACvC;QACAoB,SAAS,CAAC,CAAC9B,kBAAkBoB;IAC/B;AACF;AAEA;;CAEC,GACD,OAAO,SAASI,qBAAqBN,CAAmB;IACtD,OAAOL,OAAOkB,MAAM,CAACb,GAClBc,GAAG,CAAC,CAACd,IAAMe,KAAKC,SAAS,CAAChB,EAAEhC,KAAK,GACjCiD,IAAI,CAAC;AACV;AAEA,OAAO,MAAMC,iBAAiB;IAC5B;QAAEvC,OAAO;QAAQM,MAAM;IAAe;IACtC;QAAEN,OAAO;QAAQM,MAAM;IAAe;CACvC,CAAU"}
|
|
1
|
+
{"version":3,"sources":["../../../src/components/Variables/variable-model.ts"],"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 { ListVariableDefinition, VariableDefinition, VariableValue } from '@perses-dev/spec';\nimport { useQueries, useQuery, UseQueryOptions, UseQueryResult } from '@tanstack/react-query';\nimport { useCallback, useMemo, useState } from 'react';\nimport { GetVariableOptionsContext, VariableOption, VariablePlugin } from '../../model';\nimport {\n useAllVariableValues,\n useDatasourceStore,\n usePlugin,\n usePlugins,\n useTimeRange,\n VariableStateMap,\n} from '../../runtime';\n\nexport function filterVariableList(data: VariableOption[], capturedRegexp: RegExp): VariableOption[] {\n const result: VariableOption[] = [];\n const filteredSet = new Set<string>();\n for (const variableValue of data) {\n const matches = variableValue.value.matchAll(capturedRegexp);\n let concat = '';\n for (const match of matches) {\n for (let i = 1; i < match.length; i++) {\n const m = match[i];\n if (m !== undefined) {\n concat = `${concat}${m}`;\n }\n }\n }\n if (concat !== '' && !filteredSet.has(concat)) {\n // like that we are avoiding to have duplicating variable value\n filteredSet.add(concat);\n result.push({ label: variableValue.label, value: concat });\n }\n }\n return result;\n}\n\nfunction useVariablePluginContext(): GetVariableOptionsContext {\n const datasourceStore = useDatasourceStore();\n const allVariables = useAllVariableValues();\n const { absoluteTimeRange: timeRange } = useTimeRange();\n\n return { timeRange, datasourceStore, variables: allVariables };\n}\n\nconst getVariableQueryConfig = (\n definition: ListVariableDefinition,\n variablePluginCtx: GetVariableOptionsContext,\n variablePlugin: VariablePlugin | undefined,\n enabled: boolean,\n onFetched?: (name: string, options: VariableOption[], definition: ListVariableDefinition) => void\n): UseQueryOptions<VariableOption[]> => {\n const capturingRegexp =\n definition.spec.capturingRegexp !== undefined ? new RegExp(definition.spec.capturingRegexp, 'g') : undefined;\n const variablesValueKey = getVariableValuesKey(variablePluginCtx.variables);\n return {\n queryKey: ['variable', definition, variablePluginCtx.timeRange, variablesValueKey],\n queryFn: async ({ signal }): Promise<VariableOption[]> => {\n const resp = await variablePlugin?.getVariableOptions(definition.spec.plugin.spec, variablePluginCtx, signal);\n if (!resp?.data?.length) {\n onFetched?.(definition.spec.name, [], definition);\n return [];\n }\n const options = capturingRegexp ? filterVariableList(resp.data, capturingRegexp) : resp.data;\n onFetched?.(definition.spec.name, options, definition);\n return options;\n },\n enabled,\n };\n};\n\nfunction resolveDependsOnVariables(\n variablePlugin: VariablePlugin | undefined,\n variablePluginCtx: GetVariableOptionsContext,\n definition: ListVariableDefinition\n): string[] {\n if (variablePlugin?.dependsOn) {\n const dependencies = variablePlugin.dependsOn(definition.spec.plugin.spec, variablePluginCtx);\n return dependencies.variables ? dependencies.variables.filter((v) => v !== definition.spec.name) : []; // Exclude self variable to avoid circular dependency and default to empty array to avoid deadlock\n }\n return [];\n}\n\nexport function useListVariablePluginValues(definition: ListVariableDefinition): UseQueryResult<VariableOption[]> {\n const { data: variablePlugin } = usePlugin('Variable', definition.spec.plugin.kind);\n\n const variablePluginCtx = useVariablePluginContext();\n\n const dependsOnVariables = resolveDependsOnVariables(variablePlugin, variablePluginCtx, definition);\n\n const dependentVariables = useAllVariableValues(dependsOnVariables);\n const waitToLoad = dependsOnVariables.some((v) => dependentVariables[v]?.loading);\n\n const ctx = { ...variablePluginCtx, variables: dependentVariables };\n\n return useQuery(getVariableQueryConfig(definition, ctx, variablePlugin, !!variablePlugin && !waitToLoad));\n}\n\nfunction resolveDefaultValue(definition: ListVariableDefinition, options: VariableOption[]): VariableValue {\n const { defaultValue, allowMultiple } = definition.spec;\n if (defaultValue !== undefined && defaultValue !== null) {\n return defaultValue;\n }\n if (options[0]?.value) {\n const first = options[0].value;\n return allowMultiple ? [first] : first;\n }\n return allowMultiple ? [] : '';\n}\n\n/**\n * Resolves initial values for all ListVariable definitions by fetching their options in dependency order.\n * Returns a map of variable names to their resolved default values, merging with any already-provided outer variables.\n */\nexport function useResolveListVariableValues(variableDefinitions: VariableDefinition[]): {\n initialVariableValues: Record<string, VariableValue>;\n isLoading: boolean;\n} {\n const { timeRange, datasourceStore, variables: outerVariableValues } = useVariablePluginContext();\n\n const listVariables = useMemo(\n () => variableDefinitions.filter((v): v is ListVariableDefinition => v.kind === 'ListVariable'),\n [variableDefinitions]\n );\n\n const pluginResults = usePlugins(\n 'Variable',\n listVariables.map((d) => ({ kind: d.spec.plugin.kind }))\n );\n\n // Resolved variable state. Updated by onFetched when queries resolve.\n // Needed because of dependencies between variables that require multiple rounds of fetching.\n const [resolvedVariables, setResolvedVariables] = useState<VariableStateMap>({});\n\n const allVariables = useMemo(() => {\n return { ...outerVariableValues, ...resolvedVariables };\n }, [outerVariableValues, resolvedVariables]);\n\n const onFetched = useCallback((name: string, options: VariableOption[], definition: ListVariableDefinition) => {\n setResolvedVariables((prev) => ({\n ...prev,\n [name]: { value: resolveDefaultValue(definition, options), loading: false, options },\n }));\n }, []);\n\n const queryResults = useQueries({\n queries: listVariables.map((definition, index) => {\n const plugin = pluginResults[index]?.data;\n const isPluginLoading = pluginResults[index]?.isLoading ?? true;\n\n const dependsOn = resolveDependsOnVariables(\n plugin,\n { timeRange, datasourceStore, variables: allVariables },\n definition\n );\n\n const hasPendingDeps = dependsOn.some(\n (v) =>\n (resolvedVariables[v] === undefined && listVariables.some((lv) => lv.spec.name === v)) ||\n allVariables[v]?.loading\n );\n\n const dependentVariables: VariableStateMap = {};\n for (const v of dependsOn) {\n const state = allVariables[v];\n if (state) {\n dependentVariables[v] = state;\n }\n }\n\n const ctx = { timeRange, datasourceStore, variables: dependentVariables };\n return getVariableQueryConfig(definition, ctx, plugin, !hasPendingDeps && !isPluginLoading, onFetched);\n }),\n });\n\n const initialVariableValues: Record<string, VariableValue> = useMemo(\n () =>\n Object.fromEntries(\n Object.entries(allVariables)\n .filter(([, state]) => state?.value !== undefined)\n .map(([name, state]) => [name, state!.value])\n ),\n [allVariables]\n );\n\n return { initialVariableValues, isLoading: queryResults.some((r) => r.isLoading) };\n}\n\n/**\n * Returns a serialized string of the current state of variable values.\n */\nexport function getVariableValuesKey(v: VariableStateMap): string {\n return Object.values(v)\n .map((v) => JSON.stringify(v.value))\n .join(',');\n}\n\nexport const VARIABLE_TYPES = [\n { label: 'List', kind: 'ListVariable' },\n { label: 'Text', kind: 'TextVariable' },\n] as const;\n"],"names":["useQueries","useQuery","useCallback","useMemo","useState","useAllVariableValues","useDatasourceStore","usePlugin","usePlugins","useTimeRange","filterVariableList","data","capturedRegexp","result","filteredSet","Set","variableValue","matches","value","matchAll","concat","match","i","length","m","undefined","has","add","push","label","useVariablePluginContext","datasourceStore","allVariables","absoluteTimeRange","timeRange","variables","getVariableQueryConfig","definition","variablePluginCtx","variablePlugin","enabled","onFetched","capturingRegexp","spec","RegExp","variablesValueKey","getVariableValuesKey","queryKey","queryFn","signal","resp","getVariableOptions","plugin","name","options","resolveDependsOnVariables","dependsOn","dependencies","filter","v","useListVariablePluginValues","kind","dependsOnVariables","dependentVariables","waitToLoad","some","loading","ctx","resolveDefaultValue","defaultValue","allowMultiple","first","useResolveListVariableValues","variableDefinitions","outerVariableValues","listVariables","pluginResults","map","d","resolvedVariables","setResolvedVariables","prev","queryResults","queries","index","isPluginLoading","isLoading","hasPendingDeps","lv","state","initialVariableValues","Object","fromEntries","entries","r","values","JSON","stringify","join","VARIABLE_TYPES"],"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;AAGjC,SAASA,UAAU,EAAEC,QAAQ,QAAyC,wBAAwB;AAC9F,SAASC,WAAW,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,QAAQ;AAEvD,SACEC,oBAAoB,EACpBC,kBAAkB,EAClBC,SAAS,EACTC,UAAU,EACVC,YAAY,Q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AK,GACjCgF,IAAI,CAAC;AACV;AAEA,OAAO,MAAMC,iBAAiB;IAC5B;QAAEtE,OAAO;QAAQgC,MAAM;IAAe;IACtC;QAAEhC,OAAO;QAAQgC,MAAM;IAAe;CACvC,CAAU"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ReactElement, ReactNode } from 'react';
|
|
2
2
|
import { PanelEditorValues, VariableDefinition, PluginSchema } from '@perses-dev/spec';
|
|
3
|
-
import { DatasourceDefinition } from '@perses-dev/core';
|
|
4
3
|
import { z } from 'zod';
|
|
4
|
+
import { DatasourceDefinition } from '@perses-dev/client';
|
|
5
5
|
export interface ValidationSchemas {
|
|
6
6
|
datasourceEditorSchema: z.Schema<DatasourceDefinition>;
|
|
7
7
|
panelEditorSchema: z.Schema<PanelEditorValues>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ValidationProvider.d.ts","sourceRoot":"","sources":["../../src/context/ValidationProvider.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAiB,YAAY,EAAE,SAAS,EAAwB,MAAM,OAAO,CAAC;AACrF,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAClB,YAAY,EAKb,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"ValidationProvider.d.ts","sourceRoot":"","sources":["../../src/context/ValidationProvider.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAiB,YAAY,EAAE,SAAS,EAAwB,MAAM,OAAO,CAAC;AACrF,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAClB,YAAY,EAKb,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAmC,oBAAoB,EAA8B,MAAM,oBAAoB,CAAC;AAEvH,MAAM,WAAW,iBAAiB;IAChC,sBAAsB,EAAE,CAAC,CAAC,MAAM,CAAC,oBAAoB,CAAC,CAAC;IACvD,iBAAiB,EAAE,CAAC,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAC;IAC/C,oBAAoB,EAAE,CAAC,CAAC,MAAM,CAAC,kBAAkB,CAAC,CAAC;IACnD,+BAA+B,EAAE,CAAC,YAAY,EAAE,YAAY,KAAK,IAAI,CAAC;IACtE,0BAA0B,EAAE,CAAC,YAAY,EAAE,YAAY,KAAK,IAAI,CAAC;IACjE,6BAA6B,EAAE,CAAC,YAAY,EAAE,YAAY,KAAK,IAAI,CAAC;CACrE;AAED,eAAO,MAAM,wBAAwB,wDAA0D,CAAC;AAEhG,wBAAgB,oBAAoB,IAAI,iBAAiB,CAMxD;AAED,UAAU,uBAAuB;IAC/B,QAAQ,EAAE,SAAS,CAAC;CACrB;AAKD,wBAAgB,kBAAkB,CAAC,EAAE,QAAQ,EAAE,EAAE,uBAAuB,GAAG,YAAY,CAiCtF"}
|
|
@@ -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,10 +11,9 @@
|
|
|
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 { createContext, useContext, useState } from 'react';
|
|
15
15
|
import { panelEditorSchema as defaultPanelEditorSchema, variableDefinitionSchema, buildPanelEditorSchema, buildVariableDefinitionSchema } from '@perses-dev/spec';
|
|
16
|
-
import {
|
|
16
|
+
import { buildDatasourceDefinitionSchema, datasourceDefinitionSchema } from '@perses-dev/client';
|
|
17
17
|
export const ValidationSchemasContext = /*#__PURE__*/ createContext(undefined);
|
|
18
18
|
export function useValidationSchemas() {
|
|
19
19
|
const ctx = useContext(ValidationSchemasContext);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/context/ValidationProvider.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 { createContext, ReactElement, ReactNode, useContext, useState } from 'react';\nimport {\n PanelEditorValues,\n VariableDefinition,\n PluginSchema,\n panelEditorSchema as defaultPanelEditorSchema,\n variableDefinitionSchema,\n buildPanelEditorSchema,\n buildVariableDefinitionSchema,\n} from '@perses-dev/spec';\nimport {
|
|
1
|
+
{"version":3,"sources":["../../src/context/ValidationProvider.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 { createContext, ReactElement, ReactNode, useContext, useState } from 'react';\nimport {\n PanelEditorValues,\n VariableDefinition,\n PluginSchema,\n panelEditorSchema as defaultPanelEditorSchema,\n variableDefinitionSchema,\n buildPanelEditorSchema,\n buildVariableDefinitionSchema,\n} from '@perses-dev/spec';\n\nimport { z } from 'zod';\nimport { buildDatasourceDefinitionSchema, DatasourceDefinition, datasourceDefinitionSchema } from '@perses-dev/client';\n\nexport interface ValidationSchemas {\n datasourceEditorSchema: z.Schema<DatasourceDefinition>;\n panelEditorSchema: z.Schema<PanelEditorValues>;\n variableEditorSchema: z.Schema<VariableDefinition>;\n setDatasourceEditorSchemaPlugin: (pluginSchema: PluginSchema) => void;\n setPanelEditorSchemaPlugin: (pluginSchema: PluginSchema) => void;\n setVariableEditorSchemaPlugin: (pluginSchema: PluginSchema) => void;\n}\n\nexport const ValidationSchemasContext = createContext<ValidationSchemas | undefined>(undefined);\n\nexport function useValidationSchemas(): ValidationSchemas {\n const ctx = useContext(ValidationSchemasContext);\n if (ctx === undefined) {\n throw new Error('No ValidationSchemasContext found. Did you forget a Provider?');\n }\n return ctx;\n}\n\ninterface ValidationProviderProps {\n children: ReactNode;\n}\n\n/*\n * Provide validation schemas for forms handling plugins (datasources, variables, panels).\n */\nexport function ValidationProvider({ children }: ValidationProviderProps): ReactElement {\n const [datasourceEditorSchema, setDatasourceEditorSchema] =\n useState<z.Schema<DatasourceDefinition>>(datasourceDefinitionSchema);\n const [panelEditorSchema, setPanelEditorSchema] = useState<z.Schema<PanelEditorValues>>(defaultPanelEditorSchema); // TODO I don't get why this does not compile\n const [variableEditorSchema, setVariableEditorSchema] =\n useState<z.Schema<VariableDefinition>>(variableDefinitionSchema);\n\n function setDatasourceEditorSchemaPlugin(pluginSchema: PluginSchema): void {\n setDatasourceEditorSchema(buildDatasourceDefinitionSchema(pluginSchema));\n }\n\n function setPanelEditorSchemaPlugin(pluginSchema: PluginSchema): void {\n setPanelEditorSchema(buildPanelEditorSchema(pluginSchema));\n }\n\n function setVariableEditorSchemaPlugin(pluginSchema: PluginSchema): void {\n setVariableEditorSchema(buildVariableDefinitionSchema(pluginSchema));\n }\n\n return (\n <ValidationSchemasContext.Provider\n value={{\n datasourceEditorSchema,\n panelEditorSchema,\n variableEditorSchema,\n setDatasourceEditorSchemaPlugin,\n setPanelEditorSchemaPlugin,\n setVariableEditorSchemaPlugin,\n }}\n >\n {children}\n </ValidationSchemasContext.Provider>\n );\n}\n"],"names":["createContext","useContext","useState","panelEditorSchema","defaultPanelEditorSchema","variableDefinitionSchema","buildPanelEditorSchema","buildVariableDefinitionSchema","buildDatasourceDefinitionSchema","datasourceDefinitionSchema","ValidationSchemasContext","undefined","useValidationSchemas","ctx","Error","ValidationProvider","children","datasourceEditorSchema","setDatasourceEditorSchema","setPanelEditorSchema","variableEditorSchema","setVariableEditorSchema","setDatasourceEditorSchemaPlugin","pluginSchema","setPanelEditorSchemaPlugin","setVariableEditorSchemaPlugin","Provider","value"],"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,aAAa,EAA2BC,UAAU,EAAEC,QAAQ,QAAQ,QAAQ;AACrF,SAIEC,qBAAqBC,wBAAwB,EAC7CC,wBAAwB,EACxBC,sBAAsB,EACtBC,6BAA6B,QACxB,mBAAmB;AAG1B,SAASC,+BAA+B,EAAwBC,0BAA0B,QAAQ,qBAAqB;AAWvH,OAAO,MAAMC,yCAA2BV,cAA6CW,WAAW;AAEhG,OAAO,SAASC;IACd,MAAMC,MAAMZ,WAAWS;IACvB,IAAIG,QAAQF,WAAW;QACrB,MAAM,IAAIG,MAAM;IAClB;IACA,OAAOD;AACT;AAMA;;CAEC,GACD,OAAO,SAASE,mBAAmB,EAAEC,QAAQ,EAA2B;IACtE,MAAM,CAACC,wBAAwBC,0BAA0B,GACvDhB,SAAyCO;IAC3C,MAAM,CAACN,mBAAmBgB,qBAAqB,GAAGjB,SAAsCE,2BAA2B,6CAA6C;IAChK,MAAM,CAACgB,sBAAsBC,wBAAwB,GACnDnB,SAAuCG;IAEzC,SAASiB,gCAAgCC,YAA0B;QACjEL,0BAA0BV,gCAAgCe;IAC5D;IAEA,SAASC,2BAA2BD,YAA0B;QAC5DJ,qBAAqBb,uBAAuBiB;IAC9C;IAEA,SAASE,8BAA8BF,YAA0B;QAC/DF,wBAAwBd,8BAA8BgB;IACxD;IAEA,qBACE,KAACb,yBAAyBgB,QAAQ;QAChCC,OAAO;YACLV;YACAd;YACAiB;YACAE;YACAE;YACAC;QACF;kBAECT;;AAGP"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Query, QueryKey } from '@tanstack/react-query';
|
|
2
|
+
import { AlertsData, UnknownSpec } from '@perses-dev/spec';
|
|
3
|
+
import { DatasourceStore, VariableStateMap } from '../runtime';
|
|
4
|
+
import { Plugin } from './plugin-base';
|
|
5
|
+
/**
|
|
6
|
+
* An object containing all the dependencies of an AlertsQuery.
|
|
7
|
+
*/
|
|
8
|
+
type AlertsQueryPluginDependencies = {
|
|
9
|
+
/**
|
|
10
|
+
* Returns a list of variables name this alerts query depends on.
|
|
11
|
+
*/
|
|
12
|
+
variables?: string[];
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* A plugin for running alerts queries.
|
|
16
|
+
* Alerts represent current state, not historical data, so the context
|
|
17
|
+
* does NOT include absoluteTimeRange.
|
|
18
|
+
*/
|
|
19
|
+
export interface AlertsQueryPlugin<Spec = UnknownSpec> extends Plugin<Spec> {
|
|
20
|
+
getAlertsData: (spec: Spec, ctx: AlertsQueryContext, abortSignal?: AbortSignal) => Promise<AlertsData>;
|
|
21
|
+
dependsOn?: (spec: Spec, ctx: AlertsQueryContext) => AlertsQueryPluginDependencies;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Context available to AlertsQuery plugins at runtime.
|
|
25
|
+
* Note: No absoluteTimeRange since alerts represent current state.
|
|
26
|
+
*/
|
|
27
|
+
export interface AlertsQueryContext {
|
|
28
|
+
datasourceStore: DatasourceStore;
|
|
29
|
+
variableState: VariableStateMap;
|
|
30
|
+
}
|
|
31
|
+
export type AlertsDataQuery = Query<AlertsData, unknown, AlertsData, QueryKey>;
|
|
32
|
+
export {};
|
|
33
|
+
//# sourceMappingURL=alerts-queries.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"alerts-queries.d.ts","sourceRoot":"","sources":["../../src/model/alerts-queries.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC/D,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAEvC;;GAEG;AACH,KAAK,6BAA6B,GAAG;IACnC;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;CACtB,CAAC;AAEF;;;;GAIG;AACH,MAAM,WAAW,iBAAiB,CAAC,IAAI,GAAG,WAAW,CAAE,SAAQ,MAAM,CAAC,IAAI,CAAC;IACzE,aAAa,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,kBAAkB,EAAE,WAAW,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,UAAU,CAAC,CAAC;IACvG,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,kBAAkB,KAAK,6BAA6B,CAAC;CACpF;AAED;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IACjC,eAAe,EAAE,eAAe,CAAC;IACjC,aAAa,EAAE,gBAAgB,CAAC;CACjC;AAED,MAAM,MAAM,eAAe,GAAG,KAAK,CAAC,UAAU,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAC"}
|
|
@@ -10,18 +10,6 @@
|
|
|
10
10
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
11
|
// See the License for the specific language governing permissions and
|
|
12
12
|
// limitations under the License.
|
|
13
|
-
export
|
|
14
|
-
if (action === 'read') return 'View';
|
|
15
|
-
if (isDraft && action === 'create') return 'Add';
|
|
16
|
-
if (!isDraft && action === 'create') return 'Create';
|
|
17
|
-
if (action === 'update') return 'Edit';
|
|
18
|
-
return '';
|
|
19
|
-
}
|
|
20
|
-
export function getSubmitText(action, isDraft) {
|
|
21
|
-
if (isDraft && action === 'create') return 'Add';
|
|
22
|
-
if (isDraft && action === 'update') return 'Apply';
|
|
23
|
-
if (!isDraft) return 'Save';
|
|
24
|
-
return '';
|
|
25
|
-
}
|
|
13
|
+
export { };
|
|
26
14
|
|
|
27
|
-
//# sourceMappingURL=
|
|
15
|
+
//# sourceMappingURL=alerts-queries.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/model/alerts-queries.ts"],"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 { Query, QueryKey } from '@tanstack/react-query';\nimport { AlertsData, UnknownSpec } from '@perses-dev/spec';\nimport { DatasourceStore, VariableStateMap } from '../runtime';\nimport { Plugin } from './plugin-base';\n\n/**\n * An object containing all the dependencies of an AlertsQuery.\n */\ntype AlertsQueryPluginDependencies = {\n /**\n * Returns a list of variables name this alerts query depends on.\n */\n variables?: string[];\n};\n\n/**\n * A plugin for running alerts queries.\n * Alerts represent current state, not historical data, so the context\n * does NOT include absoluteTimeRange.\n */\nexport interface AlertsQueryPlugin<Spec = UnknownSpec> extends Plugin<Spec> {\n getAlertsData: (spec: Spec, ctx: AlertsQueryContext, abortSignal?: AbortSignal) => Promise<AlertsData>;\n dependsOn?: (spec: Spec, ctx: AlertsQueryContext) => AlertsQueryPluginDependencies;\n}\n\n/**\n * Context available to AlertsQuery plugins at runtime.\n * Note: No absoluteTimeRange since alerts represent current state.\n */\nexport interface AlertsQueryContext {\n datasourceStore: DatasourceStore;\n variableState: VariableStateMap;\n}\n\nexport type AlertsDataQuery = Query<AlertsData, unknown, AlertsData, QueryKey>;\n"],"names":[],"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;AAoCjC,WAA+E"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { TimeSeriesValueTuple } from './time-series-queries';
|
|
2
|
+
export declare const DEFAULT_CALCULATION: CalculationType;
|
|
3
|
+
export declare const CalculationsMap: {
|
|
4
|
+
first: typeof first;
|
|
5
|
+
last: typeof last;
|
|
6
|
+
'first-number': typeof firstNumber;
|
|
7
|
+
'last-number': typeof lastNumber;
|
|
8
|
+
mean: typeof mean;
|
|
9
|
+
sum: typeof sum;
|
|
10
|
+
min: typeof min;
|
|
11
|
+
max: typeof max;
|
|
12
|
+
};
|
|
13
|
+
export type CalculationType = keyof typeof CalculationsMap;
|
|
14
|
+
export type CalculationConfig = {
|
|
15
|
+
label: string;
|
|
16
|
+
description: string;
|
|
17
|
+
};
|
|
18
|
+
export declare const CALCULATIONS_CONFIG: Readonly<Record<CalculationType, CalculationConfig>>;
|
|
19
|
+
type CalculationValue = number | null | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* Calculate a multiple values for a set of time series data.
|
|
22
|
+
*
|
|
23
|
+
* @param values - Array of time series data.
|
|
24
|
+
* @param includeCalculations - Array of calculations to include.
|
|
25
|
+
*/
|
|
26
|
+
export declare function getCalculations<IncludeCalcs extends CalculationType[]>(values: TimeSeriesValueTuple[], includeCalculations: IncludeCalcs): Record<Extract<CalculationType, IncludeCalcs[number]>, CalculationValue>;
|
|
27
|
+
/**
|
|
28
|
+
* Calculate a single value for a set of time series data.
|
|
29
|
+
*
|
|
30
|
+
* Use `getCalculations` instead if you need multiple calculations.
|
|
31
|
+
*
|
|
32
|
+
* @param values - Array of time series data.
|
|
33
|
+
* @param calculation - Name of the calculation to calculate.
|
|
34
|
+
*/
|
|
35
|
+
export declare function getCalculation(values: TimeSeriesValueTuple[], calculation: CalculationType): CalculationValue;
|
|
36
|
+
declare function first(values: TimeSeriesValueTuple[]): CalculationValue;
|
|
37
|
+
declare function last(values: TimeSeriesValueTuple[]): CalculationValue;
|
|
38
|
+
declare function firstNumber(values: TimeSeriesValueTuple[]): CalculationValue;
|
|
39
|
+
declare function lastNumber(values: TimeSeriesValueTuple[]): CalculationValue;
|
|
40
|
+
declare function mean(values: TimeSeriesValueTuple[]): CalculationValue;
|
|
41
|
+
declare function sum(values: TimeSeriesValueTuple[]): CalculationValue;
|
|
42
|
+
declare function min(values: TimeSeriesValueTuple[]): CalculationValue;
|
|
43
|
+
declare function max(values: TimeSeriesValueTuple[]): CalculationValue;
|
|
44
|
+
export {};
|
|
45
|
+
//# sourceMappingURL=calculations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"calculations.d.ts","sourceRoot":"","sources":["../../src/model/calculations.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAE7D,eAAO,MAAM,mBAAmB,EAAE,eAAwB,CAAC;AAE3D,eAAO,MAAM,eAAe;;;;;;;;;CAS3B,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG,MAAM,OAAO,eAAe,CAAC;AAE3D,MAAM,MAAM,iBAAiB,GAAG;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,QAAQ,CAAC,MAAM,CAAC,eAAe,EAAE,iBAAiB,CAAC,CAiC3E,CAAC;AAEX,KAAK,gBAAgB,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;AAElD;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,YAAY,SAAS,eAAe,EAAE,EACpE,MAAM,EAAE,oBAAoB,EAAE,EAC9B,mBAAmB,EAAE,YAAY,GAChC,MAAM,CAGP,OAAO,CAAC,eAAe,EAAE,YAAY,CAAC,MAAM,CAAC,CAAC,EAC9C,gBAAgB,CACjB,CA8EA;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,oBAAoB,EAAE,EAAE,WAAW,EAAE,eAAe,GAAG,gBAAgB,CAE7G;AAED,iBAAS,KAAK,CAAC,MAAM,EAAE,oBAAoB,EAAE,GAAG,gBAAgB,CAE/D;AAED,iBAAS,IAAI,CAAC,MAAM,EAAE,oBAAoB,EAAE,GAAG,gBAAgB,CAE9D;AAED,iBAAS,WAAW,CAAC,MAAM,EAAE,oBAAoB,EAAE,GAAG,gBAAgB,CAErE;AAED,iBAAS,UAAU,CAAC,MAAM,EAAE,oBAAoB,EAAE,GAAG,gBAAgB,CAEpE;AAED,iBAAS,IAAI,CAAC,MAAM,EAAE,oBAAoB,EAAE,GAAG,gBAAgB,CAE9D;AAED,iBAAS,GAAG,CAAC,MAAM,EAAE,oBAAoB,EAAE,GAAG,gBAAgB,CAE7D;AAED,iBAAS,GAAG,CAAC,MAAM,EAAE,oBAAoB,EAAE,GAAG,gBAAgB,CAE7D;AAED,iBAAS,GAAG,CAAC,MAAM,EAAE,oBAAoB,EAAE,GAAG,gBAAgB,CAE7D"}
|
|
@@ -0,0 +1,165 @@
|
|
|
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
|
+
export const DEFAULT_CALCULATION = 'last'; // aligned with cue
|
|
14
|
+
export const CalculationsMap = {
|
|
15
|
+
first: first,
|
|
16
|
+
last: last,
|
|
17
|
+
'first-number': firstNumber,
|
|
18
|
+
'last-number': lastNumber,
|
|
19
|
+
mean: mean,
|
|
20
|
+
sum: sum,
|
|
21
|
+
min: min,
|
|
22
|
+
max: max
|
|
23
|
+
};
|
|
24
|
+
export const CALCULATIONS_CONFIG = {
|
|
25
|
+
first: {
|
|
26
|
+
label: 'First',
|
|
27
|
+
description: 'First value'
|
|
28
|
+
},
|
|
29
|
+
last: {
|
|
30
|
+
label: 'Last',
|
|
31
|
+
description: 'Last value'
|
|
32
|
+
},
|
|
33
|
+
'first-number': {
|
|
34
|
+
label: 'First *',
|
|
35
|
+
description: 'First numeric value'
|
|
36
|
+
},
|
|
37
|
+
'last-number': {
|
|
38
|
+
label: 'Last *',
|
|
39
|
+
description: 'Last numeric value'
|
|
40
|
+
},
|
|
41
|
+
mean: {
|
|
42
|
+
label: 'Avg',
|
|
43
|
+
description: 'Average value excluding nulls'
|
|
44
|
+
},
|
|
45
|
+
sum: {
|
|
46
|
+
label: 'Sum',
|
|
47
|
+
description: 'The sum of all values'
|
|
48
|
+
},
|
|
49
|
+
min: {
|
|
50
|
+
label: 'Min',
|
|
51
|
+
description: 'Minimum value'
|
|
52
|
+
},
|
|
53
|
+
max: {
|
|
54
|
+
label: 'Max',
|
|
55
|
+
description: 'Maximum value'
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* Calculate a multiple values for a set of time series data.
|
|
60
|
+
*
|
|
61
|
+
* @param values - Array of time series data.
|
|
62
|
+
* @param includeCalculations - Array of calculations to include.
|
|
63
|
+
*/ export function getCalculations(values, includeCalculations) {
|
|
64
|
+
const calculations = includeCalculations.reduce((initResult, calculation)=>{
|
|
65
|
+
initResult[calculation] = undefined;
|
|
66
|
+
return initResult;
|
|
67
|
+
}, {});
|
|
68
|
+
// We save these values as separate values instead of directly setting them
|
|
69
|
+
// in the calculations because they are needed by multiple calculations.
|
|
70
|
+
let nonNullCount = 0;
|
|
71
|
+
let sum = 0;
|
|
72
|
+
// We use this large function capable of performing one or more calculations
|
|
73
|
+
// in a single iteration of the data to minimize the performance impact of
|
|
74
|
+
// generating multiple calculations for large timeseries values. This is
|
|
75
|
+
// less optimized for certain single calculations when done in isolation (e.g.
|
|
76
|
+
// `last`), but will be more performant in the more expensive cases where
|
|
77
|
+
// multiple values are being used (e.g. table legend).
|
|
78
|
+
values.forEach((tuple, i)=>{
|
|
79
|
+
const value = tuple[1];
|
|
80
|
+
if (i === 0 && 'first' in calculations) {
|
|
81
|
+
calculations.first = value;
|
|
82
|
+
}
|
|
83
|
+
if (i === values.length - 1 && 'last' in calculations) {
|
|
84
|
+
calculations.last = value;
|
|
85
|
+
}
|
|
86
|
+
// Handling specific to non-null values.
|
|
87
|
+
if (typeof value === 'number') {
|
|
88
|
+
nonNullCount += 1;
|
|
89
|
+
sum += value;
|
|
90
|
+
if ('first-number' in calculations && calculations['first-number'] === undefined) {
|
|
91
|
+
// Save the first number we see.
|
|
92
|
+
calculations['first-number'] = value;
|
|
93
|
+
}
|
|
94
|
+
if ('last-number' in calculations) {
|
|
95
|
+
// Keep setting the numbers we see, which will eventually be set to the
|
|
96
|
+
// last number when finished iterating.
|
|
97
|
+
calculations['last-number'] = value;
|
|
98
|
+
}
|
|
99
|
+
if ('min' in calculations) {
|
|
100
|
+
if (typeof calculations.min !== 'number') {
|
|
101
|
+
// Init the first time we see a number
|
|
102
|
+
calculations.min = value;
|
|
103
|
+
} else {
|
|
104
|
+
// Use lowest value once initialized
|
|
105
|
+
calculations.min = Math.min(calculations.min, value);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
if ('max' in calculations) {
|
|
109
|
+
if (typeof calculations.max !== 'number') {
|
|
110
|
+
// Init the first time we see a number
|
|
111
|
+
calculations.max = value;
|
|
112
|
+
} else {
|
|
113
|
+
// Use highest value once initialized
|
|
114
|
+
calculations.max = Math.max(calculations.max, value);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
// Set calculations that require iterating over all values.
|
|
120
|
+
if (nonNullCount > 0 && 'sum' in calculations) {
|
|
121
|
+
calculations.sum = sum;
|
|
122
|
+
}
|
|
123
|
+
if (nonNullCount > 0 && 'mean' in calculations) {
|
|
124
|
+
calculations.mean = sum / nonNullCount;
|
|
125
|
+
}
|
|
126
|
+
return calculations;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Calculate a single value for a set of time series data.
|
|
130
|
+
*
|
|
131
|
+
* Use `getCalculations` instead if you need multiple calculations.
|
|
132
|
+
*
|
|
133
|
+
* @param values - Array of time series data.
|
|
134
|
+
* @param calculation - Name of the calculation to calculate.
|
|
135
|
+
*/ export function getCalculation(values, calculation) {
|
|
136
|
+
return getCalculations(values, [
|
|
137
|
+
calculation
|
|
138
|
+
])[calculation];
|
|
139
|
+
}
|
|
140
|
+
function first(values) {
|
|
141
|
+
return getCalculation(values, 'first');
|
|
142
|
+
}
|
|
143
|
+
function last(values) {
|
|
144
|
+
return getCalculation(values, 'last');
|
|
145
|
+
}
|
|
146
|
+
function firstNumber(values) {
|
|
147
|
+
return getCalculation(values, 'first-number');
|
|
148
|
+
}
|
|
149
|
+
function lastNumber(values) {
|
|
150
|
+
return getCalculation(values, 'last-number');
|
|
151
|
+
}
|
|
152
|
+
function mean(values) {
|
|
153
|
+
return getCalculation(values, 'mean');
|
|
154
|
+
}
|
|
155
|
+
function sum(values) {
|
|
156
|
+
return getCalculation(values, 'sum');
|
|
157
|
+
}
|
|
158
|
+
function min(values) {
|
|
159
|
+
return getCalculation(values, 'min');
|
|
160
|
+
}
|
|
161
|
+
function max(values) {
|
|
162
|
+
return getCalculation(values, 'max');
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
//# sourceMappingURL=calculations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/model/calculations.ts"],"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 { TimeSeriesValueTuple } from './time-series-queries';\n\nexport const DEFAULT_CALCULATION: CalculationType = 'last'; // aligned with cue\n\nexport const CalculationsMap = {\n first: first,\n last: last,\n 'first-number': firstNumber,\n 'last-number': lastNumber,\n mean: mean,\n sum: sum,\n min: min,\n max: max,\n};\n\nexport type CalculationType = keyof typeof CalculationsMap;\n\nexport type CalculationConfig = {\n label: string;\n description: string;\n};\n\nexport const CALCULATIONS_CONFIG: Readonly<Record<CalculationType, CalculationConfig>> = {\n first: {\n label: 'First',\n description: 'First value',\n },\n last: {\n label: 'Last',\n description: 'Last value',\n },\n 'first-number': {\n label: 'First *',\n description: 'First numeric value',\n },\n 'last-number': {\n label: 'Last *',\n description: 'Last numeric value',\n },\n mean: {\n label: 'Avg',\n description: 'Average value excluding nulls',\n },\n sum: {\n label: 'Sum',\n description: 'The sum of all values',\n },\n min: {\n label: 'Min',\n description: 'Minimum value',\n },\n max: {\n label: 'Max',\n description: 'Maximum value',\n },\n} as const;\n\ntype CalculationValue = number | null | undefined;\n\n/**\n * Calculate a multiple values for a set of time series data.\n *\n * @param values - Array of time series data.\n * @param includeCalculations - Array of calculations to include.\n */\nexport function getCalculations<IncludeCalcs extends CalculationType[]>(\n values: TimeSeriesValueTuple[],\n includeCalculations: IncludeCalcs\n): Record<\n // This extract combined with the generics above keeps the key of the returned\n // record to *just* the specified calculations.\n Extract<CalculationType, IncludeCalcs[number]>,\n CalculationValue\n> {\n const calculations = includeCalculations.reduce(\n (initResult, calculation) => {\n initResult[calculation] = undefined;\n return initResult;\n },\n {} as Record<string, CalculationValue>\n );\n\n // We save these values as separate values instead of directly setting them\n // in the calculations because they are needed by multiple calculations.\n let nonNullCount = 0;\n let sum = 0;\n\n // We use this large function capable of performing one or more calculations\n // in a single iteration of the data to minimize the performance impact of\n // generating multiple calculations for large timeseries values. This is\n // less optimized for certain single calculations when done in isolation (e.g.\n // `last`), but will be more performant in the more expensive cases where\n // multiple values are being used (e.g. table legend).\n values.forEach((tuple, i) => {\n const value = tuple[1];\n\n if (i === 0 && 'first' in calculations) {\n calculations.first = value;\n }\n if (i === values.length - 1 && 'last' in calculations) {\n calculations.last = value;\n }\n\n // Handling specific to non-null values.\n if (typeof value === 'number') {\n nonNullCount += 1;\n sum += value;\n\n if ('first-number' in calculations && calculations['first-number'] === undefined) {\n // Save the first number we see.\n calculations['first-number'] = value;\n }\n\n if ('last-number' in calculations) {\n // Keep setting the numbers we see, which will eventually be set to the\n // last number when finished iterating.\n calculations['last-number'] = value;\n }\n\n if ('min' in calculations) {\n if (typeof calculations.min !== 'number') {\n // Init the first time we see a number\n calculations.min = value;\n } else {\n // Use lowest value once initialized\n calculations.min = Math.min(calculations.min, value);\n }\n }\n\n if ('max' in calculations) {\n if (typeof calculations.max !== 'number') {\n // Init the first time we see a number\n calculations.max = value;\n } else {\n // Use highest value once initialized\n calculations.max = Math.max(calculations.max, value);\n }\n }\n }\n });\n\n // Set calculations that require iterating over all values.\n if (nonNullCount > 0 && 'sum' in calculations) {\n calculations.sum = sum;\n }\n\n if (nonNullCount > 0 && 'mean' in calculations) {\n calculations.mean = sum / nonNullCount;\n }\n\n return calculations;\n}\n\n/**\n * Calculate a single value for a set of time series data.\n *\n * Use `getCalculations` instead if you need multiple calculations.\n *\n * @param values - Array of time series data.\n * @param calculation - Name of the calculation to calculate.\n */\nexport function getCalculation(values: TimeSeriesValueTuple[], calculation: CalculationType): CalculationValue {\n return getCalculations(values, [calculation])[calculation];\n}\n\nfunction first(values: TimeSeriesValueTuple[]): CalculationValue {\n return getCalculation(values, 'first');\n}\n\nfunction last(values: TimeSeriesValueTuple[]): CalculationValue {\n return getCalculation(values, 'last');\n}\n\nfunction firstNumber(values: TimeSeriesValueTuple[]): CalculationValue {\n return getCalculation(values, 'first-number');\n}\n\nfunction lastNumber(values: TimeSeriesValueTuple[]): CalculationValue {\n return getCalculation(values, 'last-number');\n}\n\nfunction mean(values: TimeSeriesValueTuple[]): CalculationValue {\n return getCalculation(values, 'mean');\n}\n\nfunction sum(values: TimeSeriesValueTuple[]): CalculationValue {\n return getCalculation(values, 'sum');\n}\n\nfunction min(values: TimeSeriesValueTuple[]): CalculationValue {\n return getCalculation(values, 'min');\n}\n\nfunction max(values: TimeSeriesValueTuple[]): CalculationValue {\n return getCalculation(values, 'max');\n}\n"],"names":["DEFAULT_CALCULATION","CalculationsMap","first","last","firstNumber","lastNumber","mean","sum","min","max","CALCULATIONS_CONFIG","label","description","getCalculations","values","includeCalculations","calculations","reduce","initResult","calculation","undefined","nonNullCount","forEach","tuple","i","value","length","Math","getCalculation"],"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;AAIjC,OAAO,MAAMA,sBAAuC,OAAO,CAAC,mBAAmB;AAE/E,OAAO,MAAMC,kBAAkB;IAC7BC,OAAOA;IACPC,MAAMA;IACN,gBAAgBC;IAChB,eAAeC;IACfC,MAAMA;IACNC,KAAKA;IACLC,KAAKA;IACLC,KAAKA;AACP,EAAE;AASF,OAAO,MAAMC,sBAA4E;IACvFR,OAAO;QACLS,OAAO;QACPC,aAAa;IACf;IACAT,MAAM;QACJQ,OAAO;QACPC,aAAa;IACf;IACA,gBAAgB;QACdD,OAAO;QACPC,aAAa;IACf;IACA,eAAe;QACbD,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,aAAaR,GAAG,GAAGmB,KAAKnB,GAAG,CAACQ,aAAaR,GAAG,EAAEiB;gBAChD;YACF;YAEA,IAAI,SAAST,cAAc;gBACzB,IAAI,OAAOA,aAAaP,GAAG,KAAK,UAAU;oBACxC,sCAAsC;oBACtCO,aAAaP,GAAG,GAAGgB;gBACrB,OAAO;oBACL,qCAAqC;oBACrCT,aAAaP,GAAG,GAAGkB,KAAKlB,GAAG,CAACO,aAAaP,GAAG,EAAEgB;gBAChD;YACF;QACF;IACF;IAEA,2DAA2D;IAC3D,IAAIJ,eAAe,KAAK,SAASL,cAAc;QAC7CA,aAAaT,GAAG,GAAGA;IACrB;IAEA,IAAIc,eAAe,KAAK,UAAUL,cAAc;QAC9CA,aAAaV,IAAI,GAAGC,MAAMc;IAC5B;IAEA,OAAOL;AACT;AAEA;;;;;;;CAOC,GACD,OAAO,SAASY,eAAed,MAA8B,EAAEK,WAA4B;IACzF,OAAON,gBAAgBC,QAAQ;QAACK;KAAY,CAAC,CAACA,YAAY;AAC5D;AAEA,SAASjB,MAAMY,MAA8B;IAC3C,OAAOc,eAAed,QAAQ;AAChC;AAEA,SAASX,KAAKW,MAA8B;IAC1C,OAAOc,eAAed,QAAQ;AAChC;AAEA,SAASV,YAAYU,MAA8B;IACjD,OAAOc,eAAed,QAAQ;AAChC;AAEA,SAAST,WAAWS,MAA8B;IAChD,OAAOc,eAAed,QAAQ;AAChC;AAEA,SAASR,KAAKQ,MAA8B;IAC1C,OAAOc,eAAed,QAAQ;AAChC;AAEA,SAASP,IAAIO,MAA8B;IACzC,OAAOc,eAAed,QAAQ;AAChC;AAEA,SAASN,IAAIM,MAA8B;IACzC,OAAOc,eAAed,QAAQ;AAChC;AAEA,SAASL,IAAIK,MAA8B;IACzC,OAAOc,eAAed,QAAQ;AAChC"}
|
package/dist/model/index.d.ts
CHANGED
|
@@ -10,4 +10,7 @@ export * from './time-series-queries';
|
|
|
10
10
|
export * from './trace-queries';
|
|
11
11
|
export * from './profile-queries';
|
|
12
12
|
export * from './variables';
|
|
13
|
+
export * from './calculations';
|
|
14
|
+
export * from './alerts-queries';
|
|
15
|
+
export * from './silences-queries';
|
|
13
16
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/model/index.ts"],"names":[],"mappings":"AAaA,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AACtC,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/model/index.ts"],"names":[],"mappings":"AAaA,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AACtC,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC"}
|
package/dist/model/index.js
CHANGED
|
@@ -22,5 +22,8 @@ export * from './time-series-queries';
|
|
|
22
22
|
export * from './trace-queries';
|
|
23
23
|
export * from './profile-queries';
|
|
24
24
|
export * from './variables';
|
|
25
|
+
export * from './calculations';
|
|
26
|
+
export * from './alerts-queries';
|
|
27
|
+
export * from './silences-queries';
|
|
25
28
|
|
|
26
29
|
//# sourceMappingURL=index.js.map
|