@kong-ui-public/analytics-metric-provider 11.0.2-pr.2637.b25f7e003.0 → 11.0.3-pr.2637.08ad5f08e.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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ref as Y, watchEffect as
|
|
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
2
|
import { stripUnknownFilters as je, queryableExploreDimensions as He } from "@kong-ui-public/analytics-utilities";
|
|
3
3
|
import { createI18n as Ye, i18nTComponent as Qe } from "@kong-ui-public/i18n";
|
|
4
4
|
import "axios";
|
|
@@ -58,17 +58,17 @@ function cr() {
|
|
|
58
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
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
60
|
const mr = (e) => {
|
|
61
|
-
var r, t,
|
|
61
|
+
var r, t, o, a, n;
|
|
62
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 = (
|
|
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
64
|
};
|
|
65
|
-
function yr(e = Y({}), r, t,
|
|
65
|
+
function yr(e = Y({}), r, t, o = mr) {
|
|
66
66
|
const a = Y(
|
|
67
67
|
"PENDING"
|
|
68
68
|
/* PENDING */
|
|
69
69
|
);
|
|
70
|
-
return
|
|
71
|
-
const n =
|
|
70
|
+
return Ne(() => {
|
|
71
|
+
const n = o(e.value);
|
|
72
72
|
if (e.value && n && t.value) {
|
|
73
73
|
a.value = "VALIDATING_HAS_DATA";
|
|
74
74
|
return;
|
|
@@ -99,18 +99,18 @@ function yr(e = Y({}), r, t, i = mr) {
|
|
|
99
99
|
swrvState: we
|
|
100
100
|
};
|
|
101
101
|
}
|
|
102
|
-
const L = Symbol("default"), te = "status_code_grouped", he = (e, r, t,
|
|
103
|
-
e[r][t] || (e[r][t] = {}), e[r][t][
|
|
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
104
|
};
|
|
105
105
|
function gr(e, r) {
|
|
106
|
-
var
|
|
107
|
-
const t = ((
|
|
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
108
|
return a.length > 2 || a.length > 1 && !n ? (console.error("Don't know how to work with provided dimensions:", a), {
|
|
109
109
|
previous: { [L]: { [L]: 0 } },
|
|
110
110
|
current: { [L]: { [L]: 0 } }
|
|
111
|
-
}) : e.data.reduce((
|
|
112
|
-
const s =
|
|
113
|
-
return new Date(
|
|
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
114
|
}, {
|
|
115
115
|
previous: {},
|
|
116
116
|
current: {}
|
|
@@ -119,7 +119,7 @@ function gr(e, r) {
|
|
|
119
119
|
function hr(e) {
|
|
120
120
|
e.queryReady === void 0 && (e.queryReady = g(() => !0));
|
|
121
121
|
const r = g(() => {
|
|
122
|
-
var s,
|
|
122
|
+
var s, u;
|
|
123
123
|
return {
|
|
124
124
|
metrics: e.metrics.value,
|
|
125
125
|
dimensions: [
|
|
@@ -127,16 +127,16 @@ function hr(e) {
|
|
|
127
127
|
...e.withTrend.value ? ["time"] : []
|
|
128
128
|
],
|
|
129
129
|
granularity: e.withTrend.value ? "trend" : void 0,
|
|
130
|
-
...(
|
|
130
|
+
...(u = e.filter.value) != null && u.length ? { filters: e.filter.value } : {},
|
|
131
131
|
time_range: e.timeRange.value
|
|
132
132
|
};
|
|
133
133
|
}), t = g(() => {
|
|
134
|
-
var
|
|
135
|
-
if (!((
|
|
134
|
+
var u, c, v, p;
|
|
135
|
+
if (!((u = e.queryReady) != null && u.value))
|
|
136
136
|
return null;
|
|
137
|
-
const s = (
|
|
137
|
+
const s = (c = e.filter) != null && c.value ? JSON.stringify(e.filter.value) : "";
|
|
138
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:
|
|
139
|
+
}), { response: o, error: a, isValidating: n } = V.useRequest(
|
|
140
140
|
() => t.value,
|
|
141
141
|
() => e.queryFn({
|
|
142
142
|
// TODO: Use a type guard to validate that if the datasource is basic,
|
|
@@ -149,78 +149,90 @@ function hr(e) {
|
|
|
149
149
|
revalidateOnFocus: !1,
|
|
150
150
|
errorRetryCount: dr
|
|
151
151
|
}
|
|
152
|
-
), { state:
|
|
153
|
-
var s,
|
|
154
|
-
return !((
|
|
155
|
-
}),
|
|
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
156
|
var s;
|
|
157
|
-
return (s =
|
|
157
|
+
return (s = o.value) == null ? void 0 : s.meta;
|
|
158
158
|
}));
|
|
159
159
|
return {
|
|
160
|
-
isLoading: g(() =>
|
|
161
|
-
hasError: g(() =>
|
|
162
|
-
raw:
|
|
163
|
-
mapped:
|
|
164
|
-
trendRange:
|
|
160
|
+
isLoading: g(() => d.PENDING === l.value),
|
|
161
|
+
hasError: g(() => d.ERROR === l.value),
|
|
162
|
+
raw: o,
|
|
163
|
+
mapped: f,
|
|
164
|
+
trendRange: i
|
|
165
165
|
};
|
|
166
166
|
}
|
|
167
|
-
const K = (e, r, t = L,
|
|
168
|
-
const
|
|
169
|
-
return
|
|
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
170
|
}, 0);
|
|
171
171
|
function pr(e) {
|
|
172
172
|
const {
|
|
173
173
|
cardType: r,
|
|
174
174
|
title: t,
|
|
175
|
-
description:
|
|
175
|
+
description: o,
|
|
176
176
|
record: a,
|
|
177
177
|
hasError: n,
|
|
178
|
-
increaseIsBad:
|
|
179
|
-
formatValueFn:
|
|
180
|
-
trendRange:
|
|
178
|
+
increaseIsBad: l,
|
|
179
|
+
formatValueFn: d,
|
|
180
|
+
trendRange: f
|
|
181
181
|
} = e;
|
|
182
182
|
return g(() => {
|
|
183
|
-
let
|
|
183
|
+
let i = 0, s = 0;
|
|
184
184
|
if (a != null && a.value)
|
|
185
185
|
try {
|
|
186
|
-
|
|
187
|
-
} catch (
|
|
186
|
+
i = K(a.value, "current", e.lookupKey, e.sumGroupedValues), s = K(a.value, "previous", e.lookupKey, e.sumGroupedValues);
|
|
187
|
+
} catch (u) {
|
|
188
188
|
console.error(
|
|
189
189
|
"Metric card data doesn't have the expected structure:",
|
|
190
|
-
|
|
190
|
+
u
|
|
191
191
|
);
|
|
192
192
|
}
|
|
193
193
|
return {
|
|
194
194
|
cardType: r,
|
|
195
195
|
hasError: n.value,
|
|
196
|
-
currentValue:
|
|
196
|
+
currentValue: i,
|
|
197
197
|
previousValue: s,
|
|
198
198
|
title: t.value,
|
|
199
|
-
description:
|
|
200
|
-
increaseIsBad: !!
|
|
199
|
+
description: o,
|
|
200
|
+
increaseIsBad: !!l,
|
|
201
201
|
// Coerce undefined to false
|
|
202
|
-
formatValueFn:
|
|
203
|
-
trendRange:
|
|
202
|
+
formatValueFn: d,
|
|
203
|
+
trendRange: f == null ? void 0 : f.value
|
|
204
204
|
};
|
|
205
205
|
});
|
|
206
206
|
}
|
|
207
207
|
function Rr(e, r, t) {
|
|
208
|
-
const { i18n:
|
|
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
|
+
};
|
|
209
226
|
return g(() => {
|
|
210
|
-
var
|
|
211
|
-
if (
|
|
212
|
-
return
|
|
213
|
-
if (((
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
a = new Date(r.value.start).getTime(), n = new Date(r.value.end).getTime();
|
|
220
|
-
else
|
|
221
|
-
return "";
|
|
222
|
-
let u = (n - a) / (1e3 * 60 * 60 * 24), c = (n - a) / (1e3 * 60 * 60), d = (n - a) / (1e3 * 60);
|
|
223
|
-
return e.value && (u /= 2, c /= 2, d /= 2), u >= 1 ? i.t("trendRange.custom_days", { numDays: Math.round(u) }) : c >= 1 ? i.t("trendRange.custom_hours", { numHours: Math.round(c) }) : d >= 1 ? i.t("trendRange.custom_minutes", { numMinutes: Math.round(d) }) : i.t("trendRange.custom_days", { numDays: Math.round(u) });
|
|
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 "";
|
|
224
236
|
});
|
|
225
237
|
}
|
|
226
238
|
var ne = /* @__PURE__ */ new WeakMap(), pe = 0;
|
|
@@ -228,8 +240,8 @@ function Tr(e) {
|
|
|
228
240
|
if (!e.length)
|
|
229
241
|
return "";
|
|
230
242
|
for (var r = "arg", t = 0; t < e.length; ++t) {
|
|
231
|
-
var
|
|
232
|
-
e[t] === null || typeof e[t] != "object" && typeof e[t] != "function" ? typeof e[t] == "string" ?
|
|
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;
|
|
233
245
|
}
|
|
234
246
|
return r;
|
|
235
247
|
}
|
|
@@ -253,18 +265,18 @@ var se = (
|
|
|
253
265
|
}, e.prototype.get = function(r) {
|
|
254
266
|
var t = this.serializeKey(r);
|
|
255
267
|
return this.items.get(t);
|
|
256
|
-
}, e.prototype.set = function(r, t,
|
|
257
|
-
var a = this.serializeKey(r), n =
|
|
268
|
+
}, e.prototype.set = function(r, t, o) {
|
|
269
|
+
var a = this.serializeKey(r), n = o || this.ttl, l = Date.now(), d = {
|
|
258
270
|
data: t,
|
|
259
|
-
createdAt:
|
|
260
|
-
expiresAt: n ?
|
|
271
|
+
createdAt: l,
|
|
272
|
+
expiresAt: n ? l + n : 1 / 0
|
|
261
273
|
};
|
|
262
|
-
this.dispatchExpire(n,
|
|
263
|
-
}, e.prototype.dispatchExpire = function(r, t,
|
|
274
|
+
this.dispatchExpire(n, d, a), this.items.set(a, d);
|
|
275
|
+
}, e.prototype.dispatchExpire = function(r, t, o) {
|
|
264
276
|
var a = this;
|
|
265
277
|
r && setTimeout(function() {
|
|
266
|
-
var n = Date.now(),
|
|
267
|
-
|
|
278
|
+
var n = Date.now(), l = n >= t.expiresAt;
|
|
279
|
+
l && a.delete(o);
|
|
268
280
|
}, r);
|
|
269
281
|
}, e.prototype.delete = function(r) {
|
|
270
282
|
this.items.delete(r);
|
|
@@ -274,131 +286,131 @@ var se = (
|
|
|
274
286
|
function _r() {
|
|
275
287
|
return typeof navigator.onLine < "u" ? navigator.onLine : !0;
|
|
276
288
|
}
|
|
277
|
-
function
|
|
289
|
+
function Sr() {
|
|
278
290
|
return typeof document < "u" && typeof document.visibilityState < "u" ? document.visibilityState !== "hidden" : !0;
|
|
279
291
|
}
|
|
280
|
-
var
|
|
292
|
+
var Cr = function(e) {
|
|
281
293
|
return fetch(e).then(function(r) {
|
|
282
294
|
return r.json();
|
|
283
295
|
});
|
|
284
296
|
};
|
|
285
297
|
const ae = {
|
|
286
298
|
isOnline: _r,
|
|
287
|
-
isDocumentVisible:
|
|
288
|
-
fetcher:
|
|
299
|
+
isDocumentVisible: Sr,
|
|
300
|
+
fetcher: Cr
|
|
289
301
|
};
|
|
290
302
|
var b = function() {
|
|
291
303
|
return b = Object.assign || function(e) {
|
|
292
|
-
for (var r, t = 1,
|
|
304
|
+
for (var r, t = 1, o = arguments.length; t < o; t++) {
|
|
293
305
|
r = arguments[t];
|
|
294
306
|
for (var a in r) Object.prototype.hasOwnProperty.call(r, a) && (e[a] = r[a]);
|
|
295
307
|
}
|
|
296
308
|
return e;
|
|
297
309
|
}, b.apply(this, arguments);
|
|
298
|
-
}, P = function(e, r, t,
|
|
310
|
+
}, P = function(e, r, t, o) {
|
|
299
311
|
function a(n) {
|
|
300
|
-
return n instanceof t ? n : new t(function(
|
|
301
|
-
|
|
312
|
+
return n instanceof t ? n : new t(function(l) {
|
|
313
|
+
l(n);
|
|
302
314
|
});
|
|
303
315
|
}
|
|
304
|
-
return new (t || (t = Promise))(function(n,
|
|
305
|
-
function
|
|
316
|
+
return new (t || (t = Promise))(function(n, l) {
|
|
317
|
+
function d(s) {
|
|
306
318
|
try {
|
|
307
|
-
o
|
|
308
|
-
} catch (
|
|
309
|
-
u
|
|
319
|
+
i(o.next(s));
|
|
320
|
+
} catch (u) {
|
|
321
|
+
l(u);
|
|
310
322
|
}
|
|
311
323
|
}
|
|
312
|
-
function
|
|
324
|
+
function f(s) {
|
|
313
325
|
try {
|
|
314
|
-
o
|
|
315
|
-
} catch (
|
|
316
|
-
u
|
|
326
|
+
i(o.throw(s));
|
|
327
|
+
} catch (u) {
|
|
328
|
+
l(u);
|
|
317
329
|
}
|
|
318
330
|
}
|
|
319
|
-
function
|
|
320
|
-
s.done ? n(s.value) : a(s.value).then(
|
|
331
|
+
function i(s) {
|
|
332
|
+
s.done ? n(s.value) : a(s.value).then(d, f);
|
|
321
333
|
}
|
|
322
|
-
|
|
334
|
+
i((o = o.apply(e, r || [])).next());
|
|
323
335
|
});
|
|
324
336
|
}, $ = function(e, r) {
|
|
325
337
|
var t = { label: 0, sent: function() {
|
|
326
338
|
if (n[0] & 1) throw n[1];
|
|
327
339
|
return n[1];
|
|
328
|
-
}, trys: [], ops: [] },
|
|
329
|
-
return
|
|
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() {
|
|
330
342
|
return this;
|
|
331
|
-
}),
|
|
332
|
-
function
|
|
343
|
+
}), l;
|
|
344
|
+
function d(i) {
|
|
333
345
|
return function(s) {
|
|
334
|
-
return
|
|
346
|
+
return f([i, s]);
|
|
335
347
|
};
|
|
336
348
|
}
|
|
337
|
-
function
|
|
338
|
-
if (
|
|
349
|
+
function f(i) {
|
|
350
|
+
if (o) throw new TypeError("Generator is already executing.");
|
|
339
351
|
for (; t; ) try {
|
|
340
|
-
if (
|
|
341
|
-
switch (a = 0, n && (
|
|
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]) {
|
|
342
354
|
case 0:
|
|
343
355
|
case 1:
|
|
344
|
-
n =
|
|
356
|
+
n = i;
|
|
345
357
|
break;
|
|
346
358
|
case 4:
|
|
347
|
-
return t.label++, { value:
|
|
359
|
+
return t.label++, { value: i[1], done: !1 };
|
|
348
360
|
case 5:
|
|
349
|
-
t.label++, a =
|
|
361
|
+
t.label++, a = i[1], i = [0];
|
|
350
362
|
continue;
|
|
351
363
|
case 7:
|
|
352
|
-
|
|
364
|
+
i = t.ops.pop(), t.trys.pop();
|
|
353
365
|
continue;
|
|
354
366
|
default:
|
|
355
|
-
if (n = t.trys, !(n = n.length > 0 && n[n.length - 1]) && (
|
|
367
|
+
if (n = t.trys, !(n = n.length > 0 && n[n.length - 1]) && (i[0] === 6 || i[0] === 2)) {
|
|
356
368
|
t = 0;
|
|
357
369
|
continue;
|
|
358
370
|
}
|
|
359
|
-
if (
|
|
360
|
-
t.label =
|
|
371
|
+
if (i[0] === 3 && (!n || i[1] > n[0] && i[1] < n[3])) {
|
|
372
|
+
t.label = i[1];
|
|
361
373
|
break;
|
|
362
374
|
}
|
|
363
|
-
if (
|
|
364
|
-
t.label = n[1], n =
|
|
375
|
+
if (i[0] === 6 && t.label < n[1]) {
|
|
376
|
+
t.label = n[1], n = i;
|
|
365
377
|
break;
|
|
366
378
|
}
|
|
367
379
|
if (n && t.label < n[2]) {
|
|
368
|
-
t.label = n[2], t.ops.push(
|
|
380
|
+
t.label = n[2], t.ops.push(i);
|
|
369
381
|
break;
|
|
370
382
|
}
|
|
371
383
|
n[2] && t.ops.pop(), t.trys.pop();
|
|
372
384
|
continue;
|
|
373
385
|
}
|
|
374
|
-
|
|
386
|
+
i = r.call(e, t);
|
|
375
387
|
} catch (s) {
|
|
376
|
-
|
|
388
|
+
i = [6, s], a = 0;
|
|
377
389
|
} finally {
|
|
378
|
-
|
|
390
|
+
o = n = 0;
|
|
379
391
|
}
|
|
380
|
-
if (
|
|
381
|
-
return { value:
|
|
392
|
+
if (i[0] & 5) throw i[1];
|
|
393
|
+
return { value: i[0] ? i[1] : void 0, done: !0 };
|
|
382
394
|
}
|
|
383
395
|
}, Ir = function(e, r) {
|
|
384
396
|
var t = typeof Symbol == "function" && e[Symbol.iterator];
|
|
385
397
|
if (!t) return e;
|
|
386
|
-
var
|
|
398
|
+
var o = t.call(e), a, n = [], l;
|
|
387
399
|
try {
|
|
388
|
-
for (; (r === void 0 || r-- > 0) && !(a =
|
|
389
|
-
} catch (
|
|
390
|
-
|
|
400
|
+
for (; (r === void 0 || r-- > 0) && !(a = o.next()).done; ) n.push(a.value);
|
|
401
|
+
} catch (d) {
|
|
402
|
+
l = { error: d };
|
|
391
403
|
} finally {
|
|
392
404
|
try {
|
|
393
|
-
a && !a.done && (t =
|
|
405
|
+
a && !a.done && (t = o.return) && t.call(o);
|
|
394
406
|
} finally {
|
|
395
|
-
if (
|
|
407
|
+
if (l) throw l.error;
|
|
396
408
|
}
|
|
397
409
|
}
|
|
398
410
|
return n;
|
|
399
411
|
}, Ar = function(e, r, t) {
|
|
400
|
-
if (t || arguments.length === 2) for (var
|
|
401
|
-
(n || !(
|
|
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]);
|
|
402
414
|
return e.concat(n || Array.prototype.slice.call(r));
|
|
403
415
|
}, Oe = new se(), Q = new se(), ie = new se(), Le = {
|
|
404
416
|
cache: Oe,
|
|
@@ -416,9 +428,9 @@ var b = function() {
|
|
|
416
428
|
isDocumentVisible: ae.isDocumentVisible
|
|
417
429
|
};
|
|
418
430
|
function Dr(e, r, t) {
|
|
419
|
-
var
|
|
420
|
-
if (
|
|
421
|
-
|
|
431
|
+
var o = Q.get(e);
|
|
432
|
+
if (o)
|
|
433
|
+
o.data.push(r);
|
|
422
434
|
else {
|
|
423
435
|
var a = 5e3;
|
|
424
436
|
Q.set(e, [r], t > 0 ? t + a : t);
|
|
@@ -426,44 +438,44 @@ function Dr(e, r, t) {
|
|
|
426
438
|
}
|
|
427
439
|
function br(e, r, t) {
|
|
428
440
|
if (t.isDocumentVisible() && !(t.errorRetryCount !== void 0 && r > t.errorRetryCount)) {
|
|
429
|
-
var
|
|
441
|
+
var o = Math.min(r || 0, t.errorRetryCount), a = o * t.errorRetryInterval;
|
|
430
442
|
setTimeout(function() {
|
|
431
|
-
e(null, { errorRetryCount:
|
|
443
|
+
e(null, { errorRetryCount: o + 1, shouldRetryOnError: !0 });
|
|
432
444
|
}, a);
|
|
433
445
|
}
|
|
434
446
|
}
|
|
435
|
-
var Re = function(e, r, t,
|
|
436
|
-
return t === void 0 && (t = Oe),
|
|
437
|
-
var a, n,
|
|
438
|
-
return $(this, function(
|
|
439
|
-
switch (
|
|
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) {
|
|
440
452
|
case 0:
|
|
441
453
|
if (!Or(r)) return [3, 5];
|
|
442
|
-
|
|
454
|
+
u.label = 1;
|
|
443
455
|
case 1:
|
|
444
|
-
return
|
|
456
|
+
return u.trys.push([1, 3, , 4]), [4, r];
|
|
445
457
|
case 2:
|
|
446
|
-
return a =
|
|
458
|
+
return a = u.sent(), [3, 4];
|
|
447
459
|
case 3:
|
|
448
|
-
return
|
|
460
|
+
return d = u.sent(), n = d, [3, 4];
|
|
449
461
|
case 4:
|
|
450
462
|
return [3, 6];
|
|
451
463
|
case 5:
|
|
452
|
-
a = r,
|
|
464
|
+
a = r, u.label = 6;
|
|
453
465
|
case 6:
|
|
454
|
-
if (
|
|
466
|
+
if (l = !1, f = { data: a, error: n, isValidating: l }, typeof a < "u")
|
|
455
467
|
try {
|
|
456
|
-
t.set(e,
|
|
457
|
-
} catch (
|
|
458
|
-
console.error("swrv(mutate): failed to set cache",
|
|
468
|
+
t.set(e, f, o);
|
|
469
|
+
} catch (c) {
|
|
470
|
+
console.error("swrv(mutate): failed to set cache", c);
|
|
459
471
|
}
|
|
460
|
-
return
|
|
461
|
-
return
|
|
462
|
-
}), s.forEach(function(
|
|
463
|
-
typeof
|
|
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;
|
|
464
476
|
var p = v === s.length - 1;
|
|
465
477
|
p || delete s[v];
|
|
466
|
-
}), s = s.filter(Boolean)), [2,
|
|
478
|
+
}), s = s.filter(Boolean)), [2, f];
|
|
467
479
|
}
|
|
468
480
|
});
|
|
469
481
|
});
|
|
@@ -471,12 +483,12 @@ var Re = function(e, r, t, i) {
|
|
|
471
483
|
function wr() {
|
|
472
484
|
for (var e = this, r = [], t = 0; t < arguments.length; t++)
|
|
473
485
|
r[t] = arguments[t];
|
|
474
|
-
var
|
|
475
|
-
if (!
|
|
486
|
+
var o, a, n = b({}, Le), l = !1, d = !1, f = ke(), i = (f == null ? void 0 : f.proxy) || f;
|
|
487
|
+
if (!i)
|
|
476
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;
|
|
477
|
-
var s = (
|
|
478
|
-
r.length >= 1 && (
|
|
479
|
-
var
|
|
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);
|
|
480
492
|
typeof a > "u" && (a = n.fetcher);
|
|
481
493
|
var v = null;
|
|
482
494
|
v || (v = Fe({
|
|
@@ -488,31 +500,31 @@ function wr() {
|
|
|
488
500
|
}));
|
|
489
501
|
var p = function(m, y) {
|
|
490
502
|
return P(e, void 0, void 0, function() {
|
|
491
|
-
var
|
|
503
|
+
var N, T, C, A, x, ce, J, de = this;
|
|
492
504
|
return $(this, function(Z) {
|
|
493
505
|
switch (Z.label) {
|
|
494
506
|
case 0:
|
|
495
|
-
return
|
|
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, [
|
|
496
508
|
2
|
|
497
509
|
/*return*/
|
|
498
|
-
]) :
|
|
510
|
+
]) : C && (ce = !!(Date.now() - C.createdAt >= n.dedupingInterval || y != null && y.forceRevalidate), !ce) ? (v.isValidating = !1, v.isLoading = !1, [
|
|
499
511
|
2
|
|
500
512
|
/*return*/
|
|
501
513
|
]) : (J = function() {
|
|
502
514
|
return P(de, void 0, void 0, function() {
|
|
503
|
-
var
|
|
515
|
+
var k, fe, ee, ve;
|
|
504
516
|
return $(this, function(X) {
|
|
505
517
|
switch (X.label) {
|
|
506
518
|
case 0:
|
|
507
|
-
return
|
|
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)]);
|
|
508
520
|
case 1:
|
|
509
521
|
return X.sent(), [3, 4];
|
|
510
522
|
case 2:
|
|
511
|
-
return [4, Re(T,
|
|
523
|
+
return [4, Re(T, k.data, n.cache, u)];
|
|
512
524
|
case 3:
|
|
513
525
|
X.sent(), X.label = 4;
|
|
514
526
|
case 4:
|
|
515
|
-
return v.isValidating = !1, v.isLoading = !1, ie.delete(T), v.error !== void 0 && (ve = !
|
|
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)), [
|
|
516
528
|
2
|
|
517
529
|
/*return*/
|
|
518
530
|
];
|
|
@@ -521,12 +533,12 @@ function wr() {
|
|
|
521
533
|
});
|
|
522
534
|
}, A && n.revalidateDebounce ? (setTimeout(function() {
|
|
523
535
|
return P(de, void 0, void 0, function() {
|
|
524
|
-
return $(this, function(
|
|
525
|
-
switch (
|
|
536
|
+
return $(this, function(k) {
|
|
537
|
+
switch (k.label) {
|
|
526
538
|
case 0:
|
|
527
|
-
return
|
|
539
|
+
return l ? [3, 2] : [4, J()];
|
|
528
540
|
case 1:
|
|
529
|
-
|
|
541
|
+
k.sent(), k.label = 2;
|
|
530
542
|
case 2:
|
|
531
543
|
return [
|
|
532
544
|
2
|
|
@@ -570,7 +582,7 @@ function wr() {
|
|
|
570
582
|
case 2:
|
|
571
583
|
h && clearTimeout(h), y.label = 3;
|
|
572
584
|
case 3:
|
|
573
|
-
return n.refreshInterval && !
|
|
585
|
+
return n.refreshInterval && !l && (h = setTimeout(m, n.refreshInterval)), [
|
|
574
586
|
2
|
|
575
587
|
/*return*/
|
|
576
588
|
];
|
|
@@ -580,15 +592,15 @@ function wr() {
|
|
|
580
592
|
};
|
|
581
593
|
n.refreshInterval && (h = setTimeout(m, n.refreshInterval)), n.revalidateOnFocus && (document.addEventListener("visibilitychange", _, !1), window.addEventListener("focus", _, !1));
|
|
582
594
|
}), qe(function() {
|
|
583
|
-
|
|
584
|
-
var m = Q.get(
|
|
595
|
+
l = !0, h && clearTimeout(h), n.revalidateOnFocus && (document.removeEventListener("visibilitychange", _, !1), window.removeEventListener("focus", _, !1));
|
|
596
|
+
var m = Q.get(c.value);
|
|
585
597
|
m && (m.data = m.data.filter(function(y) {
|
|
586
598
|
return y !== v;
|
|
587
599
|
}));
|
|
588
600
|
});
|
|
589
601
|
try {
|
|
590
|
-
Ue(
|
|
591
|
-
Pe(
|
|
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;
|
|
592
604
|
}, {
|
|
593
605
|
immediate: !0
|
|
594
606
|
});
|
|
@@ -604,10 +616,10 @@ function Or(e) {
|
|
|
604
616
|
}
|
|
605
617
|
function Lr(e, r, t) {
|
|
606
618
|
const {
|
|
607
|
-
data:
|
|
619
|
+
data: o,
|
|
608
620
|
error: a,
|
|
609
621
|
isValidating: n,
|
|
610
|
-
mutate:
|
|
622
|
+
mutate: l
|
|
611
623
|
} = wr(e, r, {
|
|
612
624
|
revalidateDebounce: 500,
|
|
613
625
|
revalidateOnFocus: !1,
|
|
@@ -615,41 +627,41 @@ function Lr(e, r, t) {
|
|
|
615
627
|
...t
|
|
616
628
|
});
|
|
617
629
|
return {
|
|
618
|
-
data: g(() =>
|
|
619
|
-
response:
|
|
630
|
+
data: g(() => o.value),
|
|
631
|
+
response: o,
|
|
620
632
|
error: a,
|
|
621
633
|
isValidating: n,
|
|
622
|
-
revalidate:
|
|
634
|
+
revalidate: l
|
|
623
635
|
};
|
|
624
636
|
}
|
|
625
|
-
const
|
|
637
|
+
const V = {
|
|
626
638
|
useI18n: cr,
|
|
627
639
|
useMetricCardBuilder: pr,
|
|
628
640
|
useMetricFetcher: hr,
|
|
629
641
|
useTrendRange: Rr,
|
|
630
642
|
useRequest: Lr
|
|
631
|
-
},
|
|
643
|
+
}, Me = Symbol("METRICS_PROVIDER_KEY"), Mr = (e) => {
|
|
632
644
|
const {
|
|
633
645
|
datasource: r,
|
|
634
646
|
dimension: t,
|
|
635
|
-
dimensionFilterValue:
|
|
647
|
+
dimensionFilterValue: o,
|
|
636
648
|
additionalFilter: a,
|
|
637
649
|
queryReady: n,
|
|
638
|
-
timeRange:
|
|
639
|
-
hasTrendAccess:
|
|
640
|
-
refreshInterval:
|
|
641
|
-
abortController:
|
|
650
|
+
timeRange: l,
|
|
651
|
+
hasTrendAccess: d,
|
|
652
|
+
refreshInterval: f,
|
|
653
|
+
abortController: i,
|
|
642
654
|
queryFn: s,
|
|
643
|
-
averageLatencies:
|
|
655
|
+
averageLatencies: u
|
|
644
656
|
} = e;
|
|
645
|
-
if (
|
|
657
|
+
if (o && !t)
|
|
646
658
|
throw new Error("Must provide a dimension if filtering by a value");
|
|
647
|
-
const
|
|
659
|
+
const c = !!(t && o), v = !!(t && !o), p = g(() => {
|
|
648
660
|
const y = [];
|
|
649
|
-
return
|
|
661
|
+
return c && y.push({
|
|
650
662
|
field: t,
|
|
651
663
|
operator: "in",
|
|
652
|
-
value: [
|
|
664
|
+
value: [o]
|
|
653
665
|
}), a.value && y.push(...je(r.value, a.value)), y;
|
|
654
666
|
}), _ = {
|
|
655
667
|
datasource: r,
|
|
@@ -659,36 +671,36 @@ const N = {
|
|
|
659
671
|
// Traffic and error rate cards should only try to query for the dimension if it's going to be used.
|
|
660
672
|
// It isn't used for single entity queries.
|
|
661
673
|
dimensions: [
|
|
662
|
-
...t && !
|
|
674
|
+
...t && !c ? [t] : [],
|
|
663
675
|
"status_code_grouped"
|
|
664
676
|
],
|
|
665
677
|
filter: p,
|
|
666
678
|
queryReady: n,
|
|
667
|
-
timeRange:
|
|
679
|
+
timeRange: l,
|
|
668
680
|
// Traffic and error rate cards can't query trend if multiple entities are expected.
|
|
669
|
-
withTrend: g(() =>
|
|
670
|
-
refreshInterval:
|
|
681
|
+
withTrend: g(() => d.value && !v),
|
|
682
|
+
refreshInterval: f,
|
|
671
683
|
queryFn: s,
|
|
672
|
-
abortController:
|
|
684
|
+
abortController: i,
|
|
673
685
|
refreshCounter: e.refreshCounter
|
|
674
686
|
}, h = {
|
|
675
687
|
datasource: r,
|
|
676
688
|
metrics: g(() => [
|
|
677
|
-
|
|
689
|
+
u.value ? "response_latency_average" : "response_latency_p99"
|
|
678
690
|
]),
|
|
679
691
|
// To keep single-entity queries consistent, don't bother querying the dimension for latency
|
|
680
692
|
// in the single-entity case, even though it's possible.
|
|
681
|
-
...t && !
|
|
693
|
+
...t && !c ? { dimensions: [t] } : {},
|
|
682
694
|
filter: p,
|
|
683
695
|
queryReady: n,
|
|
684
|
-
timeRange:
|
|
696
|
+
timeRange: l,
|
|
685
697
|
// Don't query latency trends in the multi-entity case: it's possible, but wasteful.
|
|
686
|
-
withTrend: g(() =>
|
|
687
|
-
refreshInterval:
|
|
698
|
+
withTrend: g(() => d.value && !v),
|
|
699
|
+
refreshInterval: f,
|
|
688
700
|
queryFn: s,
|
|
689
|
-
abortController:
|
|
701
|
+
abortController: i,
|
|
690
702
|
refreshCounter: e.refreshCounter
|
|
691
|
-
}, I =
|
|
703
|
+
}, I = V.useMetricFetcher(_), m = V.useMetricFetcher(h);
|
|
692
704
|
return {
|
|
693
705
|
trafficData: I,
|
|
694
706
|
latencyData: m
|
|
@@ -713,87 +725,87 @@ const N = {
|
|
|
713
725
|
},
|
|
714
726
|
setup(e) {
|
|
715
727
|
const r = e;
|
|
716
|
-
if (r.dimension && He.findIndex((
|
|
728
|
+
if (r.dimension && He.findIndex((c) => c === r.dimension) === -1)
|
|
717
729
|
throw new Error(`Attempted to use MetricsProvider with an invalid dimension: ${r.dimension}`);
|
|
718
|
-
const t =
|
|
719
|
-
let
|
|
720
|
-
t ?
|
|
721
|
-
const a = We(), n = g(() => !0),
|
|
722
|
-
const
|
|
723
|
-
return
|
|
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 || {
|
|
724
736
|
type: "relative",
|
|
725
737
|
time_range: "7d",
|
|
726
738
|
tz: new Intl.DateTimeFormat().resolvedOptions().timeZone
|
|
727
739
|
};
|
|
728
|
-
}),
|
|
740
|
+
}), i = g(() => !r.percentileLatency), {
|
|
729
741
|
trafficData: s,
|
|
730
|
-
latencyData:
|
|
731
|
-
} =
|
|
732
|
-
datasource:
|
|
742
|
+
latencyData: u
|
|
743
|
+
} = Mr({
|
|
744
|
+
datasource: d,
|
|
733
745
|
dimension: r.dimension,
|
|
734
746
|
dimensionFilterValue: r.filterValue,
|
|
735
747
|
additionalFilter: G(r, "additionalFilter"),
|
|
736
|
-
queryReady:
|
|
737
|
-
timeRange:
|
|
748
|
+
queryReady: l,
|
|
749
|
+
timeRange: f,
|
|
738
750
|
hasTrendAccess: n,
|
|
739
751
|
refreshInterval: r.refreshInterval,
|
|
740
|
-
queryFn:
|
|
741
|
-
averageLatencies:
|
|
752
|
+
queryFn: o,
|
|
753
|
+
averageLatencies: i,
|
|
742
754
|
abortController: r.abortController,
|
|
743
755
|
refreshCounter: G(r, "refreshCounter")
|
|
744
756
|
});
|
|
745
|
-
return ze(
|
|
757
|
+
return ze(Me, {
|
|
746
758
|
data: {
|
|
747
759
|
traffic: s,
|
|
748
|
-
latency:
|
|
760
|
+
latency: u
|
|
749
761
|
},
|
|
750
762
|
description: G(() => r.description),
|
|
751
763
|
containerTitle: G(() => r.containerTitle),
|
|
752
764
|
hasTrendAccess: n,
|
|
753
765
|
longCardTitles: r.longCardTitles,
|
|
754
|
-
averageLatencies:
|
|
755
|
-
}), (
|
|
766
|
+
averageLatencies: i
|
|
767
|
+
}), (c, v) => Ce(c.$slots, "default", {
|
|
756
768
|
hasTrendAccess: n.value,
|
|
757
|
-
timeRange:
|
|
769
|
+
timeRange: f.value
|
|
758
770
|
});
|
|
759
771
|
}
|
|
760
772
|
});
|
|
761
|
-
function
|
|
773
|
+
function Vr(e) {
|
|
762
774
|
return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
|
|
763
775
|
}
|
|
764
|
-
var
|
|
776
|
+
var Ve = { exports: {} };
|
|
765
777
|
(function(e) {
|
|
766
778
|
(function() {
|
|
767
|
-
function r(
|
|
768
|
-
if (s.separator === !1 ||
|
|
769
|
-
return
|
|
770
|
-
var
|
|
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("");
|
|
771
783
|
return v.reverse().forEach(function(p, _) {
|
|
772
|
-
_ && _ % 3 === 0 &&
|
|
773
|
-
}),
|
|
784
|
+
_ && _ % 3 === 0 && c.push(u), c.push(p);
|
|
785
|
+
}), c.reverse().join("");
|
|
774
786
|
}
|
|
775
|
-
function t(
|
|
776
|
-
var
|
|
777
|
-
return
|
|
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);
|
|
778
790
|
}
|
|
779
|
-
var
|
|
780
|
-
function
|
|
781
|
-
var
|
|
791
|
+
var o = 1e3, a = 1e4, n = 1e6, l = 1e9, d = 1e12;
|
|
792
|
+
function f(i, s) {
|
|
793
|
+
var u;
|
|
782
794
|
s = s || {};
|
|
783
|
-
var
|
|
784
|
-
|
|
785
|
-
var v = s.min10k ? a :
|
|
786
|
-
return
|
|
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;
|
|
787
799
|
}
|
|
788
|
-
|
|
800
|
+
f.addCommas = r, e.exports = f;
|
|
789
801
|
})();
|
|
790
|
-
})(
|
|
791
|
-
var
|
|
792
|
-
const
|
|
802
|
+
})(Ve);
|
|
803
|
+
var Nr = Ve.exports;
|
|
804
|
+
const kr = /* @__PURE__ */ Vr(Nr);
|
|
793
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 || {});
|
|
794
806
|
const ue = 2, Te = ue + 2, Fr = (e, r, t = !1) => {
|
|
795
|
-
let
|
|
796
|
-
return t && (
|
|
807
|
+
let o = !r || Number(e.toFixed(Te)) === 0 ? 0 : Number(e.toFixed(Te)) > 0 ? 1 : -1;
|
|
808
|
+
return t && (o *= -1), o;
|
|
797
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 = {
|
|
798
810
|
key: 0,
|
|
799
811
|
class: "metricscard-description"
|
|
@@ -883,23 +895,23 @@ const ue = 2, Te = ue + 2, Fr = (e, r, t = !1) => {
|
|
|
883
895
|
[O.TRAFFIC, rr],
|
|
884
896
|
[O.ERROR_RATE, tr],
|
|
885
897
|
[O.LATENCY, nr]
|
|
886
|
-
]), t = e,
|
|
887
|
-
const
|
|
898
|
+
]), t = e, o = (d) => {
|
|
899
|
+
const f = {
|
|
888
900
|
red: `var(--kui-color-text-danger-strong, ${Pr})`,
|
|
889
901
|
green: `var(--kui-color-text-success, ${$r})`,
|
|
890
902
|
grey: `var(--kui-color-text-neutral-strong, ${Ee})`
|
|
891
903
|
};
|
|
892
|
-
return
|
|
893
|
-
}, a = (
|
|
894
|
-
return (
|
|
895
|
-
const
|
|
896
|
-
return R(),
|
|
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", {
|
|
897
909
|
class: z(["metricscard", e.cardSize])
|
|
898
910
|
}, [
|
|
899
911
|
q("div", {
|
|
900
912
|
class: z(["metricscard-title", e.cardSize])
|
|
901
913
|
}, [
|
|
902
|
-
E(
|
|
914
|
+
E(l) ? M("", !0) : (R(), U(re(E(r).get(e.cardType)), {
|
|
903
915
|
key: 0,
|
|
904
916
|
class: "metricscard-icon",
|
|
905
917
|
color: `var(--kui-color-text-neutral, ${E(oe)})`,
|
|
@@ -911,7 +923,7 @@ const ue = 2, Te = ue + 2, Fr = (e, r, t = !1) => {
|
|
|
911
923
|
]),
|
|
912
924
|
_: 1
|
|
913
925
|
})),
|
|
914
|
-
e.tooltip ? (R(), U(
|
|
926
|
+
e.tooltip ? (R(), U(i, {
|
|
915
927
|
key: 1,
|
|
916
928
|
class: "metricscard-tooltip",
|
|
917
929
|
placement: "right",
|
|
@@ -924,31 +936,31 @@ const ue = 2, Te = ue + 2, Fr = (e, r, t = !1) => {
|
|
|
924
936
|
}, null, 8, ["color", "size"])
|
|
925
937
|
]),
|
|
926
938
|
_: 1
|
|
927
|
-
}, 8, ["text"])) :
|
|
939
|
+
}, 8, ["text"])) : M("", !0)
|
|
928
940
|
], 2),
|
|
929
|
-
e.description && E(n) ? (R(),
|
|
941
|
+
e.description && E(n) ? (R(), S("div", Kr, [
|
|
930
942
|
q("span", null, w(e.description), 1)
|
|
931
|
-
])) :
|
|
943
|
+
])) : M("", !0),
|
|
932
944
|
q("div", Br, [
|
|
933
|
-
e.hasError ? (R(),
|
|
945
|
+
e.hasError ? (R(), S("div", Xr, [
|
|
934
946
|
F(E(be), {
|
|
935
947
|
color: `var(--kui-color-text-neutral, ${E(oe)})`,
|
|
936
948
|
size: E(zr)
|
|
937
949
|
}, null, 8, ["color", "size"]),
|
|
938
950
|
q("div", null, " " + w(e.errorMessage), 1)
|
|
939
|
-
])) : (R(),
|
|
951
|
+
])) : (R(), S("div", {
|
|
940
952
|
key: 1,
|
|
941
953
|
class: z(["metricscard-value", e.cardSize]),
|
|
942
954
|
"data-testid": "metric-value"
|
|
943
955
|
}, w(e.metricValue), 3)),
|
|
944
|
-
E(n) ? (R(),
|
|
956
|
+
E(n) ? (R(), S("div", Gr, [
|
|
945
957
|
q("div", {
|
|
946
958
|
class: z(["metricscard-trend-change", a(e.changePolarity)]),
|
|
947
959
|
"data-testid": "metric-trend-parent"
|
|
948
960
|
}, [
|
|
949
961
|
e.changePolarity !== 0 ? (R(), U(re(e.trendIcon), {
|
|
950
962
|
key: 0,
|
|
951
|
-
color:
|
|
963
|
+
color: o(e.changePolarity),
|
|
952
964
|
size: E(j)
|
|
953
965
|
}, null, 8, ["color", "size"])) : (R(), U(E(ir), {
|
|
954
966
|
key: 1,
|
|
@@ -957,21 +969,21 @@ const ue = 2, Te = ue + 2, Fr = (e, r, t = !1) => {
|
|
|
957
969
|
}, null, 8, ["color", "size"])),
|
|
958
970
|
q("div", jr, w(e.metricChange), 1)
|
|
959
971
|
], 2),
|
|
960
|
-
e.trendRange ? (R(),
|
|
961
|
-
])) :
|
|
972
|
+
e.trendRange ? (R(), S("div", Hr, w(e.trendRange), 1)) : M("", !0)
|
|
973
|
+
])) : M("", !0)
|
|
962
974
|
])
|
|
963
975
|
], 2);
|
|
964
976
|
};
|
|
965
977
|
}
|
|
966
978
|
}), le = (e, r) => {
|
|
967
979
|
const t = e.__vccOpts || e;
|
|
968
|
-
for (const [
|
|
969
|
-
t[
|
|
980
|
+
for (const [o, a] of r)
|
|
981
|
+
t[o] = a;
|
|
970
982
|
return t;
|
|
971
983
|
}, Qr = /* @__PURE__ */ le(Yr, [["__scopeId", "data-v-b1513f6f"]]), Wr = {}, Jr = { class: "loading-tabs" };
|
|
972
984
|
function Zr(e, r) {
|
|
973
985
|
const t = Ie("KSkeletonBox");
|
|
974
|
-
return R(),
|
|
986
|
+
return R(), S("div", Jr, [
|
|
975
987
|
F(t, { width: "100" }),
|
|
976
988
|
F(t, { width: "75" })
|
|
977
989
|
]);
|
|
@@ -1034,46 +1046,46 @@ const et = /* @__PURE__ */ le(Wr, [["render", Zr], ["__scopeId", "data-v-9c7113d
|
|
|
1034
1046
|
}
|
|
1035
1047
|
},
|
|
1036
1048
|
setup(e) {
|
|
1037
|
-
const r = e, t = g(() => r.cards.every((a) => (a == null ? void 0 : a.hasError) === !0)),
|
|
1038
|
-
const n = qr(a.currentValue, a.previousValue) || 0,
|
|
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);
|
|
1039
1051
|
return {
|
|
1040
|
-
metricValue: a.formatValueFn ? a.formatValueFn(a.currentValue) :
|
|
1052
|
+
metricValue: a.formatValueFn ? a.formatValueFn(a.currentValue) : kr(a.currentValue, { capital: !0, round: !0 }) || "0",
|
|
1041
1053
|
metricChange: a.formatChangeFn ? a.formatChangeFn(n) : xr(n, r.hasTrendAccess, r.fallbackDisplayText),
|
|
1042
|
-
changePolarity:
|
|
1043
|
-
trendIcon: Ur(
|
|
1054
|
+
changePolarity: l,
|
|
1055
|
+
trendIcon: Ur(l, a.increaseIsBad),
|
|
1044
1056
|
cardSize: r.cardSize,
|
|
1045
1057
|
hasContainerTitle: !!r.containerTitle
|
|
1046
1058
|
};
|
|
1047
1059
|
};
|
|
1048
|
-
return (a, n) => (R(),
|
|
1060
|
+
return (a, n) => (R(), S("div", {
|
|
1049
1061
|
class: z(["kong-ui-public-metric-card-container", e.cardSize])
|
|
1050
1062
|
}, [
|
|
1051
|
-
r.containerTitle || r.containerDescription ? (R(),
|
|
1063
|
+
r.containerTitle || r.containerDescription ? (R(), S("div", rt, [
|
|
1052
1064
|
Ae(w(r.containerTitle) + " ", 1),
|
|
1053
|
-
r.containerDescription ? (R(),
|
|
1054
|
-
])) :
|
|
1055
|
-
t.value ? (R(),
|
|
1065
|
+
r.containerDescription ? (R(), S("div", tt, w(r.containerDescription), 1)) : M("", !0)
|
|
1066
|
+
])) : M("", !0),
|
|
1067
|
+
t.value ? (R(), S("div", nt, [
|
|
1056
1068
|
F(E(be), { class: "error-display-icon" }),
|
|
1057
|
-
e.errorMessage ? (R(),
|
|
1058
|
-
])) : (R(),
|
|
1059
|
-
(R(!0),
|
|
1060
|
-
e.loading ? (R(),
|
|
1061
|
-
key: `skeleton-${
|
|
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}`,
|
|
1062
1074
|
class: "loading-tab"
|
|
1063
1075
|
}, [
|
|
1064
1076
|
F(et, {
|
|
1065
1077
|
class: z(e.cardSize === E(D).Small ? "loading-tabs-small" : "loading-tabs-large")
|
|
1066
1078
|
}, null, 8, ["class"])
|
|
1067
|
-
])) : (R(), U(Qr, Be({ key:
|
|
1079
|
+
])) : (R(), U(Qr, Be({ key: d }, { ref_for: !0 }, o(l), {
|
|
1068
1080
|
"card-size": e.cardSize,
|
|
1069
|
-
"card-type":
|
|
1070
|
-
description:
|
|
1081
|
+
"card-type": l.cardType,
|
|
1082
|
+
description: l.description,
|
|
1071
1083
|
"error-message": e.errorMessage,
|
|
1072
|
-
"has-error":
|
|
1073
|
-
title:
|
|
1074
|
-
"title-tag":
|
|
1075
|
-
tooltip:
|
|
1076
|
-
"trend-range":
|
|
1084
|
+
"has-error": l.hasError,
|
|
1085
|
+
title: l.title,
|
|
1086
|
+
"title-tag": l.titleTag,
|
|
1087
|
+
tooltip: l.tooltip,
|
|
1088
|
+
"trend-range": l.trendRange
|
|
1077
1089
|
}), null, 16, ["card-size", "card-type", "description", "error-message", "has-error", "title", "title-tag", "tooltip", "trend-range"]))
|
|
1078
1090
|
], 64))), 256))
|
|
1079
1091
|
]))
|
|
@@ -1087,34 +1099,34 @@ const et = /* @__PURE__ */ le(Wr, [["render", Zr], ["__scopeId", "data-v-9c7113d
|
|
|
1087
1099
|
cardToDisplay: { default: void 0 }
|
|
1088
1100
|
},
|
|
1089
1101
|
setup(e) {
|
|
1090
|
-
const r = e, t =
|
|
1102
|
+
const r = e, t = Se(Me);
|
|
1091
1103
|
if (!t)
|
|
1092
1104
|
throw new Error("MetricsConsumer must be nested inside a MetricsProvider instance.");
|
|
1093
|
-
const { traffic:
|
|
1105
|
+
const { traffic: o, latency: a } = t.data, { i18n: n } = V.useI18n(), l = g(() => t.containerTitle.value ? D.Medium : r.cardSize), d = V.useMetricCardBuilder({
|
|
1094
1106
|
cardType: O.TRAFFIC,
|
|
1095
1107
|
title: g(() => t.longCardTitles ? n.t("metricCard.long.traffic") : n.t("metricCard.short.traffic")),
|
|
1096
|
-
record:
|
|
1097
|
-
hasError:
|
|
1108
|
+
record: o.mapped,
|
|
1109
|
+
hasError: o.hasError,
|
|
1098
1110
|
lookupKey: r.lookupKey,
|
|
1099
1111
|
sumGroupedValues: B,
|
|
1100
|
-
trendRange:
|
|
1101
|
-
}),
|
|
1102
|
-
const h =
|
|
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;
|
|
1103
1115
|
return {
|
|
1104
1116
|
cardType: O.ERROR_RATE,
|
|
1105
|
-
hasError:
|
|
1117
|
+
hasError: o.hasError.value,
|
|
1106
1118
|
currentValue: y,
|
|
1107
|
-
previousValue:
|
|
1108
|
-
formatValueFn:
|
|
1119
|
+
previousValue: C,
|
|
1120
|
+
formatValueFn: f,
|
|
1109
1121
|
title: t.longCardTitles ? n.t("metricCard.long.errorRate") : n.t("metricCard.short.errorRate"),
|
|
1110
1122
|
increaseIsBad: !0,
|
|
1111
|
-
trendRange:
|
|
1123
|
+
trendRange: o.trendRange.value
|
|
1112
1124
|
};
|
|
1113
|
-
}), s = (h) => `${h}ms`,
|
|
1125
|
+
}), s = (h) => `${h}ms`, u = V.useMetricCardBuilder({
|
|
1114
1126
|
cardType: O.LATENCY,
|
|
1115
1127
|
title: g(() => {
|
|
1116
1128
|
const { longCardTitles: h, averageLatencies: I } = t, m = I.value ? "averageLatency" : "p99Latency";
|
|
1117
|
-
return h ? n.t(`metricCard.long.${m}`) :
|
|
1129
|
+
return h ? n.t(`metricCard.long.${m}`) : l.value === D.Small ? n.t(`metricCard.small.${m}`) : n.t(`metricCard.short.${m}`);
|
|
1118
1130
|
}),
|
|
1119
1131
|
hasError: a.hasError,
|
|
1120
1132
|
record: a.mapped,
|
|
@@ -1122,24 +1134,24 @@ const et = /* @__PURE__ */ le(Wr, [["render", Zr], ["__scopeId", "data-v-9c7113d
|
|
|
1122
1134
|
increaseIsBad: !0,
|
|
1123
1135
|
formatValueFn: s,
|
|
1124
1136
|
trendRange: a.trendRange
|
|
1125
|
-
}),
|
|
1126
|
-
cards:
|
|
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,
|
|
1127
1139
|
containerTitle: t.containerTitle.value,
|
|
1128
1140
|
containerDescription: t.description.value,
|
|
1129
1141
|
loading: v.value,
|
|
1130
1142
|
hasTrendAccess: t.hasTrendAccess.value,
|
|
1131
1143
|
fallbackDisplayText: n.t("general.notAvailable"),
|
|
1132
|
-
cardSize:
|
|
1144
|
+
cardSize: l.value,
|
|
1133
1145
|
hideTitle: !0
|
|
1134
1146
|
})), _ = g(() => ({
|
|
1135
1147
|
loading: p.value.loading,
|
|
1136
|
-
trafficCard:
|
|
1137
|
-
errorRateCard:
|
|
1138
|
-
latencyCard:
|
|
1139
|
-
errorRateFormatted:
|
|
1140
|
-
latencyFormatted: s(
|
|
1148
|
+
trafficCard: d.value,
|
|
1149
|
+
errorRateCard: i.value,
|
|
1150
|
+
latencyCard: u.value,
|
|
1151
|
+
errorRateFormatted: f(i.value.currentValue),
|
|
1152
|
+
latencyFormatted: s(u.value.currentValue)
|
|
1141
1153
|
}));
|
|
1142
|
-
return (h, I) =>
|
|
1154
|
+
return (h, I) => Ce(h.$slots, "default", { cardValues: _.value }, () => [
|
|
1143
1155
|
F(st, Xe(Ge(p.value)), null, 16)
|
|
1144
1156
|
]);
|
|
1145
1157
|
}
|
|
@@ -1162,42 +1174,42 @@ const et = /* @__PURE__ */ le(Wr, [["render", Zr], ["__scopeId", "data-v-9c7113d
|
|
|
1162
1174
|
} : {
|
|
1163
1175
|
start: new Date(Date.now() - 864e5),
|
|
1164
1176
|
end: /* @__PURE__ */ new Date()
|
|
1165
|
-
},
|
|
1166
|
-
start: new Date(t.start.getTime() -
|
|
1177
|
+
}, o = t.end.getTime() - t.start.getTime(), a = e.granularity === "trend" ? {
|
|
1178
|
+
start: new Date(t.start.getTime() - o),
|
|
1167
1179
|
end: t.end,
|
|
1168
1180
|
granularity: t.end.getTime() - t.start.getTime()
|
|
1169
1181
|
} : {
|
|
1170
1182
|
start: t.start,
|
|
1171
1183
|
end: t.end,
|
|
1172
1184
|
granularity: t.end.getTime() - t.start.getTime()
|
|
1173
|
-
}, n = a.end.getTime(),
|
|
1185
|
+
}, n = a.end.getTime(), l = a.start.getTime(), d = a.granularity, f = e.granularity === "trend" ? 2 : 1;
|
|
1174
1186
|
if ((e.dimensions ?? []).length > 2)
|
|
1175
1187
|
throw new Error(`Explore only supports 0-2 dimensions; got: ${JSON.stringify(e.dimensions)}`);
|
|
1176
|
-
const
|
|
1177
|
-
for (let m = 0; m <
|
|
1178
|
-
for (let y = 0; y <
|
|
1179
|
-
const
|
|
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] } : {};
|
|
1180
1192
|
(h = e.dimensions) != null && h.includes("status_code_grouped") ? B.forEach((T) => {
|
|
1181
|
-
const
|
|
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 });
|
|
1182
1194
|
v.push({
|
|
1183
1195
|
version: "v1",
|
|
1184
|
-
timestamp: m === 0 ? H(
|
|
1185
|
-
event:
|
|
1196
|
+
timestamp: m === 0 ? H(l).toISOString() : H(l + d).toISOString(),
|
|
1197
|
+
event: C
|
|
1186
1198
|
});
|
|
1187
1199
|
}) : v.push({
|
|
1188
1200
|
version: "v1",
|
|
1189
|
-
timestamp: m === 0 ? H(
|
|
1190
|
-
event:
|
|
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 })
|
|
1191
1203
|
});
|
|
1192
1204
|
}
|
|
1193
1205
|
const p = {
|
|
1194
|
-
start_ms:
|
|
1206
|
+
start_ms: l,
|
|
1195
1207
|
end_ms: n,
|
|
1196
|
-
start: new Date(
|
|
1208
|
+
start: new Date(l).toISOString(),
|
|
1197
1209
|
end: new Date(n).toISOString(),
|
|
1198
|
-
granularity_ms:
|
|
1199
|
-
display:
|
|
1200
|
-
[
|
|
1210
|
+
granularity_ms: d,
|
|
1211
|
+
display: i ? {
|
|
1212
|
+
[i]: _e(s),
|
|
1201
1213
|
...(I = e.dimensions) != null && I.includes("status_code_grouped") ? { status_code_grouped: _e(B) } : {}
|
|
1202
1214
|
} : {},
|
|
1203
1215
|
metric_names: e.metrics,
|