@tellaro/tql 0.1.18 → 0.2.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.d.ts +1 -0
- package/dist/src/completionProvider.d.ts +0 -1
- package/dist/src/completionProvider.js +195 -534
- package/dist/src/complexityAnalyzer.d.ts +0 -1
- package/dist/src/complexityAnalyzer.js +33 -36
- package/dist/src/parser.d.ts +0 -1
- package/dist/src/parser.js +78 -115
- package/dist/src/schemaCache.d.ts +0 -1
- package/dist/src/schemaCache.js +34 -42
- package/dist/src/semanticPreview.d.ts +0 -1
- package/dist/src/semanticPreview.js +36 -38
- package/dist/src/tokenizer.d.ts +0 -15
- package/dist/src/tokenizer.js +47 -156
- package/dist/src/types.d.ts +14 -0
- package/dist/src/validator.d.ts +0 -1
- package/dist/src/validator.js +31 -148
- package/dist/tql.css +1 -0
- package/dist/vue/TqlAutocomplete.vue2.js +56 -59
- package/dist/vue/TqlInput.vue.js +1 -1
- package/dist/vue/TqlInput.vue2.js +333 -359
- package/dist/vue/components/TqlPreview.vue2.js +58 -62
- package/dist/vue/composables/useQueryHistory.d.ts +0 -1
- package/dist/vue/composables/useQueryHistory.js +1 -4
- package/dist/vue/useTqlInput.js +107 -117
- package/package.json +11 -5
- package/dist/style.css +0 -1
|
@@ -1,29 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var h = (i, e, t) => p(i, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
-
import { parseTql as g } from "./parser.js";
|
|
5
|
-
const c = {
|
|
1
|
+
import { parseTql as u } from "./parser.js";
|
|
2
|
+
const d = {
|
|
6
3
|
maxDepth: 5,
|
|
7
4
|
maxRegex: 3,
|
|
8
5
|
maxInListSize: 100,
|
|
9
6
|
maxOrChainLength: 10,
|
|
10
7
|
maxLeadingWildcards: 2
|
|
11
|
-
},
|
|
8
|
+
}, h = /* @__PURE__ */ new Set([
|
|
12
9
|
"geoip_lookup",
|
|
13
10
|
"geoip",
|
|
14
11
|
"geo",
|
|
15
12
|
"nslookup"
|
|
16
|
-
]),
|
|
17
|
-
class
|
|
13
|
+
]), p = /\*/g, g = /^\*/;
|
|
14
|
+
class c {
|
|
15
|
+
thresholds;
|
|
18
16
|
constructor(e) {
|
|
19
|
-
|
|
20
|
-
this.thresholds = { ...c, ...e };
|
|
17
|
+
this.thresholds = { ...d, ...e };
|
|
21
18
|
}
|
|
22
19
|
/**
|
|
23
20
|
* Analyze a TQL query for complexity
|
|
24
21
|
*/
|
|
25
22
|
analyze(e) {
|
|
26
|
-
const t =
|
|
23
|
+
const t = u(e), a = {
|
|
27
24
|
depth: 0,
|
|
28
25
|
operatorCount: 0,
|
|
29
26
|
wildcardCount: 0,
|
|
@@ -72,8 +69,8 @@ class x {
|
|
|
72
69
|
}
|
|
73
70
|
analyzeUnaryExpression(e, t, a, n, s) {
|
|
74
71
|
t.operatorCount++;
|
|
75
|
-
const
|
|
76
|
-
this.analyzeExpression(e.operand, t, a, n + 1,
|
|
72
|
+
const i = e.operator === "NOT" ? s + 1 : s;
|
|
73
|
+
this.analyzeExpression(e.operand, t, a, n + 1, i);
|
|
77
74
|
}
|
|
78
75
|
analyzeGroupExpression(e, t, a, n, s) {
|
|
79
76
|
this.analyzeExpression(e.expression, t, a, n + 1, s);
|
|
@@ -82,7 +79,7 @@ class x {
|
|
|
82
79
|
t.operatorCount++;
|
|
83
80
|
const n = e.field;
|
|
84
81
|
if (n.type === "mutator")
|
|
85
|
-
t.mutatorCount++,
|
|
82
|
+
t.mutatorCount++, h.has(n.mutator) && (t.postProcessingMutatorCount++, a.push({
|
|
86
83
|
type: "post_processing_mutator",
|
|
87
84
|
message: `Mutator '${n.mutator}' requires post-processing and may be slow`,
|
|
88
85
|
severity: "warning",
|
|
@@ -90,28 +87,28 @@ class x {
|
|
|
90
87
|
}));
|
|
91
88
|
else if (n.type === "field" && n.mutators) {
|
|
92
89
|
t.mutatorCount += n.mutators.length;
|
|
93
|
-
for (const
|
|
94
|
-
|
|
90
|
+
for (const i of n.mutators)
|
|
91
|
+
h.has(i) && (t.postProcessingMutatorCount++, a.push({
|
|
95
92
|
type: "post_processing_mutator",
|
|
96
|
-
message: `Mutator '${
|
|
93
|
+
message: `Mutator '${i}' requires post-processing and may be slow`,
|
|
97
94
|
severity: "warning",
|
|
98
95
|
location: { start: n.start, end: n.end }
|
|
99
96
|
}));
|
|
100
97
|
}
|
|
101
98
|
const s = e.operator.toLowerCase();
|
|
102
99
|
if ((s === "regexp" || s === "regex" || s === "matches" || s === "not_regexp" || s === "not_matches") && t.regexCount++, this.analyzeValue(e.value, t, a, e), (s === "in" || s === "not_in") && Array.isArray(e.value)) {
|
|
103
|
-
const
|
|
104
|
-
t.inListMaxSize = Math.max(t.inListMaxSize,
|
|
100
|
+
const i = e.value.length;
|
|
101
|
+
t.inListMaxSize = Math.max(t.inListMaxSize, i);
|
|
105
102
|
}
|
|
106
103
|
}
|
|
107
104
|
analyzeValue(e, t, a, n) {
|
|
108
105
|
const s = Array.isArray(e) ? e : [e];
|
|
109
|
-
for (const
|
|
110
|
-
if (
|
|
111
|
-
const l =
|
|
112
|
-
l && (t.wildcardCount += l.length,
|
|
106
|
+
for (const i of s)
|
|
107
|
+
if (i.valueType === "string" && typeof i.value == "string") {
|
|
108
|
+
const l = i.value.match(p);
|
|
109
|
+
l && (t.wildcardCount += l.length, g.test(i.value) && (t.leadingWildcardCount++, t.leadingWildcardCount <= this.thresholds.maxLeadingWildcards && a.push({
|
|
113
110
|
type: "leading_wildcard",
|
|
114
|
-
message: `Leading wildcard in '${
|
|
111
|
+
message: `Leading wildcard in '${i.value}' is expensive - consider using 'endswith' if possible`,
|
|
115
112
|
severity: "warning",
|
|
116
113
|
location: { start: n.start, end: n.end }
|
|
117
114
|
})));
|
|
@@ -188,22 +185,22 @@ class x {
|
|
|
188
185
|
return a += n * 2, a >= 4 ? "high" : a >= 2 ? "medium" : "low";
|
|
189
186
|
}
|
|
190
187
|
}
|
|
191
|
-
function r(
|
|
192
|
-
return new
|
|
188
|
+
function r(o, e) {
|
|
189
|
+
return new c(e).analyze(o);
|
|
193
190
|
}
|
|
194
|
-
function
|
|
195
|
-
return r(
|
|
191
|
+
function f(o, e) {
|
|
192
|
+
return r(o, e).score === "high";
|
|
196
193
|
}
|
|
197
|
-
function
|
|
198
|
-
return r(
|
|
194
|
+
function x(o, e) {
|
|
195
|
+
return r(o, e).warnings;
|
|
199
196
|
}
|
|
200
|
-
function
|
|
201
|
-
return r(
|
|
197
|
+
function C(o) {
|
|
198
|
+
return r(o).metrics;
|
|
202
199
|
}
|
|
203
200
|
export {
|
|
204
|
-
|
|
201
|
+
c as ComplexityAnalyzer,
|
|
205
202
|
r as analyzeComplexity,
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
203
|
+
C as getComplexityMetrics,
|
|
204
|
+
x as getComplexityWarnings,
|
|
205
|
+
f as isHighComplexity
|
|
209
206
|
};
|
package/dist/src/parser.d.ts
CHANGED
package/dist/src/parser.js
CHANGED
|
@@ -1,19 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { tokenizeTql as u, COMPARISON_OPERATORS as c } from "./tokenizer.js";
|
|
2
|
+
const d = 50, p = /* @__PURE__ */ new Set(["logicalOp", "paren"]);
|
|
3
|
+
class v {
|
|
4
|
+
tokens;
|
|
5
|
+
allTokens;
|
|
6
|
+
// Including whitespace for highlighting
|
|
7
|
+
current;
|
|
8
|
+
errors;
|
|
9
|
+
warnings;
|
|
10
|
+
depth;
|
|
8
11
|
constructor(e) {
|
|
9
|
-
|
|
10
|
-
o(this, "allTokens");
|
|
11
|
-
// Including whitespace for highlighting
|
|
12
|
-
o(this, "current");
|
|
13
|
-
o(this, "errors");
|
|
14
|
-
o(this, "warnings");
|
|
15
|
-
o(this, "depth");
|
|
16
|
-
this.allTokens = p(e), this.tokens = this.allTokens.filter((t) => t.type !== "whitespace"), this.current = 0, this.errors = [], this.warnings = [], this.depth = 0;
|
|
12
|
+
this.allTokens = u(e), this.tokens = this.allTokens.filter((t) => t.type !== "whitespace"), this.current = 0, this.errors = [], this.warnings = [], this.depth = 0;
|
|
17
13
|
}
|
|
18
14
|
/**
|
|
19
15
|
* Parse the input and return the result
|
|
@@ -62,7 +58,7 @@ class y {
|
|
|
62
58
|
* Parse a full expression (lowest precedence)
|
|
63
59
|
*/
|
|
64
60
|
parseExpression() {
|
|
65
|
-
if (this.depth++, this.depth >
|
|
61
|
+
if (this.depth++, this.depth > d)
|
|
66
62
|
throw new Error("Maximum query depth exceeded");
|
|
67
63
|
try {
|
|
68
64
|
return this.parseOr();
|
|
@@ -84,14 +80,14 @@ class y {
|
|
|
84
80
|
"MISSING_OPERAND",
|
|
85
81
|
"Add a condition after 'OR'"
|
|
86
82
|
), e;
|
|
87
|
-
const
|
|
83
|
+
const r = this.parseAnd();
|
|
88
84
|
e = {
|
|
89
85
|
type: "binary",
|
|
90
86
|
operator: "OR",
|
|
91
87
|
left: e,
|
|
92
|
-
right:
|
|
88
|
+
right: r,
|
|
93
89
|
start: e.start,
|
|
94
|
-
end:
|
|
90
|
+
end: r.end
|
|
95
91
|
};
|
|
96
92
|
}
|
|
97
93
|
return e;
|
|
@@ -110,14 +106,14 @@ class y {
|
|
|
110
106
|
"MISSING_OPERAND",
|
|
111
107
|
"Add a condition after 'AND'"
|
|
112
108
|
), e;
|
|
113
|
-
const
|
|
109
|
+
const r = this.parseUnary();
|
|
114
110
|
e = {
|
|
115
111
|
type: "binary",
|
|
116
112
|
operator: "AND",
|
|
117
113
|
left: e,
|
|
118
|
-
right:
|
|
114
|
+
right: r,
|
|
119
115
|
start: e.start,
|
|
120
|
-
end:
|
|
116
|
+
end: r.end
|
|
121
117
|
};
|
|
122
118
|
}
|
|
123
119
|
return e;
|
|
@@ -198,16 +194,14 @@ class y {
|
|
|
198
194
|
"Valid types: string, int, float, date, bool, array"
|
|
199
195
|
);
|
|
200
196
|
}
|
|
201
|
-
const
|
|
197
|
+
const r = [];
|
|
202
198
|
for (; this.check("pipe"); )
|
|
203
199
|
if (this.advance(), this.check("mutator")) {
|
|
204
200
|
const s = this.advance();
|
|
205
|
-
|
|
201
|
+
r.push(s.value.toLowerCase());
|
|
206
202
|
} else if (this.check("field")) {
|
|
207
203
|
const s = this.advance();
|
|
208
|
-
|
|
209
|
-
const suggestion = suggestMut(s.value);
|
|
210
|
-
this.addWarning(`Unknown mutator '${s.value}'`, s, suggestion ? `Did you mean: ${suggestion}?` : "Valid mutators: lowercase, uppercase, trim, geo, nslookup, etc.");
|
|
204
|
+
r.push(s.value.toLowerCase()), this.addWarning(`Unknown mutator '${s.value}'`, s, "Check the mutator name spelling");
|
|
211
205
|
} else {
|
|
212
206
|
const s = this.isAtEnd() ? this.previous() : this.peek();
|
|
213
207
|
this.addError(
|
|
@@ -218,30 +212,14 @@ class y {
|
|
|
218
212
|
);
|
|
219
213
|
break;
|
|
220
214
|
}
|
|
221
|
-
if (
|
|
215
|
+
if (r.length > 0 && (t = {
|
|
222
216
|
...t,
|
|
223
|
-
mutators:
|
|
217
|
+
mutators: r,
|
|
224
218
|
end: this.previous().end
|
|
225
219
|
}), !this.check("operator")) {
|
|
226
|
-
|
|
227
|
-
// Enrichment mutators don't require an operator - they transform the field into enriched data
|
|
228
|
-
const lastMutator = n.length > 0 ? n[n.length - 1] : null;
|
|
229
|
-
const isEnrichmentMutator = lastMutator && ENRICHMENT_MUTATORS.includes(lastMutator);
|
|
230
|
-
|
|
231
|
-
if (isEnrichmentMutator) {
|
|
232
|
-
// Return a valid enrichment expression without error
|
|
233
|
-
return {
|
|
234
|
-
type: "enrichment",
|
|
235
|
-
field: t,
|
|
236
|
-
mutator: lastMutator,
|
|
237
|
-
start: t.start,
|
|
238
|
-
end: t.end
|
|
239
|
-
};
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
const s = this.isAtEnd() ? this.previous() : this.peek(), h = n.length > 0 ? `'${e.value}' with mutator` : `'${e.value}'`;
|
|
220
|
+
const s = this.isAtEnd() ? this.previous() : this.peek(), o = r.length > 0 ? `'${e.value}' with mutator` : `'${e.value}'`;
|
|
243
221
|
return this.addError(
|
|
244
|
-
`Expected operator after field ${
|
|
222
|
+
`Expected operator after field ${o}`,
|
|
245
223
|
s,
|
|
246
224
|
"MISSING_OPERATOR",
|
|
247
225
|
"Add an operator like 'eq', 'contains', '==', etc."
|
|
@@ -260,35 +238,28 @@ class y {
|
|
|
260
238
|
end: t.end
|
|
261
239
|
};
|
|
262
240
|
}
|
|
263
|
-
const
|
|
264
|
-
|
|
265
|
-
// Handle unknown operator with suggestions
|
|
266
|
-
if (typeof a === 'object' && a.unknown) {
|
|
267
|
-
const suggestionMsg = a.suggestion ? `Did you mean: ${a.suggestion}?` : "Valid operators: eq, ne, contains, startswith, gt, lt, etc.";
|
|
268
|
-
this.addWarning(`Unknown operator '${a.value}'`, i, suggestionMsg);
|
|
269
|
-
a = a.value; // Use the original value
|
|
270
|
-
}
|
|
271
|
-
if (a === "exists" || a === "not_exists")
|
|
241
|
+
const a = this.advance(), n = this.normalizeOperator(a.value);
|
|
242
|
+
if (n === "exists" || n === "not_exists")
|
|
272
243
|
return {
|
|
273
244
|
type: "comparison",
|
|
274
245
|
field: t,
|
|
275
|
-
operator:
|
|
246
|
+
operator: n,
|
|
276
247
|
value: {
|
|
277
248
|
type: "literal",
|
|
278
249
|
valueType: "boolean",
|
|
279
250
|
value: !0,
|
|
280
|
-
start:
|
|
281
|
-
end:
|
|
251
|
+
start: a.end,
|
|
252
|
+
end: a.end
|
|
282
253
|
},
|
|
283
254
|
start: t.start,
|
|
284
|
-
end:
|
|
255
|
+
end: a.end
|
|
285
256
|
};
|
|
286
|
-
if ((
|
|
257
|
+
if ((n === "is" || n === "is_not") && this.check("null")) {
|
|
287
258
|
const s = this.advance();
|
|
288
259
|
return {
|
|
289
260
|
type: "comparison",
|
|
290
261
|
field: t,
|
|
291
|
-
operator:
|
|
262
|
+
operator: n,
|
|
292
263
|
value: {
|
|
293
264
|
type: "literal",
|
|
294
265
|
valueType: "null",
|
|
@@ -300,18 +271,18 @@ class y {
|
|
|
300
271
|
end: s.end
|
|
301
272
|
};
|
|
302
273
|
}
|
|
303
|
-
if (
|
|
274
|
+
if (n === "in" || n === "not_in") {
|
|
304
275
|
const s = this.parseValueList();
|
|
305
276
|
return {
|
|
306
277
|
type: "comparison",
|
|
307
278
|
field: t,
|
|
308
|
-
operator:
|
|
279
|
+
operator: n,
|
|
309
280
|
value: s,
|
|
310
281
|
start: t.start,
|
|
311
282
|
end: this.previous().end
|
|
312
283
|
};
|
|
313
284
|
}
|
|
314
|
-
if (
|
|
285
|
+
if (n === "between" || n === "not_between") {
|
|
315
286
|
const s = this.parseValue();
|
|
316
287
|
this.matchLogical("AND") || this.addError(
|
|
317
288
|
"Expected 'AND' between values in 'between' operator",
|
|
@@ -319,44 +290,44 @@ class y {
|
|
|
319
290
|
"INVALID_SYNTAX",
|
|
320
291
|
"Use format: field between value1 AND value2"
|
|
321
292
|
);
|
|
322
|
-
const
|
|
293
|
+
const o = this.parseValue();
|
|
323
294
|
return {
|
|
324
295
|
type: "comparison",
|
|
325
296
|
field: t,
|
|
326
|
-
operator:
|
|
327
|
-
value: [s,
|
|
297
|
+
operator: n,
|
|
298
|
+
value: [s, o],
|
|
328
299
|
start: t.start,
|
|
329
|
-
end:
|
|
300
|
+
end: o.end
|
|
330
301
|
};
|
|
331
302
|
}
|
|
332
303
|
if (this.isAtEnd())
|
|
333
304
|
return this.addError(
|
|
334
|
-
`Expected a value after operator '${
|
|
335
|
-
|
|
305
|
+
`Expected a value after operator '${n}'`,
|
|
306
|
+
a,
|
|
336
307
|
"MISSING_VALUE",
|
|
337
308
|
'Add a value like "text", 123, or true'
|
|
338
309
|
), {
|
|
339
310
|
type: "comparison",
|
|
340
311
|
field: t,
|
|
341
|
-
operator:
|
|
312
|
+
operator: n,
|
|
342
313
|
value: {
|
|
343
314
|
type: "literal",
|
|
344
315
|
valueType: "string",
|
|
345
316
|
value: "",
|
|
346
|
-
start:
|
|
347
|
-
end:
|
|
317
|
+
start: a.end,
|
|
318
|
+
end: a.end
|
|
348
319
|
},
|
|
349
320
|
start: t.start,
|
|
350
|
-
end:
|
|
321
|
+
end: a.end
|
|
351
322
|
};
|
|
352
|
-
const
|
|
323
|
+
const h = this.parseValue();
|
|
353
324
|
return {
|
|
354
325
|
type: "comparison",
|
|
355
326
|
field: t,
|
|
356
|
-
operator:
|
|
357
|
-
value:
|
|
327
|
+
operator: n,
|
|
328
|
+
value: h,
|
|
358
329
|
start: t.start,
|
|
359
|
-
end:
|
|
330
|
+
end: h.end
|
|
360
331
|
};
|
|
361
332
|
}
|
|
362
333
|
/**
|
|
@@ -447,7 +418,7 @@ class y {
|
|
|
447
418
|
};
|
|
448
419
|
}
|
|
449
420
|
normalizeOperator(e) {
|
|
450
|
-
const t = e.toLowerCase(),
|
|
421
|
+
const t = e.toLowerCase(), r = {
|
|
451
422
|
"==": "eq",
|
|
452
423
|
"=": "eq",
|
|
453
424
|
"!=": "ne",
|
|
@@ -456,9 +427,9 @@ class y {
|
|
|
456
427
|
"<": "lt",
|
|
457
428
|
"<=": "lte"
|
|
458
429
|
};
|
|
459
|
-
if (e in
|
|
460
|
-
return
|
|
461
|
-
const
|
|
430
|
+
if (e in r)
|
|
431
|
+
return r[e];
|
|
432
|
+
const a = {
|
|
462
433
|
"!in": "not_in",
|
|
463
434
|
"!contains": "not_contains",
|
|
464
435
|
"!startswith": "not_startswith",
|
|
@@ -473,22 +444,14 @@ class y {
|
|
|
473
444
|
"!all": "not_all",
|
|
474
445
|
"!none": "not_none"
|
|
475
446
|
};
|
|
476
|
-
if (t in
|
|
477
|
-
return
|
|
478
|
-
const
|
|
447
|
+
if (t in a)
|
|
448
|
+
return a[t];
|
|
449
|
+
const n = {
|
|
479
450
|
regex: "regexp",
|
|
480
451
|
starts_with: "startswith",
|
|
481
452
|
ends_with: "endswith"
|
|
482
453
|
};
|
|
483
|
-
|
|
484
|
-
// Check if this is a valid operator, if not add a warning with suggestions
|
|
485
|
-
if (!v.includes(t)) {
|
|
486
|
-
const suggestion = suggestOp(t);
|
|
487
|
-
// Return the original value but note that it might be invalid
|
|
488
|
-
// The warning will be added by the caller if needed
|
|
489
|
-
return { value: t, unknown: true, suggestion };
|
|
490
|
-
}
|
|
491
|
-
return t;
|
|
454
|
+
return t in n ? n[t] : (c.includes(t), t);
|
|
492
455
|
}
|
|
493
456
|
isAtEnd() {
|
|
494
457
|
return this.current >= this.tokens.length;
|
|
@@ -514,7 +477,7 @@ class y {
|
|
|
514
477
|
matchLogical(e) {
|
|
515
478
|
return this.check("logicalOp") && this.peek().value.toUpperCase() === e ? (this.advance(), !0) : !1;
|
|
516
479
|
}
|
|
517
|
-
addError(e, t,
|
|
480
|
+
addError(e, t, r, a) {
|
|
518
481
|
this.errors.push({
|
|
519
482
|
message: e,
|
|
520
483
|
start: t.start,
|
|
@@ -522,11 +485,11 @@ class y {
|
|
|
522
485
|
line: t.line,
|
|
523
486
|
column: t.column,
|
|
524
487
|
severity: "error",
|
|
525
|
-
code:
|
|
526
|
-
suggestion:
|
|
488
|
+
code: r,
|
|
489
|
+
suggestion: a
|
|
527
490
|
});
|
|
528
491
|
}
|
|
529
|
-
addWarning(e, t,
|
|
492
|
+
addWarning(e, t, r) {
|
|
530
493
|
this.warnings.push({
|
|
531
494
|
message: e,
|
|
532
495
|
start: t.start,
|
|
@@ -535,7 +498,7 @@ class y {
|
|
|
535
498
|
column: t.column,
|
|
536
499
|
severity: "warning",
|
|
537
500
|
code: "TYPE_MISMATCH",
|
|
538
|
-
suggestion:
|
|
501
|
+
suggestion: r
|
|
539
502
|
});
|
|
540
503
|
}
|
|
541
504
|
/**
|
|
@@ -544,7 +507,7 @@ class y {
|
|
|
544
507
|
*/
|
|
545
508
|
synchronize() {
|
|
546
509
|
for (this.advance(); !this.isAtEnd(); ) {
|
|
547
|
-
if (
|
|
510
|
+
if (p.has(this.peek().type) || this.peek().type === "paren" && this.peek().value === ")")
|
|
548
511
|
return;
|
|
549
512
|
this.advance();
|
|
550
513
|
}
|
|
@@ -576,23 +539,23 @@ class y {
|
|
|
576
539
|
};
|
|
577
540
|
}
|
|
578
541
|
}
|
|
579
|
-
function
|
|
580
|
-
return new
|
|
542
|
+
function l(i) {
|
|
543
|
+
return new v(i).parse();
|
|
581
544
|
}
|
|
582
|
-
function
|
|
583
|
-
return
|
|
545
|
+
function k(i) {
|
|
546
|
+
return l(i).success;
|
|
584
547
|
}
|
|
585
|
-
function
|
|
586
|
-
return
|
|
548
|
+
function y(i) {
|
|
549
|
+
return l(i).errors;
|
|
587
550
|
}
|
|
588
|
-
function
|
|
589
|
-
let e = `Error at line ${
|
|
590
|
-
return
|
|
551
|
+
function E(i) {
|
|
552
|
+
let e = `Error at line ${i.line}, column ${i.column}: ${i.message}`;
|
|
553
|
+
return i.suggestion && (e += ` (${i.suggestion})`), e;
|
|
591
554
|
}
|
|
592
555
|
export {
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
556
|
+
v as TqlParser,
|
|
557
|
+
E as formatParseError,
|
|
558
|
+
y as getTqlErrors,
|
|
559
|
+
k as isValidTql,
|
|
560
|
+
l as parseTql
|
|
598
561
|
};
|
package/dist/src/schemaCache.js
CHANGED
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var d = (s, e, t) => m(s, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
-
class p {
|
|
5
|
-
constructor() {
|
|
6
|
-
d(this, "cache", null);
|
|
7
|
-
}
|
|
1
|
+
class d {
|
|
2
|
+
cache = null;
|
|
8
3
|
/**
|
|
9
4
|
* Get cached schema data, rebuilding if schema has changed.
|
|
10
5
|
* Returns null if no schema provided.
|
|
@@ -31,33 +26,31 @@ class p {
|
|
|
31
26
|
* Get field by name with O(1) lookup
|
|
32
27
|
*/
|
|
33
28
|
getField(e, t) {
|
|
34
|
-
|
|
35
|
-
return n == null ? void 0 : n.fieldMap.get(t);
|
|
29
|
+
return this.get(e)?.fieldMap.get(t);
|
|
36
30
|
}
|
|
37
31
|
/**
|
|
38
32
|
* Get field type by name with O(1) lookup
|
|
39
33
|
*/
|
|
40
34
|
getFieldType(e, t) {
|
|
41
|
-
|
|
42
|
-
return n == null ? void 0 : n.typeMap.get(t);
|
|
35
|
+
return this.get(e)?.typeMap.get(t);
|
|
43
36
|
}
|
|
44
37
|
/**
|
|
45
38
|
* Build the cache from a schema
|
|
46
39
|
*/
|
|
47
40
|
buildCache(e, t) {
|
|
48
|
-
const
|
|
49
|
-
const r = o ? `${o}.${
|
|
50
|
-
if (
|
|
51
|
-
for (const
|
|
52
|
-
|
|
41
|
+
const a = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), n = [], h = (c, o) => {
|
|
42
|
+
const r = o ? `${o}.${c.name}` : c.name;
|
|
43
|
+
if (a.set(r, c), i.set(r, c.type), n.push(r), c.nested)
|
|
44
|
+
for (const p of c.nested)
|
|
45
|
+
h(p, r);
|
|
53
46
|
};
|
|
54
|
-
for (const
|
|
55
|
-
c
|
|
47
|
+
for (const c of e)
|
|
48
|
+
h(c);
|
|
56
49
|
return {
|
|
57
50
|
fields: e,
|
|
58
|
-
fieldMap:
|
|
59
|
-
typeMap:
|
|
60
|
-
allFieldNames:
|
|
51
|
+
fieldMap: a,
|
|
52
|
+
typeMap: i,
|
|
53
|
+
allFieldNames: n,
|
|
61
54
|
hash: t,
|
|
62
55
|
timestamp: Date.now()
|
|
63
56
|
};
|
|
@@ -67,38 +60,37 @@ class p {
|
|
|
67
60
|
* Uses a simple string-based hash for performance.
|
|
68
61
|
*/
|
|
69
62
|
computeHash(e) {
|
|
70
|
-
const t = (
|
|
71
|
-
let
|
|
72
|
-
return
|
|
73
|
-
}).join(","),
|
|
74
|
-
let
|
|
75
|
-
for (let
|
|
76
|
-
|
|
77
|
-
return (
|
|
63
|
+
const t = (n) => n.map((h) => {
|
|
64
|
+
let c = `${h.name}:${h.type}`;
|
|
65
|
+
return h.nested && (c += `[${t(h.nested)}]`), c;
|
|
66
|
+
}).join(","), a = t(e);
|
|
67
|
+
let i = 5381;
|
|
68
|
+
for (let n = 0; n < a.length; n++)
|
|
69
|
+
i = i * 33 ^ a.charCodeAt(n);
|
|
70
|
+
return (i >>> 0).toString(36);
|
|
78
71
|
}
|
|
79
72
|
}
|
|
80
73
|
let l = null;
|
|
81
74
|
function u() {
|
|
82
|
-
return l || (l = new
|
|
75
|
+
return l || (l = new d()), l;
|
|
83
76
|
}
|
|
84
|
-
function
|
|
85
|
-
return new
|
|
77
|
+
function g() {
|
|
78
|
+
return new d();
|
|
86
79
|
}
|
|
87
|
-
function
|
|
88
|
-
|
|
89
|
-
return (e == null ? void 0 : e.allFieldNames) ?? [];
|
|
80
|
+
function f(s) {
|
|
81
|
+
return u().get(s)?.allFieldNames ?? [];
|
|
90
82
|
}
|
|
91
|
-
function
|
|
83
|
+
function m(s, e) {
|
|
92
84
|
return u().getFieldType(s, e);
|
|
93
85
|
}
|
|
94
|
-
function
|
|
86
|
+
function F(s, e) {
|
|
95
87
|
return u().getField(s, e);
|
|
96
88
|
}
|
|
97
89
|
export {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
90
|
+
d as SchemaCache,
|
|
91
|
+
g as createSchemaCache,
|
|
92
|
+
F as getCachedField,
|
|
93
|
+
f as getCachedFieldNames,
|
|
94
|
+
m as getCachedFieldType,
|
|
103
95
|
u as getSchemaCache
|
|
104
96
|
};
|