@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
package/dist/vue/useTqlInput.js
CHANGED
|
@@ -1,59 +1,61 @@
|
|
|
1
|
-
import { useDebounceFn as
|
|
2
|
-
import { ref as p, computed as
|
|
3
|
-
import {
|
|
4
|
-
import { parseTql as
|
|
5
|
-
import { findTokenAtPosition as R, tokenizeTql as
|
|
6
|
-
import { validateTql as
|
|
7
|
-
function
|
|
1
|
+
import { useDebounceFn as O } from "@vueuse/core";
|
|
2
|
+
import { ref as p, computed as T, watch as oe } from "vue";
|
|
3
|
+
import { getCompletions as re, shouldTriggerCompletion as ue } from "../src/completionProvider.js";
|
|
4
|
+
import { parseTql as le } from "../src/parser.js";
|
|
5
|
+
import { findTokenAtPosition as R, tokenizeTql as ae } from "../src/tokenizer.js";
|
|
6
|
+
import { validateTql as ie } from "../src/validator.js";
|
|
7
|
+
function he(V) {
|
|
8
8
|
const {
|
|
9
9
|
modelValue: i,
|
|
10
10
|
fieldSchema: u,
|
|
11
11
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
12
|
-
snippets:
|
|
12
|
+
snippets: ce,
|
|
13
13
|
// Reserved for future snippet support
|
|
14
14
|
fieldValues: y,
|
|
15
15
|
validateOnInput: j = !0,
|
|
16
|
-
debounceMs:
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
debounceMs: Q = 300,
|
|
17
|
+
completionDebounceMs: U = 50,
|
|
18
|
+
// Faster debounce for completions
|
|
19
|
+
autocomplete: A = !0,
|
|
20
|
+
onValidation: C,
|
|
21
|
+
onParse: k
|
|
22
|
+
} = V, v = p([]), w = p(null), m = p(null), c = p(0), g = p([]), f = p(!1), q = p(!1), _ = T(() => {
|
|
21
23
|
var e;
|
|
22
|
-
return ((e =
|
|
23
|
-
}), b =
|
|
24
|
+
return ((e = m.value) == null ? void 0 : e.valid) ?? !0;
|
|
25
|
+
}), b = T(() => {
|
|
24
26
|
var e;
|
|
25
|
-
return ((e =
|
|
26
|
-
}), P =
|
|
27
|
+
return ((e = m.value) == null ? void 0 : e.errors) ?? [];
|
|
28
|
+
}), P = T(() => {
|
|
27
29
|
var e;
|
|
28
|
-
return ((e =
|
|
29
|
-
}),
|
|
30
|
-
function
|
|
31
|
-
return v.value =
|
|
30
|
+
return ((e = m.value) == null ? void 0 : e.warnings) ?? [];
|
|
31
|
+
}), $ = T(() => b.value.length > 0), B = T(() => P.value.length > 0);
|
|
32
|
+
function M() {
|
|
33
|
+
return v.value = ae(i.value), v.value;
|
|
32
34
|
}
|
|
33
|
-
function
|
|
34
|
-
const e =
|
|
35
|
-
return w.value = e,
|
|
35
|
+
function G() {
|
|
36
|
+
const e = le(i.value);
|
|
37
|
+
return w.value = e, k == null || k(e), e;
|
|
36
38
|
}
|
|
37
|
-
function
|
|
39
|
+
function E() {
|
|
38
40
|
var s, r;
|
|
39
|
-
|
|
41
|
+
q.value = !0;
|
|
40
42
|
const e = (s = u == null ? void 0 : u.value) == null ? void 0 : s.map((l) => l.name), t = (r = u == null ? void 0 : u.value) == null ? void 0 : r.reduce(
|
|
41
|
-
(l,
|
|
43
|
+
(l, d) => (l[d.name] = d.type, l),
|
|
42
44
|
{}
|
|
43
|
-
), n =
|
|
45
|
+
), n = ie(i.value, {
|
|
44
46
|
availableFields: e,
|
|
45
47
|
fieldTypes: t,
|
|
46
48
|
strictMode: !1
|
|
47
49
|
});
|
|
48
|
-
return
|
|
50
|
+
return m.value = n, q.value = !1, C == null || C(n), n;
|
|
49
51
|
}
|
|
50
|
-
const
|
|
52
|
+
const H = O(E, Q), J = O(I, U);
|
|
51
53
|
function I() {
|
|
52
|
-
if (!
|
|
53
|
-
|
|
54
|
+
if (!A) {
|
|
55
|
+
g.value = [], f.value = !1;
|
|
54
56
|
return;
|
|
55
57
|
}
|
|
56
|
-
const e =
|
|
58
|
+
const e = re(
|
|
57
59
|
{
|
|
58
60
|
query: i.value,
|
|
59
61
|
cursorPosition: c.value
|
|
@@ -65,21 +67,21 @@ function me(V) {
|
|
|
65
67
|
maxItems: 15
|
|
66
68
|
}
|
|
67
69
|
);
|
|
68
|
-
|
|
70
|
+
g.value = e, f.value = e.length > 0;
|
|
69
71
|
}
|
|
70
|
-
function
|
|
71
|
-
I(),
|
|
72
|
+
function K() {
|
|
73
|
+
I(), f.value = g.value.length > 0;
|
|
72
74
|
}
|
|
73
75
|
function W() {
|
|
74
|
-
|
|
76
|
+
f.value = !1;
|
|
75
77
|
}
|
|
76
78
|
function z(e) {
|
|
77
|
-
|
|
79
|
+
M(), j && H(), A && ue(e, c.value) && (J(), g.value.length > 0 && (f.value = !0));
|
|
78
80
|
}
|
|
79
|
-
function
|
|
81
|
+
function L(e) {
|
|
80
82
|
c.value = e, I();
|
|
81
83
|
}
|
|
82
|
-
function
|
|
84
|
+
function N(e) {
|
|
83
85
|
const t = i.value, n = c.value, s = R(v.value, n);
|
|
84
86
|
let r = n, l = n;
|
|
85
87
|
if (s && s.type !== "whitespace")
|
|
@@ -91,40 +93,40 @@ function me(V) {
|
|
|
91
93
|
o.end === n && (r = o.start, l = o.end);
|
|
92
94
|
}
|
|
93
95
|
}
|
|
94
|
-
const
|
|
95
|
-
let
|
|
96
|
-
const
|
|
96
|
+
const d = t.substring(0, r), ee = t.substring(l), x = [];
|
|
97
|
+
let h = e.insertText;
|
|
98
|
+
const te = [...e.insertText.matchAll(/\$(\d+)/g)].sort(
|
|
97
99
|
(a, o) => parseInt(a[1]) - parseInt(o[1])
|
|
98
100
|
);
|
|
99
|
-
let
|
|
100
|
-
for (const a of
|
|
101
|
-
const o =
|
|
101
|
+
let D = 0;
|
|
102
|
+
for (const a of te) {
|
|
103
|
+
const o = h.indexOf(a[0]);
|
|
102
104
|
if (o !== -1) {
|
|
103
|
-
const
|
|
105
|
+
const F = r + o - D;
|
|
104
106
|
x.push({
|
|
105
|
-
start:
|
|
106
|
-
end:
|
|
107
|
+
start: F,
|
|
108
|
+
end: F
|
|
107
109
|
// Zero-width cursor position
|
|
108
|
-
}),
|
|
110
|
+
}), h = h.replace(a[0], ""), D += a[0].length;
|
|
109
111
|
}
|
|
110
112
|
}
|
|
111
|
-
const
|
|
112
|
-
return W(), { query:
|
|
113
|
+
const ne = d + h + ee, se = x.length > 0 ? x[0].start : r + h.length;
|
|
114
|
+
return W(), { query: ne, newCursorPosition: se, placeholders: x };
|
|
113
115
|
}
|
|
114
|
-
function
|
|
115
|
-
const t = i.value, n = c.value, s = t.substring(0, n), r = t.substring(n),
|
|
116
|
-
return s +
|
|
116
|
+
function X(e) {
|
|
117
|
+
const t = i.value, n = c.value, s = t.substring(0, n), r = t.substring(n), d = s.length > 0 && !s.endsWith(" ") && !s.endsWith("(") ? " " : "";
|
|
118
|
+
return s + d + e.insertText + r;
|
|
117
119
|
}
|
|
118
|
-
function
|
|
120
|
+
function Y() {
|
|
119
121
|
return R(v.value, c.value);
|
|
120
122
|
}
|
|
121
|
-
function
|
|
123
|
+
function Z(e) {
|
|
122
124
|
return b.value.some((t) => e >= t.start && e < t.end);
|
|
123
125
|
}
|
|
124
|
-
function
|
|
126
|
+
function S(e) {
|
|
125
127
|
return b.value.filter((t) => e >= t.start && e < t.end);
|
|
126
128
|
}
|
|
127
|
-
return
|
|
129
|
+
return oe(
|
|
128
130
|
i,
|
|
129
131
|
(e) => {
|
|
130
132
|
e !== void 0 && z(e);
|
|
@@ -134,33 +136,33 @@ function me(V) {
|
|
|
134
136
|
// State
|
|
135
137
|
tokens: v,
|
|
136
138
|
parseResult: w,
|
|
137
|
-
validationResult:
|
|
139
|
+
validationResult: m,
|
|
138
140
|
cursorPosition: c,
|
|
139
|
-
completionItems:
|
|
140
|
-
showAutocomplete:
|
|
141
|
-
isValidating:
|
|
141
|
+
completionItems: g,
|
|
142
|
+
showAutocomplete: f,
|
|
143
|
+
isValidating: q,
|
|
142
144
|
// Computed
|
|
143
|
-
isValid:
|
|
145
|
+
isValid: _,
|
|
144
146
|
errors: b,
|
|
145
147
|
warnings: P,
|
|
146
|
-
hasErrors:
|
|
147
|
-
hasWarnings:
|
|
148
|
+
hasErrors: $,
|
|
149
|
+
hasWarnings: B,
|
|
148
150
|
// Methods
|
|
149
|
-
tokenize:
|
|
150
|
-
parse:
|
|
151
|
-
validate:
|
|
151
|
+
tokenize: M,
|
|
152
|
+
parse: G,
|
|
153
|
+
validate: E,
|
|
152
154
|
updateCompletions: I,
|
|
153
|
-
triggerAutocomplete:
|
|
155
|
+
triggerAutocomplete: K,
|
|
154
156
|
hideAutocomplete: W,
|
|
155
157
|
handleInput: z,
|
|
156
|
-
handleCursorChange:
|
|
157
|
-
insertCompletion:
|
|
158
|
-
insertSnippet:
|
|
159
|
-
getTokenAtCursor:
|
|
160
|
-
isPositionInError:
|
|
161
|
-
getErrorsAtPosition:
|
|
158
|
+
handleCursorChange: L,
|
|
159
|
+
insertCompletion: N,
|
|
160
|
+
insertSnippet: X,
|
|
161
|
+
getTokenAtCursor: Y,
|
|
162
|
+
isPositionInError: Z,
|
|
163
|
+
getErrorsAtPosition: S
|
|
162
164
|
};
|
|
163
165
|
}
|
|
164
166
|
export {
|
|
165
|
-
|
|
167
|
+
he as useTqlInput
|
|
166
168
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tellaro/tql",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Tellaro Query Language (TQL) parser, validator, and autocomplete for JavaScript/TypeScript",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -62,10 +62,12 @@
|
|
|
62
62
|
"@types/js-yaml": "^4.0.9",
|
|
63
63
|
"@types/node": "^20.11.0",
|
|
64
64
|
"@vitejs/plugin-vue": "^5.0.0",
|
|
65
|
+
"@vue/test-utils": "^2.4.0",
|
|
65
66
|
"@vue/tsconfig": "^0.5.1",
|
|
66
67
|
"@vueuse/core": "^10.0.0",
|
|
67
68
|
"eslint": "^8.56.0",
|
|
68
69
|
"js-yaml": "^4.1.0",
|
|
70
|
+
"jsdom": "^24.0.0",
|
|
69
71
|
"typescript": "^5.3.0",
|
|
70
72
|
"vite": "^5.0.0",
|
|
71
73
|
"vite-plugin-dts": "^3.7.0",
|