@burdenoff/microfe-bigconsole 2026.1012.2 → 2026.1012.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.
Files changed (39) hide show
  1. package/dist/bigconsole/assistant/assistantApi.js +5 -5
  2. package/dist/bigconsole/components/builder/inspector/AppearanceSection.js +33 -18
  3. package/dist/bigconsole/components/dashboard/ExportDashboardDialog.js +123 -121
  4. package/dist/bigconsole/components/dashboard/ImportDashboardDialog.js +241 -267
  5. package/dist/bigconsole/components/dashboard/WidgetPalette.js +154 -150
  6. package/dist/bigconsole/components/embed/renderer-manifest.js +12 -0
  7. package/dist/bigconsole/components/widgets/WidgetRegistry.js +122 -1
  8. package/dist/bigconsole/components/widgets/WidgetWrapper.js +227 -224
  9. package/dist/bigconsole/components/widgets/advanced/AdvancedWidgetConfig.d.ts +10 -0
  10. package/dist/bigconsole/components/widgets/advanced/AdvancedWidgetConfig.js +113 -0
  11. package/dist/bigconsole/components/widgets/advanced/AdvancedWidgets.d.ts +10 -0
  12. package/dist/bigconsole/components/widgets/advanced/AdvancedWidgets.js +186 -0
  13. package/dist/bigconsole/components/widgets/advanced/data.d.ts +36 -0
  14. package/dist/bigconsole/components/widgets/advanced/data.js +113 -0
  15. package/dist/bigconsole/components/widgets/advanced/mapData.d.ts +10 -0
  16. package/dist/bigconsole/components/widgets/advanced/mapData.js +22 -0
  17. package/dist/bigconsole/components/widgets/advanced/waterfallData.d.ts +15 -0
  18. package/dist/bigconsole/components/widgets/advanced/waterfallData.js +28 -0
  19. package/dist/bigconsole/components/widgets/chart/charts/WaterfallChart.js +34 -37
  20. package/dist/bigconsole/components/widgets/index.js +1 -1
  21. package/dist/bigconsole/components/widgets/map-widget/MapWidget.d.ts +2 -0
  22. package/dist/bigconsole/components/widgets/map-widget/MapWidget.js +64 -63
  23. package/dist/bigconsole/graphql/widgetCapabilities.d.ts +7 -0
  24. package/dist/bigconsole/graphql/widgetCapabilities.js +37 -0
  25. package/dist/bigconsole/hooks/useExportDashboard.js +62 -38
  26. package/dist/bigconsole/hooks/useImportDashboard.d.ts +2 -12
  27. package/dist/bigconsole/hooks/useImportDashboard.js +95 -126
  28. package/dist/bigconsole/hooks/useWidgetCatalog.js +46 -41
  29. package/dist/bigconsole/hooks/useWidgetOperations.js +113 -88
  30. package/dist/bigconsole/renderers/adapters/BigConsoleRenderer.js +8 -5
  31. package/dist/bigconsole/types/index.d.ts +1 -1
  32. package/dist/bigconsole/utils/advancedWidgetCapabilities.d.ts +14 -0
  33. package/dist/bigconsole/utils/advancedWidgetCapabilities.js +36 -0
  34. package/dist/bigconsole/utils/widgetTypeMapping.d.ts +1 -1
  35. package/dist/bigconsole/utils/widgetTypeMapping.js +13 -2
  36. package/dist/generated/wspace-operations.d.ts +61 -2
  37. package/dist/generated/wspace-operations.js +44 -18
  38. package/dist/generated/wspace-types.d.ts +34 -3
  39. package/package.json +1 -1
@@ -1,9 +1,11 @@
1
- import { GetDashboardDocument as e, ImportDashboardDocument as t, UpdateDashboardDocument as n, ValidateDashboardImportDocument as r } from "../../generated/wspace-operations.js";
2
- import { createBigConsoleQuotaError as i, isBigConsoleQuotaError as a } from "../utils/quota.js";
3
- import { useCallback as o, useState as s } from "react";
4
- import { useApolloClient as c } from "@apollo/client/react";
1
+ import { ImportDashboardDocument as e, ValidateDashboardImportDocument as t } from "../../generated/wspace-operations.js";
2
+ import { useBigConsole as n } from "../context/BigConsoleContext.js";
3
+ import "../context/index.js";
4
+ import { createBigConsoleQuotaError as r, isBigConsoleQuotaError as i } from "../utils/quota.js";
5
+ import { useCallback as a, useLayoutEffect as o, useRef as s, useState as c } from "react";
6
+ import { useApolloClient as l } from "@apollo/client/react";
5
7
  //#region src/bigconsole/hooks/useImportDashboard.ts
6
- function l(e) {
8
+ function u(e) {
7
9
  return new Promise((t, n) => {
8
10
  let r = new FileReader();
9
11
  r.onload = (e) => {
@@ -12,148 +14,115 @@ function l(e) {
12
14
  }, r.onerror = () => n(/* @__PURE__ */ Error("Failed to read file")), r.readAsText(e);
13
15
  });
14
16
  }
15
- function u(e) {
16
- if (e == null) return e;
17
- if (Array.isArray(e)) return e.map((e) => u(e));
18
- if (typeof e == "object") {
19
- let t = {};
20
- for (let [n, r] of Object.entries(e)) n !== "__typename" && (t[n] = u(r));
21
- return t;
22
- }
23
- return e;
24
- }
25
- function d(e) {
26
- try {
27
- let t = JSON.parse(e);
28
- return t.exportedFrom?.dashboardId || t.dashboard?.id || null;
29
- } catch {
30
- return null;
31
- }
32
- }
33
- function f() {
34
- let [f, p] = s(!1), [m, h] = s(null), [g, _] = s(null), [v, y] = s(null), b = c(), x = o(async (e) => {
17
+ function d() {
18
+ let [d, f] = c(!1), [p, m] = c(null), [h, g] = c(null), [_, v] = c(null), y = l(), { currentUser: b, workspaceId: x } = n(), S = `${b?.id ?? ""}|${x ?? ""}`, C = s(S), w = s(0);
19
+ o(() => (C.current = S, w.current++, f(!1), m(null), g(null), v(null), () => {
20
+ C.current = "";
21
+ }), [S]);
22
+ let T = a(() => {
23
+ if (!x || !b?.id || C.current !== S) throw Error("Select a workspace before importing a dashboard.");
24
+ return {
25
+ requiredWorkspaceAuth: !0,
26
+ requiredWorkspaceId: x,
27
+ queryDeduplication: !1
28
+ };
29
+ }, [
30
+ x,
31
+ b?.id,
32
+ S
33
+ ]), E = a(async (e) => {
34
+ let n = ++w.current, r = () => C.current === S && w.current === n;
35
35
  try {
36
- p(!0), h(null);
37
- let t = (await b.query({
38
- query: r,
36
+ let n = T();
37
+ f(!0), m(null), g(null), v(null);
38
+ let i = await y.query({
39
+ query: t,
39
40
  variables: { content: e },
40
- fetchPolicy: "network-only"
41
- })).data?.validateDashboardImport;
42
- if (t) return _(t), t;
41
+ fetchPolicy: "no-cache",
42
+ errorPolicy: "none",
43
+ context: n
44
+ });
45
+ if (!r()) return null;
46
+ if (i.error) throw i.error;
47
+ let a = i.data?.validateDashboardImport;
48
+ if (a) return g(a), a;
43
49
  throw Error("Validation returned empty result");
44
50
  } catch (e) {
45
- return h(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to validate import")), null;
51
+ return r() && m(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to validate import")), null;
46
52
  } finally {
47
- p(!1);
53
+ r() && f(!1);
48
54
  }
49
- }, [b]), S = o(async (r, o = {}) => {
55
+ }, [
56
+ y,
57
+ S,
58
+ T
59
+ ]), D = a(async (t, n = {}) => {
60
+ let a = ++w.current, o = () => C.current === S && w.current === a;
50
61
  try {
51
- p(!0), h(null);
52
- let s = JSON.parse(r).dashboard, c = d(r), l = !1, f;
53
- if (c) try {
54
- let t = (await b.query({
55
- query: e,
56
- variables: { id: c },
57
- fetchPolicy: "network-only"
58
- })).data?.getDashboard;
59
- if (t) {
60
- if ((t.description || "") !== (s.description || "") || t.category !== s.category || t.visibility !== s.visibility || JSON.stringify(t.layout) !== JSON.stringify(s.layout) || JSON.stringify(t.metadata) !== JSON.stringify(s.metadata) || JSON.stringify(t.context) !== JSON.stringify(s.context)) {
61
- let e = {
62
- id: c,
63
- name: t.name,
64
- description: s.description || void 0,
65
- category: s.category || void 0,
66
- layout: u(s.layout) || void 0,
67
- visibility: s.visibility || void 0,
68
- metadata: u(s.metadata) || void 0,
69
- context: u(s.context) || void 0,
70
- translations: u(s.translations) || void 0
71
- }, r = (await b.mutate({
72
- mutation: n,
73
- variables: { input: e }
74
- })).data?.updateBigConsoleDashboard;
75
- r && (l = !0, f = {
76
- id: r.id,
77
- name: r.name
78
- });
79
- } else {
80
- f = {
81
- id: t.id,
82
- name: t.name
83
- };
84
- let e = {
85
- success: !0,
86
- dashboard: f,
87
- originalUpdated: !1,
88
- originalDashboard: f,
89
- alreadyExists: !0
90
- };
91
- return y(e), e;
92
- }
93
- let e = {
94
- success: !0,
95
- dashboard: f,
96
- originalUpdated: l,
97
- originalDashboard: f,
98
- alreadyExists: !1
99
- };
100
- return y(e), e;
101
- }
102
- } catch (e) {
103
- console.warn("Could not fetch original dashboard:", e);
104
- }
105
- let m = await b.mutate({
106
- mutation: t,
62
+ let a = T();
63
+ f(!0), m(null), v(null);
64
+ let s = await y.mutate({
65
+ mutation: e,
107
66
  variables: { input: {
108
- content: r,
109
- name: o.name,
110
- visibility: o.visibility,
111
- skipWarnings: o.skipWarnings ?? !1
112
- } }
67
+ content: t,
68
+ name: n.name,
69
+ visibility: n.visibility,
70
+ skipWarnings: n.skipWarnings ?? !1
71
+ } },
72
+ errorPolicy: "none",
73
+ context: a
113
74
  });
114
- if (a(m)) throw i(m);
115
- let g = m.data?.importBigConsoleDashboard;
116
- if (g) {
117
- let e = {
118
- ...g,
119
- originalUpdated: !1,
120
- originalDashboard: void 0
121
- };
122
- return y(e), e;
123
- }
124
- throw Error("Import returned empty result");
75
+ if (!o()) return null;
76
+ if (i(s)) throw r(s);
77
+ if (s.error) throw s.error;
78
+ let c = s.data?.importBigConsoleDashboard;
79
+ if (!c) throw Error("Import returned empty result");
80
+ if (c.success && !c.dashboard?.id) throw Error("Import returned no dashboard");
81
+ return v(c), c;
125
82
  } catch (e) {
126
- if (a(e)) throw e;
127
- return h(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to import dashboard")), null;
83
+ if (!o()) return null;
84
+ if (i(e)) throw e;
85
+ return m(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to import dashboard")), null;
128
86
  } finally {
129
- p(!1);
87
+ o() && f(!1);
130
88
  }
131
- }, [b]);
89
+ }, [
90
+ y,
91
+ S,
92
+ T
93
+ ]);
132
94
  return {
133
- loading: f,
134
- error: m,
135
- validationResult: g,
136
- importResult: v,
137
- validateImport: x,
138
- importDashboard: S,
139
- importFromFile: o(async (e, t = {}) => {
95
+ loading: d,
96
+ error: p,
97
+ validationResult: h,
98
+ importResult: _,
99
+ validateImport: E,
100
+ importDashboard: D,
101
+ importFromFile: a(async (e, t = {}) => {
102
+ let n = ++w.current, r = () => C.current === S && w.current === n, i;
140
103
  try {
141
- if (!e.name.endsWith(".json")) throw Error("Invalid file type. Please select a JSON file.");
142
- let n = await l(e);
104
+ if (T(), f(!0), m(null), g(null), v(null), !e.name.toLowerCase().endsWith(".json")) throw Error("Invalid file type. Please select a JSON file.");
105
+ if (i = await u(e), !r()) return null;
143
106
  try {
144
- JSON.parse(n);
107
+ JSON.parse(i);
145
108
  } catch {
146
109
  throw Error("Invalid JSON format. Please select a valid export file.");
147
110
  }
148
- return await S(n, t);
149
111
  } catch (e) {
150
- return h(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to import from file")), null;
112
+ return r() && m(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to import from file")), null;
113
+ } finally {
114
+ r() && f(!1);
151
115
  }
152
- }, [S]),
153
- clearState: o(() => {
154
- h(null), _(null), y(null);
116
+ return r() ? D(i, t) : null;
117
+ }, [
118
+ D,
119
+ S,
120
+ T
121
+ ]),
122
+ clearState: a(() => {
123
+ w.current++, f(!1), m(null), g(null), v(null);
155
124
  }, [])
156
125
  };
157
126
  }
158
127
  //#endregion
159
- export { f as default };
128
+ export { d as default };
@@ -1,26 +1,27 @@
1
- import { GetWidgetTypesDocument as e } from "../../generated/wspace-operations.js";
1
+ import { loadNativeWidgetCatalog as e } from "../graphql/widgetCapabilities.js";
2
2
  import t, { WIDGET_CATEGORY_LABELS as n, getAllWidgetDefinitions as r, getWidgetDefinition as i } from "../components/widgets/WidgetRegistry.js";
3
3
  import { isFederationAccessible as a, mapFromFederationWidgetType as o } from "../utils/widgetTypeMapping.js";
4
- import { useEffect as s, useMemo as c } from "react";
5
- import { useQuery as l } from "@tanstack/react-query";
6
- import { print as u } from "graphql";
4
+ import { filterAdvancedWidgetDefinitions as s, nativeFederationTypes as c } from "../utils/advancedWidgetCapabilities.js";
5
+ import { useEffect as l, useLayoutEffect as u, useMemo as d, useRef as f } from "react";
6
+ import { useApolloClient as p } from "@apollo/client/react";
7
+ import { useQuery as m } from "@tanstack/react-query";
7
8
  //#region src/bigconsole/hooks/useWidgetCatalog.ts
8
- var d = new Set(Object.keys(n)), f = "Puzzle", p = "Installed";
9
- function m(e) {
9
+ var h = new Set(Object.keys(n)), g = "Puzzle", _ = "Installed";
10
+ function v(e) {
10
11
  let n = String(e).toLowerCase();
11
12
  return Object.prototype.hasOwnProperty.call(t, n) || a(e);
12
13
  }
13
- function h(e) {
14
+ function y(e) {
14
15
  let n = String(e).toLowerCase();
15
16
  return Object.prototype.hasOwnProperty.call(t, n) ? n : o(e);
16
17
  }
17
- function g(e) {
18
+ function b(e) {
18
19
  return {
19
20
  type: "custom",
20
21
  name: e.label,
21
22
  description: e.description,
22
- icon: e.icon || f,
23
- category: p,
23
+ icon: e.icon || g,
24
+ category: _,
24
25
  component: null,
25
26
  defaultConfig: {
26
27
  ...e.defaultConfig ?? {},
@@ -51,9 +52,9 @@ function g(e) {
51
52
  tags: ["store", "installed"]
52
53
  };
53
54
  }
54
- function _(e) {
55
- if (!m(e.type)) return g(e);
56
- let t = h(e.type), n = i(t), r = d.has(e.category) ? e.category : n.category;
55
+ function x(e) {
56
+ if (!v(e.type)) return b(e);
57
+ let t = y(e.type), n = i(t), r = h.has(e.category) ? e.category : n.category;
57
58
  return {
58
59
  type: t,
59
60
  name: e.label,
@@ -81,42 +82,46 @@ function _(e) {
81
82
  tags: n.tags
82
83
  };
83
84
  }
84
- function v(t = {}) {
85
- let { workspaceId: n, apiGatewayUrl: i, authToken: a, enabled: o = !0 } = t, { data: d, isLoading: f, error: p } = l({
86
- queryKey: ["widgetCatalog", n],
85
+ function S(t = {}) {
86
+ let { workspaceId: n, apiGatewayUrl: i, enabled: a = !0 } = t, o = p(), h = f(n);
87
+ u(() => (h.current = a ? n : void 0, () => {
88
+ h.current = void 0;
89
+ }), [n, a]);
90
+ let { data: g, isLoading: _, error: v } = m({
91
+ queryKey: [
92
+ "widgetCatalog",
93
+ n,
94
+ i
95
+ ],
87
96
  queryFn: async () => {
88
- let t = { "Content-Type": "application/json" };
89
- n && (t["x-workspace-id"] = n), a && (t.Authorization = `Bearer ${a}`);
90
- let r = i ? `${i}/workspaces/graphql` : "/workspaces/graphql", o = await fetch(r, {
91
- method: "POST",
92
- headers: t,
93
- body: JSON.stringify({ query: u(e) })
94
- });
95
- if (!o.ok) throw Error(`Failed to fetch widget catalog: ${o.status}`);
96
- let s = await o.json();
97
- if (s.errors?.length) throw Error(s.errors[0].message);
98
- return s.data?.getWidgetTypes ?? [];
97
+ if (!n || h.current !== n) throw Error("Widget catalog workspace changed.");
98
+ let t = await e(o, n);
99
+ if (h.current !== n) throw Error("Widget catalog workspace changed.");
100
+ return t;
99
101
  },
100
- enabled: o && !!n,
102
+ enabled: a && !!n,
101
103
  staleTime: 600 * 1e3
102
104
  });
103
- return s(() => {
104
- p && console.warn("Falling back to bundled widget registry:", p.message);
105
- }, [p]), c(() => d && d.length > 0 ? {
106
- definitions: d.map(_),
105
+ l(() => {
106
+ v && console.warn("Falling back to bundled widget registry:", v.message);
107
+ }, [v]);
108
+ let y = g?.getWidgetTypes, b = d(() => c(g?.getWidgetTypes ?? []), [g]);
109
+ return d(() => y && y.length > 0 ? {
110
+ definitions: s(y.map(x), b),
107
111
  source: "backend",
108
- loading: f,
109
- error: p ?? void 0
112
+ loading: _,
113
+ error: v ?? void 0
110
114
  } : {
111
- definitions: r(),
115
+ definitions: s(r(), b),
112
116
  source: "static",
113
- loading: f,
114
- error: p ?? void 0
117
+ loading: _,
118
+ error: v ?? void 0
115
119
  }, [
116
- d,
117
- f,
118
- p
120
+ y,
121
+ b,
122
+ _,
123
+ v
119
124
  ]);
120
125
  }
121
126
  //#endregion
122
- export { v as default };
127
+ export { S as default };