@marvalt/madapter 2.2.2 → 2.3.2
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/generators/index.d.ts +24 -0
- package/dist/generators/index.d.ts.map +1 -0
- package/dist/generators.cjs +462 -0
- package/dist/generators.cjs.map +1 -0
- package/dist/generators.esm.js +459 -0
- package/dist/generators.esm.js.map +1 -0
- package/dist/index.cjs +0 -244
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +60 -112
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +1 -243
- package/dist/index.esm.js.map +1 -1
- package/package.json +5 -1
package/dist/index.d.ts
CHANGED
|
@@ -281,117 +281,6 @@ declare class MauticService {
|
|
|
281
281
|
}
|
|
282
282
|
declare let mauticService: MauticService | null;
|
|
283
283
|
|
|
284
|
-
/**
|
|
285
|
-
* @license GPL-3.0-or-later
|
|
286
|
-
*
|
|
287
|
-
* This file is part of the MarVAlt Open SDK.
|
|
288
|
-
* Copyright (c) 2025 Vibune Pty Ltd.
|
|
289
|
-
*
|
|
290
|
-
* This program is free software: you can redistribute it and/or modify
|
|
291
|
-
* it under the terms of the GNU General Public License as published by
|
|
292
|
-
* the Free Software Foundation, either version 3 of the License, or
|
|
293
|
-
* (at your option) any later version.
|
|
294
|
-
*
|
|
295
|
-
* This program is distributed in the hope that it will be useful,
|
|
296
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
297
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
298
|
-
* See the GNU General Public License for more details.
|
|
299
|
-
*/
|
|
300
|
-
|
|
301
|
-
interface MauticStaticData {
|
|
302
|
-
generated_at: string;
|
|
303
|
-
total_forms: number;
|
|
304
|
-
forms: MauticForm$1[];
|
|
305
|
-
}
|
|
306
|
-
interface MauticFormData {
|
|
307
|
-
id: string;
|
|
308
|
-
name: string;
|
|
309
|
-
description?: string;
|
|
310
|
-
isPublished: boolean;
|
|
311
|
-
postAction?: string;
|
|
312
|
-
postActionProperty?: string;
|
|
313
|
-
formType?: string;
|
|
314
|
-
fields: Array<{
|
|
315
|
-
id: number;
|
|
316
|
-
label: string;
|
|
317
|
-
alias: string;
|
|
318
|
-
type: string;
|
|
319
|
-
isRequired: boolean;
|
|
320
|
-
validationMessage?: string;
|
|
321
|
-
defaultValue?: string;
|
|
322
|
-
properties?: {
|
|
323
|
-
placeholder?: string;
|
|
324
|
-
cssClass?: string;
|
|
325
|
-
validation?: string[];
|
|
326
|
-
options?: string[];
|
|
327
|
-
helpText?: string;
|
|
328
|
-
size?: string;
|
|
329
|
-
[key: string]: unknown;
|
|
330
|
-
};
|
|
331
|
-
}>;
|
|
332
|
-
actions: Array<{
|
|
333
|
-
id: number;
|
|
334
|
-
name: string;
|
|
335
|
-
type: string;
|
|
336
|
-
properties: Record<string, unknown>;
|
|
337
|
-
}>;
|
|
338
|
-
cssClass?: string;
|
|
339
|
-
submitAction?: string;
|
|
340
|
-
[key: string]: unknown;
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
/**
|
|
344
|
-
* @license GPL-3.0-or-later
|
|
345
|
-
*
|
|
346
|
-
* This file is part of the MarVAlt Open SDK.
|
|
347
|
-
* Copyright (c) 2025 Vibune Pty Ltd.
|
|
348
|
-
*
|
|
349
|
-
* This program is free software: you can redistribute it and/or modify
|
|
350
|
-
* it under the terms of the GNU General Public License as published by
|
|
351
|
-
* the Free Software Foundation, either version 3 of the License, or
|
|
352
|
-
* (at your option) any later version.
|
|
353
|
-
*
|
|
354
|
-
* This program is distributed in the hope that it will be useful,
|
|
355
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
356
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
357
|
-
* See the GNU General Public License for more details.
|
|
358
|
-
*/
|
|
359
|
-
|
|
360
|
-
declare class MauticGenerator {
|
|
361
|
-
private client;
|
|
362
|
-
private config;
|
|
363
|
-
private cachedToken;
|
|
364
|
-
constructor(config: MauticGeneratorConfig);
|
|
365
|
-
/**
|
|
366
|
-
* Get OAuth2 token for direct mode API calls
|
|
367
|
-
*/
|
|
368
|
-
private getOAuth2Token;
|
|
369
|
-
/**
|
|
370
|
-
* Generate static data for Mautic forms
|
|
371
|
-
*/
|
|
372
|
-
generateStaticData(): Promise<MauticStaticData>;
|
|
373
|
-
/**
|
|
374
|
-
* Write static data to file
|
|
375
|
-
*/
|
|
376
|
-
writeStaticData(staticData: MauticStaticData): Promise<void>;
|
|
377
|
-
/**
|
|
378
|
-
* Generate and write static data
|
|
379
|
-
*/
|
|
380
|
-
generateAndWrite(): Promise<MauticStaticData>;
|
|
381
|
-
/**
|
|
382
|
-
* Fetch list of forms from Mautic
|
|
383
|
-
*/
|
|
384
|
-
private fetchMauticFormsList;
|
|
385
|
-
/**
|
|
386
|
-
* Fetch individual form details from Mautic
|
|
387
|
-
*/
|
|
388
|
-
private fetchMauticForm;
|
|
389
|
-
}
|
|
390
|
-
/**
|
|
391
|
-
* Generate Mautic static data with configuration
|
|
392
|
-
*/
|
|
393
|
-
declare function generateMauticData(config: MauticGeneratorConfig): Promise<MauticStaticData>;
|
|
394
|
-
|
|
395
284
|
/**
|
|
396
285
|
* @license GPL-3.0-or-later
|
|
397
286
|
*
|
|
@@ -710,6 +599,65 @@ declare const getDataMetadata: () => {
|
|
|
710
599
|
form_types: (string | undefined)[];
|
|
711
600
|
};
|
|
712
601
|
|
|
602
|
+
/**
|
|
603
|
+
* @license GPL-3.0-or-later
|
|
604
|
+
*
|
|
605
|
+
* This file is part of the MarVAlt Open SDK.
|
|
606
|
+
* Copyright (c) 2025 Vibune Pty Ltd.
|
|
607
|
+
*
|
|
608
|
+
* This program is free software: you can redistribute it and/or modify
|
|
609
|
+
* it under the terms of the GNU General Public License as published by
|
|
610
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
611
|
+
* (at your option) any later version.
|
|
612
|
+
*
|
|
613
|
+
* This program is distributed in the hope that it will be useful,
|
|
614
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
615
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
616
|
+
* See the GNU General Public License for more details.
|
|
617
|
+
*/
|
|
618
|
+
|
|
619
|
+
interface MauticStaticData {
|
|
620
|
+
generated_at: string;
|
|
621
|
+
total_forms: number;
|
|
622
|
+
forms: MauticForm$1[];
|
|
623
|
+
}
|
|
624
|
+
interface MauticFormData {
|
|
625
|
+
id: string;
|
|
626
|
+
name: string;
|
|
627
|
+
description?: string;
|
|
628
|
+
isPublished: boolean;
|
|
629
|
+
postAction?: string;
|
|
630
|
+
postActionProperty?: string;
|
|
631
|
+
formType?: string;
|
|
632
|
+
fields: Array<{
|
|
633
|
+
id: number;
|
|
634
|
+
label: string;
|
|
635
|
+
alias: string;
|
|
636
|
+
type: string;
|
|
637
|
+
isRequired: boolean;
|
|
638
|
+
validationMessage?: string;
|
|
639
|
+
defaultValue?: string;
|
|
640
|
+
properties?: {
|
|
641
|
+
placeholder?: string;
|
|
642
|
+
cssClass?: string;
|
|
643
|
+
validation?: string[];
|
|
644
|
+
options?: string[];
|
|
645
|
+
helpText?: string;
|
|
646
|
+
size?: string;
|
|
647
|
+
[key: string]: unknown;
|
|
648
|
+
};
|
|
649
|
+
}>;
|
|
650
|
+
actions: Array<{
|
|
651
|
+
id: number;
|
|
652
|
+
name: string;
|
|
653
|
+
type: string;
|
|
654
|
+
properties: Record<string, unknown>;
|
|
655
|
+
}>;
|
|
656
|
+
cssClass?: string;
|
|
657
|
+
submitAction?: string;
|
|
658
|
+
[key: string]: unknown;
|
|
659
|
+
}
|
|
660
|
+
|
|
713
661
|
/**
|
|
714
662
|
* @license GPL-3.0-or-later
|
|
715
663
|
*
|
|
@@ -816,5 +764,5 @@ declare const sanitizeFormData: (formData: Record<string, any>) => Record<string
|
|
|
816
764
|
*/
|
|
817
765
|
declare const formatFormDataForSubmission: (formData: Record<string, any>) => Record<string, any>;
|
|
818
766
|
|
|
819
|
-
export { MauticClient, MauticForm,
|
|
767
|
+
export { MauticClient, MauticForm, MauticProvider, MauticService, MauticTracking, TurnstileWidget, createMauticConfig, formatFormDataForSubmission, getAllFieldTypes, getDataMetadata, getDefaultMauticConfig, getFormByAlias, getFormById, getFormFieldByAlias, getFormsByFieldType, getFormsByType, getFormsCountByStatus, getMauticConfigSummary, getMauticData, getPublishedForms, isDataLoaded, isFormDataValid, isMauticEnabled, isRequiredFieldValid, isValidEmail, isValidPhone, isValidUrl, loadMauticData, mauticService, mergeMauticConfig, sanitizeFormData, searchForms, setMauticClient, useMauticAddTags, useMauticAddToSegment, useMauticClient, useMauticConfig, useMauticContactByEmail, useMauticContactTags, useMauticContext, useMauticCreateContact, useMauticEvent, useMauticEventTracking, useMauticForm, useMauticFormSubmission, useMauticForms, useMauticRemoveFromSegment, useMauticRemoveTags, useMauticSegments, useMauticTags, useMauticTracking, useMauticUpdateContact, validateField, validateFormData, validateMauticConfig };
|
|
820
768
|
export type { AuthMode, MauticApiResponse, MauticConfig, MauticContact, MauticEvent, MauticFormAction, MauticFormConfig, MauticFormData, MauticFormField, MauticFormSubmission, MauticForm$1 as MauticFormType, MauticGeneratorConfig, MauticStaticData, MauticTrackingConfig };
|
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;AAGH,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAGtD,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAGtD,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAMxE,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AACtG,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAGrE,OAAO,EACL,uBAAuB,EACvB,sBAAsB,EACtB,sBAAsB,EACtB,uBAAuB,EACvB,cAAc,EACd,aAAa,EACb,sBAAsB,EACtB,gBAAgB,EAChB,mBAAmB,EACnB,oBAAoB,EACpB,aAAa,EACb,iBAAiB,EACjB,qBAAqB,EACrB,0BAA0B,EAC1B,eAAe,GAChB,MAAM,yBAAyB,CAAC;AAGjC,OAAO,EACL,cAAc,EACd,gBAAgB,EAChB,eAAe,EACf,eAAe,GAChB,MAAM,kCAAkC,CAAC;AAG1C,OAAO,EACL,cAAc,EACd,aAAa,EACb,iBAAiB,EACjB,WAAW,EACX,cAAc,EACd,cAAc,EACd,mBAAmB,EACnB,WAAW,EACX,mBAAmB,EACnB,gBAAgB,EAChB,qBAAqB,EACrB,YAAY,EACZ,eAAe,GAChB,MAAM,0BAA0B,CAAC;AAGlC,YAAY,EACV,aAAa,EACb,oBAAoB,EACpB,eAAe,EACf,gBAAgB,EAChB,UAAU,IAAI,cAAc,EAC5B,gBAAgB,EAChB,WAAW,EACX,iBAAiB,GAClB,MAAM,gBAAgB,CAAC;AAExB,YAAY,EACV,QAAQ,EACR,YAAY,EACZ,qBAAqB,EACrB,oBAAoB,GACrB,MAAM,gBAAgB,CAAC;AAExB,YAAY,EACV,gBAAgB,EAChB,cAAc,GACf,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EACL,kBAAkB,EAClB,oBAAoB,EACpB,sBAAsB,EACtB,iBAAiB,EACjB,eAAe,EACf,sBAAsB,GACvB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,UAAU,EACV,oBAAoB,EACpB,aAAa,EACb,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,2BAA2B,GAC5B,MAAM,oBAAoB,CAAC"}
|
package/dist/index.esm.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
|
-
import path from 'path';
|
|
3
1
|
import React, { useRef, useEffect, useState, createContext, useMemo, useContext } from 'react';
|
|
4
2
|
import { useQueryClient, useMutation, useQuery } from '@tanstack/react-query';
|
|
5
3
|
|
|
@@ -439,246 +437,6 @@ catch {
|
|
|
439
437
|
// Silently skip initialization when environment is not configured
|
|
440
438
|
}
|
|
441
439
|
|
|
442
|
-
/**
|
|
443
|
-
* @license GPL-3.0-or-later
|
|
444
|
-
*
|
|
445
|
-
* This file is part of the MarVAlt Open SDK.
|
|
446
|
-
* Copyright (c) 2025 Vibune Pty Ltd.
|
|
447
|
-
*
|
|
448
|
-
* This program is free software: you can redistribute it and/or modify
|
|
449
|
-
* it under the terms of the GNU General Public License as published by
|
|
450
|
-
* the Free Software Foundation, either version 3 of the License, or
|
|
451
|
-
* (at your option) any later version.
|
|
452
|
-
*
|
|
453
|
-
* This program is distributed in the hope that it will be useful,
|
|
454
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
455
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
456
|
-
* See the GNU General Public License for more details.
|
|
457
|
-
*/
|
|
458
|
-
class MauticGenerator {
|
|
459
|
-
constructor(config) {
|
|
460
|
-
this.cachedToken = null;
|
|
461
|
-
this.config = config;
|
|
462
|
-
// Generator uses direct OAuth2 calls, not the client
|
|
463
|
-
// Client is only used for proxy mode (cloudflare_proxy)
|
|
464
|
-
this.client = new MauticClient({
|
|
465
|
-
apiUrl: config.apiUrl,
|
|
466
|
-
proxyEndpoint: config.cloudflareWorkerUrl,
|
|
467
|
-
timeout: config.timeout,
|
|
468
|
-
retries: config.retries,
|
|
469
|
-
});
|
|
470
|
-
}
|
|
471
|
-
/**
|
|
472
|
-
* Get OAuth2 token for direct mode API calls
|
|
473
|
-
*/
|
|
474
|
-
async getOAuth2Token() {
|
|
475
|
-
if (this.cachedToken && this.cachedToken.expires_at > Date.now() + 300000) {
|
|
476
|
-
console.log('🔑 Using cached OAuth2 token');
|
|
477
|
-
return this.cachedToken.access_token;
|
|
478
|
-
}
|
|
479
|
-
if (!this.config.clientId || !this.config.clientSecret) {
|
|
480
|
-
throw new Error('OAuth2 credentials (clientId, clientSecret) required for direct mode');
|
|
481
|
-
}
|
|
482
|
-
console.log('🔑 Fetching new OAuth2 token...');
|
|
483
|
-
const tokenUrl = `${this.config.apiUrl}/oauth/v2/token`;
|
|
484
|
-
const body = new URLSearchParams({
|
|
485
|
-
grant_type: 'client_credentials',
|
|
486
|
-
client_id: this.config.clientId,
|
|
487
|
-
client_secret: this.config.clientSecret,
|
|
488
|
-
});
|
|
489
|
-
const headers = { 'Content-Type': 'application/x-www-form-urlencoded' };
|
|
490
|
-
if (this.config.cfAccessClientId && this.config.cfAccessClientSecret) {
|
|
491
|
-
headers['CF-Access-Client-Id'] = this.config.cfAccessClientId;
|
|
492
|
-
headers['CF-Access-Client-Secret'] = this.config.cfAccessClientSecret;
|
|
493
|
-
console.log('🔐 Added CF Access headers to OAuth2 token request');
|
|
494
|
-
}
|
|
495
|
-
const resp = await fetch(tokenUrl, { method: 'POST', headers, body: body.toString() });
|
|
496
|
-
if (!resp.ok) {
|
|
497
|
-
const errText = await resp.text();
|
|
498
|
-
throw new Error(`OAuth2 token failed: ${resp.status} ${errText}`);
|
|
499
|
-
}
|
|
500
|
-
const data = await resp.json();
|
|
501
|
-
this.cachedToken = {
|
|
502
|
-
access_token: data.access_token,
|
|
503
|
-
expires_at: Date.now() + (data.expires_in * 1000),
|
|
504
|
-
};
|
|
505
|
-
console.log('✅ OAuth2 token cached');
|
|
506
|
-
return this.cachedToken.access_token;
|
|
507
|
-
}
|
|
508
|
-
/**
|
|
509
|
-
* Generate static data for Mautic forms
|
|
510
|
-
*/
|
|
511
|
-
async generateStaticData() {
|
|
512
|
-
console.log('🔄 Generating Mautic forms JSON data...');
|
|
513
|
-
try {
|
|
514
|
-
const allForms = await this.fetchMauticFormsList();
|
|
515
|
-
console.log(`📝 Found ${allForms.length} forms`);
|
|
516
|
-
const forms = [];
|
|
517
|
-
for (const formSummary of allForms) {
|
|
518
|
-
const formId = formSummary.id?.toString();
|
|
519
|
-
if (!formId) {
|
|
520
|
-
console.warn(`⚠️ Form summary missing ID:`, formSummary);
|
|
521
|
-
continue;
|
|
522
|
-
}
|
|
523
|
-
try {
|
|
524
|
-
const formDetails = await this.fetchMauticForm(formId);
|
|
525
|
-
if (!formDetails) {
|
|
526
|
-
console.warn(`⚠️ No form details returned for form ${formId}`);
|
|
527
|
-
continue;
|
|
528
|
-
}
|
|
529
|
-
// Extract the form data with proper structure
|
|
530
|
-
const formData = {
|
|
531
|
-
id: formId,
|
|
532
|
-
name: formDetails.name || formSummary.name || `Form ${formId}`,
|
|
533
|
-
description: formDetails.description,
|
|
534
|
-
isPublished: formDetails.isPublished || formSummary.isPublished || false,
|
|
535
|
-
// Include post-submission behavior configuration
|
|
536
|
-
postAction: formDetails.postAction || 'message',
|
|
537
|
-
postActionProperty: formDetails.postActionProperty || 'Thank you for your submission!',
|
|
538
|
-
// Include other important form properties
|
|
539
|
-
formType: formDetails.formType || 'standalone',
|
|
540
|
-
// Extract fields with validation and properties
|
|
541
|
-
fields: (formDetails.fields || []).map((field) => ({
|
|
542
|
-
id: field.id,
|
|
543
|
-
label: field.label,
|
|
544
|
-
alias: field.alias,
|
|
545
|
-
type: field.type,
|
|
546
|
-
isRequired: field.isRequired || false,
|
|
547
|
-
validationMessage: field.validationMessage,
|
|
548
|
-
defaultValue: field.defaultValue,
|
|
549
|
-
properties: {
|
|
550
|
-
placeholder: field.properties?.placeholder,
|
|
551
|
-
cssClass: field.properties?.cssClass,
|
|
552
|
-
validation: field.properties?.validation,
|
|
553
|
-
options: field.properties?.options,
|
|
554
|
-
helpText: field.properties?.helpText,
|
|
555
|
-
size: field.properties?.size,
|
|
556
|
-
...field.properties
|
|
557
|
-
}
|
|
558
|
-
})),
|
|
559
|
-
// Extract actions
|
|
560
|
-
actions: (formDetails.actions || []).map((action) => ({
|
|
561
|
-
id: action.id,
|
|
562
|
-
name: action.name,
|
|
563
|
-
type: action.type,
|
|
564
|
-
properties: action.properties || {}
|
|
565
|
-
})),
|
|
566
|
-
// Include styling and behavior
|
|
567
|
-
cssClass: formDetails.cssClass,
|
|
568
|
-
submitAction: formDetails.submitAction,
|
|
569
|
-
// Keep the details for reference
|
|
570
|
-
...formSummary
|
|
571
|
-
};
|
|
572
|
-
forms.push(formData);
|
|
573
|
-
console.log(`✅ Processed form: ${formData.name} (ID: ${formId})`);
|
|
574
|
-
}
|
|
575
|
-
catch (error) {
|
|
576
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
577
|
-
console.error(`❌ Error processing form ${formId}:`, message);
|
|
578
|
-
// Continue with other forms
|
|
579
|
-
}
|
|
580
|
-
}
|
|
581
|
-
const staticData = {
|
|
582
|
-
generated_at: new Date().toISOString(),
|
|
583
|
-
total_forms: forms.length,
|
|
584
|
-
forms: forms.map((form) => ({
|
|
585
|
-
id: parseInt(form.id),
|
|
586
|
-
name: form.name,
|
|
587
|
-
alias: String(form.alias ?? (form.name || '').toLowerCase().replace(/\s+/g, '-')),
|
|
588
|
-
description: form.description,
|
|
589
|
-
isPublished: form.isPublished,
|
|
590
|
-
fields: form.fields,
|
|
591
|
-
actions: form.actions,
|
|
592
|
-
cssClass: form.cssClass,
|
|
593
|
-
submitAction: form.submitAction,
|
|
594
|
-
postAction: form.postAction,
|
|
595
|
-
postActionProperty: form.postActionProperty,
|
|
596
|
-
formType: form.formType,
|
|
597
|
-
}))
|
|
598
|
-
};
|
|
599
|
-
console.log(`✅ Generated static data for ${forms.length} forms`);
|
|
600
|
-
return staticData;
|
|
601
|
-
}
|
|
602
|
-
catch (error) {
|
|
603
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
604
|
-
console.error('❌ Error generating Mautic static data:', message);
|
|
605
|
-
throw new Error(message);
|
|
606
|
-
}
|
|
607
|
-
}
|
|
608
|
-
/**
|
|
609
|
-
* Write static data to file
|
|
610
|
-
*/
|
|
611
|
-
async writeStaticData(staticData) {
|
|
612
|
-
const outputPath = path.resolve(this.config.outputPath);
|
|
613
|
-
const outputDir = path.dirname(outputPath);
|
|
614
|
-
// Ensure output directory exists
|
|
615
|
-
if (!fs.existsSync(outputDir)) {
|
|
616
|
-
fs.mkdirSync(outputDir, { recursive: true });
|
|
617
|
-
}
|
|
618
|
-
// Write the static data
|
|
619
|
-
fs.writeFileSync(outputPath, JSON.stringify(staticData, null, 2));
|
|
620
|
-
console.log(`📁 Static data written to: ${outputPath}`);
|
|
621
|
-
}
|
|
622
|
-
/**
|
|
623
|
-
* Generate and write static data
|
|
624
|
-
*/
|
|
625
|
-
async generateAndWrite() {
|
|
626
|
-
const staticData = await this.generateStaticData();
|
|
627
|
-
await this.writeStaticData(staticData);
|
|
628
|
-
return staticData;
|
|
629
|
-
}
|
|
630
|
-
/**
|
|
631
|
-
* Fetch list of forms from Mautic
|
|
632
|
-
*/
|
|
633
|
-
async fetchMauticFormsList() {
|
|
634
|
-
if (this.config.authMode === 'cloudflare_proxy') {
|
|
635
|
-
const forms = await this.client.getForms();
|
|
636
|
-
return Array.isArray(forms) ? forms : [];
|
|
637
|
-
}
|
|
638
|
-
// Direct mode with OAuth2
|
|
639
|
-
const token = await this.getOAuth2Token();
|
|
640
|
-
const url = `${this.config.apiUrl}/api/forms`;
|
|
641
|
-
const headers = { 'Authorization': `Bearer ${token}` };
|
|
642
|
-
if (this.config.cfAccessClientId && this.config.cfAccessClientSecret) {
|
|
643
|
-
headers['CF-Access-Client-Id'] = this.config.cfAccessClientId;
|
|
644
|
-
headers['CF-Access-Client-Secret'] = this.config.cfAccessClientSecret;
|
|
645
|
-
}
|
|
646
|
-
const resp = await fetch(url, { headers });
|
|
647
|
-
if (!resp.ok)
|
|
648
|
-
throw new Error(`Failed to fetch forms: ${resp.status}`);
|
|
649
|
-
const data = await resp.json();
|
|
650
|
-
return Array.isArray(data.forms) ? data.forms : [];
|
|
651
|
-
}
|
|
652
|
-
/**
|
|
653
|
-
* Fetch individual form details from Mautic
|
|
654
|
-
*/
|
|
655
|
-
async fetchMauticForm(formId) {
|
|
656
|
-
if (this.config.authMode === 'cloudflare_proxy') {
|
|
657
|
-
return this.client.getForm(parseInt(formId, 10));
|
|
658
|
-
}
|
|
659
|
-
// Direct mode with OAuth2
|
|
660
|
-
const token = await this.getOAuth2Token();
|
|
661
|
-
const url = `${this.config.apiUrl}/api/forms/${formId}`;
|
|
662
|
-
const headers = { 'Authorization': `Bearer ${token}` };
|
|
663
|
-
if (this.config.cfAccessClientId && this.config.cfAccessClientSecret) {
|
|
664
|
-
headers['CF-Access-Client-Id'] = this.config.cfAccessClientId;
|
|
665
|
-
headers['CF-Access-Client-Secret'] = this.config.cfAccessClientSecret;
|
|
666
|
-
}
|
|
667
|
-
const resp = await fetch(url, { headers });
|
|
668
|
-
if (!resp.ok)
|
|
669
|
-
throw new Error(`Failed to fetch form ${formId}: ${resp.status}`);
|
|
670
|
-
const data = await resp.json();
|
|
671
|
-
return data.form || data;
|
|
672
|
-
}
|
|
673
|
-
}
|
|
674
|
-
/**
|
|
675
|
-
* Generate Mautic static data with configuration
|
|
676
|
-
*/
|
|
677
|
-
async function generateMauticData(config) {
|
|
678
|
-
const generator = new MauticGenerator(config);
|
|
679
|
-
return generator.generateAndWrite();
|
|
680
|
-
}
|
|
681
|
-
|
|
682
440
|
var jsxRuntime = {exports: {}};
|
|
683
441
|
|
|
684
442
|
var reactJsxRuntime_production_min = {};
|
|
@@ -3170,5 +2928,5 @@ const formatFormDataForSubmission = (formData) => {
|
|
|
3170
2928
|
return formatted;
|
|
3171
2929
|
};
|
|
3172
2930
|
|
|
3173
|
-
export { MauticClient, MauticForm,
|
|
2931
|
+
export { MauticClient, MauticForm, MauticProvider, MauticService, MauticTracking, TurnstileWidget, createMauticConfig, formatFormDataForSubmission, getAllFieldTypes, getDataMetadata, getDefaultMauticConfig, getFormByAlias, getFormById, getFormFieldByAlias, getFormsByFieldType, getFormsByType, getFormsCountByStatus, getMauticConfigSummary, getMauticData, getPublishedForms, isDataLoaded, isFormDataValid, isMauticEnabled, isRequiredFieldValid, isValidEmail, isValidPhone, isValidUrl, loadMauticData, mauticService, mergeMauticConfig, sanitizeFormData, searchForms, setMauticClient, useMauticAddTags, useMauticAddToSegment, useMauticClient, useMauticConfig, useMauticContactByEmail, useMauticContactTags, useMauticContext, useMauticCreateContact, useMauticEvent, useMauticEventTracking, useMauticForm, useMauticFormSubmission, useMauticForms, useMauticRemoveFromSegment, useMauticRemoveTags, useMauticSegments, useMauticTags, useMauticTracking, useMauticUpdateContact, validateField, validateFormData, validateMauticConfig };
|
|
3174
2932
|
//# sourceMappingURL=index.esm.js.map
|