Update dependency @prometheus-io/lezer-promql to v0.55.1 (#95272)

* Update dependency @prometheus-io/lezer-promql to v0.55.1

* chore(grafana-prometheus): update type import

* fix duration resolver

* fix unit test

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Jack Westbrook <jack.westbrook@gmail.com>
Co-authored-by: ismail simsek <ismailsimsek09@gmail.com>
This commit is contained in:
renovate[bot]
2024-11-09 01:16:51 +02:00
committed by GitHub
co-authored by Jack Westbrook ismail simsek
parent b4644580cf
commit b1c5aa0929
5 changed files with 20 additions and 19 deletions
+1 -1
View File
@@ -49,7 +49,7 @@
"@lezer/common": "1.2.3",
"@lezer/highlight": "1.2.1",
"@lezer/lr": "1.4.2",
"@prometheus-io/lezer-promql": "0.54.1",
"@prometheus-io/lezer-promql": "0.55.1",
"@reduxjs/toolkit": "2.2.8",
"d3": "7.9.0",
"date-fns": "3.6.0",
@@ -15,6 +15,7 @@ import {
MatrixSelector,
Neq,
NeqRegex,
NumberDurationLiteralInDurationContext,
parser,
PromQL,
StringLiteral,
@@ -190,7 +191,7 @@ const RESOLVERS: Resolver[] = [
fun: resolveLabelMatcher,
},
{
path: [ERROR_NODE_NAME, MatrixSelector],
path: [ERROR_NODE_NAME, NumberDurationLiteralInDurationContext, MatrixSelector],
fun: resolveDurations,
},
{
@@ -460,10 +461,10 @@ export function getSituation(text: string, pos: number): Situation | null {
}
/**
PromQL
Expr
VectorSelector
LabelMatchers
PromQL
Expr
VectorSelector
LabelMatchers
*/
const tree = parser.parse(text);
@@ -49,10 +49,10 @@ describe('Monaco Query Validation', () => {
query = 'max_over_time(deriv(rate(distance_covered_total[5s])[30s5s])[10m:])';
expect(validateQuery(query, query, [query], parser)).toEqual([
{
endColumn: 60,
endColumn: 59,
endLineNumber: 1,
error: 'rate(distance_covered_total[5s])[30s5s]',
startColumn: 21,
error: '5s',
startColumn: 57,
startLineNumber: 1,
},
]);
@@ -14,7 +14,7 @@ import {
LabelName,
MatchingModifierClause,
MatchOp,
NumberLiteral,
NumberDurationLiteral,
On,
ParenExpr,
parser,
@@ -334,7 +334,7 @@ function updateFunctionArgs(expr: string, node: SyntaxNode | null, context: Cont
break;
}
case NumberLiteral: {
case NumberDurationLiteral: {
op.params.push(parseFloat(getString(expr, node)));
break;
}
@@ -369,8 +369,8 @@ function handleBinary(expr: string, node: SyntaxNode, context: Context) {
const opDef = binaryScalarOperatorToOperatorName[op];
const leftNumber = left.type.id === NumberLiteral;
const rightNumber = right.type.id === NumberLiteral;
const leftNumber = left.type.id === NumberDurationLiteral;
const rightNumber = right.type.id === NumberDurationLiteral;
const rightBinary = right.type.id === BinaryExpr;
@@ -389,7 +389,7 @@ function handleBinary(expr: string, node: SyntaxNode, context: Context) {
// Due to the way binary ops are parsed we can get a binary operation on the right that starts with a number which
// is a factor for a current binary operation. So we have to add it as an operation now.
const leftMostChild = getLeftMostChild(right);
if (leftMostChild?.type.id === NumberLiteral) {
if (leftMostChild?.type.id === NumberDurationLiteral) {
visQuery.operations.push(makeBinOp(opDef, expr, leftMostChild, !!binModifier?.isBool));
}
+5 -5
View File
@@ -3886,7 +3886,7 @@ __metadata:
"@lezer/common": "npm:1.2.3"
"@lezer/highlight": "npm:1.2.1"
"@lezer/lr": "npm:1.4.2"
"@prometheus-io/lezer-promql": "npm:0.54.1"
"@prometheus-io/lezer-promql": "npm:0.55.1"
"@reduxjs/toolkit": "npm:2.2.8"
"@rollup/plugin-image": "npm:3.0.3"
"@rollup/plugin-node-resolve": "npm:15.3.0"
@@ -6345,13 +6345,13 @@ __metadata:
languageName: node
linkType: hard
"@prometheus-io/lezer-promql@npm:0.54.1":
version: 0.54.1
resolution: "@prometheus-io/lezer-promql@npm:0.54.1"
"@prometheus-io/lezer-promql@npm:0.55.1":
version: 0.55.1
resolution: "@prometheus-io/lezer-promql@npm:0.55.1"
peerDependencies:
"@lezer/highlight": ^1.1.2
"@lezer/lr": ^1.2.3
checksum: 10/ee556a20ea2ea473404a4185c1b01b3337c176175c9531411fd10dc4c5920e898c50dd48af1f750711d406d4cac2e3c6da67d157f8d23a5c435a8cbbc403558b
checksum: 10/58f286a3d787429b1a8e210b8044a71bc9fca331a1f1a1751d35bd70fe5d53bc4557aad9552fe132f4b33765239b2d25c5d0bbc483742def2bcf421fd9174560
languageName: node
linkType: hard