react-semaphor 0.1.582 → 0.1.583
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/analytics-protocol/index.js +1 -1
- package/dist/assistant-context/index.js +1 -1
- package/dist/briefings/index.js +1 -1
- package/dist/chunks/{assistant-chat-CVtxjVEH.js → assistant-chat-D3fm5qod.js} +5 -5
- package/dist/chunks/{bookmark-impact-BDSeeRy7.js → bookmark-impact-Dpxl46Wd.js} +1 -1
- package/dist/chunks/{card-filter-builder-CMZ5nwdC.js → card-filter-builder-IxkFVxy2.js} +3 -3
- package/dist/chunks/{dashboard-BNn7fpDY.js → dashboard-BMqG98fc.js} +1 -1
- package/dist/chunks/{dashboard-briefing-launcher-C9wf8KhD.js → dashboard-briefing-launcher-D45YfCkm.js} +6 -6
- package/dist/chunks/{dashboard-controls-PDb9Gap5.js → dashboard-controls-DOvZRfof.js} +7 -7
- package/dist/chunks/{dashboard-json-CvtVy2UH.js → dashboard-json-B_4TqF_o.js} +1 -1
- package/dist/chunks/{dates-B42fboJU.js → dates-44_rcNj2.js} +4 -4
- package/dist/chunks/{edit-dashboard-visual-Cat0RWPp.js → edit-dashboard-visual-BBPKJWSe.js} +7 -7
- package/dist/chunks/{filter-reach-copy-C-RH1rVx.js → filter-reach-copy-DWPq4Swi.js} +556 -556
- package/dist/chunks/{index-JWLo4R_t.js → index-DPRzcFp0.js} +1 -1
- package/dist/chunks/{matrix-analytical-definition-dkS8szLM.js → matrix-analytical-definition-D_HgptqZ.js} +1 -1
- package/dist/chunks/{report-preferences-dialog-CwbsD6t6.js → report-preferences-dialog-B8PhISua.js} +7 -7
- package/dist/chunks/{resolve-dashboard-input-context-6FP1-7aU.js → resolve-dashboard-input-context-BfT8y5xL.js} +4260 -4246
- package/dist/chunks/{saved-dashboard-context-D2G0uLji.js → saved-dashboard-context-DH91-2B9.js} +2 -2
- package/dist/chunks/{semaphor-ready-indicator-UhNS27Gy.js → semaphor-ready-indicator-Cg_Z2IDc.js} +12954 -12942
- package/dist/chunks/{shelf-drop-preview-context-DPksW68k.js → shelf-drop-preview-context-C7-BgcP4.js} +2 -2
- package/dist/chunks/{stored-dashboard-KpTy4umJ.js → stored-dashboard-BpyCiE49.js} +2 -2
- package/dist/chunks/{variable-draft-CP5I66_J.js → variable-draft-D8GFhAkm.js} +3 -3
- package/dist/dashboard/index.js +1 -1
- package/dist/dashboard-authoring/index.js +1000 -993
- package/dist/index.js +11 -11
- package/dist/style.css +1 -1
- package/dist/surfboard/index.js +1 -1
- package/dist/types/components/ui-custom/date-range-presets.d.ts +7 -0
- package/dist/types/shared/dashboard-authoring/operations/operation-types.d.ts +7 -0
- package/package.json +1 -1
|
@@ -1,32 +1,32 @@
|
|
|
1
1
|
var _s = Object.defineProperty;
|
|
2
2
|
var Cs = (e, a, t) => a in e ? _s(e, a, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[a] = t;
|
|
3
3
|
var lt = (e, a, t) => Cs(e, typeof a != "symbol" ? a + "" : a, t);
|
|
4
|
-
import { _ as $s, $ as ws, a0 as xs, a1 as Ss, a2 as ks, a3 as qa, a4 as
|
|
5
|
-
import { dC as Vr, bQ as jr, de as Kr, df as Wr, du as Ur, dt as Gr, dn as Qr, ey as Hr, dv as zr, dw as Yr, dY as Jr, cU as Xr, cV as Zr, cW as ed, cR as td, cS as ad, cT as sd, cN as od, cO as nd, cQ as id, cP as rd, cX as dd, dS as ld, dg as cd, cc as ud, e1 as fd, e2 as md, cb as hd, d8 as pd, dE as gd, cl as bd, eA as yd, eC as vd, c2 as Id, dV as _d, dH as Cd, e3 as $d, eV as wd, f4 as xd, eZ as Sd, dr as kd, ds as Td, ci as Rd, bM as Ad, eQ as Fd, dG as Dd, co as Od, dN as Ed, ch as qd, f8 as Nd, f9 as Pd, en as Ld, dF as Md, eI as Bd, fd as Vd, cF as jd, e_ as Kd, dm as Wd, cj as Ud, eb as Gd, ec as Qd, cY as Hd, cG as zd, dU as Yd, bG as Jd, dZ as Xd, el as Zd, dJ as el, eJ as tl, bH as al, bP as sl, e6 as ol, cA as nl, fb as il, eo as rl, dM as dl, em as ll, dX as cl, d7 as ul, d6 as fl, cg as ml, dT as hl, b_ as pl, c4 as gl, dR as bl, cx as yl, bE as vl, e$ as Il, f3 as _l, cp as Cl, e0 as $l, d_ as wl, eh as xl, bI as Sl, ep as kl, eR as Tl, dA as Rl, dB as Al, fe as Fl, ff as Dl, fh as Ol, b$ as El, c0 as ql, c1 as Nl, ck as Pl, cm as Ll, fa as Ml, ev as Bl, db as Vl, f as jl, cM as Kl, c9 as Wl, cu as Ul, b as Gl, cJ as Ql, dc as Hl, bS as zl, bT as Yl, dL as Jl, c8 as Xl, e8 as Zl, cq as ec, bz as tc, cd as ac, dp as sc, bW as oc, dz as nc, c3 as ic, d2 as rc, fg as dc, bN as lc, d4 as cc, e9 as uc, d5 as fc, ed as mc, eE as hc, eD as pc, dO as gc, cC as bc, ct as yc, cv as vc, l as Ic, cw as _c, et as Cc, dx as $c, dK as wc, bA as xc, bB as Sc, bC as kc, bJ as Tc, eX as Rc, eS as Ac, dD as Fc, eT as Dc, cz as Oc, ce as Ec, cI as qc, dy as Nc, es as Pc, d9 as Lc, da as Mc, bR as Bc, fc as Vc, dI as jc, eq as Kc, dd as Wc, eH as Uc, J as Gc, eW as Qc, c7 as Hc, f0 as zc, f1 as Yc, dk as Jc, cL as Xc, bV as Zc, d$ as eu, dW as tu, bD as au, cD as su, cE as ou, cf as nu, c_ as iu, bZ as ru, c5 as du, c6 as lu, dh as cu, di as uu, ca as fu, bK as mu, bY as hu, d0 as pu, eB as gu, ex as bu, f2 as yu, d1 as vu, c$ as Iu, f5 as _u, bU as Cu, ez as $u, cB as wu, ew as xu, cK as Su, ea as ku, dj as Tu, cy as Ru, dq as Au, bF as Fu, bX as Du, dP as Ou, eG as Eu, e7 as qu, cH as Nu, d3 as Pu, bO as Lu, dQ as Mu, f6 as Bu, e5 as Vu, e4 as ju, eu as Ku, eF as Wu, cn as Uu, cs as Gu, bL as Qu, eY as Hu, eU as zu, f7 as Yu, cZ as Ju, er as Xu, ek as Zu, dl as ef, ej as tf, eL as af, eg as sf, ei as of, cr as nf, ee as rf, ef as df, eK as lf, eM as cf, eN as uf, eO as ff, eP as mf } from "../chunks/resolve-dashboard-input-context-
|
|
6
|
-
import { K as Eo, L as Wa, G as Ua, M as qo, N as No, O as Ot, P as Ga, Q as Qa, A as
|
|
4
|
+
import { _ as $s, $ as ws, a0 as xs, a1 as Ss, a2 as ks, a3 as qa, a4 as Ie, a5 as Ts, a6 as he, a7 as $e, a8 as la, a9 as ot, aa as Na, ab as Q, ac as G, ad as qe, ae as Rs, af as As, ag as Ft, ah as Fs, ai as Ds, aj as Os, ak as Es, al as qs, am as Ns, an as Pa, ao as Ps, ap as Ls, aq as Ms, ar as Bs, as as Vs, at as js, au as Ks, av as ca, aw as La, ax as ua, ay as we, az as be, aA as Ne, aB as Ws, aC as Us, aD as Gs, o as Xe, aE as Qs, aF as Hs, aG as _t, aH as Ze, aI as zs, aJ as Ys, aK as Ma, aL as Dt, aM as Ct, aN as Js, aO as Xs, aP as Zs, aQ as ie, aR as Ba, aS as Va, aT as ct, aU as eo, aV as to, aW as fa, aX as $t, aY as ao, aZ as ma, a_ as so, a$ as ha, b0 as pa, b1 as et, b2 as ga, b3 as De, b4 as oo, b5 as He, m as no, b6 as ja, b7 as io, b8 as ro, b9 as lo, ba as Ka, a as co, bb as uo, bc as fo, bd as mo, be as ho, bf as po, bg as go, bh as bo, bi as yo, bj as vo, bk as Io, bl as _o, bm as ba, bn as Co, bo as $o, bp as wo, bq as xo, br as So, bs as ko, bt as To, bu as Ro, bv as Ao, bw as Fo, bx as Do, by as Oo } from "../chunks/resolve-dashboard-input-context-BfT8y5xL.js";
|
|
5
|
+
import { dC as Vr, bQ as jr, de as Kr, df as Wr, du as Ur, dt as Gr, dn as Qr, ey as Hr, dv as zr, dw as Yr, dY as Jr, cU as Xr, cV as Zr, cW as ed, cR as td, cS as ad, cT as sd, cN as od, cO as nd, cQ as id, cP as rd, cX as dd, dS as ld, dg as cd, cc as ud, e1 as fd, e2 as md, cb as hd, d8 as pd, dE as gd, cl as bd, eA as yd, eC as vd, c2 as Id, dV as _d, dH as Cd, e3 as $d, eV as wd, f4 as xd, eZ as Sd, dr as kd, ds as Td, ci as Rd, bM as Ad, eQ as Fd, dG as Dd, co as Od, dN as Ed, ch as qd, f8 as Nd, f9 as Pd, en as Ld, dF as Md, eI as Bd, fd as Vd, cF as jd, e_ as Kd, dm as Wd, cj as Ud, eb as Gd, ec as Qd, cY as Hd, cG as zd, dU as Yd, bG as Jd, dZ as Xd, el as Zd, dJ as el, eJ as tl, bH as al, bP as sl, e6 as ol, cA as nl, fb as il, eo as rl, dM as dl, em as ll, dX as cl, d7 as ul, d6 as fl, cg as ml, dT as hl, b_ as pl, c4 as gl, dR as bl, cx as yl, bE as vl, e$ as Il, f3 as _l, cp as Cl, e0 as $l, d_ as wl, eh as xl, bI as Sl, ep as kl, eR as Tl, dA as Rl, dB as Al, fe as Fl, ff as Dl, fh as Ol, b$ as El, c0 as ql, c1 as Nl, ck as Pl, cm as Ll, fa as Ml, ev as Bl, db as Vl, f as jl, cM as Kl, c9 as Wl, cu as Ul, b as Gl, cJ as Ql, dc as Hl, bS as zl, bT as Yl, dL as Jl, c8 as Xl, e8 as Zl, cq as ec, bz as tc, cd as ac, dp as sc, bW as oc, dz as nc, c3 as ic, d2 as rc, fg as dc, bN as lc, d4 as cc, e9 as uc, d5 as fc, ed as mc, eE as hc, eD as pc, dO as gc, cC as bc, ct as yc, cv as vc, l as Ic, cw as _c, et as Cc, dx as $c, dK as wc, bA as xc, bB as Sc, bC as kc, bJ as Tc, eX as Rc, eS as Ac, dD as Fc, eT as Dc, cz as Oc, ce as Ec, cI as qc, dy as Nc, es as Pc, d9 as Lc, da as Mc, bR as Bc, fc as Vc, dI as jc, eq as Kc, dd as Wc, eH as Uc, J as Gc, eW as Qc, c7 as Hc, f0 as zc, f1 as Yc, dk as Jc, cL as Xc, bV as Zc, d$ as eu, dW as tu, bD as au, cD as su, cE as ou, cf as nu, c_ as iu, bZ as ru, c5 as du, c6 as lu, dh as cu, di as uu, ca as fu, bK as mu, bY as hu, d0 as pu, eB as gu, ex as bu, f2 as yu, d1 as vu, c$ as Iu, f5 as _u, bU as Cu, ez as $u, cB as wu, ew as xu, cK as Su, ea as ku, dj as Tu, cy as Ru, dq as Au, bF as Fu, bX as Du, dP as Ou, eG as Eu, e7 as qu, cH as Nu, d3 as Pu, bO as Lu, dQ as Mu, f6 as Bu, e5 as Vu, e4 as ju, eu as Ku, eF as Wu, cn as Uu, cs as Gu, bL as Qu, eY as Hu, eU as zu, f7 as Yu, cZ as Ju, er as Xu, ek as Zu, dl as ef, ej as tf, eL as af, eg as sf, ei as of, cr as nf, ee as rf, ef as df, eK as lf, eM as cf, eN as uf, eO as ff, eP as mf } from "../chunks/resolve-dashboard-input-context-BfT8y5xL.js";
|
|
6
|
+
import { K as Eo, L as Wa, G as Ua, M as qo, N as No, O as Ot, P as Ga, Q as Qa, A as xe, R as Po, S as Lo, H as Mo, T as Bo } from "../chunks/bookmark-state-BEl_G9vr.js";
|
|
7
7
|
import { ae as pf, ay as gf, Y as bf, Z as yf, a8 as vf, ac as If, a9 as _f, aa as Cf, ab as $f, af as wf, aw as xf, aq as Sf, D as kf, au as Tf, F as Rf, a1 as Af, I as Ff, ax as Df, a4 as Of, a5 as Ef, as as qf, ad as Nf, a2 as Pf, ao as Lf, at as Mf, av as Bf, ap as Vf, ar as jf, a0 as Kf, _ as Wf, ah as Uf, am as Gf, W as Qf, X as Hf, U as zf, a3 as Yf, an as Jf, az as Xf, ai as Zf, ag as em, aj as tm, ak as am, al as sm, a7 as om, a6 as nm, $ as im } from "../chunks/bookmark-state-BEl_G9vr.js";
|
|
8
|
-
import { L as dm, G as lm, H as cm, g as um, F as fm, q as mm, A as hm, D as pm, u as gm, v as bm, E as ym, C as vm, s as Im, t as _m, p as Cm, B as $m, I as wm, w as xm, y as Sm, x as km, z as Tm } from "../chunks/stored-dashboard-
|
|
8
|
+
import { L as dm, G as lm, H as cm, g as um, F as fm, q as mm, A as hm, D as pm, u as gm, v as bm, E as ym, C as vm, s as Im, t as _m, p as Cm, B as $m, I as wm, w as xm, y as Sm, x as km, z as Tm } from "../chunks/stored-dashboard-BpyCiE49.js";
|
|
9
9
|
import { r as Vo, a5 as ya, aD as jo } from "../chunks/pivot-result-contract-expectations-8tuNjRvG.js";
|
|
10
10
|
import { aG as Am, aF as Fm, aA as Dm, aE as Om, aH as Em, au as qm } from "../chunks/pivot-result-contract-expectations-8tuNjRvG.js";
|
|
11
11
|
import { f as Ko, w as Wo, D as va, r as Uo } from "../chunks/metric-comparison-n9NsIa-2.js";
|
|
12
12
|
import { p as Go } from "../chunks/report-runtime-context-BhPzLTbS.js";
|
|
13
|
-
import { r as Ha, D as Ia, f as Qo, h as za, i as Ho, j as zo, k as Yo, e as wt, l as Jo, v as Xo } from "../chunks/filter-reach-copy-
|
|
14
|
-
import { N as Pm, R as Lm, n as Mm, q as Bm, u as Vm, t as jm, F as Km, B as Wm, m as Um, p as Gm, I as Qm, O as Hm, P as zm, C as Ym, K as Jm, E as Xm, w as Zm, x as eh, z as th, o as ah, y as sh, Q as oh, M as nh, L as ih, G as rh, H as dh, s as lh, J as ch, A as uh } from "../chunks/filter-reach-copy-
|
|
13
|
+
import { r as Ha, D as Ia, f as Qo, h as za, i as Ho, j as zo, k as Yo, e as wt, l as Jo, v as Xo } from "../chunks/filter-reach-copy-DWPq4Swi.js";
|
|
14
|
+
import { N as Pm, R as Lm, n as Mm, q as Bm, u as Vm, t as jm, F as Km, B as Wm, m as Um, p as Gm, I as Qm, O as Hm, P as zm, C as Ym, K as Jm, E as Xm, w as Zm, x as eh, z as th, o as ah, y as sh, Q as oh, M as nh, L as ih, G as rh, H as dh, s as lh, J as ch, A as uh } from "../chunks/filter-reach-copy-DWPq4Swi.js";
|
|
15
15
|
import { a7 as Ya, r as Ja, aN as Zo, a_ as Pe, aL as en, aQ as tn, aK as an, aE as sn, aM as on, a5 as nn } from "../chunks/validators-B8fpdinG.js";
|
|
16
16
|
import "../chunks/schema-C9NPiIru.js";
|
|
17
17
|
import { i as Xa, C as je, D as rn, e as dn, b as ln } from "../chunks/edit-9df1zOWe.js";
|
|
18
18
|
import "../chunks/matrix-operation-contract-DCVinw1o.js";
|
|
19
|
-
import { A as Me, B as ze, z as cn, f as un, y as Et, t as
|
|
20
|
-
import { y as _a, C as mn } from "../chunks/matrix-analytical-definition-
|
|
19
|
+
import { A as Me, B as ze, z as cn, f as un, y as Et, t as Se, e as fn } from "../chunks/analytics-base-schemas-BaIQrEzX.js";
|
|
20
|
+
import { y as _a, C as mn } from "../chunks/matrix-analytical-definition-D_HgptqZ.js";
|
|
21
21
|
import "zod";
|
|
22
22
|
import "../value-format-preferences/index.js";
|
|
23
23
|
import { C as mh, a as hh, S as ph } from "../chunks/pickers-DkqmtnTL.js";
|
|
24
24
|
import { r as hn } from "../chunks/index-CV_Kzou0.js";
|
|
25
25
|
import "../chunks/context-BTLBjQNh.js";
|
|
26
|
-
import { v as Ye, a as pn, i as Ca, o as ut, d as gn, b as bn, c as yn } from "../chunks/variable-draft-
|
|
27
|
-
import { S as bh, f as yh, g as vh, e as Ih, n as _h } from "../chunks/variable-draft-
|
|
28
|
-
import { r as $h, a as wh } from "../chunks/dates-
|
|
29
|
-
import { b as Sh, d as kh } from "../chunks/bookmark-impact-
|
|
26
|
+
import { v as Ye, a as pn, i as Ca, o as ut, d as gn, b as bn, c as yn } from "../chunks/variable-draft-D8GFhAkm.js";
|
|
27
|
+
import { S as bh, f as yh, g as vh, e as Ih, n as _h } from "../chunks/variable-draft-D8GFhAkm.js";
|
|
28
|
+
import { r as $h, a as wh } from "../chunks/dates-44_rcNj2.js";
|
|
29
|
+
import { b as Sh, d as kh } from "../chunks/bookmark-impact-Dpxl46Wd.js";
|
|
30
30
|
import { r as ye, b as vn, s as In, a as _n } from "../chunks/resolver-DG_tfEpt.js";
|
|
31
31
|
import { n as Cn, r as $n } from "../chunks/index-BVKzKl5d.js";
|
|
32
32
|
import { e as Rh } from "../chunks/brand-BoUV0iHF.js";
|
|
@@ -54,11 +54,11 @@ const kr = [
|
|
|
54
54
|
"tableConfig"
|
|
55
55
|
];
|
|
56
56
|
class ce extends Error {
|
|
57
|
-
constructor(t, s,
|
|
57
|
+
constructor(t, s, o) {
|
|
58
58
|
super(t);
|
|
59
59
|
lt(this, "field");
|
|
60
60
|
lt(this, "details");
|
|
61
|
-
Object.setPrototypeOf(this, ce.prototype), this.name = "CardQueryRequestError", this.field = s, this.details =
|
|
61
|
+
Object.setPrototypeOf(this, ce.prototype), this.name = "CardQueryRequestError", this.field = s, this.details = o;
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
function qt(e) {
|
|
@@ -71,7 +71,7 @@ function Ke(e) {
|
|
|
71
71
|
return typeof e == "string" ? e : "";
|
|
72
72
|
}
|
|
73
73
|
function wn(e, a = {}) {
|
|
74
|
-
const t = ve(e), s = qt(a),
|
|
74
|
+
const t = ve(e), s = qt(a), o = {};
|
|
75
75
|
if (t.calendarContext !== void 0) {
|
|
76
76
|
const i = Go(t.calendarContext);
|
|
77
77
|
if (!i.ok)
|
|
@@ -80,16 +80,16 @@ function wn(e, a = {}) {
|
|
|
80
80
|
"calendarContext",
|
|
81
81
|
i.issues
|
|
82
82
|
);
|
|
83
|
-
|
|
83
|
+
o.calendarContext = i.value;
|
|
84
84
|
}
|
|
85
|
-
const
|
|
86
|
-
if (!
|
|
85
|
+
const n = $s(t.resolvedPrimaryDateField);
|
|
86
|
+
if (!n.ok)
|
|
87
87
|
throw new ce(
|
|
88
|
-
`${s}${ws(
|
|
88
|
+
`${s}${ws(n.issues)}`,
|
|
89
89
|
"resolvedPrimaryDateField",
|
|
90
|
-
|
|
90
|
+
n.issues
|
|
91
91
|
);
|
|
92
|
-
if (t.resolvedPrimaryDateField && (
|
|
92
|
+
if (t.resolvedPrimaryDateField && (o.resolvedPrimaryDateField = t.resolvedPrimaryDateField), t.globalDateComparison !== void 0) {
|
|
93
93
|
const i = Ko(t.globalDateComparison);
|
|
94
94
|
if (!i.ok)
|
|
95
95
|
throw new ce(
|
|
@@ -97,140 +97,140 @@ function wn(e, a = {}) {
|
|
|
97
97
|
"globalDateComparison",
|
|
98
98
|
i.errors
|
|
99
99
|
);
|
|
100
|
-
|
|
100
|
+
o.globalDateComparison = Wo(
|
|
101
101
|
t.globalDateComparison
|
|
102
102
|
);
|
|
103
103
|
}
|
|
104
|
-
return
|
|
104
|
+
return o;
|
|
105
105
|
}
|
|
106
106
|
function Rr(e, a = {}) {
|
|
107
|
-
const t = ve(e), s = qt(a),
|
|
107
|
+
const t = ve(e), s = qt(a), o = {};
|
|
108
108
|
if (t.pagination !== void 0) {
|
|
109
|
-
const
|
|
109
|
+
const n = ve(t.pagination), i = n.page, d = n.pageSize;
|
|
110
110
|
if (!Number.isInteger(i) || i < 1 || !Number.isInteger(d) || d < 1)
|
|
111
111
|
throw new ce(
|
|
112
112
|
`${s}pagination must name a page and a page size of at least 1`,
|
|
113
113
|
"pagination"
|
|
114
114
|
);
|
|
115
|
-
|
|
115
|
+
o.pagination = { page: i, pageSize: d };
|
|
116
116
|
}
|
|
117
117
|
if (t.tableTotalsRequest !== void 0) {
|
|
118
118
|
if (!t.tableTotalsRequest || typeof t.tableTotalsRequest != "object" || Array.isArray(t.tableTotalsRequest))
|
|
119
119
|
throw new ce(`${s}tableTotalsRequest must be an object`, "tableTotalsRequest");
|
|
120
|
-
|
|
120
|
+
o.tableTotalsRequest = t.tableTotalsRequest;
|
|
121
121
|
}
|
|
122
122
|
if (t.sourceRowProbe !== void 0) {
|
|
123
|
-
const
|
|
124
|
-
if (!Number.isInteger(
|
|
123
|
+
const n = ve(t.sourceRowProbe).limit;
|
|
124
|
+
if (!Number.isInteger(n) || n < 1)
|
|
125
125
|
throw new ce(
|
|
126
126
|
`${s}sourceRowProbe must name a limit of at least 1`,
|
|
127
127
|
"sourceRowProbe"
|
|
128
128
|
);
|
|
129
|
-
if (
|
|
129
|
+
if (o.pagination)
|
|
130
130
|
throw new ce(
|
|
131
131
|
`${s}sourceRowProbe cannot be combined with pagination`,
|
|
132
132
|
"sourceRowProbe"
|
|
133
133
|
);
|
|
134
|
-
|
|
134
|
+
o.sourceRowProbe = { limit: n };
|
|
135
135
|
}
|
|
136
|
-
return
|
|
136
|
+
return o;
|
|
137
137
|
}
|
|
138
138
|
function Ar(e, a = {}) {
|
|
139
|
-
const t = ve(e), s = qt(a),
|
|
140
|
-
if (!
|
|
139
|
+
const t = ve(e), s = qt(a), o = (w) => new ce(`${s}${w} is required`, w), n = Ke(t.connection_id).trim();
|
|
140
|
+
if (!n) throw o("connection_id");
|
|
141
141
|
const i = Ke(t.cardType).trim();
|
|
142
|
-
if (!i) throw
|
|
142
|
+
if (!i) throw o("cardType");
|
|
143
143
|
const d = t.resultOwner;
|
|
144
144
|
if (d !== "config" && d !== "freeform" && d !== "none")
|
|
145
|
-
throw
|
|
146
|
-
const l = ve(t.cardConfig), c = Ke(t.sql), h = Ke(t.python),
|
|
147
|
-
if (d === "config" && !
|
|
148
|
-
if (d === "freeform" && !c.trim()) throw
|
|
149
|
-
const
|
|
150
|
-
hasExecutableConfig:
|
|
145
|
+
throw o("resultOwner");
|
|
146
|
+
const l = ve(t.cardConfig), c = Ke(t.sql), h = Ke(t.python), p = !!a.configOptional || Object.keys(l).length > 0;
|
|
147
|
+
if (d === "config" && !p) throw o("cardConfig");
|
|
148
|
+
if (d === "freeform" && !c.trim()) throw o("sql");
|
|
149
|
+
const I = xs({
|
|
150
|
+
hasExecutableConfig: p,
|
|
151
151
|
sql: c,
|
|
152
152
|
normalizedPython: h
|
|
153
153
|
});
|
|
154
|
-
if (d !==
|
|
154
|
+
if (d !== I)
|
|
155
155
|
throw new ce(
|
|
156
|
-
`${s}resultOwner must match the normalized execution owner "${
|
|
156
|
+
`${s}resultOwner must match the normalized execution owner "${I}"`,
|
|
157
157
|
"resultOwner"
|
|
158
158
|
);
|
|
159
|
-
if (d === "none") throw
|
|
160
|
-
const
|
|
161
|
-
if (Object.keys(
|
|
162
|
-
const
|
|
159
|
+
if (d === "none") throw o("cardConfig");
|
|
160
|
+
const v = ve(t.cardDataSource);
|
|
161
|
+
if (Object.keys(v).length === 0) throw o("cardDataSource");
|
|
162
|
+
const x = Ss({
|
|
163
163
|
controlValues: t.controlValues,
|
|
164
164
|
controlDefinitions: t.controlDefinitions,
|
|
165
165
|
cardControlDefinitions: t.cardControlDefinitions,
|
|
166
166
|
controlBindings: t.controlBindings
|
|
167
167
|
});
|
|
168
168
|
return {
|
|
169
|
-
connection_id:
|
|
169
|
+
connection_id: n,
|
|
170
170
|
cardType: i,
|
|
171
171
|
sql: c,
|
|
172
172
|
python: h,
|
|
173
173
|
resultOwner: d,
|
|
174
174
|
cardConfig: l,
|
|
175
|
-
cardDataSource:
|
|
175
|
+
cardDataSource: v,
|
|
176
176
|
active_filters: Array.isArray(t.active_filters) ? t.active_filters : [],
|
|
177
|
-
controlValues:
|
|
178
|
-
controlDefinitions:
|
|
179
|
-
cardControlDefinitions:
|
|
180
|
-
controlBindings:
|
|
177
|
+
controlValues: x.controlValues,
|
|
178
|
+
controlDefinitions: x.controlDefinitions,
|
|
179
|
+
cardControlDefinitions: x.cardControlDefinitions,
|
|
180
|
+
controlBindings: x.controlBindings,
|
|
181
181
|
...wn(t, a),
|
|
182
182
|
...typeof t.sqlRowLimit == "number" && Number.isInteger(t.sqlRowLimit) && t.sqlRowLimit > 0 ? { sqlRowLimit: t.sqlRowLimit } : {}
|
|
183
183
|
};
|
|
184
184
|
}
|
|
185
185
|
const ft = ["#14b8a6", "#5eead4", "#374151", "#6b7280", "#d1d5db"], xn = ["spacing", "canvasPadding", "canvas", "cardCorners", "chartColors"], Za = ["light", "dark"];
|
|
186
186
|
function Fr(e) {
|
|
187
|
-
const a = [], t = ht(e.globalStyle) ? e.globalStyle : {}, s = ht(t.default) ? t.default : {},
|
|
188
|
-
Array.isArray(d) && typeof d[1] == "number" && (i.spacing =
|
|
189
|
-
const l =
|
|
190
|
-
typeof l == "number" && (i.cardCorners =
|
|
191
|
-
const c =
|
|
192
|
-
typeof c == "number" && (i.controlCorners =
|
|
193
|
-
const h =
|
|
194
|
-
typeof h == "number" && (i.barCorners =
|
|
195
|
-
for (const
|
|
196
|
-
const
|
|
197
|
-
|
|
198
|
-
const
|
|
199
|
-
if (
|
|
200
|
-
const
|
|
201
|
-
|
|
187
|
+
const a = [], t = ht(e.globalStyle) ? e.globalStyle : {}, s = ht(t.default) ? t.default : {}, o = ht(t.dark) ? t.dark : {}, n = (p) => ye(o, p) ?? ye(s, p), i = {}, d = n(["gridLayout", "margin"]);
|
|
188
|
+
Array.isArray(d) && typeof d[1] == "number" && (i.spacing = Oe("spacing", d[1], a), i.canvasPadding = Oe("canvasPadding", d[1], a));
|
|
189
|
+
const l = n(["cardBorderRadius"]);
|
|
190
|
+
typeof l == "number" && (i.cardCorners = Oe("cardCorners", l, a));
|
|
191
|
+
const c = n(["controlInputRadius"]);
|
|
192
|
+
typeof c == "number" && (i.controlCorners = Oe("controlCorners", c, a));
|
|
193
|
+
const h = n(["chart", "options", "borderRadius"]);
|
|
194
|
+
typeof h == "number" && (i.barCorners = Oe("barCorners", h, a));
|
|
195
|
+
for (const p of Za) {
|
|
196
|
+
const I = p === "light" ? ye(s, ["canvasTheme"]) : n(["canvasTheme"]), v = Tn(I, a);
|
|
197
|
+
v !== void 0 && (i.canvas = { ...i.canvas, [p]: v });
|
|
198
|
+
const x = kn(s, o, p);
|
|
199
|
+
if (x) {
|
|
200
|
+
const w = x.filter(Xa).map((E) => E.toLowerCase());
|
|
201
|
+
w.length < x.length && a.push({ field: "chartColors", kind: "dropped_colour", detail: `${p}: ${x.length - w.length} colours that aren't hex` }), w.length >= je.min && (i.chartColors = { ...i.chartColors, [p]: w.slice(0, je.max) }), w.length > je.max && a.push({ field: "chartColors", kind: "clamped", detail: `${p}: kept the first ${je.max} colours` });
|
|
202
202
|
}
|
|
203
203
|
}
|
|
204
204
|
return { style: Sn(i, e.organizationAppearance, a), notes: a };
|
|
205
205
|
}
|
|
206
206
|
function Sn(e, a, t) {
|
|
207
|
-
const s = vn({ organizationAppearance: a ? Cn(a).spec : null }),
|
|
208
|
-
for (const
|
|
209
|
-
const i = _n[
|
|
207
|
+
const s = vn({ organizationAppearance: a ? Cn(a).spec : null }), o = { ...e };
|
|
208
|
+
for (const n of Object.keys(e)) {
|
|
209
|
+
const i = _n[n], d = n === "canvas" || n === "chartColors";
|
|
210
210
|
for (const l of Za) {
|
|
211
|
-
const c = In(
|
|
211
|
+
const c = In(o, n, l);
|
|
212
212
|
if (c === void 0) continue;
|
|
213
|
-
const h = xn.includes(
|
|
214
|
-
if (!(!h && !
|
|
215
|
-
if ((d || l === "light") && t.push({ field:
|
|
216
|
-
const
|
|
217
|
-
delete
|
|
218
|
-
} else l === "light" && delete n
|
|
213
|
+
const h = xn.includes(n) && ye($n(a, l), i) !== void 0, p = JSON.stringify(ye(s.schemes[l], i)) === JSON.stringify(c);
|
|
214
|
+
if (!(!h && !p))
|
|
215
|
+
if ((d || l === "light") && t.push({ field: n, kind: h ? "brand_wins" : "equal_to_inherited", detail: d ? l : `${JSON.stringify(c)}` }), d) {
|
|
216
|
+
const I = { ...o[n] };
|
|
217
|
+
delete I[l], Object.keys(I).length > 0 ? o[n] = I : delete o[n];
|
|
218
|
+
} else l === "light" && delete o[n];
|
|
219
219
|
}
|
|
220
220
|
}
|
|
221
|
-
return Object.keys(
|
|
221
|
+
return Object.keys(o).length > 0 ? o : void 0;
|
|
222
222
|
}
|
|
223
223
|
function kn(e, a, t) {
|
|
224
|
-
const s = ye(e, ["chart", "dataset", "backgroundColor"]),
|
|
225
|
-
if (t === "light") return Array.isArray(s) ?
|
|
226
|
-
const i = mt(
|
|
227
|
-
if (!(!Array.isArray(
|
|
228
|
-
return Array.isArray(s) || Array.isArray(
|
|
224
|
+
const s = ye(e, ["chart", "dataset", "backgroundColor"]), o = ye(a, ["chart", "dataset", "backgroundColor"]), n = mt(ft, s);
|
|
225
|
+
if (t === "light") return Array.isArray(s) ? n : void 0;
|
|
226
|
+
const i = mt(n, mt(ft, o));
|
|
227
|
+
if (!(!Array.isArray(o) && JSON.stringify(i) === JSON.stringify(ft)))
|
|
228
|
+
return Array.isArray(s) || Array.isArray(o) ? i : void 0;
|
|
229
229
|
}
|
|
230
230
|
function mt(e, a) {
|
|
231
231
|
if (!Array.isArray(a)) return [...e];
|
|
232
232
|
const t = Math.max(e.length, a.length);
|
|
233
|
-
return Array.from({ length: t }, (s,
|
|
233
|
+
return Array.from({ length: t }, (s, o) => a[o] !== void 0 ? String(a[o]) : e[o]);
|
|
234
234
|
}
|
|
235
235
|
function Tn(e, a) {
|
|
236
236
|
if (!(e == null || e === "")) {
|
|
@@ -240,9 +240,9 @@ function Tn(e, a) {
|
|
|
240
240
|
a.push({ field: "canvas", kind: "dropped_colour", detail: String(e) });
|
|
241
241
|
}
|
|
242
242
|
}
|
|
243
|
-
function
|
|
244
|
-
const { min: s, max:
|
|
245
|
-
return
|
|
243
|
+
function Oe(e, a, t) {
|
|
244
|
+
const { min: s, max: o } = rn[e], n = Math.min(o, Math.max(s, Math.round(a)));
|
|
245
|
+
return n !== a && t.push({ field: e, kind: "clamped", detail: `${a} → ${n}` }), n;
|
|
246
246
|
}
|
|
247
247
|
function ht(e) {
|
|
248
248
|
return typeof e == "object" && e !== null && !Array.isArray(e);
|
|
@@ -261,8 +261,8 @@ const pt = {
|
|
|
261
261
|
function Rn(e) {
|
|
262
262
|
var t;
|
|
263
263
|
const a = {};
|
|
264
|
-
for (const [s,
|
|
265
|
-
|
|
264
|
+
for (const [s, o] of Object.entries(e ?? {}))
|
|
265
|
+
o !== void 0 && ((t = pt[s]) == null || t.call(pt, o, a));
|
|
266
266
|
return a;
|
|
267
267
|
}
|
|
268
268
|
const An = {
|
|
@@ -272,12 +272,12 @@ const An = {
|
|
|
272
272
|
};
|
|
273
273
|
function Fn(e, a, t = {}) {
|
|
274
274
|
var d;
|
|
275
|
-
const s =
|
|
275
|
+
const s = Ie(e), o = Eo(a.scope), n = new Set(Wa(e).map((l) => l.id)), i = {
|
|
276
276
|
reaches: [],
|
|
277
277
|
excluded: [
|
|
278
278
|
.../* @__PURE__ */ new Set([
|
|
279
279
|
...(((d = a.application) == null ? void 0 : d.cards) ?? []).filter((l) => l.kind === "excluded").map((l) => l.cardId),
|
|
280
|
-
...
|
|
280
|
+
...o.filter((l) => n.has(l))
|
|
281
281
|
])
|
|
282
282
|
],
|
|
283
283
|
notReached: []
|
|
@@ -291,12 +291,12 @@ function Fn(e, a, t = {}) {
|
|
|
291
291
|
], i;
|
|
292
292
|
}
|
|
293
293
|
for (const l of s.reachedCards({ inputId: a.id })) {
|
|
294
|
-
const c =
|
|
295
|
-
const
|
|
294
|
+
const c = $e(a, l.card, t), h = c.reach, p = () => {
|
|
295
|
+
const I = he(l.card);
|
|
296
296
|
return {
|
|
297
297
|
cardId: l.cardId,
|
|
298
298
|
title: l.card.title ?? "",
|
|
299
|
-
...(
|
|
299
|
+
...(I == null ? void 0 : I.kind) === "semantic" ? { datasetName: I.datasetName } : {}
|
|
300
300
|
};
|
|
301
301
|
};
|
|
302
302
|
switch (h) {
|
|
@@ -311,7 +311,7 @@ function Fn(e, a, t = {}) {
|
|
|
311
311
|
(i.blocked ?? (i.blocked = [])).push({ cardId: l.cardId, title: l.card.title ?? "", reason: h });
|
|
312
312
|
break;
|
|
313
313
|
case "relationship":
|
|
314
|
-
(i.relationshipPending ?? (i.relationshipPending = [])).push(
|
|
314
|
+
(i.relationshipPending ?? (i.relationshipPending = [])).push(p());
|
|
315
315
|
break;
|
|
316
316
|
case "sqlTemplate":
|
|
317
317
|
(i.sqlPending ?? (i.sqlPending = [])).push({ cardId: l.cardId, title: l.card.title ?? "" });
|
|
@@ -319,18 +319,18 @@ function Fn(e, a, t = {}) {
|
|
|
319
319
|
case "excluded":
|
|
320
320
|
break;
|
|
321
321
|
case "notApplicable":
|
|
322
|
-
he(l.card) && i.notReached.push({ ...
|
|
322
|
+
he(l.card) && i.notReached.push({ ...p(), ...c.reason ? { reason: c.reason } : {} });
|
|
323
323
|
break;
|
|
324
324
|
default: {
|
|
325
|
-
const
|
|
326
|
-
throw new Error(`Unhandled filter reach ${String(
|
|
325
|
+
const I = h;
|
|
326
|
+
throw new Error(`Unhandled filter reach ${String(I)}`);
|
|
327
327
|
}
|
|
328
328
|
}
|
|
329
329
|
}
|
|
330
330
|
for (const l of s.reachedVariables({ inputId: a.id })) {
|
|
331
331
|
const c = Ua(e, l.variableId);
|
|
332
332
|
if ((c == null ? void 0 : c.kind) !== "variable") continue;
|
|
333
|
-
const h =
|
|
333
|
+
const h = $e(a, c.card, t), p = he(c.card), I = { cardId: c.id, title: c.variable.name, ...(p == null ? void 0 : p.kind) === "semantic" ? { datasetName: p.datasetName } : {} };
|
|
334
334
|
switch (h.reach) {
|
|
335
335
|
case "bound":
|
|
336
336
|
case "automatic":
|
|
@@ -343,7 +343,7 @@ function Fn(e, a, t = {}) {
|
|
|
343
343
|
(i.blocked ?? (i.blocked = [])).push({ cardId: c.id, title: c.variable.name, reason: h.reach });
|
|
344
344
|
break;
|
|
345
345
|
case "relationship":
|
|
346
|
-
(i.relationshipPending ?? (i.relationshipPending = [])).push(
|
|
346
|
+
(i.relationshipPending ?? (i.relationshipPending = [])).push(I);
|
|
347
347
|
break;
|
|
348
348
|
case "sqlTemplate":
|
|
349
349
|
(i.sqlPending ?? (i.sqlPending = [])).push({ cardId: c.id, title: c.variable.name });
|
|
@@ -351,30 +351,30 @@ function Fn(e, a, t = {}) {
|
|
|
351
351
|
case "excluded":
|
|
352
352
|
break;
|
|
353
353
|
case "notApplicable":
|
|
354
|
-
i.notReached.push({ ...
|
|
354
|
+
i.notReached.push({ ...I, ...h.reason ? { reason: h.reason } : {} });
|
|
355
355
|
break;
|
|
356
356
|
}
|
|
357
357
|
}
|
|
358
358
|
return i;
|
|
359
359
|
}
|
|
360
360
|
function Dn(e, a) {
|
|
361
|
-
var
|
|
361
|
+
var o;
|
|
362
362
|
const t = a.scope;
|
|
363
363
|
if (t.kind === "allSheets") {
|
|
364
|
-
if ((
|
|
365
|
-
const
|
|
364
|
+
if ((o = t.sheetKinds) != null && o.length && !t.sheetKinds.includes("dashboard")) return;
|
|
365
|
+
const n = qo(t);
|
|
366
366
|
return {
|
|
367
367
|
sheetIds: "all",
|
|
368
|
-
...
|
|
368
|
+
...n.length ? { exceptSheetIds: [...n] } : {},
|
|
369
369
|
...No(t) ? { includesDocumentSheets: !0 } : {}
|
|
370
370
|
};
|
|
371
371
|
}
|
|
372
372
|
if (t.kind !== "sheets") return;
|
|
373
|
-
const s = [...Ot(e).values()].filter((
|
|
373
|
+
const s = [...Ot(e).values()].filter((n) => Ga(a, n));
|
|
374
374
|
return {
|
|
375
|
-
sheetIds: s.filter((
|
|
375
|
+
sheetIds: s.filter((n) => n.sheetKind === "dashboard").map((n) => n.sheetId),
|
|
376
376
|
// Document sheets it names stay through a change of sheets (`withUnstatedScopeParts`).
|
|
377
|
-
...s.some((
|
|
377
|
+
...s.some((n) => n.sheetKind === "document") ? { includesDocumentSheets: !0 } : {}
|
|
378
378
|
};
|
|
379
379
|
}
|
|
380
380
|
function es(e, a) {
|
|
@@ -382,54 +382,54 @@ function es(e, a) {
|
|
|
382
382
|
}
|
|
383
383
|
function ts(e, a, t, s) {
|
|
384
384
|
var E, _, S;
|
|
385
|
-
const { input:
|
|
386
|
-
filterId:
|
|
387
|
-
label:
|
|
385
|
+
const { input: o } = a, n = Fn(e, o, s), i = (y, D) => ({
|
|
386
|
+
filterId: o.id,
|
|
387
|
+
label: o.label,
|
|
388
388
|
editable: !1,
|
|
389
389
|
kind: D,
|
|
390
390
|
notEditable: { reason: y, message: An[y] },
|
|
391
|
-
reaches:
|
|
392
|
-
excluded:
|
|
393
|
-
...
|
|
394
|
-
...
|
|
395
|
-
...
|
|
391
|
+
reaches: n.reaches,
|
|
392
|
+
excluded: n.excluded,
|
|
393
|
+
...n.blocked ? { blocked: n.blocked } : {},
|
|
394
|
+
...n.relationshipPending ? { relationshipPending: n.relationshipPending } : {},
|
|
395
|
+
...n.sqlPending ? { sqlPending: n.sqlPending } : {}
|
|
396
396
|
});
|
|
397
|
-
if (
|
|
398
|
-
const d = ks(
|
|
397
|
+
if (o.filter.kind === "global-date") return i("global_date", "global_date");
|
|
398
|
+
const d = ks(o.filter).filter((y) => y.kind === "semantic");
|
|
399
399
|
if (d.length !== 1 || d[0].kind !== "semantic") return i("not_semantic", "field");
|
|
400
|
-
const l = Dn(e,
|
|
400
|
+
const l = Dn(e, o);
|
|
401
401
|
if (!l || a.origin !== "embeddedInput") return i("scope_not_expressible", "field");
|
|
402
|
-
const c = ((E =
|
|
402
|
+
const c = ((E = o.filter.fieldMeta) == null ? void 0 : E.name) ?? ((_ = o.filter.column) == null ? void 0 : _.split(".").pop()) ?? "", h = Ha({
|
|
403
403
|
dashboard: e,
|
|
404
|
-
target: { kind: "dashboardInput", input:
|
|
404
|
+
target: { kind: "dashboardInput", input: o, scope: {} },
|
|
405
405
|
calendar: es(t, void 0)
|
|
406
|
-
}).value,
|
|
407
|
-
|
|
408
|
-
{ use: "filterDefault", columnHasTime: qa(
|
|
406
|
+
}).value, p = Ya(o.filter.dataType), I = p || (S = h == null ? void 0 : h.values) == null ? void 0 : S.filter((y) => ["string", "number", "boolean"].includes(typeof y)), v = Ja(h && "relativeMeta" in h ? h.relativeMeta : void 0), x = p ? v : void 0, w = x ? Zo(
|
|
407
|
+
x,
|
|
408
|
+
{ use: "filterDefault", columnHasTime: qa(o.filter) === "datetime" },
|
|
409
409
|
"defaultPeriod"
|
|
410
410
|
) : void 0;
|
|
411
411
|
return {
|
|
412
|
-
filterId:
|
|
413
|
-
label:
|
|
412
|
+
filterId: o.id,
|
|
413
|
+
label: o.label,
|
|
414
414
|
editable: !0,
|
|
415
415
|
domainId: d[0].domainId,
|
|
416
416
|
datasetName: d[0].datasetName,
|
|
417
417
|
field: c,
|
|
418
|
-
selection:
|
|
419
|
-
...
|
|
420
|
-
...
|
|
421
|
-
...
|
|
422
|
-
...
|
|
418
|
+
selection: o.filter.type === "single" ? "single" : "multiple",
|
|
419
|
+
...I != null && I.length ? { defaultValues: I } : {},
|
|
420
|
+
...x ? { defaultPeriod: x } : {},
|
|
421
|
+
...w ? { defaultPeriodReadOnly: w } : {},
|
|
422
|
+
...p ? { datePicker: o.filter.dateSelectionMode === "day" ? "day" : o.filter.dateSelectionMode === "months" ? "month" : "range" } : {},
|
|
423
423
|
...l,
|
|
424
|
-
...
|
|
424
|
+
...n
|
|
425
425
|
};
|
|
426
426
|
}
|
|
427
427
|
function as(e, a, t) {
|
|
428
|
-
return
|
|
428
|
+
return Ie(e).inputs.map((s) => ts(e, s, a, t));
|
|
429
429
|
}
|
|
430
430
|
function Le(e, a, t, s) {
|
|
431
|
-
const
|
|
432
|
-
return
|
|
431
|
+
const o = Ie(e).findFilterInput({ inputId: a });
|
|
432
|
+
return o ? ts(e, o, t, s) : void 0;
|
|
433
433
|
}
|
|
434
434
|
const Nt = (e) => `${e.domainId}\0${e.datasetName}`;
|
|
435
435
|
function ss(e, a) {
|
|
@@ -458,17 +458,17 @@ function ns(e) {
|
|
|
458
458
|
function On(e) {
|
|
459
459
|
const a = os(e), t = /* @__PURE__ */ new Map();
|
|
460
460
|
for (const { field: s } of ns(e)) {
|
|
461
|
-
const
|
|
462
|
-
|
|
461
|
+
const o = ss(s, a);
|
|
462
|
+
o && t.set(Nt(o), o);
|
|
463
463
|
}
|
|
464
464
|
return [...t.values()];
|
|
465
465
|
}
|
|
466
466
|
function En(e, a, t) {
|
|
467
467
|
if (!t) return;
|
|
468
|
-
const s = la(a),
|
|
469
|
-
if (!
|
|
470
|
-
const
|
|
471
|
-
return i ? ot(i,
|
|
468
|
+
const s = la(a), o = ns(e).find((d) => la(d.ref) === s);
|
|
469
|
+
if (!o) return;
|
|
470
|
+
const n = ss(o.field, os(e)), i = n ? t[Nt(n)] : void 0;
|
|
471
|
+
return i ? ot(i, o.field.name, n.datasetName) : void 0;
|
|
472
472
|
}
|
|
473
473
|
const xt = ["orientation", "stack", "donut", "totals", "dataLabels", "legend", "axes", "comparisonDisplay", "inheritComparison", "band"], qn = {
|
|
474
474
|
orientation: "orientation",
|
|
@@ -487,66 +487,66 @@ function Pn(e) {
|
|
|
487
487
|
return `${/^[aeiou]/i.test(a) ? "an" : "a"} ${a}`;
|
|
488
488
|
}
|
|
489
489
|
function Ln(e, a, t) {
|
|
490
|
-
const s = Object.fromEntries(Object.entries(a).filter(([
|
|
490
|
+
const s = Object.fromEntries(Object.entries(a).filter(([o, n]) => n !== void 0 && !t.includes(o)));
|
|
491
491
|
return Object.keys(s).length ? { op: "card.update", cardId: e.cardRef, ...s } : void 0;
|
|
492
492
|
}
|
|
493
|
-
function Mn(e, a, t, s,
|
|
494
|
-
var
|
|
495
|
-
const
|
|
496
|
-
if (!
|
|
497
|
-
const i = xt.filter((
|
|
498
|
-
for (const
|
|
499
|
-
|
|
493
|
+
function Mn(e, a, t, s, o) {
|
|
494
|
+
var v, x, w, E, _, S, y, D, $, N;
|
|
495
|
+
const n = xt.filter((g) => t[g] !== void 0);
|
|
496
|
+
if (!n.length) return {};
|
|
497
|
+
const i = xt.filter((g) => a.settings.has(g)), d = n.filter((g) => !a.settings.has(g));
|
|
498
|
+
for (const g of d)
|
|
499
|
+
o.push(
|
|
500
500
|
Q("setting_not_for_card", {
|
|
501
|
-
message: `${G(e.title)} is ${Pn(a)}, which has no ${qn[
|
|
502
|
-
path: `${s.path}.${
|
|
503
|
-
fix: i.length ? `Leave out ${
|
|
501
|
+
message: `${G(e.title)} is ${Pn(a)}, which has no ${qn[g]}.`,
|
|
502
|
+
path: `${s.path}.${g}`,
|
|
503
|
+
fix: i.length ? `Leave out ${g}; this card takes ${i.join(", ")}.` : `Leave out ${g}.`,
|
|
504
504
|
allowed: i,
|
|
505
505
|
suggestedChange: Ln(s, t, d)
|
|
506
506
|
})
|
|
507
507
|
);
|
|
508
508
|
if (d.length) return {};
|
|
509
|
-
const l = {}, c = ((
|
|
509
|
+
const l = {}, c = ((v = qe(e)) == null ? void 0 : v.properties) ?? {}, h = {
|
|
510
510
|
...c,
|
|
511
511
|
...t.orientation !== void 0 ? { orientation: t.orientation } : {},
|
|
512
512
|
...t.stack !== void 0 ? { stack: t.stack } : {},
|
|
513
513
|
...t.donut !== void 0 ? { donut: t.donut } : {}
|
|
514
514
|
};
|
|
515
|
-
["orientation", "stack", "donut"].some((
|
|
516
|
-
const
|
|
515
|
+
["orientation", "stack", "donut"].some((g) => h[g] !== c[g]) && (l.variant = Rs(a.type, h));
|
|
516
|
+
const p = l.variant ? As(e, l.variant) : e, I = Ft(p);
|
|
517
517
|
if (t.totals) {
|
|
518
|
-
const
|
|
519
|
-
|
|
518
|
+
const g = Fs(e, a, t.totals, ((x = I.totals) == null ? void 0 : x.row) ?? !1, s, o);
|
|
519
|
+
g && (l.totals = g);
|
|
520
520
|
}
|
|
521
521
|
if (t.dataLabels) {
|
|
522
|
-
const
|
|
523
|
-
t.dataLabels.show !== Ds(
|
|
522
|
+
const g = {};
|
|
523
|
+
t.dataLabels.show !== Ds(p) && (g.show = t.dataLabels.show);
|
|
524
524
|
const k = t.dataLabels.format;
|
|
525
|
-
if (k === null && ((
|
|
526
|
-
const T = Bn(e, a, k, `${s.path}.dataLabels.format`,
|
|
527
|
-
T && !Pe(T, (E =
|
|
525
|
+
if (k === null && ((w = I.dataLabels) != null && w.format) && (g.format = null), k) {
|
|
526
|
+
const T = Bn(e, a, k, `${s.path}.dataLabels.format`, o);
|
|
527
|
+
T && !Pe(T, (E = I.dataLabels) == null ? void 0 : E.format) && (g.format = T);
|
|
528
528
|
}
|
|
529
|
-
Object.keys(
|
|
529
|
+
Object.keys(g).length && (l.dataLabels = g);
|
|
530
530
|
}
|
|
531
531
|
if (t.legend) {
|
|
532
|
-
const
|
|
533
|
-
t.legend.show !== ((_ =
|
|
532
|
+
const g = {};
|
|
533
|
+
t.legend.show !== ((_ = I.legend) == null ? void 0 : _.show) && (g.show = t.legend.show), t.legend.position !== void 0 && t.legend.position !== ((S = I.legend) == null ? void 0 : S.position) && (g.position = t.legend.position), Object.keys(g).length && (l.legend = g);
|
|
534
534
|
}
|
|
535
535
|
if (t.axes) {
|
|
536
|
-
const
|
|
536
|
+
const g = Os(p.type, p.preferences), k = {};
|
|
537
537
|
for (const T of ["x", "y"]) {
|
|
538
538
|
const L = t.axes[T];
|
|
539
539
|
if (!L) continue;
|
|
540
|
-
const V = Vn(e, T, L, ((y =
|
|
540
|
+
const V = Vn(e, T, L, ((y = I.axes) == null ? void 0 : y[T]) ?? {}, T === g, `${s.path}.axes.${T}`, o);
|
|
541
541
|
V && (k[Nn[T]] = V);
|
|
542
542
|
}
|
|
543
543
|
Object.keys(k).length && (l.axes = k);
|
|
544
544
|
}
|
|
545
545
|
if (t.comparisonDisplay) {
|
|
546
|
-
const
|
|
547
|
-
T !== void 0 && T !== ((
|
|
546
|
+
const g = (D = e.preferences) == null ? void 0 : D.comparisonPresentation, k = {}, { show: T, mode: L, precision: V } = t.comparisonDisplay;
|
|
547
|
+
T !== void 0 && T !== ((g == null ? void 0 : g.showComparison) ?? !0) && (k.show = T), L !== void 0 && L !== ((g == null ? void 0 : g.displayMode) ?? "difference") && (k.mode = L), V !== void 0 && V !== ((g == null ? void 0 : g.precision) ?? null) && (k.precision = V), Object.keys(k).length && (l.comparisonDisplay = k);
|
|
548
548
|
}
|
|
549
|
-
return t.inheritComparison !== void 0 && t.inheritComparison !== ((($ = e.preferences) == null ? void 0 : $.inheritGlobalComparison) !== !1) && (l.inheritComparison = t.inheritComparison), t.band !== void 0 && (t.band === "trend" && !Es(e.config) ?
|
|
549
|
+
return t.inheritComparison !== void 0 && t.inheritComparison !== ((($ = e.preferences) == null ? void 0 : $.inheritGlobalComparison) !== !1) && (l.inheritComparison = t.inheritComparison), t.band !== void 0 && (t.band === "trend" && !Es(e.config) ? o.push(
|
|
550
550
|
Q("value_invalid", {
|
|
551
551
|
message: `${G(e.title)} has no Trend By date, so it has no trend to show.`,
|
|
552
552
|
path: `${s.path}.band`,
|
|
@@ -555,51 +555,51 @@ function Mn(e, a, t, s, n) {
|
|
|
555
555
|
})
|
|
556
556
|
) : t.band !== (((N = e.config) == null ? void 0 : N.kpiBand) ?? "automatic") && (l.band = t.band === "automatic" ? null : t.band)), l;
|
|
557
557
|
}
|
|
558
|
-
function Bn(e, a, t, s,
|
|
559
|
-
const
|
|
560
|
-
if (!i.includes(
|
|
558
|
+
function Bn(e, a, t, s, o) {
|
|
559
|
+
const n = String(t.type), i = Ns("cartesian", "number"), d = Me(n), l = d == null ? void 0 : d.safeParse(t);
|
|
560
|
+
if (!i.includes(n) || !(l != null && l.success)) {
|
|
561
561
|
const h = l && !l.success ? l.error.issues[0] : void 0;
|
|
562
|
-
|
|
562
|
+
o.push(
|
|
563
563
|
Q("format_invalid", {
|
|
564
|
-
message: i.includes(
|
|
564
|
+
message: i.includes(n) ? `That format for the values on ${G(e.title)} isn't valid: ${(h == null ? void 0 : h.message) ?? "invalid"}.` : `The values on ${G(e.title)} are numbers, so they can't take a ${n.replace("_", " ")} format.`,
|
|
565
565
|
path: s,
|
|
566
566
|
fix: "Send a whole number, currency, percent, scientific or duration format.",
|
|
567
|
-
allowed: i.includes(
|
|
567
|
+
allowed: i.includes(n) ? ze(n) : [...i]
|
|
568
568
|
})
|
|
569
569
|
);
|
|
570
570
|
return;
|
|
571
571
|
}
|
|
572
572
|
const c = Pa({ surface: a.type === "pie" ? "pie" : "cartesian", value: "number", rawValueKinds: [] }, l.data);
|
|
573
573
|
if (!c.ok) {
|
|
574
|
-
|
|
574
|
+
o.push(Q("format_invalid", { message: `${G(e.title)} can't draw that format on its values: ${c.reason}.`, path: s }));
|
|
575
575
|
return;
|
|
576
576
|
}
|
|
577
577
|
return l.data;
|
|
578
578
|
}
|
|
579
|
-
function Vn(e, a, t, s,
|
|
579
|
+
function Vn(e, a, t, s, o, n, i) {
|
|
580
580
|
const d = {};
|
|
581
|
-
t.title !== void 0 && (t.title !== null && !t.title.trim() ? i.push(Q("value_invalid", { message: "An axis title can't be empty.", path: `${
|
|
581
|
+
t.title !== void 0 && (t.title !== null && !t.title.trim() ? i.push(Q("value_invalid", { message: "An axis title can't be empty.", path: `${n}.title`, fix: "Send a title, or null for none." })) : (t.title ?? void 0) !== s.title && (d.title = t.title));
|
|
582
582
|
const l = ["min", "max"].filter((c) => t[c] !== void 0 && t[c] !== null);
|
|
583
|
-
if (!
|
|
583
|
+
if (!o && l.length) {
|
|
584
584
|
const c = gt[a === "x" ? "y" : "x"];
|
|
585
585
|
i.push(
|
|
586
586
|
Q("setting_not_for_card", {
|
|
587
587
|
message: `${G(e.title)}'s ${gt[a]} axis lists categories; set a range on its ${c} axis.`,
|
|
588
|
-
path: `${
|
|
588
|
+
path: `${n}.${l[0]}`,
|
|
589
589
|
allowed: ["title"]
|
|
590
590
|
})
|
|
591
591
|
);
|
|
592
592
|
return;
|
|
593
593
|
}
|
|
594
|
-
if (
|
|
595
|
-
for (const
|
|
596
|
-
const
|
|
597
|
-
if (
|
|
598
|
-
if (
|
|
599
|
-
i.push(Q("value_invalid", { message: `An axis ${
|
|
594
|
+
if (o) {
|
|
595
|
+
for (const p of ["min", "max"]) {
|
|
596
|
+
const I = t[p];
|
|
597
|
+
if (I !== void 0) {
|
|
598
|
+
if (I !== null && !Number.isFinite(I)) {
|
|
599
|
+
i.push(Q("value_invalid", { message: `An axis ${p} must be a number.`, path: `${n}.${p}` }));
|
|
600
600
|
return;
|
|
601
601
|
}
|
|
602
|
-
(
|
|
602
|
+
(I ?? void 0) !== s[p] && (d[p] = I);
|
|
603
603
|
}
|
|
604
604
|
}
|
|
605
605
|
const c = t.min !== void 0 ? t.min : s.min, h = t.max !== void 0 ? t.max : s.max;
|
|
@@ -607,7 +607,7 @@ function Vn(e, a, t, s, n, o, i) {
|
|
|
607
607
|
i.push(
|
|
608
608
|
Q("value_invalid", {
|
|
609
609
|
message: `The ${gt[a]} axis of ${G(e.title)} can't start at ${c} and end at ${h}.`,
|
|
610
|
-
path:
|
|
610
|
+
path: n,
|
|
611
611
|
fix: "Send a min no greater than the max."
|
|
612
612
|
})
|
|
613
613
|
);
|
|
@@ -616,47 +616,47 @@ function Vn(e, a, t, s, n, o, i) {
|
|
|
616
616
|
}
|
|
617
617
|
return Object.keys(d).length ? d : void 0;
|
|
618
618
|
}
|
|
619
|
-
function $a(e, a, t, s,
|
|
620
|
-
const
|
|
619
|
+
function $a(e, a, t, s, o) {
|
|
620
|
+
const n = o === "date" && s.role === "dimension";
|
|
621
621
|
return Q("setting_not_for_card", {
|
|
622
|
-
message:
|
|
622
|
+
message: o === "text" ? `${a} on ${G(e.title)} shows its text as it is; text formats apply on a Matrix only.` : o === "category" ? `${a} labels the categories of ${G(e.title)}, which a chart shows as the query returns them; format it on a table or a Matrix.` : `${G(e.title)} shows ${a}, ${is(s)}, without a format of its own; this card type doesn't apply one.`,
|
|
623
623
|
path: t,
|
|
624
|
-
...
|
|
624
|
+
...n ? { fix: `Group ${a} by day, week, month, quarter or year to format its dates.` } : {}
|
|
625
625
|
});
|
|
626
626
|
}
|
|
627
627
|
const is = (e) => e.granularity ? `a date grouped by ${e.granularity}` : e.dataType ? `a ${e.dataType.toLowerCase()}` : "this column";
|
|
628
|
-
function
|
|
628
|
+
function ke(e, a) {
|
|
629
629
|
return `${e}.columns[${JSON.stringify(a)}]`;
|
|
630
630
|
}
|
|
631
631
|
function St(e, a, t, s) {
|
|
632
|
-
const { [s]:
|
|
633
|
-
return Object.keys(
|
|
632
|
+
const { [s]: o, ...n } = t;
|
|
633
|
+
return Object.keys(n).length ? { op: "card.update", cardId: e.cardRef, columns: { [a]: n } } : void 0;
|
|
634
634
|
}
|
|
635
635
|
function jn(e, a, t) {
|
|
636
|
-
const { hidden: s, width:
|
|
637
|
-
return Object.keys(
|
|
636
|
+
const { hidden: s, width: o, ...n } = t;
|
|
637
|
+
return Object.keys(n).length ? { op: "card.update", cardId: e.cardRef, columns: { [a]: n } } : void 0;
|
|
638
638
|
}
|
|
639
639
|
function We(e, a, t) {
|
|
640
640
|
return { op: "card.update", cardId: e.cardRef, columns: { [a]: { format: t } } };
|
|
641
641
|
}
|
|
642
|
-
function Kn(e, a, t, s,
|
|
642
|
+
function Kn(e, a, t, s, o, n, i) {
|
|
643
643
|
var c;
|
|
644
|
-
const d =
|
|
644
|
+
const d = o.label;
|
|
645
645
|
if (d === void 0 || d === t.label) return;
|
|
646
|
-
const l = `${
|
|
646
|
+
const l = `${ke(n.path, s)}.label`;
|
|
647
647
|
if (!a.settings.has("columns.label") || !t.labelKey) {
|
|
648
648
|
i.push(
|
|
649
649
|
Q("setting_not_for_card", {
|
|
650
650
|
message: a.sql ? `${G(e.title)}'s column ${s} takes its header from the query; rename it in the SQL.` : `${s} on ${G(e.title)} takes no header of its own.`,
|
|
651
651
|
path: l,
|
|
652
652
|
allowed: ["hidden", "width", "format"].filter((h) => h !== "hidden" || a.settings.has("columns.hidden")),
|
|
653
|
-
suggestedChange: St(
|
|
653
|
+
suggestedChange: St(n, s, o, "label")
|
|
654
654
|
})
|
|
655
655
|
);
|
|
656
656
|
return;
|
|
657
657
|
}
|
|
658
658
|
if (d === null) {
|
|
659
|
-
const h = ((c = En(e, t.ref,
|
|
659
|
+
const h = ((c = En(e, t.ref, n.catalogs)) == null ? void 0 : c.label) || t.field || t.label;
|
|
660
660
|
return t.labelInherited && t.label === h ? void 0 : { key: t.labelKey, label: h, origin: "semantic" };
|
|
661
661
|
}
|
|
662
662
|
if (!d.trim()) {
|
|
@@ -665,48 +665,48 @@ function Kn(e, a, t, s, n, o, i) {
|
|
|
665
665
|
}
|
|
666
666
|
return { key: t.labelKey, label: d };
|
|
667
667
|
}
|
|
668
|
-
function Wn(e, a, t, s,
|
|
669
|
-
var
|
|
670
|
-
const d = `${
|
|
668
|
+
function Wn(e, a, t, s, o, n, i) {
|
|
669
|
+
var g, k;
|
|
670
|
+
const d = `${ke(n.path, s)}.format`;
|
|
671
671
|
if (!a.settings.has("columns.format")) {
|
|
672
672
|
i.push(Q("setting_not_for_card", { message: `${G(e.title)} takes no column formats.`, path: d }));
|
|
673
673
|
return;
|
|
674
674
|
}
|
|
675
|
-
const l = t.ref, c = ((
|
|
675
|
+
const l = t.ref, c = ((g = n.modelFormats) == null ? void 0 : g.status) === "read" ? n.modelFormats.formats : void 0, h = l.kind === "matrixLevel" ? c == null ? void 0 : c[l.levelId] : l.kind === "matrixMeasure" ? c == null ? void 0 : c[l.measureId] : void 0, p = Vo({
|
|
676
676
|
card: e,
|
|
677
677
|
column: l,
|
|
678
678
|
...c ? { modelFormats: c } : {},
|
|
679
679
|
...h ? { catalogFormat: h } : {}
|
|
680
|
-
}),
|
|
681
|
-
if (
|
|
682
|
-
if (
|
|
683
|
-
const
|
|
684
|
-
if (
|
|
685
|
-
i.push($a(e, s, d, t,
|
|
680
|
+
}), I = p.source === "override" ? p.format : void 0;
|
|
681
|
+
if (o === null) return I ? null : void 0;
|
|
682
|
+
if (I && Pe(o, I)) return;
|
|
683
|
+
const v = js(e, a, t, n.sqlResultColumns), x = v.value, w = Ks(v);
|
|
684
|
+
if (w.length === 0) {
|
|
685
|
+
i.push($a(e, s, d, t, x));
|
|
686
686
|
return;
|
|
687
687
|
}
|
|
688
|
-
const E = !("type" in
|
|
689
|
-
if (E && !
|
|
690
|
-
const T =
|
|
688
|
+
const E = !("type" in o) || o.type === void 0;
|
|
689
|
+
if (E && !p.format) {
|
|
690
|
+
const T = w[0];
|
|
691
691
|
i.push(
|
|
692
692
|
Q("format_invalid", {
|
|
693
693
|
// Unavailable is not "none": say which, so the agent knows the column may have a model format (ledger P2-20).
|
|
694
|
-
message: ((k =
|
|
694
|
+
message: ((k = n.modelFormats) == null ? void 0 : k.status) === "unavailable" ? `${s} on ${G(e.title)} may follow its model's format, which couldn't be read; state the whole format with its type.` : `${s} on ${G(e.title)} has no format to change; state the whole format with its type.`,
|
|
695
695
|
path: d,
|
|
696
696
|
fix: "Add `type` to the format.",
|
|
697
697
|
allowed: ze(T),
|
|
698
|
-
suggestedChange: We(
|
|
698
|
+
suggestedChange: We(n, s, { type: T, ...o })
|
|
699
699
|
})
|
|
700
700
|
);
|
|
701
701
|
return;
|
|
702
702
|
}
|
|
703
|
-
const _ = E ? { ...
|
|
704
|
-
if (!
|
|
703
|
+
const _ = E ? { ...p.format, ...o } : o, S = String(_.type);
|
|
704
|
+
if (!w.includes(S)) {
|
|
705
705
|
i.push(
|
|
706
706
|
S === "string" ? $a(e, s, `${d}.type`, t, "text") : Q("format_invalid", {
|
|
707
|
-
message:
|
|
707
|
+
message: x === "result" ? `${s} on ${G(e.title)} comes straight from the query, so it can't take a ${S.replace("_", " ")} format.` : `${s} on ${G(e.title)} is ${is(t)}, so it can't take a ${S.replace("_", " ")} format.`,
|
|
708
708
|
path: `${d}.type`,
|
|
709
|
-
allowed: [...
|
|
709
|
+
allowed: [...w]
|
|
710
710
|
})
|
|
711
711
|
);
|
|
712
712
|
return;
|
|
@@ -720,7 +720,7 @@ function Wn(e, a, t, s, n, o, i) {
|
|
|
720
720
|
path: d,
|
|
721
721
|
fix: Hn(S),
|
|
722
722
|
allowed: y ? ze(S) : [...cn],
|
|
723
|
-
...
|
|
723
|
+
...p.format ? { suggestedChange: We(n, s, p.format) } : {}
|
|
724
724
|
})
|
|
725
725
|
);
|
|
726
726
|
return;
|
|
@@ -735,13 +735,13 @@ function Wn(e, a, t, s, n, o, i) {
|
|
|
735
735
|
message: `${s} on ${G(e.title)} is grouped by ${t.granularity}, which that date format doesn't fit.`,
|
|
736
736
|
path: d,
|
|
737
737
|
allowed: L,
|
|
738
|
-
suggestedChange: We(
|
|
738
|
+
suggestedChange: We(n, s, { type: "temporal_bucket", presentation: { mode: "preset", preset: L[0] ?? "short" } })
|
|
739
739
|
})
|
|
740
740
|
);
|
|
741
741
|
return;
|
|
742
742
|
}
|
|
743
743
|
if ($.type === "date") {
|
|
744
|
-
const T =
|
|
744
|
+
const T = o, L = p.format ?? {}, V = Object.keys(T).filter((K) => !ca.includes(K) && !Pe(T[K], L[K]));
|
|
745
745
|
if (V.length) {
|
|
746
746
|
const K = Object.fromEntries(Object.entries($).filter(([B]) => !V.includes(B)));
|
|
747
747
|
i.push(
|
|
@@ -750,13 +750,13 @@ function Wn(e, a, t, s, n, o, i) {
|
|
|
750
750
|
path: d,
|
|
751
751
|
fix: `Leave out ${V.join(", ")}.`,
|
|
752
752
|
allowed: ca.filter((B) => B !== "type"),
|
|
753
|
-
suggestedChange: We(
|
|
753
|
+
suggestedChange: We(n, s, K)
|
|
754
754
|
})
|
|
755
755
|
);
|
|
756
756
|
return;
|
|
757
757
|
}
|
|
758
758
|
}
|
|
759
|
-
const N = Pa(
|
|
759
|
+
const N = Pa(v, $);
|
|
760
760
|
if (!N.ok) {
|
|
761
761
|
i.push(
|
|
762
762
|
Q("format_invalid", {
|
|
@@ -768,71 +768,71 @@ function Wn(e, a, t, s, n, o, i) {
|
|
|
768
768
|
);
|
|
769
769
|
return;
|
|
770
770
|
}
|
|
771
|
-
return
|
|
771
|
+
return I && Pe(I, $) ? void 0 : $;
|
|
772
772
|
}
|
|
773
|
-
function Un(e, a, t, s,
|
|
774
|
-
var
|
|
775
|
-
const d =
|
|
773
|
+
function Un(e, a, t, s, o, n, i) {
|
|
774
|
+
var w, E;
|
|
775
|
+
const d = o.polarity;
|
|
776
776
|
if (d === void 0) return;
|
|
777
|
-
const l = `${
|
|
777
|
+
const l = `${ke(n.path, s)}.polarity`, c = t.ref;
|
|
778
778
|
if (!(a.settings.has("columns.polarity") && (c.kind === "sqlKpiValue" || c.kind === "field" && t.role === "measure"))) {
|
|
779
779
|
i.push(
|
|
780
780
|
Q("setting_not_for_card", {
|
|
781
781
|
message: t.role === "measure" || t.role === "value" ? `${G(e.title)} shows no comparison, so ${s} has no favorable direction.` : `${s} on ${G(e.title)} isn't a measure, so it has no favorable direction.`,
|
|
782
782
|
path: l,
|
|
783
783
|
fix: "Leave out polarity.",
|
|
784
|
-
suggestedChange: St(
|
|
784
|
+
suggestedChange: St(n, s, o, "polarity")
|
|
785
785
|
})
|
|
786
786
|
);
|
|
787
787
|
return;
|
|
788
788
|
}
|
|
789
|
-
const
|
|
790
|
-
if (d === null) return
|
|
791
|
-
if (
|
|
789
|
+
const p = c.kind === "field" ? (E = (w = e.config) == null ? void 0 : w.metricColumns) == null ? void 0 : E.find((_) => _.id === c.fieldId) : void 0, I = c.kind === "sqlKpiValue" ? La(e) : void 0, v = c.kind === "sqlKpiValue" ? (I == null ? void 0 : I.source) === "sql" && I.polarity !== va ? I.polarity : void 0 : p == null ? void 0 : p.comparisonPolarity, x = p == null ? void 0 : p.semanticComparisonPolarity;
|
|
790
|
+
if (d === null) return v ? null : void 0;
|
|
791
|
+
if (x && d !== x) {
|
|
792
792
|
i.push(
|
|
793
793
|
Q("polarity_set_by_model", {
|
|
794
|
-
message: `The model says ${s} is ${
|
|
794
|
+
message: `The model says ${s} is ${x.replace(/_/g, " ")}; a card can't say otherwise.`,
|
|
795
795
|
path: l,
|
|
796
796
|
fix: "Change it in the model, or leave polarity out.",
|
|
797
|
-
allowed: [
|
|
798
|
-
suggestedChange: St(
|
|
797
|
+
allowed: [x],
|
|
798
|
+
suggestedChange: St(n, s, o, "polarity")
|
|
799
799
|
})
|
|
800
800
|
);
|
|
801
801
|
return;
|
|
802
802
|
}
|
|
803
|
-
return d === (
|
|
803
|
+
return d === (x ?? v ?? va) ? void 0 : d;
|
|
804
804
|
}
|
|
805
|
-
function Gn(e, a, t, s,
|
|
806
|
-
var h,
|
|
807
|
-
if (
|
|
808
|
-
const l =
|
|
805
|
+
function Gn(e, a, t, s, o, n, i, d) {
|
|
806
|
+
var h, p, I;
|
|
807
|
+
if (o.hidden === void 0 && o.width === void 0) return {};
|
|
808
|
+
const l = ke(i.path, s);
|
|
809
809
|
if (!a.settings.has("columns.hidden") || t.resultKey === void 0) {
|
|
810
|
-
const
|
|
810
|
+
const v = a.pivoted && t.role === "measure";
|
|
811
811
|
return d.push(
|
|
812
812
|
Q("setting_not_for_card", {
|
|
813
|
-
message:
|
|
814
|
-
path: `${l}.${
|
|
815
|
-
allowed:
|
|
816
|
-
suggestedChange: jn(i, s,
|
|
813
|
+
message: v ? `${s} on ${G(e.title)} has a column for each pivot value; hide or size them in the editor.` : `${G(e.title)} has no hidden columns or column widths; those are for tables.`,
|
|
814
|
+
path: `${l}.${o.hidden !== void 0 ? "hidden" : "width"}`,
|
|
815
|
+
allowed: v ? ["label", "format"] : ["label", "format"].filter((x) => a.settings.has(`columns.${x}`)),
|
|
816
|
+
suggestedChange: jn(i, s, o)
|
|
817
817
|
})
|
|
818
818
|
), {};
|
|
819
819
|
}
|
|
820
820
|
const c = {};
|
|
821
|
-
if (
|
|
822
|
-
const { minSize:
|
|
823
|
-
|
|
821
|
+
if (o.hidden !== void 0 && o.hidden !== ((n == null ? void 0 : n.hidden) === !0) && (c.hidden = o.hidden), o.width !== void 0 && o.width !== ((n == null ? void 0 : n.width) ?? null)) {
|
|
822
|
+
const { minSize: v, maxSize: x } = Vs((I = (p = (h = e.preferences) == null ? void 0 : h.tablePrefs) == null ? void 0 : p.columnSettingsMap) == null ? void 0 : I[t.resultKey]);
|
|
823
|
+
o.width !== null && (!Number.isFinite(o.width) || o.width < v || o.width > x) ? d.push(
|
|
824
824
|
Q("value_invalid", {
|
|
825
|
-
message: `${s} on ${G(e.title)} can be ${
|
|
825
|
+
message: `${s} on ${G(e.title)} can be ${v} to ${x} pixels wide.`,
|
|
826
826
|
path: `${l}.width`,
|
|
827
|
-
fix: `Send a width from ${
|
|
827
|
+
fix: `Send a width from ${v} to ${x} pixels, or null for automatic.`
|
|
828
828
|
})
|
|
829
|
-
) : c.width =
|
|
829
|
+
) : c.width = o.width;
|
|
830
830
|
}
|
|
831
831
|
return c;
|
|
832
832
|
}
|
|
833
833
|
function Qn(e, a, t) {
|
|
834
834
|
var E, _, S, y;
|
|
835
|
-
const { columns: s = {}, ...
|
|
835
|
+
const { columns: s = {}, ...o } = a.settings ?? {}, n = [], i = xt.some((D) => o[D] !== void 0), d = !!((_ = (E = a.highlights) == null ? void 0 : E.add) != null && _.length || (y = (S = a.highlights) == null ? void 0 : S.remove) != null && y.length);
|
|
836
836
|
if (!Object.keys(s).length && !i && !d) return { ok: !0, labels: [], settings: null, warnings: [] };
|
|
837
837
|
const l = Ps(e);
|
|
838
838
|
if (!l)
|
|
@@ -840,49 +840,49 @@ function Qn(e, a, t) {
|
|
|
840
840
|
ok: !1,
|
|
841
841
|
problems: [Q("setting_not_for_card", { message: `${G(e.title)} takes no card settings through this tool.`, path: t.path })]
|
|
842
842
|
};
|
|
843
|
-
const c = Mn(e, l,
|
|
843
|
+
const c = Mn(e, l, o, t, n), h = Ls(e, l, t.sqlResultColumns), p = d ? Ms(e, l, h, a.highlights, t, n) : void 0, I = Ft(e), v = [], x = [];
|
|
844
844
|
for (const [D, $] of Object.entries(s)) {
|
|
845
|
-
const N = Bs(h, D, { path:
|
|
845
|
+
const N = Bs(h, D, { path: ke(t.path, D), cardTitle: G(e.title) });
|
|
846
846
|
if (!N.ok) {
|
|
847
|
-
|
|
847
|
+
n.push(N.problem);
|
|
848
848
|
continue;
|
|
849
849
|
}
|
|
850
|
-
const
|
|
851
|
-
if (
|
|
852
|
-
|
|
850
|
+
const g = N.column;
|
|
851
|
+
if (g.sqlName === "inferred") {
|
|
852
|
+
n.push(
|
|
853
853
|
Q("columns_unavailable", {
|
|
854
854
|
message: `${G(e.title)}'s columns weren't read from its query, so ${D} can't be checked.`,
|
|
855
|
-
path:
|
|
855
|
+
path: ke(t.path, D),
|
|
856
856
|
fix: "Check that the card runs and returns rows, then propose again."
|
|
857
857
|
})
|
|
858
858
|
);
|
|
859
859
|
continue;
|
|
860
860
|
}
|
|
861
|
-
const k = Kn(e, l,
|
|
862
|
-
k &&
|
|
863
|
-
const T = Gn(e, l,
|
|
864
|
-
column:
|
|
861
|
+
const k = Kn(e, l, g, D, $, t, n);
|
|
862
|
+
k && v.push(k);
|
|
863
|
+
const T = Gn(e, l, g, D, $, I.columns[g.name], t, n), L = $.format !== void 0 ? Wn(e, l, g, D, $.format, t, n) : void 0, V = Un(e, l, g, D, $, t, n), K = {
|
|
864
|
+
column: g.ref,
|
|
865
865
|
...T,
|
|
866
866
|
...L !== void 0 ? { format: L } : {},
|
|
867
867
|
...V !== void 0 ? { polarity: V } : {}
|
|
868
868
|
};
|
|
869
|
-
Object.keys(K).length > 1 &&
|
|
869
|
+
Object.keys(K).length > 1 && x.push(K);
|
|
870
870
|
}
|
|
871
|
-
if (
|
|
872
|
-
const
|
|
873
|
-
return { ok: !0, labels:
|
|
871
|
+
if (n.length) return { ok: !1, problems: n };
|
|
872
|
+
const w = { ...c, ...x.length ? { columns: x } : {}, ...p ? { highlights: p } : {} };
|
|
873
|
+
return { ok: !0, labels: v, settings: Object.keys(w).length ? w : null, warnings: [] };
|
|
874
874
|
}
|
|
875
875
|
function Hn(e) {
|
|
876
876
|
const a = Me(e), t = a && a === Me("number") ? ua.number : e === "temporal_bucket" || e === "date" ? ua[e] : void 0;
|
|
877
877
|
return t ? `Send a stored format: ${t}.` : "Send the format in the stored shape the outline shows.";
|
|
878
878
|
}
|
|
879
|
-
function zn(e, a, t, s,
|
|
879
|
+
function zn(e, a, t, s, o) {
|
|
880
880
|
var _, S, y, D, $, N;
|
|
881
|
-
const
|
|
882
|
-
if (!
|
|
883
|
-
const i =
|
|
881
|
+
const n = we(e, { sql: !0, calculations: !1 });
|
|
882
|
+
if (!n.editable) return [n.message];
|
|
883
|
+
const i = n.query, d = a;
|
|
884
884
|
if ("sql" in a) return d.sql === i.sql && d.connectionId === i.connectionId ? [] : ["the SQL"];
|
|
885
|
-
const l = (s == null ? void 0 : s.source.kind) === "semantic" ?
|
|
885
|
+
const l = (s == null ? void 0 : s.source.kind) === "semantic" ? we({
|
|
886
886
|
id: e.id,
|
|
887
887
|
title: e.title,
|
|
888
888
|
type: s.type,
|
|
@@ -891,45 +891,45 @@ function zn(e, a, t, s, n) {
|
|
|
891
891
|
config: s.config
|
|
892
892
|
}, { sql: !0, calculations: !1 }) : void 0;
|
|
893
893
|
if (l && !l.editable) return ["the compiled query"];
|
|
894
|
-
const c = l != null && l.editable ? l.query : void 0, h = String(d.datasetName ?? ""),
|
|
894
|
+
const c = l != null && l.editable ? l.query : void 0, h = String(d.datasetName ?? ""), p = [], I = (g) => be(g, h), v = (g, k, T) => {
|
|
895
895
|
const L = k ?? [], V = T ?? [];
|
|
896
|
-
(L.length !== V.length || L.some((K, B) =>
|
|
896
|
+
(L.length !== V.length || L.some((K, B) => I(K) !== I(V[B]))) && p.push(g);
|
|
897
897
|
};
|
|
898
|
-
for (const
|
|
899
|
-
if (
|
|
900
|
-
const
|
|
901
|
-
|
|
898
|
+
for (const g of ["domainId", "datasetName"]) d[g] !== i[g] && p.push(g);
|
|
899
|
+
if (v("measures", d.measures, i.measures), v("columns", d.columns, i.columns), t || n.matrix) {
|
|
900
|
+
const g = (T) => new Set(((T == null ? void 0 : T.columns) ?? []).map(I)), k = (T, L) => (T ?? []).filter((V) => !g(L).has(I(V)));
|
|
901
|
+
v("dimensions", k(d.dimensions, t), k(i.dimensions, n.matrix)), v("matrix.columns", t == null ? void 0 : t.columns, (_ = n.matrix) == null ? void 0 : _.columns);
|
|
902
902
|
} else
|
|
903
|
-
|
|
904
|
-
const
|
|
905
|
-
|
|
906
|
-
const E = (S = e.config) != null && S.matrix ? e.config.matrix.spec.measures.map((
|
|
907
|
-
(d.measures ?? []).forEach((
|
|
908
|
-
const T =
|
|
909
|
-
T && _a(E[k] ?? {}) !== T &&
|
|
903
|
+
v("dimensions", d.dimensions, i.dimensions);
|
|
904
|
+
const x = d.timeWindow !== void 0 && !d.timeGrain, w = x && i.timeWindow === void 0 ? void 0 : x && d.dateField === void 0 ? c == null ? void 0 : c.dateField : d.dateField;
|
|
905
|
+
w !== void 0 && (i.dateField === void 0 || I(w) !== I(i.dateField)) && p.push("dateField"), d.timeGrain !== void 0 && d.timeGrain !== i.timeGrain && p.push("timeGrain");
|
|
906
|
+
const E = (S = e.config) != null && S.matrix ? e.config.matrix.spec.measures.map((g) => g.kind === "aggregate" ? { aggregate: g.aggregate } : {}) : ((y = e.config) == null ? void 0 : y.metricColumns) ?? [];
|
|
907
|
+
(d.measures ?? []).forEach((g, k) => {
|
|
908
|
+
const T = g && typeof g == "object" ? g.aggregate : void 0;
|
|
909
|
+
T && _a(E[k] ?? {}) !== T && p.push(`the aggregate of measures[${k}]`);
|
|
910
910
|
});
|
|
911
|
-
for (const { key:
|
|
912
|
-
Ws(e,
|
|
913
|
-
if (!
|
|
914
|
-
const
|
|
911
|
+
for (const { key: g, label: k } of Ne(a))
|
|
912
|
+
Ws(e, g) !== k && p.push(`the label "${k}"`);
|
|
913
|
+
if (!o || o.aspects.includes("filters")) {
|
|
914
|
+
const g = d.filters ?? [];
|
|
915
915
|
let k = i.filters ?? [];
|
|
916
916
|
const T = d.timeWindow, L = i.timeWindow, V = (K, B) => {
|
|
917
917
|
const se = (oe) => JSON.stringify((oe ?? []).map(String));
|
|
918
|
-
return
|
|
918
|
+
return I(K.field) === I(B.field) && K.operator === B.operator && (K.scope ?? "row") === (B.scope ?? "row") && (typeof K.field == "object" ? K.field.aggregate : void 0) === (typeof B.field == "object" ? B.field.aggregate : void 0) && (K.values === void 0 || se(K.values) === se(B.values));
|
|
919
919
|
};
|
|
920
920
|
if (T && !L) {
|
|
921
921
|
const K = ((c == null ? void 0 : c.filters) ?? []).filter(
|
|
922
|
-
(B) => !(c != null && c.timeWindow) && !
|
|
922
|
+
(B) => !(c != null && c.timeWindow) && !g.some((se) => V(se, B))
|
|
923
923
|
);
|
|
924
|
-
(!K.length || K.some((B) => !k.some((se) => V(B, se)))) &&
|
|
925
|
-
} else T ? en(d.timeWindow, i.timeWindow) ||
|
|
926
|
-
(
|
|
924
|
+
(!K.length || K.some((B) => !k.some((se) => V(B, se)))) && p.push("timeWindow"), k = k.filter((B) => !K.some((se) => V(se, B)));
|
|
925
|
+
} else T ? en(d.timeWindow, i.timeWindow) || p.push("timeWindow") : L && p.push("timeWindow");
|
|
926
|
+
(g.length !== k.length || g.some((K, B) => !V(K, k[B]))) && p.push("filters");
|
|
927
927
|
}
|
|
928
928
|
if (d.orderBy !== void 0) {
|
|
929
|
-
const
|
|
930
|
-
(!k || !T || k.direction !==
|
|
929
|
+
const g = d.orderBy, k = ($ = (D = e.config) == null ? void 0 : D.sortByColumns) == null ? void 0 : $[0], T = k && Us(e.config ?? {}, k), L = g.field && typeof g.field == "object" ? g.field.aggregate : void 0;
|
|
930
|
+
(!k || !T || k.direction !== g.direction || I(g.field) !== Gs(T.name, Na(T)) || L !== void 0 && _a(T) !== L) && p.push("orderBy");
|
|
931
931
|
}
|
|
932
|
-
return d.limit !== void 0 && ((N = e.config) == null ? void 0 : N.rowLimit) !== d.limit &&
|
|
932
|
+
return d.limit !== void 0 && ((N = e.config) == null ? void 0 : N.rowLimit) !== d.limit && p.push("limit"), p;
|
|
933
933
|
}
|
|
934
934
|
function kt(e) {
|
|
935
935
|
const a = Wa({ variables: [e] })[0];
|
|
@@ -946,19 +946,19 @@ function Je(e, a) {
|
|
|
946
946
|
}
|
|
947
947
|
function Yn(e, a, t, s) {
|
|
948
948
|
var i;
|
|
949
|
-
const
|
|
950
|
-
|
|
951
|
-
const
|
|
952
|
-
return ((i =
|
|
949
|
+
const o = Je(e, a);
|
|
950
|
+
o || s.problem(ls(e, a, t));
|
|
951
|
+
const n = rs(o, { sql: !0 });
|
|
952
|
+
return ((i = n.source) == null ? void 0 : i.kind) === "sql" && s.need(t), n.editable || s.problem({
|
|
953
953
|
code: "variable_not_editable",
|
|
954
|
-
message:
|
|
954
|
+
message: n.message,
|
|
955
955
|
path: t,
|
|
956
956
|
fix: "Tell the user to change it in the editor; removing it works.",
|
|
957
|
-
details: { reason:
|
|
958
|
-
}),
|
|
957
|
+
details: { reason: n.reason }
|
|
958
|
+
}), o;
|
|
959
959
|
}
|
|
960
960
|
function ls(e, a, t) {
|
|
961
|
-
const s = (e.variables ?? []).map((
|
|
961
|
+
const s = (e.variables ?? []).map((o) => o.name);
|
|
962
962
|
return {
|
|
963
963
|
code: "variable_unknown",
|
|
964
964
|
message: `No variable named ${a} on this dashboard.`,
|
|
@@ -978,7 +978,7 @@ function cs(e, a) {
|
|
|
978
978
|
}
|
|
979
979
|
async function wa(e, a, t) {
|
|
980
980
|
var y, D;
|
|
981
|
-
const { problem: s, need:
|
|
981
|
+
const { problem: s, need: o, services: n } = t, { path: i, query: d } = e, l = ds(e.get), c = {
|
|
982
982
|
id: e.id,
|
|
983
983
|
name: e.name,
|
|
984
984
|
...e.label ? { label: e.label } : {},
|
|
@@ -988,55 +988,55 @@ async function wa(e, a, t) {
|
|
|
988
988
|
sql: ""
|
|
989
989
|
};
|
|
990
990
|
if ("sql" in d)
|
|
991
|
-
return
|
|
991
|
+
return o(`${i}.query`), l.kind !== "only" && l.kind !== "first" && s({
|
|
992
992
|
code: "invalid_change",
|
|
993
993
|
message: "A SQL variable takes the only row or the first row of its result.",
|
|
994
994
|
path: `${i}.get`,
|
|
995
995
|
fix: 'Send get: "only" or "first", or write the aggregate or the list in the SQL itself.'
|
|
996
996
|
}), S(Ye({ ...c, mode: "sql", connectionId: d.connectionId, sql: d.sql, get: l.kind }, a));
|
|
997
|
-
const h = await
|
|
997
|
+
const h = await n.loadCardSource({ domainId: d.domainId, datasetName: d.datasetName });
|
|
998
998
|
h != null && h.dataSource || s({
|
|
999
999
|
code: "variable_source_unreachable",
|
|
1000
1000
|
message: `The dataset ${d.datasetName} isn't in the domain ${d.domainId} or in this project.`,
|
|
1001
1001
|
path: `${i}.query.datasetName`,
|
|
1002
1002
|
fix: "List the domain's datasets with semaphor_list_datasets and name one of them."
|
|
1003
1003
|
});
|
|
1004
|
-
const
|
|
1004
|
+
const p = h.fields;
|
|
1005
1005
|
for (const $ of Ma({ ...d, measures: d.measures ?? [] })) s({ ...$, path: `${i}.${$.path}` });
|
|
1006
|
-
const
|
|
1007
|
-
const
|
|
1006
|
+
const I = ($, N) => {
|
|
1007
|
+
const g = Ct($), k = Js($, d.datasetName);
|
|
1008
1008
|
k.toLowerCase() !== d.datasetName.toLowerCase() && s({
|
|
1009
1009
|
code: "field_not_found",
|
|
1010
|
-
message: `A variable reads one dataset: "${
|
|
1010
|
+
message: `A variable reads one dataset: "${g}" names ${k}, not ${d.datasetName}.`,
|
|
1011
1011
|
path: N,
|
|
1012
1012
|
fix: `Name a field of ${d.datasetName}, or set datasetName to ${k} and read its field.`
|
|
1013
1013
|
});
|
|
1014
|
-
const T = ot(
|
|
1014
|
+
const T = ot(p, g, d.datasetName);
|
|
1015
1015
|
return T || s({
|
|
1016
1016
|
code: "field_not_found",
|
|
1017
|
-
message: `"${
|
|
1017
|
+
message: `"${g}" isn't a field of ${d.datasetName}.`,
|
|
1018
1018
|
path: N,
|
|
1019
1019
|
fix: "Use one of details.available, or read semaphor_get_dataset_schema.",
|
|
1020
|
-
details: { available:
|
|
1020
|
+
details: { available: p.slice(0, 20).map((L) => L.name) }
|
|
1021
1021
|
}), T;
|
|
1022
|
-
},
|
|
1022
|
+
}, v = d.measures ?? [], x = d.dimensions ?? [], w = {
|
|
1023
1023
|
...c,
|
|
1024
1024
|
mode: "data",
|
|
1025
1025
|
dataSource: h.dataSource,
|
|
1026
1026
|
connectionId: h.connectionId,
|
|
1027
1027
|
get: "only",
|
|
1028
|
-
...(y = d.filters) != null && y.length ? { conditions: await Xn(d,
|
|
1028
|
+
...(y = d.filters) != null && y.length ? { conditions: await Xn(d, n, i, t.refuseAll) } : {}
|
|
1029
1029
|
};
|
|
1030
1030
|
if (l.kind === "aggregate") {
|
|
1031
|
-
(
|
|
1031
|
+
(v.length !== 1 || x.length) && s({
|
|
1032
1032
|
code: "invalid_change",
|
|
1033
1033
|
message: "An aggregate reads one measure and no dimension.",
|
|
1034
1034
|
path: `${i}.query`,
|
|
1035
1035
|
fix: `Send measures: [{ name, aggregate }] alone; for one field's value use get: "only", "first" or "list" with dimensions: [field].`
|
|
1036
1036
|
}), d.orderBy && s({ code: "invalid_change", message: "An aggregate is one value, so it has no order.", path: `${i}.query.orderBy`, fix: "Leave out orderBy." });
|
|
1037
|
-
const $ = v
|
|
1038
|
-
if (!Ca(k) || !
|
|
1039
|
-
const L =
|
|
1037
|
+
const $ = I(v[0], `${i}.query.measures[0]`), N = typeof v[0] == "string" ? void 0 : v[0].aggregate, g = pn($).filter((L) => Ca(L.value)), k = N ?? (ut($) ? "calculation" : gn($));
|
|
1038
|
+
if (!Ca(k) || !g.some((L) => L.value === k)) {
|
|
1039
|
+
const L = g.map((V) => V.value);
|
|
1040
1040
|
s({
|
|
1041
1041
|
code: "invalid_change",
|
|
1042
1042
|
message: N ? `${N} isn't an aggregate ${$.label || $.name} takes.` : `${$.label || $.name} needs its aggregate.`,
|
|
@@ -1045,16 +1045,16 @@ async function wa(e, a, t) {
|
|
|
1045
1045
|
allowed: L
|
|
1046
1046
|
});
|
|
1047
1047
|
}
|
|
1048
|
-
const T = Jn(
|
|
1049
|
-
return S(Ye({ ...
|
|
1048
|
+
const T = Jn(v[0], { ...w, field: $, get: k }, `${i}.query.measures[0].comparison`, s);
|
|
1049
|
+
return S(Ye({ ...w, field: $, get: k, ...T ? { comparison: T } : {} }, a));
|
|
1050
1050
|
}
|
|
1051
|
-
(
|
|
1051
|
+
(x.length !== 1 || v.length) && s({
|
|
1052
1052
|
code: "invalid_change",
|
|
1053
1053
|
message: `The ${l.kind === "only" ? "only value" : l.kind === "first" ? "first value" : "list"} reads one dimension; a measure's one value is get: "aggregate".`,
|
|
1054
1054
|
path: `${i}.query`,
|
|
1055
1055
|
fix: "Send dimensions: [field] and no measures; order the first value or the list with orderBy."
|
|
1056
1056
|
});
|
|
1057
|
-
const E =
|
|
1057
|
+
const E = I(x[0], `${i}.query.dimensions[0]`);
|
|
1058
1058
|
ut(E) && s({
|
|
1059
1059
|
code: "invalid_change",
|
|
1060
1060
|
message: `${E.label || E.name} is an aggregate calculation, so it has one value, not rows.`,
|
|
@@ -1069,12 +1069,12 @@ async function wa(e, a, t) {
|
|
|
1069
1069
|
message: "The order names a field, not an aggregate: the first value is ordered by the latest (desc) or earliest (asc) of that field per value.",
|
|
1070
1070
|
path: `${i}.query.orderBy.field`,
|
|
1071
1071
|
fix: 'Send orderBy: { field: "<field>", direction }.'
|
|
1072
|
-
}), _ =
|
|
1072
|
+
}), _ = I($, `${i}.query.orderBy.field`);
|
|
1073
1073
|
}
|
|
1074
1074
|
return S(
|
|
1075
1075
|
Ye(
|
|
1076
1076
|
{
|
|
1077
|
-
...
|
|
1077
|
+
...w,
|
|
1078
1078
|
field: E,
|
|
1079
1079
|
get: l.kind,
|
|
1080
1080
|
..._ ? { sortField: _ } : {},
|
|
@@ -1086,43 +1086,43 @@ async function wa(e, a, t) {
|
|
|
1086
1086
|
)
|
|
1087
1087
|
);
|
|
1088
1088
|
function S($) {
|
|
1089
|
-
const N = { ...$, name: e.name },
|
|
1090
|
-
return
|
|
1089
|
+
const N = { ...$, name: e.name }, g = Dt(N, a);
|
|
1090
|
+
return g.length && t.refuseAll(cs(g, i)), N;
|
|
1091
1091
|
}
|
|
1092
1092
|
}
|
|
1093
1093
|
function Jn(e, a, t, s) {
|
|
1094
|
-
var
|
|
1095
|
-
const
|
|
1096
|
-
if (!(!
|
|
1097
|
-
return
|
|
1094
|
+
var n, i;
|
|
1095
|
+
const o = typeof e == "string" ? void 0 : e.comparison;
|
|
1096
|
+
if (!(!o || o.kind === "inherit" || o.kind === "off"))
|
|
1097
|
+
return o.kind === "target" && s({
|
|
1098
1098
|
code: "invalid_change",
|
|
1099
1099
|
message: "A variable compares with an earlier period, not a target.",
|
|
1100
1100
|
path: t,
|
|
1101
1101
|
fix: "Send comparison: { kind: 'previous_period' } or { kind: 'previous_year' }; put a target in the words, or on a KPI card."
|
|
1102
1102
|
}), yn(a) || s({
|
|
1103
1103
|
code: "invalid_change",
|
|
1104
|
-
message: `${((
|
|
1104
|
+
message: `${((n = a.field) == null ? void 0 : n.label) || ((i = a.field) == null ? void 0 : i.name)} with ${String(a.get)} isn't a number, so it has no comparison.`,
|
|
1105
1105
|
path: t,
|
|
1106
1106
|
fix: "Compare a count, or a numeric field's total, average, lowest or highest; leave comparison out here."
|
|
1107
|
-
}), Xs(
|
|
1107
|
+
}), Xs(o);
|
|
1108
1108
|
}
|
|
1109
1109
|
async function Xn(e, a, t, s) {
|
|
1110
|
-
var
|
|
1111
|
-
const
|
|
1110
|
+
var n;
|
|
1111
|
+
const o = await a.compileCardQuery({
|
|
1112
1112
|
query: { domainId: e.domainId, datasetName: e.datasetName, measures: ["__count"], filters: e.filters },
|
|
1113
1113
|
chartType: "table"
|
|
1114
1114
|
});
|
|
1115
|
-
return
|
|
1115
|
+
return o.ok ? ((n = o.part.config) == null ? void 0 : n.filters) ?? null : s(o.problems.map((i) => ({ ...i, path: i.path ? `${t}.query.${i.path}` : `${t}.query.filters` })));
|
|
1116
1116
|
}
|
|
1117
|
-
function Zn(e, a, t, s,
|
|
1118
|
-
const
|
|
1119
|
-
|
|
1117
|
+
function Zn(e, a, t, s, o) {
|
|
1118
|
+
const n = ds(a), i = bn(e);
|
|
1119
|
+
n.kind === "aggregate" && e.get.kind !== "aggregate" && s.problem({ code: "invalid_change", message: `${e.name} reads a field's rows; an aggregate needs its measure.`, path: `${o}.get`, fix: 'Send query with measures: [{ name, aggregate }] and get: "aggregate".' }), n.kind !== "aggregate" && e.get.kind === "aggregate" && s.problem({ code: "invalid_change", message: `${e.name} is an aggregate; a value, the first or a list reads a dimension.`, path: `${o}.get`, fix: "Send query with dimensions: [field] and the get." }), i.mode === "sql" && n.kind !== "only" && n.kind !== "first" && s.problem({ code: "invalid_change", message: "A SQL variable takes the only row or the first row of its result.", path: `${o}.get`, fix: 'Send get: "only" or "first", or write the list in the SQL itself.' });
|
|
1120
1120
|
const d = Ye(
|
|
1121
1121
|
{
|
|
1122
1122
|
...i,
|
|
1123
1123
|
// An aggregate keeps its own function; the others are the dialog's choices by name.
|
|
1124
|
-
...
|
|
1125
|
-
...
|
|
1124
|
+
...n.kind === "aggregate" ? {} : { get: n.kind },
|
|
1125
|
+
...n.kind === "list" ? { listLimit: n.limit ?? i.listLimit, listSeparator: n.separator ?? i.listSeparator } : { listLimit: void 0, listSeparator: void 0 }
|
|
1126
1126
|
},
|
|
1127
1127
|
t
|
|
1128
1128
|
);
|
|
@@ -1132,63 +1132,63 @@ function ei(e, a) {
|
|
|
1132
1132
|
const t = Qa(e).filter(({ ref: i }) => i.source === "data" && i.variableId === a), s = (i) => {
|
|
1133
1133
|
var d;
|
|
1134
1134
|
return `"${((d = (e.sheets ?? []).find((l) => l.id === i)) == null ? void 0 : d.title) ?? i}"`;
|
|
1135
|
-
},
|
|
1135
|
+
}, o = xe(e);
|
|
1136
1136
|
return { words: [
|
|
1137
1137
|
...new Set(
|
|
1138
1138
|
t.map(
|
|
1139
1139
|
({ place: i, where: d }) => {
|
|
1140
1140
|
var l;
|
|
1141
|
-
return d.kind === "card" ? `the card "${((l =
|
|
1141
|
+
return d.kind === "card" ? `the card "${((l = o.find((c) => c.cardId === d.cardId)) == null ? void 0 : l.card.title) ?? d.cardId}"` : d.kind === "section" ? `a text section of ${s(i.sheetId)}` : `the ${d.kind} of ${s(i.sheetId)}`;
|
|
1142
1142
|
}
|
|
1143
1143
|
)
|
|
1144
1144
|
)
|
|
1145
1145
|
].join(", "), places: t };
|
|
1146
1146
|
}
|
|
1147
|
-
function ti(e, a, t, s,
|
|
1148
|
-
const { problem:
|
|
1149
|
-
(!Xe(t) || !t.document) &&
|
|
1147
|
+
function ti(e, a, t, s, o) {
|
|
1148
|
+
const { problem: n } = o;
|
|
1149
|
+
(!Xe(t) || !t.document) && n({
|
|
1150
1150
|
code: "invalid_change",
|
|
1151
1151
|
message: `"${t.title ?? t.id}" is not a Document sheet.`,
|
|
1152
1152
|
path: `${s}.sheetId`,
|
|
1153
1153
|
fix: "Name a Document sheet; a grid sheet's words are its text cards (card.update with text)."
|
|
1154
|
-
}), e.text === void 0 && e.style === void 0 &&
|
|
1154
|
+
}), e.text === void 0 && e.style === void 0 && n({ code: "invalid_change", message: "This document.text.update has neither text nor style.", path: s, fix: "Send text (the words), style ({ size, align }) or both." });
|
|
1155
1155
|
const i = t.document, d = e.target;
|
|
1156
1156
|
let l, c;
|
|
1157
1157
|
if ("sectionId" in d) {
|
|
1158
|
-
const
|
|
1159
|
-
|
|
1158
|
+
const w = i.sections.find((E) => E.id === d.sectionId);
|
|
1159
|
+
w || n({ code: "invalid_change", message: `No section ${d.sectionId} on "${t.title}".`, path: `${s}.target.sectionId`, fix: "Use a section id from the outline's textSections." }), w.type !== "text" && n({ code: "invalid_change", message: `Section ${d.sectionId} is a ${w.type} section, not text.`, path: `${s}.target.sectionId`, fix: "Name one of the outline's textSections." }), l = w.content, c = w.style;
|
|
1160
1160
|
} else {
|
|
1161
|
-
const { region:
|
|
1162
|
-
Ia[
|
|
1161
|
+
const { region: w, role: E } = d;
|
|
1162
|
+
Ia[w].includes(E) || n({
|
|
1163
1163
|
code: "invalid_change",
|
|
1164
|
-
message: `The ${
|
|
1164
|
+
message: `The ${w} has ${w === "header" ? "a title and a metadata line" : "a note and a page info line"}, not a ${E} line.`,
|
|
1165
1165
|
path: `${s}.target.role`,
|
|
1166
|
-
fix: `Send role: ${Ia[
|
|
1167
|
-
}), e.style !== void 0 && !Qs(E) &&
|
|
1166
|
+
fix: `Send role: ${Ia[w].map((S) => `"${S}"`).join(" or ")}.`
|
|
1167
|
+
}), e.style !== void 0 && !Qs(E) && n({
|
|
1168
1168
|
code: "invalid_change",
|
|
1169
1169
|
message: `The footer's ${E === "pageInfo" ? "page info" : E} line has no size or alignment; only the header's title and metadata lines and text sections do.`,
|
|
1170
1170
|
path: `${s}.style`,
|
|
1171
1171
|
fix: "Leave style out for a footer line."
|
|
1172
1172
|
});
|
|
1173
|
-
const _ = i[
|
|
1173
|
+
const _ = i[w] ? Qo(i[w].blocks, E) : void 0;
|
|
1174
1174
|
l = (_ == null ? void 0 : _.content) ?? [], c = _ == null ? void 0 : _.style;
|
|
1175
1175
|
}
|
|
1176
|
-
const h = e.style !== void 0 ? Hs(e.style) : void 0,
|
|
1177
|
-
let
|
|
1176
|
+
const h = e.style !== void 0 ? Hs(e.style) : void 0, p = !h || Object.entries(h).every(([w, E]) => (c == null ? void 0 : c[w]) === E);
|
|
1177
|
+
let I;
|
|
1178
1178
|
if (e.text !== void 0) {
|
|
1179
|
-
const
|
|
1179
|
+
const w = { kind: "document", sheetId: t.id }, E = { catalog: _t({ dashboard: a, place: w }), inputs: a.inputs, variables: a.variables }, _ = JSON.stringify(Ze(l, E));
|
|
1180
1180
|
if (JSON.stringify(zs(e.text)) !== _) {
|
|
1181
|
-
const S = Ys(e.text, l, { dashboard: a, place:
|
|
1182
|
-
S.ok ||
|
|
1181
|
+
const S = Ys(e.text, l, { dashboard: a, place: w, path: `${s}.text`, links: !0 });
|
|
1182
|
+
S.ok || o.refuseAll(S.problems);
|
|
1183
1183
|
const y = S.content;
|
|
1184
|
-
JSON.stringify(Ze(y, E)) !== _ && (
|
|
1184
|
+
JSON.stringify(Ze(y, E)) !== _ && (I = y);
|
|
1185
1185
|
}
|
|
1186
1186
|
}
|
|
1187
|
-
const
|
|
1188
|
-
...
|
|
1189
|
-
...h !== void 0 && !
|
|
1187
|
+
const v = {
|
|
1188
|
+
...I !== void 0 ? { content: I } : {},
|
|
1189
|
+
...h !== void 0 && !p ? { style: h } : {}
|
|
1190
1190
|
};
|
|
1191
|
-
return { edit: "sectionId" in d ? { type: "updateText", sectionId: d.sectionId, ...
|
|
1191
|
+
return { edit: "sectionId" in d ? { type: "updateText", sectionId: d.sectionId, ...v } : { type: "updateRegionText", region: d.region, role: d.role, ...v }, unchanged: I === void 0 && p };
|
|
1192
1192
|
}
|
|
1193
1193
|
class me extends Error {
|
|
1194
1194
|
}
|
|
@@ -1209,8 +1209,8 @@ async function Dr(e, a, t) {
|
|
|
1209
1209
|
}
|
|
1210
1210
|
async function fs(e, a, t, s) {
|
|
1211
1211
|
var Gt, Qt, Ht, zt, Yt, Jt, Xt, Zt, ea, ta, aa, sa, oa, na, ia, ra;
|
|
1212
|
-
const
|
|
1213
|
-
let
|
|
1212
|
+
const o = [], n = [], i = [], d = [], l = /* @__PURE__ */ new Set(), c = [], h = /* @__PURE__ */ new Map(), p = { calendar: t.calendar }, I = t.relationshipReach ? { relationshipReach: t.relationshipReach } : {};
|
|
1213
|
+
let v = e, x, w = 0, E = 0;
|
|
1214
1214
|
const { limit: _ } = s;
|
|
1215
1215
|
if (a.length > _.max)
|
|
1216
1216
|
return {
|
|
@@ -1226,23 +1226,23 @@ async function fs(e, a, t, s) {
|
|
|
1226
1226
|
};
|
|
1227
1227
|
const S = [];
|
|
1228
1228
|
if (a.forEach((m, r) => {
|
|
1229
|
-
const
|
|
1230
|
-
if (
|
|
1231
|
-
S.push(
|
|
1229
|
+
const f = Zs.safeParse(m);
|
|
1230
|
+
if (f.success) {
|
|
1231
|
+
S.push(f.data);
|
|
1232
1232
|
return;
|
|
1233
1233
|
}
|
|
1234
|
-
for (const
|
|
1235
|
-
const b = tn(
|
|
1236
|
-
|
|
1234
|
+
for (const u of f.error.issues) {
|
|
1235
|
+
const b = tn(u.message);
|
|
1236
|
+
o.push({
|
|
1237
1237
|
code: "invalid_change",
|
|
1238
|
-
message: (b == null ? void 0 : b.message) ??
|
|
1239
|
-
path: us(`changes[${r}]`,
|
|
1238
|
+
message: (b == null ? void 0 : b.message) ?? u.message,
|
|
1239
|
+
path: us(`changes[${r}]`, u),
|
|
1240
1240
|
fix: (b == null ? void 0 : b.fix) ?? "Send the change in the shape the tool schema gives."
|
|
1241
1241
|
});
|
|
1242
1242
|
}
|
|
1243
|
-
}),
|
|
1243
|
+
}), o.length) return { ok: !1, problems: o };
|
|
1244
1244
|
const y = (m) => {
|
|
1245
|
-
throw
|
|
1245
|
+
throw o.push(m), new me();
|
|
1246
1246
|
}, D = (m) => {
|
|
1247
1247
|
t.capabilities.sql || y({
|
|
1248
1248
|
code: "capability_required",
|
|
@@ -1251,13 +1251,13 @@ async function fs(e, a, t, s) {
|
|
|
1251
1251
|
fix: "Use a measures or records query (a semantic dataset for a variable), or ask an administrator for SQL access."
|
|
1252
1252
|
}), l.add("sql");
|
|
1253
1253
|
}, $ = (m, r) => {
|
|
1254
|
-
const
|
|
1255
|
-
|
|
1254
|
+
const f = wt(v, [m], p);
|
|
1255
|
+
f.ok ? (v = f.dashboard, i.push(m)) : y({ code: "invalid_change", message: f.failedAt.message, path: r, ...f.failedAt.fix ? { fix: f.failedAt.fix } : {} });
|
|
1256
1256
|
}, N = async (m) => {
|
|
1257
1257
|
var X, Y, j, ne, fe;
|
|
1258
|
-
const { cardId: r, index:
|
|
1258
|
+
const { cardId: r, index: f, path: u } = m, { settings: b = {}, highlights: C } = m.request, O = b.columns && Object.keys(b.columns).length ? b.columns : void 0, A = Object.entries(b).some(([H, de]) => H !== "columns" && de !== void 0), F = !!((X = C == null ? void 0 : C.add) != null && X.length);
|
|
1259
1259
|
if (!O && !A && !F && !((Y = C == null ? void 0 : C.remove) != null && Y.length)) return null;
|
|
1260
|
-
const R = ie(
|
|
1260
|
+
const R = ie(v, r).card, P = Object.values(O ?? {}).some((H) => H.label === null), q = Object.values(O ?? {}).some((H) => H.format !== void 0 && H.format !== null), M = {};
|
|
1261
1261
|
if (P && !((j = R.sql) != null && j.trim()))
|
|
1262
1262
|
for (const H of On(R)) {
|
|
1263
1263
|
const de = await t.loadCardSource(H);
|
|
@@ -1270,11 +1270,11 @@ async function fs(e, a, t, s) {
|
|
|
1270
1270
|
}
|
|
1271
1271
|
let z;
|
|
1272
1272
|
if ((O || F) && ((fe = R.sql) != null && fe.trim()) && R.type !== "kpi") {
|
|
1273
|
-
const H = t.readSqlResultColumns ? await t.readSqlResultColumns({ cardId: r, dashboard:
|
|
1273
|
+
const H = t.readSqlResultColumns ? await t.readSqlResultColumns({ cardId: r, dashboard: v }) : null;
|
|
1274
1274
|
H || y({
|
|
1275
1275
|
code: "columns_unavailable",
|
|
1276
1276
|
message: O ? `"${R.title || "Untitled"}" couldn't be run to read its columns, so their names can't be checked.` : `"${R.title || "Untitled"}" couldn't be run to read its columns, so the highlight's column can't be checked.`,
|
|
1277
|
-
path: O ? `${
|
|
1277
|
+
path: O ? `${u}.columns` : `${u}.column`,
|
|
1278
1278
|
fix: "Check that the card runs and returns rows, then propose again."
|
|
1279
1279
|
}), z = H;
|
|
1280
1280
|
}
|
|
@@ -1285,7 +1285,7 @@ async function fs(e, a, t, s) {
|
|
|
1285
1285
|
...C ? { highlights: C } : {}
|
|
1286
1286
|
},
|
|
1287
1287
|
{
|
|
1288
|
-
path:
|
|
1288
|
+
path: u,
|
|
1289
1289
|
cardRef: m.cardRef,
|
|
1290
1290
|
catalogs: M,
|
|
1291
1291
|
newId: t.newId,
|
|
@@ -1294,50 +1294,50 @@ async function fs(e, a, t, s) {
|
|
|
1294
1294
|
}
|
|
1295
1295
|
);
|
|
1296
1296
|
if (!W.ok)
|
|
1297
|
-
throw
|
|
1297
|
+
throw o.push(...W.problems), new me();
|
|
1298
1298
|
for (const H of W.labels) {
|
|
1299
|
-
const de = m.queryLabels.find((
|
|
1299
|
+
const de = m.queryLabels.find((Fe) => He(Fe.key, H.key) && Fe.label !== H.label);
|
|
1300
1300
|
de && y({
|
|
1301
1301
|
code: "value_invalid",
|
|
1302
1302
|
message: `Two labels are stated for one column of "${R.title || "Untitled"}": "${de.label}" in the query and "${H.label}" in columns.`,
|
|
1303
|
-
path: `${
|
|
1303
|
+
path: `${u}.columns`,
|
|
1304
1304
|
fix: "State the label once."
|
|
1305
1305
|
});
|
|
1306
1306
|
}
|
|
1307
|
-
return
|
|
1308
|
-
},
|
|
1307
|
+
return n.push(...W.warnings), W.labels.length && pa(R, W.labels).changed.length && $({ op: "card.update", cardId: r, update: { kind: "relabel", labels: W.labels }, changeIndex: f }, `${u}.columns`), W.settings && $({ op: "card.update", cardId: r, update: { kind: "settings", settings: W.settings }, changeIndex: f }, O ? `${u}.columns` : u), W.settings;
|
|
1308
|
+
}, g = (m, r) => {
|
|
1309
1309
|
var b;
|
|
1310
|
-
const
|
|
1311
|
-
|
|
1312
|
-
const
|
|
1313
|
-
return ((b =
|
|
1310
|
+
const f = ie(v, m);
|
|
1311
|
+
f || y({ code: "card_not_editable", message: "Cards in Document sections are changed in the editor.", path: `${r}.cardId`, fix: "Tell the user to change it in the editor.", details: { reason: "document_section" } });
|
|
1312
|
+
const u = we(f.card, { sql: !0 });
|
|
1313
|
+
return ((b = u.source) == null ? void 0 : b.kind) === "sql" && D(`${r}.cardId`), u.editable || y({
|
|
1314
1314
|
code: "card_not_editable",
|
|
1315
|
-
message:
|
|
1315
|
+
message: u.message,
|
|
1316
1316
|
path: `${r}.cardId`,
|
|
1317
|
-
fix:
|
|
1318
|
-
details: { reason:
|
|
1319
|
-
}),
|
|
1317
|
+
fix: u.reason === "needs_sql_access" ? "Ask for SQL access." : "Tell the user to change it in the editor.",
|
|
1318
|
+
details: { reason: u.reason, ...u.detail ? { detail: u.detail } : {} }
|
|
1319
|
+
}), f.frame.visualId && n.push({
|
|
1320
1320
|
code: "detaches_linked_visual",
|
|
1321
|
-
message: `"${
|
|
1321
|
+
message: `"${f.card.title}" will stop following its library visual and become local to this dashboard.`,
|
|
1322
1322
|
path: r,
|
|
1323
1323
|
details: { cardIds: [m] }
|
|
1324
|
-
}), { card:
|
|
1325
|
-
}, k = /* @__PURE__ */ new Map(), T = (m, r,
|
|
1324
|
+
}), { card: f.card, read: u };
|
|
1325
|
+
}, k = /* @__PURE__ */ new Map(), T = (m, r, f) => {
|
|
1326
1326
|
var b;
|
|
1327
|
-
const
|
|
1327
|
+
const u = Ka("metric", ((b = m.config) == null ? void 0 : b.metricColumns) ?? []);
|
|
1328
1328
|
return r.map(({ index: C, calculations: O }) => ({
|
|
1329
1329
|
...O,
|
|
1330
|
-
measure:
|
|
1331
|
-
path: `${
|
|
1330
|
+
measure: u[C] ?? { role: "metric", field: "", ordinal: C },
|
|
1331
|
+
path: `${f}.query.measures[${C}]`
|
|
1332
1332
|
}));
|
|
1333
1333
|
}, L = async (m) => {
|
|
1334
|
-
const r = ie(
|
|
1334
|
+
const r = ie(v, m.cardId).card, f = T(r, m.stated, m.path), u = f.some((O) => {
|
|
1335
1335
|
var A, F;
|
|
1336
1336
|
return ((A = O.comparison) == null ? void 0 : A.kind) === "previous_period" || ((F = O.comparison) == null ? void 0 : F.kind) === "previous_year";
|
|
1337
|
-
}), b =
|
|
1337
|
+
}), b = u && t.readComparisonDates ? await t.readComparisonDates({ card: r, dashboard: v }) : ka(r), C = fa({ card: r, stated: f, context: { path: m.path, cardRef: m.cardRef, dates: b } });
|
|
1338
1338
|
if (!C.ok)
|
|
1339
|
-
throw
|
|
1340
|
-
return
|
|
1339
|
+
throw o.push(...C.problems), new me();
|
|
1340
|
+
return n.push(...C.warnings), u && k.set(m.cardId, m.path), C.update ? ($(
|
|
1341
1341
|
{ op: "card.update", cardId: m.cardId, update: { kind: "calculations", calculations: C.update }, changeIndex: m.index },
|
|
1342
1342
|
`${m.path}.query`
|
|
1343
1343
|
), !0) : !1;
|
|
@@ -1353,34 +1353,34 @@ async function fs(e, a, t, s) {
|
|
|
1353
1353
|
comparisonDisplay: m.comparisonDisplay,
|
|
1354
1354
|
inheritComparison: m.inheritComparison,
|
|
1355
1355
|
band: m.band
|
|
1356
|
-
}), K = (m) => Object.entries(V(m)).filter(([, r]) => r !== void 0).map(([r]) => r), B = (m) => (
|
|
1356
|
+
}), K = (m) => Object.entries(V(m)).filter(([, r]) => r !== void 0).map(([r]) => r), B = (m) => (o.push(...m.slice(0, -1)), y(m[m.length - 1])), se = (m, r, f, u) => {
|
|
1357
1357
|
const { card: b } = r, C = [...m.type ? ["type"] : [], ...m.query ? ["query"] : [], ...m.matrix ? ["matrix"] : [], ...K(m)];
|
|
1358
1358
|
C.length && y({
|
|
1359
1359
|
code: "invalid_change",
|
|
1360
1360
|
message: `"${b.title}" is a text card, so it takes no ${et(C)}.`,
|
|
1361
|
-
path:
|
|
1361
|
+
path: u,
|
|
1362
1362
|
fix: "Change a card to or from text in the editor, or add a new card and remove this one."
|
|
1363
1363
|
});
|
|
1364
|
-
const O = ja(b, { inputs:
|
|
1365
|
-
O.editable || y({ code: "card_not_editable", message: O.message, path: `${
|
|
1364
|
+
const O = ja(b, { inputs: v.inputs, variables: v.variables });
|
|
1365
|
+
O.editable || y({ code: "card_not_editable", message: O.message, path: `${u}.cardId`, fix: "Tell the user to change it in the editor.", details: { reason: "text" } });
|
|
1366
1366
|
const A = O.editable && (O.form === "legacy_html" || O.form === "legacy_runs");
|
|
1367
1367
|
A && m.description !== void 0 && m.text === void 0 && y({
|
|
1368
1368
|
code: "invalid_change",
|
|
1369
1369
|
message: `"${b.title}" keeps its words in its description, so a description change would replace them.`,
|
|
1370
|
-
path: `${
|
|
1370
|
+
path: `${u}.description`,
|
|
1371
1371
|
fix: "Send the words in text with it: they are stored as rich text, and the description becomes the subtitle."
|
|
1372
|
-
}), d.push({ ref: m.cardId, kind: "card", id: b.id, title: m.title ?? b.title ?? "", changeIndex:
|
|
1372
|
+
}), d.push({ ref: m.cardId, kind: "card", id: b.id, title: m.title ?? b.title ?? "", changeIndex: f });
|
|
1373
1373
|
let F = !1, R = !1;
|
|
1374
1374
|
if (m.text !== void 0) {
|
|
1375
1375
|
const M = ga({
|
|
1376
1376
|
text: m.text,
|
|
1377
1377
|
card: b,
|
|
1378
1378
|
// Any variable the catalog offers where the card sits (DV-D13).
|
|
1379
|
-
context: { dashboard:
|
|
1380
|
-
path: `${
|
|
1379
|
+
context: { dashboard: v, place: { kind: "sheet", sheetId: r.sheet.id, cardId: b.id } },
|
|
1380
|
+
path: `${u}.text`,
|
|
1381
1381
|
storeAsRichText: A && m.description !== void 0
|
|
1382
1382
|
});
|
|
1383
|
-
M.ok || B(M.problems), M.ok && !M.unchanged && ($({ op: "card.update", cardId: b.id, update: { kind: "text", richContent: M.richContent, clearsLegacy: M.clearsLegacy }, changeIndex:
|
|
1383
|
+
M.ok || B(M.problems), M.ok && !M.unchanged && ($({ op: "card.update", cardId: b.id, update: { kind: "text", richContent: M.richContent, clearsLegacy: M.clearsLegacy }, changeIndex: f }, u), F = !0, R = M.clearsLegacy);
|
|
1384
1384
|
}
|
|
1385
1385
|
const P = m.title !== void 0 && m.title !== b.title, q = m.description !== void 0 && (A ? R : (m.description ?? void 0) !== (b.description ?? void 0));
|
|
1386
1386
|
(P || q) && ($(
|
|
@@ -1388,26 +1388,26 @@ async function fs(e, a, t, s) {
|
|
|
1388
1388
|
op: "card.update",
|
|
1389
1389
|
cardId: b.id,
|
|
1390
1390
|
update: { kind: "rename", ...P ? { title: m.title } : {}, ...q ? { description: m.description } : {} },
|
|
1391
|
-
changeIndex:
|
|
1391
|
+
changeIndex: f
|
|
1392
1392
|
},
|
|
1393
|
-
|
|
1394
|
-
), F = !0), F && r.frame.visualId &&
|
|
1393
|
+
u
|
|
1394
|
+
), F = !0), F && r.frame.visualId && n.push({
|
|
1395
1395
|
code: "detaches_linked_visual",
|
|
1396
1396
|
message: `"${b.title}" will stop following its library visual and become local to this dashboard.`,
|
|
1397
|
-
path:
|
|
1397
|
+
path: u,
|
|
1398
1398
|
details: { cardIds: [b.id] }
|
|
1399
1399
|
});
|
|
1400
1400
|
}, oe = (m, r) => {
|
|
1401
1401
|
if (m.startsWith("$")) {
|
|
1402
|
-
const
|
|
1403
|
-
return (!
|
|
1402
|
+
const f = h.get(m);
|
|
1403
|
+
return (!f || f.kind !== "card") && y({
|
|
1404
1404
|
code: "handle_unknown",
|
|
1405
1405
|
message: `${m} isn't a card handle defined earlier in this list.`,
|
|
1406
1406
|
path: r,
|
|
1407
1407
|
fix: "Define the handle with an earlier card.add, or use the card id from the outline."
|
|
1408
|
-
}),
|
|
1408
|
+
}), f.id;
|
|
1409
1409
|
}
|
|
1410
|
-
return
|
|
1410
|
+
return xe(v).some((f) => f.cardId === m) || y({
|
|
1411
1411
|
code: "card_not_found",
|
|
1412
1412
|
message: `There's no card ${m} on this dashboard.`,
|
|
1413
1413
|
path: r,
|
|
@@ -1415,25 +1415,25 @@ async function fs(e, a, t, s) {
|
|
|
1415
1415
|
}), m;
|
|
1416
1416
|
}, te = (m, r) => {
|
|
1417
1417
|
if (m.startsWith("$")) {
|
|
1418
|
-
const
|
|
1419
|
-
return (!
|
|
1418
|
+
const u = h.get(m);
|
|
1419
|
+
return (!u || u.kind !== "filter") && y({
|
|
1420
1420
|
code: "handle_unknown",
|
|
1421
1421
|
message: `${m} isn't a filter handle defined earlier in this list.`,
|
|
1422
1422
|
path: r,
|
|
1423
1423
|
fix: "Define the handle with an earlier filter.add, or use the filter id from the outline."
|
|
1424
|
-
}),
|
|
1424
|
+
}), u.id;
|
|
1425
1425
|
}
|
|
1426
|
-
return (Array.isArray(
|
|
1426
|
+
return (Array.isArray(v.inputs) ? v.inputs : []).some((u) => u.id === m && u.kind === "filter") || y({
|
|
1427
1427
|
code: "filter_not_found",
|
|
1428
1428
|
message: `There's no filter ${m} on this dashboard.`,
|
|
1429
1429
|
path: r,
|
|
1430
1430
|
fix: "Read the outline again and use its filter ids."
|
|
1431
1431
|
}), m;
|
|
1432
1432
|
}, Bt = (m, r) => {
|
|
1433
|
-
const
|
|
1434
|
-
return
|
|
1435
|
-
},
|
|
1436
|
-
let
|
|
1433
|
+
const f = m.startsWith("$") ? void 0 : Je(v, m);
|
|
1434
|
+
return f ? f.id : oe(m, r);
|
|
1435
|
+
}, Re = { services: t, problem: y, refuseAll: B, need: D }, nt = () => (v.sheets ?? []).filter((m) => !Xe(m)), Be = () => nt().map((m) => ({ sheetId: m.id, title: m.title ?? "" })), it = (m, r, f) => {
|
|
1436
|
+
let u = m;
|
|
1437
1437
|
if (m.startsWith("$")) {
|
|
1438
1438
|
const C = h.get(m);
|
|
1439
1439
|
(!C || C.kind !== "sheet") && y({
|
|
@@ -1441,25 +1441,25 @@ async function fs(e, a, t, s) {
|
|
|
1441
1441
|
message: `${m} isn't a sheet handle defined earlier in this list.`,
|
|
1442
1442
|
path: r,
|
|
1443
1443
|
fix: "Define the handle with an earlier sheet.add, or use the sheet id from the outline."
|
|
1444
|
-
}),
|
|
1444
|
+
}), u = C.id;
|
|
1445
1445
|
}
|
|
1446
|
-
const b = (
|
|
1447
|
-
return b || y({ code: "sheet_not_found", message: `There's no sheet ${
|
|
1448
|
-
},
|
|
1446
|
+
const b = (v.sheets ?? []).find((C) => C.id === u);
|
|
1447
|
+
return b || y({ code: "sheet_not_found", message: `There's no sheet ${u} on this dashboard.`, path: r, fix: "Read the outline again and use its sheet ids.", details: { sheets: Be() } }), f.grid && Xe(b) && y({ code: "sheet_not_a_grid", message: `"${b.title}" is a Document sheet.`, path: r, fix: "Add the card to a grid sheet; Document sheets are changed in the editor.", details: { sheets: Be() } }), b;
|
|
1448
|
+
}, Ae = (m, r) => it(m, r, { grid: !0 }), Vt = (m, r) => m.map((f, u) => Ae(f, `${r}.sheetIds[${u}]`).id), jt = (m, r, f, u) => {
|
|
1449
1449
|
var A;
|
|
1450
|
-
for (const F of Ma(r,
|
|
1451
|
-
const b =
|
|
1450
|
+
for (const F of Ma(r, f)) y({ ...F, path: `${u}.${F.path}` });
|
|
1451
|
+
const b = De[m], C = tt(r), O = r.dateField;
|
|
1452
1452
|
if (O && typeof O != "string" && O.label && !r.timeGrain && y({
|
|
1453
1453
|
code: "invalid_change",
|
|
1454
1454
|
message: "A label names a column, and the date field is a column only when the card groups by it.",
|
|
1455
|
-
path: `${
|
|
1455
|
+
path: `${u}.query.dateField.label`,
|
|
1456
1456
|
fix: "Send timeGrain to group by the date, or leave the label out."
|
|
1457
1457
|
}), !b.forms.includes(C)) {
|
|
1458
|
-
const F = Object.keys(
|
|
1458
|
+
const F = Object.keys(De).filter((R) => De[R].forms.includes(C));
|
|
1459
1459
|
y({
|
|
1460
1460
|
code: "type_not_supported",
|
|
1461
1461
|
message: `A ${m.replace(/_/g, " ")} card takes ${b.forms.map((R) => Ue[R]).join(" or ")}, not ${Ue[C]}.`,
|
|
1462
|
-
path: `${
|
|
1462
|
+
path: `${u}.query`,
|
|
1463
1463
|
fix: `Send ${b.forms.map((R) => Ue[R]).join(" or ")}, or use a type this query fits: ${F.join(", ")}.`
|
|
1464
1464
|
});
|
|
1465
1465
|
}
|
|
@@ -1468,39 +1468,39 @@ async function fs(e, a, t, s) {
|
|
|
1468
1468
|
b.measures && (R < b.measures.min || b.measures.max !== void 0 && R > b.measures.max) && y({
|
|
1469
1469
|
code: "type_not_supported",
|
|
1470
1470
|
message: `A ${m.replace(/_/g, " ")} card shows exactly ${b.measures.max} measure.`,
|
|
1471
|
-
path: `${
|
|
1471
|
+
path: `${u}.query.measures`,
|
|
1472
1472
|
fix: "Send one measure, or use a table or chart for several."
|
|
1473
1473
|
}), !b.dimensions && ((A = F.dimensions) != null && A.length) && y({
|
|
1474
1474
|
code: "type_not_supported",
|
|
1475
1475
|
message: `A ${m.replace(/_/g, " ")} card shows one number, so it has no dimensions.`,
|
|
1476
|
-
path: `${
|
|
1476
|
+
path: `${u}.query.dimensions`,
|
|
1477
1477
|
fix: "Remove the dimensions, or use a table or chart."
|
|
1478
1478
|
}), m === "matrix" && (F.orderBy || F.limit) && y({
|
|
1479
1479
|
code: "type_not_supported",
|
|
1480
1480
|
message: "A Matrix's sorting and top N are set in the editor.",
|
|
1481
|
-
path: `${
|
|
1481
|
+
path: `${u}.query`,
|
|
1482
1482
|
fix: "Leave out orderBy and limit for a Matrix."
|
|
1483
1483
|
});
|
|
1484
1484
|
}
|
|
1485
|
-
if (b.matrixColumns && !
|
|
1485
|
+
if (b.matrixColumns && !f && y({
|
|
1486
1486
|
code: "type_not_supported",
|
|
1487
1487
|
message: "A Matrix needs matrix.columns: the query fields that run across the top.",
|
|
1488
|
-
path: `${
|
|
1488
|
+
path: `${u}.matrix`,
|
|
1489
1489
|
fix: "Send matrix: { columns: [...] } naming dimensions or the date field of the query (an empty list puts nothing across the top)."
|
|
1490
|
-
}), !b.matrixColumns &&
|
|
1490
|
+
}), !b.matrixColumns && f && y({ code: "type_not_supported", message: "matrix.columns is only for Matrix cards.", path: `${u}.matrix`, fix: 'Leave out matrix, or use type "matrix".' }), f && C === "measures") {
|
|
1491
1491
|
const F = r, R = F.datasetName, P = [...F.dimensions ?? [], ...F.timeGrain && F.dateField ? [F.dateField] : []];
|
|
1492
|
-
P.length &&
|
|
1492
|
+
P.length && f.columns.length >= P.length && P.every((M) => f.columns.some((U) => be(U, R) === be(M, R))) && y({
|
|
1493
1493
|
code: "type_not_supported",
|
|
1494
1494
|
message: "A Matrix needs at least one field down the side.",
|
|
1495
|
-
path: `${
|
|
1495
|
+
path: `${u}.matrix.columns`,
|
|
1496
1496
|
fix: "Leave one dimension or the date field out of matrix.columns."
|
|
1497
1497
|
});
|
|
1498
1498
|
const q = new Set([...F.dimensions ?? [], ...F.dateField ? [F.dateField] : []].map((M) => be(M, R)));
|
|
1499
|
-
|
|
1499
|
+
f.columns.forEach((M, U) => {
|
|
1500
1500
|
q.has(be(M, R)) || y({
|
|
1501
1501
|
code: "type_not_supported",
|
|
1502
1502
|
message: `"${Ct(M)}" isn't one of the query's dimensions or its date field.`,
|
|
1503
|
-
path: `${
|
|
1503
|
+
path: `${u}.matrix.columns[${U}]`,
|
|
1504
1504
|
fix: "Name dimensions or the date field of the query in matrix.columns."
|
|
1505
1505
|
});
|
|
1506
1506
|
});
|
|
@@ -1511,15 +1511,15 @@ async function fs(e, a, t, s) {
|
|
|
1511
1511
|
path: `${r}.query`,
|
|
1512
1512
|
fix: m.code === "query_not_kept" ? "Tell the user to make this change in the editor." : "Read the outline again and propose again.",
|
|
1513
1513
|
details: { reason: "not_expressible", ..."parts" in m ? { parts: m.parts } : {} }
|
|
1514
|
-
}), Wt = (m, r,
|
|
1515
|
-
const A = zn(m, r,
|
|
1514
|
+
}), Wt = (m, r, f, u, b, C, O) => {
|
|
1515
|
+
const A = zn(m, r, f, C, O);
|
|
1516
1516
|
if (!A.length) return;
|
|
1517
1517
|
const F = r;
|
|
1518
1518
|
if (A.length === 1 && A[0] === "dateField" && F.dateField && !F.timeGrain && !F.timeWindow) {
|
|
1519
1519
|
y({
|
|
1520
1520
|
code: "value_invalid",
|
|
1521
1521
|
message: `A dateField on its own doesn't change "${b}": it needs timeGrain to group by the date (a KPI's Trend By) or a timeWindow to filter by it.`,
|
|
1522
|
-
path: `${
|
|
1522
|
+
path: `${u}.query.dateField`,
|
|
1523
1523
|
fix: 'Add timeGrain (for example "month") or a timeWindow, or leave out dateField.'
|
|
1524
1524
|
});
|
|
1525
1525
|
return;
|
|
@@ -1528,31 +1528,31 @@ async function fs(e, a, t, s) {
|
|
|
1528
1528
|
y({
|
|
1529
1529
|
code: "card_not_editable",
|
|
1530
1530
|
message: O ? `As changed, "${b}" wouldn't hold ${R} as asked, so make this change in the editor.` : `"${b}" can't be built holding ${R} as asked.`,
|
|
1531
|
-
path: `${
|
|
1531
|
+
path: `${u}.query`,
|
|
1532
1532
|
fix: O ? "Tell the user to make this change in the editor." : `Leave out ${R}; the rest of the card can be added.`,
|
|
1533
1533
|
details: { reason: "not_expressible", detail: `doesn't hold: ${R}` }
|
|
1534
1534
|
});
|
|
1535
|
-
}, Ut = async (m, r,
|
|
1535
|
+
}, Ut = async (m, r, f, u, b = !1) => {
|
|
1536
1536
|
const C = ct(m);
|
|
1537
1537
|
if ("sql" in r)
|
|
1538
|
-
return D(`${
|
|
1538
|
+
return D(`${u}.query`), { type: C, source: { kind: "sql", connectionId: r.connectionId, sql: r.sql } };
|
|
1539
1539
|
const O = C === "matrixTable" || C === "detailTable" ? "table" : C, A = await t.compileCardQuery({ query: r, chartType: O });
|
|
1540
1540
|
if (!A.ok)
|
|
1541
|
-
throw
|
|
1542
|
-
|
|
1541
|
+
throw o.push(...A.problems.map((q) => ({ ...q, path: q.path ? `${u}.query.${q.path}` : `${u}.query` }))), new me();
|
|
1542
|
+
n.push(...A.warnings.map((q) => ({ ...q, path: q.path ?? `${u}.query` })));
|
|
1543
1543
|
const F = !b && "timeWindow" in r && r.timeWindow ? ui(A.part.config) : void 0;
|
|
1544
|
-
F && "timeWindow" in r && r.timeWindow && hs(r.timeWindow, { use: "cardFilter", columnHasTime: uo(F) }, `${
|
|
1544
|
+
F && "timeWindow" in r && r.timeWindow && hs(r.timeWindow, { use: "cardFilter", columnHasTime: uo(F) }, `${u}.query.timeWindow`, y);
|
|
1545
1545
|
let R = { ...A.part, type: C };
|
|
1546
1546
|
const P = R.config ?? {};
|
|
1547
1547
|
if (C === "detailTable") {
|
|
1548
1548
|
const q = fo(mo("table", "detailTable", P)) ?? {};
|
|
1549
1549
|
R = { ...R, config: oi(q) };
|
|
1550
1550
|
}
|
|
1551
|
-
return C === "matrixTable" && (R = await vs(R, P, r,
|
|
1552
|
-
}, vs = async (m, r,
|
|
1551
|
+
return C === "matrixTable" && (R = await vs(R, P, r, f, u)), ni(R, Ne(r));
|
|
1552
|
+
}, vs = async (m, r, f, u, b) => {
|
|
1553
1553
|
var q;
|
|
1554
|
-
const C = await t.loadCardSource({ domainId:
|
|
1555
|
-
if (C || y({ code: "field_not_found", message: `The dataset "${
|
|
1554
|
+
const C = await t.loadCardSource({ domainId: f.domainId, datasetName: f.datasetName });
|
|
1555
|
+
if (C || y({ code: "field_not_found", message: `The dataset "${f.datasetName}" isn't available.`, path: `${b}.query.datasetName`, fix: "Find datasets with semaphor_list_datasets." }), m.source.kind !== "semantic") throw new me();
|
|
1556
1556
|
const O = { id: "scratch", title: "", type: "table", dataSource: m.source.dataSource, config: r }, A = po(O, "matrixTable", { catalog: C.fields, createId: t.newId }), F = A.status === "changed" ? (q = A.card.config) == null ? void 0 : q.matrix : void 0;
|
|
1557
1557
|
(A.status !== "changed" || A.leftOut.length || !F) && y({
|
|
1558
1558
|
code: "type_not_supported",
|
|
@@ -1561,8 +1561,8 @@ async function fs(e, a, t, s) {
|
|
|
1561
1561
|
fix: "Use plain dataset fields for a Matrix, or use a table."
|
|
1562
1562
|
});
|
|
1563
1563
|
let R = F;
|
|
1564
|
-
const P =
|
|
1565
|
-
for (const [M, U] of
|
|
1564
|
+
const P = f.datasetName;
|
|
1565
|
+
for (const [M, U] of u.columns.entries()) {
|
|
1566
1566
|
const z = [...R.spec.rows, ...R.spec.columns].find(
|
|
1567
1567
|
(W) => go(W.field) === be(U, P)
|
|
1568
1568
|
);
|
|
@@ -1571,42 +1571,42 @@ async function fs(e, a, t, s) {
|
|
|
1571
1571
|
return { ...m, config: { matrix: R } };
|
|
1572
1572
|
}, rt = /* @__PURE__ */ new Map(), dt = /* @__PURE__ */ new Map();
|
|
1573
1573
|
for (const [m, r] of S.entries()) {
|
|
1574
|
-
const
|
|
1574
|
+
const f = `changes[${m}]`;
|
|
1575
1575
|
try {
|
|
1576
1576
|
switch (r.op) {
|
|
1577
1577
|
case "card.add": {
|
|
1578
|
-
const
|
|
1579
|
-
const Y = oe(r.position.after, `${
|
|
1578
|
+
const u = r.position && typeof r.position == "object" ? (() => {
|
|
1579
|
+
const Y = oe(r.position.after, `${f}.position.after`), j = xe(v).find(
|
|
1580
1580
|
(ne) => ne.cardId === Y && ne.kind === "frameCard"
|
|
1581
1581
|
);
|
|
1582
1582
|
return !j || j.kind !== "frameCard" ? y({
|
|
1583
1583
|
code: "card_not_found",
|
|
1584
1584
|
message: `${r.position.after} isn't a card on a grid sheet.`,
|
|
1585
|
-
path: `${
|
|
1585
|
+
path: `${f}.position.after`,
|
|
1586
1586
|
fix: "Use a cardId from semaphor_get_dashboard_details on the same sheet, or a handle from this proposal."
|
|
1587
|
-
}) : (r.sheetId &&
|
|
1587
|
+
}) : (r.sheetId && Ae(r.sheetId, `${f}.sheetId`).id !== j.sheetId && y({
|
|
1588
1588
|
code: "invalid_change",
|
|
1589
1589
|
message: `position.after names a card on another sheet than ${r.sheetId}.`,
|
|
1590
|
-
path: `${
|
|
1590
|
+
path: `${f}.position.after`,
|
|
1591
1591
|
fix: "Leave out sheetId, or name the card's sheet."
|
|
1592
1592
|
}), { sheetId: j.sheetId, frameId: j.frameId });
|
|
1593
|
-
})() : void 0, b =
|
|
1593
|
+
})() : void 0, b = u ? Ae(u.sheetId, `${f}.position.after`) : r.sheetId ? Ae(r.sheetId, `${f}.sheetId`) : (() => {
|
|
1594
1594
|
const Y = nt();
|
|
1595
1595
|
return Y.length !== 1 && y({
|
|
1596
1596
|
code: Y.length ? "sheet_required" : "sheet_not_a_grid",
|
|
1597
1597
|
message: Y.length ? "This dashboard has several grid sheets; say which one gets the card." : "This dashboard has no grid sheet to add a card to.",
|
|
1598
|
-
path: `${
|
|
1598
|
+
path: `${f}.sheetId`,
|
|
1599
1599
|
fix: Y.length ? "Send sheetId: one of details.sheets." : "Add a sheet with sheet.add earlier in this list.",
|
|
1600
1600
|
details: { sheets: Be() }
|
|
1601
1601
|
}), Y[0];
|
|
1602
|
-
})(), C =
|
|
1603
|
-
const j = r.handle ?? `$card_${++
|
|
1604
|
-
return h.has(j) && y({ code: "invalid_change", message: `The handle ${j} is defined twice.`, path: `${
|
|
1602
|
+
})(), C = u ? { after: u.frameId } : typeof r.position == "string" ? r.position : void 0, O = C || r.width ? { ...C ? { position: C } : {}, ...r.width ? { width: r.width } : {} } : void 0, A = (Y) => {
|
|
1603
|
+
const j = r.handle ?? `$card_${++w}`;
|
|
1604
|
+
return h.has(j) && y({ code: "invalid_change", message: `The handle ${j} is defined twice.`, path: `${f}.handle`, fix: "Give each new card, filter or sheet its own handle." }), h.set(j, { kind: "card", id: Y.id, title: r.title }), d.push({ ref: j, kind: "card", id: Y.id, title: r.title, changeIndex: m }), j;
|
|
1605
1605
|
};
|
|
1606
1606
|
if (r.type === "text") {
|
|
1607
1607
|
const Y = [...r.query ? ["query"] : [], ...r.matrix ? ["matrix"] : [], ...K(r)];
|
|
1608
|
-
Y.length && y({ code: "invalid_change", message: `A text card takes no ${et(Y)}.`, path:
|
|
1609
|
-
const j = ga({ text: r.text, context: { dashboard:
|
|
1608
|
+
Y.length && y({ code: "invalid_change", message: `A text card takes no ${et(Y)}.`, path: f, fix: xa }), r.text === void 0 && y({ code: "invalid_change", message: "A text card needs its words in text.", path: `${f}.text`, fix: xa });
|
|
1609
|
+
const j = ga({ text: r.text, context: { dashboard: v, place: { kind: "sheet", sheetId: b.id } }, path: `${f}.text` });
|
|
1610
1610
|
j.ok || B(j.problems);
|
|
1611
1611
|
const ne = zo({
|
|
1612
1612
|
id: t.newId(),
|
|
@@ -1614,45 +1614,45 @@ async function fs(e, a, t, s) {
|
|
|
1614
1614
|
...r.description ? { description: r.description } : {},
|
|
1615
1615
|
richContent: j.ok && !j.unchanged ? j.richContent : { version: 1, blocks: [{ type: "paragraph", children: [] }] }
|
|
1616
1616
|
});
|
|
1617
|
-
$({ op: "card.add", sheetId: b.id, frame: { id: t.newId(), cards: [ne], activeCardId: ne.id }, ...O ? { placement: O } : {}, changeIndex: m },
|
|
1617
|
+
$({ op: "card.add", sheetId: b.id, frame: { id: t.newId(), cards: [ne], activeCardId: ne.id }, ...O ? { placement: O } : {}, changeIndex: m }, f), A(ne);
|
|
1618
1618
|
break;
|
|
1619
1619
|
}
|
|
1620
1620
|
(r.text !== void 0 || !r.query) && y({
|
|
1621
1621
|
code: "invalid_change",
|
|
1622
1622
|
message: r.text !== void 0 ? `A ${r.type} card takes a query, not text.` : `A ${r.type} card needs a query.`,
|
|
1623
|
-
path: r.text !== void 0 ? `${
|
|
1623
|
+
path: r.text !== void 0 ? `${f}.text` : `${f}.query`,
|
|
1624
1624
|
fix: "Send query; text is for type text."
|
|
1625
1625
|
});
|
|
1626
1626
|
const F = yt(r.query), R = F.query, P = r.type;
|
|
1627
|
-
jt(P, R, r.matrix,
|
|
1628
|
-
const q = await Ut(P, R, r.matrix,
|
|
1627
|
+
jt(P, R, r.matrix, f);
|
|
1628
|
+
const q = await Ut(P, R, r.matrix, f), M = {
|
|
1629
1629
|
...Yo({ id: t.newId(), title: r.title, ...r.description ? { description: r.description } : {} }),
|
|
1630
1630
|
type: q.type
|
|
1631
1631
|
}, U = ha(M, q);
|
|
1632
|
-
U.ok || y({ code: "invalid_change", message: U.message, path:
|
|
1632
|
+
U.ok || y({ code: "invalid_change", message: U.message, path: f });
|
|
1633
1633
|
const z = U.ok ? U.card : M;
|
|
1634
|
-
Wt(z, R, r.matrix,
|
|
1634
|
+
Wt(z, R, r.matrix, f, r.title, q);
|
|
1635
1635
|
const W = { id: t.newId(), cards: [z], activeCardId: z.id };
|
|
1636
|
-
$({ op: "card.add", sheetId: b.id, frame: W, ...O ? { placement: O } : {}, changeIndex: m },
|
|
1636
|
+
$({ op: "card.add", sheetId: b.id, frame: W, ...O ? { placement: O } : {}, changeIndex: m }, f);
|
|
1637
1637
|
const X = A(z);
|
|
1638
|
-
c.push(z.id), await L({ cardId: z.id, cardRef: X, stated: F.calculations, index: m, path:
|
|
1638
|
+
c.push(z.id), await L({ cardId: z.id, cardRef: X, stated: F.calculations, index: m, path: f }), await N({
|
|
1639
1639
|
cardId: z.id,
|
|
1640
1640
|
cardRef: X,
|
|
1641
1641
|
request: { settings: V(r) },
|
|
1642
1642
|
queryLabels: "sql" in R ? [] : Ne(R),
|
|
1643
1643
|
index: m,
|
|
1644
|
-
path:
|
|
1644
|
+
path: f
|
|
1645
1645
|
});
|
|
1646
1646
|
break;
|
|
1647
1647
|
}
|
|
1648
1648
|
case "card.update": {
|
|
1649
|
-
const
|
|
1649
|
+
const u = oe(r.cardId, `${f}.cardId`), b = ie(v, u);
|
|
1650
1650
|
if ((b == null ? void 0 : b.card.type) === "text") {
|
|
1651
|
-
se(r, b, m,
|
|
1651
|
+
se(r, b, m, f);
|
|
1652
1652
|
break;
|
|
1653
1653
|
}
|
|
1654
|
-
r.text !== void 0 && y({ code: "invalid_change", message: `"${(b == null ? void 0 : b.card.title) ??
|
|
1655
|
-
const { card: C, read: O } =
|
|
1654
|
+
r.text !== void 0 && y({ code: "invalid_change", message: `"${(b == null ? void 0 : b.card.title) ?? u}" isn't a text card, so it takes no text.`, path: `${f}.text`, fix: "Change its query; text is for text cards." });
|
|
1655
|
+
const { card: C, read: O } = g(u, f);
|
|
1656
1656
|
let A = !1, F = [];
|
|
1657
1657
|
const R = r.type && r.type !== ((Gt = qe(C)) == null ? void 0 : Gt.type) ? ct(r.type) : void 0;
|
|
1658
1658
|
if (R && R !== C.type) {
|
|
@@ -1664,67 +1664,67 @@ async function fs(e, a, t, s) {
|
|
|
1664
1664
|
return z.push(X), X;
|
|
1665
1665
|
}
|
|
1666
1666
|
});
|
|
1667
|
-
if (W.status === "refused" && y({ code: "type_not_supported", message: "The card's dataset fields couldn't be loaded for a change to or from a Matrix.", path: `${
|
|
1667
|
+
if (W.status === "refused" && y({ code: "type_not_supported", message: "The card's dataset fields couldn't be loaded for a change to or from a Matrix.", path: `${f}.type`, fix: "Send a complete query with the type change." }), W.status === "changed") {
|
|
1668
1668
|
const X = [...W.leftOut, ...W.droppedPreferences];
|
|
1669
|
-
X.length &&
|
|
1669
|
+
X.length && n.push({
|
|
1670
1670
|
code: "type_change_drops",
|
|
1671
1671
|
message: `Changing "${C.title}" to ${r.type.replace(/_/g, " ")} leaves out ${X.join(", ")}.`,
|
|
1672
|
-
path: `${
|
|
1672
|
+
path: `${f}.type`,
|
|
1673
1673
|
details: { dropped: X }
|
|
1674
1674
|
}), $(
|
|
1675
|
-
{ op: "card.update", cardId:
|
|
1676
|
-
`${
|
|
1675
|
+
{ op: "card.update", cardId: u, update: { kind: "retype", type: R, ...U ? { catalog: U } : {}, newIds: z }, changeIndex: m },
|
|
1676
|
+
`${f}.type`
|
|
1677
1677
|
), A = !0;
|
|
1678
1678
|
}
|
|
1679
1679
|
}
|
|
1680
1680
|
const P = r.query ? yt(r.query) : void 0;
|
|
1681
1681
|
if (r.query || r.matrix) {
|
|
1682
|
-
const q = ie(
|
|
1682
|
+
const q = ie(v, u).card, M = we(q, { sql: !0, calculations: !1 }), U = M.editable ? yt(M.query).query : void 0, z = U, W = li(z, (P == null ? void 0 : P.query) ?? {}, `${f}.query`, (le) => {
|
|
1683
1683
|
if (le.code === "query_form_mismatch" && (P != null && P.calculations.length)) {
|
|
1684
|
-
const pe = T(q, P.calculations,
|
|
1685
|
-
if (!
|
|
1686
|
-
throw
|
|
1684
|
+
const pe = T(q, P.calculations, f), Ce = fa({ card: q, stated: pe, context: { path: f, cardRef: r.cardId, dates: ka(q) } });
|
|
1685
|
+
if (!Ce.ok)
|
|
1686
|
+
throw o.push(...Ce.problems), new me();
|
|
1687
1687
|
}
|
|
1688
1688
|
return y(le);
|
|
1689
1689
|
});
|
|
1690
1690
|
F = di((P == null ? void 0 : P.query) ?? {}, W);
|
|
1691
1691
|
const X = ((Ht = qe(q)) == null ? void 0 : Ht.type) ?? $t(q.type), Y = r.matrix ?? (M.editable ? M.matrix : void 0);
|
|
1692
|
-
jt(X, W, Y,
|
|
1692
|
+
jt(X, W, Y, f);
|
|
1693
1693
|
const j = M.editable && U ? ao(U, W, M.matrix, Y) : void 0, ne = !j || j.aspects.length > 0, fe = j && !("sql" in W) ? Ne(W).filter((le) => !ma(j, le.key.role)) : [], H = so(q, j, fe.map((le) => le.key.role));
|
|
1694
|
-
H && Kt(H,
|
|
1694
|
+
H && Kt(H, f);
|
|
1695
1695
|
let de = W;
|
|
1696
1696
|
if (j && !("sql" in W) && W.orderBy && !j.aspects.includes("order") && ["metric", "group_by", "detail"].some((le) => ma(j, le))) {
|
|
1697
1697
|
const { orderBy: le, ...pe } = W;
|
|
1698
1698
|
de = pe;
|
|
1699
1699
|
}
|
|
1700
|
-
let
|
|
1700
|
+
let Fe;
|
|
1701
1701
|
if (ne) {
|
|
1702
|
-
const le = !!(z && ms(z, (P == null ? void 0 : P.query) ?? {}) && (j != null && j.keptWindow)), pe = await Ut(X, de, Y,
|
|
1703
|
-
|
|
1704
|
-
const da = j ? { ...
|
|
1705
|
-
if (ge.ok || Kt(ge,
|
|
1702
|
+
const le = !!(z && ms(z, (P == null ? void 0 : P.query) ?? {}) && (j != null && j.keptWindow)), pe = await Ut(X, de, Y, f, le), Ce = pe.type === ct(X) ? { ...pe, type: q.type } : pe;
|
|
1703
|
+
Fe = Ce;
|
|
1704
|
+
const da = j ? { ...Ce, change: j } : Ce, ge = ha(q, da);
|
|
1705
|
+
if (ge.ok || Kt(ge, f), ge.ok && ge.droppedBindings.length && n.push({
|
|
1706
1706
|
code: "control_binding_dropped",
|
|
1707
1707
|
message: `"${q.title}" loses the controls bound to the levels or measures this change removes; they stop changing this card.`,
|
|
1708
|
-
path: `${
|
|
1708
|
+
path: `${f}.query`,
|
|
1709
1709
|
fix: "Keep those fields in the query, or tell the user the controls no longer apply to this card.",
|
|
1710
1710
|
details: { controlIds: ge.droppedBindings }
|
|
1711
1711
|
}), ge.ok)
|
|
1712
1712
|
for (const Ve of ge.keptLabels)
|
|
1713
|
-
|
|
1713
|
+
n.push({
|
|
1714
1714
|
code: "label_kept_after_change",
|
|
1715
1715
|
message: `"${q.title}" keeps the label "${Ve.label}" on ${Ve.field}, whose aggregate or time grain changed.`,
|
|
1716
|
-
path: `${
|
|
1716
|
+
path: `${f}.query`,
|
|
1717
1717
|
fix: "State a new label on the field ref if the old one no longer fits.",
|
|
1718
1718
|
details: { columns: [{ label: Ve.label, field: Ve.field }] }
|
|
1719
1719
|
});
|
|
1720
|
-
$({ op: "card.update", cardId:
|
|
1720
|
+
$({ op: "card.update", cardId: u, update: { kind: "requery", query: da }, changeIndex: m }, `${f}.query`), A = !0;
|
|
1721
1721
|
}
|
|
1722
|
-
fe.length && pa(ie(
|
|
1722
|
+
fe.length && pa(ie(v, u).card, fe).changed.length && $({ op: "card.update", cardId: u, update: { kind: "relabel", labels: fe }, changeIndex: m }, `${f}.query`), (ne || fe.length) && Wt(ie(v, u).card, de, Y, f, q.title ?? "", Fe, j);
|
|
1723
1723
|
}
|
|
1724
|
-
(r.query || R) && await L({ cardId:
|
|
1724
|
+
(r.query || R) && await L({ cardId: u, cardRef: r.cardId, stated: (P == null ? void 0 : P.calculations) ?? [], index: m, path: f }) && (A = !0), (r.title !== void 0 || r.description !== void 0) && $(
|
|
1725
1725
|
{
|
|
1726
1726
|
op: "card.update",
|
|
1727
|
-
cardId:
|
|
1727
|
+
cardId: u,
|
|
1728
1728
|
update: {
|
|
1729
1729
|
kind: "rename",
|
|
1730
1730
|
...r.title !== void 0 ? { title: r.title } : {},
|
|
@@ -1732,72 +1732,72 @@ async function fs(e, a, t, s) {
|
|
|
1732
1732
|
},
|
|
1733
1733
|
changeIndex: m
|
|
1734
1734
|
},
|
|
1735
|
-
|
|
1735
|
+
f
|
|
1736
1736
|
), await N({
|
|
1737
|
-
cardId:
|
|
1737
|
+
cardId: u,
|
|
1738
1738
|
cardRef: r.cardId,
|
|
1739
1739
|
request: { settings: V(r) },
|
|
1740
1740
|
queryLabels: F,
|
|
1741
1741
|
index: m,
|
|
1742
|
-
path:
|
|
1743
|
-
}), A && !c.includes(
|
|
1742
|
+
path: f
|
|
1743
|
+
}), A && !c.includes(u) && c.push(u), d.push({ ref: r.cardId, kind: "card", id: u, title: C.title ?? "", changeIndex: m });
|
|
1744
1744
|
break;
|
|
1745
1745
|
}
|
|
1746
1746
|
case "card.remove": {
|
|
1747
|
-
const
|
|
1748
|
-
b || y({ code: "card_not_editable", message: "Cards in Document sections are removed in the editor.", path: `${
|
|
1747
|
+
const u = oe(r.cardId, `${f}.cardId`), b = ie(v, u);
|
|
1748
|
+
b || y({ code: "card_not_editable", message: "Cards in Document sections are removed in the editor.", path: `${f}.cardId`, fix: "Tell the user to remove it in the editor.", details: { reason: "document_section" } }), bt(b.frame) && b.frame.cards.length > 1 && y({ code: "card_not_editable", message: "This card is an input of a custom visual; remove it in the editor.", path: `${f}.cardId`, fix: "Tell the user to remove it in the editor.", details: { reason: "custom" } }), b.frame.visualId && b.frame.cards.length > 1 && n.push({
|
|
1749
1749
|
code: "detaches_linked_visual",
|
|
1750
1750
|
message: `Removing "${b.card.title}" makes the rest of its tile local to this dashboard; it stops following its library visual.`,
|
|
1751
|
-
path:
|
|
1752
|
-
details: { cardIds: b.frame.cards.filter((C) => C.id !==
|
|
1753
|
-
}), $({ op: "card.remove", cardId:
|
|
1751
|
+
path: f,
|
|
1752
|
+
details: { cardIds: b.frame.cards.filter((C) => C.id !== u).map((C) => C.id) }
|
|
1753
|
+
}), $({ op: "card.remove", cardId: u, changeIndex: m }, f), d.push({ ref: r.cardId, kind: "card", id: u, title: b.card.title ?? "", changeIndex: m });
|
|
1754
1754
|
break;
|
|
1755
1755
|
}
|
|
1756
1756
|
case "filter.add": {
|
|
1757
|
-
const
|
|
1758
|
-
|
|
1759
|
-
const b = ot(
|
|
1757
|
+
const u = await t.loadCardSource({ domainId: r.domainId, datasetName: r.datasetName });
|
|
1758
|
+
u || y({ code: "field_not_found", message: `The dataset "${r.datasetName}" isn't available in this domain.`, path: `${f}.datasetName`, fix: "Find datasets with semaphor_list_datasets." });
|
|
1759
|
+
const b = ot(u.fields, r.field, r.datasetName);
|
|
1760
1760
|
b || y({
|
|
1761
1761
|
code: "field_not_found",
|
|
1762
1762
|
message: `"${r.field}" isn't a field of ${r.datasetName}.`,
|
|
1763
|
-
path: `${
|
|
1763
|
+
path: `${f}.field`,
|
|
1764
1764
|
fix: "Use one of details.available, or read semaphor_get_dataset_schema.",
|
|
1765
|
-
details: { available:
|
|
1765
|
+
details: { available: u.fields.slice(0, 20).map((P) => P.name) }
|
|
1766
1766
|
});
|
|
1767
|
-
const C = r.sheetIds ? Vt(r.sheetIds,
|
|
1767
|
+
const C = r.sheetIds ? Vt(r.sheetIds, f) : void 0, O = Ta(C), A = Ho({
|
|
1768
1768
|
field: b,
|
|
1769
|
-
dataSource:
|
|
1770
|
-
connectionId:
|
|
1771
|
-
connectionType:
|
|
1769
|
+
dataSource: u.dataSource,
|
|
1770
|
+
connectionId: u.connectionId,
|
|
1771
|
+
connectionType: u.connectionType,
|
|
1772
1772
|
scope: O,
|
|
1773
|
-
dashboard:
|
|
1773
|
+
dashboard: v,
|
|
1774
1774
|
createId: t.newId,
|
|
1775
1775
|
label: r.label
|
|
1776
1776
|
}), F = { ...A.filter };
|
|
1777
|
-
F.dateSelectionMode || (F.type = r.selection ?? "multiple"), r.defaultValues && (F.defaultValues = r.defaultValues), r.defaultPeriod && (F.defaultDateFilter = Ra(r.defaultPeriod, b, `${
|
|
1777
|
+
F.dateSelectionMode || (F.type = r.selection ?? "multiple"), r.defaultValues && (F.defaultValues = r.defaultValues), r.defaultPeriod && (F.defaultDateFilter = Ra(r.defaultPeriod, b, `${f}.defaultPeriod`, y)), $({ op: "filter.add", input: { ...A, filter: F }, changeIndex: m }, f), rt.set(A.id, { sheetIds: C ?? "all", changeIndex: m }), (r.defaultValues !== void 0 || r.defaultPeriod !== void 0) && dt.set(A.id, { values: r.defaultValues, period: r.defaultPeriod, changeIndex: m });
|
|
1778
1778
|
const R = r.handle;
|
|
1779
|
-
R && (h.has(R) && y({ code: "invalid_change", message: `The handle ${R} is defined twice.`, path: `${
|
|
1779
|
+
R && (h.has(R) && y({ code: "invalid_change", message: `The handle ${R} is defined twice.`, path: `${f}.handle`, fix: "Give each new card, filter or sheet its own handle." }), h.set(R, { kind: "filter", id: A.id, title: r.label })), d.push({ ref: R ?? A.id, kind: "filter", id: A.id, title: r.label, changeIndex: m });
|
|
1780
1780
|
break;
|
|
1781
1781
|
}
|
|
1782
1782
|
case "filter.update": {
|
|
1783
|
-
const
|
|
1783
|
+
const u = te(r.filterId, `${f}.filterId`), b = Le(v, u, void 0, I);
|
|
1784
1784
|
b != null && b.editable || y({
|
|
1785
1785
|
code: "filter_not_editable",
|
|
1786
1786
|
message: b && !b.editable ? b.notEditable.message : "This filter can't be changed through the MCP.",
|
|
1787
|
-
path: `${
|
|
1787
|
+
path: `${f}.filterId`,
|
|
1788
1788
|
fix: "Tell the user to change it in the editor; removing or excluding it works."
|
|
1789
1789
|
});
|
|
1790
|
-
const C = (
|
|
1790
|
+
const C = (v.inputs ?? []).find((P) => P.id === u);
|
|
1791
1791
|
if ((C == null ? void 0 : C.kind) !== "filter" || !C.filter) throw new me();
|
|
1792
1792
|
const O = { ...C.filter };
|
|
1793
1793
|
let A = !1;
|
|
1794
1794
|
r.selection && (O.type = r.selection), r.defaultValues !== void 0 && (A = !0, r.defaultValues === null ? delete O.defaultValues : O.defaultValues = r.defaultValues), r.defaultPeriod !== void 0 && (A = !0, r.defaultPeriod === null ? delete O.defaultDateFilter : O.defaultDateFilter = Ra(
|
|
1795
1795
|
r.defaultPeriod,
|
|
1796
1796
|
{ dataType: O.dataType },
|
|
1797
|
-
`${
|
|
1797
|
+
`${f}.defaultPeriod`,
|
|
1798
1798
|
y
|
|
1799
1799
|
));
|
|
1800
|
-
const F = r.sheetIds === void 0 ? void 0 : r.sheetIds ? Vt(r.sheetIds,
|
|
1800
|
+
const F = r.sheetIds === void 0 ? void 0 : r.sheetIds ? Vt(r.sheetIds, f) : "all", R = {
|
|
1801
1801
|
...r.label !== void 0 ? { label: r.label } : {},
|
|
1802
1802
|
...r.selection !== void 0 || A ? { definition: O } : {},
|
|
1803
1803
|
// A change of sheets states the sheets; what else the scope says (the cards it leaves out,
|
|
@@ -1805,136 +1805,136 @@ async function fs(e, a, t, s) {
|
|
|
1805
1805
|
...F ? { scope: Po(
|
|
1806
1806
|
C.scope,
|
|
1807
1807
|
Ta(F === "all" ? void 0 : F),
|
|
1808
|
-
new Set([...Ot(
|
|
1808
|
+
new Set([...Ot(v).values()].filter((P) => P.sheetKind === "document").map((P) => P.sheetId))
|
|
1809
1809
|
) } : {},
|
|
1810
1810
|
...A ? { values: { defaultChanged: !0, target: {} } } : {}
|
|
1811
1811
|
};
|
|
1812
|
-
$({ op: "filter.update", filterId:
|
|
1812
|
+
$({ op: "filter.update", filterId: u, settings: R, changeIndex: m }, f), F && rt.set(u, { sheetIds: F, changeIndex: m }), A && dt.set(u, { values: r.defaultValues, period: r.defaultPeriod, changeIndex: m }), d.push({ ref: r.filterId, kind: "filter", id: u, title: C.label, changeIndex: m });
|
|
1813
1813
|
break;
|
|
1814
1814
|
}
|
|
1815
1815
|
case "filter.remove": {
|
|
1816
|
-
const
|
|
1817
|
-
$({ op: "filter.remove", filterId:
|
|
1816
|
+
const u = te(r.filterId, `${f}.filterId`), b = ((zt = (v.inputs ?? []).find((C) => C.id === u)) == null ? void 0 : zt.label) ?? "";
|
|
1817
|
+
$({ op: "filter.remove", filterId: u, changeIndex: m }, f), d.push({ ref: r.filterId, kind: "filter", id: u, title: b, changeIndex: m });
|
|
1818
1818
|
break;
|
|
1819
1819
|
}
|
|
1820
1820
|
case "filter.bind": {
|
|
1821
|
-
const
|
|
1821
|
+
const u = te(r.filterId, `${f}.filterId`), b = Le(v, u, void 0, I);
|
|
1822
1822
|
b != null && b.editable || y({
|
|
1823
1823
|
code: "filter_not_editable",
|
|
1824
1824
|
message: b && !b.editable ? b.notEditable.message : "This filter can't be changed through the MCP.",
|
|
1825
|
-
path: `${
|
|
1825
|
+
path: `${f}.filterId`,
|
|
1826
1826
|
fix: "Tell the user to change it in the editor; removing or excluding it works."
|
|
1827
1827
|
});
|
|
1828
|
-
const C = Bt(r.cardId, `${
|
|
1829
|
-
$({ op: "filter.bind", filterId:
|
|
1828
|
+
const C = Bt(r.cardId, `${f}.cardId`), O = Ua(v, C).card, A = Ie(v).findFilterInput({ inputId: u }), F = A && $e(A.input, O, I).reach === "relationshipApplied", R = await fi(O, r.field, t, `${f}.field`, y, F ? b.label : void 0);
|
|
1829
|
+
$({ op: "filter.bind", filterId: u, cardId: C, binding: { kind: "bound", cardId: C, bindingId: t.newId(), target: R }, changeIndex: m }, f), d.push({ ref: r.filterId, kind: "filter", id: u, title: b.label, changeIndex: m });
|
|
1830
1830
|
break;
|
|
1831
1831
|
}
|
|
1832
1832
|
case "layout.arrange": {
|
|
1833
|
-
const
|
|
1833
|
+
const u = r.sheetId ? Ae(r.sheetId, `${f}.sheetId`) : (() => {
|
|
1834
1834
|
const b = nt();
|
|
1835
1835
|
return b.length !== 1 && y({
|
|
1836
1836
|
code: b.length ? "sheet_required" : "sheet_not_a_grid",
|
|
1837
1837
|
message: b.length ? "This dashboard has several grid sheets; say which one to arrange." : "This dashboard has no grid sheet to arrange.",
|
|
1838
|
-
path: `${
|
|
1838
|
+
path: `${f}.sheetId`,
|
|
1839
1839
|
fix: b.length ? "Send sheetId: one of details.sheets." : "Add a sheet with sheet.add earlier in this list.",
|
|
1840
1840
|
details: { sheets: Be() }
|
|
1841
1841
|
}), b[0];
|
|
1842
1842
|
})();
|
|
1843
|
-
$({ op: "layout.arrange", sheetId:
|
|
1843
|
+
$({ op: "layout.arrange", sheetId: u.id, ...r.keepOrder ? { keepOrder: !0 } : {}, changeIndex: m }, f);
|
|
1844
1844
|
break;
|
|
1845
1845
|
}
|
|
1846
1846
|
case "layout.tabs": {
|
|
1847
|
-
const
|
|
1848
|
-
new Set(
|
|
1849
|
-
const C =
|
|
1847
|
+
const u = r.cardIds.map((q, M) => oe(q, `${f}.cardIds[${M}]`)), b = (q, M, U = `${f}.cardIds`) => y({ code: "layout_invalid", message: q, path: U, fix: M });
|
|
1848
|
+
new Set(u).size !== u.length && b("Each card is named once in tabs.", "Name two or more different cards, each once.");
|
|
1849
|
+
const C = u.map((q, M) => ie(v, q) ?? b("A Document section's card can't be a tab.", "Name cards on a grid sheet.", `${f}.cardIds[${M}]`)), O = C[0].sheet;
|
|
1850
1850
|
C.some((q) => q.sheet.id !== O.id) && b("Tabs are cards on one sheet.", "Name cards on one sheet; a card moves to another sheet in the editor."), C.some((q) => bt(q.frame) && q.frame.cards.length > 1) && b("A custom visual's inputs stay in its spot.", "Name cards that aren't a custom visual's inputs, or arrange them in the editor.");
|
|
1851
1851
|
const A = C[0].frame, F = C[0].card;
|
|
1852
1852
|
d.push({ ref: r.cardIds[0], kind: "card", id: F.id, title: F.title ?? "", changeIndex: m });
|
|
1853
1853
|
const R = Ba(A);
|
|
1854
|
-
if (
|
|
1854
|
+
if (u.every((q, M) => R[M] === q)) break;
|
|
1855
1855
|
const P = [...new Map(C.map((q) => [q.frame.id, q.frame])).values()].filter((q) => q.visualId);
|
|
1856
|
-
P.length &&
|
|
1856
|
+
P.length && n.push({
|
|
1857
1857
|
code: "detaches_linked_visual",
|
|
1858
1858
|
message: "Moving these cards makes the tiles they leave or join local to this dashboard; they stop following their library visuals.",
|
|
1859
|
-
path:
|
|
1859
|
+
path: f,
|
|
1860
1860
|
details: { cardIds: P.flatMap((q) => q.cards.map((M) => M.id)) }
|
|
1861
|
-
}), F.type === "kpi" && C.slice(1).some((q) => q.card.type === "text") &&
|
|
1861
|
+
}), F.type === "kpi" && C.slice(1).some((q) => q.card.type === "text") && n.push({
|
|
1862
1862
|
code: "tabs_show_as_kpi_info",
|
|
1863
1863
|
message: `A text card in ${Va(F.title)}'s spot shows as the KPI's info, not as a tab.`,
|
|
1864
|
-
path:
|
|
1864
|
+
path: f,
|
|
1865
1865
|
fix: "Put another card first if the text should be a tab of its own."
|
|
1866
|
-
}), $({ op: "layout.tabs", sheetId: O.id, cardIds:
|
|
1866
|
+
}), $({ op: "layout.tabs", sheetId: O.id, cardIds: u, changeIndex: m }, f);
|
|
1867
1867
|
break;
|
|
1868
1868
|
}
|
|
1869
1869
|
case "layout.untab": {
|
|
1870
|
-
const
|
|
1871
|
-
if (b || y({ code: "layout_invalid", message: "A Document section's card has no spot of its own.", path: `${
|
|
1872
|
-
b.frame.visualId &&
|
|
1870
|
+
const u = oe(r.cardId, `${f}.cardId`), b = ie(v, u);
|
|
1871
|
+
if (b || y({ code: "layout_invalid", message: "A Document section's card has no spot of its own.", path: `${f}.cardId`, fix: "Name a card on a grid sheet." }), bt(b.frame) && b.frame.cards.length > 1 && y({ code: "layout_invalid", message: "A custom visual's inputs stay in its spot.", path: `${f}.cardId`, fix: "Arrange a custom visual in the editor." }), d.push({ ref: r.cardId, kind: "card", id: u, title: b.card.title ?? "", changeIndex: m }), b.frame.cards.length < 2) break;
|
|
1872
|
+
b.frame.visualId && n.push({
|
|
1873
1873
|
code: "detaches_linked_visual",
|
|
1874
1874
|
message: `Taking "${b.card.title}" out of its tabs makes them local to this dashboard; they stop following their library visual.`,
|
|
1875
|
-
path:
|
|
1875
|
+
path: f,
|
|
1876
1876
|
details: { cardIds: b.frame.cards.map((C) => C.id) }
|
|
1877
|
-
}), $({ op: "layout.untab", cardId:
|
|
1877
|
+
}), $({ op: "layout.untab", cardId: u, newFrameId: t.newId(), changeIndex: m }, f);
|
|
1878
1878
|
break;
|
|
1879
1879
|
}
|
|
1880
1880
|
case "filter.exclude": {
|
|
1881
|
-
const
|
|
1882
|
-
$({ op: "filter.exclude", filterId:
|
|
1881
|
+
const u = te(r.filterId, `${f}.filterId`), b = Bt(r.cardId, `${f}.cardId`), C = ((Yt = (v.inputs ?? []).find((O) => O.id === u)) == null ? void 0 : Yt.label) ?? "";
|
|
1882
|
+
$({ op: "filter.exclude", filterId: u, cardId: b, changeIndex: m }, f), d.push({ ref: r.filterId, kind: "filter", id: u, title: C, changeIndex: m });
|
|
1883
1883
|
break;
|
|
1884
1884
|
}
|
|
1885
1885
|
case "highlight.add":
|
|
1886
1886
|
case "highlight.remove": {
|
|
1887
|
-
const
|
|
1888
|
-
cardId:
|
|
1887
|
+
const u = oe(r.cardId, `${f}.cardId`), { card: b } = g(u, f), { op: C, cardId: O, ...A } = r, F = await N({
|
|
1888
|
+
cardId: u,
|
|
1889
1889
|
cardRef: r.cardId,
|
|
1890
1890
|
request: { highlights: r.op === "highlight.add" ? { add: [A] } : { remove: [r.ruleId] } },
|
|
1891
1891
|
queryLabels: [],
|
|
1892
1892
|
index: m,
|
|
1893
|
-
path:
|
|
1893
|
+
path: f
|
|
1894
1894
|
}), R = (Xt = (Jt = F == null ? void 0 : F.highlights) == null ? void 0 : Jt.add) == null ? void 0 : Xt[0];
|
|
1895
|
-
d.push({ ref: r.cardId, kind: "card", id:
|
|
1895
|
+
d.push({ ref: r.cardId, kind: "card", id: u, title: b.title ?? "", changeIndex: m, ...R ? { ruleId: R.id } : {} });
|
|
1896
1896
|
break;
|
|
1897
1897
|
}
|
|
1898
1898
|
case "sheet.add": {
|
|
1899
|
-
const
|
|
1900
|
-
$({ op: "sheet.add", sheet: { id:
|
|
1899
|
+
const u = t.newId();
|
|
1900
|
+
$({ op: "sheet.add", sheet: { id: u, title: r.title }, changeIndex: m }, f);
|
|
1901
1901
|
const b = r.handle ?? `$sheet_${++E}`;
|
|
1902
|
-
h.has(b) && y({ code: "invalid_change", message: `The handle ${b} is defined twice.`, path: `${
|
|
1902
|
+
h.has(b) && y({ code: "invalid_change", message: `The handle ${b} is defined twice.`, path: `${f}.handle`, fix: "Give each new card, filter or sheet its own handle." }), h.set(b, { kind: "sheet", id: u, title: r.title }), d.push({ ref: b, kind: "sheet", id: u, title: r.title, changeIndex: m });
|
|
1903
1903
|
break;
|
|
1904
1904
|
}
|
|
1905
1905
|
case "sheet.update": {
|
|
1906
|
-
const
|
|
1907
|
-
(
|
|
1906
|
+
const u = it(r.sheetId, `${f}.sheetId`, { grid: !1 });
|
|
1907
|
+
(u.title ?? "") !== r.title && $({ op: "sheet.update", sheetId: u.id, title: r.title, changeIndex: m }, f), d.push({ ref: r.sheetId, kind: "sheet", id: u.id, title: r.title, changeIndex: m });
|
|
1908
1908
|
break;
|
|
1909
1909
|
}
|
|
1910
1910
|
case "dashboard.update": {
|
|
1911
|
-
const
|
|
1912
|
-
(
|
|
1911
|
+
const u = r.title !== void 0 && r.title !== v.title ? r.title : void 0, b = r.description === null ? v.description ? null : void 0 : r.description !== v.description ? r.description : void 0;
|
|
1912
|
+
(u !== void 0 || b !== void 0) && $(
|
|
1913
1913
|
{
|
|
1914
1914
|
op: "dashboard.update",
|
|
1915
|
-
...
|
|
1915
|
+
...u !== void 0 ? { title: u } : {},
|
|
1916
1916
|
...b !== void 0 ? { description: b } : {},
|
|
1917
1917
|
changeIndex: m
|
|
1918
1918
|
},
|
|
1919
|
-
|
|
1919
|
+
f
|
|
1920
1920
|
);
|
|
1921
1921
|
break;
|
|
1922
1922
|
}
|
|
1923
1923
|
case "dashboard.style": {
|
|
1924
|
-
const { op:
|
|
1925
|
-
|
|
1926
|
-
const { style: C, organizationAppearance: O } = za(
|
|
1924
|
+
const { op: u, ...b } = r;
|
|
1925
|
+
x ?? (x = t.readOrganizationAppearance ? t.readOrganizationAppearance() : Promise.resolve(null));
|
|
1926
|
+
const { style: C, organizationAppearance: O } = za(v, await x), A = dn({ style: C, edit: b, layers: { organizationAppearance: O } });
|
|
1927
1927
|
if (A.ok)
|
|
1928
|
-
A.sentences.length && $({ op: "dashboard.style", style: A.style, sentences: A.sentences, changeIndex: m },
|
|
1928
|
+
A.sentences.length && $({ op: "dashboard.style", style: A.style, sentences: A.sentences, changeIndex: m }, f);
|
|
1929
1929
|
else {
|
|
1930
1930
|
const { refusal: F } = A;
|
|
1931
|
-
y({ code: F.code, message: F.message, path: F.field === "edit" ?
|
|
1931
|
+
y({ code: F.code, message: F.message, path: F.field === "edit" ? f : `${f}.${F.field}`, fix: F.fix });
|
|
1932
1932
|
}
|
|
1933
1933
|
break;
|
|
1934
1934
|
}
|
|
1935
1935
|
case "variable.add": {
|
|
1936
|
-
Je(
|
|
1937
|
-
const
|
|
1936
|
+
Je(v, r.name) && y({ code: "variable_name_taken", message: `A variable named ${r.name} is already on this dashboard.`, path: `${f}.name`, fix: "Choose another name, or change it with variable.update." });
|
|
1937
|
+
const u = await wa(
|
|
1938
1938
|
{
|
|
1939
1939
|
id: t.newId(),
|
|
1940
1940
|
name: r.name,
|
|
@@ -1943,76 +1943,76 @@ async function fs(e, a, t, s) {
|
|
|
1943
1943
|
get: r.get,
|
|
1944
1944
|
...r.presentation ? { presentation: r.presentation } : {},
|
|
1945
1945
|
...r.emptyText ? { emptyText: r.emptyText } : {},
|
|
1946
|
-
path:
|
|
1946
|
+
path: f
|
|
1947
1947
|
},
|
|
1948
|
-
|
|
1949
|
-
|
|
1948
|
+
v,
|
|
1949
|
+
Re
|
|
1950
1950
|
);
|
|
1951
|
-
$({ op: "variable.add", variable:
|
|
1951
|
+
$({ op: "variable.add", variable: u, changeIndex: m }, f), d.push({ ref: r.name, kind: "variable", id: u.id, title: u.name, changeIndex: m });
|
|
1952
1952
|
break;
|
|
1953
1953
|
}
|
|
1954
1954
|
case "variable.update": {
|
|
1955
|
-
const
|
|
1955
|
+
const u = Yn(v, r.name, `${f}.name`, Re), b = r.rename ?? u.name, C = {
|
|
1956
1956
|
...r.rename !== void 0 ? { name: r.rename } : {},
|
|
1957
1957
|
...r.label !== void 0 ? { label: r.label } : {},
|
|
1958
1958
|
...r.presentation !== void 0 ? { presentation: r.presentation } : {},
|
|
1959
1959
|
...r.emptyText !== void 0 ? { emptyText: r.emptyText } : {}
|
|
1960
|
-
}, O = { ...
|
|
1960
|
+
}, O = { ...v, variables: (v.variables ?? []).filter((R) => R.id !== u.id) };
|
|
1961
1961
|
if (r.query) {
|
|
1962
1962
|
const R = await wa(
|
|
1963
1963
|
{
|
|
1964
|
-
id:
|
|
1964
|
+
id: u.id,
|
|
1965
1965
|
name: b,
|
|
1966
|
-
label: r.label === null ? void 0 : r.label ??
|
|
1966
|
+
label: r.label === null ? void 0 : r.label ?? u.label,
|
|
1967
1967
|
query: r.query,
|
|
1968
|
-
get: r.get ??
|
|
1969
|
-
presentation: r.presentation === null ? void 0 : r.presentation ??
|
|
1970
|
-
emptyText: r.emptyText === null ? void 0 : r.emptyText ??
|
|
1971
|
-
path:
|
|
1968
|
+
get: r.get ?? u.get,
|
|
1969
|
+
presentation: r.presentation === null ? void 0 : r.presentation ?? u.presentation,
|
|
1970
|
+
emptyText: r.emptyText === null ? void 0 : r.emptyText ?? u.emptyText,
|
|
1971
|
+
path: f
|
|
1972
1972
|
},
|
|
1973
1973
|
O,
|
|
1974
|
-
|
|
1974
|
+
Re
|
|
1975
1975
|
);
|
|
1976
1976
|
C.query = R.query, C.get = R.get;
|
|
1977
1977
|
} else if (r.get !== void 0) {
|
|
1978
|
-
const R = Zn(
|
|
1978
|
+
const R = Zn(u, r.get, O, Re, f);
|
|
1979
1979
|
C.query = R.query, C.get = R.get;
|
|
1980
1980
|
}
|
|
1981
|
-
Object.keys(C).length || y({ code: "invalid_change", message: `variable.update on ${
|
|
1982
|
-
const A = { ...
|
|
1983
|
-
F.length && B(cs(F,
|
|
1981
|
+
Object.keys(C).length || y({ code: "invalid_change", message: `variable.update on ${u.name} changes nothing.`, path: f, fix: "Send rename, label, query, get, presentation or emptyText." });
|
|
1982
|
+
const A = { ...u, ...Object.fromEntries(Object.entries(C).map(([R, P]) => [R, P ?? void 0])), id: u.id }, F = Dt(A, { ...O, variables: [...O.variables, A] });
|
|
1983
|
+
F.length && B(cs(F, f)), $({ op: "variable.update", variableId: u.id, patch: C, changeIndex: m }, f), d.push({ ref: r.name, kind: "variable", id: u.id, title: b, changeIndex: m });
|
|
1984
1984
|
break;
|
|
1985
1985
|
}
|
|
1986
1986
|
case "variable.remove": {
|
|
1987
|
-
const
|
|
1988
|
-
|
|
1989
|
-
const b =
|
|
1987
|
+
const u = Je(v, r.name);
|
|
1988
|
+
u || y(ls(v, r.name, `${f}.name`));
|
|
1989
|
+
const b = u, C = ei(v, b.id);
|
|
1990
1990
|
C.places.length && y({
|
|
1991
1991
|
code: "variable_in_use",
|
|
1992
1992
|
message: `${b.name} is shown in ${C.words}.`,
|
|
1993
|
-
path: `${
|
|
1993
|
+
path: `${f}.name`,
|
|
1994
1994
|
fix: "Remove its chips first (card.update with text, or document.text.update), or ask the user whether the chips should read as missing.",
|
|
1995
1995
|
details: { places: C.places }
|
|
1996
|
-
}), $({ op: "variable.remove", variableId: b.id, changeIndex: m },
|
|
1996
|
+
}), $({ op: "variable.remove", variableId: b.id, changeIndex: m }, f), d.push({ ref: r.name, kind: "variable", id: b.id, title: b.name, changeIndex: m });
|
|
1997
1997
|
break;
|
|
1998
1998
|
}
|
|
1999
1999
|
case "document.text.update": {
|
|
2000
|
-
const
|
|
2001
|
-
if (d.push({ ref: r.sheetId, kind: "sheet", id:
|
|
2002
|
-
$({ op: "document.text", sheetId:
|
|
2000
|
+
const u = it(r.sheetId, `${f}.sheetId`, { grid: !1 }), { edit: b, unchanged: C } = ti(r, v, u, f, Re);
|
|
2001
|
+
if (d.push({ ref: r.sheetId, kind: "sheet", id: u.id, title: u.title ?? "", changeIndex: m }), C) break;
|
|
2002
|
+
$({ op: "document.text", sheetId: u.id, edit: b, changeIndex: m }, f);
|
|
2003
2003
|
break;
|
|
2004
2004
|
}
|
|
2005
2005
|
default: {
|
|
2006
|
-
const
|
|
2007
|
-
throw new Error(`Unhandled change ${JSON.stringify(
|
|
2006
|
+
const u = r;
|
|
2007
|
+
throw new Error(`Unhandled change ${JSON.stringify(u)}`);
|
|
2008
2008
|
}
|
|
2009
2009
|
}
|
|
2010
|
-
} catch (
|
|
2011
|
-
if (!(
|
|
2010
|
+
} catch (u) {
|
|
2011
|
+
if (!(u instanceof me)) throw u;
|
|
2012
2012
|
}
|
|
2013
2013
|
}
|
|
2014
|
-
if (
|
|
2015
|
-
const ae = wt(e, i,
|
|
2014
|
+
if (o.length) return { ok: !1, problems: o };
|
|
2015
|
+
const ae = wt(e, i, { ...p, ...I });
|
|
2016
2016
|
if (!ae.ok)
|
|
2017
2017
|
return {
|
|
2018
2018
|
ok: !1,
|
|
@@ -2028,59 +2028,59 @@ async function fs(e, a, t, s) {
|
|
|
2028
2028
|
for (const m of c) {
|
|
2029
2029
|
const r = ie(ae.dashboard, m);
|
|
2030
2030
|
if (!r) continue;
|
|
2031
|
-
const
|
|
2032
|
-
|
|
2031
|
+
const f = ((ea = i.find((O) => Pt(O) === m)) == null ? void 0 : ea.changeIndex) ?? 0, u = we(r.card, { sql: !0 }), b = ((ta = qe(r.card)) == null ? void 0 : ta.type) ?? $t(r.card.type);
|
|
2032
|
+
u.editable && ("sql" in u.query ? !!u.query.sql : "measures" in u.query ? u.query.measures.length > 0 : u.query.columns.length > 0) && ((aa = De[b]) == null ? void 0 : aa.forms.includes(tt(u.query))) || o.push({
|
|
2033
2033
|
code: "type_not_supported",
|
|
2034
2034
|
message: `As changed, "${r.card.title}" would have no query a ${b.replace(/_/g, " ")} can run.`,
|
|
2035
|
-
path: `changes[${
|
|
2036
|
-
fix: `Send a complete query with the type change: ${((sa =
|
|
2035
|
+
path: `changes[${f}]`,
|
|
2036
|
+
fix: `Send a complete query with the type change: ${((sa = De[b]) == null ? void 0 : sa.forms.map((O) => Ue[O]).join(" or ")) ?? "a measures query"}.`
|
|
2037
2037
|
});
|
|
2038
2038
|
}
|
|
2039
|
-
if (
|
|
2039
|
+
if (o.push(...ii(e, ae.dashboard, i, rt, I)), o.push(...ri(ae.dashboard, dt, t.calendar)), o.length) return { ok: !1, problems: o };
|
|
2040
2040
|
for (const m of i) {
|
|
2041
2041
|
if (m.op !== "filter.add" && !(m.op === "filter.update" && m.settings.scope)) continue;
|
|
2042
|
-
const r = m.op === "filter.add" ? m.input.id : m.filterId,
|
|
2043
|
-
if (!(
|
|
2044
|
-
const
|
|
2042
|
+
const r = m.op === "filter.add" ? m.input.id : m.filterId, f = Le(ae.dashboard, r, void 0, I);
|
|
2043
|
+
if (!(f != null && f.editable)) continue;
|
|
2044
|
+
const u = async (A) => {
|
|
2045
2045
|
const F = [];
|
|
2046
2046
|
for (const R of A) {
|
|
2047
2047
|
const P = R.datasetName ? await t.findRelationshipFields({
|
|
2048
|
-
domainId:
|
|
2049
|
-
fromDataset:
|
|
2050
|
-
field:
|
|
2048
|
+
domainId: f.domainId,
|
|
2049
|
+
fromDataset: f.datasetName,
|
|
2050
|
+
field: f.field,
|
|
2051
2051
|
toDataset: R.datasetName
|
|
2052
2052
|
}) : [];
|
|
2053
2053
|
F.push({ ...R, suggestedFields: P });
|
|
2054
2054
|
}
|
|
2055
2055
|
return F;
|
|
2056
|
-
}, b = (A) => A.map((F) => `"${F.title}"`).join(", "), C =
|
|
2057
|
-
if (C.length &&
|
|
2056
|
+
}, b = (A) => A.map((F) => `"${F.title}"`).join(", "), C = f.notReached.filter((A) => A.reason === "sql_no_filter_reference"), O = f.notReached.filter((A) => A.reason !== "sql_no_filter_reference");
|
|
2057
|
+
if (C.length && n.push({
|
|
2058
2058
|
code: "filter_not_reaching_cards",
|
|
2059
|
-
message: `"${
|
|
2059
|
+
message: `"${f.label}" doesn't reach ${C.length} SQL card${C.length === 1 ? "" : "s"} whose SQL doesn't use dashboard filters: ${b(C)}.`,
|
|
2060
2060
|
path: `changes[${m.changeIndex ?? 0}]`,
|
|
2061
2061
|
fix: "To filter a SQL card, add {{ filters | where }} to its SQL (or {{ filters | and }} after an existing WHERE) with card.update, or leave it unfiltered.",
|
|
2062
2062
|
details: { cards: C }
|
|
2063
2063
|
}), O.length) {
|
|
2064
|
-
const A = await
|
|
2065
|
-
|
|
2064
|
+
const A = await u(O);
|
|
2065
|
+
n.push({
|
|
2066
2066
|
code: "filter_not_reaching_cards",
|
|
2067
|
-
message: `"${
|
|
2067
|
+
message: `"${f.label}" doesn't reach ${A.length} card${A.length === 1 ? "" : "s"} on its sheets: ${b(A)}.`,
|
|
2068
2068
|
path: `changes[${m.changeIndex ?? 0}]`,
|
|
2069
2069
|
fix: "Add filter.bind with one of the suggested fields to reach a card, or leave it unfiltered.",
|
|
2070
2070
|
details: { cards: A }
|
|
2071
2071
|
});
|
|
2072
2072
|
}
|
|
2073
|
-
if ((oa =
|
|
2073
|
+
if ((oa = f.sqlPending) != null && oa.length && n.push({
|
|
2074
2074
|
code: "filter_reach_through_sql",
|
|
2075
|
-
message: `"${
|
|
2075
|
+
message: `"${f.label}" may reach ${f.sqlPending.length} SQL card${f.sqlPending.length === 1 ? "" : "s"} as ${f.sqlPending.length === 1 ? "its" : "their"} SQL decides: ${b(f.sqlPending)}.`,
|
|
2076
2076
|
path: `changes[${m.changeIndex ?? 0}]`,
|
|
2077
2077
|
fix: "Read the card's SQL to tell the user whether it uses this filter.",
|
|
2078
|
-
details: { cards:
|
|
2079
|
-
}), (na =
|
|
2080
|
-
const A = await f
|
|
2081
|
-
|
|
2078
|
+
details: { cards: f.sqlPending }
|
|
2079
|
+
}), (na = f.relationshipPending) != null && na.length) {
|
|
2080
|
+
const A = await u(f.relationshipPending);
|
|
2081
|
+
n.push({
|
|
2082
2082
|
code: "filter_reach_through_relationships",
|
|
2083
|
-
message: `"${
|
|
2083
|
+
message: `"${f.label}" may reach ${A.length} card${A.length === 1 ? "" : "s"} on its sheets through the domain's relationships: ${b(A)}. Whether it applies is decided when each card runs.`,
|
|
2084
2084
|
path: `changes[${m.changeIndex ?? 0}]`,
|
|
2085
2085
|
fix: "Add filter.bind with one of the suggested fields to make it certain, or leave it to the relationships.",
|
|
2086
2086
|
details: { cards: A }
|
|
@@ -2089,56 +2089,56 @@ async function fs(e, a, t, s) {
|
|
|
2089
2089
|
}
|
|
2090
2090
|
if (t.readComparisonDates)
|
|
2091
2091
|
for (const [m, r] of k) {
|
|
2092
|
-
const
|
|
2093
|
-
if (!
|
|
2094
|
-
const
|
|
2095
|
-
|
|
2092
|
+
const f = (ia = ie(ae.dashboard, m)) == null ? void 0 : ia.card;
|
|
2093
|
+
if (!f) continue;
|
|
2094
|
+
const u = await t.readComparisonDates({ card: f, dashboard: ae.dashboard });
|
|
2095
|
+
u.dateWindow === "none" && n.push({
|
|
2096
2096
|
code: "comparison_without_date_window",
|
|
2097
|
-
message: `"${
|
|
2097
|
+
message: `"${f.title || "Untitled"}" compares with an earlier period only while a date range applies to ${((ra = u.comparisonDate) == null ? void 0 : ra.label) ?? "its date"}; none does yet.`,
|
|
2098
2098
|
path: r,
|
|
2099
2099
|
fix: "Add a timeWindow on that date, or a dashboard date filter that reaches the card."
|
|
2100
2100
|
});
|
|
2101
2101
|
}
|
|
2102
|
-
const Is = si(ae.dashboard, i, ae.descriptions,
|
|
2102
|
+
const Is = si(ae.dashboard, i, ae.descriptions, I);
|
|
2103
2103
|
return {
|
|
2104
2104
|
ok: !0,
|
|
2105
2105
|
operations: i,
|
|
2106
|
-
context:
|
|
2106
|
+
context: p,
|
|
2107
2107
|
dashboard: ae.dashboard,
|
|
2108
2108
|
detaches: ae.detaches,
|
|
2109
2109
|
refs: d,
|
|
2110
2110
|
descriptions: Is,
|
|
2111
2111
|
changedCardIds: c,
|
|
2112
2112
|
requires: [...l],
|
|
2113
|
-
warnings:
|
|
2113
|
+
warnings: n
|
|
2114
2114
|
};
|
|
2115
2115
|
}
|
|
2116
2116
|
function si(e, a, t, s) {
|
|
2117
|
-
const
|
|
2118
|
-
if (!n.length) return [...t];
|
|
2119
|
-
const o = as(e, void 0, s);
|
|
2117
|
+
const o = a.filter((l) => l.op === "card.add");
|
|
2120
2118
|
if (!o.length) return [...t];
|
|
2119
|
+
const n = as(e, void 0, s);
|
|
2120
|
+
if (!n.length) return [...t];
|
|
2121
2121
|
const i = (l) => et(l.map((c) => `"${c}"`)), d = /* @__PURE__ */ new Map();
|
|
2122
|
-
for (const l of
|
|
2122
|
+
for (const l of o) {
|
|
2123
2123
|
const c = Pt(l);
|
|
2124
2124
|
if (!c || l.changeIndex === void 0) continue;
|
|
2125
|
-
const h =
|
|
2125
|
+
const h = n.filter((_) => _.reaches.includes(c)).map((_) => _.label), p = (_) => n.filter(
|
|
2126
2126
|
(S) => {
|
|
2127
2127
|
var y;
|
|
2128
2128
|
return "notReached" in S && ((y = S.notReached) == null ? void 0 : y.some((D) => D.cardId === c && D.reason === "sql_no_filter_reference" === _));
|
|
2129
2129
|
}
|
|
2130
|
-
).map((S) => S.label),
|
|
2130
|
+
).map((S) => S.label), I = p(!1), v = p(!0), x = n.filter((_) => {
|
|
2131
2131
|
var S;
|
|
2132
2132
|
return (S = _.relationshipPending) == null ? void 0 : S.some((y) => y.cardId === c);
|
|
2133
|
-
}).map((_) => _.label),
|
|
2133
|
+
}).map((_) => _.label), w = n.filter((_) => {
|
|
2134
2134
|
var S;
|
|
2135
2135
|
return (S = _.sqlPending) == null ? void 0 : S.some((y) => y.cardId === c);
|
|
2136
2136
|
}).map((_) => _.label), E = [
|
|
2137
2137
|
...h.length ? [`The dashboard's ${i(h)} filter${h.length === 1 ? " applies" : "s apply"} to it.`] : [],
|
|
2138
|
-
...
|
|
2139
|
-
...
|
|
2140
|
-
...
|
|
2141
|
-
...
|
|
2138
|
+
...I.length ? [`${i(I)} ${I.length === 1 ? "doesn't" : "don't"} reach it.`] : [],
|
|
2139
|
+
...v.length ? [`${i(v)} ${v.length === 1 ? "doesn't" : "don't"} reach it: its SQL doesn't use dashboard filters.`] : [],
|
|
2140
|
+
...x.length ? [`${i(x)} may reach it through the domain's relationships.`] : [],
|
|
2141
|
+
...w.length ? [`${i(w)} may apply through its SQL.`] : []
|
|
2142
2142
|
];
|
|
2143
2143
|
E.length && d.set(l.changeIndex, E.join(" "));
|
|
2144
2144
|
}
|
|
@@ -2161,37 +2161,37 @@ function ni(e, a) {
|
|
|
2161
2161
|
if (!a.length || !e.config) return e;
|
|
2162
2162
|
const t = { ...e.config }, s = [];
|
|
2163
2163
|
if (t.matrix) {
|
|
2164
|
-
const
|
|
2165
|
-
for (const { key: h, label:
|
|
2164
|
+
const n = t.matrix, i = vo(n), d = [...n.spec.rows, ...n.spec.columns], l = { ...n.presentation.levelLabels }, c = { ...n.presentation.measureLabels };
|
|
2165
|
+
for (const { key: h, label: p } of a) {
|
|
2166
2166
|
if (h.role === "metric") {
|
|
2167
|
-
const
|
|
2168
|
-
if (
|
|
2169
|
-
c[
|
|
2167
|
+
const I = i.measures.findIndex((v) => He(v, h));
|
|
2168
|
+
if (I < 0) continue;
|
|
2169
|
+
c[n.spec.measures[I].id] = p;
|
|
2170
2170
|
} else {
|
|
2171
|
-
const
|
|
2172
|
-
if (
|
|
2173
|
-
l[d[
|
|
2171
|
+
const I = i.levels.findIndex((v) => He(v, h));
|
|
2172
|
+
if (I < 0) continue;
|
|
2173
|
+
l[d[I].id] = p;
|
|
2174
2174
|
}
|
|
2175
2175
|
s.push(h);
|
|
2176
2176
|
}
|
|
2177
|
-
return t.matrix = { ...
|
|
2177
|
+
return t.matrix = { ...n, presentation: { ...n.presentation, levelLabels: l, measureLabels: c } }, { ...e, config: t, statedLabels: s };
|
|
2178
2178
|
}
|
|
2179
|
-
const
|
|
2180
|
-
for (const { key:
|
|
2181
|
-
const d = [...t[n
|
|
2182
|
-
l < 0 || (d[l] = mn(d[l], i), t[n
|
|
2179
|
+
const o = { metric: "metricColumns", group_by: "groupByColumns", detail: "detailColumns" };
|
|
2180
|
+
for (const { key: n, label: i } of a) {
|
|
2181
|
+
const d = [...t[o[n.role]] ?? []], l = Ka(n.role, d).findIndex((c) => He(c, n));
|
|
2182
|
+
l < 0 || (d[l] = mn(d[l], i), t[o[n.role]] = d, s.push(n));
|
|
2183
2183
|
}
|
|
2184
2184
|
return { ...e, config: t, statedLabels: s };
|
|
2185
2185
|
}
|
|
2186
|
-
function ii(e, a, t, s,
|
|
2186
|
+
function ii(e, a, t, s, o) {
|
|
2187
2187
|
var E;
|
|
2188
|
-
const
|
|
2188
|
+
const n = [], i = new Map(xe(a).map((_) => [_.cardId, _])), d = Ot(a), l = Ie(a), c = (_) => {
|
|
2189
2189
|
var S, y;
|
|
2190
2190
|
return ((y = (S = a.sheets) == null ? void 0 : S.find((D) => D.id === _)) == null ? void 0 : y.title) ?? _;
|
|
2191
2191
|
}, h = (_, S) => {
|
|
2192
2192
|
var y;
|
|
2193
2193
|
return ((y = [...t].reverse().find((D) => Pt(D) === S || "filterId" in D && D.filterId === _)) == null ? void 0 : y.changeIndex) ?? 0;
|
|
2194
|
-
},
|
|
2194
|
+
}, p = (_, S) => {
|
|
2195
2195
|
const y = l.findFilterInput({ inputId: _ }).input, D = i.get(S), $ = `"${D.card.title ?? ""}"`, N = `"${y.label}"`;
|
|
2196
2196
|
if (D.kind === "documentSectionCard")
|
|
2197
2197
|
return {
|
|
@@ -2199,8 +2199,8 @@ function ii(e, a, t, s, n) {
|
|
|
2199
2199
|
message: `${$} is in a Document section, which takes only the filters its Document sheet shows.`,
|
|
2200
2200
|
fix: "Tell the user to change where the filter shows in the editor."
|
|
2201
2201
|
};
|
|
2202
|
-
const
|
|
2203
|
-
if (
|
|
2202
|
+
const g = d.get(D.sheetId);
|
|
2203
|
+
if (g && !Ga(y, g))
|
|
2204
2204
|
return {
|
|
2205
2205
|
reason: "outside_sheets",
|
|
2206
2206
|
message: `${N} isn't shown on "${c(D.sheetId)}", so it can't filter ${$}.`,
|
|
@@ -2223,7 +2223,7 @@ function ii(e, a, t, s, n) {
|
|
|
2223
2223
|
fix: "Bind the field it should use (filter.bind), or exclude the card (filter.exclude), in the same proposal."
|
|
2224
2224
|
};
|
|
2225
2225
|
case "relationship": {
|
|
2226
|
-
const T =
|
|
2226
|
+
const T = $e(y, D.card, o);
|
|
2227
2227
|
return T.reach === "blocked" ? {
|
|
2228
2228
|
reason: "relationship_route_changed",
|
|
2229
2229
|
message: `The relationships ${$} used for ${N} changed in the domain.`,
|
|
@@ -2251,17 +2251,17 @@ function ii(e, a, t, s, n) {
|
|
|
2251
2251
|
throw new Error(`Unhandled filter card target ${String(T.status)}`);
|
|
2252
2252
|
}
|
|
2253
2253
|
}
|
|
2254
|
-
},
|
|
2254
|
+
}, I = /* @__PURE__ */ new Set(), v = /* @__PURE__ */ new Map();
|
|
2255
2255
|
for (const _ of t)
|
|
2256
|
-
(_.op === "filter.bind" || _.op === "filter.exclude") &&
|
|
2257
|
-
for (const _ of
|
|
2258
|
-
const S = Le(a, _.filterId, void 0,
|
|
2256
|
+
(_.op === "filter.bind" || _.op === "filter.exclude") && v.set(`${_.filterId}|${_.cardId}`, _);
|
|
2257
|
+
for (const _ of v.values()) {
|
|
2258
|
+
const S = Le(a, _.filterId, void 0, o), y = i.get(_.cardId);
|
|
2259
2259
|
if (!S || !y) continue;
|
|
2260
2260
|
const D = S.reaches.includes(_.cardId);
|
|
2261
2261
|
if (_.op === "filter.bind" ? D : !D) continue;
|
|
2262
|
-
|
|
2263
|
-
const $ = _.op === "filter.bind" ?
|
|
2264
|
-
|
|
2262
|
+
I.add(`${_.filterId}|${_.cardId}`);
|
|
2263
|
+
const $ = _.op === "filter.bind" ? p(_.filterId, _.cardId) : { reason: "filter_settings_override", message: `"${S.label}" would still filter "${y.card.title ?? ""}".`, fix: "Tell the user to change the filter's settings in the editor." };
|
|
2264
|
+
n.push({
|
|
2265
2265
|
code: "filter_not_editable",
|
|
2266
2266
|
message: $.message,
|
|
2267
2267
|
path: `changes[${_.changeIndex ?? 0}]`,
|
|
@@ -2270,13 +2270,13 @@ function ii(e, a, t, s, n) {
|
|
|
2270
2270
|
});
|
|
2271
2271
|
}
|
|
2272
2272
|
for (const [_, S] of s) {
|
|
2273
|
-
const y = Le(a, _, void 0,
|
|
2273
|
+
const y = Le(a, _, void 0, o);
|
|
2274
2274
|
if (!y) continue;
|
|
2275
|
-
const D = y.editable && ((E = y.exceptSheetIds) == null ? void 0 : E.some((
|
|
2275
|
+
const D = y.editable && ((E = y.exceptSheetIds) == null ? void 0 : E.some((g) => {
|
|
2276
2276
|
var k;
|
|
2277
|
-
return ((k = d.get(
|
|
2277
|
+
return ((k = d.get(g)) == null ? void 0 : k.sheetKind) === "dashboard";
|
|
2278
2278
|
})), $ = y.editable && !D ? y.sheetIds : void 0, N = S.sheetIds === "all" ? "all" : [...S.sheetIds].sort();
|
|
2279
|
-
Pe($ === "all" || !$ ? $ : [...$].sort(), N) ||
|
|
2279
|
+
Pe($ === "all" || !$ ? $ : [...$].sort(), N) || n.push({
|
|
2280
2280
|
code: "filter_not_editable",
|
|
2281
2281
|
message: `"${y.label}" wouldn't show on the sheets asked for. Change where it shows in the editor.`,
|
|
2282
2282
|
path: `changes[${S.changeIndex}].sheetIds`,
|
|
@@ -2284,15 +2284,15 @@ function ii(e, a, t, s, n) {
|
|
|
2284
2284
|
details: { reason: "filter_settings_override", ...$ ? { sheetIds: $ } : {} }
|
|
2285
2285
|
});
|
|
2286
2286
|
}
|
|
2287
|
-
const
|
|
2287
|
+
const x = Ie(e), w = (_) => _ === "blocked" || _ === "ambiguous";
|
|
2288
2288
|
for (const _ of l.inputs) {
|
|
2289
2289
|
const S = _.input.id;
|
|
2290
2290
|
for (const y of l.reachedCards({ inputId: S })) {
|
|
2291
|
-
if (
|
|
2292
|
-
const D =
|
|
2293
|
-
if (D && $ &&
|
|
2294
|
-
const N =
|
|
2295
|
-
|
|
2291
|
+
if (I.has(`${S}|${y.cardId}`) || !w($e(_.input, y.card, o).reach)) continue;
|
|
2292
|
+
const D = x.findFilterInput({ inputId: S }), $ = D && x.reachedCards({ inputId: S }).find((g) => g.cardId === y.cardId);
|
|
2293
|
+
if (D && $ && w($e(D.input, $.card, o).reach)) continue;
|
|
2294
|
+
const N = p(S, y.cardId);
|
|
2295
|
+
n.push({
|
|
2296
2296
|
code: "invalid_change",
|
|
2297
2297
|
message: `${N.message} The card would stop showing data while "${_.input.label}" has a value.`,
|
|
2298
2298
|
path: `changes[${h(S, y.cardId)}]`,
|
|
@@ -2301,63 +2301,63 @@ function ii(e, a, t, s, n) {
|
|
|
2301
2301
|
});
|
|
2302
2302
|
}
|
|
2303
2303
|
}
|
|
2304
|
-
return
|
|
2304
|
+
return n;
|
|
2305
2305
|
}
|
|
2306
2306
|
function ri(e, a, t) {
|
|
2307
|
-
const s = [],
|
|
2308
|
-
for (const [
|
|
2309
|
-
const d =
|
|
2307
|
+
const s = [], o = Ie(e);
|
|
2308
|
+
for (const [n, i] of a) {
|
|
2309
|
+
const d = o.findFilterInput({ inputId: n });
|
|
2310
2310
|
if (!d) continue;
|
|
2311
|
-
const l = Ha({ dashboard: e, target: { kind: "dashboardInput", input: d.input, scope: {} }, calendar: t }).value, c = d.input.filter.dateSelectionMode, h = c === "day" ? "its date picker takes one day" : void 0,
|
|
2311
|
+
const l = Ha({ dashboard: e, target: { kind: "dashboardInput", input: d.input, scope: {} }, calendar: t }).value, c = d.input.filter.dateSelectionMode, h = c === "day" ? "its date picker takes one day" : c === "months" ? "its month picker takes one whole month" : void 0, p = (I, v) => s.push({
|
|
2312
2312
|
code: "filter_not_editable",
|
|
2313
|
-
message:
|
|
2313
|
+
message: I,
|
|
2314
2314
|
path: `changes[${i.changeIndex}]`,
|
|
2315
|
-
fix:
|
|
2315
|
+
fix: v,
|
|
2316
2316
|
details: { reason: "default_not_applied", ...c ? { datePicker: c } : {} }
|
|
2317
2317
|
});
|
|
2318
2318
|
if (i.period) {
|
|
2319
|
-
const
|
|
2320
|
-
(!
|
|
2319
|
+
const I = Ja(l && "relativeMeta" in l ? l.relativeMeta : void 0);
|
|
2320
|
+
(!I || an(i.period) || !sn(I, i.period)) && p(
|
|
2321
2321
|
`"${d.input.label}" wouldn't load with that default${h ? `: ${h}` : ""}.`,
|
|
2322
2322
|
h ? "Ask for a default the picker can take, or tell the user to make it a date range in the editor." : "Tell the user to change the filter's default in the editor."
|
|
2323
2323
|
);
|
|
2324
2324
|
} else if (i.values) {
|
|
2325
|
-
const
|
|
2326
|
-
(!l ||
|
|
2325
|
+
const I = (v) => JSON.stringify((v ?? []).map(String).sort());
|
|
2326
|
+
(!l || I(l.values) !== I(i.values)) && p(`"${d.input.label}" wouldn't load with those values.`, "Tell the user to change the filter's default in the editor.");
|
|
2327
2327
|
} else
|
|
2328
|
-
(Ya(d.input.filter.dataType) ? i.period === null : i.values === null) && l &&
|
|
2328
|
+
(Ya(d.input.filter.dataType) ? i.period === null : i.values === null) && l && p(`"${d.input.label}" would still load with a default.`, "Tell the user to change the filter's default in the editor.");
|
|
2329
2329
|
}
|
|
2330
2330
|
return s;
|
|
2331
2331
|
}
|
|
2332
2332
|
function yt(e) {
|
|
2333
2333
|
const a = e.measures;
|
|
2334
2334
|
if (!Array.isArray(a)) return { query: e, calculations: [] };
|
|
2335
|
-
const t = [], s = a.map((
|
|
2336
|
-
if (!
|
|
2337
|
-
const { comparison: i, transform: d, ...l } =
|
|
2338
|
-
return i === void 0 && d === void 0 ?
|
|
2335
|
+
const t = [], s = a.map((o, n) => {
|
|
2336
|
+
if (!o || typeof o != "object") return o;
|
|
2337
|
+
const { comparison: i, transform: d, ...l } = o;
|
|
2338
|
+
return i === void 0 && d === void 0 ? o : (t.push({ index: n, calculations: { ...i !== void 0 ? { comparison: i } : {}, ...d !== void 0 ? { transform: d } : {} } }), Object.keys(l).length === 1 && typeof l.name == "string" ? l.name : l);
|
|
2339
2339
|
});
|
|
2340
2340
|
return { query: { ...e, measures: s }, calculations: t };
|
|
2341
2341
|
}
|
|
2342
2342
|
function ka(e) {
|
|
2343
2343
|
var t, s;
|
|
2344
|
-
const a = (s = (t = e.config) == null ? void 0 : t.groupByColumns) == null ? void 0 : s.find((
|
|
2344
|
+
const a = (s = (t = e.config) == null ? void 0 : t.groupByColumns) == null ? void 0 : s.find((o) => co(o.dataType || "") === "date");
|
|
2345
2345
|
return { comparisonDate: a ? { name: a.name, label: a.label || a.name } : null, dateWindow: "unknown" };
|
|
2346
2346
|
}
|
|
2347
2347
|
function di(e, a) {
|
|
2348
2348
|
if ("sql" in a) return [];
|
|
2349
|
-
const t = e, s = (...
|
|
2349
|
+
const t = e, s = (...n) => new Set(n.flatMap((i) => Array.isArray(i) ? i : i ? [i] : []).map((i) => be(i, a.datasetName))), o = {
|
|
2350
2350
|
metric: s(t.measures),
|
|
2351
2351
|
group_by: s(t.dimensions, t.dateField),
|
|
2352
2352
|
detail: s(t.columns)
|
|
2353
2353
|
};
|
|
2354
|
-
return Ne(a).filter((
|
|
2354
|
+
return Ne(a).filter((n) => o[n.key.role].has(n.key.field));
|
|
2355
2355
|
}
|
|
2356
2356
|
function li(e, a, t, s) {
|
|
2357
|
-
const
|
|
2358
|
-
if (!e ||
|
|
2359
|
-
const
|
|
2360
|
-
return
|
|
2357
|
+
const o = Object.fromEntries(Object.entries(a).filter(([, p]) => p != null)), n = tt(o), i = tt(e), d = (p) => Sa[p].safeParse(o);
|
|
2358
|
+
if (!e || n && n !== i) {
|
|
2359
|
+
const p = n ?? i, I = p ? d(p) : void 0;
|
|
2360
|
+
return I != null && I.success ? I.data : s({
|
|
2361
2361
|
code: e ? "query_form_mismatch" : "type_not_supported",
|
|
2362
2362
|
message: e ? "This patch changes the query's form (measures, records or SQL) without a complete query." : "This card's current query can't be patched; send a complete query.",
|
|
2363
2363
|
path: t,
|
|
@@ -2365,17 +2365,17 @@ function li(e, a, t, s) {
|
|
|
2365
2365
|
});
|
|
2366
2366
|
}
|
|
2367
2367
|
const l = { ...e };
|
|
2368
|
-
for (const [
|
|
2369
|
-
|
|
2368
|
+
for (const [p, I] of Object.entries(a))
|
|
2369
|
+
I !== void 0 && (I === null ? delete l[p] : l[p] = I);
|
|
2370
2370
|
const c = ms(e, a);
|
|
2371
2371
|
c && delete l.timeWindow;
|
|
2372
2372
|
const h = Sa[i].safeParse(l);
|
|
2373
2373
|
if (!h.success) {
|
|
2374
|
-
const
|
|
2374
|
+
const p = h.error.issues[0];
|
|
2375
2375
|
return s({
|
|
2376
|
-
code: (
|
|
2377
|
-
message: (
|
|
2378
|
-
path:
|
|
2376
|
+
code: (p == null ? void 0 : p.code) === "unrecognized_keys" ? "query_form_mismatch" : "invalid_change",
|
|
2377
|
+
message: (p == null ? void 0 : p.message) ?? "The merged query is not valid.",
|
|
2378
|
+
path: p ? us(t, p) : t,
|
|
2379
2379
|
fix: "Patch only keys of the card's query form, or send a complete query of a new form."
|
|
2380
2380
|
});
|
|
2381
2381
|
}
|
|
@@ -2392,12 +2392,12 @@ function Ra(e, a, t, s) {
|
|
|
2392
2392
|
return ["date", "datetime", "timestamp"].some((i) => Tt(a.dataType).includes(i)) || s({ code: "invalid_change", message: "defaultPeriod is for date filters.", path: t, fix: "Use defaultValues for this field." }), hs(e, { use: "filterDefault", columnHasTime: ci(a) }, t, s);
|
|
2393
2393
|
}
|
|
2394
2394
|
function hs(e, a, t, s) {
|
|
2395
|
-
const
|
|
2396
|
-
return
|
|
2395
|
+
const o = on(e, a);
|
|
2396
|
+
return o.ok ? o.window : s({
|
|
2397
2397
|
code: "invalid_change",
|
|
2398
|
-
message:
|
|
2399
|
-
fix:
|
|
2400
|
-
path:
|
|
2398
|
+
message: o.refusal.message,
|
|
2399
|
+
fix: o.refusal.fix,
|
|
2400
|
+
path: o.refusal.path ? `${t}.${o.refusal.path}` : t
|
|
2401
2401
|
});
|
|
2402
2402
|
}
|
|
2403
2403
|
function ci(e) {
|
|
@@ -2405,24 +2405,31 @@ function ci(e) {
|
|
|
2405
2405
|
}
|
|
2406
2406
|
function ui(e) {
|
|
2407
2407
|
var a, t, s;
|
|
2408
|
-
return (s = (t = (a = e == null ? void 0 : e.filters) == null ? void 0 : a.conditions) == null ? void 0 : t.find((
|
|
2408
|
+
return (s = (t = (a = e == null ? void 0 : e.filters) == null ? void 0 : a.conditions) == null ? void 0 : t.find((o) => o.relativeMeta)) == null ? void 0 : s.field;
|
|
2409
2409
|
}
|
|
2410
|
-
async function fi(e, a, t, s, n) {
|
|
2411
|
-
const
|
|
2412
|
-
if (!
|
|
2413
|
-
return
|
|
2410
|
+
async function fi(e, a, t, s, o, n) {
|
|
2411
|
+
const i = no(e), d = i.kind === "config" ? i.executableSources : i.kind === "sql" ? i.pinnedCatalogSources.map((w) => w.source) : [], l = he(e), c = typeof a == "string" ? (l == null ? void 0 : l.kind) === "semantic" ? l.datasetName : void 0 : a.datasetName, h = d.find((w) => w.kind === "semantic" && Tt(w.datasetName) === Tt(c));
|
|
2412
|
+
if ((!h || h.kind !== "semantic") && n)
|
|
2413
|
+
return o({
|
|
2414
|
+
code: "field_not_found",
|
|
2415
|
+
message: `"${n}" already filters "${e.title}" through the domain's relationships, so it needs no binding; the card doesn't read ${c ? `the dataset ${c}` : "that dataset"}.`,
|
|
2416
|
+
path: s,
|
|
2417
|
+
fix: "Leave out this filter.bind: the filter applies to the card as it is."
|
|
2418
|
+
});
|
|
2419
|
+
if (!h || h.kind !== "semantic")
|
|
2420
|
+
return o({
|
|
2414
2421
|
code: "field_not_found",
|
|
2415
|
-
message: `"${e.title}" doesn't read ${
|
|
2422
|
+
message: `"${e.title}" doesn't read ${c ? `the dataset ${c}` : "a dataset"}.`,
|
|
2416
2423
|
path: s,
|
|
2417
2424
|
fix: "Name a field of the card's own dataset, or { name, datasetName } for a dataset its query joins."
|
|
2418
2425
|
});
|
|
2419
|
-
const
|
|
2420
|
-
return
|
|
2426
|
+
const p = await t.loadCardSource({ domainId: h.domainId, datasetName: h.datasetName }), I = typeof a == "string" ? a : a.name, v = p ? ot(p.fields, I, h.datasetName) : void 0, x = v ? Jo(h, { column_name: v.name, data_type: v.dataType, ...v.sourceField ? { sourceField: v.sourceField } : {} }) : void 0;
|
|
2427
|
+
return x || o({
|
|
2421
2428
|
code: "field_not_found",
|
|
2422
|
-
message: `"${
|
|
2429
|
+
message: `"${I}" isn't a field of ${h.datasetName}.`,
|
|
2423
2430
|
path: s,
|
|
2424
2431
|
fix: "Use one of details.available, or read semaphor_get_dataset_schema.",
|
|
2425
|
-
details: { available: ((
|
|
2432
|
+
details: { available: ((p == null ? void 0 : p.fields) ?? []).slice(0, 20).map((w) => w.name) }
|
|
2426
2433
|
});
|
|
2427
2434
|
}
|
|
2428
2435
|
const mi = {
|
|
@@ -2442,26 +2449,26 @@ async function Or(e, a) {
|
|
|
2442
2449
|
] : []
|
|
2443
2450
|
);
|
|
2444
2451
|
if (s.length) return { ok: !1, problems: s };
|
|
2445
|
-
const
|
|
2446
|
-
if (!
|
|
2447
|
-
const i = hi(
|
|
2448
|
-
return { ...i, seed:
|
|
2452
|
+
const o = pi(e, a), n = await fs(o, e.changes, a, { limit: mi });
|
|
2453
|
+
if (!n.ok) return n;
|
|
2454
|
+
const i = hi(n, e.changes);
|
|
2455
|
+
return { ...i, seed: o, sentence: gi(i.dashboard) };
|
|
2449
2456
|
}
|
|
2450
2457
|
function hi(e, a) {
|
|
2451
|
-
if (a.some((
|
|
2452
|
-
if (!
|
|
2453
|
-
const { op: i } =
|
|
2454
|
-
return i === "layout.arrange" || i === "card.add" && ("width" in
|
|
2458
|
+
if (a.some((n) => {
|
|
2459
|
+
if (!n || typeof n != "object") return !1;
|
|
2460
|
+
const { op: i } = n;
|
|
2461
|
+
return i === "layout.arrange" || i === "card.add" && ("width" in n || "position" in n);
|
|
2455
2462
|
})) return e;
|
|
2456
|
-
const s = (e.dashboard.sheets ?? []).filter((
|
|
2463
|
+
const s = (e.dashboard.sheets ?? []).filter((n) => !Xe(n) && (n.frames ?? []).length > 0).map((n) => ({ op: "layout.arrange", sheetId: n.id }));
|
|
2457
2464
|
if (!s.length) return e;
|
|
2458
|
-
const
|
|
2459
|
-
if (!
|
|
2465
|
+
const o = wt(e.dashboard, s, e.context);
|
|
2466
|
+
if (!o.ok) throw new Error(`Arranging a new dashboard failed: ${o.failedAt.code}`);
|
|
2460
2467
|
return {
|
|
2461
2468
|
...e,
|
|
2462
2469
|
operations: [...e.operations, ...s],
|
|
2463
|
-
dashboard:
|
|
2464
|
-
descriptions: [...e.descriptions, ...
|
|
2470
|
+
dashboard: o.dashboard,
|
|
2471
|
+
descriptions: [...e.descriptions, ...o.descriptions]
|
|
2465
2472
|
};
|
|
2466
2473
|
}
|
|
2467
2474
|
function pi(e, a) {
|
|
@@ -2477,33 +2484,33 @@ function pi(e, a) {
|
|
|
2477
2484
|
}
|
|
2478
2485
|
const vt = (e, a) => `${e} ${a}${e === 1 ? "" : "s"}`;
|
|
2479
2486
|
function gi(e) {
|
|
2480
|
-
const a = e.sheets ?? [], t = a.reduce((
|
|
2487
|
+
const a = e.sheets ?? [], t = a.reduce((n, i) => n + (i.frames ?? []).reduce((d, l) => {
|
|
2481
2488
|
var c;
|
|
2482
2489
|
return d + (((c = l.cards) == null ? void 0 : c.length) ?? 0);
|
|
2483
|
-
}, 0), 0), s = (e.inputs ?? []).filter((
|
|
2484
|
-
return `Creates a private dashboard ${Va(e.title)} with ${et(
|
|
2490
|
+
}, 0), 0), s = (e.inputs ?? []).filter((n) => n.kind === "filter").length, o = [vt(a.length, "sheet"), vt(t, "card"), ...s ? [vt(s, "filter")] : []];
|
|
2491
|
+
return `Creates a private dashboard ${Va(e.title)} with ${et(o)}.`;
|
|
2485
2492
|
}
|
|
2486
2493
|
const bi = 50;
|
|
2487
2494
|
function Er(e, a) {
|
|
2488
2495
|
var $, N;
|
|
2489
|
-
const t = ($ = a.sheetIds) != null && $.length ? new Set(a.sheetIds) : void 0, s = (N = a.cardIds) != null && N.length ? new Set(a.cardIds) : void 0,
|
|
2490
|
-
(
|
|
2491
|
-
), i =
|
|
2492
|
-
(e.sheets ?? []).flatMap((
|
|
2493
|
-
), l = /* @__PURE__ */ new Map(), c = (
|
|
2494
|
-
(
|
|
2496
|
+
const t = ($ = a.sheetIds) != null && $.length ? new Set(a.sheetIds) : void 0, s = (N = a.cardIds) != null && N.length ? new Set(a.cardIds) : void 0, o = (e.sheets ?? []).filter((g) => !t || t.has(g.id)), n = xe(e).filter(
|
|
2497
|
+
(g) => (!t || t.has(g.sheetId)) && (!s || s.has(g.cardId))
|
|
2498
|
+
), i = n.length > (a.maxQueryCards ?? bi), d = new Map(
|
|
2499
|
+
(e.sheets ?? []).flatMap((g) => (g.frames ?? []).map((k) => [k.id, k]))
|
|
2500
|
+
), l = /* @__PURE__ */ new Map(), c = (g) => {
|
|
2501
|
+
(g == null ? void 0 : g.kind) === "semantic" && l.set(`${g.domainId}|${g.datasetName}`, { domainId: g.domainId, datasetName: g.datasetName });
|
|
2495
2502
|
}, h = new Map(
|
|
2496
|
-
(e.sheets ?? []).map((
|
|
2497
|
-
),
|
|
2498
|
-
if (
|
|
2499
|
-
const T = _t({ dashboard: e, place: { kind: "sheet", sheetId:
|
|
2500
|
-
return
|
|
2501
|
-
},
|
|
2502
|
-
sheetId:
|
|
2503
|
-
title:
|
|
2504
|
-
kind:
|
|
2505
|
-
...
|
|
2506
|
-
cards:
|
|
2503
|
+
(e.sheets ?? []).map((g) => [g.id, _t({ dashboard: e, place: { kind: g.kind === "document" ? "document" : "sheet", sheetId: g.id } })])
|
|
2504
|
+
), p = (g) => ({ catalog: g, inputs: e.inputs, variables: e.variables }), I = (g) => p(h.get(g)), v = /* @__PURE__ */ new Map(), x = (g, k) => {
|
|
2505
|
+
if (g.kind === "document") return I(g.id);
|
|
2506
|
+
const T = _t({ dashboard: e, place: { kind: "sheet", sheetId: g.id, cardId: k } });
|
|
2507
|
+
return v.set(`${g.id}:${k}`, T), p(T);
|
|
2508
|
+
}, w = o.map((g) => ({
|
|
2509
|
+
sheetId: g.id,
|
|
2510
|
+
title: g.title ?? "",
|
|
2511
|
+
kind: g.kind === "document" ? "document" : "dashboard",
|
|
2512
|
+
...g.kind === "document" ? vi(g, I(g.id)) : { layout: Ci(g) },
|
|
2513
|
+
cards: n.filter((k) => k.sheetId === g.id).map((k) => {
|
|
2507
2514
|
var oe;
|
|
2508
2515
|
const T = k.card, L = k.kind === "frameCard" ? (oe = d.get(k.frameId)) == null ? void 0 : oe.visualId : void 0, V = L ? { linkedVisualId: L } : {}, K = { cardId: k.cardId, title: T.title ?? "" };
|
|
2509
2516
|
if (k.kind !== "frameCard") {
|
|
@@ -2521,10 +2528,10 @@ function Er(e, a) {
|
|
|
2521
2528
|
};
|
|
2522
2529
|
}
|
|
2523
2530
|
if (T.type === "text") {
|
|
2524
|
-
const te = ja(T,
|
|
2531
|
+
const te = ja(T, x(g, T.id));
|
|
2525
2532
|
return te.editable ? { ...K, type: "text", ...V, editable: !0, text: te.text, ...te.editorOnly.length ? { editorOnly: te.editorOnly } : {} } : { ...K, ...Ge(T), ...V, editable: !1, notEditable: { reason: "text", message: te.message } };
|
|
2526
2533
|
}
|
|
2527
|
-
const B =
|
|
2534
|
+
const B = we(T, { sql: a.sql });
|
|
2528
2535
|
if (c(B.source), !B.editable)
|
|
2529
2536
|
return {
|
|
2530
2537
|
...K,
|
|
@@ -2553,20 +2560,20 @@ function Er(e, a) {
|
|
|
2553
2560
|
})), E = as(e, es(a.calendar, a.updatedAt), {
|
|
2554
2561
|
...a.relationshipReach ? { relationshipReach: a.relationshipReach } : {}
|
|
2555
2562
|
});
|
|
2556
|
-
for (const
|
|
2557
|
-
|
|
2558
|
-
const _ = Ii(e, a, new Map([...h, ...
|
|
2559
|
-
for (const
|
|
2560
|
-
const k = kt(
|
|
2563
|
+
for (const g of E)
|
|
2564
|
+
g.editable && l.set(`${g.domainId}|${g.datasetName}`, { domainId: g.domainId, datasetName: g.datasetName });
|
|
2565
|
+
const _ = Ii(e, a, new Map([...h, ...v]));
|
|
2566
|
+
for (const g of e.variables ?? []) {
|
|
2567
|
+
const k = kt(g);
|
|
2561
2568
|
(k == null ? void 0 : k.kind) === "semantic" && l.set(`${k.domainId}|${k.datasetName}`, { domainId: k.domainId, datasetName: k.datasetName });
|
|
2562
2569
|
}
|
|
2563
|
-
const S = (e.variables ?? []).filter((
|
|
2570
|
+
const S = (e.variables ?? []).filter((g) => {
|
|
2564
2571
|
var k;
|
|
2565
|
-
return ((k = kt(
|
|
2566
|
-
}).map((
|
|
2567
|
-
(
|
|
2572
|
+
return ((k = kt(g)) == null ? void 0 : k.kind) === "physical";
|
|
2573
|
+
}).map((g) => g.name), y = (e.sheets ?? []).some(
|
|
2574
|
+
(g) => {
|
|
2568
2575
|
var k;
|
|
2569
|
-
return (k =
|
|
2576
|
+
return (k = g.document) == null ? void 0 : k.sections.some((T) => {
|
|
2570
2577
|
var L, V;
|
|
2571
2578
|
return T.type === "text" && (((L = T.style) == null ? void 0 : L.fontWeight) || ((V = T.style) == null ? void 0 : V.color));
|
|
2572
2579
|
});
|
|
@@ -2585,7 +2592,7 @@ function Er(e, a) {
|
|
|
2585
2592
|
updatedAt: a.updatedAt,
|
|
2586
2593
|
access: a.access,
|
|
2587
2594
|
datasets: [...l.values()],
|
|
2588
|
-
sheets:
|
|
2595
|
+
sheets: w,
|
|
2589
2596
|
filters: E,
|
|
2590
2597
|
variables: _,
|
|
2591
2598
|
style: yi(e, a),
|
|
@@ -2604,9 +2611,9 @@ function Aa(e, a) {
|
|
|
2604
2611
|
function vi(e, a) {
|
|
2605
2612
|
const t = e.document;
|
|
2606
2613
|
if (!t) return {};
|
|
2607
|
-
const s = (
|
|
2608
|
-
var
|
|
2609
|
-
return (((
|
|
2614
|
+
const s = (o) => {
|
|
2615
|
+
var n;
|
|
2616
|
+
return (((n = t[o]) == null ? void 0 : n.blocks) ?? []).flatMap(
|
|
2610
2617
|
(i) => i.type === "text" && i.role ? [Aa({ role: i.role, text: Ze(i.content, { ...a, documentInputs: t.inputs }) }, i.style)] : []
|
|
2611
2618
|
);
|
|
2612
2619
|
};
|
|
@@ -2614,47 +2621,47 @@ function vi(e, a) {
|
|
|
2614
2621
|
header: s("header"),
|
|
2615
2622
|
footer: s("footer"),
|
|
2616
2623
|
textSections: t.sections.flatMap(
|
|
2617
|
-
(
|
|
2624
|
+
(o) => o.type === "text" ? [Aa({ sectionId: o.id, text: Ze(o.content, { ...a, documentInputs: t.inputs }) }, o.style)] : []
|
|
2618
2625
|
)
|
|
2619
2626
|
};
|
|
2620
2627
|
}
|
|
2621
2628
|
function Ii(e, a, t) {
|
|
2622
|
-
const s = Qa(e),
|
|
2629
|
+
const s = Qa(e), o = (c) => s.filter(({ ref: h }) => c(h)).map(({ place: h, where: p }) => ({
|
|
2623
2630
|
sheetId: h.sheetId,
|
|
2624
|
-
where:
|
|
2625
|
-
id:
|
|
2626
|
-
})),
|
|
2631
|
+
where: p.kind,
|
|
2632
|
+
id: p.kind === "card" ? p.cardId : p.kind === "section" ? p.sectionId : p.blockId
|
|
2633
|
+
})), n = /* @__PURE__ */ new Map();
|
|
2627
2634
|
for (const c of t.values())
|
|
2628
2635
|
for (const h of c.entries) {
|
|
2629
|
-
const
|
|
2630
|
-
(!
|
|
2636
|
+
const p = n.get(h.name);
|
|
2637
|
+
(!p || p.kind === "report" && h.kind !== "report") && n.set(h.name, h);
|
|
2631
2638
|
}
|
|
2632
|
-
const i = [...
|
|
2639
|
+
const i = [...n.values()].filter((c) => c.kind === "input").map((c) => ({
|
|
2633
2640
|
name: c.name,
|
|
2634
2641
|
kind: "input",
|
|
2635
2642
|
words: c.input.kind === "control" ? `The ${c.label} control's value` : `The ${c.label} filter's value`,
|
|
2636
2643
|
parts: [...c.parts],
|
|
2637
|
-
usedIn:
|
|
2644
|
+
usedIn: o((h) => h.source === "input" && h.inputId === c.input.id || h.source === "dashboardInputAlias" && h.variableName === c.name),
|
|
2638
2645
|
editable: !1
|
|
2639
|
-
})), d = [...
|
|
2646
|
+
})), d = [...n.values()].filter((c) => c.kind === "report").map((c) => ({
|
|
2640
2647
|
name: c.name,
|
|
2641
2648
|
kind: "report",
|
|
2642
2649
|
words: _i[c.reportKey],
|
|
2643
2650
|
parts: [],
|
|
2644
|
-
usedIn:
|
|
2651
|
+
usedIn: o((h) => h.source === "documentMeta" && h.key === c.reportKey),
|
|
2645
2652
|
editable: !1
|
|
2646
2653
|
})), l = (e.variables ?? []).map((c) => {
|
|
2647
|
-
const h = rs(c, { sql: a.sql }),
|
|
2654
|
+
const h = rs(c, { sql: a.sql }), p = Dt(c, e)[0], I = Co(c.presentation);
|
|
2648
2655
|
return {
|
|
2649
2656
|
name: c.name,
|
|
2650
2657
|
kind: "data",
|
|
2651
2658
|
words: Xo(c),
|
|
2652
2659
|
parts: Lo(c),
|
|
2653
|
-
...
|
|
2654
|
-
usedIn:
|
|
2660
|
+
...I ? { presentation: I } : {},
|
|
2661
|
+
usedIn: o((v) => v.source === "data" && v.variableId === c.id),
|
|
2655
2662
|
editable: h.editable,
|
|
2656
2663
|
...h.editable ? {} : { notEditable: { reason: h.reason, message: h.message } },
|
|
2657
|
-
...
|
|
2664
|
+
...p ? { broken: `${p.message} ${p.fix}` } : {}
|
|
2658
2665
|
};
|
|
2659
2666
|
});
|
|
2660
2667
|
return [...i, ...d, ...l];
|
|
@@ -2672,8 +2679,8 @@ function Ci(e) {
|
|
|
2672
2679
|
const a = new Map((e.frames ?? []).map((t) => [t.id, t]));
|
|
2673
2680
|
return hn(e).rows.map((t) => ({
|
|
2674
2681
|
tiles: t.tiles.map((s) => {
|
|
2675
|
-
const
|
|
2676
|
-
return { cardIds:
|
|
2682
|
+
const o = a.get(s.frameId);
|
|
2683
|
+
return { cardIds: o ? Ba(o) : [], width: s.width };
|
|
2677
2684
|
})
|
|
2678
2685
|
}));
|
|
2679
2686
|
}
|
|
@@ -2687,17 +2694,17 @@ const re = ue, $i = ["metricColumns", "groupByColumns", "detailColumns", "pivotB
|
|
|
2687
2694
|
function Si(e) {
|
|
2688
2695
|
return Me(String(e.type)) ?? Et;
|
|
2689
2696
|
}
|
|
2690
|
-
function
|
|
2697
|
+
function Ee(e, a, t) {
|
|
2691
2698
|
if (t === void 0) return;
|
|
2692
2699
|
const s = Z(t) ? Si(t).safeParse(t) : Et.safeParse(t);
|
|
2693
2700
|
if (!s.success)
|
|
2694
|
-
for (const
|
|
2695
|
-
const
|
|
2696
|
-
for (const i of
|
|
2701
|
+
for (const o of s.error.issues) {
|
|
2702
|
+
const n = o.code === "unrecognized_keys" ? o.keys : [o.path.length ? String(o.path[o.path.length - 1]) : "type"];
|
|
2703
|
+
for (const i of n)
|
|
2697
2704
|
e.push({
|
|
2698
|
-
path: [a, ...
|
|
2705
|
+
path: [a, ...o.path.map(String), ...o.code === "unrecognized_keys" ? [i] : []].join("."),
|
|
2699
2706
|
field: i,
|
|
2700
|
-
replacement: i === "locale" ? "nothing: the viewer's locale applies" :
|
|
2707
|
+
replacement: i === "locale" ? "nothing: the viewer's locale applies" : o.code === "unrecognized_keys" ? "nothing: the stored format type has no such key" : `a value the stored format type accepts (${o.message})`
|
|
2701
2708
|
});
|
|
2702
2709
|
}
|
|
2703
2710
|
}
|
|
@@ -2705,63 +2712,63 @@ function It(e, a, t) {
|
|
|
2705
2712
|
if (Z(t)) {
|
|
2706
2713
|
for (const s of ["dateFormat", "customFormat"])
|
|
2707
2714
|
re(t, s) && e.push({ path: `${a}.${s}`, field: s, replacement: "`format` on this column (a temporal bucket or date format)" });
|
|
2708
|
-
|
|
2715
|
+
Ee(e, `${a}.format`, t.format);
|
|
2709
2716
|
}
|
|
2710
2717
|
}
|
|
2711
2718
|
function ps(e, a) {
|
|
2712
2719
|
const t = [], s = e.config;
|
|
2713
|
-
for (const
|
|
2714
|
-
const
|
|
2715
|
-
Array.isArray(
|
|
2720
|
+
for (const x of $i) {
|
|
2721
|
+
const w = s == null ? void 0 : s[x];
|
|
2722
|
+
Array.isArray(w) && w.forEach((E, _) => It(t, `${a}.config.${x}[${_}]`, E));
|
|
2716
2723
|
}
|
|
2717
|
-
const
|
|
2718
|
-
for (const
|
|
2719
|
-
const
|
|
2720
|
-
if (Z(
|
|
2724
|
+
const o = Z(s == null ? void 0 : s.matrix) ? s.matrix : void 0, n = Z(o == null ? void 0 : o.presentation) ? o.presentation : void 0;
|
|
2725
|
+
for (const x of ["measureFormats", "levelFormats"]) {
|
|
2726
|
+
const w = n == null ? void 0 : n[x];
|
|
2727
|
+
if (Z(w)) for (const [E, _] of Object.entries(w)) Ee(t, `${a}.config.matrix.presentation.${x}.${E}`, _);
|
|
2721
2728
|
}
|
|
2722
|
-
re(
|
|
2729
|
+
re(n, "conditionalFormatting") && t.push({ path: `${a}.config.matrix.presentation.conditionalFormatting`, field: "conditionalFormatting", replacement: Qe });
|
|
2723
2730
|
const i = e.interactionConfig, d = i == null ? void 0 : i.drillHierarchies;
|
|
2724
|
-
Array.isArray(d) && d.forEach((
|
|
2725
|
-
Z(
|
|
2726
|
-
Z(E) && It(t, `${a}.interactionConfig.drillHierarchies[${
|
|
2731
|
+
Array.isArray(d) && d.forEach((x, w) => {
|
|
2732
|
+
Z(x) && (It(t, `${a}.interactionConfig.drillHierarchies[${w}].baseField`, x.baseField), Array.isArray(x.steps) && x.steps.forEach((E, _) => {
|
|
2733
|
+
Z(E) && It(t, `${a}.interactionConfig.drillHierarchies[${w}].steps[${_}].field`, E.field);
|
|
2727
2734
|
}));
|
|
2728
2735
|
});
|
|
2729
2736
|
const l = e.preferences;
|
|
2730
2737
|
if (!l) return t;
|
|
2731
2738
|
const c = `${a}.preferences`;
|
|
2732
2739
|
if (re(l, "formatNumber")) {
|
|
2733
|
-
const
|
|
2740
|
+
const x = l.formatNumber, w = Z(x) && Object.keys(x).every((E) => E === "colorRanges");
|
|
2734
2741
|
t.push(
|
|
2735
|
-
|
|
2742
|
+
w ? { path: `${c}.formatNumber.colorRanges`, field: "colorRanges", replacement: `${Qe} (a rule on the KPI's value)` } : { path: `${c}.formatNumber`, field: "formatNumber", replacement: "`format` on each measure in `config.metricColumns`; for a SQL KPI, `preferences.sqlKpiValue.format`" }
|
|
2736
2743
|
);
|
|
2737
2744
|
}
|
|
2738
2745
|
re(l, "numberAxisFormat") && t.push({ path: `${c}.numberAxisFormat`, field: "numberAxisFormat", replacement: "`valueFormat` on `preferences.yAxisConfig` (or the axis it formats)" }), re(l, "columnSettings") && t.push({ path: `${c}.columnSettings`, field: "columnSettings", replacement: "`preferences.tablePrefs.columnSettingsMap`, keyed by column" });
|
|
2739
2746
|
const h = l.kpiVisualOptions;
|
|
2740
2747
|
re(h, "formatOptions") && t.push({ path: `${c}.kpiVisualOptions.formatOptions`, field: "formatOptions", replacement: "`format` on each measure in `config.metricColumns`; for a SQL KPI, `preferences.sqlKpiValue.format`" }), re(h, "queryComparisonPolarity") && t.push({ path: `${c}.kpiVisualOptions.queryComparisonPolarity`, field: "queryComparisonPolarity", replacement: "`preferences.sqlKpiValue.comparisonPolarity`" });
|
|
2741
|
-
const
|
|
2742
|
-
re(
|
|
2743
|
-
const
|
|
2744
|
-
if (Z(
|
|
2745
|
-
for (const [
|
|
2746
|
-
if (!Z(
|
|
2747
|
-
const E = `${c}.tablePrefs.columnSettingsMap.${
|
|
2748
|
+
const p = l.tablePrefs;
|
|
2749
|
+
re(p, "conditionalFormatting") && t.push({ path: `${c}.tablePrefs.conditionalFormatting`, field: "conditionalFormatting", replacement: Qe });
|
|
2750
|
+
const I = p == null ? void 0 : p.columnSettingsMap;
|
|
2751
|
+
if (Z(I))
|
|
2752
|
+
for (const [x, w] of Object.entries(I)) {
|
|
2753
|
+
if (!Z(w)) continue;
|
|
2754
|
+
const E = `${c}.tablePrefs.columnSettingsMap.${x}`;
|
|
2748
2755
|
for (const _ of ["numberFormat", "dateFormat", "inheritMetricFormat"])
|
|
2749
|
-
re(
|
|
2750
|
-
re(
|
|
2756
|
+
re(w, _) && t.push({ path: `${E}.${_}`, field: _, replacement: _ === "inheritMetricFormat" ? "nothing: a column follows its `format`" : xi });
|
|
2757
|
+
re(w, "colorRanges") && t.push({ path: `${E}.colorRanges`, field: "colorRanges", replacement: Qe });
|
|
2751
2758
|
}
|
|
2752
|
-
for (const
|
|
2753
|
-
const
|
|
2754
|
-
if (Z(
|
|
2759
|
+
for (const x of wi) {
|
|
2760
|
+
const w = l[x];
|
|
2761
|
+
if (Z(w)) {
|
|
2755
2762
|
for (const E of ["formatMode", "mode", "formatOptions"])
|
|
2756
|
-
re(
|
|
2757
|
-
|
|
2763
|
+
re(w, E) && t.push({ path: `${c}.${x}.${E}`, field: E, replacement: `\`preferences.${x}.valueFormat\` (absent means the column's format)` });
|
|
2764
|
+
x === "dataLabelsConfig" && re(w, "format") && t.push({ path: `${c}.${x}.format`, field: "format", replacement: "`preferences.dataLabelsConfig.valueFormat`" }), Ee(t, `${c}.${x}.valueFormat`, w.valueFormat);
|
|
2758
2765
|
}
|
|
2759
2766
|
}
|
|
2760
|
-
const
|
|
2761
|
-
if (Z(
|
|
2762
|
-
for (const [
|
|
2763
|
-
Z(
|
|
2764
|
-
return Z(l.sqlKpiValue) &&
|
|
2767
|
+
const v = l.sqlColumns;
|
|
2768
|
+
if (Z(v))
|
|
2769
|
+
for (const [x, w] of Object.entries(v))
|
|
2770
|
+
Z(w) && Ee(t, `${c}.sqlColumns.${x}.format`, w.format);
|
|
2771
|
+
return Z(l.sqlKpiValue) && Ee(t, `${c}.sqlKpiValue.format`, l.sqlKpiValue.format), t;
|
|
2765
2772
|
}
|
|
2766
2773
|
function ki(e) {
|
|
2767
2774
|
const a = `sheets[id=${e.sheetId}]`;
|
|
@@ -2777,7 +2784,7 @@ function ki(e) {
|
|
|
2777
2784
|
function gs(e) {
|
|
2778
2785
|
if (!Z(e)) return [];
|
|
2779
2786
|
if (Array.isArray(e.sheets))
|
|
2780
|
-
return
|
|
2787
|
+
return xe(e).map((t) => ({
|
|
2781
2788
|
card: t.card,
|
|
2782
2789
|
at: ki(t)
|
|
2783
2790
|
}));
|
|
@@ -2788,15 +2795,15 @@ function qr(e) {
|
|
|
2788
2795
|
return gs(e).flatMap(({ card: a, at: t }) => ps(a, t));
|
|
2789
2796
|
}
|
|
2790
2797
|
function Ti(e, a) {
|
|
2791
|
-
var
|
|
2792
|
-
const t = (
|
|
2798
|
+
var n;
|
|
2799
|
+
const t = (n = e.preferences) == null ? void 0 : n.conditionalFormatting;
|
|
2793
2800
|
if (t === void 0) return [];
|
|
2794
|
-
const s = `${a}.preferences.conditionalFormatting`,
|
|
2795
|
-
return
|
|
2801
|
+
const s = `${a}.preferences.conditionalFormatting`, o = wo.safeParse(t);
|
|
2802
|
+
return o.success ? xo(e).map((i) => ({
|
|
2796
2803
|
code: "invalid_conditional_formatting",
|
|
2797
2804
|
path: `${s}.rules[id=${i.ruleId}].${i.path}`,
|
|
2798
2805
|
message: i.message
|
|
2799
|
-
})) :
|
|
2806
|
+
})) : o.error.issues.map((i) => ({
|
|
2800
2807
|
code: "invalid_conditional_formatting",
|
|
2801
2808
|
path: [s, ...i.path.map((d) => typeof d == "number" ? `[${d}]` : d)].join(".").replace(/\.\[/g, "["),
|
|
2802
2809
|
message: i.message
|
|
@@ -2831,9 +2838,9 @@ function J(e) {
|
|
|
2831
2838
|
function bs(e, a) {
|
|
2832
2839
|
return JSON.stringify(e) === JSON.stringify(a);
|
|
2833
2840
|
}
|
|
2834
|
-
function
|
|
2841
|
+
function _e(e, a) {
|
|
2835
2842
|
const t = (s) => J(s) ? Object.fromEntries(
|
|
2836
|
-
Object.keys(s).sort().map((
|
|
2843
|
+
Object.keys(s).sort().map((o) => [o, t(s[o])])
|
|
2837
2844
|
) : s;
|
|
2838
2845
|
return bs(t(e), t(a));
|
|
2839
2846
|
}
|
|
@@ -2862,7 +2869,7 @@ function Fi(e, a) {
|
|
|
2862
2869
|
if (s >= 0) return `config.${t}[${s}]`;
|
|
2863
2870
|
}
|
|
2864
2871
|
}
|
|
2865
|
-
function
|
|
2872
|
+
function Te(e, a) {
|
|
2866
2873
|
let t = !1;
|
|
2867
2874
|
for (const s of a)
|
|
2868
2875
|
Object.prototype.hasOwnProperty.call(e, s) && (delete e[s], t = !0);
|
|
@@ -2877,8 +2884,8 @@ function st(e, a, t, s) {
|
|
|
2877
2884
|
}
|
|
2878
2885
|
function Mt(e) {
|
|
2879
2886
|
if (!J(e)) return;
|
|
2880
|
-
if (e.type === "temporal_bucket") return
|
|
2881
|
-
const a =
|
|
2887
|
+
if (e.type === "temporal_bucket") return Se(e);
|
|
2888
|
+
const a = Se(e);
|
|
2882
2889
|
return (a == null ? void 0 : a.type) === "currency" && a.currency === void 0 && jo(e) ? { ...a, currency: "USD" } : a;
|
|
2883
2890
|
}
|
|
2884
2891
|
function At(e, a, t) {
|
|
@@ -2897,7 +2904,7 @@ function At(e, a, t) {
|
|
|
2897
2904
|
to: `${t}.format`
|
|
2898
2905
|
}));
|
|
2899
2906
|
}
|
|
2900
|
-
|
|
2907
|
+
Te(a, ["dateFormat", "customFormat"]) && e.changes.push({ path: `${t}.dateFormat`, action: "removed" });
|
|
2901
2908
|
}
|
|
2902
2909
|
}
|
|
2903
2910
|
function Di(e, a, t) {
|
|
@@ -2907,27 +2914,27 @@ function Di(e, a, t) {
|
|
|
2907
2914
|
path: `${t}.dateFormat`,
|
|
2908
2915
|
action: "moved",
|
|
2909
2916
|
to: `${t}.format`
|
|
2910
|
-
})) : e.card.type === "detailTable" && at(a.dataType) && a.format && typeof s == "string" && s.trim() && !
|
|
2917
|
+
})) : e.card.type === "detailTable" && at(a.dataType) && a.format && typeof s == "string" && s.trim() && !_e(a.format, { type: "date", pattern: s }) && e.unconverted.push({
|
|
2911
2918
|
path: `${t}.dateFormat`,
|
|
2912
2919
|
reason: "detail_date_beside_format",
|
|
2913
2920
|
detail: "A detail date pattern on a column that has a format of its own."
|
|
2914
|
-
}),
|
|
2921
|
+
}), Te(a, ["dateFormat", "customFormat"]) && e.changes.push({ path: `${t}.dateFormat`, action: "removed" });
|
|
2915
2922
|
}
|
|
2916
2923
|
function Oi(e, a, t, s) {
|
|
2917
2924
|
if (a.format !== void 0) {
|
|
2918
|
-
const
|
|
2919
|
-
|
|
2925
|
+
const o = Mt(a.format);
|
|
2926
|
+
o ? _e(o, a.format) || (a.format = o, e.changes.push({ path: `${s}.format`, action: "cleaned" })) : (delete a.format, e.changes.push({ path: `${s}.format`, action: "removed" }));
|
|
2920
2927
|
}
|
|
2921
|
-
t === "groupByColumns" || t === "pivotByColumns" ? At(e, a, s) : t === "detailColumns" ? Di(e, a, s) :
|
|
2928
|
+
t === "groupByColumns" || t === "pivotByColumns" ? At(e, a, s) : t === "detailColumns" ? Di(e, a, s) : Te(a, ["dateFormat", "customFormat"]) && e.changes.push({ path: `${s}.dateFormat`, action: "removed" });
|
|
2922
2929
|
}
|
|
2923
2930
|
function Ei(e, a) {
|
|
2924
2931
|
for (const t of Lt)
|
|
2925
|
-
ee(e.card, t).forEach((s,
|
|
2932
|
+
ee(e.card, t).forEach((s, o) => {
|
|
2926
2933
|
var i;
|
|
2927
2934
|
if (!s.format || s.formatOrigin) return;
|
|
2928
|
-
const
|
|
2929
|
-
s.formatOrigin =
|
|
2930
|
-
path: `config.${t}[${
|
|
2935
|
+
const n = (i = a.modelFormatFor) == null ? void 0 : i.call(a, s);
|
|
2936
|
+
s.formatOrigin = n && _e(Se(n), s.format) ? "semantic" : "override", e.changes.push({
|
|
2937
|
+
path: `config.${t}[${o}].formatOrigin`,
|
|
2931
2938
|
action: "marked"
|
|
2932
2939
|
});
|
|
2933
2940
|
});
|
|
@@ -2935,15 +2942,15 @@ function Ei(e, a) {
|
|
|
2935
2942
|
function qi(e) {
|
|
2936
2943
|
var t;
|
|
2937
2944
|
const a = (t = e.card.interactionConfig) == null ? void 0 : t.drillHierarchies;
|
|
2938
|
-
Array.isArray(a) && a.forEach((s,
|
|
2945
|
+
Array.isArray(a) && a.forEach((s, o) => {
|
|
2939
2946
|
if (!J(s)) return;
|
|
2940
|
-
const
|
|
2941
|
-
J(s.baseField) && At(e, s.baseField, `${
|
|
2947
|
+
const n = `interactionConfig.drillHierarchies[${o}]`;
|
|
2948
|
+
J(s.baseField) && At(e, s.baseField, `${n}.baseField`), Array.isArray(s.steps) && s.steps.forEach((i, d) => {
|
|
2942
2949
|
if (J(i) && J(i.field)) {
|
|
2943
|
-
const l = i.field, c = `${
|
|
2950
|
+
const l = i.field, c = `${n}.steps[${d}].field`;
|
|
2944
2951
|
if (l.format !== void 0) {
|
|
2945
2952
|
const h = Mt(l.format);
|
|
2946
|
-
h && !
|
|
2953
|
+
h && !_e(h, l.format) && (l.format = h, e.changes.push({ path: `${c}.format`, action: "cleaned" }));
|
|
2947
2954
|
}
|
|
2948
2955
|
At(e, l, c);
|
|
2949
2956
|
}
|
|
@@ -2957,7 +2964,7 @@ const Ni = [
|
|
|
2957
2964
|
"colorRanges"
|
|
2958
2965
|
];
|
|
2959
2966
|
function Pi(e, a) {
|
|
2960
|
-
const t = (
|
|
2967
|
+
const t = (o) => o == null ? void 0 : o.trim().toLowerCase(), s = t(a);
|
|
2961
2968
|
return [
|
|
2962
2969
|
e.id,
|
|
2963
2970
|
e.alias,
|
|
@@ -2965,7 +2972,7 @@ function Pi(e, a) {
|
|
|
2965
2972
|
e.qualifiedFieldName,
|
|
2966
2973
|
e.label,
|
|
2967
2974
|
e.role === "metric" ? Uo(e) : void 0
|
|
2968
|
-
].some((
|
|
2975
|
+
].some((o) => o !== void 0 && t(o) === s);
|
|
2969
2976
|
}
|
|
2970
2977
|
function Fa(e, a) {
|
|
2971
2978
|
const t = Do(e, { columnId: a });
|
|
@@ -2974,7 +2981,7 @@ function Fa(e, a) {
|
|
|
2974
2981
|
...ee(e, "detailColumns"),
|
|
2975
2982
|
...ee(e, "metricColumns"),
|
|
2976
2983
|
...ee(e, "groupByColumns")
|
|
2977
|
-
].filter((
|
|
2984
|
+
].filter((o) => Pi(o, a));
|
|
2978
2985
|
return s.length === 1 ? s[0] : void 0;
|
|
2979
2986
|
}
|
|
2980
2987
|
function Li(e) {
|
|
@@ -2986,14 +2993,14 @@ function Mi(e, a) {
|
|
|
2986
2993
|
}
|
|
2987
2994
|
function Da(e, a, t, s) {
|
|
2988
2995
|
var i;
|
|
2989
|
-
const
|
|
2990
|
-
|
|
2996
|
+
const o = (i = e.card).preferences ?? (i.preferences = {}), n = o.sqlColumns ?? (o.sqlColumns = {});
|
|
2997
|
+
n[a] = { ...n[a], format: t }, e.changes.push({ path: s, action: "moved", to: `preferences.sqlColumns[${JSON.stringify(a)}].format` });
|
|
2991
2998
|
}
|
|
2992
2999
|
function Bi(e) {
|
|
2993
3000
|
const [a, ...t] = e;
|
|
2994
3001
|
if (!a) return;
|
|
2995
3002
|
const s = Object.fromEntries(
|
|
2996
|
-
Object.entries(a).filter(([
|
|
3003
|
+
Object.entries(a).filter(([o, n]) => t.every((i) => bs(i[o], n)))
|
|
2997
3004
|
);
|
|
2998
3005
|
return Et.safeParse(s).success ? s : void 0;
|
|
2999
3006
|
}
|
|
@@ -3004,24 +3011,24 @@ function Vi(e, a) {
|
|
|
3004
3011
|
pivotByColumns: ee(t, "pivotByColumns"),
|
|
3005
3012
|
detailColumns: t.type === "detailTable" ? ee(t, "detailColumns") : []
|
|
3006
3013
|
});
|
|
3007
|
-
for (const [
|
|
3008
|
-
const i =
|
|
3009
|
-
if (st(e,
|
|
3010
|
-
for (const l of
|
|
3011
|
-
l !== d && !
|
|
3014
|
+
for (const [o, n] of a) {
|
|
3015
|
+
const i = n.find((l) => l.key === s.get(o)), d = i ?? n[0];
|
|
3016
|
+
if (st(e, o, d.format, d.from), !i)
|
|
3017
|
+
for (const l of n)
|
|
3018
|
+
l !== d && !_e(l.format, d.format) && e.unconverted.push({
|
|
3012
3019
|
path: l.from,
|
|
3013
3020
|
reason: "ambiguous_column_setting",
|
|
3014
|
-
detail: `"${l.key}" and "${d.key}" both name ${
|
|
3021
|
+
detail: `"${l.key}" and "${d.key}" both name ${o.id}.`
|
|
3015
3022
|
});
|
|
3016
3023
|
}
|
|
3017
3024
|
}
|
|
3018
3025
|
function ji(e, a) {
|
|
3019
|
-
var
|
|
3026
|
+
var n;
|
|
3020
3027
|
if (!a.length) return;
|
|
3021
|
-
const t = ee(e.card, "metricColumns"), s = t.length === 1 ? t[0] : void 0,
|
|
3022
|
-
s &&
|
|
3028
|
+
const t = ee(e.card, "metricColumns"), s = t.length === 1 ? t[0] : void 0, o = s && !s.format ? Bi(a.map((i) => i.format)) : void 0;
|
|
3029
|
+
s && o && st(e, s, o, a[0].from);
|
|
3023
3030
|
for (const i of a)
|
|
3024
|
-
if (!(s != null && s.format &&
|
|
3031
|
+
if (!(s != null && s.format && _e(i.format, s.format))) {
|
|
3025
3032
|
if (!t.length) {
|
|
3026
3033
|
e.unconverted.push({
|
|
3027
3034
|
path: i.from,
|
|
@@ -3031,7 +3038,7 @@ function ji(e, a) {
|
|
|
3031
3038
|
continue;
|
|
3032
3039
|
}
|
|
3033
3040
|
e.unconverted.push(
|
|
3034
|
-
((
|
|
3041
|
+
((n = s == null ? void 0 : s.format) == null ? void 0 : n.type) === i.format.type ? {
|
|
3035
3042
|
path: i.from,
|
|
3036
3043
|
reason: "pivot_value_format_difference",
|
|
3037
3044
|
detail: `"${i.key}" is one pivot value's column; its format differs from its measure's, which every pivot value now shows.`
|
|
@@ -3047,44 +3054,44 @@ function Ki(e) {
|
|
|
3047
3054
|
var l;
|
|
3048
3055
|
const a = (l = e.card.preferences) == null ? void 0 : l.tablePrefs, t = a == null ? void 0 : a.columnSettingsMap;
|
|
3049
3056
|
if (!J(t)) return;
|
|
3050
|
-
const s = e.card,
|
|
3057
|
+
const s = e.card, o = ys(s), n = ee(s, "pivotByColumns").length > 0, i = /* @__PURE__ */ new Map(), d = [];
|
|
3051
3058
|
for (const [c, h] of Object.entries(t)) {
|
|
3052
3059
|
if (!J(h)) continue;
|
|
3053
|
-
const
|
|
3054
|
-
if (Li(
|
|
3055
|
-
const
|
|
3056
|
-
if (
|
|
3057
|
-
Da(e, c,
|
|
3058
|
-
else if (
|
|
3059
|
-
const
|
|
3060
|
-
|
|
3061
|
-
path:
|
|
3060
|
+
const p = h, I = `preferences.tablePrefs.columnSettingsMap[${JSON.stringify(c)}]`;
|
|
3061
|
+
if (Li(p)) {
|
|
3062
|
+
const v = So(p.numberFormat);
|
|
3063
|
+
if (v && o)
|
|
3064
|
+
Da(e, c, v, `${I}.numberFormat`);
|
|
3065
|
+
else if (v && Rt(s)) {
|
|
3066
|
+
const x = Fa(s, c), w = { key: c, format: v, from: `${I}.numberFormat` };
|
|
3067
|
+
x ? i.set(x, [...i.get(x) ?? [], w]) : n ? d.push(w) : e.unconverted.push({
|
|
3068
|
+
path: w.from,
|
|
3062
3069
|
reason: "unmatched_column_setting",
|
|
3063
3070
|
detail: `"${c}" names no card column.`
|
|
3064
3071
|
});
|
|
3065
|
-
} else
|
|
3066
|
-
(
|
|
3072
|
+
} else v && s.type !== "matrixTable" && s.type !== "kpi" && ee(s, "metricColumns").some(
|
|
3073
|
+
(w) => w.comparison != null
|
|
3067
3074
|
) && e.unconverted.push({
|
|
3068
|
-
path: `${
|
|
3075
|
+
path: `${I}.numberFormat`,
|
|
3069
3076
|
reason: "chart_comparison_column_setting",
|
|
3070
3077
|
detail: `"${c}" formats this chart's comparison tooltip only.`
|
|
3071
3078
|
});
|
|
3072
3079
|
}
|
|
3073
|
-
if (J(
|
|
3074
|
-
const
|
|
3075
|
-
if (
|
|
3076
|
-
Da(e, c, ko(
|
|
3077
|
-
else if (
|
|
3078
|
-
const
|
|
3079
|
-
(!
|
|
3080
|
-
path: `${
|
|
3080
|
+
if (J(p.dateFormat)) {
|
|
3081
|
+
const v = p.type === "date";
|
|
3082
|
+
if (v && o)
|
|
3083
|
+
Da(e, c, ko(p.dateFormat), `${I}.dateFormat`);
|
|
3084
|
+
else if (v && Rt(s)) {
|
|
3085
|
+
const x = Fa(s, c);
|
|
3086
|
+
(!x || !Mi(s, x)) && e.unconverted.push({
|
|
3087
|
+
path: `${I}.dateFormat`,
|
|
3081
3088
|
reason: "config_column_date_setting",
|
|
3082
3089
|
detail: `"${c}"'s download formats its dates with this setting.`
|
|
3083
3090
|
});
|
|
3084
3091
|
}
|
|
3085
3092
|
}
|
|
3086
|
-
for (const
|
|
3087
|
-
Object.prototype.hasOwnProperty.call(
|
|
3093
|
+
for (const v of Ni)
|
|
3094
|
+
Object.prototype.hasOwnProperty.call(p, v) && (delete p[v], e.changes.push({ path: `${I}.${v}`, action: "removed" }));
|
|
3088
3095
|
}
|
|
3089
3096
|
Vi(e, i), ji(e, d);
|
|
3090
3097
|
}
|
|
@@ -3099,7 +3106,7 @@ function Ui(e) {
|
|
|
3099
3106
|
function Gi(e) {
|
|
3100
3107
|
const a = e.card, t = a.preferences;
|
|
3101
3108
|
if (!t) return;
|
|
3102
|
-
const s = t.kpiVisualOptions,
|
|
3109
|
+
const s = t.kpiVisualOptions, o = J(s == null ? void 0 : s.formatOptions) ? s.formatOptions : void 0, n = t, i = J(n.formatNumber) ? n.formatNumber : void 0, d = o ? Se(To(o)) : void 0, l = i && Wi(i) ? Se(Ro(i)) : void 0;
|
|
3103
3110
|
if (a.type === "kpi") {
|
|
3104
3111
|
if (Ui(i) && e.unconverted.push({
|
|
3105
3112
|
path: "preferences.formatNumber.enabled",
|
|
@@ -3133,22 +3140,22 @@ function Gi(e) {
|
|
|
3133
3140
|
detail: "A card-wide number format on a chart measure without a format of its own."
|
|
3134
3141
|
});
|
|
3135
3142
|
}
|
|
3136
|
-
if (!i && ue(
|
|
3143
|
+
if (!i && ue(n, "formatNumber") && (delete n.formatNumber, e.changes.push({ path: "preferences.formatNumber", action: "removed" })), i) {
|
|
3137
3144
|
const c = i.colorRanges;
|
|
3138
|
-
Array.isArray(c) && c.length > 0 ?
|
|
3145
|
+
Array.isArray(c) && c.length > 0 ? n.formatNumber = { colorRanges: c } : delete n.formatNumber, e.changes.push({ path: "preferences.formatNumber", action: "removed" });
|
|
3139
3146
|
}
|
|
3140
|
-
s &&
|
|
3147
|
+
s && Te(s, ["formatOptions", "queryComparisonPolarity"]) && (e.changes.push({ path: "preferences.kpiVisualOptions.formatOptions", action: "removed" }), Object.keys(s).length === 0 && delete t.kpiVisualOptions);
|
|
3141
3148
|
for (const c of ["numberAxisFormat", "columnSettings"])
|
|
3142
|
-
|
|
3149
|
+
Te(t, [c]) && e.changes.push({ path: `preferences.${c}`, action: "removed" });
|
|
3143
3150
|
}
|
|
3144
3151
|
function Qi(e, a) {
|
|
3145
|
-
var
|
|
3152
|
+
var n;
|
|
3146
3153
|
const t = a == null ? void 0 : a.decimalPlaces, s = e.card.preferences;
|
|
3147
|
-
if (typeof t != "number" || ((
|
|
3148
|
-
const
|
|
3149
|
-
|
|
3154
|
+
if (typeof t != "number" || ((n = s.comparisonPresentation) == null ? void 0 : n.precision) !== void 0) return;
|
|
3155
|
+
const o = Bo(t);
|
|
3156
|
+
o !== void 0 && (s.comparisonPresentation = {
|
|
3150
3157
|
...s.comparisonPresentation,
|
|
3151
|
-
precision:
|
|
3158
|
+
precision: o
|
|
3152
3159
|
}, e.changes.push({
|
|
3153
3160
|
path: "preferences.formatNumber.decimalPlaces",
|
|
3154
3161
|
action: "moved",
|
|
@@ -3162,34 +3169,34 @@ function zi(e) {
|
|
|
3162
3169
|
for (const t of Ri) {
|
|
3163
3170
|
const s = a[t];
|
|
3164
3171
|
if (!J(s)) continue;
|
|
3165
|
-
const
|
|
3172
|
+
const o = `preferences.${t}`, n = J(s.formatOptions) ? s.formatOptions : void 0, i = t === "dataLabelsConfig" && typeof s.format == "string" ? s.format : void 0, d = s.formatMode === "override" || s.formatMode === "inherit" ? s.formatMode : s.mode === "override" || s.mode === "inherit" ? s.mode : void 0, l = d ?? (i === "none" ? "raw" : i && i !== "auto" || n ? "override" : "inherit");
|
|
3166
3173
|
if (l === "raw" || d === void 0 && i === "none")
|
|
3167
|
-
e.unconverted.push({ path: `${
|
|
3174
|
+
e.unconverted.push({ path: `${o}.format`, reason: "raw_display", detail: "Data labels show raw values." });
|
|
3168
3175
|
else if (l === "override") {
|
|
3169
|
-
const c =
|
|
3170
|
-
h && (s.valueFormat = h, e.changes.push({ path: `${
|
|
3176
|
+
const c = n && n.type ? n : i && Hi.has(i) ? { ...n, type: i } : n, h = c ? Se(Ao(c, { preserveOmittedProperties: !0 })) : void 0;
|
|
3177
|
+
h && (s.valueFormat = h, e.changes.push({ path: `${o}.formatOptions`, action: "moved", to: `${o}.valueFormat` }));
|
|
3171
3178
|
}
|
|
3172
|
-
|
|
3179
|
+
Te(s, ["formatMode", "mode", "formatOptions", ...t === "dataLabelsConfig" ? ["format"] : []]) && e.changes.push({ path: `${o}.formatMode`, action: "removed" });
|
|
3173
3180
|
}
|
|
3174
3181
|
}
|
|
3175
3182
|
function Yi(e) {
|
|
3176
3183
|
var s;
|
|
3177
3184
|
const a = (s = e.card.config) == null ? void 0 : s.matrix, t = J(a) && J(a.presentation) ? a.presentation : void 0;
|
|
3178
3185
|
if (t)
|
|
3179
|
-
for (const
|
|
3180
|
-
const
|
|
3181
|
-
if (J(
|
|
3182
|
-
for (const [i, d] of Object.entries(
|
|
3186
|
+
for (const o of ["measureFormats", "levelFormats"]) {
|
|
3187
|
+
const n = t[o];
|
|
3188
|
+
if (J(n))
|
|
3189
|
+
for (const [i, d] of Object.entries(n)) {
|
|
3183
3190
|
const l = Mt(d);
|
|
3184
|
-
l && !
|
|
3191
|
+
l && !_e(l, d) && (n[i] = l, e.changes.push({ path: `config.matrix.presentation.${o}[${JSON.stringify(i)}]`, action: "cleaned" }));
|
|
3185
3192
|
}
|
|
3186
3193
|
}
|
|
3187
3194
|
}
|
|
3188
3195
|
function Ji(e, a = {}) {
|
|
3189
3196
|
const t = { card: structuredClone(e), changes: [], unconverted: [] };
|
|
3190
3197
|
for (const s of Lt)
|
|
3191
|
-
ee(t.card, s).forEach((
|
|
3192
|
-
J(
|
|
3198
|
+
ee(t.card, s).forEach((o, n) => {
|
|
3199
|
+
J(o) && Oi(t, o, s, `config.${s}[${n}]`);
|
|
3193
3200
|
});
|
|
3194
3201
|
return qi(t), Ki(t), Gi(t), zi(t), Yi(t), Ei(t, a), t.changes.length === 0 && t.unconverted.length === 0 ? { card: e, changes: [], unconverted: [] } : t;
|
|
3195
3202
|
}
|
|
@@ -3209,12 +3216,12 @@ function ar(e, a) {
|
|
|
3209
3216
|
var c, h;
|
|
3210
3217
|
const t = ((c = e.config) == null ? void 0 : c.metricColumns) ?? [], s = ((h = e.config) == null ? void 0 : h.pivotByColumns) ?? [];
|
|
3211
3218
|
if (t.length !== 1 || s.length !== 1) return { reason: "pivot_key_form" };
|
|
3212
|
-
const
|
|
3219
|
+
const o = t[0], n = s[0], i = o.aliasTemplate ?? "", d = i.includes(`{{${n.name}}}`) || i.includes(`{{${n.entityName}.${n.name}}}`), l = !!(o.valueAliases && Object.keys(o.valueAliases).length);
|
|
3213
3220
|
return d || l || /["'`\t\n\r]/.test(a) || a.startsWith("col_") ? { reason: "pivot_key_form" } : {
|
|
3214
3221
|
ref: {
|
|
3215
3222
|
kind: "pivot",
|
|
3216
|
-
metricId:
|
|
3217
|
-
members: [{ fieldId:
|
|
3223
|
+
metricId: o.id,
|
|
3224
|
+
members: [{ fieldId: n.id, value: a === Zi ? null : a }]
|
|
3218
3225
|
}
|
|
3219
3226
|
};
|
|
3220
3227
|
}
|
|
@@ -3222,30 +3229,30 @@ function sr(e, a) {
|
|
|
3222
3229
|
var i, d;
|
|
3223
3230
|
if (a === Xi) return { reason: "unassigned_trigger" };
|
|
3224
3231
|
if (er(e)) return { ref: { kind: "result", key: a } };
|
|
3225
|
-
const t = tr(e), s = t.filter((l) => Oa(l).includes(a)),
|
|
3226
|
-
return
|
|
3232
|
+
const t = tr(e), s = t.filter((l) => Oa(l).includes(a)), o = s.length ? s : t.filter((l) => Oa(l).some((c) => (c == null ? void 0 : c.trim().toLowerCase()) === a.trim().toLowerCase())), n = [...new Set(o.map((l) => l.id))];
|
|
3233
|
+
return n.length === 1 ? { ref: { kind: "field", fieldId: n[0] } } : n.length > 1 ? { reason: "ambiguous_column" } : (d = (i = e.config) == null ? void 0 : i.pivotByColumns) != null && d.length ? ar(e, a) : { reason: "no_matching_column" };
|
|
3227
3234
|
}
|
|
3228
|
-
function Ea(e, a, t, s,
|
|
3229
|
-
const
|
|
3230
|
-
s.push({ ruleId: e.id, name: e.name, enabled: e.enabled !== !1, path: `${t}.${
|
|
3235
|
+
function Ea(e, a, t, s, o) {
|
|
3236
|
+
const n = (g, k, T) => {
|
|
3237
|
+
s.push({ ruleId: e.id, name: e.name, enabled: e.enabled !== !1, path: `${t}.${g}`, reference: k, reason: T });
|
|
3231
3238
|
}, i = e.condition.columnId ?? "", d = a(i);
|
|
3232
|
-
if (!("ref" in d)) return
|
|
3239
|
+
if (!("ref" in d)) return n("condition.columnId", i, d.reason);
|
|
3233
3240
|
const l = e.target.level, c = l === "row" ? e.target.applyToColumnIds : e.target.columnIds;
|
|
3234
3241
|
if (l === "cell" && !(c != null && c.length) && e.enabled !== !1)
|
|
3235
|
-
return
|
|
3242
|
+
return n("target.columnIds", "", "every_column");
|
|
3236
3243
|
const h = [];
|
|
3237
|
-
for (const [
|
|
3244
|
+
for (const [g, k] of (c ?? []).entries()) {
|
|
3238
3245
|
const T = a(k);
|
|
3239
3246
|
if (!("ref" in T))
|
|
3240
|
-
return
|
|
3247
|
+
return n(`target.${l === "row" ? "applyToColumnIds" : "columnIds"}[${g}]`, k, T.reason);
|
|
3241
3248
|
h.push(T.ref);
|
|
3242
3249
|
}
|
|
3243
3250
|
const {
|
|
3244
|
-
columnIds:
|
|
3245
|
-
applyToColumnIds:
|
|
3246
|
-
conditionColumnId:
|
|
3247
|
-
matrix:
|
|
3248
|
-
rowRoles:
|
|
3251
|
+
columnIds: p,
|
|
3252
|
+
applyToColumnIds: I,
|
|
3253
|
+
conditionColumnId: v,
|
|
3254
|
+
matrix: x,
|
|
3255
|
+
rowRoles: w,
|
|
3249
3256
|
depth: E,
|
|
3250
3257
|
includeTotals: _,
|
|
3251
3258
|
includeSubtotals: S,
|
|
@@ -3254,9 +3261,9 @@ function Ea(e, a, t, s, n) {
|
|
|
3254
3261
|
...y,
|
|
3255
3262
|
...h.length ? { columns: h } : {},
|
|
3256
3263
|
// The Matrix scope means something only on a Matrix card.
|
|
3257
|
-
...
|
|
3258
|
-
...
|
|
3259
|
-
...
|
|
3264
|
+
...o ? {
|
|
3265
|
+
...x !== void 0 ? { matrix: x } : {},
|
|
3266
|
+
...w !== void 0 ? { rowRoles: w } : {},
|
|
3260
3267
|
...E !== void 0 ? { depth: E } : {},
|
|
3261
3268
|
..._ !== void 0 ? { includeTotals: _ } : {},
|
|
3262
3269
|
...S !== void 0 ? { includeSubtotals: S } : {}
|
|
@@ -3269,74 +3276,74 @@ function Ea(e, a, t, s, n) {
|
|
|
3269
3276
|
};
|
|
3270
3277
|
}
|
|
3271
3278
|
function or(e, a) {
|
|
3272
|
-
var
|
|
3273
|
-
const t = (
|
|
3279
|
+
var o;
|
|
3280
|
+
const t = (o = La(e)) == null ? void 0 : o.value;
|
|
3274
3281
|
if (!t) return [];
|
|
3275
|
-
const s = (
|
|
3276
|
-
return a.flatMap((
|
|
3277
|
-
if (!
|
|
3278
|
-
const { start: d, end: l, color: c } =
|
|
3279
|
-
if (Number.isNaN(h) || Number.isNaN(
|
|
3280
|
-
const
|
|
3281
|
-
return [{ id: `kpi-color-range-${i + 1}`, condition:
|
|
3282
|
+
const s = (n) => n === null ? 0 : typeof n == "number" || typeof n == "string" || typeof n == "boolean" ? Number(n) : NaN;
|
|
3283
|
+
return a.flatMap((n, i) => {
|
|
3284
|
+
if (!n || typeof n != "object") return [];
|
|
3285
|
+
const { start: d, end: l, color: c } = n, h = s(d), p = s(l);
|
|
3286
|
+
if (Number.isNaN(h) || Number.isNaN(p) || h > p || h === 1 / 0 || p === -1 / 0) return [];
|
|
3287
|
+
const I = h === -1 / 0 ? void 0 : h, v = p === 1 / 0 ? void 0 : p, x = I !== void 0 && v !== void 0 ? { kind: "between", column: t, min: I, max: v, inclusive: !0 } : I !== void 0 ? { kind: "comparison", column: t, operator: "gte", value: I } : v !== void 0 ? { kind: "comparison", column: t, operator: "lte", value: v } : { kind: "blank", column: t, isBlank: !1 }, w = typeof c == "string" ? c : "";
|
|
3288
|
+
return [{ id: `kpi-color-range-${i + 1}`, condition: x, target: { level: "cell" }, style: { textColor: w } }];
|
|
3282
3289
|
}).reverse();
|
|
3283
3290
|
}
|
|
3284
3291
|
function nr(e) {
|
|
3285
|
-
var h,
|
|
3286
|
-
const a = structuredClone(e), t = [], s = [],
|
|
3292
|
+
var h, p, I, v, x, w, E;
|
|
3293
|
+
const a = structuredClone(e), t = [], s = [], o = [], n = (_) => {
|
|
3287
3294
|
t.some((S) => S.from.startsWith(_)) || t.push({ ruleId: "", action: "removed", from: _ });
|
|
3288
3295
|
}, i = (h = a.preferences) == null ? void 0 : h.tablePrefs;
|
|
3289
3296
|
if (i && ue(i, "conditionalFormatting")) {
|
|
3290
3297
|
const _ = i.conditionalFormatting, S = "preferences.tablePrefs.conditionalFormatting", y = a.type === "table" || a.type === "detailTable";
|
|
3291
3298
|
((_ == null ? void 0 : _.rules) ?? []).forEach((D, $) => {
|
|
3292
|
-
var
|
|
3293
|
-
if (!y || ((
|
|
3299
|
+
var g;
|
|
3300
|
+
if (!y || ((g = D.target) == null ? void 0 : g.matrix) !== void 0) {
|
|
3294
3301
|
t.push({ ruleId: D.id, action: "removed", from: `${S}.rules[${$}]` });
|
|
3295
3302
|
return;
|
|
3296
3303
|
}
|
|
3297
3304
|
const N = Ea(D, (k) => sr(a, k), `${S}.rules[${$}]`, s, !1);
|
|
3298
|
-
N && (
|
|
3299
|
-
}), delete i.conditionalFormatting, s.some((D) => D.path.startsWith(S)) ||
|
|
3305
|
+
N && (o.push(N), t.push({ ruleId: D.id, action: "moved", from: `${S}.rules[${$}]` }));
|
|
3306
|
+
}), delete i.conditionalFormatting, s.some((D) => D.path.startsWith(S)) || n(S);
|
|
3300
3307
|
}
|
|
3301
|
-
const d = (
|
|
3308
|
+
const d = (I = (p = a.config) == null ? void 0 : p.matrix) == null ? void 0 : I.presentation;
|
|
3302
3309
|
if (d && ue(d, "conditionalFormatting")) {
|
|
3303
|
-
const _ = d.conditionalFormatting, S = "config.matrix.presentation.conditionalFormatting", y = new Set((
|
|
3310
|
+
const _ = d.conditionalFormatting, S = "config.matrix.presentation.conditionalFormatting", y = new Set((x = (v = a.config) == null ? void 0 : v.matrix) == null ? void 0 : x.spec.measures.map((D) => D.id));
|
|
3304
3311
|
((_ == null ? void 0 : _.rules) ?? []).forEach((D, $) => {
|
|
3305
3312
|
const N = Ea(
|
|
3306
3313
|
D,
|
|
3307
|
-
(
|
|
3314
|
+
(g) => y.has(g) ? { ref: { kind: "matrixMeasure", measureId: g } } : { reason: "no_matching_column" },
|
|
3308
3315
|
`${S}.rules[${$}]`,
|
|
3309
3316
|
s,
|
|
3310
3317
|
!0
|
|
3311
3318
|
);
|
|
3312
|
-
N && (
|
|
3313
|
-
}), delete d.conditionalFormatting, s.some((D) => D.path.startsWith(S)) ||
|
|
3319
|
+
N && (o.push(N), t.push({ ruleId: D.id, action: "moved", from: `${S}.rules[${$}]` }));
|
|
3320
|
+
}), delete d.conditionalFormatting, s.some((D) => D.path.startsWith(S)) || n(S);
|
|
3314
3321
|
}
|
|
3315
3322
|
const l = a.preferences, c = l == null ? void 0 : l.formatNumber;
|
|
3316
3323
|
if (c && ue(c, "colorRanges")) {
|
|
3317
3324
|
const _ = Array.isArray(c.colorRanges) ? c.colorRanges : [];
|
|
3318
3325
|
if (a.type === "kpi") {
|
|
3319
3326
|
const S = or(a, _);
|
|
3320
|
-
|
|
3327
|
+
o.push(...S), S.forEach((y) => t.push({ ruleId: y.id, action: "moved", from: "preferences.formatNumber.colorRanges" }));
|
|
3321
3328
|
}
|
|
3322
3329
|
delete c.colorRanges, Object.keys(c).length === 0 && delete l.formatNumber, t.some((S) => S.from === "preferences.formatNumber.colorRanges") || t.push({ ruleId: "", action: "removed", from: "preferences.formatNumber.colorRanges" });
|
|
3323
3330
|
}
|
|
3324
3331
|
if (!t.length && !s.length) return { card: e, changes: [], unresolved: [] };
|
|
3325
|
-
if (
|
|
3326
|
-
const _ = ((E = (
|
|
3332
|
+
if (o.length) {
|
|
3333
|
+
const _ = ((E = (w = a.preferences) == null ? void 0 : w.conditionalFormatting) == null ? void 0 : E.rules) ?? [], S = new Set(_.map((y) => y.id));
|
|
3327
3334
|
a.preferences = {
|
|
3328
3335
|
...a.preferences,
|
|
3329
3336
|
conditionalFormatting: {
|
|
3330
3337
|
version: 1,
|
|
3331
|
-
rules: [..._, ...
|
|
3338
|
+
rules: [..._, ...o.filter((y) => !S.has(y.id))]
|
|
3332
3339
|
}
|
|
3333
3340
|
};
|
|
3334
3341
|
}
|
|
3335
3342
|
return { card: a, changes: t, unresolved: s };
|
|
3336
3343
|
}
|
|
3337
3344
|
function Pr(e, a = {}) {
|
|
3338
|
-
const { only: t, ...s } = a,
|
|
3339
|
-
return { card: (
|
|
3345
|
+
const { only: t, ...s } = a, o = t === "rules" ? void 0 : Ji(e, s), n = t === "formats" ? void 0 : nr((o == null ? void 0 : o.card) ?? e);
|
|
3346
|
+
return { card: (n == null ? void 0 : n.card) ?? (o == null ? void 0 : o.card) ?? e, formats: o, rules: n };
|
|
3340
3347
|
}
|
|
3341
3348
|
function ir(e) {
|
|
3342
3349
|
if (e.op === "dashboard.update" || e.op === "dashboard.style" || e.op === "sheet.update") return !0;
|
|
@@ -3365,7 +3372,7 @@ export {
|
|
|
3365
3372
|
kr as CARD_QUERY_REQUEST_EXECUTED_FIELDS,
|
|
3366
3373
|
mh as CARD_SURFACES,
|
|
3367
3374
|
Qr as CARD_TYPES,
|
|
3368
|
-
|
|
3375
|
+
De as CARD_TYPE_RULES,
|
|
3369
3376
|
je as CHART_COLORS_BOUNDS,
|
|
3370
3377
|
Hr as CHIP_VALUE_COLUMN,
|
|
3371
3378
|
zr as COLUMN_KEY_CLASSES,
|
|
@@ -3512,7 +3519,7 @@ export {
|
|
|
3512
3519
|
yh as defaultVariableName,
|
|
3513
3520
|
kh as describeBookmarkImpact,
|
|
3514
3521
|
vl as describeDashboardFilterCardReach,
|
|
3515
|
-
|
|
3522
|
+
$e as describeDashboardFilterCardReachDetail,
|
|
3516
3523
|
Il as describeMeasureCalculations,
|
|
3517
3524
|
ao as describeQueryChange,
|
|
3518
3525
|
Hm as describeRelationshipRoute,
|
|
@@ -3612,7 +3619,7 @@ export {
|
|
|
3612
3619
|
bm as legacyTableRoutingTarget,
|
|
3613
3620
|
bc as linkedClickToFilterOverridesSchema,
|
|
3614
3621
|
ym as listAdHocFilterValuesOnTab,
|
|
3615
|
-
|
|
3622
|
+
xe as listDashboardCardLocations,
|
|
3616
3623
|
yc as listDashboardFilterDefinitions,
|
|
3617
3624
|
vc as listDashboardFilterInputsOnTab,
|
|
3618
3625
|
Wa as listDashboardFilterTargets,
|
|
@@ -3676,12 +3683,12 @@ export {
|
|
|
3676
3683
|
oo as queryForm,
|
|
3677
3684
|
jc as queryMeasureSchema,
|
|
3678
3685
|
Kc as readCardConditionalRules,
|
|
3679
|
-
|
|
3686
|
+
we as readCardQuery,
|
|
3680
3687
|
Ft as readCardSettings,
|
|
3681
3688
|
he as readCardSource,
|
|
3682
3689
|
qe as readCardTypeProperties,
|
|
3683
3690
|
$h as readComparisonDates,
|
|
3684
|
-
|
|
3691
|
+
Ie as readDashboardFilterModel,
|
|
3685
3692
|
wh as readDefaultComparisonDates,
|
|
3686
3693
|
Wc as readExactDomainCalculatedFieldReference,
|
|
3687
3694
|
ih as readFilterReachResponse,
|