@tellaro/tql 0.2.1 → 0.2.22

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.
@@ -83,6 +83,9 @@ export declare class TqlTokenizer {
83
83
  private isWhitespace;
84
84
  private isDigit;
85
85
  private isIdentifierStart;
86
+ /**
87
+ * Check if char can continue an identifier (NOT including @ which is only valid at start)
88
+ */
86
89
  private isIdentifierChar;
87
90
  private isOperatorChar;
88
91
  }
@@ -1,4 +1,4 @@
1
- const c = [
1
+ const l = [
2
2
  // Equality
3
3
  "eq",
4
4
  "ne",
@@ -39,7 +39,7 @@ const c = [
39
39
  "not_any",
40
40
  "not_all",
41
41
  "not_none"
42
- ], h = {
42
+ ], c = {
43
43
  "==": "eq",
44
44
  "=": "eq",
45
45
  "!=": "ne",
@@ -47,7 +47,7 @@ const c = [
47
47
  ">=": "gte",
48
48
  "<": "lt",
49
49
  "<=": "lte"
50
- }, l = {
50
+ }, u = {
51
51
  "!in": "not_in",
52
52
  "!contains": "not_contains",
53
53
  "!startswith": "not_startswith",
@@ -61,7 +61,7 @@ const c = [
61
61
  "!any": "not_any",
62
62
  "!all": "not_all",
63
63
  "!none": "not_none"
64
- }, u = ["AND", "OR", "NOT"], p = ["ANY", "ALL", "NONE"], d = [
64
+ }, p = ["AND", "OR", "NOT"], d = ["ANY", "ALL", "NONE"], k = [
65
65
  // String mutators
66
66
  "lowercase",
67
67
  "uppercase",
@@ -96,7 +96,7 @@ const c = [
96
96
  "sum",
97
97
  "min",
98
98
  "max"
99
- ], k = [
99
+ ], f = [
100
100
  // Counting
101
101
  "count",
102
102
  "unique_count",
@@ -125,7 +125,7 @@ const c = [
125
125
  "values",
126
126
  "unique",
127
127
  "distinct"
128
- ], f = [
128
+ ], m = [
129
129
  "string",
130
130
  "str",
131
131
  "number",
@@ -141,7 +141,7 @@ const c = [
141
141
  "list",
142
142
  "object",
143
143
  "geo"
144
- ], m = [
144
+ ], _ = [
145
145
  "bar",
146
146
  "barchart",
147
147
  "line",
@@ -161,8 +161,8 @@ const c = [
161
161
  "nested_pie",
162
162
  "nested_donut",
163
163
  "chord"
164
- ], _ = ["by", "as", "null", "true", "false", "stats", "top", "bottom"];
165
- class g {
164
+ ], g = ["by", "as", "null", "true", "false", "stats", "top", "bottom"];
165
+ class T {
166
166
  input;
167
167
  position;
168
168
  line;
@@ -294,7 +294,7 @@ class g {
294
294
  const s = t + this.peek();
295
295
  if (s === "=>")
296
296
  return this.advance(), this.makeToken("arrow", "=>", e, n, i);
297
- (s in h || s === "==" || s === "!=") && (t = s, this.advance());
297
+ (s in c || s === "==" || s === "!=") && (t = s, this.advance());
298
298
  }
299
299
  if (t === "!") {
300
300
  const s = this.position;
@@ -302,12 +302,12 @@ class g {
302
302
  for (; !this.isAtEnd() && this.isIdentifierChar(this.peek()); )
303
303
  r += this.advance();
304
304
  if (r) {
305
- if ("!" + r in l)
305
+ if ("!" + r in u)
306
306
  return this.makeToken("operator", "!" + r, e, n, i);
307
307
  this.position = s, this.column = i + 1;
308
308
  }
309
309
  }
310
- return t in h || t === "==" || t === "=" || t === "!=" || t === ">" || t === ">=" || t === "<" || t === "<=" ? this.makeToken("operator", t, e, n, i) : this.makeToken("unknown", t, e, n, i);
310
+ return t in c || t === "==" || t === "=" || t === "!=" || t === ">" || t === ">=" || t === "<" || t === "<=" ? this.makeToken("operator", t, e, n, i) : this.makeToken("unknown", t, e, n, i);
311
311
  }
312
312
  /**
313
313
  * Scan an identifier (field name, operator keyword, etc.)
@@ -315,17 +315,26 @@ class g {
315
315
  scanIdentifier(e, n, i) {
316
316
  this.position = e, this.column = i;
317
317
  let t = "";
318
- for (; !this.isAtEnd() && this.isIdentifierChar(this.peek()); )
319
- t += this.advance();
320
- const s = this.classifyIdentifier(t);
321
- return this.makeToken(s, t, e, n, i);
318
+ const s = this.advance();
319
+ if (t += s, s === "@" && this.peek() === "@")
320
+ return this.makeToken("unknown", t, e, n, i);
321
+ let r = s;
322
+ for (; !this.isAtEnd() && this.isIdentifierChar(this.peek()); ) {
323
+ const h = this.advance();
324
+ if (h === "." && r === ".")
325
+ return this.position--, this.column--, t = t.slice(0, -1), this.makeToken("unknown", t, e, n, i);
326
+ t += h, r = h;
327
+ }
328
+ t.endsWith(".") && (this.position--, this.column--, t = t.slice(0, -1));
329
+ const a = this.classifyIdentifier(t);
330
+ return this.makeToken(a, t, e, n, i);
322
331
  }
323
332
  /**
324
333
  * Classify an identifier into the appropriate token type
325
334
  */
326
335
  classifyIdentifier(e) {
327
336
  const n = e.toUpperCase(), i = e.toLowerCase();
328
- return u.includes(n) ? "logicalOp" : p.includes(n) ? "collectionOp" : i === "true" || i === "false" ? "boolean" : i === "null" ? "null" : i === "stats" ? "keyword" : c.includes(i) ? "operator" : k.includes(i) ? "aggregation" : d.includes(i) ? "mutator" : f.includes(i) ? "typeHint" : m.includes(i) ? "visualization" : _.includes(i) ? "keyword" : "field";
337
+ return p.includes(n) ? "logicalOp" : d.includes(n) ? "collectionOp" : i === "true" || i === "false" ? "boolean" : i === "null" ? "null" : i === "stats" ? "keyword" : l.includes(i) ? "operator" : f.includes(i) ? "aggregation" : k.includes(i) ? "mutator" : m.includes(i) ? "typeHint" : _.includes(i) ? "visualization" : g.includes(i) ? "keyword" : "field";
329
338
  }
330
339
  // ============================================================================
331
340
  // Helper Methods
@@ -364,30 +373,33 @@ class g {
364
373
  isIdentifierStart(e) {
365
374
  return e >= "a" && e <= "z" || e >= "A" && e <= "Z" || e === "_" || e === "@";
366
375
  }
376
+ /**
377
+ * Check if char can continue an identifier (NOT including @ which is only valid at start)
378
+ */
367
379
  isIdentifierChar(e) {
368
- return this.isIdentifierStart(e) || this.isDigit(e) || e === "." || // For nested field access
380
+ return e >= "a" && e <= "z" || e >= "A" && e <= "Z" || e === "_" || this.isDigit(e) || e === "." || // For nested field access
369
381
  e === "-";
370
382
  }
371
383
  isOperatorChar(e) {
372
384
  return e === "=" || e === "!" || e === ">" || e === "<";
373
385
  }
374
386
  }
375
- function T(o) {
376
- return new g(o).tokenize();
377
- }
378
387
  function w(o) {
379
- return T(o).filter((e) => e.type !== "whitespace");
388
+ return new T(o).tokenize();
389
+ }
390
+ function b(o) {
391
+ return w(o).filter((e) => e.type !== "whitespace");
380
392
  }
381
- function b(o, e) {
393
+ function v(o, e) {
382
394
  for (const n of o)
383
395
  if (e >= n.start && e < n.end)
384
396
  return n;
385
397
  return null;
386
398
  }
387
- function v(o, e, n) {
399
+ function O(o, e, n) {
388
400
  return o.filter((i) => i.start < n && i.end > e);
389
401
  }
390
- function O(o, e) {
402
+ function A(o, e) {
391
403
  let n = null;
392
404
  for (const i of o)
393
405
  if (i.end <= e)
@@ -396,7 +408,7 @@ function O(o, e) {
396
408
  break;
397
409
  return n;
398
410
  }
399
- function A(o, e, n = !0) {
411
+ function E(o, e, n = !0) {
400
412
  const i = n ? o.filter((s) => s.type !== "whitespace") : o;
401
413
  let t = null;
402
414
  for (const s of i)
@@ -407,21 +419,21 @@ function A(o, e, n = !0) {
407
419
  return t;
408
420
  }
409
421
  export {
410
- k as AGGREGATION_FUNCTIONS,
411
- p as COLLECTION_OPERATORS,
412
- c as COMPARISON_OPERATORS,
413
- _ as KEYWORDS,
414
- u as LOGICAL_OPERATORS,
415
- d as MUTATORS,
416
- l as NEGATION_SYMBOL_OPERATORS,
417
- h as SYMBOL_OPERATORS,
418
- f as TYPE_HINTS,
419
- g as TqlTokenizer,
420
- m as VISUALIZATION_TYPES,
421
- A as findPreviousToken,
422
- b as findTokenAtPosition,
423
- O as findTokenBefore,
424
- v as findTokensInRange,
425
- T as tokenizeTql,
426
- w as tokenizeTqlNoWhitespace
422
+ f as AGGREGATION_FUNCTIONS,
423
+ d as COLLECTION_OPERATORS,
424
+ l as COMPARISON_OPERATORS,
425
+ g as KEYWORDS,
426
+ p as LOGICAL_OPERATORS,
427
+ k as MUTATORS,
428
+ u as NEGATION_SYMBOL_OPERATORS,
429
+ c as SYMBOL_OPERATORS,
430
+ m as TYPE_HINTS,
431
+ T as TqlTokenizer,
432
+ _ as VISUALIZATION_TYPES,
433
+ E as findPreviousToken,
434
+ v as findTokenAtPosition,
435
+ A as findTokenBefore,
436
+ O as findTokensInRange,
437
+ w as tokenizeTql,
438
+ b as tokenizeTqlNoWhitespace
427
439
  };
@@ -1,4 +1,9 @@
1
- import { ComputedRef } from 'vue';
1
+ /**
2
+ * TQL (Tellaro Query Language) Type Definitions
3
+ *
4
+ * Comprehensive type system for TQL parsing, validation, and autocomplete.
5
+ * Synchronized with tellaro-query-language Python/Rust implementations.
6
+ */
2
7
  export type TqlTokenType = "field" | "operator" | "logicalOp" | "collectionOp" | "string" | "number" | "boolean" | "null" | "paren" | "bracket" | "comma" | "pipe" | "arrow" | "doubleColon" | "mutator" | "aggregation" | "keyword" | "typeHint" | "visualization" | "whitespace" | "unknown" | "error";
3
8
  export interface TqlToken {
4
9
  type: TqlTokenType;
@@ -231,6 +236,14 @@ export interface TqlInputEmits {
231
236
  (e: "parse", result: TqlParseResult): void;
232
237
  (e: "submit", value: string): void;
233
238
  }
239
+ /**
240
+ * Reactive reference type for Vue computed properties.
241
+ * This is a simplified type that matches Vue's ComputedRef interface
242
+ * without requiring Vue as a direct dependency.
243
+ */
244
+ export interface ReactiveRef<T> {
245
+ readonly value: T;
246
+ }
234
247
  export interface TqlInputExpose {
235
248
  focus(): void;
236
249
  blur(): void;
@@ -240,12 +253,12 @@ export interface TqlInputExpose {
240
253
  getTokenAtPosition(pos: number): TqlToken | null;
241
254
  getCursorPosition(): number;
242
255
  setCursorPosition(pos: number): void;
243
- /** Whether the current query is valid (no syntax errors) */
244
- isValid: ComputedRef<boolean>;
245
- /** Whether the current query has validation errors */
246
- hasErrors: ComputedRef<boolean>;
247
- /** Array of current validation errors */
248
- errors: ComputedRef<TqlParseError[]>;
256
+ /** Whether the current query is valid (no syntax errors). Access via .value */
257
+ isValid: ReactiveRef<boolean>;
258
+ /** Whether the current query has validation errors. Access via .value */
259
+ hasErrors: ReactiveRef<boolean>;
260
+ /** Array of current validation errors. Access via .value */
261
+ errors: ReactiveRef<TqlParseError[]>;
249
262
  }
250
263
  export type ComplexityScore = "low" | "medium" | "high";
251
264
  export interface ComplexityWarning {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tellaro/tql",
3
- "version": "0.2.1",
3
+ "version": "0.2.22",
4
4
  "description": "Tellaro Query Language (TQL) parser, validator, and autocomplete for JavaScript/TypeScript",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -73,6 +73,7 @@
73
73
  "@vue/test-utils": "^2.4.0",
74
74
  "@vue/tsconfig": "^0.5.1",
75
75
  "@vueuse/core": "^10.0.0",
76
+ "ajv": "^8.17.1",
76
77
  "eslint": "^8.56.0",
77
78
  "js-yaml": "^4.1.0",
78
79
  "jsdom": "^24.0.0",