mcp-wordpress 1.1.2 → 1.1.7
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 +8 -8
- package/bin/mcp-wordpress.js +1 -1
- package/dist/client/api.d.ts +10 -10
- package/dist/client/api.js +157 -157
- package/dist/client/api.js.map +1 -1
- package/dist/client/auth.d.ts +2 -2
- package/dist/client/auth.d.ts.map +1 -1
- package/dist/client/auth.js +72 -72
- package/dist/client/auth.js.map +1 -1
- package/dist/client/managers/AuthenticationManager.d.ts +2 -2
- package/dist/client/managers/AuthenticationManager.d.ts.map +1 -1
- package/dist/client/managers/AuthenticationManager.js +50 -46
- package/dist/client/managers/AuthenticationManager.js.map +1 -1
- package/dist/client/managers/BaseManager.d.ts +1 -1
- package/dist/client/managers/BaseManager.d.ts.map +1 -1
- package/dist/client/managers/BaseManager.js +9 -9
- package/dist/client/managers/BaseManager.js.map +1 -1
- package/dist/client/managers/RequestManager.d.ts +2 -2
- package/dist/client/managers/RequestManager.js +15 -15
- package/dist/client/managers/index.d.ts +3 -3
- package/dist/client/managers/index.js +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +78 -61
- package/dist/index.js.map +1 -1
- package/dist/tools/auth.d.ts +2 -2
- package/dist/tools/auth.js +31 -31
- package/dist/tools/auth.js.map +1 -1
- package/dist/tools/comments.d.ts +2 -2
- package/dist/tools/comments.js +79 -79
- package/dist/tools/media.d.ts +2 -2
- package/dist/tools/media.d.ts.map +1 -1
- package/dist/tools/media.js +80 -80
- package/dist/tools/media.js.map +1 -1
- package/dist/tools/pages.d.ts +2 -2
- package/dist/tools/pages.js +75 -75
- package/dist/tools/posts.d.ts +2 -2
- package/dist/tools/posts.js +94 -94
- package/dist/tools/site.d.ts +2 -2
- package/dist/tools/site.js +60 -60
- package/dist/tools/site.js.map +1 -1
- package/dist/tools/taxonomies.d.ts +2 -2
- package/dist/tools/taxonomies.js +89 -89
- package/dist/tools/users.d.ts +2 -2
- package/dist/tools/users.js +68 -68
- package/dist/tools/users.js.map +1 -1
- package/dist/types/mcp.d.ts +1 -1
- package/dist/types/mcp.d.ts.map +1 -1
- package/dist/utils/debug.d.ts.map +1 -1
- package/dist/utils/debug.js +10 -6
- package/dist/utils/debug.js.map +1 -1
- package/dist/utils/toolWrapper.js +3 -3
- package/docs/developer/GITHUB_ACTIONS_SETUP.md +208 -0
- package/docs/developer/MAINTENANCE.md +307 -0
- package/docs/developer/MIGRATION_GUIDE.md +172 -0
- package/docs/developer/NPM_AUTH_SETUP.md +142 -0
- package/docs/developer/REFACTORING.md +196 -0
- package/docs/releases/COMMUNITY_ANNOUNCEMENT_v1.1.2.md +126 -0
- package/docs/releases/RELEASE_NOTES_v1.1.2.md +173 -0
- package/docs/user-guides/CLAUDE_DESKTOP_SETUP.md +187 -0
- package/package.json +4 -3
- package/src/client/api.ts +229 -229
- package/src/client/auth.ts +135 -136
- package/src/client/managers/AuthenticationManager.ts +148 -105
- package/src/client/managers/BaseManager.ts +15 -12
- package/src/client/managers/RequestManager.ts +17 -17
- package/src/client/managers/index.ts +3 -3
- package/src/index.ts +141 -114
- package/src/server.ts +1 -1
- package/src/tools/auth.ts +36 -36
- package/src/tools/comments.ts +90 -90
- package/src/tools/media.ts +89 -91
- package/src/tools/pages.ts +86 -86
- package/src/tools/posts.ts +106 -106
- package/src/tools/site.ts +71 -71
- package/src/tools/taxonomies.ts +102 -102
- package/src/tools/users.ts +77 -77
- package/src/types/client.ts +1 -1
- package/src/types/index.ts +1 -1
- package/src/types/mcp.ts +36 -16
- package/src/types/wordpress.ts +1 -1
- package/src/utils/debug.ts +63 -39
- package/src/utils/error.ts +1 -1
- package/src/utils/toolWrapper.ts +4 -4
- package/dist/client/WordPressClient.d.ts +0 -81
- package/dist/client/WordPressClient.d.ts.map +0 -1
- package/dist/client/WordPressClient.js +0 -354
- package/dist/client/WordPressClient.js.map +0 -1
- package/dist/tools/base.d.ts +0 -37
- package/dist/tools/base.d.ts.map +0 -1
- package/dist/tools/base.js +0 -60
- package/dist/tools/base.js.map +0 -1
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
* Handles all authentication methods and token management
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import type { AuthConfig, AuthMethod } from
|
|
7
|
-
import { AuthenticationError } from
|
|
8
|
-
import { BaseManager } from
|
|
9
|
-
import { debug } from
|
|
6
|
+
import type { AuthConfig, AuthMethod } from '../../types/client.js';
|
|
7
|
+
import { AuthenticationError } from '../../types/client.js';
|
|
8
|
+
import { BaseManager } from './BaseManager.js';
|
|
9
|
+
import { debug } from '../../utils/debug.js';
|
|
10
10
|
|
|
11
11
|
export class AuthenticationManager extends BaseManager {
|
|
12
12
|
private jwtToken: string | null = null;
|
|
@@ -16,40 +16,46 @@ export class AuthenticationManager extends BaseManager {
|
|
|
16
16
|
* Get authentication from environment variables
|
|
17
17
|
*/
|
|
18
18
|
static getAuthFromEnv(): AuthConfig {
|
|
19
|
-
const method: AuthMethod =
|
|
20
|
-
(process.env.WORDPRESS_AUTH_METHOD as AuthMethod) ||
|
|
19
|
+
const method: AuthMethod =
|
|
20
|
+
(process.env.WORDPRESS_AUTH_METHOD as AuthMethod) || 'app-password';
|
|
21
21
|
|
|
22
22
|
switch (method) {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
23
|
+
case 'app-password':
|
|
24
|
+
return {
|
|
25
|
+
method: 'app-password',
|
|
26
|
+
username: process.env.WORDPRESS_USERNAME || '',
|
|
27
|
+
appPassword: process.env.WORDPRESS_APP_PASSWORD || ''
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
case 'jwt':
|
|
31
|
+
return {
|
|
32
|
+
method: 'jwt',
|
|
33
|
+
username: process.env.WORDPRESS_USERNAME || '',
|
|
34
|
+
password:
|
|
35
|
+
process.env.WORDPRESS_JWT_PASSWORD ||
|
|
36
|
+
process.env.WORDPRESS_PASSWORD ||
|
|
37
|
+
'',
|
|
38
|
+
secret: process.env.WORDPRESS_JWT_SECRET || ''
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
case 'basic':
|
|
42
|
+
return {
|
|
43
|
+
method: 'basic',
|
|
44
|
+
username: process.env.WORDPRESS_USERNAME || '',
|
|
45
|
+
password: process.env.WORDPRESS_PASSWORD || ''
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
case 'api-key':
|
|
49
|
+
return {
|
|
50
|
+
method: 'api-key',
|
|
51
|
+
apiKey: process.env.WORDPRESS_API_KEY || ''
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
default:
|
|
55
|
+
throw new AuthenticationError(
|
|
56
|
+
`Unsupported authentication method: ${method}`,
|
|
57
|
+
method
|
|
58
|
+
);
|
|
53
59
|
}
|
|
54
60
|
}
|
|
55
61
|
|
|
@@ -60,36 +66,49 @@ export class AuthenticationManager extends BaseManager {
|
|
|
60
66
|
const auth = this.config.auth;
|
|
61
67
|
|
|
62
68
|
switch (auth.method) {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
69
|
+
case 'app-password':
|
|
70
|
+
if (!auth.username || !auth.appPassword) {
|
|
71
|
+
throw new AuthenticationError(
|
|
72
|
+
'Username and app password are required',
|
|
73
|
+
auth.method
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const credentials = Buffer.from(
|
|
78
|
+
`${auth.username}:${auth.appPassword}`
|
|
79
|
+
).toString('base64');
|
|
80
|
+
return { Authorization: `Basic ${credentials}` };
|
|
81
|
+
|
|
82
|
+
case 'jwt':
|
|
83
|
+
if (!this.jwtToken) {
|
|
84
|
+
await this.authenticateJWT();
|
|
85
|
+
}
|
|
86
|
+
return { Authorization: `Bearer ${this.jwtToken}` };
|
|
87
|
+
|
|
88
|
+
case 'basic':
|
|
89
|
+
if (!auth.username || !auth.password) {
|
|
90
|
+
throw new AuthenticationError(
|
|
91
|
+
'Username and password are required',
|
|
92
|
+
auth.method
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const basicCredentials = Buffer.from(
|
|
97
|
+
`${auth.username}:${auth.password}`
|
|
98
|
+
).toString('base64');
|
|
99
|
+
return { Authorization: `Basic ${basicCredentials}` };
|
|
100
|
+
|
|
101
|
+
case 'api-key':
|
|
102
|
+
if (!auth.apiKey) {
|
|
103
|
+
throw new AuthenticationError('API key is required', auth.method);
|
|
104
|
+
}
|
|
105
|
+
return { 'X-API-Key': auth.apiKey };
|
|
106
|
+
|
|
107
|
+
default:
|
|
108
|
+
throw new AuthenticationError(
|
|
109
|
+
`Unsupported authentication method: ${auth.method}`,
|
|
110
|
+
auth.method
|
|
111
|
+
);
|
|
93
112
|
}
|
|
94
113
|
}
|
|
95
114
|
|
|
@@ -98,18 +117,23 @@ export class AuthenticationManager extends BaseManager {
|
|
|
98
117
|
*/
|
|
99
118
|
private async authenticateJWT(): Promise<void> {
|
|
100
119
|
const auth = this.config.auth;
|
|
101
|
-
|
|
102
|
-
if (auth.method !==
|
|
103
|
-
throw new AuthenticationError(
|
|
120
|
+
|
|
121
|
+
if (auth.method !== 'jwt' || !auth.username || !auth.password) {
|
|
122
|
+
throw new AuthenticationError(
|
|
123
|
+
'JWT authentication requires username and password',
|
|
124
|
+
'jwt'
|
|
125
|
+
);
|
|
104
126
|
}
|
|
105
127
|
|
|
106
128
|
try {
|
|
107
129
|
// This would need the RequestManager instance to make the request
|
|
108
130
|
// For now, we'll throw an error indicating this needs to be implemented
|
|
109
|
-
throw new AuthenticationError(
|
|
110
|
-
|
|
131
|
+
throw new AuthenticationError(
|
|
132
|
+
'JWT authentication requires RequestManager integration',
|
|
133
|
+
'jwt'
|
|
134
|
+
);
|
|
111
135
|
} catch (error) {
|
|
112
|
-
this.handleError(error,
|
|
136
|
+
this.handleError(error, 'JWT authentication');
|
|
113
137
|
}
|
|
114
138
|
}
|
|
115
139
|
|
|
@@ -118,17 +142,18 @@ export class AuthenticationManager extends BaseManager {
|
|
|
118
142
|
*/
|
|
119
143
|
async testAuthentication(): Promise<boolean> {
|
|
120
144
|
try {
|
|
121
|
-
const
|
|
122
|
-
debug.log(
|
|
123
|
-
|
|
145
|
+
const _headers = await this.getAuthHeaders();
|
|
146
|
+
debug.log('Authentication headers prepared', {
|
|
147
|
+
method: this.config.auth.method
|
|
148
|
+
});
|
|
149
|
+
|
|
124
150
|
// This would need the RequestManager to actually test the connection
|
|
125
151
|
// For now, we'll return true if headers can be generated
|
|
126
152
|
this.authenticated = true;
|
|
127
153
|
return true;
|
|
128
|
-
|
|
129
154
|
} catch (error) {
|
|
130
155
|
this.authenticated = false;
|
|
131
|
-
debug.log(
|
|
156
|
+
debug.log('Authentication test failed', error);
|
|
132
157
|
return false;
|
|
133
158
|
}
|
|
134
159
|
}
|
|
@@ -155,36 +180,54 @@ export class AuthenticationManager extends BaseManager {
|
|
|
155
180
|
const auth = this.config.auth;
|
|
156
181
|
|
|
157
182
|
if (!auth.method) {
|
|
158
|
-
throw new AuthenticationError(
|
|
183
|
+
throw new AuthenticationError(
|
|
184
|
+
'Authentication method is required',
|
|
185
|
+
'app-password'
|
|
186
|
+
);
|
|
159
187
|
}
|
|
160
188
|
|
|
161
189
|
switch (auth.method) {
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
190
|
+
case 'app-password':
|
|
191
|
+
if (!auth.username || !auth.appPassword) {
|
|
192
|
+
throw new AuthenticationError(
|
|
193
|
+
'App password authentication requires username and appPassword',
|
|
194
|
+
'app-password'
|
|
195
|
+
);
|
|
196
|
+
}
|
|
197
|
+
break;
|
|
198
|
+
|
|
199
|
+
case 'jwt':
|
|
200
|
+
if (!auth.username || !auth.password || !auth.secret) {
|
|
201
|
+
throw new AuthenticationError(
|
|
202
|
+
'JWT authentication requires username, password, and secret',
|
|
203
|
+
'jwt'
|
|
204
|
+
);
|
|
205
|
+
}
|
|
206
|
+
break;
|
|
207
|
+
|
|
208
|
+
case 'basic':
|
|
209
|
+
if (!auth.username || !auth.password) {
|
|
210
|
+
throw new AuthenticationError(
|
|
211
|
+
'Basic authentication requires username and password',
|
|
212
|
+
'basic'
|
|
213
|
+
);
|
|
214
|
+
}
|
|
215
|
+
break;
|
|
216
|
+
|
|
217
|
+
case 'api-key':
|
|
218
|
+
if (!auth.apiKey) {
|
|
219
|
+
throw new AuthenticationError(
|
|
220
|
+
'API key authentication requires apiKey',
|
|
221
|
+
'api-key'
|
|
222
|
+
);
|
|
223
|
+
}
|
|
224
|
+
break;
|
|
225
|
+
|
|
226
|
+
default:
|
|
227
|
+
throw new AuthenticationError(
|
|
228
|
+
`Unsupported authentication method: ${auth.method}`,
|
|
229
|
+
auth.method
|
|
230
|
+
);
|
|
188
231
|
}
|
|
189
232
|
}
|
|
190
|
-
}
|
|
233
|
+
}
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
* Provides common functionality and error handling
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import type { WordPressClientConfig
|
|
7
|
-
import { WordPressAPIError
|
|
8
|
-
import { debug, logError } from
|
|
9
|
-
import { getErrorMessage } from
|
|
6
|
+
import type { WordPressClientConfig } from '../../types/client.js';
|
|
7
|
+
import { WordPressAPIError } from '../../types/client.js';
|
|
8
|
+
import { debug, logError } from '../../utils/debug.js';
|
|
9
|
+
import { getErrorMessage } from '../../utils/error.js';
|
|
10
10
|
|
|
11
11
|
export abstract class BaseManager {
|
|
12
12
|
protected config: WordPressClientConfig;
|
|
@@ -25,19 +25,19 @@ export abstract class BaseManager {
|
|
|
25
25
|
throw error;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
if (error.name ===
|
|
28
|
+
if (error.name === 'AbortError' || error.code === 'ABORT_ERR') {
|
|
29
29
|
throw new WordPressAPIError(
|
|
30
30
|
`Request timeout after ${this.config.timeout}ms`,
|
|
31
31
|
408,
|
|
32
|
-
|
|
32
|
+
'timeout'
|
|
33
33
|
);
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
if (error.code ===
|
|
36
|
+
if (error.code === 'ECONNREFUSED' || error.code === 'ENOTFOUND') {
|
|
37
37
|
throw new WordPressAPIError(
|
|
38
38
|
`Cannot connect to WordPress site: ${this.config.baseUrl}`,
|
|
39
39
|
503,
|
|
40
|
-
|
|
40
|
+
'connection_failed'
|
|
41
41
|
);
|
|
42
42
|
}
|
|
43
43
|
|
|
@@ -45,7 +45,7 @@ export abstract class BaseManager {
|
|
|
45
45
|
throw new WordPressAPIError(
|
|
46
46
|
`${operation} failed: ${message}`,
|
|
47
47
|
500,
|
|
48
|
-
|
|
48
|
+
'unknown_error'
|
|
49
49
|
);
|
|
50
50
|
}
|
|
51
51
|
|
|
@@ -59,15 +59,18 @@ export abstract class BaseManager {
|
|
|
59
59
|
/**
|
|
60
60
|
* Validate required parameters
|
|
61
61
|
*/
|
|
62
|
-
protected validateRequired(
|
|
62
|
+
protected validateRequired(
|
|
63
|
+
params: Record<string, any>,
|
|
64
|
+
requiredFields: string[]
|
|
65
|
+
): void {
|
|
63
66
|
for (const field of requiredFields) {
|
|
64
67
|
if (params[field] === undefined || params[field] === null) {
|
|
65
68
|
throw new WordPressAPIError(
|
|
66
69
|
`Missing required parameter: ${field}`,
|
|
67
70
|
400,
|
|
68
|
-
|
|
71
|
+
'missing_parameter'
|
|
69
72
|
);
|
|
70
73
|
}
|
|
71
74
|
}
|
|
72
75
|
}
|
|
73
|
-
}
|
|
76
|
+
}
|
|
@@ -3,16 +3,16 @@
|
|
|
3
3
|
* Handles all HTTP operations, rate limiting, and retries
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import fetch from
|
|
6
|
+
import fetch from 'node-fetch';
|
|
7
7
|
import type {
|
|
8
8
|
HTTPMethod,
|
|
9
9
|
RequestOptions,
|
|
10
10
|
ClientStats,
|
|
11
11
|
WordPressClientConfig
|
|
12
|
-
} from
|
|
13
|
-
import { WordPressAPIError, RateLimitError } from
|
|
14
|
-
import { BaseManager } from
|
|
15
|
-
import { debug, startTimer } from
|
|
12
|
+
} from '../../types/client.js';
|
|
13
|
+
import { WordPressAPIError, RateLimitError } from '../../types/client.js';
|
|
14
|
+
import { BaseManager } from './BaseManager.js';
|
|
15
|
+
import { debug, startTimer } from '../../utils/debug.js';
|
|
16
16
|
|
|
17
17
|
export class RequestManager extends BaseManager {
|
|
18
18
|
private stats: ClientStats;
|
|
@@ -22,14 +22,14 @@ export class RequestManager extends BaseManager {
|
|
|
22
22
|
constructor(config: WordPressClientConfig) {
|
|
23
23
|
super(config);
|
|
24
24
|
|
|
25
|
-
this.requestInterval = 60000 / parseInt(process.env.RATE_LIMIT ||
|
|
25
|
+
this.requestInterval = 60000 / parseInt(process.env.RATE_LIMIT || '60');
|
|
26
26
|
this.stats = {
|
|
27
27
|
totalRequests: 0,
|
|
28
28
|
successfulRequests: 0,
|
|
29
29
|
failedRequests: 0,
|
|
30
30
|
averageResponseTime: 0,
|
|
31
31
|
rateLimitHits: 0,
|
|
32
|
-
authFailures: 0
|
|
32
|
+
authFailures: 0
|
|
33
33
|
};
|
|
34
34
|
}
|
|
35
35
|
|
|
@@ -114,14 +114,14 @@ export class RequestManager extends BaseManager {
|
|
|
114
114
|
const fetchOptions: any = {
|
|
115
115
|
method,
|
|
116
116
|
headers: {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
...options.headers
|
|
117
|
+
'Content-Type': 'application/json',
|
|
118
|
+
'User-Agent': 'MCP-WordPress/1.1.1',
|
|
119
|
+
...options.headers
|
|
120
120
|
},
|
|
121
|
-
signal: controller.signal
|
|
121
|
+
signal: controller.signal
|
|
122
122
|
};
|
|
123
123
|
|
|
124
|
-
if (data && method !==
|
|
124
|
+
if (data && method !== 'GET') {
|
|
125
125
|
fetchOptions.body = JSON.stringify(data);
|
|
126
126
|
}
|
|
127
127
|
|
|
@@ -154,7 +154,7 @@ export class RequestManager extends BaseManager {
|
|
|
154
154
|
}
|
|
155
155
|
|
|
156
156
|
const message = errorData.message || `HTTP ${response.status}: ${response.statusText}`;
|
|
157
|
-
const code = errorData.code ||
|
|
157
|
+
const code = errorData.code || 'http_error';
|
|
158
158
|
|
|
159
159
|
if (response.status === 429) {
|
|
160
160
|
this.stats.rateLimitHits++;
|
|
@@ -172,9 +172,9 @@ export class RequestManager extends BaseManager {
|
|
|
172
172
|
* Build full URL from endpoint
|
|
173
173
|
*/
|
|
174
174
|
private buildUrl(endpoint: string): string {
|
|
175
|
-
const baseUrl = this.config.baseUrl.replace(/\/$/,
|
|
176
|
-
const apiBase =
|
|
177
|
-
const cleanEndpoint = endpoint.startsWith(
|
|
175
|
+
const baseUrl = this.config.baseUrl.replace(/\/$/, '');
|
|
176
|
+
const apiBase = '/wp-json/wp/v2';
|
|
177
|
+
const cleanEndpoint = endpoint.startsWith('/') ? endpoint : `/${endpoint}`;
|
|
178
178
|
|
|
179
179
|
return `${baseUrl}${apiBase}${cleanEndpoint}`;
|
|
180
180
|
}
|
|
@@ -211,4 +211,4 @@ export class RequestManager extends BaseManager {
|
|
|
211
211
|
getStats(): ClientStats {
|
|
212
212
|
return { ...this.stats };
|
|
213
213
|
}
|
|
214
|
-
}
|
|
214
|
+
}
|
|
@@ -3,6 +3,6 @@
|
|
|
3
3
|
* Exports all manager classes for the WordPress client
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
export { BaseManager } from
|
|
7
|
-
export { AuthenticationManager } from
|
|
8
|
-
export { RequestManager } from
|
|
6
|
+
export { BaseManager } from './BaseManager.js';
|
|
7
|
+
export { AuthenticationManager } from './AuthenticationManager.js';
|
|
8
|
+
export { RequestManager } from './RequestManager.js';
|