@marvalt/wadapter 1.1.12 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +52 -145
- package/dist/client/wordpress-client.d.ts.map +1 -1
- package/dist/gravity-forms/gravity-forms-client.d.ts.map +1 -1
- package/dist/index.d.ts +65 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +123 -31
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +134 -30
- 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 +1 -3
- package/dist/types/wordpress.d.ts.map +1 -1
- package/dist/utils/config.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,179 +1,86 @@
|
|
|
1
1
|
# marvalt-wadapter
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Static-first WordPress and Gravity Forms integration for React apps.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## What it provides
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
- WordPress and Gravity Forms static-data generators (build-time)
|
|
8
|
+
- Static data loaders and selectors (runtime reads from JSON only)
|
|
9
|
+
- Gravity Forms submission client with two modes: `cloudflare_proxy` and `direct`
|
|
8
10
|
|
|
9
|
-
##
|
|
11
|
+
## Modes
|
|
10
12
|
|
|
11
|
-
|
|
12
|
-
-
|
|
13
|
-
-
|
|
14
|
-
-
|
|
15
|
-
- **React Hooks**: Custom hooks for WordPress data management
|
|
16
|
-
- **React Components**: Pre-built components for WordPress content display
|
|
13
|
+
- `cloudflare_proxy`:
|
|
14
|
+
- Frontend calls a Cloudflare Worker with `?endpoint=/wp-json/...`.
|
|
15
|
+
- Worker injects Cloudflare Access credentials from its environment and forwards requests.
|
|
16
|
+
- Gravity Forms submissions go to enhanced `gf-api/v1` endpoints via the worker.
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
-
|
|
20
|
-
-
|
|
21
|
-
-
|
|
22
|
-
- **Email Verification**: Handle email verification workflows
|
|
23
|
-
- **React Hooks**: Custom hooks for form handling and submission
|
|
24
|
-
- **React Components**: Pre-built form components with validation
|
|
18
|
+
- `direct`:
|
|
19
|
+
- Frontend calls your backend directly (not behind Zero Trust).
|
|
20
|
+
- WordPress uses `/wp-json/wp/v2/...`.
|
|
21
|
+
- Gravity Forms uses official REST API v2 for submissions.
|
|
25
22
|
|
|
26
|
-
|
|
27
|
-
- **WordPress Content**: Generate static data for posts, pages, media, etc.
|
|
28
|
-
- **Gravity Forms**: Generate form configurations, fields, notifications, confirmations
|
|
29
|
-
- **Form Protection**: Include Albert Bruckmann plugin behavior in static data
|
|
30
|
-
- **Validation**: Comprehensive data validation and error handling
|
|
31
|
-
|
|
32
|
-
## Installation
|
|
23
|
+
## Install
|
|
33
24
|
|
|
34
25
|
```bash
|
|
35
26
|
npm install @marvalt/wadapter
|
|
36
27
|
```
|
|
37
28
|
|
|
38
|
-
##
|
|
39
|
-
|
|
40
|
-
### WordPress Content
|
|
41
|
-
|
|
42
|
-
```typescript
|
|
43
|
-
import { useWordPress } from '@marvalt/wadapter';
|
|
44
|
-
|
|
45
|
-
function BlogPost({ postId }: { postId: number }) {
|
|
46
|
-
const { data: post, loading, error } = useWordPress('posts', postId);
|
|
47
|
-
|
|
48
|
-
if (loading) return <div>Loading...</div>;
|
|
49
|
-
if (error) return <div>Error: {error.message}</div>;
|
|
50
|
-
|
|
51
|
-
return (
|
|
52
|
-
<article>
|
|
53
|
-
<h1>{post.title.rendered}</h1>
|
|
54
|
-
<div dangerouslySetInnerHTML={{ __html: post.content.rendered }} />
|
|
55
|
-
</article>
|
|
56
|
-
);
|
|
57
|
-
}
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
### Gravity Forms
|
|
61
|
-
|
|
62
|
-
```typescript
|
|
63
|
-
import { useGravityForms } from '@marvalt/wadapter';
|
|
64
|
-
|
|
65
|
-
function ContactForm({ formId }: { formId: number }) {
|
|
66
|
-
const { submitForm, loading, result } = useGravityForms(formId);
|
|
67
|
-
|
|
68
|
-
const handleSubmit = async (formData: Record<string, any>) => {
|
|
69
|
-
await submitForm(formData);
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
return (
|
|
73
|
-
<form onSubmit={handleSubmit}>
|
|
74
|
-
{/* Form fields */}
|
|
75
|
-
<button type="submit" disabled={loading}>
|
|
76
|
-
{loading ? 'Submitting...' : 'Submit'}
|
|
77
|
-
</button>
|
|
78
|
-
{result && (
|
|
79
|
-
<div className={result.success ? 'success' : 'error'}>
|
|
80
|
-
{result.message}
|
|
81
|
-
</div>
|
|
82
|
-
)}
|
|
83
|
-
</form>
|
|
84
|
-
);
|
|
85
|
-
}
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
### Static Data Generation
|
|
89
|
-
|
|
90
|
-
```typescript
|
|
91
|
-
import { generateWordPressData, generateGravityFormsData } from '@marvalt/wadapter';
|
|
92
|
-
|
|
93
|
-
// Generate WordPress static data
|
|
94
|
-
await generateWordPressData({
|
|
95
|
-
apiUrl: 'https://your-wordpress-site.com',
|
|
96
|
-
endpoints: ['posts', 'pages', 'media'],
|
|
97
|
-
outputPath: './public/static-data.json'
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
// Generate Gravity Forms static data
|
|
101
|
-
await generateGravityFormsData({
|
|
102
|
-
apiUrl: 'https://your-wordpress-site.com',
|
|
103
|
-
outputPath: './public/gravity-forms.json'
|
|
104
|
-
});
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
## Configuration
|
|
29
|
+
## Configure
|
|
108
30
|
|
|
109
|
-
|
|
31
|
+
Required environment variables:
|
|
110
32
|
|
|
111
33
|
```env
|
|
112
|
-
#
|
|
113
|
-
|
|
114
|
-
VITE_WP_AUTH_MODE=cloudflare_proxy
|
|
115
|
-
VITE_CLOUDFLARE_WORKER_URL=https://your-worker.your-subdomain.workers.dev
|
|
116
|
-
|
|
117
|
-
# Gravity Forms Configuration
|
|
118
|
-
VITE_GRAVITY_FORMS_API_URL=https://your-wordpress-site.com/wp-json/gf-api/v1
|
|
119
|
-
VITE_GRAVITY_FORMS_USERNAME=your-username
|
|
120
|
-
VITE_GRAVITY_FORMS_PASSWORD=your-app-password
|
|
34
|
+
# Mode
|
|
35
|
+
VITE_AUTH_MODE=cloudflare_proxy|direct
|
|
121
36
|
|
|
122
|
-
#
|
|
123
|
-
|
|
124
|
-
|
|
37
|
+
# WordPress
|
|
38
|
+
VITE_WORDPRESS_API_URL=https://your-wordpress-site.com
|
|
39
|
+
VITE_CLOUDFLARE_WORKER_URL=https://your-worker.your-subdomain.workers.dev # when cloudflare_proxy
|
|
40
|
+
VITE_WP_API_USERNAME=your-username # when direct
|
|
41
|
+
VITE_WP_APP_PASSWORD=your-app-password # when direct
|
|
42
|
+
|
|
43
|
+
# Gravity Forms
|
|
44
|
+
VITE_GRAVITY_FORMS_API_URL=https://your-wordpress-site.com # base site URL
|
|
45
|
+
VITE_GRAVITY_FORMS_USERNAME=your-username # when direct
|
|
46
|
+
VITE_GRAVITY_FORMS_PASSWORD=your-app-password # when direct
|
|
47
|
+
|
|
48
|
+
# Optional worker headers (set at runtime by frontend; CF Access secrets live in the worker env)
|
|
49
|
+
VITE_APP_ID=your-app-id
|
|
50
|
+
VITE_WORKER_SECRET=your-shared-secret
|
|
125
51
|
```
|
|
126
52
|
|
|
127
|
-
##
|
|
128
|
-
|
|
129
|
-
### WordPress Hooks
|
|
130
|
-
|
|
131
|
-
- `useWordPress(endpoint, id?)` - Fetch WordPress content
|
|
132
|
-
- `useWordPressMedia(mediaId)` - Fetch WordPress media
|
|
133
|
-
- `useWordPressCategories()` - Fetch WordPress categories
|
|
134
|
-
- `useWordPressTags()` - Fetch WordPress tags
|
|
53
|
+
## Build-time generation
|
|
135
54
|
|
|
136
|
-
|
|
55
|
+
The generators fetch WordPress and Gravity Forms data and write static JSON:
|
|
137
56
|
|
|
138
|
-
- `
|
|
139
|
-
-
|
|
140
|
-
- `useGravityFormsFields(formId)` - Fetch form fields
|
|
57
|
+
- WordPress JSON: `public/wordpress-data.json`
|
|
58
|
+
- Gravity Forms JSON: `public/gravityForms.json`
|
|
141
59
|
|
|
142
|
-
|
|
60
|
+
You can wire them into npm scripts using your preferred runner. Example entry points are included in the docs.
|
|
143
61
|
|
|
144
|
-
|
|
145
|
-
- `generateGravityFormsData(config)` - Generate Gravity Forms static data
|
|
146
|
-
- `generateFormProtectionData(config)` - Generate form protection data
|
|
62
|
+
## Runtime access (static-only)
|
|
147
63
|
|
|
148
|
-
|
|
64
|
+
- Loaders
|
|
65
|
+
- `loadWordPressData(path = '/wordpress-data.json')`
|
|
66
|
+
- `loadGravityFormsData(path = '/gravityForms.json')`
|
|
149
67
|
|
|
150
|
-
|
|
68
|
+
- Selectors
|
|
69
|
+
- WordPress: `getWordPressPosts`, `getWordPressPages`, `getWordPressMedia`, `getWordPressCategories`, `getWordPressTags`
|
|
70
|
+
- Gravity Forms: `getActiveForms`, `getPublishedForms`, `getFormById`
|
|
151
71
|
|
|
152
|
-
|
|
153
|
-
- **Form Validation**: Enhanced form validation with protection rules
|
|
154
|
-
- **Spam Protection**: Built-in spam protection mechanisms
|
|
155
|
-
- **Rate Limiting**: Prevent form abuse with rate limiting
|
|
72
|
+
Note: These selectors read only from static JSON. They do not fetch live content at runtime.
|
|
156
73
|
|
|
157
|
-
##
|
|
158
|
-
|
|
159
|
-
Licensed under the [GNU General Public License v3.0 or later (GPLv3+)](LICENSE).
|
|
160
|
-
|
|
161
|
-
This adapter is part of the **MarVAlt Open SDK**, designed for use with DigiVAlt and MarVAlt-based deployments.
|
|
162
|
-
Commercial orchestration, automation, and AI components are licensed separately via [marvalt.cloud](https://marvalt.cloud).
|
|
74
|
+
## Form submissions
|
|
163
75
|
|
|
76
|
+
Use the package Gravity Forms client. It routes per mode:
|
|
164
77
|
|
|
165
|
-
|
|
78
|
+
- `cloudflare_proxy`: worker `?endpoint=/wp-json/gf-api/v1/...`
|
|
79
|
+
- `direct`: official Gravity Forms REST v2 endpoints
|
|
166
80
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
## Changelog
|
|
81
|
+
## License
|
|
170
82
|
|
|
171
|
-
|
|
172
|
-
- WordPress static data generation
|
|
173
|
-
- Gravity Forms integration
|
|
174
|
-
- Albert Bruckmann form protection integration
|
|
175
|
-
- React hooks and components
|
|
176
|
-
- Comprehensive TypeScript support
|
|
83
|
+
GPL-3.0-or-later.
|
|
177
84
|
|
|
178
85
|
|
|
179
86
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wordpress-client.d.ts","sourceRoot":"","sources":["../../src/client/wordpress-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAIH,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,aAAa,EAAE,aAAa,EAAE,cAAc,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAE1J,qBAAa,eAAe;IAC1B,OAAO,CAAC,MAAM,CAAkB;gBAEpB,MAAM,EAAE,eAAe;YAIrB,WAAW;
|
|
1
|
+
{"version":3,"file":"wordpress-client.d.ts","sourceRoot":"","sources":["../../src/client/wordpress-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAIH,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,aAAa,EAAE,aAAa,EAAE,cAAc,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAE1J,qBAAa,eAAe;IAC1B,OAAO,CAAC,MAAM,CAAkB;gBAEpB,MAAM,EAAE,eAAe;YAIrB,WAAW;IAmGzB,OAAO,CAAC,UAAU;IASZ,QAAQ,CAAC,MAAM,GAAE,oBAAyB,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;IAIrE,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IAI3C,QAAQ,CAAC,MAAM,GAAE,oBAAyB,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;IAIrE,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IAI3C,QAAQ,CAAC,MAAM,GAAE,oBAAyB,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC;IAItE,YAAY,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IAIjD,aAAa,CAAC,MAAM,GAAE,oBAAyB,GAAG,OAAO,CAAC,iBAAiB,EAAE,CAAC;IAI9E,OAAO,CAAC,MAAM,GAAE,oBAAyB,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC;IAKnE,eAAe,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;IAIjC,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;IAI5C,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC;IAQ3E,kBAAkB,IAAI,OAAO,CAAC,GAAG,CAAC;IAIlC,UAAU,CAAC,MAAM,GAAE,oBAAyB,GAAG,OAAO,CAAC;QAC3D,KAAK,EAAE,aAAa,EAAE,CAAC;QACvB,KAAK,EAAE,aAAa,EAAE,CAAC;QACvB,KAAK,EAAE,cAAc,EAAE,CAAC;QACxB,UAAU,EAAE,iBAAiB,EAAE,CAAC;QAChC,IAAI,EAAE,YAAY,EAAE,CAAC;KACtB,CAAC;CAWH"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gravity-forms-client.d.ts","sourceRoot":"","sources":["../../src/gravity-forms/gravity-forms-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAIH,OAAO,EAAE,kBAAkB,EAAE,WAAW,EAAE,qBAAqB,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AAE7H,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,MAAM,CAAqB;gBAEvB,MAAM,EAAE,kBAAkB;YAIxB,WAAW;
|
|
1
|
+
{"version":3,"file":"gravity-forms-client.d.ts","sourceRoot":"","sources":["../../src/gravity-forms/gravity-forms-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAIH,OAAO,EAAE,kBAAkB,EAAE,WAAW,EAAE,qBAAqB,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AAE7H,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,MAAM,CAAqB;gBAEvB,MAAM,EAAE,kBAAkB;YAIxB,WAAW;IAiEzB,OAAO,CAAC,UAAU;IASZ,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;IAQzC,QAAQ,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC;IAOlC,aAAa,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;IAO/C,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,qBAAqB,GAAG,OAAO,CAAC,2BAA2B,CAAC;IAUnG,SAAS,IAAI,OAAO,CAAC;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAC;QAAC,cAAc,EAAE,MAAM,CAAA;KAAE,CAAC;CAM1F"}
|
package/dist/index.d.ts
CHANGED
|
@@ -311,10 +311,8 @@ interface WordPressAuthor {
|
|
|
311
311
|
}
|
|
312
312
|
interface WordPressConfig {
|
|
313
313
|
apiUrl?: string;
|
|
314
|
-
authMode: 'direct' | 'cloudflare_proxy'
|
|
314
|
+
authMode: 'direct' | 'cloudflare_proxy';
|
|
315
315
|
cloudflareWorkerUrl?: string;
|
|
316
|
-
supabaseUrl?: string;
|
|
317
|
-
supabaseAnonKey?: string;
|
|
318
316
|
username?: string;
|
|
319
317
|
password?: string;
|
|
320
318
|
appId?: string;
|
|
@@ -558,10 +556,8 @@ interface GravityFormSubmissionResult {
|
|
|
558
556
|
}
|
|
559
557
|
interface GravityFormsConfig {
|
|
560
558
|
apiUrl?: string;
|
|
561
|
-
authMode: 'direct' | 'cloudflare_proxy'
|
|
559
|
+
authMode: 'direct' | 'cloudflare_proxy';
|
|
562
560
|
cloudflareWorkerUrl?: string;
|
|
563
|
-
supabaseUrl?: string;
|
|
564
|
-
supabaseAnonKey?: string;
|
|
565
561
|
username?: string;
|
|
566
562
|
password?: string;
|
|
567
563
|
appId?: string;
|
|
@@ -777,6 +773,67 @@ interface GravityFormsProviderProps {
|
|
|
777
773
|
declare const GravityFormsProvider: React.FC<GravityFormsProviderProps>;
|
|
778
774
|
declare function useGravityFormsContext(): GravityFormsContextType;
|
|
779
775
|
|
|
776
|
+
/**
|
|
777
|
+
* @license GPL-3.0-or-later
|
|
778
|
+
*
|
|
779
|
+
* This file is part of the MarVAlt Open SDK.
|
|
780
|
+
* Copyright (c) 2025 Vibune Pty Ltd.
|
|
781
|
+
*
|
|
782
|
+
* This program is free software: you can redistribute it and/or modify
|
|
783
|
+
* it under the terms of the GNU General Public License as published by
|
|
784
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
785
|
+
* (at your option) any later version.
|
|
786
|
+
*
|
|
787
|
+
* This program is distributed in the hope that it will be useful,
|
|
788
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
789
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
790
|
+
* See the GNU General Public License for more details.
|
|
791
|
+
*/
|
|
792
|
+
|
|
793
|
+
interface WordPressStaticData {
|
|
794
|
+
generatedAt?: string;
|
|
795
|
+
posts: WordPressPost[];
|
|
796
|
+
pages: WordPressPage[];
|
|
797
|
+
media: WordPressMedia[];
|
|
798
|
+
categories: WordPressCategory[];
|
|
799
|
+
tags: WordPressTag[];
|
|
800
|
+
}
|
|
801
|
+
declare function loadWordPressData(path?: string): Promise<WordPressStaticData | null>;
|
|
802
|
+
declare function hasWordPressStatic(): boolean;
|
|
803
|
+
declare function getWordPressPosts(): WordPressPost[];
|
|
804
|
+
declare function getWordPressPages(): WordPressPage[];
|
|
805
|
+
declare function getWordPressMedia(): WordPressMedia[];
|
|
806
|
+
declare function getWordPressCategories(): WordPressCategory[];
|
|
807
|
+
declare function getWordPressTags(): WordPressTag[];
|
|
808
|
+
|
|
809
|
+
/**
|
|
810
|
+
* @license GPL-3.0-or-later
|
|
811
|
+
*
|
|
812
|
+
* This file is part of the MarVAlt Open SDK.
|
|
813
|
+
* Copyright (c) 2025 Vibune Pty Ltd.
|
|
814
|
+
*
|
|
815
|
+
* This program is free software: you can redistribute it and/or modify
|
|
816
|
+
* it under the terms of the GNU General Public License as published by
|
|
817
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
818
|
+
* (at your option) any later version.
|
|
819
|
+
*
|
|
820
|
+
* This program is distributed in the hope that it will be useful,
|
|
821
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
822
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
823
|
+
* See the GNU General Public License for more details.
|
|
824
|
+
*/
|
|
825
|
+
|
|
826
|
+
interface GravityFormsStaticData$1 {
|
|
827
|
+
generated_at?: string;
|
|
828
|
+
total_forms: number;
|
|
829
|
+
forms: GravityForm$1[];
|
|
830
|
+
}
|
|
831
|
+
declare function loadGravityFormsData(path?: string): Promise<GravityFormsStaticData$1 | null>;
|
|
832
|
+
declare function hasGravityFormsStatic(): boolean;
|
|
833
|
+
declare function getActiveForms(): GravityForm$1[];
|
|
834
|
+
declare function getPublishedForms(): GravityForm$1[];
|
|
835
|
+
declare function getFormById(id: number | string): GravityForm$1 | undefined;
|
|
836
|
+
|
|
780
837
|
/**
|
|
781
838
|
* @license GPL-3.0-or-later
|
|
782
839
|
*
|
|
@@ -1011,5 +1068,5 @@ declare function validateFormData(formData: Record<string, any>, rules: Record<s
|
|
|
1011
1068
|
errors: Record<string, string[]>;
|
|
1012
1069
|
};
|
|
1013
1070
|
|
|
1014
|
-
export { FormProtectionGenerator, GravityForm, GravityFormsClient, GravityFormsGenerator, GravityFormsProvider, WordPressClient, WordPressContent, WordPressGenerator, WordPressProvider, createFormProtectionConfig, createGravityFormsConfig, createWordPressConfig, generateFormProtectionData, generateGravityFormsData, generateWordPressData, sanitizeHtml, transformWordPressMedia, transformWordPressMediaItems, transformWordPressPage, transformWordPressPages, transformWordPressPost, transformWordPressPosts, useGravityForms, useGravityFormsConfig, useGravityFormsContext, useWordPress, useWordPressCategories, useWordPressContext, useWordPressMedia, useWordPressPage, useWordPressPages, useWordPressPost, useWordPressPosts, useWordPressTags, validateEmail, validateFormData, validateFormProtectionConfig, validateGravityFormsConfig, validateMaxLength, validateMinLength, validatePhoneNumber, validateRequired, validateUrl, validateWordPressConfig };
|
|
1015
|
-
export type { EmailVerificationData, FormProtectionConfig, FormProtectionGeneratorConfig, FormProtectionResult, FormProtectionStaticData, FormProtectionValidation, GravityFormConfirmation, GravityFormField, GravityFormNotification, GravityFormSubmission, GravityFormSubmissionResult, GravityFormsConfig, GravityFormsGeneratorConfig,
|
|
1071
|
+
export { FormProtectionGenerator, GravityForm, GravityFormsClient, GravityFormsGenerator, GravityFormsProvider, WordPressClient, WordPressContent, WordPressGenerator, WordPressProvider, createFormProtectionConfig, createGravityFormsConfig, createWordPressConfig, generateFormProtectionData, generateGravityFormsData, generateWordPressData, getActiveForms, getFormById, getPublishedForms, getWordPressCategories, getWordPressMedia, getWordPressPages, getWordPressPosts, getWordPressTags, hasGravityFormsStatic, hasWordPressStatic, loadGravityFormsData, loadWordPressData, sanitizeHtml, transformWordPressMedia, transformWordPressMediaItems, transformWordPressPage, transformWordPressPages, transformWordPressPost, transformWordPressPosts, useGravityForms, useGravityFormsConfig, useGravityFormsContext, useWordPress, useWordPressCategories, useWordPressContext, useWordPressMedia, useWordPressPage, useWordPressPages, useWordPressPost, useWordPressPosts, useWordPressTags, validateEmail, validateFormData, validateFormProtectionConfig, validateGravityFormsConfig, validateMaxLength, validateMinLength, validatePhoneNumber, validateRequired, validateUrl, validateWordPressConfig };
|
|
1072
|
+
export type { EmailVerificationData, FormProtectionConfig, FormProtectionGeneratorConfig, FormProtectionResult, FormProtectionStaticData, FormProtectionValidation, GravityFormConfirmation, GravityFormField, GravityFormNotification, GravityFormSubmission, GravityFormSubmissionResult, GravityFormsConfig, GravityFormsGeneratorConfig, StaticDataStore, TransformedWordPressMedia, TransformedWordPressPage, TransformedWordPressPost, UseGravityFormsResult, UseWordPressResult, WordPressAuthor, WordPressCategory, WordPressConfig, WordPressGeneratorConfig, WordPressMedia, WordPressPage, WordPressPost, WordPressQueryParams, WordPressStaticData, WordPressTag };
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAKH,cAAc,2BAA2B,CAAC;AAC1C,cAAc,uCAAuC,CAAC;AAGtD,cAAc,sCAAsC,CAAC;AAGrD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,+BAA+B,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,qCAAqC,CAAC;AACvE,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAC7D,cAAc,qCAAqC,CAAC;AACpD,cAAc,wCAAwC,CAAC;AAGvD,cAAc,4CAA4C,CAAC;AAC3D,cAAc,oDAAoD,CAAC;AACnE,cAAc,wDAAwD,CAAC;AAGvE,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AAGxC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAKH,cAAc,2BAA2B,CAAC;AAC1C,cAAc,uCAAuC,CAAC;AAGtD,cAAc,sCAAsC,CAAC;AAGrD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,+BAA+B,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,qCAAqC,CAAC;AACvE,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAC7D,cAAc,qCAAqC,CAAC;AACpD,cAAc,wCAAwC,CAAC;AAGvD,cAAc,2BAA2B,CAAC;AAC1C,cAAc,+BAA+B,CAAC;AAG9C,cAAc,4CAA4C,CAAC;AAC3D,cAAc,oDAAoD,CAAC;AACnE,cAAc,wDAAwD,CAAC;AAGvE,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AAGxC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC"}
|
package/dist/index.esm.js
CHANGED
|
@@ -37,7 +37,7 @@ class WordPressClient {
|
|
|
37
37
|
});
|
|
38
38
|
// Construct URL based on auth mode
|
|
39
39
|
let url;
|
|
40
|
-
if (this.config.authMode === 'cloudflare_proxy'
|
|
40
|
+
if (this.config.authMode === 'cloudflare_proxy') {
|
|
41
41
|
// For proxy modes, pass the full REST path including /wp-json as query parameter
|
|
42
42
|
const fullEndpoint = `/wp-json${endpoint}?${queryString.toString()}`;
|
|
43
43
|
url = `${baseUrl}?endpoint=${encodeURIComponent(fullEndpoint)}`;
|
|
@@ -63,12 +63,6 @@ class WordPressClient {
|
|
|
63
63
|
headers['CF-Access-Client-Secret'] = this.config.cfAccessClientSecret;
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
|
-
else if (this.config.authMode === 'supabase_proxy') {
|
|
67
|
-
// Add Supabase proxy authentication headers
|
|
68
|
-
if (this.config.supabaseAnonKey) {
|
|
69
|
-
headers['apikey'] = this.config.supabaseAnonKey;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
66
|
else {
|
|
73
67
|
// Direct mode - use basic auth
|
|
74
68
|
if (this.config.username && this.config.password) {
|
|
@@ -124,8 +118,6 @@ class WordPressClient {
|
|
|
124
118
|
switch (this.config.authMode) {
|
|
125
119
|
case 'cloudflare_proxy':
|
|
126
120
|
return this.config.cloudflareWorkerUrl || '';
|
|
127
|
-
case 'supabase_proxy':
|
|
128
|
-
return `${this.config.supabaseUrl}/functions/v1/wp-proxy`;
|
|
129
121
|
default:
|
|
130
122
|
return this.config.apiUrl || '';
|
|
131
123
|
}
|
|
@@ -289,7 +281,7 @@ class GravityFormsClient {
|
|
|
289
281
|
async makeRequest(endpoint, options = {}) {
|
|
290
282
|
// Construct URL based on auth mode
|
|
291
283
|
let url;
|
|
292
|
-
if (this.config.authMode === 'cloudflare_proxy'
|
|
284
|
+
if (this.config.authMode === 'cloudflare_proxy') {
|
|
293
285
|
// For proxy modes, pass the full REST path including /wp-json as query parameter
|
|
294
286
|
const baseUrl = this.getBaseUrl();
|
|
295
287
|
const fullEndpoint = `/wp-json${endpoint}`;
|
|
@@ -317,12 +309,6 @@ class GravityFormsClient {
|
|
|
317
309
|
headers['CF-Access-Client-Secret'] = this.config.cfAccessClientSecret;
|
|
318
310
|
}
|
|
319
311
|
}
|
|
320
|
-
else if (this.config.authMode === 'supabase_proxy') {
|
|
321
|
-
// Add Supabase proxy authentication headers
|
|
322
|
-
if (this.config.supabaseAnonKey) {
|
|
323
|
-
headers['apikey'] = this.config.supabaseAnonKey;
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
312
|
else {
|
|
327
313
|
// Direct mode - use basic auth
|
|
328
314
|
if (this.config.username && this.config.password) {
|
|
@@ -357,29 +343,43 @@ class GravityFormsClient {
|
|
|
357
343
|
switch (this.config.authMode) {
|
|
358
344
|
case 'cloudflare_proxy':
|
|
359
345
|
return this.config.cloudflareWorkerUrl || '';
|
|
360
|
-
case 'supabase_proxy':
|
|
361
|
-
return `${this.config.supabaseUrl}/functions/v1/wp-proxy`;
|
|
362
346
|
default:
|
|
363
347
|
return this.config.apiUrl || '';
|
|
364
348
|
}
|
|
365
349
|
}
|
|
366
350
|
async getForm(id) {
|
|
367
|
-
|
|
351
|
+
// proxy: use enhanced gf-api/v1; direct: use official GF REST v2 (under /wp-json)
|
|
352
|
+
const endpoint = this.config.authMode === 'cloudflare_proxy'
|
|
353
|
+
? `/gf-api/v1/forms/${id}`
|
|
354
|
+
: `/wp-json/gf/v2/forms/${id}`;
|
|
355
|
+
return this.makeRequest(endpoint);
|
|
368
356
|
}
|
|
369
357
|
async getForms() {
|
|
370
|
-
|
|
358
|
+
const endpoint = this.config.authMode === 'cloudflare_proxy'
|
|
359
|
+
? '/gf-api/v1/forms'
|
|
360
|
+
: '/wp-json/gf/v2/forms';
|
|
361
|
+
return this.makeRequest(endpoint);
|
|
371
362
|
}
|
|
372
363
|
async getFormConfig(id) {
|
|
373
|
-
|
|
364
|
+
const endpoint = this.config.authMode === 'cloudflare_proxy'
|
|
365
|
+
? `/gf-api/v1/forms/${id}/config`
|
|
366
|
+
: `/wp-json/gf/v2/forms/${id}`; // v2 returns full form including settings
|
|
367
|
+
return this.makeRequest(endpoint);
|
|
374
368
|
}
|
|
375
369
|
async submitForm(formId, submission) {
|
|
376
|
-
|
|
370
|
+
const endpoint = this.config.authMode === 'cloudflare_proxy'
|
|
371
|
+
? `/gf-api/v1/forms/${formId}/submit`
|
|
372
|
+
: `/wp-json/gf/v2/forms/${formId}/submissions`; // official GF REST v2 submissions
|
|
373
|
+
return this.makeRequest(endpoint, {
|
|
377
374
|
method: 'POST',
|
|
378
375
|
body: JSON.stringify(submission),
|
|
379
376
|
});
|
|
380
377
|
}
|
|
381
378
|
async getHealth() {
|
|
382
|
-
|
|
379
|
+
const endpoint = this.config.authMode === 'cloudflare_proxy'
|
|
380
|
+
? '/gf-api/v1/health'
|
|
381
|
+
: '/wp-json/gf/v2/health';
|
|
382
|
+
return this.makeRequest(endpoint);
|
|
383
383
|
}
|
|
384
384
|
}
|
|
385
385
|
|
|
@@ -2009,6 +2009,102 @@ function useGravityFormsContext() {
|
|
|
2009
2009
|
return context;
|
|
2010
2010
|
}
|
|
2011
2011
|
|
|
2012
|
+
/**
|
|
2013
|
+
* @license GPL-3.0-or-later
|
|
2014
|
+
*
|
|
2015
|
+
* This file is part of the MarVAlt Open SDK.
|
|
2016
|
+
* Copyright (c) 2025 Vibune Pty Ltd.
|
|
2017
|
+
*
|
|
2018
|
+
* This program is free software: you can redistribute it and/or modify
|
|
2019
|
+
* it under the terms of the GNU General Public License as published by
|
|
2020
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
2021
|
+
* (at your option) any later version.
|
|
2022
|
+
*
|
|
2023
|
+
* This program is distributed in the hope that it will be useful,
|
|
2024
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
2025
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
2026
|
+
* See the GNU General Public License for more details.
|
|
2027
|
+
*/
|
|
2028
|
+
let wordpressStaticData = null;
|
|
2029
|
+
async function loadWordPressData(path = '/wordpress-data.json') {
|
|
2030
|
+
try {
|
|
2031
|
+
const res = await fetch(path);
|
|
2032
|
+
if (!res.ok)
|
|
2033
|
+
return null;
|
|
2034
|
+
wordpressStaticData = (await res.json());
|
|
2035
|
+
return wordpressStaticData;
|
|
2036
|
+
}
|
|
2037
|
+
catch {
|
|
2038
|
+
return null;
|
|
2039
|
+
}
|
|
2040
|
+
}
|
|
2041
|
+
function hasWordPressStatic() {
|
|
2042
|
+
return !!wordpressStaticData && Array.isArray(wordpressStaticData.posts);
|
|
2043
|
+
}
|
|
2044
|
+
function getWordPressPosts() {
|
|
2045
|
+
return wordpressStaticData?.posts ?? [];
|
|
2046
|
+
}
|
|
2047
|
+
function getWordPressPages() {
|
|
2048
|
+
return wordpressStaticData?.pages ?? [];
|
|
2049
|
+
}
|
|
2050
|
+
function getWordPressMedia() {
|
|
2051
|
+
return wordpressStaticData?.media ?? [];
|
|
2052
|
+
}
|
|
2053
|
+
function getWordPressCategories() {
|
|
2054
|
+
return wordpressStaticData?.categories ?? [];
|
|
2055
|
+
}
|
|
2056
|
+
function getWordPressTags() {
|
|
2057
|
+
return wordpressStaticData?.tags ?? [];
|
|
2058
|
+
}
|
|
2059
|
+
|
|
2060
|
+
/**
|
|
2061
|
+
* @license GPL-3.0-or-later
|
|
2062
|
+
*
|
|
2063
|
+
* This file is part of the MarVAlt Open SDK.
|
|
2064
|
+
* Copyright (c) 2025 Vibune Pty Ltd.
|
|
2065
|
+
*
|
|
2066
|
+
* This program is free software: you can redistribute it and/or modify
|
|
2067
|
+
* it under the terms of the GNU General Public License as published by
|
|
2068
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
2069
|
+
* (at your option) any later version.
|
|
2070
|
+
*
|
|
2071
|
+
* This program is distributed in the hope that it will be useful,
|
|
2072
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
2073
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
2074
|
+
* See the GNU General Public License for more details.
|
|
2075
|
+
*/
|
|
2076
|
+
let gravityFormsStaticData = null;
|
|
2077
|
+
async function loadGravityFormsData(path = '/gravityForms.json') {
|
|
2078
|
+
try {
|
|
2079
|
+
const res = await fetch(path);
|
|
2080
|
+
if (!res.ok)
|
|
2081
|
+
return null;
|
|
2082
|
+
const json = await res.json();
|
|
2083
|
+
gravityFormsStaticData = {
|
|
2084
|
+
generated_at: json.generated_at,
|
|
2085
|
+
total_forms: json.total_forms,
|
|
2086
|
+
forms: (json.forms ?? []),
|
|
2087
|
+
};
|
|
2088
|
+
return gravityFormsStaticData;
|
|
2089
|
+
}
|
|
2090
|
+
catch {
|
|
2091
|
+
return null;
|
|
2092
|
+
}
|
|
2093
|
+
}
|
|
2094
|
+
function hasGravityFormsStatic() {
|
|
2095
|
+
return !!gravityFormsStaticData && Array.isArray(gravityFormsStaticData.forms);
|
|
2096
|
+
}
|
|
2097
|
+
function getActiveForms() {
|
|
2098
|
+
return (gravityFormsStaticData?.forms ?? []).filter(f => f.is_active === true || f.isActive === true);
|
|
2099
|
+
}
|
|
2100
|
+
function getPublishedForms() {
|
|
2101
|
+
return (gravityFormsStaticData?.forms ?? []).filter(f => f.is_trash === false || f.isPublished === true);
|
|
2102
|
+
}
|
|
2103
|
+
function getFormById(id) {
|
|
2104
|
+
const key = String(id);
|
|
2105
|
+
return (gravityFormsStaticData?.forms ?? []).find(f => String(f.id) === key);
|
|
2106
|
+
}
|
|
2107
|
+
|
|
2012
2108
|
/**
|
|
2013
2109
|
* @license GPL-3.0-or-later
|
|
2014
2110
|
*
|
|
@@ -2317,9 +2413,8 @@ async function generateFormProtectionData(config) {
|
|
|
2317
2413
|
function createWordPressConfig(overrides = {}) {
|
|
2318
2414
|
return {
|
|
2319
2415
|
apiUrl: process.env.VITE_WORDPRESS_API_URL || '',
|
|
2320
|
-
authMode: process.env.
|
|
2416
|
+
authMode: process.env.VITE_AUTH_MODE || 'cloudflare_proxy',
|
|
2321
2417
|
cloudflareWorkerUrl: process.env.VITE_CLOUDFLARE_WORKER_URL,
|
|
2322
|
-
supabaseUrl: process.env.VITE_SUPABASE_URL,
|
|
2323
2418
|
username: process.env.VITE_WP_API_USERNAME,
|
|
2324
2419
|
password: process.env.VITE_WP_APP_PASSWORD,
|
|
2325
2420
|
timeout: 30000,
|
|
@@ -2330,9 +2425,8 @@ function createWordPressConfig(overrides = {}) {
|
|
|
2330
2425
|
function createGravityFormsConfig(overrides = {}) {
|
|
2331
2426
|
return {
|
|
2332
2427
|
apiUrl: process.env.VITE_GRAVITY_FORMS_API_URL || '',
|
|
2333
|
-
authMode: process.env.
|
|
2428
|
+
authMode: process.env.VITE_AUTH_MODE || 'cloudflare_proxy',
|
|
2334
2429
|
cloudflareWorkerUrl: process.env.VITE_CLOUDFLARE_WORKER_URL,
|
|
2335
|
-
supabaseUrl: process.env.VITE_SUPABASE_URL,
|
|
2336
2430
|
username: process.env.VITE_GRAVITY_FORMS_USERNAME || '',
|
|
2337
2431
|
password: process.env.VITE_GRAVITY_FORMS_PASSWORD || '',
|
|
2338
2432
|
timeout: 30000,
|
|
@@ -2360,9 +2454,7 @@ function validateWordPressConfig(config) {
|
|
|
2360
2454
|
if (config.authMode === 'cloudflare_proxy' && !config.cloudflareWorkerUrl) {
|
|
2361
2455
|
errors.push('Cloudflare Worker URL is required for cloudflare_proxy mode');
|
|
2362
2456
|
}
|
|
2363
|
-
|
|
2364
|
-
errors.push('Supabase URL is required for supabase_proxy mode');
|
|
2365
|
-
}
|
|
2457
|
+
// no other proxy modes supported
|
|
2366
2458
|
return errors;
|
|
2367
2459
|
}
|
|
2368
2460
|
function validateGravityFormsConfig(config) {
|
|
@@ -2475,5 +2567,5 @@ function validateFormData(formData, rules) {
|
|
|
2475
2567
|
return { isValid, errors };
|
|
2476
2568
|
}
|
|
2477
2569
|
|
|
2478
|
-
export { FormProtectionGenerator, GravityForm, GravityFormsClient, GravityFormsGenerator, GravityFormsProvider, WordPressClient, WordPressContent, WordPressGenerator, WordPressProvider, createFormProtectionConfig, createGravityFormsConfig, createWordPressConfig, generateFormProtectionData, generateGravityFormsData, generateWordPressData, sanitizeHtml, transformWordPressMedia, transformWordPressMediaItems, transformWordPressPage, transformWordPressPages, transformWordPressPost, transformWordPressPosts, useGravityForms, useGravityFormsConfig, useGravityFormsContext, useWordPress, useWordPressCategories, useWordPressContext, useWordPressMedia, useWordPressPage, useWordPressPages, useWordPressPost, useWordPressPosts, useWordPressTags, validateEmail, validateFormData, validateFormProtectionConfig, validateGravityFormsConfig, validateMaxLength, validateMinLength, validatePhoneNumber, validateRequired, validateUrl, validateWordPressConfig };
|
|
2570
|
+
export { FormProtectionGenerator, GravityForm, GravityFormsClient, GravityFormsGenerator, GravityFormsProvider, WordPressClient, WordPressContent, WordPressGenerator, WordPressProvider, createFormProtectionConfig, createGravityFormsConfig, createWordPressConfig, generateFormProtectionData, generateGravityFormsData, generateWordPressData, getActiveForms, getFormById, getPublishedForms, getWordPressCategories, getWordPressMedia, getWordPressPages, getWordPressPosts, getWordPressTags, hasGravityFormsStatic, hasWordPressStatic, loadGravityFormsData, loadWordPressData, sanitizeHtml, transformWordPressMedia, transformWordPressMediaItems, transformWordPressPage, transformWordPressPages, transformWordPressPost, transformWordPressPosts, useGravityForms, useGravityFormsConfig, useGravityFormsContext, useWordPress, useWordPressCategories, useWordPressContext, useWordPressMedia, useWordPressPage, useWordPressPages, useWordPressPost, useWordPressPosts, useWordPressTags, validateEmail, validateFormData, validateFormProtectionConfig, validateGravityFormsConfig, validateMaxLength, validateMinLength, validatePhoneNumber, validateRequired, validateUrl, validateWordPressConfig };
|
|
2479
2571
|
//# sourceMappingURL=index.esm.js.map
|