@tellaro/tql 1.3.8 → 1.4.1
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/dist/index.js +44 -41
- package/dist/node_modules/@kurkle/color/dist/color.esm.js +442 -0
- package/dist/node_modules/chart.js/dist/chart.js +6149 -0
- package/dist/node_modules/chart.js/dist/chunks/helpers.dataset.js +1685 -0
- package/dist/node_modules/chartjs-adapter-luxon/dist/chartjs-adapter-luxon.esm.js +56 -0
- package/dist/node_modules/chartjs-plugin-datalabels/dist/chartjs-plugin-datalabels.esm.js +607 -0
- package/dist/node_modules/luxon/build/es6/luxon.js +5524 -0
- package/dist/src/builder.d.ts +62 -0
- package/dist/src/builder.js +56 -0
- package/dist/src/chart/colors.d.ts +23 -0
- package/dist/src/chart/colors.js +101 -0
- package/dist/src/chart/formatters.d.ts +17 -0
- package/dist/src/chart/formatters.js +49 -0
- package/dist/src/chart/index.d.ts +9 -0
- package/dist/src/chart/index.js +31 -0
- package/dist/src/chart/mappers.d.ts +849 -0
- package/dist/src/chart/mappers.js +613 -0
- package/dist/src/completionProvider.js +294 -165
- package/dist/src/index.d.ts +2 -1
- package/dist/src/parser.d.ts +10 -0
- package/dist/src/parser.js +41 -9
- package/dist/src/semanticPreview.d.ts +1 -1
- package/dist/src/tokenizer.js +124 -103
- package/dist/src/types.d.ts +27 -3
- package/dist/src/validator.js +37 -10
- package/dist/tql.css +1 -1
- package/dist/vue/TqlChart.vue.d.ts +2 -0
- package/dist/vue/TqlChart.vue.js +7 -0
- package/dist/vue/TqlChart.vue2.js +208 -0
- package/dist/vue/components/TqlPreview.vue.js +4 -4
- package/dist/vue/index.d.ts +1 -0
- package/dist/vue/index.js +12 -10
- package/dist/vue/useTqlInput.d.ts +54 -0
- package/dist/vue/useTqlInput.js +80 -80
- package/package.json +39 -3
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { tokenizeTql as x, COMPARISON_OPERATORS as
|
|
1
|
+
import { tokenizeTql as x, COMPARISON_OPERATORS as S, LOGICAL_OPERATORS as N, AGGREGATION_FUNCTIONS as I, VISUALIZATION_TYPES as L, TYPE_HINTS as A, MUTATORS as R } from "./tokenizer.js";
|
|
2
2
|
import { fuzzyMatch as w } from "./fuzzyMatcher.js";
|
|
3
3
|
import { getSchemaCache as $ } from "./schemaCache.js";
|
|
4
4
|
const P = [
|
|
@@ -167,7 +167,7 @@ const P = [
|
|
|
167
167
|
sum: { detail: "Sum", documentation: "Sum of numeric array elements" },
|
|
168
168
|
min: { detail: "Minimum", documentation: "Minimum value in array" },
|
|
169
169
|
max: { detail: "Maximum", documentation: "Maximum value in array" }
|
|
170
|
-
},
|
|
170
|
+
}, h = {
|
|
171
171
|
// String outputs
|
|
172
172
|
lowercase: "keyword",
|
|
173
173
|
uppercase: "keyword",
|
|
@@ -201,7 +201,7 @@ const P = [
|
|
|
201
201
|
geo: "object",
|
|
202
202
|
// Array output (returns array of strings)
|
|
203
203
|
split: "keyword"
|
|
204
|
-
},
|
|
204
|
+
}, z = {
|
|
205
205
|
// Universal operators (work with all types)
|
|
206
206
|
eq: ["text", "keyword", "long", "integer", "double", "float", "date", "boolean", "ip"],
|
|
207
207
|
ne: ["text", "keyword", "long", "integer", "double", "float", "date", "boolean", "ip"],
|
|
@@ -238,186 +238,267 @@ const P = [
|
|
|
238
238
|
all: ["nested", "object", "keyword"],
|
|
239
239
|
none: ["nested", "object", "keyword"]
|
|
240
240
|
};
|
|
241
|
-
class
|
|
241
|
+
class E {
|
|
242
242
|
cache = /* @__PURE__ */ new Map();
|
|
243
243
|
maxSize = 50;
|
|
244
244
|
maxAge = 5e3;
|
|
245
245
|
// 5 seconds
|
|
246
246
|
get(t) {
|
|
247
|
-
const
|
|
248
|
-
if (
|
|
249
|
-
return
|
|
250
|
-
|
|
247
|
+
const i = this.cache.get(t);
|
|
248
|
+
if (i && Date.now() - i.timestamp < this.maxAge)
|
|
249
|
+
return i.result;
|
|
250
|
+
i && this.cache.delete(t);
|
|
251
251
|
}
|
|
252
|
-
set(t,
|
|
252
|
+
set(t, i) {
|
|
253
253
|
if (this.cache.size >= this.maxSize) {
|
|
254
|
-
const
|
|
255
|
-
|
|
254
|
+
const o = this.cache.keys().next().value;
|
|
255
|
+
o && this.cache.delete(o);
|
|
256
256
|
}
|
|
257
|
-
this.cache.set(t, { result:
|
|
257
|
+
this.cache.set(t, { result: i, timestamp: Date.now() });
|
|
258
258
|
}
|
|
259
259
|
clear() {
|
|
260
260
|
this.cache.clear();
|
|
261
261
|
}
|
|
262
262
|
}
|
|
263
|
-
const v = new
|
|
264
|
-
function
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
263
|
+
const v = new E();
|
|
264
|
+
function U(e, t, i) {
|
|
265
|
+
if (!e) return { type: "start", partialText: "" };
|
|
266
|
+
const o = `${e.substring(0, t)}|${t}`, a = v.get(o);
|
|
267
|
+
if (a)
|
|
268
|
+
return a.fieldName && !a.fieldType && i && (a.fieldType = p(a.fieldName, i)), a;
|
|
269
|
+
const n = F(e, t, i);
|
|
270
|
+
return v.set(o, n), n;
|
|
270
271
|
}
|
|
271
|
-
function F(e, t,
|
|
272
|
-
const
|
|
273
|
-
if (
|
|
272
|
+
function F(e, t, i) {
|
|
273
|
+
const a = x(e.substring(0, t)).filter((l) => l.type !== "whitespace");
|
|
274
|
+
if (a.length === 0)
|
|
274
275
|
return { type: "start" };
|
|
275
|
-
const n =
|
|
276
|
+
const n = a[a.length - 1], s = a.length > 1 ? a[a.length - 2] : null, u = n.end === t && !e[t - 1]?.match(/\s/), d = u ? n.value : void 0;
|
|
276
277
|
if (n.type === "logicalOp")
|
|
277
278
|
return { type: "start" };
|
|
279
|
+
if (n.type === "paren" && n.value === "(") {
|
|
280
|
+
const l = a.length - 1, r = l > 0 ? a[l - 1] : null;
|
|
281
|
+
if (r && r.type === "visualization")
|
|
282
|
+
return { type: "in_viz_params" };
|
|
283
|
+
}
|
|
284
|
+
if (n.type === "comma" || n.type === "field" && u) {
|
|
285
|
+
const l = a.indexOf(n);
|
|
286
|
+
for (let r = l - 1; r >= 0; r--) {
|
|
287
|
+
if (a[r].type === "paren" && a[r].value === "(") {
|
|
288
|
+
if (r > 0 && a[r - 1].type === "visualization")
|
|
289
|
+
return { type: "in_viz_params", partialText: d };
|
|
290
|
+
break;
|
|
291
|
+
}
|
|
292
|
+
if (a[r].type === "paren" && a[r].value === ")") break;
|
|
293
|
+
}
|
|
294
|
+
}
|
|
278
295
|
if (n.type === "paren" && n.value === "(")
|
|
279
296
|
return { type: "after_paren" };
|
|
280
297
|
if (n.type === "arrow")
|
|
281
|
-
return { type: "after_arrow", partialText:
|
|
298
|
+
return { type: "after_arrow", partialText: d };
|
|
282
299
|
if (n.type === "doubleColon")
|
|
283
|
-
return { type: "after_double_colon", partialText:
|
|
284
|
-
if (n.type === "visualization" &&
|
|
285
|
-
return { type: "after_arrow", partialText:
|
|
286
|
-
if (n.type === "typeHint" &&
|
|
287
|
-
return { type: "after_double_colon", partialText:
|
|
300
|
+
return { type: "after_double_colon", partialText: d };
|
|
301
|
+
if (n.type === "visualization" && u)
|
|
302
|
+
return { type: "after_arrow", partialText: d };
|
|
303
|
+
if (n.type === "typeHint" && u)
|
|
304
|
+
return { type: "after_double_colon", partialText: d };
|
|
288
305
|
if (n.type === "keyword" && n.value.toLowerCase() === "stats")
|
|
289
|
-
return { type: "after_stats", partialText:
|
|
306
|
+
return { type: "after_stats", partialText: d };
|
|
290
307
|
if (n.type === "keyword" && n.value.toLowerCase() === "by")
|
|
291
|
-
return { type: "after_by", partialText:
|
|
308
|
+
return { type: "after_by", partialText: d };
|
|
309
|
+
if (n.type === "paren" && n.value === ")") {
|
|
310
|
+
const l = a.indexOf(n);
|
|
311
|
+
for (let r = l - 1; r >= 0; r--) {
|
|
312
|
+
if (a[r].type === "keyword" && a[r].value.toLowerCase() === "stats")
|
|
313
|
+
return { type: "after_stats_agg" };
|
|
314
|
+
if (a[r].type === "keyword" && a[r].value.toLowerCase() === "by" || a[r].type === "pipe") break;
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
if (n.type === "field" && !u) {
|
|
318
|
+
const l = a.indexOf(n);
|
|
319
|
+
for (let r = l - 1; r >= 0; r--) {
|
|
320
|
+
if (a[r].type === "keyword" && a[r].value.toLowerCase() === "by") {
|
|
321
|
+
for (let c = r - 1; c >= 0; c--) {
|
|
322
|
+
if (a[c].type === "keyword" && a[c].value.toLowerCase() === "stats")
|
|
323
|
+
return { type: "after_group_by_field" };
|
|
324
|
+
if (a[c].type === "pipe") break;
|
|
325
|
+
}
|
|
326
|
+
break;
|
|
327
|
+
}
|
|
328
|
+
if (a[r].type === "pipe") break;
|
|
329
|
+
}
|
|
330
|
+
}
|
|
292
331
|
if (n.type === "pipe")
|
|
293
|
-
return { type: "after_pipe", partialText:
|
|
332
|
+
return { type: "after_pipe", partialText: d };
|
|
294
333
|
if (n.type === "mutator") {
|
|
295
|
-
if (
|
|
296
|
-
return { type: "after_pipe", partialText:
|
|
297
|
-
const
|
|
334
|
+
if (u)
|
|
335
|
+
return { type: "after_pipe", partialText: d };
|
|
336
|
+
const l = n.value.toLowerCase(), r = h[l];
|
|
298
337
|
return {
|
|
299
338
|
type: "after_mutator",
|
|
300
|
-
mutatorName:
|
|
301
|
-
mutatorOutputType:
|
|
339
|
+
mutatorName: l,
|
|
340
|
+
mutatorOutputType: r
|
|
302
341
|
};
|
|
303
342
|
}
|
|
304
343
|
if (n.type === "aggregation")
|
|
305
|
-
return
|
|
344
|
+
return u ? { type: "after_stats", partialText: d } : { type: "after_value" };
|
|
306
345
|
if (n.type === "field") {
|
|
307
|
-
if (
|
|
308
|
-
return s?.type === "pipe" ? { type: "after_pipe", partialText:
|
|
346
|
+
if (u)
|
|
347
|
+
return s?.type === "pipe" ? { type: "after_pipe", partialText: d } : { type: "start", partialText: d };
|
|
309
348
|
if (s?.type === "pipe")
|
|
310
349
|
return { type: "after_pipe", partialText: n.value };
|
|
311
|
-
const
|
|
312
|
-
return { type: "after_field", fieldName: n.value, fieldType:
|
|
350
|
+
const l = p(n.value, i);
|
|
351
|
+
return { type: "after_field", fieldName: n.value, fieldType: l };
|
|
313
352
|
}
|
|
314
353
|
if (n.type === "operator") {
|
|
315
|
-
if (
|
|
354
|
+
if (u) {
|
|
316
355
|
if (s?.type === "field") {
|
|
317
|
-
const
|
|
318
|
-
return { type: "after_field", fieldName: s.value, fieldType:
|
|
356
|
+
const l = p(s.value, i);
|
|
357
|
+
return { type: "after_field", fieldName: s.value, fieldType: l, partialText: d };
|
|
319
358
|
}
|
|
320
359
|
if (s?.type === "mutator") {
|
|
321
|
-
const
|
|
322
|
-
return { type: "after_mutator", mutatorName:
|
|
360
|
+
const l = s.value.toLowerCase(), r = h[l];
|
|
361
|
+
return { type: "after_mutator", mutatorName: l, mutatorOutputType: r, partialText: d };
|
|
323
362
|
}
|
|
324
363
|
}
|
|
325
364
|
return { type: "after_operator", operatorName: n.value };
|
|
326
365
|
}
|
|
327
366
|
if (n.type === "string" || n.type === "number" || n.type === "boolean" || n.type === "null")
|
|
328
|
-
return
|
|
367
|
+
return u ? { type: "at_value_end" } : { type: "after_value" };
|
|
329
368
|
if (n.type === "paren" && n.value === ")")
|
|
330
369
|
return { type: "after_value" };
|
|
331
|
-
if (s?.type === "field" &&
|
|
332
|
-
const
|
|
333
|
-
return { type: "after_field", fieldName: s.value, fieldType:
|
|
370
|
+
if (s?.type === "field" && u) {
|
|
371
|
+
const l = p(s.value, i);
|
|
372
|
+
return { type: "after_field", fieldName: s.value, fieldType: l, partialText: d };
|
|
334
373
|
}
|
|
335
|
-
if (s?.type === "mutator" &&
|
|
336
|
-
const
|
|
337
|
-
return { type: "after_mutator", mutatorName:
|
|
374
|
+
if (s?.type === "mutator" && u) {
|
|
375
|
+
const l = s.value.toLowerCase(), r = h[l];
|
|
376
|
+
return { type: "after_mutator", mutatorName: l, mutatorOutputType: r, partialText: d };
|
|
338
377
|
}
|
|
339
|
-
return { type: "unknown", partialText:
|
|
378
|
+
return { type: "unknown", partialText: d };
|
|
340
379
|
}
|
|
341
380
|
function p(e, t) {
|
|
342
381
|
return t ? $().getFieldType(t, e) : void 0;
|
|
343
382
|
}
|
|
344
|
-
function
|
|
345
|
-
const { query:
|
|
346
|
-
|
|
383
|
+
function Q(e, t = {}) {
|
|
384
|
+
const { query: i, cursorPosition: o } = e;
|
|
385
|
+
if (!i) return [];
|
|
386
|
+
const a = U(i, o, t.fields), n = [];
|
|
387
|
+
switch (a.type) {
|
|
347
388
|
case "start":
|
|
348
389
|
case "after_paren":
|
|
349
|
-
n.push(...
|
|
390
|
+
n.push(...g(t.fields, a.partialText)), n.push(O("NOT")), t.includeSnippets !== !1 && n.push(...B(t, a.partialText));
|
|
350
391
|
break;
|
|
351
392
|
case "after_field":
|
|
352
|
-
n.push(...y(
|
|
393
|
+
n.push(...y(a.partialText, a.fieldType));
|
|
353
394
|
break;
|
|
354
395
|
case "after_mutator":
|
|
355
|
-
n.push(...y(
|
|
396
|
+
n.push(...y(a.partialText, a.mutatorOutputType));
|
|
356
397
|
break;
|
|
357
398
|
case "after_operator":
|
|
358
|
-
n.push(...
|
|
399
|
+
n.push(...j(a.fieldName, t));
|
|
359
400
|
break;
|
|
360
401
|
case "after_value":
|
|
361
|
-
n.push(...
|
|
402
|
+
n.push(..._());
|
|
362
403
|
break;
|
|
363
404
|
case "at_value_end":
|
|
364
405
|
break;
|
|
365
406
|
case "after_pipe":
|
|
366
|
-
n.push(...
|
|
407
|
+
n.push(...V(a.partialText)), (!a.partialText || "stats".includes(a.partialText.toLowerCase())) && n.push({
|
|
408
|
+
label: "stats",
|
|
409
|
+
insertText: "stats ",
|
|
410
|
+
kind: "keyword",
|
|
411
|
+
detail: "Aggregate data with stats functions (count, sum, avg, ...)",
|
|
412
|
+
sortOrder: 1
|
|
413
|
+
// Top of list
|
|
414
|
+
});
|
|
415
|
+
break;
|
|
416
|
+
case "after_stats_agg":
|
|
417
|
+
n.push({
|
|
418
|
+
label: "by",
|
|
419
|
+
insertText: "by ",
|
|
420
|
+
kind: "keyword",
|
|
421
|
+
detail: "Group results by field",
|
|
422
|
+
sortOrder: 1
|
|
423
|
+
}), n.push({
|
|
424
|
+
label: "=>",
|
|
425
|
+
insertText: "=> ",
|
|
426
|
+
kind: "visualization",
|
|
427
|
+
detail: "Set visualization type (bar, pie, line, ...)",
|
|
428
|
+
sortOrder: 2
|
|
429
|
+
});
|
|
430
|
+
break;
|
|
431
|
+
case "after_group_by_field":
|
|
432
|
+
n.push({
|
|
433
|
+
label: "=>",
|
|
434
|
+
insertText: "=> ",
|
|
435
|
+
kind: "visualization",
|
|
436
|
+
detail: "Set visualization type (bar, pie, line, ...)",
|
|
437
|
+
sortOrder: 1
|
|
438
|
+
}), n.push({
|
|
439
|
+
label: ",",
|
|
440
|
+
insertText: ", ",
|
|
441
|
+
kind: "keyword",
|
|
442
|
+
detail: "Add another group-by field",
|
|
443
|
+
sortOrder: 2
|
|
444
|
+
});
|
|
367
445
|
break;
|
|
368
446
|
case "after_double_colon":
|
|
369
|
-
n.push(...H(
|
|
447
|
+
n.push(...H(a.partialText));
|
|
370
448
|
break;
|
|
371
449
|
case "after_arrow":
|
|
372
|
-
n.push(...Y(
|
|
450
|
+
n.push(...Y(a.partialText));
|
|
451
|
+
break;
|
|
452
|
+
case "in_viz_params":
|
|
453
|
+
n.push(...W(a.partialText));
|
|
373
454
|
break;
|
|
374
455
|
case "after_stats":
|
|
375
|
-
n.push(...C(
|
|
456
|
+
n.push(...C(a.partialText));
|
|
376
457
|
break;
|
|
377
458
|
case "after_by":
|
|
378
|
-
n.push(...
|
|
459
|
+
n.push(...g(t.fields, a.partialText));
|
|
379
460
|
break;
|
|
380
461
|
default:
|
|
381
|
-
n.push(...
|
|
462
|
+
n.push(...g(t.fields, a.partialText)), n.push(...y(a.partialText)), n.push(..._());
|
|
382
463
|
}
|
|
383
|
-
t.includeAggregations &&
|
|
464
|
+
t.includeAggregations && a.type === "start" && n.push(...C(a.partialText));
|
|
384
465
|
let s = n;
|
|
385
|
-
const
|
|
386
|
-
if (
|
|
387
|
-
const
|
|
388
|
-
if (
|
|
389
|
-
const
|
|
390
|
-
for (const
|
|
391
|
-
const m = w(
|
|
392
|
-
f.matched && f.score >=
|
|
393
|
-
...
|
|
466
|
+
const u = t.fuzzyMatching !== !1, d = t.minFuzzyScore ?? 0;
|
|
467
|
+
if (a.partialText) {
|
|
468
|
+
const l = a.partialText.toLowerCase();
|
|
469
|
+
if (u) {
|
|
470
|
+
const r = [];
|
|
471
|
+
for (const c of n) {
|
|
472
|
+
const m = w(l, c.label), b = c.filterText ? w(l, c.filterText) : { matched: !1, score: 0 }, f = m.score >= b.score ? m : b;
|
|
473
|
+
f.matched && f.score >= d && r.push({
|
|
474
|
+
...c,
|
|
394
475
|
matchScore: f.score,
|
|
395
476
|
matchedIndices: m.matched ? m.matchedIndices : void 0
|
|
396
477
|
});
|
|
397
478
|
}
|
|
398
|
-
s =
|
|
479
|
+
s = r;
|
|
399
480
|
} else
|
|
400
481
|
s = n.filter(
|
|
401
|
-
(
|
|
482
|
+
(r) => r.label.toLowerCase().includes(l) || r.filterText?.toLowerCase().includes(l)
|
|
402
483
|
);
|
|
403
484
|
}
|
|
404
|
-
return s.sort((
|
|
485
|
+
return s.sort((l, r) => l.matchScore !== void 0 && r.matchScore !== void 0 && r.matchScore !== l.matchScore ? r.matchScore - l.matchScore : l.sortOrder - r.sortOrder), t.maxItems && t.maxItems > 0 && (s = s.slice(0, t.maxItems)), s;
|
|
405
486
|
}
|
|
406
|
-
function
|
|
487
|
+
function g(e, t) {
|
|
407
488
|
if (!e || e.length === 0)
|
|
408
|
-
return
|
|
409
|
-
const
|
|
410
|
-
for (const
|
|
411
|
-
const
|
|
412
|
-
if (
|
|
413
|
-
for (const n of
|
|
414
|
-
const s = k(n,
|
|
415
|
-
|
|
489
|
+
return G(t);
|
|
490
|
+
const i = [];
|
|
491
|
+
for (const o of e) {
|
|
492
|
+
const a = k(o);
|
|
493
|
+
if (i.push(a), o.nested)
|
|
494
|
+
for (const n of o.nested) {
|
|
495
|
+
const s = k(n, o.name);
|
|
496
|
+
i.push(s);
|
|
416
497
|
}
|
|
417
498
|
}
|
|
418
|
-
return
|
|
499
|
+
return i;
|
|
419
500
|
}
|
|
420
|
-
function
|
|
501
|
+
function G(e) {
|
|
421
502
|
return [
|
|
422
503
|
{ name: "hostname", description: "Host/machine name" },
|
|
423
504
|
{ name: "status", description: "Status value" },
|
|
@@ -434,20 +515,20 @@ function q(e) {
|
|
|
434
515
|
{ name: "os.version", description: "Operating system version" },
|
|
435
516
|
{ name: "customer", description: "Customer identifier" },
|
|
436
517
|
{ name: "stack", description: "Stack identifier" }
|
|
437
|
-
].filter((
|
|
438
|
-
label:
|
|
439
|
-
insertText:
|
|
518
|
+
].filter((i) => !e || i.name.toLowerCase().includes(e.toLowerCase())).map((i) => ({
|
|
519
|
+
label: i.name,
|
|
520
|
+
insertText: i.name + " ",
|
|
440
521
|
// Add trailing space for easier operator typing
|
|
441
522
|
kind: "field",
|
|
442
|
-
detail:
|
|
523
|
+
detail: i.description,
|
|
443
524
|
sortOrder: 10
|
|
444
525
|
}));
|
|
445
526
|
}
|
|
446
527
|
function k(e, t) {
|
|
447
|
-
const
|
|
528
|
+
const i = t ? `${t}.${e.name}` : e.name;
|
|
448
529
|
return {
|
|
449
|
-
label:
|
|
450
|
-
insertText:
|
|
530
|
+
label: i,
|
|
531
|
+
insertText: i + " ",
|
|
451
532
|
// Add trailing space for easier operator typing
|
|
452
533
|
kind: "field",
|
|
453
534
|
detail: e.description || `Type: ${e.type}`,
|
|
@@ -456,24 +537,24 @@ function k(e, t) {
|
|
|
456
537
|
};
|
|
457
538
|
}
|
|
458
539
|
function y(e, t) {
|
|
459
|
-
let
|
|
460
|
-
return t && (
|
|
461
|
-
const
|
|
462
|
-
return !
|
|
463
|
-
})), e && (
|
|
464
|
-
const n = D[
|
|
540
|
+
let i = [...S];
|
|
541
|
+
return t && (i = i.filter((o) => {
|
|
542
|
+
const a = z[o];
|
|
543
|
+
return !a || a.includes(t);
|
|
544
|
+
})), e && (i = i.filter((o) => o.toLowerCase().includes(e.toLowerCase()))), i.map((o, a) => {
|
|
545
|
+
const n = D[o] || { detail: o, documentation: "" }, s = q(o, t);
|
|
465
546
|
return {
|
|
466
|
-
label:
|
|
547
|
+
label: o,
|
|
467
548
|
insertText: s,
|
|
468
549
|
kind: "operator",
|
|
469
550
|
detail: n.detail,
|
|
470
551
|
documentation: n.documentation,
|
|
471
|
-
sortOrder: 20 +
|
|
552
|
+
sortOrder: 20 + a
|
|
472
553
|
};
|
|
473
554
|
});
|
|
474
555
|
}
|
|
475
|
-
function
|
|
476
|
-
const
|
|
556
|
+
function q(e, t) {
|
|
557
|
+
const i = [
|
|
477
558
|
"contains",
|
|
478
559
|
"not_contains",
|
|
479
560
|
"startswith",
|
|
@@ -485,18 +566,18 @@ function B(e, t) {
|
|
|
485
566
|
"not_regexp",
|
|
486
567
|
"matches",
|
|
487
568
|
"not_matches"
|
|
488
|
-
],
|
|
569
|
+
], o = ["exists", "not_exists"], a = ["is", "is_not"];
|
|
489
570
|
if (e === "in" || e === "not_in")
|
|
490
|
-
return
|
|
571
|
+
return T(t) ? `${e} [$1]` : `${e} ["$1"]`;
|
|
491
572
|
if (e === "between" || e === "not_between")
|
|
492
|
-
return
|
|
493
|
-
if (
|
|
573
|
+
return T(t) ? `${e} $1 AND $2` : `${e} "$1" AND "$2"`;
|
|
574
|
+
if (a.includes(e))
|
|
494
575
|
return `${e} null`;
|
|
495
|
-
if (
|
|
576
|
+
if (o.includes(e))
|
|
496
577
|
return e;
|
|
497
578
|
if (e === "cidr" || e === "not_cidr")
|
|
498
579
|
return `${e} "$1"`;
|
|
499
|
-
if (
|
|
580
|
+
if (i.includes(e))
|
|
500
581
|
return `${e} "$1"`;
|
|
501
582
|
if (!t)
|
|
502
583
|
return `${e} `;
|
|
@@ -523,11 +604,11 @@ function B(e, t) {
|
|
|
523
604
|
return `${e} `;
|
|
524
605
|
}
|
|
525
606
|
}
|
|
526
|
-
function
|
|
607
|
+
function T(e) {
|
|
527
608
|
return e === "long" || e === "integer" || e === "double" || e === "float" || e === "short" || e === "byte" || e === "half_float" || e === "scaled_float" || e === "unsigned_long";
|
|
528
609
|
}
|
|
529
|
-
function
|
|
530
|
-
return
|
|
610
|
+
function _() {
|
|
611
|
+
return N.filter((e) => e !== "NOT").map(
|
|
531
612
|
(e, t) => O(e, t)
|
|
532
613
|
);
|
|
533
614
|
}
|
|
@@ -540,17 +621,17 @@ function O(e, t = 0) {
|
|
|
540
621
|
sortOrder: 30 + t
|
|
541
622
|
};
|
|
542
623
|
}
|
|
543
|
-
function
|
|
544
|
-
const
|
|
545
|
-
return e && t?.fieldValues?.[e] && t.fieldValues[e].forEach((
|
|
546
|
-
|
|
547
|
-
label:
|
|
548
|
-
insertText: `"${
|
|
624
|
+
function j(e, t) {
|
|
625
|
+
const i = [];
|
|
626
|
+
return e && t?.fieldValues?.[e] && t.fieldValues[e].forEach((a, n) => {
|
|
627
|
+
i.push({
|
|
628
|
+
label: a,
|
|
629
|
+
insertText: `"${a}"`,
|
|
549
630
|
kind: "value",
|
|
550
631
|
detail: `Known value for ${e}`,
|
|
551
632
|
sortOrder: 40 + n
|
|
552
633
|
});
|
|
553
|
-
}),
|
|
634
|
+
}), i.push(
|
|
554
635
|
{
|
|
555
636
|
label: '"text"',
|
|
556
637
|
insertText: '"$1"',
|
|
@@ -579,87 +660,135 @@ function G(e, t) {
|
|
|
579
660
|
detail: "Null value",
|
|
580
661
|
sortOrder: 53
|
|
581
662
|
}
|
|
582
|
-
),
|
|
663
|
+
), i;
|
|
583
664
|
}
|
|
584
|
-
function
|
|
585
|
-
return P.filter((
|
|
586
|
-
label:
|
|
587
|
-
insertText:
|
|
665
|
+
function B(e, t) {
|
|
666
|
+
return P.filter((o) => !t || o.label.toLowerCase().includes(t.toLowerCase())).map((o, a) => ({
|
|
667
|
+
label: o.label,
|
|
668
|
+
insertText: o.insertText,
|
|
588
669
|
kind: "snippet",
|
|
589
|
-
detail:
|
|
590
|
-
documentation: `Insert: ${
|
|
591
|
-
sortOrder: 100 +
|
|
670
|
+
detail: o.description,
|
|
671
|
+
documentation: `Insert: ${o.insertText}`,
|
|
672
|
+
sortOrder: 100 + a
|
|
592
673
|
}));
|
|
593
674
|
}
|
|
594
|
-
function
|
|
675
|
+
function V(e) {
|
|
595
676
|
return R.filter((t) => !e || t.toLowerCase().includes(e.toLowerCase())).map(
|
|
596
|
-
(t,
|
|
597
|
-
const
|
|
677
|
+
(t, i) => {
|
|
678
|
+
const o = M[t] || { detail: "Field mutator", documentation: "" };
|
|
598
679
|
return {
|
|
599
680
|
label: t,
|
|
600
681
|
insertText: t,
|
|
601
682
|
kind: "mutator",
|
|
602
|
-
detail:
|
|
603
|
-
documentation:
|
|
604
|
-
sortOrder: 60 +
|
|
683
|
+
detail: o.detail,
|
|
684
|
+
documentation: o.documentation,
|
|
685
|
+
sortOrder: 60 + i
|
|
605
686
|
};
|
|
606
687
|
}
|
|
607
688
|
);
|
|
608
689
|
}
|
|
609
690
|
function C(e) {
|
|
610
|
-
return
|
|
691
|
+
return I.filter(
|
|
611
692
|
(t) => !e || t.toLowerCase().includes(e.toLowerCase())
|
|
612
|
-
).map((t,
|
|
693
|
+
).map((t, i) => ({
|
|
613
694
|
label: t,
|
|
614
695
|
insertText: `${t}($1)`,
|
|
615
696
|
kind: "aggregation",
|
|
616
697
|
detail: "Aggregation function",
|
|
617
|
-
sortOrder: 70 +
|
|
698
|
+
sortOrder: 70 + i
|
|
618
699
|
}));
|
|
619
700
|
}
|
|
620
701
|
function H(e) {
|
|
621
|
-
return
|
|
702
|
+
return A.filter(
|
|
622
703
|
(t) => !e || t.toLowerCase().includes(e.toLowerCase())
|
|
623
|
-
).map((t,
|
|
704
|
+
).map((t, i) => ({
|
|
624
705
|
label: t,
|
|
625
706
|
insertText: t,
|
|
626
707
|
kind: "typeHint",
|
|
627
708
|
detail: "Type hint",
|
|
628
|
-
sortOrder: 80 +
|
|
709
|
+
sortOrder: 80 + i
|
|
629
710
|
}));
|
|
630
711
|
}
|
|
631
712
|
function Y(e) {
|
|
632
|
-
return
|
|
713
|
+
return L.filter(
|
|
633
714
|
(t) => !e || t.toLowerCase().includes(e.toLowerCase())
|
|
634
|
-
).map((t,
|
|
715
|
+
).map((t, i) => ({
|
|
635
716
|
label: t,
|
|
636
717
|
insertText: t,
|
|
637
718
|
kind: "visualization",
|
|
638
719
|
detail: "Visualization type",
|
|
639
|
-
sortOrder: 90 +
|
|
720
|
+
sortOrder: 90 + i
|
|
721
|
+
}));
|
|
722
|
+
}
|
|
723
|
+
const K = [
|
|
724
|
+
// Titles & labels
|
|
725
|
+
{ name: "title", detail: "Chart title", insertText: 'title="' },
|
|
726
|
+
{ name: "x_label", detail: "X-axis label", insertText: 'x_label="' },
|
|
727
|
+
{ name: "y_label", detail: "Y-axis label", insertText: 'y_label="' },
|
|
728
|
+
{ name: "labels", detail: "Show data labels: true, false, minmax", insertText: "labels=true" },
|
|
729
|
+
{ name: "legend", detail: "Legend position: top, bottom, left, right", insertText: "legend=" },
|
|
730
|
+
// Chart modes
|
|
731
|
+
{ name: "stacked", detail: "Stack data series (true/false)", insertText: "stacked=true" },
|
|
732
|
+
{ name: "normalize", detail: "100% stacked mode (true/false)", insertText: "normalize=true" },
|
|
733
|
+
{ name: "donut", detail: "Donut style for pie charts (true/false)", insertText: "donut=true" },
|
|
734
|
+
{ name: "fill", detail: "Fill area under line (true/false)", insertText: "fill=true" },
|
|
735
|
+
{ name: "smooth", detail: "Smooth line curves (true/false)", insertText: "smooth=true" },
|
|
736
|
+
// Data formatting
|
|
737
|
+
{ name: "format", detail: "Number format: number, short, percent, bytes, duration", insertText: "format=" },
|
|
738
|
+
{ name: "nulls", detail: "Null handling: zero, gaps, connect", insertText: "nulls=" },
|
|
739
|
+
{ name: "sort", detail: "Sort order: desc, asc, none", insertText: "sort=desc" },
|
|
740
|
+
// Filtering
|
|
741
|
+
{ name: "top", detail: "Show top N values (rest grouped as Other)", insertText: "top=" },
|
|
742
|
+
{ name: "colors", detail: 'Colors: "key:#hex,...", "severity", "warm", "cool"', insertText: 'colors="' },
|
|
743
|
+
{ name: "include", detail: 'Show only these values: "val1,val2,..."', insertText: 'include="' },
|
|
744
|
+
{ name: "exclude", detail: 'Hide these values: "val1,val2,..."', insertText: 'exclude="' },
|
|
745
|
+
{ name: "other", detail: "Group excluded values into Other bucket", insertText: "other=true" },
|
|
746
|
+
// Axis bounds
|
|
747
|
+
{ name: "y_min", detail: "Y-axis minimum value", insertText: "y_min=" },
|
|
748
|
+
{ name: "y_max", detail: "Y-axis maximum value", insertText: "y_max=" },
|
|
749
|
+
// Threshold / reference line
|
|
750
|
+
{ name: "threshold", detail: "Horizontal threshold line value", insertText: "threshold=" },
|
|
751
|
+
{ name: "threshold_color", detail: "Threshold line color (hex)", insertText: 'threshold_color="' },
|
|
752
|
+
{ name: "threshold_label", detail: "Threshold line label text", insertText: 'threshold_label="' },
|
|
753
|
+
// Interaction
|
|
754
|
+
{ name: "drilldown", detail: "Enable click-to-drill (true/false)", insertText: "drilldown=true" },
|
|
755
|
+
{ name: "crosshair", detail: "Show all values at hover point (true/false)", insertText: "crosshair=true" },
|
|
756
|
+
{ name: "link", detail: 'Template URL for value links: "https://...{{value}}"', insertText: 'link="' },
|
|
757
|
+
{ name: "link_target", detail: "Link target: _self (default) or _blank", insertText: "link_target=" }
|
|
758
|
+
];
|
|
759
|
+
function W(e) {
|
|
760
|
+
return K.filter(
|
|
761
|
+
(t) => !e || t.name.toLowerCase().includes(e.toLowerCase())
|
|
762
|
+
).map((t, i) => ({
|
|
763
|
+
label: t.name,
|
|
764
|
+
insertText: t.insertText,
|
|
765
|
+
kind: "visualization",
|
|
766
|
+
detail: t.detail,
|
|
767
|
+
sortOrder: 95 + i
|
|
640
768
|
}));
|
|
641
769
|
}
|
|
642
|
-
function
|
|
643
|
-
const
|
|
644
|
-
(
|
|
770
|
+
function ee(e, t) {
|
|
771
|
+
const o = x(e).find(
|
|
772
|
+
(a) => a.start <= t && a.end >= t && a.type !== "whitespace"
|
|
645
773
|
);
|
|
646
|
-
return
|
|
647
|
-
word:
|
|
648
|
-
start:
|
|
649
|
-
end:
|
|
774
|
+
return o ? {
|
|
775
|
+
word: o.value,
|
|
776
|
+
start: o.start,
|
|
777
|
+
end: o.end
|
|
650
778
|
} : null;
|
|
651
779
|
}
|
|
652
|
-
function
|
|
780
|
+
function te() {
|
|
653
781
|
return [" ", "(", ".", '"', "'", "|", ":", "="];
|
|
654
782
|
}
|
|
655
|
-
function
|
|
656
|
-
if (
|
|
657
|
-
|
|
658
|
-
|
|
783
|
+
function ae(e, t, i) {
|
|
784
|
+
if (!e) return !1;
|
|
785
|
+
if (i === " " || i === "(" || i === "." || i === "|" || i === ":" || i === "=") return !0;
|
|
786
|
+
const o = x(e.substring(0, t)), a = o[o.length - 1];
|
|
787
|
+
return !!(a && a.type === "field" && a.value.length >= 2);
|
|
659
788
|
}
|
|
660
789
|
export {
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
790
|
+
te as getCompletionTriggerCharacters,
|
|
791
|
+
Q as getCompletions,
|
|
792
|
+
ee as getWordAtPosition,
|
|
793
|
+
ae as shouldTriggerCompletion
|
|
665
794
|
};
|