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