@databrainhq/plugin 0.17.9-beta.54 → 0.17.9-beta.56
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/{Accordion-CYthA7hI.mjs → Accordion-ChukdUTN.mjs} +1 -1
- package/dist/{CardChartSlot-ClaGH_WG.mjs → CardChartSlot-B56mnvX_.mjs} +5 -5
- package/dist/{Chart-9Kbc5GWj.mjs → Chart-C_38h0oW.mjs} +8 -8
- package/dist/{ChartTypePanel-CnEEFdIE.mjs → ChartTypePanel-efKLrW0l.mjs} +8 -8
- package/dist/{CreateGlobalFilter-CMThk9X8.mjs → CreateGlobalFilter-b52KPIHA.mjs} +2 -2
- package/dist/{CreateMetricV2-CyxOYjFh.mjs → CreateMetricV2-BcYDuFO7.mjs} +11 -11
- package/dist/{HorizontalStackTable-wOyYw_HM.mjs → HorizontalStackTable-mg6k5CmN.mjs} +3 -3
- package/dist/{ManageMetricsV2-Cvou21vJ.mjs → ManageMetricsV2-CEmTsPEF.mjs} +3 -3
- package/dist/{MetricCardV2-ChpKWOJy.mjs → MetricCardV2-CLl6-gu5.mjs} +752 -700
- package/dist/{NoDataFound-CFZ240jh.mjs → NoDataFound-Cowe6WJQ.mjs} +1 -1
- package/dist/{Panel-BpAIfmDU.mjs → Panel-C9f6SPjQ.mjs} +1 -1
- package/dist/{PivotTableV2-Dis6siW9.mjs → PivotTableV2-BAH-e_t2.mjs} +2 -2
- package/dist/{PivotTableV3-Cgs_jTEA.mjs → PivotTableV3-BlYdjypT.mjs} +4 -4
- package/dist/{Portal-CEuy4Zyk.mjs → Portal-5FJ1yAWh.mjs} +2 -2
- package/dist/{RadioButton-3MAAKvzv.mjs → RadioButton-Bv9S4V21.mjs} +1 -1
- package/dist/{ScheduleEmail-CjaXkLiS.mjs → ScheduleEmail-DpH7b_6-.mjs} +6 -6
- package/dist/{SearchMetricData-DcNwcJYI.mjs → SearchMetricData-BplGNchb.mjs} +13 -13
- package/dist/{SortPanel-DLuZnhbs.mjs → SortPanel-BgNFd7aa.mjs} +8 -8
- package/dist/{Table-BIHNbx03.mjs → Table-BqEdMmgl.mjs} +4 -4
- package/dist/{TagInputField-CzLeqr3G.mjs → TagInputField-Bx4SMhHq.mjs} +4 -4
- package/dist/{TextAreaField-AXMe-Vuo.mjs → TextAreaField-CzTAQPoh.mjs} +2 -2
- package/dist/{TimeSeriesSettings-CwLUyfrk.mjs → TimeSeriesSettings-CgzlCKvy.mjs} +2 -2
- package/dist/cardQueryError-D9JvTAXs.mjs +5247 -0
- package/dist/{conditionalFormatting-Dwh1zp-l.mjs → conditionalFormatting-9nsQwtpu.mjs} +1 -1
- package/dist/{createGlobalFilter.module-CcqSTCtL.mjs → createGlobalFilter.module-B1MhKvKM.mjs} +1 -1
- package/dist/data.cjs +1 -1
- package/dist/data.mjs +1 -1
- package/dist/{echarts-DKgzxZiu.mjs → echarts-zgjEVbyp.mjs} +2 -2
- package/dist/{metric.mutation-BhHdNmVR.mjs → metric.mutation-cYDbHPa2.mjs} +1 -1
- package/dist/{permissions-CRnV7dKB.mjs → permissions-DYV8g5UE.mjs} +5 -5
- package/dist/{pluginV3Request-CeA8XQxB.mjs → pluginV3Request-D9WChXJv.mjs} +1 -1
- package/dist/{renderer-x8Z7Mxc5.mjs → renderer-BFVSDnMA.mjs} +1 -1
- package/dist/{timeseries-Dto8IAO0.mjs → timeseries-Bi-JmLH9.mjs} +1 -1
- package/dist/{toTasteAppearance-DhoxgFyx.mjs → toTasteAppearance-BPeS91-D.mjs} +3 -3
- package/dist/{useGuesTokenUsageLog-BXov_YU2.mjs → useGuesTokenUsageLog-CcA5-Uur.mjs} +1 -1
- package/dist/{usePublishArchivedMetrics-DxgRTJLo.mjs → usePublishArchivedMetrics-DYrn8_6z.mjs} +2 -2
- package/dist/{useQuery-DLS92E5D.mjs → useQuery-k8wewYC0.mjs} +1 -1
- package/dist/webcomponents.css +2 -2
- package/dist/webcomponents.es.js +2923 -4216
- package/dist/webcomponents.umd.js +177 -177
- package/package.json +1 -1
- package/dist/cardQueryError-CLU0EPLv.mjs +0 -3954
|
@@ -1,3954 +0,0 @@
|
|
|
1
|
-
import "react";
|
|
2
|
-
import "react-dom";
|
|
3
|
-
import "react-dom/client";
|
|
4
|
-
import { o as e, t } from "./rolldown-runtime-C1JUX4Ur.mjs";
|
|
5
|
-
import { c as n, l as r } from "./cardStates-pxkuDK8H.mjs";
|
|
6
|
-
import { Bt as i, It as a, Vt as o, Zt as s, a as c, c as l, l as u, m as d, u as f, zt as p } from "./pluginV3Request-CeA8XQxB.mjs";
|
|
7
|
-
import { $ as m, K as h, O as g, Q as _, U as v, X as y, Y as b, Z as x, a as S, at as C, d as w, et as ee, i as te, l as T, lt as ne, q as E, s as D, tt as O } from "./metric.mutation-BhHdNmVR.mjs";
|
|
8
|
-
import { $a as k, $n as re, $t as A, At as ie, Br as ae, En as oe, Fn as se, Gt as ce, Hn as le, Ht as ue, In as de, Ja as j, Ki as fe, Kn as pe, La as me, Mn as M, On as he, Pn as ge, Qn as _e, Sn as ve, Tn as ye, Tr as be, Ut as xe, Va as N, Xa as Se, Xt as Ce, Ya as P, Yt as we, Za as Te, Zn as Ee, _n as De, an as Oe, ar as ke, bn as Ae, dn as je, gi as Me, gn as Ne, hn as Pe, in as Fe, jr as Ie, nn as Le, nr as Re, on as ze, or as F, qa as Be, qn as Ve, qt as He, ra as Ue, rr as We, s as Ge, tn as Ke, tr as qe, un as Je, ur as Ye, vi as Xe, vn as Ze, wn as Qe, ya as $e } from "./Portal-CEuy4Zyk.mjs";
|
|
9
|
-
import { t as et } from "./useQuery-DLS92E5D.mjs";
|
|
10
|
-
import { s as tt } from "./toTasteAppearance-DhoxgFyx.mjs";
|
|
11
|
-
import { y as nt } from "./option-B1zeYJnm.mjs";
|
|
12
|
-
import { n as rt } from "./timeseries-Dto8IAO0.mjs";
|
|
13
|
-
import { i as it } from "./text-CtrvkDIo.mjs";
|
|
14
|
-
import { E as at, M as ot, O as st, T as ct, a as lt, c as ut, f as dt, k as ft, m as pt, p as mt, u as ht, v as gt, y as _t } from "./permissions-CRnV7dKB.mjs";
|
|
15
|
-
import { f as vt, o as yt } from "./RadioButton-3MAAKvzv.mjs";
|
|
16
|
-
import { t as bt } from "./TimeSeriesSettings-CwLUyfrk.mjs";
|
|
17
|
-
import { createContext as xt, useCallback as I, useContext as St, useEffect as L, useLayoutEffect as Ct, useMemo as R, useRef as z, useState as B, useSyncExternalStore as wt } from "react";
|
|
18
|
-
import { jsx as Tt, jsxs as Et } from "react/jsx-runtime";
|
|
19
|
-
//#region src/helpers/getValidRlsConditionOptions.ts
|
|
20
|
-
var Dt = (e, t) => {
|
|
21
|
-
if (!t?.[e.name]) return;
|
|
22
|
-
let n = t?.[e.name]?.defaultOption?.toString(), r = (t?.[e.name]?.options)?.filter((t) => {
|
|
23
|
-
if (t == null) return !1;
|
|
24
|
-
switch (e.datatype) {
|
|
25
|
-
case "string":
|
|
26
|
-
if (!(typeof t == "string" || typeof t == "object" && typeof t?.value == "string") || !t) return !1;
|
|
27
|
-
break;
|
|
28
|
-
case "number":
|
|
29
|
-
if (!(typeof t == "number" || typeof t == "object" && t?.value) || !t) return !1;
|
|
30
|
-
break;
|
|
31
|
-
case "date": {
|
|
32
|
-
if (typeof t != "object" || !t.name) return !1;
|
|
33
|
-
let e = t.range?.toString().trim().toLowerCase().replace(/\s+/g, ""), n = e === "timerange" || t.isTimeFilter && e === "custom";
|
|
34
|
-
if (!n && ![
|
|
35
|
-
"last",
|
|
36
|
-
"this",
|
|
37
|
-
"custom"
|
|
38
|
-
].includes(e || "") || n && !ke({
|
|
39
|
-
endDate: t.endDate ?? t.toDate,
|
|
40
|
-
endTime: t.endTime,
|
|
41
|
-
startDate: t.startDate ?? t.fromDate,
|
|
42
|
-
startTime: t.startTime
|
|
43
|
-
}) || e !== "custom" && !n && !t.time && ![
|
|
44
|
-
"Day",
|
|
45
|
-
"Week",
|
|
46
|
-
"Month",
|
|
47
|
-
"Quarter",
|
|
48
|
-
"Year"
|
|
49
|
-
].includes(t.time)) return !1;
|
|
50
|
-
break;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
return !0;
|
|
54
|
-
}) || [];
|
|
55
|
-
if (r.length) return {
|
|
56
|
-
value: n === void 0 || r.some((e) => {
|
|
57
|
-
let { label: t, name: r, value: i } = e ?? {};
|
|
58
|
-
return [
|
|
59
|
-
r,
|
|
60
|
-
t,
|
|
61
|
-
i,
|
|
62
|
-
e
|
|
63
|
-
].filter((e) => e != null).map(String).includes(n);
|
|
64
|
-
}) ? n : void 0,
|
|
65
|
-
options: r
|
|
66
|
-
};
|
|
67
|
-
}, Ot = ({ rlsConditions: e, isFrontendApp: t }) => e.filter((e) => (t || !e.isAppFilter) && !e.isHiddenInUi), kt = xt({}), At = () => St(kt), jt = /;\s*$/, Mt = (e) => e.replace(jt, ""), Nt = (e) => `${e?.token || ""}|${+!!e?.isFrontendApp}|${e?.clientId || ""}`, Pt = (e, t = {}) => e?.id ? e.drillConfig?.levels?.some((e) => !!e?.filters?.length) ? {
|
|
68
|
-
eligible: !1,
|
|
69
|
-
reason: "drill-filtered"
|
|
70
|
-
} : e.isEncrypted && !t.isGuestTokenSession ? {
|
|
71
|
-
eligible: !1,
|
|
72
|
-
reason: "encrypted-payload"
|
|
73
|
-
} : { eligible: !0 } : {
|
|
74
|
-
eligible: !1,
|
|
75
|
-
reason: "no-metric-id"
|
|
76
|
-
}, Ft = (e, t, n, r = "embed", i) => ({
|
|
77
|
-
key: e,
|
|
78
|
-
externalMetricId: t.id,
|
|
79
|
-
...r === "platform" && n ? { clientId: n } : {},
|
|
80
|
-
...r === "platform" && t.timezone ? { timezone: t.timezone } : {},
|
|
81
|
-
...t.isEncrypted && i ? {
|
|
82
|
-
rlsConditions: t.rlsConditions?.length ? j(t.rlsConditions, i) : [],
|
|
83
|
-
globalFilters: t.globalFilters?.filters?.length ? j(t.globalFilters, i) : {
|
|
84
|
-
tableName: "",
|
|
85
|
-
filters: []
|
|
86
|
-
}
|
|
87
|
-
} : {
|
|
88
|
-
rlsConditions: t.rlsConditions,
|
|
89
|
-
globalFilters: t.globalFilters
|
|
90
|
-
},
|
|
91
|
-
tenancyLevel: t.tenancyLevel,
|
|
92
|
-
filterValues: t.filterValues,
|
|
93
|
-
drillFilters: t.drillFilters,
|
|
94
|
-
limit: t.limit,
|
|
95
|
-
offset: t.offset,
|
|
96
|
-
isAllClient: t.isAllClient,
|
|
97
|
-
dynamicXAxis: t.dynamicXAxis,
|
|
98
|
-
dbId: t.dbId,
|
|
99
|
-
pivotHeaders: t.pivotHeaders,
|
|
100
|
-
timeseriesSettings: t.timeseriesSettings,
|
|
101
|
-
chartSeriesField: t.chartSeriesField,
|
|
102
|
-
comparisonCount: t.comparisonCount,
|
|
103
|
-
drillConfig: t.drillConfig,
|
|
104
|
-
...t.isEncrypted && i ? { isEncrypted: !0 } : {}
|
|
105
|
-
}), It = (e) => {
|
|
106
|
-
let t = [];
|
|
107
|
-
if (typeof e.data == "string") try {
|
|
108
|
-
t = JSON.parse(e.data);
|
|
109
|
-
} catch {
|
|
110
|
-
return {
|
|
111
|
-
data: [],
|
|
112
|
-
timeTaken: e.timeTaken || 0,
|
|
113
|
-
error: { message: "Invalid response from server" }
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
else e.data !== void 0 && (t = e.data);
|
|
117
|
-
return {
|
|
118
|
-
data: t,
|
|
119
|
-
timeTaken: e.timeTaken || 0,
|
|
120
|
-
comparisonValue: e.comparisonValue,
|
|
121
|
-
totalRecords: e.totalRecords,
|
|
122
|
-
metaData: e.metaData,
|
|
123
|
-
...e.notices ? { notices: e.notices } : {},
|
|
124
|
-
...e.error ? { error: e.error } : {},
|
|
125
|
-
...e.cacheHit === void 0 ? {} : { cacheHit: e.cacheHit },
|
|
126
|
-
...e.dataAsOf === void 0 ? {} : { dataAsOf: e.dataAsOf },
|
|
127
|
-
...e.cacheEnabled === void 0 ? {} : { cacheEnabled: e.cacheEnabled }
|
|
128
|
-
};
|
|
129
|
-
}, Lt = 45e3, Rt = 1e3, zt = 1500, Bt = class {
|
|
130
|
-
options;
|
|
131
|
-
queue = [];
|
|
132
|
-
flushScheduled = !1;
|
|
133
|
-
flushTimer = null;
|
|
134
|
-
flushDueAt = 0;
|
|
135
|
-
burstStartedAt = 0;
|
|
136
|
-
burstIsCold = !1;
|
|
137
|
-
lastDispatchAt = null;
|
|
138
|
-
unsupported = !1;
|
|
139
|
-
authStrikes = 0;
|
|
140
|
-
constructor(e) {
|
|
141
|
-
this.options = {
|
|
142
|
-
transport: e.transport,
|
|
143
|
-
timeoutMs: e.timeoutMs ?? 45e3,
|
|
144
|
-
maxBatchSize: e.maxBatchSize ?? 24,
|
|
145
|
-
windowMs: e.windowMs ?? 0,
|
|
146
|
-
coalesceWindowMs: e.coalesceWindowMs ?? 0,
|
|
147
|
-
visibleCoalesceWindowMs: e.visibleCoalesceWindowMs ?? e.coalesceWindowMs ?? 0,
|
|
148
|
-
coalesceIdleMs: e.coalesceIdleMs ?? 1e3,
|
|
149
|
-
coalesceMaxWaitMs: e.coalesceMaxWaitMs ?? 1500,
|
|
150
|
-
coldHeadSize: e.coldHeadSize ?? 0,
|
|
151
|
-
now: e.now ?? (() => Date.now()),
|
|
152
|
-
authStrikeLimit: e.authStrikeLimit ?? 3,
|
|
153
|
-
scheduleMicrotask: e.scheduleMicrotask ?? ((e) => typeof queueMicrotask == "function" ? queueMicrotask(e) : Promise.resolve().then(e)),
|
|
154
|
-
scheduleTimeout: e.scheduleTimeout ?? ((e, t) => setTimeout(e, t)),
|
|
155
|
-
cancelTimeout: e.cancelTimeout ?? ((e) => {
|
|
156
|
-
e != null && clearTimeout(e);
|
|
157
|
-
}),
|
|
158
|
-
createAbortController: e.createAbortController ?? (() => new AbortController())
|
|
159
|
-
};
|
|
160
|
-
}
|
|
161
|
-
get isDisabled() {
|
|
162
|
-
return this.unsupported || this.authStrikes >= this.options.authStrikeLimit;
|
|
163
|
-
}
|
|
164
|
-
reset() {
|
|
165
|
-
this.cancelScheduledFlush(), this.queue = [], this.burstIsCold = !1, this.unsupported = !1, this.authStrikes = 0, this.lastDispatchAt = null;
|
|
166
|
-
}
|
|
167
|
-
enqueue(e) {
|
|
168
|
-
return this.isDisabled ? e.fallback() : new Promise((t, n) => {
|
|
169
|
-
this.queue.push({
|
|
170
|
-
...e,
|
|
171
|
-
resolve: t,
|
|
172
|
-
reject: n
|
|
173
|
-
}), this.scheduleFlush();
|
|
174
|
-
});
|
|
175
|
-
}
|
|
176
|
-
cancelScheduledFlush() {
|
|
177
|
-
this.flushScheduled = !1, this.flushDueAt = 0, this.flushTimer !== null && (this.options.cancelTimeout(this.flushTimer), this.flushTimer = null);
|
|
178
|
-
}
|
|
179
|
-
isWarm() {
|
|
180
|
-
let { coalesceWindowMs: e, coalesceIdleMs: t, now: n } = this.options;
|
|
181
|
-
return e <= 0 || this.lastDispatchAt === null ? !1 : n() - this.lastDispatchAt <= t;
|
|
182
|
-
}
|
|
183
|
-
scheduleFlush() {
|
|
184
|
-
if (this.queue.length >= this.options.maxBatchSize) {
|
|
185
|
-
this.cancelScheduledFlush(), this.flush();
|
|
186
|
-
return;
|
|
187
|
-
}
|
|
188
|
-
let e = () => {
|
|
189
|
-
this.flushScheduled = !1, this.flushTimer = null, this.flushDueAt = 0, this.flush();
|
|
190
|
-
};
|
|
191
|
-
if (!this.isWarm()) {
|
|
192
|
-
if (this.flushScheduled) return;
|
|
193
|
-
this.flushScheduled = !0, this.burstIsCold = !0, this.options.windowMs > 0 ? (this.flushDueAt = this.options.now() + this.options.windowMs, this.flushTimer = this.options.scheduleTimeout(e, this.options.windowMs)) : this.options.scheduleMicrotask(e);
|
|
194
|
-
return;
|
|
195
|
-
}
|
|
196
|
-
let t = this.options.now();
|
|
197
|
-
this.flushScheduled || (this.burstStartedAt = t, this.burstIsCold = !1);
|
|
198
|
-
let n = this.queue.some((e) => e.batchPolicy === "visible"), r = n ? this.options.visibleCoalesceWindowMs : this.options.coalesceWindowMs, i = Math.min(t + r, this.burstStartedAt + this.options.coalesceMaxWaitMs);
|
|
199
|
-
this.flushScheduled && (i === this.flushDueAt || !n && i < this.flushDueAt) || (this.flushTimer !== null && (this.options.cancelTimeout(this.flushTimer), this.flushTimer = null), this.flushScheduled = !0, this.flushDueAt = i, this.flushTimer = this.options.scheduleTimeout(e, Math.max(0, i - t)));
|
|
200
|
-
}
|
|
201
|
-
async flush() {
|
|
202
|
-
let e = this.queue;
|
|
203
|
-
this.queue = [];
|
|
204
|
-
let t = this.burstIsCold;
|
|
205
|
-
if (this.burstIsCold = !1, !e.length) return;
|
|
206
|
-
if (this.isDisabled) {
|
|
207
|
-
e.forEach((e) => {
|
|
208
|
-
this.settleWithFallback(e);
|
|
209
|
-
});
|
|
210
|
-
return;
|
|
211
|
-
}
|
|
212
|
-
let n = /* @__PURE__ */ new Map();
|
|
213
|
-
e.forEach((e) => {
|
|
214
|
-
let t = Nt(e.session), r = n.get(t);
|
|
215
|
-
r ? r.push(e) : n.set(t, [e]);
|
|
216
|
-
});
|
|
217
|
-
let { coldHeadSize: r, maxBatchSize: i } = this.options, a = t ? Math.min(r, i) : 0, o = [];
|
|
218
|
-
n.forEach((e) => {
|
|
219
|
-
let t = 0;
|
|
220
|
-
a > 0 && e.length > a && (o.push(e.slice(0, a)), t = a);
|
|
221
|
-
for (let n = t; n < e.length; n += i) o.push(e.slice(n, n + i));
|
|
222
|
-
}), this.lastDispatchAt = this.options.now(), await Promise.all(o.map((e) => this.sendChunk(e)));
|
|
223
|
-
}
|
|
224
|
-
async sendChunk(e) {
|
|
225
|
-
if (this.isDisabled) {
|
|
226
|
-
e.forEach((e) => {
|
|
227
|
-
this.settleWithFallback(e);
|
|
228
|
-
});
|
|
229
|
-
return;
|
|
230
|
-
}
|
|
231
|
-
let t = this.options.createAbortController(), r = !1, i = !1, a = this.options.scheduleTimeout(() => {
|
|
232
|
-
if (!i) {
|
|
233
|
-
r = !0;
|
|
234
|
-
try {
|
|
235
|
-
t.abort();
|
|
236
|
-
} catch {}
|
|
237
|
-
}
|
|
238
|
-
}, this.options.timeoutMs), o = () => {
|
|
239
|
-
this.options.cancelTimeout(a);
|
|
240
|
-
}, s;
|
|
241
|
-
try {
|
|
242
|
-
s = await this.options.transport(e.map((e) => e.request), t.signal, e[0]?.session || {}), i = !0, o();
|
|
243
|
-
} catch (t) {
|
|
244
|
-
if (i = !0, o(), r) {
|
|
245
|
-
let { message: t } = new x(this.options.timeoutMs);
|
|
246
|
-
e.forEach((e) => {
|
|
247
|
-
e.resolve({
|
|
248
|
-
data: [],
|
|
249
|
-
timeTaken: this.options.timeoutMs,
|
|
250
|
-
error: {
|
|
251
|
-
code: "QUERY_TIMEOUT",
|
|
252
|
-
message: t
|
|
253
|
-
}
|
|
254
|
-
});
|
|
255
|
-
});
|
|
256
|
-
return;
|
|
257
|
-
}
|
|
258
|
-
if (n(t)?.code === "UNAUTHORIZED_ORIGIN") {
|
|
259
|
-
e.forEach((e) => {
|
|
260
|
-
e.reject(t);
|
|
261
|
-
});
|
|
262
|
-
return;
|
|
263
|
-
}
|
|
264
|
-
if (t?.isBatchUnsupported) {
|
|
265
|
-
this.unsupported = !0, e.forEach((e) => {
|
|
266
|
-
this.settleWithFallback(e);
|
|
267
|
-
});
|
|
268
|
-
return;
|
|
269
|
-
}
|
|
270
|
-
if (t?.isBatchAuth) {
|
|
271
|
-
this.authStrikes += 1, e.forEach((e) => {
|
|
272
|
-
this.settleWithFallback(e);
|
|
273
|
-
});
|
|
274
|
-
return;
|
|
275
|
-
}
|
|
276
|
-
e.forEach((e) => {
|
|
277
|
-
this.settleWithFallback(e);
|
|
278
|
-
});
|
|
279
|
-
return;
|
|
280
|
-
}
|
|
281
|
-
if (this.authStrikes = 0, s?.error || !Array.isArray(s?.results)) {
|
|
282
|
-
e.forEach((e) => {
|
|
283
|
-
this.settleWithFallback(e);
|
|
284
|
-
});
|
|
285
|
-
return;
|
|
286
|
-
}
|
|
287
|
-
let c = /* @__PURE__ */ new Map();
|
|
288
|
-
s.results.forEach((e) => {
|
|
289
|
-
e?.key !== void 0 && e?.key !== null && c.set(String(e.key), e);
|
|
290
|
-
}), e.forEach((e, t) => {
|
|
291
|
-
let n = c.get(e.request.key) ?? s.results?.[t];
|
|
292
|
-
if (!n) {
|
|
293
|
-
this.settleWithFallback(e);
|
|
294
|
-
return;
|
|
295
|
-
}
|
|
296
|
-
let r = It(n);
|
|
297
|
-
e.resolve(r);
|
|
298
|
-
});
|
|
299
|
-
}
|
|
300
|
-
settleWithFallback(e) {
|
|
301
|
-
e.fallback().then(e.resolve, e.reject);
|
|
302
|
-
}
|
|
303
|
-
}, Vt = "dbnMetricBatch", Ht = "@dbn:metricQueryBatch", V = () => {
|
|
304
|
-
try {
|
|
305
|
-
let e = window.localStorage.getItem(Ht);
|
|
306
|
-
if (e === "on" || e === "off") return e;
|
|
307
|
-
} catch {}
|
|
308
|
-
return null;
|
|
309
|
-
}, Ut = (e) => {
|
|
310
|
-
try {
|
|
311
|
-
e === null ? window.localStorage.removeItem(Ht) : window.localStorage.setItem(Ht, e);
|
|
312
|
-
} catch {}
|
|
313
|
-
}, Wt = () => {
|
|
314
|
-
try {
|
|
315
|
-
let e = new URLSearchParams(window.location.search).get(Vt);
|
|
316
|
-
(e === "on" || e === "off") && Ut(e);
|
|
317
|
-
} catch {}
|
|
318
|
-
}, Gt = () => typeof window > "u" || window.dbn?.disableMetricQueryBatch ? "off" : (Wt(), V() ?? "auto"), Kt = () => Gt() !== "off", qt = /* @__PURE__ */ new Set(), H = () => {
|
|
319
|
-
let e;
|
|
320
|
-
return qt.forEach((t) => {
|
|
321
|
-
if (!e) try {
|
|
322
|
-
let n = t();
|
|
323
|
-
n && Object.keys(n).length && (e = n);
|
|
324
|
-
} catch {}
|
|
325
|
-
}), e;
|
|
326
|
-
}, Jt = "/hasuraActions/externalMetricQueryBatch", Yt = "/api/v3/metric/queryBatch", Xt = [
|
|
327
|
-
404,
|
|
328
|
-
405,
|
|
329
|
-
501
|
|
330
|
-
], Zt = [
|
|
331
|
-
200,
|
|
332
|
-
400,
|
|
333
|
-
401,
|
|
334
|
-
403
|
|
335
|
-
], Qt = (e) => !!e.token || !!(e.isFrontendApp && e.clientId), $t = (e = {}) => typeof window > "u" || typeof fetch != "function" || window.dbn?.isEnableProxyAuth ? null : Qt(e) ? "embed" : H() ? "platform" : null, en = (e = "platform") => `${window.dbn?.baseUrl || d}${e === "embed" ? Yt : Jt}`, tn = async (e, t, r = {}) => {
|
|
336
|
-
let i = $t(r);
|
|
337
|
-
if (!i) throw new b("No credentials available for batched queries");
|
|
338
|
-
let a;
|
|
339
|
-
if (i === "embed") a = await l({
|
|
340
|
-
path: Yt,
|
|
341
|
-
method: "POST",
|
|
342
|
-
signal: t,
|
|
343
|
-
token: r.token,
|
|
344
|
-
isFrontend: r.isFrontendApp,
|
|
345
|
-
clientId: r.clientId,
|
|
346
|
-
data: { requests: e },
|
|
347
|
-
throwOnHttpError: !1
|
|
348
|
-
});
|
|
349
|
-
else {
|
|
350
|
-
let n = H();
|
|
351
|
-
if (!n) throw new b("No access token available for batched queries");
|
|
352
|
-
a = await fetch(en(i), {
|
|
353
|
-
method: "POST",
|
|
354
|
-
signal: t,
|
|
355
|
-
headers: {
|
|
356
|
-
"Content-Type": "application/json",
|
|
357
|
-
"X-Plugin-Origin": window.location.host,
|
|
358
|
-
...f(),
|
|
359
|
-
...n
|
|
360
|
-
},
|
|
361
|
-
body: JSON.stringify({ input: { input: { requests: e } } })
|
|
362
|
-
});
|
|
363
|
-
}
|
|
364
|
-
if (Xt.includes(a.status)) throw new y(`Batch endpoint responded ${a.status}`);
|
|
365
|
-
let o;
|
|
366
|
-
try {
|
|
367
|
-
o = await a.json();
|
|
368
|
-
} catch {
|
|
369
|
-
throw new y("Batch endpoint returned a non-JSON body");
|
|
370
|
-
}
|
|
371
|
-
let s = n(o);
|
|
372
|
-
if (s?.code === "UNAUTHORIZED_ORIGIN" || s?.details?.reason === "UNAUTHORIZED_ORIGIN") throw Object.assign(Error(s.message || "UNAUTHORIZED_ORIGIN"), s, { code: "UNAUTHORIZED_ORIGIN" });
|
|
373
|
-
let c = o?.error && typeof o.error == "object" ? o.error : void 0;
|
|
374
|
-
if (c && Zt.includes(a.status)) throw new b(c.message || "Unauthorized request!");
|
|
375
|
-
if (a.status === 401 || a.status === 403) throw new b(`Batch endpoint responded ${a.status}`);
|
|
376
|
-
if (!a.ok) throw Error(o?.message || `Batch request failed with status ${a.status}`);
|
|
377
|
-
if (!Array.isArray(o?.results) && typeof o?.error != "string") throw new y("Batch endpoint response did not match the expected shape");
|
|
378
|
-
return o;
|
|
379
|
-
}, nn = null, rn = 50, an = 4, on = () => (nn ||= new Bt({
|
|
380
|
-
transport: tn,
|
|
381
|
-
coalesceWindowMs: 500,
|
|
382
|
-
visibleCoalesceWindowMs: rn,
|
|
383
|
-
coalesceIdleMs: Rt,
|
|
384
|
-
coalesceMaxWaitMs: zt,
|
|
385
|
-
coldHeadSize: an
|
|
386
|
-
}), nn), sn = async ({ payload: e, savedMetricQuery: t, dbName: n, savedMetricIdentifiers: r, clientId: i, key: a, hints: o, batchPolicy: s, session: c, single: l }) => {
|
|
387
|
-
t !== void 0 && Ee(t, "metric.query", n), _e(r);
|
|
388
|
-
let u = qe(e);
|
|
389
|
-
if (!Kt()) return l(u);
|
|
390
|
-
let d = $t(c);
|
|
391
|
-
if (!d || !Pt(u, o).eligible) return l(u);
|
|
392
|
-
let f = {
|
|
393
|
-
request: Ft(a, u, i, d, c?.token),
|
|
394
|
-
fallback: () => l(u),
|
|
395
|
-
batchPolicy: s,
|
|
396
|
-
session: c
|
|
397
|
-
};
|
|
398
|
-
return on().enqueue(f);
|
|
399
|
-
}, U = xt("standard"), cn = xt(void 0), W = 8, G = /* @__PURE__ */ new Map(), ln = /* @__PURE__ */ new Set(), un = (e, t) => {
|
|
400
|
-
if (!e || typeof t != "boolean") return;
|
|
401
|
-
let n = t ? "cached" : "live";
|
|
402
|
-
if (G.get(e) !== n) {
|
|
403
|
-
if (G.delete(e), G.size >= W) {
|
|
404
|
-
let e = G.keys().next().value;
|
|
405
|
-
e !== void 0 && G.delete(e);
|
|
406
|
-
}
|
|
407
|
-
G.set(e, n);
|
|
408
|
-
for (let e of ln) e();
|
|
409
|
-
}
|
|
410
|
-
}, dn = (e) => (ln.add(e), () => {
|
|
411
|
-
ln.delete(e);
|
|
412
|
-
}), fn = (e) => e ? G.get(e) : void 0, pn = 134217728, mn = /* @__PURE__ */ new WeakMap(), hn = (e, t = /* @__PURE__ */ new WeakSet()) => {
|
|
413
|
-
if (e == null) return 0;
|
|
414
|
-
if (typeof e == "string") return e.length * 2;
|
|
415
|
-
if (typeof e == "number" || typeof e == "bigint") return 8;
|
|
416
|
-
if (typeof e == "boolean") return 4;
|
|
417
|
-
if (typeof e != "object") return 0;
|
|
418
|
-
let n = e, r = mn.get(n);
|
|
419
|
-
if (r !== void 0) return r;
|
|
420
|
-
if (t.has(n)) return 0;
|
|
421
|
-
t.add(n);
|
|
422
|
-
let i = 32;
|
|
423
|
-
if (Array.isArray(e)) for (let n of e) i += 8 + hn(n, t);
|
|
424
|
-
else for (let [n, r] of Object.entries(e)) i += n.length * 2 + 8 + hn(r, t);
|
|
425
|
-
return mn.set(n, i), i;
|
|
426
|
-
}, gn = (e, { maxEntries: t = 128, maxBytes: n = pn } = {}) => {
|
|
427
|
-
let r = e.getQueryCache().findAll({
|
|
428
|
-
queryKey: [p],
|
|
429
|
-
type: "inactive"
|
|
430
|
-
}).map((e) => ({
|
|
431
|
-
query: e,
|
|
432
|
-
bytes: hn(e.state.data)
|
|
433
|
-
})).sort((e, t) => e.query.state.dataUpdatedAt - t.query.state.dataUpdatedAt), i = r.reduce((e, t) => e + t.bytes, 0);
|
|
434
|
-
for (; r.length > t || i > n && r.length > 1;) {
|
|
435
|
-
let t = r.shift();
|
|
436
|
-
if (!t) break;
|
|
437
|
-
i -= t.bytes, e.removeQueries({
|
|
438
|
-
queryKey: t.query.queryKey,
|
|
439
|
-
exact: !0,
|
|
440
|
-
type: "inactive"
|
|
441
|
-
});
|
|
442
|
-
}
|
|
443
|
-
}, _n = /* @__PURE__ */ new WeakSet(), vn = (e) => {
|
|
444
|
-
if (_n.has(e)) return;
|
|
445
|
-
_n.add(e);
|
|
446
|
-
let t = () => {
|
|
447
|
-
_n.delete(e), gn(e);
|
|
448
|
-
}, n = globalThis.scheduler;
|
|
449
|
-
if (typeof n?.postTask == "function") {
|
|
450
|
-
n.postTask(t, { priority: "background" });
|
|
451
|
-
return;
|
|
452
|
-
}
|
|
453
|
-
if (typeof requestIdleCallback == "function") {
|
|
454
|
-
requestIdleCallback(t, { timeout: 1e3 });
|
|
455
|
-
return;
|
|
456
|
-
}
|
|
457
|
-
setTimeout(t, 0);
|
|
458
|
-
}, K = /* @__PURE__ */ t(((e, t) => {
|
|
459
|
-
(function(n, r) {
|
|
460
|
-
typeof e == "object" ? t.exports = e = r(Te()) : typeof define == "function" && define.amd ? define(["./core"], r) : r(n.CryptoJS);
|
|
461
|
-
})(e, function(e) {
|
|
462
|
-
return e.enc.Hex;
|
|
463
|
-
});
|
|
464
|
-
})), yn = /* @__PURE__ */ t(((e, t) => {
|
|
465
|
-
(function(n, r) {
|
|
466
|
-
typeof e == "object" ? t.exports = e = r(Te()) : typeof define == "function" && define.amd ? define(["./core"], r) : r(n.CryptoJS);
|
|
467
|
-
})(e, function(e) {
|
|
468
|
-
return (function(t) {
|
|
469
|
-
var n = e, r = n.lib, i = r.WordArray, a = r.Hasher, o = n.algo, s = [], c = [];
|
|
470
|
-
(function() {
|
|
471
|
-
function e(e) {
|
|
472
|
-
for (var n = t.sqrt(e), r = 2; r <= n; r++) if (!(e % r)) return !1;
|
|
473
|
-
return !0;
|
|
474
|
-
}
|
|
475
|
-
function n(e) {
|
|
476
|
-
return (e - (e | 0)) * 4294967296 | 0;
|
|
477
|
-
}
|
|
478
|
-
for (var r = 2, i = 0; i < 64;) e(r) && (i < 8 && (s[i] = n(t.pow(r, 1 / 2))), c[i] = n(t.pow(r, 1 / 3)), i++), r++;
|
|
479
|
-
})();
|
|
480
|
-
var l = [], u = o.SHA256 = a.extend({
|
|
481
|
-
_doReset: function() {
|
|
482
|
-
this._hash = new i.init(s.slice(0));
|
|
483
|
-
},
|
|
484
|
-
_doProcessBlock: function(e, t) {
|
|
485
|
-
for (var n = this._hash.words, r = n[0], i = n[1], a = n[2], o = n[3], s = n[4], u = n[5], d = n[6], f = n[7], p = 0; p < 64; p++) {
|
|
486
|
-
if (p < 16) l[p] = e[t + p] | 0;
|
|
487
|
-
else {
|
|
488
|
-
var m = l[p - 15], h = (m << 25 | m >>> 7) ^ (m << 14 | m >>> 18) ^ m >>> 3, g = l[p - 2], _ = (g << 15 | g >>> 17) ^ (g << 13 | g >>> 19) ^ g >>> 10;
|
|
489
|
-
l[p] = h + l[p - 7] + _ + l[p - 16];
|
|
490
|
-
}
|
|
491
|
-
var v = s & u ^ ~s & d, y = r & i ^ r & a ^ i & a, b = (r << 30 | r >>> 2) ^ (r << 19 | r >>> 13) ^ (r << 10 | r >>> 22), x = (s << 26 | s >>> 6) ^ (s << 21 | s >>> 11) ^ (s << 7 | s >>> 25), S = f + x + v + c[p] + l[p], C = b + y;
|
|
492
|
-
f = d, d = u, u = s, s = o + S | 0, o = a, a = i, i = r, r = S + C | 0;
|
|
493
|
-
}
|
|
494
|
-
n[0] = n[0] + r | 0, n[1] = n[1] + i | 0, n[2] = n[2] + a | 0, n[3] = n[3] + o | 0, n[4] = n[4] + s | 0, n[5] = n[5] + u | 0, n[6] = n[6] + d | 0, n[7] = n[7] + f | 0;
|
|
495
|
-
},
|
|
496
|
-
_doFinalize: function() {
|
|
497
|
-
var e = this._data, n = e.words, r = this._nDataBytes * 8, i = e.sigBytes * 8;
|
|
498
|
-
return n[i >>> 5] |= 128 << 24 - i % 32, n[(i + 64 >>> 9 << 4) + 14] = t.floor(r / 4294967296), n[(i + 64 >>> 9 << 4) + 15] = r, e.sigBytes = n.length * 4, this._process(), this._hash;
|
|
499
|
-
},
|
|
500
|
-
clone: function() {
|
|
501
|
-
var e = a.clone.call(this);
|
|
502
|
-
return e._hash = this._hash.clone(), e;
|
|
503
|
-
}
|
|
504
|
-
});
|
|
505
|
-
n.SHA256 = a._createHelper(u), n.HmacSHA256 = a._createHmacHelper(u);
|
|
506
|
-
})(Math), e.SHA256;
|
|
507
|
-
});
|
|
508
|
-
})), bn = /* @__PURE__ */ t(((e, t) => {
|
|
509
|
-
(function(n, r, i) {
|
|
510
|
-
typeof e == "object" ? t.exports = e = r(Te(), yn(), Se()) : typeof define == "function" && define.amd ? define([
|
|
511
|
-
"./core",
|
|
512
|
-
"./sha256",
|
|
513
|
-
"./hmac"
|
|
514
|
-
], r) : r(n.CryptoJS);
|
|
515
|
-
})(e, function(e) {
|
|
516
|
-
return e.HmacSHA256;
|
|
517
|
-
});
|
|
518
|
-
})), xn = /* @__PURE__ */ e(K()), Sn = /* @__PURE__ */ e(yn()), Cn = /* @__PURE__ */ e(bn()), wn = (e) => {
|
|
519
|
-
let t = Object.getPrototypeOf(e);
|
|
520
|
-
return (t === Object.prototype || t === null) && !("toJSON" in e);
|
|
521
|
-
}, Tn = (e, t) => {
|
|
522
|
-
if (e === t) return !0;
|
|
523
|
-
if (e === null || t === null || typeof e != "object" || typeof t != "object") return !1;
|
|
524
|
-
if (Array.isArray(e)) {
|
|
525
|
-
if (!Array.isArray(t) || e.length !== t.length) return !1;
|
|
526
|
-
for (let n = 0; n < e.length; n += 1) if (!Tn(e[n], t[n])) return !1;
|
|
527
|
-
return !0;
|
|
528
|
-
}
|
|
529
|
-
if (Array.isArray(t) || !wn(e) || !wn(t)) return !1;
|
|
530
|
-
let n = Object.keys(e);
|
|
531
|
-
if (n.length !== Object.keys(t).length) return !1;
|
|
532
|
-
for (let r of n) if (!Object.hasOwn(t, r) || !Tn(e[r], t[r])) return !1;
|
|
533
|
-
return !0;
|
|
534
|
-
}, En = "dbn:metric-query:guest-principal:v1", Dn = 8, q = /* @__PURE__ */ new Map(), J = (e) => {
|
|
535
|
-
if (!e) return;
|
|
536
|
-
let t = q.get(e);
|
|
537
|
-
if (t !== void 0) return t;
|
|
538
|
-
let n = (0, Cn.default)(e, En).toString(xn.default);
|
|
539
|
-
if (q.size >= Dn) {
|
|
540
|
-
let e = q.keys().next().value;
|
|
541
|
-
e !== void 0 && q.delete(e);
|
|
542
|
-
}
|
|
543
|
-
return q.set(e, n), n;
|
|
544
|
-
}, On = "dbn:metric-query:client-scope:v1", kn = 16, An = /* @__PURE__ */ new Map(), Y = (e) => {
|
|
545
|
-
if (!e) return;
|
|
546
|
-
let t = An.get(e);
|
|
547
|
-
if (t !== void 0) return t;
|
|
548
|
-
let n = (0, Cn.default)(e, On).toString(xn.default);
|
|
549
|
-
if (An.size >= kn) {
|
|
550
|
-
let e = An.keys().next().value;
|
|
551
|
-
e !== void 0 && An.delete(e);
|
|
552
|
-
}
|
|
553
|
-
return An.set(e, n), n;
|
|
554
|
-
}, jn = [
|
|
555
|
-
"updatedAt",
|
|
556
|
-
"query",
|
|
557
|
-
"metricQuery",
|
|
558
|
-
"datasetMetricSettings",
|
|
559
|
-
"companyIntegrationId",
|
|
560
|
-
"limit",
|
|
561
|
-
"rlsConditions",
|
|
562
|
-
"dataSecuritySettings",
|
|
563
|
-
"isEnableGroupBy",
|
|
564
|
-
"groupBy",
|
|
565
|
-
"selectedGroupBy",
|
|
566
|
-
"timeGrain"
|
|
567
|
-
], Mn = /* @__PURE__ */ new WeakMap(), Nn = (e) => {
|
|
568
|
-
if (!e) return;
|
|
569
|
-
let t = Mn.get(e);
|
|
570
|
-
if (t !== void 0) return t;
|
|
571
|
-
let n = e, r = (0, Sn.default)(JSON.stringify(jn.map((e) => n[e] ?? null))).toString(xn.default).slice(0, 16);
|
|
572
|
-
return Mn.set(e, r), r;
|
|
573
|
-
}, Pn = (e, t, n) => {
|
|
574
|
-
if (!t) return e;
|
|
575
|
-
let r = Y(n);
|
|
576
|
-
return r ? { clientScope: r } : e;
|
|
577
|
-
}, Fn = ({ queryName: e, data: t, clientId: n, clientCacheScope: r, isFrontendApp: i, token: a, isFullScreen: o, metricRevision: s }) => [
|
|
578
|
-
e,
|
|
579
|
-
t,
|
|
580
|
-
Pn(n, i, r),
|
|
581
|
-
i,
|
|
582
|
-
a ? { guestPrincipal: J(a) } : void 0,
|
|
583
|
-
o,
|
|
584
|
-
s
|
|
585
|
-
], In = (e, t) => !e || !!t, Ln = /* @__PURE__ */ new WeakMap(), Rn = 512, X = /* @__PURE__ */ new Map(), zn = (e) => {
|
|
586
|
-
switch (typeof e) {
|
|
587
|
-
case "string": return JSON.stringify(e);
|
|
588
|
-
case "boolean": return e ? "true" : "false";
|
|
589
|
-
case "undefined": return "null";
|
|
590
|
-
default: return g([e]).slice(1, -1);
|
|
591
|
-
}
|
|
592
|
-
}, Bn = (e, t, n) => {
|
|
593
|
-
if (X.delete(e), X.size >= Rn) {
|
|
594
|
-
let e = X.keys().next().value;
|
|
595
|
-
e !== void 0 && X.delete(e);
|
|
596
|
-
}
|
|
597
|
-
X.set(e, {
|
|
598
|
-
payload: t,
|
|
599
|
-
hash: n
|
|
600
|
-
});
|
|
601
|
-
}, Vn = (e) => {
|
|
602
|
-
if (typeof e != "object" || !e) return zn(e);
|
|
603
|
-
let t = Ln.get(e);
|
|
604
|
-
if (t !== void 0) return t;
|
|
605
|
-
let n = e.id, r = typeof n == "string" ? X.get(n) : void 0, i = r && Tn(r.payload, e) ? r.hash : zn(e);
|
|
606
|
-
return Ln.set(e, i), typeof n == "string" && Bn(n, e, i), i;
|
|
607
|
-
}, Hn = (e) => `[${e.map((e, t) => t === 1 ? Vn(e) : zn(e)).join(",")}]`, Un = ({ queryName: e, workspaceId: t, guestToken: n, isFrontendApp: r, encryptedClientId: i }) => [
|
|
608
|
-
e,
|
|
609
|
-
t,
|
|
610
|
-
{
|
|
611
|
-
guestPrincipal: J(n),
|
|
612
|
-
isFrontendApp: r,
|
|
613
|
-
encryptedClientId: i
|
|
614
|
-
}
|
|
615
|
-
], Wn = ({ clientId: e, clientCacheScope: t, metricRevision: n, data: i, token: a, isFrontendApp: o, isFullScreen: c = "", batchHints: l, savedMetricQuery: u, savedMetricIdentifiers: d, dbName: f, timeoutMs: h = Lt }, g) => {
|
|
616
|
-
let y = v(), b = St(U), x = St(cn), S = J(a), C = I(() => fn(S), [S]), w = wt(dn, C, C), ee = (x ?? w) === "live", te = !!i.id && !g?.isDisableQuery && (!o || !!e), T = Fn({
|
|
617
|
-
queryName: p,
|
|
618
|
-
data: i,
|
|
619
|
-
clientId: e,
|
|
620
|
-
clientCacheScope: t,
|
|
621
|
-
isFrontendApp: o,
|
|
622
|
-
token: a,
|
|
623
|
-
isFullScreen: c,
|
|
624
|
-
metricRevision: n
|
|
625
|
-
});
|
|
626
|
-
L(() => {
|
|
627
|
-
O() && m("metric-query-enabled-state", {
|
|
628
|
-
isQueryEnabled: te,
|
|
629
|
-
hasMetricId: !!i.id,
|
|
630
|
-
isDisableQuery: !!g?.isDisableQuery,
|
|
631
|
-
isFrontendApp: o,
|
|
632
|
-
hasClientId: !!e,
|
|
633
|
-
hasToken: !!a,
|
|
634
|
-
isFullScreen: c,
|
|
635
|
-
payload: ne(i)
|
|
636
|
-
});
|
|
637
|
-
}, [
|
|
638
|
-
te,
|
|
639
|
-
i,
|
|
640
|
-
g?.isDisableQuery,
|
|
641
|
-
o,
|
|
642
|
-
e,
|
|
643
|
-
a,
|
|
644
|
-
c
|
|
645
|
-
]);
|
|
646
|
-
let D = (t) => {
|
|
647
|
-
let n = t || i;
|
|
648
|
-
return O() && m("metric-query-fetch-start", {
|
|
649
|
-
path: s,
|
|
650
|
-
clientId: e,
|
|
651
|
-
isFrontendApp: o,
|
|
652
|
-
hasToken: !!a,
|
|
653
|
-
isFullScreen: c,
|
|
654
|
-
payload: ne(n)
|
|
655
|
-
}), E(s, {
|
|
656
|
-
method: "POST",
|
|
657
|
-
data: {
|
|
658
|
-
...n || {},
|
|
659
|
-
...!o && a ? {
|
|
660
|
-
...Array.isArray(n?.rlsConditions) && n.rlsConditions.length ? { rlsConditions: j(n.rlsConditions, a) } : { rlsConditions: [] },
|
|
661
|
-
...typeof n?.globalFilters == "object" && n.globalFilters !== null && "filters" in n.globalFilters && Array.isArray(n.globalFilters.filters) && n.globalFilters.filters.length ? { globalFilters: j(n.globalFilters, a) } : { globalFilters: {
|
|
662
|
-
tableName: "",
|
|
663
|
-
filters: []
|
|
664
|
-
} }
|
|
665
|
-
} : {}
|
|
666
|
-
},
|
|
667
|
-
isFrontend: o,
|
|
668
|
-
clientId: e,
|
|
669
|
-
token: a,
|
|
670
|
-
timeoutMs: h
|
|
671
|
-
});
|
|
672
|
-
}, k = et({
|
|
673
|
-
queryKey: T,
|
|
674
|
-
queryKeyHashFn: Hn,
|
|
675
|
-
queryFn: () => (O() && m("metric-query-dispatch", {
|
|
676
|
-
metricId: i?.id,
|
|
677
|
-
payload: ne(i)
|
|
678
|
-
}), sn({
|
|
679
|
-
batchPolicy: b,
|
|
680
|
-
payload: i,
|
|
681
|
-
savedMetricQuery: u,
|
|
682
|
-
savedMetricIdentifiers: d,
|
|
683
|
-
dbName: f,
|
|
684
|
-
clientId: e,
|
|
685
|
-
key: `${i?.id || "metric"}::${JSON.stringify(i)}::${e || ""}`,
|
|
686
|
-
hints: {
|
|
687
|
-
...l || {},
|
|
688
|
-
isGuestTokenSession: !o && !!a
|
|
689
|
-
},
|
|
690
|
-
session: {
|
|
691
|
-
token: a,
|
|
692
|
-
isFrontendApp: o,
|
|
693
|
-
clientId: e
|
|
694
|
-
},
|
|
695
|
-
single: D
|
|
696
|
-
})),
|
|
697
|
-
enabled: te,
|
|
698
|
-
meta: a || ee || !In(o, t) ? { persist: !1 } : void 0,
|
|
699
|
-
retry: (e, t) => r(t).code !== "UNAUTHORIZED_ORIGIN" && !_(t) && e < 2,
|
|
700
|
-
staleTime: ee ? 3e4 : 3e5,
|
|
701
|
-
gcTime: 9e5
|
|
702
|
-
}), re = Hn(T), A = R(() => ({
|
|
703
|
-
queryHash: re,
|
|
704
|
-
dataUpdatedAt: k.dataUpdatedAt,
|
|
705
|
-
errorUpdatedAt: k.errorUpdatedAt,
|
|
706
|
-
fetchStatus: k.fetchStatus,
|
|
707
|
-
isSuccess: k.isSuccess,
|
|
708
|
-
isError: k.isError,
|
|
709
|
-
data: k.data,
|
|
710
|
-
error: k.error
|
|
711
|
-
}), [
|
|
712
|
-
re,
|
|
713
|
-
k.dataUpdatedAt,
|
|
714
|
-
k.errorUpdatedAt,
|
|
715
|
-
k.fetchStatus,
|
|
716
|
-
k.isSuccess,
|
|
717
|
-
k.isError,
|
|
718
|
-
k.data,
|
|
719
|
-
k.error
|
|
720
|
-
]), ie = z(i);
|
|
721
|
-
ie.current = i;
|
|
722
|
-
let ae = z(g);
|
|
723
|
-
return ae.current = g, L(() => {
|
|
724
|
-
if (!A.isSuccess || A.fetchStatus !== "idle") return;
|
|
725
|
-
let e = A.data;
|
|
726
|
-
O() && m("metric-query-success", {
|
|
727
|
-
payload: ne(ie.current),
|
|
728
|
-
responseDataType: typeof e?.data,
|
|
729
|
-
responseRowCount: Array.isArray(e?.data) ? e?.data?.length : void 0,
|
|
730
|
-
totalRecords: e?.totalRecords
|
|
731
|
-
}), un(S, e?.cacheEnabled), ae.current?.onSuccess?.(e), vn(y);
|
|
732
|
-
}, [
|
|
733
|
-
A,
|
|
734
|
-
S,
|
|
735
|
-
y
|
|
736
|
-
]), L(() => () => vn(y), [y]), L(() => {
|
|
737
|
-
if (A.fetchStatus !== "idle" || !A.isSuccess && !A.isError) return;
|
|
738
|
-
let e = A.data, t = A.error;
|
|
739
|
-
O() && m("metric-query-settled", {
|
|
740
|
-
payload: ne(ie.current),
|
|
741
|
-
hasError: !!t,
|
|
742
|
-
errorMessage: t instanceof Error ? t.message : t?.message,
|
|
743
|
-
responseDataType: typeof e?.data,
|
|
744
|
-
responseRowCount: Array.isArray(e?.data) ? e?.data?.length : void 0
|
|
745
|
-
}), ae.current?.onSettled?.(e, t);
|
|
746
|
-
}, [A]), k;
|
|
747
|
-
}, Gn = async ({ workspaceId: e, token: t, isFrontend: n, encryptedClientId: r }) => (n && await u(), E(`${i}?id=${e}`, {
|
|
748
|
-
method: "GET",
|
|
749
|
-
token: n ? "" : t || "",
|
|
750
|
-
isFrontend: n,
|
|
751
|
-
clientId: r
|
|
752
|
-
})), Kn = (e, t, n, r) => {
|
|
753
|
-
let { token: i } = k(), a = n ? "" : t || i || "";
|
|
754
|
-
return et({
|
|
755
|
-
queryKey: Un({
|
|
756
|
-
queryName: o,
|
|
757
|
-
workspaceId: e,
|
|
758
|
-
guestToken: a,
|
|
759
|
-
isFrontendApp: !!n,
|
|
760
|
-
encryptedClientId: r
|
|
761
|
-
}),
|
|
762
|
-
meta: { persist: !1 },
|
|
763
|
-
queryFn: () => Gn({
|
|
764
|
-
workspaceId: e,
|
|
765
|
-
token: a,
|
|
766
|
-
isFrontend: n,
|
|
767
|
-
encryptedClientId: r
|
|
768
|
-
}),
|
|
769
|
-
enabled: !!e
|
|
770
|
-
});
|
|
771
|
-
}, qn = ({ language: e, translationDictionary: t }) => !e || !t ? !1 : Object.values(t).some((t) => !!t?.[e]), Jn = ({ language: e, translationDictionary: t }) => !qn({
|
|
772
|
-
language: e,
|
|
773
|
-
translationDictionary: t
|
|
774
|
-
}), Yn = ({ language: e, tableLimit: t, translationDictionary: n }) => Jn({
|
|
775
|
-
language: e,
|
|
776
|
-
translationDictionary: n
|
|
777
|
-
}) ? {
|
|
778
|
-
limit: String(t.limit),
|
|
779
|
-
offset: String(t.offset)
|
|
780
|
-
} : {}, Z = ({ language: e, search: t, searchColumns: n, translationDictionary: r }) => {
|
|
781
|
-
if (!Jn({
|
|
782
|
-
language: e,
|
|
783
|
-
translationDictionary: r
|
|
784
|
-
})) return {};
|
|
785
|
-
let i = t?.trim(), a = !!n?.length;
|
|
786
|
-
return {
|
|
787
|
-
search: i && a ? i : void 0,
|
|
788
|
-
searchColumns: i && a ? n : void 0
|
|
789
|
-
};
|
|
790
|
-
}, Xn = ({ currentSearchValue: e, nextValue: t, shouldUseServerSideSearch: n, tableLimit: r }) => {
|
|
791
|
-
let i = String(t).trim() !== (e || "").trim(), a = r.offset !== 0;
|
|
792
|
-
return {
|
|
793
|
-
shouldResetPageOffset: a,
|
|
794
|
-
shouldSetTablePending: a || n && i
|
|
795
|
-
};
|
|
796
|
-
}, Zn = ({ isPythonMode: e, search: t, shouldUseServerSideSearch: n }) => e ? !0 : !n, Qn = ({ columnName: e, disableDownloadUnderlyingDataNoFilters: t, isLoading: n, isSingleValueChart: r }) => !n && !t && !!(e || r), $n = ({ isPrev: e, nextOffset: t, prev: n, resetValue: r }) => r === void 0 ? t === void 0 ? {
|
|
797
|
-
limit: n.limit,
|
|
798
|
-
offset: e ? Math.max(n.offset - n.limit, 0) : n.offset + n.limit
|
|
799
|
-
} : {
|
|
800
|
-
limit: n.limit,
|
|
801
|
-
offset: Math.max(t, 0)
|
|
802
|
-
} : {
|
|
803
|
-
limit: r,
|
|
804
|
-
offset: 0
|
|
805
|
-
}, er = (e) => e == null ? e : le(e.toString()), tr = (e, t) => [...e ?? [], ...t ?? []].some((e) => !!e?.columnName && e.value !== void 0), nr = (e = []) => e.filter((e) => e?.columnName && e.value !== void 0), rr = ({ columnName: e, dataType: t, drillFilters: n = [], expressionSql: r, isSingleValueChart: i, value: a }) => {
|
|
806
|
-
let o = nr(n);
|
|
807
|
-
return i || !e || a === void 0 ? o : [...o.filter((t) => t.columnName !== e || String(t.value) !== String(a)), {
|
|
808
|
-
columnName: e,
|
|
809
|
-
dataType: t,
|
|
810
|
-
expressionSql: r,
|
|
811
|
-
value: a
|
|
812
|
-
}];
|
|
813
|
-
}, ir = ({ columnName: e, dataType: t, drillFilters: n = [], expressionSql: r, isSingleValueChart: i, value: a }) => rr({
|
|
814
|
-
columnName: e,
|
|
815
|
-
dataType: t,
|
|
816
|
-
drillFilters: n,
|
|
817
|
-
expressionSql: r,
|
|
818
|
-
isSingleValueChart: i,
|
|
819
|
-
value: a
|
|
820
|
-
}).map((e) => ({
|
|
821
|
-
columnName: e.columnName,
|
|
822
|
-
dataType: e.dataType,
|
|
823
|
-
expressionSql: e.expressionSql,
|
|
824
|
-
value: er(e.value)
|
|
825
|
-
})), ar = ({ columnName: e, dataType: t, drillFilters: n = [], expressionSql: r, isSingleValueChart: i, value: a }) => rr({
|
|
826
|
-
columnName: e,
|
|
827
|
-
dataType: t,
|
|
828
|
-
drillFilters: n,
|
|
829
|
-
expressionSql: r,
|
|
830
|
-
isSingleValueChart: i,
|
|
831
|
-
value: a
|
|
832
|
-
}), or = ({ query: e, limit: t, offset: n, dbName: r }) => {
|
|
833
|
-
let i = Ie === r?.toLowerCase(), a = [Xe, Me].includes(r?.toLowerCase() || ""), o = fe === r?.toLowerCase(), s = (e) => n ? `OFFSET ${n} LIMIT ${e}` : `LIMIT ${e}`, c = Mt(e), l = (c?.toLowerCase() ?? "").includes("order"), u = parseInt(t, 10);
|
|
834
|
-
if (c?.toLowerCase().includes("limit")) {
|
|
835
|
-
let e = parseInt(c?.toLowerCase().split("limit")?.[1]?.trim() ?? "0", 10), r = n ? t : Math.min(e, u);
|
|
836
|
-
o ? (c = c.replace(`limit ${e}`, s(r)), c = c.replace(`LIMIT ${e}`, s(r))) : a || i ? (c = c.replace(`limit ${e}`, `${l || i || o ? "" : "order by(select null)"} ${`offset ${n || 0} rows`} fetch next ${r} rows only`), c = c.replace(`LIMIT ${e}`, `${l || i || o ? "" : " ORDER BY(SELECT NULL) "} OFFSET ${n || 0} ROWS FETCH NEXT ${r} ROWS ONLY`)) : (c = c.replace(`limit ${e}`, `limit ${r} ${n ? `OFFSET ${n}` : ""}`), c = c.replace(`LIMIT ${e}`, `LIMIT ${r} ${n ? `OFFSET ${n}` : ""}`));
|
|
837
|
-
} else c?.toLowerCase().includes("fetch") || c?.toLowerCase().includes("limit") || (r?.toLowerCase() === "mssql" || r?.toLowerCase() === "athena" || r?.toLowerCase() === "microsoft fabric" ? c += ` ${l || i || o ? "" : " ORDER BY(SELECT NULL) "} ${`offset ${n || 0} rows`} fetch next ${u} rows only` : c += o ? ` ${s(u)}` : ` limit ${u} ${n ? `OFFSET ${n}` : ""}`);
|
|
838
|
-
return c;
|
|
839
|
-
}, Q = (e) => {
|
|
840
|
-
try {
|
|
841
|
-
return JSON.stringify(e);
|
|
842
|
-
} catch {
|
|
843
|
-
return String(Date.now()) + ":" + Math.random().toString(36).slice(2);
|
|
844
|
-
}
|
|
845
|
-
}, sr = (e, t) => {
|
|
846
|
-
if (t?.error && !(Array.isArray(t?.data) && t.data.length)) {
|
|
847
|
-
cr(e, t.error);
|
|
848
|
-
return;
|
|
849
|
-
}
|
|
850
|
-
let n = t?.data, r = typeof t?.totalRecords == "number" ? t.totalRecords : 0, i = n && Array.isArray(n) && n.length ? n : [];
|
|
851
|
-
e.forEach((e) => {
|
|
852
|
-
e.setTotalRecords?.(r), e.setData(i), e.setLoading(!1);
|
|
853
|
-
});
|
|
854
|
-
};
|
|
855
|
-
function cr(e, t) {
|
|
856
|
-
e.forEach((e) => {
|
|
857
|
-
e.onError?.(t), e.setData([]), e.setLoading(!1), e.setTotalRecords?.(0);
|
|
858
|
-
});
|
|
859
|
-
}
|
|
860
|
-
var lr = ({ datasourceId: e, clientName: t, dbName: n, tenancyType: r, values: i, query: a, companyId: o, workspaceId: s, metricId: c, dashboardId: l, token: u, isFrontendApp: d, encryptedClientId: f, globalFilters: p, isAllClient: m, rlsConditions: h, dataMartRelationships: g, customSql: _, isEnableCustomSQL: v, drillFilters: y }) => {
|
|
861
|
-
let { mutateAsync: b } = T(), { data: x } = Kn(s, void 0, d, f), S = x?.weekStartDay === "sunday" ? "sunday" : "monday", C = z(/* @__PURE__ */ new Map()), w = z({
|
|
862
|
-
token: u,
|
|
863
|
-
epoch: 0
|
|
864
|
-
});
|
|
865
|
-
w.current.token !== u && (w.current = {
|
|
866
|
-
token: u,
|
|
867
|
-
epoch: w.current.epoch + 1
|
|
868
|
-
});
|
|
869
|
-
let ee = w.current.epoch;
|
|
870
|
-
return L(() => {
|
|
871
|
-
let e = C.current;
|
|
872
|
-
return () => {
|
|
873
|
-
e.clear();
|
|
874
|
-
};
|
|
875
|
-
}, []), { getUnderlyingData: I(({ columnName: x, dataType: w, expressionSql: te, value: T, setData: ne, setLoading: E, isSingleValueChart: D, clientColumnType: O, limit: k, offset: re, search: A, searchColumns: ie, setTotalRecords: ae, pointFilters: oe, onError: se, withoutFilters: ce }) => {
|
|
876
|
-
let le = r === "MULTI_DATABASE" && t || "", ue = v && _ ? _ : k !== void 0 || re !== void 0 ? a : or({
|
|
877
|
-
query: a,
|
|
878
|
-
limit: "5000",
|
|
879
|
-
dbName: n
|
|
880
|
-
}), de = ce ? {
|
|
881
|
-
...p,
|
|
882
|
-
filters: p.filters.filter((e) => e.isVariableFilter)
|
|
883
|
-
} : p, j = h, fe = ge({
|
|
884
|
-
clientColumnType: O,
|
|
885
|
-
query: ue || "",
|
|
886
|
-
dbName: n,
|
|
887
|
-
rlsConditions: j,
|
|
888
|
-
tenancyLevel: r || "TABLE",
|
|
889
|
-
clientId: t,
|
|
890
|
-
globalFilters: de,
|
|
891
|
-
values: i,
|
|
892
|
-
isAllClient: m,
|
|
893
|
-
dataMartRelationships: g,
|
|
894
|
-
weekStartDay: S
|
|
895
|
-
}), pe = D && !v ? vt(fe) : fe, me = tr(y, oe) ? ir({
|
|
896
|
-
columnName: x,
|
|
897
|
-
dataType: w,
|
|
898
|
-
drillFilters: oe?.length ? [...y ?? [], ...oe] : y,
|
|
899
|
-
expressionSql: te,
|
|
900
|
-
isSingleValueChart: D,
|
|
901
|
-
value: T
|
|
902
|
-
}) : [], M = {
|
|
903
|
-
columnName: D ? void 0 : x,
|
|
904
|
-
companyId: o,
|
|
905
|
-
query: P(pe, o),
|
|
906
|
-
dataType: D ? void 0 : w,
|
|
907
|
-
expressionSql: D ? void 0 : te,
|
|
908
|
-
value: D ? void 0 : er(T),
|
|
909
|
-
drillFilters: me.length ? me : void 0,
|
|
910
|
-
workspaceId: s,
|
|
911
|
-
metricId: c,
|
|
912
|
-
dashboardId: l,
|
|
913
|
-
isCustomSql: v && !!_,
|
|
914
|
-
databaseName: le,
|
|
915
|
-
datasourceId: e,
|
|
916
|
-
limit: k,
|
|
917
|
-
offset: re,
|
|
918
|
-
search: A,
|
|
919
|
-
searchColumns: ie,
|
|
920
|
-
globalFilters: de,
|
|
921
|
-
rlsConditions: j,
|
|
922
|
-
filterValues: i,
|
|
923
|
-
isSingleValueChart: D && !v
|
|
924
|
-
};
|
|
925
|
-
ne([]), E(!0);
|
|
926
|
-
let he = Q({
|
|
927
|
-
columnName: M.columnName,
|
|
928
|
-
value: M.value,
|
|
929
|
-
dataType: M.dataType,
|
|
930
|
-
expressionSql: M.expressionSql,
|
|
931
|
-
drillFilters: M.drillFilters,
|
|
932
|
-
limit: M.limit,
|
|
933
|
-
offset: M.offset,
|
|
934
|
-
search: M.search,
|
|
935
|
-
searchColumns: M.searchColumns,
|
|
936
|
-
finalQuery: pe,
|
|
937
|
-
companyId: M.companyId,
|
|
938
|
-
workspaceId: M.workspaceId,
|
|
939
|
-
metricId: M.metricId,
|
|
940
|
-
dashboardId: M.dashboardId,
|
|
941
|
-
datasourceId: M.datasourceId,
|
|
942
|
-
databaseName: M.databaseName,
|
|
943
|
-
isCustomSql: M.isCustomSql,
|
|
944
|
-
isSingleValueChart: D,
|
|
945
|
-
principal: `${+!!d}|${f || ""}|${ee}`
|
|
946
|
-
}), _e = {
|
|
947
|
-
setData: ne,
|
|
948
|
-
setLoading: E,
|
|
949
|
-
setTotalRecords: ae,
|
|
950
|
-
onError: se
|
|
951
|
-
}, ve = C.current.get(he);
|
|
952
|
-
if (ve) {
|
|
953
|
-
ve.subscribers.add(_e);
|
|
954
|
-
return;
|
|
955
|
-
}
|
|
956
|
-
let ye = /* @__PURE__ */ new Set([_e]);
|
|
957
|
-
C.current.set(he, { subscribers: ye }), b({
|
|
958
|
-
data: M,
|
|
959
|
-
token: u || "",
|
|
960
|
-
isFrontendApp: d,
|
|
961
|
-
encryptedClientId: d && f || ""
|
|
962
|
-
}).then((e) => {
|
|
963
|
-
let t = C.current.get(he);
|
|
964
|
-
C.current.delete(he), sr(t?.subscribers ?? ye, e);
|
|
965
|
-
}).catch((e) => {
|
|
966
|
-
let t = C.current.get(he);
|
|
967
|
-
C.current.delete(he), cr(t?.subscribers ?? ye, e);
|
|
968
|
-
});
|
|
969
|
-
}, [
|
|
970
|
-
t,
|
|
971
|
-
o,
|
|
972
|
-
_,
|
|
973
|
-
g,
|
|
974
|
-
e,
|
|
975
|
-
n,
|
|
976
|
-
y,
|
|
977
|
-
p,
|
|
978
|
-
m,
|
|
979
|
-
v,
|
|
980
|
-
c,
|
|
981
|
-
l,
|
|
982
|
-
u,
|
|
983
|
-
d,
|
|
984
|
-
f,
|
|
985
|
-
ee,
|
|
986
|
-
a,
|
|
987
|
-
h,
|
|
988
|
-
r,
|
|
989
|
-
b,
|
|
990
|
-
i,
|
|
991
|
-
S,
|
|
992
|
-
s
|
|
993
|
-
]) };
|
|
994
|
-
}, ur = new Set([
|
|
995
|
-
"bar",
|
|
996
|
-
"row",
|
|
997
|
-
"stack",
|
|
998
|
-
"horizontal stack",
|
|
999
|
-
"line",
|
|
1000
|
-
"area",
|
|
1001
|
-
"stacked area",
|
|
1002
|
-
"stepped",
|
|
1003
|
-
"combo",
|
|
1004
|
-
"pie",
|
|
1005
|
-
"doughnut",
|
|
1006
|
-
"rose",
|
|
1007
|
-
"table"
|
|
1008
|
-
].map((e) => be(e))), dr = /\border\s+by\b/i, fr = /\bunion\b/i, pr = (e) => {
|
|
1009
|
-
let t = 0, n = null, r = "";
|
|
1010
|
-
for (let i of e) n ? (i === n && (n = null), r += " ") : i === "'" || i === "\"" || i === "`" ? (n = i, r += t ? " " : i) : (i === "(" && (t += 1), r += t ? " " : i, i === ")" && (t = Math.max(0, t - 1)));
|
|
1011
|
-
return r;
|
|
1012
|
-
}, mr = /^(?:(?:"[^"]*"|`[^`]*`|\[[^\]]*\]|[\w$]+)\.)*(?:"([^"]+)"|`([^`]+)`|\[([^\]]+)\]|([\w$]+))$/, hr = /\s+(asc|desc)?\s*(nulls\s+(first|last))?\s*$/i, gr = (e) => {
|
|
1013
|
-
let t = pr(e), n = [...t.matchAll(/\border\s+by\b/gi)], r = n[n.length - 1];
|
|
1014
|
-
if (r?.index === void 0) return null;
|
|
1015
|
-
let i = r.index + r[0].length, a = t.slice(i).search(/\b(limit|offset|fetch)\b|;/i), o = a < 0 ? e.length : i + a, s = [], c = i;
|
|
1016
|
-
for (let n = i; n <= o; n += 1) {
|
|
1017
|
-
if (n < o && t[n] !== ",") continue;
|
|
1018
|
-
let r = e.slice(c, n).replace(hr, "").trim();
|
|
1019
|
-
if (c = n + 1, /^\d+$/.test(r)) {
|
|
1020
|
-
s.push(Number(r));
|
|
1021
|
-
continue;
|
|
1022
|
-
}
|
|
1023
|
-
let i = mr.exec(r);
|
|
1024
|
-
if (!i) return null;
|
|
1025
|
-
s.push(i[1] ?? i[2] ?? i[3] ?? i[4]);
|
|
1026
|
-
}
|
|
1027
|
-
return s.length ? s : null;
|
|
1028
|
-
}, _r = ({ query: e, chartType: t, isDrilled: n, isPythonMode: r }) => {
|
|
1029
|
-
if (n || r || typeof e != "string" || !e.trim() || fr.test(e) || !ur.has(be(t)) || !dr.test(e)) return null;
|
|
1030
|
-
let i = gr(e);
|
|
1031
|
-
return i ? { orderBy: i } : null;
|
|
1032
|
-
}, vr = (e) => e == null || e === "", yr = (e, t) => {
|
|
1033
|
-
let n = vr(e), r = vr(t);
|
|
1034
|
-
return n || r ? n === r ? 0 : n ? 1 : -1 : nt(typeof e == "number" ? e : String(e), typeof t == "number" ? t : String(t));
|
|
1035
|
-
}, br = (e, t) => typeof e == "number" ? t[e - 1] : t.find((t) => t.toLowerCase() === e.toLowerCase());
|
|
1036
|
-
function xr(e, t = { orderBy: [] }) {
|
|
1037
|
-
if (!Array.isArray(e) || e.length < 2) return e;
|
|
1038
|
-
let n = Object.keys(e[0] ?? {});
|
|
1039
|
-
if (!n.length) return e;
|
|
1040
|
-
let r = t.orderBy.map((e) => br(e, n));
|
|
1041
|
-
if (r.some((e) => e === void 0)) return e;
|
|
1042
|
-
let i = (t, r) => {
|
|
1043
|
-
for (let i of n) {
|
|
1044
|
-
let n = yr(e[t]?.[i], e[r]?.[i]);
|
|
1045
|
-
if (n !== 0) return n;
|
|
1046
|
-
}
|
|
1047
|
-
return t - r;
|
|
1048
|
-
}, a = (t, n) => r.every((r) => yr(e[t]?.[r], e[n]?.[r]) === 0), o = [];
|
|
1049
|
-
for (let t = 0; t < e.length;) {
|
|
1050
|
-
let n = t + 1;
|
|
1051
|
-
for (; n < e.length && a(t, n);) n += 1;
|
|
1052
|
-
let r = [];
|
|
1053
|
-
for (let e = t; e < n; e += 1) r.push(e);
|
|
1054
|
-
o.push(...r.sort(i)), t = n;
|
|
1055
|
-
}
|
|
1056
|
-
return o.every((e, t) => e === t) ? e : o.map((t) => e[t]);
|
|
1057
|
-
}
|
|
1058
|
-
//#endregion
|
|
1059
|
-
//#region src/components/Chart/metricCardResult.ts
|
|
1060
|
-
var Sr = { rows: [] }, Cr = {
|
|
1061
|
-
rows: [],
|
|
1062
|
-
error: {
|
|
1063
|
-
code: "INVALID_METRIC_RESULT",
|
|
1064
|
-
message: "Could not load chart data.",
|
|
1065
|
-
hint: "Retry the chart. If it still fails, contact your workspace admin."
|
|
1066
|
-
}
|
|
1067
|
-
}, wr = (e) => typeof e == "object" && !!e && !Array.isArray(e), Tr = (e) => {
|
|
1068
|
-
if (e == null) return Sr;
|
|
1069
|
-
if (!wr(e)) return Cr;
|
|
1070
|
-
let t = e.errorDetail ? n(e) ?? e.error : e.error, r = e.data;
|
|
1071
|
-
if (typeof r == "string") try {
|
|
1072
|
-
r = JSON.parse(r);
|
|
1073
|
-
} catch {
|
|
1074
|
-
return t ? {
|
|
1075
|
-
rows: [],
|
|
1076
|
-
error: t
|
|
1077
|
-
} : Cr;
|
|
1078
|
-
}
|
|
1079
|
-
if (wr(r) && (r.error || r.errorDetail)) return {
|
|
1080
|
-
rows: [],
|
|
1081
|
-
error: r.errorDetail ? n(r) ?? r.error : r.error
|
|
1082
|
-
};
|
|
1083
|
-
if (t) return {
|
|
1084
|
-
rows: [],
|
|
1085
|
-
error: t
|
|
1086
|
-
};
|
|
1087
|
-
if (wr(r) && typeof r.code == "string" && typeof r.message == "string") return {
|
|
1088
|
-
rows: [],
|
|
1089
|
-
error: {
|
|
1090
|
-
code: r.code,
|
|
1091
|
-
message: r.message
|
|
1092
|
-
}
|
|
1093
|
-
};
|
|
1094
|
-
if (!Array.isArray(r) || !r.every(wr)) return Cr;
|
|
1095
|
-
let i = Array.isArray(e.notices) && e.notices.some((e) => wr(e) && e.code === "FILTER_NOT_APPLIED");
|
|
1096
|
-
return {
|
|
1097
|
-
rows: r,
|
|
1098
|
-
...i ? { isFilterNotApplied: !0 } : {}
|
|
1099
|
-
};
|
|
1100
|
-
}, Er = (e) => typeof e == "object" && !!e && "configType" in e && e.configType === "AGGREGATE", Dr = Symbol("cross-filter-source-metric"), Or = (e, t) => (t && Object.defineProperty(e, Dr, { value: t }), e);
|
|
1101
|
-
function kr({ filters: e, metricId: t, isGroupByEnabled: n, enableCrossFilterBeforeDrill: r = !1 }) {
|
|
1102
|
-
return r ? (e || []).filter((e) => {
|
|
1103
|
-
let r = e[Dr];
|
|
1104
|
-
return r ? r !== t : !n;
|
|
1105
|
-
}) : n ? [] : e || [];
|
|
1106
|
-
}
|
|
1107
|
-
function Ar(e, t, n) {
|
|
1108
|
-
return t === "DATABASE" ? `${n}.${e?.split(".").slice(1).join(".")}` : e;
|
|
1109
|
-
}
|
|
1110
|
-
var jr = (e) => {
|
|
1111
|
-
let t = e?.table?.schemaName, n = e?.table?.tableName;
|
|
1112
|
-
if (t && n) return `${t}.${n}`;
|
|
1113
|
-
}, Mr = (e) => typeof e == "string" && !!e.trim(), Nr = (e, t) => t?.find((t) => t?.alias === e || t?.name === e), Pr = ({ columnName: e, selectedDims: t }) => {
|
|
1114
|
-
if (!Mr(e)) return;
|
|
1115
|
-
if (!t?.length) return e;
|
|
1116
|
-
let n = Nr(e, t);
|
|
1117
|
-
if (n && jr(n)) return Mr(n.name) ? n.name : e;
|
|
1118
|
-
}, Fr = "This filter column is no longer available. Refresh the metric and select a column before filtering.", Ir = ({ columnName: e, rowFilters: t, selectedDims: n, requiresSchemaMetadata: r = !1 }) => {
|
|
1119
|
-
let i = t?.length ? t.map((e) => e.columnName) : e === void 0 ? [] : [e];
|
|
1120
|
-
return i.some((e) => !Mr(e)) || (t?.length || r) && !n?.length || i.some((e) => !!n?.length && !Pr({
|
|
1121
|
-
columnName: e,
|
|
1122
|
-
selectedDims: n
|
|
1123
|
-
})) ? Fr : void 0;
|
|
1124
|
-
};
|
|
1125
|
-
function Lr(e) {
|
|
1126
|
-
let t = e.value === null || e.value === void 0, n = t ? "null" : e.value;
|
|
1127
|
-
return Or({
|
|
1128
|
-
columnName: e.columnName,
|
|
1129
|
-
datatype: "string",
|
|
1130
|
-
isAddOnMetrics: !0,
|
|
1131
|
-
name: "cross-filter",
|
|
1132
|
-
options: [n],
|
|
1133
|
-
tableName: Ar(e.tableName, e.tenancyLevel, e.clientId),
|
|
1134
|
-
value: [n],
|
|
1135
|
-
...t ? { filterVariant: {
|
|
1136
|
-
label: "IN",
|
|
1137
|
-
value: "IN"
|
|
1138
|
-
} } : {}
|
|
1139
|
-
}, e.sourceMetricId);
|
|
1140
|
-
}
|
|
1141
|
-
function Rr({ existing: e, isReset: t, levelIndex: n, hasCurrentLevel: r, filterValue: i, columnName: a, rowFilters: o, selectedDims: s, activeLevelTableName: c, tenancyLevel: l, clientId: u, sourceMetricId: d }) {
|
|
1142
|
-
if (t || n) return [];
|
|
1143
|
-
let f = i != null && Mr(a);
|
|
1144
|
-
if (!((f || o?.length) && r)) return [];
|
|
1145
|
-
if (o?.length) {
|
|
1146
|
-
let t = o.map((e) => {
|
|
1147
|
-
let t = Pr({
|
|
1148
|
-
columnName: e?.columnName,
|
|
1149
|
-
selectedDims: s
|
|
1150
|
-
}), n = jr(t ? Nr(e.columnName, s) : void 0);
|
|
1151
|
-
if (n && t) return Lr({
|
|
1152
|
-
columnName: t,
|
|
1153
|
-
value: e?.value,
|
|
1154
|
-
tableName: n,
|
|
1155
|
-
tenancyLevel: l,
|
|
1156
|
-
clientId: u,
|
|
1157
|
-
sourceMetricId: d
|
|
1158
|
-
});
|
|
1159
|
-
}).filter((e) => !!e);
|
|
1160
|
-
return [...e || [], ...t];
|
|
1161
|
-
}
|
|
1162
|
-
if (f) {
|
|
1163
|
-
if (d) return Wr({
|
|
1164
|
-
existing: e,
|
|
1165
|
-
columnName: a,
|
|
1166
|
-
value: i,
|
|
1167
|
-
selectedDims: s,
|
|
1168
|
-
tenancyLevel: l,
|
|
1169
|
-
clientId: u,
|
|
1170
|
-
sourceMetricId: d
|
|
1171
|
-
});
|
|
1172
|
-
let t = Pr({
|
|
1173
|
-
columnName: a,
|
|
1174
|
-
selectedDims: s
|
|
1175
|
-
});
|
|
1176
|
-
return t ? [...e || [], Lr({
|
|
1177
|
-
columnName: t,
|
|
1178
|
-
value: i,
|
|
1179
|
-
tableName: c,
|
|
1180
|
-
tenancyLevel: l,
|
|
1181
|
-
clientId: u,
|
|
1182
|
-
sourceMetricId: d
|
|
1183
|
-
})] : e || [];
|
|
1184
|
-
}
|
|
1185
|
-
return [];
|
|
1186
|
-
}
|
|
1187
|
-
var zr = /* @__PURE__ */ new Set([
|
|
1188
|
-
N.progressBar,
|
|
1189
|
-
N.progressBarV2,
|
|
1190
|
-
N.linearGauge,
|
|
1191
|
-
N.linearGaugeV2,
|
|
1192
|
-
N.gauge,
|
|
1193
|
-
N.gaugeV2
|
|
1194
|
-
]);
|
|
1195
|
-
function Br({ runtimeEnabled: e, metricEnabled: t }) {
|
|
1196
|
-
return !!e || !!t;
|
|
1197
|
-
}
|
|
1198
|
-
function Vr({ chartType: e, isDrillEnabled: t, dimensions: n, drilledLevel: r, drillLevels: i }) {
|
|
1199
|
-
if (e && zr.has(e)) return "terminal";
|
|
1200
|
-
if (!t || (n?.length ?? 0) === r) return "none";
|
|
1201
|
-
let a = i || [];
|
|
1202
|
-
return a[a.length - 1]?.isEnable ? "none" : "drill";
|
|
1203
|
-
}
|
|
1204
|
-
function Hr({ chartType: e, params: t, rowFilters: n, dimensions: r }) {
|
|
1205
|
-
return e === N.table ? {
|
|
1206
|
-
name: n?.find((e) => r?.some((t) => e?.columnName === t))?.value,
|
|
1207
|
-
rowFilters: n
|
|
1208
|
-
} : t;
|
|
1209
|
-
}
|
|
1210
|
-
function Ur(e, t) {
|
|
1211
|
-
if (!Mr(e)) return !1;
|
|
1212
|
-
let n = Nr(e, t);
|
|
1213
|
-
return !!n && !!jr(n);
|
|
1214
|
-
}
|
|
1215
|
-
function Wr({ existing: e, columnName: t, value: n, mode: r = "only", selectedDims: i, tenancyLevel: a, clientId: o, sourceMetricId: s }) {
|
|
1216
|
-
if (!Mr(t) || n === void 0) return e || [];
|
|
1217
|
-
let c = Nr(t, i), l = Pr({
|
|
1218
|
-
columnName: t,
|
|
1219
|
-
selectedDims: i
|
|
1220
|
-
}), u = jr(c);
|
|
1221
|
-
if (!u || !l) return e || [];
|
|
1222
|
-
let d = Lr({
|
|
1223
|
-
columnName: l,
|
|
1224
|
-
value: n,
|
|
1225
|
-
tableName: u,
|
|
1226
|
-
tenancyLevel: a,
|
|
1227
|
-
clientId: o,
|
|
1228
|
-
sourceMetricId: s
|
|
1229
|
-
}), f = (e || []).filter((e) => e?.name !== "cross-filter" || e?.columnName !== l), p = {
|
|
1230
|
-
label: "NOT IN",
|
|
1231
|
-
value: "NOT IN"
|
|
1232
|
-
};
|
|
1233
|
-
return [...f, r === "exclude" ? Or({
|
|
1234
|
-
...d,
|
|
1235
|
-
filterVariant: p
|
|
1236
|
-
}, s) : d];
|
|
1237
|
-
}
|
|
1238
|
-
//#endregion
|
|
1239
|
-
//#region src/core/metric-builder/terminalAction.ts
|
|
1240
|
-
var Gr = {
|
|
1241
|
-
"no-subset": "no-subset",
|
|
1242
|
-
"no-reachable-columns": "no-reachable-columns",
|
|
1243
|
-
"all-dimensions-used": "all-dimensions-used",
|
|
1244
|
-
"max-depth-reached": "max-depth-reached",
|
|
1245
|
-
"custom-sql": "custom-sql"
|
|
1246
|
-
}, Kr = ({ position: e, hasAuthoredNextLevel: t, pool: n, canDrillIntoAnyDimension: r }) => {
|
|
1247
|
-
if (t) return "underlying-data-not-permitted";
|
|
1248
|
-
if (r) {
|
|
1249
|
-
if (n?.groups?.length) return "underlying-data-not-permitted";
|
|
1250
|
-
if (n?.unavailableReason) return Gr[n.unavailableReason];
|
|
1251
|
-
if (e.currentDepth >= 3) return "max-depth-reached";
|
|
1252
|
-
}
|
|
1253
|
-
return "hierarchy-exhausted";
|
|
1254
|
-
};
|
|
1255
|
-
function qr(e) {
|
|
1256
|
-
if (e.resultState === "failed") return {
|
|
1257
|
-
kind: "none",
|
|
1258
|
-
reason: "query-failed"
|
|
1259
|
-
};
|
|
1260
|
-
if (e.resultState === "empty") return {
|
|
1261
|
-
kind: "none",
|
|
1262
|
-
reason: "empty-result"
|
|
1263
|
-
};
|
|
1264
|
-
let { chart: t, chartWithMetric: n } = e.clickActions || {};
|
|
1265
|
-
return n?.isEnable && n.metricId ? {
|
|
1266
|
-
kind: "openMetric",
|
|
1267
|
-
metricId: n.metricId
|
|
1268
|
-
} : t?.isEnable && t.route && t.routeType !== "user" ? {
|
|
1269
|
-
kind: "openUrl",
|
|
1270
|
-
url: t.route,
|
|
1271
|
-
isOpenInNewTab: t.isOpenInNewTab
|
|
1272
|
-
} : e.canViewUnderlyingData ? { kind: "viewRecords" } : {
|
|
1273
|
-
kind: "none",
|
|
1274
|
-
reason: Kr(e)
|
|
1275
|
-
};
|
|
1276
|
-
}
|
|
1277
|
-
var Jr = {
|
|
1278
|
-
"hierarchy-exhausted": {
|
|
1279
|
-
title: "There is nothing further to break this down by",
|
|
1280
|
-
body: "This is the whole breakdown this chart is set up for."
|
|
1281
|
-
},
|
|
1282
|
-
"max-depth-reached": {
|
|
1283
|
-
title: "This is as far as this chart breaks down",
|
|
1284
|
-
body: "Go back a step to break it down a different way."
|
|
1285
|
-
},
|
|
1286
|
-
"all-dimensions-used": {
|
|
1287
|
-
title: "Everything you can group by is already on this chart",
|
|
1288
|
-
body: "Go back a step to swap one of them for another."
|
|
1289
|
-
},
|
|
1290
|
-
"no-reachable-columns": {
|
|
1291
|
-
title: "There is nothing else to group this by",
|
|
1292
|
-
body: "Nothing else in this data connects to what the chart is built from."
|
|
1293
|
-
},
|
|
1294
|
-
"no-subset": {
|
|
1295
|
-
title: "Breaking this down is not available here",
|
|
1296
|
-
body: "This view does not carry the fields it would need."
|
|
1297
|
-
},
|
|
1298
|
-
"custom-sql": {
|
|
1299
|
-
title: "This chart cannot be grouped a different way",
|
|
1300
|
-
body: "It is built to answer one shape of question, and you are at the end of it."
|
|
1301
|
-
},
|
|
1302
|
-
"underlying-data-not-permitted": {
|
|
1303
|
-
title: "The rows behind this are not open to you",
|
|
1304
|
-
body: "Ask the team who set this dashboard up if you need them."
|
|
1305
|
-
},
|
|
1306
|
-
"empty-result": {
|
|
1307
|
-
title: "Nothing matched this",
|
|
1308
|
-
body: "Go back a step and pick something else."
|
|
1309
|
-
},
|
|
1310
|
-
"blank-value": {
|
|
1311
|
-
title: "This one is blank, so there is nothing to open",
|
|
1312
|
-
body: "Pick a point with a name on it, or go back a step."
|
|
1313
|
-
},
|
|
1314
|
-
"level-without-measure": {
|
|
1315
|
-
title: "The next step was saved without a measure, so it has no values to show",
|
|
1316
|
-
body: "The chart author can add a measure to this step in the metric editor."
|
|
1317
|
-
},
|
|
1318
|
-
"query-failed": {
|
|
1319
|
-
title: "This did not load",
|
|
1320
|
-
body: "Try again, or go back a step."
|
|
1321
|
-
}
|
|
1322
|
-
};
|
|
1323
|
-
function Yr(e) {
|
|
1324
|
-
switch (e.kind) {
|
|
1325
|
-
case "viewRecords": return {
|
|
1326
|
-
title: "Look at the rows behind this",
|
|
1327
|
-
body: "There is nothing further to break this down by, so the individual records are the next thing to see.",
|
|
1328
|
-
cta: "View records"
|
|
1329
|
-
};
|
|
1330
|
-
case "openUrl": return {
|
|
1331
|
-
title: "Open the full detail",
|
|
1332
|
-
body: "This chart links out to more about what you picked.",
|
|
1333
|
-
cta: "Open link"
|
|
1334
|
-
};
|
|
1335
|
-
case "openMetric": return {
|
|
1336
|
-
title: "Carry on in another chart",
|
|
1337
|
-
body: "Another chart is set up to pick up from what you picked here.",
|
|
1338
|
-
cta: "Open chart"
|
|
1339
|
-
};
|
|
1340
|
-
default: return Jr[e.reason];
|
|
1341
|
-
}
|
|
1342
|
-
}
|
|
1343
|
-
//#endregion
|
|
1344
|
-
//#region src/helpers/customSqlDrill.ts
|
|
1345
|
-
var Xr = (e) => typeof e == "object" && !!e && !Array.isArray(e), Zr = (e) => typeof e == "string" ? e : "", Qr = (e) => {
|
|
1346
|
-
if (!Xr(e)) return !1;
|
|
1347
|
-
let t = Xr(e.newDatasetSettings) ? e.newDatasetSettings : {};
|
|
1348
|
-
return t.isPythonMode === !0 && Zr(t.pythonCode).trim() || e.isUseRawSQL !== !0 && t.isSqlMode !== !0 ? !1 : !Xr((Xr(t.configuration) ? t.configuration : {}).table);
|
|
1349
|
-
}, $r = (e) => {
|
|
1350
|
-
let t = e?.name || e?.alias;
|
|
1351
|
-
return t ? {
|
|
1352
|
-
...e,
|
|
1353
|
-
name: t,
|
|
1354
|
-
alias: t
|
|
1355
|
-
} : e;
|
|
1356
|
-
}, ei = (e) => e?.levels?.length ? {
|
|
1357
|
-
...e,
|
|
1358
|
-
levels: e.levels.map((e) => ({
|
|
1359
|
-
...e,
|
|
1360
|
-
dimensions: (e?.dimensions || []).map($r),
|
|
1361
|
-
measures: (e?.measures || []).map($r)
|
|
1362
|
-
}))
|
|
1363
|
-
} : e, ti = (e, t, n) => n?.length ? {
|
|
1364
|
-
...e,
|
|
1365
|
-
[t]: n
|
|
1366
|
-
} : Object.fromEntries(Object.entries(e).filter(([e]) => e !== t)), ni = ({ metricId: e, filters: t, onChange: n }) => {
|
|
1367
|
-
e && n?.(e, t);
|
|
1368
|
-
}, ri = (e) => e.find(([, e, t]) => !Array.isArray(e) || !t && e.length === 0)?.[0], ii = (e, t) => {
|
|
1369
|
-
let n = e?.chartType, r = n === "pivotV2" || n === "pivot table 2";
|
|
1370
|
-
if (!r && n !== "pivotV3" && n !== "pivot table 3") return { renderEmpty: !1 };
|
|
1371
|
-
let i = ri(r ? [
|
|
1372
|
-
["chartOptions.pivotTableSettings2.dimensions", e?.pivotTableSettings2?.dimensions],
|
|
1373
|
-
[
|
|
1374
|
-
"chartOptions.pivotTableSettings2.headers",
|
|
1375
|
-
e?.pivotTableSettings2?.headers,
|
|
1376
|
-
!0
|
|
1377
|
-
],
|
|
1378
|
-
["chartOptions.pivotTableSettings2.measures", e?.pivotTableSettings2?.measures]
|
|
1379
|
-
] : [
|
|
1380
|
-
["chartOptions.pivotTableSettings3.columns", e?.pivotTableSettings3?.columns],
|
|
1381
|
-
[
|
|
1382
|
-
"chartOptions.pivotTableSettings3.rows",
|
|
1383
|
-
e?.pivotTableSettings3?.rows,
|
|
1384
|
-
!0
|
|
1385
|
-
],
|
|
1386
|
-
[
|
|
1387
|
-
"chartOptions.pivotTableSettings3.dims",
|
|
1388
|
-
e?.pivotTableSettings3?.dims,
|
|
1389
|
-
!0
|
|
1390
|
-
],
|
|
1391
|
-
[
|
|
1392
|
-
"chartOptions.pivotTableSettings3.aggregates",
|
|
1393
|
-
e?.pivotTableSettings3?.aggregates,
|
|
1394
|
-
!0
|
|
1395
|
-
]
|
|
1396
|
-
]);
|
|
1397
|
-
if (i) return {
|
|
1398
|
-
renderEmpty: !0,
|
|
1399
|
-
missingField: i
|
|
1400
|
-
};
|
|
1401
|
-
let a = t?.newDatasetSettings, o = ri([
|
|
1402
|
-
[
|
|
1403
|
-
"datasetMetricSettings.newDatasetSettings.selectedDims",
|
|
1404
|
-
a?.selectedDims,
|
|
1405
|
-
!0
|
|
1406
|
-
],
|
|
1407
|
-
[
|
|
1408
|
-
"datasetMetricSettings.newDatasetSettings.selectedMetrics",
|
|
1409
|
-
a?.selectedMetrics,
|
|
1410
|
-
!0
|
|
1411
|
-
],
|
|
1412
|
-
[
|
|
1413
|
-
"datasetMetricSettings.newDatasetSettings.configuration.filters",
|
|
1414
|
-
a?.configuration?.filters,
|
|
1415
|
-
!0
|
|
1416
|
-
]
|
|
1417
|
-
]);
|
|
1418
|
-
return o ? {
|
|
1419
|
-
renderEmpty: !0,
|
|
1420
|
-
missingField: o
|
|
1421
|
-
} : [a?.selectedDims, a?.selectedMetrics].some((e) => Array.isArray(e) && e.length > 0) ? { renderEmpty: !1 } : {
|
|
1422
|
-
renderEmpty: !0,
|
|
1423
|
-
missingField: "datasetMetricSettings.newDatasetSettings.selectedDims"
|
|
1424
|
-
};
|
|
1425
|
-
}, ai = xt([]), oi = () => {
|
|
1426
|
-
let e = St(ai), { data: t } = k(), n = t?.externalDashboard?.dashboardFiltersLayout;
|
|
1427
|
-
return R(() => e.length ? e : Array.isArray(n) ? n.filter((e) => typeof e == "string") : [], [e, n]);
|
|
1428
|
-
}, si = (e, t, n = []) => {
|
|
1429
|
-
if (!t.length || e.length < 2) return e;
|
|
1430
|
-
let r = (e) => {
|
|
1431
|
-
let r = n.find((t) => t.name && t.name === e.name || !!t.columnName && t.columnName === e.columnName && (!t.tableName || !e.tableName || t.tableName === e.tableName)), i = [
|
|
1432
|
-
e.clientLabel,
|
|
1433
|
-
e.name,
|
|
1434
|
-
e.columnName,
|
|
1435
|
-
r?.originalLabel,
|
|
1436
|
-
r?.label,
|
|
1437
|
-
r?.name
|
|
1438
|
-
];
|
|
1439
|
-
for (let e of i) {
|
|
1440
|
-
if (!e) continue;
|
|
1441
|
-
let n = t.indexOf(e);
|
|
1442
|
-
if (n >= 0) return n;
|
|
1443
|
-
}
|
|
1444
|
-
return -1;
|
|
1445
|
-
};
|
|
1446
|
-
return e.map((e) => ({
|
|
1447
|
-
filter: e,
|
|
1448
|
-
position: r(e)
|
|
1449
|
-
})).map((e, t) => ({
|
|
1450
|
-
...e,
|
|
1451
|
-
index: t
|
|
1452
|
-
})).sort((e, t) => e.position >= 0 && t.position < 0 ? -1 : e.position < 0 && t.position >= 0 ? 1 : e.position === t.position ? e.index - t.index : e.position - t.position).map((e) => e.filter);
|
|
1453
|
-
}, ci = 100, li = (e) => {
|
|
1454
|
-
let [t, n] = B(e);
|
|
1455
|
-
return L(() => {
|
|
1456
|
-
if (e) {
|
|
1457
|
-
n(!0);
|
|
1458
|
-
return;
|
|
1459
|
-
}
|
|
1460
|
-
let t = setTimeout(() => n(!1), ci);
|
|
1461
|
-
return () => clearTimeout(t);
|
|
1462
|
-
}, [e]), t;
|
|
1463
|
-
}, ui = (e, t) => !(!e || e.isLoading !== !0 || e.key !== t || e.data?.data?.length), di = ({ clientId: e, guestToken: t, isFrontendApp: n }) => JSON.stringify({
|
|
1464
|
-
clientId: e,
|
|
1465
|
-
guestToken: t || "",
|
|
1466
|
-
isFrontendApp: n
|
|
1467
|
-
}), fi = ({ query: e, clientId: t, isFrontendApp: n }) => JSON.stringify({
|
|
1468
|
-
query: e,
|
|
1469
|
-
tenant: {
|
|
1470
|
-
clientId: t,
|
|
1471
|
-
isFrontendApp: n
|
|
1472
|
-
}
|
|
1473
|
-
}), pi = (e, t) => e?.includes(t) ? e : [...e || [], t], mi = (e, t) => e?.includes(t) ? e.filter((e) => e !== t) : e, hi = (e, t) => !!(e && e.data?.data === t.data && e.data?.name === t.name && e.data?.description === t.description && e.isLoading === t.isLoading && e.key === t.key), gi = (e) => e.isMetric !== !1 || e.elementSettings?.elementType?.value === "metricExpression", _i = ({ metric: e, isAllClient: t, tenancyLevel: n, appliedMetricFilters: r, firstLoadAppliedMetricFilters: i, tableColumnFilters: a, chartSettings: o, isPythonMode: s, globalFilters: c, filterValues: l, tableLimit: u, calendarType: d, comparisonCount: f, datasourceId: p, drillConfig: m, isFrontendApp: h, guestToken: g }) => ({
|
|
1474
|
-
isAllClient: t,
|
|
1475
|
-
id: e?.id,
|
|
1476
|
-
tenancyLevel: n,
|
|
1477
|
-
rlsConditions: [...(r?.length ? r : i) || [], ...o?.tableSettings?.isServerSidePagination && o?.chartType === N.table ? a.map((e) => e.condition).filter((e) => se(e)) : []],
|
|
1478
|
-
globalFilters: s ? void 0 : {
|
|
1479
|
-
...c,
|
|
1480
|
-
filters: c?.filters?.filter((e) => Array.isArray(e?.value) ? e?.value?.length : e)
|
|
1481
|
-
},
|
|
1482
|
-
filterValues: s ? void 0 : l,
|
|
1483
|
-
limit: o?.tableSettings?.isServerSidePagination && o?.chartType === N.table ? Math.min(u.limit, 1e3) : void 0,
|
|
1484
|
-
offset: o?.tableSettings?.isServerSidePagination && o?.chartType === N.table ? u.offset : void 0,
|
|
1485
|
-
disableStringify: !0,
|
|
1486
|
-
pivotHeaders: o?.pivotTableSettings2?.headers || [],
|
|
1487
|
-
timeseriesSettings: s ? void 0 : {
|
|
1488
|
-
format: o?.timeSeriesSettings?.groupBySettings?.value?.toLowerCase() || "monthly",
|
|
1489
|
-
seriesField: o?.seriesField || "",
|
|
1490
|
-
isFiscal: d === "ind"
|
|
1491
|
-
},
|
|
1492
|
-
chartSeriesField: o?.seriesField !== "ungrouped" && o?.seriesField && o?.isDynamicSeries ? o?.seriesField : void 0,
|
|
1493
|
-
comparisonCount: f,
|
|
1494
|
-
dynamicXAxis: {
|
|
1495
|
-
isEnable: !!(o?.dynamicXAxis?.isEnabled || o?.enduserMeasureAndDimensions?.isEnabled) && Ue.includes(o?.chartType || ""),
|
|
1496
|
-
xaxis: o?.xAxis || "",
|
|
1497
|
-
customField: o?.dynamicXAxis?.selectedOption?.column
|
|
1498
|
-
},
|
|
1499
|
-
dbId: p,
|
|
1500
|
-
elementSettings: e?.elementSettings?.metricExpression,
|
|
1501
|
-
drillConfig: Qr(e?.datasetMetricSettings) ? ei(m) : m,
|
|
1502
|
-
isEncrypted: !(h || !g)
|
|
1503
|
-
}), vi = (e) => {
|
|
1504
|
-
let t = e.object.customTable?.query;
|
|
1505
|
-
return e.object.wId ? !t || !t.includes("{{") : !1;
|
|
1506
|
-
}, yi = (e, t) => e.customTable ? "" : e.tableName ? P(e.tableName, t) : e.tableName, bi = (e, t) => {
|
|
1507
|
-
if (!e.customColumnSql) return e.columnName ? P(e.columnName, t) : e.columnName;
|
|
1508
|
-
}, xi = (e) => {
|
|
1509
|
-
let { object: t } = e, n = t.wId;
|
|
1510
|
-
return {
|
|
1511
|
-
...t,
|
|
1512
|
-
tableName: yi(t, n),
|
|
1513
|
-
columnName: bi(t, n),
|
|
1514
|
-
filter: t.filter?.length ? j(t.filter, n) : [],
|
|
1515
|
-
customTable: t.customTable?.query ? {
|
|
1516
|
-
query: P(t.customTable.query, n),
|
|
1517
|
-
alias: P(t.customTable.alias, n)
|
|
1518
|
-
} : t.customTable
|
|
1519
|
-
};
|
|
1520
|
-
}, Si = async (e, t, n) => {
|
|
1521
|
-
if (vi(e)) try {
|
|
1522
|
-
let r = await t({
|
|
1523
|
-
data: xi(e),
|
|
1524
|
-
encryptedClientId: n.isFrontendApp ? n.encryptedClientId || "" : n.clientId || "",
|
|
1525
|
-
isFrontendApp: !!n.isFrontendApp,
|
|
1526
|
-
token: n.token || ""
|
|
1527
|
-
});
|
|
1528
|
-
return r?.data && Array.isArray(r.data) ? r.data[0]?.value || e.element?.defaultValue || "" : void 0;
|
|
1529
|
-
} catch {
|
|
1530
|
-
return;
|
|
1531
|
-
}
|
|
1532
|
-
}, Ci = async ({ entries: e, fetchColumnValues: t, ctx: n, onSeed: r, onResolved: i, onLoading: a, onSettle: o, isCancelled: s }) => {
|
|
1533
|
-
a(!0);
|
|
1534
|
-
let c = {};
|
|
1535
|
-
e?.forEach((e) => {
|
|
1536
|
-
c[e?.element?.name] = e?.element?.defaultValue || "";
|
|
1537
|
-
}), r(c);
|
|
1538
|
-
try {
|
|
1539
|
-
for (let r = 0; r < (e?.length || 0); r++) {
|
|
1540
|
-
if (s()) return;
|
|
1541
|
-
let o = e[r];
|
|
1542
|
-
a(!0);
|
|
1543
|
-
let c = await Si(o, t, n);
|
|
1544
|
-
if (s()) return;
|
|
1545
|
-
c !== void 0 && i(o.element.name, c);
|
|
1546
|
-
}
|
|
1547
|
-
} finally {
|
|
1548
|
-
o();
|
|
1549
|
-
}
|
|
1550
|
-
}, wi = "__dbnFullscreenDrillState", Ti = (e) => typeof e == "object" && !!e, Ei = (e) => Array.isArray(e), Di = (e, t) => ({
|
|
1551
|
-
...e,
|
|
1552
|
-
...t,
|
|
1553
|
-
metric: {
|
|
1554
|
-
...e.metric,
|
|
1555
|
-
[wi]: t
|
|
1556
|
-
}
|
|
1557
|
-
}), Oi = (e, t = {}) => {
|
|
1558
|
-
let n = Ti(e) && Ti(e.__dbnFullscreenDrillState) ? e[wi] : {};
|
|
1559
|
-
return {
|
|
1560
|
-
drilledLevel: t.drilledLevel ?? (typeof n.drilledLevel == "number" ? n.drilledLevel : void 0),
|
|
1561
|
-
drillFilters: t.drillFilters ?? (Ei(n.drillFilters) ? n.drillFilters : void 0),
|
|
1562
|
-
drillType: t.drillType ?? (typeof n.drillType == "string" ? n.drillType : void 0),
|
|
1563
|
-
underlyingDataDrillFilters: t.underlyingDataDrillFilters ?? (Ei(n.underlyingDataDrillFilters) ? n.underlyingDataDrillFilters : void 0)
|
|
1564
|
-
};
|
|
1565
|
-
}, ki = (e, t) => {
|
|
1566
|
-
if (!e || e.isEnableGroupBy === !1 || t.drilledLevel === void 0 && t.drillFilters === void 0 && t.drillType === void 0 && t.underlyingDataDrillFilters === void 0) return e;
|
|
1567
|
-
let n = e.configV2?.levels;
|
|
1568
|
-
if (!n?.length) return t.drillType === void 0 ? e : {
|
|
1569
|
-
...e,
|
|
1570
|
-
drillType: t.drillType
|
|
1571
|
-
};
|
|
1572
|
-
let r = Math.max(0, Math.min(n.length - 1, Math.trunc(t.drilledLevel ?? n.findIndex((e) => e.isEnable)))), i = t.drillFilters ?? t.underlyingDataDrillFilters;
|
|
1573
|
-
return {
|
|
1574
|
-
...e,
|
|
1575
|
-
isEnableGroupBy: !0,
|
|
1576
|
-
drillType: t.drillType ?? e.drillType,
|
|
1577
|
-
configV2: {
|
|
1578
|
-
...e.configV2,
|
|
1579
|
-
isEnable: !0,
|
|
1580
|
-
levels: n.map((e, t) => ({
|
|
1581
|
-
...e,
|
|
1582
|
-
isEnable: t === r,
|
|
1583
|
-
...t === r && i ? { filters: i } : {}
|
|
1584
|
-
}))
|
|
1585
|
-
}
|
|
1586
|
-
};
|
|
1587
|
-
}, Ai = (e) => e.includes(";;") ? e.split(";;") : e, ji = (e, t) => e === void 0 ? t : [...Array.isArray(e) ? e : [e], ...Array.isArray(t) ? t : [t]], Mi = (e, t) => {
|
|
1588
|
-
let n = Ye(e);
|
|
1589
|
-
if (n.mode !== "large") return n.mode === "all" ? F : n.mode === "some" && Array.isArray(e) && e.length && t?.toUpperCase() === "NOT IN" ? [F, ...e] : e;
|
|
1590
|
-
}, Ni = [
|
|
1591
|
-
"dashboardId",
|
|
1592
|
-
"configId",
|
|
1593
|
-
"embed",
|
|
1594
|
-
"isDbn"
|
|
1595
|
-
], Pi = (e) => `dbn.${e}.`, Fi = "drill.", Ii = (e) => {
|
|
1596
|
-
let t = encodeURIComponent(e.levelIndex);
|
|
1597
|
-
return e.filters?.length ? `${t}~${e.filters.map((e) => `${encodeURIComponent(e.columnName)}:${encodeURIComponent(String(e.value ?? ""))}`).join("|")}` : t;
|
|
1598
|
-
}, Li = (e) => {
|
|
1599
|
-
if (!e) return null;
|
|
1600
|
-
let t = e.indexOf("~"), n = t === -1 ? e : e.slice(0, t), r = decodeURIComponent(n);
|
|
1601
|
-
return r ? t === -1 ? {
|
|
1602
|
-
levelIndex: r,
|
|
1603
|
-
filters: []
|
|
1604
|
-
} : {
|
|
1605
|
-
levelIndex: r,
|
|
1606
|
-
filters: e.slice(t + 1).split("|").map((e) => {
|
|
1607
|
-
let t = e.indexOf(":");
|
|
1608
|
-
if (t === -1) return null;
|
|
1609
|
-
let n = decodeURIComponent(e.slice(0, t));
|
|
1610
|
-
return n ? {
|
|
1611
|
-
columnName: n,
|
|
1612
|
-
value: decodeURIComponent(e.slice(t + 1))
|
|
1613
|
-
} : null;
|
|
1614
|
-
}).filter((e) => e !== null)
|
|
1615
|
-
} : null;
|
|
1616
|
-
}, Ri = (e, t) => {
|
|
1617
|
-
if (!t) return {};
|
|
1618
|
-
let n = `${Pi(t)}${Fi}`, r = {};
|
|
1619
|
-
return new URLSearchParams(e).forEach((e, t) => {
|
|
1620
|
-
if (!t.startsWith(n)) return;
|
|
1621
|
-
let i = t.slice(n.length), a = Li(e);
|
|
1622
|
-
i && a && (r[i] = a);
|
|
1623
|
-
}), r;
|
|
1624
|
-
}, zi = ({ currentSearch: e, dashboardId: t, entries: n, legacyGlobals: r = {}, namespaced: i = !0 }) => {
|
|
1625
|
-
if (!i) {
|
|
1626
|
-
let e = new URLSearchParams();
|
|
1627
|
-
return Ni.forEach((n) => {
|
|
1628
|
-
let i = r[n];
|
|
1629
|
-
if (n === "dashboardId") {
|
|
1630
|
-
e.set(n, t ?? "");
|
|
1631
|
-
return;
|
|
1632
|
-
}
|
|
1633
|
-
i && e.set(n, i);
|
|
1634
|
-
}), n.forEach(({ key: t, value: n }) => {
|
|
1635
|
-
e.set(t, n);
|
|
1636
|
-
}), e;
|
|
1637
|
-
}
|
|
1638
|
-
let a = new URLSearchParams(e);
|
|
1639
|
-
if (!t) return a;
|
|
1640
|
-
let o = Pi(t), s = [];
|
|
1641
|
-
return a.forEach((e, t) => {
|
|
1642
|
-
t.startsWith(o) && s.push(t);
|
|
1643
|
-
}), s.forEach((e) => {
|
|
1644
|
-
a.delete(e);
|
|
1645
|
-
}), n.forEach(({ key: e, value: t }) => {
|
|
1646
|
-
a.set(`${o}${e}`, t);
|
|
1647
|
-
}), a;
|
|
1648
|
-
}, Bi = (e, t) => {
|
|
1649
|
-
let n = e?.levels;
|
|
1650
|
-
if (!e || !n?.length) return null;
|
|
1651
|
-
let r = n.findIndex((e) => e?.index === t.levelIndex);
|
|
1652
|
-
return r === -1 ? null : {
|
|
1653
|
-
...e,
|
|
1654
|
-
levels: n.map((e, n) => n === r ? {
|
|
1655
|
-
...e,
|
|
1656
|
-
isEnable: !0,
|
|
1657
|
-
filters: [...t.filters]
|
|
1658
|
-
} : {
|
|
1659
|
-
...e,
|
|
1660
|
-
isEnable: !1,
|
|
1661
|
-
filters: n > r ? [] : e?.filters
|
|
1662
|
-
})
|
|
1663
|
-
};
|
|
1664
|
-
}, Vi = (e, t) => {
|
|
1665
|
-
let n = new URLSearchParams(e), r = {}, i = {}, a = t ? Pi(t) : null, o = (e, t, n) => {
|
|
1666
|
-
e[t] = ji(e[t], Ai(n));
|
|
1667
|
-
};
|
|
1668
|
-
return n.forEach((e, t) => {
|
|
1669
|
-
if (a && t.startsWith(a)) {
|
|
1670
|
-
let n = t.slice(a.length);
|
|
1671
|
-
if (n.startsWith("drill.")) return;
|
|
1672
|
-
o(i, n, e);
|
|
1673
|
-
return;
|
|
1674
|
-
}
|
|
1675
|
-
t.startsWith("dbn.") || o(r, t, e);
|
|
1676
|
-
}), {
|
|
1677
|
-
...r,
|
|
1678
|
-
...i
|
|
1679
|
-
};
|
|
1680
|
-
}, Hi = ({ savedDrillDownSettings: e, initialDrillState: t }) => {
|
|
1681
|
-
let [n, r] = B([]), i = t.drillFilters ?? [], a = z(i), o = z(t.underlyingDataDrillFilters), s = ki(e, t), [c, l] = B(i), [u, d] = B(s ?? {
|
|
1682
|
-
isEnableGroupBy: !1,
|
|
1683
|
-
isEnableCrossFilter: !1,
|
|
1684
|
-
drillType: ""
|
|
1685
|
-
}), [f, p] = B([]);
|
|
1686
|
-
return {
|
|
1687
|
-
drilldownCols: n,
|
|
1688
|
-
setDrillDownCols: r,
|
|
1689
|
-
initialDrillFiltersRef: a,
|
|
1690
|
-
initialUnderlyingDataDrillFiltersRef: o,
|
|
1691
|
-
drillFilters: c,
|
|
1692
|
-
setDrillFilters: l,
|
|
1693
|
-
drillDownSettings: u,
|
|
1694
|
-
setDrillDownSettings: d,
|
|
1695
|
-
adhocDrillDims: f,
|
|
1696
|
-
setAdhocDrillDims: p
|
|
1697
|
-
};
|
|
1698
|
-
}, Ui = ({ metric: e, chartSettings: t, drillDownSettings: n, setDrillDownSettings: r, initialDrilledLevel: i, initialDrillFiltersProp: a, initialDrillType: o, initialUnderlyingDataDrillFilters: s }) => {
|
|
1699
|
-
L(() => {
|
|
1700
|
-
if (e?.drillDownSettings?.isEnableGroupBy) {
|
|
1701
|
-
let c = e?.datasetMetricSettings;
|
|
1702
|
-
if (!e?.drillDownSettings?.configV2 && !n?.configV2 && c?.newDatasetSettings?.selectedMetrics?.length && c?.newDatasetSettings?.selectedDims?.length) {
|
|
1703
|
-
let n = {
|
|
1704
|
-
...e?.drillDownSettings || {},
|
|
1705
|
-
configV2: {
|
|
1706
|
-
isEnable: !!e?.drillDownSettings?.isEnableGroupBy,
|
|
1707
|
-
levels: pt({
|
|
1708
|
-
selectedDims: c?.newDatasetSettings?.selectedDims,
|
|
1709
|
-
selectedMetrics: c?.newDatasetSettings?.selectedMetrics,
|
|
1710
|
-
chartSettings: t,
|
|
1711
|
-
drilldownChartSettings: e?.drillDownSettings?.drilldownChartSettings,
|
|
1712
|
-
makeIndex: () => we(4)
|
|
1713
|
-
})
|
|
1714
|
-
}
|
|
1715
|
-
};
|
|
1716
|
-
r(() => ki(n, {
|
|
1717
|
-
drilledLevel: i,
|
|
1718
|
-
drillFilters: a,
|
|
1719
|
-
drillType: o,
|
|
1720
|
-
underlyingDataDrillFilters: s
|
|
1721
|
-
}) ?? n);
|
|
1722
|
-
} else n?.isEnableGroupBy || r(e?.drillDownSettings);
|
|
1723
|
-
}
|
|
1724
|
-
}, [
|
|
1725
|
-
e?.drillDownSettings?.isEnableGroupBy,
|
|
1726
|
-
e?.drillDownSettings?.configV2,
|
|
1727
|
-
e?.datasetMetricSettings,
|
|
1728
|
-
t,
|
|
1729
|
-
a,
|
|
1730
|
-
i,
|
|
1731
|
-
o,
|
|
1732
|
-
s,
|
|
1733
|
-
r
|
|
1734
|
-
]);
|
|
1735
|
-
}, Wi = ({ drillUrlState: e, metric: t, drillDownSettings: n, setDrillDownSettings: r, setChartSettings: i }) => {
|
|
1736
|
-
let a = z(!1);
|
|
1737
|
-
L(() => {
|
|
1738
|
-
if (a.current) return;
|
|
1739
|
-
let o = e?.position;
|
|
1740
|
-
if (!e?.enabled || !o || !t?.id) return;
|
|
1741
|
-
let s = n?.configV2;
|
|
1742
|
-
if (!s?.levels?.length) return;
|
|
1743
|
-
a.current = !0;
|
|
1744
|
-
let c = Bi(s, o);
|
|
1745
|
-
if (!c) return;
|
|
1746
|
-
r((e) => ({
|
|
1747
|
-
...e,
|
|
1748
|
-
configV2: c
|
|
1749
|
-
}));
|
|
1750
|
-
let l = c.levels?.find((e) => e?.isEnable);
|
|
1751
|
-
l?.chartSettings && i((e) => ({
|
|
1752
|
-
...e,
|
|
1753
|
-
...l.chartSettings
|
|
1754
|
-
})), m("drill-restored-from-url", {
|
|
1755
|
-
metricId: t?.id,
|
|
1756
|
-
levelIndex: o.levelIndex,
|
|
1757
|
-
filterCount: o.filters?.length || 0
|
|
1758
|
-
});
|
|
1759
|
-
}, [
|
|
1760
|
-
e?.enabled,
|
|
1761
|
-
e?.position,
|
|
1762
|
-
n?.configV2,
|
|
1763
|
-
t?.id,
|
|
1764
|
-
r,
|
|
1765
|
-
i
|
|
1766
|
-
]);
|
|
1767
|
-
let o = z(void 0);
|
|
1768
|
-
L(() => {
|
|
1769
|
-
if (!e?.enabled || !e.onChange || !t?.id) return;
|
|
1770
|
-
let r = n?.configV2?.levels || [], i = r.findIndex((e) => e?.isEnable), a = i >= 0 ? r[i] : void 0, s = i > 0 && a?.index ? Ii({
|
|
1771
|
-
levelIndex: a.index,
|
|
1772
|
-
filters: (a.filters || []).filter((e) => e?.columnName).map((e) => ({
|
|
1773
|
-
columnName: String(e.columnName),
|
|
1774
|
-
value: String(e.value ?? "")
|
|
1775
|
-
}))
|
|
1776
|
-
}) : null;
|
|
1777
|
-
o.current !== s && (o.current = s, e.onChange(t.id, s));
|
|
1778
|
-
}, [
|
|
1779
|
-
e?.enabled,
|
|
1780
|
-
e?.onChange,
|
|
1781
|
-
n?.configV2,
|
|
1782
|
-
t?.id
|
|
1783
|
-
]);
|
|
1784
|
-
}, Gi = ({ metric: e, metricStore: t, setMetricStore: n }) => {
|
|
1785
|
-
let r = z(e?.id);
|
|
1786
|
-
r.current = e?.id;
|
|
1787
|
-
let i = z(t);
|
|
1788
|
-
i.current = t;
|
|
1789
|
-
let a = z(n);
|
|
1790
|
-
a.current = n, L(() => () => {
|
|
1791
|
-
let e = r.current, t = i.current, n = a.current;
|
|
1792
|
-
e && t && n && t.get(e)?.data?.data && n((t) => {
|
|
1793
|
-
let n = t.get(e);
|
|
1794
|
-
if (!n?.data?.data) return t;
|
|
1795
|
-
let r = new Map(t);
|
|
1796
|
-
return r.set(e, {
|
|
1797
|
-
...n,
|
|
1798
|
-
data: {
|
|
1799
|
-
...n.data,
|
|
1800
|
-
data: void 0
|
|
1801
|
-
}
|
|
1802
|
-
}), r;
|
|
1803
|
-
});
|
|
1804
|
-
}, []);
|
|
1805
|
-
}, Ki = ({ metric: e, metricStore: t }) => {
|
|
1806
|
-
let n = !!e?.elementSettings?.summary?.metricList?.length, [r, i] = B(0);
|
|
1807
|
-
return L(() => {
|
|
1808
|
-
let e = t?.subscribe;
|
|
1809
|
-
if (n && typeof e == "function") return e(() => i((e) => e + 1));
|
|
1810
|
-
}, [t, n]), r;
|
|
1811
|
-
}, qi = "Could not generate this metric summary. Try again.", Ji = 1500, Yi = /* @__PURE__ */ new Map(), Xi = (e, t) => {
|
|
1812
|
-
Yi.get(e) === t && Yi.delete(e), t.abandonTimer && clearTimeout(t.abandonTimer), t.abandonTimer = void 0;
|
|
1813
|
-
}, Zi = (e) => {
|
|
1814
|
-
Yi.forEach((t, n) => {
|
|
1815
|
-
t.settledAt !== void 0 && e - t.settledAt >= 3e4 && Xi(n, t);
|
|
1816
|
-
}), !(Yi.size <= 24) && [...Yi.entries()].filter(([, e]) => e.settledAt !== void 0).sort(([, e], [, t]) => (e.settledAt ?? 0) - (t.settledAt ?? 0)).slice(0, Math.max(0, Yi.size - 24)).forEach(([e, t]) => {
|
|
1817
|
-
Xi(e, t);
|
|
1818
|
-
});
|
|
1819
|
-
}, Qi = (e, t, n = Date.now) => {
|
|
1820
|
-
Zi(n());
|
|
1821
|
-
let r = Yi.get(e);
|
|
1822
|
-
if (r) r.abandonTimer && (clearTimeout(r.abandonTimer), r.abandonTimer = void 0);
|
|
1823
|
-
else {
|
|
1824
|
-
let i = new AbortController(), a = {
|
|
1825
|
-
controller: i,
|
|
1826
|
-
holders: 0,
|
|
1827
|
-
promise: Promise.resolve()
|
|
1828
|
-
};
|
|
1829
|
-
a.promise = t(i.signal).then((e) => (a.settledAt = n(), e), (t) => {
|
|
1830
|
-
throw Xi(e, a), t;
|
|
1831
|
-
}), a.promise.catch(() => void 0), Yi.set(e, a), r = a;
|
|
1832
|
-
}
|
|
1833
|
-
let i = r;
|
|
1834
|
-
i.holders += 1;
|
|
1835
|
-
let a = !1, o = () => {
|
|
1836
|
-
a || (a = !0, --i.holders, !(i.holders > 0 || i.settledAt !== void 0) && (i.abandonTimer ||= setTimeout(() => {
|
|
1837
|
-
i.abandonTimer = void 0, !(i.holders > 0) && (i.controller.abort(), Xi(e, i));
|
|
1838
|
-
}, Ji)));
|
|
1839
|
-
};
|
|
1840
|
-
return {
|
|
1841
|
-
promise: i.promise,
|
|
1842
|
-
release: o,
|
|
1843
|
-
abort: () => {
|
|
1844
|
-
o(), i.controller.abort(), Xi(e, i);
|
|
1845
|
-
}
|
|
1846
|
-
};
|
|
1847
|
-
}, $i = {
|
|
1848
|
-
status: "idle",
|
|
1849
|
-
summary: "",
|
|
1850
|
-
error: "",
|
|
1851
|
-
empty: !1
|
|
1852
|
-
}, ea = {
|
|
1853
|
-
...$i,
|
|
1854
|
-
status: "failed",
|
|
1855
|
-
error: qi
|
|
1856
|
-
}, ta = {
|
|
1857
|
-
status: "done",
|
|
1858
|
-
summary: "",
|
|
1859
|
-
error: "There is no data to summarize.",
|
|
1860
|
-
empty: !0
|
|
1861
|
-
}, na = () => {
|
|
1862
|
-
let [e, t] = B($i), n = z(null), r = z(null), i = I(() => {
|
|
1863
|
-
let e = r.current;
|
|
1864
|
-
r.current = null, n.current = null, e?.abort(), t($i);
|
|
1865
|
-
}, []), a = I(() => {
|
|
1866
|
-
let e = r.current;
|
|
1867
|
-
r.current = null, e?.abort(), t($i);
|
|
1868
|
-
}, []), o = I((e, i) => {
|
|
1869
|
-
if (n.current === e) return;
|
|
1870
|
-
if (n.current = e, r.current?.release(), r.current = null, !i) {
|
|
1871
|
-
t(ta);
|
|
1872
|
-
return;
|
|
1873
|
-
}
|
|
1874
|
-
t({
|
|
1875
|
-
...$i,
|
|
1876
|
-
status: "running"
|
|
1877
|
-
});
|
|
1878
|
-
let a = Qi(e, async (e) => {
|
|
1879
|
-
try {
|
|
1880
|
-
let t = await i(e), n = t && typeof t == "object" && "summary" in t && typeof t.summary == "string" ? t.summary.trim() : "";
|
|
1881
|
-
return n ? {
|
|
1882
|
-
...$i,
|
|
1883
|
-
status: "done",
|
|
1884
|
-
summary: n
|
|
1885
|
-
} : ta;
|
|
1886
|
-
} catch (e) {
|
|
1887
|
-
if (c(e)) throw e;
|
|
1888
|
-
return ea;
|
|
1889
|
-
}
|
|
1890
|
-
});
|
|
1891
|
-
r.current = a, a.promise.then((e) => {
|
|
1892
|
-
r.current === a && t(e);
|
|
1893
|
-
}, (e) => {
|
|
1894
|
-
r.current === a && t(c(e) ? $i : ea);
|
|
1895
|
-
});
|
|
1896
|
-
}, []);
|
|
1897
|
-
return L(() => () => {
|
|
1898
|
-
r.current?.release(), r.current = null, n.current = null;
|
|
1899
|
-
}, []), {
|
|
1900
|
-
state: e,
|
|
1901
|
-
start: o,
|
|
1902
|
-
stop: a,
|
|
1903
|
-
reset: i
|
|
1904
|
-
};
|
|
1905
|
-
}, ra = (e) => {
|
|
1906
|
-
let t = z(e);
|
|
1907
|
-
return t.current !== e && !Tn(t.current, e) && (t.current = e), t.current;
|
|
1908
|
-
}, $ = (e) => {
|
|
1909
|
-
if (!e) return null;
|
|
1910
|
-
let t = new Date(e);
|
|
1911
|
-
return t instanceof Date && !Number.isNaN(t.getTime()) ? t : null;
|
|
1912
|
-
}, ia = (e) => ie(e || {}) ? {
|
|
1913
|
-
startTime: e?.startTime,
|
|
1914
|
-
endTime: e?.endTime,
|
|
1915
|
-
isTimeFilter: !0
|
|
1916
|
-
} : {}, aa = ({ option: e, value: t }) => ({
|
|
1917
|
-
startDate: $(e?.fromDate) ?? $(e?.startDate) ?? void 0,
|
|
1918
|
-
endDate: $(e?.toDate) ?? $(e?.endDate) ?? void 0,
|
|
1919
|
-
...ia(e),
|
|
1920
|
-
value: t,
|
|
1921
|
-
label: t
|
|
1922
|
-
}), oa = (e, t) => {
|
|
1923
|
-
if (typeof e == "object" && e) return Reflect.get(e, t);
|
|
1924
|
-
}, sa = [], ca = [], la = [], ua = (e, t) => {
|
|
1925
|
-
let n = t?.configV2?.levels?.find((e) => e?.isEnable)?.chartSettings;
|
|
1926
|
-
return n ? {
|
|
1927
|
-
...e,
|
|
1928
|
-
...n
|
|
1929
|
-
} : e;
|
|
1930
|
-
}, da = ({ raw: e, selectedDims: t, selectedMetrics: n, datasetSettings: r, integrationName: i, isPythonMode: a, stableOrder: o }) => {
|
|
1931
|
-
let s = Tr({ data: e });
|
|
1932
|
-
if (!s.rows.length) return sa;
|
|
1933
|
-
let c = ue(s.rows, t || [], n || []), l = c;
|
|
1934
|
-
if (i?.toLowerCase() === "redshift" && !a) {
|
|
1935
|
-
let e = r?.selectedMetrics || [], t = [...((r?.selectedDims)?.filter((e) => !it(e?.alias)) || [])?.map((e) => e.alias), ...e?.map((e) => e.alias)];
|
|
1936
|
-
l = De(t, c);
|
|
1937
|
-
}
|
|
1938
|
-
let u = ot(l);
|
|
1939
|
-
return !Array.isArray(u) || !u.length ? sa : o ? xr(u, o) : u;
|
|
1940
|
-
}, fa = ({ externalDashboardClientId: e, metric: t, globalFilters: n = {
|
|
1941
|
-
tableName: "",
|
|
1942
|
-
filters: []
|
|
1943
|
-
}, rlsFilters: r, clientId: i, tenancyLevel: o, isInternalApp: s, appFilters: c, setCrossDashboardFilters: l, crossDashboardFilters: u, enableCrossFilter: d, enableCrossFilterBeforeDrill: f = !1, metricFilterOptions: p, isAllClient: g, isFrontendApp: _, guestToken: v, encryptedClientId: y, clientCacheScope: b, dashboardId: x, workspaceId: T, metricStore: E, setMetricStore: O, summaryReferencedMetricIds: k, onServerEvent: ie, clientColumnType: le, datasourceId: j, appliedCardMetricFilters: fe, onMetricFiltersChange: _e, language: be, translationDictionary: Se, calendarType: P, setLoadedCardMetadata: Te, isRulePending: Ee = !1, setSettledCardIds: De, drillUrlState: ke, isFullScreen: Me, setMetricMetadata: Ie, viewMetricData: F, generatingPdf: Ve, dataMartTables: qe, isDisableQuery: Ye = !1, token: Xe, drilledLevel: et, drillFilters: nt, drillType: it, underlyingDataDrillFilters: lt }) => {
|
|
1944
|
-
let [pt, vt] = B(!1), xt = w(), [St, wt] = B(null), { state: Tt, start: Et, stop: kt, reset: At } = na(), jt = Tt.summary, Mt = Tt.error, Nt = Tt.empty, Pt = Tt.status === "running", Ft = z(null), It = z(null), [Lt, Rt] = B({
|
|
1945
|
-
limit: parseInt(t?.chartOptions?.tableSettings?.defaultRowSize || "100", 10),
|
|
1946
|
-
offset: 0
|
|
1947
|
-
}), [zt, Bt] = B(0), [Vt, Ht] = B(0), [V, Ut] = B(t?.rlsConditions || []), [Wt, Gt] = B([]), [Kt, qt] = B(!1), [H, Jt] = B(), [Yt, Xt] = B(""), [Zt, Qt] = B([]), [$t, en] = B({
|
|
1948
|
-
isOpen: !1,
|
|
1949
|
-
report: "",
|
|
1950
|
-
isLoading: !1
|
|
1951
|
-
}), [tn, nn] = B(!1), { drilldownCols: rn, setDrillDownCols: an, initialDrillFiltersRef: on, initialUnderlyingDataDrillFiltersRef: sn, drillFilters: U, setDrillFilters: cn, drillDownSettings: W, setDrillDownSettings: G, adhocDrillDims: ln, setAdhocDrillDims: un } = Hi({
|
|
1952
|
-
savedDrillDownSettings: t?.drillDownSettings,
|
|
1953
|
-
initialDrillState: {
|
|
1954
|
-
drilledLevel: et,
|
|
1955
|
-
drillFilters: nt,
|
|
1956
|
-
drillType: it,
|
|
1957
|
-
underlyingDataDrillFilters: lt
|
|
1958
|
-
}
|
|
1959
|
-
}), dn = !s && f === !0, fn = Br({
|
|
1960
|
-
runtimeEnabled: d,
|
|
1961
|
-
metricEnabled: t?.drillDownSettings?.isEnableCrossFilter
|
|
1962
|
-
}), [pn, mn] = B([]), [hn, gn] = B(!1), [_n, vn] = B(!1), [K, yn] = B([]), bn = z(_e);
|
|
1963
|
-
bn.current = _e;
|
|
1964
|
-
let xn = I((e) => {
|
|
1965
|
-
yn((n) => {
|
|
1966
|
-
let r = typeof e == "function" ? e(n) : e;
|
|
1967
|
-
return ni({
|
|
1968
|
-
metricId: t?.id,
|
|
1969
|
-
filters: r,
|
|
1970
|
-
onChange: bn.current
|
|
1971
|
-
}), r;
|
|
1972
|
-
});
|
|
1973
|
-
}, [t?.id]), [Sn, Cn] = B({}), [wn, Tn] = B(!1), [En, Dn] = B([]), [q, J] = B(ua(t?.chartOptions, t?.drillDownSettings)), On = z(""), [kn, An] = B({
|
|
1974
|
-
data: [],
|
|
1975
|
-
error: "",
|
|
1976
|
-
isLoading: !1,
|
|
1977
|
-
currentValue: ""
|
|
1978
|
-
}), Y = R(() => !!t?.datasetMetricSettings?.newDatasetSettings?.isPythonMode, [t?.datasetMetricSettings?.newDatasetSettings?.isPythonMode]), jn = R(() => Qr(t?.datasetMetricSettings), [t?.datasetMetricSettings]), Mn = I((e) => se(e) ? !0 : e?.isAddOnMetrics && e?.datatype === "date" ? !1 : !!(e?.isAddOnMetrics && e?.client?.isEnable && e?.client?.columnName && e?.client?.as && !g && i), [i, g]), Pn = R(() => t?.externalDashboardMetrics?.[0]?.externalDashboard?.companyWorkspace?.datamart?.datamartRelationships || [], [t]), Fn = R(() => {
|
|
1979
|
-
let e = {};
|
|
1980
|
-
if (r?.values) for (let t in r.values) {
|
|
1981
|
-
let n = `${t}_variable`;
|
|
1982
|
-
e[n] = r.values[t];
|
|
1983
|
-
}
|
|
1984
|
-
return e;
|
|
1985
|
-
}, [r?.values]), In = R(() => {
|
|
1986
|
-
let e = t?.datasetMetricSettings?.newDatasetSettings?.selectedMainTable;
|
|
1987
|
-
return (qe?.find((t) => t.tableName === e?.tableName))?.customColumnFields?.map((n) => ({
|
|
1988
|
-
value: n?.columnName,
|
|
1989
|
-
label: n?.columnName,
|
|
1990
|
-
isCustomField: !0,
|
|
1991
|
-
column: {
|
|
1992
|
-
uniqueId: we(10),
|
|
1993
|
-
alias: n?.columnName,
|
|
1994
|
-
configType: "DIMENSION",
|
|
1995
|
-
datatype: n?.datatype,
|
|
1996
|
-
dropType: "DIMENSION",
|
|
1997
|
-
index: 1e3,
|
|
1998
|
-
name: n?.columnName,
|
|
1999
|
-
parentAlias: `${je(e?.schemaName, t?.companyIntegration?.name || "")}_${e?.tableName?.replaceAll(" ", "_")?.replace("*", "_")}`,
|
|
2000
|
-
table: t?.datasetMetricSettings?.newDatasetSettings?.selectedMainTable,
|
|
2001
|
-
type: "DEFAULT",
|
|
2002
|
-
draggableItemData: {
|
|
2003
|
-
column: {
|
|
2004
|
-
name: n?.columnName,
|
|
2005
|
-
dataType: n?.datatype,
|
|
2006
|
-
as: n?.datatype
|
|
2007
|
-
},
|
|
2008
|
-
table: t?.datasetMetricSettings?.newDatasetSettings?.selectedMainTable
|
|
2009
|
-
},
|
|
2010
|
-
label: "",
|
|
2011
|
-
sql: ""
|
|
2012
|
-
}
|
|
2013
|
-
})) || [];
|
|
2014
|
-
}, [
|
|
2015
|
-
t?.datasetMetricSettings?.newDatasetSettings?.selectedMainTable,
|
|
2016
|
-
t?.companyIntegration?.name,
|
|
2017
|
-
qe
|
|
2018
|
-
]), Ln = R(() => {
|
|
2019
|
-
let e = t?.drillDownSettings?.isEnableGroupBy;
|
|
2020
|
-
return (dn ? [...V?.length ? V : [], ...kr({
|
|
2021
|
-
filters: u,
|
|
2022
|
-
metricId: t?.id,
|
|
2023
|
-
isGroupByEnabled: e,
|
|
2024
|
-
enableCrossFilterBeforeDrill: !0
|
|
2025
|
-
})] : e ? V || [] : [...V?.length ? V : [], ...u || []]).filter((e) => e.isAddOnMetrics).map((e) => s ? {
|
|
2026
|
-
...e,
|
|
2027
|
-
dimensionColumn: q?.xAxis || "",
|
|
2028
|
-
measureColumn: q?.yAxisList?.[0] || "",
|
|
2029
|
-
options: e.datatype === "date" ? e.options : [],
|
|
2030
|
-
variableOptions: e.datatype === "date" ? e.variableOptions : []
|
|
2031
|
-
} : {
|
|
2032
|
-
...e,
|
|
2033
|
-
dimensionColumn: q?.xAxis || "",
|
|
2034
|
-
measureColumn: q?.yAxisList?.[0] || "",
|
|
2035
|
-
value: e.isAppFilter ? e.datatype === "date" ? ze(c?.values?.[e.name], e?.datePresetOptions || e?.presetDateOptions) || (e?.options)?.find((t) => t.name === (c?.values?.[e.name] ?? e.value)) : c?.values?.[e.name] ?? e.value : e.value,
|
|
2036
|
-
options: e.datatype === "date" ? e?.options?.map((t) => P === "ind" && e.datatype === "date" ? {
|
|
2037
|
-
...t,
|
|
2038
|
-
isFiscal: !0
|
|
2039
|
-
} : t) : [],
|
|
2040
|
-
variableOptions: e.datatype === "date" ? e.variableOptions : []
|
|
2041
|
-
}).filter((e) => Mn(e));
|
|
2042
|
-
}, [
|
|
2043
|
-
c?.values,
|
|
2044
|
-
P,
|
|
2045
|
-
q?.xAxis,
|
|
2046
|
-
q?.yAxisList,
|
|
2047
|
-
u,
|
|
2048
|
-
t?.id,
|
|
2049
|
-
dn,
|
|
2050
|
-
s,
|
|
2051
|
-
t?.drillDownSettings?.isEnableGroupBy,
|
|
2052
|
-
V,
|
|
2053
|
-
Mn
|
|
2054
|
-
]), Rn = R(() => JSON.stringify(Wt), [Wt]), X = ra(R(() => ({
|
|
2055
|
-
..._i({
|
|
2056
|
-
metric: t,
|
|
2057
|
-
isAllClient: g,
|
|
2058
|
-
tenancyLevel: o,
|
|
2059
|
-
appliedMetricFilters: K,
|
|
2060
|
-
firstLoadAppliedMetricFilters: Ln,
|
|
2061
|
-
tableColumnFilters: Wt,
|
|
2062
|
-
chartSettings: q,
|
|
2063
|
-
isPythonMode: Y,
|
|
2064
|
-
globalFilters: n,
|
|
2065
|
-
filterValues: Fn,
|
|
2066
|
-
tableLimit: Lt,
|
|
2067
|
-
calendarType: P,
|
|
2068
|
-
comparisonCount: Vt,
|
|
2069
|
-
datasourceId: j,
|
|
2070
|
-
drillConfig: W?.configV2,
|
|
2071
|
-
isFrontendApp: _,
|
|
2072
|
-
guestToken: v
|
|
2073
|
-
}),
|
|
2074
|
-
dashboardId: x
|
|
2075
|
-
}), [
|
|
2076
|
-
q,
|
|
2077
|
-
g,
|
|
2078
|
-
t,
|
|
2079
|
-
K,
|
|
2080
|
-
Ln,
|
|
2081
|
-
Y,
|
|
2082
|
-
Fn,
|
|
2083
|
-
U,
|
|
2084
|
-
o,
|
|
2085
|
-
n,
|
|
2086
|
-
Lt,
|
|
2087
|
-
Vt,
|
|
2088
|
-
Ue,
|
|
2089
|
-
j,
|
|
2090
|
-
P,
|
|
2091
|
-
W?.configV2,
|
|
2092
|
-
v,
|
|
2093
|
-
_,
|
|
2094
|
-
x,
|
|
2095
|
-
Rn
|
|
2096
|
-
])), zn = R(() => JSON.stringify(X), [X]), Bn = ii(q, t?.datasetMetricSettings), Vn = t?.datasetMetricSettings, Hn = re(Vn), Un = Ye || Bn.renderEmpty || !!Hn, Gn = _ ? y || "" : i || "", qn = R(() => fi({
|
|
2097
|
-
query: X,
|
|
2098
|
-
clientId: Gn,
|
|
2099
|
-
isFrontendApp: _
|
|
2100
|
-
}), [
|
|
2101
|
-
Gn,
|
|
2102
|
-
_,
|
|
2103
|
-
X
|
|
2104
|
-
]), Jn = R(() => di({
|
|
2105
|
-
clientId: Gn,
|
|
2106
|
-
guestToken: v,
|
|
2107
|
-
isFrontendApp: _
|
|
2108
|
-
}), [
|
|
2109
|
-
Gn,
|
|
2110
|
-
v,
|
|
2111
|
-
_
|
|
2112
|
-
]);
|
|
2113
|
-
L(() => {
|
|
2114
|
-
m("metric-query-payload-prepared", {
|
|
2115
|
-
metricId: t?.id,
|
|
2116
|
-
metricName: t?.name,
|
|
2117
|
-
chartType: q?.chartType,
|
|
2118
|
-
payload: ne(X)
|
|
2119
|
-
});
|
|
2120
|
-
}, [
|
|
2121
|
-
X,
|
|
2122
|
-
t?.id,
|
|
2123
|
-
t?.name,
|
|
2124
|
-
q?.chartType
|
|
2125
|
-
]);
|
|
2126
|
-
let Yn = R(() => Nn(t), [t]), { data: Z, dataUpdatedAt: Xn, isFetching: Zn, isLoading: Qn, error: $n, refetch: er } = Wn({
|
|
2127
|
-
data: X,
|
|
2128
|
-
clientId: _ ? y || "" : i,
|
|
2129
|
-
clientCacheScope: _ ? b : void 0,
|
|
2130
|
-
metricRevision: Yn,
|
|
2131
|
-
token: v,
|
|
2132
|
-
isFrontendApp: _,
|
|
2133
|
-
isFullScreen: Me,
|
|
2134
|
-
savedMetricQuery: t?.isMetric === !1 || !t?.query ? void 0 : Be(t?.query, t?.companyId),
|
|
2135
|
-
savedMetricIdentifiers: Vn,
|
|
2136
|
-
dbName: t?.companyIntegration?.name || t?.integrationName,
|
|
2137
|
-
batchHints: {
|
|
2138
|
-
chartType: q?.chartType,
|
|
2139
|
-
isEnableComparisonFilter: !!q?.isEnableComparisonFilter,
|
|
2140
|
-
isMultiDimension: !!q?.isMultiDimension,
|
|
2141
|
-
isDynamicSeries: !!q?.isDynamicSeries,
|
|
2142
|
-
seriesField: q?.seriesField,
|
|
2143
|
-
isDataMartQuery: !!(t?.datasetMetricSettings)?.newDatasetSettings?.isDataMartQuery
|
|
2144
|
-
}
|
|
2145
|
-
}, {
|
|
2146
|
-
isDisableQuery: Un,
|
|
2147
|
-
onSuccess: (e) => {
|
|
2148
|
-
let t = Tr(e), n = ot(t.rows), r = oa(oa(t.error, "details"), "legacyCode");
|
|
2149
|
-
if (Te && oa(t.error, "code") !== "E1001" && r !== "E1001") {
|
|
2150
|
-
let e = X?.id, t = !!n?.length && (q?.chartType !== N.singleValue || n?.[0]?.[q?.singleValue || ""] != null);
|
|
2151
|
-
Te?.((n) => {
|
|
2152
|
-
let r = n?.find((t) => t?.id === e);
|
|
2153
|
-
return r && r.isDataFound === t ? n : [...n?.filter((t) => t?.id !== e) || [], {
|
|
2154
|
-
id: e,
|
|
2155
|
-
isDataFound: t
|
|
2156
|
-
}];
|
|
2157
|
-
});
|
|
2158
|
-
}
|
|
2159
|
-
},
|
|
2160
|
-
onSettled: () => {
|
|
2161
|
-
let e = X?.id;
|
|
2162
|
-
De && e && De((t) => pi(t, e));
|
|
2163
|
-
}
|
|
2164
|
-
}), tr = li(Qn), nr = Zn && !Qn && Xn > 0, rr = R(() => Tr(Z), [Z]), ir = !Un && !Zn && !$n && rr.isFilterNotApplied ? "A filter could not be applied to this chart." : void 0, ar = z(void 0);
|
|
2165
|
-
L(() => {
|
|
2166
|
-
ir && ar.current !== Z && (ar.current = Z, h("metric.filter_not_applied", { error_code: "FILTER_NOT_APPLIED" }));
|
|
2167
|
-
}, [ir, Z]);
|
|
2168
|
-
let or = R(() => _r({
|
|
2169
|
-
query: t?.isMetric === !1 || !t?.query ? void 0 : Be(t?.query, t?.companyId),
|
|
2170
|
-
chartType: q?.chartType,
|
|
2171
|
-
isDrilled: U.length > 0,
|
|
2172
|
-
isPythonMode: Y
|
|
2173
|
-
}), [
|
|
2174
|
-
t?.isMetric,
|
|
2175
|
-
t?.query,
|
|
2176
|
-
t?.companyId,
|
|
2177
|
-
q?.chartType,
|
|
2178
|
-
U.length,
|
|
2179
|
-
Y
|
|
2180
|
-
]), Q = R(() => da({
|
|
2181
|
-
raw: rr.rows,
|
|
2182
|
-
selectedDims: (t?.datasetMetricSettings)?.newDatasetSettings?.selectedDims,
|
|
2183
|
-
selectedMetrics: (t?.datasetMetricSettings)?.newDatasetSettings?.selectedMetrics,
|
|
2184
|
-
datasetSettings: t?.datasetMetricSettings?.newDatasetSettings,
|
|
2185
|
-
integrationName: t?.companyIntegration?.name,
|
|
2186
|
-
isPythonMode: Y,
|
|
2187
|
-
stableOrder: or
|
|
2188
|
-
}), [
|
|
2189
|
-
rr.rows,
|
|
2190
|
-
t?.datasetMetricSettings,
|
|
2191
|
-
t?.companyIntegration?.name,
|
|
2192
|
-
Y,
|
|
2193
|
-
or
|
|
2194
|
-
]), sr = R(() => ft(Z?.metaData?.truncation, Q.length), [Z, Q]), cr = R(() => st(sr), [sr]), ur = Hn || $n || rr.error;
|
|
2195
|
-
L(() => {
|
|
2196
|
-
if (!ur) return;
|
|
2197
|
-
let e = ur instanceof Error ? ur.message : oa(ur, "message"), n = oa(ur, "context");
|
|
2198
|
-
m("metric-query-error-observed", {
|
|
2199
|
-
metricId: t?.id,
|
|
2200
|
-
metricName: t?.name,
|
|
2201
|
-
chartType: q?.chartType,
|
|
2202
|
-
message: e,
|
|
2203
|
-
context: n,
|
|
2204
|
-
payload: ne(X)
|
|
2205
|
-
});
|
|
2206
|
-
}, [
|
|
2207
|
-
ur,
|
|
2208
|
-
t?.id,
|
|
2209
|
-
t?.name,
|
|
2210
|
-
q?.chartType
|
|
2211
|
-
]), L(() => {
|
|
2212
|
-
let e = X?.id;
|
|
2213
|
-
Un && De && e && De((t) => pi(t, e));
|
|
2214
|
-
}, [
|
|
2215
|
-
Un,
|
|
2216
|
-
X?.id,
|
|
2217
|
-
De
|
|
2218
|
-
]), L(() => {
|
|
2219
|
-
let e = X?.id;
|
|
2220
|
-
!Un && De && e && De((t) => mi(t, e));
|
|
2221
|
-
}, [
|
|
2222
|
-
Un,
|
|
2223
|
-
zn,
|
|
2224
|
-
De
|
|
2225
|
-
]);
|
|
2226
|
-
let { data: dr } = Kn(T, void 0, _, y), fr = R(() => dr?.weekStartDay === "sunday" ? "sunday" : "monday", [dr]), { mutate: pr } = te(), { mutateAsync: mr } = S(), hr = R(() => JSON.stringify({
|
|
2227
|
-
metricViewFilters: F?.metricViewFilters || [],
|
|
2228
|
-
xAxisSettings: F?.xAxisSettings || [],
|
|
2229
|
-
yAxisSettings: F?.yAxisSettings || []
|
|
2230
|
-
}), [
|
|
2231
|
-
F?.metricViewFilters,
|
|
2232
|
-
F?.xAxisSettings,
|
|
2233
|
-
F?.yAxisSettings
|
|
2234
|
-
]), gr = R(() => JSON.stringify(fe || []), [fe]), vr = z(F);
|
|
2235
|
-
vr.current = F;
|
|
2236
|
-
let yr = z(fe);
|
|
2237
|
-
yr.current = fe;
|
|
2238
|
-
let br = z(t?.id);
|
|
2239
|
-
br.current = t?.id, L(() => {
|
|
2240
|
-
let e = vr.current, n = yr.current, r = br.current, a = On.current !== hr, s = [...e?.metricViewFilters?.find((e) => e.id === r)?.filters?.filter((e) => !n?.find((t) => e?.name === t?.name)) || [], ...n || []];
|
|
2241
|
-
Ut((e) => {
|
|
2242
|
-
let n = t?.rlsConditions?.map((t) => {
|
|
2243
|
-
let n = e?.find((e) => e.name === t.name && e.datatype === t.datatype && e.tableName === t.tableName && e.columnName === t.columnName), r = t;
|
|
2244
|
-
if (p) {
|
|
2245
|
-
let e = Dt(r, p);
|
|
2246
|
-
if (e) {
|
|
2247
|
-
let t = r.datatype === "date" ? e.options?.find((t) => t.name === e.value) : void 0;
|
|
2248
|
-
r = {
|
|
2249
|
-
...r,
|
|
2250
|
-
filterType: "manual",
|
|
2251
|
-
value: e.value ? r.datatype === "string" && r?.filterVariant?.value === "IN" ? [e.value] : e.value : r.value,
|
|
2252
|
-
options: r.datatype === "date" ? e.options?.map((e) => ({
|
|
2253
|
-
...e,
|
|
2254
|
-
startDate: $(e.fromDate) ?? $(e.startDate) ?? void 0,
|
|
2255
|
-
endDate: $(e.toDate) ?? $(e.endDate) ?? void 0,
|
|
2256
|
-
minDate: $(e.minDate) ?? void 0,
|
|
2257
|
-
maxDate: $(e.maxDate) ?? void 0,
|
|
2258
|
-
fromDate: $(e.fromDate) ?? void 0,
|
|
2259
|
-
toDate: $(e.toDate) ?? void 0,
|
|
2260
|
-
...ia(e)
|
|
2261
|
-
})) : e.options,
|
|
2262
|
-
variableOptions: r.datatype === "date" ? e.options?.map((e) => ({
|
|
2263
|
-
range: e.range,
|
|
2264
|
-
startDate: $(e.fromDate) ?? $(e.startDate) ?? void 0,
|
|
2265
|
-
endDate: $(e.toDate) ?? $(e.endDate) ?? void 0,
|
|
2266
|
-
minDate: $(e.minDate) ?? void 0,
|
|
2267
|
-
maxDate: $(e.maxDate) ?? void 0,
|
|
2268
|
-
fromDate: $(e.fromDate) ?? void 0,
|
|
2269
|
-
toDate: $(e.toDate) ?? void 0,
|
|
2270
|
-
...ia(e),
|
|
2271
|
-
value: e.name,
|
|
2272
|
-
label: e.name
|
|
2273
|
-
})) : e.options?.map((e) => ({
|
|
2274
|
-
value: e,
|
|
2275
|
-
label: e
|
|
2276
|
-
})),
|
|
2277
|
-
selectedVariableValue: e.value ? r.datatype === "string" ? {
|
|
2278
|
-
value: e.value,
|
|
2279
|
-
label: e.value
|
|
2280
|
-
} : aa({
|
|
2281
|
-
option: t,
|
|
2282
|
-
value: e.value
|
|
2283
|
-
}) : r.selectedVariableValue
|
|
2284
|
-
};
|
|
2285
|
-
}
|
|
2286
|
-
}
|
|
2287
|
-
let c = s.find((e) => r.name === e.name);
|
|
2288
|
-
if (c && (r = {
|
|
2289
|
-
...r,
|
|
2290
|
-
...c?.client ? { client: c?.client } : {},
|
|
2291
|
-
...c?.value ? { value: c?.value } : {},
|
|
2292
|
-
...c?.selectedDropdownValue ? { selectedDropdownValue: c?.selectedDropdownValue } : {},
|
|
2293
|
-
...c?.selectedVariableValue ? { selectedVariableValue: c?.selectedVariableValue } : {},
|
|
2294
|
-
...c?.options && Array.isArray(c.options) && c.options.length ? { options: c.options } : {}
|
|
2295
|
-
}), n && !a && (r = {
|
|
2296
|
-
...r,
|
|
2297
|
-
...r?.value === void 0 && n?.value !== void 0 ? { value: n.value } : {},
|
|
2298
|
-
...r?.selectedDropdownValue === void 0 && n?.selectedDropdownValue !== void 0 ? { selectedDropdownValue: n.selectedDropdownValue } : {},
|
|
2299
|
-
...r?.selectedVariableValue === void 0 && n?.selectedVariableValue !== void 0 ? { selectedVariableValue: n.selectedVariableValue } : {}
|
|
2300
|
-
}), r?.datatype === "date" && r?.options?.find((e) => e.range === "Custom Date") && r?.isEnableDynamicDate && r?.dynamicDate?.value) {
|
|
2301
|
-
let e = A($e?.find((e) => e.value === r?.dynamicDate?.value)?.count || 0), t = Ge(e), n = Ge(e);
|
|
2302
|
-
r = {
|
|
2303
|
-
...r,
|
|
2304
|
-
options: r?.options?.map((r) => r.range === "Custom Date" ? {
|
|
2305
|
-
...r,
|
|
2306
|
-
startDate: e,
|
|
2307
|
-
endDate: e,
|
|
2308
|
-
timeGrainValue: `${t} - ${n}`
|
|
2309
|
-
} : r)
|
|
2310
|
-
};
|
|
2311
|
-
}
|
|
2312
|
-
return o === "DATABASE" ? {
|
|
2313
|
-
...r,
|
|
2314
|
-
tableName: `${i}.${t.tableName.split(".").slice(1).join(".")}`
|
|
2315
|
-
} : r;
|
|
2316
|
-
}) || [];
|
|
2317
|
-
return xe(e || [], n || []) ? e : n || [];
|
|
2318
|
-
});
|
|
2319
|
-
}, [
|
|
2320
|
-
t?.rlsConditions,
|
|
2321
|
-
p,
|
|
2322
|
-
o,
|
|
2323
|
-
i,
|
|
2324
|
-
gr,
|
|
2325
|
-
hr
|
|
2326
|
-
]), L(() => {
|
|
2327
|
-
On.current = hr;
|
|
2328
|
-
}, [hr]), L(() => {
|
|
2329
|
-
t?.id && Ie && !Y && t?.isMetric && Ie?.((e) => {
|
|
2330
|
-
let n = {
|
|
2331
|
-
filters: [...K || [], ...q?.tableSettings?.isServerSidePagination && q?.chartType === N.table ? Wt?.map((e) => e.condition)?.filter((e) => se(e)) : []],
|
|
2332
|
-
xAxisSettings: {
|
|
2333
|
-
isEnable: !!(q?.dynamicXAxis?.isEnabled || q?.enduserMeasureAndDimensions?.isEnabled) && Ue.includes(q?.chartType || ""),
|
|
2334
|
-
xaxis: q?.xAxis || ""
|
|
2335
|
-
},
|
|
2336
|
-
yAxisSettings: {
|
|
2337
|
-
isEnable: !(q?.dynamicYAxis?.isEnabled && q?.dynamicYAxis?.selectedOption && !Array.isArray(q?.dynamicYAxis?.selectedOption)),
|
|
2338
|
-
yAxis: q?.dynamicYAxis?.selectedOption || ""
|
|
2339
|
-
},
|
|
2340
|
-
id: t?.id,
|
|
2341
|
-
metricRequestData: {
|
|
2342
|
-
isAllClient: g,
|
|
2343
|
-
timeseriesSettings: Y ? void 0 : {
|
|
2344
|
-
format: q?.timeSeriesSettings?.groupBySettings?.value?.toLowerCase() || "monthly",
|
|
2345
|
-
seriesField: q?.seriesField || "",
|
|
2346
|
-
isFiscal: P === "ind"
|
|
2347
|
-
}
|
|
2348
|
-
}
|
|
2349
|
-
}, r = e?.find((e) => e.id === t?.id);
|
|
2350
|
-
return r && xe(r, n) ? e : [...e?.filter((e) => e.id !== t?.id) || [], n];
|
|
2351
|
-
});
|
|
2352
|
-
}, [
|
|
2353
|
-
t?.id,
|
|
2354
|
-
t?.isMetric,
|
|
2355
|
-
K,
|
|
2356
|
-
q?.timeSeriesSettings,
|
|
2357
|
-
q?.seriesField,
|
|
2358
|
-
Y,
|
|
2359
|
-
P,
|
|
2360
|
-
g,
|
|
2361
|
-
Wt,
|
|
2362
|
-
q?.tableSettings?.isServerSidePagination,
|
|
2363
|
-
q?.chartType,
|
|
2364
|
-
q?.dynamicYAxis,
|
|
2365
|
-
q?.dynamicXAxis
|
|
2366
|
-
]), Ui({
|
|
2367
|
-
metric: t,
|
|
2368
|
-
chartSettings: q,
|
|
2369
|
-
drillDownSettings: W,
|
|
2370
|
-
setDrillDownSettings: G,
|
|
2371
|
-
initialDrilledLevel: et,
|
|
2372
|
-
initialDrillFiltersProp: nt,
|
|
2373
|
-
initialDrillType: it,
|
|
2374
|
-
initialUnderlyingDataDrillFilters: lt
|
|
2375
|
-
}), Wi({
|
|
2376
|
-
drillUrlState: ke,
|
|
2377
|
-
metric: t,
|
|
2378
|
-
drillDownSettings: W,
|
|
2379
|
-
setDrillDownSettings: G,
|
|
2380
|
-
setChartSettings: J
|
|
2381
|
-
});
|
|
2382
|
-
let { mutateAsync: xr } = D(), Sr = R(() => JSON.stringify(n?.filters), [n?.filters]), Cr = R(() => {
|
|
2383
|
-
let e = t?.datasetMetricSettings?.metricVariables || [];
|
|
2384
|
-
if (!e || !Array.isArray(e) || !e?.length) return [];
|
|
2385
|
-
let r = [];
|
|
2386
|
-
for (let a = 0; a < e?.length; a++) {
|
|
2387
|
-
let s = e[a], c = s.type.value === "custom" && s.customQuery && s.customColumnName, l = c ? {
|
|
2388
|
-
query: ge({
|
|
2389
|
-
query: s?.customQuery || "",
|
|
2390
|
-
tenancyLevel: o,
|
|
2391
|
-
clientId: i,
|
|
2392
|
-
isAllClient: g,
|
|
2393
|
-
clientColumnType: le || "STRING",
|
|
2394
|
-
dbName: t?.companyIntegration?.name,
|
|
2395
|
-
rlsConditions: K?.filter((e) => e.isVariableFilter),
|
|
2396
|
-
globalFilters: {
|
|
2397
|
-
...n,
|
|
2398
|
-
filters: n?.filters?.filter((e) => e?.isVariableFilter && !!(Array.isArray(e?.value) ? e?.value?.length : e))
|
|
2399
|
-
},
|
|
2400
|
-
weekStartDay: fr
|
|
2401
|
-
}),
|
|
2402
|
-
alias: ae
|
|
2403
|
-
} : void 0, u = s.dependOnOptions?.length ? K?.filter((e) => s.dependOnOptions.some((t) => t.type === "metric" && t.filter?.value === e.name && t.column)) : [], d = s.dependOnOptions?.length ? n?.filters?.filter((e) => Array.isArray(e?.value) ? e?.value?.length : e && s.dependOnOptions.some((t) => t.type === "dashboard" && t.filter?.value === e.label && t.column)) : [], f = u?.map((e) => {
|
|
2404
|
-
let t = We(e);
|
|
2405
|
-
return e.datatype === "date" && t === void 0 ? null : {
|
|
2406
|
-
columnName: s.dependOnOptions.find((t) => e.name === t.filter?.value)?.column || "",
|
|
2407
|
-
value: t,
|
|
2408
|
-
as: e.datatype
|
|
2409
|
-
};
|
|
2410
|
-
}).filter(Boolean), p = d?.map((e) => {
|
|
2411
|
-
let t = e.as === "date" ? Re(e) : de(e?.value);
|
|
2412
|
-
return e.as === "date" && t === void 0 ? null : {
|
|
2413
|
-
columnName: s.dependOnOptions.find((t) => e.label === t.filter?.value)?.column || "",
|
|
2414
|
-
value: t,
|
|
2415
|
-
as: e.as
|
|
2416
|
-
};
|
|
2417
|
-
}).filter(Boolean);
|
|
2418
|
-
s.isClientScoped && i && le && !g && o === "TABLE" && s.clientColumn?.name?.value && s.clientColumn?.datatype?.value && f.push({
|
|
2419
|
-
columnName: s.clientColumn?.name?.value,
|
|
2420
|
-
value: i,
|
|
2421
|
-
as: s.clientColumn?.datatype?.value
|
|
2422
|
-
});
|
|
2423
|
-
let m = [...f, ...p];
|
|
2424
|
-
r.push({
|
|
2425
|
-
object: {
|
|
2426
|
-
wId: T,
|
|
2427
|
-
tableName: c ? "" : s?.table?.value,
|
|
2428
|
-
columnName: c ? s?.customColumnName || "" : s?.column?.value || "",
|
|
2429
|
-
filter: m,
|
|
2430
|
-
customTable: l,
|
|
2431
|
-
aggregate: c ? "" : s?.column?.aggregate || "",
|
|
2432
|
-
limit: "1",
|
|
2433
|
-
datasourceId: j,
|
|
2434
|
-
databaseName: o === "MULTI_DATABASE" && i || ""
|
|
2435
|
-
},
|
|
2436
|
-
element: s
|
|
2437
|
-
});
|
|
2438
|
-
}
|
|
2439
|
-
return r;
|
|
2440
|
-
}, [
|
|
2441
|
-
t?.datasetMetricSettings?.metricVariables,
|
|
2442
|
-
Sr,
|
|
2443
|
-
K,
|
|
2444
|
-
le,
|
|
2445
|
-
T,
|
|
2446
|
-
o,
|
|
2447
|
-
i,
|
|
2448
|
-
g,
|
|
2449
|
-
j
|
|
2450
|
-
]), wr = R(() => JSON.stringify(Cr), [Cr]), Dr = z(null), Or = z(0), Ar = z({
|
|
2451
|
-
clientId: i,
|
|
2452
|
-
encryptedClientId: y,
|
|
2453
|
-
isFrontendApp: _,
|
|
2454
|
-
token: Xe
|
|
2455
|
-
});
|
|
2456
|
-
Ar.current.clientId = i, Ar.current.encryptedClientId = y, Ar.current.isFrontendApp = _, Ar.current.token = Xe;
|
|
2457
|
-
let jr = z(xr);
|
|
2458
|
-
jr.current = xr, L(() => {
|
|
2459
|
-
Or.current += 1;
|
|
2460
|
-
let e = Or.current, t = () => Or.current !== e;
|
|
2461
|
-
if (Cr?.length) {
|
|
2462
|
-
let { clientId: e, encryptedClientId: n, isFrontendApp: r, token: i } = Ar.current;
|
|
2463
|
-
Ci({
|
|
2464
|
-
entries: Cr,
|
|
2465
|
-
fetchColumnValues: jr.current,
|
|
2466
|
-
ctx: {
|
|
2467
|
-
clientId: e,
|
|
2468
|
-
encryptedClientId: n,
|
|
2469
|
-
isFrontendApp: r,
|
|
2470
|
-
token: i
|
|
2471
|
-
},
|
|
2472
|
-
onSeed: (e) => Cn(e),
|
|
2473
|
-
onResolved: (e, t) => Cn((n) => ({
|
|
2474
|
-
...n,
|
|
2475
|
-
[e]: t
|
|
2476
|
-
})),
|
|
2477
|
-
onLoading: (e) => vt(e),
|
|
2478
|
-
onSettle: () => {
|
|
2479
|
-
Dr.current && clearTimeout(Dr.current), Dr.current = setTimeout(() => {
|
|
2480
|
-
Dr.current = null, vt(!1);
|
|
2481
|
-
}, 200);
|
|
2482
|
-
},
|
|
2483
|
-
isCancelled: t
|
|
2484
|
-
}).catch(() => {});
|
|
2485
|
-
}
|
|
2486
|
-
return () => {
|
|
2487
|
-
Or.current += 1, Dr.current &&= (clearTimeout(Dr.current), null);
|
|
2488
|
-
};
|
|
2489
|
-
}, [wr]);
|
|
2490
|
-
let Mr = R(() => (t?.datasetMetricSettings)?.newDatasetSettings?.selectedDims?.[0]?.name, [t]);
|
|
2491
|
-
R(() => Fe(t?.datasetMetricSettings?.selectedDimensions?.[U.length < t?.datasetMetricSettings?.selectedDimensions?.length ? U.length : 0] || ""), [t?.datasetMetricSettings, U]);
|
|
2492
|
-
let Nr = R(() => {
|
|
2493
|
-
let e = t?.drillDownSettings?.isEnableGroupBy;
|
|
2494
|
-
return dn ? [...V?.length ? V : [], ...kr({
|
|
2495
|
-
filters: u,
|
|
2496
|
-
metricId: t?.id,
|
|
2497
|
-
isGroupByEnabled: e,
|
|
2498
|
-
enableCrossFilterBeforeDrill: !0
|
|
2499
|
-
})] : e ? V || [] : [...V?.length ? V : [], ...u || []];
|
|
2500
|
-
}, [
|
|
2501
|
-
u,
|
|
2502
|
-
t?.id,
|
|
2503
|
-
dn,
|
|
2504
|
-
t?.drillDownSettings?.isEnableGroupBy,
|
|
2505
|
-
V
|
|
2506
|
-
]), Pr = I((e = []) => e.filter((e) => e.isAddOnMetrics).map((e) => s ? {
|
|
2507
|
-
...e,
|
|
2508
|
-
dimensionColumn: q?.xAxis || "",
|
|
2509
|
-
measureColumn: q?.yAxisList?.[0] || "",
|
|
2510
|
-
options: e.datatype === "date" ? e.options : [],
|
|
2511
|
-
variableOptions: e.datatype === "date" ? e.variableOptions : []
|
|
2512
|
-
} : {
|
|
2513
|
-
...e,
|
|
2514
|
-
dimensionColumn: q?.xAxis || "",
|
|
2515
|
-
measureColumn: q?.yAxisList?.[0] || "",
|
|
2516
|
-
value: e.isAppFilter ? e.datatype === "date" ? ze(c?.values?.[e.name], e?.datePresetOptions || e?.presetDateOptions) || (e?.options)?.find((t) => t.name === (c?.values?.[e.name] ?? e.value)) : c?.values?.[e.name] ?? e.value : e.value,
|
|
2517
|
-
options: e.datatype === "date" ? e?.options?.map((t) => P === "ind" && e.datatype === "date" ? {
|
|
2518
|
-
...t,
|
|
2519
|
-
isFiscal: !0
|
|
2520
|
-
} : t) : [],
|
|
2521
|
-
variableOptions: e.datatype === "date" ? e.variableOptions : []
|
|
2522
|
-
}).filter((e) => Mn(e)), [
|
|
2523
|
-
c?.values,
|
|
2524
|
-
P,
|
|
2525
|
-
q?.xAxis,
|
|
2526
|
-
q?.yAxisList,
|
|
2527
|
-
s,
|
|
2528
|
-
Mn
|
|
2529
|
-
]);
|
|
2530
|
-
R(() => Pr(Nr), [Pr, Nr]), L(() => {
|
|
2531
|
-
Nr?.some((e) => e.isAddOnMetrics) ? xn(Pr(Nr)) : xn([]);
|
|
2532
|
-
}, [Pr, Nr]);
|
|
2533
|
-
let Fr = R(() => q?.chartType === N.singleValue && !!q?.customSettings?.comparisonValueShow && !!q?.customSettings?.comparisonTimeGrain && !!q?.customSettings?.comparisonTimePeriod && !!q?.singleValue, [q]);
|
|
2534
|
-
L(() => {
|
|
2535
|
-
let e = Z;
|
|
2536
|
-
if (An({
|
|
2537
|
-
data: [],
|
|
2538
|
-
error: "",
|
|
2539
|
-
isLoading: !1,
|
|
2540
|
-
currentValue: ""
|
|
2541
|
-
}), q?.chartType === N.table) {
|
|
2542
|
-
let t = e?.totalRecords;
|
|
2543
|
-
typeof t == "number" && Bt(t);
|
|
2544
|
-
}
|
|
2545
|
-
m("metric-query-response-applied", {
|
|
2546
|
-
metricId: t?.id,
|
|
2547
|
-
metricName: t?.name,
|
|
2548
|
-
chartType: q?.chartType,
|
|
2549
|
-
rowCount: Q?.length || 0,
|
|
2550
|
-
columns: Object.keys(Q?.[0] || {}),
|
|
2551
|
-
totalRecords: e?.totalRecords,
|
|
2552
|
-
truncation: sr,
|
|
2553
|
-
drillConfig: C(W?.configV2)
|
|
2554
|
-
});
|
|
2555
|
-
let n = !!W?.isEnableGroupBy && !!W?.configV2?.isEnable && !!W?.configV2?.levels?.some((e) => e?.isEnable);
|
|
2556
|
-
if (t?.datasetMetricSettings?.isUseRawSQL && !(jn && n)) {
|
|
2557
|
-
let e = Object.keys(Q?.[0] || {});
|
|
2558
|
-
J((t) => ({
|
|
2559
|
-
...t,
|
|
2560
|
-
yAxisList: e.length ? e : t?.yAxisList || []
|
|
2561
|
-
}));
|
|
2562
|
-
}
|
|
2563
|
-
let r = e?.metaData;
|
|
2564
|
-
mn(Oe(r?.groupbyColumnList)), en((e) => ({
|
|
2565
|
-
...e,
|
|
2566
|
-
report: "",
|
|
2567
|
-
isLoading: e?.isLoading,
|
|
2568
|
-
isOpen: e?.isOpen
|
|
2569
|
-
}));
|
|
2570
|
-
}, [
|
|
2571
|
-
Z,
|
|
2572
|
-
t?.datasetMetricSettings,
|
|
2573
|
-
Q,
|
|
2574
|
-
sr,
|
|
2575
|
-
jn,
|
|
2576
|
-
W?.isEnableGroupBy,
|
|
2577
|
-
W?.configV2
|
|
2578
|
-
]), L(() => {
|
|
2579
|
-
t?.datasetMetricSettings?.createdSorts?.length ? Tn(!0) : Tn(!1);
|
|
2580
|
-
}, [t?.datasetMetricSettings?.createdSorts?.length]), L(() => {
|
|
2581
|
-
q?.chartType === N.timeSeries && q?.timeSeriesSettings?.groupBySettings?.value && !Y && J((e) => ({
|
|
2582
|
-
...e,
|
|
2583
|
-
xAxis: `${q?.timeSeriesSettings?.groupBySettings?.value?.toLowerCase()} of ${Mr}`
|
|
2584
|
-
}));
|
|
2585
|
-
}, [
|
|
2586
|
-
Q,
|
|
2587
|
-
q?.chartType,
|
|
2588
|
-
q?.timeSeriesSettings,
|
|
2589
|
-
Y
|
|
2590
|
-
]), L(() => {
|
|
2591
|
-
if (q?.isEnableComparisonFilter && [N.line].includes(q?.chartType)) {
|
|
2592
|
-
let e = t?.datasetMetricSettings?.newDatasetSettings?.selectedMetrics || [], n = Object?.keys(Q?.[0] || {});
|
|
2593
|
-
J((t) => ({
|
|
2594
|
-
...t,
|
|
2595
|
-
yAxisList: [...n.filter((t) => e?.some((e) => t.startsWith(e.alias)))]
|
|
2596
|
-
}));
|
|
2597
|
-
}
|
|
2598
|
-
}, [
|
|
2599
|
-
Q,
|
|
2600
|
-
q?.isEnableComparisonFilter,
|
|
2601
|
-
Vt,
|
|
2602
|
-
q?.chartType
|
|
2603
|
-
]);
|
|
2604
|
-
let Lr = I((e, n, r, i, o, s) => {
|
|
2605
|
-
ee("metric-filter-applied", {
|
|
2606
|
-
metricId: t?.id,
|
|
2607
|
-
hasCustomValue: !!i,
|
|
2608
|
-
hasStringValues: !!o?.length,
|
|
2609
|
-
stringValueCount: o?.length || 0,
|
|
2610
|
-
hasTimeGrain: !!s,
|
|
2611
|
-
rlsConditionCount: V?.length || 0
|
|
2612
|
-
}), ie?.(a, t?.id), Ut(i ? (t) => t?.map((t) => t.name === e ? {
|
|
2613
|
-
...t,
|
|
2614
|
-
value: n,
|
|
2615
|
-
options: t.options?.map((e) => n === e.name ? {
|
|
2616
|
-
...e,
|
|
2617
|
-
...i,
|
|
2618
|
-
timeGrainValue: s
|
|
2619
|
-
} : e),
|
|
2620
|
-
variableOptions: t.variableOptions?.map((e) => e.value === n ? {
|
|
2621
|
-
...e,
|
|
2622
|
-
...i,
|
|
2623
|
-
timeGrainValue: s
|
|
2624
|
-
} : e),
|
|
2625
|
-
selectedVariableValue: {
|
|
2626
|
-
value: n,
|
|
2627
|
-
label: n,
|
|
2628
|
-
endDate: i.endDate,
|
|
2629
|
-
startDate: i.startDate,
|
|
2630
|
-
...ia(i),
|
|
2631
|
-
timeGrainValue: s
|
|
2632
|
-
}
|
|
2633
|
-
} : t) : o ? (t) => t?.map((t) => t.name === e ? {
|
|
2634
|
-
...t,
|
|
2635
|
-
value: o?.length ? o?.map((e) => e.value) : void 0,
|
|
2636
|
-
selectedDropdownValue: o?.length ? o : void 0
|
|
2637
|
-
} : t) : (t) => t?.map((t) => t.name === e ? {
|
|
2638
|
-
...t,
|
|
2639
|
-
value: n,
|
|
2640
|
-
selectedVariableValue: {
|
|
2641
|
-
value: n,
|
|
2642
|
-
label: n
|
|
2643
|
-
},
|
|
2644
|
-
selectedDropdownValue: {
|
|
2645
|
-
value: n,
|
|
2646
|
-
label: r || n
|
|
2647
|
-
}
|
|
2648
|
-
} : t));
|
|
2649
|
-
}, []), zr = I((e) => {
|
|
2650
|
-
e?.event && e?.event?.event?.preventDefault(), m("chart-click-params-captured", {
|
|
2651
|
-
metricId: t?.id,
|
|
2652
|
-
metricName: t?.name,
|
|
2653
|
-
chartType: q?.chartType,
|
|
2654
|
-
name: e?.name,
|
|
2655
|
-
value: e?.value,
|
|
2656
|
-
seriesName: e?.seriesName,
|
|
2657
|
-
dataIndex: e?.dataIndex,
|
|
2658
|
-
drillConfig: C(W?.configV2)
|
|
2659
|
-
}), Jt(e);
|
|
2660
|
-
}, [
|
|
2661
|
-
t?.id,
|
|
2662
|
-
t?.name,
|
|
2663
|
-
q?.chartType,
|
|
2664
|
-
W?.configV2
|
|
2665
|
-
]), Vr = R(() => {
|
|
2666
|
-
let e = Array.isArray(Q) && Q.length && H?.name != null ? Q?.map((e) => Object.entries(e).find(([, e]) => (typeof e == "number" && typeof H?.name == "string" ? e?.toString() : e) === H.name)?.[0]).filter((e) => e)[0] : "";
|
|
2667
|
-
if (!e) return e;
|
|
2668
|
-
let n = t?.datasetMetricSettings?.newDatasetSettings, r = [...n?.selectedDims || [], ...n?.selectedMetrics || []], i = W?.configV2?.levels?.flatMap((e) => e?.dimensions || []) || [];
|
|
2669
|
-
return Qe(e, {
|
|
2670
|
-
selectedColumns: r,
|
|
2671
|
-
levelColumns: i,
|
|
2672
|
-
dbName: t?.companyIntegration?.name
|
|
2673
|
-
});
|
|
2674
|
-
}, [
|
|
2675
|
-
Q,
|
|
2676
|
-
H?.name,
|
|
2677
|
-
t?.datasetMetricSettings,
|
|
2678
|
-
t?.companyIntegration?.name,
|
|
2679
|
-
W?.configV2?.levels
|
|
2680
|
-
]), Hr = R(() => {
|
|
2681
|
-
if (!H) return;
|
|
2682
|
-
let e = q?.isMultiDimension || q?.isDynamicSeries ? q?.seriesField : void 0, t = e === "ungrouped" ? void 0 : e, n = !t && typeof H.seriesName == "string" ? H.seriesName : q?.yAxisList?.[0] || q?.singleValue, r = tt(q);
|
|
2683
|
-
return at({
|
|
2684
|
-
params: H,
|
|
2685
|
-
axisDimension: Vr ? { columnName: Vr } : void 0,
|
|
2686
|
-
seriesDimension: t ? { columnName: t } : void 0,
|
|
2687
|
-
measure: n ? { columnName: n } : void 0,
|
|
2688
|
-
formatMeasure: r ? (e) => r(e, n) : void 0
|
|
2689
|
-
});
|
|
2690
|
-
}, [
|
|
2691
|
-
H,
|
|
2692
|
-
Vr,
|
|
2693
|
-
q
|
|
2694
|
-
]), Ur = R(() => {
|
|
2695
|
-
let e = t?.datasetMetricSettings?.newDatasetSettings;
|
|
2696
|
-
return {
|
|
2697
|
-
selectedDims: e?.selectedDims,
|
|
2698
|
-
selectedMetrics: e?.selectedMetrics,
|
|
2699
|
-
levelDimensions: W?.configV2?.levels?.flatMap((e) => e?.dimensions || []) || []
|
|
2700
|
-
};
|
|
2701
|
-
}, [W?.configV2?.levels, t?.datasetMetricSettings]), Gr = I((e) => ce({
|
|
2702
|
-
filter: e,
|
|
2703
|
-
...Ur
|
|
2704
|
-
}), [Ur]), Kr = R(() => {
|
|
2705
|
-
if (sn.current !== void 0 && U === on.current) return sn.current;
|
|
2706
|
-
let e = W?.configV2?.levels?.find((e) => e?.isEnable)?.filters || [];
|
|
2707
|
-
return (e.length ? e : U).map(Gr);
|
|
2708
|
-
}, [
|
|
2709
|
-
W?.configV2?.levels,
|
|
2710
|
-
U,
|
|
2711
|
-
Gr,
|
|
2712
|
-
on,
|
|
2713
|
-
sn
|
|
2714
|
-
]), qr = R(() => ye({
|
|
2715
|
-
columnName: Vr,
|
|
2716
|
-
...Ur
|
|
2717
|
-
}), [Vr, Ur]), { getUnderlyingData: Jr } = lr({
|
|
2718
|
-
clientName: i,
|
|
2719
|
-
dbName: t?.companyIntegration?.name,
|
|
2720
|
-
tenancyType: o,
|
|
2721
|
-
values: Fn,
|
|
2722
|
-
companyId: t?.companyId,
|
|
2723
|
-
query: Be(t?.query, t?.companyId),
|
|
2724
|
-
workspaceId: T,
|
|
2725
|
-
metricId: t?.id,
|
|
2726
|
-
dashboardId: x,
|
|
2727
|
-
rlsConditions: K,
|
|
2728
|
-
globalFilters: n,
|
|
2729
|
-
isAllClient: !!g,
|
|
2730
|
-
dataMartRelationships: Pn,
|
|
2731
|
-
customSql: t?.clickActions?.underlyingData?.sql,
|
|
2732
|
-
isEnableCustomSQL: q?.chartType === N.singleValue && t?.clickActions?.underlyingData?.isEnable && t?.clickActions?.underlyingData?.sql,
|
|
2733
|
-
datasourceId: j,
|
|
2734
|
-
drillFilters: Kr,
|
|
2735
|
-
token: Xe || "",
|
|
2736
|
-
isFrontendApp: _,
|
|
2737
|
-
encryptedClientId: _ ? y || "" : i || ""
|
|
2738
|
-
}), Xr = async (e, n, r, a, s, c) => {
|
|
2739
|
-
m("drill-config-change-start", {
|
|
2740
|
-
metricId: t?.id,
|
|
2741
|
-
metricName: t?.name,
|
|
2742
|
-
clickedLevelIndex: r,
|
|
2743
|
-
isReset: !!a,
|
|
2744
|
-
clickName: n?.name,
|
|
2745
|
-
clickValue: n?.value,
|
|
2746
|
-
rowFilters: n?.rowFilters,
|
|
2747
|
-
incomingConfig: C(e),
|
|
2748
|
-
stateConfig: C(W?.configV2)
|
|
2749
|
-
});
|
|
2750
|
-
let d = t?.datasetMetricSettings;
|
|
2751
|
-
if (!e || !jn && !d?.newDatasetSettings?.configuration || !t?.companyIntegration?.name) {
|
|
2752
|
-
m("drill-config-change-skipped", {
|
|
2753
|
-
metricId: t?.id,
|
|
2754
|
-
hasStateConfig: !!W?.configV2,
|
|
2755
|
-
hasIncomingConfig: !!e,
|
|
2756
|
-
hasDatasetConfiguration: !!d?.newDatasetSettings?.configuration,
|
|
2757
|
-
integrationName: t?.companyIntegration?.name
|
|
2758
|
-
}), n && h("metric.drill_blocked", {
|
|
2759
|
-
reason: "missing-configuration",
|
|
2760
|
-
error_code: "DRILL_CONFIG_UNAVAILABLE"
|
|
2761
|
-
});
|
|
2762
|
-
return;
|
|
2763
|
-
}
|
|
2764
|
-
let f = n?.name, p = (e?.levels || []).find((e) => r ? e?.index === r : e?.isEnable), g = p?.dimensions?.[0]?.alias, _ = n?.rowFilters || [], { config: v, outcome: y } = dt({
|
|
2765
|
-
config: jn && ei(e) || e,
|
|
2766
|
-
clickedLevelIndex: r,
|
|
2767
|
-
isReset: a,
|
|
2768
|
-
clickedValue: f,
|
|
2769
|
-
rowFilters: n?.rowFilters,
|
|
2770
|
-
adhocDescent: c,
|
|
2771
|
-
enrichFilter: Gr
|
|
2772
|
-
});
|
|
2773
|
-
if (m("drill-config-level-change-resolved", {
|
|
2774
|
-
metricId: t?.id,
|
|
2775
|
-
clickedLevelIndex: r,
|
|
2776
|
-
outcome: y,
|
|
2777
|
-
filterValue: f,
|
|
2778
|
-
rowFilters: n?.rowFilters,
|
|
2779
|
-
resolvedConfig: C(v)
|
|
2780
|
-
}), y === "unrepresentable") {
|
|
2781
|
-
wt(Yr({
|
|
2782
|
-
kind: "none",
|
|
2783
|
-
reason: "blank-value"
|
|
2784
|
-
})), h("metric.drill_blocked", {
|
|
2785
|
-
reason: "blank-value",
|
|
2786
|
-
error_code: "DRILL_BLANK_VALUE"
|
|
2787
|
-
});
|
|
2788
|
-
return;
|
|
2789
|
-
}
|
|
2790
|
-
let b = v, x = [...s || [], ...ln], S = x.length ? [...d?.newDatasetSettings?.selectedDims || [], ...x] : d?.newDatasetSettings?.selectedDims;
|
|
2791
|
-
if (b = jn ? b : Ae({
|
|
2792
|
-
config: b,
|
|
2793
|
-
selectedDims: S,
|
|
2794
|
-
selectedMetrics: d?.newDatasetSettings?.selectedMetrics,
|
|
2795
|
-
previousSelectedDims: S,
|
|
2796
|
-
previousSelectedMetrics: d?.newDatasetSettings?.selectedMetrics
|
|
2797
|
-
}) || b, y === "descend" && _t(b?.levels?.find((e) => e?.isEnable))) {
|
|
2798
|
-
wt(Yr({
|
|
2799
|
-
kind: "none",
|
|
2800
|
-
reason: "level-without-measure"
|
|
2801
|
-
})), h("metric.drill_blocked", {
|
|
2802
|
-
reason: "level-without-measure",
|
|
2803
|
-
error_code: "DRILL_LEVEL_NO_MEASURE"
|
|
2804
|
-
});
|
|
2805
|
-
return;
|
|
2806
|
-
}
|
|
2807
|
-
wt(null);
|
|
2808
|
-
let w = b?.levels?.find((e) => e?.isEnable), ee = !!b?.levels?.[b?.levels?.length - 1]?.isEnable, te = b?.levels?.[0]?.isEnable, T = gt({
|
|
2809
|
-
parentSettings: q,
|
|
2810
|
-
levelSettings: w?.chartSettings,
|
|
2811
|
-
measures: w?.measures
|
|
2812
|
-
}) || q, ne = T?.chartType === N.table, E = [...w?.dimensions?.map((e) => e.alias) || [], ...w?.measures?.map((e) => e.alias) || []], D = {
|
|
2813
|
-
...T,
|
|
2814
|
-
xAxis: w?.dimensions?.[0]?.alias || "",
|
|
2815
|
-
yAxisList: ee && !T?.chartType || ne ? E : w?.measures?.map((e) => e.alias) || [],
|
|
2816
|
-
chartType: ee && !T?.chartType ? N.table : T?.chartType
|
|
2817
|
-
}, O = `${w?.dimensions?.[0]?.table?.schemaName}.${w?.dimensions?.[0]?.table?.tableName}`;
|
|
2818
|
-
if (m("drill-config-next-state-ready", {
|
|
2819
|
-
metricId: t?.id,
|
|
2820
|
-
activeLevel: {
|
|
2821
|
-
index: w?.index,
|
|
2822
|
-
name: w?.name,
|
|
2823
|
-
filters: w?.filters
|
|
2824
|
-
},
|
|
2825
|
-
isLastLevel: ee,
|
|
2826
|
-
isFirstLevelActive: te,
|
|
2827
|
-
chartType: D?.chartType,
|
|
2828
|
-
xAxis: D?.xAxis,
|
|
2829
|
-
yAxisList: D?.yAxisList,
|
|
2830
|
-
tableColumns: E,
|
|
2831
|
-
updatedConfig: C(b)
|
|
2832
|
-
}), G((e) => ({
|
|
2833
|
-
...e,
|
|
2834
|
-
configV2: {
|
|
2835
|
-
...b || {},
|
|
2836
|
-
levels: b?.levels?.map((e) => e.index === w?.index ? {
|
|
2837
|
-
...e,
|
|
2838
|
-
chartSettings: D
|
|
2839
|
-
} : e) || []
|
|
2840
|
-
}
|
|
2841
|
-
})), J((e) => D), y === "descend" || y === "adhoc-descend") {
|
|
2842
|
-
let e = It.current, t = e ? e.querySelector("[data-chart-engine=\"v2\"]") ? "v2" : "v1" : void 0;
|
|
2843
|
-
h("metric.drilled", {
|
|
2844
|
-
level: b.levels?.findIndex((e) => e.isEnable) ?? -1,
|
|
2845
|
-
...t ? { engine: t } : {}
|
|
2846
|
-
});
|
|
2847
|
-
}
|
|
2848
|
-
if (m("drill-config-state-committed", {
|
|
2849
|
-
metricId: t?.id,
|
|
2850
|
-
chartType: D?.chartType,
|
|
2851
|
-
activeLevelIndex: w?.index,
|
|
2852
|
-
drillConfig: C(b)
|
|
2853
|
-
}), fn && !jn) {
|
|
2854
|
-
let e = Rr({
|
|
2855
|
-
existing: u,
|
|
2856
|
-
isReset: a,
|
|
2857
|
-
levelIndex: r,
|
|
2858
|
-
hasCurrentLevel: !!p,
|
|
2859
|
-
filterValue: f,
|
|
2860
|
-
columnName: g,
|
|
2861
|
-
rowFilters: _,
|
|
2862
|
-
selectedDims: d?.newDatasetSettings?.selectedDims,
|
|
2863
|
-
activeLevelTableName: O,
|
|
2864
|
-
tenancyLevel: o,
|
|
2865
|
-
clientId: i,
|
|
2866
|
-
sourceMetricId: dn ? t?.id : void 0
|
|
2867
|
-
}), n = !a && !r ? Ir({
|
|
2868
|
-
columnName: g,
|
|
2869
|
-
rowFilters: _,
|
|
2870
|
-
selectedDims: d?.newDatasetSettings?.selectedDims
|
|
2871
|
-
}) : void 0;
|
|
2872
|
-
m("drill-cross-filter-state-committed", {
|
|
2873
|
-
metricId: t?.id,
|
|
2874
|
-
crossFilterCount: e?.length || 0,
|
|
2875
|
-
drillCrossFilters: e
|
|
2876
|
-
}), n ? (wt({
|
|
2877
|
-
title: "Filter unavailable",
|
|
2878
|
-
body: n
|
|
2879
|
-
}), h("metric.drill_blocked", {
|
|
2880
|
-
reason: "unresolved-column",
|
|
2881
|
-
action: "drill-cross-filter",
|
|
2882
|
-
error_code: "DRILL_COLUMN_UNAVAILABLE"
|
|
2883
|
-
})) : l?.(e);
|
|
2884
|
-
}
|
|
2885
|
-
}, Zr = ({ columnName: e, value: n, mode: r = "only" }) => {
|
|
2886
|
-
if (!fn) return;
|
|
2887
|
-
let a = t?.datasetMetricSettings, s = Ir({
|
|
2888
|
-
columnName: e,
|
|
2889
|
-
selectedDims: a?.newDatasetSettings?.selectedDims,
|
|
2890
|
-
requiresSchemaMetadata: !0
|
|
2891
|
-
});
|
|
2892
|
-
if (s) {
|
|
2893
|
-
wt({
|
|
2894
|
-
title: "Filter unavailable",
|
|
2895
|
-
body: s
|
|
2896
|
-
}), h("metric.drill_blocked", {
|
|
2897
|
-
reason: "unresolved-column",
|
|
2898
|
-
action: "dashboard-filter",
|
|
2899
|
-
error_code: "DRILL_COLUMN_UNAVAILABLE"
|
|
2900
|
-
});
|
|
2901
|
-
return;
|
|
2902
|
-
}
|
|
2903
|
-
let c = Wr({
|
|
2904
|
-
existing: u,
|
|
2905
|
-
columnName: e,
|
|
2906
|
-
value: n,
|
|
2907
|
-
mode: r,
|
|
2908
|
-
selectedDims: a?.newDatasetSettings?.selectedDims,
|
|
2909
|
-
tenancyLevel: o,
|
|
2910
|
-
clientId: i,
|
|
2911
|
-
sourceMetricId: dn ? t?.id : void 0
|
|
2912
|
-
});
|
|
2913
|
-
m("point-cross-filter-committed", {
|
|
2914
|
-
metricId: t?.id,
|
|
2915
|
-
columnName: e,
|
|
2916
|
-
mode: r,
|
|
2917
|
-
crossFilterCount: c?.length || 0
|
|
2918
|
-
}), l?.(c);
|
|
2919
|
-
}, $r = ({ columnName: e, value: n, mode: r = "only" }) => {
|
|
2920
|
-
if (!t?.id) return;
|
|
2921
|
-
let a = t?.datasetMetricSettings, s = Ir({
|
|
2922
|
-
columnName: e,
|
|
2923
|
-
selectedDims: a?.newDatasetSettings?.selectedDims,
|
|
2924
|
-
requiresSchemaMetadata: !0
|
|
2925
|
-
});
|
|
2926
|
-
if (s) {
|
|
2927
|
-
wt({
|
|
2928
|
-
title: "Filter unavailable",
|
|
2929
|
-
body: s
|
|
2930
|
-
}), h("metric.drill_blocked", {
|
|
2931
|
-
reason: "unresolved-column",
|
|
2932
|
-
action: "metric-filter",
|
|
2933
|
-
error_code: "DRILL_COLUMN_UNAVAILABLE"
|
|
2934
|
-
});
|
|
2935
|
-
return;
|
|
2936
|
-
}
|
|
2937
|
-
let c = Wr({
|
|
2938
|
-
existing: fe,
|
|
2939
|
-
columnName: e,
|
|
2940
|
-
value: n,
|
|
2941
|
-
mode: r,
|
|
2942
|
-
selectedDims: a?.newDatasetSettings?.selectedDims,
|
|
2943
|
-
tenancyLevel: o,
|
|
2944
|
-
clientId: i
|
|
2945
|
-
});
|
|
2946
|
-
m("metric-filter-committed", {
|
|
2947
|
-
metricId: t?.id,
|
|
2948
|
-
columnName: e,
|
|
2949
|
-
mode: r,
|
|
2950
|
-
filterCount: c?.length || 0
|
|
2951
|
-
}), _e?.(t.id, c);
|
|
2952
|
-
}, ti = async (e, n) => {
|
|
2953
|
-
m("drill-down-handler-start", {
|
|
2954
|
-
metricId: t?.id,
|
|
2955
|
-
metricName: t?.name,
|
|
2956
|
-
paramsName: e?.name,
|
|
2957
|
-
paramsValue: e?.value,
|
|
2958
|
-
paramsSeriesName: e?.seriesName,
|
|
2959
|
-
rowFilters: e?.rowFilters || n,
|
|
2960
|
-
drillConfig: C(W?.configV2)
|
|
2961
|
-
}), await Xr(W?.configV2, e), m("drill-down-handler-complete", {
|
|
2962
|
-
metricId: t?.id,
|
|
2963
|
-
metricName: t?.name
|
|
2964
|
-
});
|
|
2965
|
-
}, ri = async ({ dimension: e, params: n, point: r }) => {
|
|
2966
|
-
if (!e?.alias) return;
|
|
2967
|
-
let i = t?.datasetMetricSettings, a = W?.configV2, o = a?.levels || [], s = o.findIndex((e) => e?.isEnable), c = (s >= 0 ? o.slice(0, s + 1) : []).map((e) => ({
|
|
2968
|
-
...e,
|
|
2969
|
-
isEnable: !1
|
|
2970
|
-
})), l = mt({
|
|
2971
|
-
dimension: e,
|
|
2972
|
-
measures: i?.newDatasetSettings?.selectedMetrics || [],
|
|
2973
|
-
index: we(4),
|
|
2974
|
-
chartSettings: q
|
|
2975
|
-
}), u = {
|
|
2976
|
-
...a || {},
|
|
2977
|
-
isEnable: !0,
|
|
2978
|
-
levels: [...c, l]
|
|
2979
|
-
}, d = c[c.length - 1], f = {
|
|
2980
|
-
columnName: d?.dimensions?.[0]?.alias || i?.newDatasetSettings?.selectedDims?.[0]?.alias,
|
|
2981
|
-
parentFilters: d?.filters || [],
|
|
2982
|
-
pointFilters: ct(r, Gr).filters
|
|
2983
|
-
};
|
|
2984
|
-
m("adhoc-drill-start", {
|
|
2985
|
-
metricId: t?.id,
|
|
2986
|
-
dimensionAlias: e?.alias,
|
|
2987
|
-
clickedValue: n?.name,
|
|
2988
|
-
seededConfig: !a,
|
|
2989
|
-
drillConfig: C(u)
|
|
2990
|
-
}), un((t) => t.some((t) => t?.alias === e?.alias) ? t : [...t, e]), G((e) => ({
|
|
2991
|
-
...e,
|
|
2992
|
-
isEnableGroupBy: !0,
|
|
2993
|
-
configV2: u
|
|
2994
|
-
})), await Xr(u, n, void 0, !1, [e], f);
|
|
2995
|
-
}, ai = ({ filters: e, nextLevel: r, currentValue: a }) => {
|
|
2996
|
-
let o = t?.datasetMetricSettings?.newDatasetSettings, s = o?.configuration, c = o?.selectedDims || [], l = o?.selectedMetrics || [], u = t?.datasetMetricSettings?.createdSorts || [], { headerColumns: d, nonHeaderColumns: f } = c.reduce((e, t) => (q?.pivotTableSettings2?.headers?.includes(t.alias) ? e.headerColumns.push(t) : e.nonHeaderColumns.push(t), e), {
|
|
2997
|
-
headerColumns: [],
|
|
2998
|
-
nonHeaderColumns: []
|
|
2999
|
-
}), p = e?.map((e) => `${e.columnName};;${e.value}`).join(";;");
|
|
3000
|
-
An((e) => ({
|
|
3001
|
-
...e,
|
|
3002
|
-
data: e.data.filter((e) => e.key !== p),
|
|
3003
|
-
error: "",
|
|
3004
|
-
isLoading: !0,
|
|
3005
|
-
currentValue: a
|
|
3006
|
-
}));
|
|
3007
|
-
let m = f.slice(0, r), h = e?.map((e) => {
|
|
3008
|
-
let t = c.find((t) => t.alias === e.columnName || Le(t) === e.columnName);
|
|
3009
|
-
if (t) return {
|
|
3010
|
-
alias: t.alias || "",
|
|
3011
|
-
columnName: t.name,
|
|
3012
|
-
dataType: t.datatype,
|
|
3013
|
-
method: "=",
|
|
3014
|
-
parentAlias: t.parentAlias,
|
|
3015
|
-
type: "dimension",
|
|
3016
|
-
value: e.value,
|
|
3017
|
-
relationOperator: "AND"
|
|
3018
|
-
};
|
|
3019
|
-
}).filter((e) => e), g = [
|
|
3020
|
-
...m,
|
|
3021
|
-
...l,
|
|
3022
|
-
...d
|
|
3023
|
-
], { aggregates: b, dimensions: x } = Ke(g), S = He(u), C = ut(S, g), w = {
|
|
3024
|
-
...s,
|
|
3025
|
-
dimensions: x,
|
|
3026
|
-
aggregates: b,
|
|
3027
|
-
filters: [...s.filters, ...h],
|
|
3028
|
-
orders: C,
|
|
3029
|
-
isApplyGlobalFilter: !0,
|
|
3030
|
-
isApplyMetricFilter: !0,
|
|
3031
|
-
globalFilters: n,
|
|
3032
|
-
rlsConditions: K
|
|
3033
|
-
};
|
|
3034
|
-
pr({
|
|
3035
|
-
data: {
|
|
3036
|
-
configuration: w,
|
|
3037
|
-
id: T,
|
|
3038
|
-
datasourceId: j,
|
|
3039
|
-
dashboardId: "",
|
|
3040
|
-
isCreateMetric: !0
|
|
3041
|
-
},
|
|
3042
|
-
clientId: _ ? y || "" : i,
|
|
3043
|
-
token: v || "",
|
|
3044
|
-
isFrontendApp: _
|
|
3045
|
-
}, { onSuccess(e) {
|
|
3046
|
-
let n = e?.error, r = e?.data;
|
|
3047
|
-
if (n?.message) An((e) => ({
|
|
3048
|
-
...e,
|
|
3049
|
-
error: n?.message,
|
|
3050
|
-
isLoading: !1,
|
|
3051
|
-
currentValue: ""
|
|
3052
|
-
}));
|
|
3053
|
-
else {
|
|
3054
|
-
let e = ue(Array.isArray(r) ? r : [], c, l), n = ot(e);
|
|
3055
|
-
An((e) => ({
|
|
3056
|
-
data: [...e.data, {
|
|
3057
|
-
key: p,
|
|
3058
|
-
data: n
|
|
3059
|
-
}],
|
|
3060
|
-
error: "",
|
|
3061
|
-
isLoading: !1,
|
|
3062
|
-
currentValue: ""
|
|
3063
|
-
})), J((e) => ({
|
|
3064
|
-
...e,
|
|
3065
|
-
pivotTableSettings2: {
|
|
3066
|
-
...q?.pivotTableSettings2,
|
|
3067
|
-
dimensions: Ce(f, t?.companyIntegration?.name || ""),
|
|
3068
|
-
headers: Ce(d, t?.companyIntegration?.name || "")
|
|
3069
|
-
}
|
|
3070
|
-
}));
|
|
3071
|
-
}
|
|
3072
|
-
} });
|
|
3073
|
-
}, ci = I(async (e, n) => {
|
|
3074
|
-
m("drill-level-click-handler-start", {
|
|
3075
|
-
metricId: t?.id,
|
|
3076
|
-
metricName: t?.name,
|
|
3077
|
-
clickedLevelIndex: e,
|
|
3078
|
-
isReset: !!n,
|
|
3079
|
-
drillConfig: C(W?.configV2)
|
|
3080
|
-
}), n && un([]), wt(null), await Xr(W?.configV2, void 0, e, n), m("drill-level-click-handler-complete", {
|
|
3081
|
-
metricId: t?.id,
|
|
3082
|
-
metricName: t?.name,
|
|
3083
|
-
clickedLevelIndex: e,
|
|
3084
|
-
isReset: !!n
|
|
3085
|
-
});
|
|
3086
|
-
}, [
|
|
3087
|
-
W?.configV2,
|
|
3088
|
-
t?.id,
|
|
3089
|
-
t?.name,
|
|
3090
|
-
un
|
|
3091
|
-
]), vi = I((e) => {
|
|
3092
|
-
if (e) Ut((e) => [...e?.filter((e) => e.group !== `${Vt}`)]), Ht((e) => e - 1);
|
|
3093
|
-
else {
|
|
3094
|
-
let e = V.filter((e) => !e?.group)?.map((e) => ({
|
|
3095
|
-
...e,
|
|
3096
|
-
name: `${e?.name}_${Vt + 1}`,
|
|
3097
|
-
group: `${Vt + 1}`,
|
|
3098
|
-
dependOn: e.dependOn ? {
|
|
3099
|
-
value: `${e.dependOn?.value}_${Vt + 1}`,
|
|
3100
|
-
label: `${e.dependOn?.label}_${Vt + 1}`,
|
|
3101
|
-
customColumnName: e.dependOn?.customColumnName
|
|
3102
|
-
} : void 0,
|
|
3103
|
-
dependOns: e?.dependOns?.map((e) => ({
|
|
3104
|
-
value: `${e?.value}_${Vt + 1}`,
|
|
3105
|
-
label: `${e?.label}_${Vt + 1}`,
|
|
3106
|
-
customColumnName: e?.customColumnName
|
|
3107
|
-
})) || []
|
|
3108
|
-
}));
|
|
3109
|
-
e.length && (Ut((t) => [...t, ...e]), Ht((e) => e + 1));
|
|
3110
|
-
}
|
|
3111
|
-
}, [V]), yi = I(async () => {
|
|
3112
|
-
$t.report ? en((e) => ({
|
|
3113
|
-
...e,
|
|
3114
|
-
isOpen: !0
|
|
3115
|
-
})) : (en({
|
|
3116
|
-
report: "",
|
|
3117
|
-
isLoading: !0,
|
|
3118
|
-
isOpen: !0
|
|
3119
|
-
}), await mr({
|
|
3120
|
-
data: {
|
|
3121
|
-
data: Q,
|
|
3122
|
-
wId: T
|
|
3123
|
-
},
|
|
3124
|
-
clientId: _ ? y || "" : i,
|
|
3125
|
-
token: v || "",
|
|
3126
|
-
isFrontendApp: _
|
|
3127
|
-
}, {
|
|
3128
|
-
onSuccess(e) {
|
|
3129
|
-
let t = e?.content;
|
|
3130
|
-
en((e) => ({
|
|
3131
|
-
...e,
|
|
3132
|
-
report: t || "",
|
|
3133
|
-
isLoading: !1
|
|
3134
|
-
}));
|
|
3135
|
-
},
|
|
3136
|
-
onError() {
|
|
3137
|
-
en((e) => ({
|
|
3138
|
-
...e,
|
|
3139
|
-
report: "",
|
|
3140
|
-
isLoading: !1
|
|
3141
|
-
}));
|
|
3142
|
-
}
|
|
3143
|
-
}));
|
|
3144
|
-
}, [
|
|
3145
|
-
Q,
|
|
3146
|
-
i,
|
|
3147
|
-
_,
|
|
3148
|
-
v,
|
|
3149
|
-
y,
|
|
3150
|
-
i,
|
|
3151
|
-
$t
|
|
3152
|
-
]), bi = R(() => {
|
|
3153
|
-
let e = t?.datasetMetricSettings?.newDatasetSettings, n = e?.configuration, r = M(Q || []), i = r, a = e?.selectedDims?.some((e) => Ne(e?.datatype)) || Pe(Q?.[0] || ""), o = e?.selectedDims?.length > 1 && e?.selectedMetrics?.length > 0, s = [
|
|
3154
|
-
N.pivot,
|
|
3155
|
-
N.pivotV2,
|
|
3156
|
-
N.pivotV3,
|
|
3157
|
-
N.timeSeries,
|
|
3158
|
-
N.treeMap,
|
|
3159
|
-
N.indianMap,
|
|
3160
|
-
N.geoBarMap,
|
|
3161
|
-
N.geoMap,
|
|
3162
|
-
N.geoScatterMap,
|
|
3163
|
-
N.worldMap
|
|
3164
|
-
], c = !!n?.aggregates?.length && !!n?.dimensions?.length;
|
|
3165
|
-
return c && a && (i = [...r?.filter((e) => !s?.includes(e)), ...s]), c && !a && (i = [...r?.filter((e) => !s?.includes(e)), ...s?.filter((e) => e !== N.timeSeries)]), !c && a && (i = [...r?.filter((e) => !s?.includes(e)), N.timeSeries]), !c && !a && (i = r?.filter((e) => !s?.includes(e))), W?.isEnableGroupBy && W?.configV2 && (i = i?.filter((e) => me?.includes(e))), o || (i = i?.filter((e) => e !== N.bubbleV2)), i;
|
|
3166
|
-
}, [
|
|
3167
|
-
Q,
|
|
3168
|
-
q?.xAxis,
|
|
3169
|
-
W?.isEnableGroupBy,
|
|
3170
|
-
W?.configV2,
|
|
3171
|
-
t?.datasetMetricSettings?.newDatasetSettings?.configuration?.aggregates,
|
|
3172
|
-
t?.datasetMetricSettings?.newDatasetSettings?.configuration?.dimensions
|
|
3173
|
-
]), xi = (e) => {
|
|
3174
|
-
let n = t?.datasetMetricSettings?.newDatasetSettings, r = n?.configuration, i = n?.selectedDims || [], a = n?.selectedMetrics || [], o = t?.companyIntegration?.name, s = q?.enduserMeasureAndDimensions?.isEnabled;
|
|
3175
|
-
oe({
|
|
3176
|
-
chartAggregateColumns: Je(Ce(a?.filter((e) => !e || typeof e != "object" ? !1 : Er(e) && s ? q?.enduserMeasureAndDimensions?.measures?.some((t) => t.value === e.alias) : !0) || [], o), Q || []),
|
|
3177
|
-
chartDimensions: Je(Ce(i?.filter((e) => !s || q?.enduserMeasureAndDimensions?.dimensions?.some((t) => t.value === e.alias)) || [], o), Q || []),
|
|
3178
|
-
chartMetrics: Je(Ce(a?.filter((e) => !s || q?.enduserMeasureAndDimensions?.measures?.some((t) => t.value === e.alias)) || [], o), Q || []),
|
|
3179
|
-
chartSettings: q,
|
|
3180
|
-
chartTimeColumns: Ce(i?.filter((e) => Ne(e.datatype)), o),
|
|
3181
|
-
chartType: e,
|
|
3182
|
-
configAggregates: r?.aggregates,
|
|
3183
|
-
configuration: n?.configuration,
|
|
3184
|
-
dbName: o,
|
|
3185
|
-
pivotHeaderColumns: [],
|
|
3186
|
-
resultData: Q || [],
|
|
3187
|
-
setChartSettings: J
|
|
3188
|
-
});
|
|
3189
|
-
}, Si = R(() => pe(V.filter((e) => e.group && e.isAddOnMetrics && !e.isHiddenInUi && !e.isAppFilter), "group"), [V]), wi = R(() => q?.customSettings?.comparisonValueShow && q?.chartType === N.singleValue ? n?.filters?.find((e) => e?.as === "date") : void 0, [
|
|
3190
|
-
q?.customSettings?.comparisonValueShow,
|
|
3191
|
-
q?.chartType,
|
|
3192
|
-
n?.filters?.find((e) => e?.as === "date")
|
|
3193
|
-
]);
|
|
3194
|
-
L(() => {
|
|
3195
|
-
Q?.length && pn.length ? gn(!0) : gn(!1);
|
|
3196
|
-
}, [
|
|
3197
|
-
Q,
|
|
3198
|
-
pn.length,
|
|
3199
|
-
t?.integrationName,
|
|
3200
|
-
t?.query
|
|
3201
|
-
]);
|
|
3202
|
-
let Ti = R(() => t?.datasetMetricSettings?.newDatasetSettings?.selectedMetrics?.some(Er) && t?.datasetMetricSettings?.newDatasetSettings?.selectedDims?.map((e) => ({
|
|
3203
|
-
value: e.alias,
|
|
3204
|
-
label: e.alias
|
|
3205
|
-
})) || [], [t?.datasetMetricSettings?.newDatasetSettings]), Ei = R(() => t?.datasetMetricSettings?.newDatasetSettings?.selectedMetrics?.map((e) => ({
|
|
3206
|
-
value: e?.alias || e?.name,
|
|
3207
|
-
label: e?.alias || e?.name
|
|
3208
|
-
})) || [], [t?.datasetMetricSettings?.newDatasetSettings?.selectedMetrics]), Di = oi(), { metricFilters: Oi, leftPositionedMetricFilters: ki, rightPositionedMetricFilters: Ai } = R(() => {
|
|
3209
|
-
let r = Ot({
|
|
3210
|
-
rlsConditions: V,
|
|
3211
|
-
isFrontendApp: _
|
|
3212
|
-
}), a = yt({
|
|
3213
|
-
metric: {
|
|
3214
|
-
clientId: t?.clientId,
|
|
3215
|
-
isCreatedByClient: t?.isCreatedByClient
|
|
3216
|
-
},
|
|
3217
|
-
dashboard: { createdBy: e },
|
|
3218
|
-
principal: {
|
|
3219
|
-
clientId: i,
|
|
3220
|
-
isAllClient: g
|
|
3221
|
-
},
|
|
3222
|
-
tenancyLevel: o,
|
|
3223
|
-
rlsConditions: r,
|
|
3224
|
-
clientColumnType: le,
|
|
3225
|
-
dataMartTables: qe
|
|
3226
|
-
}).rls, s = a.filter((e) => e.isAddOnMetrics);
|
|
3227
|
-
Ve && (s = s.filter((e) => se(e, !0)));
|
|
3228
|
-
let c = [], l = [];
|
|
3229
|
-
return s = si(s, Di, n?.filters), s.forEach((e) => {
|
|
3230
|
-
e.position === "top-right" ? l.push(e) : c.push(e);
|
|
3231
|
-
}), {
|
|
3232
|
-
metricFilters: [...a.filter((e) => !e.isAddOnMetrics), ...s],
|
|
3233
|
-
leftPositionedMetricFilters: c,
|
|
3234
|
-
rightPositionedMetricFilters: l
|
|
3235
|
-
};
|
|
3236
|
-
}, [
|
|
3237
|
-
V,
|
|
3238
|
-
_,
|
|
3239
|
-
Ve,
|
|
3240
|
-
t?.isCreatedByClient,
|
|
3241
|
-
t?.clientId,
|
|
3242
|
-
e,
|
|
3243
|
-
o,
|
|
3244
|
-
i,
|
|
3245
|
-
g,
|
|
3246
|
-
le,
|
|
3247
|
-
qe,
|
|
3248
|
-
Di,
|
|
3249
|
-
n?.filters
|
|
3250
|
-
]), ji = [
|
|
3251
|
-
N.pie,
|
|
3252
|
-
N.doughnut,
|
|
3253
|
-
N.rose,
|
|
3254
|
-
N.funnel,
|
|
3255
|
-
N.singleValue,
|
|
3256
|
-
N.table,
|
|
3257
|
-
N.pivot,
|
|
3258
|
-
N.horizontalStackTable,
|
|
3259
|
-
N.geoBarMap,
|
|
3260
|
-
N.geoMap,
|
|
3261
|
-
N.geoScatterMap,
|
|
3262
|
-
N.sankey,
|
|
3263
|
-
N.timeSeries,
|
|
3264
|
-
N.geoBarMap,
|
|
3265
|
-
N.geoMap,
|
|
3266
|
-
N.geoScatterMap,
|
|
3267
|
-
N.worldMap,
|
|
3268
|
-
N.boxplot,
|
|
3269
|
-
N.timeSeries,
|
|
3270
|
-
N.gantt
|
|
3271
|
-
].includes(q?.chartType) || (q?.isMultiDimension || q?.isDynamicSeries) && q?.seriesField !== "ungrouped", Mi = I((e) => {
|
|
3272
|
-
let n = t?.dataSecuritySettings?.csvColumns || [];
|
|
3273
|
-
return e?.length ? e?.map((e) => {
|
|
3274
|
-
let t = {};
|
|
3275
|
-
for (let r in e) n?.includes(r) || (t[r] = e[r]);
|
|
3276
|
-
return t;
|
|
3277
|
-
}) : [];
|
|
3278
|
-
}, [t?.dataSecuritySettings]), Ni = R(() => Mi(Q), [Q, Mi]);
|
|
3279
|
-
L(() => {
|
|
3280
|
-
q || (J(t?.chartOptions), Rt({
|
|
3281
|
-
limit: parseInt(t?.chartOptions?.tableSettings?.defaultRowSize || "100", 10),
|
|
3282
|
-
offset: 0
|
|
3283
|
-
}));
|
|
3284
|
-
}, [t?.chartOptions, q]), L(() => {
|
|
3285
|
-
q?.tableSettings?.isServerSidePagination && q?.chartType === N.table && Rt({
|
|
3286
|
-
limit: parseInt(q?.tableSettings?.defaultRowSize || "100", 10),
|
|
3287
|
-
offset: 0
|
|
3288
|
-
});
|
|
3289
|
-
}, [
|
|
3290
|
-
q?.tableSettings?.isServerSidePagination,
|
|
3291
|
-
q?.chartType,
|
|
3292
|
-
q?.tableSettings?.defaultRowSize
|
|
3293
|
-
]);
|
|
3294
|
-
let Pi = z(n);
|
|
3295
|
-
Pi.current = n, L(() => {
|
|
3296
|
-
if (q?.chartType === N.timeSeries && q?.timeSeriesSettings?.groupBySettings?.isGlobalFilter && Mr) {
|
|
3297
|
-
let e = Pi.current?.filters?.find((e) => e.label === q?.timeSeriesSettings?.groupBySettings?.globalFilterOption?.value)?.value;
|
|
3298
|
-
if ((typeof e == "string" || typeof e == "object" && e?.value) && e) {
|
|
3299
|
-
let t = typeof e == "string" ? de(e)?.toLowerCase() : q?.timeSeriesSettings?.groupBySettings?.formatWithValue?.find((t) => t.value === de(e?.value))?.format?.toLowerCase() || "";
|
|
3300
|
-
bt?.find((e) => e?.value?.toLowerCase() === t) && J((e) => ({
|
|
3301
|
-
...e,
|
|
3302
|
-
timeSeriesSettings: {
|
|
3303
|
-
...e?.timeSeriesSettings,
|
|
3304
|
-
groupBySettings: {
|
|
3305
|
-
...e?.timeSeriesSettings?.groupBySettings,
|
|
3306
|
-
value: t
|
|
3307
|
-
}
|
|
3308
|
-
},
|
|
3309
|
-
xAxis: Y ? e.xAxis : `${t} of ${Mr}`
|
|
3310
|
-
}));
|
|
3311
|
-
}
|
|
3312
|
-
}
|
|
3313
|
-
}, [
|
|
3314
|
-
Sr,
|
|
3315
|
-
q?.chartType,
|
|
3316
|
-
q?.timeSeriesSettings?.groupBySettings?.isGlobalFilter,
|
|
3317
|
-
q?.timeSeriesSettings?.groupBySettings?.globalFilterOption,
|
|
3318
|
-
Mr
|
|
3319
|
-
]), L(() => {
|
|
3320
|
-
q?.isDynamicSeries && (q?.seriesOptions?.includes("ungrouped") ? q?.ungroupedAlias ? Dn(q?.seriesOptions?.map((e) => e === "ungrouped" ? {
|
|
3321
|
-
value: e,
|
|
3322
|
-
label: q?.ungroupedAlias
|
|
3323
|
-
} : {
|
|
3324
|
-
value: e,
|
|
3325
|
-
label: e
|
|
3326
|
-
})) : Dn(q?.seriesOptions?.map((e) => ({
|
|
3327
|
-
value: e,
|
|
3328
|
-
label: e
|
|
3329
|
-
}))) : Dn([...q?.seriesOptions?.map((e) => ({
|
|
3330
|
-
value: e,
|
|
3331
|
-
label: e
|
|
3332
|
-
})) ?? []]));
|
|
3333
|
-
}, [
|
|
3334
|
-
q?.seriesOptions,
|
|
3335
|
-
q?.isDynamicSeries,
|
|
3336
|
-
q?.ungroupedAlias
|
|
3337
|
-
]);
|
|
3338
|
-
let [Fi, Ii] = B(!1), Li = (e) => {
|
|
3339
|
-
e.key === "Control" && Ii(!0);
|
|
3340
|
-
}, Ri = (e) => {
|
|
3341
|
-
e.key === "Control" && Ii(!1);
|
|
3342
|
-
};
|
|
3343
|
-
L(() => {
|
|
3344
|
-
Q?.length && Qt(Object.keys(Q?.[0] || {}));
|
|
3345
|
-
}, [Q?.length]), L(() => (q?.customSettings?.chartZoom?.isZoomEnabled && (window.addEventListener("keydown", Li), window.addEventListener("keyup", Ri)), () => {
|
|
3346
|
-
window.removeEventListener("keydown", Li), window.removeEventListener("keyup", Ri);
|
|
3347
|
-
}), []);
|
|
3348
|
-
let zi = R(() => {
|
|
3349
|
-
let e = !1;
|
|
3350
|
-
if (Q?.length) {
|
|
3351
|
-
let t = q?.singleValue;
|
|
3352
|
-
e = Q[0][t] === null && q?.chartType === N.singleValue;
|
|
3353
|
-
}
|
|
3354
|
-
return e;
|
|
3355
|
-
}, [
|
|
3356
|
-
Q?.length,
|
|
3357
|
-
q?.singleValue,
|
|
3358
|
-
q?.chartType === N.singleValue
|
|
3359
|
-
]), Bi = R(() => rt({
|
|
3360
|
-
chartOptions: q,
|
|
3361
|
-
data: Q || []
|
|
3362
|
-
}), [
|
|
3363
|
-
Q,
|
|
3364
|
-
q?.xAxis,
|
|
3365
|
-
q?.yAxisList,
|
|
3366
|
-
q?.dynamicXAxis?.isEnabled,
|
|
3367
|
-
q?.chartType,
|
|
3368
|
-
q?.seriesField,
|
|
3369
|
-
q?.customSettings?.cumulativeBar,
|
|
3370
|
-
q?.isGroupXAxis,
|
|
3371
|
-
q?.timeSeriesSettings?.seriesType[0],
|
|
3372
|
-
q?.timeSeriesSettings?.groupBySettings?.fillXAxis
|
|
3373
|
-
]), Vi = R(() => he({
|
|
3374
|
-
text: ve(t?.name || "", Sn) || "",
|
|
3375
|
-
selectedLanguage: be,
|
|
3376
|
-
translationDictionary: Se
|
|
3377
|
-
}), [
|
|
3378
|
-
t?.name,
|
|
3379
|
-
Sn,
|
|
3380
|
-
Se,
|
|
3381
|
-
be
|
|
3382
|
-
]), qi = R(() => he({
|
|
3383
|
-
text: ve(t?.longDescription || "", Sn) || "",
|
|
3384
|
-
selectedLanguage: be,
|
|
3385
|
-
translationDictionary: Se
|
|
3386
|
-
}), [
|
|
3387
|
-
t?.longDescription,
|
|
3388
|
-
Sn,
|
|
3389
|
-
be,
|
|
3390
|
-
Se
|
|
3391
|
-
]), Ji = R(() => he({
|
|
3392
|
-
text: ve(t?.description || "", Sn) || "",
|
|
3393
|
-
selectedLanguage: be,
|
|
3394
|
-
translationDictionary: Se
|
|
3395
|
-
}), [
|
|
3396
|
-
t?.description,
|
|
3397
|
-
Sn,
|
|
3398
|
-
be,
|
|
3399
|
-
Se
|
|
3400
|
-
]), Yi = R(() => he({
|
|
3401
|
-
text: ve(t?.footNote || "", Sn) || "",
|
|
3402
|
-
selectedLanguage: be,
|
|
3403
|
-
translationDictionary: Se
|
|
3404
|
-
}), [
|
|
3405
|
-
t?.footNote,
|
|
3406
|
-
Sn,
|
|
3407
|
-
be,
|
|
3408
|
-
Se
|
|
3409
|
-
]), Xi = R(() => `${Q?.[0]?.dbn_metric_expression_data || "No Data Found"}`, [Q]), Zi = R(() => t?.rlsConditions?.map((e) => {
|
|
3410
|
-
if (e?.datatype === "date" && e?.options?.find((e) => e.range === "Custom Date") && e?.isEnableDynamicDate && e?.dynamicDate?.value) {
|
|
3411
|
-
let t = A($e?.find((t) => t.value === e?.dynamicDate?.value)?.count || 0), n = Ge(t), r = Ge(t);
|
|
3412
|
-
return {
|
|
3413
|
-
...e,
|
|
3414
|
-
options: e?.options?.map((e) => e.range === "Custom Date" ? {
|
|
3415
|
-
...e,
|
|
3416
|
-
startDate: t,
|
|
3417
|
-
endDate: t,
|
|
3418
|
-
timeGrainValue: `${n} - ${r}`
|
|
3419
|
-
} : e)
|
|
3420
|
-
};
|
|
3421
|
-
}
|
|
3422
|
-
return e;
|
|
3423
|
-
}), [t?.rlsConditions]);
|
|
3424
|
-
Ct(() => {
|
|
3425
|
-
if (Qn && O?.((e) => {
|
|
3426
|
-
if (ui(e?.get(t?.id), qn)) return e;
|
|
3427
|
-
let n = new Map(e);
|
|
3428
|
-
return n.set(t?.id, {
|
|
3429
|
-
data: {
|
|
3430
|
-
data: [],
|
|
3431
|
-
name: "",
|
|
3432
|
-
description: ""
|
|
3433
|
-
},
|
|
3434
|
-
isLoading: Qn,
|
|
3435
|
-
key: qn
|
|
3436
|
-
}), n;
|
|
3437
|
-
}), Z?.data && E) {
|
|
3438
|
-
let e = pa(t?.id, k) ? Z?.data : void 0;
|
|
3439
|
-
O?.((n) => {
|
|
3440
|
-
if (hi(n?.get(t?.id), {
|
|
3441
|
-
data: e,
|
|
3442
|
-
name: t?.name || "",
|
|
3443
|
-
description: t?.description || "",
|
|
3444
|
-
isLoading: Qn,
|
|
3445
|
-
key: qn
|
|
3446
|
-
})) return n;
|
|
3447
|
-
let r = new Map(n);
|
|
3448
|
-
return r.set(t?.id, {
|
|
3449
|
-
data: {
|
|
3450
|
-
data: e,
|
|
3451
|
-
name: t?.name || "",
|
|
3452
|
-
description: t?.description || ""
|
|
3453
|
-
},
|
|
3454
|
-
isLoading: Qn,
|
|
3455
|
-
key: qn
|
|
3456
|
-
}), r;
|
|
3457
|
-
});
|
|
3458
|
-
}
|
|
3459
|
-
if (!Qn && ur) {
|
|
3460
|
-
let e = gi(t);
|
|
3461
|
-
O?.((n) => {
|
|
3462
|
-
let r = n?.get(t?.id);
|
|
3463
|
-
if (r && !r.isLoading && !!r.error === e && r.key === qn) return n;
|
|
3464
|
-
let i = new Map(n);
|
|
3465
|
-
return i.set(t?.id, {
|
|
3466
|
-
data: r?.data ?? {
|
|
3467
|
-
data: [],
|
|
3468
|
-
name: "",
|
|
3469
|
-
description: ""
|
|
3470
|
-
},
|
|
3471
|
-
isLoading: !1,
|
|
3472
|
-
key: qn,
|
|
3473
|
-
...e ? { error: "failed" } : {}
|
|
3474
|
-
}), i;
|
|
3475
|
-
});
|
|
3476
|
-
}
|
|
3477
|
-
}, [
|
|
3478
|
-
Z?.data,
|
|
3479
|
-
Qn,
|
|
3480
|
-
qn,
|
|
3481
|
-
ur
|
|
3482
|
-
]), Gi({
|
|
3483
|
-
metric: t,
|
|
3484
|
-
metricStore: E,
|
|
3485
|
-
setMetricStore: O
|
|
3486
|
-
});
|
|
3487
|
-
let Qi = Ki({
|
|
3488
|
-
metric: t,
|
|
3489
|
-
metricStore: E
|
|
3490
|
-
});
|
|
3491
|
-
Ct(() => {
|
|
3492
|
-
Ft.current !== Jn && (Ft.current = Jn, At());
|
|
3493
|
-
}, [Jn, At]);
|
|
3494
|
-
let $i = () => !!t?.elementSettings?.summary?.metricList?.some((e) => E?.get(e.value)?.isLoading === !0);
|
|
3495
|
-
Ct(() => {
|
|
3496
|
-
let e = t?.elementSettings?.summary;
|
|
3497
|
-
if (!e?.metricList?.length || !E?.get(t?.id)) return;
|
|
3498
|
-
let n = e.metricList.map((e) => E.get(e.value));
|
|
3499
|
-
if (n.some((e) => e?.isLoading)) return;
|
|
3500
|
-
let r = JSON.stringify({
|
|
3501
|
-
keys: n.map((e) => [e?.key, !!e?.data?.data?.length]),
|
|
3502
|
-
prompt: e.summaryPrompt,
|
|
3503
|
-
id: t?.id,
|
|
3504
|
-
identity: Jn
|
|
3505
|
-
}), a = n.map((e) => ({
|
|
3506
|
-
data: e?.data?.data || [],
|
|
3507
|
-
metricName: e?.data?.name,
|
|
3508
|
-
metricDescription: e?.data?.description
|
|
3509
|
-
})), o = a.every((e) => e.data.length > 0);
|
|
3510
|
-
Et(r, o ? (r) => xt.mutateAsync({
|
|
3511
|
-
signal: r,
|
|
3512
|
-
data: {
|
|
3513
|
-
metricData: a,
|
|
3514
|
-
summaryPrompt: e.summaryPrompt,
|
|
3515
|
-
id: t?.id,
|
|
3516
|
-
filters: n.map((e) => e?.key).join("###"),
|
|
3517
|
-
name: t?.name,
|
|
3518
|
-
description: t?.description,
|
|
3519
|
-
workspaceId: T
|
|
3520
|
-
},
|
|
3521
|
-
token: v || "",
|
|
3522
|
-
clientId: _ ? y || "" : i,
|
|
3523
|
-
isFrontendApp: _
|
|
3524
|
-
}) : void 0);
|
|
3525
|
-
}, [
|
|
3526
|
-
t?.elementSettings,
|
|
3527
|
-
t?.id,
|
|
3528
|
-
t?.name,
|
|
3529
|
-
t?.description,
|
|
3530
|
-
E,
|
|
3531
|
-
Qi,
|
|
3532
|
-
Jn,
|
|
3533
|
-
Et,
|
|
3534
|
-
xt,
|
|
3535
|
-
T,
|
|
3536
|
-
v,
|
|
3537
|
-
_,
|
|
3538
|
-
y,
|
|
3539
|
-
i
|
|
3540
|
-
]), L(() => {
|
|
3541
|
-
let e = ht(q?.customSettings?.comboAxisSettings || []), t = e?.flatMap((e) => e?.measures), n = q?.yAxisList?.every((e) => t?.includes(e));
|
|
3542
|
-
if (q?.yAxisList?.length && q?.yAxisList?.length !== t?.length && !t?.length && [
|
|
3543
|
-
N.combo,
|
|
3544
|
-
N.timeSeries,
|
|
3545
|
-
N.horizontalCombo
|
|
3546
|
-
].includes(q?.chartType || "")) {
|
|
3547
|
-
let e = q?.yAxisList?.filter((e) => !q?.comboBarList?.includes(e))?.filter((e) => !t?.includes(e)), n = q?.customSettings?.comboStackAxisSymbols?.name || "", r = q?.customSettings?.comboLabelFormatter?.find((e) => e.axis === (n || "stack"))?.formatter, i = q?.comboBarList?.join(" and "), a = q?.customSettings?.comboLabelFormatter?.find((e) => e.axis === i)?.formatter;
|
|
3548
|
-
J((t) => ({
|
|
3549
|
-
...t,
|
|
3550
|
-
customSettings: {
|
|
3551
|
-
...t.customSettings,
|
|
3552
|
-
comboAxisSettings: ht([
|
|
3553
|
-
...t.customSettings?.comboAxisSettings || [],
|
|
3554
|
-
...e?.map((e) => {
|
|
3555
|
-
let t = q?.customSettings?.comboLabelFormatter?.find((t) => t.axis === e)?.formatter, n = q?.customSettings?.comboAxisSymbols?.find((t) => t.name === e);
|
|
3556
|
-
return {
|
|
3557
|
-
axis: e,
|
|
3558
|
-
measures: [e],
|
|
3559
|
-
chartTypes: [{
|
|
3560
|
-
axis: e,
|
|
3561
|
-
type: "line"
|
|
3562
|
-
}],
|
|
3563
|
-
numberFormatter: q?.customSettings?.numberFormatter,
|
|
3564
|
-
labelFormatter: t,
|
|
3565
|
-
prefix: n?.prefix || "",
|
|
3566
|
-
suffix: n?.suffix || "",
|
|
3567
|
-
isEnableLabelFormatter: !!t?.length
|
|
3568
|
-
};
|
|
3569
|
-
}),
|
|
3570
|
-
...q?.comboBarList?.length && (q?.customSettings?.isCombineBarAxis || q?.customSettings?.isStackBar) ? [{
|
|
3571
|
-
axis: q?.customSettings?.isStackBar && n || i,
|
|
3572
|
-
measures: q?.comboBarList,
|
|
3573
|
-
chartTypes: q?.comboBarList?.map((e) => ({
|
|
3574
|
-
axis: e,
|
|
3575
|
-
type: "bar"
|
|
3576
|
-
})),
|
|
3577
|
-
isEnableStackBar: q?.customSettings?.isStackBar,
|
|
3578
|
-
numberFormatter: q?.customSettings?.numberFormatter,
|
|
3579
|
-
...q?.customSettings?.isStackBar ? {
|
|
3580
|
-
prefix: q?.customSettings?.comboStackAxisSymbols?.prefix || "",
|
|
3581
|
-
suffix: q?.customSettings?.comboStackAxisSymbols?.suffix || "",
|
|
3582
|
-
labelFormatter: r,
|
|
3583
|
-
isEnableLabelFormatter: !!r?.length
|
|
3584
|
-
} : {
|
|
3585
|
-
prefix: q?.customSettings?.combinedAxisPrefix || "",
|
|
3586
|
-
suffix: q?.customSettings?.combinedAxisSuffix || "",
|
|
3587
|
-
labelFormatter: a,
|
|
3588
|
-
isEnableLabelFormatter: !!a?.length
|
|
3589
|
-
}
|
|
3590
|
-
}] : [],
|
|
3591
|
-
...q?.comboBarList?.length && !q?.customSettings?.isCombineBarAxis && !q?.customSettings?.isStackBar ? q?.comboBarList?.map((e) => {
|
|
3592
|
-
let t = q?.customSettings?.comboLabelFormatter?.find((t) => t.axis === e)?.formatter, n = q?.customSettings?.comboAxisSymbols?.find((t) => t.name === e);
|
|
3593
|
-
return {
|
|
3594
|
-
axis: e,
|
|
3595
|
-
measures: [e],
|
|
3596
|
-
chartTypes: [{
|
|
3597
|
-
axis: e,
|
|
3598
|
-
type: "bar"
|
|
3599
|
-
}],
|
|
3600
|
-
numberFormatter: q?.customSettings?.numberFormatter,
|
|
3601
|
-
labelFormatter: t,
|
|
3602
|
-
prefix: n?.prefix || "",
|
|
3603
|
-
suffix: n?.suffix || "",
|
|
3604
|
-
isEnableLabelFormatter: !!t?.length
|
|
3605
|
-
};
|
|
3606
|
-
}) : []
|
|
3607
|
-
].filter((e) => e?.measures?.length)),
|
|
3608
|
-
comboAxisSymbols: [],
|
|
3609
|
-
combinedAxisPrefix: "",
|
|
3610
|
-
combinedAxisSuffix: "",
|
|
3611
|
-
comboLabelFormatter: [],
|
|
3612
|
-
comboStackAxisSymbols: void 0,
|
|
3613
|
-
isCombineBarAxis: !1,
|
|
3614
|
-
isStackBar: !1
|
|
3615
|
-
},
|
|
3616
|
-
comboBarList: []
|
|
3617
|
-
}));
|
|
3618
|
-
}
|
|
3619
|
-
if (t?.length && q?.yAxisList?.length && (q?.yAxisList?.length !== t?.length || q?.yAxisList?.length === t?.length && !n) && [
|
|
3620
|
-
N.combo,
|
|
3621
|
-
N.timeSeries,
|
|
3622
|
-
N.horizontalCombo
|
|
3623
|
-
].includes(q?.chartType || "")) {
|
|
3624
|
-
let e = q?.yAxisList?.filter((e) => !t?.includes(e));
|
|
3625
|
-
(t?.filter((e) => !q?.yAxisList?.includes(e)))?.forEach((e) => {
|
|
3626
|
-
let t = q?.customSettings?.comboAxisSettings?.find((t) => t.measures?.includes(e)), n = t?.axis, r = (t?.measures?.length || 0) > 1;
|
|
3627
|
-
J((t) => ({
|
|
3628
|
-
...t,
|
|
3629
|
-
customSettings: {
|
|
3630
|
-
...t.customSettings,
|
|
3631
|
-
comboAxisSettings: ht(r ? t.customSettings?.comboAxisSettings?.map((t) => t.axis === n ? {
|
|
3632
|
-
...t,
|
|
3633
|
-
measures: t?.measures?.filter((t) => t !== e)
|
|
3634
|
-
} : t)?.filter((e) => e?.measures?.length) || [] : t.customSettings?.comboAxisSettings?.filter((e) => e.axis !== n && e?.measures?.length) || [])
|
|
3635
|
-
}
|
|
3636
|
-
}));
|
|
3637
|
-
}), e?.length && J((t) => ({
|
|
3638
|
-
...t,
|
|
3639
|
-
customSettings: {
|
|
3640
|
-
...t.customSettings,
|
|
3641
|
-
comboAxisSettings: ht([...t.customSettings?.comboAxisSettings || [], ...e?.map((e) => ({
|
|
3642
|
-
axis: e,
|
|
3643
|
-
measures: [e],
|
|
3644
|
-
chartTypes: [{
|
|
3645
|
-
axis: e,
|
|
3646
|
-
type: "line"
|
|
3647
|
-
}]
|
|
3648
|
-
}))].filter((e) => e?.measures?.length) || [])
|
|
3649
|
-
}
|
|
3650
|
-
}));
|
|
3651
|
-
}
|
|
3652
|
-
t?.length && q?.yAxisList?.length && q?.yAxisList?.length === t?.length && n && [
|
|
3653
|
-
N.combo,
|
|
3654
|
-
N.timeSeries,
|
|
3655
|
-
N.horizontalCombo
|
|
3656
|
-
].includes(q?.chartType || "") && q?.customSettings?.comboAxisSettings?.length !== e?.length && J((t) => ({
|
|
3657
|
-
...t,
|
|
3658
|
-
customSettings: {
|
|
3659
|
-
...t?.customSettings,
|
|
3660
|
-
comboAxisSettings: e
|
|
3661
|
-
}
|
|
3662
|
-
}));
|
|
3663
|
-
}, [
|
|
3664
|
-
q?.yAxisList,
|
|
3665
|
-
q?.customSettings?.comboAxisSettings,
|
|
3666
|
-
q?.comboBarList,
|
|
3667
|
-
q?.customSettings?.isCombineBarAxis,
|
|
3668
|
-
q?.customSettings?.isStackBar,
|
|
3669
|
-
q?.customSettings?.comboStackAxisSymbols?.name,
|
|
3670
|
-
q?.customSettings?.comboStackAxisSymbols?.prefix,
|
|
3671
|
-
q?.customSettings?.comboStackAxisSymbols?.suffix,
|
|
3672
|
-
q?.customSettings?.comboLabelFormatter,
|
|
3673
|
-
q?.customSettings?.comboAxisSymbols,
|
|
3674
|
-
q?.customSettings?.numberFormatter,
|
|
3675
|
-
q?.customSettings?.combinedAxisPrefix,
|
|
3676
|
-
q?.customSettings?.combinedAxisSuffix,
|
|
3677
|
-
q?.chartType
|
|
3678
|
-
]), L(() => {
|
|
3679
|
-
q?.yAxisList?.length && q?.yAxisList?.length < 5 && q?.chartType === N.boxplot && J((e) => ({
|
|
3680
|
-
...e,
|
|
3681
|
-
chartType: N.line
|
|
3682
|
-
})), !q?.yAxisList?.length && q?.chartType === N.funnelV2 && J((e) => ({
|
|
3683
|
-
...e,
|
|
3684
|
-
chartType: N.singleValue
|
|
3685
|
-
}));
|
|
3686
|
-
}, [q?.chartType, q?.yAxisList?.length]);
|
|
3687
|
-
let ea = ({ columnAlias: e, value: n, isClear: r = !1 }) => {
|
|
3688
|
-
let i = t?.datasetMetricSettings;
|
|
3689
|
-
i && Ze({
|
|
3690
|
-
columnAlias: e,
|
|
3691
|
-
datasetSettings: i,
|
|
3692
|
-
setTableColumnFilters: Gt,
|
|
3693
|
-
value: n,
|
|
3694
|
-
isClear: r
|
|
3695
|
-
});
|
|
3696
|
-
};
|
|
3697
|
-
L(() => {
|
|
3698
|
-
if (!q?.dynamicYAxis?.isEnabled || !q?.dynamicYAxis?.selectedOption || Array.isArray(q?.dynamicYAxis?.selectedOption)) return;
|
|
3699
|
-
let e = q?.dynamicYAxis?.selectedOption;
|
|
3700
|
-
J((t) => ({
|
|
3701
|
-
...t,
|
|
3702
|
-
dynamicYAxis: {
|
|
3703
|
-
...t?.dynamicYAxis,
|
|
3704
|
-
selectedOption: [e]
|
|
3705
|
-
},
|
|
3706
|
-
yAxisList: [e?.value]
|
|
3707
|
-
}));
|
|
3708
|
-
}, [q?.dynamicYAxis?.selectedOption, q?.dynamicYAxis?.isEnabled]), L(() => {
|
|
3709
|
-
let e = F?.yAxisSettings?.find((e) => e?.yAxisSettings?.isEnable && e?.id === t?.id && e?.yAxisSettings?.yAxis && Array.isArray(e?.yAxisSettings?.yAxis) && e?.yAxisSettings?.yAxis?.length > 0), n = F?.xAxisSettings?.find((e) => e?.xAxisSettings?.isEnable && e?.id === t?.id && e?.xAxisSettings?.xaxis), r = W?.configV2?.levels?.length ? W : t?.drillDownSettings, i = ua(t?.chartOptions, r), a = i !== t?.chartOptions;
|
|
3710
|
-
if (!q?.dynamicYAxis?.isEnabled && !q?.dynamicXAxis?.isEnabled && !a || !e && !n && !a) {
|
|
3711
|
-
J((e) => t?.chartOptions || e);
|
|
3712
|
-
return;
|
|
3713
|
-
}
|
|
3714
|
-
let o = e?.yAxisSettings?.yAxis?.[0];
|
|
3715
|
-
J((e) => {
|
|
3716
|
-
let t = a ? {
|
|
3717
|
-
...e,
|
|
3718
|
-
...i
|
|
3719
|
-
} : e;
|
|
3720
|
-
return {
|
|
3721
|
-
...t,
|
|
3722
|
-
dynamicYAxis: {
|
|
3723
|
-
...t?.dynamicYAxis,
|
|
3724
|
-
selectedOption: o ? [o] : t?.dynamicYAxis?.selectedOption || []
|
|
3725
|
-
},
|
|
3726
|
-
dynamicXAxis: {
|
|
3727
|
-
...t?.dynamicXAxis,
|
|
3728
|
-
selectedOption: n?.xAxisSettings?.xaxis ? {
|
|
3729
|
-
value: n?.xAxisSettings?.xaxis,
|
|
3730
|
-
label: n?.xAxisSettings?.xaxis
|
|
3731
|
-
} : t?.dynamicXAxis?.selectedOption || []
|
|
3732
|
-
},
|
|
3733
|
-
yAxisList: o?.value ? [o?.value] : t?.yAxisList || [],
|
|
3734
|
-
xAxis: n?.xAxisSettings?.xaxis ? n?.xAxisSettings?.xaxis : t?.xAxis || ""
|
|
3735
|
-
};
|
|
3736
|
-
});
|
|
3737
|
-
}, [
|
|
3738
|
-
F?.yAxisSettings,
|
|
3739
|
-
t?.id,
|
|
3740
|
-
F?.xAxisSettings,
|
|
3741
|
-
q?.dynamicYAxis?.isEnabled,
|
|
3742
|
-
q?.dynamicXAxis?.isEnabled,
|
|
3743
|
-
W,
|
|
3744
|
-
W?.configV2?.isEnable,
|
|
3745
|
-
W?.configV2?.levels,
|
|
3746
|
-
t?.chartOptions,
|
|
3747
|
-
t?.drillDownSettings
|
|
3748
|
-
]), L(() => {
|
|
3749
|
-
q?.customSettings?.isShowDuration && q?.chartType === N.gantt && !q?.customSettings?.ganttTooltipKeys?.includes("Duration") && J((e) => ({
|
|
3750
|
-
...e,
|
|
3751
|
-
customSettings: {
|
|
3752
|
-
...e?.customSettings,
|
|
3753
|
-
ganttTooltipKeys: [...e?.customSettings?.ganttTooltipKeys || [], "Duration"]
|
|
3754
|
-
}
|
|
3755
|
-
}));
|
|
3756
|
-
}, [
|
|
3757
|
-
q?.customSettings?.isShowDuration,
|
|
3758
|
-
q?.chartType,
|
|
3759
|
-
q?.customSettings?.ganttTooltipKeys
|
|
3760
|
-
]);
|
|
3761
|
-
let ta = R(() => t?.datasetMetricSettings?.selectedDimensions?.map((e) => Fe(e || "none")) || la, [t?.datasetMetricSettings?.selectedDimensions]);
|
|
3762
|
-
return {
|
|
3763
|
-
drillBlockedNotice: St,
|
|
3764
|
-
filterNotAppliedNotice: ir,
|
|
3765
|
-
dismissDrillBlockedNotice: () => wt(null),
|
|
3766
|
-
elementSummary: jt,
|
|
3767
|
-
elementSummaryError: Mt,
|
|
3768
|
-
elementSummaryEmpty: Nt,
|
|
3769
|
-
isLoadingSummary: Pt,
|
|
3770
|
-
stopSummary: kt,
|
|
3771
|
-
isMetricListLoading: $i,
|
|
3772
|
-
onDrillLevelClick: ci,
|
|
3773
|
-
onDrillDown: ti,
|
|
3774
|
-
onFilterDashboardTo: Zr,
|
|
3775
|
-
onFilterMetricTo: $r,
|
|
3776
|
-
handleChartClick: zr,
|
|
3777
|
-
dataDb: Q,
|
|
3778
|
-
truncation: sr,
|
|
3779
|
-
truncationNotice: cr,
|
|
3780
|
-
getUnderlyingData: Jr,
|
|
3781
|
-
onChangeFilterValue: Lr,
|
|
3782
|
-
isShowChartPopup: Kt,
|
|
3783
|
-
setShowChartPopup: qt,
|
|
3784
|
-
columnName: Vr,
|
|
3785
|
-
underlyingDataPoint: Hr,
|
|
3786
|
-
chartParams: H,
|
|
3787
|
-
isQueryLoading: !Hn && (Qn || pt || tr || Ee && (!Q?.length || zi)),
|
|
3788
|
-
isMetricUpdating: nr,
|
|
3789
|
-
isSingleValueNull: zi,
|
|
3790
|
-
dynamicOptions: En,
|
|
3791
|
-
chartSettings: q,
|
|
3792
|
-
setChartSettings: J,
|
|
3793
|
-
isEnableZoom: Fi,
|
|
3794
|
-
filterValues: Fn,
|
|
3795
|
-
containerRef: It,
|
|
3796
|
-
drilledLevel: U.length,
|
|
3797
|
-
dimensions: ta,
|
|
3798
|
-
rlsConditions: V,
|
|
3799
|
-
setRlsConditions: Ut,
|
|
3800
|
-
setTableLimit: Rt,
|
|
3801
|
-
isEnableNextBtn: zt > Lt?.limit + Lt?.offset,
|
|
3802
|
-
isEnablePrevBtn: Lt?.offset !== 0,
|
|
3803
|
-
paginationInfo: {
|
|
3804
|
-
limit: Lt?.limit,
|
|
3805
|
-
offset: Lt?.offset,
|
|
3806
|
-
totalRecords: zt
|
|
3807
|
-
},
|
|
3808
|
-
onChangePage: (e, t, n) => {
|
|
3809
|
-
Rt(t ? {
|
|
3810
|
-
limit: t,
|
|
3811
|
-
offset: 0
|
|
3812
|
-
} : (t) => {
|
|
3813
|
-
let r;
|
|
3814
|
-
return r = n || n === 0 ? n : e ? t.offset > t.limit ? t.offset - t.limit : 0 : t.offset + t.limit, {
|
|
3815
|
-
limit: t.limit,
|
|
3816
|
-
offset: r
|
|
3817
|
-
};
|
|
3818
|
-
});
|
|
3819
|
-
},
|
|
3820
|
-
isExternalChart: q?.tableSettings?.isServerSidePagination && q?.chartType === N.table,
|
|
3821
|
-
isEnablePivotTable: hn,
|
|
3822
|
-
groupByList: pn,
|
|
3823
|
-
hasNumberKeys: !0,
|
|
3824
|
-
isEnableGauge: !0,
|
|
3825
|
-
updateFilter: (e) => {
|
|
3826
|
-
Ut((t) => t?.map((t) => t.name === e.name && t.datatype === e.datatype && t.tableName === e.tableName && t.columnName === e.columnName ? {
|
|
3827
|
-
...t,
|
|
3828
|
-
isAddOnMetrics: !t.isAddOnMetrics
|
|
3829
|
-
} : t));
|
|
3830
|
-
},
|
|
3831
|
-
metricFilters: Oi,
|
|
3832
|
-
leftPositionedMetricFilters: ki,
|
|
3833
|
-
rightPositionedMetricFilters: Ai,
|
|
3834
|
-
drillFilters: U,
|
|
3835
|
-
underlyingDataColumnMetadata: qr,
|
|
3836
|
-
underlyingDataDrillFilters: Kr,
|
|
3837
|
-
drillType: W?.drillType,
|
|
3838
|
-
tableResultsDownloadData: Ni,
|
|
3839
|
-
filterCsvColumns: Mi,
|
|
3840
|
-
appliedMetricFilters: K,
|
|
3841
|
-
pivotHeaderOptions: Ti,
|
|
3842
|
-
pivotDrillState: kn,
|
|
3843
|
-
onDrillPivotTable: ai,
|
|
3844
|
-
legendData: Bi,
|
|
3845
|
-
timeseriesDimension: Mr,
|
|
3846
|
-
isPythonMode: Y,
|
|
3847
|
-
sortOrder: Yt,
|
|
3848
|
-
setSortOrder: Xt,
|
|
3849
|
-
isNotFirstRender: tn,
|
|
3850
|
-
setNotFirstRender: nn,
|
|
3851
|
-
isSorted: wn,
|
|
3852
|
-
isInavlidForSort: ji,
|
|
3853
|
-
onAddComparison: vi,
|
|
3854
|
-
groupedRlsConditions: Si,
|
|
3855
|
-
onGenerateMetricSummary: yi,
|
|
3856
|
-
summary: $t,
|
|
3857
|
-
setSummary: en,
|
|
3858
|
-
dataMartRelationships: Pn,
|
|
3859
|
-
onChartChange: xi,
|
|
3860
|
-
isCompareValue: Fr,
|
|
3861
|
-
isShowChartPropertyPanel: _n,
|
|
3862
|
-
setShowChartPropertyPanel: vn,
|
|
3863
|
-
columnList: Zt,
|
|
3864
|
-
variables: Sn,
|
|
3865
|
-
metricName: Vi,
|
|
3866
|
-
longDescription: qi,
|
|
3867
|
-
footNote: Yi,
|
|
3868
|
-
description: Ji,
|
|
3869
|
-
drilldownCols: rn,
|
|
3870
|
-
switchMeasureOptions: Ei,
|
|
3871
|
-
metricExpressionResult: Xi,
|
|
3872
|
-
dateFilter: wi,
|
|
3873
|
-
drillDownSettings: W,
|
|
3874
|
-
onDrillIntoDimension: ri,
|
|
3875
|
-
adhocDrillDims: ln,
|
|
3876
|
-
enabledCharts: bi,
|
|
3877
|
-
tableColumnFilters: Wt,
|
|
3878
|
-
onChangePaginationColumnFilters: ea,
|
|
3879
|
-
queryError: ur,
|
|
3880
|
-
queryPermissionDenied: !!$n?.isBatchAuth,
|
|
3881
|
-
refetchMetricData: er,
|
|
3882
|
-
customSwitchXAxis: In,
|
|
3883
|
-
savedMetricFilters: Zi || ca
|
|
3884
|
-
};
|
|
3885
|
-
};
|
|
3886
|
-
function pa(e, t) {
|
|
3887
|
-
return t === void 0 || t.has(e);
|
|
3888
|
-
}
|
|
3889
|
-
var ma = {
|
|
3890
|
-
notice: "_notice_vwpz7_1",
|
|
3891
|
-
icon: "_icon_vwpz7_15"
|
|
3892
|
-
}, ha = ({ text: e }) => e ? /* @__PURE__ */ Et("div", {
|
|
3893
|
-
className: ma.notice,
|
|
3894
|
-
role: "status",
|
|
3895
|
-
"data-testid": "custom-sql-filter-notice",
|
|
3896
|
-
children: [/* @__PURE__ */ Tt(lt, {
|
|
3897
|
-
className: ma.icon,
|
|
3898
|
-
"aria-hidden": "true"
|
|
3899
|
-
}), /* @__PURE__ */ Tt("span", { children: e })]
|
|
3900
|
-
}) : null, ga = (e) => {
|
|
3901
|
-
let t = e.value ?? e.selectedVariableValue?.value;
|
|
3902
|
-
return Array.isArray(t) ? t.length > 0 : typeof t == "string" ? t.trim().length > 0 : t != null;
|
|
3903
|
-
}, _a = (e) => {
|
|
3904
|
-
let t = e.label ?? e.name ?? e.column;
|
|
3905
|
-
return typeof t == "string" && t.trim() ? t.trim() : "Filter";
|
|
3906
|
-
}, va = ({ isCustomSqlMetric: e, query: t, metricId: n, filters: r }) => {
|
|
3907
|
-
if (!e) return [];
|
|
3908
|
-
let i = Ve(t || "");
|
|
3909
|
-
return (r || []).flatMap((e) => {
|
|
3910
|
-
let t = e.restrictedMetrics?.some((e) => e.value === n);
|
|
3911
|
-
if (!e.isVariableFilter || e.isFilterApplied === !1 || e.isHiddenInUi || t || !ga(e)) return [];
|
|
3912
|
-
let r = (e.variableStrings || []).filter(Boolean), a = r.filter((e) => !i.includes(e));
|
|
3913
|
-
return r.length > 0 && a.length === 0 ? [] : [{
|
|
3914
|
-
label: _a(e),
|
|
3915
|
-
missingVariables: a
|
|
3916
|
-
}];
|
|
3917
|
-
});
|
|
3918
|
-
}, ya = (e) => e.length === 1 ? e[0] : e.length === 2 ? `${e[0]} and ${e[1]}` : `${e.slice(0, -1).join(", ")}, and ${e.at(-1)}`, ba = (e) => {
|
|
3919
|
-
let t = va(e);
|
|
3920
|
-
if (!t.length) return null;
|
|
3921
|
-
let n = [...new Set(t.flatMap((e) => e.missingVariables))], r = t.length === 1 ? `${t[0].label} is not applied to this custom SQL metric.` : `${t.length} filters are not applied to this custom SQL metric.`;
|
|
3922
|
-
return n.length ? `${r} Add ${ya(n)} to the metric SQL.` : `${r} Configure matching filter variables in the metric SQL.`;
|
|
3923
|
-
}, xa = ({ chart: e, valueColumn: t, isDrillEnabled: n, drilledLevel: r, dimensionCount: i, params: a, passAllData: o }) => {
|
|
3924
|
-
let s = e?.chartType;
|
|
3925
|
-
return s === N.table || s === N.singleValue || n && r === i ? o ? a?.reduce((e, t) => (e[t.columnName] = t.value, e), {}) : a?.find((e) => e.columnName === t)?.value : [N.sankey, N.treeMap].includes(s) ? o ? {
|
|
3926
|
-
name: a?.name,
|
|
3927
|
-
value: a?.value
|
|
3928
|
-
} : a?.value : o ? {
|
|
3929
|
-
name: a?.name,
|
|
3930
|
-
value: a?.value,
|
|
3931
|
-
columnName: a?.seriesName
|
|
3932
|
-
} : t === e?.xAxis || s === N.gauge && t === e?.gaugeSettings?.dimensions?.join(", ") ? a?.name : a?.seriesName === t || s === N.gauge && t === e?.gaugeSettings?.metric || [N.funnel].includes(s) ? a?.value : null;
|
|
3933
|
-
}, Sa = (e, t, n) => !e || t === n, Ca = ({ chart: e, chartWithMetric: t, chartWithDashboard: n, isDrillEnabled: r, drilledLevel: i, dimensionCount: a, isLastConfiguredDrillLevel: o, isTableRedirectAllowed: s = !0 }) => {
|
|
3934
|
-
let c = Sa(r, i, a), l = c || !!o, u = !!e?.isEnable && l && s, d = e?.routeType === "user";
|
|
3935
|
-
return {
|
|
3936
|
-
navigate: u && !d,
|
|
3937
|
-
host: u && d,
|
|
3938
|
-
openNestedMetric: !!t?.isEnable && c,
|
|
3939
|
-
openDashboard: !!n?.isEnable && l
|
|
3940
|
-
};
|
|
3941
|
-
}, wa = (e) => e === "column" ? {
|
|
3942
|
-
code: "JOIN_COLUMN_HIDDEN",
|
|
3943
|
-
message: "A column this metric uses is hidden or no longer in the datamart.",
|
|
3944
|
-
hint: "Ask an editor to unhide it in the datamart or update the metric."
|
|
3945
|
-
} : {
|
|
3946
|
-
code: "JOIN_PATH_MISSING",
|
|
3947
|
-
message: "A join this metric uses is no longer in the datamart.",
|
|
3948
|
-
hint: "Ask an editor to add the relationship back or update the metric."
|
|
3949
|
-
}, Ta = (e) => {
|
|
3950
|
-
let t = r(e, { fallback: "The query couldn't run." });
|
|
3951
|
-
return t.code === "JOIN_COLUMN_HIDDEN" ? r(wa("column")) : t.code === "JOIN_PATH_MISSING" ? r(wa("join")) : t;
|
|
3952
|
-
};
|
|
3953
|
-
//#endregion
|
|
3954
|
-
export { Xn as A, Br as C, $n as D, Jn as E, At as F, Ot as I, Zn as M, Kn as N, ar as O, kt as P, Ur as S, Qn as T, Di as _, ba as a, Yr as b, qi as c, Pi as d, Vi as f, ki as g, Oi as h, xa as i, Z as j, Yn as k, Fi as l, Mi as m, Ta as n, ha as o, Ri as p, Ca as r, fa as s, wa as t, zi as u, ti as v, Vr as w, Hr as x, qr as y };
|