@marvalt/wadapter 1.1.12 → 2.0.1
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 +67 -139
- package/dist/client/wordpress-client.d.ts.map +1 -1
- package/dist/generators/gravity-forms/gravity-forms-generator.d.ts +3 -3
- package/dist/generators/gravity-forms/gravity-forms-generator.d.ts.map +1 -1
- package/dist/generators/wordpress/wordpress-generator.d.ts.map +1 -1
- package/dist/gravity-forms/gravity-forms-client.d.ts.map +1 -1
- package/dist/index.d.ts +70 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +335 -32
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +346 -31
- package/dist/index.js.map +1 -1
- package/dist/static/gravity-forms-static.d.ts +28 -0
- package/dist/static/gravity-forms-static.d.ts.map +1 -0
- package/dist/static/wordpress-static.d.ts +33 -0
- package/dist/static/wordpress-static.d.ts.map +1 -0
- package/dist/types/gravity-forms.d.ts +1 -3
- package/dist/types/gravity-forms.d.ts.map +1 -1
- package/dist/types/wordpress.d.ts +3 -3
- package/dist/types/wordpress.d.ts.map +1 -1
- package/dist/utils/config.d.ts.map +1 -1
- package/package.json +5 -1
package/dist/index.js
CHANGED
|
@@ -39,7 +39,7 @@ class WordPressClient {
|
|
|
39
39
|
});
|
|
40
40
|
// Construct URL based on auth mode
|
|
41
41
|
let url;
|
|
42
|
-
if (this.config.authMode === 'cloudflare_proxy'
|
|
42
|
+
if (this.config.authMode === 'cloudflare_proxy') {
|
|
43
43
|
// For proxy modes, pass the full REST path including /wp-json as query parameter
|
|
44
44
|
const fullEndpoint = `/wp-json${endpoint}?${queryString.toString()}`;
|
|
45
45
|
url = `${baseUrl}?endpoint=${encodeURIComponent(fullEndpoint)}`;
|
|
@@ -65,12 +65,6 @@ class WordPressClient {
|
|
|
65
65
|
headers['CF-Access-Client-Secret'] = this.config.cfAccessClientSecret;
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
|
-
else if (this.config.authMode === 'supabase_proxy') {
|
|
69
|
-
// Add Supabase proxy authentication headers
|
|
70
|
-
if (this.config.supabaseAnonKey) {
|
|
71
|
-
headers['apikey'] = this.config.supabaseAnonKey;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
68
|
else {
|
|
75
69
|
// Direct mode - use basic auth
|
|
76
70
|
if (this.config.username && this.config.password) {
|
|
@@ -126,8 +120,6 @@ class WordPressClient {
|
|
|
126
120
|
switch (this.config.authMode) {
|
|
127
121
|
case 'cloudflare_proxy':
|
|
128
122
|
return this.config.cloudflareWorkerUrl || '';
|
|
129
|
-
case 'supabase_proxy':
|
|
130
|
-
return `${this.config.supabaseUrl}/functions/v1/wp-proxy`;
|
|
131
123
|
default:
|
|
132
124
|
return this.config.apiUrl || '';
|
|
133
125
|
}
|
|
@@ -291,7 +283,7 @@ class GravityFormsClient {
|
|
|
291
283
|
async makeRequest(endpoint, options = {}) {
|
|
292
284
|
// Construct URL based on auth mode
|
|
293
285
|
let url;
|
|
294
|
-
if (this.config.authMode === 'cloudflare_proxy'
|
|
286
|
+
if (this.config.authMode === 'cloudflare_proxy') {
|
|
295
287
|
// For proxy modes, pass the full REST path including /wp-json as query parameter
|
|
296
288
|
const baseUrl = this.getBaseUrl();
|
|
297
289
|
const fullEndpoint = `/wp-json${endpoint}`;
|
|
@@ -319,12 +311,6 @@ class GravityFormsClient {
|
|
|
319
311
|
headers['CF-Access-Client-Secret'] = this.config.cfAccessClientSecret;
|
|
320
312
|
}
|
|
321
313
|
}
|
|
322
|
-
else if (this.config.authMode === 'supabase_proxy') {
|
|
323
|
-
// Add Supabase proxy authentication headers
|
|
324
|
-
if (this.config.supabaseAnonKey) {
|
|
325
|
-
headers['apikey'] = this.config.supabaseAnonKey;
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
314
|
else {
|
|
329
315
|
// Direct mode - use basic auth
|
|
330
316
|
if (this.config.username && this.config.password) {
|
|
@@ -359,29 +345,43 @@ class GravityFormsClient {
|
|
|
359
345
|
switch (this.config.authMode) {
|
|
360
346
|
case 'cloudflare_proxy':
|
|
361
347
|
return this.config.cloudflareWorkerUrl || '';
|
|
362
|
-
case 'supabase_proxy':
|
|
363
|
-
return `${this.config.supabaseUrl}/functions/v1/wp-proxy`;
|
|
364
348
|
default:
|
|
365
349
|
return this.config.apiUrl || '';
|
|
366
350
|
}
|
|
367
351
|
}
|
|
368
352
|
async getForm(id) {
|
|
369
|
-
|
|
353
|
+
// proxy: use enhanced gf-api/v1; direct: use official GF REST v2 (under /wp-json)
|
|
354
|
+
const endpoint = this.config.authMode === 'cloudflare_proxy'
|
|
355
|
+
? `/gf-api/v1/forms/${id}`
|
|
356
|
+
: `/wp-json/gf/v2/forms/${id}`;
|
|
357
|
+
return this.makeRequest(endpoint);
|
|
370
358
|
}
|
|
371
359
|
async getForms() {
|
|
372
|
-
|
|
360
|
+
const endpoint = this.config.authMode === 'cloudflare_proxy'
|
|
361
|
+
? '/gf-api/v1/forms'
|
|
362
|
+
: '/wp-json/gf/v2/forms';
|
|
363
|
+
return this.makeRequest(endpoint);
|
|
373
364
|
}
|
|
374
365
|
async getFormConfig(id) {
|
|
375
|
-
|
|
366
|
+
const endpoint = this.config.authMode === 'cloudflare_proxy'
|
|
367
|
+
? `/gf-api/v1/forms/${id}/config`
|
|
368
|
+
: `/wp-json/gf/v2/forms/${id}`; // v2 returns full form including settings
|
|
369
|
+
return this.makeRequest(endpoint);
|
|
376
370
|
}
|
|
377
371
|
async submitForm(formId, submission) {
|
|
378
|
-
|
|
372
|
+
const endpoint = this.config.authMode === 'cloudflare_proxy'
|
|
373
|
+
? `/gf-api/v1/forms/${formId}/submit`
|
|
374
|
+
: `/wp-json/gf/v2/forms/${formId}/submissions`; // official GF REST v2 submissions
|
|
375
|
+
return this.makeRequest(endpoint, {
|
|
379
376
|
method: 'POST',
|
|
380
377
|
body: JSON.stringify(submission),
|
|
381
378
|
});
|
|
382
379
|
}
|
|
383
380
|
async getHealth() {
|
|
384
|
-
|
|
381
|
+
const endpoint = this.config.authMode === 'cloudflare_proxy'
|
|
382
|
+
? '/gf-api/v1/health'
|
|
383
|
+
: '/wp-json/gf/v2/health';
|
|
384
|
+
return this.makeRequest(endpoint);
|
|
385
385
|
}
|
|
386
386
|
}
|
|
387
387
|
|
|
@@ -2011,6 +2011,301 @@ function useGravityFormsContext() {
|
|
|
2011
2011
|
return context;
|
|
2012
2012
|
}
|
|
2013
2013
|
|
|
2014
|
+
/**
|
|
2015
|
+
* @license GPL-3.0-or-later
|
|
2016
|
+
*
|
|
2017
|
+
* This file is part of the MarVAlt Open SDK.
|
|
2018
|
+
* Copyright (c) 2025 Vibune Pty Ltd.
|
|
2019
|
+
*
|
|
2020
|
+
* This program is free software: you can redistribute it and/or modify
|
|
2021
|
+
* it under the terms of the GNU General Public License as published by
|
|
2022
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
2023
|
+
* (at your option) any later version.
|
|
2024
|
+
*
|
|
2025
|
+
* This program is distributed in the hope that it will be useful,
|
|
2026
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
2027
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
2028
|
+
* See the GNU General Public License for more details.
|
|
2029
|
+
*/
|
|
2030
|
+
let wordpressStaticData = null;
|
|
2031
|
+
async function loadWordPressData(path = '/wordpress-data.json') {
|
|
2032
|
+
try {
|
|
2033
|
+
const res = await fetch(path);
|
|
2034
|
+
if (!res.ok)
|
|
2035
|
+
return null;
|
|
2036
|
+
wordpressStaticData = (await res.json());
|
|
2037
|
+
return wordpressStaticData;
|
|
2038
|
+
}
|
|
2039
|
+
catch {
|
|
2040
|
+
return null;
|
|
2041
|
+
}
|
|
2042
|
+
}
|
|
2043
|
+
function hasWordPressStatic() {
|
|
2044
|
+
return !!wordpressStaticData && Array.isArray(wordpressStaticData.posts);
|
|
2045
|
+
}
|
|
2046
|
+
function getWordPressPosts() {
|
|
2047
|
+
return wordpressStaticData?.posts ?? [];
|
|
2048
|
+
}
|
|
2049
|
+
function getWordPressPages() {
|
|
2050
|
+
return wordpressStaticData?.pages ?? [];
|
|
2051
|
+
}
|
|
2052
|
+
function getWordPressMedia() {
|
|
2053
|
+
return wordpressStaticData?.media ?? [];
|
|
2054
|
+
}
|
|
2055
|
+
function getWordPressCategories() {
|
|
2056
|
+
return wordpressStaticData?.categories ?? [];
|
|
2057
|
+
}
|
|
2058
|
+
function getWordPressTags() {
|
|
2059
|
+
return wordpressStaticData?.tags ?? [];
|
|
2060
|
+
}
|
|
2061
|
+
|
|
2062
|
+
/**
|
|
2063
|
+
* @license GPL-3.0-or-later
|
|
2064
|
+
*
|
|
2065
|
+
* This file is part of the MarVAlt Open SDK.
|
|
2066
|
+
* Copyright (c) 2025 Vibune Pty Ltd.
|
|
2067
|
+
*
|
|
2068
|
+
* This program is free software: you can redistribute it and/or modify
|
|
2069
|
+
* it under the terms of the GNU General Public License as published by
|
|
2070
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
2071
|
+
* (at your option) any later version.
|
|
2072
|
+
*
|
|
2073
|
+
* This program is distributed in the hope that it will be useful,
|
|
2074
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
2075
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
2076
|
+
* See the GNU General Public License for more details.
|
|
2077
|
+
*/
|
|
2078
|
+
let gravityFormsStaticData = null;
|
|
2079
|
+
async function loadGravityFormsData(path = '/gravityForms.json') {
|
|
2080
|
+
try {
|
|
2081
|
+
const res = await fetch(path);
|
|
2082
|
+
if (!res.ok)
|
|
2083
|
+
return null;
|
|
2084
|
+
const json = await res.json();
|
|
2085
|
+
gravityFormsStaticData = {
|
|
2086
|
+
generated_at: json.generated_at,
|
|
2087
|
+
total_forms: json.total_forms,
|
|
2088
|
+
forms: (json.forms ?? []),
|
|
2089
|
+
};
|
|
2090
|
+
return gravityFormsStaticData;
|
|
2091
|
+
}
|
|
2092
|
+
catch {
|
|
2093
|
+
return null;
|
|
2094
|
+
}
|
|
2095
|
+
}
|
|
2096
|
+
function hasGravityFormsStatic() {
|
|
2097
|
+
return !!gravityFormsStaticData && Array.isArray(gravityFormsStaticData.forms);
|
|
2098
|
+
}
|
|
2099
|
+
function getActiveForms() {
|
|
2100
|
+
return (gravityFormsStaticData?.forms ?? []).filter(f => f.is_active === true || f.isActive === true);
|
|
2101
|
+
}
|
|
2102
|
+
function getPublishedForms() {
|
|
2103
|
+
return (gravityFormsStaticData?.forms ?? []).filter(f => f.is_trash === false || f.isPublished === true);
|
|
2104
|
+
}
|
|
2105
|
+
function getFormById(id) {
|
|
2106
|
+
const key = String(id);
|
|
2107
|
+
return (gravityFormsStaticData?.forms ?? []).find(f => String(f.id) === key);
|
|
2108
|
+
}
|
|
2109
|
+
|
|
2110
|
+
let document;
|
|
2111
|
+
let offset;
|
|
2112
|
+
let output;
|
|
2113
|
+
let stack;
|
|
2114
|
+
const tokenizer = /<!--\s+(\/)?wp:([a-z][a-z0-9_-]*\/)?([a-z][a-z0-9_-]*)\s+({(?:(?=([^}]+|}+(?=})|(?!}\s+\/?-->)[^])*)\5|[^]*?)}\s+)?(\/)?-->/g;
|
|
2115
|
+
function Block(blockName, attrs, innerBlocks, innerHTML, innerContent) {
|
|
2116
|
+
return {
|
|
2117
|
+
blockName,
|
|
2118
|
+
attrs,
|
|
2119
|
+
innerBlocks,
|
|
2120
|
+
innerHTML,
|
|
2121
|
+
innerContent
|
|
2122
|
+
};
|
|
2123
|
+
}
|
|
2124
|
+
function Freeform(innerHTML) {
|
|
2125
|
+
return Block(null, {}, [], innerHTML, [innerHTML]);
|
|
2126
|
+
}
|
|
2127
|
+
function Frame(block, tokenStart, tokenLength, prevOffset, leadingHtmlStart) {
|
|
2128
|
+
return {
|
|
2129
|
+
block,
|
|
2130
|
+
tokenStart,
|
|
2131
|
+
tokenLength,
|
|
2132
|
+
prevOffset: prevOffset || tokenStart + tokenLength,
|
|
2133
|
+
leadingHtmlStart
|
|
2134
|
+
};
|
|
2135
|
+
}
|
|
2136
|
+
const parse = (doc) => {
|
|
2137
|
+
document = doc;
|
|
2138
|
+
offset = 0;
|
|
2139
|
+
output = [];
|
|
2140
|
+
stack = [];
|
|
2141
|
+
tokenizer.lastIndex = 0;
|
|
2142
|
+
do {
|
|
2143
|
+
} while (proceed());
|
|
2144
|
+
return output;
|
|
2145
|
+
};
|
|
2146
|
+
function proceed() {
|
|
2147
|
+
const stackDepth = stack.length;
|
|
2148
|
+
const next = nextToken();
|
|
2149
|
+
const [tokenType, blockName, attrs, startOffset, tokenLength] = next;
|
|
2150
|
+
const leadingHtmlStart = startOffset > offset ? offset : null;
|
|
2151
|
+
switch (tokenType) {
|
|
2152
|
+
case "no-more-tokens":
|
|
2153
|
+
if (0 === stackDepth) {
|
|
2154
|
+
addFreeform();
|
|
2155
|
+
return false;
|
|
2156
|
+
}
|
|
2157
|
+
if (1 === stackDepth) {
|
|
2158
|
+
addBlockFromStack();
|
|
2159
|
+
return false;
|
|
2160
|
+
}
|
|
2161
|
+
while (0 < stack.length) {
|
|
2162
|
+
addBlockFromStack();
|
|
2163
|
+
}
|
|
2164
|
+
return false;
|
|
2165
|
+
case "void-block":
|
|
2166
|
+
if (0 === stackDepth) {
|
|
2167
|
+
if (null !== leadingHtmlStart) {
|
|
2168
|
+
output.push(
|
|
2169
|
+
Freeform(
|
|
2170
|
+
document.substr(
|
|
2171
|
+
leadingHtmlStart,
|
|
2172
|
+
startOffset - leadingHtmlStart
|
|
2173
|
+
)
|
|
2174
|
+
)
|
|
2175
|
+
);
|
|
2176
|
+
}
|
|
2177
|
+
output.push(Block(blockName, attrs, [], "", []));
|
|
2178
|
+
offset = startOffset + tokenLength;
|
|
2179
|
+
return true;
|
|
2180
|
+
}
|
|
2181
|
+
addInnerBlock(
|
|
2182
|
+
Block(blockName, attrs, [], "", []),
|
|
2183
|
+
startOffset,
|
|
2184
|
+
tokenLength
|
|
2185
|
+
);
|
|
2186
|
+
offset = startOffset + tokenLength;
|
|
2187
|
+
return true;
|
|
2188
|
+
case "block-opener":
|
|
2189
|
+
stack.push(
|
|
2190
|
+
Frame(
|
|
2191
|
+
Block(blockName, attrs, [], "", []),
|
|
2192
|
+
startOffset,
|
|
2193
|
+
tokenLength,
|
|
2194
|
+
startOffset + tokenLength,
|
|
2195
|
+
leadingHtmlStart
|
|
2196
|
+
)
|
|
2197
|
+
);
|
|
2198
|
+
offset = startOffset + tokenLength;
|
|
2199
|
+
return true;
|
|
2200
|
+
case "block-closer":
|
|
2201
|
+
if (0 === stackDepth) {
|
|
2202
|
+
addFreeform();
|
|
2203
|
+
return false;
|
|
2204
|
+
}
|
|
2205
|
+
if (1 === stackDepth) {
|
|
2206
|
+
addBlockFromStack(startOffset);
|
|
2207
|
+
offset = startOffset + tokenLength;
|
|
2208
|
+
return true;
|
|
2209
|
+
}
|
|
2210
|
+
const stackTop = stack.pop();
|
|
2211
|
+
const html = document.substr(
|
|
2212
|
+
stackTop.prevOffset,
|
|
2213
|
+
startOffset - stackTop.prevOffset
|
|
2214
|
+
);
|
|
2215
|
+
stackTop.block.innerHTML += html;
|
|
2216
|
+
stackTop.block.innerContent.push(html);
|
|
2217
|
+
stackTop.prevOffset = startOffset + tokenLength;
|
|
2218
|
+
addInnerBlock(
|
|
2219
|
+
stackTop.block,
|
|
2220
|
+
stackTop.tokenStart,
|
|
2221
|
+
stackTop.tokenLength,
|
|
2222
|
+
startOffset + tokenLength
|
|
2223
|
+
);
|
|
2224
|
+
offset = startOffset + tokenLength;
|
|
2225
|
+
return true;
|
|
2226
|
+
default:
|
|
2227
|
+
addFreeform();
|
|
2228
|
+
return false;
|
|
2229
|
+
}
|
|
2230
|
+
}
|
|
2231
|
+
function parseJSON(input) {
|
|
2232
|
+
try {
|
|
2233
|
+
return JSON.parse(input);
|
|
2234
|
+
} catch (e) {
|
|
2235
|
+
return null;
|
|
2236
|
+
}
|
|
2237
|
+
}
|
|
2238
|
+
function nextToken() {
|
|
2239
|
+
const matches = tokenizer.exec(document);
|
|
2240
|
+
if (null === matches) {
|
|
2241
|
+
return ["no-more-tokens", "", null, 0, 0];
|
|
2242
|
+
}
|
|
2243
|
+
const startedAt = matches.index;
|
|
2244
|
+
const [
|
|
2245
|
+
match,
|
|
2246
|
+
closerMatch,
|
|
2247
|
+
namespaceMatch,
|
|
2248
|
+
nameMatch,
|
|
2249
|
+
attrsMatch,
|
|
2250
|
+
,
|
|
2251
|
+
voidMatch
|
|
2252
|
+
] = matches;
|
|
2253
|
+
const length = match.length;
|
|
2254
|
+
const isCloser = !!closerMatch;
|
|
2255
|
+
const isVoid = !!voidMatch;
|
|
2256
|
+
const namespace = namespaceMatch || "core/";
|
|
2257
|
+
const name = namespace + nameMatch;
|
|
2258
|
+
const hasAttrs = !!attrsMatch;
|
|
2259
|
+
const attrs = hasAttrs ? parseJSON(attrsMatch) : {};
|
|
2260
|
+
if (isVoid) {
|
|
2261
|
+
return ["void-block", name, attrs, startedAt, length];
|
|
2262
|
+
}
|
|
2263
|
+
if (isCloser) {
|
|
2264
|
+
return ["block-closer", name, null, startedAt, length];
|
|
2265
|
+
}
|
|
2266
|
+
return ["block-opener", name, attrs, startedAt, length];
|
|
2267
|
+
}
|
|
2268
|
+
function addFreeform(rawLength) {
|
|
2269
|
+
const length = document.length - offset;
|
|
2270
|
+
if (0 === length) {
|
|
2271
|
+
return;
|
|
2272
|
+
}
|
|
2273
|
+
output.push(Freeform(document.substr(offset, length)));
|
|
2274
|
+
}
|
|
2275
|
+
function addInnerBlock(block, tokenStart, tokenLength, lastOffset) {
|
|
2276
|
+
const parent = stack[stack.length - 1];
|
|
2277
|
+
parent.block.innerBlocks.push(block);
|
|
2278
|
+
const html = document.substr(
|
|
2279
|
+
parent.prevOffset,
|
|
2280
|
+
tokenStart - parent.prevOffset
|
|
2281
|
+
);
|
|
2282
|
+
if (html) {
|
|
2283
|
+
parent.block.innerHTML += html;
|
|
2284
|
+
parent.block.innerContent.push(html);
|
|
2285
|
+
}
|
|
2286
|
+
parent.block.innerContent.push(null);
|
|
2287
|
+
parent.prevOffset = lastOffset ? lastOffset : tokenStart + tokenLength;
|
|
2288
|
+
}
|
|
2289
|
+
function addBlockFromStack(endOffset) {
|
|
2290
|
+
const { block, leadingHtmlStart, prevOffset, tokenStart } = stack.pop();
|
|
2291
|
+
const html = endOffset ? document.substr(prevOffset, endOffset - prevOffset) : document.substr(prevOffset);
|
|
2292
|
+
if (html) {
|
|
2293
|
+
block.innerHTML += html;
|
|
2294
|
+
block.innerContent.push(html);
|
|
2295
|
+
}
|
|
2296
|
+
if (null !== leadingHtmlStart) {
|
|
2297
|
+
output.push(
|
|
2298
|
+
Freeform(
|
|
2299
|
+
document.substr(
|
|
2300
|
+
leadingHtmlStart,
|
|
2301
|
+
tokenStart - leadingHtmlStart
|
|
2302
|
+
)
|
|
2303
|
+
)
|
|
2304
|
+
);
|
|
2305
|
+
}
|
|
2306
|
+
output.push(block);
|
|
2307
|
+
}
|
|
2308
|
+
|
|
2014
2309
|
/**
|
|
2015
2310
|
* @license GPL-3.0-or-later
|
|
2016
2311
|
*
|
|
@@ -2041,6 +2336,8 @@ class WordPressGenerator {
|
|
|
2041
2336
|
const data = await client.getAllData({
|
|
2042
2337
|
per_page: this.config.maxItems || 100,
|
|
2043
2338
|
_embed: this.config.includeEmbedded || false,
|
|
2339
|
+
// required for content.raw with Gutenberg comments
|
|
2340
|
+
context: 'edit',
|
|
2044
2341
|
});
|
|
2045
2342
|
// Create the static data structure matching the existing format
|
|
2046
2343
|
const staticData = {
|
|
@@ -2062,7 +2359,17 @@ class WordPressGenerator {
|
|
|
2062
2359
|
},
|
|
2063
2360
|
// Map the data to the expected structure
|
|
2064
2361
|
posts: data.posts,
|
|
2065
|
-
pages: data.pages
|
|
2362
|
+
pages: (data.pages || []).map((p) => {
|
|
2363
|
+
let blocks = [];
|
|
2364
|
+
try {
|
|
2365
|
+
const raw = p?.content?.raw || '';
|
|
2366
|
+
blocks = raw ? parse(raw) : [];
|
|
2367
|
+
}
|
|
2368
|
+
catch (e) {
|
|
2369
|
+
console.warn('⚠️ Failed to parse Gutenberg blocks for page', p?.id, e);
|
|
2370
|
+
}
|
|
2371
|
+
return { ...p, blocks };
|
|
2372
|
+
}),
|
|
2066
2373
|
media: data.media,
|
|
2067
2374
|
categories: data.categories,
|
|
2068
2375
|
tags: data.tags,
|
|
@@ -2319,9 +2626,8 @@ async function generateFormProtectionData(config) {
|
|
|
2319
2626
|
function createWordPressConfig(overrides = {}) {
|
|
2320
2627
|
return {
|
|
2321
2628
|
apiUrl: process.env.VITE_WORDPRESS_API_URL || '',
|
|
2322
|
-
authMode: process.env.
|
|
2629
|
+
authMode: process.env.VITE_AUTH_MODE || 'cloudflare_proxy',
|
|
2323
2630
|
cloudflareWorkerUrl: process.env.VITE_CLOUDFLARE_WORKER_URL,
|
|
2324
|
-
supabaseUrl: process.env.VITE_SUPABASE_URL,
|
|
2325
2631
|
username: process.env.VITE_WP_API_USERNAME,
|
|
2326
2632
|
password: process.env.VITE_WP_APP_PASSWORD,
|
|
2327
2633
|
timeout: 30000,
|
|
@@ -2332,9 +2638,8 @@ function createWordPressConfig(overrides = {}) {
|
|
|
2332
2638
|
function createGravityFormsConfig(overrides = {}) {
|
|
2333
2639
|
return {
|
|
2334
2640
|
apiUrl: process.env.VITE_GRAVITY_FORMS_API_URL || '',
|
|
2335
|
-
authMode: process.env.
|
|
2641
|
+
authMode: process.env.VITE_AUTH_MODE || 'cloudflare_proxy',
|
|
2336
2642
|
cloudflareWorkerUrl: process.env.VITE_CLOUDFLARE_WORKER_URL,
|
|
2337
|
-
supabaseUrl: process.env.VITE_SUPABASE_URL,
|
|
2338
2643
|
username: process.env.VITE_GRAVITY_FORMS_USERNAME || '',
|
|
2339
2644
|
password: process.env.VITE_GRAVITY_FORMS_PASSWORD || '',
|
|
2340
2645
|
timeout: 30000,
|
|
@@ -2362,9 +2667,7 @@ function validateWordPressConfig(config) {
|
|
|
2362
2667
|
if (config.authMode === 'cloudflare_proxy' && !config.cloudflareWorkerUrl) {
|
|
2363
2668
|
errors.push('Cloudflare Worker URL is required for cloudflare_proxy mode');
|
|
2364
2669
|
}
|
|
2365
|
-
|
|
2366
|
-
errors.push('Supabase URL is required for supabase_proxy mode');
|
|
2367
|
-
}
|
|
2670
|
+
// no other proxy modes supported
|
|
2368
2671
|
return errors;
|
|
2369
2672
|
}
|
|
2370
2673
|
function validateGravityFormsConfig(config) {
|
|
@@ -2492,6 +2795,18 @@ exports.createWordPressConfig = createWordPressConfig;
|
|
|
2492
2795
|
exports.generateFormProtectionData = generateFormProtectionData;
|
|
2493
2796
|
exports.generateGravityFormsData = generateGravityFormsData;
|
|
2494
2797
|
exports.generateWordPressData = generateWordPressData;
|
|
2798
|
+
exports.getActiveForms = getActiveForms;
|
|
2799
|
+
exports.getFormById = getFormById;
|
|
2800
|
+
exports.getPublishedForms = getPublishedForms;
|
|
2801
|
+
exports.getWordPressCategories = getWordPressCategories;
|
|
2802
|
+
exports.getWordPressMedia = getWordPressMedia;
|
|
2803
|
+
exports.getWordPressPages = getWordPressPages;
|
|
2804
|
+
exports.getWordPressPosts = getWordPressPosts;
|
|
2805
|
+
exports.getWordPressTags = getWordPressTags;
|
|
2806
|
+
exports.hasGravityFormsStatic = hasGravityFormsStatic;
|
|
2807
|
+
exports.hasWordPressStatic = hasWordPressStatic;
|
|
2808
|
+
exports.loadGravityFormsData = loadGravityFormsData;
|
|
2809
|
+
exports.loadWordPressData = loadWordPressData;
|
|
2495
2810
|
exports.sanitizeHtml = sanitizeHtml;
|
|
2496
2811
|
exports.transformWordPressMedia = transformWordPressMedia;
|
|
2497
2812
|
exports.transformWordPressMediaItems = transformWordPressMediaItems;
|