@grafana/scenes 5.35.0--canary.1007.12374452740.0 → 5.35.0
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +29 -0
- package/dist/esm/querying/SceneQueryRunner.js +4 -4
- package/dist/esm/querying/SceneQueryRunner.js.map +1 -1
- package/dist/esm/variables/adhoc/patchGetAdhocFilters.js +2 -1
- package/dist/esm/variables/adhoc/patchGetAdhocFilters.js.map +1 -1
- package/dist/esm/variables/groupby/findActiveGroupByVariablesByUid.js +3 -1
- package/dist/esm/variables/groupby/findActiveGroupByVariablesByUid.js.map +1 -1
- package/dist/esm/variables/utils.js +5 -2
- package/dist/esm/variables/utils.js.map +1 -1
- package/dist/esm/variables/variants/query/createQueryVariableRunner.js +27 -1
- package/dist/esm/variables/variants/query/createQueryVariableRunner.js.map +1 -1
- package/dist/esm/variables/variants/query/guards.js +7 -1
- package/dist/esm/variables/variants/query/guards.js.map +1 -1
- package/dist/index.js +43 -8
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
@@ -2474,7 +2474,7 @@ function patchGetAdhocFilters(filterVar) {
|
|
2474
2474
|
function findActiveAdHocFilterVariableByUid(dsUid) {
|
2475
2475
|
var _a;
|
2476
2476
|
for (const filter of allActiveFilterSets.values()) {
|
2477
|
-
if (((_a = filter.state.datasource) == null ? void 0 : _a.uid) === dsUid) {
|
2477
|
+
if (interpolate(filter, (_a = filter.state.datasource) == null ? void 0 : _a.uid) === dsUid) {
|
2478
2478
|
return filter;
|
2479
2479
|
}
|
2480
2480
|
}
|
@@ -2520,7 +2520,7 @@ const allActiveGroupByVariables = /* @__PURE__ */ new Set();
|
|
2520
2520
|
function findActiveGroupByVariablesByUid(dsUid) {
|
2521
2521
|
var _a;
|
2522
2522
|
for (const groupByVariable of allActiveGroupByVariables.values()) {
|
2523
|
-
if (((_a = groupByVariable.state.datasource) == null ? void 0 : _a.uid) === dsUid) {
|
2523
|
+
if (interpolate(groupByVariable, (_a = groupByVariable.state.datasource) == null ? void 0 : _a.uid) === dsUid) {
|
2524
2524
|
return groupByVariable;
|
2525
2525
|
}
|
2526
2526
|
}
|
@@ -5563,7 +5563,7 @@ class SceneQueryRunner extends SceneObjectBase {
|
|
5563
5563
|
try {
|
5564
5564
|
const datasource = (_c = this.state.datasource) != null ? _c : findFirstDatasource(queries);
|
5565
5565
|
const ds = await getDataSource(datasource, this._scopedVars);
|
5566
|
-
this.findAndSubscribeToAdHocFilters(
|
5566
|
+
this.findAndSubscribeToAdHocFilters(ds.uid);
|
5567
5567
|
const runRequest = runtime.getRunRequest();
|
5568
5568
|
const { primary, secondaries, processors } = this.prepareRequests(timeRange, ds);
|
5569
5569
|
writeSceneLog("SceneQueryRunner", "Starting runRequest", this.state.key);
|
@@ -5692,13 +5692,13 @@ class SceneQueryRunner extends SceneObjectBase {
|
|
5692
5692
|
});
|
5693
5693
|
return Array.from(found.values());
|
5694
5694
|
}
|
5695
|
-
findAndSubscribeToAdHocFilters(
|
5696
|
-
const filtersVar = findActiveAdHocFilterVariableByUid(
|
5695
|
+
findAndSubscribeToAdHocFilters(interpolatedUid) {
|
5696
|
+
const filtersVar = findActiveAdHocFilterVariableByUid(interpolatedUid);
|
5697
5697
|
if (this._adhocFiltersVar !== filtersVar) {
|
5698
5698
|
this._adhocFiltersVar = filtersVar;
|
5699
5699
|
this._updateExplicitVariableDependencies();
|
5700
5700
|
}
|
5701
|
-
const groupByVar = findActiveGroupByVariablesByUid(
|
5701
|
+
const groupByVar = findActiveGroupByVariablesByUid(interpolatedUid);
|
5702
5702
|
if (this._groupByVar !== groupByVar) {
|
5703
5703
|
this._groupByVar = groupByVar;
|
5704
5704
|
this._updateExplicitVariableDependencies();
|
@@ -5792,13 +5792,16 @@ function escapeLokiRegexp(value) {
|
|
5792
5792
|
return value.replace(RE2_METACHARACTERS, "\\$&");
|
5793
5793
|
}
|
5794
5794
|
function getQueriesForVariables(sourceObject) {
|
5795
|
+
var _a;
|
5795
5796
|
const runners = sceneGraph.findAllObjects(
|
5796
5797
|
sourceObject.getRoot(),
|
5797
5798
|
(o) => o instanceof SceneQueryRunner
|
5798
5799
|
);
|
5800
|
+
const interpolatedDsUuid = sceneGraph.interpolate(sourceObject, (_a = sourceObject.state.datasource) == null ? void 0 : _a.uid);
|
5799
5801
|
const applicableRunners = filterOutInactiveRunnerDuplicates(runners).filter((r) => {
|
5800
|
-
var
|
5801
|
-
|
5802
|
+
var _a2;
|
5803
|
+
const interpolatedQueryDsUuid = sceneGraph.interpolate(sourceObject, (_a2 = r.state.datasource) == null ? void 0 : _a2.uid);
|
5804
|
+
return interpolatedQueryDsUuid === interpolatedDsUuid;
|
5802
5805
|
});
|
5803
5806
|
if (applicableRunners.length === 0) {
|
5804
5807
|
return [];
|
@@ -6098,6 +6101,12 @@ const hasCustomVariableSupport = (datasource) => {
|
|
6098
6101
|
const variableSupport = datasource.variables;
|
6099
6102
|
return "query" in variableSupport && "editor" in variableSupport && Boolean(variableSupport.query) && Boolean(variableSupport.editor);
|
6100
6103
|
};
|
6104
|
+
const hasDataSourceVariableSupport = (datasource) => {
|
6105
|
+
if (!datasource.variables) {
|
6106
|
+
return false;
|
6107
|
+
}
|
6108
|
+
return datasource.variables.getType() === data.VariableSupportType.Datasource;
|
6109
|
+
};
|
6101
6110
|
|
6102
6111
|
var __defProp$w = Object.defineProperty;
|
6103
6112
|
var __defProps$k = Object.defineProperties;
|
@@ -6193,6 +6202,29 @@ class CustomQueryRunner {
|
|
6193
6202
|
return this._runRequest(this.datasource, request, this.datasource.variables.query.bind(this.datasource.variables));
|
6194
6203
|
}
|
6195
6204
|
}
|
6205
|
+
const variableDummyRefId = "variable-query";
|
6206
|
+
class DatasourceQueryRunner {
|
6207
|
+
constructor(datasource, _runRequest = runtime.getRunRequest()) {
|
6208
|
+
this.datasource = datasource;
|
6209
|
+
this._runRequest = _runRequest;
|
6210
|
+
}
|
6211
|
+
getTarget(variable) {
|
6212
|
+
var _a;
|
6213
|
+
if (hasDataSourceVariableSupport(this.datasource)) {
|
6214
|
+
if (typeof variable.state.query === "string") {
|
6215
|
+
return variable.state.query;
|
6216
|
+
}
|
6217
|
+
return __spreadProps$k(__spreadValues$w({}, variable.state.query), { refId: (_a = variable.state.query.refId) != null ? _a : variableDummyRefId });
|
6218
|
+
}
|
6219
|
+
throw new Error("Couldn't create a target with supplied arguments.");
|
6220
|
+
}
|
6221
|
+
runRequest(_, request) {
|
6222
|
+
if (!hasDataSourceVariableSupport(this.datasource)) {
|
6223
|
+
return getEmptyMetricFindValueObservable();
|
6224
|
+
}
|
6225
|
+
return this._runRequest(this.datasource, request, this.datasource.query);
|
6226
|
+
}
|
6227
|
+
}
|
6196
6228
|
function getEmptyMetricFindValueObservable() {
|
6197
6229
|
return rxjs.of({ state: data.LoadingState.Done, series: [], timeRange: data.getDefaultTimeRange() });
|
6198
6230
|
}
|
@@ -6206,6 +6238,9 @@ function createQueryVariableRunnerFactory(datasource) {
|
|
6206
6238
|
if (hasCustomVariableSupport(datasource)) {
|
6207
6239
|
return new CustomQueryRunner(datasource);
|
6208
6240
|
}
|
6241
|
+
if (hasDataSourceVariableSupport(datasource)) {
|
6242
|
+
return new DatasourceQueryRunner(datasource);
|
6243
|
+
}
|
6209
6244
|
throw new Error(`Couldn't create a query runner for datasource ${datasource.type}`);
|
6210
6245
|
}
|
6211
6246
|
let createQueryVariableRunner = createQueryVariableRunnerFactory;
|