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