react-semaphor 0.1.324 → 0.1.326
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/analytics-protocol/index.cjs +1 -0
- package/dist/analytics-protocol/index.js +274 -0
- package/dist/brand-studio/index.cjs +2 -2
- package/dist/brand-studio/index.js +7 -6
- package/dist/chunks/{braces-C7BeIXvM.js → braces-DVaMJoCd.js} +1 -1
- package/dist/chunks/{braces-ZjRH2Kl7.js → braces-dHeaioTd.js} +1 -1
- package/dist/chunks/{calendar-preferences-dialog-B9Hz3pTH.js → calendar-preferences-dialog--2jD-eKu.js} +6 -5
- package/dist/chunks/calendar-preferences-dialog-mqU_uOmY.js +1 -0
- package/dist/chunks/{chevrons-up-down-CA-XvN1o.js → chevrons-up-down-CLbzBHoI.js} +1 -1
- package/dist/chunks/{chevrons-up-down-Cuilz9aY.js → chevrons-up-down-DNQE-uEp.js} +1 -1
- package/dist/chunks/{dashboard-briefing-launcher-COLpvReF.js → dashboard-briefing-launcher-DguNfFr8.js} +1 -1
- package/dist/chunks/{dashboard-briefing-launcher-CUEn7cr6.js → dashboard-briefing-launcher-DsjXUPFq.js} +29 -28
- package/dist/chunks/{dashboard-controls-CLShFyUq.js → dashboard-controls-DgNkM1yT.js} +10 -9
- package/dist/chunks/{dashboard-controls-DH8gdpOc.js → dashboard-controls-XCa9PZuU.js} +1 -1
- package/dist/chunks/dashboard-json-DiBd65Xf.js +1 -0
- package/dist/chunks/{dashboard-json-Db0DpTMw.js → dashboard-json-DkA6Bf0Y.js} +7 -6
- package/dist/chunks/{edit-dashboard-visual-Cc3xpTNQ.js → edit-dashboard-visual-BC9eOc4U.js} +2 -2
- package/dist/chunks/{edit-dashboard-visual-DmMKWtln.js → edit-dashboard-visual-Q5hW5MXk.js} +11 -9
- package/dist/chunks/index-B1-46PoR.js +1303 -0
- package/dist/chunks/index-BxM99sFL.js +1 -0
- package/dist/chunks/index-CuHybtft.js +51 -0
- package/dist/chunks/{index-PTx7430W.js → index-DwfDwtv2.js} +33456 -32921
- package/dist/chunks/{palette-CanPG11m.js → palette-DpcvHAiY.js} +1 -1
- package/dist/chunks/{palette-D96DOM7E.js → palette-DtmNws9a.js} +1 -1
- package/dist/chunks/{resource-management-panel-DR7Ku6sa.js → resource-management-panel-CGwWKZOP.js} +1 -1
- package/dist/chunks/{resource-management-panel-C1mbF-2a.js → resource-management-panel-D2oAQkKi.js} +6 -5
- package/dist/chunks/{save-DxkSzUTZ.js → save-BY7WF62U.js} +1 -1
- package/dist/chunks/{save-CqrBQKG6.js → save-Cv_XRb94.js} +1 -1
- package/dist/chunks/{switch-BXICAlvS.js → switch-5aQ_jcLH.js} +39 -39
- package/dist/chunks/{switch-Deo2Ltmj.js → switch-j3AThLFk.js} +2580 -2628
- package/dist/chunks/{use-create-flow-overlay-state-CmxTpqeg.js → use-create-flow-overlay-state-BQPXP0AM.js} +1 -1
- package/dist/chunks/{use-create-flow-overlay-state-B65gg2oB.js → use-create-flow-overlay-state-CP6GDQAX.js} +29 -28
- package/dist/chunks/{use-visual-utils-Diuguy3D.js → use-visual-utils-CSXU-96k.js} +2 -2
- package/dist/chunks/{use-visual-utils-51Nsy8cj.js → use-visual-utils-NpOW5uZ1.js} +1 -1
- package/dist/chunks/validators-DJUMR5An.js +2 -0
- package/dist/chunks/validators-DvTxl9i0.js +352 -0
- package/dist/dashboard/index.cjs +1 -1
- package/dist/dashboard/index.js +1 -1
- package/dist/dashboard-authoring/index.cjs +3 -3
- package/dist/dashboard-authoring/index.js +857 -310
- package/dist/data-app-sdk/index.cjs +1 -0
- package/dist/data-app-sdk/index.js +512 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +141 -140
- package/dist/surfboard/index.cjs +1 -1
- package/dist/surfboard/index.js +2 -2
- package/dist/types/analytics-protocol.d.ts +495 -0
- package/dist/types/dashboard-authoring.d.ts +183 -0
- package/dist/types/dashboard.d.ts +6 -1
- package/dist/types/data-app-sdk.d.ts +378 -0
- package/dist/types/main.d.ts +118 -2
- package/dist/types/shared.d.ts +1 -0
- package/dist/types/surfboard.d.ts +6 -1
- package/dist/types/types.d.ts +6 -1
- package/package.json +11 -1
- package/dist/chunks/calendar-preferences-dialog-CLXaVo3h.js +0 -1
- package/dist/chunks/dashboard-json-eGBWfSN1.js +0 -1
- package/dist/chunks/index-CMS4bp9G.js +0 -1303
|
@@ -1,532 +1,1079 @@
|
|
|
1
|
-
|
|
1
|
+
import { a as Z, v as ee } from "../chunks/validators-DvTxl9i0.js";
|
|
2
|
+
const te = [
|
|
2
3
|
"lg",
|
|
3
4
|
"md",
|
|
4
5
|
"sm",
|
|
5
6
|
"xs",
|
|
6
7
|
"xxs"
|
|
7
|
-
],
|
|
8
|
-
function
|
|
9
|
-
return
|
|
10
|
-
}
|
|
11
|
-
function
|
|
12
|
-
const
|
|
13
|
-
for (const
|
|
14
|
-
if (
|
|
15
|
-
return
|
|
16
|
-
|
|
8
|
+
], $ = 10;
|
|
9
|
+
function f(e, t, a) {
|
|
10
|
+
return a ? { code: e, message: t, cardId: a } : { code: e, message: t };
|
|
11
|
+
}
|
|
12
|
+
function D(e) {
|
|
13
|
+
const t = /* @__PURE__ */ new Set();
|
|
14
|
+
for (const a of e) {
|
|
15
|
+
if (t.has(a))
|
|
16
|
+
return a;
|
|
17
|
+
t.add(a);
|
|
17
18
|
}
|
|
18
19
|
return null;
|
|
19
20
|
}
|
|
20
|
-
function
|
|
21
|
-
var
|
|
22
|
-
const
|
|
23
|
-
if (!
|
|
21
|
+
function ae(e) {
|
|
22
|
+
var w, C;
|
|
23
|
+
const t = [];
|
|
24
|
+
if (!e || typeof e != "object")
|
|
24
25
|
return {
|
|
25
26
|
ok: !1,
|
|
26
27
|
errors: [
|
|
27
|
-
|
|
28
|
+
f(
|
|
28
29
|
"invalid_plan",
|
|
29
30
|
"Dashboard plan must be a structured object."
|
|
30
31
|
)
|
|
31
32
|
],
|
|
32
33
|
warnings: []
|
|
33
34
|
};
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
35
|
+
const a = e, n = [...a.warnings || []];
|
|
36
|
+
a.version !== 1 && t.push(f("invalid_version", "Dashboard plan version must be 1.")), (w = a.title) != null && w.trim() || t.push(f("missing_title", "Dashboard plan needs a title."));
|
|
37
|
+
const i = Array.isArray(a.datasets) ? a.datasets : [], r = Array.isArray(a.sheets) ? a.sheets : [];
|
|
38
|
+
i.length !== 1 && t.push(
|
|
39
|
+
f(
|
|
39
40
|
"invalid_dataset_count",
|
|
40
41
|
"MVP dashboard authoring requires exactly one selected dataset."
|
|
41
42
|
)
|
|
42
|
-
),
|
|
43
|
-
|
|
43
|
+
), r.length !== 1 && t.push(
|
|
44
|
+
f(
|
|
44
45
|
"invalid_sheet_count",
|
|
45
46
|
"MVP dashboard authoring creates exactly one dashboard sheet."
|
|
46
47
|
)
|
|
47
48
|
);
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
|
|
49
|
+
const d = r[0];
|
|
50
|
+
d && d.kind !== "dashboard" && t.push(
|
|
51
|
+
f("invalid_sheet_kind", 'Generated sheet must use kind "dashboard".')
|
|
51
52
|
);
|
|
52
|
-
const l = (
|
|
53
|
-
l.length >
|
|
54
|
-
|
|
53
|
+
const l = (d == null ? void 0 : d.cards) || [];
|
|
54
|
+
l.length > $ && t.push(
|
|
55
|
+
f(
|
|
55
56
|
"too_many_cards",
|
|
56
|
-
|
|
57
|
+
`Generated dashboards can contain at most ${$} cards.`
|
|
57
58
|
)
|
|
58
59
|
);
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
|
|
60
|
+
const s = D(l.map((u) => u.id));
|
|
61
|
+
s && t.push(
|
|
62
|
+
f("duplicate_card_id", `Duplicate generated card id: ${s}.`)
|
|
62
63
|
);
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
|
|
64
|
+
const c = D(l.map((u) => u.frameId));
|
|
65
|
+
c && t.push(
|
|
66
|
+
f(
|
|
66
67
|
"duplicate_frame_id",
|
|
67
|
-
`Duplicate generated frame id: ${
|
|
68
|
+
`Duplicate generated frame id: ${c}.`
|
|
68
69
|
)
|
|
69
70
|
);
|
|
70
|
-
for (const
|
|
71
|
-
(
|
|
72
|
-
|
|
71
|
+
for (const u of l)
|
|
72
|
+
(C = u.title) != null && C.trim() || t.push(f("missing_card_title", "Card title is required.", u.id)), u.type === "custom" && t.push(
|
|
73
|
+
f(
|
|
73
74
|
"custom_visual_out_of_scope",
|
|
74
75
|
"Whole-dashboard authoring supports built-in visual types only.",
|
|
75
|
-
|
|
76
|
+
u.id
|
|
76
77
|
)
|
|
77
|
-
),
|
|
78
|
-
|
|
78
|
+
), u.type !== "text" && !u.query && n.push(
|
|
79
|
+
f(
|
|
79
80
|
"missing_query_intent",
|
|
80
81
|
"Non-text card has no query intent and may be skipped by the app layer.",
|
|
81
|
-
|
|
82
|
+
u.id
|
|
82
83
|
)
|
|
83
84
|
);
|
|
84
|
-
const
|
|
85
|
-
|
|
86
|
-
|
|
85
|
+
const m = Array.isArray(a.filterInputs) ? a.filterInputs : [], y = m.map((u) => u.id), g = D(y);
|
|
86
|
+
g && t.push(
|
|
87
|
+
f(
|
|
87
88
|
"duplicate_input_id",
|
|
88
|
-
`Duplicate dashboard input id: ${
|
|
89
|
+
`Duplicate dashboard input id: ${g}.`
|
|
89
90
|
)
|
|
90
91
|
);
|
|
91
|
-
const o =
|
|
92
|
-
|
|
93
|
-
|
|
92
|
+
const o = m.map((u) => u.variableName).filter(Boolean) || [], b = D(o);
|
|
93
|
+
b && t.push(
|
|
94
|
+
f(
|
|
94
95
|
"duplicate_input_variable",
|
|
95
|
-
`Duplicate dashboard input variable name: ${
|
|
96
|
+
`Duplicate dashboard input variable name: ${b}.`
|
|
96
97
|
)
|
|
97
98
|
);
|
|
98
|
-
const
|
|
99
|
-
for (const
|
|
100
|
-
|
|
101
|
-
|
|
99
|
+
const x = Array.isArray(a.calculatedFields) ? a.calculatedFields : [];
|
|
100
|
+
for (const u of x)
|
|
101
|
+
u.scope === "domain" && u.reuseOnly !== !0 && t.push(
|
|
102
|
+
f(
|
|
102
103
|
"domain_calculated_field_create_out_of_scope",
|
|
103
|
-
`Creating domain calculated field "${
|
|
104
|
+
`Creating domain calculated field "${u.name}" is outside MVP.`
|
|
104
105
|
)
|
|
105
106
|
);
|
|
106
|
-
return { ok:
|
|
107
|
+
return { ok: t.length === 0, errors: t, warnings: n };
|
|
107
108
|
}
|
|
108
|
-
function
|
|
109
|
-
var
|
|
110
|
-
const
|
|
111
|
-
if (!
|
|
109
|
+
function ne(e) {
|
|
110
|
+
var d;
|
|
111
|
+
const t = [];
|
|
112
|
+
if (!e || typeof e != "object")
|
|
112
113
|
return {
|
|
113
114
|
ok: !1,
|
|
114
115
|
errors: [
|
|
115
|
-
|
|
116
|
+
f(
|
|
116
117
|
"invalid_change_plan",
|
|
117
118
|
"Dashboard change plan must be a structured object."
|
|
118
119
|
)
|
|
119
120
|
],
|
|
120
121
|
warnings: []
|
|
121
122
|
};
|
|
122
|
-
const
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
), (
|
|
126
|
-
|
|
123
|
+
const a = e, n = [...a.warnings || []];
|
|
124
|
+
a.version !== 1 && t.push(
|
|
125
|
+
f("invalid_version", "Dashboard change plan version must be 1.")
|
|
126
|
+
), (d = a.dashboardId) != null && d.trim() || t.push(
|
|
127
|
+
f("missing_dashboard_id", "Dashboard change plan needs a dashboard id.")
|
|
127
128
|
);
|
|
128
|
-
const
|
|
129
|
-
|
|
130
|
-
|
|
129
|
+
const i = Array.isArray(a.datasets) ? a.datasets : [], r = Array.isArray(a.operations) ? a.operations : [];
|
|
130
|
+
i.length > 1 && t.push(
|
|
131
|
+
f(
|
|
131
132
|
"invalid_dataset_count",
|
|
132
133
|
"MVP dashboard refinement can ground new AI operations in at most one selected dataset."
|
|
133
134
|
)
|
|
134
135
|
);
|
|
135
|
-
for (const l of
|
|
136
|
+
for (const l of r) {
|
|
136
137
|
if (l.kind === "unsupported") {
|
|
137
|
-
|
|
138
|
-
|
|
138
|
+
n.push(
|
|
139
|
+
f("unsupported_operation", l.reason || l.requestedAction)
|
|
139
140
|
);
|
|
140
141
|
continue;
|
|
141
142
|
}
|
|
142
|
-
l.kind === "addCard" && l.card.type === "custom" &&
|
|
143
|
-
|
|
143
|
+
l.kind === "addCard" && l.card.type === "custom" && t.push(
|
|
144
|
+
f(
|
|
144
145
|
"custom_visual_out_of_scope",
|
|
145
146
|
"Whole-dashboard authoring supports built-in visual types only.",
|
|
146
147
|
l.card.id
|
|
147
148
|
)
|
|
148
|
-
), l.kind === "addCalculatedField" && l.field.scope === "domain" && l.field.reuseOnly !== !0 &&
|
|
149
|
-
|
|
149
|
+
), l.kind === "addCalculatedField" && l.field.scope === "domain" && l.field.reuseOnly !== !0 && t.push(
|
|
150
|
+
f(
|
|
150
151
|
"domain_calculated_field_create_out_of_scope",
|
|
151
152
|
`Creating domain calculated field "${l.field.name}" is outside MVP.`
|
|
152
153
|
)
|
|
153
154
|
);
|
|
154
155
|
}
|
|
155
|
-
return { ok:
|
|
156
|
+
return { ok: t.length === 0, errors: t, warnings: n };
|
|
156
157
|
}
|
|
157
|
-
const
|
|
158
|
+
const re = {
|
|
158
159
|
lg: 48,
|
|
159
160
|
md: 36,
|
|
160
161
|
sm: 24,
|
|
161
162
|
xs: 12,
|
|
162
163
|
xxs: 6
|
|
163
164
|
};
|
|
164
|
-
function
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
return { w: 48, h: 28, minW: 12, minH: 12 };
|
|
170
|
-
case "text":
|
|
171
|
-
return { w: 48, h: 10, minW: 12, minH: 8 };
|
|
172
|
-
case "chart":
|
|
173
|
-
default:
|
|
174
|
-
return { w: 24, h: 24, minW: 12, minH: 10 };
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
function E(t, a) {
|
|
178
|
-
let e = 0, i = 0, n = 0;
|
|
179
|
-
return t.map((d) => {
|
|
180
|
-
const s = Math.min(d.w, a);
|
|
181
|
-
e > 0 && e + s > a && (e = 0, i += n, n = 0);
|
|
165
|
+
function ie(e, t) {
|
|
166
|
+
let a = 0, n = 0, i = 0;
|
|
167
|
+
return e.map((r) => {
|
|
168
|
+
const d = Math.min(r.w, t);
|
|
169
|
+
a > 0 && a + d > t && (a = 0, n += i, i = 0);
|
|
182
170
|
const l = {
|
|
183
|
-
i:
|
|
184
|
-
x:
|
|
185
|
-
y:
|
|
186
|
-
w:
|
|
187
|
-
h:
|
|
188
|
-
minW: Math.min(
|
|
189
|
-
minH:
|
|
171
|
+
i: r.frameId,
|
|
172
|
+
x: a,
|
|
173
|
+
y: n,
|
|
174
|
+
w: d,
|
|
175
|
+
h: r.h,
|
|
176
|
+
minW: Math.min(r.minW, t),
|
|
177
|
+
minH: r.minH,
|
|
190
178
|
static: !1
|
|
191
179
|
};
|
|
192
|
-
return
|
|
180
|
+
return a += d, i = Math.max(i, r.h), l;
|
|
193
181
|
});
|
|
194
182
|
}
|
|
195
|
-
function
|
|
196
|
-
const
|
|
183
|
+
function se(e) {
|
|
184
|
+
const t = [...e].sort((s, c) => s.priority - c.priority), a = t.filter((s) => s.role === "kpi"), n = t.filter((s) => s.role === "chart"), i = t.filter((s) => s.role === "table"), r = t.filter((s) => s.role === "text"), d = r.slice(0, 1), l = r.slice(d.length);
|
|
185
|
+
return { kpis: a, introText: d, charts: n, tables: i, supportingText: l };
|
|
186
|
+
}
|
|
187
|
+
function de(e, t, a) {
|
|
188
|
+
return t === "xxs" || t === "xs" ? a : t === "sm" ? Math.min(12, a) : t === "md" ? e <= 1 || e === 2 ? 18 : 12 : e <= 1 || e === 2 ? 24 : e === 3 ? 16 : 12;
|
|
189
|
+
}
|
|
190
|
+
function oe(e, t, a, n) {
|
|
191
|
+
return a === "xxs" || a === "xs" || a === "sm" || a === "md" || t === 1 || t % 2 === 1 && e === 0 ? n : n / 2;
|
|
192
|
+
}
|
|
193
|
+
function le(e) {
|
|
194
|
+
const { item: t, band: a, index: n, bandCount: i, breakpoint: r, columns: d } = e;
|
|
195
|
+
return a === "kpi" ? {
|
|
196
|
+
...t,
|
|
197
|
+
band: a,
|
|
198
|
+
w: de(i, r, d),
|
|
199
|
+
h: 15,
|
|
200
|
+
minW: Math.min(6, d),
|
|
201
|
+
minH: 12
|
|
202
|
+
} : a === "table" ? {
|
|
203
|
+
...t,
|
|
204
|
+
band: a,
|
|
205
|
+
w: d,
|
|
206
|
+
h: r === "xxs" || r === "xs" ? 34 : 38,
|
|
207
|
+
minW: Math.min(12, d),
|
|
208
|
+
minH: 18
|
|
209
|
+
} : a === "introText" ? {
|
|
210
|
+
...t,
|
|
211
|
+
band: a,
|
|
212
|
+
w: d,
|
|
213
|
+
h: r === "xxs" || r === "xs" ? 12 : 10,
|
|
214
|
+
minW: Math.min(12, d),
|
|
215
|
+
minH: 8
|
|
216
|
+
} : a === "supportingText" ? {
|
|
217
|
+
...t,
|
|
218
|
+
band: a,
|
|
219
|
+
w: r === "lg" ? d / 2 : d,
|
|
220
|
+
h: r === "xxs" || r === "xs" ? 12 : 10,
|
|
221
|
+
minW: Math.min(12, d),
|
|
222
|
+
minH: 8
|
|
223
|
+
} : {
|
|
224
|
+
...t,
|
|
225
|
+
band: a,
|
|
226
|
+
w: oe(n, i, r, d),
|
|
227
|
+
h: r === "xxs" || r === "xs" ? 28 : 30,
|
|
228
|
+
minW: Math.min(12, d),
|
|
229
|
+
minH: 16
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
function A(e, t, a, n) {
|
|
233
|
+
return e.map(
|
|
234
|
+
(i, r) => le({
|
|
235
|
+
item: i,
|
|
236
|
+
band: t,
|
|
237
|
+
index: r,
|
|
238
|
+
bandCount: e.length,
|
|
239
|
+
breakpoint: a,
|
|
240
|
+
columns: n
|
|
241
|
+
})
|
|
242
|
+
);
|
|
243
|
+
}
|
|
244
|
+
function P(e) {
|
|
245
|
+
const t = se(e);
|
|
197
246
|
return Object.fromEntries(
|
|
198
|
-
|
|
199
|
-
const
|
|
200
|
-
...
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
247
|
+
te.map((a) => {
|
|
248
|
+
const n = re[a], i = [
|
|
249
|
+
...A(t.introText, "introText", a, n),
|
|
250
|
+
...A(t.kpis, "kpi", a, n),
|
|
251
|
+
...A(t.charts, "chart", a, n),
|
|
252
|
+
...A(t.tables, "table", a, n),
|
|
253
|
+
...A(t.supportingText, "supportingText", a, n)
|
|
254
|
+
];
|
|
255
|
+
return [a, ie(i, n)];
|
|
205
256
|
})
|
|
206
257
|
);
|
|
207
258
|
}
|
|
208
|
-
function
|
|
209
|
-
|
|
259
|
+
function ce(e) {
|
|
260
|
+
const t = String(e || "").trim().toLowerCase();
|
|
261
|
+
return t.includes("date") || t.includes("time") || t.includes("timestamp") ? "date" : t.includes("int") || t.includes("float") || t.includes("double") || t.includes("decimal") || t.includes("numeric") || t.includes("number") || t.includes("currency") || t.includes("percent") ? "number" : t.includes("bool") ? "boolean" : "string";
|
|
210
262
|
}
|
|
211
|
-
function
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
return
|
|
216
|
-
|
|
263
|
+
function ue(e) {
|
|
264
|
+
return !!(e && typeof e == "object" && !Array.isArray(e));
|
|
265
|
+
}
|
|
266
|
+
function fe(e) {
|
|
267
|
+
return ue(e) && typeof e.filterId == "string" && typeof e.operation == "string" && Array.isArray(e.values);
|
|
268
|
+
}
|
|
269
|
+
function pe(e) {
|
|
270
|
+
return e.filter(
|
|
271
|
+
(t) => typeof t == "string" || typeof t == "number"
|
|
272
|
+
);
|
|
273
|
+
}
|
|
274
|
+
function me(e) {
|
|
275
|
+
return e.filter(
|
|
276
|
+
(t) => t instanceof Date || typeof t == "string"
|
|
277
|
+
);
|
|
278
|
+
}
|
|
279
|
+
function q(e, t) {
|
|
280
|
+
if (t === void 0)
|
|
281
|
+
return;
|
|
282
|
+
const a = ce(e.dataType), n = e.operation || "in";
|
|
283
|
+
if (fe(t))
|
|
284
|
+
return {
|
|
285
|
+
...t,
|
|
286
|
+
filterId: e.id,
|
|
287
|
+
name: t.name || e.column,
|
|
288
|
+
valueType: a,
|
|
289
|
+
dataType: e.dataType,
|
|
290
|
+
fieldMeta: e.fieldMeta,
|
|
291
|
+
semanticContext: e.semanticContext
|
|
292
|
+
};
|
|
293
|
+
if (n === "is null" || n === "is not null")
|
|
294
|
+
return {
|
|
295
|
+
filterId: e.id,
|
|
296
|
+
name: e.column,
|
|
297
|
+
operation: n,
|
|
298
|
+
valueType: a,
|
|
299
|
+
values: [],
|
|
300
|
+
dataType: e.dataType,
|
|
301
|
+
fieldMeta: e.fieldMeta,
|
|
302
|
+
semanticContext: e.semanticContext
|
|
303
|
+
};
|
|
304
|
+
const i = Array.isArray(t) ? t : [t], r = a === "date" ? me(i) : pe(i);
|
|
305
|
+
if (r.length !== 0 && !((n === "between" || n === "not between") && r.length < 2))
|
|
306
|
+
return {
|
|
307
|
+
filterId: e.id,
|
|
308
|
+
name: e.column,
|
|
309
|
+
operation: n,
|
|
310
|
+
valueType: a,
|
|
311
|
+
values: r,
|
|
312
|
+
dataType: e.dataType,
|
|
313
|
+
fieldMeta: e.fieldMeta,
|
|
314
|
+
semanticContext: e.semanticContext
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
function he(e, t, a) {
|
|
318
|
+
return a ? { code: e, message: t, cardId: a } : { code: e, message: t };
|
|
319
|
+
}
|
|
320
|
+
function be(e, t, a) {
|
|
321
|
+
const n = (t || []).filter(
|
|
322
|
+
(i) => i.scope === "card" && i.targetCardId === a
|
|
323
|
+
).map((i) => i.field).filter(Boolean);
|
|
324
|
+
return n.length === 0 ? e : {
|
|
325
|
+
...e,
|
|
217
326
|
calculatedFields: [
|
|
218
|
-
...
|
|
219
|
-
...
|
|
327
|
+
...e.calculatedFields || [],
|
|
328
|
+
...n
|
|
220
329
|
]
|
|
221
330
|
};
|
|
222
331
|
}
|
|
223
|
-
function
|
|
224
|
-
const
|
|
332
|
+
function ge(e) {
|
|
333
|
+
const t = {};
|
|
225
334
|
return {
|
|
226
|
-
inputs: (
|
|
227
|
-
|
|
228
|
-
|
|
335
|
+
inputs: (e.filterInputs || []).map((n, i) => {
|
|
336
|
+
const r = q(
|
|
337
|
+
n.filter,
|
|
338
|
+
n.defaultValue
|
|
339
|
+
);
|
|
340
|
+
return r && (t.shared ?? (t.shared = {}), t.shared[n.id] = {
|
|
341
|
+
status: "set",
|
|
342
|
+
value: {
|
|
343
|
+
kind: "filter",
|
|
344
|
+
filterValue: r
|
|
345
|
+
}
|
|
346
|
+
}), {
|
|
347
|
+
id: n.id,
|
|
229
348
|
kind: "filter",
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
exports: ["label", "value", "start", "end", "range"],
|
|
244
|
-
filter: i.filter
|
|
245
|
-
})),
|
|
246
|
-
defaultInputValues: a.shared && Object.keys(a.shared).length > 0 ? a : void 0
|
|
349
|
+
label: n.label,
|
|
350
|
+
variableName: n.variableName,
|
|
351
|
+
scope: n.scope || { kind: "allSheets", sheetKinds: ["dashboard"] },
|
|
352
|
+
runtimeScope: "shared",
|
|
353
|
+
presentation: {
|
|
354
|
+
placement: "toolbar",
|
|
355
|
+
order: i
|
|
356
|
+
},
|
|
357
|
+
exports: ["label", "value", "start", "end", "range"],
|
|
358
|
+
filter: n.filter
|
|
359
|
+
};
|
|
360
|
+
}),
|
|
361
|
+
defaultInputValues: t.shared && Object.keys(t.shared).length > 0 ? t : void 0
|
|
247
362
|
};
|
|
248
363
|
}
|
|
249
|
-
function
|
|
250
|
-
var
|
|
251
|
-
const
|
|
252
|
-
if (!
|
|
364
|
+
function Oe(e) {
|
|
365
|
+
var y, g;
|
|
366
|
+
const t = ae(e.plan);
|
|
367
|
+
if (!t.ok)
|
|
253
368
|
throw new Error(
|
|
254
|
-
|
|
369
|
+
t.errors.map((o) => o.message).join(`
|
|
255
370
|
`) || "Dashboard plan is invalid."
|
|
256
371
|
);
|
|
257
|
-
const
|
|
258
|
-
|
|
259
|
-
),
|
|
260
|
-
for (const o of
|
|
261
|
-
const
|
|
262
|
-
if (!
|
|
263
|
-
const
|
|
372
|
+
const a = e.plan.sheets[0], n = [...t.warnings], i = [], r = new Map(
|
|
373
|
+
e.cardArtifacts.map((o) => [o.planCardId, o])
|
|
374
|
+
), d = [];
|
|
375
|
+
for (const o of a.cards) {
|
|
376
|
+
const b = r.get(o.id);
|
|
377
|
+
if (!b) {
|
|
378
|
+
const w = he(
|
|
264
379
|
"missing_card_artifact",
|
|
265
380
|
`Card "${o.title}" was skipped because no generated artifact was supplied.`,
|
|
266
381
|
o.id
|
|
267
382
|
);
|
|
268
|
-
|
|
383
|
+
i.push(w);
|
|
269
384
|
continue;
|
|
270
385
|
}
|
|
271
|
-
|
|
272
|
-
const
|
|
273
|
-
|
|
274
|
-
|
|
386
|
+
n.push(...b.warnings || []);
|
|
387
|
+
const x = be(
|
|
388
|
+
b.card,
|
|
389
|
+
e.plan.calculatedFields,
|
|
275
390
|
o.id
|
|
276
391
|
);
|
|
277
|
-
|
|
392
|
+
d.push({
|
|
278
393
|
id: o.frameId,
|
|
279
|
-
cards: [
|
|
280
|
-
activeCardId:
|
|
394
|
+
cards: [x],
|
|
395
|
+
activeCardId: x.id
|
|
281
396
|
});
|
|
282
397
|
}
|
|
283
|
-
if (
|
|
398
|
+
if (d.length === 0)
|
|
284
399
|
throw new Error("Dashboard plan did not produce any persistable cards.");
|
|
285
|
-
const { inputs: l, defaultInputValues:
|
|
286
|
-
|
|
400
|
+
const { inputs: l, defaultInputValues: s } = ge(e.plan), c = P(
|
|
401
|
+
a.cards.filter((o) => d.some((b) => b.id === o.frameId)).map((o) => ({
|
|
287
402
|
frameId: o.frameId,
|
|
288
403
|
priority: o.priority,
|
|
289
404
|
role: o.role
|
|
290
405
|
}))
|
|
291
406
|
);
|
|
292
407
|
return { dashboard: {
|
|
293
|
-
id:
|
|
294
|
-
title:
|
|
295
|
-
description:
|
|
408
|
+
id: e.dashboardId,
|
|
409
|
+
title: e.plan.title,
|
|
410
|
+
description: e.plan.description || "",
|
|
296
411
|
sheets: [
|
|
297
412
|
{
|
|
298
|
-
id:
|
|
413
|
+
id: a.id,
|
|
299
414
|
kind: "dashboard",
|
|
300
|
-
title:
|
|
301
|
-
description:
|
|
302
|
-
frames:
|
|
303
|
-
layouts:
|
|
304
|
-
calculatedFields: (
|
|
415
|
+
title: a.title,
|
|
416
|
+
description: a.description,
|
|
417
|
+
frames: d,
|
|
418
|
+
layouts: c,
|
|
419
|
+
calculatedFields: (y = e.plan.calculatedFields) == null ? void 0 : y.filter((o) => o.scope === "sheet" && o.field).map((o) => o.field)
|
|
305
420
|
}
|
|
306
421
|
],
|
|
307
|
-
calculatedFields: (
|
|
422
|
+
calculatedFields: (g = e.plan.calculatedFields) == null ? void 0 : g.filter((o) => o.scope === "dashboard" && o.field).map((o) => o.field),
|
|
308
423
|
inputs: l,
|
|
309
|
-
...
|
|
310
|
-
}, warnings:
|
|
424
|
+
...s ? { defaultInputValues: s } : {}
|
|
425
|
+
}, warnings: n, skippedOperations: i };
|
|
311
426
|
}
|
|
312
|
-
function
|
|
313
|
-
return
|
|
427
|
+
function k(e, t, a) {
|
|
428
|
+
return a ? { code: e, message: t, cardId: a } : { code: e, message: t };
|
|
314
429
|
}
|
|
315
|
-
function
|
|
316
|
-
return JSON.parse(JSON.stringify(
|
|
430
|
+
function Ie(e) {
|
|
431
|
+
return JSON.parse(JSON.stringify(e));
|
|
317
432
|
}
|
|
318
|
-
function
|
|
319
|
-
var
|
|
320
|
-
return (
|
|
321
|
-
(
|
|
433
|
+
function ye(e) {
|
|
434
|
+
var t;
|
|
435
|
+
return (t = e.sheets) == null ? void 0 : t.find(
|
|
436
|
+
(a) => (a.kind || "dashboard") === "dashboard"
|
|
322
437
|
);
|
|
323
438
|
}
|
|
324
|
-
function
|
|
325
|
-
var
|
|
326
|
-
for (const
|
|
327
|
-
for (const
|
|
328
|
-
const
|
|
329
|
-
if (
|
|
330
|
-
return { sheet:
|
|
439
|
+
function M(e, t) {
|
|
440
|
+
var a;
|
|
441
|
+
for (const n of e.sheets || [])
|
|
442
|
+
for (const i of n.frames || []) {
|
|
443
|
+
const r = (a = i.cards) == null ? void 0 : a.find((d) => d.id === t);
|
|
444
|
+
if (r)
|
|
445
|
+
return { sheet: n, frame: i, card: r };
|
|
331
446
|
}
|
|
332
447
|
return null;
|
|
333
448
|
}
|
|
334
|
-
function
|
|
335
|
-
var
|
|
336
|
-
const
|
|
337
|
-
return
|
|
449
|
+
function W(e) {
|
|
450
|
+
var a, n;
|
|
451
|
+
const t = (n = (a = e.cards) == null ? void 0 : a[0]) == null ? void 0 : n.type;
|
|
452
|
+
return t === "kpi" ? "kpi" : t === "table" || t === "detailTable" || t === "pivotTable" ? "table" : t === "text" ? "text" : "chart";
|
|
338
453
|
}
|
|
339
|
-
function
|
|
340
|
-
var
|
|
454
|
+
function we(e) {
|
|
455
|
+
var t;
|
|
341
456
|
return new Map(
|
|
342
|
-
(((
|
|
457
|
+
(((t = e.layouts) == null ? void 0 : t.lg) || []).map((a, n) => [a.i, n])
|
|
343
458
|
);
|
|
344
459
|
}
|
|
345
|
-
function
|
|
346
|
-
const
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
),
|
|
350
|
-
(
|
|
351
|
-
frameId:
|
|
352
|
-
role:
|
|
353
|
-
priority:
|
|
460
|
+
function G(e, t = /* @__PURE__ */ new Map()) {
|
|
461
|
+
const a = we(e), n = Math.max(
|
|
462
|
+
a.size,
|
|
463
|
+
t.size
|
|
464
|
+
), i = (e.frames || []).map(
|
|
465
|
+
(r, d) => ({
|
|
466
|
+
frameId: r.id,
|
|
467
|
+
role: W(r),
|
|
468
|
+
priority: t.get(r.id) ?? a.get(r.id) ?? n + d
|
|
354
469
|
})
|
|
355
470
|
);
|
|
356
|
-
|
|
471
|
+
e.layouts = P(i);
|
|
357
472
|
}
|
|
358
|
-
function
|
|
359
|
-
return Object.values(
|
|
473
|
+
function _e(e) {
|
|
474
|
+
return Object.values(e.layouts || {}).some((t) => t.length > 0);
|
|
360
475
|
}
|
|
361
|
-
function
|
|
362
|
-
if (!
|
|
363
|
-
|
|
476
|
+
function ve(e, t) {
|
|
477
|
+
if (!_e(e)) {
|
|
478
|
+
G(e);
|
|
364
479
|
return;
|
|
365
480
|
}
|
|
366
|
-
const
|
|
367
|
-
{ frameId:
|
|
481
|
+
const a = P([
|
|
482
|
+
{ frameId: t.id, role: W(t), priority: 0 }
|
|
368
483
|
]);
|
|
369
|
-
|
|
370
|
-
for (const [
|
|
371
|
-
const
|
|
372
|
-
if (
|
|
484
|
+
e.layouts ?? (e.layouts = {});
|
|
485
|
+
for (const [n, i] of Object.entries(a)) {
|
|
486
|
+
const r = e.layouts[n] || [];
|
|
487
|
+
if (r.some((s) => s.i === t.id))
|
|
373
488
|
continue;
|
|
374
|
-
const
|
|
375
|
-
if (!
|
|
489
|
+
const d = i[0];
|
|
490
|
+
if (!d)
|
|
376
491
|
continue;
|
|
377
|
-
const l =
|
|
378
|
-
(
|
|
492
|
+
const l = r.reduce(
|
|
493
|
+
(s, c) => Math.max(s, c.y + c.h),
|
|
379
494
|
0
|
|
380
495
|
);
|
|
381
|
-
|
|
382
|
-
...
|
|
383
|
-
{ ...
|
|
496
|
+
e.layouts[n] = [
|
|
497
|
+
...r,
|
|
498
|
+
{ ...d, y: l }
|
|
384
499
|
];
|
|
385
500
|
}
|
|
386
501
|
}
|
|
387
|
-
function
|
|
388
|
-
var
|
|
389
|
-
a
|
|
502
|
+
function ke(e, t) {
|
|
503
|
+
var n;
|
|
504
|
+
const a = q(
|
|
505
|
+
t.filter,
|
|
506
|
+
t.defaultValue
|
|
507
|
+
);
|
|
508
|
+
a && (e.defaultInputValues ?? (e.defaultInputValues = {}), (n = e.defaultInputValues).shared ?? (n.shared = {}), e.defaultInputValues.shared[t.id] = {
|
|
390
509
|
status: "set",
|
|
391
510
|
value: {
|
|
392
511
|
kind: "filter",
|
|
393
|
-
filterValue: a
|
|
512
|
+
filterValue: a
|
|
394
513
|
}
|
|
395
514
|
});
|
|
396
515
|
}
|
|
397
|
-
function
|
|
516
|
+
function Ee(e) {
|
|
398
517
|
var l;
|
|
399
|
-
const
|
|
400
|
-
if (!
|
|
518
|
+
const t = ne(e.changePlan);
|
|
519
|
+
if (!t.ok)
|
|
401
520
|
throw new Error(
|
|
402
|
-
|
|
521
|
+
t.errors.map((s) => s.message).join(`
|
|
403
522
|
`) || "Dashboard change plan is invalid."
|
|
404
523
|
);
|
|
405
|
-
const
|
|
406
|
-
|
|
407
|
-
),
|
|
408
|
-
if (!
|
|
524
|
+
const a = Ie(e.dashboard), n = [...t.warnings], i = [], r = new Map(
|
|
525
|
+
e.cardArtifacts.map((s) => [s.planCardId, s])
|
|
526
|
+
), d = ye(a);
|
|
527
|
+
if (!d)
|
|
409
528
|
throw new Error("Dashboard has no editable dashboard sheet.");
|
|
410
|
-
|
|
411
|
-
for (const
|
|
412
|
-
switch (
|
|
529
|
+
d.frames ?? (d.frames = []);
|
|
530
|
+
for (const s of e.changePlan.operations)
|
|
531
|
+
switch (s.kind) {
|
|
413
532
|
case "addCard": {
|
|
414
|
-
if ((
|
|
415
|
-
(
|
|
416
|
-
var
|
|
417
|
-
return
|
|
533
|
+
if ((d.frames || []).reduce(
|
|
534
|
+
(g, o) => {
|
|
535
|
+
var b;
|
|
536
|
+
return g + (((b = o.cards) == null ? void 0 : b.length) || 0);
|
|
418
537
|
},
|
|
419
538
|
0
|
|
420
|
-
) >=
|
|
421
|
-
|
|
422
|
-
|
|
539
|
+
) >= $) {
|
|
540
|
+
i.push(
|
|
541
|
+
k(
|
|
423
542
|
"generated_card_limit_reached",
|
|
424
|
-
|
|
425
|
-
|
|
543
|
+
`MVP AI refinement is capped at ${$} cards.`,
|
|
544
|
+
s.card.id
|
|
426
545
|
)
|
|
427
546
|
);
|
|
428
547
|
break;
|
|
429
548
|
}
|
|
430
|
-
const
|
|
431
|
-
if (!
|
|
432
|
-
|
|
433
|
-
|
|
549
|
+
const m = r.get(s.card.id);
|
|
550
|
+
if (!m) {
|
|
551
|
+
i.push(
|
|
552
|
+
k(
|
|
434
553
|
"missing_card_artifact",
|
|
435
|
-
`Card "${
|
|
436
|
-
|
|
554
|
+
`Card "${s.card.title}" was skipped because no generated artifact was supplied.`,
|
|
555
|
+
s.card.id
|
|
437
556
|
)
|
|
438
557
|
);
|
|
439
558
|
break;
|
|
440
559
|
}
|
|
441
|
-
const
|
|
442
|
-
id:
|
|
443
|
-
cards: [
|
|
444
|
-
activeCardId:
|
|
560
|
+
const y = {
|
|
561
|
+
id: s.card.frameId,
|
|
562
|
+
cards: [m.card],
|
|
563
|
+
activeCardId: m.card.id
|
|
445
564
|
};
|
|
446
|
-
|
|
565
|
+
d.frames.push(y), ve(d, y);
|
|
447
566
|
break;
|
|
448
567
|
}
|
|
449
568
|
case "addFilterInput": {
|
|
450
|
-
|
|
451
|
-
const
|
|
452
|
-
id:
|
|
569
|
+
a.inputs ?? (a.inputs = []);
|
|
570
|
+
const c = {
|
|
571
|
+
id: s.input.id,
|
|
453
572
|
kind: "filter",
|
|
454
|
-
label:
|
|
455
|
-
variableName:
|
|
456
|
-
scope:
|
|
573
|
+
label: s.input.label,
|
|
574
|
+
variableName: s.input.variableName,
|
|
575
|
+
scope: s.input.scope || {
|
|
576
|
+
kind: "allSheets",
|
|
577
|
+
sheetKinds: ["dashboard"]
|
|
578
|
+
},
|
|
457
579
|
runtimeScope: "shared",
|
|
458
580
|
presentation: {
|
|
459
581
|
placement: "toolbar",
|
|
460
|
-
order:
|
|
582
|
+
order: a.inputs.length
|
|
461
583
|
},
|
|
462
584
|
exports: ["label", "value", "start", "end", "range"],
|
|
463
|
-
filter:
|
|
585
|
+
filter: s.input.filter
|
|
464
586
|
};
|
|
465
|
-
|
|
587
|
+
a.inputs.push(c), ke(a, s.input);
|
|
466
588
|
break;
|
|
467
589
|
}
|
|
468
590
|
case "addCalculatedField": {
|
|
469
|
-
if (
|
|
470
|
-
|
|
471
|
-
else if (
|
|
472
|
-
|
|
473
|
-
else if (
|
|
474
|
-
const
|
|
475
|
-
|
|
476
|
-
|
|
591
|
+
if (s.field.scope === "dashboard" && s.field.field)
|
|
592
|
+
a.calculatedFields ?? (a.calculatedFields = []), a.calculatedFields.push(s.field.field);
|
|
593
|
+
else if (s.field.scope === "sheet" && s.field.field)
|
|
594
|
+
d.calculatedFields ?? (d.calculatedFields = []), d.calculatedFields.push(s.field.field);
|
|
595
|
+
else if (s.field.scope === "card" && s.field.field) {
|
|
596
|
+
const c = s.field.targetCardId ? M(a, s.field.targetCardId) : null;
|
|
597
|
+
c ? ((l = c.card).calculatedFields ?? (l.calculatedFields = []), c.card.calculatedFields.push(s.field.field)) : i.push(
|
|
598
|
+
k(
|
|
477
599
|
"missing_calculated_field_target",
|
|
478
|
-
`Calculated field "${
|
|
600
|
+
`Calculated field "${s.field.name}" needs a valid target card.`
|
|
479
601
|
)
|
|
480
602
|
);
|
|
481
603
|
}
|
|
482
604
|
break;
|
|
483
605
|
}
|
|
484
606
|
case "renameCard": {
|
|
485
|
-
const
|
|
486
|
-
if (!
|
|
487
|
-
|
|
488
|
-
|
|
607
|
+
const c = M(a, s.cardId);
|
|
608
|
+
if (!c) {
|
|
609
|
+
i.push(
|
|
610
|
+
k(
|
|
489
611
|
"card_not_found",
|
|
490
|
-
`Card "${
|
|
491
|
-
|
|
612
|
+
`Card "${s.cardId}" could not be renamed because it was not found.`,
|
|
613
|
+
s.cardId
|
|
492
614
|
)
|
|
493
615
|
);
|
|
494
616
|
break;
|
|
495
617
|
}
|
|
496
|
-
|
|
618
|
+
c.card.title = s.title, s.description !== void 0 && (c.card.description = s.description);
|
|
497
619
|
break;
|
|
498
620
|
}
|
|
499
621
|
case "reorderCards": {
|
|
500
|
-
const
|
|
501
|
-
for (let
|
|
502
|
-
const
|
|
503
|
-
|
|
622
|
+
const c = /* @__PURE__ */ new Map();
|
|
623
|
+
for (let m = 0; m < s.cardIds.length; m += 1) {
|
|
624
|
+
const y = s.cardIds[m], g = M(a, y);
|
|
625
|
+
g && c.set(g.frame.id, m);
|
|
504
626
|
}
|
|
505
|
-
|
|
627
|
+
G(d, c);
|
|
506
628
|
break;
|
|
507
629
|
}
|
|
508
630
|
case "reuseCalculatedField":
|
|
509
|
-
|
|
510
|
-
|
|
631
|
+
n.push(
|
|
632
|
+
k(
|
|
511
633
|
"reused_calculated_field",
|
|
512
|
-
`Calculated field "${
|
|
634
|
+
`Calculated field "${s.fieldId}" is reused by reference.`
|
|
513
635
|
)
|
|
514
636
|
);
|
|
515
637
|
break;
|
|
516
638
|
case "unsupported":
|
|
517
|
-
|
|
518
|
-
|
|
639
|
+
i.push(
|
|
640
|
+
k("unsupported_operation", s.reason || s.requestedAction)
|
|
519
641
|
);
|
|
520
642
|
break;
|
|
521
643
|
}
|
|
522
|
-
return { dashboard:
|
|
644
|
+
return { dashboard: a, warnings: n, skippedOperations: i };
|
|
645
|
+
}
|
|
646
|
+
function I(e, t, a) {
|
|
647
|
+
return a ? { code: e, message: t, cardId: a } : { code: e, message: t };
|
|
648
|
+
}
|
|
649
|
+
function S(e, t) {
|
|
650
|
+
return e.trim().toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "") || t;
|
|
651
|
+
}
|
|
652
|
+
function K(e, t) {
|
|
653
|
+
if (!t.has(e))
|
|
654
|
+
return t.add(e), e;
|
|
655
|
+
let a = 2, n = `${e}-${a}`;
|
|
656
|
+
for (; t.has(n); )
|
|
657
|
+
a += 1, n = `${e}-${a}`;
|
|
658
|
+
return t.add(n), n;
|
|
659
|
+
}
|
|
660
|
+
function xe(e) {
|
|
661
|
+
return e.kind === "semantic" ? [
|
|
662
|
+
"semantic",
|
|
663
|
+
e.domainId,
|
|
664
|
+
e.datasetId || "",
|
|
665
|
+
e.datasetName,
|
|
666
|
+
e.connectionId || ""
|
|
667
|
+
].join(":") : e.kind === "physical" ? [
|
|
668
|
+
"physical",
|
|
669
|
+
e.connectionId,
|
|
670
|
+
e.databaseName || "",
|
|
671
|
+
e.schemaName || "",
|
|
672
|
+
e.tableName
|
|
673
|
+
].join(":") : ["sql", e.connectionId, e.sql].join(":");
|
|
674
|
+
}
|
|
675
|
+
function v(e) {
|
|
676
|
+
return !!(e && typeof e == "object");
|
|
677
|
+
}
|
|
678
|
+
function E(e) {
|
|
679
|
+
return v(e) && (e.kind === "semantic" || e.kind === "physical" || e.kind === "sql");
|
|
680
|
+
}
|
|
681
|
+
function U(e) {
|
|
682
|
+
return Array.isArray(e.inputs) ? e.inputs.filter(
|
|
683
|
+
(t) => v(t) && typeof t.id == "string"
|
|
684
|
+
) : [];
|
|
685
|
+
}
|
|
686
|
+
function J(e) {
|
|
687
|
+
return Array.isArray(e.sections) ? e.sections.filter(
|
|
688
|
+
(t) => v(t)
|
|
689
|
+
) : [];
|
|
690
|
+
}
|
|
691
|
+
function X(e) {
|
|
692
|
+
return Array.isArray(e.views) ? e.views.filter(
|
|
693
|
+
(t) => v(t)
|
|
694
|
+
) : [];
|
|
695
|
+
}
|
|
696
|
+
function Ce(e) {
|
|
697
|
+
return e.kind === "semantic" ? {
|
|
698
|
+
kind: "semantic",
|
|
699
|
+
domainId: e.domainId,
|
|
700
|
+
datasetName: e.datasetName,
|
|
701
|
+
datasetId: e.datasetId,
|
|
702
|
+
label: e.label,
|
|
703
|
+
connectionId: e.connectionId
|
|
704
|
+
} : e.kind === "physical" ? {
|
|
705
|
+
kind: "physical",
|
|
706
|
+
connectionId: e.connectionId,
|
|
707
|
+
databaseName: e.databaseName,
|
|
708
|
+
schemaName: e.schemaName,
|
|
709
|
+
tableName: e.tableName,
|
|
710
|
+
label: e.label
|
|
711
|
+
} : null;
|
|
712
|
+
}
|
|
713
|
+
function Fe(e) {
|
|
714
|
+
return (e == null ? void 0 : e.source) || null;
|
|
715
|
+
}
|
|
716
|
+
function Y(e) {
|
|
717
|
+
const t = [];
|
|
718
|
+
for (const a of U(e))
|
|
719
|
+
E(a.source) && t.push(a.source);
|
|
720
|
+
for (const a of J(e))
|
|
721
|
+
for (const n of X(a)) {
|
|
722
|
+
const i = Fe(n.analytics);
|
|
723
|
+
E(i) && t.push(i);
|
|
724
|
+
}
|
|
725
|
+
return t;
|
|
726
|
+
}
|
|
727
|
+
function Ae(e, t) {
|
|
728
|
+
const a = /* @__PURE__ */ new Map();
|
|
729
|
+
for (const i of Y(e))
|
|
730
|
+
a.set(xe(i), i);
|
|
731
|
+
const n = [...a.values()].map(Ce).filter((i) => !!i);
|
|
732
|
+
return n.length === 0 ? (t.push(
|
|
733
|
+
I(
|
|
734
|
+
"missing_materializable_dataset",
|
|
735
|
+
"No semantic or physical source could be converted into the current dashboard authoring dataset reference."
|
|
736
|
+
)
|
|
737
|
+
), []) : (n.length > 1 && t.push(
|
|
738
|
+
I(
|
|
739
|
+
"multiple_datasets_out_of_scope",
|
|
740
|
+
"The current dashboard authoring compiler supports one selected dataset; using the first source and deferring the rest."
|
|
741
|
+
)
|
|
742
|
+
), [n[0]]);
|
|
743
|
+
}
|
|
744
|
+
function Se(e) {
|
|
745
|
+
return (Array.isArray(e.fields) ? e.fields : []).map((t) => t.name).filter((t) => {
|
|
746
|
+
var a;
|
|
747
|
+
return t !== ((a = e.dateField) == null ? void 0 : a.name);
|
|
748
|
+
});
|
|
749
|
+
}
|
|
750
|
+
function Te(e) {
|
|
751
|
+
const t = Array.isArray(e.metrics) ? e.metrics.filter(
|
|
752
|
+
(a) => typeof a == "string" && a.trim().length > 0
|
|
753
|
+
) : [];
|
|
754
|
+
return Array.from(
|
|
755
|
+
new Set(
|
|
756
|
+
[e.metric, ...t].filter(
|
|
757
|
+
(a) => typeof a == "string" && a.trim().length > 0
|
|
758
|
+
)
|
|
759
|
+
)
|
|
760
|
+
);
|
|
761
|
+
}
|
|
762
|
+
function De(e) {
|
|
763
|
+
return v(e) && typeof e.name == "string" && e.name.trim().length > 0;
|
|
764
|
+
}
|
|
765
|
+
function $e(e) {
|
|
766
|
+
if (!Array.isArray(e.dimensions))
|
|
767
|
+
return;
|
|
768
|
+
const t = e.dimensions.filter(De).map((a) => a.name);
|
|
769
|
+
return t.length ? t : void 0;
|
|
770
|
+
}
|
|
771
|
+
function H(e) {
|
|
772
|
+
return e === "hour" ? "day" : e;
|
|
773
|
+
}
|
|
774
|
+
function Ne(e) {
|
|
775
|
+
var t, a;
|
|
776
|
+
if (e) {
|
|
777
|
+
if (e.kind === "metric")
|
|
778
|
+
return {
|
|
779
|
+
metric: e.metric,
|
|
780
|
+
metrics: Te(e),
|
|
781
|
+
dateField: (t = e.dateField) == null ? void 0 : t.name,
|
|
782
|
+
timeGrain: H(e.timeGrain),
|
|
783
|
+
dimensions: $e(e),
|
|
784
|
+
limit: e.limit
|
|
785
|
+
};
|
|
786
|
+
if (e.kind === "records")
|
|
787
|
+
return {
|
|
788
|
+
metrics: e.measures,
|
|
789
|
+
dateField: (a = e.dateField) == null ? void 0 : a.name,
|
|
790
|
+
timeGrain: H(e.timeGrain),
|
|
791
|
+
dimensions: Se(e),
|
|
792
|
+
limit: e.limit
|
|
793
|
+
};
|
|
794
|
+
}
|
|
795
|
+
}
|
|
796
|
+
function Me(e) {
|
|
797
|
+
return e && ee(e).ok ? e : void 0;
|
|
798
|
+
}
|
|
799
|
+
function Ve(e) {
|
|
800
|
+
var t;
|
|
801
|
+
switch ((t = e.presentation) == null ? void 0 : t.kind) {
|
|
802
|
+
case "kpi":
|
|
803
|
+
return "kpi";
|
|
804
|
+
case "lineChart":
|
|
805
|
+
return "line";
|
|
806
|
+
case "barChart":
|
|
807
|
+
return "bar";
|
|
808
|
+
case "areaChart":
|
|
809
|
+
return "area";
|
|
810
|
+
case "table":
|
|
811
|
+
return "table";
|
|
812
|
+
case "text":
|
|
813
|
+
return "text";
|
|
814
|
+
default:
|
|
815
|
+
return null;
|
|
816
|
+
}
|
|
817
|
+
}
|
|
818
|
+
function Pe(e) {
|
|
819
|
+
var t, a, n;
|
|
820
|
+
return ((t = e.presentation) == null ? void 0 : t.kind) === "kpi" ? "kpi" : ((a = e.presentation) == null ? void 0 : a.kind) === "table" ? "table" : ((n = e.presentation) == null ? void 0 : n.kind) === "text" ? "text" : "chart";
|
|
821
|
+
}
|
|
822
|
+
function qe(e) {
|
|
823
|
+
switch (e) {
|
|
824
|
+
case "not_in":
|
|
825
|
+
return "not in";
|
|
826
|
+
case "contains":
|
|
827
|
+
return "like";
|
|
828
|
+
default:
|
|
829
|
+
return e || "in";
|
|
830
|
+
}
|
|
831
|
+
}
|
|
832
|
+
function Be(e) {
|
|
833
|
+
return v(e.field) ? e.field.dataType === "datetime" ? "date" : e.field.dataType || "string" : "string";
|
|
834
|
+
}
|
|
835
|
+
function Le(e) {
|
|
836
|
+
if (!(!e || e.kind !== "physical"))
|
|
837
|
+
return [e.databaseName, e.schemaName, e.tableName].filter(Boolean).join(".");
|
|
838
|
+
}
|
|
839
|
+
function ze(e, t, a, n, i) {
|
|
840
|
+
if (e.kind !== "filter")
|
|
841
|
+
return i.push(
|
|
842
|
+
I(
|
|
843
|
+
"control_inputs_deferred",
|
|
844
|
+
`Control input "${e.label}" is represented in the protocol but not yet materialized by the dashboard authoring adapter.`
|
|
845
|
+
)
|
|
846
|
+
), null;
|
|
847
|
+
if (!v(e.field) || typeof e.field.name != "string")
|
|
848
|
+
return i.push(
|
|
849
|
+
I(
|
|
850
|
+
"filter_requires_field",
|
|
851
|
+
`Filter "${e.label || e.id}" needs a field before the dashboard compiler can materialize it.`
|
|
852
|
+
)
|
|
853
|
+
), null;
|
|
854
|
+
const r = e.source || t, d = (r == null ? void 0 : r.kind) === "semantic" || (r == null ? void 0 : r.kind) === "physical" || (r == null ? void 0 : r.kind) === "sql" ? r.connectionId : void 0;
|
|
855
|
+
if (!d)
|
|
856
|
+
return i.push(
|
|
857
|
+
I(
|
|
858
|
+
"filter_requires_connection_id",
|
|
859
|
+
`Filter "${e.label}" needs a source connectionId before the dashboard compiler can materialize it.`
|
|
860
|
+
)
|
|
861
|
+
), null;
|
|
862
|
+
const c = {
|
|
863
|
+
id: `filter-${K(
|
|
864
|
+
S(e.id, e.field.name),
|
|
865
|
+
n
|
|
866
|
+
)}`,
|
|
867
|
+
variableName: e.id,
|
|
868
|
+
connectionId: d,
|
|
869
|
+
title: e.label,
|
|
870
|
+
column: e.field.name,
|
|
871
|
+
dataType: Be(e),
|
|
872
|
+
qualifiedTableName: Le(r),
|
|
873
|
+
sql: "",
|
|
874
|
+
operation: qe(e.operator),
|
|
875
|
+
type: e.multi === !1 ? "single" : "multiple",
|
|
876
|
+
location: "dashboard",
|
|
877
|
+
displayMode: "toolbar",
|
|
878
|
+
fieldMeta: (r == null ? void 0 : r.kind) === "semantic" ? {
|
|
879
|
+
name: e.field.name,
|
|
880
|
+
qualifiedFieldName: e.field.name,
|
|
881
|
+
dataType: e.field.dataType,
|
|
882
|
+
role: e.field.role === "measure" ? "metric" : "groupby"
|
|
883
|
+
} : void 0,
|
|
884
|
+
semanticContext: (r == null ? void 0 : r.kind) === "semantic" ? {
|
|
885
|
+
semanticDomainId: r.domainId,
|
|
886
|
+
connectionId: r.connectionId
|
|
887
|
+
} : void 0
|
|
888
|
+
};
|
|
889
|
+
return {
|
|
890
|
+
id: e.id,
|
|
891
|
+
label: e.label,
|
|
892
|
+
variableName: e.id,
|
|
893
|
+
scope: a,
|
|
894
|
+
filter: c,
|
|
895
|
+
defaultValue: q(
|
|
896
|
+
c,
|
|
897
|
+
e.defaultValue
|
|
898
|
+
)
|
|
899
|
+
};
|
|
900
|
+
}
|
|
901
|
+
function V(e) {
|
|
902
|
+
const t = [], a = [];
|
|
903
|
+
for (const n of e.viewIds) {
|
|
904
|
+
const i = e.viewIdToCardId.get(n);
|
|
905
|
+
i ? t.push(i) : a.push(n);
|
|
906
|
+
}
|
|
907
|
+
return a.length > 0 && e.warnings.push(
|
|
908
|
+
I(
|
|
909
|
+
"input_scope_view_not_found",
|
|
910
|
+
`Filter "${e.inputLabel}" referenced unknown view ids: ${a.join(", ")}.`
|
|
911
|
+
)
|
|
912
|
+
), Array.from(new Set(t));
|
|
913
|
+
}
|
|
914
|
+
function Re(e) {
|
|
915
|
+
var n, i;
|
|
916
|
+
if (!e.protocolScope) {
|
|
917
|
+
const r = Array.from(new Set(e.boundCardIds));
|
|
918
|
+
return r.length > 0 && r.length < e.allCardIds.length ? { kind: "cards", cardIds: r } : void 0;
|
|
919
|
+
}
|
|
920
|
+
if (e.protocolScope.level === "dashboard") {
|
|
921
|
+
if (!((n = e.protocolScope.excludeViewIds) != null && n.length))
|
|
922
|
+
return;
|
|
923
|
+
const r = new Set(
|
|
924
|
+
V({
|
|
925
|
+
inputLabel: e.inputLabel,
|
|
926
|
+
viewIds: e.protocolScope.excludeViewIds,
|
|
927
|
+
viewIdToCardId: e.viewIdToCardId,
|
|
928
|
+
warnings: e.warnings
|
|
929
|
+
})
|
|
930
|
+
);
|
|
931
|
+
return {
|
|
932
|
+
kind: "cards",
|
|
933
|
+
cardIds: e.allCardIds.filter((d) => !r.has(d))
|
|
934
|
+
};
|
|
935
|
+
}
|
|
936
|
+
if (e.protocolScope.level === "view") {
|
|
937
|
+
const r = V({
|
|
938
|
+
inputLabel: e.inputLabel,
|
|
939
|
+
viewIds: e.protocolScope.viewIds,
|
|
940
|
+
viewIdToCardId: e.viewIdToCardId,
|
|
941
|
+
warnings: e.warnings
|
|
942
|
+
});
|
|
943
|
+
return r.length === 0 ? (e.warnings.push(
|
|
944
|
+
I(
|
|
945
|
+
"input_scope_has_no_materialized_cards",
|
|
946
|
+
`Filter "${e.inputLabel}" was deferred because its view scope does not match any materialized cards.`
|
|
947
|
+
)
|
|
948
|
+
), null) : { kind: "cards", cardIds: r };
|
|
949
|
+
}
|
|
950
|
+
const t = e.sectionIdToCardIds.get(e.protocolScope.sectionId) || [];
|
|
951
|
+
if (t.length === 0)
|
|
952
|
+
return e.warnings.push(
|
|
953
|
+
I(
|
|
954
|
+
"input_scope_section_not_found",
|
|
955
|
+
`Filter "${e.inputLabel}" was deferred because section "${e.protocolScope.sectionId}" does not match any materialized cards.`
|
|
956
|
+
)
|
|
957
|
+
), null;
|
|
958
|
+
if (!((i = e.protocolScope.excludeViewIds) != null && i.length))
|
|
959
|
+
return { kind: "cards", cardIds: t };
|
|
960
|
+
const a = new Set(
|
|
961
|
+
V({
|
|
962
|
+
inputLabel: e.inputLabel,
|
|
963
|
+
viewIds: e.protocolScope.excludeViewIds,
|
|
964
|
+
viewIdToCardId: e.viewIdToCardId,
|
|
965
|
+
warnings: e.warnings
|
|
966
|
+
})
|
|
967
|
+
);
|
|
968
|
+
return {
|
|
969
|
+
kind: "cards",
|
|
970
|
+
cardIds: t.filter((r) => !a.has(r))
|
|
971
|
+
};
|
|
972
|
+
}
|
|
973
|
+
function He(e) {
|
|
974
|
+
var w, C, u;
|
|
975
|
+
const t = [], a = Z(e);
|
|
976
|
+
for (const p of a.warnings)
|
|
977
|
+
t.push(I(p.code, p.message));
|
|
978
|
+
for (const p of a.errors)
|
|
979
|
+
t.push(I(p.code, p.message));
|
|
980
|
+
const n = J(e), i = U(e), r = Ae(e, t), d = Y(e)[0], l = [], s = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Map(), m = /* @__PURE__ */ new Map(), y = /* @__PURE__ */ new Set(), g = /* @__PURE__ */ new Set();
|
|
981
|
+
let o = 0;
|
|
982
|
+
for (const [p, _] of n.entries()) {
|
|
983
|
+
const F = typeof _.title == "string" ? _.title : `Section ${p + 1}`, B = _.id || S(F, `section-${p + 1}`);
|
|
984
|
+
c.set(B, []);
|
|
985
|
+
for (const [L, h] of X(_).entries()) {
|
|
986
|
+
const z = Ve(h), N = S(
|
|
987
|
+
h.id || `${F}-${h.title || `View ${L + 1}`}`,
|
|
988
|
+
`card-${p + 1}-${L + 1}`
|
|
989
|
+
);
|
|
990
|
+
if (!z) {
|
|
991
|
+
t.push(
|
|
992
|
+
I(
|
|
993
|
+
"unsupported_presentation",
|
|
994
|
+
`Dashboard presentation "${((w = h.presentation) == null ? void 0 : w.kind) || "unknown"}" is not supported by the dashboard authoring adapter.`,
|
|
995
|
+
`card-${N}`
|
|
996
|
+
)
|
|
997
|
+
);
|
|
998
|
+
continue;
|
|
999
|
+
}
|
|
1000
|
+
if (((C = h.analytics) == null ? void 0 : C.kind) === "sql") {
|
|
1001
|
+
t.push(
|
|
1002
|
+
I(
|
|
1003
|
+
"sql_intent_deferred",
|
|
1004
|
+
"SQL analytics intent is valid protocol, but the current dashboard authoring adapter only materializes semantic and physical config-card intents.",
|
|
1005
|
+
`card-${N}`
|
|
1006
|
+
)
|
|
1007
|
+
);
|
|
1008
|
+
continue;
|
|
1009
|
+
}
|
|
1010
|
+
const R = K(N, y), T = `card-${R}`;
|
|
1011
|
+
h.id && s.set(h.id, T), (u = c.get(B)) == null || u.push(T);
|
|
1012
|
+
const Q = h.analytics && "inputs" in h.analytics ? h.analytics.inputs : void 0;
|
|
1013
|
+
for (const j of Q || []) {
|
|
1014
|
+
const O = m.get(j.inputId) || [];
|
|
1015
|
+
O.push(T), m.set(j.inputId, O);
|
|
1016
|
+
}
|
|
1017
|
+
l.push({
|
|
1018
|
+
id: T,
|
|
1019
|
+
frameId: `frame-${R}`,
|
|
1020
|
+
title: h.title,
|
|
1021
|
+
description: h.description,
|
|
1022
|
+
type: z,
|
|
1023
|
+
role: Pe(h),
|
|
1024
|
+
priority: o,
|
|
1025
|
+
section: F,
|
|
1026
|
+
query: Ne(h.analytics),
|
|
1027
|
+
analyticsIntent: Me(h.analytics),
|
|
1028
|
+
text: h.text
|
|
1029
|
+
}), o += 1;
|
|
1030
|
+
}
|
|
1031
|
+
}
|
|
1032
|
+
const b = i.map((p) => {
|
|
1033
|
+
const _ = Re({
|
|
1034
|
+
protocolScope: p.scope,
|
|
1035
|
+
inputLabel: p.label,
|
|
1036
|
+
allCardIds: l.map((F) => F.id),
|
|
1037
|
+
boundCardIds: m.get(p.id) || [],
|
|
1038
|
+
viewIdToCardId: s,
|
|
1039
|
+
sectionIdToCardIds: c,
|
|
1040
|
+
warnings: t
|
|
1041
|
+
});
|
|
1042
|
+
return _ === null ? null : ze(
|
|
1043
|
+
p,
|
|
1044
|
+
d,
|
|
1045
|
+
_,
|
|
1046
|
+
g,
|
|
1047
|
+
t
|
|
1048
|
+
);
|
|
1049
|
+
}).filter((p) => !!p);
|
|
1050
|
+
return { plan: {
|
|
1051
|
+
version: 1,
|
|
1052
|
+
id: `plan-${S(e.title, "dashboard")}`,
|
|
1053
|
+
title: e.title,
|
|
1054
|
+
description: e.description,
|
|
1055
|
+
datasets: r,
|
|
1056
|
+
sheets: [
|
|
1057
|
+
{
|
|
1058
|
+
id: `sheet-${S(e.title, "dashboard")}`,
|
|
1059
|
+
title: e.title,
|
|
1060
|
+
description: e.description,
|
|
1061
|
+
kind: "dashboard",
|
|
1062
|
+
cards: l
|
|
1063
|
+
}
|
|
1064
|
+
],
|
|
1065
|
+
filterInputs: b.length ? b : void 0,
|
|
1066
|
+
warnings: t.length ? t : void 0,
|
|
1067
|
+
unresolvedRequests: a.ok ? void 0 : a.errors.map((p) => p.message)
|
|
1068
|
+
}, warnings: t };
|
|
523
1069
|
}
|
|
524
1070
|
export {
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
1071
|
+
te as DASHBOARD_AUTHORING_BREAKPOINTS,
|
|
1072
|
+
$ as DASHBOARD_AUTHORING_MAX_GENERATED_CARDS,
|
|
1073
|
+
Ee as applyDashboardChangePlan,
|
|
1074
|
+
Oe as compileDashboardFromPlan,
|
|
1075
|
+
P as compileResponsiveDashboardLayouts,
|
|
1076
|
+
He as dashboardPlanFromSemaphorDashboardIntent,
|
|
1077
|
+
ne as validateDashboardChangePlan,
|
|
1078
|
+
ae as validateDashboardPlan
|
|
532
1079
|
};
|