@marvalt/wadapter 2.3.10 → 2.3.13
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/dist/client/wordpress-client.d.ts +40 -0
- package/dist/client/wordpress-client.d.ts.map +1 -1
- package/dist/generators/wordpress/wordpress-generator.d.ts.map +1 -1
- package/dist/generators.cjs +122 -15
- package/dist/generators.cjs.map +1 -1
- package/dist/generators.esm.js +122 -15
- package/dist/generators.esm.js.map +1 -1
- package/dist/index.d.ts +40 -0
- package/dist/index.esm.js +99 -5
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +99 -5
- package/dist/index.js.map +1 -1
- package/dist/react/components/GravityForm.d.ts.map +1 -1
- package/dist/react/hooks/useGravityForms.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -111,29 +111,102 @@ class WordPressClient {
|
|
|
111
111
|
return this.config.apiUrl || '';
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
|
+
/**
|
|
115
|
+
* Fetch posts with automatic pagination support
|
|
116
|
+
* @param params Query parameters including per_page for total items to fetch
|
|
117
|
+
* @returns All posts up to the limit, fetched across multiple pages if needed
|
|
118
|
+
*/
|
|
114
119
|
async getPosts(params = {}) {
|
|
115
|
-
return this.
|
|
120
|
+
return this.fetchPaginated('/wp/v2/posts', params);
|
|
116
121
|
}
|
|
117
122
|
async getPost(id) {
|
|
118
123
|
return this.makeRequest(`/wp/v2/posts/${id}`);
|
|
119
124
|
}
|
|
125
|
+
/**
|
|
126
|
+
* Fetch pages with automatic pagination support
|
|
127
|
+
* @param params Query parameters including per_page for total items to fetch
|
|
128
|
+
* @returns All pages up to the limit, fetched across multiple pages if needed
|
|
129
|
+
*/
|
|
120
130
|
async getPages(params = {}) {
|
|
121
|
-
return this.
|
|
131
|
+
return this.fetchPaginated('/wp/v2/pages', params);
|
|
122
132
|
}
|
|
123
133
|
async getPage(id) {
|
|
124
134
|
return this.makeRequest(`/wp/v2/pages/${id}`);
|
|
125
135
|
}
|
|
136
|
+
/**
|
|
137
|
+
* Fetch media with automatic pagination support
|
|
138
|
+
* @param params Query parameters including per_page for total items to fetch
|
|
139
|
+
* @returns All media items up to the limit, fetched across multiple pages if needed
|
|
140
|
+
*/
|
|
126
141
|
async getMedia(params = {}) {
|
|
127
|
-
return this.
|
|
142
|
+
return this.fetchPaginated('/wp/v2/media', params);
|
|
128
143
|
}
|
|
129
144
|
async getMediaItem(id) {
|
|
130
145
|
return this.makeRequest(`/wp/v2/media/${id}`);
|
|
131
146
|
}
|
|
147
|
+
/**
|
|
148
|
+
* Fetch categories with automatic pagination support
|
|
149
|
+
* @param params Query parameters including per_page for total items to fetch
|
|
150
|
+
* @returns All categories up to the limit, fetched across multiple pages if needed
|
|
151
|
+
*/
|
|
132
152
|
async getCategories(params = {}) {
|
|
133
|
-
return this.
|
|
153
|
+
return this.fetchPaginated('/wp/v2/categories', params);
|
|
134
154
|
}
|
|
155
|
+
/**
|
|
156
|
+
* Fetch tags with automatic pagination support
|
|
157
|
+
* @param params Query parameters including per_page for total items to fetch
|
|
158
|
+
* @returns All tags up to the limit, fetched across multiple pages if needed
|
|
159
|
+
*/
|
|
135
160
|
async getTags(params = {}) {
|
|
136
|
-
return this.
|
|
161
|
+
return this.fetchPaginated('/wp/v2/tags', params);
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Fetch data with automatic pagination
|
|
165
|
+
* Handles fetching all items up to the requested limit by making multiple API calls if needed
|
|
166
|
+
* @param endpoint The API endpoint to fetch from
|
|
167
|
+
* @param params Query parameters including per_page for total items to fetch
|
|
168
|
+
* @returns Array of all items fetched across all pages
|
|
169
|
+
*/
|
|
170
|
+
async fetchPaginated(endpoint, params = {}) {
|
|
171
|
+
const requestedTotal = params.per_page || 100;
|
|
172
|
+
const itemsPerPage = Math.min(requestedTotal, 100); // WordPress max is typically 100
|
|
173
|
+
const maxPages = Math.ceil(requestedTotal / itemsPerPage);
|
|
174
|
+
let allItems = [];
|
|
175
|
+
let currentPage = 1;
|
|
176
|
+
let hasMorePages = true;
|
|
177
|
+
console.log(`🔄 Fetching ${endpoint} with pagination: ${requestedTotal} items requested (${maxPages} pages of ${itemsPerPage})`);
|
|
178
|
+
while (hasMorePages && currentPage <= maxPages && allItems.length < requestedTotal) {
|
|
179
|
+
const pageParams = {
|
|
180
|
+
...params,
|
|
181
|
+
per_page: itemsPerPage,
|
|
182
|
+
page: currentPage,
|
|
183
|
+
};
|
|
184
|
+
console.log(`📄 Fetching page ${currentPage}/${maxPages} for ${endpoint}...`);
|
|
185
|
+
try {
|
|
186
|
+
const pageData = await this.makeRequest(endpoint, pageParams);
|
|
187
|
+
if (!pageData || pageData.length === 0) {
|
|
188
|
+
console.log(`✓ No more data on page ${currentPage}, stopping pagination`);
|
|
189
|
+
hasMorePages = false;
|
|
190
|
+
break;
|
|
191
|
+
}
|
|
192
|
+
allItems = allItems.concat(pageData);
|
|
193
|
+
console.log(`✓ Page ${currentPage}: fetched ${pageData.length} items (total: ${allItems.length})`);
|
|
194
|
+
// Stop if we got fewer items than requested per page (last page)
|
|
195
|
+
if (pageData.length < itemsPerPage) {
|
|
196
|
+
console.log(`✓ Reached last page (partial results)`);
|
|
197
|
+
hasMorePages = false;
|
|
198
|
+
}
|
|
199
|
+
currentPage++;
|
|
200
|
+
}
|
|
201
|
+
catch (error) {
|
|
202
|
+
console.error(`❌ Error fetching page ${currentPage}:`, error);
|
|
203
|
+
// Stop pagination on error but return what we have so far
|
|
204
|
+
hasMorePages = false;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
console.log(`✅ Pagination complete for ${endpoint}: ${allItems.length} total items fetched`);
|
|
208
|
+
// Trim to exact requested amount if we fetched more
|
|
209
|
+
return allItems.slice(0, requestedTotal);
|
|
137
210
|
}
|
|
138
211
|
// Gravity Forms endpoints
|
|
139
212
|
async getGravityForms() {
|
|
@@ -152,6 +225,15 @@ class WordPressClient {
|
|
|
152
225
|
async getStaticDataNonce() {
|
|
153
226
|
return this.makeRequest('/static-data/v1/nonce');
|
|
154
227
|
}
|
|
228
|
+
/**
|
|
229
|
+
* Fetch a custom post type with automatic pagination support
|
|
230
|
+
* @param postType The custom post type slug (e.g., 'chapter-member', 'events')
|
|
231
|
+
* @param params Query parameters including per_page for total items to fetch
|
|
232
|
+
* @returns All items of the custom post type up to the limit
|
|
233
|
+
*/
|
|
234
|
+
async getCustomPostType(postType, params = {}) {
|
|
235
|
+
return this.fetchPaginated(`/wp/v2/${postType}`, params);
|
|
236
|
+
}
|
|
155
237
|
async getAllData(params = {}) {
|
|
156
238
|
const [posts, pages, media, categories, tags] = await Promise.all([
|
|
157
239
|
this.getPosts(params),
|
|
@@ -519,6 +601,11 @@ function useGravityForms(formId, config) {
|
|
|
519
601
|
setError(new Error('Gravity Forms configuration is required'));
|
|
520
602
|
return;
|
|
521
603
|
}
|
|
604
|
+
console.log('🔍 useGravityForms.submitForm called:', {
|
|
605
|
+
formId,
|
|
606
|
+
submission,
|
|
607
|
+
submission_field_values: submission?.field_values,
|
|
608
|
+
});
|
|
522
609
|
try {
|
|
523
610
|
setSubmitting(true);
|
|
524
611
|
setError(null);
|
|
@@ -2035,6 +2122,12 @@ const GravityForm = ({ formId, config, className = '', onSubmit, onError, }) =>
|
|
|
2035
2122
|
setTurnstileError('Please complete the verification');
|
|
2036
2123
|
return;
|
|
2037
2124
|
}
|
|
2125
|
+
console.log('🔍 GravityForm.handleSubmit:', {
|
|
2126
|
+
formId,
|
|
2127
|
+
formData,
|
|
2128
|
+
formDataKeys: Object.keys(formData),
|
|
2129
|
+
turnstileToken,
|
|
2130
|
+
});
|
|
2038
2131
|
try {
|
|
2039
2132
|
const submission = {
|
|
2040
2133
|
form_id: formId,
|
|
@@ -2045,6 +2138,7 @@ const GravityForm = ({ formId, config, className = '', onSubmit, onError, }) =>
|
|
|
2045
2138
|
}
|
|
2046
2139
|
} : {})
|
|
2047
2140
|
};
|
|
2141
|
+
console.log('🔍 GravityForm submission object:', submission);
|
|
2048
2142
|
await submitForm(submission);
|
|
2049
2143
|
if (onSubmit && result) {
|
|
2050
2144
|
onSubmit(result);
|