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
@@ -3,16 +3,16 @@
3
3
  * Extends the base WordPress client with intelligent caching capabilities and performance monitoring
4
4
  */
5
5
 
6
- import { WordPressClient } from './api.js';
7
- import { CacheManager } from '../cache/CacheManager.js';
8
- import { HttpCacheWrapper } from '../cache/HttpCacheWrapper.js';
9
- import { CacheInvalidation } from '../cache/CacheInvalidation.js';
10
- import { SecurityConfig } from '../security/SecurityConfig.js';
6
+ import { WordPressClient } from "./api.js";
7
+ import { CacheManager } from "../cache/CacheManager.js";
8
+ import { HttpCacheWrapper } from "../cache/HttpCacheWrapper.js";
9
+ import { CacheInvalidation } from "../cache/CacheInvalidation.js";
10
+ import { SecurityConfig } from "../security/SecurityConfig.js";
11
11
  import type {
12
12
  WordPressClientConfig,
13
13
  HTTPMethod,
14
- RequestOptions
15
- } from '../types/client.js';
14
+ RequestOptions,
15
+ } from "../types/client.js";
16
16
  import type {
17
17
  WordPressPost,
18
18
  WordPressUser,
@@ -21,8 +21,8 @@ import type {
21
21
  WordPressSiteSettings,
22
22
  PostQueryParams,
23
23
  CreatePostRequest,
24
- UpdatePostRequest
25
- } from '../types/wordpress.js';
24
+ UpdatePostRequest,
25
+ } from "../types/wordpress.js";
26
26
 
27
27
  /**
28
28
  * WordPress client with intelligent caching
@@ -33,17 +33,17 @@ export class CachedWordPressClient extends WordPressClient {
33
33
  private cacheInvalidation: CacheInvalidation;
34
34
  private siteId: string;
35
35
 
36
- constructor(config: WordPressClientConfig, siteId: string = 'default') {
36
+ constructor(config: WordPressClientConfig, siteId: string = "default") {
37
37
  super(config);
38
38
  this.siteId = siteId;
39
-
39
+
40
40
  // Initialize caching system
41
41
  this.cacheManager = new CacheManager({
42
42
  maxSize: SecurityConfig.cache.maxSize,
43
43
  defaultTTL: SecurityConfig.cache.defaultTTL,
44
44
  enableLRU: SecurityConfig.cache.enableLRU,
45
45
  enableStats: SecurityConfig.cache.enableStats,
46
- sitePrefix: siteId
46
+ sitePrefix: siteId,
47
47
  });
48
48
 
49
49
  this.httpCache = new HttpCacheWrapper(this.cacheManager, siteId);
@@ -57,44 +57,44 @@ export class CachedWordPressClient extends WordPressClient {
57
57
  method: HTTPMethod,
58
58
  endpoint: string,
59
59
  data: any = null,
60
- options: RequestOptions = {}
60
+ options: RequestOptions = {},
61
61
  ): Promise<T> {
62
62
  // Only cache GET requests
63
- if (method.toUpperCase() !== 'GET' || !SecurityConfig.cache.enabled) {
63
+ if (method.toUpperCase() !== "GET" || !SecurityConfig.cache.enabled) {
64
64
  const response = await super.request<T>(method, endpoint, data, options);
65
-
65
+
66
66
  // Trigger cache invalidation for write operations
67
- if (['POST', 'PUT', 'PATCH', 'DELETE'].includes(method.toUpperCase())) {
67
+ if (["POST", "PUT", "PATCH", "DELETE"].includes(method.toUpperCase())) {
68
68
  await this.handleCacheInvalidation(method, endpoint, data);
69
69
  }
70
-
70
+
71
71
  return response;
72
72
  }
73
73
 
74
74
  // Use cached request for GET operations
75
75
  const requestFn = () => super.request<T>(method, endpoint, data, options);
76
-
76
+
77
77
  const requestOptions = {
78
78
  method,
79
79
  url: `${this.config.baseUrl}/wp-json/wp/v2/${endpoint}`,
80
80
  headers: {},
81
81
  params: {},
82
- data
82
+ data,
83
83
  };
84
84
 
85
85
  const cacheOptions = this.getCacheOptions(endpoint);
86
-
86
+
87
87
  const response = await this.httpCache.request(
88
88
  async () => {
89
89
  const result = await requestFn();
90
90
  return {
91
91
  data: result,
92
92
  status: 200,
93
- headers: {}
93
+ headers: {},
94
94
  };
95
95
  },
96
96
  requestOptions,
97
- cacheOptions
97
+ cacheOptions,
98
98
  );
99
99
 
100
100
  return response.data;
@@ -108,14 +108,16 @@ export class CachedWordPressClient extends WordPressClient {
108
108
  * Get posts with intelligent caching
109
109
  */
110
110
  async getPosts(params: PostQueryParams = {}): Promise<WordPressPost[]> {
111
- return await this.request<WordPressPost[]>('GET', 'posts', null, { params });
111
+ return await this.request<WordPressPost[]>("GET", "posts", null, {
112
+ params,
113
+ });
112
114
  }
113
115
 
114
116
  /**
115
117
  * Get single post with caching
116
118
  */
117
119
  async getPost(id: number): Promise<WordPressPost> {
118
- return await this.request<WordPressPost>('GET', `posts/${id}`);
120
+ return await this.request<WordPressPost>("GET", `posts/${id}`);
119
121
  }
120
122
 
121
123
  /**
@@ -123,10 +125,10 @@ export class CachedWordPressClient extends WordPressClient {
123
125
  */
124
126
  async createPost(data: CreatePostRequest): Promise<WordPressPost> {
125
127
  const post = await super.createPost(data);
126
-
128
+
127
129
  // Invalidate related caches
128
- await this.cacheInvalidation.invalidateResource('posts', post.id, 'create');
129
-
130
+ await this.cacheInvalidation.invalidateResource("posts", post.id, "create");
131
+
130
132
  return post;
131
133
  }
132
134
 
@@ -135,22 +137,25 @@ export class CachedWordPressClient extends WordPressClient {
135
137
  */
136
138
  async updatePost(data: UpdatePostRequest): Promise<WordPressPost> {
137
139
  const post = await super.updatePost(data);
138
-
140
+
139
141
  // Invalidate related caches
140
- await this.cacheInvalidation.invalidateResource('posts', post.id, 'update');
141
-
142
+ await this.cacheInvalidation.invalidateResource("posts", post.id, "update");
143
+
142
144
  return post;
143
145
  }
144
146
 
145
147
  /**
146
148
  * Delete post with cache invalidation
147
149
  */
148
- async deletePost(id: number, force?: boolean): Promise<{ deleted: boolean; previous?: WordPressPost }> {
150
+ async deletePost(
151
+ id: number,
152
+ force?: boolean,
153
+ ): Promise<{ deleted: boolean; previous?: WordPressPost }> {
149
154
  const result = await super.deletePost(id, force);
150
-
155
+
151
156
  // Invalidate related caches
152
- await this.cacheInvalidation.invalidateResource('posts', id, 'delete');
153
-
157
+ await this.cacheInvalidation.invalidateResource("posts", id, "delete");
158
+
154
159
  return result;
155
160
  }
156
161
 
@@ -158,42 +163,43 @@ export class CachedWordPressClient extends WordPressClient {
158
163
  * Get current user with session caching
159
164
  */
160
165
  async getCurrentUser(): Promise<WordPressUser> {
161
- return await this.request<WordPressUser>('GET', 'users/me');
166
+ return await this.request<WordPressUser>("GET", "users/me");
162
167
  }
163
168
 
164
169
  /**
165
170
  * Get categories with semi-static caching
166
171
  */
167
172
  async getCategories(params: any = {}): Promise<WordPressCategory[]> {
168
- return await this.request<WordPressCategory[]>('GET', 'categories', null, { params });
173
+ return await this.request<WordPressCategory[]>("GET", "categories", null, {
174
+ params,
175
+ });
169
176
  }
170
177
 
171
178
  /**
172
179
  * Get tags with semi-static caching
173
180
  */
174
181
  async getTags(params: any = {}): Promise<WordPressTag[]> {
175
- return await this.request<WordPressTag[]>('GET', 'tags', null, { params });
182
+ return await this.request<WordPressTag[]>("GET", "tags", null, { params });
176
183
  }
177
184
 
178
185
  /**
179
186
  * Get site settings with static caching
180
187
  */
181
188
  async getSiteSettings(): Promise<WordPressSiteSettings> {
182
- return await this.request<WordPressSiteSettings>('GET', 'settings');
189
+ return await this.request<WordPressSiteSettings>("GET", "settings");
183
190
  }
184
191
 
185
192
  /**
186
193
  * Cache management methods
187
194
  */
188
195
 
189
-
190
196
  /**
191
197
  * Private helper methods
192
198
  */
193
199
 
194
200
  private extractEndpoint(url: string): string {
195
201
  // Simple approach - use the endpoint part
196
- return url.replace(/^.*\/wp-json\/wp\/v2\//, '').split('?')[0];
202
+ return url.replace(/^.*\/wp-json\/wp\/v2\//, "").split("?")[0];
197
203
  }
198
204
 
199
205
  /**
@@ -204,29 +210,29 @@ export class CachedWordPressClient extends WordPressClient {
204
210
  if (this.isStaticEndpoint(endpoint)) {
205
211
  return {
206
212
  ttl: SecurityConfig.cache.ttlPresets.static,
207
- cacheControl: SecurityConfig.cache.cacheHeaders.static
213
+ cacheControl: SecurityConfig.cache.cacheHeaders.static,
208
214
  };
209
215
  }
210
-
216
+
211
217
  if (this.isSemiStaticEndpoint(endpoint)) {
212
218
  return {
213
219
  ttl: SecurityConfig.cache.ttlPresets.semiStatic,
214
- cacheControl: SecurityConfig.cache.cacheHeaders.semiStatic
220
+ cacheControl: SecurityConfig.cache.cacheHeaders.semiStatic,
215
221
  };
216
222
  }
217
-
223
+
218
224
  if (this.isSessionEndpoint(endpoint)) {
219
225
  return {
220
226
  ttl: SecurityConfig.cache.ttlPresets.session,
221
227
  cacheControl: SecurityConfig.cache.cacheHeaders.session,
222
- private: true
228
+ private: true,
223
229
  };
224
230
  }
225
-
231
+
226
232
  // Default to dynamic caching
227
233
  return {
228
234
  ttl: SecurityConfig.cache.ttlPresets.dynamic,
229
- cacheControl: SecurityConfig.cache.cacheHeaders.dynamic
235
+ cacheControl: SecurityConfig.cache.cacheHeaders.dynamic,
230
236
  };
231
237
  }
232
238
 
@@ -236,37 +242,41 @@ export class CachedWordPressClient extends WordPressClient {
236
242
  private async handleCacheInvalidation(
237
243
  method: string,
238
244
  endpoint: string,
239
- data: any
245
+ data: any,
240
246
  ): Promise<void> {
241
247
  const resource = this.extractResourceFromEndpoint(endpoint);
242
248
  const id = this.extractIdFromEndpoint(endpoint);
243
-
244
- let operationType: 'create' | 'update' | 'delete';
245
-
249
+
250
+ let operationType: "create" | "update" | "delete";
251
+
246
252
  switch (method.toUpperCase()) {
247
- case 'POST':
248
- operationType = 'create';
253
+ case "POST":
254
+ operationType = "create";
249
255
  break;
250
- case 'PUT':
251
- case 'PATCH':
252
- operationType = 'update';
256
+ case "PUT":
257
+ case "PATCH":
258
+ operationType = "update";
253
259
  break;
254
- case 'DELETE':
255
- operationType = 'delete';
260
+ case "DELETE":
261
+ operationType = "delete";
256
262
  break;
257
263
  default:
258
264
  return;
259
265
  }
260
266
 
261
- await this.cacheInvalidation.invalidateResource(resource, id, operationType);
267
+ await this.cacheInvalidation.invalidateResource(
268
+ resource,
269
+ id,
270
+ operationType,
271
+ );
262
272
  }
263
273
 
264
274
  /**
265
275
  * Extract resource type from endpoint
266
276
  */
267
277
  private extractResourceFromEndpoint(endpoint: string): string {
268
- const parts = endpoint.split('/');
269
- return parts[0] || 'unknown';
278
+ const parts = endpoint.split("/");
279
+ return parts[0] || "unknown";
270
280
  }
271
281
 
272
282
  /**
@@ -281,24 +291,24 @@ export class CachedWordPressClient extends WordPressClient {
281
291
  * Check if endpoint contains static data
282
292
  */
283
293
  private isStaticEndpoint(endpoint: string): boolean {
284
- const staticEndpoints = ['settings', 'types', 'statuses'];
285
- return staticEndpoints.some(pattern => endpoint.includes(pattern));
294
+ const staticEndpoints = ["settings", "types", "statuses"];
295
+ return staticEndpoints.some((pattern) => endpoint.includes(pattern));
286
296
  }
287
297
 
288
298
  /**
289
299
  * Check if endpoint contains semi-static data
290
300
  */
291
301
  private isSemiStaticEndpoint(endpoint: string): boolean {
292
- const semiStaticEndpoints = ['categories', 'tags', 'users', 'taxonomies'];
293
- return semiStaticEndpoints.some(pattern => endpoint.includes(pattern));
302
+ const semiStaticEndpoints = ["categories", "tags", "users", "taxonomies"];
303
+ return semiStaticEndpoints.some((pattern) => endpoint.includes(pattern));
294
304
  }
295
305
 
296
306
  /**
297
307
  * Check if endpoint is session-related
298
308
  */
299
309
  private isSessionEndpoint(endpoint: string): boolean {
300
- const sessionEndpoints = ['users/me', 'application-passwords'];
301
- return sessionEndpoints.some(pattern => endpoint.includes(pattern));
310
+ const sessionEndpoints = ["users/me", "application-passwords"];
311
+ return sessionEndpoints.some((pattern) => endpoint.includes(pattern));
302
312
  }
303
313
 
304
314
  /**
@@ -332,7 +342,7 @@ export class CachedWordPressClient extends WordPressClient {
332
342
  * Clear cache entries matching pattern
333
343
  */
334
344
  clearCachePattern(pattern: string): number {
335
- const regex = new RegExp(pattern, 'i');
345
+ const regex = new RegExp(pattern, "i");
336
346
  return this.cacheManager.clearPattern(regex);
337
347
  }
338
348
 
@@ -346,11 +356,11 @@ export class CachedWordPressClient extends WordPressClient {
346
356
  () => this.getCurrentUser().catch(() => null),
347
357
  () => this.getCategories().catch(() => null),
348
358
  () => this.getTags().catch(() => null),
349
- () => this.getSiteSettings().catch(() => null)
359
+ () => this.getSiteSettings().catch(() => null),
350
360
  ];
351
361
 
352
362
  // Execute warmup operations in parallel
353
- await Promise.allSettled(warmupOperations.map(op => op()));
363
+ await Promise.allSettled(warmupOperations.map((op) => op()));
354
364
  } catch (_error) {
355
365
  // Ignore warmup errors - they shouldn't fail the cache warming
356
366
  }
@@ -370,18 +380,18 @@ export class CachedWordPressClient extends WordPressClient {
370
380
  const total = stats.hits + stats.misses;
371
381
  const hitRate = total > 0 ? stats.hits / total : 0;
372
382
  const missRate = 1 - hitRate;
373
-
374
- let efficiency = 'Poor';
375
- if (hitRate >= 0.9) efficiency = 'Excellent';
376
- else if (hitRate >= 0.8) efficiency = 'Good';
377
- else if (hitRate >= 0.6) efficiency = 'Fair';
383
+
384
+ let efficiency = "Poor";
385
+ if (hitRate >= 0.9) efficiency = "Excellent";
386
+ else if (hitRate >= 0.8) efficiency = "Good";
387
+ else if (hitRate >= 0.6) efficiency = "Fair";
378
388
 
379
389
  return {
380
390
  hitRate,
381
391
  missRate,
382
392
  efficiency,
383
393
  memoryUsage: this.estimateMemoryUsage(),
384
- totalEntries: stats.totalSize
394
+ totalEntries: stats.totalSize,
385
395
  };
386
396
  }
387
397
 
@@ -397,14 +407,14 @@ export class CachedWordPressClient extends WordPressClient {
397
407
  ttlPresets: any;
398
408
  } {
399
409
  const stats = this.cacheManager.getStats();
400
-
410
+
401
411
  return {
402
412
  enabled: SecurityConfig.cache.enabled,
403
413
  siteId: this.siteId,
404
414
  maxSize: SecurityConfig.cache.maxSize,
405
415
  defaultTTL: SecurityConfig.cache.defaultTTL,
406
416
  currentSize: stats.totalSize,
407
- ttlPresets: SecurityConfig.cache.ttlPresets
417
+ ttlPresets: SecurityConfig.cache.ttlPresets,
408
418
  };
409
419
  }
410
420
 
@@ -435,8 +445,8 @@ export class CachedWordPressClient extends WordPressClient {
435
445
  configuration: this.getCacheInfo(),
436
446
  siteInfo: {
437
447
  siteId: this.siteId,
438
- baseUrl: this.config.baseUrl
439
- }
448
+ baseUrl: this.config.baseUrl,
449
+ },
440
450
  };
441
451
  }
442
452
  }