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/types/seo.ts
ADDED
|
@@ -0,0 +1,546 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SEO Type Definitions
|
|
3
|
+
*
|
|
4
|
+
* This module defines all TypeScript interfaces and types used by the SEO toolkit.
|
|
5
|
+
* It provides comprehensive type safety for SEO operations including analysis,
|
|
6
|
+
* metadata generation, schema markup, and site audits.
|
|
7
|
+
*
|
|
8
|
+
* @since 2.7.0
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { z } from "zod";
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* SEO analysis types for different evaluation modes
|
|
15
|
+
*/
|
|
16
|
+
export type SEOAnalysisType = "readability" | "keywords" | "structure" | "full";
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Priority levels for SEO recommendations
|
|
20
|
+
*/
|
|
21
|
+
export type SEOPriority = "low" | "medium" | "high" | "critical";
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Supported schema.org types for structured data
|
|
25
|
+
*/
|
|
26
|
+
export type SchemaType =
|
|
27
|
+
| "Article"
|
|
28
|
+
| "Product"
|
|
29
|
+
| "FAQ"
|
|
30
|
+
| "HowTo"
|
|
31
|
+
| "Organization"
|
|
32
|
+
| "Website"
|
|
33
|
+
| "BreadcrumbList"
|
|
34
|
+
| "Event"
|
|
35
|
+
| "Recipe"
|
|
36
|
+
| "Course"
|
|
37
|
+
| "LocalBusiness"
|
|
38
|
+
| "Person"
|
|
39
|
+
| "Review"
|
|
40
|
+
| "VideoObject";
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Base parameters for all SEO tool operations
|
|
44
|
+
*/
|
|
45
|
+
export interface SEOToolParams {
|
|
46
|
+
/** Target site identifier for multi-site setups */
|
|
47
|
+
site?: string;
|
|
48
|
+
|
|
49
|
+
/** WordPress post ID */
|
|
50
|
+
postId?: number;
|
|
51
|
+
|
|
52
|
+
/** Multiple post IDs for bulk operations */
|
|
53
|
+
postIds?: number[];
|
|
54
|
+
|
|
55
|
+
/** Type of SEO analysis to perform */
|
|
56
|
+
analysisType?: SEOAnalysisType;
|
|
57
|
+
|
|
58
|
+
/** Schema type for structured data generation */
|
|
59
|
+
schemaType?: SchemaType;
|
|
60
|
+
|
|
61
|
+
/** Focus keywords for optimization */
|
|
62
|
+
focusKeywords?: string[];
|
|
63
|
+
|
|
64
|
+
/** Target locale for content optimization */
|
|
65
|
+
locale?: string;
|
|
66
|
+
|
|
67
|
+
/** Updates to apply in bulk operations */
|
|
68
|
+
updates?: Partial<SEOMetadata>;
|
|
69
|
+
|
|
70
|
+
/** Dry run mode for testing without changes */
|
|
71
|
+
dryRun?: boolean;
|
|
72
|
+
|
|
73
|
+
/** Force refresh, bypassing cache */
|
|
74
|
+
force?: boolean;
|
|
75
|
+
|
|
76
|
+
/** Type of audit to perform */
|
|
77
|
+
auditType?: "technical" | "content" | "performance" | "full";
|
|
78
|
+
|
|
79
|
+
/** Raw schema JSON for validation */
|
|
80
|
+
schema?: unknown;
|
|
81
|
+
|
|
82
|
+
/** Check plugins flag for integration testing */
|
|
83
|
+
checkPlugins?: boolean;
|
|
84
|
+
|
|
85
|
+
/** Test metadata access flag for integration testing */
|
|
86
|
+
testMetadataAccess?: boolean;
|
|
87
|
+
|
|
88
|
+
/** Include analysis flag for live data retrieval */
|
|
89
|
+
includeAnalysis?: boolean;
|
|
90
|
+
|
|
91
|
+
/** Include recommendations flag for live data retrieval */
|
|
92
|
+
includeRecommendations?: boolean;
|
|
93
|
+
|
|
94
|
+
/** Use Google validator for schema validation */
|
|
95
|
+
useGoogleValidator?: boolean;
|
|
96
|
+
|
|
97
|
+
/** Custom data for schema generation or other operations */
|
|
98
|
+
customData?: unknown;
|
|
99
|
+
|
|
100
|
+
/** Title for metadata generation */
|
|
101
|
+
title?: string;
|
|
102
|
+
|
|
103
|
+
/** Description for metadata generation */
|
|
104
|
+
description?: string;
|
|
105
|
+
|
|
106
|
+
/** Maximum number of suggestions for internal linking */
|
|
107
|
+
maxSuggestions?: number;
|
|
108
|
+
|
|
109
|
+
/** Minimum relevance score for suggestions */
|
|
110
|
+
minimumRelevance?: number;
|
|
111
|
+
|
|
112
|
+
/** Maximum pages to audit */
|
|
113
|
+
maxPages?: number;
|
|
114
|
+
|
|
115
|
+
/** Include external links in audit */
|
|
116
|
+
includeExternalLinks?: boolean;
|
|
117
|
+
|
|
118
|
+
/** Include technical audit */
|
|
119
|
+
includeTechnical?: boolean;
|
|
120
|
+
|
|
121
|
+
/** Include content audit */
|
|
122
|
+
includeContent?: boolean;
|
|
123
|
+
|
|
124
|
+
/** Include architecture audit */
|
|
125
|
+
includeArchitecture?: boolean;
|
|
126
|
+
|
|
127
|
+
/** Include performance audit */
|
|
128
|
+
includePerformance?: boolean;
|
|
129
|
+
|
|
130
|
+
/** Include accessibility audit */
|
|
131
|
+
includeAccessibility?: boolean;
|
|
132
|
+
|
|
133
|
+
/** Minimum severity level for audit */
|
|
134
|
+
minSeverity?: "low" | "medium" | "high" | "critical";
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* SEO recommendation with actionable insights
|
|
139
|
+
*/
|
|
140
|
+
export interface SEORecommendation {
|
|
141
|
+
/** Category of the recommendation */
|
|
142
|
+
type: "title" | "meta" | "content" | "structure" | "keyword" | "technical" | "performance";
|
|
143
|
+
|
|
144
|
+
/** Priority level of the issue */
|
|
145
|
+
priority: SEOPriority;
|
|
146
|
+
|
|
147
|
+
/** Human-readable recommendation message */
|
|
148
|
+
message: string;
|
|
149
|
+
|
|
150
|
+
/** Estimated impact on SEO (0-100) */
|
|
151
|
+
impact: number;
|
|
152
|
+
|
|
153
|
+
/** Whether an automatic fix is available */
|
|
154
|
+
autoFixAvailable: boolean;
|
|
155
|
+
|
|
156
|
+
/** Suggested fix if available */
|
|
157
|
+
suggestedFix?: string;
|
|
158
|
+
|
|
159
|
+
/** Additional context or documentation link */
|
|
160
|
+
helpUrl?: string;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* SEO metrics for content evaluation
|
|
165
|
+
*/
|
|
166
|
+
export interface SEOMetrics {
|
|
167
|
+
/** Total word count */
|
|
168
|
+
wordCount: number;
|
|
169
|
+
|
|
170
|
+
/** Average words per sentence */
|
|
171
|
+
avgWordsPerSentence: number;
|
|
172
|
+
|
|
173
|
+
/** Average syllables per word */
|
|
174
|
+
avgSyllablesPerWord: number;
|
|
175
|
+
|
|
176
|
+
/** Flesch Reading Ease score (0-100) */
|
|
177
|
+
fleschReadingEase: number;
|
|
178
|
+
|
|
179
|
+
/** Flesch-Kincaid Grade Level */
|
|
180
|
+
fleschKincaidGrade: number;
|
|
181
|
+
|
|
182
|
+
/** Keyword density percentage */
|
|
183
|
+
keywordDensity: number;
|
|
184
|
+
|
|
185
|
+
/** Number of headings (H1-H6) */
|
|
186
|
+
headingCount: number;
|
|
187
|
+
|
|
188
|
+
/** Number of internal links */
|
|
189
|
+
internalLinkCount: number;
|
|
190
|
+
|
|
191
|
+
/** Number of external links */
|
|
192
|
+
externalLinkCount: number;
|
|
193
|
+
|
|
194
|
+
/** Number of images */
|
|
195
|
+
imageCount: number;
|
|
196
|
+
|
|
197
|
+
/** Number of images with alt text */
|
|
198
|
+
imagesWithAltText: number;
|
|
199
|
+
|
|
200
|
+
/** Estimated reading time in minutes */
|
|
201
|
+
readingTime: number;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* Comprehensive SEO analysis result
|
|
206
|
+
*/
|
|
207
|
+
export interface SEOAnalysisResult {
|
|
208
|
+
/** Overall SEO score (0-100) */
|
|
209
|
+
score: number;
|
|
210
|
+
|
|
211
|
+
/** Pass/fail status */
|
|
212
|
+
status: "poor" | "needs-improvement" | "good" | "excellent";
|
|
213
|
+
|
|
214
|
+
/** Detailed metrics */
|
|
215
|
+
metrics: SEOMetrics;
|
|
216
|
+
|
|
217
|
+
/** List of recommendations */
|
|
218
|
+
recommendations: SEORecommendation[];
|
|
219
|
+
|
|
220
|
+
/** Keyword analysis if applicable */
|
|
221
|
+
keywordAnalysis?: {
|
|
222
|
+
primaryKeyword: string;
|
|
223
|
+
keywordFound: boolean;
|
|
224
|
+
occurrences: number;
|
|
225
|
+
density: number;
|
|
226
|
+
semanticKeywords: string[];
|
|
227
|
+
competitorGap?: string[];
|
|
228
|
+
};
|
|
229
|
+
|
|
230
|
+
/** Content structure analysis */
|
|
231
|
+
structure?: {
|
|
232
|
+
hasH1: boolean;
|
|
233
|
+
h1Text: string;
|
|
234
|
+
headingHierarchy: boolean;
|
|
235
|
+
paragraphCount: number;
|
|
236
|
+
avgParagraphLength: number;
|
|
237
|
+
};
|
|
238
|
+
|
|
239
|
+
/** Timestamp of analysis */
|
|
240
|
+
analyzedAt: string;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* SEO metadata for posts and pages
|
|
245
|
+
*/
|
|
246
|
+
export interface SEOMetadata {
|
|
247
|
+
/** SEO title tag (max 60 chars) */
|
|
248
|
+
title: string;
|
|
249
|
+
|
|
250
|
+
/** Meta description (155-160 chars) */
|
|
251
|
+
description: string;
|
|
252
|
+
|
|
253
|
+
/** Focus keyword/keyphrase */
|
|
254
|
+
focusKeyword?: string;
|
|
255
|
+
|
|
256
|
+
/** Canonical URL */
|
|
257
|
+
canonical?: string;
|
|
258
|
+
|
|
259
|
+
/** Robots meta directives */
|
|
260
|
+
robots?: {
|
|
261
|
+
index: boolean;
|
|
262
|
+
follow: boolean;
|
|
263
|
+
archive?: boolean;
|
|
264
|
+
snippet?: boolean;
|
|
265
|
+
imageindex?: boolean;
|
|
266
|
+
};
|
|
267
|
+
|
|
268
|
+
/** OpenGraph metadata */
|
|
269
|
+
openGraph?: {
|
|
270
|
+
title: string;
|
|
271
|
+
description: string;
|
|
272
|
+
type: string;
|
|
273
|
+
image?: string;
|
|
274
|
+
url?: string;
|
|
275
|
+
siteName?: string;
|
|
276
|
+
locale?: string;
|
|
277
|
+
};
|
|
278
|
+
|
|
279
|
+
/** Twitter Card metadata */
|
|
280
|
+
twitterCard?: {
|
|
281
|
+
card: "summary" | "summary_large_image" | "app" | "player";
|
|
282
|
+
title?: string;
|
|
283
|
+
description?: string;
|
|
284
|
+
image?: string;
|
|
285
|
+
site?: string;
|
|
286
|
+
creator?: string;
|
|
287
|
+
};
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* Schema.org structured data markup
|
|
292
|
+
*/
|
|
293
|
+
export interface SchemaMarkup {
|
|
294
|
+
/** JSON-LD context */
|
|
295
|
+
"@context": "https://schema.org";
|
|
296
|
+
|
|
297
|
+
/** Schema type */
|
|
298
|
+
"@type": SchemaType | SchemaType[];
|
|
299
|
+
|
|
300
|
+
/** Schema properties (varies by type) */
|
|
301
|
+
[key: string]: unknown;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
/**
|
|
305
|
+
* Result of bulk SEO operations
|
|
306
|
+
*/
|
|
307
|
+
export interface BulkOperationResult {
|
|
308
|
+
/** Total number of items processed */
|
|
309
|
+
total: number;
|
|
310
|
+
|
|
311
|
+
/** Number of successful operations */
|
|
312
|
+
success: number;
|
|
313
|
+
|
|
314
|
+
/** Number of failed operations */
|
|
315
|
+
failed: number;
|
|
316
|
+
|
|
317
|
+
/** Number of skipped items */
|
|
318
|
+
skipped: number;
|
|
319
|
+
|
|
320
|
+
/** Details of failed operations */
|
|
321
|
+
errors?: Array<{
|
|
322
|
+
postId: number;
|
|
323
|
+
error: string;
|
|
324
|
+
}>;
|
|
325
|
+
|
|
326
|
+
/** Processing time in milliseconds */
|
|
327
|
+
processingTime: number;
|
|
328
|
+
|
|
329
|
+
/** Whether operation was dry run */
|
|
330
|
+
dryRun: boolean;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
/**
|
|
334
|
+
* Internal linking suggestion
|
|
335
|
+
*/
|
|
336
|
+
export interface InternalLinkSuggestion {
|
|
337
|
+
/** Source post ID */
|
|
338
|
+
sourcePostId: number;
|
|
339
|
+
|
|
340
|
+
/** Target post ID */
|
|
341
|
+
targetPostId: number;
|
|
342
|
+
|
|
343
|
+
/** Target post title */
|
|
344
|
+
targetTitle: string;
|
|
345
|
+
|
|
346
|
+
/** Target post URL */
|
|
347
|
+
targetUrl: string;
|
|
348
|
+
|
|
349
|
+
/** Suggested anchor text */
|
|
350
|
+
anchorText: string;
|
|
351
|
+
|
|
352
|
+
/** Relevance score (0-100) */
|
|
353
|
+
relevance: number;
|
|
354
|
+
|
|
355
|
+
/** Reason for suggestion */
|
|
356
|
+
reason: string;
|
|
357
|
+
|
|
358
|
+
/** Context around the suggested link location */
|
|
359
|
+
context?: string;
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
/**
|
|
363
|
+
* Site audit issue
|
|
364
|
+
*/
|
|
365
|
+
export interface AuditIssue {
|
|
366
|
+
/** Unique issue identifier */
|
|
367
|
+
id: string;
|
|
368
|
+
|
|
369
|
+
/** Issue category */
|
|
370
|
+
category: "technical" | "content" | "architecture" | "performance" | "accessibility" | "security";
|
|
371
|
+
|
|
372
|
+
/** Severity level */
|
|
373
|
+
severity: SEOPriority;
|
|
374
|
+
|
|
375
|
+
/** Issue title */
|
|
376
|
+
title: string;
|
|
377
|
+
|
|
378
|
+
/** Detailed description */
|
|
379
|
+
description: string;
|
|
380
|
+
|
|
381
|
+
/** Affected items/pages */
|
|
382
|
+
affectedItems: string[];
|
|
383
|
+
|
|
384
|
+
/** Impact description */
|
|
385
|
+
impact: string;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
/**
|
|
389
|
+
* Audit section result
|
|
390
|
+
*/
|
|
391
|
+
export interface AuditSection {
|
|
392
|
+
/** Section name */
|
|
393
|
+
name: string;
|
|
394
|
+
|
|
395
|
+
/** Section score (0-100) */
|
|
396
|
+
score: number;
|
|
397
|
+
|
|
398
|
+
/** Number of issues found */
|
|
399
|
+
issues: number;
|
|
400
|
+
|
|
401
|
+
/** Whether section passed all checks */
|
|
402
|
+
passed: boolean;
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
/**
|
|
406
|
+
* Audit configuration interface
|
|
407
|
+
*/
|
|
408
|
+
export interface AuditConfiguration {
|
|
409
|
+
/** Technical SEO audit enabled */
|
|
410
|
+
technical: boolean;
|
|
411
|
+
|
|
412
|
+
/** Content quality audit enabled */
|
|
413
|
+
content: boolean;
|
|
414
|
+
|
|
415
|
+
/** Site architecture audit enabled */
|
|
416
|
+
architecture: boolean;
|
|
417
|
+
|
|
418
|
+
/** Performance audit enabled */
|
|
419
|
+
performance: boolean;
|
|
420
|
+
|
|
421
|
+
/** Accessibility audit enabled */
|
|
422
|
+
accessibility: boolean;
|
|
423
|
+
|
|
424
|
+
/** Maximum pages to audit */
|
|
425
|
+
maxPages: number;
|
|
426
|
+
|
|
427
|
+
/** Minimum severity to include */
|
|
428
|
+
minSeverity: SEOPriority;
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
/**
|
|
432
|
+
* Comprehensive site audit result
|
|
433
|
+
*/
|
|
434
|
+
export interface SiteAuditResult {
|
|
435
|
+
/** Audit timestamp */
|
|
436
|
+
timestamp: string;
|
|
437
|
+
|
|
438
|
+
/** Site URL that was audited */
|
|
439
|
+
siteUrl: string;
|
|
440
|
+
|
|
441
|
+
/** Overall site health score (0-100) */
|
|
442
|
+
overallScore: number;
|
|
443
|
+
|
|
444
|
+
/** Audit sections with individual scores */
|
|
445
|
+
sections: AuditSection[];
|
|
446
|
+
|
|
447
|
+
/** List of identified issues */
|
|
448
|
+
issues: AuditIssue[];
|
|
449
|
+
|
|
450
|
+
/** Actionable recommendations */
|
|
451
|
+
recommendations: string[];
|
|
452
|
+
|
|
453
|
+
/** Audit summary text */
|
|
454
|
+
summary: string;
|
|
455
|
+
|
|
456
|
+
/** Processing time in milliseconds */
|
|
457
|
+
processingTime: number;
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
/**
|
|
461
|
+
* Zod schemas for validation
|
|
462
|
+
*/
|
|
463
|
+
|
|
464
|
+
export const SEOToolParamsSchema = z.object({
|
|
465
|
+
site: z.string().optional(),
|
|
466
|
+
postId: z.number().optional(),
|
|
467
|
+
postIds: z.array(z.number()).optional(),
|
|
468
|
+
analysisType: z.enum(["readability", "keywords", "structure", "full"]).optional(),
|
|
469
|
+
schemaType: z
|
|
470
|
+
.enum([
|
|
471
|
+
"Article",
|
|
472
|
+
"Product",
|
|
473
|
+
"FAQ",
|
|
474
|
+
"HowTo",
|
|
475
|
+
"Organization",
|
|
476
|
+
"Website",
|
|
477
|
+
"BreadcrumbList",
|
|
478
|
+
"Event",
|
|
479
|
+
"Recipe",
|
|
480
|
+
"Course",
|
|
481
|
+
"LocalBusiness",
|
|
482
|
+
"Person",
|
|
483
|
+
"Review",
|
|
484
|
+
"VideoObject",
|
|
485
|
+
])
|
|
486
|
+
.optional(),
|
|
487
|
+
focusKeywords: z.array(z.string()).optional(),
|
|
488
|
+
locale: z.string().optional(),
|
|
489
|
+
updates: z.record(z.string(), z.unknown()).optional(),
|
|
490
|
+
dryRun: z.boolean().optional(),
|
|
491
|
+
force: z.boolean().optional(),
|
|
492
|
+
auditType: z.enum(["technical", "content", "performance", "full"]).optional(),
|
|
493
|
+
schema: z.unknown().optional(),
|
|
494
|
+
});
|
|
495
|
+
|
|
496
|
+
export const SEORecommendationSchema = z.object({
|
|
497
|
+
type: z.enum(["title", "meta", "content", "structure", "keyword", "technical", "performance"]),
|
|
498
|
+
priority: z.enum(["low", "medium", "high", "critical"]),
|
|
499
|
+
message: z.string(),
|
|
500
|
+
impact: z.number().min(0).max(100),
|
|
501
|
+
autoFixAvailable: z.boolean(),
|
|
502
|
+
suggestedFix: z.string().optional(),
|
|
503
|
+
helpUrl: z.string().url().optional(),
|
|
504
|
+
});
|
|
505
|
+
|
|
506
|
+
export const SEOMetricsSchema = z.object({
|
|
507
|
+
wordCount: z.number(),
|
|
508
|
+
avgWordsPerSentence: z.number(),
|
|
509
|
+
avgSyllablesPerWord: z.number(),
|
|
510
|
+
fleschReadingEase: z.number(),
|
|
511
|
+
fleschKincaidGrade: z.number(),
|
|
512
|
+
keywordDensity: z.number(),
|
|
513
|
+
headingCount: z.number(),
|
|
514
|
+
internalLinkCount: z.number(),
|
|
515
|
+
externalLinkCount: z.number(),
|
|
516
|
+
imageCount: z.number(),
|
|
517
|
+
imagesWithAltText: z.number(),
|
|
518
|
+
readingTime: z.number(),
|
|
519
|
+
});
|
|
520
|
+
|
|
521
|
+
export const SEOAnalysisResultSchema = z.object({
|
|
522
|
+
score: z.number().min(0).max(100),
|
|
523
|
+
status: z.enum(["poor", "needs-improvement", "good", "excellent"]),
|
|
524
|
+
metrics: SEOMetricsSchema,
|
|
525
|
+
recommendations: z.array(SEORecommendationSchema),
|
|
526
|
+
keywordAnalysis: z
|
|
527
|
+
.object({
|
|
528
|
+
primaryKeyword: z.string(),
|
|
529
|
+
keywordFound: z.boolean(),
|
|
530
|
+
occurrences: z.number(),
|
|
531
|
+
density: z.number(),
|
|
532
|
+
semanticKeywords: z.array(z.string()),
|
|
533
|
+
competitorGap: z.array(z.string()).optional(),
|
|
534
|
+
})
|
|
535
|
+
.optional(),
|
|
536
|
+
structure: z
|
|
537
|
+
.object({
|
|
538
|
+
hasH1: z.boolean(),
|
|
539
|
+
h1Text: z.string(),
|
|
540
|
+
headingHierarchy: z.boolean(),
|
|
541
|
+
paragraphCount: z.number(),
|
|
542
|
+
avgParagraphLength: z.number(),
|
|
543
|
+
})
|
|
544
|
+
.optional(),
|
|
545
|
+
analyzedAt: z.string(),
|
|
546
|
+
});
|
|
@@ -93,7 +93,7 @@ export class ErrorHandlers {
|
|
|
93
93
|
"Go to your WordPress admin → Users → Profile → Application Passwords",
|
|
94
94
|
"Create a new application password with a descriptive name",
|
|
95
95
|
"Make sure the WordPress site URL ends with wp-json/wp/v2",
|
|
96
|
-
"Check if your site has
|
|
96
|
+
"Check if your site has unknown security plugins blocking REST API",
|
|
97
97
|
`Original error: ${errorMessage}`,
|
|
98
98
|
],
|
|
99
99
|
});
|
package/src/utils/error.ts
CHANGED
|
@@ -12,8 +12,7 @@ const logger = LoggerFactory.server().child({ component: "ErrorUtils" });
|
|
|
12
12
|
const LEGACY_ERROR_LOGS_ENABLED = config().error.legacyLogsEnabled;
|
|
13
13
|
|
|
14
14
|
// Internal helper to avoid sprinkling conditionals
|
|
15
|
-
|
|
16
|
-
function legacyConsoleError(...args: any[]) {
|
|
15
|
+
function legacyConsoleError(...args: unknown[]) {
|
|
17
16
|
if (LEGACY_ERROR_LOGS_ENABLED) {
|
|
18
17
|
console.error(...args);
|
|
19
18
|
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utils Barrel Export
|
|
3
|
+
* Centralized exports for all utility functions
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
// Debug utilities
|
|
7
|
+
export { debug, startTimer } from './debug.js';
|
|
8
|
+
|
|
9
|
+
// Error handling utilities
|
|
10
|
+
export * from './error.js';
|
|
11
|
+
export * from './enhancedError.js';
|
|
12
|
+
|
|
13
|
+
// Logging utilities
|
|
14
|
+
export { LoggerFactory } from './logger.js';
|
|
15
|
+
|
|
16
|
+
// Validation utilities
|
|
17
|
+
export * from './validation.js';
|
|
18
|
+
|
|
19
|
+
// Tool wrapper utilities
|
|
20
|
+
export * from './toolWrapper.js';
|
|
21
|
+
|
|
22
|
+
// Streaming utilities (if any exports exist)
|
|
23
|
+
export * from './streaming.js';
|
package/src/utils/logger.ts
CHANGED
|
@@ -257,13 +257,13 @@ export class Logger {
|
|
|
257
257
|
this.debug(`Completed: ${message}`, { duration: `${duration}ms` });
|
|
258
258
|
return result;
|
|
259
259
|
}
|
|
260
|
-
} catch (
|
|
260
|
+
} catch (_error) {
|
|
261
261
|
const duration = Date.now() - start;
|
|
262
262
|
this.error(`Failed: ${message}`, {
|
|
263
263
|
duration: `${duration}ms`,
|
|
264
|
-
|
|
264
|
+
_error: _error instanceof Error ? _error.message : String(_error),
|
|
265
265
|
});
|
|
266
|
-
throw
|
|
266
|
+
throw _error;
|
|
267
267
|
}
|
|
268
268
|
}
|
|
269
269
|
}
|
package/src/utils/toolWrapper.ts
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { getErrorMessage } from "./error.js";
|
|
7
|
-
import type { IWordPressClient } from
|
|
8
|
-
import type { BaseToolParams } from
|
|
7
|
+
import type { IWordPressClient } from "../types/client.js";
|
|
8
|
+
import type { BaseToolParams } from "../types/tools.js";
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Wrapper for tool methods that standardizes error handling
|
|
@@ -17,8 +17,8 @@ export function withErrorHandling<T extends readonly unknown[], R>(
|
|
|
17
17
|
return async (...args: T): Promise<R> => {
|
|
18
18
|
try {
|
|
19
19
|
return await fn(...args);
|
|
20
|
-
} catch (
|
|
21
|
-
throw new Error(`${operation}: ${getErrorMessage(
|
|
20
|
+
} catch (_error) {
|
|
21
|
+
throw new Error(`${operation}: ${getErrorMessage(_error)}`);
|
|
22
22
|
}
|
|
23
23
|
};
|
|
24
24
|
}
|
|
@@ -35,8 +35,8 @@ export function withValidation<T extends readonly unknown[], R>(
|
|
|
35
35
|
try {
|
|
36
36
|
validator(...args);
|
|
37
37
|
return await fn(...args);
|
|
38
|
-
} catch (
|
|
39
|
-
throw new Error(`${operation}: ${getErrorMessage(
|
|
38
|
+
} catch (_error) {
|
|
39
|
+
throw new Error(`${operation}: ${getErrorMessage(_error)}`);
|
|
40
40
|
}
|
|
41
41
|
};
|
|
42
42
|
}
|
|
@@ -82,8 +82,8 @@ export function errorHandler(operation: string) {
|
|
|
82
82
|
descriptor.value = async function (...args: unknown[]) {
|
|
83
83
|
try {
|
|
84
84
|
return await originalMethod.apply(this, args);
|
|
85
|
-
} catch (
|
|
86
|
-
throw new Error(`${operation}: ${getErrorMessage(
|
|
85
|
+
} catch (_error) {
|
|
86
|
+
throw new Error(`${operation}: ${getErrorMessage(_error)}`);
|
|
87
87
|
}
|
|
88
88
|
};
|
|
89
89
|
|
|
@@ -112,7 +112,7 @@ export function formatErrorResponse(operation: string, error: unknown): never {
|
|
|
112
112
|
export async function toolWrapper<T>(fn: () => Promise<T>): Promise<T> {
|
|
113
113
|
try {
|
|
114
114
|
return await fn();
|
|
115
|
-
} catch (
|
|
116
|
-
throw new Error(getErrorMessage(
|
|
115
|
+
} catch (_error) {
|
|
116
|
+
throw new Error(getErrorMessage(_error));
|
|
117
117
|
}
|
|
118
118
|
}
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
* These validators form the foundation for more specific validation logic.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import { WordPressAPIError } from "
|
|
9
|
-
import { WordPressId, createWordPressId } from "
|
|
8
|
+
import { WordPressAPIError } from "@/types/client.js";
|
|
9
|
+
import { WordPressId, createWordPressId } from "@/types/enhanced.js";
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* Validates and sanitizes numeric IDs with comprehensive edge case handling
|
|
@@ -32,5 +32,5 @@ export { validatePostStatus, validateSearchQuery, validatePaginationParams, vali
|
|
|
32
32
|
export { RateLimiter, authRateLimiter } from "./rateLimit.js";
|
|
33
33
|
|
|
34
34
|
// Re-export type dependencies for convenience
|
|
35
|
-
export type { WordPressId } from "
|
|
36
|
-
export { WordPressAPIError } from "
|
|
35
|
+
export type { WordPressId } from "@/types/enhanced.js";
|
|
36
|
+
export { WordPressAPIError } from "@/types/client.js";
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
* and username validation with security considerations.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import { WordPressAPIError } from "
|
|
9
|
-
import { config } from "
|
|
8
|
+
import { WordPressAPIError } from "@/types/client.js";
|
|
9
|
+
import { config } from "@/config/Config.js";
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* Validates and sanitizes URLs with enhanced edge case handling
|
|
@@ -69,9 +69,9 @@ export function validateUrl(url: string, fieldName: string = "url"): string {
|
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
return cleanUrl;
|
|
72
|
-
} catch (
|
|
73
|
-
if (
|
|
74
|
-
throw
|
|
72
|
+
} catch (_error) {
|
|
73
|
+
if (_error instanceof WordPressAPIError) {
|
|
74
|
+
throw _error;
|
|
75
75
|
}
|
|
76
76
|
throw new WordPressAPIError(`Invalid ${fieldName}: malformed URL "${cleanUrl}"`, 400, "INVALID_PARAMETER");
|
|
77
77
|
}
|