payload-plugin-newsletter 0.8.7 → 0.9.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/CHANGELOG.md +45 -0
- package/CLAUDE.md +8 -2
- package/README.md +86 -0
- package/dist/client.d.cts +1 -1
- package/dist/client.d.ts +1 -1
- package/dist/components.cjs +777 -0
- package/dist/components.cjs.map +1 -1
- package/dist/components.d.cts +28 -2
- package/dist/components.d.ts +28 -2
- package/dist/components.js +764 -0
- package/dist/components.js.map +1 -1
- package/dist/fields.cjs +80 -0
- package/dist/fields.cjs.map +1 -0
- package/dist/fields.d.cts +13 -0
- package/dist/fields.d.ts +13 -0
- package/dist/fields.js +65 -0
- package/dist/fields.js.map +1 -0
- package/dist/index.cjs +2228 -19
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +2246 -17
- package/dist/index.js.map +1 -1
- package/dist/types.cjs +271 -0
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +620 -1
- package/dist/types.d.ts +620 -1
- package/dist/types.js +255 -0
- package/dist/types.js.map +1 -1
- package/dist/utils.cjs +337 -0
- package/dist/utils.cjs.map +1 -0
- package/dist/utils.d.cts +43 -0
- package/dist/utils.d.ts +43 -0
- package/dist/utils.js +298 -0
- package/dist/utils.js.map +1 -0
- package/package.json +21 -1
package/dist/types.d.ts
CHANGED
|
@@ -1,5 +1,590 @@
|
|
|
1
1
|
import { Field } from 'payload';
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Core types for newsletter management functionality
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Represents a newsletter/broadcast in the system
|
|
8
|
+
*/
|
|
9
|
+
interface Newsletter {
|
|
10
|
+
id: string;
|
|
11
|
+
name: string;
|
|
12
|
+
subject: string;
|
|
13
|
+
preheader?: string;
|
|
14
|
+
content: string;
|
|
15
|
+
status: NewsletterStatus;
|
|
16
|
+
trackOpens: boolean;
|
|
17
|
+
trackClicks: boolean;
|
|
18
|
+
replyTo?: string;
|
|
19
|
+
recipientCount?: number;
|
|
20
|
+
sentAt?: Date;
|
|
21
|
+
scheduledAt?: Date;
|
|
22
|
+
createdAt: Date;
|
|
23
|
+
updatedAt: Date;
|
|
24
|
+
providerData?: Record<string, any>;
|
|
25
|
+
providerId?: string;
|
|
26
|
+
providerType?: 'broadcast' | 'resend';
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Possible statuses for a newsletter
|
|
30
|
+
*/
|
|
31
|
+
declare enum NewsletterStatus {
|
|
32
|
+
DRAFT = "draft",
|
|
33
|
+
SCHEDULED = "scheduled",
|
|
34
|
+
SENDING = "sending",
|
|
35
|
+
SENT = "sent",
|
|
36
|
+
FAILED = "failed",
|
|
37
|
+
PAUSED = "paused",
|
|
38
|
+
CANCELED = "canceled"
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Options for listing newsletters
|
|
42
|
+
*/
|
|
43
|
+
interface ListNewsletterOptions {
|
|
44
|
+
limit?: number;
|
|
45
|
+
offset?: number;
|
|
46
|
+
status?: NewsletterStatus;
|
|
47
|
+
sortBy?: 'createdAt' | 'updatedAt' | 'sentAt' | 'name';
|
|
48
|
+
sortOrder?: 'asc' | 'desc';
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Response from listing newsletters
|
|
52
|
+
*/
|
|
53
|
+
interface ListNewsletterResponse<T = Newsletter> {
|
|
54
|
+
items: T[];
|
|
55
|
+
total: number;
|
|
56
|
+
limit: number;
|
|
57
|
+
offset: number;
|
|
58
|
+
hasMore: boolean;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Input for creating a new newsletter
|
|
62
|
+
*/
|
|
63
|
+
interface CreateNewsletterInput {
|
|
64
|
+
name: string;
|
|
65
|
+
subject: string;
|
|
66
|
+
preheader?: string;
|
|
67
|
+
content: string;
|
|
68
|
+
trackOpens?: boolean;
|
|
69
|
+
trackClicks?: boolean;
|
|
70
|
+
replyTo?: string;
|
|
71
|
+
audienceIds?: string[];
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Input for updating an existing newsletter
|
|
75
|
+
*/
|
|
76
|
+
interface UpdateNewsletterInput {
|
|
77
|
+
name?: string;
|
|
78
|
+
subject?: string;
|
|
79
|
+
preheader?: string;
|
|
80
|
+
content?: string;
|
|
81
|
+
trackOpens?: boolean;
|
|
82
|
+
trackClicks?: boolean;
|
|
83
|
+
replyTo?: string;
|
|
84
|
+
audienceIds?: string[];
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Options for sending a newsletter
|
|
88
|
+
*/
|
|
89
|
+
interface SendNewsletterOptions {
|
|
90
|
+
audienceIds?: string[];
|
|
91
|
+
testMode?: boolean;
|
|
92
|
+
testRecipients?: string[];
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Analytics data for a newsletter
|
|
96
|
+
*/
|
|
97
|
+
interface NewsletterAnalytics {
|
|
98
|
+
sent: number;
|
|
99
|
+
delivered: number;
|
|
100
|
+
opened: number;
|
|
101
|
+
clicked: number;
|
|
102
|
+
bounced: number;
|
|
103
|
+
complained: number;
|
|
104
|
+
unsubscribed: number;
|
|
105
|
+
deliveryRate?: number;
|
|
106
|
+
openRate?: number;
|
|
107
|
+
clickRate?: number;
|
|
108
|
+
bounceRate?: number;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Capabilities that a newsletter provider supports
|
|
112
|
+
*/
|
|
113
|
+
interface NewsletterProviderCapabilities {
|
|
114
|
+
supportsScheduling: boolean;
|
|
115
|
+
supportsSegmentation: boolean;
|
|
116
|
+
supportsAnalytics: boolean;
|
|
117
|
+
supportsABTesting: boolean;
|
|
118
|
+
supportsTemplates: boolean;
|
|
119
|
+
supportsPersonalization: boolean;
|
|
120
|
+
maxRecipientsPerSend?: number;
|
|
121
|
+
editableStatuses: NewsletterStatus[];
|
|
122
|
+
supportedContentTypes: ('html' | 'text' | 'react')[];
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Error types specific to newsletter operations
|
|
126
|
+
*/
|
|
127
|
+
declare class NewsletterProviderError extends Error {
|
|
128
|
+
code: NewsletterErrorCode;
|
|
129
|
+
provider: string;
|
|
130
|
+
details?: any | undefined;
|
|
131
|
+
constructor(message: string, code: NewsletterErrorCode, provider: string, details?: any | undefined);
|
|
132
|
+
}
|
|
133
|
+
declare enum NewsletterErrorCode {
|
|
134
|
+
NOT_SUPPORTED = "NOT_SUPPORTED",
|
|
135
|
+
INVALID_STATUS = "INVALID_STATUS",
|
|
136
|
+
PROVIDER_ERROR = "PROVIDER_ERROR",
|
|
137
|
+
VALIDATION_ERROR = "VALIDATION_ERROR",
|
|
138
|
+
NOT_FOUND = "NOT_FOUND",
|
|
139
|
+
PERMISSION_DENIED = "PERMISSION_DENIED",
|
|
140
|
+
RATE_LIMITED = "RATE_LIMITED",
|
|
141
|
+
CONFIGURATION_ERROR = "CONFIGURATION_ERROR"
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Newsletter template for reusable content
|
|
145
|
+
*/
|
|
146
|
+
interface NewsletterTemplate {
|
|
147
|
+
id: string;
|
|
148
|
+
name: string;
|
|
149
|
+
description?: string;
|
|
150
|
+
content: string;
|
|
151
|
+
variables?: NewsletterTemplateVariable[];
|
|
152
|
+
createdAt: Date;
|
|
153
|
+
updatedAt: Date;
|
|
154
|
+
}
|
|
155
|
+
interface NewsletterTemplateVariable {
|
|
156
|
+
name: string;
|
|
157
|
+
type: 'text' | 'html' | 'image' | 'url';
|
|
158
|
+
defaultValue?: string;
|
|
159
|
+
required?: boolean;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Core types for broadcast management functionality
|
|
164
|
+
*/
|
|
165
|
+
/**
|
|
166
|
+
* Represents a broadcast (individual email campaign) in the system
|
|
167
|
+
*/
|
|
168
|
+
interface Broadcast {
|
|
169
|
+
id: string;
|
|
170
|
+
channelId: string;
|
|
171
|
+
name: string;
|
|
172
|
+
subject: string;
|
|
173
|
+
preheader?: string;
|
|
174
|
+
content: string;
|
|
175
|
+
status: BroadcastStatus;
|
|
176
|
+
trackOpens: boolean;
|
|
177
|
+
trackClicks: boolean;
|
|
178
|
+
replyTo?: string;
|
|
179
|
+
recipientCount?: number;
|
|
180
|
+
sentAt?: Date;
|
|
181
|
+
scheduledAt?: Date;
|
|
182
|
+
createdAt: Date;
|
|
183
|
+
updatedAt: Date;
|
|
184
|
+
providerData?: Record<string, any>;
|
|
185
|
+
providerId?: string;
|
|
186
|
+
providerType?: 'broadcast' | 'resend';
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Possible statuses for a broadcast
|
|
190
|
+
*/
|
|
191
|
+
declare enum BroadcastStatus {
|
|
192
|
+
DRAFT = "draft",
|
|
193
|
+
SCHEDULED = "scheduled",
|
|
194
|
+
SENDING = "sending",
|
|
195
|
+
SENT = "sent",
|
|
196
|
+
FAILED = "failed",
|
|
197
|
+
PAUSED = "paused",
|
|
198
|
+
CANCELED = "canceled"
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Options for listing broadcasts
|
|
202
|
+
*/
|
|
203
|
+
interface ListBroadcastOptions {
|
|
204
|
+
limit?: number;
|
|
205
|
+
offset?: number;
|
|
206
|
+
status?: BroadcastStatus;
|
|
207
|
+
channelId?: string;
|
|
208
|
+
sortBy?: 'createdAt' | 'updatedAt' | 'sentAt' | 'name';
|
|
209
|
+
sortOrder?: 'asc' | 'desc';
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Response from listing broadcasts
|
|
213
|
+
*/
|
|
214
|
+
interface ListBroadcastResponse<T = Broadcast> {
|
|
215
|
+
items: T[];
|
|
216
|
+
total: number;
|
|
217
|
+
limit: number;
|
|
218
|
+
offset: number;
|
|
219
|
+
hasMore: boolean;
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Input for creating a new broadcast
|
|
223
|
+
*/
|
|
224
|
+
interface CreateBroadcastInput {
|
|
225
|
+
channelId: string;
|
|
226
|
+
name: string;
|
|
227
|
+
subject: string;
|
|
228
|
+
preheader?: string;
|
|
229
|
+
content: string;
|
|
230
|
+
trackOpens?: boolean;
|
|
231
|
+
trackClicks?: boolean;
|
|
232
|
+
replyTo?: string;
|
|
233
|
+
audienceIds?: string[];
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Input for updating an existing broadcast
|
|
237
|
+
*/
|
|
238
|
+
interface UpdateBroadcastInput {
|
|
239
|
+
name?: string;
|
|
240
|
+
subject?: string;
|
|
241
|
+
preheader?: string;
|
|
242
|
+
content?: string;
|
|
243
|
+
trackOpens?: boolean;
|
|
244
|
+
trackClicks?: boolean;
|
|
245
|
+
replyTo?: string;
|
|
246
|
+
audienceIds?: string[];
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Options for sending a broadcast
|
|
250
|
+
*/
|
|
251
|
+
interface SendBroadcastOptions {
|
|
252
|
+
audienceIds?: string[];
|
|
253
|
+
testMode?: boolean;
|
|
254
|
+
testRecipients?: string[];
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Analytics data for a broadcast
|
|
258
|
+
*/
|
|
259
|
+
interface BroadcastAnalytics {
|
|
260
|
+
sent: number;
|
|
261
|
+
delivered: number;
|
|
262
|
+
opened: number;
|
|
263
|
+
clicked: number;
|
|
264
|
+
bounced: number;
|
|
265
|
+
complained: number;
|
|
266
|
+
unsubscribed: number;
|
|
267
|
+
deliveryRate?: number;
|
|
268
|
+
openRate?: number;
|
|
269
|
+
clickRate?: number;
|
|
270
|
+
bounceRate?: number;
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Capabilities that a broadcast provider supports
|
|
274
|
+
*/
|
|
275
|
+
interface BroadcastProviderCapabilities {
|
|
276
|
+
supportsScheduling: boolean;
|
|
277
|
+
supportsSegmentation: boolean;
|
|
278
|
+
supportsAnalytics: boolean;
|
|
279
|
+
supportsABTesting: boolean;
|
|
280
|
+
supportsTemplates: boolean;
|
|
281
|
+
supportsPersonalization: boolean;
|
|
282
|
+
maxRecipientsPerSend?: number;
|
|
283
|
+
editableStatuses: BroadcastStatus[];
|
|
284
|
+
supportedContentTypes: ('html' | 'text' | 'react')[];
|
|
285
|
+
supportsMultipleChannels: boolean;
|
|
286
|
+
supportsChannelSegmentation: boolean;
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* Error types specific to broadcast operations
|
|
290
|
+
*/
|
|
291
|
+
declare class BroadcastProviderError extends Error {
|
|
292
|
+
code: BroadcastErrorCode;
|
|
293
|
+
provider: string;
|
|
294
|
+
details?: any | undefined;
|
|
295
|
+
constructor(message: string, code: BroadcastErrorCode, provider: string, details?: any | undefined);
|
|
296
|
+
}
|
|
297
|
+
declare enum BroadcastErrorCode {
|
|
298
|
+
NOT_SUPPORTED = "NOT_SUPPORTED",
|
|
299
|
+
INVALID_STATUS = "INVALID_STATUS",
|
|
300
|
+
PROVIDER_ERROR = "PROVIDER_ERROR",
|
|
301
|
+
VALIDATION_ERROR = "VALIDATION_ERROR",
|
|
302
|
+
NOT_FOUND = "NOT_FOUND",
|
|
303
|
+
PERMISSION_DENIED = "PERMISSION_DENIED",
|
|
304
|
+
RATE_LIMITED = "RATE_LIMITED",
|
|
305
|
+
CONFIGURATION_ERROR = "CONFIGURATION_ERROR",
|
|
306
|
+
CHANNEL_NOT_FOUND = "CHANNEL_NOT_FOUND",
|
|
307
|
+
INVALID_CHANNEL = "INVALID_CHANNEL"
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* Broadcast template for reusable content
|
|
311
|
+
*/
|
|
312
|
+
interface BroadcastTemplate {
|
|
313
|
+
id: string;
|
|
314
|
+
channelId?: string;
|
|
315
|
+
name: string;
|
|
316
|
+
description?: string;
|
|
317
|
+
content: string;
|
|
318
|
+
variables?: BroadcastTemplateVariable[];
|
|
319
|
+
createdAt: Date;
|
|
320
|
+
updatedAt: Date;
|
|
321
|
+
}
|
|
322
|
+
interface BroadcastTemplateVariable {
|
|
323
|
+
name: string;
|
|
324
|
+
type: 'text' | 'html' | 'image' | 'url';
|
|
325
|
+
defaultValue?: string;
|
|
326
|
+
required?: boolean;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
interface Channel {
|
|
330
|
+
id: string;
|
|
331
|
+
name: string;
|
|
332
|
+
description?: string;
|
|
333
|
+
fromName: string;
|
|
334
|
+
fromEmail: string;
|
|
335
|
+
replyTo?: string;
|
|
336
|
+
providerId: string;
|
|
337
|
+
providerType: 'broadcast' | 'resend';
|
|
338
|
+
subscriberCount?: number;
|
|
339
|
+
active: boolean;
|
|
340
|
+
createdAt: Date;
|
|
341
|
+
updatedAt: Date;
|
|
342
|
+
}
|
|
343
|
+
interface CreateChannelInput {
|
|
344
|
+
name: string;
|
|
345
|
+
description?: string;
|
|
346
|
+
fromName: string;
|
|
347
|
+
fromEmail: string;
|
|
348
|
+
replyTo?: string;
|
|
349
|
+
}
|
|
350
|
+
interface UpdateChannelInput {
|
|
351
|
+
name?: string;
|
|
352
|
+
description?: string;
|
|
353
|
+
fromName?: string;
|
|
354
|
+
fromEmail?: string;
|
|
355
|
+
replyTo?: string;
|
|
356
|
+
active?: boolean;
|
|
357
|
+
}
|
|
358
|
+
interface ListChannelsOptions {
|
|
359
|
+
limit?: number;
|
|
360
|
+
offset?: number;
|
|
361
|
+
active?: boolean;
|
|
362
|
+
}
|
|
363
|
+
interface ListChannelsResponse {
|
|
364
|
+
channels: Channel[];
|
|
365
|
+
total: number;
|
|
366
|
+
limit: number;
|
|
367
|
+
offset: number;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
/**
|
|
371
|
+
* Provider interfaces for broadcast management
|
|
372
|
+
*/
|
|
373
|
+
|
|
374
|
+
/**
|
|
375
|
+
* Main interface for broadcast providers
|
|
376
|
+
*/
|
|
377
|
+
interface BroadcastProvider {
|
|
378
|
+
/**
|
|
379
|
+
* Get the provider name
|
|
380
|
+
*/
|
|
381
|
+
readonly name: string;
|
|
382
|
+
/**
|
|
383
|
+
* List channels (newsletter types/publications)
|
|
384
|
+
*/
|
|
385
|
+
listChannels(options?: ListChannelsOptions): Promise<ListChannelsResponse>;
|
|
386
|
+
/**
|
|
387
|
+
* Get a specific channel by ID
|
|
388
|
+
*/
|
|
389
|
+
getChannel(id: string): Promise<Channel>;
|
|
390
|
+
/**
|
|
391
|
+
* Create a new channel
|
|
392
|
+
*/
|
|
393
|
+
createChannel(data: CreateChannelInput): Promise<Channel>;
|
|
394
|
+
/**
|
|
395
|
+
* Update an existing channel
|
|
396
|
+
*/
|
|
397
|
+
updateChannel(id: string, data: UpdateChannelInput): Promise<Channel>;
|
|
398
|
+
/**
|
|
399
|
+
* Delete a channel
|
|
400
|
+
*/
|
|
401
|
+
deleteChannel(id: string): Promise<void>;
|
|
402
|
+
/**
|
|
403
|
+
* List broadcasts with pagination
|
|
404
|
+
*/
|
|
405
|
+
list(options?: ListBroadcastOptions): Promise<ListBroadcastResponse<Broadcast>>;
|
|
406
|
+
/**
|
|
407
|
+
* Get a specific broadcast by ID
|
|
408
|
+
*/
|
|
409
|
+
get(id: string): Promise<Broadcast>;
|
|
410
|
+
/**
|
|
411
|
+
* Create a new broadcast
|
|
412
|
+
*/
|
|
413
|
+
create(data: CreateBroadcastInput): Promise<Broadcast>;
|
|
414
|
+
/**
|
|
415
|
+
* Update an existing broadcast
|
|
416
|
+
*/
|
|
417
|
+
update(id: string, data: UpdateBroadcastInput): Promise<Broadcast>;
|
|
418
|
+
/**
|
|
419
|
+
* Delete a broadcast
|
|
420
|
+
*/
|
|
421
|
+
delete(id: string): Promise<void>;
|
|
422
|
+
/**
|
|
423
|
+
* Send a broadcast immediately or to test recipients
|
|
424
|
+
*/
|
|
425
|
+
send(id: string, options?: SendBroadcastOptions): Promise<Broadcast>;
|
|
426
|
+
/**
|
|
427
|
+
* Schedule a broadcast for future sending
|
|
428
|
+
*/
|
|
429
|
+
schedule(id: string, scheduledAt: Date): Promise<Broadcast>;
|
|
430
|
+
/**
|
|
431
|
+
* Cancel a scheduled broadcast
|
|
432
|
+
*/
|
|
433
|
+
cancelSchedule(id: string): Promise<Broadcast>;
|
|
434
|
+
/**
|
|
435
|
+
* Get analytics for a broadcast
|
|
436
|
+
*/
|
|
437
|
+
getAnalytics(id: string): Promise<BroadcastAnalytics>;
|
|
438
|
+
/**
|
|
439
|
+
* Get provider capabilities
|
|
440
|
+
*/
|
|
441
|
+
getCapabilities(): BroadcastProviderCapabilities;
|
|
442
|
+
/**
|
|
443
|
+
* Validate that the provider is properly configured
|
|
444
|
+
*/
|
|
445
|
+
validateConfiguration(): Promise<boolean>;
|
|
446
|
+
}
|
|
447
|
+
/**
|
|
448
|
+
* Legacy newsletter provider interface for backwards compatibility
|
|
449
|
+
* @deprecated Use BroadcastProvider instead
|
|
450
|
+
*/
|
|
451
|
+
interface NewsletterProvider {
|
|
452
|
+
/**
|
|
453
|
+
* Get the provider name
|
|
454
|
+
*/
|
|
455
|
+
readonly name: string;
|
|
456
|
+
/**
|
|
457
|
+
* List newsletters with pagination
|
|
458
|
+
*/
|
|
459
|
+
list(options?: ListNewsletterOptions): Promise<ListNewsletterResponse<Newsletter>>;
|
|
460
|
+
/**
|
|
461
|
+
* Get a specific newsletter by ID
|
|
462
|
+
*/
|
|
463
|
+
get(id: string): Promise<Newsletter>;
|
|
464
|
+
/**
|
|
465
|
+
* Create a new newsletter
|
|
466
|
+
*/
|
|
467
|
+
create(data: CreateNewsletterInput): Promise<Newsletter>;
|
|
468
|
+
/**
|
|
469
|
+
* Update an existing newsletter
|
|
470
|
+
*/
|
|
471
|
+
update(id: string, data: UpdateNewsletterInput): Promise<Newsletter>;
|
|
472
|
+
/**
|
|
473
|
+
* Delete a newsletter
|
|
474
|
+
*/
|
|
475
|
+
delete(id: string): Promise<void>;
|
|
476
|
+
/**
|
|
477
|
+
* Send a newsletter immediately or to test recipients
|
|
478
|
+
*/
|
|
479
|
+
send(id: string, options?: SendNewsletterOptions): Promise<Newsletter>;
|
|
480
|
+
/**
|
|
481
|
+
* Schedule a newsletter for future sending
|
|
482
|
+
*/
|
|
483
|
+
schedule(id: string, scheduledAt: Date): Promise<Newsletter>;
|
|
484
|
+
/**
|
|
485
|
+
* Cancel a scheduled newsletter
|
|
486
|
+
*/
|
|
487
|
+
cancelSchedule(id: string): Promise<Newsletter>;
|
|
488
|
+
/**
|
|
489
|
+
* Get analytics for a newsletter
|
|
490
|
+
*/
|
|
491
|
+
getAnalytics(id: string): Promise<NewsletterAnalytics>;
|
|
492
|
+
/**
|
|
493
|
+
* Get provider capabilities
|
|
494
|
+
*/
|
|
495
|
+
getCapabilities(): NewsletterProviderCapabilities;
|
|
496
|
+
/**
|
|
497
|
+
* Validate that the provider is properly configured
|
|
498
|
+
*/
|
|
499
|
+
validateConfiguration(): Promise<boolean>;
|
|
500
|
+
}
|
|
501
|
+
/**
|
|
502
|
+
* Base abstract class for broadcast providers
|
|
503
|
+
*/
|
|
504
|
+
declare abstract class BaseBroadcastProvider implements BroadcastProvider {
|
|
505
|
+
protected config: any;
|
|
506
|
+
abstract readonly name: string;
|
|
507
|
+
constructor(config: any);
|
|
508
|
+
abstract listChannels(options?: ListChannelsOptions): Promise<ListChannelsResponse>;
|
|
509
|
+
abstract getChannel(id: string): Promise<Channel>;
|
|
510
|
+
abstract createChannel(data: CreateChannelInput): Promise<Channel>;
|
|
511
|
+
abstract updateChannel(id: string, data: UpdateChannelInput): Promise<Channel>;
|
|
512
|
+
abstract deleteChannel(id: string): Promise<void>;
|
|
513
|
+
abstract list(options?: ListBroadcastOptions): Promise<ListBroadcastResponse<Broadcast>>;
|
|
514
|
+
abstract get(id: string): Promise<Broadcast>;
|
|
515
|
+
abstract create(data: CreateBroadcastInput): Promise<Broadcast>;
|
|
516
|
+
abstract update(id: string, data: UpdateBroadcastInput): Promise<Broadcast>;
|
|
517
|
+
abstract delete(id: string): Promise<void>;
|
|
518
|
+
abstract send(id: string, options?: SendBroadcastOptions): Promise<Broadcast>;
|
|
519
|
+
abstract getCapabilities(): BroadcastProviderCapabilities;
|
|
520
|
+
abstract validateConfiguration(): Promise<boolean>;
|
|
521
|
+
/**
|
|
522
|
+
* Schedule a broadcast - default implementation throws not supported
|
|
523
|
+
*/
|
|
524
|
+
schedule(id: string, scheduledAt: Date): Promise<Broadcast>;
|
|
525
|
+
/**
|
|
526
|
+
* Cancel scheduled broadcast - default implementation throws not supported
|
|
527
|
+
*/
|
|
528
|
+
cancelSchedule(id: string): Promise<Broadcast>;
|
|
529
|
+
/**
|
|
530
|
+
* Get analytics - default implementation returns zeros
|
|
531
|
+
*/
|
|
532
|
+
getAnalytics(id: string): Promise<BroadcastAnalytics>;
|
|
533
|
+
/**
|
|
534
|
+
* Helper method to validate required fields
|
|
535
|
+
*/
|
|
536
|
+
protected validateRequiredFields(data: any, fields: string[]): void;
|
|
537
|
+
/**
|
|
538
|
+
* Helper method to check if a status transition is allowed
|
|
539
|
+
*/
|
|
540
|
+
protected canEditInStatus(status: BroadcastStatus): boolean;
|
|
541
|
+
/**
|
|
542
|
+
* Helper to build pagination response
|
|
543
|
+
*/
|
|
544
|
+
protected buildListResponse<T>(items: T[], total: number, options?: ListBroadcastOptions): ListBroadcastResponse<T>;
|
|
545
|
+
}
|
|
546
|
+
/**
|
|
547
|
+
* Base abstract class for newsletter providers
|
|
548
|
+
* @deprecated Use BaseBroadcastProvider instead
|
|
549
|
+
*/
|
|
550
|
+
declare abstract class BaseNewsletterProvider implements NewsletterProvider {
|
|
551
|
+
protected config: any;
|
|
552
|
+
abstract readonly name: string;
|
|
553
|
+
constructor(config: any);
|
|
554
|
+
abstract list(options?: ListNewsletterOptions): Promise<ListNewsletterResponse<Newsletter>>;
|
|
555
|
+
abstract get(id: string): Promise<Newsletter>;
|
|
556
|
+
abstract create(data: CreateNewsletterInput): Promise<Newsletter>;
|
|
557
|
+
abstract update(id: string, data: UpdateNewsletterInput): Promise<Newsletter>;
|
|
558
|
+
abstract delete(id: string): Promise<void>;
|
|
559
|
+
abstract send(id: string, options?: SendNewsletterOptions): Promise<Newsletter>;
|
|
560
|
+
abstract getCapabilities(): NewsletterProviderCapabilities;
|
|
561
|
+
abstract validateConfiguration(): Promise<boolean>;
|
|
562
|
+
/**
|
|
563
|
+
* Schedule a newsletter - default implementation throws not supported
|
|
564
|
+
*/
|
|
565
|
+
schedule(id: string, scheduledAt: Date): Promise<Newsletter>;
|
|
566
|
+
/**
|
|
567
|
+
* Cancel scheduled newsletter - default implementation throws not supported
|
|
568
|
+
*/
|
|
569
|
+
cancelSchedule(id: string): Promise<Newsletter>;
|
|
570
|
+
/**
|
|
571
|
+
* Get analytics - default implementation returns zeros
|
|
572
|
+
*/
|
|
573
|
+
getAnalytics(id: string): Promise<NewsletterAnalytics>;
|
|
574
|
+
/**
|
|
575
|
+
* Helper method to validate required fields
|
|
576
|
+
*/
|
|
577
|
+
protected validateRequiredFields(data: any, fields: string[]): void;
|
|
578
|
+
/**
|
|
579
|
+
* Helper method to check if a status transition is allowed
|
|
580
|
+
*/
|
|
581
|
+
protected canEditInStatus(status: NewsletterStatus): boolean;
|
|
582
|
+
/**
|
|
583
|
+
* Helper to build pagination response
|
|
584
|
+
*/
|
|
585
|
+
protected buildListResponse<T>(items: T[], total: number, options?: ListNewsletterOptions): ListNewsletterResponse<T>;
|
|
586
|
+
}
|
|
587
|
+
|
|
3
588
|
interface NewsletterPluginConfig {
|
|
4
589
|
/**
|
|
5
590
|
* Enable or disable the plugin
|
|
@@ -186,6 +771,36 @@ interface NewsletterPluginConfig {
|
|
|
186
771
|
*/
|
|
187
772
|
queue?: string;
|
|
188
773
|
};
|
|
774
|
+
/**
|
|
775
|
+
* Newsletter management configuration
|
|
776
|
+
*/
|
|
777
|
+
newsletterManagement?: {
|
|
778
|
+
/**
|
|
779
|
+
* Enable newsletter management features
|
|
780
|
+
* @default false
|
|
781
|
+
*/
|
|
782
|
+
enabled?: boolean;
|
|
783
|
+
/**
|
|
784
|
+
* Collection names for broadcast management
|
|
785
|
+
*/
|
|
786
|
+
collections?: {
|
|
787
|
+
/**
|
|
788
|
+
* Channels collection slug
|
|
789
|
+
* @default 'channels'
|
|
790
|
+
*/
|
|
791
|
+
channels?: string;
|
|
792
|
+
/**
|
|
793
|
+
* Broadcasts collection slug
|
|
794
|
+
* @default 'broadcasts'
|
|
795
|
+
*/
|
|
796
|
+
broadcasts?: string;
|
|
797
|
+
};
|
|
798
|
+
/**
|
|
799
|
+
* Optional: Custom broadcast provider implementation
|
|
800
|
+
* If not provided, will use the default email provider
|
|
801
|
+
*/
|
|
802
|
+
provider?: BroadcastProvider;
|
|
803
|
+
};
|
|
189
804
|
};
|
|
190
805
|
/**
|
|
191
806
|
* Internationalization configuration
|
|
@@ -197,8 +812,10 @@ interface NewsletterPluginConfig {
|
|
|
197
812
|
}
|
|
198
813
|
interface ResendProviderConfig {
|
|
199
814
|
apiKey: string;
|
|
815
|
+
fromEmail?: string;
|
|
200
816
|
fromAddress?: string;
|
|
201
817
|
fromName?: string;
|
|
818
|
+
replyTo?: string;
|
|
202
819
|
audienceIds?: {
|
|
203
820
|
[locale: string]: {
|
|
204
821
|
production?: string;
|
|
@@ -212,8 +829,10 @@ interface BroadcastProviderConfig {
|
|
|
212
829
|
production?: string;
|
|
213
830
|
development?: string;
|
|
214
831
|
};
|
|
832
|
+
fromEmail?: string;
|
|
215
833
|
fromAddress?: string;
|
|
216
834
|
fromName?: string;
|
|
835
|
+
replyTo?: string;
|
|
217
836
|
}
|
|
218
837
|
interface EmailProvider {
|
|
219
838
|
send(params: SendEmailParams): Promise<void>;
|
|
@@ -427,4 +1046,4 @@ interface ExtendedPayloadRequest extends Request {
|
|
|
427
1046
|
};
|
|
428
1047
|
}
|
|
429
1048
|
|
|
430
|
-
export type
|
|
1049
|
+
export { type AfterSubscribeArgs, type AfterUnsubscribeArgs, type AfterUnsubscribeSyncArgs, BaseBroadcastProvider, BaseNewsletterProvider, type BeforeSubscribeArgs, type BeforeUnsubscribeArgs, type Broadcast, type BroadcastAnalytics, BroadcastErrorCode, type BroadcastProvider, type BroadcastProviderCapabilities, type BroadcastProviderConfig, BroadcastProviderError, BroadcastStatus, type BroadcastTemplate, type BroadcastTemplateVariable, type Channel, type CreateBroadcastInput, type CreateChannelInput, type CreateNewsletterInput, type EmailProvider, type ExtendedPayloadRequest, type ListBroadcastOptions, type ListBroadcastResponse, type ListChannelsOptions, type ListChannelsResponse, type ListNewsletterOptions, type ListNewsletterResponse, type MagicLinkEmailProps, type Newsletter, type NewsletterAnalytics, NewsletterErrorCode, type NewsletterPluginConfig, type NewsletterProvider, type NewsletterProviderCapabilities, NewsletterProviderError, NewsletterStatus, type NewsletterTemplate, type NewsletterTemplateVariable, type PreferencesFormProps, type ResendProviderConfig, type SendBroadcastOptions, type SendEmailParams, type SendNewsletterOptions, type SigninRequestData, type SignupFormProps, type SubscribeRequestData, type Subscriber, type SurveyQuestion, type UnsubscribeRequestData, type UpdateBroadcastInput, type UpdateChannelInput, type UpdateNewsletterInput, type UpdatePreferencesRequestData, type VerifyMagicLinkRequestData, type WelcomeEmailProps };
|