@burdenoff/microfe-bigconsole 2026.1118.4 → 2026.1118.6

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.
Files changed (29) hide show
  1. package/dist/bigconsole/components/explore/CreateQueryWidget.d.ts +5 -0
  2. package/dist/bigconsole/components/explore/CreateQueryWidget.js +192 -0
  3. package/dist/bigconsole/components/explore/QueryResults.d.ts +4 -0
  4. package/dist/bigconsole/components/explore/QueryResults.js +42 -0
  5. package/dist/bigconsole/components/explore/SavedQueryWidget.d.ts +4 -0
  6. package/dist/bigconsole/components/explore/SavedQueryWidget.js +69 -0
  7. package/dist/bigconsole/components/explore/SqlDraftEditor.d.ts +3 -1
  8. package/dist/bigconsole/components/explore/SqlDraftEditor.js +336 -58
  9. package/dist/bigconsole/components/explore/SqlDraftEntry.js +11 -11
  10. package/dist/bigconsole/components/explore/VisualBuilder.d.ts +14 -0
  11. package/dist/bigconsole/components/explore/VisualBuilder.js +283 -0
  12. package/dist/bigconsole/components/explore/useExploreRun.d.ts +32 -0
  13. package/dist/bigconsole/components/explore/useExploreRun.js +104 -0
  14. package/dist/bigconsole/components/explore/visualSql.d.ts +49 -0
  15. package/dist/bigconsole/components/explore/visualSql.js +95 -0
  16. package/dist/bigconsole/components/insights/BoardLintPanel.d.ts +28 -0
  17. package/dist/bigconsole/components/insights/BoardLintPanel.js +171 -0
  18. package/dist/bigconsole/components/insights/DraftCheckDialog.d.ts +9 -3
  19. package/dist/bigconsole/components/insights/DraftCheckDialog.js +53 -146
  20. package/dist/bigconsole/components/widgets/WidgetWrapper.js +237 -228
  21. package/dist/bigconsole/hooks/useWidgetOperations.js +1 -0
  22. package/dist/bigconsole/pages/InsightsPage.js +305 -274
  23. package/dist/bigconsole/types/index.d.ts +1 -0
  24. package/dist/bigconsole/utils/boardLint.d.ts +5 -0
  25. package/dist/bigconsole/utils/boardLint.js +4 -1
  26. package/dist/generated/wspace-operations.d.ts +143 -0
  27. package/dist/generated/wspace-operations.js +1127 -73
  28. package/dist/generated/wspace-types.d.ts +93 -0
  29. package/package.json +1 -1
@@ -1,91 +1,369 @@
1
1
  import { useTr as e } from "../../../shared/hooks/useTr.js";
2
2
  import { ExpressionEditor as t } from "../parser/ExpressionEditor.js";
3
- import { useState as n } from "react";
4
- import { Button as r } from "@burdenoff/fe-libs/ui";
5
- import { useUnsavedChanges as i } from "@burdenoff/fe-libs/shared/hooks";
6
- import { jsx as a, jsxs as o } from "react/jsx-runtime";
3
+ import { ExploreHistoryDocument as n, ExploreSavedQueriesDocument as r, ExploreSavedQueryDocument as i, ExploreSourcesDocument as a, SaveExploreDocument as o } from "../../../generated/wspace-operations.js";
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 { 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";
10
+ 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";
7
14
  // src/bigconsole/components/explore/SqlDraftEditor.tsx
8
- var s = [
15
+ var _ = [
9
16
  "SELECT",
10
17
  "FROM",
11
18
  "WHERE",
19
+ "AND",
20
+ "IS NULL",
21
+ "IS NOT NULL",
22
+ "INNER JOIN",
23
+ "LEFT JOIN",
24
+ "ON",
25
+ "AS",
12
26
  "GROUP BY",
13
27
  "ORDER BY",
14
28
  "ASC",
15
29
  "DESC",
16
- "AS",
17
30
  "COUNT",
18
31
  "SUM",
19
32
  "AVG",
20
33
  "MIN",
21
34
  "MAX",
22
- "IS NULL",
23
35
  "LIMIT"
24
- ], c = (e, t) => {
25
- let n = e.getModel();
26
- if (!n) return;
27
- let r = t.languages.registerCompletionItemProvider("sql", { provideCompletionItems(e, r) {
28
- if (e !== n) return { suggestions: [] };
29
- let i = n.getWordAtPosition(r), a = new t.Range(r.lineNumber, i?.startColumn ?? r.column, r.lineNumber, i?.endColumn ?? r.column);
30
- return { suggestions: s.map((e) => ({
31
- label: e,
32
- insertText: e,
33
- kind: t.languages.CompletionItemKind.Keyword,
34
- range: a
35
- })) };
36
- } });
37
- e.onDidDispose(() => r.dispose());
38
- };
39
- function l() {
40
- let s = e(), [l, u] = n(""), [d, f] = n(""), p = s("bigconsole.assistant.unsaved.sqlDraft", "the query draft");
41
- i({
36
+ ];
37
+ 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({
42
40
  id: "bigconsole-sql-draft",
43
- label: p,
44
- dirty: l.length > 0
41
+ label: Te,
42
+ dirty: ye
45
43
  });
46
- async function m() {
44
+ let Ee = f(T);
45
+ d(() => {
46
+ Ee.current = T;
47
+ }, [T]), d(() => {
48
+ let e = new AbortController();
49
+ return J.current = e, () => {
50
+ e.abort(), J.current = null;
51
+ };
52
+ }, []), d(() => {
53
+ let e = new AbortController(), t = u(v, e.signal);
54
+ return Promise.all([
55
+ b.query({
56
+ query: a,
57
+ fetchPolicy: "no-cache",
58
+ context: t
59
+ }),
60
+ b.query({
61
+ query: r,
62
+ fetchPolicy: "no-cache",
63
+ context: t
64
+ }),
65
+ b.query({
66
+ query: n,
67
+ fetchPolicy: "no-cache",
68
+ context: t
69
+ })
70
+ ]).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
+ }
75
+ }).catch((t) => {
76
+ e.signal.aborted || (E([]), k([]), O([]), P(l(t)));
77
+ }).finally(() => {
78
+ e.signal.aborted || me(A);
79
+ }), () => e.abort();
80
+ }, [
81
+ b,
82
+ v,
83
+ A
84
+ ]);
85
+ let De = oe((e, t) => {
86
+ let n = e.getModel();
87
+ if (!n) return;
88
+ let r = t.languages.registerCompletionItemProvider("sql", {
89
+ triggerCharacters: ["."],
90
+ provideCompletionItems(e, r) {
91
+ 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;
93
+ return { suggestions: (o ? s.find((e) => e.name === o)?.fields.map((e) => e.name) ?? [] : [
94
+ ..._,
95
+ ...s.map((e) => e.name),
96
+ ...s.flatMap((e) => e.fields.map((t) => e.name + "." + t.name))
97
+ ]).map((e) => ({
98
+ label: e,
99
+ insertText: _.includes(e) ? e : e.split(".").map((e) => "\"" + e.replaceAll("\"", "\"\"") + "\"").join("."),
100
+ kind: _.includes(e) ? t.languages.CompletionItemKind.Keyword : t.languages.CompletionItemKind.Field,
101
+ range: a
102
+ })) };
103
+ }
104
+ });
105
+ e.onDidDispose(() => r.dispose());
106
+ }, []);
107
+ function Oe(e) {
108
+ w(e), I(""), H(!1), W(""), G(""), X();
109
+ }
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
+ }
113
+ async function Ae(e, t) {
114
+ let n = J.current?.signal;
115
+ if (!(!n || n.aborted || K)) {
116
+ q(!0), G(""), W(""), H(!1), X();
117
+ try {
118
+ let r = u(v, n), a = e === "open" && t ? (await b.query({
119
+ query: i,
120
+ variables: { id: t },
121
+ fetchPolicy: "no-cache",
122
+ context: r
123
+ })).data?.bigconsoleSavedQuery : (await b.mutate({
124
+ mutation: o,
125
+ variables: {
126
+ name: z.trim(),
127
+ sql: Q
128
+ },
129
+ fetchPolicy: "no-cache",
130
+ context: r
131
+ })).data?.bigconsoleSaveExplore;
132
+ if (n.aborted) return;
133
+ 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);
135
+ } catch (e) {
136
+ n.aborted || (G(l(e)), j((e) => e + 1));
137
+ } finally {
138
+ n.aborted || q(!1);
139
+ }
140
+ }
141
+ }
142
+ async function je() {
47
143
  try {
48
- await navigator.clipboard.writeText(l), f(s("bigconsole.explore.copied", "Draft copied."));
144
+ await navigator.clipboard.writeText(Q), W(y("bigconsole.explore.copied", "Draft copied."));
49
145
  } catch {
50
- f(s("bigconsole.explore.copyFailed", "Select and copy the draft in the editor."));
146
+ W(y("bigconsole.explore.copyFailed", "Select and copy the draft in the editor."));
51
147
  }
52
148
  }
53
- return /* @__PURE__ */ o("div", {
54
- className: "mt-3 space-y-3",
149
+ let $ = Y || K;
150
+ return /* @__PURE__ */ g("div", {
151
+ className: "mt-3 space-y-4",
55
152
  children: [
56
- /* @__PURE__ */ a("p", {
57
- className: "text-sm text-text-secondary",
58
- children: s("bigconsole.explore.draftHelp", "Draft SQL with keyword suggestions. Sink schemas and query execution are unavailable. Copy your draft before leaving this page.")
153
+ /* @__PURE__ */ g("section", {
154
+ "aria-label": "Authorized schema",
155
+ children: [
156
+ /* @__PURE__ */ h("h3", {
157
+ className: "font-medium",
158
+ children: "Available sources"
159
+ }),
160
+ M && /* @__PURE__ */ h("span", {
161
+ role: "status",
162
+ children: "Loading schema…"
163
+ }),
164
+ N && /* @__PURE__ */ h("p", {
165
+ role: "alert",
166
+ children: N
167
+ }),
168
+ !M && !N && !T.length && /* @__PURE__ */ h("p", { children: "No sources are authorized for this workspace." }),
169
+ /* @__PURE__ */ h("div", {
170
+ className: "flex flex-wrap gap-3",
171
+ children: T.map((e) => /* @__PURE__ */ g("details", { children: [/* @__PURE__ */ h("summary", {
172
+ className: "cursor-pointer",
173
+ children: e.name
174
+ }), /* @__PURE__ */ h("ul", {
175
+ className: "ml-4 text-sm",
176
+ children: e.fields.map((e) => /* @__PURE__ */ g("li", { children: [
177
+ e.name,
178
+ " · ",
179
+ e.type,
180
+ e.nullable ? " · nullable" : "",
181
+ e.masked ? " · masked" : ""
182
+ ] }, e.id))
183
+ })] }, e.id))
184
+ }),
185
+ /* @__PURE__ */ h("button", {
186
+ className: "mt-1 text-sm underline",
187
+ type: "button",
188
+ disabled: $ || M,
189
+ onClick: () => {
190
+ X(), j((e) => e + 1);
191
+ },
192
+ children: "Refresh schema"
193
+ })
194
+ ]
195
+ }),
196
+ /* @__PURE__ */ g("div", {
197
+ "aria-label": "Query mode",
198
+ className: "flex gap-2",
199
+ children: [/* @__PURE__ */ h(m, {
200
+ size: "sm",
201
+ type: "button",
202
+ "aria-pressed": x === "sql",
203
+ disabled: $,
204
+ onClick: () => {
205
+ S("sql"), H(!1), X(), G("");
206
+ },
207
+ children: "SQL"
208
+ }), /* @__PURE__ */ h(m, {
209
+ size: "sm",
210
+ type: "button",
211
+ "aria-pressed": x === "visual",
212
+ disabled: $,
213
+ onClick: () => {
214
+ S("visual"), H(!1), X(), G("");
215
+ },
216
+ children: "Explore"
217
+ })]
59
218
  }),
60
- /* @__PURE__ */ a(t, {
219
+ x === "sql" ? /* @__PURE__ */ h(t, {
61
220
  language: "sql",
62
- value: l,
63
- onChange: (e) => {
64
- u(e), f("");
65
- },
66
- onEditorMount: c,
221
+ value: C,
222
+ onChange: Oe,
223
+ onEditorMount: De,
224
+ readOnly: $,
67
225
  saveViewState: !1,
68
226
  inputOptions: {
69
- ariaLabel: s("bigconsole.explore.sqlEditor", "SQL editor"),
227
+ ariaLabel: y("bigconsole.explore.sqlEditor", "SQL editor"),
70
228
  wordBasedSuggestions: "off"
71
229
  }
72
- }),
73
- /* @__PURE__ */ o("div", {
74
- className: "flex items-center gap-2",
75
- children: [/* @__PURE__ */ a(r, {
76
- type: "button",
77
- size: "sm",
78
- variant: "secondary",
79
- disabled: !l.trim(),
80
- onClick: m,
81
- children: s("bigconsole.explore.copy", "Copy draft")
82
- }), /* @__PURE__ */ a("span", {
83
- role: "status",
230
+ }) : /* @__PURE__ */ g(le, { children: [
231
+ /* @__PURE__ */ h("p", {
84
232
  className: "text-sm text-text-secondary",
85
- children: d
86
- })]
87
- })
233
+ children: "Explore builds a separate query. Return to SQL to see your original text."
234
+ }),
235
+ /* @__PURE__ */ h("fieldset", {
236
+ disabled: $,
237
+ children: /* @__PURE__ */ h(ee, {
238
+ sources: T,
239
+ value: ue,
240
+ onChange: (e) => {
241
+ de(e), L(""), ve(!0), X(), G("");
242
+ }
243
+ })
244
+ }),
245
+ /* @__PURE__ */ h("h3", {
246
+ className: "font-medium",
247
+ children: "Generated SQL"
248
+ }),
249
+ Z ? /* @__PURE__ */ h("pre", {
250
+ className: "max-w-full overflow-auto rounded bg-bg-surface p-2",
251
+ children: Z
252
+ }) : /* @__PURE__ */ h("p", {
253
+ className: "text-sm",
254
+ children: "Choose fields or an aggregate. Complete each filter and join, and group any projected fields when aggregating."
255
+ })
256
+ ] }),
257
+ /* @__PURE__ */ g("div", {
258
+ className: "flex flex-wrap gap-2",
259
+ children: [
260
+ /* @__PURE__ */ h(m, {
261
+ size: "sm",
262
+ type: "button",
263
+ disabled: $ || !Q.trim() || !T.length || M || !!N,
264
+ onClick: () => void ke(),
265
+ children: "Run"
266
+ }),
267
+ Y && /* @__PURE__ */ h(m, {
268
+ size: "sm",
269
+ type: "button",
270
+ disabled: we,
271
+ onClick: () => void xe(),
272
+ children: we ? "Cancelling…" : "Cancel"
273
+ }),
274
+ /* @__PURE__ */ h(m, {
275
+ size: "sm",
276
+ type: "button",
277
+ variant: "secondary",
278
+ disabled: !Q.trim(),
279
+ onClick: () => void je(),
280
+ children: y("bigconsole.explore.copy", "Copy draft")
281
+ })
282
+ ]
283
+ }),
284
+ Y && /* @__PURE__ */ h("p", {
285
+ role: "status",
286
+ children: "Running query…"
287
+ }),
288
+ Ce && /* @__PURE__ */ h("p", {
289
+ role: "alert",
290
+ children: Ce
291
+ }),
292
+ Se && /* @__PURE__ */ h(ie, { result: Se }),
293
+ /* @__PURE__ */ g("fieldset", {
294
+ disabled: $,
295
+ className: "flex flex-wrap items-end gap-2",
296
+ children: [
297
+ /* @__PURE__ */ h("legend", {
298
+ className: "font-medium",
299
+ children: "Saved queries"
300
+ }),
301
+ /* @__PURE__ */ h(s, {
302
+ label: "Open saved query",
303
+ children: /* @__PURE__ */ g("select", {
304
+ className: c,
305
+ value: R,
306
+ onChange: (e) => {
307
+ e.target.value && Ae("open", e.target.value);
308
+ },
309
+ children: [/* @__PURE__ */ h("option", {
310
+ value: "",
311
+ children: "Choose a query"
312
+ }), fe.map((e) => /* @__PURE__ */ h("option", {
313
+ value: e.id,
314
+ children: e.name
315
+ }, e.id))]
316
+ })
317
+ }),
318
+ /* @__PURE__ */ h(s, {
319
+ label: "Query name",
320
+ children: /* @__PURE__ */ h("input", {
321
+ className: c,
322
+ value: z,
323
+ onChange: (e) => B(e.target.value)
324
+ })
325
+ }),
326
+ /* @__PURE__ */ h(m, {
327
+ size: "sm",
328
+ type: "button",
329
+ disabled: !Q.trim() || !z.trim() || !!N || M || !T.length,
330
+ onClick: () => void Ae("save"),
331
+ children: "Save as new query"
332
+ }),
333
+ R && /* @__PURE__ */ h(m, {
334
+ size: "sm",
335
+ type: "button",
336
+ onClick: () => H(!V),
337
+ children: "Add to dashboard"
338
+ })
339
+ ]
340
+ }),
341
+ U && /* @__PURE__ */ h("p", {
342
+ role: "status",
343
+ children: U
344
+ }),
345
+ ge && /* @__PURE__ */ h("p", {
346
+ role: "alert",
347
+ children: ge
348
+ }),
349
+ V && R && /* @__PURE__ */ h(ae, {
350
+ savedId: R,
351
+ name: z,
352
+ workspaceId: v
353
+ }, R),
354
+ /* @__PURE__ */ g("details", { children: [/* @__PURE__ */ h("summary", {
355
+ className: "cursor-pointer font-medium",
356
+ children: "Query history"
357
+ }), D.length ? /* @__PURE__ */ h("ul", {
358
+ className: "mt-1 text-sm",
359
+ children: D.map((e) => /* @__PURE__ */ g("li", { children: [
360
+ e.startedAt,
361
+ " · ",
362
+ e.status,
363
+ e.durationMs == null ? "" : " · " + e.durationMs + " ms"
364
+ ] }, e.id))
365
+ }) : /* @__PURE__ */ h("p", { children: "No query runs to show." })] })
88
366
  ]
89
367
  });
90
368
  }
91
- export { l as default };
369
+ export { v as default };
@@ -5,26 +5,26 @@ import { FeatureFlagProvider as a, useFeatureFlags as o } from "@burdenoff/fe-li
5
5
  import { jsx as s, jsxs as c } from "react/jsx-runtime";
6
6
  // src/bigconsole/components/explore/SqlDraftEntry.tsx
7
7
  var l = r(() => import("./SqlDraftEditor.js")), u = "bigconsole.sql-authoring", d = [u];
8
- function f() {
9
- let { error: e, getEvaluation: t } = o(), n = t(u);
10
- return e || n?.flagType !== "BOOLEAN" || n.value !== !0 || n.errorCode || n.reason !== "TARGETING_MATCH" || n.variant !== "workspace-override" ? null : /* @__PURE__ */ s(p, {});
8
+ function f({ workspaceId: e }) {
9
+ let { error: t, getEvaluation: n } = o(), r = n(u);
10
+ return t || r?.flagType !== "BOOLEAN" || r.value !== !0 || r.errorCode || r.reason !== "TARGETING_MATCH" || r.variant !== "workspace-override" ? null : /* @__PURE__ */ s(p, { workspaceId: e });
11
11
  }
12
- function p() {
13
- let r = e(), [a, o] = i(!1);
12
+ function p({ workspaceId: r }) {
13
+ let a = e(), [o, u] = i(!1);
14
14
  return /* @__PURE__ */ c("details", {
15
15
  className: "rounded-card border border-border-default bg-bg-surface p-4",
16
16
  onToggle: (e) => {
17
- e.currentTarget.open && o(!0);
17
+ e.currentTarget.open && u(!0);
18
18
  },
19
19
  children: [/* @__PURE__ */ s("summary", {
20
20
  className: `cursor-pointer font-medium text-text-primary ${t}`,
21
- children: r("bigconsole.explore.sqlEditor", "SQL editor")
22
- }), a && /* @__PURE__ */ s(n, {
21
+ children: a("bigconsole.explore.sqlEditor", "SQL editor")
22
+ }), o && /* @__PURE__ */ s(n, {
23
23
  fallback: /* @__PURE__ */ s("span", {
24
24
  role: "status",
25
- children: r("bigconsole.explore.loading", "Loading editor…")
25
+ children: a("bigconsole.explore.loading", "Loading editor…")
26
26
  }),
27
- children: /* @__PURE__ */ s(l, {})
27
+ children: /* @__PURE__ */ s(l, { workspaceId: r })
28
28
  })]
29
29
  });
30
30
  }
@@ -34,7 +34,7 @@ function m({ workspaceId: e, actorId: t }) {
34
34
  gateway: "global",
35
35
  flagKeys: d,
36
36
  defaultEnabled: !1,
37
- children: /* @__PURE__ */ s(f, {})
37
+ children: /* @__PURE__ */ s(f, { workspaceId: e })
38
38
  }, JSON.stringify([e, t]));
39
39
  }
40
40
  export { m as SqlDraftEntry };
@@ -0,0 +1,14 @@
1
+ import { ReactElement } from 'react';
2
+ import { ExploreSource, VisualQuery } from './visualSql';
3
+ export declare const controlClass = "rounded border border-border-default bg-bg-surface px-2 py-1 text-sm text-text-primary";
4
+ export declare function Control({ label, children }: {
5
+ label: string;
6
+ children: ReactElement<{
7
+ id?: string;
8
+ }>;
9
+ }): import('react').JSX.Element;
10
+ export declare function VisualBuilder({ sources, value: q, onChange, }: {
11
+ sources: readonly ExploreSource[];
12
+ value: VisualQuery;
13
+ onChange: (q: VisualQuery) => void;
14
+ }): import('react').JSX.Element;