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.
- package/README.md +124 -54
- package/bin/status.js +1 -1
- package/dist/cache/CacheInvalidation.d.ts +3 -1
- package/dist/cache/CacheInvalidation.d.ts.map +1 -1
- package/dist/cache/CacheInvalidation.js +10 -4
- package/dist/cache/CacheInvalidation.js.map +1 -1
- package/dist/cache/CacheManager.d.ts +3 -2
- package/dist/cache/CacheManager.d.ts.map +1 -1
- package/dist/cache/CacheManager.js +11 -3
- package/dist/cache/CacheManager.js.map +1 -1
- package/dist/cache/HttpCacheWrapper.d.ts +7 -6
- package/dist/cache/HttpCacheWrapper.d.ts.map +1 -1
- package/dist/cache/HttpCacheWrapper.js +8 -5
- package/dist/cache/HttpCacheWrapper.js.map +1 -1
- package/dist/cache/index.d.ts +3 -3
- package/dist/cache/index.d.ts.map +1 -1
- package/dist/cache/index.js +1 -1
- package/dist/cache/index.js.map +1 -1
- package/dist/client/CachedWordPressClient.d.ts +23 -9
- package/dist/client/CachedWordPressClient.d.ts.map +1 -1
- package/dist/client/CachedWordPressClient.js +4 -1
- package/dist/client/CachedWordPressClient.js.map +1 -1
- package/dist/client/MockWordPressClient.d.ts +2 -1
- package/dist/client/MockWordPressClient.d.ts.map +1 -1
- package/dist/client/MockWordPressClient.js +3 -1
- package/dist/client/MockWordPressClient.js.map +1 -1
- package/dist/client/api.d.ts +17 -13
- package/dist/client/api.d.ts.map +1 -1
- package/dist/client/api.js +135 -30
- package/dist/client/api.js.map +1 -1
- package/dist/client/auth.d.ts.map +1 -1
- package/dist/client/auth.js +2 -3
- package/dist/client/auth.js.map +1 -1
- package/dist/client/managers/AuthenticationManager.d.ts +55 -2
- package/dist/client/managers/AuthenticationManager.d.ts.map +1 -1
- package/dist/client/managers/AuthenticationManager.js +269 -71
- package/dist/client/managers/AuthenticationManager.js.map +1 -1
- package/dist/client/managers/BaseManager.d.ts +3 -3
- package/dist/client/managers/BaseManager.d.ts.map +1 -1
- package/dist/client/managers/BaseManager.js +11 -5
- package/dist/client/managers/BaseManager.js.map +1 -1
- package/dist/client/managers/RequestManager.d.ts +2 -2
- package/dist/client/managers/RequestManager.d.ts.map +1 -1
- package/dist/client/managers/RequestManager.js +25 -12
- package/dist/client/managers/RequestManager.js.map +1 -1
- package/dist/config/Config.d.ts +155 -0
- package/dist/config/Config.d.ts.map +1 -0
- package/dist/config/Config.js +215 -0
- package/dist/config/Config.js.map +1 -0
- package/dist/config/ConfigurationSchema.d.ts +21 -21
- package/dist/config/ConfigurationSchema.d.ts.map +1 -1
- package/dist/config/ConfigurationSchema.js +19 -2
- package/dist/config/ConfigurationSchema.js.map +1 -1
- package/dist/config/ServerConfiguration.d.ts +2 -1
- package/dist/config/ServerConfiguration.d.ts.map +1 -1
- package/dist/config/ServerConfiguration.js +73 -43
- package/dist/config/ServerConfiguration.js.map +1 -1
- package/dist/docs/DocumentationGenerator.d.ts +9 -8
- package/dist/docs/DocumentationGenerator.d.ts.map +1 -1
- package/dist/docs/DocumentationGenerator.js +10 -7
- package/dist/docs/DocumentationGenerator.js.map +1 -1
- package/dist/docs/MarkdownFormatter.d.ts.map +1 -1
- package/dist/docs/MarkdownFormatter.js +3 -2
- package/dist/docs/MarkdownFormatter.js.map +1 -1
- package/dist/dxt-entry.js +15 -14
- package/dist/dxt-entry.js.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +37 -21
- package/dist/index.js.map +1 -1
- package/dist/performance/MetricsCollector.d.ts +13 -7
- package/dist/performance/MetricsCollector.d.ts.map +1 -1
- package/dist/performance/MetricsCollector.js +69 -27
- package/dist/performance/MetricsCollector.js.map +1 -1
- package/dist/performance/PerformanceAnalytics.d.ts +8 -2
- package/dist/performance/PerformanceAnalytics.d.ts.map +1 -1
- package/dist/performance/PerformanceAnalytics.js +17 -47
- package/dist/performance/PerformanceAnalytics.js.map +1 -1
- package/dist/performance/PerformanceMonitor.d.ts +2 -1
- package/dist/performance/PerformanceMonitor.d.ts.map +1 -1
- package/dist/performance/PerformanceMonitor.js +12 -13
- package/dist/performance/PerformanceMonitor.js.map +1 -1
- package/dist/performance/index.d.ts +2 -2
- package/dist/performance/index.d.ts.map +1 -1
- package/dist/security/AISecurityScanner.d.ts +1 -0
- package/dist/security/AISecurityScanner.d.ts.map +1 -1
- package/dist/security/AISecurityScanner.js +22 -12
- package/dist/security/AISecurityScanner.js.map +1 -1
- package/dist/security/AutomatedRemediation.d.ts +4 -3
- package/dist/security/AutomatedRemediation.d.ts.map +1 -1
- package/dist/security/AutomatedRemediation.js +46 -15
- package/dist/security/AutomatedRemediation.js.map +1 -1
- package/dist/security/InputValidator.d.ts +13 -9
- package/dist/security/InputValidator.d.ts.map +1 -1
- package/dist/security/InputValidator.js +4 -2
- package/dist/security/InputValidator.js.map +1 -1
- package/dist/security/SecurityCIPipeline.d.ts +1 -1
- package/dist/security/SecurityCIPipeline.d.ts.map +1 -1
- package/dist/security/SecurityCIPipeline.js +38 -29
- package/dist/security/SecurityCIPipeline.js.map +1 -1
- package/dist/security/SecurityConfig.d.ts +3 -3
- package/dist/security/SecurityConfig.d.ts.map +1 -1
- package/dist/security/SecurityConfig.js +13 -9
- package/dist/security/SecurityConfig.js.map +1 -1
- package/dist/security/SecurityConfigManager.d.ts +2 -2
- package/dist/security/SecurityConfigManager.d.ts.map +1 -1
- package/dist/security/SecurityConfigManager.js +20 -15
- package/dist/security/SecurityConfigManager.js.map +1 -1
- package/dist/security/SecurityMonitoring.d.ts +2 -2
- package/dist/security/SecurityMonitoring.d.ts.map +1 -1
- package/dist/security/SecurityMonitoring.js +19 -17
- package/dist/security/SecurityMonitoring.js.map +1 -1
- package/dist/security/SecurityReviewer.d.ts.map +1 -1
- package/dist/security/SecurityReviewer.js +10 -7
- package/dist/security/SecurityReviewer.js.map +1 -1
- package/dist/security/index.d.ts +24 -23
- package/dist/security/index.d.ts.map +1 -1
- package/dist/security/index.js +52 -23
- package/dist/security/index.js.map +1 -1
- package/dist/server/ConnectionTester.d.ts +12 -4
- package/dist/server/ConnectionTester.d.ts.map +1 -1
- package/dist/server/ConnectionTester.js +96 -22
- package/dist/server/ConnectionTester.js.map +1 -1
- package/dist/server/ToolRegistry.d.ts +2 -2
- package/dist/server/ToolRegistry.d.ts.map +1 -1
- package/dist/server/ToolRegistry.js +10 -5
- package/dist/server/ToolRegistry.js.map +1 -1
- package/dist/src/cache/CacheInvalidation.d.ts +120 -0
- package/dist/src/cache/CacheInvalidation.d.ts.map +1 -0
- package/dist/src/cache/CacheInvalidation.js +355 -0
- package/dist/src/cache/CacheInvalidation.js.map +1 -0
- package/dist/src/cache/CacheManager.d.ts +149 -0
- package/dist/src/cache/CacheManager.d.ts.map +1 -0
- package/dist/src/cache/CacheManager.js +326 -0
- package/dist/src/cache/CacheManager.js.map +1 -0
- package/dist/src/cache/HttpCacheWrapper.d.ts +122 -0
- package/dist/src/cache/HttpCacheWrapper.d.ts.map +1 -0
- package/dist/src/cache/HttpCacheWrapper.js +283 -0
- package/dist/src/cache/HttpCacheWrapper.js.map +1 -0
- package/dist/src/cache/index.d.ts +12 -0
- package/dist/src/cache/index.d.ts.map +1 -0
- package/dist/src/cache/index.js +9 -0
- package/dist/src/cache/index.js.map +1 -0
- package/dist/src/client/CachedWordPressClient.d.ts +174 -0
- package/dist/src/client/CachedWordPressClient.d.ts.map +1 -0
- package/dist/src/client/CachedWordPressClient.js +345 -0
- package/dist/src/client/CachedWordPressClient.js.map +1 -0
- package/dist/src/client/MockWordPressClient.d.ts +56 -0
- package/dist/src/client/MockWordPressClient.d.ts.map +1 -0
- package/dist/src/client/MockWordPressClient.js +371 -0
- package/dist/src/client/MockWordPressClient.js.map +1 -0
- package/dist/src/client/api.d.ts +235 -0
- package/dist/src/client/api.d.ts.map +1 -0
- package/dist/src/client/api.js +896 -0
- package/dist/src/client/api.js.map +1 -0
- package/dist/src/client/auth.d.ts +121 -0
- package/dist/src/client/auth.d.ts.map +1 -0
- package/dist/src/client/auth.js +429 -0
- package/dist/src/client/auth.js.map +1 -0
- package/dist/src/client/managers/AuthenticationManager.d.ts +92 -0
- package/dist/src/client/managers/AuthenticationManager.d.ts.map +1 -0
- package/dist/src/client/managers/AuthenticationManager.js +369 -0
- package/dist/src/client/managers/AuthenticationManager.js.map +1 -0
- package/dist/src/client/managers/BaseManager.d.ts +22 -0
- package/dist/src/client/managers/BaseManager.d.ts.map +1 -0
- package/dist/src/client/managers/BaseManager.js +53 -0
- package/dist/src/client/managers/BaseManager.js.map +1 -0
- package/dist/src/client/managers/RequestManager.d.ts +47 -0
- package/dist/src/client/managers/RequestManager.d.ts.map +1 -0
- package/dist/src/client/managers/RequestManager.js +193 -0
- package/dist/src/client/managers/RequestManager.js.map +1 -0
- package/dist/src/client/managers/index.d.ts +8 -0
- package/dist/src/client/managers/index.d.ts.map +1 -0
- package/dist/src/client/managers/index.js +8 -0
- package/dist/src/client/managers/index.js.map +1 -0
- package/dist/src/config/Config.d.ts +155 -0
- package/dist/src/config/Config.d.ts.map +1 -0
- package/dist/src/config/Config.js +215 -0
- package/dist/src/config/Config.js.map +1 -0
- package/dist/src/config/ConfigurationSchema.d.ts +281 -0
- package/dist/src/config/ConfigurationSchema.d.ts.map +1 -0
- package/dist/src/config/ConfigurationSchema.js +205 -0
- package/dist/src/config/ConfigurationSchema.js.map +1 -0
- package/dist/src/config/ServerConfiguration.d.ts +47 -0
- package/dist/src/config/ServerConfiguration.d.ts.map +1 -0
- package/dist/src/config/ServerConfiguration.js +255 -0
- package/dist/src/config/ServerConfiguration.js.map +1 -0
- package/dist/src/docs/DocumentationGenerator.d.ts +185 -0
- package/dist/src/docs/DocumentationGenerator.d.ts.map +1 -0
- package/dist/src/docs/DocumentationGenerator.js +777 -0
- package/dist/src/docs/DocumentationGenerator.js.map +1 -0
- package/dist/src/docs/MarkdownFormatter.d.ts +84 -0
- package/dist/src/docs/MarkdownFormatter.d.ts.map +1 -0
- package/dist/src/docs/MarkdownFormatter.js +458 -0
- package/dist/src/docs/MarkdownFormatter.js.map +1 -0
- package/dist/src/docs/index.d.ts +8 -0
- package/dist/src/docs/index.d.ts.map +1 -0
- package/dist/src/docs/index.js +7 -0
- package/dist/src/docs/index.js.map +1 -0
- package/dist/src/dxt-entry.d.ts +6 -0
- package/dist/src/dxt-entry.d.ts.map +1 -0
- package/dist/src/dxt-entry.js +39 -0
- package/dist/src/dxt-entry.js.map +1 -0
- package/dist/src/index.d.ts +18 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +143 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/performance/MetricsCollector.d.ts +145 -0
- package/dist/src/performance/MetricsCollector.d.ts.map +1 -0
- package/dist/src/performance/MetricsCollector.js +368 -0
- package/dist/src/performance/MetricsCollector.js.map +1 -0
- package/dist/src/performance/PerformanceAnalytics.d.ts +168 -0
- package/dist/src/performance/PerformanceAnalytics.d.ts.map +1 -0
- package/dist/src/performance/PerformanceAnalytics.js +570 -0
- package/dist/src/performance/PerformanceAnalytics.js.map +1 -0
- package/dist/src/performance/PerformanceMonitor.d.ts +203 -0
- package/dist/src/performance/PerformanceMonitor.d.ts.map +1 -0
- package/dist/src/performance/PerformanceMonitor.js +478 -0
- package/dist/src/performance/PerformanceMonitor.js.map +1 -0
- package/dist/src/performance/index.d.ts +11 -0
- package/dist/src/performance/index.d.ts.map +1 -0
- package/dist/src/performance/index.js +8 -0
- package/dist/src/performance/index.js.map +1 -0
- package/dist/src/security/AISecurityScanner.d.ts +176 -0
- package/dist/src/security/AISecurityScanner.d.ts.map +1 -0
- package/dist/src/security/AISecurityScanner.js +655 -0
- package/dist/src/security/AISecurityScanner.js.map +1 -0
- package/dist/src/security/AutomatedRemediation.d.ts +146 -0
- package/dist/src/security/AutomatedRemediation.d.ts.map +1 -0
- package/dist/src/security/AutomatedRemediation.js +566 -0
- package/dist/src/security/AutomatedRemediation.js.map +1 -0
- package/dist/src/security/InputValidator.d.ts +219 -0
- package/dist/src/security/InputValidator.d.ts.map +1 -0
- package/dist/src/security/InputValidator.js +295 -0
- package/dist/src/security/InputValidator.js.map +1 -0
- package/dist/src/security/SecurityCIPipeline.d.ts +213 -0
- package/dist/src/security/SecurityCIPipeline.d.ts.map +1 -0
- package/dist/src/security/SecurityCIPipeline.js +693 -0
- package/dist/src/security/SecurityCIPipeline.js.map +1 -0
- package/dist/src/security/SecurityConfig.d.ts +129 -0
- package/dist/src/security/SecurityConfig.d.ts.map +1 -0
- package/dist/src/security/SecurityConfig.js +266 -0
- package/dist/src/security/SecurityConfig.js.map +1 -0
- package/dist/src/security/SecurityConfigManager.d.ts +294 -0
- package/dist/src/security/SecurityConfigManager.d.ts.map +1 -0
- package/dist/src/security/SecurityConfigManager.js +558 -0
- package/dist/src/security/SecurityConfigManager.js.map +1 -0
- package/dist/src/security/SecurityMonitoring.d.ts +245 -0
- package/dist/src/security/SecurityMonitoring.d.ts.map +1 -0
- package/dist/src/security/SecurityMonitoring.js +598 -0
- package/dist/src/security/SecurityMonitoring.js.map +1 -0
- package/dist/src/security/SecurityReviewer.d.ts +168 -0
- package/dist/src/security/SecurityReviewer.d.ts.map +1 -0
- package/dist/src/security/SecurityReviewer.js +686 -0
- package/dist/src/security/SecurityReviewer.js.map +1 -0
- package/dist/src/security/index.d.ts +183 -0
- package/dist/src/security/index.d.ts.map +1 -0
- package/dist/src/security/index.js +218 -0
- package/dist/src/security/index.js.map +1 -0
- package/dist/src/server/ConnectionTester.d.ts +32 -0
- package/dist/src/server/ConnectionTester.d.ts.map +1 -0
- package/dist/src/server/ConnectionTester.js +135 -0
- package/dist/src/server/ConnectionTester.js.map +1 -0
- package/dist/src/server/ToolRegistry.d.ts +50 -0
- package/dist/src/server/ToolRegistry.d.ts.map +1 -0
- package/dist/src/server/ToolRegistry.js +219 -0
- package/dist/src/server/ToolRegistry.js.map +1 -0
- package/dist/src/server.d.ts +7 -0
- package/dist/src/server.d.ts.map +1 -0
- package/dist/src/server.js +7 -0
- package/dist/src/server.js.map +1 -0
- package/dist/src/tools/BaseToolManager.d.ts +62 -0
- package/dist/src/tools/BaseToolManager.d.ts.map +1 -0
- package/dist/src/tools/BaseToolManager.js +195 -0
- package/dist/src/tools/BaseToolManager.js.map +1 -0
- package/dist/src/tools/auth.d.ts +50 -0
- package/dist/src/tools/auth.d.ts.map +1 -0
- package/dist/src/tools/auth.js +133 -0
- package/dist/src/tools/auth.js.map +1 -0
- package/dist/src/tools/cache.d.ts +260 -0
- package/dist/src/tools/cache.d.ts.map +1 -0
- package/dist/src/tools/cache.js +232 -0
- package/dist/src/tools/cache.js.map +1 -0
- package/dist/src/tools/comments.d.ts +33 -0
- package/dist/src/tools/comments.d.ts.map +1 -0
- package/dist/src/tools/comments.js +235 -0
- package/dist/src/tools/comments.js.map +1 -0
- package/dist/src/tools/index.d.ts +11 -0
- package/dist/src/tools/index.d.ts.map +1 -0
- package/dist/src/tools/index.js +11 -0
- package/dist/src/tools/index.js.map +1 -0
- package/dist/src/tools/media.d.ts +70 -0
- package/dist/src/tools/media.d.ts.map +1 -0
- package/dist/src/tools/media.js +248 -0
- package/dist/src/tools/media.js.map +1 -0
- package/dist/src/tools/pages.d.ts +32 -0
- package/dist/src/tools/pages.d.ts.map +1 -0
- package/dist/src/tools/pages.js +215 -0
- package/dist/src/tools/pages.js.map +1 -0
- package/dist/src/tools/performance.d.ts +73 -0
- package/dist/src/tools/performance.d.ts.map +1 -0
- package/dist/src/tools/performance.js +922 -0
- package/dist/src/tools/performance.js.map +1 -0
- package/dist/src/tools/posts/PostHandlers.d.ts +46 -0
- package/dist/src/tools/posts/PostHandlers.d.ts.map +1 -0
- package/dist/src/tools/posts/PostHandlers.js +400 -0
- package/dist/src/tools/posts/PostHandlers.js.map +1 -0
- package/dist/src/tools/posts/PostToolDefinitions.d.ts +37 -0
- package/dist/src/tools/posts/PostToolDefinitions.d.ts.map +1 -0
- package/dist/src/tools/posts/PostToolDefinitions.js +236 -0
- package/dist/src/tools/posts/PostToolDefinitions.js.map +1 -0
- package/dist/src/tools/posts/index.d.ts +138 -0
- package/dist/src/tools/posts/index.d.ts.map +1 -0
- package/dist/src/tools/posts/index.js +163 -0
- package/dist/src/tools/posts/index.js.map +1 -0
- package/dist/src/tools/posts.d.ts +15 -0
- package/dist/src/tools/posts.d.ts.map +1 -0
- package/dist/src/tools/posts.js +16 -0
- package/dist/src/tools/posts.js.map +1 -0
- package/dist/src/tools/site.d.ts +32 -0
- package/dist/src/tools/site.d.ts.map +1 -0
- package/dist/src/tools/site.js +234 -0
- package/dist/src/tools/site.js.map +1 -0
- package/dist/src/tools/taxonomies.d.ts +36 -0
- package/dist/src/tools/taxonomies.d.ts.map +1 -0
- package/dist/src/tools/taxonomies.js +286 -0
- package/dist/src/tools/taxonomies.js.map +1 -0
- package/dist/src/tools/users.d.ts +33 -0
- package/dist/src/tools/users.d.ts.map +1 -0
- package/dist/src/tools/users.js +308 -0
- package/dist/src/tools/users.js.map +1 -0
- package/dist/src/types/client.d.ts +223 -0
- package/dist/src/types/client.d.ts.map +1 -0
- package/dist/src/types/client.js +97 -0
- package/dist/src/types/client.js.map +1 -0
- package/dist/src/types/enhanced.d.ts +237 -0
- package/dist/src/types/enhanced.d.ts.map +1 -0
- package/dist/src/types/enhanced.js +49 -0
- package/dist/src/types/enhanced.js.map +1 -0
- package/dist/src/types/index.d.ts +160 -0
- package/dist/src/types/index.d.ts.map +1 -0
- package/dist/src/types/index.js +14 -0
- package/dist/src/types/index.js.map +1 -0
- package/dist/src/types/mcp.d.ts +178 -0
- package/dist/src/types/mcp.d.ts.map +1 -0
- package/dist/src/types/mcp.js +7 -0
- package/dist/src/types/mcp.js.map +1 -0
- package/dist/src/types/requests.d.ts +322 -0
- package/dist/src/types/requests.d.ts.map +1 -0
- package/dist/src/types/requests.js +8 -0
- package/dist/src/types/requests.js.map +1 -0
- package/dist/src/types/tools.d.ts +506 -0
- package/dist/src/types/tools.d.ts.map +1 -0
- package/dist/src/types/tools.js +8 -0
- package/dist/src/types/tools.js.map +1 -0
- package/dist/src/types/wordpress.d.ts +471 -0
- package/dist/src/types/wordpress.d.ts.map +1 -0
- package/dist/src/types/wordpress.js +14 -0
- package/dist/src/types/wordpress.js.map +1 -0
- package/dist/src/utils/debug.d.ts +71 -0
- package/dist/src/utils/debug.d.ts.map +1 -0
- package/dist/src/utils/debug.js +235 -0
- package/dist/src/utils/debug.js.map +1 -0
- package/dist/src/utils/enhancedError.d.ts +61 -0
- package/dist/src/utils/enhancedError.d.ts.map +1 -0
- package/dist/src/utils/enhancedError.js +221 -0
- package/dist/src/utils/enhancedError.js.map +1 -0
- package/dist/src/utils/error.d.ts +17 -0
- package/dist/src/utils/error.d.ts.map +1 -0
- package/dist/src/utils/error.js +108 -0
- package/dist/src/utils/error.js.map +1 -0
- package/dist/src/utils/logger.d.ts +106 -0
- package/dist/src/utils/logger.d.ts.map +1 -0
- package/dist/src/utils/logger.js +280 -0
- package/dist/src/utils/logger.js.map +1 -0
- package/dist/src/utils/streaming.d.ts +104 -0
- package/dist/src/utils/streaming.d.ts.map +1 -0
- package/dist/src/utils/streaming.js +331 -0
- package/dist/src/utils/streaming.js.map +1 -0
- package/dist/src/utils/toolWrapper.d.ts +42 -0
- package/dist/src/utils/toolWrapper.d.ts.map +1 -0
- package/dist/src/utils/toolWrapper.js +101 -0
- package/dist/src/utils/toolWrapper.js.map +1 -0
- package/dist/src/utils/validation/core.d.ts +21 -0
- package/dist/src/utils/validation/core.d.ts.map +1 -0
- package/dist/src/utils/validation/core.js +71 -0
- package/dist/src/utils/validation/core.js.map +1 -0
- package/dist/src/utils/validation/index.d.ts +25 -0
- package/dist/src/utils/validation/index.d.ts.map +1 -0
- package/dist/src/utils/validation/index.js +29 -0
- package/dist/src/utils/validation/index.js.map +1 -0
- package/dist/src/utils/validation/network.d.ts +19 -0
- package/dist/src/utils/validation/network.d.ts.map +1 -0
- package/dist/src/utils/validation/network.js +93 -0
- package/dist/src/utils/validation/network.js.map +1 -0
- package/dist/src/utils/validation/rateLimit.d.ts +21 -0
- package/dist/src/utils/validation/rateLimit.d.ts.map +1 -0
- package/dist/src/utils/validation/rateLimit.js +43 -0
- package/dist/src/utils/validation/rateLimit.js.map +1 -0
- package/dist/src/utils/validation/security.d.ts +29 -0
- package/dist/src/utils/validation/security.d.ts.map +1 -0
- package/dist/src/utils/validation/security.js +327 -0
- package/dist/src/utils/validation/security.js.map +1 -0
- package/dist/src/utils/validation/wordpress.d.ts +31 -0
- package/dist/src/utils/validation/wordpress.d.ts.map +1 -0
- package/dist/src/utils/validation/wordpress.js +146 -0
- package/dist/src/utils/validation/wordpress.js.map +1 -0
- package/dist/src/utils/validation.d.ts +15 -0
- package/dist/src/utils/validation.d.ts.map +1 -0
- package/dist/src/utils/validation.js +27 -0
- package/dist/src/utils/validation.js.map +1 -0
- package/dist/tests/vitest.setup.d.ts +6 -0
- package/dist/tests/vitest.setup.d.ts.map +1 -0
- package/dist/tests/vitest.setup.js +39 -0
- package/dist/tests/vitest.setup.js.map +1 -0
- package/dist/tools/BaseToolManager.d.ts +47 -11
- package/dist/tools/BaseToolManager.d.ts.map +1 -1
- package/dist/tools/BaseToolManager.js +168 -29
- package/dist/tools/BaseToolManager.js.map +1 -1
- package/dist/tools/auth.d.ts +16 -10
- package/dist/tools/auth.d.ts.map +1 -1
- package/dist/tools/auth.js +3 -2
- package/dist/tools/auth.js.map +1 -1
- package/dist/tools/cache.d.ts +30 -30
- package/dist/tools/cache.d.ts.map +1 -1
- package/dist/tools/cache.js +1 -6
- package/dist/tools/cache.js.map +1 -1
- package/dist/tools/comments.d.ts +20 -20
- package/dist/tools/comments.d.ts.map +1 -1
- package/dist/tools/comments.js +16 -9
- package/dist/tools/comments.js.map +1 -1
- package/dist/tools/media.d.ts +18 -16
- package/dist/tools/media.d.ts.map +1 -1
- package/dist/tools/media.js +16 -15
- package/dist/tools/media.js.map +1 -1
- package/dist/tools/pages.d.ts +19 -17
- package/dist/tools/pages.d.ts.map +1 -1
- package/dist/tools/pages.js +16 -12
- package/dist/tools/pages.js.map +1 -1
- package/dist/tools/performance.d.ts +11 -1
- package/dist/tools/performance.d.ts.map +1 -1
- package/dist/tools/performance.js +67 -34
- package/dist/tools/performance.js.map +1 -1
- package/dist/tools/posts/PostHandlers.d.ts +46 -0
- package/dist/tools/posts/PostHandlers.d.ts.map +1 -0
- package/dist/tools/posts/PostHandlers.js +400 -0
- package/dist/tools/posts/PostHandlers.js.map +1 -0
- package/dist/tools/posts/PostToolDefinitions.d.ts +37 -0
- package/dist/tools/posts/PostToolDefinitions.d.ts.map +1 -0
- package/dist/tools/posts/PostToolDefinitions.js +236 -0
- package/dist/tools/posts/PostToolDefinitions.js.map +1 -0
- package/dist/tools/posts/index.d.ts +138 -0
- package/dist/tools/posts/index.d.ts.map +1 -0
- package/dist/tools/posts/index.js +163 -0
- package/dist/tools/posts/index.js.map +1 -0
- package/dist/tools/posts.d.ts +10 -246
- package/dist/tools/posts.d.ts.map +1 -1
- package/dist/tools/posts.js +11 -723
- package/dist/tools/posts.js.map +1 -1
- package/dist/tools/site.d.ts +19 -18
- package/dist/tools/site.d.ts.map +1 -1
- package/dist/tools/site.js +14 -10
- package/dist/tools/site.js.map +1 -1
- package/dist/tools/taxonomies.d.ts +23 -24
- package/dist/tools/taxonomies.d.ts.map +1 -1
- package/dist/tools/taxonomies.js +24 -18
- package/dist/tools/taxonomies.js.map +1 -1
- package/dist/tools/users.d.ts +20 -15
- package/dist/tools/users.d.ts.map +1 -1
- package/dist/tools/users.js +12 -8
- package/dist/tools/users.js.map +1 -1
- package/dist/types/client.d.ts +48 -41
- package/dist/types/client.d.ts.map +1 -1
- package/dist/types/client.js +30 -5
- package/dist/types/client.js.map +1 -1
- package/dist/types/enhanced.d.ts +237 -0
- package/dist/types/enhanced.d.ts.map +1 -0
- package/dist/types/enhanced.js +49 -0
- package/dist/types/enhanced.js.map +1 -0
- package/dist/types/index.d.ts +15 -12
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +2 -0
- package/dist/types/index.js.map +1 -1
- package/dist/types/mcp.d.ts +12 -12
- package/dist/types/mcp.d.ts.map +1 -1
- package/dist/types/requests.d.ts +322 -0
- package/dist/types/requests.d.ts.map +1 -0
- package/dist/types/requests.js +8 -0
- package/dist/types/requests.js.map +1 -0
- package/dist/types/tools.d.ts +506 -0
- package/dist/types/tools.d.ts.map +1 -0
- package/dist/types/tools.js +8 -0
- package/dist/types/tools.js.map +1 -0
- package/dist/types/wordpress.d.ts +43 -15
- package/dist/types/wordpress.d.ts.map +1 -1
- package/dist/types/wordpress.js +8 -1
- package/dist/types/wordpress.js.map +1 -1
- package/dist/utils/debug.d.ts +19 -11
- package/dist/utils/debug.d.ts.map +1 -1
- package/dist/utils/debug.js +46 -10
- package/dist/utils/debug.js.map +1 -1
- package/dist/utils/enhancedError.d.ts +8 -8
- package/dist/utils/enhancedError.d.ts.map +1 -1
- package/dist/utils/enhancedError.js.map +1 -1
- package/dist/utils/error.d.ts +2 -4
- package/dist/utils/error.d.ts.map +1 -1
- package/dist/utils/error.js +42 -5
- package/dist/utils/error.js.map +1 -1
- package/dist/utils/logger.d.ts +106 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +280 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/streaming.d.ts +9 -9
- package/dist/utils/streaming.d.ts.map +1 -1
- package/dist/utils/streaming.js +71 -52
- package/dist/utils/streaming.js.map +1 -1
- package/dist/utils/toolWrapper.d.ts +9 -7
- package/dist/utils/toolWrapper.d.ts.map +1 -1
- package/dist/utils/toolWrapper.js.map +1 -1
- package/dist/utils/validation/core.d.ts +21 -0
- package/dist/utils/validation/core.d.ts.map +1 -0
- package/dist/utils/validation/core.js +71 -0
- package/dist/utils/validation/core.js.map +1 -0
- package/dist/utils/validation/index.d.ts +25 -0
- package/dist/utils/validation/index.d.ts.map +1 -0
- package/dist/utils/validation/index.js +29 -0
- package/dist/utils/validation/index.js.map +1 -0
- package/dist/utils/validation/network.d.ts +19 -0
- package/dist/utils/validation/network.d.ts.map +1 -0
- package/dist/utils/validation/network.js +93 -0
- package/dist/utils/validation/network.js.map +1 -0
- package/dist/utils/validation/rateLimit.d.ts +21 -0
- package/dist/utils/validation/rateLimit.d.ts.map +1 -0
- package/dist/utils/validation/rateLimit.js +43 -0
- package/dist/utils/validation/rateLimit.js.map +1 -0
- package/dist/utils/validation/security.d.ts +29 -0
- package/dist/utils/validation/security.d.ts.map +1 -0
- package/dist/utils/validation/security.js +327 -0
- package/dist/utils/validation/security.js.map +1 -0
- package/dist/utils/validation/wordpress.d.ts +31 -0
- package/dist/utils/validation/wordpress.d.ts.map +1 -0
- package/dist/utils/validation/wordpress.js +146 -0
- package/dist/utils/validation/wordpress.js.map +1 -0
- package/dist/utils/validation.d.ts +13 -82
- package/dist/utils/validation.d.ts.map +1 -1
- package/dist/utils/validation.js +25 -343
- package/dist/utils/validation.js.map +1 -1
- package/docs/BADGE_UPDATES.md +132 -0
- package/docs/CI_CD_IMPROVEMENTS.md +191 -0
- package/docs/INCREMENTAL_COVERAGE.md +183 -0
- package/docs/INSTALLATION.md +4 -2
- package/docs/TROUBLESHOOTING.md +2 -1
- package/docs/api/README.md +3 -1
- package/docs/api/openapi.json +5 -1
- package/docs/api/summary.json +1 -1
- package/docs/api/tools/wp_create_post.md +12 -14
- package/docs/developer/TESTING.md +24 -19
- package/docs/examples/claude-desktop-config.md +1 -1
- package/docs/examples/docker-production.md +100 -93
- package/docs/examples/multi-site-setup.md +5 -4
- package/docs/examples/single-site-setup.md +3 -4
- package/docs/examples/use-case-workflows.md +4 -5
- package/docs/integrations/claude-desktop.md +39 -34
- package/docs/integrations/cline.md +4 -4
- package/docs/integrations/vs-code.md +9 -8
- package/docs/user-guides/DXT_INSTALLATION.md +2 -1
- package/docs/user-guides/SMITHERY_SETUP.md +10 -10
- package/package.json +57 -39
- package/src/cache/CacheInvalidation.ts +12 -5
- package/src/cache/CacheManager.ts +18 -15
- package/src/cache/HttpCacheWrapper.ts +30 -59
- package/src/cache/__tests__/HttpCacheWrapper.test.ts +6 -5
- package/src/cache/index.ts +3 -14
- package/src/client/CachedWordPressClient.ts +32 -30
- package/src/client/MockWordPressClient.ts +4 -2
- package/src/client/api.ts +186 -64
- package/src/client/auth.ts +15 -40
- package/src/client/managers/AuthenticationManager.ts +337 -77
- package/src/client/managers/BaseManager.ts +18 -30
- package/src/client/managers/RequestManager.ts +39 -44
- package/src/config/Config.ts +308 -0
- package/src/config/ConfigurationSchema.ts +23 -2
- package/src/config/ServerConfiguration.ts +73 -49
- package/src/docs/DocumentationGenerator.ts +50 -39
- package/src/docs/MarkdownFormatter.ts +19 -29
- package/src/dxt-entry.cjs +26 -16
- package/src/dxt-entry.ts +17 -27
- package/src/index.ts +42 -28
- package/src/performance/MetricsCollector.ts +108 -86
- package/src/performance/PerformanceAnalytics.ts +69 -164
- package/src/performance/PerformanceMonitor.ts +32 -47
- package/src/performance/index.ts +2 -10
- package/src/security/AISecurityScanner.ts +22 -12
- package/src/security/AutomatedRemediation.ts +49 -18
- package/src/security/InputValidator.ts +9 -6
- package/src/security/SecurityCIPipeline.ts +53 -37
- package/src/security/SecurityConfig.ts +22 -22
- package/src/security/SecurityConfigManager.ts +23 -19
- package/src/security/SecurityMonitoring.ts +24 -21
- package/src/security/SecurityReviewer.ts +10 -7
- package/src/security/index.ts +64 -29
- package/src/server/ConnectionTester.ts +120 -31
- package/src/server/ToolRegistry.ts +31 -21
- package/src/tools/BaseToolManager.ts +286 -33
- package/src/tools/auth.ts +20 -8
- package/src/tools/cache.ts +5 -15
- package/src/tools/comments.ts +34 -48
- package/src/tools/media.ts +41 -53
- package/src/tools/pages.ts +32 -54
- package/src/tools/performance.ts +141 -176
- package/src/tools/posts/PostHandlers.ts +474 -0
- package/src/tools/posts/PostToolDefinitions.ts +250 -0
- package/src/tools/posts/index.ts +192 -0
- package/src/tools/posts.ts +24 -780
- package/src/tools/site.ts +34 -19
- package/src/tools/taxonomies.ts +41 -57
- package/src/tools/users.ts +28 -16
- package/src/types/client.ts +114 -138
- package/src/types/enhanced.ts +318 -0
- package/src/types/index.ts +51 -30
- package/src/types/mcp.ts +20 -42
- package/src/types/requests.ts +378 -0
- package/src/types/tools.ts +608 -0
- package/src/types/wordpress.ts +56 -34
- package/src/utils/debug.ts +77 -59
- package/src/utils/enhancedError.ts +8 -8
- package/src/utils/error.ts +53 -31
- package/src/utils/logger.ts +351 -0
- package/src/utils/streaming.ts +86 -68
- package/src/utils/toolWrapper.ts +10 -12
- package/src/utils/validation/core.ts +108 -0
- package/src/utils/validation/index.ts +36 -0
- package/src/utils/validation/network.ts +132 -0
- package/src/utils/validation/rateLimit.ts +54 -0
- package/src/utils/validation/security.ts +361 -0
- package/src/utils/validation/wordpress.ts +180 -0
- package/src/utils/validation.ts +47 -470
- package/dist/cache/__tests__/CacheInvalidation.test.d.ts +0 -5
- package/dist/cache/__tests__/CacheInvalidation.test.d.ts.map +0 -1
- package/dist/cache/__tests__/CacheInvalidation.test.js +0 -238
- package/dist/cache/__tests__/CacheInvalidation.test.js.map +0 -1
- package/dist/cache/__tests__/CacheManager.test.d.ts +0 -5
- package/dist/cache/__tests__/CacheManager.test.d.ts.map +0 -1
- package/dist/cache/__tests__/CacheManager.test.js +0 -233
- package/dist/cache/__tests__/CacheManager.test.js.map +0 -1
- package/dist/cache/__tests__/CachedWordPressClient.test.d.ts +0 -5
- package/dist/cache/__tests__/CachedWordPressClient.test.d.ts.map +0 -1
- package/dist/cache/__tests__/CachedWordPressClient.test.js +0 -231
- package/dist/cache/__tests__/CachedWordPressClient.test.js.map +0 -1
- package/dist/cache/__tests__/HttpCacheWrapper.test.d.ts +0 -5
- package/dist/cache/__tests__/HttpCacheWrapper.test.d.ts.map +0 -1
- package/dist/cache/__tests__/HttpCacheWrapper.test.js +0 -299
- package/dist/cache/__tests__/HttpCacheWrapper.test.js.map +0 -1
package/dist/tools/posts.js
CHANGED
|
@@ -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
|
-
*
|
|
2
|
+
* WordPress Posts Tools - Legacy Import Module
|
|
7
3
|
*
|
|
8
|
-
* This
|
|
9
|
-
*
|
|
10
|
-
*
|
|
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
|
-
* @
|
|
17
|
-
*
|
|
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
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
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
|