react-semaphor 0.1.536 → 0.1.538
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.js +352 -341
- package/dist/assistant-context/index.js +10 -0
- package/dist/assistant-protocol/index.js +104 -0
- package/dist/brand-studio/index.js +35 -31
- package/dist/briefings/index.js +46 -45
- package/dist/chunks/_commonjsHelpers-BkfeUUK-.js +28 -0
- package/dist/chunks/add-to-dashboard-CxtTfISD.js +56 -0
- package/dist/chunks/aggregate-table-row-presentation-Qgpv6_G8.js +979 -0
- package/dist/chunks/analytics-base-schemas-BFAoRlkU.js +472 -0
- package/dist/chunks/apply-dashboard-operations-C-iahGka.js +402 -0
- package/dist/chunks/assistant-chat-BAqUIFp5.js +7966 -0
- package/dist/chunks/availability-Bp5Gfu1I.js +44 -0
- package/dist/chunks/{bookmark-state-B-I9BDD0.js → bookmark-state-k7y5SNGf.js} +9 -9
- package/dist/chunks/{braces-8TRlDwDw.js → braces-o9UiRQes.js} +1 -1
- package/dist/chunks/calculated-field-identity-DcBS2NPP.js +2161 -0
- package/dist/chunks/calendar-day-equality-Bpl15IBo.js +487 -0
- package/dist/chunks/class-utils-Df1OVOT1.js +2315 -0
- package/dist/chunks/{field-dependencies-CpRUwr9J.js → common-types-CUf03Htv.js} +65 -58
- package/dist/chunks/context-HD9usB1P.js +349 -0
- package/dist/chunks/conversation-sQiWYUOb.js +16 -0
- package/dist/chunks/csv-utils-GUfKyT1J.js +56 -0
- package/dist/chunks/custom-visual-inputs-BrUOIwln.js +3288 -0
- package/dist/chunks/{dashboard-BTDY_I5L.js → dashboard-DTDDFQsS.js} +1 -1
- package/dist/chunks/{dashboard-briefing-launcher-DV_rlhT2.js → dashboard-briefing-launcher-Bb2QUqOa.js} +764 -740
- package/dist/chunks/{dashboard-controls-B4LxN5dr.js → dashboard-controls-FpONU8QV.js} +683 -686
- package/dist/chunks/{common-types-g7yS12Cg.js → dashboard-filter-value-compatibility-D95O4nd7.js} +18 -24
- package/dist/chunks/dashboard-json-DazPhBU_.js +69 -0
- package/dist/chunks/document-dashboard-inputs-D96rlU7S.js +10678 -0
- package/dist/chunks/document-sheet-utils-C1eEldxs.js +1076 -0
- package/dist/chunks/{edit-dashboard-visual-L5zsle6X.js → edit-dashboard-visual-CIhZodVH.js} +4744 -4746
- package/dist/chunks/editor-draft-sync-BN5qYHPF.js +15 -0
- package/dist/chunks/filter-value-text-BhWugPWE.js +163 -0
- package/dist/chunks/index-CqMiAkay.js +3164 -0
- package/dist/chunks/index-CuHybtft.js +51 -0
- package/dist/chunks/layout-grid-Bgzth8vd.js +16 -0
- package/dist/chunks/{matrix-analytical-definition-CgBTD6H8.js → matrix-analytical-definition-bcprSe4u.js} +1 -1
- package/dist/chunks/{matrix-card-CAdizkUl.js → matrix-card-CJn1hB5V.js} +13 -12
- package/dist/chunks/matrix-definition-DQDI2okF.js +206 -0
- package/dist/chunks/{matrix-formatter-DJCk8Znf.js → matrix-formatter-Bgw32tb3.js} +648 -457
- package/dist/chunks/matrix-member-presentation-BNPSDKBG.js +105 -0
- package/dist/chunks/{matrix-operation-contract-BKupLHXL.js → matrix-operation-contract-B8PBF1Gd.js} +134 -133
- package/dist/chunks/{metric-comparison-BKHyvnAy.js → metric-comparison-CojWeLqx.js} +1 -1
- package/dist/chunks/{palette-Cp1hqZtm.js → palette-D10o_yYX.js} +1 -1
- package/dist/chunks/pivot-header-presentation-MkcKnjn3.js +42 -0
- package/dist/chunks/{pivot-result-identity-Bs4tLtLo.js → pivot-result-identity-D6hhcRXi.js} +1 -1
- package/dist/chunks/pivot-result-lifecycle-8qCDmpKc.js +804 -0
- package/dist/chunks/raw-temporal-D61lr48Y.js +1464 -0
- package/dist/chunks/{raw-temporal-contract-mLFS-9wk.js → raw-temporal-contract-C51YG48G.js} +1 -1
- package/dist/chunks/report-preferences-dialog-BCGs4-AE.js +1808 -0
- package/dist/chunks/{report-runtime-context-CG_I0PPW.js → report-runtime-context-B984Nq1E.js} +8 -7
- package/dist/chunks/save-CfJpQQ68.js +21 -0
- package/dist/chunks/saved-dashboard-context-BrTkjcod.js +566 -0
- package/dist/chunks/{selection-reducer-CiDEtmAq.js → selection-reducer-vKIb_jS6.js} +2 -2
- package/dist/chunks/{semaphor-ready-indicator-3TXTZgw-.js → semaphor-ready-indicator-CHHoWhil.js} +65657 -62814
- package/dist/chunks/{shelf-drop-preview-context-CBCs9rjz.js → shelf-drop-preview-context-EsayECEC.js} +199 -196
- package/dist/chunks/{source-entity-resolution-C-oNyYMp.js → source-entity-resolution-CVA1a85c.js} +8 -8
- package/dist/chunks/switch-CvItuC1Q.js +8199 -0
- package/dist/chunks/{temporal-bucket-DlFuhCnT.js → temporal-bucket-D8JF7zKz.js} +86 -71
- package/dist/chunks/{temporal-bucket-contract-D2OuaVZ7.js → temporal-bucket-contract-DaOajRC7.js} +1 -1
- package/dist/chunks/{token-types-DtSJOUjh.js → token-types-bxUxXDX2.js} +1 -1
- package/dist/chunks/{upload-CAIpsti1.js → upload-BFX7apKV.js} +1 -1
- package/dist/chunks/{use-create-flow-overlay-state-Bk-SBnaY.js → use-create-flow-overlay-state-BqA92GkX.js} +331 -339
- package/dist/chunks/{validators-DMSH81OM.js → validators-Ej1DdCXa.js} +1050 -1510
- package/dist/chunks/visual-choice-JiJ-_3bi.js +204 -0
- package/dist/chunks/x-4f5U2XwU.js +100 -0
- package/dist/chunks/{zoned-wall-clock-1qlWCE20.js → zoned-wall-clock-MulfA26h.js} +2 -2
- package/dist/dashboard/index.js +2 -2
- package/dist/dashboard-authoring/index.js +823 -661
- package/dist/data-app-sdk/index.js +32 -30
- package/dist/data-app-sdk-adapters/index.js +23 -22
- package/dist/data-app-sdk-validation/index.js +23 -22
- package/dist/format-utils/index.js +173 -168
- package/dist/index.js +267 -258
- package/dist/layouts/index.js +236 -24
- package/dist/report-runtime-context/index.js +2 -2
- package/dist/style.css +1 -1
- package/dist/surfboard/index.js +2 -2
- package/dist/types/assistant-context.d.ts +2 -0
- package/dist/types/assistant-protocol.d.ts +2 -0
- package/dist/types/components/assistant/assistant-entry-points.d.ts +18 -0
- package/dist/types/components/assistant/assistant-provider.d.ts +19 -0
- package/dist/types/components/assistant/assistant-store.d.ts +52 -0
- package/dist/types/components/assistant/use-assistant.d.ts +38 -0
- package/dist/types/components/index.d.ts +5 -1
- package/dist/types/components/surfboard/filter/types.d.ts +5 -2
- package/dist/types/index.js +50 -51
- package/dist/types/lib/api/invalidate-token.d.ts +7 -0
- package/dist/types/lib/charts/cartesian-fields.d.ts +64 -0
- package/dist/types/lib/charts/types.d.ts +7 -0
- package/dist/types/lib/dashboard-inputs/dashboard-filter-mapping-storage-transition.d.ts +14 -2
- package/dist/types/lib/dashboard-inputs/dashboard-input-target-context.d.ts +5 -6
- package/dist/types/lib/dashboard-inputs/dashboard-input-values.d.ts +8 -3
- package/dist/types/lib/dashboard-inputs/resolve-dashboard-input-context.d.ts +11 -6
- package/dist/types/lib/dashboard-pagination/dashboard-card-pagination.d.ts +7 -0
- package/dist/types/lib/dashboard-viewer/compatibility-input-storage.d.ts +79 -0
- package/dist/types/lib/dashboard-viewer/viewer-state.d.ts +3 -2
- package/dist/types/lib/document/document-table-data-policy.d.ts +15 -0
- package/dist/types/lib/filter-values/filter-mode.d.ts +22 -0
- package/dist/types/lib/hooks/use-calendar-context.d.ts +5 -0
- package/dist/types/lib/hooks/use-text-filter.d.ts +7 -0
- package/dist/types/lib/print/print-inputs.d.ts +4 -2
- package/dist/types/lib/query-context/build-card-query-context.d.ts +12 -4
- package/dist/types/lib/query-context/build-dashboard-execution-snapshot.d.ts +93 -0
- package/dist/types/lib/query-context/card-server-request.d.ts +72 -0
- package/dist/types/lib/query-context/compile-dashboard-card-filters.d.ts +7 -0
- package/dist/types/lib/query-context/describe-card-execution-snapshot.d.ts +56 -0
- package/dist/types/lib/query-context/document-section-card-query.d.ts +45 -0
- package/dist/types/lib/query-context/resolve-runtime-card-filters.d.ts +17 -2
- package/dist/types/lib/stores/dashboard-store.d.ts +34 -11
- package/dist/types/lib/stores/editor-store.d.ts +4 -2
- package/dist/types/lib/types/token-types.d.ts +11 -0
- package/dist/types/lib/utils/card-type-change.d.ts +30 -0
- package/dist/types/lib/utils/comparison-window-caption.d.ts +12 -0
- package/dist/types/lib/utils/filter-default-value-utils.d.ts +13 -2
- package/dist/types/shared/analytics-protocol/applied-constraints.d.ts +74 -0
- package/dist/types/shared/analytics-protocol/contracts.d.ts +5 -0
- package/dist/types/shared/analytics-protocol/filter-field-ownership.d.ts +43 -0
- package/dist/types/shared/analytics-protocol/index.d.ts +3 -0
- package/dist/types/shared/analytics-protocol/matrix-window-contract.d.ts +1 -1
- package/dist/types/shared/analytics-protocol/visual-choice.d.ts +75 -0
- package/dist/types/shared/assistant-context/index.d.ts +9 -0
- package/dist/types/shared/assistant-context/project-context.d.ts +55 -0
- package/dist/types/shared/assistant-context/saved-dashboard-context.d.ts +130 -0
- package/dist/types/shared/assistant-protocol/add-to-dashboard.d.ts +17 -0
- package/dist/types/shared/assistant-protocol/artifact.d.ts +63 -0
- package/dist/types/shared/assistant-protocol/availability.d.ts +39 -0
- package/dist/types/shared/assistant-protocol/context.d.ts +952 -0
- package/dist/types/shared/assistant-protocol/conversation.d.ts +38 -0
- package/dist/types/shared/assistant-protocol/index.d.ts +16 -0
- package/dist/types/shared/assistant-protocol/limits.d.ts +53 -0
- package/dist/types/shared/assistant-protocol/parts.d.ts +131 -0
- package/dist/types/shared/assistant-protocol/request.d.ts +77 -0
- package/dist/types/shared/assistant-protocol/sources.d.ts +27 -0
- package/dist/types/shared/assistant-protocol/token-config.d.ts +32 -0
- package/dist/types/shared/assistant-protocol/transcript.d.ts +40 -0
- package/dist/types/shared/dashboard-authoring/card-query-request.d.ts +112 -0
- package/dist/types/shared/dashboard-authoring/control-execution-contract.d.ts +1794 -0
- package/dist/types/shared/dashboard-authoring/index.d.ts +5 -0
- package/dist/types/shared/dashboard-authoring/new-card.d.ts +10 -0
- package/dist/types/shared/dashboard-authoring/operations/apply-dashboard-operations.d.ts +40 -0
- package/dist/types/shared/dashboard-authoring/resolved-primary-date-field-validation.d.ts +16 -0
- package/dist/types/shared/format-utils/filter-detail.d.ts +70 -0
- package/dist/types/shared/format-utils/filter-value-text.d.ts +15 -0
- package/dist/types/shared/format-utils/index.d.ts +3 -0
- package/dist/types/shared/format-utils/raw-temporal.d.ts +7 -0
- package/dist/types/shared/format-utils/temporal-bucket.d.ts +7 -0
- package/dist/types/shared/layouts/frame-layouts.d.ts +23 -0
- package/dist/types/shared/layouts/index.d.ts +1 -0
- package/package.json +12 -2
- package/dist/chunks/calculated-field-identity-BptYhyOP.js +0 -1326
- package/dist/chunks/calendar-day-equality-BRjN1S9h.js +0 -383
- package/dist/chunks/card-config-utils-BOM1dxCk.js +0 -1150
- package/dist/chunks/constants-DNWVy8Y3.js +0 -9
- package/dist/chunks/dashboard-json-Ccjo0Dzw.js +0 -65
- package/dist/chunks/field-aggregations-CoLzYHeL.js +0 -1229
- package/dist/chunks/index-DTcTAGGM.js +0 -4101
- package/dist/chunks/matrix-continuation-C4sRcjZU.js +0 -72
- package/dist/chunks/matrix-control-sources-DTqcA2_L.js +0 -636
- package/dist/chunks/matrix-definition-D9iShKZI.js +0 -87
- package/dist/chunks/matrix-member-presentation-Ct8GuxHt.js +0 -209
- package/dist/chunks/numeric-presentation-CWu3gunq.js +0 -537
- package/dist/chunks/pivot-header-presentation-CHs2GFrM.js +0 -753
- package/dist/chunks/pivot-result-lifecycle-DQz_gjGu.js +0 -789
- package/dist/chunks/raw-temporal-iMXRK-Qz.js +0 -930
- package/dist/chunks/report-preferences-dialog-CW8VEIDx.js +0 -1623
- package/dist/chunks/save-kO6cIaob.js +0 -34
- package/dist/chunks/semantic-format-DiqYeKwU.js +0 -192
- package/dist/chunks/switch-CKB-kUaC.js +0 -25003
- package/dist/chunks/temporal-input-presentation-BD7YNUzu.js +0 -195
- package/dist/chunks/x-CXDkqdur.js +0 -149
- package/dist/types/lib/class-utils.d.ts +0 -2
- package/dist/types/lib/document/document-input-runtime.d.ts +0 -26
- package/dist/types/lib/utils.d.ts +0 -51
|
@@ -0,0 +1,2161 @@
|
|
|
1
|
+
var He = Object.defineProperty;
|
|
2
|
+
var ze = (e, t, n) => t in e ? He(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
|
3
|
+
var U = (e, t, n) => ze(e, typeof t != "symbol" ? t + "" : t, n);
|
|
4
|
+
import { I as Je, E as S, u as j, k as Ke, l as Me, B as Te, r as ae, t as le, aJ as Ze, x as Qe, a2 as We, am as Xe, aa as et, C as ce } from "./validators-Ej1DdCXa.js";
|
|
5
|
+
import { D as tt, t as nt } from "./matrix-operation-contract-B8PBF1Gd.js";
|
|
6
|
+
import { f as ot, C as rt } from "./metric-comparison-CojWeLqx.js";
|
|
7
|
+
import { j as Ne, b as it } from "./analytics-base-schemas-BFAoRlkU.js";
|
|
8
|
+
import { z as i } from "zod";
|
|
9
|
+
import { o as st } from "./source-entity-resolution-CVA1a85c.js";
|
|
10
|
+
import { r as at, C as lt } from "./common-types-CUf03Htv.js";
|
|
11
|
+
import { i as ct, a as dt } from "./matrix-card-CJn1hB5V.js";
|
|
12
|
+
import { v as $, i as mt, f as pt } from "./temporal-bucket-D8JF7zKz.js";
|
|
13
|
+
import { DEFAULT_RESOLVED_VALUE_FORMAT_PREFERENCES as Oe } from "../value-format-preferences/index.js";
|
|
14
|
+
import { g as de } from "./matrix-analytical-definition-bcprSe4u.js";
|
|
15
|
+
import { s as L } from "./stable-serialize-CfqXeiBP.js";
|
|
16
|
+
import { p as ut } from "./matrix-definition-DQDI2okF.js";
|
|
17
|
+
const V = /* @__PURE__ */ new Set([
|
|
18
|
+
"previous_period",
|
|
19
|
+
"same_period_last_year",
|
|
20
|
+
"start_vs_end",
|
|
21
|
+
"target"
|
|
22
|
+
]), ft = /* @__PURE__ */ new Set([...V, "none", ""]);
|
|
23
|
+
function y(e) {
|
|
24
|
+
return !!e && typeof e == "object" && !Array.isArray(e);
|
|
25
|
+
}
|
|
26
|
+
function ke(e) {
|
|
27
|
+
const t = y(e.preferences) ? e.preferences : void 0, n = t && y(t.kpiVisualOptions) ? t.kpiVisualOptions : void 0, o = t && y(t.tableVisualOptions) ? t.tableVisualOptions : void 0;
|
|
28
|
+
return {
|
|
29
|
+
preferences: t,
|
|
30
|
+
kpiOptions: n,
|
|
31
|
+
kpiComparison: n && y(n.metricComparison) ? n.metricComparison : void 0,
|
|
32
|
+
kpiComparisonPresent: !!n && "metricComparison" in n,
|
|
33
|
+
tableOptions: o,
|
|
34
|
+
tableComparison: o && y(o.metricComparison) ? o.metricComparison : void 0,
|
|
35
|
+
tableComparisonPresent: !!o && "metricComparison" in o
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
function me(e) {
|
|
39
|
+
const t = [], n = (o, r) => {
|
|
40
|
+
if (Array.isArray(o)) {
|
|
41
|
+
o.forEach((a, s) => n(a, `${r}[${s}]`));
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
if (!y(o)) return;
|
|
45
|
+
const l = o.config;
|
|
46
|
+
if (y(l)) {
|
|
47
|
+
const a = ke(o), s = !!(a.kpiComparisonPresent || a.tableComparisonPresent), c = l.metricColumns, d = Array.isArray(c) ? c.flatMap(
|
|
48
|
+
(m, p) => y(m) ? [{ index: p, metric: m }] : []
|
|
49
|
+
) : [];
|
|
50
|
+
if ((d.some(({ metric: m }) => "comparisonType" in m) || s) && t.push({
|
|
51
|
+
path: r,
|
|
52
|
+
card: o,
|
|
53
|
+
metrics: d,
|
|
54
|
+
malformedMetricIndexes: Array.isArray(c) ? c.flatMap(
|
|
55
|
+
(m, p) => y(m) ? [] : [p]
|
|
56
|
+
) : [],
|
|
57
|
+
malformedMetricColumns: "metricColumns" in l && !Array.isArray(c),
|
|
58
|
+
hasLegacyPresentation: s
|
|
59
|
+
}), "metricColumns" in l || s) return;
|
|
60
|
+
}
|
|
61
|
+
Object.entries(o).forEach(
|
|
62
|
+
([a, s]) => n(s, r ? `${r}.${a}` : a)
|
|
63
|
+
);
|
|
64
|
+
};
|
|
65
|
+
return n(e, "$"), t;
|
|
66
|
+
}
|
|
67
|
+
const Ye = {
|
|
68
|
+
difference: "difference",
|
|
69
|
+
change: "percent_change",
|
|
70
|
+
change_difference: "both",
|
|
71
|
+
ratio: "ratio"
|
|
72
|
+
};
|
|
73
|
+
function pe(e, t) {
|
|
74
|
+
if (!e) return;
|
|
75
|
+
const n = Object.fromEntries(
|
|
76
|
+
t.flatMap(
|
|
77
|
+
(o) => typeof e[o] == "string" ? [[o, e[o]]] : []
|
|
78
|
+
)
|
|
79
|
+
);
|
|
80
|
+
return Object.keys(n).length ? n : void 0;
|
|
81
|
+
}
|
|
82
|
+
function gt(e, t, n) {
|
|
83
|
+
if (e !== void 0) {
|
|
84
|
+
if (!y(e)) {
|
|
85
|
+
n.push({
|
|
86
|
+
severity: "error",
|
|
87
|
+
code: "invalid_legacy_comparison_presentation",
|
|
88
|
+
path: t,
|
|
89
|
+
message: "Legacy comparison formatOptions must be an object."
|
|
90
|
+
});
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
Object.entries(e).forEach(([o, r]) => {
|
|
94
|
+
if (o === "decimalPlaces") {
|
|
95
|
+
(typeof r != "number" || !Number.isInteger(r) || r < 0 || r > 6) && n.push({
|
|
96
|
+
severity: "error",
|
|
97
|
+
code: "invalid_legacy_comparison_presentation",
|
|
98
|
+
path: `${t}.decimalPlaces`,
|
|
99
|
+
message: "Legacy comparison decimalPlaces must be an integer from 0 through 6."
|
|
100
|
+
});
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
o === "type" && (r === void 0 || r === "auto") || r !== void 0 && n.push({
|
|
104
|
+
severity: "error",
|
|
105
|
+
code: "unsupported_comparison_format",
|
|
106
|
+
path: `${t}.${o}`,
|
|
107
|
+
message: `Legacy comparison format option "${o}" has no canonical presentation mapping.`
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
function J(e, t) {
|
|
113
|
+
const n = t === "kpi" ? e.calculationType : e.calculatedAs, o = t === "table" && n === void 0 ? "both" : Ye[String(n)], r = y(e.formatOptions) ? e.formatOptions : void 0, l = y(e.conditionalLabels) ? e.conditionalLabels : void 0, a = y(
|
|
114
|
+
t === "kpi" ? e.colorConfig : e.colors
|
|
115
|
+
) ? t === "kpi" ? e.colorConfig : e.colors : void 0, s = {};
|
|
116
|
+
if (o && (s.displayMode = o), typeof (r == null ? void 0 : r.decimalPlaces) == "number" && (s.precision = r.decimalPlaces), t === "kpi") {
|
|
117
|
+
const m = e.showArrow !== !1, p = e.showColor !== !1;
|
|
118
|
+
s.indicatorStyle = m ? p ? "arrow_badge" : "arrow" : p ? "badge" : "none", s.showColor = p, (e.position === "left" || e.position === "right" || e.position === "top") && (s.position = e.position), typeof e.conditionalLabel == "boolean" && (s.conditionalLabel = e.conditionalLabel), typeof e.labelName == "string" && (s.labelName = e.labelName);
|
|
119
|
+
} else (e.indicatorStyle === "arrow_badge" || e.indicatorStyle === "arrow" || e.indicatorStyle === "badge" || e.indicatorStyle === "none") && (s.indicatorStyle = e.indicatorStyle);
|
|
120
|
+
const c = l ? {
|
|
121
|
+
...pe(l, ["increase", "decrease"]),
|
|
122
|
+
...typeof l.noChange == "string" ? { neutral: l.noChange } : typeof l.neutral == "string" ? { neutral: l.neutral } : {}
|
|
123
|
+
} : void 0;
|
|
124
|
+
c && Object.keys(c).length && (s.conditionalLabels = c);
|
|
125
|
+
const d = a ? {
|
|
126
|
+
...pe(a, ["increase", "decrease"]),
|
|
127
|
+
...typeof a.noChange == "string" ? { neutral: a.noChange } : typeof a.neutral == "string" ? { neutral: a.neutral } : {}
|
|
128
|
+
} : void 0;
|
|
129
|
+
return d && Object.keys(d).length && (s.colors = d), s;
|
|
130
|
+
}
|
|
131
|
+
function ue(e) {
|
|
132
|
+
return { ...rt, ...e };
|
|
133
|
+
}
|
|
134
|
+
function fe(e) {
|
|
135
|
+
return e.some(({ metric: t }) => t.comparisonType === "previous_period" || t.comparisonType === "same_period_last_year" || t.comparisonType === "target" ? !0 : y(t.comparison) && t.comparison.mode === "explicit");
|
|
136
|
+
}
|
|
137
|
+
function H(e) {
|
|
138
|
+
const t = e.card.config;
|
|
139
|
+
return e.metrics.length === 2 && (t.groupByColumns === void 0 || Array.isArray(t.groupByColumns) && t.groupByColumns.length === 0);
|
|
140
|
+
}
|
|
141
|
+
function ge(e, t, n, o) {
|
|
142
|
+
const r = t === "kpi" ? [
|
|
143
|
+
"enabled",
|
|
144
|
+
"calculationType",
|
|
145
|
+
"formatOptions",
|
|
146
|
+
"showArrow",
|
|
147
|
+
"showColor",
|
|
148
|
+
"conditionalLabel",
|
|
149
|
+
"labelName",
|
|
150
|
+
"position",
|
|
151
|
+
"conditionalLabels",
|
|
152
|
+
"colorConfig",
|
|
153
|
+
"lowerIsBetter"
|
|
154
|
+
] : [
|
|
155
|
+
"calculatedAs",
|
|
156
|
+
"indicatorStyle",
|
|
157
|
+
"formatOptions",
|
|
158
|
+
"colors",
|
|
159
|
+
"lowerIsBetter"
|
|
160
|
+
];
|
|
161
|
+
Object.keys(e).forEach((m) => {
|
|
162
|
+
r.includes(m) || o.push({
|
|
163
|
+
severity: "error",
|
|
164
|
+
code: "invalid_legacy_comparison_presentation",
|
|
165
|
+
path: `${n}.${m}`,
|
|
166
|
+
message: `Unknown legacy comparison presentation field "${m}" cannot be dropped automatically.`
|
|
167
|
+
});
|
|
168
|
+
});
|
|
169
|
+
const l = t === "kpi" ? "calculationType" : "calculatedAs";
|
|
170
|
+
e[l] !== void 0 && !Ye[String(e[l])] && o.push({
|
|
171
|
+
severity: "error",
|
|
172
|
+
code: "invalid_legacy_comparison_presentation",
|
|
173
|
+
path: `${n}.${l}`,
|
|
174
|
+
message: `Legacy comparison ${l} is unsupported.`
|
|
175
|
+
}), t === "kpi" && e.position !== void 0 && !["left", "right", "top"].includes(String(e.position)) && o.push({
|
|
176
|
+
severity: "error",
|
|
177
|
+
code: "invalid_legacy_comparison_presentation",
|
|
178
|
+
path: `${n}.position`,
|
|
179
|
+
message: "Legacy comparison position is unsupported."
|
|
180
|
+
}), t === "kpi" && e.labelName !== void 0 && typeof e.labelName != "string" && o.push({
|
|
181
|
+
severity: "error",
|
|
182
|
+
code: "invalid_legacy_comparison_presentation",
|
|
183
|
+
path: `${n}.labelName`,
|
|
184
|
+
message: "Legacy comparison labelName must be a string."
|
|
185
|
+
}), (t === "kpi" ? [
|
|
186
|
+
["conditionalLabels", ["increase", "decrease", "noChange"]],
|
|
187
|
+
["colorConfig", ["increase", "decrease", "noChange"]]
|
|
188
|
+
] : [["colors", ["increase", "decrease", "neutral"]]]).forEach(([m, p]) => {
|
|
189
|
+
if (e[m] !== void 0) {
|
|
190
|
+
if (!y(e[m])) {
|
|
191
|
+
o.push({
|
|
192
|
+
severity: "error",
|
|
193
|
+
code: "invalid_legacy_comparison_presentation",
|
|
194
|
+
path: `${n}.${m}`,
|
|
195
|
+
message: `Legacy comparison ${m} must be an object.`
|
|
196
|
+
});
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
Object.entries(e[m]).forEach(([g, f]) => {
|
|
200
|
+
p.includes(g) ? typeof f != "string" && o.push({
|
|
201
|
+
severity: "error",
|
|
202
|
+
code: "invalid_legacy_comparison_presentation",
|
|
203
|
+
path: `${n}.${m}.${g}`,
|
|
204
|
+
message: `Legacy comparison ${m}.${g} must be a string.`
|
|
205
|
+
}) : o.push({
|
|
206
|
+
severity: "error",
|
|
207
|
+
code: "invalid_legacy_comparison_presentation",
|
|
208
|
+
path: `${n}.${m}.${g}`,
|
|
209
|
+
message: `Unknown legacy comparison ${m} field "${g}" cannot be dropped automatically.`
|
|
210
|
+
});
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
}), (t === "kpi" ? ["enabled", "showArrow", "showColor", "conditionalLabel", "lowerIsBetter"] : ["lowerIsBetter"]).forEach((m) => {
|
|
214
|
+
e[m] !== void 0 && typeof e[m] != "boolean" && o.push({
|
|
215
|
+
severity: "error",
|
|
216
|
+
code: "invalid_legacy_comparison_presentation",
|
|
217
|
+
path: `${n}.${m}`,
|
|
218
|
+
message: `Legacy comparison ${m} must be a boolean.`
|
|
219
|
+
});
|
|
220
|
+
}), t === "table" && e.indicatorStyle !== void 0 && !["arrow_badge", "arrow", "badge", "none"].includes(
|
|
221
|
+
String(e.indicatorStyle)
|
|
222
|
+
) && o.push({
|
|
223
|
+
severity: "error",
|
|
224
|
+
code: "invalid_legacy_comparison_presentation",
|
|
225
|
+
path: `${n}.indicatorStyle`,
|
|
226
|
+
message: "Legacy comparison indicatorStyle is unsupported."
|
|
227
|
+
}), gt(e.formatOptions, `${n}.formatOptions`, o);
|
|
228
|
+
const c = J(e, t);
|
|
229
|
+
ot(c, n).errors.forEach((m) => {
|
|
230
|
+
o.push({
|
|
231
|
+
severity: "error",
|
|
232
|
+
code: "invalid_legacy_comparison_presentation",
|
|
233
|
+
path: m.path || n,
|
|
234
|
+
message: m.message
|
|
235
|
+
});
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
function he(e) {
|
|
239
|
+
const t = ke(e.card), n = t.kpiComparison ? J(t.kpiComparison, "kpi") : void 0, o = t.tableComparison ? J(t.tableComparison, "table") : void 0;
|
|
240
|
+
return { namespaces: t, kpi: n, table: o, presentation: n || o };
|
|
241
|
+
}
|
|
242
|
+
function ht(e) {
|
|
243
|
+
const t = y(e.preferences) ? e.preferences : {}, n = y(t.kpiVisualOptions) ? t.kpiVisualOptions : {}, o = y(n.metricComparison) ? n.metricComparison : {}, r = y(t.tableVisualOptions) ? t.tableVisualOptions : {}, l = y(r.metricComparison) ? r.metricComparison : {};
|
|
244
|
+
return n.lowerIsBetter === !0 || o.lowerIsBetter === !0 || l.lowerIsBetter === !0 ? "lower_is_better" : "higher_is_better";
|
|
245
|
+
}
|
|
246
|
+
function yt(e) {
|
|
247
|
+
switch (e.comparisonType) {
|
|
248
|
+
case "previous_period":
|
|
249
|
+
return { mode: "explicit", spec: { kind: "previous_period" } };
|
|
250
|
+
case "same_period_last_year":
|
|
251
|
+
return { mode: "explicit", spec: { kind: "previous_year" } };
|
|
252
|
+
case "target":
|
|
253
|
+
return {
|
|
254
|
+
mode: "explicit",
|
|
255
|
+
spec: { kind: "target", targetValue: e.targetValue }
|
|
256
|
+
};
|
|
257
|
+
default:
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
function bt(e) {
|
|
262
|
+
const t = y(e.preferences) ? e.preferences : void 0;
|
|
263
|
+
if (!t) return;
|
|
264
|
+
const n = y(t.kpiVisualOptions) ? t.kpiVisualOptions : void 0;
|
|
265
|
+
n && delete n.lowerIsBetter;
|
|
266
|
+
const o = y(t.tableVisualOptions) ? t.tableVisualOptions : void 0, r = o && y(o.metricComparison) ? o.metricComparison : void 0;
|
|
267
|
+
r && delete r.lowerIsBetter;
|
|
268
|
+
}
|
|
269
|
+
function An(e) {
|
|
270
|
+
const t = me(e);
|
|
271
|
+
if (!t.length)
|
|
272
|
+
return { document: e, changed: !1, changes: [], diagnostics: [] };
|
|
273
|
+
const n = [];
|
|
274
|
+
if (t.forEach((a) => {
|
|
275
|
+
var s, c, d, m;
|
|
276
|
+
if (a.malformedMetricColumns && n.push({
|
|
277
|
+
severity: "error",
|
|
278
|
+
code: "malformed_metric_columns",
|
|
279
|
+
path: `${a.path}.config.metricColumns`,
|
|
280
|
+
message: "Metric columns must be an array before comparison migration."
|
|
281
|
+
}), a.malformedMetricIndexes.forEach((p) => {
|
|
282
|
+
n.push({
|
|
283
|
+
severity: "error",
|
|
284
|
+
code: "malformed_metric_columns",
|
|
285
|
+
path: `${a.path}.config.metricColumns[${p}]`,
|
|
286
|
+
message: "Metric columns must contain objects before comparison migration."
|
|
287
|
+
});
|
|
288
|
+
}), a.metrics.forEach(({ metric: p, index: g }) => {
|
|
289
|
+
if (!("comparisonType" in p)) return;
|
|
290
|
+
const f = `${a.path}.config.metricColumns[${g}]`, _ = String(p.comparisonType || "");
|
|
291
|
+
"comparison" in p && n.push({
|
|
292
|
+
severity: "error",
|
|
293
|
+
code: "conflicting_comparison_contracts",
|
|
294
|
+
path: f,
|
|
295
|
+
message: "Metric contains both legacy and canonical comparison configuration; resolve the conflict before migration."
|
|
296
|
+
});
|
|
297
|
+
const I = y(p.parameters) ? p.parameters : void 0, C = I && y(I.windowTransform) ? I.windowTransform : void 0;
|
|
298
|
+
V.has(_) && (C == null ? void 0 : C.function) === "previous_period_delta" && n.push({
|
|
299
|
+
severity: "error",
|
|
300
|
+
code: "conflicting_comparison_window_transform",
|
|
301
|
+
path: f,
|
|
302
|
+
message: "A metric cannot combine baseline comparison with previous_period_delta; resolve the authoring intent before migration."
|
|
303
|
+
}), ft.has(_) || n.push({
|
|
304
|
+
severity: "error",
|
|
305
|
+
code: "unsupported_comparison_type",
|
|
306
|
+
path: `${f}.comparisonType`,
|
|
307
|
+
message: `Unsupported legacy metric comparison type "${_}".`
|
|
308
|
+
}), p.comparisonType === "target" && (typeof p.targetValue != "number" || !Number.isFinite(p.targetValue)) && n.push({
|
|
309
|
+
severity: "error",
|
|
310
|
+
code: "invalid_target_value",
|
|
311
|
+
path: `${f}.targetValue`,
|
|
312
|
+
message: "Legacy target comparison requires a finite metric targetValue."
|
|
313
|
+
}), p.comparisonType === "start_vs_end" && n.push({
|
|
314
|
+
severity: "error",
|
|
315
|
+
code: "unsupported_start_vs_end",
|
|
316
|
+
path: `${f}.comparisonType`,
|
|
317
|
+
message: "start_vs_end is retired and cannot be migrated automatically."
|
|
318
|
+
}), p.targetValue !== void 0 && p.comparisonType !== "target" && n.push({
|
|
319
|
+
severity: "warning",
|
|
320
|
+
code: "stray_target_value",
|
|
321
|
+
path: `${f}.targetValue`,
|
|
322
|
+
message: "Dead non-target targetValue will be removed without changing the baseline."
|
|
323
|
+
});
|
|
324
|
+
}), a.hasLegacyPresentation) {
|
|
325
|
+
const { namespaces: p, kpi: g, table: f } = he(a), _ = [
|
|
326
|
+
(s = p.kpiOptions) == null ? void 0 : s.lowerIsBetter,
|
|
327
|
+
(c = p.kpiComparison) == null ? void 0 : c.lowerIsBetter,
|
|
328
|
+
(d = p.tableComparison) == null ? void 0 : d.lowerIsBetter
|
|
329
|
+
].filter((I) => typeof I == "boolean");
|
|
330
|
+
new Set(_).size > 1 && n.push({
|
|
331
|
+
severity: "error",
|
|
332
|
+
code: "conflicting_legacy_polarity",
|
|
333
|
+
path: `${a.path}.preferences`,
|
|
334
|
+
message: "Legacy comparison polarity values disagree; resolve the conflict before migration."
|
|
335
|
+
}), ((m = p.kpiOptions) == null ? void 0 : m.lowerIsBetter) !== void 0 && typeof p.kpiOptions.lowerIsBetter != "boolean" && n.push({
|
|
336
|
+
severity: "error",
|
|
337
|
+
code: "invalid_legacy_comparison_presentation",
|
|
338
|
+
path: `${a.path}.preferences.kpiVisualOptions.lowerIsBetter`,
|
|
339
|
+
message: "Legacy comparison lowerIsBetter must be a boolean."
|
|
340
|
+
}), p.kpiComparisonPresent && !p.kpiComparison && n.push({
|
|
341
|
+
severity: "error",
|
|
342
|
+
code: "invalid_legacy_comparison_presentation",
|
|
343
|
+
path: `${a.path}.preferences.kpiVisualOptions.metricComparison`,
|
|
344
|
+
message: "Legacy KPI comparison presentation must be an object."
|
|
345
|
+
}), p.tableComparisonPresent && !p.tableComparison && n.push({
|
|
346
|
+
severity: "error",
|
|
347
|
+
code: "invalid_legacy_comparison_presentation",
|
|
348
|
+
path: `${a.path}.preferences.tableVisualOptions.metricComparison`,
|
|
349
|
+
message: "Legacy table comparison presentation must be an object."
|
|
350
|
+
}), "comparisonPresentation" in (p.preferences || {}) && n.push({
|
|
351
|
+
severity: "error",
|
|
352
|
+
code: "conflicting_comparison_presentation_contracts",
|
|
353
|
+
path: `${a.path}.preferences.comparisonPresentation`,
|
|
354
|
+
message: "Card contains both legacy and canonical comparison presentation; resolve the conflict before migration."
|
|
355
|
+
}), p.kpiComparison && typeof p.kpiComparison.enabled == "boolean" && "metricPairComparisonEnabled" in (p.preferences || {}) && H(a) && n.push({
|
|
356
|
+
severity: "error",
|
|
357
|
+
code: "conflicting_comparison_presentation_contracts",
|
|
358
|
+
path: `${a.path}.preferences.metricPairComparisonEnabled`,
|
|
359
|
+
message: "Card contains both legacy and canonical metric-pair enablement; resolve the conflict before migration."
|
|
360
|
+
}), p.kpiComparison && ge(
|
|
361
|
+
p.kpiComparison,
|
|
362
|
+
"kpi",
|
|
363
|
+
`${a.path}.preferences.kpiVisualOptions.metricComparison`,
|
|
364
|
+
n
|
|
365
|
+
), p.tableComparison && ge(
|
|
366
|
+
p.tableComparison,
|
|
367
|
+
"table",
|
|
368
|
+
`${a.path}.preferences.tableVisualOptions.metricComparison`,
|
|
369
|
+
n
|
|
370
|
+
), g && f && JSON.stringify(ue(g)) !== JSON.stringify(ue(f)) && n.push({
|
|
371
|
+
severity: "error",
|
|
372
|
+
code: "conflicting_legacy_presentation_namespaces",
|
|
373
|
+
path: `${a.path}.preferences`,
|
|
374
|
+
message: "KPI and table comparison presentation values disagree; resolve the conflict before migration."
|
|
375
|
+
});
|
|
376
|
+
}
|
|
377
|
+
}), n.some((a) => a.severity === "error"))
|
|
378
|
+
return { document: e, changed: !1, changes: [], diagnostics: n };
|
|
379
|
+
const o = JSON.parse(JSON.stringify(e)), r = me(o), l = [];
|
|
380
|
+
return r.forEach((a) => {
|
|
381
|
+
var c;
|
|
382
|
+
const s = ht(a.card);
|
|
383
|
+
if (a.metrics.forEach(({ metric: d, index: m }) => {
|
|
384
|
+
if (!("comparisonType" in d)) return;
|
|
385
|
+
const p = String(d.comparisonType || ""), g = `${a.path}.config.metricColumns[${m}]`, f = yt(d), _ = ["comparisonType"];
|
|
386
|
+
delete d.comparisonType, "targetValue" in d && (delete d.targetValue, _.push("targetValue")), "comparisonDisplay" in d && (delete d.comparisonDisplay, _.push("comparisonDisplay")), f ? d.comparison = f : delete d.comparison, V.has(p) && (d.comparisonPolarity = s), l.push({
|
|
387
|
+
kind: "metric",
|
|
388
|
+
path: g,
|
|
389
|
+
metricId: typeof d.id == "string" ? d.id : void 0,
|
|
390
|
+
legacyType: p,
|
|
391
|
+
comparison: f,
|
|
392
|
+
comparisonPolarity: V.has(p) ? s : void 0,
|
|
393
|
+
removedFields: _
|
|
394
|
+
});
|
|
395
|
+
}), bt(a.card), a.hasLegacyPresentation) {
|
|
396
|
+
const { namespaces: d, presentation: m } = he(a), p = (c = d.kpiComparison) == null ? void 0 : c.enabled, g = {
|
|
397
|
+
...m
|
|
398
|
+
};
|
|
399
|
+
typeof p == "boolean" && fe(a.metrics) && (g.showComparison = p);
|
|
400
|
+
const f = typeof p == "boolean" && H(a) ? p : void 0, _ = typeof p == "boolean" && !fe(a.metrics) && !H(a) ? ["kpiVisualOptions.metricComparison.enabled"] : void 0, I = d.preferences, C = [];
|
|
401
|
+
a.metrics.forEach(({ metric: k }) => {
|
|
402
|
+
"comparisonPolarity" in k || (k.comparisonPolarity = s, typeof k.id == "string" && C.push(k.id));
|
|
403
|
+
}), Object.keys(g).length && (I.comparisonPresentation = g), f !== void 0 && (I.metricPairComparisonEnabled = f), d.kpiOptions && delete d.kpiOptions.metricComparison, d.tableOptions && delete d.tableOptions.metricComparison, l.push({
|
|
404
|
+
kind: "presentation",
|
|
405
|
+
path: `${a.path}.preferences`,
|
|
406
|
+
comparisonPresentation: Object.keys(g).length ? g : void 0,
|
|
407
|
+
metricPairComparisonEnabled: f,
|
|
408
|
+
comparisonPolarityMetricIds: C,
|
|
409
|
+
intentionallyDiscardedFields: _,
|
|
410
|
+
removedFields: [
|
|
411
|
+
...d.kpiComparison ? ["kpiVisualOptions.metricComparison"] : [],
|
|
412
|
+
...d.tableComparison ? ["tableVisualOptions.metricComparison"] : []
|
|
413
|
+
]
|
|
414
|
+
});
|
|
415
|
+
}
|
|
416
|
+
}), { document: o, changed: !0, changes: l, diagnostics: n };
|
|
417
|
+
}
|
|
418
|
+
function h(e) {
|
|
419
|
+
return typeof e == "string" && e.trim().length > 0 ? e.trim() : null;
|
|
420
|
+
}
|
|
421
|
+
function Ae(e) {
|
|
422
|
+
return Array.from(new Set(e.filter((t) => !!t)));
|
|
423
|
+
}
|
|
424
|
+
function It(e) {
|
|
425
|
+
const t = h(e.table), n = h(e.schema), o = h(e.catalog) || h(e.database);
|
|
426
|
+
return t ? Ae([
|
|
427
|
+
t,
|
|
428
|
+
n ? `${n}.${t}` : null,
|
|
429
|
+
o ? `${o}.${t}` : null,
|
|
430
|
+
o && n ? `${o}.${n}.${t}` : null
|
|
431
|
+
]) : [];
|
|
432
|
+
}
|
|
433
|
+
function ye(e) {
|
|
434
|
+
const t = h(e.table) || h(e.tableName);
|
|
435
|
+
return Ae([
|
|
436
|
+
h(e.name),
|
|
437
|
+
h(e.alias),
|
|
438
|
+
...It({
|
|
439
|
+
table: t,
|
|
440
|
+
schema: h(e.schema) || h(e.schemaName),
|
|
441
|
+
catalog: h(e.catalog),
|
|
442
|
+
database: h(e.database) || h(e.databaseName)
|
|
443
|
+
})
|
|
444
|
+
]);
|
|
445
|
+
}
|
|
446
|
+
function _t(e, t) {
|
|
447
|
+
const n = h(e.domainId), o = h(t.domainId);
|
|
448
|
+
if (n && o && n !== o)
|
|
449
|
+
return !0;
|
|
450
|
+
if (e.type === "dataset")
|
|
451
|
+
return !1;
|
|
452
|
+
const r = h(e.id), l = h(t.id);
|
|
453
|
+
if (r && l && r !== l)
|
|
454
|
+
return !0;
|
|
455
|
+
const a = h(e.connectionId), s = h(t.connectionId);
|
|
456
|
+
return !!(a && s && a !== s);
|
|
457
|
+
}
|
|
458
|
+
function K(e, t = !1) {
|
|
459
|
+
return h(e.table) || h(e.tableName) || (e.type !== "dataset" || t ? h(e.name) : null);
|
|
460
|
+
}
|
|
461
|
+
function Z(e) {
|
|
462
|
+
return h(e.catalog) || h(e.database) || h(e.databaseName);
|
|
463
|
+
}
|
|
464
|
+
function Q(e) {
|
|
465
|
+
return h(e.schema) || h(e.schemaName);
|
|
466
|
+
}
|
|
467
|
+
function B(e) {
|
|
468
|
+
return e.length === 1 ? e[0] : void 0;
|
|
469
|
+
}
|
|
470
|
+
function Ct(e, t) {
|
|
471
|
+
const n = K(t, !0), o = Z(t), r = Q(t);
|
|
472
|
+
if (!(!n || !o && !r))
|
|
473
|
+
return B(
|
|
474
|
+
e.filter((l) => {
|
|
475
|
+
const a = l;
|
|
476
|
+
return !(K(a) !== n || o && Z(a) !== o || r && Q(a) !== r);
|
|
477
|
+
})
|
|
478
|
+
);
|
|
479
|
+
}
|
|
480
|
+
function P(e, t) {
|
|
481
|
+
if (!t || !(e != null && e.length))
|
|
482
|
+
return;
|
|
483
|
+
const n = e.filter(
|
|
484
|
+
(s) => !_t(s, t)
|
|
485
|
+
);
|
|
486
|
+
if (t.type === "dataset") {
|
|
487
|
+
const s = h(t.id);
|
|
488
|
+
if (s)
|
|
489
|
+
return B(
|
|
490
|
+
n.filter(
|
|
491
|
+
(d) => d.type === "dataset" && h(d.id) === s
|
|
492
|
+
)
|
|
493
|
+
);
|
|
494
|
+
if (h(t.domainId)) {
|
|
495
|
+
const d = h(t.name);
|
|
496
|
+
return B(
|
|
497
|
+
n.filter(
|
|
498
|
+
(m) => m.type === "dataset" && h(m.name) === d
|
|
499
|
+
)
|
|
500
|
+
);
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
let o = [];
|
|
504
|
+
if (t.type === "dataset") {
|
|
505
|
+
const s = h(t.name);
|
|
506
|
+
if (o = n.filter(
|
|
507
|
+
(c) => c.type === "dataset" && h(c.name) === s
|
|
508
|
+
), o.length === 1)
|
|
509
|
+
return o[0];
|
|
510
|
+
}
|
|
511
|
+
if (!!(K(t, !0) && (Z(t) || Q(t))))
|
|
512
|
+
return Ct(n, t);
|
|
513
|
+
if (o.length > 1)
|
|
514
|
+
return;
|
|
515
|
+
const l = ye(t);
|
|
516
|
+
if (l.length === 0)
|
|
517
|
+
return;
|
|
518
|
+
const a = n.filter((s) => ye(
|
|
519
|
+
s
|
|
520
|
+
).some(
|
|
521
|
+
(d) => l.includes(d)
|
|
522
|
+
));
|
|
523
|
+
return B(a);
|
|
524
|
+
}
|
|
525
|
+
function z(e, t) {
|
|
526
|
+
const n = P(e, t);
|
|
527
|
+
return n ? { ...t, ...n } : t;
|
|
528
|
+
}
|
|
529
|
+
function Rn(e, t) {
|
|
530
|
+
const n = t || [];
|
|
531
|
+
return n.length === 0 ? e : {
|
|
532
|
+
...e,
|
|
533
|
+
baseEntity: z(n, e.baseEntity),
|
|
534
|
+
joins: e.joins.map((o) => ({
|
|
535
|
+
...o,
|
|
536
|
+
source: z(n, o.source),
|
|
537
|
+
target: z(n, o.target)
|
|
538
|
+
}))
|
|
539
|
+
};
|
|
540
|
+
}
|
|
541
|
+
function Pn(e, t) {
|
|
542
|
+
if (!(e != null && e.joins.length))
|
|
543
|
+
return [];
|
|
544
|
+
const n = [
|
|
545
|
+
e.baseEntity,
|
|
546
|
+
...e.joins.flatMap((r) => [r.source, r.target])
|
|
547
|
+
], o = [];
|
|
548
|
+
return n.forEach((r) => {
|
|
549
|
+
!P(t, r) && !P(o, r) && o.push(r);
|
|
550
|
+
}), o;
|
|
551
|
+
}
|
|
552
|
+
function A(e) {
|
|
553
|
+
return !!e && typeof e == "object" && !Array.isArray(e);
|
|
554
|
+
}
|
|
555
|
+
function R(e) {
|
|
556
|
+
return A(e) && typeof e.name == "string";
|
|
557
|
+
}
|
|
558
|
+
function ee(e) {
|
|
559
|
+
return !A(e) || e.kind !== "semantic" && e.kind !== "physical" || (e.kind === "semantic" ? [e.datasetId, e.datasetName, e.connectionId] : [e.databaseName, e.schemaName]).some(
|
|
560
|
+
(n) => n !== void 0 && typeof n != "string"
|
|
561
|
+
) ? !1 : Je(
|
|
562
|
+
e
|
|
563
|
+
);
|
|
564
|
+
}
|
|
565
|
+
function vt(e) {
|
|
566
|
+
return [
|
|
567
|
+
...e.groupByColumns ?? [],
|
|
568
|
+
...e.metricColumns ?? [],
|
|
569
|
+
...e.pivotByColumns ?? [],
|
|
570
|
+
...e.detailColumns ?? [],
|
|
571
|
+
...e.sortByColumns ?? []
|
|
572
|
+
];
|
|
573
|
+
}
|
|
574
|
+
function te(e) {
|
|
575
|
+
return e ? [
|
|
576
|
+
...(e.conditions ?? []).flatMap(
|
|
577
|
+
(t) => t.field ? [t.field] : []
|
|
578
|
+
),
|
|
579
|
+
...(e.groups ?? []).flatMap(te)
|
|
580
|
+
] : [];
|
|
581
|
+
}
|
|
582
|
+
function Re(e) {
|
|
583
|
+
var o, r;
|
|
584
|
+
const t = "parameters" in e ? te((o = e.parameters) == null ? void 0 : o.filters) : [], n = ((r = e.calculatedFormula) == null ? void 0 : r.inputFields) ?? [];
|
|
585
|
+
return [
|
|
586
|
+
...t,
|
|
587
|
+
...n.flatMap((l) => Re(l))
|
|
588
|
+
];
|
|
589
|
+
}
|
|
590
|
+
function Pe(e) {
|
|
591
|
+
const t = Array.isArray(e == null ? void 0 : e.selectedEntities) ? e.selectedEntities.filter(R) : [];
|
|
592
|
+
return j(
|
|
593
|
+
t.flatMap((n) => {
|
|
594
|
+
const o = F(n, e);
|
|
595
|
+
return o ? [o] : [];
|
|
596
|
+
})
|
|
597
|
+
);
|
|
598
|
+
}
|
|
599
|
+
function W(e, t) {
|
|
600
|
+
const n = t.filter(
|
|
601
|
+
(o) => S(o, e)
|
|
602
|
+
);
|
|
603
|
+
return n.length === 1 ? n[0] : void 0;
|
|
604
|
+
}
|
|
605
|
+
function Et(e, t) {
|
|
606
|
+
if (t.kind === "semantic")
|
|
607
|
+
return !!(e.entityId && e.entityId === t.datasetId || e.entityName && e.entityName === t.datasetName);
|
|
608
|
+
const n = [
|
|
609
|
+
t.databaseName,
|
|
610
|
+
t.schemaName,
|
|
611
|
+
t.tableName
|
|
612
|
+
].filter((o) => !!o).join(".");
|
|
613
|
+
return !!(e.entityName === t.tableName || e.qualifiedEntityName && e.qualifiedEntityName === n);
|
|
614
|
+
}
|
|
615
|
+
function wt(e, t) {
|
|
616
|
+
const n = Array.isArray(t == null ? void 0 : t.selectedEntities) ? t.selectedEntities.filter(R) : [], o = e.entityName || e.qualifiedEntityName;
|
|
617
|
+
if (!o) return;
|
|
618
|
+
const r = e.entityId ? P(n, {
|
|
619
|
+
type: "dataset",
|
|
620
|
+
id: e.entityId,
|
|
621
|
+
name: o
|
|
622
|
+
}) : void 0;
|
|
623
|
+
if (r)
|
|
624
|
+
return F(r, t);
|
|
625
|
+
const l = P(n, {
|
|
626
|
+
type: (t == null ? void 0 : t.mode) === "semanticDomain" ? "dataset" : "table",
|
|
627
|
+
name: (t == null ? void 0 : t.mode) === "semanticDomain" ? o : e.qualifiedEntityName || o
|
|
628
|
+
});
|
|
629
|
+
if (l && !((t == null ? void 0 : t.mode) === "semanticDomain" && e.entityId && ![
|
|
630
|
+
e.entityName,
|
|
631
|
+
e.qualifiedEntityName,
|
|
632
|
+
l.name,
|
|
633
|
+
l.type === "dataset" && "table" in l ? l.table : void 0
|
|
634
|
+
].filter((s) => !!s).includes(e.entityId)))
|
|
635
|
+
return F(l, t);
|
|
636
|
+
}
|
|
637
|
+
function Dt(e, t, n) {
|
|
638
|
+
var l, a, s;
|
|
639
|
+
const o = !!(Ke(e) || (a = (l = e.calculatedFormula) == null ? void 0 : l.inputFields) != null && a.length || (s = e.derivedField) != null && s.inputs && Object.keys(e.derivedField.inputs).length > 0);
|
|
640
|
+
if (e.source && !o) {
|
|
641
|
+
const c = W(
|
|
642
|
+
e.source,
|
|
643
|
+
n
|
|
644
|
+
);
|
|
645
|
+
return c ? [c] : [];
|
|
646
|
+
}
|
|
647
|
+
const r = at(e).datasets;
|
|
648
|
+
return j(
|
|
649
|
+
r.flatMap((c) => {
|
|
650
|
+
const m = e.source && Et(c, e.source) && W(e.source, n) || wt(c, t);
|
|
651
|
+
return m ? [m] : [];
|
|
652
|
+
})
|
|
653
|
+
);
|
|
654
|
+
}
|
|
655
|
+
function Mt(e, t) {
|
|
656
|
+
const n = Pe(t), o = vt(e), r = te(e.filters), l = [
|
|
657
|
+
...r,
|
|
658
|
+
...[...o, ...r].flatMap(Re)
|
|
659
|
+
];
|
|
660
|
+
return j(
|
|
661
|
+
[...o, ...l].flatMap(
|
|
662
|
+
(a) => Dt(a, t, n)
|
|
663
|
+
)
|
|
664
|
+
);
|
|
665
|
+
}
|
|
666
|
+
function Tt(e, t, n) {
|
|
667
|
+
var r;
|
|
668
|
+
return ee(e) ? !!!((r = t == null ? void 0 : t.selectedEntities) != null && r.length) || !n ? e : W(e, Pe(t)) : void 0;
|
|
669
|
+
}
|
|
670
|
+
function F(e, t) {
|
|
671
|
+
var d, m;
|
|
672
|
+
const n = Array.isArray(t == null ? void 0 : t.selectedEntities) ? t.selectedEntities.filter(R) : void 0, o = P(n, e), r = o ? { ...e, ...o } : e, l = "domainId" in r && typeof r.domainId == "string" && !!r.domainId.trim();
|
|
673
|
+
if ((t == null ? void 0 : t.mode) === "semanticDomain" && !l)
|
|
674
|
+
return;
|
|
675
|
+
if ((t == null ? void 0 : t.mode) !== "database" && r.type === "dataset") {
|
|
676
|
+
const p = st(
|
|
677
|
+
{
|
|
678
|
+
entities: [r],
|
|
679
|
+
semanticDomainId: t == null ? void 0 : t.semanticDomainId,
|
|
680
|
+
connectionId: t == null ? void 0 : t.connectionId,
|
|
681
|
+
fieldEntityType: "dataset"
|
|
682
|
+
},
|
|
683
|
+
{ includePhysicalDatasets: !0 }
|
|
684
|
+
);
|
|
685
|
+
if (p.kind === "resolved") {
|
|
686
|
+
const g = "label" in r && typeof r.label == "string" ? r.label : void 0;
|
|
687
|
+
return {
|
|
688
|
+
...p.source,
|
|
689
|
+
...g ? { label: g } : {}
|
|
690
|
+
};
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
if ((t == null ? void 0 : t.mode) === "semanticDomain")
|
|
694
|
+
return;
|
|
695
|
+
const a = r.connectionId || (t == null ? void 0 : t.connectionId), s = r.type === "dataset" && "table" in r && r.table ? r.table : r.name;
|
|
696
|
+
if (!a || !s)
|
|
697
|
+
return;
|
|
698
|
+
const c = {
|
|
699
|
+
kind: "physical",
|
|
700
|
+
connectionId: a,
|
|
701
|
+
connectionType: r.connectionType || (t == null ? void 0 : t.connectionType),
|
|
702
|
+
tableName: s,
|
|
703
|
+
databaseName: r.database || ((d = t == null ? void 0 : t.dbSelection) == null ? void 0 : d.database),
|
|
704
|
+
schemaName: r.schema || ((m = t == null ? void 0 : t.dbSelection) == null ? void 0 : m.schema),
|
|
705
|
+
dialect: r.dialect
|
|
706
|
+
};
|
|
707
|
+
return ee(c) ? c : void 0;
|
|
708
|
+
}
|
|
709
|
+
function Nt(e, t) {
|
|
710
|
+
var s, c;
|
|
711
|
+
const n = F(e, t);
|
|
712
|
+
if (!n) return;
|
|
713
|
+
const o = e.type === "dataset" && "table" in e && typeof e.table == "string" ? e.table.trim() : void 0, r = n.kind === "physical" ? n.tableName : o, l = e.connectionId || (t == null ? void 0 : t.connectionId), a = r && l ? {
|
|
714
|
+
connectionId: l,
|
|
715
|
+
databaseName: e.database || ((s = t == null ? void 0 : t.dbSelection) == null ? void 0 : s.database),
|
|
716
|
+
schemaName: e.schema || ((c = t == null ? void 0 : t.dbSelection) == null ? void 0 : c.schema),
|
|
717
|
+
tableName: r
|
|
718
|
+
} : void 0;
|
|
719
|
+
return { source: n, ...a ? { executionTable: a } : {} };
|
|
720
|
+
}
|
|
721
|
+
function Ot(e) {
|
|
722
|
+
const t = A(e.dataSource) ? e.dataSource : void 0;
|
|
723
|
+
if (typeof e.sql == "string" && e.sql.trim()) {
|
|
724
|
+
const s = [], c = Array.isArray(t == null ? void 0 : t.selectedEntities) ? t.selectedEntities : [];
|
|
725
|
+
for (const d of c) {
|
|
726
|
+
if (!R(d)) continue;
|
|
727
|
+
const m = Nt(d, t);
|
|
728
|
+
m && !s.some(
|
|
729
|
+
(p) => S(
|
|
730
|
+
p.source,
|
|
731
|
+
m.source
|
|
732
|
+
)
|
|
733
|
+
) && s.push(m);
|
|
734
|
+
}
|
|
735
|
+
return {
|
|
736
|
+
cardId: e.id,
|
|
737
|
+
kind: "sql",
|
|
738
|
+
pinnedCatalogSources: s
|
|
739
|
+
};
|
|
740
|
+
}
|
|
741
|
+
if (!A(e.config))
|
|
742
|
+
return { cardId: e.id, kind: "unconfigured" };
|
|
743
|
+
const n = e.config, o = [], r = ct(e);
|
|
744
|
+
if (r.status === "invalid")
|
|
745
|
+
return { cardId: e.id, kind: "unconfigured" };
|
|
746
|
+
const l = r.status === "ready" ? r.config : void 0;
|
|
747
|
+
if (e.type === "matrixTable" && !l)
|
|
748
|
+
return { cardId: e.id, kind: "unconfigured" };
|
|
749
|
+
l && o.push(
|
|
750
|
+
...dt(l.spec).filter(ee)
|
|
751
|
+
);
|
|
752
|
+
const a = (l == null ? void 0 : l.spec.joinPlan) ?? (A(n.joinPlan) ? n.joinPlan : void 0);
|
|
753
|
+
if (a) {
|
|
754
|
+
const s = Array.isArray(a.joins) ? a.joins : [], c = [a.baseEntity];
|
|
755
|
+
for (const m of s)
|
|
756
|
+
A(m) && c.push(m.source, m.target);
|
|
757
|
+
let d = !1;
|
|
758
|
+
for (const m of c) {
|
|
759
|
+
if (!R(m)) {
|
|
760
|
+
d = !0;
|
|
761
|
+
continue;
|
|
762
|
+
}
|
|
763
|
+
const p = F(m, t);
|
|
764
|
+
p ? o.push(p) : d = !0;
|
|
765
|
+
}
|
|
766
|
+
d && (o.length = 0);
|
|
767
|
+
} else if (e.type !== "matrixTable") {
|
|
768
|
+
const s = Array.isArray(t == null ? void 0 : t.selectedEntities) ? t.selectedEntities : [];
|
|
769
|
+
if (s.length === 1 && R(s[0])) {
|
|
770
|
+
const d = F(
|
|
771
|
+
s[0],
|
|
772
|
+
t
|
|
773
|
+
);
|
|
774
|
+
d && o.push(d);
|
|
775
|
+
}
|
|
776
|
+
o.push(...Mt(n, t));
|
|
777
|
+
const c = Tt(
|
|
778
|
+
n.queryBaseSource,
|
|
779
|
+
t,
|
|
780
|
+
o.length > 0
|
|
781
|
+
);
|
|
782
|
+
c && o.push(c);
|
|
783
|
+
}
|
|
784
|
+
return {
|
|
785
|
+
cardId: e.id,
|
|
786
|
+
kind: "config",
|
|
787
|
+
executableSources: j(o)
|
|
788
|
+
};
|
|
789
|
+
}
|
|
790
|
+
function Fn(e, t) {
|
|
791
|
+
return (e.kind === "config" ? e.executableSources : e.kind === "sql" ? e.pinnedCatalogSources.map((o) => o.source) : []).some(
|
|
792
|
+
(o) => S(o, t)
|
|
793
|
+
);
|
|
794
|
+
}
|
|
795
|
+
function kt(e, t) {
|
|
796
|
+
if (e.kind === "config")
|
|
797
|
+
return e.executableSources.find(
|
|
798
|
+
(n) => S(n, t)
|
|
799
|
+
);
|
|
800
|
+
}
|
|
801
|
+
function $n(e, t) {
|
|
802
|
+
var n;
|
|
803
|
+
return (n = Yt(e, t)) == null ? void 0 : n.source;
|
|
804
|
+
}
|
|
805
|
+
function Yt(e, t) {
|
|
806
|
+
if (e.kind === "sql")
|
|
807
|
+
return e.pinnedCatalogSources.find(
|
|
808
|
+
(n) => S(n.source, t)
|
|
809
|
+
);
|
|
810
|
+
}
|
|
811
|
+
const Fe = {
|
|
812
|
+
rowMembers: !0,
|
|
813
|
+
columnMembers: !0,
|
|
814
|
+
cells: !0
|
|
815
|
+
};
|
|
816
|
+
function At(e, t) {
|
|
817
|
+
return {
|
|
818
|
+
enabled: t === "on",
|
|
819
|
+
fields: e.type === "detailTable" ? { kind: "clickedCell" } : { kind: "wholeRow" },
|
|
820
|
+
multipleSelection: !0,
|
|
821
|
+
selectionCheckboxes: "auto",
|
|
822
|
+
...e.type === "matrixTable" ? { matrixSources: { ...Fe } } : {},
|
|
823
|
+
targets: { kind: "allSheets" },
|
|
824
|
+
cardMappings: []
|
|
825
|
+
};
|
|
826
|
+
}
|
|
827
|
+
const Rt = ["string", "number", "boolean", "date", "datetime"];
|
|
828
|
+
function Pt(e) {
|
|
829
|
+
return (e.kind === "semantic" ? [e.datasetId, e.datasetName] : [
|
|
830
|
+
e.tableName,
|
|
831
|
+
[e.databaseName, e.schemaName, e.tableName].filter(Boolean).join(".")
|
|
832
|
+
]).filter((t) => !!t).map((t) => Te(t));
|
|
833
|
+
}
|
|
834
|
+
function Ft(e, t) {
|
|
835
|
+
if (t.kind !== "config" || e.expression || e.calculatedFormula) return;
|
|
836
|
+
const n = Me(e.dataType);
|
|
837
|
+
if (!Rt.includes(n)) return;
|
|
838
|
+
let o;
|
|
839
|
+
if (e.source)
|
|
840
|
+
o = kt(t, e.source);
|
|
841
|
+
else {
|
|
842
|
+
const r = [e.entityId, e.entityName, e.qualifiedEntityName].filter((a) => !!a).map((a) => Te(a)), l = t.executableSources.filter(
|
|
843
|
+
(a) => Pt(a).some((s) => r.includes(s))
|
|
844
|
+
);
|
|
845
|
+
l.length === 1 ? o = l[0] : !l.length && t.executableSources.length === 1 && (o = t.executableSources[0]);
|
|
846
|
+
}
|
|
847
|
+
if (!(!o || !e.name))
|
|
848
|
+
return {
|
|
849
|
+
name: e.name,
|
|
850
|
+
source: o,
|
|
851
|
+
dataType: n,
|
|
852
|
+
...e.sourceField && e.sourceField !== e.name ? { sourceField: e.sourceField } : {}
|
|
853
|
+
};
|
|
854
|
+
}
|
|
855
|
+
function $t(e, t) {
|
|
856
|
+
const { matrixSources: n, ...o } = t, r = t.fields.kind === "chosenColumns" ? {
|
|
857
|
+
kind: "chosenColumns",
|
|
858
|
+
clickedFieldKeys: [...new Set(t.fields.clickedFieldKeys)]
|
|
859
|
+
} : t.fields;
|
|
860
|
+
return {
|
|
861
|
+
...o,
|
|
862
|
+
fields: r,
|
|
863
|
+
...e.type === "matrixTable" ? { matrixSources: n ?? { ...Fe } } : {}
|
|
864
|
+
};
|
|
865
|
+
}
|
|
866
|
+
function xn(e, t) {
|
|
867
|
+
var p, g;
|
|
868
|
+
if (e.clickToFilter)
|
|
869
|
+
return $t(e, e.clickToFilter);
|
|
870
|
+
const n = At(e, t), o = (((p = e.interactionConfig) == null ? void 0 : p.interactions) ?? []).filter(
|
|
871
|
+
(f) => f.mode === "clickFilter"
|
|
872
|
+
);
|
|
873
|
+
if (!o.length) return n;
|
|
874
|
+
const r = Ot(e);
|
|
875
|
+
let l = !1;
|
|
876
|
+
const a = [];
|
|
877
|
+
for (const f of o) {
|
|
878
|
+
if (((g = f.trigger) == null ? void 0 : g.type) !== "attribute") {
|
|
879
|
+
l = !0;
|
|
880
|
+
continue;
|
|
881
|
+
}
|
|
882
|
+
const _ = Ft(
|
|
883
|
+
f.trigger.field,
|
|
884
|
+
r
|
|
885
|
+
);
|
|
886
|
+
if (!_) {
|
|
887
|
+
l = !0;
|
|
888
|
+
continue;
|
|
889
|
+
}
|
|
890
|
+
const I = nt(_);
|
|
891
|
+
a.includes(I) || a.push(I);
|
|
892
|
+
}
|
|
893
|
+
const s = o.every(
|
|
894
|
+
(f) => f.applyToCardIds !== void 0
|
|
895
|
+
), c = [
|
|
896
|
+
...new Set(o.flatMap((f) => f.applyToCardIds ?? []))
|
|
897
|
+
], d = o.filter(
|
|
898
|
+
(f) => f.applyToCardIds === void 0
|
|
899
|
+
), m = s ? [] : [
|
|
900
|
+
...new Set(d.flatMap((f) => f.excludeCardIds ?? []))
|
|
901
|
+
].filter(
|
|
902
|
+
(f) => d.every((_) => {
|
|
903
|
+
var I;
|
|
904
|
+
return (I = _.excludeCardIds) == null ? void 0 : I.includes(f);
|
|
905
|
+
})
|
|
906
|
+
);
|
|
907
|
+
return {
|
|
908
|
+
...n,
|
|
909
|
+
enabled: !0,
|
|
910
|
+
fields: l || !a.length ? { kind: "wholeRow" } : { kind: "chosenColumns", clickedFieldKeys: a },
|
|
911
|
+
targets: s ? { kind: "cards", cardIds: c } : { kind: "allSheets" },
|
|
912
|
+
cardMappings: m.map((f) => ({
|
|
913
|
+
kind: "excluded",
|
|
914
|
+
cardId: f
|
|
915
|
+
}))
|
|
916
|
+
};
|
|
917
|
+
}
|
|
918
|
+
const $e = i.union([
|
|
919
|
+
i.object({
|
|
920
|
+
kind: i.literal("allSheets"),
|
|
921
|
+
sheetKinds: i.array(i.enum(["dashboard", "document"])).optional()
|
|
922
|
+
}).strict(),
|
|
923
|
+
i.object({ kind: i.literal("sheets"), sheetIds: i.array(i.string()) }).strict(),
|
|
924
|
+
i.object({ kind: i.literal("cards"), cardIds: i.array(i.string()) }).strict(),
|
|
925
|
+
i.object({
|
|
926
|
+
kind: i.literal("documentSections"),
|
|
927
|
+
sheetId: i.string(),
|
|
928
|
+
sectionIds: i.array(i.string())
|
|
929
|
+
}).strict()
|
|
930
|
+
]), xe = i.union([
|
|
931
|
+
i.object({
|
|
932
|
+
kind: i.literal("bound"),
|
|
933
|
+
cardId: i.string().min(1),
|
|
934
|
+
clickedFieldKey: i.string().min(1),
|
|
935
|
+
target: i.object({ kind: i.literal("field"), field: tt }).strict()
|
|
936
|
+
}).strict(),
|
|
937
|
+
i.object({ kind: i.literal("excluded"), cardId: i.string().min(1) }).strict()
|
|
938
|
+
]), Sn = i.object({
|
|
939
|
+
enabled: i.boolean(),
|
|
940
|
+
fields: i.union([
|
|
941
|
+
i.object({ kind: i.literal("wholeRow") }).strict(),
|
|
942
|
+
i.object({ kind: i.literal("clickedCell") }).strict(),
|
|
943
|
+
i.object({
|
|
944
|
+
kind: i.literal("chosenColumns"),
|
|
945
|
+
clickedFieldKeys: i.array(i.string().min(1))
|
|
946
|
+
}).strict()
|
|
947
|
+
]),
|
|
948
|
+
multipleSelection: i.boolean(),
|
|
949
|
+
selectionCheckboxes: i.enum(["auto", "always", "never"]),
|
|
950
|
+
matrixSources: i.object({
|
|
951
|
+
rowMembers: i.boolean(),
|
|
952
|
+
columnMembers: i.boolean(),
|
|
953
|
+
cells: i.boolean()
|
|
954
|
+
}).strict().optional(),
|
|
955
|
+
targets: $e,
|
|
956
|
+
cardMappings: i.array(xe)
|
|
957
|
+
}).strict(), Ln = i.boolean(), Vn = i.object({
|
|
958
|
+
targets: $e.nullable().optional(),
|
|
959
|
+
cardMappings: i.array(xe).nullable().optional()
|
|
960
|
+
}).strict(), xt = [
|
|
961
|
+
"bar",
|
|
962
|
+
"horizontalBar",
|
|
963
|
+
"line",
|
|
964
|
+
"area",
|
|
965
|
+
"stackedArea",
|
|
966
|
+
"combo",
|
|
967
|
+
"stackedBar",
|
|
968
|
+
"stackedLine"
|
|
969
|
+
], St = new Set(
|
|
970
|
+
xt
|
|
971
|
+
);
|
|
972
|
+
function Lt(e) {
|
|
973
|
+
return typeof e == "string" && St.has(e);
|
|
974
|
+
}
|
|
975
|
+
function Bn(e) {
|
|
976
|
+
return e === "detailTable" || e === "table" || e === "aggregateTable" || e === "pivotTable" || e === "custom" || Lt(e);
|
|
977
|
+
}
|
|
978
|
+
function be(e) {
|
|
979
|
+
return !!(e != null && e.trim());
|
|
980
|
+
}
|
|
981
|
+
function jn(e) {
|
|
982
|
+
return be(e.sql) || be(e.normalizedPython) ? "freeform" : e.hasExecutableConfig ? "config" : "none";
|
|
983
|
+
}
|
|
984
|
+
const q = {
|
|
985
|
+
type: "temporal_bucket",
|
|
986
|
+
presentation: { mode: "auto" }
|
|
987
|
+
}, N = {
|
|
988
|
+
value: "auto",
|
|
989
|
+
label: "Automatic",
|
|
990
|
+
format: q
|
|
991
|
+
};
|
|
992
|
+
function b(e, t) {
|
|
993
|
+
return {
|
|
994
|
+
value: `pattern:${e}`,
|
|
995
|
+
label: t,
|
|
996
|
+
format: {
|
|
997
|
+
type: "temporal_bucket",
|
|
998
|
+
presentation: { mode: "pattern", pattern: e }
|
|
999
|
+
}
|
|
1000
|
+
};
|
|
1001
|
+
}
|
|
1002
|
+
function x(e, t) {
|
|
1003
|
+
return {
|
|
1004
|
+
value: `preset:${e}`,
|
|
1005
|
+
label: t,
|
|
1006
|
+
format: {
|
|
1007
|
+
type: "temporal_bucket",
|
|
1008
|
+
presentation: { mode: "preset", preset: e }
|
|
1009
|
+
}
|
|
1010
|
+
};
|
|
1011
|
+
}
|
|
1012
|
+
function Y(e) {
|
|
1013
|
+
return {
|
|
1014
|
+
...b(e, "Custom format…"),
|
|
1015
|
+
value: "custom",
|
|
1016
|
+
custom: !0
|
|
1017
|
+
};
|
|
1018
|
+
}
|
|
1019
|
+
const ne = {
|
|
1020
|
+
second: [
|
|
1021
|
+
N,
|
|
1022
|
+
b("HH:mm:ss", "14:30:45 (HH:mm:ss)"),
|
|
1023
|
+
b(
|
|
1024
|
+
"YYYY-MM-DD HH:mm:ss",
|
|
1025
|
+
"2024-01-15 14:30:45 (YYYY-MM-DD HH:mm:ss)"
|
|
1026
|
+
),
|
|
1027
|
+
Y("DD/MM/YYYY HH:mm:ss")
|
|
1028
|
+
],
|
|
1029
|
+
minute: [
|
|
1030
|
+
N,
|
|
1031
|
+
b("HH:mm", "14:30 (HH:mm)"),
|
|
1032
|
+
b("YYYY-MM-DD HH:mm", "2024-01-15 14:30 (YYYY-MM-DD HH:mm)"),
|
|
1033
|
+
Y("DD/MM/YYYY HH:mm")
|
|
1034
|
+
],
|
|
1035
|
+
hour: [
|
|
1036
|
+
N,
|
|
1037
|
+
b("HH", "14 (HH)"),
|
|
1038
|
+
b("YYYY-MM-DD HH", "2024-01-15 14 (YYYY-MM-DD HH)"),
|
|
1039
|
+
Y("DD/MM/YYYY HH")
|
|
1040
|
+
],
|
|
1041
|
+
day: [
|
|
1042
|
+
N,
|
|
1043
|
+
b("YYYY-MM-DD", "2024-01-15 (YYYY-MM-DD)"),
|
|
1044
|
+
b("MM/DD/YYYY", "01/15/2024 (MM/DD/YYYY)"),
|
|
1045
|
+
b("DD/MM/YYYY", "15/01/2024 (DD/MM/YYYY)"),
|
|
1046
|
+
b("MMM DD, YYYY", "Jan 15, 2024 (MMM DD, YYYY)"),
|
|
1047
|
+
b("MMMM DD, YYYY", "January 15, 2024 (MMMM DD, YYYY)"),
|
|
1048
|
+
Y("YYYY/MM/DD")
|
|
1049
|
+
],
|
|
1050
|
+
week: [
|
|
1051
|
+
N,
|
|
1052
|
+
x("week_of_short", "Week of Jan 15, 2024"),
|
|
1053
|
+
x("week_of_long", "Week of January 15, 2024"),
|
|
1054
|
+
b("YYYY-MM-DD", "2024-01-15 (YYYY-MM-DD)"),
|
|
1055
|
+
Y("YYYY/MM/DD")
|
|
1056
|
+
],
|
|
1057
|
+
month: [
|
|
1058
|
+
N,
|
|
1059
|
+
b("MMM YYYY", "Jan 2024 (MMM YYYY)"),
|
|
1060
|
+
b("MMMM YYYY", "January 2024 (MMMM YYYY)"),
|
|
1061
|
+
b("YYYY-MM", "2024-01 (YYYY-MM)"),
|
|
1062
|
+
b("MM/YYYY", "01/2024 (MM/YYYY)"),
|
|
1063
|
+
b("YYYY MMM", "2024 Jan (YYYY MMM)"),
|
|
1064
|
+
Y("YYYY/MM")
|
|
1065
|
+
],
|
|
1066
|
+
quarter: [
|
|
1067
|
+
N,
|
|
1068
|
+
x("quarter_short", "Q1 2024"),
|
|
1069
|
+
x("quarter_long", "1st Quarter 2024")
|
|
1070
|
+
],
|
|
1071
|
+
year: [
|
|
1072
|
+
N,
|
|
1073
|
+
b("YYYY", "2024 (YYYY)"),
|
|
1074
|
+
b("YY", "24 (YY)")
|
|
1075
|
+
]
|
|
1076
|
+
}, Vt = {
|
|
1077
|
+
second: "2026-07-31T14:05:09",
|
|
1078
|
+
minute: "2026-07-31T14:05:00",
|
|
1079
|
+
hour: "2026-07-31T14:00:00",
|
|
1080
|
+
day: "2026-07-31",
|
|
1081
|
+
week: "2026-07-27",
|
|
1082
|
+
month: "2026-07-01",
|
|
1083
|
+
quarter: "2026-07-01",
|
|
1084
|
+
year: "2026-01-01"
|
|
1085
|
+
};
|
|
1086
|
+
function Bt(e, t, n = Oe) {
|
|
1087
|
+
return pt({
|
|
1088
|
+
value: Vt[t],
|
|
1089
|
+
metadata: {
|
|
1090
|
+
kind: "temporal_bucket",
|
|
1091
|
+
granularity: t,
|
|
1092
|
+
calendar: {
|
|
1093
|
+
tz: "UTC",
|
|
1094
|
+
weekStart: 1,
|
|
1095
|
+
...e.presentation.mode === "preset" && (e.presentation.preset === "fiscal_quarter_short" || e.presentation.preset === "fiscal_year") ? {
|
|
1096
|
+
fiscalCalendar: {
|
|
1097
|
+
kind: "month_aligned",
|
|
1098
|
+
yearStartMonth: 7
|
|
1099
|
+
}
|
|
1100
|
+
} : {}
|
|
1101
|
+
}
|
|
1102
|
+
},
|
|
1103
|
+
format: e.presentation.mode === "auto" ? {
|
|
1104
|
+
type: "temporal_bucket",
|
|
1105
|
+
locale: n.locale,
|
|
1106
|
+
presentation: {
|
|
1107
|
+
mode: "auto",
|
|
1108
|
+
styles: {
|
|
1109
|
+
dateStyle: n.dateStyle,
|
|
1110
|
+
dateTime: { ...n.dateTime }
|
|
1111
|
+
}
|
|
1112
|
+
}
|
|
1113
|
+
} : {
|
|
1114
|
+
type: "temporal_bucket",
|
|
1115
|
+
locale: n.locale,
|
|
1116
|
+
presentation: e.presentation
|
|
1117
|
+
}
|
|
1118
|
+
});
|
|
1119
|
+
}
|
|
1120
|
+
function qn(e, t, n = Oe) {
|
|
1121
|
+
const o = ne[e], r = (t == null ? void 0 : t.presentation.mode) === "preset" ? t.presentation.preset : void 0, l = r && t && $(t, e).ok && !o.some(
|
|
1122
|
+
(s) => {
|
|
1123
|
+
var c;
|
|
1124
|
+
return ((c = s.format) == null ? void 0 : c.presentation.mode) === "preset" && s.format.presentation.preset === r;
|
|
1125
|
+
}
|
|
1126
|
+
) ? x(r, r) : void 0;
|
|
1127
|
+
return (l ? [...o, l] : o).map((s) => {
|
|
1128
|
+
if (!s.format || s.custom) return s;
|
|
1129
|
+
const c = Bt(
|
|
1130
|
+
s.format,
|
|
1131
|
+
e,
|
|
1132
|
+
n
|
|
1133
|
+
);
|
|
1134
|
+
return s.format.presentation.mode === "pattern" ? {
|
|
1135
|
+
...s,
|
|
1136
|
+
label: `${c} (${s.format.presentation.pattern})`
|
|
1137
|
+
} : s.format.presentation.mode === "auto" ? { ...s, label: `Automatic (${c})` } : { ...s, label: c };
|
|
1138
|
+
});
|
|
1139
|
+
}
|
|
1140
|
+
function Gn(e, t) {
|
|
1141
|
+
const n = ne[t];
|
|
1142
|
+
if (e.presentation.mode === "pattern") {
|
|
1143
|
+
const o = e.presentation.pattern, r = n.find(
|
|
1144
|
+
(l) => {
|
|
1145
|
+
var a;
|
|
1146
|
+
return ((a = l.format) == null ? void 0 : a.presentation.mode) === "pattern" && l.format.presentation.pattern === o;
|
|
1147
|
+
}
|
|
1148
|
+
);
|
|
1149
|
+
return {
|
|
1150
|
+
value: (r == null ? void 0 : r.value) ?? "custom",
|
|
1151
|
+
customPattern: r != null && r.custom || !r ? o : "",
|
|
1152
|
+
format: e
|
|
1153
|
+
};
|
|
1154
|
+
}
|
|
1155
|
+
if (e.presentation.mode === "preset") {
|
|
1156
|
+
const o = e.presentation.preset, r = n.find(
|
|
1157
|
+
(a) => {
|
|
1158
|
+
var s;
|
|
1159
|
+
return ((s = a.format) == null ? void 0 : s.presentation.mode) === "preset" && a.format.presentation.preset === o;
|
|
1160
|
+
}
|
|
1161
|
+
), l = $(
|
|
1162
|
+
e,
|
|
1163
|
+
t
|
|
1164
|
+
).ok;
|
|
1165
|
+
return r ? { value: r.value, customPattern: "", format: e } : l ? {
|
|
1166
|
+
value: `preset:${o}`,
|
|
1167
|
+
customPattern: "",
|
|
1168
|
+
format: e
|
|
1169
|
+
} : { value: "auto", customPattern: "", format: q };
|
|
1170
|
+
}
|
|
1171
|
+
return { value: "auto", customPattern: "", format: e };
|
|
1172
|
+
}
|
|
1173
|
+
function Un(e, t, n = "") {
|
|
1174
|
+
var a;
|
|
1175
|
+
const o = ne[e].find(
|
|
1176
|
+
(s) => s.value === t
|
|
1177
|
+
), r = t.startsWith("preset:") ? t.slice(7) : void 0, l = t === "custom" ? {
|
|
1178
|
+
type: "temporal_bucket",
|
|
1179
|
+
presentation: {
|
|
1180
|
+
mode: "pattern",
|
|
1181
|
+
pattern: n.trim() || (((a = o == null ? void 0 : o.format) == null ? void 0 : a.presentation.mode) === "pattern" ? o.format.presentation.pattern : "")
|
|
1182
|
+
}
|
|
1183
|
+
} : (o == null ? void 0 : o.format) ?? (r && mt(r) ? {
|
|
1184
|
+
type: "temporal_bucket",
|
|
1185
|
+
presentation: {
|
|
1186
|
+
mode: "preset",
|
|
1187
|
+
preset: r
|
|
1188
|
+
}
|
|
1189
|
+
} : void 0);
|
|
1190
|
+
return !l || !$(l, e).ok ? q : l;
|
|
1191
|
+
}
|
|
1192
|
+
function Hn(e, t) {
|
|
1193
|
+
return $(e, t).ok ? e : q;
|
|
1194
|
+
}
|
|
1195
|
+
function Ie(e, t, n = (o) => {
|
|
1196
|
+
var r;
|
|
1197
|
+
return ((r = o.derivedField) == null ? void 0 : r.dataType) ?? o.dataType;
|
|
1198
|
+
}) {
|
|
1199
|
+
return t === "sql_param" || t === "presentation_currency" ? [] : t === "config_metric_selector" || t === "config_aggregation" ? e.measures.flatMap((o) => o.kind === "aggregate" ? [{ id: o.id, kind: "measure", measure: o }] : []) : ["rows", "columns"].flatMap((o) => e[o].filter((r) => t !== "config_grain" || Xe(n(r.field))).map((r) => ({ id: r.id, kind: "level", axis: o, level: r })));
|
|
1200
|
+
}
|
|
1201
|
+
function zn(e, t, n, o) {
|
|
1202
|
+
const r = [...e.rows, ...e.columns].find((d) => d.id === t);
|
|
1203
|
+
if (!r) throw new Error("Matrix level is no longer present.");
|
|
1204
|
+
if (o === t) return { kind: "structure", rows: e.rows, columns: e.columns };
|
|
1205
|
+
const l = e.rows.filter((d) => d.id !== t), a = e.columns.filter((d) => d.id !== t), s = n === "rows" ? l : a, c = o ? s.findIndex((d) => d.id === o) : -1;
|
|
1206
|
+
return s.splice(c < 0 ? s.length : c, 0, r), { kind: "structure", rows: l, columns: a };
|
|
1207
|
+
}
|
|
1208
|
+
function oe(e, t) {
|
|
1209
|
+
const n = de(e), o = de(t), r = (s, c) => L(n[s][c]) === L(o[s][c]), l = (s) => {
|
|
1210
|
+
const c = n.rankings.find((m) => m.id === s), d = o.rankings.find((m) => m.id === s);
|
|
1211
|
+
return !!c && !!d && L(c) === L(d);
|
|
1212
|
+
};
|
|
1213
|
+
return (s, c, d = !1) => c.length <= t[s].length && c.every(
|
|
1214
|
+
(m, p) => {
|
|
1215
|
+
var g;
|
|
1216
|
+
return (m.member.kind === "value" || d && l(m.member.rankingId)) && m.levelId === ((g = t[s][p]) == null ? void 0 : g.id) && r(s, p);
|
|
1217
|
+
}
|
|
1218
|
+
);
|
|
1219
|
+
}
|
|
1220
|
+
function _e(e, t, n, o) {
|
|
1221
|
+
if (!n) return n;
|
|
1222
|
+
const r = oe(e, t), l = new Set(t.measures.map((a) => a.id));
|
|
1223
|
+
return { ...n, rules: n.rules.filter((a) => {
|
|
1224
|
+
const s = a.target.matrix, c = !s || (s.levelId === void 0 || t[s.axis].some((m) => m.id === s.levelId)) && (s.oppositePath === void 0 || r(s.axis === "rows" ? "columns" : "rows", s.oppositePath, !0)), { validationRefs: d } = Ze(a);
|
|
1225
|
+
return c && d.every((m) => l.has(m)) ? !0 : (o.push({ kind: "conditional_format", id: a.id, message: "Removed a conditional rule whose measure, level or member path changed." }), !1);
|
|
1226
|
+
}) };
|
|
1227
|
+
}
|
|
1228
|
+
function jt(e, t, n = !1) {
|
|
1229
|
+
const o = { ...t }, r = [], l = oe(e, o), a = new Set(o.measures.map((c) => c.id)), s = (c, d, m) => r.push({ kind: c, id: d, message: m });
|
|
1230
|
+
return o.sorts = o.sorts.filter((c) => {
|
|
1231
|
+
const d = o[c.axis].findIndex(
|
|
1232
|
+
(p) => p.id === c.levelId
|
|
1233
|
+
), m = d >= 0 && (c.scope.kind === "level" || c.scope.parent.length === d && l(c.axis, c.scope.parent)) && (c.target.kind === "member" || a.has(c.target.measureId) && l(
|
|
1234
|
+
c.axis === "rows" ? "columns" : "rows",
|
|
1235
|
+
c.target.oppositePath
|
|
1236
|
+
));
|
|
1237
|
+
return m || s(
|
|
1238
|
+
"sort",
|
|
1239
|
+
c.levelId,
|
|
1240
|
+
"Removed a sort whose level, measure or member path changed."
|
|
1241
|
+
), m;
|
|
1242
|
+
}), o.rankings = o.rankings.filter((c) => {
|
|
1243
|
+
const d = o[c.axis].some((m) => m.id === c.levelId) && a.has(c.measureId) && l(
|
|
1244
|
+
c.axis === "rows" ? "columns" : "rows",
|
|
1245
|
+
c.oppositePath
|
|
1246
|
+
);
|
|
1247
|
+
return d || s(
|
|
1248
|
+
"ranking",
|
|
1249
|
+
c.id,
|
|
1250
|
+
"Removed a ranking whose level, measure or member path changed."
|
|
1251
|
+
), d;
|
|
1252
|
+
}), { spec: (n ? Qe : We).parse(o), notices: r };
|
|
1253
|
+
}
|
|
1254
|
+
function Jn(e, t, n = [], o, r = !1) {
|
|
1255
|
+
const l = [];
|
|
1256
|
+
if (t.kind !== "structure") {
|
|
1257
|
+
const u = t.kind === "presentation" ? { ...e, presentation: t.presentation } : t.kind === "defaults" ? { ...e, defaultView: t.defaultView } : t.kind === "sorts" ? { ...e, spec: { ...e.spec, sorts: t.sorts } } : {
|
|
1258
|
+
...e,
|
|
1259
|
+
spec: { ...e.spec, rankings: t.rankings }
|
|
1260
|
+
};
|
|
1261
|
+
return t.kind === "rankings" && u.presentation.conditionalFormatting && (u.presentation = { ...u.presentation, conditionalFormatting: _e(e.spec, u.spec, u.presentation.conditionalFormatting, l) }), {
|
|
1262
|
+
config: (r ? ae : le).parse(u),
|
|
1263
|
+
notices: l,
|
|
1264
|
+
removedBindings: [],
|
|
1265
|
+
bindings: n
|
|
1266
|
+
};
|
|
1267
|
+
}
|
|
1268
|
+
const a = jt(e.spec, {
|
|
1269
|
+
...e.spec,
|
|
1270
|
+
rows: t.rows ?? e.spec.rows,
|
|
1271
|
+
columns: t.columns ?? e.spec.columns,
|
|
1272
|
+
measures: t.measures ?? e.spec.measures
|
|
1273
|
+
}, r), s = a.spec;
|
|
1274
|
+
l.push(...a.notices);
|
|
1275
|
+
const c = oe(e.spec, s), d = new Set(s.measures.map((u) => u.id)), m = [...s.rows, ...s.columns], p = new Set(m.map((u) => u.id)), g = (u, D, v) => l.push({ kind: u, id: D, message: v }), f = [], _ = n.flatMap((u) => {
|
|
1276
|
+
if (u.target === "sql_param" || u.target === "presentation_currency") return [u];
|
|
1277
|
+
const D = Ie(e.spec, u.target, o), v = u.matrixTargetId ?? (D.length === 1 ? D[0].id : void 0);
|
|
1278
|
+
return Ie(s, u.target, o).some((E) => E.id === v) ? u.matrixTargetId ? [u] : (g("binding", u.controlId, "Pinned the control binding to its original Matrix target after a structural change."), [{ ...u, matrixTargetId: v }]) : (g(
|
|
1279
|
+
"binding",
|
|
1280
|
+
u.controlId,
|
|
1281
|
+
"Removed a control binding whose original Matrix target is missing, ambiguous or no longer eligible."
|
|
1282
|
+
), f.push(u), []);
|
|
1283
|
+
}), I = (u, D, v) => Object.fromEntries(
|
|
1284
|
+
Object.entries(u).filter(([M]) => D.has(M) ? !0 : (g(v, M, `Removed a ${v} override for a removed field.`), !1))
|
|
1285
|
+
), C = {
|
|
1286
|
+
...e.presentation,
|
|
1287
|
+
levelLabels: I(e.presentation.levelLabels, p, "label"),
|
|
1288
|
+
measureLabels: I(
|
|
1289
|
+
e.presentation.measureLabels,
|
|
1290
|
+
d,
|
|
1291
|
+
"label"
|
|
1292
|
+
),
|
|
1293
|
+
levelFormats: I(
|
|
1294
|
+
e.presentation.levelFormats,
|
|
1295
|
+
p,
|
|
1296
|
+
"format"
|
|
1297
|
+
),
|
|
1298
|
+
measureFormats: I(
|
|
1299
|
+
e.presentation.measureFormats,
|
|
1300
|
+
d,
|
|
1301
|
+
"format"
|
|
1302
|
+
),
|
|
1303
|
+
totals: { ...e.presentation.totals }
|
|
1304
|
+
};
|
|
1305
|
+
C.levelFormats = Object.fromEntries(
|
|
1306
|
+
Object.entries(C.levelFormats).filter(([u, D]) => {
|
|
1307
|
+
const v = m.find((E) => E.id === u), M = [...e.spec.rows, ...e.spec.columns].find(
|
|
1308
|
+
(E) => E.id === u
|
|
1309
|
+
);
|
|
1310
|
+
return D.type !== "temporal_bucket" || v.grain && v.grain === (M == null ? void 0 : M.grain) ? !0 : (g(
|
|
1311
|
+
"format",
|
|
1312
|
+
u,
|
|
1313
|
+
"Removed a temporal format because its grain changed."
|
|
1314
|
+
), !1);
|
|
1315
|
+
})
|
|
1316
|
+
), C.conditionalFormatting && (C.conditionalFormatting = _e(e.spec, s, C.conditionalFormatting, l));
|
|
1317
|
+
const k = { ...e.defaultView };
|
|
1318
|
+
for (const u of ["rows", "columns"]) {
|
|
1319
|
+
const D = {
|
|
1320
|
+
...e.presentation.totals.rows.levels,
|
|
1321
|
+
...e.presentation.totals.columns.levels
|
|
1322
|
+
};
|
|
1323
|
+
for (const E of Object.keys(e.presentation.totals[u].levels))
|
|
1324
|
+
p.has(E) || g("total", E, "Removed subtotal settings for a removed level.");
|
|
1325
|
+
C.totals[u] = {
|
|
1326
|
+
...e.presentation.totals[u],
|
|
1327
|
+
levels: Object.fromEntries(
|
|
1328
|
+
s[u].map((E) => [
|
|
1329
|
+
E.id,
|
|
1330
|
+
D[E.id] ?? { visible: !0, position: "before" }
|
|
1331
|
+
])
|
|
1332
|
+
)
|
|
1333
|
+
};
|
|
1334
|
+
const v = e.defaultView[u], M = Math.min(v.depth, Math.max(0, s[u].length - 1));
|
|
1335
|
+
M !== v.depth && g(
|
|
1336
|
+
"depth",
|
|
1337
|
+
u,
|
|
1338
|
+
`Reduced ${u} expansion depth to fit the hierarchy.`
|
|
1339
|
+
), k[u] = {
|
|
1340
|
+
depth: M,
|
|
1341
|
+
overrides: v.overrides.filter((E) => E.path.length < s[u].length && c(u, E.path) ? !0 : (g(
|
|
1342
|
+
"expansion",
|
|
1343
|
+
u,
|
|
1344
|
+
`Removed a ${u} expansion override whose path changed or became a leaf.`
|
|
1345
|
+
), !1))
|
|
1346
|
+
};
|
|
1347
|
+
}
|
|
1348
|
+
return {
|
|
1349
|
+
config: (r ? ae : le).parse({
|
|
1350
|
+
...e,
|
|
1351
|
+
spec: s,
|
|
1352
|
+
presentation: C,
|
|
1353
|
+
defaultView: k
|
|
1354
|
+
}),
|
|
1355
|
+
notices: l,
|
|
1356
|
+
removedBindings: f,
|
|
1357
|
+
bindings: _
|
|
1358
|
+
};
|
|
1359
|
+
}
|
|
1360
|
+
const Se = [
|
|
1361
|
+
{ value: "COUNT", label: "Count" },
|
|
1362
|
+
{ value: "DISTINCT", label: "Count Distinct" }
|
|
1363
|
+
], qt = [
|
|
1364
|
+
...Se,
|
|
1365
|
+
{ value: "SUM", label: "Sum" },
|
|
1366
|
+
{ value: "AVG", label: "Average" },
|
|
1367
|
+
{ value: "MIN", label: "Min" },
|
|
1368
|
+
{ value: "MAX", label: "Max" },
|
|
1369
|
+
{ value: "MEDIAN", label: "Median" }
|
|
1370
|
+
];
|
|
1371
|
+
function Kn(e) {
|
|
1372
|
+
return Me(e) === "number" ? qt : Se;
|
|
1373
|
+
}
|
|
1374
|
+
function Zn(e, t) {
|
|
1375
|
+
return `${e}-${t}`;
|
|
1376
|
+
}
|
|
1377
|
+
const Qn = "CONTROL_PLACEHOLDER_QUOTED", Gt = "CONTROL_REFERENCE_MISSING", Ut = "CONTROL_VALUE_MISSING", Wn = "CONTROL_VALUE_INVALID", Xn = "CONTROL_CONTEXT_UNSUPPORTED", Ht = "CONTROL_DEFINITION_DUPLICATE", zt = "CONTROL_DEFINITION_INVALID", re = "CONTROL_BINDING_MAPPING_MISSING", eo = "CONTROL_BINDING_TARGET_INVALID", Ce = "CONTROL_BINDING_VALUE_INVALID";
|
|
1378
|
+
class w extends Error {
|
|
1379
|
+
constructor(n, o) {
|
|
1380
|
+
super(n);
|
|
1381
|
+
U(this, "status", 400);
|
|
1382
|
+
U(this, "details");
|
|
1383
|
+
Object.setPrototypeOf(this, w.prototype), this.name = "ControlResolutionError", this.details = o;
|
|
1384
|
+
}
|
|
1385
|
+
}
|
|
1386
|
+
function to(e, t) {
|
|
1387
|
+
const n = /* @__PURE__ */ new Map();
|
|
1388
|
+
for (const o of [...e, ...t]) {
|
|
1389
|
+
if (!o || typeof o != "object" || typeof o.id != "string" || o.id.trim().length === 0)
|
|
1390
|
+
throw new w(
|
|
1391
|
+
"Malformed control definition was provided for query execution.",
|
|
1392
|
+
{
|
|
1393
|
+
code: zt
|
|
1394
|
+
}
|
|
1395
|
+
);
|
|
1396
|
+
if (n.get(o.id))
|
|
1397
|
+
throw new w(
|
|
1398
|
+
`Duplicate control definition '${o.id}' was provided for query execution.`,
|
|
1399
|
+
{
|
|
1400
|
+
code: Ht,
|
|
1401
|
+
controlId: o.id
|
|
1402
|
+
}
|
|
1403
|
+
);
|
|
1404
|
+
n.set(o.id, o);
|
|
1405
|
+
}
|
|
1406
|
+
return n;
|
|
1407
|
+
}
|
|
1408
|
+
const Jt = /^-?(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?$/;
|
|
1409
|
+
function Kt(e) {
|
|
1410
|
+
switch (e.source.kind) {
|
|
1411
|
+
case "manual":
|
|
1412
|
+
return e.source.options.map((t) => t.value);
|
|
1413
|
+
case "field_allowlist":
|
|
1414
|
+
return e.source.fieldIds;
|
|
1415
|
+
case "metric_allowlist":
|
|
1416
|
+
return e.source.metricIds;
|
|
1417
|
+
case "dataset_values":
|
|
1418
|
+
return null;
|
|
1419
|
+
default:
|
|
1420
|
+
return null;
|
|
1421
|
+
}
|
|
1422
|
+
}
|
|
1423
|
+
function T(e) {
|
|
1424
|
+
return `${e.label || e.id} (${e.id})`;
|
|
1425
|
+
}
|
|
1426
|
+
function Zt(e) {
|
|
1427
|
+
return e.type === "field_selector" || e.type === "metric_selector" || e.type === "aggregation_selector" || e.type === "grain_selector";
|
|
1428
|
+
}
|
|
1429
|
+
function ve(e, t) {
|
|
1430
|
+
const n = Kt(e);
|
|
1431
|
+
if (!(!n || n.length === 0) && !n.includes(t))
|
|
1432
|
+
throw new Error(
|
|
1433
|
+
`Control ${T(e)} received unsupported value '${t}'.`
|
|
1434
|
+
);
|
|
1435
|
+
}
|
|
1436
|
+
function ie(e, t) {
|
|
1437
|
+
switch (e.type) {
|
|
1438
|
+
case "enum":
|
|
1439
|
+
case "field_selector":
|
|
1440
|
+
case "metric_selector":
|
|
1441
|
+
case "aggregation_selector":
|
|
1442
|
+
case "grain_selector": {
|
|
1443
|
+
if (typeof t != "string" || t.trim().length === 0)
|
|
1444
|
+
throw new Error(
|
|
1445
|
+
`Control ${T(e)} requires a non-empty string value.`
|
|
1446
|
+
);
|
|
1447
|
+
return Zt(e) && t === lt || ve(e, t), t;
|
|
1448
|
+
}
|
|
1449
|
+
case "multi_enum": {
|
|
1450
|
+
if (!Array.isArray(t))
|
|
1451
|
+
throw new Error(
|
|
1452
|
+
`Control ${T(e)} requires a non-empty array value.`
|
|
1453
|
+
);
|
|
1454
|
+
if (t.length === 0) {
|
|
1455
|
+
if (!e.requiredAtExecution)
|
|
1456
|
+
return;
|
|
1457
|
+
throw new Error(
|
|
1458
|
+
`Control ${T(e)} requires a non-empty array value.`
|
|
1459
|
+
);
|
|
1460
|
+
}
|
|
1461
|
+
for (const n of t) {
|
|
1462
|
+
if (typeof n != "string" || n.trim().length === 0)
|
|
1463
|
+
throw new Error(
|
|
1464
|
+
`Control ${T(e)} requires string array values.`
|
|
1465
|
+
);
|
|
1466
|
+
ve(e, n);
|
|
1467
|
+
}
|
|
1468
|
+
return t;
|
|
1469
|
+
}
|
|
1470
|
+
case "text": {
|
|
1471
|
+
if (typeof t != "string")
|
|
1472
|
+
throw new Error(
|
|
1473
|
+
`Control ${T(e)} requires a string value.`
|
|
1474
|
+
);
|
|
1475
|
+
return t;
|
|
1476
|
+
}
|
|
1477
|
+
case "number": {
|
|
1478
|
+
if (typeof t == "number" && Number.isFinite(t))
|
|
1479
|
+
return t;
|
|
1480
|
+
if (typeof t == "string" && Jt.test(t.trim()))
|
|
1481
|
+
return Number(t);
|
|
1482
|
+
throw new Error(
|
|
1483
|
+
`Control ${T(e)} requires a numeric value.`
|
|
1484
|
+
);
|
|
1485
|
+
}
|
|
1486
|
+
case "boolean": {
|
|
1487
|
+
if (typeof t != "boolean")
|
|
1488
|
+
throw new Error(
|
|
1489
|
+
`Control ${T(e)} requires a boolean value.`
|
|
1490
|
+
);
|
|
1491
|
+
return t;
|
|
1492
|
+
}
|
|
1493
|
+
case "date": {
|
|
1494
|
+
if (t instanceof Date && !Number.isNaN(t.getTime()))
|
|
1495
|
+
return t;
|
|
1496
|
+
if (typeof t == "string" && t.trim().length > 0) {
|
|
1497
|
+
const n = t.trim(), o = ut(n);
|
|
1498
|
+
if (!Number.isNaN(o.getTime()))
|
|
1499
|
+
return n;
|
|
1500
|
+
}
|
|
1501
|
+
throw new Error(
|
|
1502
|
+
`Control ${T(e)} requires a date-compatible value.`
|
|
1503
|
+
);
|
|
1504
|
+
}
|
|
1505
|
+
default:
|
|
1506
|
+
return t;
|
|
1507
|
+
}
|
|
1508
|
+
}
|
|
1509
|
+
function no(e) {
|
|
1510
|
+
var r;
|
|
1511
|
+
const t = e.definitions.get(e.binding.controlId);
|
|
1512
|
+
if (!t)
|
|
1513
|
+
throw new w(
|
|
1514
|
+
`Binding references unknown control '${e.binding.controlId}'.`,
|
|
1515
|
+
{
|
|
1516
|
+
code: Gt,
|
|
1517
|
+
controlId: e.binding.controlId
|
|
1518
|
+
}
|
|
1519
|
+
);
|
|
1520
|
+
if (!Object.prototype.hasOwnProperty.call(
|
|
1521
|
+
e.controlValues || {},
|
|
1522
|
+
e.binding.controlId
|
|
1523
|
+
)) {
|
|
1524
|
+
if (!t.requiredAtExecution)
|
|
1525
|
+
return;
|
|
1526
|
+
throw new w(
|
|
1527
|
+
`Control '${e.binding.controlId}' must resolve to a concrete value before query execution.`,
|
|
1528
|
+
{
|
|
1529
|
+
code: Ut,
|
|
1530
|
+
controlId: e.binding.controlId
|
|
1531
|
+
}
|
|
1532
|
+
);
|
|
1533
|
+
}
|
|
1534
|
+
let o;
|
|
1535
|
+
try {
|
|
1536
|
+
o = ie(
|
|
1537
|
+
t,
|
|
1538
|
+
(r = e.controlValues) == null ? void 0 : r[e.binding.controlId]
|
|
1539
|
+
);
|
|
1540
|
+
} catch (l) {
|
|
1541
|
+
const a = l instanceof Error ? l.message : String(l);
|
|
1542
|
+
throw new w(a, {
|
|
1543
|
+
code: Ce,
|
|
1544
|
+
controlId: e.binding.controlId
|
|
1545
|
+
});
|
|
1546
|
+
}
|
|
1547
|
+
if (typeof o == "string" && o.trim().length > 0)
|
|
1548
|
+
return o;
|
|
1549
|
+
if (typeof o == "number" || typeof o == "boolean")
|
|
1550
|
+
return String(o);
|
|
1551
|
+
if (o instanceof Date && !Number.isNaN(o.getTime()))
|
|
1552
|
+
return o.toISOString();
|
|
1553
|
+
throw new w(
|
|
1554
|
+
`Binding control '${e.binding.controlId}' must resolve to a single scalar value.`,
|
|
1555
|
+
{
|
|
1556
|
+
code: Ce,
|
|
1557
|
+
controlId: e.binding.controlId
|
|
1558
|
+
}
|
|
1559
|
+
);
|
|
1560
|
+
}
|
|
1561
|
+
function oo(e) {
|
|
1562
|
+
const t = e.binding.mapping[e.selectedValue];
|
|
1563
|
+
if (typeof t == "string" && t.trim().length > 0)
|
|
1564
|
+
return t;
|
|
1565
|
+
throw new w(
|
|
1566
|
+
`Binding for control '${e.binding.controlId}' does not map value '${e.selectedValue}'.`,
|
|
1567
|
+
{
|
|
1568
|
+
code: re,
|
|
1569
|
+
controlId: e.binding.controlId
|
|
1570
|
+
}
|
|
1571
|
+
);
|
|
1572
|
+
}
|
|
1573
|
+
function ro(e) {
|
|
1574
|
+
const t = e.binding.mapping[e.selectedValue];
|
|
1575
|
+
if (t && typeof t == "object" && "role" in t && t.role === "groupby")
|
|
1576
|
+
return t;
|
|
1577
|
+
throw new w(
|
|
1578
|
+
`Binding for control '${e.binding.controlId}' does not map value '${e.selectedValue}' to a valid group-by field.`,
|
|
1579
|
+
{
|
|
1580
|
+
code: re,
|
|
1581
|
+
controlId: e.binding.controlId
|
|
1582
|
+
}
|
|
1583
|
+
);
|
|
1584
|
+
}
|
|
1585
|
+
function io(e) {
|
|
1586
|
+
const t = e.binding.mapping[e.selectedValue];
|
|
1587
|
+
if (t && typeof t == "object" && "role" in t && t.role === "metric")
|
|
1588
|
+
return t;
|
|
1589
|
+
throw new w(
|
|
1590
|
+
`Binding for control '${e.binding.controlId}' does not map value '${e.selectedValue}' to a valid metric field.`,
|
|
1591
|
+
{
|
|
1592
|
+
code: re,
|
|
1593
|
+
controlId: e.binding.controlId
|
|
1594
|
+
}
|
|
1595
|
+
);
|
|
1596
|
+
}
|
|
1597
|
+
function so(e) {
|
|
1598
|
+
return e.target === "presentation_currency";
|
|
1599
|
+
}
|
|
1600
|
+
function ao(e) {
|
|
1601
|
+
return e.target !== "sql_param" && e.target !== "presentation_currency";
|
|
1602
|
+
}
|
|
1603
|
+
const Qt = i.unknown().optional(), Le = i.object({
|
|
1604
|
+
id: i.string().trim().min(1),
|
|
1605
|
+
name: i.string().trim().min(1),
|
|
1606
|
+
label: i.string().trim().min(1),
|
|
1607
|
+
alias: i.string().trim().min(1).optional(),
|
|
1608
|
+
qualifiedFieldName: i.string().trim().min(1),
|
|
1609
|
+
dataType: i.string().trim().min(1),
|
|
1610
|
+
description: i.string().optional(),
|
|
1611
|
+
qualifiedEntityName: i.string().optional(),
|
|
1612
|
+
dateFormat: i.string().optional(),
|
|
1613
|
+
customFormat: i.string().optional(),
|
|
1614
|
+
granularity: i.enum(["day", "week", "month", "quarter", "year", "hour", "minute", "second"]).optional(),
|
|
1615
|
+
entityId: i.string().trim().min(1),
|
|
1616
|
+
entityName: i.string().trim().min(1),
|
|
1617
|
+
entityType: i.string().trim().min(1),
|
|
1618
|
+
source: et.optional(),
|
|
1619
|
+
expression: i.string().optional(),
|
|
1620
|
+
format: Qt
|
|
1621
|
+
}).passthrough(), Wt = Le.extend({
|
|
1622
|
+
role: i.literal("groupby")
|
|
1623
|
+
}), Xt = Le.extend({
|
|
1624
|
+
role: i.literal("metric"),
|
|
1625
|
+
aggregate: i.enum(["COUNT", "SUM", "AVG", "MIN", "MAX", "MEDIAN", "DISTINCT"]).optional()
|
|
1626
|
+
}), Ve = i.object({
|
|
1627
|
+
granularity: i.enum([
|
|
1628
|
+
"day",
|
|
1629
|
+
"week",
|
|
1630
|
+
"month",
|
|
1631
|
+
"quarter",
|
|
1632
|
+
"year",
|
|
1633
|
+
"hour",
|
|
1634
|
+
"minute",
|
|
1635
|
+
"second"
|
|
1636
|
+
]).optional(),
|
|
1637
|
+
format: Ne.optional(),
|
|
1638
|
+
dateFormat: i.string().optional(),
|
|
1639
|
+
customFormat: i.string().optional()
|
|
1640
|
+
}).strict().superRefine((e, t) => {
|
|
1641
|
+
if (!e.format) return;
|
|
1642
|
+
if (!e.granularity) {
|
|
1643
|
+
t.addIssue({
|
|
1644
|
+
code: i.ZodIssueCode.custom,
|
|
1645
|
+
path: ["granularity"],
|
|
1646
|
+
message: "granularity is required when format is provided"
|
|
1647
|
+
});
|
|
1648
|
+
return;
|
|
1649
|
+
}
|
|
1650
|
+
const n = $(
|
|
1651
|
+
e.format,
|
|
1652
|
+
e.granularity
|
|
1653
|
+
);
|
|
1654
|
+
n.ok || t.addIssue({
|
|
1655
|
+
code: i.ZodIssueCode.custom,
|
|
1656
|
+
path: ["format"],
|
|
1657
|
+
message: n.message
|
|
1658
|
+
});
|
|
1659
|
+
});
|
|
1660
|
+
function lo(e) {
|
|
1661
|
+
return e === void 0 || Ve.safeParse(e).success;
|
|
1662
|
+
}
|
|
1663
|
+
const en = i.object({
|
|
1664
|
+
value: i.string().trim().min(1),
|
|
1665
|
+
label: i.string().trim().min(1),
|
|
1666
|
+
presentation: Ve.optional()
|
|
1667
|
+
}).strict(), tn = i.discriminatedUnion("kind", [
|
|
1668
|
+
i.object({
|
|
1669
|
+
kind: i.literal("manual"),
|
|
1670
|
+
options: i.array(en).min(1)
|
|
1671
|
+
}).strict(),
|
|
1672
|
+
i.object({
|
|
1673
|
+
kind: i.literal("dataset_values"),
|
|
1674
|
+
fieldId: i.string().trim().min(1),
|
|
1675
|
+
connectionId: i.string().trim().min(1).optional()
|
|
1676
|
+
}).strict(),
|
|
1677
|
+
i.object({
|
|
1678
|
+
kind: i.literal("field_allowlist"),
|
|
1679
|
+
fieldIds: i.array(i.string().trim().min(1))
|
|
1680
|
+
}).strict(),
|
|
1681
|
+
i.object({
|
|
1682
|
+
kind: i.literal("metric_allowlist"),
|
|
1683
|
+
metricIds: i.array(i.string().trim().min(1))
|
|
1684
|
+
}).strict(),
|
|
1685
|
+
i.object({
|
|
1686
|
+
kind: i.literal("sql_query"),
|
|
1687
|
+
connectionId: i.string().trim().min(1),
|
|
1688
|
+
sql: i.string().trim().min(1),
|
|
1689
|
+
valueColumn: i.string().trim().min(1),
|
|
1690
|
+
labelColumn: i.string().trim().min(1).optional()
|
|
1691
|
+
}).strict()
|
|
1692
|
+
]), nn = i.object({
|
|
1693
|
+
id: i.string().trim().min(1),
|
|
1694
|
+
label: i.string().trim().min(1),
|
|
1695
|
+
scope: i.enum(["dashboard", "card"]),
|
|
1696
|
+
type: i.enum([
|
|
1697
|
+
"enum",
|
|
1698
|
+
"multi_enum",
|
|
1699
|
+
"text",
|
|
1700
|
+
"number",
|
|
1701
|
+
"boolean",
|
|
1702
|
+
"date",
|
|
1703
|
+
"field_selector",
|
|
1704
|
+
"metric_selector",
|
|
1705
|
+
"aggregation_selector",
|
|
1706
|
+
"grain_selector"
|
|
1707
|
+
]),
|
|
1708
|
+
source: tn,
|
|
1709
|
+
initialValueStrategy: i.enum([
|
|
1710
|
+
"saved_default",
|
|
1711
|
+
"builtin",
|
|
1712
|
+
"embed_required",
|
|
1713
|
+
"schedule_snapshot"
|
|
1714
|
+
]),
|
|
1715
|
+
defaultValue: i.unknown().optional(),
|
|
1716
|
+
requiredAtExecution: i.boolean(),
|
|
1717
|
+
hidden: i.boolean().optional(),
|
|
1718
|
+
locked: i.boolean().optional(),
|
|
1719
|
+
helpText: i.string().optional(),
|
|
1720
|
+
placement: i.enum(["toolbar", "card_header", "advanced"]).optional(),
|
|
1721
|
+
showLabel: i.boolean().optional(),
|
|
1722
|
+
toolbarWidth: i.number().optional()
|
|
1723
|
+
}).strict().superRefine((e, t) => {
|
|
1724
|
+
e.source.kind === "sql_query" && (e.scope !== "dashboard" && t.addIssue({
|
|
1725
|
+
code: i.ZodIssueCode.custom,
|
|
1726
|
+
path: ["scope"],
|
|
1727
|
+
message: "with source.kind 'sql_query' must be dashboard-scoped."
|
|
1728
|
+
}), e.type !== "enum" && e.type !== "multi_enum" && t.addIssue({
|
|
1729
|
+
code: i.ZodIssueCode.custom,
|
|
1730
|
+
path: ["type"],
|
|
1731
|
+
message: "with source.kind 'sql_query' must be of type 'enum' or 'multi_enum'."
|
|
1732
|
+
}));
|
|
1733
|
+
}), Ee = i.record(i.string().trim().min(1)).refine((e) => Object.keys(e).length > 0, {
|
|
1734
|
+
message: "must not be empty"
|
|
1735
|
+
}), on = i.discriminatedUnion("kind", [
|
|
1736
|
+
i.object({ kind: i.literal("metric"), metricId: i.string().trim().min(1) }).strict(),
|
|
1737
|
+
i.object({ kind: i.literal("column"), columnKey: i.string().trim().min(1) }).strict(),
|
|
1738
|
+
i.object({ kind: i.literal("matrix_measure"), measureId: i.string().trim().min(1) }).strict()
|
|
1739
|
+
]), Be = i.object({ kind: i.literal("matrix_instance"), id: i.string().uuid() }).strict(), je = (e) => e.kind !== "matrix_instance", rn = i.record(i.union([
|
|
1740
|
+
Be,
|
|
1741
|
+
Wt.refine(je)
|
|
1742
|
+
])).refine((e) => Object.keys(e).length > 0, {
|
|
1743
|
+
message: "must not be empty"
|
|
1744
|
+
}), sn = i.record(i.union([
|
|
1745
|
+
Be,
|
|
1746
|
+
Xt.refine(je)
|
|
1747
|
+
])).refine((e) => Object.keys(e).length > 0, {
|
|
1748
|
+
message: "must not be empty"
|
|
1749
|
+
}), an = i.discriminatedUnion("target", [
|
|
1750
|
+
i.object({
|
|
1751
|
+
controlId: i.string().trim().min(1),
|
|
1752
|
+
target: i.literal("sql_param"),
|
|
1753
|
+
paramId: i.string().trim().min(1)
|
|
1754
|
+
}).strict(),
|
|
1755
|
+
i.object({
|
|
1756
|
+
controlId: i.string().trim().min(1),
|
|
1757
|
+
target: i.literal("config_metric_selector"),
|
|
1758
|
+
matrixTargetId: i.string().uuid().optional(),
|
|
1759
|
+
mapping: sn
|
|
1760
|
+
}).strict(),
|
|
1761
|
+
i.object({
|
|
1762
|
+
controlId: i.string().trim().min(1),
|
|
1763
|
+
target: i.literal("config_field_selector"),
|
|
1764
|
+
matrixTargetId: i.string().uuid().optional(),
|
|
1765
|
+
mapping: rn
|
|
1766
|
+
}).strict(),
|
|
1767
|
+
i.object({
|
|
1768
|
+
controlId: i.string().trim().min(1),
|
|
1769
|
+
target: i.literal("config_aggregation"),
|
|
1770
|
+
matrixTargetId: i.string().uuid().optional(),
|
|
1771
|
+
mapping: Ee
|
|
1772
|
+
}).strict(),
|
|
1773
|
+
i.object({
|
|
1774
|
+
controlId: i.string().trim().min(1),
|
|
1775
|
+
target: i.literal("config_grain"),
|
|
1776
|
+
matrixTargetId: i.string().uuid().optional(),
|
|
1777
|
+
mapping: Ee
|
|
1778
|
+
}).strict(),
|
|
1779
|
+
// Presentation only: the control picks the currency values are shown in.
|
|
1780
|
+
i.object({
|
|
1781
|
+
controlId: i.string().trim().min(1),
|
|
1782
|
+
target: i.literal("presentation_currency"),
|
|
1783
|
+
presentationTarget: on
|
|
1784
|
+
}).strict()
|
|
1785
|
+
]), we = i.array(nn), qe = i.array(an).superRefine((e, t) => {
|
|
1786
|
+
const n = /* @__PURE__ */ new Map(), o = [];
|
|
1787
|
+
e.forEach((r, l) => {
|
|
1788
|
+
if (r.target === "sql_param") {
|
|
1789
|
+
const s = n.get(r.paramId);
|
|
1790
|
+
s !== void 0 ? t.addIssue({
|
|
1791
|
+
code: i.ZodIssueCode.custom,
|
|
1792
|
+
path: [l, "paramId"],
|
|
1793
|
+
message: `duplicates sql_param placeholder '${r.paramId}' already defined at controlBindings[${s}]`
|
|
1794
|
+
}) : n.set(r.paramId, l);
|
|
1795
|
+
return;
|
|
1796
|
+
}
|
|
1797
|
+
if (r.target === "presentation_currency") return;
|
|
1798
|
+
const a = o.find((s) => s.target === r.target && (!s.matrixTargetId || !r.matrixTargetId || s.matrixTargetId === r.matrixTargetId));
|
|
1799
|
+
a && t.addIssue({
|
|
1800
|
+
code: i.ZodIssueCode.custom,
|
|
1801
|
+
path: [l, r.matrixTargetId ? "matrixTargetId" : "target"],
|
|
1802
|
+
message: `duplicates ${r.target} already defined at controlBindings[${a.index}]; multiple controls require distinct explicit Matrix targets`
|
|
1803
|
+
}), o.push({ target: r.target, matrixTargetId: r.matrixTargetId, index: l });
|
|
1804
|
+
});
|
|
1805
|
+
});
|
|
1806
|
+
function ln(e) {
|
|
1807
|
+
const t = [], n = /* @__PURE__ */ new Map(), o = (r, l) => {
|
|
1808
|
+
r.forEach((a, s) => {
|
|
1809
|
+
const c = n.get(a.id);
|
|
1810
|
+
if (c) {
|
|
1811
|
+
t.push({
|
|
1812
|
+
path: [l, s, "id"],
|
|
1813
|
+
message: `duplicates control id '${a.id}' already defined at ${se(c.path)}`
|
|
1814
|
+
});
|
|
1815
|
+
return;
|
|
1816
|
+
}
|
|
1817
|
+
n.set(a.id, { path: [l, s, "id"] });
|
|
1818
|
+
});
|
|
1819
|
+
};
|
|
1820
|
+
return o(e.controlDefinitions, "controlDefinitions"), o(e.cardControlDefinitions, "cardControlDefinitions"), e.controlBindings.forEach((r, l) => {
|
|
1821
|
+
n.has(r.controlId) || t.push({
|
|
1822
|
+
path: ["controlBindings", l, "controlId"],
|
|
1823
|
+
message: `references unknown control '${r.controlId}'`
|
|
1824
|
+
});
|
|
1825
|
+
}), t;
|
|
1826
|
+
}
|
|
1827
|
+
function se(e) {
|
|
1828
|
+
return e.length === 0 ? "root" : e.map(
|
|
1829
|
+
(t) => typeof t == "number" ? `[${t}]` : /^[A-Za-z_]\w*$/.test(t) ? t : `['${t}']`
|
|
1830
|
+
).join(".").replace(".[", "[");
|
|
1831
|
+
}
|
|
1832
|
+
class G extends Error {
|
|
1833
|
+
constructor(t) {
|
|
1834
|
+
super(t), Object.setPrototypeOf(this, G.prototype), this.name = "ExecutionControlContractError";
|
|
1835
|
+
}
|
|
1836
|
+
}
|
|
1837
|
+
function Ge(e) {
|
|
1838
|
+
const t = e.issues[0], n = se((t == null ? void 0 : t.path) || []);
|
|
1839
|
+
return new G(`Invalid control contract: ${n} ${(t == null ? void 0 : t.message) || "is invalid"}`);
|
|
1840
|
+
}
|
|
1841
|
+
function X(e, t) {
|
|
1842
|
+
return new G(`Invalid control contract: ${se(e)} ${t}`);
|
|
1843
|
+
}
|
|
1844
|
+
function co(e) {
|
|
1845
|
+
try {
|
|
1846
|
+
return e === void 0 ? [] : qe.parse(e);
|
|
1847
|
+
} catch (t) {
|
|
1848
|
+
throw t instanceof i.ZodError ? Ge(t) : t;
|
|
1849
|
+
}
|
|
1850
|
+
}
|
|
1851
|
+
function cn(e) {
|
|
1852
|
+
try {
|
|
1853
|
+
const t = {
|
|
1854
|
+
controlDefinitions: e.controlDefinitions === void 0 ? [] : we.parse(
|
|
1855
|
+
e.controlDefinitions
|
|
1856
|
+
),
|
|
1857
|
+
cardControlDefinitions: e.cardControlDefinitions === void 0 ? [] : we.parse(
|
|
1858
|
+
e.cardControlDefinitions
|
|
1859
|
+
),
|
|
1860
|
+
controlBindings: e.controlBindings === void 0 ? [] : qe.parse(e.controlBindings)
|
|
1861
|
+
}, n = ln(t);
|
|
1862
|
+
if (n.length > 0)
|
|
1863
|
+
throw new i.ZodError(
|
|
1864
|
+
n.map((o) => ({
|
|
1865
|
+
code: i.ZodIssueCode.custom,
|
|
1866
|
+
path: o.path,
|
|
1867
|
+
message: o.message
|
|
1868
|
+
}))
|
|
1869
|
+
);
|
|
1870
|
+
return t;
|
|
1871
|
+
} catch (t) {
|
|
1872
|
+
throw t instanceof i.ZodError ? Ge(t) : t;
|
|
1873
|
+
}
|
|
1874
|
+
}
|
|
1875
|
+
function dn(e) {
|
|
1876
|
+
return !e || typeof e != "object" || Array.isArray(e) ? {} : { ...e };
|
|
1877
|
+
}
|
|
1878
|
+
function mn(e) {
|
|
1879
|
+
var o;
|
|
1880
|
+
const t = /* @__PURE__ */ new Map();
|
|
1881
|
+
for (const r of [
|
|
1882
|
+
...e.controlDefinitions,
|
|
1883
|
+
...e.cardControlDefinitions
|
|
1884
|
+
])
|
|
1885
|
+
t.set(r.id, r);
|
|
1886
|
+
const n = {};
|
|
1887
|
+
for (const [r, l] of Object.entries(e.controlValues)) {
|
|
1888
|
+
const a = t.get(r);
|
|
1889
|
+
if (!a)
|
|
1890
|
+
continue;
|
|
1891
|
+
const s = ((o = e.strictControlIds) == null ? void 0 : o.has(r)) ?? !1;
|
|
1892
|
+
try {
|
|
1893
|
+
const c = ie(a, l);
|
|
1894
|
+
c === void 0 ? delete n[r] : n[r] = c;
|
|
1895
|
+
} catch (c) {
|
|
1896
|
+
if (!s)
|
|
1897
|
+
continue;
|
|
1898
|
+
const d = c instanceof Error ? c.message : String(c);
|
|
1899
|
+
throw X(["controlValues", r], d);
|
|
1900
|
+
}
|
|
1901
|
+
}
|
|
1902
|
+
return n;
|
|
1903
|
+
}
|
|
1904
|
+
function pn(e) {
|
|
1905
|
+
const t = /* @__PURE__ */ new Map();
|
|
1906
|
+
for (const n of [
|
|
1907
|
+
...e.controlDefinitions,
|
|
1908
|
+
...e.cardControlDefinitions
|
|
1909
|
+
])
|
|
1910
|
+
t.set(n.id, n);
|
|
1911
|
+
for (const n of e.controlBindings) {
|
|
1912
|
+
if (n.target === "sql_param" || n.target === "presentation_currency")
|
|
1913
|
+
continue;
|
|
1914
|
+
const o = t.get(n.controlId);
|
|
1915
|
+
if (!o)
|
|
1916
|
+
continue;
|
|
1917
|
+
if (!Object.prototype.hasOwnProperty.call(
|
|
1918
|
+
e.controlValues,
|
|
1919
|
+
n.controlId
|
|
1920
|
+
)) {
|
|
1921
|
+
if (o.requiredAtExecution)
|
|
1922
|
+
throw X(
|
|
1923
|
+
["controlValues", n.controlId],
|
|
1924
|
+
`Control '${n.controlId}' must resolve to a concrete value before query execution.`
|
|
1925
|
+
);
|
|
1926
|
+
continue;
|
|
1927
|
+
}
|
|
1928
|
+
try {
|
|
1929
|
+
if (ie(
|
|
1930
|
+
o,
|
|
1931
|
+
e.controlValues[n.controlId]
|
|
1932
|
+
) === void 0)
|
|
1933
|
+
throw new Error(
|
|
1934
|
+
`Control '${n.controlId}' must resolve to a concrete value before query execution.`
|
|
1935
|
+
);
|
|
1936
|
+
} catch (l) {
|
|
1937
|
+
const a = l instanceof Error ? l.message : String(l);
|
|
1938
|
+
throw X(
|
|
1939
|
+
["controlValues", n.controlId],
|
|
1940
|
+
a
|
|
1941
|
+
);
|
|
1942
|
+
}
|
|
1943
|
+
}
|
|
1944
|
+
}
|
|
1945
|
+
function mo(e) {
|
|
1946
|
+
const t = cn({
|
|
1947
|
+
controlDefinitions: e.controlDefinitions,
|
|
1948
|
+
cardControlDefinitions: e.cardControlDefinitions,
|
|
1949
|
+
controlBindings: e.controlBindings
|
|
1950
|
+
}), n = new Set(
|
|
1951
|
+
t.controlBindings.map((r) => r.controlId)
|
|
1952
|
+
), o = mn({
|
|
1953
|
+
controlValues: dn(e.controlValues),
|
|
1954
|
+
controlDefinitions: t.controlDefinitions,
|
|
1955
|
+
cardControlDefinitions: t.cardControlDefinitions,
|
|
1956
|
+
strictControlIds: n
|
|
1957
|
+
});
|
|
1958
|
+
return pn({
|
|
1959
|
+
controlValues: o,
|
|
1960
|
+
controlDefinitions: t.controlDefinitions,
|
|
1961
|
+
cardControlDefinitions: t.cardControlDefinitions,
|
|
1962
|
+
controlBindings: t.controlBindings
|
|
1963
|
+
}), {
|
|
1964
|
+
controlValues: o,
|
|
1965
|
+
controlDefinitions: t.controlDefinitions,
|
|
1966
|
+
cardControlDefinitions: t.cardControlDefinitions,
|
|
1967
|
+
controlBindings: t.controlBindings
|
|
1968
|
+
};
|
|
1969
|
+
}
|
|
1970
|
+
const un = new Set(it);
|
|
1971
|
+
function Ue(e) {
|
|
1972
|
+
return typeof e == "string" && un.has(e);
|
|
1973
|
+
}
|
|
1974
|
+
function fn(e) {
|
|
1975
|
+
return typeof e == "object" && e !== null && !Array.isArray(e);
|
|
1976
|
+
}
|
|
1977
|
+
function O(e, t, n) {
|
|
1978
|
+
(typeof e != "string" || e.trim().length === 0) && n.push({
|
|
1979
|
+
path: t,
|
|
1980
|
+
message: `${t.split(".").pop()} must be a non-empty string`
|
|
1981
|
+
});
|
|
1982
|
+
}
|
|
1983
|
+
function gn(e, t, n) {
|
|
1984
|
+
e !== void 0 && typeof e != "string" && n.push({
|
|
1985
|
+
path: t,
|
|
1986
|
+
message: `${t.split(".").pop()} must be a string`
|
|
1987
|
+
});
|
|
1988
|
+
}
|
|
1989
|
+
function De(e, t, n) {
|
|
1990
|
+
Ue(e) || n.push({
|
|
1991
|
+
path: t,
|
|
1992
|
+
message: `${t.split(".").pop()} must be a supported time granularity`
|
|
1993
|
+
});
|
|
1994
|
+
}
|
|
1995
|
+
function po(e) {
|
|
1996
|
+
if (e == null)
|
|
1997
|
+
return { ok: !0 };
|
|
1998
|
+
if (!fn(e))
|
|
1999
|
+
return {
|
|
2000
|
+
ok: !1,
|
|
2001
|
+
issues: [
|
|
2002
|
+
{
|
|
2003
|
+
path: "resolvedPrimaryDateField",
|
|
2004
|
+
message: "resolvedPrimaryDateField must be an object or null"
|
|
2005
|
+
}
|
|
2006
|
+
]
|
|
2007
|
+
};
|
|
2008
|
+
const t = [];
|
|
2009
|
+
O(
|
|
2010
|
+
e.sourceDataset,
|
|
2011
|
+
"resolvedPrimaryDateField.sourceDataset",
|
|
2012
|
+
t
|
|
2013
|
+
), O(
|
|
2014
|
+
e.sourceField,
|
|
2015
|
+
"resolvedPrimaryDateField.sourceField",
|
|
2016
|
+
t
|
|
2017
|
+
), O(e.name, "resolvedPrimaryDateField.name", t), O(
|
|
2018
|
+
e.qualifiedFieldName,
|
|
2019
|
+
"resolvedPrimaryDateField.qualifiedFieldName",
|
|
2020
|
+
t
|
|
2021
|
+
), O(
|
|
2022
|
+
e.entityId,
|
|
2023
|
+
"resolvedPrimaryDateField.entityId",
|
|
2024
|
+
t
|
|
2025
|
+
), O(
|
|
2026
|
+
e.entityName,
|
|
2027
|
+
"resolvedPrimaryDateField.entityName",
|
|
2028
|
+
t
|
|
2029
|
+
), O(
|
|
2030
|
+
e.entityType,
|
|
2031
|
+
"resolvedPrimaryDateField.entityType",
|
|
2032
|
+
t
|
|
2033
|
+
), O(
|
|
2034
|
+
e.dataType,
|
|
2035
|
+
"resolvedPrimaryDateField.dataType",
|
|
2036
|
+
t
|
|
2037
|
+
), gn(
|
|
2038
|
+
e.qualifiedEntityName,
|
|
2039
|
+
"resolvedPrimaryDateField.qualifiedEntityName",
|
|
2040
|
+
t
|
|
2041
|
+
);
|
|
2042
|
+
const n = e.format === void 0 ? void 0 : Ne.safeParse(e.format);
|
|
2043
|
+
if (n && !n.success && t.push({
|
|
2044
|
+
path: "resolvedPrimaryDateField.format",
|
|
2045
|
+
message: "format must be a valid temporal bucket format"
|
|
2046
|
+
}), e.format !== void 0 && e.defaultGranularity === void 0 && t.push({
|
|
2047
|
+
path: "resolvedPrimaryDateField.defaultGranularity",
|
|
2048
|
+
message: "defaultGranularity is required when format is provided"
|
|
2049
|
+
}), e.defaultGranularity !== void 0 && De(
|
|
2050
|
+
e.defaultGranularity,
|
|
2051
|
+
"resolvedPrimaryDateField.defaultGranularity",
|
|
2052
|
+
t
|
|
2053
|
+
), n != null && n.success && Ue(e.defaultGranularity)) {
|
|
2054
|
+
const o = $(
|
|
2055
|
+
n.data,
|
|
2056
|
+
e.defaultGranularity
|
|
2057
|
+
);
|
|
2058
|
+
o.ok || t.push({
|
|
2059
|
+
path: "resolvedPrimaryDateField.format",
|
|
2060
|
+
message: o.message
|
|
2061
|
+
});
|
|
2062
|
+
}
|
|
2063
|
+
for (const o of ["dateFormat", "customFormat"])
|
|
2064
|
+
Object.prototype.hasOwnProperty.call(e, o) && t.push({
|
|
2065
|
+
path: `resolvedPrimaryDateField.${o}`,
|
|
2066
|
+
message: `${o} is retired; use format instead`
|
|
2067
|
+
});
|
|
2068
|
+
return e.supportedGranularities !== void 0 && (Array.isArray(e.supportedGranularities) ? e.supportedGranularities.forEach((o, r) => {
|
|
2069
|
+
De(
|
|
2070
|
+
o,
|
|
2071
|
+
`resolvedPrimaryDateField.supportedGranularities.${r}`,
|
|
2072
|
+
t
|
|
2073
|
+
);
|
|
2074
|
+
}) : t.push({
|
|
2075
|
+
path: "resolvedPrimaryDateField.supportedGranularities",
|
|
2076
|
+
message: "supportedGranularities must be an array"
|
|
2077
|
+
})), t.length > 0 ? { ok: !1, issues: t } : { ok: !0 };
|
|
2078
|
+
}
|
|
2079
|
+
function uo(e) {
|
|
2080
|
+
return e.map((t) => `${t.path}: ${t.message}`).join("; ");
|
|
2081
|
+
}
|
|
2082
|
+
function hn(e) {
|
|
2083
|
+
return !e.entityName || e.entityName === ce || e.entityName === "calculated_fields" || e.qualifiedEntityName === ce || e.qualifiedEntityName === "calculated_fields" ? "root" : e.qualifiedEntityName || e.entityName;
|
|
2084
|
+
}
|
|
2085
|
+
function yn(e) {
|
|
2086
|
+
return ["domain", e.role || "field", hn(e), e.name].join("::");
|
|
2087
|
+
}
|
|
2088
|
+
function fo(e) {
|
|
2089
|
+
var r, l;
|
|
2090
|
+
if (e.fieldScope !== "domain") return;
|
|
2091
|
+
const t = e.calculatedFieldOrigin;
|
|
2092
|
+
if ((r = t == null ? void 0 : t.id) != null && r.startsWith("domain::")) return t.id;
|
|
2093
|
+
const n = (l = e.derivedField) == null ? void 0 : l.resultRole, o = n === "measure" ? "metric" : n === "dimension" || n === "date" ? "groupby" : e.derivedField || t == null ? void 0 : t.role;
|
|
2094
|
+
if (!(o !== "metric" && o !== "groupby"))
|
|
2095
|
+
return yn({ ...e, role: o });
|
|
2096
|
+
}
|
|
2097
|
+
export {
|
|
2098
|
+
nn as $,
|
|
2099
|
+
q as A,
|
|
2100
|
+
_e as B,
|
|
2101
|
+
jt as C,
|
|
2102
|
+
Jn as D,
|
|
2103
|
+
Kn as E,
|
|
2104
|
+
Zn as F,
|
|
2105
|
+
Qn as G,
|
|
2106
|
+
Gt as H,
|
|
2107
|
+
Ut as I,
|
|
2108
|
+
Wn as J,
|
|
2109
|
+
Xn as K,
|
|
2110
|
+
Ht as L,
|
|
2111
|
+
zt as M,
|
|
2112
|
+
re as N,
|
|
2113
|
+
eo as O,
|
|
2114
|
+
Ce as P,
|
|
2115
|
+
w as Q,
|
|
2116
|
+
to as R,
|
|
2117
|
+
xt as S,
|
|
2118
|
+
ie as T,
|
|
2119
|
+
no as U,
|
|
2120
|
+
oo as V,
|
|
2121
|
+
ro as W,
|
|
2122
|
+
io as X,
|
|
2123
|
+
so as Y,
|
|
2124
|
+
ao as Z,
|
|
2125
|
+
lo as _,
|
|
2126
|
+
jn as a,
|
|
2127
|
+
an as a0,
|
|
2128
|
+
G as a1,
|
|
2129
|
+
co as a2,
|
|
2130
|
+
cn as a3,
|
|
2131
|
+
hn as a4,
|
|
2132
|
+
yn as a5,
|
|
2133
|
+
fo as a6,
|
|
2134
|
+
Rn as a7,
|
|
2135
|
+
Pn as a8,
|
|
2136
|
+
Ot as b,
|
|
2137
|
+
Sn as c,
|
|
2138
|
+
Bt as d,
|
|
2139
|
+
Gn as e,
|
|
2140
|
+
uo as f,
|
|
2141
|
+
qn as g,
|
|
2142
|
+
Un as h,
|
|
2143
|
+
Lt as i,
|
|
2144
|
+
Hn as j,
|
|
2145
|
+
F as k,
|
|
2146
|
+
Fn as l,
|
|
2147
|
+
kt as m,
|
|
2148
|
+
$n as n,
|
|
2149
|
+
Yt as o,
|
|
2150
|
+
mo as p,
|
|
2151
|
+
At as q,
|
|
2152
|
+
Ln as r,
|
|
2153
|
+
Bn as s,
|
|
2154
|
+
An as t,
|
|
2155
|
+
Ft as u,
|
|
2156
|
+
po as v,
|
|
2157
|
+
xn as w,
|
|
2158
|
+
Vn as x,
|
|
2159
|
+
Ie as y,
|
|
2160
|
+
zn as z
|
|
2161
|
+
};
|