strapi-cache 1.3.0 → 1.4.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.
Files changed (39) hide show
  1. package/README.md +55 -13
  2. package/dist/_chunks/en-BPx_Feq_.mjs +17 -0
  3. package/dist/_chunks/en-BPx_Feq_.mjs.map +1 -0
  4. package/dist/_chunks/en-BdzOe-Jv.mjs +16 -0
  5. package/dist/_chunks/en-BdzOe-Jv.mjs.map +1 -0
  6. package/dist/_chunks/en-Bev8UGB9.js +14 -0
  7. package/dist/_chunks/en-Bev8UGB9.js.map +1 -0
  8. package/dist/_chunks/en-C0JeH0S_.js +17 -0
  9. package/dist/_chunks/en-C0JeH0S_.js.map +1 -0
  10. package/dist/_chunks/en-C0qeO9FB.mjs +15 -0
  11. package/dist/_chunks/en-C0qeO9FB.mjs.map +1 -0
  12. package/dist/_chunks/en-CVjURV1W.js +11 -0
  13. package/dist/_chunks/en-CVjURV1W.js.map +1 -0
  14. package/dist/_chunks/en-C_x7qEgd.mjs +11 -0
  15. package/dist/_chunks/en-C_x7qEgd.mjs.map +1 -0
  16. package/dist/_chunks/en-DZzRFINn.js +16 -0
  17. package/dist/_chunks/en-DZzRFINn.js.map +1 -0
  18. package/dist/_chunks/en-D_Fd-4QS.js +15 -0
  19. package/dist/_chunks/en-D_Fd-4QS.js.map +1 -0
  20. package/dist/_chunks/en-DdVULHeC.mjs +14 -0
  21. package/dist/_chunks/en-DdVULHeC.mjs.map +1 -0
  22. package/dist/admin/index.js +83 -1
  23. package/dist/admin/index.js.map +1 -1
  24. package/dist/admin/index.mjs +83 -1
  25. package/dist/admin/index.mjs.map +1 -1
  26. package/dist/admin/src/components/PurgeCacheButton/index.d.ts +2 -0
  27. package/dist/admin/src/permission.d.ts +6 -0
  28. package/dist/server/index.js +68 -18
  29. package/dist/server/index.js.map +1 -1
  30. package/dist/server/index.mjs +68 -18
  31. package/dist/server/index.mjs.map +1 -1
  32. package/dist/server/src/controllers/controller.d.ts +2 -1
  33. package/dist/server/src/controllers/index.d.ts +2 -1
  34. package/dist/server/src/index.d.ts +11 -12
  35. package/dist/server/src/permissions.d.ts +6 -0
  36. package/dist/server/src/routes/index.d.ts +7 -2
  37. package/dist/server/src/routes/purge.d.ts +14 -0
  38. package/dist/server/src/types/cache.types.d.ts +1 -1
  39. package/package.json +3 -3
package/README.md CHANGED
@@ -41,21 +41,30 @@ In your Strapi project, navigate to `config/plugins.js` and add the following co
41
41
 
42
42
  ```javascript
43
43
  // config/plugins.{js,ts}
44
- 'strapi-cache': {
45
- enabled: true,
46
- config: {
47
- debug: false, // Enable debug logs
48
- max: 1000, // Maximum number of items in the cache (only for memory cache)
49
- ttl: 1000 * 60 * 60, // Time to live for cache items (1 hour)
50
- size: 1024 * 1024 * 1024, // Maximum size of the cache (1 GB) (only for memory cache)
51
- allowStale: false, // Allow stale cache items (only for memory cache)
52
- cacheableRoutes: ['/api/products', '/api/categories'], // Caches routes which start with these paths (if empty array, all '/api' routes are cached)
53
- provider: 'memory', // Cache provider ('memory' or 'redis')
54
- redisUrl: env('REDIS_URL', 'redis://localhost:6379'), // Redis URL (if using Redis)
55
- },
44
+ 'strapi-cache': {
45
+ enabled: true,
46
+ config: {
47
+ debug: false, // Enable debug logs
48
+ max: 1000, // Maximum number of items in the cache (only for memory cache)
49
+ ttl: 1000 * 60 * 60, // Time to live for cache items (1 hour)
50
+ size: 1024 * 1024 * 1024, // Maximum size of the cache (1 GB) (only for memory cache)
51
+ allowStale: false, // Allow stale cache items (only for memory cache)
52
+ cacheableRoutes: ['/api/products', '/api/categories'], // Caches routes which start with these paths (if empty array, all '/api' routes are cached)
53
+ provider: 'memory', // Cache provider ('memory' or 'redis')
54
+ redisUrl: env('REDIS_URL', 'redis://localhost:6379'), // Redis URL (if using Redis)
56
55
  },
56
+ },
57
57
  ```
58
58
 
59
+ ## 🔍 Routes
60
+
61
+ The plugin creates two new routes
62
+
63
+ - `POST /strapi-cache/purge-cache` (purges the whole cache)
64
+ - `POST /strapi-cache/purge-cache/:key` (purges cache entries with have the key in the cache key)
65
+
66
+ Both routes are protected by the policies `admin::isAuthenticatedAdmin` and `plugin::strapi-cache.purge-cache`. The second policy can be managed in the plugin's permissions section under the settings.
67
+
59
68
  ## 🗂️ How It Works
60
69
 
61
70
  - **Storage**: The plugin keeps cached data in memory or Redis, depending on the configuration.
@@ -68,10 +77,43 @@ In your Strapi project, navigate to `config/plugins.js` and add the following co
68
77
 
69
78
  - [x] **Cache Invalidation**: Automatically invalidate cache on content updates, deletions, or creations.
70
79
  - [x] **GraphQL Caching**: Cache GraphQL queries.
71
- - [ ] **Purge Cache in Settings**: Add a UI option in the Strapi admin panel to manually purge the cache.
80
+ - [x] **Purge Cache Button**: Add a UI option in the Strapi admin panel to manually purge the cache for content-types.
81
+ - [ ] **Purge Whole Cache Button**: Add a UI option in the Strapi admin settings panel to purge the whole cache.
72
82
  - [x] **Route/Content-Type Specific Caching**: Allow users to define which routes should be cached based.
73
83
  - [x] **Switchable Cache Providers**: Explore support for other caching providers like Redis for distributed caching.
74
84
 
85
+ ## 🛑 Problems
86
+
87
+ If you encounter any issues, please feel free to open an issue on the [GitHub repo](https://github.com/TupiC/strapi-cache/issues/new).
88
+
89
+ ## 🛠️ Troubleshooting
90
+
91
+ If you encounter an error like:
92
+
93
+ ```
94
+ Access to fetch at 'http://your-backend.com' from origin 'http://your-origin.com' has been blocked by CORS policy:
95
+ Request header field cache-control is not allowed by Access-Control-Allow-Headers in preflight response.
96
+ ```
97
+
98
+ You might need to adjust your CORS middlware settings in Strapi:
99
+
100
+ ```javascript
101
+ // config/middlewares.{js,ts}
102
+ 'strapi::cors';
103
+ ```
104
+
105
+ with:
106
+
107
+ ```javascript
108
+ // config/middlewares.{js,ts}
109
+ {
110
+ name: "strapi::cors",
111
+ config: {
112
+ headers: ["Content-Type", "Authorization", "Cache-Control"], // Add 'Cache-Control' to the allowed headers
113
+ },
114
+ },
115
+ ```
116
+
75
117
  ## 🛠️ Contributing
76
118
 
77
119
  Contributions are welcome! If you have suggestions or improvements, please open an issue or submit a pull request.
@@ -0,0 +1,17 @@
1
+ const en = {
2
+ "strapi-cache.name": "Strapi Cache",
3
+ "strapi-cache.settings": "Cache Settings",
4
+ "strapi-cache.view.settings.title": "Strapi Cache Settings",
5
+ "strapi-cache.view.settings.subtitle": "Configure what to cache",
6
+ "strapi-cache.cache.purge": "Purge Cache",
7
+ "strapi-cache.cache.cancel": "No, cancel",
8
+ "strapi-cache.cache.confirm": "Yes, purge",
9
+ "strapi-cache.cache.purge.confirmation": "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",
12
+ "strapi-cache.cache.purge.no-content-type": "No content type found"
13
+ };
14
+ export {
15
+ en as default
16
+ };
17
+ //# sourceMappingURL=en-BPx_Feq_.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"en-BPx_Feq_.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;"}
@@ -0,0 +1,16 @@
1
+ const en = {
2
+ "strapi-cache.name": "Strapi Cache",
3
+ "strapi-cache.settings": "Cache Settings",
4
+ "strapi-cache.view.settings.title": "Strapi Cache Settings",
5
+ "strapi-cache.view.settings.subtitle": "Configure what to cache",
6
+ "strapi-cache.cache.purge": "Purge Cache",
7
+ "strapi-cache.cache.cancel": "No, cancel",
8
+ "strapi-cache.cache.confirm": "Yes, purge",
9
+ "strapi-cache.cache.purge.confirmation": "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"
12
+ };
13
+ export {
14
+ en as default
15
+ };
16
+ //# sourceMappingURL=en-BdzOe-Jv.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"en-BdzOe-Jv.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;"}
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const en = {
4
+ "strapi-cache.name": "Strapi Cache",
5
+ "strapi-cache.settings": "Cache Settings",
6
+ "strapi-cache.view.settings.title": "Strapi Cache Settings",
7
+ "strapi-cache.view.settings.subtitle": "Configure what to cache",
8
+ "strapi-cache.cache.purge": "Purge Cache",
9
+ "strapi-cache.cache.cancel": "No, cancel",
10
+ "strapi-cache.cache.confirm": "Yes, purge",
11
+ "strapi-cache.cache.purge.confirmation": "Are you sure you want to purge the cache?"
12
+ };
13
+ exports.default = en;
14
+ //# sourceMappingURL=en-Bev8UGB9.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"en-Bev8UGB9.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;"}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const en = {
4
+ "strapi-cache.name": "Strapi Cache",
5
+ "strapi-cache.settings": "Cache Settings",
6
+ "strapi-cache.view.settings.title": "Strapi Cache Settings",
7
+ "strapi-cache.view.settings.subtitle": "Configure what to cache",
8
+ "strapi-cache.cache.purge": "Purge Cache",
9
+ "strapi-cache.cache.cancel": "No, cancel",
10
+ "strapi-cache.cache.confirm": "Yes, purge",
11
+ "strapi-cache.cache.purge.confirmation": "Are you sure you want to purge the cache?",
12
+ "strapi-cache.cache.purge.success": "Cache purged successfully",
13
+ "strapi-cache.cache.purge.error": "Error purging cache",
14
+ "strapi-cache.cache.purge.no-content-type": "No content type found"
15
+ };
16
+ exports.default = en;
17
+ //# sourceMappingURL=en-C0JeH0S_.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"en-C0JeH0S_.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;"}
@@ -0,0 +1,15 @@
1
+ const en = {
2
+ "strapi-cache.name": "Strapi Cache",
3
+ "strapi-cache.settings": "Cache Settings",
4
+ "strapi-cache.view.settings.title": "Strapi Cache Settings",
5
+ "strapi-cache.view.settings.subtitle": "Configure what to cache",
6
+ "strapi-cache.cache.purge": "Purge Cache",
7
+ "strapi-cache.cache.cancel": "No, cancel",
8
+ "strapi-cache.cache.confirm": "Yes, purge",
9
+ "strapi-cache.cache.purge.confirmation": "Are you sure you want to purge the cache?",
10
+ "strapi-cache.cache.purge.success": "Cache purged successfully"
11
+ };
12
+ export {
13
+ en as default
14
+ };
15
+ //# sourceMappingURL=en-C0qeO9FB.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"en-C0qeO9FB.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;"}
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const en = {
4
+ "strapi-cache.name": "Strapi Cache",
5
+ "strapi-cache.settings": "Cache Settings",
6
+ "strapi-cache.view.settings.title": "Strapi Cache Settings",
7
+ "strapi-cache.view.settings.subtitle": "Configure what to cache",
8
+ "strapi-cache.cache.purge": "Purge Cache"
9
+ };
10
+ exports.default = en;
11
+ //# sourceMappingURL=en-CVjURV1W.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"en-CVjURV1W.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;"}
@@ -0,0 +1,11 @@
1
+ const en = {
2
+ "strapi-cache.name": "Strapi Cache",
3
+ "strapi-cache.settings": "Cache Settings",
4
+ "strapi-cache.view.settings.title": "Strapi Cache Settings",
5
+ "strapi-cache.view.settings.subtitle": "Configure what to cache",
6
+ "strapi-cache.cache.purge": "Purge Cache"
7
+ };
8
+ export {
9
+ en as default
10
+ };
11
+ //# sourceMappingURL=en-C_x7qEgd.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"en-C_x7qEgd.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;"}
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const en = {
4
+ "strapi-cache.name": "Strapi Cache",
5
+ "strapi-cache.settings": "Cache Settings",
6
+ "strapi-cache.view.settings.title": "Strapi Cache Settings",
7
+ "strapi-cache.view.settings.subtitle": "Configure what to cache",
8
+ "strapi-cache.cache.purge": "Purge Cache",
9
+ "strapi-cache.cache.cancel": "No, cancel",
10
+ "strapi-cache.cache.confirm": "Yes, purge",
11
+ "strapi-cache.cache.purge.confirmation": "Are you sure you want to purge the cache?",
12
+ "strapi-cache.cache.purge.success": "Cache purged successfully",
13
+ "strapi-cache.cache.purge.error": "Error purging cache"
14
+ };
15
+ exports.default = en;
16
+ //# sourceMappingURL=en-DZzRFINn.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"en-DZzRFINn.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;"}
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const en = {
4
+ "strapi-cache.name": "Strapi Cache",
5
+ "strapi-cache.settings": "Cache Settings",
6
+ "strapi-cache.view.settings.title": "Strapi Cache Settings",
7
+ "strapi-cache.view.settings.subtitle": "Configure what to cache",
8
+ "strapi-cache.cache.purge": "Purge Cache",
9
+ "strapi-cache.cache.cancel": "No, cancel",
10
+ "strapi-cache.cache.confirm": "Yes, purge",
11
+ "strapi-cache.cache.purge.confirmation": "Are you sure you want to purge the cache?",
12
+ "strapi-cache.cache.purge.success": "Cache purged successfully"
13
+ };
14
+ exports.default = en;
15
+ //# sourceMappingURL=en-D_Fd-4QS.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"en-D_Fd-4QS.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;"}
@@ -0,0 +1,14 @@
1
+ const en = {
2
+ "strapi-cache.name": "Strapi Cache",
3
+ "strapi-cache.settings": "Cache Settings",
4
+ "strapi-cache.view.settings.title": "Strapi Cache Settings",
5
+ "strapi-cache.view.settings.subtitle": "Configure what to cache",
6
+ "strapi-cache.cache.purge": "Purge Cache",
7
+ "strapi-cache.cache.cancel": "No, cancel",
8
+ "strapi-cache.cache.confirm": "Yes, purge",
9
+ "strapi-cache.cache.purge.confirmation": "Are you sure you want to purge the cache?"
10
+ };
11
+ export {
12
+ en as default
13
+ };
14
+ //# sourceMappingURL=en-DdVULHeC.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"en-DdVULHeC.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;"}
@@ -1,5 +1,10 @@
1
1
  "use strict";
2
2
  const react = require("react");
3
+ const jsxRuntime = require("react/jsx-runtime");
4
+ const reactIntl = require("react-intl");
5
+ const icons = require("@strapi/icons");
6
+ const designSystem = require("@strapi/design-system");
7
+ const admin = require("@strapi/strapi/admin");
3
8
  const __variableDynamicImportRuntimeHelper = (glob, path, segs) => {
4
9
  const v = glob[path];
5
10
  if (v) {
@@ -24,6 +29,79 @@ const Initializer = ({ setPlugin }) => {
24
29
  }, []);
25
30
  return null;
26
31
  };
32
+ const pluginPermissions = {
33
+ purge: [{ action: "plugin::strapi-cache.purge-cache", subject: null }]
34
+ };
35
+ function PurgeCacheButton() {
36
+ const { allowedActions } = admin.useRBAC(pluginPermissions);
37
+ const formatMessage = reactIntl.useIntl().formatMessage;
38
+ const { post } = admin.useFetchClient();
39
+ const { toggleNotification } = admin.useNotification();
40
+ const { contentType } = admin.unstable_useContentManagerContext();
41
+ const pluralName = contentType?.info.pluralName;
42
+ const clearCache = () => {
43
+ if (!pluralName) {
44
+ toggleNotification({
45
+ type: "warning",
46
+ message: formatMessage({
47
+ id: "strapi-cache.cache.purge.no-content-type",
48
+ defaultMessage: "No content type found"
49
+ })
50
+ });
51
+ return;
52
+ }
53
+ post(`/strapi-cache/purge-cache/${pluralName}`, void 0, {
54
+ headers: {
55
+ "Content-Type": "application/json"
56
+ }
57
+ }).then(() => {
58
+ toggleNotification({
59
+ type: "success",
60
+ message: formatMessage({
61
+ id: "strapi-cache.cache.purge.success",
62
+ defaultMessage: "Cache purged successfully"
63
+ }) + `: ${pluralName}`
64
+ });
65
+ }).catch(() => {
66
+ toggleNotification({
67
+ type: "danger",
68
+ message: formatMessage({
69
+ id: "strapi-cache.cache.purge.error",
70
+ defaultMessage: "Error purging cache"
71
+ }) + `: ${pluralName}`
72
+ });
73
+ });
74
+ };
75
+ if (!allowedActions.canPurgeCache) {
76
+ return null;
77
+ }
78
+ return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Modal.Root, { children: [
79
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Trigger, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { startIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.Archive, {}), variant: "danger", children: formatMessage({
80
+ id: "strapi-cache.cache.purge",
81
+ defaultMessage: "Purge Cache"
82
+ }) }) }),
83
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Modal.Content, { children: [
84
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Title, { children: formatMessage({
85
+ id: "strapi-cache.cache.purge",
86
+ defaultMessage: "Purge Cache"
87
+ }) }) }),
88
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Body, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", children: formatMessage({
89
+ id: "strapi-cache.cache.purge.confirmation",
90
+ defaultMessage: "Are you sure you want to purge the cache?"
91
+ }) }) }),
92
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Modal.Footer, { children: [
93
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Close, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { variant: "tertiary", children: formatMessage({
94
+ id: "strapi-cache.cache.cancel",
95
+ defaultMessage: "No, cancel"
96
+ }) }) }),
97
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Close, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { onClick: clearCache, children: formatMessage({
98
+ id: "strapi-cache.cache.confirm",
99
+ defaultMessage: "Yes, confirm"
100
+ }) }) })
101
+ ] })
102
+ ] })
103
+ ] }) });
104
+ }
27
105
  const index = {
28
106
  register(app) {
29
107
  app.registerPlugin({
@@ -32,12 +110,16 @@ const index = {
32
110
  isReady: false,
33
111
  name: PLUGIN_ID
34
112
  });
113
+ app.getPlugin("content-manager").injectComponent("listView", "actions", {
114
+ name: PurgeCacheButton,
115
+ Component: PurgeCacheButton
116
+ });
35
117
  },
36
118
  async registerTrads({ locales }) {
37
119
  return Promise.all(
38
120
  locales.map(async (locale) => {
39
121
  try {
40
- const { default: data } = await __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./translations/en.json": () => Promise.resolve().then(() => require("../_chunks/en-CIN0kRXJ.js")) }), `./translations/${locale}.json`, 3);
122
+ const { default: data } = await __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./translations/en.json": () => Promise.resolve().then(() => require("../_chunks/en-C0JeH0S_.js")) }), `./translations/${locale}.json`, 3);
41
123
  return { data, locale };
42
124
  } catch {
43
125
  return { data: {}, locale };
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../admin/src/pluginId.ts","../../admin/src/components/Initializer.tsx","../../admin/src/index.ts"],"sourcesContent":["export const PLUGIN_ID = 'strapi-cache';\n","import { useEffect, useRef } from 'react';\n\nimport { PLUGIN_ID } from '../pluginId';\n\ntype InitializerProps = {\n setPlugin: (id: string) => void;\n};\n\nconst Initializer = ({ setPlugin }: InitializerProps) => {\n const ref = useRef(setPlugin);\n\n useEffect(() => {\n ref.current(PLUGIN_ID);\n }, []);\n\n return null;\n};\n\nexport { Initializer };\n","import { PLUGIN_ID } from './pluginId';\nimport { Initializer } from './components/Initializer';\n\nexport default {\n register(app: any) {\n app.registerPlugin({\n id: PLUGIN_ID,\n initializer: Initializer,\n isReady: false,\n name: PLUGIN_ID,\n });\n },\n\n async registerTrads({ locales }: { locales: string[] }) {\n return Promise.all(\n locales.map(async (locale) => {\n try {\n const { default: data } = await import(`./translations/${locale}.json`);\n\n return { data, locale };\n } catch {\n return { data: {}, locale };\n }\n })\n );\n },\n};\n"],"names":["useRef","useEffect"],"mappings":";;;;;;;;;;;;;;;;;;AAAO,MAAM,YAAY;ACQzB,MAAM,cAAc,CAAC,EAAE,gBAAkC;AACjD,QAAA,MAAMA,aAAO,SAAS;AAE5BC,QAAAA,UAAU,MAAM;AACd,QAAI,QAAQ,SAAS;AAAA,EACvB,GAAG,EAAE;AAEE,SAAA;AACT;ACbA,MAAe,QAAA;AAAA,EACb,SAAS,KAAU;AACjB,QAAI,eAAe;AAAA,MACjB,IAAI;AAAA,MACJ,aAAa;AAAA,MACb,SAAS;AAAA,MACT,MAAM;AAAA,IAAA,CACP;AAAA,EACH;AAAA,EAEA,MAAM,cAAc,EAAE,WAAkC;AACtD,WAAO,QAAQ;AAAA,MACb,QAAQ,IAAI,OAAO,WAAW;AACxB,YAAA;AACF,gBAAM,EAAE,SAAS,SAAS,MAAM,qCAAA,uBAAA,OAAA,EAAA,0BAAA,MAAA,QAAA,QAAA,EAAA,KAAA,MAAA,QAAA,2BAAA,CAAA,EAAA,CAAA,GAAA,kBAAA,MAAA,SAAA,CAAA;AAEzB,iBAAA,EAAE,MAAM,OAAO;AAAA,QAAA,QAChB;AACN,iBAAO,EAAE,MAAM,CAAC,GAAG,OAAO;AAAA,QAAA;AAAA,MAE7B,CAAA;AAAA,IACH;AAAA,EAAA;AAEJ;;"}
1
+ {"version":3,"file":"index.js","sources":["../../admin/src/pluginId.ts","../../admin/src/components/Initializer.tsx","../../admin/src/permission.ts","../../admin/src/components/PurgeCacheButton/index.tsx","../../admin/src/index.ts"],"sourcesContent":["export const PLUGIN_ID = 'strapi-cache';\n","import { useEffect, useRef } from 'react';\n\nimport { PLUGIN_ID } from '../pluginId';\n\ntype InitializerProps = {\n setPlugin: (id: string) => void;\n};\n\nconst Initializer = ({ setPlugin }: InitializerProps) => {\n const ref = useRef(setPlugin);\n\n useEffect(() => {\n ref.current(PLUGIN_ID);\n }, []);\n\n return null;\n};\n\nexport { Initializer };\n","export const pluginPermissions = {\n purge: [{ action: 'plugin::strapi-cache.purge-cache', subject: null }],\n};\n","import { useIntl } from 'react-intl';\nimport { Archive } from '@strapi/icons';\nimport { Button, Modal } from '@strapi/design-system';\nimport { useRBAC } from '@strapi/strapi/admin';\nimport { pluginPermissions } from '../../permission';\nimport { Typography } from '@strapi/design-system';\nimport { useFetchClient } from '@strapi/strapi/admin';\nimport { unstable_useContentManagerContext as useContentManagerContext } from '@strapi/strapi/admin';\nimport { useNotification } from '@strapi/strapi/admin';\n\nfunction PurgeCacheButton() {\n const { allowedActions } = useRBAC(pluginPermissions);\n const formatMessage = useIntl().formatMessage;\n const { post } = useFetchClient();\n const { toggleNotification } = useNotification();\n const { contentType } = useContentManagerContext();\n const pluralName = contentType?.info.pluralName;\n\n const clearCache = () => {\n if (!pluralName) {\n toggleNotification({\n type: 'warning',\n message: formatMessage({\n id: 'strapi-cache.cache.purge.no-content-type',\n defaultMessage: 'No content type found',\n }),\n });\n return;\n }\n\n post(`/strapi-cache/purge-cache/${pluralName}`, undefined, {\n headers: {\n 'Content-Type': 'application/json',\n },\n })\n .then(() => {\n toggleNotification({\n type: 'success',\n message:\n formatMessage({\n id: 'strapi-cache.cache.purge.success',\n defaultMessage: 'Cache purged successfully',\n }) + `: ${pluralName}`,\n });\n })\n .catch(() => {\n toggleNotification({\n type: 'danger',\n message:\n formatMessage({\n id: 'strapi-cache.cache.purge.error',\n defaultMessage: 'Error purging cache',\n }) + `: ${pluralName}`,\n });\n });\n };\n\n if (!allowedActions.canPurgeCache) {\n return null;\n }\n\n return (\n <>\n <Modal.Root>\n <Modal.Trigger>\n <Button startIcon={<Archive />} variant=\"danger\">\n {formatMessage({\n id: 'strapi-cache.cache.purge',\n defaultMessage: 'Purge Cache',\n })}\n </Button>\n </Modal.Trigger>\n <Modal.Content>\n <Modal.Header>\n <Modal.Title>\n {formatMessage({\n id: 'strapi-cache.cache.purge',\n defaultMessage: 'Purge Cache',\n })}\n </Modal.Title>\n </Modal.Header>\n <Modal.Body>\n <Typography variant=\"omega\">\n {formatMessage({\n id: 'strapi-cache.cache.purge.confirmation',\n defaultMessage: 'Are you sure you want to purge the cache?',\n })}\n </Typography>\n </Modal.Body>\n <Modal.Footer>\n <Modal.Close>\n <Button variant=\"tertiary\">\n {formatMessage({\n id: 'strapi-cache.cache.cancel',\n defaultMessage: 'No, cancel',\n })}\n </Button>\n </Modal.Close>\n <Modal.Close>\n <Button onClick={clearCache}>\n {formatMessage({\n id: 'strapi-cache.cache.confirm',\n defaultMessage: 'Yes, confirm',\n })}\n </Button>\n </Modal.Close>\n </Modal.Footer>\n </Modal.Content>\n </Modal.Root>\n </>\n );\n}\n\nexport default PurgeCacheButton;\n","import { PLUGIN_ID } from './pluginId';\nimport { Initializer } from './components/Initializer';\nimport PurgeCacheButton from './components/PurgeCacheButton';\n\nexport default {\n register(app: any) {\n app.registerPlugin({\n id: PLUGIN_ID,\n initializer: Initializer,\n isReady: false,\n name: PLUGIN_ID,\n });\n\n app.getPlugin('content-manager').injectComponent('listView', 'actions', {\n name: PurgeCacheButton,\n Component: PurgeCacheButton,\n });\n },\n\n async registerTrads({ locales }: { locales: string[] }) {\n return Promise.all(\n locales.map(async (locale) => {\n try {\n const { default: data } = await import(`./translations/${locale}.json`);\n\n return { data, locale };\n } catch {\n return { data: {}, locale };\n }\n })\n );\n },\n};\n"],"names":["useRef","useEffect","useRBAC","useIntl","useFetchClient","useNotification","useContentManagerContext","jsx","Fragment","jsxs","Modal","Button","Archive","Typography"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAO,MAAM,YAAY;ACQzB,MAAM,cAAc,CAAC,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AA,MACjB,IAAI;AAAA,MACJ,aAAa;AAAA,MACb,SAAS;AAAA,MACT,MAAM;AAAA,IAAA,CACP;AAED,QAAI,UAAU,iBAAiB,EAAE,gBAAgB,YAAY,WAAW;AAAA,MACtE,MAAM;AAAA,MACN,WAAW;AAAA,IAAA,CACZ;AAAA,EACH;AAAA,EAEA,MAAM,cAAc,EAAE,WAAkC;AACtD,WAAO,QAAQ;AAAA,MACb,QAAQ,IAAI,OAAO,WAAW;AACxB,YAAA;AACF,gBAAM,EAAE,SAAS,SAAS,MAAM,qCAAA,uBAAA,OAAA,EAAA,0BAAA,MAAA,QAAA,QAAA,EAAA,KAAA,MAAA,QAAA,2BAAA,CAAA,EAAA,CAAA,GAAA,kBAAA,MAAA,SAAA,CAAA;AAEzB,iBAAA,EAAE,MAAM,OAAO;AAAA,QAAA,QAChB;AACN,iBAAO,EAAE,MAAM,CAAC,GAAG,OAAO;AAAA,QAAA;AAAA,MAE7B,CAAA;AAAA,IACH;AAAA,EAAA;AAEJ;;"}
@@ -1,4 +1,9 @@
1
1
  import { useRef, useEffect } from "react";
2
+ import { jsx, Fragment, jsxs } from "react/jsx-runtime";
3
+ import { useIntl } from "react-intl";
4
+ import { Archive } from "@strapi/icons";
5
+ import { Modal, Button, Typography } from "@strapi/design-system";
6
+ import { useRBAC, useFetchClient, useNotification, unstable_useContentManagerContext } from "@strapi/strapi/admin";
2
7
  const __variableDynamicImportRuntimeHelper = (glob, path, segs) => {
3
8
  const v = glob[path];
4
9
  if (v) {
@@ -23,6 +28,79 @@ const Initializer = ({ setPlugin }) => {
23
28
  }, []);
24
29
  return null;
25
30
  };
31
+ const pluginPermissions = {
32
+ purge: [{ action: "plugin::strapi-cache.purge-cache", subject: null }]
33
+ };
34
+ function PurgeCacheButton() {
35
+ const { allowedActions } = useRBAC(pluginPermissions);
36
+ const formatMessage = useIntl().formatMessage;
37
+ const { post } = useFetchClient();
38
+ const { toggleNotification } = useNotification();
39
+ const { contentType } = unstable_useContentManagerContext();
40
+ const pluralName = contentType?.info.pluralName;
41
+ const clearCache = () => {
42
+ if (!pluralName) {
43
+ toggleNotification({
44
+ type: "warning",
45
+ message: formatMessage({
46
+ id: "strapi-cache.cache.purge.no-content-type",
47
+ defaultMessage: "No content type found"
48
+ })
49
+ });
50
+ return;
51
+ }
52
+ post(`/strapi-cache/purge-cache/${pluralName}`, void 0, {
53
+ headers: {
54
+ "Content-Type": "application/json"
55
+ }
56
+ }).then(() => {
57
+ toggleNotification({
58
+ type: "success",
59
+ message: formatMessage({
60
+ id: "strapi-cache.cache.purge.success",
61
+ defaultMessage: "Cache purged successfully"
62
+ }) + `: ${pluralName}`
63
+ });
64
+ }).catch(() => {
65
+ toggleNotification({
66
+ type: "danger",
67
+ message: formatMessage({
68
+ id: "strapi-cache.cache.purge.error",
69
+ defaultMessage: "Error purging cache"
70
+ }) + `: ${pluralName}`
71
+ });
72
+ });
73
+ };
74
+ if (!allowedActions.canPurgeCache) {
75
+ return null;
76
+ }
77
+ return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(Modal.Root, { children: [
78
+ /* @__PURE__ */ jsx(Modal.Trigger, { children: /* @__PURE__ */ jsx(Button, { startIcon: /* @__PURE__ */ jsx(Archive, {}), variant: "danger", children: formatMessage({
79
+ id: "strapi-cache.cache.purge",
80
+ defaultMessage: "Purge Cache"
81
+ }) }) }),
82
+ /* @__PURE__ */ jsxs(Modal.Content, { children: [
83
+ /* @__PURE__ */ jsx(Modal.Header, { children: /* @__PURE__ */ jsx(Modal.Title, { children: formatMessage({
84
+ id: "strapi-cache.cache.purge",
85
+ defaultMessage: "Purge Cache"
86
+ }) }) }),
87
+ /* @__PURE__ */ jsx(Modal.Body, { children: /* @__PURE__ */ jsx(Typography, { variant: "omega", children: formatMessage({
88
+ id: "strapi-cache.cache.purge.confirmation",
89
+ defaultMessage: "Are you sure you want to purge the cache?"
90
+ }) }) }),
91
+ /* @__PURE__ */ jsxs(Modal.Footer, { children: [
92
+ /* @__PURE__ */ jsx(Modal.Close, { children: /* @__PURE__ */ jsx(Button, { variant: "tertiary", children: formatMessage({
93
+ id: "strapi-cache.cache.cancel",
94
+ defaultMessage: "No, cancel"
95
+ }) }) }),
96
+ /* @__PURE__ */ jsx(Modal.Close, { children: /* @__PURE__ */ jsx(Button, { onClick: clearCache, children: formatMessage({
97
+ id: "strapi-cache.cache.confirm",
98
+ defaultMessage: "Yes, confirm"
99
+ }) }) })
100
+ ] })
101
+ ] })
102
+ ] }) });
103
+ }
26
104
  const index = {
27
105
  register(app) {
28
106
  app.registerPlugin({
@@ -31,12 +109,16 @@ const index = {
31
109
  isReady: false,
32
110
  name: PLUGIN_ID
33
111
  });
112
+ app.getPlugin("content-manager").injectComponent("listView", "actions", {
113
+ name: PurgeCacheButton,
114
+ Component: PurgeCacheButton
115
+ });
34
116
  },
35
117
  async registerTrads({ locales }) {
36
118
  return Promise.all(
37
119
  locales.map(async (locale) => {
38
120
  try {
39
- const { default: data } = await __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./translations/en.json": () => import("../_chunks/en-BgoZyxl0.mjs") }), `./translations/${locale}.json`, 3);
121
+ const { default: data } = await __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./translations/en.json": () => import("../_chunks/en-BPx_Feq_.mjs") }), `./translations/${locale}.json`, 3);
40
122
  return { data, locale };
41
123
  } catch {
42
124
  return { data: {}, locale };
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":["../../admin/src/pluginId.ts","../../admin/src/components/Initializer.tsx","../../admin/src/index.ts"],"sourcesContent":["export const PLUGIN_ID = 'strapi-cache';\n","import { useEffect, useRef } from 'react';\n\nimport { PLUGIN_ID } from '../pluginId';\n\ntype InitializerProps = {\n setPlugin: (id: string) => void;\n};\n\nconst Initializer = ({ setPlugin }: InitializerProps) => {\n const ref = useRef(setPlugin);\n\n useEffect(() => {\n ref.current(PLUGIN_ID);\n }, []);\n\n return null;\n};\n\nexport { Initializer };\n","import { PLUGIN_ID } from './pluginId';\nimport { Initializer } from './components/Initializer';\n\nexport default {\n register(app: any) {\n app.registerPlugin({\n id: PLUGIN_ID,\n initializer: Initializer,\n isReady: false,\n name: PLUGIN_ID,\n });\n },\n\n async registerTrads({ locales }: { locales: string[] }) {\n return Promise.all(\n locales.map(async (locale) => {\n try {\n const { default: data } = await import(`./translations/${locale}.json`);\n\n return { data, locale };\n } catch {\n return { data: {}, locale };\n }\n })\n );\n },\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAO,MAAM,YAAY;ACQzB,MAAM,cAAc,CAAC,EAAE,gBAAkC;AACjD,QAAA,MAAM,OAAO,SAAS;AAE5B,YAAU,MAAM;AACd,QAAI,QAAQ,SAAS;AAAA,EACvB,GAAG,EAAE;AAEE,SAAA;AACT;ACbA,MAAe,QAAA;AAAA,EACb,SAAS,KAAU;AACjB,QAAI,eAAe;AAAA,MACjB,IAAI;AAAA,MACJ,aAAa;AAAA,MACb,SAAS;AAAA,MACT,MAAM;AAAA,IAAA,CACP;AAAA,EACH;AAAA,EAEA,MAAM,cAAc,EAAE,WAAkC;AACtD,WAAO,QAAQ;AAAA,MACb,QAAQ,IAAI,OAAO,WAAW;AACxB,YAAA;AACF,gBAAM,EAAE,SAAS,SAAS,MAAM,qCAAA,uBAAA,OAAA,EAAA,0BAAA,MAAA,OAAA,4BAAA,EAAA,CAAA,GAAA,kBAAA,MAAA,SAAA,CAAA;AAEzB,iBAAA,EAAE,MAAM,OAAO;AAAA,QAAA,QAChB;AACN,iBAAO,EAAE,MAAM,CAAC,GAAG,OAAO;AAAA,QAAA;AAAA,MAE7B,CAAA;AAAA,IACH;AAAA,EAAA;AAEJ;"}
1
+ {"version":3,"file":"index.mjs","sources":["../../admin/src/pluginId.ts","../../admin/src/components/Initializer.tsx","../../admin/src/permission.ts","../../admin/src/components/PurgeCacheButton/index.tsx","../../admin/src/index.ts"],"sourcesContent":["export const PLUGIN_ID = 'strapi-cache';\n","import { useEffect, useRef } from 'react';\n\nimport { PLUGIN_ID } from '../pluginId';\n\ntype InitializerProps = {\n setPlugin: (id: string) => void;\n};\n\nconst Initializer = ({ setPlugin }: InitializerProps) => {\n const ref = useRef(setPlugin);\n\n useEffect(() => {\n ref.current(PLUGIN_ID);\n }, []);\n\n return null;\n};\n\nexport { Initializer };\n","export const pluginPermissions = {\n purge: [{ action: 'plugin::strapi-cache.purge-cache', subject: null }],\n};\n","import { useIntl } from 'react-intl';\nimport { Archive } from '@strapi/icons';\nimport { Button, Modal } from '@strapi/design-system';\nimport { useRBAC } from '@strapi/strapi/admin';\nimport { pluginPermissions } from '../../permission';\nimport { Typography } from '@strapi/design-system';\nimport { useFetchClient } from '@strapi/strapi/admin';\nimport { unstable_useContentManagerContext as useContentManagerContext } from '@strapi/strapi/admin';\nimport { useNotification } from '@strapi/strapi/admin';\n\nfunction PurgeCacheButton() {\n const { allowedActions } = useRBAC(pluginPermissions);\n const formatMessage = useIntl().formatMessage;\n const { post } = useFetchClient();\n const { toggleNotification } = useNotification();\n const { contentType } = useContentManagerContext();\n const pluralName = contentType?.info.pluralName;\n\n const clearCache = () => {\n if (!pluralName) {\n toggleNotification({\n type: 'warning',\n message: formatMessage({\n id: 'strapi-cache.cache.purge.no-content-type',\n defaultMessage: 'No content type found',\n }),\n });\n return;\n }\n\n post(`/strapi-cache/purge-cache/${pluralName}`, undefined, {\n headers: {\n 'Content-Type': 'application/json',\n },\n })\n .then(() => {\n toggleNotification({\n type: 'success',\n message:\n formatMessage({\n id: 'strapi-cache.cache.purge.success',\n defaultMessage: 'Cache purged successfully',\n }) + `: ${pluralName}`,\n });\n })\n .catch(() => {\n toggleNotification({\n type: 'danger',\n message:\n formatMessage({\n id: 'strapi-cache.cache.purge.error',\n defaultMessage: 'Error purging cache',\n }) + `: ${pluralName}`,\n });\n });\n };\n\n if (!allowedActions.canPurgeCache) {\n return null;\n }\n\n return (\n <>\n <Modal.Root>\n <Modal.Trigger>\n <Button startIcon={<Archive />} variant=\"danger\">\n {formatMessage({\n id: 'strapi-cache.cache.purge',\n defaultMessage: 'Purge Cache',\n })}\n </Button>\n </Modal.Trigger>\n <Modal.Content>\n <Modal.Header>\n <Modal.Title>\n {formatMessage({\n id: 'strapi-cache.cache.purge',\n defaultMessage: 'Purge Cache',\n })}\n </Modal.Title>\n </Modal.Header>\n <Modal.Body>\n <Typography variant=\"omega\">\n {formatMessage({\n id: 'strapi-cache.cache.purge.confirmation',\n defaultMessage: 'Are you sure you want to purge the cache?',\n })}\n </Typography>\n </Modal.Body>\n <Modal.Footer>\n <Modal.Close>\n <Button variant=\"tertiary\">\n {formatMessage({\n id: 'strapi-cache.cache.cancel',\n defaultMessage: 'No, cancel',\n })}\n </Button>\n </Modal.Close>\n <Modal.Close>\n <Button onClick={clearCache}>\n {formatMessage({\n id: 'strapi-cache.cache.confirm',\n defaultMessage: 'Yes, confirm',\n })}\n </Button>\n </Modal.Close>\n </Modal.Footer>\n </Modal.Content>\n </Modal.Root>\n </>\n );\n}\n\nexport default PurgeCacheButton;\n","import { PLUGIN_ID } from './pluginId';\nimport { Initializer } from './components/Initializer';\nimport PurgeCacheButton from './components/PurgeCacheButton';\n\nexport default {\n register(app: any) {\n app.registerPlugin({\n id: PLUGIN_ID,\n initializer: Initializer,\n isReady: false,\n name: PLUGIN_ID,\n });\n\n app.getPlugin('content-manager').injectComponent('listView', 'actions', {\n name: PurgeCacheButton,\n Component: PurgeCacheButton,\n });\n },\n\n async registerTrads({ locales }: { locales: string[] }) {\n return Promise.all(\n locales.map(async (locale) => {\n try {\n const { default: data } = await import(`./translations/${locale}.json`);\n\n return { data, locale };\n } catch {\n return { data: {}, locale };\n }\n })\n );\n },\n};\n"],"names":["useContentManagerContext"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAO,MAAM,YAAY;ACQzB,MAAM,cAAc,CAAC,EAAE,gBAAkC;AACjD,QAAA,MAAM,OAAO,SAAS;AAE5B,YAAU,MAAM;AACd,QAAI,QAAQ,SAAS;AAAA,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,OAAO,WAAW;AACxB,YAAA;AACF,gBAAM,EAAE,SAAS,SAAS,MAAM,qCAAA,uBAAA,OAAA,EAAA,0BAAA,MAAA,OAAA,4BAAA,EAAA,CAAA,GAAA,kBAAA,MAAA,SAAA,CAAA;AAEzB,iBAAA,EAAE,MAAM,OAAO;AAAA,QAAA,QAChB;AACN,iBAAO,EAAE,MAAM,CAAC,GAAG,OAAO;AAAA,QAAA;AAAA,MAE7B,CAAA;AAAA,IACH;AAAA,EAAA;AAEJ;"}
@@ -0,0 +1,2 @@
1
+ declare function PurgeCacheButton(): import("react/jsx-runtime").JSX.Element | null;
2
+ export default PurgeCacheButton;
@@ -0,0 +1,6 @@
1
+ export declare const pluginPermissions: {
2
+ purge: {
3
+ action: string;
4
+ subject: null;
5
+ }[];
6
+ };