react-semaphor 0.1.424 → 0.1.425
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/analytics-protocol/index.cjs +1 -1
- package/dist/analytics-protocol/index.js +243 -91
- package/dist/appearance/index.cjs +1 -1
- package/dist/appearance/index.js +1 -1
- package/dist/brand-studio/index.cjs +2 -2
- package/dist/brand-studio/index.js +8 -8
- package/dist/chunks/{analyze-result-contract-D7pjjYPy.js → analyze-result-contract-DnfF8kBb.js} +434 -427
- package/dist/chunks/analyze-result-contract-ege_u6Nl.js +1 -0
- package/dist/chunks/{braces-8TRlDwDw.js → braces-BdbUk_r9.js} +1 -1
- package/dist/chunks/{braces-D2tStQjF.js → braces-CbO-aIwH.js} +1 -1
- package/dist/chunks/calendar-preferences-dialog-BLaSWhLl.js +1 -0
- package/dist/chunks/{calendar-preferences-dialog-D5mABNDT.js → calendar-preferences-dialog-DJwV0aqn.js} +4 -4
- package/dist/chunks/{catalog-field-grounding-CJKAqtiC.js → catalog-field-grounding-DcxPLns0.js} +10 -10
- package/dist/chunks/{switch-2bh3Hka1.js → code-editor-Bkk7s8hI.js} +7382 -6809
- package/dist/chunks/code-editor-CkXyNgYc.js +138 -0
- package/dist/chunks/{common-types-4bjoIgvm.js → common-types-ClkOI-3O.js} +4 -4
- package/dist/chunks/comparison-document-migration-CQJ0DZlL.js +414 -0
- package/dist/chunks/comparison-document-migration-Db64RWYD.js +1 -0
- package/dist/chunks/{index-Dzz6jXSY.js → dashboard-5agU0G_D.js} +57458 -56183
- package/dist/chunks/dashboard-MKIqgGDp.js +1402 -0
- package/dist/chunks/{dashboard-briefing-launcher-DuWgwtxX.js → dashboard-briefing-launcher-CII8-4qo.js} +11 -6
- package/dist/chunks/{dashboard-briefing-launcher-BNDzMjjt.js → dashboard-briefing-launcher-qyEVfuOm.js} +226 -209
- package/dist/chunks/dashboard-controls-PJpeYZHw.js +36 -0
- package/dist/chunks/dashboard-controls-aJY0FNPP.js +2196 -0
- package/dist/chunks/dashboard-input-contract-BFpERluO.js +18 -0
- package/dist/chunks/dashboard-input-contract-DV3cshjz.js +1 -0
- package/dist/chunks/{dashboard-json-CkTEDNtH.js → dashboard-json-CzHSP6Fa.js} +16 -15
- package/dist/chunks/dashboard-json-DtmR5yCf.js +1 -0
- package/dist/chunks/date-formatter-BTTYdAik.js +1 -0
- package/dist/chunks/date-formatter-D-89jTjG.js +514 -0
- package/dist/chunks/{edit-dashboard-visual-CRjVRZLk.js → edit-dashboard-visual-AkZzwBCV.js} +8892 -8996
- package/dist/chunks/edit-dashboard-visual-Cif6uDqN.js +182 -0
- package/dist/chunks/{index-CjzRe2su.js → index-CnujJ3fa.js} +3 -3
- package/dist/chunks/{index-DRlMUglg.js → index-Dpm_VET4.js} +2 -2
- package/dist/chunks/{index-CJdxSyQq.js → index-If0wlXGi.js} +308 -308
- package/dist/chunks/index-jSrCwPQz.js +31 -0
- package/dist/chunks/{x-CXDkqdur.js → index-xHCrHprY.js} +59 -59
- package/dist/chunks/{layout-grid-C0OI-MRn.js → layout-grid-B08pP7v6.js} +1 -1
- package/dist/chunks/{layout-grid-CiubineE.js → layout-grid-D5tYJg1-.js} +1 -1
- package/dist/chunks/metric-comparison-4oA4ouU9.js +354 -0
- package/dist/chunks/metric-comparison-nQKquVnx.js +1 -0
- package/dist/chunks/{palette-C4KTXOug.js → palette-C0yjT5Tv.js} +1 -1
- package/dist/chunks/{palette-Cp1hqZtm.js → palette-jqaAcwiQ.js} +1 -1
- package/dist/chunks/{save-DgMfP0j8.js → save-HCJjjzdX.js} +1 -1
- package/dist/chunks/{save-C__QggEE.js → save-Xdc4pnys.js} +1 -1
- package/dist/chunks/{search-BHsQIWBV.js → search-DHZCro8B.js} +1 -1
- package/dist/chunks/{search-DNCejM7Z.js → search-Dcud9ajy.js} +1 -1
- package/dist/chunks/{update-policy-C1pmhLz9.js → update-policy-BgONreNd.js} +1 -1
- package/dist/chunks/{update-policy-BCJc0oI5.js → update-policy-CY2k-pJP.js} +9 -9
- package/dist/chunks/{use-create-flow-overlay-state-B9vArrvr.js → use-create-flow-overlay-state-ByOKVV2K.js} +62 -62
- package/dist/chunks/{use-create-flow-overlay-state-B-bYbtix.js → use-create-flow-overlay-state-DmuReEnk.js} +2 -2
- package/dist/chunks/validators-B4VMLX3_.js +1 -0
- package/dist/chunks/{validators-PXkij33j.js → validators-Cz-XuORM.js} +123 -119
- package/dist/dashboard/index.cjs +1 -1
- package/dist/dashboard/index.js +2 -2
- package/dist/dashboard-authoring/index.cjs +2 -2
- package/dist/dashboard-authoring/index.js +6 -4
- package/dist/data-app-builder/index.cjs +6 -6
- package/dist/data-app-builder/index.js +5 -5
- package/dist/data-app-codegen/index.cjs +1 -1
- package/dist/data-app-codegen/index.js +2 -2
- package/dist/data-app-codegen-node/index.cjs +1 -1
- package/dist/data-app-codegen-node/index.js +3 -3
- package/dist/data-app-sdk/index.cjs +1 -1
- package/dist/data-app-sdk/index.js +6 -6
- package/dist/data-app-sdk-adapters/index.cjs +1 -1
- package/dist/data-app-sdk-adapters/index.js +1 -1
- package/dist/data-app-sdk-validation/index.cjs +1 -1
- package/dist/data-app-sdk-validation/index.js +65 -68
- package/dist/format-utils/index.cjs +2 -2
- package/dist/format-utils/index.js +59 -58
- package/dist/index.cjs +1 -1
- package/dist/index.js +19 -19
- package/dist/style.css +1 -1
- package/dist/surfboard/index.cjs +1 -1
- package/dist/surfboard/index.js +3 -3
- package/dist/types/analytics-protocol.d.ts +299 -3
- package/dist/types/brand-studio.d.ts +2 -2
- package/dist/types/briefings.d.ts +65 -41
- package/dist/types/dashboard-assistant.d.ts +28 -7
- package/dist/types/dashboard-authoring.d.ts +123 -43
- package/dist/types/dashboard.d.ts +97 -48
- package/dist/types/data-app-builder.d.ts +2 -2
- package/dist/types/data-app-sdk.d.ts +1 -1
- package/dist/types/format-utils.d.ts +98 -10
- package/dist/types/index.js +1 -1
- package/dist/types/main.d.ts +229 -95
- package/dist/types/shared.d.ts +84 -43
- package/dist/types/surfboard.d.ts +99 -49
- package/dist/types/types.d.ts +110 -50
- package/package.json +2 -1
- package/dist/chunks/analyze-result-contract-DpDcImgk.js +0 -1
- package/dist/chunks/calendar-preferences-dialog-iokD3HbE.js +0 -1
- package/dist/chunks/contracts-CoCOpd_i.js +0 -11
- package/dist/chunks/contracts-CtB2VONT.js +0 -1
- package/dist/chunks/dashboard-controls-bbEF-AbK.js +0 -52
- package/dist/chunks/dashboard-controls-id39vb7G.js +0 -2322
- package/dist/chunks/dashboard-json-DVoqS1ks.js +0 -1
- package/dist/chunks/date-formatter-B4EBSe9C.js +0 -1
- package/dist/chunks/date-formatter-BlhBftA9.js +0 -416
- package/dist/chunks/edit-dashboard-visual-CkrxZCcp.js +0 -178
- package/dist/chunks/index-S1CGUcSz.js +0 -1406
- package/dist/chunks/switch-DMT7qf_R.js +0 -138
- package/dist/chunks/validators-DMlVbd1p.js +0 -1
- package/dist/chunks/x-B6ghREd2.js +0 -31
|
@@ -0,0 +1,414 @@
|
|
|
1
|
+
import "./analyze-result-contract-DnfF8kBb.js";
|
|
2
|
+
import { v as V, C as T } from "./metric-comparison-4oA4ouU9.js";
|
|
3
|
+
const x = [
|
|
4
|
+
"lg",
|
|
5
|
+
"md",
|
|
6
|
+
"sm",
|
|
7
|
+
"xs",
|
|
8
|
+
"xxs"
|
|
9
|
+
], R = 15, _ = /* @__PURE__ */ new Set([
|
|
10
|
+
"previous_period",
|
|
11
|
+
"same_period_last_year",
|
|
12
|
+
"start_vs_end",
|
|
13
|
+
"target"
|
|
14
|
+
]), k = /* @__PURE__ */ new Set([..._, "none", ""]);
|
|
15
|
+
function l(e) {
|
|
16
|
+
return !!e && typeof e == "object" && !Array.isArray(e);
|
|
17
|
+
}
|
|
18
|
+
function A(e) {
|
|
19
|
+
const r = l(e.preferences) ? e.preferences : void 0, o = r && l(r.kpiVisualOptions) ? r.kpiVisualOptions : void 0, s = r && l(r.tableVisualOptions) ? r.tableVisualOptions : void 0;
|
|
20
|
+
return {
|
|
21
|
+
preferences: r,
|
|
22
|
+
kpiOptions: o,
|
|
23
|
+
kpiComparison: o && l(o.metricComparison) ? o.metricComparison : void 0,
|
|
24
|
+
kpiComparisonPresent: !!o && "metricComparison" in o,
|
|
25
|
+
tableOptions: s,
|
|
26
|
+
tableComparison: s && l(s.metricComparison) ? s.metricComparison : void 0,
|
|
27
|
+
tableComparisonPresent: !!s && "metricComparison" in s
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
function O(e) {
|
|
31
|
+
const r = [], o = (s, p) => {
|
|
32
|
+
if (Array.isArray(s)) {
|
|
33
|
+
s.forEach((t, c) => o(t, `${p}[${c}]`));
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
if (!l(s)) return;
|
|
37
|
+
const m = s.config;
|
|
38
|
+
if (l(m)) {
|
|
39
|
+
const t = A(s), c = !!(t.kpiComparisonPresent || t.tableComparisonPresent), d = m.metricColumns, a = Array.isArray(d) ? d.flatMap(
|
|
40
|
+
(n, i) => l(n) ? [{ index: i, metric: n }] : []
|
|
41
|
+
) : [];
|
|
42
|
+
if ((a.some(({ metric: n }) => "comparisonType" in n) || c) && r.push({
|
|
43
|
+
path: p,
|
|
44
|
+
card: s,
|
|
45
|
+
metrics: a,
|
|
46
|
+
malformedMetricIndexes: Array.isArray(d) ? d.flatMap(
|
|
47
|
+
(n, i) => l(n) ? [] : [i]
|
|
48
|
+
) : [],
|
|
49
|
+
malformedMetricColumns: "metricColumns" in m && !Array.isArray(d),
|
|
50
|
+
hasLegacyPresentation: c
|
|
51
|
+
}), "metricColumns" in m || c) return;
|
|
52
|
+
}
|
|
53
|
+
Object.entries(s).forEach(
|
|
54
|
+
([t, c]) => o(c, p ? `${p}.${t}` : t)
|
|
55
|
+
);
|
|
56
|
+
};
|
|
57
|
+
return o(e, "$"), r;
|
|
58
|
+
}
|
|
59
|
+
const E = {
|
|
60
|
+
difference: "difference",
|
|
61
|
+
change: "percent_change",
|
|
62
|
+
change_difference: "both",
|
|
63
|
+
ratio: "ratio"
|
|
64
|
+
};
|
|
65
|
+
function $(e, r) {
|
|
66
|
+
if (!e) return;
|
|
67
|
+
const o = Object.fromEntries(
|
|
68
|
+
r.flatMap(
|
|
69
|
+
(s) => typeof e[s] == "string" ? [[s, e[s]]] : []
|
|
70
|
+
)
|
|
71
|
+
);
|
|
72
|
+
return Object.keys(o).length ? o : void 0;
|
|
73
|
+
}
|
|
74
|
+
function I(e, r, o) {
|
|
75
|
+
if (e !== void 0) {
|
|
76
|
+
if (!l(e)) {
|
|
77
|
+
o.push({
|
|
78
|
+
severity: "error",
|
|
79
|
+
code: "invalid_legacy_comparison_presentation",
|
|
80
|
+
path: r,
|
|
81
|
+
message: "Legacy comparison formatOptions must be an object."
|
|
82
|
+
});
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
Object.entries(e).forEach(([s, p]) => {
|
|
86
|
+
if (s === "decimalPlaces") {
|
|
87
|
+
(typeof p != "number" || !Number.isInteger(p) || p < 0 || p > 6) && o.push({
|
|
88
|
+
severity: "error",
|
|
89
|
+
code: "invalid_legacy_comparison_presentation",
|
|
90
|
+
path: `${r}.decimalPlaces`,
|
|
91
|
+
message: "Legacy comparison decimalPlaces must be an integer from 0 through 6."
|
|
92
|
+
});
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
s === "type" && (p === void 0 || p === "auto") || p !== void 0 && o.push({
|
|
96
|
+
severity: "error",
|
|
97
|
+
code: "unsupported_comparison_format",
|
|
98
|
+
path: `${r}.${s}`,
|
|
99
|
+
message: `Legacy comparison format option "${s}" has no canonical presentation mapping.`
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
function C(e, r) {
|
|
105
|
+
const o = r === "kpi" ? e.calculationType : e.calculatedAs, s = r === "table" && o === void 0 ? "both" : E[String(o)], p = l(e.formatOptions) ? e.formatOptions : void 0, m = l(e.conditionalLabels) ? e.conditionalLabels : void 0, t = l(
|
|
106
|
+
r === "kpi" ? e.colorConfig : e.colors
|
|
107
|
+
) ? r === "kpi" ? e.colorConfig : e.colors : void 0, c = {};
|
|
108
|
+
if (s && (c.displayMode = s), typeof (p == null ? void 0 : p.decimalPlaces) == "number" && (c.precision = p.decimalPlaces), r === "kpi") {
|
|
109
|
+
const n = e.showArrow !== !1, i = e.showColor !== !1;
|
|
110
|
+
c.indicatorStyle = n ? i ? "arrow_badge" : "arrow" : i ? "badge" : "none", c.showColor = i, (e.position === "left" || e.position === "right" || e.position === "top") && (c.position = e.position), typeof e.conditionalLabel == "boolean" && (c.conditionalLabel = e.conditionalLabel), typeof e.labelName == "string" && (c.labelName = e.labelName);
|
|
111
|
+
} else (e.indicatorStyle === "arrow_badge" || e.indicatorStyle === "arrow" || e.indicatorStyle === "badge" || e.indicatorStyle === "none") && (c.indicatorStyle = e.indicatorStyle);
|
|
112
|
+
const d = m ? {
|
|
113
|
+
...$(m, ["increase", "decrease"]),
|
|
114
|
+
...typeof m.noChange == "string" ? { neutral: m.noChange } : typeof m.neutral == "string" ? { neutral: m.neutral } : {}
|
|
115
|
+
} : void 0;
|
|
116
|
+
d && Object.keys(d).length && (c.conditionalLabels = d);
|
|
117
|
+
const a = t ? {
|
|
118
|
+
...$(t, ["increase", "decrease"]),
|
|
119
|
+
...typeof t.noChange == "string" ? { neutral: t.noChange } : typeof t.neutral == "string" ? { neutral: t.neutral } : {}
|
|
120
|
+
} : void 0;
|
|
121
|
+
return a && Object.keys(a).length && (c.colors = a), c;
|
|
122
|
+
}
|
|
123
|
+
function w(e) {
|
|
124
|
+
return { ...T, ...e };
|
|
125
|
+
}
|
|
126
|
+
function P(e) {
|
|
127
|
+
return e.some(({ metric: r }) => r.comparisonType === "previous_period" || r.comparisonType === "same_period_last_year" || r.comparisonType === "target" ? !0 : l(r.comparison) && r.comparison.mode === "explicit");
|
|
128
|
+
}
|
|
129
|
+
function v(e) {
|
|
130
|
+
const r = e.card.config;
|
|
131
|
+
return e.metrics.length === 2 && (r.groupByColumns === void 0 || Array.isArray(r.groupByColumns) && r.groupByColumns.length === 0);
|
|
132
|
+
}
|
|
133
|
+
function L(e, r, o, s) {
|
|
134
|
+
const p = r === "kpi" ? [
|
|
135
|
+
"enabled",
|
|
136
|
+
"calculationType",
|
|
137
|
+
"formatOptions",
|
|
138
|
+
"showArrow",
|
|
139
|
+
"showColor",
|
|
140
|
+
"conditionalLabel",
|
|
141
|
+
"labelName",
|
|
142
|
+
"position",
|
|
143
|
+
"conditionalLabels",
|
|
144
|
+
"colorConfig",
|
|
145
|
+
"lowerIsBetter"
|
|
146
|
+
] : [
|
|
147
|
+
"calculatedAs",
|
|
148
|
+
"indicatorStyle",
|
|
149
|
+
"formatOptions",
|
|
150
|
+
"colors",
|
|
151
|
+
"lowerIsBetter"
|
|
152
|
+
];
|
|
153
|
+
Object.keys(e).forEach((n) => {
|
|
154
|
+
p.includes(n) || s.push({
|
|
155
|
+
severity: "error",
|
|
156
|
+
code: "invalid_legacy_comparison_presentation",
|
|
157
|
+
path: `${o}.${n}`,
|
|
158
|
+
message: `Unknown legacy comparison presentation field "${n}" cannot be dropped automatically.`
|
|
159
|
+
});
|
|
160
|
+
});
|
|
161
|
+
const m = r === "kpi" ? "calculationType" : "calculatedAs";
|
|
162
|
+
e[m] !== void 0 && !E[String(e[m])] && s.push({
|
|
163
|
+
severity: "error",
|
|
164
|
+
code: "invalid_legacy_comparison_presentation",
|
|
165
|
+
path: `${o}.${m}`,
|
|
166
|
+
message: `Legacy comparison ${m} is unsupported.`
|
|
167
|
+
}), r === "kpi" && e.position !== void 0 && !["left", "right", "top"].includes(String(e.position)) && s.push({
|
|
168
|
+
severity: "error",
|
|
169
|
+
code: "invalid_legacy_comparison_presentation",
|
|
170
|
+
path: `${o}.position`,
|
|
171
|
+
message: "Legacy comparison position is unsupported."
|
|
172
|
+
}), r === "kpi" && e.labelName !== void 0 && typeof e.labelName != "string" && s.push({
|
|
173
|
+
severity: "error",
|
|
174
|
+
code: "invalid_legacy_comparison_presentation",
|
|
175
|
+
path: `${o}.labelName`,
|
|
176
|
+
message: "Legacy comparison labelName must be a string."
|
|
177
|
+
}), (r === "kpi" ? [
|
|
178
|
+
["conditionalLabels", ["increase", "decrease", "noChange"]],
|
|
179
|
+
["colorConfig", ["increase", "decrease", "noChange"]]
|
|
180
|
+
] : [["colors", ["increase", "decrease", "neutral"]]]).forEach(([n, i]) => {
|
|
181
|
+
if (e[n] !== void 0) {
|
|
182
|
+
if (!l(e[n])) {
|
|
183
|
+
s.push({
|
|
184
|
+
severity: "error",
|
|
185
|
+
code: "invalid_legacy_comparison_presentation",
|
|
186
|
+
path: `${o}.${n}`,
|
|
187
|
+
message: `Legacy comparison ${n} must be an object.`
|
|
188
|
+
});
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
Object.entries(e[n]).forEach(([u, f]) => {
|
|
192
|
+
i.includes(u) ? typeof f != "string" && s.push({
|
|
193
|
+
severity: "error",
|
|
194
|
+
code: "invalid_legacy_comparison_presentation",
|
|
195
|
+
path: `${o}.${n}.${u}`,
|
|
196
|
+
message: `Legacy comparison ${n}.${u} must be a string.`
|
|
197
|
+
}) : s.push({
|
|
198
|
+
severity: "error",
|
|
199
|
+
code: "invalid_legacy_comparison_presentation",
|
|
200
|
+
path: `${o}.${n}.${u}`,
|
|
201
|
+
message: `Unknown legacy comparison ${n} field "${u}" cannot be dropped automatically.`
|
|
202
|
+
});
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
}), (r === "kpi" ? ["enabled", "showArrow", "showColor", "conditionalLabel", "lowerIsBetter"] : ["lowerIsBetter"]).forEach((n) => {
|
|
206
|
+
e[n] !== void 0 && typeof e[n] != "boolean" && s.push({
|
|
207
|
+
severity: "error",
|
|
208
|
+
code: "invalid_legacy_comparison_presentation",
|
|
209
|
+
path: `${o}.${n}`,
|
|
210
|
+
message: `Legacy comparison ${n} must be a boolean.`
|
|
211
|
+
});
|
|
212
|
+
}), r === "table" && e.indicatorStyle !== void 0 && !["arrow_badge", "arrow", "badge", "none"].includes(
|
|
213
|
+
String(e.indicatorStyle)
|
|
214
|
+
) && s.push({
|
|
215
|
+
severity: "error",
|
|
216
|
+
code: "invalid_legacy_comparison_presentation",
|
|
217
|
+
path: `${o}.indicatorStyle`,
|
|
218
|
+
message: "Legacy comparison indicatorStyle is unsupported."
|
|
219
|
+
}), I(e.formatOptions, `${o}.formatOptions`, s);
|
|
220
|
+
const d = C(e, r);
|
|
221
|
+
V(d, o).errors.forEach((n) => {
|
|
222
|
+
s.push({
|
|
223
|
+
severity: "error",
|
|
224
|
+
code: "invalid_legacy_comparison_presentation",
|
|
225
|
+
path: n.path || o,
|
|
226
|
+
message: n.message
|
|
227
|
+
});
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
function S(e) {
|
|
231
|
+
const r = A(e.card), o = r.kpiComparison ? C(r.kpiComparison, "kpi") : void 0, s = r.tableComparison ? C(r.tableComparison, "table") : void 0;
|
|
232
|
+
return { namespaces: r, kpi: o, table: s, presentation: o || s };
|
|
233
|
+
}
|
|
234
|
+
function N(e) {
|
|
235
|
+
const r = l(e.preferences) ? e.preferences : {}, o = l(r.kpiVisualOptions) ? r.kpiVisualOptions : {}, s = l(o.metricComparison) ? o.metricComparison : {}, p = l(r.tableVisualOptions) ? r.tableVisualOptions : {}, m = l(p.metricComparison) ? p.metricComparison : {};
|
|
236
|
+
return o.lowerIsBetter === !0 || s.lowerIsBetter === !0 || m.lowerIsBetter === !0 ? "lower_is_better" : "higher_is_better";
|
|
237
|
+
}
|
|
238
|
+
function B(e) {
|
|
239
|
+
switch (e.comparisonType) {
|
|
240
|
+
case "previous_period":
|
|
241
|
+
return { mode: "explicit", spec: { kind: "previous_period" } };
|
|
242
|
+
case "same_period_last_year":
|
|
243
|
+
return { mode: "explicit", spec: { kind: "previous_year" } };
|
|
244
|
+
case "target":
|
|
245
|
+
return {
|
|
246
|
+
mode: "explicit",
|
|
247
|
+
spec: { kind: "target", targetValue: e.targetValue }
|
|
248
|
+
};
|
|
249
|
+
default:
|
|
250
|
+
return;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
function M(e) {
|
|
254
|
+
const r = l(e.preferences) ? e.preferences : void 0;
|
|
255
|
+
if (!r) return;
|
|
256
|
+
const o = l(r.kpiVisualOptions) ? r.kpiVisualOptions : void 0;
|
|
257
|
+
o && delete o.lowerIsBetter;
|
|
258
|
+
const s = l(r.tableVisualOptions) ? r.tableVisualOptions : void 0, p = s && l(s.metricComparison) ? s.metricComparison : void 0;
|
|
259
|
+
p && delete p.lowerIsBetter;
|
|
260
|
+
}
|
|
261
|
+
function F(e) {
|
|
262
|
+
const r = O(e);
|
|
263
|
+
if (!r.length)
|
|
264
|
+
return { document: e, changed: !1, changes: [], diagnostics: [] };
|
|
265
|
+
const o = [];
|
|
266
|
+
if (r.forEach((t) => {
|
|
267
|
+
var c, d, a, n;
|
|
268
|
+
if (t.malformedMetricColumns && o.push({
|
|
269
|
+
severity: "error",
|
|
270
|
+
code: "malformed_metric_columns",
|
|
271
|
+
path: `${t.path}.config.metricColumns`,
|
|
272
|
+
message: "Metric columns must be an array before comparison migration."
|
|
273
|
+
}), t.malformedMetricIndexes.forEach((i) => {
|
|
274
|
+
o.push({
|
|
275
|
+
severity: "error",
|
|
276
|
+
code: "malformed_metric_columns",
|
|
277
|
+
path: `${t.path}.config.metricColumns[${i}]`,
|
|
278
|
+
message: "Metric columns must contain objects before comparison migration."
|
|
279
|
+
});
|
|
280
|
+
}), t.metrics.forEach(({ metric: i, index: u }) => {
|
|
281
|
+
if (!("comparisonType" in i)) return;
|
|
282
|
+
const f = `${t.path}.config.metricColumns[${u}]`, g = String(i.comparisonType || "");
|
|
283
|
+
"comparison" in i && o.push({
|
|
284
|
+
severity: "error",
|
|
285
|
+
code: "conflicting_comparison_contracts",
|
|
286
|
+
path: f,
|
|
287
|
+
message: "Metric contains both legacy and canonical comparison configuration; resolve the conflict before migration."
|
|
288
|
+
});
|
|
289
|
+
const h = l(i.parameters) ? i.parameters : void 0, b = h && l(h.windowTransform) ? h.windowTransform : void 0;
|
|
290
|
+
_.has(g) && (b == null ? void 0 : b.function) === "previous_period_delta" && o.push({
|
|
291
|
+
severity: "error",
|
|
292
|
+
code: "conflicting_comparison_window_transform",
|
|
293
|
+
path: f,
|
|
294
|
+
message: "A metric cannot combine baseline comparison with previous_period_delta; resolve the authoring intent before migration."
|
|
295
|
+
}), k.has(g) || o.push({
|
|
296
|
+
severity: "error",
|
|
297
|
+
code: "unsupported_comparison_type",
|
|
298
|
+
path: `${f}.comparisonType`,
|
|
299
|
+
message: `Unsupported legacy metric comparison type "${g}".`
|
|
300
|
+
}), i.comparisonType === "target" && (typeof i.targetValue != "number" || !Number.isFinite(i.targetValue)) && o.push({
|
|
301
|
+
severity: "error",
|
|
302
|
+
code: "invalid_target_value",
|
|
303
|
+
path: `${f}.targetValue`,
|
|
304
|
+
message: "Legacy target comparison requires a finite metric targetValue."
|
|
305
|
+
}), i.comparisonType === "start_vs_end" && o.push({
|
|
306
|
+
severity: "error",
|
|
307
|
+
code: "unsupported_start_vs_end",
|
|
308
|
+
path: `${f}.comparisonType`,
|
|
309
|
+
message: "start_vs_end is retired and cannot be migrated automatically."
|
|
310
|
+
}), i.targetValue !== void 0 && i.comparisonType !== "target" && o.push({
|
|
311
|
+
severity: "warning",
|
|
312
|
+
code: "stray_target_value",
|
|
313
|
+
path: `${f}.targetValue`,
|
|
314
|
+
message: "Dead non-target targetValue will be removed without changing the baseline."
|
|
315
|
+
});
|
|
316
|
+
}), t.hasLegacyPresentation) {
|
|
317
|
+
const { namespaces: i, kpi: u, table: f } = S(t), g = [
|
|
318
|
+
(c = i.kpiOptions) == null ? void 0 : c.lowerIsBetter,
|
|
319
|
+
(d = i.kpiComparison) == null ? void 0 : d.lowerIsBetter,
|
|
320
|
+
(a = i.tableComparison) == null ? void 0 : a.lowerIsBetter
|
|
321
|
+
].filter((h) => typeof h == "boolean");
|
|
322
|
+
new Set(g).size > 1 && o.push({
|
|
323
|
+
severity: "error",
|
|
324
|
+
code: "conflicting_legacy_polarity",
|
|
325
|
+
path: `${t.path}.preferences`,
|
|
326
|
+
message: "Legacy comparison polarity values disagree; resolve the conflict before migration."
|
|
327
|
+
}), ((n = i.kpiOptions) == null ? void 0 : n.lowerIsBetter) !== void 0 && typeof i.kpiOptions.lowerIsBetter != "boolean" && o.push({
|
|
328
|
+
severity: "error",
|
|
329
|
+
code: "invalid_legacy_comparison_presentation",
|
|
330
|
+
path: `${t.path}.preferences.kpiVisualOptions.lowerIsBetter`,
|
|
331
|
+
message: "Legacy comparison lowerIsBetter must be a boolean."
|
|
332
|
+
}), i.kpiComparisonPresent && !i.kpiComparison && o.push({
|
|
333
|
+
severity: "error",
|
|
334
|
+
code: "invalid_legacy_comparison_presentation",
|
|
335
|
+
path: `${t.path}.preferences.kpiVisualOptions.metricComparison`,
|
|
336
|
+
message: "Legacy KPI comparison presentation must be an object."
|
|
337
|
+
}), i.tableComparisonPresent && !i.tableComparison && o.push({
|
|
338
|
+
severity: "error",
|
|
339
|
+
code: "invalid_legacy_comparison_presentation",
|
|
340
|
+
path: `${t.path}.preferences.tableVisualOptions.metricComparison`,
|
|
341
|
+
message: "Legacy table comparison presentation must be an object."
|
|
342
|
+
}), "comparisonPresentation" in (i.preferences || {}) && o.push({
|
|
343
|
+
severity: "error",
|
|
344
|
+
code: "conflicting_comparison_presentation_contracts",
|
|
345
|
+
path: `${t.path}.preferences.comparisonPresentation`,
|
|
346
|
+
message: "Card contains both legacy and canonical comparison presentation; resolve the conflict before migration."
|
|
347
|
+
}), i.kpiComparison && typeof i.kpiComparison.enabled == "boolean" && "metricPairComparisonEnabled" in (i.preferences || {}) && v(t) && o.push({
|
|
348
|
+
severity: "error",
|
|
349
|
+
code: "conflicting_comparison_presentation_contracts",
|
|
350
|
+
path: `${t.path}.preferences.metricPairComparisonEnabled`,
|
|
351
|
+
message: "Card contains both legacy and canonical metric-pair enablement; resolve the conflict before migration."
|
|
352
|
+
}), i.kpiComparison && L(
|
|
353
|
+
i.kpiComparison,
|
|
354
|
+
"kpi",
|
|
355
|
+
`${t.path}.preferences.kpiVisualOptions.metricComparison`,
|
|
356
|
+
o
|
|
357
|
+
), i.tableComparison && L(
|
|
358
|
+
i.tableComparison,
|
|
359
|
+
"table",
|
|
360
|
+
`${t.path}.preferences.tableVisualOptions.metricComparison`,
|
|
361
|
+
o
|
|
362
|
+
), u && f && JSON.stringify(w(u)) !== JSON.stringify(w(f)) && o.push({
|
|
363
|
+
severity: "error",
|
|
364
|
+
code: "conflicting_legacy_presentation_namespaces",
|
|
365
|
+
path: `${t.path}.preferences`,
|
|
366
|
+
message: "KPI and table comparison presentation values disagree; resolve the conflict before migration."
|
|
367
|
+
});
|
|
368
|
+
}
|
|
369
|
+
}), o.some((t) => t.severity === "error"))
|
|
370
|
+
return { document: e, changed: !1, changes: [], diagnostics: o };
|
|
371
|
+
const s = JSON.parse(JSON.stringify(e)), p = O(s), m = [];
|
|
372
|
+
return p.forEach((t) => {
|
|
373
|
+
var d;
|
|
374
|
+
const c = N(t.card);
|
|
375
|
+
if (t.metrics.forEach(({ metric: a, index: n }) => {
|
|
376
|
+
if (!("comparisonType" in a)) return;
|
|
377
|
+
const i = String(a.comparisonType || ""), u = `${t.path}.config.metricColumns[${n}]`, f = B(a), g = ["comparisonType"];
|
|
378
|
+
delete a.comparisonType, "targetValue" in a && (delete a.targetValue, g.push("targetValue")), "comparisonDisplay" in a && (delete a.comparisonDisplay, g.push("comparisonDisplay")), f ? a.comparison = f : delete a.comparison, _.has(i) && (a.comparisonPolarity = c), m.push({
|
|
379
|
+
kind: "metric",
|
|
380
|
+
path: u,
|
|
381
|
+
metricId: typeof a.id == "string" ? a.id : void 0,
|
|
382
|
+
legacyType: i,
|
|
383
|
+
comparison: f,
|
|
384
|
+
comparisonPolarity: _.has(i) ? c : void 0,
|
|
385
|
+
removedFields: g
|
|
386
|
+
});
|
|
387
|
+
}), M(t.card), t.hasLegacyPresentation) {
|
|
388
|
+
const { namespaces: a, presentation: n } = S(t), i = (d = a.kpiComparison) == null ? void 0 : d.enabled, u = {
|
|
389
|
+
...n
|
|
390
|
+
};
|
|
391
|
+
typeof i == "boolean" && P(t.metrics) && (u.showComparison = i);
|
|
392
|
+
const f = typeof i == "boolean" && v(t) ? i : void 0, g = typeof i == "boolean" && !P(t.metrics) && !v(t) ? ["kpiVisualOptions.metricComparison.enabled"] : void 0, h = a.preferences, b = [];
|
|
393
|
+
t.metrics.forEach(({ metric: y }) => {
|
|
394
|
+
"comparisonPolarity" in y || (y.comparisonPolarity = c, typeof y.id == "string" && b.push(y.id));
|
|
395
|
+
}), Object.keys(u).length && (h.comparisonPresentation = u), f !== void 0 && (h.metricPairComparisonEnabled = f), a.kpiOptions && delete a.kpiOptions.metricComparison, a.tableOptions && delete a.tableOptions.metricComparison, m.push({
|
|
396
|
+
kind: "presentation",
|
|
397
|
+
path: `${t.path}.preferences`,
|
|
398
|
+
comparisonPresentation: Object.keys(u).length ? u : void 0,
|
|
399
|
+
metricPairComparisonEnabled: f,
|
|
400
|
+
comparisonPolarityMetricIds: b,
|
|
401
|
+
intentionallyDiscardedFields: g,
|
|
402
|
+
removedFields: [
|
|
403
|
+
...a.kpiComparison ? ["kpiVisualOptions.metricComparison"] : [],
|
|
404
|
+
...a.tableComparison ? ["tableVisualOptions.metricComparison"] : []
|
|
405
|
+
]
|
|
406
|
+
});
|
|
407
|
+
}
|
|
408
|
+
}), { document: s, changed: !0, changes: m, diagnostics: o };
|
|
409
|
+
}
|
|
410
|
+
export {
|
|
411
|
+
R as D,
|
|
412
|
+
x as a,
|
|
413
|
+
F as t
|
|
414
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";require("./analyze-result-contract-ege_u6Nl.js");const L=require("./metric-comparison-nQKquVnx.js"),I=["lg","md","sm","xs","xxs"],V=15,_=new Set(["previous_period","same_period_last_year","start_vs_end","target"]),k=new Set([..._,"none",""]);function l(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function E(e){const r=l(e.preferences)?e.preferences:void 0,o=r&&l(r.kpiVisualOptions)?r.kpiVisualOptions:void 0,s=r&&l(r.tableVisualOptions)?r.tableVisualOptions:void 0;return{preferences:r,kpiOptions:o,kpiComparison:o&&l(o.metricComparison)?o.metricComparison:void 0,kpiComparisonPresent:!!o&&"metricComparison"in o,tableOptions:s,tableComparison:s&&l(s.metricComparison)?s.metricComparison:void 0,tableComparisonPresent:!!s&&"metricComparison"in s}}function O(e){const r=[],o=(s,p)=>{if(Array.isArray(s)){s.forEach((n,c)=>o(n,`${p}[${c}]`));return}if(!l(s))return;const m=s.config;if(l(m)){const n=E(s),c=!!(n.kpiComparisonPresent||n.tableComparisonPresent),d=m.metricColumns,a=Array.isArray(d)?d.flatMap((t,i)=>l(t)?[{index:i,metric:t}]:[]):[];if((a.some(({metric:t})=>"comparisonType"in t)||c)&&r.push({path:p,card:s,metrics:a,malformedMetricIndexes:Array.isArray(d)?d.flatMap((t,i)=>l(t)?[]:[i]):[],malformedMetricColumns:"metricColumns"in m&&!Array.isArray(d),hasLegacyPresentation:c}),"metricColumns"in m||c)return}Object.entries(s).forEach(([n,c])=>o(c,p?`${p}.${n}`:n))};return o(e,"$"),r}const T={difference:"difference",change:"percent_change",change_difference:"both",ratio:"ratio"};function $(e,r){if(!e)return;const o=Object.fromEntries(r.flatMap(s=>typeof e[s]=="string"?[[s,e[s]]]:[]));return Object.keys(o).length?o:void 0}function N(e,r,o){if(e!==void 0){if(!l(e)){o.push({severity:"error",code:"invalid_legacy_comparison_presentation",path:r,message:"Legacy comparison formatOptions must be an object."});return}Object.entries(e).forEach(([s,p])=>{if(s==="decimalPlaces"){(typeof p!="number"||!Number.isInteger(p)||p<0||p>6)&&o.push({severity:"error",code:"invalid_legacy_comparison_presentation",path:`${r}.decimalPlaces`,message:"Legacy comparison decimalPlaces must be an integer from 0 through 6."});return}s==="type"&&(p===void 0||p==="auto")||p!==void 0&&o.push({severity:"error",code:"unsupported_comparison_format",path:`${r}.${s}`,message:`Legacy comparison format option "${s}" has no canonical presentation mapping.`})})}}function C(e,r){const o=r==="kpi"?e.calculationType:e.calculatedAs,s=r==="table"&&o===void 0?"both":T[String(o)],p=l(e.formatOptions)?e.formatOptions:void 0,m=l(e.conditionalLabels)?e.conditionalLabels:void 0,n=l(r==="kpi"?e.colorConfig:e.colors)?r==="kpi"?e.colorConfig:e.colors:void 0,c={};if(s&&(c.displayMode=s),typeof(p==null?void 0:p.decimalPlaces)=="number"&&(c.precision=p.decimalPlaces),r==="kpi"){const t=e.showArrow!==!1,i=e.showColor!==!1;c.indicatorStyle=t?i?"arrow_badge":"arrow":i?"badge":"none",c.showColor=i,(e.position==="left"||e.position==="right"||e.position==="top")&&(c.position=e.position),typeof e.conditionalLabel=="boolean"&&(c.conditionalLabel=e.conditionalLabel),typeof e.labelName=="string"&&(c.labelName=e.labelName)}else(e.indicatorStyle==="arrow_badge"||e.indicatorStyle==="arrow"||e.indicatorStyle==="badge"||e.indicatorStyle==="none")&&(c.indicatorStyle=e.indicatorStyle);const d=m?{...$(m,["increase","decrease"]),...typeof m.noChange=="string"?{neutral:m.noChange}:typeof m.neutral=="string"?{neutral:m.neutral}:{}}:void 0;d&&Object.keys(d).length&&(c.conditionalLabels=d);const a=n?{...$(n,["increase","decrease"]),...typeof n.noChange=="string"?{neutral:n.noChange}:typeof n.neutral=="string"?{neutral:n.neutral}:{}}:void 0;return a&&Object.keys(a).length&&(c.colors=a),c}function w(e){return{...L.COMPARISON_PRESENTATION_DEFAULTS,...e}}function A(e){return e.some(({metric:r})=>r.comparisonType==="previous_period"||r.comparisonType==="same_period_last_year"||r.comparisonType==="target"?!0:l(r.comparison)&&r.comparison.mode==="explicit")}function v(e){const r=e.card.config;return e.metrics.length===2&&(r.groupByColumns===void 0||Array.isArray(r.groupByColumns)&&r.groupByColumns.length===0)}function P(e,r,o,s){const p=r==="kpi"?["enabled","calculationType","formatOptions","showArrow","showColor","conditionalLabel","labelName","position","conditionalLabels","colorConfig","lowerIsBetter"]:["calculatedAs","indicatorStyle","formatOptions","colors","lowerIsBetter"];Object.keys(e).forEach(t=>{p.includes(t)||s.push({severity:"error",code:"invalid_legacy_comparison_presentation",path:`${o}.${t}`,message:`Unknown legacy comparison presentation field "${t}" cannot be dropped automatically.`})});const m=r==="kpi"?"calculationType":"calculatedAs";e[m]!==void 0&&!T[String(e[m])]&&s.push({severity:"error",code:"invalid_legacy_comparison_presentation",path:`${o}.${m}`,message:`Legacy comparison ${m} is unsupported.`}),r==="kpi"&&e.position!==void 0&&!["left","right","top"].includes(String(e.position))&&s.push({severity:"error",code:"invalid_legacy_comparison_presentation",path:`${o}.position`,message:"Legacy comparison position is unsupported."}),r==="kpi"&&e.labelName!==void 0&&typeof e.labelName!="string"&&s.push({severity:"error",code:"invalid_legacy_comparison_presentation",path:`${o}.labelName`,message:"Legacy comparison labelName must be a string."}),(r==="kpi"?[["conditionalLabels",["increase","decrease","noChange"]],["colorConfig",["increase","decrease","noChange"]]]:[["colors",["increase","decrease","neutral"]]]).forEach(([t,i])=>{if(e[t]!==void 0){if(!l(e[t])){s.push({severity:"error",code:"invalid_legacy_comparison_presentation",path:`${o}.${t}`,message:`Legacy comparison ${t} must be an object.`});return}Object.entries(e[t]).forEach(([u,f])=>{i.includes(u)?typeof f!="string"&&s.push({severity:"error",code:"invalid_legacy_comparison_presentation",path:`${o}.${t}.${u}`,message:`Legacy comparison ${t}.${u} must be a string.`}):s.push({severity:"error",code:"invalid_legacy_comparison_presentation",path:`${o}.${t}.${u}`,message:`Unknown legacy comparison ${t} field "${u}" cannot be dropped automatically.`})})}}),(r==="kpi"?["enabled","showArrow","showColor","conditionalLabel","lowerIsBetter"]:["lowerIsBetter"]).forEach(t=>{e[t]!==void 0&&typeof e[t]!="boolean"&&s.push({severity:"error",code:"invalid_legacy_comparison_presentation",path:`${o}.${t}`,message:`Legacy comparison ${t} must be a boolean.`})}),r==="table"&&e.indicatorStyle!==void 0&&!["arrow_badge","arrow","badge","none"].includes(String(e.indicatorStyle))&&s.push({severity:"error",code:"invalid_legacy_comparison_presentation",path:`${o}.indicatorStyle`,message:"Legacy comparison indicatorStyle is unsupported."}),N(e.formatOptions,`${o}.formatOptions`,s);const d=C(e,r);L.validateComparisonPresentationSpec(d,o).errors.forEach(t=>{s.push({severity:"error",code:"invalid_legacy_comparison_presentation",path:t.path||o,message:t.message})})}function S(e){const r=E(e.card),o=r.kpiComparison?C(r.kpiComparison,"kpi"):void 0,s=r.tableComparison?C(r.tableComparison,"table"):void 0;return{namespaces:r,kpi:o,table:s,presentation:o||s}}function B(e){const r=l(e.preferences)?e.preferences:{},o=l(r.kpiVisualOptions)?r.kpiVisualOptions:{},s=l(o.metricComparison)?o.metricComparison:{},p=l(r.tableVisualOptions)?r.tableVisualOptions:{},m=l(p.metricComparison)?p.metricComparison:{};return o.lowerIsBetter===!0||s.lowerIsBetter===!0||m.lowerIsBetter===!0?"lower_is_better":"higher_is_better"}function D(e){switch(e.comparisonType){case"previous_period":return{mode:"explicit",spec:{kind:"previous_period"}};case"same_period_last_year":return{mode:"explicit",spec:{kind:"previous_year"}};case"target":return{mode:"explicit",spec:{kind:"target",targetValue:e.targetValue}};default:return}}function M(e){const r=l(e.preferences)?e.preferences:void 0;if(!r)return;const o=l(r.kpiVisualOptions)?r.kpiVisualOptions:void 0;o&&delete o.lowerIsBetter;const s=l(r.tableVisualOptions)?r.tableVisualOptions:void 0,p=s&&l(s.metricComparison)?s.metricComparison:void 0;p&&delete p.lowerIsBetter}function R(e){const r=O(e);if(!r.length)return{document:e,changed:!1,changes:[],diagnostics:[]};const o=[];if(r.forEach(n=>{var c,d,a,t;if(n.malformedMetricColumns&&o.push({severity:"error",code:"malformed_metric_columns",path:`${n.path}.config.metricColumns`,message:"Metric columns must be an array before comparison migration."}),n.malformedMetricIndexes.forEach(i=>{o.push({severity:"error",code:"malformed_metric_columns",path:`${n.path}.config.metricColumns[${i}]`,message:"Metric columns must contain objects before comparison migration."})}),n.metrics.forEach(({metric:i,index:u})=>{if(!("comparisonType"in i))return;const f=`${n.path}.config.metricColumns[${u}]`,g=String(i.comparisonType||"");"comparison"in i&&o.push({severity:"error",code:"conflicting_comparison_contracts",path:f,message:"Metric contains both legacy and canonical comparison configuration; resolve the conflict before migration."});const h=l(i.parameters)?i.parameters:void 0,b=h&&l(h.windowTransform)?h.windowTransform:void 0;_.has(g)&&(b==null?void 0:b.function)==="previous_period_delta"&&o.push({severity:"error",code:"conflicting_comparison_window_transform",path:f,message:"A metric cannot combine baseline comparison with previous_period_delta; resolve the authoring intent before migration."}),k.has(g)||o.push({severity:"error",code:"unsupported_comparison_type",path:`${f}.comparisonType`,message:`Unsupported legacy metric comparison type "${g}".`}),i.comparisonType==="target"&&(typeof i.targetValue!="number"||!Number.isFinite(i.targetValue))&&o.push({severity:"error",code:"invalid_target_value",path:`${f}.targetValue`,message:"Legacy target comparison requires a finite metric targetValue."}),i.comparisonType==="start_vs_end"&&o.push({severity:"error",code:"unsupported_start_vs_end",path:`${f}.comparisonType`,message:"start_vs_end is retired and cannot be migrated automatically."}),i.targetValue!==void 0&&i.comparisonType!=="target"&&o.push({severity:"warning",code:"stray_target_value",path:`${f}.targetValue`,message:"Dead non-target targetValue will be removed without changing the baseline."})}),n.hasLegacyPresentation){const{namespaces:i,kpi:u,table:f}=S(n),g=[(c=i.kpiOptions)==null?void 0:c.lowerIsBetter,(d=i.kpiComparison)==null?void 0:d.lowerIsBetter,(a=i.tableComparison)==null?void 0:a.lowerIsBetter].filter(h=>typeof h=="boolean");new Set(g).size>1&&o.push({severity:"error",code:"conflicting_legacy_polarity",path:`${n.path}.preferences`,message:"Legacy comparison polarity values disagree; resolve the conflict before migration."}),((t=i.kpiOptions)==null?void 0:t.lowerIsBetter)!==void 0&&typeof i.kpiOptions.lowerIsBetter!="boolean"&&o.push({severity:"error",code:"invalid_legacy_comparison_presentation",path:`${n.path}.preferences.kpiVisualOptions.lowerIsBetter`,message:"Legacy comparison lowerIsBetter must be a boolean."}),i.kpiComparisonPresent&&!i.kpiComparison&&o.push({severity:"error",code:"invalid_legacy_comparison_presentation",path:`${n.path}.preferences.kpiVisualOptions.metricComparison`,message:"Legacy KPI comparison presentation must be an object."}),i.tableComparisonPresent&&!i.tableComparison&&o.push({severity:"error",code:"invalid_legacy_comparison_presentation",path:`${n.path}.preferences.tableVisualOptions.metricComparison`,message:"Legacy table comparison presentation must be an object."}),"comparisonPresentation"in(i.preferences||{})&&o.push({severity:"error",code:"conflicting_comparison_presentation_contracts",path:`${n.path}.preferences.comparisonPresentation`,message:"Card contains both legacy and canonical comparison presentation; resolve the conflict before migration."}),i.kpiComparison&&typeof i.kpiComparison.enabled=="boolean"&&"metricPairComparisonEnabled"in(i.preferences||{})&&v(n)&&o.push({severity:"error",code:"conflicting_comparison_presentation_contracts",path:`${n.path}.preferences.metricPairComparisonEnabled`,message:"Card contains both legacy and canonical metric-pair enablement; resolve the conflict before migration."}),i.kpiComparison&&P(i.kpiComparison,"kpi",`${n.path}.preferences.kpiVisualOptions.metricComparison`,o),i.tableComparison&&P(i.tableComparison,"table",`${n.path}.preferences.tableVisualOptions.metricComparison`,o),u&&f&&JSON.stringify(w(u))!==JSON.stringify(w(f))&&o.push({severity:"error",code:"conflicting_legacy_presentation_namespaces",path:`${n.path}.preferences`,message:"KPI and table comparison presentation values disagree; resolve the conflict before migration."})}}),o.some(n=>n.severity==="error"))return{document:e,changed:!1,changes:[],diagnostics:o};const s=JSON.parse(JSON.stringify(e)),p=O(s),m=[];return p.forEach(n=>{var d;const c=B(n.card);if(n.metrics.forEach(({metric:a,index:t})=>{if(!("comparisonType"in a))return;const i=String(a.comparisonType||""),u=`${n.path}.config.metricColumns[${t}]`,f=D(a),g=["comparisonType"];delete a.comparisonType,"targetValue"in a&&(delete a.targetValue,g.push("targetValue")),"comparisonDisplay"in a&&(delete a.comparisonDisplay,g.push("comparisonDisplay")),f?a.comparison=f:delete a.comparison,_.has(i)&&(a.comparisonPolarity=c),m.push({kind:"metric",path:u,metricId:typeof a.id=="string"?a.id:void 0,legacyType:i,comparison:f,comparisonPolarity:_.has(i)?c:void 0,removedFields:g})}),M(n.card),n.hasLegacyPresentation){const{namespaces:a,presentation:t}=S(n),i=(d=a.kpiComparison)==null?void 0:d.enabled,u={...t};typeof i=="boolean"&&A(n.metrics)&&(u.showComparison=i);const f=typeof i=="boolean"&&v(n)?i:void 0,g=typeof i=="boolean"&&!A(n.metrics)&&!v(n)?["kpiVisualOptions.metricComparison.enabled"]:void 0,h=a.preferences,b=[];n.metrics.forEach(({metric:y})=>{"comparisonPolarity"in y||(y.comparisonPolarity=c,typeof y.id=="string"&&b.push(y.id))}),Object.keys(u).length&&(h.comparisonPresentation=u),f!==void 0&&(h.metricPairComparisonEnabled=f),a.kpiOptions&&delete a.kpiOptions.metricComparison,a.tableOptions&&delete a.tableOptions.metricComparison,m.push({kind:"presentation",path:`${n.path}.preferences`,comparisonPresentation:Object.keys(u).length?u:void 0,metricPairComparisonEnabled:f,comparisonPolarityMetricIds:b,intentionallyDiscardedFields:g,removedFields:[...a.kpiComparison?["kpiVisualOptions.metricComparison"]:[],...a.tableComparison?["tableVisualOptions.metricComparison"]:[]]})}}),{document:s,changed:!0,changes:m,diagnostics:o}}exports.DASHBOARD_AUTHORING_BREAKPOINTS=I;exports.DASHBOARD_AUTHORING_MAX_GENERATED_CARDS=V;exports.transformComparisonDocument=R;
|