@kong-ui-public/analytics-config-store 1.4.26 → 1.4.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ref as m, inject as C, computed as o, watch as R, defineComponent as D, unref as d, renderSlot as h, createCommentVNode as S } from "vue";
|
|
2
2
|
import { defineStore as b, storeToRefs as T } from "pinia";
|
|
3
|
-
const P = 2592e6, F = 2,
|
|
4
|
-
const e = m(null), u = m(null), p = C(
|
|
3
|
+
const P = 2592e6, F = 2, I = 2e3, M = 10, U = "analytics-query-provider", k = b("analytics-config", () => {
|
|
4
|
+
const e = m(null), u = m(null), p = C(U);
|
|
5
5
|
p ? p.configFn().then((r) => {
|
|
6
6
|
e.value = r;
|
|
7
7
|
}).catch((r) => {
|
|
@@ -13,10 +13,10 @@ const P = 2592e6, F = 2, k = 2e3, I = 10, M = "analytics-query-provider", U = b(
|
|
|
13
13
|
analytics: null,
|
|
14
14
|
requests: null
|
|
15
15
|
});
|
|
16
|
-
const
|
|
16
|
+
const a = o(() => {
|
|
17
17
|
const r = e.value?.analytics?.retention_ms;
|
|
18
18
|
return !!r && r >= P;
|
|
19
|
-
}), f = o(() => "7d"), l = o(() => !e.value),
|
|
19
|
+
}), f = o(() => "7d"), l = o(() => !e.value), v = o(() => !!e.value?.analytics), g = o(() => !!e.value?.analytics?.percentiles), y = () => new Promise((r) => {
|
|
20
20
|
if (!l.value)
|
|
21
21
|
return r();
|
|
22
22
|
const c = R(l, () => {
|
|
@@ -25,21 +25,21 @@ const P = 2592e6, F = 2, k = 2e3, I = 10, M = "analytics-query-provider", U = b(
|
|
|
25
25
|
}), n = o(
|
|
26
26
|
() => e.value?.ui?.maxParallelRequests ?? F
|
|
27
27
|
), t = o(
|
|
28
|
-
() => e.value?.ui?.requestInterval ??
|
|
29
|
-
),
|
|
30
|
-
() => e.value?.ui?.requestIntervalCap ??
|
|
28
|
+
() => e.value?.ui?.requestInterval ?? I
|
|
29
|
+
), i = o(
|
|
30
|
+
() => e.value?.ui?.requestIntervalCap ?? M
|
|
31
31
|
);
|
|
32
32
|
return {
|
|
33
33
|
analyticsConfig: e,
|
|
34
|
-
longRetention:
|
|
34
|
+
longRetention: a,
|
|
35
35
|
defaultQueryTimeForOrg: f,
|
|
36
36
|
loading: l,
|
|
37
|
-
analytics:
|
|
37
|
+
analytics: v,
|
|
38
38
|
percentiles: g,
|
|
39
39
|
maxParallelRequests: n,
|
|
40
40
|
requestInterval: t,
|
|
41
|
-
requestIntervalCap:
|
|
42
|
-
isReady:
|
|
41
|
+
requestIntervalCap: i,
|
|
42
|
+
isReady: y,
|
|
43
43
|
configError: u
|
|
44
44
|
};
|
|
45
45
|
}), L = "analytics-query-provider", Y = b("datasource-config", () => {
|
|
@@ -49,36 +49,36 @@ const P = 2592e6, F = 2, k = 2e3, I = 10, M = "analytics-query-provider", U = b(
|
|
|
49
49
|
}).catch((n) => {
|
|
50
50
|
u.value = n, e.value = [], console.warn("Error fetching datasource config"), console.warn(n);
|
|
51
51
|
}) : (console.warn("Analytics components 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/dashboard-renderer/README.md#requirements"), u.value = new Error("No analytics bridge provided"), e.value = []);
|
|
52
|
-
const
|
|
53
|
-
if (!
|
|
52
|
+
const a = o(() => e.value === void 0), f = async () => new Promise((n) => {
|
|
53
|
+
if (!a.value)
|
|
54
54
|
return n();
|
|
55
|
-
const t = R(() =>
|
|
56
|
-
|
|
55
|
+
const t = R(() => a.value, (i) => {
|
|
56
|
+
i || (t(), n());
|
|
57
57
|
});
|
|
58
58
|
}), l = o(() => (e.value ?? []).reduce((n, t) => {
|
|
59
|
-
const
|
|
59
|
+
const i = t.fields.reduce((r, c) => (r[c.name] = c, r), {});
|
|
60
60
|
return n[t.name] = {
|
|
61
61
|
...t,
|
|
62
|
-
fieldsMap:
|
|
62
|
+
fieldsMap: i
|
|
63
63
|
}, n;
|
|
64
|
-
}, {})),
|
|
64
|
+
}, {})), v = o(() => (n) => a.value ? [] : (e.value ?? []).filter((t) => t.fields.some((i) => i.name === n)).map((t) => t.name)), g = o(() => ({
|
|
65
65
|
datasource: n,
|
|
66
66
|
filter: t
|
|
67
67
|
}) => {
|
|
68
|
-
if (
|
|
68
|
+
if (a.value)
|
|
69
69
|
return !0;
|
|
70
|
-
const
|
|
71
|
-
if (!
|
|
70
|
+
const i = l.value[n];
|
|
71
|
+
if (!i)
|
|
72
72
|
return !0;
|
|
73
|
-
const r =
|
|
73
|
+
const r = i.fieldsMap[t.field];
|
|
74
74
|
return r?.filter ? r.filter.operators.flatMap((c) => c.ops).includes(t.operator) : !1;
|
|
75
|
-
}),
|
|
75
|
+
}), y = o(() => ({
|
|
76
76
|
datasource: n,
|
|
77
77
|
filters: t,
|
|
78
|
-
queryFields:
|
|
78
|
+
queryFields: i = void 0,
|
|
79
79
|
metrics: r = void 0
|
|
80
80
|
}) => {
|
|
81
|
-
const c = t.filter((s) => g.value({ datasource: n, filter: s })), E =
|
|
81
|
+
const c = t.filter((s) => g.value({ datasource: n, filter: s })), E = i ?? r;
|
|
82
82
|
if (!E?.length)
|
|
83
83
|
return c;
|
|
84
84
|
const q = l.value[n];
|
|
@@ -94,11 +94,11 @@ const P = 2592e6, F = 2, k = 2e3, I = 10, M = "analytics-query-provider", U = b(
|
|
|
94
94
|
datasourceConfig: e,
|
|
95
95
|
datasourceConfigError: u,
|
|
96
96
|
datasourceConfigMap: l,
|
|
97
|
-
getFieldDataSources:
|
|
97
|
+
getFieldDataSources: v,
|
|
98
98
|
isFilterValidForDatasource: g,
|
|
99
|
-
loading:
|
|
99
|
+
loading: a,
|
|
100
100
|
isReady: f,
|
|
101
|
-
stripUnknownFilters:
|
|
101
|
+
stripUnknownFilters: y
|
|
102
102
|
};
|
|
103
103
|
}), $ = /* @__PURE__ */ D({
|
|
104
104
|
__name: "AnalyticsConfigCheck",
|
|
@@ -107,25 +107,20 @@ const P = 2592e6, F = 2, k = 2e3, I = 10, M = "analytics-query-provider", U = b(
|
|
|
107
107
|
requirePercentiles: { type: Boolean }
|
|
108
108
|
},
|
|
109
109
|
setup(e) {
|
|
110
|
-
const u = e, p =
|
|
111
|
-
() => (u.requireAnalytics ?
|
|
110
|
+
const u = e, p = k(), { analytics: a, percentiles: f, configError: l, loading: v } = T(p), g = o(
|
|
111
|
+
() => (u.requireAnalytics ? a.value : !0) && (u.requirePercentiles ? f.value : !0)
|
|
112
112
|
);
|
|
113
|
-
return (
|
|
114
|
-
|
|
115
|
-
error: d(l)
|
|
116
|
-
}) : !d(y) && g.value ? h(v.$slots, "default", {
|
|
117
|
-
key: 1,
|
|
118
|
-
hasAnalytics: d(i),
|
|
113
|
+
return (y, n) => !d(v) && d(l) ? h(y.$slots, "error", { error: d(l) }, void 0, void 0, 0) : !d(v) && g.value ? h(y.$slots, "default", {
|
|
114
|
+
hasAnalytics: d(a),
|
|
119
115
|
hasPercentiles: d(f)
|
|
120
|
-
}) : d(
|
|
121
|
-
|
|
122
|
-
hasAnalytics: d(i),
|
|
116
|
+
}, void 0, void 0, 1) : d(v) ? S("", !0) : h(y.$slots, "fallback", {
|
|
117
|
+
hasAnalytics: d(a),
|
|
123
118
|
hasPercentiles: d(f)
|
|
124
|
-
});
|
|
119
|
+
}, void 0, void 0, 2);
|
|
125
120
|
}
|
|
126
121
|
});
|
|
127
122
|
export {
|
|
128
123
|
$ as AnalyticsConfigCheck,
|
|
129
|
-
|
|
124
|
+
k as useAnalyticsConfigStore,
|
|
130
125
|
Y as useDatasourceConfigStore
|
|
131
126
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(u,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue"),require("pinia")):typeof define=="function"&&define.amd?define(["exports","vue","pinia"],e):(u=typeof globalThis<"u"?globalThis:u||self,e(u["kong-ui-public-vitals-config-store"]={},u.Vue,u.pinia))})(this,(function(u,e,E){"use strict";const R="analytics-query-provider",h=E.defineStore("analytics-config",()=>{const n=e.ref(null),d=e.ref(null),f=e.inject(R);f?f.configFn().then(t=>{n.value=t}).catch(t=>{d.value=t,n.value={analytics:null,requests:null},console.warn("Error fetching analytics config"),console.warn(t)}):(console.warn("Analytics components 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/dashboard-renderer/README.md#requirements"),d.value=new Error("No analytics bridge provided"),n.value={analytics:null,requests:null});const a=e.computed(()=>{const t=n.value?.analytics?.retention_ms;return!!t&&t>=2592e6}),p=e.computed(()=>"7d"),c=e.computed(()=>!n.value),y=e.computed(()=>!!n.value?.analytics),g=e.computed(()=>!!n.value?.analytics?.percentiles),m=()=>new Promise(t=>{if(!c.value)return t();const l=e.watch(c,()=>{c.value||(l(),t())})}),r=e.computed(()=>n.value?.ui?.maxParallelRequests??2),o=e.computed(()=>n.value?.ui?.requestInterval??2e3),s=e.computed(()=>n.value?.ui?.requestIntervalCap??10);return{analyticsConfig:n,longRetention:a,defaultQueryTimeForOrg:p,loading:c,analytics:y,percentiles:g,maxParallelRequests:r,requestInterval:o,requestIntervalCap:s,isReady:m,configError:d}}),T="analytics-query-provider",_=E.defineStore("datasource-config",()=>{const n=e.ref(void 0),d=e.ref(null),f=e.inject(T);f?f.datasourceConfigFn().then(r=>{n.value=r}).catch(r=>{d.value=r,n.value=[],console.warn("Error fetching datasource config"),console.warn(r)}):(console.warn("Analytics components 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/dashboard-renderer/README.md#requirements"),d.value=new Error("No analytics bridge provided"),n.value=[]);const a=e.computed(()=>n.value===void 0),p=async()=>new Promise(r=>{if(!a.value)return r();const o=e.watch(()=>a.value,s=>{s||(o(),r())})}),c=e.computed(()=>(n.value??[]).reduce((r,o)=>{const s=o.fields.reduce((t,l)=>(t[l.name]=l,t),{});return r[o.name]={...o,fieldsMap:s},r},{})),y=e.computed(()=>r=>a.value?[]:(n.value??[]).filter(o=>o.fields.some(s=>s.name===r)).map(o=>o.name)),g=e.computed(()=>({datasource:r,filter:o})=>{if(a.value)return!0;const s=c.value[r];if(!s)return!0;const t=s.fieldsMap[o.field];return t?.filter?t.filter.operators.flatMap(l=>l.ops).includes(o.operator):!1}),m=e.computed(()=>({datasource:r,filters:o,queryFields:s=void 0,metrics:t=void 0})=>{const l=o.filter(i=>g.value({datasource:r,filter:i})),A=s??t;if(!A?.length)return l;const S=c.value[r];if(!S)return l;const q=A.map(i=>S.fieldsMap[i]).filter(i=>i!==void 0).filter(i=>i.supportedDimensions!==void 0).map(i=>new Set(i.supportedDimensions));if(!q.length)return l;const
|
|
1
|
+
(function(u,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue"),require("pinia")):typeof define=="function"&&define.amd?define(["exports","vue","pinia"],e):(u=typeof globalThis<"u"?globalThis:u||self,e(u["kong-ui-public-vitals-config-store"]={},u.Vue,u.pinia))})(this,(function(u,e,E){"use strict";const R="analytics-query-provider",h=E.defineStore("analytics-config",()=>{const n=e.ref(null),d=e.ref(null),f=e.inject(R);f?f.configFn().then(t=>{n.value=t}).catch(t=>{d.value=t,n.value={analytics:null,requests:null},console.warn("Error fetching analytics config"),console.warn(t)}):(console.warn("Analytics components 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/dashboard-renderer/README.md#requirements"),d.value=new Error("No analytics bridge provided"),n.value={analytics:null,requests:null});const a=e.computed(()=>{const t=n.value?.analytics?.retention_ms;return!!t&&t>=2592e6}),p=e.computed(()=>"7d"),c=e.computed(()=>!n.value),y=e.computed(()=>!!n.value?.analytics),g=e.computed(()=>!!n.value?.analytics?.percentiles),m=()=>new Promise(t=>{if(!c.value)return t();const l=e.watch(c,()=>{c.value||(l(),t())})}),r=e.computed(()=>n.value?.ui?.maxParallelRequests??2),o=e.computed(()=>n.value?.ui?.requestInterval??2e3),s=e.computed(()=>n.value?.ui?.requestIntervalCap??10);return{analyticsConfig:n,longRetention:a,defaultQueryTimeForOrg:p,loading:c,analytics:y,percentiles:g,maxParallelRequests:r,requestInterval:o,requestIntervalCap:s,isReady:m,configError:d}}),T="analytics-query-provider",_=E.defineStore("datasource-config",()=>{const n=e.ref(void 0),d=e.ref(null),f=e.inject(T);f?f.datasourceConfigFn().then(r=>{n.value=r}).catch(r=>{d.value=r,n.value=[],console.warn("Error fetching datasource config"),console.warn(r)}):(console.warn("Analytics components 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/dashboard-renderer/README.md#requirements"),d.value=new Error("No analytics bridge provided"),n.value=[]);const a=e.computed(()=>n.value===void 0),p=async()=>new Promise(r=>{if(!a.value)return r();const o=e.watch(()=>a.value,s=>{s||(o(),r())})}),c=e.computed(()=>(n.value??[]).reduce((r,o)=>{const s=o.fields.reduce((t,l)=>(t[l.name]=l,t),{});return r[o.name]={...o,fieldsMap:s},r},{})),y=e.computed(()=>r=>a.value?[]:(n.value??[]).filter(o=>o.fields.some(s=>s.name===r)).map(o=>o.name)),g=e.computed(()=>({datasource:r,filter:o})=>{if(a.value)return!0;const s=c.value[r];if(!s)return!0;const t=s.fieldsMap[o.field];return t?.filter?t.filter.operators.flatMap(l=>l.ops).includes(o.operator):!1}),m=e.computed(()=>({datasource:r,filters:o,queryFields:s=void 0,metrics:t=void 0})=>{const l=o.filter(i=>g.value({datasource:r,filter:i})),A=s??t;if(!A?.length)return l;const S=c.value[r];if(!S)return l;const q=A.map(i=>S.fieldsMap[i]).filter(i=>i!==void 0).filter(i=>i.supportedDimensions!==void 0).map(i=>new Set(i.supportedDimensions));if(!q.length)return l;const C=q.reduce((i,D)=>D.intersection(i));return l.filter(i=>C.has(i.field))});return{datasourceConfig:n,datasourceConfigError:d,datasourceConfigMap:c,getFieldDataSources:y,isFilterValidForDatasource:g,loading:a,isReady:p,stripUnknownFilters:m}}),v=e.defineComponent({__name:"AnalyticsConfigCheck",props:{requireAnalytics:{type:Boolean},requirePercentiles:{type:Boolean}},setup(n){const d=n,f=h(),{analytics:a,percentiles:p,configError:c,loading:y}=E.storeToRefs(f),g=e.computed(()=>(d.requireAnalytics?a.value:!0)&&(d.requirePercentiles?p.value:!0));return(m,r)=>!e.unref(y)&&e.unref(c)?e.renderSlot(m.$slots,"error",{error:e.unref(c)},void 0,void 0,0):!e.unref(y)&&g.value?e.renderSlot(m.$slots,"default",{hasAnalytics:e.unref(a),hasPercentiles:e.unref(p)},void 0,void 0,1):e.unref(y)?e.createCommentVNode("",!0):e.renderSlot(m.$slots,"fallback",{hasAnalytics:e.unref(a),hasPercentiles:e.unref(p)},void 0,void 0,2)}});u.AnalyticsConfigCheck=v,u.useAnalyticsConfigStore=h,u.useDatasourceConfigStore=_,Object.defineProperty(u,Symbol.toStringTag,{value:"Module"})}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kong-ui-public/analytics-config-store",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.27",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/vitals-config-store.umd.js",
|
|
6
6
|
"module": "./dist/vitals-config-store.es.js",
|
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
24
|
"pinia": ">= 3.0.4 < 5",
|
|
25
|
-
"vue": "^3.5.
|
|
26
|
-
"@kong-ui-public/analytics-utilities": "^12.31.
|
|
25
|
+
"vue": "^3.5.41",
|
|
26
|
+
"@kong-ui-public/analytics-utilities": "^12.31.1"
|
|
27
27
|
},
|
|
28
28
|
"repository": {
|
|
29
29
|
"type": "git",
|