@kong-ui-public/analytics-metric-provider 11.1.6 → 11.1.7-pr.2694.d983d66d0.0
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/package.json +8 -8
- package/dist/style.css +0 -1
- package/dist/types/components/MetricCardContainer.vue.d.ts +0 -92
- package/dist/types/components/MetricCardContainer.vue.d.ts.map +0 -1
- package/dist/types/components/MetricsConsumer.vue.d.ts +0 -35
- package/dist/types/components/MetricsConsumer.vue.d.ts.map +0 -1
- package/dist/types/components/MetricsProvider.vue.d.ts +0 -49
- package/dist/types/components/MetricsProvider.vue.d.ts.map +0 -1
- package/dist/types/components/MetricsTestHarness.vue.d.ts +0 -27
- package/dist/types/components/MetricsTestHarness.vue.d.ts.map +0 -1
- package/dist/types/components/display/MetricCardLoadingSkeleton.vue.d.ts +0 -4
- package/dist/types/components/display/MetricCardLoadingSkeleton.vue.d.ts.map +0 -1
- package/dist/types/components/display/MetricsCard.vue.d.ts +0 -398
- package/dist/types/components/display/MetricsCard.vue.d.ts.map +0 -1
- package/dist/types/components/metricsProviderUtil.d.ts +0 -35
- package/dist/types/components/metricsProviderUtil.d.ts.map +0 -1
- package/dist/types/composables/index.d.ts +0 -14
- package/dist/types/composables/index.d.ts.map +0 -1
- package/dist/types/composables/useI18n.d.ts +0 -9
- package/dist/types/composables/useI18n.d.ts.map +0 -1
- package/dist/types/composables/useMetricCardBuilder.d.ts +0 -20
- package/dist/types/composables/useMetricCardBuilder.d.ts.map +0 -1
- package/dist/types/composables/useMetricFetcher.d.ts +0 -19
- package/dist/types/composables/useMetricFetcher.d.ts.map +0 -1
- package/dist/types/composables/useRequest.d.ts +0 -12
- package/dist/types/composables/useRequest.d.ts.map +0 -1
- package/dist/types/composables/useTrendRange.d.ts +0 -4
- package/dist/types/composables/useTrendRange.d.ts.map +0 -1
- package/dist/types/constants.d.ts +0 -7
- package/dist/types/constants.d.ts.map +0 -1
- package/dist/types/enums/index.d.ts +0 -3
- package/dist/types/enums/index.d.ts.map +0 -1
- package/dist/types/enums/metric-card-size.enum.d.ts +0 -7
- package/dist/types/enums/metric-card-size.enum.d.ts.map +0 -1
- package/dist/types/enums/metric-card-type.enum.d.ts +0 -7
- package/dist/types/enums/metric-card-type.enum.d.ts.map +0 -1
- package/dist/types/index.d.ts +0 -10
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/mockExploreResponse.d.ts +0 -12
- package/dist/types/mockExploreResponse.d.ts.map +0 -1
- package/dist/types/types/fetcher-types.d.ts +0 -16
- package/dist/types/types/fetcher-types.d.ts.map +0 -1
- package/dist/types/types/index.d.ts +0 -3
- package/dist/types/types/index.d.ts.map +0 -1
- package/dist/types/types/metric-card.d.ts +0 -36
- package/dist/types/types/metric-card.d.ts.map +0 -1
- package/dist/types/utilities/index.d.ts +0 -2
- package/dist/types/utilities/index.d.ts.map +0 -1
- package/dist/types/utilities/trend-display.d.ts +0 -24
- package/dist/types/utilities/trend-display.d.ts.map +0 -1
- package/dist/vitals-metric-provider.es.js +0 -1243
- package/dist/vitals-metric-provider.umd.js +0 -1
|
@@ -1,1243 +0,0 @@
|
|
|
1
|
-
import { ref as Y, watchEffect as Ne, computed as g, getCurrentInstance as ke, reactive as Fe, onMounted as xe, onUnmounted as qe, watch as Ue, isReadonly as Pe, toRefs as $e, defineComponent as W, inject as Se, toRef as G, provide as ze, renderSlot as Ce, resolveComponent as Ie, createElementBlock as S, openBlock as R, normalizeClass as z, createElementVNode as q, createCommentVNode as M, createBlock as U, unref as E, resolveDynamicComponent as re, withCtx as me, createTextVNode as Ae, toDisplayString as w, createVNode as F, Fragment as ye, renderList as Ke, mergeProps as Be, normalizeProps as Xe, guardReactiveProps as Ge } from "vue";
|
|
2
|
-
import { stripUnknownFilters as je, queryableExploreDimensions as He } from "@kong-ui-public/analytics-utilities";
|
|
3
|
-
import { createI18n as Ye, i18nTComponent as Qe } from "@kong-ui-public/i18n";
|
|
4
|
-
import "axios";
|
|
5
|
-
import { useAnalyticsConfigStore as We } from "@kong-ui-public/analytics-config-store";
|
|
6
|
-
import { TrendUpIcon as Je, TrendDownIcon as Ze, IndeterminateSmallIcon as De, VitalsIcon as er, CloudUploadIcon as rr, WarningOutlineIcon as tr, ResponseIcon as nr, InfoIcon as ar, WarningIcon as be, EqualIcon as ir } from "@kong/icons";
|
|
7
|
-
const or = {
|
|
8
|
-
notAvailable: "N/A"
|
|
9
|
-
}, sr = {
|
|
10
|
-
small: {
|
|
11
|
-
traffic: "Requests",
|
|
12
|
-
errorRate: "Error rate",
|
|
13
|
-
averageLatency: "Avg. latency",
|
|
14
|
-
p99Latency: "P99 latency"
|
|
15
|
-
},
|
|
16
|
-
short: {
|
|
17
|
-
traffic: "Requests",
|
|
18
|
-
errorRate: "Error rate",
|
|
19
|
-
averageLatency: "Average latency",
|
|
20
|
-
p99Latency: "P99 latency"
|
|
21
|
-
},
|
|
22
|
-
long: {
|
|
23
|
-
traffic: "Number of requests",
|
|
24
|
-
errorRate: "Average error rate",
|
|
25
|
-
averageLatency: "Average latency",
|
|
26
|
-
p99Latency: "P99 latency"
|
|
27
|
-
}
|
|
28
|
-
}, ur = {
|
|
29
|
-
custom_days: "vs previous {numDays, plural, =1 {day} other {# days}}",
|
|
30
|
-
custom_hours: "vs previous {numHours, plural, =1 {hour} other {# hours}}",
|
|
31
|
-
custom_minutes: "vs previous {numMinutes, plural, =1 {minute} other {# minutes}}",
|
|
32
|
-
"15m": "vs previous 15 minutes",
|
|
33
|
-
"1h": "vs previous hour",
|
|
34
|
-
"6h": "vs previous 6 hours",
|
|
35
|
-
"12h": "vs previous 12 hours",
|
|
36
|
-
"24h": "vs previous 24 hours",
|
|
37
|
-
"7d": "vs previous 7 days",
|
|
38
|
-
"30d": "vs previous 30 days",
|
|
39
|
-
current_week: "vs previous week",
|
|
40
|
-
current_month: "vs previous month",
|
|
41
|
-
current_quarter: "vs previous quarter",
|
|
42
|
-
previous_week: "vs previous time period",
|
|
43
|
-
previous_month: "vs previous time period",
|
|
44
|
-
previous_quarter: "vs previous quarter"
|
|
45
|
-
}, lr = {
|
|
46
|
-
general: or,
|
|
47
|
-
metricCard: sr,
|
|
48
|
-
trendRange: ur
|
|
49
|
-
};
|
|
50
|
-
function cr() {
|
|
51
|
-
const e = Ye("en-us", lr);
|
|
52
|
-
return {
|
|
53
|
-
i18n: e,
|
|
54
|
-
i18nT: Qe(e)
|
|
55
|
-
// Translation component <i18n-t>
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
const dr = 2, B = ["1XX", "2XX", "3XX", "4XX", "5XX"], ge = ["4XX", "5XX"], yt = ["1XX", "2XX", "3XX"], fr = 30 * 1e3, vr = "analytics-query-provider";
|
|
59
|
-
var we = /* @__PURE__ */ ((e) => (e.VALIDATING = "VALIDATING", e.VALIDATING_HAS_DATA = "VALIDATING_HAS_DATA", e.PENDING = "PENDING", e.SUCCESS = "SUCCESS", e.SUCCESS_HAS_DATA = "SUCCESS_HAS_DATA", e.ERROR = "ERROR", e.STALE_IF_ERROR = "STALE_IF_ERROR", e))(we || {});
|
|
60
|
-
const mr = (e) => {
|
|
61
|
-
var r, t, o, a, n;
|
|
62
|
-
return e ? !!// TODO: revisit: currently only the first check ever matters?
|
|
63
|
-
((r = Object.keys(e)) != null && r.length || (t = e.data) != null && t.length || (a = (o = e.data) == null ? void 0 : o.data) != null && a.length || !((n = e.data) != null && n.data) && typeof e.data == "object" && Object.keys(e == null ? void 0 : e.data).length) : !1;
|
|
64
|
-
};
|
|
65
|
-
function yr(e = Y({}), r, t, o = mr) {
|
|
66
|
-
const a = Y(
|
|
67
|
-
"PENDING"
|
|
68
|
-
/* PENDING */
|
|
69
|
-
);
|
|
70
|
-
return Ne(() => {
|
|
71
|
-
const n = o(e.value);
|
|
72
|
-
if (e.value && n && t.value) {
|
|
73
|
-
a.value = "VALIDATING_HAS_DATA";
|
|
74
|
-
return;
|
|
75
|
-
}
|
|
76
|
-
if (e.value && t.value) {
|
|
77
|
-
a.value = "VALIDATING";
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
80
|
-
if (e.value && r.value) {
|
|
81
|
-
a.value = "STALE_IF_ERROR";
|
|
82
|
-
return;
|
|
83
|
-
}
|
|
84
|
-
if (e.value === void 0 && !r.value) {
|
|
85
|
-
a.value = "PENDING";
|
|
86
|
-
return;
|
|
87
|
-
}
|
|
88
|
-
if (e.value && !r.value && n) {
|
|
89
|
-
a.value = "SUCCESS_HAS_DATA";
|
|
90
|
-
return;
|
|
91
|
-
}
|
|
92
|
-
if (e.value && !r.value) {
|
|
93
|
-
a.value = "SUCCESS";
|
|
94
|
-
return;
|
|
95
|
-
}
|
|
96
|
-
e.value === void 0 && r && (a.value = "ERROR");
|
|
97
|
-
}), {
|
|
98
|
-
state: a,
|
|
99
|
-
swrvState: we
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
const L = Symbol("default"), te = "status_code_grouped", he = (e, r, t, o, a) => {
|
|
103
|
-
e[r][t] || (e[r][t] = {}), e[r][t][o] = a;
|
|
104
|
-
};
|
|
105
|
-
function gr(e, r) {
|
|
106
|
-
var d;
|
|
107
|
-
const t = ((d = e.meta.metric_names) == null ? void 0 : d[0]) || "", o = e.meta.start_ms, a = Object.keys(e.meta.display || {}), n = !!a.find((f) => f === te), l = a.find((f) => f !== te);
|
|
108
|
-
return a.length > 2 || a.length > 1 && !n ? (console.error("Don't know how to work with provided dimensions:", a), {
|
|
109
|
-
previous: { [L]: { [L]: 0 } },
|
|
110
|
-
current: { [L]: { [L]: 0 } }
|
|
111
|
-
}) : e.data.reduce((f, i) => {
|
|
112
|
-
const s = i.event[t], u = l ? i.event[l] : L, c = n ? i.event[te] : L;
|
|
113
|
-
return new Date(i.timestamp).getTime() === o && r ? he(f, "previous", u, c, s) : he(f, "current", u, c, s), f;
|
|
114
|
-
}, {
|
|
115
|
-
previous: {},
|
|
116
|
-
current: {}
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
function hr(e) {
|
|
120
|
-
e.queryReady === void 0 && (e.queryReady = g(() => !0));
|
|
121
|
-
const r = g(() => {
|
|
122
|
-
var s, u;
|
|
123
|
-
return {
|
|
124
|
-
metrics: e.metrics.value,
|
|
125
|
-
dimensions: [
|
|
126
|
-
...(s = e.dimensions) != null && s.length ? [...e.dimensions] : [],
|
|
127
|
-
...e.withTrend.value ? ["time"] : []
|
|
128
|
-
],
|
|
129
|
-
granularity: e.withTrend.value ? "trend" : void 0,
|
|
130
|
-
...(u = e.filter.value) != null && u.length ? { filters: e.filter.value } : {},
|
|
131
|
-
time_range: e.timeRange.value
|
|
132
|
-
};
|
|
133
|
-
}), t = g(() => {
|
|
134
|
-
var u, c, v, p;
|
|
135
|
-
if (!((u = e.queryReady) != null && u.value))
|
|
136
|
-
return null;
|
|
137
|
-
const s = (c = e.filter) != null && c.value ? JSON.stringify(e.filter.value) : "";
|
|
138
|
-
return `metric-fetcher-${JSON.stringify(e.timeRange.value)}-${(v = e.dimensions) == null ? void 0 : v.join("-")}-${(p = e.metrics.value) == null ? void 0 : p.join("-")}-${s}-${e.refreshCounter.value}`;
|
|
139
|
-
}), { response: o, error: a, isValidating: n } = V.useRequest(
|
|
140
|
-
() => t.value,
|
|
141
|
-
() => e.queryFn({
|
|
142
|
-
// TODO: Use a type guard to validate that if the datasource is basic,
|
|
143
|
-
// the query is a valid basic explore query.
|
|
144
|
-
datasource: e.datasource.value,
|
|
145
|
-
query: r.value
|
|
146
|
-
}, e.abortController ?? new AbortController()),
|
|
147
|
-
{
|
|
148
|
-
refreshInterval: e.refreshInterval,
|
|
149
|
-
revalidateOnFocus: !1,
|
|
150
|
-
errorRetryCount: dr
|
|
151
|
-
}
|
|
152
|
-
), { state: l, swrvState: d } = yr(o, a, n), f = g(() => {
|
|
153
|
-
var s, u, c, v, p, _, h;
|
|
154
|
-
return !((u = (s = o.value) == null ? void 0 : s.data) != null && u.length) || !((v = (c = o.value) == null ? void 0 : c.meta) != null && v.display) || !((h = (_ = (p = o.value) == null ? void 0 : p.meta) == null ? void 0 : _.metric_names) != null && h.length) ? { current: {}, previous: {} } : gr(o.value, e.withTrend.value);
|
|
155
|
-
}), i = V.useTrendRange(e.withTrend, e.timeRange, g(() => {
|
|
156
|
-
var s;
|
|
157
|
-
return (s = o.value) == null ? void 0 : s.meta;
|
|
158
|
-
}));
|
|
159
|
-
return {
|
|
160
|
-
isLoading: g(() => d.PENDING === l.value),
|
|
161
|
-
hasError: g(() => d.ERROR === l.value),
|
|
162
|
-
raw: o,
|
|
163
|
-
mapped: f,
|
|
164
|
-
trendRange: i
|
|
165
|
-
};
|
|
166
|
-
}
|
|
167
|
-
const K = (e, r, t = L, o) => (o ?? [L]).reduce((n, l) => {
|
|
168
|
-
const d = e[r][t];
|
|
169
|
-
return d ? n + (d[l] || 0) : n;
|
|
170
|
-
}, 0);
|
|
171
|
-
function pr(e) {
|
|
172
|
-
const {
|
|
173
|
-
cardType: r,
|
|
174
|
-
title: t,
|
|
175
|
-
description: o,
|
|
176
|
-
record: a,
|
|
177
|
-
hasError: n,
|
|
178
|
-
increaseIsBad: l,
|
|
179
|
-
formatValueFn: d,
|
|
180
|
-
trendRange: f
|
|
181
|
-
} = e;
|
|
182
|
-
return g(() => {
|
|
183
|
-
let i = 0, s = 0;
|
|
184
|
-
if (a != null && a.value)
|
|
185
|
-
try {
|
|
186
|
-
i = K(a.value, "current", e.lookupKey, e.sumGroupedValues), s = K(a.value, "previous", e.lookupKey, e.sumGroupedValues);
|
|
187
|
-
} catch (u) {
|
|
188
|
-
console.error(
|
|
189
|
-
"Metric card data doesn't have the expected structure:",
|
|
190
|
-
u
|
|
191
|
-
);
|
|
192
|
-
}
|
|
193
|
-
return {
|
|
194
|
-
cardType: r,
|
|
195
|
-
hasError: n.value,
|
|
196
|
-
currentValue: i,
|
|
197
|
-
previousValue: s,
|
|
198
|
-
title: t.value,
|
|
199
|
-
description: o,
|
|
200
|
-
increaseIsBad: !!l,
|
|
201
|
-
// Coerce undefined to false
|
|
202
|
-
formatValueFn: d,
|
|
203
|
-
trendRange: f == null ? void 0 : f.value
|
|
204
|
-
};
|
|
205
|
-
});
|
|
206
|
-
}
|
|
207
|
-
function Rr(e, r, t) {
|
|
208
|
-
const { i18n: o } = V.useI18n(), a = 1e3 * 60, n = a * 60, l = n * 24, d = (i, s) => {
|
|
209
|
-
let u = s - i;
|
|
210
|
-
e.value && (u /= 2);
|
|
211
|
-
const c = u / l, v = u / n, p = u / a;
|
|
212
|
-
return c >= 1 ? o.t("trendRange.custom_days", { numDays: Math.round(c) }) : v >= 1 ? o.t("trendRange.custom_hours", { numHours: Math.round(v) }) : p >= 1 ? o.t("trendRange.custom_minutes", { numMinutes: Math.round(p) }) : o.t("trendRange.custom_days", { numDays: Math.round(c) });
|
|
213
|
-
}, f = () => {
|
|
214
|
-
var i, s;
|
|
215
|
-
if ((i = t == null ? void 0 : t.value) != null && i.start_ms && t.value.end_ms)
|
|
216
|
-
return {
|
|
217
|
-
startMs: t.value.start_ms,
|
|
218
|
-
endMs: t.value.end_ms
|
|
219
|
-
};
|
|
220
|
-
if (((s = r == null ? void 0 : r.value) == null ? void 0 : s.type) === "absolute" && r.value.start && r.value.end)
|
|
221
|
-
return {
|
|
222
|
-
startMs: new Date(r.value.start).getTime(),
|
|
223
|
-
endMs: new Date(r.value.end).getTime()
|
|
224
|
-
};
|
|
225
|
-
};
|
|
226
|
-
return g(() => {
|
|
227
|
-
var i, s;
|
|
228
|
-
if (((i = r == null ? void 0 : r.value) == null ? void 0 : i.type) === "relative" && e.value)
|
|
229
|
-
return o.t(`trendRange.${r.value.time_range}`);
|
|
230
|
-
if (e.value || ((s = r == null ? void 0 : r.value) == null ? void 0 : s.type) === "absolute") {
|
|
231
|
-
const u = f();
|
|
232
|
-
if (u)
|
|
233
|
-
return d(u.startMs, u.endMs);
|
|
234
|
-
}
|
|
235
|
-
return "";
|
|
236
|
-
});
|
|
237
|
-
}
|
|
238
|
-
var ne = /* @__PURE__ */ new WeakMap(), pe = 0;
|
|
239
|
-
function Tr(e) {
|
|
240
|
-
if (!e.length)
|
|
241
|
-
return "";
|
|
242
|
-
for (var r = "arg", t = 0; t < e.length; ++t) {
|
|
243
|
-
var o = void 0;
|
|
244
|
-
e[t] === null || typeof e[t] != "object" && typeof e[t] != "function" ? typeof e[t] == "string" ? o = '"' + e[t] + '"' : o = String(e[t]) : ne.has(e[t]) ? o = ne.get(e[t]) : (o = pe, ne.set(e[t], pe++)), r += "@" + o;
|
|
245
|
-
}
|
|
246
|
-
return r;
|
|
247
|
-
}
|
|
248
|
-
function Er(e) {
|
|
249
|
-
if (typeof e == "function")
|
|
250
|
-
try {
|
|
251
|
-
e = e();
|
|
252
|
-
} catch {
|
|
253
|
-
e = "";
|
|
254
|
-
}
|
|
255
|
-
return Array.isArray(e) ? e = Tr(e) : e = String(e || ""), e;
|
|
256
|
-
}
|
|
257
|
-
var se = (
|
|
258
|
-
/** @class */
|
|
259
|
-
function() {
|
|
260
|
-
function e(r) {
|
|
261
|
-
r === void 0 && (r = 0), this.items = /* @__PURE__ */ new Map(), this.ttl = r;
|
|
262
|
-
}
|
|
263
|
-
return e.prototype.serializeKey = function(r) {
|
|
264
|
-
return Er(r);
|
|
265
|
-
}, e.prototype.get = function(r) {
|
|
266
|
-
var t = this.serializeKey(r);
|
|
267
|
-
return this.items.get(t);
|
|
268
|
-
}, e.prototype.set = function(r, t, o) {
|
|
269
|
-
var a = this.serializeKey(r), n = o || this.ttl, l = Date.now(), d = {
|
|
270
|
-
data: t,
|
|
271
|
-
createdAt: l,
|
|
272
|
-
expiresAt: n ? l + n : 1 / 0
|
|
273
|
-
};
|
|
274
|
-
this.dispatchExpire(n, d, a), this.items.set(a, d);
|
|
275
|
-
}, e.prototype.dispatchExpire = function(r, t, o) {
|
|
276
|
-
var a = this;
|
|
277
|
-
r && setTimeout(function() {
|
|
278
|
-
var n = Date.now(), l = n >= t.expiresAt;
|
|
279
|
-
l && a.delete(o);
|
|
280
|
-
}, r);
|
|
281
|
-
}, e.prototype.delete = function(r) {
|
|
282
|
-
this.items.delete(r);
|
|
283
|
-
}, e;
|
|
284
|
-
}()
|
|
285
|
-
);
|
|
286
|
-
function _r() {
|
|
287
|
-
return typeof navigator.onLine < "u" ? navigator.onLine : !0;
|
|
288
|
-
}
|
|
289
|
-
function Sr() {
|
|
290
|
-
return typeof document < "u" && typeof document.visibilityState < "u" ? document.visibilityState !== "hidden" : !0;
|
|
291
|
-
}
|
|
292
|
-
var Cr = function(e) {
|
|
293
|
-
return fetch(e).then(function(r) {
|
|
294
|
-
return r.json();
|
|
295
|
-
});
|
|
296
|
-
};
|
|
297
|
-
const ae = {
|
|
298
|
-
isOnline: _r,
|
|
299
|
-
isDocumentVisible: Sr,
|
|
300
|
-
fetcher: Cr
|
|
301
|
-
};
|
|
302
|
-
var b = function() {
|
|
303
|
-
return b = Object.assign || function(e) {
|
|
304
|
-
for (var r, t = 1, o = arguments.length; t < o; t++) {
|
|
305
|
-
r = arguments[t];
|
|
306
|
-
for (var a in r) Object.prototype.hasOwnProperty.call(r, a) && (e[a] = r[a]);
|
|
307
|
-
}
|
|
308
|
-
return e;
|
|
309
|
-
}, b.apply(this, arguments);
|
|
310
|
-
}, P = function(e, r, t, o) {
|
|
311
|
-
function a(n) {
|
|
312
|
-
return n instanceof t ? n : new t(function(l) {
|
|
313
|
-
l(n);
|
|
314
|
-
});
|
|
315
|
-
}
|
|
316
|
-
return new (t || (t = Promise))(function(n, l) {
|
|
317
|
-
function d(s) {
|
|
318
|
-
try {
|
|
319
|
-
i(o.next(s));
|
|
320
|
-
} catch (u) {
|
|
321
|
-
l(u);
|
|
322
|
-
}
|
|
323
|
-
}
|
|
324
|
-
function f(s) {
|
|
325
|
-
try {
|
|
326
|
-
i(o.throw(s));
|
|
327
|
-
} catch (u) {
|
|
328
|
-
l(u);
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
function i(s) {
|
|
332
|
-
s.done ? n(s.value) : a(s.value).then(d, f);
|
|
333
|
-
}
|
|
334
|
-
i((o = o.apply(e, r || [])).next());
|
|
335
|
-
});
|
|
336
|
-
}, $ = function(e, r) {
|
|
337
|
-
var t = { label: 0, sent: function() {
|
|
338
|
-
if (n[0] & 1) throw n[1];
|
|
339
|
-
return n[1];
|
|
340
|
-
}, trys: [], ops: [] }, o, a, n, l;
|
|
341
|
-
return l = { next: d(0), throw: d(1), return: d(2) }, typeof Symbol == "function" && (l[Symbol.iterator] = function() {
|
|
342
|
-
return this;
|
|
343
|
-
}), l;
|
|
344
|
-
function d(i) {
|
|
345
|
-
return function(s) {
|
|
346
|
-
return f([i, s]);
|
|
347
|
-
};
|
|
348
|
-
}
|
|
349
|
-
function f(i) {
|
|
350
|
-
if (o) throw new TypeError("Generator is already executing.");
|
|
351
|
-
for (; t; ) try {
|
|
352
|
-
if (o = 1, a && (n = i[0] & 2 ? a.return : i[0] ? a.throw || ((n = a.return) && n.call(a), 0) : a.next) && !(n = n.call(a, i[1])).done) return n;
|
|
353
|
-
switch (a = 0, n && (i = [i[0] & 2, n.value]), i[0]) {
|
|
354
|
-
case 0:
|
|
355
|
-
case 1:
|
|
356
|
-
n = i;
|
|
357
|
-
break;
|
|
358
|
-
case 4:
|
|
359
|
-
return t.label++, { value: i[1], done: !1 };
|
|
360
|
-
case 5:
|
|
361
|
-
t.label++, a = i[1], i = [0];
|
|
362
|
-
continue;
|
|
363
|
-
case 7:
|
|
364
|
-
i = t.ops.pop(), t.trys.pop();
|
|
365
|
-
continue;
|
|
366
|
-
default:
|
|
367
|
-
if (n = t.trys, !(n = n.length > 0 && n[n.length - 1]) && (i[0] === 6 || i[0] === 2)) {
|
|
368
|
-
t = 0;
|
|
369
|
-
continue;
|
|
370
|
-
}
|
|
371
|
-
if (i[0] === 3 && (!n || i[1] > n[0] && i[1] < n[3])) {
|
|
372
|
-
t.label = i[1];
|
|
373
|
-
break;
|
|
374
|
-
}
|
|
375
|
-
if (i[0] === 6 && t.label < n[1]) {
|
|
376
|
-
t.label = n[1], n = i;
|
|
377
|
-
break;
|
|
378
|
-
}
|
|
379
|
-
if (n && t.label < n[2]) {
|
|
380
|
-
t.label = n[2], t.ops.push(i);
|
|
381
|
-
break;
|
|
382
|
-
}
|
|
383
|
-
n[2] && t.ops.pop(), t.trys.pop();
|
|
384
|
-
continue;
|
|
385
|
-
}
|
|
386
|
-
i = r.call(e, t);
|
|
387
|
-
} catch (s) {
|
|
388
|
-
i = [6, s], a = 0;
|
|
389
|
-
} finally {
|
|
390
|
-
o = n = 0;
|
|
391
|
-
}
|
|
392
|
-
if (i[0] & 5) throw i[1];
|
|
393
|
-
return { value: i[0] ? i[1] : void 0, done: !0 };
|
|
394
|
-
}
|
|
395
|
-
}, Ir = function(e, r) {
|
|
396
|
-
var t = typeof Symbol == "function" && e[Symbol.iterator];
|
|
397
|
-
if (!t) return e;
|
|
398
|
-
var o = t.call(e), a, n = [], l;
|
|
399
|
-
try {
|
|
400
|
-
for (; (r === void 0 || r-- > 0) && !(a = o.next()).done; ) n.push(a.value);
|
|
401
|
-
} catch (d) {
|
|
402
|
-
l = { error: d };
|
|
403
|
-
} finally {
|
|
404
|
-
try {
|
|
405
|
-
a && !a.done && (t = o.return) && t.call(o);
|
|
406
|
-
} finally {
|
|
407
|
-
if (l) throw l.error;
|
|
408
|
-
}
|
|
409
|
-
}
|
|
410
|
-
return n;
|
|
411
|
-
}, Ar = function(e, r, t) {
|
|
412
|
-
if (t || arguments.length === 2) for (var o = 0, a = r.length, n; o < a; o++)
|
|
413
|
-
(n || !(o in r)) && (n || (n = Array.prototype.slice.call(r, 0, o)), n[o] = r[o]);
|
|
414
|
-
return e.concat(n || Array.prototype.slice.call(r));
|
|
415
|
-
}, Oe = new se(), Q = new se(), ie = new se(), Le = {
|
|
416
|
-
cache: Oe,
|
|
417
|
-
refreshInterval: 0,
|
|
418
|
-
ttl: 0,
|
|
419
|
-
serverTTL: 1e3,
|
|
420
|
-
dedupingInterval: 2e3,
|
|
421
|
-
revalidateOnFocus: !0,
|
|
422
|
-
revalidateDebounce: 0,
|
|
423
|
-
shouldRetryOnError: !0,
|
|
424
|
-
errorRetryInterval: 5e3,
|
|
425
|
-
errorRetryCount: 5,
|
|
426
|
-
fetcher: ae.fetcher,
|
|
427
|
-
isOnline: ae.isOnline,
|
|
428
|
-
isDocumentVisible: ae.isDocumentVisible
|
|
429
|
-
};
|
|
430
|
-
function Dr(e, r, t) {
|
|
431
|
-
var o = Q.get(e);
|
|
432
|
-
if (o)
|
|
433
|
-
o.data.push(r);
|
|
434
|
-
else {
|
|
435
|
-
var a = 5e3;
|
|
436
|
-
Q.set(e, [r], t > 0 ? t + a : t);
|
|
437
|
-
}
|
|
438
|
-
}
|
|
439
|
-
function br(e, r, t) {
|
|
440
|
-
if (t.isDocumentVisible() && !(t.errorRetryCount !== void 0 && r > t.errorRetryCount)) {
|
|
441
|
-
var o = Math.min(r || 0, t.errorRetryCount), a = o * t.errorRetryInterval;
|
|
442
|
-
setTimeout(function() {
|
|
443
|
-
e(null, { errorRetryCount: o + 1, shouldRetryOnError: !0 });
|
|
444
|
-
}, a);
|
|
445
|
-
}
|
|
446
|
-
}
|
|
447
|
-
var Re = function(e, r, t, o) {
|
|
448
|
-
return t === void 0 && (t = Oe), o === void 0 && (o = Le.ttl), P(void 0, void 0, void 0, function() {
|
|
449
|
-
var a, n, l, d, f, i, s;
|
|
450
|
-
return $(this, function(u) {
|
|
451
|
-
switch (u.label) {
|
|
452
|
-
case 0:
|
|
453
|
-
if (!Or(r)) return [3, 5];
|
|
454
|
-
u.label = 1;
|
|
455
|
-
case 1:
|
|
456
|
-
return u.trys.push([1, 3, , 4]), [4, r];
|
|
457
|
-
case 2:
|
|
458
|
-
return a = u.sent(), [3, 4];
|
|
459
|
-
case 3:
|
|
460
|
-
return d = u.sent(), n = d, [3, 4];
|
|
461
|
-
case 4:
|
|
462
|
-
return [3, 6];
|
|
463
|
-
case 5:
|
|
464
|
-
a = r, u.label = 6;
|
|
465
|
-
case 6:
|
|
466
|
-
if (l = !1, f = { data: a, error: n, isValidating: l }, typeof a < "u")
|
|
467
|
-
try {
|
|
468
|
-
t.set(e, f, o);
|
|
469
|
-
} catch (c) {
|
|
470
|
-
console.error("swrv(mutate): failed to set cache", c);
|
|
471
|
-
}
|
|
472
|
-
return i = Q.get(e), i && i.data.length && (s = i.data.filter(function(c) {
|
|
473
|
-
return c.key === e;
|
|
474
|
-
}), s.forEach(function(c, v) {
|
|
475
|
-
typeof f.data < "u" && (c.data = f.data), c.error = f.error, c.isValidating = f.isValidating, c.isLoading = f.isValidating;
|
|
476
|
-
var p = v === s.length - 1;
|
|
477
|
-
p || delete s[v];
|
|
478
|
-
}), s = s.filter(Boolean)), [2, f];
|
|
479
|
-
}
|
|
480
|
-
});
|
|
481
|
-
});
|
|
482
|
-
};
|
|
483
|
-
function wr() {
|
|
484
|
-
for (var e = this, r = [], t = 0; t < arguments.length; t++)
|
|
485
|
-
r[t] = arguments[t];
|
|
486
|
-
var o, a, n = b({}, Le), l = !1, d = !1, f = ke(), i = (f == null ? void 0 : f.proxy) || f;
|
|
487
|
-
if (!i)
|
|
488
|
-
return console.error("Could not get current instance, check to make sure that `useSwrv` is declared in the top level of the setup function."), null;
|
|
489
|
-
var s = (i == null ? void 0 : i.$isServer) || !1;
|
|
490
|
-
r.length >= 1 && (o = r[0]), r.length >= 2 && (a = r[1]), r.length > 2 && (n = b(b({}, n), r[2]));
|
|
491
|
-
var u = s ? n.serverTTL : n.ttl, c = typeof o == "function" ? o : Y(o);
|
|
492
|
-
typeof a > "u" && (a = n.fetcher);
|
|
493
|
-
var v = null;
|
|
494
|
-
v || (v = Fe({
|
|
495
|
-
data: void 0,
|
|
496
|
-
error: void 0,
|
|
497
|
-
isValidating: !0,
|
|
498
|
-
isLoading: !0,
|
|
499
|
-
key: null
|
|
500
|
-
}));
|
|
501
|
-
var p = function(m, y) {
|
|
502
|
-
return P(e, void 0, void 0, function() {
|
|
503
|
-
var N, T, C, A, x, ce, J, de = this;
|
|
504
|
-
return $(this, function(Z) {
|
|
505
|
-
switch (Z.label) {
|
|
506
|
-
case 0:
|
|
507
|
-
return N = v.data === void 0, T = c.value, T ? (C = n.cache.get(T), A = C && C.data, v.isValidating = !0, v.isLoading = !A, A && (v.data = A.data, v.error = A.error), x = m || a, !x || !n.isDocumentVisible() && !N || (y == null ? void 0 : y.forceRevalidate) !== void 0 && !(y != null && y.forceRevalidate) ? (v.isValidating = !1, v.isLoading = !1, [
|
|
508
|
-
2
|
|
509
|
-
/*return*/
|
|
510
|
-
]) : C && (ce = !!(Date.now() - C.createdAt >= n.dedupingInterval || y != null && y.forceRevalidate), !ce) ? (v.isValidating = !1, v.isLoading = !1, [
|
|
511
|
-
2
|
|
512
|
-
/*return*/
|
|
513
|
-
]) : (J = function() {
|
|
514
|
-
return P(de, void 0, void 0, function() {
|
|
515
|
-
var k, fe, ee, ve;
|
|
516
|
-
return $(this, function(X) {
|
|
517
|
-
switch (X.label) {
|
|
518
|
-
case 0:
|
|
519
|
-
return k = ie.get(T), k ? [3, 2] : (fe = Array.isArray(T) ? T : [T], ee = x.apply(void 0, Ar([], Ir(fe), !1)), ie.set(T, ee, n.dedupingInterval), [4, Re(T, ee, n.cache, u)]);
|
|
520
|
-
case 1:
|
|
521
|
-
return X.sent(), [3, 4];
|
|
522
|
-
case 2:
|
|
523
|
-
return [4, Re(T, k.data, n.cache, u)];
|
|
524
|
-
case 3:
|
|
525
|
-
X.sent(), X.label = 4;
|
|
526
|
-
case 4:
|
|
527
|
-
return v.isValidating = !1, v.isLoading = !1, ie.delete(T), v.error !== void 0 && (ve = !l && n.shouldRetryOnError && (y ? y.shouldRetryOnError : !0), ve && br(p, y ? y.errorRetryCount : 1, n)), [
|
|
528
|
-
2
|
|
529
|
-
/*return*/
|
|
530
|
-
];
|
|
531
|
-
}
|
|
532
|
-
});
|
|
533
|
-
});
|
|
534
|
-
}, A && n.revalidateDebounce ? (setTimeout(function() {
|
|
535
|
-
return P(de, void 0, void 0, function() {
|
|
536
|
-
return $(this, function(k) {
|
|
537
|
-
switch (k.label) {
|
|
538
|
-
case 0:
|
|
539
|
-
return l ? [3, 2] : [4, J()];
|
|
540
|
-
case 1:
|
|
541
|
-
k.sent(), k.label = 2;
|
|
542
|
-
case 2:
|
|
543
|
-
return [
|
|
544
|
-
2
|
|
545
|
-
/*return*/
|
|
546
|
-
];
|
|
547
|
-
}
|
|
548
|
-
});
|
|
549
|
-
});
|
|
550
|
-
}, n.revalidateDebounce), [3, 3]) : [3, 1])) : [
|
|
551
|
-
2
|
|
552
|
-
/*return*/
|
|
553
|
-
];
|
|
554
|
-
case 1:
|
|
555
|
-
return [4, J()];
|
|
556
|
-
case 2:
|
|
557
|
-
Z.sent(), Z.label = 3;
|
|
558
|
-
case 3:
|
|
559
|
-
return [
|
|
560
|
-
2
|
|
561
|
-
/*return*/
|
|
562
|
-
];
|
|
563
|
-
}
|
|
564
|
-
});
|
|
565
|
-
});
|
|
566
|
-
}, _ = function() {
|
|
567
|
-
return P(e, void 0, void 0, function() {
|
|
568
|
-
return $(this, function(m) {
|
|
569
|
-
return [2, p(null, { shouldRetryOnError: !1 })];
|
|
570
|
-
});
|
|
571
|
-
});
|
|
572
|
-
}, h = null;
|
|
573
|
-
xe(function() {
|
|
574
|
-
var m = function() {
|
|
575
|
-
return P(e, void 0, void 0, function() {
|
|
576
|
-
return $(this, function(y) {
|
|
577
|
-
switch (y.label) {
|
|
578
|
-
case 0:
|
|
579
|
-
return !v.error && n.isOnline() ? [4, p()] : [3, 2];
|
|
580
|
-
case 1:
|
|
581
|
-
return y.sent(), [3, 3];
|
|
582
|
-
case 2:
|
|
583
|
-
h && clearTimeout(h), y.label = 3;
|
|
584
|
-
case 3:
|
|
585
|
-
return n.refreshInterval && !l && (h = setTimeout(m, n.refreshInterval)), [
|
|
586
|
-
2
|
|
587
|
-
/*return*/
|
|
588
|
-
];
|
|
589
|
-
}
|
|
590
|
-
});
|
|
591
|
-
});
|
|
592
|
-
};
|
|
593
|
-
n.refreshInterval && (h = setTimeout(m, n.refreshInterval)), n.revalidateOnFocus && (document.addEventListener("visibilitychange", _, !1), window.addEventListener("focus", _, !1));
|
|
594
|
-
}), qe(function() {
|
|
595
|
-
l = !0, h && clearTimeout(h), n.revalidateOnFocus && (document.removeEventListener("visibilitychange", _, !1), window.removeEventListener("focus", _, !1));
|
|
596
|
-
var m = Q.get(c.value);
|
|
597
|
-
m && (m.data = m.data.filter(function(y) {
|
|
598
|
-
return y !== v;
|
|
599
|
-
}));
|
|
600
|
-
});
|
|
601
|
-
try {
|
|
602
|
-
Ue(c, function(m) {
|
|
603
|
-
Pe(c) || (c.value = m), v.key = m, v.isValidating = !!m, Dr(c.value, v, u), !s && !d && c.value && p(), d = !1;
|
|
604
|
-
}, {
|
|
605
|
-
immediate: !0
|
|
606
|
-
});
|
|
607
|
-
} catch {
|
|
608
|
-
}
|
|
609
|
-
var I = b(b({}, $e(v)), { mutate: function(m, y) {
|
|
610
|
-
return p(m, b(b({}, y), { forceRevalidate: !0 }));
|
|
611
|
-
} });
|
|
612
|
-
return I;
|
|
613
|
-
}
|
|
614
|
-
function Or(e) {
|
|
615
|
-
return e !== null && typeof e == "object" && typeof e.then == "function";
|
|
616
|
-
}
|
|
617
|
-
function Lr(e, r, t) {
|
|
618
|
-
const {
|
|
619
|
-
data: o,
|
|
620
|
-
error: a,
|
|
621
|
-
isValidating: n,
|
|
622
|
-
mutate: l
|
|
623
|
-
} = wr(e, r, {
|
|
624
|
-
revalidateDebounce: 500,
|
|
625
|
-
revalidateOnFocus: !1,
|
|
626
|
-
dedupingInterval: 100,
|
|
627
|
-
...t
|
|
628
|
-
});
|
|
629
|
-
return {
|
|
630
|
-
data: g(() => o.value),
|
|
631
|
-
response: o,
|
|
632
|
-
error: a,
|
|
633
|
-
isValidating: n,
|
|
634
|
-
revalidate: l
|
|
635
|
-
};
|
|
636
|
-
}
|
|
637
|
-
const V = {
|
|
638
|
-
useI18n: cr,
|
|
639
|
-
useMetricCardBuilder: pr,
|
|
640
|
-
useMetricFetcher: hr,
|
|
641
|
-
useTrendRange: Rr,
|
|
642
|
-
useRequest: Lr
|
|
643
|
-
}, Me = Symbol("METRICS_PROVIDER_KEY"), Mr = (e) => {
|
|
644
|
-
const {
|
|
645
|
-
datasource: r,
|
|
646
|
-
dimension: t,
|
|
647
|
-
dimensionFilterValue: o,
|
|
648
|
-
additionalFilter: a,
|
|
649
|
-
queryReady: n,
|
|
650
|
-
timeRange: l,
|
|
651
|
-
hasTrendAccess: d,
|
|
652
|
-
refreshInterval: f,
|
|
653
|
-
abortController: i,
|
|
654
|
-
queryFn: s,
|
|
655
|
-
averageLatencies: u
|
|
656
|
-
} = e;
|
|
657
|
-
if (o && !t)
|
|
658
|
-
throw new Error("Must provide a dimension if filtering by a value");
|
|
659
|
-
const c = !!(t && o), v = !!(t && !o), p = g(() => {
|
|
660
|
-
const y = [];
|
|
661
|
-
return c && y.push({
|
|
662
|
-
field: t,
|
|
663
|
-
operator: "in",
|
|
664
|
-
value: [o]
|
|
665
|
-
}), a.value && y.push(...je(r.value, a.value)), y;
|
|
666
|
-
}), _ = {
|
|
667
|
-
datasource: r,
|
|
668
|
-
metrics: Y([
|
|
669
|
-
"request_count"
|
|
670
|
-
]),
|
|
671
|
-
// Traffic and error rate cards should only try to query for the dimension if it's going to be used.
|
|
672
|
-
// It isn't used for single entity queries.
|
|
673
|
-
dimensions: [
|
|
674
|
-
...t && !c ? [t] : [],
|
|
675
|
-
"status_code_grouped"
|
|
676
|
-
],
|
|
677
|
-
filter: p,
|
|
678
|
-
queryReady: n,
|
|
679
|
-
timeRange: l,
|
|
680
|
-
// Traffic and error rate cards can't query trend if multiple entities are expected.
|
|
681
|
-
withTrend: g(() => d.value && !v),
|
|
682
|
-
refreshInterval: f,
|
|
683
|
-
queryFn: s,
|
|
684
|
-
abortController: i,
|
|
685
|
-
refreshCounter: e.refreshCounter
|
|
686
|
-
}, h = {
|
|
687
|
-
datasource: r,
|
|
688
|
-
metrics: g(() => [
|
|
689
|
-
u.value ? "response_latency_average" : "response_latency_p99"
|
|
690
|
-
]),
|
|
691
|
-
// To keep single-entity queries consistent, don't bother querying the dimension for latency
|
|
692
|
-
// in the single-entity case, even though it's possible.
|
|
693
|
-
...t && !c ? { dimensions: [t] } : {},
|
|
694
|
-
filter: p,
|
|
695
|
-
queryReady: n,
|
|
696
|
-
timeRange: l,
|
|
697
|
-
// Don't query latency trends in the multi-entity case: it's possible, but wasteful.
|
|
698
|
-
withTrend: g(() => d.value && !v),
|
|
699
|
-
refreshInterval: f,
|
|
700
|
-
queryFn: s,
|
|
701
|
-
abortController: i,
|
|
702
|
-
refreshCounter: e.refreshCounter
|
|
703
|
-
}, I = V.useMetricFetcher(_), m = V.useMetricFetcher(h);
|
|
704
|
-
return {
|
|
705
|
-
trafficData: I,
|
|
706
|
-
latencyData: m
|
|
707
|
-
};
|
|
708
|
-
}, gt = /* @__PURE__ */ W({
|
|
709
|
-
__name: "MetricsProvider",
|
|
710
|
-
props: {
|
|
711
|
-
datasource: { default: void 0 },
|
|
712
|
-
maxTimeRange: { default: "30d" },
|
|
713
|
-
overrideTimeRange: { default: void 0 },
|
|
714
|
-
dimension: { default: void 0 },
|
|
715
|
-
filterValue: { default: void 0 },
|
|
716
|
-
additionalFilter: { default: void 0 },
|
|
717
|
-
queryReady: { type: Boolean, default: !0 },
|
|
718
|
-
refreshInterval: { default: fr },
|
|
719
|
-
longCardTitles: { type: Boolean, default: !1 },
|
|
720
|
-
containerTitle: { default: void 0 },
|
|
721
|
-
description: { default: void 0 },
|
|
722
|
-
percentileLatency: { type: Boolean, default: void 0 },
|
|
723
|
-
abortController: { default: void 0 },
|
|
724
|
-
refreshCounter: { default: 0 }
|
|
725
|
-
},
|
|
726
|
-
setup(e) {
|
|
727
|
-
const r = e;
|
|
728
|
-
if (r.dimension && He.findIndex((c) => c === r.dimension) === -1)
|
|
729
|
-
throw new Error(`Attempted to use MetricsProvider with an invalid dimension: ${r.dimension}`);
|
|
730
|
-
const t = Se(vr);
|
|
731
|
-
let o;
|
|
732
|
-
t ? o = t.queryFn : (console.warn("Analytics dashboards require a query bridge supplied via provide / inject."), console.warn("Please ensure your application has a query bridge provided under the key 'analytics-query-provider', as described in"), console.warn("https://github.com/Kong/public-ui-components/blob/main/packages/analytics/analytics-metric-provider/README.md#requirements"), o = () => Promise.reject(new Error("Query bridge required")));
|
|
733
|
-
const a = We(), n = g(() => !0), l = g(() => !a.loading && r.queryReady), d = g(() => r.datasource ? r.datasource : "basic"), f = g(() => {
|
|
734
|
-
const c = r.overrideTimeRange;
|
|
735
|
-
return c && !c.tz && (c.tz = new Intl.DateTimeFormat().resolvedOptions().timeZone), c || {
|
|
736
|
-
type: "relative",
|
|
737
|
-
time_range: "7d",
|
|
738
|
-
tz: new Intl.DateTimeFormat().resolvedOptions().timeZone
|
|
739
|
-
};
|
|
740
|
-
}), i = g(() => !r.percentileLatency), {
|
|
741
|
-
trafficData: s,
|
|
742
|
-
latencyData: u
|
|
743
|
-
} = Mr({
|
|
744
|
-
datasource: d,
|
|
745
|
-
dimension: r.dimension,
|
|
746
|
-
dimensionFilterValue: r.filterValue,
|
|
747
|
-
additionalFilter: G(r, "additionalFilter"),
|
|
748
|
-
queryReady: l,
|
|
749
|
-
timeRange: f,
|
|
750
|
-
hasTrendAccess: n,
|
|
751
|
-
refreshInterval: r.refreshInterval,
|
|
752
|
-
queryFn: o,
|
|
753
|
-
averageLatencies: i,
|
|
754
|
-
abortController: r.abortController,
|
|
755
|
-
refreshCounter: G(r, "refreshCounter")
|
|
756
|
-
});
|
|
757
|
-
return ze(Me, {
|
|
758
|
-
data: {
|
|
759
|
-
traffic: s,
|
|
760
|
-
latency: u
|
|
761
|
-
},
|
|
762
|
-
description: G(() => r.description),
|
|
763
|
-
containerTitle: G(() => r.containerTitle),
|
|
764
|
-
hasTrendAccess: n,
|
|
765
|
-
longCardTitles: r.longCardTitles,
|
|
766
|
-
averageLatencies: i
|
|
767
|
-
}), (c, v) => Ce(c.$slots, "default", {
|
|
768
|
-
hasTrendAccess: n.value,
|
|
769
|
-
timeRange: f.value
|
|
770
|
-
});
|
|
771
|
-
}
|
|
772
|
-
});
|
|
773
|
-
function Vr(e) {
|
|
774
|
-
return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
|
|
775
|
-
}
|
|
776
|
-
var Ve = { exports: {} };
|
|
777
|
-
(function(e) {
|
|
778
|
-
(function() {
|
|
779
|
-
function r(i, s) {
|
|
780
|
-
if (s.separator === !1 || i < 1e3)
|
|
781
|
-
return i.toString();
|
|
782
|
-
var u = typeof s.separator == "string" ? s.separator : ",", c = [], v = Math.round(i).toString().split("");
|
|
783
|
-
return v.reverse().forEach(function(p, _) {
|
|
784
|
-
_ && _ % 3 === 0 && c.push(u), c.push(p);
|
|
785
|
-
}), c.reverse().join("");
|
|
786
|
-
}
|
|
787
|
-
function t(i, s, u) {
|
|
788
|
-
var c = i / s, v = u.round ? "round" : "floor";
|
|
789
|
-
return u.decimal === !1 ? (i = Math[v](c), i.toString()) : (u.precision ? i = c : i = c < 10 ? Math[v](c * 10) / 10 : Math[v](c), i = i.toString(), typeof u.decimal == "string" && (i = i.replace(".", u.decimal)), i);
|
|
790
|
-
}
|
|
791
|
-
var o = 1e3, a = 1e4, n = 1e6, l = 1e9, d = 1e12;
|
|
792
|
-
function f(i, s) {
|
|
793
|
-
var u;
|
|
794
|
-
s = s || {};
|
|
795
|
-
var c = i < 0;
|
|
796
|
-
c && (i = Math.abs(i)), s.precision && (i = parseFloat(i.toPrecision(s.precision)));
|
|
797
|
-
var v = s.min10k ? a : o;
|
|
798
|
-
return i < v || s.precision && s.precision > Math.log10(i) ? u = r(t(i, 1, s), s) : i < n ? u = t(i, o, s) + "k" : i < l ? u = t(i, n, s) + "m" : i < d ? u = r(t(i, l, s), s) + "b" : u = r(t(i, d, s), s) + "t", c && (u = "-" + u), s.capital && (u = u.toUpperCase()), s.prefix && (u = s.prefix + u), s.suffix && (u = u + s.suffix), u;
|
|
799
|
-
}
|
|
800
|
-
f.addCommas = r, e.exports = f;
|
|
801
|
-
})();
|
|
802
|
-
})(Ve);
|
|
803
|
-
var Nr = Ve.exports;
|
|
804
|
-
const kr = /* @__PURE__ */ Vr(Nr);
|
|
805
|
-
var O = /* @__PURE__ */ ((e) => (e.GENERIC_COUNT = "GenericCount", e.TRAFFIC = "Traffic", e.ERROR_RATE = "ErrorRate", e.LATENCY = "Latency", e))(O || {}), D = /* @__PURE__ */ ((e) => (e.Small = "sm", e.Medium = "md", e.Large = "lg", e.ExtraLarge = "xl", e))(D || {});
|
|
806
|
-
const ue = 2, Te = ue + 2, Fr = (e, r, t = !1) => {
|
|
807
|
-
let o = !r || Number(e.toFixed(Te)) === 0 ? 0 : Number(e.toFixed(Te)) > 0 ? 1 : -1;
|
|
808
|
-
return t && (o *= -1), o;
|
|
809
|
-
}, xr = (e, r, t) => r ? `${Math.abs(e * 100).toFixed(ue)}%` : t, qr = (e, r) => r === 0 ? 0 : e / r - 1, Ur = (e, r = !1) => (r && (e *= -1), e > 0 ? Je : e < 0 ? Ze : De), Pr = "#ad000e", oe = "#6c7489", Ee = "#52596e", $r = "#007d60", j = "16px", zr = "20px", Kr = {
|
|
810
|
-
key: 0,
|
|
811
|
-
class: "metricscard-description"
|
|
812
|
-
}, Br = { class: "metricscard-valuetrend" }, Xr = {
|
|
813
|
-
key: 0,
|
|
814
|
-
class: "metricscard-error"
|
|
815
|
-
}, Gr = {
|
|
816
|
-
key: 2,
|
|
817
|
-
class: "metricscard-trend"
|
|
818
|
-
}, jr = { "data-testid": "metric-trend-change" }, Hr = {
|
|
819
|
-
key: 0,
|
|
820
|
-
class: "metricscard-trend-range"
|
|
821
|
-
}, Yr = /* @__PURE__ */ W({
|
|
822
|
-
__name: "MetricsCard",
|
|
823
|
-
props: {
|
|
824
|
-
cardType: {
|
|
825
|
-
type: String,
|
|
826
|
-
required: !0,
|
|
827
|
-
default: O.GENERIC_COUNT
|
|
828
|
-
},
|
|
829
|
-
title: {
|
|
830
|
-
type: String,
|
|
831
|
-
default: "0%",
|
|
832
|
-
required: !0
|
|
833
|
-
},
|
|
834
|
-
description: {
|
|
835
|
-
type: String,
|
|
836
|
-
default: "",
|
|
837
|
-
required: !1
|
|
838
|
-
},
|
|
839
|
-
tooltip: {
|
|
840
|
-
type: String,
|
|
841
|
-
required: !1,
|
|
842
|
-
default: ""
|
|
843
|
-
},
|
|
844
|
-
timeframe: {
|
|
845
|
-
type: String,
|
|
846
|
-
required: !1,
|
|
847
|
-
default: ""
|
|
848
|
-
},
|
|
849
|
-
metricValue: {
|
|
850
|
-
type: String,
|
|
851
|
-
default: ""
|
|
852
|
-
},
|
|
853
|
-
metricChange: {
|
|
854
|
-
type: String,
|
|
855
|
-
required: !0
|
|
856
|
-
},
|
|
857
|
-
changePolarity: {
|
|
858
|
-
type: Number,
|
|
859
|
-
required: !0
|
|
860
|
-
},
|
|
861
|
-
trendIcon: {
|
|
862
|
-
type: Object,
|
|
863
|
-
default: De
|
|
864
|
-
},
|
|
865
|
-
trendRange: {
|
|
866
|
-
type: String,
|
|
867
|
-
default: ""
|
|
868
|
-
},
|
|
869
|
-
hasError: {
|
|
870
|
-
type: Boolean,
|
|
871
|
-
default: !1
|
|
872
|
-
},
|
|
873
|
-
errorMessage: {
|
|
874
|
-
type: String,
|
|
875
|
-
default: "Vitals data error"
|
|
876
|
-
},
|
|
877
|
-
cardSize: {
|
|
878
|
-
type: String,
|
|
879
|
-
required: !1,
|
|
880
|
-
default: () => D.Large
|
|
881
|
-
},
|
|
882
|
-
hasContainerTitle: {
|
|
883
|
-
type: Boolean,
|
|
884
|
-
required: !1,
|
|
885
|
-
default: !1
|
|
886
|
-
},
|
|
887
|
-
titleTag: {
|
|
888
|
-
type: String,
|
|
889
|
-
default: "span"
|
|
890
|
-
}
|
|
891
|
-
},
|
|
892
|
-
setup(e) {
|
|
893
|
-
const r = /* @__PURE__ */ new Map([
|
|
894
|
-
[O.GENERIC_COUNT, er],
|
|
895
|
-
[O.TRAFFIC, rr],
|
|
896
|
-
[O.ERROR_RATE, tr],
|
|
897
|
-
[O.LATENCY, nr]
|
|
898
|
-
]), t = e, o = (d) => {
|
|
899
|
-
const f = {
|
|
900
|
-
red: `var(--kui-color-text-danger-strong, ${Pr})`,
|
|
901
|
-
green: `var(--kui-color-text-success, ${$r})`,
|
|
902
|
-
grey: `var(--kui-color-text-neutral-strong, ${Ee})`
|
|
903
|
-
};
|
|
904
|
-
return d > 0 ? f.green : d < 0 ? f.red : f.grey;
|
|
905
|
-
}, a = (d) => d > 0 ? "positive" : d < 0 ? "negative" : "neutral", n = [D.Medium, D.Large].includes(t.cardSize), l = [D.Small].includes(t.cardSize);
|
|
906
|
-
return (d, f) => {
|
|
907
|
-
const i = Ie("KTooltip");
|
|
908
|
-
return R(), S("div", {
|
|
909
|
-
class: z(["metricscard", e.cardSize])
|
|
910
|
-
}, [
|
|
911
|
-
q("div", {
|
|
912
|
-
class: z(["metricscard-title", e.cardSize])
|
|
913
|
-
}, [
|
|
914
|
-
E(l) ? M("", !0) : (R(), U(re(E(r).get(e.cardType)), {
|
|
915
|
-
key: 0,
|
|
916
|
-
class: "metricscard-icon",
|
|
917
|
-
color: `var(--kui-color-text-neutral, ${E(oe)})`,
|
|
918
|
-
size: E(j)
|
|
919
|
-
}, null, 8, ["color", "size"])),
|
|
920
|
-
(R(), U(re(e.titleTag), null, {
|
|
921
|
-
default: me(() => [
|
|
922
|
-
Ae(w(e.title), 1)
|
|
923
|
-
]),
|
|
924
|
-
_: 1
|
|
925
|
-
})),
|
|
926
|
-
e.tooltip ? (R(), U(i, {
|
|
927
|
-
key: 1,
|
|
928
|
-
class: "metricscard-tooltip",
|
|
929
|
-
placement: "right",
|
|
930
|
-
text: e.tooltip
|
|
931
|
-
}, {
|
|
932
|
-
default: me(() => [
|
|
933
|
-
F(E(ar), {
|
|
934
|
-
color: `var(--kui-color-text-neutral, ${E(oe)})`,
|
|
935
|
-
size: E(j)
|
|
936
|
-
}, null, 8, ["color", "size"])
|
|
937
|
-
]),
|
|
938
|
-
_: 1
|
|
939
|
-
}, 8, ["text"])) : M("", !0)
|
|
940
|
-
], 2),
|
|
941
|
-
e.description && E(n) ? (R(), S("div", Kr, [
|
|
942
|
-
q("span", null, w(e.description), 1)
|
|
943
|
-
])) : M("", !0),
|
|
944
|
-
q("div", Br, [
|
|
945
|
-
e.hasError ? (R(), S("div", Xr, [
|
|
946
|
-
F(E(be), {
|
|
947
|
-
color: `var(--kui-color-text-neutral, ${E(oe)})`,
|
|
948
|
-
size: E(zr)
|
|
949
|
-
}, null, 8, ["color", "size"]),
|
|
950
|
-
q("div", null, " " + w(e.errorMessage), 1)
|
|
951
|
-
])) : (R(), S("div", {
|
|
952
|
-
key: 1,
|
|
953
|
-
class: z(["metricscard-value", e.cardSize]),
|
|
954
|
-
"data-testid": "metric-value"
|
|
955
|
-
}, w(e.metricValue), 3)),
|
|
956
|
-
E(n) ? (R(), S("div", Gr, [
|
|
957
|
-
q("div", {
|
|
958
|
-
class: z(["metricscard-trend-change", a(e.changePolarity)]),
|
|
959
|
-
"data-testid": "metric-trend-parent"
|
|
960
|
-
}, [
|
|
961
|
-
e.changePolarity !== 0 ? (R(), U(re(e.trendIcon), {
|
|
962
|
-
key: 0,
|
|
963
|
-
color: o(e.changePolarity),
|
|
964
|
-
size: E(j)
|
|
965
|
-
}, null, 8, ["color", "size"])) : (R(), U(E(ir), {
|
|
966
|
-
key: 1,
|
|
967
|
-
color: `var(--kui-color-text-neutral-strong, ${E(Ee)})`,
|
|
968
|
-
size: E(j)
|
|
969
|
-
}, null, 8, ["color", "size"])),
|
|
970
|
-
q("div", jr, w(e.metricChange), 1)
|
|
971
|
-
], 2),
|
|
972
|
-
e.trendRange ? (R(), S("div", Hr, w(e.trendRange), 1)) : M("", !0)
|
|
973
|
-
])) : M("", !0)
|
|
974
|
-
])
|
|
975
|
-
], 2);
|
|
976
|
-
};
|
|
977
|
-
}
|
|
978
|
-
}), le = (e, r) => {
|
|
979
|
-
const t = e.__vccOpts || e;
|
|
980
|
-
for (const [o, a] of r)
|
|
981
|
-
t[o] = a;
|
|
982
|
-
return t;
|
|
983
|
-
}, Qr = /* @__PURE__ */ le(Yr, [["__scopeId", "data-v-b1513f6f"]]), Wr = {}, Jr = { class: "loading-tabs" };
|
|
984
|
-
function Zr(e, r) {
|
|
985
|
-
const t = Ie("KSkeletonBox");
|
|
986
|
-
return R(), S("div", Jr, [
|
|
987
|
-
F(t, { width: "100" }),
|
|
988
|
-
F(t, { width: "75" })
|
|
989
|
-
]);
|
|
990
|
-
}
|
|
991
|
-
const et = /* @__PURE__ */ le(Wr, [["render", Zr], ["__scopeId", "data-v-9c7113d7"]]), rt = {
|
|
992
|
-
key: 0,
|
|
993
|
-
class: "container-title"
|
|
994
|
-
}, tt = {
|
|
995
|
-
key: 0,
|
|
996
|
-
class: "container-description"
|
|
997
|
-
}, nt = {
|
|
998
|
-
key: 1,
|
|
999
|
-
class: "error-display"
|
|
1000
|
-
}, at = {
|
|
1001
|
-
key: 0,
|
|
1002
|
-
class: "error-display-message"
|
|
1003
|
-
}, it = {
|
|
1004
|
-
key: 2,
|
|
1005
|
-
class: "cards-wrapper"
|
|
1006
|
-
}, ot = /* @__PURE__ */ W({
|
|
1007
|
-
__name: "MetricCardContainer",
|
|
1008
|
-
props: {
|
|
1009
|
-
fallbackDisplayText: {
|
|
1010
|
-
type: String,
|
|
1011
|
-
required: !0
|
|
1012
|
-
},
|
|
1013
|
-
cards: {
|
|
1014
|
-
type: Array,
|
|
1015
|
-
required: !0
|
|
1016
|
-
},
|
|
1017
|
-
errorMessage: {
|
|
1018
|
-
type: String,
|
|
1019
|
-
required: !1,
|
|
1020
|
-
default: ""
|
|
1021
|
-
},
|
|
1022
|
-
loading: {
|
|
1023
|
-
type: Boolean,
|
|
1024
|
-
required: !1,
|
|
1025
|
-
default: !1
|
|
1026
|
-
},
|
|
1027
|
-
hasTrendAccess: {
|
|
1028
|
-
type: Boolean,
|
|
1029
|
-
required: !1,
|
|
1030
|
-
default: !0
|
|
1031
|
-
},
|
|
1032
|
-
cardSize: {
|
|
1033
|
-
type: String,
|
|
1034
|
-
required: !1,
|
|
1035
|
-
default: () => D.Large
|
|
1036
|
-
},
|
|
1037
|
-
containerTitle: {
|
|
1038
|
-
type: String,
|
|
1039
|
-
required: !1,
|
|
1040
|
-
default: ""
|
|
1041
|
-
},
|
|
1042
|
-
containerDescription: {
|
|
1043
|
-
type: String,
|
|
1044
|
-
required: !1,
|
|
1045
|
-
default: ""
|
|
1046
|
-
}
|
|
1047
|
-
},
|
|
1048
|
-
setup(e) {
|
|
1049
|
-
const r = e, t = g(() => r.cards.every((a) => (a == null ? void 0 : a.hasError) === !0)), o = (a) => {
|
|
1050
|
-
const n = qr(a.currentValue, a.previousValue) || 0, l = Fr(n, r.hasTrendAccess, a.increaseIsBad);
|
|
1051
|
-
return {
|
|
1052
|
-
metricValue: a.formatValueFn ? a.formatValueFn(a.currentValue) : kr(a.currentValue, { capital: !0, round: !0 }) || "0",
|
|
1053
|
-
metricChange: a.formatChangeFn ? a.formatChangeFn(n) : xr(n, r.hasTrendAccess, r.fallbackDisplayText),
|
|
1054
|
-
changePolarity: l,
|
|
1055
|
-
trendIcon: Ur(l, a.increaseIsBad),
|
|
1056
|
-
cardSize: r.cardSize,
|
|
1057
|
-
hasContainerTitle: !!r.containerTitle
|
|
1058
|
-
};
|
|
1059
|
-
};
|
|
1060
|
-
return (a, n) => (R(), S("div", {
|
|
1061
|
-
class: z(["kong-ui-public-metric-card-container", e.cardSize])
|
|
1062
|
-
}, [
|
|
1063
|
-
r.containerTitle || r.containerDescription ? (R(), S("div", rt, [
|
|
1064
|
-
Ae(w(r.containerTitle) + " ", 1),
|
|
1065
|
-
r.containerDescription ? (R(), S("div", tt, w(r.containerDescription), 1)) : M("", !0)
|
|
1066
|
-
])) : M("", !0),
|
|
1067
|
-
t.value ? (R(), S("div", nt, [
|
|
1068
|
-
F(E(be), { class: "error-display-icon" }),
|
|
1069
|
-
e.errorMessage ? (R(), S("div", at, w(e.errorMessage), 1)) : M("", !0)
|
|
1070
|
-
])) : (R(), S("div", it, [
|
|
1071
|
-
(R(!0), S(ye, null, Ke(e.cards, (l, d) => (R(), S(ye, null, [
|
|
1072
|
-
e.loading ? (R(), S("div", {
|
|
1073
|
-
key: `skeleton-${d}`,
|
|
1074
|
-
class: "loading-tab"
|
|
1075
|
-
}, [
|
|
1076
|
-
F(et, {
|
|
1077
|
-
class: z(e.cardSize === E(D).Small ? "loading-tabs-small" : "loading-tabs-large")
|
|
1078
|
-
}, null, 8, ["class"])
|
|
1079
|
-
])) : (R(), U(Qr, Be({ key: d }, { ref_for: !0 }, o(l), {
|
|
1080
|
-
"card-size": e.cardSize,
|
|
1081
|
-
"card-type": l.cardType,
|
|
1082
|
-
description: l.description,
|
|
1083
|
-
"error-message": e.errorMessage,
|
|
1084
|
-
"has-error": l.hasError,
|
|
1085
|
-
title: l.title,
|
|
1086
|
-
"title-tag": l.titleTag,
|
|
1087
|
-
tooltip: l.tooltip,
|
|
1088
|
-
"trend-range": l.trendRange
|
|
1089
|
-
}), null, 16, ["card-size", "card-type", "description", "error-message", "has-error", "title", "title-tag", "tooltip", "trend-range"]))
|
|
1090
|
-
], 64))), 256))
|
|
1091
|
-
]))
|
|
1092
|
-
], 2));
|
|
1093
|
-
}
|
|
1094
|
-
}), st = /* @__PURE__ */ le(ot, [["__scopeId", "data-v-7080ba56"]]), ht = /* @__PURE__ */ W({
|
|
1095
|
-
__name: "MetricsConsumer",
|
|
1096
|
-
props: {
|
|
1097
|
-
lookupKey: { default: void 0 },
|
|
1098
|
-
cardSize: { default: D.Large },
|
|
1099
|
-
cardToDisplay: { default: void 0 }
|
|
1100
|
-
},
|
|
1101
|
-
setup(e) {
|
|
1102
|
-
const r = e, t = Se(Me);
|
|
1103
|
-
if (!t)
|
|
1104
|
-
throw new Error("MetricsConsumer must be nested inside a MetricsProvider instance.");
|
|
1105
|
-
const { traffic: o, latency: a } = t.data, { i18n: n } = V.useI18n(), l = g(() => t.containerTitle.value ? D.Medium : r.cardSize), d = V.useMetricCardBuilder({
|
|
1106
|
-
cardType: O.TRAFFIC,
|
|
1107
|
-
title: g(() => t.longCardTitles ? n.t("metricCard.long.traffic") : n.t("metricCard.short.traffic")),
|
|
1108
|
-
record: o.mapped,
|
|
1109
|
-
hasError: o.hasError,
|
|
1110
|
-
lookupKey: r.lookupKey,
|
|
1111
|
-
sumGroupedValues: B,
|
|
1112
|
-
trendRange: o.trendRange
|
|
1113
|
-
}), f = (h) => `${h.toFixed(ue)}%`, i = g(() => {
|
|
1114
|
-
const h = o.mapped.value, I = K(h, "current", r.lookupKey, ge), m = K(h, "current", r.lookupKey, B), y = I / m * 100 || 0, N = K(h, "previous", r.lookupKey, ge), T = K(h, "previous", r.lookupKey, B), C = N / T * 100 || 0;
|
|
1115
|
-
return {
|
|
1116
|
-
cardType: O.ERROR_RATE,
|
|
1117
|
-
hasError: o.hasError.value,
|
|
1118
|
-
currentValue: y,
|
|
1119
|
-
previousValue: C,
|
|
1120
|
-
formatValueFn: f,
|
|
1121
|
-
title: t.longCardTitles ? n.t("metricCard.long.errorRate") : n.t("metricCard.short.errorRate"),
|
|
1122
|
-
increaseIsBad: !0,
|
|
1123
|
-
trendRange: o.trendRange.value
|
|
1124
|
-
};
|
|
1125
|
-
}), s = (h) => `${h}ms`, u = V.useMetricCardBuilder({
|
|
1126
|
-
cardType: O.LATENCY,
|
|
1127
|
-
title: g(() => {
|
|
1128
|
-
const { longCardTitles: h, averageLatencies: I } = t, m = I.value ? "averageLatency" : "p99Latency";
|
|
1129
|
-
return h ? n.t(`metricCard.long.${m}`) : l.value === D.Small ? n.t(`metricCard.small.${m}`) : n.t(`metricCard.short.${m}`);
|
|
1130
|
-
}),
|
|
1131
|
-
hasError: a.hasError,
|
|
1132
|
-
record: a.mapped,
|
|
1133
|
-
lookupKey: r.lookupKey,
|
|
1134
|
-
increaseIsBad: !0,
|
|
1135
|
-
formatValueFn: s,
|
|
1136
|
-
trendRange: a.trendRange
|
|
1137
|
-
}), c = g(() => r.cardToDisplay === "TRAFFIC" ? [d.value] : r.cardToDisplay === "ERROR_RATE" ? [i.value] : r.cardToDisplay === "LATENCY" ? [u.value] : [d.value, i.value, u.value]), v = g(() => r.cardToDisplay === "TRAFFIC" || r.cardToDisplay === "ERROR_RATE" ? o.isLoading.value : r.cardToDisplay === "LATENCY" ? a.isLoading.value : o.isLoading.value || a.isLoading.value), p = g(() => ({
|
|
1138
|
-
cards: c.value,
|
|
1139
|
-
containerTitle: t.containerTitle.value,
|
|
1140
|
-
containerDescription: t.description.value,
|
|
1141
|
-
loading: v.value,
|
|
1142
|
-
hasTrendAccess: t.hasTrendAccess.value,
|
|
1143
|
-
fallbackDisplayText: n.t("general.notAvailable"),
|
|
1144
|
-
cardSize: l.value,
|
|
1145
|
-
hideTitle: !0
|
|
1146
|
-
})), _ = g(() => ({
|
|
1147
|
-
loading: p.value.loading,
|
|
1148
|
-
trafficCard: d.value,
|
|
1149
|
-
errorRateCard: i.value,
|
|
1150
|
-
latencyCard: u.value,
|
|
1151
|
-
errorRateFormatted: f(i.value.currentValue),
|
|
1152
|
-
latencyFormatted: s(u.value.currentValue)
|
|
1153
|
-
}));
|
|
1154
|
-
return (h, I) => Ce(h.$slots, "default", { cardValues: _.value }, () => [
|
|
1155
|
-
F(st, Xe(Ge(p.value)), null, 16)
|
|
1156
|
-
]);
|
|
1157
|
-
}
|
|
1158
|
-
}), H = (e) => new Date(e), pt = (e, r) => {
|
|
1159
|
-
const t = e.body;
|
|
1160
|
-
e.reply({
|
|
1161
|
-
statusCode: 200,
|
|
1162
|
-
body: ut(t, r)
|
|
1163
|
-
});
|
|
1164
|
-
}, _e = (e) => e.reduce((r, t) => (r[t] = { name: t }, r), {}), ut = (e, r) => {
|
|
1165
|
-
var _, h, I;
|
|
1166
|
-
const t = r != null && r.timeRange && {
|
|
1167
|
-
start: r.timeRange.start,
|
|
1168
|
-
end: r.timeRange.end
|
|
1169
|
-
} || ((_ = e.time_range) == null ? void 0 : _.type) === "absolute" ? {
|
|
1170
|
-
// @ts-ignore - already asserted time range is absolute above
|
|
1171
|
-
start: new Date(e.time_range.start),
|
|
1172
|
-
// @ts-ignore - already asserted time range is absolute above
|
|
1173
|
-
end: new Date(e.time_range.end)
|
|
1174
|
-
} : {
|
|
1175
|
-
start: new Date(Date.now() - 864e5),
|
|
1176
|
-
end: /* @__PURE__ */ new Date()
|
|
1177
|
-
}, o = t.end.getTime() - t.start.getTime(), a = e.granularity === "trend" ? {
|
|
1178
|
-
start: new Date(t.start.getTime() - o),
|
|
1179
|
-
end: t.end,
|
|
1180
|
-
granularity: t.end.getTime() - t.start.getTime()
|
|
1181
|
-
} : {
|
|
1182
|
-
start: t.start,
|
|
1183
|
-
end: t.end,
|
|
1184
|
-
granularity: t.end.getTime() - t.start.getTime()
|
|
1185
|
-
}, n = a.end.getTime(), l = a.start.getTime(), d = a.granularity, f = e.granularity === "trend" ? 2 : 1;
|
|
1186
|
-
if ((e.dimensions ?? []).length > 2)
|
|
1187
|
-
throw new Error(`Explore only supports 0-2 dimensions; got: ${JSON.stringify(e.dimensions)}`);
|
|
1188
|
-
const i = (e.dimensions ?? []).find((m) => m !== "time"), s = (r == null ? void 0 : r.dimensionNames) ?? [], u = Math.max(s.length, 1), c = e.metrics || [], v = [];
|
|
1189
|
-
for (let m = 0; m < f; m++)
|
|
1190
|
-
for (let y = 0; y < u; y++) {
|
|
1191
|
-
const N = i ? { [i]: s[y] } : {};
|
|
1192
|
-
(h = e.dimensions) != null && h.includes("status_code_grouped") ? B.forEach((T) => {
|
|
1193
|
-
const C = c.reduce((A, x) => ((r == null ? void 0 : r.deterministic) ?? !0 ? A[x] = (f - m) * 1e3 + 100 * y + 1 : A[x] = Math.round(Math.random() * 1e3), A), { ...N, status_code_grouped: T });
|
|
1194
|
-
v.push({
|
|
1195
|
-
version: "v1",
|
|
1196
|
-
timestamp: m === 0 ? H(l).toISOString() : H(l + d).toISOString(),
|
|
1197
|
-
event: C
|
|
1198
|
-
});
|
|
1199
|
-
}) : v.push({
|
|
1200
|
-
version: "v1",
|
|
1201
|
-
timestamp: m === 0 ? H(l).toISOString() : H(l + d).toISOString(),
|
|
1202
|
-
event: c.reduce((T, C) => ((r == null ? void 0 : r.deterministic) ?? !0 ? T[C] = (f - m) * 1e3 + 100 * y + 1 : T[C] = Math.round(Math.random() * 1e3), T), { ...N })
|
|
1203
|
-
});
|
|
1204
|
-
}
|
|
1205
|
-
const p = {
|
|
1206
|
-
start_ms: l,
|
|
1207
|
-
end_ms: n,
|
|
1208
|
-
start: new Date(l).toISOString(),
|
|
1209
|
-
end: new Date(n).toISOString(),
|
|
1210
|
-
granularity_ms: d,
|
|
1211
|
-
display: i ? {
|
|
1212
|
-
[i]: _e(s),
|
|
1213
|
-
...(I = e.dimensions) != null && I.includes("status_code_grouped") ? { status_code_grouped: _e(B) } : {}
|
|
1214
|
-
} : {},
|
|
1215
|
-
metric_names: e.metrics,
|
|
1216
|
-
query_id: "test"
|
|
1217
|
-
};
|
|
1218
|
-
return {
|
|
1219
|
-
data: v,
|
|
1220
|
-
meta: p
|
|
1221
|
-
};
|
|
1222
|
-
};
|
|
1223
|
-
export {
|
|
1224
|
-
B as ALL_STATUS_CODE_GROUPS,
|
|
1225
|
-
ue as DECIMAL_DISPLAY,
|
|
1226
|
-
Te as DECIMAL_ROUNDING_PRECISION,
|
|
1227
|
-
fr as DEFAULT_REFRESH_INTERVAL,
|
|
1228
|
-
vr as INJECT_QUERY_PROVIDER,
|
|
1229
|
-
dr as MAX_ANALYTICS_REQUEST_RETRIES,
|
|
1230
|
-
D as MetricCardSize,
|
|
1231
|
-
O as MetricCardType,
|
|
1232
|
-
ht as MetricsConsumer,
|
|
1233
|
-
gt as MetricsProvider,
|
|
1234
|
-
ge as STATUS_CODES_FAILED,
|
|
1235
|
-
yt as STATUS_CODES_SUCCESS,
|
|
1236
|
-
qr as calculateChange,
|
|
1237
|
-
Fr as changePolarity,
|
|
1238
|
-
Ur as defineIcon,
|
|
1239
|
-
xr as metricChange,
|
|
1240
|
-
ut as mockExploreResponse,
|
|
1241
|
-
pt as mockExploreResponseFromCypress,
|
|
1242
|
-
Rr as useTrendRange
|
|
1243
|
-
};
|