strapi-cache 1.4.3 → 1.4.5
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/_chunks/de-CBzKPGsY.mjs +14 -0
- package/dist/_chunks/de-CjN-9Obj.js +14 -0
- package/dist/_chunks/{en-D3udXrSa.mjs → en-BDlRjAzq.mjs} +2 -3
- package/dist/_chunks/{en-CcRrGOBv.js → en-D24wwyGh.js} +2 -3
- package/dist/admin/index.js +69 -134
- package/dist/admin/index.mjs +71 -136
- package/dist/admin/src/components/PurgeCacheButton/index.d.ts +1 -1
- package/dist/admin/src/components/PurgeEntityButton/index.d.ts +1 -1
- package/dist/admin/src/components/PurgeModal/PurgeButton/index.d.ts +4 -0
- package/dist/admin/src/components/PurgeModal/index.d.ts +7 -0
- package/dist/server/index.js +0 -1
- package/dist/server/index.mjs +0 -1
- package/package.json +4 -4
- package/dist/_chunks/en-B9bQFCLY.mjs +0 -18
- package/dist/_chunks/en-B9bQFCLY.mjs.map +0 -1
- package/dist/_chunks/en-BPx_Feq_.mjs +0 -17
- package/dist/_chunks/en-BPx_Feq_.mjs.map +0 -1
- package/dist/_chunks/en-BdzOe-Jv.mjs +0 -16
- package/dist/_chunks/en-BdzOe-Jv.mjs.map +0 -1
- package/dist/_chunks/en-Bev8UGB9.js +0 -14
- package/dist/_chunks/en-Bev8UGB9.js.map +0 -1
- package/dist/_chunks/en-BgoZyxl0.mjs +0 -10
- package/dist/_chunks/en-BgoZyxl0.mjs.map +0 -1
- package/dist/_chunks/en-BkqNXvi0.mjs +0 -18
- package/dist/_chunks/en-BkqNXvi0.mjs.map +0 -1
- package/dist/_chunks/en-C0JeH0S_.js +0 -17
- package/dist/_chunks/en-C0JeH0S_.js.map +0 -1
- package/dist/_chunks/en-C0qeO9FB.mjs +0 -15
- package/dist/_chunks/en-C0qeO9FB.mjs.map +0 -1
- package/dist/_chunks/en-CBPjpI-y.js +0 -18
- package/dist/_chunks/en-CBPjpI-y.js.map +0 -1
- package/dist/_chunks/en-CIN0kRXJ.js +0 -10
- package/dist/_chunks/en-CIN0kRXJ.js.map +0 -1
- package/dist/_chunks/en-CVjURV1W.js +0 -11
- package/dist/_chunks/en-CVjURV1W.js.map +0 -1
- package/dist/_chunks/en-CWf_jLFj.js +0 -18
- package/dist/_chunks/en-CWf_jLFj.js.map +0 -1
- package/dist/_chunks/en-C_x7qEgd.mjs +0 -11
- package/dist/_chunks/en-C_x7qEgd.mjs.map +0 -1
- package/dist/_chunks/en-CcRrGOBv.js.map +0 -1
- package/dist/_chunks/en-Cq54r800.mjs +0 -18
- package/dist/_chunks/en-Cq54r800.mjs.map +0 -1
- package/dist/_chunks/en-D3udXrSa.mjs.map +0 -1
- package/dist/_chunks/en-DZzRFINn.js +0 -16
- package/dist/_chunks/en-DZzRFINn.js.map +0 -1
- package/dist/_chunks/en-D_Fd-4QS.js +0 -15
- package/dist/_chunks/en-D_Fd-4QS.js.map +0 -1
- package/dist/_chunks/en-DdVULHeC.mjs +0 -14
- package/dist/_chunks/en-DdVULHeC.mjs.map +0 -1
- package/dist/_chunks/en-DehLWejq.mjs +0 -18
- package/dist/_chunks/en-DehLWejq.mjs.map +0 -1
- package/dist/_chunks/en-Do3Kh30d.js +0 -18
- package/dist/_chunks/en-Do3Kh30d.js.map +0 -1
- package/dist/_chunks/en-N9VY0B4k.mjs +0 -18
- package/dist/_chunks/en-N9VY0B4k.mjs.map +0 -1
- package/dist/_chunks/en-O03hkb40.js +0 -18
- package/dist/_chunks/en-O03hkb40.js.map +0 -1
- package/dist/_chunks/en-TyY2Xkua.js +0 -18
- package/dist/_chunks/en-TyY2Xkua.js.map +0 -1
- package/dist/_chunks/en-eba6oPnU.mjs +0 -18
- package/dist/_chunks/en-eba6oPnU.mjs.map +0 -1
- package/dist/_chunks/en-wt3vH-k4.js +0 -18
- package/dist/_chunks/en-wt3vH-k4.js.map +0 -1
- package/dist/admin/index.js.map +0 -1
- package/dist/admin/index.mjs.map +0 -1
- package/dist/server/index.js.map +0 -1
- package/dist/server/index.mjs.map +0 -1
- package/dist/server/src/destroy.d.ts +0 -5
- package/dist/server/src/routes/content-api.d.ts +0 -9
- package/dist/server/src/services/service.d.ts +0 -6
- package/dist/server/src/utils/etag.d.ts +0 -3
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const de = {
|
|
2
|
+
"strapi-cache.name": "Strapi-Cache",
|
|
3
|
+
"strapi-cache.cache.purge": "Cache leeren",
|
|
4
|
+
"strapi-cache.cache.purge.entity": "Entity-Cache leeren",
|
|
5
|
+
"strapi-cache.cache.cancel": "Nein, abbrechen",
|
|
6
|
+
"strapi-cache.cache.confirm": "Ja, leeren",
|
|
7
|
+
"strapi-cache.cache.purge.confirmation": "Dies löscht alle Schlüssel, bei denen {key} Teil des Schlüssels ist. Sind Sie sicher, dass Sie den Cache leeren möchten?",
|
|
8
|
+
"strapi-cache.cache.purge.success": "Cache erfolgreich für {key} geleert",
|
|
9
|
+
"strapi-cache.cache.purge.error": "Fehler beim Leeren des Caches für {key}",
|
|
10
|
+
"strapi-cache.cache.purge.no-content-type": "Kein Inhaltstyp gefunden"
|
|
11
|
+
};
|
|
12
|
+
export {
|
|
13
|
+
de as default
|
|
14
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const de = {
|
|
4
|
+
"strapi-cache.name": "Strapi-Cache",
|
|
5
|
+
"strapi-cache.cache.purge": "Cache leeren",
|
|
6
|
+
"strapi-cache.cache.purge.entity": "Entity-Cache leeren",
|
|
7
|
+
"strapi-cache.cache.cancel": "Nein, abbrechen",
|
|
8
|
+
"strapi-cache.cache.confirm": "Ja, leeren",
|
|
9
|
+
"strapi-cache.cache.purge.confirmation": "Dies löscht alle Schlüssel, bei denen {key} Teil des Schlüssels ist. Sind Sie sicher, dass Sie den Cache leeren möchten?",
|
|
10
|
+
"strapi-cache.cache.purge.success": "Cache erfolgreich für {key} geleert",
|
|
11
|
+
"strapi-cache.cache.purge.error": "Fehler beim Leeren des Caches für {key}",
|
|
12
|
+
"strapi-cache.cache.purge.no-content-type": "Kein Inhaltstyp gefunden"
|
|
13
|
+
};
|
|
14
|
+
exports.default = de;
|
|
@@ -5,11 +5,10 @@ const en = {
|
|
|
5
5
|
"strapi-cache.cache.cancel": "No, cancel",
|
|
6
6
|
"strapi-cache.cache.confirm": "Yes, purge",
|
|
7
7
|
"strapi-cache.cache.purge.confirmation": "This purges all keys where {key} is part of the key. Are you sure you want to purge the cache?",
|
|
8
|
-
"strapi-cache.cache.purge.success": "Cache purged successfully",
|
|
9
|
-
"strapi-cache.cache.purge.error": "Error purging cache",
|
|
8
|
+
"strapi-cache.cache.purge.success": "Cache purged successfully for {key}",
|
|
9
|
+
"strapi-cache.cache.purge.error": "Error purging cache for {key}",
|
|
10
10
|
"strapi-cache.cache.purge.no-content-type": "No content type found"
|
|
11
11
|
};
|
|
12
12
|
export {
|
|
13
13
|
en as default
|
|
14
14
|
};
|
|
15
|
-
//# sourceMappingURL=en-D3udXrSa.mjs.map
|
|
@@ -7,9 +7,8 @@ const en = {
|
|
|
7
7
|
"strapi-cache.cache.cancel": "No, cancel",
|
|
8
8
|
"strapi-cache.cache.confirm": "Yes, purge",
|
|
9
9
|
"strapi-cache.cache.purge.confirmation": "This purges all keys where {key} is part of the key. Are you sure you want to purge the cache?",
|
|
10
|
-
"strapi-cache.cache.purge.success": "Cache purged successfully",
|
|
11
|
-
"strapi-cache.cache.purge.error": "Error purging cache",
|
|
10
|
+
"strapi-cache.cache.purge.success": "Cache purged successfully for {key}",
|
|
11
|
+
"strapi-cache.cache.purge.error": "Error purging cache for {key}",
|
|
12
12
|
"strapi-cache.cache.purge.no-content-type": "No content type found"
|
|
13
13
|
};
|
|
14
14
|
exports.default = en;
|
|
15
|
-
//# sourceMappingURL=en-CcRrGOBv.js.map
|
package/dist/admin/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
const react = require("react");
|
|
3
3
|
const jsxRuntime = require("react/jsx-runtime");
|
|
4
|
+
const admin = require("@strapi/strapi/admin");
|
|
4
5
|
const reactIntl = require("react-intl");
|
|
5
6
|
const icons = require("@strapi/icons");
|
|
6
7
|
const designSystem = require("@strapi/design-system");
|
|
7
|
-
const admin = require("@strapi/strapi/admin");
|
|
8
8
|
const __variableDynamicImportRuntimeHelper = (glob, path, segs) => {
|
|
9
9
|
const v = glob[path];
|
|
10
10
|
if (v) {
|
|
@@ -32,14 +32,19 @@ const Initializer = ({ setPlugin }) => {
|
|
|
32
32
|
const pluginPermissions = {
|
|
33
33
|
purge: [{ action: "plugin::strapi-cache.purge-cache", subject: null }]
|
|
34
34
|
};
|
|
35
|
-
function
|
|
35
|
+
function PurgeButton({ onClick }) {
|
|
36
|
+
const formatMessage = reactIntl.useIntl().formatMessage;
|
|
37
|
+
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { onClick, children: formatMessage({
|
|
38
|
+
id: "strapi-cache.cache.confirm",
|
|
39
|
+
defaultMessage: "Yes, confirm"
|
|
40
|
+
}) });
|
|
41
|
+
}
|
|
42
|
+
function PurgeModal({ buttonText, keyToUse, buttonWidth }) {
|
|
36
43
|
const { allowedActions } = admin.useRBAC(pluginPermissions);
|
|
37
44
|
const formatMessage = reactIntl.useIntl().formatMessage;
|
|
38
45
|
const { post, get } = admin.useFetchClient();
|
|
39
46
|
const { toggleNotification } = admin.useNotification();
|
|
40
|
-
const { contentType } = admin.unstable_useContentManagerContext();
|
|
41
47
|
const [cacheableRoutes, setCacheableRoutes] = react.useState();
|
|
42
|
-
const pluralName = contentType?.info.pluralName;
|
|
43
48
|
react.useEffect(() => {
|
|
44
49
|
if (!allowedActions.canPurgeCache) {
|
|
45
50
|
return;
|
|
@@ -57,109 +62,16 @@ function PurgeCacheButton() {
|
|
|
57
62
|
setCacheableRoutes(data);
|
|
58
63
|
});
|
|
59
64
|
}, [allowedActions.canPurgeCache]);
|
|
60
|
-
const clearCache = () => {
|
|
61
|
-
if (!pluralName) {
|
|
62
|
-
toggleNotification({
|
|
63
|
-
type: "warning",
|
|
64
|
-
message: formatMessage({
|
|
65
|
-
id: "strapi-cache.cache.purge.no-content-type",
|
|
66
|
-
defaultMessage: "No content type found"
|
|
67
|
-
})
|
|
68
|
-
});
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
post(`/strapi-cache/purge-cache/${pluralName}`, void 0, {
|
|
72
|
-
headers: {
|
|
73
|
-
"Content-Type": "application/json"
|
|
74
|
-
}
|
|
75
|
-
}).then(() => {
|
|
76
|
-
toggleNotification({
|
|
77
|
-
type: "success",
|
|
78
|
-
message: formatMessage({
|
|
79
|
-
id: "strapi-cache.cache.purge.success",
|
|
80
|
-
defaultMessage: "Cache purged successfully"
|
|
81
|
-
}) + `: ${pluralName}`
|
|
82
|
-
});
|
|
83
|
-
}).catch(() => {
|
|
84
|
-
toggleNotification({
|
|
85
|
-
type: "danger",
|
|
86
|
-
message: formatMessage({
|
|
87
|
-
id: "strapi-cache.cache.purge.error",
|
|
88
|
-
defaultMessage: "Error purging cache"
|
|
89
|
-
}) + `: ${pluralName}`
|
|
90
|
-
});
|
|
91
|
-
});
|
|
92
|
-
};
|
|
93
65
|
const isCacheableRoute = () => {
|
|
94
|
-
if (!
|
|
66
|
+
if (!keyToUse || !cacheableRoutes) {
|
|
95
67
|
return false;
|
|
96
68
|
}
|
|
97
69
|
return cacheableRoutes.length === 0 || cacheableRoutes.some((route) => {
|
|
98
|
-
return route.includes(
|
|
70
|
+
return route.includes(keyToUse);
|
|
99
71
|
});
|
|
100
72
|
};
|
|
101
|
-
if (!allowedActions.canPurgeCache || !isCacheableRoute()) {
|
|
102
|
-
return null;
|
|
103
|
-
}
|
|
104
|
-
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Modal.Root, { children: [
|
|
105
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Trigger, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { startIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.Archive, {}), variant: "danger", children: formatMessage({
|
|
106
|
-
id: "strapi-cache.cache.purge",
|
|
107
|
-
defaultMessage: "Purge Cache"
|
|
108
|
-
}) }) }),
|
|
109
|
-
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Modal.Content, { children: [
|
|
110
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Title, { children: formatMessage({
|
|
111
|
-
id: "strapi-cache.cache.purge",
|
|
112
|
-
defaultMessage: "Purge Cache"
|
|
113
|
-
}) }) }),
|
|
114
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Body, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", children: formatMessage(
|
|
115
|
-
{
|
|
116
|
-
id: "strapi-cache.cache.purge.confirmation",
|
|
117
|
-
defaultMessage: "Are you sure you want to purge the cache?"
|
|
118
|
-
},
|
|
119
|
-
{
|
|
120
|
-
key: `"${pluralName}"`
|
|
121
|
-
}
|
|
122
|
-
) }) }),
|
|
123
|
-
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Modal.Footer, { children: [
|
|
124
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Close, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { variant: "tertiary", children: formatMessage({
|
|
125
|
-
id: "strapi-cache.cache.cancel",
|
|
126
|
-
defaultMessage: "No, cancel"
|
|
127
|
-
}) }) }),
|
|
128
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Close, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { onClick: clearCache, children: formatMessage({
|
|
129
|
-
id: "strapi-cache.cache.confirm",
|
|
130
|
-
defaultMessage: "Yes, confirm"
|
|
131
|
-
}) }) })
|
|
132
|
-
] })
|
|
133
|
-
] })
|
|
134
|
-
] }) });
|
|
135
|
-
}
|
|
136
|
-
function PurgeEntityButton() {
|
|
137
|
-
const { allowedActions } = admin.useRBAC(pluginPermissions);
|
|
138
|
-
const formatMessage = reactIntl.useIntl().formatMessage;
|
|
139
|
-
const { post, get } = admin.useFetchClient();
|
|
140
|
-
const { toggleNotification } = admin.useNotification();
|
|
141
|
-
const { contentType, id } = admin.unstable_useContentManagerContext();
|
|
142
|
-
const [cacheableRoutes, setCacheableRoutes] = react.useState();
|
|
143
|
-
const pluralName = contentType?.info.pluralName;
|
|
144
|
-
react.useEffect(() => {
|
|
145
|
-
if (!allowedActions.canPurgeCache) {
|
|
146
|
-
return;
|
|
147
|
-
}
|
|
148
|
-
const fetchCacheableRoutes = async () => {
|
|
149
|
-
try {
|
|
150
|
-
const { data } = await get("/strapi-cache/cacheable-routes");
|
|
151
|
-
return data;
|
|
152
|
-
} catch (error) {
|
|
153
|
-
console.error("Error fetching cacheable routes:", error);
|
|
154
|
-
return void 0;
|
|
155
|
-
}
|
|
156
|
-
};
|
|
157
|
-
fetchCacheableRoutes().then((data) => {
|
|
158
|
-
setCacheableRoutes(data);
|
|
159
|
-
});
|
|
160
|
-
}, [allowedActions.canPurgeCache]);
|
|
161
73
|
const clearCache = () => {
|
|
162
|
-
if (!
|
|
74
|
+
if (!keyToUse) {
|
|
163
75
|
toggleNotification({
|
|
164
76
|
type: "warning",
|
|
165
77
|
message: formatMessage({
|
|
@@ -169,68 +81,92 @@ function PurgeEntityButton() {
|
|
|
169
81
|
});
|
|
170
82
|
return;
|
|
171
83
|
}
|
|
172
|
-
post(`/strapi-cache/purge-cache/${
|
|
84
|
+
post(`/strapi-cache/purge-cache/${keyToUse}`, void 0, {
|
|
173
85
|
headers: {
|
|
174
86
|
"Content-Type": "application/json"
|
|
175
87
|
}
|
|
176
88
|
}).then(() => {
|
|
177
89
|
toggleNotification({
|
|
178
90
|
type: "success",
|
|
179
|
-
message: formatMessage(
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
91
|
+
message: formatMessage(
|
|
92
|
+
{
|
|
93
|
+
id: "strapi-cache.cache.purge.success",
|
|
94
|
+
defaultMessage: "Cache purged successfully"
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
key: `"${keyToUse}"`
|
|
98
|
+
}
|
|
99
|
+
)
|
|
183
100
|
});
|
|
184
101
|
}).catch(() => {
|
|
185
102
|
toggleNotification({
|
|
186
103
|
type: "danger",
|
|
187
|
-
message: formatMessage(
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
104
|
+
message: formatMessage(
|
|
105
|
+
{
|
|
106
|
+
id: "strapi-cache.cache.purge.error",
|
|
107
|
+
defaultMessage: "Error purging cache"
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
key: `"${keyToUse}"`
|
|
111
|
+
}
|
|
112
|
+
)
|
|
191
113
|
});
|
|
192
114
|
});
|
|
193
115
|
};
|
|
194
|
-
const isCacheableRoute = () => {
|
|
195
|
-
if (!pluralName || !cacheableRoutes) {
|
|
196
|
-
return false;
|
|
197
|
-
}
|
|
198
|
-
return cacheableRoutes.length === 0 || cacheableRoutes.some((route) => {
|
|
199
|
-
return route.includes(pluralName);
|
|
200
|
-
});
|
|
201
|
-
};
|
|
202
116
|
if (!allowedActions.canPurgeCache || !isCacheableRoute()) {
|
|
203
117
|
return null;
|
|
204
118
|
}
|
|
205
|
-
return /* @__PURE__ */ jsxRuntime.
|
|
206
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Trigger, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { width:
|
|
207
|
-
id: "strapi-cache.cache.purge.entity",
|
|
208
|
-
defaultMessage: "Purge Entity Cache"
|
|
209
|
-
}) }) }),
|
|
119
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Modal.Root, { children: [
|
|
120
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Trigger, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { width: buttonWidth, startIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.Archive, {}), variant: "danger", children: buttonText }) }),
|
|
210
121
|
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Modal.Content, { children: [
|
|
211
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Title, { children:
|
|
212
|
-
id: "strapi-cache.cache.purge.entity",
|
|
213
|
-
defaultMessage: "Purge Entity Cache"
|
|
214
|
-
}) }) }),
|
|
122
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Title, { children: buttonText }) }),
|
|
215
123
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Body, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", children: formatMessage(
|
|
216
124
|
{
|
|
217
125
|
id: "strapi-cache.cache.purge.confirmation",
|
|
218
126
|
defaultMessage: "Are you sure you want to purge the cache?"
|
|
219
127
|
},
|
|
220
|
-
{ key: `"${
|
|
128
|
+
{ key: `"${keyToUse}"` }
|
|
221
129
|
) }) }),
|
|
222
130
|
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Modal.Footer, { children: [
|
|
223
131
|
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Close, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { variant: "tertiary", children: formatMessage({
|
|
224
132
|
id: "strapi-cache.cache.cancel",
|
|
225
133
|
defaultMessage: "No, cancel"
|
|
226
134
|
}) }) }),
|
|
227
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Close, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
228
|
-
id: "strapi-cache.cache.confirm",
|
|
229
|
-
defaultMessage: "Yes, confirm"
|
|
230
|
-
}) }) })
|
|
135
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Close, { children: /* @__PURE__ */ jsxRuntime.jsx(PurgeButton, { onClick: clearCache }) })
|
|
231
136
|
] })
|
|
232
137
|
] })
|
|
233
|
-
] })
|
|
138
|
+
] });
|
|
139
|
+
}
|
|
140
|
+
function PurgeCacheButton() {
|
|
141
|
+
const { contentType } = admin.unstable_useContentManagerContext();
|
|
142
|
+
const { formatMessage } = reactIntl.useIntl();
|
|
143
|
+
const keyToUse = contentType?.info.pluralName;
|
|
144
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
145
|
+
PurgeModal,
|
|
146
|
+
{
|
|
147
|
+
buttonText: formatMessage({
|
|
148
|
+
id: "strapi-cache.cache.purge",
|
|
149
|
+
defaultMessage: "Purge Cache"
|
|
150
|
+
}),
|
|
151
|
+
keyToUse
|
|
152
|
+
}
|
|
153
|
+
);
|
|
154
|
+
}
|
|
155
|
+
function PurgeEntityButton() {
|
|
156
|
+
const { formatMessage } = reactIntl.useIntl();
|
|
157
|
+
const { id, isSingleType, contentType } = admin.unstable_useContentManagerContext();
|
|
158
|
+
const keyToUse = isSingleType ? contentType?.info.singularName : id;
|
|
159
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
160
|
+
PurgeModal,
|
|
161
|
+
{
|
|
162
|
+
buttonWidth: "100%",
|
|
163
|
+
buttonText: formatMessage({
|
|
164
|
+
id: "strapi-cache.cache.purge.entity",
|
|
165
|
+
defaultMessage: "Purge Entity Cache"
|
|
166
|
+
}),
|
|
167
|
+
keyToUse
|
|
168
|
+
}
|
|
169
|
+
);
|
|
234
170
|
}
|
|
235
171
|
const index = {
|
|
236
172
|
register(app) {
|
|
@@ -253,7 +189,7 @@ const index = {
|
|
|
253
189
|
return Promise.all(
|
|
254
190
|
locales.map(async (locale) => {
|
|
255
191
|
try {
|
|
256
|
-
const { default: data } = await __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./translations/en.json": () => Promise.resolve().then(() => require("../_chunks/en-
|
|
192
|
+
const { default: data } = await __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./translations/de.json": () => Promise.resolve().then(() => require("../_chunks/de-CjN-9Obj.js")), "./translations/en.json": () => Promise.resolve().then(() => require("../_chunks/en-D24wwyGh.js")) }), `./translations/${locale}.json`, 3);
|
|
257
193
|
return { data, locale };
|
|
258
194
|
} catch {
|
|
259
195
|
return { data: {}, locale };
|
|
@@ -263,4 +199,3 @@ const index = {
|
|
|
263
199
|
}
|
|
264
200
|
};
|
|
265
201
|
module.exports = index;
|
|
266
|
-
//# sourceMappingURL=index.js.map
|
package/dist/admin/index.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { useRef, useEffect, useState } from "react";
|
|
2
|
-
import { jsx,
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useRBAC, useFetchClient, useNotification, unstable_useContentManagerContext } from "@strapi/strapi/admin";
|
|
3
4
|
import { useIntl } from "react-intl";
|
|
4
5
|
import { Archive } from "@strapi/icons";
|
|
5
|
-
import {
|
|
6
|
-
import { useRBAC, useFetchClient, useNotification, unstable_useContentManagerContext } from "@strapi/strapi/admin";
|
|
6
|
+
import { Button, Modal, Typography } from "@strapi/design-system";
|
|
7
7
|
const __variableDynamicImportRuntimeHelper = (glob, path, segs) => {
|
|
8
8
|
const v = glob[path];
|
|
9
9
|
if (v) {
|
|
@@ -31,14 +31,19 @@ const Initializer = ({ setPlugin }) => {
|
|
|
31
31
|
const pluginPermissions = {
|
|
32
32
|
purge: [{ action: "plugin::strapi-cache.purge-cache", subject: null }]
|
|
33
33
|
};
|
|
34
|
-
function
|
|
34
|
+
function PurgeButton({ onClick }) {
|
|
35
|
+
const formatMessage = useIntl().formatMessage;
|
|
36
|
+
return /* @__PURE__ */ jsx(Button, { onClick, children: formatMessage({
|
|
37
|
+
id: "strapi-cache.cache.confirm",
|
|
38
|
+
defaultMessage: "Yes, confirm"
|
|
39
|
+
}) });
|
|
40
|
+
}
|
|
41
|
+
function PurgeModal({ buttonText, keyToUse, buttonWidth }) {
|
|
35
42
|
const { allowedActions } = useRBAC(pluginPermissions);
|
|
36
43
|
const formatMessage = useIntl().formatMessage;
|
|
37
44
|
const { post, get } = useFetchClient();
|
|
38
45
|
const { toggleNotification } = useNotification();
|
|
39
|
-
const { contentType } = unstable_useContentManagerContext();
|
|
40
46
|
const [cacheableRoutes, setCacheableRoutes] = useState();
|
|
41
|
-
const pluralName = contentType?.info.pluralName;
|
|
42
47
|
useEffect(() => {
|
|
43
48
|
if (!allowedActions.canPurgeCache) {
|
|
44
49
|
return;
|
|
@@ -56,109 +61,16 @@ function PurgeCacheButton() {
|
|
|
56
61
|
setCacheableRoutes(data);
|
|
57
62
|
});
|
|
58
63
|
}, [allowedActions.canPurgeCache]);
|
|
59
|
-
const clearCache = () => {
|
|
60
|
-
if (!pluralName) {
|
|
61
|
-
toggleNotification({
|
|
62
|
-
type: "warning",
|
|
63
|
-
message: formatMessage({
|
|
64
|
-
id: "strapi-cache.cache.purge.no-content-type",
|
|
65
|
-
defaultMessage: "No content type found"
|
|
66
|
-
})
|
|
67
|
-
});
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
70
|
-
post(`/strapi-cache/purge-cache/${pluralName}`, void 0, {
|
|
71
|
-
headers: {
|
|
72
|
-
"Content-Type": "application/json"
|
|
73
|
-
}
|
|
74
|
-
}).then(() => {
|
|
75
|
-
toggleNotification({
|
|
76
|
-
type: "success",
|
|
77
|
-
message: formatMessage({
|
|
78
|
-
id: "strapi-cache.cache.purge.success",
|
|
79
|
-
defaultMessage: "Cache purged successfully"
|
|
80
|
-
}) + `: ${pluralName}`
|
|
81
|
-
});
|
|
82
|
-
}).catch(() => {
|
|
83
|
-
toggleNotification({
|
|
84
|
-
type: "danger",
|
|
85
|
-
message: formatMessage({
|
|
86
|
-
id: "strapi-cache.cache.purge.error",
|
|
87
|
-
defaultMessage: "Error purging cache"
|
|
88
|
-
}) + `: ${pluralName}`
|
|
89
|
-
});
|
|
90
|
-
});
|
|
91
|
-
};
|
|
92
64
|
const isCacheableRoute = () => {
|
|
93
|
-
if (!
|
|
65
|
+
if (!keyToUse || !cacheableRoutes) {
|
|
94
66
|
return false;
|
|
95
67
|
}
|
|
96
68
|
return cacheableRoutes.length === 0 || cacheableRoutes.some((route) => {
|
|
97
|
-
return route.includes(
|
|
69
|
+
return route.includes(keyToUse);
|
|
98
70
|
});
|
|
99
71
|
};
|
|
100
|
-
if (!allowedActions.canPurgeCache || !isCacheableRoute()) {
|
|
101
|
-
return null;
|
|
102
|
-
}
|
|
103
|
-
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(Modal.Root, { children: [
|
|
104
|
-
/* @__PURE__ */ jsx(Modal.Trigger, { children: /* @__PURE__ */ jsx(Button, { startIcon: /* @__PURE__ */ jsx(Archive, {}), variant: "danger", children: formatMessage({
|
|
105
|
-
id: "strapi-cache.cache.purge",
|
|
106
|
-
defaultMessage: "Purge Cache"
|
|
107
|
-
}) }) }),
|
|
108
|
-
/* @__PURE__ */ jsxs(Modal.Content, { children: [
|
|
109
|
-
/* @__PURE__ */ jsx(Modal.Header, { children: /* @__PURE__ */ jsx(Modal.Title, { children: formatMessage({
|
|
110
|
-
id: "strapi-cache.cache.purge",
|
|
111
|
-
defaultMessage: "Purge Cache"
|
|
112
|
-
}) }) }),
|
|
113
|
-
/* @__PURE__ */ jsx(Modal.Body, { children: /* @__PURE__ */ jsx(Typography, { variant: "omega", children: formatMessage(
|
|
114
|
-
{
|
|
115
|
-
id: "strapi-cache.cache.purge.confirmation",
|
|
116
|
-
defaultMessage: "Are you sure you want to purge the cache?"
|
|
117
|
-
},
|
|
118
|
-
{
|
|
119
|
-
key: `"${pluralName}"`
|
|
120
|
-
}
|
|
121
|
-
) }) }),
|
|
122
|
-
/* @__PURE__ */ jsxs(Modal.Footer, { children: [
|
|
123
|
-
/* @__PURE__ */ jsx(Modal.Close, { children: /* @__PURE__ */ jsx(Button, { variant: "tertiary", children: formatMessage({
|
|
124
|
-
id: "strapi-cache.cache.cancel",
|
|
125
|
-
defaultMessage: "No, cancel"
|
|
126
|
-
}) }) }),
|
|
127
|
-
/* @__PURE__ */ jsx(Modal.Close, { children: /* @__PURE__ */ jsx(Button, { onClick: clearCache, children: formatMessage({
|
|
128
|
-
id: "strapi-cache.cache.confirm",
|
|
129
|
-
defaultMessage: "Yes, confirm"
|
|
130
|
-
}) }) })
|
|
131
|
-
] })
|
|
132
|
-
] })
|
|
133
|
-
] }) });
|
|
134
|
-
}
|
|
135
|
-
function PurgeEntityButton() {
|
|
136
|
-
const { allowedActions } = useRBAC(pluginPermissions);
|
|
137
|
-
const formatMessage = useIntl().formatMessage;
|
|
138
|
-
const { post, get } = useFetchClient();
|
|
139
|
-
const { toggleNotification } = useNotification();
|
|
140
|
-
const { contentType, id } = unstable_useContentManagerContext();
|
|
141
|
-
const [cacheableRoutes, setCacheableRoutes] = useState();
|
|
142
|
-
const pluralName = contentType?.info.pluralName;
|
|
143
|
-
useEffect(() => {
|
|
144
|
-
if (!allowedActions.canPurgeCache) {
|
|
145
|
-
return;
|
|
146
|
-
}
|
|
147
|
-
const fetchCacheableRoutes = async () => {
|
|
148
|
-
try {
|
|
149
|
-
const { data } = await get("/strapi-cache/cacheable-routes");
|
|
150
|
-
return data;
|
|
151
|
-
} catch (error) {
|
|
152
|
-
console.error("Error fetching cacheable routes:", error);
|
|
153
|
-
return void 0;
|
|
154
|
-
}
|
|
155
|
-
};
|
|
156
|
-
fetchCacheableRoutes().then((data) => {
|
|
157
|
-
setCacheableRoutes(data);
|
|
158
|
-
});
|
|
159
|
-
}, [allowedActions.canPurgeCache]);
|
|
160
72
|
const clearCache = () => {
|
|
161
|
-
if (!
|
|
73
|
+
if (!keyToUse) {
|
|
162
74
|
toggleNotification({
|
|
163
75
|
type: "warning",
|
|
164
76
|
message: formatMessage({
|
|
@@ -168,68 +80,92 @@ function PurgeEntityButton() {
|
|
|
168
80
|
});
|
|
169
81
|
return;
|
|
170
82
|
}
|
|
171
|
-
post(`/strapi-cache/purge-cache/${
|
|
83
|
+
post(`/strapi-cache/purge-cache/${keyToUse}`, void 0, {
|
|
172
84
|
headers: {
|
|
173
85
|
"Content-Type": "application/json"
|
|
174
86
|
}
|
|
175
87
|
}).then(() => {
|
|
176
88
|
toggleNotification({
|
|
177
89
|
type: "success",
|
|
178
|
-
message: formatMessage(
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
90
|
+
message: formatMessage(
|
|
91
|
+
{
|
|
92
|
+
id: "strapi-cache.cache.purge.success",
|
|
93
|
+
defaultMessage: "Cache purged successfully"
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
key: `"${keyToUse}"`
|
|
97
|
+
}
|
|
98
|
+
)
|
|
182
99
|
});
|
|
183
100
|
}).catch(() => {
|
|
184
101
|
toggleNotification({
|
|
185
102
|
type: "danger",
|
|
186
|
-
message: formatMessage(
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
103
|
+
message: formatMessage(
|
|
104
|
+
{
|
|
105
|
+
id: "strapi-cache.cache.purge.error",
|
|
106
|
+
defaultMessage: "Error purging cache"
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
key: `"${keyToUse}"`
|
|
110
|
+
}
|
|
111
|
+
)
|
|
190
112
|
});
|
|
191
113
|
});
|
|
192
114
|
};
|
|
193
|
-
const isCacheableRoute = () => {
|
|
194
|
-
if (!pluralName || !cacheableRoutes) {
|
|
195
|
-
return false;
|
|
196
|
-
}
|
|
197
|
-
return cacheableRoutes.length === 0 || cacheableRoutes.some((route) => {
|
|
198
|
-
return route.includes(pluralName);
|
|
199
|
-
});
|
|
200
|
-
};
|
|
201
115
|
if (!allowedActions.canPurgeCache || !isCacheableRoute()) {
|
|
202
116
|
return null;
|
|
203
117
|
}
|
|
204
|
-
return /* @__PURE__ */
|
|
205
|
-
/* @__PURE__ */ jsx(Modal.Trigger, { children: /* @__PURE__ */ jsx(Button, { width:
|
|
206
|
-
id: "strapi-cache.cache.purge.entity",
|
|
207
|
-
defaultMessage: "Purge Entity Cache"
|
|
208
|
-
}) }) }),
|
|
118
|
+
return /* @__PURE__ */ jsxs(Modal.Root, { children: [
|
|
119
|
+
/* @__PURE__ */ jsx(Modal.Trigger, { children: /* @__PURE__ */ jsx(Button, { width: buttonWidth, startIcon: /* @__PURE__ */ jsx(Archive, {}), variant: "danger", children: buttonText }) }),
|
|
209
120
|
/* @__PURE__ */ jsxs(Modal.Content, { children: [
|
|
210
|
-
/* @__PURE__ */ jsx(Modal.Header, { children: /* @__PURE__ */ jsx(Modal.Title, { children:
|
|
211
|
-
id: "strapi-cache.cache.purge.entity",
|
|
212
|
-
defaultMessage: "Purge Entity Cache"
|
|
213
|
-
}) }) }),
|
|
121
|
+
/* @__PURE__ */ jsx(Modal.Header, { children: /* @__PURE__ */ jsx(Modal.Title, { children: buttonText }) }),
|
|
214
122
|
/* @__PURE__ */ jsx(Modal.Body, { children: /* @__PURE__ */ jsx(Typography, { variant: "omega", children: formatMessage(
|
|
215
123
|
{
|
|
216
124
|
id: "strapi-cache.cache.purge.confirmation",
|
|
217
125
|
defaultMessage: "Are you sure you want to purge the cache?"
|
|
218
126
|
},
|
|
219
|
-
{ key: `"${
|
|
127
|
+
{ key: `"${keyToUse}"` }
|
|
220
128
|
) }) }),
|
|
221
129
|
/* @__PURE__ */ jsxs(Modal.Footer, { children: [
|
|
222
130
|
/* @__PURE__ */ jsx(Modal.Close, { children: /* @__PURE__ */ jsx(Button, { variant: "tertiary", children: formatMessage({
|
|
223
131
|
id: "strapi-cache.cache.cancel",
|
|
224
132
|
defaultMessage: "No, cancel"
|
|
225
133
|
}) }) }),
|
|
226
|
-
/* @__PURE__ */ jsx(Modal.Close, { children: /* @__PURE__ */ jsx(
|
|
227
|
-
id: "strapi-cache.cache.confirm",
|
|
228
|
-
defaultMessage: "Yes, confirm"
|
|
229
|
-
}) }) })
|
|
134
|
+
/* @__PURE__ */ jsx(Modal.Close, { children: /* @__PURE__ */ jsx(PurgeButton, { onClick: clearCache }) })
|
|
230
135
|
] })
|
|
231
136
|
] })
|
|
232
|
-
] })
|
|
137
|
+
] });
|
|
138
|
+
}
|
|
139
|
+
function PurgeCacheButton() {
|
|
140
|
+
const { contentType } = unstable_useContentManagerContext();
|
|
141
|
+
const { formatMessage } = useIntl();
|
|
142
|
+
const keyToUse = contentType?.info.pluralName;
|
|
143
|
+
return /* @__PURE__ */ jsx(
|
|
144
|
+
PurgeModal,
|
|
145
|
+
{
|
|
146
|
+
buttonText: formatMessage({
|
|
147
|
+
id: "strapi-cache.cache.purge",
|
|
148
|
+
defaultMessage: "Purge Cache"
|
|
149
|
+
}),
|
|
150
|
+
keyToUse
|
|
151
|
+
}
|
|
152
|
+
);
|
|
153
|
+
}
|
|
154
|
+
function PurgeEntityButton() {
|
|
155
|
+
const { formatMessage } = useIntl();
|
|
156
|
+
const { id, isSingleType, contentType } = unstable_useContentManagerContext();
|
|
157
|
+
const keyToUse = isSingleType ? contentType?.info.singularName : id;
|
|
158
|
+
return /* @__PURE__ */ jsx(
|
|
159
|
+
PurgeModal,
|
|
160
|
+
{
|
|
161
|
+
buttonWidth: "100%",
|
|
162
|
+
buttonText: formatMessage({
|
|
163
|
+
id: "strapi-cache.cache.purge.entity",
|
|
164
|
+
defaultMessage: "Purge Entity Cache"
|
|
165
|
+
}),
|
|
166
|
+
keyToUse
|
|
167
|
+
}
|
|
168
|
+
);
|
|
233
169
|
}
|
|
234
170
|
const index = {
|
|
235
171
|
register(app) {
|
|
@@ -252,7 +188,7 @@ const index = {
|
|
|
252
188
|
return Promise.all(
|
|
253
189
|
locales.map(async (locale) => {
|
|
254
190
|
try {
|
|
255
|
-
const { default: data } = await __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./translations/en.json": () => import("../_chunks/en-
|
|
191
|
+
const { default: data } = await __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./translations/de.json": () => import("../_chunks/de-CBzKPGsY.mjs"), "./translations/en.json": () => import("../_chunks/en-BDlRjAzq.mjs") }), `./translations/${locale}.json`, 3);
|
|
256
192
|
return { data, locale };
|
|
257
193
|
} catch {
|
|
258
194
|
return { data: {}, locale };
|
|
@@ -264,4 +200,3 @@ const index = {
|
|
|
264
200
|
export {
|
|
265
201
|
index as default
|
|
266
202
|
};
|
|
267
|
-
//# sourceMappingURL=index.mjs.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare function PurgeCacheButton(): import("react/jsx-runtime").JSX.Element
|
|
1
|
+
declare function PurgeCacheButton(): import("react/jsx-runtime").JSX.Element;
|
|
2
2
|
export default PurgeCacheButton;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare function PurgeEntityButton(): import("react/jsx-runtime").JSX.Element
|
|
1
|
+
declare function PurgeEntityButton(): import("react/jsx-runtime").JSX.Element;
|
|
2
2
|
export default PurgeEntityButton;
|
package/dist/server/index.js
CHANGED
package/dist/server/index.mjs
CHANGED