@tellaro/tql 0.1.10 → 0.1.11
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/src/completionProvider.js +80 -69
- package/package.json +1 -1
|
@@ -256,8 +256,8 @@ class q {
|
|
|
256
256
|
}
|
|
257
257
|
set(t, a) {
|
|
258
258
|
if (this.cache.size >= this.maxSize) {
|
|
259
|
-
const
|
|
260
|
-
|
|
259
|
+
const i = this.cache.keys().next().value;
|
|
260
|
+
i && this.cache.delete(i);
|
|
261
261
|
}
|
|
262
262
|
this.cache.set(t, { result: a, timestamp: Date.now() });
|
|
263
263
|
}
|
|
@@ -267,18 +267,18 @@ class q {
|
|
|
267
267
|
}
|
|
268
268
|
const v = new q();
|
|
269
269
|
function B(e, t, a) {
|
|
270
|
-
const
|
|
271
|
-
if (
|
|
272
|
-
return
|
|
270
|
+
const i = `${e.substring(0, t)}|${t}`, o = v.get(i);
|
|
271
|
+
if (o)
|
|
272
|
+
return o.fieldName && !o.fieldType && a && (o.fieldType = f(o.fieldName, a)), o;
|
|
273
273
|
const n = G(e, t, a);
|
|
274
|
-
return v.set(
|
|
274
|
+
return v.set(i, n), n;
|
|
275
275
|
}
|
|
276
276
|
function G(e, t, a) {
|
|
277
277
|
var u;
|
|
278
|
-
const
|
|
279
|
-
if (
|
|
278
|
+
const o = b(e.substring(0, t)).filter((l) => l.type !== "whitespace");
|
|
279
|
+
if (o.length === 0)
|
|
280
280
|
return { type: "start" };
|
|
281
|
-
const n =
|
|
281
|
+
const n = o[o.length - 1], r = o.length > 1 ? o[o.length - 2] : null, d = n.end === t && !((u = e[t - 1]) != null && u.match(/\s/)), s = d ? n.value : void 0;
|
|
282
282
|
if (n.type === "logicalOp")
|
|
283
283
|
return { type: "start" };
|
|
284
284
|
if (n.type === "paren" && n.value === "(")
|
|
@@ -347,21 +347,21 @@ function G(e, t, a) {
|
|
|
347
347
|
function f(e, t) {
|
|
348
348
|
return t ? M().getFieldType(t, e) : void 0;
|
|
349
349
|
}
|
|
350
|
-
function
|
|
351
|
-
const { query: a, cursorPosition:
|
|
352
|
-
switch (
|
|
350
|
+
function ae(e, t = {}) {
|
|
351
|
+
const { query: a, cursorPosition: i } = e, o = B(a, i, t.fields), n = [];
|
|
352
|
+
switch (o.type) {
|
|
353
353
|
case "start":
|
|
354
354
|
case "after_paren":
|
|
355
|
-
n.push(...y(t.fields,
|
|
355
|
+
n.push(...y(t.fields, o.partialText)), n.push(N("NOT")), t.includeSnippets !== !1 && n.push(...K(t, o.partialText));
|
|
356
356
|
break;
|
|
357
357
|
case "after_field":
|
|
358
|
-
n.push(...x(
|
|
358
|
+
n.push(...x(o.partialText, o.fieldType)), n.push(H());
|
|
359
359
|
break;
|
|
360
360
|
case "after_mutator":
|
|
361
|
-
n.push(...x(
|
|
361
|
+
n.push(...x(o.partialText, o.mutatorOutputType));
|
|
362
362
|
break;
|
|
363
363
|
case "after_operator":
|
|
364
|
-
n.push(...
|
|
364
|
+
n.push(...Y(o.fieldName, t));
|
|
365
365
|
break;
|
|
366
366
|
case "after_value":
|
|
367
367
|
n.push(...C());
|
|
@@ -369,28 +369,28 @@ function te(e, t = {}) {
|
|
|
369
369
|
case "at_value_end":
|
|
370
370
|
break;
|
|
371
371
|
case "after_pipe":
|
|
372
|
-
n.push(...
|
|
372
|
+
n.push(...W(o.partialText));
|
|
373
373
|
break;
|
|
374
374
|
case "after_double_colon":
|
|
375
|
-
n.push(...
|
|
375
|
+
n.push(...Z(o.partialText));
|
|
376
376
|
break;
|
|
377
377
|
case "after_arrow":
|
|
378
|
-
n.push(...
|
|
378
|
+
n.push(...J(o.partialText));
|
|
379
379
|
break;
|
|
380
380
|
case "after_stats":
|
|
381
|
-
n.push(...O(
|
|
381
|
+
n.push(...O(o.partialText));
|
|
382
382
|
break;
|
|
383
383
|
case "after_by":
|
|
384
|
-
n.push(...y(t.fields,
|
|
384
|
+
n.push(...y(t.fields, o.partialText));
|
|
385
385
|
break;
|
|
386
386
|
default:
|
|
387
|
-
n.push(...y(t.fields,
|
|
387
|
+
n.push(...y(t.fields, o.partialText)), n.push(...x(o.partialText)), n.push(...C());
|
|
388
388
|
}
|
|
389
|
-
t.includeAggregations &&
|
|
389
|
+
t.includeAggregations && o.type === "start" && n.push(...O(o.partialText));
|
|
390
390
|
let r = n;
|
|
391
391
|
const d = t.fuzzyMatching !== !1, s = t.minFuzzyScore ?? 0;
|
|
392
|
-
if (
|
|
393
|
-
const u =
|
|
392
|
+
if (o.partialText) {
|
|
393
|
+
const u = o.partialText.toLowerCase();
|
|
394
394
|
if (d) {
|
|
395
395
|
const l = [];
|
|
396
396
|
for (const c of n) {
|
|
@@ -416,11 +416,11 @@ function y(e, t) {
|
|
|
416
416
|
if (!e || e.length === 0)
|
|
417
417
|
return V(t);
|
|
418
418
|
const a = [];
|
|
419
|
-
for (const
|
|
420
|
-
const
|
|
421
|
-
if (a.push(
|
|
422
|
-
for (const n of
|
|
423
|
-
const r = k(n,
|
|
419
|
+
for (const i of e) {
|
|
420
|
+
const o = k(i);
|
|
421
|
+
if (a.push(o), i.nested)
|
|
422
|
+
for (const n of i.nested) {
|
|
423
|
+
const r = k(n, i.name);
|
|
424
424
|
a.push(r);
|
|
425
425
|
}
|
|
426
426
|
}
|
|
@@ -466,18 +466,18 @@ function k(e, t) {
|
|
|
466
466
|
}
|
|
467
467
|
function x(e, t) {
|
|
468
468
|
let a = [...A];
|
|
469
|
-
return t && (a = a.filter((
|
|
470
|
-
const
|
|
471
|
-
return !
|
|
472
|
-
})), e && (a = a.filter((
|
|
473
|
-
const n = U[
|
|
469
|
+
return t && (a = a.filter((i) => {
|
|
470
|
+
const o = F[i];
|
|
471
|
+
return !o || o.includes(t);
|
|
472
|
+
})), e && (a = a.filter((i) => i.toLowerCase().includes(e.toLowerCase()))), a.map((i, o) => {
|
|
473
|
+
const n = U[i] || { detail: i, documentation: "" }, r = j(i, t);
|
|
474
474
|
return {
|
|
475
|
-
label:
|
|
475
|
+
label: i,
|
|
476
476
|
insertText: r,
|
|
477
477
|
kind: "operator",
|
|
478
478
|
detail: n.detail,
|
|
479
479
|
documentation: n.documentation,
|
|
480
|
-
sortOrder: 20 +
|
|
480
|
+
sortOrder: 20 + o
|
|
481
481
|
};
|
|
482
482
|
});
|
|
483
483
|
}
|
|
@@ -494,14 +494,14 @@ function j(e, t) {
|
|
|
494
494
|
"not_regexp",
|
|
495
495
|
"matches",
|
|
496
496
|
"not_matches"
|
|
497
|
-
],
|
|
497
|
+
], i = ["exists", "not_exists"], o = ["is", "is_not"];
|
|
498
498
|
if (e === "in" || e === "not_in")
|
|
499
499
|
return T(t) ? `${e} [$1]` : `${e} ["$1"]`;
|
|
500
500
|
if (e === "between" || e === "not_between")
|
|
501
501
|
return T(t) ? `${e} $1 AND $2` : `${e} "$1" AND "$2"`;
|
|
502
|
-
if (i.includes(e))
|
|
503
|
-
return `${e} null`;
|
|
504
502
|
if (o.includes(e))
|
|
503
|
+
return `${e} null`;
|
|
504
|
+
if (i.includes(e))
|
|
505
505
|
return e;
|
|
506
506
|
if (e === "cidr" || e === "not_cidr")
|
|
507
507
|
return `${e} "$1"`;
|
|
@@ -545,10 +545,21 @@ function N(e, t = 0) {
|
|
|
545
545
|
sortOrder: 30 + t
|
|
546
546
|
};
|
|
547
547
|
}
|
|
548
|
-
function H(
|
|
549
|
-
|
|
548
|
+
function H() {
|
|
549
|
+
return {
|
|
550
|
+
label: "|",
|
|
551
|
+
insertText: "| ",
|
|
552
|
+
kind: "operator",
|
|
553
|
+
detail: "Pipe to mutator",
|
|
554
|
+
documentation: "Chain field to a mutator function (e.g., hostname | lower)",
|
|
555
|
+
sortOrder: 19
|
|
556
|
+
// Just before operators (20+)
|
|
557
|
+
};
|
|
558
|
+
}
|
|
559
|
+
function Y(e, t) {
|
|
560
|
+
var i;
|
|
550
561
|
const a = [];
|
|
551
|
-
return e && ((
|
|
562
|
+
return e && ((i = t == null ? void 0 : t.fieldValues) != null && i[e]) && t.fieldValues[e].forEach((n, r) => {
|
|
552
563
|
a.push({
|
|
553
564
|
label: n,
|
|
554
565
|
insertText: `"${n}"`,
|
|
@@ -587,26 +598,26 @@ function H(e, t) {
|
|
|
587
598
|
}
|
|
588
599
|
), a;
|
|
589
600
|
}
|
|
590
|
-
function
|
|
591
|
-
return E.filter((
|
|
592
|
-
label:
|
|
593
|
-
insertText:
|
|
601
|
+
function K(e, t) {
|
|
602
|
+
return E.filter((i) => !t || i.label.toLowerCase().includes(t.toLowerCase())).map((i, o) => ({
|
|
603
|
+
label: i.label,
|
|
604
|
+
insertText: i.insertText,
|
|
594
605
|
kind: "snippet",
|
|
595
|
-
detail:
|
|
596
|
-
documentation: `Insert: ${
|
|
597
|
-
sortOrder: 100 +
|
|
606
|
+
detail: i.description,
|
|
607
|
+
documentation: `Insert: ${i.insertText}`,
|
|
608
|
+
sortOrder: 100 + o
|
|
598
609
|
}));
|
|
599
610
|
}
|
|
600
|
-
function
|
|
611
|
+
function W(e) {
|
|
601
612
|
return D.filter((t) => !e || t.toLowerCase().includes(e.toLowerCase())).map(
|
|
602
613
|
(t, a) => {
|
|
603
|
-
const
|
|
614
|
+
const i = z[t] || { detail: "Field mutator", documentation: "" };
|
|
604
615
|
return {
|
|
605
616
|
label: t,
|
|
606
617
|
insertText: t,
|
|
607
618
|
kind: "mutator",
|
|
608
|
-
detail:
|
|
609
|
-
documentation:
|
|
619
|
+
detail: i.detail,
|
|
620
|
+
documentation: i.documentation,
|
|
610
621
|
sortOrder: 60 + a
|
|
611
622
|
};
|
|
612
623
|
}
|
|
@@ -623,7 +634,7 @@ function O(e) {
|
|
|
623
634
|
sortOrder: 70 + a
|
|
624
635
|
}));
|
|
625
636
|
}
|
|
626
|
-
function
|
|
637
|
+
function Z(e) {
|
|
627
638
|
return P.filter(
|
|
628
639
|
(t) => !e || t.toLowerCase().includes(e.toLowerCase())
|
|
629
640
|
).map((t, a) => ({
|
|
@@ -634,7 +645,7 @@ function W(e) {
|
|
|
634
645
|
sortOrder: 80 + a
|
|
635
646
|
}));
|
|
636
647
|
}
|
|
637
|
-
function
|
|
648
|
+
function J(e) {
|
|
638
649
|
return $.filter(
|
|
639
650
|
(t) => !e || t.toLowerCase().includes(e.toLowerCase())
|
|
640
651
|
).map((t, a) => ({
|
|
@@ -645,27 +656,27 @@ function Z(e) {
|
|
|
645
656
|
sortOrder: 90 + a
|
|
646
657
|
}));
|
|
647
658
|
}
|
|
648
|
-
function
|
|
649
|
-
const
|
|
650
|
-
(
|
|
659
|
+
function ne(e, t) {
|
|
660
|
+
const i = b(e).find(
|
|
661
|
+
(o) => o.start <= t && o.end >= t && o.type !== "whitespace"
|
|
651
662
|
);
|
|
652
|
-
return
|
|
653
|
-
word:
|
|
654
|
-
start:
|
|
655
|
-
end:
|
|
663
|
+
return i ? {
|
|
664
|
+
word: i.value,
|
|
665
|
+
start: i.start,
|
|
666
|
+
end: i.end
|
|
656
667
|
} : null;
|
|
657
668
|
}
|
|
658
|
-
function
|
|
669
|
+
function oe() {
|
|
659
670
|
return [" ", "(", ".", '"', "'", "|", ":", "="];
|
|
660
671
|
}
|
|
661
672
|
function ie(e, t, a) {
|
|
662
673
|
if (a === " " || a === "(" || a === "." || a === "|" || a === ":" || a === "=") return !0;
|
|
663
|
-
const
|
|
664
|
-
return !!(
|
|
674
|
+
const i = b(e.substring(0, t)), o = i[i.length - 1];
|
|
675
|
+
return !!(o && o.type === "field" && o.value.length >= 2);
|
|
665
676
|
}
|
|
666
677
|
export {
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
678
|
+
oe as getCompletionTriggerCharacters,
|
|
679
|
+
ae as getCompletions,
|
|
680
|
+
ne as getWordAtPosition,
|
|
670
681
|
ie as shouldTriggerCompletion
|
|
671
682
|
};
|