mcp-wordpress 2.11.13 → 3.0.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 +14 -29
- package/dist/cache/CacheInvalidation.js.map +1 -1
- package/dist/cache/CacheManager.d.ts +7 -0
- package/dist/cache/CacheManager.d.ts.map +1 -1
- package/dist/cache/CacheManager.js +21 -7
- package/dist/cache/CacheManager.js.map +1 -1
- package/dist/cache/HttpCacheWrapper.js.map +1 -1
- package/dist/cache/SEOCacheManager.d.ts.map +1 -1
- package/dist/cache/SEOCacheManager.js +6 -1
- package/dist/cache/SEOCacheManager.js.map +1 -1
- package/dist/cache/index.d.ts.map +1 -1
- package/dist/cache/index.js.map +1 -1
- package/dist/client/CachedWordPressClient.d.ts.map +1 -1
- package/dist/client/CachedWordPressClient.js.map +1 -1
- package/dist/client/MockWordPressClient.d.ts.map +1 -1
- package/dist/client/MockWordPressClient.js.map +1 -1
- package/dist/client/SEOWordPressClient.d.ts.map +1 -1
- package/dist/client/SEOWordPressClient.js.map +1 -1
- package/dist/client/api.d.ts +11 -26
- package/dist/client/api.d.ts.map +1 -1
- package/dist/client/api.js +111 -203
- package/dist/client/api.js.map +1 -1
- package/dist/client/auth.d.ts.map +1 -1
- package/dist/client/auth.js.map +1 -1
- package/dist/client/managers/AuthManager.d.ts.map +1 -1
- package/dist/client/managers/RequestManager.d.ts.map +1 -1
- package/dist/client/managers/RequestManager.js +6 -5
- package/dist/client/managers/RequestManager.js.map +1 -1
- package/dist/client/managers/composed/MigrationAdapter.d.ts +3 -3
- package/dist/client/managers/composed/MigrationAdapter.d.ts.map +1 -1
- package/dist/client/managers/composed/MigrationAdapter.js +2 -2
- package/dist/client/managers/composed/MigrationAdapter.js.map +1 -1
- package/dist/client/managers/composed/index.d.ts +7 -7
- package/dist/client/managers/composed/index.d.ts.map +1 -1
- package/dist/client/managers/composed/index.js +6 -6
- package/dist/client/managers/composed/index.js.map +1 -1
- package/dist/client/managers/implementations/ConfigurationProviderImpl.d.ts +1 -1
- package/dist/client/managers/implementations/ConfigurationProviderImpl.d.ts.map +1 -1
- package/dist/client/managers/implementations/ErrorHandlerImpl.d.ts +1 -1
- package/dist/client/managers/implementations/ErrorHandlerImpl.d.ts.map +1 -1
- package/dist/client/managers/implementations/ParameterValidatorImpl.d.ts +1 -1
- package/dist/client/managers/implementations/ParameterValidatorImpl.d.ts.map +1 -1
- package/dist/client/operations/comments.d.ts +58 -0
- package/dist/client/operations/comments.d.ts.map +1 -0
- package/dist/client/operations/comments.js +74 -0
- package/dist/client/operations/comments.js.map +1 -0
- package/dist/client/operations/index.d.ts +12 -0
- package/dist/client/operations/index.d.ts.map +1 -0
- package/dist/client/operations/index.js +12 -0
- package/dist/client/operations/index.js.map +1 -0
- package/dist/client/operations/media.d.ts +55 -0
- package/dist/client/operations/media.d.ts.map +1 -0
- package/dist/client/operations/media.js +132 -0
- package/dist/client/operations/media.js.map +1 -0
- package/dist/client/operations/pages.d.ts +50 -0
- package/dist/client/operations/pages.d.ts.map +1 -0
- package/dist/client/operations/pages.js +56 -0
- package/dist/client/operations/pages.js.map +1 -0
- package/dist/client/operations/posts.d.ts +50 -0
- package/dist/client/operations/posts.d.ts.map +1 -0
- package/dist/client/operations/posts.js +53 -0
- package/dist/client/operations/posts.js.map +1 -0
- package/dist/client/operations/site.d.ts +60 -0
- package/dist/client/operations/site.d.ts.map +1 -0
- package/dist/client/operations/site.js +83 -0
- package/dist/client/operations/site.js.map +1 -0
- package/dist/client/operations/taxonomies.d.ts +69 -0
- package/dist/client/operations/taxonomies.d.ts.map +1 -0
- package/dist/client/operations/taxonomies.js +87 -0
- package/dist/client/operations/taxonomies.js.map +1 -0
- package/dist/client/operations/users.d.ts +50 -0
- package/dist/client/operations/users.d.ts.map +1 -0
- package/dist/client/operations/users.js +57 -0
- package/dist/client/operations/users.js.map +1 -0
- package/dist/config/ServerConfiguration.d.ts.map +1 -1
- package/dist/config/ServerConfiguration.js.map +1 -1
- package/dist/docs/DocumentationGenerator.js.map +1 -1
- package/dist/performance/MetricsCollector.d.ts.map +1 -1
- package/dist/performance/MetricsCollector.js.map +1 -1
- package/dist/performance/PerformanceMonitor.js.map +1 -1
- package/dist/security/AISecurityScanner.d.ts.map +1 -1
- package/dist/security/AISecurityScanner.js +3 -2
- package/dist/security/AISecurityScanner.js.map +1 -1
- package/dist/security/AutomatedRemediation.js.map +1 -1
- package/dist/security/InputValidator.d.ts.map +1 -1
- package/dist/security/InputValidator.js +30 -18
- package/dist/security/InputValidator.js.map +1 -1
- package/dist/security/SecurityCIPipeline.d.ts +19 -196
- package/dist/security/SecurityCIPipeline.d.ts.map +1 -1
- package/dist/security/SecurityCIPipeline.js +95 -639
- package/dist/security/SecurityCIPipeline.js.map +1 -1
- package/dist/security/SecurityConfig.js.map +1 -1
- package/dist/security/SecurityConfigManager.js.map +1 -1
- package/dist/security/SecurityGateExecutor.d.ts +67 -0
- package/dist/security/SecurityGateExecutor.d.ts.map +1 -0
- package/dist/security/SecurityGateExecutor.js +363 -0
- package/dist/security/SecurityGateExecutor.js.map +1 -0
- package/dist/security/SecurityMonitoring.js.map +1 -1
- package/dist/security/SecurityReportGenerator.d.ts +65 -0
- package/dist/security/SecurityReportGenerator.d.ts.map +1 -0
- package/dist/security/SecurityReportGenerator.js +210 -0
- package/dist/security/SecurityReportGenerator.js.map +1 -0
- package/dist/security/SecurityReviewer.js.map +1 -1
- package/dist/security/SecurityTypes.d.ts +188 -0
- package/dist/security/SecurityTypes.d.ts.map +1 -0
- package/dist/security/SecurityTypes.js +6 -0
- package/dist/security/SecurityTypes.js.map +1 -0
- package/dist/security/index.d.ts +5 -28
- package/dist/security/index.d.ts.map +1 -1
- package/dist/security/index.js +4 -0
- package/dist/security/index.js.map +1 -1
- package/dist/server/ConnectionTester.d.ts.map +1 -1
- package/dist/server/ConnectionTester.js.map +1 -1
- package/dist/server/ToolRegistry.d.ts.map +1 -1
- package/dist/server/ToolRegistry.js.map +1 -1
- package/dist/tools/BaseToolManager.d.ts.map +1 -1
- package/dist/tools/BaseToolManager.js.map +1 -1
- package/dist/tools/auth.d.ts.map +1 -1
- package/dist/tools/auth.js.map +1 -1
- package/dist/tools/cache.d.ts.map +1 -1
- package/dist/tools/cache.js.map +1 -1
- package/dist/tools/comments.d.ts.map +1 -1
- package/dist/tools/comments.js.map +1 -1
- package/dist/tools/media.d.ts.map +1 -1
- package/dist/tools/media.js.map +1 -1
- package/dist/tools/pages.d.ts.map +1 -1
- package/dist/tools/pages.js.map +1 -1
- package/dist/tools/performance/PerformanceHelpers.d.ts +116 -0
- package/dist/tools/performance/PerformanceHelpers.d.ts.map +1 -0
- package/dist/tools/performance/PerformanceHelpers.js +298 -0
- package/dist/tools/performance/PerformanceHelpers.js.map +1 -0
- package/dist/tools/performance/PerformanceTools.d.ts +54 -0
- package/dist/tools/performance/PerformanceTools.d.ts.map +1 -0
- package/dist/tools/performance/PerformanceTools.js +687 -0
- package/dist/tools/performance/PerformanceTools.js.map +1 -0
- package/dist/tools/performance/index.d.ts +8 -0
- package/dist/tools/performance/index.d.ts.map +1 -0
- package/dist/tools/performance/index.js +8 -0
- package/dist/tools/performance/index.js.map +1 -0
- package/dist/tools/performance.d.ts +12 -69
- package/dist/tools/performance.d.ts.map +1 -1
- package/dist/tools/performance.js +12 -920
- package/dist/tools/performance.js.map +1 -1
- package/dist/tools/posts.d.ts.map +1 -1
- package/dist/tools/seo/analyzers/ContentAnalyzer.d.ts.map +1 -1
- package/dist/tools/seo/analyzers/ContentAnalyzer.js +14 -3
- package/dist/tools/seo/analyzers/ContentAnalyzer.js.map +1 -1
- package/dist/tools/seo/auditors/SiteAuditor.d.ts.map +1 -1
- package/dist/tools/seo/auditors/SiteAuditor.js +12 -3
- package/dist/tools/seo/auditors/SiteAuditor.js.map +1 -1
- package/dist/tools/seo/generators/MetaGenerator.d.ts.map +1 -1
- package/dist/tools/seo/generators/MetaGenerator.js +25 -8
- package/dist/tools/seo/generators/MetaGenerator.js.map +1 -1
- package/dist/tools/seo/generators/SchemaGenerator.d.ts.map +1 -1
- package/dist/tools/seo/generators/SchemaGenerator.js.map +1 -1
- package/dist/tools/seo/optimizers/InternalLinkingSuggester.d.ts.map +1 -1
- package/dist/tools/seo/optimizers/InternalLinkingSuggester.js.map +1 -1
- package/dist/tools/site.d.ts.map +1 -1
- package/dist/tools/site.js.map +1 -1
- package/dist/tools/taxonomies.d.ts.map +1 -1
- package/dist/tools/taxonomies.js.map +1 -1
- package/dist/tools/users.d.ts.map +1 -1
- package/dist/tools/users.js.map +1 -1
- package/dist/utils/CircuitBreaker.d.ts +243 -0
- package/dist/utils/CircuitBreaker.d.ts.map +1 -0
- package/dist/utils/CircuitBreaker.js +456 -0
- package/dist/utils/CircuitBreaker.js.map +1 -0
- package/dist/utils/debug.d.ts.map +1 -1
- package/dist/utils/debug.js.map +1 -1
- package/dist/utils/error.js.map +1 -1
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +2 -0
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/logger.js.map +1 -1
- package/dist/utils/toolWrapper.d.ts.map +1 -1
- package/docs/DEPRECATIONS.md +157 -0
- package/package.json +2 -3
- package/src/cache/CacheInvalidation.ts +1 -1
- package/src/cache/CacheManager.ts +25 -8
- package/src/cache/HttpCacheWrapper.ts +1 -1
- package/src/cache/SEOCacheManager.ts +9 -3
- package/src/cache/index.ts +1 -1
- package/src/client/CachedWordPressClient.ts +6 -6
- package/src/client/MockWordPressClient.ts +3 -3
- package/src/client/SEOWordPressClient.ts +6 -6
- package/src/client/api.ts +129 -215
- package/src/client/auth.ts +3 -3
- package/src/client/managers/AuthManager.ts +1 -1
- package/src/client/managers/RequestManager.ts +6 -7
- package/src/client/managers/composed/MigrationAdapter.ts +4 -4
- package/src/client/managers/composed/index.ts +7 -7
- package/src/client/managers/implementations/ConfigurationProviderImpl.ts +1 -1
- package/src/client/managers/implementations/ErrorHandlerImpl.ts +1 -1
- package/src/client/managers/implementations/ParameterValidatorImpl.ts +1 -1
- package/src/client/operations/comments.ts +96 -0
- package/src/client/operations/index.ts +12 -0
- package/src/client/operations/media.ts +162 -0
- package/src/client/operations/pages.ts +71 -0
- package/src/client/operations/posts.ts +68 -0
- package/src/client/operations/site.ts +106 -0
- package/src/client/operations/taxonomies.ts +115 -0
- package/src/client/operations/users.ts +72 -0
- package/src/config/ServerConfiguration.ts +6 -6
- package/src/docs/DocumentationGenerator.ts +3 -3
- package/src/performance/MetricsCollector.ts +4 -4
- package/src/performance/PerformanceMonitor.ts +1 -1
- package/src/security/AISecurityScanner.ts +4 -3
- package/src/security/AutomatedRemediation.ts +1 -1
- package/src/security/InputValidator.ts +36 -19
- package/src/security/SecurityCIPipeline.ts +130 -953
- package/src/security/SecurityConfig.ts +1 -1
- package/src/security/SecurityConfigManager.ts +1 -1
- package/src/security/SecurityGateExecutor.ts +485 -0
- package/src/security/SecurityMonitoring.ts +1 -1
- package/src/security/SecurityReportGenerator.ts +272 -0
- package/src/security/SecurityReviewer.ts +1 -1
- package/src/security/SecurityTypes.ts +199 -0
- package/src/security/index.ts +6 -1
- package/src/server/ConnectionTester.ts +4 -4
- package/src/server/ToolRegistry.ts +6 -6
- package/src/tools/BaseToolManager.ts +2 -2
- package/src/tools/auth.ts +3 -3
- package/src/tools/cache.ts +3 -3
- package/src/tools/comments.ts +3 -3
- package/src/tools/media.ts +3 -3
- package/src/tools/pages.ts +3 -3
- package/src/tools/performance/PerformanceHelpers.ts +330 -0
- package/src/tools/performance/PerformanceTools.ts +854 -0
- package/src/tools/performance/index.ts +8 -0
- package/src/tools/performance.ts +12 -1073
- package/src/tools/posts.ts +1 -1
- package/src/tools/seo/analyzers/ContentAnalyzer.ts +21 -7
- package/src/tools/seo/auditors/SiteAuditor.ts +18 -7
- package/src/tools/seo/generators/MetaGenerator.ts +33 -12
- package/src/tools/seo/generators/SchemaGenerator.ts +3 -3
- package/src/tools/seo/optimizers/InternalLinkingSuggester.ts +4 -4
- package/src/tools/site.ts +3 -3
- package/src/tools/taxonomies.ts +3 -3
- package/src/tools/users.ts +4 -4
- package/src/utils/CircuitBreaker.ts +572 -0
- package/src/utils/debug.ts +3 -3
- package/src/utils/error.ts +1 -1
- package/src/utils/index.ts +3 -0
- package/src/utils/logger.ts +1 -1
- package/src/utils/toolWrapper.ts +2 -2
- package/docs/BRANCH_PROTECTION.md +0 -0
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
# Deprecation Guide
|
|
2
|
+
|
|
3
|
+
This document tracks deprecated APIs and provides migration guidance for the MCP WordPress project.
|
|
4
|
+
|
|
5
|
+
## Deprecation Policy
|
|
6
|
+
|
|
7
|
+
- **Deprecation Notice**: APIs are marked with `@deprecated` JSDoc tag
|
|
8
|
+
- **Warning Period**: Deprecated APIs remain functional for at least 2 minor versions
|
|
9
|
+
- **Removal Timeline**: Removal is announced in CHANGELOG.md before the breaking release
|
|
10
|
+
|
|
11
|
+
## Currently Deprecated APIs
|
|
12
|
+
|
|
13
|
+
### 1. Legacy Import Modules
|
|
14
|
+
|
|
15
|
+
#### `src/tools/posts.ts` (Re-export Module)
|
|
16
|
+
|
|
17
|
+
**Status**: Deprecated since v2.10.0 | **Removal**: v3.0.0
|
|
18
|
+
|
|
19
|
+
**Reason**: Refactored to modular structure for better maintainability.
|
|
20
|
+
|
|
21
|
+
**Migration**:
|
|
22
|
+
|
|
23
|
+
```typescript
|
|
24
|
+
// Before (deprecated)
|
|
25
|
+
import PostTools from "./tools/posts.js";
|
|
26
|
+
import { handleCreatePost } from "./tools/posts.js";
|
|
27
|
+
|
|
28
|
+
// After (recommended)
|
|
29
|
+
import { PostTools } from "./tools/posts/index.js";
|
|
30
|
+
import { handleCreatePost } from "./tools/posts/PostHandlers.js";
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
**Note**: The legacy import still works and will continue to work until v3.0.0.
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
#### `src/utils/validation.ts` (Re-export Module)
|
|
38
|
+
|
|
39
|
+
**Status**: Deprecated since v2.8.0 | **Removal**: v3.0.0
|
|
40
|
+
|
|
41
|
+
**Reason**: Refactored to modular structure with focused validation modules.
|
|
42
|
+
|
|
43
|
+
**Migration**:
|
|
44
|
+
|
|
45
|
+
```typescript
|
|
46
|
+
// Before (deprecated)
|
|
47
|
+
import { validateId, sanitizeHtml, RateLimiter } from "./utils/validation.js";
|
|
48
|
+
|
|
49
|
+
// After (recommended) - Import from specific modules
|
|
50
|
+
import { validateId } from "./utils/validation/core.js";
|
|
51
|
+
import { sanitizeHtml } from "./utils/validation/security.js";
|
|
52
|
+
import { RateLimiter } from "./utils/validation/rate-limiter.js";
|
|
53
|
+
|
|
54
|
+
// Or use the new index (also acceptable)
|
|
55
|
+
import { validateId, sanitizeHtml, RateLimiter } from "./utils/validation/index.js";
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
**Available Modules**:
|
|
59
|
+
|
|
60
|
+
| Module | Exports |
|
|
61
|
+
| ---------------------------- | ----------------------------------------------------------------------------- |
|
|
62
|
+
| `validation/core.js` | `validateId`, `validateString`, `validateArray` |
|
|
63
|
+
| `validation/security.js` | `validateFilePath`, `validateFileSize`, `validateMimeType`, `sanitizeHtml` |
|
|
64
|
+
| `validation/network.js` | `validateUrl`, `validateEmail`, `validateUsername` |
|
|
65
|
+
| `validation/wordpress.js` | `validatePostStatus`, `validateSearchQuery`, `validatePaginationParams`, etc. |
|
|
66
|
+
| `validation/rate-limiter.js` | `RateLimiter`, `authRateLimiter` |
|
|
67
|
+
|
|
68
|
+
---
|
|
69
|
+
|
|
70
|
+
#### `src/tools/performance.ts` (Re-export Module)
|
|
71
|
+
|
|
72
|
+
**Status**: Deprecated since v2.12.0 | **Removal**: v3.0.0
|
|
73
|
+
|
|
74
|
+
**Reason**: Refactored to modular structure for better maintainability.
|
|
75
|
+
|
|
76
|
+
**Migration**:
|
|
77
|
+
|
|
78
|
+
```typescript
|
|
79
|
+
// Before (deprecated)
|
|
80
|
+
import PerformanceTools from "./tools/performance.js";
|
|
81
|
+
|
|
82
|
+
// After (recommended)
|
|
83
|
+
import { PerformanceTools } from "./tools/performance/index.js";
|
|
84
|
+
import { calculateHealthStatus, formatUptime } from "./tools/performance/PerformanceHelpers.js";
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
### 2. Internal Method Deprecations
|
|
90
|
+
|
|
91
|
+
#### `VersionManager.loadVersionSync()` (Private Method)
|
|
92
|
+
|
|
93
|
+
**Status**: Deprecated since v2.5.0 | **Removal**: v3.0.0
|
|
94
|
+
|
|
95
|
+
**Reason**: Async initialization provides better performance.
|
|
96
|
+
|
|
97
|
+
**Migration**:
|
|
98
|
+
|
|
99
|
+
```typescript
|
|
100
|
+
// Before (deprecated pattern)
|
|
101
|
+
const version = VersionManager.getInstance().getVersion(); // May load sync
|
|
102
|
+
|
|
103
|
+
// After (recommended)
|
|
104
|
+
const manager = VersionManager.getInstance();
|
|
105
|
+
await manager.initialize(); // Async load
|
|
106
|
+
const version = manager.getVersion(); // Uses cached value
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
---
|
|
110
|
+
|
|
111
|
+
## Upcoming Deprecations (v2.13.0)
|
|
112
|
+
|
|
113
|
+
The following items are candidates for deprecation in future releases:
|
|
114
|
+
|
|
115
|
+
### Legacy Alias Exports
|
|
116
|
+
|
|
117
|
+
Located in `src/utils/validation.ts`:
|
|
118
|
+
|
|
119
|
+
- `validateWordPressId` → Use `validateId` from `validation/core.js`
|
|
120
|
+
- `validatePostData` → Use `validatePostParams` from `validation/wordpress.js`
|
|
121
|
+
- `cleanHtml` → Use `sanitizeHtml` from `validation/security.js`
|
|
122
|
+
|
|
123
|
+
---
|
|
124
|
+
|
|
125
|
+
## Removed APIs
|
|
126
|
+
|
|
127
|
+
### v2.0.0 (Breaking Release)
|
|
128
|
+
|
|
129
|
+
| Removed | Replacement |
|
|
130
|
+
| ---------------------------- | ------------------------------ |
|
|
131
|
+
| `WordPressClient.connect()` | `WordPressClient.initialize()` |
|
|
132
|
+
| `config.getEnv()` | `config().app` |
|
|
133
|
+
|
|
134
|
+
---
|
|
135
|
+
|
|
136
|
+
## Migration Assistance
|
|
137
|
+
|
|
138
|
+
If you need help migrating from deprecated APIs:
|
|
139
|
+
|
|
140
|
+
1. Check this document for migration examples
|
|
141
|
+
2. Review the CHANGELOG.md for version-specific changes
|
|
142
|
+
3. Run `npm run lint` to catch deprecated import warnings
|
|
143
|
+
4. Open an issue on GitHub for migration questions
|
|
144
|
+
|
|
145
|
+
## Version Support Matrix
|
|
146
|
+
|
|
147
|
+
| Version | Status | Deprecations Active | End of Support |
|
|
148
|
+
| -------- | ------------- | ------------------- | ---------------- |
|
|
149
|
+
| v2.12.x | Current | Yes | - |
|
|
150
|
+
| v2.11.x | Maintained | Yes | v2.14.0 release |
|
|
151
|
+
| v2.10.x | Security Only | Yes | v2.13.0 release |
|
|
152
|
+
| v2.9.x | End of Life | N/A | Ended |
|
|
153
|
+
| v3.0.0 | Planned | Removed | - |
|
|
154
|
+
|
|
155
|
+
---
|
|
156
|
+
|
|
157
|
+
*Last updated: December 2024*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mcp-wordpress",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "Comprehensive Model Context Protocol server for WordPress management with composition-based architecture, 59 tools, SEO toolkit, performance monitoring, intelligent caching, and production-ready authentication",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"mcp",
|
|
@@ -155,8 +155,7 @@
|
|
|
155
155
|
"fs-extra": "^11.3.1",
|
|
156
156
|
"husky": "^9.1.7",
|
|
157
157
|
"lint-staged": "^16.1.5",
|
|
158
|
-
"markdownlint-cli": "^0.
|
|
159
|
-
"mcp-evals": "^2.0.1",
|
|
158
|
+
"markdownlint-cli": "^0.47.0",
|
|
160
159
|
"nock": "^14.0.10",
|
|
161
160
|
"node-fetch": "^3.3.2",
|
|
162
161
|
"open": "^10.2.0",
|
|
@@ -3,8 +3,7 @@
|
|
|
3
3
|
* Implements multi-layer caching with TTL, LRU eviction, and site-specific keys
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import
|
|
7
|
-
import { ConfigHelpers } from "../config/Config.js";
|
|
6
|
+
import { ConfigHelpers } from "@/config/Config.js";
|
|
8
7
|
|
|
9
8
|
export interface CacheEntry<T = unknown> {
|
|
10
9
|
value: T;
|
|
@@ -56,6 +55,7 @@ export class CacheManager {
|
|
|
56
55
|
|
|
57
56
|
/**
|
|
58
57
|
* Generate cache key with site prefix and parameter hash
|
|
58
|
+
* Uses fast non-cryptographic hash (FNV-1a) for 3-5x better performance
|
|
59
59
|
*/
|
|
60
60
|
generateKey(siteId: string, endpoint: string, params?: Record<string, unknown>): string {
|
|
61
61
|
const baseKey = `${siteId}:${endpoint}`;
|
|
@@ -64,16 +64,33 @@ export class CacheManager {
|
|
|
64
64
|
return baseKey;
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
//
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
.digest("hex")
|
|
72
|
-
.substring(0, 8);
|
|
67
|
+
// Use fast non-cryptographic hash (FNV-1a) for cache keys
|
|
68
|
+
// Normalized params ensure consistent ordering
|
|
69
|
+
const paramString = JSON.stringify(this.normalizeParams(params));
|
|
70
|
+
const paramHash = this.fastHash(paramString);
|
|
73
71
|
|
|
74
72
|
return `${baseKey}:${paramHash}`;
|
|
75
73
|
}
|
|
76
74
|
|
|
75
|
+
/**
|
|
76
|
+
* Fast non-cryptographic hash function (FNV-1a variant)
|
|
77
|
+
* 3-5x faster than MD5 for cache key generation
|
|
78
|
+
* Returns base36 string for compact keys with low collision risk
|
|
79
|
+
*/
|
|
80
|
+
private fastHash(str: string): string {
|
|
81
|
+
let hash = 2166136261; // FNV offset basis (32-bit)
|
|
82
|
+
|
|
83
|
+
for (let i = 0; i < str.length; i++) {
|
|
84
|
+
hash ^= str.charCodeAt(i);
|
|
85
|
+
// FNV prime: 16777619
|
|
86
|
+
hash = Math.imul(hash, 16777619);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// Convert to unsigned 32-bit integer and encode as base36
|
|
90
|
+
// Base36 (0-9, a-z) gives ~6 characters for 32-bit hash (more compact than hex)
|
|
91
|
+
return (hash >>> 0).toString(36);
|
|
92
|
+
}
|
|
93
|
+
|
|
77
94
|
/**
|
|
78
95
|
* Get value from cache if not expired
|
|
79
96
|
*/
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
import { CacheManager, CachePresets } from "./CacheManager.js";
|
|
7
7
|
import * as crypto from "crypto";
|
|
8
|
-
import { LoggerFactory } from "
|
|
8
|
+
import { LoggerFactory } from "@/utils/logger.js";
|
|
9
9
|
|
|
10
10
|
export interface HttpCacheOptions {
|
|
11
11
|
ttl?: number;
|
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
import { CacheManager, type CacheConfig } from "./CacheManager.js";
|
|
12
|
-
import { Config } from "
|
|
13
|
-
import { LoggerFactory } from "
|
|
12
|
+
import { Config } from "@/config/Config.js";
|
|
13
|
+
import { LoggerFactory } from "@/utils/logger.js";
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* SEO-specific cache manager
|
|
@@ -242,7 +242,13 @@ export class SEOCacheManager extends CacheManager {
|
|
|
242
242
|
private async invalidatePattern(pattern: string): Promise<void> {
|
|
243
243
|
// Get all cache keys and filter by pattern
|
|
244
244
|
const allKeys = await this.getAllKeys();
|
|
245
|
-
|
|
245
|
+
|
|
246
|
+
// Escape regex special characters first, then convert glob * to regex .*
|
|
247
|
+
// This prevents regex injection and handles patterns correctly
|
|
248
|
+
const escapedPattern = pattern
|
|
249
|
+
.replace(/[.+?^${}()|[\]\\]/g, "\\$&") // Escape regex special chars except *
|
|
250
|
+
.replace(/\*/g, ".*"); // Convert glob wildcards to regex
|
|
251
|
+
const regex = new RegExp("^" + escapedPattern + "$");
|
|
246
252
|
|
|
247
253
|
const matchingKeys = allKeys.filter((key) => regex.test(key));
|
|
248
254
|
|
package/src/cache/index.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
export { CacheManager, CachePresets } from "./CacheManager.js";
|
|
7
7
|
export { HttpCacheWrapper } from "./HttpCacheWrapper.js";
|
|
8
8
|
export { CacheInvalidation, WordPressCachePatterns, CacheWarmer } from "./CacheInvalidation.js";
|
|
9
|
-
export { CachedWordPressClient } from "
|
|
9
|
+
export { CachedWordPressClient } from "@/client/CachedWordPressClient.js";
|
|
10
10
|
|
|
11
11
|
export type { CacheEntry, CacheStats, CacheConfig } from "./CacheManager.js";
|
|
12
12
|
|
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { WordPressClient } from "./api.js";
|
|
7
|
-
import { CacheManager, type CacheStats } from "
|
|
8
|
-
import { HttpCacheWrapper } from "
|
|
9
|
-
import { CacheInvalidation } from "
|
|
10
|
-
import { SecurityConfig } from "
|
|
11
|
-
import type { WordPressClientConfig, HTTPMethod, RequestOptions } from "
|
|
7
|
+
import { CacheManager, type CacheStats } from "@/cache/CacheManager.js";
|
|
8
|
+
import { HttpCacheWrapper } from "@/cache/HttpCacheWrapper.js";
|
|
9
|
+
import { CacheInvalidation } from "@/cache/CacheInvalidation.js";
|
|
10
|
+
import { SecurityConfig } from "@/security/SecurityConfig.js";
|
|
11
|
+
import type { WordPressClientConfig, HTTPMethod, RequestOptions } from "@/types/client.js";
|
|
12
12
|
import type {
|
|
13
13
|
WordPressPost,
|
|
14
14
|
WordPressUser,
|
|
@@ -18,7 +18,7 @@ import type {
|
|
|
18
18
|
PostQueryParams,
|
|
19
19
|
CreatePostRequest,
|
|
20
20
|
UpdatePostRequest,
|
|
21
|
-
} from "
|
|
21
|
+
} from "@/types/wordpress.js";
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
24
|
* WordPress client with intelligent caching
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { WordPressClient } from "./api.js";
|
|
2
|
-
import { WordPressClientConfig } from "
|
|
3
|
-
import { LoggerFactory } from "
|
|
2
|
+
import { WordPressClientConfig } from "@/types/client.js";
|
|
3
|
+
import { LoggerFactory } from "@/utils/logger.js";
|
|
4
4
|
import type {
|
|
5
5
|
WordPressPost,
|
|
6
6
|
WordPressUser,
|
|
@@ -8,7 +8,7 @@ import type {
|
|
|
8
8
|
PostQueryParams,
|
|
9
9
|
CreatePostRequest,
|
|
10
10
|
UpdatePostRequest,
|
|
11
|
-
} from "
|
|
11
|
+
} from "@/types/wordpress.js";
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* Mock WordPress client for CI environments
|
|
@@ -17,12 +17,12 @@
|
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
19
|
import { WordPressClient } from "./api.js";
|
|
20
|
-
import { LoggerFactory } from "
|
|
21
|
-
import { handleToolError } from "
|
|
22
|
-
import type { WordPressPost, WordPressPage } from "
|
|
23
|
-
import type { WordPressClientConfig } from "
|
|
24
|
-
import type { SchemaType } from "
|
|
25
|
-
import type { SEOMetadata, SchemaMarkup } from "
|
|
20
|
+
import { LoggerFactory } from "@/utils/logger.js";
|
|
21
|
+
import { handleToolError } from "@/utils/error.js";
|
|
22
|
+
import type { WordPressPost, WordPressPage } from "@/types/wordpress.js";
|
|
23
|
+
import type { WordPressClientConfig } from "@/types/client.js";
|
|
24
|
+
import type { SchemaType } from "@/types/seo.js";
|
|
25
|
+
import type { SEOMetadata, SchemaMarkup } from "@/types/seo.js";
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
28
|
* WordPress Plugin interface for API responses
|