react-semaphor 0.1.376 → 0.1.378
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 -1
- package/dist/analytics-protocol/index.js +47 -43
- package/dist/brand-studio/index.cjs +4 -4
- package/dist/brand-studio/index.js +10 -8
- package/dist/chunks/braces-BT-ZyB-g.js +6 -0
- package/dist/chunks/braces-DOxxfERN.js +23 -0
- package/dist/chunks/calendar-preferences-dialog-CRvQz4TE.js +1 -0
- package/dist/chunks/{calendar-preferences-dialog-B6fsethx.js → calendar-preferences-dialog-DZe8Nd-4.js} +14 -14
- package/dist/chunks/catalog-field-grounding-8L9I0zdg.js +1 -0
- package/dist/chunks/catalog-field-grounding-BK4BX8sZ.js +200 -0
- package/dist/chunks/dashboard-briefing-launcher-BWyHpn2M.js +111 -0
- package/dist/chunks/{dashboard-briefing-launcher-BKCRO7Qw.js → dashboard-briefing-launcher-DURdx5Ox.js} +3147 -2386
- package/dist/chunks/dashboard-controls-D5mjF67R.js +2279 -0
- package/dist/chunks/dashboard-controls-J71GLAxt.js +52 -0
- package/dist/chunks/{dashboard-json-QT0T2ad_.js → dashboard-json-BumvCRuk.js} +14 -13
- package/dist/chunks/dashboard-json-Cv8jXh0X.js +1 -0
- package/dist/chunks/{edit-dashboard-visual-DNzPgXMh.js → edit-dashboard-visual-dvhQzG_h.js} +33 -33
- package/dist/chunks/{edit-dashboard-visual-kNoMQRmH.js → edit-dashboard-visual-eYJMy7aw.js} +677 -677
- package/dist/chunks/{index-CPpqPJba.js → index-c_0nwsOM.js} +199 -194
- package/dist/chunks/{index-DX_0OcRv.js → index-hhH5F_tQ.js} +20665 -20527
- package/dist/chunks/layout-grid-DTbOIOsE.js +16 -0
- package/dist/chunks/layout-grid-DccceHv4.js +6 -0
- package/dist/chunks/{palette-2HWSR5wb.js → palette-DCzLwqIw.js} +1 -1
- package/dist/chunks/{palette-BcHHAmOU.js → palette-SimHJELn.js} +1 -1
- package/dist/chunks/{save-MoF1T13_.js → save-D2O96E5A.js} +1 -1
- package/dist/chunks/{save-B-YfAPhu.js → save-zNVYH02T.js} +1 -1
- package/dist/chunks/{switch-DmE_MY3L.js → switch-DMPsMpHW.js} +1 -1
- package/dist/chunks/{switch-CmHP5dT7.js → switch-Jhyl63RF.js} +1 -1
- package/dist/chunks/{use-create-flow-overlay-state-BLPQgGuz.js → use-create-flow-overlay-state-D9UKBuCA.js} +2 -2
- package/dist/chunks/{use-create-flow-overlay-state-D_Ntx-_C.js → use-create-flow-overlay-state-hlsTNh2b.js} +113 -112
- package/dist/chunks/{validation-DlrTIf1N.js → validation-BM3-ShHV.js} +1 -1
- package/dist/chunks/{validation-1V7bWmYw.js → validation-BVpqRFar.js} +1 -1
- package/dist/dashboard/index.cjs +1 -1
- package/dist/dashboard/index.js +1 -1
- package/dist/dashboard-authoring/index.cjs +1 -1
- package/dist/dashboard-authoring/index.js +1 -1
- package/dist/data-app-builder/index.cjs +1 -1
- package/dist/data-app-builder/index.js +3 -3
- package/dist/data-app-sdk/index.cjs +1 -1
- package/dist/data-app-sdk/index.js +22 -21
- package/dist/data-app-sdk-validation/index.cjs +1 -1
- package/dist/data-app-sdk-validation/index.js +2 -2
- package/dist/index.cjs +1 -1
- package/dist/index.js +128 -126
- package/dist/style.css +1 -1
- package/dist/surfboard/index.cjs +1 -1
- package/dist/surfboard/index.js +2 -2
- package/dist/types/analytics-protocol.d.ts +128 -0
- package/dist/types/dashboard-assistant.d.ts +42 -0
- package/dist/types/data-app-sdk-validation.d.ts +42 -0
- package/dist/types/data-app-sdk.d.ts +42 -0
- package/dist/types/main.d.ts +7 -0
- package/package.json +1 -1
- package/dist/chunks/calendar-preferences-dialog-Dh1b0ytN.js +0 -1
- package/dist/chunks/catalog-field-grounding-DoEBOXQd.js +0 -100
- package/dist/chunks/catalog-field-grounding-Du6mKDcF.js +0 -1
- package/dist/chunks/chevrons-up-down-D2fZD4N_.js +0 -6
- package/dist/chunks/chevrons-up-down-lahj6tQy.js +0 -14
- package/dist/chunks/dashboard-briefing-launcher-Gv1cwT0I.js +0 -111
- package/dist/chunks/dashboard-controls-BDJZarV7.js +0 -52
- package/dist/chunks/dashboard-controls-CchLBVDv.js +0 -3037
- package/dist/chunks/dashboard-json-ZhIEMXN0.js +0 -1
- package/dist/chunks/layout-grid-BOTLt36V.js +0 -36
- package/dist/chunks/layout-grid-CS6BSCJF.js +0 -11
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { c as ge,
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { c as ge, H as ie, E as Le, u as Z, G as M, a7 as bt, W as yt, Y as vt, Z as xt, a as fe, $ as Ct, a8 as kt, B as q, e as St, X as et, f as tt, a9 as Nt, aa as wt, ab as pe, ac as je, ad as Qe, ae as Se, af as Ne, ag as Dt, ah as $e, ai as Et, aj as It, ak as me, al as Ft, am as Pe, g as He, an as at, ao as rt, ap as st, L as oe, a0 as nt, a1 as we, a2 as De, a3 as Ee, a4 as Ie, a5 as Fe, aq as ot, ar as Vt, as as Tt, at as We, au as _t, av as Ke, aw as Lt, ax as Ve } from "./switch-DMPsMpHW.js";
|
|
2
|
+
import { useState as K, useEffect as de, useCallback as R, useMemo as P, useRef as Te, Fragment as At } from "react";
|
|
3
|
+
import { aD as qt, u as Mt, aE as ce, aF as Ot, aG as Ae, aH as zt, aI as Ut, aJ as Rt, p as B, aK as Bt, aL as jt, aM as lt, aN as Qt, aO as $t, aP as Pt, aQ as Ht, aR as Wt, y as Kt, aS as Yt, aT as it, aU as dt, aV as Gt, aW as Jt, aX as Xt, ay as Ye, aY as Zt, aZ as ea, a_ as ct, a$ as ut, b0 as ta, b1 as aa, b2 as ra, b3 as sa, b4 as na, ar as oa, b5 as la, b6 as ia } from "./index-hhH5F_tQ.js";
|
|
4
4
|
import { jsx as a, jsxs as m, Fragment as re } from "react/jsx-runtime";
|
|
5
5
|
import "./index-CuHybtft.js";
|
|
6
|
-
import
|
|
6
|
+
import "./catalog-field-grounding-BK4BX8sZ.js";
|
|
7
|
+
import { S as pt } from "./save-zNVYH02T.js";
|
|
7
8
|
/**
|
|
8
9
|
* @license lucide-react v0.453.0 - ISC
|
|
9
10
|
*
|
|
@@ -33,7 +34,7 @@ const ca = ge("Link2", [
|
|
|
33
34
|
* This source code is licensed under the ISC license.
|
|
34
35
|
* See the LICENSE file in the root directory of this source tree.
|
|
35
36
|
*/
|
|
36
|
-
const
|
|
37
|
+
const Fa = ge("Rows3", [
|
|
37
38
|
["rect", { width: "18", height: "18", x: "3", y: "3", rx: "2", key: "afitv7" }],
|
|
38
39
|
["path", { d: "M21 9H3", key: "1338ky" }],
|
|
39
40
|
["path", { d: "M21 15H3", key: "9uk58r" }]
|
|
@@ -44,7 +45,7 @@ const Ia = ge("Rows3", [
|
|
|
44
45
|
* This source code is licensed under the ISC license.
|
|
45
46
|
* See the LICENSE file in the root directory of this source tree.
|
|
46
47
|
*/
|
|
47
|
-
const
|
|
48
|
+
const Va = ge("SendHorizontal", [
|
|
48
49
|
[
|
|
49
50
|
"path",
|
|
50
51
|
{
|
|
@@ -54,78 +55,8 @@ const Fa = ge("SendHorizontal", [
|
|
|
54
55
|
],
|
|
55
56
|
["path", { d: "M6 12h16", key: "s4cdu5" }]
|
|
56
57
|
]);
|
|
57
|
-
function
|
|
58
|
-
const
|
|
59
|
-
setSelectedConnectionId: r,
|
|
60
|
-
setSelectedDatabaseName: n,
|
|
61
|
-
setSelectedSchemaName: s,
|
|
62
|
-
setSelectedTableName: l,
|
|
63
|
-
setSelectedDatamodelId: d
|
|
64
|
-
} = ie();
|
|
65
|
-
de(() => {
|
|
66
|
-
var w;
|
|
67
|
-
if (!t) return;
|
|
68
|
-
const { tableName: p, schemaName: f, databaseName: u, connectionId: v } = qt(t), b = (w = t.selectedEntities) == null ? void 0 : w[0], x = (b == null ? void 0 : b.type) === "model" && "id" in b ? b.id : "";
|
|
69
|
-
r(v || ""), n(u || ""), s(f || ""), l(p || ""), d(x);
|
|
70
|
-
}, [
|
|
71
|
-
t,
|
|
72
|
-
r,
|
|
73
|
-
n,
|
|
74
|
-
s,
|
|
75
|
-
l,
|
|
76
|
-
d
|
|
77
|
-
]);
|
|
78
|
-
}
|
|
79
|
-
const _e = /* @__PURE__ */ new Set();
|
|
80
|
-
function Ta(t) {
|
|
81
|
-
return _e.add(t), () => {
|
|
82
|
-
_e.delete(t);
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
function ua() {
|
|
86
|
-
_e.forEach((t) => {
|
|
87
|
-
t();
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
function mt() {
|
|
91
|
-
var u, v;
|
|
92
|
-
const t = M((b) => b.card), r = M((b) => b.frame), n = P(
|
|
93
|
-
() => lt(r, t),
|
|
94
|
-
[r, t]
|
|
95
|
-
), { manifest: s } = Mt(
|
|
96
|
-
((u = n == null ? void 0 : n.customCardPreferences) == null ? void 0 : u.url) || ""
|
|
97
|
-
), l = P(
|
|
98
|
-
() => {
|
|
99
|
-
var b;
|
|
100
|
-
return (b = s == null ? void 0 : s.visuals) == null ? void 0 : b.find(
|
|
101
|
-
(h) => {
|
|
102
|
-
var x;
|
|
103
|
-
return h.name === ((x = n == null ? void 0 : n.customCardPreferences) == null ? void 0 : x.componentName);
|
|
104
|
-
}
|
|
105
|
-
);
|
|
106
|
-
},
|
|
107
|
-
[s, (v = n == null ? void 0 : n.customCardPreferences) == null ? void 0 : v.componentName]
|
|
108
|
-
), d = Ot(n, l), p = P(
|
|
109
|
-
() => zt({
|
|
110
|
-
frame: r,
|
|
111
|
-
configCard: n,
|
|
112
|
-
isMultiInputVisual: d === "multiple"
|
|
113
|
-
}),
|
|
114
|
-
[r, n, d]
|
|
115
|
-
), f = P(() => {
|
|
116
|
-
const b = p.findIndex(
|
|
117
|
-
(h) => (h == null ? void 0 : h.id) === t.id
|
|
118
|
-
);
|
|
119
|
-
return b < 0 ? -1 : Ut(t, b);
|
|
120
|
-
}, [p, t]);
|
|
121
|
-
return P(() => !n || d !== "multiple" || f < 0 ? t.type : Rt(
|
|
122
|
-
t,
|
|
123
|
-
f,
|
|
124
|
-
l == null ? void 0 : l.slots
|
|
125
|
-
) ?? t.type, [n, d, f, t, l == null ? void 0 : l.slots]);
|
|
126
|
-
}
|
|
127
|
-
function pa(t) {
|
|
128
|
-
const [r, n] = K(null), [s, l] = K(null), d = Bt();
|
|
58
|
+
function ua(t) {
|
|
59
|
+
const [r, n] = K(null), [s, l] = K(null), d = qt();
|
|
129
60
|
return de(() => {
|
|
130
61
|
if (!t || t.trim() === "") {
|
|
131
62
|
n(null), l(null);
|
|
@@ -163,7 +94,7 @@ function pa(t) {
|
|
|
163
94
|
})();
|
|
164
95
|
}, [t, d]), r;
|
|
165
96
|
}
|
|
166
|
-
function
|
|
97
|
+
function pa(t, r) {
|
|
167
98
|
if (t.length === 0)
|
|
168
99
|
return "";
|
|
169
100
|
const n = t.find(
|
|
@@ -191,6 +122,17 @@ function ma(t, r) {
|
|
|
191
122
|
}
|
|
192
123
|
return t[0].id;
|
|
193
124
|
}
|
|
125
|
+
const _e = /* @__PURE__ */ new Set();
|
|
126
|
+
function Ta(t) {
|
|
127
|
+
return _e.add(t), () => {
|
|
128
|
+
_e.delete(t);
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
function ma() {
|
|
132
|
+
_e.forEach((t) => {
|
|
133
|
+
t();
|
|
134
|
+
});
|
|
135
|
+
}
|
|
194
136
|
const fa = (t) => {
|
|
195
137
|
if (!t || !("detailTableBackup" in t))
|
|
196
138
|
return t;
|
|
@@ -224,7 +166,7 @@ async function Ge(t, r, n, s, l = "Opening library visual...") {
|
|
|
224
166
|
throw B.dismiss(f), u;
|
|
225
167
|
}
|
|
226
168
|
}
|
|
227
|
-
function
|
|
169
|
+
function mt(t) {
|
|
228
170
|
if (typeof t == "string")
|
|
229
171
|
return JSON.parse(t);
|
|
230
172
|
if (typeof t == "object")
|
|
@@ -236,13 +178,13 @@ function ha(t, r) {
|
|
|
236
178
|
const n = (t == null ? void 0 : t.frameObject) ?? ((d = t == null ? void 0 : t.visual) == null ? void 0 : d.frameObject);
|
|
237
179
|
if (!n)
|
|
238
180
|
return !1;
|
|
239
|
-
const s =
|
|
181
|
+
const s = mt(n);
|
|
240
182
|
if (!(s != null && s.cards) || s.cards.length === 0)
|
|
241
183
|
return !1;
|
|
242
184
|
const l = (p = s.cards) == null ? void 0 : p.find(
|
|
243
185
|
(f) => f.id === s.activeCardId
|
|
244
186
|
);
|
|
245
|
-
return l ? (
|
|
187
|
+
return l ? (Bt({
|
|
246
188
|
...r,
|
|
247
189
|
frame: s,
|
|
248
190
|
card: l,
|
|
@@ -255,10 +197,10 @@ function ga() {
|
|
|
255
197
|
var l;
|
|
256
198
|
return ((l = s.card.customCardPreferences) == null ? void 0 : l.url) || "";
|
|
257
199
|
}
|
|
258
|
-
), r =
|
|
200
|
+
), r = ua(t);
|
|
259
201
|
return { getUpdatedFrame: R(() => {
|
|
260
202
|
var F;
|
|
261
|
-
|
|
203
|
+
ma();
|
|
262
204
|
const {
|
|
263
205
|
frame: s,
|
|
264
206
|
card: l,
|
|
@@ -286,12 +228,12 @@ function ga() {
|
|
|
286
228
|
return {
|
|
287
229
|
...s,
|
|
288
230
|
cards: N,
|
|
289
|
-
activeCardId:
|
|
231
|
+
activeCardId: pa(N, s.activeCardId)
|
|
290
232
|
};
|
|
291
233
|
}, [r]) };
|
|
292
234
|
}
|
|
293
235
|
function qe() {
|
|
294
|
-
const { authToken: t, tokenProps: r } =
|
|
236
|
+
const { authToken: t, tokenProps: r } = Mt(), n = ce(), s = Ot(), l = Ae(), { selectVisual: d } = zt(), {
|
|
295
237
|
setFrame: p,
|
|
296
238
|
setCard: f,
|
|
297
239
|
setIsDevMode: u,
|
|
@@ -315,7 +257,7 @@ function qe() {
|
|
|
315
257
|
clearSelectedFrameId: V
|
|
316
258
|
} = Le(), z = Z((_) => _.selectedSheetId), H = Z((_) => _.selectedFrameId), X = Z((_) => _.dashboard), te = Z((_) => _.filterValues), L = Z(
|
|
317
259
|
(_) => _.inlineFilterValuesMap
|
|
318
|
-
), Q =
|
|
260
|
+
), Q = Ut((l == null ? void 0 : l.id) || "", {
|
|
319
261
|
enabled: !!(l != null && l.id) && !!(t != null && t.accessToken)
|
|
320
262
|
}), Y = R(
|
|
321
263
|
async (_) => {
|
|
@@ -404,11 +346,11 @@ function qe() {
|
|
|
404
346
|
), ue = (A == null ? void 0 : A.frameObject) ?? ((W = A == null ? void 0 : A.visual) == null ? void 0 : W.frameObject);
|
|
405
347
|
if (!ue)
|
|
406
348
|
return E("Visual has no frame data");
|
|
407
|
-
const $ =
|
|
349
|
+
const $ = mt(ue);
|
|
408
350
|
if (!($ != null && $.cards) || $.cards.length === 0)
|
|
409
351
|
return E("Visual frame is malformed");
|
|
410
352
|
const le = {
|
|
411
|
-
...
|
|
353
|
+
...Rt($),
|
|
412
354
|
visualId: _.id
|
|
413
355
|
// Link this frame to the library visual
|
|
414
356
|
};
|
|
@@ -445,7 +387,66 @@ function qe() {
|
|
|
445
387
|
refetch: Q.refetch
|
|
446
388
|
};
|
|
447
389
|
}
|
|
448
|
-
function _a({
|
|
390
|
+
function _a() {
|
|
391
|
+
const t = M((p) => p.card.dataSource), {
|
|
392
|
+
setSelectedConnectionId: r,
|
|
393
|
+
setSelectedDatabaseName: n,
|
|
394
|
+
setSelectedSchemaName: s,
|
|
395
|
+
setSelectedTableName: l,
|
|
396
|
+
setSelectedDatamodelId: d
|
|
397
|
+
} = ie();
|
|
398
|
+
de(() => {
|
|
399
|
+
var w;
|
|
400
|
+
if (!t) return;
|
|
401
|
+
const { tableName: p, schemaName: f, databaseName: u, connectionId: v } = jt(t), b = (w = t.selectedEntities) == null ? void 0 : w[0], x = (b == null ? void 0 : b.type) === "model" && "id" in b ? b.id : "";
|
|
402
|
+
r(v || ""), n(u || ""), s(f || ""), l(p || ""), d(x);
|
|
403
|
+
}, [
|
|
404
|
+
t,
|
|
405
|
+
r,
|
|
406
|
+
n,
|
|
407
|
+
s,
|
|
408
|
+
l,
|
|
409
|
+
d
|
|
410
|
+
]);
|
|
411
|
+
}
|
|
412
|
+
function ft() {
|
|
413
|
+
var u, v;
|
|
414
|
+
const t = M((b) => b.card), r = M((b) => b.frame), n = P(
|
|
415
|
+
() => lt(r, t),
|
|
416
|
+
[r, t]
|
|
417
|
+
), { manifest: s } = Qt(
|
|
418
|
+
((u = n == null ? void 0 : n.customCardPreferences) == null ? void 0 : u.url) || ""
|
|
419
|
+
), l = P(
|
|
420
|
+
() => {
|
|
421
|
+
var b;
|
|
422
|
+
return (b = s == null ? void 0 : s.visuals) == null ? void 0 : b.find(
|
|
423
|
+
(h) => {
|
|
424
|
+
var x;
|
|
425
|
+
return h.name === ((x = n == null ? void 0 : n.customCardPreferences) == null ? void 0 : x.componentName);
|
|
426
|
+
}
|
|
427
|
+
);
|
|
428
|
+
},
|
|
429
|
+
[s, (v = n == null ? void 0 : n.customCardPreferences) == null ? void 0 : v.componentName]
|
|
430
|
+
), d = $t(n, l), p = P(
|
|
431
|
+
() => Pt({
|
|
432
|
+
frame: r,
|
|
433
|
+
configCard: n,
|
|
434
|
+
isMultiInputVisual: d === "multiple"
|
|
435
|
+
}),
|
|
436
|
+
[r, n, d]
|
|
437
|
+
), f = P(() => {
|
|
438
|
+
const b = p.findIndex(
|
|
439
|
+
(h) => (h == null ? void 0 : h.id) === t.id
|
|
440
|
+
);
|
|
441
|
+
return b < 0 ? -1 : Ht(t, b);
|
|
442
|
+
}, [p, t]);
|
|
443
|
+
return P(() => !n || d !== "multiple" || f < 0 ? t.type : Wt(
|
|
444
|
+
t,
|
|
445
|
+
f,
|
|
446
|
+
l == null ? void 0 : l.slots
|
|
447
|
+
) ?? t.type, [n, d, f, t, l == null ? void 0 : l.slots]);
|
|
448
|
+
}
|
|
449
|
+
function La({
|
|
449
450
|
type: t,
|
|
450
451
|
isLinked: r,
|
|
451
452
|
className: n,
|
|
@@ -544,7 +545,7 @@ function Me(t) {
|
|
|
544
545
|
const r = Nt(t);
|
|
545
546
|
return r ? (B.error(r), !1) : !0;
|
|
546
547
|
}
|
|
547
|
-
function
|
|
548
|
+
function Aa({
|
|
548
549
|
className: t,
|
|
549
550
|
variant: r = "outline"
|
|
550
551
|
}) {
|
|
@@ -567,7 +568,7 @@ function La({
|
|
|
567
568
|
}
|
|
568
569
|
);
|
|
569
570
|
}
|
|
570
|
-
function
|
|
571
|
+
function qa({
|
|
571
572
|
className: t,
|
|
572
573
|
variant: r = "default"
|
|
573
574
|
}) {
|
|
@@ -617,7 +618,7 @@ function Aa({
|
|
|
617
618
|
}
|
|
618
619
|
);
|
|
619
620
|
}
|
|
620
|
-
function
|
|
621
|
+
function Ma({
|
|
621
622
|
className: t
|
|
622
623
|
}) {
|
|
623
624
|
const r = ce(), [n, s] = K(!1), l = Ae(), d = M((k) => k.frame), p = Z((k) => k.selectedSheetId), f = Z((k) => k.dashboard), { updateFrame: u, setIsVisualEditing: v } = Le(), { getUpdatedFrame: b } = qe(), h = dt(), x = Gt();
|
|
@@ -680,8 +681,8 @@ function qa({
|
|
|
680
681
|
}
|
|
681
682
|
);
|
|
682
683
|
}
|
|
683
|
-
function
|
|
684
|
-
const { setTempQueryData: r, setSqlGen: n } = ie(), s = ce(), l = M((h) => h.tempQueryData), d = M((h) => h.onClose), p = M((h) => h.card), f =
|
|
684
|
+
function Oa({ className: t }) {
|
|
685
|
+
const { setTempQueryData: r, setSqlGen: n } = ie(), s = ce(), l = M((h) => h.tempQueryData), d = M((h) => h.onClose), p = M((h) => h.card), f = ft(), u = P(() => f !== p.type ? { ...p, type: f } : p, [p, f]), { queryKey: v } = it(u);
|
|
685
686
|
function b() {
|
|
686
687
|
if (l) {
|
|
687
688
|
const { queryKey: h, queryData: x } = l;
|
|
@@ -703,12 +704,12 @@ function Ma({ className: t }) {
|
|
|
703
704
|
}
|
|
704
705
|
);
|
|
705
706
|
}
|
|
706
|
-
function
|
|
707
|
+
function za({
|
|
707
708
|
label: t = "Clear",
|
|
708
709
|
variant: r = "secondary",
|
|
709
710
|
className: n
|
|
710
711
|
} = {}) {
|
|
711
|
-
const { setTempQueryData: s } = ie(), l = ce(), d = M((O) => O.tempQueryData), p = M((O) => O.card), f =
|
|
712
|
+
const { setTempQueryData: s } = ie(), l = ce(), d = M((O) => O.tempQueryData), p = M((O) => O.card), f = ft(), u = P(() => f !== p.type ? { ...p, type: f } : p, [p, f]), { queryKey: v } = it(u), {
|
|
712
713
|
setCardSql: b,
|
|
713
714
|
setSqlGen: h,
|
|
714
715
|
setCardPython: x,
|
|
@@ -1016,7 +1017,7 @@ function Ca(t) {
|
|
|
1016
1017
|
defaultValue: me(n, void 0)
|
|
1017
1018
|
};
|
|
1018
1019
|
}
|
|
1019
|
-
function
|
|
1020
|
+
function Ua({
|
|
1020
1021
|
scope: t,
|
|
1021
1022
|
controls: r,
|
|
1022
1023
|
reservedControlIds: n,
|
|
@@ -1912,7 +1913,7 @@ function za({
|
|
|
1912
1913
|
)
|
|
1913
1914
|
] });
|
|
1914
1915
|
}
|
|
1915
|
-
function
|
|
1916
|
+
function Ra(t) {
|
|
1916
1917
|
const {
|
|
1917
1918
|
open: r,
|
|
1918
1919
|
onOpenChange: n,
|
|
@@ -1947,21 +1948,21 @@ function Ua(t) {
|
|
|
1947
1948
|
};
|
|
1948
1949
|
}
|
|
1949
1950
|
export {
|
|
1950
|
-
|
|
1951
|
-
|
|
1951
|
+
Ua as C,
|
|
1952
|
+
Aa as E,
|
|
1952
1953
|
da as L,
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1954
|
+
Fa as R,
|
|
1955
|
+
Va as S,
|
|
1956
|
+
La as V,
|
|
1957
|
+
Oa as a,
|
|
1958
|
+
qa as b,
|
|
1959
|
+
Ma as c,
|
|
1959
1960
|
ca as d,
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1961
|
+
Ra as e,
|
|
1962
|
+
_a as f,
|
|
1963
|
+
ft as g,
|
|
1964
|
+
ma as h,
|
|
1965
|
+
za as i,
|
|
1965
1966
|
Ta as r,
|
|
1966
1967
|
qe as u
|
|
1967
1968
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { n as z, c as D } from "./validators-CtNmgsvG.js";
|
|
2
|
-
import { n as O } from "./catalog-field-grounding-
|
|
2
|
+
import { n as O } from "./catalog-field-grounding-BK4BX8sZ.js";
|
|
3
3
|
import { b as M, c as j, a as q } from "./source-identity-Dj3dryN9.js";
|
|
4
4
|
function x(e) {
|
|
5
5
|
var t, i;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const x=require("./validators-jpoYhpHh.js"),V=require("./catalog-field-grounding-Du6mKDcF.js"),c=require("./source-identity-C-xaeE_I.js");function S(e){var t,i;const r=G(e);return{version:1,kind:"metric",id:e.id,label:e.label,source:g(e),metrics:r,primaryMetric:L(e,r),dateField:e.dateField?a(e.dateField,"date"):void 0,timeGrain:e.timeGrain,dimensions:(t=e.dimensions)==null?void 0:t.map(o=>a(o,"dimension")),comparison:le(e.comparison),orderBy:e.orderBy?{field:a(e.orderBy.field),direction:e.orderBy.direction}:void 0,inputs:p(e.inputs),limit:e.limit,...(i=e.derivedFields)!=null&&i.length?{derivedFields:e.derivedFields}:{}}}function R(e){var t;return{...S(e),...e.timeWindow?{timeWindow:e.timeWindow}:{},...(t=e.filters)!=null&&t.length?{filters:e.filters}:{},...e.analysis?{analysis:e.analysis}:{}}}function W(e){return{...e.chartTitle?{chartTitle:e.chartTitle}:{},...e.chartType?{chartType:e.chartType}:{},...e.driverMode?{driverMode:e.driverMode}:{},...e.includePopulation!==void 0?{includePopulation:e.includePopulation}:{},...e.calendarContext?{calendarContext:e.calendarContext}:{}}}function L(e,r){if(!e.primaryMetric)return r[0]||{name:"",role:"measure"};const t=a(e.primaryMetric,"measure"),i=Y(t,r),o=i.length===1?i[0]:void 0;return o?C(t,o):t}function G(e){const r=[];for(const t of e.metrics.map(i=>a(i,"measure"))){if(!t.name)continue;const i=r.findIndex(o=>U(o,t));if(i===-1){r.push(t);continue}r[i]=C(r[i],t)}return r}function U(e,r){return c.semaphorFieldRefsMatch(e,r)&&h(e)===h(r)}function J(e,r){return h(r)===h(e)}function X(e,r){return r.name!==e.name||e.source&&!c.semaphorFieldRefsMatch(r,e)?!1:J(e,r)}function Y(e,r){const t=r.filter(i=>X(e,i));return e.aggregate!==void 0,t}function h(e){return(e.aggregate||"SUM").toUpperCase()}function C(e,r){if(e.aggregate&&r.aggregate&&e.aggregate!==r.aggregate)throw new Error(`Metric "${e.name}" was requested with conflicting aggregate semantics: ${e.aggregate} and ${r.aggregate}.`);return{...c.preferSemaphorFieldRefMetadata(e,r),aggregate:e.aggregate||r.aggregate}}function H(e){var t,i;if("sort"in e)throw new Error("semaphor.records supports orderBy for a single deterministic sort. Multiple sort clauses are not supported by the analytics protocol yet.");if(!de(e))throw new Error("semaphor.records needs at least one field.");const r=Z(e.fields);return{version:1,kind:"records",id:e.id,label:e.label,source:g(e),fields:r,dateField:e.dateField?a(e.dateField,"date"):void 0,timeGrain:e.timeGrain,...e.timeWindow?{timeWindow:e.timeWindow}:{},...(t=e.filters)!=null&&t.length?{filters:e.filters}:{},orderBy:e.orderBy?{field:a(e.orderBy.field),direction:e.orderBy.direction}:void 0,inputs:p(e.inputs),limit:e.limit,...e.pagination?{pagination:e.pagination}:{},...(i=e.derivedFields)!=null&&i.length?{derivedFields:e.derivedFields}:{}}}function Z(e){return e.map(r=>{const t=a(r);if(!t.role)throw new Error(`semaphor.records field "${t.name}" needs an explicit role.`);return t})}function T(e){var r;return{version:1,kind:"inputOptions",id:e.id,label:e.label,source:g(e),field:a(e.field,"dimension"),search:e.search,limit:e.limit,...(r=e.derivedFields)!=null&&r.length?{derivedFields:e.derivedFields}:{}}}function P(e){var r;return{version:1,kind:"sql",id:e.id,label:e.label,source:e.source,sql:e.sql,...e.defaultParameters?{defaultParameters:e.defaultParameters}:{},...e.pythonCode?{pythonCode:e.pythonCode}:{},...(r=e.fields)!=null&&r.length?{fields:e.fields.map(t=>a(t))}:{},inputs:p(e.inputs),limit:e.limit,...e.pagination?{pagination:e.pagination}:{},rationale:e.rationale}}function B(e){var r,t;return{version:1,kind:"matrix",id:e.id,label:e.label,source:g(e),rows:e.rows.map(i=>A(i,"dimension")),...e.columns?{columns:e.columns.map(i=>A(i,"dimension"))}:{},values:e.values.map(ee),...(r=e.filters)!=null&&r.length?{filters:e.filters}:{},inputs:p(e.inputs),...e.totals?{totals:e.totals}:{},...(t=e.sort)!=null&&t.length?{sort:e.sort}:{},...e.expansion?{expansion:e.expansion}:{},...e.layout?{layout:e.layout}:{},...e.displayLimits?{displayLimits:e.displayLimits}:{}}}function A(e,r){return re(e)?{...e,field:a(e.field,r)}:{field:a(e,r)}}function ee(e){return te(e)?{...e,field:a(e.field,"measure")}:{field:a(e,"measure"),aggregate:e.aggregate}}function re(e){return"field"in e}function te(e){return"field"in e}function D(e){if("toAnalyticsInput"in e){const n=e.toAnalyticsInput();return{inputId:n.inputId,kind:n.kind,...n.controlRole?{controlRole:n.controlRole}:{},...n.operator?{operator:n.operator}:{},...n.field?{field:n.field}:{}}}if("id"in e){const n=k(e);return{inputId:n.inputId,kind:n.kind,...n.controlRole?{controlRole:n.controlRole}:{},...n.operator?{operator:n.operator}:{},...n.field?{field:n.field}:{}}}const r="kind"in e?e.kind:void 0,t="operator"in e?O(e.operator,e.inputId):void 0,i="controlRole"in e?e.controlRole:"role"in e?e.role:void 0,o=ie(i)?i:void 0;return{inputId:e.inputId,...r?{kind:r}:{},...o?{controlRole:o}:{},...t?{operator:t}:{},...e.field?{field:e.field}:{}}}function ie(e){return e==="grain"||e==="metric"||e==="dimension"||e==="aggregation"||e==="sqlParam"}function oe(e){const r=p(e);return r.length>0?r:void 0}function z(e){return(e||[]).map(se)}function ne(e){return z(e).filter(r=>r.isActive)}function k(e){if(e.kind==="filter"){const r=O(e.operator,e.id);return{inputId:e.id,kind:e.kind,label:e.label,field:a(e.field,"dimension"),operator:r||"in"}}return{inputId:e.id,kind:e.kind,label:e.label,controlRole:e.role}}function ae(e=[]){return e.map(r=>typeof r=="object"?r:{label:String(r),value:r})}function I(e){return e==null?!1:Array.isArray(e)?e.length>0:typeof e=="string"?e.trim().length>0:!0}function se(e){if("toAnalyticsInput"in e)return e.toAnalyticsInput();if("kind"in e&&"isActive"in e)return e;if("id"in e){const r=k(e),t=Object.prototype.hasOwnProperty.call(e,"value")?e.value:e.defaultValue;return{inputId:r.inputId,kind:r.kind,label:r.label,...r.field?{field:r.field}:{},...r.operator?{operator:r.operator}:{},...r.controlRole?{controlRole:r.controlRole}:{},value:t,isActive:I(t)}}return{...e,kind:"filter",isActive:I(e.value),value:e.value}}function g(e){return e.source}function de(e){var r;return!!((r=e.fields)!=null&&r.length)}function a(e,r){return{...e,role:e.role||r}}function p(e){return(e||[]).map(D)}function le(e){if(e)return e}function O(e,r){if(e===void 0)return;const t=x.normalizeSemaphorInputOperator(e);if(!t)throw new Error(`useSemaphorInput "${r}" uses unsupported filter operator "${e}".`);return t}function j(e,r={}){const t=r.pathPrefix||"analysisOptions";if(e===void 0)return{ok:!0};if(!e||typeof e!="object"||Array.isArray(e))return u(t,"Data App analysis options must be an object.");const i=e,o={};if(i.chartTitle!==void 0){if(typeof i.chartTitle!="string")return u(`${t}.chartTitle`,'Data App analysis option "chartTitle" must be a string.');o.chartTitle=i.chartTitle}if(i.chartType!==void 0){if(typeof i.chartType!="string")return u(`${t}.chartType`,'Data App analysis option "chartType" must be a string.');o.chartType=i.chartType}if(i.driverMode!==void 0){if(!ce(i.driverMode))return u(`${t}.driverMode`,'Data App analysis option "driverMode" must be absolute_delta, largest_negative, largest_positive, positive_and_negative, or all.');o.driverMode=i.driverMode}if(i.includePopulation!==void 0){if(typeof i.includePopulation!="boolean")return u(`${t}.includePopulation`,'Data App analysis option "includePopulation" must be a boolean.');o.includePopulation=i.includePopulation}if(i.calendarContext!==void 0){const n=ye(i.calendarContext,{pathPrefix:`${t}.calendarContext`,validateTimezone:r.validateTimezone});if(!n.ok)return n;o.calendarContext=n.calendarContext}return{ok:!0,analysisOptions:o}}function ue(e){const r=e.queries.map((o,n)=>fe(o,n,{fieldCatalogs:e.fieldCatalogs||[],requireFieldCatalog:!!e.requireFieldCatalog,validateTimezone:e.validateTimezone})),t=r.flatMap(o=>o.diagnostics),i=r.map(o=>o.executionResult);return{ok:t.every(o=>o.severity!=="error"),diagnostics:t,queries:r,intents:r.flatMap(o=>o.intent?[o.intent]:[]),executionResults:i}}function fe(e,r,t){const i=`queries.${r}`;try{const o=pe(e),n=xe(e,o),s=x.validateSemaphorAnalyticsIntent(o),d=[...ke({querySpec:e,queryId:n,intent:o,pathPrefix:i}),...s.errors.map(m=>w(m,{queryHook:e.queryHook,queryId:n,pathPrefix:i,severity:"error",intent:o})),...s.warnings.map(m=>w(m,{queryHook:e.queryHook,queryId:n,pathPrefix:i,severity:"warning",intent:o})),...ge({querySpec:e,queryId:n,intent:o,pathPrefix:i,fieldCatalogs:t.fieldCatalogs,requireFieldCatalog:t.requireFieldCatalog}),...Se({querySpec:e,queryId:n,intent:o,pathPrefix:i,validateTimezone:t.validateTimezone})],l=Fe(s,d);return{queryHook:e.queryHook,queryId:n,intent:o,diagnostics:d,executionResult:F({intent:o,validation:l,diagnostics:d})}}catch(o){const n={severity:"error",code:"invalid_query_spec",message:o instanceof Error?o.message:String(o),path:i,queryHook:e.queryHook,queryId:N(e.spec)},s=K([n]);return{queryHook:e.queryHook,queryId:n.queryId,diagnostics:[n],executionResult:F({validation:s,diagnostics:[n]})}}}function u(e,r){return{ok:!1,issues:[{code:"invalid_analysis_option",message:r,path:e}]}}function Q(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function ce(e){return e==="absolute_delta"||e==="largest_negative"||e==="largest_positive"||e==="positive_and_negative"||e==="all"}function me(e){return e.trim().length>0&&!Number.isNaN(Date.parse(e))}function ye(e,r){var l;if(!e||typeof e!="object"||Array.isArray(e))return u(r.pathPrefix,'Data App analysis option "calendarContext" must be an object.');const t=e,i=t.tz,o=t.weekStart,n=t.anchor,s=n&&typeof n=="object"&&!Array.isArray(n)?n.iso:void 0,d=typeof i=="string"?((l=r.validateTimezone)==null?void 0:l.call(r,i))??i:null;return d?typeof o!="number"||!Number.isInteger(o)||o<0||o>6?u(`${r.pathPrefix}.weekStart`,'Data App analysis option "calendarContext.weekStart" must be an integer from 0 to 6.'):n!=="now"&&!(typeof s=="string"&&me(s))?u(`${r.pathPrefix}.anchor`,'Data App analysis option "calendarContext.anchor" must be "now" or an object with a valid iso string.'):{ok:!0,calendarContext:{tz:d,weekStart:o,anchor:n}}:u(`${r.pathPrefix}.tz`,'Data App analysis option "calendarContext.tz" must be a valid timezone string.')}function pe(e){return he(e.spec)}function he(e){if(!Q(e))throw new Error("useSemaphorQuery spec must be an object.");if(e.queryKind==="metric")return S(e);if(e.queryKind==="analysis")return R(e);if(e.queryKind==="records")return H(e);if(e.queryKind==="sql")return P(e);if(e.queryKind==="matrix")return B(e);if(e.queryKind==="inputOptions")return T(e);throw new Error("useSemaphorQuery spec.queryKind must be metric, analysis, records, inputOptions, sql, or matrix.")}function ge(e){if(e.intent.kind==="sql")return[];if(e.fieldCatalogs.length===0&&!e.requireFieldCatalog)return[];const r=Ae(e.fieldCatalogs,e.intent.source);if(!r)return[{severity:"error",code:"invalid_source_ref",message:`Source ref for ${e.querySpec.queryHook} does not match a visible Semaphor source.`,path:`${e.pathPrefix}.spec.source`,queryHook:e.querySpec.queryHook,queryId:e.queryId,intentId:e.intent.id,source:e.intent.source}];const t=ve({...e,catalog:r}),i={...r,fields:[...r.fields,...$e(e.intent,r,e.intent.source)]};return[...t,...Ie({...e,catalog:i}),...qe({...e,catalog:i})]}function ve(e){const r=E(e.intent);if(r.length===0)return[];const t=[],i=new Set;return r.forEach((o,n)=>{const s=`${e.pathPrefix}.spec.derivedFields.${n}`,d=$(o.name);d&&(i.has(d)&&t.push({severity:"error",code:"duplicate_derived_field",message:`Derived field "${o.name}" is declared more than once.`,path:`${s}.name`,queryHook:e.querySpec.queryHook,queryId:e.queryId,intentId:e.intent.id,source:e.intent.source}),i.add(d),e.catalog.fields.some(l=>$(l.name)===d)&&t.push({severity:"error",code:"derived_field_name_collision",message:`Derived field "${o.name}" conflicts with a field already visible on the selected Semaphor source.`,path:`${s}.name`,queryHook:e.querySpec.queryHook,queryId:e.queryId,intentId:e.intent.id,source:e.intent.source})),Object.entries(o.inputs||{}).forEach(([l,m])=>{const f=Me(m);if(!f)return;const v=y(f,e.intent.source);if(!c.semaphorSourcesReferToSameDataset(v,e.intent.source)){t.push({severity:"error",code:"unsupported_derived_field_source",message:`Derived field "${o.name}" input "${l}" references a different Semaphor source. App-local derived fields must use fields from the query source.`,path:`${s}.inputs.${l}`,queryHook:e.querySpec.queryHook,queryId:e.queryId,intentId:e.intent.id,source:v,field:f});return}b(e.catalog,f,e.intent.source)||t.push({severity:"error",code:"missing_field",message:`Derived field "${o.name}" input "${l}" references field "${f.name}", which is not visible on the selected Semaphor source.`,path:`${s}.inputs.${l}`,queryHook:e.querySpec.queryHook,queryId:e.queryId,intentId:e.intent.id,source:v,field:f})})}),t}function Ie(e){return be(e.intent).flatMap(({field:r,path:t})=>b(e.catalog,r,e.intent.source)?[]:[{severity:"error",code:"missing_field",message:`Field "${r.name}" is not visible on the selected Semaphor source.`,path:`${e.pathPrefix}.${t}`,queryHook:e.querySpec.queryHook,queryId:e.queryId,intentId:e.intent.id,source:y(r,e.intent.source),field:r}])}function qe(e){return("inputs"in e.intent?e.intent.inputs||[]:[]).flatMap((t,i)=>{if(!t.field)return[];const o=y(t.field,e.intent.source);return c.semaphorSourcesReferToSameDataset(o,e.intent.source)?b(e.catalog,t.field,e.intent.source)?[]:[{severity:"error",code:"missing_field",message:`Input "${t.inputId}" references field "${t.field.name}", which is not visible on the selected Semaphor source.`,path:`${e.pathPrefix}.spec.inputs.${i}.field`,queryHook:e.querySpec.queryHook,queryId:e.queryId,intentId:e.intent.id,source:o,field:t.field}]:[{severity:"error",code:"unsupported_input_filter_composition",message:`Input "${t.inputId}" filters a different Semaphor source than the query. Cross-source Data App inputs are not supported yet.`,path:`${e.pathPrefix}.spec.inputs.${i}.field`,queryHook:e.querySpec.queryHook,queryId:e.queryId,intentId:e.intent.id,source:o,field:t.field}]})}function Se(e){if(e.querySpec.spec.queryKind!=="analysis")return[];const r=j(e.querySpec.spec,{pathPrefix:`${e.pathPrefix}.spec`,validateTimezone:e.validateTimezone});return r.ok?[]:r.issues.map(t=>({severity:"error",code:t.code,message:t.message,path:t.path,queryHook:e.querySpec.queryHook,queryId:e.queryId,intentId:e.intent.id,source:e.intent.source}))}function ke(e){return e.querySpec.spec.queryKind!=="sql"?[]:Q(e.querySpec.spec)?Object.prototype.hasOwnProperty.call(e.querySpec.spec,"parameters")?[{severity:"error",code:"deprecated_sql_parameters",message:"semaphor.sql uses defaultParameters for static SQL param(...) fallback values. The legacy parameters field is not supported.",path:`${e.pathPrefix}.spec.parameters`,queryHook:e.querySpec.queryHook,queryId:e.queryId,intentId:e.intent.id}]:[]:[]}function be(e){return e.kind==="metric"?[...e.metrics.map((r,t)=>({field:r,path:`spec.metrics.${t}`})),...e.primaryMetric?[{field:e.primaryMetric,path:"spec.primaryMetric"}]:[],...e.dateField?[{field:e.dateField,path:"spec.dateField"}]:[],...(e.dimensions||[]).map((r,t)=>({field:r,path:`spec.dimensions.${t}`})),...e.orderBy?[{field:e.orderBy.field,path:"spec.orderBy.field"}]:[],...(e.filters||[]).map((r,t)=>({field:r.field,path:`spec.filters.${t}.field`}))]:e.kind==="records"?[...e.fields.map((r,t)=>({field:r,path:`spec.fields.${t}`})),...e.dateField?[{field:e.dateField,path:"spec.dateField"}]:[],...e.orderBy?[{field:e.orderBy.field,path:"spec.orderBy.field"}]:[],...(e.filters||[]).map((r,t)=>({field:r.field,path:`spec.filters.${t}.field`}))]:e.kind==="inputOptions"?[{field:e.field,path:"spec.field"}]:e.kind==="matrix"?[...e.rows.map((r,t)=>({field:r.field,path:`spec.rows.${t}.field`})),...e.rows.flatMap((r,t)=>{var i;return((i=r.sortBy)==null?void 0:i.by.kind)==="field"?[{field:r.sortBy.by.field,path:`spec.rows.${t}.sortBy.by.field`}]:[]}),...(e.columns||[]).map((r,t)=>({field:r.field,path:`spec.columns.${t}.field`})),...(e.columns||[]).flatMap((r,t)=>{var i;return((i=r.sortBy)==null?void 0:i.by.kind)==="field"?[{field:r.sortBy.by.field,path:`spec.columns.${t}.sortBy.by.field`}]:[]}),...e.values.map((r,t)=>({field:r.field,path:`spec.values.${t}.field`})),...(e.sort||[]).flatMap((r,t)=>r.by.kind==="field"?[{field:r.by.field,path:`spec.sort.${t}.by.field`}]:[]),...(e.filters||[]).map((r,t)=>({field:r.field,path:`spec.filters.${t}.field`}))]:[]}function Ae(e,r){return e.find(t=>q(t,r))}function b(e,r,t){const i=y(r,t);if(q(e,i))return e.fields.find(o=>_e(o,r)&&q(e,y(o,e.source)))}function E(e){return!("derivedFields"in e)||!Array.isArray(e.derivedFields)?[]:e.derivedFields}function $e(e,r,t){return E(e).map(i=>({name:i.name,label:i.label,role:we(i.resultRole),dataType:i.dataType,source:r.source||t,...i.defaultAggregate?{aggregate:i.defaultAggregate}:{}}))}function we(e){return e==="measure"?"measure":e==="date"?"date":e==="id"?"id":"dimension"}function Me(e){if(!e||typeof e!="object")return;const r=e;return r.field||r.metric||r.dimension}function $(e){return V.normalizeAnalyticsCatalogName(e)}function q(e,r){return[e.source,...e.sourceAliases||[]].some(t=>c.semaphorSourcesReferToSameDataset(t,r))}function y(e,r){return e.source||r}function _e(e,r){return!!(e.name&&r.name&&e.name===r.name)}function w(e,r){return{severity:r.severity,code:e.code||"invalid_analytics_intent",message:e.message,path:e.path?`${r.pathPrefix}.spec.${e.path}`:r.pathPrefix,queryHook:r.queryHook,queryId:r.queryId,intentId:r.intent.id,source:r.intent.source}}function Fe(e,r){const t=K(r);return{ok:t.ok&&e.ok,errors:_([...e.errors,...t.errors]),warnings:_([...e.warnings,...t.warnings]),repairHints:[...e.repairHints,...t.repairHints]}}function K(e){const r=e.filter(i=>i.severity==="error").map(M),t=e.filter(i=>i.severity==="warning").map(M);return{ok:r.length===0,errors:r,warnings:t,repairHints:r.map(i=>{var o,n;return{code:i.code,message:i.message,fieldRole:i.fieldRole,invalidField:(o=i.repairHint)==null?void 0:o.invalidField,recommendedNextStep:((n=i.repairHint)==null?void 0:n.recommendedNextStep)||"Update the Data App SDK query spec to use visible Semaphor source and field refs."}})}}function M(e){var r;return{code:e.code,message:e.message,path:e.path,fieldRole:e.code==="invalid_source_ref"?"source":void 0,repairHint:{code:e.code,message:e.message,invalidField:(r=e.field)==null?void 0:r.name,fieldRole:e.code==="invalid_source_ref"?"source":void 0,recommendedNextStep:e.code==="unsupported_input_filter_composition"?"Use an input field from the same Semaphor source as the query, or split the query into separate source-scoped queries.":"Update the query spec to use a visible Semaphor source and field ref."}}}function _(e){const r=new Set;return e.filter(t=>{const i=`${t.code}:${t.path||""}:${t.message}`;return r.has(i)?!1:(r.add(i),!0)})}function F(e){var t,i;const r=e.diagnostics.filter(o=>o.severity==="error");return{intentId:(t=e.intent)==null?void 0:t.id,status:r.length?"failed":"answered",resultShape:(i=e.intent)==null?void 0:i.kind,intent:e.intent,validation:e.validation,coverage:{answeredObligations:r.length?[]:["query_spec_validation"],missingObligations:r.length?["query_spec_validation"]:[],warnings:e.validation.warnings},missingFields:r.filter(o=>o.code==="missing_field").flatMap(o=>{var n;return(n=o.field)!=null&&n.name?[o.field.name]:[]}),warnings:e.diagnostics.filter(o=>o.severity==="warning").map(o=>o.message),metadata:{validationKind:"data_app_sdk_query_spec"}}}function xe(e,r){return r.id||N(e.spec)}function N(e){if(!e||typeof e!="object"||!("id"in e))return;const r=e.id;return typeof r=="string"&&r.trim()?r:void 0}exports.hasSemaphorInputValue=I;exports.normalizeSemaphorAnalysisQueryOptions=j;exports.normalizeSemaphorInputOptions=ae;exports.toSemaphorActiveInputSnapshots=ne;exports.toSemaphorAnalysisIntent=R;exports.toSemaphorAnalysisQueryOptions=W;exports.toSemaphorInputBinding=D;exports.toSemaphorInputBindings=oe;exports.toSemaphorInputOptionsIntent=T;exports.toSemaphorInputSnapshots=z;exports.toSemaphorInputSpec=k;exports.toSemaphorMatrixIntent=B;exports.toSemaphorMetricIntent=S;exports.toSemaphorRecordsIntent=H;exports.toSemaphorSqlIntent=P;exports.validateSemaphorDataAppQuerySpecs=ue;
|
|
1
|
+
"use strict";const x=require("./validators-jpoYhpHh.js"),V=require("./catalog-field-grounding-8L9I0zdg.js"),c=require("./source-identity-C-xaeE_I.js");function S(e){var t,i;const r=G(e);return{version:1,kind:"metric",id:e.id,label:e.label,source:g(e),metrics:r,primaryMetric:L(e,r),dateField:e.dateField?a(e.dateField,"date"):void 0,timeGrain:e.timeGrain,dimensions:(t=e.dimensions)==null?void 0:t.map(o=>a(o,"dimension")),comparison:le(e.comparison),orderBy:e.orderBy?{field:a(e.orderBy.field),direction:e.orderBy.direction}:void 0,inputs:p(e.inputs),limit:e.limit,...(i=e.derivedFields)!=null&&i.length?{derivedFields:e.derivedFields}:{}}}function R(e){var t;return{...S(e),...e.timeWindow?{timeWindow:e.timeWindow}:{},...(t=e.filters)!=null&&t.length?{filters:e.filters}:{},...e.analysis?{analysis:e.analysis}:{}}}function W(e){return{...e.chartTitle?{chartTitle:e.chartTitle}:{},...e.chartType?{chartType:e.chartType}:{},...e.driverMode?{driverMode:e.driverMode}:{},...e.includePopulation!==void 0?{includePopulation:e.includePopulation}:{},...e.calendarContext?{calendarContext:e.calendarContext}:{}}}function L(e,r){if(!e.primaryMetric)return r[0]||{name:"",role:"measure"};const t=a(e.primaryMetric,"measure"),i=Y(t,r),o=i.length===1?i[0]:void 0;return o?C(t,o):t}function G(e){const r=[];for(const t of e.metrics.map(i=>a(i,"measure"))){if(!t.name)continue;const i=r.findIndex(o=>U(o,t));if(i===-1){r.push(t);continue}r[i]=C(r[i],t)}return r}function U(e,r){return c.semaphorFieldRefsMatch(e,r)&&h(e)===h(r)}function J(e,r){return h(r)===h(e)}function X(e,r){return r.name!==e.name||e.source&&!c.semaphorFieldRefsMatch(r,e)?!1:J(e,r)}function Y(e,r){const t=r.filter(i=>X(e,i));return e.aggregate!==void 0,t}function h(e){return(e.aggregate||"SUM").toUpperCase()}function C(e,r){if(e.aggregate&&r.aggregate&&e.aggregate!==r.aggregate)throw new Error(`Metric "${e.name}" was requested with conflicting aggregate semantics: ${e.aggregate} and ${r.aggregate}.`);return{...c.preferSemaphorFieldRefMetadata(e,r),aggregate:e.aggregate||r.aggregate}}function H(e){var t,i;if("sort"in e)throw new Error("semaphor.records supports orderBy for a single deterministic sort. Multiple sort clauses are not supported by the analytics protocol yet.");if(!de(e))throw new Error("semaphor.records needs at least one field.");const r=Z(e.fields);return{version:1,kind:"records",id:e.id,label:e.label,source:g(e),fields:r,dateField:e.dateField?a(e.dateField,"date"):void 0,timeGrain:e.timeGrain,...e.timeWindow?{timeWindow:e.timeWindow}:{},...(t=e.filters)!=null&&t.length?{filters:e.filters}:{},orderBy:e.orderBy?{field:a(e.orderBy.field),direction:e.orderBy.direction}:void 0,inputs:p(e.inputs),limit:e.limit,...e.pagination?{pagination:e.pagination}:{},...(i=e.derivedFields)!=null&&i.length?{derivedFields:e.derivedFields}:{}}}function Z(e){return e.map(r=>{const t=a(r);if(!t.role)throw new Error(`semaphor.records field "${t.name}" needs an explicit role.`);return t})}function T(e){var r;return{version:1,kind:"inputOptions",id:e.id,label:e.label,source:g(e),field:a(e.field,"dimension"),search:e.search,limit:e.limit,...(r=e.derivedFields)!=null&&r.length?{derivedFields:e.derivedFields}:{}}}function P(e){var r;return{version:1,kind:"sql",id:e.id,label:e.label,source:e.source,sql:e.sql,...e.defaultParameters?{defaultParameters:e.defaultParameters}:{},...e.pythonCode?{pythonCode:e.pythonCode}:{},...(r=e.fields)!=null&&r.length?{fields:e.fields.map(t=>a(t))}:{},inputs:p(e.inputs),limit:e.limit,...e.pagination?{pagination:e.pagination}:{},rationale:e.rationale}}function B(e){var r,t;return{version:1,kind:"matrix",id:e.id,label:e.label,source:g(e),rows:e.rows.map(i=>A(i,"dimension")),...e.columns?{columns:e.columns.map(i=>A(i,"dimension"))}:{},values:e.values.map(ee),...(r=e.filters)!=null&&r.length?{filters:e.filters}:{},inputs:p(e.inputs),...e.totals?{totals:e.totals}:{},...(t=e.sort)!=null&&t.length?{sort:e.sort}:{},...e.expansion?{expansion:e.expansion}:{},...e.layout?{layout:e.layout}:{},...e.displayLimits?{displayLimits:e.displayLimits}:{}}}function A(e,r){return re(e)?{...e,field:a(e.field,r)}:{field:a(e,r)}}function ee(e){return te(e)?{...e,field:a(e.field,"measure")}:{field:a(e,"measure"),aggregate:e.aggregate}}function re(e){return"field"in e}function te(e){return"field"in e}function D(e){if("toAnalyticsInput"in e){const n=e.toAnalyticsInput();return{inputId:n.inputId,kind:n.kind,...n.controlRole?{controlRole:n.controlRole}:{},...n.operator?{operator:n.operator}:{},...n.field?{field:n.field}:{}}}if("id"in e){const n=k(e);return{inputId:n.inputId,kind:n.kind,...n.controlRole?{controlRole:n.controlRole}:{},...n.operator?{operator:n.operator}:{},...n.field?{field:n.field}:{}}}const r="kind"in e?e.kind:void 0,t="operator"in e?O(e.operator,e.inputId):void 0,i="controlRole"in e?e.controlRole:"role"in e?e.role:void 0,o=ie(i)?i:void 0;return{inputId:e.inputId,...r?{kind:r}:{},...o?{controlRole:o}:{},...t?{operator:t}:{},...e.field?{field:e.field}:{}}}function ie(e){return e==="grain"||e==="metric"||e==="dimension"||e==="aggregation"||e==="sqlParam"}function oe(e){const r=p(e);return r.length>0?r:void 0}function z(e){return(e||[]).map(se)}function ne(e){return z(e).filter(r=>r.isActive)}function k(e){if(e.kind==="filter"){const r=O(e.operator,e.id);return{inputId:e.id,kind:e.kind,label:e.label,field:a(e.field,"dimension"),operator:r||"in"}}return{inputId:e.id,kind:e.kind,label:e.label,controlRole:e.role}}function ae(e=[]){return e.map(r=>typeof r=="object"?r:{label:String(r),value:r})}function I(e){return e==null?!1:Array.isArray(e)?e.length>0:typeof e=="string"?e.trim().length>0:!0}function se(e){if("toAnalyticsInput"in e)return e.toAnalyticsInput();if("kind"in e&&"isActive"in e)return e;if("id"in e){const r=k(e),t=Object.prototype.hasOwnProperty.call(e,"value")?e.value:e.defaultValue;return{inputId:r.inputId,kind:r.kind,label:r.label,...r.field?{field:r.field}:{},...r.operator?{operator:r.operator}:{},...r.controlRole?{controlRole:r.controlRole}:{},value:t,isActive:I(t)}}return{...e,kind:"filter",isActive:I(e.value),value:e.value}}function g(e){return e.source}function de(e){var r;return!!((r=e.fields)!=null&&r.length)}function a(e,r){return{...e,role:e.role||r}}function p(e){return(e||[]).map(D)}function le(e){if(e)return e}function O(e,r){if(e===void 0)return;const t=x.normalizeSemaphorInputOperator(e);if(!t)throw new Error(`useSemaphorInput "${r}" uses unsupported filter operator "${e}".`);return t}function j(e,r={}){const t=r.pathPrefix||"analysisOptions";if(e===void 0)return{ok:!0};if(!e||typeof e!="object"||Array.isArray(e))return u(t,"Data App analysis options must be an object.");const i=e,o={};if(i.chartTitle!==void 0){if(typeof i.chartTitle!="string")return u(`${t}.chartTitle`,'Data App analysis option "chartTitle" must be a string.');o.chartTitle=i.chartTitle}if(i.chartType!==void 0){if(typeof i.chartType!="string")return u(`${t}.chartType`,'Data App analysis option "chartType" must be a string.');o.chartType=i.chartType}if(i.driverMode!==void 0){if(!ce(i.driverMode))return u(`${t}.driverMode`,'Data App analysis option "driverMode" must be absolute_delta, largest_negative, largest_positive, positive_and_negative, or all.');o.driverMode=i.driverMode}if(i.includePopulation!==void 0){if(typeof i.includePopulation!="boolean")return u(`${t}.includePopulation`,'Data App analysis option "includePopulation" must be a boolean.');o.includePopulation=i.includePopulation}if(i.calendarContext!==void 0){const n=ye(i.calendarContext,{pathPrefix:`${t}.calendarContext`,validateTimezone:r.validateTimezone});if(!n.ok)return n;o.calendarContext=n.calendarContext}return{ok:!0,analysisOptions:o}}function ue(e){const r=e.queries.map((o,n)=>fe(o,n,{fieldCatalogs:e.fieldCatalogs||[],requireFieldCatalog:!!e.requireFieldCatalog,validateTimezone:e.validateTimezone})),t=r.flatMap(o=>o.diagnostics),i=r.map(o=>o.executionResult);return{ok:t.every(o=>o.severity!=="error"),diagnostics:t,queries:r,intents:r.flatMap(o=>o.intent?[o.intent]:[]),executionResults:i}}function fe(e,r,t){const i=`queries.${r}`;try{const o=pe(e),n=xe(e,o),s=x.validateSemaphorAnalyticsIntent(o),d=[...ke({querySpec:e,queryId:n,intent:o,pathPrefix:i}),...s.errors.map(m=>w(m,{queryHook:e.queryHook,queryId:n,pathPrefix:i,severity:"error",intent:o})),...s.warnings.map(m=>w(m,{queryHook:e.queryHook,queryId:n,pathPrefix:i,severity:"warning",intent:o})),...ge({querySpec:e,queryId:n,intent:o,pathPrefix:i,fieldCatalogs:t.fieldCatalogs,requireFieldCatalog:t.requireFieldCatalog}),...Se({querySpec:e,queryId:n,intent:o,pathPrefix:i,validateTimezone:t.validateTimezone})],l=Fe(s,d);return{queryHook:e.queryHook,queryId:n,intent:o,diagnostics:d,executionResult:F({intent:o,validation:l,diagnostics:d})}}catch(o){const n={severity:"error",code:"invalid_query_spec",message:o instanceof Error?o.message:String(o),path:i,queryHook:e.queryHook,queryId:N(e.spec)},s=K([n]);return{queryHook:e.queryHook,queryId:n.queryId,diagnostics:[n],executionResult:F({validation:s,diagnostics:[n]})}}}function u(e,r){return{ok:!1,issues:[{code:"invalid_analysis_option",message:r,path:e}]}}function Q(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function ce(e){return e==="absolute_delta"||e==="largest_negative"||e==="largest_positive"||e==="positive_and_negative"||e==="all"}function me(e){return e.trim().length>0&&!Number.isNaN(Date.parse(e))}function ye(e,r){var l;if(!e||typeof e!="object"||Array.isArray(e))return u(r.pathPrefix,'Data App analysis option "calendarContext" must be an object.');const t=e,i=t.tz,o=t.weekStart,n=t.anchor,s=n&&typeof n=="object"&&!Array.isArray(n)?n.iso:void 0,d=typeof i=="string"?((l=r.validateTimezone)==null?void 0:l.call(r,i))??i:null;return d?typeof o!="number"||!Number.isInteger(o)||o<0||o>6?u(`${r.pathPrefix}.weekStart`,'Data App analysis option "calendarContext.weekStart" must be an integer from 0 to 6.'):n!=="now"&&!(typeof s=="string"&&me(s))?u(`${r.pathPrefix}.anchor`,'Data App analysis option "calendarContext.anchor" must be "now" or an object with a valid iso string.'):{ok:!0,calendarContext:{tz:d,weekStart:o,anchor:n}}:u(`${r.pathPrefix}.tz`,'Data App analysis option "calendarContext.tz" must be a valid timezone string.')}function pe(e){return he(e.spec)}function he(e){if(!Q(e))throw new Error("useSemaphorQuery spec must be an object.");if(e.queryKind==="metric")return S(e);if(e.queryKind==="analysis")return R(e);if(e.queryKind==="records")return H(e);if(e.queryKind==="sql")return P(e);if(e.queryKind==="matrix")return B(e);if(e.queryKind==="inputOptions")return T(e);throw new Error("useSemaphorQuery spec.queryKind must be metric, analysis, records, inputOptions, sql, or matrix.")}function ge(e){if(e.intent.kind==="sql")return[];if(e.fieldCatalogs.length===0&&!e.requireFieldCatalog)return[];const r=Ae(e.fieldCatalogs,e.intent.source);if(!r)return[{severity:"error",code:"invalid_source_ref",message:`Source ref for ${e.querySpec.queryHook} does not match a visible Semaphor source.`,path:`${e.pathPrefix}.spec.source`,queryHook:e.querySpec.queryHook,queryId:e.queryId,intentId:e.intent.id,source:e.intent.source}];const t=ve({...e,catalog:r}),i={...r,fields:[...r.fields,...$e(e.intent,r,e.intent.source)]};return[...t,...Ie({...e,catalog:i}),...qe({...e,catalog:i})]}function ve(e){const r=E(e.intent);if(r.length===0)return[];const t=[],i=new Set;return r.forEach((o,n)=>{const s=`${e.pathPrefix}.spec.derivedFields.${n}`,d=$(o.name);d&&(i.has(d)&&t.push({severity:"error",code:"duplicate_derived_field",message:`Derived field "${o.name}" is declared more than once.`,path:`${s}.name`,queryHook:e.querySpec.queryHook,queryId:e.queryId,intentId:e.intent.id,source:e.intent.source}),i.add(d),e.catalog.fields.some(l=>$(l.name)===d)&&t.push({severity:"error",code:"derived_field_name_collision",message:`Derived field "${o.name}" conflicts with a field already visible on the selected Semaphor source.`,path:`${s}.name`,queryHook:e.querySpec.queryHook,queryId:e.queryId,intentId:e.intent.id,source:e.intent.source})),Object.entries(o.inputs||{}).forEach(([l,m])=>{const f=Me(m);if(!f)return;const v=y(f,e.intent.source);if(!c.semaphorSourcesReferToSameDataset(v,e.intent.source)){t.push({severity:"error",code:"unsupported_derived_field_source",message:`Derived field "${o.name}" input "${l}" references a different Semaphor source. App-local derived fields must use fields from the query source.`,path:`${s}.inputs.${l}`,queryHook:e.querySpec.queryHook,queryId:e.queryId,intentId:e.intent.id,source:v,field:f});return}b(e.catalog,f,e.intent.source)||t.push({severity:"error",code:"missing_field",message:`Derived field "${o.name}" input "${l}" references field "${f.name}", which is not visible on the selected Semaphor source.`,path:`${s}.inputs.${l}`,queryHook:e.querySpec.queryHook,queryId:e.queryId,intentId:e.intent.id,source:v,field:f})})}),t}function Ie(e){return be(e.intent).flatMap(({field:r,path:t})=>b(e.catalog,r,e.intent.source)?[]:[{severity:"error",code:"missing_field",message:`Field "${r.name}" is not visible on the selected Semaphor source.`,path:`${e.pathPrefix}.${t}`,queryHook:e.querySpec.queryHook,queryId:e.queryId,intentId:e.intent.id,source:y(r,e.intent.source),field:r}])}function qe(e){return("inputs"in e.intent?e.intent.inputs||[]:[]).flatMap((t,i)=>{if(!t.field)return[];const o=y(t.field,e.intent.source);return c.semaphorSourcesReferToSameDataset(o,e.intent.source)?b(e.catalog,t.field,e.intent.source)?[]:[{severity:"error",code:"missing_field",message:`Input "${t.inputId}" references field "${t.field.name}", which is not visible on the selected Semaphor source.`,path:`${e.pathPrefix}.spec.inputs.${i}.field`,queryHook:e.querySpec.queryHook,queryId:e.queryId,intentId:e.intent.id,source:o,field:t.field}]:[{severity:"error",code:"unsupported_input_filter_composition",message:`Input "${t.inputId}" filters a different Semaphor source than the query. Cross-source Data App inputs are not supported yet.`,path:`${e.pathPrefix}.spec.inputs.${i}.field`,queryHook:e.querySpec.queryHook,queryId:e.queryId,intentId:e.intent.id,source:o,field:t.field}]})}function Se(e){if(e.querySpec.spec.queryKind!=="analysis")return[];const r=j(e.querySpec.spec,{pathPrefix:`${e.pathPrefix}.spec`,validateTimezone:e.validateTimezone});return r.ok?[]:r.issues.map(t=>({severity:"error",code:t.code,message:t.message,path:t.path,queryHook:e.querySpec.queryHook,queryId:e.queryId,intentId:e.intent.id,source:e.intent.source}))}function ke(e){return e.querySpec.spec.queryKind!=="sql"?[]:Q(e.querySpec.spec)?Object.prototype.hasOwnProperty.call(e.querySpec.spec,"parameters")?[{severity:"error",code:"deprecated_sql_parameters",message:"semaphor.sql uses defaultParameters for static SQL param(...) fallback values. The legacy parameters field is not supported.",path:`${e.pathPrefix}.spec.parameters`,queryHook:e.querySpec.queryHook,queryId:e.queryId,intentId:e.intent.id}]:[]:[]}function be(e){return e.kind==="metric"?[...e.metrics.map((r,t)=>({field:r,path:`spec.metrics.${t}`})),...e.primaryMetric?[{field:e.primaryMetric,path:"spec.primaryMetric"}]:[],...e.dateField?[{field:e.dateField,path:"spec.dateField"}]:[],...(e.dimensions||[]).map((r,t)=>({field:r,path:`spec.dimensions.${t}`})),...e.orderBy?[{field:e.orderBy.field,path:"spec.orderBy.field"}]:[],...(e.filters||[]).map((r,t)=>({field:r.field,path:`spec.filters.${t}.field`}))]:e.kind==="records"?[...e.fields.map((r,t)=>({field:r,path:`spec.fields.${t}`})),...e.dateField?[{field:e.dateField,path:"spec.dateField"}]:[],...e.orderBy?[{field:e.orderBy.field,path:"spec.orderBy.field"}]:[],...(e.filters||[]).map((r,t)=>({field:r.field,path:`spec.filters.${t}.field`}))]:e.kind==="inputOptions"?[{field:e.field,path:"spec.field"}]:e.kind==="matrix"?[...e.rows.map((r,t)=>({field:r.field,path:`spec.rows.${t}.field`})),...e.rows.flatMap((r,t)=>{var i;return((i=r.sortBy)==null?void 0:i.by.kind)==="field"?[{field:r.sortBy.by.field,path:`spec.rows.${t}.sortBy.by.field`}]:[]}),...(e.columns||[]).map((r,t)=>({field:r.field,path:`spec.columns.${t}.field`})),...(e.columns||[]).flatMap((r,t)=>{var i;return((i=r.sortBy)==null?void 0:i.by.kind)==="field"?[{field:r.sortBy.by.field,path:`spec.columns.${t}.sortBy.by.field`}]:[]}),...e.values.map((r,t)=>({field:r.field,path:`spec.values.${t}.field`})),...(e.sort||[]).flatMap((r,t)=>r.by.kind==="field"?[{field:r.by.field,path:`spec.sort.${t}.by.field`}]:[]),...(e.filters||[]).map((r,t)=>({field:r.field,path:`spec.filters.${t}.field`}))]:[]}function Ae(e,r){return e.find(t=>q(t,r))}function b(e,r,t){const i=y(r,t);if(q(e,i))return e.fields.find(o=>_e(o,r)&&q(e,y(o,e.source)))}function E(e){return!("derivedFields"in e)||!Array.isArray(e.derivedFields)?[]:e.derivedFields}function $e(e,r,t){return E(e).map(i=>({name:i.name,label:i.label,role:we(i.resultRole),dataType:i.dataType,source:r.source||t,...i.defaultAggregate?{aggregate:i.defaultAggregate}:{}}))}function we(e){return e==="measure"?"measure":e==="date"?"date":e==="id"?"id":"dimension"}function Me(e){if(!e||typeof e!="object")return;const r=e;return r.field||r.metric||r.dimension}function $(e){return V.normalizeAnalyticsCatalogName(e)}function q(e,r){return[e.source,...e.sourceAliases||[]].some(t=>c.semaphorSourcesReferToSameDataset(t,r))}function y(e,r){return e.source||r}function _e(e,r){return!!(e.name&&r.name&&e.name===r.name)}function w(e,r){return{severity:r.severity,code:e.code||"invalid_analytics_intent",message:e.message,path:e.path?`${r.pathPrefix}.spec.${e.path}`:r.pathPrefix,queryHook:r.queryHook,queryId:r.queryId,intentId:r.intent.id,source:r.intent.source}}function Fe(e,r){const t=K(r);return{ok:t.ok&&e.ok,errors:_([...e.errors,...t.errors]),warnings:_([...e.warnings,...t.warnings]),repairHints:[...e.repairHints,...t.repairHints]}}function K(e){const r=e.filter(i=>i.severity==="error").map(M),t=e.filter(i=>i.severity==="warning").map(M);return{ok:r.length===0,errors:r,warnings:t,repairHints:r.map(i=>{var o,n;return{code:i.code,message:i.message,fieldRole:i.fieldRole,invalidField:(o=i.repairHint)==null?void 0:o.invalidField,recommendedNextStep:((n=i.repairHint)==null?void 0:n.recommendedNextStep)||"Update the Data App SDK query spec to use visible Semaphor source and field refs."}})}}function M(e){var r;return{code:e.code,message:e.message,path:e.path,fieldRole:e.code==="invalid_source_ref"?"source":void 0,repairHint:{code:e.code,message:e.message,invalidField:(r=e.field)==null?void 0:r.name,fieldRole:e.code==="invalid_source_ref"?"source":void 0,recommendedNextStep:e.code==="unsupported_input_filter_composition"?"Use an input field from the same Semaphor source as the query, or split the query into separate source-scoped queries.":"Update the query spec to use a visible Semaphor source and field ref."}}}function _(e){const r=new Set;return e.filter(t=>{const i=`${t.code}:${t.path||""}:${t.message}`;return r.has(i)?!1:(r.add(i),!0)})}function F(e){var t,i;const r=e.diagnostics.filter(o=>o.severity==="error");return{intentId:(t=e.intent)==null?void 0:t.id,status:r.length?"failed":"answered",resultShape:(i=e.intent)==null?void 0:i.kind,intent:e.intent,validation:e.validation,coverage:{answeredObligations:r.length?[]:["query_spec_validation"],missingObligations:r.length?["query_spec_validation"]:[],warnings:e.validation.warnings},missingFields:r.filter(o=>o.code==="missing_field").flatMap(o=>{var n;return(n=o.field)!=null&&n.name?[o.field.name]:[]}),warnings:e.diagnostics.filter(o=>o.severity==="warning").map(o=>o.message),metadata:{validationKind:"data_app_sdk_query_spec"}}}function xe(e,r){return r.id||N(e.spec)}function N(e){if(!e||typeof e!="object"||!("id"in e))return;const r=e.id;return typeof r=="string"&&r.trim()?r:void 0}exports.hasSemaphorInputValue=I;exports.normalizeSemaphorAnalysisQueryOptions=j;exports.normalizeSemaphorInputOptions=ae;exports.toSemaphorActiveInputSnapshots=ne;exports.toSemaphorAnalysisIntent=R;exports.toSemaphorAnalysisQueryOptions=W;exports.toSemaphorInputBinding=D;exports.toSemaphorInputBindings=oe;exports.toSemaphorInputOptionsIntent=T;exports.toSemaphorInputSnapshots=z;exports.toSemaphorInputSpec=k;exports.toSemaphorMatrixIntent=B;exports.toSemaphorMetricIntent=S;exports.toSemaphorRecordsIntent=H;exports.toSemaphorSqlIntent=P;exports.validateSemaphorDataAppQuerySpecs=ue;
|
package/dist/dashboard/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("../chunks/index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("../chunks/index-c_0nwsOM.js"),e=require("../chunks/common-types-C73-Ud1-.js");exports.Dashboard=o.Dashboard;exports.CONTROL_CARD_DEFAULT_VALUE=e.CONTROL_CARD_DEFAULT_VALUE;exports.EMPTY_SELECTION=e.EMPTY_SELECTION;
|
package/dist/dashboard/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const v=require("../chunks/contracts-CtB2VONT.js"),N=require("../chunks/source-identity-C-xaeE_I.js"),z=require("../chunks/validators-jpoYhpHh.js"),De=require("../chunks/catalog-field-grounding-Du6mKDcF.js");function _(e){return e&&typeof e=="object"?e:null}function D(e){return typeof e=="string"?e:null}function oe(e){var t,r,n;return!!(e&&typeof e=="object")&&(((t=_(e))==null?void 0:t.kind)==="semantic"||((r=_(e))==null?void 0:r.kind)==="physical"||((n=_(e))==null?void 0:n.kind)==="sql")}function M(e){return oe(e)?e.kind==="semantic"?!!(e.domainId&&e.datasetName):e.kind==="physical"?!!(e.connectionId&&e.tableName):!1:!1}function ve(e){return N.semaphorSourceIdentityKey(e)}function K(e,t){return N.semaphorSourcesReferToSameDataset(e,t)}function se(e,t){return N.preferSemaphorSourceMetadata(e,t)}function R(e){const t=[];for(const r of e){const n=t.findIndex(o=>K(o,r));n===-1?t.push(r):t[n]=se(t[n],r)}return t}function Ce(e){return R(e)[0]}function G(e,t){return e.kind!=="semantic"||e.connectionId||(t==null?void 0:t.kind)!=="semantic"||!N.semaphorSourcesReferToSameDataset(e,t)||!t.connectionId?e:{...e,connectionId:t.connectionId}}function W(e){return M(e)?e:void 0}function ae(e,t){if(!(e.kind!=="semantic"||e.connectionId))return t.find(r=>(r==null?void 0:r.kind)==="semantic"&&N.semaphorSourcesReferToSameDataset(e,r)&&!!r.connectionId)}function S(e,t){const r=W(e==null?void 0:e.source);return r?G(r,t):void 0}function de({explicitSource:e,field:t,defaultSource:r,fallbackSources:n}){const o=[r,...n||[]],a=W(e),i=a?G(a,ae(a,o)):void 0;if(i)return i;if(e!==void 0)return;const d=S(t,r),s=d?G(d,ae(d,o)):void 0;if(s)return s;if((t==null?void 0:t.source)===void 0)return W(r)}function ke(e,t){if(!(e!=null&&e.name)||!(t!=null&&t.name)||e.name!==t.name)return!1;const r=S(e),n=S(t);return!r||!n?!0:K(r,n)}function C(e){var t;return D((t=_(e))==null?void 0:t.kind)}function ce(e){var t,r;return C(e)!=="semantic"?null:((r=D((t=_(e))==null?void 0:t.domainId))==null?void 0:r.trim())||null}function xe(e){var t;return C(e)!=="semantic"?null:D((t=_(e))==null?void 0:t.datasetName)}function Te(e){var t;return C(e)!=="semantic"?null:D((t=_(e))==null?void 0:t.datasetId)}function Fe(e){var t;return C(e)!=="physical"?null:D((t=_(e))==null?void 0:t.connectionId)}function Re(e){var t;return C(e)!=="physical"?null:D((t=_(e))==null?void 0:t.tableName)}function Ne(e){var t;return C(e)!=="physical"?"":D((t=_(e))==null?void 0:t.databaseName)||""}function Me(e){var t;return C(e)!=="physical"?"":D((t=_(e))==null?void 0:t.schemaName)||""}function le(e){if(e.analyticsIntent&&typeof e.analyticsIntent=="object"&&"source"in e.analyticsIntent)return e.analyticsIntent.source}function ue({datasets:e,requireAtLeastOne:t}){if(t&&e.length<1)return{ok:!1,issue:"invalid_dataset_count"};if(e.length<=1)return{ok:!0};const r=e.map(ce),n=new Set(r.filter(Boolean));return r.some(o=>!o)||n.size!==1?{ok:!1,issue:"invalid_multi_dataset_scope"}:{ok:!0}}function E(e,t){if(!t)return!1;if(t.kind==="semantic"){const r=Te(e);return ce(e)===t.domainId?r&&t.datasetId?r===t.datasetId:xe(e)===t.datasetName:!1}return t.kind==="physical"?Fe(e)===t.connectionId&&Re(e)===t.tableName&&Ne(e)===(t.databaseName||"")&&Me(e)===(t.schemaName||""):!1}function $e(e,t){return e.find(r=>E(r,t))}function p(e,t,r){return r?{code:e,message:t,cardId:r}:{code:e,message:t}}function B(e){const t=new Set;for(const r of e){if(t.has(r))return r;t.add(r)}return null}function fe({card:e,datasets:t,errors:r}){if(e.type==="text")return;const n=le(e);if(!n){if(t.length<=1)return;r.push(p("missing_card_analytics_source","Multi-dataset dashboard cards must include analytics intent with a source so the materializer can choose the correct dataset.",e.id));return}t.some(o=>E(o,n))||r.push(p("invalid_card_analytics_source","Dashboard cards with an explicit analytics source must use one of the selected datasets.",e.id))}function P(e){return e.map(t=>t==null?void 0:t.source).filter(t=>!!t)}function H(e){return Array.isArray(e)?e.filter(t=>!!(t&&typeof t=="object")):[]}function ie(e){return Array.isArray(e)?e.filter(t=>!!(t&&typeof t=="object")):[]}function Oe(e){var r;if(!e)return[];const t=[e.source];return e.kind==="metric"?t.push(...P([...H(e.metrics),e.primaryMetric,e.dateField,...H(e.dimensions),...ie(e.filters).map(n=>n.field)])):e.kind==="records"?t.push(...P([...H(e.fields),e.dateField,(r=e.orderBy)==null?void 0:r.field,...ie(e.filters).map(n=>n.field)])):e.kind==="inputOptions"?t.push(...P([e.field])):e.kind==="sql"&&t.push(...P(e.fields||[])),t}function pe({card:e,datasets:t,errors:r}){if(e.type!=="text"){for(const n of Oe(e.analyticsIntent))if(n&&!t.some(o=>E(o,n))){r.push(p("invalid_card_query_source","Dashboard card query field references must use one of the selected datasets.",e.id));return}}}function he({card:e,errors:t}){if(e.type==="text"||!e.analyticsIntent)return;const r=z.validateSemaphorAnalyticsIntent(e.analyticsIntent);if(!r.ok)for(const n of r.errors)t.push(p(n.code,n.path?`${n.path}: ${n.message}`:n.message,e.id))}function me({datasets:e,errors:t,requireAtLeastOne:r}){const n=ue({datasets:e,requireAtLeastOne:r});if(!n.ok){if(n.issue==="invalid_dataset_count"){t.push(p("invalid_dataset_count","Dashboard authoring requires at least one selected dataset."));return}t.push(p("invalid_multi_dataset_scope","Multi-dataset dashboard authoring is limited to semantic datasets from one domain."))}}function ge(e){var f,g;const t=[];if(!e||typeof e!="object")return{ok:!1,errors:[p("invalid_plan","Dashboard plan must be a structured object.")],warnings:[]};const r=e,n=[...r.warnings||[]];r.version!==1&&t.push(p("invalid_version","Dashboard plan version must be 1.")),(f=r.title)!=null&&f.trim()||t.push(p("missing_title","Dashboard plan needs a title."));const o=Array.isArray(r.datasets)?r.datasets:[],a=Array.isArray(r.sheets)?r.sheets:[];me({datasets:o,errors:t,requireAtLeastOne:!0}),a.length!==1&&t.push(p("invalid_sheet_count","MVP dashboard authoring creates exactly one dashboard sheet."));const i=a[0];i&&i.kind!=="dashboard"&&t.push(p("invalid_sheet_kind",'Generated sheet must use kind "dashboard".'));const d=(i==null?void 0:i.cards)||[];d.length>v.DASHBOARD_AUTHORING_MAX_GENERATED_CARDS&&t.push(p("too_many_cards",`Generated dashboards can contain at most ${v.DASHBOARD_AUTHORING_MAX_GENERATED_CARDS} cards.`));const s=B(d.map(l=>l.id));s&&t.push(p("duplicate_card_id",`Duplicate generated card id: ${s}.`));const u=B(d.map(l=>l.frameId));u&&t.push(p("duplicate_frame_id",`Duplicate generated frame id: ${u}.`));for(const l of d)(g=l.title)!=null&&g.trim()||t.push(p("missing_card_title","Card title is required.",l.id)),l.type==="custom"&&t.push(p("custom_visual_out_of_scope","Whole-dashboard authoring supports built-in visual types only.",l.id)),l.type!=="text"&&!l.analyticsIntent&&n.push(p("missing_analytics_intent","Non-text card has no analytics intent and may be skipped by the app layer.",l.id)),fe({card:l,datasets:o,errors:t}),he({card:l,errors:t}),pe({card:l,datasets:o,errors:t});const h=Array.isArray(r.filterInputs)?r.filterInputs:[],I=h.map(l=>l.id),A=B(I);A&&t.push(p("duplicate_input_id",`Duplicate dashboard input id: ${A}.`));const w=h.map(l=>l.variableName).filter(Boolean)||[],y=B(w);y&&t.push(p("duplicate_input_variable",`Duplicate dashboard input variable name: ${y}.`));const c=Array.isArray(r.calculatedFields)?r.calculatedFields:[];for(const l of c)l.scope==="domain"&&l.reuseOnly!==!0&&t.push(p("domain_calculated_field_create_out_of_scope",`Creating domain calculated field "${l.name}" is outside MVP.`));return{ok:t.length===0,errors:t,warnings:n}}function be(e){var i;const t=[];if(!e||typeof e!="object")return{ok:!1,errors:[p("invalid_change_plan","Dashboard change plan must be a structured object.")],warnings:[]};const r=e,n=[...r.warnings||[]];r.version!==1&&t.push(p("invalid_version","Dashboard change plan version must be 1.")),(i=r.dashboardId)!=null&&i.trim()||t.push(p("missing_dashboard_id","Dashboard change plan needs a dashboard id."));const o=Array.isArray(r.datasets)?r.datasets:[],a=Array.isArray(r.operations)?r.operations:[];me({datasets:o,errors:t,requireAtLeastOne:!1});for(const d of a){if(d.kind==="unsupported"){n.push(p("unsupported_operation",d.reason||d.requestedAction));continue}d.kind==="addCard"&&d.card.type==="custom"&&t.push(p("custom_visual_out_of_scope","Whole-dashboard authoring supports built-in visual types only.",d.card.id)),d.kind==="addCard"&&(fe({card:d.card,datasets:o,errors:t}),he({card:d.card,errors:t}),pe({card:d.card,datasets:o,errors:t})),d.kind==="addCalculatedField"&&d.field.scope==="domain"&&d.field.reuseOnly!==!0&&t.push(p("domain_calculated_field_create_out_of_scope",`Creating domain calculated field "${d.field.name}" is outside MVP.`))}return{ok:t.length===0,errors:t,warnings:n}}const Be={lg:48,md:36,sm:24,xs:12,xxs:6};function Pe(e,t){let r=0,n=0,o=0;return e.map(a=>{const i=Math.min(a.w,t);r>0&&r+i>t&&(r=0,n+=o,o=0);const d={i:a.frameId,x:r,y:n,w:i,h:a.h,minW:Math.min(a.minW,t),minH:a.minH,static:!1};return r+=i,o=Math.max(o,a.h),d})}function ze(e){const t=[...e].sort((s,u)=>s.priority-u.priority),r=t.filter(s=>s.role==="kpi"),n=t.filter(s=>s.role==="chart"),o=t.filter(s=>s.role==="table"),a=t.filter(s=>s.role==="text"),i=a.slice(0,1),d=a.slice(i.length);return{kpis:r,introText:i,charts:n,tables:o,supportingText:d}}function Ee(e,t,r){return t==="xxs"||t==="xs"?r:t==="sm"?Math.min(12,r):t==="md"?e<=1||e===2?18:12:e<=1||e===2?24:e===3?16:12}function qe(e,t,r,n){return r==="xxs"||r==="xs"||r==="sm"||r==="md"||t===1||t%2===1&&e===0?n:n/2}function Ve(e){const{item:t,band:r,index:n,bandCount:o,breakpoint:a,columns:i}=e;return r==="kpi"?{...t,band:r,w:Ee(o,a,i),h:15,minW:Math.min(6,i),minH:12}:r==="table"?{...t,band:r,w:i,h:a==="xxs"||a==="xs"?34:38,minW:Math.min(12,i),minH:18}:r==="introText"?{...t,band:r,w:i,h:a==="xxs"||a==="xs"?12:10,minW:Math.min(12,i),minH:8}:r==="supportingText"?{...t,band:r,w:a==="lg"?i/2:i,h:a==="xxs"||a==="xs"?12:10,minW:Math.min(12,i),minH:8}:{...t,band:r,w:qe(n,o,a,i),h:a==="xxs"||a==="xs"?28:30,minW:Math.min(12,i),minH:16}}function T(e,t,r,n){return e.map((o,a)=>Ve({item:o,band:t,index:a,bandCount:e.length,breakpoint:r,columns:n}))}function q(e){const t=ze(e);return Object.fromEntries(v.DASHBOARD_AUTHORING_BREAKPOINTS.map(r=>{const n=Be[r],o=[...T(t.introText,"introText",r,n),...T(t.kpis,"kpi",r,n),...T(t.charts,"chart",r,n),...T(t.tables,"table",r,n),...T(t.supportingText,"supportingText",r,n)];return[r,Pe(o,n)]}))}function He(e){const t=De.normalizeAnalyticsCatalogDataType(e);return t==="datetime"?"date":t==="unknown"?"string":t}function Le(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function je(e){return Le(e)&&typeof e.filterId=="string"&&typeof e.operation=="string"&&Array.isArray(e.values)}function Ge(e){return e.filter(t=>typeof t=="string"||typeof t=="number")}function We(e){return e.filter(t=>t instanceof Date||typeof t=="string")}function X(e,t){if(t===void 0)return;const r=He(e.dataType),n=e.operation||"in";if(je(t))return{...t,filterId:e.id,name:t.name||e.column,valueType:r,dataType:e.dataType,fieldMeta:e.fieldMeta,semanticContext:e.semanticContext};if(n==="is null"||n==="is not null")return{filterId:e.id,name:e.column,operation:n,valueType:r,values:[],dataType:e.dataType,fieldMeta:e.fieldMeta,semanticContext:e.semanticContext};const o=Array.isArray(t)?t:[t],a=r==="date"?We(o):Ge(o);if(a.length!==0&&!((n==="between"||n==="not between")&&a.length<2))return{filterId:e.id,name:e.column,operation:n,valueType:r,values:a,dataType:e.dataType,fieldMeta:e.fieldMeta,semanticContext:e.semanticContext}}function Ie(e,t,r){return r?{code:e,message:t,cardId:r}:{code:e,message:t}}function Ue(e,t,r){const n=(t||[]).filter(o=>o.scope==="card"&&o.targetCardId===r).map(o=>o.field).filter(Boolean);return n.length===0?e:{...e,calculatedFields:[...e.calculatedFields||[],...n]}}function U(e,t){return Array.from(new Set((e||[]).map(r=>t.get(r)).filter(r=>!!r)))}function Ke(e,t){if((e==null?void 0:e.kind)!=="cards")return e;const r=U(e.cardIds,t);return r.length>0?{...e,cardIds:r}:null}function Xe(e,t){return!e.applyToCardIds&&!e.excludeCardIds?e:{...e,...e.applyToCardIds?{applyToCardIds:U(e.applyToCardIds,t)}:{},...e.excludeCardIds?{excludeCardIds:U(e.excludeCardIds,t)}:{}}}function Je(e,t){const r={},n=[];return{inputs:(e.filterInputs||[]).flatMap((a,i)=>{const d=Ke(a.scope,t);if(d===null)return n.push(Ie("filter_input_scope_empty",`Filter input "${a.label}" was skipped because all scoped cards were skipped during query validation.`)),[];const s=X(a.filter,a.defaultValue);return s&&(r.shared??(r.shared={}),r.shared[a.id]={status:"set",value:{kind:"filter",filterValue:s}}),[{id:a.id,kind:"filter",label:a.label,variableName:a.variableName,scope:d||{kind:"allSheets",sheetKinds:["dashboard"]},runtimeScope:"shared",presentation:{placement:"toolbar",order:i},exports:["label","value","start","end","range"],filter:Xe(a.filter,t)}]}),warnings:n,defaultInputValues:r.shared&&Object.keys(r.shared).length>0?r:void 0}}function Qe(e){var w,y;const t=ge(e.plan);if(!t.ok)throw new Error(t.errors.map(c=>c.message).join(`
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const v=require("../chunks/contracts-CtB2VONT.js"),N=require("../chunks/source-identity-C-xaeE_I.js"),z=require("../chunks/validators-jpoYhpHh.js"),De=require("../chunks/catalog-field-grounding-8L9I0zdg.js");function _(e){return e&&typeof e=="object"?e:null}function D(e){return typeof e=="string"?e:null}function oe(e){var t,r,n;return!!(e&&typeof e=="object")&&(((t=_(e))==null?void 0:t.kind)==="semantic"||((r=_(e))==null?void 0:r.kind)==="physical"||((n=_(e))==null?void 0:n.kind)==="sql")}function M(e){return oe(e)?e.kind==="semantic"?!!(e.domainId&&e.datasetName):e.kind==="physical"?!!(e.connectionId&&e.tableName):!1:!1}function ve(e){return N.semaphorSourceIdentityKey(e)}function K(e,t){return N.semaphorSourcesReferToSameDataset(e,t)}function se(e,t){return N.preferSemaphorSourceMetadata(e,t)}function R(e){const t=[];for(const r of e){const n=t.findIndex(o=>K(o,r));n===-1?t.push(r):t[n]=se(t[n],r)}return t}function Ce(e){return R(e)[0]}function G(e,t){return e.kind!=="semantic"||e.connectionId||(t==null?void 0:t.kind)!=="semantic"||!N.semaphorSourcesReferToSameDataset(e,t)||!t.connectionId?e:{...e,connectionId:t.connectionId}}function W(e){return M(e)?e:void 0}function ae(e,t){if(!(e.kind!=="semantic"||e.connectionId))return t.find(r=>(r==null?void 0:r.kind)==="semantic"&&N.semaphorSourcesReferToSameDataset(e,r)&&!!r.connectionId)}function S(e,t){const r=W(e==null?void 0:e.source);return r?G(r,t):void 0}function de({explicitSource:e,field:t,defaultSource:r,fallbackSources:n}){const o=[r,...n||[]],a=W(e),i=a?G(a,ae(a,o)):void 0;if(i)return i;if(e!==void 0)return;const d=S(t,r),s=d?G(d,ae(d,o)):void 0;if(s)return s;if((t==null?void 0:t.source)===void 0)return W(r)}function ke(e,t){if(!(e!=null&&e.name)||!(t!=null&&t.name)||e.name!==t.name)return!1;const r=S(e),n=S(t);return!r||!n?!0:K(r,n)}function C(e){var t;return D((t=_(e))==null?void 0:t.kind)}function ce(e){var t,r;return C(e)!=="semantic"?null:((r=D((t=_(e))==null?void 0:t.domainId))==null?void 0:r.trim())||null}function xe(e){var t;return C(e)!=="semantic"?null:D((t=_(e))==null?void 0:t.datasetName)}function Te(e){var t;return C(e)!=="semantic"?null:D((t=_(e))==null?void 0:t.datasetId)}function Fe(e){var t;return C(e)!=="physical"?null:D((t=_(e))==null?void 0:t.connectionId)}function Re(e){var t;return C(e)!=="physical"?null:D((t=_(e))==null?void 0:t.tableName)}function Ne(e){var t;return C(e)!=="physical"?"":D((t=_(e))==null?void 0:t.databaseName)||""}function Me(e){var t;return C(e)!=="physical"?"":D((t=_(e))==null?void 0:t.schemaName)||""}function le(e){if(e.analyticsIntent&&typeof e.analyticsIntent=="object"&&"source"in e.analyticsIntent)return e.analyticsIntent.source}function ue({datasets:e,requireAtLeastOne:t}){if(t&&e.length<1)return{ok:!1,issue:"invalid_dataset_count"};if(e.length<=1)return{ok:!0};const r=e.map(ce),n=new Set(r.filter(Boolean));return r.some(o=>!o)||n.size!==1?{ok:!1,issue:"invalid_multi_dataset_scope"}:{ok:!0}}function E(e,t){if(!t)return!1;if(t.kind==="semantic"){const r=Te(e);return ce(e)===t.domainId?r&&t.datasetId?r===t.datasetId:xe(e)===t.datasetName:!1}return t.kind==="physical"?Fe(e)===t.connectionId&&Re(e)===t.tableName&&Ne(e)===(t.databaseName||"")&&Me(e)===(t.schemaName||""):!1}function $e(e,t){return e.find(r=>E(r,t))}function p(e,t,r){return r?{code:e,message:t,cardId:r}:{code:e,message:t}}function B(e){const t=new Set;for(const r of e){if(t.has(r))return r;t.add(r)}return null}function fe({card:e,datasets:t,errors:r}){if(e.type==="text")return;const n=le(e);if(!n){if(t.length<=1)return;r.push(p("missing_card_analytics_source","Multi-dataset dashboard cards must include analytics intent with a source so the materializer can choose the correct dataset.",e.id));return}t.some(o=>E(o,n))||r.push(p("invalid_card_analytics_source","Dashboard cards with an explicit analytics source must use one of the selected datasets.",e.id))}function P(e){return e.map(t=>t==null?void 0:t.source).filter(t=>!!t)}function H(e){return Array.isArray(e)?e.filter(t=>!!(t&&typeof t=="object")):[]}function ie(e){return Array.isArray(e)?e.filter(t=>!!(t&&typeof t=="object")):[]}function Oe(e){var r;if(!e)return[];const t=[e.source];return e.kind==="metric"?t.push(...P([...H(e.metrics),e.primaryMetric,e.dateField,...H(e.dimensions),...ie(e.filters).map(n=>n.field)])):e.kind==="records"?t.push(...P([...H(e.fields),e.dateField,(r=e.orderBy)==null?void 0:r.field,...ie(e.filters).map(n=>n.field)])):e.kind==="inputOptions"?t.push(...P([e.field])):e.kind==="sql"&&t.push(...P(e.fields||[])),t}function pe({card:e,datasets:t,errors:r}){if(e.type!=="text"){for(const n of Oe(e.analyticsIntent))if(n&&!t.some(o=>E(o,n))){r.push(p("invalid_card_query_source","Dashboard card query field references must use one of the selected datasets.",e.id));return}}}function he({card:e,errors:t}){if(e.type==="text"||!e.analyticsIntent)return;const r=z.validateSemaphorAnalyticsIntent(e.analyticsIntent);if(!r.ok)for(const n of r.errors)t.push(p(n.code,n.path?`${n.path}: ${n.message}`:n.message,e.id))}function me({datasets:e,errors:t,requireAtLeastOne:r}){const n=ue({datasets:e,requireAtLeastOne:r});if(!n.ok){if(n.issue==="invalid_dataset_count"){t.push(p("invalid_dataset_count","Dashboard authoring requires at least one selected dataset."));return}t.push(p("invalid_multi_dataset_scope","Multi-dataset dashboard authoring is limited to semantic datasets from one domain."))}}function ge(e){var f,g;const t=[];if(!e||typeof e!="object")return{ok:!1,errors:[p("invalid_plan","Dashboard plan must be a structured object.")],warnings:[]};const r=e,n=[...r.warnings||[]];r.version!==1&&t.push(p("invalid_version","Dashboard plan version must be 1.")),(f=r.title)!=null&&f.trim()||t.push(p("missing_title","Dashboard plan needs a title."));const o=Array.isArray(r.datasets)?r.datasets:[],a=Array.isArray(r.sheets)?r.sheets:[];me({datasets:o,errors:t,requireAtLeastOne:!0}),a.length!==1&&t.push(p("invalid_sheet_count","MVP dashboard authoring creates exactly one dashboard sheet."));const i=a[0];i&&i.kind!=="dashboard"&&t.push(p("invalid_sheet_kind",'Generated sheet must use kind "dashboard".'));const d=(i==null?void 0:i.cards)||[];d.length>v.DASHBOARD_AUTHORING_MAX_GENERATED_CARDS&&t.push(p("too_many_cards",`Generated dashboards can contain at most ${v.DASHBOARD_AUTHORING_MAX_GENERATED_CARDS} cards.`));const s=B(d.map(l=>l.id));s&&t.push(p("duplicate_card_id",`Duplicate generated card id: ${s}.`));const u=B(d.map(l=>l.frameId));u&&t.push(p("duplicate_frame_id",`Duplicate generated frame id: ${u}.`));for(const l of d)(g=l.title)!=null&&g.trim()||t.push(p("missing_card_title","Card title is required.",l.id)),l.type==="custom"&&t.push(p("custom_visual_out_of_scope","Whole-dashboard authoring supports built-in visual types only.",l.id)),l.type!=="text"&&!l.analyticsIntent&&n.push(p("missing_analytics_intent","Non-text card has no analytics intent and may be skipped by the app layer.",l.id)),fe({card:l,datasets:o,errors:t}),he({card:l,errors:t}),pe({card:l,datasets:o,errors:t});const h=Array.isArray(r.filterInputs)?r.filterInputs:[],I=h.map(l=>l.id),A=B(I);A&&t.push(p("duplicate_input_id",`Duplicate dashboard input id: ${A}.`));const w=h.map(l=>l.variableName).filter(Boolean)||[],y=B(w);y&&t.push(p("duplicate_input_variable",`Duplicate dashboard input variable name: ${y}.`));const c=Array.isArray(r.calculatedFields)?r.calculatedFields:[];for(const l of c)l.scope==="domain"&&l.reuseOnly!==!0&&t.push(p("domain_calculated_field_create_out_of_scope",`Creating domain calculated field "${l.name}" is outside MVP.`));return{ok:t.length===0,errors:t,warnings:n}}function be(e){var i;const t=[];if(!e||typeof e!="object")return{ok:!1,errors:[p("invalid_change_plan","Dashboard change plan must be a structured object.")],warnings:[]};const r=e,n=[...r.warnings||[]];r.version!==1&&t.push(p("invalid_version","Dashboard change plan version must be 1.")),(i=r.dashboardId)!=null&&i.trim()||t.push(p("missing_dashboard_id","Dashboard change plan needs a dashboard id."));const o=Array.isArray(r.datasets)?r.datasets:[],a=Array.isArray(r.operations)?r.operations:[];me({datasets:o,errors:t,requireAtLeastOne:!1});for(const d of a){if(d.kind==="unsupported"){n.push(p("unsupported_operation",d.reason||d.requestedAction));continue}d.kind==="addCard"&&d.card.type==="custom"&&t.push(p("custom_visual_out_of_scope","Whole-dashboard authoring supports built-in visual types only.",d.card.id)),d.kind==="addCard"&&(fe({card:d.card,datasets:o,errors:t}),he({card:d.card,errors:t}),pe({card:d.card,datasets:o,errors:t})),d.kind==="addCalculatedField"&&d.field.scope==="domain"&&d.field.reuseOnly!==!0&&t.push(p("domain_calculated_field_create_out_of_scope",`Creating domain calculated field "${d.field.name}" is outside MVP.`))}return{ok:t.length===0,errors:t,warnings:n}}const Be={lg:48,md:36,sm:24,xs:12,xxs:6};function Pe(e,t){let r=0,n=0,o=0;return e.map(a=>{const i=Math.min(a.w,t);r>0&&r+i>t&&(r=0,n+=o,o=0);const d={i:a.frameId,x:r,y:n,w:i,h:a.h,minW:Math.min(a.minW,t),minH:a.minH,static:!1};return r+=i,o=Math.max(o,a.h),d})}function ze(e){const t=[...e].sort((s,u)=>s.priority-u.priority),r=t.filter(s=>s.role==="kpi"),n=t.filter(s=>s.role==="chart"),o=t.filter(s=>s.role==="table"),a=t.filter(s=>s.role==="text"),i=a.slice(0,1),d=a.slice(i.length);return{kpis:r,introText:i,charts:n,tables:o,supportingText:d}}function Ee(e,t,r){return t==="xxs"||t==="xs"?r:t==="sm"?Math.min(12,r):t==="md"?e<=1||e===2?18:12:e<=1||e===2?24:e===3?16:12}function qe(e,t,r,n){return r==="xxs"||r==="xs"||r==="sm"||r==="md"||t===1||t%2===1&&e===0?n:n/2}function Ve(e){const{item:t,band:r,index:n,bandCount:o,breakpoint:a,columns:i}=e;return r==="kpi"?{...t,band:r,w:Ee(o,a,i),h:15,minW:Math.min(6,i),minH:12}:r==="table"?{...t,band:r,w:i,h:a==="xxs"||a==="xs"?34:38,minW:Math.min(12,i),minH:18}:r==="introText"?{...t,band:r,w:i,h:a==="xxs"||a==="xs"?12:10,minW:Math.min(12,i),minH:8}:r==="supportingText"?{...t,band:r,w:a==="lg"?i/2:i,h:a==="xxs"||a==="xs"?12:10,minW:Math.min(12,i),minH:8}:{...t,band:r,w:qe(n,o,a,i),h:a==="xxs"||a==="xs"?28:30,minW:Math.min(12,i),minH:16}}function T(e,t,r,n){return e.map((o,a)=>Ve({item:o,band:t,index:a,bandCount:e.length,breakpoint:r,columns:n}))}function q(e){const t=ze(e);return Object.fromEntries(v.DASHBOARD_AUTHORING_BREAKPOINTS.map(r=>{const n=Be[r],o=[...T(t.introText,"introText",r,n),...T(t.kpis,"kpi",r,n),...T(t.charts,"chart",r,n),...T(t.tables,"table",r,n),...T(t.supportingText,"supportingText",r,n)];return[r,Pe(o,n)]}))}function He(e){const t=De.normalizeAnalyticsCatalogDataType(e);return t==="datetime"?"date":t==="unknown"?"string":t}function Le(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function je(e){return Le(e)&&typeof e.filterId=="string"&&typeof e.operation=="string"&&Array.isArray(e.values)}function Ge(e){return e.filter(t=>typeof t=="string"||typeof t=="number")}function We(e){return e.filter(t=>t instanceof Date||typeof t=="string")}function X(e,t){if(t===void 0)return;const r=He(e.dataType),n=e.operation||"in";if(je(t))return{...t,filterId:e.id,name:t.name||e.column,valueType:r,dataType:e.dataType,fieldMeta:e.fieldMeta,semanticContext:e.semanticContext};if(n==="is null"||n==="is not null")return{filterId:e.id,name:e.column,operation:n,valueType:r,values:[],dataType:e.dataType,fieldMeta:e.fieldMeta,semanticContext:e.semanticContext};const o=Array.isArray(t)?t:[t],a=r==="date"?We(o):Ge(o);if(a.length!==0&&!((n==="between"||n==="not between")&&a.length<2))return{filterId:e.id,name:e.column,operation:n,valueType:r,values:a,dataType:e.dataType,fieldMeta:e.fieldMeta,semanticContext:e.semanticContext}}function Ie(e,t,r){return r?{code:e,message:t,cardId:r}:{code:e,message:t}}function Ue(e,t,r){const n=(t||[]).filter(o=>o.scope==="card"&&o.targetCardId===r).map(o=>o.field).filter(Boolean);return n.length===0?e:{...e,calculatedFields:[...e.calculatedFields||[],...n]}}function U(e,t){return Array.from(new Set((e||[]).map(r=>t.get(r)).filter(r=>!!r)))}function Ke(e,t){if((e==null?void 0:e.kind)!=="cards")return e;const r=U(e.cardIds,t);return r.length>0?{...e,cardIds:r}:null}function Xe(e,t){return!e.applyToCardIds&&!e.excludeCardIds?e:{...e,...e.applyToCardIds?{applyToCardIds:U(e.applyToCardIds,t)}:{},...e.excludeCardIds?{excludeCardIds:U(e.excludeCardIds,t)}:{}}}function Je(e,t){const r={},n=[];return{inputs:(e.filterInputs||[]).flatMap((a,i)=>{const d=Ke(a.scope,t);if(d===null)return n.push(Ie("filter_input_scope_empty",`Filter input "${a.label}" was skipped because all scoped cards were skipped during query validation.`)),[];const s=X(a.filter,a.defaultValue);return s&&(r.shared??(r.shared={}),r.shared[a.id]={status:"set",value:{kind:"filter",filterValue:s}}),[{id:a.id,kind:"filter",label:a.label,variableName:a.variableName,scope:d||{kind:"allSheets",sheetKinds:["dashboard"]},runtimeScope:"shared",presentation:{placement:"toolbar",order:i},exports:["label","value","start","end","range"],filter:Xe(a.filter,t)}]}),warnings:n,defaultInputValues:r.shared&&Object.keys(r.shared).length>0?r:void 0}}function Qe(e){var w,y;const t=ge(e.plan);if(!t.ok)throw new Error(t.errors.map(c=>c.message).join(`
|
|
2
2
|
`)||"Dashboard plan is invalid.");const r=e.plan.sheets[0],n=[...t.warnings],o=[],a=new Map(e.cardArtifacts.map(c=>[c.planCardId,c])),i=new Map(e.cardArtifacts.map(c=>[c.planCardId,c.card.id])),d=[];for(const c of r.cards){const f=a.get(c.id);if(!f){const l=Ie("missing_card_artifact",`Card "${c.title}" was skipped because no generated artifact was supplied.`,c.id);o.push(l);continue}n.push(...f.warnings||[]);const g=Ue(f.card,e.plan.calculatedFields,c.id);d.push({id:c.frameId,cards:[g],activeCardId:g.id})}if(d.length===0)throw new Error("Dashboard plan did not produce any persistable cards.");const{inputs:s,defaultInputValues:u,warnings:h}=Je(e.plan,i);n.push(...h);const I=q(r.cards.filter(c=>d.some(f=>f.id===c.frameId)).map(c=>({frameId:c.frameId,priority:c.priority,role:c.role})));return{dashboard:{id:e.dashboardId,title:e.plan.title,description:e.plan.description||"",sheets:[{id:r.id,kind:"dashboard",title:r.title,description:r.description,frames:d,layouts:I,calculatedFields:(w=e.plan.calculatedFields)==null?void 0:w.filter(c=>c.scope==="sheet"&&c.field).map(c=>c.field)}],calculatedFields:(y=e.plan.calculatedFields)==null?void 0:y.filter(c=>c.scope==="dashboard"&&c.field).map(c=>c.field),inputs:s,...u?{defaultInputValues:u}:{}},warnings:n,skippedOperations:o}}function k(e,t,r){return r?{code:e,message:t,cardId:r}:{code:e,message:t}}function Ye(e){return JSON.parse(JSON.stringify(e))}function Ze(e){var t;return(t=e.sheets)==null?void 0:t.find(r=>(r.kind||"dashboard")==="dashboard")}function L(e,t){var r;for(const n of e.sheets||[])for(const o of n.frames||[]){const a=(r=o.cards)==null?void 0:r.find(i=>i.id===t);if(a)return{sheet:n,frame:o,card:a}}return null}function ye(e){var r,n;const t=(n=(r=e.cards)==null?void 0:r[0])==null?void 0:n.type;return t==="kpi"?"kpi":t==="table"||t==="detailTable"||t==="pivotTable"?"table":t==="text"?"text":"chart"}function et(e){var t;return new Map((((t=e.layouts)==null?void 0:t.lg)||[]).map((r,n)=>[r.i,n]))}function _e(e,t=new Map){const r=et(e),n=Math.max(r.size,t.size),o=(e.frames||[]).map((a,i)=>({frameId:a.id,role:ye(a),priority:t.get(a.id)??r.get(a.id)??n+i}));e.layouts=q(o)}function tt(e){return Object.values(e.layouts||{}).some(t=>t.length>0)}function rt(e,t){if(!tt(e)){_e(e);return}const r=q([{frameId:t.id,role:ye(t),priority:0}]);e.layouts??(e.layouts={});for(const[n,o]of Object.entries(r)){const a=e.layouts[n]||[];if(a.some(s=>s.i===t.id))continue;const i=o[0];if(!i)continue;const d=a.reduce((s,u)=>Math.max(s,u.y+u.h),0);e.layouts[n]=[...a,{...i,y:d}]}}function nt(e,t){var n;const r=X(t.filter,t.defaultValue);r&&(e.defaultInputValues??(e.defaultInputValues={}),(n=e.defaultInputValues).shared??(n.shared={}),e.defaultInputValues.shared[t.id]={status:"set",value:{kind:"filter",filterValue:r}})}function at(e){var d;const t=be(e.changePlan);if(!t.ok)throw new Error(t.errors.map(s=>s.message).join(`
|
|
3
3
|
`)||"Dashboard change plan is invalid.");const r=Ye(e.dashboard),n=[...t.warnings],o=[],a=new Map(e.cardArtifacts.map(s=>[s.planCardId,s])),i=Ze(r);if(!i)throw new Error("Dashboard has no editable dashboard sheet.");i.frames??(i.frames=[]);for(const s of e.changePlan.operations)switch(s.kind){case"addCard":{if((i.frames||[]).reduce((A,w)=>{var y;return A+(((y=w.cards)==null?void 0:y.length)||0)},0)>=v.DASHBOARD_AUTHORING_MAX_GENERATED_CARDS){o.push(k("generated_card_limit_reached",`AI refinement is capped at ${v.DASHBOARD_AUTHORING_MAX_GENERATED_CARDS} cards.`,s.card.id));break}const h=a.get(s.card.id);if(!h){o.push(k("missing_card_artifact",`Card "${s.card.title}" was skipped because no generated artifact was supplied.`,s.card.id));break}const I={id:s.card.frameId,cards:[h.card],activeCardId:h.card.id};i.frames.push(I),rt(i,I);break}case"addFilterInput":{r.inputs??(r.inputs=[]);const u={id:s.input.id,kind:"filter",label:s.input.label,variableName:s.input.variableName,scope:s.input.scope||{kind:"allSheets",sheetKinds:["dashboard"]},runtimeScope:"shared",presentation:{placement:"toolbar",order:r.inputs.length},exports:["label","value","start","end","range"],filter:s.input.filter};r.inputs.push(u),nt(r,s.input);break}case"addCalculatedField":{if(s.field.scope==="dashboard"&&s.field.field)r.calculatedFields??(r.calculatedFields=[]),r.calculatedFields.push(s.field.field);else if(s.field.scope==="sheet"&&s.field.field)i.calculatedFields??(i.calculatedFields=[]),i.calculatedFields.push(s.field.field);else if(s.field.scope==="card"&&s.field.field){const u=s.field.targetCardId?L(r,s.field.targetCardId):null;u?((d=u.card).calculatedFields??(d.calculatedFields=[]),u.card.calculatedFields.push(s.field.field)):o.push(k("missing_calculated_field_target",`Calculated field "${s.field.name}" needs a valid target card.`))}break}case"renameCard":{const u=L(r,s.cardId);if(!u){o.push(k("card_not_found",`Card "${s.cardId}" could not be renamed because it was not found.`,s.cardId));break}u.card.title=s.title,s.description!==void 0&&(u.card.description=s.description);break}case"reorderCards":{const u=new Map;for(let h=0;h<s.cardIds.length;h+=1){const I=s.cardIds[h],A=L(r,I);A&&u.set(A.frame.id,h)}_e(i,u);break}case"reuseCalculatedField":n.push(k("reused_calculated_field",`Calculated field "${s.fieldId}" is reused by reference.`));break;case"unsupported":o.push(k("unsupported_operation",s.reason||s.requestedAction));break}return{dashboard:r,warnings:n,skippedOperations:o}}function b(e,t,r){return r?{code:e,message:t,cardId:r}:{code:e,message:t}}function F(e,t){return e.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||t}function Se(e,t){if(!t.has(e))return t.add(e),e;let r=2,n=`${e}-${r}`;for(;t.has(n);)r+=1,n=`${e}-${r}`;return t.add(n),n}function $(e){return!!(e&&typeof e=="object")}function Ae(e){return Array.isArray(e.inputs)?e.inputs.filter(t=>$(t)&&typeof t.id=="string"):[]}function J(e){return Array.isArray(e.sections)?e.sections.filter(t=>$(t)):[]}function Q(e){return Array.isArray(e.views)?e.views.filter(t=>$(t)):[]}function x(e){if(!Array.isArray(e))return[];const t=[];for(const r of e){const n=S(r);n&&t.push(n)}return t}function it(e){var n,o;if(!e)return[];const t=[];if(M(e.source)&&t.push(e.source),e.kind==="metric"){t.push(...x(e.metrics));const a=S(e.dateField);a&&t.push(a),t.push(...x(e.dimensions)),t.push(...x((n=e.filters)==null?void 0:n.map(i=>i.field)))}else if(e.kind==="records"){const a=S(e.dateField);a&&t.push(a),t.push(...x(e.fields)),t.push(...x((o=e.filters)==null?void 0:o.map(i=>i.field)))}else if(e.kind==="inputOptions"){const a=S(e.field);a&&t.push(a)}else e.kind==="sql"&&t.push(...x(e.fields));const r="inputs"in e&&Array.isArray(e.inputs)?e.inputs:[];for(const a of r){const i=S(a.field);i&&t.push(i)}return t}function ot(e){const t=[];for(const r of Ae(e)){const n=S(r.field);n&&t.push(n)}for(const r of J(e))for(const n of Q(r))t.push(...it(n.analytics));return t}function st(e){var r;const t=[];for(const n of J(e))for(const o of Q(n))M((r=o.analytics)==null?void 0:r.source)&&t.push(o.analytics.source);return t}function dt(e,t){const r=R(e).filter(M);if(r.length===0)return t.push(b("missing_materializable_dataset","No semantic or physical source could be converted into the current dashboard authoring dataset reference.")),[];const n=r.every(a=>a.kind==="semantic"),o=Array.from(new Set(r.filter(a=>a.kind==="semantic").map(a=>a.domainId)));return r.length>1&&(!n||o.length!==1)?(t.push(b("multiple_datasets_out_of_scope","The dashboard authoring compiler supports multiple datasets only within one semantic domain; using the first source and deferring the rest.")),[r[0]]):r}function ct(e,t){const r=J(e),n=Ae(e),o=R(ot(e)),a=R(st(e));return{sections:r,inputs:n,sources:o,primarySources:a,defaultSource:a.length===1?a[0]:void 0,datasets:dt(o,t)}}function lt(e){return e&&z.validateSemaphorAnalyticsIntent(e).ok?e:void 0}function ut(e){var t;switch((t=e.presentation)==null?void 0:t.kind){case"kpi":return"kpi";case"lineChart":return"line";case"barChart":return"bar";case"areaChart":return"area";case"table":return"table";case"text":return"text";default:return null}}function ft(e){var t,r,n;return((t=e.presentation)==null?void 0:t.kind)==="kpi"?"kpi":((r=e.presentation)==null?void 0:r.kind)==="table"?"table":((n=e.presentation)==null?void 0:n.kind)==="text"?"text":"chart"}function pt(e){const t=z.normalizeSemaphorInputOperator(e);switch(t){case"not_in":return"not in";case"not_between":return"not between";case"contains":return"like";case"not_contains":return"not like";default:return t||"in"}}function ht(e){return $(e.field)?e.field.dataType==="datetime"?"date":e.field.dataType||"string":"string"}function mt(e){if(!(!e||e.kind!=="physical"))return[e.databaseName,e.schemaName,e.tableName].filter(Boolean).join(".")}function gt(e,t,r,n,o,a){if(e.kind!=="filter")return a.push(b("control_inputs_deferred",`Control input "${e.label}" is represented in the protocol but not yet materialized by the dashboard authoring adapter.`)),null;if(!$(e.field)||typeof e.field.name!="string")return a.push(b("filter_requires_field",`Filter "${e.label||e.id}" needs a field before the dashboard compiler can materialize it.`)),null;const i=de({explicitSource:void 0,field:e.field,defaultSource:t,fallbackSources:r}),d=(i==null?void 0:i.kind)==="semantic"||(i==null?void 0:i.kind)==="physical"?i.connectionId:void 0;if(!d)return a.push(b("filter_requires_connection_id",`Filter "${e.label}" needs a source connectionId before the dashboard compiler can materialize it.`)),null;const h={id:`filter-${Se(F(e.id,e.field.name),o)}`,variableName:e.id,connectionId:d,title:e.label,column:e.field.name,dataType:ht(e),qualifiedTableName:mt(i),sql:"",operation:pt(e.operator),type:e.multi===!1?"single":"multiple",location:"dashboard",displayMode:"toolbar",fieldMeta:(i==null?void 0:i.kind)==="semantic"?{name:e.field.name,qualifiedFieldName:e.field.name,dataType:e.field.dataType,role:e.field.role==="measure"?"metric":"groupby"}:void 0,semanticContext:(i==null?void 0:i.kind)==="semantic"?{semanticDomainId:i.domainId,connectionId:i.connectionId}:void 0};return{id:e.id,label:e.label,variableName:e.id,scope:n,filter:h,defaultValue:X(h,e.defaultValue)}}function j(e){const t=[],r=[];for(const n of e.viewIds){const o=e.viewIdToCardId.get(n);o?t.push(o):r.push(n)}return r.length>0&&e.warnings.push(b("input_scope_view_not_found",`Filter "${e.inputLabel}" referenced unknown view ids: ${r.join(", ")}.`)),Array.from(new Set(t))}function bt(e){var n,o;if(!e.protocolScope){const a=Array.from(new Set(e.boundCardIds));return a.length>0&&a.length<e.allCardIds.length?{kind:"cards",cardIds:a}:void 0}if(e.protocolScope.level==="dashboard"){if(!((n=e.protocolScope.excludeViewIds)!=null&&n.length))return;const a=new Set(j({inputLabel:e.inputLabel,viewIds:e.protocolScope.excludeViewIds,viewIdToCardId:e.viewIdToCardId,warnings:e.warnings}));return{kind:"cards",cardIds:e.allCardIds.filter(i=>!a.has(i))}}if(e.protocolScope.level==="view"){const a=j({inputLabel:e.inputLabel,viewIds:e.protocolScope.viewIds,viewIdToCardId:e.viewIdToCardId,warnings:e.warnings});return a.length===0?(e.warnings.push(b("input_scope_has_no_materialized_cards",`Filter "${e.inputLabel}" was deferred because its view scope does not match any materialized cards.`)),null):{kind:"cards",cardIds:a}}const t=e.sectionIdToCardIds.get(e.protocolScope.sectionId)||[];if(t.length===0)return e.warnings.push(b("input_scope_section_not_found",`Filter "${e.inputLabel}" was deferred because section "${e.protocolScope.sectionId}" does not match any materialized cards.`)),null;if(!((o=e.protocolScope.excludeViewIds)!=null&&o.length))return{kind:"cards",cardIds:t};const r=new Set(j({inputLabel:e.inputLabel,viewIds:e.protocolScope.excludeViewIds,viewIdToCardId:e.viewIdToCardId,warnings:e.warnings}));return{kind:"cards",cardIds:t.filter(a=>!r.has(a))}}function It(e){var w,y,c;const t=[],r=z.validateSemaphorDashboardIntent(e);for(const f of r.warnings)t.push(b(f.code,f.message));for(const f of r.errors)t.push(b(f.code,f.message));const n=ct(e,t),o=[],a=new Map,i=new Map,d=new Map,s=new Set,u=new Set;let h=0;for(const[f,g]of n.sections.entries()){const l=typeof g.title=="string"?g.title:`Section ${f+1}`,Y=g.id||F(l,`section-${f+1}`);i.set(Y,[]);for(const[Z,m]of Q(g).entries()){const ee=ut(m),V=F(m.id||`${l}-${m.title||`View ${Z+1}`}`,`card-${f+1}-${Z+1}`);if(!ee){t.push(b("unsupported_presentation",`Dashboard presentation "${((w=m.presentation)==null?void 0:w.kind)||"unknown"}" is not supported by the dashboard authoring adapter.`,`card-${V}`));continue}if(((y=m.analytics)==null?void 0:y.kind)==="sql"){t.push(b("sql_intent_deferred","SQL analytics intent is valid protocol, but the current dashboard authoring adapter only materializes semantic and physical config-card intents.",`card-${V}`));continue}const te=Se(V,s),O=`card-${te}`;m.id&&a.set(m.id,O),(c=i.get(Y))==null||c.push(O);const we=m.analytics&&"inputs"in m.analytics?m.analytics.inputs:void 0;for(const re of we||[]){const ne=d.get(re.inputId)||[];ne.push(O),d.set(re.inputId,ne)}o.push({id:O,frameId:`frame-${te}`,title:m.title,description:m.description,type:ee,role:ft(m),priority:h,section:l,analyticsIntent:lt(m.analytics),text:m.text}),h+=1}}const I=n.inputs.map(f=>{const g=bt({protocolScope:f.scope,inputLabel:f.label,allCardIds:o.map(l=>l.id),boundCardIds:d.get(f.id)||[],viewIdToCardId:a,sectionIdToCardIds:i,warnings:t});return g===null?null:gt(f,n.defaultSource,n.sources,g,u,t)}).filter(f=>!!f);return{plan:{version:1,id:`plan-${F(e.title,"dashboard")}`,title:e.title,description:e.description,datasets:n.datasets,sheets:[{id:`sheet-${F(e.title,"dashboard")}`,title:e.title,description:e.description,kind:"dashboard",cards:o}],filterInputs:I.length?I:void 0,warnings:t.length?t:void 0,unresolvedRequests:r.ok?void 0:r.errors.map(f=>f.message)},warnings:t}}exports.DASHBOARD_AUTHORING_BREAKPOINTS=v.DASHBOARD_AUTHORING_BREAKPOINTS;exports.DASHBOARD_AUTHORING_MAX_GENERATED_CARDS=v.DASHBOARD_AUTHORING_MAX_GENERATED_CARDS;exports.applyDashboardChangePlan=at;exports.compileDashboardFromPlan=Qe;exports.compileResponsiveDashboardLayouts=q;exports.dashboardAuthoringDatasetMatchesSource=E;exports.dashboardAuthoringFieldsReferToSameTarget=ke;exports.dashboardAuthoringSourceFromField=S;exports.dashboardAuthoringSourceKey=ve;exports.dashboardAuthoringSourcesReferToSameDataset=K;exports.dashboardPlanFromSemaphorDashboardIntent=It;exports.findDashboardAuthoringDatasetForSource=$e;exports.getDashboardAuthoringCardSource=le;exports.isMaterializableDashboardAuthoringSource=M;exports.isSemaphorSourceRef=oe;exports.mergeDashboardAuthoringSources=R;exports.preferDashboardAuthoringSourceMetadata=se;exports.preferredDashboardAuthoringSource=Ce;exports.resolveDashboardAuthoringSource=de;exports.validateDashboardAuthoringDatasetScope=ue;exports.validateDashboardChangePlan=be;exports.validateDashboardPlan=ge;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { D as B, a as be } from "../chunks/contracts-CoCOpd_i.js";
|
|
2
2
|
import { s as Ie, a as E, p as ye } from "../chunks/source-identity-Dj3dryN9.js";
|
|
3
3
|
import { c as ae, f as _e, n as we } from "../chunks/validators-CtNmgsvG.js";
|
|
4
|
-
import {
|
|
4
|
+
import { c as ve } from "../chunks/catalog-field-grounding-BK4BX8sZ.js";
|
|
5
5
|
function _(e) {
|
|
6
6
|
return e && typeof e == "object" ? e : null;
|
|
7
7
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),p=require("react"),kn=require("react-dom/client"),v=require("../chunks/index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),p=require("react"),kn=require("react-dom/client"),v=require("../chunks/index-c_0nwsOM.js"),x=require("../chunks/switch-Jhyl63RF.js"),Ye=require("../data-app-builder-browser-runtime/index.cjs"),Nn=require("../chunks/save-D2O96E5A.js");function Fr(t){const s=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const a in t)if(a!=="default"){const d=Object.getOwnPropertyDescriptor(t,a);Object.defineProperty(s,a,d.get?d:{enumerable:!0,get:()=>t[a]})}}return s.default=t,Object.freeze(s)}const An=Fr(p),Cn=Fr(kn);/**
|
|
2
2
|
* @license lucide-react v0.453.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|