@tellaro/tql 1.5.0 → 3.0.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.
- package/dist/index.js +73 -65
- package/dist/src/builder.d.ts +6 -0
- package/dist/src/completionProvider.js +276 -195
- package/dist/src/complexityAnalyzer.js +41 -32
- package/dist/src/index.d.ts +3 -3
- package/dist/src/parser.d.ts +193 -1
- package/dist/src/parser.js +614 -127
- package/dist/src/semanticPreview.d.ts +23 -0
- package/dist/src/semanticPreview.js +111 -41
- package/dist/src/tokenizer.d.ts +134 -5
- package/dist/src/tokenizer.js +47 -30
- package/dist/src/types.d.ts +138 -10
- package/dist/src/validator.d.ts +235 -1
- package/dist/src/validator.js +468 -150
- package/dist/tql.css +1 -1
- package/dist/vue/TqlAutocomplete.vue.d.ts +24 -1
- package/dist/vue/TqlChart.vue.d.ts +19 -1
- package/dist/vue/TqlChart.vue.js +1 -1
- package/dist/vue/TqlInput.vue.d.ts +92 -1
- package/dist/vue/TqlInput.vue.js +1 -1
- package/dist/vue/TqlInput.vue2.js +282 -256
- package/dist/vue/components/TqlPreview.vue.d.ts +89 -2
- package/dist/vue/components/TqlPreview.vue.js +4 -4
- package/dist/vue/index.d.ts +1 -1
- package/dist/vue/useTqlInput.d.ts +38 -29
- package/package.json +3 -5
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { tokenizeTql as
|
|
2
|
-
import { fuzzyMatch as
|
|
3
|
-
import { getSchemaCache as
|
|
4
|
-
|
|
1
|
+
import { BOOLEAN_PREDICATE_MUTATORS as L, tokenizeTql as T, COMPARISON_OPERATORS as E, LOGICAL_OPERATORS as R, AGGREGATION_FUNCTIONS as P, VISUALIZATION_TYPES as $, TYPE_HINTS as D, MUTATORS as M } from "./tokenizer.js";
|
|
2
|
+
import { fuzzyMatch as _ } from "./fuzzyMatcher.js";
|
|
3
|
+
import { getSchemaCache as S } from "./schemaCache.js";
|
|
4
|
+
import { ALL_FIELD_TYPES as u, BETWEEN_FIELD_TYPES as w, ORDERED_FIELD_TYPES as f } from "./validator.js";
|
|
5
|
+
const z = [
|
|
5
6
|
{
|
|
6
7
|
label: "Simple equality",
|
|
7
8
|
insertText: 'field eq "value"',
|
|
@@ -104,13 +105,25 @@ const P = [
|
|
|
104
105
|
description: "Top 10 results by count",
|
|
105
106
|
category: "Stats"
|
|
106
107
|
}
|
|
107
|
-
],
|
|
108
|
+
], U = {
|
|
108
109
|
eq: { detail: "Equals", documentation: "Exact match comparison" },
|
|
109
110
|
ne: { detail: "Not equals", documentation: "Match any value except this one" },
|
|
110
|
-
gt: {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
111
|
+
gt: {
|
|
112
|
+
detail: "Greater than",
|
|
113
|
+
documentation: "Ordered comparison. Numbers and dates compare numerically; two STRINGS compare lexicographically. An array-valued field matches if ANY element does."
|
|
114
|
+
},
|
|
115
|
+
gte: {
|
|
116
|
+
detail: "Greater than or equal",
|
|
117
|
+
documentation: "Ordered comparison. Numbers and dates compare numerically; two STRINGS compare lexicographically. An array-valued field matches if ANY element does."
|
|
118
|
+
},
|
|
119
|
+
lt: {
|
|
120
|
+
detail: "Less than",
|
|
121
|
+
documentation: "Ordered comparison. Numbers and dates compare numerically; two STRINGS compare lexicographically. An array-valued field matches if ANY element does."
|
|
122
|
+
},
|
|
123
|
+
lte: {
|
|
124
|
+
detail: "Less than or equal",
|
|
125
|
+
documentation: "Ordered comparison. Numbers and dates compare numerically; two STRINGS compare lexicographically. An array-valued field matches if ANY element does."
|
|
126
|
+
},
|
|
114
127
|
contains: { detail: "Contains substring", documentation: "Case-insensitive substring match" },
|
|
115
128
|
not_contains: { detail: "Does not contain", documentation: "Negative substring match" },
|
|
116
129
|
startswith: { detail: "Starts with", documentation: "Match prefix of field value" },
|
|
@@ -123,23 +136,47 @@ const P = [
|
|
|
123
136
|
not_regex: { detail: "Not matching regex", documentation: "Alias for not_regexp" },
|
|
124
137
|
matches: { detail: "Pattern match", documentation: "Match using pattern" },
|
|
125
138
|
not_matches: { detail: "Not matching pattern", documentation: "Negative pattern match" },
|
|
126
|
-
between: {
|
|
139
|
+
between: {
|
|
140
|
+
detail: "Between range",
|
|
141
|
+
documentation: "Inclusive range. Usage: field between A AND B, or field between [A, B]. Numeric bounds compare numerically; STRING bounds compare lexicographically, matching the range query this becomes on a keyword field."
|
|
142
|
+
},
|
|
127
143
|
not_between: { detail: "Not between range", documentation: "Exclude values in range" },
|
|
128
144
|
in: { detail: "In list", documentation: 'Usage: field in ["a", "b", "c"]' },
|
|
129
145
|
not_in: { detail: "Not in list", documentation: "Exclude values in list" },
|
|
130
|
-
exists: {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
146
|
+
exists: {
|
|
147
|
+
detail: "Field exists",
|
|
148
|
+
documentation: "Field HAS A VALUE. An empty array [] counts as present."
|
|
149
|
+
},
|
|
150
|
+
not_exists: {
|
|
151
|
+
detail: "Field not exists",
|
|
152
|
+
documentation: "Field HAS NO VALUE — absent, or present and explicitly null. Identical to `field is null`. An empty array [] does NOT satisfy it."
|
|
153
|
+
},
|
|
154
|
+
is: {
|
|
155
|
+
detail: "Is null check",
|
|
156
|
+
documentation: "Usage: field is null. Means the field HAS NO VALUE — absent, OR present and explicitly null — so it is identical to `field not exists`. An empty array [] is a PRESENT value and does not satisfy it."
|
|
157
|
+
},
|
|
158
|
+
is_not: {
|
|
159
|
+
detail: "Is not null check",
|
|
160
|
+
documentation: "Usage: field is_not null (or `field is not null`). The exact complement of `is null`, and identical to `field exists`."
|
|
161
|
+
},
|
|
134
162
|
cidr: { detail: "CIDR match", documentation: "Match IP addresses in CIDR range (IP fields only)" },
|
|
135
163
|
not_cidr: { detail: "Not in CIDR", documentation: "Exclude IPs in CIDR range" },
|
|
136
|
-
any: {
|
|
137
|
-
|
|
138
|
-
|
|
164
|
+
any: {
|
|
165
|
+
detail: "Any element matches",
|
|
166
|
+
documentation: "True if any element matches. A SCALAR field is treated as a one-element collection, so `any` works on non-array fields too."
|
|
167
|
+
},
|
|
168
|
+
all: {
|
|
169
|
+
detail: "All elements match",
|
|
170
|
+
documentation: "True if every element matches. A scalar field is treated as a one-element collection."
|
|
171
|
+
},
|
|
172
|
+
none: {
|
|
173
|
+
detail: "No elements match",
|
|
174
|
+
documentation: "True if no element matches. A scalar field is treated as a one-element collection."
|
|
175
|
+
},
|
|
139
176
|
not_any: { detail: "Not any matches", documentation: "Negation of any" },
|
|
140
177
|
not_all: { detail: "Not all match", documentation: "Negation of all" },
|
|
141
178
|
not_none: { detail: "Not none match", documentation: "Negation of none" }
|
|
142
|
-
},
|
|
179
|
+
}, F = {
|
|
143
180
|
lowercase: { detail: "Convert to lowercase", documentation: "Transform string to lowercase" },
|
|
144
181
|
uppercase: { detail: "Convert to uppercase", documentation: "Transform string to uppercase" },
|
|
145
182
|
trim: { detail: "Trim whitespace", documentation: "Remove leading/trailing whitespace" },
|
|
@@ -155,8 +192,14 @@ const P = [
|
|
|
155
192
|
sha256: { detail: "SHA256 hash", documentation: "Calculate SHA256 hash" },
|
|
156
193
|
refang: { detail: "Refang IOC", documentation: "Convert defanged URL/IP to normal form" },
|
|
157
194
|
defang: { detail: "Defang IOC", documentation: "Convert URL/IP to safe defanged form" },
|
|
158
|
-
is_private: {
|
|
159
|
-
|
|
195
|
+
is_private: {
|
|
196
|
+
detail: "Is private IP",
|
|
197
|
+
documentation: "True if the IP is not globally reachable: RFC1918, loopback, link-local, IPv6 ULA, TEST-NET-1/2/3, benchmarking (198.18/15), class E (240/4) and 2001:db8::/32. NOT true for CGNAT 100.64/10, which is neither private nor global."
|
|
198
|
+
},
|
|
199
|
+
is_global: {
|
|
200
|
+
detail: "Is global IP",
|
|
201
|
+
documentation: "True only if the IP is genuinely routable. Not the inverse of is_private: CGNAT 100.64/10 and multicast are neither private nor global."
|
|
202
|
+
},
|
|
160
203
|
nslookup: { detail: "DNS lookup", documentation: "Perform DNS lookup on hostname/IP" },
|
|
161
204
|
geoip_lookup: { detail: "GeoIP lookup", documentation: "Get geolocation data for IP" },
|
|
162
205
|
geoip: { detail: "GeoIP lookup", documentation: "Alias for geoip_lookup" },
|
|
@@ -168,7 +211,7 @@ const P = [
|
|
|
168
211
|
sum: { detail: "Sum", documentation: "Sum of numeric array elements" },
|
|
169
212
|
min: { detail: "Minimum", documentation: "Minimum value in array" },
|
|
170
213
|
max: { detail: "Maximum", documentation: "Maximum value in array" }
|
|
171
|
-
},
|
|
214
|
+
}, g = {
|
|
172
215
|
// String outputs
|
|
173
216
|
lowercase: "keyword",
|
|
174
217
|
uppercase: "keyword",
|
|
@@ -185,8 +228,20 @@ const P = [
|
|
|
185
228
|
defang: "keyword",
|
|
186
229
|
nslookup: "keyword",
|
|
187
230
|
// Boolean outputs
|
|
188
|
-
|
|
189
|
-
is_global
|
|
231
|
+
//
|
|
232
|
+
// SPREAD, not listed. This table used to name `is_private` and `is_global` by hand and
|
|
233
|
+
// stop there, so `is_loopback`, `is_multicast` and `is_link_local` — the three predicates
|
|
234
|
+
// added later — fell through to no declared output type and were offered the operator set
|
|
235
|
+
// for an unknown field. That is the identical omission Python made in three copies of its
|
|
236
|
+
// predicate list, and the reason both engines now derive the set instead of writing it out.
|
|
237
|
+
// There is exactly one JS copy, in `tokenizer.ts`, pinned against both engines by
|
|
238
|
+
// `tests/booleanPredicateSugar.spec.ts`.
|
|
239
|
+
...Object.fromEntries(
|
|
240
|
+
L.map((e) => [e, "boolean"])
|
|
241
|
+
),
|
|
242
|
+
// `any` and `all` are collection OPERATORS rather than predicates — absent from both
|
|
243
|
+
// engines' predicate sets, and not eligible for the `field | <name>` filter sugar — so
|
|
244
|
+
// they are declared here and not folded into the set above.
|
|
190
245
|
any: "boolean",
|
|
191
246
|
all: "boolean",
|
|
192
247
|
// Number outputs
|
|
@@ -202,23 +257,32 @@ const P = [
|
|
|
202
257
|
geo: "object",
|
|
203
258
|
// Array output (returns array of strings)
|
|
204
259
|
split: "keyword"
|
|
205
|
-
},
|
|
206
|
-
//
|
|
207
|
-
eq:
|
|
208
|
-
ne:
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
is
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
260
|
+
}, G = {
|
|
261
|
+
// Equality and membership — every field type, by NAME rather than by a transcribed list.
|
|
262
|
+
eq: u,
|
|
263
|
+
ne: u,
|
|
264
|
+
in: u,
|
|
265
|
+
not_in: u,
|
|
266
|
+
// Existence. `is null` is the SAME PREDICATE as `not exists`, so these four lists must be
|
|
267
|
+
// equal. They were not: `nested` and `object` were offered for `exists` and withheld from
|
|
268
|
+
// `is`, so the completion menu published one of two spellings of one operation depending
|
|
269
|
+
// on the field type. Pinned by `tests/collectionAndNullSemantics.spec.ts`.
|
|
270
|
+
exists: u,
|
|
271
|
+
not_exists: u,
|
|
272
|
+
is: u,
|
|
273
|
+
is_not: u,
|
|
274
|
+
// Ordered comparison — numeric, date and keyword. See ORDERED_FIELD_TYPES in
|
|
275
|
+
// `validator.ts`: both evaluators fall back to a lexicographic string comparison, and
|
|
276
|
+
// Python's own validator lists all four in `keyword_ops`. Withholding them from a keyword
|
|
277
|
+
// field's menu hid an operator every layer of the product supports.
|
|
278
|
+
gt: f,
|
|
279
|
+
gte: f,
|
|
280
|
+
lt: f,
|
|
281
|
+
lte: f,
|
|
282
|
+
// Numeric and date. `keyword` and `text` stay out because Python's `keyword_ops` excludes
|
|
283
|
+
// `between` while including `gte` — see BETWEEN_FIELD_TYPES in `validator.ts`.
|
|
284
|
+
between: w,
|
|
285
|
+
not_between: w,
|
|
222
286
|
// String operators (text/keyword only)
|
|
223
287
|
contains: ["text", "keyword"],
|
|
224
288
|
not_contains: ["text", "keyword"],
|
|
@@ -235,12 +299,27 @@ const P = [
|
|
|
235
299
|
// IP-specific operators
|
|
236
300
|
cidr: ["ip"],
|
|
237
301
|
not_cidr: ["ip"],
|
|
238
|
-
// Collection operators
|
|
239
|
-
|
|
240
|
-
all
|
|
241
|
-
|
|
302
|
+
// Collection operators — every field type, and their negated forms stated explicitly.
|
|
303
|
+
//
|
|
304
|
+
// Two defects in four lines. `any`/`all`/`none` were restricted to `nested | object |
|
|
305
|
+
// keyword`, so the menu withheld them from an `ip` or `long` field — while both
|
|
306
|
+
// evaluators now treat a SCALAR as a one-element collection and iterate array-valued
|
|
307
|
+
// fields regardless of mapping type. `related.ip any [...]` is the ordinary case for an IP
|
|
308
|
+
// field: OpenSearch has no array type, so ECS's array guarantees live on ordinary `ip` and
|
|
309
|
+
// `keyword` mappings.
|
|
310
|
+
//
|
|
311
|
+
// And `not_any`/`not_all`/`not_none` were absent from this table entirely, which the
|
|
312
|
+
// filter reads as "no restriction" — so the negated halves were offered on every type
|
|
313
|
+
// while their positive twins were withheld. Permissive by omission is not the same as
|
|
314
|
+
// permissive by decision, and only one of them survives someone reading the table.
|
|
315
|
+
any: u,
|
|
316
|
+
all: u,
|
|
317
|
+
none: u,
|
|
318
|
+
not_any: u,
|
|
319
|
+
not_all: u,
|
|
320
|
+
not_none: u
|
|
242
321
|
};
|
|
243
|
-
class
|
|
322
|
+
class B {
|
|
244
323
|
cache = /* @__PURE__ */ new Map();
|
|
245
324
|
maxSize = 50;
|
|
246
325
|
maxAge = 5e3;
|
|
@@ -262,149 +341,151 @@ class E {
|
|
|
262
341
|
this.cache.clear();
|
|
263
342
|
}
|
|
264
343
|
}
|
|
265
|
-
const k = new
|
|
266
|
-
function
|
|
344
|
+
const k = new B();
|
|
345
|
+
function V(e, t, i) {
|
|
267
346
|
if (!e) return { type: "start", partialText: "" };
|
|
268
|
-
const o = `${e.substring(0, t)}|${t}`, a = k.get(
|
|
347
|
+
const o = S().get(i)?.hash ?? "-", n = `${e.substring(0, t)}|${t}|${o}`, a = k.get(n);
|
|
269
348
|
if (a)
|
|
270
|
-
return a.fieldName && !a.fieldType && i && (a.fieldType =
|
|
271
|
-
const
|
|
272
|
-
return k.set(
|
|
349
|
+
return a.fieldName && !a.fieldType && i && (a.fieldType = h(a.fieldName, i)), a;
|
|
350
|
+
const s = Y(e, t, i);
|
|
351
|
+
return k.set(n, s), s;
|
|
273
352
|
}
|
|
274
|
-
function
|
|
275
|
-
const
|
|
276
|
-
if (
|
|
353
|
+
function Y(e, t, i) {
|
|
354
|
+
const n = T(e.substring(0, t)).filter((l) => l.type !== "whitespace");
|
|
355
|
+
if (n.length === 0)
|
|
277
356
|
return { type: "start" };
|
|
278
|
-
const
|
|
279
|
-
if (
|
|
357
|
+
const a = n[n.length - 1], s = n.length > 1 ? n[n.length - 2] : null, c = a.end === t && !e[t - 1]?.match(/\s/), d = c ? a.value : void 0;
|
|
358
|
+
if (a.type === "logicalOp")
|
|
280
359
|
return { type: "start" };
|
|
281
|
-
if (
|
|
282
|
-
const l =
|
|
360
|
+
if (a.type === "paren" && a.value === "(") {
|
|
361
|
+
const l = n.length - 1, r = l > 0 ? n[l - 1] : null;
|
|
283
362
|
if (r && r.type === "visualization")
|
|
284
363
|
return { type: "in_viz_params" };
|
|
285
364
|
}
|
|
286
|
-
if (
|
|
287
|
-
const l =
|
|
365
|
+
if (a.type === "comma" || a.type === "field" && c) {
|
|
366
|
+
const l = n.indexOf(a);
|
|
288
367
|
for (let r = l - 1; r >= 0; r--) {
|
|
289
|
-
if (
|
|
290
|
-
if (r > 0 &&
|
|
368
|
+
if (n[r].type === "paren" && n[r].value === "(") {
|
|
369
|
+
if (r > 0 && n[r - 1].type === "visualization")
|
|
291
370
|
return { type: "in_viz_params", partialText: d };
|
|
292
371
|
break;
|
|
293
372
|
}
|
|
294
|
-
if (
|
|
373
|
+
if (n[r].type === "paren" && n[r].value === ")") break;
|
|
295
374
|
}
|
|
296
375
|
}
|
|
297
|
-
if (
|
|
376
|
+
if (a.type === "paren" && a.value === "(")
|
|
298
377
|
return { type: "after_paren" };
|
|
299
|
-
if (
|
|
378
|
+
if (a.type === "arrow")
|
|
300
379
|
return { type: "after_arrow", partialText: d };
|
|
301
|
-
if (
|
|
380
|
+
if (s?.type === "doubleColon" && c)
|
|
302
381
|
return { type: "after_double_colon", partialText: d };
|
|
303
|
-
if (
|
|
382
|
+
if (a.type === "doubleColon")
|
|
383
|
+
return { type: "after_double_colon" };
|
|
384
|
+
if (a.type === "visualization" && c)
|
|
304
385
|
return { type: "after_arrow", partialText: d };
|
|
305
|
-
if (
|
|
386
|
+
if (a.type === "typeHint" && c)
|
|
306
387
|
return { type: "after_double_colon", partialText: d };
|
|
307
|
-
if (
|
|
388
|
+
if (a.type === "keyword" && a.value.toLowerCase() === "stats")
|
|
308
389
|
return { type: "after_stats", partialText: d };
|
|
309
|
-
if (
|
|
390
|
+
if (a.type === "keyword" && a.value.toLowerCase() === "by")
|
|
310
391
|
return { type: "after_by", partialText: d };
|
|
311
|
-
if (
|
|
312
|
-
const l =
|
|
392
|
+
if (a.type === "paren" && a.value === ")") {
|
|
393
|
+
const l = n.indexOf(a);
|
|
313
394
|
for (let r = l - 1; r >= 0; r--) {
|
|
314
|
-
if (
|
|
395
|
+
if (n[r].type === "keyword" && n[r].value.toLowerCase() === "stats")
|
|
315
396
|
return { type: "after_stats_agg" };
|
|
316
|
-
if (
|
|
397
|
+
if (n[r].type === "keyword" && n[r].value.toLowerCase() === "by" || n[r].type === "pipe") break;
|
|
317
398
|
}
|
|
318
399
|
}
|
|
319
|
-
if (
|
|
320
|
-
const l =
|
|
400
|
+
if (a.type === "field" && !c) {
|
|
401
|
+
const l = n.indexOf(a);
|
|
321
402
|
for (let r = l - 1; r >= 0; r--) {
|
|
322
|
-
if (
|
|
323
|
-
for (let
|
|
324
|
-
if (
|
|
403
|
+
if (n[r].type === "keyword" && n[r].value.toLowerCase() === "by") {
|
|
404
|
+
for (let m = r - 1; m >= 0; m--) {
|
|
405
|
+
if (n[m].type === "keyword" && n[m].value.toLowerCase() === "stats")
|
|
325
406
|
return { type: "after_group_by_field" };
|
|
326
|
-
if (
|
|
407
|
+
if (n[m].type === "pipe") break;
|
|
327
408
|
}
|
|
328
409
|
break;
|
|
329
410
|
}
|
|
330
|
-
if (
|
|
411
|
+
if (n[r].type === "pipe") break;
|
|
331
412
|
}
|
|
332
413
|
}
|
|
333
|
-
if (
|
|
414
|
+
if (a.type === "pipe")
|
|
334
415
|
return { type: "after_pipe", partialText: d };
|
|
335
|
-
if (
|
|
336
|
-
if (
|
|
416
|
+
if (a.type === "mutator") {
|
|
417
|
+
if (c)
|
|
337
418
|
return { type: "after_pipe", partialText: d };
|
|
338
|
-
const l =
|
|
419
|
+
const l = a.value.toLowerCase(), r = g[l];
|
|
339
420
|
return {
|
|
340
421
|
type: "after_mutator",
|
|
341
422
|
mutatorName: l,
|
|
342
423
|
mutatorOutputType: r
|
|
343
424
|
};
|
|
344
425
|
}
|
|
345
|
-
if (
|
|
346
|
-
return
|
|
347
|
-
if (
|
|
348
|
-
if (
|
|
426
|
+
if (a.type === "aggregation")
|
|
427
|
+
return c ? { type: "after_stats", partialText: d } : { type: "after_value" };
|
|
428
|
+
if (a.type === "field") {
|
|
429
|
+
if (c)
|
|
349
430
|
return s?.type === "pipe" ? { type: "after_pipe", partialText: d } : { type: "start", partialText: d };
|
|
350
431
|
if (s?.type === "pipe")
|
|
351
|
-
return { type: "after_pipe", partialText:
|
|
352
|
-
const l =
|
|
353
|
-
return { type: "after_field", fieldName:
|
|
432
|
+
return { type: "after_pipe", partialText: a.value };
|
|
433
|
+
const l = h(a.value, i);
|
|
434
|
+
return { type: "after_field", fieldName: a.value, fieldType: l };
|
|
354
435
|
}
|
|
355
|
-
if (
|
|
356
|
-
if (
|
|
436
|
+
if (a.type === "operator") {
|
|
437
|
+
if (c) {
|
|
357
438
|
if (s?.type === "field") {
|
|
358
|
-
const l =
|
|
439
|
+
const l = h(s.value, i);
|
|
359
440
|
return { type: "after_field", fieldName: s.value, fieldType: l, partialText: d };
|
|
360
441
|
}
|
|
361
442
|
if (s?.type === "mutator") {
|
|
362
|
-
const l = s.value.toLowerCase(), r =
|
|
443
|
+
const l = s.value.toLowerCase(), r = g[l];
|
|
363
444
|
return { type: "after_mutator", mutatorName: l, mutatorOutputType: r, partialText: d };
|
|
364
445
|
}
|
|
365
446
|
}
|
|
366
|
-
return { type: "after_operator", operatorName:
|
|
447
|
+
return { type: "after_operator", operatorName: a.value };
|
|
367
448
|
}
|
|
368
|
-
if (
|
|
369
|
-
return
|
|
370
|
-
if (
|
|
449
|
+
if (a.type === "string" || a.type === "number" || a.type === "boolean" || a.type === "null")
|
|
450
|
+
return c ? { type: "at_value_end" } : { type: "after_value" };
|
|
451
|
+
if (a.type === "paren" && a.value === ")")
|
|
371
452
|
return { type: "after_value" };
|
|
372
|
-
if (s?.type === "field" &&
|
|
373
|
-
const l =
|
|
453
|
+
if (s?.type === "field" && c) {
|
|
454
|
+
const l = h(s.value, i);
|
|
374
455
|
return { type: "after_field", fieldName: s.value, fieldType: l, partialText: d };
|
|
375
456
|
}
|
|
376
|
-
if (s?.type === "mutator" &&
|
|
377
|
-
const l = s.value.toLowerCase(), r =
|
|
457
|
+
if (s?.type === "mutator" && c) {
|
|
458
|
+
const l = s.value.toLowerCase(), r = g[l];
|
|
378
459
|
return { type: "after_mutator", mutatorName: l, mutatorOutputType: r, partialText: d };
|
|
379
460
|
}
|
|
380
461
|
return { type: "unknown", partialText: d };
|
|
381
462
|
}
|
|
382
|
-
function
|
|
383
|
-
return t ?
|
|
463
|
+
function h(e, t) {
|
|
464
|
+
return t ? S().getFieldType(t, e) : void 0;
|
|
384
465
|
}
|
|
385
|
-
function
|
|
386
|
-
const { query: i, cursorPosition: o } = e,
|
|
387
|
-
switch (
|
|
466
|
+
function ie(e, t = {}) {
|
|
467
|
+
const { query: i, cursorPosition: o } = e, n = V(i, o, t.fields), a = [];
|
|
468
|
+
switch (n.type) {
|
|
388
469
|
case "start":
|
|
389
470
|
case "after_paren":
|
|
390
|
-
|
|
471
|
+
a.push(...x(t.fields, n.partialText)), a.push(I("NOT")), t.includeSnippets !== !1 && a.push(...K(t, n.partialText));
|
|
391
472
|
break;
|
|
392
473
|
case "after_field":
|
|
393
|
-
|
|
474
|
+
a.push(...b(n.partialText, n.fieldType));
|
|
394
475
|
break;
|
|
395
476
|
case "after_mutator":
|
|
396
|
-
|
|
477
|
+
a.push(...b(n.partialText, n.mutatorOutputType));
|
|
397
478
|
break;
|
|
398
479
|
case "after_operator":
|
|
399
|
-
|
|
480
|
+
a.push(...j(n.fieldName, t));
|
|
400
481
|
break;
|
|
401
482
|
case "after_value":
|
|
402
|
-
|
|
483
|
+
a.push(...C());
|
|
403
484
|
break;
|
|
404
485
|
case "at_value_end":
|
|
405
486
|
break;
|
|
406
487
|
case "after_pipe":
|
|
407
|
-
|
|
488
|
+
a.push(...W(n.partialText)), (!n.partialText || "stats".includes(n.partialText.toLowerCase())) && a.push({
|
|
408
489
|
label: "stats",
|
|
409
490
|
insertText: "stats ",
|
|
410
491
|
kind: "keyword",
|
|
@@ -414,13 +495,13 @@ function Q(e, t = {}) {
|
|
|
414
495
|
});
|
|
415
496
|
break;
|
|
416
497
|
case "after_stats_agg":
|
|
417
|
-
|
|
498
|
+
a.push({
|
|
418
499
|
label: "by",
|
|
419
500
|
insertText: "by ",
|
|
420
501
|
kind: "keyword",
|
|
421
502
|
detail: "Group results by field",
|
|
422
503
|
sortOrder: 1
|
|
423
|
-
}),
|
|
504
|
+
}), a.push({
|
|
424
505
|
label: "=>",
|
|
425
506
|
insertText: "=> ",
|
|
426
507
|
kind: "visualization",
|
|
@@ -429,13 +510,13 @@ function Q(e, t = {}) {
|
|
|
429
510
|
});
|
|
430
511
|
break;
|
|
431
512
|
case "after_group_by_field":
|
|
432
|
-
|
|
513
|
+
a.push({
|
|
433
514
|
label: "=>",
|
|
434
515
|
insertText: "=> ",
|
|
435
516
|
kind: "visualization",
|
|
436
517
|
detail: "Set visualization type (bar, pie, line, ...)",
|
|
437
518
|
sortOrder: 1
|
|
438
|
-
}),
|
|
519
|
+
}), a.push({
|
|
439
520
|
label: ",",
|
|
440
521
|
insertText: ", ",
|
|
441
522
|
kind: "keyword",
|
|
@@ -444,61 +525,61 @@ function Q(e, t = {}) {
|
|
|
444
525
|
});
|
|
445
526
|
break;
|
|
446
527
|
case "after_double_colon":
|
|
447
|
-
|
|
528
|
+
a.push(...Z(n.partialText));
|
|
448
529
|
break;
|
|
449
530
|
case "after_arrow":
|
|
450
|
-
|
|
531
|
+
a.push(...X(n.partialText));
|
|
451
532
|
break;
|
|
452
533
|
case "in_viz_params":
|
|
453
|
-
|
|
534
|
+
a.push(...Q(n.partialText));
|
|
454
535
|
break;
|
|
455
536
|
case "after_stats":
|
|
456
|
-
|
|
537
|
+
a.push(...O(n.partialText));
|
|
457
538
|
break;
|
|
458
539
|
case "after_by":
|
|
459
|
-
|
|
540
|
+
a.push(...x(t.fields, n.partialText));
|
|
460
541
|
break;
|
|
461
542
|
default:
|
|
462
|
-
|
|
543
|
+
a.push(...x(t.fields, n.partialText)), a.push(...b(n.partialText)), a.push(...C());
|
|
463
544
|
}
|
|
464
|
-
t.includeAggregations &&
|
|
465
|
-
let s =
|
|
466
|
-
const
|
|
467
|
-
if (
|
|
468
|
-
const l =
|
|
469
|
-
if (
|
|
545
|
+
t.includeAggregations && n.type === "start" && a.push(...O(n.partialText));
|
|
546
|
+
let s = a;
|
|
547
|
+
const c = t.fuzzyMatching !== !1, d = t.minFuzzyScore ?? 0;
|
|
548
|
+
if (n.partialText) {
|
|
549
|
+
const l = n.partialText.toLowerCase();
|
|
550
|
+
if (c) {
|
|
470
551
|
const r = [];
|
|
471
|
-
for (const
|
|
472
|
-
const
|
|
473
|
-
|
|
474
|
-
...
|
|
475
|
-
matchScore:
|
|
476
|
-
matchedIndices:
|
|
552
|
+
for (const m of a) {
|
|
553
|
+
const p = _(l, m.label), v = m.filterText ? _(l, m.filterText) : { matched: !1, score: 0 }, y = p.score >= v.score ? p : v;
|
|
554
|
+
y.matched && y.score >= d && r.push({
|
|
555
|
+
...m,
|
|
556
|
+
matchScore: y.score,
|
|
557
|
+
matchedIndices: p.matched ? p.matchedIndices : void 0
|
|
477
558
|
});
|
|
478
559
|
}
|
|
479
560
|
s = r;
|
|
480
561
|
} else
|
|
481
|
-
s =
|
|
562
|
+
s = a.filter(
|
|
482
563
|
(r) => r.label.toLowerCase().includes(l) || r.filterText?.toLowerCase().includes(l)
|
|
483
564
|
);
|
|
484
565
|
}
|
|
485
566
|
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;
|
|
486
567
|
}
|
|
487
|
-
function
|
|
568
|
+
function x(e, t) {
|
|
488
569
|
if (!e || e.length === 0)
|
|
489
|
-
return
|
|
570
|
+
return q(t);
|
|
490
571
|
const i = [];
|
|
491
572
|
for (const o of e) {
|
|
492
|
-
const
|
|
493
|
-
if (i.push(
|
|
494
|
-
for (const
|
|
495
|
-
const s =
|
|
573
|
+
const n = N(o);
|
|
574
|
+
if (i.push(n), o.nested)
|
|
575
|
+
for (const a of o.nested) {
|
|
576
|
+
const s = N(a, o.name);
|
|
496
577
|
i.push(s);
|
|
497
578
|
}
|
|
498
579
|
}
|
|
499
580
|
return i;
|
|
500
581
|
}
|
|
501
|
-
function
|
|
582
|
+
function q(e) {
|
|
502
583
|
return [
|
|
503
584
|
{ name: "hostname", description: "Host/machine name" },
|
|
504
585
|
{ name: "status", description: "Status value" },
|
|
@@ -524,7 +605,7 @@ function G(e) {
|
|
|
524
605
|
sortOrder: 10
|
|
525
606
|
}));
|
|
526
607
|
}
|
|
527
|
-
function
|
|
608
|
+
function N(e, t) {
|
|
528
609
|
const i = t ? `${t}.${e.name}` : e.name;
|
|
529
610
|
return {
|
|
530
611
|
label: i,
|
|
@@ -536,24 +617,24 @@ function v(e, t) {
|
|
|
536
617
|
sortOrder: 10
|
|
537
618
|
};
|
|
538
619
|
}
|
|
539
|
-
function
|
|
540
|
-
let i = [...
|
|
620
|
+
function b(e, t) {
|
|
621
|
+
let i = [...E];
|
|
541
622
|
return t && (i = i.filter((o) => {
|
|
542
|
-
const
|
|
543
|
-
return !
|
|
544
|
-
})), e && (i = i.filter((o) => o.toLowerCase().includes(e.toLowerCase()))), i.map((o,
|
|
545
|
-
const
|
|
623
|
+
const n = G[o];
|
|
624
|
+
return !n || n.includes(t);
|
|
625
|
+
})), e && (i = i.filter((o) => o.toLowerCase().includes(e.toLowerCase()))), i.map((o, n) => {
|
|
626
|
+
const a = U[o] || { detail: o, documentation: "" }, s = H(o, t);
|
|
546
627
|
return {
|
|
547
628
|
label: o,
|
|
548
629
|
insertText: s,
|
|
549
630
|
kind: "operator",
|
|
550
|
-
detail:
|
|
551
|
-
documentation:
|
|
552
|
-
sortOrder: 20 +
|
|
631
|
+
detail: a.detail,
|
|
632
|
+
documentation: a.documentation,
|
|
633
|
+
sortOrder: 20 + n
|
|
553
634
|
};
|
|
554
635
|
});
|
|
555
636
|
}
|
|
556
|
-
function
|
|
637
|
+
function H(e, t) {
|
|
557
638
|
const i = [
|
|
558
639
|
"contains",
|
|
559
640
|
"not_contains",
|
|
@@ -567,12 +648,12 @@ function q(e, t) {
|
|
|
567
648
|
"not_regex",
|
|
568
649
|
"matches",
|
|
569
650
|
"not_matches"
|
|
570
|
-
], o = ["exists", "not_exists"],
|
|
651
|
+
], o = ["exists", "not_exists"], n = ["is", "is_not"];
|
|
571
652
|
if (e === "in" || e === "not_in")
|
|
572
|
-
return
|
|
653
|
+
return A(t) ? `${e} [$1]` : `${e} ["$1"]`;
|
|
573
654
|
if (e === "between" || e === "not_between")
|
|
574
|
-
return
|
|
575
|
-
if (
|
|
655
|
+
return A(t) ? `${e} $1 AND $2` : `${e} "$1" AND "$2"`;
|
|
656
|
+
if (n.includes(e))
|
|
576
657
|
return `${e} null`;
|
|
577
658
|
if (o.includes(e))
|
|
578
659
|
return e;
|
|
@@ -605,15 +686,15 @@ function q(e, t) {
|
|
|
605
686
|
return `${e} `;
|
|
606
687
|
}
|
|
607
688
|
}
|
|
608
|
-
function
|
|
689
|
+
function A(e) {
|
|
609
690
|
return e === "long" || e === "integer" || e === "double" || e === "float" || e === "short" || e === "byte" || e === "half_float" || e === "scaled_float" || e === "unsigned_long";
|
|
610
691
|
}
|
|
611
|
-
function
|
|
612
|
-
return
|
|
613
|
-
(e, t) =>
|
|
692
|
+
function C() {
|
|
693
|
+
return R.filter((e) => e !== "NOT").map(
|
|
694
|
+
(e, t) => I(e, t)
|
|
614
695
|
);
|
|
615
696
|
}
|
|
616
|
-
function
|
|
697
|
+
function I(e, t = 0) {
|
|
617
698
|
return {
|
|
618
699
|
label: e,
|
|
619
700
|
insertText: e + " ",
|
|
@@ -624,13 +705,13 @@ function O(e, t = 0) {
|
|
|
624
705
|
}
|
|
625
706
|
function j(e, t) {
|
|
626
707
|
const i = [];
|
|
627
|
-
return e && t?.fieldValues?.[e] && t.fieldValues[e].forEach((
|
|
708
|
+
return e && t?.fieldValues?.[e] && t.fieldValues[e].forEach((n, a) => {
|
|
628
709
|
i.push({
|
|
629
|
-
label:
|
|
630
|
-
insertText: `"${
|
|
710
|
+
label: n,
|
|
711
|
+
insertText: `"${n}"`,
|
|
631
712
|
kind: "value",
|
|
632
713
|
detail: `Known value for ${e}`,
|
|
633
|
-
sortOrder: 40 +
|
|
714
|
+
sortOrder: 40 + a
|
|
634
715
|
});
|
|
635
716
|
}), i.push(
|
|
636
717
|
{
|
|
@@ -663,20 +744,20 @@ function j(e, t) {
|
|
|
663
744
|
}
|
|
664
745
|
), i;
|
|
665
746
|
}
|
|
666
|
-
function
|
|
667
|
-
return
|
|
747
|
+
function K(e, t) {
|
|
748
|
+
return z.filter((o) => !t || o.label.toLowerCase().includes(t.toLowerCase())).map((o, n) => ({
|
|
668
749
|
label: o.label,
|
|
669
750
|
insertText: o.insertText,
|
|
670
751
|
kind: "snippet",
|
|
671
752
|
detail: o.description,
|
|
672
753
|
documentation: `Insert: ${o.insertText}`,
|
|
673
|
-
sortOrder: 100 +
|
|
754
|
+
sortOrder: 100 + n
|
|
674
755
|
}));
|
|
675
756
|
}
|
|
676
|
-
function
|
|
677
|
-
return
|
|
757
|
+
function W(e) {
|
|
758
|
+
return M.filter((t) => !e || t.toLowerCase().includes(e.toLowerCase())).map(
|
|
678
759
|
(t, i) => {
|
|
679
|
-
const o =
|
|
760
|
+
const o = F[t] || { detail: "Field mutator", documentation: "" };
|
|
680
761
|
return {
|
|
681
762
|
label: t,
|
|
682
763
|
insertText: t,
|
|
@@ -688,8 +769,8 @@ function V(e) {
|
|
|
688
769
|
}
|
|
689
770
|
);
|
|
690
771
|
}
|
|
691
|
-
function
|
|
692
|
-
return
|
|
772
|
+
function O(e) {
|
|
773
|
+
return P.filter(
|
|
693
774
|
(t) => !e || t.toLowerCase().includes(e.toLowerCase())
|
|
694
775
|
).map((t, i) => ({
|
|
695
776
|
label: t,
|
|
@@ -699,8 +780,8 @@ function C(e) {
|
|
|
699
780
|
sortOrder: 70 + i
|
|
700
781
|
}));
|
|
701
782
|
}
|
|
702
|
-
function
|
|
703
|
-
return
|
|
783
|
+
function Z(e) {
|
|
784
|
+
return D.filter(
|
|
704
785
|
(t) => !e || t.toLowerCase().includes(e.toLowerCase())
|
|
705
786
|
).map((t, i) => ({
|
|
706
787
|
label: t,
|
|
@@ -710,8 +791,8 @@ function H(e) {
|
|
|
710
791
|
sortOrder: 80 + i
|
|
711
792
|
}));
|
|
712
793
|
}
|
|
713
|
-
function
|
|
714
|
-
return
|
|
794
|
+
function X(e) {
|
|
795
|
+
return $.filter(
|
|
715
796
|
(t) => !e || t.toLowerCase().includes(e.toLowerCase())
|
|
716
797
|
).map((t, i) => ({
|
|
717
798
|
label: t,
|
|
@@ -721,7 +802,7 @@ function Y(e) {
|
|
|
721
802
|
sortOrder: 90 + i
|
|
722
803
|
}));
|
|
723
804
|
}
|
|
724
|
-
const
|
|
805
|
+
const J = [
|
|
725
806
|
// Titles & labels
|
|
726
807
|
{ name: "title", detail: "Chart title", insertText: 'title="' },
|
|
727
808
|
{ name: "x_label", detail: "X-axis label", insertText: 'x_label="' },
|
|
@@ -757,8 +838,8 @@ const K = [
|
|
|
757
838
|
{ name: "link", detail: 'Template URL for value links: "https://...{{value}}"', insertText: 'link="' },
|
|
758
839
|
{ name: "link_target", detail: "Link target: _self (default) or _blank", insertText: "link_target=" }
|
|
759
840
|
];
|
|
760
|
-
function
|
|
761
|
-
return
|
|
841
|
+
function Q(e) {
|
|
842
|
+
return J.filter(
|
|
762
843
|
(t) => !e || t.name.toLowerCase().includes(e.toLowerCase())
|
|
763
844
|
).map((t, i) => ({
|
|
764
845
|
label: t.name,
|
|
@@ -768,9 +849,9 @@ function W(e) {
|
|
|
768
849
|
sortOrder: 95 + i
|
|
769
850
|
}));
|
|
770
851
|
}
|
|
771
|
-
function
|
|
772
|
-
const o =
|
|
773
|
-
(
|
|
852
|
+
function re(e, t) {
|
|
853
|
+
const o = T(e).find(
|
|
854
|
+
(n) => n.start <= t && n.end >= t && n.type !== "whitespace"
|
|
774
855
|
);
|
|
775
856
|
return o ? {
|
|
776
857
|
word: o.value,
|
|
@@ -778,18 +859,18 @@ function ee(e, t) {
|
|
|
778
859
|
end: o.end
|
|
779
860
|
} : null;
|
|
780
861
|
}
|
|
781
|
-
function
|
|
862
|
+
function oe() {
|
|
782
863
|
return [" ", "(", ".", '"', "'", "|", ":", "="];
|
|
783
864
|
}
|
|
784
|
-
function
|
|
865
|
+
function le(e, t, i) {
|
|
785
866
|
if (!e) return !1;
|
|
786
867
|
if (i === " " || i === "(" || i === "." || i === "|" || i === ":" || i === "=") return !0;
|
|
787
|
-
const o =
|
|
788
|
-
return !!(
|
|
868
|
+
const o = T(e.substring(0, t)), n = o[o.length - 1];
|
|
869
|
+
return !!(n && n.type === "field" && n.value.length >= 2);
|
|
789
870
|
}
|
|
790
871
|
export {
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
872
|
+
oe as getCompletionTriggerCharacters,
|
|
873
|
+
ie as getCompletions,
|
|
874
|
+
re as getWordAtPosition,
|
|
875
|
+
le as shouldTriggerCompletion
|
|
795
876
|
};
|