@marvalt/madapter 1.0.14
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 +28 -0
- package/README.md +422 -0
- package/dist/client/mautic-client.d.ts +88 -0
- package/dist/client/mautic-client.d.ts.map +1 -0
- package/dist/data/mautic-data-store.d.ts +84 -0
- package/dist/data/mautic-data-store.d.ts.map +1 -0
- package/dist/generators/mautic-generator.d.ts +48 -0
- package/dist/generators/mautic-generator.d.ts.map +1 -0
- package/dist/index.cjs +3199 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +770 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.esm.js +3141 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/react/components/MauticForm.d.ts +31 -0
- package/dist/react/components/MauticForm.d.ts.map +1 -0
- package/dist/react/components/MauticTracking.d.ts +42 -0
- package/dist/react/components/MauticTracking.d.ts.map +1 -0
- package/dist/react/hooks/useMautic.d.ts +98 -0
- package/dist/react/hooks/useMautic.d.ts.map +1 -0
- package/dist/react/providers/MauticProvider.d.ts +42 -0
- package/dist/react/providers/MauticProvider.d.ts.map +1 -0
- package/dist/service/mautic-service.d.ts +40 -0
- package/dist/service/mautic-service.d.ts.map +1 -0
- package/dist/setupTests.d.ts +18 -0
- package/dist/setupTests.d.ts.map +1 -0
- package/dist/types/config.d.ts +46 -0
- package/dist/types/config.d.ts.map +1 -0
- package/dist/types/mautic.d.ts +108 -0
- package/dist/types/mautic.d.ts.map +1 -0
- package/dist/types/static-data.d.ts +59 -0
- package/dist/types/static-data.d.ts.map +1 -0
- package/dist/utils/config.d.ts +54 -0
- package/dist/utils/config.d.ts.map +1 -0
- package/dist/utils/validation.d.ts +58 -0
- package/dist/utils/validation.d.ts.map +1 -0
- package/package.json +90 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
GPL-3.0-or-later
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Vibune Pty Ltd.
|
|
4
|
+
|
|
5
|
+
This program is free software: you can redistribute it and/or modify
|
|
6
|
+
it under the terms of the GNU General Public License as published by
|
|
7
|
+
the Free Software Foundation, either version 3 of the License, or
|
|
8
|
+
(at your option) any later version.
|
|
9
|
+
|
|
10
|
+
This program is distributed in the hope that it will be useful,
|
|
11
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
GNU General Public License for more details.
|
|
14
|
+
|
|
15
|
+
You should have received a copy of the GNU General Public License
|
|
16
|
+
along with this program. If not, see https://www.gnu.org/licenses/.
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
package/README.md
ADDED
|
@@ -0,0 +1,422 @@
|
|
|
1
|
+
# madapter
|
|
2
|
+
|
|
3
|
+
A MarVAlt adapter for Mautic marketing automation in React, with static data generation support.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- π **Mautic API Client** - Full-featured client for Mautic API operations
|
|
8
|
+
- π **Dynamic Form Rendering** - Render Mautic forms dynamically in React
|
|
9
|
+
- π **Static Data Generation** - Generate static JSON files for build-time data
|
|
10
|
+
- π― **Event Tracking** - Mautic tracking script integration with proxy support
|
|
11
|
+
- π§ **React Hooks** - Comprehensive React Query hooks for all Mautic operations
|
|
12
|
+
- π‘οΈ **TypeScript Support** - Full TypeScript support with comprehensive type definitions
|
|
13
|
+
- π **Authentication Modes** - Support for Cloudflare Worker proxy and direct API access
|
|
14
|
+
- β
**Form Validation** - Client-side validation with customizable rules
|
|
15
|
+
- π¨ **Customizable Components** - Flexible and customizable React components
|
|
16
|
+
|
|
17
|
+
## Installation
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npm install @marvalt/madapter
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### Peer Dependencies
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
npm install @tanstack/react-query react react-dom
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Quick Start
|
|
30
|
+
|
|
31
|
+
### 1. Environment Configuration
|
|
32
|
+
|
|
33
|
+
Use the same auth mode variable used by all integrations: `VITE_AUTH_MODE`.
|
|
34
|
+
|
|
35
|
+
Create `.env` (nonβsecret):
|
|
36
|
+
```bash
|
|
37
|
+
# Global auth mode used across integrations
|
|
38
|
+
VITE_AUTH_MODE=cloudflare_proxy # or direct (dev only)
|
|
39
|
+
|
|
40
|
+
# Mautic via Cloudflare Worker proxy
|
|
41
|
+
VITE_MAUTIC_PROXY_URL=https://your-mautic-proxy.workers.dev
|
|
42
|
+
|
|
43
|
+
# Frontend app identity used by the Worker for auth headers
|
|
44
|
+
VITE_FRONTEND_ID=your-app-id
|
|
45
|
+
VITE_FRONTEND_SECRET=your-worker-secret
|
|
46
|
+
|
|
47
|
+
# Mautic OAuth client credentials (typically configured on the Worker)
|
|
48
|
+
# Add here only if your tooling expects them documented in the app env.
|
|
49
|
+
VITE_MAUTIC_API_PUBLIC_KEY=your-mautic-api-public-key
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Create `.env.local` (secrets for local dev only):
|
|
53
|
+
```bash
|
|
54
|
+
# Secret OAuth key (usually a Worker secret, optional in app env)
|
|
55
|
+
VITE_MAUTIC_API_SECRET_KEY=your-mautic-api-secret-key
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Notes:
|
|
59
|
+
- In proxy mode, the Worker reads `MAUTIC_API_PUBLIC_KEY` and `MAUTIC_API_SECRET_KEY` from its own environment.
|
|
60
|
+
- The frontend sends `x-app-id` and `x-worker-secret` headers; the client sets these automatically.
|
|
61
|
+
|
|
62
|
+
### 2. React Query Setup
|
|
63
|
+
|
|
64
|
+
```tsx
|
|
65
|
+
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
|
66
|
+
|
|
67
|
+
const queryClient = new QueryClient();
|
|
68
|
+
|
|
69
|
+
function App() {
|
|
70
|
+
return (
|
|
71
|
+
<QueryClientProvider client={queryClient}>
|
|
72
|
+
{/* Your app components */}
|
|
73
|
+
</QueryClientProvider>
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
The client autoβconfigures from `import.meta.env`/`process.env`. If you prefer explicit configuration, wrap your app with the provider exported by the package and pass the config fields shown above.
|
|
79
|
+
|
|
80
|
+
### 3. Form Rendering (recommended)
|
|
81
|
+
|
|
82
|
+
```tsx
|
|
83
|
+
import { MauticForm } from '@marvalt/madapter';
|
|
84
|
+
|
|
85
|
+
function ContactPage() {
|
|
86
|
+
return (
|
|
87
|
+
<div>
|
|
88
|
+
<h1>Contact Us</h1>
|
|
89
|
+
<MauticForm
|
|
90
|
+
formId="1"
|
|
91
|
+
title="Get in Touch"
|
|
92
|
+
description="Send us a message and we'll get back to you soon."
|
|
93
|
+
onSuccess={(data) => console.log('Form submitted:', data)}
|
|
94
|
+
onError={(error) => console.error('Form error:', error)}
|
|
95
|
+
/>
|
|
96
|
+
</div>
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### 4. Event Tracking
|
|
102
|
+
|
|
103
|
+
```tsx
|
|
104
|
+
import { MauticTracking } from '@marvalt/madapter';
|
|
105
|
+
|
|
106
|
+
function App() {
|
|
107
|
+
return (
|
|
108
|
+
<MauticTracking
|
|
109
|
+
enabled={true}
|
|
110
|
+
proxyUrl={process.env.VITE_MAUTIC_PROXY_URL}
|
|
111
|
+
appId={process.env.VITE_FRONTEND_ID}
|
|
112
|
+
workerSecret={process.env.VITE_FRONTEND_SECRET}
|
|
113
|
+
>
|
|
114
|
+
{/* Your app content */}
|
|
115
|
+
</MauticTracking>
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
## Static Data Generation
|
|
121
|
+
|
|
122
|
+
### 1. Create Generation Script
|
|
123
|
+
|
|
124
|
+
```typescript
|
|
125
|
+
// scripts/generateMauticData.ts
|
|
126
|
+
import { generateMauticData } from '@marvalt/madapter';
|
|
127
|
+
|
|
128
|
+
async function generateData() {
|
|
129
|
+
try {
|
|
130
|
+
const staticData = await generateMauticData({
|
|
131
|
+
authMode: 'cloudflare_proxy',
|
|
132
|
+
cloudflareWorkerUrl: process.env.VITE_MAUTIC_PROXY_URL,
|
|
133
|
+
appId: process.env.VITE_FRONTEND_ID,
|
|
134
|
+
workerSecret: process.env.VITE_FRONTEND_SECRET,
|
|
135
|
+
outputPath: './src/data/mautic-data.json',
|
|
136
|
+
includeInactive: false,
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
console.log(`Generated data for ${staticData.total_forms} forms`);
|
|
140
|
+
} catch (error) {
|
|
141
|
+
console.error('Error generating Mautic data:', error);
|
|
142
|
+
process.exit(1);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
generateData();
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
### 2. Update package.json
|
|
150
|
+
|
|
151
|
+
```json
|
|
152
|
+
{
|
|
153
|
+
"scripts": {
|
|
154
|
+
"generate:mautic-data": "tsx scripts/generateMauticData.ts",
|
|
155
|
+
"build": "npm run generate:mautic-data && vite build"
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
## React Hooks
|
|
161
|
+
|
|
162
|
+
### Form Submission
|
|
163
|
+
|
|
164
|
+
```tsx
|
|
165
|
+
import { useMauticFormSubmission } from '@marvalt/madapter';
|
|
166
|
+
|
|
167
|
+
function CustomForm() {
|
|
168
|
+
const submitMutation = useMauticFormSubmission();
|
|
169
|
+
|
|
170
|
+
const handleSubmit = async (formData) => {
|
|
171
|
+
try {
|
|
172
|
+
await submitMutation.mutateAsync({
|
|
173
|
+
formId: 1,
|
|
174
|
+
fields: formData,
|
|
175
|
+
returnUrl: window.location.href,
|
|
176
|
+
});
|
|
177
|
+
console.log('Form submitted successfully!');
|
|
178
|
+
} catch (error) {
|
|
179
|
+
console.error('Form submission failed:', error);
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
return (
|
|
184
|
+
<form onSubmit={handleSubmit}>
|
|
185
|
+
{/* Your form fields */}
|
|
186
|
+
</form>
|
|
187
|
+
);
|
|
188
|
+
}
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
### Contact Management
|
|
192
|
+
|
|
193
|
+
```tsx
|
|
194
|
+
import { useMauticCreateContact, useMauticContactByEmail } from '@marvalt/madapter';
|
|
195
|
+
|
|
196
|
+
function ContactManager() {
|
|
197
|
+
const createMutation = useMauticCreateContact();
|
|
198
|
+
const { data: contact } = useMauticContactByEmail('user@example.com');
|
|
199
|
+
|
|
200
|
+
const handleCreateContact = async (contactData) => {
|
|
201
|
+
await createMutation.mutateAsync({
|
|
202
|
+
email: contactData.email,
|
|
203
|
+
firstname: contactData.firstName,
|
|
204
|
+
lastname: contactData.lastName,
|
|
205
|
+
});
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
return (
|
|
209
|
+
<div>
|
|
210
|
+
{contact && <p>Contact found: {contact.data?.firstname}</p>}
|
|
211
|
+
{/* Your contact management UI */}
|
|
212
|
+
</div>
|
|
213
|
+
);
|
|
214
|
+
}
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
### Event Tracking
|
|
218
|
+
|
|
219
|
+
```tsx
|
|
220
|
+
import { useMauticEventTracking } from '@marvalt/madapter';
|
|
221
|
+
|
|
222
|
+
function ProductPage() {
|
|
223
|
+
const trackEvent = useMauticEventTracking();
|
|
224
|
+
|
|
225
|
+
const handleProductView = () => {
|
|
226
|
+
trackEvent.mutate({
|
|
227
|
+
email: 'user@example.com',
|
|
228
|
+
eventName: 'product_view',
|
|
229
|
+
eventData: { productId: '123', category: 'electronics' },
|
|
230
|
+
});
|
|
231
|
+
};
|
|
232
|
+
|
|
233
|
+
return (
|
|
234
|
+
<div>
|
|
235
|
+
<button onClick={handleProductView}>Track Product View</button>
|
|
236
|
+
</div>
|
|
237
|
+
);
|
|
238
|
+
}
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
## API Reference
|
|
242
|
+
|
|
243
|
+
### MauticClient
|
|
244
|
+
|
|
245
|
+
```typescript
|
|
246
|
+
import { MauticClient } from '@marvalt/madapter';
|
|
247
|
+
|
|
248
|
+
const client = new MauticClient({
|
|
249
|
+
authMode: 'cloudflare_proxy',
|
|
250
|
+
cloudflareWorkerUrl: 'https://proxy.workers.dev',
|
|
251
|
+
appId: 'your-app-id',
|
|
252
|
+
workerSecret: 'your-secret',
|
|
253
|
+
});
|
|
254
|
+
|
|
255
|
+
// Form operations
|
|
256
|
+
await client.submitForm(1, { formId: 1, fields: { email: 'test@example.com' } });
|
|
257
|
+
await client.getForms();
|
|
258
|
+
await client.getForm(1);
|
|
259
|
+
|
|
260
|
+
// Contact operations
|
|
261
|
+
await client.createContact({ email: 'test@example.com', firstname: 'Test' });
|
|
262
|
+
await client.updateContact(1, { firstname: 'Updated' });
|
|
263
|
+
await client.getContactByEmail('test@example.com');
|
|
264
|
+
|
|
265
|
+
// Event tracking
|
|
266
|
+
await client.trackEvent('page_view', { page: '/home' });
|
|
267
|
+
|
|
268
|
+
// Tag management
|
|
269
|
+
await client.addTagToContact(1, ['newsletter', 'premium']);
|
|
270
|
+
await client.removeTagFromContact(1, ['newsletter']);
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
### Configuration
|
|
274
|
+
|
|
275
|
+
```typescript
|
|
276
|
+
interface MauticConfig {
|
|
277
|
+
authMode: 'cloudflare_proxy' | 'direct';
|
|
278
|
+
apiUrl?: string; // Required for direct mode
|
|
279
|
+
cloudflareWorkerUrl?: string; // Required for proxy mode
|
|
280
|
+
appId?: string; // Required for proxy mode
|
|
281
|
+
workerSecret?: string; // Required for proxy mode
|
|
282
|
+
timeout?: number; // Default: 30000ms
|
|
283
|
+
retries?: number; // Default: 3
|
|
284
|
+
}
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
## Authentication Modes
|
|
288
|
+
|
|
289
|
+
### Cloudflare Worker Proxy (Recommended)
|
|
290
|
+
|
|
291
|
+
```typescript
|
|
292
|
+
const config = {
|
|
293
|
+
authMode: 'cloudflare_proxy',
|
|
294
|
+
cloudflareWorkerUrl: 'https://your-proxy.workers.dev',
|
|
295
|
+
appId: 'your-frontend-id',
|
|
296
|
+
workerSecret: 'your-worker-secret',
|
|
297
|
+
};
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
### Direct API Access (Legacy)
|
|
301
|
+
|
|
302
|
+
```typescript
|
|
303
|
+
const config = {
|
|
304
|
+
authMode: 'direct',
|
|
305
|
+
apiUrl: 'https://your-mautic-instance.com',
|
|
306
|
+
};
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
## Form Field Types
|
|
310
|
+
|
|
311
|
+
The package supports all standard Mautic field types:
|
|
312
|
+
|
|
313
|
+
- `text` - Text input
|
|
314
|
+
- `email` - Email input with validation
|
|
315
|
+
- `tel` - Phone number input
|
|
316
|
+
- `url` - URL input
|
|
317
|
+
- `textarea` - Multi-line text input
|
|
318
|
+
- `select` - Dropdown selection
|
|
319
|
+
- `checkbox` - Single checkbox
|
|
320
|
+
- `radio` - Radio button group
|
|
321
|
+
|
|
322
|
+
## Customization
|
|
323
|
+
|
|
324
|
+
### Custom Form Styling
|
|
325
|
+
|
|
326
|
+
```tsx
|
|
327
|
+
<MauticForm
|
|
328
|
+
formId="1"
|
|
329
|
+
className="custom-form"
|
|
330
|
+
// Custom CSS classes will be applied to form elements
|
|
331
|
+
/>
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
### Custom Validation
|
|
335
|
+
|
|
336
|
+
```typescript
|
|
337
|
+
import { validateField } from '@marvalt/madapter';
|
|
338
|
+
|
|
339
|
+
const customValidation = (field, value) => {
|
|
340
|
+
const baseError = validateField(field, value);
|
|
341
|
+
if (baseError) return baseError;
|
|
342
|
+
|
|
343
|
+
// Add custom validation logic
|
|
344
|
+
if (field.alias === 'custom_field' && value.length < 5) {
|
|
345
|
+
return 'Custom field must be at least 5 characters';
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
return null;
|
|
349
|
+
};
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
## Error Handling & Common Pitfalls
|
|
353
|
+
|
|
354
|
+
```tsx
|
|
355
|
+
import { MauticForm } from '@marvalt/madapter';
|
|
356
|
+
|
|
357
|
+
function FormWithErrorHandling() {
|
|
358
|
+
const handleError = (error) => {
|
|
359
|
+
console.error('Form submission error:', error);
|
|
360
|
+
// Custom error handling logic
|
|
361
|
+
};
|
|
362
|
+
|
|
363
|
+
return (
|
|
364
|
+
<MauticForm
|
|
365
|
+
formId="1"
|
|
366
|
+
onError={handleError}
|
|
367
|
+
onSuccess={(data) => console.log('Success:', data)}
|
|
368
|
+
/>
|
|
369
|
+
);
|
|
370
|
+
}
|
|
371
|
+
```
|
|
372
|
+
|
|
373
|
+
Tips to avoid errors:
|
|
374
|
+
|
|
375
|
+
- 404/HTML after submit: Some Mautic setups return an HTML page (even 404) after a successful submit. The client treats this as success. If you implement custom submission, do not rely on server redirects; handle redirects clientβside using the formβs configured `postAction`.
|
|
376
|
+
- Redirects: Prefer clientβside redirects. The client sets `mauticform[return]` to an empty string and performs the redirect on the frontend.
|
|
377
|
+
- Dev tracking: Tracking is disabled in `VITE_DEV`/development builds by design; donβt expect `mtc.js` to load locally.
|
|
378
|
+
- Proxy headers: In proxy mode the client sends `x-app-id` and `x-worker-secret` automatically. Ensure `VITE_FRONTEND_ID` and `VITE_FRONTEND_SECRET` are set.
|
|
379
|
+
- Forms data: If you reference a form ID that doesnβt exist in your Mautic instance, youβll receive a 404 from the API. Use the static data generator or fetch `/forms` via the Worker to confirm IDs.
|
|
380
|
+
|
|
381
|
+
## Development
|
|
382
|
+
|
|
383
|
+
### Building the Package
|
|
384
|
+
|
|
385
|
+
```bash
|
|
386
|
+
npm run build
|
|
387
|
+
```
|
|
388
|
+
|
|
389
|
+
### Running Tests
|
|
390
|
+
|
|
391
|
+
```bash
|
|
392
|
+
npm test
|
|
393
|
+
npm run test:watch
|
|
394
|
+
npm run test:coverage
|
|
395
|
+
```
|
|
396
|
+
|
|
397
|
+
### Linting
|
|
398
|
+
|
|
399
|
+
```bash
|
|
400
|
+
npm run lint
|
|
401
|
+
npm run lint:fix
|
|
402
|
+
```
|
|
403
|
+
|
|
404
|
+
## License
|
|
405
|
+
|
|
406
|
+
GPL-3.0-or-later. See LICENSE.
|
|
407
|
+
|
|
408
|
+
## Support
|
|
409
|
+
|
|
410
|
+
For support and questions, please contact:
|
|
411
|
+
- Email: support@vibune.com
|
|
412
|
+
- Documentation: [GitHub Repository](https://github.com/MarVAlt/madapter)
|
|
413
|
+
|
|
414
|
+
## Changelog
|
|
415
|
+
|
|
416
|
+
### 1.0.0
|
|
417
|
+
- Initial release
|
|
418
|
+
- Mautic API client
|
|
419
|
+
- React components and hooks
|
|
420
|
+
- Static data generation
|
|
421
|
+
- Event tracking
|
|
422
|
+
- TypeScript support
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license GPL-3.0-or-later
|
|
3
|
+
*
|
|
4
|
+
* This file is part of the MarVAlt Open SDK.
|
|
5
|
+
* Copyright (c) 2025 Vibune Pty Ltd.
|
|
6
|
+
*
|
|
7
|
+
* This program is free software: you can redistribute it and/or modify
|
|
8
|
+
* it under the terms of the GNU General Public License as published by
|
|
9
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
10
|
+
* (at your option) any later version.
|
|
11
|
+
*
|
|
12
|
+
* This program is distributed in the hope that it will be useful,
|
|
13
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
14
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
15
|
+
* See the GNU General Public License for more details.
|
|
16
|
+
*/
|
|
17
|
+
import { MauticConfig } from '../types/config';
|
|
18
|
+
import { MauticContact, MauticFormSubmission, MauticForm, MauticApiResponse } from '../types/mautic';
|
|
19
|
+
export declare class MauticClient {
|
|
20
|
+
private baseUrl;
|
|
21
|
+
private proxyUrl?;
|
|
22
|
+
private appId?;
|
|
23
|
+
private workerSecret?;
|
|
24
|
+
private useProxy;
|
|
25
|
+
private isConfigured;
|
|
26
|
+
private config;
|
|
27
|
+
constructor(config: MauticConfig);
|
|
28
|
+
private validateConfiguration;
|
|
29
|
+
private getAuthHeaders;
|
|
30
|
+
private makeRequest;
|
|
31
|
+
/**
|
|
32
|
+
* Submit a form to Mautic
|
|
33
|
+
*/
|
|
34
|
+
submitForm(formId: number, submission: MauticFormSubmission): Promise<MauticApiResponse>;
|
|
35
|
+
/**
|
|
36
|
+
* Create a new contact in Mautic
|
|
37
|
+
*/
|
|
38
|
+
createContact(contact: MauticContact): Promise<MauticApiResponse>;
|
|
39
|
+
/**
|
|
40
|
+
* Update an existing contact in Mautic
|
|
41
|
+
*/
|
|
42
|
+
updateContact(contactId: number, contact: Partial<MauticContact>): Promise<MauticApiResponse>;
|
|
43
|
+
/**
|
|
44
|
+
* Get a contact by email
|
|
45
|
+
*/
|
|
46
|
+
getContactByEmail(email: string): Promise<MauticApiResponse>;
|
|
47
|
+
/**
|
|
48
|
+
* Get all forms from Mautic
|
|
49
|
+
*/
|
|
50
|
+
getForms(): Promise<MauticForm[]>;
|
|
51
|
+
/**
|
|
52
|
+
* Get a specific form by ID
|
|
53
|
+
*/
|
|
54
|
+
getForm(formId: number): Promise<MauticForm>;
|
|
55
|
+
/**
|
|
56
|
+
* Track an event in Mautic
|
|
57
|
+
*/
|
|
58
|
+
trackEvent(eventName: string, eventData?: Record<string, any>): Promise<MauticApiResponse>;
|
|
59
|
+
/**
|
|
60
|
+
* Add tags to a contact
|
|
61
|
+
*/
|
|
62
|
+
addTagToContact(contactId: number, tags: string[]): Promise<MauticApiResponse>;
|
|
63
|
+
/**
|
|
64
|
+
* Remove tags from a contact
|
|
65
|
+
*/
|
|
66
|
+
removeTagFromContact(contactId: number, tags: string[]): Promise<MauticApiResponse>;
|
|
67
|
+
/**
|
|
68
|
+
* Get contact tags
|
|
69
|
+
*/
|
|
70
|
+
getContactTags(contactId: number): Promise<MauticApiResponse>;
|
|
71
|
+
/**
|
|
72
|
+
* Get all tags
|
|
73
|
+
*/
|
|
74
|
+
getTags(): Promise<MauticApiResponse>;
|
|
75
|
+
/**
|
|
76
|
+
* Get segments
|
|
77
|
+
*/
|
|
78
|
+
getSegments(): Promise<MauticApiResponse>;
|
|
79
|
+
/**
|
|
80
|
+
* Add contact to segment
|
|
81
|
+
*/
|
|
82
|
+
addContactToSegment(contactId: number, segmentId: number): Promise<MauticApiResponse>;
|
|
83
|
+
/**
|
|
84
|
+
* Remove contact from segment
|
|
85
|
+
*/
|
|
86
|
+
removeContactFromSegment(contactId: number, segmentId: number): Promise<MauticApiResponse>;
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=mautic-client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mautic-client.d.ts","sourceRoot":"","sources":["../../src/client/mautic-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,YAAY,EAAY,MAAM,iBAAiB,CAAC;AACzD,OAAO,EACL,aAAa,EACb,oBAAoB,EACpB,UAAU,EAGV,iBAAiB,EAClB,MAAM,iBAAiB,CAAC;AAEzB,qBAAa,YAAY;IACvB,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,QAAQ,CAAC,CAAS;IAC1B,OAAO,CAAC,KAAK,CAAC,CAAS;IACvB,OAAO,CAAC,YAAY,CAAC,CAAS;IAC9B,OAAO,CAAC,QAAQ,CAAU;IAC1B,OAAO,CAAC,YAAY,CAAU;IAC9B,OAAO,CAAC,MAAM,CAAe;gBAEjB,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AAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAO3F;;OAEG;IACG,wBAAwB,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC;CAMjG"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license GPL-3.0-or-later
|
|
3
|
+
*
|
|
4
|
+
* This file is part of the MarVAlt Open SDK.
|
|
5
|
+
* Copyright (c) 2025 Vibune Pty Ltd.
|
|
6
|
+
*
|
|
7
|
+
* This program is free software: you can redistribute it and/or modify
|
|
8
|
+
* it under the terms of the GNU General Public License as published by
|
|
9
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
10
|
+
* (at your option) any later version.
|
|
11
|
+
*
|
|
12
|
+
* This program is distributed in the hope that it will be useful,
|
|
13
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
14
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
15
|
+
* See the GNU General Public License for more details.
|
|
16
|
+
*/
|
|
17
|
+
import { MauticForm, MauticFormField } from '../types/mautic';
|
|
18
|
+
export interface MauticDataStore {
|
|
19
|
+
generated_at: string;
|
|
20
|
+
forms: MauticForm[];
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Load Mautic data from JSON file
|
|
24
|
+
*/
|
|
25
|
+
export declare const loadMauticData: () => Promise<MauticDataStore>;
|
|
26
|
+
/**
|
|
27
|
+
* Get the current Mautic data store
|
|
28
|
+
*/
|
|
29
|
+
export declare const getMauticData: () => MauticDataStore;
|
|
30
|
+
/**
|
|
31
|
+
* Get all published forms
|
|
32
|
+
*/
|
|
33
|
+
export declare const getPublishedForms: () => MauticForm[];
|
|
34
|
+
/**
|
|
35
|
+
* Get form by ID
|
|
36
|
+
*/
|
|
37
|
+
export declare const getFormById: (id: number) => MauticForm | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* Get form by alias
|
|
40
|
+
*/
|
|
41
|
+
export declare const getFormByAlias: (alias: string) => MauticForm | undefined;
|
|
42
|
+
/**
|
|
43
|
+
* Get forms by type
|
|
44
|
+
*/
|
|
45
|
+
export declare const getFormsByType: (type: string) => MauticForm[];
|
|
46
|
+
/**
|
|
47
|
+
* Get forms by field type
|
|
48
|
+
*/
|
|
49
|
+
export declare const getFormsByFieldType: (fieldType: string) => MauticForm[];
|
|
50
|
+
/**
|
|
51
|
+
* Search forms by name or description
|
|
52
|
+
*/
|
|
53
|
+
export declare const searchForms: (query: string) => MauticForm[];
|
|
54
|
+
/**
|
|
55
|
+
* Get form field by alias
|
|
56
|
+
*/
|
|
57
|
+
export declare const getFormFieldByAlias: (formId: number, fieldAlias: string) => MauticFormField | undefined;
|
|
58
|
+
/**
|
|
59
|
+
* Get all unique field types across all forms
|
|
60
|
+
*/
|
|
61
|
+
export declare const getAllFieldTypes: () => string[];
|
|
62
|
+
/**
|
|
63
|
+
* Get forms count by status
|
|
64
|
+
*/
|
|
65
|
+
export declare const getFormsCountByStatus: () => {
|
|
66
|
+
total: number;
|
|
67
|
+
published: number;
|
|
68
|
+
unpublished: number;
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* Check if data store is loaded
|
|
72
|
+
*/
|
|
73
|
+
export declare const isDataLoaded: () => boolean;
|
|
74
|
+
/**
|
|
75
|
+
* Get data store metadata
|
|
76
|
+
*/
|
|
77
|
+
export declare const getDataMetadata: () => {
|
|
78
|
+
generated_at: string;
|
|
79
|
+
total_forms: number;
|
|
80
|
+
published_forms: number;
|
|
81
|
+
field_types: string[];
|
|
82
|
+
form_types: (string | undefined)[];
|
|
83
|
+
};
|
|
84
|
+
//# sourceMappingURL=mautic-data-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mautic-data-store.d.ts","sourceRoot":"","sources":["../../src/data/mautic-data-store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;G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
|
|
5
|
+
* Copyright (c) 2025 Vibune Pty Ltd.
|
|
6
|
+
*
|
|
7
|
+
* This program is free software: you can redistribute it and/or modify
|
|
8
|
+
* it under the terms of the GNU General Public License as published by
|
|
9
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
10
|
+
* (at your option) any later version.
|
|
11
|
+
*
|
|
12
|
+
* This program is distributed in the hope that it will be useful,
|
|
13
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
14
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
15
|
+
* See the GNU General Public License for more details.
|
|
16
|
+
*/
|
|
17
|
+
import { MauticGeneratorConfig } from '../types/config';
|
|
18
|
+
import { MauticStaticData } from '../types/static-data';
|
|
19
|
+
export declare class MauticGenerator {
|
|
20
|
+
private client;
|
|
21
|
+
private config;
|
|
22
|
+
constructor(config: MauticGeneratorConfig);
|
|
23
|
+
/**
|
|
24
|
+
* Generate static data for Mautic forms
|
|
25
|
+
*/
|
|
26
|
+
generateStaticData(): Promise<MauticStaticData>;
|
|
27
|
+
/**
|
|
28
|
+
* Write static data to file
|
|
29
|
+
*/
|
|
30
|
+
writeStaticData(staticData: MauticStaticData): Promise<void>;
|
|
31
|
+
/**
|
|
32
|
+
* Generate and write static data
|
|
33
|
+
*/
|
|
34
|
+
generateAndWrite(): Promise<MauticStaticData>;
|
|
35
|
+
/**
|
|
36
|
+
* Fetch list of forms from Mautic
|
|
37
|
+
*/
|
|
38
|
+
private fetchMauticFormsList;
|
|
39
|
+
/**
|
|
40
|
+
* Fetch individual form details from Mautic
|
|
41
|
+
*/
|
|
42
|
+
private fetchMauticForm;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Generate Mautic static data with configuration
|
|
46
|
+
*/
|
|
47
|
+
export declare function generateMauticData(config: MauticGeneratorConfig): Promise<MauticStaticData>;
|
|
48
|
+
//# sourceMappingURL=mautic-generator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mautic-generator.d.ts","sourceRoot":"","sources":["../../src/generators/mautic-generator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAIH,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAkB,MAAM,sBAAsB,CAAC;AAGxE,qBAAa,eAAe;IAC1B,OAAO,CAAC,MAAM,CAAe;IAC7B,OAAO,CAAC,MAAM,CAAwB;gBAE1B,MAAM,EAAE,qBAAqB;IAazC;;OAEG;IACG,kBAAkB,IAAI,OAAO,CAAC,gBAAgB,CAAC;IA2GrD;;OAEG;IACG,eAAe,CAAC,UAAU,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC;IAclE;;OAEG;IACG,gBAAgB,IAAI,OAAO,CAAC,gBAAgB,CAAC;IAMnD;;OAEG;YACW,oBAAoB;IA2BlC;;OAEG;YACW,eAAe;CAwB9B;AAED;;GAEG;AACH,wBAAsB,kBAAkB,CAAC,MAAM,EAAE,qBAAqB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAGjG"}
|