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