mcp-wordpress 2.4.2 → 2.5.1

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 (653) hide show
  1. package/README.md +124 -54
  2. package/bin/status.js +1 -1
  3. package/dist/cache/CacheInvalidation.d.ts +3 -1
  4. package/dist/cache/CacheInvalidation.d.ts.map +1 -1
  5. package/dist/cache/CacheInvalidation.js +10 -4
  6. package/dist/cache/CacheInvalidation.js.map +1 -1
  7. package/dist/cache/CacheManager.d.ts +3 -2
  8. package/dist/cache/CacheManager.d.ts.map +1 -1
  9. package/dist/cache/CacheManager.js +11 -3
  10. package/dist/cache/CacheManager.js.map +1 -1
  11. package/dist/cache/HttpCacheWrapper.d.ts +7 -6
  12. package/dist/cache/HttpCacheWrapper.d.ts.map +1 -1
  13. package/dist/cache/HttpCacheWrapper.js +8 -5
  14. package/dist/cache/HttpCacheWrapper.js.map +1 -1
  15. package/dist/cache/index.d.ts +3 -3
  16. package/dist/cache/index.d.ts.map +1 -1
  17. package/dist/cache/index.js +1 -1
  18. package/dist/cache/index.js.map +1 -1
  19. package/dist/client/CachedWordPressClient.d.ts +23 -9
  20. package/dist/client/CachedWordPressClient.d.ts.map +1 -1
  21. package/dist/client/CachedWordPressClient.js +4 -1
  22. package/dist/client/CachedWordPressClient.js.map +1 -1
  23. package/dist/client/MockWordPressClient.d.ts +2 -1
  24. package/dist/client/MockWordPressClient.d.ts.map +1 -1
  25. package/dist/client/MockWordPressClient.js +3 -1
  26. package/dist/client/MockWordPressClient.js.map +1 -1
  27. package/dist/client/api.d.ts +17 -13
  28. package/dist/client/api.d.ts.map +1 -1
  29. package/dist/client/api.js +135 -30
  30. package/dist/client/api.js.map +1 -1
  31. package/dist/client/auth.d.ts.map +1 -1
  32. package/dist/client/auth.js +2 -3
  33. package/dist/client/auth.js.map +1 -1
  34. package/dist/client/managers/AuthenticationManager.d.ts +55 -2
  35. package/dist/client/managers/AuthenticationManager.d.ts.map +1 -1
  36. package/dist/client/managers/AuthenticationManager.js +269 -71
  37. package/dist/client/managers/AuthenticationManager.js.map +1 -1
  38. package/dist/client/managers/BaseManager.d.ts +3 -3
  39. package/dist/client/managers/BaseManager.d.ts.map +1 -1
  40. package/dist/client/managers/BaseManager.js +11 -5
  41. package/dist/client/managers/BaseManager.js.map +1 -1
  42. package/dist/client/managers/RequestManager.d.ts +2 -2
  43. package/dist/client/managers/RequestManager.d.ts.map +1 -1
  44. package/dist/client/managers/RequestManager.js +25 -12
  45. package/dist/client/managers/RequestManager.js.map +1 -1
  46. package/dist/config/Config.d.ts +155 -0
  47. package/dist/config/Config.d.ts.map +1 -0
  48. package/dist/config/Config.js +215 -0
  49. package/dist/config/Config.js.map +1 -0
  50. package/dist/config/ConfigurationSchema.d.ts +21 -21
  51. package/dist/config/ConfigurationSchema.d.ts.map +1 -1
  52. package/dist/config/ConfigurationSchema.js +19 -2
  53. package/dist/config/ConfigurationSchema.js.map +1 -1
  54. package/dist/config/ServerConfiguration.d.ts +2 -1
  55. package/dist/config/ServerConfiguration.d.ts.map +1 -1
  56. package/dist/config/ServerConfiguration.js +73 -43
  57. package/dist/config/ServerConfiguration.js.map +1 -1
  58. package/dist/docs/DocumentationGenerator.d.ts +9 -8
  59. package/dist/docs/DocumentationGenerator.d.ts.map +1 -1
  60. package/dist/docs/DocumentationGenerator.js +10 -7
  61. package/dist/docs/DocumentationGenerator.js.map +1 -1
  62. package/dist/docs/MarkdownFormatter.d.ts.map +1 -1
  63. package/dist/docs/MarkdownFormatter.js +3 -2
  64. package/dist/docs/MarkdownFormatter.js.map +1 -1
  65. package/dist/dxt-entry.js +15 -14
  66. package/dist/dxt-entry.js.map +1 -1
  67. package/dist/index.d.ts +3 -1
  68. package/dist/index.d.ts.map +1 -1
  69. package/dist/index.js +37 -21
  70. package/dist/index.js.map +1 -1
  71. package/dist/performance/MetricsCollector.d.ts +13 -7
  72. package/dist/performance/MetricsCollector.d.ts.map +1 -1
  73. package/dist/performance/MetricsCollector.js +69 -27
  74. package/dist/performance/MetricsCollector.js.map +1 -1
  75. package/dist/performance/PerformanceAnalytics.d.ts +8 -2
  76. package/dist/performance/PerformanceAnalytics.d.ts.map +1 -1
  77. package/dist/performance/PerformanceAnalytics.js +17 -47
  78. package/dist/performance/PerformanceAnalytics.js.map +1 -1
  79. package/dist/performance/PerformanceMonitor.d.ts +2 -1
  80. package/dist/performance/PerformanceMonitor.d.ts.map +1 -1
  81. package/dist/performance/PerformanceMonitor.js +12 -13
  82. package/dist/performance/PerformanceMonitor.js.map +1 -1
  83. package/dist/performance/index.d.ts +2 -2
  84. package/dist/performance/index.d.ts.map +1 -1
  85. package/dist/security/AISecurityScanner.d.ts +1 -0
  86. package/dist/security/AISecurityScanner.d.ts.map +1 -1
  87. package/dist/security/AISecurityScanner.js +22 -12
  88. package/dist/security/AISecurityScanner.js.map +1 -1
  89. package/dist/security/AutomatedRemediation.d.ts +4 -3
  90. package/dist/security/AutomatedRemediation.d.ts.map +1 -1
  91. package/dist/security/AutomatedRemediation.js +46 -15
  92. package/dist/security/AutomatedRemediation.js.map +1 -1
  93. package/dist/security/InputValidator.d.ts +13 -9
  94. package/dist/security/InputValidator.d.ts.map +1 -1
  95. package/dist/security/InputValidator.js +4 -2
  96. package/dist/security/InputValidator.js.map +1 -1
  97. package/dist/security/SecurityCIPipeline.d.ts +1 -1
  98. package/dist/security/SecurityCIPipeline.d.ts.map +1 -1
  99. package/dist/security/SecurityCIPipeline.js +38 -29
  100. package/dist/security/SecurityCIPipeline.js.map +1 -1
  101. package/dist/security/SecurityConfig.d.ts +3 -3
  102. package/dist/security/SecurityConfig.d.ts.map +1 -1
  103. package/dist/security/SecurityConfig.js +13 -9
  104. package/dist/security/SecurityConfig.js.map +1 -1
  105. package/dist/security/SecurityConfigManager.d.ts +2 -2
  106. package/dist/security/SecurityConfigManager.d.ts.map +1 -1
  107. package/dist/security/SecurityConfigManager.js +20 -15
  108. package/dist/security/SecurityConfigManager.js.map +1 -1
  109. package/dist/security/SecurityMonitoring.d.ts +2 -2
  110. package/dist/security/SecurityMonitoring.d.ts.map +1 -1
  111. package/dist/security/SecurityMonitoring.js +19 -17
  112. package/dist/security/SecurityMonitoring.js.map +1 -1
  113. package/dist/security/SecurityReviewer.d.ts.map +1 -1
  114. package/dist/security/SecurityReviewer.js +10 -7
  115. package/dist/security/SecurityReviewer.js.map +1 -1
  116. package/dist/security/index.d.ts +24 -23
  117. package/dist/security/index.d.ts.map +1 -1
  118. package/dist/security/index.js +52 -23
  119. package/dist/security/index.js.map +1 -1
  120. package/dist/server/ConnectionTester.d.ts +12 -4
  121. package/dist/server/ConnectionTester.d.ts.map +1 -1
  122. package/dist/server/ConnectionTester.js +96 -22
  123. package/dist/server/ConnectionTester.js.map +1 -1
  124. package/dist/server/ToolRegistry.d.ts +2 -2
  125. package/dist/server/ToolRegistry.d.ts.map +1 -1
  126. package/dist/server/ToolRegistry.js +10 -5
  127. package/dist/server/ToolRegistry.js.map +1 -1
  128. package/dist/src/cache/CacheInvalidation.d.ts +120 -0
  129. package/dist/src/cache/CacheInvalidation.d.ts.map +1 -0
  130. package/dist/src/cache/CacheInvalidation.js +355 -0
  131. package/dist/src/cache/CacheInvalidation.js.map +1 -0
  132. package/dist/src/cache/CacheManager.d.ts +149 -0
  133. package/dist/src/cache/CacheManager.d.ts.map +1 -0
  134. package/dist/src/cache/CacheManager.js +326 -0
  135. package/dist/src/cache/CacheManager.js.map +1 -0
  136. package/dist/src/cache/HttpCacheWrapper.d.ts +122 -0
  137. package/dist/src/cache/HttpCacheWrapper.d.ts.map +1 -0
  138. package/dist/src/cache/HttpCacheWrapper.js +283 -0
  139. package/dist/src/cache/HttpCacheWrapper.js.map +1 -0
  140. package/dist/src/cache/index.d.ts +12 -0
  141. package/dist/src/cache/index.d.ts.map +1 -0
  142. package/dist/src/cache/index.js +9 -0
  143. package/dist/src/cache/index.js.map +1 -0
  144. package/dist/src/client/CachedWordPressClient.d.ts +174 -0
  145. package/dist/src/client/CachedWordPressClient.d.ts.map +1 -0
  146. package/dist/src/client/CachedWordPressClient.js +345 -0
  147. package/dist/src/client/CachedWordPressClient.js.map +1 -0
  148. package/dist/src/client/MockWordPressClient.d.ts +56 -0
  149. package/dist/src/client/MockWordPressClient.d.ts.map +1 -0
  150. package/dist/src/client/MockWordPressClient.js +371 -0
  151. package/dist/src/client/MockWordPressClient.js.map +1 -0
  152. package/dist/src/client/api.d.ts +235 -0
  153. package/dist/src/client/api.d.ts.map +1 -0
  154. package/dist/src/client/api.js +896 -0
  155. package/dist/src/client/api.js.map +1 -0
  156. package/dist/src/client/auth.d.ts +121 -0
  157. package/dist/src/client/auth.d.ts.map +1 -0
  158. package/dist/src/client/auth.js +429 -0
  159. package/dist/src/client/auth.js.map +1 -0
  160. package/dist/src/client/managers/AuthenticationManager.d.ts +92 -0
  161. package/dist/src/client/managers/AuthenticationManager.d.ts.map +1 -0
  162. package/dist/src/client/managers/AuthenticationManager.js +369 -0
  163. package/dist/src/client/managers/AuthenticationManager.js.map +1 -0
  164. package/dist/src/client/managers/BaseManager.d.ts +22 -0
  165. package/dist/src/client/managers/BaseManager.d.ts.map +1 -0
  166. package/dist/src/client/managers/BaseManager.js +53 -0
  167. package/dist/src/client/managers/BaseManager.js.map +1 -0
  168. package/dist/src/client/managers/RequestManager.d.ts +47 -0
  169. package/dist/src/client/managers/RequestManager.d.ts.map +1 -0
  170. package/dist/src/client/managers/RequestManager.js +193 -0
  171. package/dist/src/client/managers/RequestManager.js.map +1 -0
  172. package/dist/src/client/managers/index.d.ts +8 -0
  173. package/dist/src/client/managers/index.d.ts.map +1 -0
  174. package/dist/src/client/managers/index.js +8 -0
  175. package/dist/src/client/managers/index.js.map +1 -0
  176. package/dist/src/config/Config.d.ts +155 -0
  177. package/dist/src/config/Config.d.ts.map +1 -0
  178. package/dist/src/config/Config.js +215 -0
  179. package/dist/src/config/Config.js.map +1 -0
  180. package/dist/src/config/ConfigurationSchema.d.ts +281 -0
  181. package/dist/src/config/ConfigurationSchema.d.ts.map +1 -0
  182. package/dist/src/config/ConfigurationSchema.js +205 -0
  183. package/dist/src/config/ConfigurationSchema.js.map +1 -0
  184. package/dist/src/config/ServerConfiguration.d.ts +47 -0
  185. package/dist/src/config/ServerConfiguration.d.ts.map +1 -0
  186. package/dist/src/config/ServerConfiguration.js +255 -0
  187. package/dist/src/config/ServerConfiguration.js.map +1 -0
  188. package/dist/src/docs/DocumentationGenerator.d.ts +185 -0
  189. package/dist/src/docs/DocumentationGenerator.d.ts.map +1 -0
  190. package/dist/src/docs/DocumentationGenerator.js +777 -0
  191. package/dist/src/docs/DocumentationGenerator.js.map +1 -0
  192. package/dist/src/docs/MarkdownFormatter.d.ts +84 -0
  193. package/dist/src/docs/MarkdownFormatter.d.ts.map +1 -0
  194. package/dist/src/docs/MarkdownFormatter.js +458 -0
  195. package/dist/src/docs/MarkdownFormatter.js.map +1 -0
  196. package/dist/src/docs/index.d.ts +8 -0
  197. package/dist/src/docs/index.d.ts.map +1 -0
  198. package/dist/src/docs/index.js +7 -0
  199. package/dist/src/docs/index.js.map +1 -0
  200. package/dist/src/dxt-entry.d.ts +6 -0
  201. package/dist/src/dxt-entry.d.ts.map +1 -0
  202. package/dist/src/dxt-entry.js +39 -0
  203. package/dist/src/dxt-entry.js.map +1 -0
  204. package/dist/src/index.d.ts +18 -0
  205. package/dist/src/index.d.ts.map +1 -0
  206. package/dist/src/index.js +143 -0
  207. package/dist/src/index.js.map +1 -0
  208. package/dist/src/performance/MetricsCollector.d.ts +145 -0
  209. package/dist/src/performance/MetricsCollector.d.ts.map +1 -0
  210. package/dist/src/performance/MetricsCollector.js +368 -0
  211. package/dist/src/performance/MetricsCollector.js.map +1 -0
  212. package/dist/src/performance/PerformanceAnalytics.d.ts +168 -0
  213. package/dist/src/performance/PerformanceAnalytics.d.ts.map +1 -0
  214. package/dist/src/performance/PerformanceAnalytics.js +570 -0
  215. package/dist/src/performance/PerformanceAnalytics.js.map +1 -0
  216. package/dist/src/performance/PerformanceMonitor.d.ts +203 -0
  217. package/dist/src/performance/PerformanceMonitor.d.ts.map +1 -0
  218. package/dist/src/performance/PerformanceMonitor.js +478 -0
  219. package/dist/src/performance/PerformanceMonitor.js.map +1 -0
  220. package/dist/src/performance/index.d.ts +11 -0
  221. package/dist/src/performance/index.d.ts.map +1 -0
  222. package/dist/src/performance/index.js +8 -0
  223. package/dist/src/performance/index.js.map +1 -0
  224. package/dist/src/security/AISecurityScanner.d.ts +176 -0
  225. package/dist/src/security/AISecurityScanner.d.ts.map +1 -0
  226. package/dist/src/security/AISecurityScanner.js +655 -0
  227. package/dist/src/security/AISecurityScanner.js.map +1 -0
  228. package/dist/src/security/AutomatedRemediation.d.ts +146 -0
  229. package/dist/src/security/AutomatedRemediation.d.ts.map +1 -0
  230. package/dist/src/security/AutomatedRemediation.js +566 -0
  231. package/dist/src/security/AutomatedRemediation.js.map +1 -0
  232. package/dist/src/security/InputValidator.d.ts +219 -0
  233. package/dist/src/security/InputValidator.d.ts.map +1 -0
  234. package/dist/src/security/InputValidator.js +295 -0
  235. package/dist/src/security/InputValidator.js.map +1 -0
  236. package/dist/src/security/SecurityCIPipeline.d.ts +213 -0
  237. package/dist/src/security/SecurityCIPipeline.d.ts.map +1 -0
  238. package/dist/src/security/SecurityCIPipeline.js +693 -0
  239. package/dist/src/security/SecurityCIPipeline.js.map +1 -0
  240. package/dist/src/security/SecurityConfig.d.ts +129 -0
  241. package/dist/src/security/SecurityConfig.d.ts.map +1 -0
  242. package/dist/src/security/SecurityConfig.js +266 -0
  243. package/dist/src/security/SecurityConfig.js.map +1 -0
  244. package/dist/src/security/SecurityConfigManager.d.ts +294 -0
  245. package/dist/src/security/SecurityConfigManager.d.ts.map +1 -0
  246. package/dist/src/security/SecurityConfigManager.js +558 -0
  247. package/dist/src/security/SecurityConfigManager.js.map +1 -0
  248. package/dist/src/security/SecurityMonitoring.d.ts +245 -0
  249. package/dist/src/security/SecurityMonitoring.d.ts.map +1 -0
  250. package/dist/src/security/SecurityMonitoring.js +598 -0
  251. package/dist/src/security/SecurityMonitoring.js.map +1 -0
  252. package/dist/src/security/SecurityReviewer.d.ts +168 -0
  253. package/dist/src/security/SecurityReviewer.d.ts.map +1 -0
  254. package/dist/src/security/SecurityReviewer.js +686 -0
  255. package/dist/src/security/SecurityReviewer.js.map +1 -0
  256. package/dist/src/security/index.d.ts +183 -0
  257. package/dist/src/security/index.d.ts.map +1 -0
  258. package/dist/src/security/index.js +218 -0
  259. package/dist/src/security/index.js.map +1 -0
  260. package/dist/src/server/ConnectionTester.d.ts +32 -0
  261. package/dist/src/server/ConnectionTester.d.ts.map +1 -0
  262. package/dist/src/server/ConnectionTester.js +135 -0
  263. package/dist/src/server/ConnectionTester.js.map +1 -0
  264. package/dist/src/server/ToolRegistry.d.ts +50 -0
  265. package/dist/src/server/ToolRegistry.d.ts.map +1 -0
  266. package/dist/src/server/ToolRegistry.js +219 -0
  267. package/dist/src/server/ToolRegistry.js.map +1 -0
  268. package/dist/src/server.d.ts +7 -0
  269. package/dist/src/server.d.ts.map +1 -0
  270. package/dist/src/server.js +7 -0
  271. package/dist/src/server.js.map +1 -0
  272. package/dist/src/tools/BaseToolManager.d.ts +62 -0
  273. package/dist/src/tools/BaseToolManager.d.ts.map +1 -0
  274. package/dist/src/tools/BaseToolManager.js +195 -0
  275. package/dist/src/tools/BaseToolManager.js.map +1 -0
  276. package/dist/src/tools/auth.d.ts +50 -0
  277. package/dist/src/tools/auth.d.ts.map +1 -0
  278. package/dist/src/tools/auth.js +133 -0
  279. package/dist/src/tools/auth.js.map +1 -0
  280. package/dist/src/tools/cache.d.ts +260 -0
  281. package/dist/src/tools/cache.d.ts.map +1 -0
  282. package/dist/src/tools/cache.js +232 -0
  283. package/dist/src/tools/cache.js.map +1 -0
  284. package/dist/src/tools/comments.d.ts +33 -0
  285. package/dist/src/tools/comments.d.ts.map +1 -0
  286. package/dist/src/tools/comments.js +235 -0
  287. package/dist/src/tools/comments.js.map +1 -0
  288. package/dist/src/tools/index.d.ts +11 -0
  289. package/dist/src/tools/index.d.ts.map +1 -0
  290. package/dist/src/tools/index.js +11 -0
  291. package/dist/src/tools/index.js.map +1 -0
  292. package/dist/src/tools/media.d.ts +70 -0
  293. package/dist/src/tools/media.d.ts.map +1 -0
  294. package/dist/src/tools/media.js +248 -0
  295. package/dist/src/tools/media.js.map +1 -0
  296. package/dist/src/tools/pages.d.ts +32 -0
  297. package/dist/src/tools/pages.d.ts.map +1 -0
  298. package/dist/src/tools/pages.js +215 -0
  299. package/dist/src/tools/pages.js.map +1 -0
  300. package/dist/src/tools/performance.d.ts +73 -0
  301. package/dist/src/tools/performance.d.ts.map +1 -0
  302. package/dist/src/tools/performance.js +922 -0
  303. package/dist/src/tools/performance.js.map +1 -0
  304. package/dist/src/tools/posts/PostHandlers.d.ts +46 -0
  305. package/dist/src/tools/posts/PostHandlers.d.ts.map +1 -0
  306. package/dist/src/tools/posts/PostHandlers.js +400 -0
  307. package/dist/src/tools/posts/PostHandlers.js.map +1 -0
  308. package/dist/src/tools/posts/PostToolDefinitions.d.ts +37 -0
  309. package/dist/src/tools/posts/PostToolDefinitions.d.ts.map +1 -0
  310. package/dist/src/tools/posts/PostToolDefinitions.js +236 -0
  311. package/dist/src/tools/posts/PostToolDefinitions.js.map +1 -0
  312. package/dist/src/tools/posts/index.d.ts +138 -0
  313. package/dist/src/tools/posts/index.d.ts.map +1 -0
  314. package/dist/src/tools/posts/index.js +163 -0
  315. package/dist/src/tools/posts/index.js.map +1 -0
  316. package/dist/src/tools/posts.d.ts +15 -0
  317. package/dist/src/tools/posts.d.ts.map +1 -0
  318. package/dist/src/tools/posts.js +16 -0
  319. package/dist/src/tools/posts.js.map +1 -0
  320. package/dist/src/tools/site.d.ts +32 -0
  321. package/dist/src/tools/site.d.ts.map +1 -0
  322. package/dist/src/tools/site.js +234 -0
  323. package/dist/src/tools/site.js.map +1 -0
  324. package/dist/src/tools/taxonomies.d.ts +36 -0
  325. package/dist/src/tools/taxonomies.d.ts.map +1 -0
  326. package/dist/src/tools/taxonomies.js +286 -0
  327. package/dist/src/tools/taxonomies.js.map +1 -0
  328. package/dist/src/tools/users.d.ts +33 -0
  329. package/dist/src/tools/users.d.ts.map +1 -0
  330. package/dist/src/tools/users.js +308 -0
  331. package/dist/src/tools/users.js.map +1 -0
  332. package/dist/src/types/client.d.ts +223 -0
  333. package/dist/src/types/client.d.ts.map +1 -0
  334. package/dist/src/types/client.js +97 -0
  335. package/dist/src/types/client.js.map +1 -0
  336. package/dist/src/types/enhanced.d.ts +237 -0
  337. package/dist/src/types/enhanced.d.ts.map +1 -0
  338. package/dist/src/types/enhanced.js +49 -0
  339. package/dist/src/types/enhanced.js.map +1 -0
  340. package/dist/src/types/index.d.ts +160 -0
  341. package/dist/src/types/index.d.ts.map +1 -0
  342. package/dist/src/types/index.js +14 -0
  343. package/dist/src/types/index.js.map +1 -0
  344. package/dist/src/types/mcp.d.ts +178 -0
  345. package/dist/src/types/mcp.d.ts.map +1 -0
  346. package/dist/src/types/mcp.js +7 -0
  347. package/dist/src/types/mcp.js.map +1 -0
  348. package/dist/src/types/requests.d.ts +322 -0
  349. package/dist/src/types/requests.d.ts.map +1 -0
  350. package/dist/src/types/requests.js +8 -0
  351. package/dist/src/types/requests.js.map +1 -0
  352. package/dist/src/types/tools.d.ts +506 -0
  353. package/dist/src/types/tools.d.ts.map +1 -0
  354. package/dist/src/types/tools.js +8 -0
  355. package/dist/src/types/tools.js.map +1 -0
  356. package/dist/src/types/wordpress.d.ts +471 -0
  357. package/dist/src/types/wordpress.d.ts.map +1 -0
  358. package/dist/src/types/wordpress.js +14 -0
  359. package/dist/src/types/wordpress.js.map +1 -0
  360. package/dist/src/utils/debug.d.ts +71 -0
  361. package/dist/src/utils/debug.d.ts.map +1 -0
  362. package/dist/src/utils/debug.js +235 -0
  363. package/dist/src/utils/debug.js.map +1 -0
  364. package/dist/src/utils/enhancedError.d.ts +61 -0
  365. package/dist/src/utils/enhancedError.d.ts.map +1 -0
  366. package/dist/src/utils/enhancedError.js +221 -0
  367. package/dist/src/utils/enhancedError.js.map +1 -0
  368. package/dist/src/utils/error.d.ts +17 -0
  369. package/dist/src/utils/error.d.ts.map +1 -0
  370. package/dist/src/utils/error.js +108 -0
  371. package/dist/src/utils/error.js.map +1 -0
  372. package/dist/src/utils/logger.d.ts +106 -0
  373. package/dist/src/utils/logger.d.ts.map +1 -0
  374. package/dist/src/utils/logger.js +280 -0
  375. package/dist/src/utils/logger.js.map +1 -0
  376. package/dist/src/utils/streaming.d.ts +104 -0
  377. package/dist/src/utils/streaming.d.ts.map +1 -0
  378. package/dist/src/utils/streaming.js +331 -0
  379. package/dist/src/utils/streaming.js.map +1 -0
  380. package/dist/src/utils/toolWrapper.d.ts +42 -0
  381. package/dist/src/utils/toolWrapper.d.ts.map +1 -0
  382. package/dist/src/utils/toolWrapper.js +101 -0
  383. package/dist/src/utils/toolWrapper.js.map +1 -0
  384. package/dist/src/utils/validation/core.d.ts +21 -0
  385. package/dist/src/utils/validation/core.d.ts.map +1 -0
  386. package/dist/src/utils/validation/core.js +71 -0
  387. package/dist/src/utils/validation/core.js.map +1 -0
  388. package/dist/src/utils/validation/index.d.ts +25 -0
  389. package/dist/src/utils/validation/index.d.ts.map +1 -0
  390. package/dist/src/utils/validation/index.js +29 -0
  391. package/dist/src/utils/validation/index.js.map +1 -0
  392. package/dist/src/utils/validation/network.d.ts +19 -0
  393. package/dist/src/utils/validation/network.d.ts.map +1 -0
  394. package/dist/src/utils/validation/network.js +93 -0
  395. package/dist/src/utils/validation/network.js.map +1 -0
  396. package/dist/src/utils/validation/rateLimit.d.ts +21 -0
  397. package/dist/src/utils/validation/rateLimit.d.ts.map +1 -0
  398. package/dist/src/utils/validation/rateLimit.js +43 -0
  399. package/dist/src/utils/validation/rateLimit.js.map +1 -0
  400. package/dist/src/utils/validation/security.d.ts +29 -0
  401. package/dist/src/utils/validation/security.d.ts.map +1 -0
  402. package/dist/src/utils/validation/security.js +327 -0
  403. package/dist/src/utils/validation/security.js.map +1 -0
  404. package/dist/src/utils/validation/wordpress.d.ts +31 -0
  405. package/dist/src/utils/validation/wordpress.d.ts.map +1 -0
  406. package/dist/src/utils/validation/wordpress.js +146 -0
  407. package/dist/src/utils/validation/wordpress.js.map +1 -0
  408. package/dist/src/utils/validation.d.ts +15 -0
  409. package/dist/src/utils/validation.d.ts.map +1 -0
  410. package/dist/src/utils/validation.js +27 -0
  411. package/dist/src/utils/validation.js.map +1 -0
  412. package/dist/tests/vitest.setup.d.ts +6 -0
  413. package/dist/tests/vitest.setup.d.ts.map +1 -0
  414. package/dist/tests/vitest.setup.js +39 -0
  415. package/dist/tests/vitest.setup.js.map +1 -0
  416. package/dist/tools/BaseToolManager.d.ts +47 -11
  417. package/dist/tools/BaseToolManager.d.ts.map +1 -1
  418. package/dist/tools/BaseToolManager.js +168 -29
  419. package/dist/tools/BaseToolManager.js.map +1 -1
  420. package/dist/tools/auth.d.ts +16 -10
  421. package/dist/tools/auth.d.ts.map +1 -1
  422. package/dist/tools/auth.js +3 -2
  423. package/dist/tools/auth.js.map +1 -1
  424. package/dist/tools/cache.d.ts +30 -30
  425. package/dist/tools/cache.d.ts.map +1 -1
  426. package/dist/tools/cache.js +1 -6
  427. package/dist/tools/cache.js.map +1 -1
  428. package/dist/tools/comments.d.ts +20 -20
  429. package/dist/tools/comments.d.ts.map +1 -1
  430. package/dist/tools/comments.js +16 -9
  431. package/dist/tools/comments.js.map +1 -1
  432. package/dist/tools/media.d.ts +18 -16
  433. package/dist/tools/media.d.ts.map +1 -1
  434. package/dist/tools/media.js +16 -15
  435. package/dist/tools/media.js.map +1 -1
  436. package/dist/tools/pages.d.ts +19 -17
  437. package/dist/tools/pages.d.ts.map +1 -1
  438. package/dist/tools/pages.js +16 -12
  439. package/dist/tools/pages.js.map +1 -1
  440. package/dist/tools/performance.d.ts +11 -1
  441. package/dist/tools/performance.d.ts.map +1 -1
  442. package/dist/tools/performance.js +67 -34
  443. package/dist/tools/performance.js.map +1 -1
  444. package/dist/tools/posts/PostHandlers.d.ts +46 -0
  445. package/dist/tools/posts/PostHandlers.d.ts.map +1 -0
  446. package/dist/tools/posts/PostHandlers.js +400 -0
  447. package/dist/tools/posts/PostHandlers.js.map +1 -0
  448. package/dist/tools/posts/PostToolDefinitions.d.ts +37 -0
  449. package/dist/tools/posts/PostToolDefinitions.d.ts.map +1 -0
  450. package/dist/tools/posts/PostToolDefinitions.js +236 -0
  451. package/dist/tools/posts/PostToolDefinitions.js.map +1 -0
  452. package/dist/tools/posts/index.d.ts +138 -0
  453. package/dist/tools/posts/index.d.ts.map +1 -0
  454. package/dist/tools/posts/index.js +163 -0
  455. package/dist/tools/posts/index.js.map +1 -0
  456. package/dist/tools/posts.d.ts +10 -246
  457. package/dist/tools/posts.d.ts.map +1 -1
  458. package/dist/tools/posts.js +11 -723
  459. package/dist/tools/posts.js.map +1 -1
  460. package/dist/tools/site.d.ts +19 -18
  461. package/dist/tools/site.d.ts.map +1 -1
  462. package/dist/tools/site.js +14 -10
  463. package/dist/tools/site.js.map +1 -1
  464. package/dist/tools/taxonomies.d.ts +23 -24
  465. package/dist/tools/taxonomies.d.ts.map +1 -1
  466. package/dist/tools/taxonomies.js +24 -18
  467. package/dist/tools/taxonomies.js.map +1 -1
  468. package/dist/tools/users.d.ts +20 -15
  469. package/dist/tools/users.d.ts.map +1 -1
  470. package/dist/tools/users.js +12 -8
  471. package/dist/tools/users.js.map +1 -1
  472. package/dist/types/client.d.ts +48 -41
  473. package/dist/types/client.d.ts.map +1 -1
  474. package/dist/types/client.js +30 -5
  475. package/dist/types/client.js.map +1 -1
  476. package/dist/types/enhanced.d.ts +237 -0
  477. package/dist/types/enhanced.d.ts.map +1 -0
  478. package/dist/types/enhanced.js +49 -0
  479. package/dist/types/enhanced.js.map +1 -0
  480. package/dist/types/index.d.ts +15 -12
  481. package/dist/types/index.d.ts.map +1 -1
  482. package/dist/types/index.js +2 -0
  483. package/dist/types/index.js.map +1 -1
  484. package/dist/types/mcp.d.ts +12 -12
  485. package/dist/types/mcp.d.ts.map +1 -1
  486. package/dist/types/requests.d.ts +322 -0
  487. package/dist/types/requests.d.ts.map +1 -0
  488. package/dist/types/requests.js +8 -0
  489. package/dist/types/requests.js.map +1 -0
  490. package/dist/types/tools.d.ts +506 -0
  491. package/dist/types/tools.d.ts.map +1 -0
  492. package/dist/types/tools.js +8 -0
  493. package/dist/types/tools.js.map +1 -0
  494. package/dist/types/wordpress.d.ts +43 -15
  495. package/dist/types/wordpress.d.ts.map +1 -1
  496. package/dist/types/wordpress.js +8 -1
  497. package/dist/types/wordpress.js.map +1 -1
  498. package/dist/utils/debug.d.ts +19 -11
  499. package/dist/utils/debug.d.ts.map +1 -1
  500. package/dist/utils/debug.js +46 -10
  501. package/dist/utils/debug.js.map +1 -1
  502. package/dist/utils/enhancedError.d.ts +8 -8
  503. package/dist/utils/enhancedError.d.ts.map +1 -1
  504. package/dist/utils/enhancedError.js.map +1 -1
  505. package/dist/utils/error.d.ts +2 -4
  506. package/dist/utils/error.d.ts.map +1 -1
  507. package/dist/utils/error.js +42 -5
  508. package/dist/utils/error.js.map +1 -1
  509. package/dist/utils/logger.d.ts +106 -0
  510. package/dist/utils/logger.d.ts.map +1 -0
  511. package/dist/utils/logger.js +280 -0
  512. package/dist/utils/logger.js.map +1 -0
  513. package/dist/utils/streaming.d.ts +9 -9
  514. package/dist/utils/streaming.d.ts.map +1 -1
  515. package/dist/utils/streaming.js +71 -52
  516. package/dist/utils/streaming.js.map +1 -1
  517. package/dist/utils/toolWrapper.d.ts +9 -7
  518. package/dist/utils/toolWrapper.d.ts.map +1 -1
  519. package/dist/utils/toolWrapper.js.map +1 -1
  520. package/dist/utils/validation/core.d.ts +21 -0
  521. package/dist/utils/validation/core.d.ts.map +1 -0
  522. package/dist/utils/validation/core.js +71 -0
  523. package/dist/utils/validation/core.js.map +1 -0
  524. package/dist/utils/validation/index.d.ts +25 -0
  525. package/dist/utils/validation/index.d.ts.map +1 -0
  526. package/dist/utils/validation/index.js +29 -0
  527. package/dist/utils/validation/index.js.map +1 -0
  528. package/dist/utils/validation/network.d.ts +19 -0
  529. package/dist/utils/validation/network.d.ts.map +1 -0
  530. package/dist/utils/validation/network.js +93 -0
  531. package/dist/utils/validation/network.js.map +1 -0
  532. package/dist/utils/validation/rateLimit.d.ts +21 -0
  533. package/dist/utils/validation/rateLimit.d.ts.map +1 -0
  534. package/dist/utils/validation/rateLimit.js +43 -0
  535. package/dist/utils/validation/rateLimit.js.map +1 -0
  536. package/dist/utils/validation/security.d.ts +29 -0
  537. package/dist/utils/validation/security.d.ts.map +1 -0
  538. package/dist/utils/validation/security.js +327 -0
  539. package/dist/utils/validation/security.js.map +1 -0
  540. package/dist/utils/validation/wordpress.d.ts +31 -0
  541. package/dist/utils/validation/wordpress.d.ts.map +1 -0
  542. package/dist/utils/validation/wordpress.js +146 -0
  543. package/dist/utils/validation/wordpress.js.map +1 -0
  544. package/dist/utils/validation.d.ts +13 -82
  545. package/dist/utils/validation.d.ts.map +1 -1
  546. package/dist/utils/validation.js +25 -343
  547. package/dist/utils/validation.js.map +1 -1
  548. package/docs/BADGE_UPDATES.md +132 -0
  549. package/docs/CI_CD_IMPROVEMENTS.md +191 -0
  550. package/docs/INCREMENTAL_COVERAGE.md +183 -0
  551. package/docs/INSTALLATION.md +4 -2
  552. package/docs/TROUBLESHOOTING.md +2 -1
  553. package/docs/api/README.md +3 -1
  554. package/docs/api/openapi.json +5 -1
  555. package/docs/api/summary.json +1 -1
  556. package/docs/api/tools/wp_create_post.md +12 -14
  557. package/docs/developer/TESTING.md +24 -19
  558. package/docs/examples/claude-desktop-config.md +1 -1
  559. package/docs/examples/docker-production.md +100 -93
  560. package/docs/examples/multi-site-setup.md +5 -4
  561. package/docs/examples/single-site-setup.md +3 -4
  562. package/docs/examples/use-case-workflows.md +4 -5
  563. package/docs/integrations/claude-desktop.md +39 -34
  564. package/docs/integrations/cline.md +4 -4
  565. package/docs/integrations/vs-code.md +9 -8
  566. package/docs/user-guides/DXT_INSTALLATION.md +2 -1
  567. package/docs/user-guides/SMITHERY_SETUP.md +10 -10
  568. package/package.json +57 -39
  569. package/src/cache/CacheInvalidation.ts +12 -5
  570. package/src/cache/CacheManager.ts +18 -15
  571. package/src/cache/HttpCacheWrapper.ts +30 -59
  572. package/src/cache/__tests__/HttpCacheWrapper.test.ts +6 -5
  573. package/src/cache/index.ts +3 -14
  574. package/src/client/CachedWordPressClient.ts +32 -30
  575. package/src/client/MockWordPressClient.ts +4 -2
  576. package/src/client/api.ts +186 -64
  577. package/src/client/auth.ts +15 -40
  578. package/src/client/managers/AuthenticationManager.ts +337 -77
  579. package/src/client/managers/BaseManager.ts +18 -30
  580. package/src/client/managers/RequestManager.ts +39 -44
  581. package/src/config/Config.ts +308 -0
  582. package/src/config/ConfigurationSchema.ts +23 -2
  583. package/src/config/ServerConfiguration.ts +73 -49
  584. package/src/docs/DocumentationGenerator.ts +50 -39
  585. package/src/docs/MarkdownFormatter.ts +19 -29
  586. package/src/dxt-entry.cjs +26 -16
  587. package/src/dxt-entry.ts +17 -27
  588. package/src/index.ts +42 -28
  589. package/src/performance/MetricsCollector.ts +108 -86
  590. package/src/performance/PerformanceAnalytics.ts +69 -164
  591. package/src/performance/PerformanceMonitor.ts +32 -47
  592. package/src/performance/index.ts +2 -10
  593. package/src/security/AISecurityScanner.ts +22 -12
  594. package/src/security/AutomatedRemediation.ts +49 -18
  595. package/src/security/InputValidator.ts +9 -6
  596. package/src/security/SecurityCIPipeline.ts +53 -37
  597. package/src/security/SecurityConfig.ts +22 -22
  598. package/src/security/SecurityConfigManager.ts +23 -19
  599. package/src/security/SecurityMonitoring.ts +24 -21
  600. package/src/security/SecurityReviewer.ts +10 -7
  601. package/src/security/index.ts +64 -29
  602. package/src/server/ConnectionTester.ts +120 -31
  603. package/src/server/ToolRegistry.ts +31 -21
  604. package/src/tools/BaseToolManager.ts +286 -33
  605. package/src/tools/auth.ts +20 -8
  606. package/src/tools/cache.ts +5 -15
  607. package/src/tools/comments.ts +34 -48
  608. package/src/tools/media.ts +41 -53
  609. package/src/tools/pages.ts +32 -54
  610. package/src/tools/performance.ts +141 -176
  611. package/src/tools/posts/PostHandlers.ts +474 -0
  612. package/src/tools/posts/PostToolDefinitions.ts +250 -0
  613. package/src/tools/posts/index.ts +192 -0
  614. package/src/tools/posts.ts +24 -780
  615. package/src/tools/site.ts +34 -19
  616. package/src/tools/taxonomies.ts +41 -57
  617. package/src/tools/users.ts +28 -16
  618. package/src/types/client.ts +114 -138
  619. package/src/types/enhanced.ts +318 -0
  620. package/src/types/index.ts +51 -30
  621. package/src/types/mcp.ts +20 -42
  622. package/src/types/requests.ts +378 -0
  623. package/src/types/tools.ts +608 -0
  624. package/src/types/wordpress.ts +56 -34
  625. package/src/utils/debug.ts +77 -59
  626. package/src/utils/enhancedError.ts +8 -8
  627. package/src/utils/error.ts +53 -31
  628. package/src/utils/logger.ts +351 -0
  629. package/src/utils/streaming.ts +86 -68
  630. package/src/utils/toolWrapper.ts +10 -12
  631. package/src/utils/validation/core.ts +108 -0
  632. package/src/utils/validation/index.ts +36 -0
  633. package/src/utils/validation/network.ts +132 -0
  634. package/src/utils/validation/rateLimit.ts +54 -0
  635. package/src/utils/validation/security.ts +361 -0
  636. package/src/utils/validation/wordpress.ts +180 -0
  637. package/src/utils/validation.ts +47 -470
  638. package/dist/cache/__tests__/CacheInvalidation.test.d.ts +0 -5
  639. package/dist/cache/__tests__/CacheInvalidation.test.d.ts.map +0 -1
  640. package/dist/cache/__tests__/CacheInvalidation.test.js +0 -238
  641. package/dist/cache/__tests__/CacheInvalidation.test.js.map +0 -1
  642. package/dist/cache/__tests__/CacheManager.test.d.ts +0 -5
  643. package/dist/cache/__tests__/CacheManager.test.d.ts.map +0 -1
  644. package/dist/cache/__tests__/CacheManager.test.js +0 -233
  645. package/dist/cache/__tests__/CacheManager.test.js.map +0 -1
  646. package/dist/cache/__tests__/CachedWordPressClient.test.d.ts +0 -5
  647. package/dist/cache/__tests__/CachedWordPressClient.test.d.ts.map +0 -1
  648. package/dist/cache/__tests__/CachedWordPressClient.test.js +0 -231
  649. package/dist/cache/__tests__/CachedWordPressClient.test.js.map +0 -1
  650. package/dist/cache/__tests__/HttpCacheWrapper.test.d.ts +0 -5
  651. package/dist/cache/__tests__/HttpCacheWrapper.test.d.ts.map +0 -1
  652. package/dist/cache/__tests__/HttpCacheWrapper.test.js +0 -299
  653. package/dist/cache/__tests__/HttpCacheWrapper.test.js.map +0 -1
@@ -1,728 +1,16 @@
1
- import { getErrorMessage } from "../utils/error.js";
2
- import { ErrorHandlers, EnhancedError } from "../utils/enhancedError.js";
3
- import { validateId, validatePaginationParams, validatePostParams } from "../utils/validation.js";
4
- import { WordPressDataStreamer, StreamingUtils } from "../utils/streaming.js";
5
1
  /**
6
- * Provides comprehensive tools for managing WordPress posts.
2
+ * WordPress Posts Tools - Legacy Import Module
7
3
  *
8
- * This class encapsulates tool definitions and their corresponding handlers for:
9
- * - Listing posts with advanced filtering and search capabilities
10
- * - Creating new posts with full metadata support
11
- * - Updating existing posts with validation
12
- * - Deleting posts with trash/permanent options
13
- * - Retrieving individual posts with detailed information
14
- * - Managing post revisions and history
4
+ * This file maintains backward compatibility while the codebase transitions
5
+ * to the new modular structure. The actual implementation has been refactored
6
+ * into focused modules under ./posts/ directory.
15
7
  *
16
- * @example
17
- * ```typescript
18
- * const postTools = new PostTools();
19
- * const tools = postTools.getTools();
20
- *
21
- * // Use with a WordPress client
22
- * const client = new WordPressClient(config);
23
- * const result = await postTools.handleListPosts(client, { per_page: 10 });
24
- * ```
25
- *
26
- * @since 1.0.0
27
- * @author MCP WordPress Team
8
+ * @deprecated Use direct imports from ./posts/ modules instead
9
+ * @see ./posts/index.ts for the new modular implementation
28
10
  */
29
- export class PostTools {
30
- /**
31
- * Retrieves the complete list of post management tools available for MCP.
32
- *
33
- * Returns an array of tool definitions that can be registered with an MCP server.
34
- * Each tool includes comprehensive parameter validation, error handling, and
35
- * detailed documentation with usage examples.
36
- *
37
- * @returns {Array<MCPTool>} An array of MCPTool definitions for post management
38
- *
39
- * @example
40
- * ```typescript
41
- * const postTools = new PostTools();
42
- * const tools = postTools.getTools();
43
- * console.log(tools.length); // 6 tools: list, get, create, update, delete, revisions
44
- * ```
45
- */
46
- getTools() {
47
- return [
48
- {
49
- name: "wp_list_posts",
50
- description: "Lists posts from a WordPress site with comprehensive filtering options. Supports search, status filtering, and category/tag filtering with enhanced metadata display.\n\n" +
51
- "**Usage Examples:**\n" +
52
- "• Basic listing: `wp_list_posts`\n" +
53
- '• Search posts: `wp_list_posts --search="AI trends"`\n' +
54
- '• Filter by status: `wp_list_posts --status="draft"`\n' +
55
- "• Category filtering: `wp_list_posts --categories=[1,2,3]`\n" +
56
- "• Paginated results: `wp_list_posts --per_page=20 --page=2`\n" +
57
- '• Combined filters: `wp_list_posts --search="WordPress" --status="publish" --per_page=10`',
58
- parameters: [
59
- {
60
- name: "per_page",
61
- type: "number",
62
- description: "Number of items to return per page (max 100).",
63
- },
64
- {
65
- name: "search",
66
- type: "string",
67
- description: "Limit results to those matching a search term.",
68
- },
69
- {
70
- name: "status",
71
- type: "string",
72
- description: "Filter by post status.",
73
- enum: ["publish", "future", "draft", "pending", "private"],
74
- },
75
- {
76
- name: "categories",
77
- type: "array",
78
- items: { type: "number" },
79
- description: "Limit results to posts in specific category IDs.",
80
- },
81
- {
82
- name: "tags",
83
- type: "array",
84
- items: { type: "number" },
85
- description: "Limit results to posts with specific tag IDs.",
86
- },
87
- ],
88
- handler: this.handleListPosts.bind(this),
89
- },
90
- {
91
- name: "wp_get_post",
92
- description: "Retrieves detailed information about a single post including metadata, content statistics, and management links.",
93
- parameters: [
94
- {
95
- name: "id",
96
- type: "number",
97
- required: true,
98
- description: "The unique identifier for the post.",
99
- },
100
- ],
101
- handler: this.handleGetPost.bind(this),
102
- },
103
- {
104
- name: "wp_create_post",
105
- description: "Creates a new WordPress post with comprehensive validation and detailed success feedback including management links.\n\n" +
106
- "**Usage Examples:**\n" +
107
- '• Simple post: `wp_create_post --title="My New Post" --content="<p>Hello World!</p>"`\n' +
108
- '• Draft post: `wp_create_post --title="Draft Post" --status="draft"`\n' +
109
- '• Categorized post: `wp_create_post --title="Tech News" --categories=[1,5] --tags=[10,20]`\n' +
110
- '• Scheduled post: `wp_create_post --title="Future Post" --status="future" --date="2024-12-25T10:00:00"`\n' +
111
- '• Complete post: `wp_create_post --title="Complete Post" --content="<p>Content</p>" --excerpt="Summary" --status="publish"`',
112
- parameters: [
113
- {
114
- name: "title",
115
- type: "string",
116
- required: true,
117
- description: "The title for the post.",
118
- },
119
- {
120
- name: "content",
121
- type: "string",
122
- description: "The content for the post, in HTML format.",
123
- },
124
- {
125
- name: "status",
126
- type: "string",
127
- description: "The publishing status for the post.",
128
- enum: ["publish", "draft", "pending", "private"],
129
- },
130
- {
131
- name: "excerpt",
132
- type: "string",
133
- description: "The excerpt for the post.",
134
- },
135
- {
136
- name: "categories",
137
- type: "array",
138
- items: { type: "number" },
139
- description: "An array of category IDs to assign to the post.",
140
- },
141
- {
142
- name: "tags",
143
- type: "array",
144
- items: { type: "number" },
145
- description: "An array of tag IDs to assign to the post.",
146
- },
147
- ],
148
- handler: this.handleCreatePost.bind(this),
149
- },
150
- {
151
- name: "wp_update_post",
152
- description: "Updates an existing WordPress post with validation and detailed confirmation.",
153
- parameters: [
154
- {
155
- name: "id",
156
- type: "number",
157
- required: true,
158
- description: "The ID of the post to update.",
159
- },
160
- {
161
- name: "title",
162
- type: "string",
163
- description: "The new title for the post.",
164
- },
165
- {
166
- name: "content",
167
- type: "string",
168
- description: "The new content for the post, in HTML format.",
169
- },
170
- {
171
- name: "status",
172
- type: "string",
173
- description: "The new status for the post.",
174
- enum: ["publish", "draft", "pending", "private"],
175
- },
176
- ],
177
- handler: this.handleUpdatePost.bind(this),
178
- },
179
- {
180
- name: "wp_delete_post",
181
- description: "Deletes a WordPress post with option for permanent deletion or moving to trash.",
182
- parameters: [
183
- {
184
- name: "id",
185
- type: "number",
186
- required: true,
187
- description: "The ID of the post to delete.",
188
- },
189
- {
190
- name: "force",
191
- type: "boolean",
192
- description: "If true, permanently delete. If false, move to trash. Defaults to false.",
193
- },
194
- ],
195
- handler: this.handleDeletePost.bind(this),
196
- },
197
- {
198
- name: "wp_get_post_revisions",
199
- description: "Retrieves the revision history for a specific post showing author and modification dates.",
200
- parameters: [
201
- {
202
- name: "id",
203
- type: "number",
204
- required: true,
205
- description: "The ID of the post to get revisions for.",
206
- },
207
- ],
208
- handler: this.handleGetPostRevisions.bind(this),
209
- },
210
- ];
211
- }
212
- /**
213
- * Handles listing posts from a WordPress site with comprehensive filtering options.
214
- *
215
- * This method provides advanced search capabilities, status filtering, pagination,
216
- * and category/tag filtering. Results include enhanced metadata and author information.
217
- * For large result sets (>50 posts), it automatically uses streaming for better performance.
218
- *
219
- * @param {WordPressClient} client - The WordPress client instance for API communication
220
- * @param {PostQueryParams} params - Query parameters for filtering and pagination
221
- * @param {number} [params.per_page=10] - Number of posts to return per page (max 100)
222
- * @param {string} [params.search] - Search term to filter posts by title/content
223
- * @param {string|string[]} [params.status] - Post status filter (publish, draft, etc.)
224
- * @param {number[]} [params.categories] - Array of category IDs to filter by
225
- * @param {number[]} [params.tags] - Array of tag IDs to filter by
226
- * @param {number} [params.page=1] - Page number for pagination
227
- *
228
- * @returns {Promise<string>} Formatted list of posts with metadata and context
229
- *
230
- * @throws {EnhancedError} When validation fails or API request encounters an error
231
- *
232
- * @example
233
- * ```typescript
234
- * // Basic listing
235
- * const result = await handleListPosts(client, {});
236
- *
237
- * // Advanced filtering
238
- * const filtered = await handleListPosts(client, {
239
- * search: "WordPress tips",
240
- * status: "publish",
241
- * categories: [1, 2],
242
- * per_page: 20
243
- * });
244
- * ```
245
- *
246
- * @since 1.0.0
247
- */
248
- async handleListPosts(client, params) {
249
- try {
250
- // Enhanced input validation and sanitization
251
- const paginationValidated = validatePaginationParams({
252
- page: params.page,
253
- per_page: params.per_page,
254
- offset: params.offset,
255
- });
256
- const sanitizedParams = {
257
- ...params,
258
- ...paginationValidated,
259
- };
260
- // Validate and sanitize search term
261
- if (sanitizedParams.search) {
262
- sanitizedParams.search = sanitizedParams.search.trim();
263
- if (sanitizedParams.search.length === 0) {
264
- delete sanitizedParams.search;
265
- }
266
- }
267
- // Validate category and tag IDs if provided
268
- if (sanitizedParams.categories) {
269
- sanitizedParams.categories = sanitizedParams.categories.map((id) => validateId(id, "category ID"));
270
- }
271
- if (sanitizedParams.tags) {
272
- sanitizedParams.tags = sanitizedParams.tags.map((id) => validateId(id, "tag ID"));
273
- }
274
- // Validate status parameter
275
- if (sanitizedParams.status) {
276
- const validStatuses = ["publish", "future", "draft", "pending", "private"];
277
- const statusesToCheck = Array.isArray(sanitizedParams.status)
278
- ? sanitizedParams.status
279
- : [sanitizedParams.status];
280
- for (const statusToCheck of statusesToCheck) {
281
- if (!validStatuses.includes(statusToCheck)) {
282
- throw ErrorHandlers.validationError("status", statusToCheck, "one of: " + validStatuses.join(", "));
283
- }
284
- }
285
- }
286
- // Performance optimization: set reasonable defaults
287
- if (!sanitizedParams.per_page) {
288
- sanitizedParams.per_page = 10; // Default to 10 posts for better performance
289
- }
290
- const posts = await client.getPosts(sanitizedParams);
291
- if (posts.length === 0) {
292
- const searchInfo = sanitizedParams.search ? ` matching "${sanitizedParams.search}"` : "";
293
- const statusInfo = sanitizedParams.status ? ` with status "${sanitizedParams.status}"` : "";
294
- return `No posts found${searchInfo}${statusInfo}. Try adjusting your search criteria or check if posts exist.`;
295
- }
296
- // Use streaming for large result sets (>50 posts)
297
- if (posts.length > 50) {
298
- const streamResults = [];
299
- for await (const result of WordPressDataStreamer.streamPosts(posts, {
300
- includeAuthor: true,
301
- includeCategories: true,
302
- includeTags: true,
303
- batchSize: 20,
304
- })) {
305
- streamResults.push(result);
306
- }
307
- return StreamingUtils.formatStreamingResponse(streamResults, "posts");
308
- }
309
- // Add comprehensive site context information
310
- const siteUrl = client.getSiteUrl ? client.getSiteUrl() : "Unknown site";
311
- const totalPosts = posts.length;
312
- const statusCounts = posts.reduce((acc, p) => {
313
- acc[p.status] = (acc[p.status] || 0) + 1;
314
- return acc;
315
- }, {});
316
- // Enhanced metadata
317
- const metadata = [
318
- `📊 **Posts Summary**: ${totalPosts} total`,
319
- `📝 **Status Breakdown**: ${Object.entries(statusCounts)
320
- .map(([status, count]) => `${status}: ${count}`)
321
- .join(", ")}`,
322
- `🌐 **Source**: ${siteUrl}`,
323
- `📅 **Retrieved**: ${new Date().toLocaleString()}`,
324
- ...(params.search ? [`🔍 **Search Term**: "${params.search}"`] : []),
325
- ...(params.categories ? [`📁 **Categories**: ${params.categories.join(", ")}`] : []),
326
- ...(params.tags ? [`🏷️ **Tags**: ${params.tags.join(", ")}`] : []),
327
- ];
328
- // Fetch additional metadata for enhanced responses
329
- const authorIds = [...new Set(posts.map((p) => p.author).filter(Boolean))];
330
- const categoryIds = [...new Set(posts.flatMap((p) => p.categories || []))];
331
- const tagIds = [...new Set(posts.flatMap((p) => p.tags || []))];
332
- // Fetch authors, categories, and tags in parallel for better performance
333
- const [authors, categories, tags] = await Promise.all([
334
- authorIds.length > 0
335
- ? Promise.all(authorIds.map(async (id) => {
336
- try {
337
- const user = await client.getUser(id);
338
- return { id, name: user.name || user.username || `User ${id}` };
339
- }
340
- catch {
341
- return { id, name: `User ${id}` };
342
- }
343
- }))
344
- : [],
345
- categoryIds.length > 0
346
- ? Promise.all(categoryIds.map(async (id) => {
347
- try {
348
- const category = await client.getCategory(id);
349
- return { id, name: category.name || `Category ${id}` };
350
- }
351
- catch {
352
- return { id, name: `Category ${id}` };
353
- }
354
- }))
355
- : [],
356
- tagIds.length > 0
357
- ? Promise.all(tagIds.map(async (id) => {
358
- try {
359
- const tag = await client.getTag(id);
360
- return { id, name: tag.name || `Tag ${id}` };
361
- }
362
- catch {
363
- return { id, name: `Tag ${id}` };
364
- }
365
- }))
366
- : [],
367
- ]);
368
- // Create lookup maps for performance
369
- const authorMap = new Map(authors.map((a) => [a.id, a.name]));
370
- const categoryMap = new Map(categories.map((c) => [c.id, c.name]));
371
- const tagMap = new Map(tags.map((t) => [t.id, t.name]));
372
- const content = metadata.join("\n") +
373
- "\n\n" +
374
- posts
375
- .map((p) => {
376
- const date = new Date(p.date);
377
- const formattedDate = date.toLocaleDateString("en-US", {
378
- year: "numeric",
379
- month: "short",
380
- day: "numeric",
381
- });
382
- const excerpt = p.excerpt?.rendered
383
- ? p.excerpt.rendered.replace(/<[^>]*>/g, "").substring(0, 80) + "..."
384
- : "";
385
- // Enhanced metadata
386
- const authorName = authorMap.get(p.author) || `User ${p.author}`;
387
- const postCategories = (p.categories || []).map((id) => categoryMap.get(id) || `Category ${id}`);
388
- const postTags = (p.tags || []).map((id) => tagMap.get(id) || `Tag ${id}`);
389
- let postInfo = `- ID ${p.id}: **${p.title.rendered}** (${p.status})\n`;
390
- postInfo += ` 👤 Author: ${authorName}\n`;
391
- postInfo += ` 📅 Published: ${formattedDate}\n`;
392
- if (postCategories.length > 0) {
393
- postInfo += ` 📁 Categories: ${postCategories.join(", ")}\n`;
394
- }
395
- if (postTags.length > 0) {
396
- postInfo += ` 🏷️ Tags: ${postTags.join(", ")}\n`;
397
- }
398
- if (excerpt) {
399
- postInfo += ` 📝 Excerpt: ${excerpt}\n`;
400
- }
401
- postInfo += ` 🔗 Link: ${p.link}`;
402
- return postInfo;
403
- })
404
- .join("\n\n");
405
- // Add pagination guidance for large result sets
406
- let finalContent = content;
407
- if (posts.length >= (sanitizedParams.per_page || 10)) {
408
- finalContent += `\n\n📄 **Pagination Tip**: Use \`per_page\` parameter to control results (max 100). Current: ${sanitizedParams.per_page || 10}`;
409
- }
410
- return finalContent;
411
- }
412
- catch (error) {
413
- throw new Error(`Failed to list posts: ${getErrorMessage(error)}`);
414
- }
415
- }
416
- /**
417
- * Retrieves a single WordPress post by ID with complete details and metadata.
418
- *
419
- * This method fetches a specific post and returns comprehensive information including
420
- * content, metadata, author details, categories, tags, and publication status.
421
- *
422
- * @param {WordPressClient} client - The WordPress client instance for API communication
423
- * @param {Object} params - Parameters for post retrieval
424
- * @param {number} params.id - The unique ID of the post to retrieve
425
- *
426
- * @returns {Promise<string>} Detailed post information formatted for display
427
- *
428
- * @throws {EnhancedError} When post ID is invalid or post is not found
429
- *
430
- * @example
431
- * ```typescript
432
- * // Get a specific post
433
- * const post = await handleGetPost(client, { id: 123 });
434
- * ```
435
- *
436
- * @since 1.0.0
437
- */
438
- async handleGetPost(client, params) {
439
- try {
440
- // Input validation
441
- if (!params.id || typeof params.id !== "number" || params.id <= 0) {
442
- throw ErrorHandlers.validationError("id", params.id, "positive integer");
443
- }
444
- const post = await client.getPost(params.id);
445
- // Fetch additional metadata for enhanced response
446
- const [author, categories, tags] = await Promise.all([
447
- post.author
448
- ? (async () => {
449
- try {
450
- const user = await client.getUser(post.author);
451
- return user.name || user.username || `User ${post.author}`;
452
- }
453
- catch {
454
- return `User ${post.author}`;
455
- }
456
- })()
457
- : "Unknown",
458
- post.categories && post.categories.length > 0
459
- ? Promise.all(post.categories.map(async (id) => {
460
- try {
461
- const category = await client.getCategory(id);
462
- return category.name || `Category ${id}`;
463
- }
464
- catch {
465
- return `Category ${id}`;
466
- }
467
- }))
468
- : [],
469
- post.tags && post.tags.length > 0
470
- ? Promise.all(post.tags.map(async (id) => {
471
- try {
472
- const tag = await client.getTag(id);
473
- return tag.name || `Tag ${id}`;
474
- }
475
- catch {
476
- return `Tag ${id}`;
477
- }
478
- }))
479
- : [],
480
- ]);
481
- // Enhanced post details with comprehensive metadata
482
- const siteUrl = client.getSiteUrl ? client.getSiteUrl() : "Unknown site";
483
- const publishedDate = new Date(post.date);
484
- const modifiedDate = new Date(post.modified);
485
- const excerpt = post.excerpt?.rendered
486
- ? post.excerpt.rendered.replace(/<[^>]*>/g, "").substring(0, 150) + "..."
487
- : "No excerpt available";
488
- const wordCount = post.content?.rendered ? post.content.rendered.replace(/<[^>]*>/g, "").split(/\s+/).length : 0;
489
- let content = `**📄 Post Details (ID: ${post.id})**\n\n`;
490
- content += `**📋 Basic Information:**\n`;
491
- content += `- **Title:** ${post.title.rendered}\n`;
492
- content += `- **Status:** ${post.status}\n`;
493
- content += `- **Type:** ${post.type}\n`;
494
- content += `- **Author:** ${author}\n`;
495
- content += `- **Slug:** ${post.slug}\n\n`;
496
- content += `**📅 Dates:**\n`;
497
- content += `- **Published:** ${publishedDate.toLocaleString()}\n`;
498
- content += `- **Modified:** ${modifiedDate.toLocaleString()}\n\n`;
499
- content += `**📊 Content:**\n`;
500
- content += `- **Word Count:** ~${wordCount} words\n`;
501
- content += `- **Excerpt:** ${excerpt}\n\n`;
502
- if (categories.length > 0) {
503
- content += `**📁 Categories:** ${categories.join(", ")}\n`;
504
- }
505
- if (tags.length > 0) {
506
- content += `**🏷️ Tags:** ${tags.join(", ")}\n`;
507
- }
508
- if (categories.length > 0 || tags.length > 0) {
509
- content += `\n`;
510
- }
511
- content += `**🔗 Links:**\n`;
512
- content += `- **Permalink:** ${post.link}\n`;
513
- content += `- **Edit Link:** ${post.link.replace(/\/$/, "")}/wp-admin/post.php?post=${post.id}&action=edit\n\n`;
514
- content += `**🌐 Source:** ${siteUrl}\n`;
515
- content += `**📅 Retrieved:** ${new Date().toLocaleString()}`;
516
- return content;
517
- }
518
- catch (error) {
519
- // Handle specific error cases
520
- const errorMessage = getErrorMessage(error);
521
- if (errorMessage.includes("Invalid post ID") || errorMessage.includes("not found")) {
522
- throw ErrorHandlers.postNotFound(params.id, error);
523
- }
524
- if (errorMessage.includes("401") || errorMessage.includes("Unauthorized")) {
525
- throw ErrorHandlers.authenticationFailed(error);
526
- }
527
- if (errorMessage.includes("403") || errorMessage.includes("Forbidden")) {
528
- throw ErrorHandlers.permissionDenied("get post", error);
529
- }
530
- if (errorMessage.includes("timeout") || errorMessage.includes("network")) {
531
- throw ErrorHandlers.connectionError(error);
532
- }
533
- // Generic error with suggestions
534
- throw ErrorHandlers.generic("get post", error);
535
- }
536
- }
537
- /**
538
- * Creates a new WordPress post with comprehensive validation and metadata support.
539
- *
540
- * This method handles the creation of new posts with full support for content,
541
- * metadata, categories, tags, and publishing options. Includes automatic validation
542
- * and sanitization of all input parameters.
543
- *
544
- * @param {WordPressClient} client - The WordPress client instance for API communication
545
- * @param {CreatePostRequest} params - Post creation parameters
546
- * @param {string} params.title - The post title
547
- * @param {string} params.content - The post content in HTML format
548
- * @param {string} [params.status="draft"] - Post status (publish, draft, pending, private)
549
- * @param {string} [params.excerpt] - Post excerpt/summary
550
- * @param {number[]} [params.categories] - Array of category IDs to assign
551
- * @param {number[]} [params.tags] - Array of tag IDs to assign
552
- *
553
- * @returns {Promise<string>} Success message with the new post ID and details
554
- *
555
- * @throws {EnhancedError} When validation fails or post creation encounters an error
556
- *
557
- * @example
558
- * ```typescript
559
- * // Create a basic post
560
- * const result = await handleCreatePost(client, {
561
- * title: "My New Post",
562
- * content: "<p>This is the post content.</p>",
563
- * status: "publish"
564
- * });
565
- *
566
- * // Create post with categories and tags
567
- * const detailed = await handleCreatePost(client, {
568
- * title: "WordPress Tips",
569
- * content: "<p>Detailed WordPress tips...</p>",
570
- * categories: [1, 2],
571
- * tags: [5, 6],
572
- * excerpt: "Learn essential WordPress tips"
573
- * });
574
- * ```
575
- *
576
- * @since 1.0.0
577
- */
578
- async handleCreatePost(client, params) {
579
- try {
580
- // Enhanced input validation using new validation utilities
581
- const validatedParams = validatePostParams(params);
582
- const post = await client.createPost(validatedParams);
583
- const siteUrl = client.getSiteUrl ? client.getSiteUrl() : "Unknown site";
584
- return (`✅ **Post Created Successfully!**\n\n` +
585
- `**📄 Post Details:**\n` +
586
- `- **ID:** ${post.id}\n` +
587
- `- **Title:** ${post.title.rendered}\n` +
588
- `- **Status:** ${post.status}\n` +
589
- `- **Link:** ${post.link}\n` +
590
- `- **Edit Link:** ${post.link.replace(/\/$/, "")}/wp-admin/post.php?post=${post.id}&action=edit\n\n` +
591
- `**🌐 Site:** ${siteUrl}\n` +
592
- `**📅 Created:** ${new Date().toLocaleString()}`);
593
- }
594
- catch (error) {
595
- if (error instanceof EnhancedError) {
596
- throw error;
597
- }
598
- throw new Error(`Failed to create post: ${getErrorMessage(error)}`);
599
- }
600
- }
601
- /**
602
- * Updates an existing WordPress post with validation and detailed confirmation.
603
- *
604
- * This method allows updating any aspect of a post including title, content, status,
605
- * categories, and tags. Only provided fields are updated, leaving others unchanged.
606
- *
607
- * @param {WordPressClient} client - The WordPress client instance for API communication
608
- * @param {UpdatePostRequest & {id: number}} params - Update parameters
609
- * @param {number} params.id - The ID of the post to update
610
- * @param {string} [params.title] - New post title
611
- * @param {string} [params.content] - New post content in HTML format
612
- * @param {string} [params.status] - New post status (publish, draft, pending, private)
613
- * @param {string} [params.excerpt] - New post excerpt
614
- * @param {number[]} [params.categories] - New category IDs to assign
615
- * @param {number[]} [params.tags] - New tag IDs to assign
616
- *
617
- * @returns {Promise<string>} Success message confirming the update
618
- *
619
- * @throws {EnhancedError} When post ID is invalid or update fails
620
- *
621
- * @example
622
- * ```typescript
623
- * // Update post title and status
624
- * const result = await handleUpdatePost(client, {
625
- * id: 123,
626
- * title: "Updated Post Title",
627
- * status: "publish"
628
- * });
629
- *
630
- * // Update content and categories
631
- * const updated = await handleUpdatePost(client, {
632
- * id: 123,
633
- * content: "<p>New content here...</p>",
634
- * categories: [1, 3, 5]
635
- * });
636
- * ```
637
- *
638
- * @since 1.0.0
639
- */
640
- async handleUpdatePost(client, params) {
641
- try {
642
- const post = await client.updatePost(params);
643
- return `✅ Post ${post.id} updated successfully.`;
644
- }
645
- catch (error) {
646
- throw new Error(`Failed to update post: ${getErrorMessage(error)}`);
647
- }
648
- }
649
- /**
650
- * Deletes a WordPress post with options for trash or permanent deletion.
651
- *
652
- * This method provides safe deletion with trash option (default) or permanent
653
- * deletion when force is specified. Includes confirmation of the deletion action.
654
- *
655
- * @param {WordPressClient} client - The WordPress client instance for API communication
656
- * @param {Object} params - Deletion parameters
657
- * @param {number} params.id - The ID of the post to delete
658
- * @param {boolean} [params.force=false] - Whether to permanently delete (true) or move to trash (false)
659
- *
660
- * @returns {Promise<string>} Confirmation message of the deletion action
661
- *
662
- * @throws {EnhancedError} When post ID is invalid or deletion fails
663
- *
664
- * @example
665
- * ```typescript
666
- * // Move post to trash (safe deletion)
667
- * const result = await handleDeletePost(client, { id: 123 });
668
- *
669
- * // Permanently delete post (cannot be undone)
670
- * const permanent = await handleDeletePost(client, {
671
- * id: 123,
672
- * force: true
673
- * });
674
- * ```
675
- *
676
- * @since 1.0.0
677
- */
678
- async handleDeletePost(client, params) {
679
- try {
680
- await client.deletePost(params.id, params.force);
681
- const action = params.force ? "permanently deleted" : "moved to trash";
682
- return `✅ Post ${params.id} has been ${action}.`;
683
- }
684
- catch (error) {
685
- throw new Error(`Failed to delete post: ${getErrorMessage(error)}`);
686
- }
687
- }
688
- /**
689
- * Retrieves revision history for a specific WordPress post.
690
- *
691
- * This method fetches all available revisions for a post, providing a complete
692
- * history of changes including dates, authors, and modification details.
693
- *
694
- * @param {WordPressClient} client - The WordPress client instance for API communication
695
- * @param {Object} params - Parameters for revision retrieval
696
- * @param {number} params.id - The ID of the post to get revisions for
697
- *
698
- * @returns {Promise<string>} Formatted list of post revisions with details
699
- *
700
- * @throws {EnhancedError} When post ID is invalid or revisions cannot be retrieved
701
- *
702
- * @example
703
- * ```typescript
704
- * // Get all revisions for a post
705
- * const revisions = await handleGetPostRevisions(client, { id: 123 });
706
- * ```
707
- *
708
- * @since 1.0.0
709
- */
710
- async handleGetPostRevisions(client, params) {
711
- try {
712
- const revisions = await client.getPostRevisions(params.id);
713
- if (revisions.length === 0) {
714
- return `No revisions found for post ${params.id}.`;
715
- }
716
- const content = `Found ${revisions.length} revisions for post ${params.id}:\n\n` +
717
- revisions
718
- .map((r) => `- Revision by user ID ${r.author} at ${new Date(r.modified).toLocaleString()}`)
719
- .join("\n");
720
- return content;
721
- }
722
- catch (error) {
723
- throw new Error(`Failed to get post revisions: ${getErrorMessage(error)}`);
724
- }
725
- }
726
- }
727
- export default PostTools;
11
+ // Re-export the refactored PostTools class for backward compatibility
12
+ export { PostTools as default, PostTools } from "./posts/index.js";
13
+ // Re-export specific components for granular imports
14
+ export { postToolDefinitions } from "./posts/PostToolDefinitions.js";
15
+ export { handleListPosts, handleGetPost, handleCreatePost, handleUpdatePost, handleDeletePost, handleGetPostRevisions, } from "./posts/PostHandlers.js";
728
16
  //# sourceMappingURL=posts.js.map