@kong-ui-public/analytics-config-store 1.4.65 → 1.4.66-pr.3942.b9fcfd083.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.
|
@@ -8,6 +8,7 @@ export declare const useDatasourceConfigStore: import("pinia").SetupStoreDefinit
|
|
|
8
8
|
showInUI: boolean;
|
|
9
9
|
fields: {
|
|
10
10
|
name: string;
|
|
11
|
+
label: string;
|
|
11
12
|
showInUI: boolean;
|
|
12
13
|
aggregation: boolean;
|
|
13
14
|
group: boolean;
|
|
@@ -53,6 +54,7 @@ export declare const useDatasourceConfigStore: import("pinia").SetupStoreDefinit
|
|
|
53
54
|
showInUI: boolean;
|
|
54
55
|
fields: {
|
|
55
56
|
name: string;
|
|
57
|
+
label: string;
|
|
56
58
|
showInUI: boolean;
|
|
57
59
|
aggregation: boolean;
|
|
58
60
|
group: boolean;
|
|
@@ -96,6 +98,7 @@ export declare const useDatasourceConfigStore: import("pinia").SetupStoreDefinit
|
|
|
96
98
|
}[] | undefined>;
|
|
97
99
|
datasourceConfigError: import("vue").Ref<Error | null, Error | null>;
|
|
98
100
|
datasourceConfigMap: import("vue").ComputedRef<Record<string, MappedDatasourceConfig>>;
|
|
101
|
+
fieldTranslationMap: import("vue").ComputedRef<Map<string, string>>;
|
|
99
102
|
getFieldDataSources: import("vue").ComputedRef<(fieldName: string) => string[]>;
|
|
100
103
|
isFilterValidForDatasource: import("vue").ComputedRef<({ datasource, filter, }: {
|
|
101
104
|
datasource: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"datasource-config.d.ts","sourceRoot":"","sources":["../../../src/stores/datasource-config.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAmB,gBAAgB,EAAE,KAAK,EAAE,MAAM,qCAAqC,CAAA;AAI/G,MAAM,MAAM,sBAAsB,GAAG,gBAAgB,GAAG;IACtD,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAA;CACjC,CAAA;AAED,eAAO,MAAM,wBAAwB
|
|
1
|
+
{"version":3,"file":"datasource-config.d.ts","sourceRoot":"","sources":["../../../src/stores/datasource-config.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAmB,gBAAgB,EAAE,KAAK,EAAE,MAAM,qCAAqC,CAAA;AAI/G,MAAM,MAAM,sBAAsB,GAAG,gBAAgB,GAAG;IACtD,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAA;CACjC,CAAA;AAED,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;+DA6Ed,MAAM,KAAG,MAAM,EAAE;oFAejC;QACD,UAAU,EAAE,MAAM,CAAA;QAClB,MAAM,EAAE,UAAU,CAAA;KACnB,KAAG,OAAO;;mBArEa,OAAO,CAAC,IAAI,CAAC;oGAmGlC;QACD,UAAU,EAAE,MAAM,CAAA;QAClB,OAAO,EAAE,UAAU,EAAE,CAAA;QACrB,WAAW,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;QAC/B,2CAA2C;QAC3C,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;KAC5B,KAAG,UAAU,EAAE;EAgDlB,CAAA"}
|
|
@@ -1,126 +1,135 @@
|
|
|
1
|
-
import { ref as
|
|
2
|
-
import { defineStore as
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
p ? p.configFn().then((
|
|
6
|
-
|
|
7
|
-
}).catch((
|
|
8
|
-
|
|
1
|
+
import { ref as h, inject as R, computed as o, watch as b, defineComponent as S, unref as d, renderSlot as E, createCommentVNode as T } from "vue";
|
|
2
|
+
import { defineStore as w, storeToRefs as P } from "pinia";
|
|
3
|
+
const F = 2592e6, I = 2, M = 2e3, U = 10, k = "analytics-query-provider", L = w("analytics-config", () => {
|
|
4
|
+
const n = h(null), l = h(null), p = R(k);
|
|
5
|
+
p ? p.configFn().then((e) => {
|
|
6
|
+
n.value = e;
|
|
7
|
+
}).catch((e) => {
|
|
8
|
+
l.value = e, n.value = {
|
|
9
9
|
analytics: null,
|
|
10
10
|
requests: null
|
|
11
|
-
}, console.warn("Error fetching analytics config"), console.warn(
|
|
12
|
-
}) : (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"),
|
|
11
|
+
}, console.warn("Error fetching analytics config"), console.warn(e);
|
|
12
|
+
}) : (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"), l.value = new Error("No analytics bridge provided"), n.value = {
|
|
13
13
|
analytics: null,
|
|
14
14
|
requests: null
|
|
15
15
|
});
|
|
16
16
|
const a = o(() => {
|
|
17
|
-
const
|
|
18
|
-
return !!
|
|
19
|
-
}),
|
|
20
|
-
if (!
|
|
21
|
-
return
|
|
22
|
-
const c =
|
|
23
|
-
|
|
17
|
+
const e = n.value?.analytics?.retention_ms;
|
|
18
|
+
return !!e && e >= F;
|
|
19
|
+
}), v = o(() => "7d"), i = o(() => !n.value), y = o(() => !!n.value?.analytics), g = o(() => !!n.value?.analytics?.percentiles), f = () => new Promise((e) => {
|
|
20
|
+
if (!i.value)
|
|
21
|
+
return e();
|
|
22
|
+
const c = b(i, () => {
|
|
23
|
+
i.value || (c(), e());
|
|
24
24
|
});
|
|
25
|
-
}),
|
|
26
|
-
() =>
|
|
25
|
+
}), m = o(
|
|
26
|
+
() => n.value?.ui?.maxParallelRequests ?? I
|
|
27
|
+
), r = o(
|
|
28
|
+
() => n.value?.ui?.requestInterval ?? M
|
|
27
29
|
), t = o(
|
|
28
|
-
() =>
|
|
29
|
-
), i = o(
|
|
30
|
-
() => e.value?.ui?.requestIntervalCap ?? M
|
|
30
|
+
() => n.value?.ui?.requestIntervalCap ?? U
|
|
31
31
|
);
|
|
32
32
|
return {
|
|
33
|
-
analyticsConfig:
|
|
33
|
+
analyticsConfig: n,
|
|
34
34
|
longRetention: a,
|
|
35
|
-
defaultQueryTimeForOrg:
|
|
36
|
-
loading:
|
|
37
|
-
analytics:
|
|
35
|
+
defaultQueryTimeForOrg: v,
|
|
36
|
+
loading: i,
|
|
37
|
+
analytics: y,
|
|
38
38
|
percentiles: g,
|
|
39
|
-
maxParallelRequests:
|
|
40
|
-
requestInterval:
|
|
41
|
-
requestIntervalCap:
|
|
42
|
-
isReady:
|
|
43
|
-
configError:
|
|
39
|
+
maxParallelRequests: m,
|
|
40
|
+
requestInterval: r,
|
|
41
|
+
requestIntervalCap: t,
|
|
42
|
+
isReady: f,
|
|
43
|
+
configError: l
|
|
44
44
|
};
|
|
45
|
-
}),
|
|
46
|
-
const
|
|
47
|
-
p ? p.datasourceConfigFn().then((
|
|
48
|
-
|
|
49
|
-
}).catch((
|
|
50
|
-
|
|
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"),
|
|
52
|
-
const a = o(() =>
|
|
45
|
+
}), N = "analytics-query-provider", $ = w("datasource-config", () => {
|
|
46
|
+
const n = h(void 0), l = h(null), p = R(N);
|
|
47
|
+
p ? p.datasourceConfigFn().then((r) => {
|
|
48
|
+
n.value = r;
|
|
49
|
+
}).catch((r) => {
|
|
50
|
+
l.value = r, n.value = [], console.warn("Error fetching datasource config"), console.warn(r);
|
|
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"), l.value = new Error("No analytics bridge provided"), n.value = []);
|
|
52
|
+
const a = o(() => n.value === void 0), v = async () => new Promise((r) => {
|
|
53
53
|
if (!a.value)
|
|
54
|
-
return
|
|
55
|
-
const t =
|
|
56
|
-
|
|
54
|
+
return r();
|
|
55
|
+
const t = b(() => a.value, (e) => {
|
|
56
|
+
e || (t(), r());
|
|
57
57
|
});
|
|
58
|
-
}),
|
|
59
|
-
const
|
|
60
|
-
return
|
|
58
|
+
}), i = o(() => (n.value ?? []).reduce((r, t) => {
|
|
59
|
+
const e = t.fields.reduce((c, u) => (c[u.name] = u, c), {});
|
|
60
|
+
return r[t.name] = {
|
|
61
61
|
...t,
|
|
62
|
-
fieldsMap:
|
|
63
|
-
},
|
|
64
|
-
}, {})),
|
|
65
|
-
|
|
62
|
+
fieldsMap: e
|
|
63
|
+
}, r;
|
|
64
|
+
}, {})), y = o(() => {
|
|
65
|
+
const r = /* @__PURE__ */ new Map();
|
|
66
|
+
if (!n.value)
|
|
67
|
+
return r;
|
|
68
|
+
for (const t of n.value)
|
|
69
|
+
for (const e of t.fields)
|
|
70
|
+
r.set(e.name, e.label);
|
|
71
|
+
return r;
|
|
72
|
+
}), g = o(() => (r) => a.value ? [] : (n.value ?? []).filter((t) => t.fields.some((e) => e.name === r)).map((t) => t.name)), f = o(() => ({
|
|
73
|
+
datasource: r,
|
|
66
74
|
filter: t
|
|
67
75
|
}) => {
|
|
68
76
|
if (a.value)
|
|
69
77
|
return !0;
|
|
70
|
-
const
|
|
71
|
-
if (!
|
|
78
|
+
const e = i.value[r];
|
|
79
|
+
if (!e)
|
|
72
80
|
return !0;
|
|
73
|
-
const
|
|
74
|
-
return
|
|
75
|
-
}),
|
|
76
|
-
datasource:
|
|
81
|
+
const c = e.fieldsMap[t.field];
|
|
82
|
+
return c?.filter ? c.filter.operators.flatMap((u) => u.ops).includes(t.operator) : !1;
|
|
83
|
+
}), m = o(() => ({
|
|
84
|
+
datasource: r,
|
|
77
85
|
filters: t,
|
|
78
|
-
queryFields:
|
|
79
|
-
metrics:
|
|
86
|
+
queryFields: e = void 0,
|
|
87
|
+
metrics: c = void 0
|
|
80
88
|
}) => {
|
|
81
|
-
const
|
|
82
|
-
if (!
|
|
83
|
-
return
|
|
84
|
-
const
|
|
85
|
-
if (!
|
|
86
|
-
return
|
|
87
|
-
const
|
|
88
|
-
if (!
|
|
89
|
-
return
|
|
90
|
-
const
|
|
91
|
-
return
|
|
89
|
+
const u = t.filter((s) => f.value({ datasource: r, filter: s })), q = e ?? c;
|
|
90
|
+
if (!q?.length)
|
|
91
|
+
return u;
|
|
92
|
+
const A = i.value[r];
|
|
93
|
+
if (!A)
|
|
94
|
+
return u;
|
|
95
|
+
const C = q.map((s) => A.fieldsMap[s]).filter((s) => s !== void 0).filter((s) => s.supportedDimensions !== void 0).map((s) => new Set(s.supportedDimensions));
|
|
96
|
+
if (!C.length)
|
|
97
|
+
return u;
|
|
98
|
+
const _ = C.reduce((s, D) => D.intersection(s));
|
|
99
|
+
return u.filter((s) => _.has(s.field));
|
|
92
100
|
});
|
|
93
101
|
return {
|
|
94
|
-
datasourceConfig:
|
|
95
|
-
datasourceConfigError:
|
|
96
|
-
datasourceConfigMap:
|
|
97
|
-
|
|
98
|
-
|
|
102
|
+
datasourceConfig: n,
|
|
103
|
+
datasourceConfigError: l,
|
|
104
|
+
datasourceConfigMap: i,
|
|
105
|
+
fieldTranslationMap: y,
|
|
106
|
+
getFieldDataSources: g,
|
|
107
|
+
isFilterValidForDatasource: f,
|
|
99
108
|
loading: a,
|
|
100
|
-
isReady:
|
|
101
|
-
stripUnknownFilters:
|
|
109
|
+
isReady: v,
|
|
110
|
+
stripUnknownFilters: m
|
|
102
111
|
};
|
|
103
|
-
}),
|
|
112
|
+
}), j = /* @__PURE__ */ S({
|
|
104
113
|
__name: "AnalyticsConfigCheck",
|
|
105
114
|
props: {
|
|
106
115
|
requireAnalytics: { type: Boolean },
|
|
107
116
|
requirePercentiles: { type: Boolean }
|
|
108
117
|
},
|
|
109
|
-
setup(
|
|
110
|
-
const
|
|
111
|
-
() => (
|
|
118
|
+
setup(n) {
|
|
119
|
+
const l = n, p = L(), { analytics: a, percentiles: v, configError: i, loading: y } = P(p), g = o(
|
|
120
|
+
() => (l.requireAnalytics ? a.value : !0) && (l.requirePercentiles ? v.value : !0)
|
|
112
121
|
);
|
|
113
|
-
return (
|
|
122
|
+
return (f, m) => !d(y) && d(i) ? E(f.$slots, "error", { error: d(i) }, void 0, void 0, 0) : !d(y) && g.value ? E(f.$slots, "default", {
|
|
114
123
|
hasAnalytics: d(a),
|
|
115
|
-
hasPercentiles: d(
|
|
116
|
-
}, void 0, void 0, 1) : d(
|
|
124
|
+
hasPercentiles: d(v)
|
|
125
|
+
}, void 0, void 0, 1) : d(y) ? T("", !0) : E(f.$slots, "fallback", {
|
|
117
126
|
hasAnalytics: d(a),
|
|
118
|
-
hasPercentiles: d(
|
|
127
|
+
hasPercentiles: d(v)
|
|
119
128
|
}, void 0, void 0, 2);
|
|
120
129
|
}
|
|
121
130
|
});
|
|
122
131
|
export {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
132
|
+
j as AnalyticsConfigCheck,
|
|
133
|
+
L as useAnalyticsConfigStore,
|
|
134
|
+
$ as useDatasourceConfigStore
|
|
126
135
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(c,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue"),require("pinia")):typeof define=="function"&&define.amd?define(["exports","vue","pinia"],e):(c=typeof globalThis<"u"?globalThis:c||self,e(c["kong-ui-public-vitals-config-store"]={},c.Vue,c.pinia))})(this,(function(c,e,h){"use strict";const v="analytics-query-provider",A=h.defineStore("analytics-config",()=>{const r=e.ref(null),l=e.ref(null),p=e.inject(v);p?p.configFn().then(n=>{r.value=n}).catch(n=>{l.value=n,r.value={analytics:null,requests:null},console.warn("Error fetching analytics config"),console.warn(n)}):(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"),l.value=new Error("No analytics bridge provided"),r.value={analytics:null,requests:null});const s=e.computed(()=>{const n=r.value?.analytics?.retention_ms;return!!n&&n>=2592e6}),m=e.computed(()=>"7d"),a=e.computed(()=>!r.value),y=e.computed(()=>!!r.value?.analytics),g=e.computed(()=>!!r.value?.analytics?.percentiles),f=()=>new Promise(n=>{if(!a.value)return n();const u=e.watch(a,()=>{a.value||(u(),n())})}),E=e.computed(()=>r.value?.ui?.maxParallelRequests??2),t=e.computed(()=>r.value?.ui?.requestInterval??2e3),o=e.computed(()=>r.value?.ui?.requestIntervalCap??10);return{analyticsConfig:r,longRetention:s,defaultQueryTimeForOrg:m,loading:a,analytics:y,percentiles:g,maxParallelRequests:E,requestInterval:t,requestIntervalCap:o,isReady:f,configError:l}}),R="analytics-query-provider",_=h.defineStore("datasource-config",()=>{const r=e.ref(void 0),l=e.ref(null),p=e.inject(R);p?p.datasourceConfigFn().then(t=>{r.value=t}).catch(t=>{l.value=t,r.value=[],console.warn("Error fetching datasource 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"),l.value=new Error("No analytics bridge provided"),r.value=[]);const s=e.computed(()=>r.value===void 0),m=async()=>new Promise(t=>{if(!s.value)return t();const o=e.watch(()=>s.value,n=>{n||(o(),t())})}),a=e.computed(()=>(r.value??[]).reduce((t,o)=>{const n=o.fields.reduce((u,d)=>(u[d.name]=d,u),{});return t[o.name]={...o,fieldsMap:n},t},{})),y=e.computed(()=>{const t=new Map;if(!r.value)return t;for(const o of r.value)for(const n of o.fields)t.set(n.name,n.label);return t}),g=e.computed(()=>t=>s.value?[]:(r.value??[]).filter(o=>o.fields.some(n=>n.name===t)).map(o=>o.name)),f=e.computed(()=>({datasource:t,filter:o})=>{if(s.value)return!0;const n=a.value[t];if(!n)return!0;const u=n.fieldsMap[o.field];return u?.filter?u.filter.operators.flatMap(d=>d.ops).includes(o.operator):!1}),E=e.computed(()=>({datasource:t,filters:o,queryFields:n=void 0,metrics:u=void 0})=>{const d=o.filter(i=>f.value({datasource:t,filter:i})),S=n??u;if(!S?.length)return d;const T=a.value[t];if(!T)return d;const q=S.map(i=>T.fieldsMap[i]).filter(i=>i!==void 0).filter(i=>i.supportedDimensions!==void 0).map(i=>new Set(i.supportedDimensions));if(!q.length)return d;const b=q.reduce((i,D)=>D.intersection(i));return d.filter(i=>b.has(i.field))});return{datasourceConfig:r,datasourceConfigError:l,datasourceConfigMap:a,fieldTranslationMap:y,getFieldDataSources:g,isFilterValidForDatasource:f,loading:s,isReady:m,stripUnknownFilters:E}}),C=e.defineComponent({__name:"AnalyticsConfigCheck",props:{requireAnalytics:{type:Boolean},requirePercentiles:{type:Boolean}},setup(r){const l=r,p=A(),{analytics:s,percentiles:m,configError:a,loading:y}=h.storeToRefs(p),g=e.computed(()=>(l.requireAnalytics?s.value:!0)&&(l.requirePercentiles?m.value:!0));return(f,E)=>!e.unref(y)&&e.unref(a)?e.renderSlot(f.$slots,"error",{error:e.unref(a)},void 0,void 0,0):!e.unref(y)&&g.value?e.renderSlot(f.$slots,"default",{hasAnalytics:e.unref(s),hasPercentiles:e.unref(m)},void 0,void 0,1):e.unref(y)?e.createCommentVNode("",!0):e.renderSlot(f.$slots,"fallback",{hasAnalytics:e.unref(s),hasPercentiles:e.unref(m)},void 0,void 0,2)}});c.AnalyticsConfigCheck=C,c.useAnalyticsConfigStore=A,c.useDatasourceConfigStore=_,Object.defineProperty(c,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.66-pr.3942.b9fcfd083.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/vitals-config-store.umd.js",
|
|
6
6
|
"module": "./dist/vitals-config-store.es.js",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"access": "public"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
|
-
"@kong-ui-public/analytics-utilities": "^13.5.
|
|
24
|
+
"@kong-ui-public/analytics-utilities": "^13.5.2-pr.3942.b9fcfd083.0",
|
|
25
25
|
"pinia": "^4.0.3",
|
|
26
26
|
"vue": "^3.5.43"
|
|
27
27
|
},
|