@burdenoff/microfe-bigconsole 2026.1124.6 → 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.
- package/dist/bigconsole/components/builder/inspector/QuerySection.d.ts +15 -0
- package/dist/bigconsole/components/builder/inspector/QuerySection.js +554 -0
- package/dist/bigconsole/components/builder/inspector/index.d.ts +1 -0
- package/dist/bigconsole/components/builder/inspector/index.js +1 -0
- package/dist/bigconsole/components/widgets/PropertiesPanel.js +800 -779
- package/dist/bigconsole/components/widgets/chart/ChartWidget.js +140 -130
- package/dist/bigconsole/components/widgets/chart/charts/numericSeries.js +4 -4
- package/dist/bigconsole/components/widgets/chart/charts/referenceElements.js +1 -1
- package/dist/bigconsole/components/widgets/chart/charts/types.d.ts +1 -1
- package/dist/bigconsole/hooks/useWidgetQueryPreview.d.ts +11 -0
- package/dist/bigconsole/hooks/useWidgetQueryPreview.js +42 -0
- package/dist/bigconsole/utils/widgetQuery.d.ts +111 -0
- package/dist/bigconsole/utils/widgetQuery.js +265 -0
- package/dist/generated/wspace-operations.d.ts +14 -0
- package/dist/generated/wspace-operations.js +130 -11
- package/dist/generated/wspace-types.d.ts +8 -1
- package/package.json +1 -1
|
@@ -13,11 +13,12 @@ import { ChartLegend as p } from "./ChartLegend.js";
|
|
|
13
13
|
import "../../../contexts/index.js";
|
|
14
14
|
import { WidgetEmptyState as m } from "../states/EmptyState.js";
|
|
15
15
|
import { aggregatePieRows as h, classifyChartData as g } from "./chartRows.js";
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
16
|
+
import { chartQueryColumns as _, readQuery as v } from "../../../utils/widgetQuery.js";
|
|
17
|
+
import { memo as y, useCallback as b, useMemo as x, useState as S } from "react";
|
|
18
|
+
import { useI18n as C } from "@burdenoff/fe-libs/shared/providers/shell/I18nProvider";
|
|
19
|
+
import { jsx as w, jsxs as T } from "react/jsx-runtime";
|
|
19
20
|
// src/bigconsole/components/widgets/chart/ChartWidget.tsx
|
|
20
|
-
var
|
|
21
|
+
var E = [], D = {
|
|
21
22
|
number: {
|
|
22
23
|
key: "bigconsole.widget.chart.unsupported.number",
|
|
23
24
|
fallback: "This data is a single value."
|
|
@@ -34,168 +35,177 @@ var w = [], T = {
|
|
|
34
35
|
key: "bigconsole.widget.chart.unsupported.values",
|
|
35
36
|
fallback: "This data is a list of values without field names."
|
|
36
37
|
}
|
|
37
|
-
},
|
|
38
|
+
}, O = [
|
|
38
39
|
"var(--color-chart-1)",
|
|
39
40
|
"var(--color-chart-2)",
|
|
40
41
|
"var(--color-chart-3)",
|
|
41
42
|
"var(--color-chart-4)",
|
|
42
43
|
"var(--color-chart-5)"
|
|
43
|
-
],
|
|
44
|
-
let { t:
|
|
44
|
+
], k = y(function({ widget: y, data: k = [], onClick: A, onDrilldown: j }) {
|
|
45
|
+
let { t: M } = C(), N = y.config, [P, F] = S([]), I = x(() => g(k), [k]), L = I.kind === "rows" ? I.rows : E, R = x(() => v(y.config), [y.config]), z = x(() => R ? _(R, L[0]) : N?.selectedFields, [
|
|
45
46
|
R,
|
|
46
|
-
F,
|
|
47
47
|
L,
|
|
48
|
-
|
|
49
|
-
]),
|
|
50
|
-
|
|
48
|
+
N?.selectedFields
|
|
49
|
+
]), B = N?.valueField || "value", V = N?.labelField || "name", H = N?.chartType?.toLowerCase() === "pie", U = x(() => H ? h(L, V, B) : L, [
|
|
50
|
+
H,
|
|
51
|
+
L,
|
|
52
|
+
V,
|
|
53
|
+
B
|
|
54
|
+
]), { handleDataClick: W, enabled: G } = t(y.id, N?.crossFilterMappings || [{
|
|
55
|
+
sourceField: N?.labelField || "name",
|
|
51
56
|
targetFilterId: "category"
|
|
52
|
-
}]), { clearAllCrossFilters:
|
|
53
|
-
type:
|
|
54
|
-
xAxisKey:
|
|
55
|
-
xAxisLabel:
|
|
56
|
-
yAxisLabel:
|
|
57
|
-
showGrid:
|
|
58
|
-
showLegend:
|
|
59
|
-
legendPosition:
|
|
60
|
-
showDots:
|
|
61
|
-
curveType:
|
|
62
|
-
colors:
|
|
63
|
-
seriesNames:
|
|
64
|
-
stacked:
|
|
65
|
-
isDonut:
|
|
66
|
-
innerRadius:
|
|
67
|
-
outerRadius:
|
|
68
|
-
referenceLines:
|
|
69
|
-
conditionalRules:
|
|
70
|
-
series:
|
|
71
|
-
selectedFields:
|
|
72
|
-
dualAxis:
|
|
73
|
-
yAxisRightLabel:
|
|
74
|
-
logScale:
|
|
75
|
-
startAtZero:
|
|
76
|
-
yMin:
|
|
77
|
-
yMax:
|
|
78
|
-
valueField:
|
|
79
|
-
labelField:
|
|
80
|
-
showTotal:
|
|
81
|
-
totalLabel:
|
|
82
|
-
xField:
|
|
83
|
-
yField:
|
|
84
|
-
sizeField:
|
|
85
|
-
colorField:
|
|
86
|
-
}), [
|
|
57
|
+
}]), { clearAllCrossFilters: K, hasCrossFilters: q } = e(), J = x(() => ({
|
|
58
|
+
type: y.type === "funnel_chart" ? "funnel" : N?.chartType?.toLowerCase() || "line",
|
|
59
|
+
xAxisKey: N?.xAxisField || N?.labelField || "name",
|
|
60
|
+
xAxisLabel: N?.xAxisLabel,
|
|
61
|
+
yAxisLabel: N?.yAxisLabel,
|
|
62
|
+
showGrid: N?.showGrid,
|
|
63
|
+
showLegend: N?.showLegend,
|
|
64
|
+
legendPosition: N?.legendPosition,
|
|
65
|
+
showDots: N?.showDataPoints,
|
|
66
|
+
curveType: N?.curveType,
|
|
67
|
+
colors: N?.colors,
|
|
68
|
+
seriesNames: N?.seriesLabels,
|
|
69
|
+
stacked: N?.stacked,
|
|
70
|
+
isDonut: N?.showAsDonut,
|
|
71
|
+
innerRadius: N?.innerRadius,
|
|
72
|
+
outerRadius: N?.outerRadius,
|
|
73
|
+
referenceLines: N?.referenceLines,
|
|
74
|
+
conditionalRules: N?.conditionalRules,
|
|
75
|
+
series: R ? void 0 : N?.series,
|
|
76
|
+
selectedFields: z,
|
|
77
|
+
dualAxis: N?.dualAxis,
|
|
78
|
+
yAxisRightLabel: N?.yAxisRightLabel,
|
|
79
|
+
logScale: N?.logScale,
|
|
80
|
+
startAtZero: N?.startAtZero,
|
|
81
|
+
yMin: N?.yMin,
|
|
82
|
+
yMax: N?.yMax,
|
|
83
|
+
valueField: N?.valueField,
|
|
84
|
+
labelField: N?.labelField,
|
|
85
|
+
showTotal: N?.showTotal,
|
|
86
|
+
totalLabel: N?.totalLabel,
|
|
87
|
+
xField: N?.xField,
|
|
88
|
+
yField: N?.yField,
|
|
89
|
+
sizeField: N?.sizeField,
|
|
90
|
+
colorField: N?.colorField
|
|
91
|
+
}), [
|
|
92
|
+
N,
|
|
93
|
+
y.type,
|
|
94
|
+
R,
|
|
95
|
+
z
|
|
96
|
+
]), Y = J.type !== "funnel" && (J.type === "combo" || J.dualAxis === !0 || J.series?.some((e) => e.axis === "right" || e.type === "bar") && J.series?.some((e) => e.type === "line") || !1), X = x(() => !L.length || J.type === "pie" || J.type === "funnel" || J.type === "scatter" || J.type === "waterfall" ? [] : (Y && J.selectedFields !== void 0 ? n(L, J).map((e) => e.field) : r(L, J.xAxisKey, J.selectedFields)).map((e, t) => ({
|
|
87
97
|
dataKey: e,
|
|
88
|
-
name:
|
|
89
|
-
color:
|
|
90
|
-
hidden:
|
|
98
|
+
name: J.seriesNames?.[e] || e,
|
|
99
|
+
color: J.colors?.[t] || O[t % O.length],
|
|
100
|
+
hidden: P.includes(e)
|
|
91
101
|
})), [
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
]),
|
|
98
|
-
|
|
99
|
-
}, []),
|
|
100
|
-
if (
|
|
101
|
-
let t = e[
|
|
102
|
-
|
|
102
|
+
L,
|
|
103
|
+
J,
|
|
104
|
+
P,
|
|
105
|
+
N?.selectedFields,
|
|
106
|
+
Y
|
|
107
|
+
]), Z = b((e) => {
|
|
108
|
+
F((t) => t.includes(e) ? t.filter((t) => t !== e) : [...t, e]);
|
|
109
|
+
}, []), Q = b((e, t) => {
|
|
110
|
+
if (G) {
|
|
111
|
+
let t = e[N?.labelField || "name"];
|
|
112
|
+
W(e, t);
|
|
103
113
|
}
|
|
104
|
-
|
|
114
|
+
j ? j(e) : A && y.drilldowns?.length && A(e, t);
|
|
105
115
|
}, [
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
]),
|
|
113
|
-
if (
|
|
114
|
-
data:
|
|
115
|
-
config:
|
|
116
|
-
hiddenSeries:
|
|
117
|
-
onDataClick:
|
|
116
|
+
A,
|
|
117
|
+
j,
|
|
118
|
+
y.drilldowns,
|
|
119
|
+
G,
|
|
120
|
+
W,
|
|
121
|
+
N?.labelField
|
|
122
|
+
]), $ = () => {
|
|
123
|
+
if (Y) return /* @__PURE__ */ w(u, {
|
|
124
|
+
data: L,
|
|
125
|
+
config: J,
|
|
126
|
+
hiddenSeries: P,
|
|
127
|
+
onDataClick: Q
|
|
118
128
|
});
|
|
119
|
-
switch (
|
|
120
|
-
case "waterfall": return /* @__PURE__ */
|
|
121
|
-
data:
|
|
122
|
-
config:
|
|
123
|
-
onDataClick:
|
|
129
|
+
switch (J.type) {
|
|
130
|
+
case "waterfall": return /* @__PURE__ */ w(d, {
|
|
131
|
+
data: L,
|
|
132
|
+
config: J,
|
|
133
|
+
onDataClick: Q
|
|
124
134
|
});
|
|
125
|
-
case "scatter": return /* @__PURE__ */
|
|
126
|
-
data:
|
|
127
|
-
config:
|
|
128
|
-
onDataClick:
|
|
135
|
+
case "scatter": return /* @__PURE__ */ w(f, {
|
|
136
|
+
data: L,
|
|
137
|
+
config: J,
|
|
138
|
+
onDataClick: Q
|
|
129
139
|
});
|
|
130
|
-
case "bar": return /* @__PURE__ */
|
|
131
|
-
data:
|
|
132
|
-
config:
|
|
133
|
-
hiddenSeries:
|
|
134
|
-
onDataClick:
|
|
140
|
+
case "bar": return /* @__PURE__ */ w(a, {
|
|
141
|
+
data: L,
|
|
142
|
+
config: J,
|
|
143
|
+
hiddenSeries: P,
|
|
144
|
+
onDataClick: Q
|
|
135
145
|
});
|
|
136
|
-
case "area": return /* @__PURE__ */
|
|
137
|
-
data:
|
|
138
|
-
config:
|
|
139
|
-
hiddenSeries:
|
|
140
|
-
onDataClick:
|
|
146
|
+
case "area": return /* @__PURE__ */ w(o, {
|
|
147
|
+
data: L,
|
|
148
|
+
config: J,
|
|
149
|
+
hiddenSeries: P,
|
|
150
|
+
onDataClick: Q
|
|
141
151
|
});
|
|
142
|
-
case "pie": return /* @__PURE__ */
|
|
143
|
-
data:
|
|
144
|
-
config:
|
|
145
|
-
dataKey:
|
|
146
|
-
nameKey:
|
|
147
|
-
onDataClick:
|
|
152
|
+
case "pie": return /* @__PURE__ */ w(s, {
|
|
153
|
+
data: U,
|
|
154
|
+
config: J,
|
|
155
|
+
dataKey: B,
|
|
156
|
+
nameKey: V,
|
|
157
|
+
onDataClick: Q
|
|
148
158
|
});
|
|
149
159
|
case "funnel": {
|
|
150
|
-
let e = l(
|
|
151
|
-
valueField:
|
|
152
|
-
labelField:
|
|
160
|
+
let e = l(L, {
|
|
161
|
+
valueField: N?.valueField,
|
|
162
|
+
labelField: N?.labelField
|
|
153
163
|
});
|
|
154
|
-
return /* @__PURE__ */
|
|
155
|
-
data:
|
|
156
|
-
config:
|
|
164
|
+
return /* @__PURE__ */ w(c, {
|
|
165
|
+
data: L,
|
|
166
|
+
config: J,
|
|
157
167
|
dataKey: e.valueField,
|
|
158
168
|
nameKey: e.labelField,
|
|
159
|
-
onDataClick:
|
|
169
|
+
onDataClick: Q
|
|
160
170
|
});
|
|
161
171
|
}
|
|
162
|
-
default: return /* @__PURE__ */
|
|
163
|
-
data:
|
|
164
|
-
config:
|
|
165
|
-
hiddenSeries:
|
|
166
|
-
onDataClick:
|
|
172
|
+
default: return /* @__PURE__ */ w(i, {
|
|
173
|
+
data: L,
|
|
174
|
+
config: J,
|
|
175
|
+
hiddenSeries: P,
|
|
176
|
+
onDataClick: Q
|
|
167
177
|
});
|
|
168
178
|
}
|
|
169
179
|
};
|
|
170
|
-
if (
|
|
180
|
+
if (I.kind === "empty") return /* @__PURE__ */ w(m, {
|
|
171
181
|
widgetType: "chart",
|
|
172
182
|
hasDataSource: !0
|
|
173
183
|
});
|
|
174
|
-
if (
|
|
175
|
-
let e =
|
|
176
|
-
return /* @__PURE__ */
|
|
184
|
+
if (I.kind === "unsupported") {
|
|
185
|
+
let e = D[I.shape];
|
|
186
|
+
return /* @__PURE__ */ w(m, {
|
|
177
187
|
widgetType: "chart",
|
|
178
188
|
hasDataSource: !0,
|
|
179
|
-
message: `${
|
|
189
|
+
message: `${M(e.key, e.fallback)} ${M("bigconsole.widget.chart.unsupported.hint", "A chart needs a list of rows. Pick a parser that returns rows, or use a Metric Card for one number.")}`
|
|
180
190
|
});
|
|
181
191
|
}
|
|
182
|
-
return /* @__PURE__ */
|
|
192
|
+
return /* @__PURE__ */ T("div", {
|
|
183
193
|
className: "flex flex-col h-full p-4",
|
|
184
194
|
children: [
|
|
185
|
-
|
|
195
|
+
q && /* @__PURE__ */ w("div", {
|
|
186
196
|
className: "flex items-center gap-2 mb-2 -mt-1",
|
|
187
|
-
children: /* @__PURE__ */
|
|
197
|
+
children: /* @__PURE__ */ T("button", {
|
|
188
198
|
type: "button",
|
|
189
199
|
onClick: (e) => {
|
|
190
|
-
e.stopPropagation(),
|
|
200
|
+
e.stopPropagation(), K();
|
|
191
201
|
},
|
|
192
202
|
className: "\n inline-flex items-center gap-1.5\n px-2.5 py-1 rounded-md\n text-xs font-medium\n bg-action-primary-bg/10 text-action-primary-text\n hover:bg-action-primary-bg/20\n transition-colors\n ",
|
|
193
|
-
children: [/* @__PURE__ */
|
|
203
|
+
children: [/* @__PURE__ */ w("svg", {
|
|
194
204
|
className: "w-3.5 h-3.5",
|
|
195
205
|
fill: "none",
|
|
196
206
|
stroke: "currentColor",
|
|
197
207
|
viewBox: "0 0 24 24",
|
|
198
|
-
children: /* @__PURE__ */
|
|
208
|
+
children: /* @__PURE__ */ w("path", {
|
|
199
209
|
strokeLinecap: "round",
|
|
200
210
|
strokeLinejoin: "round",
|
|
201
211
|
strokeWidth: 2,
|
|
@@ -204,21 +214,21 @@ var w = [], T = {
|
|
|
204
214
|
}), "Clear Filter"]
|
|
205
215
|
})
|
|
206
216
|
}),
|
|
207
|
-
|
|
208
|
-
items:
|
|
217
|
+
J.legendPosition === "top" && X.length > 0 && /* @__PURE__ */ w(p, {
|
|
218
|
+
items: X,
|
|
209
219
|
position: "top",
|
|
210
|
-
onItemClick:
|
|
220
|
+
onItemClick: Z
|
|
211
221
|
}),
|
|
212
|
-
/* @__PURE__ */
|
|
222
|
+
/* @__PURE__ */ w("div", {
|
|
213
223
|
className: "flex-1 min-h-0",
|
|
214
|
-
children:
|
|
224
|
+
children: $()
|
|
215
225
|
}),
|
|
216
|
-
|
|
217
|
-
items:
|
|
226
|
+
J.legendPosition === "bottom" && X.length > 0 && /* @__PURE__ */ w(p, {
|
|
227
|
+
items: X,
|
|
218
228
|
position: "bottom",
|
|
219
|
-
onItemClick:
|
|
229
|
+
onItemClick: Z
|
|
220
230
|
})
|
|
221
231
|
]
|
|
222
232
|
});
|
|
223
233
|
});
|
|
224
|
-
export {
|
|
234
|
+
export { k as ChartWidget, k as default };
|
|
@@ -3,10 +3,10 @@ function e(e, t, n) {
|
|
|
3
3
|
let r = e[0];
|
|
4
4
|
if (!r) return [];
|
|
5
5
|
let i = n ?? Object.keys(r);
|
|
6
|
-
return [...new Set(i.filter((
|
|
7
|
-
if (typeof
|
|
8
|
-
let
|
|
9
|
-
return typeof n == "number" && Number.isFinite(n);
|
|
6
|
+
return [...new Set(i.filter((n) => {
|
|
7
|
+
if (typeof n != "string" || n === t) return !1;
|
|
8
|
+
let i = r[n];
|
|
9
|
+
return typeof i == "number" ? Number.isFinite(i) : i === null && e.some((e) => typeof e[n] == "number" && Number.isFinite(e[n]));
|
|
10
10
|
}))];
|
|
11
11
|
}
|
|
12
12
|
function t(t, n) {
|
|
@@ -8,7 +8,7 @@ function o(e, r, a, o, s) {
|
|
|
8
8
|
let u = [];
|
|
9
9
|
return s.data.forEach((s, d) => {
|
|
10
10
|
let f = s[l], p = t(s[c.field], e.value, c.mode);
|
|
11
|
-
f
|
|
11
|
+
f != null && p != null && u.push(/* @__PURE__ */ n(i, {
|
|
12
12
|
x: f,
|
|
13
13
|
y: p,
|
|
14
14
|
r: 5,
|
|
@@ -29,7 +29,7 @@ export interface SeriesConfig {
|
|
|
29
29
|
}
|
|
30
30
|
export type CurveType = 'monotone' | 'linear' | 'step' | 'stepAfter' | 'stepBefore' | 'natural';
|
|
31
31
|
export interface ChartData {
|
|
32
|
-
[key: string]: string | number | undefined;
|
|
32
|
+
[key: string]: string | number | null | undefined;
|
|
33
33
|
}
|
|
34
34
|
export interface ChartConfig {
|
|
35
35
|
/** Chart type */
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { WidgetQuery } from '../utils/widgetQuery';
|
|
2
|
+
export interface WidgetQueryPreview {
|
|
3
|
+
/** The rows the query produces, or null before the first answer and when it cannot run. */
|
|
4
|
+
rows: Record<string, unknown>[] | null;
|
|
5
|
+
loading: boolean;
|
|
6
|
+
/** Why the query cannot run, in words for the person editing, or null. */
|
|
7
|
+
error: string | null;
|
|
8
|
+
}
|
|
9
|
+
/** Wait this long after the last change before asking the service. */
|
|
10
|
+
export declare const PREVIEW_DELAY_MS = 400;
|
|
11
|
+
export declare function useWidgetQueryPreview(widgetId: string | null | undefined, query: WidgetQuery | null, enabled: boolean): WidgetQueryPreview;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { PreviewWidgetQueryDocument as e } from "../../generated/wspace-operations.js";
|
|
2
|
+
import { useEffect as t, useState as n } from "react";
|
|
3
|
+
import { useQuery as r } from "@apollo/client/react";
|
|
4
|
+
var i = (e) => typeof e == "object" && !!e && !Array.isArray(e);
|
|
5
|
+
function a(a, o, s) {
|
|
6
|
+
let c = o ? JSON.stringify(o) : null, [l, u] = n({
|
|
7
|
+
widgetId: a,
|
|
8
|
+
draft: c
|
|
9
|
+
});
|
|
10
|
+
t(() => {
|
|
11
|
+
let e = setTimeout(() => u({
|
|
12
|
+
widgetId: a,
|
|
13
|
+
draft: c
|
|
14
|
+
}), 400);
|
|
15
|
+
return () => clearTimeout(e);
|
|
16
|
+
}, [a, c]);
|
|
17
|
+
let d = s && !!a && c !== null, f = l.widgetId !== a || l.draft !== c, p = !d || f, { data: m, loading: h, error: g } = r(e, {
|
|
18
|
+
variables: {
|
|
19
|
+
id: a ?? "",
|
|
20
|
+
query: c === null ? {} : JSON.parse(c)
|
|
21
|
+
},
|
|
22
|
+
skip: p,
|
|
23
|
+
fetchPolicy: "network-only"
|
|
24
|
+
});
|
|
25
|
+
if (p || h) return {
|
|
26
|
+
rows: null,
|
|
27
|
+
loading: d && (f || h),
|
|
28
|
+
error: null
|
|
29
|
+
};
|
|
30
|
+
if (m?.getWidget && m.getWidget.id !== a) return {
|
|
31
|
+
rows: null,
|
|
32
|
+
loading: !1,
|
|
33
|
+
error: null
|
|
34
|
+
};
|
|
35
|
+
let _ = m?.getWidget?.data, v = _?.processed;
|
|
36
|
+
return {
|
|
37
|
+
rows: !_?.error && Array.isArray(v) && v.every(i) ? v : null,
|
|
38
|
+
loading: !1,
|
|
39
|
+
error: g ? g.message : _?.error ?? null
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
export { a as useWidgetQueryPreview };
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Group-by, aggregation and series for a widget (BOFF-13346) — the browser side.
|
|
3
|
+
*
|
|
4
|
+
* The service owns the calculation: a widget saves `config.query` and the service applies it to the rows the
|
|
5
|
+
* parser produced (see `wspace-bigconsole-svc/src/modules/widget/query`). This module holds only what the Data tab
|
|
6
|
+
* needs to build that query: the shape, the fields found in the parser's sample rows (with a type icon each),
|
|
7
|
+
* starting suggestions, and plain-language warnings. It never aggregates rows itself, so there is one
|
|
8
|
+
* implementation of the maths and past views, compare, exports and the preview all agree.
|
|
9
|
+
*/
|
|
10
|
+
export declare const QUERY_AGGREGATES: readonly ["sum", "avg", "min", "max", "count", "distinct_count"];
|
|
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
|
+
}
|
|
18
|
+
/** Limits the service enforces; the pickers stop at the same numbers so a saved query always runs. */
|
|
19
|
+
export declare const QUERY_LIMITS: {
|
|
20
|
+
readonly dimensions: 2;
|
|
21
|
+
readonly measures: 6;
|
|
22
|
+
readonly series: 12;
|
|
23
|
+
readonly rows: 1000;
|
|
24
|
+
};
|
|
25
|
+
export interface QueryMeasure {
|
|
26
|
+
agg: QueryAggregate;
|
|
27
|
+
/** Omitted only for `count`, which then counts rows. */
|
|
28
|
+
field?: string;
|
|
29
|
+
as?: string;
|
|
30
|
+
}
|
|
31
|
+
export interface QueryOrder {
|
|
32
|
+
by: 'measure' | 'dimension';
|
|
33
|
+
index: number;
|
|
34
|
+
direction: 'asc' | 'desc';
|
|
35
|
+
}
|
|
36
|
+
export interface WidgetQuery {
|
|
37
|
+
dimensions: string[];
|
|
38
|
+
dateBuckets?: QueryDateBucket[];
|
|
39
|
+
measures: QueryMeasure[];
|
|
40
|
+
series?: string;
|
|
41
|
+
filters: Array<{
|
|
42
|
+
field: string;
|
|
43
|
+
op: string;
|
|
44
|
+
value?: string | number | boolean;
|
|
45
|
+
}>;
|
|
46
|
+
orderBy?: QueryOrder;
|
|
47
|
+
limit?: number;
|
|
48
|
+
}
|
|
49
|
+
export type FieldKind = 'text' | 'number' | 'date' | 'boolean';
|
|
50
|
+
export interface DetectedField {
|
|
51
|
+
name: string;
|
|
52
|
+
kind: FieldKind;
|
|
53
|
+
}
|
|
54
|
+
/** The rows a parser preview holds, or null when it is not a list of rows. */
|
|
55
|
+
export declare function previewRows(preview: unknown): Record<string, unknown>[] | null;
|
|
56
|
+
/**
|
|
57
|
+
* The fields in a list of rows, in first-seen order, each with a kind. A field whose values disagree
|
|
58
|
+
* (numbers in some rows, words in others) is offered as text: counting still works on it, summing would not.
|
|
59
|
+
*/
|
|
60
|
+
export declare function detectFields(rows: readonly Record<string, unknown>[]): DetectedField[];
|
|
61
|
+
/** Fields a value can be summed, averaged, minimised or maximised on. */
|
|
62
|
+
export declare function numericFields(fields: readonly DetectedField[]): DetectedField[];
|
|
63
|
+
/** Calculations that need a number field; count and distinct count work on anything. */
|
|
64
|
+
export declare const NUMERIC_ONLY: ReadonlySet<QueryAggregate>;
|
|
65
|
+
/** Read a saved query from a widget's config, or null when it has none or it is not usable. */
|
|
66
|
+
export declare function readQuery(config: Record<string, unknown> | undefined | null): WidgetQuery | null;
|
|
67
|
+
/**
|
|
68
|
+
* A first query from the field types, so a new binding starts from something that draws: the first date or
|
|
69
|
+
* text field to group by, the first number field summed, and for a chart a second low-cardinality text field
|
|
70
|
+
* as the series. Returns null when the fields offer nothing to group or total.
|
|
71
|
+
*/
|
|
72
|
+
export declare function suggestQuery(fields: readonly DetectedField[], rows: readonly Record<string, unknown>[], allowSeries?: boolean, allowDimensions?: boolean): WidgetQuery | null;
|
|
73
|
+
/**
|
|
74
|
+
* A warning for a chart whose x field repeats, with no grouping to merge the repeats (the ticket's
|
|
75
|
+
* "two points both labelled 2026-08"). Null when the field is unique or the data is a query result.
|
|
76
|
+
*/
|
|
77
|
+
export declare function repeatedXWarning(rows: readonly Record<string, unknown>[], xField: string | undefined): string | null;
|
|
78
|
+
/** Why a draft query cannot be saved yet, in words for the person editing, or null when it is ready. */
|
|
79
|
+
export declare function queryProblem(query: WidgetQuery, fields: readonly DetectedField[], allowSeries?: boolean, allowGrouping?: boolean): string | null;
|
|
80
|
+
/** The editor offers only the groups and values each renderer can present. */
|
|
81
|
+
export declare function queryInputLimits(widgetType: string | undefined, config: Record<string, unknown> | undefined): {
|
|
82
|
+
dimensions: number;
|
|
83
|
+
measures: number;
|
|
84
|
+
};
|
|
85
|
+
export declare function queryRendererProblem(query: WidgetQuery, widgetType: string | undefined, config: Record<string, unknown> | undefined): string | null;
|
|
86
|
+
/** One line saying what the query does, for the collapsed state and the preview caption. */
|
|
87
|
+
export declare function describeQuery(query: WidgetQuery): string;
|
|
88
|
+
/** Drop empty parts so a saved query stays small and a cleared form saves no query at all. */
|
|
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[];
|
|
92
|
+
export declare function supportsQuery(widgetType: string | undefined, config?: Record<string, unknown>): boolean;
|
|
93
|
+
export declare function supportsQuerySeries(widgetType: string | undefined, config: Record<string, unknown> | undefined): boolean;
|
|
94
|
+
/**
|
|
95
|
+
* The output column of each value, named as the service names them: `as`, else the field, else "count"; a name
|
|
96
|
+
* already taken gets the calculation in front ("max_revenue"). Kept identical to the service so the mappings
|
|
97
|
+
* the Data tab writes point at columns that exist.
|
|
98
|
+
*/
|
|
99
|
+
export declare function measureNames(query: WidgetQuery): string[];
|
|
100
|
+
/** Every grouped output row contains the full set of series columns, including gaps. */
|
|
101
|
+
export declare function chartQueryColumns(query: WidgetQuery, firstRow: Record<string, unknown> | undefined): string[];
|
|
102
|
+
/**
|
|
103
|
+
* The field mappings a query's output needs, so a widget reads the columns the service now returns instead of
|
|
104
|
+
* the ones the parser used to. `undefined` removes a key. A split by series makes one column per value, so the
|
|
105
|
+
* saved series selection is dropped and the chart draws every numeric column.
|
|
106
|
+
*/
|
|
107
|
+
export declare function mappingPatch(widgetType: string | undefined, query: WidgetQuery): Record<string, string | string[] | undefined>;
|
|
108
|
+
/** Keep a snapshot of the raw parser mappings while the widget renders the query's output columns. */
|
|
109
|
+
export declare function applyQueryToConfig(config: Record<string, unknown>, widgetType: string | undefined, query: WidgetQuery | null): Record<string, unknown>;
|
|
110
|
+
/** A copy of an object without one key (the optional parts of a query are absent, never undefined). */
|
|
111
|
+
export declare function omitKey<T extends object, K extends keyof T>(value: T, key: K): Omit<T, K>;
|