@burdenoff/microfe-bigconsole 2026.1124.3 → 2026.1124.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.
@@ -0,0 +1,50 @@
1
+ import { PreviewCopyBindingsDocument as e, SetCopyBindingsDocument as t } from "../../generated/wspace-operations.js";
2
+ import { useCallback as n, useState as r } from "react";
3
+ import { useApolloClient as i } from "@apollo/client/react";
4
+ // src/bigconsole/hooks/useFleetBindingActions.ts
5
+ var a = (e) => e === "APPLIED" ? "APPLIED" : e === "UNCHANGED" ? "UNCHANGED" : "INCOMPATIBLE", o = (e) => ({
6
+ preview: e.preview,
7
+ appliedCount: e.appliedCount,
8
+ copies: e.copies.map((e) => ({
9
+ dashboardId: e.dashboardId,
10
+ name: e.name ?? null,
11
+ state: a(e.state),
12
+ reasonCode: e.reasonCode ?? null,
13
+ reason: e.reason ?? null,
14
+ widgetsRebound: e.widgetsRebound,
15
+ widgetsKeptLocal: e.widgetsKeptLocal
16
+ }))
17
+ });
18
+ function s() {
19
+ let a = i(), [s, c] = r(!1), l = n(async (e) => {
20
+ c(!0);
21
+ try {
22
+ return await e();
23
+ } finally {
24
+ c(!1);
25
+ }
26
+ }, []);
27
+ return {
28
+ busy: s,
29
+ preview: n((t) => l(async () => {
30
+ let n = (await a.query({
31
+ query: e,
32
+ variables: { input: t },
33
+ fetchPolicy: "no-cache",
34
+ errorPolicy: "none"
35
+ })).data?.previewCopyBindings;
36
+ if (!n) throw Error("The preview could not be made.");
37
+ return o(n);
38
+ }), [a, l]),
39
+ apply: n((e) => l(async () => {
40
+ let n = (await a.mutate({
41
+ mutation: t,
42
+ variables: { input: e },
43
+ errorPolicy: "none"
44
+ })).data?.setCopyBindings;
45
+ if (!n) throw Error("The data sources could not be changed.");
46
+ return o(n);
47
+ }), [a, l])
48
+ };
49
+ }
50
+ export { s as useFleetBindingActions };
@@ -0,0 +1,19 @@
1
+ import { CopyBinding, MasterSources } from '../utils/fleetBindings';
2
+ export interface SinkChoice {
3
+ id: string;
4
+ name: string;
5
+ isActive: boolean;
6
+ }
7
+ /** One request for up to COPIES_PER_REQUEST copies: each is an alias of the same field. */
8
+ export declare const bindingsBatchDocument: (count: number) => import('graphql').DocumentNode;
9
+ interface UseFleetBindingsResult {
10
+ loading: boolean;
11
+ error: Error | null;
12
+ master: MasterSources;
13
+ sinks: ReadonlyMap<string, SinkChoice>;
14
+ sinksTruncated: boolean;
15
+ bindings: ReadonlyMap<string, readonly CopyBinding[]>;
16
+ refetch: () => Promise<void>;
17
+ }
18
+ export declare function useFleetBindings(masterId: string, copyIds: readonly string[], enabled: boolean): UseFleetBindingsResult;
19
+ export {};
@@ -0,0 +1,140 @@
1
+ import "../context/index.js";
2
+ import { useBigConsole as e } from "../context/BigConsoleContext.js";
3
+ import { FleetDataSinkChoicesDocument as t, FleetMasterSourcesDocument as n } from "../../generated/wspace-operations.js";
4
+ import { masterSources as r } from "../utils/fleetBindings.js";
5
+ import { useCallback as i, useEffect as a, useLayoutEffect as o, useRef as s, useState as c } from "react";
6
+ import { useApolloClient as l } from "@apollo/client/react";
7
+ import { gql as u } from "@apollo/client";
8
+ // src/bigconsole/hooks/useFleetBindings.ts
9
+ var d = 10, f = 100, p = 20, m = (e) => u`query FleetCopyBindings(${Array.from({ length: e }, (e, t) => `$c${t}: ID!`).join(", ")}) {
10
+ ${Array.from({ length: e }, (e, t) => `c${t}: dashboardBindings(dashboardId: $c${t}) { kind masterRefId copyRefId }`).join("\n ")}
11
+ }`, h = (e) => typeof e == "object" && !!e && "kind" in e && typeof e.kind == "string" && "masterRefId" in e && typeof e.masterRefId == "string" && "copyRefId" in e && typeof e.copyRefId == "string", g = {
12
+ key: "",
13
+ master: {
14
+ sinks: [],
15
+ otherSourceWidgets: 0
16
+ },
17
+ sinks: /* @__PURE__ */ new Map(),
18
+ sinksTruncated: !1,
19
+ bindings: /* @__PURE__ */ new Map(),
20
+ error: null
21
+ };
22
+ function _(u, _, v) {
23
+ let { workspaceId: y, currentUser: b } = e(), x = l(), S = [..._].sort().join(","), C = `${y ?? ""}:${b?.id ?? ""}:${u}:${S}`, [w, T] = c(g), [E, D] = c(v), O = s(C), k = s(0);
24
+ o(() => (O.current = C, () => {
25
+ O.current = "", k.current += 1;
26
+ }), [C]);
27
+ let A = i(async () => {
28
+ if (O.current !== C) return;
29
+ let e = ++k.current, i = () => O.current === C && k.current === e, a = {
30
+ requiredWorkspaceAuth: !0,
31
+ requiredWorkspaceId: y,
32
+ queryDeduplication: !1
33
+ }, o = S ? S.split(",") : [];
34
+ try {
35
+ D(!0);
36
+ let e = async () => {
37
+ let e = await x.query({
38
+ query: n,
39
+ variables: { dashboardId: u },
40
+ fetchPolicy: "no-cache",
41
+ errorPolicy: "none",
42
+ context: a
43
+ });
44
+ return r(e.data?.listWidgetsByDashboard ?? []);
45
+ }, s = async (e) => {
46
+ let n = (await x.query({
47
+ query: t,
48
+ variables: {
49
+ first: f,
50
+ after: e
51
+ },
52
+ fetchPolicy: "no-cache",
53
+ errorPolicy: "none",
54
+ context: a
55
+ })).data?.listDataSinks;
56
+ return {
57
+ nodes: (n?.edges ?? []).map((e) => ({
58
+ id: e.node.id,
59
+ name: e.node.name ?? e.node.id,
60
+ isActive: e.node.isActive
61
+ })),
62
+ next: n?.pageInfo.hasNextPage ? n.pageInfo.endCursor ?? null : null
63
+ };
64
+ }, [c, l, g] = await Promise.all([
65
+ e(),
66
+ (async () => {
67
+ let e = /* @__PURE__ */ new Map(), t = null;
68
+ for (let n = 0; n < p; n += 1) {
69
+ let n = await s(t);
70
+ for (let t of n.nodes) e.set(t.id, t);
71
+ if (n.next === null) return {
72
+ sinks: e,
73
+ truncated: !1
74
+ };
75
+ t = n.next;
76
+ }
77
+ return {
78
+ sinks: e,
79
+ truncated: !0
80
+ };
81
+ })(),
82
+ (async () => {
83
+ let e = [];
84
+ for (let t = 0; t < o.length; t += d) e.push(o.slice(t, t + d));
85
+ let t = /* @__PURE__ */ new Map();
86
+ return await Promise.all(e.map(async (e) => {
87
+ let n = await x.query({
88
+ query: m(e.length),
89
+ variables: Object.fromEntries(e.map((e, t) => [`c${t}`, e])),
90
+ fetchPolicy: "no-cache",
91
+ errorPolicy: "none",
92
+ context: a
93
+ });
94
+ e.forEach((e, r) => {
95
+ let i = n.data?.[`c${r}`];
96
+ if (!Array.isArray(i)) throw Error("The data sources of a copy could not be read");
97
+ t.set(e, i.filter(h));
98
+ });
99
+ })), t;
100
+ })()
101
+ ]);
102
+ i() && T({
103
+ key: C,
104
+ master: c,
105
+ sinks: l.sinks,
106
+ sinksTruncated: l.truncated,
107
+ bindings: g,
108
+ error: null
109
+ });
110
+ } catch (e) {
111
+ i() && T({
112
+ ...g,
113
+ key: C,
114
+ error: e instanceof Error ? e : /* @__PURE__ */ Error("Failed to load the data sources")
115
+ });
116
+ } finally {
117
+ i() && D(!1);
118
+ }
119
+ }, [
120
+ x,
121
+ S,
122
+ C,
123
+ u,
124
+ y
125
+ ]);
126
+ a(() => {
127
+ v && A();
128
+ }, [v, A]);
129
+ let j = w.key === C;
130
+ return {
131
+ loading: v && (E || !j),
132
+ error: j ? w.error : null,
133
+ master: j ? w.master : g.master,
134
+ sinks: j ? w.sinks : g.sinks,
135
+ sinksTruncated: j ? w.sinksTruncated : !1,
136
+ bindings: j ? w.bindings : g.bindings,
137
+ refetch: A
138
+ };
139
+ }
140
+ export { m as bindingsBatchDocument, _ as useFleetBindings };
@@ -0,0 +1,49 @@
1
+ import { BigConsoleLinkBindingKind } from '../../generated/wspace-types';
2
+ /** What a widget reads from, by id. */
3
+ export interface WidgetSources {
4
+ dataSinkId?: string | null;
5
+ parserId?: string | null;
6
+ savedQueryId?: string | null;
7
+ }
8
+ export interface MasterSink {
9
+ id: string;
10
+ /** How many of the master's widgets read it. */
11
+ widgetCount: number;
12
+ }
13
+ export interface MasterSources {
14
+ sinks: MasterSink[];
15
+ /** Widgets that read through a parser or a saved query, whose source cannot be swapped here. */
16
+ otherSourceWidgets: number;
17
+ }
18
+ /** The data sinks the master's widgets read, most used first, and how many widgets read some other way. */
19
+ export declare function masterSources(widgets: readonly WidgetSources[]): MasterSources;
20
+ /** A copy's data source in place of one of the master's, as the server holds it. */
21
+ export interface CopyBinding {
22
+ kind: string;
23
+ masterRefId: string;
24
+ copyRefId: string;
25
+ }
26
+ /** What the copy reads in place of the master's data sink `from`: its own sink, or null for the master's. */
27
+ export declare function currentSink(bindings: readonly CopyBinding[] | undefined, from: string): string | null;
28
+ /** What a person has chosen: for each of the master's data sinks, for each copy, its sink (null = the master's). */
29
+ export type BindingDraft = Record<string, Record<string, string | null>>;
30
+ /** The choice for one copy and one master sink: what was picked, or what the copy reads now. */
31
+ export declare function chosenSink(draft: BindingDraft, bindings: ReadonlyMap<string, readonly CopyBinding[]>, copyId: string, from: string): string | null;
32
+ /** A choice made again to what the copy already reads is not a change: it is dropped from the draft. */
33
+ export declare function withChoice(draft: BindingDraft, bindings: ReadonlyMap<string, readonly CopyBinding[]>, copyId: string, from: string, to: string | null): BindingDraft;
34
+ export interface BindingsInput {
35
+ masterDashboardId: string;
36
+ copies: Array<{
37
+ copyDashboardId: string;
38
+ swaps: Array<{
39
+ from: string;
40
+ kind: BigConsoleLinkBindingKind;
41
+ to: string | null;
42
+ }>;
43
+ }>;
44
+ }
45
+ /**
46
+ * The request a draft amounts to: one entry per copy that changes, each with only the swaps that change it.
47
+ * Null when nothing changes, so there is nothing to preview. `copyIds` keeps the copies in the order shown.
48
+ */
49
+ export declare function bindingsInput(masterDashboardId: string, draft: BindingDraft, copyIds: readonly string[]): BindingsInput | null;
@@ -0,0 +1,52 @@
1
+ import { BigConsoleLinkBindingKind as e } from "../../generated/wspace-types.js";
2
+ // src/bigconsole/utils/fleetBindings.ts
3
+ function t(e) {
4
+ let t = /* @__PURE__ */ new Map(), n = 0;
5
+ for (let r of e) r.dataSinkId && t.set(r.dataSinkId, (t.get(r.dataSinkId) ?? 0) + 1), (r.parserId || r.savedQueryId) && (n += 1);
6
+ return {
7
+ sinks: [...t.entries()].map(([e, t]) => ({
8
+ id: e,
9
+ widgetCount: t
10
+ })).sort((e, t) => t.widgetCount - e.widgetCount || e.id.localeCompare(t.id)),
11
+ otherSourceWidgets: n
12
+ };
13
+ }
14
+ function n(e, t) {
15
+ let n = e?.find((e) => e.kind === "DATA_SINK" && e.masterRefId === t);
16
+ return n ? n.copyRefId : null;
17
+ }
18
+ function r(e, t, r, i) {
19
+ let a = e[i]?.[r];
20
+ return a === void 0 ? n(t.get(r), i) : a;
21
+ }
22
+ function i(e, t, r, i, a) {
23
+ let o = {
24
+ ...e,
25
+ [i]: { ...e[i] }
26
+ };
27
+ return a === n(t.get(r), i) ? (delete o[i]?.[r], Object.keys(o[i] ?? {}).length === 0 && delete o[i]) : o[i] = {
28
+ ...o[i],
29
+ [r]: a
30
+ }, o;
31
+ }
32
+ function a(t, n, r) {
33
+ let i = r.flatMap((t) => {
34
+ let r = Object.keys(n).sort().flatMap((r) => {
35
+ let i = n[r]?.[t];
36
+ return i === void 0 ? [] : [{
37
+ from: r,
38
+ kind: e.DataSink,
39
+ to: i
40
+ }];
41
+ });
42
+ return r.length > 0 ? [{
43
+ copyDashboardId: t,
44
+ swaps: r
45
+ }] : [];
46
+ });
47
+ return i.length > 0 ? {
48
+ masterDashboardId: t,
49
+ copies: i
50
+ } : null;
51
+ }
52
+ export { a as bindingsInput, r as chosenSink, n as currentSink, t as masterSources, i as withChoice };
@@ -50,6 +50,23 @@ export type BigConsoleAsOfUnavailableReason =
50
50
  /** The history could not be read. */
51
51
  | 'READ_FAILED';
52
52
  export type BigConsoleAskStatus = 'CLARIFICATION_NEEDED' | 'INSUFFICIENT_DATA' | 'NO_MATCHING_DATA' | 'REFUSED' | 'UNAVAILABLE' | 'UNSUPPORTED' | 'VERIFIED';
53
+ /** How one copy ended up */
54
+ export type BigConsoleBindingCopyState =
55
+ /** The copy uses its own data sources now */
56
+ 'APPLIED'
57
+ /** The copy could not take the change, and nothing was written for it. See the reason. */
58
+ | 'INCOMPATIBLE'
59
+ /** The copy already used them */
60
+ | 'UNCHANGED';
61
+ /** One change to a copy's data sources */
62
+ export type BigConsoleBindingSwapInput = {
63
+ /** The one the master's widgets use */
64
+ from: string | number;
65
+ /** What kind of data source */
66
+ kind: BigConsoleLinkBindingKind;
67
+ /** The one the copy uses instead. Null puts the copy back on the master's. */
68
+ to?: string | number | null | undefined;
69
+ };
53
70
  /** What kind of source item a report row describes. */
54
71
  export type BigConsoleBoardMigrationItemKind = 'FILTER' | 'WIDGET';
55
72
  /** What kind of query a source card ran. */
@@ -107,6 +124,13 @@ export type BigConsoleConflictResolution =
107
124
  | 'REMOTE_WINS'
108
125
  /** Rename on conflict (bigconsole native) */
109
126
  | 'RENAME';
127
+ /** The changes for one copy */
128
+ export type BigConsoleCopyBindingsInput = {
129
+ /** The copy. It must be an active direct copy of the master. */
130
+ copyDashboardId: string | number;
131
+ /** Its changes */
132
+ swaps: Array<BigConsoleBindingSwapInput>;
133
+ };
110
134
  export type BigConsoleCreateDashboardEmbedPolicyInput = {
111
135
  /** Exact HTTPS origins allowed to frame the embed (frame-ancestors). */
112
136
  allowedParentOrigins: Array<string>;
@@ -784,6 +808,14 @@ export type BigConsoleKpiReconciliationTieScope =
784
808
  | 'NONE'
785
809
  /** The card value equals the records' total for the period. */
786
810
  | 'PERIOD';
811
+ /** A kind of data source a copy can use in place of the master's */
812
+ export type BigConsoleLinkBindingKind =
813
+ /** A data sink */
814
+ 'DATA_SINK'
815
+ /** A parser */
816
+ | 'PARSER'
817
+ /** A saved query */
818
+ | 'SAVED_QUERY';
787
819
  /** Input for linking an existing board under a master */
788
820
  export type BigConsoleLinkDashboardInput = {
789
821
  /**
@@ -903,6 +935,13 @@ export type BigConsoleRestoreNoticeCode =
903
935
  * that board's default page
904
936
  */
905
937
  'DRILLDOWN_PAGE_MISSING';
938
+ /** Re-point copies of a master at their own data sources */
939
+ export type BigConsoleSetCopyBindingsInput = {
940
+ /** The copies to change, each with its own data sources. A copy can be named once. */
941
+ copies: Array<BigConsoleCopyBindingsInput>;
942
+ /** The master */
943
+ masterDashboardId: string | number;
944
+ };
906
945
  /** Input for sharing a dashboard */
907
946
  export type BigConsoleShareDashboardInput = {
908
947
  /** Dashboard ID to share */
@@ -5699,6 +5738,24 @@ export type RestoreWidgetToOriginalMutation = {
5699
5738
  }>;
5700
5739
  };
5701
5740
  };
5741
+ export type SetCopyBindingsMutationVariables = Exact<{
5742
+ input: Types.BigConsoleSetCopyBindingsInput;
5743
+ }>;
5744
+ export type SetCopyBindingsMutation = {
5745
+ setCopyBindings: {
5746
+ preview: boolean;
5747
+ appliedCount: number;
5748
+ copies: Array<{
5749
+ dashboardId: string;
5750
+ name: string | null;
5751
+ state: Types.BigConsoleBindingCopyState;
5752
+ reasonCode: string | null;
5753
+ reason: string | null;
5754
+ widgetsRebound: number;
5755
+ widgetsKeptLocal: number;
5756
+ }>;
5757
+ };
5758
+ };
5702
5759
  export type SetDashboardAsMasterMutationVariables = Exact<{
5703
5760
  id: string | number;
5704
5761
  }>;
@@ -5779,6 +5836,36 @@ export type FleetChildrenQuery = {
5779
5836
  }>;
5780
5837
  };
5781
5838
  };
5839
+ export type FleetDataSinkChoicesQueryVariables = Exact<{
5840
+ first?: number | null | undefined;
5841
+ after?: string | null | undefined;
5842
+ }>;
5843
+ export type FleetDataSinkChoicesQuery = {
5844
+ listDataSinks: {
5845
+ edges: Array<{
5846
+ node: {
5847
+ id: string;
5848
+ name: string | null;
5849
+ isActive: boolean;
5850
+ };
5851
+ }>;
5852
+ pageInfo: {
5853
+ hasNextPage: boolean;
5854
+ endCursor: string | null;
5855
+ };
5856
+ };
5857
+ };
5858
+ export type FleetMasterSourcesQueryVariables = Exact<{
5859
+ dashboardId: string | number;
5860
+ }>;
5861
+ export type FleetMasterSourcesQuery = {
5862
+ listWidgetsByDashboard: Array<{
5863
+ id: string;
5864
+ dataSinkId: string | null;
5865
+ parserId: string | null;
5866
+ savedQueryId: string | null;
5867
+ }>;
5868
+ };
5782
5869
  export type FleetWidgetFlagsQueryVariables = Exact<{
5783
5870
  dashboardId: string | number;
5784
5871
  offset?: number | null | undefined;
@@ -5794,6 +5881,24 @@ export type FleetWidgetFlagsQuery = {
5794
5881
  createdAt: string;
5795
5882
  }>;
5796
5883
  };
5884
+ export type PreviewCopyBindingsQueryVariables = Exact<{
5885
+ input: Types.BigConsoleSetCopyBindingsInput;
5886
+ }>;
5887
+ export type PreviewCopyBindingsQuery = {
5888
+ previewCopyBindings: {
5889
+ preview: boolean;
5890
+ appliedCount: number;
5891
+ copies: Array<{
5892
+ dashboardId: string;
5893
+ name: string | null;
5894
+ state: Types.BigConsoleBindingCopyState;
5895
+ reasonCode: string | null;
5896
+ reason: string | null;
5897
+ widgetsRebound: number;
5898
+ widgetsKeptLocal: number;
5899
+ }>;
5900
+ };
5901
+ };
5797
5902
  export type PreviewPushToCopiesQueryVariables = Exact<{
5798
5903
  input: Types.BigConsolePushToCopiesInput;
5799
5904
  }>;
@@ -9844,13 +9949,17 @@ export declare const ResolveWidgetFlagDocument: DocumentNode<ResolveWidgetFlagMu
9844
9949
  export declare const RespondToDashboardLinkDocument: DocumentNode<RespondToDashboardLinkMutation, RespondToDashboardLinkMutationVariables>;
9845
9950
  export declare const RestoreDashboardToOriginalDocument: DocumentNode<RestoreDashboardToOriginalMutation, RestoreDashboardToOriginalMutationVariables>;
9846
9951
  export declare const RestoreWidgetToOriginalDocument: DocumentNode<RestoreWidgetToOriginalMutation, RestoreWidgetToOriginalMutationVariables>;
9952
+ export declare const SetCopyBindingsDocument: DocumentNode<SetCopyBindingsMutation, SetCopyBindingsMutationVariables>;
9847
9953
  export declare const SetDashboardAsMasterDocument: DocumentNode<SetDashboardAsMasterMutation, SetDashboardAsMasterMutationVariables>;
9848
9954
  export declare const UnsetDashboardAsMasterDocument: DocumentNode<UnsetDashboardAsMasterMutation, UnsetDashboardAsMasterMutationVariables>;
9849
9955
  export declare const FleetLinksDocument: DocumentNode<FleetLinksQuery, FleetLinksQueryVariables>;
9850
9956
  export declare const FleetBoardNameDocument: DocumentNode<FleetBoardNameQuery, FleetBoardNameQueryVariables>;
9851
9957
  export declare const FleetBoardStateDocument: DocumentNode<FleetBoardStateQuery, FleetBoardStateQueryVariables>;
9852
9958
  export declare const FleetChildrenDocument: DocumentNode<FleetChildrenQuery, FleetChildrenQueryVariables>;
9959
+ export declare const FleetDataSinkChoicesDocument: DocumentNode<FleetDataSinkChoicesQuery, FleetDataSinkChoicesQueryVariables>;
9960
+ export declare const FleetMasterSourcesDocument: DocumentNode<FleetMasterSourcesQuery, FleetMasterSourcesQueryVariables>;
9853
9961
  export declare const FleetWidgetFlagsDocument: DocumentNode<FleetWidgetFlagsQuery, FleetWidgetFlagsQueryVariables>;
9962
+ export declare const PreviewCopyBindingsDocument: DocumentNode<PreviewCopyBindingsQuery, PreviewCopyBindingsQueryVariables>;
9854
9963
  export declare const PreviewPushToCopiesDocument: DocumentNode<PreviewPushToCopiesQuery, PreviewPushToCopiesQueryVariables>;
9855
9964
  export declare const PreviewRestoreDashboardToOriginalDocument: DocumentNode<PreviewRestoreDashboardToOriginalQuery, PreviewRestoreDashboardToOriginalQueryVariables>;
9856
9965
  export declare const ExplainKpiChangeDocument: DocumentNode<ExplainKpiChangeQuery, ExplainKpiChangeQueryVariables>;