UNPKG

@prometheus-io/codemirror-promql

Version:
46 lines (45 loc) 1.68 kB
import { CompleteStrategy } from './index'; import { SyntaxNode } from '@lezer/common'; import { PrometheusClient } from '../client'; import { CompletionContext, CompletionResult } from '@codemirror/autocomplete'; import { EditorState } from '@codemirror/state'; import { Matcher } from '../types'; export declare enum ContextKind { MetricName = 0, LabelName = 1, LabelValue = 2, Function = 3, Aggregation = 4, BinOpModifier = 5, BinOp = 6, MatchOp = 7, AggregateOpModifier = 8, Duration = 9, DurationExpr = 10, DurationExprOperator = 11, Offset = 12, Bool = 13, AtModifiers = 14, Number = 15 } export interface Context { kind: ContextKind; metricName?: string; labelName?: string; matchers?: Matcher[]; } export declare function computeEndCompletePosition(state: EditorState, node: SyntaxNode, pos: number): number; export declare const durationWithUnitRegexp: RegExp; export declare function computeStartCompletePosition(state: EditorState, node: SyntaxNode, pos: number): number; export declare function analyzeCompletion(state: EditorState, node: SyntaxNode, pos: number): Context[]; export declare class HybridComplete implements CompleteStrategy { private readonly prometheusClient; private readonly maxMetricsMetadata; constructor(prometheusClient?: PrometheusClient, maxMetricsMetadata?: number); getPrometheusClient(): PrometheusClient | undefined; destroy(): void; promQL(context: CompletionContext): Promise<CompletionResult | null> | CompletionResult | null; private autocompleteMetricName; private autocompleteLabelName; private autocompleteLabelValue; }