@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,14 +3,15 @@ import { ExpressionEditor as t } from "../parser/ExpressionEditor.js";
3
3
  import { ExploreHistoryDocument as n, ExploreSavedQueriesDocument as r, ExploreSavedQueryDocument as i, ExploreSourcesDocument as a, SaveExploreDocument as o } from "../../../generated/wspace-operations.js";
4
4
  import { Control as s, VisualBuilder as ee, controlClass as c } from "./VisualBuilder.js";
5
5
  import { emptyVisual as te, visualSql as ne } from "./visualSql.js";
6
- import { exploreError as l, useExploreRun as re, workspaceRequest as u } from "./useExploreRun.js";
7
- import { QueryResults as ie } from "./QueryResults.js";
8
- import { CreateQueryWidget as ae } from "./CreateQueryWidget.js";
9
- import { useCallback as oe, useEffect as d, useRef as f, useState as p } from "react";
6
+ import { useExploreRun as re, workspaceRequest as ie } from "./useExploreRun.js";
7
+ import { exploreErrorMessage as l, withoutError as u } from "./exploreErrors.js";
8
+ import { QueryResults as ae } from "./QueryResults.js";
9
+ import { CreateQueryWidget as oe } from "./CreateQueryWidget.js";
10
+ import { useCallback as se, useEffect as d, useRef as f, useState as p } from "react";
10
11
  import { Button as m } from "@burdenoff/fe-libs/ui";
11
- import { useUnsavedChanges as se } from "@burdenoff/fe-libs/shared/hooks";
12
- import { useApolloClient as ce } from "@apollo/client/react";
13
- import { Fragment as le, jsx as h, jsxs as g } from "react/jsx-runtime";
12
+ import { useUnsavedChanges as ce } from "@burdenoff/fe-libs/shared/hooks";
13
+ import { useApolloClient as le } from "@apollo/client/react";
14
+ import { Fragment as ue, jsx as h, jsxs as g } from "react/jsx-runtime";
14
15
  // src/bigconsole/components/explore/SqlDraftEditor.tsx
15
16
  var _ = [
16
17
  "SELECT",
@@ -35,22 +36,22 @@ var _ = [
35
36
  "LIMIT"
36
37
  ];
37
38
  function v({ workspaceId: v }) {
38
- let y = e(), b = ce(), [x, S] = p("sql"), [C, w] = p(""), [ue, de] = p(te), [T, E] = p([]), [D, O] = p([]), [fe, k] = p([]), [A, j] = p(0), [pe, me] = p(-1), M = A !== pe, [N, P] = p(""), [F, I] = p(""), [he, L] = p(""), R = x === "sql" ? F : he, [z, B] = p(""), [V, H] = p(!1), [U, W] = p(""), [ge, G] = p(""), [K, q] = p(!1), [_e, ve] = p(!1), ye = !F && !!C.length || _e, J = f(null), { run: be, cancel: xe, result: Se, error: Ce, running: Y, cancelling: we, clearResult: X } = re(v), Z = ne(ue, T), Q = x === "sql" ? C : Z, Te = y("bigconsole.assistant.unsaved.sqlDraft", "the query draft");
39
- se({
39
+ let y = e(), b = le(), [x, S] = p("sql"), [C, w] = p(""), [T, de] = p(te), [E, D] = p([]), [O, k] = p([]), [fe, A] = p([]), [j, M] = p(0), [pe, me] = p(-1), N = j !== pe, [P, F] = p(""), [I, L] = p(""), [he, R] = p(""), z = x === "sql" ? I : he, [B, V] = p(""), [H, U] = p(!1), [W, G] = p(""), [K, q] = p(""), [ge, _e] = p(!1), [ve, ye] = p(!1), be = !I && !!C.length || ve, J = f(null), { run: xe, cancel: Se, result: Ce, error: we, running: Y, cancelling: Te, clearResult: X } = re(v), Z = ne(T, E), Q = x === "sql" ? C : Z, Ee = y("bigconsole.assistant.unsaved.sqlDraft", "the query draft");
40
+ ce({
40
41
  id: "bigconsole-sql-draft",
41
- label: Te,
42
- dirty: ye
42
+ label: Ee,
43
+ dirty: be
43
44
  });
44
- let Ee = f(T);
45
+ let De = f(E);
45
46
  d(() => {
46
- Ee.current = T;
47
- }, [T]), d(() => {
47
+ De.current = E;
48
+ }, [E]), d(() => {
48
49
  let e = new AbortController();
49
50
  return J.current = e, () => {
50
51
  e.abort(), J.current = null;
51
52
  };
52
53
  }, []), d(() => {
53
- let e = new AbortController(), t = u(v, e.signal);
54
+ let e = new AbortController(), t = ie(v, e.signal);
54
55
  return Promise.all([
55
56
  b.query({
56
57
  query: a,
@@ -68,28 +69,29 @@ function v({ workspaceId: v }) {
68
69
  context: t
69
70
  })
70
71
  ]).then(([t, n, r]) => {
71
- if (!e.signal.aborted) {
72
- if (!t.data || !n.data || !r.data) throw Error("Incomplete catalog");
73
- P(""), E(t.data.bigconsoleExploreSources), k(n.data.bigconsoleSavedQueries), O(r.data.bigconsoleExploreHistory);
74
- }
72
+ if (e.signal.aborted) return;
73
+ let i = u(t), a = u(n), o = u(r);
74
+ if (!i.data || !a.data || !o.data) throw Error("Incomplete catalog");
75
+ F(""), D(i.data.bigconsoleExploreSources), A(a.data.bigconsoleSavedQueries), k(o.data.bigconsoleExploreHistory);
75
76
  }).catch((t) => {
76
- e.signal.aborted || (E([]), k([]), O([]), P(l(t)));
77
+ e.signal.aborted || (D([]), A([]), k([]), F(l(t, y)));
77
78
  }).finally(() => {
78
- e.signal.aborted || me(A);
79
+ e.signal.aborted || me(j);
79
80
  }), () => e.abort();
80
81
  }, [
81
82
  b,
82
83
  v,
83
- A
84
+ j,
85
+ y
84
86
  ]);
85
- let De = oe((e, t) => {
87
+ let Oe = se((e, t) => {
86
88
  let n = e.getModel();
87
89
  if (!n) return;
88
90
  let r = t.languages.registerCompletionItemProvider("sql", {
89
91
  triggerCharacters: ["."],
90
92
  provideCompletionItems(e, r) {
91
93
  if (e !== n) return { suggestions: [] };
92
- let i = n.getWordUntilPosition(r), a = new t.Range(r.lineNumber, i.startColumn, r.lineNumber, i.endColumn), o = n.getLineContent(r.lineNumber).slice(0, i.startColumn - 1).match(/"?([a-z_][a-z0-9_]*)"?\.$/i)?.[1].toLowerCase(), s = Ee.current;
94
+ let i = n.getWordUntilPosition(r), a = new t.Range(r.lineNumber, i.startColumn, r.lineNumber, i.endColumn), o = n.getLineContent(r.lineNumber).slice(0, i.startColumn - 1).match(/"?([a-z_][a-z0-9_]*)"?\.$/i)?.[1].toLowerCase(), s = De.current;
93
95
  return { suggestions: (o ? s.find((e) => e.name === o)?.fields.map((e) => e.name) ?? [] : [
94
96
  ..._,
95
97
  ...s.map((e) => e.name),
@@ -104,26 +106,26 @@ function v({ workspaceId: v }) {
104
106
  });
105
107
  e.onDidDispose(() => r.dispose());
106
108
  }, []);
107
- function Oe(e) {
108
- w(e), I(""), H(!1), W(""), G(""), X();
109
+ function ke(e) {
110
+ w(e), L(""), U(!1), G(""), q(""), X();
109
111
  }
110
- async function ke() {
111
- G(""), W(""), await be(R ? { savedQueryId: R } : { sql: Q }), J.current && !J.current.signal.aborted && j((e) => e + 1);
112
+ async function Ae() {
113
+ q(""), G(""), await xe(z ? { savedQueryId: z } : { sql: Q }), J.current && !J.current.signal.aborted && M((e) => e + 1);
112
114
  }
113
- async function Ae(e, t) {
115
+ async function je(e, t) {
114
116
  let n = J.current?.signal;
115
- if (!(!n || n.aborted || K)) {
116
- q(!0), G(""), W(""), H(!1), X();
117
+ if (!(!n || n.aborted || ge)) {
118
+ _e(!0), q(""), G(""), U(!1), X();
117
119
  try {
118
- let r = u(v, n), a = e === "open" && t ? (await b.query({
120
+ let r = ie(v, n), a = e === "open" && t ? u(await b.query({
119
121
  query: i,
120
122
  variables: { id: t },
121
123
  fetchPolicy: "no-cache",
122
124
  context: r
123
- })).data?.bigconsoleSavedQuery : (await b.mutate({
125
+ })).data?.bigconsoleSavedQuery : u(await b.mutate({
124
126
  mutation: o,
125
127
  variables: {
126
- name: z.trim(),
128
+ name: B.trim(),
127
129
  sql: Q
128
130
  },
129
131
  fetchPolicy: "no-cache",
@@ -131,22 +133,22 @@ function v({ workspaceId: v }) {
131
133
  })).data?.bigconsoleSaveExplore;
132
134
  if (n.aborted) return;
133
135
  if (!a) throw Error("Missing saved definition");
134
- B(a.name), e === "save" && x === "visual" ? (L(a.id), ve(!1)) : (I(a.id), S("sql"), w(a.sql)), W(e === "open" ? "Saved query opened." : "Query saved."), j((e) => e + 1);
136
+ V(a.name), e === "save" && x === "visual" ? (R(a.id), ye(!1)) : (L(a.id), S("sql"), w(a.sql)), G(e === "open" ? "Saved query opened." : "Query saved."), M((e) => e + 1);
135
137
  } catch (e) {
136
- n.aborted || (G(l(e)), j((e) => e + 1));
138
+ n.aborted || (q(l(e, y)), M((e) => e + 1));
137
139
  } finally {
138
- n.aborted || q(!1);
140
+ n.aborted || _e(!1);
139
141
  }
140
142
  }
141
143
  }
142
- async function je() {
144
+ async function Me() {
143
145
  try {
144
- await navigator.clipboard.writeText(Q), W(y("bigconsole.explore.copied", "Draft copied."));
146
+ await navigator.clipboard.writeText(Q), G(y("bigconsole.explore.copied", "Draft copied."));
145
147
  } catch {
146
- W(y("bigconsole.explore.copyFailed", "Select and copy the draft in the editor."));
148
+ G(y("bigconsole.explore.copyFailed", "Select and copy the draft in the editor."));
147
149
  }
148
150
  }
149
- let $ = Y || K;
151
+ let $ = Y || ge;
150
152
  return /* @__PURE__ */ g("div", {
151
153
  className: "mt-3 space-y-4",
152
154
  children: [
@@ -157,18 +159,18 @@ function v({ workspaceId: v }) {
157
159
  className: "font-medium",
158
160
  children: "Available sources"
159
161
  }),
160
- M && /* @__PURE__ */ h("span", {
162
+ N && /* @__PURE__ */ h("span", {
161
163
  role: "status",
162
164
  children: "Loading schema…"
163
165
  }),
164
- N && /* @__PURE__ */ h("p", {
166
+ P && /* @__PURE__ */ h("p", {
165
167
  role: "alert",
166
- children: N
168
+ children: P
167
169
  }),
168
- !M && !N && !T.length && /* @__PURE__ */ h("p", { children: "No sources are authorized for this workspace." }),
170
+ !N && !P && !E.length && /* @__PURE__ */ h("p", { children: "No sources are authorized for this workspace." }),
169
171
  /* @__PURE__ */ h("div", {
170
172
  className: "flex flex-wrap gap-3",
171
- children: T.map((e) => /* @__PURE__ */ g("details", { children: [/* @__PURE__ */ h("summary", {
173
+ children: E.map((e) => /* @__PURE__ */ g("details", { children: [/* @__PURE__ */ h("summary", {
172
174
  className: "cursor-pointer",
173
175
  children: e.name
174
176
  }), /* @__PURE__ */ h("ul", {
@@ -185,9 +187,9 @@ function v({ workspaceId: v }) {
185
187
  /* @__PURE__ */ h("button", {
186
188
  className: "mt-1 text-sm underline",
187
189
  type: "button",
188
- disabled: $ || M,
190
+ disabled: $ || N,
189
191
  onClick: () => {
190
- X(), j((e) => e + 1);
192
+ X(), M((e) => e + 1);
191
193
  },
192
194
  children: "Refresh schema"
193
195
  })
@@ -202,7 +204,7 @@ function v({ workspaceId: v }) {
202
204
  "aria-pressed": x === "sql",
203
205
  disabled: $,
204
206
  onClick: () => {
205
- S("sql"), H(!1), X(), G("");
207
+ S("sql"), U(!1), X(), q("");
206
208
  },
207
209
  children: "SQL"
208
210
  }), /* @__PURE__ */ h(m, {
@@ -211,7 +213,7 @@ function v({ workspaceId: v }) {
211
213
  "aria-pressed": x === "visual",
212
214
  disabled: $,
213
215
  onClick: () => {
214
- S("visual"), H(!1), X(), G("");
216
+ S("visual"), U(!1), X(), q("");
215
217
  },
216
218
  children: "Explore"
217
219
  })]
@@ -219,15 +221,15 @@ function v({ workspaceId: v }) {
219
221
  x === "sql" ? /* @__PURE__ */ h(t, {
220
222
  language: "sql",
221
223
  value: C,
222
- onChange: Oe,
223
- onEditorMount: De,
224
+ onChange: ke,
225
+ onEditorMount: Oe,
224
226
  readOnly: $,
225
227
  saveViewState: !1,
226
228
  inputOptions: {
227
229
  ariaLabel: y("bigconsole.explore.sqlEditor", "SQL editor"),
228
230
  wordBasedSuggestions: "off"
229
231
  }
230
- }) : /* @__PURE__ */ g(le, { children: [
232
+ }) : /* @__PURE__ */ g(ue, { children: [
231
233
  /* @__PURE__ */ h("p", {
232
234
  className: "text-sm text-text-secondary",
233
235
  children: "Explore builds a separate query. Return to SQL to see your original text."
@@ -235,10 +237,10 @@ function v({ workspaceId: v }) {
235
237
  /* @__PURE__ */ h("fieldset", {
236
238
  disabled: $,
237
239
  children: /* @__PURE__ */ h(ee, {
238
- sources: T,
239
- value: ue,
240
+ sources: E,
241
+ value: T,
240
242
  onChange: (e) => {
241
- de(e), L(""), ve(!0), X(), G("");
243
+ de(e), R(""), ye(!0), X(), q("");
242
244
  }
243
245
  })
244
246
  }),
@@ -260,23 +262,23 @@ function v({ workspaceId: v }) {
260
262
  /* @__PURE__ */ h(m, {
261
263
  size: "sm",
262
264
  type: "button",
263
- disabled: $ || !Q.trim() || !T.length || M || !!N,
264
- onClick: () => void ke(),
265
+ disabled: $ || !Q.trim() || !E.length || N || !!P,
266
+ onClick: () => void Ae(),
265
267
  children: "Run"
266
268
  }),
267
269
  Y && /* @__PURE__ */ h(m, {
268
270
  size: "sm",
269
271
  type: "button",
270
- disabled: we,
271
- onClick: () => void xe(),
272
- children: we ? "Cancelling…" : "Cancel"
272
+ disabled: Te,
273
+ onClick: () => void Se(),
274
+ children: Te ? "Cancelling…" : "Cancel"
273
275
  }),
274
276
  /* @__PURE__ */ h(m, {
275
277
  size: "sm",
276
278
  type: "button",
277
279
  variant: "secondary",
278
280
  disabled: !Q.trim(),
279
- onClick: () => void je(),
281
+ onClick: () => void Me(),
280
282
  children: y("bigconsole.explore.copy", "Copy draft")
281
283
  })
282
284
  ]
@@ -285,11 +287,11 @@ function v({ workspaceId: v }) {
285
287
  role: "status",
286
288
  children: "Running query…"
287
289
  }),
288
- Ce && /* @__PURE__ */ h("p", {
290
+ we && /* @__PURE__ */ h("p", {
289
291
  role: "alert",
290
- children: Ce
292
+ children: we
291
293
  }),
292
- Se && /* @__PURE__ */ h(ie, { result: Se }),
294
+ Ce && /* @__PURE__ */ h(ae, { result: Ce }),
293
295
  /* @__PURE__ */ g("fieldset", {
294
296
  disabled: $,
295
297
  className: "flex flex-wrap items-end gap-2",
@@ -302,9 +304,9 @@ function v({ workspaceId: v }) {
302
304
  label: "Open saved query",
303
305
  children: /* @__PURE__ */ g("select", {
304
306
  className: c,
305
- value: R,
307
+ value: z,
306
308
  onChange: (e) => {
307
- e.target.value && Ae("open", e.target.value);
309
+ e.target.value && je("open", e.target.value);
308
310
  },
309
311
  children: [/* @__PURE__ */ h("option", {
310
312
  value: "",
@@ -319,44 +321,44 @@ function v({ workspaceId: v }) {
319
321
  label: "Query name",
320
322
  children: /* @__PURE__ */ h("input", {
321
323
  className: c,
322
- value: z,
323
- onChange: (e) => B(e.target.value)
324
+ value: B,
325
+ onChange: (e) => V(e.target.value)
324
326
  })
325
327
  }),
326
328
  /* @__PURE__ */ h(m, {
327
329
  size: "sm",
328
330
  type: "button",
329
- disabled: !Q.trim() || !z.trim() || !!N || M || !T.length,
330
- onClick: () => void Ae("save"),
331
+ disabled: !Q.trim() || !B.trim() || !!P || N || !E.length,
332
+ onClick: () => void je("save"),
331
333
  children: "Save as new query"
332
334
  }),
333
- R && /* @__PURE__ */ h(m, {
335
+ z && /* @__PURE__ */ h(m, {
334
336
  size: "sm",
335
337
  type: "button",
336
- onClick: () => H(!V),
338
+ onClick: () => U(!H),
337
339
  children: "Add to dashboard"
338
340
  })
339
341
  ]
340
342
  }),
341
- U && /* @__PURE__ */ h("p", {
343
+ W && /* @__PURE__ */ h("p", {
342
344
  role: "status",
343
- children: U
345
+ children: W
344
346
  }),
345
- ge && /* @__PURE__ */ h("p", {
347
+ K && /* @__PURE__ */ h("p", {
346
348
  role: "alert",
347
- children: ge
349
+ children: K
348
350
  }),
349
- V && R && /* @__PURE__ */ h(ae, {
350
- savedId: R,
351
- name: z,
351
+ H && z && /* @__PURE__ */ h(oe, {
352
+ savedId: z,
353
+ name: B,
352
354
  workspaceId: v
353
- }, R),
355
+ }, z),
354
356
  /* @__PURE__ */ g("details", { children: [/* @__PURE__ */ h("summary", {
355
357
  className: "cursor-pointer font-medium",
356
358
  children: "Query history"
357
- }), D.length ? /* @__PURE__ */ h("ul", {
359
+ }), O.length ? /* @__PURE__ */ h("ul", {
358
360
  className: "mt-1 text-sm",
359
- children: D.map((e) => /* @__PURE__ */ g("li", { children: [
361
+ children: O.map((e) => /* @__PURE__ */ g("li", { children: [
360
362
  e.startedAt,
361
363
  " · ",
362
364
  e.status,
@@ -0,0 +1,21 @@
1
+ /** `useTr()`-compatible translator: the key, then the English fallback. */
2
+ export type Translate = (key: string, fallback: string) => string;
3
+ /**
4
+ * A localized, user-facing message for an Explore failure.
5
+ *
6
+ * A known reason wins over its code, a known code wins over the generic message, and
7
+ * the connection message is kept for failures that carry no GraphQL error at all, which
8
+ * is what a real transport failure looks like. Codes are read from every Apollo error
9
+ * shape, including a non-2xx `ServerError` whose GraphQL body is only in `bodyText`.
10
+ */
11
+ export declare function exploreErrorMessage(error: unknown, tr: Translate): string;
12
+ /**
13
+ * Return an Apollo result, or throw the GraphQL error it carries.
14
+ *
15
+ * The shared client runs queries and mutations with errorPolicy "all", so a refusal
16
+ * arrives as `result.error` with no data instead of a rejected promise. Reading only
17
+ * `data` would turn every refusal into a generic "missing data" failure.
18
+ */
19
+ export declare function withoutError<T extends {
20
+ error?: unknown;
21
+ }>(result: T): T;
@@ -0,0 +1,79 @@
1
+ import { graphQLErrorDetails as e } from "../../utils/backendError.js";
2
+ // src/bigconsole/components/explore/exploreErrors.ts
3
+ var t = {
4
+ PERMISSION_DENIED: "You do not have permission to use this query or its sources.",
5
+ FORBIDDEN: "You do not have permission to use this query or its sources.",
6
+ INVALID_QUERY: "This statement is invalid or uses an unsupported field or operation.",
7
+ SCHEMA_CHANGED: "A source schema changed. Review the query against the current schema and save a new definition.",
8
+ SOURCE_UNAVAILABLE: "A required source version is unavailable. Try again after ingestion completes.",
9
+ INVALID_DATA: "A source contains data that does not fit its declared schema.",
10
+ INPUT_LIMIT: "The query exceeds the input budget. Choose a smaller source.",
11
+ BUSY: "The query concurrency limit was reached. Try again shortly.",
12
+ CANCELLED: "Query cancelled.",
13
+ TIMEOUT: "The query timed out.",
14
+ ENGINE_UNAVAILABLE: "The query engine is unavailable. Try again shortly.",
15
+ EXECUTION_FAILED: "The query could not be evaluated against the current data."
16
+ }, n = {
17
+ NOT_SELECT: {
18
+ code: "INVALID_QUERY",
19
+ message: "Only a single read-only SELECT statement can be run here. Statements that change data or schema are not allowed."
20
+ },
21
+ MULTIPLE_STATEMENTS: {
22
+ code: "INVALID_QUERY",
23
+ message: "Run one SELECT statement at a time."
24
+ },
25
+ SYNTAX_ERROR: {
26
+ code: "INVALID_QUERY",
27
+ message: "The statement could not be parsed. Check its syntax."
28
+ },
29
+ SELECT_STAR: {
30
+ code: "INVALID_QUERY",
31
+ message: "SELECT * is not supported. List the columns you need, for example SELECT amount, order_date FROM orders."
32
+ },
33
+ UNSUPPORTED_SYNTAX: {
34
+ code: "INVALID_QUERY",
35
+ message: "This statement uses a clause or expression the editor does not support. Use columns, simple filters, joins on equal keys, GROUP BY, ORDER BY and LIMIT."
36
+ },
37
+ EMPTY_QUERY: {
38
+ code: "INVALID_QUERY",
39
+ message: "Enter a SELECT statement to run."
40
+ },
41
+ QUERY_TOO_LONG: {
42
+ code: "INVALID_QUERY",
43
+ message: "The statement is too long. Shorten it and try again."
44
+ },
45
+ INVALID_REQUEST: {
46
+ code: "INVALID_QUERY",
47
+ message: "The request was malformed. Reload the page and try again."
48
+ },
49
+ INVALID_NAME: {
50
+ code: "INVALID_QUERY",
51
+ message: "Enter a name of 1 to 100 characters."
52
+ },
53
+ UNKNOWN_REFERENCE: {
54
+ code: "PERMISSION_DENIED",
55
+ message: "A table or column in this statement does not exist or is not available to you."
56
+ },
57
+ AMBIGUOUS_REFERENCE: {
58
+ code: "PERMISSION_DENIED",
59
+ message: "A column name matches more than one table. Qualify it with the table name or alias."
60
+ },
61
+ MASKED_FIELD: {
62
+ code: "PERMISSION_DENIED",
63
+ message: "Masked columns can be shown, but not filtered, grouped, sorted, joined or aggregated."
64
+ }
65
+ }, r = "The query could not be completed. Try again.", i = "The request could not be completed. Check your connection and try again.";
66
+ function a(a, o) {
67
+ let s = e(a);
68
+ for (let { code: e, reason: t } of s) {
69
+ let r = t && Object.hasOwn(n, t) ? n[t] : void 0;
70
+ if (r && r.code === e) return o(`bigconsole.explore.errors.reason.${t}`, r.message);
71
+ }
72
+ for (let { code: e } of s) if (Object.hasOwn(t, e)) return o(`bigconsole.explore.errors.${e}`, t[e]);
73
+ return s.length ? o("bigconsole.explore.errors.unknown", r) : o("bigconsole.explore.errors.network", i);
74
+ }
75
+ function o(e) {
76
+ if (e.error) throw e.error;
77
+ return e;
78
+ }
79
+ export { a as exploreErrorMessage, o as withoutError };
@@ -1,3 +1,4 @@
1
+ import { exploreErrorMessage as exploreError } from './exploreErrors';
1
2
  export declare function workspaceRequest(workspaceId: string, signal?: AbortSignal): {
2
3
  requiredWorkspaceAuth: boolean;
3
4
  requiredWorkspaceId: string;
@@ -6,7 +7,7 @@ export declare function workspaceRequest(workspaceId: string, signal?: AbortSign
6
7
  signal: AbortSignal | undefined;
7
8
  };
8
9
  };
9
- export declare function exploreError(error: unknown): string;
10
+ export { exploreError };
10
11
  type Cell = string | boolean | number | null;
11
12
  export interface QueryResult {
12
13
  columns: string[];
@@ -29,4 +30,3 @@ export declare function useExploreRun(workspaceId: string): {
29
30
  error: string;
30
31
  clearResult: () => void;
31
32
  };
32
- export {};
@@ -1,9 +1,10 @@
1
1
  import { CancelExploreDocument as e, RunExploreDocument as t } from "../../../generated/wspace-operations.js";
2
- import { useCallback as n, useEffect as r, useRef as i, useState as a } from "react";
3
- import { useApolloClient as o } from "@apollo/client/react";
4
- import { CombinedGraphQLErrors as s } from "@apollo/client";
2
+ import { useOptionalTr as n } from "../../../shared/hooks/useTr.js";
3
+ import { exploreErrorMessage as r, withoutError as i } from "./exploreErrors.js";
4
+ import { useCallback as a, useEffect as o, useRef as s, useState as c } from "react";
5
+ import { useApolloClient as l } from "@apollo/client/react";
5
6
  // src/bigconsole/components/explore/useExploreRun.ts
6
- function c(e, t) {
7
+ function u(e, t) {
7
8
  return {
8
9
  requiredWorkspaceAuth: !0,
9
10
  requiredWorkspaceId: e,
@@ -11,26 +12,6 @@ function c(e, t) {
11
12
  fetchOptions: { signal: t }
12
13
  };
13
14
  }
14
- var l = {
15
- PERMISSION_DENIED: "You do not have permission to use this query or its sources.",
16
- FORBIDDEN: "You do not have permission to use this query or its sources.",
17
- INVALID_QUERY: "This SQL is invalid or uses an unsupported field or operation.",
18
- SCHEMA_CHANGED: "A source schema changed. Review the query against the current schema and save a new definition.",
19
- SOURCE_UNAVAILABLE: "A required source version is unavailable. Try again after ingestion completes.",
20
- INVALID_DATA: "A source contains data that does not fit its declared schema.",
21
- INPUT_LIMIT: "The query exceeds the input budget. Choose a smaller source.",
22
- BUSY: "The query concurrency limit was reached. Try again shortly.",
23
- CANCELLED: "Query cancelled.",
24
- TIMEOUT: "The query timed out.",
25
- ENGINE_UNAVAILABLE: "The query engine is unavailable. Try again shortly."
26
- };
27
- function u(e) {
28
- if (s.is(e)) for (let t of e.errors) {
29
- let e = t.extensions?.code;
30
- if (typeof e == "string" && l[e]) return l[e];
31
- }
32
- return "The request could not be completed. Check your connection and try again.";
33
- }
34
15
  function d(e, t, n) {
35
16
  if (!Array.isArray(t) || !t.every((t) => Array.isArray(t) && t.length === e.length && t.every((e) => e === null || [
36
17
  "boolean",
@@ -43,62 +24,66 @@ function d(e, t, n) {
43
24
  truncated: n
44
25
  };
45
26
  }
46
- function f(s) {
47
- let l = o(), f = i(null), [p, m] = a(null), [h, g] = a(""), [_, v] = a(!1), [y, b] = a(!1), x = n((t) => l.mutate({
27
+ function f(f) {
28
+ let p = l(), m = n(), h = s(null), [g, _] = c(null), [v, y] = c(""), [b, x] = c(!1), [S, C] = c(!1), w = a((t) => p.mutate({
48
29
  mutation: e,
49
30
  variables: { requestId: t },
50
31
  fetchPolicy: "no-cache",
51
- context: c(s)
52
- }), [l, s]);
53
- return r(() => () => {
54
- let e = f.current;
55
- f.current = null, e && (e.controller.abort(), x(e.id).catch(() => {}));
56
- }, [x]), {
57
- run: n(async (e) => {
58
- if (f.current) return;
32
+ context: u(f)
33
+ }), [p, f]);
34
+ return o(() => () => {
35
+ let e = h.current;
36
+ h.current = null, e && (e.controller.abort(), w(e.id).catch(() => {}));
37
+ }, [w]), {
38
+ run: a(async (e) => {
39
+ if (h.current) return;
59
40
  let n = {
60
41
  id: crypto.randomUUID(),
61
42
  controller: new AbortController()
62
43
  };
63
- f.current = n, m(null), g(""), v(!0), b(!1);
44
+ h.current = n, _(null), y(""), x(!0), C(!1);
64
45
  try {
65
- let r = await l.mutate({
46
+ let r = i(await p.mutate({
66
47
  mutation: t,
67
48
  variables: {
68
49
  requestId: n.id,
69
50
  ...e
70
51
  },
71
52
  fetchPolicy: "no-cache",
72
- context: c(s, n.controller.signal)
73
- });
74
- if (f.current !== n) return;
75
- let i = r.data?.bigconsoleRunExplore;
76
- if (!i) throw Error("Missing result");
77
- m(d(i.columns, i.rows, i.truncated));
53
+ context: u(f, n.controller.signal)
54
+ }));
55
+ if (h.current !== n) return;
56
+ let a = r.data?.bigconsoleRunExplore;
57
+ if (!a) throw Error("Missing result");
58
+ _(d(a.columns, a.rows, a.truncated));
78
59
  } catch (e) {
79
- f.current === n && g(u(e));
60
+ h.current === n && y(r(e, m));
80
61
  } finally {
81
- f.current === n && (f.current = null, v(!1), b(!1));
62
+ h.current === n && (h.current = null, x(!1), C(!1));
82
63
  }
83
- }, [l, s]),
64
+ }, [
65
+ p,
66
+ f,
67
+ m
68
+ ]),
84
69
  cancel: async () => {
85
- let e = f.current;
70
+ let e = h.current;
86
71
  if (e) {
87
- b(!0);
72
+ C(!0);
88
73
  try {
89
- await x(e.id);
74
+ i(await w(e.id));
90
75
  } catch (t) {
91
- f.current === e && (g(u(t)), b(!1));
76
+ h.current === e && (y(r(t, m)), C(!1));
92
77
  }
93
78
  }
94
79
  },
95
- running: _,
96
- cancelling: y,
97
- result: p,
98
- error: h,
80
+ running: b,
81
+ cancelling: S,
82
+ result: g,
83
+ error: v,
99
84
  clearResult: () => {
100
- m(null), g("");
85
+ _(null), y("");
101
86
  }
102
87
  };
103
88
  }
104
- export { u as exploreError, d as tabularResult, f as useExploreRun, c as workspaceRequest };
89
+ export { r as exploreError, d as tabularResult, f as useExploreRun, u as workspaceRequest };
@@ -1,8 +1,13 @@
1
1
  type TranslateFn = (key: string, fallback: string) => string;
2
2
  export declare function resolveBackendErrorMessage(t: TranslateFn, error: unknown): string;
3
+ /** One GraphQL error's stable code, plus the optional `extensions.reason` refinement. */
4
+ export interface GraphQLErrorDetail {
5
+ code: string;
6
+ reason?: string;
7
+ }
3
8
  /**
4
- * Every GraphQL `extensions.code` reachable from an error, in the shapes the
5
- * fe-libs Apollo 4 client hands back:
9
+ * Every GraphQL error code (with its optional reason) reachable from an error, in the
10
+ * shapes the fe-libs Apollo 4 client hands back:
6
11
  *
7
12
  * - `CombinedGraphQLErrors` (a `query()` resolved with `{ error }` under
8
13
  * errorPolicy "all", or thrown under "none"): `error.errors[]`;
@@ -15,6 +20,8 @@ export declare function resolveBackendErrorMessage(t: TranslateFn, error: unknow
15
20
  *
16
21
  * Returns `[]` when none is found. Never throws.
17
22
  */
23
+ export declare function graphQLErrorDetails(error: unknown): GraphQLErrorDetail[];
24
+ /** Every distinct GraphQL `extensions.code` reachable from `error`; see {@link graphQLErrorDetails}. */
18
25
  export declare function graphQLErrorCodes(error: unknown): string[];
19
26
  /** True when any GraphQL error reachable from `error` carries one of `codes`. */
20
27
  export declare function hasGraphQLErrorCode(error: unknown, codes: ReadonlySet<string>): boolean;