mcp-wordpress 1.2.2 → 1.3.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 (251) hide show
  1. package/README.md +210 -182
  2. package/dist/cache/CacheInvalidation.d.ts +3 -3
  3. package/dist/cache/CacheInvalidation.d.ts.map +1 -1
  4. package/dist/cache/CacheInvalidation.js +119 -119
  5. package/dist/cache/CacheInvalidation.js.map +1 -1
  6. package/dist/cache/CacheManager.d.ts +5 -0
  7. package/dist/cache/CacheManager.d.ts.map +1 -1
  8. package/dist/cache/CacheManager.js +26 -16
  9. package/dist/cache/CacheManager.js.map +1 -1
  10. package/dist/cache/HttpCacheWrapper.d.ts +1 -1
  11. package/dist/cache/HttpCacheWrapper.d.ts.map +1 -1
  12. package/dist/cache/HttpCacheWrapper.js +29 -29
  13. package/dist/cache/HttpCacheWrapper.js.map +1 -1
  14. package/dist/cache/__tests__/CacheInvalidation.test.js +96 -94
  15. package/dist/cache/__tests__/CacheInvalidation.test.js.map +1 -1
  16. package/dist/cache/__tests__/CacheManager.test.js +113 -113
  17. package/dist/cache/__tests__/CacheManager.test.js.map +1 -1
  18. package/dist/cache/__tests__/CachedWordPressClient.test.js +102 -99
  19. package/dist/cache/__tests__/CachedWordPressClient.test.js.map +1 -1
  20. package/dist/cache/__tests__/HttpCacheWrapper.test.js +98 -95
  21. package/dist/cache/__tests__/HttpCacheWrapper.test.js.map +1 -1
  22. package/dist/cache/index.d.ts +7 -7
  23. package/dist/cache/index.d.ts.map +1 -1
  24. package/dist/cache/index.js +4 -4
  25. package/dist/cache/index.js.map +1 -1
  26. package/dist/client/CachedWordPressClient.d.ts +4 -4
  27. package/dist/client/CachedWordPressClient.d.ts.map +1 -1
  28. package/dist/client/CachedWordPressClient.js +55 -51
  29. package/dist/client/CachedWordPressClient.js.map +1 -1
  30. package/dist/client/api.d.ts +10 -10
  31. package/dist/client/api.js +158 -158
  32. package/dist/client/api.js.map +1 -1
  33. package/dist/client/auth.d.ts +2 -2
  34. package/dist/client/auth.js +72 -72
  35. package/dist/client/managers/AuthenticationManager.d.ts +2 -2
  36. package/dist/client/managers/AuthenticationManager.js +46 -46
  37. package/dist/client/managers/BaseManager.d.ts +1 -1
  38. package/dist/client/managers/BaseManager.js +9 -9
  39. package/dist/client/managers/RequestManager.d.ts +5 -3
  40. package/dist/client/managers/RequestManager.d.ts.map +1 -1
  41. package/dist/client/managers/RequestManager.js +39 -19
  42. package/dist/client/managers/RequestManager.js.map +1 -1
  43. package/dist/client/managers/index.d.ts +3 -3
  44. package/dist/client/managers/index.js +3 -3
  45. package/dist/config/ConfigurationSchema.d.ts +2 -2
  46. package/dist/config/ConfigurationSchema.d.ts.map +1 -1
  47. package/dist/config/ConfigurationSchema.js +40 -40
  48. package/dist/config/ConfigurationSchema.js.map +1 -1
  49. package/dist/config/ServerConfiguration.d.ts +2 -2
  50. package/dist/config/ServerConfiguration.js +35 -35
  51. package/dist/config/ServerConfiguration.js.map +1 -1
  52. package/dist/docs/DocumentationGenerator.d.ts.map +1 -1
  53. package/dist/docs/DocumentationGenerator.js +296 -255
  54. package/dist/docs/DocumentationGenerator.js.map +1 -1
  55. package/dist/docs/MarkdownFormatter.d.ts +1 -1
  56. package/dist/docs/MarkdownFormatter.d.ts.map +1 -1
  57. package/dist/docs/MarkdownFormatter.js +60 -51
  58. package/dist/docs/MarkdownFormatter.js.map +1 -1
  59. package/dist/docs/index.d.ts +3 -3
  60. package/dist/docs/index.d.ts.map +1 -1
  61. package/dist/docs/index.js +2 -2
  62. package/dist/index.d.ts.map +1 -1
  63. package/dist/index.js +16 -16
  64. package/dist/index.js.map +1 -1
  65. package/dist/mcp-wordpress-1.3.0.tgz +0 -0
  66. package/dist/performance/MetricsCollector.d.ts +3 -3
  67. package/dist/performance/MetricsCollector.d.ts.map +1 -1
  68. package/dist/performance/MetricsCollector.js +33 -27
  69. package/dist/performance/MetricsCollector.js.map +1 -1
  70. package/dist/performance/PerformanceAnalytics.d.ts +12 -12
  71. package/dist/performance/PerformanceAnalytics.d.ts.map +1 -1
  72. package/dist/performance/PerformanceAnalytics.js +200 -154
  73. package/dist/performance/PerformanceAnalytics.js.map +1 -1
  74. package/dist/performance/PerformanceMonitor.d.ts +5 -5
  75. package/dist/performance/PerformanceMonitor.d.ts.map +1 -1
  76. package/dist/performance/PerformanceMonitor.js +53 -52
  77. package/dist/performance/PerformanceMonitor.js.map +1 -1
  78. package/dist/performance/index.d.ts +6 -6
  79. package/dist/performance/index.d.ts.map +1 -1
  80. package/dist/performance/index.js +3 -3
  81. package/dist/security/InputValidator.d.ts +1 -1
  82. package/dist/security/InputValidator.d.ts.map +1 -1
  83. package/dist/security/InputValidator.js +111 -88
  84. package/dist/security/InputValidator.js.map +1 -1
  85. package/dist/security/SecurityConfig.d.ts +5 -5
  86. package/dist/security/SecurityConfig.js +92 -92
  87. package/dist/security/SecurityConfig.js.map +1 -1
  88. package/dist/server/ConnectionTester.d.ts +1 -1
  89. package/dist/server/ConnectionTester.d.ts.map +1 -1
  90. package/dist/server/ConnectionTester.js +4 -4
  91. package/dist/server/ConnectionTester.js.map +1 -1
  92. package/dist/server/ToolRegistry.d.ts +2 -2
  93. package/dist/server/ToolRegistry.d.ts.map +1 -1
  94. package/dist/server/ToolRegistry.js +35 -32
  95. package/dist/server/ToolRegistry.js.map +1 -1
  96. package/dist/server.d.ts +2 -2
  97. package/dist/server.js +2 -2
  98. package/dist/tools/BaseToolManager.js +5 -5
  99. package/dist/tools/auth.d.ts +2 -2
  100. package/dist/tools/auth.d.ts.map +1 -1
  101. package/dist/tools/auth.js +32 -31
  102. package/dist/tools/auth.js.map +1 -1
  103. package/dist/tools/cache.d.ts +1 -1
  104. package/dist/tools/cache.d.ts.map +1 -1
  105. package/dist/tools/cache.js +71 -71
  106. package/dist/tools/cache.js.map +1 -1
  107. package/dist/tools/comments.d.ts +2 -2
  108. package/dist/tools/comments.d.ts.map +1 -1
  109. package/dist/tools/comments.js +79 -79
  110. package/dist/tools/comments.js.map +1 -1
  111. package/dist/tools/index.d.ts +10 -10
  112. package/dist/tools/index.js +10 -10
  113. package/dist/tools/media.d.ts +2 -2
  114. package/dist/tools/media.js +80 -80
  115. package/dist/tools/pages.d.ts +2 -2
  116. package/dist/tools/pages.d.ts.map +1 -1
  117. package/dist/tools/pages.js +75 -75
  118. package/dist/tools/pages.js.map +1 -1
  119. package/dist/tools/performance.d.ts +1 -1
  120. package/dist/tools/performance.d.ts.map +1 -1
  121. package/dist/tools/performance.js +311 -287
  122. package/dist/tools/performance.js.map +1 -1
  123. package/dist/tools/posts.d.ts +2 -2
  124. package/dist/tools/posts.d.ts.map +1 -1
  125. package/dist/tools/posts.js +94 -94
  126. package/dist/tools/posts.js.map +1 -1
  127. package/dist/tools/site.d.ts +2 -2
  128. package/dist/tools/site.d.ts.map +1 -1
  129. package/dist/tools/site.js +60 -60
  130. package/dist/tools/site.js.map +1 -1
  131. package/dist/tools/taxonomies.d.ts +2 -2
  132. package/dist/tools/taxonomies.js +89 -89
  133. package/dist/tools/users.d.ts +2 -2
  134. package/dist/tools/users.js +68 -68
  135. package/dist/tools/users.js.map +1 -1
  136. package/dist/types/client.d.ts +13 -13
  137. package/dist/types/client.d.ts.map +1 -1
  138. package/dist/types/client.js +12 -12
  139. package/dist/types/client.js.map +1 -1
  140. package/dist/types/index.d.ts +19 -19
  141. package/dist/types/index.d.ts.map +1 -1
  142. package/dist/types/index.js +3 -3
  143. package/dist/types/mcp.d.ts +7 -7
  144. package/dist/types/wordpress.d.ts +21 -21
  145. package/dist/types/wordpress.d.ts.map +1 -1
  146. package/dist/utils/debug.d.ts +2 -2
  147. package/dist/utils/debug.js +28 -28
  148. package/dist/utils/error.d.ts.map +1 -1
  149. package/dist/utils/error.js +13 -13
  150. package/dist/utils/error.js.map +1 -1
  151. package/dist/utils/toolWrapper.d.ts.map +1 -1
  152. package/dist/utils/toolWrapper.js +5 -5
  153. package/dist/utils/toolWrapper.js.map +1 -1
  154. package/dist/utils/validation.d.ts.map +1 -1
  155. package/dist/utils/validation.js +41 -31
  156. package/dist/utils/validation.js.map +1 -1
  157. package/docs/CACHING.md +36 -2
  158. package/docs/DOCKER.md +24 -18
  159. package/docs/PERFORMANCE_MONITORING.md +49 -1
  160. package/docs/SECURITY_TESTING.md +30 -1
  161. package/docs/api/README.md +9 -1
  162. package/docs/api/summary.json +1 -1
  163. package/docs/contract-testing.md +24 -3
  164. package/docs/developer/GITHUB_ACTIONS_SETUP.md +8 -2
  165. package/docs/developer/MAINTENANCE.md +29 -3
  166. package/docs/developer/MIGRATION_GUIDE.md +13 -1
  167. package/docs/developer/NPM_AUTH_SETUP.md +13 -2
  168. package/docs/developer/REFACTORING.md +31 -1
  169. package/docs/releases/COMMUNITY_ANNOUNCEMENT_v1.1.2.md +18 -7
  170. package/docs/releases/RELEASE_NOTES_v1.1.2.md +31 -5
  171. package/docs/user-guides/DOCKER_SETUP.md +264 -0
  172. package/docs/user-guides/DTX_SETUP.md +327 -0
  173. package/docs/user-guides/NPM_SETUP.md +109 -0
  174. package/docs/user-guides/NPX_SETUP.md +281 -0
  175. package/docs/wordpress-rest-api-authentication-troubleshooting.md +13 -2
  176. package/package.json +27 -8
  177. package/src/cache/CacheInvalidation.ts +140 -132
  178. package/src/cache/CacheManager.ts +40 -29
  179. package/src/cache/HttpCacheWrapper.ts +105 -68
  180. package/src/cache/__tests__/CacheInvalidation.test.ts +123 -118
  181. package/src/cache/__tests__/CacheManager.test.ts +156 -152
  182. package/src/cache/__tests__/CachedWordPressClient.test.ts +131 -116
  183. package/src/cache/__tests__/HttpCacheWrapper.test.ts +118 -115
  184. package/src/cache/index.ts +13 -13
  185. package/src/client/CachedWordPressClient.ts +90 -80
  186. package/src/client/api.ts +205 -205
  187. package/src/client/auth.ts +80 -80
  188. package/src/client/managers/AuthenticationManager.ts +61 -61
  189. package/src/client/managers/BaseManager.ts +11 -11
  190. package/src/client/managers/RequestManager.ts +79 -47
  191. package/src/client/managers/index.ts +3 -3
  192. package/src/config/ConfigurationSchema.ts +44 -44
  193. package/src/config/ServerConfiguration.ts +39 -39
  194. package/src/docs/DocumentationGenerator.ts +402 -295
  195. package/src/docs/MarkdownFormatter.ts +94 -69
  196. package/src/docs/index.ts +4 -4
  197. package/src/index.ts +24 -21
  198. package/src/performance/MetricsCollector.ts +90 -58
  199. package/src/performance/PerformanceAnalytics.ts +386 -262
  200. package/src/performance/PerformanceMonitor.ts +152 -118
  201. package/src/performance/index.ts +9 -9
  202. package/src/security/InputValidator.ts +148 -91
  203. package/src/security/SecurityConfig.ts +94 -94
  204. package/src/server/ConnectionTester.ts +21 -15
  205. package/src/server/ToolRegistry.ts +64 -51
  206. package/src/server.ts +2 -2
  207. package/src/tools/BaseToolManager.ts +6 -6
  208. package/src/tools/auth.ts +42 -37
  209. package/src/tools/cache.ts +85 -81
  210. package/src/tools/comments.ts +93 -91
  211. package/src/tools/index.ts +10 -10
  212. package/src/tools/media.ts +89 -89
  213. package/src/tools/pages.ts +89 -87
  214. package/src/tools/performance.ts +443 -352
  215. package/src/tools/posts.ts +109 -107
  216. package/src/tools/site.ts +86 -77
  217. package/src/tools/taxonomies.ts +102 -102
  218. package/src/tools/users.ts +77 -77
  219. package/src/types/client.ts +157 -60
  220. package/src/types/index.ts +49 -27
  221. package/src/types/mcp.ts +15 -15
  222. package/src/types/wordpress.ts +57 -29
  223. package/src/utils/debug.ts +37 -37
  224. package/src/utils/error.ts +47 -25
  225. package/src/utils/toolWrapper.ts +12 -8
  226. package/src/utils/validation.ts +116 -65
  227. package/dist/client/WordPressClient.d.ts +0 -81
  228. package/dist/client/WordPressClient.d.ts.map +0 -1
  229. package/dist/client/WordPressClient.js +0 -354
  230. package/dist/client/WordPressClient.js.map +0 -1
  231. package/dist/performance/AnomalyDetector.d.ts +0 -63
  232. package/dist/performance/AnomalyDetector.d.ts.map +0 -1
  233. package/dist/performance/AnomalyDetector.js +0 -222
  234. package/dist/performance/AnomalyDetector.js.map +0 -1
  235. package/dist/performance/BenchmarkAnalyzer.d.ts +0 -67
  236. package/dist/performance/BenchmarkAnalyzer.d.ts.map +0 -1
  237. package/dist/performance/BenchmarkAnalyzer.js +0 -301
  238. package/dist/performance/BenchmarkAnalyzer.js.map +0 -1
  239. package/dist/performance/TrendAnalyzer.d.ts +0 -69
  240. package/dist/performance/TrendAnalyzer.d.ts.map +0 -1
  241. package/dist/performance/TrendAnalyzer.js +0 -203
  242. package/dist/performance/TrendAnalyzer.js.map +0 -1
  243. package/dist/tools/BaseToolClass.d.ts +0 -76
  244. package/dist/tools/BaseToolClass.d.ts.map +0 -1
  245. package/dist/tools/BaseToolClass.js +0 -104
  246. package/dist/tools/BaseToolClass.js.map +0 -1
  247. package/dist/tools/base.d.ts +0 -37
  248. package/dist/tools/base.d.ts.map +0 -1
  249. package/dist/tools/base.js +0 -60
  250. package/dist/tools/base.js.map +0 -1
  251. package/docs/user-guides/CLAUDE_DESKTOP_SETUP.md +0 -187
@@ -2,15 +2,15 @@
2
2
  * Tests for CachedWordPressClient
3
3
  */
4
4
 
5
- import { CachedWordPressClient } from '../index.js';
6
- import type { WordPressClientConfig } from '../../types/client.js';
5
+ import { CachedWordPressClient } from "../index.js";
6
+ import type { WordPressClientConfig } from "../../types/client.js";
7
7
 
8
8
  // Mock the base WordPress client
9
- jest.mock('../../client/api.js', () => {
9
+ jest.mock("../../client/api.js", () => {
10
10
  return {
11
11
  WordPressClient: jest.fn().mockImplementation(() => ({
12
- baseUrl: 'https://example.com',
13
- auth: { method: 'app-password', username: 'test', appPassword: 'test' },
12
+ baseUrl: "https://example.com",
13
+ auth: { method: "app-password", username: "test", appPassword: "test" },
14
14
  jwtToken: null,
15
15
  request: jest.fn(),
16
16
  getPosts: jest.fn(),
@@ -21,26 +21,26 @@ jest.mock('../../client/api.js', () => {
21
21
  getCurrentUser: jest.fn(),
22
22
  getCategories: jest.fn(),
23
23
  getTags: jest.fn(),
24
- getSiteSettings: jest.fn()
25
- }))
24
+ getSiteSettings: jest.fn(),
25
+ })),
26
26
  };
27
27
  });
28
28
 
29
- describe('CachedWordPressClient', () => {
29
+ describe("CachedWordPressClient", () => {
30
30
  let client: CachedWordPressClient;
31
31
  let config: WordPressClientConfig;
32
32
 
33
33
  beforeEach(() => {
34
34
  config = {
35
- baseUrl: 'https://example.com',
35
+ baseUrl: "https://example.com",
36
36
  auth: {
37
- method: 'app-password',
38
- username: 'test',
39
- appPassword: 'test-password'
40
- }
37
+ method: "app-password",
38
+ username: "test",
39
+ appPassword: "test-password",
40
+ },
41
41
  };
42
42
 
43
- client = new CachedWordPressClient(config, 'test-site');
43
+ client = new CachedWordPressClient(config, "test-site");
44
44
  });
45
45
 
46
46
  afterEach(() => {
@@ -48,29 +48,30 @@ describe('CachedWordPressClient', () => {
48
48
  jest.clearAllMocks();
49
49
  });
50
50
 
51
- describe('Initialization', () => {
52
- test('should initialize with caching system', () => {
51
+ describe("Initialization", () => {
52
+ test("should initialize with caching system", () => {
53
53
  expect(client).toBeDefined();
54
- expect(client['cacheManager']).toBeDefined();
55
- expect(client['httpCache']).toBeDefined();
56
- expect(client['cacheInvalidation']).toBeDefined();
54
+ expect(client["cacheManager"]).toBeDefined();
55
+ expect(client["httpCache"]).toBeDefined();
56
+ expect(client["cacheInvalidation"]).toBeDefined();
57
57
  });
58
58
 
59
- test('should use provided site ID', () => {
60
- const customClient = new CachedWordPressClient(config, 'custom-site');
61
- expect(customClient['siteId']).toBe('custom-site');
59
+ test("should use provided site ID", () => {
60
+ const customClient = new CachedWordPressClient(config, "custom-site");
61
+ expect(customClient["siteId"]).toBe("custom-site");
62
62
  });
63
63
 
64
- test('should default to "default" site ID', () => {
64
+ test("should default to \"default\" site ID", () => {
65
65
  const defaultClient = new CachedWordPressClient(config);
66
- expect(defaultClient['siteId']).toBe('default');
66
+ expect(defaultClient["siteId"]).toBe("default");
67
67
  });
68
68
  });
69
69
 
70
- describe('GET Request Caching', () => {
71
- test('should cache GET requests', async () => {
72
- const mockResponse = [{ id: 1, title: 'Test Post' }];
73
- (client as any).request = jest.fn()
70
+ describe("GET Request Caching", () => {
71
+ test("should cache GET requests", async () => {
72
+ const mockResponse = [{ id: 1, title: "Test Post" }];
73
+ (client as any).request = jest
74
+ .fn()
74
75
  .mockImplementationOnce(async () => mockResponse)
75
76
  .mockImplementationOnce(async () => mockResponse);
76
77
 
@@ -86,8 +87,8 @@ describe('CachedWordPressClient', () => {
86
87
  expect((client as any).request).toHaveBeenCalledTimes(1);
87
88
  });
88
89
 
89
- test('should cache individual post requests', async () => {
90
- const mockPost = { id: 1, title: 'Test Post' };
90
+ test("should cache individual post requests", async () => {
91
+ const mockPost = { id: 1, title: "Test Post" };
91
92
  (client as any).request = jest.fn().mockResolvedValue(mockPost);
92
93
 
93
94
  const result1 = await client.getPost(1);
@@ -99,117 +100,123 @@ describe('CachedWordPressClient', () => {
99
100
  });
100
101
  });
101
102
 
102
- describe('Write Operations and Cache Invalidation', () => {
103
- test('should invalidate cache on post creation', async () => {
104
- const mockPost = { id: 1, title: 'New Post' };
105
- const mockCreateData = { title: 'New Post', content: 'Content' };
106
-
103
+ describe("Write Operations and Cache Invalidation", () => {
104
+ test("should invalidate cache on post creation", async () => {
105
+ const mockPost = { id: 1, title: "New Post" };
106
+ const mockCreateData = { title: "New Post", content: "Content" };
107
+
107
108
  // Mock the parent class methods
108
109
  const _originalCreatePost = client.createPost;
109
110
  client.createPost = jest.fn().mockResolvedValue(mockPost);
110
-
111
- const invalidateSpy = jest.spyOn(client['cacheInvalidation'], 'invalidateResource');
111
+
112
+ const invalidateSpy = jest.spyOn(
113
+ client["cacheInvalidation"],
114
+ "invalidateResource",
115
+ );
112
116
 
113
117
  await client.createPost(mockCreateData);
114
118
 
115
- expect(invalidateSpy).toHaveBeenCalledWith('posts', 1, 'create');
119
+ expect(invalidateSpy).toHaveBeenCalledWith("posts", 1, "create");
116
120
  });
117
121
 
118
- test('should invalidate cache on post update', async () => {
119
- const mockPost = { id: 1, title: 'Updated Post' };
120
- const mockUpdateData = { id: 1, title: 'Updated Post' };
121
-
122
+ test("should invalidate cache on post update", async () => {
123
+ const mockPost = { id: 1, title: "Updated Post" };
124
+ const mockUpdateData = { id: 1, title: "Updated Post" };
125
+
122
126
  client.updatePost = jest.fn().mockResolvedValue(mockPost);
123
- const invalidateSpy = jest.spyOn(client['cacheInvalidation'], 'invalidateResource');
127
+ const invalidateSpy = jest.spyOn(
128
+ client["cacheInvalidation"],
129
+ "invalidateResource",
130
+ );
124
131
 
125
132
  await client.updatePost(mockUpdateData);
126
133
 
127
- expect(invalidateSpy).toHaveBeenCalledWith('posts', 1, 'update');
134
+ expect(invalidateSpy).toHaveBeenCalledWith("posts", 1, "update");
128
135
  });
129
136
 
130
- test('should invalidate cache on post deletion', async () => {
137
+ test("should invalidate cache on post deletion", async () => {
131
138
  client.deletePost = jest.fn().mockResolvedValue(undefined);
132
- const invalidateSpy = jest.spyOn(client['cacheInvalidation'], 'invalidateResource');
139
+ const invalidateSpy = jest.spyOn(
140
+ client["cacheInvalidation"],
141
+ "invalidateResource",
142
+ );
133
143
 
134
144
  await client.deletePost(1);
135
145
 
136
- expect(invalidateSpy).toHaveBeenCalledWith('posts', 1, 'delete');
146
+ expect(invalidateSpy).toHaveBeenCalledWith("posts", 1, "delete");
137
147
  });
138
148
  });
139
149
 
140
- describe('Cache Configuration by Endpoint Type', () => {
141
- test('should use static caching for site settings', async () => {
142
- const mockSettings = { title: 'Test Site' };
150
+ describe("Cache Configuration by Endpoint Type", () => {
151
+ test("should use static caching for site settings", async () => {
152
+ const mockSettings = { title: "Test Site" };
143
153
  (client as any).request = jest.fn().mockResolvedValue(mockSettings);
144
154
 
145
155
  await client.getSiteSettings();
146
156
 
147
157
  // Verify request was made with static cache configuration
148
- expect((client as any).request).toHaveBeenCalledWith(
149
- 'GET',
150
- 'settings'
151
- );
158
+ expect((client as any).request).toHaveBeenCalledWith("GET", "settings");
152
159
  });
153
160
 
154
- test('should use semi-static caching for categories', async () => {
155
- const mockCategories = [{ id: 1, name: 'Test Category' }];
161
+ test("should use semi-static caching for categories", async () => {
162
+ const mockCategories = [{ id: 1, name: "Test Category" }];
156
163
  (client as any).request = jest.fn().mockResolvedValue(mockCategories);
157
164
 
158
165
  await client.getCategories();
159
166
 
160
167
  expect((client as any).request).toHaveBeenCalledWith(
161
- 'GET',
162
- 'categories',
168
+ "GET",
169
+ "categories",
163
170
  null,
164
- { params: {} }
171
+ { params: {} },
165
172
  );
166
173
  });
167
174
 
168
- test('should use session caching for current user', async () => {
169
- const mockUser = { id: 1, username: 'testuser' };
175
+ test("should use session caching for current user", async () => {
176
+ const mockUser = { id: 1, username: "testuser" };
170
177
  (client as any).request = jest.fn().mockResolvedValue(mockUser);
171
178
 
172
179
  await client.getCurrentUser();
173
180
 
174
- expect((client as any).request).toHaveBeenCalledWith(
175
- 'GET',
176
- 'users/me'
177
- );
181
+ expect((client as any).request).toHaveBeenCalledWith("GET", "users/me");
178
182
  });
179
183
  });
180
184
 
181
- describe('Cache Management', () => {
182
- test('should clear all cache', () => {
183
- const clearSpy = jest.spyOn(client['httpCache'], 'invalidateAll');
184
-
185
+ describe("Cache Management", () => {
186
+ test("should clear all cache", () => {
187
+ const clearSpy = jest.spyOn(client["httpCache"], "invalidateAll");
188
+
185
189
  const result = client.clearCache();
186
-
190
+
187
191
  expect(clearSpy).toHaveBeenCalled();
188
- expect(typeof result).toBe('number');
192
+ expect(typeof result).toBe("number");
189
193
  });
190
194
 
191
- test('should clear cache by pattern', () => {
192
- const pattern = 'posts.*';
193
- const clearPatternSpy = jest.spyOn(client['httpCache'], 'invalidatePattern');
194
-
195
+ test("should clear cache by pattern", () => {
196
+ const pattern = "posts.*";
197
+ const clearPatternSpy = jest.spyOn(
198
+ client["httpCache"],
199
+ "invalidatePattern",
200
+ );
201
+
195
202
  const result = client.clearCachePattern(pattern);
196
-
203
+
197
204
  expect(clearPatternSpy).toHaveBeenCalledWith(pattern);
198
- expect(typeof result).toBe('number');
205
+ expect(typeof result).toBe("number");
199
206
  });
200
207
 
201
- test('should provide cache statistics', () => {
208
+ test("should provide cache statistics", () => {
202
209
  const stats = client.getCacheStats();
203
-
204
- expect(stats).toHaveProperty('cache');
205
- expect(stats).toHaveProperty('invalidation');
206
- expect(stats.cache).toHaveProperty('hits');
207
- expect(stats.cache).toHaveProperty('misses');
208
- expect(stats.cache).toHaveProperty('totalSize');
209
- expect(stats.invalidation).toHaveProperty('queueSize');
210
+
211
+ expect(stats).toHaveProperty("cache");
212
+ expect(stats).toHaveProperty("invalidation");
213
+ expect(stats.cache).toHaveProperty("hits");
214
+ expect(stats.cache).toHaveProperty("misses");
215
+ expect(stats.cache).toHaveProperty("totalSize");
216
+ expect(stats.invalidation).toHaveProperty("queueSize");
210
217
  });
211
218
 
212
- test('should warm cache with essential data', async () => {
219
+ test("should warm cache with essential data", async () => {
213
220
  // Mock all the methods that warmCache calls
214
221
  client.getCurrentUser = jest.fn().mockResolvedValue({ id: 1 });
215
222
  client.getCategories = jest.fn().mockResolvedValue([]);
@@ -224,23 +231,25 @@ describe('CachedWordPressClient', () => {
224
231
  expect(client.getSiteSettings).toHaveBeenCalled();
225
232
  });
226
233
 
227
- test('should handle cache warming errors gracefully', async () => {
228
- client.getCurrentUser = jest.fn().mockRejectedValue(new Error('Auth failed'));
234
+ test("should handle cache warming errors gracefully", async () => {
235
+ client.getCurrentUser = jest
236
+ .fn()
237
+ .mockRejectedValue(new Error("Auth failed"));
229
238
  client.getCategories = jest.fn().mockResolvedValue([]);
230
239
  client.getTags = jest.fn().mockResolvedValue([]);
231
240
  client.getSiteSettings = jest.fn().mockResolvedValue({});
232
241
 
233
242
  // Should not throw despite getCurrentUser failing
234
243
  await expect(client.warmCache()).resolves.toBeUndefined();
235
-
244
+
236
245
  expect(client.getCategories).toHaveBeenCalled();
237
246
  expect(client.getTags).toHaveBeenCalled();
238
247
  expect(client.getSiteSettings).toHaveBeenCalled();
239
248
  });
240
249
  });
241
250
 
242
- describe('Cache Key Generation', () => {
243
- test('should generate different cache keys for different parameters', async () => {
251
+ describe("Cache Key Generation", () => {
252
+ test("should generate different cache keys for different parameters", async () => {
244
253
  const mockPosts = [{ id: 1 }];
245
254
  (client as any).request = jest.fn().mockResolvedValue(mockPosts);
246
255
 
@@ -252,12 +261,12 @@ describe('CachedWordPressClient', () => {
252
261
  expect((client as any).request).toHaveBeenCalledTimes(2);
253
262
  });
254
263
 
255
- test('should use same cache key for identical parameters', async () => {
264
+ test("should use same cache key for identical parameters", async () => {
256
265
  const mockPosts = [{ id: 1 }];
257
266
  (client as any).request = jest.fn().mockResolvedValue(mockPosts);
258
267
 
259
- const params = { per_page: 10, status: ['publish'] as ['publish'] };
260
-
268
+ const params = { per_page: 10, status: ["publish"] as ["publish"] };
269
+
261
270
  await client.getPosts(params);
262
271
  await client.getPosts(params);
263
272
 
@@ -266,39 +275,45 @@ describe('CachedWordPressClient', () => {
266
275
  });
267
276
  });
268
277
 
269
- describe('Helper Methods', () => {
270
- test('should extract resource from endpoint', () => {
271
- const resource1 = (client as any).extractResourceFromEndpoint('posts');
272
- const resource2 = (client as any).extractResourceFromEndpoint('posts/123');
273
- const resource3 = (client as any).extractResourceFromEndpoint('categories');
278
+ describe("Helper Methods", () => {
279
+ test("should extract resource from endpoint", () => {
280
+ const resource1 = (client as any).extractResourceFromEndpoint("posts");
281
+ const resource2 = (client as any).extractResourceFromEndpoint(
282
+ "posts/123",
283
+ );
284
+ const resource3 = (client as any).extractResourceFromEndpoint(
285
+ "categories",
286
+ );
274
287
 
275
- expect(resource1).toBe('posts');
276
- expect(resource2).toBe('posts');
277
- expect(resource3).toBe('categories');
288
+ expect(resource1).toBe("posts");
289
+ expect(resource2).toBe("posts");
290
+ expect(resource3).toBe("categories");
278
291
  });
279
292
 
280
- test('should extract ID from endpoint', () => {
281
- const id1 = (client as any).extractIdFromEndpoint('posts/123');
282
- const id2 = (client as any).extractIdFromEndpoint('posts/123/revisions');
283
- const id3 = (client as any).extractIdFromEndpoint('posts');
293
+ test("should extract ID from endpoint", () => {
294
+ const id1 = (client as any).extractIdFromEndpoint("posts/123");
295
+ const id2 = (client as any).extractIdFromEndpoint("posts/123/revisions");
296
+ const id3 = (client as any).extractIdFromEndpoint("posts");
284
297
 
285
298
  expect(id1).toBe(123);
286
299
  expect(id2).toBe(123);
287
300
  expect(id3).toBeUndefined();
288
301
  });
289
302
 
290
- test('should identify endpoint types correctly', () => {
291
- expect((client as any).isStaticEndpoint('settings')).toBe(true);
292
- expect((client as any).isStaticEndpoint('types')).toBe(true);
293
- expect((client as any).isStaticEndpoint('posts')).toBe(false);
303
+ test("should identify endpoint types correctly", () => {
304
+ expect((client as any).isStaticEndpoint("settings")).toBe(true);
305
+ expect((client as any).isStaticEndpoint("types")).toBe(true);
306
+ expect((client as any).isStaticEndpoint("posts")).toBe(false);
294
307
 
295
- expect((client as any).isSemiStaticEndpoint('categories')).toBe(true);
296
- expect((client as any).isSemiStaticEndpoint('tags')).toBe(true);
297
- expect((client as any).isSemiStaticEndpoint('posts')).toBe(false);
308
+ expect((client as any).isSemiStaticEndpoint("categories")).toBe(true);
309
+ expect((client as any).isSemiStaticEndpoint("tags")).toBe(true);
310
+ expect((client as any).isSemiStaticEndpoint("posts")).toBe(false);
298
311
 
299
- expect((client as any).isSessionEndpoint('users/me')).toBe(true);
300
- expect((client as any).isSessionEndpoint('application-passwords')).toBe(true);
301
- expect((client as any).isSessionEndpoint('posts')).toBe(false);
312
+ expect((client as any).isSessionEndpoint("users/me")).toBe(true);
313
+ expect((client as any).isSessionEndpoint("application-passwords")).toBe(
314
+ true,
315
+ );
316
+ expect((client as any).isSessionEndpoint("posts")).toBe(false);
302
317
  });
303
318
  });
304
319
  });