mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Chore: Update lezer package of prometheus frontend (#91252)
* update lezer package * Use UnquotedLabelMatcher instead of LabelMatcher * Use UnquotedLabelMatcher instead of LabelMatcher in parsing.ts
This commit is contained in:
@@ -282,7 +282,6 @@
|
|||||||
"@opentelemetry/exporter-collector": "0.25.0",
|
"@opentelemetry/exporter-collector": "0.25.0",
|
||||||
"@opentelemetry/semantic-conventions": "1.25.1",
|
"@opentelemetry/semantic-conventions": "1.25.1",
|
||||||
"@popperjs/core": "2.11.8",
|
"@popperjs/core": "2.11.8",
|
||||||
"@prometheus-io/lezer-promql": "^0.52.0",
|
|
||||||
"@react-aria/dialog": "3.5.16",
|
"@react-aria/dialog": "3.5.16",
|
||||||
"@react-aria/focus": "3.18.1",
|
"@react-aria/focus": "3.18.1",
|
||||||
"@react-aria/overlays": "3.23.1",
|
"@react-aria/overlays": "3.23.1",
|
||||||
|
|||||||
@@ -48,8 +48,8 @@
|
|||||||
"@leeoniya/ufuzzy": "1.0.14",
|
"@leeoniya/ufuzzy": "1.0.14",
|
||||||
"@lezer/common": "1.2.1",
|
"@lezer/common": "1.2.1",
|
||||||
"@lezer/highlight": "1.2.0",
|
"@lezer/highlight": "1.2.0",
|
||||||
"@lezer/lr": "1.4.0",
|
"@lezer/lr": "1.4.2",
|
||||||
"@prometheus-io/lezer-promql": "0.52.1",
|
"@prometheus-io/lezer-promql": "0.53.1",
|
||||||
"@reduxjs/toolkit": "2.2.7",
|
"@reduxjs/toolkit": "2.2.7",
|
||||||
"d3": "7.9.0",
|
"d3": "7.9.0",
|
||||||
"date-fns": "3.6.0",
|
"date-fns": "3.6.0",
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ import {
|
|||||||
FunctionCallBody,
|
FunctionCallBody,
|
||||||
GroupingLabels,
|
GroupingLabels,
|
||||||
Identifier,
|
Identifier,
|
||||||
LabelMatcher,
|
|
||||||
LabelMatchers,
|
LabelMatchers,
|
||||||
LabelName,
|
LabelName,
|
||||||
MatchOp,
|
MatchOp,
|
||||||
@@ -19,6 +18,7 @@ import {
|
|||||||
parser,
|
parser,
|
||||||
PromQL,
|
PromQL,
|
||||||
StringLiteral,
|
StringLiteral,
|
||||||
|
UnquotedLabelMatcher,
|
||||||
VectorSelector,
|
VectorSelector,
|
||||||
} from '@prometheus-io/lezer-promql';
|
} from '@prometheus-io/lezer-promql';
|
||||||
|
|
||||||
@@ -33,7 +33,7 @@ type NodeTypeId =
|
|||||||
| typeof FunctionCallBody
|
| typeof FunctionCallBody
|
||||||
| typeof GroupingLabels
|
| typeof GroupingLabels
|
||||||
| typeof Identifier
|
| typeof Identifier
|
||||||
| typeof LabelMatcher
|
| typeof UnquotedLabelMatcher
|
||||||
| typeof LabelMatchers
|
| typeof LabelMatchers
|
||||||
| typeof LabelName
|
| typeof LabelName
|
||||||
| typeof PromQL
|
| typeof PromQL
|
||||||
@@ -178,7 +178,7 @@ const RESOLVERS: Resolver[] = [
|
|||||||
fun: resolveInFunction,
|
fun: resolveInFunction,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: [StringLiteral, LabelMatcher],
|
path: [StringLiteral, UnquotedLabelMatcher],
|
||||||
fun: resolveLabelMatcher,
|
fun: resolveLabelMatcher,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -186,7 +186,7 @@ const RESOLVERS: Resolver[] = [
|
|||||||
fun: resolveTopLevel,
|
fun: resolveTopLevel,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: [ERROR_NODE_NAME, LabelMatcher],
|
path: [ERROR_NODE_NAME, UnquotedLabelMatcher],
|
||||||
fun: resolveLabelMatcher,
|
fun: resolveLabelMatcher,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -216,7 +216,7 @@ function getLabelOp(opNode: SyntaxNode): LabelOperator | null {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getLabel(labelMatcherNode: SyntaxNode, text: string): Label | null {
|
function getLabel(labelMatcherNode: SyntaxNode, text: string): Label | null {
|
||||||
if (labelMatcherNode.type.id !== LabelMatcher) {
|
if (labelMatcherNode.type.id !== UnquotedLabelMatcher) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -253,7 +253,7 @@ function getLabels(labelMatchersNode: SyntaxNode, text: string): Label[] {
|
|||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
const labelNodes = labelMatchersNode.getChildren(LabelMatcher);
|
const labelNodes = labelMatchersNode.getChildren(UnquotedLabelMatcher);
|
||||||
return labelNodes.map((ln) => getLabel(ln, text)).filter(notEmpty);
|
return labelNodes.map((ln) => getLabel(ln, text)).filter(notEmpty);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -317,7 +317,7 @@ function resolveLabelMatcher(node: SyntaxNode, text: string, pos: number): Situa
|
|||||||
// - or an error node (like in `{job=^}`)
|
// - or an error node (like in `{job=^}`)
|
||||||
const inStringNode = !node.type.isError;
|
const inStringNode = !node.type.isError;
|
||||||
|
|
||||||
const parent = walk(node, [['parent', LabelMatcher]]);
|
const parent = walk(node, [['parent', UnquotedLabelMatcher]]);
|
||||||
if (parent === null) {
|
if (parent === null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -387,7 +387,7 @@ function resolveDurations(node: SyntaxNode, text: string, pos: number): Situatio
|
|||||||
function resolveLabelKeysWithEquals(node: SyntaxNode, text: string, pos: number): Situation | null {
|
function resolveLabelKeysWithEquals(node: SyntaxNode, text: string, pos: number): Situation | null {
|
||||||
// next false positive:
|
// next false positive:
|
||||||
// `something{a="1"^}`
|
// `something{a="1"^}`
|
||||||
const child = walk(node, [['firstChild', LabelMatcher]]);
|
const child = walk(node, [['firstChild', UnquotedLabelMatcher]]);
|
||||||
if (child !== null) {
|
if (child !== null) {
|
||||||
// means the label-matching part contains at least one label already.
|
// means the label-matching part contains at least one label already.
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -514,7 +514,7 @@ describe('buildVisualQueryFromString', () => {
|
|||||||
text: 'afe}',
|
text: 'afe}',
|
||||||
from: 14,
|
from: 14,
|
||||||
to: 18,
|
to: 18,
|
||||||
parentType: 'LabelMatcher',
|
parentType: 'UnquotedLabelMatcher',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
query: {
|
query: {
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ import {
|
|||||||
FunctionIdentifier,
|
FunctionIdentifier,
|
||||||
GroupingLabels,
|
GroupingLabels,
|
||||||
Identifier,
|
Identifier,
|
||||||
LabelMatcher,
|
|
||||||
LabelName,
|
LabelName,
|
||||||
MatchingModifierClause,
|
MatchingModifierClause,
|
||||||
MatchOp,
|
MatchOp,
|
||||||
@@ -20,6 +19,7 @@ import {
|
|||||||
ParenExpr,
|
ParenExpr,
|
||||||
parser,
|
parser,
|
||||||
StringLiteral,
|
StringLiteral,
|
||||||
|
UnquotedLabelMatcher,
|
||||||
VectorSelector,
|
VectorSelector,
|
||||||
Without,
|
Without,
|
||||||
} from '@prometheus-io/lezer-promql';
|
} from '@prometheus-io/lezer-promql';
|
||||||
@@ -145,7 +145,7 @@ export function handleExpression(expr: string, node: SyntaxNode, context: Contex
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case LabelMatcher: {
|
case UnquotedLabelMatcher: {
|
||||||
// Same as MetricIdentifier should be just one per query.
|
// Same as MetricIdentifier should be just one per query.
|
||||||
visQuery.labels.push(getLabel(expr, node));
|
visQuery.labels.push(getLabel(expr, node));
|
||||||
const err = node.getChild(ErrorId);
|
const err = node.getChild(ErrorId);
|
||||||
|
|||||||
21
yarn.lock
21
yarn.lock
@@ -3563,8 +3563,8 @@ __metadata:
|
|||||||
"@leeoniya/ufuzzy": "npm:1.0.14"
|
"@leeoniya/ufuzzy": "npm:1.0.14"
|
||||||
"@lezer/common": "npm:1.2.1"
|
"@lezer/common": "npm:1.2.1"
|
||||||
"@lezer/highlight": "npm:1.2.0"
|
"@lezer/highlight": "npm:1.2.0"
|
||||||
"@lezer/lr": "npm:1.4.0"
|
"@lezer/lr": "npm:1.4.2"
|
||||||
"@prometheus-io/lezer-promql": "npm:0.52.1"
|
"@prometheus-io/lezer-promql": "npm:0.53.1"
|
||||||
"@reduxjs/toolkit": "npm:2.2.7"
|
"@reduxjs/toolkit": "npm:2.2.7"
|
||||||
"@rollup/plugin-image": "npm:3.0.3"
|
"@rollup/plugin-image": "npm:3.0.3"
|
||||||
"@rollup/plugin-node-resolve": "npm:15.2.3"
|
"@rollup/plugin-node-resolve": "npm:15.2.3"
|
||||||
@@ -4622,12 +4622,12 @@ __metadata:
|
|||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
"@lezer/lr@npm:1.4.0":
|
"@lezer/lr@npm:1.4.2":
|
||||||
version: 1.4.0
|
version: 1.4.2
|
||||||
resolution: "@lezer/lr@npm:1.4.0"
|
resolution: "@lezer/lr@npm:1.4.2"
|
||||||
dependencies:
|
dependencies:
|
||||||
"@lezer/common": "npm:^1.0.0"
|
"@lezer/common": "npm:^1.0.0"
|
||||||
checksum: 10/7391d0d08e54cd9e4f4d46e6ee6aa81fbaf079b22ed9c13d01fc9928e0ffd16d0c2d21b2cedd55675ad6c687277db28349ea8db81c9c69222cd7e7c40edd026e
|
checksum: 10/f7b505906c8d8df14c07866553cf3dae1e065b1da8b28fbb4193fd67ab8d187eb45f92759e29a2cfe4283296f0aa864b38a0a91708ecfc3e24b8f662d626e0c6
|
||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
@@ -5841,13 +5841,13 @@ __metadata:
|
|||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
"@prometheus-io/lezer-promql@npm:0.52.1, @prometheus-io/lezer-promql@npm:^0.52.0":
|
"@prometheus-io/lezer-promql@npm:0.53.1":
|
||||||
version: 0.52.1
|
version: 0.53.1
|
||||||
resolution: "@prometheus-io/lezer-promql@npm:0.52.1"
|
resolution: "@prometheus-io/lezer-promql@npm:0.53.1"
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
"@lezer/highlight": ^1.1.2
|
"@lezer/highlight": ^1.1.2
|
||||||
"@lezer/lr": ^1.2.3
|
"@lezer/lr": ^1.2.3
|
||||||
checksum: 10/531164b8ddedbe0e0ba9304ea918f5cb0bb9c14f5e68c835fa02d3dbbe37c90daa8344a54666ba32aea6db8dfc0720cbc5b5ea50e1ed1126e987fcea7394b595
|
checksum: 10/ebb506155f6343277e7bafc7342af3b8c0f162eda08c380f680f8c526878211a17be92e75b5d5de69cbf344f50a76221472b50533dde152ea396e148278c2d77
|
||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
@@ -17526,7 +17526,6 @@ __metadata:
|
|||||||
"@playwright/test": "npm:1.46.0"
|
"@playwright/test": "npm:1.46.0"
|
||||||
"@pmmmwh/react-refresh-webpack-plugin": "npm:0.5.15"
|
"@pmmmwh/react-refresh-webpack-plugin": "npm:0.5.15"
|
||||||
"@popperjs/core": "npm:2.11.8"
|
"@popperjs/core": "npm:2.11.8"
|
||||||
"@prometheus-io/lezer-promql": "npm:^0.52.0"
|
|
||||||
"@react-aria/dialog": "npm:3.5.16"
|
"@react-aria/dialog": "npm:3.5.16"
|
||||||
"@react-aria/focus": "npm:3.18.1"
|
"@react-aria/focus": "npm:3.18.1"
|
||||||
"@react-aria/overlays": "npm:3.23.1"
|
"@react-aria/overlays": "npm:3.23.1"
|
||||||
|
|||||||
Reference in New Issue
Block a user