@burdenoff/microfe-bigconsole 2026.1121.1 → 2026.1121.3

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.
@@ -3,70 +3,72 @@ import { useBigConsole as t } from "../../context/BigConsoleContext.js";
3
3
  import "../../context/index.js";
4
4
  import { CreateQueryWidget as n } from "../explore/CreateQueryWidget.js";
5
5
  import { reportBigConsoleQuotaError as r } from "../../utils/quota.js";
6
- import { exploreError as i, workspaceRequest as a } from "../explore/useExploreRun.js";
7
- import { STATUS_HEADING as o, barWidths as s, defaultWidgetTitle as c, toRows as l } from "./askAnswer.js";
8
- import { useCallback as u, useEffect as d, useRef as f, useState as p } from "react";
9
- import { useApolloClient as m } from "@apollo/client/react";
10
- import { jsx as h, jsxs as g } from "react/jsx-runtime";
6
+ import { workspaceRequest as i } from "../explore/useExploreRun.js";
7
+ import { exploreErrorMessage as a, withoutError as o } from "../explore/exploreErrors.js";
8
+ import { useOptionalTr as s } from "../../../shared/hooks/useTr.js";
9
+ import { STATUS_HEADING as c, barWidths as l, defaultWidgetTitle as u, toRows as d } from "./askAnswer.js";
10
+ import { useCallback as f, useEffect as p, useRef as m, useState as h } from "react";
11
+ import { useApolloClient as g } from "@apollo/client/react";
12
+ import { jsx as _, jsxs as v } from "react/jsx-runtime";
11
13
  // src/bigconsole/components/ask/AskYourData.tsx
12
- var _ = 500;
13
- function v({ answer: e, workspaceId: t }) {
14
- let r = l(e.rows, e.columns.length), [i, a] = p(!1), o = e.chart, u = o ? e.columns.indexOf(o.categoryColumn) : -1, d = o ? e.columns.indexOf(o.valueColumn) : -1, f = o && d >= 0 ? s(r.map((e) => e[d] ?? null)) : [], m = e.provenance;
15
- return /* @__PURE__ */ g("div", {
14
+ var y = 500;
15
+ function b({ answer: e, workspaceId: t }) {
16
+ let r = d(e.rows, e.columns.length), [i, a] = h(!1), o = e.chart, s = o ? e.columns.indexOf(o.categoryColumn) : -1, c = o ? e.columns.indexOf(o.valueColumn) : -1, f = o && c >= 0 ? l(r.map((e) => e[c] ?? null)) : [], p = e.provenance;
17
+ return /* @__PURE__ */ v("div", {
16
18
  className: "space-y-3",
17
19
  children: [
18
- /* @__PURE__ */ h("p", {
20
+ /* @__PURE__ */ _("p", {
19
21
  className: "text-base font-medium text-text-primary",
20
22
  children: e.headline
21
23
  }),
22
- o && u >= 0 && d >= 0 && /* @__PURE__ */ h("ul", {
24
+ o && s >= 0 && c >= 0 && /* @__PURE__ */ _("ul", {
23
25
  "aria-label": `${o.valueColumn} by ${o.categoryColumn}`,
24
26
  className: "space-y-1",
25
- children: r.map((e, t) => /* @__PURE__ */ g("li", {
27
+ children: r.map((e, t) => /* @__PURE__ */ v("li", {
26
28
  className: "grid grid-cols-[8rem_1fr_6rem] items-center gap-2 text-sm",
27
29
  children: [
28
- /* @__PURE__ */ h("span", {
30
+ /* @__PURE__ */ _("span", {
29
31
  className: "truncate",
30
- children: String(e[u])
32
+ children: String(e[s])
31
33
  }),
32
- /* @__PURE__ */ h("span", {
34
+ /* @__PURE__ */ _("span", {
33
35
  className: "h-3 rounded bg-bg-surface",
34
36
  "aria-hidden": "true",
35
- children: /* @__PURE__ */ h("span", {
37
+ children: /* @__PURE__ */ _("span", {
36
38
  className: "block h-3 rounded bg-action-primary-bg",
37
39
  style: { width: `${f[t] ?? 0}%` }
38
40
  })
39
41
  }),
40
- /* @__PURE__ */ h("span", {
42
+ /* @__PURE__ */ _("span", {
41
43
  className: "text-right tabular-nums",
42
- children: String(e[d])
44
+ children: String(e[c])
43
45
  })
44
46
  ]
45
47
  }, t))
46
48
  }),
47
- e.truncated && /* @__PURE__ */ h("p", {
49
+ e.truncated && /* @__PURE__ */ _("p", {
48
50
  role: "status",
49
51
  className: "text-sm font-medium text-text-primary",
50
52
  children: "Only part of the result is shown; the service limit was reached, so treat these rows as incomplete."
51
53
  }),
52
- r.length > 0 && /* @__PURE__ */ h("div", {
54
+ r.length > 0 && /* @__PURE__ */ _("div", {
53
55
  className: "max-h-72 overflow-auto rounded border border-border-default",
54
56
  tabIndex: 0,
55
57
  "aria-label": "Answer data",
56
- children: /* @__PURE__ */ g("table", {
58
+ children: /* @__PURE__ */ v("table", {
57
59
  className: "w-full text-left text-sm",
58
- children: [/* @__PURE__ */ h("thead", {
60
+ children: [/* @__PURE__ */ _("thead", {
59
61
  className: "sticky top-0 bg-bg-surface",
60
- children: /* @__PURE__ */ h("tr", { children: e.columns.map((e) => /* @__PURE__ */ h("th", {
62
+ children: /* @__PURE__ */ _("tr", { children: e.columns.map((e) => /* @__PURE__ */ _("th", {
61
63
  scope: "col",
62
64
  className: "px-3 py-2",
63
65
  children: e
64
66
  }, e)) })
65
- }), /* @__PURE__ */ h("tbody", { children: r.map((e, t) => /* @__PURE__ */ h("tr", {
67
+ }), /* @__PURE__ */ _("tbody", { children: r.map((e, t) => /* @__PURE__ */ _("tr", {
66
68
  className: "border-t border-border-default",
67
- children: e.map((e, t) => /* @__PURE__ */ h("td", {
69
+ children: e.map((e, t) => /* @__PURE__ */ _("td", {
68
70
  className: "px-3 py-1.5",
69
- children: e === null ? /* @__PURE__ */ h("i", {
71
+ children: e === null ? /* @__PURE__ */ _("i", {
70
72
  className: "text-text-secondary",
71
73
  children: "NULL"
72
74
  }) : String(e)
@@ -74,102 +76,102 @@ function v({ answer: e, workspaceId: t }) {
74
76
  }, t)) })]
75
77
  })
76
78
  }),
77
- m && /* @__PURE__ */ g("details", {
79
+ p && /* @__PURE__ */ v("details", {
78
80
  className: "rounded border border-border-default p-3 text-sm",
79
81
  children: [
80
- /* @__PURE__ */ h("summary", {
82
+ /* @__PURE__ */ _("summary", {
81
83
  className: "cursor-pointer font-medium",
82
84
  children: "How I got this"
83
85
  }),
84
- /* @__PURE__ */ g("dl", {
86
+ /* @__PURE__ */ v("dl", {
85
87
  className: "mt-2 space-y-1",
86
88
  children: [
87
- /* @__PURE__ */ g("div", { children: [/* @__PURE__ */ h("dt", {
89
+ /* @__PURE__ */ v("div", { children: [/* @__PURE__ */ _("dt", {
88
90
  className: "inline font-medium",
89
91
  children: "Data source: "
90
- }), /* @__PURE__ */ g("dd", {
92
+ }), /* @__PURE__ */ v("dd", {
91
93
  className: "inline",
92
94
  children: [
93
- m.sourceName,
95
+ p.sourceName,
94
96
  " ",
95
- /* @__PURE__ */ g("span", {
97
+ /* @__PURE__ */ v("span", {
96
98
  className: "text-text-secondary",
97
99
  children: [
98
100
  "(",
99
- m.sourceId,
101
+ p.sourceId,
100
102
  ")"
101
103
  ]
102
104
  })
103
105
  ]
104
106
  })] }),
105
- /* @__PURE__ */ g("div", { children: [/* @__PURE__ */ h("dt", {
107
+ /* @__PURE__ */ v("div", { children: [/* @__PURE__ */ _("dt", {
106
108
  className: "inline font-medium",
107
109
  children: "Parser: "
108
- }), /* @__PURE__ */ h("dd", {
110
+ }), /* @__PURE__ */ _("dd", {
109
111
  className: "inline",
110
- children: m.parser
112
+ children: p.parser
111
113
  })] }),
112
- /* @__PURE__ */ g("div", { children: [/* @__PURE__ */ h("dt", {
114
+ /* @__PURE__ */ v("div", { children: [/* @__PURE__ */ _("dt", {
113
115
  className: "inline font-medium",
114
116
  children: "Fields: "
115
- }), /* @__PURE__ */ h("dd", {
117
+ }), /* @__PURE__ */ _("dd", {
116
118
  className: "inline",
117
- children: m.fieldsUsed.map((e) => `${e.name} (${e.type})`).join(", ")
119
+ children: p.fieldsUsed.map((e) => `${e.name} (${e.type})`).join(", ")
118
120
  })] }),
119
- /* @__PURE__ */ g("div", { children: [/* @__PURE__ */ h("dt", {
121
+ /* @__PURE__ */ v("div", { children: [/* @__PURE__ */ _("dt", {
120
122
  className: "inline font-medium",
121
123
  children: "Aggregation: "
122
- }), /* @__PURE__ */ h("dd", {
124
+ }), /* @__PURE__ */ _("dd", {
123
125
  className: "inline",
124
- children: m.aggregations.join(", ")
126
+ children: p.aggregations.join(", ")
125
127
  })] }),
126
- /* @__PURE__ */ g("div", { children: [/* @__PURE__ */ h("dt", {
128
+ /* @__PURE__ */ v("div", { children: [/* @__PURE__ */ _("dt", {
127
129
  className: "inline font-medium",
128
130
  children: "Grouped by: "
129
- }), /* @__PURE__ */ h("dd", {
131
+ }), /* @__PURE__ */ _("dd", {
130
132
  className: "inline",
131
- children: m.grouping.length ? m.grouping.join(", ") : "nothing"
133
+ children: p.grouping.length ? p.grouping.join(", ") : "nothing"
132
134
  })] }),
133
- /* @__PURE__ */ g("div", { children: [/* @__PURE__ */ h("dt", {
135
+ /* @__PURE__ */ v("div", { children: [/* @__PURE__ */ _("dt", {
134
136
  className: "inline font-medium",
135
137
  children: "Filters: "
136
- }), /* @__PURE__ */ h("dd", {
138
+ }), /* @__PURE__ */ _("dd", {
137
139
  className: "inline",
138
- children: m.filters.length ? m.filters.join("; ") : "none"
140
+ children: p.filters.length ? p.filters.join("; ") : "none"
139
141
  })] }),
140
- m.timeRange && /* @__PURE__ */ g("div", { children: [/* @__PURE__ */ h("dt", {
142
+ p.timeRange && /* @__PURE__ */ v("div", { children: [/* @__PURE__ */ _("dt", {
141
143
  className: "inline font-medium",
142
144
  children: "Time range: "
143
- }), /* @__PURE__ */ h("dd", {
145
+ }), /* @__PURE__ */ _("dd", {
144
146
  className: "inline",
145
- children: m.timeRange
147
+ children: p.timeRange
146
148
  })] }),
147
- /* @__PURE__ */ g("div", { children: [/* @__PURE__ */ h("dt", {
149
+ /* @__PURE__ */ v("div", { children: [/* @__PURE__ */ _("dt", {
148
150
  className: "inline font-medium",
149
151
  children: "Metric: "
150
- }), /* @__PURE__ */ h("dd", {
152
+ }), /* @__PURE__ */ _("dd", {
151
153
  className: "inline",
152
- children: m.metricDefinition
154
+ children: p.metricDefinition
153
155
  })] }),
154
- /* @__PURE__ */ g("div", { children: [/* @__PURE__ */ h("dt", {
156
+ /* @__PURE__ */ v("div", { children: [/* @__PURE__ */ _("dt", {
155
157
  className: "inline font-medium",
156
158
  children: "Query: "
157
- }), /* @__PURE__ */ h("dd", {
159
+ }), /* @__PURE__ */ _("dd", {
158
160
  className: "inline",
159
- children: /* @__PURE__ */ h("code", {
161
+ children: /* @__PURE__ */ _("code", {
160
162
  className: "break-all",
161
- children: m.query
163
+ children: p.query
162
164
  })
163
165
  })] })
164
166
  ]
165
167
  }),
166
- m.limitations.length > 0 && /* @__PURE__ */ h("ul", {
168
+ p.limitations.length > 0 && /* @__PURE__ */ _("ul", {
167
169
  className: "mt-2 list-disc pl-5 text-text-secondary",
168
- children: m.limitations.map((e) => /* @__PURE__ */ h("li", { children: e }, e))
170
+ children: p.limitations.map((e) => /* @__PURE__ */ _("li", { children: e }, e))
169
171
  })
170
172
  ]
171
173
  }),
172
- e.usage && /* @__PURE__ */ g("p", {
174
+ e.usage && /* @__PURE__ */ v("p", {
173
175
  className: "text-xs text-text-secondary",
174
176
  children: [
175
177
  e.usage.model,
@@ -181,11 +183,11 @@ function v({ answer: e, workspaceId: t }) {
181
183
  e.usage.credits == null ? "" : ` · ${e.usage.credits} AI credits`
182
184
  ]
183
185
  }),
184
- e.spec != null && (i ? /* @__PURE__ */ h(n, {
186
+ e.spec != null && (i ? /* @__PURE__ */ _(n, {
185
187
  askSpec: e.spec,
186
- name: c(e),
188
+ name: u(e),
187
189
  workspaceId: t
188
- }) : /* @__PURE__ */ h("button", {
190
+ }) : /* @__PURE__ */ _("button", {
189
191
  type: "button",
190
192
  className: "rounded border border-border-default px-3 py-1.5 text-sm",
191
193
  onClick: () => a(!0),
@@ -194,127 +196,128 @@ function v({ answer: e, workspaceId: t }) {
194
196
  ]
195
197
  });
196
198
  }
197
- function y() {
198
- let n = m(), { workspaceId: s, currentUser: c } = t(), l = c?.id ?? "", [y, b] = p(""), [x, S] = p(null), [C, w] = p(""), [T, E] = p(!1), [D, O] = p(""), k = f(0);
199
- d(() => () => {
200
- k.current += 1;
199
+ function x() {
200
+ let n = g(), l = s(), { workspaceId: u, currentUser: d } = t(), x = d?.id ?? "", [S, C] = h(""), [w, T] = h(null), [E, D] = h(""), [O, k] = h(!1), [A, j] = h(""), M = m(0);
201
+ p(() => () => {
202
+ M.current += 1;
201
203
  }, []);
202
- let A = u(async (t) => {
203
- let o = t.trim();
204
- if (!o || o.length > _ || !s) return;
205
- let c = ++k.current;
206
- E(!0), O(""), S(null), w(o);
204
+ let N = f(async (t) => {
205
+ let s = t.trim();
206
+ if (!s || s.length > y || !u) return;
207
+ let c = ++M.current;
208
+ k(!0), j(""), T(null), D(s);
207
209
  try {
208
- let { data: t } = await n.query({
210
+ let { data: t } = o(await n.query({
209
211
  query: e,
210
- variables: { question: o },
212
+ variables: { question: s },
211
213
  fetchPolicy: "network-only",
212
- context: a(s)
213
- });
214
- if (c !== k.current) return;
214
+ context: i(u)
215
+ }));
216
+ if (c !== M.current) return;
215
217
  if (!t?.bigconsoleAsk) throw Error("Missing answer");
216
- S(t.bigconsoleAsk);
218
+ T(t.bigconsoleAsk);
217
219
  } catch (e) {
218
- if (c !== k.current || r(e, "command")) return;
219
- O(i(e));
220
+ if (c !== M.current || r(e, "command")) return;
221
+ j(a(e, l));
220
222
  } finally {
221
- c === k.current && E(!1);
223
+ c === M.current && k(!1);
222
224
  }
223
225
  }, [
224
226
  n,
225
- s,
227
+ u,
228
+ x,
226
229
  l
227
230
  ]);
228
- return /* @__PURE__ */ g("section", {
231
+ return /* @__PURE__ */ v("section", {
229
232
  "aria-labelledby": "ask-heading",
230
233
  className: "space-y-3 rounded border border-border-default bg-bg-surface p-4",
231
234
  children: [
232
- /* @__PURE__ */ h("h2", {
235
+ /* @__PURE__ */ _("h2", {
233
236
  id: "ask-heading",
234
237
  className: "m-0 text-lg font-semibold text-text-primary",
235
238
  children: "Ask your data"
236
239
  }),
237
- /* @__PURE__ */ h("p", {
240
+ /* @__PURE__ */ _("p", {
238
241
  className: "m-0 text-sm text-text-secondary",
239
242
  children: "Ask a question about data already in your workspace. Answers come from a verified query over the data you may see; nothing is changed."
240
243
  }),
241
- /* @__PURE__ */ g("form", {
244
+ /* @__PURE__ */ v("form", {
242
245
  onSubmit: (e) => {
243
- e.preventDefault(), A(y);
246
+ e.preventDefault(), N(S);
244
247
  },
245
248
  className: "flex flex-wrap items-end gap-2",
246
- children: [/* @__PURE__ */ g("label", {
249
+ children: [/* @__PURE__ */ v("label", {
247
250
  className: "flex min-w-[16rem] flex-1 flex-col gap-1 text-sm",
248
251
  htmlFor: "ask-input",
249
- children: ["Your question", /* @__PURE__ */ h("input", {
252
+ children: ["Your question", /* @__PURE__ */ _("input", {
250
253
  id: "ask-input",
251
254
  className: "rounded border border-border-default bg-bg-surface px-3 py-2",
252
- value: y,
253
- maxLength: _,
255
+ value: S,
256
+ maxLength: y,
254
257
  placeholder: "e.g. Which region had the most revenue in August?",
255
- onChange: (e) => b(e.target.value)
258
+ onChange: (e) => C(e.target.value)
256
259
  })]
257
- }), /* @__PURE__ */ h("button", {
260
+ }), /* @__PURE__ */ _("button", {
258
261
  type: "submit",
259
- disabled: T || !y.trim() || !s,
262
+ disabled: O || !S.trim() || !u,
260
263
  className: "rounded bg-action-primary-bg px-4 py-2 text-sm font-medium text-action-primary-fg disabled:opacity-60",
261
- children: T ? "Asking…" : "Ask"
264
+ children: O ? "Asking…" : "Ask"
262
265
  })]
263
266
  }),
264
- !s && /* @__PURE__ */ h("p", {
267
+ !u && /* @__PURE__ */ _("p", {
265
268
  role: "status",
266
269
  className: "m-0 text-sm text-text-secondary",
267
270
  children: "Select a workspace to ask a question."
268
271
  }),
269
- /* @__PURE__ */ g("div", {
272
+ /* @__PURE__ */ v("div", {
270
273
  "aria-live": "polite",
271
274
  children: [
272
- T && /* @__PURE__ */ h("p", {
275
+ O && /* @__PURE__ */ _("p", {
273
276
  role: "status",
274
277
  children: "Finding the answer in your data…"
275
278
  }),
276
- D && /* @__PURE__ */ h("p", {
279
+ A && /* @__PURE__ */ _("p", {
277
280
  role: "alert",
278
- children: D
281
+ children: A
279
282
  }),
280
- x && /* @__PURE__ */ g("p", {
283
+ w && /* @__PURE__ */ v("p", {
281
284
  className: "m-0 text-sm text-text-secondary",
282
285
  "data-testid": "ask-asked",
283
- children: ["Answer to: ", /* @__PURE__ */ h("q", { children: C })]
286
+ children: ["Answer to: ", /* @__PURE__ */ _("q", { children: E })]
284
287
  }),
285
- x?.status === "VERIFIED" && /* @__PURE__ */ h(v, {
286
- answer: x,
287
- workspaceId: s ?? ""
288
- }, C + x.headline),
289
- x && x.status !== "VERIFIED" && /* @__PURE__ */ g("div", {
288
+ w?.status === "VERIFIED" && /* @__PURE__ */ _(b, {
289
+ answer: w,
290
+ workspaceId: u ?? ""
291
+ }, E + w.headline),
292
+ w && w.status !== "VERIFIED" && /* @__PURE__ */ v("div", {
290
293
  className: "space-y-2",
291
- "data-status": x.status,
294
+ "data-status": w.status,
292
295
  children: [
293
- /* @__PURE__ */ h("h3", {
296
+ /* @__PURE__ */ _("h3", {
294
297
  className: "m-0 text-base font-medium",
295
- children: o[x.status]
298
+ children: c[w.status]
296
299
  }),
297
- x.message && /* @__PURE__ */ h("p", {
300
+ w.message && /* @__PURE__ */ _("p", {
298
301
  className: "m-0 text-sm",
299
- children: x.message
302
+ children: w.message
300
303
  }),
301
- x.clarificationOptions.length > 0 && /* @__PURE__ */ h("div", {
304
+ w.clarificationOptions.length > 0 && /* @__PURE__ */ _("div", {
302
305
  className: "flex flex-wrap gap-2",
303
306
  role: "group",
304
307
  "aria-label": "Choose a data source",
305
- children: x.clarificationOptions.map((e) => /* @__PURE__ */ h("button", {
308
+ children: w.clarificationOptions.map((e) => /* @__PURE__ */ _("button", {
306
309
  type: "button",
307
310
  className: "rounded border border-border-default px-3 py-1 text-sm",
308
311
  onClick: () => {
309
- let t = ` (use ${e.name})`, n = C.slice(0, Math.max(0, _ - t.length)) + t;
310
- b(n), A(n);
312
+ let t = ` (use ${e.name})`, n = E.slice(0, Math.max(0, y - t.length)) + t;
313
+ C(n), N(n);
311
314
  },
312
315
  children: e.name
313
316
  }, e.id))
314
317
  }),
315
- x.provenance && /* @__PURE__ */ g("p", {
318
+ w.provenance && /* @__PURE__ */ v("p", {
316
319
  className: "m-0 text-xs text-text-secondary",
317
- children: ["Looked at: ", x.provenance.sourceName]
320
+ children: ["Looked at: ", w.provenance.sourceName]
318
321
  })
319
322
  ]
320
323
  })
@@ -323,8 +326,8 @@ function y() {
323
326
  ]
324
327
  });
325
328
  }
326
- function b() {
329
+ function S() {
327
330
  let { workspaceId: e, currentUser: n } = t();
328
- return /* @__PURE__ */ h(y, {}, `${e ?? ""}|${n?.id ?? ""}`);
331
+ return /* @__PURE__ */ _(x, {}, `${e ?? ""}|${n?.id ?? ""}`);
329
332
  }
330
- export { b as AskYourData };
333
+ export { S as AskYourData };