@burdenoff/microfe-bigconsole 2026.1124.7 → 2026.1124.8
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.
|
@@ -1,31 +1,31 @@
|
|
|
1
1
|
import { Section as e } from "../../common/Section.js";
|
|
2
2
|
import { useWidgetQueryPreview as t } from "../../../hooks/useWidgetQueryPreview.js";
|
|
3
|
-
import { NUMERIC_ONLY as n, QUERY_AGGREGATES as r, QUERY_LIMITS as i,
|
|
3
|
+
import { NUMERIC_ONLY as n, QUERY_AGGREGATES as r, QUERY_LIMITS as i, dateBucketUnits as a, describeQuery as o, detectFields as ee, normalizeQuery as s, omitKey as c, queryInputLimits as l, queryProblem as u, queryRendererProblem as d, repeatedXWarning as f, suggestQuery as p, supportsQuery as m, supportsQuerySeries as h } from "../../../utils/widgetQuery.js";
|
|
4
4
|
import "../../common/index.js";
|
|
5
5
|
import { Suspense as g, lazy as _, useMemo as v } from "react";
|
|
6
6
|
import { Calendar as y, Hash as b, Plus as x, ToggleLeft as S, Trash2 as C, Type as w } from "lucide-react";
|
|
7
|
-
import { Button as T, Input as
|
|
8
|
-
import { useI18n as
|
|
9
|
-
import { Fragment as
|
|
7
|
+
import { Button as T, Input as E, Label as D, Select as O, SelectContent as k, SelectItem as A, SelectTrigger as j, SelectValue as M, Spinner as N } from "@burdenoff/fe-libs/ui";
|
|
8
|
+
import { useI18n as P } from "@burdenoff/fe-libs/shared/providers/shell/I18nProvider";
|
|
9
|
+
import { Fragment as F, jsx as I, jsxs as L } from "react/jsx-runtime";
|
|
10
10
|
// src/bigconsole/components/builder/inspector/QuerySection.tsx
|
|
11
|
-
var
|
|
11
|
+
var R = "__none__", z = 8, B = {
|
|
12
12
|
text: w,
|
|
13
13
|
number: b,
|
|
14
14
|
date: y,
|
|
15
15
|
boolean: S
|
|
16
|
-
},
|
|
16
|
+
}, V = {
|
|
17
17
|
text: "text",
|
|
18
18
|
number: "number",
|
|
19
19
|
date: "date",
|
|
20
20
|
boolean: "true/false"
|
|
21
|
-
},
|
|
21
|
+
}, H = {
|
|
22
22
|
sum: "Total",
|
|
23
23
|
avg: "Average",
|
|
24
24
|
min: "Smallest",
|
|
25
25
|
max: "Largest",
|
|
26
26
|
count: "Count",
|
|
27
27
|
distinct_count: "Distinct count"
|
|
28
|
-
},
|
|
28
|
+
}, U = [
|
|
29
29
|
{
|
|
30
30
|
value: "none",
|
|
31
31
|
label: "Keep the data order"
|
|
@@ -43,11 +43,11 @@ var L = "__none__", R = 8, z = {
|
|
|
43
43
|
label: "Group A to Z"
|
|
44
44
|
}
|
|
45
45
|
];
|
|
46
|
-
function
|
|
46
|
+
function W(e) {
|
|
47
47
|
let t = e.orderBy;
|
|
48
48
|
return t ? t.by === "dimension" ? "group-asc" : t.direction === "desc" ? "value-desc" : "value-asc" : "none";
|
|
49
49
|
}
|
|
50
|
-
function
|
|
50
|
+
function G(e, t) {
|
|
51
51
|
let n = c(e, "orderBy");
|
|
52
52
|
return t === "value-desc" ? {
|
|
53
53
|
...n,
|
|
@@ -72,70 +72,103 @@ function W(e, t) {
|
|
|
72
72
|
}
|
|
73
73
|
} : n;
|
|
74
74
|
}
|
|
75
|
-
var
|
|
76
|
-
function
|
|
75
|
+
var K = _(() => import("../../widgets/chart/ChartWidget.js"));
|
|
76
|
+
function q(e) {
|
|
77
77
|
return e.map((e) => Object.fromEntries(Object.entries(e).map(([e, t]) => [e, t === null || typeof t == "string" || typeof t == "number" ? t : void 0])));
|
|
78
78
|
}
|
|
79
|
-
var
|
|
80
|
-
let t =
|
|
81
|
-
return /* @__PURE__ */
|
|
79
|
+
var J = ({ field: e }) => {
|
|
80
|
+
let t = B[e.kind];
|
|
81
|
+
return /* @__PURE__ */ L("span", {
|
|
82
82
|
className: "flex items-center gap-2",
|
|
83
83
|
children: [
|
|
84
|
-
/* @__PURE__ */
|
|
84
|
+
/* @__PURE__ */ I(t, {
|
|
85
85
|
className: "h-3.5 w-3.5 shrink-0 text-text-secondary",
|
|
86
86
|
"aria-hidden": !0
|
|
87
87
|
}),
|
|
88
|
-
/* @__PURE__ */
|
|
89
|
-
/* @__PURE__ */
|
|
88
|
+
/* @__PURE__ */ I("span", { children: e.name }),
|
|
89
|
+
/* @__PURE__ */ L("span", {
|
|
90
90
|
className: "sr-only",
|
|
91
91
|
children: [
|
|
92
92
|
"(",
|
|
93
|
-
|
|
93
|
+
V[e.kind],
|
|
94
94
|
")"
|
|
95
95
|
]
|
|
96
96
|
})
|
|
97
97
|
]
|
|
98
98
|
});
|
|
99
|
-
},
|
|
100
|
-
value: n ?? (i ?
|
|
101
|
-
onValueChange: (e) => o(e ===
|
|
102
|
-
children: [/* @__PURE__ */
|
|
99
|
+
}, Y = ({ id: e, label: t, value: n, fields: r, optional: i = !1, placeholder: a, onChange: o }) => /* @__PURE__ */ L(O, {
|
|
100
|
+
value: n ?? (i ? R : void 0),
|
|
101
|
+
onValueChange: (e) => o(e === R ? void 0 : e),
|
|
102
|
+
children: [/* @__PURE__ */ I(j, {
|
|
103
103
|
id: e,
|
|
104
104
|
"aria-label": t,
|
|
105
105
|
style: {
|
|
106
106
|
height: "var(--size-controlHeight-md)",
|
|
107
107
|
fontSize: "var(--font-size-body-sm)"
|
|
108
108
|
},
|
|
109
|
-
children: /* @__PURE__ */
|
|
110
|
-
}), /* @__PURE__ */
|
|
111
|
-
i && /* @__PURE__ */
|
|
112
|
-
value:
|
|
109
|
+
children: /* @__PURE__ */ I(M, { placeholder: a })
|
|
110
|
+
}), /* @__PURE__ */ L(k, { children: [
|
|
111
|
+
i && /* @__PURE__ */ I(A, {
|
|
112
|
+
value: R,
|
|
113
113
|
children: "None"
|
|
114
114
|
}),
|
|
115
|
-
n !== void 0 && !r.some((e) => e.name === n) && /* @__PURE__ */
|
|
115
|
+
n !== void 0 && !r.some((e) => e.name === n) && /* @__PURE__ */ I(A, {
|
|
116
116
|
value: n,
|
|
117
117
|
children: n
|
|
118
118
|
}),
|
|
119
|
-
r.map((e) => /* @__PURE__ */
|
|
119
|
+
r.map((e) => /* @__PURE__ */ I(A, {
|
|
120
120
|
value: e.name,
|
|
121
|
-
children: /* @__PURE__ */
|
|
121
|
+
children: /* @__PURE__ */ I(J, { field: e })
|
|
122
122
|
}, e.name))
|
|
123
123
|
] })]
|
|
124
|
-
}),
|
|
124
|
+
}), X = ({ children: e }) => /* @__PURE__ */ I("div", {
|
|
125
125
|
className: "flex min-w-0 items-center gap-2",
|
|
126
126
|
children: e
|
|
127
|
-
})
|
|
128
|
-
|
|
129
|
-
|
|
127
|
+
});
|
|
128
|
+
function te({ field: e, unit: t, options: n, onChange: r }) {
|
|
129
|
+
let { t: i } = P(), a = {
|
|
130
|
+
day: i("bigconsole.widget.query.dateBucketDay", "Day"),
|
|
131
|
+
week: i("bigconsole.widget.query.dateBucketWeek", "Week (starts Monday)"),
|
|
132
|
+
month: i("bigconsole.widget.query.dateBucketMonth", "Month"),
|
|
133
|
+
quarter: i("bigconsole.widget.query.dateBucketQuarter", "Quarter"),
|
|
134
|
+
year: i("bigconsole.widget.query.dateBucketYear", "Year")
|
|
135
|
+
}, o = i("bigconsole.widget.query.dateBucketField", "Date bucket for {{field}} (UTC)", { field: e });
|
|
136
|
+
return /* @__PURE__ */ L(O, {
|
|
137
|
+
value: t ?? R,
|
|
138
|
+
onValueChange: (e) => r(n.find((t) => t === e)),
|
|
139
|
+
children: [/* @__PURE__ */ I(j, {
|
|
140
|
+
"aria-label": o,
|
|
141
|
+
className: "min-h-11 text-sm",
|
|
142
|
+
children: /* @__PURE__ */ I(M, {})
|
|
143
|
+
}), /* @__PURE__ */ L(k, { children: [
|
|
144
|
+
/* @__PURE__ */ I(A, {
|
|
145
|
+
value: R,
|
|
146
|
+
children: i("bigconsole.widget.query.dateBucketNone", "No bucket")
|
|
147
|
+
}),
|
|
148
|
+
t && !n.includes(t) && /* @__PURE__ */ I(A, {
|
|
149
|
+
value: t,
|
|
150
|
+
disabled: !0,
|
|
151
|
+
children: a[t]
|
|
152
|
+
}),
|
|
153
|
+
n.map((e) => /* @__PURE__ */ I(A, {
|
|
154
|
+
value: e,
|
|
155
|
+
children: a[e]
|
|
156
|
+
}, e))
|
|
157
|
+
] })]
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
var Z = ({ widget: g, rows: _, query: y, sourceSaved: b, onChange: S }) => {
|
|
161
|
+
let { t: w } = P(), N = v(() => _ ? ee(_) : [], [_]), F = h(g.type, g.config), R = m(g.type, g.config), z = g.type === "metric_card", B = l(g.type, g.config), V = y ? d(y, g.type, g.config) ?? u(y, N, F, R) : null, K = y !== null && V === null, q = t(g.id, K ? y : null, K && b), J = g.type === "chart", Z = typeof g.config?.xAxisField == "string" ? g.config.xAxisField : y?.dimensions[0] ?? void 0, Q = !y && J && _ ? f(_, Z) : null, $ = (e) => S(s(e) ?? e);
|
|
162
|
+
if (!R) return y ? /* @__PURE__ */ I(e, {
|
|
130
163
|
title: w("bigconsole.widget.query.title", "Group and total"),
|
|
131
164
|
"data-testid": "widget-inspector-query",
|
|
132
|
-
children: /* @__PURE__ */
|
|
165
|
+
children: /* @__PURE__ */ L("div", {
|
|
133
166
|
className: "space-y-3",
|
|
134
|
-
children: [/* @__PURE__ */
|
|
167
|
+
children: [/* @__PURE__ */ I("p", {
|
|
135
168
|
role: "alert",
|
|
136
169
|
className: "text-sm text-text-secondary",
|
|
137
|
-
children:
|
|
138
|
-
}), /* @__PURE__ */
|
|
170
|
+
children: V
|
|
171
|
+
}), /* @__PURE__ */ I(T, {
|
|
139
172
|
type: "button",
|
|
140
173
|
variant: "outline",
|
|
141
174
|
onClick: () => S(null),
|
|
@@ -144,110 +177,130 @@ var q = ({ field: e }) => {
|
|
|
144
177
|
})
|
|
145
178
|
}) : null;
|
|
146
179
|
if (!y) {
|
|
147
|
-
let t = _ ? p(
|
|
148
|
-
return /* @__PURE__ */
|
|
180
|
+
let t = _ ? p(N, _, F, B.dimensions > 0) : null;
|
|
181
|
+
return /* @__PURE__ */ I(e, {
|
|
149
182
|
title: w("bigconsole.widget.query.title", "Group and total"),
|
|
150
|
-
description: w(
|
|
183
|
+
description: w(z ? "bigconsole.widget.query.metricIntro" : "bigconsole.widget.query.intro", z ? "Calculate one value across the rows without writing a parser." : "Add up, average or count the rows, grouped by a field, without writing a parser."),
|
|
151
184
|
"data-testid": "widget-inspector-query",
|
|
152
|
-
children: /* @__PURE__ */
|
|
185
|
+
children: /* @__PURE__ */ L("div", {
|
|
153
186
|
className: "space-y-3",
|
|
154
187
|
children: [
|
|
155
|
-
Q && /* @__PURE__ */
|
|
188
|
+
Q && /* @__PURE__ */ I("p", {
|
|
156
189
|
role: "status",
|
|
157
190
|
className: "break-words text-xs text-[var(--color-status-warning-text)]",
|
|
158
191
|
"data-testid": "query-repeat-warning",
|
|
159
192
|
children: Q
|
|
160
193
|
}),
|
|
161
|
-
!_ && /* @__PURE__ */
|
|
194
|
+
!_ && /* @__PURE__ */ I("p", {
|
|
162
195
|
className: "text-xs text-text-secondary",
|
|
163
196
|
children: w("bigconsole.widget.query.needsRows", "Connect a data source and parser that return a list of rows to use this.")
|
|
164
197
|
}),
|
|
165
|
-
/* @__PURE__ */
|
|
198
|
+
/* @__PURE__ */ I(T, {
|
|
166
199
|
type: "button",
|
|
167
200
|
variant: "outline",
|
|
168
|
-
disabled: !_ ||
|
|
201
|
+
disabled: !_ || N.length === 0,
|
|
169
202
|
onClick: () => S(t ?? {
|
|
170
203
|
dimensions: [],
|
|
171
204
|
measures: [{ agg: "count" }],
|
|
172
205
|
filters: []
|
|
173
206
|
}),
|
|
174
207
|
"data-testid": "query-start",
|
|
175
|
-
children:
|
|
208
|
+
children: z ? w("bigconsole.widget.query.metricStart", "Calculate a metric") : w("bigconsole.widget.query.start", "Group and total the rows")
|
|
176
209
|
})
|
|
177
210
|
]
|
|
178
211
|
})
|
|
179
212
|
});
|
|
180
213
|
}
|
|
181
|
-
let
|
|
182
|
-
return /* @__PURE__ */
|
|
214
|
+
let re = y.measures.length === 1;
|
|
215
|
+
return /* @__PURE__ */ I(e, {
|
|
183
216
|
title: w("bigconsole.widget.query.title", "Group and total"),
|
|
184
|
-
description:
|
|
217
|
+
description: o(y),
|
|
185
218
|
"data-testid": "widget-inspector-query",
|
|
186
|
-
children: /* @__PURE__ */
|
|
219
|
+
children: /* @__PURE__ */ L("div", {
|
|
187
220
|
className: "flex flex-col gap-form-gap",
|
|
188
221
|
children: [
|
|
189
|
-
|
|
222
|
+
V && /* @__PURE__ */ I("p", {
|
|
190
223
|
role: "alert",
|
|
191
224
|
className: "break-words text-xs text-[var(--color-status-error-text)]",
|
|
192
225
|
"data-testid": "query-problem",
|
|
193
|
-
children:
|
|
226
|
+
children: V
|
|
194
227
|
}),
|
|
195
|
-
(
|
|
228
|
+
(B.dimensions > 0 || y.dimensions.length > 0) && /* @__PURE__ */ L("div", {
|
|
196
229
|
className: "space-y-2",
|
|
197
230
|
children: [
|
|
198
|
-
/* @__PURE__ */
|
|
199
|
-
y.dimensions.map((e, t) =>
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
231
|
+
/* @__PURE__ */ I(D, { children: w("bigconsole.widget.query.groupBy", "Group by") }),
|
|
232
|
+
y.dimensions.map((e, t) => {
|
|
233
|
+
let n = y.dateBuckets?.find(({ field: t }) => t === e), r = N.some(({ name: t, kind: n }) => t === e && n === "date");
|
|
234
|
+
return /* @__PURE__ */ L("div", {
|
|
235
|
+
className: "space-y-2",
|
|
236
|
+
children: [/* @__PURE__ */ L(X, { children: [/* @__PURE__ */ I(Y, {
|
|
237
|
+
id: `query-group-${t}`,
|
|
238
|
+
label: w("bigconsole.widget.query.groupByField", "Group by field {{n}}", { n: t + 1 }),
|
|
239
|
+
value: e,
|
|
240
|
+
fields: N,
|
|
241
|
+
placeholder: w("bigconsole.widget.query.pickField", "Pick a field"),
|
|
242
|
+
onChange: (e) => $({
|
|
243
|
+
...y,
|
|
244
|
+
dimensions: y.dimensions.map((n, r) => r === t ? e ?? "" : n)
|
|
245
|
+
})
|
|
246
|
+
}), /* @__PURE__ */ I(T, {
|
|
247
|
+
type: "button",
|
|
248
|
+
variant: "ghost",
|
|
249
|
+
size: "icon",
|
|
250
|
+
"aria-label": w("bigconsole.widget.query.removeGroup", "Remove group by {{field}}", { field: e }),
|
|
251
|
+
onClick: () => $({
|
|
252
|
+
...y,
|
|
253
|
+
dimensions: y.dimensions.filter((e, n) => n !== t)
|
|
254
|
+
}),
|
|
255
|
+
children: /* @__PURE__ */ I(C, {
|
|
256
|
+
className: "h-4 w-4",
|
|
257
|
+
"aria-hidden": !0
|
|
258
|
+
})
|
|
259
|
+
})] }), !z && (r || n) && /* @__PURE__ */ I(te, {
|
|
260
|
+
field: e,
|
|
261
|
+
unit: n?.unit,
|
|
262
|
+
options: a(_, e),
|
|
263
|
+
onChange: (t) => {
|
|
264
|
+
let n = y.dateBuckets?.filter(({ field: t }) => t !== e) ?? [];
|
|
265
|
+
t && n.push({
|
|
266
|
+
field: e,
|
|
267
|
+
unit: t
|
|
268
|
+
}), $({
|
|
269
|
+
...y,
|
|
270
|
+
dateBuckets: n
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
})]
|
|
274
|
+
}, `${e}-${t}`);
|
|
275
|
+
}),
|
|
276
|
+
y.dimensions.length < B.dimensions && /* @__PURE__ */ L(T, {
|
|
224
277
|
type: "button",
|
|
225
278
|
variant: "ghost",
|
|
226
279
|
size: "sm",
|
|
227
280
|
onClick: () => {
|
|
228
|
-
let e =
|
|
281
|
+
let e = N.find((e) => !y.dimensions.includes(e.name) && e.name !== y.series);
|
|
229
282
|
$({
|
|
230
283
|
...y,
|
|
231
284
|
dimensions: [...y.dimensions, e?.name ?? ""]
|
|
232
285
|
});
|
|
233
286
|
},
|
|
234
287
|
"data-testid": "query-add-group",
|
|
235
|
-
children: [/* @__PURE__ */
|
|
288
|
+
children: [/* @__PURE__ */ I(x, {
|
|
236
289
|
className: "mr-1 h-4 w-4",
|
|
237
290
|
"aria-hidden": !0
|
|
238
291
|
}), w("bigconsole.widget.query.addGroup", "Add a group by")]
|
|
239
292
|
})
|
|
240
293
|
]
|
|
241
294
|
}),
|
|
242
|
-
/* @__PURE__ */
|
|
295
|
+
/* @__PURE__ */ L("div", {
|
|
243
296
|
className: "space-y-2",
|
|
244
297
|
children: [
|
|
245
|
-
/* @__PURE__ */
|
|
246
|
-
y.measures.map((e, t) => /* @__PURE__ */
|
|
247
|
-
/* @__PURE__ */
|
|
298
|
+
/* @__PURE__ */ I(D, { children: w("bigconsole.widget.query.values", "Values") }),
|
|
299
|
+
y.measures.map((e, t) => /* @__PURE__ */ L(X, { children: [
|
|
300
|
+
/* @__PURE__ */ L(O, {
|
|
248
301
|
value: e.agg,
|
|
249
302
|
onValueChange: (r) => {
|
|
250
|
-
let i = r, a = e.field !== void 0 && (!n.has(i) ||
|
|
303
|
+
let i = r, a = e.field !== void 0 && (!n.has(i) || N.find((t) => t.name === e.field)?.kind === "number");
|
|
251
304
|
$({
|
|
252
305
|
...y,
|
|
253
306
|
measures: y.measures.map((e, n) => n === t ? {
|
|
@@ -256,24 +309,24 @@ var q = ({ field: e }) => {
|
|
|
256
309
|
} : e)
|
|
257
310
|
});
|
|
258
311
|
},
|
|
259
|
-
children: [/* @__PURE__ */
|
|
312
|
+
children: [/* @__PURE__ */ I(j, {
|
|
260
313
|
"aria-label": w("bigconsole.widget.query.calculation", "Calculation {{n}}", { n: t + 1 }),
|
|
261
314
|
style: {
|
|
262
315
|
height: "var(--size-controlHeight-md)",
|
|
263
316
|
fontSize: "var(--font-size-body-sm)",
|
|
264
317
|
maxWidth: "9rem"
|
|
265
318
|
},
|
|
266
|
-
children: /* @__PURE__ */
|
|
267
|
-
}), /* @__PURE__ */
|
|
319
|
+
children: /* @__PURE__ */ I(M, {})
|
|
320
|
+
}), /* @__PURE__ */ I(k, { children: r.map((e) => /* @__PURE__ */ I(A, {
|
|
268
321
|
value: e,
|
|
269
|
-
children:
|
|
322
|
+
children: H[e]
|
|
270
323
|
}, e)) })]
|
|
271
324
|
}),
|
|
272
|
-
/* @__PURE__ */
|
|
325
|
+
/* @__PURE__ */ I(Y, {
|
|
273
326
|
id: `query-value-${t}`,
|
|
274
327
|
label: w("bigconsole.widget.query.valueField", "Value field {{n}}", { n: t + 1 }),
|
|
275
328
|
value: e.field,
|
|
276
|
-
fields: n.has(e.agg) ?
|
|
329
|
+
fields: n.has(e.agg) ? N.filter((e) => e.kind === "number") : N,
|
|
277
330
|
optional: e.agg === "count",
|
|
278
331
|
placeholder: e.agg === "count" ? w("bigconsole.widget.query.rows", "Rows") : w("bigconsole.widget.query.pickField", "Pick a field"),
|
|
279
332
|
onChange: (e) => $({
|
|
@@ -288,7 +341,7 @@ var q = ({ field: e }) => {
|
|
|
288
341
|
})
|
|
289
342
|
})
|
|
290
343
|
}),
|
|
291
|
-
y.measures.length > 1 && /* @__PURE__ */
|
|
344
|
+
y.measures.length > 1 && /* @__PURE__ */ I(T, {
|
|
292
345
|
type: "button",
|
|
293
346
|
variant: "ghost",
|
|
294
347
|
size: "icon",
|
|
@@ -298,18 +351,18 @@ var q = ({ field: e }) => {
|
|
|
298
351
|
measures: y.measures.filter((e, n) => n !== t),
|
|
299
352
|
series: void 0
|
|
300
353
|
}),
|
|
301
|
-
children: /* @__PURE__ */
|
|
354
|
+
children: /* @__PURE__ */ I(C, {
|
|
302
355
|
className: "h-4 w-4",
|
|
303
356
|
"aria-hidden": !0
|
|
304
357
|
})
|
|
305
358
|
})
|
|
306
359
|
] }, t)),
|
|
307
|
-
y.measures.length <
|
|
360
|
+
y.measures.length < B.measures && !y.series && /* @__PURE__ */ L(T, {
|
|
308
361
|
type: "button",
|
|
309
362
|
variant: "ghost",
|
|
310
363
|
size: "sm",
|
|
311
364
|
onClick: () => {
|
|
312
|
-
let e =
|
|
365
|
+
let e = N.find((e) => e.kind === "number" && !y.measures.some((t) => t.field === e.name));
|
|
313
366
|
$({
|
|
314
367
|
...y,
|
|
315
368
|
measures: [...y.measures, e ? {
|
|
@@ -319,31 +372,31 @@ var q = ({ field: e }) => {
|
|
|
319
372
|
});
|
|
320
373
|
},
|
|
321
374
|
"data-testid": "query-add-value",
|
|
322
|
-
children: [/* @__PURE__ */
|
|
375
|
+
children: [/* @__PURE__ */ I(x, {
|
|
323
376
|
className: "mr-1 h-4 w-4",
|
|
324
377
|
"aria-hidden": !0
|
|
325
378
|
}), w("bigconsole.widget.query.addValue", "Add a value")]
|
|
326
379
|
})
|
|
327
380
|
]
|
|
328
381
|
}),
|
|
329
|
-
!
|
|
382
|
+
!F && y.series && /* @__PURE__ */ I(T, {
|
|
330
383
|
type: "button",
|
|
331
384
|
variant: "outline",
|
|
332
385
|
onClick: () => $(c(y, "series")),
|
|
333
386
|
children: w("bigconsole.widget.query.removeSeries", "Remove series split")
|
|
334
387
|
}),
|
|
335
|
-
|
|
388
|
+
F && /* @__PURE__ */ L("div", {
|
|
336
389
|
className: "space-y-2",
|
|
337
390
|
children: [
|
|
338
|
-
/* @__PURE__ */
|
|
391
|
+
/* @__PURE__ */ I(D, {
|
|
339
392
|
htmlFor: "query-series",
|
|
340
393
|
children: w("bigconsole.widget.query.series", "Split into lines by")
|
|
341
394
|
}),
|
|
342
|
-
/* @__PURE__ */
|
|
395
|
+
/* @__PURE__ */ I(Y, {
|
|
343
396
|
id: "query-series",
|
|
344
397
|
label: w("bigconsole.widget.query.series", "Split into lines by"),
|
|
345
398
|
value: y.series,
|
|
346
|
-
fields:
|
|
399
|
+
fields: N.filter((e) => !y.dimensions.includes(e.name)),
|
|
347
400
|
optional: !0,
|
|
348
401
|
placeholder: w("bigconsole.widget.query.noSeries", "One line"),
|
|
349
402
|
onChange: (e) => {
|
|
@@ -354,44 +407,44 @@ var q = ({ field: e }) => {
|
|
|
354
407
|
} : t);
|
|
355
408
|
}
|
|
356
409
|
}),
|
|
357
|
-
!
|
|
410
|
+
!re && /* @__PURE__ */ I("p", {
|
|
358
411
|
className: "text-xs text-text-secondary",
|
|
359
412
|
children: w("bigconsole.widget.query.seriesNeedsOne", "Splitting into lines works with one value. Remove the others to use it.")
|
|
360
413
|
}),
|
|
361
|
-
y.series && /* @__PURE__ */
|
|
414
|
+
y.series && /* @__PURE__ */ I("p", {
|
|
362
415
|
className: "text-xs text-text-secondary",
|
|
363
416
|
children: w("bigconsole.widget.query.seriesMax", "Up to {{max}} different values; more would be too many lines.", { max: i.series })
|
|
364
417
|
})
|
|
365
418
|
]
|
|
366
419
|
}),
|
|
367
|
-
/* @__PURE__ */
|
|
420
|
+
/* @__PURE__ */ L("div", {
|
|
368
421
|
className: "grid grid-cols-2 gap-form-gap",
|
|
369
|
-
children: [/* @__PURE__ */
|
|
422
|
+
children: [/* @__PURE__ */ L("div", {
|
|
370
423
|
className: "space-y-2",
|
|
371
|
-
children: [/* @__PURE__ */
|
|
424
|
+
children: [/* @__PURE__ */ I(D, {
|
|
372
425
|
htmlFor: "query-sort",
|
|
373
426
|
children: w("bigconsole.widget.query.sort", "Sort")
|
|
374
|
-
}), /* @__PURE__ */
|
|
375
|
-
value:
|
|
376
|
-
onValueChange: (e) => $(
|
|
377
|
-
children: [/* @__PURE__ */
|
|
427
|
+
}), /* @__PURE__ */ L(O, {
|
|
428
|
+
value: W(y),
|
|
429
|
+
onValueChange: (e) => $(G(y, e)),
|
|
430
|
+
children: [/* @__PURE__ */ I(j, {
|
|
378
431
|
id: "query-sort",
|
|
379
432
|
style: {
|
|
380
433
|
height: "var(--size-controlHeight-md)",
|
|
381
434
|
fontSize: "var(--font-size-body-sm)"
|
|
382
435
|
},
|
|
383
|
-
children: /* @__PURE__ */
|
|
384
|
-
}), /* @__PURE__ */
|
|
436
|
+
children: /* @__PURE__ */ I(M, {})
|
|
437
|
+
}), /* @__PURE__ */ I(k, { children: U.filter((e) => e.value !== "group-asc" || y.dimensions.length > 0).map((e) => /* @__PURE__ */ I(A, {
|
|
385
438
|
value: e.value,
|
|
386
439
|
children: e.label
|
|
387
440
|
}, e.value)) })]
|
|
388
441
|
})]
|
|
389
|
-
}), /* @__PURE__ */
|
|
442
|
+
}), /* @__PURE__ */ L("div", {
|
|
390
443
|
className: "space-y-2",
|
|
391
|
-
children: [/* @__PURE__ */
|
|
444
|
+
children: [/* @__PURE__ */ I(D, {
|
|
392
445
|
htmlFor: "query-limit",
|
|
393
446
|
children: w("bigconsole.widget.query.limit", "Show only the first")
|
|
394
|
-
}), /* @__PURE__ */
|
|
447
|
+
}), /* @__PURE__ */ I(E, {
|
|
395
448
|
id: "query-limit",
|
|
396
449
|
type: "number",
|
|
397
450
|
min: 1,
|
|
@@ -408,18 +461,18 @@ var q = ({ field: e }) => {
|
|
|
408
461
|
})]
|
|
409
462
|
})]
|
|
410
463
|
}),
|
|
411
|
-
|
|
464
|
+
K && !b && /* @__PURE__ */ I("p", {
|
|
412
465
|
role: "status",
|
|
413
466
|
className: "text-xs text-text-secondary",
|
|
414
467
|
children: w("bigconsole.widget.query.previewRequiresSavedSource", "Save the data source changes to preview this query.")
|
|
415
468
|
}),
|
|
416
|
-
/* @__PURE__ */
|
|
469
|
+
/* @__PURE__ */ I(ne, {
|
|
417
470
|
widget: g,
|
|
418
|
-
isChart:
|
|
419
|
-
state:
|
|
420
|
-
ready:
|
|
471
|
+
isChart: J,
|
|
472
|
+
state: q,
|
|
473
|
+
ready: K && b
|
|
421
474
|
}),
|
|
422
|
-
/* @__PURE__ */
|
|
475
|
+
/* @__PURE__ */ I("div", { children: /* @__PURE__ */ I(T, {
|
|
423
476
|
type: "button",
|
|
424
477
|
variant: "ghost",
|
|
425
478
|
size: "sm",
|
|
@@ -430,67 +483,67 @@ var q = ({ field: e }) => {
|
|
|
430
483
|
]
|
|
431
484
|
})
|
|
432
485
|
});
|
|
433
|
-
},
|
|
434
|
-
let { t: i } =
|
|
486
|
+
}, ne = ({ widget: e, isChart: t, state: n, ready: r }) => {
|
|
487
|
+
let { t: i } = P();
|
|
435
488
|
if (!r) return null;
|
|
436
489
|
let a = n.rows && n.rows[0] ? Object.keys(n.rows[0]) : [];
|
|
437
|
-
return /* @__PURE__ */
|
|
490
|
+
return /* @__PURE__ */ L("div", {
|
|
438
491
|
className: "space-y-2",
|
|
439
492
|
"data-testid": "query-preview",
|
|
440
493
|
"aria-live": "polite",
|
|
441
494
|
children: [
|
|
442
|
-
/* @__PURE__ */
|
|
495
|
+
/* @__PURE__ */ L("div", {
|
|
443
496
|
className: "flex items-center gap-2",
|
|
444
|
-
children: [/* @__PURE__ */
|
|
497
|
+
children: [/* @__PURE__ */ I(D, { children: i("bigconsole.widget.query.preview", "Preview") }), n.loading && /* @__PURE__ */ I(N, { style: {
|
|
445
498
|
width: "14px",
|
|
446
499
|
height: "14px"
|
|
447
500
|
} })]
|
|
448
501
|
}),
|
|
449
|
-
n.error && /* @__PURE__ */
|
|
502
|
+
n.error && /* @__PURE__ */ I("p", {
|
|
450
503
|
role: "alert",
|
|
451
504
|
className: "break-words text-xs text-[var(--color-status-error-text)]",
|
|
452
505
|
"data-testid": "query-preview-error",
|
|
453
506
|
children: n.error
|
|
454
507
|
}),
|
|
455
|
-
!n.error && n.rows && n.rows.length === 0 && /* @__PURE__ */
|
|
508
|
+
!n.error && n.rows && n.rows.length === 0 && /* @__PURE__ */ I("p", {
|
|
456
509
|
className: "text-xs text-text-secondary",
|
|
457
510
|
children: i("bigconsole.widget.query.previewEmpty", "No rows to show.")
|
|
458
511
|
}),
|
|
459
|
-
n.rows && n.rows.length > 0 && /* @__PURE__ */
|
|
460
|
-
t && /* @__PURE__ */
|
|
512
|
+
n.rows && n.rows.length > 0 && /* @__PURE__ */ L(F, { children: [
|
|
513
|
+
t && /* @__PURE__ */ I("div", {
|
|
461
514
|
className: "h-56 min-w-0 rounded-input border border-[var(--color-border-subtle)] p-2",
|
|
462
515
|
"data-testid": "query-preview-chart",
|
|
463
|
-
children: /* @__PURE__ */
|
|
516
|
+
children: /* @__PURE__ */ I(g, {
|
|
464
517
|
fallback: null,
|
|
465
|
-
children: /* @__PURE__ */
|
|
518
|
+
children: /* @__PURE__ */ I(K, {
|
|
466
519
|
widget: e,
|
|
467
|
-
data:
|
|
520
|
+
data: q(n.rows)
|
|
468
521
|
})
|
|
469
522
|
})
|
|
470
523
|
}),
|
|
471
|
-
/* @__PURE__ */
|
|
524
|
+
/* @__PURE__ */ I("div", {
|
|
472
525
|
className: "max-h-48 min-w-0 overflow-auto rounded-input border border-[var(--color-border-subtle)]",
|
|
473
|
-
children: /* @__PURE__ */
|
|
526
|
+
children: /* @__PURE__ */ L("table", {
|
|
474
527
|
className: "w-full text-xs",
|
|
475
|
-
children: [/* @__PURE__ */
|
|
528
|
+
children: [/* @__PURE__ */ I("thead", {
|
|
476
529
|
className: "bg-bg-surface text-left text-text-secondary",
|
|
477
|
-
children: /* @__PURE__ */
|
|
530
|
+
children: /* @__PURE__ */ I("tr", { children: a.map((e) => /* @__PURE__ */ I("th", {
|
|
478
531
|
className: "px-2 py-1 font-medium",
|
|
479
532
|
children: e
|
|
480
533
|
}, e)) })
|
|
481
|
-
}), /* @__PURE__ */
|
|
534
|
+
}), /* @__PURE__ */ I("tbody", { children: n.rows.slice(0, z).map((e, t) => /* @__PURE__ */ I("tr", {
|
|
482
535
|
className: "border-t border-[var(--color-border-subtle)]",
|
|
483
|
-
children: a.map((t) => /* @__PURE__ */
|
|
536
|
+
children: a.map((t) => /* @__PURE__ */ I("td", {
|
|
484
537
|
className: "px-2 py-1",
|
|
485
538
|
children: String(e[t] ?? "")
|
|
486
539
|
}, t))
|
|
487
540
|
}, t)) })]
|
|
488
541
|
})
|
|
489
542
|
}),
|
|
490
|
-
n.rows.length >
|
|
543
|
+
n.rows.length > z && /* @__PURE__ */ I("p", {
|
|
491
544
|
className: "text-xs text-text-secondary",
|
|
492
545
|
children: i("bigconsole.widget.query.previewMore", "Showing the first {{n}} of {{total}} rows.", {
|
|
493
|
-
n:
|
|
546
|
+
n: z,
|
|
494
547
|
total: n.rows.length
|
|
495
548
|
})
|
|
496
549
|
})
|
|
@@ -498,4 +551,4 @@ var q = ({ field: e }) => {
|
|
|
498
551
|
]
|
|
499
552
|
});
|
|
500
553
|
};
|
|
501
|
-
export {
|
|
554
|
+
export { Z as QuerySection };
|
|
@@ -9,6 +9,12 @@
|
|
|
9
9
|
*/
|
|
10
10
|
export declare const QUERY_AGGREGATES: readonly ["sum", "avg", "min", "max", "count", "distinct_count"];
|
|
11
11
|
export type QueryAggregate = (typeof QUERY_AGGREGATES)[number];
|
|
12
|
+
export declare const QUERY_DATE_BUCKETS: readonly ["day", "week", "month", "quarter", "year"];
|
|
13
|
+
export type QueryDateBucketUnit = (typeof QUERY_DATE_BUCKETS)[number];
|
|
14
|
+
export interface QueryDateBucket {
|
|
15
|
+
field: string;
|
|
16
|
+
unit: QueryDateBucketUnit;
|
|
17
|
+
}
|
|
12
18
|
/** Limits the service enforces; the pickers stop at the same numbers so a saved query always runs. */
|
|
13
19
|
export declare const QUERY_LIMITS: {
|
|
14
20
|
readonly dimensions: 2;
|
|
@@ -29,6 +35,7 @@ export interface QueryOrder {
|
|
|
29
35
|
}
|
|
30
36
|
export interface WidgetQuery {
|
|
31
37
|
dimensions: string[];
|
|
38
|
+
dateBuckets?: QueryDateBucket[];
|
|
32
39
|
measures: QueryMeasure[];
|
|
33
40
|
series?: string;
|
|
34
41
|
filters: Array<{
|
|
@@ -80,6 +87,8 @@ export declare function queryRendererProblem(query: WidgetQuery, widgetType: str
|
|
|
80
87
|
export declare function describeQuery(query: WidgetQuery): string;
|
|
81
88
|
/** Drop empty parts so a saved query stays small and a cleared form saves no query at all. */
|
|
82
89
|
export declare function normalizeQuery(query: WidgetQuery): WidgetQuery | null;
|
|
90
|
+
/** A parser's year-month value has insufficient precision for daily or weekly buckets. */
|
|
91
|
+
export declare function dateBucketUnits(rows: readonly Record<string, unknown>[] | null, field: string): readonly QueryDateBucketUnit[];
|
|
83
92
|
export declare function supportsQuery(widgetType: string | undefined, config?: Record<string, unknown>): boolean;
|
|
84
93
|
export declare function supportsQuerySeries(widgetType: string | undefined, config: Record<string, unknown> | undefined): boolean;
|
|
85
94
|
/**
|
|
@@ -6,62 +6,78 @@ var e = [
|
|
|
6
6
|
"max",
|
|
7
7
|
"count",
|
|
8
8
|
"distinct_count"
|
|
9
|
-
], t =
|
|
9
|
+
], t = [
|
|
10
|
+
"day",
|
|
11
|
+
"week",
|
|
12
|
+
"month",
|
|
13
|
+
"quarter",
|
|
14
|
+
"year"
|
|
15
|
+
], n = {
|
|
10
16
|
dimensions: 2,
|
|
11
17
|
measures: 6,
|
|
12
18
|
series: 12,
|
|
13
19
|
rows: 1e3
|
|
14
|
-
},
|
|
15
|
-
function a(e) {
|
|
16
|
-
return e == null || e === "" ? null : typeof e == "boolean" ? "boolean" : typeof e == "number" ? Number.isFinite(e) ? "number" : null : typeof e == "string" ? i.test(e) ? "date" : e.trim() !== "" && Number.isFinite(Number(e)) ? "number" : "text" : "text";
|
|
17
|
-
}
|
|
20
|
+
}, r = 200, i = (e) => typeof e == "object" && !!e && !Array.isArray(e), a = /^\d{4}-\d{2}(-\d{2}([T ]\d{2}:\d{2}(:\d{2}(\.\d+)?)?(Z|[+-]\d{2}:?\d{2})?)?)?$/;
|
|
18
21
|
function o(e) {
|
|
19
|
-
return
|
|
22
|
+
return e == null || e === "" ? null : typeof e == "boolean" ? "boolean" : typeof e == "number" ? Number.isFinite(e) ? "number" : null : typeof e == "string" ? a.test(e) ? "date" : e.trim() !== "" && Number.isFinite(Number(e)) ? "number" : "text" : "text";
|
|
20
23
|
}
|
|
21
24
|
function s(e) {
|
|
25
|
+
return !Array.isArray(e) || e.length === 0 ? null : e.every(i) ? e : null;
|
|
26
|
+
}
|
|
27
|
+
function c(e) {
|
|
22
28
|
let t = /* @__PURE__ */ new Map();
|
|
23
|
-
for (let
|
|
24
|
-
let
|
|
25
|
-
i == null ? t.set(e,
|
|
29
|
+
for (let n of e.slice(0, r)) for (let [e, r] of Object.entries(n)) {
|
|
30
|
+
let n = o(r), i = t.get(e);
|
|
31
|
+
i == null ? t.set(e, n) : n !== null && i !== n && t.set(e, "mixed");
|
|
26
32
|
}
|
|
27
33
|
return [...t].map(([e, t]) => ({
|
|
28
34
|
name: e,
|
|
29
35
|
kind: t === null || t === "mixed" ? "text" : t
|
|
30
36
|
}));
|
|
31
37
|
}
|
|
32
|
-
var
|
|
33
|
-
function
|
|
34
|
-
return e.filter(
|
|
38
|
+
var l = (e) => e.kind === "number";
|
|
39
|
+
function u(e) {
|
|
40
|
+
return e.filter(l);
|
|
35
41
|
}
|
|
36
|
-
var
|
|
42
|
+
var d = /* @__PURE__ */ new Set([
|
|
37
43
|
"sum",
|
|
38
44
|
"avg",
|
|
39
45
|
"min",
|
|
40
46
|
"max"
|
|
41
|
-
]),
|
|
47
|
+
]), f = {
|
|
42
48
|
sum: "added up",
|
|
43
49
|
avg: "averaged",
|
|
44
50
|
min: "used for the smallest value",
|
|
45
51
|
max: "used for the largest value"
|
|
46
52
|
};
|
|
47
|
-
function
|
|
48
|
-
let
|
|
49
|
-
if (!r
|
|
50
|
-
let
|
|
53
|
+
function p(n) {
|
|
54
|
+
let r = n?.query;
|
|
55
|
+
if (!i(r) || !Array.isArray(r.measures)) return null;
|
|
56
|
+
let a = r.measures.filter(i).flatMap((t) => {
|
|
51
57
|
if (typeof t.agg != "string" || !e.includes(t.agg)) return [];
|
|
52
58
|
let n = { agg: t.agg };
|
|
53
59
|
return typeof t.field == "string" && (n.field = t.field), typeof t.as == "string" && (n.as = t.as), [n];
|
|
54
60
|
});
|
|
55
|
-
if (
|
|
56
|
-
let
|
|
57
|
-
dimensions: Array.isArray(
|
|
58
|
-
measures:
|
|
59
|
-
filters: Array.isArray(
|
|
61
|
+
if (a.length === 0) return null;
|
|
62
|
+
let o = {
|
|
63
|
+
dimensions: Array.isArray(r.dimensions) ? r.dimensions.filter((e) => typeof e == "string") : [],
|
|
64
|
+
measures: a,
|
|
65
|
+
filters: Array.isArray(r.filters) ? r.filters.filter(i) : []
|
|
60
66
|
};
|
|
61
|
-
|
|
67
|
+
if (typeof r.series == "string" && r.series !== "" && (o.series = r.series), Array.isArray(r.dateBuckets)) {
|
|
68
|
+
let e = r.dateBuckets.filter(i).flatMap((e) => {
|
|
69
|
+
let n = t.find((t) => t === e.unit);
|
|
70
|
+
return typeof e.field == "string" && n ? [{
|
|
71
|
+
field: e.field,
|
|
72
|
+
unit: n
|
|
73
|
+
}] : [];
|
|
74
|
+
});
|
|
75
|
+
e.length > 0 && (o.dateBuckets = e);
|
|
76
|
+
}
|
|
77
|
+
return i(r.orderBy) && (o.orderBy = r.orderBy), typeof r.limit == "number" && (o.limit = r.limit), o;
|
|
62
78
|
}
|
|
63
|
-
function
|
|
64
|
-
let a =
|
|
79
|
+
function m(e, t, r = !0, i = !0) {
|
|
80
|
+
let a = u(e)[0];
|
|
65
81
|
if (!a) return null;
|
|
66
82
|
let o = i ? e.find((e) => e.kind === "date") ?? e.find((e) => e.kind === "text") : void 0;
|
|
67
83
|
if (!o) return {
|
|
@@ -79,18 +95,18 @@ function p(e, n, r = !0, i = !0) {
|
|
|
79
95
|
field: a.name
|
|
80
96
|
}],
|
|
81
97
|
filters: []
|
|
82
|
-
}, c = e.find((e) => e.kind === "text" && e.name !== o.name &&
|
|
98
|
+
}, c = e.find((e) => e.kind === "text" && e.name !== o.name && h(t, e.name) >= 2 && h(t, e.name) <= n.series);
|
|
83
99
|
return r && c && o.kind === "date" && (s.series = c.name), s;
|
|
84
100
|
}
|
|
85
|
-
function
|
|
86
|
-
let
|
|
87
|
-
for (let i of e.slice(0,
|
|
101
|
+
function h(e, t) {
|
|
102
|
+
let n = /* @__PURE__ */ new Set();
|
|
103
|
+
for (let i of e.slice(0, r)) {
|
|
88
104
|
let e = i[t];
|
|
89
|
-
e != null &&
|
|
105
|
+
e != null && n.add(String(e));
|
|
90
106
|
}
|
|
91
|
-
return
|
|
107
|
+
return n.size;
|
|
92
108
|
}
|
|
93
|
-
function
|
|
109
|
+
function g(e, t) {
|
|
94
110
|
if (!t || e.length < 2) return null;
|
|
95
111
|
let n = /* @__PURE__ */ new Map();
|
|
96
112
|
for (let r of e) {
|
|
@@ -104,7 +120,7 @@ function h(e, t) {
|
|
|
104
120
|
let [i] = r[0];
|
|
105
121
|
return `"${t}" repeats (for example "${i}" appears more than once), so the chart draws several points with the same label. Group by "${t}" and split by another field to show one point per value.`;
|
|
106
122
|
}
|
|
107
|
-
function
|
|
123
|
+
function _(e, t, n = !0, r = !0) {
|
|
108
124
|
if (!r) return "This chart type needs individual rows. Stop grouping or choose a different chart type.";
|
|
109
125
|
let i = new Set(t.map((e) => e.name));
|
|
110
126
|
if (e.measures.length === 0) return "Pick at least one value to calculate.";
|
|
@@ -112,38 +128,40 @@ function g(e, t, n = !0, r = !0) {
|
|
|
112
128
|
if (n.agg !== "count" && !n.field) return "Pick a field for each calculation.";
|
|
113
129
|
if (n.field && i.size > 0 && !i.has(n.field)) return `"${n.field}" is not in the data any more. Pick another field.`;
|
|
114
130
|
let e = t.find((e) => e.name === n.field);
|
|
115
|
-
if (e &&
|
|
131
|
+
if (e && d.has(n.agg) && e.kind !== "number") return `"${e.name}" holds ${e.kind === "date" ? "dates" : "text"}, so it cannot be ${f[n.agg] ?? "calculated"}. Use count or distinct count, or pick a number field.`;
|
|
116
132
|
}
|
|
117
133
|
for (let t of e.dimensions) if (i.size > 0 && !i.has(t)) return `"${t}" is not in the data any more. Pick another field.`;
|
|
118
134
|
if (new Set(e.dimensions).size !== e.dimensions.length) return "Choose a different field for each group.";
|
|
119
135
|
if (e.series && !n) return "Remove the series split to use this widget type.";
|
|
136
|
+
let a = (e.dateBuckets ?? []).map(({ field: e }) => e);
|
|
137
|
+
if (a.some((t) => !e.dimensions.includes(t)) || new Set(a).size !== a.length) return "Choose one date bucket for each group-by field.";
|
|
120
138
|
if (e.series && e.measures.length !== 1) return "Splitting into lines needs exactly one value.";
|
|
121
139
|
if (e.series && e.dimensions.includes(e.series)) return "Choose a different field to split into lines.";
|
|
122
|
-
let
|
|
123
|
-
return new Set(
|
|
140
|
+
let o = [...e.dimensions, ...k(e)];
|
|
141
|
+
return new Set(o).size === o.length ? null : "Choose distinct output fields and calculations.";
|
|
124
142
|
}
|
|
125
|
-
function
|
|
143
|
+
function v(e, t) {
|
|
126
144
|
return e === "metric_card" ? {
|
|
127
145
|
dimensions: 0,
|
|
128
146
|
measures: 1
|
|
129
147
|
} : e === "chart" ? {
|
|
130
148
|
dimensions: 1,
|
|
131
|
-
measures:
|
|
132
|
-
} :
|
|
149
|
+
measures: E(t) === "pie" ? 1 : n.measures
|
|
150
|
+
} : n;
|
|
133
151
|
}
|
|
134
|
-
function
|
|
135
|
-
let { dimensions: r, measures: i } =
|
|
152
|
+
function y(e, t, n) {
|
|
153
|
+
let { dimensions: r, measures: i } = v(t, n);
|
|
136
154
|
if (t === "metric_card") {
|
|
137
155
|
if (e.dimensions.length > r || e.series) return "Remove grouping and series to calculate one metric.";
|
|
138
156
|
if (e.measures.length !== i) return "Choose one value to calculate for this metric.";
|
|
139
157
|
}
|
|
140
158
|
if (t === "chart") {
|
|
141
|
-
if (
|
|
159
|
+
if (E(n) === "pie" && (e.dimensions.length !== r || e.measures.length !== i)) return "Choose one group and one value for a pie chart.";
|
|
142
160
|
if (e.dimensions.length > r) return "Choose one group for this chart’s x-axis.";
|
|
143
161
|
}
|
|
144
162
|
return null;
|
|
145
163
|
}
|
|
146
|
-
function
|
|
164
|
+
function b(e) {
|
|
147
165
|
let t = {
|
|
148
166
|
sum: "Total of",
|
|
149
167
|
avg: "Average of",
|
|
@@ -154,7 +172,7 @@ function y(e) {
|
|
|
154
172
|
}, n = [e.measures.map((e) => e.agg === "count" && !e.field ? "Number of rows" : `${t[e.agg]} ${e.field ?? ""}`.trim()).join(", ")];
|
|
155
173
|
return e.dimensions.length > 0 && n.push(`by ${e.dimensions.join(" and ")}`), e.series && n.push(`split by ${e.series}`), n.join(" ");
|
|
156
174
|
}
|
|
157
|
-
function
|
|
175
|
+
function x(e) {
|
|
158
176
|
if (e.measures.length === 0) return null;
|
|
159
177
|
let t = {
|
|
160
178
|
dimensions: e.dimensions.filter((e) => e !== ""),
|
|
@@ -164,44 +182,50 @@ function b(e) {
|
|
|
164
182
|
...e.as ? { as: e.as } : {}
|
|
165
183
|
})),
|
|
166
184
|
filters: e.filters
|
|
167
|
-
};
|
|
168
|
-
if (e.series && (t.series = e.series), e.orderBy) {
|
|
185
|
+
}, n = e.dateBuckets?.filter(({ field: e }) => t.dimensions.includes(e));
|
|
186
|
+
if (n?.length && (t.dateBuckets = n), e.series && (t.series = e.series), e.orderBy) {
|
|
169
187
|
let n = e.orderBy.by === "dimension" ? t.dimensions : t.measures;
|
|
170
188
|
e.orderBy.index >= 0 && e.orderBy.index < n.length && (t.orderBy = e.orderBy);
|
|
171
189
|
}
|
|
172
190
|
return e.limit !== void 0 && (t.limit = e.limit), t;
|
|
173
191
|
}
|
|
174
|
-
|
|
192
|
+
function S(e, n) {
|
|
193
|
+
return e?.some((e) => {
|
|
194
|
+
let t = e[n];
|
|
195
|
+
return typeof t == "string" && /^\d{4}-\d{2}$/.test(t);
|
|
196
|
+
}) ? t.filter((e) => e !== "day" && e !== "week") : t;
|
|
197
|
+
}
|
|
198
|
+
var C = /* @__PURE__ */ new Set([
|
|
175
199
|
"chart",
|
|
176
200
|
"table",
|
|
177
201
|
"metric_card"
|
|
178
|
-
]),
|
|
202
|
+
]), w = /* @__PURE__ */ new Set([
|
|
179
203
|
"line",
|
|
180
204
|
"bar",
|
|
181
205
|
"area",
|
|
182
206
|
"combo"
|
|
183
|
-
]),
|
|
184
|
-
function
|
|
207
|
+
]), T = /* @__PURE__ */ new Set([...w, "pie"]);
|
|
208
|
+
function E(e) {
|
|
185
209
|
return typeof e?.chartType == "string" ? e.chartType.toLowerCase() : "line";
|
|
186
210
|
}
|
|
187
|
-
function
|
|
188
|
-
return e === "chart" ?
|
|
211
|
+
function D(e, t) {
|
|
212
|
+
return e === "chart" ? T.has(E(t)) : e !== void 0 && C.has(e);
|
|
189
213
|
}
|
|
190
|
-
function
|
|
191
|
-
return e === "chart" &&
|
|
214
|
+
function O(e, t) {
|
|
215
|
+
return e === "chart" && w.has(E(t));
|
|
192
216
|
}
|
|
193
|
-
function
|
|
217
|
+
function k(e) {
|
|
194
218
|
let t = new Set(e.dimensions);
|
|
195
219
|
return e.measures.map((e) => {
|
|
196
220
|
let n = e.as ?? e.field ?? "count", r = t.has(n) ? `${e.agg}_${n}` : n;
|
|
197
221
|
return t.add(r), r;
|
|
198
222
|
});
|
|
199
223
|
}
|
|
200
|
-
function
|
|
201
|
-
return e.series ? Object.keys(t ?? {}).filter((t) => !e.dimensions.includes(t)) :
|
|
224
|
+
function A(e, t) {
|
|
225
|
+
return e.series ? Object.keys(t ?? {}).filter((t) => !e.dimensions.includes(t)) : k(e);
|
|
202
226
|
}
|
|
203
|
-
function
|
|
204
|
-
let [n] = t.dimensions, r =
|
|
227
|
+
function j(e, t) {
|
|
228
|
+
let [n] = t.dimensions, r = k(t), [i] = r;
|
|
205
229
|
return e === "chart" ? {
|
|
206
230
|
xAxisField: n,
|
|
207
231
|
labelField: n,
|
|
@@ -211,7 +235,7 @@ function k(e, t) {
|
|
|
211
235
|
series: void 0
|
|
212
236
|
} : e === "metric_card" ? { valueField: i } : e === "table" ? { columns: void 0 } : {};
|
|
213
237
|
}
|
|
214
|
-
var
|
|
238
|
+
var M = /* @__PURE__ */ new Map([
|
|
215
239
|
["chart", [
|
|
216
240
|
"xAxisField",
|
|
217
241
|
"labelField",
|
|
@@ -223,19 +247,19 @@ var A = /* @__PURE__ */ new Map([
|
|
|
223
247
|
["metric_card", ["valueField"]],
|
|
224
248
|
["table", ["columns"]]
|
|
225
249
|
]);
|
|
226
|
-
function
|
|
227
|
-
let
|
|
250
|
+
function N(e, t, n) {
|
|
251
|
+
let r = { ...e }, a = M.get(t ?? "") ?? [];
|
|
228
252
|
if (n === null) {
|
|
229
|
-
delete
|
|
253
|
+
delete r.query, delete r.querySourceMappings;
|
|
230
254
|
let t = e.querySourceMappings;
|
|
231
|
-
if (
|
|
232
|
-
return
|
|
255
|
+
if (i(t)) for (let e of a) Object.hasOwn(t, e) ? r[e] = t[e] : delete r[e];
|
|
256
|
+
return r;
|
|
233
257
|
}
|
|
234
|
-
!
|
|
235
|
-
for (let [e,
|
|
236
|
-
return
|
|
258
|
+
!p(e) && a.length > 0 && (r.querySourceMappings = Object.fromEntries(a.filter((t) => Object.hasOwn(e, t)).map((t) => [t, e[t]]))), r.query = n;
|
|
259
|
+
for (let [e, i] of Object.entries(j(t, n))) i === void 0 ? delete r[e] : r[e] = i;
|
|
260
|
+
return r;
|
|
237
261
|
}
|
|
238
|
-
function
|
|
262
|
+
function P(e, t) {
|
|
239
263
|
return Object.fromEntries(Object.entries(e).filter(([e]) => e !== t));
|
|
240
264
|
}
|
|
241
|
-
export {
|
|
265
|
+
export { d as NUMERIC_ONLY, e as QUERY_AGGREGATES, t as QUERY_DATE_BUCKETS, n as QUERY_LIMITS, N as applyQueryToConfig, A as chartQueryColumns, S as dateBucketUnits, b as describeQuery, c as detectFields, j as mappingPatch, k as measureNames, x as normalizeQuery, u as numericFields, P as omitKey, s as previewRows, v as queryInputLimits, _ as queryProblem, y as queryRendererProblem, p as readQuery, g as repeatedXWarning, m as suggestQuery, D as supportsQuery, O as supportsQuerySeries };
|