@djangocfg/ext-newsletter 1.0.0 → 1.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/dist/index.d.ts DELETED
@@ -1,2084 +0,0 @@
1
- import { ConsolaInstance } from 'consola';
2
- import { z, ZodError } from 'zod';
3
-
4
- /**
5
- * Simple serializer for bulk email.
6
- *
7
- * Request model (no read-only fields).
8
- */
9
- interface BulkEmailRequest$1 {
10
- recipients: Array<string>;
11
- subject: string;
12
- email_title: string;
13
- main_text: string;
14
- main_html_content?: string;
15
- button_text?: string;
16
- button_url?: string;
17
- secondary_text?: string;
18
- }
19
- /**
20
- * Response for bulk email sending.
21
- *
22
- * Response model (includes read-only fields).
23
- */
24
- interface BulkEmailResponse$2 {
25
- success: boolean;
26
- sent_count: number;
27
- failed_count: number;
28
- total_recipients: number;
29
- error?: string;
30
- }
31
-
32
- declare namespace models$6 {
33
- export type { BulkEmailRequest$1 as BulkEmailRequest, BulkEmailResponse$2 as BulkEmailResponse };
34
- }
35
-
36
- /**
37
- * API endpoints for Bulk Email.
38
- */
39
- declare class ExtNewsletterBulkEmail {
40
- private client;
41
- constructor(client: any);
42
- /**
43
- * Send Bulk Email
44
- *
45
- * Send bulk emails to multiple recipients using base email template.
46
- */
47
- newsletterBulkCreate(data: BulkEmailRequest$1): Promise<BulkEmailResponse$2>;
48
- }
49
-
50
- /**
51
- * * `pending` - Pending
52
- * * `sent` - Sent
53
- * * `failed` - Failed
54
- */
55
- declare enum EmailLogStatus {
56
- PENDING = "pending",
57
- SENT = "sent",
58
- FAILED = "failed"
59
- }
60
- /**
61
- * * `draft` - Draft
62
- * * `sending` - Sending
63
- * * `sent` - Sent
64
- * * `failed` - Failed
65
- */
66
- declare enum NewsletterCampaignStatus {
67
- DRAFT = "draft",
68
- SENDING = "sending",
69
- SENT = "sent",
70
- FAILED = "failed"
71
- }
72
-
73
- type enums_EmailLogStatus = EmailLogStatus;
74
- declare const enums_EmailLogStatus: typeof EmailLogStatus;
75
- type enums_NewsletterCampaignStatus = NewsletterCampaignStatus;
76
- declare const enums_NewsletterCampaignStatus: typeof NewsletterCampaignStatus;
77
- declare namespace enums {
78
- export { enums_EmailLogStatus as EmailLogStatus, enums_NewsletterCampaignStatus as NewsletterCampaignStatus };
79
- }
80
-
81
- /**
82
- *
83
- * Response model (includes read-only fields).
84
- */
85
- interface PaginatedNewsletterCampaignList$1 {
86
- /** Total number of items across all pages */
87
- count: number;
88
- /** Current page number (1-based) */
89
- page: number;
90
- /** Total number of pages */
91
- pages: number;
92
- /** Number of items per page */
93
- page_size: number;
94
- /** Whether there is a next page */
95
- has_next: boolean;
96
- /** Whether there is a previous page */
97
- has_previous: boolean;
98
- /** Next page number (null if no next page) */
99
- next_page?: number | null;
100
- /** Previous page number (null if no previous page) */
101
- previous_page?: number | null;
102
- /** Array of items for current page */
103
- results: Array<NewsletterCampaign$2>;
104
- }
105
- /**
106
- * Serializer for NewsletterCampaign model.
107
- *
108
- * Request model (no read-only fields).
109
- */
110
- interface NewsletterCampaignRequest$1 {
111
- newsletter: number;
112
- subject: string;
113
- email_title: string;
114
- main_text: string;
115
- main_html_content?: string;
116
- button_text?: string;
117
- button_url?: string;
118
- secondary_text?: string;
119
- }
120
- /**
121
- * Serializer for NewsletterCampaign model.
122
- *
123
- * Response model (includes read-only fields).
124
- */
125
- interface NewsletterCampaign$2 {
126
- id: number;
127
- newsletter: number;
128
- newsletter_title: string;
129
- subject: string;
130
- email_title: string;
131
- main_text: string;
132
- main_html_content?: string;
133
- button_text?: string;
134
- button_url?: string;
135
- secondary_text?: string;
136
- /** * `draft` - Draft
137
- * `sending` - Sending
138
- * `sent` - Sent
139
- * `failed` - Failed */
140
- status: NewsletterCampaignStatus;
141
- created_at: string;
142
- sent_at?: string | null;
143
- recipient_count: number;
144
- }
145
- /**
146
- * Simple serializer for sending campaign.
147
- *
148
- * Request model (no read-only fields).
149
- */
150
- interface SendCampaignRequest$1 {
151
- campaign_id: number;
152
- }
153
- /**
154
- * Response for sending campaign.
155
- *
156
- * Response model (includes read-only fields).
157
- */
158
- interface SendCampaignResponse$1 {
159
- success: boolean;
160
- message?: string;
161
- sent_count?: number;
162
- error?: string;
163
- }
164
- /**
165
- * Generic error response.
166
- *
167
- * Response model (includes read-only fields).
168
- */
169
- interface ErrorResponse$2 {
170
- success?: boolean;
171
- message: string;
172
- }
173
-
174
- declare namespace models$5 {
175
- export type { ErrorResponse$2 as ErrorResponse, NewsletterCampaign$2 as NewsletterCampaign, NewsletterCampaignRequest$1 as NewsletterCampaignRequest, PaginatedNewsletterCampaignList$1 as PaginatedNewsletterCampaignList, SendCampaignRequest$1 as SendCampaignRequest, SendCampaignResponse$1 as SendCampaignResponse };
176
- }
177
-
178
- /**
179
- * API endpoints for Campaigns.
180
- */
181
- declare class ExtNewsletterCampaigns {
182
- private client;
183
- constructor(client: any);
184
- newsletterCampaignsList(page?: number, page_size?: number): Promise<PaginatedNewsletterCampaignList$1>;
185
- newsletterCampaignsList(params?: {
186
- page?: number;
187
- page_size?: number;
188
- }): Promise<PaginatedNewsletterCampaignList$1>;
189
- /**
190
- * Create Newsletter Campaign
191
- *
192
- * Create a new newsletter campaign.
193
- */
194
- newsletterCampaignsCreate(data: NewsletterCampaignRequest$1): Promise<NewsletterCampaign$2>;
195
- /**
196
- * Get Campaign Details
197
- *
198
- * Retrieve details of a specific newsletter campaign.
199
- */
200
- newsletterCampaignsRetrieve(id: number): Promise<NewsletterCampaign$2>;
201
- /**
202
- * Update Campaign
203
- *
204
- * Update a newsletter campaign.
205
- */
206
- newsletterCampaignsUpdate(id: number, data: NewsletterCampaignRequest$1): Promise<NewsletterCampaign$2>;
207
- /**
208
- * Delete Campaign
209
- *
210
- * Delete a newsletter campaign.
211
- */
212
- newsletterCampaignsDestroy(id: number): Promise<void>;
213
- /**
214
- * Send Newsletter Campaign
215
- *
216
- * Send a newsletter campaign to all subscribers.
217
- */
218
- newsletterCampaignsSendCreate(data: SendCampaignRequest$1): Promise<SendCampaignResponse$1>;
219
- }
220
-
221
- /**
222
- *
223
- * Response model (includes read-only fields).
224
- */
225
- interface PaginatedEmailLogList$1 {
226
- /** Total number of items across all pages */
227
- count: number;
228
- /** Current page number (1-based) */
229
- page: number;
230
- /** Total number of pages */
231
- pages: number;
232
- /** Number of items per page */
233
- page_size: number;
234
- /** Whether there is a next page */
235
- has_next: boolean;
236
- /** Whether there is a previous page */
237
- has_previous: boolean;
238
- /** Next page number (null if no next page) */
239
- next_page?: number | null;
240
- /** Previous page number (null if no previous page) */
241
- previous_page?: number | null;
242
- /** Array of items for current page */
243
- results: Array<EmailLog$1>;
244
- }
245
- /**
246
- * Serializer for EmailLog model.
247
- *
248
- * Response model (includes read-only fields).
249
- */
250
- interface EmailLog$1 {
251
- id: string;
252
- user?: number | null;
253
- user_email: string;
254
- newsletter?: number | null;
255
- newsletter_title: string;
256
- /** Comma-separated email addresses */
257
- recipient: string;
258
- subject: string;
259
- body: string;
260
- /** * `pending` - Pending
261
- * `sent` - Sent
262
- * `failed` - Failed */
263
- status: EmailLogStatus;
264
- created_at: string;
265
- sent_at?: string | null;
266
- error_message?: string | null;
267
- }
268
-
269
- declare namespace models$4 {
270
- export type { EmailLog$1 as EmailLog, PaginatedEmailLogList$1 as PaginatedEmailLogList };
271
- }
272
-
273
- /**
274
- * API endpoints for Logs.
275
- */
276
- declare class ExtNewsletterLogs {
277
- private client;
278
- constructor(client: any);
279
- newsletterLogsList(page?: number, page_size?: number): Promise<PaginatedEmailLogList$1>;
280
- newsletterLogsList(params?: {
281
- page?: number;
282
- page_size?: number;
283
- }): Promise<PaginatedEmailLogList$1>;
284
- }
285
-
286
- /**
287
- *
288
- * Response model (includes read-only fields).
289
- */
290
- interface PaginatedNewsletterList$1 {
291
- /** Total number of items across all pages */
292
- count: number;
293
- /** Current page number (1-based) */
294
- page: number;
295
- /** Total number of pages */
296
- pages: number;
297
- /** Number of items per page */
298
- page_size: number;
299
- /** Whether there is a next page */
300
- has_next: boolean;
301
- /** Whether there is a previous page */
302
- has_previous: boolean;
303
- /** Next page number (null if no next page) */
304
- next_page?: number | null;
305
- /** Previous page number (null if no previous page) */
306
- previous_page?: number | null;
307
- /** Array of items for current page */
308
- results: Array<Newsletter$1>;
309
- }
310
- /**
311
- * Serializer for Newsletter model.
312
- *
313
- * Response model (includes read-only fields).
314
- */
315
- interface Newsletter$1 {
316
- id: number;
317
- title: string;
318
- description?: string;
319
- is_active?: boolean;
320
- /** Automatically subscribe new users to this newsletter */
321
- auto_subscribe?: boolean;
322
- created_at: string;
323
- updated_at: string;
324
- subscribers_count: number;
325
- }
326
-
327
- declare namespace models$3 {
328
- export type { Newsletter$1 as Newsletter, PaginatedNewsletterList$1 as PaginatedNewsletterList };
329
- }
330
-
331
- /**
332
- * API endpoints for Newsletters.
333
- */
334
- declare class ExtNewsletterNewsletters {
335
- private client;
336
- constructor(client: any);
337
- newsletterNewslettersList(page?: number, page_size?: number): Promise<PaginatedNewsletterList$1>;
338
- newsletterNewslettersList(params?: {
339
- page?: number;
340
- page_size?: number;
341
- }): Promise<PaginatedNewsletterList$1>;
342
- /**
343
- * Get Newsletter Details
344
- *
345
- * Retrieve details of a specific newsletter.
346
- */
347
- newsletterNewslettersRetrieve(id: number): Promise<Newsletter$1>;
348
- }
349
-
350
- /**
351
- * Simple serializer for newsletter subscription.
352
- *
353
- * Request model (no read-only fields).
354
- */
355
- interface SubscribeRequest$1 {
356
- newsletter_id: number;
357
- email: string;
358
- }
359
- /**
360
- * Response for subscription.
361
- *
362
- * Response model (includes read-only fields).
363
- */
364
- interface SubscribeResponse$1 {
365
- success: boolean;
366
- message: string;
367
- subscription_id?: number;
368
- }
369
- /**
370
- * Generic error response.
371
- *
372
- * Response model (includes read-only fields).
373
- */
374
- interface ErrorResponse$1 {
375
- success?: boolean;
376
- message: string;
377
- }
378
- /**
379
- *
380
- * Response model (includes read-only fields).
381
- */
382
- interface PaginatedNewsletterSubscriptionList$1 {
383
- /** Total number of items across all pages */
384
- count: number;
385
- /** Current page number (1-based) */
386
- page: number;
387
- /** Total number of pages */
388
- pages: number;
389
- /** Number of items per page */
390
- page_size: number;
391
- /** Whether there is a next page */
392
- has_next: boolean;
393
- /** Whether there is a previous page */
394
- has_previous: boolean;
395
- /** Next page number (null if no next page) */
396
- next_page?: number | null;
397
- /** Previous page number (null if no previous page) */
398
- previous_page?: number | null;
399
- /** Array of items for current page */
400
- results: Array<NewsletterSubscription$1>;
401
- }
402
- /**
403
- * Simple serializer for unsubscribe.
404
- *
405
- * Request model (no read-only fields).
406
- */
407
- interface UnsubscribeRequest$2 {
408
- subscription_id: number;
409
- }
410
- /**
411
- * Generic success response.
412
- *
413
- * Response model (includes read-only fields).
414
- */
415
- interface SuccessResponse$1 {
416
- success: boolean;
417
- message: string;
418
- }
419
- /**
420
- * Serializer for NewsletterSubscription model.
421
- *
422
- * Response model (includes read-only fields).
423
- */
424
- interface NewsletterSubscription$1 {
425
- id: number;
426
- newsletter: number;
427
- newsletter_title: string;
428
- user?: number | null;
429
- user_email: string;
430
- email: string;
431
- is_active?: boolean;
432
- subscribed_at: string;
433
- unsubscribed_at?: string | null;
434
- }
435
-
436
- declare namespace models$2 {
437
- export type { ErrorResponse$1 as ErrorResponse, NewsletterSubscription$1 as NewsletterSubscription, PaginatedNewsletterSubscriptionList$1 as PaginatedNewsletterSubscriptionList, SubscribeRequest$1 as SubscribeRequest, SubscribeResponse$1 as SubscribeResponse, SuccessResponse$1 as SuccessResponse, UnsubscribeRequest$2 as UnsubscribeRequest };
438
- }
439
-
440
- /**
441
- * API endpoints for Subscriptions.
442
- */
443
- declare class ExtNewsletterSubscriptions {
444
- private client;
445
- constructor(client: any);
446
- /**
447
- * Subscribe to Newsletter
448
- *
449
- * Subscribe an email address to a newsletter.
450
- */
451
- newsletterSubscribeCreate(data: SubscribeRequest$1): Promise<SubscribeResponse$1>;
452
- newsletterSubscriptionsList(page?: number, page_size?: number): Promise<PaginatedNewsletterSubscriptionList$1>;
453
- newsletterSubscriptionsList(params?: {
454
- page?: number;
455
- page_size?: number;
456
- }): Promise<PaginatedNewsletterSubscriptionList$1>;
457
- /**
458
- * Unsubscribe from Newsletter
459
- *
460
- * Unsubscribe from a newsletter using subscription ID.
461
- */
462
- newsletterUnsubscribeCreate(data: UnsubscribeRequest$2): Promise<SuccessResponse$1>;
463
- }
464
-
465
- /**
466
- * Simple serializer for test email.
467
- *
468
- * Request model (no read-only fields).
469
- */
470
- interface TestEmailRequest$1 {
471
- email: string;
472
- subject?: string;
473
- message?: string;
474
- }
475
- /**
476
- * Response for bulk email sending.
477
- *
478
- * Response model (includes read-only fields).
479
- */
480
- interface BulkEmailResponse$1 {
481
- success: boolean;
482
- sent_count: number;
483
- failed_count: number;
484
- total_recipients: number;
485
- error?: string;
486
- }
487
-
488
- declare namespace models$1 {
489
- export type { BulkEmailResponse$1 as BulkEmailResponse, TestEmailRequest$1 as TestEmailRequest };
490
- }
491
-
492
- /**
493
- * API endpoints for Testing.
494
- */
495
- declare class ExtNewsletterTesting {
496
- private client;
497
- constructor(client: any);
498
- /**
499
- * Test Email Sending
500
- *
501
- * Send a test email to verify mailer configuration.
502
- */
503
- newsletterTestCreate(data: TestEmailRequest$1): Promise<BulkEmailResponse$1>;
504
- }
505
-
506
- /**
507
- * Serializer for NewsletterCampaign model.
508
- *
509
- * Request model (no read-only fields).
510
- */
511
- interface PatchedNewsletterCampaignRequest$1 {
512
- newsletter?: number;
513
- subject?: string;
514
- email_title?: string;
515
- main_text?: string;
516
- main_html_content?: string;
517
- button_text?: string;
518
- button_url?: string;
519
- secondary_text?: string;
520
- }
521
- /**
522
- * Serializer for NewsletterCampaign model.
523
- *
524
- * Response model (includes read-only fields).
525
- */
526
- interface NewsletterCampaign$1 {
527
- id: number;
528
- newsletter: number;
529
- newsletter_title: string;
530
- subject: string;
531
- email_title: string;
532
- main_text: string;
533
- main_html_content?: string;
534
- button_text?: string;
535
- button_url?: string;
536
- secondary_text?: string;
537
- /** * `draft` - Draft
538
- * `sending` - Sending
539
- * `sent` - Sent
540
- * `failed` - Failed */
541
- status: NewsletterCampaignStatus;
542
- created_at: string;
543
- sent_at?: string | null;
544
- recipient_count: number;
545
- }
546
- /**
547
- * Simple serializer for unsubscribe.
548
- *
549
- * Request model (no read-only fields).
550
- */
551
- interface UnsubscribeRequest$1 {
552
- subscription_id: number;
553
- }
554
- /**
555
- * Simple serializer for unsubscribe.
556
- *
557
- * Response model (includes read-only fields).
558
- */
559
- interface Unsubscribe$1 {
560
- subscription_id: number;
561
- }
562
- /**
563
- * Simple serializer for unsubscribe.
564
- *
565
- * Request model (no read-only fields).
566
- */
567
- interface PatchedUnsubscribeRequest$1 {
568
- subscription_id?: number;
569
- }
570
-
571
- declare namespace models {
572
- export type { NewsletterCampaign$1 as NewsletterCampaign, PatchedNewsletterCampaignRequest$1 as PatchedNewsletterCampaignRequest, PatchedUnsubscribeRequest$1 as PatchedUnsubscribeRequest, Unsubscribe$1 as Unsubscribe, UnsubscribeRequest$1 as UnsubscribeRequest };
573
- }
574
-
575
- /**
576
- * API endpoints for Newsletter.
577
- */
578
- declare class ExtNewsletterNewsletter {
579
- private client;
580
- constructor(client: any);
581
- /**
582
- * Retrieve, update, or delete a newsletter campaign.
583
- */
584
- campaignsPartialUpdate(id: number, data?: PatchedNewsletterCampaignRequest$1): Promise<NewsletterCampaign$1>;
585
- /**
586
- * Handle newsletter unsubscriptions.
587
- */
588
- unsubscribeUpdate(data: UnsubscribeRequest$1): Promise<Unsubscribe$1>;
589
- /**
590
- * Handle newsletter unsubscriptions.
591
- */
592
- unsubscribePartialUpdate(data?: PatchedUnsubscribeRequest$1): Promise<Unsubscribe$1>;
593
- }
594
-
595
- /**
596
- * HTTP Client Adapter Pattern
597
- *
598
- * Allows switching between fetch/axios/httpx without changing generated code.
599
- * Provides unified interface for making HTTP requests.
600
- */
601
- interface HttpRequest {
602
- method: string;
603
- url: string;
604
- headers?: Record<string, string>;
605
- body?: any;
606
- params?: Record<string, any>;
607
- /** FormData for file uploads (multipart/form-data) */
608
- formData?: FormData;
609
- }
610
- interface HttpResponse<T = any> {
611
- data: T;
612
- status: number;
613
- statusText: string;
614
- headers: Record<string, string>;
615
- }
616
- /**
617
- * HTTP Client Adapter Interface.
618
- * Implement this to use custom HTTP clients (axios, httpx, etc.)
619
- */
620
- interface HttpClientAdapter {
621
- request<T = any>(request: HttpRequest): Promise<HttpResponse<T>>;
622
- }
623
- /**
624
- * Default Fetch API adapter.
625
- * Uses native browser fetch() with proper error handling.
626
- */
627
- declare class FetchAdapter implements HttpClientAdapter {
628
- request<T = any>(request: HttpRequest): Promise<HttpResponse<T>>;
629
- }
630
-
631
- /**
632
- * API Logger with Consola
633
- * Beautiful console logging for API requests and responses
634
- *
635
- * Installation:
636
- * npm install consola
637
- */
638
-
639
- /**
640
- * Request log data
641
- */
642
- interface RequestLog {
643
- method: string;
644
- url: string;
645
- headers?: Record<string, string>;
646
- body?: any;
647
- timestamp: number;
648
- }
649
- /**
650
- * Response log data
651
- */
652
- interface ResponseLog {
653
- status: number;
654
- statusText: string;
655
- data?: any;
656
- duration: number;
657
- timestamp: number;
658
- }
659
- /**
660
- * Error log data
661
- */
662
- interface ErrorLog {
663
- message: string;
664
- statusCode?: number;
665
- fieldErrors?: Record<string, string[]>;
666
- duration: number;
667
- timestamp: number;
668
- }
669
- /**
670
- * Logger configuration
671
- */
672
- interface LoggerConfig {
673
- /** Enable logging */
674
- enabled: boolean;
675
- /** Log requests */
676
- logRequests: boolean;
677
- /** Log responses */
678
- logResponses: boolean;
679
- /** Log errors */
680
- logErrors: boolean;
681
- /** Log request/response bodies */
682
- logBodies: boolean;
683
- /** Log headers (excluding sensitive ones) */
684
- logHeaders: boolean;
685
- /** Custom consola instance */
686
- consola?: ConsolaInstance;
687
- }
688
- /**
689
- * API Logger class
690
- */
691
- declare class APILogger {
692
- private config;
693
- private consola;
694
- constructor(config?: Partial<LoggerConfig>);
695
- /**
696
- * Enable logging
697
- */
698
- enable(): void;
699
- /**
700
- * Disable logging
701
- */
702
- disable(): void;
703
- /**
704
- * Update configuration
705
- */
706
- setConfig(config: Partial<LoggerConfig>): void;
707
- /**
708
- * Filter sensitive headers
709
- */
710
- private filterHeaders;
711
- /**
712
- * Log request
713
- */
714
- logRequest(request: RequestLog): void;
715
- /**
716
- * Log response
717
- */
718
- logResponse(request: RequestLog, response: ResponseLog): void;
719
- /**
720
- * Log error
721
- */
722
- logError(request: RequestLog, error: ErrorLog): void;
723
- /**
724
- * Log general info
725
- */
726
- info(message: string, ...args: any[]): void;
727
- /**
728
- * Log warning
729
- */
730
- warn(message: string, ...args: any[]): void;
731
- /**
732
- * Log error
733
- */
734
- error(message: string, ...args: any[]): void;
735
- /**
736
- * Log debug
737
- */
738
- debug(message: string, ...args: any[]): void;
739
- /**
740
- * Log success
741
- */
742
- success(message: string, ...args: any[]): void;
743
- /**
744
- * Create a sub-logger with prefix
745
- */
746
- withTag(tag: string): ConsolaInstance;
747
- }
748
-
749
- /**
750
- * Retry Configuration and Utilities
751
- *
752
- * Provides automatic retry logic for failed HTTP requests using p-retry.
753
- * Retries only on network errors and server errors (5xx), not client errors (4xx).
754
- */
755
- /**
756
- * Information about a failed retry attempt.
757
- */
758
- interface FailedAttemptInfo {
759
- /** The error that caused the failure */
760
- error: Error;
761
- /** The attempt number (1-indexed) */
762
- attemptNumber: number;
763
- /** Number of retries left */
764
- retriesLeft: number;
765
- }
766
- /**
767
- * Retry configuration options.
768
- *
769
- * Uses exponential backoff with jitter by default to avoid thundering herd.
770
- */
771
- interface RetryConfig {
772
- /**
773
- * Maximum number of retry attempts.
774
- * @default 3
775
- */
776
- retries?: number;
777
- /**
778
- * Exponential backoff factor.
779
- * @default 2
780
- */
781
- factor?: number;
782
- /**
783
- * Minimum wait time between retries (ms).
784
- * @default 1000
785
- */
786
- minTimeout?: number;
787
- /**
788
- * Maximum wait time between retries (ms).
789
- * @default 60000
790
- */
791
- maxTimeout?: number;
792
- /**
793
- * Add randomness to wait times (jitter).
794
- * Helps avoid thundering herd problem.
795
- * @default true
796
- */
797
- randomize?: boolean;
798
- /**
799
- * Callback called on each failed attempt.
800
- */
801
- onFailedAttempt?: (info: FailedAttemptInfo) => void;
802
- }
803
- /**
804
- * Default retry configuration.
805
- */
806
- declare const DEFAULT_RETRY_CONFIG: Required<RetryConfig>;
807
- /**
808
- * Determine if an error should trigger a retry.
809
- *
810
- * Retries on:
811
- * - Network errors (connection refused, timeout, etc.)
812
- * - Server errors (5xx status codes)
813
- * - Rate limiting (429 status code)
814
- *
815
- * Does NOT retry on:
816
- * - Client errors (4xx except 429)
817
- * - Authentication errors (401, 403)
818
- * - Not found (404)
819
- *
820
- * @param error - The error to check
821
- * @returns true if should retry, false otherwise
822
- */
823
- declare function shouldRetry(error: any): boolean;
824
- /**
825
- * Wrap a function with retry logic.
826
- *
827
- * @param fn - Async function to retry
828
- * @param config - Retry configuration
829
- * @returns Result of the function
830
- *
831
- * @example
832
- * ```typescript
833
- * const result = await withRetry(
834
- * async () => fetch('https://api.example.com/users'),
835
- * { retries: 5, minTimeout: 2000 }
836
- * );
837
- * ```
838
- */
839
- declare function withRetry<T>(fn: () => Promise<T>, config?: RetryConfig): Promise<T>;
840
-
841
- /**
842
- * Async API client for Django CFG API.
843
- *
844
- * Usage:
845
- * ```typescript
846
- * const client = new APIClient('https://api.example.com');
847
- * const users = await client.users.list();
848
- * const post = await client.posts.create(newPost);
849
- *
850
- * // Custom HTTP adapter (e.g., Axios)
851
- * const client = new APIClient('https://api.example.com', {
852
- * httpClient: new AxiosAdapter()
853
- * });
854
- * ```
855
- */
856
- declare class APIClient {
857
- private baseUrl;
858
- private httpClient;
859
- private logger;
860
- private retryConfig;
861
- ext_newsletter_bulk_email: ExtNewsletterBulkEmail;
862
- ext_newsletter_campaigns: ExtNewsletterCampaigns;
863
- ext_newsletter_logs: ExtNewsletterLogs;
864
- ext_newsletter_newsletters: ExtNewsletterNewsletters;
865
- ext_newsletter_subscriptions: ExtNewsletterSubscriptions;
866
- ext_newsletter_testing: ExtNewsletterTesting;
867
- ext_newsletter_newsletter: ExtNewsletterNewsletter;
868
- constructor(baseUrl: string, options?: {
869
- httpClient?: HttpClientAdapter;
870
- loggerConfig?: Partial<LoggerConfig>;
871
- retryConfig?: RetryConfig;
872
- });
873
- /**
874
- * Get CSRF token from cookies (for SessionAuthentication).
875
- *
876
- * Returns null if cookie doesn't exist (JWT-only auth).
877
- */
878
- getCsrfToken(): string | null;
879
- /**
880
- * Make HTTP request with Django CSRF and session handling.
881
- * Automatically retries on network errors and 5xx server errors.
882
- */
883
- request<T>(method: string, path: string, options?: {
884
- params?: Record<string, any>;
885
- body?: any;
886
- formData?: FormData;
887
- headers?: Record<string, string>;
888
- }): Promise<T>;
889
- /**
890
- * Internal request method (without retry wrapper).
891
- * Used by request() method with optional retry logic.
892
- */
893
- private _makeRequest;
894
- }
895
-
896
- /**
897
- * Storage adapters for cross-platform token storage.
898
- *
899
- * Supports:
900
- * - LocalStorage (browser)
901
- * - Cookies (SSR/browser)
902
- * - Memory (Node.js/Electron/testing)
903
- */
904
-
905
- /**
906
- * Storage adapter interface for cross-platform token storage.
907
- */
908
- interface StorageAdapter {
909
- getItem(key: string): string | null;
910
- setItem(key: string, value: string): void;
911
- removeItem(key: string): void;
912
- }
913
- /**
914
- * LocalStorage adapter with safe try-catch for browser environments.
915
- * Works in modern browsers with localStorage support.
916
- *
917
- * Note: This adapter uses window.localStorage and should only be used in browser/client environments.
918
- * For server-side usage, use MemoryStorageAdapter or CookieStorageAdapter instead.
919
- */
920
- declare class LocalStorageAdapter implements StorageAdapter {
921
- private logger?;
922
- constructor(logger?: APILogger);
923
- getItem(key: string): string | null;
924
- setItem(key: string, value: string): void;
925
- removeItem(key: string): void;
926
- }
927
- /**
928
- * Cookie-based storage adapter for SSR and browser environments.
929
- * Useful for Next.js, Nuxt.js, and other SSR frameworks.
930
- */
931
- declare class CookieStorageAdapter implements StorageAdapter {
932
- private logger?;
933
- constructor(logger?: APILogger);
934
- getItem(key: string): string | null;
935
- setItem(key: string, value: string): void;
936
- removeItem(key: string): void;
937
- }
938
- /**
939
- * In-memory storage adapter for Node.js, Electron, and testing environments.
940
- * Data is stored in RAM and cleared when process exits.
941
- */
942
- declare class MemoryStorageAdapter implements StorageAdapter {
943
- private storage;
944
- private logger?;
945
- constructor(logger?: APILogger);
946
- getItem(key: string): string | null;
947
- setItem(key: string, value: string): void;
948
- removeItem(key: string): void;
949
- }
950
-
951
- /**
952
- * Zod schema for BulkEmailRequest
953
- *
954
- * This schema provides runtime validation and type inference.
955
- * * Simple serializer for bulk email.
956
- * */
957
-
958
- /**
959
- * Simple serializer for bulk email.
960
- */
961
- declare const BulkEmailRequestSchema: z.ZodObject<{
962
- recipients: z.ZodArray<z.ZodEmail>;
963
- subject: z.ZodString;
964
- email_title: z.ZodString;
965
- main_text: z.ZodString;
966
- main_html_content: z.ZodOptional<z.ZodString>;
967
- button_text: z.ZodOptional<z.ZodString>;
968
- button_url: z.ZodOptional<z.ZodURL>;
969
- secondary_text: z.ZodOptional<z.ZodString>;
970
- }, z.core.$strip>;
971
- /**
972
- * Infer TypeScript type from Zod schema
973
- */
974
- type BulkEmailRequest = z.infer<typeof BulkEmailRequestSchema>;
975
-
976
- /**
977
- * Zod schema for BulkEmailResponse
978
- *
979
- * This schema provides runtime validation and type inference.
980
- * * Response for bulk email sending.
981
- * */
982
-
983
- /**
984
- * Response for bulk email sending.
985
- */
986
- declare const BulkEmailResponseSchema: z.ZodObject<{
987
- success: z.ZodBoolean;
988
- sent_count: z.ZodInt;
989
- failed_count: z.ZodInt;
990
- total_recipients: z.ZodInt;
991
- error: z.ZodOptional<z.ZodString>;
992
- }, z.core.$strip>;
993
- /**
994
- * Infer TypeScript type from Zod schema
995
- */
996
- type BulkEmailResponse = z.infer<typeof BulkEmailResponseSchema>;
997
-
998
- /**
999
- * Zod schema for EmailLog
1000
- *
1001
- * This schema provides runtime validation and type inference.
1002
- * * Serializer for EmailLog model.
1003
- * */
1004
-
1005
- /**
1006
- * Serializer for EmailLog model.
1007
- */
1008
- declare const EmailLogSchema: z.ZodObject<{
1009
- id: z.ZodString;
1010
- user: z.ZodNullable<z.ZodInt>;
1011
- user_email: z.ZodString;
1012
- newsletter: z.ZodNullable<z.ZodInt>;
1013
- newsletter_title: z.ZodString;
1014
- recipient: z.ZodString;
1015
- subject: z.ZodString;
1016
- body: z.ZodString;
1017
- status: z.ZodEnum<typeof EmailLogStatus>;
1018
- created_at: z.ZodISODateTime;
1019
- sent_at: z.ZodNullable<z.ZodISODateTime>;
1020
- error_message: z.ZodNullable<z.ZodString>;
1021
- }, z.core.$strip>;
1022
- /**
1023
- * Infer TypeScript type from Zod schema
1024
- */
1025
- type EmailLog = z.infer<typeof EmailLogSchema>;
1026
-
1027
- /**
1028
- * Zod schema for ErrorResponse
1029
- *
1030
- * This schema provides runtime validation and type inference.
1031
- * * Generic error response.
1032
- * */
1033
-
1034
- /**
1035
- * Generic error response.
1036
- */
1037
- declare const ErrorResponseSchema: z.ZodObject<{
1038
- success: z.ZodOptional<z.ZodBoolean>;
1039
- message: z.ZodString;
1040
- }, z.core.$strip>;
1041
- /**
1042
- * Infer TypeScript type from Zod schema
1043
- */
1044
- type ErrorResponse = z.infer<typeof ErrorResponseSchema>;
1045
-
1046
- /**
1047
- * Zod schema for Newsletter
1048
- *
1049
- * This schema provides runtime validation and type inference.
1050
- * * Serializer for Newsletter model.
1051
- * */
1052
-
1053
- /**
1054
- * Serializer for Newsletter model.
1055
- */
1056
- declare const NewsletterSchema: z.ZodObject<{
1057
- id: z.ZodInt;
1058
- title: z.ZodString;
1059
- description: z.ZodOptional<z.ZodString>;
1060
- is_active: z.ZodOptional<z.ZodBoolean>;
1061
- auto_subscribe: z.ZodOptional<z.ZodBoolean>;
1062
- created_at: z.ZodISODateTime;
1063
- updated_at: z.ZodISODateTime;
1064
- subscribers_count: z.ZodInt;
1065
- }, z.core.$strip>;
1066
- /**
1067
- * Infer TypeScript type from Zod schema
1068
- */
1069
- type Newsletter = z.infer<typeof NewsletterSchema>;
1070
-
1071
- /**
1072
- * Zod schema for NewsletterCampaign
1073
- *
1074
- * This schema provides runtime validation and type inference.
1075
- * * Serializer for NewsletterCampaign model.
1076
- * */
1077
-
1078
- /**
1079
- * Serializer for NewsletterCampaign model.
1080
- */
1081
- declare const NewsletterCampaignSchema: z.ZodObject<{
1082
- id: z.ZodInt;
1083
- newsletter: z.ZodInt;
1084
- newsletter_title: z.ZodString;
1085
- subject: z.ZodString;
1086
- email_title: z.ZodString;
1087
- main_text: z.ZodString;
1088
- main_html_content: z.ZodOptional<z.ZodString>;
1089
- button_text: z.ZodOptional<z.ZodString>;
1090
- button_url: z.ZodOptional<z.ZodURL>;
1091
- secondary_text: z.ZodOptional<z.ZodString>;
1092
- status: z.ZodEnum<typeof NewsletterCampaignStatus>;
1093
- created_at: z.ZodISODateTime;
1094
- sent_at: z.ZodNullable<z.ZodISODateTime>;
1095
- recipient_count: z.ZodInt;
1096
- }, z.core.$strip>;
1097
- /**
1098
- * Infer TypeScript type from Zod schema
1099
- */
1100
- type NewsletterCampaign = z.infer<typeof NewsletterCampaignSchema>;
1101
-
1102
- /**
1103
- * Zod schema for NewsletterCampaignRequest
1104
- *
1105
- * This schema provides runtime validation and type inference.
1106
- * * Serializer for NewsletterCampaign model.
1107
- * */
1108
-
1109
- /**
1110
- * Serializer for NewsletterCampaign model.
1111
- */
1112
- declare const NewsletterCampaignRequestSchema: z.ZodObject<{
1113
- newsletter: z.ZodInt;
1114
- subject: z.ZodString;
1115
- email_title: z.ZodString;
1116
- main_text: z.ZodString;
1117
- main_html_content: z.ZodOptional<z.ZodString>;
1118
- button_text: z.ZodOptional<z.ZodString>;
1119
- button_url: z.ZodOptional<z.ZodURL>;
1120
- secondary_text: z.ZodOptional<z.ZodString>;
1121
- }, z.core.$strip>;
1122
- /**
1123
- * Infer TypeScript type from Zod schema
1124
- */
1125
- type NewsletterCampaignRequest = z.infer<typeof NewsletterCampaignRequestSchema>;
1126
-
1127
- /**
1128
- * Zod schema for NewsletterSubscription
1129
- *
1130
- * This schema provides runtime validation and type inference.
1131
- * * Serializer for NewsletterSubscription model.
1132
- * */
1133
-
1134
- /**
1135
- * Serializer for NewsletterSubscription model.
1136
- */
1137
- declare const NewsletterSubscriptionSchema: z.ZodObject<{
1138
- id: z.ZodInt;
1139
- newsletter: z.ZodInt;
1140
- newsletter_title: z.ZodString;
1141
- user: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
1142
- user_email: z.ZodString;
1143
- email: z.ZodEmail;
1144
- is_active: z.ZodOptional<z.ZodBoolean>;
1145
- subscribed_at: z.ZodISODateTime;
1146
- unsubscribed_at: z.ZodNullable<z.ZodISODateTime>;
1147
- }, z.core.$strip>;
1148
- /**
1149
- * Infer TypeScript type from Zod schema
1150
- */
1151
- type NewsletterSubscription = z.infer<typeof NewsletterSubscriptionSchema>;
1152
-
1153
- declare const PaginatedEmailLogListSchema: z.ZodObject<{
1154
- count: z.ZodInt;
1155
- page: z.ZodInt;
1156
- pages: z.ZodInt;
1157
- page_size: z.ZodInt;
1158
- has_next: z.ZodBoolean;
1159
- has_previous: z.ZodBoolean;
1160
- next_page: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
1161
- previous_page: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
1162
- results: z.ZodArray<z.ZodObject<{
1163
- id: z.ZodString;
1164
- user: z.ZodNullable<z.ZodInt>;
1165
- user_email: z.ZodString;
1166
- newsletter: z.ZodNullable<z.ZodInt>;
1167
- newsletter_title: z.ZodString;
1168
- recipient: z.ZodString;
1169
- subject: z.ZodString;
1170
- body: z.ZodString;
1171
- status: z.ZodEnum<typeof EmailLogStatus>;
1172
- created_at: z.ZodISODateTime;
1173
- sent_at: z.ZodNullable<z.ZodISODateTime>;
1174
- error_message: z.ZodNullable<z.ZodString>;
1175
- }, z.core.$strip>>;
1176
- }, z.core.$strip>;
1177
- /**
1178
- * Infer TypeScript type from Zod schema
1179
- */
1180
- type PaginatedEmailLogList = z.infer<typeof PaginatedEmailLogListSchema>;
1181
-
1182
- declare const PaginatedNewsletterCampaignListSchema: z.ZodObject<{
1183
- count: z.ZodInt;
1184
- page: z.ZodInt;
1185
- pages: z.ZodInt;
1186
- page_size: z.ZodInt;
1187
- has_next: z.ZodBoolean;
1188
- has_previous: z.ZodBoolean;
1189
- next_page: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
1190
- previous_page: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
1191
- results: z.ZodArray<z.ZodObject<{
1192
- id: z.ZodInt;
1193
- newsletter: z.ZodInt;
1194
- newsletter_title: z.ZodString;
1195
- subject: z.ZodString;
1196
- email_title: z.ZodString;
1197
- main_text: z.ZodString;
1198
- main_html_content: z.ZodOptional<z.ZodString>;
1199
- button_text: z.ZodOptional<z.ZodString>;
1200
- button_url: z.ZodOptional<z.ZodURL>;
1201
- secondary_text: z.ZodOptional<z.ZodString>;
1202
- status: z.ZodEnum<typeof NewsletterCampaignStatus>;
1203
- created_at: z.ZodISODateTime;
1204
- sent_at: z.ZodNullable<z.ZodISODateTime>;
1205
- recipient_count: z.ZodInt;
1206
- }, z.core.$strip>>;
1207
- }, z.core.$strip>;
1208
- /**
1209
- * Infer TypeScript type from Zod schema
1210
- */
1211
- type PaginatedNewsletterCampaignList = z.infer<typeof PaginatedNewsletterCampaignListSchema>;
1212
-
1213
- /**
1214
- * Zod schema for PaginatedNewsletterList
1215
- *
1216
- * This schema provides runtime validation and type inference.
1217
- * */
1218
-
1219
- declare const PaginatedNewsletterListSchema: z.ZodObject<{
1220
- count: z.ZodInt;
1221
- page: z.ZodInt;
1222
- pages: z.ZodInt;
1223
- page_size: z.ZodInt;
1224
- has_next: z.ZodBoolean;
1225
- has_previous: z.ZodBoolean;
1226
- next_page: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
1227
- previous_page: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
1228
- results: z.ZodArray<z.ZodObject<{
1229
- id: z.ZodInt;
1230
- title: z.ZodString;
1231
- description: z.ZodOptional<z.ZodString>;
1232
- is_active: z.ZodOptional<z.ZodBoolean>;
1233
- auto_subscribe: z.ZodOptional<z.ZodBoolean>;
1234
- created_at: z.ZodISODateTime;
1235
- updated_at: z.ZodISODateTime;
1236
- subscribers_count: z.ZodInt;
1237
- }, z.core.$strip>>;
1238
- }, z.core.$strip>;
1239
- /**
1240
- * Infer TypeScript type from Zod schema
1241
- */
1242
- type PaginatedNewsletterList = z.infer<typeof PaginatedNewsletterListSchema>;
1243
-
1244
- /**
1245
- * Zod schema for PaginatedNewsletterSubscriptionList
1246
- *
1247
- * This schema provides runtime validation and type inference.
1248
- * */
1249
-
1250
- declare const PaginatedNewsletterSubscriptionListSchema: z.ZodObject<{
1251
- count: z.ZodInt;
1252
- page: z.ZodInt;
1253
- pages: z.ZodInt;
1254
- page_size: z.ZodInt;
1255
- has_next: z.ZodBoolean;
1256
- has_previous: z.ZodBoolean;
1257
- next_page: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
1258
- previous_page: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
1259
- results: z.ZodArray<z.ZodObject<{
1260
- id: z.ZodInt;
1261
- newsletter: z.ZodInt;
1262
- newsletter_title: z.ZodString;
1263
- user: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
1264
- user_email: z.ZodString;
1265
- email: z.ZodEmail;
1266
- is_active: z.ZodOptional<z.ZodBoolean>;
1267
- subscribed_at: z.ZodISODateTime;
1268
- unsubscribed_at: z.ZodNullable<z.ZodISODateTime>;
1269
- }, z.core.$strip>>;
1270
- }, z.core.$strip>;
1271
- /**
1272
- * Infer TypeScript type from Zod schema
1273
- */
1274
- type PaginatedNewsletterSubscriptionList = z.infer<typeof PaginatedNewsletterSubscriptionListSchema>;
1275
-
1276
- /**
1277
- * Zod schema for PatchedNewsletterCampaignRequest
1278
- *
1279
- * This schema provides runtime validation and type inference.
1280
- * * Serializer for NewsletterCampaign model.
1281
- * */
1282
-
1283
- /**
1284
- * Serializer for NewsletterCampaign model.
1285
- */
1286
- declare const PatchedNewsletterCampaignRequestSchema: z.ZodObject<{
1287
- newsletter: z.ZodOptional<z.ZodInt>;
1288
- subject: z.ZodOptional<z.ZodString>;
1289
- email_title: z.ZodOptional<z.ZodString>;
1290
- main_text: z.ZodOptional<z.ZodString>;
1291
- main_html_content: z.ZodOptional<z.ZodString>;
1292
- button_text: z.ZodOptional<z.ZodString>;
1293
- button_url: z.ZodOptional<z.ZodURL>;
1294
- secondary_text: z.ZodOptional<z.ZodString>;
1295
- }, z.core.$strip>;
1296
- /**
1297
- * Infer TypeScript type from Zod schema
1298
- */
1299
- type PatchedNewsletterCampaignRequest = z.infer<typeof PatchedNewsletterCampaignRequestSchema>;
1300
-
1301
- /**
1302
- * Zod schema for PatchedUnsubscribeRequest
1303
- *
1304
- * This schema provides runtime validation and type inference.
1305
- * * Simple serializer for unsubscribe.
1306
- * */
1307
-
1308
- /**
1309
- * Simple serializer for unsubscribe.
1310
- */
1311
- declare const PatchedUnsubscribeRequestSchema: z.ZodObject<{
1312
- subscription_id: z.ZodOptional<z.ZodInt>;
1313
- }, z.core.$strip>;
1314
- /**
1315
- * Infer TypeScript type from Zod schema
1316
- */
1317
- type PatchedUnsubscribeRequest = z.infer<typeof PatchedUnsubscribeRequestSchema>;
1318
-
1319
- /**
1320
- * Zod schema for SendCampaignRequest
1321
- *
1322
- * This schema provides runtime validation and type inference.
1323
- * * Simple serializer for sending campaign.
1324
- * */
1325
-
1326
- /**
1327
- * Simple serializer for sending campaign.
1328
- */
1329
- declare const SendCampaignRequestSchema: z.ZodObject<{
1330
- campaign_id: z.ZodInt;
1331
- }, z.core.$strip>;
1332
- /**
1333
- * Infer TypeScript type from Zod schema
1334
- */
1335
- type SendCampaignRequest = z.infer<typeof SendCampaignRequestSchema>;
1336
-
1337
- /**
1338
- * Zod schema for SendCampaignResponse
1339
- *
1340
- * This schema provides runtime validation and type inference.
1341
- * * Response for sending campaign.
1342
- * */
1343
-
1344
- /**
1345
- * Response for sending campaign.
1346
- */
1347
- declare const SendCampaignResponseSchema: z.ZodObject<{
1348
- success: z.ZodBoolean;
1349
- message: z.ZodOptional<z.ZodString>;
1350
- sent_count: z.ZodOptional<z.ZodInt>;
1351
- error: z.ZodOptional<z.ZodString>;
1352
- }, z.core.$strip>;
1353
- /**
1354
- * Infer TypeScript type from Zod schema
1355
- */
1356
- type SendCampaignResponse = z.infer<typeof SendCampaignResponseSchema>;
1357
-
1358
- /**
1359
- * Zod schema for SubscribeRequest
1360
- *
1361
- * This schema provides runtime validation and type inference.
1362
- * * Simple serializer for newsletter subscription.
1363
- * */
1364
-
1365
- /**
1366
- * Simple serializer for newsletter subscription.
1367
- */
1368
- declare const SubscribeRequestSchema: z.ZodObject<{
1369
- newsletter_id: z.ZodInt;
1370
- email: z.ZodEmail;
1371
- }, z.core.$strip>;
1372
- /**
1373
- * Infer TypeScript type from Zod schema
1374
- */
1375
- type SubscribeRequest = z.infer<typeof SubscribeRequestSchema>;
1376
-
1377
- /**
1378
- * Zod schema for SubscribeResponse
1379
- *
1380
- * This schema provides runtime validation and type inference.
1381
- * * Response for subscription.
1382
- * */
1383
-
1384
- /**
1385
- * Response for subscription.
1386
- */
1387
- declare const SubscribeResponseSchema: z.ZodObject<{
1388
- success: z.ZodBoolean;
1389
- message: z.ZodString;
1390
- subscription_id: z.ZodOptional<z.ZodInt>;
1391
- }, z.core.$strip>;
1392
- /**
1393
- * Infer TypeScript type from Zod schema
1394
- */
1395
- type SubscribeResponse = z.infer<typeof SubscribeResponseSchema>;
1396
-
1397
- /**
1398
- * Zod schema for SuccessResponse
1399
- *
1400
- * This schema provides runtime validation and type inference.
1401
- * * Generic success response.
1402
- * */
1403
-
1404
- /**
1405
- * Generic success response.
1406
- */
1407
- declare const SuccessResponseSchema: z.ZodObject<{
1408
- success: z.ZodBoolean;
1409
- message: z.ZodString;
1410
- }, z.core.$strip>;
1411
- /**
1412
- * Infer TypeScript type from Zod schema
1413
- */
1414
- type SuccessResponse = z.infer<typeof SuccessResponseSchema>;
1415
-
1416
- /**
1417
- * Zod schema for TestEmailRequest
1418
- *
1419
- * This schema provides runtime validation and type inference.
1420
- * * Simple serializer for test email.
1421
- * */
1422
-
1423
- /**
1424
- * Simple serializer for test email.
1425
- */
1426
- declare const TestEmailRequestSchema: z.ZodObject<{
1427
- email: z.ZodEmail;
1428
- subject: z.ZodOptional<z.ZodString>;
1429
- message: z.ZodOptional<z.ZodString>;
1430
- }, z.core.$strip>;
1431
- /**
1432
- * Infer TypeScript type from Zod schema
1433
- */
1434
- type TestEmailRequest = z.infer<typeof TestEmailRequestSchema>;
1435
-
1436
- /**
1437
- * Zod schema for Unsubscribe
1438
- *
1439
- * This schema provides runtime validation and type inference.
1440
- * * Simple serializer for unsubscribe.
1441
- * */
1442
-
1443
- /**
1444
- * Simple serializer for unsubscribe.
1445
- */
1446
- declare const UnsubscribeSchema: z.ZodObject<{
1447
- subscription_id: z.ZodInt;
1448
- }, z.core.$strip>;
1449
- /**
1450
- * Infer TypeScript type from Zod schema
1451
- */
1452
- type Unsubscribe = z.infer<typeof UnsubscribeSchema>;
1453
-
1454
- /**
1455
- * Zod schema for UnsubscribeRequest
1456
- *
1457
- * This schema provides runtime validation and type inference.
1458
- * * Simple serializer for unsubscribe.
1459
- * */
1460
-
1461
- /**
1462
- * Simple serializer for unsubscribe.
1463
- */
1464
- declare const UnsubscribeRequestSchema: z.ZodObject<{
1465
- subscription_id: z.ZodInt;
1466
- }, z.core.$strip>;
1467
- /**
1468
- * Infer TypeScript type from Zod schema
1469
- */
1470
- type UnsubscribeRequest = z.infer<typeof UnsubscribeRequestSchema>;
1471
-
1472
- /**
1473
- * Zod Schemas - Runtime validation and type inference
1474
- *
1475
- * Auto-generated from OpenAPI specification.
1476
- * Provides runtime validation for API requests and responses.
1477
- *
1478
- * Usage:
1479
- * ```typescript
1480
- * import { UserSchema } from './schemas'
1481
- *
1482
- * // Validate data
1483
- * const user = UserSchema.parse(data)
1484
- *
1485
- * // Type inference
1486
- * type User = z.infer<typeof UserSchema>
1487
- * ```
1488
- */
1489
-
1490
- type index$1_BulkEmailRequest = BulkEmailRequest;
1491
- declare const index$1_BulkEmailRequestSchema: typeof BulkEmailRequestSchema;
1492
- type index$1_BulkEmailResponse = BulkEmailResponse;
1493
- declare const index$1_BulkEmailResponseSchema: typeof BulkEmailResponseSchema;
1494
- type index$1_EmailLog = EmailLog;
1495
- declare const index$1_EmailLogSchema: typeof EmailLogSchema;
1496
- type index$1_ErrorResponse = ErrorResponse;
1497
- declare const index$1_ErrorResponseSchema: typeof ErrorResponseSchema;
1498
- type index$1_Newsletter = Newsletter;
1499
- type index$1_NewsletterCampaign = NewsletterCampaign;
1500
- type index$1_NewsletterCampaignRequest = NewsletterCampaignRequest;
1501
- declare const index$1_NewsletterCampaignRequestSchema: typeof NewsletterCampaignRequestSchema;
1502
- declare const index$1_NewsletterCampaignSchema: typeof NewsletterCampaignSchema;
1503
- declare const index$1_NewsletterSchema: typeof NewsletterSchema;
1504
- type index$1_NewsletterSubscription = NewsletterSubscription;
1505
- declare const index$1_NewsletterSubscriptionSchema: typeof NewsletterSubscriptionSchema;
1506
- type index$1_PaginatedEmailLogList = PaginatedEmailLogList;
1507
- declare const index$1_PaginatedEmailLogListSchema: typeof PaginatedEmailLogListSchema;
1508
- type index$1_PaginatedNewsletterCampaignList = PaginatedNewsletterCampaignList;
1509
- declare const index$1_PaginatedNewsletterCampaignListSchema: typeof PaginatedNewsletterCampaignListSchema;
1510
- type index$1_PaginatedNewsletterList = PaginatedNewsletterList;
1511
- declare const index$1_PaginatedNewsletterListSchema: typeof PaginatedNewsletterListSchema;
1512
- type index$1_PaginatedNewsletterSubscriptionList = PaginatedNewsletterSubscriptionList;
1513
- declare const index$1_PaginatedNewsletterSubscriptionListSchema: typeof PaginatedNewsletterSubscriptionListSchema;
1514
- type index$1_PatchedNewsletterCampaignRequest = PatchedNewsletterCampaignRequest;
1515
- declare const index$1_PatchedNewsletterCampaignRequestSchema: typeof PatchedNewsletterCampaignRequestSchema;
1516
- type index$1_PatchedUnsubscribeRequest = PatchedUnsubscribeRequest;
1517
- declare const index$1_PatchedUnsubscribeRequestSchema: typeof PatchedUnsubscribeRequestSchema;
1518
- type index$1_SendCampaignRequest = SendCampaignRequest;
1519
- declare const index$1_SendCampaignRequestSchema: typeof SendCampaignRequestSchema;
1520
- type index$1_SendCampaignResponse = SendCampaignResponse;
1521
- declare const index$1_SendCampaignResponseSchema: typeof SendCampaignResponseSchema;
1522
- type index$1_SubscribeRequest = SubscribeRequest;
1523
- declare const index$1_SubscribeRequestSchema: typeof SubscribeRequestSchema;
1524
- type index$1_SubscribeResponse = SubscribeResponse;
1525
- declare const index$1_SubscribeResponseSchema: typeof SubscribeResponseSchema;
1526
- type index$1_SuccessResponse = SuccessResponse;
1527
- declare const index$1_SuccessResponseSchema: typeof SuccessResponseSchema;
1528
- type index$1_TestEmailRequest = TestEmailRequest;
1529
- declare const index$1_TestEmailRequestSchema: typeof TestEmailRequestSchema;
1530
- type index$1_Unsubscribe = Unsubscribe;
1531
- type index$1_UnsubscribeRequest = UnsubscribeRequest;
1532
- declare const index$1_UnsubscribeRequestSchema: typeof UnsubscribeRequestSchema;
1533
- declare const index$1_UnsubscribeSchema: typeof UnsubscribeSchema;
1534
- declare namespace index$1 {
1535
- export { type index$1_BulkEmailRequest as BulkEmailRequest, index$1_BulkEmailRequestSchema as BulkEmailRequestSchema, type index$1_BulkEmailResponse as BulkEmailResponse, index$1_BulkEmailResponseSchema as BulkEmailResponseSchema, type index$1_EmailLog as EmailLog, index$1_EmailLogSchema as EmailLogSchema, type index$1_ErrorResponse as ErrorResponse, index$1_ErrorResponseSchema as ErrorResponseSchema, type index$1_Newsletter as Newsletter, type index$1_NewsletterCampaign as NewsletterCampaign, type index$1_NewsletterCampaignRequest as NewsletterCampaignRequest, index$1_NewsletterCampaignRequestSchema as NewsletterCampaignRequestSchema, index$1_NewsletterCampaignSchema as NewsletterCampaignSchema, index$1_NewsletterSchema as NewsletterSchema, type index$1_NewsletterSubscription as NewsletterSubscription, index$1_NewsletterSubscriptionSchema as NewsletterSubscriptionSchema, type index$1_PaginatedEmailLogList as PaginatedEmailLogList, index$1_PaginatedEmailLogListSchema as PaginatedEmailLogListSchema, type index$1_PaginatedNewsletterCampaignList as PaginatedNewsletterCampaignList, index$1_PaginatedNewsletterCampaignListSchema as PaginatedNewsletterCampaignListSchema, type index$1_PaginatedNewsletterList as PaginatedNewsletterList, index$1_PaginatedNewsletterListSchema as PaginatedNewsletterListSchema, type index$1_PaginatedNewsletterSubscriptionList as PaginatedNewsletterSubscriptionList, index$1_PaginatedNewsletterSubscriptionListSchema as PaginatedNewsletterSubscriptionListSchema, type index$1_PatchedNewsletterCampaignRequest as PatchedNewsletterCampaignRequest, index$1_PatchedNewsletterCampaignRequestSchema as PatchedNewsletterCampaignRequestSchema, type index$1_PatchedUnsubscribeRequest as PatchedUnsubscribeRequest, index$1_PatchedUnsubscribeRequestSchema as PatchedUnsubscribeRequestSchema, type index$1_SendCampaignRequest as SendCampaignRequest, index$1_SendCampaignRequestSchema as SendCampaignRequestSchema, type index$1_SendCampaignResponse as SendCampaignResponse, index$1_SendCampaignResponseSchema as SendCampaignResponseSchema, type index$1_SubscribeRequest as SubscribeRequest, index$1_SubscribeRequestSchema as SubscribeRequestSchema, type index$1_SubscribeResponse as SubscribeResponse, index$1_SubscribeResponseSchema as SubscribeResponseSchema, type index$1_SuccessResponse as SuccessResponse, index$1_SuccessResponseSchema as SuccessResponseSchema, type index$1_TestEmailRequest as TestEmailRequest, index$1_TestEmailRequestSchema as TestEmailRequestSchema, type index$1_Unsubscribe as Unsubscribe, type index$1_UnsubscribeRequest as UnsubscribeRequest, index$1_UnsubscribeRequestSchema as UnsubscribeRequestSchema, index$1_UnsubscribeSchema as UnsubscribeSchema };
1536
- }
1537
-
1538
- /**
1539
- * Zod Validation Events - Browser CustomEvent integration
1540
- *
1541
- * Dispatches browser CustomEvents when Zod validation fails, allowing
1542
- * React/frontend apps to listen and handle validation errors globally.
1543
- *
1544
- * @example
1545
- * ```typescript
1546
- * // In your React app
1547
- * window.addEventListener('zod-validation-error', (event) => {
1548
- * const { operation, path, method, error, response } = event.detail;
1549
- * console.error(`Validation failed for ${method} ${path}`, error);
1550
- * // Show toast notification, log to Sentry, etc.
1551
- * });
1552
- * ```
1553
- */
1554
-
1555
- /**
1556
- * Validation error event detail
1557
- */
1558
- interface ValidationErrorDetail {
1559
- /** Operation/function name that failed validation */
1560
- operation: string;
1561
- /** API endpoint path */
1562
- path: string;
1563
- /** HTTP method */
1564
- method: string;
1565
- /** Zod validation error */
1566
- error: ZodError;
1567
- /** Raw response data that failed validation */
1568
- response: any;
1569
- /** Timestamp of the error */
1570
- timestamp: Date;
1571
- }
1572
- /**
1573
- * Custom event type for Zod validation errors
1574
- */
1575
- type ValidationErrorEvent = CustomEvent<ValidationErrorDetail>;
1576
- /**
1577
- * Dispatch a Zod validation error event.
1578
- *
1579
- * Only dispatches in browser environment (when window is defined).
1580
- * Safe to call in Node.js/SSR - will be a no-op.
1581
- *
1582
- * @param detail - Validation error details
1583
- */
1584
- declare function dispatchValidationError(detail: ValidationErrorDetail): void;
1585
- /**
1586
- * Add a global listener for Zod validation errors.
1587
- *
1588
- * @param callback - Function to call when validation error occurs
1589
- * @returns Cleanup function to remove the listener
1590
- *
1591
- * @example
1592
- * ```typescript
1593
- * const cleanup = onValidationError(({ operation, error }) => {
1594
- * toast.error(`Validation failed in ${operation}`);
1595
- * logToSentry(error);
1596
- * });
1597
- *
1598
- * // Later, remove listener
1599
- * cleanup();
1600
- * ```
1601
- */
1602
- declare function onValidationError(callback: (detail: ValidationErrorDetail) => void): () => void;
1603
- /**
1604
- * Format Zod error for logging/display.
1605
- *
1606
- * @param error - Zod validation error
1607
- * @returns Formatted error message
1608
- */
1609
- declare function formatZodError(error: ZodError): string;
1610
-
1611
- /**
1612
- * API operation
1613
- *
1614
- * @method PATCH
1615
- * @path /cfg/newsletter/campaigns/{id}/
1616
- */
1617
- declare function partialUpdateNewsletterCampaignsPartialUpdate(id: number, data?: PatchedNewsletterCampaignRequest, client?: any): Promise<NewsletterCampaign>;
1618
- /**
1619
- * API operation
1620
- *
1621
- * @method PUT
1622
- * @path /cfg/newsletter/unsubscribe/
1623
- */
1624
- declare function updateNewsletterUnsubscribeUpdate(data: UnsubscribeRequest, client?: any): Promise<Unsubscribe>;
1625
- /**
1626
- * API operation
1627
- *
1628
- * @method PATCH
1629
- * @path /cfg/newsletter/unsubscribe/
1630
- */
1631
- declare function partialUpdateNewsletterUnsubscribePartialUpdate(data?: PatchedUnsubscribeRequest, client?: any): Promise<Unsubscribe>;
1632
-
1633
- /**
1634
- * Send Bulk Email
1635
- *
1636
- * @method POST
1637
- * @path /cfg/newsletter/bulk/
1638
- */
1639
- declare function createNewsletterBulkCreate(data: BulkEmailRequest, client?: any): Promise<BulkEmailResponse>;
1640
-
1641
- /**
1642
- * List Newsletter Campaigns
1643
- *
1644
- * @method GET
1645
- * @path /cfg/newsletter/campaigns/
1646
- */
1647
- declare function getNewsletterCampaignsList(params?: {
1648
- page?: number;
1649
- page_size?: number;
1650
- }, client?: any): Promise<PaginatedNewsletterCampaignList>;
1651
- /**
1652
- * Create Newsletter Campaign
1653
- *
1654
- * @method POST
1655
- * @path /cfg/newsletter/campaigns/
1656
- */
1657
- declare function createNewsletterCampaignsCreate(data: NewsletterCampaignRequest, client?: any): Promise<NewsletterCampaign>;
1658
- /**
1659
- * Get Campaign Details
1660
- *
1661
- * @method GET
1662
- * @path /cfg/newsletter/campaigns/{id}/
1663
- */
1664
- declare function getNewsletterCampaignsRetrieve(id: number, client?: any): Promise<NewsletterCampaign>;
1665
- /**
1666
- * Update Campaign
1667
- *
1668
- * @method PUT
1669
- * @path /cfg/newsletter/campaigns/{id}/
1670
- */
1671
- declare function updateNewsletterCampaignsUpdate(id: number, data: NewsletterCampaignRequest, client?: any): Promise<NewsletterCampaign>;
1672
- /**
1673
- * Delete Campaign
1674
- *
1675
- * @method DELETE
1676
- * @path /cfg/newsletter/campaigns/{id}/
1677
- */
1678
- declare function deleteNewsletterCampaignsDestroy(id: number, client?: any): Promise<void>;
1679
- /**
1680
- * Send Newsletter Campaign
1681
- *
1682
- * @method POST
1683
- * @path /cfg/newsletter/campaigns/send/
1684
- */
1685
- declare function createNewsletterCampaignsSendCreate(data: SendCampaignRequest, client?: any): Promise<SendCampaignResponse>;
1686
-
1687
- /**
1688
- * List Email Logs
1689
- *
1690
- * @method GET
1691
- * @path /cfg/newsletter/logs/
1692
- */
1693
- declare function getNewsletterLogsList(params?: {
1694
- page?: number;
1695
- page_size?: number;
1696
- }, client?: any): Promise<PaginatedEmailLogList>;
1697
-
1698
- /**
1699
- * List Active Newsletters
1700
- *
1701
- * @method GET
1702
- * @path /cfg/newsletter/newsletters/
1703
- */
1704
- declare function getNewsletterNewslettersList(params?: {
1705
- page?: number;
1706
- page_size?: number;
1707
- }, client?: any): Promise<PaginatedNewsletterList>;
1708
- /**
1709
- * Get Newsletter Details
1710
- *
1711
- * @method GET
1712
- * @path /cfg/newsletter/newsletters/{id}/
1713
- */
1714
- declare function getNewsletterNewslettersRetrieve(id: number, client?: any): Promise<Newsletter>;
1715
-
1716
- /**
1717
- * Subscribe to Newsletter
1718
- *
1719
- * @method POST
1720
- * @path /cfg/newsletter/subscribe/
1721
- */
1722
- declare function createNewsletterSubscribeCreate(data: SubscribeRequest, client?: any): Promise<SubscribeResponse>;
1723
- /**
1724
- * List User Subscriptions
1725
- *
1726
- * @method GET
1727
- * @path /cfg/newsletter/subscriptions/
1728
- */
1729
- declare function getNewsletterSubscriptionsList(params?: {
1730
- page?: number;
1731
- page_size?: number;
1732
- }, client?: any): Promise<PaginatedNewsletterSubscriptionList>;
1733
- /**
1734
- * Unsubscribe from Newsletter
1735
- *
1736
- * @method POST
1737
- * @path /cfg/newsletter/unsubscribe/
1738
- */
1739
- declare function createNewsletterUnsubscribeCreate(data: UnsubscribeRequest, client?: any): Promise<SuccessResponse>;
1740
-
1741
- /**
1742
- * Test Email Sending
1743
- *
1744
- * @method POST
1745
- * @path /cfg/newsletter/test/
1746
- */
1747
- declare function createNewsletterTestCreate(data: TestEmailRequest, client?: any): Promise<BulkEmailResponse>;
1748
-
1749
- /**
1750
- * Typed Fetchers - Universal API functions
1751
- *
1752
- * Auto-generated from OpenAPI specification.
1753
- * These functions work in any JavaScript environment.
1754
- *
1755
- * Features:
1756
- * - Runtime validation with Zod
1757
- * - Type-safe parameters and responses
1758
- * - Works with any data-fetching library (SWR, React Query, etc)
1759
- * - Server Component compatible
1760
- *
1761
- * Usage:
1762
- * ```typescript
1763
- * import * as fetchers from './fetchers'
1764
- *
1765
- * // Direct usage
1766
- * const user = await fetchers.getUser(1)
1767
- *
1768
- * // With SWR
1769
- * const { data } = useSWR('user-1', () => fetchers.getUser(1))
1770
- *
1771
- * // With React Query
1772
- * const { data } = useQuery(['user', 1], () => fetchers.getUser(1))
1773
- * ```
1774
- */
1775
-
1776
- declare const index_createNewsletterBulkCreate: typeof createNewsletterBulkCreate;
1777
- declare const index_createNewsletterCampaignsCreate: typeof createNewsletterCampaignsCreate;
1778
- declare const index_createNewsletterCampaignsSendCreate: typeof createNewsletterCampaignsSendCreate;
1779
- declare const index_createNewsletterSubscribeCreate: typeof createNewsletterSubscribeCreate;
1780
- declare const index_createNewsletterTestCreate: typeof createNewsletterTestCreate;
1781
- declare const index_createNewsletterUnsubscribeCreate: typeof createNewsletterUnsubscribeCreate;
1782
- declare const index_deleteNewsletterCampaignsDestroy: typeof deleteNewsletterCampaignsDestroy;
1783
- declare const index_getNewsletterCampaignsList: typeof getNewsletterCampaignsList;
1784
- declare const index_getNewsletterCampaignsRetrieve: typeof getNewsletterCampaignsRetrieve;
1785
- declare const index_getNewsletterLogsList: typeof getNewsletterLogsList;
1786
- declare const index_getNewsletterNewslettersList: typeof getNewsletterNewslettersList;
1787
- declare const index_getNewsletterNewslettersRetrieve: typeof getNewsletterNewslettersRetrieve;
1788
- declare const index_getNewsletterSubscriptionsList: typeof getNewsletterSubscriptionsList;
1789
- declare const index_partialUpdateNewsletterCampaignsPartialUpdate: typeof partialUpdateNewsletterCampaignsPartialUpdate;
1790
- declare const index_partialUpdateNewsletterUnsubscribePartialUpdate: typeof partialUpdateNewsletterUnsubscribePartialUpdate;
1791
- declare const index_updateNewsletterCampaignsUpdate: typeof updateNewsletterCampaignsUpdate;
1792
- declare const index_updateNewsletterUnsubscribeUpdate: typeof updateNewsletterUnsubscribeUpdate;
1793
- declare namespace index {
1794
- export { index_createNewsletterBulkCreate as createNewsletterBulkCreate, index_createNewsletterCampaignsCreate as createNewsletterCampaignsCreate, index_createNewsletterCampaignsSendCreate as createNewsletterCampaignsSendCreate, index_createNewsletterSubscribeCreate as createNewsletterSubscribeCreate, index_createNewsletterTestCreate as createNewsletterTestCreate, index_createNewsletterUnsubscribeCreate as createNewsletterUnsubscribeCreate, index_deleteNewsletterCampaignsDestroy as deleteNewsletterCampaignsDestroy, index_getNewsletterCampaignsList as getNewsletterCampaignsList, index_getNewsletterCampaignsRetrieve as getNewsletterCampaignsRetrieve, index_getNewsletterLogsList as getNewsletterLogsList, index_getNewsletterNewslettersList as getNewsletterNewslettersList, index_getNewsletterNewslettersRetrieve as getNewsletterNewslettersRetrieve, index_getNewsletterSubscriptionsList as getNewsletterSubscriptionsList, index_partialUpdateNewsletterCampaignsPartialUpdate as partialUpdateNewsletterCampaignsPartialUpdate, index_partialUpdateNewsletterUnsubscribePartialUpdate as partialUpdateNewsletterUnsubscribePartialUpdate, index_updateNewsletterCampaignsUpdate as updateNewsletterCampaignsUpdate, index_updateNewsletterUnsubscribeUpdate as updateNewsletterUnsubscribeUpdate };
1795
- }
1796
-
1797
- /**
1798
- * Global API Instance - Singleton configuration
1799
- *
1800
- * This module provides a global API instance that can be configured once
1801
- * and used throughout your application.
1802
- *
1803
- * Usage:
1804
- * ```typescript
1805
- * // Configure once (e.g., in your app entry point)
1806
- * import { configureAPI } from './api-instance'
1807
- *
1808
- * configureAPI({
1809
- * baseUrl: 'https://api.example.com',
1810
- * token: 'your-jwt-token'
1811
- * })
1812
- *
1813
- * // Then use fetchers and hooks anywhere without configuration
1814
- * import { getUsers } from './fetchers'
1815
- * const users = await getUsers({ page: 1 })
1816
- * ```
1817
- *
1818
- * For SSR or multiple instances:
1819
- * ```typescript
1820
- * import { API } from './index'
1821
- * import { getUsers } from './fetchers'
1822
- *
1823
- * const api = new API('https://api.example.com')
1824
- * const users = await getUsers({ page: 1 }, api)
1825
- * ```
1826
- */
1827
-
1828
- /**
1829
- * Get the global API instance
1830
- * @throws Error if API is not configured
1831
- */
1832
- declare function getAPIInstance(): API;
1833
- /**
1834
- * Check if API is configured
1835
- */
1836
- declare function isAPIConfigured(): boolean;
1837
- /**
1838
- * Configure the global API instance
1839
- *
1840
- * @param baseUrl - Base URL for the API
1841
- * @param options - Optional configuration (storage, retry, logger)
1842
- *
1843
- * @example
1844
- * ```typescript
1845
- * configureAPI({
1846
- * baseUrl: 'https://api.example.com',
1847
- * token: 'jwt-token',
1848
- * options: {
1849
- * retryConfig: { maxRetries: 3 },
1850
- * loggerConfig: { enabled: true }
1851
- * }
1852
- * })
1853
- * ```
1854
- */
1855
- declare function configureAPI(config: {
1856
- baseUrl: string;
1857
- token?: string;
1858
- refreshToken?: string;
1859
- options?: APIOptions;
1860
- }): API;
1861
- /**
1862
- * Reconfigure the global API instance with new settings
1863
- * Useful for updating tokens or base URL
1864
- */
1865
- declare function reconfigureAPI(updates: {
1866
- baseUrl?: string;
1867
- token?: string;
1868
- refreshToken?: string;
1869
- }): API;
1870
- /**
1871
- * Clear tokens from the global API instance
1872
- */
1873
- declare function clearAPITokens(): void;
1874
- /**
1875
- * Reset the global API instance
1876
- * Useful for testing or logout scenarios
1877
- */
1878
- declare function resetAPI(): void;
1879
-
1880
- /**
1881
- * API Error Classes
1882
- *
1883
- * Typed error classes with Django REST Framework support.
1884
- */
1885
- /**
1886
- * HTTP API Error with DRF field-specific validation errors.
1887
- *
1888
- * Usage:
1889
- * ```typescript
1890
- * try {
1891
- * await api.users.create(userData);
1892
- * } catch (error) {
1893
- * if (error instanceof APIError) {
1894
- * if (error.isValidationError) {
1895
- * console.log('Field errors:', error.fieldErrors);
1896
- * // { "email": ["Email already exists"], "username": ["Required"] }
1897
- * }
1898
- * }
1899
- * }
1900
- * ```
1901
- */
1902
- declare class APIError extends Error {
1903
- statusCode: number;
1904
- statusText: string;
1905
- response: any;
1906
- url: string;
1907
- constructor(statusCode: number, statusText: string, response: any, url: string, message?: string);
1908
- /**
1909
- * Get error details from response.
1910
- * DRF typically returns: { "detail": "Error message" } or { "field": ["error1", "error2"] }
1911
- */
1912
- get details(): Record<string, any> | null;
1913
- /**
1914
- * Get field-specific validation errors from DRF.
1915
- * Returns: { "field_name": ["error1", "error2"], ... }
1916
- */
1917
- get fieldErrors(): Record<string, string[]> | null;
1918
- /**
1919
- * Get single error message from DRF.
1920
- * Checks for "detail", "message", or first field error.
1921
- */
1922
- get errorMessage(): string;
1923
- get isValidationError(): boolean;
1924
- get isAuthError(): boolean;
1925
- get isPermissionError(): boolean;
1926
- get isNotFoundError(): boolean;
1927
- get isServerError(): boolean;
1928
- }
1929
- /**
1930
- * Network Error (connection failed, timeout, etc.)
1931
- */
1932
- declare class NetworkError extends Error {
1933
- url: string;
1934
- originalError?: Error;
1935
- constructor(message: string, url: string, originalError?: Error);
1936
- }
1937
-
1938
- /**
1939
- * Django CFG API - API Client with JWT Management
1940
- *
1941
- * Usage:
1942
- * ```typescript
1943
- * import { API } from './api';
1944
- *
1945
- * const api = new API('https://api.example.com');
1946
- *
1947
- * // Set JWT token
1948
- * api.setToken('your-jwt-token', 'refresh-token');
1949
- *
1950
- * // Use API
1951
- * const posts = await api.posts.list();
1952
- * const user = await api.users.retrieve(1);
1953
- *
1954
- * // Check authentication
1955
- * if (api.isAuthenticated()) {
1956
- * // ...
1957
- * }
1958
- *
1959
- * // Custom storage with logging (for Electron/Node.js)
1960
- * import { MemoryStorageAdapter, APILogger } from './storage';
1961
- * const logger = new APILogger({ enabled: true, logLevel: 'debug' });
1962
- * const api = new API('https://api.example.com', {
1963
- * storage: new MemoryStorageAdapter(logger),
1964
- * loggerConfig: { enabled: true, logLevel: 'debug' }
1965
- * });
1966
- *
1967
- * // Get OpenAPI schema
1968
- * const schema = api.getSchema();
1969
- * ```
1970
- */
1971
-
1972
- declare const TOKEN_KEY = "auth_token";
1973
- declare const REFRESH_TOKEN_KEY = "refresh_token";
1974
- interface APIOptions {
1975
- /** Custom storage adapter (defaults to LocalStorageAdapter) */
1976
- storage?: StorageAdapter;
1977
- /** Retry configuration for failed requests */
1978
- retryConfig?: RetryConfig;
1979
- /** Logger configuration */
1980
- loggerConfig?: Partial<LoggerConfig>;
1981
- }
1982
- declare class API {
1983
- private baseUrl;
1984
- private _client;
1985
- private _token;
1986
- private _refreshToken;
1987
- private storage;
1988
- private options?;
1989
- ext_newsletter_bulk_email: ExtNewsletterBulkEmail;
1990
- ext_newsletter_campaigns: ExtNewsletterCampaigns;
1991
- ext_newsletter_logs: ExtNewsletterLogs;
1992
- ext_newsletter_newsletters: ExtNewsletterNewsletters;
1993
- ext_newsletter_subscriptions: ExtNewsletterSubscriptions;
1994
- ext_newsletter_testing: ExtNewsletterTesting;
1995
- ext_newsletter_newsletter: ExtNewsletterNewsletter;
1996
- constructor(baseUrl: string, options?: APIOptions);
1997
- private _loadTokensFromStorage;
1998
- private _reinitClients;
1999
- private _injectAuthHeader;
2000
- /**
2001
- * Get current JWT token
2002
- */
2003
- getToken(): string | null;
2004
- /**
2005
- * Get current refresh token
2006
- */
2007
- getRefreshToken(): string | null;
2008
- /**
2009
- * Set JWT token and refresh token
2010
- * @param token - JWT access token
2011
- * @param refreshToken - JWT refresh token (optional)
2012
- */
2013
- setToken(token: string, refreshToken?: string): void;
2014
- /**
2015
- * Clear all tokens
2016
- */
2017
- clearTokens(): void;
2018
- /**
2019
- * Check if user is authenticated
2020
- */
2021
- isAuthenticated(): boolean;
2022
- /**
2023
- * Update base URL and reinitialize clients
2024
- * @param url - New base URL
2025
- */
2026
- setBaseUrl(url: string): void;
2027
- /**
2028
- * Get current base URL
2029
- */
2030
- getBaseUrl(): string;
2031
- /**
2032
- * Get OpenAPI schema path
2033
- * @returns Path to the OpenAPI schema JSON file
2034
- *
2035
- * Note: The OpenAPI schema is available in the schema.json file.
2036
- * You can load it dynamically using:
2037
- * ```typescript
2038
- * const schema = await fetch('./schema.json').then(r => r.json());
2039
- * // or using fs in Node.js:
2040
- * // const schema = JSON.parse(fs.readFileSync('./schema.json', 'utf-8'));
2041
- * ```
2042
- */
2043
- getSchemaPath(): string;
2044
- }
2045
-
2046
- /**
2047
- * Newsletter Extension API
2048
- *
2049
- * Pre-configured API instance with shared authentication
2050
- */
2051
-
2052
- declare const apiNewsletter: API;
2053
-
2054
- /**
2055
- * Hero Component Types
2056
- */
2057
- interface HeroAction {
2058
- label: string;
2059
- onClick: () => void;
2060
- }
2061
- interface HeroProps {
2062
- /** Main heading text */
2063
- title: string;
2064
- /** Supporting description text */
2065
- description?: string;
2066
- /** Primary call-to-action button */
2067
- primaryAction?: HeroAction;
2068
- /** Secondary call-to-action button */
2069
- secondaryAction?: HeroAction;
2070
- /** Show newsletter subscription form */
2071
- showNewsletter?: boolean;
2072
- /** Email input placeholder */
2073
- newsletterPlaceholder?: string;
2074
- /** Subscribe button text */
2075
- newsletterButtonText?: string;
2076
- /** Newsletter submission handler */
2077
- onNewsletterSubmit?: (email: string) => Promise<{
2078
- message?: string;
2079
- } | void>;
2080
- /** Additional CSS classes */
2081
- className?: string;
2082
- }
2083
-
2084
- export { API, APIClient, APIError, APILogger, type APIOptions, type BulkEmailRequest, BulkEmailRequestSchema, type BulkEmailResponse, BulkEmailResponseSchema, CookieStorageAdapter, DEFAULT_RETRY_CONFIG, type EmailLog, EmailLogSchema, enums as Enums, type ErrorLog, type ErrorResponse, ErrorResponseSchema, models$6 as ExtNewsletterBulkEmailTypes, models$5 as ExtNewsletterCampaignsTypes, models$4 as ExtNewsletterLogsTypes, models as ExtNewsletterNewsletterTypes, models$3 as ExtNewsletterNewslettersTypes, models$2 as ExtNewsletterSubscriptionsTypes, models$1 as ExtNewsletterTestingTypes, type FailedAttemptInfo, FetchAdapter, index as Fetchers, type HeroAction, type HeroProps, type HttpClientAdapter, type HttpRequest, type HttpResponse, LocalStorageAdapter, type LoggerConfig, MemoryStorageAdapter, NetworkError, type Newsletter, type NewsletterCampaign, type NewsletterCampaignRequest, NewsletterCampaignRequestSchema, NewsletterCampaignSchema, NewsletterSchema, type NewsletterSubscription, NewsletterSubscriptionSchema, type PaginatedEmailLogList, PaginatedEmailLogListSchema, type PaginatedNewsletterCampaignList, PaginatedNewsletterCampaignListSchema, type PaginatedNewsletterList, PaginatedNewsletterListSchema, type PaginatedNewsletterSubscriptionList, PaginatedNewsletterSubscriptionListSchema, type PatchedNewsletterCampaignRequest, PatchedNewsletterCampaignRequestSchema, type PatchedUnsubscribeRequest, PatchedUnsubscribeRequestSchema, REFRESH_TOKEN_KEY, type RequestLog, type ResponseLog, type RetryConfig, index$1 as Schemas, type SendCampaignRequest, SendCampaignRequestSchema, type SendCampaignResponse, SendCampaignResponseSchema, type StorageAdapter, type SubscribeRequest, SubscribeRequestSchema, type SubscribeResponse, SubscribeResponseSchema, type SuccessResponse, SuccessResponseSchema, TOKEN_KEY, type TestEmailRequest, TestEmailRequestSchema, type Unsubscribe, type UnsubscribeRequest, UnsubscribeRequestSchema, UnsubscribeSchema, type ValidationErrorDetail, type ValidationErrorEvent, apiNewsletter, clearAPITokens, configureAPI, createNewsletterBulkCreate, createNewsletterCampaignsCreate, createNewsletterCampaignsSendCreate, createNewsletterSubscribeCreate, createNewsletterTestCreate, createNewsletterUnsubscribeCreate, deleteNewsletterCampaignsDestroy, dispatchValidationError, formatZodError, getAPIInstance, getNewsletterCampaignsList, getNewsletterCampaignsRetrieve, getNewsletterLogsList, getNewsletterNewslettersList, getNewsletterNewslettersRetrieve, getNewsletterSubscriptionsList, isAPIConfigured, onValidationError, partialUpdateNewsletterCampaignsPartialUpdate, partialUpdateNewsletterUnsubscribePartialUpdate, reconfigureAPI, resetAPI, shouldRetry, updateNewsletterCampaignsUpdate, updateNewsletterUnsubscribeUpdate, withRetry };