strapi-cache 1.2.1 → 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 (46) hide show
  1. package/README.md +61 -16
  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 +275 -167
  29. package/dist/server/index.js.map +1 -1
  30. package/dist/server/index.mjs +274 -167
  31. package/dist/server/index.mjs.map +1 -1
  32. package/dist/server/src/config/index.d.ts +3 -1
  33. package/dist/server/src/controllers/controller.d.ts +2 -1
  34. package/dist/server/src/controllers/index.d.ts +2 -1
  35. package/dist/server/src/index.d.ts +14 -13
  36. package/dist/server/src/permissions.d.ts +6 -0
  37. package/dist/server/src/routes/index.d.ts +7 -2
  38. package/dist/server/src/routes/purge.d.ts +14 -0
  39. package/dist/server/src/services/index.d.ts +4 -2
  40. package/dist/server/src/services/memory/provider.d.ts +16 -0
  41. package/dist/server/src/services/memory/service.d.ts +6 -0
  42. package/dist/server/src/services/redis/provider.d.ts +16 -0
  43. package/dist/server/src/services/redis/service.d.ts +6 -0
  44. package/dist/server/src/services/resolver.d.ts +3 -0
  45. package/dist/server/src/types/cache.types.d.ts +1 -1
  46. package/package.json +4 -3
@@ -7,7 +7,9 @@ declare const _default: {
7
7
  ttl: number;
8
8
  size: number;
9
9
  allowStale: boolean;
10
- contentTypes: any[];
10
+ cacheableRoutes: any[];
11
+ provider: string;
12
+ redisUrl: any;
11
13
  };
12
14
  validator: (config: any) => void;
13
15
  };
@@ -3,6 +3,7 @@ import { Context } from 'koa';
3
3
  declare const controller: ({ strapi }: {
4
4
  strapi: Core.Strapi;
5
5
  }) => {
6
- index(ctx: Context): void;
6
+ purgeCache(ctx: Context): Promise<void>;
7
+ purgeCacheByKey(ctx: Context): Promise<void>;
7
8
  };
8
9
  export default controller;
@@ -3,7 +3,8 @@ declare const _default: {
3
3
  controller: ({ strapi }: {
4
4
  strapi: import("@strapi/types/dist/core").Strapi;
5
5
  }) => {
6
- index(ctx: import("koa").Context): void;
6
+ purgeCache(ctx: import("koa").Context): Promise<void>;
7
+ purgeCacheByKey(ctx: import("koa").Context): Promise<void>;
7
8
  };
8
9
  };
9
10
  export default _default;
@@ -1,16 +1,12 @@
1
1
  /// <reference types="koa" />
2
2
  declare const _default: {
3
3
  register: ({ strapi }: {
4
- strapi: import("@strapi/types/dist/core").Strapi; /**
5
- * Plugin server methods
6
- */
7
- }) => void;
8
- bootstrap: ({ strapi }: {
9
4
  strapi: import("@strapi/types/dist/core").Strapi;
10
5
  }) => void;
11
- destroy: ({ strapi }: {
6
+ bootstrap: ({ strapi }: {
12
7
  strapi: import("@strapi/types/dist/core").Strapi;
13
8
  }) => void;
9
+ destroy(): void;
14
10
  config: {
15
11
  default: ({ env }: {
16
12
  env: any;
@@ -20,7 +16,9 @@ declare const _default: {
20
16
  ttl: number;
21
17
  size: number;
22
18
  allowStale: boolean;
23
- contentTypes: any[];
19
+ cacheableRoutes: any[];
20
+ provider: string;
21
+ redisUrl: any;
24
22
  };
25
23
  validator: (config: any) => void;
26
24
  };
@@ -28,21 +26,24 @@ declare const _default: {
28
26
  controller: ({ strapi }: {
29
27
  strapi: import("@strapi/types/dist/core").Strapi;
30
28
  }) => {
31
- index(ctx: import("koa").Context): void;
29
+ purgeCache(ctx: import("koa").Context): Promise<void>;
30
+ purgeCacheByKey(ctx: import("koa").Context): Promise<void>;
32
31
  };
33
32
  };
34
33
  routes: {
35
- 'content-api': {
34
+ 'purge-route': {
36
35
  type: string;
37
36
  routes: {
38
37
  method: string;
39
38
  path: string;
40
39
  handler: string;
41
- /**
42
- * Plugin server methods
43
- */
44
40
  config: {
45
- policies: any[];
41
+ policies: (string | {
42
+ name: string;
43
+ config: {
44
+ actions: string[];
45
+ };
46
+ })[];
46
47
  };
47
48
  }[];
48
49
  };
@@ -0,0 +1,6 @@
1
+ export declare const actions: {
2
+ section: string;
3
+ displayName: string;
4
+ uid: string;
5
+ pluginName: string;
6
+ }[];
@@ -1,12 +1,17 @@
1
1
  declare const routes: {
2
- 'content-api': {
2
+ 'purge-route': {
3
3
  type: string;
4
4
  routes: {
5
5
  method: string;
6
6
  path: string;
7
7
  handler: string;
8
8
  config: {
9
- policies: any[];
9
+ policies: (string | {
10
+ name: string;
11
+ config: {
12
+ actions: string[];
13
+ };
14
+ })[];
10
15
  };
11
16
  }[];
12
17
  };
@@ -0,0 +1,14 @@
1
+ declare const _default: {
2
+ method: string;
3
+ path: string;
4
+ handler: string;
5
+ config: {
6
+ policies: (string | {
7
+ name: string;
8
+ config: {
9
+ actions: string[];
10
+ };
11
+ })[];
12
+ };
13
+ }[];
14
+ export default _default;
@@ -1,6 +1,8 @@
1
+ import type { Core } from '@strapi/strapi';
2
+ import { CacheService } from '../../src/types/cache.types';
1
3
  declare const _default: {
2
4
  service: ({ strapi }: {
3
- strapi: import("@strapi/types/dist/core").Strapi;
4
- }) => import("../types/cache.types").CacheService;
5
+ strapi: Core.Strapi;
6
+ }) => CacheService;
5
7
  };
6
8
  export default _default;
@@ -0,0 +1,16 @@
1
+ import type { Core } from '@strapi/strapi';
2
+ import { CacheProvider } from '../../types/cache.types';
3
+ export declare class InMemoryCacheProvider implements CacheProvider {
4
+ private strapi;
5
+ private initialized;
6
+ private provider;
7
+ constructor(strapi: Core.Strapi);
8
+ init(): void;
9
+ get ready(): boolean;
10
+ get(key: string): Promise<any | null>;
11
+ set(key: string, val: any): Promise<any | null>;
12
+ del(key: string): Promise<any | null>;
13
+ keys(): Promise<string[] | null>;
14
+ reset(): Promise<any | null>;
15
+ clearByRegexp(regExps: RegExp[]): Promise<void>;
16
+ }
@@ -0,0 +1,6 @@
1
+ import type { Core } from '@strapi/strapi';
2
+ import type { CacheService } from '../../types/cache.types';
3
+ declare const service: ({ strapi }: {
4
+ strapi: Core.Strapi;
5
+ }) => CacheService;
6
+ export default service;
@@ -0,0 +1,16 @@
1
+ import type { Core } from '@strapi/strapi';
2
+ import { CacheProvider } from '../../types/cache.types';
3
+ export declare class RedisCacheProvider implements CacheProvider {
4
+ private strapi;
5
+ private initialized;
6
+ private client;
7
+ constructor(strapi: Core.Strapi);
8
+ init(): void;
9
+ get ready(): boolean;
10
+ get(key: string): Promise<any | null>;
11
+ set(key: string, val: any): Promise<any | null>;
12
+ del(key: string): Promise<any | null>;
13
+ keys(): Promise<string[] | null>;
14
+ reset(): Promise<any | null>;
15
+ clearByRegexp(regExps: RegExp[]): Promise<void>;
16
+ }
@@ -0,0 +1,6 @@
1
+ import type { Core } from '@strapi/strapi';
2
+ import type { CacheService } from '../../types/cache.types';
3
+ declare const service: ({ strapi }: {
4
+ strapi: Core.Strapi;
5
+ }) => CacheService;
6
+ export default service;
@@ -0,0 +1,3 @@
1
+ import type { Core } from '@strapi/strapi';
2
+ import { CacheProvider } from '../../src/types/cache.types';
3
+ export declare const resolveCacheProvider: (strapi: Core.Strapi) => CacheProvider;
@@ -10,7 +10,7 @@ export interface CacheProvider {
10
10
  clearByRegexp(regExps: RegExp[]): Promise<void>;
11
11
  }
12
12
  export interface CacheService {
13
- createCache(): CacheProvider;
13
+ getCacheInstance(): CacheProvider;
14
14
  }
15
15
  export interface CacheInstance {
16
16
  initialized: boolean;
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.2.1",
2
+ "version": "1.4.0",
3
3
  "keywords": [
4
4
  "strapi cache",
5
5
  "strapi rest cache",
@@ -37,8 +37,9 @@
37
37
  "test": "vitest"
38
38
  },
39
39
  "dependencies": {
40
- "@strapi/design-system": "^2.0.0-rc.21",
41
- "@strapi/icons": "^2.0.0-rc.21",
40
+ "@strapi/design-system": "^2.0.0-rc.23",
41
+ "@strapi/icons": "^2.0.0-rc.23",
42
+ "ioredis": "^5.6.1",
42
43
  "lru-cache": "^11.1.0",
43
44
  "raw-body": "^3.0.0",
44
45
  "react-intl": "^7.1.10"