@tellaro/tql 1.3.8 → 1.4.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.
Files changed (33) hide show
  1. package/dist/index.js +44 -41
  2. package/dist/node_modules/@kurkle/color/dist/color.esm.js +442 -0
  3. package/dist/node_modules/chart.js/dist/chart.js +6149 -0
  4. package/dist/node_modules/chart.js/dist/chunks/helpers.dataset.js +1685 -0
  5. package/dist/node_modules/chartjs-adapter-luxon/dist/chartjs-adapter-luxon.esm.js +56 -0
  6. package/dist/node_modules/chartjs-plugin-annotation/dist/chartjs-plugin-annotation.esm.js +1655 -0
  7. package/dist/node_modules/chartjs-plugin-datalabels/dist/chartjs-plugin-datalabels.esm.js +607 -0
  8. package/dist/node_modules/luxon/build/es6/luxon.js +5524 -0
  9. package/dist/src/builder.d.ts +62 -0
  10. package/dist/src/builder.js +56 -0
  11. package/dist/src/chart/colors.d.ts +23 -0
  12. package/dist/src/chart/colors.js +101 -0
  13. package/dist/src/chart/formatters.d.ts +17 -0
  14. package/dist/src/chart/formatters.js +49 -0
  15. package/dist/src/chart/index.d.ts +9 -0
  16. package/dist/src/chart/index.js +31 -0
  17. package/dist/src/chart/mappers.d.ts +849 -0
  18. package/dist/src/chart/mappers.js +613 -0
  19. package/dist/src/completionProvider.js +294 -165
  20. package/dist/src/index.d.ts +2 -1
  21. package/dist/src/parser.d.ts +10 -0
  22. package/dist/src/parser.js +41 -9
  23. package/dist/src/tokenizer.js +124 -103
  24. package/dist/src/types.d.ts +27 -3
  25. package/dist/src/validator.js +10 -9
  26. package/dist/tql.css +1 -1
  27. package/dist/vue/TqlChart.vue.d.ts +2 -0
  28. package/dist/vue/TqlChart.vue.js +7 -0
  29. package/dist/vue/TqlChart.vue2.js +212 -0
  30. package/dist/vue/index.d.ts +1 -0
  31. package/dist/vue/index.js +12 -10
  32. package/dist/vue/useTqlInput.js +80 -80
  33. package/package.json +39 -3
@@ -1,4 +1,4 @@
1
- import { tokenizeTql as x, COMPARISON_OPERATORS as N, LOGICAL_OPERATORS as I, AGGREGATION_FUNCTIONS as S, VISUALIZATION_TYPES as A, TYPE_HINTS as L, MUTATORS as R } from "./tokenizer.js";
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
- }, g = {
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
- }, E = {
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 U {
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 a = this.cache.get(t);
248
- if (a && Date.now() - a.timestamp < this.maxAge)
249
- return a.result;
250
- a && this.cache.delete(t);
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, a) {
252
+ set(t, i) {
253
253
  if (this.cache.size >= this.maxSize) {
254
- const i = this.cache.keys().next().value;
255
- i && this.cache.delete(i);
254
+ const o = this.cache.keys().next().value;
255
+ o && this.cache.delete(o);
256
256
  }
257
- this.cache.set(t, { result: a, timestamp: Date.now() });
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 U();
264
- function z(e, t, a) {
265
- const i = `${e.substring(0, t)}|${t}`, o = v.get(i);
266
- if (o)
267
- return o.fieldName && !o.fieldType && a && (o.fieldType = p(o.fieldName, a)), o;
268
- const n = F(e, t, a);
269
- return v.set(i, n), n;
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, a) {
272
- const o = x(e.substring(0, t)).filter((r) => r.type !== "whitespace");
273
- if (o.length === 0)
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 = o[o.length - 1], s = o.length > 1 ? o[o.length - 2] : null, d = n.end === t && !e[t - 1]?.match(/\s/), l = d ? n.value : void 0;
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 === "identifier" || 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: l };
298
+ return { type: "after_arrow", partialText: d };
282
299
  if (n.type === "doubleColon")
283
- return { type: "after_double_colon", partialText: l };
284
- if (n.type === "visualization" && d)
285
- return { type: "after_arrow", partialText: l };
286
- if (n.type === "typeHint" && d)
287
- return { type: "after_double_colon", partialText: l };
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: l };
306
+ return { type: "after_stats", partialText: d };
290
307
  if (n.type === "keyword" && n.value.toLowerCase() === "by")
291
- return { type: "after_by", partialText: l };
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: l };
332
+ return { type: "after_pipe", partialText: d };
294
333
  if (n.type === "mutator") {
295
- if (d)
296
- return { type: "after_pipe", partialText: l };
297
- const r = n.value.toLowerCase(), c = g[r];
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: r,
301
- mutatorOutputType: c
339
+ mutatorName: l,
340
+ mutatorOutputType: r
302
341
  };
303
342
  }
304
343
  if (n.type === "aggregation")
305
- return d ? { type: "after_stats", partialText: l } : { type: "after_value" };
344
+ return u ? { type: "after_stats", partialText: d } : { type: "after_value" };
306
345
  if (n.type === "field") {
307
- if (d)
308
- return s?.type === "pipe" ? { type: "after_pipe", partialText: l } : { type: "start", partialText: l };
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 r = p(n.value, a);
312
- return { type: "after_field", fieldName: n.value, fieldType: r };
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 (d) {
354
+ if (u) {
316
355
  if (s?.type === "field") {
317
- const r = p(s.value, a);
318
- return { type: "after_field", fieldName: s.value, fieldType: r, partialText: l };
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 r = s.value.toLowerCase(), c = g[r];
322
- return { type: "after_mutator", mutatorName: r, mutatorOutputType: c, partialText: l };
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 d ? { type: "at_value_end" } : { type: "after_value" };
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" && d) {
332
- const r = p(s.value, a);
333
- return { type: "after_field", fieldName: s.value, fieldType: r, partialText: l };
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" && d) {
336
- const r = s.value.toLowerCase(), c = g[r];
337
- return { type: "after_mutator", mutatorName: r, mutatorOutputType: c, partialText: l };
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: l };
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 J(e, t = {}) {
345
- const { query: a, cursorPosition: i } = e, o = z(a, i, t.fields), n = [];
346
- switch (o.type) {
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(...h(t.fields, o.partialText)), n.push(O("NOT")), t.includeSnippets !== !1 && n.push(...V(t, o.partialText));
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(o.partialText, o.fieldType));
393
+ n.push(...y(a.partialText, a.fieldType));
353
394
  break;
354
395
  case "after_mutator":
355
- n.push(...y(o.partialText, o.mutatorOutputType));
396
+ n.push(...y(a.partialText, a.mutatorOutputType));
356
397
  break;
357
398
  case "after_operator":
358
- n.push(...G(o.fieldName, t));
399
+ n.push(...j(a.fieldName, t));
359
400
  break;
360
401
  case "after_value":
361
- n.push(...T());
402
+ n.push(..._());
362
403
  break;
363
404
  case "at_value_end":
364
405
  break;
365
406
  case "after_pipe":
366
- n.push(...j(o.partialText));
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(o.partialText));
447
+ n.push(...H(a.partialText));
370
448
  break;
371
449
  case "after_arrow":
372
- n.push(...Y(o.partialText));
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(o.partialText));
456
+ n.push(...C(a.partialText));
376
457
  break;
377
458
  case "after_by":
378
- n.push(...h(t.fields, o.partialText));
459
+ n.push(...g(t.fields, a.partialText));
379
460
  break;
380
461
  default:
381
- n.push(...h(t.fields, o.partialText)), n.push(...y(o.partialText)), n.push(...T());
462
+ n.push(...g(t.fields, a.partialText)), n.push(...y(a.partialText)), n.push(..._());
382
463
  }
383
- t.includeAggregations && o.type === "start" && n.push(...C(o.partialText));
464
+ t.includeAggregations && a.type === "start" && n.push(...C(a.partialText));
384
465
  let s = n;
385
- const d = t.fuzzyMatching !== !1, l = t.minFuzzyScore ?? 0;
386
- if (o.partialText) {
387
- const r = o.partialText.toLowerCase();
388
- if (d) {
389
- const c = [];
390
- for (const u of n) {
391
- const m = w(r, u.label), b = u.filterText ? w(r, u.filterText) : { matched: !1, score: 0 }, f = m.score >= b.score ? m : b;
392
- f.matched && f.score >= l && c.push({
393
- ...u,
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 = c;
479
+ s = r;
399
480
  } else
400
481
  s = n.filter(
401
- (c) => c.label.toLowerCase().includes(r) || c.filterText?.toLowerCase().includes(r)
482
+ (r) => r.label.toLowerCase().includes(l) || r.filterText?.toLowerCase().includes(l)
402
483
  );
403
484
  }
404
- return s.sort((r, c) => r.matchScore !== void 0 && c.matchScore !== void 0 && c.matchScore !== r.matchScore ? c.matchScore - r.matchScore : r.sortOrder - c.sortOrder), t.maxItems && t.maxItems > 0 && (s = s.slice(0, t.maxItems)), s;
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 h(e, t) {
487
+ function g(e, t) {
407
488
  if (!e || e.length === 0)
408
- return q(t);
409
- const a = [];
410
- for (const i of e) {
411
- const o = k(i);
412
- if (a.push(o), i.nested)
413
- for (const n of i.nested) {
414
- const s = k(n, i.name);
415
- a.push(s);
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 a;
499
+ return i;
419
500
  }
420
- function q(e) {
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((a) => !e || a.name.toLowerCase().includes(e.toLowerCase())).map((a) => ({
438
- label: a.name,
439
- insertText: a.name + " ",
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: a.description,
523
+ detail: i.description,
443
524
  sortOrder: 10
444
525
  }));
445
526
  }
446
527
  function k(e, t) {
447
- const a = t ? `${t}.${e.name}` : e.name;
528
+ const i = t ? `${t}.${e.name}` : e.name;
448
529
  return {
449
- label: a,
450
- insertText: a + " ",
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 a = [...N];
460
- return t && (a = a.filter((i) => {
461
- const o = E[i];
462
- return !o || o.includes(t);
463
- })), e && (a = a.filter((i) => i.toLowerCase().includes(e.toLowerCase()))), a.map((i, o) => {
464
- const n = D[i] || { detail: i, documentation: "" }, s = B(i, t);
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: i,
547
+ label: o,
467
548
  insertText: s,
468
549
  kind: "operator",
469
550
  detail: n.detail,
470
551
  documentation: n.documentation,
471
- sortOrder: 20 + o
552
+ sortOrder: 20 + a
472
553
  };
473
554
  });
474
555
  }
475
- function B(e, t) {
476
- const a = [
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
- ], i = ["exists", "not_exists"], o = ["is", "is_not"];
569
+ ], o = ["exists", "not_exists"], a = ["is", "is_not"];
489
570
  if (e === "in" || e === "not_in")
490
- return _(t) ? `${e} [$1]` : `${e} ["$1"]`;
571
+ return T(t) ? `${e} [$1]` : `${e} ["$1"]`;
491
572
  if (e === "between" || e === "not_between")
492
- return _(t) ? `${e} $1 AND $2` : `${e} "$1" AND "$2"`;
493
- if (o.includes(e))
573
+ return T(t) ? `${e} $1 AND $2` : `${e} "$1" AND "$2"`;
574
+ if (a.includes(e))
494
575
  return `${e} null`;
495
- if (i.includes(e))
576
+ if (o.includes(e))
496
577
  return e;
497
578
  if (e === "cidr" || e === "not_cidr")
498
579
  return `${e} "$1"`;
499
- if (a.includes(e))
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 _(e) {
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 T() {
530
- return I.filter((e) => e !== "NOT").map(
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 G(e, t) {
544
- const a = [];
545
- return e && t?.fieldValues?.[e] && t.fieldValues[e].forEach((o, n) => {
546
- a.push({
547
- label: o,
548
- insertText: `"${o}"`,
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
- }), a.push(
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
- ), a;
663
+ ), i;
583
664
  }
584
- function V(e, t) {
585
- return P.filter((i) => !t || i.label.toLowerCase().includes(t.toLowerCase())).map((i, o) => ({
586
- label: i.label,
587
- insertText: i.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: i.description,
590
- documentation: `Insert: ${i.insertText}`,
591
- sortOrder: 100 + o
670
+ detail: o.description,
671
+ documentation: `Insert: ${o.insertText}`,
672
+ sortOrder: 100 + a
592
673
  }));
593
674
  }
594
- function j(e) {
675
+ function V(e) {
595
676
  return R.filter((t) => !e || t.toLowerCase().includes(e.toLowerCase())).map(
596
- (t, a) => {
597
- const i = M[t] || { detail: "Field mutator", documentation: "" };
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: i.detail,
603
- documentation: i.documentation,
604
- sortOrder: 60 + a
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 S.filter(
691
+ return I.filter(
611
692
  (t) => !e || t.toLowerCase().includes(e.toLowerCase())
612
- ).map((t, a) => ({
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 + a
698
+ sortOrder: 70 + i
618
699
  }));
619
700
  }
620
701
  function H(e) {
621
- return L.filter(
702
+ return A.filter(
622
703
  (t) => !e || t.toLowerCase().includes(e.toLowerCase())
623
- ).map((t, a) => ({
704
+ ).map((t, i) => ({
624
705
  label: t,
625
706
  insertText: t,
626
707
  kind: "typeHint",
627
708
  detail: "Type hint",
628
- sortOrder: 80 + a
709
+ sortOrder: 80 + i
629
710
  }));
630
711
  }
631
712
  function Y(e) {
632
- return A.filter(
713
+ return L.filter(
633
714
  (t) => !e || t.toLowerCase().includes(e.toLowerCase())
634
- ).map((t, a) => ({
715
+ ).map((t, i) => ({
635
716
  label: t,
636
717
  insertText: t,
637
718
  kind: "visualization",
638
719
  detail: "Visualization type",
639
- sortOrder: 90 + a
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 Q(e, t) {
643
- const i = x(e).find(
644
- (o) => o.start <= t && o.end >= t && o.type !== "whitespace"
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 i ? {
647
- word: i.value,
648
- start: i.start,
649
- end: i.end
774
+ return o ? {
775
+ word: o.value,
776
+ start: o.start,
777
+ end: o.end
650
778
  } : null;
651
779
  }
652
- function X() {
780
+ function te() {
653
781
  return [" ", "(", ".", '"', "'", "|", ":", "="];
654
782
  }
655
- function ee(e, t, a) {
656
- if (a === " " || a === "(" || a === "." || a === "|" || a === ":" || a === "=") return !0;
657
- const i = x(e.substring(0, t)), o = i[i.length - 1];
658
- return !!(o && o.type === "field" && o.value.length >= 2);
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
- X as getCompletionTriggerCharacters,
662
- J as getCompletions,
663
- Q as getWordAtPosition,
664
- ee as shouldTriggerCompletion
790
+ te as getCompletionTriggerCharacters,
791
+ Q as getCompletions,
792
+ ee as getWordAtPosition,
793
+ ae as shouldTriggerCompletion
665
794
  };