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
|
@@ -61,7 +61,7 @@ describe("CachedWordPressClient", () => {
|
|
|
61
61
|
expect(customClient["siteId"]).toBe("custom-site");
|
|
62
62
|
});
|
|
63
63
|
|
|
64
|
-
test(
|
|
64
|
+
test('should default to "default" site ID', () => {
|
|
65
65
|
const defaultClient = new CachedWordPressClient(config);
|
|
66
66
|
expect(defaultClient["siteId"]).toBe("default");
|
|
67
67
|
});
|
|
@@ -70,7 +70,7 @@ describe("CachedWordPressClient", () => {
|
|
|
70
70
|
describe("GET Request Caching", () => {
|
|
71
71
|
test("should cache GET requests", async () => {
|
|
72
72
|
const mockResponse = [{ id: 1, title: "Test Post" }];
|
|
73
|
-
(client as
|
|
73
|
+
(client as unknown).request = jest
|
|
74
74
|
.fn()
|
|
75
75
|
.mockImplementationOnce(async () => mockResponse)
|
|
76
76
|
.mockImplementationOnce(async () => mockResponse);
|
|
@@ -84,19 +84,19 @@ describe("CachedWordPressClient", () => {
|
|
|
84
84
|
expect(result2).toEqual(mockResponse);
|
|
85
85
|
|
|
86
86
|
// Verify the underlying request was only called once due to caching
|
|
87
|
-
expect((client as
|
|
87
|
+
expect((client as unknown).request).toHaveBeenCalledTimes(1);
|
|
88
88
|
});
|
|
89
89
|
|
|
90
90
|
test("should cache individual post requests", async () => {
|
|
91
91
|
const mockPost = { id: 1, title: "Test Post" };
|
|
92
|
-
(client as
|
|
92
|
+
(client as unknown).request = jest.fn().mockResolvedValue(mockPost);
|
|
93
93
|
|
|
94
94
|
const result1 = await client.getPost(1);
|
|
95
95
|
const result2 = await client.getPost(1);
|
|
96
96
|
|
|
97
97
|
expect(result1).toEqual(mockPost);
|
|
98
98
|
expect(result2).toEqual(mockPost);
|
|
99
|
-
expect((client as
|
|
99
|
+
expect((client as unknown).request).toHaveBeenCalledTimes(1);
|
|
100
100
|
});
|
|
101
101
|
});
|
|
102
102
|
|
|
@@ -109,10 +109,7 @@ describe("CachedWordPressClient", () => {
|
|
|
109
109
|
const _originalCreatePost = client.createPost;
|
|
110
110
|
client.createPost = jest.fn().mockResolvedValue(mockPost);
|
|
111
111
|
|
|
112
|
-
const invalidateSpy = jest.spyOn(
|
|
113
|
-
client["cacheInvalidation"],
|
|
114
|
-
"invalidateResource",
|
|
115
|
-
);
|
|
112
|
+
const invalidateSpy = jest.spyOn(client["cacheInvalidation"], "invalidateResource");
|
|
116
113
|
|
|
117
114
|
await client.createPost(mockCreateData);
|
|
118
115
|
|
|
@@ -124,10 +121,7 @@ describe("CachedWordPressClient", () => {
|
|
|
124
121
|
const mockUpdateData = { id: 1, title: "Updated Post" };
|
|
125
122
|
|
|
126
123
|
client.updatePost = jest.fn().mockResolvedValue(mockPost);
|
|
127
|
-
const invalidateSpy = jest.spyOn(
|
|
128
|
-
client["cacheInvalidation"],
|
|
129
|
-
"invalidateResource",
|
|
130
|
-
);
|
|
124
|
+
const invalidateSpy = jest.spyOn(client["cacheInvalidation"], "invalidateResource");
|
|
131
125
|
|
|
132
126
|
await client.updatePost(mockUpdateData);
|
|
133
127
|
|
|
@@ -136,10 +130,7 @@ describe("CachedWordPressClient", () => {
|
|
|
136
130
|
|
|
137
131
|
test("should invalidate cache on post deletion", async () => {
|
|
138
132
|
client.deletePost = jest.fn().mockResolvedValue(undefined);
|
|
139
|
-
const invalidateSpy = jest.spyOn(
|
|
140
|
-
client["cacheInvalidation"],
|
|
141
|
-
"invalidateResource",
|
|
142
|
-
);
|
|
133
|
+
const invalidateSpy = jest.spyOn(client["cacheInvalidation"], "invalidateResource");
|
|
143
134
|
|
|
144
135
|
await client.deletePost(1);
|
|
145
136
|
|
|
@@ -150,35 +141,30 @@ describe("CachedWordPressClient", () => {
|
|
|
150
141
|
describe("Cache Configuration by Endpoint Type", () => {
|
|
151
142
|
test("should use static caching for site settings", async () => {
|
|
152
143
|
const mockSettings = { title: "Test Site" };
|
|
153
|
-
(client as
|
|
144
|
+
(client as unknown).request = jest.fn().mockResolvedValue(mockSettings);
|
|
154
145
|
|
|
155
146
|
await client.getSiteSettings();
|
|
156
147
|
|
|
157
148
|
// Verify request was made with static cache configuration
|
|
158
|
-
expect((client as
|
|
149
|
+
expect((client as unknown).request).toHaveBeenCalledWith("GET", "settings");
|
|
159
150
|
});
|
|
160
151
|
|
|
161
152
|
test("should use semi-static caching for categories", async () => {
|
|
162
153
|
const mockCategories = [{ id: 1, name: "Test Category" }];
|
|
163
|
-
(client as
|
|
154
|
+
(client as unknown).request = jest.fn().mockResolvedValue(mockCategories);
|
|
164
155
|
|
|
165
156
|
await client.getCategories();
|
|
166
157
|
|
|
167
|
-
expect((client as
|
|
168
|
-
"GET",
|
|
169
|
-
"categories",
|
|
170
|
-
null,
|
|
171
|
-
{ params: {} },
|
|
172
|
-
);
|
|
158
|
+
expect((client as unknown).request).toHaveBeenCalledWith("GET", "categories", null, { params: {} });
|
|
173
159
|
});
|
|
174
160
|
|
|
175
161
|
test("should use session caching for current user", async () => {
|
|
176
162
|
const mockUser = { id: 1, username: "testuser" };
|
|
177
|
-
(client as
|
|
163
|
+
(client as unknown).request = jest.fn().mockResolvedValue(mockUser);
|
|
178
164
|
|
|
179
165
|
await client.getCurrentUser();
|
|
180
166
|
|
|
181
|
-
expect((client as
|
|
167
|
+
expect((client as unknown).request).toHaveBeenCalledWith("GET", "users/me");
|
|
182
168
|
});
|
|
183
169
|
});
|
|
184
170
|
|
|
@@ -194,10 +180,7 @@ describe("CachedWordPressClient", () => {
|
|
|
194
180
|
|
|
195
181
|
test("should clear cache by pattern", () => {
|
|
196
182
|
const pattern = "posts.*";
|
|
197
|
-
const clearPatternSpy = jest.spyOn(
|
|
198
|
-
client["httpCache"],
|
|
199
|
-
"invalidatePattern",
|
|
200
|
-
);
|
|
183
|
+
const clearPatternSpy = jest.spyOn(client["httpCache"], "invalidatePattern");
|
|
201
184
|
|
|
202
185
|
const result = client.clearCachePattern(pattern);
|
|
203
186
|
|
|
@@ -232,9 +215,7 @@ describe("CachedWordPressClient", () => {
|
|
|
232
215
|
});
|
|
233
216
|
|
|
234
217
|
test("should handle cache warming errors gracefully", async () => {
|
|
235
|
-
client.getCurrentUser = jest
|
|
236
|
-
.fn()
|
|
237
|
-
.mockRejectedValue(new Error("Auth failed"));
|
|
218
|
+
client.getCurrentUser = jest.fn().mockRejectedValue(new Error("Auth failed"));
|
|
238
219
|
client.getCategories = jest.fn().mockResolvedValue([]);
|
|
239
220
|
client.getTags = jest.fn().mockResolvedValue([]);
|
|
240
221
|
client.getSiteSettings = jest.fn().mockResolvedValue({});
|
|
@@ -251,19 +232,19 @@ describe("CachedWordPressClient", () => {
|
|
|
251
232
|
describe("Cache Key Generation", () => {
|
|
252
233
|
test("should generate different cache keys for different parameters", async () => {
|
|
253
234
|
const mockPosts = [{ id: 1 }];
|
|
254
|
-
(client as
|
|
235
|
+
(client as unknown).request = jest.fn().mockResolvedValue(mockPosts);
|
|
255
236
|
|
|
256
237
|
// Make requests with different parameters
|
|
257
238
|
await client.getPosts({ per_page: 10 });
|
|
258
239
|
await client.getPosts({ per_page: 20 });
|
|
259
240
|
|
|
260
241
|
// Should make two separate requests due to different cache keys
|
|
261
|
-
expect((client as
|
|
242
|
+
expect((client as unknown).request).toHaveBeenCalledTimes(2);
|
|
262
243
|
});
|
|
263
244
|
|
|
264
245
|
test("should use same cache key for identical parameters", async () => {
|
|
265
246
|
const mockPosts = [{ id: 1 }];
|
|
266
|
-
(client as
|
|
247
|
+
(client as unknown).request = jest.fn().mockResolvedValue(mockPosts);
|
|
267
248
|
|
|
268
249
|
const params = { per_page: 10, status: ["publish"] as ["publish"] };
|
|
269
250
|
|
|
@@ -271,19 +252,15 @@ describe("CachedWordPressClient", () => {
|
|
|
271
252
|
await client.getPosts(params);
|
|
272
253
|
|
|
273
254
|
// Should only make one request due to caching
|
|
274
|
-
expect((client as
|
|
255
|
+
expect((client as unknown).request).toHaveBeenCalledTimes(1);
|
|
275
256
|
});
|
|
276
257
|
});
|
|
277
258
|
|
|
278
259
|
describe("Helper Methods", () => {
|
|
279
260
|
test("should extract resource from endpoint", () => {
|
|
280
|
-
const resource1 = (client as
|
|
281
|
-
const resource2 = (client as
|
|
282
|
-
|
|
283
|
-
);
|
|
284
|
-
const resource3 = (client as any).extractResourceFromEndpoint(
|
|
285
|
-
"categories",
|
|
286
|
-
);
|
|
261
|
+
const resource1 = (client as unknown).extractResourceFromEndpoint("posts");
|
|
262
|
+
const resource2 = (client as unknown).extractResourceFromEndpoint("posts/123");
|
|
263
|
+
const resource3 = (client as unknown).extractResourceFromEndpoint("categories");
|
|
287
264
|
|
|
288
265
|
expect(resource1).toBe("posts");
|
|
289
266
|
expect(resource2).toBe("posts");
|
|
@@ -291,9 +268,9 @@ describe("CachedWordPressClient", () => {
|
|
|
291
268
|
});
|
|
292
269
|
|
|
293
270
|
test("should extract ID from endpoint", () => {
|
|
294
|
-
const id1 = (client as
|
|
295
|
-
const id2 = (client as
|
|
296
|
-
const id3 = (client as
|
|
271
|
+
const id1 = (client as unknown).extractIdFromEndpoint("posts/123");
|
|
272
|
+
const id2 = (client as unknown).extractIdFromEndpoint("posts/123/revisions");
|
|
273
|
+
const id3 = (client as unknown).extractIdFromEndpoint("posts");
|
|
297
274
|
|
|
298
275
|
expect(id1).toBe(123);
|
|
299
276
|
expect(id2).toBe(123);
|
|
@@ -301,19 +278,17 @@ describe("CachedWordPressClient", () => {
|
|
|
301
278
|
});
|
|
302
279
|
|
|
303
280
|
test("should identify endpoint types correctly", () => {
|
|
304
|
-
expect((client as
|
|
305
|
-
expect((client as
|
|
306
|
-
expect((client as
|
|
307
|
-
|
|
308
|
-
expect((client as
|
|
309
|
-
expect((client as
|
|
310
|
-
expect((client as
|
|
311
|
-
|
|
312
|
-
expect((client as
|
|
313
|
-
expect((client as
|
|
314
|
-
|
|
315
|
-
);
|
|
316
|
-
expect((client as any).isSessionEndpoint("posts")).toBe(false);
|
|
281
|
+
expect((client as unknown).isStaticEndpoint("settings")).toBe(true);
|
|
282
|
+
expect((client as unknown).isStaticEndpoint("types")).toBe(true);
|
|
283
|
+
expect((client as unknown).isStaticEndpoint("posts")).toBe(false);
|
|
284
|
+
|
|
285
|
+
expect((client as unknown).isSemiStaticEndpoint("categories")).toBe(true);
|
|
286
|
+
expect((client as unknown).isSemiStaticEndpoint("tags")).toBe(true);
|
|
287
|
+
expect((client as unknown).isSemiStaticEndpoint("posts")).toBe(false);
|
|
288
|
+
|
|
289
|
+
expect((client as unknown).isSessionEndpoint("users/me")).toBe(true);
|
|
290
|
+
expect((client as unknown).isSessionEndpoint("application-passwords")).toBe(true);
|
|
291
|
+
expect((client as unknown).isSessionEndpoint("posts")).toBe(false);
|
|
317
292
|
});
|
|
318
293
|
});
|
|
319
294
|
});
|