@burdenoff/microfe-bigconsole 2026.1121.2 → 2026.1121.4
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/ask/AskYourData.js +116 -116
- package/dist/bigconsole/components/explore/CreateQueryWidget.js +102 -102
- package/dist/bigconsole/components/explore/SqlDraftEditor.js +135 -135
- package/dist/bigconsole/components/explore/exploreErrors.d.ts +10 -0
- package/dist/bigconsole/components/explore/exploreErrors.js +5 -1
- package/dist/bigconsole/components/explore/useExploreRun.js +37 -37
- package/package.json +4 -4
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { useTr as e } from "../../../shared/hooks/useTr.js";
|
|
2
2
|
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
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
4
|
+
import { Control as s, VisualBuilder as ee, controlClass as c } from "./VisualBuilder.js";
|
|
5
|
+
import { emptyVisual as te, visualSql as ne } from "./visualSql.js";
|
|
6
|
+
import { useExploreRun as re, workspaceRequest as ie } from "./useExploreRun.js";
|
|
7
|
+
import { exploreErrorMessage as l, withoutError as u } from "./exploreErrors.js";
|
|
8
8
|
import { QueryResults as ae } from "./QueryResults.js";
|
|
9
9
|
import { CreateQueryWidget as oe } from "./CreateQueryWidget.js";
|
|
10
|
-
import { useCallback as se, useEffect as
|
|
11
|
-
import { Button as
|
|
10
|
+
import { useCallback as se, useEffect as d, useRef as f, useState as p } from "react";
|
|
11
|
+
import { Button as m } from "@burdenoff/fe-libs/ui";
|
|
12
12
|
import { useUnsavedChanges as ce } from "@burdenoff/fe-libs/shared/hooks";
|
|
13
13
|
import { useApolloClient as le } from "@apollo/client/react";
|
|
14
|
-
import { Fragment as ue, jsx as
|
|
14
|
+
import { Fragment as ue, jsx as h, jsxs as g } from "react/jsx-runtime";
|
|
15
15
|
// src/bigconsole/components/explore/SqlDraftEditor.tsx
|
|
16
|
-
var
|
|
16
|
+
var _ = [
|
|
17
17
|
"SELECT",
|
|
18
18
|
"FROM",
|
|
19
19
|
"WHERE",
|
|
@@ -35,97 +35,97 @@ var g = [
|
|
|
35
35
|
"MAX",
|
|
36
36
|
"LIMIT"
|
|
37
37
|
];
|
|
38
|
-
function
|
|
39
|
-
let
|
|
38
|
+
function v({ workspaceId: v }) {
|
|
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
40
|
ce({
|
|
41
41
|
id: "bigconsole-sql-draft",
|
|
42
|
-
label:
|
|
43
|
-
dirty:
|
|
42
|
+
label: Ee,
|
|
43
|
+
dirty: be
|
|
44
44
|
});
|
|
45
|
-
let
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}, [
|
|
45
|
+
let De = f(E);
|
|
46
|
+
d(() => {
|
|
47
|
+
De.current = E;
|
|
48
|
+
}, [E]), d(() => {
|
|
49
49
|
let e = new AbortController();
|
|
50
50
|
return J.current = e, () => {
|
|
51
51
|
e.abort(), J.current = null;
|
|
52
52
|
};
|
|
53
|
-
}, []),
|
|
54
|
-
let e = new AbortController(), t =
|
|
53
|
+
}, []), d(() => {
|
|
54
|
+
let e = new AbortController(), t = ie(v, e.signal);
|
|
55
55
|
return Promise.all([
|
|
56
|
-
|
|
56
|
+
b.query({
|
|
57
57
|
query: a,
|
|
58
58
|
fetchPolicy: "no-cache",
|
|
59
59
|
context: t
|
|
60
60
|
}),
|
|
61
|
-
|
|
61
|
+
b.query({
|
|
62
62
|
query: r,
|
|
63
63
|
fetchPolicy: "no-cache",
|
|
64
64
|
context: t
|
|
65
65
|
}),
|
|
66
|
-
|
|
66
|
+
b.query({
|
|
67
67
|
query: n,
|
|
68
68
|
fetchPolicy: "no-cache",
|
|
69
69
|
context: t
|
|
70
70
|
})
|
|
71
71
|
]).then(([t, n, r]) => {
|
|
72
|
-
if (
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
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);
|
|
76
76
|
}).catch((t) => {
|
|
77
|
-
e.signal.aborted || (
|
|
77
|
+
e.signal.aborted || (D([]), A([]), k([]), F(l(t, y)));
|
|
78
78
|
}).finally(() => {
|
|
79
|
-
e.signal.aborted ||
|
|
79
|
+
e.signal.aborted || me(j);
|
|
80
80
|
}), () => e.abort();
|
|
81
81
|
}, [
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
82
|
+
b,
|
|
83
|
+
v,
|
|
84
|
+
j,
|
|
85
|
+
y
|
|
86
86
|
]);
|
|
87
|
-
let
|
|
87
|
+
let Oe = se((e, t) => {
|
|
88
88
|
let n = e.getModel();
|
|
89
89
|
if (!n) return;
|
|
90
90
|
let r = t.languages.registerCompletionItemProvider("sql", {
|
|
91
91
|
triggerCharacters: ["."],
|
|
92
92
|
provideCompletionItems(e, r) {
|
|
93
93
|
if (e !== n) return { suggestions: [] };
|
|
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 =
|
|
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;
|
|
95
95
|
return { suggestions: (o ? s.find((e) => e.name === o)?.fields.map((e) => e.name) ?? [] : [
|
|
96
|
-
...
|
|
96
|
+
..._,
|
|
97
97
|
...s.map((e) => e.name),
|
|
98
98
|
...s.flatMap((e) => e.fields.map((t) => e.name + "." + t.name))
|
|
99
99
|
]).map((e) => ({
|
|
100
100
|
label: e,
|
|
101
|
-
insertText:
|
|
102
|
-
kind:
|
|
101
|
+
insertText: _.includes(e) ? e : e.split(".").map((e) => "\"" + e.replaceAll("\"", "\"\"") + "\"").join("."),
|
|
102
|
+
kind: _.includes(e) ? t.languages.CompletionItemKind.Keyword : t.languages.CompletionItemKind.Field,
|
|
103
103
|
range: a
|
|
104
104
|
})) };
|
|
105
105
|
}
|
|
106
106
|
});
|
|
107
107
|
e.onDidDispose(() => r.dispose());
|
|
108
108
|
}, []);
|
|
109
|
-
function
|
|
110
|
-
|
|
109
|
+
function ke(e) {
|
|
110
|
+
w(e), L(""), U(!1), G(""), q(""), X();
|
|
111
111
|
}
|
|
112
|
-
async function
|
|
113
|
-
|
|
112
|
+
async function Ae() {
|
|
113
|
+
q(""), G(""), await xe(z ? { savedQueryId: z } : { sql: Q }), J.current && !J.current.signal.aborted && M((e) => e + 1);
|
|
114
114
|
}
|
|
115
|
-
async function
|
|
115
|
+
async function je(e, t) {
|
|
116
116
|
let n = J.current?.signal;
|
|
117
|
-
if (!(!n || n.aborted ||
|
|
118
|
-
|
|
117
|
+
if (!(!n || n.aborted || ge)) {
|
|
118
|
+
_e(!0), q(""), G(""), U(!1), X();
|
|
119
119
|
try {
|
|
120
|
-
let r =
|
|
120
|
+
let r = ie(v, n), a = e === "open" && t ? u(await b.query({
|
|
121
121
|
query: i,
|
|
122
122
|
variables: { id: t },
|
|
123
123
|
fetchPolicy: "no-cache",
|
|
124
124
|
context: r
|
|
125
|
-
})).data?.bigconsoleSavedQuery : (await
|
|
125
|
+
})).data?.bigconsoleSavedQuery : u(await b.mutate({
|
|
126
126
|
mutation: o,
|
|
127
127
|
variables: {
|
|
128
|
-
name:
|
|
128
|
+
name: B.trim(),
|
|
129
129
|
sql: Q
|
|
130
130
|
},
|
|
131
131
|
fetchPolicy: "no-cache",
|
|
@@ -133,49 +133,49 @@ function _({ workspaceId: _ }) {
|
|
|
133
133
|
})).data?.bigconsoleSaveExplore;
|
|
134
134
|
if (n.aborted) return;
|
|
135
135
|
if (!a) throw Error("Missing saved definition");
|
|
136
|
-
|
|
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);
|
|
137
137
|
} catch (e) {
|
|
138
|
-
n.aborted || (
|
|
138
|
+
n.aborted || (q(l(e, y)), M((e) => e + 1));
|
|
139
139
|
} finally {
|
|
140
|
-
n.aborted ||
|
|
140
|
+
n.aborted || _e(!1);
|
|
141
141
|
}
|
|
142
142
|
}
|
|
143
143
|
}
|
|
144
|
-
async function
|
|
144
|
+
async function Me() {
|
|
145
145
|
try {
|
|
146
|
-
await navigator.clipboard.writeText(Q),
|
|
146
|
+
await navigator.clipboard.writeText(Q), G(y("bigconsole.explore.copied", "Draft copied."));
|
|
147
147
|
} catch {
|
|
148
|
-
|
|
148
|
+
G(y("bigconsole.explore.copyFailed", "Select and copy the draft in the editor."));
|
|
149
149
|
}
|
|
150
150
|
}
|
|
151
|
-
let $ = Y ||
|
|
152
|
-
return /* @__PURE__ */
|
|
151
|
+
let $ = Y || ge;
|
|
152
|
+
return /* @__PURE__ */ g("div", {
|
|
153
153
|
className: "mt-3 space-y-4",
|
|
154
154
|
children: [
|
|
155
|
-
/* @__PURE__ */
|
|
155
|
+
/* @__PURE__ */ g("section", {
|
|
156
156
|
"aria-label": "Authorized schema",
|
|
157
157
|
children: [
|
|
158
|
-
/* @__PURE__ */
|
|
158
|
+
/* @__PURE__ */ h("h3", {
|
|
159
159
|
className: "font-medium",
|
|
160
160
|
children: "Available sources"
|
|
161
161
|
}),
|
|
162
|
-
|
|
162
|
+
N && /* @__PURE__ */ h("span", {
|
|
163
163
|
role: "status",
|
|
164
164
|
children: "Loading schema…"
|
|
165
165
|
}),
|
|
166
|
-
|
|
166
|
+
P && /* @__PURE__ */ h("p", {
|
|
167
167
|
role: "alert",
|
|
168
|
-
children:
|
|
168
|
+
children: P
|
|
169
169
|
}),
|
|
170
|
-
!
|
|
171
|
-
/* @__PURE__ */
|
|
170
|
+
!N && !P && !E.length && /* @__PURE__ */ h("p", { children: "No sources are authorized for this workspace." }),
|
|
171
|
+
/* @__PURE__ */ h("div", {
|
|
172
172
|
className: "flex flex-wrap gap-3",
|
|
173
|
-
children:
|
|
173
|
+
children: E.map((e) => /* @__PURE__ */ g("details", { children: [/* @__PURE__ */ h("summary", {
|
|
174
174
|
className: "cursor-pointer",
|
|
175
175
|
children: e.name
|
|
176
|
-
}), /* @__PURE__ */
|
|
176
|
+
}), /* @__PURE__ */ h("ul", {
|
|
177
177
|
className: "ml-4 text-sm",
|
|
178
|
-
children: e.fields.map((e) => /* @__PURE__ */
|
|
178
|
+
children: e.fields.map((e) => /* @__PURE__ */ g("li", { children: [
|
|
179
179
|
e.name,
|
|
180
180
|
" · ",
|
|
181
181
|
e.type,
|
|
@@ -184,188 +184,188 @@ function _({ workspaceId: _ }) {
|
|
|
184
184
|
] }, e.id))
|
|
185
185
|
})] }, e.id))
|
|
186
186
|
}),
|
|
187
|
-
/* @__PURE__ */
|
|
187
|
+
/* @__PURE__ */ h("button", {
|
|
188
188
|
className: "mt-1 text-sm underline",
|
|
189
189
|
type: "button",
|
|
190
|
-
disabled: $ ||
|
|
190
|
+
disabled: $ || N,
|
|
191
191
|
onClick: () => {
|
|
192
|
-
X(),
|
|
192
|
+
X(), M((e) => e + 1);
|
|
193
193
|
},
|
|
194
194
|
children: "Refresh schema"
|
|
195
195
|
})
|
|
196
196
|
]
|
|
197
197
|
}),
|
|
198
|
-
/* @__PURE__ */
|
|
198
|
+
/* @__PURE__ */ g("div", {
|
|
199
199
|
"aria-label": "Query mode",
|
|
200
200
|
className: "flex gap-2",
|
|
201
|
-
children: [/* @__PURE__ */ m
|
|
201
|
+
children: [/* @__PURE__ */ h(m, {
|
|
202
202
|
size: "sm",
|
|
203
203
|
type: "button",
|
|
204
|
-
"aria-pressed":
|
|
204
|
+
"aria-pressed": x === "sql",
|
|
205
205
|
disabled: $,
|
|
206
206
|
onClick: () => {
|
|
207
|
-
|
|
207
|
+
S("sql"), U(!1), X(), q("");
|
|
208
208
|
},
|
|
209
209
|
children: "SQL"
|
|
210
|
-
}), /* @__PURE__ */ m
|
|
210
|
+
}), /* @__PURE__ */ h(m, {
|
|
211
211
|
size: "sm",
|
|
212
212
|
type: "button",
|
|
213
|
-
"aria-pressed":
|
|
213
|
+
"aria-pressed": x === "visual",
|
|
214
214
|
disabled: $,
|
|
215
215
|
onClick: () => {
|
|
216
|
-
|
|
216
|
+
S("visual"), U(!1), X(), q("");
|
|
217
217
|
},
|
|
218
218
|
children: "Explore"
|
|
219
219
|
})]
|
|
220
220
|
}),
|
|
221
|
-
|
|
221
|
+
x === "sql" ? /* @__PURE__ */ h(t, {
|
|
222
222
|
language: "sql",
|
|
223
|
-
value:
|
|
224
|
-
onChange:
|
|
225
|
-
onEditorMount:
|
|
223
|
+
value: C,
|
|
224
|
+
onChange: ke,
|
|
225
|
+
onEditorMount: Oe,
|
|
226
226
|
readOnly: $,
|
|
227
227
|
saveViewState: !1,
|
|
228
228
|
inputOptions: {
|
|
229
|
-
ariaLabel:
|
|
229
|
+
ariaLabel: y("bigconsole.explore.sqlEditor", "SQL editor"),
|
|
230
230
|
wordBasedSuggestions: "off"
|
|
231
231
|
}
|
|
232
|
-
}) : /* @__PURE__ */
|
|
233
|
-
/* @__PURE__ */
|
|
232
|
+
}) : /* @__PURE__ */ g(ue, { children: [
|
|
233
|
+
/* @__PURE__ */ h("p", {
|
|
234
234
|
className: "text-sm text-text-secondary",
|
|
235
235
|
children: "Explore builds a separate query. Return to SQL to see your original text."
|
|
236
236
|
}),
|
|
237
|
-
/* @__PURE__ */
|
|
237
|
+
/* @__PURE__ */ h("fieldset", {
|
|
238
238
|
disabled: $,
|
|
239
|
-
children: /* @__PURE__ */
|
|
240
|
-
sources:
|
|
241
|
-
value:
|
|
239
|
+
children: /* @__PURE__ */ h(ee, {
|
|
240
|
+
sources: E,
|
|
241
|
+
value: T,
|
|
242
242
|
onChange: (e) => {
|
|
243
|
-
|
|
243
|
+
de(e), R(""), ye(!0), X(), q("");
|
|
244
244
|
}
|
|
245
245
|
})
|
|
246
246
|
}),
|
|
247
|
-
/* @__PURE__ */
|
|
247
|
+
/* @__PURE__ */ h("h3", {
|
|
248
248
|
className: "font-medium",
|
|
249
249
|
children: "Generated SQL"
|
|
250
250
|
}),
|
|
251
|
-
Z ? /* @__PURE__ */
|
|
251
|
+
Z ? /* @__PURE__ */ h("pre", {
|
|
252
252
|
className: "max-w-full overflow-auto rounded bg-bg-surface p-2",
|
|
253
253
|
children: Z
|
|
254
|
-
}) : /* @__PURE__ */
|
|
254
|
+
}) : /* @__PURE__ */ h("p", {
|
|
255
255
|
className: "text-sm",
|
|
256
256
|
children: "Choose fields or an aggregate. Complete each filter and join, and group any projected fields when aggregating."
|
|
257
257
|
})
|
|
258
258
|
] }),
|
|
259
|
-
/* @__PURE__ */
|
|
259
|
+
/* @__PURE__ */ g("div", {
|
|
260
260
|
className: "flex flex-wrap gap-2",
|
|
261
261
|
children: [
|
|
262
|
-
/* @__PURE__ */ m
|
|
262
|
+
/* @__PURE__ */ h(m, {
|
|
263
263
|
size: "sm",
|
|
264
264
|
type: "button",
|
|
265
|
-
disabled: $ || !Q.trim() || !
|
|
266
|
-
onClick: () => void
|
|
265
|
+
disabled: $ || !Q.trim() || !E.length || N || !!P,
|
|
266
|
+
onClick: () => void Ae(),
|
|
267
267
|
children: "Run"
|
|
268
268
|
}),
|
|
269
|
-
Y && /* @__PURE__ */ m
|
|
269
|
+
Y && /* @__PURE__ */ h(m, {
|
|
270
270
|
size: "sm",
|
|
271
271
|
type: "button",
|
|
272
|
-
disabled:
|
|
273
|
-
onClick: () => void
|
|
274
|
-
children:
|
|
272
|
+
disabled: Te,
|
|
273
|
+
onClick: () => void Se(),
|
|
274
|
+
children: Te ? "Cancelling…" : "Cancel"
|
|
275
275
|
}),
|
|
276
|
-
/* @__PURE__ */ m
|
|
276
|
+
/* @__PURE__ */ h(m, {
|
|
277
277
|
size: "sm",
|
|
278
278
|
type: "button",
|
|
279
279
|
variant: "secondary",
|
|
280
280
|
disabled: !Q.trim(),
|
|
281
|
-
onClick: () => void
|
|
282
|
-
children:
|
|
281
|
+
onClick: () => void Me(),
|
|
282
|
+
children: y("bigconsole.explore.copy", "Copy draft")
|
|
283
283
|
})
|
|
284
284
|
]
|
|
285
285
|
}),
|
|
286
|
-
Y && /* @__PURE__ */
|
|
286
|
+
Y && /* @__PURE__ */ h("p", {
|
|
287
287
|
role: "status",
|
|
288
288
|
children: "Running query…"
|
|
289
289
|
}),
|
|
290
|
-
|
|
290
|
+
we && /* @__PURE__ */ h("p", {
|
|
291
291
|
role: "alert",
|
|
292
|
-
children:
|
|
292
|
+
children: we
|
|
293
293
|
}),
|
|
294
|
-
|
|
295
|
-
/* @__PURE__ */
|
|
294
|
+
Ce && /* @__PURE__ */ h(ae, { result: Ce }),
|
|
295
|
+
/* @__PURE__ */ g("fieldset", {
|
|
296
296
|
disabled: $,
|
|
297
297
|
className: "flex flex-wrap items-end gap-2",
|
|
298
298
|
children: [
|
|
299
|
-
/* @__PURE__ */
|
|
299
|
+
/* @__PURE__ */ h("legend", {
|
|
300
300
|
className: "font-medium",
|
|
301
301
|
children: "Saved queries"
|
|
302
302
|
}),
|
|
303
|
-
/* @__PURE__ */
|
|
303
|
+
/* @__PURE__ */ h(s, {
|
|
304
304
|
label: "Open saved query",
|
|
305
|
-
children: /* @__PURE__ */
|
|
305
|
+
children: /* @__PURE__ */ g("select", {
|
|
306
306
|
className: c,
|
|
307
|
-
value:
|
|
307
|
+
value: z,
|
|
308
308
|
onChange: (e) => {
|
|
309
|
-
e.target.value &&
|
|
309
|
+
e.target.value && je("open", e.target.value);
|
|
310
310
|
},
|
|
311
|
-
children: [/* @__PURE__ */
|
|
311
|
+
children: [/* @__PURE__ */ h("option", {
|
|
312
312
|
value: "",
|
|
313
313
|
children: "Choose a query"
|
|
314
|
-
}),
|
|
314
|
+
}), fe.map((e) => /* @__PURE__ */ h("option", {
|
|
315
315
|
value: e.id,
|
|
316
316
|
children: e.name
|
|
317
317
|
}, e.id))]
|
|
318
318
|
})
|
|
319
319
|
}),
|
|
320
|
-
/* @__PURE__ */
|
|
320
|
+
/* @__PURE__ */ h(s, {
|
|
321
321
|
label: "Query name",
|
|
322
|
-
children: /* @__PURE__ */
|
|
322
|
+
children: /* @__PURE__ */ h("input", {
|
|
323
323
|
className: c,
|
|
324
|
-
value:
|
|
325
|
-
onChange: (e) =>
|
|
324
|
+
value: B,
|
|
325
|
+
onChange: (e) => V(e.target.value)
|
|
326
326
|
})
|
|
327
327
|
}),
|
|
328
|
-
/* @__PURE__ */ m
|
|
328
|
+
/* @__PURE__ */ h(m, {
|
|
329
329
|
size: "sm",
|
|
330
330
|
type: "button",
|
|
331
|
-
disabled: !Q.trim() || !
|
|
332
|
-
onClick: () => void
|
|
331
|
+
disabled: !Q.trim() || !B.trim() || !!P || N || !E.length,
|
|
332
|
+
onClick: () => void je("save"),
|
|
333
333
|
children: "Save as new query"
|
|
334
334
|
}),
|
|
335
|
-
|
|
335
|
+
z && /* @__PURE__ */ h(m, {
|
|
336
336
|
size: "sm",
|
|
337
337
|
type: "button",
|
|
338
|
-
onClick: () =>
|
|
338
|
+
onClick: () => U(!H),
|
|
339
339
|
children: "Add to dashboard"
|
|
340
340
|
})
|
|
341
341
|
]
|
|
342
342
|
}),
|
|
343
|
-
|
|
343
|
+
W && /* @__PURE__ */ h("p", {
|
|
344
344
|
role: "status",
|
|
345
|
-
children:
|
|
345
|
+
children: W
|
|
346
346
|
}),
|
|
347
|
-
|
|
347
|
+
K && /* @__PURE__ */ h("p", {
|
|
348
348
|
role: "alert",
|
|
349
|
-
children:
|
|
349
|
+
children: K
|
|
350
350
|
}),
|
|
351
|
-
|
|
352
|
-
savedId:
|
|
353
|
-
name:
|
|
354
|
-
workspaceId:
|
|
355
|
-
},
|
|
356
|
-
/* @__PURE__ */
|
|
351
|
+
H && z && /* @__PURE__ */ h(oe, {
|
|
352
|
+
savedId: z,
|
|
353
|
+
name: B,
|
|
354
|
+
workspaceId: v
|
|
355
|
+
}, z),
|
|
356
|
+
/* @__PURE__ */ g("details", { children: [/* @__PURE__ */ h("summary", {
|
|
357
357
|
className: "cursor-pointer font-medium",
|
|
358
358
|
children: "Query history"
|
|
359
|
-
}),
|
|
359
|
+
}), O.length ? /* @__PURE__ */ h("ul", {
|
|
360
360
|
className: "mt-1 text-sm",
|
|
361
|
-
children:
|
|
361
|
+
children: O.map((e) => /* @__PURE__ */ g("li", { children: [
|
|
362
362
|
e.startedAt,
|
|
363
363
|
" · ",
|
|
364
364
|
e.status,
|
|
365
365
|
e.durationMs == null ? "" : " · " + e.durationMs + " ms"
|
|
366
366
|
] }, e.id))
|
|
367
|
-
}) : /* @__PURE__ */
|
|
367
|
+
}) : /* @__PURE__ */ h("p", { children: "No query runs to show." })] })
|
|
368
368
|
]
|
|
369
369
|
});
|
|
370
370
|
}
|
|
371
|
-
export {
|
|
371
|
+
export { v as default };
|
|
@@ -9,3 +9,13 @@ export type Translate = (key: string, fallback: string) => string;
|
|
|
9
9
|
* shape, including a non-2xx `ServerError` whose GraphQL body is only in `bodyText`.
|
|
10
10
|
*/
|
|
11
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;
|
|
@@ -72,4 +72,8 @@ function a(a, o) {
|
|
|
72
72
|
for (let { code: e } of s) if (Object.hasOwn(t, e)) return o(`bigconsole.explore.errors.${e}`, t[e]);
|
|
73
73
|
return s.length ? o("bigconsole.explore.errors.unknown", r) : o("bigconsole.explore.errors.network", i);
|
|
74
74
|
}
|
|
75
|
-
|
|
75
|
+
function o(e) {
|
|
76
|
+
if (e.error) throw e.error;
|
|
77
|
+
return e;
|
|
78
|
+
}
|
|
79
|
+
export { a as exploreErrorMessage, o as withoutError };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { CancelExploreDocument as e, RunExploreDocument as t } from "../../../generated/wspace-operations.js";
|
|
2
2
|
import { useOptionalTr as n } from "../../../shared/hooks/useTr.js";
|
|
3
|
-
import { exploreErrorMessage as r } from "./exploreErrors.js";
|
|
4
|
-
import { useCallback as
|
|
5
|
-
import { useApolloClient as
|
|
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";
|
|
6
6
|
// src/bigconsole/components/explore/useExploreRun.ts
|
|
7
|
-
function
|
|
7
|
+
function u(e, t) {
|
|
8
8
|
return {
|
|
9
9
|
requiredWorkspaceAuth: !0,
|
|
10
10
|
requiredWorkspaceId: e,
|
|
@@ -12,7 +12,7 @@ function l(e, t) {
|
|
|
12
12
|
fetchOptions: { signal: t }
|
|
13
13
|
};
|
|
14
14
|
}
|
|
15
|
-
function
|
|
15
|
+
function d(e, t, n) {
|
|
16
16
|
if (!Array.isArray(t) || !t.every((t) => Array.isArray(t) && t.length === e.length && t.every((e) => e === null || [
|
|
17
17
|
"boolean",
|
|
18
18
|
"number",
|
|
@@ -24,66 +24,66 @@ function u(e, t, n) {
|
|
|
24
24
|
truncated: n
|
|
25
25
|
};
|
|
26
26
|
}
|
|
27
|
-
function
|
|
28
|
-
let
|
|
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({
|
|
29
29
|
mutation: e,
|
|
30
30
|
variables: { requestId: t },
|
|
31
31
|
fetchPolicy: "no-cache",
|
|
32
|
-
context:
|
|
33
|
-
}), [
|
|
34
|
-
return
|
|
35
|
-
let e =
|
|
36
|
-
|
|
37
|
-
}, [
|
|
38
|
-
run:
|
|
39
|
-
if (
|
|
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;
|
|
40
40
|
let n = {
|
|
41
41
|
id: crypto.randomUUID(),
|
|
42
42
|
controller: new AbortController()
|
|
43
43
|
};
|
|
44
|
-
|
|
44
|
+
h.current = n, _(null), y(""), x(!0), C(!1);
|
|
45
45
|
try {
|
|
46
|
-
let r = await
|
|
46
|
+
let r = i(await p.mutate({
|
|
47
47
|
mutation: t,
|
|
48
48
|
variables: {
|
|
49
49
|
requestId: n.id,
|
|
50
50
|
...e
|
|
51
51
|
},
|
|
52
52
|
fetchPolicy: "no-cache",
|
|
53
|
-
context:
|
|
54
|
-
});
|
|
55
|
-
if (
|
|
56
|
-
let
|
|
57
|
-
if (!
|
|
58
|
-
|
|
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));
|
|
59
59
|
} catch (e) {
|
|
60
|
-
|
|
60
|
+
h.current === n && y(r(e, m));
|
|
61
61
|
} finally {
|
|
62
|
-
|
|
62
|
+
h.current === n && (h.current = null, x(!1), C(!1));
|
|
63
63
|
}
|
|
64
64
|
}, [
|
|
65
|
+
p,
|
|
65
66
|
f,
|
|
66
|
-
|
|
67
|
-
p
|
|
67
|
+
m
|
|
68
68
|
]),
|
|
69
69
|
cancel: async () => {
|
|
70
|
-
let e =
|
|
70
|
+
let e = h.current;
|
|
71
71
|
if (e) {
|
|
72
|
-
|
|
72
|
+
C(!0);
|
|
73
73
|
try {
|
|
74
|
-
await
|
|
74
|
+
i(await w(e.id));
|
|
75
75
|
} catch (t) {
|
|
76
|
-
|
|
76
|
+
h.current === e && (y(r(t, m)), C(!1));
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
79
|
},
|
|
80
|
-
running:
|
|
81
|
-
cancelling:
|
|
82
|
-
result:
|
|
83
|
-
error:
|
|
80
|
+
running: b,
|
|
81
|
+
cancelling: S,
|
|
82
|
+
result: g,
|
|
83
|
+
error: v,
|
|
84
84
|
clearResult: () => {
|
|
85
|
-
|
|
85
|
+
_(null), y("");
|
|
86
86
|
}
|
|
87
87
|
};
|
|
88
88
|
}
|
|
89
|
-
export { r as exploreError,
|
|
89
|
+
export { r as exploreError, d as tabularResult, f as useExploreRun, u as workspaceRequest };
|