@marvalt/madapter 1.0.14 → 2.1.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/dist/index.d.ts CHANGED
@@ -18,21 +18,31 @@ import * as _tanstack_react_query from '@tanstack/react-query';
18
18
  * See the GNU General Public License for more details.
19
19
  */
20
20
  type AuthMode = 'cloudflare_proxy' | 'direct';
21
+ /**
22
+ * Mautic client configuration (for runtime/browser use)
23
+ * Convention-based: Uses /api/mautic-submit by default
24
+ */
21
25
  interface MauticConfig {
22
- authMode: AuthMode;
26
+ /** Mautic instance URL (e.g., https://your-mautic.com) */
23
27
  apiUrl?: string;
24
- cloudflareWorkerUrl?: string;
25
- appId?: string;
26
- workerSecret?: string;
28
+ /**
29
+ * Proxy endpoint for server-side authentication
30
+ * @default '/api/mautic-submit'
31
+ */
32
+ proxyEndpoint?: string;
33
+ /** Request timeout in milliseconds */
27
34
  timeout?: number;
35
+ /** Number of retry attempts */
28
36
  retries?: number;
29
37
  }
30
38
  interface MauticGeneratorConfig {
31
39
  authMode: AuthMode;
32
40
  apiUrl?: string;
33
41
  cloudflareWorkerUrl?: string;
34
- appId?: string;
35
- workerSecret?: string;
42
+ clientId?: string;
43
+ clientSecret?: string;
44
+ cfAccessClientId?: string;
45
+ cfAccessClientSecret?: string;
36
46
  outputPath: string;
37
47
  formIds?: number[];
38
48
  includeInactive?: boolean;
@@ -43,8 +53,6 @@ interface MauticTrackingConfig {
43
53
  enabled?: boolean;
44
54
  mauticUrl?: string;
45
55
  proxyUrl?: string;
46
- appId?: string;
47
- workerSecret?: string;
48
56
  }
49
57
 
50
58
  /**
@@ -173,16 +181,9 @@ interface MauticApiResponse<T = any> {
173
181
  */
174
182
 
175
183
  declare class MauticClient {
176
- private baseUrl;
177
- private proxyUrl?;
178
- private appId?;
179
- private workerSecret?;
180
- private useProxy;
181
- private isConfigured;
184
+ private proxyEndpoint;
182
185
  private config;
183
186
  constructor(config: MauticConfig);
184
- private validateConfiguration;
185
- private getAuthHeaders;
186
187
  private makeRequest;
187
188
  /**
188
189
  * Submit a form to Mautic
@@ -278,7 +279,7 @@ declare class MauticService {
278
279
  removeTagFromContact(contactId: number, tags: string[]): Promise<any>;
279
280
  trackEvent(eventName: string, eventData?: Record<string, any>): Promise<any>;
280
281
  }
281
- declare const mauticService: MauticService;
282
+ declare let mauticService: MauticService | null;
282
283
 
283
284
  /**
284
285
  * @license GPL-3.0-or-later
@@ -359,7 +360,12 @@ interface MauticFormData {
359
360
  declare class MauticGenerator {
360
361
  private client;
361
362
  private config;
363
+ private cachedToken;
362
364
  constructor(config: MauticGeneratorConfig);
365
+ /**
366
+ * Get OAuth2 token for direct mode API calls
367
+ */
368
+ private getOAuth2Token;
363
369
  /**
364
370
  * Generate static data for Mautic forms
365
371
  */
@@ -677,6 +683,7 @@ declare const getDataMetadata: () => {
677
683
 
678
684
  /**
679
685
  * Create Mautic configuration from environment variables
686
+ * Convention-based: Uses /api/mautic-submit by default
680
687
  */
681
688
  declare const createMauticConfig: (overrides?: Partial<MauticConfig>) => MauticConfig;
682
689
  /**
@@ -702,11 +709,8 @@ declare const isMauticEnabled: (config: MauticConfig) => boolean;
702
709
  * Get Mautic configuration summary (for debugging)
703
710
  */
704
711
  declare const getMauticConfigSummary: (config: MauticConfig) => {
705
- authMode: AuthMode;
706
712
  hasApiUrl: boolean;
707
- hasCloudflareWorkerUrl: boolean;
708
- hasAppId: boolean;
709
- hasWorkerSecret: boolean;
713
+ proxyEndpoint: string;
710
714
  timeout: number | undefined;
711
715
  retries: number | undefined;
712
716
  isEnabled: boolean;