react-semaphor 0.1.558 → 0.1.560
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 +368 -358
- package/dist/assistant-context/index.js +1 -1
- package/dist/assistant-protocol/index.js +5 -5
- package/dist/brand-studio/index.js +9 -9
- package/dist/briefings/index.js +5 -5
- package/dist/chunks/analytics-base-schemas-CHLxsPfX.js +630 -0
- package/dist/chunks/{assistant-chat-BCWoP6Rf.js → assistant-chat-Bu2fFm_I.js} +206 -207
- package/dist/chunks/{bookmark-state-PjQpxbG7.js → bookmark-state-BFY9oNmr.js} +3 -3
- package/dist/chunks/{braces-D5Ucy7q1.js → braces-Da41xfUd.js} +1 -1
- package/dist/chunks/{comparison-window-caption-Dc7BaCMz.js → comparison-window-caption-4FNkMrzE.js} +213 -213
- package/dist/chunks/{context-DVy4HOU0.js → context-BgPDzLHZ.js} +1 -1
- package/dist/chunks/{custom-visual-inputs-B-DLRGrV.js → custom-visual-inputs-Dz-enUNR.js} +1 -1
- package/dist/chunks/{dashboard-wK6Bai4V.js → dashboard-_MeBuy67.js} +1 -1
- package/dist/chunks/{dashboard-briefing-launcher-Coqghdn6.js → dashboard-briefing-launcher-CEi4Pr_v.js} +1152 -1166
- package/dist/chunks/{dashboard-controls-BYWSM2RM.js → dashboard-controls-Bi7fyG-4.js} +98 -98
- package/dist/chunks/{dashboard-json-pPTB5gj0.js → dashboard-json-B1mU_OMa.js} +5 -5
- package/dist/chunks/{document-dashboard-inputs-PY_7Xm55.js → document-dashboard-inputs-CkWfDB8c.js} +64 -64
- package/dist/chunks/{edit-dashboard-visual-BODxuUeq.js → edit-dashboard-visual-0CJN31Y3.js} +8274 -8514
- package/dist/chunks/filter-reach-copy-BF4w4kI2.js +3738 -0
- package/dist/chunks/{filter-value-text-CUBpotVN.js → filter-value-text-CRC-K_l_.js} +3 -3
- package/dist/chunks/{global-date-filter-utils-BsFqnnbA.js → global-date-filter-utils-D8365uPH.js} +4088 -3416
- package/dist/chunks/{index-DP_wQl0v.js → index-DtHidOPV.js} +579 -604
- package/dist/chunks/{layout-grid-CkoXmv0L.js → layout-grid-BvsH4RY2.js} +1 -1
- package/dist/chunks/{list-filter-B4i25kuc.js → list-filter-Dg0otx5E.js} +1 -1
- package/dist/chunks/{matrix-analytical-definition-4GTUDheD.js → matrix-analytical-definition-CM18W8w6.js} +41 -41
- package/dist/chunks/{matrix-card-fS_4O7zA.js → matrix-card-HPskLaPy.js} +3 -3
- package/dist/chunks/{matrix-member-presentation-Dj7HaAHC.js → matrix-member-presentation-Bbrfrke4.js} +1 -1
- package/dist/chunks/{matrix-operation-contract-CpgLZ7E5.js → matrix-operation-contract-WPv4R-H_.js} +130 -130
- package/dist/chunks/{metric-comparison-C8LY7GG5.js → metric-comparison-ljMKYZKa.js} +2 -2
- package/dist/chunks/{model-change-CJEj3ZD6.js → model-change-Ccn1zaxl.js} +1 -1
- package/dist/chunks/{palette-stlpjVk4.js → palette-Bsh376zO.js} +1 -1
- package/dist/chunks/{pivot-result-contract-expectations-DMk-mKhG.js → pivot-result-contract-expectations-Bl5suy4-.js} +602 -696
- package/dist/chunks/{pivot-result-identity-CrQ54Xbj.js → pivot-result-identity-vS9TSh4f.js} +1 -1
- package/dist/chunks/{raw-temporal-presentation-BI2z2LlB.js → raw-temporal-presentation-BHm7s-hz.js} +230 -274
- package/dist/chunks/{report-preferences-dialog-Dc-YyVwf.js → report-preferences-dialog-BV8L0SeS.js} +55 -55
- package/dist/chunks/{report-runtime-context-CohdtiMg.js → report-runtime-context-BZQh9ywy.js} +2 -2
- package/dist/chunks/{resolve-dashboard-input-context-BZYI1hB0.js → resolve-dashboard-input-context-CAMiWvyR.js} +2021 -2239
- package/dist/chunks/{save-C1dgxgAu.js → save-B5EAsgQF.js} +1 -1
- package/dist/chunks/{saved-dashboard-context-CIBoMq46.js → saved-dashboard-context-n2Wn11cV.js} +57 -57
- package/dist/chunks/{selection-reducer-_d6aKJnj.js → selection-reducer-D0YnaAD9.js} +1 -1
- package/dist/chunks/{semaphor-ready-indicator-ERTLU7B4.js → semaphor-ready-indicator-XLBLOJ2V.js} +38446 -39176
- package/dist/chunks/{shelf-drop-preview-context-fEnx6iL_.js → shelf-drop-preview-context-DHMa54a-.js} +570 -570
- package/dist/chunks/source-entity-resolution-dUG5VWRm.js +607 -0
- package/dist/chunks/{switch-BqUan2mN.js → switch-ByxH4M7t.js} +3 -3
- package/dist/chunks/{table-export-sheet-CTCTA_bd.js → table-export-sheet-C_GdeTYU.js} +1 -1
- package/dist/chunks/{table-settings-DF1gdVQR.js → table-settings-Imz0FgWi.js} +8 -8
- package/dist/chunks/{temporal-input-presentation-DoSniQj1.js → temporal-input-presentation-uvNK_tM0.js} +1109 -820
- package/dist/chunks/{token-types-DFyLflLY.js → token-types-CQtXUVMy.js} +1 -1
- package/dist/chunks/{upload-DcoyjkRV.js → upload-wbR-NVzq.js} +1 -1
- package/dist/chunks/{use-create-flow-overlay-state-xhb9YFg-.js → use-create-flow-overlay-state-CEBaLOKC.js} +6 -6
- package/dist/chunks/validators-CXTneCA4.js +3453 -0
- package/dist/chunks/{zoned-wall-clock-E35Frf9v.js → zoned-wall-clock-B1n_WjW3.js} +1 -1
- package/dist/dashboard/index.js +2 -2
- package/dist/dashboard-authoring/index.js +2207 -1496
- package/dist/data-app-sdk/index.js +20 -20
- package/dist/data-app-sdk-adapters/index.js +3 -3
- package/dist/data-app-sdk-validation/index.js +6 -6
- package/dist/format-utils/index.js +181 -176
- package/dist/index.js +22 -22
- 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/components/editor/editor-aside/utils.d.ts +1 -1
- package/dist/types/components/visual/data-table/types/data-table.d.ts +5 -20
- package/dist/types/index.js +6 -6
- package/dist/types/lib/formatters/canonical-format-adapter.d.ts +2 -29
- package/dist/types/lib/formatters/raw-temporal-presentation.d.ts +0 -2
- package/dist/types/lib/formatters/table-column-settings.d.ts +47 -0
- package/dist/types/lib/matrix-table/matrix-card-adapter.d.ts +10 -188
- package/dist/types/lib/matrix-table/matrix-delivery-policy.d.ts +1 -1
- package/dist/types/lib/matrix-table/matrix-delivery.d.ts +16 -372
- package/dist/types/lib/stores/dashboard-store.d.ts +0 -1
- package/dist/types/lib/stores/editor-store.d.ts +39 -9
- package/dist/types/lib/stores/table-actions.d.ts +9 -3
- package/dist/types/lib/table-formatting/index.d.ts +0 -2
- package/dist/types/lib/table-formatting/table-conditional-formatting-range-source.d.ts +3 -2
- package/dist/types/lib/table-formatting/table-conditional-formatting-range.d.ts +3 -2
- package/dist/types/lib/table-formatting/table-formatting-normalize.d.ts +1 -2
- package/dist/types/lib/table-formatting/table-formatting-render-model.d.ts +9 -0
- package/dist/types/lib/table-formatting/table-formatting-types.d.ts +5 -95
- package/dist/types/lib/table-formatting/table-presentation-fields.d.ts +35 -0
- package/dist/types/lib/types/common-types.d.ts +40 -47
- package/dist/types/lib/types/explorer-types.d.ts +13 -44
- package/dist/types/lib/utils/card-config-utils.d.ts +9 -1
- package/dist/types/lib/utils/card-definition.d.ts +9 -187
- package/dist/types/shared/analytics-protocol/analytics-base-schemas.d.ts +159 -513
- package/dist/types/shared/analytics-protocol/contracts.d.ts +32 -9
- package/dist/types/shared/analytics-protocol/execution-input-schemas.d.ts +108 -980
- package/dist/types/shared/analytics-protocol/field-validation.d.ts +1 -0
- package/dist/types/shared/analytics-protocol/matrix-definition-contract.d.ts +281 -4624
- package/dist/types/shared/analytics-protocol/matrix-operation-contract.d.ts +20 -20
- package/dist/types/shared/analytics-protocol/matrix-operation-request.d.ts +18 -18
- package/dist/types/shared/analytics-protocol/matrix-path-contract.d.ts +40 -40
- package/dist/types/shared/analytics-protocol/matrix-window-contract.d.ts +3 -203
- package/dist/types/shared/analytics-protocol/scalar-value.d.ts +8 -8
- package/dist/types/shared/analytics-protocol/source-capabilities.d.ts +21 -0
- package/dist/types/shared/assistant-context/saved-dashboard-context.d.ts +8 -0
- package/dist/types/shared/assistant-protocol/context.d.ts +69 -69
- package/dist/types/shared/dashboard-authoring/canonical-result-keys.d.ts +13 -0
- package/dist/types/shared/dashboard-authoring/card-export-request.d.ts +4 -1
- package/dist/types/shared/dashboard-authoring/card-formats/sql-date-pattern.d.ts +10 -0
- package/dist/types/shared/dashboard-authoring/card-formats/upgrade-card-formats.d.ts +57 -0
- package/dist/types/shared/dashboard-authoring/changes/dashboard-change.d.ts +24 -24
- package/dist/types/shared/dashboard-authoring/conditional-formatting/editable.d.ts +14 -0
- package/dist/types/shared/dashboard-authoring/conditional-formatting/evaluate.d.ts +16 -0
- package/dist/types/shared/dashboard-authoring/conditional-formatting/index.d.ts +9 -0
- package/dist/types/shared/dashboard-authoring/conditional-formatting/kpi.d.ts +14 -0
- package/dist/types/shared/dashboard-authoring/conditional-formatting/resolve-card-column-ref.d.ts +17 -0
- package/dist/types/shared/dashboard-authoring/conditional-formatting/retain.d.ts +14 -0
- package/dist/types/shared/dashboard-authoring/conditional-formatting/schema.d.ts +4499 -0
- package/dist/types/shared/dashboard-authoring/conditional-formatting/store.d.ts +12 -0
- package/dist/types/shared/dashboard-authoring/conditional-formatting/types.d.ts +151 -0
- package/dist/types/shared/dashboard-authoring/conditional-formatting/upgrade.d.ts +35 -0
- package/dist/types/shared/dashboard-authoring/control-execution-contract.d.ts +62 -62
- package/dist/types/shared/dashboard-authoring/dashboard-card-source-index.d.ts +2 -0
- package/dist/types/shared/dashboard-authoring/index.d.ts +5 -0
- package/dist/types/shared/dashboard-authoring/legacy-table-routing.d.ts +4 -2
- package/dist/types/shared/dashboard-authoring/matrix-authoring.d.ts +4 -5
- package/dist/types/shared/dashboard-authoring/matrix-delivery.d.ts +24 -736
- package/dist/types/shared/dashboard-authoring/retired-presentation-fields.d.ts +31 -0
- package/dist/types/shared/dashboard-authoring/upgrade-card-presentation.d.ts +14 -0
- package/dist/types/shared/format-utils/formatters/matrix-formatter.d.ts +5 -1
- package/dist/types/shared/format-utils/formatters/number-formatter.d.ts +16 -0
- package/dist/types/shared/format-utils/index.d.ts +2 -0
- package/dist/types/shared/format-utils/matrix-export-presentation.d.ts +10 -366
- package/dist/types/shared/format-utils/raw-temporal.d.ts +15 -1
- package/dist/types/shared/format-utils/resolve-column-format.d.ts +43 -0
- package/dist/types/shared/format-utils/retired-format-adapters.d.ts +68 -0
- package/dist/types/shared/format-utils/semantic-format.d.ts +5 -1
- package/dist/types/shared/format-utils/stored-value-format.d.ts +16 -0
- package/dist/types/shared/format-utils/types/format-types.d.ts +10 -12
- package/package.json +1 -1
- package/dist/chunks/analytics-base-schemas-BUFUoO6G.js +0 -472
- package/dist/chunks/editor-draft-sync-BN5qYHPF.js +0 -15
- package/dist/chunks/filter-reach-copy-BvJH9JO-.js +0 -3411
- package/dist/chunks/source-entity-resolution-DXW1HpKf.js +0 -816
- package/dist/chunks/validators-hmfNNQz8.js +0 -3595
- package/dist/types/lib/table-formatting/table-conditional-formatting-evaluator.d.ts +0 -9
- package/dist/types/lib/table-formatting/table-formatting-validation.d.ts +0 -12
|
@@ -1,3595 +0,0 @@
|
|
|
1
|
-
import { M as ke, j as U, l as Le, m as Rt, o as Tt, q as Et, v as Nt, g as Ve, h as ee, a as $t, c as qe } from "./analytics-base-schemas-BUFUoO6G.js";
|
|
2
|
-
import { z as n } from "zod";
|
|
3
|
-
function jt(e) {
|
|
4
|
-
return typeof e == "string" || typeof e == "number" && Number.isFinite(e) || typeof e == "boolean";
|
|
5
|
-
}
|
|
6
|
-
function Ct(e) {
|
|
7
|
-
return !Array.isArray(e) || e.length === 0 || e.length > ke || !e.every(jt) ? {
|
|
8
|
-
ok: !1,
|
|
9
|
-
error: `matchValues must be 1 to ${ke} string, number or boolean values.`
|
|
10
|
-
} : { ok: !0, values: e };
|
|
11
|
-
}
|
|
12
|
-
const Ot = [
|
|
13
|
-
"day",
|
|
14
|
-
"week",
|
|
15
|
-
"month",
|
|
16
|
-
"quarter",
|
|
17
|
-
"year"
|
|
18
|
-
], Wn = ["this", "previous"], Yt = ["now", "latest_available"], Pt = [
|
|
19
|
-
"include_partial",
|
|
20
|
-
"complete_periods"
|
|
21
|
-
], ea = {
|
|
22
|
-
second: 31536e4,
|
|
23
|
-
minute: 5256e3,
|
|
24
|
-
hour: 87600,
|
|
25
|
-
day: 3650,
|
|
26
|
-
week: 520,
|
|
27
|
-
month: 120,
|
|
28
|
-
quarter: 40,
|
|
29
|
-
year: 10
|
|
30
|
-
};
|
|
31
|
-
function Bt(e) {
|
|
32
|
-
return e.anchor ?? "latest_available";
|
|
33
|
-
}
|
|
34
|
-
function R(e) {
|
|
35
|
-
return !!e && (e.kind === void 0 || e.kind === "relative");
|
|
36
|
-
}
|
|
37
|
-
function Lt(e) {
|
|
38
|
-
return (e == null ? void 0 : e.kind) === "calendar";
|
|
39
|
-
}
|
|
40
|
-
function ta(e) {
|
|
41
|
-
return R(e) && e.anchor === "latest_available" || qt(e) ? null : R(e) && e.unit === "day" && e.completeness !== "complete_periods" ? { mode: "between", unit: "day", from: 1 - e.value, to: 0 } : Ut(R(e) ? { ...e, anchor: "now" } : e);
|
|
42
|
-
}
|
|
43
|
-
const Vt = /* @__PURE__ */ new Set(["week", "month", "quarter", "year"]);
|
|
44
|
-
function qt(e) {
|
|
45
|
-
return R(e) && Vt.has(e.unit) && e.completeness !== "complete_periods";
|
|
46
|
-
}
|
|
47
|
-
function ia(e) {
|
|
48
|
-
const t = e;
|
|
49
|
-
return t.mode === "between" ? t.unit === "day" && t.to === 0 && typeof t.from == "number" && t.from <= 0 ? { unit: "day", value: 1 - t.from } : null : t.mode === "last" && typeof t.n == "number" ? t.relativeTo === "latest_data" ? null : {
|
|
50
|
-
unit: t.unit,
|
|
51
|
-
value: t.n,
|
|
52
|
-
anchor: "now",
|
|
53
|
-
completeness: t.complete ? "complete_periods" : "include_partial"
|
|
54
|
-
} : t.mode === "this" ? t.boundary ? null : { kind: "calendar", unit: t.unit, period: "this", ...t.toDate ? { toDate: !0 } : {} } : t.mode === "previous" ? { kind: "calendar", unit: t.unit, period: "previous" } : null;
|
|
55
|
-
}
|
|
56
|
-
function Ut(e, t = {}) {
|
|
57
|
-
if (Lt(e))
|
|
58
|
-
return e.period === "previous" ? { mode: "previous", unit: e.unit } : {
|
|
59
|
-
mode: "this",
|
|
60
|
-
unit: e.unit,
|
|
61
|
-
...e.toDate ? { toDate: !0 } : {}
|
|
62
|
-
};
|
|
63
|
-
if (!R(e))
|
|
64
|
-
return null;
|
|
65
|
-
const i = Bt(e) === "latest_available" ? { relativeTo: "latest_data" } : {}, o = e.value, r = (t.completeness ?? e.completeness) === "complete_periods";
|
|
66
|
-
switch (e.unit) {
|
|
67
|
-
case "second":
|
|
68
|
-
return null;
|
|
69
|
-
case "minute":
|
|
70
|
-
case "hour":
|
|
71
|
-
return r ? null : { mode: "last", n: o, unit: e.unit, ...i };
|
|
72
|
-
default:
|
|
73
|
-
return {
|
|
74
|
-
mode: "last",
|
|
75
|
-
n: o,
|
|
76
|
-
unit: e.unit,
|
|
77
|
-
...r ? { complete: !0 } : {},
|
|
78
|
-
...i
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
function s(e, t, i) {
|
|
83
|
-
return i ? { code: e, message: t, path: i } : { code: e, message: t };
|
|
84
|
-
}
|
|
85
|
-
function m(e) {
|
|
86
|
-
return typeof e == "string" && e.trim().length > 0;
|
|
87
|
-
}
|
|
88
|
-
function Ht(e) {
|
|
89
|
-
const t = /* @__PURE__ */ new Set();
|
|
90
|
-
return Gt(e, (i) => (t.add(i), `{${i}}`)), Array.from(t);
|
|
91
|
-
}
|
|
92
|
-
function Gt(e, t) {
|
|
93
|
-
let i = "", o = 0, r = 0;
|
|
94
|
-
for (; r < e.length; ) {
|
|
95
|
-
const a = e[r];
|
|
96
|
-
if (a === "'" || a === '"') {
|
|
97
|
-
r = zt(e, r);
|
|
98
|
-
continue;
|
|
99
|
-
}
|
|
100
|
-
if (a === "{") {
|
|
101
|
-
const l = e.indexOf("}", r + 1);
|
|
102
|
-
if (l === -1) {
|
|
103
|
-
r += 1;
|
|
104
|
-
continue;
|
|
105
|
-
}
|
|
106
|
-
const d = e.slice(r + 1, l);
|
|
107
|
-
/^[A-Za-z_][A-Za-z0-9_]*$/.test(d) && (i += e.slice(o, r) + t(d), o = l + 1), r = l + 1;
|
|
108
|
-
continue;
|
|
109
|
-
}
|
|
110
|
-
r += 1;
|
|
111
|
-
}
|
|
112
|
-
return i + e.slice(o);
|
|
113
|
-
}
|
|
114
|
-
function zt(e, t) {
|
|
115
|
-
const i = e[t];
|
|
116
|
-
let o = t + 1;
|
|
117
|
-
for (; o < e.length; ) {
|
|
118
|
-
if (e[o] === i) {
|
|
119
|
-
if (e[o + 1] === i) {
|
|
120
|
-
o += 2;
|
|
121
|
-
continue;
|
|
122
|
-
}
|
|
123
|
-
return o + 1;
|
|
124
|
-
}
|
|
125
|
-
o += 1;
|
|
126
|
-
}
|
|
127
|
-
return e.length;
|
|
128
|
-
}
|
|
129
|
-
function f(e) {
|
|
130
|
-
return !!(e && typeof e == "object" && !Array.isArray(e));
|
|
131
|
-
}
|
|
132
|
-
const Qt = /* @__PURE__ */ new Set([
|
|
133
|
-
"SUM",
|
|
134
|
-
"COUNT",
|
|
135
|
-
"AVG",
|
|
136
|
-
"MIN",
|
|
137
|
-
"MAX",
|
|
138
|
-
"MEDIAN",
|
|
139
|
-
"DISTINCT"
|
|
140
|
-
]);
|
|
141
|
-
function ue(e, t, i) {
|
|
142
|
-
if (!e || typeof e != "object") {
|
|
143
|
-
i.push(
|
|
144
|
-
s("missing_source", "Analytics intent needs a source.", t)
|
|
145
|
-
);
|
|
146
|
-
return;
|
|
147
|
-
}
|
|
148
|
-
if (e.kind === "semantic") {
|
|
149
|
-
m(e.domainId) || i.push(
|
|
150
|
-
s(
|
|
151
|
-
"missing_semantic_domain",
|
|
152
|
-
"Semantic source needs a domainId.",
|
|
153
|
-
`${t}.domainId`
|
|
154
|
-
)
|
|
155
|
-
), m(e.datasetName) || i.push(
|
|
156
|
-
s(
|
|
157
|
-
"missing_dataset_name",
|
|
158
|
-
"Semantic source needs a datasetName.",
|
|
159
|
-
`${t}.datasetName`
|
|
160
|
-
)
|
|
161
|
-
);
|
|
162
|
-
return;
|
|
163
|
-
}
|
|
164
|
-
if (e.kind === "physical") {
|
|
165
|
-
m(e.connectionId) || i.push(
|
|
166
|
-
s(
|
|
167
|
-
"missing_connection_id",
|
|
168
|
-
"Physical source needs a connectionId.",
|
|
169
|
-
`${t}.connectionId`
|
|
170
|
-
)
|
|
171
|
-
), m(e.tableName) || i.push(
|
|
172
|
-
s(
|
|
173
|
-
"missing_table_name",
|
|
174
|
-
"Physical source needs a tableName.",
|
|
175
|
-
`${t}.tableName`
|
|
176
|
-
)
|
|
177
|
-
);
|
|
178
|
-
return;
|
|
179
|
-
}
|
|
180
|
-
if (e.kind === "sql") {
|
|
181
|
-
m(e.connectionId) || i.push(
|
|
182
|
-
s(
|
|
183
|
-
"missing_connection_id",
|
|
184
|
-
"SQL source needs a connectionId.",
|
|
185
|
-
`${t}.connectionId`
|
|
186
|
-
)
|
|
187
|
-
);
|
|
188
|
-
return;
|
|
189
|
-
}
|
|
190
|
-
i.push(
|
|
191
|
-
s("invalid_source_kind", "Source kind is not supported.", t)
|
|
192
|
-
);
|
|
193
|
-
}
|
|
194
|
-
function b(e, t, i, o = {}) {
|
|
195
|
-
if (!e || !f(e)) {
|
|
196
|
-
o.required && i.push(
|
|
197
|
-
s("missing_field_ref", "Field reference needs a name.", t)
|
|
198
|
-
);
|
|
199
|
-
return;
|
|
200
|
-
}
|
|
201
|
-
m(e.name) || i.push(
|
|
202
|
-
s(
|
|
203
|
-
"missing_field_ref",
|
|
204
|
-
"Field reference needs a name.",
|
|
205
|
-
`${t}.name`
|
|
206
|
-
)
|
|
207
|
-
), e.source !== void 0 && ue(e.source, `${t}.source`, i), ce(e.aggregate, `${t}.aggregate`, i);
|
|
208
|
-
}
|
|
209
|
-
function ce(e, t, i) {
|
|
210
|
-
e !== void 0 && (typeof e != "string" || !Qt.has(e)) && i.push(
|
|
211
|
-
s(
|
|
212
|
-
"invalid_aggregate",
|
|
213
|
-
"Field aggregate must be SUM, COUNT, AVG, MIN, MAX, MEDIAN, or DISTINCT.",
|
|
214
|
-
t
|
|
215
|
-
)
|
|
216
|
-
);
|
|
217
|
-
}
|
|
218
|
-
const Kt = /* @__PURE__ */ new Set([
|
|
219
|
-
"measure",
|
|
220
|
-
"dimension",
|
|
221
|
-
"date",
|
|
222
|
-
"id",
|
|
223
|
-
"unknown"
|
|
224
|
-
]), Xt = /* @__PURE__ */ new Set(["row", "aggregate"]), Ue = /* @__PURE__ */ new Set([
|
|
225
|
-
"string",
|
|
226
|
-
"number",
|
|
227
|
-
"boolean",
|
|
228
|
-
"date",
|
|
229
|
-
"datetime",
|
|
230
|
-
"unknown"
|
|
231
|
-
]), Zt = /* @__PURE__ */ new Set([
|
|
232
|
-
"number",
|
|
233
|
-
"currency",
|
|
234
|
-
"percent",
|
|
235
|
-
"percentage",
|
|
236
|
-
"scientific",
|
|
237
|
-
"date",
|
|
238
|
-
"datetime",
|
|
239
|
-
"duration",
|
|
240
|
-
"string",
|
|
241
|
-
"temporal_bucket"
|
|
242
|
-
]), Jt = /* @__PURE__ */ new Set([
|
|
243
|
-
"millisecond",
|
|
244
|
-
"second",
|
|
245
|
-
"minute",
|
|
246
|
-
"hour",
|
|
247
|
-
"day"
|
|
248
|
-
]), Wt = /* @__PURE__ */ new Set(["compact", "digital", "long"]);
|
|
249
|
-
function He(e, t, i) {
|
|
250
|
-
if (e === void 0)
|
|
251
|
-
return;
|
|
252
|
-
if (!f(e)) {
|
|
253
|
-
i.push(
|
|
254
|
-
s(
|
|
255
|
-
"invalid_value_format",
|
|
256
|
-
"Value format must be a structured object.",
|
|
257
|
-
t
|
|
258
|
-
)
|
|
259
|
-
);
|
|
260
|
-
return;
|
|
261
|
-
}
|
|
262
|
-
const o = e;
|
|
263
|
-
(typeof o.type != "string" || !Zt.has(o.type)) && i.push(
|
|
264
|
-
s(
|
|
265
|
-
"invalid_value_format_type",
|
|
266
|
-
"Value format type must be number, currency, percent, percentage, scientific, date, datetime, duration, string, or temporal_bucket.",
|
|
267
|
-
`${t}.type`
|
|
268
|
-
)
|
|
269
|
-
), o.type === "temporal_bucket" && !U.safeParse(e).success && i.push(
|
|
270
|
-
s(
|
|
271
|
-
"invalid_temporal_bucket_format",
|
|
272
|
-
"Temporal bucket format must contain a valid auto, preset, or pattern presentation.",
|
|
273
|
-
t
|
|
274
|
-
)
|
|
275
|
-
), (o.type === "number" || o.type === "currency" || o.type === "percent" || o.type === "percentage" || o.type === "scientific") && Object.prototype.hasOwnProperty.call(e, "locale") && i.push(
|
|
276
|
-
s(
|
|
277
|
-
"invalid_value_format",
|
|
278
|
-
"Numeric value formats cannot define viewer locale.",
|
|
279
|
-
`${t}.locale`
|
|
280
|
-
)
|
|
281
|
-
), Y(
|
|
282
|
-
e.minimumFractionDigits,
|
|
283
|
-
`${t}.minimumFractionDigits`,
|
|
284
|
-
i
|
|
285
|
-
), Y(
|
|
286
|
-
e.maximumFractionDigits,
|
|
287
|
-
`${t}.maximumFractionDigits`,
|
|
288
|
-
i
|
|
289
|
-
), Y(e.scale, `${t}.scale`, i), Y(e.maxUnits, `${t}.maxUnits`, i), e.useGrouping !== void 0 && typeof e.useGrouping != "boolean" && i.push(
|
|
290
|
-
s(
|
|
291
|
-
"invalid_value_format_use_grouping",
|
|
292
|
-
"Value format useGrouping must be boolean.",
|
|
293
|
-
`${t}.useGrouping`
|
|
294
|
-
)
|
|
295
|
-
), e.negativeStyle !== void 0 && e.negativeStyle !== "minus" && e.negativeStyle !== "parentheses" && i.push(
|
|
296
|
-
s(
|
|
297
|
-
"invalid_value_format_negative_style",
|
|
298
|
-
"Value format negativeStyle must be minus or parentheses.",
|
|
299
|
-
`${t}.negativeStyle`
|
|
300
|
-
)
|
|
301
|
-
), e.percentValueMode !== void 0 && e.percentValueMode !== "fraction" && e.percentValueMode !== "whole" && i.push(
|
|
302
|
-
s(
|
|
303
|
-
"invalid_value_format_percent_mode",
|
|
304
|
-
"Value format percentValueMode must be fraction or whole.",
|
|
305
|
-
`${t}.percentValueMode`
|
|
306
|
-
)
|
|
307
|
-
);
|
|
308
|
-
for (const r of ["inputUnit", "largestUnit", "smallestUnit"]) {
|
|
309
|
-
const a = e[r];
|
|
310
|
-
a !== void 0 && (typeof a != "string" || !Jt.has(a)) && i.push(
|
|
311
|
-
s(
|
|
312
|
-
"invalid_value_format_duration_unit",
|
|
313
|
-
"Duration format units must be millisecond, second, minute, hour, or day.",
|
|
314
|
-
`${t}.${r}`
|
|
315
|
-
)
|
|
316
|
-
);
|
|
317
|
-
}
|
|
318
|
-
e.outputStyle !== void 0 && (typeof e.outputStyle != "string" || !Wt.has(e.outputStyle)) && i.push(
|
|
319
|
-
s(
|
|
320
|
-
"invalid_value_format_duration_style",
|
|
321
|
-
"Duration format outputStyle must be compact, digital, or long.",
|
|
322
|
-
`${t}.outputStyle`
|
|
323
|
-
)
|
|
324
|
-
);
|
|
325
|
-
}
|
|
326
|
-
function Y(e, t, i) {
|
|
327
|
-
e !== void 0 && (typeof e != "number" || !Number.isFinite(e)) && i.push(
|
|
328
|
-
s(
|
|
329
|
-
"invalid_value_format_number",
|
|
330
|
-
"Value format numeric options must be finite numbers.",
|
|
331
|
-
t
|
|
332
|
-
)
|
|
333
|
-
);
|
|
334
|
-
}
|
|
335
|
-
const ei = /* @__PURE__ */ new Set([
|
|
336
|
-
"additive",
|
|
337
|
-
"non_additive",
|
|
338
|
-
"ratio_of_sums",
|
|
339
|
-
"weighted",
|
|
340
|
-
"pre_aggregated",
|
|
341
|
-
"snapshot"
|
|
342
|
-
]), ti = /* @__PURE__ */ new Set([
|
|
343
|
-
"default",
|
|
344
|
-
"symmetric_aggregate",
|
|
345
|
-
"aggregate_then_join",
|
|
346
|
-
"weighted"
|
|
347
|
-
]);
|
|
348
|
-
function ii(e, t, i) {
|
|
349
|
-
if (!e || !f(e)) {
|
|
350
|
-
i.push(
|
|
351
|
-
s(
|
|
352
|
-
"invalid_derived_field_input",
|
|
353
|
-
"Derived field inputs must be structured input references.",
|
|
354
|
-
t
|
|
355
|
-
)
|
|
356
|
-
);
|
|
357
|
-
return;
|
|
358
|
-
}
|
|
359
|
-
if (e.kind === "field") {
|
|
360
|
-
b(e.field, `${t}.field`, i, { required: !0 }), ce(e.aggregate, `${t}.aggregate`, i);
|
|
361
|
-
return;
|
|
362
|
-
}
|
|
363
|
-
i.push(
|
|
364
|
-
s(
|
|
365
|
-
"invalid_derived_field_input",
|
|
366
|
-
"Derived field input kind must be field.",
|
|
367
|
-
`${t}.kind`
|
|
368
|
-
)
|
|
369
|
-
);
|
|
370
|
-
}
|
|
371
|
-
function pe(e) {
|
|
372
|
-
const t = [];
|
|
373
|
-
if (!f(e))
|
|
374
|
-
return t.push(
|
|
375
|
-
s(
|
|
376
|
-
"invalid_derived_field",
|
|
377
|
-
"Derived field definition must be a structured object."
|
|
378
|
-
)
|
|
379
|
-
), { ok: !1, errors: t, warnings: [] };
|
|
380
|
-
if (e.kind !== "derived_field" && t.push(
|
|
381
|
-
s(
|
|
382
|
-
"invalid_derived_field_kind",
|
|
383
|
-
"Derived field kind must be derived_field.",
|
|
384
|
-
"kind"
|
|
385
|
-
)
|
|
386
|
-
), m(e.name) || t.push(
|
|
387
|
-
s(
|
|
388
|
-
"invalid_derived_field_name",
|
|
389
|
-
"Derived field needs a name.",
|
|
390
|
-
"name"
|
|
391
|
-
)
|
|
392
|
-
), m(e.label) || t.push(
|
|
393
|
-
s(
|
|
394
|
-
"invalid_derived_field_label",
|
|
395
|
-
"Derived field needs a label.",
|
|
396
|
-
"label"
|
|
397
|
-
)
|
|
398
|
-
), Kt.has(e.resultRole) || t.push(
|
|
399
|
-
s(
|
|
400
|
-
"invalid_derived_field_role",
|
|
401
|
-
"Derived field resultRole must be measure, dimension, date, id, or unknown.",
|
|
402
|
-
"resultRole"
|
|
403
|
-
)
|
|
404
|
-
), Ue.has(e.dataType) || t.push(
|
|
405
|
-
s(
|
|
406
|
-
"invalid_derived_field_data_type",
|
|
407
|
-
"Derived field dataType must be string, number, boolean, date, datetime, or unknown.",
|
|
408
|
-
"dataType"
|
|
409
|
-
)
|
|
410
|
-
), Xt.has(e.computeStage) || t.push(
|
|
411
|
-
s(
|
|
412
|
-
"invalid_derived_field_compute_stage",
|
|
413
|
-
"Derived field computeStage must be row or aggregate.",
|
|
414
|
-
"computeStage"
|
|
415
|
-
)
|
|
416
|
-
), e.computeStage === "aggregate" && e.resultRole !== "measure" && t.push(
|
|
417
|
-
s(
|
|
418
|
-
"invalid_derived_field_compute_stage",
|
|
419
|
-
"Aggregate-stage derived fields must have resultRole measure.",
|
|
420
|
-
"computeStage"
|
|
421
|
-
)
|
|
422
|
-
), e.resultRole !== "measure" && e.defaultAggregate !== void 0 && t.push(
|
|
423
|
-
s(
|
|
424
|
-
"invalid_derived_field_aggregate",
|
|
425
|
-
"Only measure derived fields may declare defaultAggregate.",
|
|
426
|
-
"defaultAggregate"
|
|
427
|
-
)
|
|
428
|
-
), e.computeStage === "row" && e.resultRole === "measure" && e.defaultAggregate === void 0 && t.push(
|
|
429
|
-
s(
|
|
430
|
-
"missing_derived_field_default_aggregate",
|
|
431
|
-
"Row-stage measure derived fields must declare defaultAggregate so row results have explicit rollup semantics.",
|
|
432
|
-
"defaultAggregate"
|
|
433
|
-
)
|
|
434
|
-
), ce(
|
|
435
|
-
e.defaultAggregate,
|
|
436
|
-
"defaultAggregate",
|
|
437
|
-
t
|
|
438
|
-
), e.aggregationBehavior !== void 0 && !ei.has(
|
|
439
|
-
e.aggregationBehavior
|
|
440
|
-
) && t.push(
|
|
441
|
-
s(
|
|
442
|
-
"invalid_derived_field_aggregation_behavior",
|
|
443
|
-
"Derived field aggregationBehavior is not supported.",
|
|
444
|
-
"aggregationBehavior"
|
|
445
|
-
)
|
|
446
|
-
), e.aggregationStrategy !== void 0 && !ti.has(
|
|
447
|
-
e.aggregationStrategy
|
|
448
|
-
) && t.push(
|
|
449
|
-
s(
|
|
450
|
-
"invalid_derived_field_aggregation_strategy",
|
|
451
|
-
"Derived field aggregationStrategy is not supported.",
|
|
452
|
-
"aggregationStrategy"
|
|
453
|
-
)
|
|
454
|
-
), m(e.expression) || t.push(
|
|
455
|
-
s(
|
|
456
|
-
"invalid_derived_field_expression",
|
|
457
|
-
"Derived field needs a named-token expression.",
|
|
458
|
-
"expression"
|
|
459
|
-
)
|
|
460
|
-
), e.expressionLanguage !== void 0 && e.expressionLanguage !== "semaphor_sql_template" && t.push(
|
|
461
|
-
s(
|
|
462
|
-
"invalid_derived_field_expression_language",
|
|
463
|
-
"Derived field expressionLanguage must be semaphor_sql_template.",
|
|
464
|
-
"expressionLanguage"
|
|
465
|
-
)
|
|
466
|
-
), !f(e.inputs) || Object.keys(e.inputs).length === 0 ? t.push(
|
|
467
|
-
s(
|
|
468
|
-
"invalid_derived_field_inputs",
|
|
469
|
-
"Derived field needs at least one typed input.",
|
|
470
|
-
"inputs"
|
|
471
|
-
)
|
|
472
|
-
) : Object.entries(e.inputs).forEach(([o, r]) => {
|
|
473
|
-
if (!m(o)) {
|
|
474
|
-
t.push(
|
|
475
|
-
s(
|
|
476
|
-
"invalid_derived_field_input_name",
|
|
477
|
-
"Derived field input names must be non-empty strings.",
|
|
478
|
-
"inputs"
|
|
479
|
-
)
|
|
480
|
-
);
|
|
481
|
-
return;
|
|
482
|
-
}
|
|
483
|
-
ii(
|
|
484
|
-
r,
|
|
485
|
-
`inputs.${o}`,
|
|
486
|
-
t
|
|
487
|
-
);
|
|
488
|
-
}), m(e.expression) && f(e.inputs)) {
|
|
489
|
-
const o = Ht(
|
|
490
|
-
e.expression
|
|
491
|
-
), r = new Set(o), a = Object.keys(e.inputs).filter(
|
|
492
|
-
(l) => m(l)
|
|
493
|
-
);
|
|
494
|
-
o.forEach((l) => {
|
|
495
|
-
Object.prototype.hasOwnProperty.call(e.inputs, l) || t.push(
|
|
496
|
-
s(
|
|
497
|
-
"invalid_derived_field_expression_token",
|
|
498
|
-
`Derived field expression token "{${l}}" needs a matching inputs.${l} entry.`,
|
|
499
|
-
"expression"
|
|
500
|
-
)
|
|
501
|
-
);
|
|
502
|
-
}), a.forEach((l) => {
|
|
503
|
-
r.has(l) || t.push(
|
|
504
|
-
s(
|
|
505
|
-
"unused_derived_field_input",
|
|
506
|
-
`Derived field input "${l}" is not referenced by expression.`,
|
|
507
|
-
`inputs.${l}`
|
|
508
|
-
)
|
|
509
|
-
);
|
|
510
|
-
});
|
|
511
|
-
}
|
|
512
|
-
const i = e.format;
|
|
513
|
-
return f(i) && i.type === "temporal_bucket" ? t.push(
|
|
514
|
-
s(
|
|
515
|
-
"invalid_derived_field_format",
|
|
516
|
-
"Derived field computation metadata cannot own temporal bucket presentation; declare grain and format on the grouped field.",
|
|
517
|
-
"format"
|
|
518
|
-
)
|
|
519
|
-
) : He(i, "format", t), e.tags !== void 0 && (!Array.isArray(e.tags) || e.tags.some((o) => !m(o))) && t.push(
|
|
520
|
-
s(
|
|
521
|
-
"invalid_derived_field_tags",
|
|
522
|
-
"Derived field tags must be non-empty strings.",
|
|
523
|
-
"tags"
|
|
524
|
-
)
|
|
525
|
-
), { ok: t.length === 0, errors: t, warnings: [] };
|
|
526
|
-
}
|
|
527
|
-
const M = n.string().min(1).refine((e) => e.trim().length > 0, "Must not be blank."), [ni, ai, oi, si] = Le.options, Ge = n.union([
|
|
528
|
-
ni.innerType().omit({ locale: !0 }).strict().superRefine((e, t) => {
|
|
529
|
-
const { minimumFractionDigits: i = 0, maximumFractionDigits: o = 2 } = e;
|
|
530
|
-
(![i, o].every((r) => Number.isInteger(r) && r >= 0 && r <= 20) || i > o) && t.addIssue({
|
|
531
|
-
code: "custom",
|
|
532
|
-
message: "Fraction digits must be integers from 0 to 20 with minimum <= maximum."
|
|
533
|
-
}), e.scale !== void 0 && !Number.isFinite(e.scale) && t.addIssue({ code: "custom", message: "Scale must be finite." });
|
|
534
|
-
}),
|
|
535
|
-
ai.strict(),
|
|
536
|
-
oi.strict(),
|
|
537
|
-
si.strict()
|
|
538
|
-
]), we = n.union([
|
|
539
|
-
Ge,
|
|
540
|
-
U
|
|
541
|
-
]), me = n.union([
|
|
542
|
-
Rt.extend({ domainId: M, datasetName: M }).strict(),
|
|
543
|
-
Tt.extend({ connectionId: M, tableName: M }).strict()
|
|
544
|
-
]), ze = Et.extend({
|
|
545
|
-
name: M,
|
|
546
|
-
source: me.optional()
|
|
547
|
-
}).strict(), fe = Nt.extend({
|
|
548
|
-
format: Ge.optional(),
|
|
549
|
-
inputs: n.record(
|
|
550
|
-
n.object({
|
|
551
|
-
kind: n.literal("field"),
|
|
552
|
-
field: ze,
|
|
553
|
-
aggregate: Ve.optional()
|
|
554
|
-
}).strict()
|
|
555
|
-
)
|
|
556
|
-
}).strict().superRefine((e, t) => {
|
|
557
|
-
var i;
|
|
558
|
-
for (const o of pe(e).errors)
|
|
559
|
-
t.addIssue({
|
|
560
|
-
code: "custom",
|
|
561
|
-
path: ((i = o.path) == null ? void 0 : i.split(".")) ?? [],
|
|
562
|
-
message: o.message
|
|
563
|
-
});
|
|
564
|
-
}), ri = ze.extend({
|
|
565
|
-
derivedField: fe.optional()
|
|
566
|
-
}).strict();
|
|
567
|
-
function ge(e) {
|
|
568
|
-
return typeof e == "string" ? e.trim().toLowerCase() : "";
|
|
569
|
-
}
|
|
570
|
-
function li(e) {
|
|
571
|
-
return String(
|
|
572
|
-
e.column_name || e.name || e.qualifiedFieldName || ""
|
|
573
|
-
);
|
|
574
|
-
}
|
|
575
|
-
function di(e) {
|
|
576
|
-
return Array.from(
|
|
577
|
-
new Set(
|
|
578
|
-
[e.column_name, e.name, e.qualifiedFieldName, e.alias].filter(
|
|
579
|
-
(t) => typeof t == "string" && t.trim().length > 0
|
|
580
|
-
).map((t) => t.trim())
|
|
581
|
-
)
|
|
582
|
-
);
|
|
583
|
-
}
|
|
584
|
-
function he(e) {
|
|
585
|
-
const t = Ke(e);
|
|
586
|
-
return t ? mi(t) ? "number" : t.includes("timestamp") || t.includes("datetime") || t.startsWith("time") ? "datetime" : t.includes("date") ? "date" : t.includes("bool") ? "boolean" : "string" : "unknown";
|
|
587
|
-
}
|
|
588
|
-
const K = /* @__PURE__ */ new Map([
|
|
589
|
-
// Integer families (PostgreSQL, ClickHouse, DuckDB, MySQL).
|
|
590
|
-
["int", "integer"],
|
|
591
|
-
["uint", "integer"],
|
|
592
|
-
["integer", "integer"],
|
|
593
|
-
["uinteger", "integer"],
|
|
594
|
-
["bigint", "integer"],
|
|
595
|
-
["ubigint", "integer"],
|
|
596
|
-
["smallint", "integer"],
|
|
597
|
-
["usmallint", "integer"],
|
|
598
|
-
["tinyint", "integer"],
|
|
599
|
-
["utinyint", "integer"],
|
|
600
|
-
["mediumint", "integer"],
|
|
601
|
-
["hugeint", "integer"],
|
|
602
|
-
["uhugeint", "integer"],
|
|
603
|
-
// Exact decimal families.
|
|
604
|
-
["numeric", "decimal"],
|
|
605
|
-
["decimal", "decimal"],
|
|
606
|
-
// Binary floating point.
|
|
607
|
-
["float", "float"],
|
|
608
|
-
["double", "float"],
|
|
609
|
-
["real", "float"],
|
|
610
|
-
["bfloat16", "float"],
|
|
611
|
-
// Numeric for grounding; storage representation not established
|
|
612
|
-
// (`number(p, s)` with an explicit scale is resolved before this table).
|
|
613
|
-
["number", null],
|
|
614
|
-
["money", null],
|
|
615
|
-
["currency", null],
|
|
616
|
-
["percent", null]
|
|
617
|
-
]), ui = ["int", "uint", "decimal", "float"];
|
|
618
|
-
function ci(e) {
|
|
619
|
-
return e.length > 0 && Array.from(e).every((t) => t >= "0" && t <= "9");
|
|
620
|
-
}
|
|
621
|
-
function pi(e) {
|
|
622
|
-
var i;
|
|
623
|
-
const t = (i = /^number\s*\(\s*\d+\s*,\s*(\d+)\s*\)$/.exec(e)) == null ? void 0 : i[1];
|
|
624
|
-
return t === void 0 ? null : Number(t) === 0 ? "integer" : "decimal";
|
|
625
|
-
}
|
|
626
|
-
function Qe(e) {
|
|
627
|
-
const t = e.split(/[\s(]/, 1)[0] || "";
|
|
628
|
-
if (t === "number")
|
|
629
|
-
return { numeric: !0, kind: pi(e) };
|
|
630
|
-
if (K.has(t))
|
|
631
|
-
return { numeric: !0, kind: K.get(t) ?? null };
|
|
632
|
-
const i = ui.find(
|
|
633
|
-
(o) => t.startsWith(o) && ci(t.slice(o.length))
|
|
634
|
-
);
|
|
635
|
-
return i ? { numeric: !0, kind: K.get(i) ?? null } : { numeric: !1, kind: null };
|
|
636
|
-
}
|
|
637
|
-
function mi(e) {
|
|
638
|
-
return Qe(e).numeric;
|
|
639
|
-
}
|
|
640
|
-
function fi(e) {
|
|
641
|
-
return Qe(Ke(e)).kind;
|
|
642
|
-
}
|
|
643
|
-
function Ke(e) {
|
|
644
|
-
let t = ge(e), i = "";
|
|
645
|
-
for (; t && t !== i; )
|
|
646
|
-
i = t, t = Ae(t, "nullable"), t = Ae(t, "lowcardinality");
|
|
647
|
-
return t;
|
|
648
|
-
}
|
|
649
|
-
function Ae(e, t) {
|
|
650
|
-
const i = `${t}(`;
|
|
651
|
-
return !e.startsWith(i) || !e.endsWith(")") ? e : e.slice(i.length, -1).trim();
|
|
652
|
-
}
|
|
653
|
-
function gi(e) {
|
|
654
|
-
const t = he(e);
|
|
655
|
-
return t === "date" || t === "datetime";
|
|
656
|
-
}
|
|
657
|
-
function Xe(e) {
|
|
658
|
-
return gi(e.dataType || e.data_type);
|
|
659
|
-
}
|
|
660
|
-
function Ze(e) {
|
|
661
|
-
const t = Je(e);
|
|
662
|
-
return t === "id" || t === "row_id";
|
|
663
|
-
}
|
|
664
|
-
function Fe(e) {
|
|
665
|
-
const t = Je(e);
|
|
666
|
-
return Ze(e) || t.endsWith("_id") || t.endsWith("_key") || t.endsWith("_number");
|
|
667
|
-
}
|
|
668
|
-
function Je(e) {
|
|
669
|
-
return ge(
|
|
670
|
-
li(e) || e.name || e.alias
|
|
671
|
-
).replace(/[^a-z0-9]+/g, "_").replace(/^_+|_+$/g, "");
|
|
672
|
-
}
|
|
673
|
-
function We(e, t = {}) {
|
|
674
|
-
const i = ge(e.role);
|
|
675
|
-
return i === "metric" || i === "measure" ? !t.excludeIdentifiers || !Fe(e) : i === "groupby" || i === "dimension" || i === "date" || i === "id" ? !1 : he(
|
|
676
|
-
e.dataType || e.data_type
|
|
677
|
-
) === "number" && (!t.excludeIdentifiers || !Fe(e));
|
|
678
|
-
}
|
|
679
|
-
function na(e) {
|
|
680
|
-
return !We(e) && !Xe(e);
|
|
681
|
-
}
|
|
682
|
-
function aa(e) {
|
|
683
|
-
const t = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), o = /* @__PURE__ */ new Set();
|
|
684
|
-
for (const r of e) {
|
|
685
|
-
if (Ze(r))
|
|
686
|
-
continue;
|
|
687
|
-
const a = di(r);
|
|
688
|
-
if (a.length !== 0) {
|
|
689
|
-
if (Xe(r)) {
|
|
690
|
-
a.forEach((l) => i.add(l));
|
|
691
|
-
continue;
|
|
692
|
-
}
|
|
693
|
-
if (We(r, { excludeIdentifiers: !0 })) {
|
|
694
|
-
a.forEach((l) => t.add(l));
|
|
695
|
-
continue;
|
|
696
|
-
}
|
|
697
|
-
a.forEach((l) => o.add(l));
|
|
698
|
-
}
|
|
699
|
-
}
|
|
700
|
-
return {
|
|
701
|
-
validMeasureCandidates: Array.from(t).sort(),
|
|
702
|
-
validDateCandidates: Array.from(i).sort(),
|
|
703
|
-
validDimensionCandidates: Array.from(o).sort()
|
|
704
|
-
};
|
|
705
|
-
}
|
|
706
|
-
const T = 16 * 1024;
|
|
707
|
-
function L(e) {
|
|
708
|
-
const t = /^([+-]?)(?:(\d+)(?:\.(\d*))?|\.(\d+))(?:[eE]([+-]?\d+))?$/.exec(e);
|
|
709
|
-
return t ? {
|
|
710
|
-
sign: t[1],
|
|
711
|
-
whole: t[2] ?? "",
|
|
712
|
-
fraction: t[3] ?? t[4],
|
|
713
|
-
exponent: Number(t[5] ?? "0")
|
|
714
|
-
} : null;
|
|
715
|
-
}
|
|
716
|
-
function xe(e) {
|
|
717
|
-
const { sign: t, whole: i, fraction: o = "", exponent: r } = e, a = (i + o).replace(/^0+/, ""), l = a.replace(/0+$/, ""), d = r - o.length + a.length - l.length;
|
|
718
|
-
return !Number.isSafeInteger(r) || !Number.isSafeInteger(d) ? null : l ? `${t === "-" ? "-" : ""}${l}e${d}` : "0";
|
|
719
|
-
}
|
|
720
|
-
function hi(e) {
|
|
721
|
-
const t = L(e);
|
|
722
|
-
if (!t) return null;
|
|
723
|
-
const i = t.sign === "+" ? e.slice(1) : e, o = Number(e);
|
|
724
|
-
if (!Number.isFinite(o)) return i;
|
|
725
|
-
const r = xe(t), a = L(String(o));
|
|
726
|
-
return r !== null && a !== null && r === xe(a) ? o : i;
|
|
727
|
-
}
|
|
728
|
-
function _i(e) {
|
|
729
|
-
if (e.length > T)
|
|
730
|
-
throw new RangeError("Exact numeric text exceeds 16 KiB.");
|
|
731
|
-
const t = L(e);
|
|
732
|
-
if (!t) throw new TypeError("Expected finite decimal text.");
|
|
733
|
-
const { sign: i, whole: o, fraction: r, exponent: a } = t, l = `${i}${o || "0"}${r ? `.${r}` : ""}`;
|
|
734
|
-
return F(`${l}e${a}`);
|
|
735
|
-
}
|
|
736
|
-
function F(e) {
|
|
737
|
-
if (e.length > T)
|
|
738
|
-
throw new RangeError("Exact numeric text exceeds 16 KiB.");
|
|
739
|
-
const t = L(e);
|
|
740
|
-
if (!t || t.whole === "" || t.fraction === "")
|
|
741
|
-
throw new TypeError("Expected finite decimal text.");
|
|
742
|
-
const { sign: i, whole: o, fraction: r = "", exponent: a } = t;
|
|
743
|
-
if (!Number.isSafeInteger(a) || Math.abs(a) > T)
|
|
744
|
-
throw new RangeError("Exact numeric exponent exceeds the text budget.");
|
|
745
|
-
const l = o + r, d = o.length + a;
|
|
746
|
-
if (Math.max(l.length, d) + Math.max(0, -d) + 3 > T)
|
|
747
|
-
throw new RangeError("Normalized exact numeric text exceeds 16 KiB.");
|
|
748
|
-
let p;
|
|
749
|
-
d <= 0 ? p = `0.${"0".repeat(-d)}${l}` : d >= l.length ? p = l + "0".repeat(d - l.length) : p = `${l.slice(0, d)}.${l.slice(d)}`;
|
|
750
|
-
const [u, h = ""] = p.split("."), y = u.replace(/^0+(?=\d)/, ""), S = h.replace(/0+$/, ""), _ = y + (S ? `.${S}` : "");
|
|
751
|
-
return i === "-" && _ !== "0" ? `-${_}` : _;
|
|
752
|
-
}
|
|
753
|
-
function et(e, t) {
|
|
754
|
-
const i = e.startsWith("-"), o = t.startsWith("-");
|
|
755
|
-
if (i !== o) return i ? -1 : 1;
|
|
756
|
-
const [r, a = ""] = (i ? e.slice(1) : e).split("."), [l, d = ""] = (o ? t.slice(1) : t).split(".");
|
|
757
|
-
let c = Math.sign(r.length - l.length);
|
|
758
|
-
if (!c && r !== l && (c = r < l ? -1 : 1), !c) {
|
|
759
|
-
const p = Math.max(a.length, d.length), u = a.padEnd(p, "0"), h = d.padEnd(p, "0");
|
|
760
|
-
c = u === h ? 0 : u < h ? -1 : 1;
|
|
761
|
-
}
|
|
762
|
-
return c === 0 ? 0 : i ? -c : c;
|
|
763
|
-
}
|
|
764
|
-
function oa(e, t) {
|
|
765
|
-
if (typeof t == "number" && !Number.isFinite(t))
|
|
766
|
-
throw new TypeError("Numeric scale must be finite.");
|
|
767
|
-
const i = [e, F(String(t))].map((a) => {
|
|
768
|
-
const [l, d = ""] = a.split(".");
|
|
769
|
-
return { coefficient: BigInt(l + d), digits: d.length };
|
|
770
|
-
}), o = i[0].coefficient * i[1].coefficient, r = i[0].digits + i[1].digits;
|
|
771
|
-
return F(`${o}e-${r}`);
|
|
772
|
-
}
|
|
773
|
-
function yi(e) {
|
|
774
|
-
try {
|
|
775
|
-
return F(e) === e;
|
|
776
|
-
} catch {
|
|
777
|
-
return !1;
|
|
778
|
-
}
|
|
779
|
-
}
|
|
780
|
-
const tt = n.object({
|
|
781
|
-
kind: n.literal("exact_number"),
|
|
782
|
-
type: n.enum(["integer", "decimal"]),
|
|
783
|
-
value: n.string().max(T).refine(yi, "Expected canonical decimal text.")
|
|
784
|
-
}).strict().superRefine((e, t) => {
|
|
785
|
-
e.type === "integer" && e.value.includes(".") && t.addIssue({ code: "custom", path: ["value"], message: "An integer cannot have fractional digits." });
|
|
786
|
-
}), B = n.union([
|
|
787
|
-
n.null(),
|
|
788
|
-
n.string(),
|
|
789
|
-
n.boolean(),
|
|
790
|
-
n.number().finite(),
|
|
791
|
-
tt
|
|
792
|
-
]);
|
|
793
|
-
function bi(e, t) {
|
|
794
|
-
return tt.parse({ kind: "exact_number", type: t, value: F(e) });
|
|
795
|
-
}
|
|
796
|
-
function V(e) {
|
|
797
|
-
return typeof e == "object" && e !== null && "kind" in e && e.kind === "exact_number" && "type" in e && (e.type === "integer" || e.type === "decimal") && "value" in e && typeof e.value == "string";
|
|
798
|
-
}
|
|
799
|
-
function sa(e) {
|
|
800
|
-
const t = fi(e.nativeDataType);
|
|
801
|
-
if (!t) throw new TypeError("Numeric result type is not established.");
|
|
802
|
-
if (e.value === null) return null;
|
|
803
|
-
if (t === "float") {
|
|
804
|
-
if (typeof e.value != "number" || !Number.isFinite(e.value))
|
|
805
|
-
throw new TypeError("Expected a finite floating-point result.");
|
|
806
|
-
return e.value;
|
|
807
|
-
}
|
|
808
|
-
if (e.exactText === void 0)
|
|
809
|
-
throw new TypeError("Exact numeric sidecar is required; rounded result values cannot substitute.");
|
|
810
|
-
return bi(e.exactText, t);
|
|
811
|
-
}
|
|
812
|
-
const _e = n.string().uuid(), H = n.enum(["rows", "columns"]), vi = n.enum(["member", "subtotal", "grand_total", "others"]), Ii = n.discriminatedUnion("kind", [
|
|
813
|
-
n.object({ kind: n.literal("value"), value: B }).strict(),
|
|
814
|
-
n.object({ kind: n.literal("others"), rankingId: _e }).strict()
|
|
815
|
-
]), x = n.array(n.object({ levelId: _e, member: Ii }).strict()).readonly().superRefine((e, t) => {
|
|
816
|
-
new Set(e.map((i) => i.levelId)).size !== e.length && t.addIssue({
|
|
817
|
-
code: "custom",
|
|
818
|
-
path: [],
|
|
819
|
-
message: "Duplicate identity."
|
|
820
|
-
}), e.some(
|
|
821
|
-
(i, o) => i.member.kind === "others" && o !== e.length - 1
|
|
822
|
-
) && t.addIssue({
|
|
823
|
-
code: "custom",
|
|
824
|
-
path: [],
|
|
825
|
-
message: "Others is terminal."
|
|
826
|
-
});
|
|
827
|
-
}), ra = n.object({
|
|
828
|
-
rowPath: x,
|
|
829
|
-
columnPath: x,
|
|
830
|
-
measureId: _e
|
|
831
|
-
}).strict();
|
|
832
|
-
function it(e) {
|
|
833
|
-
return JSON.stringify(
|
|
834
|
-
e.map(({ levelId: t, member: i }) => [
|
|
835
|
-
t,
|
|
836
|
-
i.kind === "others" ? ["others", i.rankingId] : typeof i.value == "object" && i.value !== null ? ["exact_number", i.value.value] : [typeof i.value, i.value]
|
|
837
|
-
])
|
|
838
|
-
);
|
|
839
|
-
}
|
|
840
|
-
const te = "SEMAPHOR_CALCULATED_FIELD", Si = "calculated_fields";
|
|
841
|
-
function ki(e) {
|
|
842
|
-
return (e == null ? void 0 : e.sourceField) || (e == null ? void 0 : e.name) || "";
|
|
843
|
-
}
|
|
844
|
-
const wi = [
|
|
845
|
-
// Day granularity formats
|
|
846
|
-
"MM-DD-YYYY",
|
|
847
|
-
"YYYY-MM-DD",
|
|
848
|
-
"MM/DD/YYYY",
|
|
849
|
-
"DD/MM/YYYY",
|
|
850
|
-
"MMMM DD, YYYY",
|
|
851
|
-
"MMM DD, YYYY",
|
|
852
|
-
"DD MMM YYYY",
|
|
853
|
-
"YYYY-MM-DD HH:mm",
|
|
854
|
-
"YYYY-MM-DD HH:mm:ss",
|
|
855
|
-
"YYYY-MM-DD HH:mm Z",
|
|
856
|
-
"YYYY-MM-DD HH:mm:ss Z",
|
|
857
|
-
// Week granularity formats
|
|
858
|
-
"Week of MMM DD, YYYY",
|
|
859
|
-
"Week of MMMM DD, YYYY",
|
|
860
|
-
"YYYY-WW",
|
|
861
|
-
// Month granularity formats
|
|
862
|
-
"MMM YYYY",
|
|
863
|
-
"MMMM YYYY",
|
|
864
|
-
"YYYY-MM",
|
|
865
|
-
"MM/YYYY",
|
|
866
|
-
"YYYY MMM",
|
|
867
|
-
// Quarter granularity formats
|
|
868
|
-
"Q1 YYYY",
|
|
869
|
-
"YYYY Q1",
|
|
870
|
-
"1st Quarter YYYY",
|
|
871
|
-
"YYYY-Q1",
|
|
872
|
-
"Quarter 1, YYYY",
|
|
873
|
-
// Year granularity formats
|
|
874
|
-
"YYYY",
|
|
875
|
-
"YY",
|
|
876
|
-
// Custom format
|
|
877
|
-
"custom"
|
|
878
|
-
];
|
|
879
|
-
function la(e) {
|
|
880
|
-
return e.role === "metric" && "expression" in e && !!e.expression;
|
|
881
|
-
}
|
|
882
|
-
function da(e) {
|
|
883
|
-
return !!e.expression;
|
|
884
|
-
}
|
|
885
|
-
function Ai(e) {
|
|
886
|
-
return !!(e && (e.calculationRepresentation || e.expression || e.derivedField || e.calculatedFieldOrigin || e.calculatedFormula || ie(e)));
|
|
887
|
-
}
|
|
888
|
-
function nt(e) {
|
|
889
|
-
var h, y, S;
|
|
890
|
-
if (!e)
|
|
891
|
-
return {
|
|
892
|
-
representation: "physical",
|
|
893
|
-
ownership: "local",
|
|
894
|
-
completeness: "not-calculated",
|
|
895
|
-
runtimeExecutable: !1,
|
|
896
|
-
legacyManual: !1
|
|
897
|
-
};
|
|
898
|
-
const t = e.fieldScope === "domain" ? "domain" : "local", i = ((h = e.derivedField) == null ? void 0 : h.computeStage) || ((y = e.calculatedFormula) == null ? void 0 : y.computeStage), o = !e.calculatedFormula || Array.isArray(e.calculatedFormula.inputFields) && e.calculatedFormula.inputFields.every((_) => {
|
|
899
|
-
const O = _ && ki(_);
|
|
900
|
-
return typeof O == "string" && !!O.trim();
|
|
901
|
-
}), r = typeof e.expression == "string" && !!e.expression.trim() && o, a = e.calculationRepresentation;
|
|
902
|
-
if (e.derivedField || a === "typed-derived") {
|
|
903
|
-
const _ = e.derivedField !== void 0 && pe(e.derivedField).ok;
|
|
904
|
-
return {
|
|
905
|
-
representation: "typed-derived",
|
|
906
|
-
ownership: t,
|
|
907
|
-
completeness: (!a || a === "typed-derived") && _ && (!e.expression && !e.calculatedFormula || r) ? "complete" : "incomplete",
|
|
908
|
-
computeStage: i,
|
|
909
|
-
runtimeExecutable: r,
|
|
910
|
-
legacyManual: !1
|
|
911
|
-
};
|
|
912
|
-
}
|
|
913
|
-
if (!(!!a || Ai(e)))
|
|
914
|
-
return {
|
|
915
|
-
representation: "physical",
|
|
916
|
-
ownership: t,
|
|
917
|
-
completeness: "not-calculated",
|
|
918
|
-
runtimeExecutable: !1,
|
|
919
|
-
legacyManual: !1
|
|
920
|
-
};
|
|
921
|
-
const d = i || (e.role === "groupby" || ((S = e.calculatedFieldOrigin) == null ? void 0 : S.role) === "groupby" ? "row" : void 0), c = t === "domain" || ie(e) || e.fieldScope === "card" || e.fieldScope === "sheet" || e.fieldScope === "dashboard" ? "manual" : "inline-expression", p = a === "manual" || a === "inline-expression" ? a : c, u = (!a || a === "manual" || a === "inline-expression") && !(a === "inline-expression" && ie(e));
|
|
922
|
-
return {
|
|
923
|
-
representation: p,
|
|
924
|
-
ownership: t,
|
|
925
|
-
completeness: r && u ? "complete" : "incomplete",
|
|
926
|
-
computeStage: d,
|
|
927
|
-
runtimeExecutable: r,
|
|
928
|
-
legacyManual: p === "manual" && t === "local" && !d
|
|
929
|
-
};
|
|
930
|
-
}
|
|
931
|
-
function ua(e) {
|
|
932
|
-
if (e.calculationRepresentation) return e;
|
|
933
|
-
const { representation: t } = nt(e);
|
|
934
|
-
return t === "physical" ? e : { ...e, calculationRepresentation: t };
|
|
935
|
-
}
|
|
936
|
-
function ca(e) {
|
|
937
|
-
return nt(e).computeStage;
|
|
938
|
-
}
|
|
939
|
-
function pa(e, t) {
|
|
940
|
-
return e === "aggregate" && t === "default";
|
|
941
|
-
}
|
|
942
|
-
function ma(e) {
|
|
943
|
-
var i, o;
|
|
944
|
-
const t = e;
|
|
945
|
-
return !!(t != null && t.expression && ((o = (i = t.calculatedFormula) == null ? void 0 : i.inputFields) != null && o.length));
|
|
946
|
-
}
|
|
947
|
-
function fa(e) {
|
|
948
|
-
return !!(e && (e.entityName === te || e.entityId === te));
|
|
949
|
-
}
|
|
950
|
-
function ie(e) {
|
|
951
|
-
return e ? [e.entityName, e.entityId, e.qualifiedEntityName].some(
|
|
952
|
-
(t) => t === te || t === Si
|
|
953
|
-
) : !1;
|
|
954
|
-
}
|
|
955
|
-
function ga(e) {
|
|
956
|
-
return typeof e == "object" && e !== null && e.mode === "last" && e.relativeTo === "latest_data";
|
|
957
|
-
}
|
|
958
|
-
function Fi(e) {
|
|
959
|
-
return e === "between" || e === "not between";
|
|
960
|
-
}
|
|
961
|
-
const G = n.enum(["day", "week", "month", "quarter", "year"]), xi = n.enum(["minute", "hour"]), at = n.number().int().positive(), De = n.number().int(), ot = n.object({
|
|
962
|
-
mode: n.literal("last"),
|
|
963
|
-
n: at,
|
|
964
|
-
unit: xi,
|
|
965
|
-
complete: n.literal(!1).optional(),
|
|
966
|
-
relativeTo: n.literal("latest_data").optional()
|
|
967
|
-
}), st = n.object({
|
|
968
|
-
mode: n.literal("last"),
|
|
969
|
-
n: at,
|
|
970
|
-
unit: G,
|
|
971
|
-
complete: n.boolean().optional(),
|
|
972
|
-
relativeTo: n.literal("latest_data").optional()
|
|
973
|
-
}), rt = n.object({
|
|
974
|
-
mode: n.literal("this"),
|
|
975
|
-
unit: G,
|
|
976
|
-
toDate: n.boolean().optional(),
|
|
977
|
-
boundary: n.enum(["first_day", "last_day"]).optional()
|
|
978
|
-
}), lt = n.object({ mode: n.literal("previous"), unit: G }), dt = n.object({
|
|
979
|
-
mode: n.literal("between"),
|
|
980
|
-
unit: G,
|
|
981
|
-
from: De,
|
|
982
|
-
to: De
|
|
983
|
-
}), ne = {
|
|
984
|
-
check: (e) => e.boundary === void 0 || e.unit === "month",
|
|
985
|
-
message: 'A month boundary requires unit "month".'
|
|
986
|
-
}, Di = n.union([
|
|
987
|
-
ot.strict(),
|
|
988
|
-
st.strict(),
|
|
989
|
-
rt.strict().refine(ne.check, {
|
|
990
|
-
message: ne.message,
|
|
991
|
-
path: ["boundary"]
|
|
992
|
-
}),
|
|
993
|
-
lt.strict(),
|
|
994
|
-
dt.strict()
|
|
995
|
-
]), Mi = n.union([
|
|
996
|
-
ot,
|
|
997
|
-
st,
|
|
998
|
-
rt.refine(ne.check),
|
|
999
|
-
lt,
|
|
1000
|
-
dt
|
|
1001
|
-
]);
|
|
1002
|
-
function ha(e) {
|
|
1003
|
-
const t = Mi.safeParse(e);
|
|
1004
|
-
return t.success ? t.data : void 0;
|
|
1005
|
-
}
|
|
1006
|
-
const [Ri, Ti, Ei, Ni] = Le.options, $i = n.union([
|
|
1007
|
-
Ri.innerType().strict(),
|
|
1008
|
-
Ti.extend({ type: n.literal("date") }).strict(),
|
|
1009
|
-
Ei.strict(),
|
|
1010
|
-
Ni.strict(),
|
|
1011
|
-
U
|
|
1012
|
-
]), I = n.string().min(1), Me = n.enum(["groupby", "metric", "sortby", "pivotby", "detail"]), ut = n.enum([
|
|
1013
|
-
"table",
|
|
1014
|
-
"view",
|
|
1015
|
-
"materialized view",
|
|
1016
|
-
"model",
|
|
1017
|
-
"file",
|
|
1018
|
-
"dataset",
|
|
1019
|
-
"url",
|
|
1020
|
-
"upload"
|
|
1021
|
-
]), X = n.object({
|
|
1022
|
-
connectionId: I,
|
|
1023
|
-
connectionType: n.enum([
|
|
1024
|
-
"GoogleSheets",
|
|
1025
|
-
"FileUpload",
|
|
1026
|
-
"MySQL",
|
|
1027
|
-
"MSSQL",
|
|
1028
|
-
"PostgreSQL",
|
|
1029
|
-
"BigQuery",
|
|
1030
|
-
"Redshift",
|
|
1031
|
-
"Snowflake",
|
|
1032
|
-
"S3",
|
|
1033
|
-
"clickhouse",
|
|
1034
|
-
"API",
|
|
1035
|
-
"none"
|
|
1036
|
-
]),
|
|
1037
|
-
type: ut,
|
|
1038
|
-
name: I,
|
|
1039
|
-
// Grounded relationship plans retain semantic identity and display metadata.
|
|
1040
|
-
// SQL stays server-resolved; it is not accepted inside a join entity.
|
|
1041
|
-
alias: n.string().optional(),
|
|
1042
|
-
id: I.optional(),
|
|
1043
|
-
domainId: I.optional(),
|
|
1044
|
-
datasetType: n.enum(["physical", "virtual"]).optional(),
|
|
1045
|
-
label: n.string().optional(),
|
|
1046
|
-
description: n.string().optional(),
|
|
1047
|
-
dbObjectType: n.string().optional(),
|
|
1048
|
-
database: n.string().optional(),
|
|
1049
|
-
schema: n.string().optional(),
|
|
1050
|
-
dialect: n.enum([
|
|
1051
|
-
"mysql",
|
|
1052
|
-
"postgres",
|
|
1053
|
-
"bigquery",
|
|
1054
|
-
"redshift",
|
|
1055
|
-
"snowflake",
|
|
1056
|
-
"clickhouse",
|
|
1057
|
-
"duckdb",
|
|
1058
|
-
"mssql"
|
|
1059
|
-
]).optional()
|
|
1060
|
-
}).strict(), q = n.lazy(
|
|
1061
|
-
() => n.object({
|
|
1062
|
-
id: I,
|
|
1063
|
-
name: I,
|
|
1064
|
-
label: n.string(),
|
|
1065
|
-
/** Set when `label` was synthesized from `name`; see `Field.derivedLabel`. */
|
|
1066
|
-
derivedLabel: n.string().optional(),
|
|
1067
|
-
qualifiedFieldName: I,
|
|
1068
|
-
dataType: I,
|
|
1069
|
-
entityId: I,
|
|
1070
|
-
entityName: I,
|
|
1071
|
-
entityType: ut,
|
|
1072
|
-
alias: n.string().optional(),
|
|
1073
|
-
sourceField: n.string().optional(),
|
|
1074
|
-
source: me.optional(),
|
|
1075
|
-
nativeDataType: n.string().optional(),
|
|
1076
|
-
description: n.string().optional(),
|
|
1077
|
-
qualifiedEntityName: n.string().optional(),
|
|
1078
|
-
dateFormat: n.enum(wi).optional(),
|
|
1079
|
-
customFormat: n.string().optional(),
|
|
1080
|
-
granularity: ee.optional(),
|
|
1081
|
-
role: Me.optional(),
|
|
1082
|
-
calculationRepresentation: n.enum(["inline-expression", "manual", "typed-derived"]).optional(),
|
|
1083
|
-
calculatedFieldOrigin: n.object({ id: I, role: Me.optional() }).strict().optional(),
|
|
1084
|
-
aggregateOrigin: n.enum(["default", "explicit"]).optional(),
|
|
1085
|
-
labelOrigin: n.enum(["semantic", "override"]).optional(),
|
|
1086
|
-
formatOrigin: n.enum(["semantic", "override"]).optional(),
|
|
1087
|
-
expression: n.string().optional(),
|
|
1088
|
-
derivedField: fe.optional(),
|
|
1089
|
-
format: $i.optional(),
|
|
1090
|
-
semanticTemporalPresentation: n.object({
|
|
1091
|
-
granularity: ee,
|
|
1092
|
-
format: U
|
|
1093
|
-
}).strict().optional(),
|
|
1094
|
-
aggregate: Ve.optional(),
|
|
1095
|
-
fieldScope: n.enum(["card", "sheet", "dashboard", "domain"]).optional(),
|
|
1096
|
-
calculatedFormula: n.object({
|
|
1097
|
-
operation: n.enum([
|
|
1098
|
-
"sum",
|
|
1099
|
-
"difference",
|
|
1100
|
-
"product",
|
|
1101
|
-
"ratio",
|
|
1102
|
-
"change",
|
|
1103
|
-
"percentage",
|
|
1104
|
-
"scale",
|
|
1105
|
-
"custom"
|
|
1106
|
-
]),
|
|
1107
|
-
inputFields: n.array(q),
|
|
1108
|
-
constant: n.number().finite().optional(),
|
|
1109
|
-
computeStage: n.enum(["row", "aggregate"]).optional()
|
|
1110
|
-
}).strict().optional()
|
|
1111
|
-
}).strict()
|
|
1112
|
-
), ji = n.union([
|
|
1113
|
-
n.string(),
|
|
1114
|
-
n.number().finite(),
|
|
1115
|
-
n.boolean(),
|
|
1116
|
-
n.date(),
|
|
1117
|
-
n.null()
|
|
1118
|
-
]), Ci = n.object({
|
|
1119
|
-
id: I,
|
|
1120
|
-
field: q,
|
|
1121
|
-
operator: n.enum([
|
|
1122
|
-
"=",
|
|
1123
|
-
"!=",
|
|
1124
|
-
">",
|
|
1125
|
-
">=",
|
|
1126
|
-
"<",
|
|
1127
|
-
"<=",
|
|
1128
|
-
"contains",
|
|
1129
|
-
"startsWith",
|
|
1130
|
-
"endsWith",
|
|
1131
|
-
"like",
|
|
1132
|
-
"not like",
|
|
1133
|
-
"in",
|
|
1134
|
-
"not in",
|
|
1135
|
-
"between",
|
|
1136
|
-
"not between",
|
|
1137
|
-
"isNull",
|
|
1138
|
-
"isNotNull"
|
|
1139
|
-
]),
|
|
1140
|
-
value: n.union([ji, n.array(n.string()), n.array(n.number().finite())]),
|
|
1141
|
-
label: n.string().optional(),
|
|
1142
|
-
temporalBucket: $t.optional(),
|
|
1143
|
-
relativeMeta: Di.optional(),
|
|
1144
|
-
latestValue: n.literal(!0).optional(),
|
|
1145
|
-
latestValuePolicy: n.literal("snapshot").optional()
|
|
1146
|
-
}).strict().superRefine((e, t) => {
|
|
1147
|
-
const { operator: i, value: o } = e;
|
|
1148
|
-
if ((i === "between" || i === "not between") && (!Array.isArray(o) || o.length !== 2) && t.addIssue({
|
|
1149
|
-
code: "custom",
|
|
1150
|
-
path: ["value"],
|
|
1151
|
-
message: "Between requires two endpoints."
|
|
1152
|
-
}), e.relativeMeta && !Fi(i) && t.addIssue({
|
|
1153
|
-
code: "custom",
|
|
1154
|
-
path: ["relativeMeta"],
|
|
1155
|
-
message: "A relative date requires between or not between."
|
|
1156
|
-
}), e.latestValue) {
|
|
1157
|
-
const a = [e.field.nativeDataType, e.field.dataType].map((l) => he(l)).some((l) => l === "date" || l === "datetime");
|
|
1158
|
-
(i !== "=" || !a) && t.addIssue({
|
|
1159
|
-
code: "custom",
|
|
1160
|
-
path: ["latestValue"],
|
|
1161
|
-
message: "Latest value requires = on a date or timestamp field."
|
|
1162
|
-
});
|
|
1163
|
-
}
|
|
1164
|
-
(i === "in" || i === "not in") && !Array.isArray(o) && t.addIssue({
|
|
1165
|
-
code: "custom",
|
|
1166
|
-
path: ["value"],
|
|
1167
|
-
message: "Membership requires an array."
|
|
1168
|
-
});
|
|
1169
|
-
}), ct = n.lazy(
|
|
1170
|
-
() => n.object({
|
|
1171
|
-
id: I,
|
|
1172
|
-
logicalOperator: n.enum(["AND", "OR"]),
|
|
1173
|
-
negate: n.boolean(),
|
|
1174
|
-
conditions: n.array(Ci),
|
|
1175
|
-
groups: n.array(ct)
|
|
1176
|
-
}).strict()
|
|
1177
|
-
), Oi = n.object({
|
|
1178
|
-
baseEntity: X,
|
|
1179
|
-
joins: n.array(
|
|
1180
|
-
n.object({
|
|
1181
|
-
id: I,
|
|
1182
|
-
source: X,
|
|
1183
|
-
target: X,
|
|
1184
|
-
joinType: n.enum(["INNER", "LEFT", "RIGHT", "FULL"]),
|
|
1185
|
-
sequence: n.number().int().nonnegative(),
|
|
1186
|
-
autoResolved: n.boolean().optional(),
|
|
1187
|
-
relationshipId: n.string().optional(),
|
|
1188
|
-
relationshipName: n.string().optional(),
|
|
1189
|
-
relationshipCardinality: n.enum(["one_to_one", "one_to_many", "many_to_one", "many_to_many"]).optional(),
|
|
1190
|
-
relationshipTraversalDirection: n.enum(["forward", "reverse"]).optional(),
|
|
1191
|
-
joinKeyGroups: n.array(
|
|
1192
|
-
n.object({
|
|
1193
|
-
id: I,
|
|
1194
|
-
operator: n.enum(["AND", "OR"]),
|
|
1195
|
-
keys: n.array(
|
|
1196
|
-
n.object({
|
|
1197
|
-
id: n.string().optional(),
|
|
1198
|
-
source: q,
|
|
1199
|
-
target: q,
|
|
1200
|
-
operator: n.enum(["=", "!=", ">", ">=", "<", "<="])
|
|
1201
|
-
}).strict()
|
|
1202
|
-
).min(1)
|
|
1203
|
-
}).strict()
|
|
1204
|
-
).min(1)
|
|
1205
|
-
}).strict()
|
|
1206
|
-
)
|
|
1207
|
-
}).strict(), Yi = n.object({
|
|
1208
|
-
axis: H,
|
|
1209
|
-
levelId: n.string().uuid().optional(),
|
|
1210
|
-
// Persisted table preferences are edited through Immer; runtime paths remain readonly.
|
|
1211
|
-
oppositePath: x.transform((e) => [...e]).optional()
|
|
1212
|
-
}).strict(), k = n.string().min(1), Pi = n.array(
|
|
1213
|
-
n.enum(["body", "header", "footer", "subtotal", "grandTotal"])
|
|
1214
|
-
), Bi = n.enum(["normal", "medium", "semibold", "bold"]), Li = n.enum(["none", "underline", "line-through"]), pt = n.object({
|
|
1215
|
-
version: n.literal(1),
|
|
1216
|
-
rules: n.array(
|
|
1217
|
-
n.object({
|
|
1218
|
-
id: n.string().min(1),
|
|
1219
|
-
name: n.string().optional(),
|
|
1220
|
-
enabled: n.boolean().optional(),
|
|
1221
|
-
target: n.object({
|
|
1222
|
-
level: n.enum(["cell", "row"]),
|
|
1223
|
-
matrix: Yi.optional(),
|
|
1224
|
-
columnIds: n.array(k).optional(),
|
|
1225
|
-
conditionColumnId: k.optional(),
|
|
1226
|
-
applyToColumnIds: n.array(k).optional(),
|
|
1227
|
-
tableParts: Pi.optional(),
|
|
1228
|
-
rowRoles: n.array(n.string()).optional(),
|
|
1229
|
-
depth: n.number().int().nonnegative().optional(),
|
|
1230
|
-
includeTotals: n.boolean().optional(),
|
|
1231
|
-
includeSubtotals: n.boolean().optional()
|
|
1232
|
-
}).strict(),
|
|
1233
|
-
condition: n.discriminatedUnion("kind", [
|
|
1234
|
-
n.object({
|
|
1235
|
-
kind: n.literal("comparison"),
|
|
1236
|
-
columnId: k,
|
|
1237
|
-
operator: n.enum(["eq", "neq", "gt", "gte", "lt", "lte"]),
|
|
1238
|
-
value: B
|
|
1239
|
-
}).strict(),
|
|
1240
|
-
n.object({
|
|
1241
|
-
kind: n.literal("between"),
|
|
1242
|
-
columnId: k,
|
|
1243
|
-
min: B,
|
|
1244
|
-
max: B,
|
|
1245
|
-
inclusive: n.boolean().optional()
|
|
1246
|
-
}).strict(),
|
|
1247
|
-
n.object({
|
|
1248
|
-
kind: n.literal("blank"),
|
|
1249
|
-
columnId: k,
|
|
1250
|
-
isBlank: n.boolean()
|
|
1251
|
-
}).strict(),
|
|
1252
|
-
n.object({
|
|
1253
|
-
kind: n.literal("contains"),
|
|
1254
|
-
columnId: k,
|
|
1255
|
-
value: n.string(),
|
|
1256
|
-
caseSensitive: n.boolean().optional(),
|
|
1257
|
-
exact: n.boolean().optional()
|
|
1258
|
-
}).strict(),
|
|
1259
|
-
n.object({
|
|
1260
|
-
kind: n.literal("topBottom"),
|
|
1261
|
-
columnId: k,
|
|
1262
|
-
direction: n.enum(["top", "bottom"]),
|
|
1263
|
-
count: n.number().int().positive()
|
|
1264
|
-
}).strict(),
|
|
1265
|
-
n.object({
|
|
1266
|
-
kind: n.literal("colorScale"),
|
|
1267
|
-
columnId: k,
|
|
1268
|
-
range: n.enum(["auto", "manual"]),
|
|
1269
|
-
min: n.number().finite().optional(),
|
|
1270
|
-
mid: n.number().finite().optional(),
|
|
1271
|
-
max: n.number().finite().optional(),
|
|
1272
|
-
colors: n.object({
|
|
1273
|
-
min: n.string(),
|
|
1274
|
-
mid: n.string().optional(),
|
|
1275
|
-
max: n.string()
|
|
1276
|
-
}).strict()
|
|
1277
|
-
}).strict(),
|
|
1278
|
-
n.object({
|
|
1279
|
-
kind: n.literal("dataBar"),
|
|
1280
|
-
columnId: k,
|
|
1281
|
-
range: n.enum(["auto", "manual"]),
|
|
1282
|
-
min: n.number().finite().optional(),
|
|
1283
|
-
max: n.number().finite().optional(),
|
|
1284
|
-
color: n.string(),
|
|
1285
|
-
showValue: n.boolean().optional()
|
|
1286
|
-
}).strict()
|
|
1287
|
-
]),
|
|
1288
|
-
style: n.object({
|
|
1289
|
-
backgroundColor: n.string().optional(),
|
|
1290
|
-
textColor: n.string().optional(),
|
|
1291
|
-
fontWeight: Bi.optional(),
|
|
1292
|
-
italic: n.boolean().optional(),
|
|
1293
|
-
textDecoration: Li.optional(),
|
|
1294
|
-
icon: n.enum(["arrowUp", "arrowDown", "warning", "check", "x"]).optional(),
|
|
1295
|
-
dataBar: n.object({ color: n.string(), showValue: n.boolean() }).strict().optional()
|
|
1296
|
-
}).strict().optional()
|
|
1297
|
-
}).strict()
|
|
1298
|
-
)
|
|
1299
|
-
}).strict();
|
|
1300
|
-
function _a(e, t) {
|
|
1301
|
-
const i = (a) => {
|
|
1302
|
-
if (V(a)) return a.value;
|
|
1303
|
-
const l = typeof a == "string" ? hi(a.trim()) ?? ae(a) : ae(a);
|
|
1304
|
-
if (l === null) return null;
|
|
1305
|
-
try {
|
|
1306
|
-
return _i(String(l));
|
|
1307
|
-
} catch {
|
|
1308
|
-
return null;
|
|
1309
|
-
}
|
|
1310
|
-
}, o = i(e), r = i(t);
|
|
1311
|
-
return o === null || r === null ? null : et(o, r);
|
|
1312
|
-
}
|
|
1313
|
-
function ya(e, t, i) {
|
|
1314
|
-
const o = Ui(e);
|
|
1315
|
-
if (o === null) return null;
|
|
1316
|
-
if (typeof o == "number" && typeof t == "number" && typeof i == "number") {
|
|
1317
|
-
const _ = Hi(o, t, i);
|
|
1318
|
-
return { ratio: _, midpointComparison: Math.sign(_ - 0.5) };
|
|
1319
|
-
}
|
|
1320
|
-
if ([t, i].some((_) => typeof _ == "number" && !Number.isFinite(_))) return null;
|
|
1321
|
-
const r = [o, t, i].map((_) => {
|
|
1322
|
-
const O = typeof _ == "number" ? F(String(_)) : _.value, [Mt, Se = ""] = O.split(".");
|
|
1323
|
-
return { coefficient: Mt + Se, scale: Se.length };
|
|
1324
|
-
}), a = Math.max(...r.map((_) => _.scale)), [l, d, c] = r.map(
|
|
1325
|
-
(_) => BigInt(_.coefficient) * 10n ** BigInt(a - _.scale)
|
|
1326
|
-
), p = c - d, u = l - d;
|
|
1327
|
-
if (p <= 0n)
|
|
1328
|
-
return {
|
|
1329
|
-
ratio: l >= c ? 1 : 0,
|
|
1330
|
-
midpointComparison: l >= c ? 1 : -1
|
|
1331
|
-
};
|
|
1332
|
-
const h = u * 2n - p, y = h < 0n ? -1 : h > 0n ? 1 : 0;
|
|
1333
|
-
return { ratio: u <= 0n ? 0 : u >= p ? 1 : Number(u * 1000000000n / p) / 1e9, midpointComparison: y };
|
|
1334
|
-
}
|
|
1335
|
-
function ba(e) {
|
|
1336
|
-
return !!e && typeof e == "object" && !Array.isArray(e);
|
|
1337
|
-
}
|
|
1338
|
-
function va(e) {
|
|
1339
|
-
return e.enabled !== !1;
|
|
1340
|
-
}
|
|
1341
|
-
function Ia(e) {
|
|
1342
|
-
return e.kind === "topBottom" || e.kind === "colorScale" && e.range === "auto" || e.kind === "dataBar" && e.range === "auto";
|
|
1343
|
-
}
|
|
1344
|
-
function Vi(e) {
|
|
1345
|
-
return e.columnId;
|
|
1346
|
-
}
|
|
1347
|
-
function qi(e) {
|
|
1348
|
-
const t = [Vi(e.condition)];
|
|
1349
|
-
return { validationRefs: [.../* @__PURE__ */ new Set([
|
|
1350
|
-
...t,
|
|
1351
|
-
...e.target.conditionColumnId === void 0 ? [] : [e.target.conditionColumnId],
|
|
1352
|
-
...e.target.columnIds ?? [],
|
|
1353
|
-
...e.target.applyToColumnIds ?? []
|
|
1354
|
-
])], evaluationInputs: t };
|
|
1355
|
-
}
|
|
1356
|
-
function ae(e) {
|
|
1357
|
-
if (typeof e == "number")
|
|
1358
|
-
return Number.isFinite(e) ? e : null;
|
|
1359
|
-
if (typeof e == "string" && e.trim() !== "") {
|
|
1360
|
-
const t = Number(e);
|
|
1361
|
-
return Number.isFinite(t) ? t : null;
|
|
1362
|
-
}
|
|
1363
|
-
return null;
|
|
1364
|
-
}
|
|
1365
|
-
function Ui(e) {
|
|
1366
|
-
return V(e) ? e : ae(e);
|
|
1367
|
-
}
|
|
1368
|
-
function Sa(e) {
|
|
1369
|
-
const t = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set();
|
|
1370
|
-
for (const o of e)
|
|
1371
|
-
V(o) ? i.add(o.value) : t.add(o);
|
|
1372
|
-
return {
|
|
1373
|
-
has: (o) => V(o) ? i.has(o.value) : t.has(o)
|
|
1374
|
-
};
|
|
1375
|
-
}
|
|
1376
|
-
function ka(e, t) {
|
|
1377
|
-
return typeof e == "number" && typeof t == "number" ? Math.sign(e - t) : et(
|
|
1378
|
-
typeof e == "number" ? F(String(e)) : e.value,
|
|
1379
|
-
typeof t == "number" ? F(String(t)) : t.value
|
|
1380
|
-
);
|
|
1381
|
-
}
|
|
1382
|
-
function wa(e) {
|
|
1383
|
-
return e == null || e === "";
|
|
1384
|
-
}
|
|
1385
|
-
function Hi(e, t, i) {
|
|
1386
|
-
return !Number.isFinite(e) || !Number.isFinite(t) || !Number.isFinite(i) ? 0 : i === t ? e >= i ? 1 : 0 : Math.max(0, Math.min(1, (e - t) / (i - t)));
|
|
1387
|
-
}
|
|
1388
|
-
function Gi(e) {
|
|
1389
|
-
switch (e) {
|
|
1390
|
-
case "bold":
|
|
1391
|
-
return 700;
|
|
1392
|
-
case "semibold":
|
|
1393
|
-
return 600;
|
|
1394
|
-
case "medium":
|
|
1395
|
-
return 500;
|
|
1396
|
-
case "normal":
|
|
1397
|
-
return 400;
|
|
1398
|
-
default:
|
|
1399
|
-
return;
|
|
1400
|
-
}
|
|
1401
|
-
}
|
|
1402
|
-
function Aa(e) {
|
|
1403
|
-
return e ? mt({
|
|
1404
|
-
fontWeight: Gi(e.fontWeight),
|
|
1405
|
-
fontStyle: e.italic ? "italic" : void 0,
|
|
1406
|
-
color: e.textColor,
|
|
1407
|
-
backgroundColor: e.backgroundColor,
|
|
1408
|
-
textDecoration: e.textDecoration
|
|
1409
|
-
}) : {};
|
|
1410
|
-
}
|
|
1411
|
-
function Fa(...e) {
|
|
1412
|
-
return Object.assign(
|
|
1413
|
-
{},
|
|
1414
|
-
...e.filter((t) => !!t).map(mt)
|
|
1415
|
-
);
|
|
1416
|
-
}
|
|
1417
|
-
function mt(e) {
|
|
1418
|
-
return Object.fromEntries(
|
|
1419
|
-
Object.entries(e).filter(([, t]) => t !== void 0)
|
|
1420
|
-
);
|
|
1421
|
-
}
|
|
1422
|
-
const v = n.string().uuid(), zi = n.string().min(1), Qi = n.number().int().positive().max(Number.MAX_SAFE_INTEGER), Ki = n.enum([
|
|
1423
|
-
"SUM",
|
|
1424
|
-
"COUNT",
|
|
1425
|
-
"DISTINCT",
|
|
1426
|
-
"AVG",
|
|
1427
|
-
"MIN",
|
|
1428
|
-
"MAX",
|
|
1429
|
-
"MEDIAN"
|
|
1430
|
-
]), ft = ri.omit({
|
|
1431
|
-
aggregate: !0
|
|
1432
|
-
}), Xi = {
|
|
1433
|
-
id: v,
|
|
1434
|
-
field: ft,
|
|
1435
|
-
grain: ee.optional()
|
|
1436
|
-
}, oe = n.object(Xi).strict(), Zi = n.object({
|
|
1437
|
-
id: v,
|
|
1438
|
-
kind: n.literal("aggregate"),
|
|
1439
|
-
field: ft,
|
|
1440
|
-
aggregate: Ki
|
|
1441
|
-
}).strict(), Ji = n.object({
|
|
1442
|
-
id: v,
|
|
1443
|
-
kind: n.literal("calculated"),
|
|
1444
|
-
definition: fe
|
|
1445
|
-
}).strict(), gt = n.discriminatedUnion("kind", [Zi, Ji]), Wi = n.discriminatedUnion("kind", [
|
|
1446
|
-
n.object({ kind: n.literal("member") }).strict(),
|
|
1447
|
-
n.object({
|
|
1448
|
-
kind: n.literal("measure"),
|
|
1449
|
-
measureId: v,
|
|
1450
|
-
oppositePath: x
|
|
1451
|
-
}).strict()
|
|
1452
|
-
]), en = {
|
|
1453
|
-
axis: H,
|
|
1454
|
-
levelId: v,
|
|
1455
|
-
scope: n.discriminatedUnion("kind", [
|
|
1456
|
-
n.object({ kind: n.literal("level") }).strict(),
|
|
1457
|
-
n.object({ kind: n.literal("branch"), parent: x }).strict()
|
|
1458
|
-
]),
|
|
1459
|
-
target: Wi,
|
|
1460
|
-
direction: n.enum(["asc", "desc"]),
|
|
1461
|
-
nulls: n.enum(["first", "last"])
|
|
1462
|
-
}, ht = n.object(en).strict(), tn = n.object({
|
|
1463
|
-
id: v,
|
|
1464
|
-
axis: H,
|
|
1465
|
-
levelId: v,
|
|
1466
|
-
direction: n.enum(["top", "bottom"]),
|
|
1467
|
-
count: Qi,
|
|
1468
|
-
measureId: v,
|
|
1469
|
-
oppositePath: x,
|
|
1470
|
-
others: n.boolean()
|
|
1471
|
-
}).strict(), Z = n.number().finite(), nn = n.object({
|
|
1472
|
-
id: v,
|
|
1473
|
-
axis: H,
|
|
1474
|
-
levelId: v,
|
|
1475
|
-
measureId: v,
|
|
1476
|
-
operator: n.enum(["=", "!=", ">", ">=", "<", "<=", "between", "not between"]),
|
|
1477
|
-
value: n.union([
|
|
1478
|
-
Z,
|
|
1479
|
-
n.tuple([Z, Z]).readonly()
|
|
1480
|
-
])
|
|
1481
|
-
}).strict().superRefine((e, t) => {
|
|
1482
|
-
const i = e.operator === "between" || e.operator === "not between";
|
|
1483
|
-
i !== Array.isArray(e.value) ? g(t, ["value"], i ? "A range condition needs a low and a high bound." : "A comparison needs one number.") : i && e.value[0] > e.value[1] && g(t, ["value"], "The low bound must not exceed the high bound.");
|
|
1484
|
-
}), _t = n.object({
|
|
1485
|
-
source: me,
|
|
1486
|
-
rows: n.array(oe).min(1).readonly(),
|
|
1487
|
-
columns: n.array(oe).readonly(),
|
|
1488
|
-
measures: n.array(gt).min(1).readonly(),
|
|
1489
|
-
filters: ct.optional(),
|
|
1490
|
-
joinPlan: Oi.optional(),
|
|
1491
|
-
relationshipHint: n.object({ relationshipIds: n.array(zi).optional() }).strict().optional(),
|
|
1492
|
-
sorts: n.array(ht).readonly(),
|
|
1493
|
-
rankings: n.array(tn).readonly(),
|
|
1494
|
-
measureFilters: n.array(nn).readonly().optional()
|
|
1495
|
-
}).strict();
|
|
1496
|
-
function yt(e) {
|
|
1497
|
-
return JSON.stringify([
|
|
1498
|
-
e.axis,
|
|
1499
|
-
e.levelId,
|
|
1500
|
-
e.scope.kind,
|
|
1501
|
-
e.scope.kind === "branch" ? it(e.scope.parent) : null
|
|
1502
|
-
]);
|
|
1503
|
-
}
|
|
1504
|
-
function g(e, t, i) {
|
|
1505
|
-
e.addIssue({ code: "custom", path: t, message: i });
|
|
1506
|
-
}
|
|
1507
|
-
function w(e, t, i) {
|
|
1508
|
-
new Set(e).size !== e.length && g(t, i, "Duplicate identity.");
|
|
1509
|
-
}
|
|
1510
|
-
function $(e, t, i, o, r, a = !1) {
|
|
1511
|
-
i.length > e[t].length && g(o, r, "Path exceeds axis depth."), i.forEach((l, d) => {
|
|
1512
|
-
var c;
|
|
1513
|
-
if (l.levelId !== ((c = e[t][d]) == null ? void 0 : c.id) && g(o, [...r, d], "Path must be an ordered axis prefix."), l.member.kind === "others") {
|
|
1514
|
-
const p = l.member.rankingId;
|
|
1515
|
-
(a || d !== i.length - 1 || !e.rankings.some(
|
|
1516
|
-
(u) => u.id === p && u.others && u.axis === t && u.levelId === l.levelId
|
|
1517
|
-
)) && g(
|
|
1518
|
-
o,
|
|
1519
|
-
[...r, d],
|
|
1520
|
-
"Others must terminate a path at its enabled ranking and cannot be a sort/rank target."
|
|
1521
|
-
);
|
|
1522
|
-
}
|
|
1523
|
-
});
|
|
1524
|
-
}
|
|
1525
|
-
function bt(e, t, i, o) {
|
|
1526
|
-
w(t.map(yt), i, o), t.forEach((r, a) => {
|
|
1527
|
-
const l = [...o, a], d = e[r.axis].findIndex((c) => c.id === r.levelId);
|
|
1528
|
-
if (d < 0 && g(i, l, "Sort level is not on its axis."), r.scope.kind === "branch" && ($(
|
|
1529
|
-
e,
|
|
1530
|
-
r.axis,
|
|
1531
|
-
r.scope.parent,
|
|
1532
|
-
i,
|
|
1533
|
-
[...l, "scope", "parent"],
|
|
1534
|
-
!0
|
|
1535
|
-
), r.scope.parent.length !== d && g(
|
|
1536
|
-
i,
|
|
1537
|
-
l,
|
|
1538
|
-
"Branch sort must name the immediate parent of its level."
|
|
1539
|
-
)), r.target.kind === "measure") {
|
|
1540
|
-
const c = r.target.measureId;
|
|
1541
|
-
e.measures.some((p) => p.id === c) || g(i, l, "Unknown sort measure."), $(
|
|
1542
|
-
e,
|
|
1543
|
-
r.axis === "rows" ? "columns" : "rows",
|
|
1544
|
-
r.target.oppositePath,
|
|
1545
|
-
i,
|
|
1546
|
-
[...l, "target", "oppositePath"],
|
|
1547
|
-
!0
|
|
1548
|
-
);
|
|
1549
|
-
}
|
|
1550
|
-
});
|
|
1551
|
-
}
|
|
1552
|
-
function P(e, t, i, o) {
|
|
1553
|
-
e && (e.kind !== t.kind || e.kind === "semantic" && t.kind === "semantic" && e.domainId !== t.domainId || e.kind === "physical" && t.kind === "physical" && e.connectionId !== t.connectionId) && g(
|
|
1554
|
-
i,
|
|
1555
|
-
o,
|
|
1556
|
-
"Field source must belong to the same semantic domain or physical connection."
|
|
1557
|
-
);
|
|
1558
|
-
}
|
|
1559
|
-
function J(e, t, i) {
|
|
1560
|
-
(e.aggregationBehavior === "snapshot" || e.aggregationBehavior === "weighted" || e.aggregationStrategy === "weighted") && g(t, i, "This measure semantic requires a later capability.");
|
|
1561
|
-
}
|
|
1562
|
-
function vt(e, t) {
|
|
1563
|
-
w(
|
|
1564
|
-
[...e.rows, ...e.columns, ...e.measures].map((a) => a.id),
|
|
1565
|
-
t,
|
|
1566
|
-
[]
|
|
1567
|
-
), w(
|
|
1568
|
-
e.rankings.map((a) => a.id),
|
|
1569
|
-
t,
|
|
1570
|
-
["rankings"]
|
|
1571
|
-
), w(
|
|
1572
|
-
e.rankings.map((a) => JSON.stringify([a.axis, a.levelId])),
|
|
1573
|
-
t,
|
|
1574
|
-
["rankings"]
|
|
1575
|
-
);
|
|
1576
|
-
for (const a of ["rows", "columns"])
|
|
1577
|
-
e[a].forEach((l, d) => {
|
|
1578
|
-
l.grain && l.field.dataType !== void 0 && !["date", "datetime", "unknown"].includes(l.field.dataType) && g(t, [a, d, "grain"], "Grain requires a temporal field.");
|
|
1579
|
-
});
|
|
1580
|
-
const i = [
|
|
1581
|
-
...e.rows,
|
|
1582
|
-
...e.columns,
|
|
1583
|
-
...e.measures.filter((a) => a.kind === "aggregate")
|
|
1584
|
-
];
|
|
1585
|
-
for (const a of i)
|
|
1586
|
-
if (P(a.field.source, e.source, t, [
|
|
1587
|
-
a.id,
|
|
1588
|
-
"field",
|
|
1589
|
-
"source"
|
|
1590
|
-
]), a.field.derivedField) {
|
|
1591
|
-
a.field.derivedField.computeStage !== "row" && g(
|
|
1592
|
-
t,
|
|
1593
|
-
[a.id],
|
|
1594
|
-
"Aggregate-stage calculations cannot be grouped or wrapped in an aggregate."
|
|
1595
|
-
), J(a.field.derivedField, t, [a.id]);
|
|
1596
|
-
for (const l of Object.values(a.field.derivedField.inputs))
|
|
1597
|
-
P(l.field.source, e.source, t, [a.id, "inputs"]);
|
|
1598
|
-
}
|
|
1599
|
-
for (const a of e.measures)
|
|
1600
|
-
if (a.kind === "calculated") {
|
|
1601
|
-
(a.definition.computeStage !== "aggregate" || a.definition.resultRole !== "measure") && g(
|
|
1602
|
-
t,
|
|
1603
|
-
[a.id],
|
|
1604
|
-
"Calculated measures require aggregate stage and measure role."
|
|
1605
|
-
), J(a.definition, t, [a.id]);
|
|
1606
|
-
for (const l of Object.values(a.definition.inputs))
|
|
1607
|
-
P(l.field.source, e.source, t, [
|
|
1608
|
-
a.id,
|
|
1609
|
-
"inputs"
|
|
1610
|
-
]);
|
|
1611
|
-
}
|
|
1612
|
-
const o = (a) => {
|
|
1613
|
-
const l = (d, c) => {
|
|
1614
|
-
var p, u;
|
|
1615
|
-
if ((d.aggregate || ((p = d.derivedField) == null ? void 0 : p.computeStage) === "aggregate") && g(t, c, "Aggregate/HAVING filters are not supported."), d.derivedField) {
|
|
1616
|
-
J(d.derivedField, t, c);
|
|
1617
|
-
for (const h of Object.values(d.derivedField.inputs))
|
|
1618
|
-
P(h.field.source, e.source, t, c);
|
|
1619
|
-
}
|
|
1620
|
-
for (const h of ((u = d.calculatedFormula) == null ? void 0 : u.inputFields) ?? [])
|
|
1621
|
-
l(h, c);
|
|
1622
|
-
};
|
|
1623
|
-
for (const d of a.conditions)
|
|
1624
|
-
l(d.field, ["filters", d.id]);
|
|
1625
|
-
a.groups.forEach(o);
|
|
1626
|
-
};
|
|
1627
|
-
if (e.filters && o(e.filters), e.joinPlan) {
|
|
1628
|
-
const a = [
|
|
1629
|
-
e.joinPlan.baseEntity,
|
|
1630
|
-
...e.joinPlan.joins.flatMap((l) => [l.source, l.target])
|
|
1631
|
-
];
|
|
1632
|
-
(new Set(a.map((l) => l.connectionId)).size > 1 || e.source.kind === "physical" && a[0].connectionId !== e.source.connectionId) && g(t, ["joinPlan"], "Joins must stay within the source connection."), w(
|
|
1633
|
-
e.joinPlan.joins.map((l) => l.id),
|
|
1634
|
-
t,
|
|
1635
|
-
["joinPlan", "joins"]
|
|
1636
|
-
);
|
|
1637
|
-
}
|
|
1638
|
-
bt(e, e.sorts, t, ["sorts"]);
|
|
1639
|
-
const r = e.measureFilters ?? [];
|
|
1640
|
-
w(r.map((a) => a.id), t, ["measureFilters"]), w(
|
|
1641
|
-
r.map((a) => JSON.stringify([a.axis, a.levelId])),
|
|
1642
|
-
t,
|
|
1643
|
-
["measureFilters"]
|
|
1644
|
-
), r.forEach((a, l) => {
|
|
1645
|
-
(!e[a.axis].some((d) => d.id === a.levelId) || !e.measures.some((d) => d.id === a.measureId)) && g(t, ["measureFilters", l], "Unknown measure filter level or measure.");
|
|
1646
|
-
}), e.rankings.forEach((a, l) => {
|
|
1647
|
-
(!e[a.axis].some((d) => d.id === a.levelId) || !e.measures.some((d) => d.id === a.measureId)) && g(t, ["rankings", l], "Unknown ranking level or measure."), $(
|
|
1648
|
-
e,
|
|
1649
|
-
a.axis === "rows" ? "columns" : "rows",
|
|
1650
|
-
a.oppositePath,
|
|
1651
|
-
t,
|
|
1652
|
-
["rankings", l, "oppositePath"],
|
|
1653
|
-
!0
|
|
1654
|
-
);
|
|
1655
|
-
});
|
|
1656
|
-
}
|
|
1657
|
-
const C = _t.superRefine(vt), an = _t.extend({
|
|
1658
|
-
rows: n.array(oe).readonly(),
|
|
1659
|
-
measures: n.array(gt).readonly()
|
|
1660
|
-
}), on = an.superRefine(vt), sn = C.innerType().extend({ kind: n.literal("matrix") }), rn = sn.superRefine(({ kind: e, ...t }, i) => {
|
|
1661
|
-
const o = C.safeParse(t);
|
|
1662
|
-
o.success || o.error.issues.forEach((r) => i.addIssue(r));
|
|
1663
|
-
}), ln = "{member}", Re = n.object({
|
|
1664
|
-
visible: n.boolean(),
|
|
1665
|
-
position: n.enum(["before", "after"]),
|
|
1666
|
-
/** As written; a subtotal's `{member}` becomes its member's name. */
|
|
1667
|
-
label: n.string().optional()
|
|
1668
|
-
}).strict(), Te = n.object({
|
|
1669
|
-
grand: Re,
|
|
1670
|
-
levels: n.record(v, Re).readonly(),
|
|
1671
|
-
/**
|
|
1672
|
-
* Skip a subtotal that only repeats one row: an expanded group with
|
|
1673
|
-
* exactly one child shows no subtotal. Off when absent.
|
|
1674
|
-
*/
|
|
1675
|
-
skipRedundant: n.boolean().optional()
|
|
1676
|
-
}).strict(), Ee = pt.shape.rules.element, dn = pt.extend({
|
|
1677
|
-
rules: n.array(Ee.extend({
|
|
1678
|
-
target: Ee.shape.target.extend({
|
|
1679
|
-
rowRoles: n.array(vi).optional()
|
|
1680
|
-
})
|
|
1681
|
-
}))
|
|
1682
|
-
}).superRefine((e, t) => {
|
|
1683
|
-
var i;
|
|
1684
|
-
w(e.rules.map((o) => o.id), t, ["rules"]);
|
|
1685
|
-
for (const o of e.rules) {
|
|
1686
|
-
const r = o.condition;
|
|
1687
|
-
r.kind === "topBottom" && g(
|
|
1688
|
-
t,
|
|
1689
|
-
["rules", o.id],
|
|
1690
|
-
"Relative highlighting is deferred."
|
|
1691
|
-
), (r.kind === "dataBar" || r.kind === "colorScale") && ((r.range !== "manual" || r.min === void 0 || r.max === void 0 || r.min >= r.max) && g(
|
|
1692
|
-
t,
|
|
1693
|
-
["rules", o.id],
|
|
1694
|
-
"Explicit increasing range endpoints are required."
|
|
1695
|
-
), r.kind === "colorScale" && r.mid !== void 0 && (r.mid <= r.min || r.mid >= r.max) && g(
|
|
1696
|
-
t,
|
|
1697
|
-
["rules", o.id],
|
|
1698
|
-
"Midpoint must be inside the range."
|
|
1699
|
-
)), (i = o.style) != null && i.dataBar && g(
|
|
1700
|
-
t,
|
|
1701
|
-
["rules", o.id],
|
|
1702
|
-
"Use an explicit-range dataBar condition."
|
|
1703
|
-
);
|
|
1704
|
-
}
|
|
1705
|
-
});
|
|
1706
|
-
function un(e, t, i, o, r = []) {
|
|
1707
|
-
for (const a of e.rules) {
|
|
1708
|
-
const l = [...r, "rules", a.id], d = a.target.matrix;
|
|
1709
|
-
d && (d.levelId !== void 0 && !t[d.axis].some((c) => c.id === d.levelId) && g(o, [...l, "target", "matrix", "levelId"], "Conditional-format level is not on the selected axis."), d.oppositePath !== void 0 && $(t, d.axis === "rows" ? "columns" : "rows", d.oppositePath, o, [...l, "target", "matrix", "oppositePath"])), qi(a).validationRefs.some((c) => !i.has(c)) && g(o, l, "Conditional rules must reference displayed measures.");
|
|
1710
|
-
}
|
|
1711
|
-
}
|
|
1712
|
-
const cn = {
|
|
1713
|
-
layout: n.discriminatedUnion("kind", [
|
|
1714
|
-
n.object({ kind: n.literal("compact") }).strict(),
|
|
1715
|
-
n.object({ kind: n.literal("tabular"), repeatLabels: n.boolean() }).strict()
|
|
1716
|
-
]),
|
|
1717
|
-
absence: n.object({ emptyText: n.string(), nullText: n.string() }).strict(),
|
|
1718
|
-
levelLabels: n.record(v, n.string()).readonly(),
|
|
1719
|
-
measureLabels: n.record(v, n.string()).readonly(),
|
|
1720
|
-
levelFormats: n.record(v, we).readonly(),
|
|
1721
|
-
measureFormats: n.record(v, we).readonly(),
|
|
1722
|
-
totals: n.object({ rows: Te, columns: Te }).strict(),
|
|
1723
|
-
conditionalFormatting: dn.optional()
|
|
1724
|
-
}, ye = n.object(cn).strict(), pn = n.object({
|
|
1725
|
-
depth: n.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER),
|
|
1726
|
-
overrides: n.array(
|
|
1727
|
-
n.object({ path: x, expanded: n.boolean() }).strict()
|
|
1728
|
-
).readonly()
|
|
1729
|
-
}).strict(), Ne = pn.superRefine(
|
|
1730
|
-
(e, t) => w(
|
|
1731
|
-
e.overrides.map((i) => it(i.path)),
|
|
1732
|
-
t,
|
|
1733
|
-
["overrides"]
|
|
1734
|
-
)
|
|
1735
|
-
), mn = { rows: Ne, columns: Ne }, z = n.object(mn).strict(), fn = z.extend({ sorts: n.array(ht).readonly() }).strict(), gn = fn.superRefine(
|
|
1736
|
-
(e, t) => w(e.sorts.map(yt), t, ["sorts"])
|
|
1737
|
-
);
|
|
1738
|
-
function Q(e, t) {
|
|
1739
|
-
var c, p;
|
|
1740
|
-
const { spec: i, presentation: o, defaults: r, session: a } = e, l = new Set([...i.rows, ...i.columns].map((u) => u.id)), d = new Set(i.measures.map((u) => u.id));
|
|
1741
|
-
for (const u of [
|
|
1742
|
-
"levelLabels",
|
|
1743
|
-
"levelFormats",
|
|
1744
|
-
"measureLabels",
|
|
1745
|
-
"measureFormats"
|
|
1746
|
-
]) {
|
|
1747
|
-
const h = u.startsWith("level") ? l : d;
|
|
1748
|
-
for (const y of Object.keys(o[u]))
|
|
1749
|
-
h.has(y) || g(
|
|
1750
|
-
t,
|
|
1751
|
-
["presentation", u, y],
|
|
1752
|
-
"Unknown presentation reference."
|
|
1753
|
-
);
|
|
1754
|
-
}
|
|
1755
|
-
for (const [u, h] of Object.entries(o.measureFormats))
|
|
1756
|
-
h.type === "temporal_bucket" && g(
|
|
1757
|
-
t,
|
|
1758
|
-
["presentation", "measureFormats", u],
|
|
1759
|
-
"Measures cannot own temporal bucket formats."
|
|
1760
|
-
);
|
|
1761
|
-
for (const [u, h] of Object.entries(o.levelFormats))
|
|
1762
|
-
h.type === "temporal_bucket" && !((c = [...i.rows, ...i.columns].find((y) => y.id === u)) != null && c.grain) && g(
|
|
1763
|
-
t,
|
|
1764
|
-
["presentation", "levelFormats", u],
|
|
1765
|
-
"Temporal bucket formats require a grain."
|
|
1766
|
-
);
|
|
1767
|
-
for (const u of ["rows", "columns"]) {
|
|
1768
|
-
(p = o.totals[u].grand.label) != null && p.includes(
|
|
1769
|
-
ln
|
|
1770
|
-
) && g(
|
|
1771
|
-
t,
|
|
1772
|
-
["presentation", "totals", u, "grand", "label"],
|
|
1773
|
-
"The grand total has no member, so its label cannot use {member}."
|
|
1774
|
-
);
|
|
1775
|
-
const h = Object.keys(o.totals[u].levels);
|
|
1776
|
-
(h.length !== i[u].length || h.some((y) => !i[u].some((S) => S.id === y))) && g(
|
|
1777
|
-
t,
|
|
1778
|
-
["presentation", "totals", u],
|
|
1779
|
-
"Subtotal map must contain exactly the current axis levels."
|
|
1780
|
-
);
|
|
1781
|
-
for (const y of [r, ...a ? [a] : []])
|
|
1782
|
-
for (const S of y[u].overrides)
|
|
1783
|
-
$(
|
|
1784
|
-
i,
|
|
1785
|
-
u,
|
|
1786
|
-
S.path,
|
|
1787
|
-
t,
|
|
1788
|
-
[u, "overrides"],
|
|
1789
|
-
!0
|
|
1790
|
-
), S.path.length || g(
|
|
1791
|
-
t,
|
|
1792
|
-
[u, "overrides"],
|
|
1793
|
-
"Use depth to expand/collapse the root."
|
|
1794
|
-
);
|
|
1795
|
-
}
|
|
1796
|
-
a && bt(i, a.sorts, t, ["session", "sorts"]), o.conditionalFormatting && un(
|
|
1797
|
-
o.conditionalFormatting,
|
|
1798
|
-
i,
|
|
1799
|
-
d,
|
|
1800
|
-
t,
|
|
1801
|
-
["presentation", "conditionalFormatting"]
|
|
1802
|
-
);
|
|
1803
|
-
}
|
|
1804
|
-
const hn = n.object({
|
|
1805
|
-
spec: C,
|
|
1806
|
-
presentation: ye,
|
|
1807
|
-
defaults: z,
|
|
1808
|
-
session: gn.optional()
|
|
1809
|
-
}).strict(), xa = hn.superRefine(Q), _n = n.object({
|
|
1810
|
-
version: n.literal(1),
|
|
1811
|
-
spec: C,
|
|
1812
|
-
presentation: ye,
|
|
1813
|
-
defaultView: z
|
|
1814
|
-
}).strict(), yn = _n.superRefine(
|
|
1815
|
-
(e, t) => Q({ ...e, defaults: e.defaultView }, t)
|
|
1816
|
-
), bn = yn.innerType().extend({
|
|
1817
|
-
spec: on
|
|
1818
|
-
}), Da = bn.superRefine((e, t) => Q({ ...e, defaults: e.defaultView }, t)), $e = n.object({ spec: C, presentation: ye }).strict(), vn = n.union([
|
|
1819
|
-
$e.extend({
|
|
1820
|
-
mode: n.literal("layout"),
|
|
1821
|
-
format: n.enum(["csv", "xlsx", "pdf"]),
|
|
1822
|
-
expansion: n.union([
|
|
1823
|
-
z.extend({ kind: n.literal("current") }).strict(),
|
|
1824
|
-
n.object({ kind: n.literal("all") }).strict()
|
|
1825
|
-
])
|
|
1826
|
-
}).strict(),
|
|
1827
|
-
$e.extend({ mode: n.literal("flat"), format: n.enum(["csv", "xlsx"]) }).strict()
|
|
1828
|
-
]), Ma = vn.superRefine(
|
|
1829
|
-
(e, t) => Q(
|
|
1830
|
-
{
|
|
1831
|
-
...e,
|
|
1832
|
-
defaults: e.mode === "layout" && e.expansion.kind === "current" ? e.expansion : {
|
|
1833
|
-
rows: { depth: 0, overrides: [] },
|
|
1834
|
-
columns: { depth: 0, overrides: [] }
|
|
1835
|
-
}
|
|
1836
|
-
},
|
|
1837
|
-
t
|
|
1838
|
-
)
|
|
1839
|
-
);
|
|
1840
|
-
function Ra(e) {
|
|
1841
|
-
return e && "id" in e ? e.id : void 0;
|
|
1842
|
-
}
|
|
1843
|
-
const In = "SUM";
|
|
1844
|
-
function A(e) {
|
|
1845
|
-
return typeof e == "string" && e.trim().length > 0;
|
|
1846
|
-
}
|
|
1847
|
-
function E(e) {
|
|
1848
|
-
return A(e) ? e.trim().toLowerCase() : "";
|
|
1849
|
-
}
|
|
1850
|
-
function Ta(e) {
|
|
1851
|
-
const t = A(e.id) ? e.id.trim() : void 0;
|
|
1852
|
-
if (!t) return;
|
|
1853
|
-
const i = E(t), o = A(e.table) ? e.table.trim() : void 0;
|
|
1854
|
-
if (!(i === E(e.name) || o && i === E(o)))
|
|
1855
|
-
return t;
|
|
1856
|
-
}
|
|
1857
|
-
function D(e) {
|
|
1858
|
-
const t = A(e.datasetId) ? e.datasetId.trim() : void 0;
|
|
1859
|
-
if (t)
|
|
1860
|
-
return E(t) === E(e.datasetName) ? void 0 : t;
|
|
1861
|
-
}
|
|
1862
|
-
function It(e) {
|
|
1863
|
-
if (e.kind !== "semantic") return e;
|
|
1864
|
-
const t = D(e), { datasetId: i, ...o } = e;
|
|
1865
|
-
return {
|
|
1866
|
-
...o,
|
|
1867
|
-
...t ? { datasetId: t } : {}
|
|
1868
|
-
};
|
|
1869
|
-
}
|
|
1870
|
-
function Ea(e) {
|
|
1871
|
-
return e ? e.kind === "semantic" ? !!(A(e.domainId) && (A(e.datasetId) || A(e.datasetName))) : e.kind === "physical" ? A(e.connectionId) && A(e.tableName) : A(e.connectionId) : !1;
|
|
1872
|
-
}
|
|
1873
|
-
function se(e) {
|
|
1874
|
-
if (!e)
|
|
1875
|
-
return "";
|
|
1876
|
-
if (e.kind === "semantic") {
|
|
1877
|
-
const t = D(e);
|
|
1878
|
-
return [
|
|
1879
|
-
e.kind,
|
|
1880
|
-
e.domainId,
|
|
1881
|
-
t ? `datasetId:${t}` : `datasetName:${e.datasetName}`
|
|
1882
|
-
].join(":");
|
|
1883
|
-
}
|
|
1884
|
-
return e.kind === "physical" ? [
|
|
1885
|
-
e.kind,
|
|
1886
|
-
e.connectionId,
|
|
1887
|
-
e.databaseName || "",
|
|
1888
|
-
e.schemaName || "",
|
|
1889
|
-
e.tableName
|
|
1890
|
-
].join(":") : [
|
|
1891
|
-
e.kind,
|
|
1892
|
-
e.connectionId,
|
|
1893
|
-
e.dialect || "",
|
|
1894
|
-
e.label || ""
|
|
1895
|
-
].join(":");
|
|
1896
|
-
}
|
|
1897
|
-
function be(e, t) {
|
|
1898
|
-
if (!e || !t)
|
|
1899
|
-
return e === t;
|
|
1900
|
-
if (e.kind !== t.kind)
|
|
1901
|
-
return !1;
|
|
1902
|
-
if (e.kind === "semantic" && t.kind === "semantic") {
|
|
1903
|
-
if (e.domainId !== t.domainId)
|
|
1904
|
-
return !1;
|
|
1905
|
-
const i = D(e), o = D(t);
|
|
1906
|
-
return i && o ? i === o : e.datasetName === t.datasetName;
|
|
1907
|
-
}
|
|
1908
|
-
return se(e) === se(t);
|
|
1909
|
-
}
|
|
1910
|
-
function St(e, t) {
|
|
1911
|
-
return e.kind !== "semantic" || t.kind !== "semantic" ? e : It({
|
|
1912
|
-
...e,
|
|
1913
|
-
datasetName: e.datasetName || t.datasetName,
|
|
1914
|
-
datasetId: D(e) || D(t),
|
|
1915
|
-
label: e.label || t.label,
|
|
1916
|
-
connectionId: e.connectionId || t.connectionId
|
|
1917
|
-
});
|
|
1918
|
-
}
|
|
1919
|
-
function Na(e) {
|
|
1920
|
-
const t = [];
|
|
1921
|
-
for (const i of e) {
|
|
1922
|
-
const o = It(
|
|
1923
|
-
i
|
|
1924
|
-
), r = t.findIndex(
|
|
1925
|
-
(a) => be(a, o)
|
|
1926
|
-
);
|
|
1927
|
-
if (r === -1) {
|
|
1928
|
-
t.push(o);
|
|
1929
|
-
continue;
|
|
1930
|
-
}
|
|
1931
|
-
t[r] = St(
|
|
1932
|
-
t[r],
|
|
1933
|
-
o
|
|
1934
|
-
);
|
|
1935
|
-
}
|
|
1936
|
-
return t;
|
|
1937
|
-
}
|
|
1938
|
-
function Sn(e, t) {
|
|
1939
|
-
return e.name === t.name && be(e.source, t.source);
|
|
1940
|
-
}
|
|
1941
|
-
function $a(e) {
|
|
1942
|
-
return [
|
|
1943
|
-
e.source ? se(e.source) : "unknown",
|
|
1944
|
-
kt(e),
|
|
1945
|
-
e.name
|
|
1946
|
-
].filter(Boolean).join(":");
|
|
1947
|
-
}
|
|
1948
|
-
function kt(e) {
|
|
1949
|
-
return kn(
|
|
1950
|
-
e.aggregate || In
|
|
1951
|
-
);
|
|
1952
|
-
}
|
|
1953
|
-
function kn(e) {
|
|
1954
|
-
return e.trim().toUpperCase();
|
|
1955
|
-
}
|
|
1956
|
-
function ja(e, t) {
|
|
1957
|
-
return {
|
|
1958
|
-
...e,
|
|
1959
|
-
label: e.label || t.label,
|
|
1960
|
-
role: e.role || t.role,
|
|
1961
|
-
dataType: e.dataType || t.dataType,
|
|
1962
|
-
source: e.source && t.source ? St(e.source, t.source) : e.source || t.source
|
|
1963
|
-
};
|
|
1964
|
-
}
|
|
1965
|
-
function wn(e) {
|
|
1966
|
-
for (let t = 0; t < e.length; t += 1) {
|
|
1967
|
-
const i = e[t];
|
|
1968
|
-
if (e.some(
|
|
1969
|
-
(o, r) => r !== t && At(o, i)
|
|
1970
|
-
))
|
|
1971
|
-
return !1;
|
|
1972
|
-
}
|
|
1973
|
-
return !0;
|
|
1974
|
-
}
|
|
1975
|
-
function wt(e, t) {
|
|
1976
|
-
return Sn(e, t);
|
|
1977
|
-
}
|
|
1978
|
-
function At(e, t) {
|
|
1979
|
-
return wt(e, t) && j(e) === j(t);
|
|
1980
|
-
}
|
|
1981
|
-
function An(e) {
|
|
1982
|
-
return `Metric intent has duplicate measure "${e.name}" with the same aggregate (${j(e)}). Use different aggregates to request both, or remove one entry.`;
|
|
1983
|
-
}
|
|
1984
|
-
function je(e) {
|
|
1985
|
-
return typeof e == "string" || typeof e == "number" || typeof e == "boolean" || e === null;
|
|
1986
|
-
}
|
|
1987
|
-
function Fn(e, t, i) {
|
|
1988
|
-
if (e !== void 0) {
|
|
1989
|
-
if (!e || typeof e != "object" || Array.isArray(e)) {
|
|
1990
|
-
i.push(
|
|
1991
|
-
s(
|
|
1992
|
-
"invalid_sql_default_parameters",
|
|
1993
|
-
"SQL defaultParameters must be an object keyed by parameter name.",
|
|
1994
|
-
t
|
|
1995
|
-
)
|
|
1996
|
-
);
|
|
1997
|
-
return;
|
|
1998
|
-
}
|
|
1999
|
-
Object.entries(e).forEach(([o, r]) => {
|
|
2000
|
-
if (!o.trim()) {
|
|
2001
|
-
i.push(
|
|
2002
|
-
s(
|
|
2003
|
-
"invalid_sql_default_parameter_name",
|
|
2004
|
-
"SQL defaultParameters names must be non-empty strings.",
|
|
2005
|
-
`${t}.${o}`
|
|
2006
|
-
)
|
|
2007
|
-
);
|
|
2008
|
-
return;
|
|
2009
|
-
}
|
|
2010
|
-
(Array.isArray(r) ? r.every(je) : je(r)) || i.push(
|
|
2011
|
-
s(
|
|
2012
|
-
"invalid_sql_default_parameter_value",
|
|
2013
|
-
"SQL defaultParameters values must be strings, numbers, booleans, nulls, or arrays of those scalar values.",
|
|
2014
|
-
`${t}.${o}`
|
|
2015
|
-
)
|
|
2016
|
-
);
|
|
2017
|
-
});
|
|
2018
|
-
}
|
|
2019
|
-
}
|
|
2020
|
-
function xn(e, t) {
|
|
2021
|
-
return ve(e, t).length === 1;
|
|
2022
|
-
}
|
|
2023
|
-
function Dn(e, t) {
|
|
2024
|
-
return ve(e, t).length === 1;
|
|
2025
|
-
}
|
|
2026
|
-
function ve(e, t) {
|
|
2027
|
-
return t.filter(
|
|
2028
|
-
(o) => Mn(e, o)
|
|
2029
|
-
);
|
|
2030
|
-
}
|
|
2031
|
-
function Mn(e, t) {
|
|
2032
|
-
return Rn(e, t) ? e.source ? wt(t, e) : !0 : !1;
|
|
2033
|
-
}
|
|
2034
|
-
function Rn(e, t) {
|
|
2035
|
-
return !(t.name !== e.name || e.role !== void 0 && t.role !== void 0 && t.role !== e.role || Tn(e, t) && j(t) !== j(e));
|
|
2036
|
-
}
|
|
2037
|
-
function Tn(e, t) {
|
|
2038
|
-
return e.role === "measure" || t.role === "measure" || e.aggregate !== void 0 || t.aggregate !== void 0;
|
|
2039
|
-
}
|
|
2040
|
-
function j(e) {
|
|
2041
|
-
return kt(e);
|
|
2042
|
-
}
|
|
2043
|
-
const En = /^(\d{4})-(\d{2})-(\d{2})$/, Ft = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})(?::(\d{2})(?:\.(\d+))?)?(Z|[+-]\d{2}:\d{2})$/;
|
|
2044
|
-
function re(e) {
|
|
2045
|
-
if (typeof e != "string")
|
|
2046
|
-
return null;
|
|
2047
|
-
const t = e.trim(), i = En.exec(t);
|
|
2048
|
-
if (i) {
|
|
2049
|
-
const [, y, S, _] = i;
|
|
2050
|
-
return Ce(y, S, _) ? new Date(Date.UTC(Number(y), Number(S) - 1, Number(_))) : null;
|
|
2051
|
-
}
|
|
2052
|
-
const o = Ft.exec(t);
|
|
2053
|
-
if (!o)
|
|
2054
|
-
return null;
|
|
2055
|
-
const [, r, a, l, d, c, p = "00", , u] = o;
|
|
2056
|
-
if (!Ce(r, a, l) || !N(d, 0, 23) || !N(c, 0, 59) || !N(p, 0, 59) || !Nn(u))
|
|
2057
|
-
return null;
|
|
2058
|
-
const h = new Date(t);
|
|
2059
|
-
return Number.isFinite(h.getTime()) ? h : null;
|
|
2060
|
-
}
|
|
2061
|
-
function Ca(e) {
|
|
2062
|
-
return typeof e != "string" || !Ft.test(e.trim()) ? null : re(e);
|
|
2063
|
-
}
|
|
2064
|
-
function Ce(e, t, i) {
|
|
2065
|
-
const o = Number(e), r = Number(t), a = Number(i);
|
|
2066
|
-
if (!Number.isInteger(o) || !Number.isInteger(r) || !Number.isInteger(a) || r < 1 || r > 12)
|
|
2067
|
-
return !1;
|
|
2068
|
-
const l = new Date(Date.UTC(o, r - 1, a));
|
|
2069
|
-
return l.getUTCFullYear() === o && l.getUTCMonth() === r - 1 && l.getUTCDate() === a;
|
|
2070
|
-
}
|
|
2071
|
-
function N(e, t, i) {
|
|
2072
|
-
const o = Number(e);
|
|
2073
|
-
return Number.isInteger(o) && o >= t && o <= i;
|
|
2074
|
-
}
|
|
2075
|
-
function Nn(e) {
|
|
2076
|
-
if (e === "Z")
|
|
2077
|
-
return !0;
|
|
2078
|
-
const t = /^([+-])(\d{2}):(\d{2})$/.exec(e);
|
|
2079
|
-
return !!(t && N(t[2], 0, 23) && N(t[3], 0, 59));
|
|
2080
|
-
}
|
|
2081
|
-
function Oe(e, t, i) {
|
|
2082
|
-
if (e !== void 0) {
|
|
2083
|
-
if (!f(e)) {
|
|
2084
|
-
i.push(
|
|
2085
|
-
s(
|
|
2086
|
-
"invalid_pagination",
|
|
2087
|
-
"Pagination must be an object with positive integer page and pageSize.",
|
|
2088
|
-
t
|
|
2089
|
-
)
|
|
2090
|
-
);
|
|
2091
|
-
return;
|
|
2092
|
-
}
|
|
2093
|
-
(!Number.isInteger(e.page) || typeof e.page != "number" || e.page < 1) && i.push(
|
|
2094
|
-
s(
|
|
2095
|
-
"invalid_pagination_page",
|
|
2096
|
-
"Pagination page must be a positive integer.",
|
|
2097
|
-
`${t}.page`
|
|
2098
|
-
)
|
|
2099
|
-
), (!Number.isInteger(e.pageSize) || typeof e.pageSize != "number" || e.pageSize < 1) && i.push(
|
|
2100
|
-
s(
|
|
2101
|
-
"invalid_pagination_page_size",
|
|
2102
|
-
"Pagination pageSize must be a positive integer.",
|
|
2103
|
-
`${t}.pageSize`
|
|
2104
|
-
)
|
|
2105
|
-
);
|
|
2106
|
-
}
|
|
2107
|
-
}
|
|
2108
|
-
function Ye(e) {
|
|
2109
|
-
const t = /* @__PURE__ */ new Set();
|
|
2110
|
-
for (const i of e) {
|
|
2111
|
-
if (t.has(i))
|
|
2112
|
-
return i;
|
|
2113
|
-
t.add(i);
|
|
2114
|
-
}
|
|
2115
|
-
return null;
|
|
2116
|
-
}
|
|
2117
|
-
function $n(e, t, i) {
|
|
2118
|
-
if (!f(e)) {
|
|
2119
|
-
i.push(
|
|
2120
|
-
s(
|
|
2121
|
-
"invalid_input_binding",
|
|
2122
|
-
"Input bindings must be structured objects.",
|
|
2123
|
-
t
|
|
2124
|
-
)
|
|
2125
|
-
);
|
|
2126
|
-
return;
|
|
2127
|
-
}
|
|
2128
|
-
m(e.inputId) || i.push(
|
|
2129
|
-
s(
|
|
2130
|
-
"invalid_input_binding",
|
|
2131
|
-
"Input bindings need a non-empty inputId.",
|
|
2132
|
-
`${t}.inputId`
|
|
2133
|
-
)
|
|
2134
|
-
), e.kind !== void 0 && e.kind !== "filter" && e.kind !== "control" && i.push(
|
|
2135
|
-
s(
|
|
2136
|
-
"invalid_input_binding",
|
|
2137
|
-
"Input binding kind must be filter or control.",
|
|
2138
|
-
`${t}.kind`
|
|
2139
|
-
)
|
|
2140
|
-
), e.field !== void 0 && b(e.field, `${t}.field`, i), e.relationshipHint !== void 0 && Ie(
|
|
2141
|
-
e.relationshipHint,
|
|
2142
|
-
`${t}.relationshipHint`,
|
|
2143
|
-
i
|
|
2144
|
-
);
|
|
2145
|
-
}
|
|
2146
|
-
function Ie(e, t, i) {
|
|
2147
|
-
if (!f(e)) {
|
|
2148
|
-
i.push(
|
|
2149
|
-
s(
|
|
2150
|
-
"invalid_relationship_hint",
|
|
2151
|
-
"Relationship hints must be structured objects.",
|
|
2152
|
-
t
|
|
2153
|
-
)
|
|
2154
|
-
);
|
|
2155
|
-
return;
|
|
2156
|
-
}
|
|
2157
|
-
e.relationshipIds !== void 0 && (!Array.isArray(e.relationshipIds) || e.relationshipIds.some((o) => !m(o))) && i.push(
|
|
2158
|
-
s(
|
|
2159
|
-
"invalid_relationship_hint",
|
|
2160
|
-
"Relationship hint relationshipIds must be non-empty strings.",
|
|
2161
|
-
`${t}.relationshipIds`
|
|
2162
|
-
)
|
|
2163
|
-
);
|
|
2164
|
-
}
|
|
2165
|
-
function jn(e, t) {
|
|
2166
|
-
var o, r;
|
|
2167
|
-
if (((o = e.source) == null ? void 0 : o.kind) !== "semantic" && ((r = e.source) == null ? void 0 : r.kind) !== "physical" && t.push(
|
|
2168
|
-
s(
|
|
2169
|
-
"invalid_input_options_source",
|
|
2170
|
-
"Input options must use a semantic or physical source.",
|
|
2171
|
-
"source"
|
|
2172
|
-
)
|
|
2173
|
-
), m(e.inputId) || t.push(
|
|
2174
|
-
s(
|
|
2175
|
-
"missing_input_options_input_id",
|
|
2176
|
-
"Input options intent needs the inputId it populates.",
|
|
2177
|
-
"inputId"
|
|
2178
|
-
)
|
|
2179
|
-
), e.search !== void 0 && typeof e.search != "string" && t.push(
|
|
2180
|
-
s(
|
|
2181
|
-
"invalid_input_options_search",
|
|
2182
|
-
"Input options search must be a string.",
|
|
2183
|
-
"search"
|
|
2184
|
-
)
|
|
2185
|
-
), e.matchValues !== void 0) {
|
|
2186
|
-
const a = Ct(e.matchValues);
|
|
2187
|
-
a.ok || t.push(
|
|
2188
|
-
s("invalid_input_options_match_values", a.error, "matchValues")
|
|
2189
|
-
), typeof e.search == "string" && e.search.trim() && t.push(
|
|
2190
|
-
s(
|
|
2191
|
-
"invalid_input_options_match_values",
|
|
2192
|
-
"Input options matchValues cannot be combined with search.",
|
|
2193
|
-
"matchValues"
|
|
2194
|
-
)
|
|
2195
|
-
);
|
|
2196
|
-
}
|
|
2197
|
-
if (e.limit !== void 0 && (typeof e.limit != "number" || !Number.isFinite(e.limit) || !Number.isInteger(e.limit) || e.limit <= 0) && t.push(
|
|
2198
|
-
s(
|
|
2199
|
-
"invalid_input_options_limit",
|
|
2200
|
-
"Input options limit must be a positive finite number.",
|
|
2201
|
-
"limit"
|
|
2202
|
-
)
|
|
2203
|
-
), (!e.labelField || !m(e.labelField.name)) && t.push(
|
|
2204
|
-
s(
|
|
2205
|
-
"missing_input_options_label_field",
|
|
2206
|
-
"Input options intent needs a labelField.",
|
|
2207
|
-
"labelField"
|
|
2208
|
-
)
|
|
2209
|
-
), b(e.labelField, "labelField", t, {
|
|
2210
|
-
required: !0
|
|
2211
|
-
}), (!e.valueField || !m(e.valueField.name)) && t.push(
|
|
2212
|
-
s(
|
|
2213
|
-
"missing_input_options_value_field",
|
|
2214
|
-
"Input options intent needs a valueField.",
|
|
2215
|
-
"valueField"
|
|
2216
|
-
)
|
|
2217
|
-
), b(e.valueField, "valueField", t, {
|
|
2218
|
-
required: !0
|
|
2219
|
-
}), e.searchField !== void 0 && b(e.searchField, "searchField", t, {
|
|
2220
|
-
required: !0
|
|
2221
|
-
}), e.disambiguationFields !== void 0 && (Array.isArray(e.disambiguationFields) ? e.disambiguationFields.forEach((a, l) => {
|
|
2222
|
-
b(a, `disambiguationFields.${l}`, t, {
|
|
2223
|
-
required: !0
|
|
2224
|
-
});
|
|
2225
|
-
}) : t.push(
|
|
2226
|
-
s(
|
|
2227
|
-
"invalid_input_options_disambiguation_fields",
|
|
2228
|
-
"Input options disambiguationFields must be an array of field refs.",
|
|
2229
|
-
"disambiguationFields"
|
|
2230
|
-
)
|
|
2231
|
-
)), [
|
|
2232
|
-
{ field: e.labelField, path: "labelField" },
|
|
2233
|
-
{ field: e.valueField, path: "valueField" },
|
|
2234
|
-
...e.searchField ? [{ field: e.searchField, path: "searchField" }] : [],
|
|
2235
|
-
...Array.isArray(e.disambiguationFields) ? e.disambiguationFields.map((a, l) => ({
|
|
2236
|
-
field: a,
|
|
2237
|
-
path: `disambiguationFields.${l}`
|
|
2238
|
-
})) : []
|
|
2239
|
-
].forEach(({ field: a, path: l }) => {
|
|
2240
|
-
a != null && a.source && !be(a.source, e.source) && t.push(
|
|
2241
|
-
s(
|
|
2242
|
-
"input_options_field_source_mismatch",
|
|
2243
|
-
"Input option fields must belong to the declared option source.",
|
|
2244
|
-
`${l}.source`
|
|
2245
|
-
)
|
|
2246
|
-
);
|
|
2247
|
-
}), e.dependencies !== void 0) {
|
|
2248
|
-
const a = On(
|
|
2249
|
-
e.dependencies
|
|
2250
|
-
);
|
|
2251
|
-
t.push(...a.errors), a.ok && Pn(e, t);
|
|
2252
|
-
}
|
|
2253
|
-
if (e.population !== void 0) {
|
|
2254
|
-
const a = e.population;
|
|
2255
|
-
if (!f(a))
|
|
2256
|
-
t.push(
|
|
2257
|
-
s(
|
|
2258
|
-
"invalid_input_options_population",
|
|
2259
|
-
"Input options population must be a structured object.",
|
|
2260
|
-
"population"
|
|
2261
|
-
)
|
|
2262
|
-
);
|
|
2263
|
-
else {
|
|
2264
|
-
const l = a.kind;
|
|
2265
|
-
l !== "option_source" && l !== "related_population" && t.push(
|
|
2266
|
-
s(
|
|
2267
|
-
"invalid_input_options_population",
|
|
2268
|
-
"Input options population kind must be option_source or related_population.",
|
|
2269
|
-
"population.kind"
|
|
2270
|
-
)
|
|
2271
|
-
), l === "option_source" && a.baseSource !== void 0 && t.push(
|
|
2272
|
-
s(
|
|
2273
|
-
"invalid_input_options_population",
|
|
2274
|
-
"Input options population baseSource is only valid for related_population.",
|
|
2275
|
-
"population.baseSource"
|
|
2276
|
-
)
|
|
2277
|
-
), l === "option_source" && a.relationshipHint !== void 0 && t.push(
|
|
2278
|
-
s(
|
|
2279
|
-
"invalid_input_options_population",
|
|
2280
|
-
"Input options population relationshipHint is only valid for related_population.",
|
|
2281
|
-
"population.relationshipHint"
|
|
2282
|
-
)
|
|
2283
|
-
), l === "related_population" && (ue(
|
|
2284
|
-
a.baseSource,
|
|
2285
|
-
"population.baseSource",
|
|
2286
|
-
t
|
|
2287
|
-
), a.relationshipHint !== void 0 && Ie(
|
|
2288
|
-
a.relationshipHint,
|
|
2289
|
-
"population.relationshipHint",
|
|
2290
|
-
t
|
|
2291
|
-
));
|
|
2292
|
-
}
|
|
2293
|
-
}
|
|
2294
|
-
}
|
|
2295
|
-
function Cn(e, t) {
|
|
2296
|
-
if (!(!("inputs" in e) || e.inputs === void 0)) {
|
|
2297
|
-
if (!Array.isArray(e.inputs)) {
|
|
2298
|
-
t.push(
|
|
2299
|
-
s(
|
|
2300
|
-
"invalid_input_binding",
|
|
2301
|
-
"Analytics intent inputs must be an array of input bindings.",
|
|
2302
|
-
"inputs"
|
|
2303
|
-
)
|
|
2304
|
-
);
|
|
2305
|
-
return;
|
|
2306
|
-
}
|
|
2307
|
-
e.inputs.forEach(
|
|
2308
|
-
(i, o) => $n(i, `inputs.${o}`, t)
|
|
2309
|
-
);
|
|
2310
|
-
}
|
|
2311
|
-
}
|
|
2312
|
-
function On(e, t = "protocol") {
|
|
2313
|
-
const i = [];
|
|
2314
|
-
if (!f(e))
|
|
2315
|
-
return i.push(
|
|
2316
|
-
s(
|
|
2317
|
-
"invalid_input_options_dependencies",
|
|
2318
|
-
"Input options dependencies must be a structured object.",
|
|
2319
|
-
"dependencies"
|
|
2320
|
-
)
|
|
2321
|
-
), { ok: !1, errors: i, warnings: [] };
|
|
2322
|
-
const o = e, r = o.mode;
|
|
2323
|
-
if (r !== void 0 && r !== "independent" && r !== "explicit" && r !== "all_applicable" && i.push(
|
|
2324
|
-
s(
|
|
2325
|
-
"invalid_input_options_dependencies",
|
|
2326
|
-
"Input options dependencies mode must be independent, explicit, or all_applicable.",
|
|
2327
|
-
"dependencies.mode"
|
|
2328
|
-
)
|
|
2329
|
-
), W(
|
|
2330
|
-
o.includeInputIds,
|
|
2331
|
-
"dependencies.includeInputIds",
|
|
2332
|
-
i,
|
|
2333
|
-
"Input options includeInputIds must be non-empty strings."
|
|
2334
|
-
), W(
|
|
2335
|
-
o.excludeInputIds,
|
|
2336
|
-
"dependencies.excludeInputIds",
|
|
2337
|
-
i,
|
|
2338
|
-
"Input options excludeInputIds must be non-empty strings."
|
|
2339
|
-
), r === "all_applicable" && o.includeInputIds !== void 0 && i.push(
|
|
2340
|
-
s(
|
|
2341
|
-
"invalid_input_options_dependencies",
|
|
2342
|
-
"All applicable dependencies cannot specify includeInputIds.",
|
|
2343
|
-
"dependencies.includeInputIds"
|
|
2344
|
-
)
|
|
2345
|
-
), W(
|
|
2346
|
-
o.omitInputIds,
|
|
2347
|
-
"dependencies.omitInputIds",
|
|
2348
|
-
i,
|
|
2349
|
-
"Input options omitInputIds must be non-empty strings."
|
|
2350
|
-
), Array.isArray(o.omitInputIds)) {
|
|
2351
|
-
const a = new Set(
|
|
2352
|
-
Array.isArray(o.includeInputIds) ? o.includeInputIds : []
|
|
2353
|
-
);
|
|
2354
|
-
(r !== "explicit" || new Set(o.omitInputIds).size !== o.omitInputIds.length || o.omitInputIds.some((l) => !a.has(l))) && i.push(
|
|
2355
|
-
s(
|
|
2356
|
-
"invalid_input_options_dependencies",
|
|
2357
|
-
"A browse override may only omit unique ids from an explicit includeInputIds list.",
|
|
2358
|
-
"dependencies.omitInputIds"
|
|
2359
|
-
)
|
|
2360
|
-
);
|
|
2361
|
-
}
|
|
2362
|
-
return t === "dashboard" && Yn(o, i), { ok: i.length === 0, errors: i, warnings: [] };
|
|
2363
|
-
}
|
|
2364
|
-
function Yn(e, t) {
|
|
2365
|
-
const { mode: i, includeInputIds: o, excludeInputIds: r } = e;
|
|
2366
|
-
i === void 0 && t.push(
|
|
2367
|
-
s(
|
|
2368
|
-
"invalid_input_options_dependencies",
|
|
2369
|
-
"Dashboard option dependencies must declare a mode.",
|
|
2370
|
-
"dependencies.mode"
|
|
2371
|
-
)
|
|
2372
|
-
);
|
|
2373
|
-
for (const [a, l] of [
|
|
2374
|
-
["dependencies.includeInputIds", o],
|
|
2375
|
-
["dependencies.excludeInputIds", r]
|
|
2376
|
-
])
|
|
2377
|
-
Array.isArray(l) && new Set(l).size !== l.length && t.push(
|
|
2378
|
-
s(
|
|
2379
|
-
"invalid_input_options_dependencies",
|
|
2380
|
-
"Dashboard option dependency input IDs must be unique.",
|
|
2381
|
-
a
|
|
2382
|
-
)
|
|
2383
|
-
);
|
|
2384
|
-
i === "independent" && (o !== void 0 || r !== void 0) && t.push(
|
|
2385
|
-
s(
|
|
2386
|
-
"invalid_input_options_dependencies",
|
|
2387
|
-
"Independent dashboard dependencies cannot specify input IDs.",
|
|
2388
|
-
"dependencies"
|
|
2389
|
-
)
|
|
2390
|
-
), i === "explicit" && (!Array.isArray(o) || o.length === 0 || r !== void 0) && t.push(
|
|
2391
|
-
s(
|
|
2392
|
-
"invalid_input_options_dependencies",
|
|
2393
|
-
"Explicit dashboard dependencies require included input IDs and cannot specify exclusions.",
|
|
2394
|
-
"dependencies"
|
|
2395
|
-
)
|
|
2396
|
-
);
|
|
2397
|
-
}
|
|
2398
|
-
function Pn(e, t) {
|
|
2399
|
-
var r, a, l;
|
|
2400
|
-
const i = new Set(
|
|
2401
|
-
Array.isArray(e.inputs) ? e.inputs.map((d) => f(d) ? d.inputId : void 0).filter((d) => typeof d == "string") : []
|
|
2402
|
-
), o = new Set(((r = e.dependencies) == null ? void 0 : r.omitInputIds) || []);
|
|
2403
|
-
for (const d of ((a = e.dependencies) == null ? void 0 : a.includeInputIds) || [])
|
|
2404
|
-
!i.has(d) && !o.has(d) && t.push(
|
|
2405
|
-
s(
|
|
2406
|
-
"invalid_input_options_dependencies",
|
|
2407
|
-
`Input options dependency "${d}" is not declared in inputs.`,
|
|
2408
|
-
"dependencies.includeInputIds"
|
|
2409
|
-
)
|
|
2410
|
-
);
|
|
2411
|
-
for (const d of ((l = e.dependencies) == null ? void 0 : l.excludeInputIds) || [])
|
|
2412
|
-
d !== e.inputId && !i.has(d) && t.push(
|
|
2413
|
-
s(
|
|
2414
|
-
"invalid_input_options_dependencies",
|
|
2415
|
-
`Input options dependency exclusion "${d}" is not the populated inputId and is not declared in inputs.`,
|
|
2416
|
-
"dependencies.excludeInputIds"
|
|
2417
|
-
)
|
|
2418
|
-
);
|
|
2419
|
-
}
|
|
2420
|
-
function W(e, t, i, o) {
|
|
2421
|
-
e !== void 0 && (!Array.isArray(e) || e.some((r) => !m(r))) && i.push(s("invalid_input_options_dependencies", o, t));
|
|
2422
|
-
}
|
|
2423
|
-
const Bn = new Set(qe);
|
|
2424
|
-
function Ln(e, t, i) {
|
|
2425
|
-
if (f(e) && e.type === "temporal_bucket") {
|
|
2426
|
-
i.push(
|
|
2427
|
-
s(
|
|
2428
|
-
"invalid_scalar_value_format",
|
|
2429
|
-
"Scalar and measure slots cannot own temporal bucket presentation; declare it with grain on a grouped field or axis.",
|
|
2430
|
-
t
|
|
2431
|
-
)
|
|
2432
|
-
);
|
|
2433
|
-
return;
|
|
2434
|
-
}
|
|
2435
|
-
He(e, t, i);
|
|
2436
|
-
}
|
|
2437
|
-
function Pe(e, t, i) {
|
|
2438
|
-
if (!f(e)) {
|
|
2439
|
-
i.push(
|
|
2440
|
-
s(
|
|
2441
|
-
"invalid_result_column_ref",
|
|
2442
|
-
"Result calculation references must use columnKey or field.",
|
|
2443
|
-
t
|
|
2444
|
-
)
|
|
2445
|
-
);
|
|
2446
|
-
return;
|
|
2447
|
-
}
|
|
2448
|
-
const o = m(e.columnKey), r = f(e.field);
|
|
2449
|
-
if (o === r) {
|
|
2450
|
-
i.push(
|
|
2451
|
-
s(
|
|
2452
|
-
"invalid_result_column_ref",
|
|
2453
|
-
"Result calculation references must identify exactly one of columnKey or field.",
|
|
2454
|
-
t
|
|
2455
|
-
)
|
|
2456
|
-
);
|
|
2457
|
-
return;
|
|
2458
|
-
}
|
|
2459
|
-
r && b(e.field, `${t}.field`, i, {
|
|
2460
|
-
required: !0
|
|
2461
|
-
});
|
|
2462
|
-
}
|
|
2463
|
-
function Vn(e, t, i) {
|
|
2464
|
-
if (!f(e)) {
|
|
2465
|
-
i.push(
|
|
2466
|
-
s(
|
|
2467
|
-
"invalid_result_calculation_output",
|
|
2468
|
-
"Result calculation output must be a structured object.",
|
|
2469
|
-
t
|
|
2470
|
-
)
|
|
2471
|
-
);
|
|
2472
|
-
return;
|
|
2473
|
-
}
|
|
2474
|
-
m(e.key) || i.push(
|
|
2475
|
-
s(
|
|
2476
|
-
"invalid_result_calculation_output",
|
|
2477
|
-
"Result calculation output needs a stable key.",
|
|
2478
|
-
`${t}.key`
|
|
2479
|
-
)
|
|
2480
|
-
), e.dataType !== void 0 && (typeof e.dataType != "string" || !Ue.has(e.dataType)) && i.push(
|
|
2481
|
-
s(
|
|
2482
|
-
"invalid_result_calculation_output",
|
|
2483
|
-
"Result calculation output dataType must be string, number, boolean, date, datetime, or unknown.",
|
|
2484
|
-
`${t}.dataType`
|
|
2485
|
-
)
|
|
2486
|
-
), Ln(e.format, `${t}.format`, i);
|
|
2487
|
-
}
|
|
2488
|
-
function qn(e, t) {
|
|
2489
|
-
if (e.analysis === void 0)
|
|
2490
|
-
return;
|
|
2491
|
-
if (!f(e.analysis)) {
|
|
2492
|
-
t.push(
|
|
2493
|
-
s(
|
|
2494
|
-
"invalid_measure_analysis",
|
|
2495
|
-
"Metric analysis must be a structured object.",
|
|
2496
|
-
"analysis"
|
|
2497
|
-
)
|
|
2498
|
-
);
|
|
2499
|
-
return;
|
|
2500
|
-
}
|
|
2501
|
-
if (e.analysis.kind !== "period_change") {
|
|
2502
|
-
t.push(
|
|
2503
|
-
s(
|
|
2504
|
-
"invalid_measure_analysis",
|
|
2505
|
-
"Metric analysis kind is not supported.",
|
|
2506
|
-
"analysis.kind"
|
|
2507
|
-
)
|
|
2508
|
-
);
|
|
2509
|
-
return;
|
|
2510
|
-
}
|
|
2511
|
-
e.dateField || t.push(
|
|
2512
|
-
s(
|
|
2513
|
-
"missing_analysis_date_field",
|
|
2514
|
-
"Period-change analysis needs a dateField.",
|
|
2515
|
-
"dateField"
|
|
2516
|
-
)
|
|
2517
|
-
), e.timeGrain || t.push(
|
|
2518
|
-
s(
|
|
2519
|
-
"missing_analysis_time_grain",
|
|
2520
|
-
"Period-change analysis needs a timeGrain.",
|
|
2521
|
-
"timeGrain"
|
|
2522
|
-
)
|
|
2523
|
-
), e.analysis.orderBy !== void 0 && e.analysis.orderBy !== "absolute_change" && e.analysis.orderBy !== "positive_change" && e.analysis.orderBy !== "negative_change" && e.analysis.orderBy !== "period" && t.push(
|
|
2524
|
-
s(
|
|
2525
|
-
"invalid_measure_analysis",
|
|
2526
|
-
"Period-change analysis orderBy must be absolute_change, positive_change, negative_change, or period.",
|
|
2527
|
-
"analysis.orderBy"
|
|
2528
|
-
)
|
|
2529
|
-
);
|
|
2530
|
-
const { timeWindow: i } = e.analysis;
|
|
2531
|
-
i !== void 0 && le(i, "analysis.timeWindow", t);
|
|
2532
|
-
}
|
|
2533
|
-
const Un = new Set(
|
|
2534
|
-
Ot
|
|
2535
|
-
), Hn = new Set(
|
|
2536
|
-
Yt
|
|
2537
|
-
), Gn = new Set(
|
|
2538
|
-
Pt
|
|
2539
|
-
);
|
|
2540
|
-
function zn(e, t, i) {
|
|
2541
|
-
Un.has(e.unit) || i.push(
|
|
2542
|
-
s(
|
|
2543
|
-
"invalid_time_window",
|
|
2544
|
-
"Calendar time window unit must be one of: day, week, month, quarter, year.",
|
|
2545
|
-
`${t}.unit`
|
|
2546
|
-
)
|
|
2547
|
-
), e.period !== "this" && e.period !== "previous" && i.push(
|
|
2548
|
-
s(
|
|
2549
|
-
"invalid_time_window",
|
|
2550
|
-
"Calendar time window period must be this or previous.",
|
|
2551
|
-
`${t}.period`
|
|
2552
|
-
)
|
|
2553
|
-
), e.toDate !== void 0 && typeof e.toDate != "boolean" ? i.push(
|
|
2554
|
-
s(
|
|
2555
|
-
"invalid_time_window",
|
|
2556
|
-
"Calendar time window toDate must be a boolean.",
|
|
2557
|
-
`${t}.toDate`
|
|
2558
|
-
)
|
|
2559
|
-
) : e.toDate === !0 && e.period !== "this" && i.push(
|
|
2560
|
-
s(
|
|
2561
|
-
"invalid_time_window",
|
|
2562
|
-
"Calendar time window toDate is only allowed with period this.",
|
|
2563
|
-
`${t}.toDate`
|
|
2564
|
-
)
|
|
2565
|
-
);
|
|
2566
|
-
}
|
|
2567
|
-
function le(e, t, i) {
|
|
2568
|
-
if (!f(e)) {
|
|
2569
|
-
i.push(
|
|
2570
|
-
s(
|
|
2571
|
-
"invalid_time_window",
|
|
2572
|
-
"Time window must be a structured object.",
|
|
2573
|
-
t
|
|
2574
|
-
)
|
|
2575
|
-
);
|
|
2576
|
-
return;
|
|
2577
|
-
}
|
|
2578
|
-
if (e.kind !== void 0 && e.kind !== "relative" && e.kind !== "calendar" && e.kind !== "absolute" && i.push(
|
|
2579
|
-
s(
|
|
2580
|
-
"invalid_time_window",
|
|
2581
|
-
"Time window kind must be relative, calendar or absolute.",
|
|
2582
|
-
`${t}.kind`
|
|
2583
|
-
)
|
|
2584
|
-
), e.kind === "calendar") {
|
|
2585
|
-
zn(e, t, i);
|
|
2586
|
-
return;
|
|
2587
|
-
}
|
|
2588
|
-
if (e.kind === "absolute") {
|
|
2589
|
-
if (m(e.start) || i.push(
|
|
2590
|
-
s(
|
|
2591
|
-
"invalid_time_window",
|
|
2592
|
-
"Absolute time window start must be a non-empty ISO date or timestamp string.",
|
|
2593
|
-
`${t}.start`
|
|
2594
|
-
)
|
|
2595
|
-
), m(e.end) || i.push(
|
|
2596
|
-
s(
|
|
2597
|
-
"invalid_time_window",
|
|
2598
|
-
"Absolute time window end must be a non-empty ISO date or timestamp string.",
|
|
2599
|
-
`${t}.end`
|
|
2600
|
-
)
|
|
2601
|
-
), m(e.start) && m(e.end)) {
|
|
2602
|
-
const o = re(e.start), r = re(e.end);
|
|
2603
|
-
o || i.push(
|
|
2604
|
-
s(
|
|
2605
|
-
"invalid_time_window",
|
|
2606
|
-
"Absolute time window start must be a valid ISO date or timestamp.",
|
|
2607
|
-
`${t}.start`
|
|
2608
|
-
)
|
|
2609
|
-
), r || i.push(
|
|
2610
|
-
s(
|
|
2611
|
-
"invalid_time_window",
|
|
2612
|
-
"Absolute time window end must be a valid ISO date or timestamp.",
|
|
2613
|
-
`${t}.end`
|
|
2614
|
-
)
|
|
2615
|
-
), o && r && o.getTime() > r.getTime() && i.push(
|
|
2616
|
-
s(
|
|
2617
|
-
"invalid_time_window",
|
|
2618
|
-
"Absolute time window start must be before or equal to end.",
|
|
2619
|
-
t
|
|
2620
|
-
)
|
|
2621
|
-
);
|
|
2622
|
-
}
|
|
2623
|
-
return;
|
|
2624
|
-
}
|
|
2625
|
-
(typeof e.unit != "string" || !Bn.has(e.unit)) && i.push(
|
|
2626
|
-
s(
|
|
2627
|
-
"invalid_time_window",
|
|
2628
|
-
`Time window unit must be one of: ${qe.join(", ")}.`,
|
|
2629
|
-
`${t}.unit`
|
|
2630
|
-
)
|
|
2631
|
-
), (typeof e.value != "number" || !Number.isFinite(e.value) || e.value <= 0) && i.push(
|
|
2632
|
-
s(
|
|
2633
|
-
"invalid_time_window",
|
|
2634
|
-
"Time window value must be a positive number.",
|
|
2635
|
-
`${t}.value`
|
|
2636
|
-
)
|
|
2637
|
-
), e.anchor !== void 0 && !Hn.has(e.anchor) && i.push(
|
|
2638
|
-
s(
|
|
2639
|
-
"invalid_time_window",
|
|
2640
|
-
"Time window anchor must be now or latest_available.",
|
|
2641
|
-
`${t}.anchor`
|
|
2642
|
-
)
|
|
2643
|
-
), e.completeness !== void 0 && !Gn.has(e.completeness) && i.push(
|
|
2644
|
-
s(
|
|
2645
|
-
"invalid_time_window",
|
|
2646
|
-
"Time window completeness must be include_partial or complete_periods.",
|
|
2647
|
-
`${t}.completeness`
|
|
2648
|
-
)
|
|
2649
|
-
);
|
|
2650
|
-
}
|
|
2651
|
-
function de(e, t, i) {
|
|
2652
|
-
if (e !== void 0) {
|
|
2653
|
-
if (!Array.isArray(e)) {
|
|
2654
|
-
i.push(
|
|
2655
|
-
s(
|
|
2656
|
-
"invalid_analytics_filters",
|
|
2657
|
-
"Analytics filters must be an array.",
|
|
2658
|
-
t
|
|
2659
|
-
)
|
|
2660
|
-
);
|
|
2661
|
-
return;
|
|
2662
|
-
}
|
|
2663
|
-
e.forEach((o, r) => {
|
|
2664
|
-
var c;
|
|
2665
|
-
const a = `${t}.${r}`;
|
|
2666
|
-
if (!f(o)) {
|
|
2667
|
-
i.push(
|
|
2668
|
-
s(
|
|
2669
|
-
"invalid_analytics_filter",
|
|
2670
|
-
"Analytics filter must be a structured object.",
|
|
2671
|
-
a
|
|
2672
|
-
)
|
|
2673
|
-
);
|
|
2674
|
-
return;
|
|
2675
|
-
}
|
|
2676
|
-
const l = o;
|
|
2677
|
-
b(l.field, `${a}.field`, i, {
|
|
2678
|
-
required: !0
|
|
2679
|
-
}), l.scope !== void 0 && l.scope !== "row" && l.scope !== "aggregate" && i.push(
|
|
2680
|
-
s(
|
|
2681
|
-
"invalid_analytics_filter_scope",
|
|
2682
|
-
"Analytics filter scope must be row or aggregate.",
|
|
2683
|
-
`${a}.scope`
|
|
2684
|
-
)
|
|
2685
|
-
), l.scope === "aggregate" && ((c = l.field) == null ? void 0 : c.role) !== void 0 && l.field.role !== "measure" && i.push(
|
|
2686
|
-
s(
|
|
2687
|
-
"invalid_analytics_filter_scope",
|
|
2688
|
-
"Aggregate-scope analytics filters must target a measure field.",
|
|
2689
|
-
`${a}.scope`
|
|
2690
|
-
)
|
|
2691
|
-
);
|
|
2692
|
-
const d = l.operator === "is_null" || l.operator === "is_not_null";
|
|
2693
|
-
if (l.operator !== void 0 && l.operator !== "=" && l.operator !== "!=" && l.operator !== "in" && l.operator !== "not_in" && l.operator !== "contains" && l.operator !== "not_contains" && l.operator !== "between" && l.operator !== "not_between" && l.operator !== ">" && l.operator !== ">=" && l.operator !== "<" && l.operator !== "<=" && l.operator !== "is_null" && l.operator !== "is_not_null" && i.push(
|
|
2694
|
-
s(
|
|
2695
|
-
"invalid_analytics_filter_operator",
|
|
2696
|
-
"Analytics filter operator is not supported.",
|
|
2697
|
-
`${a}.operator`
|
|
2698
|
-
)
|
|
2699
|
-
), l.values === void 0 && !d && i.push(
|
|
2700
|
-
s(
|
|
2701
|
-
"missing_analytics_filter_value",
|
|
2702
|
-
"Analytics filter needs values unless it is a null check.",
|
|
2703
|
-
a
|
|
2704
|
-
)
|
|
2705
|
-
), d && l.values !== void 0) {
|
|
2706
|
-
i.push(
|
|
2707
|
-
s(
|
|
2708
|
-
"invalid_analytics_filter_values",
|
|
2709
|
-
"Null-check analytics filters must not include values.",
|
|
2710
|
-
`${a}.values`
|
|
2711
|
-
)
|
|
2712
|
-
);
|
|
2713
|
-
return;
|
|
2714
|
-
}
|
|
2715
|
-
if (l.values !== void 0 && !Array.isArray(l.values)) {
|
|
2716
|
-
i.push(
|
|
2717
|
-
s(
|
|
2718
|
-
"invalid_analytics_filter_values",
|
|
2719
|
-
"Analytics filter values must be an array when provided.",
|
|
2720
|
-
`${a}.values`
|
|
2721
|
-
)
|
|
2722
|
-
);
|
|
2723
|
-
return;
|
|
2724
|
-
}
|
|
2725
|
-
if (l.values !== void 0) {
|
|
2726
|
-
const p = l.values.length;
|
|
2727
|
-
if (l.operator === "between" || l.operator === "not_between") {
|
|
2728
|
-
p !== 2 && i.push(
|
|
2729
|
-
s(
|
|
2730
|
-
"invalid_analytics_filter_values",
|
|
2731
|
-
"Between analytics filters must include exactly two values.",
|
|
2732
|
-
`${a}.values`
|
|
2733
|
-
)
|
|
2734
|
-
);
|
|
2735
|
-
return;
|
|
2736
|
-
}
|
|
2737
|
-
(l.operator === "contains" || l.operator === "not_contains" || l.operator === "=" || l.operator === "!=" || l.operator === ">" || l.operator === ">=" || l.operator === "<" || l.operator === "<=" || l.operator === void 0) && p !== 1 && i.push(
|
|
2738
|
-
s(
|
|
2739
|
-
"invalid_analytics_filter_values",
|
|
2740
|
-
"Scalar analytics filters must include exactly one value. Use in/not_in for multiple values.",
|
|
2741
|
-
`${a}.values`
|
|
2742
|
-
)
|
|
2743
|
-
);
|
|
2744
|
-
}
|
|
2745
|
-
});
|
|
2746
|
-
}
|
|
2747
|
-
}
|
|
2748
|
-
function Oa(e) {
|
|
2749
|
-
const t = [];
|
|
2750
|
-
if (!f(e))
|
|
2751
|
-
return t.push(
|
|
2752
|
-
s(
|
|
2753
|
-
"invalid_result_calculation",
|
|
2754
|
-
"Result calculation must be a structured object."
|
|
2755
|
-
)
|
|
2756
|
-
), { ok: !1, errors: t, warnings: [] };
|
|
2757
|
-
if (m(e.id) || t.push(
|
|
2758
|
-
s(
|
|
2759
|
-
"invalid_result_calculation_id",
|
|
2760
|
-
"Result calculation needs an id.",
|
|
2761
|
-
"id"
|
|
2762
|
-
)
|
|
2763
|
-
), m(e.label) || t.push(
|
|
2764
|
-
s(
|
|
2765
|
-
"invalid_result_calculation_label",
|
|
2766
|
-
"Result calculation needs a label.",
|
|
2767
|
-
"label"
|
|
2768
|
-
)
|
|
2769
|
-
), e.kind !== "percent_of_total" && e.kind !== "rank" && e.kind !== "running_total" && e.kind !== "previous_row_delta" && t.push(
|
|
2770
|
-
s(
|
|
2771
|
-
"invalid_result_calculation_kind",
|
|
2772
|
-
"Result calculation kind must be percent_of_total, rank, running_total, or previous_row_delta.",
|
|
2773
|
-
"kind"
|
|
2774
|
-
)
|
|
2775
|
-
), Pe(e.input, "input", t), Vn(e.output, "output", t), e.kind === "percent_of_total") {
|
|
2776
|
-
const i = e.denominator;
|
|
2777
|
-
i !== void 0 && (f(i) ? i.scope === "population" ? (b(i.metric, "denominator.metric", t, {
|
|
2778
|
-
required: !0
|
|
2779
|
-
}), de(
|
|
2780
|
-
i.filters,
|
|
2781
|
-
"denominator.filters",
|
|
2782
|
-
t
|
|
2783
|
-
)) : i.scope !== "returned_result" && t.push(
|
|
2784
|
-
s(
|
|
2785
|
-
"invalid_result_calculation_denominator",
|
|
2786
|
-
"Percent-of-total denominator scope must be returned_result or population.",
|
|
2787
|
-
"denominator.scope"
|
|
2788
|
-
)
|
|
2789
|
-
) : t.push(
|
|
2790
|
-
s(
|
|
2791
|
-
"invalid_result_calculation_denominator",
|
|
2792
|
-
"Percent-of-total denominator must be a structured object.",
|
|
2793
|
-
"denominator"
|
|
2794
|
-
)
|
|
2795
|
-
));
|
|
2796
|
-
}
|
|
2797
|
-
return e.kind === "rank" && e.order !== void 0 && e.order !== "asc" && e.order !== "desc" && t.push(
|
|
2798
|
-
s(
|
|
2799
|
-
"invalid_result_calculation_order",
|
|
2800
|
-
"Rank result calculation order must be asc or desc.",
|
|
2801
|
-
"order"
|
|
2802
|
-
)
|
|
2803
|
-
), (e.kind === "running_total" || e.kind === "previous_row_delta") && e.orderBy !== void 0 && Pe(e.orderBy, "orderBy", t), { ok: t.length === 0, errors: t, warnings: [] };
|
|
2804
|
-
}
|
|
2805
|
-
function xt(e) {
|
|
2806
|
-
var o;
|
|
2807
|
-
const t = [], i = [];
|
|
2808
|
-
if (!e || typeof e != "object")
|
|
2809
|
-
return {
|
|
2810
|
-
ok: !1,
|
|
2811
|
-
errors: [
|
|
2812
|
-
s(
|
|
2813
|
-
"invalid_analytics_intent",
|
|
2814
|
-
"Analytics intent must be a structured object."
|
|
2815
|
-
)
|
|
2816
|
-
],
|
|
2817
|
-
warnings: i,
|
|
2818
|
-
repairHints: [
|
|
2819
|
-
{
|
|
2820
|
-
code: "invalid_analytics_intent",
|
|
2821
|
-
recommendedNextStep: "Send one structured analytics intent object with kind, source, and required fields."
|
|
2822
|
-
}
|
|
2823
|
-
]
|
|
2824
|
-
};
|
|
2825
|
-
if (e.kind === "matrix") {
|
|
2826
|
-
const r = rn.safeParse(e);
|
|
2827
|
-
return r.success || t.push(...r.error.issues.map((a) => s("invalid_matrix_intent", a.message, a.path.join(".")))), { ok: t.length === 0, errors: t, warnings: i, repairHints: Be(t) };
|
|
2828
|
-
}
|
|
2829
|
-
if (e.version !== void 0 && e.version !== 1 && t.push(
|
|
2830
|
-
s(
|
|
2831
|
-
"invalid_version",
|
|
2832
|
-
"Analytics intent version must be 1.",
|
|
2833
|
-
"version"
|
|
2834
|
-
)
|
|
2835
|
-
), ue(e.source, "source", t), Qn(e, t), Cn(e, t), "relationshipHint" in e && e.relationshipHint !== void 0 && Ie(
|
|
2836
|
-
e.relationshipHint,
|
|
2837
|
-
"relationshipHint",
|
|
2838
|
-
t
|
|
2839
|
-
), e.kind === "metric") {
|
|
2840
|
-
const r = Array.isArray(e.measures) ? e.measures.filter(
|
|
2841
|
-
(a) => f(a) && m(a.name)
|
|
2842
|
-
) : [];
|
|
2843
|
-
if (!Array.isArray(e.measures) || e.measures.length === 0 ? t.push(
|
|
2844
|
-
s(
|
|
2845
|
-
"missing_measure",
|
|
2846
|
-
"Metric intent needs at least one measure.",
|
|
2847
|
-
"measures"
|
|
2848
|
-
)
|
|
2849
|
-
) : e.measures.some(
|
|
2850
|
-
(a) => !f(a) || !m(a.name)
|
|
2851
|
-
) && t.push(
|
|
2852
|
-
s(
|
|
2853
|
-
"invalid_measure_list",
|
|
2854
|
-
"Metric intent measures must be an array of field references with names.",
|
|
2855
|
-
"measures"
|
|
2856
|
-
)
|
|
2857
|
-
), r.forEach((a, l) => {
|
|
2858
|
-
b(a, `measures.${l}`, t, {
|
|
2859
|
-
required: !0
|
|
2860
|
-
});
|
|
2861
|
-
}), r.length > 0 && !wn(r)) {
|
|
2862
|
-
const a = r.find(
|
|
2863
|
-
(l, d) => r.some(
|
|
2864
|
-
(c, p) => p !== d && At(c, l)
|
|
2865
|
-
)
|
|
2866
|
-
);
|
|
2867
|
-
a && t.push(
|
|
2868
|
-
s(
|
|
2869
|
-
"duplicate_measure",
|
|
2870
|
-
An(a),
|
|
2871
|
-
"measures"
|
|
2872
|
-
)
|
|
2873
|
-
);
|
|
2874
|
-
}
|
|
2875
|
-
if (f(e.primaryMeasure) && m(e.primaryMeasure.name) && ve(
|
|
2876
|
-
e.primaryMeasure,
|
|
2877
|
-
r
|
|
2878
|
-
).length > 1 && t.push(
|
|
2879
|
-
s(
|
|
2880
|
-
"ambiguous_primary_measure",
|
|
2881
|
-
"Metric intent primaryMeasure must identify exactly one selected measure.",
|
|
2882
|
-
"primaryMeasure"
|
|
2883
|
-
)
|
|
2884
|
-
), e.primaryMeasure !== void 0 && (b(e.primaryMeasure, "primaryMeasure", t, {
|
|
2885
|
-
required: !0
|
|
2886
|
-
}), f(e.primaryMeasure) && m(e.primaryMeasure.name) && r.length > 0 && !xn(
|
|
2887
|
-
e.primaryMeasure,
|
|
2888
|
-
r
|
|
2889
|
-
) && t.push(
|
|
2890
|
-
s(
|
|
2891
|
-
"invalid_primary_measure",
|
|
2892
|
-
"Metric intent primaryMeasure must match one measure field reference.",
|
|
2893
|
-
"primaryMeasure"
|
|
2894
|
-
)
|
|
2895
|
-
)), e.dimensions !== void 0 && !Array.isArray(e.dimensions) ? t.push(
|
|
2896
|
-
s(
|
|
2897
|
-
"invalid_measure_dimensions",
|
|
2898
|
-
"Metric intent dimensions must be an array of field references.",
|
|
2899
|
-
"dimensions"
|
|
2900
|
-
)
|
|
2901
|
-
) : Array.isArray(e.dimensions) && e.dimensions.some(
|
|
2902
|
-
(a) => !f(a) || !m(a.name)
|
|
2903
|
-
) && t.push(
|
|
2904
|
-
s(
|
|
2905
|
-
"invalid_measure_dimensions",
|
|
2906
|
-
"Metric intent dimensions must be an array of field references with names.",
|
|
2907
|
-
"dimensions"
|
|
2908
|
-
)
|
|
2909
|
-
), e.dateField !== void 0 && b(e.dateField, "dateField", t), e.timeWindow !== void 0 && (le(e.timeWindow, "timeWindow", t), e.dateField || t.push(
|
|
2910
|
-
s(
|
|
2911
|
-
"missing_time_window_date_field",
|
|
2912
|
-
"Metric timeWindow needs a dateField.",
|
|
2913
|
-
"dateField"
|
|
2914
|
-
)
|
|
2915
|
-
)), de(e.filters, "filters", t), Array.isArray(e.dimensions) && e.dimensions.forEach((a, l) => {
|
|
2916
|
-
b(a, `dimensions.${l}`, t);
|
|
2917
|
-
}), e.orderBy !== void 0) {
|
|
2918
|
-
if (!f(e.orderBy))
|
|
2919
|
-
t.push(
|
|
2920
|
-
s(
|
|
2921
|
-
"invalid_measure_order_by",
|
|
2922
|
-
"Metric intent orderBy must be a structured object.",
|
|
2923
|
-
"orderBy"
|
|
2924
|
-
)
|
|
2925
|
-
);
|
|
2926
|
-
else if (b(e.orderBy.field, "orderBy.field", t, {
|
|
2927
|
-
required: !0
|
|
2928
|
-
}), e.orderBy.direction !== "asc" && e.orderBy.direction !== "desc" && t.push(
|
|
2929
|
-
s(
|
|
2930
|
-
"invalid_measure_order_direction",
|
|
2931
|
-
"Metric intent orderBy direction must be asc or desc.",
|
|
2932
|
-
"orderBy.direction"
|
|
2933
|
-
)
|
|
2934
|
-
), f(e.orderBy.field) && m(e.orderBy.field.name)) {
|
|
2935
|
-
const a = [
|
|
2936
|
-
...r,
|
|
2937
|
-
...e.timeGrain && e.dateField && f(e.dateField) ? [e.dateField] : [],
|
|
2938
|
-
...Array.isArray(e.dimensions) ? e.dimensions.filter(
|
|
2939
|
-
(l) => f(l) && m(l.name)
|
|
2940
|
-
) : []
|
|
2941
|
-
];
|
|
2942
|
-
a.length > 0 && !Dn(
|
|
2943
|
-
e.orderBy.field,
|
|
2944
|
-
a
|
|
2945
|
-
) && t.push(
|
|
2946
|
-
s(
|
|
2947
|
-
"invalid_measure_order_by",
|
|
2948
|
-
"Metric intent orderBy.field must match one selected measure, grouped dateField, or dimension.",
|
|
2949
|
-
"orderBy.field"
|
|
2950
|
-
)
|
|
2951
|
-
);
|
|
2952
|
-
}
|
|
2953
|
-
}
|
|
2954
|
-
qn(e, t);
|
|
2955
|
-
} else if (e.kind === "records") {
|
|
2956
|
-
if (!Array.isArray(e.fields) || e.fields.length === 0 ? t.push(
|
|
2957
|
-
s(
|
|
2958
|
-
"missing_record_fields",
|
|
2959
|
-
"Records intent needs at least one field.",
|
|
2960
|
-
"fields"
|
|
2961
|
-
)
|
|
2962
|
-
) : e.fields.some(
|
|
2963
|
-
(r) => !f(r) || !m(r.name)
|
|
2964
|
-
) && t.push(
|
|
2965
|
-
s(
|
|
2966
|
-
"invalid_record_fields",
|
|
2967
|
-
"Records intent fields must be field references with names.",
|
|
2968
|
-
"fields"
|
|
2969
|
-
)
|
|
2970
|
-
), Array.isArray(e.fields) && e.fields.forEach((r, a) => {
|
|
2971
|
-
b(r, `fields.${a}`, t);
|
|
2972
|
-
}), e.dateField !== void 0 && b(e.dateField, "dateField", t), Oe(e.pagination, "pagination", t), e.timeWindow !== void 0 && (le(e.timeWindow, "timeWindow", t), e.dateField || t.push(
|
|
2973
|
-
s(
|
|
2974
|
-
"missing_time_window_date_field",
|
|
2975
|
-
"Records timeWindow needs a dateField.",
|
|
2976
|
-
"dateField"
|
|
2977
|
-
)
|
|
2978
|
-
)), de(e.filters, "filters", t), Array.isArray(e.filters) && e.filters.forEach((r, a) => {
|
|
2979
|
-
f(r) && r.scope === "aggregate" && t.push(
|
|
2980
|
-
s(
|
|
2981
|
-
"unsupported_record_filter_scope",
|
|
2982
|
-
"Records intents support row-scope filters only. Use a metric intent for aggregate-scope filters.",
|
|
2983
|
-
`filters.${a}.scope`
|
|
2984
|
-
)
|
|
2985
|
-
);
|
|
2986
|
-
}), e.orderBy !== void 0 && (f(e.orderBy) ? (b(e.orderBy.field, "orderBy.field", t, {
|
|
2987
|
-
required: !0
|
|
2988
|
-
}), e.orderBy.direction !== "asc" && e.orderBy.direction !== "desc" && t.push(
|
|
2989
|
-
s(
|
|
2990
|
-
"invalid_record_order_direction",
|
|
2991
|
-
"Records intent orderBy direction must be asc or desc.",
|
|
2992
|
-
"orderBy.direction"
|
|
2993
|
-
)
|
|
2994
|
-
)) : t.push(
|
|
2995
|
-
s(
|
|
2996
|
-
"invalid_record_order_by",
|
|
2997
|
-
"Records intent orderBy must be a structured object.",
|
|
2998
|
-
"orderBy"
|
|
2999
|
-
)
|
|
3000
|
-
)), e.totals !== void 0)
|
|
3001
|
-
if (!f(e.totals))
|
|
3002
|
-
t.push(
|
|
3003
|
-
s(
|
|
3004
|
-
"invalid_records_totals",
|
|
3005
|
-
"Records totals must be a structured server totals request.",
|
|
3006
|
-
"totals"
|
|
3007
|
-
)
|
|
3008
|
-
);
|
|
3009
|
-
else {
|
|
3010
|
-
e.totals.mode !== "server" && t.push(
|
|
3011
|
-
s(
|
|
3012
|
-
"invalid_records_totals",
|
|
3013
|
-
"Records totals mode must be server.",
|
|
3014
|
-
"totals.mode"
|
|
3015
|
-
)
|
|
3016
|
-
);
|
|
3017
|
-
const r = e.totals.measures;
|
|
3018
|
-
!Array.isArray(r) || r.length === 0 ? t.push(
|
|
3019
|
-
s(
|
|
3020
|
-
"missing_records_totals_measures",
|
|
3021
|
-
"Records server totals need at least one measure.",
|
|
3022
|
-
"totals.measures"
|
|
3023
|
-
)
|
|
3024
|
-
) : r.forEach((a, l) => {
|
|
3025
|
-
b(a, `totals.measures.${l}`, t, {
|
|
3026
|
-
required: !0
|
|
3027
|
-
}), (!f(a) || a.role !== "measure") && t.push(
|
|
3028
|
-
s(
|
|
3029
|
-
"invalid_records_totals_measure",
|
|
3030
|
-
"Records server totals measures must be measure field references.",
|
|
3031
|
-
`totals.measures.${l}.role`
|
|
3032
|
-
)
|
|
3033
|
-
);
|
|
3034
|
-
});
|
|
3035
|
-
}
|
|
3036
|
-
} else e.kind === "inputOptions" ? jn(e, t) : e.kind === "sql" ? (((o = e.source) == null ? void 0 : o.kind) !== "sql" && t.push(
|
|
3037
|
-
s(
|
|
3038
|
-
"invalid_sql_source",
|
|
3039
|
-
"SQL analytics intent must use a SQL execution source.",
|
|
3040
|
-
"source"
|
|
3041
|
-
)
|
|
3042
|
-
), m(e.sql) || t.push(
|
|
3043
|
-
s("missing_sql", "SQL analytics intent needs SQL text.", "sql")
|
|
3044
|
-
), Fn(
|
|
3045
|
-
e.defaultParameters,
|
|
3046
|
-
"defaultParameters",
|
|
3047
|
-
t
|
|
3048
|
-
), Array.isArray(e.fields) && e.fields.forEach((r, a) => {
|
|
3049
|
-
b(r, `fields.${a}`, t);
|
|
3050
|
-
}), Oe(e.pagination, "pagination", t)) : t.push(
|
|
3051
|
-
s(
|
|
3052
|
-
"invalid_analytics_kind",
|
|
3053
|
-
"Analytics kind is not supported.",
|
|
3054
|
-
"kind"
|
|
3055
|
-
)
|
|
3056
|
-
);
|
|
3057
|
-
return {
|
|
3058
|
-
ok: t.length === 0,
|
|
3059
|
-
errors: t,
|
|
3060
|
-
warnings: i,
|
|
3061
|
-
repairHints: Be(t)
|
|
3062
|
-
};
|
|
3063
|
-
}
|
|
3064
|
-
function Qn(e, t) {
|
|
3065
|
-
if (!(!("derivedFields" in e) || e.derivedFields === void 0)) {
|
|
3066
|
-
if (!Array.isArray(e.derivedFields)) {
|
|
3067
|
-
t.push(
|
|
3068
|
-
s(
|
|
3069
|
-
"invalid_derived_fields",
|
|
3070
|
-
"Analytics intent derivedFields must be an array of derived field definitions.",
|
|
3071
|
-
"derivedFields"
|
|
3072
|
-
)
|
|
3073
|
-
);
|
|
3074
|
-
return;
|
|
3075
|
-
}
|
|
3076
|
-
e.derivedFields.forEach((i, o) => {
|
|
3077
|
-
pe(
|
|
3078
|
-
i
|
|
3079
|
-
).errors.forEach((a) => {
|
|
3080
|
-
t.push({
|
|
3081
|
-
...a,
|
|
3082
|
-
path: a.path ? `derivedFields.${o}.${a.path}` : `derivedFields.${o}`
|
|
3083
|
-
});
|
|
3084
|
-
});
|
|
3085
|
-
});
|
|
3086
|
-
}
|
|
3087
|
-
}
|
|
3088
|
-
function Kn(e) {
|
|
3089
|
-
const t = [], i = [];
|
|
3090
|
-
if (!e || typeof e != "object")
|
|
3091
|
-
return {
|
|
3092
|
-
ok: !1,
|
|
3093
|
-
errors: [
|
|
3094
|
-
s(
|
|
3095
|
-
"invalid_operation_intent",
|
|
3096
|
-
"Operation intent must be a structured object."
|
|
3097
|
-
)
|
|
3098
|
-
],
|
|
3099
|
-
warnings: i,
|
|
3100
|
-
repairHints: [
|
|
3101
|
-
{
|
|
3102
|
-
code: "invalid_operation_intent",
|
|
3103
|
-
recommendedNextStep: "Send one typed operation intent with version, kind, and required operation fields."
|
|
3104
|
-
}
|
|
3105
|
-
]
|
|
3106
|
-
};
|
|
3107
|
-
if (e.version !== 1 && t.push(
|
|
3108
|
-
s(
|
|
3109
|
-
"invalid_version",
|
|
3110
|
-
"Operation intent version must be 1.",
|
|
3111
|
-
"version"
|
|
3112
|
-
)
|
|
3113
|
-
), e.kind === "answer_obligations")
|
|
3114
|
-
!Array.isArray(e.obligations) || e.obligations.length === 0 ? t.push(
|
|
3115
|
-
s(
|
|
3116
|
-
"missing_obligations",
|
|
3117
|
-
"Answer-obligations operation intent needs at least one obligation.",
|
|
3118
|
-
"obligations"
|
|
3119
|
-
)
|
|
3120
|
-
) : e.obligations.forEach((o, r) => {
|
|
3121
|
-
m(o.id) || t.push(
|
|
3122
|
-
s(
|
|
3123
|
-
"missing_obligation_id",
|
|
3124
|
-
"Each analytics obligation needs an id.",
|
|
3125
|
-
`obligations.${r}.id`
|
|
3126
|
-
)
|
|
3127
|
-
), m(o.prompt) || t.push(
|
|
3128
|
-
s(
|
|
3129
|
-
"missing_obligation_prompt",
|
|
3130
|
-
"Each analytics obligation needs a prompt.",
|
|
3131
|
-
`obligations.${r}.prompt`
|
|
3132
|
-
)
|
|
3133
|
-
);
|
|
3134
|
-
});
|
|
3135
|
-
else if (e.kind === "dashboard_change") {
|
|
3136
|
-
if (m(e.instruction) || t.push(
|
|
3137
|
-
s(
|
|
3138
|
-
"missing_instruction",
|
|
3139
|
-
"Change operation intent needs an instruction.",
|
|
3140
|
-
"instruction"
|
|
3141
|
-
)
|
|
3142
|
-
), e.analyticsIntent) {
|
|
3143
|
-
const o = xt(
|
|
3144
|
-
e.analyticsIntent
|
|
3145
|
-
);
|
|
3146
|
-
t.push(...o.errors), i.push(...o.warnings);
|
|
3147
|
-
}
|
|
3148
|
-
} else
|
|
3149
|
-
t.push(
|
|
3150
|
-
s(
|
|
3151
|
-
"invalid_operation_kind",
|
|
3152
|
-
"Operation intent kind is not supported.",
|
|
3153
|
-
"kind"
|
|
3154
|
-
)
|
|
3155
|
-
);
|
|
3156
|
-
return {
|
|
3157
|
-
ok: t.length === 0,
|
|
3158
|
-
errors: t,
|
|
3159
|
-
warnings: i,
|
|
3160
|
-
repairHints: Dt(t)
|
|
3161
|
-
};
|
|
3162
|
-
}
|
|
3163
|
-
function Ya(e) {
|
|
3164
|
-
const t = [], i = [];
|
|
3165
|
-
if (!e || typeof e != "object")
|
|
3166
|
-
return {
|
|
3167
|
-
ok: !1,
|
|
3168
|
-
errors: [
|
|
3169
|
-
s(
|
|
3170
|
-
"invalid_recovery_plan",
|
|
3171
|
-
"Analytics recovery plan must be a structured object."
|
|
3172
|
-
)
|
|
3173
|
-
],
|
|
3174
|
-
warnings: i,
|
|
3175
|
-
repairHints: [
|
|
3176
|
-
{
|
|
3177
|
-
code: "invalid_recovery_plan",
|
|
3178
|
-
recommendedNextStep: "Return a typed recovery plan with operationIntent and plannedToolCalls."
|
|
3179
|
-
}
|
|
3180
|
-
]
|
|
3181
|
-
};
|
|
3182
|
-
e.version !== 1 && t.push(
|
|
3183
|
-
s("invalid_version", "Recovery plan version must be 1.", "version")
|
|
3184
|
-
), e.kind !== "analytics_recovery_plan" && t.push(
|
|
3185
|
-
s(
|
|
3186
|
-
"invalid_recovery_plan_kind",
|
|
3187
|
-
"Recovery plan kind must be analytics_recovery_plan.",
|
|
3188
|
-
"kind"
|
|
3189
|
-
)
|
|
3190
|
-
);
|
|
3191
|
-
const o = Kn(
|
|
3192
|
-
e.operationIntent
|
|
3193
|
-
);
|
|
3194
|
-
return t.push(...o.errors), i.push(...o.warnings), Array.isArray(e.plannedToolCalls) || t.push(
|
|
3195
|
-
s(
|
|
3196
|
-
"invalid_planned_tool_calls",
|
|
3197
|
-
"Recovery plan plannedToolCalls must be an array.",
|
|
3198
|
-
"plannedToolCalls"
|
|
3199
|
-
)
|
|
3200
|
-
), {
|
|
3201
|
-
ok: t.length === 0,
|
|
3202
|
-
errors: t,
|
|
3203
|
-
warnings: i,
|
|
3204
|
-
repairHints: Dt(t)
|
|
3205
|
-
};
|
|
3206
|
-
}
|
|
3207
|
-
function Dt(e) {
|
|
3208
|
-
return e.map((t) => ({
|
|
3209
|
-
code: t.code,
|
|
3210
|
-
recommendedNextStep: t.code === "missing_obligations" ? "Normalize the user request into one or more typed analytics obligations before recovery planning." : "Correct the operation/recovery contract shape before planning execution."
|
|
3211
|
-
}));
|
|
3212
|
-
}
|
|
3213
|
-
function Be(e) {
|
|
3214
|
-
return e.map((t) => {
|
|
3215
|
-
switch (t.code) {
|
|
3216
|
-
case "invalid_matrix_intent":
|
|
3217
|
-
return {
|
|
3218
|
-
code: t.code,
|
|
3219
|
-
recommendedNextStep: `Correct MatrixSpec at ${t.path || "the definition"}: ${t.message} Keep presentation and matrixWindowRequest outside the intent.`
|
|
3220
|
-
};
|
|
3221
|
-
case "missing_source":
|
|
3222
|
-
return {
|
|
3223
|
-
code: t.code,
|
|
3224
|
-
fieldRole: "source",
|
|
3225
|
-
recommendedNextStep: "Provide a semantic, physical, or SQL source before executing analytics."
|
|
3226
|
-
};
|
|
3227
|
-
case "missing_measure":
|
|
3228
|
-
return {
|
|
3229
|
-
code: t.code,
|
|
3230
|
-
fieldRole: "measure",
|
|
3231
|
-
recommendedNextStep: "Choose one exact measure from the grounded schema candidates."
|
|
3232
|
-
};
|
|
3233
|
-
case "missing_record_fields":
|
|
3234
|
-
return {
|
|
3235
|
-
code: t.code,
|
|
3236
|
-
fieldRole: "dimension",
|
|
3237
|
-
recommendedNextStep: "Provide at least one field for the records intent."
|
|
3238
|
-
};
|
|
3239
|
-
case "missing_matrix_rows":
|
|
3240
|
-
return {
|
|
3241
|
-
code: t.code,
|
|
3242
|
-
fieldRole: "dimension",
|
|
3243
|
-
recommendedNextStep: "Choose at least one row axis level for the matrix table."
|
|
3244
|
-
};
|
|
3245
|
-
case "missing_matrix_values":
|
|
3246
|
-
return {
|
|
3247
|
-
code: t.code,
|
|
3248
|
-
fieldRole: "measure",
|
|
3249
|
-
recommendedNextStep: "Choose at least one value field for the matrix table."
|
|
3250
|
-
};
|
|
3251
|
-
case "unsupported_matrix_sql_source":
|
|
3252
|
-
return {
|
|
3253
|
-
code: t.code,
|
|
3254
|
-
fieldRole: "source",
|
|
3255
|
-
recommendedNextStep: "Use a semantic or explorer-backed source for matrix tables; raw SQL matrix tables are not supported."
|
|
3256
|
-
};
|
|
3257
|
-
case "missing_input_options_input_id":
|
|
3258
|
-
return {
|
|
3259
|
-
code: t.code,
|
|
3260
|
-
fieldRole: "input",
|
|
3261
|
-
recommendedNextStep: "Provide the inputId that these option values populate."
|
|
3262
|
-
};
|
|
3263
|
-
case "missing_input_options_label_field":
|
|
3264
|
-
return {
|
|
3265
|
-
code: t.code,
|
|
3266
|
-
fieldRole: "dimension",
|
|
3267
|
-
recommendedNextStep: "Provide the human-readable field used as option labels."
|
|
3268
|
-
};
|
|
3269
|
-
case "missing_input_options_value_field":
|
|
3270
|
-
return {
|
|
3271
|
-
code: t.code,
|
|
3272
|
-
fieldRole: "dimension",
|
|
3273
|
-
recommendedNextStep: "Provide the stable field used as option values."
|
|
3274
|
-
};
|
|
3275
|
-
case "missing_sql":
|
|
3276
|
-
return {
|
|
3277
|
-
code: t.code,
|
|
3278
|
-
fieldRole: "sql",
|
|
3279
|
-
recommendedNextStep: "Provide bounded read-only SQL with an explicit outer LIMIT."
|
|
3280
|
-
};
|
|
3281
|
-
case "conflicting_sql":
|
|
3282
|
-
return {
|
|
3283
|
-
code: t.code,
|
|
3284
|
-
fieldRole: "sql",
|
|
3285
|
-
recommendedNextStep: "Use one canonical SQL text location for the intent; prefer top-level sql."
|
|
3286
|
-
};
|
|
3287
|
-
case "missing_semantic_domain":
|
|
3288
|
-
case "missing_dataset_name":
|
|
3289
|
-
case "missing_connection_id":
|
|
3290
|
-
case "missing_table_name":
|
|
3291
|
-
return {
|
|
3292
|
-
code: t.code,
|
|
3293
|
-
fieldRole: "source",
|
|
3294
|
-
recommendedNextStep: "Use grounded catalog metadata to fill the missing source reference."
|
|
3295
|
-
};
|
|
3296
|
-
default:
|
|
3297
|
-
return;
|
|
3298
|
-
}
|
|
3299
|
-
}).filter((t) => !!t);
|
|
3300
|
-
}
|
|
3301
|
-
function Xn(e, t, i, o) {
|
|
3302
|
-
if (!e || typeof e != "object") {
|
|
3303
|
-
i.push(
|
|
3304
|
-
s("invalid_view", "Dashboard view must be an object.", t)
|
|
3305
|
-
);
|
|
3306
|
-
return;
|
|
3307
|
-
}
|
|
3308
|
-
if (m(e.title) || i.push(
|
|
3309
|
-
s("missing_view_title", "Dashboard view needs a title.", t)
|
|
3310
|
-
), !e.presentation || typeof e.presentation != "object") {
|
|
3311
|
-
i.push(
|
|
3312
|
-
s(
|
|
3313
|
-
"missing_presentation",
|
|
3314
|
-
"Dashboard view needs a presentation.",
|
|
3315
|
-
`${t}.presentation`
|
|
3316
|
-
)
|
|
3317
|
-
);
|
|
3318
|
-
return;
|
|
3319
|
-
}
|
|
3320
|
-
if (e.presentation.kind === "text") {
|
|
3321
|
-
m(e.text) || o.push(
|
|
3322
|
-
s(
|
|
3323
|
-
"missing_text_content",
|
|
3324
|
-
"Text views should include text content.",
|
|
3325
|
-
`${t}.text`
|
|
3326
|
-
)
|
|
3327
|
-
);
|
|
3328
|
-
return;
|
|
3329
|
-
}
|
|
3330
|
-
if (!e.analytics) {
|
|
3331
|
-
i.push(
|
|
3332
|
-
s(
|
|
3333
|
-
"missing_view_analytics",
|
|
3334
|
-
"Non-text dashboard views need analytics intent.",
|
|
3335
|
-
`${t}.analytics`
|
|
3336
|
-
)
|
|
3337
|
-
);
|
|
3338
|
-
return;
|
|
3339
|
-
}
|
|
3340
|
-
e.presentation.kind === "matrixTable" && e.analytics.kind !== "matrix" && i.push(
|
|
3341
|
-
s(
|
|
3342
|
-
"invalid_matrix_view_analytics",
|
|
3343
|
-
"Matrix table views need matrix analytics intent.",
|
|
3344
|
-
`${t}.analytics.kind`
|
|
3345
|
-
)
|
|
3346
|
-
);
|
|
3347
|
-
const r = xt(e.analytics);
|
|
3348
|
-
for (const a of r.errors)
|
|
3349
|
-
i.push(
|
|
3350
|
-
s(
|
|
3351
|
-
a.code,
|
|
3352
|
-
a.message,
|
|
3353
|
-
`${t}.analytics${a.path ? `.${a.path}` : ""}`
|
|
3354
|
-
)
|
|
3355
|
-
);
|
|
3356
|
-
for (const a of r.warnings)
|
|
3357
|
-
o.push(
|
|
3358
|
-
s(
|
|
3359
|
-
a.code,
|
|
3360
|
-
a.message,
|
|
3361
|
-
`${t}.analytics${a.path ? `.${a.path}` : ""}`
|
|
3362
|
-
)
|
|
3363
|
-
);
|
|
3364
|
-
}
|
|
3365
|
-
function Pa(e) {
|
|
3366
|
-
const t = [], i = [];
|
|
3367
|
-
if (!e || typeof e != "object")
|
|
3368
|
-
return {
|
|
3369
|
-
ok: !1,
|
|
3370
|
-
errors: [
|
|
3371
|
-
s(
|
|
3372
|
-
"invalid_dashboard_intent",
|
|
3373
|
-
"Dashboard intent must be a structured object."
|
|
3374
|
-
)
|
|
3375
|
-
],
|
|
3376
|
-
warnings: i
|
|
3377
|
-
};
|
|
3378
|
-
e.version !== 1 && t.push(
|
|
3379
|
-
s("invalid_version", "Dashboard intent version must be 1.")
|
|
3380
|
-
), e.kind !== "dashboard" && t.push(
|
|
3381
|
-
s("invalid_kind", "Experience intent kind must be dashboard.")
|
|
3382
|
-
), m(e.title) || t.push(
|
|
3383
|
-
s("missing_title", "Dashboard intent needs a title.", "title")
|
|
3384
|
-
);
|
|
3385
|
-
const o = Array.isArray(e.inputs) ? e.inputs : [], r = Ye(
|
|
3386
|
-
o.filter(f).map((c) => c.id).filter((c) => typeof c == "string")
|
|
3387
|
-
);
|
|
3388
|
-
r && t.push(
|
|
3389
|
-
s(
|
|
3390
|
-
"duplicate_input_id",
|
|
3391
|
-
`Duplicate input id: ${r}.`,
|
|
3392
|
-
"inputs"
|
|
3393
|
-
)
|
|
3394
|
-
);
|
|
3395
|
-
for (const [c, p] of o.entries()) {
|
|
3396
|
-
const u = `inputs.${c}`;
|
|
3397
|
-
if (!f(p)) {
|
|
3398
|
-
t.push(
|
|
3399
|
-
s("invalid_input", "Dashboard input must be an object.", u)
|
|
3400
|
-
);
|
|
3401
|
-
continue;
|
|
3402
|
-
}
|
|
3403
|
-
m(p.id) || t.push(
|
|
3404
|
-
s("missing_input_id", "Input needs an id.", `${u}.id`)
|
|
3405
|
-
), m(p.label) || t.push(
|
|
3406
|
-
s("missing_input_label", "Input needs a label.", `${u}.label`)
|
|
3407
|
-
), !p.field || !m(p.field.name) ? t.push(
|
|
3408
|
-
s("missing_input_field", "Input needs a field.", `${u}.field`)
|
|
3409
|
-
) : b(p.field, `${u}.field`, t);
|
|
3410
|
-
}
|
|
3411
|
-
const a = Array.isArray(e.sections) ? e.sections : [];
|
|
3412
|
-
a.length === 0 && t.push(
|
|
3413
|
-
s(
|
|
3414
|
-
"missing_sections",
|
|
3415
|
-
"Dashboard intent needs at least one section.",
|
|
3416
|
-
"sections"
|
|
3417
|
-
)
|
|
3418
|
-
);
|
|
3419
|
-
const l = a.flatMap(
|
|
3420
|
-
(c) => c && typeof c == "object" && Array.isArray(c.views) ? c.views.filter(f).map((p) => p.id).filter((p) => !!p) : []
|
|
3421
|
-
), d = Ye(l);
|
|
3422
|
-
d && t.push(
|
|
3423
|
-
s(
|
|
3424
|
-
"duplicate_view_id",
|
|
3425
|
-
`Duplicate dashboard view id: ${d}.`,
|
|
3426
|
-
"sections"
|
|
3427
|
-
)
|
|
3428
|
-
);
|
|
3429
|
-
for (const [c, p] of a.entries()) {
|
|
3430
|
-
const u = `sections.${c}`;
|
|
3431
|
-
if (!p || typeof p != "object") {
|
|
3432
|
-
t.push(
|
|
3433
|
-
s(
|
|
3434
|
-
"invalid_section",
|
|
3435
|
-
"Dashboard section must be an object.",
|
|
3436
|
-
u
|
|
3437
|
-
)
|
|
3438
|
-
);
|
|
3439
|
-
continue;
|
|
3440
|
-
}
|
|
3441
|
-
if (m(p.title) || t.push(
|
|
3442
|
-
s(
|
|
3443
|
-
"missing_section_title",
|
|
3444
|
-
"Dashboard section needs a title.",
|
|
3445
|
-
u
|
|
3446
|
-
)
|
|
3447
|
-
), !Array.isArray(p.views) || p.views.length === 0) {
|
|
3448
|
-
t.push(
|
|
3449
|
-
s(
|
|
3450
|
-
"missing_section_views",
|
|
3451
|
-
"Dashboard section needs at least one view.",
|
|
3452
|
-
`${u}.views`
|
|
3453
|
-
)
|
|
3454
|
-
);
|
|
3455
|
-
continue;
|
|
3456
|
-
}
|
|
3457
|
-
for (const [h, y] of p.views.entries())
|
|
3458
|
-
Xn(
|
|
3459
|
-
y,
|
|
3460
|
-
`${u}.views.${h}`,
|
|
3461
|
-
t,
|
|
3462
|
-
i
|
|
3463
|
-
);
|
|
3464
|
-
}
|
|
3465
|
-
return { ok: t.length === 0, errors: t, warnings: i };
|
|
3466
|
-
}
|
|
3467
|
-
export {
|
|
3468
|
-
Ct as $,
|
|
3469
|
-
H as A,
|
|
3470
|
-
Ki as B,
|
|
3471
|
-
te as C,
|
|
3472
|
-
wi as D,
|
|
3473
|
-
ft as E,
|
|
3474
|
-
oe as F,
|
|
3475
|
-
gt as G,
|
|
3476
|
-
Ii as H,
|
|
3477
|
-
x as I,
|
|
3478
|
-
ra as J,
|
|
3479
|
-
Wi as K,
|
|
3480
|
-
Si as L,
|
|
3481
|
-
ht as M,
|
|
3482
|
-
tn as N,
|
|
3483
|
-
nn as O,
|
|
3484
|
-
yt as P,
|
|
3485
|
-
C as Q,
|
|
3486
|
-
Re as R,
|
|
3487
|
-
ln as S,
|
|
3488
|
-
ye as T,
|
|
3489
|
-
Ne as U,
|
|
3490
|
-
z as V,
|
|
3491
|
-
gn as W,
|
|
3492
|
-
xa as X,
|
|
3493
|
-
Ma as Y,
|
|
3494
|
-
me as Z,
|
|
3495
|
-
jt as _,
|
|
3496
|
-
kt as a,
|
|
3497
|
-
Ia as a$,
|
|
3498
|
-
re as a0,
|
|
3499
|
-
On as a1,
|
|
3500
|
-
Oa as a2,
|
|
3501
|
-
xt as a3,
|
|
3502
|
-
Kn as a4,
|
|
3503
|
-
Ya as a5,
|
|
3504
|
-
Pa as a6,
|
|
3505
|
-
pe as a7,
|
|
3506
|
-
ge as a8,
|
|
3507
|
-
li as a9,
|
|
3508
|
-
Lt as aA,
|
|
3509
|
-
ta as aB,
|
|
3510
|
-
qt as aC,
|
|
3511
|
-
ia as aD,
|
|
3512
|
-
Ut as aE,
|
|
3513
|
-
tt as aF,
|
|
3514
|
-
B as aG,
|
|
3515
|
-
bi as aH,
|
|
3516
|
-
V as aI,
|
|
3517
|
-
sa as aJ,
|
|
3518
|
-
F as aK,
|
|
3519
|
-
hi as aL,
|
|
3520
|
-
$ as aM,
|
|
3521
|
-
we as aN,
|
|
3522
|
-
oa as aO,
|
|
3523
|
-
et as aP,
|
|
3524
|
-
on as aQ,
|
|
3525
|
-
qi as aR,
|
|
3526
|
-
fe as aS,
|
|
3527
|
-
Gt as aT,
|
|
3528
|
-
Me as aU,
|
|
3529
|
-
dn as aV,
|
|
3530
|
-
ba as aW,
|
|
3531
|
-
Yi as aX,
|
|
3532
|
-
Fa as aY,
|
|
3533
|
-
Aa as aZ,
|
|
3534
|
-
va as a_,
|
|
3535
|
-
di as aa,
|
|
3536
|
-
he as ab,
|
|
3537
|
-
fi as ac,
|
|
3538
|
-
gi as ad,
|
|
3539
|
-
Xe as ae,
|
|
3540
|
-
Ze as af,
|
|
3541
|
-
Fe as ag,
|
|
3542
|
-
We as ah,
|
|
3543
|
-
na as ai,
|
|
3544
|
-
aa as aj,
|
|
3545
|
-
Ra as ak,
|
|
3546
|
-
Ta as al,
|
|
3547
|
-
D as am,
|
|
3548
|
-
It as an,
|
|
3549
|
-
be as ao,
|
|
3550
|
-
St as ap,
|
|
3551
|
-
$a as aq,
|
|
3552
|
-
Fi as ar,
|
|
3553
|
-
Di as as,
|
|
3554
|
-
Ot as at,
|
|
3555
|
-
Wn as au,
|
|
3556
|
-
Yt as av,
|
|
3557
|
-
Pt as aw,
|
|
3558
|
-
ea as ax,
|
|
3559
|
-
Bt as ay,
|
|
3560
|
-
R as az,
|
|
3561
|
-
da as b,
|
|
3562
|
-
Vi as b0,
|
|
3563
|
-
Ui as b1,
|
|
3564
|
-
ka as b2,
|
|
3565
|
-
Sa as b3,
|
|
3566
|
-
wa as b4,
|
|
3567
|
-
_a as b5,
|
|
3568
|
-
ae as b6,
|
|
3569
|
-
ya as b7,
|
|
3570
|
-
un as b8,
|
|
3571
|
-
Ai as c,
|
|
3572
|
-
nt as d,
|
|
3573
|
-
ca as e,
|
|
3574
|
-
pa as f,
|
|
3575
|
-
ki as g,
|
|
3576
|
-
ma as h,
|
|
3577
|
-
la as i,
|
|
3578
|
-
fa as j,
|
|
3579
|
-
ie as k,
|
|
3580
|
-
Da as l,
|
|
3581
|
-
rn as m,
|
|
3582
|
-
ua as n,
|
|
3583
|
-
yn as o,
|
|
3584
|
-
ja as p,
|
|
3585
|
-
Na as q,
|
|
3586
|
-
Ca as r,
|
|
3587
|
-
Sn as s,
|
|
3588
|
-
it as t,
|
|
3589
|
-
ga as u,
|
|
3590
|
-
ha as v,
|
|
3591
|
-
Ea as w,
|
|
3592
|
-
se as x,
|
|
3593
|
-
ct as y,
|
|
3594
|
-
vi as z
|
|
3595
|
-
};
|