react-semaphor 0.1.541 → 0.1.543
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 +75 -75
- package/dist/assistant-context/index.js +1 -1
- package/dist/brand-studio/index.js +3 -3
- package/dist/briefings/index.js +51 -49
- package/dist/chunks/apply-dashboard-operations-CG9S7MGt.js +2260 -0
- package/dist/chunks/{assistant-chat-D1fDZD6O.js → assistant-chat-BFMRUYoB.js} +12 -12
- package/dist/chunks/bookmark-state-CXw7lZ50.js +118 -0
- package/dist/chunks/{calendar-day-equality-Bpl15IBo.js → calendar-day-equality-BmJAWduY.js} +180 -207
- package/dist/chunks/comparison-window-caption-Bv18samq.js +1618 -0
- package/dist/chunks/custom-visual-inputs-DUtpYZOk.js +323 -0
- package/dist/chunks/{dashboard-B6IrON_Q.js → dashboard-B9mKTJoy.js} +1 -1
- package/dist/chunks/{dashboard-briefing-launcher-DwjFpewq.js → dashboard-briefing-launcher-Bdmry_oG.js} +18 -18
- package/dist/chunks/{dashboard-controls-C_BI28ME.js → dashboard-controls-UGpjOM2k.js} +69 -70
- package/dist/chunks/{dashboard-filter-value-compatibility-D95O4nd7.js → dashboard-filter-value-compatibility-CwQ_iSNb.js} +2 -2
- package/dist/chunks/{dashboard-json-DDY15Trn.js → dashboard-json-DG8dz0eX.js} +4 -4
- package/dist/chunks/{document-dashboard-inputs-DP_Op5mu.js → document-dashboard-inputs-OwqCbrVp.js} +2382 -4975
- package/dist/chunks/document-sheet-utils-BTb3VZxV.js +3619 -0
- package/dist/chunks/{edit-dashboard-visual-CH2dzWW-.js → edit-dashboard-visual-CDpA4y5e.js} +728 -728
- package/dist/chunks/{filter-value-text-BhWugPWE.js → filter-value-text-CYsVYPuD.js} +18 -19
- package/dist/chunks/{index-DaQlghLY.js → index-l5LclZvs.js} +824 -1351
- package/dist/chunks/{matrix-analytical-definition-bcprSe4u.js → matrix-analytical-definition-C7Gb0e12.js} +1 -1
- package/dist/chunks/{matrix-card-CJn1hB5V.js → matrix-card-DjwWcCo8.js} +2 -2
- package/dist/chunks/{matrix-formatter-DQ8avoIQ.js → matrix-formatter-BnsTX90d.js} +430 -417
- package/dist/chunks/{matrix-member-presentation-BNPSDKBG.js → matrix-member-presentation-CQGdVks6.js} +1 -1
- package/dist/chunks/{matrix-operation-contract-B8PBF1Gd.js → matrix-operation-contract-8OIO4gob.js} +65 -65
- package/dist/chunks/metric-comparison-DEwi9uc2.js +498 -0
- package/dist/chunks/numeric-presentation-F_-H6VAw.js +5227 -0
- package/dist/chunks/{pivot-header-presentation-MkcKnjn3.js → pivot-header-presentation-DHcx1XGQ.js} +1 -1
- package/dist/chunks/{pivot-result-identity-D6hhcRXi.js → pivot-result-identity-DJhXXcns.js} +1 -1
- package/dist/chunks/pivot-result-lifecycle-DupbRk-R.js +1155 -0
- package/dist/chunks/raw-temporal-presentation-D-azM_98.js +585 -0
- package/dist/chunks/{report-preferences-dialog-DpNkFfQO.js → report-preferences-dialog-CPwRwEJx.js} +75 -75
- package/dist/chunks/{report-runtime-context-B984Nq1E.js → report-runtime-context-Dq8XyODK.js} +1 -1
- package/dist/chunks/{saved-dashboard-context-CJ2WpoMF.js → saved-dashboard-context-BKvMfRfC.js} +233 -206
- package/dist/chunks/{selection-reducer-vKIb_jS6.js → selection-reducer-Dj_8xD69.js} +1 -1
- package/dist/chunks/{semaphor-ready-indicator-KT598QJq.js → semaphor-ready-indicator-CN2AHm2x.js} +37489 -39476
- package/dist/chunks/{shelf-drop-preview-context-BxV3Fl8h.js → shelf-drop-preview-context-BGl_rxcW.js} +6 -6
- package/dist/chunks/sort-target-MT1WK1vX.js +29 -0
- package/dist/chunks/{source-entity-resolution-CVA1a85c.js → source-entity-resolution-BYn9giz3.js} +1 -1
- package/dist/chunks/{switch-DWEWiv1J.js → switch-C3jLxlG0.js} +2 -2
- package/dist/chunks/table-export-sheet-BDRXLLdq.js +949 -0
- package/dist/chunks/table-settings-CLZocegs.js +501 -0
- package/dist/chunks/temporal-bucket-D7NBrrtL.js +2071 -0
- package/dist/chunks/{token-types-bxUxXDX2.js → token-types-DBbZVQsm.js} +1 -1
- package/dist/chunks/{use-create-flow-overlay-state-DdD12SMY.js → use-create-flow-overlay-state-BnclfB2k.js} +151 -151
- package/dist/chunks/{validators-Ej1DdCXa.js → validators-DMHTpf7a.js} +73 -73
- package/dist/dashboard/index.js +2 -2
- package/dist/dashboard-authoring/index.js +462 -457
- package/dist/data-app-sdk/index.js +5 -5
- package/dist/data-app-sdk-adapters/index.js +2 -2
- package/dist/data-app-sdk-validation/index.js +9 -9
- package/dist/format-utils/index.js +346 -241
- package/dist/index.js +174 -175
- package/dist/report-runtime-context/index.js +1 -1
- package/dist/surfboard/index.js +2 -2
- package/dist/types/briefings/attachment-outcomes.d.ts +1 -1
- package/dist/types/briefings/attachments.d.ts +17 -1
- package/dist/types/briefings/index.d.ts +5 -3
- package/dist/types/index.js +48 -48
- package/dist/types/lib/api/exports-api.d.ts +11 -65
- package/dist/types/lib/dashboard-inputs/control-contract-overrides.d.ts +17 -0
- package/dist/types/lib/dashboard-viewer/export-table-view.d.ts +2 -0
- package/dist/types/lib/hooks/use-dashboard.d.ts +3 -6
- package/dist/types/lib/matrix-table/matrix-delivery-policy.d.ts +8 -2
- package/dist/types/lib/matrix-table/matrix-delivery.d.ts +8 -6
- package/dist/types/lib/query-context/build-dashboard-card-query-contract.d.ts +50 -0
- package/dist/types/lib/types/explorer-types.d.ts +6 -0
- package/dist/types/shared/analytics-protocol/matrix-definition-contract.d.ts +3 -3
- package/dist/types/shared/assistant-context/index.d.ts +1 -1
- package/dist/types/shared/assistant-context/saved-dashboard-context.d.ts +23 -6
- package/dist/types/shared/dashboard-authoring/card-export-request.d.ts +173 -0
- package/dist/types/shared/dashboard-authoring/index.d.ts +1 -0
- package/dist/types/shared/dashboard-authoring/matrix-delivery.d.ts +4 -3
- package/dist/types/shared/format-utils/exporters/export-cells.d.ts +90 -0
- package/dist/types/shared/format-utils/exporters/export-file-format.d.ts +44 -0
- package/dist/types/shared/format-utils/exporters/index.d.ts +6 -0
- package/dist/types/shared/format-utils/exporters/xlsx-file.d.ts +90 -0
- package/dist/types/shared/format-utils/formatters/date-formatter.d.ts +8 -12
- package/dist/types/shared/format-utils/formatters/index.d.ts +1 -1
- package/dist/types/shared/format-utils/formatters/matrix-formatter.d.ts +2 -0
- package/dist/types/shared/format-utils/index.d.ts +2 -0
- package/dist/types/shared/format-utils/matrix-continuation.d.ts +55 -9
- package/dist/types/shared/format-utils/matrix-export-presentation.d.ts +21 -1
- package/dist/types/shared/format-utils/matrix-export-xlsx.d.ts +27 -0
- package/dist/types/shared/format-utils/presentation-execution.d.ts +27 -2
- package/dist/types/shared/format-utils/raw-temporal.d.ts +8 -0
- package/dist/types/shared/format-utils/table-export/index.d.ts +8 -0
- package/dist/types/shared/format-utils/table-export/prepare-table-export.d.ts +50 -0
- package/dist/types/shared/format-utils/table-export/table-export-formatting.d.ts +47 -0
- package/dist/types/shared/format-utils/table-export/table-export-raw-temporal.d.ts +40 -0
- package/dist/types/shared/format-utils/table-export/table-export-result.d.ts +31 -0
- package/dist/types/shared/format-utils/table-export/table-export-sheet.d.ts +38 -0
- package/dist/types/shared/format-utils/temporal-bucket.d.ts +9 -0
- package/package.json +2 -1
- package/dist/chunks/aggregate-table-row-presentation-B_vQjYR3.js +0 -996
- package/dist/chunks/apply-dashboard-operations-C-iahGka.js +0 -402
- package/dist/chunks/bookmark-state-k7y5SNGf.js +0 -331
- package/dist/chunks/calculated-field-identity-DcBS2NPP.js +0 -2161
- package/dist/chunks/canonical-result-keys-CEQefvdO.js +0 -33
- package/dist/chunks/common-types-CUf03Htv.js +0 -288
- package/dist/chunks/csv-utils-GUfKyT1J.js +0 -56
- package/dist/chunks/custom-visual-inputs-BrUOIwln.js +0 -3288
- package/dist/chunks/document-sheet-utils-C1eEldxs.js +0 -1076
- package/dist/chunks/matrix-definition-DQDI2okF.js +0 -206
- package/dist/chunks/metric-comparison-CojWeLqx.js +0 -392
- package/dist/chunks/pivot-result-lifecycle-8qCDmpKc.js +0 -804
- package/dist/chunks/raw-temporal-D61lr48Y.js +0 -1464
- package/dist/chunks/temporal-bucket-D8JF7zKz.js +0 -575
- package/dist/chunks/temporal-bucket-contract-DaOajRC7.js +0 -108
|
@@ -0,0 +1,498 @@
|
|
|
1
|
+
import { t as g, T as m, a as C } from "./analytics-base-schemas-BFAoRlkU.js";
|
|
2
|
+
import { v as k } from "./validators-DMHTpf7a.js";
|
|
3
|
+
function w(e) {
|
|
4
|
+
const r = g.safeParse(e);
|
|
5
|
+
return r.success ? { ok: !0, value: r.data } : {
|
|
6
|
+
ok: !1,
|
|
7
|
+
error: {
|
|
8
|
+
code: m.invalidMetadata,
|
|
9
|
+
message: "Temporal bucket metadata is invalid.",
|
|
10
|
+
path: "temporalBucket"
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
function f(e, r) {
|
|
15
|
+
if (!e.temporalBucket)
|
|
16
|
+
return r.metadataRequired ? {
|
|
17
|
+
ok: !1,
|
|
18
|
+
error: {
|
|
19
|
+
code: m.missingMetadata,
|
|
20
|
+
message: "Activated temporal bucket result is missing metadata.",
|
|
21
|
+
path: "temporalBucket"
|
|
22
|
+
}
|
|
23
|
+
} : { ok: !0 };
|
|
24
|
+
const o = w(
|
|
25
|
+
e.temporalBucket
|
|
26
|
+
);
|
|
27
|
+
if (!o.ok || !o.value)
|
|
28
|
+
return o;
|
|
29
|
+
const n = C(
|
|
30
|
+
o.value.granularity
|
|
31
|
+
);
|
|
32
|
+
return e.dataType !== n ? {
|
|
33
|
+
ok: !1,
|
|
34
|
+
error: {
|
|
35
|
+
code: m.invalidMetadata,
|
|
36
|
+
message: `${o.value.granularity} temporal buckets require dataType ${n}.`,
|
|
37
|
+
path: "dataType"
|
|
38
|
+
}
|
|
39
|
+
} : o;
|
|
40
|
+
}
|
|
41
|
+
function $(e, r) {
|
|
42
|
+
var o, n, t, i;
|
|
43
|
+
return e.granularity === r.granularity && e.calendar.tz === r.calendar.tz && e.calendar.weekStart === r.calendar.weekStart && ((o = e.calendar.fiscalCalendar) == null ? void 0 : o.kind) === ((n = r.calendar.fiscalCalendar) == null ? void 0 : n.kind) && ((t = e.calendar.fiscalCalendar) == null ? void 0 : t.yearStartMonth) === ((i = r.calendar.fiscalCalendar) == null ? void 0 : i.yearStartMonth);
|
|
44
|
+
}
|
|
45
|
+
function I(e, r) {
|
|
46
|
+
const o = /* @__PURE__ */ new Map();
|
|
47
|
+
for (const n of e) {
|
|
48
|
+
if (o.has(n.key))
|
|
49
|
+
return {
|
|
50
|
+
ok: !1,
|
|
51
|
+
error: {
|
|
52
|
+
code: m.invalidMetadata,
|
|
53
|
+
message: `Canonical result contains duplicate column key "${n.key}".`,
|
|
54
|
+
path: "columns"
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
if (o.set(n.key, n), n.temporalBucket) {
|
|
58
|
+
const t = f(n, {
|
|
59
|
+
metadataRequired: !1
|
|
60
|
+
});
|
|
61
|
+
if (!t.ok)
|
|
62
|
+
return {
|
|
63
|
+
ok: !1,
|
|
64
|
+
error: {
|
|
65
|
+
...t.error,
|
|
66
|
+
path: `columns.${n.key}.${t.error.path || "temporalBucket"}`
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
for (const n of r) {
|
|
72
|
+
const t = o.get(n.key);
|
|
73
|
+
if (!t)
|
|
74
|
+
return {
|
|
75
|
+
ok: !1,
|
|
76
|
+
error: {
|
|
77
|
+
code: m.missingMetadata,
|
|
78
|
+
message: `Activated temporal bucket result is missing column "${n.key}".`,
|
|
79
|
+
path: `columns.${n.key}`
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
const i = f(t, {
|
|
83
|
+
metadataRequired: !0
|
|
84
|
+
});
|
|
85
|
+
if (!i.ok)
|
|
86
|
+
return {
|
|
87
|
+
ok: !1,
|
|
88
|
+
error: {
|
|
89
|
+
...i.error,
|
|
90
|
+
path: `columns.${n.key}.${i.error.path || "temporalBucket"}`
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
if (!i.value || !$(i.value, n.metadata))
|
|
94
|
+
return {
|
|
95
|
+
ok: !1,
|
|
96
|
+
error: {
|
|
97
|
+
code: m.invalidMetadata,
|
|
98
|
+
message: `Temporal bucket metadata for column "${n.key}" contradicts the governed query context.`,
|
|
99
|
+
path: `columns.${n.key}.temporalBucket`
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
return { ok: !0, value: e };
|
|
104
|
+
}
|
|
105
|
+
const h = "higher_is_better", A = {
|
|
106
|
+
displayMode: "difference",
|
|
107
|
+
showComparison: !0,
|
|
108
|
+
indicatorStyle: "arrow_badge",
|
|
109
|
+
showColor: !0,
|
|
110
|
+
conditionalLabel: !1
|
|
111
|
+
};
|
|
112
|
+
function y(e) {
|
|
113
|
+
return k(e) !== null;
|
|
114
|
+
}
|
|
115
|
+
function N(e) {
|
|
116
|
+
var r, o, n, t;
|
|
117
|
+
if (((r = e.metricComparison) == null ? void 0 : r.mode) !== "off") {
|
|
118
|
+
if (((o = e.metricComparison) == null ? void 0 : o.mode) === "explicit")
|
|
119
|
+
return { source: "explicit", spec: e.metricComparison.spec };
|
|
120
|
+
if (!((e.inheritGlobalComparison ?? ((n = e.globalDateComparison) == null ? void 0 : n.inheritGlobalComparison)) === !1 || ((t = e.globalDateComparison) == null ? void 0 : t.selection.mode) !== "period"))
|
|
121
|
+
return {
|
|
122
|
+
source: "inherited",
|
|
123
|
+
spec: e.globalDateComparison.selection.spec,
|
|
124
|
+
...e.globalDateComparison.owner ? { owner: e.globalDateComparison.owner } : {}
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
function R(e) {
|
|
129
|
+
if (e.alias) return e.alias;
|
|
130
|
+
const r = e.entityName && e.entityName !== "SEMAPHOR_CALCULATED_FIELD" ? e.entityName : void 0, o = r && r !== e.name ? `${r}_` : "";
|
|
131
|
+
if (e.role !== "metric") return `${o}${e.name}`;
|
|
132
|
+
let n = e.aggregate || "metric";
|
|
133
|
+
if (e.expression) {
|
|
134
|
+
const t = e.expression.match(
|
|
135
|
+
/^(COUNT|SUM|AVG|MIN|MAX|MEDIAN|DISTINCT)\s*\(/i
|
|
136
|
+
);
|
|
137
|
+
n = t ? t[1].toLowerCase() : "expr";
|
|
138
|
+
} else
|
|
139
|
+
n = n.toLowerCase();
|
|
140
|
+
return `${o}${e.name}_${n}`;
|
|
141
|
+
}
|
|
142
|
+
function a(e, r, o) {
|
|
143
|
+
return o ? { code: e, message: r, path: o } : { code: e, message: r };
|
|
144
|
+
}
|
|
145
|
+
function d(e) {
|
|
146
|
+
return !!e && typeof e == "object" && !Array.isArray(e);
|
|
147
|
+
}
|
|
148
|
+
function s(e, r, o, n) {
|
|
149
|
+
Object.keys(e).forEach((t) => {
|
|
150
|
+
r.includes(t) || n.push(
|
|
151
|
+
a(
|
|
152
|
+
"invalid_comparison_spec",
|
|
153
|
+
`Comparison kind does not accept field "${t}".`,
|
|
154
|
+
`${o}.${t}`
|
|
155
|
+
)
|
|
156
|
+
);
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
function u(e, r, o) {
|
|
160
|
+
e.alignment !== void 0 && e.alignment !== "calendar" && e.alignment !== "weekday" && o.push(
|
|
161
|
+
a(
|
|
162
|
+
"invalid_comparison_spec",
|
|
163
|
+
'Comparison alignment must be "calendar" or "weekday".',
|
|
164
|
+
`${r}.alignment`
|
|
165
|
+
)
|
|
166
|
+
), e.toDate !== void 0 && typeof e.toDate != "boolean" && o.push(
|
|
167
|
+
a(
|
|
168
|
+
"invalid_comparison_spec",
|
|
169
|
+
"Comparison toDate must be a boolean.",
|
|
170
|
+
`${r}.toDate`
|
|
171
|
+
)
|
|
172
|
+
);
|
|
173
|
+
}
|
|
174
|
+
function b(e, r, o) {
|
|
175
|
+
e !== void 0 && (typeof e != "number" || !Number.isSafeInteger(e) || e <= 0) && o.push(
|
|
176
|
+
a(
|
|
177
|
+
"invalid_comparison_spec",
|
|
178
|
+
"Comparison offset must be a positive safe integer.",
|
|
179
|
+
r
|
|
180
|
+
)
|
|
181
|
+
);
|
|
182
|
+
}
|
|
183
|
+
function _(e, r = "comparison") {
|
|
184
|
+
const o = [];
|
|
185
|
+
return d(e) ? (e.kind === "previous_period" ? (s(
|
|
186
|
+
e,
|
|
187
|
+
["kind", "offsetPeriods", "alignment", "toDate"],
|
|
188
|
+
r,
|
|
189
|
+
o
|
|
190
|
+
), b(e.offsetPeriods, `${r}.offsetPeriods`, o), u(e, r, o)) : e.kind === "previous_year" ? (s(
|
|
191
|
+
e,
|
|
192
|
+
["kind", "offsetYears", "alignment", "toDate"],
|
|
193
|
+
r,
|
|
194
|
+
o
|
|
195
|
+
), b(e.offsetYears, `${r}.offsetYears`, o), u(e, r, o)) : e.kind === "target" ? (s(e, ["kind", "targetValue"], r, o), (typeof e.targetValue != "number" || !Number.isFinite(e.targetValue)) && o.push(
|
|
196
|
+
a(
|
|
197
|
+
"invalid_comparison_spec",
|
|
198
|
+
"Target comparison requires a finite targetValue.",
|
|
199
|
+
`${r}.targetValue`
|
|
200
|
+
)
|
|
201
|
+
)) : o.push(
|
|
202
|
+
a(
|
|
203
|
+
"invalid_comparison_spec",
|
|
204
|
+
"Comparison kind must be previous_period, previous_year, or target.",
|
|
205
|
+
`${r}.kind`
|
|
206
|
+
)
|
|
207
|
+
), { ok: o.length === 0, errors: o, warnings: [] }) : {
|
|
208
|
+
ok: !1,
|
|
209
|
+
errors: [
|
|
210
|
+
a(
|
|
211
|
+
"invalid_comparison_spec",
|
|
212
|
+
"Comparison spec must be an object.",
|
|
213
|
+
r
|
|
214
|
+
)
|
|
215
|
+
],
|
|
216
|
+
warnings: []
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
function E(e, r = "comparison") {
|
|
220
|
+
if (!d(e))
|
|
221
|
+
return {
|
|
222
|
+
ok: !1,
|
|
223
|
+
errors: [
|
|
224
|
+
a(
|
|
225
|
+
"invalid_comparison_config",
|
|
226
|
+
"Comparison config must be an object.",
|
|
227
|
+
r
|
|
228
|
+
)
|
|
229
|
+
],
|
|
230
|
+
warnings: []
|
|
231
|
+
};
|
|
232
|
+
const o = [];
|
|
233
|
+
return e.mode === "off" ? s(e, ["mode"], r, o) : e.mode === "explicit" ? (s(e, ["mode", "spec"], r, o), o.push(..._(e.spec, `${r}.spec`).errors)) : o.push(
|
|
234
|
+
a(
|
|
235
|
+
"invalid_comparison_config",
|
|
236
|
+
"Comparison mode must be off or explicit.",
|
|
237
|
+
`${r}.mode`
|
|
238
|
+
)
|
|
239
|
+
), { ok: o.length === 0, errors: o, warnings: [] };
|
|
240
|
+
}
|
|
241
|
+
function T(e, r = "comparisonSelection") {
|
|
242
|
+
if (!d(e))
|
|
243
|
+
return {
|
|
244
|
+
ok: !1,
|
|
245
|
+
errors: [
|
|
246
|
+
a(
|
|
247
|
+
"invalid_global_date_comparison",
|
|
248
|
+
"Global Date comparison selection must be an object.",
|
|
249
|
+
r
|
|
250
|
+
)
|
|
251
|
+
],
|
|
252
|
+
warnings: []
|
|
253
|
+
};
|
|
254
|
+
const o = [];
|
|
255
|
+
if (e.mode === "off")
|
|
256
|
+
s(e, ["mode"], r, o);
|
|
257
|
+
else if (e.mode === "period") {
|
|
258
|
+
s(e, ["mode", "spec"], r, o);
|
|
259
|
+
const n = _(e.spec, `${r}.spec`);
|
|
260
|
+
o.push(...n.errors), d(e.spec) && e.spec.kind === "target" && o.push(
|
|
261
|
+
a(
|
|
262
|
+
"invalid_global_date_comparison",
|
|
263
|
+
"Global Date comparison supports previous_period or previous_year, not target.",
|
|
264
|
+
`${r}.spec.kind`
|
|
265
|
+
)
|
|
266
|
+
);
|
|
267
|
+
} else
|
|
268
|
+
o.push(
|
|
269
|
+
a(
|
|
270
|
+
"invalid_global_date_comparison",
|
|
271
|
+
"Global Date comparison mode must be off or period.",
|
|
272
|
+
`${r}.mode`
|
|
273
|
+
)
|
|
274
|
+
);
|
|
275
|
+
return { ok: o.length === 0, errors: o, warnings: [] };
|
|
276
|
+
}
|
|
277
|
+
function O(e, r = "globalDateComparison") {
|
|
278
|
+
if (!d(e))
|
|
279
|
+
return {
|
|
280
|
+
ok: !1,
|
|
281
|
+
errors: [
|
|
282
|
+
a(
|
|
283
|
+
"invalid_global_date_comparison",
|
|
284
|
+
"Global Date comparison context must be an object.",
|
|
285
|
+
r
|
|
286
|
+
)
|
|
287
|
+
],
|
|
288
|
+
warnings: []
|
|
289
|
+
};
|
|
290
|
+
const o = [];
|
|
291
|
+
return s(
|
|
292
|
+
e,
|
|
293
|
+
["selection", "inheritGlobalComparison", "owner", "referenceTime"],
|
|
294
|
+
r,
|
|
295
|
+
o
|
|
296
|
+
), o.push(
|
|
297
|
+
...T(
|
|
298
|
+
e.selection,
|
|
299
|
+
`${r}.selection`
|
|
300
|
+
).errors
|
|
301
|
+
), e.inheritGlobalComparison !== void 0 && e.inheritGlobalComparison !== !1 && o.push(
|
|
302
|
+
a(
|
|
303
|
+
"invalid_global_date_comparison",
|
|
304
|
+
"inheritGlobalComparison may only be false when present.",
|
|
305
|
+
`${r}.inheritGlobalComparison`
|
|
306
|
+
)
|
|
307
|
+
), e.owner !== void 0 && (d(e.owner) ? e.owner.kind === "global_date" ? s(e.owner, ["kind"], `${r}.owner`, o) : e.owner.kind === "field_date" ? (s(
|
|
308
|
+
e.owner,
|
|
309
|
+
["kind", "filterId", "label"],
|
|
310
|
+
`${r}.owner`,
|
|
311
|
+
o
|
|
312
|
+
), (typeof e.owner.filterId != "string" || !e.owner.filterId.trim()) && o.push(
|
|
313
|
+
a(
|
|
314
|
+
"invalid_global_date_comparison",
|
|
315
|
+
"Field Date comparison owner requires a non-empty filterId.",
|
|
316
|
+
`${r}.owner.filterId`
|
|
317
|
+
)
|
|
318
|
+
), (typeof e.owner.label != "string" || !e.owner.label.trim()) && o.push(
|
|
319
|
+
a(
|
|
320
|
+
"invalid_global_date_comparison",
|
|
321
|
+
"Field Date comparison owner requires a non-empty label.",
|
|
322
|
+
`${r}.owner.label`
|
|
323
|
+
)
|
|
324
|
+
)) : o.push(
|
|
325
|
+
a(
|
|
326
|
+
"invalid_global_date_comparison",
|
|
327
|
+
"Comparison owner kind must be global_date or field_date.",
|
|
328
|
+
`${r}.owner.kind`
|
|
329
|
+
)
|
|
330
|
+
) : o.push(
|
|
331
|
+
a(
|
|
332
|
+
"invalid_global_date_comparison",
|
|
333
|
+
"Comparison owner must be an object.",
|
|
334
|
+
`${r}.owner`
|
|
335
|
+
)
|
|
336
|
+
)), e.referenceTime !== void 0 && (typeof e.referenceTime != "string" || !y(e.referenceTime)) && o.push(
|
|
337
|
+
a(
|
|
338
|
+
"invalid_global_date_comparison",
|
|
339
|
+
"referenceTime must be a valid ISO date-time string when present.",
|
|
340
|
+
`${r}.referenceTime`
|
|
341
|
+
)
|
|
342
|
+
), { ok: o.length === 0, errors: o, warnings: [] };
|
|
343
|
+
}
|
|
344
|
+
function G(e) {
|
|
345
|
+
const { referenceTime: r, ...o } = e;
|
|
346
|
+
return o;
|
|
347
|
+
}
|
|
348
|
+
function L(e, r = "comparisonPolarity") {
|
|
349
|
+
return e === "higher_is_better" || e === "lower_is_better" || e === "neutral" ? { ok: !0, errors: [], warnings: [] } : {
|
|
350
|
+
ok: !1,
|
|
351
|
+
errors: [
|
|
352
|
+
a(
|
|
353
|
+
"invalid_comparison_polarity",
|
|
354
|
+
"Comparison polarity must be higher_is_better, lower_is_better, or neutral.",
|
|
355
|
+
r
|
|
356
|
+
)
|
|
357
|
+
],
|
|
358
|
+
warnings: []
|
|
359
|
+
};
|
|
360
|
+
}
|
|
361
|
+
function P(e, r = "comparisonPresentation") {
|
|
362
|
+
if (!d(e))
|
|
363
|
+
return {
|
|
364
|
+
ok: !1,
|
|
365
|
+
errors: [
|
|
366
|
+
a(
|
|
367
|
+
"invalid_comparison_presentation",
|
|
368
|
+
"Comparison presentation must be an object.",
|
|
369
|
+
r
|
|
370
|
+
)
|
|
371
|
+
],
|
|
372
|
+
warnings: []
|
|
373
|
+
};
|
|
374
|
+
const o = [], n = [
|
|
375
|
+
"displayMode",
|
|
376
|
+
"showComparison",
|
|
377
|
+
"precision",
|
|
378
|
+
"indicatorStyle",
|
|
379
|
+
"showColor",
|
|
380
|
+
"position",
|
|
381
|
+
"conditionalLabel",
|
|
382
|
+
"labelName",
|
|
383
|
+
"conditionalLabels",
|
|
384
|
+
"colors"
|
|
385
|
+
];
|
|
386
|
+
return Object.keys(e).forEach((i) => {
|
|
387
|
+
n.includes(i) || o.push(
|
|
388
|
+
a(
|
|
389
|
+
"invalid_comparison_presentation",
|
|
390
|
+
`Comparison presentation does not accept field "${i}".`,
|
|
391
|
+
`${r}.${i}`
|
|
392
|
+
)
|
|
393
|
+
);
|
|
394
|
+
}), [
|
|
395
|
+
["displayMode", ["difference", "percent_change", "both", "ratio"]],
|
|
396
|
+
["indicatorStyle", ["arrow_badge", "arrow", "badge", "none"]],
|
|
397
|
+
["position", ["left", "right", "top"]]
|
|
398
|
+
].forEach(([i, l]) => {
|
|
399
|
+
e[i] !== void 0 && !l.includes(e[i]) && o.push(
|
|
400
|
+
a(
|
|
401
|
+
"invalid_comparison_presentation",
|
|
402
|
+
`Comparison presentation ${i} is invalid.`,
|
|
403
|
+
`${r}.${i}`
|
|
404
|
+
)
|
|
405
|
+
);
|
|
406
|
+
}), ["showComparison", "showColor", "conditionalLabel"].forEach((i) => {
|
|
407
|
+
e[i] !== void 0 && typeof e[i] != "boolean" && o.push(
|
|
408
|
+
a(
|
|
409
|
+
"invalid_comparison_presentation",
|
|
410
|
+
`Comparison presentation ${i} must be a boolean.`,
|
|
411
|
+
`${r}.${i}`
|
|
412
|
+
)
|
|
413
|
+
);
|
|
414
|
+
}), e.precision !== void 0 && (typeof e.precision != "number" || !Number.isInteger(e.precision) || e.precision < 0 || e.precision > 6) && o.push(
|
|
415
|
+
a(
|
|
416
|
+
"invalid_comparison_presentation",
|
|
417
|
+
"Comparison presentation precision must be an integer from 0 through 6.",
|
|
418
|
+
`${r}.precision`
|
|
419
|
+
)
|
|
420
|
+
), e.labelName !== void 0 && typeof e.labelName != "string" && o.push(
|
|
421
|
+
a(
|
|
422
|
+
"invalid_comparison_presentation",
|
|
423
|
+
"Comparison presentation labelName must be a string.",
|
|
424
|
+
`${r}.labelName`
|
|
425
|
+
)
|
|
426
|
+
), ["conditionalLabels", "colors"].forEach((i) => {
|
|
427
|
+
const l = e[i];
|
|
428
|
+
if (l !== void 0) {
|
|
429
|
+
if (!d(l)) {
|
|
430
|
+
o.push(
|
|
431
|
+
a(
|
|
432
|
+
"invalid_comparison_presentation",
|
|
433
|
+
`Comparison presentation ${i} must be an object.`,
|
|
434
|
+
`${r}.${i}`
|
|
435
|
+
)
|
|
436
|
+
);
|
|
437
|
+
return;
|
|
438
|
+
}
|
|
439
|
+
Object.keys(l).forEach((c) => {
|
|
440
|
+
["increase", "decrease", "neutral"].includes(c) || o.push(
|
|
441
|
+
a(
|
|
442
|
+
"invalid_comparison_presentation",
|
|
443
|
+
`Comparison presentation ${i} does not accept field "${c}".`,
|
|
444
|
+
`${r}.${i}.${c}`
|
|
445
|
+
)
|
|
446
|
+
);
|
|
447
|
+
}), Object.entries(l).forEach(([c, p]) => {
|
|
448
|
+
p !== void 0 && typeof p != "string" && o.push(
|
|
449
|
+
a(
|
|
450
|
+
"invalid_comparison_presentation",
|
|
451
|
+
`Comparison presentation ${i}.${c} must be a string.`,
|
|
452
|
+
`${r}.${i}.${c}`
|
|
453
|
+
)
|
|
454
|
+
);
|
|
455
|
+
});
|
|
456
|
+
}
|
|
457
|
+
}), { ok: o.length === 0, errors: o, warnings: [] };
|
|
458
|
+
}
|
|
459
|
+
function v(e) {
|
|
460
|
+
return e === null ? "unknown" : e > 0 ? "increase" : e < 0 ? "decrease" : "no_change";
|
|
461
|
+
}
|
|
462
|
+
function M(e, r) {
|
|
463
|
+
return e === "unknown" || e === "no_change" || r === "neutral" ? "neutral" : r === "higher_is_better" && e === "increase" || r === "lower_is_better" && e === "decrease" ? "favorable" : "unfavorable";
|
|
464
|
+
}
|
|
465
|
+
function B(e) {
|
|
466
|
+
const {
|
|
467
|
+
currentValue: r,
|
|
468
|
+
comparisonValue: o,
|
|
469
|
+
polarity: n = h
|
|
470
|
+
} = e, i = r !== null && o !== null ? r - o : null, l = i !== null && o !== null && o !== 0 ? i / Math.abs(o) : null, c = r !== null && o !== null && o !== 0 ? r / o : null, p = v(i);
|
|
471
|
+
return {
|
|
472
|
+
status: o === null ? "insufficient_history" : "available",
|
|
473
|
+
currentValue: r,
|
|
474
|
+
comparisonValue: o,
|
|
475
|
+
delta: i,
|
|
476
|
+
percentChange: l,
|
|
477
|
+
ratio: c,
|
|
478
|
+
direction: p,
|
|
479
|
+
sentiment: M(p, n)
|
|
480
|
+
};
|
|
481
|
+
}
|
|
482
|
+
export {
|
|
483
|
+
A as C,
|
|
484
|
+
h as D,
|
|
485
|
+
T as a,
|
|
486
|
+
N as b,
|
|
487
|
+
_ as c,
|
|
488
|
+
E as d,
|
|
489
|
+
O as e,
|
|
490
|
+
L as f,
|
|
491
|
+
P as g,
|
|
492
|
+
B as h,
|
|
493
|
+
f as i,
|
|
494
|
+
I as j,
|
|
495
|
+
R as r,
|
|
496
|
+
w as v,
|
|
497
|
+
G as w
|
|
498
|
+
};
|