@appscode/design-system 1.0.43-alpha.217 → 1.0.43-alpha.218
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/package.json +1 -1
- package/plugins/caching.ts +60 -7
package/package.json
CHANGED
package/plugins/caching.ts
CHANGED
|
@@ -18,7 +18,7 @@ function getRequestInterceptor(config: AxiosRequestConfig) {
|
|
|
18
18
|
|
|
19
19
|
const suffix = `${user}.${cluster}.${group}.${version}.${resource}${
|
|
20
20
|
namespace ? ".ns." + namespace : ""
|
|
21
|
-
}${params
|
|
21
|
+
}${params ? ".q." + md5(stringify(params)).toString() : ""}`;
|
|
22
22
|
|
|
23
23
|
if (_recurringCall) {
|
|
24
24
|
// always send latest date time as ctag
|
|
@@ -36,6 +36,13 @@ function getResponseInterceptor(resp: AxiosResponse) {
|
|
|
36
36
|
// get call
|
|
37
37
|
const { config, headers } = resp;
|
|
38
38
|
const { url, _recurringCall, params } = config;
|
|
39
|
+
|
|
40
|
+
// queryParams without ctag
|
|
41
|
+
const queryParamsWithoutCtag = Object.keys(params).reduce((ob, key) => {
|
|
42
|
+
if (key !== "ctag") return { ...ob, [key]: params[key] };
|
|
43
|
+
else return { ...ob };
|
|
44
|
+
}, {});
|
|
45
|
+
|
|
39
46
|
const matchListApi = url?.match(resourceListApiRgx);
|
|
40
47
|
if (matchListApi) {
|
|
41
48
|
// url matches list / render api call
|
|
@@ -45,7 +52,9 @@ function getResponseInterceptor(resp: AxiosResponse) {
|
|
|
45
52
|
|
|
46
53
|
const suffix = `${user}.${cluster}.${group}.${version}.${resource}${
|
|
47
54
|
namespace ? ".ns." + namespace : ""
|
|
48
|
-
}${
|
|
55
|
+
}${
|
|
56
|
+
params ? ".q." + md5(stringify(queryParamsWithoutCtag)).toString() : ""
|
|
57
|
+
}`;
|
|
49
58
|
|
|
50
59
|
const storageKey = `etag.${suffix}`;
|
|
51
60
|
// local storage etag
|
|
@@ -53,7 +62,7 @@ function getResponseInterceptor(resp: AxiosResponse) {
|
|
|
53
62
|
// etag in header
|
|
54
63
|
const headerEtag = headers?.["etag"];
|
|
55
64
|
|
|
56
|
-
// window.console.log({ eTag, headerEtag, _recurringCall, url })
|
|
65
|
+
// window.console.log({ eTag, headerEtag, _recurringCall, url });
|
|
57
66
|
|
|
58
67
|
if (_recurringCall) {
|
|
59
68
|
// for recurring api call
|
|
@@ -140,17 +149,61 @@ export function handleCacheFromYamls(
|
|
|
140
149
|
const groupKind = `${group || "core"}/${kind}`;
|
|
141
150
|
const gvr = (gkToGvrMap && gkToGvrMap[groupKind]) || "";
|
|
142
151
|
|
|
143
|
-
const
|
|
152
|
+
const storageKeyPrefix = `ctag.${user}.${cluster}.${gvr.replaceAll(
|
|
144
153
|
"/",
|
|
145
154
|
"."
|
|
146
155
|
)}`;
|
|
147
156
|
|
|
148
157
|
// clear list cache for all namespaces
|
|
149
|
-
localStorage.setItem(
|
|
150
|
-
|
|
158
|
+
localStorage.setItem(
|
|
159
|
+
`${storageKeyPrefix}.q.${md5(
|
|
160
|
+
stringify({ convertToTable: true })
|
|
161
|
+
).toString()}`,
|
|
162
|
+
new Date().getTime().toString()
|
|
163
|
+
);
|
|
151
164
|
// clear list cache for specific namespace
|
|
152
165
|
localStorage.setItem(
|
|
153
|
-
`${
|
|
166
|
+
`${storageKeyPrefix}.ns.${namespace || "default"}.q.${md5(
|
|
167
|
+
stringify({ convertToTable: true })
|
|
168
|
+
).toString()}`,
|
|
169
|
+
new Date().getTime().toString()
|
|
170
|
+
);
|
|
171
|
+
|
|
172
|
+
// clear for genericresources and resourcesummaries
|
|
173
|
+
localStorage.setItem(
|
|
174
|
+
`ctag.${user}.${cluster}.core.k8s.appscode.com.v1alpha1.resourcesummaries.q.${md5(
|
|
175
|
+
stringify({
|
|
176
|
+
convertToTable: true,
|
|
177
|
+
labelSelector: `k8s.io/group=${group}`,
|
|
178
|
+
})
|
|
179
|
+
).toString()}`,
|
|
180
|
+
new Date().getTime().toString()
|
|
181
|
+
);
|
|
182
|
+
localStorage.setItem(
|
|
183
|
+
`ctag.${user}.${cluster}.core.k8s.appscode.com.v1alpha1.resourcesummaries.q.${md5(
|
|
184
|
+
stringify({
|
|
185
|
+
convertToTable: true,
|
|
186
|
+
labelSelector: `k8s.io/group-kind=${kind}.${group}`,
|
|
187
|
+
})
|
|
188
|
+
).toString()}`,
|
|
189
|
+
new Date().getTime().toString()
|
|
190
|
+
);
|
|
191
|
+
localStorage.setItem(
|
|
192
|
+
`ctag.${user}.${cluster}.core.k8s.appscode.com.v1alpha1.genericresources.q.${md5(
|
|
193
|
+
stringify({
|
|
194
|
+
convertToTable: true,
|
|
195
|
+
labelSelector: `k8s.io/group=${group}`,
|
|
196
|
+
})
|
|
197
|
+
).toString()}`,
|
|
198
|
+
new Date().getTime().toString()
|
|
199
|
+
);
|
|
200
|
+
localStorage.setItem(
|
|
201
|
+
`ctag.${user}.${cluster}.core.k8s.appscode.com.v1alpha1.genericresources.q.${md5(
|
|
202
|
+
stringify({
|
|
203
|
+
convertToTable: true,
|
|
204
|
+
labelSelector: `k8s.io/group-kind=${kind}.${group}`,
|
|
205
|
+
})
|
|
206
|
+
).toString()}`,
|
|
154
207
|
new Date().getTime().toString()
|
|
155
208
|
);
|
|
156
209
|
}
|