payload-wordpress-migrator 0.0.22
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/LICENSE +21 -0
- package/README.md +586 -0
- package/dist/components/BeforeDashboardClient.d.ts +14 -0
- package/dist/components/BeforeDashboardClient.js +225 -0
- package/dist/components/BeforeDashboardClient.js.map +1 -0
- package/dist/components/BeforeDashboardClient.module.css +175 -0
- package/dist/components/BeforeDashboardServer.d.ts +1 -0
- package/dist/components/BeforeDashboardServer.js +29 -0
- package/dist/components/BeforeDashboardServer.js.map +1 -0
- package/dist/components/ContentTypeSelect.d.ts +4 -0
- package/dist/components/ContentTypeSelect.js +147 -0
- package/dist/components/ContentTypeSelect.js.map +1 -0
- package/dist/components/FieldMappingConfiguration.d.ts +5 -0
- package/dist/components/FieldMappingConfiguration.js +361 -0
- package/dist/components/FieldMappingConfiguration.js.map +1 -0
- package/dist/components/FieldMappingConfiguration.module.css +75 -0
- package/dist/components/MigrationDashboardClient.d.ts +6 -0
- package/dist/components/MigrationDashboardClient.js +49 -0
- package/dist/components/MigrationDashboardClient.js.map +1 -0
- package/dist/components/MigrationDashboardClient.module.css +749 -0
- package/dist/components/SimpleFieldMapping.d.ts +5 -0
- package/dist/components/SimpleFieldMapping.js +437 -0
- package/dist/components/SimpleFieldMapping.js.map +1 -0
- package/dist/components/dashboard/JobActionButtons.d.ts +8 -0
- package/dist/components/dashboard/JobActionButtons.js +91 -0
- package/dist/components/dashboard/JobActionButtons.js.map +1 -0
- package/dist/components/dashboard/JobsTable.d.ts +6 -0
- package/dist/components/dashboard/JobsTable.js +86 -0
- package/dist/components/dashboard/JobsTable.js.map +1 -0
- package/dist/components/dashboard/LogViewer.d.ts +3 -0
- package/dist/components/dashboard/LogViewer.js +35 -0
- package/dist/components/dashboard/LogViewer.js.map +1 -0
- package/dist/components/dashboard/SiteConfigPanel.d.ts +12 -0
- package/dist/components/dashboard/SiteConfigPanel.js +205 -0
- package/dist/components/dashboard/SiteConfigPanel.js.map +1 -0
- package/dist/components/dashboard/StatsOverview.d.ts +5 -0
- package/dist/components/dashboard/StatsOverview.js +72 -0
- package/dist/components/dashboard/StatsOverview.js.map +1 -0
- package/dist/components/dashboard/index.d.ts +7 -0
- package/dist/components/dashboard/index.js +7 -0
- package/dist/components/dashboard/index.js.map +1 -0
- package/dist/components/dashboard/types.d.ts +46 -0
- package/dist/components/dashboard/types.js +2 -0
- package/dist/components/dashboard/types.js.map +1 -0
- package/dist/components/dashboard/useMigrationDashboard.d.ts +15 -0
- package/dist/components/dashboard/useMigrationDashboard.js +584 -0
- package/dist/components/dashboard/useMigrationDashboard.js.map +1 -0
- package/dist/exports/client.d.ts +4 -0
- package/dist/exports/client.js +5 -0
- package/dist/exports/client.js.map +1 -0
- package/dist/exports/rsc.d.ts +1 -0
- package/dist/exports/rsc.js +2 -0
- package/dist/exports/rsc.js.map +1 -0
- package/dist/index.d.ts +101 -0
- package/dist/index.js +443 -0
- package/dist/index.js.map +1 -0
- package/dist/utils/content/blocks.d.ts +6 -0
- package/dist/utils/content/blocks.js +93 -0
- package/dist/utils/content/blocks.js.map +1 -0
- package/dist/utils/content/fieldMapping.d.ts +9 -0
- package/dist/utils/content/fieldMapping.js +218 -0
- package/dist/utils/content/fieldMapping.js.map +1 -0
- package/dist/utils/content/index.d.ts +4 -0
- package/dist/utils/content/index.js +4 -0
- package/dist/utils/content/index.js.map +1 -0
- package/dist/utils/content/transformer.d.ts +5 -0
- package/dist/utils/content/transformer.js +323 -0
- package/dist/utils/content/transformer.js.map +1 -0
- package/dist/utils/endpoints/handlers.d.ts +9 -0
- package/dist/utils/endpoints/handlers.js +201 -0
- package/dist/utils/endpoints/handlers.js.map +1 -0
- package/dist/utils/endpoints/index.d.ts +2 -0
- package/dist/utils/endpoints/index.js +2 -0
- package/dist/utils/endpoints/index.js.map +1 -0
- package/dist/utils/fields/analyzer.d.ts +7 -0
- package/dist/utils/fields/analyzer.js +502 -0
- package/dist/utils/fields/analyzer.js.map +1 -0
- package/dist/utils/fields/index.d.ts +2 -0
- package/dist/utils/fields/index.js +2 -0
- package/dist/utils/fields/index.js.map +1 -0
- package/dist/utils/helpers/auth.d.ts +9 -0
- package/dist/utils/helpers/auth.js +50 -0
- package/dist/utils/helpers/auth.js.map +1 -0
- package/dist/utils/helpers/cache.d.ts +11 -0
- package/dist/utils/helpers/cache.js +47 -0
- package/dist/utils/helpers/cache.js.map +1 -0
- package/dist/utils/helpers/concurrency.d.ts +2 -0
- package/dist/utils/helpers/concurrency.js +26 -0
- package/dist/utils/helpers/concurrency.js.map +1 -0
- package/dist/utils/helpers/index.d.ts +8 -0
- package/dist/utils/helpers/index.js +8 -0
- package/dist/utils/helpers/index.js.map +1 -0
- package/dist/utils/helpers/objectHelpers.d.ts +3 -0
- package/dist/utils/helpers/objectHelpers.js +22 -0
- package/dist/utils/helpers/objectHelpers.js.map +1 -0
- package/dist/utils/helpers/rateLimiter.d.ts +10 -0
- package/dist/utils/helpers/rateLimiter.js +29 -0
- package/dist/utils/helpers/rateLimiter.js.map +1 -0
- package/dist/utils/helpers/responses.d.ts +3 -0
- package/dist/utils/helpers/responses.js +23 -0
- package/dist/utils/helpers/responses.js.map +1 -0
- package/dist/utils/helpers/wpHelpers.d.ts +6 -0
- package/dist/utils/helpers/wpHelpers.js +29 -0
- package/dist/utils/helpers/wpHelpers.js.map +1 -0
- package/dist/utils/lexical/constants.d.ts +37 -0
- package/dist/utils/lexical/constants.js +58 -0
- package/dist/utils/lexical/constants.js.map +1 -0
- package/dist/utils/lexical/htmlParser.d.ts +20 -0
- package/dist/utils/lexical/htmlParser.js +253 -0
- package/dist/utils/lexical/htmlParser.js.map +1 -0
- package/dist/utils/lexical/htmlToLexicalConverter.d.ts +55 -0
- package/dist/utils/lexical/htmlToLexicalConverter.js +999 -0
- package/dist/utils/lexical/htmlToLexicalConverter.js.map +1 -0
- package/dist/utils/lexical/index.d.ts +5 -0
- package/dist/utils/lexical/index.js +4 -0
- package/dist/utils/lexical/index.js.map +1 -0
- package/dist/utils/lexical/nodeFactories.d.ts +21 -0
- package/dist/utils/lexical/nodeFactories.js +91 -0
- package/dist/utils/lexical/nodeFactories.js.map +1 -0
- package/dist/utils/lexical/preprocessor.d.ts +4 -0
- package/dist/utils/lexical/preprocessor.js +302 -0
- package/dist/utils/lexical/preprocessor.js.map +1 -0
- package/dist/utils/media/download.d.ts +7 -0
- package/dist/utils/media/download.js +85 -0
- package/dist/utils/media/download.js.map +1 -0
- package/dist/utils/media/extraction.d.ts +12 -0
- package/dist/utils/media/extraction.js +58 -0
- package/dist/utils/media/extraction.js.map +1 -0
- package/dist/utils/media/import.d.ts +7 -0
- package/dist/utils/media/import.js +146 -0
- package/dist/utils/media/import.js.map +1 -0
- package/dist/utils/media/index.d.ts +6 -0
- package/dist/utils/media/index.js +6 -0
- package/dist/utils/media/index.js.map +1 -0
- package/dist/utils/media/upload.d.ts +4 -0
- package/dist/utils/media/upload.js +46 -0
- package/dist/utils/media/upload.js.map +1 -0
- package/dist/utils/media/validation.d.ts +8 -0
- package/dist/utils/media/validation.js +60 -0
- package/dist/utils/media/validation.js.map +1 -0
- package/dist/utils/migration/index.d.ts +3 -0
- package/dist/utils/migration/index.js +3 -0
- package/dist/utils/migration/index.js.map +1 -0
- package/dist/utils/migration/jobCrud.d.ts +4 -0
- package/dist/utils/migration/jobCrud.js +380 -0
- package/dist/utils/migration/jobCrud.js.map +1 -0
- package/dist/utils/migration/orchestrator.d.ts +5 -0
- package/dist/utils/migration/orchestrator.js +756 -0
- package/dist/utils/migration/orchestrator.js.map +1 -0
- package/dist/utils/types.d.ts +201 -0
- package/dist/utils/types.js +14 -0
- package/dist/utils/types.js.map +1 -0
- package/dist/utils/wordpress/client.d.ts +61 -0
- package/dist/utils/wordpress/client.js +365 -0
- package/dist/utils/wordpress/client.js.map +1 -0
- package/dist/utils/wordpress/index.d.ts +2 -0
- package/dist/utils/wordpress/index.js +2 -0
- package/dist/utils/wordpress/index.js.map +1 -0
- package/dist/utils/wordpressApi.d.ts +11 -0
- package/dist/utils/wordpressApi.js +25 -0
- package/dist/utils/wordpressApi.js.map +1 -0
- package/package.json +155 -0
|
@@ -0,0 +1,365 @@
|
|
|
1
|
+
import { analyzeWordPressFields } from '../fields/analyzer.js';
|
|
2
|
+
import { constructWordPressApiUrl, createWordPressHeaders, getContentTypeEndpoint, getFieldAnalysisEndpoint } from '../helpers/wpHelpers.js';
|
|
3
|
+
|
|
4
|
+
// =============================================================================
|
|
5
|
+
// WORDPRESS CLIENT CLASS
|
|
6
|
+
// =============================================================================
|
|
7
|
+
class WordPressClient {
|
|
8
|
+
constructor(credentials, allowSelfSignedCerts = false){
|
|
9
|
+
this.sslWarningShown = false;
|
|
10
|
+
this.credentials = credentials;
|
|
11
|
+
this.apiUrl = constructWordPressApiUrl(credentials.wpSiteUrl);
|
|
12
|
+
this.headers = createWordPressHeaders(credentials);
|
|
13
|
+
this.allowSelfSignedCerts = allowSelfSignedCerts;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Fetch with SSL certificate handling
|
|
17
|
+
*/ async fetchWithSSLHandling(url, options = {}) {
|
|
18
|
+
try {
|
|
19
|
+
return await fetch(url, options);
|
|
20
|
+
} catch (fetchError) {
|
|
21
|
+
// If fetch fails due to SSL certificate issues and we allow self-signed certs
|
|
22
|
+
if (this.allowSelfSignedCerts && (fetchError.cause?.code === 'DEPTH_ZERO_SELF_SIGNED_CERT' || fetchError.cause?.code === 'SELF_SIGNED_CERT_IN_CHAIN' || fetchError.message?.includes('certificate'))) {
|
|
23
|
+
if (!this.sslWarningShown) {
|
|
24
|
+
this.sslWarningShown = true;
|
|
25
|
+
if (process.env.NODE_ENV === 'production') {
|
|
26
|
+
console.warn('WARNING: allowSelfSignedCerts is enabled in production. ' + 'This disables TLS certificate verification and is a security risk. ' + 'Consider using a valid SSL certificate instead.');
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
console.warn(`SSL certificate issue detected for ${url}. Attempting request with relaxed SSL verification (allowSelfSignedCerts=true).`);
|
|
30
|
+
// Create a custom fetch with relaxed SSL for this specific request
|
|
31
|
+
const https = await import('https');
|
|
32
|
+
const { default: fetch1 } = await import('node-fetch');
|
|
33
|
+
const agent = new https.Agent({
|
|
34
|
+
rejectUnauthorized: false
|
|
35
|
+
});
|
|
36
|
+
// Extract only the compatible options for node-fetch
|
|
37
|
+
const nodeOptions = {
|
|
38
|
+
agent,
|
|
39
|
+
body: options.body,
|
|
40
|
+
headers: options.headers,
|
|
41
|
+
method: options.method
|
|
42
|
+
};
|
|
43
|
+
return await fetch1(url, nodeOptions);
|
|
44
|
+
} else {
|
|
45
|
+
// Re-throw the original error with more context
|
|
46
|
+
const errorMessage = fetchError.cause?.code ? `${fetchError.message} (${fetchError.cause.code})` : fetchError.message;
|
|
47
|
+
if (fetchError.cause?.code === 'DEPTH_ZERO_SELF_SIGNED_CERT' || fetchError.cause?.code === 'SELF_SIGNED_CERT_IN_CHAIN') {
|
|
48
|
+
throw new Error(`${errorMessage}. Consider setting allowSelfSignedCerts: true in plugin configuration for development environments.`);
|
|
49
|
+
}
|
|
50
|
+
throw fetchError;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Discover available content types
|
|
56
|
+
*/ async discoverContent() {
|
|
57
|
+
try {
|
|
58
|
+
// Test connection first
|
|
59
|
+
const testResult = await this.testConnection();
|
|
60
|
+
if (!testResult.success) {
|
|
61
|
+
return {
|
|
62
|
+
success: false,
|
|
63
|
+
error: testResult.error
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
const contentTypes = [];
|
|
67
|
+
// Built-in content types to check
|
|
68
|
+
const builtInTypes = [
|
|
69
|
+
{
|
|
70
|
+
type: 'posts',
|
|
71
|
+
label: 'Posts'
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
type: 'pages',
|
|
75
|
+
label: 'Pages'
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
type: 'media',
|
|
79
|
+
label: 'Media'
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
type: 'categories',
|
|
83
|
+
label: 'Categories'
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
type: 'users',
|
|
87
|
+
label: 'Users'
|
|
88
|
+
}
|
|
89
|
+
];
|
|
90
|
+
// Check built-in content types
|
|
91
|
+
for (const { type, label } of builtInTypes){
|
|
92
|
+
try {
|
|
93
|
+
const endpoint = getContentTypeEndpoint(this.apiUrl, type);
|
|
94
|
+
// Add context=edit for users to check private field access
|
|
95
|
+
const contextParam = type === 'users' ? '&context=edit' : '';
|
|
96
|
+
const response = await fetch(`${endpoint}?per_page=1${contextParam}`, {
|
|
97
|
+
headers: this.headers
|
|
98
|
+
});
|
|
99
|
+
if (response.ok) {
|
|
100
|
+
const totalCount = parseInt(response.headers.get('X-WP-Total') || '0');
|
|
101
|
+
if (totalCount > 0) {
|
|
102
|
+
contentTypes.push({
|
|
103
|
+
type,
|
|
104
|
+
available: true,
|
|
105
|
+
count: totalCount,
|
|
106
|
+
label
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
} catch (error) {
|
|
111
|
+
console.error(`Failed to check ${type}:`, error);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
// Discover custom post types
|
|
115
|
+
try {
|
|
116
|
+
const typesResponse = await fetch(`${this.apiUrl}/types`, {
|
|
117
|
+
headers: this.headers
|
|
118
|
+
});
|
|
119
|
+
if (typesResponse.ok) {
|
|
120
|
+
const types = await typesResponse.json();
|
|
121
|
+
for (const [typeKey, typeData] of Object.entries(types)){
|
|
122
|
+
const typeInfo = typeData;
|
|
123
|
+
// Skip built-in types we already checked
|
|
124
|
+
if (![
|
|
125
|
+
'attachment',
|
|
126
|
+
'page',
|
|
127
|
+
'post'
|
|
128
|
+
].includes(typeKey) && typeInfo.rest_base) {
|
|
129
|
+
try {
|
|
130
|
+
const customResponse = await fetch(`${this.apiUrl}/${typeInfo.rest_base}?per_page=1`, {
|
|
131
|
+
headers: this.headers
|
|
132
|
+
});
|
|
133
|
+
if (customResponse.ok) {
|
|
134
|
+
const totalCustom = parseInt(customResponse.headers.get('X-WP-Total') || '0');
|
|
135
|
+
if (totalCustom > 0) {
|
|
136
|
+
contentTypes.push({
|
|
137
|
+
type: typeKey,
|
|
138
|
+
available: true,
|
|
139
|
+
count: totalCustom,
|
|
140
|
+
custom: true,
|
|
141
|
+
label: typeInfo.name || typeKey,
|
|
142
|
+
restBase: typeInfo.rest_base
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
} catch (error) {
|
|
147
|
+
console.warn(`Failed to check custom post type ${typeKey}:`, error);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
} catch (error) {
|
|
153
|
+
console.warn('Failed to discover custom post types:', error);
|
|
154
|
+
}
|
|
155
|
+
const totalItems = contentTypes.reduce((sum, type)=>sum + type.count, 0);
|
|
156
|
+
return {
|
|
157
|
+
data: {
|
|
158
|
+
contentTypes,
|
|
159
|
+
siteInfo: testResult.data?.siteInfo,
|
|
160
|
+
totalItems
|
|
161
|
+
},
|
|
162
|
+
success: true
|
|
163
|
+
};
|
|
164
|
+
} catch (error) {
|
|
165
|
+
console.error('Content discovery error:', error);
|
|
166
|
+
const errorMessage = error instanceof Error ? error.message : `Unknown error occurred: ${String(error)}`;
|
|
167
|
+
return {
|
|
168
|
+
error: errorMessage,
|
|
169
|
+
success: false
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Async generator that yields one page of results at a time.
|
|
175
|
+
* Enables streaming processing without buffering all items in memory.
|
|
176
|
+
*/ async *fetchPages(endpoint, options = {}) {
|
|
177
|
+
const { contentType, includeIds, onProgress, requestDelay = 0, timeoutMs = 30000 } = options;
|
|
178
|
+
let page = 1;
|
|
179
|
+
let hasMore = true;
|
|
180
|
+
let runningItemCount = 0;
|
|
181
|
+
const embedTypes = [
|
|
182
|
+
'pages',
|
|
183
|
+
'posts'
|
|
184
|
+
];
|
|
185
|
+
const embedParam = contentType && embedTypes.includes(contentType) ? '&_embed=1' : '';
|
|
186
|
+
const contextParam = contentType === 'users' ? '&context=edit' : '';
|
|
187
|
+
const yoastParam = contentType && embedTypes.includes(contentType) ? '&yoast_head=1' : '';
|
|
188
|
+
const includeParam = includeIds && includeIds.length > 0 ? `&include=${includeIds.join(',')}` : '';
|
|
189
|
+
while(hasMore){
|
|
190
|
+
const url = `${endpoint}?per_page=100&page=${page}${embedParam}${contextParam}${yoastParam}${includeParam}`;
|
|
191
|
+
const controller = new AbortController();
|
|
192
|
+
const timeoutId = setTimeout(()=>{
|
|
193
|
+
controller.abort();
|
|
194
|
+
}, timeoutMs);
|
|
195
|
+
let response;
|
|
196
|
+
try {
|
|
197
|
+
response = await this.fetchWithSSLHandling(url, {
|
|
198
|
+
headers: this.headers,
|
|
199
|
+
signal: controller.signal
|
|
200
|
+
});
|
|
201
|
+
} catch (fetchError) {
|
|
202
|
+
clearTimeout(timeoutId);
|
|
203
|
+
if (fetchError.name === 'AbortError') {
|
|
204
|
+
throw new Error(`WordPress API request timed out after ${timeoutMs}ms. ` + `This may indicate that your production server cannot reach the WordPress site. ` + `Check: 1) WordPress site is accessible from production, 2) No firewall blocking, 3) WordPress site allows requests from your server IP.`);
|
|
205
|
+
}
|
|
206
|
+
throw fetchError;
|
|
207
|
+
}
|
|
208
|
+
clearTimeout(timeoutId);
|
|
209
|
+
if (!response.ok) {
|
|
210
|
+
if (page === 1) {
|
|
211
|
+
throw new Error(`Failed to fetch from WordPress API (${response.status} ${response.statusText}). ` + `URL: ${endpoint}. This may indicate authentication issues or the WordPress site blocking the request.`);
|
|
212
|
+
}
|
|
213
|
+
break;
|
|
214
|
+
}
|
|
215
|
+
const items = await response.json();
|
|
216
|
+
if (items.length === 0) {
|
|
217
|
+
break;
|
|
218
|
+
}
|
|
219
|
+
const totalPages = parseInt(response.headers.get('X-WP-TotalPages') || '1');
|
|
220
|
+
const totalItems = parseInt(response.headers.get('X-WP-Total') || '0');
|
|
221
|
+
hasMore = page < totalPages;
|
|
222
|
+
runningItemCount += items.length;
|
|
223
|
+
if (onProgress) {
|
|
224
|
+
onProgress(page, totalPages, runningItemCount);
|
|
225
|
+
}
|
|
226
|
+
yield {
|
|
227
|
+
items,
|
|
228
|
+
totalItems,
|
|
229
|
+
totalPages
|
|
230
|
+
};
|
|
231
|
+
page++;
|
|
232
|
+
// Rate limiting: delay between page requests
|
|
233
|
+
if (hasMore && requestDelay > 0) {
|
|
234
|
+
await new Promise((resolve)=>setTimeout(resolve, requestDelay));
|
|
235
|
+
}
|
|
236
|
+
// Respect Retry-After header if present
|
|
237
|
+
const retryAfter = response.headers.get('retry-after');
|
|
238
|
+
if (hasMore && retryAfter) {
|
|
239
|
+
const retryMs = parseInt(retryAfter) * 1000;
|
|
240
|
+
if (retryMs > 0) {
|
|
241
|
+
await new Promise((resolve)=>setTimeout(resolve, retryMs));
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Fetch all pages of content with pagination (collects all items into memory).
|
|
248
|
+
* For streaming processing, use fetchPages() instead.
|
|
249
|
+
*/ async fetchAllPages(endpoint, onProgress, contentType, includeIds, timeoutMs = 30000) {
|
|
250
|
+
const allItems = [];
|
|
251
|
+
for await (const { items } of this.fetchPages(endpoint, {
|
|
252
|
+
contentType,
|
|
253
|
+
includeIds,
|
|
254
|
+
onProgress: onProgress ? (page, totalPages, count)=>onProgress(page, totalPages, count) : undefined,
|
|
255
|
+
timeoutMs
|
|
256
|
+
})){
|
|
257
|
+
allItems.push(...items);
|
|
258
|
+
}
|
|
259
|
+
return allItems;
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Fetch content fields for analysis
|
|
263
|
+
*/ async fetchContentFields(contentType) {
|
|
264
|
+
try {
|
|
265
|
+
const endpoint = getFieldAnalysisEndpoint(this.apiUrl, contentType);
|
|
266
|
+
const response = await fetch(endpoint, {
|
|
267
|
+
headers: this.headers
|
|
268
|
+
});
|
|
269
|
+
if (!response.ok) {
|
|
270
|
+
throw new Error(`WordPress API error: ${response.status} ${response.statusText}`);
|
|
271
|
+
}
|
|
272
|
+
const items = await response.json();
|
|
273
|
+
if (!items || items.length === 0) {
|
|
274
|
+
return {
|
|
275
|
+
data: {
|
|
276
|
+
contentType,
|
|
277
|
+
fields: []
|
|
278
|
+
},
|
|
279
|
+
success: true
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
// Analyze field structure from the sample item
|
|
283
|
+
const sampleItem = items[0];
|
|
284
|
+
const fields = analyzeWordPressFields(sampleItem, contentType);
|
|
285
|
+
return {
|
|
286
|
+
data: {
|
|
287
|
+
contentType,
|
|
288
|
+
fields
|
|
289
|
+
},
|
|
290
|
+
success: true
|
|
291
|
+
};
|
|
292
|
+
} catch (error) {
|
|
293
|
+
return {
|
|
294
|
+
error: error instanceof Error ? error.message : 'Failed to fetch WordPress content fields',
|
|
295
|
+
success: false
|
|
296
|
+
};
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
/**
|
|
300
|
+
* Test WordPress connection
|
|
301
|
+
*/ async testConnection() {
|
|
302
|
+
try {
|
|
303
|
+
const response = await fetch(`${this.apiUrl}/users/me`, {
|
|
304
|
+
headers: this.headers
|
|
305
|
+
});
|
|
306
|
+
if (!response.ok) {
|
|
307
|
+
const errorText = await response.text();
|
|
308
|
+
console.error('WordPress API error response:', errorText);
|
|
309
|
+
// Try to parse error details
|
|
310
|
+
let errorDetails = errorText;
|
|
311
|
+
try {
|
|
312
|
+
const errorJson = JSON.parse(errorText);
|
|
313
|
+
errorDetails = errorJson.message || errorJson.code || errorText;
|
|
314
|
+
} catch (parseError) {
|
|
315
|
+
// Keep original error text if JSON parsing fails
|
|
316
|
+
}
|
|
317
|
+
return {
|
|
318
|
+
error: `Connection failed with status ${response.status}: ${errorDetails}`,
|
|
319
|
+
success: false
|
|
320
|
+
};
|
|
321
|
+
}
|
|
322
|
+
const userData = await response.json();
|
|
323
|
+
return {
|
|
324
|
+
data: {
|
|
325
|
+
capabilities: userData.capabilities,
|
|
326
|
+
siteInfo: {
|
|
327
|
+
name: userData.name || userData.display_name,
|
|
328
|
+
url: this.apiUrl
|
|
329
|
+
},
|
|
330
|
+
user: userData.name || userData.display_name
|
|
331
|
+
},
|
|
332
|
+
success: true
|
|
333
|
+
};
|
|
334
|
+
} catch (error) {
|
|
335
|
+
console.error('WordPress connection test error:', error);
|
|
336
|
+
return {
|
|
337
|
+
error: error instanceof Error ? error.message : 'Unknown error occurred',
|
|
338
|
+
success: false
|
|
339
|
+
};
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
// Getter for accessing the API URL
|
|
343
|
+
get wpApiUrl() {
|
|
344
|
+
return this.apiUrl;
|
|
345
|
+
}
|
|
346
|
+
// Getter for accessing the headers
|
|
347
|
+
get wpHeaders() {
|
|
348
|
+
return this.headers;
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
// =============================================================================
|
|
352
|
+
// LEGACY COMPATIBILITY EXPORTS
|
|
353
|
+
// =============================================================================
|
|
354
|
+
const getWordPressHeaders = (site)=>createWordPressHeaders(site);
|
|
355
|
+
const testWordPressConnection = async (wpApiUrl, wpUsername, wpPassword)=>{
|
|
356
|
+
const client = new WordPressClient({
|
|
357
|
+
wpPassword,
|
|
358
|
+
wpSiteUrl: wpApiUrl.replace('/wp-json/wp/v2', ''),
|
|
359
|
+
wpUsername
|
|
360
|
+
});
|
|
361
|
+
return client.testConnection();
|
|
362
|
+
};
|
|
363
|
+
|
|
364
|
+
export { WordPressClient, getWordPressHeaders, testWordPressConnection };
|
|
365
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sources":["../../../src/utils/wordpress/client.ts"],"sourcesContent":["/** WordPress REST API client for content discovery, pagination, and authentication. */\n\nimport type { ContentTypeInfo, WordPressApiResponse, WordPressCredentials } from '../types.js'\n\nimport { analyzeWordPressFields } from '../fields/analyzer.js'\nimport {\n constructWordPressApiUrl,\n createWordPressHeaders,\n getContentTypeEndpoint,\n getFieldAnalysisEndpoint,\n} from '../helpers/index.js'\n\n// =============================================================================\n// WORDPRESS CLIENT CLASS\n// =============================================================================\n\nexport class WordPressClient {\n private allowSelfSignedCerts: boolean\n private apiUrl: string\n private credentials: WordPressCredentials\n private headers: Record<string, string>\n private sslWarningShown = false\n\n constructor(credentials: WordPressCredentials, allowSelfSignedCerts: boolean = false) {\n this.credentials = credentials\n this.apiUrl = constructWordPressApiUrl(credentials.wpSiteUrl)\n this.headers = createWordPressHeaders(credentials)\n this.allowSelfSignedCerts = allowSelfSignedCerts\n }\n\n /**\n * Fetch with SSL certificate handling\n */\n private async fetchWithSSLHandling(url: string, options: RequestInit = {}): Promise<Response> {\n try {\n return await fetch(url, options)\n } catch (fetchError: any) {\n // If fetch fails due to SSL certificate issues and we allow self-signed certs\n if (\n this.allowSelfSignedCerts &&\n (fetchError.cause?.code === 'DEPTH_ZERO_SELF_SIGNED_CERT' ||\n fetchError.cause?.code === 'SELF_SIGNED_CERT_IN_CHAIN' ||\n fetchError.message?.includes('certificate'))\n ) {\n if (!this.sslWarningShown) {\n this.sslWarningShown = true\n if (process.env.NODE_ENV === 'production') {\n console.warn(\n 'WARNING: allowSelfSignedCerts is enabled in production. ' +\n 'This disables TLS certificate verification and is a security risk. ' +\n 'Consider using a valid SSL certificate instead.',\n )\n }\n }\n\n console.warn(\n `SSL certificate issue detected for ${url}. Attempting request with relaxed SSL verification (allowSelfSignedCerts=true).`,\n )\n\n // Create a custom fetch with relaxed SSL for this specific request\n const https = await import('https')\n const { default: fetch } = await import('node-fetch')\n\n const agent = new https.Agent({\n rejectUnauthorized: false, // Only for this specific request\n })\n\n // Extract only the compatible options for node-fetch\n const nodeOptions: any = {\n agent,\n body: options.body,\n headers: options.headers,\n method: options.method,\n }\n\n return (await fetch(url, nodeOptions)) as any\n } else {\n // Re-throw the original error with more context\n const errorMessage = fetchError.cause?.code\n ? `${fetchError.message} (${fetchError.cause.code})`\n : fetchError.message\n\n if (\n fetchError.cause?.code === 'DEPTH_ZERO_SELF_SIGNED_CERT' ||\n fetchError.cause?.code === 'SELF_SIGNED_CERT_IN_CHAIN'\n ) {\n throw new Error(\n `${errorMessage}. Consider setting allowSelfSignedCerts: true in plugin configuration for development environments.`,\n )\n }\n\n throw fetchError\n }\n }\n }\n\n /**\n * Discover available content types\n */\n async discoverContent(): Promise<\n WordPressApiResponse<{ contentTypes: ContentTypeInfo[]; siteInfo?: any; totalItems: number }>\n > {\n try {\n // Test connection first\n const testResult = await this.testConnection()\n if (!testResult.success) {\n return { success: false, error: testResult.error }\n }\n\n const contentTypes: ContentTypeInfo[] = []\n\n // Built-in content types to check\n const builtInTypes = [\n { type: 'posts', label: 'Posts' },\n { type: 'pages', label: 'Pages' },\n { type: 'media', label: 'Media' },\n { type: 'categories', label: 'Categories' },\n { type: 'users', label: 'Users' },\n ]\n\n // Check built-in content types\n for (const { type, label } of builtInTypes) {\n try {\n const endpoint = getContentTypeEndpoint(this.apiUrl, type)\n // Add context=edit for users to check private field access\n const contextParam = type === 'users' ? '&context=edit' : ''\n const response = await fetch(`${endpoint}?per_page=1${contextParam}`, {\n headers: this.headers,\n })\n\n if (response.ok) {\n const totalCount = parseInt(response.headers.get('X-WP-Total') || '0')\n if (totalCount > 0) {\n contentTypes.push({\n type,\n available: true,\n count: totalCount,\n label,\n })\n }\n }\n } catch (error) {\n console.error(`Failed to check ${type}:`, error)\n }\n }\n\n // Discover custom post types\n try {\n const typesResponse = await fetch(`${this.apiUrl}/types`, { headers: this.headers })\n if (typesResponse.ok) {\n const types = await typesResponse.json()\n for (const [typeKey, typeData] of Object.entries(types)) {\n const typeInfo = typeData as any\n // Skip built-in types we already checked\n if (!['attachment', 'page', 'post'].includes(typeKey) && typeInfo.rest_base) {\n try {\n const customResponse = await fetch(\n `${this.apiUrl}/${typeInfo.rest_base}?per_page=1`,\n {\n headers: this.headers,\n },\n )\n if (customResponse.ok) {\n const totalCustom = parseInt(customResponse.headers.get('X-WP-Total') || '0')\n if (totalCustom > 0) {\n contentTypes.push({\n type: typeKey,\n available: true,\n count: totalCustom,\n custom: true,\n label: typeInfo.name || typeKey,\n restBase: typeInfo.rest_base,\n })\n }\n }\n } catch (error) {\n console.warn(`Failed to check custom post type ${typeKey}:`, error)\n }\n }\n }\n }\n } catch (error) {\n console.warn('Failed to discover custom post types:', error)\n }\n\n const totalItems = contentTypes.reduce((sum, type) => sum + type.count, 0)\n\n return {\n data: {\n contentTypes,\n siteInfo: (testResult.data as Record<string, unknown>)?.siteInfo,\n totalItems,\n },\n success: true,\n }\n } catch (error) {\n console.error('Content discovery error:', error)\n const errorMessage =\n error instanceof Error ? error.message : `Unknown error occurred: ${String(error)}`\n\n return {\n error: errorMessage,\n success: false,\n }\n }\n }\n\n /**\n * Async generator that yields one page of results at a time.\n * Enables streaming processing without buffering all items in memory.\n */\n async *fetchPages(\n endpoint: string,\n options: {\n contentType?: string\n includeIds?: number[]\n onProgress?: (page: number, totalPages: number, itemCount: number) => void\n requestDelay?: number\n timeoutMs?: number\n } = {},\n ): AsyncGenerator<{ items: any[]; totalItems: number; totalPages: number }> {\n const { contentType, includeIds, onProgress, requestDelay = 0, timeoutMs = 30000 } = options\n let page = 1\n let hasMore = true\n let runningItemCount = 0\n\n const embedTypes = ['pages', 'posts']\n const embedParam = contentType && embedTypes.includes(contentType) ? '&_embed=1' : ''\n const contextParam = contentType === 'users' ? '&context=edit' : ''\n const yoastParam = contentType && embedTypes.includes(contentType) ? '&yoast_head=1' : ''\n const includeParam =\n includeIds && includeIds.length > 0 ? `&include=${includeIds.join(',')}` : ''\n\n while (hasMore) {\n const url = `${endpoint}?per_page=100&page=${page}${embedParam}${contextParam}${yoastParam}${includeParam}`\n\n const controller = new AbortController()\n const timeoutId = setTimeout(() => {\n controller.abort()\n }, timeoutMs)\n\n let response: Response\n try {\n response = await this.fetchWithSSLHandling(url, {\n headers: this.headers,\n signal: controller.signal,\n })\n } catch (fetchError: any) {\n clearTimeout(timeoutId)\n\n if (fetchError.name === 'AbortError') {\n throw new Error(\n `WordPress API request timed out after ${timeoutMs}ms. ` +\n `This may indicate that your production server cannot reach the WordPress site. ` +\n `Check: 1) WordPress site is accessible from production, 2) No firewall blocking, 3) WordPress site allows requests from your server IP.`,\n )\n }\n\n throw fetchError\n }\n\n clearTimeout(timeoutId)\n\n if (!response.ok) {\n if (page === 1) {\n throw new Error(\n `Failed to fetch from WordPress API (${response.status} ${response.statusText}). ` +\n `URL: ${endpoint}. This may indicate authentication issues or the WordPress site blocking the request.`,\n )\n }\n break\n }\n\n const items = await response.json()\n if (items.length === 0) {\n break\n }\n\n const totalPages = parseInt(response.headers.get('X-WP-TotalPages') || '1')\n const totalItems = parseInt(response.headers.get('X-WP-Total') || '0')\n hasMore = page < totalPages\n runningItemCount += items.length\n\n if (onProgress) {\n onProgress(page, totalPages, runningItemCount)\n }\n\n yield { items, totalItems, totalPages }\n\n page++\n\n // Rate limiting: delay between page requests\n if (hasMore && requestDelay > 0) {\n await new Promise((resolve) => setTimeout(resolve, requestDelay))\n }\n\n // Respect Retry-After header if present\n const retryAfter = response.headers.get('retry-after')\n if (hasMore && retryAfter) {\n const retryMs = parseInt(retryAfter) * 1000\n if (retryMs > 0) {\n await new Promise((resolve) => setTimeout(resolve, retryMs))\n }\n }\n }\n }\n\n /**\n * Fetch all pages of content with pagination (collects all items into memory).\n * For streaming processing, use fetchPages() instead.\n */\n async fetchAllPages(\n endpoint: string,\n onProgress?: (current: number, total: number, items: number) => void,\n contentType?: string,\n includeIds?: number[],\n timeoutMs: number = 30000,\n ): Promise<any[]> {\n const allItems: any[] = []\n\n for await (const { items } of this.fetchPages(endpoint, {\n contentType,\n includeIds,\n onProgress: onProgress\n ? (page, totalPages, count) => onProgress(page, totalPages, count)\n : undefined,\n timeoutMs,\n })) {\n allItems.push(...items)\n }\n\n return allItems\n }\n\n /**\n * Fetch content fields for analysis\n */\n async fetchContentFields(\n contentType: string,\n ): Promise<WordPressApiResponse<{ contentType: string; fields: any[] }>> {\n try {\n const endpoint = getFieldAnalysisEndpoint(this.apiUrl, contentType)\n const response = await fetch(endpoint, { headers: this.headers })\n\n if (!response.ok) {\n throw new Error(`WordPress API error: ${response.status} ${response.statusText}`)\n }\n\n const items = await response.json()\n\n if (!items || items.length === 0) {\n return {\n data: {\n contentType,\n fields: [],\n },\n success: true,\n }\n }\n\n // Analyze field structure from the sample item\n const sampleItem = items[0]\n const fields = analyzeWordPressFields(sampleItem, contentType)\n\n return {\n data: {\n contentType,\n fields,\n },\n success: true,\n }\n } catch (error) {\n return {\n error: error instanceof Error ? error.message : 'Failed to fetch WordPress content fields',\n success: false,\n }\n }\n }\n\n /**\n * Test WordPress connection\n */\n async testConnection(): Promise<WordPressApiResponse> {\n try {\n const response = await fetch(`${this.apiUrl}/users/me`, {\n headers: this.headers,\n })\n\n if (!response.ok) {\n const errorText = await response.text()\n console.error('WordPress API error response:', errorText)\n\n // Try to parse error details\n let errorDetails = errorText\n try {\n const errorJson = JSON.parse(errorText)\n errorDetails = errorJson.message || errorJson.code || errorText\n } catch (parseError) {\n // Keep original error text if JSON parsing fails\n }\n\n return {\n error: `Connection failed with status ${response.status}: ${errorDetails}`,\n success: false,\n }\n }\n\n const userData = await response.json()\n return {\n data: {\n capabilities: userData.capabilities,\n siteInfo: {\n name: userData.name || userData.display_name,\n url: this.apiUrl,\n },\n user: userData.name || userData.display_name,\n },\n success: true,\n }\n } catch (error) {\n console.error('WordPress connection test error:', error)\n return {\n error: error instanceof Error ? error.message : 'Unknown error occurred',\n success: false,\n }\n }\n }\n\n // Getter for accessing the API URL\n public get wpApiUrl(): string {\n return this.apiUrl\n }\n\n // Getter for accessing the headers\n public get wpHeaders(): Record<string, string> {\n return this.headers\n }\n}\n\n// =============================================================================\n// LEGACY COMPATIBILITY EXPORTS\n// =============================================================================\n\nexport const getWordPressHeaders = (site: any) => createWordPressHeaders(site)\n\nexport const testWordPressConnection = async (\n wpApiUrl: string,\n wpUsername: string,\n wpPassword: string,\n): Promise<{ data?: any; error?: string; success: boolean }> => {\n const client = new WordPressClient({\n wpPassword,\n wpSiteUrl: wpApiUrl.replace('/wp-json/wp/v2', ''),\n wpUsername,\n })\n return client.testConnection()\n}\n"],"names":["WordPressClient","credentials","allowSelfSignedCerts","sslWarningShown","apiUrl","constructWordPressApiUrl","wpSiteUrl","headers","createWordPressHeaders","fetchWithSSLHandling","url","options","fetch","fetchError","cause","code","message","includes","process","env","NODE_ENV","console","warn","https","default","agent","Agent","rejectUnauthorized","nodeOptions","body","method","errorMessage","Error","discoverContent","testResult","testConnection","success","error","contentTypes","builtInTypes","type","label","endpoint","getContentTypeEndpoint","contextParam","response","ok","totalCount","parseInt","get","push","available","count","typesResponse","types","json","typeKey","typeData","Object","entries","typeInfo","rest_base","customResponse","totalCustom","custom","name","restBase","totalItems","reduce","sum","data","siteInfo","String","fetchPages","contentType","includeIds","onProgress","requestDelay","timeoutMs","page","hasMore","runningItemCount","embedTypes","embedParam","yoastParam","includeParam","length","join","controller","AbortController","timeoutId","setTimeout","abort","signal","clearTimeout","status","statusText","items","totalPages","Promise","resolve","retryAfter","retryMs","fetchAllPages","allItems","undefined","fetchContentFields","getFieldAnalysisEndpoint","fields","sampleItem","analyzeWordPressFields","errorText","text","errorDetails","errorJson","JSON","parse","parseError","userData","capabilities","display_name","user","wpApiUrl","wpHeaders","getWordPressHeaders","site","testWordPressConnection","wpUsername","wpPassword","client","replace"],"mappings":";;;AAYA;AACA;AACA;AAEO,MAAMA,eAAAA,CAAAA;AAOX,IAAA,WAAA,CAAYC,WAAiC,EAAEC,oBAAAA,GAAgC,KAAK,CAAE;aAF9EC,eAAAA,GAAkB,KAAA;QAGxB,IAAI,CAACF,WAAW,GAAGA,WAAAA;AAC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CA,KAAAA,CAAAA;YAClD,OAAO;AACLA,gBAAAA,KAAAA,EAAOA,KAAAA,YAAiBL,KAAAA,GAAQK,KAAAA,CAAMrB,OAAO,GAAG,wBAAA;gBAChDoB,OAAAA,EAAS;AACX,aAAA;AACF,QAAA;AACF,IAAA;;AAGA,IAAA,IAAWsF,QAAAA,GAAmB;QAC5B,OAAO,IAAI,CAACtH,MAAM;AACpB,IAAA;;AAGA,IAAA,IAAWuH,SAAAA,GAAoC;QAC7C,OAAO,IAAI,CAACpH,OAAO;AACrB,IAAA;AACF;AAEA;AACA;AACA;AAEO,MAAMqH,mBAAAA,GAAsB,CAACC,IAAAA,GAAcrH,uBAAuBqH,IAAAA;AAElE,MAAMC,uBAAAA,GAA0B,OACrCJ,QAAAA,EACAK,UAAAA,EACAC,UAAAA,GAAAA;IAEA,MAAMC,MAAAA,GAAS,IAAIjI,eAAAA,CAAgB;AACjCgI,QAAAA,UAAAA;QACA1H,SAAAA,EAAWoH,QAAAA,CAASQ,OAAO,CAAC,gBAAA,EAAkB,EAAA,CAAA;AAC9CH,QAAAA;AACF,KAAA,CAAA;AACA,IAAA,OAAOE,OAAO9F,cAAc,EAAA;AAC9B;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** Consolidated entry point re-exporting all WordPress migrator API modules. */
|
|
2
|
+
export { applyFieldMapping, transformWordPressContent } from './content/index.js';
|
|
3
|
+
export { discoverWordPressContent, fetchPayloadCollectionFields, fetchWordPressContentFields, getMigrationSummaryData, migrationSummaryHandler, wordpressConnectionHandler, } from './endpoints/index.js';
|
|
4
|
+
export { analyzePayloadFields, analyzeWordPressFields } from './fields/index.js';
|
|
5
|
+
export { cleanEmptyTextNodes, convertHtmlToLexical, createSafeLexicalFallback, createSafeLexicalRoot, createSafeParagraph, parseGutenbergBlocks, } from './lexical/index.js';
|
|
6
|
+
export { checkMigrationFields, downloadWordPressMediaFile, extractContentMedia, extractFeaturedMedia, fetchFeaturedMediaById, importMediaFromUrl, importMediaItem, isMediaTypeAllowed, testMediaDownload, uploadMediaToPayload, } from './media/index.js';
|
|
7
|
+
export { migrationJobHandler } from './migration/index.js';
|
|
8
|
+
export type { AnalyzedField, ContentCache, ContentTypeInfo, FailedItemRecord, FieldMappingConfig, FileData, JobConfiguration, LexicalRoot, MediaMetadata, MediaUploadResult, MigrationJob, MigrationSummary, RegularContentResult, SiteConfig, WordPressApiResponse, WordPressClientConfig, WordPressCredentials, WordPressItem, } from './types.js';
|
|
9
|
+
export { isMediaUploadResult, MIGRATION_COLLECTION } from './types.js';
|
|
10
|
+
export { constructWordPressApiUrl, createErrorResponse, createSuccessResponse, createWordPressHeaders, getContentCache, getContentTypeEndpoint, getFieldAnalysisEndpoint, getNestedValue, invalidateMigrationCache, isCacheValid, parseRequestBody, requireMigrationAccess, setContentCache, setNestedValue, validateWordPressCredentials, } from './helpers/index.js';
|
|
11
|
+
export { getWordPressHeaders, testWordPressConnection, WordPressClient } from './wordpress/index.js';
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export { MIGRATION_COLLECTION, isMediaUploadResult } from './types.js';
|
|
2
|
+
import { wordpressConnectionHandler, migrationSummaryHandler, discoverWordPressContent, fetchWordPressContentFields, fetchPayloadCollectionFields } from './endpoints/handlers.js';
|
|
3
|
+
export { getMigrationSummaryData } from './endpoints/handlers.js';
|
|
4
|
+
import { migrationJobHandler } from './migration/jobCrud.js';
|
|
5
|
+
export { WordPressClient, getWordPressHeaders, testWordPressConnection } from './wordpress/client.js';
|
|
6
|
+
export { analyzePayloadFields, analyzeWordPressFields } from './fields/analyzer.js';
|
|
7
|
+
export { applyFieldMapping } from './content/fieldMapping.js';
|
|
8
|
+
export { checkMigrationFields, isMediaTypeAllowed, testMediaDownload } from './media/validation.js';
|
|
9
|
+
export { cleanEmptyTextNodes, createSafeLexicalFallback, createSafeLexicalRoot, createSafeParagraph } from './lexical/nodeFactories.js';
|
|
10
|
+
export { constructWordPressApiUrl, createWordPressHeaders, getContentTypeEndpoint, getFieldAnalysisEndpoint } from './helpers/wpHelpers.js';
|
|
11
|
+
export { convertHtmlToLexical, parseGutenbergBlocks } from './lexical/preprocessor.js';
|
|
12
|
+
export { createErrorResponse, createSuccessResponse } from './helpers/responses.js';
|
|
13
|
+
export { downloadWordPressMediaFile } from './media/download.js';
|
|
14
|
+
export { extractContentMedia, extractFeaturedMedia, fetchFeaturedMediaById } from './media/extraction.js';
|
|
15
|
+
export { getContentCache, invalidateMigrationCache, isCacheValid, setContentCache } from './helpers/cache.js';
|
|
16
|
+
export { getNestedValue, setNestedValue } from './helpers/objectHelpers.js';
|
|
17
|
+
export { importMediaFromUrl, importMediaItem } from './media/import.js';
|
|
18
|
+
export { parseRequestBody, requireMigrationAccess, validateWordPressCredentials } from './helpers/auth.js';
|
|
19
|
+
export { transformWordPressContent } from './content/transformer.js';
|
|
20
|
+
export { uploadMediaToPayload } from './media/upload.js';
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
export { discoverWordPressContent, fetchPayloadCollectionFields, fetchWordPressContentFields, migrationJobHandler, migrationSummaryHandler, wordpressConnectionHandler };
|
|
25
|
+
//# sourceMappingURL=wordpressApi.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wordpressApi.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;"}
|
package/package.json
ADDED
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "payload-wordpress-migrator",
|
|
3
|
+
"version": "0.0.22",
|
|
4
|
+
"description": "A PayloadCMS plugin for WordPress migration - migrate and manage WordPress content directly in your Payload admin dashboard",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"keywords": [
|
|
8
|
+
"payload",
|
|
9
|
+
"payloadcms",
|
|
10
|
+
"wordpress",
|
|
11
|
+
"migration",
|
|
12
|
+
"content",
|
|
13
|
+
"plugin",
|
|
14
|
+
"cms"
|
|
15
|
+
],
|
|
16
|
+
"author": {
|
|
17
|
+
"name": "Igor Abdulovic",
|
|
18
|
+
"email": "igor.abdulovic@brightscout.com",
|
|
19
|
+
"url": "https://brightscout.com"
|
|
20
|
+
},
|
|
21
|
+
"repository": {
|
|
22
|
+
"type": "git",
|
|
23
|
+
"url": "https://github.com/Brightscout/payload-wordpress-migrator"
|
|
24
|
+
},
|
|
25
|
+
"bugs": {
|
|
26
|
+
"url": "https://github.com/Brightscout/payload-wordpress-migrator/issues"
|
|
27
|
+
},
|
|
28
|
+
"homepage": "https://github.com/Brightscout/payload-wordpress-migrator#readme",
|
|
29
|
+
"exports": {
|
|
30
|
+
".": {
|
|
31
|
+
"import": "./dist/index.js",
|
|
32
|
+
"require": "./dist/index.js",
|
|
33
|
+
"types": "./dist/index.d.ts",
|
|
34
|
+
"default": "./dist/index.js"
|
|
35
|
+
},
|
|
36
|
+
"./client": {
|
|
37
|
+
"import": "./dist/exports/client.js",
|
|
38
|
+
"require": "./dist/exports/client.js",
|
|
39
|
+
"types": "./dist/exports/client.d.ts",
|
|
40
|
+
"default": "./dist/exports/client.js"
|
|
41
|
+
},
|
|
42
|
+
"./rsc": {
|
|
43
|
+
"import": "./dist/exports/rsc.js",
|
|
44
|
+
"require": "./dist/exports/rsc.js",
|
|
45
|
+
"types": "./dist/exports/rsc.d.ts",
|
|
46
|
+
"default": "./dist/exports/rsc.js"
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
"main": "dist/index.js",
|
|
50
|
+
"types": "dist/index.d.ts",
|
|
51
|
+
"files": [
|
|
52
|
+
"dist"
|
|
53
|
+
],
|
|
54
|
+
"scripts": {
|
|
55
|
+
"build": "pnpm clean && rollup -c rollup.config.js && pnpm build:types",
|
|
56
|
+
"build:types": "tsc --emitDeclarationOnly --declaration --declarationDir dist",
|
|
57
|
+
"clean": "rimraf {dist,*.tsbuildinfo}",
|
|
58
|
+
"dev": "payload run ./dev/server.ts",
|
|
59
|
+
"dev:generate-importmap": "pnpm dev:payload generate:importmap",
|
|
60
|
+
"dev:generate-types": "pnpm dev:payload generate:types",
|
|
61
|
+
"dev:payload": "cross-env PAYLOAD_CONFIG_PATH=./dev/payload.config.ts payload",
|
|
62
|
+
"lint": "eslint",
|
|
63
|
+
"lint:fix": "eslint ./src --fix",
|
|
64
|
+
"prepublishOnly": "pnpm build",
|
|
65
|
+
"test": "jest"
|
|
66
|
+
},
|
|
67
|
+
"devDependencies": {
|
|
68
|
+
"@eslint/eslintrc": "^3.3.5",
|
|
69
|
+
"@payloadcms/db-mongodb": "3.81.0",
|
|
70
|
+
"@payloadcms/db-postgres": "3.81.0",
|
|
71
|
+
"@payloadcms/db-sqlite": "3.81.0",
|
|
72
|
+
"@payloadcms/eslint-config": "3.28.0",
|
|
73
|
+
"@payloadcms/next": "3.81.0",
|
|
74
|
+
"@payloadcms/richtext-lexical": "3.81.0",
|
|
75
|
+
"@payloadcms/ui": "3.81.0",
|
|
76
|
+
"@rollup/plugin-json": "^6.1.0",
|
|
77
|
+
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
78
|
+
"@rollup/plugin-swc": "^0.4.0",
|
|
79
|
+
"@swc-node/register": "1.11.1",
|
|
80
|
+
"@swc/cli": "0.8.1",
|
|
81
|
+
"@swc/jest": "^0.2.39",
|
|
82
|
+
"@testing-library/jest-dom": "^6.9.1",
|
|
83
|
+
"@testing-library/react": "^16.3.2",
|
|
84
|
+
"@testing-library/user-event": "^14.6.1",
|
|
85
|
+
"@types/jest": "30.0.0",
|
|
86
|
+
"@types/node": "^25.5.2",
|
|
87
|
+
"@types/node-fetch": "^2.6.13",
|
|
88
|
+
"@types/react": "19.2.14",
|
|
89
|
+
"@types/react-dom": "19.2.3",
|
|
90
|
+
"copyfiles": "2.4.1",
|
|
91
|
+
"cross-env": "^10.1.0",
|
|
92
|
+
"dotenv": "^17.4.1",
|
|
93
|
+
"eslint": "^10.2.0",
|
|
94
|
+
"eslint-config-next": "16.2.2",
|
|
95
|
+
"glob": "^13.0.6",
|
|
96
|
+
"graphql": "^16.13.2",
|
|
97
|
+
"jest": "30.3.0",
|
|
98
|
+
"jest-environment-jsdom": "^30.3.0",
|
|
99
|
+
"mongodb-memory-server": "^11.0.1",
|
|
100
|
+
"next": "16.2.2",
|
|
101
|
+
"open": "^11.0.0",
|
|
102
|
+
"payload": "3.81.0",
|
|
103
|
+
"prettier": "^3.8.1",
|
|
104
|
+
"qs-esm": "8.0.1",
|
|
105
|
+
"react": "19.2.4",
|
|
106
|
+
"react-dom": "19.2.4",
|
|
107
|
+
"rimraf": "6.1.3",
|
|
108
|
+
"rollup": "^4.60.1",
|
|
109
|
+
"rollup-plugin-preserve-directives": "^0.4.0",
|
|
110
|
+
"sharp": "0.34.5",
|
|
111
|
+
"sort-package-json": "^3.6.1",
|
|
112
|
+
"typescript": "6.0.2"
|
|
113
|
+
},
|
|
114
|
+
"peerDependencies": {
|
|
115
|
+
"@payloadcms/ui": "^3.29.0",
|
|
116
|
+
"next": ">=15.0.0",
|
|
117
|
+
"payload": "^3.29.0",
|
|
118
|
+
"react": "^18.0.0 || ^19.0.0",
|
|
119
|
+
"react-dom": "^18.0.0 || ^19.0.0"
|
|
120
|
+
},
|
|
121
|
+
"engines": {
|
|
122
|
+
"node": "^18.20.2 || >=20.9.0",
|
|
123
|
+
"pnpm": "^9 || ^10"
|
|
124
|
+
},
|
|
125
|
+
"publishConfig": {
|
|
126
|
+
"exports": {
|
|
127
|
+
".": {
|
|
128
|
+
"import": "./dist/index.js",
|
|
129
|
+
"types": "./dist/index.d.ts",
|
|
130
|
+
"default": "./dist/index.js"
|
|
131
|
+
},
|
|
132
|
+
"./client": {
|
|
133
|
+
"import": "./dist/exports/client.js",
|
|
134
|
+
"types": "./dist/exports/client.d.ts",
|
|
135
|
+
"default": "./dist/exports/client.js"
|
|
136
|
+
},
|
|
137
|
+
"./rsc": {
|
|
138
|
+
"import": "./dist/exports/rsc.js",
|
|
139
|
+
"types": "./dist/exports/rsc.d.ts",
|
|
140
|
+
"default": "./dist/exports/rsc.js"
|
|
141
|
+
}
|
|
142
|
+
},
|
|
143
|
+
"main": "./dist/index.js",
|
|
144
|
+
"types": "./dist/index.d.ts"
|
|
145
|
+
},
|
|
146
|
+
"pnpm": {
|
|
147
|
+
"onlyBuiltDependencies": [
|
|
148
|
+
"sharp"
|
|
149
|
+
]
|
|
150
|
+
},
|
|
151
|
+
"registry": "https://registry.npmjs.org/",
|
|
152
|
+
"dependencies": {
|
|
153
|
+
"node-fetch": "^3.3.2"
|
|
154
|
+
}
|
|
155
|
+
}
|