react-semaphor 0.1.443 → 0.1.445
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/CHANGELOG.md +7 -0
- package/dist/analytics-protocol/index.cjs +1 -1
- package/dist/analytics-protocol/index.js +123 -107
- package/dist/appearance/index.cjs +1 -1
- package/dist/brand-studio/index.cjs +2 -2
- package/dist/brand-studio/index.js +5 -4
- package/dist/briefings/index.cjs +1 -1
- package/dist/briefings/index.js +526 -457
- package/dist/chunks/analyze-result-contract-BHb7sUUW.cjs +1 -0
- package/dist/chunks/analyze-result-contract-DUv3QnMl.js +29 -0
- package/dist/chunks/{braces-CbO-aIwH.js → braces-BKimshER.cjs} +1 -1
- package/dist/chunks/{code-editor-BpADiIlq.js → code-editor-B4gTfvc5.js} +6800 -6560
- package/dist/chunks/code-editor-BYVorgOf.cjs +138 -0
- package/dist/chunks/common-types-CQ6SHfLk.cjs +1 -0
- package/dist/chunks/{common-types-ClkOI-3O.js → common-types-DFsDdpH7.js} +22 -21
- package/dist/chunks/dashboard-CAiwJW3L.cjs +1397 -0
- package/dist/chunks/{dashboard-briefing-launcher-C60n8LqW.js → dashboard-briefing-launcher-2SLNOaTg.js} +26 -24
- package/dist/chunks/{dashboard-briefing-launcher-BYMLjZxG.js → dashboard-briefing-launcher-CHwjpUYz.cjs} +2 -2
- package/dist/chunks/{dashboard-controls-ti9Rcel2.js → dashboard-controls-BfL14aqO.js} +11 -9
- package/dist/chunks/{dashboard-controls-BH_fZYDU.js → dashboard-controls-BgGTg4yw.cjs} +2 -2
- package/dist/chunks/dashboard-date-comparison-definition-DZq0htjG.cjs +1 -0
- package/dist/chunks/dashboard-json-BOv8tCa9.cjs +1 -0
- package/dist/chunks/{dashboard-json-Bturr634.js → dashboard-json-BZwq3EcS.js} +14 -12
- package/dist/chunks/{dashboard-Bd1Quco-.js → dashboard-u61yfU6u.js} +50081 -47351
- package/dist/chunks/edit-dashboard-visual-BdVCH0DJ.cjs +182 -0
- package/dist/chunks/{edit-dashboard-visual-DglMds57.js → edit-dashboard-visual-njLPYip3.js} +6825 -6656
- package/dist/chunks/{editor-action-buttons-CRi0fhVW.js → editor-action-buttons-BhLX5Q6m.js} +24 -23
- package/dist/chunks/{editor-action-buttons-Cxo7_tNG.js → editor-action-buttons-CBVMFipA.cjs} +1 -1
- package/dist/chunks/{index-D7KJindZ.js → format-types-CSv0V7mm.cjs} +1 -1
- package/dist/chunks/{index-CnujJ3fa.js → format-types-CZH5w1lo.js} +23 -17
- package/dist/chunks/{layout-grid-B08pP7v6.js → layout-grid-3-HWzEwU.cjs} +1 -1
- package/dist/chunks/{metric-comparison-CPoDx56y.js → metric-comparison-BJ_Qu1ZF.js} +1 -1
- package/dist/chunks/metric-comparison-CUAJ8n4y.cjs +1 -0
- package/dist/chunks/{palette-C0yjT5Tv.js → palette-DW_l7Jr0.cjs} +1 -1
- package/dist/chunks/pivot-result-identity-B6QCWOSi.js +94 -0
- package/dist/chunks/pivot-result-identity-CDLRT-YG.cjs +1 -0
- package/dist/chunks/pivot-result-lifecycle-BM3Pl-D1.js +914 -0
- package/dist/chunks/pivot-result-lifecycle-DPc0ANwk.cjs +4 -0
- package/dist/chunks/presentation-execution-BTV-Q43g.cjs +1 -0
- package/dist/chunks/presentation-execution-CGlb7YZ6.js +637 -0
- package/dist/chunks/{report-preferences-dialog-TtwdAuNn.js → report-preferences-dialog-D_NJu2wU.js} +7 -6
- package/dist/chunks/report-preferences-dialog-r8QzOSFb.cjs +1 -0
- package/dist/chunks/report-runtime-context-C8LZFsqV.cjs +1 -0
- package/dist/chunks/report-runtime-context-Qzn11HQe.js +387 -0
- package/dist/chunks/{save-Xdc4pnys.js → save-4_uMnE6s.cjs} +1 -1
- package/dist/chunks/{search-Dcud9ajy.js → search-6ZmeMq55.cjs} +1 -1
- package/dist/chunks/temporal-bucket-BnPxGrAi.js +446 -0
- package/dist/chunks/temporal-bucket-authoring-BUZMuVca.js +205 -0
- package/dist/chunks/temporal-bucket-authoring-CPTwHzvs.cjs +1 -0
- package/dist/chunks/temporal-bucket-contract-B2bJ1oe4.js +108 -0
- package/dist/chunks/temporal-bucket-contract-ChDBWX8I.cjs +1 -0
- package/dist/chunks/temporal-bucket-pMnV-4Nj.cjs +1 -0
- package/dist/chunks/{comparison-document-migration-Dj6xZMCb.js → temporal-result-owner-Cb27SSG9.js} +152 -123
- package/dist/chunks/temporal-result-owner-f6-i65Fb.cjs +1 -0
- package/dist/chunks/token-types-BdQ8kHBm.cjs +1 -0
- package/dist/chunks/token-types-DLo91nOf.js +8 -0
- package/dist/chunks/{update-policy-DnF_74zC.js → update-policy-BxvYMYz0.cjs} +1 -1
- package/dist/chunks/{update-policy-De2NswtM.js → update-policy-eg59mQqv.js} +1 -1
- package/dist/chunks/validators-9D4KBqKD.cjs +1 -0
- package/dist/chunks/validators-wZ2WlNHc.js +4640 -0
- package/dist/dashboard/index.cjs +1 -1
- package/dist/dashboard/index.js +2 -2
- package/dist/dashboard-authoring/index.cjs +3 -3
- package/dist/dashboard-authoring/index.js +136 -126
- package/dist/data-app-builder/index.cjs +1 -1
- package/dist/data-app-builder/index.js +2 -2
- 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 +2 -2
- package/dist/data-app-sdk/index.js +34 -35
- package/dist/data-app-sdk-adapters/index.cjs +1 -1
- package/dist/data-app-sdk-adapters/index.js +5 -5
- package/dist/data-app-sdk-validation/index.cjs +1 -1
- package/dist/data-app-sdk-validation/index.js +9 -10
- package/dist/format-utils/index.cjs +3 -3
- package/dist/format-utils/index.js +155 -176
- package/dist/index.cjs +1 -1
- package/dist/index.js +180 -174
- package/dist/report-runtime-context/index.cjs +1 -1
- package/dist/report-runtime-context/index.js +7 -392
- package/dist/shared/index.cjs +1 -1
- 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 +257 -48
- package/dist/types/briefings.d.ts +138 -50
- package/dist/types/dashboard-assistant.d.ts +207 -52
- package/dist/types/dashboard-authoring.d.ts +182 -50
- package/dist/types/dashboard.d.ts +290 -48
- package/dist/types/data-app-builder.d.ts +48 -42
- package/dist/types/data-app-codegen-node.d.ts +50 -44
- package/dist/types/data-app-codegen.d.ts +50 -44
- package/dist/types/data-app-sdk-adapters.d.ts +48 -42
- package/dist/types/data-app-sdk-validation.d.ts +81 -43
- package/dist/types/data-app-sdk.d.ts +83 -45
- package/dist/types/format-utils.d.ts +645 -67
- package/dist/types/index.cjs +1 -1
- package/dist/types/index.js +19 -19
- package/dist/types/main.d.ts +298 -94
- package/dist/types/report-runtime-context.d.ts +3 -0
- package/dist/types/shared.d.ts +116 -41
- package/dist/types/surfboard.d.ts +290 -48
- package/dist/types/types.d.ts +455 -65
- package/package.json +3 -1
- package/dist/chunks/analyze-result-contract-BswhsmWT.js +0 -1
- package/dist/chunks/analyze-result-contract-CfOBEwaC.js +0 -1998
- package/dist/chunks/code-editor-M7HTUhdF.js +0 -138
- package/dist/chunks/common-types-C73-Ud1-.js +0 -1
- package/dist/chunks/comparison-document-migration-DbU_BTxR.js +0 -1
- package/dist/chunks/csv-utils-BZDvO2Fw.js +0 -376
- package/dist/chunks/csv-utils-Co0WxHke.js +0 -4
- package/dist/chunks/dashboard-cB3xmTNn.js +0 -1402
- package/dist/chunks/dashboard-date-comparison-definition-DGZr3m-b.js +0 -1
- package/dist/chunks/dashboard-json-Dw_55vSZ.js +0 -1
- package/dist/chunks/edit-dashboard-visual-BUc3NBQ4.js +0 -182
- package/dist/chunks/metric-comparison-DVy3fll_.js +0 -1
- package/dist/chunks/numeric-presentation-BJs5lSar.js +0 -517
- package/dist/chunks/numeric-presentation-Dlb-Dk4c.js +0 -1
- package/dist/chunks/report-preferences-dialog-CCvFqH4Q.js +0 -1
- package/dist/chunks/source-identity-5OPV4gvg.js +0 -92
- package/dist/chunks/source-identity-Cbo2LOHQ.js +0 -1
- package/dist/chunks/validators-B2vUAqTf.js +0 -1
- package/dist/chunks/validators-Bce_J7Vd.js +0 -2448
- /package/dist/chunks/{card-config-utils-15sRtebL.js → card-config-utils-15sRtebL.cjs} +0 -0
- /package/dist/chunks/{catalog-field-grounding-Bnx-3tE0.js → catalog-field-grounding-Bnx-3tE0.cjs} +0 -0
- /package/dist/chunks/{dashboard-input-contract-DV3cshjz.js → dashboard-input-contract-DV3cshjz.cjs} +0 -0
- /package/dist/chunks/{index-Dpm_VET4.js → index-Dpm_VET4.cjs} +0 -0
- /package/dist/chunks/{index-jSrCwPQz.js → index-jSrCwPQz.cjs} +0 -0
- /package/dist/chunks/{normalize-dashboard-for-dirty-check-BXRUMVb2.js → normalize-dashboard-for-dirty-check-BXRUMVb2.cjs} +0 -0
- /package/dist/chunks/{operators-DrTQsJXv.js → operators-DrTQsJXv.cjs} +0 -0
- /package/dist/chunks/{use-debounced-dirty-check-XHSwAefL.js → use-debounced-dirty-check-XHSwAefL.cjs} +0 -0
package/dist/chunks/{comparison-document-migration-Dj6xZMCb.js → temporal-result-owner-Cb27SSG9.js}
RENAMED
|
@@ -1,62 +1,63 @@
|
|
|
1
|
-
import "./
|
|
2
|
-
import
|
|
3
|
-
|
|
1
|
+
import "./validators-wZ2WlNHc.js";
|
|
2
|
+
import "./analyze-result-contract-DUv3QnMl.js";
|
|
3
|
+
import { v as k, C as V } from "./metric-comparison-BJ_Qu1ZF.js";
|
|
4
|
+
const G = [
|
|
4
5
|
"lg",
|
|
5
6
|
"md",
|
|
6
7
|
"sm",
|
|
7
8
|
"xs",
|
|
8
9
|
"xxs"
|
|
9
|
-
],
|
|
10
|
+
], U = 15, _ = /* @__PURE__ */ new Set([
|
|
10
11
|
"previous_period",
|
|
11
12
|
"same_period_last_year",
|
|
12
13
|
"start_vs_end",
|
|
13
14
|
"target"
|
|
14
|
-
]),
|
|
15
|
+
]), I = /* @__PURE__ */ new Set([..._, "none", ""]);
|
|
15
16
|
function l(e) {
|
|
16
17
|
return !!e && typeof e == "object" && !Array.isArray(e);
|
|
17
18
|
}
|
|
18
|
-
function
|
|
19
|
-
const r = l(e.preferences) ? e.preferences : void 0, o = r && l(r.kpiVisualOptions) ? r.kpiVisualOptions : void 0,
|
|
19
|
+
function E(e) {
|
|
20
|
+
const r = l(e.preferences) ? e.preferences : void 0, o = r && l(r.kpiVisualOptions) ? r.kpiVisualOptions : void 0, t = r && l(r.tableVisualOptions) ? r.tableVisualOptions : void 0;
|
|
20
21
|
return {
|
|
21
22
|
preferences: r,
|
|
22
23
|
kpiOptions: o,
|
|
23
24
|
kpiComparison: o && l(o.metricComparison) ? o.metricComparison : void 0,
|
|
24
25
|
kpiComparisonPresent: !!o && "metricComparison" in o,
|
|
25
|
-
tableOptions:
|
|
26
|
-
tableComparison:
|
|
27
|
-
tableComparisonPresent: !!
|
|
26
|
+
tableOptions: t,
|
|
27
|
+
tableComparison: t && l(t.metricComparison) ? t.metricComparison : void 0,
|
|
28
|
+
tableComparisonPresent: !!t && "metricComparison" in t
|
|
28
29
|
};
|
|
29
30
|
}
|
|
30
31
|
function O(e) {
|
|
31
|
-
const r = [], o = (
|
|
32
|
-
if (Array.isArray(
|
|
33
|
-
|
|
32
|
+
const r = [], o = (t, p) => {
|
|
33
|
+
if (Array.isArray(t)) {
|
|
34
|
+
t.forEach((n, c) => o(n, `${p}[${c}]`));
|
|
34
35
|
return;
|
|
35
36
|
}
|
|
36
|
-
if (!l(
|
|
37
|
-
const m =
|
|
37
|
+
if (!l(t)) return;
|
|
38
|
+
const m = t.config;
|
|
38
39
|
if (l(m)) {
|
|
39
|
-
const
|
|
40
|
-
(
|
|
40
|
+
const n = E(t), c = !!(n.kpiComparisonPresent || n.tableComparisonPresent), d = m.metricColumns, a = Array.isArray(d) ? d.flatMap(
|
|
41
|
+
(s, i) => l(s) ? [{ index: i, metric: s }] : []
|
|
41
42
|
) : [];
|
|
42
|
-
if ((a.some(({ metric:
|
|
43
|
+
if ((a.some(({ metric: s }) => "comparisonType" in s) || c) && r.push({
|
|
43
44
|
path: p,
|
|
44
|
-
card:
|
|
45
|
+
card: t,
|
|
45
46
|
metrics: a,
|
|
46
47
|
malformedMetricIndexes: Array.isArray(d) ? d.flatMap(
|
|
47
|
-
(
|
|
48
|
+
(s, i) => l(s) ? [] : [i]
|
|
48
49
|
) : [],
|
|
49
50
|
malformedMetricColumns: "metricColumns" in m && !Array.isArray(d),
|
|
50
51
|
hasLegacyPresentation: c
|
|
51
52
|
}), "metricColumns" in m || c) return;
|
|
52
53
|
}
|
|
53
|
-
Object.entries(
|
|
54
|
-
([
|
|
54
|
+
Object.entries(t).forEach(
|
|
55
|
+
([n, c]) => o(c, p ? `${p}.${n}` : n)
|
|
55
56
|
);
|
|
56
57
|
};
|
|
57
58
|
return o(e, "$"), r;
|
|
58
59
|
}
|
|
59
|
-
const
|
|
60
|
+
const L = {
|
|
60
61
|
difference: "difference",
|
|
61
62
|
change: "percent_change",
|
|
62
63
|
change_difference: "both",
|
|
@@ -66,12 +67,12 @@ function $(e, r) {
|
|
|
66
67
|
if (!e) return;
|
|
67
68
|
const o = Object.fromEntries(
|
|
68
69
|
r.flatMap(
|
|
69
|
-
(
|
|
70
|
+
(t) => typeof e[t] == "string" ? [[t, e[t]]] : []
|
|
70
71
|
)
|
|
71
72
|
);
|
|
72
73
|
return Object.keys(o).length ? o : void 0;
|
|
73
74
|
}
|
|
74
|
-
function
|
|
75
|
+
function N(e, r, o) {
|
|
75
76
|
if (e !== void 0) {
|
|
76
77
|
if (!l(e)) {
|
|
77
78
|
o.push({
|
|
@@ -82,8 +83,8 @@ function I(e, r, o) {
|
|
|
82
83
|
});
|
|
83
84
|
return;
|
|
84
85
|
}
|
|
85
|
-
Object.entries(e).forEach(([
|
|
86
|
-
if (
|
|
86
|
+
Object.entries(e).forEach(([t, p]) => {
|
|
87
|
+
if (t === "decimalPlaces") {
|
|
87
88
|
(typeof p != "number" || !Number.isInteger(p) || p < 0 || p > 6) && o.push({
|
|
88
89
|
severity: "error",
|
|
89
90
|
code: "invalid_legacy_comparison_presentation",
|
|
@@ -92,45 +93,45 @@ function I(e, r, o) {
|
|
|
92
93
|
});
|
|
93
94
|
return;
|
|
94
95
|
}
|
|
95
|
-
|
|
96
|
+
t === "type" && (p === void 0 || p === "auto") || p !== void 0 && o.push({
|
|
96
97
|
severity: "error",
|
|
97
98
|
code: "unsupported_comparison_format",
|
|
98
|
-
path: `${r}.${
|
|
99
|
-
message: `Legacy comparison format option "${
|
|
99
|
+
path: `${r}.${t}`,
|
|
100
|
+
message: `Legacy comparison format option "${t}" has no canonical presentation mapping.`
|
|
100
101
|
});
|
|
101
102
|
});
|
|
102
103
|
}
|
|
103
104
|
}
|
|
104
|
-
function
|
|
105
|
-
const o = r === "kpi" ? e.calculationType : e.calculatedAs,
|
|
105
|
+
function v(e, r) {
|
|
106
|
+
const o = r === "kpi" ? e.calculationType : e.calculatedAs, t = r === "table" && o === void 0 ? "both" : L[String(o)], p = l(e.formatOptions) ? e.formatOptions : void 0, m = l(e.conditionalLabels) ? e.conditionalLabels : void 0, n = l(
|
|
106
107
|
r === "kpi" ? e.colorConfig : e.colors
|
|
107
108
|
) ? r === "kpi" ? e.colorConfig : e.colors : void 0, c = {};
|
|
108
|
-
if (
|
|
109
|
-
const
|
|
110
|
-
c.indicatorStyle =
|
|
109
|
+
if (t && (c.displayMode = t), typeof (p == null ? void 0 : p.decimalPlaces) == "number" && (c.precision = p.decimalPlaces), r === "kpi") {
|
|
110
|
+
const s = e.showArrow !== !1, i = e.showColor !== !1;
|
|
111
|
+
c.indicatorStyle = s ? 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
112
|
} else (e.indicatorStyle === "arrow_badge" || e.indicatorStyle === "arrow" || e.indicatorStyle === "badge" || e.indicatorStyle === "none") && (c.indicatorStyle = e.indicatorStyle);
|
|
112
113
|
const d = m ? {
|
|
113
114
|
...$(m, ["increase", "decrease"]),
|
|
114
115
|
...typeof m.noChange == "string" ? { neutral: m.noChange } : typeof m.neutral == "string" ? { neutral: m.neutral } : {}
|
|
115
116
|
} : void 0;
|
|
116
117
|
d && Object.keys(d).length && (c.conditionalLabels = d);
|
|
117
|
-
const a =
|
|
118
|
-
...$(
|
|
119
|
-
...typeof
|
|
118
|
+
const a = n ? {
|
|
119
|
+
...$(n, ["increase", "decrease"]),
|
|
120
|
+
...typeof n.noChange == "string" ? { neutral: n.noChange } : typeof n.neutral == "string" ? { neutral: n.neutral } : {}
|
|
120
121
|
} : void 0;
|
|
121
122
|
return a && Object.keys(a).length && (c.colors = a), c;
|
|
122
123
|
}
|
|
123
124
|
function w(e) {
|
|
124
|
-
return { ...
|
|
125
|
+
return { ...V, ...e };
|
|
125
126
|
}
|
|
126
127
|
function P(e) {
|
|
127
128
|
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
|
}
|
|
129
|
-
function
|
|
130
|
+
function C(e) {
|
|
130
131
|
const r = e.card.config;
|
|
131
132
|
return e.metrics.length === 2 && (r.groupByColumns === void 0 || Array.isArray(r.groupByColumns) && r.groupByColumns.length === 0);
|
|
132
133
|
}
|
|
133
|
-
function
|
|
134
|
+
function S(e, r, o, t) {
|
|
134
135
|
const p = r === "kpi" ? [
|
|
135
136
|
"enabled",
|
|
136
137
|
"calculationType",
|
|
@@ -150,26 +151,26 @@ function L(e, r, o, s) {
|
|
|
150
151
|
"colors",
|
|
151
152
|
"lowerIsBetter"
|
|
152
153
|
];
|
|
153
|
-
Object.keys(e).forEach((
|
|
154
|
-
p.includes(
|
|
154
|
+
Object.keys(e).forEach((s) => {
|
|
155
|
+
p.includes(s) || t.push({
|
|
155
156
|
severity: "error",
|
|
156
157
|
code: "invalid_legacy_comparison_presentation",
|
|
157
|
-
path: `${o}.${
|
|
158
|
-
message: `Unknown legacy comparison presentation field "${
|
|
158
|
+
path: `${o}.${s}`,
|
|
159
|
+
message: `Unknown legacy comparison presentation field "${s}" cannot be dropped automatically.`
|
|
159
160
|
});
|
|
160
161
|
});
|
|
161
162
|
const m = r === "kpi" ? "calculationType" : "calculatedAs";
|
|
162
|
-
e[m] !== void 0 && !
|
|
163
|
+
e[m] !== void 0 && !L[String(e[m])] && t.push({
|
|
163
164
|
severity: "error",
|
|
164
165
|
code: "invalid_legacy_comparison_presentation",
|
|
165
166
|
path: `${o}.${m}`,
|
|
166
167
|
message: `Legacy comparison ${m} is unsupported.`
|
|
167
|
-
}), r === "kpi" && e.position !== void 0 && !["left", "right", "top"].includes(String(e.position)) &&
|
|
168
|
+
}), r === "kpi" && e.position !== void 0 && !["left", "right", "top"].includes(String(e.position)) && t.push({
|
|
168
169
|
severity: "error",
|
|
169
170
|
code: "invalid_legacy_comparison_presentation",
|
|
170
171
|
path: `${o}.position`,
|
|
171
172
|
message: "Legacy comparison position is unsupported."
|
|
172
|
-
}), r === "kpi" && e.labelName !== void 0 && typeof e.labelName != "string" &&
|
|
173
|
+
}), r === "kpi" && e.labelName !== void 0 && typeof e.labelName != "string" && t.push({
|
|
173
174
|
severity: "error",
|
|
174
175
|
code: "invalid_legacy_comparison_presentation",
|
|
175
176
|
path: `${o}.labelName`,
|
|
@@ -177,65 +178,65 @@ function L(e, r, o, s) {
|
|
|
177
178
|
}), (r === "kpi" ? [
|
|
178
179
|
["conditionalLabels", ["increase", "decrease", "noChange"]],
|
|
179
180
|
["colorConfig", ["increase", "decrease", "noChange"]]
|
|
180
|
-
] : [["colors", ["increase", "decrease", "neutral"]]]).forEach(([
|
|
181
|
-
if (e[
|
|
182
|
-
if (!l(e[
|
|
183
|
-
|
|
181
|
+
] : [["colors", ["increase", "decrease", "neutral"]]]).forEach(([s, i]) => {
|
|
182
|
+
if (e[s] !== void 0) {
|
|
183
|
+
if (!l(e[s])) {
|
|
184
|
+
t.push({
|
|
184
185
|
severity: "error",
|
|
185
186
|
code: "invalid_legacy_comparison_presentation",
|
|
186
|
-
path: `${o}.${
|
|
187
|
-
message: `Legacy comparison ${
|
|
187
|
+
path: `${o}.${s}`,
|
|
188
|
+
message: `Legacy comparison ${s} must be an object.`
|
|
188
189
|
});
|
|
189
190
|
return;
|
|
190
191
|
}
|
|
191
|
-
Object.entries(e[
|
|
192
|
-
i.includes(u) ? typeof f != "string" &&
|
|
192
|
+
Object.entries(e[s]).forEach(([u, f]) => {
|
|
193
|
+
i.includes(u) ? typeof f != "string" && t.push({
|
|
193
194
|
severity: "error",
|
|
194
195
|
code: "invalid_legacy_comparison_presentation",
|
|
195
|
-
path: `${o}.${
|
|
196
|
-
message: `Legacy comparison ${
|
|
197
|
-
}) :
|
|
196
|
+
path: `${o}.${s}.${u}`,
|
|
197
|
+
message: `Legacy comparison ${s}.${u} must be a string.`
|
|
198
|
+
}) : t.push({
|
|
198
199
|
severity: "error",
|
|
199
200
|
code: "invalid_legacy_comparison_presentation",
|
|
200
|
-
path: `${o}.${
|
|
201
|
-
message: `Unknown legacy comparison ${
|
|
201
|
+
path: `${o}.${s}.${u}`,
|
|
202
|
+
message: `Unknown legacy comparison ${s} field "${u}" cannot be dropped automatically.`
|
|
202
203
|
});
|
|
203
204
|
});
|
|
204
205
|
}
|
|
205
|
-
}), (r === "kpi" ? ["enabled", "showArrow", "showColor", "conditionalLabel", "lowerIsBetter"] : ["lowerIsBetter"]).forEach((
|
|
206
|
-
e[
|
|
206
|
+
}), (r === "kpi" ? ["enabled", "showArrow", "showColor", "conditionalLabel", "lowerIsBetter"] : ["lowerIsBetter"]).forEach((s) => {
|
|
207
|
+
e[s] !== void 0 && typeof e[s] != "boolean" && t.push({
|
|
207
208
|
severity: "error",
|
|
208
209
|
code: "invalid_legacy_comparison_presentation",
|
|
209
|
-
path: `${o}.${
|
|
210
|
-
message: `Legacy comparison ${
|
|
210
|
+
path: `${o}.${s}`,
|
|
211
|
+
message: `Legacy comparison ${s} must be a boolean.`
|
|
211
212
|
});
|
|
212
213
|
}), r === "table" && e.indicatorStyle !== void 0 && !["arrow_badge", "arrow", "badge", "none"].includes(
|
|
213
214
|
String(e.indicatorStyle)
|
|
214
|
-
) &&
|
|
215
|
+
) && t.push({
|
|
215
216
|
severity: "error",
|
|
216
217
|
code: "invalid_legacy_comparison_presentation",
|
|
217
218
|
path: `${o}.indicatorStyle`,
|
|
218
219
|
message: "Legacy comparison indicatorStyle is unsupported."
|
|
219
|
-
}),
|
|
220
|
-
const d =
|
|
221
|
-
|
|
222
|
-
|
|
220
|
+
}), N(e.formatOptions, `${o}.formatOptions`, t);
|
|
221
|
+
const d = v(e, r);
|
|
222
|
+
k(d, o).errors.forEach((s) => {
|
|
223
|
+
t.push({
|
|
223
224
|
severity: "error",
|
|
224
225
|
code: "invalid_legacy_comparison_presentation",
|
|
225
|
-
path:
|
|
226
|
-
message:
|
|
226
|
+
path: s.path || o,
|
|
227
|
+
message: s.message
|
|
227
228
|
});
|
|
228
229
|
});
|
|
229
230
|
}
|
|
230
|
-
function
|
|
231
|
-
const r =
|
|
232
|
-
return { namespaces: r, kpi: o, table:
|
|
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";
|
|
231
|
+
function A(e) {
|
|
232
|
+
const r = E(e.card), o = r.kpiComparison ? v(r.kpiComparison, "kpi") : void 0, t = r.tableComparison ? v(r.tableComparison, "table") : void 0;
|
|
233
|
+
return { namespaces: r, kpi: o, table: t, presentation: o || t };
|
|
237
234
|
}
|
|
238
235
|
function B(e) {
|
|
236
|
+
const r = l(e.preferences) ? e.preferences : {}, o = l(r.kpiVisualOptions) ? r.kpiVisualOptions : {}, t = l(o.metricComparison) ? o.metricComparison : {}, p = l(r.tableVisualOptions) ? r.tableVisualOptions : {}, m = l(p.metricComparison) ? p.metricComparison : {};
|
|
237
|
+
return o.lowerIsBetter === !0 || t.lowerIsBetter === !0 || m.lowerIsBetter === !0 ? "lower_is_better" : "higher_is_better";
|
|
238
|
+
}
|
|
239
|
+
function M(e) {
|
|
239
240
|
switch (e.comparisonType) {
|
|
240
241
|
case "previous_period":
|
|
241
242
|
return { mode: "explicit", spec: { kind: "previous_period" } };
|
|
@@ -250,36 +251,36 @@ function B(e) {
|
|
|
250
251
|
return;
|
|
251
252
|
}
|
|
252
253
|
}
|
|
253
|
-
function
|
|
254
|
+
function R(e) {
|
|
254
255
|
const r = l(e.preferences) ? e.preferences : void 0;
|
|
255
256
|
if (!r) return;
|
|
256
257
|
const o = l(r.kpiVisualOptions) ? r.kpiVisualOptions : void 0;
|
|
257
258
|
o && delete o.lowerIsBetter;
|
|
258
|
-
const
|
|
259
|
+
const t = l(r.tableVisualOptions) ? r.tableVisualOptions : void 0, p = t && l(t.metricComparison) ? t.metricComparison : void 0;
|
|
259
260
|
p && delete p.lowerIsBetter;
|
|
260
261
|
}
|
|
261
|
-
function
|
|
262
|
+
function z(e) {
|
|
262
263
|
const r = O(e);
|
|
263
264
|
if (!r.length)
|
|
264
265
|
return { document: e, changed: !1, changes: [], diagnostics: [] };
|
|
265
266
|
const o = [];
|
|
266
|
-
if (r.forEach((
|
|
267
|
-
var c, d, a,
|
|
268
|
-
if (
|
|
267
|
+
if (r.forEach((n) => {
|
|
268
|
+
var c, d, a, s;
|
|
269
|
+
if (n.malformedMetricColumns && o.push({
|
|
269
270
|
severity: "error",
|
|
270
271
|
code: "malformed_metric_columns",
|
|
271
|
-
path: `${
|
|
272
|
+
path: `${n.path}.config.metricColumns`,
|
|
272
273
|
message: "Metric columns must be an array before comparison migration."
|
|
273
|
-
}),
|
|
274
|
+
}), n.malformedMetricIndexes.forEach((i) => {
|
|
274
275
|
o.push({
|
|
275
276
|
severity: "error",
|
|
276
277
|
code: "malformed_metric_columns",
|
|
277
|
-
path: `${
|
|
278
|
+
path: `${n.path}.config.metricColumns[${i}]`,
|
|
278
279
|
message: "Metric columns must contain objects before comparison migration."
|
|
279
280
|
});
|
|
280
|
-
}),
|
|
281
|
+
}), n.metrics.forEach(({ metric: i, index: u }) => {
|
|
281
282
|
if (!("comparisonType" in i)) return;
|
|
282
|
-
const f = `${
|
|
283
|
+
const f = `${n.path}.config.metricColumns[${u}]`, g = String(i.comparisonType || "");
|
|
283
284
|
"comparison" in i && o.push({
|
|
284
285
|
severity: "error",
|
|
285
286
|
code: "conflicting_comparison_contracts",
|
|
@@ -292,7 +293,7 @@ function F(e) {
|
|
|
292
293
|
code: "conflicting_comparison_window_transform",
|
|
293
294
|
path: f,
|
|
294
295
|
message: "A metric cannot combine baseline comparison with previous_period_delta; resolve the authoring intent before migration."
|
|
295
|
-
}),
|
|
296
|
+
}), I.has(g) || o.push({
|
|
296
297
|
severity: "error",
|
|
297
298
|
code: "unsupported_comparison_type",
|
|
298
299
|
path: `${f}.comparisonType`,
|
|
@@ -313,8 +314,8 @@ function F(e) {
|
|
|
313
314
|
path: `${f}.targetValue`,
|
|
314
315
|
message: "Dead non-target targetValue will be removed without changing the baseline."
|
|
315
316
|
});
|
|
316
|
-
}),
|
|
317
|
-
const { namespaces: i, kpi: u, table: f } =
|
|
317
|
+
}), n.hasLegacyPresentation) {
|
|
318
|
+
const { namespaces: i, kpi: u, table: f } = A(n), g = [
|
|
318
319
|
(c = i.kpiOptions) == null ? void 0 : c.lowerIsBetter,
|
|
319
320
|
(d = i.kpiComparison) == null ? void 0 : d.lowerIsBetter,
|
|
320
321
|
(a = i.tableComparison) == null ? void 0 : a.lowerIsBetter
|
|
@@ -322,59 +323,59 @@ function F(e) {
|
|
|
322
323
|
new Set(g).size > 1 && o.push({
|
|
323
324
|
severity: "error",
|
|
324
325
|
code: "conflicting_legacy_polarity",
|
|
325
|
-
path: `${
|
|
326
|
+
path: `${n.path}.preferences`,
|
|
326
327
|
message: "Legacy comparison polarity values disagree; resolve the conflict before migration."
|
|
327
|
-
}), ((
|
|
328
|
+
}), ((s = i.kpiOptions) == null ? void 0 : s.lowerIsBetter) !== void 0 && typeof i.kpiOptions.lowerIsBetter != "boolean" && o.push({
|
|
328
329
|
severity: "error",
|
|
329
330
|
code: "invalid_legacy_comparison_presentation",
|
|
330
|
-
path: `${
|
|
331
|
+
path: `${n.path}.preferences.kpiVisualOptions.lowerIsBetter`,
|
|
331
332
|
message: "Legacy comparison lowerIsBetter must be a boolean."
|
|
332
333
|
}), i.kpiComparisonPresent && !i.kpiComparison && o.push({
|
|
333
334
|
severity: "error",
|
|
334
335
|
code: "invalid_legacy_comparison_presentation",
|
|
335
|
-
path: `${
|
|
336
|
+
path: `${n.path}.preferences.kpiVisualOptions.metricComparison`,
|
|
336
337
|
message: "Legacy KPI comparison presentation must be an object."
|
|
337
338
|
}), i.tableComparisonPresent && !i.tableComparison && o.push({
|
|
338
339
|
severity: "error",
|
|
339
340
|
code: "invalid_legacy_comparison_presentation",
|
|
340
|
-
path: `${
|
|
341
|
+
path: `${n.path}.preferences.tableVisualOptions.metricComparison`,
|
|
341
342
|
message: "Legacy table comparison presentation must be an object."
|
|
342
343
|
}), "comparisonPresentation" in (i.preferences || {}) && o.push({
|
|
343
344
|
severity: "error",
|
|
344
345
|
code: "conflicting_comparison_presentation_contracts",
|
|
345
|
-
path: `${
|
|
346
|
+
path: `${n.path}.preferences.comparisonPresentation`,
|
|
346
347
|
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 || {}) &&
|
|
348
|
+
}), i.kpiComparison && typeof i.kpiComparison.enabled == "boolean" && "metricPairComparisonEnabled" in (i.preferences || {}) && C(n) && o.push({
|
|
348
349
|
severity: "error",
|
|
349
350
|
code: "conflicting_comparison_presentation_contracts",
|
|
350
|
-
path: `${
|
|
351
|
+
path: `${n.path}.preferences.metricPairComparisonEnabled`,
|
|
351
352
|
message: "Card contains both legacy and canonical metric-pair enablement; resolve the conflict before migration."
|
|
352
|
-
}), i.kpiComparison &&
|
|
353
|
+
}), i.kpiComparison && S(
|
|
353
354
|
i.kpiComparison,
|
|
354
355
|
"kpi",
|
|
355
|
-
`${
|
|
356
|
+
`${n.path}.preferences.kpiVisualOptions.metricComparison`,
|
|
356
357
|
o
|
|
357
|
-
), i.tableComparison &&
|
|
358
|
+
), i.tableComparison && S(
|
|
358
359
|
i.tableComparison,
|
|
359
360
|
"table",
|
|
360
|
-
`${
|
|
361
|
+
`${n.path}.preferences.tableVisualOptions.metricComparison`,
|
|
361
362
|
o
|
|
362
363
|
), u && f && JSON.stringify(w(u)) !== JSON.stringify(w(f)) && o.push({
|
|
363
364
|
severity: "error",
|
|
364
365
|
code: "conflicting_legacy_presentation_namespaces",
|
|
365
|
-
path: `${
|
|
366
|
+
path: `${n.path}.preferences`,
|
|
366
367
|
message: "KPI and table comparison presentation values disagree; resolve the conflict before migration."
|
|
367
368
|
});
|
|
368
369
|
}
|
|
369
|
-
}), o.some((
|
|
370
|
+
}), o.some((n) => n.severity === "error"))
|
|
370
371
|
return { document: e, changed: !1, changes: [], diagnostics: o };
|
|
371
|
-
const
|
|
372
|
-
return p.forEach((
|
|
372
|
+
const t = JSON.parse(JSON.stringify(e)), p = O(t), m = [];
|
|
373
|
+
return p.forEach((n) => {
|
|
373
374
|
var d;
|
|
374
|
-
const c =
|
|
375
|
-
if (
|
|
375
|
+
const c = B(n.card);
|
|
376
|
+
if (n.metrics.forEach(({ metric: a, index: s }) => {
|
|
376
377
|
if (!("comparisonType" in a)) return;
|
|
377
|
-
const i = String(a.comparisonType || ""), u = `${
|
|
378
|
+
const i = String(a.comparisonType || ""), u = `${n.path}.config.metricColumns[${s}]`, f = M(a), g = ["comparisonType"];
|
|
378
379
|
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
380
|
kind: "metric",
|
|
380
381
|
path: u,
|
|
@@ -384,17 +385,17 @@ function F(e) {
|
|
|
384
385
|
comparisonPolarity: _.has(i) ? c : void 0,
|
|
385
386
|
removedFields: g
|
|
386
387
|
});
|
|
387
|
-
}),
|
|
388
|
-
const { namespaces: a, presentation:
|
|
389
|
-
...
|
|
388
|
+
}), R(n.card), n.hasLegacyPresentation) {
|
|
389
|
+
const { namespaces: a, presentation: s } = A(n), i = (d = a.kpiComparison) == null ? void 0 : d.enabled, u = {
|
|
390
|
+
...s
|
|
390
391
|
};
|
|
391
|
-
typeof i == "boolean" && P(
|
|
392
|
-
const f = typeof i == "boolean" &&
|
|
393
|
-
|
|
392
|
+
typeof i == "boolean" && P(n.metrics) && (u.showComparison = i);
|
|
393
|
+
const f = typeof i == "boolean" && C(n) ? i : void 0, g = typeof i == "boolean" && !P(n.metrics) && !C(n) ? ["kpiVisualOptions.metricComparison.enabled"] : void 0, h = a.preferences, b = [];
|
|
394
|
+
n.metrics.forEach(({ metric: y }) => {
|
|
394
395
|
"comparisonPolarity" in y || (y.comparisonPolarity = c, typeof y.id == "string" && b.push(y.id));
|
|
395
396
|
}), 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
397
|
kind: "presentation",
|
|
397
|
-
path: `${
|
|
398
|
+
path: `${n.path}.preferences`,
|
|
398
399
|
comparisonPresentation: Object.keys(u).length ? u : void 0,
|
|
399
400
|
metricPairComparisonEnabled: f,
|
|
400
401
|
comparisonPolarityMetricIds: b,
|
|
@@ -405,10 +406,38 @@ function F(e) {
|
|
|
405
406
|
]
|
|
406
407
|
});
|
|
407
408
|
}
|
|
408
|
-
}), { document:
|
|
409
|
+
}), { document: t, changed: !0, changes: m, diagnostics: o };
|
|
410
|
+
}
|
|
411
|
+
const D = [
|
|
412
|
+
"bar",
|
|
413
|
+
"horizontalBar",
|
|
414
|
+
"line",
|
|
415
|
+
"area",
|
|
416
|
+
"stackedArea",
|
|
417
|
+
"combo",
|
|
418
|
+
"stackedBar",
|
|
419
|
+
"stackedLine"
|
|
420
|
+
], j = new Set(
|
|
421
|
+
D
|
|
422
|
+
);
|
|
423
|
+
function x(e) {
|
|
424
|
+
return typeof e == "string" && j.has(e);
|
|
425
|
+
}
|
|
426
|
+
function J(e) {
|
|
427
|
+
return e === "table" || e === "aggregateTable" || e === "pivotTable" || e === "custom" || x(e);
|
|
428
|
+
}
|
|
429
|
+
function T(e) {
|
|
430
|
+
return !!(e != null && e.trim());
|
|
431
|
+
}
|
|
432
|
+
function K(e) {
|
|
433
|
+
return T(e.sql) || T(e.normalizedPython) ? "freeform" : e.hasExecutableConfig ? "config" : "none";
|
|
409
434
|
}
|
|
410
435
|
export {
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
436
|
+
U as D,
|
|
437
|
+
D as S,
|
|
438
|
+
G as a,
|
|
439
|
+
x as i,
|
|
440
|
+
K as r,
|
|
441
|
+
J as s,
|
|
442
|
+
z as t
|
|
414
443
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";require("./validators-9D4KBqKD.cjs");require("./analyze-result-contract-BHb7sUUW.cjs");const E=require("./metric-comparison-CUAJ8n4y.cjs"),N=["lg","md","sm","xs","xxs"],R=15,y=new Set(["previous_period","same_period_last_year","start_vs_end","target"]),B=new Set([...y,"none",""]);function l(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function L(e){const r=l(e.preferences)?e.preferences:void 0,o=r&&l(r.kpiVisualOptions)?r.kpiVisualOptions:void 0,n=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:n,tableComparison:n&&l(n.metricComparison)?n.metricComparison:void 0,tableComparisonPresent:!!n&&"metricComparison"in n}}function O(e){const r=[],o=(n,p)=>{if(Array.isArray(n)){n.forEach((t,c)=>o(t,`${p}[${c}]`));return}if(!l(n))return;const m=n.config;if(l(m)){const t=L(n),c=!!(t.kpiComparisonPresent||t.tableComparisonPresent),d=m.metricColumns,a=Array.isArray(d)?d.flatMap((s,i)=>l(s)?[{index:i,metric:s}]:[]):[];if((a.some(({metric:s})=>"comparisonType"in s)||c)&&r.push({path:p,card:n,metrics:a,malformedMetricIndexes:Array.isArray(d)?d.flatMap((s,i)=>l(s)?[]:[i]):[],malformedMetricColumns:"metricColumns"in m&&!Array.isArray(d),hasLegacyPresentation:c}),"metricColumns"in m||c)return}Object.entries(n).forEach(([t,c])=>o(c,p?`${p}.${t}`:t))};return o(e,"$"),r}const I={difference:"difference",change:"percent_change",change_difference:"both",ratio:"ratio"};function A(e,r){if(!e)return;const o=Object.fromEntries(r.flatMap(n=>typeof e[n]=="string"?[[n,e[n]]]:[]));return Object.keys(o).length?o:void 0}function D(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(([n,p])=>{if(n==="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}n==="type"&&(p===void 0||p==="auto")||p!==void 0&&o.push({severity:"error",code:"unsupported_comparison_format",path:`${r}.${n}`,message:`Legacy comparison format option "${n}" has no canonical presentation mapping.`})})}}function v(e,r){const o=r==="kpi"?e.calculationType:e.calculatedAs,n=r==="table"&&o===void 0?"both":I[String(o)],p=l(e.formatOptions)?e.formatOptions:void 0,m=l(e.conditionalLabels)?e.conditionalLabels:void 0,t=l(r==="kpi"?e.colorConfig:e.colors)?r==="kpi"?e.colorConfig:e.colors:void 0,c={};if(n&&(c.displayMode=n),typeof(p==null?void 0:p.decimalPlaces)=="number"&&(c.precision=p.decimalPlaces),r==="kpi"){const s=e.showArrow!==!1,i=e.showColor!==!1;c.indicatorStyle=s?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?{...A(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=t?{...A(t,["increase","decrease"]),...typeof t.noChange=="string"?{neutral:t.noChange}:typeof t.neutral=="string"?{neutral:t.neutral}:{}}:void 0;return a&&Object.keys(a).length&&(c.colors=a),c}function $(e){return{...E.COMPARISON_PRESENTATION_DEFAULTS,...e}}function w(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 C(e){const r=e.card.config;return e.metrics.length===2&&(r.groupByColumns===void 0||Array.isArray(r.groupByColumns)&&r.groupByColumns.length===0)}function S(e,r,o,n){const p=r==="kpi"?["enabled","calculationType","formatOptions","showArrow","showColor","conditionalLabel","labelName","position","conditionalLabels","colorConfig","lowerIsBetter"]:["calculatedAs","indicatorStyle","formatOptions","colors","lowerIsBetter"];Object.keys(e).forEach(s=>{p.includes(s)||n.push({severity:"error",code:"invalid_legacy_comparison_presentation",path:`${o}.${s}`,message:`Unknown legacy comparison presentation field "${s}" cannot be dropped automatically.`})});const m=r==="kpi"?"calculationType":"calculatedAs";e[m]!==void 0&&!I[String(e[m])]&&n.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))&&n.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"&&n.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(([s,i])=>{if(e[s]!==void 0){if(!l(e[s])){n.push({severity:"error",code:"invalid_legacy_comparison_presentation",path:`${o}.${s}`,message:`Legacy comparison ${s} must be an object.`});return}Object.entries(e[s]).forEach(([u,f])=>{i.includes(u)?typeof f!="string"&&n.push({severity:"error",code:"invalid_legacy_comparison_presentation",path:`${o}.${s}.${u}`,message:`Legacy comparison ${s}.${u} must be a string.`}):n.push({severity:"error",code:"invalid_legacy_comparison_presentation",path:`${o}.${s}.${u}`,message:`Unknown legacy comparison ${s} field "${u}" cannot be dropped automatically.`})})}}),(r==="kpi"?["enabled","showArrow","showColor","conditionalLabel","lowerIsBetter"]:["lowerIsBetter"]).forEach(s=>{e[s]!==void 0&&typeof e[s]!="boolean"&&n.push({severity:"error",code:"invalid_legacy_comparison_presentation",path:`${o}.${s}`,message:`Legacy comparison ${s} must be a boolean.`})}),r==="table"&&e.indicatorStyle!==void 0&&!["arrow_badge","arrow","badge","none"].includes(String(e.indicatorStyle))&&n.push({severity:"error",code:"invalid_legacy_comparison_presentation",path:`${o}.indicatorStyle`,message:"Legacy comparison indicatorStyle is unsupported."}),D(e.formatOptions,`${o}.formatOptions`,n);const d=v(e,r);E.validateComparisonPresentationSpec(d,o).errors.forEach(s=>{n.push({severity:"error",code:"invalid_legacy_comparison_presentation",path:s.path||o,message:s.message})})}function T(e){const r=L(e.card),o=r.kpiComparison?v(r.kpiComparison,"kpi"):void 0,n=r.tableComparison?v(r.tableComparison,"table"):void 0;return{namespaces:r,kpi:o,table:n,presentation:o||n}}function M(e){const r=l(e.preferences)?e.preferences:{},o=l(r.kpiVisualOptions)?r.kpiVisualOptions:{},n=l(o.metricComparison)?o.metricComparison:{},p=l(r.tableVisualOptions)?r.tableVisualOptions:{},m=l(p.metricComparison)?p.metricComparison:{};return o.lowerIsBetter===!0||n.lowerIsBetter===!0||m.lowerIsBetter===!0?"lower_is_better":"higher_is_better"}function j(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 x(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 n=l(r.tableVisualOptions)?r.tableVisualOptions:void 0,p=n&&l(n.metricComparison)?n.metricComparison:void 0;p&&delete p.lowerIsBetter}function H(e){const r=O(e);if(!r.length)return{document:e,changed:!1,changes:[],diagnostics:[]};const o=[];if(r.forEach(t=>{var c,d,a,s;if(t.malformedMetricColumns&&o.push({severity:"error",code:"malformed_metric_columns",path:`${t.path}.config.metricColumns`,message:"Metric columns must be an array before comparison migration."}),t.malformedMetricIndexes.forEach(i=>{o.push({severity:"error",code:"malformed_metric_columns",path:`${t.path}.config.metricColumns[${i}]`,message:"Metric columns must contain objects before comparison migration."})}),t.metrics.forEach(({metric:i,index:u})=>{if(!("comparisonType"in i))return;const f=`${t.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;y.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."}),B.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."})}),t.hasLegacyPresentation){const{namespaces:i,kpi:u,table:f}=T(t),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:`${t.path}.preferences`,message:"Legacy comparison polarity values disagree; resolve the conflict before migration."}),((s=i.kpiOptions)==null?void 0:s.lowerIsBetter)!==void 0&&typeof i.kpiOptions.lowerIsBetter!="boolean"&&o.push({severity:"error",code:"invalid_legacy_comparison_presentation",path:`${t.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:`${t.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:`${t.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:`${t.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||{})&&C(t)&&o.push({severity:"error",code:"conflicting_comparison_presentation_contracts",path:`${t.path}.preferences.metricPairComparisonEnabled`,message:"Card contains both legacy and canonical metric-pair enablement; resolve the conflict before migration."}),i.kpiComparison&&S(i.kpiComparison,"kpi",`${t.path}.preferences.kpiVisualOptions.metricComparison`,o),i.tableComparison&&S(i.tableComparison,"table",`${t.path}.preferences.tableVisualOptions.metricComparison`,o),u&&f&&JSON.stringify($(u))!==JSON.stringify($(f))&&o.push({severity:"error",code:"conflicting_legacy_presentation_namespaces",path:`${t.path}.preferences`,message:"KPI and table comparison presentation values disagree; resolve the conflict before migration."})}}),o.some(t=>t.severity==="error"))return{document:e,changed:!1,changes:[],diagnostics:o};const n=JSON.parse(JSON.stringify(e)),p=O(n),m=[];return p.forEach(t=>{var d;const c=M(t.card);if(t.metrics.forEach(({metric:a,index:s})=>{if(!("comparisonType"in a))return;const i=String(a.comparisonType||""),u=`${t.path}.config.metricColumns[${s}]`,f=j(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,y.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:y.has(i)?c:void 0,removedFields:g})}),x(t.card),t.hasLegacyPresentation){const{namespaces:a,presentation:s}=T(t),i=(d=a.kpiComparison)==null?void 0:d.enabled,u={...s};typeof i=="boolean"&&w(t.metrics)&&(u.showComparison=i);const f=typeof i=="boolean"&&C(t)?i:void 0,g=typeof i=="boolean"&&!w(t.metrics)&&!C(t)?["kpiVisualOptions.metricComparison.enabled"]:void 0,h=a.preferences,b=[];t.metrics.forEach(({metric:_})=>{"comparisonPolarity"in _||(_.comparisonPolarity=c,typeof _.id=="string"&&b.push(_.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:`${t.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:n,changed:!0,changes:m,diagnostics:o}}const k=["bar","horizontalBar","line","area","stackedArea","combo","stackedBar","stackedLine"],Y=new Set(k);function V(e){return typeof e=="string"&&Y.has(e)}function G(e){return e==="table"||e==="aggregateTable"||e==="pivotTable"||e==="custom"||V(e)}function P(e){return!!(e!=null&&e.trim())}function F(e){return P(e.sql)||P(e.normalizedPython)?"freeform":e.hasExecutableConfig?"config":"none"}exports.DASHBOARD_AUTHORING_BREAKPOINTS=N;exports.DASHBOARD_AUTHORING_MAX_GENERATED_CARDS=R;exports.SEMAPHOR_CARTESIAN_CHART_TYPES=k;exports.isSemaphorCartesianChartType=V;exports.resolveTemporalResultOwner=F;exports.supportsCanonicalDashboardTemporalResult=G;exports.transformComparisonDocument=H;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";require("../value-format-preferences/index.cjs");require("./validators-9D4KBqKD.cjs");const A={mode:"all"};exports.DEFAULT_SEMANTIC_DOMAIN_ACCESS=A;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";const K=require("./
|
|
1
|
+
"use strict";const K=require("./validators-9D4KBqKD.cjs"),S=require("../data-app-sdk-adapters/index.cjs"),re=K.SEMAPHOR_DATA_APP_CODEGEN_SUMMARY_SCHEMA_VERSION,T=K.SEMAPHOR_DATA_APP_CODEGEN_SUMMARY_VALIDATOR_VERSION,k="semaphor-generated-data-app-contract/v1",G="semaphor-generated-data-app-contract-manifest/v1";function x(e){return E(e)?[...K.validateSemaphorDataAppCodegenSummary(e).issues,...ae(e)]:["Plan artifact must be a Semaphor codegenSummary object."]}function ne(e){const t=x(e);if(t.length>0)throw new Error(`Invalid Semaphor codegenSummary:
|
|
2
2
|
- ${t.join(`
|
|
3
3
|
- `)}`)}function ae(e){var r;const t=E(e);if(!t)return[];const n=[];return((r=E(t.validation))==null?void 0:r.status)==="blocked"&&n.push("validation.status blocked cannot be generated. Resolve blocked semantic model gaps and replan before generating contract files."),Array.isArray(t.unsupportedInsights)&&t.unsupportedInsights.forEach((i,o)=>{var a;((a=E(i))==null?void 0:a.reason)==="missing_relationship"&&n.push(`unsupportedInsights.${o}.reason missing_relationship blocks contract generation. Call semaphor_propose_semantic_model_change, apply an approved semantic model patch, and replan before generating contract files.`)}),Array.isArray(t.views)&&t.views.forEach((i,o)=>{var s;const a=E((s=E(i))==null?void 0:s.computation);(a==null?void 0:a.kind)==="unsupported"&&a.reason==="missing_relationship"&&n.push(`views.${o}.computation.reason missing_relationship blocks contract generation. Call semaphor_propose_semantic_model_change, apply an approved semantic model patch, and replan before generating contract files.`)}),n}function E(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}const J=["sources.ts","fields.ts","inputs.ts","queries.ts","bindings.ts","accessors.ts","metadata.ts","index.ts"],ie=["USAGE.md"],Y=[...J,...ie,"contract.manifest.json"];async function se({manifest:e,generatedFiles:t}){const n=[],r=y(e);if(!r)return{issues:[{message:"Generated contract manifest must be an object.",repairHint:"Regenerate the generated contract instead of hand-editing the manifest."}]};r.schemaVersion!==G&&n.push({path:"schemaVersion",message:`schemaVersion must be ${G}. Regenerate the contract with semaphor_create_data_app_contract.`,repairHint:"Regenerate the contract with semaphor_create_data_app_contract."}),r.generatedContractSchemaVersion!==k&&n.push({path:"generatedContractSchemaVersion",message:`generatedContractSchemaVersion must be ${k}. Regenerate the contract with semaphor_generate_data_app_contract.`,repairHint:"Regenerate the contract with semaphor_generate_data_app_contract."});const i=y(r.generator);A(i==null?void 0:i.name)||n.push({path:"generator.name",message:"generator.name is required.",repairHint:"Regenerate the generated contract so manifest generator metadata is written deterministically."}),A(i==null?void 0:i.version)||n.push({path:"generator.version",message:"generator.version is required.",repairHint:"Regenerate the generated contract so manifest generator metadata is written deterministically."});for(const a of x(r.codegenSummary))n.push({path:`codegenSummary.${a}`,message:`codegenSummary.${a}`,repairHint:"Regenerate the generated contract from a valid Data App codegenSummary."});if(r.codegenSummaryValidatorVersion!==T&&n.push({path:"codegenSummaryValidatorVersion",message:`codegenSummaryValidatorVersion must be ${T}. Regenerate the contract with semaphor_generate_data_app_contract.`,repairHint:"Regenerate the contract with semaphor_generate_data_app_contract."}),typeof r.codegenSummaryHash!="string")n.push({path:"codegenSummaryHash",message:"codegenSummaryHash is required.",repairHint:"Regenerate the generated contract so manifest hashes are written deterministically."});else if(y(r.codegenSummary)){const a=await fe(r.codegenSummary);r.codegenSummaryHash!==a&&n.push({path:"codegenSummaryHash",message:"codegenSummaryHash does not match codegenSummary. Regenerate the contract instead of editing the manifest.",repairHint:"Regenerate the generated contract instead of editing the manifest."})}n.push(...de(r.codegenSummary));const o=t?oe(t):[];if(n.push(...o),t&&o.length===0&&n.push(...ce(t)),typeof r.generatedContentHash!="string")n.push({path:"generatedContentHash",message:"generatedContentHash is required.",repairHint:"Regenerate the generated contract so manifest hashes are written deterministically."});else if(t&&o.length===0){const a=await ue(t);r.generatedContentHash!==a&&n.push({path:"generatedContentHash",message:"generatedContentHash does not match generated TypeScript files. Regenerate the contract instead of hand-editing generated files.",repairHint:"Regenerate the contract instead of hand-editing generated files."})}return{issues:n}}function oe(e){var r;const t=[],n=new Set(Y);for(const i of Object.keys(e)){if(i.includes("/")||i.includes("\\")){const o=((r=i.split("/").pop())==null?void 0:r.split("\\").pop())||i;t.push({path:`generatedFiles.${i}`,message:`generatedFiles keys must be generated filenames such as "${o}", not path-qualified keys such as "${i}".`,repairHint:'Pass generatedFiles keyed by filename, for example "queries.ts", not "src/semaphor/generated/queries.ts".'});continue}n.has(i)||t.push({path:`generatedFiles.${i}`,message:`generatedFiles contains unknown generated contract file "${i}".`,repairHint:"Pass only the generated files returned by semaphor_generate_data_app_contract, keyed by filename."})}return t}function ce(e){const t=e["USAGE.md"];return typeof t!="string"?[{path:"generatedFiles.USAGE.md",message:"generatedFiles.USAGE.md is required.",repairHint:"Regenerate the generated contract so the generated usage guide is written."}]:["queries","queryOptionsForView","rowsForView","metricValuesForView","kpiPropsForView","roleValuesForView","appInputSpecs","inputOptionQueries"].filter(r=>!t.includes(`\`${r}\``)).map(r=>({path:"generatedFiles.USAGE.md",message:`generatedFiles.USAGE.md must document ${r}.`,repairHint:"Regenerate the generated contract so the usage guide matches generated exports."}))}function de(e){const t=y(e);if(!t)return[];const n=[],r=new Set(b(t.inputs).map(o=>{var a;return(a=y(o))==null?void 0:a.id}).filter(A)),i=new Set(b(t.views).map(o=>{var a;return(a=y(o))==null?void 0:a.id}).filter(A));return b(t.filterContracts).forEach((o,a)=>{const s=y(o),c=s==null?void 0:s.inputId;(!A(c)||!r.has(c))&&n.push({path:`codegenSummary.filterContracts.${a}.inputId`,message:`codegenSummary.filterContracts.${a}.inputId must reference a generated input.`,repairHint:"Regenerate the generated contract from a valid planner output."}),Array.isArray(s==null?void 0:s.bindings)&&s.bindings.forEach((u,f)=>{const p=y(u),m=p==null?void 0:p.viewId;(!A(m)||!i.has(m))&&n.push({path:`codegenSummary.filterContracts.${a}.bindings.${f}.viewId`,message:`codegenSummary.filterContracts.${a}.bindings.${f}.viewId must reference a generated view.`,repairHint:"Regenerate the generated contract from a valid planner output."});const h=y(p==null?void 0:p.fieldRef);A(h==null?void 0:h.name)||n.push({path:`codegenSummary.filterContracts.${a}.bindings.${f}.fieldRef`,message:`codegenSummary.filterContracts.${a}.bindings.${f}.fieldRef is required.`,repairHint:"Regenerate the generated contract from a valid planner output."})})}),n}async function ue(e){const t=Object.keys(e).filter(r=>r.endsWith(".ts")).sort();let n="";for(const r of t)n+=`${r}\0${e[r]}\0`;return`sha256:${await Q(n)}`}async function fe(e){return`sha256:${await Q(M(e))}`}function M(e){if(e===null||typeof e!="object")return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(r=>M(r)).join(",")}]`;const t=e;return`{${Object.keys(t).sort().filter(r=>t[r]!==void 0).map(r=>`${JSON.stringify(r)}:${M(t[r])}`).join(",")}}`}async function Q(e){var r;if(!((r=globalThis.crypto)!=null&&r.subtle))throw new Error("SHA-256 digest support is required for generated contract validation.");const t=new TextEncoder().encode(e),n=await globalThis.crypto.subtle.digest("SHA-256",t);return Array.from(new Uint8Array(n)).map(i=>i.toString(16).padStart(2,"0")).join("")}function y(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function b(e){return Array.isArray(e)?e:[]}function A(e){return typeof e=="string"&&e.length>0}function pe(e){const t=d(e),n=V(t),r=[],i=[];return I(t==null?void 0:t.views).filter(o=>{var s;const a=d((s=d(o))==null?void 0:s.sdkSpec);return!!(a!=null&&a.builder&&(a!=null&&a.spec))}).forEach((o,a)=>{var u;const s=String(((u=d(o))==null?void 0:u.id)||`view_${a}`),c=W(o,n);if(c){r.push({viewId:s,...c});return}i.push({viewId:s,path:`views.${s}.sdkSpec`,message:`Generated view execution validation could not build intent for "${s}".`})}),{requests:r,issues:i}}function W(e,t){const n=d(e),r=d(n==null?void 0:n.sdkSpec),i=d(r==null?void 0:r.spec);if(!n||!(r!=null&&r.builder)||!i)return null;const o=me(t)?t:V(d(t)),a=be(r.builder),s=d(w(i,o))||{},c=ye({view:n,builder:a,rawSpec:i,spec:{...s,id:n.id,label:Ne(n,i)},context:o});try{if(a==="analysis"){const u=c;return{intent:S.toSemaphorAnalysisIntent(u),resultShape:"analysis",analysisOptions:S.toSemaphorAnalysisQueryOptions(u)}}if(a==="metric")return{intent:S.toSemaphorMetricIntent(c),resultShape:"metric"};if(a==="records")return{intent:S.toSemaphorRecordsIntent(c),resultShape:"records"};if(a==="matrix")return{intent:S.toSemaphorMatrixIntent(c),resultShape:"matrix"};if(a==="sql")return{intent:S.toSemaphorSqlIntent(c),resultShape:"sql"}}catch{return null}return null}function ge({input:e,filterContract:t,codegenSummary:n}){const r=d(e),i=d(t),o=d(r==null?void 0:r.optionQuery)||d(i==null?void 0:i.optionQuery);if(!r||!o)return null;const a=V(d(n)),s=d(o.spec),c=he(o,s,a),u=o.valueFieldRef||o.valueField||(s==null?void 0:s.valueField),f=o.labelFieldRef||o.labelField||(s==null?void 0:s.labelField);if(!c||!u||!f)return null;const m={...d(w(s||{},a))||{},id:o.id||(s==null?void 0:s.id)||`${r.id}-options`,inputId:r.id,source:c,valueField:u,labelField:f,population:o.population||(s==null?void 0:s.population),dependencies:o.dependencies||(s==null?void 0:s.dependencies),limit:o.limit||(s==null?void 0:s.limit)||100};try{return S.toSemaphorInputOptionsIntent(w(m,a))}catch{return null}}function le({input:e,filterContract:t,binding:n,option:r,codegenSummary:i}){const o=V(d(i)),a=d(e),s=d(t),c=d(n),u=w((c==null?void 0:c.fieldRef)||(s==null?void 0:s.fieldRef)||(a==null?void 0:a.fieldRef),o),f=String((s==null?void 0:s.operator)||(a==null?void 0:a.operator)||"in"),p=Fe(c);return{inputId:String((s==null?void 0:s.inputId)||(a==null?void 0:a.id)||""),kind:"filter",operator:f,value:He(f,r.value),isActive:!0,...u?{field:u}:{},...p?{relationshipHint:p}:{}}}function V(e){return{sourcesByKey:new Map(I(e==null?void 0:e.sources).map(d).filter(Me).filter(t=>typeof t.sourceKey=="string").map(t=>[String(t.sourceKey),Z(t)]))}}function me(e){var t;return e instanceof Object&&((t=d(e))==null?void 0:t.sourcesByKey)instanceof Map}function he(e,t,n){if(typeof e.sourceKey=="string")return n.sourcesByKey.get(e.sourceKey)||{sourceKey:e.sourceKey};if(e.source)return e.source;if(t!=null&&t.source)return t.source;if(typeof(t==null?void 0:t.sourceKey)=="string")return n.sourcesByKey.get(t.sourceKey)||{sourceKey:t.sourceKey}}function ye({view:e,builder:t,rawSpec:n,spec:r,context:i}){var s;if(t!=="records"&&t!=="sql")return r;const o=d((s=d(e.visualSpec))==null?void 0:s.tableBehavior);if(!o)return r;const a={...r};if(Oe(o)==="server"&&(a.pagination={page:1,pageSize:Se({tableBehavior:o,spec:r})}),t==="records"&&Ve(o)==="server"){const c=Ae({view:e,rawSpec:n,tableBehavior:o,context:i});c&&(a.orderBy=c)}return a}function Se({tableBehavior:e,spec:t}){const n=d(e.pagination),r=d(t.pagination);return F(n==null?void 0:n.pageSize)||F(r==null?void 0:r.pageSize)||F(t.limit)||100}function Ae({view:e,rawSpec:t,tableBehavior:n,context:r}){const i=d(n.sorting),o=g(i==null?void 0:i.defaultField);if(!o)return;const s=_e({view:e,rawSpec:t,context:r}).filter(c=>we(c.lookup).includes(o));if(s.length===1)return{field:s[0].field,direction:(i==null?void 0:i.defaultDirection)==="desc"?"desc":"asc"}}function _e({view:e,rawSpec:t,context:n}){var i;const r=[];for(const o of I(t.fields))$(r,o,n);$(r,t.dateField,n),$(r,(i=d(t.orderBy))==null?void 0:i.field,n);for(const o of I(e.fields))$(r,o,n);return Te(r,o=>Ee(o.lookup))}function $(e,t,n){const r=d(t);if(typeof(r==null?void 0:r.name)!="string"||r.name.length===0)return;const i=d(w(r,n))||r;e.push({lookup:r,field:i})}function we(e){return ke([g(e.name),X(e),Ie(e)])}function Ee(e){return[X(e),g(e.name),g(e.role),g(e.aggregate)].join("|")}function X(e){return[g(e.sourceKey)||Re(e.source),g(e.name),g(e.aggregate)].filter(Boolean).join(":")}function Re(e){const t=d(e);if(!t)return"";if(typeof t.kind=="string"&&typeof t.domainId=="string"){if(typeof t.datasetId=="string")return`${t.kind}:${t.domainId}:datasetId:${t.datasetId}`;if(typeof t.datasetName=="string")return`${t.kind}:${t.domainId}:datasetName:${t.datasetName}`}return JSON.stringify(t)}function Ie(e){return Ge([ve(e),g(e.aggregate).toLowerCase(),g(e.label)||g(e.name)].filter(Boolean))}function ve(e){return typeof e.sourceKey=="string"?Ce(e.sourceKey):$e(e.source)}function $e(e){const t=d(e);return t?g(t.datasetName)||g(t.datasetId)||g(t.name)||g(t.kind):""}function Ce(e){const t=String(e).split(":");return t[t.length-1]||String(e)}function Oe(e){var t;return g((t=d(e.pagination))==null?void 0:t.mode)}function Ve(e){var t;return g((t=d(e.sorting))==null?void 0:t.mode)}function w(e,t){if(!e||typeof e!="object")return e;if(Array.isArray(e))return e.map(i=>w(i,t));const n=e;if(typeof n.sourceKey=="string"&&typeof n.kind=="string"&&(typeof n.datasetName=="string"||typeof n.datasetId=="string"))return Z(n);const r={};for(const[i,o]of Object.entries(n))i!=="sourceKey"&&(r[i]=w(o,t));if(typeof n.sourceKey=="string"){const i=t.sourcesByKey.get(n.sourceKey);i&&!r.source&&(r.source=i)}return r}function Z(e){const{sourceKey:t,...n}=e;return n}function Ne(e,t){const n=d(e.visualSpec);return(n==null?void 0:n.title)||e.title||t.label}function be(e){const t=String(e||"").replace(/^semaphor\./,"");return["metric","records","analysis","matrix","sql"].includes(t)?t:""}function Fe(e){if(e!=null&&e.relationshipHint)return e.relationshipHint;const t=I(e==null?void 0:e.relationshipsUsed).map(n=>{var r;return(r=d(n))==null?void 0:r.id}).filter(n=>typeof n=="string"&&n.length>0);return t.length>0?{relationshipIds:t}:void 0}function He(e,t){return e==="in"||e==="not_in"?[t]:e==="between"?Array.isArray(t)?t:[t,t]:t}function F(e){return typeof e=="number"&&Number.isFinite(e)?e:void 0}function g(e){return typeof e=="string"?e:""}function Te(e,t){const n=new Set,r=[];for(const i of e){const o=t(i);!o||n.has(o)||(n.add(o),r.push(i))}return r}function ke(e){return Array.from(new Set(e.filter(Boolean)))}function Ge(e){return(Array.isArray(e)?e.join(" "):e).replace(/[^a-zA-Z0-9]+/g," ").trim().split(/\s+/).filter(Boolean).map((n,r)=>{const i=n.toLowerCase();return r===0?i:i.charAt(0).toUpperCase()+i.slice(1)}).join("")}function d(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function I(e){return Array.isArray(e)?e:[]}function Me(e){return e!==void 0}const De=new Set(["diagnostic_fix","fix_diagnostics","fix_inspector_warnings","fix_runtime_warnings","fix_warnings"]),Ke=new Set(["add","edit","mixed","remove"]),j=new Set(["fields","metricBindingKeys","sdkSpec"]);function xe({beforeSummary:e,afterSummary:t,migrationReport:n,operationIntent:r,constraints:i,preferences:o}){const a=l(r),s=typeof(a==null?void 0:a.kind)=="string"?a.kind.trim():"";return Ke.has(s)?{ok:!1,policy:{kind:s,mode:"invalid_operation_kind",reason:"Retired Data App operation aliases are not accepted. Use the hard-migrated analytics/layout/style operationIntent kinds."},violations:[{path:"operationIntent.kind",reason:"Use analytics_add, analytics_edit, analytics_remove, input_add, input_edit, layout_only, style_only, runtime_debug, semantic_model_repair, save_or_publish, or greenfield_create."}]}:B(o)?{ok:!1,policy:{kind:s,mode:"invalid_update_constraints",reason:"Metric aggregate override updates must use operationIntent.measureAggregateOverrides so deterministic update policy can guard the targeted edit."},violations:[{path:"preferences.measureAggregateOverrides",reason:"preferences is retired. Move measureAggregateOverrides to operationIntent.measureAggregateOverrides for update calls."}]}:B(i)?{ok:!1,policy:{kind:s,mode:"invalid_update_constraints",reason:"Metric aggregate override updates must use operationIntent.measureAggregateOverrides so deterministic update policy can guard the targeted edit."},violations:[{path:"constraints.measureAggregateOverrides",reason:"Move measureAggregateOverrides to operationIntent.measureAggregateOverrides for update calls."}]}:De.has(s)?U({beforeSummary:e,afterSummary:t,migrationReport:n,operationIntent:a,mode:"diagnostic_warning_fix",allowedViewChangeReasons:j,label:"Diagnostic warning fixes",reason:"Diagnostic warning fixes are preserve-by-default and may not add/remove views, inputs, or filter contracts."}):s==="analytics_edit"&&Array.isArray(a==null?void 0:a.measureAggregateOverrides)&&a.measureAggregateOverrides.length>0?U({beforeSummary:e,afterSummary:t,migrationReport:n,operationIntent:a,mode:"metric_aggregate_override_edit",allowedViewChangeReasons:j,label:"Metric aggregate override edits",reason:"Metric aggregate override edits are preserve-by-default and may only adjust fields/sdkSpec on targeted views."}):{ok:!0,policy:{kind:s,mode:"general_iterative_update",reason:"General generated-contract edits are allowed to change the requested contract shape. Review the migration report for expected UI work."},violations:[]}}function B(e){var t;return Array.isArray((t=l(e))==null?void 0:t.measureAggregateOverrides)}function U({beforeSummary:e,afterSummary:t,migrationReport:n,operationIntent:r,mode:i,allowedViewChangeReasons:o,label:a,reason:s}){const c=[],u=je(r==null?void 0:r.targetViewIds),f=l(n)||{};u.size===0&&c.push({path:"operationIntent.targetViewIds",reason:`${a} must declare targetViewIds so the update cannot broaden to unrelated views.`}),H({bucket:l(f.views),label:"views",operationLabel:a,violations:c}),H({bucket:l(f.inputs),label:"inputs",operationLabel:a,violations:c}),L({bucket:l(f.inputs),label:"inputs",operationLabel:a,violations:c}),H({bucket:l(f.filterContracts),label:"filterContracts",operationLabel:a,violations:c}),L({bucket:l(f.filterContracts),label:"filterContracts",operationLabel:a,violations:c});for(const m of ee(l(f.views))){u.size>0&&!u.has(_(m.id))&&c.push({path:`views.${_(m.id)||"<unknown>"}`,reason:`${a} may only change explicitly targeted views.`});const h=Array.isArray(m.reasons)?m.reasons.filter(R=>typeof R!="string"||!o.has(R)):[];h.length>0&&c.push({path:`views.${_(m.id)||"<unknown>"}`,reason:`${a} may only adjust fields/sdkSpec/metricBindingKeys; changed ${h.join(", ")}.`})}const p=qe({beforeSummary:e,afterSummary:t,targetViewIds:u,label:a});return p&&c.push(p),{ok:c.length===0,policy:{kind:_(r==null?void 0:r.kind)||"diagnostic_fix",mode:i,allowedViewChangeReasons:Array.from(o).sort(),targetViewIds:Array.from(u).sort(),reason:s},violations:c}}function qe({beforeSummary:e,afterSummary:t,targetViewIds:n,label:r}){const i=l(e),o=l(t);if(!i||!o)return{path:"codegenSummary",reason:`${r} require before/after codegen summaries for full-scope verification.`};const a=P(i),s=P(o),c=z(i.views),u=z(o.views),f=Array.isArray(a.views)?a.views:[];a.views=f;for(const p of n){const m=c.get(p),h=u.get(p);if(!m||!h)continue;const R=f.find(te=>{var q;return((q=l(te))==null?void 0:q.id)===p}),v=l(h);if(!R||!v)continue;const N=R;N.fields=C(v.fields),N.metricBindingKeys=C(v.metricBindingKeys),N.sdkSpec=C(v.sdkSpec)}return O(a)===O(s)?null:{path:"codegenSummary",reason:`${r} may only change fields/sdkSpec/metricBindingKeys on targetViewIds; another generated contract section changed.`}}function P(e){const t=C(e);for(const n of["implementationChecklist","assumptions","nextStep","nextRequiredTool","validation"])delete t[n];return Ue(t.unsupportedInsights)&&delete t.unsupportedInsights,t}function H({bucket:e,label:t,operationLabel:n,violations:r}){for(const i of D(e==null?void 0:e.added))r.push({path:`${t}.${_(i.id)||"<unknown>"}`,reason:`${n} may not add ${t}.`});for(const i of D(e==null?void 0:e.removed))r.push({path:`${t}.${_(i.id)||"<unknown>"}`,reason:`${n} may not remove ${t}.`})}function L({bucket:e,label:t,operationLabel:n,violations:r}){for(const i of ee(e))r.push({path:`${t}.${_(i.id)||"<unknown>"}`,reason:`${n} may not change ${t}.`})}function ee(e){return D(e==null?void 0:e.changed)}function D(e){return Array.isArray(e)?e.map(l).filter(Be):[]}function je(e){return Array.isArray(e)?new Set(e.filter(t=>typeof t=="string"&&t.trim().length>0).map(t=>t.trim())):new Set}function z(e){var n;const t=new Map;for(const r of Array.isArray(e)?e:[]){const i=(n=l(r))==null?void 0:n.id;typeof i=="string"&&i.trim()&&t.set(i,r)}return t}function C(e){return e===void 0?e:JSON.parse(JSON.stringify(e))}function O(e){if(e===null||typeof e!="object")return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(n=>O(n)).join(",")}]`;const t=e;return`{${Object.keys(t).sort().filter(n=>t[n]!==void 0).map(n=>`${JSON.stringify(n)}:${O(t[n])}`).join(",")}}`}function l(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function Be(e){return e!==void 0}function Ue(e){return Array.isArray(e)&&e.length===0}function _(e){return typeof e=="string"?e:""}exports.CODEGEN_SUMMARY_SCHEMA_VERSION=re;exports.CODEGEN_SUMMARY_VALIDATOR_VERSION=T;exports.CONTRACT_MANIFEST_SCHEMA_VERSION=G;exports.GENERATED_CONTRACT_SCHEMA_VERSION=k;exports.GENERATED_CONTRACT_TYPESCRIPT_FILES=J;exports.REQUIRED_GENERATED_CONTRACT_FILES=Y;exports.assertValidCodegenSummary=ne;exports.buildSemaphorGeneratedActiveInput=le;exports.buildSemaphorGeneratedInputOptionIntent=ge;exports.buildSemaphorGeneratedViewExecutionRequest=W;exports.buildSemaphorGeneratedViewExecutionRequests=pe;exports.evaluateSemaphorDataAppContractUpdatePolicy=xe;exports.validateCodegenSummary=x;exports.validateSemaphorGeneratedContract=se;
|