@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.
@@ -256,8 +256,8 @@ class q {
256
256
  }
257
257
  set(t, a) {
258
258
  if (this.cache.size >= this.maxSize) {
259
- const o = this.cache.keys().next().value;
260
- o && this.cache.delete(o);
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 o = `${e.substring(0, t)}|${t}`, i = v.get(o);
271
- if (i)
272
- return i.fieldName && !i.fieldType && a && (i.fieldType = f(i.fieldName, a)), i;
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(o, n), n;
274
+ return v.set(i, n), n;
275
275
  }
276
276
  function G(e, t, a) {
277
277
  var u;
278
- const i = b(e.substring(0, t)).filter((l) => l.type !== "whitespace");
279
- if (i.length === 0)
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 = i[i.length - 1], r = i.length > 1 ? i[i.length - 2] : null, d = n.end === t && !((u = e[t - 1]) != null && u.match(/\s/)), s = d ? n.value : void 0;
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 te(e, t = {}) {
351
- const { query: a, cursorPosition: o } = e, i = B(a, o, t.fields), n = [];
352
- switch (i.type) {
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, i.partialText)), n.push(N("NOT")), t.includeSnippets !== !1 && n.push(...Y(t, i.partialText));
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(i.partialText, i.fieldType));
358
+ n.push(...x(o.partialText, o.fieldType)), n.push(H());
359
359
  break;
360
360
  case "after_mutator":
361
- n.push(...x(i.partialText, i.mutatorOutputType));
361
+ n.push(...x(o.partialText, o.mutatorOutputType));
362
362
  break;
363
363
  case "after_operator":
364
- n.push(...H(i.fieldName, t));
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(...K(i.partialText));
372
+ n.push(...W(o.partialText));
373
373
  break;
374
374
  case "after_double_colon":
375
- n.push(...W(i.partialText));
375
+ n.push(...Z(o.partialText));
376
376
  break;
377
377
  case "after_arrow":
378
- n.push(...Z(i.partialText));
378
+ n.push(...J(o.partialText));
379
379
  break;
380
380
  case "after_stats":
381
- n.push(...O(i.partialText));
381
+ n.push(...O(o.partialText));
382
382
  break;
383
383
  case "after_by":
384
- n.push(...y(t.fields, i.partialText));
384
+ n.push(...y(t.fields, o.partialText));
385
385
  break;
386
386
  default:
387
- n.push(...y(t.fields, i.partialText)), n.push(...x(i.partialText)), n.push(...C());
387
+ n.push(...y(t.fields, o.partialText)), n.push(...x(o.partialText)), n.push(...C());
388
388
  }
389
- t.includeAggregations && i.type === "start" && n.push(...O(i.partialText));
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 (i.partialText) {
393
- const u = i.partialText.toLowerCase();
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 o of e) {
420
- const i = k(o);
421
- if (a.push(i), o.nested)
422
- for (const n of o.nested) {
423
- const r = k(n, o.name);
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((o) => {
470
- const i = F[o];
471
- return !i || i.includes(t);
472
- })), e && (a = a.filter((o) => o.toLowerCase().includes(e.toLowerCase()))), a.map((o, i) => {
473
- const n = U[o] || { detail: o, documentation: "" }, r = j(o, t);
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: o,
475
+ label: i,
476
476
  insertText: r,
477
477
  kind: "operator",
478
478
  detail: n.detail,
479
479
  documentation: n.documentation,
480
- sortOrder: 20 + i
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
- ], o = ["exists", "not_exists"], i = ["is", "is_not"];
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(e, t) {
549
- var o;
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 && ((o = t == null ? void 0 : t.fieldValues) != null && o[e]) && t.fieldValues[e].forEach((n, r) => {
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 Y(e, t) {
591
- return E.filter((o) => !t || o.label.toLowerCase().includes(t.toLowerCase())).map((o, i) => ({
592
- label: o.label,
593
- insertText: o.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: o.description,
596
- documentation: `Insert: ${o.insertText}`,
597
- sortOrder: 100 + i
606
+ detail: i.description,
607
+ documentation: `Insert: ${i.insertText}`,
608
+ sortOrder: 100 + o
598
609
  }));
599
610
  }
600
- function K(e) {
611
+ function W(e) {
601
612
  return D.filter((t) => !e || t.toLowerCase().includes(e.toLowerCase())).map(
602
613
  (t, a) => {
603
- const o = z[t] || { detail: "Field mutator", documentation: "" };
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: o.detail,
609
- documentation: o.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 W(e) {
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 Z(e) {
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 ae(e, t) {
649
- const o = b(e).find(
650
- (i) => i.start <= t && i.end >= t && i.type !== "whitespace"
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 o ? {
653
- word: o.value,
654
- start: o.start,
655
- end: o.end
663
+ return i ? {
664
+ word: i.value,
665
+ start: i.start,
666
+ end: i.end
656
667
  } : null;
657
668
  }
658
- function ne() {
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 o = b(e.substring(0, t)), i = o[o.length - 1];
664
- return !!(i && i.type === "field" && i.value.length >= 2);
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
- ne as getCompletionTriggerCharacters,
668
- te as getCompletions,
669
- ae as getWordAtPosition,
678
+ oe as getCompletionTriggerCharacters,
679
+ ae as getCompletions,
680
+ ne as getWordAtPosition,
670
681
  ie as shouldTriggerCompletion
671
682
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tellaro/tql",
3
- "version": "0.1.10",
3
+ "version": "0.1.11",
4
4
  "description": "Tellaro Query Language (TQL) parser, validator, and autocomplete for JavaScript/TypeScript",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",