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QAAUoS,EAKjC,MAAME,EAAsB,KAC1B,MAAMC,EAAetD,EAAajP,QAClC,GAAqB,OAAjBuS,EAAuB,CACzB,MAAMC,EAAcnB,EAAOoB,mBAC3BF,EAAaG,MAAMC,OAAU,GAAEH,EAtIhB,MAuIfD,EAAaG,MAAME,MAAQ,OAC3B,MAAMC,EAAaN,EAAaO,YAChCzB,EAAO0B,OAAO,CAAEH,MAAOC,EAAYF,OAAQH,MAI/CnB,EAAO2B,uBAAuBV,GAC9BA,IAIAjB,EAAO4B,WAAWjJ,EAAOkJ,OAAOC,MAAQnJ,EAAOoJ,QAAQC,OAAO,KAC5D3D,EAAc1P,QAAQqR,EAAO7E,eAM/B6E,EAAO4B,WAAWjJ,EAAOkJ,OAAOI,QAAUtJ,EAAOoJ,QAAQG,MAAM,WAC7DC,EAAAA,EAAOC,cAAc,IAAIC,cAAc,UAAW,CAAE/S,IAAK,IAAKgT,SAAS","sources":["webpack://grafana/../../opt/drone/yarncache/monaco-promql-npm-1.7.4-1b0c13a666-9fe2708be5.zip/node_modules/monaco-promql/promql/promql.contribution.js","webpack://grafana/./.yarn/__virtual__/react-use-virtual-00326e70ba/3/opt/drone/yarncache/react-use-npm-17.3.2-a032cbeb01-7379460f51.zip/node_modules/react-use/esm/useLatest.js","webpack://grafana/./public/app/plugins/datasource/prometheus/components/monaco-query-field/getOverrideServices.ts","webpack://grafana/./public/app/plugins/datasource/prometheus/components/monaco-query-field/monaco-completion-provider/util.ts","webpack://grafana/./public/app/plugins/datasource/prometheus/components/monaco-query-field/monaco-completion-provider/completions.ts","webpack://grafana/./public/app/plugins/datasource/prometheus/components/monaco-query-field/monaco-completion-provider/situation.ts","webpack://grafana/./public/app/plugins/datasource/prometheus/components/monaco-query-field/monaco-completion-provider/index.ts","webpack://grafana/./public/app/plugins/datasource/prometheus/components/monaco-query-field/MonacoQueryField.tsx"],"sourcesContent":["// The MIT License (MIT)\n//\n// Copyright (c) Celian Garcia and Augustin Husson @ Amadeus IT Group\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in all\n// copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n// SOFTWARE.\n'use strict';\n// noinspection JSUnusedGlobalSymbols\nexport var promLanguageDefinition = {\n id: 'promql',\n extensions: ['.promql'],\n aliases: ['Prometheus', 'prometheus', 'prom', 'Prom', 'promql', 'Promql', 'promQL', 'PromQL'],\n mimetypes: [],\n loader: function () { return import('./promql'); } // eslint-disable-line @typescript-eslint/explicit-function-return-type\n};\n","import { useRef } from 'react';\nvar useLatest = function (value) {\n var ref = useRef(value);\n ref.current = value;\n return ref;\n};\nexport default useLatest;\n","import { monacoTypes } from '@grafana/ui';\n\n// this thing here is a workaround in a way.\n// what we want to achieve, is that when the autocomplete-window\n// opens, the \"second, extra popup\" with the extra help,\n// also opens automatically.\n// but there is no API to achieve it.\n// the way to do it is to implement the `storageService`\n// interface, and provide our custom implementation,\n// which will default to `true` for the correct string-key.\n// unfortunately, while the typescript-interface exists,\n// it is not exported from monaco-editor,\n// so we cannot rely on typescript to make sure\n// we do it right. all we can do is to manually\n// lookup the interface, and make sure we code our code right.\n// our code is a \"best effort\" approach,\n// i am not 100% how the `scope` and `target` things work,\n// but so far it seems to work ok.\n// i would use an another approach, if there was one available.\n\nfunction makeStorageService() {\n // we need to return an object that fulfills this interface:\n // https://github.com/microsoft/vscode/blob/ff1e16eebb93af79fd6d7af1356c4003a120c563/src/vs/platform/storage/common/storage.ts#L37\n // unfortunately it is not export from monaco-editor\n\n const strings = new Map<string, string>();\n\n // we want this to be true by default\n strings.set('expandSuggestionDocs', true.toString());\n\n return {\n // we do not implement the on* handlers\n onDidChangeValue: (data: unknown): void => undefined,\n onDidChangeTarget: (data: unknown): void => undefined,\n onWillSaveState: (data: unknown): void => undefined,\n\n get: (key: string, scope: unknown, fallbackValue?: string): string | undefined => {\n return strings.get(key) ?? fallbackValue;\n },\n\n getBoolean: (key: string, scope: unknown, fallbackValue?: boolean): boolean | undefined => {\n const val = strings.get(key);\n if (val !== undefined) {\n // the interface-docs say the value will be converted\n // to a boolean but do not specify how, so we improvise\n return val === 'true';\n } else {\n return fallbackValue;\n }\n },\n\n getNumber: (key: string, scope: unknown, fallbackValue?: number): number | undefined => {\n const val = strings.get(key);\n if (val !== undefined) {\n return parseInt(val, 10);\n } else {\n return fallbackValue;\n }\n },\n\n store: (\n key: string,\n value: string | boolean | number | undefined | null,\n scope: unknown,\n target: unknown\n ): void => {\n // the interface-docs say if the value is nullish, it should act as delete\n if (value === null || value === undefined) {\n strings.delete(key);\n } else {\n strings.set(key, value.toString());\n }\n },\n\n remove: (key: string, scope: unknown): void => {\n strings.delete(key);\n },\n\n keys: (scope: unknown, target: unknown): string[] => {\n return Array.from(strings.keys());\n },\n\n logStorage: (): void => {\n console.log('logStorage: not implemented');\n },\n\n migrate: (): Promise<void> => {\n // we do not implement this\n return Promise.resolve(undefined);\n },\n\n isNew: (scope: unknown): boolean => {\n // we create a new storage for every session, we do not persist it,\n // so we return `true`.\n return true;\n },\n\n flush: (reason?: unknown): Promise<void> => {\n // we do not implement this\n return Promise.resolve(undefined);\n },\n };\n}\n\nlet overrideServices: monacoTypes.editor.IEditorOverrideServices | null = null;\n\nexport function getOverrideServices(): monacoTypes.editor.IEditorOverrideServices {\n // only have one instance of this for every query editor\n if (overrideServices === null) {\n overrideServices = {\n storageService: makeStorageService(),\n };\n }\n\n return overrideServices;\n}\n","// this helper class is used to make typescript warn you when you forget\n// a case-block in a switch statement.\n// example code that triggers the typescript-error:\n//\n// const x:'A'|'B'|'C' = 'A';\n//\n// switch(x) {\n// case 'A':\n// // something\n// case 'B':\n// // something\n// default:\n// throw new NeverCaseError(x);\n// }\n//\n//\n// typescript will show an error in this case,\n// when you add the missing `case 'C'` code,\n// the problem will be fixed.\n\nexport class NeverCaseError extends Error {\n constructor(value: never) {\n super('should never happen');\n }\n}\n","import { escapeLabelValueInExactSelector } from '../../../language_utils';\nimport { FUNCTIONS } from '../../../promql';\n\nimport type { Situation, Label } from './situation';\nimport { NeverCaseError } from './util';\n// FIXME: we should not load this from the \"outside\", but we cannot do that while we have the \"old\" query-field too\n\nexport type CompletionType = 'HISTORY' | 'FUNCTION' | 'METRIC_NAME' | 'DURATION' | 'LABEL_NAME' | 'LABEL_VALUE';\n\ntype Completion = {\n type: CompletionType;\n label: string;\n insertText: string;\n detail?: string;\n documentation?: string;\n triggerOnInsert?: boolean;\n};\n\ntype Metric = {\n name: string;\n help: string;\n type: string;\n};\n\nexport type DataProvider = {\n getHistory: () => Promise<string[]>;\n getAllMetricNames: () => Promise<Metric[]>;\n getAllLabelNames: () => Promise<string[]>;\n getLabelValues: (labelName: string) => Promise<string[]>;\n getSeries: (selector: string) => Promise<Record<string, string[]>>;\n};\n\n// we order items like: history, functions, metrics\n\nasync function getAllMetricNamesCompletions(dataProvider: DataProvider): Promise<Completion[]> {\n const metrics = await dataProvider.getAllMetricNames();\n return metrics.map((metric) => ({\n type: 'METRIC_NAME',\n label: metric.name,\n insertText: metric.name,\n detail: `${metric.name} : ${metric.type}`,\n documentation: metric.help,\n }));\n}\n\nconst FUNCTION_COMPLETIONS: Completion[] = FUNCTIONS.map((f) => ({\n type: 'FUNCTION',\n label: f.label,\n insertText: f.insertText ?? '', // i don't know what to do when this is nullish. it should not be.\n detail: f.detail,\n documentation: f.documentation,\n}));\n\nasync function getAllFunctionsAndMetricNamesCompletions(dataProvider: DataProvider): Promise<Completion[]> {\n const metricNames = await getAllMetricNamesCompletions(dataProvider);\n return [...FUNCTION_COMPLETIONS, ...metricNames];\n}\n\nconst DURATION_COMPLETIONS: Completion[] = [\n '$__interval',\n '$__range',\n '$__rate_interval',\n '1m',\n '5m',\n '10m',\n '30m',\n '1h',\n '1d',\n].map((text) => ({\n type: 'DURATION',\n label: text,\n insertText: text,\n}));\n\nasync function getAllHistoryCompletions(dataProvider: DataProvider): Promise<Completion[]> {\n // function getAllHistoryCompletions(queryHistory: PromHistoryItem[]): Completion[] {\n // NOTE: the typescript types are wrong. historyItem.query.expr can be undefined\n const allHistory = await dataProvider.getHistory();\n // FIXME: find a better history-limit\n return allHistory.slice(0, 10).map((expr) => ({\n type: 'HISTORY',\n label: expr,\n insertText: expr,\n }));\n}\n\nfunction makeSelector(metricName: string | undefined, labels: Label[]): string {\n const allLabels = [...labels];\n\n // we transform the metricName to a label, if it exists\n if (metricName !== undefined) {\n allLabels.push({ name: '__name__', value: metricName, op: '=' });\n }\n\n const allLabelTexts = allLabels.map(\n (label) => `${label.name}${label.op}\"${escapeLabelValueInExactSelector(label.value)}\"`\n );\n\n return `{${allLabelTexts.join(',')}}`;\n}\n\nasync function getLabelNames(\n metric: string | undefined,\n otherLabels: Label[],\n dataProvider: DataProvider\n): Promise<string[]> {\n if (metric === undefined && otherLabels.length === 0) {\n // if there is no filtering, we have to use a special endpoint\n return dataProvider.getAllLabelNames();\n } else {\n const selector = makeSelector(metric, otherLabels);\n const data = await dataProvider.getSeries(selector);\n const possibleLabelNames = Object.keys(data); // all names from prometheus\n const usedLabelNames = new Set(otherLabels.map((l) => l.name)); // names used in the query\n return possibleLabelNames.filter((l) => !usedLabelNames.has(l));\n }\n}\n\nasync function getLabelNamesForCompletions(\n metric: string | undefined,\n suffix: string,\n triggerOnInsert: boolean,\n otherLabels: Label[],\n dataProvider: DataProvider\n): Promise<Completion[]> {\n const labelNames = await getLabelNames(metric, otherLabels, dataProvider);\n return labelNames.map((text) => ({\n type: 'LABEL_NAME',\n label: text,\n insertText: `${text}${suffix}`,\n triggerOnInsert,\n }));\n}\n\nasync function getLabelNamesForSelectorCompletions(\n metric: string | undefined,\n otherLabels: Label[],\n dataProvider: DataProvider\n): Promise<Completion[]> {\n return getLabelNamesForCompletions(metric, '=', true, otherLabels, dataProvider);\n}\nasync function getLabelNamesForByCompletions(\n metric: string | undefined,\n otherLabels: Label[],\n dataProvider: DataProvider\n): Promise<Completion[]> {\n return getLabelNamesForCompletions(metric, '', false, otherLabels, dataProvider);\n}\n\nasync function getLabelValues(\n metric: string | undefined,\n labelName: string,\n otherLabels: Label[],\n dataProvider: DataProvider\n): Promise<string[]> {\n if (metric === undefined && otherLabels.length === 0) {\n // if there is no filtering, we have to use a special endpoint\n return dataProvider.getLabelValues(labelName);\n } else {\n const selector = makeSelector(metric, otherLabels);\n const data = await dataProvider.getSeries(selector);\n return data[labelName] ?? [];\n }\n}\n\nasync function getLabelValuesForMetricCompletions(\n metric: string | undefined,\n labelName: string,\n betweenQuotes: boolean,\n otherLabels: Label[],\n dataProvider: DataProvider\n): Promise<Completion[]> {\n const values = await getLabelValues(metric, labelName, otherLabels, dataProvider);\n return values.map((text) => ({\n type: 'LABEL_VALUE',\n label: text,\n insertText: betweenQuotes ? text : `\"${text}\"`, // FIXME: escaping strange characters?\n }));\n}\n\nexport async function getCompletions(situation: Situation, dataProvider: DataProvider): Promise<Completion[]> {\n switch (situation.type) {\n case 'IN_DURATION':\n return DURATION_COMPLETIONS;\n case 'IN_FUNCTION':\n return getAllFunctionsAndMetricNamesCompletions(dataProvider);\n case 'AT_ROOT': {\n return getAllFunctionsAndMetricNamesCompletions(dataProvider);\n }\n case 'EMPTY': {\n const metricNames = await getAllMetricNamesCompletions(dataProvider);\n const historyCompletions = await getAllHistoryCompletions(dataProvider);\n return [...historyCompletions, ...FUNCTION_COMPLETIONS, ...metricNames];\n }\n case 'IN_LABEL_SELECTOR_NO_LABEL_NAME':\n return getLabelNamesForSelectorCompletions(situation.metricName, situation.otherLabels, dataProvider);\n case 'IN_GROUPING':\n return getLabelNamesForByCompletions(situation.metricName, situation.otherLabels, dataProvider);\n case 'IN_LABEL_SELECTOR_WITH_LABEL_NAME':\n return getLabelValuesForMetricCompletions(\n situation.metricName,\n situation.labelName,\n situation.betweenQuotes,\n situation.otherLabels,\n dataProvider\n );\n default:\n throw new NeverCaseError(situation);\n }\n}\n","import type { Tree, SyntaxNode } from '@lezer/common';\nimport { parser } from 'lezer-promql';\n\nimport { NeverCaseError } from './util';\n\ntype Direction = 'parent' | 'firstChild' | 'lastChild' | 'nextSibling';\ntype NodeTypeName =\n | '⚠' // this is used as error-name\n | 'AggregateExpr'\n | 'AggregateModifier'\n | 'FunctionCallBody'\n | 'GroupingLabels'\n | 'Identifier'\n | 'LabelMatcher'\n | 'LabelMatchers'\n | 'LabelMatchList'\n | 'LabelName'\n | 'MetricIdentifier'\n | 'PromQL'\n | 'StringLiteral'\n | 'VectorSelector'\n | 'MatrixSelector'\n | 'MatchOp'\n | 'EqlSingle'\n | 'Neq'\n | 'EqlRegex'\n | 'NeqRegex';\n\ntype Path = Array<[Direction, NodeTypeName]>;\n\nfunction move(node: SyntaxNode, direction: Direction): SyntaxNode | null {\n switch (direction) {\n case 'parent':\n return node.parent;\n case 'firstChild':\n return node.firstChild;\n case 'lastChild':\n return node.lastChild;\n case 'nextSibling':\n return node.nextSibling;\n default:\n throw new NeverCaseError(direction);\n }\n}\n\nfunction walk(node: SyntaxNode, path: Path): SyntaxNode | null {\n let current: SyntaxNode | null = node;\n for (const [direction, expectedType] of path) {\n current = move(current, direction);\n if (current === null) {\n // we could not move in the direction, we stop\n return null;\n }\n if (current.type.name !== expectedType) {\n // the reached node has wrong type, we stop\n return null;\n }\n }\n return current;\n}\n\nfunction getNodeText(node: SyntaxNode, text: string): string {\n return text.slice(node.from, node.to);\n}\n\nfunction parsePromQLStringLiteral(text: string): string {\n // if it is a string-literal, it is inside quotes of some kind\n const inside = text.slice(1, text.length - 1);\n\n // FIXME: support https://prometheus.io/docs/prometheus/latest/querying/basics/#string-literals\n // FIXME: maybe check other promql code, if all is supported or not\n\n // for now we do only some very simple un-escaping\n\n // we start with double-quotes\n if (text.startsWith('\"') && text.endsWith('\"')) {\n // NOTE: this is not 100% perfect, we only unescape the double-quote,\n // there might be other characters too\n return inside.replace(/\\\\\"/, '\"');\n }\n\n // then single-quote\n if (text.startsWith(\"'\") && text.endsWith(\"'\")) {\n // NOTE: this is not 100% perfect, we only unescape the single-quote,\n // there might be other characters too\n return inside.replace(/\\\\'/, \"'\");\n }\n\n // then backticks\n if (text.startsWith('`') && text.endsWith('`')) {\n return inside;\n }\n\n throw new Error('FIXME: invalid string literal');\n}\n\ntype LabelOperator = '=' | '!=' | '=~' | '!~';\n\nexport type Label = {\n name: string;\n value: string;\n op: LabelOperator;\n};\n\nexport type Situation =\n | {\n type: 'IN_FUNCTION';\n }\n | {\n type: 'AT_ROOT';\n }\n | {\n type: 'EMPTY';\n }\n | {\n type: 'IN_DURATION';\n }\n | {\n type: 'IN_LABEL_SELECTOR_NO_LABEL_NAME';\n metricName?: string;\n otherLabels: Label[];\n }\n | {\n type: 'IN_GROUPING';\n metricName: string;\n otherLabels: Label[];\n }\n | {\n type: 'IN_LABEL_SELECTOR_WITH_LABEL_NAME';\n metricName?: string;\n labelName: string;\n betweenQuotes: boolean;\n otherLabels: Label[];\n };\n\ntype Resolver = {\n path: NodeTypeName[];\n fun: (node: SyntaxNode, text: string, pos: number) => Situation | null;\n};\n\nfunction isPathMatch(resolverPath: string[], cursorPath: string[]): boolean {\n return resolverPath.every((item, index) => item === cursorPath[index]);\n}\n\nconst ERROR_NODE_NAME: NodeTypeName = '⚠'; // this is used as error-name\n\nconst RESOLVERS: Resolver[] = [\n {\n path: ['LabelMatchers', 'VectorSelector'],\n fun: resolveLabelKeysWithEquals,\n },\n {\n path: ['PromQL'],\n fun: resolveTopLevel,\n },\n {\n path: ['FunctionCallBody'],\n fun: resolveInFunction,\n },\n {\n path: ['StringLiteral', 'LabelMatcher'],\n fun: resolveLabelMatcher,\n },\n {\n path: [ERROR_NODE_NAME, 'LabelMatcher'],\n fun: resolveLabelMatcher,\n },\n {\n path: [ERROR_NODE_NAME, 'MatrixSelector'],\n fun: resolveDurations,\n },\n {\n path: ['GroupingLabels'],\n fun: resolveLabelsForGrouping,\n },\n];\n\nconst LABEL_OP_MAP = new Map<string, LabelOperator>([\n ['EqlSingle', '='],\n ['EqlRegex', '=~'],\n ['Neq', '!='],\n ['NeqRegex', '!~'],\n]);\n\nfunction getLabelOp(opNode: SyntaxNode): LabelOperator | null {\n const opChild = opNode.firstChild;\n if (opChild === null) {\n return null;\n }\n\n return LABEL_OP_MAP.get(opChild.name) ?? null;\n}\n\nfunction getLabel(labelMatcherNode: SyntaxNode, text: string): Label | null {\n if (labelMatcherNode.type.name !== 'LabelMatcher') {\n return null;\n }\n\n const nameNode = walk(labelMatcherNode, [['firstChild', 'LabelName']]);\n\n if (nameNode === null) {\n return null;\n }\n\n const opNode = walk(nameNode, [['nextSibling', 'MatchOp']]);\n if (opNode === null) {\n return null;\n }\n\n const op = getLabelOp(opNode);\n if (op === null) {\n return null;\n }\n\n const valueNode = walk(labelMatcherNode, [['lastChild', 'StringLiteral']]);\n\n if (valueNode === null) {\n return null;\n }\n\n const name = getNodeText(nameNode, text);\n const value = parsePromQLStringLiteral(getNodeText(valueNode, text));\n\n return { name, value, op };\n}\nfunction getLabels(labelMatchersNode: SyntaxNode, text: string): Label[] {\n if (labelMatchersNode.type.name !== 'LabelMatchers') {\n return [];\n }\n\n let listNode: SyntaxNode | null = walk(labelMatchersNode, [['firstChild', 'LabelMatchList']]);\n\n const labels: Label[] = [];\n\n while (listNode !== null) {\n const matcherNode = walk(listNode, [['lastChild', 'LabelMatcher']]);\n if (matcherNode === null) {\n // unexpected, we stop\n return [];\n }\n\n const label = getLabel(matcherNode, text);\n if (label !== null) {\n labels.push(label);\n }\n\n // there might be more labels\n listNode = walk(listNode, [['firstChild', 'LabelMatchList']]);\n }\n\n // our labels-list is last-first, so we reverse it\n labels.reverse();\n\n return labels;\n}\n\nfunction getNodeChildren(node: SyntaxNode): SyntaxNode[] {\n let child: SyntaxNode | null = node.firstChild;\n const children: SyntaxNode[] = [];\n while (child !== null) {\n children.push(child);\n child = child.nextSibling;\n }\n return children;\n}\n\nfunction getNodeInSubtree(node: SyntaxNode, typeName: NodeTypeName): SyntaxNode | null {\n // first we try the current node\n if (node.type.name === typeName) {\n return node;\n }\n\n // then we try the children\n const children = getNodeChildren(node);\n for (const child of children) {\n const n = getNodeInSubtree(child, typeName);\n if (n !== null) {\n return n;\n }\n }\n\n return null;\n}\n\nfunction resolveLabelsForGrouping(node: SyntaxNode, text: string, pos: number): Situation | null {\n const aggrExpNode = walk(node, [\n ['parent', 'AggregateModifier'],\n ['parent', 'AggregateExpr'],\n ]);\n if (aggrExpNode === null) {\n return null;\n }\n const bodyNode = aggrExpNode.getChild('FunctionCallBody');\n if (bodyNode === null) {\n return null;\n }\n\n const metricIdNode = getNodeInSubtree(bodyNode, 'MetricIdentifier');\n if (metricIdNode === null) {\n return null;\n }\n\n const idNode = walk(metricIdNode, [['firstChild', 'Identifier']]);\n if (idNode === null) {\n return null;\n }\n\n const metricName = getNodeText(idNode, text);\n return {\n type: 'IN_GROUPING',\n metricName,\n otherLabels: [],\n };\n}\n\nfunction resolveLabelMatcher(node: SyntaxNode, text: string, pos: number): Situation | null {\n // we can arrive here in two situation. `node` is either:\n // - a StringNode (like in `{job=\"^\"}`)\n // - or an error node (like in `{job=^}`)\n const inStringNode = !node.type.isError;\n\n const parent = walk(node, [['parent', 'LabelMatcher']]);\n if (parent === null) {\n return null;\n }\n\n const labelNameNode = walk(parent, [['firstChild', 'LabelName']]);\n if (labelNameNode === null) {\n return null;\n }\n\n const labelName = getNodeText(labelNameNode, text);\n\n // now we need to go up, to the parent of LabelMatcher,\n // there can be one or many `LabelMatchList` parents, we have\n // to go through all of them\n\n const firstListNode = walk(parent, [['parent', 'LabelMatchList']]);\n if (firstListNode === null) {\n return null;\n }\n\n let listNode = firstListNode;\n\n // we keep going through the parent-nodes\n // as long as they are LabelMatchList.\n // as soon as we reawch LabelMatchers, we stop\n let labelMatchersNode: SyntaxNode | null = null;\n while (labelMatchersNode === null) {\n const p = listNode.parent;\n if (p === null) {\n return null;\n }\n\n const { name } = p.type;\n\n switch (name) {\n case 'LabelMatchList':\n //we keep looping\n listNode = p;\n continue;\n case 'LabelMatchers':\n // we reached the end, we can stop the loop\n labelMatchersNode = p;\n continue;\n default:\n // we reached some other node, we stop\n return null;\n }\n }\n\n // now we need to find the other names\n const allLabels = getLabels(labelMatchersNode, text);\n\n // we need to remove \"our\" label from all-labels, if it is in there\n const otherLabels = allLabels.filter((label) => label.name !== labelName);\n\n const metricNameNode = walk(labelMatchersNode, [\n ['parent', 'VectorSelector'],\n ['firstChild', 'MetricIdentifier'],\n ['firstChild', 'Identifier'],\n ]);\n\n if (metricNameNode === null) {\n // we are probably in a situation without a metric name\n return {\n type: 'IN_LABEL_SELECTOR_WITH_LABEL_NAME',\n labelName,\n betweenQuotes: inStringNode,\n otherLabels,\n };\n }\n\n const metricName = getNodeText(metricNameNode, text);\n\n return {\n type: 'IN_LABEL_SELECTOR_WITH_LABEL_NAME',\n metricName,\n labelName,\n betweenQuotes: inStringNode,\n otherLabels,\n };\n}\n\nfunction resolveTopLevel(node: SyntaxNode, text: string, pos: number): Situation {\n return {\n type: 'AT_ROOT',\n };\n}\n\nfunction resolveInFunction(node: SyntaxNode, text: string, pos: number): Situation {\n return {\n type: 'IN_FUNCTION',\n };\n}\n\nfunction resolveDurations(node: SyntaxNode, text: string, pos: number): Situation {\n return {\n type: 'IN_DURATION',\n };\n}\n\nfunction subTreeHasError(node: SyntaxNode): boolean {\n return getNodeInSubtree(node, ERROR_NODE_NAME) !== null;\n}\n\nfunction resolveLabelKeysWithEquals(node: SyntaxNode, text: string, pos: number): Situation | null {\n // for example `something{^}`\n\n // there are some false positives that can end up in this situation, that we want\n // to eliminate:\n // `something{a~^}` (if this subtree contains any error-node, we stop)\n if (subTreeHasError(node)) {\n return null;\n }\n\n // next false positive:\n // `something{a=\"1\"^}`\n const child = walk(node, [['firstChild', 'LabelMatchList']]);\n if (child !== null) {\n // means the label-matching part contains at least one label already.\n //\n // in this case, we will need to have a `,` character at the end,\n // to be able to suggest adding the next label.\n // the area between the end-of-the-child-node and the cursor-pos\n // must contain a `,` in this case.\n const textToCheck = text.slice(child.to, pos);\n\n if (!textToCheck.includes(',')) {\n return null;\n }\n }\n\n const metricNameNode = walk(node, [\n ['parent', 'VectorSelector'],\n ['firstChild', 'MetricIdentifier'],\n ['firstChild', 'Identifier'],\n ]);\n\n const otherLabels = getLabels(node, text);\n\n if (metricNameNode === null) {\n // we are probably in a situation without a metric name.\n return {\n type: 'IN_LABEL_SELECTOR_NO_LABEL_NAME',\n otherLabels,\n };\n }\n\n const metricName = getNodeText(metricNameNode, text);\n\n return {\n type: 'IN_LABEL_SELECTOR_NO_LABEL_NAME',\n metricName,\n otherLabels,\n };\n}\n\n// we find the first error-node in the tree that is at the cursor-position.\n// NOTE: this might be too slow, might need to optimize it\n// (ideas: we do not need to go into every subtree, based on from/to)\n// also, only go to places that are in the sub-tree of the node found\n// by default by lezer. problem is, `next()` will go upward too,\n// and we do not want to go higher than our node\nfunction getErrorNode(tree: Tree, pos: number): SyntaxNode | null {\n const cur = tree.cursor(pos);\n while (true) {\n if (cur.from === pos && cur.to === pos) {\n const { node } = cur;\n if (node.type.isError) {\n return node;\n }\n }\n\n if (!cur.next()) {\n break;\n }\n }\n return null;\n}\n\nexport function getSituation(text: string, pos: number): Situation | null {\n // there is a special-case when we are at the start of writing text,\n // so we handle that case first\n\n if (text === '') {\n return {\n type: 'EMPTY',\n };\n }\n\n /*\n\tPromQL\nExpr\nVectorSelector\nLabelMatchers\n*/\n const tree = parser.parse(text);\n\n // if the tree contains error, it is very probable that\n // our node is one of those error-nodes.\n // also, if there are errors, the node lezer finds us,\n // might not be the best node.\n // so first we check if there is an error-node at the cursor-position\n const maybeErrorNode = getErrorNode(tree, pos);\n\n const cur = maybeErrorNode != null ? maybeErrorNode.cursor : tree.cursor(pos);\n const currentNode = cur.node;\n\n const names = [cur.name];\n while (cur.parent()) {\n names.push(cur.name);\n }\n\n for (let resolver of RESOLVERS) {\n // i do not use a foreach because i want to stop as soon\n // as i find something\n if (isPathMatch(resolver.path, names)) {\n return resolver.fun(currentNode, text, pos);\n }\n }\n\n return null;\n}\n","import type { Monaco, monacoTypes } from '@grafana/ui';\n\nimport { getCompletions, DataProvider, CompletionType } from './completions';\nimport { getSituation } from './situation';\nimport { NeverCaseError } from './util';\n\nexport function getSuggestOptions(): monacoTypes.editor.ISuggestOptions {\n return {\n // monaco-editor sometimes provides suggestions automatically, i am not\n // sure based on what, seems to be by analyzing the words already\n // written.\n // to try it out:\n // - enter `go_goroutines{job~`\n // - have the cursor at the end of the string\n // - press ctrl-enter\n // - you will get two suggestions\n // those were not provided by grafana, they are offered automatically.\n // i want to remove those. the only way i found is:\n // - every suggestion-item has a `kind` attribute,\n // that controls the icon to the left of the suggestion.\n // - items auto-generated by monaco have `kind` set to `text`.\n // - we make sure grafana-provided suggestions do not have `kind` set to `text`.\n // - and then we tell monaco not to show suggestions of kind `text`\n showWords: false,\n };\n}\n\nfunction getMonacoCompletionItemKind(type: CompletionType, monaco: Monaco): monacoTypes.languages.CompletionItemKind {\n switch (type) {\n case 'DURATION':\n return monaco.languages.CompletionItemKind.Unit;\n case 'FUNCTION':\n return monaco.languages.CompletionItemKind.Variable;\n case 'HISTORY':\n return monaco.languages.CompletionItemKind.Snippet;\n case 'LABEL_NAME':\n return monaco.languages.CompletionItemKind.Enum;\n case 'LABEL_VALUE':\n return monaco.languages.CompletionItemKind.EnumMember;\n case 'METRIC_NAME':\n return monaco.languages.CompletionItemKind.Constructor;\n default:\n throw new NeverCaseError(type);\n }\n}\nexport function getCompletionProvider(\n monaco: Monaco,\n dataProvider: DataProvider\n): monacoTypes.languages.CompletionItemProvider {\n const provideCompletionItems = (\n model: monacoTypes.editor.ITextModel,\n position: monacoTypes.Position\n ): monacoTypes.languages.ProviderResult<monacoTypes.languages.CompletionList> => {\n const word = model.getWordAtPosition(position);\n const range =\n word != null\n ? monaco.Range.lift({\n startLineNumber: position.lineNumber,\n endLineNumber: position.lineNumber,\n startColumn: word.startColumn,\n endColumn: word.endColumn,\n })\n : monaco.Range.fromPositions(position);\n // documentation says `position` will be \"adjusted\" in `getOffsetAt`\n // i don't know what that means, to be sure i clone it\n const positionClone = {\n column: position.column,\n lineNumber: position.lineNumber,\n };\n const offset = model.getOffsetAt(positionClone);\n const situation = getSituation(model.getValue(), offset);\n const completionsPromise = situation != null ? getCompletions(situation, dataProvider) : Promise.resolve([]);\n return completionsPromise.then((items) => {\n // monaco by-default alphabetically orders the items.\n // to stop it, we use a number-as-string sortkey,\n // so that monaco keeps the order we use\n const maxIndexDigits = items.length.toString().length;\n const suggestions: monacoTypes.languages.CompletionItem[] = items.map((item, index) => ({\n kind: getMonacoCompletionItemKind(item.type, monaco),\n label: item.label,\n insertText: item.insertText,\n detail: item.detail,\n documentation: item.documentation,\n sortText: index.toString().padStart(maxIndexDigits, '0'), // to force the order we have\n range,\n command: item.triggerOnInsert\n ? {\n id: 'editor.action.triggerSuggest',\n title: '',\n }\n : undefined,\n }));\n return { suggestions };\n });\n };\n\n return {\n triggerCharacters: ['{', ',', '[', '(', '=', '~', ' ', '\"'],\n provideCompletionItems,\n };\n}\n","import { css } from '@emotion/css';\nimport { promLanguageDefinition } from 'monaco-promql';\nimport React, { useRef, useEffect } from 'react';\nimport { useLatest } from 'react-use';\n\nimport { GrafanaTheme2 } from '@grafana/data';\nimport { selectors } from '@grafana/e2e-selectors';\nimport { useTheme2, ReactMonacoEditor, Monaco, monacoTypes } from '@grafana/ui';\n\nimport { Props } from './MonacoQueryFieldProps';\nimport { getOverrideServices } from './getOverrideServices';\nimport { getCompletionProvider, getSuggestOptions } from './monaco-completion-provider';\n\nconst options: monacoTypes.editor.IStandaloneEditorConstructionOptions = {\n codeLens: false,\n contextmenu: false,\n // we need `fixedOverflowWidgets` because otherwise in grafana-dashboards\n // the popup is clipped by the panel-visualizations.\n fixedOverflowWidgets: true,\n folding: false,\n fontSize: 14,\n lineDecorationsWidth: 8, // used as \"padding-left\"\n lineNumbers: 'off',\n minimap: { enabled: false },\n overviewRulerBorder: false,\n overviewRulerLanes: 0,\n padding: {\n // these numbers were picked so that visually this matches the previous version\n // of the query-editor the best\n top: 4,\n bottom: 5,\n },\n renderLineHighlight: 'none',\n scrollbar: {\n vertical: 'hidden',\n verticalScrollbarSize: 8, // used as \"padding-right\"\n horizontal: 'hidden',\n horizontalScrollbarSize: 0,\n },\n scrollBeyondLastLine: false,\n suggest: getSuggestOptions(),\n suggestFontSize: 12,\n wordWrap: 'on',\n};\n\n// this number was chosen by testing various values. it might be necessary\n// because of the width of the border, not sure.\n//it needs to do 2 things:\n// 1. when the editor is single-line, it should make the editor height be visually correct\n// 2. when the editor is multi-line, the editor should not be \"scrollable\" (meaning,\n// you do a scroll-movement in the editor, and it will scroll the content by a couple pixels\n// up & down. this we want to avoid)\nconst EDITOR_HEIGHT_OFFSET = 2;\n\nconst PROMQL_LANG_ID = promLanguageDefinition.id;\n\n// we must only run the promql-setup code once\nlet PROMQL_SETUP_STARTED = false;\n\nfunction ensurePromQL(monaco: Monaco) {\n if (PROMQL_SETUP_STARTED === false) {\n PROMQL_SETUP_STARTED = true;\n const { aliases, extensions, mimetypes, loader } = promLanguageDefinition;\n monaco.languages.register({ id: PROMQL_LANG_ID, aliases, extensions, mimetypes });\n\n loader().then((mod) => {\n monaco.languages.setMonarchTokensProvider(PROMQL_LANG_ID, mod.language);\n monaco.languages.setLanguageConfiguration(PROMQL_LANG_ID, mod.languageConfiguration);\n });\n }\n}\n\nconst getStyles = (theme: GrafanaTheme2) => {\n return {\n container: css`\n border-radius: ${theme.shape.borderRadius()};\n border: 1px solid ${theme.components.input.borderColor};\n `,\n };\n};\n\nconst MonacoQueryField = (props: Props) => {\n // we need only one instance of `overrideServices` during the lifetime of the react component\n const overrideServicesRef = useRef(getOverrideServices());\n const containerRef = useRef<HTMLDivElement>(null);\n const { languageProvider, history, onBlur, onRunQuery, initialValue } = props;\n\n const lpRef = useLatest(languageProvider);\n const historyRef = useLatest(history);\n const onRunQueryRef = useLatest(onRunQuery);\n const onBlurRef = useLatest(onBlur);\n\n const autocompleteDisposeFun = useRef<(() => void) | null>(null);\n\n const theme = useTheme2();\n const styles = getStyles(theme);\n\n useEffect(() => {\n // when we unmount, we unregister the autocomplete-function, if it was registered\n return () => {\n autocompleteDisposeFun.current?.();\n };\n }, []);\n\n return (\n <div\n aria-label={selectors.components.QueryField.container}\n className={styles.container}\n // NOTE: we will be setting inline-style-width/height on this element\n ref={containerRef}\n >\n <ReactMonacoEditor\n overrideServices={overrideServicesRef.current}\n options={options}\n language=\"promql\"\n value={initialValue}\n beforeMount={(monaco) => {\n ensurePromQL(monaco);\n }}\n onMount={(editor, monaco) => {\n // we setup on-blur\n editor.onDidBlurEditorWidget(() => {\n onBlurRef.current(editor.getValue());\n });\n\n // we construct a DataProvider object\n const getSeries = (selector: string) => lpRef.current.getSeries(selector);\n\n const getHistory = () =>\n Promise.resolve(historyRef.current.map((h) => h.query.expr).filter((expr) => expr !== undefined));\n\n const getAllMetricNames = () => {\n const { metrics, metricsMetadata } = lpRef.current;\n const result = metrics.map((m) => {\n const metaItem = metricsMetadata?.[m];\n return {\n name: m,\n help: metaItem?.help ?? '',\n type: metaItem?.type ?? '',\n };\n });\n\n return Promise.resolve(result);\n };\n\n const getAllLabelNames = () => Promise.resolve(lpRef.current.getLabelKeys());\n\n const getLabelValues = (labelName: string) => lpRef.current.getLabelValues(labelName);\n\n const dataProvider = { getSeries, getHistory, getAllMetricNames, getAllLabelNames, getLabelValues };\n const completionProvider = getCompletionProvider(monaco, dataProvider);\n\n // completion-providers in monaco are not registered directly to editor-instances,\n // they are registered to languages. this makes it hard for us to have\n // separate completion-providers for every query-field-instance\n // (but we need that, because they might connect to different datasources).\n // the trick we do is, we wrap the callback in a \"proxy\",\n // and in the proxy, the first thing is, we check if we are called from\n // \"our editor instance\", and if not, we just return nothing. if yes,\n // we call the completion-provider.\n const filteringCompletionProvider: monacoTypes.languages.CompletionItemProvider = {\n ...completionProvider,\n provideCompletionItems: (model, position, context, token) => {\n // if the model-id does not match, then this call is from a different editor-instance,\n // not \"our instance\", so return nothing\n if (editor.getModel()?.id !== model.id) {\n return { suggestions: [] };\n }\n return completionProvider.provideCompletionItems(model, position, context, token);\n },\n };\n\n const { dispose } = monaco.languages.registerCompletionItemProvider(\n PROMQL_LANG_ID,\n filteringCompletionProvider\n );\n\n autocompleteDisposeFun.current = dispose;\n // this code makes the editor resize itself so that the content fits\n // (it will grow taller when necessary)\n // FIXME: maybe move this functionality into CodeEditor, like:\n // <CodeEditor resizingMode=\"single-line\"/>\n const updateElementHeight = () => {\n const containerDiv = containerRef.current;\n if (containerDiv !== null) {\n const pixelHeight = editor.getContentHeight();\n containerDiv.style.height = `${pixelHeight + EDITOR_HEIGHT_OFFSET}px`;\n containerDiv.style.width = '100%';\n const pixelWidth = containerDiv.clientWidth;\n editor.layout({ width: pixelWidth, height: pixelHeight });\n }\n };\n\n editor.onDidContentSizeChange(updateElementHeight);\n updateElementHeight();\n\n // handle: shift + enter\n // FIXME: maybe move this functionality into CodeEditor?\n editor.addCommand(monaco.KeyMod.Shift | monaco.KeyCode.Enter, () => {\n onRunQueryRef.current(editor.getValue());\n });\n\n /* Something in this configuration of monaco doesn't bubble up [mod]+K, which the \n command palette uses. Pass the event out of monaco manually\n */\n editor.addCommand(monaco.KeyMod.CtrlCmd | monaco.KeyCode.KeyK, function () {\n global.dispatchEvent(new KeyboardEvent('keydown', { key: 'k', metaKey: true }));\n });\n }}\n />\n </div>\n );\n};\n\n// we will lazy-load this module using React.lazy,\n// and that only supports default-exports,\n// so we have to default-export this, even if\n// it is against the style-guidelines.\n\nexport default MonacoQueryField;\n"],"names":["promLanguageDefinition","id","extensions","aliases","mimetypes","loader","value","ref","useRef","current","makeStorageService","strings","Map","set","toString","onDidChangeValue","data","onDidChangeTarget","onWillSaveState","get","key","scope","fallbackValue","getBoolean","val","undefined","getNumber","parseInt","store","target","delete","remove","keys","Array","from","logStorage","console","log","migrate","Promise","resolve","isNew","flush","reason","overrideServices","NeverCaseError","Error","constructor","super","async","getAllMetricNamesCompletions","dataProvider","getAllMetricNames","map","metric","type","label","name","insertText","detail","documentation","help","FUNCTION_COMPLETIONS","FUNCTIONS","f","getAllFunctionsAndMetricNamesCompletions","metricNames","DURATION_COMPLETIONS","text","makeSelector","metricName","labels","allLabels","push","op","escapeLabelValueInExactSelector","join","getLabelNamesForCompletions","suffix","triggerOnInsert","otherLabels","labelNames","length","getAllLabelNames","selector","getSeries","possibleLabelNames","Object","usedLabelNames","Set","l","filter","has","getLabelNames","getLabelValuesForMetricCompletions","labelName","betweenQuotes","values","getLabelValues","getCompletions","situation","historyCompletions","getHistory","slice","expr","getAllHistoryCompletions","getLabelNamesForSelectorCompletions","getLabelNamesForByCompletions","move","node","direction","parent","firstChild","lastChild","nextSibling","walk","path","expectedType","getNodeText","to","isPathMatch","resolverPath","cursorPath","every","item","index","ERROR_NODE_NAME","RESOLVERS","fun","pos","getNodeInSubtree","subTreeHasError","child","includes","metricNameNode","getLabels","resolveLabelMatcher","aggrExpNode","bodyNode","getChild","metricIdNode","idNode","LABEL_OP_MAP","getLabel","labelMatcherNode","nameNode","opNode","opChild","getLabelOp","valueNode","inside","startsWith","endsWith","replace","parsePromQLStringLiteral","labelMatchersNode","listNode","matcherNode","reverse","typeName","children","getNodeChildren","n","inStringNode","isError","labelNameNode","firstListNode","p","getMonacoCompletionItemKind","monaco","languages","CompletionItemKind","Unit","Variable","Snippet","Enum","EnumMember","Constructor","getCompletionProvider","triggerCharacters","provideCompletionItems","model","position","word","getWordAtPosition","range","Range","lift","startLineNumber","lineNumber","endLineNumber","startColumn","endColumn","fromPositions","positionClone","column","offset","getOffsetAt","tree","parser","maybeErrorNode","cur","cursor","next","getErrorNode","currentNode","names","resolver","getSituation","getValue","then","items","maxIndexDigits","suggestions","kind","sortText","padStart","command","title","options","codeLens","contextmenu","fixedOverflowWidgets","folding","fontSize","lineDecorationsWidth","lineNumbers","minimap","enabled","overviewRulerBorder","overviewRulerLanes","padding","top","bottom","renderLineHighlight","scrollbar","vertical","verticalScrollbarSize","horizontal","horizontalScrollbarSize","scrollBeyondLastLine","suggest","showWords","suggestFontSize","wordWrap","PROMQL_LANG_ID","PROMQL_SETUP_STARTED","props","overrideServicesRef","storageService","containerRef","languageProvider","history","onBlur","onRunQuery","initialValue","lpRef","useLatest","historyRef","onRunQueryRef","onBlurRef","autocompleteDisposeFun","styles","theme","container","css","shape","borderRadius","components","input","borderColor","getStyles","useTheme2","useEffect","selectors","className","ReactMonacoEditor","language","beforeMount","register","mod","setMonarchTokensProvider","setLanguageConfiguration","languageConfiguration","ensurePromQL","onMount","editor","onDidBlurEditorWidget","completionProvider","h","query","metrics","metricsMetadata","result","m","metaItem","getLabelKeys","filteringCompletionProvider","context","token","getModel","dispose","registerCompletionItemProvider","updateElementHeight","containerDiv","pixelHeight","getContentHeight","style","height","width","pixelWidth","clientWidth","layout","onDidContentSizeChange","addCommand","KeyMod","Shift","KeyCode","Enter","CtrlCmd","KeyK","global","dispatchEvent","KeyboardEvent","metaKey"],"sourceRoot":""}