@tellaro/tql 0.1.0 → 0.1.2
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 +61 -31
- package/dist/src/completionProvider.js +226 -178
- package/dist/src/complexityAnalyzer.d.ts +55 -0
- package/dist/src/complexityAnalyzer.js +209 -0
- package/dist/src/fuzzyMatcher.d.ts +71 -0
- package/dist/src/fuzzyMatcher.js +110 -0
- package/dist/src/index.d.ts +5 -0
- package/dist/src/parser.d.ts +10 -0
- package/dist/src/parser.js +101 -48
- package/dist/src/schemaCache.d.ts +75 -0
- package/dist/src/schemaCache.js +104 -0
- package/dist/src/semanticPreview.d.ts +72 -0
- package/dist/src/semanticPreview.js +242 -0
- package/dist/src/types.d.ts +121 -0
- package/dist/style.css +1 -1
- package/dist/vue/TqlAutocomplete.vue.js +2 -2
- package/dist/vue/TqlAutocomplete.vue2.js +62 -56
- package/dist/vue/TqlInput.vue.js +2 -1
- package/dist/vue/TqlInput.vue2.js +477 -215
- package/dist/vue/components/TqlPreview.vue.d.ts +4 -0
- package/dist/vue/components/TqlPreview.vue.js +9 -0
- package/dist/vue/components/TqlPreview.vue2.js +264 -0
- package/dist/vue/composables/useQueryHistory.d.ts +35 -0
- package/dist/vue/composables/useQueryHistory.js +176 -0
- package/dist/vue/index.d.ts +2 -0
- package/dist/vue/index.js +10 -6
- package/dist/vue/useTqlInput.js +79 -77
- package/package.json +3 -1
|
@@ -1,5 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
var I = Object.defineProperty;
|
|
2
|
+
var S = (e, t, a) => t in e ? I(e, t, { enumerable: !0, configurable: !0, writable: !0, value: a }) : e[t] = a;
|
|
3
|
+
var p = (e, t, a) => S(e, typeof t != "symbol" ? t + "" : t, a);
|
|
4
|
+
import { tokenizeTql as b, COMPARISON_OPERATORS as A, LOGICAL_OPERATORS as L, AGGREGATION_FUNCTIONS as R, VISUALIZATION_TYPES as $, TYPE_HINTS as P, MUTATORS as D } from "./tokenizer.js";
|
|
5
|
+
import { fuzzyMatch as _ } from "./fuzzyMatcher.js";
|
|
6
|
+
import { getSchemaCache as M } from "./schemaCache.js";
|
|
7
|
+
const E = [
|
|
3
8
|
{
|
|
4
9
|
label: "Simple equality",
|
|
5
10
|
insertText: 'field eq "value"',
|
|
@@ -102,7 +107,7 @@ const I = [
|
|
|
102
107
|
description: "Top 10 results by count",
|
|
103
108
|
category: "Stats"
|
|
104
109
|
}
|
|
105
|
-
],
|
|
110
|
+
], U = {
|
|
106
111
|
eq: { detail: "Equals", documentation: "Exact match comparison" },
|
|
107
112
|
ne: { detail: "Not equals", documentation: "Match any value except this one" },
|
|
108
113
|
gt: { detail: "Greater than", documentation: "Numeric/date comparison" },
|
|
@@ -136,7 +141,7 @@ const I = [
|
|
|
136
141
|
not_any: { detail: "Not any matches", documentation: "Negation of any" },
|
|
137
142
|
not_all: { detail: "Not all match", documentation: "Negation of all" },
|
|
138
143
|
not_none: { detail: "Not none match", documentation: "Negation of none" }
|
|
139
|
-
},
|
|
144
|
+
}, z = {
|
|
140
145
|
lowercase: { detail: "Convert to lowercase", documentation: "Transform string to lowercase" },
|
|
141
146
|
uppercase: { detail: "Convert to uppercase", documentation: "Transform string to uppercase" },
|
|
142
147
|
trim: { detail: "Trim whitespace", documentation: "Remove leading/trailing whitespace" },
|
|
@@ -165,7 +170,7 @@ const I = [
|
|
|
165
170
|
sum: { detail: "Sum", documentation: "Sum of numeric array elements" },
|
|
166
171
|
min: { detail: "Minimum", documentation: "Minimum value in array" },
|
|
167
172
|
max: { detail: "Maximum", documentation: "Maximum value in array" }
|
|
168
|
-
},
|
|
173
|
+
}, h = {
|
|
169
174
|
// String outputs
|
|
170
175
|
lowercase: "keyword",
|
|
171
176
|
uppercase: "keyword",
|
|
@@ -199,7 +204,7 @@ const I = [
|
|
|
199
204
|
geo: "object",
|
|
200
205
|
// Array output (returns array of strings)
|
|
201
206
|
split: "keyword"
|
|
202
|
-
},
|
|
207
|
+
}, F = {
|
|
203
208
|
// Universal operators (work with all types)
|
|
204
209
|
eq: ["text", "keyword", "long", "integer", "double", "float", "date", "boolean", "ip"],
|
|
205
210
|
ne: ["text", "keyword", "long", "integer", "double", "float", "date", "boolean", "ip"],
|
|
@@ -236,147 +241,190 @@ const I = [
|
|
|
236
241
|
all: ["nested", "object", "keyword"],
|
|
237
242
|
none: ["nested", "object", "keyword"]
|
|
238
243
|
};
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
244
|
+
class q {
|
|
245
|
+
constructor() {
|
|
246
|
+
p(this, "cache", /* @__PURE__ */ new Map());
|
|
247
|
+
p(this, "maxSize", 50);
|
|
248
|
+
p(this, "maxAge", 5e3);
|
|
249
|
+
}
|
|
250
|
+
// 5 seconds
|
|
251
|
+
get(t) {
|
|
252
|
+
const a = this.cache.get(t);
|
|
253
|
+
if (a && Date.now() - a.timestamp < this.maxAge)
|
|
254
|
+
return a.result;
|
|
255
|
+
a && this.cache.delete(t);
|
|
256
|
+
}
|
|
257
|
+
set(t, a) {
|
|
258
|
+
if (this.cache.size >= this.maxSize) {
|
|
259
|
+
const o = this.cache.keys().next().value;
|
|
260
|
+
o && this.cache.delete(o);
|
|
261
|
+
}
|
|
262
|
+
this.cache.set(t, { result: a, timestamp: Date.now() });
|
|
263
|
+
}
|
|
264
|
+
clear() {
|
|
265
|
+
this.cache.clear();
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
const v = new q();
|
|
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;
|
|
273
|
+
const n = G(e, t, a);
|
|
274
|
+
return v.set(o, n), n;
|
|
275
|
+
}
|
|
276
|
+
function G(e, t, a) {
|
|
277
|
+
var d;
|
|
278
|
+
const i = b(e.substring(0, t)).filter((l) => l.type !== "whitespace");
|
|
279
|
+
if (i.length === 0)
|
|
243
280
|
return { type: "start" };
|
|
244
|
-
const
|
|
245
|
-
if (
|
|
281
|
+
const n = i[i.length - 1], r = i.length > 1 ? i[i.length - 2] : null, u = n.end === t && !((d = e[t - 1]) != null && d.match(/\s/)), s = u ? n.value : void 0;
|
|
282
|
+
if (n.type === "logicalOp")
|
|
246
283
|
return { type: "start" };
|
|
247
|
-
if (
|
|
284
|
+
if (n.type === "paren" && n.value === "(")
|
|
248
285
|
return { type: "after_paren" };
|
|
249
|
-
if (
|
|
250
|
-
return { type: "after_arrow", partialText:
|
|
251
|
-
if (
|
|
252
|
-
return { type: "after_double_colon", partialText:
|
|
253
|
-
if (
|
|
254
|
-
return { type: "after_arrow", partialText:
|
|
255
|
-
if (
|
|
256
|
-
return { type: "after_double_colon", partialText:
|
|
257
|
-
if (
|
|
258
|
-
return { type: "after_stats", partialText:
|
|
259
|
-
if (
|
|
260
|
-
return { type: "after_by", partialText:
|
|
261
|
-
if (
|
|
262
|
-
return { type: "after_pipe", partialText:
|
|
263
|
-
if (
|
|
264
|
-
if (
|
|
265
|
-
return { type: "after_pipe", partialText:
|
|
266
|
-
const
|
|
286
|
+
if (n.type === "arrow")
|
|
287
|
+
return { type: "after_arrow", partialText: s };
|
|
288
|
+
if (n.type === "doubleColon")
|
|
289
|
+
return { type: "after_double_colon", partialText: s };
|
|
290
|
+
if (n.type === "visualization" && u)
|
|
291
|
+
return { type: "after_arrow", partialText: s };
|
|
292
|
+
if (n.type === "typeHint" && u)
|
|
293
|
+
return { type: "after_double_colon", partialText: s };
|
|
294
|
+
if (n.type === "keyword" && n.value.toLowerCase() === "stats")
|
|
295
|
+
return { type: "after_stats", partialText: s };
|
|
296
|
+
if (n.type === "keyword" && n.value.toLowerCase() === "by")
|
|
297
|
+
return { type: "after_by", partialText: s };
|
|
298
|
+
if (n.type === "pipe")
|
|
299
|
+
return { type: "after_pipe", partialText: s };
|
|
300
|
+
if (n.type === "mutator") {
|
|
301
|
+
if (u)
|
|
302
|
+
return { type: "after_pipe", partialText: s };
|
|
303
|
+
const l = n.value.toLowerCase(), c = h[l];
|
|
267
304
|
return {
|
|
268
305
|
type: "after_mutator",
|
|
269
|
-
mutatorName:
|
|
306
|
+
mutatorName: l,
|
|
270
307
|
mutatorOutputType: c
|
|
271
308
|
};
|
|
272
309
|
}
|
|
273
|
-
if (
|
|
274
|
-
return
|
|
275
|
-
if (
|
|
276
|
-
if (
|
|
277
|
-
return (r == null ? void 0 : r.type) === "pipe" ? { type: "after_pipe", partialText:
|
|
310
|
+
if (n.type === "aggregation")
|
|
311
|
+
return u ? { type: "after_stats", partialText: s } : { type: "after_value" };
|
|
312
|
+
if (n.type === "field") {
|
|
313
|
+
if (u)
|
|
314
|
+
return (r == null ? void 0 : r.type) === "pipe" ? { type: "after_pipe", partialText: s } : { type: "start", partialText: s };
|
|
278
315
|
if ((r == null ? void 0 : r.type) === "pipe")
|
|
279
|
-
return { type: "after_pipe", partialText:
|
|
280
|
-
const
|
|
281
|
-
return { type: "after_field", fieldName:
|
|
316
|
+
return { type: "after_pipe", partialText: n.value };
|
|
317
|
+
const l = f(n.value, a);
|
|
318
|
+
return { type: "after_field", fieldName: n.value, fieldType: l };
|
|
282
319
|
}
|
|
283
|
-
if (
|
|
284
|
-
if (
|
|
320
|
+
if (n.type === "operator") {
|
|
321
|
+
if (u) {
|
|
285
322
|
if ((r == null ? void 0 : r.type) === "field") {
|
|
286
|
-
const
|
|
287
|
-
return { type: "after_field", fieldName: r.value, fieldType:
|
|
323
|
+
const l = f(r.value, a);
|
|
324
|
+
return { type: "after_field", fieldName: r.value, fieldType: l, partialText: s };
|
|
288
325
|
}
|
|
289
326
|
if ((r == null ? void 0 : r.type) === "mutator") {
|
|
290
|
-
const
|
|
291
|
-
return { type: "after_mutator", mutatorName:
|
|
327
|
+
const l = r.value.toLowerCase(), c = h[l];
|
|
328
|
+
return { type: "after_mutator", mutatorName: l, mutatorOutputType: c, partialText: s };
|
|
292
329
|
}
|
|
293
330
|
}
|
|
294
|
-
return { type: "after_operator", operatorName:
|
|
331
|
+
return { type: "after_operator", operatorName: n.value };
|
|
295
332
|
}
|
|
296
|
-
if (
|
|
333
|
+
if (n.type === "string" || n.type === "number" || n.type === "boolean" || n.type === "null")
|
|
297
334
|
return { type: "after_value" };
|
|
298
|
-
if (
|
|
335
|
+
if (n.type === "paren" && n.value === ")")
|
|
299
336
|
return { type: "after_value" };
|
|
300
|
-
if ((r == null ? void 0 : r.type) === "field" &&
|
|
301
|
-
const
|
|
302
|
-
return { type: "after_field", fieldName: r.value, fieldType:
|
|
337
|
+
if ((r == null ? void 0 : r.type) === "field" && u) {
|
|
338
|
+
const l = f(r.value, a);
|
|
339
|
+
return { type: "after_field", fieldName: r.value, fieldType: l, partialText: s };
|
|
303
340
|
}
|
|
304
|
-
if ((r == null ? void 0 : r.type) === "mutator" &&
|
|
305
|
-
const
|
|
306
|
-
return { type: "after_mutator", mutatorName:
|
|
341
|
+
if ((r == null ? void 0 : r.type) === "mutator" && u) {
|
|
342
|
+
const l = r.value.toLowerCase(), c = h[l];
|
|
343
|
+
return { type: "after_mutator", mutatorName: l, mutatorOutputType: c, partialText: s };
|
|
307
344
|
}
|
|
308
|
-
return { type: "unknown", partialText:
|
|
345
|
+
return { type: "unknown", partialText: s };
|
|
309
346
|
}
|
|
310
|
-
function
|
|
311
|
-
|
|
312
|
-
const n = t.find((i) => i.name === e);
|
|
313
|
-
return n == null ? void 0 : n.type;
|
|
347
|
+
function f(e, t) {
|
|
348
|
+
return t ? M().getFieldType(t, e) : void 0;
|
|
314
349
|
}
|
|
315
|
-
function
|
|
316
|
-
const { query:
|
|
317
|
-
switch (
|
|
350
|
+
function te(e, t = {}) {
|
|
351
|
+
const { query: a, cursorPosition: o } = e, i = B(a, o, t.fields), n = [];
|
|
352
|
+
switch (i.type) {
|
|
318
353
|
case "start":
|
|
319
354
|
case "after_paren":
|
|
320
|
-
|
|
355
|
+
n.push(...y(t.fields, i.partialText)), n.push(N("NOT")), t.includeSnippets !== !1 && n.push(...Y(t, i.partialText));
|
|
321
356
|
break;
|
|
322
357
|
case "after_field":
|
|
323
|
-
|
|
358
|
+
n.push(...x(i.partialText, i.fieldType));
|
|
324
359
|
break;
|
|
325
360
|
case "after_mutator":
|
|
326
|
-
|
|
361
|
+
n.push(...x(i.partialText, i.mutatorOutputType));
|
|
327
362
|
break;
|
|
328
363
|
case "after_operator":
|
|
329
|
-
|
|
364
|
+
n.push(...H(i.fieldName, t));
|
|
330
365
|
break;
|
|
331
366
|
case "after_value":
|
|
332
|
-
|
|
367
|
+
n.push(...C());
|
|
333
368
|
break;
|
|
334
369
|
case "after_pipe":
|
|
335
|
-
|
|
370
|
+
n.push(...K(i.partialText));
|
|
336
371
|
break;
|
|
337
372
|
case "after_double_colon":
|
|
338
|
-
|
|
373
|
+
n.push(...W(i.partialText));
|
|
339
374
|
break;
|
|
340
375
|
case "after_arrow":
|
|
341
|
-
|
|
376
|
+
n.push(...Z(i.partialText));
|
|
342
377
|
break;
|
|
343
378
|
case "after_stats":
|
|
344
|
-
|
|
379
|
+
n.push(...O(i.partialText));
|
|
345
380
|
break;
|
|
346
381
|
case "after_by":
|
|
347
|
-
|
|
382
|
+
n.push(...y(t.fields, i.partialText));
|
|
348
383
|
break;
|
|
349
384
|
default:
|
|
350
|
-
|
|
385
|
+
n.push(...y(t.fields, i.partialText)), n.push(...x(i.partialText)), n.push(...C());
|
|
351
386
|
}
|
|
352
|
-
t.includeAggregations &&
|
|
353
|
-
let r =
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
387
|
+
t.includeAggregations && i.type === "start" && n.push(...O(i.partialText));
|
|
388
|
+
let r = n;
|
|
389
|
+
const u = t.fuzzyMatching !== !1, s = t.minFuzzyScore ?? 0;
|
|
390
|
+
if (i.partialText) {
|
|
391
|
+
const d = i.partialText.toLowerCase();
|
|
392
|
+
if (u) {
|
|
393
|
+
const l = [];
|
|
394
|
+
for (const c of n) {
|
|
395
|
+
const m = _(d, c.label), w = c.filterText ? _(d, c.filterText) : { matched: !1, score: 0 }, g = m.score >= w.score ? m : w;
|
|
396
|
+
g.matched && g.score >= s && l.push({
|
|
397
|
+
...c,
|
|
398
|
+
matchScore: g.score,
|
|
399
|
+
matchedIndices: m.matched ? m.matchedIndices : void 0
|
|
400
|
+
});
|
|
360
401
|
}
|
|
361
|
-
|
|
402
|
+
r = l;
|
|
403
|
+
} else
|
|
404
|
+
r = n.filter(
|
|
405
|
+
(l) => {
|
|
406
|
+
var c;
|
|
407
|
+
return l.label.toLowerCase().includes(d) || ((c = l.filterText) == null ? void 0 : c.toLowerCase().includes(d));
|
|
408
|
+
}
|
|
409
|
+
);
|
|
362
410
|
}
|
|
363
|
-
return r.sort((d, l) => d.sortOrder - l.sortOrder), t.maxItems && t.maxItems > 0 && (r = r.slice(0, t.maxItems)), r;
|
|
411
|
+
return r.sort((d, l) => d.matchScore !== void 0 && l.matchScore !== void 0 && l.matchScore !== d.matchScore ? l.matchScore - d.matchScore : d.sortOrder - l.sortOrder), t.maxItems && t.maxItems > 0 && (r = r.slice(0, t.maxItems)), r;
|
|
364
412
|
}
|
|
365
|
-
function
|
|
413
|
+
function y(e, t) {
|
|
366
414
|
if (!e || e.length === 0)
|
|
367
|
-
return
|
|
368
|
-
const
|
|
369
|
-
for (const
|
|
370
|
-
const
|
|
371
|
-
if (
|
|
372
|
-
for (const
|
|
373
|
-
const r =
|
|
374
|
-
|
|
415
|
+
return V(t);
|
|
416
|
+
const a = [];
|
|
417
|
+
for (const o of e) {
|
|
418
|
+
const i = k(o);
|
|
419
|
+
if (a.push(i), o.nested)
|
|
420
|
+
for (const n of o.nested) {
|
|
421
|
+
const r = k(n, o.name);
|
|
422
|
+
a.push(r);
|
|
375
423
|
}
|
|
376
424
|
}
|
|
377
|
-
return
|
|
425
|
+
return a;
|
|
378
426
|
}
|
|
379
|
-
function
|
|
427
|
+
function V(e) {
|
|
380
428
|
return [
|
|
381
429
|
{ name: "hostname", description: "Host/machine name" },
|
|
382
430
|
{ name: "status", description: "Status value" },
|
|
@@ -393,44 +441,44 @@ function $(e) {
|
|
|
393
441
|
{ name: "os.version", description: "Operating system version" },
|
|
394
442
|
{ name: "customer", description: "Customer identifier" },
|
|
395
443
|
{ name: "stack", description: "Stack identifier" }
|
|
396
|
-
].filter((
|
|
397
|
-
label:
|
|
398
|
-
insertText:
|
|
444
|
+
].filter((a) => !e || a.name.toLowerCase().includes(e.toLowerCase())).map((a) => ({
|
|
445
|
+
label: a.name,
|
|
446
|
+
insertText: a.name,
|
|
399
447
|
kind: "field",
|
|
400
|
-
detail:
|
|
448
|
+
detail: a.description,
|
|
401
449
|
sortOrder: 10
|
|
402
450
|
}));
|
|
403
451
|
}
|
|
404
|
-
function
|
|
405
|
-
const
|
|
452
|
+
function k(e, t) {
|
|
453
|
+
const a = t ? `${t}.${e.name}` : e.name;
|
|
406
454
|
return {
|
|
407
|
-
label:
|
|
408
|
-
insertText:
|
|
455
|
+
label: a,
|
|
456
|
+
insertText: a,
|
|
409
457
|
kind: "field",
|
|
410
458
|
detail: e.description || `Type: ${e.type}`,
|
|
411
459
|
documentation: e.examples ? `Examples: ${e.examples.join(", ")}` : void 0,
|
|
412
460
|
sortOrder: 10
|
|
413
461
|
};
|
|
414
462
|
}
|
|
415
|
-
function
|
|
416
|
-
let
|
|
417
|
-
return t && (
|
|
418
|
-
const
|
|
419
|
-
return !
|
|
420
|
-
})), e && (
|
|
421
|
-
const
|
|
463
|
+
function x(e, t) {
|
|
464
|
+
let a = [...A];
|
|
465
|
+
return t && (a = a.filter((o) => {
|
|
466
|
+
const i = F[o];
|
|
467
|
+
return !i || i.includes(t);
|
|
468
|
+
})), e && (a = a.filter((o) => o.toLowerCase().includes(e.toLowerCase()))), a.map((o, i) => {
|
|
469
|
+
const n = U[o] || { detail: o, documentation: "" }, r = j(o, t);
|
|
422
470
|
return {
|
|
423
|
-
label:
|
|
471
|
+
label: o,
|
|
424
472
|
insertText: r,
|
|
425
473
|
kind: "operator",
|
|
426
|
-
detail:
|
|
427
|
-
documentation:
|
|
428
|
-
sortOrder: 20 +
|
|
474
|
+
detail: n.detail,
|
|
475
|
+
documentation: n.documentation,
|
|
476
|
+
sortOrder: 20 + i
|
|
429
477
|
};
|
|
430
478
|
});
|
|
431
479
|
}
|
|
432
|
-
function
|
|
433
|
-
const
|
|
480
|
+
function j(e, t) {
|
|
481
|
+
const a = [
|
|
434
482
|
"contains",
|
|
435
483
|
"not_contains",
|
|
436
484
|
"startswith",
|
|
@@ -442,18 +490,18 @@ function P(e, t) {
|
|
|
442
490
|
"not_regexp",
|
|
443
491
|
"matches",
|
|
444
492
|
"not_matches"
|
|
445
|
-
],
|
|
493
|
+
], o = ["exists", "not_exists"], i = ["is", "is_not"];
|
|
446
494
|
if (e === "in" || e === "not_in")
|
|
447
|
-
return
|
|
495
|
+
return T(t) ? `${e} [$1]` : `${e} ["$1"]`;
|
|
448
496
|
if (e === "between" || e === "not_between")
|
|
449
|
-
return
|
|
450
|
-
if (o.includes(e))
|
|
451
|
-
return `${e} null`;
|
|
497
|
+
return T(t) ? `${e} $1 AND $2` : `${e} "$1" AND "$2"`;
|
|
452
498
|
if (i.includes(e))
|
|
499
|
+
return `${e} null`;
|
|
500
|
+
if (o.includes(e))
|
|
453
501
|
return e;
|
|
454
502
|
if (e === "cidr" || e === "not_cidr")
|
|
455
503
|
return `${e} "$1"`;
|
|
456
|
-
if (
|
|
504
|
+
if (a.includes(e))
|
|
457
505
|
return `${e} "$1"`;
|
|
458
506
|
if (!t)
|
|
459
507
|
return `${e} `;
|
|
@@ -476,15 +524,15 @@ function P(e, t) {
|
|
|
476
524
|
return `${e} `;
|
|
477
525
|
}
|
|
478
526
|
}
|
|
479
|
-
function
|
|
527
|
+
function T(e) {
|
|
480
528
|
return e === "long" || e === "integer" || e === "double" || e === "float" || e === "short" || e === "byte" || e === "half_float" || e === "scaled_float" || e === "unsigned_long";
|
|
481
529
|
}
|
|
482
|
-
function
|
|
483
|
-
return
|
|
484
|
-
(e, t) =>
|
|
530
|
+
function C() {
|
|
531
|
+
return L.filter((e) => e !== "NOT").map(
|
|
532
|
+
(e, t) => N(e, t)
|
|
485
533
|
);
|
|
486
534
|
}
|
|
487
|
-
function
|
|
535
|
+
function N(e, t = 0) {
|
|
488
536
|
return {
|
|
489
537
|
label: e,
|
|
490
538
|
insertText: e + " ",
|
|
@@ -493,18 +541,18 @@ function _(e, t = 0) {
|
|
|
493
541
|
sortOrder: 30 + t
|
|
494
542
|
};
|
|
495
543
|
}
|
|
496
|
-
function
|
|
497
|
-
var
|
|
498
|
-
const
|
|
499
|
-
return e && ((
|
|
500
|
-
|
|
501
|
-
label:
|
|
502
|
-
insertText: `"${
|
|
544
|
+
function H(e, t) {
|
|
545
|
+
var o;
|
|
546
|
+
const a = [];
|
|
547
|
+
return e && ((o = t == null ? void 0 : t.fieldValues) != null && o[e]) && t.fieldValues[e].forEach((n, r) => {
|
|
548
|
+
a.push({
|
|
549
|
+
label: n,
|
|
550
|
+
insertText: `"${n}"`,
|
|
503
551
|
kind: "value",
|
|
504
552
|
detail: `Known value for ${e}`,
|
|
505
553
|
sortOrder: 40 + r
|
|
506
554
|
});
|
|
507
|
-
}),
|
|
555
|
+
}), a.push(
|
|
508
556
|
{
|
|
509
557
|
label: '"text"',
|
|
510
558
|
insertText: '"$1"',
|
|
@@ -533,87 +581,87 @@ function D(e, t) {
|
|
|
533
581
|
detail: "Null value",
|
|
534
582
|
sortOrder: 53
|
|
535
583
|
}
|
|
536
|
-
),
|
|
584
|
+
), a;
|
|
537
585
|
}
|
|
538
|
-
function
|
|
539
|
-
return
|
|
540
|
-
label:
|
|
541
|
-
insertText:
|
|
586
|
+
function Y(e, t) {
|
|
587
|
+
return E.filter((o) => !t || o.label.toLowerCase().includes(t.toLowerCase())).map((o, i) => ({
|
|
588
|
+
label: o.label,
|
|
589
|
+
insertText: o.insertText,
|
|
542
590
|
kind: "snippet",
|
|
543
|
-
detail:
|
|
544
|
-
documentation: `Insert: ${
|
|
545
|
-
sortOrder: 100 +
|
|
591
|
+
detail: o.description,
|
|
592
|
+
documentation: `Insert: ${o.insertText}`,
|
|
593
|
+
sortOrder: 100 + i
|
|
546
594
|
}));
|
|
547
595
|
}
|
|
548
|
-
function
|
|
549
|
-
return
|
|
550
|
-
(t,
|
|
551
|
-
const
|
|
596
|
+
function K(e) {
|
|
597
|
+
return D.filter((t) => !e || t.toLowerCase().includes(e.toLowerCase())).map(
|
|
598
|
+
(t, a) => {
|
|
599
|
+
const o = z[t] || { detail: "Field mutator", documentation: "" };
|
|
552
600
|
return {
|
|
553
601
|
label: t,
|
|
554
602
|
insertText: t,
|
|
555
603
|
kind: "mutator",
|
|
556
|
-
detail:
|
|
557
|
-
documentation:
|
|
558
|
-
sortOrder: 60 +
|
|
604
|
+
detail: o.detail,
|
|
605
|
+
documentation: o.documentation,
|
|
606
|
+
sortOrder: 60 + a
|
|
559
607
|
};
|
|
560
608
|
}
|
|
561
609
|
);
|
|
562
610
|
}
|
|
563
|
-
function
|
|
564
|
-
return
|
|
611
|
+
function O(e) {
|
|
612
|
+
return R.filter(
|
|
565
613
|
(t) => !e || t.toLowerCase().includes(e.toLowerCase())
|
|
566
|
-
).map((t,
|
|
614
|
+
).map((t, a) => ({
|
|
567
615
|
label: t,
|
|
568
616
|
insertText: `${t}($1)`,
|
|
569
617
|
kind: "aggregation",
|
|
570
618
|
detail: "Aggregation function",
|
|
571
|
-
sortOrder: 70 +
|
|
619
|
+
sortOrder: 70 + a
|
|
572
620
|
}));
|
|
573
621
|
}
|
|
574
|
-
function
|
|
575
|
-
return
|
|
622
|
+
function W(e) {
|
|
623
|
+
return P.filter(
|
|
576
624
|
(t) => !e || t.toLowerCase().includes(e.toLowerCase())
|
|
577
|
-
).map((t,
|
|
625
|
+
).map((t, a) => ({
|
|
578
626
|
label: t,
|
|
579
627
|
insertText: t,
|
|
580
628
|
kind: "typeHint",
|
|
581
629
|
detail: "Type hint",
|
|
582
|
-
sortOrder: 80 +
|
|
630
|
+
sortOrder: 80 + a
|
|
583
631
|
}));
|
|
584
632
|
}
|
|
585
|
-
function
|
|
586
|
-
return
|
|
633
|
+
function Z(e) {
|
|
634
|
+
return $.filter(
|
|
587
635
|
(t) => !e || t.toLowerCase().includes(e.toLowerCase())
|
|
588
|
-
).map((t,
|
|
636
|
+
).map((t, a) => ({
|
|
589
637
|
label: t,
|
|
590
638
|
insertText: t,
|
|
591
639
|
kind: "visualization",
|
|
592
640
|
detail: "Visualization type",
|
|
593
|
-
sortOrder: 90 +
|
|
641
|
+
sortOrder: 90 + a
|
|
594
642
|
}));
|
|
595
643
|
}
|
|
596
|
-
function
|
|
597
|
-
const
|
|
598
|
-
(
|
|
644
|
+
function ae(e, t) {
|
|
645
|
+
const o = b(e).find(
|
|
646
|
+
(i) => i.start <= t && i.end >= t && i.type !== "whitespace"
|
|
599
647
|
);
|
|
600
|
-
return
|
|
601
|
-
word:
|
|
602
|
-
start:
|
|
603
|
-
end:
|
|
648
|
+
return o ? {
|
|
649
|
+
word: o.value,
|
|
650
|
+
start: o.start,
|
|
651
|
+
end: o.end
|
|
604
652
|
} : null;
|
|
605
653
|
}
|
|
606
|
-
function
|
|
654
|
+
function ne() {
|
|
607
655
|
return [" ", "(", ".", '"', "'", "|", ":", "="];
|
|
608
656
|
}
|
|
609
|
-
function
|
|
610
|
-
if (
|
|
611
|
-
const
|
|
612
|
-
return !!(
|
|
657
|
+
function ie(e, t, a) {
|
|
658
|
+
if (a === " " || a === "(" || a === "." || a === "|" || a === ":" || a === "=") return !0;
|
|
659
|
+
const o = b(e.substring(0, t)), i = o[o.length - 1];
|
|
660
|
+
return !!(i && i.type === "field" && i.value.length >= 2);
|
|
613
661
|
}
|
|
614
662
|
export {
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
663
|
+
ne as getCompletionTriggerCharacters,
|
|
664
|
+
te as getCompletions,
|
|
665
|
+
ae as getWordAtPosition,
|
|
666
|
+
ie as shouldTriggerCompletion
|
|
619
667
|
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { ComplexityMetrics, ComplexityResult, ComplexityThresholds, ComplexityWarning } from './types';
|
|
2
|
+
|
|
3
|
+
export declare class ComplexityAnalyzer {
|
|
4
|
+
private thresholds;
|
|
5
|
+
constructor(thresholds?: ComplexityThresholds);
|
|
6
|
+
/**
|
|
7
|
+
* Analyze a TQL query for complexity
|
|
8
|
+
*/
|
|
9
|
+
analyze(query: string): ComplexityResult;
|
|
10
|
+
/**
|
|
11
|
+
* Recursively analyze an expression and collect metrics
|
|
12
|
+
*/
|
|
13
|
+
private analyzeExpression;
|
|
14
|
+
private analyzeBinaryExpression;
|
|
15
|
+
private analyzeUnaryExpression;
|
|
16
|
+
private analyzeGroupExpression;
|
|
17
|
+
private analyzeComparisonExpression;
|
|
18
|
+
private analyzeValue;
|
|
19
|
+
/**
|
|
20
|
+
* Calculate the length of OR chains (consecutive ORs)
|
|
21
|
+
*/
|
|
22
|
+
private calculateOrChainLength;
|
|
23
|
+
/**
|
|
24
|
+
* Calculate the length of AND chains (consecutive ANDs)
|
|
25
|
+
*/
|
|
26
|
+
private calculateAndChainLength;
|
|
27
|
+
/**
|
|
28
|
+
* Generate warnings based on collected metrics
|
|
29
|
+
*/
|
|
30
|
+
private generateWarnings;
|
|
31
|
+
/**
|
|
32
|
+
* Generate optimization suggestions based on warnings
|
|
33
|
+
*/
|
|
34
|
+
private generateSuggestions;
|
|
35
|
+
/**
|
|
36
|
+
* Calculate overall complexity score based on metrics and warnings
|
|
37
|
+
*/
|
|
38
|
+
private calculateScore;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Analyze a TQL query for complexity using default thresholds
|
|
42
|
+
*/
|
|
43
|
+
export declare function analyzeComplexity(query: string, thresholds?: ComplexityThresholds): ComplexityResult;
|
|
44
|
+
/**
|
|
45
|
+
* Quick check if a query is considered high complexity
|
|
46
|
+
*/
|
|
47
|
+
export declare function isHighComplexity(query: string, thresholds?: ComplexityThresholds): boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Get only warnings for a query (without full analysis)
|
|
50
|
+
*/
|
|
51
|
+
export declare function getComplexityWarnings(query: string, thresholds?: ComplexityThresholds): ComplexityWarning[];
|
|
52
|
+
/**
|
|
53
|
+
* Get complexity metrics for a query
|
|
54
|
+
*/
|
|
55
|
+
export declare function getComplexityMetrics(query: string): ComplexityMetrics;
|