@burdenoff/microfe-bigconsole 2026.1118.9 → 2026.1118.10

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.
@@ -1,40 +1,62 @@
1
+ import { BACKEND_ERROR_MESSAGES as e } from "../constants/backendErrors.js";
1
2
  // src/bigconsole/utils/backendError.ts
2
- function e(e) {
3
+ function t(e) {
3
4
  return typeof e == "object" && !!e;
4
5
  }
5
- function t(t) {
6
- return Array.isArray(t) ? t.flatMap((t) => {
7
- let n = e(t) && e(t.extensions) ? t.extensions.code : void 0;
6
+ function n(e) {
7
+ if (!t(e)) return typeof e == "string" ? { message: e } : {};
8
+ let n = e, r = Array.isArray(n.graphQLErrors) ? n.graphQLErrors : [];
9
+ for (let e of r) {
10
+ let t = e?.extensions?.code;
11
+ if (typeof t == "string" && t.length > 0) return {
12
+ code: t,
13
+ message: typeof e.message == "string" ? e.message : void 0
14
+ };
15
+ }
16
+ let i = e, a = i.extensions?.code, o = typeof i.message == "string" ? i.message : void 0;
17
+ return typeof a == "string" && a.length > 0 ? {
18
+ code: a,
19
+ message: o
20
+ } : { message: o };
21
+ }
22
+ function r(t, r) {
23
+ let { code: i, message: a } = n(r), o = (i ? e[i] : void 0) ?? a ?? "Something went wrong.";
24
+ return i ? t(`bigconsole.errors.${i}`, o) : o;
25
+ }
26
+ var i = 4;
27
+ function a(e) {
28
+ return Array.isArray(e) ? e.flatMap((e) => {
29
+ let n = t(e) && t(e.extensions) ? e.extensions.code : void 0;
8
30
  return typeof n == "string" && n.length > 0 ? [n] : [];
9
31
  }) : [];
10
32
  }
11
- function n(n) {
12
- if (typeof n != "string" || n.length === 0) return [];
33
+ function o(e) {
34
+ if (typeof e != "string" || e.length === 0) return [];
13
35
  try {
14
- let r = JSON.parse(n);
15
- return e(r) ? t(r.errors) : [];
36
+ let n = JSON.parse(e);
37
+ return t(n) ? a(n.errors) : [];
16
38
  } catch {
17
39
  return [];
18
40
  }
19
41
  }
20
- function r(r) {
21
- let i = /* @__PURE__ */ new Set(), a = (r, o) => {
22
- if (!e(r) || o > 4 || i.has(r)) return [];
23
- i.add(r);
24
- let s = e(r.extensions) ? r.extensions.code : void 0;
42
+ function s(e) {
43
+ let n = /* @__PURE__ */ new Set(), r = (e, s) => {
44
+ if (!t(e) || s > i || n.has(e)) return [];
45
+ n.add(e);
46
+ let c = t(e.extensions) ? e.extensions.code : void 0;
25
47
  return [
26
- ...t(r.errors),
27
- ...t(r.graphQLErrors),
28
- ...e(r.result) ? t(r.result.errors) : [],
29
- ...n(r.bodyText),
30
- ...typeof s == "string" && s.length > 0 ? [s] : [],
31
- ...a(r.cause, o + 1),
32
- ...a(r.error, o + 1)
48
+ ...a(e.errors),
49
+ ...a(e.graphQLErrors),
50
+ ...t(e.result) ? a(e.result.errors) : [],
51
+ ...o(e.bodyText),
52
+ ...typeof c == "string" && c.length > 0 ? [c] : [],
53
+ ...r(e.cause, s + 1),
54
+ ...r(e.error, s + 1)
33
55
  ];
34
56
  };
35
- return [...new Set(a(r, 0))];
57
+ return [...new Set(r(e, 0))];
36
58
  }
37
- function i(e, t) {
38
- return r(e).some((e) => t.has(e));
59
+ function c(e, t) {
60
+ return s(e).some((e) => t.has(e));
39
61
  }
40
- export { r as graphQLErrorCodes, i as hasGraphQLErrorCode };
62
+ export { s as graphQLErrorCodes, c as hasGraphQLErrorCode, r as resolveBackendErrorMessage };
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Helpers for the "import from another tool" wizard (BOFF-14149).
3
+ *
4
+ * Kept free of React so the rules can be tested directly.
5
+ */
6
+ /** The tools a board can be imported from. */
7
+ export type MigrationSourceId = 'METABASE' | 'TABLEAU' | 'POWER_BI';
8
+ export declare const MIGRATION_SOURCES: readonly MigrationSourceId[];
9
+ /** The ways reading the board JSON can fail, each with its own message. */
10
+ export type BoardJsonProblem = 'empty' | 'not-json' | 'not-object';
11
+ export type ParsedBoardJson = {
12
+ ok: true;
13
+ value: Record<string, unknown>;
14
+ } | {
15
+ ok: false;
16
+ problem: BoardJsonProblem;
17
+ };
18
+ /**
19
+ * Read the text a user pasted or uploaded. The board has to be one JSON object,
20
+ * which is what the source tool's API returns for a single dashboard.
21
+ */
22
+ export declare function parseBoardJson(text: string): ParsedBoardJson;
23
+ /** A source URL is optional; blank means none. */
24
+ export declare function normalizeSourceUrl(value: string): string | undefined;
25
+ export type MigrationStatus = 'CLEAN' | 'APPROXIMATE' | 'UNSUPPORTED';
26
+ /** Badge variant for a status, using the design system's own variants. */
27
+ export declare function statusBadgeVariant(status: MigrationStatus): 'success' | 'warning' | 'destructive';
28
+ /** Whether the converted board can be imported as it is, with nothing to acknowledge. */
29
+ export declare function canImportWithoutAcknowledging(validation: {
30
+ isValid: boolean;
31
+ warnings: readonly unknown[];
32
+ }): boolean;
33
+ /** A Tableau workbook is sent as its XML text with the file name, minus the extension, as the name. */
34
+ export declare function buildTableauBoard(fileName: string, xml: string): Record<string, unknown>;
35
+ /** Whether a path inside a chosen folder is one of the three kinds of PBIR file the conversion reads. */
36
+ export declare function isPbirFile(path: string): boolean;
37
+ export type PowerBiProblem = 'no-pages' | 'not-json';
38
+ export type GatheredPowerBi = {
39
+ ok: true;
40
+ board: Record<string, unknown>;
41
+ } | {
42
+ ok: false;
43
+ problem: PowerBiProblem;
44
+ };
45
+ /**
46
+ * Gather a Power BI report in the PBIR folder format into the single document the
47
+ * service reads. `entries` are the files of a chosen folder with their relative
48
+ * paths (only those passing `isPbirFile` are looked at).
49
+ */
50
+ export declare function gatherPowerBiBoard(entries: ReadonlyArray<{
51
+ path: string;
52
+ text: string;
53
+ }>): GatheredPowerBi;
@@ -0,0 +1,92 @@
1
+ // src/bigconsole/utils/boardMigration.ts
2
+ var e = [
3
+ "METABASE",
4
+ "TABLEAU",
5
+ "POWER_BI"
6
+ ];
7
+ function t(e) {
8
+ if (e.trim() === "") return {
9
+ ok: !1,
10
+ problem: "empty"
11
+ };
12
+ let t;
13
+ try {
14
+ t = JSON.parse(e);
15
+ } catch {
16
+ return {
17
+ ok: !1,
18
+ problem: "not-json"
19
+ };
20
+ }
21
+ return typeof t != "object" || !t || Array.isArray(t) ? {
22
+ ok: !1,
23
+ problem: "not-object"
24
+ } : {
25
+ ok: !0,
26
+ value: Object.fromEntries(Object.entries(t))
27
+ };
28
+ }
29
+ function n(e) {
30
+ let t = e.trim();
31
+ return t === "" ? void 0 : t;
32
+ }
33
+ function r(e) {
34
+ return e === "CLEAN" ? "success" : e === "APPROXIMATE" ? "warning" : "destructive";
35
+ }
36
+ function i(e) {
37
+ return e.isValid && e.warnings.length === 0;
38
+ }
39
+ function a(e, t) {
40
+ return {
41
+ name: e.replace(/\.twb$/i, ""),
42
+ workbook: t
43
+ };
44
+ }
45
+ var o = /(?:^|\/)definition\/pages\/([^/]+)\/page\.json$/, s = /(?:^|\/)definition\/pages\/([^/]+)\/visuals\/[^/]+\/visual\.json$/, c = /(?:^|\/)definition\/pages\/pages\.json$/;
46
+ function l(e) {
47
+ return o.test(e) || s.test(e) || c.test(e);
48
+ }
49
+ function u(e) {
50
+ try {
51
+ let t = JSON.parse(e);
52
+ return typeof t != "object" || !t || Array.isArray(t) ? null : Object.fromEntries(Object.entries(t));
53
+ } catch {
54
+ return null;
55
+ }
56
+ }
57
+ function d(e) {
58
+ let t = /* @__PURE__ */ new Map(), n = (e) => {
59
+ let n = t.get(e);
60
+ if (n) return n;
61
+ let r = {
62
+ page: null,
63
+ visuals: []
64
+ };
65
+ return t.set(e, r), r;
66
+ }, r, i = "";
67
+ for (let { path: t, text: a } of e) {
68
+ let e = o.exec(t), l = s.exec(t);
69
+ if (!e && !l && !c.test(t)) continue;
70
+ let d = u(a);
71
+ if (d === null) return {
72
+ ok: !1,
73
+ problem: "not-json"
74
+ };
75
+ e?.[1] ? n(e[1]).page = d : l?.[1] ? n(l[1]).visuals.push(d) : r = d.pageOrder;
76
+ let f = t.split("/")[0] ?? "";
77
+ i === "" && f !== "definition" && !f.endsWith(".json") && (i = f.replace(/\.Report$/i, ""));
78
+ }
79
+ let a = [...t.values()].filter((e) => e.page !== null);
80
+ return a.length === 0 ? {
81
+ ok: !1,
82
+ problem: "no-pages"
83
+ } : {
84
+ ok: !0,
85
+ board: {
86
+ name: i || "Power BI report",
87
+ pageOrder: r,
88
+ pages: a
89
+ }
90
+ };
91
+ }
92
+ export { e as MIGRATION_SOURCES, a as buildTableauBoard, i as canImportWithoutAcknowledging, d as gatherPowerBiBoard, l as isPbirFile, n as normalizeSourceUrl, t as parseBoardJson, r as statusBadgeVariant };
@@ -31,6 +31,29 @@ export type BigConsoleAnomalyDetectionMethod =
31
31
  /** Mean ± (threshold × stddev); threshold defaults to 3. */
32
32
  | 'ZSCORE';
33
33
  export type BigConsoleAnomalyDirection = 'HIGH' | 'LOW';
34
+ /** What kind of source item a report row describes. */
35
+ export type BigConsoleBoardMigrationItemKind = 'FILTER' | 'WIDGET';
36
+ /** What kind of query a source card ran. */
37
+ export type BigConsoleBoardMigrationQueryKind = 'NATIVE' | 'STRUCTURED' | 'UNKNOWN';
38
+ /** The tool a board is imported from. */
39
+ export type BigConsoleBoardMigrationSource =
40
+ /** Metabase. Pass the JSON returned by GET /api/dashboard/:id. */
41
+ 'METABASE'
42
+ /**
43
+ * Power BI. Pass `{ name, pageOrder, pages: [{ page, visuals }] }`, the PBIR
44
+ * `page.json` and `visual.json` files gathered into one document.
45
+ */
46
+ | 'POWER_BI'
47
+ /** Tableau. Pass the .twb XML as a JSON string, or `{ name, workbook }`. */
48
+ | 'TABLEAU';
49
+ /** How well a source item carried over. */
50
+ export type BigConsoleBoardMigrationStatus =
51
+ /** Carried over, but something changed. The reason says what. */
52
+ 'APPROXIMATE'
53
+ /** Carried over as it was. */
54
+ | 'CLEAN'
55
+ /** Has no BigConsole equivalent. A text placeholder keeps its place on the board. */
56
+ | 'UNSUPPORTED';
34
57
  /** Input for cloning a dashboard */
35
58
  export type BigConsoleCloneDashboardInput = {
36
59
  /**
@@ -5082,6 +5105,51 @@ export type GetFilterPresetsQuery = {
5082
5105
  updatedAt: string;
5083
5106
  }>;
5084
5107
  };
5108
+ export type PreviewBoardMigrationQueryVariables = Exact<{
5109
+ source: Types.BigConsoleBoardMigrationSource;
5110
+ boardJson: Record<string, unknown>;
5111
+ sourceUrl?: string | null | undefined;
5112
+ }>;
5113
+ export type PreviewBoardMigrationQuery = {
5114
+ previewBoardMigration: {
5115
+ definition: string;
5116
+ report: {
5117
+ sourceName: string;
5118
+ totalCount: number;
5119
+ cleanCount: number;
5120
+ approximateCount: number;
5121
+ unsupportedCount: number;
5122
+ warnings: Array<string>;
5123
+ items: Array<{
5124
+ kind: Types.BigConsoleBoardMigrationItemKind;
5125
+ title: string;
5126
+ sourceType: string;
5127
+ status: Types.BigConsoleBoardMigrationStatus;
5128
+ targetType: string;
5129
+ reason: string | null;
5130
+ page: string | null;
5131
+ }>;
5132
+ dataNeeds: Array<{
5133
+ widgetTitle: string;
5134
+ page: string;
5135
+ queryKind: Types.BigConsoleBoardMigrationQueryKind;
5136
+ summary: string;
5137
+ }>;
5138
+ };
5139
+ validation: {
5140
+ isValid: boolean;
5141
+ errors: Array<{
5142
+ code: string;
5143
+ message: string;
5144
+ }>;
5145
+ warnings: Array<{
5146
+ code: string;
5147
+ message: string;
5148
+ suggestion: string | null;
5149
+ }>;
5150
+ };
5151
+ };
5152
+ };
5085
5153
  export type NarrativeFieldsFragment = {
5086
5154
  id: string;
5087
5155
  kind: Types.BigConsoleNarrativeKind;
@@ -8643,6 +8711,7 @@ export declare const UpdateFilterPresetDocument: DocumentNode<UpdateFilterPreset
8643
8711
  export declare const GetDefaultFilterPresetDocument: DocumentNode<GetDefaultFilterPresetQuery, GetDefaultFilterPresetQueryVariables>;
8644
8712
  export declare const GetFilterPresetDocument: DocumentNode<GetFilterPresetQuery, GetFilterPresetQueryVariables>;
8645
8713
  export declare const GetFilterPresetsDocument: DocumentNode<GetFilterPresetsQuery, GetFilterPresetsQueryVariables>;
8714
+ export declare const PreviewBoardMigrationDocument: DocumentNode<PreviewBoardMigrationQuery, PreviewBoardMigrationQueryVariables>;
8646
8715
  export declare const ExplainDashboardDocument: DocumentNode<ExplainDashboardQuery, ExplainDashboardQueryVariables>;
8647
8716
  export declare const ExplainWidgetDocument: DocumentNode<ExplainWidgetQuery, ExplainWidgetQueryVariables>;
8648
8717
  export declare const LatestDashboardDigestDocument: DocumentNode<LatestDashboardDigestQuery, LatestDashboardDigestQueryVariables>;