mcp-wordpress 2.4.2 → 2.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +114 -48
- package/dist/ajv-patch.js +34 -0
- 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/__tests__/HttpCacheWrapper.test.js +6 -5
- package/dist/cache/__tests__/HttpCacheWrapper.test.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 +50 -41
- 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.cjs +81 -0
- 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/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/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/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 +31 -31
- package/docs/integrations/cline.md +4 -4
- package/docs/integrations/vs-code.md +9 -8
- package/docs/user-guides/SMITHERY_SETUP.md +10 -10
- package/package.json +44 -25
- 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 +51 -47
- 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/src/types/wordpress.ts
CHANGED
|
@@ -4,6 +4,20 @@
|
|
|
4
4
|
* Comprehensive TypeScript definitions for WordPress REST API v2 responses
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
+
// Authentication method constants
|
|
8
|
+
export const AUTH_METHODS = {
|
|
9
|
+
APP_PASSWORD: "app-password",
|
|
10
|
+
JWT: "jwt",
|
|
11
|
+
BASIC: "basic",
|
|
12
|
+
API_KEY: "api-key",
|
|
13
|
+
COOKIE: "cookie",
|
|
14
|
+
} as const;
|
|
15
|
+
|
|
16
|
+
export type AuthMethod = (typeof AUTH_METHODS)[keyof typeof AUTH_METHODS];
|
|
17
|
+
|
|
18
|
+
// WordPress metadata type - can contain various primitive values and nested objects
|
|
19
|
+
export type WordPressMeta = Record<string, unknown> | unknown[];
|
|
20
|
+
|
|
7
21
|
// Common WordPress API response patterns
|
|
8
22
|
export interface WordPressRendered {
|
|
9
23
|
rendered: string;
|
|
@@ -31,15 +45,7 @@ export interface WordPressLinks {
|
|
|
31
45
|
}
|
|
32
46
|
|
|
33
47
|
// Post Types
|
|
34
|
-
export type PostStatus =
|
|
35
|
-
| "publish"
|
|
36
|
-
| "future"
|
|
37
|
-
| "draft"
|
|
38
|
-
| "pending"
|
|
39
|
-
| "private"
|
|
40
|
-
| "trash"
|
|
41
|
-
| "auto-draft"
|
|
42
|
-
| "inherit";
|
|
48
|
+
export type PostStatus = "publish" | "future" | "draft" | "pending" | "private" | "trash" | "auto-draft" | "inherit";
|
|
43
49
|
export type PostFormat =
|
|
44
50
|
| "standard"
|
|
45
51
|
| "aside"
|
|
@@ -75,7 +81,7 @@ export interface WordPressPost {
|
|
|
75
81
|
sticky: boolean;
|
|
76
82
|
template: string;
|
|
77
83
|
format: PostFormat;
|
|
78
|
-
meta:
|
|
84
|
+
meta: WordPressMeta;
|
|
79
85
|
categories: number[];
|
|
80
86
|
tags: number[];
|
|
81
87
|
_links?: WordPressLinks;
|
|
@@ -100,7 +106,7 @@ export interface WordPressPage {
|
|
|
100
106
|
comment_status: CommentStatus;
|
|
101
107
|
ping_status: PingStatus;
|
|
102
108
|
menu_order: number;
|
|
103
|
-
meta:
|
|
109
|
+
meta: WordPressMeta;
|
|
104
110
|
template: string;
|
|
105
111
|
parent: number;
|
|
106
112
|
_links?: WordPressLinks;
|
|
@@ -156,7 +162,7 @@ export interface WordPressMedia {
|
|
|
156
162
|
comment_status: CommentStatus;
|
|
157
163
|
ping_status: PingStatus;
|
|
158
164
|
template: string;
|
|
159
|
-
meta:
|
|
165
|
+
meta: WordPressMeta;
|
|
160
166
|
description: WordPressRendered;
|
|
161
167
|
caption: WordPressRendered;
|
|
162
168
|
alt_text: string;
|
|
@@ -169,12 +175,7 @@ export interface WordPressMedia {
|
|
|
169
175
|
}
|
|
170
176
|
|
|
171
177
|
// User Types
|
|
172
|
-
export type UserRole =
|
|
173
|
-
| "administrator"
|
|
174
|
-
| "editor"
|
|
175
|
-
| "author"
|
|
176
|
-
| "contributor"
|
|
177
|
-
| "subscriber";
|
|
178
|
+
export type UserRole = "administrator" | "editor" | "author" | "contributor" | "subscriber";
|
|
178
179
|
|
|
179
180
|
export interface WordPressUser {
|
|
180
181
|
id: number;
|
|
@@ -194,7 +195,7 @@ export interface WordPressUser {
|
|
|
194
195
|
capabilities: Record<string, boolean>;
|
|
195
196
|
extra_capabilities: Record<string, boolean>;
|
|
196
197
|
avatar_urls: Record<string, string>;
|
|
197
|
-
meta:
|
|
198
|
+
meta: WordPressMeta;
|
|
198
199
|
_links?: WordPressLinks;
|
|
199
200
|
}
|
|
200
201
|
|
|
@@ -218,7 +219,7 @@ export interface WordPressComment {
|
|
|
218
219
|
status: "approved" | "unapproved" | "spam" | "trash";
|
|
219
220
|
type: CommentType;
|
|
220
221
|
author_avatar_urls: Record<string, string>;
|
|
221
|
-
meta:
|
|
222
|
+
meta: WordPressMeta;
|
|
222
223
|
_links?: WordPressLinks;
|
|
223
224
|
}
|
|
224
225
|
|
|
@@ -232,7 +233,7 @@ export interface WordPressCategory {
|
|
|
232
233
|
slug: string;
|
|
233
234
|
taxonomy: string;
|
|
234
235
|
parent: number;
|
|
235
|
-
meta:
|
|
236
|
+
meta: WordPressMeta;
|
|
236
237
|
_links?: WordPressLinks;
|
|
237
238
|
}
|
|
238
239
|
|
|
@@ -244,7 +245,7 @@ export interface WordPressTag {
|
|
|
244
245
|
name: string;
|
|
245
246
|
slug: string;
|
|
246
247
|
taxonomy: string;
|
|
247
|
-
meta:
|
|
248
|
+
meta: WordPressMeta;
|
|
248
249
|
_links?: WordPressLinks;
|
|
249
250
|
}
|
|
250
251
|
|
|
@@ -304,8 +305,8 @@ export interface WordPressAPIErrorResponse {
|
|
|
304
305
|
message: string;
|
|
305
306
|
data?: {
|
|
306
307
|
status: number;
|
|
307
|
-
params?: Record<string,
|
|
308
|
-
details?: Record<string,
|
|
308
|
+
params?: Record<string, unknown>;
|
|
309
|
+
details?: Record<string, unknown>;
|
|
309
310
|
};
|
|
310
311
|
}
|
|
311
312
|
|
|
@@ -333,6 +334,7 @@ export interface PostQueryParams extends PaginationParams {
|
|
|
333
334
|
tags?: number[];
|
|
334
335
|
tags_exclude?: number[];
|
|
335
336
|
sticky?: boolean;
|
|
337
|
+
[key: string]: unknown;
|
|
336
338
|
}
|
|
337
339
|
|
|
338
340
|
export interface MediaQueryParams extends PaginationParams {
|
|
@@ -392,7 +394,7 @@ export interface CreatePostRequest {
|
|
|
392
394
|
comment_status?: CommentStatus;
|
|
393
395
|
ping_status?: PingStatus;
|
|
394
396
|
format?: PostFormat;
|
|
395
|
-
meta?:
|
|
397
|
+
meta?: WordPressMeta;
|
|
396
398
|
sticky?: boolean;
|
|
397
399
|
template?: string;
|
|
398
400
|
categories?: number[];
|
|
@@ -416,7 +418,7 @@ export interface CreatePageRequest {
|
|
|
416
418
|
comment_status?: CommentStatus;
|
|
417
419
|
ping_status?: PingStatus;
|
|
418
420
|
menu_order?: number;
|
|
419
|
-
meta?:
|
|
421
|
+
meta?: WordPressMeta;
|
|
420
422
|
parent?: number;
|
|
421
423
|
template?: string;
|
|
422
424
|
date?: string;
|
|
@@ -443,11 +445,10 @@ export interface CreateUserRequest {
|
|
|
443
445
|
url?: string;
|
|
444
446
|
locale?: string;
|
|
445
447
|
roles?: UserRole[];
|
|
446
|
-
meta?:
|
|
448
|
+
meta?: WordPressMeta;
|
|
447
449
|
}
|
|
448
450
|
|
|
449
|
-
export interface UpdateUserRequest
|
|
450
|
-
extends Partial<Omit<CreateUserRequest, "username">> {
|
|
451
|
+
export interface UpdateUserRequest extends Partial<Omit<CreateUserRequest, "username">> {
|
|
451
452
|
id: number;
|
|
452
453
|
}
|
|
453
454
|
|
|
@@ -462,11 +463,10 @@ export interface CreateCommentRequest {
|
|
|
462
463
|
date?: string;
|
|
463
464
|
date_gmt?: string;
|
|
464
465
|
status?: "approved" | "unapproved";
|
|
465
|
-
meta?:
|
|
466
|
+
meta?: WordPressMeta;
|
|
466
467
|
}
|
|
467
468
|
|
|
468
|
-
export interface UpdateCommentRequest
|
|
469
|
-
extends Partial<Omit<CreateCommentRequest, "status">> {
|
|
469
|
+
export interface UpdateCommentRequest extends Partial<Omit<CreateCommentRequest, "status">> {
|
|
470
470
|
id: number;
|
|
471
471
|
status?: "approved" | "unapproved" | "spam" | "trash";
|
|
472
472
|
}
|
|
@@ -476,7 +476,7 @@ export interface CreateCategoryRequest {
|
|
|
476
476
|
description?: string;
|
|
477
477
|
slug?: string;
|
|
478
478
|
parent?: number;
|
|
479
|
-
meta?:
|
|
479
|
+
meta?: WordPressMeta;
|
|
480
480
|
}
|
|
481
481
|
|
|
482
482
|
export interface UpdateCategoryRequest extends Partial<CreateCategoryRequest> {
|
|
@@ -487,7 +487,7 @@ export interface CreateTagRequest {
|
|
|
487
487
|
name: string;
|
|
488
488
|
description?: string;
|
|
489
489
|
slug?: string;
|
|
490
|
-
meta?:
|
|
490
|
+
meta?: WordPressMeta;
|
|
491
491
|
}
|
|
492
492
|
|
|
493
493
|
export interface UpdateTagRequest extends Partial<CreateTagRequest> {
|
|
@@ -517,3 +517,25 @@ export interface UpdateMediaRequest {
|
|
|
517
517
|
status?: PostStatus;
|
|
518
518
|
author?: number;
|
|
519
519
|
}
|
|
520
|
+
|
|
521
|
+
// Site Information
|
|
522
|
+
export interface WordPressSiteInfo {
|
|
523
|
+
name: string;
|
|
524
|
+
description: string;
|
|
525
|
+
url: string;
|
|
526
|
+
home: string;
|
|
527
|
+
gmt_offset: number;
|
|
528
|
+
timezone_string: string;
|
|
529
|
+
namespaces: string[];
|
|
530
|
+
authentication: Record<string, unknown>;
|
|
531
|
+
routes: Record<string, unknown>;
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
// Search Results
|
|
535
|
+
export interface WordPressSearchResult {
|
|
536
|
+
id: number;
|
|
537
|
+
title: string;
|
|
538
|
+
url: string;
|
|
539
|
+
type: string;
|
|
540
|
+
subtype: string;
|
|
541
|
+
}
|
package/src/utils/debug.ts
CHANGED
|
@@ -6,45 +6,44 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import type { DebugInfo } from "../types/index.js";
|
|
9
|
+
import { config } from "../config/Config.js";
|
|
9
10
|
|
|
10
11
|
// Log levels
|
|
11
12
|
export type LogLevel = "debug" | "info" | "warn" | "error";
|
|
12
13
|
|
|
13
14
|
// Logger interface
|
|
14
15
|
export interface Logger {
|
|
15
|
-
log(...args:
|
|
16
|
-
info(...args:
|
|
17
|
-
warn(...args:
|
|
18
|
-
error(...args:
|
|
16
|
+
log(...args: unknown[]): void;
|
|
17
|
+
info(...args: unknown[]): void;
|
|
18
|
+
warn(...args: unknown[]): void;
|
|
19
|
+
error(...args: unknown[]): void;
|
|
19
20
|
}
|
|
20
21
|
|
|
21
22
|
// Enhanced logger with structured logging
|
|
22
23
|
export interface StructuredLogger extends Logger {
|
|
23
24
|
logStructured(info: DebugInfo): void;
|
|
24
|
-
child(context: Record<string,
|
|
25
|
+
child(context: Record<string, unknown>): StructuredLogger;
|
|
25
26
|
}
|
|
26
27
|
|
|
28
|
+
import { ConfigHelpers } from "../config/Config.js";
|
|
29
|
+
|
|
27
30
|
// Check if debug mode is enabled
|
|
28
|
-
const isDebugMode = (): boolean =>
|
|
29
|
-
(process.env.DEBUG === "true" || process.env.NODE_ENV === "development") &&
|
|
30
|
-
process.env.NODE_ENV !== "test";
|
|
31
|
+
const isDebugMode = (): boolean => ConfigHelpers.shouldDebug();
|
|
31
32
|
|
|
32
33
|
// Get current timestamp
|
|
33
34
|
const getTimestamp = (): string => new Date().toISOString();
|
|
34
35
|
|
|
35
36
|
// Format log message with timestamp and level
|
|
36
|
-
const formatMessage = (level: LogLevel, args:
|
|
37
|
+
const formatMessage = (level: LogLevel, args: unknown[]): string => {
|
|
37
38
|
const timestamp = getTimestamp();
|
|
38
39
|
const prefix = `[${timestamp}] [${level.toUpperCase()}]`;
|
|
39
40
|
return `${prefix} ${args
|
|
40
|
-
.map((arg) =>
|
|
41
|
-
typeof arg === "object" ? JSON.stringify(arg, null, 2) : String(arg),
|
|
42
|
-
)
|
|
41
|
+
.map((arg) => (typeof arg === "object" ? JSON.stringify(arg, null, 2) : String(arg)))
|
|
43
42
|
.join(" ")}`;
|
|
44
43
|
};
|
|
45
44
|
|
|
46
45
|
// Handle circular references in objects
|
|
47
|
-
const safeStringify = (obj:
|
|
46
|
+
const safeStringify = (obj: unknown): string => {
|
|
48
47
|
try {
|
|
49
48
|
return JSON.stringify(
|
|
50
49
|
obj,
|
|
@@ -69,25 +68,25 @@ const safeStringify = (obj: any): string => {
|
|
|
69
68
|
* Debug logger that only outputs in debug mode
|
|
70
69
|
*/
|
|
71
70
|
export const debug: Logger = {
|
|
72
|
-
log: (...args:
|
|
71
|
+
log: (...args: unknown[]): void => {
|
|
73
72
|
if (isDebugMode()) {
|
|
74
73
|
console.error(formatMessage("debug", args)); // Use stderr for debug to avoid STDIO interference
|
|
75
74
|
}
|
|
76
75
|
},
|
|
77
76
|
|
|
78
|
-
info: (...args:
|
|
77
|
+
info: (...args: unknown[]): void => {
|
|
79
78
|
if (isDebugMode()) {
|
|
80
79
|
console.error(formatMessage("info", args));
|
|
81
80
|
}
|
|
82
81
|
},
|
|
83
82
|
|
|
84
|
-
warn: (...args:
|
|
83
|
+
warn: (...args: unknown[]): void => {
|
|
85
84
|
if (isDebugMode()) {
|
|
86
85
|
console.error(formatMessage("warn", args));
|
|
87
86
|
}
|
|
88
87
|
},
|
|
89
88
|
|
|
90
|
-
error: (...args:
|
|
89
|
+
error: (...args: unknown[]): void => {
|
|
91
90
|
if (isDebugMode()) {
|
|
92
91
|
console.error(formatMessage("error", args));
|
|
93
92
|
}
|
|
@@ -108,44 +107,40 @@ export const silent: Logger = {
|
|
|
108
107
|
* Enhanced structured logger
|
|
109
108
|
*/
|
|
110
109
|
class StructuredLoggerImpl implements StructuredLogger {
|
|
111
|
-
private context: Record<string,
|
|
110
|
+
private context: Record<string, unknown>;
|
|
112
111
|
private enabled: boolean;
|
|
113
112
|
|
|
114
|
-
constructor(context: Record<string,
|
|
113
|
+
constructor(context: Record<string, unknown> = {}, enabled = isDebugMode()) {
|
|
115
114
|
this.context = context;
|
|
116
115
|
this.enabled = enabled;
|
|
117
116
|
}
|
|
118
117
|
|
|
119
|
-
private output(level: LogLevel, args:
|
|
118
|
+
private output(level: LogLevel, args: unknown[]): void {
|
|
120
119
|
if (!this.enabled) return;
|
|
121
120
|
|
|
122
121
|
const debugInfo: DebugInfo = {
|
|
123
122
|
timestamp: Date.now(),
|
|
124
123
|
level,
|
|
125
|
-
message: args
|
|
126
|
-
.map((arg) =>
|
|
127
|
-
typeof arg === "object" ? safeStringify(arg) : String(arg),
|
|
128
|
-
)
|
|
129
|
-
.join(" "),
|
|
124
|
+
message: args.map((arg) => (typeof arg === "object" ? safeStringify(arg) : String(arg))).join(" "),
|
|
130
125
|
...(Object.keys(this.context).length > 0 && { context: this.context }),
|
|
131
126
|
};
|
|
132
127
|
|
|
133
128
|
console.error(safeStringify(debugInfo));
|
|
134
129
|
}
|
|
135
130
|
|
|
136
|
-
log(...args:
|
|
131
|
+
log(...args: unknown[]): void {
|
|
137
132
|
this.output("debug", args);
|
|
138
133
|
}
|
|
139
134
|
|
|
140
|
-
info(...args:
|
|
135
|
+
info(...args: unknown[]): void {
|
|
141
136
|
this.output("info", args);
|
|
142
137
|
}
|
|
143
138
|
|
|
144
|
-
warn(...args:
|
|
139
|
+
warn(...args: unknown[]): void {
|
|
145
140
|
this.output("warn", args);
|
|
146
141
|
}
|
|
147
142
|
|
|
148
|
-
error(...args:
|
|
143
|
+
error(...args: unknown[]): void {
|
|
149
144
|
this.output("error", args);
|
|
150
145
|
}
|
|
151
146
|
|
|
@@ -160,20 +155,15 @@ class StructuredLoggerImpl implements StructuredLogger {
|
|
|
160
155
|
console.error(safeStringify(enhancedInfo));
|
|
161
156
|
}
|
|
162
157
|
|
|
163
|
-
child(context: Record<string,
|
|
164
|
-
return new StructuredLoggerImpl(
|
|
165
|
-
{ ...this.context, ...context },
|
|
166
|
-
this.enabled,
|
|
167
|
-
);
|
|
158
|
+
child(context: Record<string, unknown>): StructuredLogger {
|
|
159
|
+
return new StructuredLoggerImpl({ ...this.context, ...context }, this.enabled);
|
|
168
160
|
}
|
|
169
161
|
}
|
|
170
162
|
|
|
171
163
|
/**
|
|
172
164
|
* Create a structured logger instance
|
|
173
165
|
*/
|
|
174
|
-
export const createStructuredLogger = (
|
|
175
|
-
context: Record<string, any> = {},
|
|
176
|
-
): StructuredLogger => {
|
|
166
|
+
export const createStructuredLogger = (context: Record<string, unknown> = {}): StructuredLogger => {
|
|
177
167
|
return new StructuredLoggerImpl(context);
|
|
178
168
|
};
|
|
179
169
|
|
|
@@ -185,9 +175,7 @@ export const logger: Logger = debug;
|
|
|
185
175
|
/**
|
|
186
176
|
* Create a logger with context
|
|
187
177
|
*/
|
|
188
|
-
export const createLogger = (
|
|
189
|
-
context: Record<string, any> = {},
|
|
190
|
-
): StructuredLogger => {
|
|
178
|
+
export const createLogger = (context: Record<string, unknown> = {}): StructuredLogger => {
|
|
191
179
|
return createStructuredLogger(context);
|
|
192
180
|
};
|
|
193
181
|
|
|
@@ -209,9 +197,7 @@ export const startTimer = (label?: string): PerformanceTimer => {
|
|
|
209
197
|
|
|
210
198
|
endWithLog(message = "Operation"): number {
|
|
211
199
|
const duration = Date.now() - start;
|
|
212
|
-
debug.info(
|
|
213
|
-
`${message} completed in ${duration}ms${label ? ` [${label}]` : ""}`,
|
|
214
|
-
);
|
|
200
|
+
debug.info(`${message} completed in ${duration}ms${label ? ` [${label}]` : ""}`);
|
|
215
201
|
return duration;
|
|
216
202
|
},
|
|
217
203
|
};
|
|
@@ -220,10 +206,7 @@ export const startTimer = (label?: string): PerformanceTimer => {
|
|
|
220
206
|
/**
|
|
221
207
|
* Log error with stack trace
|
|
222
208
|
*/
|
|
223
|
-
export const logError = (
|
|
224
|
-
error: Error | string,
|
|
225
|
-
context?: Record<string, any>,
|
|
226
|
-
): void => {
|
|
209
|
+
export const logError = (error: Error | string, context?: Record<string, unknown>): void => {
|
|
227
210
|
if (typeof error === "string") {
|
|
228
211
|
debug.error(error, context);
|
|
229
212
|
} else {
|
|
@@ -251,32 +234,67 @@ export const logIf = (condition: boolean, level: LogLevel = "debug") => {
|
|
|
251
234
|
};
|
|
252
235
|
|
|
253
236
|
/**
|
|
254
|
-
* Type-safe environment variable getter
|
|
237
|
+
* Type-safe environment variable getter with security logging
|
|
255
238
|
*/
|
|
256
|
-
export const getEnvVar = (
|
|
257
|
-
key: string,
|
|
258
|
-
defaultValue?: string,
|
|
259
|
-
): string | undefined => {
|
|
239
|
+
export const getEnvVar = (key: string, defaultValue?: string): string | undefined => {
|
|
260
240
|
const value = process.env[key];
|
|
261
241
|
if (value === undefined && defaultValue !== undefined) {
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
)
|
|
242
|
+
// Don't log sensitive environment variable names in production
|
|
243
|
+
const isSecretVar = /password|secret|token|key|auth/i.test(key);
|
|
244
|
+
if (!isSecretVar || !config().app.isProduction) {
|
|
245
|
+
debug.warn(`Environment variable ${key} not found, using default`);
|
|
246
|
+
}
|
|
265
247
|
return defaultValue;
|
|
266
248
|
}
|
|
267
249
|
return value;
|
|
268
250
|
};
|
|
269
251
|
|
|
270
252
|
/**
|
|
271
|
-
* Validate required environment variables
|
|
253
|
+
* Validate required environment variables with secure error messages
|
|
272
254
|
*/
|
|
273
255
|
export const validateEnvVars = (required: string[]): void => {
|
|
274
256
|
const missing = required.filter((key) => !process.env[key]);
|
|
275
257
|
if (missing.length > 0) {
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
258
|
+
// In production, don't expose which specific env vars are missing
|
|
259
|
+
const errorMessage = config().app.isProduction
|
|
260
|
+
? `Missing ${missing.length} required environment variable(s)`
|
|
261
|
+
: `Missing required environment variables: ${missing.join(", ")}`;
|
|
262
|
+
const error = new Error(errorMessage);
|
|
279
263
|
logError(error);
|
|
280
264
|
throw error;
|
|
281
265
|
}
|
|
282
266
|
};
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* Sanitize environment variable for logging
|
|
270
|
+
*/
|
|
271
|
+
export const sanitizeEnvValue = (key: string, value: string): string => {
|
|
272
|
+
const sensitiveKeys = /password|secret|token|key|auth|credential/i;
|
|
273
|
+
|
|
274
|
+
if (sensitiveKeys.test(key)) {
|
|
275
|
+
if (!value || value.length === 0) {
|
|
276
|
+
return "[EMPTY]";
|
|
277
|
+
}
|
|
278
|
+
return `[REDACTED:${value.length}chars]`;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
return value;
|
|
282
|
+
};
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* Get sanitized environment summary for debugging
|
|
286
|
+
*/
|
|
287
|
+
export const getEnvSummary = (keys: string[]): Record<string, string> => {
|
|
288
|
+
const summary: Record<string, string> = {};
|
|
289
|
+
|
|
290
|
+
for (const key of keys) {
|
|
291
|
+
const value = process.env[key];
|
|
292
|
+
if (value !== undefined) {
|
|
293
|
+
summary[key] = sanitizeEnvValue(key, value);
|
|
294
|
+
} else {
|
|
295
|
+
summary[key] = "[NOT_SET]";
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
return summary;
|
|
300
|
+
};
|
|
@@ -2,7 +2,7 @@ import { getErrorMessage } from "./error.js";
|
|
|
2
2
|
|
|
3
3
|
export interface ErrorContext {
|
|
4
4
|
operation: string;
|
|
5
|
-
parameters?: Record<string,
|
|
5
|
+
parameters?: Record<string, unknown>;
|
|
6
6
|
suggestions?: string[];
|
|
7
7
|
troubleshooting?: string[];
|
|
8
8
|
}
|
|
@@ -54,7 +54,7 @@ export class ErrorHandlers {
|
|
|
54
54
|
/**
|
|
55
55
|
* Handle post not found errors
|
|
56
56
|
*/
|
|
57
|
-
static postNotFound(postId: number, originalError:
|
|
57
|
+
static postNotFound(postId: number, originalError: unknown): EnhancedError {
|
|
58
58
|
const errorMessage = getErrorMessage(originalError);
|
|
59
59
|
|
|
60
60
|
return new EnhancedError(`Post with ID ${postId} not found`, {
|
|
@@ -78,7 +78,7 @@ export class ErrorHandlers {
|
|
|
78
78
|
/**
|
|
79
79
|
* Handle authentication errors
|
|
80
80
|
*/
|
|
81
|
-
static authenticationFailed(originalError:
|
|
81
|
+
static authenticationFailed(originalError: unknown): EnhancedError {
|
|
82
82
|
const errorMessage = getErrorMessage(originalError);
|
|
83
83
|
|
|
84
84
|
return new EnhancedError("Authentication failed", {
|
|
@@ -141,7 +141,7 @@ export class ErrorHandlers {
|
|
|
141
141
|
/**
|
|
142
142
|
* Handle permission errors
|
|
143
143
|
*/
|
|
144
|
-
static permissionDenied(operation: string, originalError:
|
|
144
|
+
static permissionDenied(operation: string, originalError: unknown): EnhancedError {
|
|
145
145
|
const errorMessage = getErrorMessage(originalError);
|
|
146
146
|
|
|
147
147
|
return new EnhancedError(`Permission denied for ${operation}`, {
|
|
@@ -163,7 +163,7 @@ export class ErrorHandlers {
|
|
|
163
163
|
/**
|
|
164
164
|
* Handle network/connection errors
|
|
165
165
|
*/
|
|
166
|
-
static connectionError(originalError:
|
|
166
|
+
static connectionError(originalError: unknown): EnhancedError {
|
|
167
167
|
const errorMessage = getErrorMessage(originalError);
|
|
168
168
|
|
|
169
169
|
return new EnhancedError("Failed to connect to WordPress site", {
|
|
@@ -185,7 +185,7 @@ export class ErrorHandlers {
|
|
|
185
185
|
/**
|
|
186
186
|
* Handle validation errors
|
|
187
187
|
*/
|
|
188
|
-
static validationError(field: string, value:
|
|
188
|
+
static validationError(field: string, value: unknown, expectedType: string): EnhancedError {
|
|
189
189
|
return new EnhancedError(`Invalid ${field}: expected ${expectedType}, got ${typeof value}`, {
|
|
190
190
|
operation: "validation",
|
|
191
191
|
parameters: { field, value, expectedType },
|
|
@@ -205,7 +205,7 @@ export class ErrorHandlers {
|
|
|
205
205
|
/**
|
|
206
206
|
* Handle rate limiting errors
|
|
207
207
|
*/
|
|
208
|
-
static rateLimitExceeded(originalError:
|
|
208
|
+
static rateLimitExceeded(originalError: unknown): EnhancedError {
|
|
209
209
|
const errorMessage = getErrorMessage(originalError);
|
|
210
210
|
|
|
211
211
|
return new EnhancedError("Rate limit exceeded", {
|
|
@@ -227,7 +227,7 @@ export class ErrorHandlers {
|
|
|
227
227
|
/**
|
|
228
228
|
* Generic error handler with basic suggestions
|
|
229
229
|
*/
|
|
230
|
-
static generic(operation: string, originalError:
|
|
230
|
+
static generic(operation: string, originalError: unknown): EnhancedError {
|
|
231
231
|
const errorMessage = getErrorMessage(originalError);
|
|
232
232
|
|
|
233
233
|
return new EnhancedError(`Failed to ${operation}`, {
|