@tellaro/tql 1.4.0 → 1.4.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/src/completionProvider.js +16 -15
- package/dist/src/complexityAnalyzer.js +1 -1
- package/dist/src/parser.js +2 -1
- package/dist/src/semanticPreview.d.ts +1 -1
- package/dist/src/semanticPreview.js +7 -7
- package/dist/src/tokenizer.js +7 -5
- package/dist/src/types.d.ts +1 -1
- package/dist/src/validator.js +43 -13
- package/dist/tql.css +1 -1
- package/dist/vue/TqlAutocomplete.vue.js +2 -2
- package/dist/vue/TqlChart.vue.js +2 -2
- package/dist/vue/TqlChart.vue2.js +109 -113
- package/dist/vue/TqlInput.vue.js +2 -2
- package/dist/vue/components/TqlPreview.vue.js +4 -4
- package/dist/vue/useTqlInput.d.ts +54 -0
- package/package.json +127 -126
- package/dist/node_modules/chartjs-plugin-annotation/dist/chartjs-plugin-annotation.esm.js +0 -1655
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { Chart as
|
|
1
|
+
import { defineComponent as at, ref as $, computed as S, onMounted as st, watch as nt, openBlock as M, createElementBlock as w, normalizeStyle as rt, createElementVNode as D, toDisplayString as O, createCommentVNode as it, nextTick as ot } from "vue";
|
|
2
|
+
import { Chart as x, Title as ct, Tooltip as ut, Legend as ft, Filler as pt, BarElement as dt, BarController as mt, LineElement as ht, LineController as yt, PointElement as gt, ArcElement as vt, PieController as bt, DoughnutController as xt, CategoryScale as kt, LinearScale as _t, TimeScale as St } from "../node_modules/chart.js/dist/chart.js";
|
|
3
3
|
import { formatValue as G } from "../src/chart/formatters.js";
|
|
4
|
-
import { extractScalarValue as J, buildChartData as
|
|
5
|
-
const
|
|
4
|
+
import { extractScalarValue as J, buildChartData as Tt, buildChartOptions as Ct, isTimeSeriesData as Mt, isLinkTemplateSafe as wt, expandLinkTemplate as Lt, chartJsType as K } from "../src/chart/mappers.js";
|
|
5
|
+
const Pt = {
|
|
6
6
|
key: 0,
|
|
7
7
|
class: "tql-chart__metric"
|
|
8
8
|
}, Ft = { class: "tql-chart__metric-value" }, Nt = {
|
|
9
9
|
key: 0,
|
|
10
10
|
class: "tql-chart__metric-title"
|
|
11
|
-
},
|
|
11
|
+
}, Ht = /* @__PURE__ */ at({
|
|
12
12
|
__name: "TqlChart",
|
|
13
13
|
props: {
|
|
14
14
|
result: {},
|
|
@@ -18,7 +18,8 @@ const At = {
|
|
|
18
18
|
},
|
|
19
19
|
emits: ["drilldown"],
|
|
20
20
|
setup(E, { emit: U }) {
|
|
21
|
-
|
|
21
|
+
x.register(
|
|
22
|
+
ct,
|
|
22
23
|
ut,
|
|
23
24
|
ft,
|
|
24
25
|
pt,
|
|
@@ -32,19 +33,14 @@ const At = {
|
|
|
32
33
|
xt,
|
|
33
34
|
kt,
|
|
34
35
|
_t,
|
|
35
|
-
St
|
|
36
|
-
Tt
|
|
36
|
+
St
|
|
37
37
|
);
|
|
38
|
-
let
|
|
39
|
-
async function
|
|
38
|
+
let L = null, P = !1, I = !1;
|
|
39
|
+
async function X() {
|
|
40
40
|
if (!I) {
|
|
41
41
|
I = !0;
|
|
42
42
|
try {
|
|
43
|
-
|
|
44
|
-
} catch {
|
|
45
|
-
}
|
|
46
|
-
try {
|
|
47
|
-
X = (await import("../node_modules/chartjs-plugin-annotation/dist/chartjs-plugin-annotation.esm.js")).default;
|
|
43
|
+
L = (await import("../node_modules/chartjs-plugin-datalabels/dist/chartjs-plugin-datalabels.esm.js")).default;
|
|
48
44
|
} catch {
|
|
49
45
|
}
|
|
50
46
|
if (!P)
|
|
@@ -54,146 +50,146 @@ const At = {
|
|
|
54
50
|
}
|
|
55
51
|
}
|
|
56
52
|
}
|
|
57
|
-
|
|
58
|
-
const
|
|
53
|
+
x.defaults.color = "#888", x.defaults.borderColor = "#ffffff0a", x.defaults.font.family = "-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif";
|
|
54
|
+
const e = E, Y = U, m = $(null), F = $(null);
|
|
59
55
|
let u = null;
|
|
60
|
-
const
|
|
61
|
-
if (
|
|
62
|
-
if (
|
|
63
|
-
const
|
|
64
|
-
return
|
|
65
|
-
}),
|
|
66
|
-
if (!
|
|
67
|
-
const
|
|
68
|
-
return
|
|
69
|
-
}), B =
|
|
70
|
-
function
|
|
71
|
-
if (!
|
|
72
|
-
const t = u.getElementsAtEventForMode(
|
|
56
|
+
const T = S(() => {
|
|
57
|
+
if (e.chartType && e.chartType !== "auto") return e.chartType;
|
|
58
|
+
if (e.result.viz_hint) return e.result.viz_hint;
|
|
59
|
+
const l = e.result.stats;
|
|
60
|
+
return l && l.type === "stats" && !l.group_by ? "number" : "bar";
|
|
61
|
+
}), N = S(() => T.value === "number"), j = S(() => T.value === "gauge"), Q = S(() => {
|
|
62
|
+
if (!N.value) return "";
|
|
63
|
+
const l = e.result.stats, t = J(l), a = e.result.viz_params?.format;
|
|
64
|
+
return a ? G(t, a) : t >= 1e6 ? (t / 1e6).toFixed(1) + "M" : t >= 1e4 ? (t / 1e3).toFixed(1) + "K" : Number.isInteger(t) ? t.toLocaleString() : t.toFixed(2);
|
|
65
|
+
}), B = S(() => e.result.viz_params?.title || "");
|
|
66
|
+
function Z(l) {
|
|
67
|
+
if (!e.drilldown || !u) return;
|
|
68
|
+
const t = u.getElementsAtEventForMode(l, "nearest", { intersect: !0 }, !1);
|
|
73
69
|
if (t.length === 0) return;
|
|
74
|
-
const
|
|
75
|
-
|
|
70
|
+
const a = t[0], o = a.datasetIndex, n = a.index, d = String(u.data.labels?.[n] ?? ""), v = Number(u.data.datasets[o]?.data?.[n] ?? 0);
|
|
71
|
+
Y("drilldown", {
|
|
76
72
|
label: d,
|
|
77
|
-
value:
|
|
73
|
+
value: v,
|
|
78
74
|
index: n,
|
|
79
|
-
field:
|
|
80
|
-
chartType:
|
|
75
|
+
field: e.result.stats.group_by?.[0],
|
|
76
|
+
chartType: T.value
|
|
81
77
|
});
|
|
82
78
|
}
|
|
83
|
-
function
|
|
84
|
-
const
|
|
85
|
-
if (!
|
|
86
|
-
const t =
|
|
79
|
+
function tt() {
|
|
80
|
+
const l = m.value;
|
|
81
|
+
if (!l) return;
|
|
82
|
+
const t = l.getContext("2d");
|
|
87
83
|
if (!t) return;
|
|
88
|
-
const
|
|
89
|
-
if (
|
|
90
|
-
for (const p of
|
|
91
|
-
const [
|
|
92
|
-
if (
|
|
93
|
-
const [V, W] =
|
|
94
|
-
!isNaN(V) && !isNaN(W) &&
|
|
84
|
+
const a = e.result.viz_params || {}, o = J(e.result.stats), n = Number(a.y_min ?? 0), d = Number(a.y_max ?? 100), v = Math.max(0, Math.min(1, (o - n) / (d - n))), k = a.ranges, h = [];
|
|
85
|
+
if (k)
|
|
86
|
+
for (const p of k.split(",")) {
|
|
87
|
+
const [C, b] = p.split(":");
|
|
88
|
+
if (C && b) {
|
|
89
|
+
const [V, W] = C.split("-").map(Number);
|
|
90
|
+
!isNaN(V) && !isNaN(W) && h.push({ from: V, to: W, color: b.startsWith("#") ? b : `#${b}` });
|
|
95
91
|
}
|
|
96
92
|
}
|
|
97
|
-
const
|
|
98
|
-
if (t.clearRect(0, 0,
|
|
99
|
-
for (const p of
|
|
100
|
-
const
|
|
101
|
-
t.beginPath(), t.arc(
|
|
93
|
+
const r = l.width = l.parentElement?.clientWidth || 400, y = l.height = 240, i = r / 2, s = y - 40, g = Math.min(r / 2 - 30, y - 60), c = Math.PI, f = 2 * Math.PI;
|
|
94
|
+
if (t.clearRect(0, 0, r, y), t.beginPath(), t.arc(i, s, g, c, f), t.lineWidth = 24, t.strokeStyle = "#333", t.lineCap = "round", t.stroke(), h.length > 0)
|
|
95
|
+
for (const p of h) {
|
|
96
|
+
const C = c + (p.from - n) / (d - n) * Math.PI, b = c + (p.to - n) / (d - n) * Math.PI;
|
|
97
|
+
t.beginPath(), t.arc(i, s, g, C, Math.min(b, f)), t.lineWidth = 24, t.strokeStyle = p.color + "66", t.lineCap = "butt", t.stroke();
|
|
102
98
|
}
|
|
103
|
-
const
|
|
104
|
-
let
|
|
105
|
-
if (
|
|
106
|
-
for (const p of
|
|
107
|
-
if (
|
|
108
|
-
|
|
99
|
+
const A = c + v * Math.PI;
|
|
100
|
+
let _ = "#818cf8";
|
|
101
|
+
if (h.length > 0) {
|
|
102
|
+
for (const p of h)
|
|
103
|
+
if (o >= p.from && o <= p.to) {
|
|
104
|
+
_ = p.color;
|
|
109
105
|
break;
|
|
110
106
|
}
|
|
111
107
|
}
|
|
112
|
-
t.beginPath(), t.arc(s,
|
|
113
|
-
const q =
|
|
114
|
-
t.fillStyle =
|
|
108
|
+
t.beginPath(), t.arc(i, s, g, c, A), t.lineWidth = 24, t.strokeStyle = _, t.lineCap = "round", t.stroke();
|
|
109
|
+
const q = a.title || "", z = a.format, lt = z ? G(o, z) : Number.isInteger(o) ? o.toLocaleString() : o.toFixed(1);
|
|
110
|
+
t.fillStyle = _, t.font = "bold 36px -apple-system, BlinkMacSystemFont, sans-serif", t.textAlign = "center", t.fillText(String(lt), i, s - 10), q && (t.fillStyle = "#888", t.font = "13px -apple-system, BlinkMacSystemFont, sans-serif", t.fillText(q, i, s + 18)), t.fillStyle = "#555", t.font = "11px -apple-system, BlinkMacSystemFont, sans-serif", t.textAlign = "left", t.fillText(String(n), i - g - 5, s + 18), t.textAlign = "right", t.fillText(String(d), i + g + 5, s + 18);
|
|
115
111
|
}
|
|
116
|
-
function
|
|
117
|
-
if (!m.value ||
|
|
118
|
-
if (
|
|
119
|
-
|
|
112
|
+
function et() {
|
|
113
|
+
if (!m.value || N.value) return;
|
|
114
|
+
if (j.value) {
|
|
115
|
+
tt();
|
|
120
116
|
return;
|
|
121
117
|
}
|
|
122
118
|
u && (u.destroy(), u = null);
|
|
123
|
-
const
|
|
124
|
-
|
|
125
|
-
const
|
|
126
|
-
|
|
127
|
-
const
|
|
128
|
-
|
|
129
|
-
...
|
|
119
|
+
const l = T.value, t = Tt(e.result, l), a = Ct(e.result, l);
|
|
120
|
+
e.drilldown && (a.onClick = Z, m.value && (m.value.style.cursor = "pointer"));
|
|
121
|
+
const o = [], n = e.result.viz_params || {}, d = n.labels === !0 || n.labels === "true" || n.labels === "minmax";
|
|
122
|
+
L && d && o.push(L);
|
|
123
|
+
const v = [...t.labels], k = a.indexAxis === "y", h = P && Mt(e.result.stats), r = a;
|
|
124
|
+
h && r?.scales?.x && !k ? r.scales.x = {
|
|
125
|
+
...r.scales.x,
|
|
130
126
|
type: "time",
|
|
131
127
|
time: { tooltipFormat: "HH:mm", displayFormats: { minute: "HH:mm", hour: "HH:mm", day: "MMM d" } },
|
|
132
|
-
ticks: { ...
|
|
133
|
-
} :
|
|
134
|
-
...
|
|
135
|
-
callback: function(
|
|
136
|
-
return
|
|
128
|
+
ticks: { ...r.scales.x.ticks, maxRotation: 0, autoSkip: !0, maxTicksLimit: 10 }
|
|
129
|
+
} : k ? r?.scales?.y && !r.scales.y.ticks?.callback && (r.scales.y.ticks = {
|
|
130
|
+
...r.scales.y.ticks,
|
|
131
|
+
callback: function(i, s) {
|
|
132
|
+
return v[s] ?? s;
|
|
137
133
|
}
|
|
138
|
-
}) :
|
|
139
|
-
...
|
|
140
|
-
callback: function(
|
|
141
|
-
return
|
|
134
|
+
}) : r?.scales?.x && !r.scales.x.ticks?.callback && (r.scales.x.ticks = {
|
|
135
|
+
...r.scales.x.ticks,
|
|
136
|
+
callback: function(i, s) {
|
|
137
|
+
return v[s] ?? s;
|
|
142
138
|
}
|
|
143
139
|
});
|
|
144
|
-
const
|
|
145
|
-
if (
|
|
146
|
-
const
|
|
147
|
-
|
|
148
|
-
...
|
|
140
|
+
const y = n.link;
|
|
141
|
+
if (y && wt(y) && F.value) {
|
|
142
|
+
const i = n.link_target || "_self", s = F.value;
|
|
143
|
+
a.plugins = {
|
|
144
|
+
...a.plugins,
|
|
149
145
|
tooltip: {
|
|
150
146
|
enabled: !1,
|
|
151
|
-
external: (
|
|
152
|
-
const { tooltip: c } =
|
|
147
|
+
external: (g) => {
|
|
148
|
+
const { tooltip: c } = g;
|
|
153
149
|
if (c.opacity === 0) {
|
|
154
150
|
s.style.opacity = "0";
|
|
155
151
|
return;
|
|
156
152
|
}
|
|
157
|
-
const
|
|
158
|
-
if (!
|
|
159
|
-
const
|
|
160
|
-
value:
|
|
161
|
-
label:
|
|
162
|
-
field:
|
|
163
|
-
count:
|
|
164
|
-
}),
|
|
165
|
-
s.innerHTML = `<div class="tt-title">${
|
|
153
|
+
const f = c.dataPoints?.[0];
|
|
154
|
+
if (!f) return;
|
|
155
|
+
const A = Lt(y, {
|
|
156
|
+
value: f.label,
|
|
157
|
+
label: f.label,
|
|
158
|
+
field: e.result.stats.group_by?.[0],
|
|
159
|
+
count: f.raw
|
|
160
|
+
}), _ = i === "_blank" ? ' rel="noopener noreferrer"' : "";
|
|
161
|
+
s.innerHTML = `<div class="tt-title">${f.label}</div><div class="tt-val">${f.formattedValue}</div><a href="${A}" target="${i}"${_} class="tt-link">Open link →</a>`, s.style.opacity = "1", s.style.left = c.caretX + "px", s.style.top = c.caretY + "px";
|
|
166
162
|
}
|
|
167
163
|
}
|
|
168
164
|
};
|
|
169
165
|
}
|
|
170
166
|
try {
|
|
171
|
-
u = new
|
|
172
|
-
type: K(
|
|
167
|
+
u = new x(m.value, {
|
|
168
|
+
type: K(l),
|
|
173
169
|
data: { labels: t.labels, datasets: t.datasets },
|
|
174
|
-
options:
|
|
175
|
-
plugins:
|
|
170
|
+
options: a,
|
|
171
|
+
plugins: o
|
|
176
172
|
});
|
|
177
|
-
} catch (
|
|
178
|
-
console.warn("[TqlChart] Plugin error, rendering without plugins:",
|
|
179
|
-
type: K(
|
|
173
|
+
} catch (i) {
|
|
174
|
+
console.warn("[TqlChart] Plugin error, rendering without plugins:", i), u = new x(m.value, {
|
|
175
|
+
type: K(l),
|
|
180
176
|
data: { labels: t.labels, datasets: t.datasets },
|
|
181
|
-
options:
|
|
177
|
+
options: a
|
|
182
178
|
});
|
|
183
179
|
}
|
|
184
180
|
}
|
|
185
181
|
let H = !1;
|
|
186
182
|
async function R() {
|
|
187
|
-
H || (await
|
|
183
|
+
H || (await X(), H = !0), ot(et);
|
|
188
184
|
}
|
|
189
|
-
return
|
|
185
|
+
return st(R), nt(() => [e.result, e.chartType], () => R(), { deep: !0 }), (l, t) => (M(), w("div", {
|
|
190
186
|
class: "tql-chart",
|
|
191
|
-
style:
|
|
187
|
+
style: rt({ height: E.height })
|
|
192
188
|
}, [
|
|
193
|
-
|
|
194
|
-
D("span", Ft, O(
|
|
195
|
-
B.value ? (
|
|
196
|
-
])) : (
|
|
189
|
+
N.value ? (M(), w("div", Pt, [
|
|
190
|
+
D("span", Ft, O(Q.value), 1),
|
|
191
|
+
B.value ? (M(), w("span", Nt, O(B.value), 1)) : it("", !0)
|
|
192
|
+
])) : (M(), w("canvas", {
|
|
197
193
|
key: 1,
|
|
198
194
|
ref_key: "canvasRef",
|
|
199
195
|
ref: m,
|
|
@@ -201,12 +197,12 @@ const At = {
|
|
|
201
197
|
}, null, 512)),
|
|
202
198
|
D("div", {
|
|
203
199
|
ref_key: "tooltipRef",
|
|
204
|
-
ref:
|
|
200
|
+
ref: F,
|
|
205
201
|
class: "tql-chart__tooltip"
|
|
206
202
|
}, null, 512)
|
|
207
203
|
], 4));
|
|
208
204
|
}
|
|
209
205
|
});
|
|
210
206
|
export {
|
|
211
|
-
|
|
207
|
+
Ht as default
|
|
212
208
|
};
|
package/dist/vue/TqlInput.vue.js
CHANGED
|
@@ -2,7 +2,7 @@ import o from "./TqlInput.vue2.js";
|
|
|
2
2
|
/* empty css */
|
|
3
3
|
/* empty css */
|
|
4
4
|
import t from "../_virtual/_plugin-vue_export-helper.js";
|
|
5
|
-
const
|
|
5
|
+
const _ = /* @__PURE__ */ t(o, [["__scopeId", "data-v-b501ae88"]]);
|
|
6
6
|
export {
|
|
7
|
-
|
|
7
|
+
_ as default
|
|
8
8
|
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import
|
|
1
|
+
import o from "./TqlPreview.vue2.js";
|
|
2
2
|
import { TqlPreviewNode as i } from "./TqlPreview.vue2.js";
|
|
3
3
|
/* empty css */
|
|
4
|
-
import
|
|
5
|
-
const
|
|
4
|
+
import r from "../../_virtual/_plugin-vue_export-helper.js";
|
|
5
|
+
const m = /* @__PURE__ */ r(o, [["__scopeId", "data-v-3521fa37"]]);
|
|
6
6
|
export {
|
|
7
7
|
i as TqlPreviewNode,
|
|
8
|
-
|
|
8
|
+
m as default
|
|
9
9
|
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { Ref } from 'vue';
|
|
2
|
+
import { TqlCompletionItem, TqlFieldSchema, TqlParseResult, TqlSnippet, TqlToken, TqlValidationResult } from '../src/types';
|
|
3
|
+
export interface UseTqlInputOptions {
|
|
4
|
+
modelValue: Ref<string>;
|
|
5
|
+
fieldSchema?: Ref<TqlFieldSchema[] | undefined>;
|
|
6
|
+
snippets?: Ref<TqlSnippet[] | undefined>;
|
|
7
|
+
fieldValues?: Ref<Record<string, string[]> | undefined>;
|
|
8
|
+
validateOnInput?: boolean;
|
|
9
|
+
/** Debounce time for validation in ms (default: 300) */
|
|
10
|
+
debounceMs?: number;
|
|
11
|
+
/** Debounce time for completions in ms (default: 50, faster than validation) */
|
|
12
|
+
completionDebounceMs?: number;
|
|
13
|
+
autocomplete?: boolean;
|
|
14
|
+
onValidation?: (result: TqlValidationResult) => void;
|
|
15
|
+
onParse?: (result: TqlParseResult) => void;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Placeholder position for tab-stop navigation (used in insertCompletion return value)
|
|
19
|
+
*/
|
|
20
|
+
export interface PlaceholderPosition {
|
|
21
|
+
start: number;
|
|
22
|
+
end: number;
|
|
23
|
+
}
|
|
24
|
+
export declare function useTqlInput(options: UseTqlInputOptions): {
|
|
25
|
+
tokens: any;
|
|
26
|
+
parseResult: any;
|
|
27
|
+
validationResult: any;
|
|
28
|
+
cursorPosition: any;
|
|
29
|
+
completionItems: any;
|
|
30
|
+
showAutocomplete: any;
|
|
31
|
+
isValidating: any;
|
|
32
|
+
isValid: any;
|
|
33
|
+
errors: any;
|
|
34
|
+
warnings: any;
|
|
35
|
+
hasErrors: any;
|
|
36
|
+
hasWarnings: any;
|
|
37
|
+
tokenize: () => any;
|
|
38
|
+
parse: () => TqlParseResult;
|
|
39
|
+
validate: () => TqlValidationResult;
|
|
40
|
+
updateCompletions: () => void;
|
|
41
|
+
triggerAutocomplete: () => void;
|
|
42
|
+
hideAutocomplete: () => void;
|
|
43
|
+
handleInput: (value: string) => void;
|
|
44
|
+
handleCursorChange: (position: number) => void;
|
|
45
|
+
insertCompletion: (item: TqlCompletionItem) => {
|
|
46
|
+
query: string;
|
|
47
|
+
newCursorPosition: number;
|
|
48
|
+
placeholders: PlaceholderPosition[];
|
|
49
|
+
};
|
|
50
|
+
insertSnippet: (snippet: TqlSnippet) => string;
|
|
51
|
+
getTokenAtCursor: () => TqlToken | null;
|
|
52
|
+
isPositionInError: (position: number) => boolean;
|
|
53
|
+
getErrorsAtPosition: (position: number) => any;
|
|
54
|
+
};
|