@perses-dev/loki-plugin 0.5.0-rc.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/__mf/js/{Loki.21b585d6.js → Loki.2bd94c1e.js} +3 -3
- package/__mf/js/async/1728.326f0c08.js +1 -0
- package/__mf/js/async/1750.eba509e1.js +1 -0
- package/__mf/js/async/392.2c7c202d.js +2 -0
- package/__mf/js/async/54.b3492a7a.js +22 -0
- package/__mf/js/async/5440.995ad0c5.js +2 -0
- package/__mf/js/async/{5440.3fedd5ea.js.LICENSE.txt → 5440.995ad0c5.js.LICENSE.txt} +3 -3
- package/__mf/js/async/6710.a94fd362.js +2 -0
- package/__mf/js/async/7958.f25f7332.js +7 -0
- package/__mf/js/async/9010.44bf2927.js +2 -0
- package/__mf/js/async/{1238.71fd7843.js → 9249.d90da2ad.js} +1 -1
- package/__mf/js/async/9389.29616aa6.js +2 -0
- package/__mf/js/async/9877.b76d1711.js +38 -0
- package/__mf/js/async/{__federation_expose_LokiDatasource.44ac1fa6.js → __federation_expose_LokiDatasource.3fe6141d.js} +2 -2
- package/__mf/js/async/{__federation_expose_LokiLogQuery.22f7c517.js → __federation_expose_LokiLogQuery.6591d0db.js} +1 -1
- package/__mf/js/async/{__federation_expose_LokiTimeSeriesQuery.4909566f.js → __federation_expose_LokiTimeSeriesQuery.2a9b451a.js} +1 -1
- package/__mf/js/{main.59f3d316.js → main.4d84b446.js} +3 -3
- package/lib/bootstrap.js +12 -0
- package/lib/bootstrap.js.map +1 -1
- package/lib/cjs/bootstrap.js +12 -0
- package/lib/cjs/components/complete.js +260 -34
- package/lib/cjs/components/index.js +1 -1
- package/lib/cjs/components/logql-editor.js +1 -1
- package/lib/cjs/components/logql-extension.js +1 -1
- package/lib/cjs/components/logql-highlight.js +1 -1
- package/lib/cjs/datasources/index.js +1 -1
- package/lib/cjs/datasources/loki-datasource/LokiDatasource.js +1 -1
- package/lib/cjs/datasources/loki-datasource/LokiDatasourceEditor.js +1 -1
- package/lib/cjs/datasources/loki-datasource/index.js +1 -1
- package/lib/cjs/datasources/loki-datasource/loki-datasource-types.js +1 -1
- package/lib/cjs/env.d.js +12 -0
- package/lib/cjs/getPluginModule.js +12 -0
- package/lib/cjs/index-federation.js +12 -0
- package/lib/cjs/index.js +12 -0
- package/lib/cjs/model/index.js +1 -1
- package/lib/cjs/model/loki-client-types.js +1 -1
- package/lib/cjs/model/loki-client.js +1 -1
- package/lib/cjs/model/loki-data-types.js +1 -1
- package/lib/cjs/model/loki-selectors.js +1 -1
- package/lib/cjs/queries/constants.js +12 -0
- package/lib/cjs/queries/index.js +1 -1
- package/lib/cjs/queries/loki-log-query/LokiLogQuery.js +12 -0
- package/lib/cjs/queries/loki-log-query/LokiLogQueryEditor.js +1 -1
- package/lib/cjs/queries/loki-log-query/get-loki-log-data.js +12 -0
- package/lib/cjs/queries/loki-log-query/index.js +12 -0
- package/lib/cjs/queries/loki-log-query/log-query-plugin-interface.js +12 -0
- package/lib/cjs/queries/loki-log-query/loki-log-query-types.js +12 -0
- package/lib/cjs/queries/loki-time-series-query/LokiTimeSeriesQuery.js +1 -1
- package/lib/cjs/queries/loki-time-series-query/LokiTimeSeriesQueryEditor.js +1 -1
- package/lib/cjs/queries/loki-time-series-query/get-loki-time-series-data.js +1 -1
- package/lib/cjs/queries/loki-time-series-query/index.js +1 -1
- package/lib/cjs/queries/loki-time-series-query/loki-time-series-query-types.js +1 -1
- package/lib/cjs/queries/query-editor-model.js +1 -1
- package/lib/cjs/setup-tests.js +12 -0
- package/lib/components/complete.d.ts +5 -0
- package/lib/components/complete.d.ts.map +1 -1
- package/lib/components/complete.js +259 -33
- package/lib/components/complete.js.map +1 -1
- package/lib/components/index.js +1 -1
- package/lib/components/index.js.map +1 -1
- package/lib/components/logql-editor.js +1 -1
- package/lib/components/logql-editor.js.map +1 -1
- package/lib/components/logql-extension.js +1 -1
- package/lib/components/logql-extension.js.map +1 -1
- package/lib/components/logql-highlight.js +1 -1
- package/lib/components/logql-highlight.js.map +1 -1
- package/lib/datasources/index.js +1 -1
- package/lib/datasources/index.js.map +1 -1
- package/lib/datasources/loki-datasource/LokiDatasource.js +1 -1
- package/lib/datasources/loki-datasource/LokiDatasource.js.map +1 -1
- package/lib/datasources/loki-datasource/LokiDatasourceEditor.js +1 -1
- package/lib/datasources/loki-datasource/LokiDatasourceEditor.js.map +1 -1
- package/lib/datasources/loki-datasource/index.js +1 -1
- package/lib/datasources/loki-datasource/index.js.map +1 -1
- package/lib/datasources/loki-datasource/loki-datasource-types.js +1 -1
- package/lib/datasources/loki-datasource/loki-datasource-types.js.map +1 -1
- package/lib/env.d.js +12 -0
- package/lib/env.d.js.map +1 -1
- package/lib/getPluginModule.d.ts.map +1 -1
- package/lib/getPluginModule.js +12 -0
- package/lib/getPluginModule.js.map +1 -1
- package/lib/index-federation.js +12 -0
- package/lib/index-federation.js.map +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +12 -0
- package/lib/index.js.map +1 -1
- package/lib/model/index.js +1 -1
- package/lib/model/index.js.map +1 -1
- package/lib/model/loki-client-types.js +1 -1
- package/lib/model/loki-client-types.js.map +1 -1
- package/lib/model/loki-client.js +1 -1
- package/lib/model/loki-client.js.map +1 -1
- package/lib/model/loki-data-types.js +1 -1
- package/lib/model/loki-data-types.js.map +1 -1
- package/lib/model/loki-selectors.js +1 -1
- package/lib/model/loki-selectors.js.map +1 -1
- package/lib/queries/constants.d.ts.map +1 -1
- package/lib/queries/constants.js +12 -0
- package/lib/queries/constants.js.map +1 -1
- package/lib/queries/index.js +1 -1
- package/lib/queries/index.js.map +1 -1
- package/lib/queries/loki-log-query/LokiLogQuery.d.ts.map +1 -1
- package/lib/queries/loki-log-query/LokiLogQuery.js +12 -0
- package/lib/queries/loki-log-query/LokiLogQuery.js.map +1 -1
- package/lib/queries/loki-log-query/LokiLogQueryEditor.js +1 -1
- package/lib/queries/loki-log-query/LokiLogQueryEditor.js.map +1 -1
- package/lib/queries/loki-log-query/get-loki-log-data.d.ts.map +1 -1
- package/lib/queries/loki-log-query/get-loki-log-data.js +12 -0
- package/lib/queries/loki-log-query/get-loki-log-data.js.map +1 -1
- package/lib/queries/loki-log-query/index.d.ts.map +1 -1
- package/lib/queries/loki-log-query/index.js +12 -0
- package/lib/queries/loki-log-query/index.js.map +1 -1
- package/lib/queries/loki-log-query/log-query-plugin-interface.d.ts.map +1 -1
- package/lib/queries/loki-log-query/log-query-plugin-interface.js +12 -0
- package/lib/queries/loki-log-query/log-query-plugin-interface.js.map +1 -1
- package/lib/queries/loki-log-query/loki-log-query-types.d.ts.map +1 -1
- package/lib/queries/loki-log-query/loki-log-query-types.js +12 -0
- package/lib/queries/loki-log-query/loki-log-query-types.js.map +1 -1
- package/lib/queries/loki-time-series-query/LokiTimeSeriesQuery.js +1 -1
- package/lib/queries/loki-time-series-query/LokiTimeSeriesQuery.js.map +1 -1
- package/lib/queries/loki-time-series-query/LokiTimeSeriesQueryEditor.js +1 -1
- package/lib/queries/loki-time-series-query/LokiTimeSeriesQueryEditor.js.map +1 -1
- package/lib/queries/loki-time-series-query/get-loki-time-series-data.js +1 -1
- package/lib/queries/loki-time-series-query/get-loki-time-series-data.js.map +1 -1
- package/lib/queries/loki-time-series-query/index.js +1 -1
- package/lib/queries/loki-time-series-query/index.js.map +1 -1
- package/lib/queries/loki-time-series-query/loki-time-series-query-types.js +1 -1
- package/lib/queries/loki-time-series-query/loki-time-series-query-types.js.map +1 -1
- package/lib/queries/query-editor-model.js +1 -1
- package/lib/queries/query-editor-model.js.map +1 -1
- package/lib/setup-tests.d.ts.map +1 -1
- package/lib/setup-tests.js +12 -0
- package/lib/setup-tests.js.map +1 -1
- package/mf-manifest.json +46 -46
- package/mf-stats.json +46 -46
- package/package.json +6 -6
- package/__mf/js/async/1490.5aa6cbcc.js +0 -22
- package/__mf/js/async/1501.f1011a16.js +0 -1
- package/__mf/js/async/1728.516fcaaf.js +0 -1
- package/__mf/js/async/3849.89f86737.js +0 -7
- package/__mf/js/async/392.c0f9d49a.js +0 -2
- package/__mf/js/async/5440.3fedd5ea.js +0 -2
- package/__mf/js/async/5501.929e6257.js +0 -2
- package/__mf/js/async/6498.903f2a94.js +0 -2
- package/__mf/js/async/8035.8dab4893.js +0 -38
- package/__mf/js/async/9389.a8ea42a0.js +0 -2
- /package/__mf/js/async/{392.c0f9d49a.js.LICENSE.txt → 392.2c7c202d.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{1490.5aa6cbcc.js.LICENSE.txt → 54.b3492a7a.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{6498.903f2a94.js.LICENSE.txt → 6710.a94fd362.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{3849.89f86737.js.LICENSE.txt → 7958.f25f7332.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{5501.929e6257.js.LICENSE.txt → 9010.44bf2927.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{9389.a8ea42a0.js.LICENSE.txt → 9389.29616aa6.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{__federation_expose_LokiDatasource.44ac1fa6.js.LICENSE.txt → __federation_expose_LokiDatasource.3fe6141d.js.LICENSE.txt} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copyright
|
|
1
|
+
// Copyright The Perses Authors
|
|
2
2
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
3
|
// you may not use this file except in compliance with the License.
|
|
4
4
|
// You may obtain a copy of the License at
|
|
@@ -34,12 +34,13 @@ _export(exports, {
|
|
|
34
34
|
const _autocomplete = require("@codemirror/autocomplete");
|
|
35
35
|
const _language = require("@codemirror/language");
|
|
36
36
|
const _lezerlogql = require("@grafana/lezer-logql");
|
|
37
|
-
const
|
|
37
|
+
const _model = require("../model");
|
|
38
38
|
const quoteChars = [
|
|
39
39
|
'"',
|
|
40
40
|
'`'
|
|
41
41
|
];
|
|
42
42
|
const defaultQuoteChar = '"';
|
|
43
|
+
const ERROR_NODE = 0; // Lezer parser creates error nodes for incomplete/malformed syntax
|
|
43
44
|
async function complete(completionCfg, { state, pos }) {
|
|
44
45
|
// First, identify the completion scope
|
|
45
46
|
const completion = identifyCompletion(state, pos, (0, _language.syntaxTree)(state));
|
|
@@ -57,12 +58,98 @@ async function complete(completionCfg, { state, pos }) {
|
|
|
57
58
|
}
|
|
58
59
|
function identifyCompletion(state, pos, tree) {
|
|
59
60
|
const node = tree.resolveInner(pos, -1);
|
|
61
|
+
switch(node.type.id){
|
|
62
|
+
case _lezerlogql.Selector:
|
|
63
|
+
case _lezerlogql.Matchers:
|
|
64
|
+
case _lezerlogql.Matcher:
|
|
65
|
+
case _lezerlogql.Identifier:
|
|
66
|
+
case _lezerlogql.Eq:
|
|
67
|
+
case _lezerlogql.Neq:
|
|
68
|
+
case _lezerlogql.Re:
|
|
69
|
+
case _lezerlogql.Nre:
|
|
70
|
+
case _lezerlogql.String:
|
|
71
|
+
{
|
|
72
|
+
const labelCompletion = detectLabelCompletion(state, pos, node);
|
|
73
|
+
if (labelCompletion) return labelCompletion;
|
|
74
|
+
break;
|
|
75
|
+
}
|
|
76
|
+
case ERROR_NODE:
|
|
77
|
+
{
|
|
78
|
+
// Check for pipe context first
|
|
79
|
+
const pipeCompletion = detectPipeCompletion(state, node);
|
|
80
|
+
if (pipeCompletion) return pipeCompletion;
|
|
81
|
+
// Then check for label completion in error nodes
|
|
82
|
+
const labelCompletion = detectLabelCompletion(state, pos, node);
|
|
83
|
+
if (labelCompletion) return labelCompletion;
|
|
84
|
+
break;
|
|
85
|
+
}
|
|
86
|
+
case _lezerlogql.Pipe:
|
|
87
|
+
{
|
|
88
|
+
// Pipe operator: suggest parser functions and line filters
|
|
89
|
+
// Examples: {job="nginx"} |▯ or {job="nginx"} | ▯
|
|
90
|
+
const hasSpaceAfterPipe = state.sliceDoc(pos - 1, pos) === ' ';
|
|
91
|
+
return {
|
|
92
|
+
scope: {
|
|
93
|
+
kind: 'PipeFunction',
|
|
94
|
+
afterPipe: true,
|
|
95
|
+
hasSpace: hasSpaceAfterPipe,
|
|
96
|
+
afterExclamation: false
|
|
97
|
+
},
|
|
98
|
+
from: pos
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
// Fallback checks for contexts not directly on a node
|
|
103
|
+
const textBeforeCursor = state.sliceDoc(0, pos).trim();
|
|
104
|
+
const hasSpace = state.sliceDoc(pos - 1, pos).match(/\s/) !== null;
|
|
105
|
+
// Check if cursor is after a pipe operator followed by whitespace
|
|
106
|
+
// This enables autocomplete after: {job="nginx"} | ▯
|
|
107
|
+
if (textBeforeCursor.endsWith('|') && hasSpace) {
|
|
108
|
+
return {
|
|
109
|
+
scope: {
|
|
110
|
+
kind: 'PipeFunction',
|
|
111
|
+
afterPipe: true,
|
|
112
|
+
hasSpace: true,
|
|
113
|
+
afterExclamation: false
|
|
114
|
+
},
|
|
115
|
+
from: pos
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
// Check if cursor is after a closing brace (stream selector) followed by whitespace
|
|
119
|
+
// This enables autocomplete after: {job="nginx"} ▯
|
|
120
|
+
if (textBeforeCursor.endsWith('}') && hasSpace) {
|
|
121
|
+
return {
|
|
122
|
+
scope: {
|
|
123
|
+
kind: 'PipeFunction',
|
|
124
|
+
afterPipe: false,
|
|
125
|
+
hasSpace: true,
|
|
126
|
+
afterExclamation: false
|
|
127
|
+
},
|
|
128
|
+
from: pos
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Retrieve completion options based on the identified completion scope.
|
|
134
|
+
*/ async function retrieveOptions(completionCfg, completion) {
|
|
135
|
+
switch(completion.kind){
|
|
136
|
+
case 'LabelName':
|
|
137
|
+
return completeLabelName(completionCfg);
|
|
138
|
+
case 'LabelValue':
|
|
139
|
+
return completeLabelValue(completionCfg, completion.label);
|
|
140
|
+
case 'PipeFunction':
|
|
141
|
+
return completePipeFunctions(completion.afterPipe, completion.hasSpace, completion.afterExclamation);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Detect label name or value completion contexts within selectors.
|
|
146
|
+
*/ function detectLabelCompletion(state, pos, node) {
|
|
60
147
|
switch(node.type.id){
|
|
61
148
|
case _lezerlogql.Selector:
|
|
62
149
|
// Selector is the entire {label matchers} expression
|
|
63
150
|
// Autocomplete at start: {▯ or empty: {}
|
|
64
151
|
// Do not autocomplete if cursor is after closing brace: {job="mysql"}▯
|
|
65
|
-
if ((node.firstChild === null || node.firstChild?.type.id ===
|
|
152
|
+
if ((node.firstChild === null || node.firstChild?.type.id === ERROR_NODE) && !state.sliceDoc(node.from, pos).includes('}')) {
|
|
66
153
|
return {
|
|
67
154
|
scope: {
|
|
68
155
|
kind: 'LabelName'
|
|
@@ -147,7 +234,7 @@ function identifyCompletion(state, pos, tree) {
|
|
|
147
234
|
}
|
|
148
235
|
}
|
|
149
236
|
break;
|
|
150
|
-
case
|
|
237
|
+
case ERROR_NODE:
|
|
151
238
|
// Error nodes represent incomplete or malformed syntax
|
|
152
239
|
// Autocomplete incomplete value after operator: { job=mys▯ or { job="mys▯
|
|
153
240
|
if ((node.prevSibling?.type.id === _lezerlogql.Eq || node.prevSibling?.type.id === _lezerlogql.Neq || node.prevSibling?.type.id === _lezerlogql.Re || node.prevSibling?.type.id === _lezerlogql.Nre) && node.parent?.type.id === _lezerlogql.Matcher) {
|
|
@@ -176,23 +263,139 @@ function identifyCompletion(state, pos, tree) {
|
|
|
176
263
|
}
|
|
177
264
|
break;
|
|
178
265
|
}
|
|
266
|
+
return undefined;
|
|
179
267
|
}
|
|
180
268
|
/**
|
|
181
|
-
*
|
|
182
|
-
*/
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
269
|
+
* Detect pipe function completion contexts (line filters, parsers, formatters).
|
|
270
|
+
*/ function detectPipeCompletion(state, node) {
|
|
271
|
+
// Check if we're in an error node right after a pipe operator
|
|
272
|
+
// This handles cases like: {job="nginx"} | !▯
|
|
273
|
+
if (node.prevSibling?.type.id === _lezerlogql.Pipe) {
|
|
274
|
+
return {
|
|
275
|
+
scope: {
|
|
276
|
+
kind: 'PipeFunction',
|
|
277
|
+
afterPipe: true,
|
|
278
|
+
hasSpace: true,
|
|
279
|
+
afterExclamation: false
|
|
280
|
+
},
|
|
281
|
+
from: node.from
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
// Check if we're after selector with space and text starts with !
|
|
285
|
+
// This handles cases like: {job="nginx"} !▯
|
|
286
|
+
const errorText = state.sliceDoc(node.from, node.to);
|
|
287
|
+
if (errorText.startsWith('!')) {
|
|
288
|
+
const textBeforeError = state.sliceDoc(0, node.from).trim();
|
|
289
|
+
if (textBeforeError.endsWith('}')) {
|
|
290
|
+
return {
|
|
291
|
+
scope: {
|
|
292
|
+
kind: 'PipeFunction',
|
|
293
|
+
afterPipe: false,
|
|
294
|
+
hasSpace: true,
|
|
295
|
+
afterExclamation: true
|
|
296
|
+
},
|
|
297
|
+
from: node.from
|
|
298
|
+
};
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
return undefined;
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* Complete LogQL pipe functions, line filters, and parser functions.
|
|
305
|
+
* Context-aware suggestions based on LogQL syntax:
|
|
306
|
+
* - After "{} ": Show all line filters (|=, !=, |~, !~) + parsers (with | prefix)
|
|
307
|
+
* - After "{} !": Show ONLY != and !~
|
|
308
|
+
* - After "{} |": Show only pipe-based filters WITHOUT the | (=, ~) + parsers
|
|
309
|
+
* - After "{} | ": Show ONLY parsers, NO line filters
|
|
310
|
+
*/ function completePipeFunctions(afterPipe, hasSpace, afterExclamation) {
|
|
311
|
+
const completions = [];
|
|
312
|
+
// Line filter operators that START with pipe: |= and |~
|
|
313
|
+
const pipeLineFilters = [
|
|
314
|
+
{
|
|
315
|
+
operator: '|=',
|
|
316
|
+
detail: 'Line contains'
|
|
317
|
+
},
|
|
318
|
+
{
|
|
319
|
+
operator: '|~',
|
|
320
|
+
detail: 'Line matches regex'
|
|
321
|
+
}
|
|
322
|
+
];
|
|
323
|
+
// Line filter operators that DON'T start with pipe: != and !~
|
|
324
|
+
const nonPipeLineFilters = [
|
|
325
|
+
{
|
|
326
|
+
operator: '!=',
|
|
327
|
+
detail: 'Line does not contain'
|
|
328
|
+
},
|
|
329
|
+
{
|
|
330
|
+
operator: '!~',
|
|
331
|
+
detail: 'Line does not match regex'
|
|
332
|
+
}
|
|
333
|
+
];
|
|
334
|
+
// Context: After "{} !" - Show ONLY != and !~
|
|
335
|
+
if (afterExclamation) {
|
|
336
|
+
nonPipeLineFilters.forEach(({ operator, detail })=>{
|
|
337
|
+
completions.push(createLineFilterCompletion(operator, detail));
|
|
338
|
+
});
|
|
339
|
+
return completions; // Don't show parsers after !
|
|
340
|
+
}
|
|
341
|
+
// Context 1: After "{} | " (pipe + space) - ONLY parsers, NO line filters
|
|
342
|
+
if (afterPipe && hasSpace) {
|
|
343
|
+
// Don't show any line filters
|
|
344
|
+
} else if (afterPipe && !hasSpace) {
|
|
345
|
+
pipeLineFilters.forEach(({ operator, detail })=>{
|
|
346
|
+
// Strip the | since user already typed it
|
|
347
|
+
const strippedOp = operator.replace('|', '');
|
|
348
|
+
completions.push(createLineFilterCompletion(strippedOp, detail));
|
|
349
|
+
});
|
|
350
|
+
} else {
|
|
351
|
+
[
|
|
352
|
+
...pipeLineFilters,
|
|
353
|
+
...nonPipeLineFilters
|
|
354
|
+
].forEach(({ operator, detail })=>{
|
|
355
|
+
completions.push(createLineFilterCompletion(operator, detail));
|
|
356
|
+
});
|
|
188
357
|
}
|
|
358
|
+
// Parser functions and pipe operations: always show
|
|
359
|
+
// Add pipe prefix when not after pipe (e.g., "{} " needs "| json" not " json")
|
|
360
|
+
const parserPrefix = !afterPipe ? '| ' : hasSpace ? '' : ' ';
|
|
361
|
+
// Parsing expressions: Extract structured data
|
|
362
|
+
const parsingExpressions = [
|
|
363
|
+
'json',
|
|
364
|
+
'logfmt',
|
|
365
|
+
'pattern',
|
|
366
|
+
'regexp',
|
|
367
|
+
'unpack',
|
|
368
|
+
'unwrap'
|
|
369
|
+
];
|
|
370
|
+
parsingExpressions.forEach((parser)=>{
|
|
371
|
+
completions.push({
|
|
372
|
+
label: `${parserPrefix}${parser}`,
|
|
373
|
+
type: 'function',
|
|
374
|
+
boost: 5
|
|
375
|
+
});
|
|
376
|
+
});
|
|
377
|
+
// Formatting and labels expressions: Format output and manipulate labels
|
|
378
|
+
const formattingAndLabels = [
|
|
379
|
+
'line_format',
|
|
380
|
+
'label_format',
|
|
381
|
+
'decolorize',
|
|
382
|
+
'drop',
|
|
383
|
+
'keep'
|
|
384
|
+
];
|
|
385
|
+
formattingAndLabels.forEach((expr)=>{
|
|
386
|
+
completions.push({
|
|
387
|
+
label: `${parserPrefix}${expr}`,
|
|
388
|
+
type: 'method'
|
|
389
|
+
});
|
|
390
|
+
});
|
|
391
|
+
return completions;
|
|
189
392
|
}
|
|
190
393
|
async function completeLabelName(completionCfg) {
|
|
191
394
|
if (!completionCfg.client) {
|
|
192
395
|
return [];
|
|
193
396
|
}
|
|
194
|
-
const start = completionCfg.timeRange?.start ? (0,
|
|
195
|
-
const end = completionCfg.timeRange?.end ? (0,
|
|
397
|
+
const start = completionCfg.timeRange?.start ? (0, _model.toUnixSeconds)(new Date(completionCfg.timeRange.start).getTime()) : undefined;
|
|
398
|
+
const end = completionCfg.timeRange?.end ? (0, _model.toUnixSeconds)(new Date(completionCfg.timeRange.end).getTime()) : undefined;
|
|
196
399
|
try {
|
|
197
400
|
const response = await completionCfg.client.labels(start, end);
|
|
198
401
|
if (response.status === 'success') {
|
|
@@ -206,6 +409,50 @@ async function completeLabelName(completionCfg) {
|
|
|
206
409
|
return [];
|
|
207
410
|
}
|
|
208
411
|
}
|
|
412
|
+
async function completeLabelValue(completionCfg, label) {
|
|
413
|
+
if (!completionCfg.client) {
|
|
414
|
+
return [];
|
|
415
|
+
}
|
|
416
|
+
const start = completionCfg.timeRange?.start ? (0, _model.toUnixSeconds)(new Date(completionCfg.timeRange.start).getTime()) : undefined;
|
|
417
|
+
const end = completionCfg.timeRange?.end ? (0, _model.toUnixSeconds)(new Date(completionCfg.timeRange.end).getTime()) : undefined;
|
|
418
|
+
try {
|
|
419
|
+
const response = await completionCfg.client.labelValues(label, start, end);
|
|
420
|
+
if (response.status === 'success') {
|
|
421
|
+
return response.data.map((value)=>({
|
|
422
|
+
label: value ?? '',
|
|
423
|
+
displayLabel: value ?? '(empty string)',
|
|
424
|
+
apply: applyQuotedCompletion
|
|
425
|
+
}));
|
|
426
|
+
}
|
|
427
|
+
return [];
|
|
428
|
+
} catch (error) {
|
|
429
|
+
console.error(`Error fetching values for label ${label}:`, error);
|
|
430
|
+
return [];
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
/**
|
|
434
|
+
* Create a line filter completion with consistent cursor positioning.
|
|
435
|
+
*/ function createLineFilterCompletion(operator, detail) {
|
|
436
|
+
return {
|
|
437
|
+
label: `${operator} ""`,
|
|
438
|
+
detail,
|
|
439
|
+
apply: (view, _completion, from, to)=>{
|
|
440
|
+
const insert = `${operator} ""`;
|
|
441
|
+
view.dispatch({
|
|
442
|
+
changes: {
|
|
443
|
+
from,
|
|
444
|
+
to,
|
|
445
|
+
insert
|
|
446
|
+
},
|
|
447
|
+
selection: {
|
|
448
|
+
anchor: from + insert.length - 1
|
|
449
|
+
}
|
|
450
|
+
});
|
|
451
|
+
},
|
|
452
|
+
type: 'text',
|
|
453
|
+
boost: 10
|
|
454
|
+
};
|
|
455
|
+
}
|
|
209
456
|
function escapeString(input, quoteChar) {
|
|
210
457
|
// do not escape raw strings (when using backticks)
|
|
211
458
|
if (quoteChar === '`') {
|
|
@@ -235,24 +482,3 @@ function applyQuotedCompletion(view, completion, from, to) {
|
|
|
235
482
|
const insertText = `${quoteChar}${escapeString(completion.label, quoteChar)}${quoteChar}`;
|
|
236
483
|
view.dispatch((0, _autocomplete.insertCompletionText)(view.state, insertText, from, to));
|
|
237
484
|
}
|
|
238
|
-
async function completeLabelValue(completionCfg, label) {
|
|
239
|
-
if (!completionCfg.client) {
|
|
240
|
-
return [];
|
|
241
|
-
}
|
|
242
|
-
const start = completionCfg.timeRange?.start ? (0, _lokiclient.toUnixSeconds)(new Date(completionCfg.timeRange.start).getTime()) : undefined;
|
|
243
|
-
const end = completionCfg.timeRange?.end ? (0, _lokiclient.toUnixSeconds)(new Date(completionCfg.timeRange.end).getTime()) : undefined;
|
|
244
|
-
try {
|
|
245
|
-
const response = await completionCfg.client.labelValues(label, start, end);
|
|
246
|
-
if (response.status === 'success') {
|
|
247
|
-
return response.data.map((value)=>({
|
|
248
|
-
label: value ?? '',
|
|
249
|
-
displayLabel: value ?? '(empty string)',
|
|
250
|
-
apply: applyQuotedCompletion
|
|
251
|
-
}));
|
|
252
|
-
}
|
|
253
|
-
return [];
|
|
254
|
-
} catch (error) {
|
|
255
|
-
console.error(`Error fetching values for label ${label}:`, error);
|
|
256
|
-
return [];
|
|
257
|
-
}
|
|
258
|
-
}
|
package/lib/cjs/env.d.js
CHANGED
|
@@ -1,2 +1,14 @@
|
|
|
1
|
+
// Copyright The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the \"License\");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an \"AS IS\" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
1
13
|
/// <reference types="@rsbuild/core/types" />
|
|
2
14
|
"use strict";
|
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
// Copyright The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the \"License\");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an \"AS IS\" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
1
13
|
"use strict";
|
|
2
14
|
Object.defineProperty(exports, "__esModule", {
|
|
3
15
|
value: true
|
|
@@ -40,4 +40,16 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
40
40
|
}
|
|
41
41
|
return newObj;
|
|
42
42
|
}
|
|
43
|
+
// Copyright The Perses Authors
|
|
44
|
+
// Licensed under the Apache License, Version 2.0 (the \"License\");
|
|
45
|
+
// you may not use this file except in compliance with the License.
|
|
46
|
+
// You may obtain a copy of the License at
|
|
47
|
+
//
|
|
48
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
49
|
+
//
|
|
50
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
51
|
+
// distributed under the License is distributed on an \"AS IS\" BASIS,
|
|
52
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
53
|
+
// See the License for the specific language governing permissions and
|
|
54
|
+
// limitations under the License.
|
|
43
55
|
Promise.resolve().then(()=>/*#__PURE__*/ _interop_require_wildcard(require("./bootstrap")));
|
package/lib/cjs/index.js
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
// Copyright The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the \"License\");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an \"AS IS\" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
1
13
|
"use strict";
|
|
2
14
|
Object.defineProperty(exports, "__esModule", {
|
|
3
15
|
value: true
|
package/lib/cjs/model/index.js
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
// Copyright The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the \"License\");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an \"AS IS\" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
1
13
|
"use strict";
|
|
2
14
|
Object.defineProperty(exports, "__esModule", {
|
|
3
15
|
value: true
|
package/lib/cjs/queries/index.js
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
// Copyright The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the \"License\");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an \"AS IS\" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
1
13
|
"use strict";
|
|
2
14
|
Object.defineProperty(exports, "__esModule", {
|
|
3
15
|
value: true
|
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
// Copyright The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the \"License\");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an \"AS IS\" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
1
13
|
"use strict";
|
|
2
14
|
Object.defineProperty(exports, "__esModule", {
|
|
3
15
|
value: true
|
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
// Copyright The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the \"License\");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an \"AS IS\" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
1
13
|
"use strict";
|
|
2
14
|
Object.defineProperty(exports, "__esModule", {
|
|
3
15
|
value: true
|
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
// Copyright The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the \"License\");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an \"AS IS\" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
1
13
|
"use strict";
|
|
2
14
|
Object.defineProperty(exports, "__esModule", {
|
|
3
15
|
value: true
|
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
// Copyright The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the \"License\");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an \"AS IS\" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
1
13
|
"use strict";
|
|
2
14
|
Object.defineProperty(exports, "__esModule", {
|
|
3
15
|
value: true
|