mcp-wordpress 2.6.4 → 2.7.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 +1 -1
- package/dist/cache/CacheInvalidation.d.ts +25 -6
- package/dist/cache/CacheInvalidation.d.ts.map +1 -1
- package/dist/cache/CacheInvalidation.js +168 -16
- package/dist/cache/CacheInvalidation.js.map +1 -1
- package/dist/cache/HttpCacheWrapper.d.ts.map +1 -1
- package/dist/cache/HttpCacheWrapper.js +3 -4
- package/dist/cache/HttpCacheWrapper.js.map +1 -1
- package/dist/cache/SEOCacheManager.d.ts +150 -0
- package/dist/cache/SEOCacheManager.d.ts.map +1 -0
- package/dist/cache/SEOCacheManager.js +275 -0
- package/dist/cache/SEOCacheManager.js.map +1 -0
- package/dist/client/SEOWordPressClient.d.ts +164 -0
- package/dist/client/SEOWordPressClient.d.ts.map +1 -0
- package/dist/client/SEOWordPressClient.js +674 -0
- package/dist/client/SEOWordPressClient.js.map +1 -0
- package/dist/client/api.d.ts.map +1 -1
- package/dist/client/api.js +50 -20
- package/dist/client/api.js.map +1 -1
- package/dist/client/auth.js +19 -19
- package/dist/client/auth.js.map +1 -1
- package/dist/client/index.d.ts +11 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +14 -0
- package/dist/client/index.js.map +1 -0
- package/dist/client/managers/AuthManager.d.ts +39 -0
- package/dist/client/managers/AuthManager.d.ts.map +1 -0
- package/dist/client/managers/AuthManager.js +142 -0
- package/dist/client/managers/AuthManager.js.map +1 -0
- package/dist/client/managers/AuthenticationManager.d.ts.map +1 -1
- package/dist/client/managers/AuthenticationManager.js +10 -9
- package/dist/client/managers/AuthenticationManager.js.map +1 -1
- package/dist/client/managers/BaseManager.d.ts.map +1 -1
- package/dist/client/managers/BaseManager.js +12 -0
- package/dist/client/managers/BaseManager.js.map +1 -1
- package/dist/client/managers/ComposedAuthenticationManager.d.ts +94 -0
- package/dist/client/managers/ComposedAuthenticationManager.d.ts.map +1 -0
- package/dist/client/managers/ComposedAuthenticationManager.js +340 -0
- package/dist/client/managers/ComposedAuthenticationManager.js.map +1 -0
- package/dist/client/managers/ComposedManagerFactory.d.ts +104 -0
- package/dist/client/managers/ComposedManagerFactory.d.ts.map +1 -0
- package/dist/client/managers/ComposedManagerFactory.js +180 -0
- package/dist/client/managers/ComposedManagerFactory.js.map +1 -0
- package/dist/client/managers/ComposedRequestManager.d.ts +82 -0
- package/dist/client/managers/ComposedRequestManager.d.ts.map +1 -0
- package/dist/client/managers/ComposedRequestManager.js +260 -0
- package/dist/client/managers/ComposedRequestManager.js.map +1 -0
- package/dist/client/managers/JWTAuthImplementation.d.ts +86 -0
- package/dist/client/managers/JWTAuthImplementation.d.ts.map +1 -0
- package/dist/client/managers/JWTAuthImplementation.js +240 -0
- package/dist/client/managers/JWTAuthImplementation.js.map +1 -0
- package/dist/client/managers/ManagersIndex.d.ts +6 -0
- package/dist/client/managers/ManagersIndex.d.ts.map +1 -0
- package/dist/client/managers/ManagersIndex.js +6 -0
- package/dist/client/managers/ManagersIndex.js.map +1 -0
- package/dist/client/managers/RequestManager.d.ts.map +1 -1
- package/dist/client/managers/RequestManager.js +5 -3
- package/dist/client/managers/RequestManager.js.map +1 -1
- package/dist/client/managers/composed/MigrationAdapter.d.ts +80 -0
- package/dist/client/managers/composed/MigrationAdapter.d.ts.map +1 -0
- package/dist/client/managers/composed/MigrationAdapter.js +214 -0
- package/dist/client/managers/composed/MigrationAdapter.js.map +1 -0
- package/dist/client/managers/composed/index.d.ts +23 -0
- package/dist/client/managers/composed/index.d.ts.map +1 -0
- package/dist/client/managers/composed/index.js +26 -0
- package/dist/client/managers/composed/index.js.map +1 -0
- package/dist/client/managers/implementations/ConfigurationProviderImpl.d.ts +27 -0
- package/dist/client/managers/implementations/ConfigurationProviderImpl.d.ts.map +1 -0
- package/dist/client/managers/implementations/ConfigurationProviderImpl.js +41 -0
- package/dist/client/managers/implementations/ConfigurationProviderImpl.js.map +1 -0
- package/dist/client/managers/implementations/ErrorHandlerImpl.d.ts +31 -0
- package/dist/client/managers/implementations/ErrorHandlerImpl.d.ts.map +1 -0
- package/dist/client/managers/implementations/ErrorHandlerImpl.js +73 -0
- package/dist/client/managers/implementations/ErrorHandlerImpl.js.map +1 -0
- package/dist/client/managers/implementations/ParameterValidatorImpl.d.ts +47 -0
- package/dist/client/managers/implementations/ParameterValidatorImpl.d.ts.map +1 -0
- package/dist/client/managers/implementations/ParameterValidatorImpl.js +141 -0
- package/dist/client/managers/implementations/ParameterValidatorImpl.js.map +1 -0
- package/dist/client/managers/interfaces/ManagerInterfaces.d.ts +147 -0
- package/dist/client/managers/interfaces/ManagerInterfaces.d.ts.map +1 -0
- package/dist/client/managers/interfaces/ManagerInterfaces.js +6 -0
- package/dist/client/managers/interfaces/ManagerInterfaces.js.map +1 -0
- package/dist/config/Config.d.ts +30 -0
- package/dist/config/Config.d.ts.map +1 -1
- package/dist/config/Config.js +30 -0
- package/dist/config/Config.js.map +1 -1
- package/dist/config/ConfigurationSchema.d.ts +75 -198
- package/dist/config/ConfigurationSchema.d.ts.map +1 -1
- package/dist/config/ConfigurationSchema.js +17 -17
- package/dist/config/ConfigurationSchema.js.map +1 -1
- package/dist/config/ServerConfiguration.d.ts +2 -2
- package/dist/config/ServerConfiguration.d.ts.map +1 -1
- package/dist/config/ServerConfiguration.js +15 -13
- package/dist/config/ServerConfiguration.js.map +1 -1
- package/dist/config/index.d.ts +8 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +11 -0
- package/dist/config/index.js.map +1 -0
- package/dist/docs/DocumentationGenerator.js +2 -2
- package/dist/docs/DocumentationGenerator.js.map +1 -1
- package/dist/dxt-entry.js +3 -3
- package/dist/dxt-entry.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +38 -37
- package/dist/index.js.map +1 -1
- package/dist/performance/MetricsCollector.d.ts.map +1 -1
- package/dist/performance/MetricsCollector.js +5 -4
- package/dist/performance/MetricsCollector.js.map +1 -1
- package/dist/security/AISecurityScanner.js +7 -7
- package/dist/security/AISecurityScanner.js.map +1 -1
- package/dist/security/AutomatedRemediation.d.ts.map +1 -1
- package/dist/security/AutomatedRemediation.js +11 -11
- package/dist/security/AutomatedRemediation.js.map +1 -1
- package/dist/security/InputValidator.d.ts +50 -126
- package/dist/security/InputValidator.d.ts.map +1 -1
- package/dist/security/InputValidator.js +9 -9
- package/dist/security/InputValidator.js.map +1 -1
- package/dist/security/SecurityCIPipeline.d.ts +47 -5
- package/dist/security/SecurityCIPipeline.d.ts.map +1 -1
- package/dist/security/SecurityCIPipeline.js +390 -49
- package/dist/security/SecurityCIPipeline.js.map +1 -1
- package/dist/security/SecurityConfigManager.js +10 -10
- package/dist/security/SecurityConfigManager.js.map +1 -1
- package/dist/security/SecurityMonitoring.js +4 -4
- package/dist/security/SecurityMonitoring.js.map +1 -1
- package/dist/security/SecurityReviewer.d.ts.map +1 -1
- package/dist/security/SecurityReviewer.js +13 -6
- package/dist/security/SecurityReviewer.js.map +1 -1
- package/dist/security/index.js +3 -3
- package/dist/security/index.js.map +1 -1
- package/dist/server/ConnectionTester.js +5 -5
- 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 +7 -6
- package/dist/server/ToolRegistry.js.map +1 -1
- package/dist/server/index.d.ts +7 -0
- package/dist/server/index.d.ts.map +1 -0
- package/dist/server/index.js +9 -0
- package/dist/server/index.js.map +1 -0
- package/dist/tools/BaseToolManager.d.ts.map +1 -1
- package/dist/tools/BaseToolManager.js +11 -11
- package/dist/tools/BaseToolManager.js.map +1 -1
- package/dist/tools/auth.d.ts.map +1 -1
- package/dist/tools/auth.js +7 -7
- package/dist/tools/auth.js.map +1 -1
- package/dist/tools/comments.d.ts.map +1 -1
- package/dist/tools/comments.js +14 -14
- package/dist/tools/comments.js.map +1 -1
- package/dist/tools/index.d.ts +1 -0
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +1 -0
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/media.d.ts.map +1 -1
- package/dist/tools/media.js +14 -11
- package/dist/tools/media.js.map +1 -1
- package/dist/tools/pages.d.ts.map +1 -1
- package/dist/tools/pages.js +12 -12
- package/dist/tools/pages.js.map +1 -1
- package/dist/tools/performance.d.ts.map +1 -1
- package/dist/tools/performance.js +13 -11
- package/dist/tools/performance.js.map +1 -1
- package/dist/tools/posts/PostHandlers.d.ts.map +1 -1
- package/dist/tools/posts/PostHandlers.js +16 -16
- package/dist/tools/posts/PostHandlers.js.map +1 -1
- package/dist/tools/posts/PostToolDefinitions.d.ts.map +1 -1
- package/dist/tools/posts/index.d.ts.map +1 -1
- package/dist/tools/seo/BulkOperations.d.ts +113 -0
- package/dist/tools/seo/BulkOperations.d.ts.map +1 -0
- package/dist/tools/seo/BulkOperations.js +398 -0
- package/dist/tools/seo/BulkOperations.js.map +1 -0
- package/dist/tools/seo/SEOHandlers.d.ts +55 -0
- package/dist/tools/seo/SEOHandlers.d.ts.map +1 -0
- package/dist/tools/seo/SEOHandlers.js +255 -0
- package/dist/tools/seo/SEOHandlers.js.map +1 -0
- package/dist/tools/seo/SEOToolDefinitions.d.ts +59 -0
- package/dist/tools/seo/SEOToolDefinitions.d.ts.map +1 -0
- package/dist/tools/seo/SEOToolDefinitions.js +385 -0
- package/dist/tools/seo/SEOToolDefinitions.js.map +1 -0
- package/dist/tools/seo/SEOTools.d.ts +203 -0
- package/dist/tools/seo/SEOTools.d.ts.map +1 -0
- package/dist/tools/seo/SEOTools.js +708 -0
- package/dist/tools/seo/SEOTools.js.map +1 -0
- package/dist/tools/seo/analyzers/ContentAnalyzer.d.ts +94 -0
- package/dist/tools/seo/analyzers/ContentAnalyzer.d.ts.map +1 -0
- package/dist/tools/seo/analyzers/ContentAnalyzer.js +402 -0
- package/dist/tools/seo/analyzers/ContentAnalyzer.js.map +1 -0
- package/dist/tools/seo/auditors/SiteAuditor.d.ts +121 -0
- package/dist/tools/seo/auditors/SiteAuditor.d.ts.map +1 -0
- package/dist/tools/seo/auditors/SiteAuditor.js +600 -0
- package/dist/tools/seo/auditors/SiteAuditor.js.map +1 -0
- package/dist/tools/seo/generators/MetaGenerator.d.ts +128 -0
- package/dist/tools/seo/generators/MetaGenerator.d.ts.map +1 -0
- package/dist/tools/seo/generators/MetaGenerator.js +547 -0
- package/dist/tools/seo/generators/MetaGenerator.js.map +1 -0
- package/dist/tools/seo/generators/SchemaGenerator.d.ts +204 -0
- package/dist/tools/seo/generators/SchemaGenerator.d.ts.map +1 -0
- package/dist/tools/seo/generators/SchemaGenerator.js +670 -0
- package/dist/tools/seo/generators/SchemaGenerator.js.map +1 -0
- package/dist/tools/seo/index.d.ts +17 -0
- package/dist/tools/seo/index.d.ts.map +1 -0
- package/dist/tools/seo/index.js +18 -0
- package/dist/tools/seo/index.js.map +1 -0
- package/dist/tools/seo/optimizers/InternalLinkingSuggester.d.ts +186 -0
- package/dist/tools/seo/optimizers/InternalLinkingSuggester.d.ts.map +1 -0
- package/dist/tools/seo/optimizers/InternalLinkingSuggester.js +683 -0
- package/dist/tools/seo/optimizers/InternalLinkingSuggester.js.map +1 -0
- package/dist/tools/site.d.ts.map +1 -1
- package/dist/tools/site.js +12 -12
- package/dist/tools/site.js.map +1 -1
- package/dist/tools/taxonomies.d.ts.map +1 -1
- package/dist/tools/taxonomies.js +20 -20
- package/dist/tools/taxonomies.js.map +1 -1
- package/dist/tools/users.d.ts.map +1 -1
- package/dist/tools/users.js +12 -12
- package/dist/tools/users.js.map +1 -1
- package/dist/types/client.d.ts +8 -6
- package/dist/types/client.d.ts.map +1 -1
- package/dist/types/client.js.map +1 -1
- package/dist/types/seo.d.ts +473 -0
- package/dist/types/seo.d.ts.map +1 -0
- package/dist/types/seo.js +94 -0
- package/dist/types/seo.js.map +1 -0
- package/dist/utils/enhancedError.js +1 -1
- package/dist/utils/enhancedError.js.map +1 -1
- package/dist/utils/error.d.ts.map +1 -1
- package/dist/utils/error.js +0 -1
- package/dist/utils/error.js.map +1 -1
- package/dist/utils/index.d.ts +12 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +18 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/logger.js +3 -3
- package/dist/utils/logger.js.map +1 -1
- package/dist/utils/toolWrapper.d.ts +2 -2
- package/dist/utils/toolWrapper.js +8 -8
- package/dist/utils/toolWrapper.js.map +1 -1
- package/dist/utils/validation/core.d.ts.map +1 -1
- package/dist/utils/validation/core.js.map +1 -1
- package/dist/utils/validation/index.d.ts.map +1 -1
- package/dist/utils/validation/index.js.map +1 -1
- package/dist/utils/validation/network.js +3 -3
- package/dist/utils/validation/network.js.map +1 -1
- package/dist/utils/validation/rateLimit.js.map +1 -1
- package/dist/utils/validation/security.js.map +1 -1
- package/dist/utils/validation/wordpress.js.map +1 -1
- package/dist/utils/version.d.ts +144 -0
- package/dist/utils/version.d.ts.map +1 -0
- package/dist/utils/version.js +318 -0
- package/dist/utils/version.js.map +1 -0
- package/package.json +21 -55
- package/src/cache/CacheInvalidation.ts +183 -20
- package/src/cache/HttpCacheWrapper.ts +8 -5
- package/src/cache/SEOCacheManager.ts +330 -0
- package/src/cache/__tests__/CacheInvalidation.test.ts +6 -11
- package/src/cache/__tests__/CachedWordPressClient.test.ts +37 -62
- package/src/client/SEOWordPressClient.ts +876 -0
- package/src/client/api.ts +50 -21
- package/src/client/auth.ts +19 -19
- package/src/client/index.ts +16 -0
- package/src/client/managers/AuthManager.ts +175 -0
- package/src/client/managers/AuthenticationManager.ts +16 -14
- package/src/client/managers/BaseManager.ts +24 -5
- package/src/client/managers/ComposedAuthenticationManager.ts +409 -0
- package/src/client/managers/ComposedManagerFactory.ts +231 -0
- package/src/client/managers/ComposedRequestManager.ts +336 -0
- package/src/client/managers/JWTAuthImplementation.ts +326 -0
- package/src/client/managers/ManagersIndex.ts +6 -0
- package/src/client/managers/RequestManager.ts +9 -7
- package/src/client/managers/composed/MigrationAdapter.ts +263 -0
- package/src/client/managers/composed/index.ts +47 -0
- package/src/client/managers/implementations/ConfigurationProviderImpl.ts +52 -0
- package/src/client/managers/implementations/ErrorHandlerImpl.ts +102 -0
- package/src/client/managers/implementations/ParameterValidatorImpl.ts +221 -0
- package/src/client/managers/interfaces/ManagerInterfaces.ts +171 -0
- package/src/config/Config.ts +63 -0
- package/src/config/ConfigurationSchema.ts +17 -17
- package/src/config/ServerConfiguration.ts +18 -16
- package/src/config/index.ts +13 -0
- package/src/docs/DocumentationGenerator.ts +2 -2
- package/src/dxt-entry.ts +3 -3
- package/src/index.ts +43 -43
- package/src/performance/MetricsCollector.ts +15 -11
- package/src/security/AISecurityScanner.ts +7 -7
- package/src/security/AutomatedRemediation.ts +13 -11
- package/src/security/InputValidator.ts +10 -9
- package/src/security/SecurityCIPipeline.ts +494 -56
- package/src/security/SecurityConfigManager.ts +10 -10
- package/src/security/SecurityMonitoring.ts +5 -5
- package/src/security/SecurityReviewer.ts +13 -6
- package/src/security/index.ts +3 -3
- package/src/server/ConnectionTester.ts +5 -5
- package/src/server/ToolRegistry.ts +9 -8
- package/src/server/index.ts +10 -0
- package/src/tools/BaseToolManager.ts +55 -83
- package/src/tools/auth.ts +21 -12
- package/src/tools/comments.ts +23 -19
- package/src/tools/index.ts +1 -0
- package/src/tools/media.ts +23 -20
- package/src/tools/pages.ts +20 -13
- package/src/tools/performance.ts +101 -32
- package/src/tools/posts/PostHandlers.ts +23 -23
- package/src/tools/posts/PostToolDefinitions.ts +1 -1
- package/src/tools/posts/index.ts +2 -2
- package/src/tools/seo/BulkOperations.ts +557 -0
- package/src/tools/seo/SEOHandlers.ts +296 -0
- package/src/tools/seo/SEOToolDefinitions.ts +402 -0
- package/src/tools/seo/SEOTools.ts +871 -0
- package/src/tools/seo/analyzers/ContentAnalyzer.ts +493 -0
- package/src/tools/seo/auditors/SiteAuditor.ts +787 -0
- package/src/tools/seo/generators/MetaGenerator.ts +694 -0
- package/src/tools/seo/generators/SchemaGenerator.ts +955 -0
- package/src/tools/seo/index.ts +47 -0
- package/src/tools/seo/optimizers/InternalLinkingSuggester.ts +934 -0
- package/src/tools/site.ts +27 -26
- package/src/tools/taxonomies.ts +29 -25
- package/src/tools/users.ts +20 -13
- package/src/types/client.ts +8 -6
- package/src/types/seo.ts +546 -0
- package/src/utils/enhancedError.ts +1 -1
- package/src/utils/error.ts +1 -2
- package/src/utils/index.ts +23 -0
- package/src/utils/logger.ts +3 -3
- package/src/utils/toolWrapper.ts +10 -10
- package/src/utils/validation/core.ts +2 -2
- package/src/utils/validation/index.ts +2 -2
- package/src/utils/validation/network.ts +5 -5
- package/src/utils/validation/rateLimit.ts +1 -1
- package/src/utils/validation/security.ts +1 -1
- package/src/utils/validation/wordpress.ts +1 -1
- package/src/utils/version.ts +402 -0
package/src/tools/comments.ts
CHANGED
|
@@ -14,7 +14,14 @@ export class CommentTools {
|
|
|
14
14
|
public getTools(): Array<{
|
|
15
15
|
name: string;
|
|
16
16
|
description: string;
|
|
17
|
-
parameters?: Array<{
|
|
17
|
+
parameters?: Array<{
|
|
18
|
+
name: string;
|
|
19
|
+
type?: string;
|
|
20
|
+
description?: string;
|
|
21
|
+
required?: boolean;
|
|
22
|
+
enum?: string[];
|
|
23
|
+
items?: unknown;
|
|
24
|
+
}>;
|
|
18
25
|
handler: (client: WordPressClient, params: Record<string, unknown>) => Promise<unknown>;
|
|
19
26
|
}> {
|
|
20
27
|
return [
|
|
@@ -165,8 +172,8 @@ export class CommentTools {
|
|
|
165
172
|
)
|
|
166
173
|
.join("\n");
|
|
167
174
|
return content;
|
|
168
|
-
} catch (
|
|
169
|
-
throw new Error(`Failed to list comments: ${getErrorMessage(
|
|
175
|
+
} catch (_error) {
|
|
176
|
+
throw new Error(`Failed to list comments: ${getErrorMessage(_error)}`);
|
|
170
177
|
}
|
|
171
178
|
}
|
|
172
179
|
|
|
@@ -182,8 +189,8 @@ export class CommentTools {
|
|
|
182
189
|
`- **Status:** ${comment.status}\n` +
|
|
183
190
|
`- **Content:** ${comment.content.rendered}`;
|
|
184
191
|
return content;
|
|
185
|
-
} catch (
|
|
186
|
-
throw new Error(`Failed to get comment: ${getErrorMessage(
|
|
192
|
+
} catch (_error) {
|
|
193
|
+
throw new Error(`Failed to get comment: ${getErrorMessage(_error)}`);
|
|
187
194
|
}
|
|
188
195
|
}
|
|
189
196
|
|
|
@@ -192,21 +199,18 @@ export class CommentTools {
|
|
|
192
199
|
try {
|
|
193
200
|
const comment = await client.createComment(createParams);
|
|
194
201
|
return `✅ Comment created successfully with ID: ${comment.id}`;
|
|
195
|
-
} catch (
|
|
196
|
-
throw new Error(`Failed to create comment: ${getErrorMessage(
|
|
202
|
+
} catch (_error) {
|
|
203
|
+
throw new Error(`Failed to create comment: ${getErrorMessage(_error)}`);
|
|
197
204
|
}
|
|
198
205
|
}
|
|
199
206
|
|
|
200
|
-
public async handleUpdateComment(
|
|
201
|
-
client: WordPressClient,
|
|
202
|
-
params: Record<string, unknown>,
|
|
203
|
-
): Promise<unknown> {
|
|
207
|
+
public async handleUpdateComment(client: WordPressClient, params: Record<string, unknown>): Promise<unknown> {
|
|
204
208
|
try {
|
|
205
209
|
const updateParams = params as unknown as UpdateCommentRequest & { id: number };
|
|
206
210
|
const comment = await client.updateComment(updateParams);
|
|
207
211
|
return `✅ Comment ${comment.id} updated successfully. New status: ${comment.status}.`;
|
|
208
|
-
} catch (
|
|
209
|
-
throw new Error(`Failed to update comment: ${getErrorMessage(
|
|
212
|
+
} catch (_error) {
|
|
213
|
+
throw new Error(`Failed to update comment: ${getErrorMessage(_error)}`);
|
|
210
214
|
}
|
|
211
215
|
}
|
|
212
216
|
|
|
@@ -216,8 +220,8 @@ export class CommentTools {
|
|
|
216
220
|
await client.deleteComment(id, force);
|
|
217
221
|
const action = force ? "permanently deleted" : "moved to trash";
|
|
218
222
|
return `✅ Comment ${id} has been ${action}`;
|
|
219
|
-
} catch (
|
|
220
|
-
throw new Error(`Failed to delete comment: ${getErrorMessage(
|
|
223
|
+
} catch (_error) {
|
|
224
|
+
throw new Error(`Failed to delete comment: ${getErrorMessage(_error)}`);
|
|
221
225
|
}
|
|
222
226
|
}
|
|
223
227
|
|
|
@@ -229,8 +233,8 @@ export class CommentTools {
|
|
|
229
233
|
status: "approved",
|
|
230
234
|
});
|
|
231
235
|
return `✅ Comment ${comment.id} has been approved.`;
|
|
232
|
-
} catch (
|
|
233
|
-
throw new Error(`Failed to approve comment: ${getErrorMessage(
|
|
236
|
+
} catch (_error) {
|
|
237
|
+
throw new Error(`Failed to approve comment: ${getErrorMessage(_error)}`);
|
|
234
238
|
}
|
|
235
239
|
}
|
|
236
240
|
|
|
@@ -242,8 +246,8 @@ export class CommentTools {
|
|
|
242
246
|
status: "spam",
|
|
243
247
|
});
|
|
244
248
|
return `✅ Comment ${comment.id} has been marked as spam.`;
|
|
245
|
-
} catch (
|
|
246
|
-
throw new Error(`Failed to mark comment as spam: ${getErrorMessage(
|
|
249
|
+
} catch (_error) {
|
|
250
|
+
throw new Error(`Failed to mark comment as spam: ${getErrorMessage(_error)}`);
|
|
247
251
|
}
|
|
248
252
|
}
|
|
249
253
|
}
|
package/src/tools/index.ts
CHANGED
|
@@ -5,6 +5,7 @@ export { default as MediaTools } from "./media.js";
|
|
|
5
5
|
export { default as PageTools } from "./pages.js";
|
|
6
6
|
export { default as PerformanceTools } from "./performance.js";
|
|
7
7
|
export { default as PostTools } from "./posts.js";
|
|
8
|
+
export { default as SEOTools } from "./seo/index.js";
|
|
8
9
|
export { default as SiteTools } from "./site.js";
|
|
9
10
|
export { default as TaxonomyTools } from "./taxonomies.js";
|
|
10
11
|
export { default as UserTools } from "./users.js";
|
package/src/tools/media.ts
CHANGED
|
@@ -54,7 +54,14 @@ export class MediaTools {
|
|
|
54
54
|
public getTools(): Array<{
|
|
55
55
|
name: string;
|
|
56
56
|
description: string;
|
|
57
|
-
parameters?: Array<{
|
|
57
|
+
parameters?: Array<{
|
|
58
|
+
name: string;
|
|
59
|
+
type?: string;
|
|
60
|
+
description?: string;
|
|
61
|
+
required?: boolean;
|
|
62
|
+
enum?: string[];
|
|
63
|
+
items?: unknown;
|
|
64
|
+
}>;
|
|
58
65
|
handler: (client: WordPressClient, params: Record<string, unknown>) => Promise<unknown>;
|
|
59
66
|
}> {
|
|
60
67
|
return [
|
|
@@ -197,8 +204,8 @@ export class MediaTools {
|
|
|
197
204
|
`Found ${media.length} media items:\n\n` +
|
|
198
205
|
media.map((m) => `- ID ${m.id}: **${m.title.rendered}** (${m.mime_type})\n Link: ${m.source_url}`).join("\n");
|
|
199
206
|
return content;
|
|
200
|
-
} catch (
|
|
201
|
-
throw new Error(`Failed to list media: ${getErrorMessage(
|
|
207
|
+
} catch (_error) {
|
|
208
|
+
throw new Error(`Failed to list media: ${getErrorMessage(_error)}`);
|
|
202
209
|
}
|
|
203
210
|
}
|
|
204
211
|
|
|
@@ -215,38 +222,34 @@ export class MediaTools {
|
|
|
215
222
|
(media.alt_text ? `- **Alt Text:** ${media.alt_text}\n` : "") +
|
|
216
223
|
(media.caption.rendered ? `- **Caption:** ${media.caption.rendered}\n` : "");
|
|
217
224
|
return content;
|
|
218
|
-
} catch (
|
|
219
|
-
throw new Error(`Failed to get media item: ${getErrorMessage(
|
|
225
|
+
} catch (_error) {
|
|
226
|
+
throw new Error(`Failed to get media item: ${getErrorMessage(_error)}`);
|
|
220
227
|
}
|
|
221
228
|
}
|
|
222
229
|
|
|
223
|
-
public async handleUploadMedia(
|
|
224
|
-
client: WordPressClient,
|
|
225
|
-
params: Record<string, unknown>,
|
|
226
|
-
): Promise<unknown> {
|
|
230
|
+
public async handleUploadMedia(client: WordPressClient, params: Record<string, unknown>): Promise<unknown> {
|
|
227
231
|
const uploadParams = params as unknown as UploadMediaRequest & { file_path: string };
|
|
228
232
|
try {
|
|
229
|
-
|
|
233
|
+
try {
|
|
234
|
+
await fs.promises.access(uploadParams.file_path);
|
|
235
|
+
} catch (_error) {
|
|
230
236
|
throw new Error(`File not found at path: ${uploadParams.file_path}`);
|
|
231
237
|
}
|
|
232
238
|
|
|
233
239
|
const media = await client.uploadMedia(uploadParams);
|
|
234
240
|
return `✅ Media uploaded successfully!\n- ID: ${media.id}\n- Title: ${media.title.rendered}\n- URL: ${media.source_url}`;
|
|
235
|
-
} catch (
|
|
236
|
-
throw new Error(`Failed to upload media: ${getErrorMessage(
|
|
241
|
+
} catch (_error) {
|
|
242
|
+
throw new Error(`Failed to upload media: ${getErrorMessage(_error)}`);
|
|
237
243
|
}
|
|
238
244
|
}
|
|
239
245
|
|
|
240
|
-
public async handleUpdateMedia(
|
|
241
|
-
client: WordPressClient,
|
|
242
|
-
params: Record<string, unknown>,
|
|
243
|
-
): Promise<unknown> {
|
|
246
|
+
public async handleUpdateMedia(client: WordPressClient, params: Record<string, unknown>): Promise<unknown> {
|
|
244
247
|
const updateParams = params as unknown as UpdateMediaRequest & { id: number };
|
|
245
248
|
try {
|
|
246
249
|
const media = await client.updateMedia(updateParams);
|
|
247
250
|
return `✅ Media ${media.id} updated successfully.`;
|
|
248
|
-
} catch (
|
|
249
|
-
throw new Error(`Failed to update media: ${getErrorMessage(
|
|
251
|
+
} catch (_error) {
|
|
252
|
+
throw new Error(`Failed to update media: ${getErrorMessage(_error)}`);
|
|
250
253
|
}
|
|
251
254
|
}
|
|
252
255
|
|
|
@@ -256,8 +259,8 @@ export class MediaTools {
|
|
|
256
259
|
await client.deleteMedia(id, force);
|
|
257
260
|
const action = force ? "permanently deleted" : "moved to trash";
|
|
258
261
|
return `✅ Media item ${id} has been ${action}`;
|
|
259
|
-
} catch (
|
|
260
|
-
throw new Error(`Failed to delete media: ${getErrorMessage(
|
|
262
|
+
} catch (_error) {
|
|
263
|
+
throw new Error(`Failed to delete media: ${getErrorMessage(_error)}`);
|
|
261
264
|
}
|
|
262
265
|
}
|
|
263
266
|
}
|
package/src/tools/pages.ts
CHANGED
|
@@ -14,7 +14,14 @@ export class PageTools {
|
|
|
14
14
|
public getTools(): Array<{
|
|
15
15
|
name: string;
|
|
16
16
|
description: string;
|
|
17
|
-
parameters?: Array<{
|
|
17
|
+
parameters?: Array<{
|
|
18
|
+
name: string;
|
|
19
|
+
type?: string;
|
|
20
|
+
description?: string;
|
|
21
|
+
required?: boolean;
|
|
22
|
+
enum?: string[];
|
|
23
|
+
items?: unknown;
|
|
24
|
+
}>;
|
|
18
25
|
handler: (client: WordPressClient, params: Record<string, unknown>) => Promise<unknown>;
|
|
19
26
|
}> {
|
|
20
27
|
return [
|
|
@@ -152,8 +159,8 @@ export class PageTools {
|
|
|
152
159
|
`Found ${pages.length} pages:\n\n` +
|
|
153
160
|
pages.map((p) => `- ID ${p.id}: **${p.title.rendered}** (${p.status})\n Link: ${p.link}`).join("\n");
|
|
154
161
|
return content;
|
|
155
|
-
} catch (
|
|
156
|
-
throw new Error(`Failed to list pages: ${getErrorMessage(
|
|
162
|
+
} catch (_error) {
|
|
163
|
+
throw new Error(`Failed to list pages: ${getErrorMessage(_error)}`);
|
|
157
164
|
}
|
|
158
165
|
}
|
|
159
166
|
|
|
@@ -168,8 +175,8 @@ export class PageTools {
|
|
|
168
175
|
`- **Link:** ${page.link}\n` +
|
|
169
176
|
`- **Date:** ${new Date(page.date).toLocaleString()}`;
|
|
170
177
|
return content;
|
|
171
|
-
} catch (
|
|
172
|
-
throw new Error(`Failed to get page: ${getErrorMessage(
|
|
178
|
+
} catch (_error) {
|
|
179
|
+
throw new Error(`Failed to get page: ${getErrorMessage(_error)}`);
|
|
173
180
|
}
|
|
174
181
|
}
|
|
175
182
|
|
|
@@ -178,8 +185,8 @@ export class PageTools {
|
|
|
178
185
|
try {
|
|
179
186
|
const page = await client.createPage(createParams);
|
|
180
187
|
return `✅ Page created successfully!\n- ID: ${page.id}\n- Title: ${page.title.rendered}\n- Link: ${page.link}`;
|
|
181
|
-
} catch (
|
|
182
|
-
throw new Error(`Failed to create page: ${getErrorMessage(
|
|
188
|
+
} catch (_error) {
|
|
189
|
+
throw new Error(`Failed to create page: ${getErrorMessage(_error)}`);
|
|
183
190
|
}
|
|
184
191
|
}
|
|
185
192
|
|
|
@@ -188,8 +195,8 @@ export class PageTools {
|
|
|
188
195
|
try {
|
|
189
196
|
const page = await client.updatePage(updateParams);
|
|
190
197
|
return `✅ Page ${page.id} updated successfully.`;
|
|
191
|
-
} catch (
|
|
192
|
-
throw new Error(`Failed to update page: ${getErrorMessage(
|
|
198
|
+
} catch (_error) {
|
|
199
|
+
throw new Error(`Failed to update page: ${getErrorMessage(_error)}`);
|
|
193
200
|
}
|
|
194
201
|
}
|
|
195
202
|
|
|
@@ -199,8 +206,8 @@ export class PageTools {
|
|
|
199
206
|
await client.deletePage(id, force);
|
|
200
207
|
const action = params.force ? "permanently deleted" : "moved to trash";
|
|
201
208
|
return `✅ Page ${id} has been ${action}.`;
|
|
202
|
-
} catch (
|
|
203
|
-
throw new Error(`Failed to delete page: ${getErrorMessage(
|
|
209
|
+
} catch (_error) {
|
|
210
|
+
throw new Error(`Failed to delete page: ${getErrorMessage(_error)}`);
|
|
204
211
|
}
|
|
205
212
|
}
|
|
206
213
|
|
|
@@ -217,8 +224,8 @@ export class PageTools {
|
|
|
217
224
|
.map((r) => `- Revision by user ID ${r.author} at ${new Date(r.modified).toLocaleString()}`)
|
|
218
225
|
.join("\n");
|
|
219
226
|
return content;
|
|
220
|
-
} catch (
|
|
221
|
-
throw new Error(`Failed to get page revisions: ${getErrorMessage(
|
|
227
|
+
} catch (_error) {
|
|
228
|
+
throw new Error(`Failed to get page revisions: ${getErrorMessage(_error)}`);
|
|
222
229
|
}
|
|
223
230
|
}
|
|
224
231
|
}
|
package/src/tools/performance.ts
CHANGED
|
@@ -8,9 +8,17 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
import type { ToolDefinition } from "../server/ToolRegistry.js";
|
|
11
|
-
import {
|
|
11
|
+
import {
|
|
12
|
+
PerformanceMonitor,
|
|
13
|
+
type PerformanceMetrics,
|
|
14
|
+
type PerformanceAlert,
|
|
15
|
+
} from "../performance/PerformanceMonitor.js";
|
|
12
16
|
import { MetricsCollector } from "../performance/MetricsCollector.js";
|
|
13
|
-
import {
|
|
17
|
+
import {
|
|
18
|
+
PerformanceAnalytics,
|
|
19
|
+
type BenchmarkComparison,
|
|
20
|
+
type PerformanceAnomaly,
|
|
21
|
+
} from "../performance/PerformanceAnalytics.js";
|
|
14
22
|
import { toolWrapper } from "../utils/toolWrapper.js";
|
|
15
23
|
import { ConfigHelpers } from "../config/Config.js";
|
|
16
24
|
import { LoggerFactory } from "../utils/logger.js";
|
|
@@ -25,10 +33,13 @@ export default class PerformanceTools {
|
|
|
25
33
|
private monitor: PerformanceMonitor;
|
|
26
34
|
private collector: MetricsCollector;
|
|
27
35
|
private analytics: PerformanceAnalytics;
|
|
28
|
-
private logger
|
|
36
|
+
private logger: ReturnType<typeof LoggerFactory.performance>;
|
|
29
37
|
private historicalDataInterval?: NodeJS.Timeout | undefined;
|
|
30
38
|
|
|
31
39
|
constructor(clients?: Map<string, unknown>) {
|
|
40
|
+
// Initialize logger first
|
|
41
|
+
this.logger = LoggerFactory.performance();
|
|
42
|
+
|
|
32
43
|
// Initialize performance monitoring system
|
|
33
44
|
this.monitor = new PerformanceMonitor({
|
|
34
45
|
enableRealTimeMonitoring: true,
|
|
@@ -273,15 +284,19 @@ export default class PerformanceTools {
|
|
|
273
284
|
*/
|
|
274
285
|
private async getPerformanceStats(_client: WordPressClient, params: Record<string, unknown>): Promise<unknown> {
|
|
275
286
|
return toolWrapper(async () => {
|
|
276
|
-
const {
|
|
287
|
+
const {
|
|
288
|
+
site,
|
|
289
|
+
category = "overview",
|
|
290
|
+
format = "summary",
|
|
291
|
+
} = params as { site?: string; category?: string; format?: string };
|
|
277
292
|
|
|
278
293
|
// Get current metrics
|
|
279
|
-
|
|
294
|
+
const metrics = this.collector.collectCurrentMetrics();
|
|
280
295
|
|
|
281
296
|
// Get site-specific metrics if requested
|
|
282
297
|
let siteMetrics = null;
|
|
283
298
|
if (site) {
|
|
284
|
-
|
|
299
|
+
siteMetrics = this.collector.getSiteMetrics(site as string);
|
|
285
300
|
}
|
|
286
301
|
|
|
287
302
|
// Filter by category
|
|
@@ -372,20 +387,25 @@ export default class PerformanceTools {
|
|
|
372
387
|
*/
|
|
373
388
|
private async getPerformanceHistory(_client: WordPressClient, params: Record<string, unknown>): Promise<unknown> {
|
|
374
389
|
return toolWrapper(async () => {
|
|
375
|
-
const {
|
|
390
|
+
const {
|
|
391
|
+
site,
|
|
392
|
+
timeframe = "24h",
|
|
393
|
+
metrics: requestedMetrics,
|
|
394
|
+
includeTrends = true,
|
|
395
|
+
} = params as { site?: string; timeframe?: string; metrics?: string[]; includeTrends?: boolean };
|
|
376
396
|
|
|
377
397
|
// Convert timeframe to milliseconds
|
|
378
398
|
const timeframMs = this.parseTimeframe(timeframe);
|
|
379
399
|
const startTime = Date.now() - timeframMs;
|
|
380
400
|
|
|
381
401
|
// Get historical data
|
|
382
|
-
|
|
402
|
+
const historicalData = this.monitor.getHistoricalData(startTime);
|
|
383
403
|
|
|
384
404
|
// Analyze trends if requested
|
|
385
405
|
let trends = null;
|
|
386
406
|
if (includeTrends) {
|
|
387
407
|
// Add current data for trend analysis
|
|
388
|
-
|
|
408
|
+
this.analytics.addDataPoint(this.collector.collectCurrentMetrics());
|
|
389
409
|
trends = this.analytics.analyzeTrends();
|
|
390
410
|
|
|
391
411
|
// Filter trends by requested metrics
|
|
@@ -395,7 +415,7 @@ export default class PerformanceTools {
|
|
|
395
415
|
}
|
|
396
416
|
|
|
397
417
|
// Process historical data for charting
|
|
398
|
-
|
|
418
|
+
const chartData = this.processHistoricalDataForChart(historicalData, requestedMetrics as string[] | undefined);
|
|
399
419
|
|
|
400
420
|
return {
|
|
401
421
|
success: true,
|
|
@@ -427,10 +447,14 @@ export default class PerformanceTools {
|
|
|
427
447
|
*/
|
|
428
448
|
private async getBenchmarkComparison(_client: WordPressClient, params: Record<string, unknown>): Promise<unknown> {
|
|
429
449
|
return toolWrapper(async () => {
|
|
430
|
-
const {
|
|
450
|
+
const {
|
|
451
|
+
site,
|
|
452
|
+
category = "all",
|
|
453
|
+
includeRecommendations = true,
|
|
454
|
+
} = params as { site?: string; category?: string; includeRecommendations?: boolean };
|
|
431
455
|
|
|
432
456
|
// Get benchmark comparisons
|
|
433
|
-
|
|
457
|
+
const benchmarks = this.analytics.benchmarkPerformance() as BenchmarkComparison[];
|
|
434
458
|
|
|
435
459
|
// Filter by category if specified
|
|
436
460
|
let filteredBenchmarks = benchmarks;
|
|
@@ -441,7 +465,7 @@ export default class PerformanceTools {
|
|
|
441
465
|
error_rate: "Error Rate",
|
|
442
466
|
system_resources: "Memory Usage",
|
|
443
467
|
};
|
|
444
|
-
|
|
468
|
+
const targetCategory = categoryMap[category as string];
|
|
445
469
|
if (targetCategory) {
|
|
446
470
|
filteredBenchmarks = benchmarks.filter((b) => b.category === targetCategory);
|
|
447
471
|
}
|
|
@@ -494,10 +518,16 @@ export default class PerformanceTools {
|
|
|
494
518
|
*/
|
|
495
519
|
private async getPerformanceAlerts(_client: WordPressClient, params: Record<string, unknown>): Promise<unknown> {
|
|
496
520
|
return toolWrapper(async () => {
|
|
497
|
-
const {
|
|
521
|
+
const {
|
|
522
|
+
site,
|
|
523
|
+
severity,
|
|
524
|
+
category,
|
|
525
|
+
limit = 20,
|
|
526
|
+
includeAnomalies = true,
|
|
527
|
+
} = params as { site?: string; severity?: string; category?: string; limit?: number; includeAnomalies?: boolean };
|
|
498
528
|
|
|
499
529
|
// Get alerts from monitor
|
|
500
|
-
|
|
530
|
+
let alerts = this.monitor.getAlerts(severity) as PerformanceAlert[];
|
|
501
531
|
|
|
502
532
|
// Filter by category if specified
|
|
503
533
|
if (category) {
|
|
@@ -505,7 +535,7 @@ export default class PerformanceTools {
|
|
|
505
535
|
}
|
|
506
536
|
|
|
507
537
|
// Limit results
|
|
508
|
-
|
|
538
|
+
alerts = alerts.slice(-(limit as number));
|
|
509
539
|
|
|
510
540
|
// Get anomalies if requested
|
|
511
541
|
let anomalies: PerformanceAnomaly[] = [];
|
|
@@ -561,15 +591,35 @@ export default class PerformanceTools {
|
|
|
561
591
|
/**
|
|
562
592
|
* Get optimization recommendations
|
|
563
593
|
*/
|
|
564
|
-
private async getOptimizationRecommendations(
|
|
594
|
+
private async getOptimizationRecommendations(
|
|
595
|
+
_client: WordPressClient,
|
|
596
|
+
params: Record<string, unknown>,
|
|
597
|
+
): Promise<unknown> {
|
|
565
598
|
return toolWrapper(async () => {
|
|
566
|
-
const {
|
|
599
|
+
const {
|
|
600
|
+
site,
|
|
601
|
+
focus = "speed",
|
|
602
|
+
priority = "all",
|
|
603
|
+
includeROI = true,
|
|
604
|
+
includePredictions = true,
|
|
605
|
+
} = params as {
|
|
606
|
+
site?: string;
|
|
607
|
+
focus?: string;
|
|
608
|
+
priority?: string;
|
|
609
|
+
includeROI?: boolean;
|
|
610
|
+
includePredictions?: boolean;
|
|
611
|
+
};
|
|
567
612
|
|
|
568
613
|
// Generate optimization plan
|
|
569
614
|
const optimizationPlan = this.analytics.generateOptimizationPlan();
|
|
570
615
|
|
|
571
616
|
// Filter by priority
|
|
572
|
-
|
|
617
|
+
let recommendations: Array<{
|
|
618
|
+
priority: string;
|
|
619
|
+
impact: string;
|
|
620
|
+
implementationEffort: string;
|
|
621
|
+
[key: string]: unknown;
|
|
622
|
+
}> = [];
|
|
573
623
|
if (priority === "quick_wins" || priority === "all") {
|
|
574
624
|
recommendations.push(
|
|
575
625
|
...optimizationPlan.quickWins.map((r) => ({
|
|
@@ -596,7 +646,7 @@ export default class PerformanceTools {
|
|
|
596
646
|
}
|
|
597
647
|
|
|
598
648
|
// Filter by focus area
|
|
599
|
-
|
|
649
|
+
if (focus !== "speed") {
|
|
600
650
|
const focusMap: Record<string, string[]> = {
|
|
601
651
|
reliability: ["reliability"],
|
|
602
652
|
efficiency: ["cost", "performance"],
|
|
@@ -607,7 +657,7 @@ export default class PerformanceTools {
|
|
|
607
657
|
}
|
|
608
658
|
|
|
609
659
|
// Get predictions if requested
|
|
610
|
-
|
|
660
|
+
let predictions: Record<string, unknown> | null = null;
|
|
611
661
|
if (includePredictions) {
|
|
612
662
|
predictions = this.analytics.predictPerformance(60); // 1 hour prediction
|
|
613
663
|
}
|
|
@@ -645,13 +695,25 @@ export default class PerformanceTools {
|
|
|
645
695
|
*/
|
|
646
696
|
private async exportPerformanceReport(_client: WordPressClient, params: Record<string, unknown>): Promise<unknown> {
|
|
647
697
|
return toolWrapper(async () => {
|
|
648
|
-
const {
|
|
698
|
+
const {
|
|
699
|
+
site,
|
|
700
|
+
format = "json",
|
|
701
|
+
includeHistorical = true,
|
|
702
|
+
includeAnalytics = true,
|
|
703
|
+
timeRange = "24h",
|
|
704
|
+
} = params as {
|
|
705
|
+
site?: string;
|
|
706
|
+
format?: string;
|
|
707
|
+
includeHistorical?: boolean;
|
|
708
|
+
includeAnalytics?: boolean;
|
|
709
|
+
timeRange?: string;
|
|
710
|
+
};
|
|
649
711
|
|
|
650
712
|
// Generate comprehensive analytics report
|
|
651
713
|
const report = this.analytics.exportAnalyticsReport();
|
|
652
714
|
|
|
653
715
|
// Add additional data based on parameters
|
|
654
|
-
|
|
716
|
+
const exportData: { currentMetrics: PerformanceMetrics; [key: string]: unknown } = {
|
|
655
717
|
metadata: {
|
|
656
718
|
generatedAt: new Date().toISOString(),
|
|
657
719
|
site: site || "all",
|
|
@@ -660,7 +722,7 @@ export default class PerformanceTools {
|
|
|
660
722
|
version: "1.0.0",
|
|
661
723
|
},
|
|
662
724
|
summary: report.summary,
|
|
663
|
-
|
|
725
|
+
currentMetrics: this.collector.collectCurrentMetrics(),
|
|
664
726
|
};
|
|
665
727
|
|
|
666
728
|
if (includeHistorical) {
|
|
@@ -798,7 +860,10 @@ export default class PerformanceTools {
|
|
|
798
860
|
return map[timeframe] || map["24h"];
|
|
799
861
|
}
|
|
800
862
|
|
|
801
|
-
private processHistoricalDataForChart(
|
|
863
|
+
private processHistoricalDataForChart(
|
|
864
|
+
data: PerformanceMetrics[],
|
|
865
|
+
requestedMetrics?: string[],
|
|
866
|
+
): Record<string, unknown> {
|
|
802
867
|
if (!data.length) return {};
|
|
803
868
|
|
|
804
869
|
const allMetrics = ["responseTime", "cacheHitRate", "errorRate", "memoryUsage", "requestVolume"];
|
|
@@ -887,7 +952,10 @@ export default class PerformanceTools {
|
|
|
887
952
|
return `${anomaly.metric} is ${Math.abs(anomaly.deviation).toFixed(1)}% ${direction} than expected (${anomaly.expectedValue.toFixed(2)} vs ${anomaly.actualValue.toFixed(2)})`;
|
|
888
953
|
}
|
|
889
954
|
|
|
890
|
-
private calculateAlertStatus(
|
|
955
|
+
private calculateAlertStatus(
|
|
956
|
+
alertSummary: { critical: number; error: number; warning: number },
|
|
957
|
+
anomalySummary: { critical: number; major: number; moderate: number; minor: number },
|
|
958
|
+
): string {
|
|
891
959
|
const critical = alertSummary.critical + anomalySummary.critical;
|
|
892
960
|
const high = alertSummary.error + anomalySummary.major;
|
|
893
961
|
|
|
@@ -916,9 +984,7 @@ export default class PerformanceTools {
|
|
|
916
984
|
return map[effort] || effort;
|
|
917
985
|
}
|
|
918
986
|
|
|
919
|
-
private calculateEstimatedImpact(
|
|
920
|
-
recommendations: Array<{ priority: string }>,
|
|
921
|
-
): string {
|
|
987
|
+
private calculateEstimatedImpact(recommendations: Array<{ priority: string }>): string {
|
|
922
988
|
const highImpact = recommendations.filter((r) => ["critical", "high"].includes(r.priority)).length;
|
|
923
989
|
const totalImpact = recommendations.length;
|
|
924
990
|
|
|
@@ -945,7 +1011,10 @@ export default class PerformanceTools {
|
|
|
945
1011
|
return csv.join("\n");
|
|
946
1012
|
}
|
|
947
1013
|
|
|
948
|
-
private createSummaryReport(data: {
|
|
1014
|
+
private createSummaryReport(data: {
|
|
1015
|
+
currentMetrics: PerformanceMetrics;
|
|
1016
|
+
analytics?: { insights?: unknown[] };
|
|
1017
|
+
}): Record<string, unknown> {
|
|
949
1018
|
const metrics = data.currentMetrics;
|
|
950
1019
|
return {
|
|
951
1020
|
summary: `Performance Report - ${new Date().toISOString()}`,
|
|
@@ -983,9 +1052,9 @@ export default class PerformanceTools {
|
|
|
983
1052
|
this.logger.debug("Historical metrics collected", {
|
|
984
1053
|
timestamp: new Date().toISOString(),
|
|
985
1054
|
});
|
|
986
|
-
} catch (
|
|
1055
|
+
} catch (_error) {
|
|
987
1056
|
this.logger.error("Failed to collect historical metrics", {
|
|
988
|
-
|
|
1057
|
+
_error: _error instanceof Error ? _error.message : String(_error),
|
|
989
1058
|
});
|
|
990
1059
|
}
|
|
991
1060
|
}, interval);
|
|
@@ -6,13 +6,13 @@
|
|
|
6
6
|
* validation, API interaction, and response formatting.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import { WordPressClient } from "
|
|
10
|
-
import { CreatePostRequest, PostQueryParams, UpdatePostRequest, WordPressPost } from "
|
|
11
|
-
import { getErrorMessage } from "
|
|
12
|
-
import { ErrorHandlers } from "
|
|
13
|
-
import { validateId, validatePaginationParams, validatePostParams } from "
|
|
14
|
-
import { sanitizeHtml } from "
|
|
15
|
-
import { WordPressDataStreamer, StreamingUtils, StreamingResult } from "
|
|
9
|
+
import { WordPressClient } from "@/client/api.js";
|
|
10
|
+
import { CreatePostRequest, PostQueryParams, UpdatePostRequest, WordPressPost } from "@/types/wordpress.js";
|
|
11
|
+
import { getErrorMessage } from "@/utils/error.js";
|
|
12
|
+
import { ErrorHandlers } from "@/utils/enhancedError.js";
|
|
13
|
+
import { validateId, validatePaginationParams, validatePostParams } from "@/utils/validation.js";
|
|
14
|
+
import { sanitizeHtml } from "@/utils/validation/security.js";
|
|
15
|
+
import { WordPressDataStreamer, StreamingUtils, StreamingResult } from "@/utils/streaming.js";
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* Handles listing WordPress posts with advanced filtering and pagination
|
|
@@ -208,8 +208,8 @@ export async function handleListPosts(
|
|
|
208
208
|
}
|
|
209
209
|
|
|
210
210
|
return finalContent;
|
|
211
|
-
} catch (
|
|
212
|
-
throw new Error(`Failed to list posts: ${getErrorMessage(
|
|
211
|
+
} catch (_error) {
|
|
212
|
+
throw new Error(`Failed to list posts: ${getErrorMessage(_error)}`);
|
|
213
213
|
}
|
|
214
214
|
}
|
|
215
215
|
|
|
@@ -295,11 +295,11 @@ export async function handleGetPost(client: WordPressClient, params: { id: numbe
|
|
|
295
295
|
}
|
|
296
296
|
|
|
297
297
|
return response;
|
|
298
|
-
} catch (
|
|
299
|
-
if (
|
|
298
|
+
} catch (_error) {
|
|
299
|
+
if (_error instanceof Error && _error.message.includes("404")) {
|
|
300
300
|
return `Post with ID ${params.id} not found. Please verify the ID and try again.`;
|
|
301
301
|
}
|
|
302
|
-
throw new Error(`Failed to get post: ${getErrorMessage(
|
|
302
|
+
throw new Error(`Failed to get post: ${getErrorMessage(_error)}`);
|
|
303
303
|
}
|
|
304
304
|
}
|
|
305
305
|
|
|
@@ -334,8 +334,8 @@ export async function handleCreatePost(
|
|
|
334
334
|
}
|
|
335
335
|
|
|
336
336
|
return response;
|
|
337
|
-
} catch (
|
|
338
|
-
throw new Error(`Failed to create post: ${getErrorMessage(
|
|
337
|
+
} catch (_error) {
|
|
338
|
+
throw new Error(`Failed to create post: ${getErrorMessage(_error)}`);
|
|
339
339
|
}
|
|
340
340
|
}
|
|
341
341
|
|
|
@@ -386,11 +386,11 @@ export async function handleUpdatePost(
|
|
|
386
386
|
response += `\n**Link**: ${updatedPost.link}`;
|
|
387
387
|
|
|
388
388
|
return response;
|
|
389
|
-
} catch (
|
|
390
|
-
if (
|
|
389
|
+
} catch (_error) {
|
|
390
|
+
if (_error instanceof Error && _error.message.includes("404")) {
|
|
391
391
|
return `Post with ID ${params.id} not found. Please verify the ID and try again.`;
|
|
392
392
|
}
|
|
393
|
-
throw new Error(`Failed to update post: ${getErrorMessage(
|
|
393
|
+
throw new Error(`Failed to update post: ${getErrorMessage(_error)}`);
|
|
394
394
|
}
|
|
395
395
|
}
|
|
396
396
|
|
|
@@ -422,11 +422,11 @@ export async function handleDeletePost(
|
|
|
422
422
|
} else {
|
|
423
423
|
return `Failed to delete post with ID ${params.id}. It may not exist or you may not have permission.`;
|
|
424
424
|
}
|
|
425
|
-
} catch (
|
|
426
|
-
if (
|
|
425
|
+
} catch (_error) {
|
|
426
|
+
if (_error instanceof Error && _error.message.includes("404")) {
|
|
427
427
|
return `Post with ID ${params.id} not found. Please verify the ID and try again.`;
|
|
428
428
|
}
|
|
429
|
-
throw new Error(`Failed to delete post: ${getErrorMessage(
|
|
429
|
+
throw new Error(`Failed to delete post: ${getErrorMessage(_error)}`);
|
|
430
430
|
}
|
|
431
431
|
}
|
|
432
432
|
|
|
@@ -465,10 +465,10 @@ export async function handleGetPostRevisions(
|
|
|
465
465
|
});
|
|
466
466
|
|
|
467
467
|
return response;
|
|
468
|
-
} catch (
|
|
469
|
-
if (
|
|
468
|
+
} catch (_error) {
|
|
469
|
+
if (_error instanceof Error && _error.message.includes("404")) {
|
|
470
470
|
return `Post with ID ${params.id} not found. Please verify the ID and try again.`;
|
|
471
471
|
}
|
|
472
|
-
throw new Error(`Failed to get post revisions: ${getErrorMessage(
|
|
472
|
+
throw new Error(`Failed to get post revisions: ${getErrorMessage(_error)}`);
|
|
473
473
|
}
|
|
474
474
|
}
|