@volchoklv/newsletter-kit 1.0.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.
@@ -0,0 +1,417 @@
1
+ "use client";
2
+
3
+ // src/adapters/email/resend.ts
4
+ function createResendAdapter(config) {
5
+ const { apiKey, from, replyTo, templates, adminEmail } = config;
6
+ async function sendEmail(params) {
7
+ const { Resend } = await import("resend");
8
+ const resend = new Resend(apiKey);
9
+ await resend.emails.send({
10
+ from,
11
+ replyTo,
12
+ to: params.to,
13
+ subject: params.subject,
14
+ html: params.html,
15
+ text: params.text
16
+ });
17
+ }
18
+ const defaultTemplates = {
19
+ confirmation: {
20
+ subject: "Confirm your subscription",
21
+ text: void 0,
22
+ html: ({ confirmUrl, email }) => `
23
+ <!DOCTYPE html>
24
+ <html>
25
+ <head>
26
+ <meta charset="utf-8">
27
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
28
+ </head>
29
+ <body style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; line-height: 1.6; color: #333; max-width: 600px; margin: 0 auto; padding: 20px;">
30
+ <h1 style="color: #111; font-size: 24px; margin-bottom: 20px;">Confirm your subscription</h1>
31
+ <p>Thanks for subscribing! Please confirm your email address by clicking the button below:</p>
32
+ <a href="${confirmUrl}" style="display: inline-block; background-color: #000; color: #fff; padding: 12px 24px; text-decoration: none; border-radius: 6px; margin: 20px 0;">
33
+ Confirm Subscription
34
+ </a>
35
+ <p style="color: #666; font-size: 14px; margin-top: 30px;">
36
+ If you didn't subscribe to this newsletter, you can safely ignore this email.
37
+ </p>
38
+ <p style="color: #999; font-size: 12px; margin-top: 20px;">
39
+ This confirmation was requested for ${email}
40
+ </p>
41
+ </body>
42
+ </html>
43
+ `
44
+ },
45
+ welcome: {
46
+ subject: "Welcome to our newsletter!",
47
+ text: void 0,
48
+ html: ({ email }) => `
49
+ <!DOCTYPE html>
50
+ <html>
51
+ <head>
52
+ <meta charset="utf-8">
53
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
54
+ </head>
55
+ <body style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; line-height: 1.6; color: #333; max-width: 600px; margin: 0 auto; padding: 20px;">
56
+ <h1 style="color: #111; font-size: 24px; margin-bottom: 20px;">You're subscribed! \u{1F389}</h1>
57
+ <p>Thanks for confirming your subscription. You'll now receive our updates at <strong>${email}</strong>.</p>
58
+ <p>We're excited to have you!</p>
59
+ </body>
60
+ </html>
61
+ `
62
+ },
63
+ unsubscribed: {
64
+ subject: "You have been unsubscribed",
65
+ text: void 0,
66
+ html: ({ email, resubscribeUrl }) => `
67
+ <!DOCTYPE html>
68
+ <html>
69
+ <head>
70
+ <meta charset="utf-8">
71
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
72
+ </head>
73
+ <body style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; line-height: 1.6; color: #333; max-width: 600px; margin: 0 auto; padding: 20px;">
74
+ <h1 style="color: #111; font-size: 24px; margin-bottom: 20px;">Unsubscribed</h1>
75
+ <p>You have been unsubscribed from our newsletter. We're sorry to see you go!</p>
76
+ ${resubscribeUrl ? `<p><a href="${resubscribeUrl}">Changed your mind? Resubscribe here.</a></p>` : ""}
77
+ <p style="color: #999; font-size: 12px; margin-top: 20px;">
78
+ This email was sent to ${email}
79
+ </p>
80
+ </body>
81
+ </html>
82
+ `
83
+ }
84
+ };
85
+ return {
86
+ async sendConfirmation(email, token, confirmUrl) {
87
+ const template = templates?.confirmation ?? defaultTemplates.confirmation;
88
+ const subject = template.subject ?? defaultTemplates.confirmation.subject;
89
+ const html = template.html ?? defaultTemplates.confirmation.html;
90
+ await sendEmail({
91
+ to: email,
92
+ subject,
93
+ html: html({ confirmUrl, email }),
94
+ text: template.text?.({ confirmUrl, email })
95
+ });
96
+ },
97
+ async sendWelcome(email) {
98
+ const template = templates?.welcome ?? defaultTemplates.welcome;
99
+ const subject = template.subject ?? defaultTemplates.welcome.subject;
100
+ const html = template.html ?? defaultTemplates.welcome.html;
101
+ await sendEmail({
102
+ to: email,
103
+ subject,
104
+ html: html({ email }),
105
+ text: template.text?.({ email })
106
+ });
107
+ },
108
+ async sendUnsubscribed(email, resubscribeUrl) {
109
+ const template = templates?.unsubscribed ?? defaultTemplates.unsubscribed;
110
+ const subject = template.subject ?? defaultTemplates.unsubscribed.subject;
111
+ const html = template.html ?? defaultTemplates.unsubscribed.html;
112
+ await sendEmail({
113
+ to: email,
114
+ subject,
115
+ html: html({ email, resubscribeUrl }),
116
+ text: template.text?.({ email, resubscribeUrl })
117
+ });
118
+ },
119
+ async notifyAdmin(subscriber) {
120
+ if (!adminEmail) return;
121
+ await sendEmail({
122
+ to: adminEmail,
123
+ subject: `New newsletter subscriber: ${subscriber.email}`,
124
+ html: `
125
+ <!DOCTYPE html>
126
+ <html>
127
+ <body style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; line-height: 1.6; color: #333; padding: 20px;">
128
+ <h2>New Newsletter Subscriber</h2>
129
+ <p><strong>Email:</strong> ${subscriber.email}</p>
130
+ <p><strong>Status:</strong> ${subscriber.status}</p>
131
+ ${subscriber.source ? `<p><strong>Source:</strong> ${subscriber.source}</p>` : ""}
132
+ ${subscriber.tags?.length ? `<p><strong>Tags:</strong> ${subscriber.tags.join(", ")}</p>` : ""}
133
+ <p><strong>Subscribed at:</strong> ${subscriber.createdAt.toISOString()}</p>
134
+ </body>
135
+ </html>
136
+ `
137
+ });
138
+ }
139
+ };
140
+ }
141
+
142
+ // src/adapters/email/nodemailer.ts
143
+ function createNodemailerAdapter(config) {
144
+ const { smtp, from, replyTo, templates, adminEmail } = config;
145
+ async function sendEmail(params) {
146
+ const nodemailer = await import("nodemailer");
147
+ const transporter = nodemailer.createTransport(smtp);
148
+ await transporter.sendMail({
149
+ from,
150
+ replyTo,
151
+ to: params.to,
152
+ subject: params.subject,
153
+ html: params.html,
154
+ text: params.text
155
+ });
156
+ }
157
+ const defaultTemplates = {
158
+ confirmation: {
159
+ subject: "Confirm your subscription",
160
+ text: void 0,
161
+ html: ({ confirmUrl, email }) => `
162
+ <!DOCTYPE html>
163
+ <html>
164
+ <head>
165
+ <meta charset="utf-8">
166
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
167
+ </head>
168
+ <body style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; line-height: 1.6; color: #333; max-width: 600px; margin: 0 auto; padding: 20px;">
169
+ <h1 style="color: #111; font-size: 24px; margin-bottom: 20px;">Confirm your subscription</h1>
170
+ <p>Thanks for subscribing! Please confirm your email address by clicking the button below:</p>
171
+ <a href="${confirmUrl}" style="display: inline-block; background-color: #000; color: #fff; padding: 12px 24px; text-decoration: none; border-radius: 6px; margin: 20px 0;">
172
+ Confirm Subscription
173
+ </a>
174
+ <p style="color: #666; font-size: 14px; margin-top: 30px;">
175
+ If you didn't subscribe to this newsletter, you can safely ignore this email.
176
+ </p>
177
+ <p style="color: #999; font-size: 12px; margin-top: 20px;">
178
+ This confirmation was requested for ${email}
179
+ </p>
180
+ </body>
181
+ </html>
182
+ `
183
+ },
184
+ welcome: {
185
+ subject: "Welcome to our newsletter!",
186
+ text: void 0,
187
+ html: ({ email }) => `
188
+ <!DOCTYPE html>
189
+ <html>
190
+ <head>
191
+ <meta charset="utf-8">
192
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
193
+ </head>
194
+ <body style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; line-height: 1.6; color: #333; max-width: 600px; margin: 0 auto; padding: 20px;">
195
+ <h1 style="color: #111; font-size: 24px; margin-bottom: 20px;">You're subscribed! \u{1F389}</h1>
196
+ <p>Thanks for confirming your subscription. You'll now receive our updates at <strong>${email}</strong>.</p>
197
+ <p>We're excited to have you!</p>
198
+ </body>
199
+ </html>
200
+ `
201
+ },
202
+ unsubscribed: {
203
+ subject: "You have been unsubscribed",
204
+ text: void 0,
205
+ html: ({ email, resubscribeUrl }) => `
206
+ <!DOCTYPE html>
207
+ <html>
208
+ <head>
209
+ <meta charset="utf-8">
210
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
211
+ </head>
212
+ <body style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; line-height: 1.6; color: #333; max-width: 600px; margin: 0 auto; padding: 20px;">
213
+ <h1 style="color: #111; font-size: 24px; margin-bottom: 20px;">Unsubscribed</h1>
214
+ <p>You have been unsubscribed from our newsletter. We're sorry to see you go!</p>
215
+ ${resubscribeUrl ? `<p><a href="${resubscribeUrl}">Changed your mind? Resubscribe here.</a></p>` : ""}
216
+ <p style="color: #999; font-size: 12px; margin-top: 20px;">
217
+ This email was sent to ${email}
218
+ </p>
219
+ </body>
220
+ </html>
221
+ `
222
+ }
223
+ };
224
+ return {
225
+ async sendConfirmation(email, token, confirmUrl) {
226
+ const template = templates?.confirmation ?? defaultTemplates.confirmation;
227
+ const subject = template.subject ?? defaultTemplates.confirmation.subject;
228
+ const html = template.html ?? defaultTemplates.confirmation.html;
229
+ await sendEmail({
230
+ to: email,
231
+ subject,
232
+ html: html({ confirmUrl, email }),
233
+ text: template.text?.({ confirmUrl, email })
234
+ });
235
+ },
236
+ async sendWelcome(email) {
237
+ const template = templates?.welcome ?? defaultTemplates.welcome;
238
+ const subject = template.subject ?? defaultTemplates.welcome.subject;
239
+ const html = template.html ?? defaultTemplates.welcome.html;
240
+ await sendEmail({
241
+ to: email,
242
+ subject,
243
+ html: html({ email }),
244
+ text: template.text?.({ email })
245
+ });
246
+ },
247
+ async sendUnsubscribed(email, resubscribeUrl) {
248
+ const template = templates?.unsubscribed ?? defaultTemplates.unsubscribed;
249
+ const subject = template.subject ?? defaultTemplates.unsubscribed.subject;
250
+ const html = template.html ?? defaultTemplates.unsubscribed.html;
251
+ await sendEmail({
252
+ to: email,
253
+ subject,
254
+ html: html({ email, resubscribeUrl }),
255
+ text: template.text?.({ email, resubscribeUrl })
256
+ });
257
+ },
258
+ async notifyAdmin(subscriber) {
259
+ if (!adminEmail) return;
260
+ await sendEmail({
261
+ to: adminEmail,
262
+ subject: `New newsletter subscriber: ${subscriber.email}`,
263
+ html: `
264
+ <!DOCTYPE html>
265
+ <html>
266
+ <body style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; line-height: 1.6; color: #333; padding: 20px;">
267
+ <h2>New Newsletter Subscriber</h2>
268
+ <p><strong>Email:</strong> ${subscriber.email}</p>
269
+ <p><strong>Status:</strong> ${subscriber.status}</p>
270
+ ${subscriber.source ? `<p><strong>Source:</strong> ${subscriber.source}</p>` : ""}
271
+ ${subscriber.tags?.length ? `<p><strong>Tags:</strong> ${subscriber.tags.join(", ")}</p>` : ""}
272
+ <p><strong>Subscribed at:</strong> ${subscriber.createdAt.toISOString()}</p>
273
+ </body>
274
+ </html>
275
+ `
276
+ });
277
+ }
278
+ };
279
+ }
280
+
281
+ // src/adapters/email/mailchimp.ts
282
+ function createMailchimpAdapter(config) {
283
+ const { apiKey, server, listId, from, adminEmail, useAsStorage } = config;
284
+ async function getClient() {
285
+ const mailchimp = await import("@mailchimp/mailchimp_marketing");
286
+ mailchimp.default.setConfig({
287
+ apiKey,
288
+ server
289
+ });
290
+ return mailchimp.default;
291
+ }
292
+ async function addOrUpdateMember(email, status) {
293
+ const client = await getClient();
294
+ const subscriberHash = await hashEmail(email);
295
+ try {
296
+ await client.lists.setListMember(listId, subscriberHash, {
297
+ email_address: email,
298
+ status_if_new: status
299
+ });
300
+ } catch (error) {
301
+ await client.lists.addListMember(listId, {
302
+ email_address: email,
303
+ status
304
+ });
305
+ }
306
+ }
307
+ async function hashEmail(email) {
308
+ const crypto = await import("crypto");
309
+ return crypto.createHash("md5").update(email.toLowerCase()).digest("hex");
310
+ }
311
+ return {
312
+ async sendConfirmation(email, _token, _confirmUrl) {
313
+ if (useAsStorage) {
314
+ await addOrUpdateMember(email, "pending");
315
+ }
316
+ },
317
+ async sendWelcome(email) {
318
+ if (useAsStorage) {
319
+ await addOrUpdateMember(email, "subscribed");
320
+ }
321
+ },
322
+ async sendUnsubscribed(email) {
323
+ if (useAsStorage) {
324
+ const client = await getClient();
325
+ const subscriberHash = await hashEmail(email);
326
+ await client.lists.updateListMember(listId, subscriberHash, {
327
+ status: "unsubscribed"
328
+ });
329
+ }
330
+ },
331
+ async notifyAdmin(subscriber) {
332
+ if (!adminEmail) return;
333
+ console.warn(
334
+ `[newsletter-kit] Mailchimp adapter: Admin notification not implemented. Consider setting up a Mailchimp webhook or automation. New subscriber: ${subscriber.email}`
335
+ );
336
+ }
337
+ };
338
+ }
339
+ function createMailchimpStorageAdapter(config) {
340
+ const { apiKey, server, listId } = config;
341
+ async function getClient() {
342
+ const mailchimp = await import("@mailchimp/mailchimp_marketing");
343
+ mailchimp.default.setConfig({
344
+ apiKey,
345
+ server
346
+ });
347
+ return mailchimp.default;
348
+ }
349
+ async function hashEmail(email) {
350
+ const crypto = await import("crypto");
351
+ return crypto.createHash("md5").update(email.toLowerCase()).digest("hex");
352
+ }
353
+ return {
354
+ async createSubscriber(input) {
355
+ const client = await getClient();
356
+ await client.lists.addListMember(listId, {
357
+ email_address: input.email,
358
+ status: "pending",
359
+ // Mailchimp handles double opt-in
360
+ tags: input.tags,
361
+ merge_fields: {
362
+ SOURCE: input.source || ""
363
+ }
364
+ });
365
+ return {
366
+ id: await hashEmail(input.email),
367
+ email: input.email,
368
+ status: "pending",
369
+ source: input.source,
370
+ tags: input.tags,
371
+ createdAt: /* @__PURE__ */ new Date(),
372
+ updatedAt: /* @__PURE__ */ new Date()
373
+ };
374
+ },
375
+ async getSubscriberByEmail(email) {
376
+ const client = await getClient();
377
+ const hash = await hashEmail(email);
378
+ try {
379
+ const member = await client.lists.getListMember(listId, hash);
380
+ return {
381
+ id: hash,
382
+ email: member.email_address,
383
+ status: member.status === "subscribed" ? "confirmed" : member.status,
384
+ tags: member.tags?.map((t) => t.name),
385
+ createdAt: new Date(member.timestamp_signup || member.timestamp_opt || Date.now()),
386
+ updatedAt: new Date(member.last_changed || Date.now())
387
+ };
388
+ } catch {
389
+ return null;
390
+ }
391
+ },
392
+ // Note: Mailchimp doesn't use tokens - it has its own confirmation system
393
+ async getSubscriberByToken() {
394
+ console.warn("[newsletter-kit] Mailchimp uses its own confirmation system");
395
+ return null;
396
+ },
397
+ async confirmSubscriber(_token) {
398
+ console.warn("[newsletter-kit] Mailchimp handles confirmation automatically");
399
+ return null;
400
+ },
401
+ async unsubscribe(email) {
402
+ const client = await getClient();
403
+ const hash = await hashEmail(email);
404
+ await client.lists.updateListMember(listId, hash, {
405
+ status: "unsubscribed"
406
+ });
407
+ return true;
408
+ }
409
+ };
410
+ }
411
+ export {
412
+ createMailchimpAdapter,
413
+ createMailchimpStorageAdapter,
414
+ createNodemailerAdapter,
415
+ createResendAdapter
416
+ };
417
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/adapters/email/resend.ts","../../../src/adapters/email/nodemailer.ts","../../../src/adapters/email/mailchimp.ts"],"sourcesContent":["import type { EmailAdapter, EmailAdapterConfig, EmailTemplates, Subscriber } from '../../types';\n\ninterface ResendAdapterConfig extends EmailAdapterConfig {\n apiKey: string;\n}\n\n/**\n * Email adapter for Resend (https://resend.com)\n * \n * @example\n * ```ts\n * import { createResendAdapter } from '@volchok/newsletter-kit/adapters/email';\n * \n * const emailAdapter = createResendAdapter({\n * apiKey: process.env.RESEND_API_KEY!,\n * from: 'newsletter@yourdomain.com',\n * adminEmail: 'you@yourdomain.com', // optional\n * });\n * ```\n */\nexport function createResendAdapter(config: ResendAdapterConfig): EmailAdapter {\n const { apiKey, from, replyTo, templates, adminEmail } = config;\n\n async function sendEmail(params: {\n to: string;\n subject: string;\n html: string;\n text?: string;\n }) {\n // Dynamic import to avoid requiring resend as a hard dependency\n const { Resend } = await import('resend');\n const resend = new Resend(apiKey);\n\n await resend.emails.send({\n from,\n replyTo,\n to: params.to,\n subject: params.subject,\n html: params.html,\n text: params.text,\n });\n }\n\n const defaultTemplates: Required<EmailTemplates> = {\n confirmation: {\n subject: 'Confirm your subscription',\n text: undefined,\n html: ({ confirmUrl, email }: { confirmUrl: string; email: string }) => `\n <!DOCTYPE html>\n <html>\n <head>\n <meta charset=\"utf-8\">\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n </head>\n <body style=\"font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; line-height: 1.6; color: #333; max-width: 600px; margin: 0 auto; padding: 20px;\">\n <h1 style=\"color: #111; font-size: 24px; margin-bottom: 20px;\">Confirm your subscription</h1>\n <p>Thanks for subscribing! Please confirm your email address by clicking the button below:</p>\n <a href=\"${confirmUrl}\" style=\"display: inline-block; background-color: #000; color: #fff; padding: 12px 24px; text-decoration: none; border-radius: 6px; margin: 20px 0;\">\n Confirm Subscription\n </a>\n <p style=\"color: #666; font-size: 14px; margin-top: 30px;\">\n If you didn't subscribe to this newsletter, you can safely ignore this email.\n </p>\n <p style=\"color: #999; font-size: 12px; margin-top: 20px;\">\n This confirmation was requested for ${email}\n </p>\n </body>\n </html>\n `,\n },\n welcome: {\n subject: 'Welcome to our newsletter!',\n text: undefined,\n html: ({ email }: { email: string }) => `\n <!DOCTYPE html>\n <html>\n <head>\n <meta charset=\"utf-8\">\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n </head>\n <body style=\"font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; line-height: 1.6; color: #333; max-width: 600px; margin: 0 auto; padding: 20px;\">\n <h1 style=\"color: #111; font-size: 24px; margin-bottom: 20px;\">You're subscribed! 🎉</h1>\n <p>Thanks for confirming your subscription. You'll now receive our updates at <strong>${email}</strong>.</p>\n <p>We're excited to have you!</p>\n </body>\n </html>\n `,\n },\n unsubscribed: {\n subject: 'You have been unsubscribed',\n text: undefined,\n html: ({ email, resubscribeUrl }: { email: string; resubscribeUrl?: string }) => `\n <!DOCTYPE html>\n <html>\n <head>\n <meta charset=\"utf-8\">\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n </head>\n <body style=\"font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; line-height: 1.6; color: #333; max-width: 600px; margin: 0 auto; padding: 20px;\">\n <h1 style=\"color: #111; font-size: 24px; margin-bottom: 20px;\">Unsubscribed</h1>\n <p>You have been unsubscribed from our newsletter. We're sorry to see you go!</p>\n ${resubscribeUrl ? `<p><a href=\"${resubscribeUrl}\">Changed your mind? Resubscribe here.</a></p>` : ''}\n <p style=\"color: #999; font-size: 12px; margin-top: 20px;\">\n This email was sent to ${email}\n </p>\n </body>\n </html>\n `,\n },\n };\n\n return {\n async sendConfirmation(email: string, token: string, confirmUrl: string) {\n const template = templates?.confirmation ?? defaultTemplates.confirmation;\n const subject = template.subject ?? defaultTemplates.confirmation.subject!;\n const html = template.html ?? defaultTemplates.confirmation.html!;\n await sendEmail({\n to: email,\n subject,\n html: html({ confirmUrl, email }),\n text: template.text?.({ confirmUrl, email }),\n });\n },\n\n async sendWelcome(email: string) {\n const template = templates?.welcome ?? defaultTemplates.welcome;\n const subject = template.subject ?? defaultTemplates.welcome.subject!;\n const html = template.html ?? defaultTemplates.welcome.html!;\n await sendEmail({\n to: email,\n subject,\n html: html({ email }),\n text: template.text?.({ email }),\n });\n },\n\n async sendUnsubscribed(email: string, resubscribeUrl?: string) {\n const template = templates?.unsubscribed ?? defaultTemplates.unsubscribed;\n const subject = template.subject ?? defaultTemplates.unsubscribed.subject!;\n const html = template.html ?? defaultTemplates.unsubscribed.html!;\n await sendEmail({\n to: email,\n subject,\n html: html({ email, resubscribeUrl }),\n text: template.text?.({ email, resubscribeUrl }),\n });\n },\n\n async notifyAdmin(subscriber: Subscriber) {\n if (!adminEmail) return;\n\n await sendEmail({\n to: adminEmail,\n subject: `New newsletter subscriber: ${subscriber.email}`,\n html: `\n <!DOCTYPE html>\n <html>\n <body style=\"font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; line-height: 1.6; color: #333; padding: 20px;\">\n <h2>New Newsletter Subscriber</h2>\n <p><strong>Email:</strong> ${subscriber.email}</p>\n <p><strong>Status:</strong> ${subscriber.status}</p>\n ${subscriber.source ? `<p><strong>Source:</strong> ${subscriber.source}</p>` : ''}\n ${subscriber.tags?.length ? `<p><strong>Tags:</strong> ${subscriber.tags.join(', ')}</p>` : ''}\n <p><strong>Subscribed at:</strong> ${subscriber.createdAt.toISOString()}</p>\n </body>\n </html>\n `,\n });\n },\n };\n}\n","import type { EmailAdapter, EmailAdapterConfig, EmailTemplates, Subscriber } from '../../types';\n\ninterface SMTPConfig {\n host: string;\n port: number;\n secure?: boolean;\n auth?: {\n user: string;\n pass: string;\n };\n}\n\ninterface NodemailerAdapterConfig extends EmailAdapterConfig {\n smtp: SMTPConfig;\n}\n\n/**\n * Email adapter for Nodemailer/SMTP\n * \n * @example\n * ```ts\n * import { createNodemailerAdapter } from '@volchok/newsletter-kit/adapters/email';\n * \n * const emailAdapter = createNodemailerAdapter({\n * smtp: {\n * host: 'smtp.example.com',\n * port: 587,\n * secure: false,\n * auth: {\n * user: process.env.SMTP_USER!,\n * pass: process.env.SMTP_PASS!,\n * },\n * },\n * from: 'newsletter@yourdomain.com',\n * adminEmail: 'you@yourdomain.com', // optional\n * });\n * ```\n */\nexport function createNodemailerAdapter(config: NodemailerAdapterConfig): EmailAdapter {\n const { smtp, from, replyTo, templates, adminEmail } = config;\n\n async function sendEmail(params: {\n to: string;\n subject: string;\n html: string;\n text?: string;\n }) {\n // Dynamic import to avoid requiring nodemailer as a hard dependency\n const nodemailer = await import('nodemailer');\n const transporter = nodemailer.createTransport(smtp);\n\n await transporter.sendMail({\n from,\n replyTo,\n to: params.to,\n subject: params.subject,\n html: params.html,\n text: params.text,\n });\n }\n\n const defaultTemplates: Required<EmailTemplates> = {\n confirmation: {\n subject: 'Confirm your subscription',\n text: undefined,\n html: ({ confirmUrl, email }: { confirmUrl: string; email: string }) => `\n <!DOCTYPE html>\n <html>\n <head>\n <meta charset=\"utf-8\">\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n </head>\n <body style=\"font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; line-height: 1.6; color: #333; max-width: 600px; margin: 0 auto; padding: 20px;\">\n <h1 style=\"color: #111; font-size: 24px; margin-bottom: 20px;\">Confirm your subscription</h1>\n <p>Thanks for subscribing! Please confirm your email address by clicking the button below:</p>\n <a href=\"${confirmUrl}\" style=\"display: inline-block; background-color: #000; color: #fff; padding: 12px 24px; text-decoration: none; border-radius: 6px; margin: 20px 0;\">\n Confirm Subscription\n </a>\n <p style=\"color: #666; font-size: 14px; margin-top: 30px;\">\n If you didn't subscribe to this newsletter, you can safely ignore this email.\n </p>\n <p style=\"color: #999; font-size: 12px; margin-top: 20px;\">\n This confirmation was requested for ${email}\n </p>\n </body>\n </html>\n `,\n },\n welcome: {\n subject: 'Welcome to our newsletter!',\n text: undefined,\n html: ({ email }: { email: string }) => `\n <!DOCTYPE html>\n <html>\n <head>\n <meta charset=\"utf-8\">\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n </head>\n <body style=\"font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; line-height: 1.6; color: #333; max-width: 600px; margin: 0 auto; padding: 20px;\">\n <h1 style=\"color: #111; font-size: 24px; margin-bottom: 20px;\">You're subscribed! 🎉</h1>\n <p>Thanks for confirming your subscription. You'll now receive our updates at <strong>${email}</strong>.</p>\n <p>We're excited to have you!</p>\n </body>\n </html>\n `,\n },\n unsubscribed: {\n subject: 'You have been unsubscribed',\n text: undefined,\n html: ({ email, resubscribeUrl }: { email: string; resubscribeUrl?: string }) => `\n <!DOCTYPE html>\n <html>\n <head>\n <meta charset=\"utf-8\">\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n </head>\n <body style=\"font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; line-height: 1.6; color: #333; max-width: 600px; margin: 0 auto; padding: 20px;\">\n <h1 style=\"color: #111; font-size: 24px; margin-bottom: 20px;\">Unsubscribed</h1>\n <p>You have been unsubscribed from our newsletter. We're sorry to see you go!</p>\n ${resubscribeUrl ? `<p><a href=\"${resubscribeUrl}\">Changed your mind? Resubscribe here.</a></p>` : ''}\n <p style=\"color: #999; font-size: 12px; margin-top: 20px;\">\n This email was sent to ${email}\n </p>\n </body>\n </html>\n `,\n },\n };\n\n return {\n async sendConfirmation(email: string, token: string, confirmUrl: string) {\n const template = templates?.confirmation ?? defaultTemplates.confirmation;\n const subject = template.subject ?? defaultTemplates.confirmation.subject!;\n const html = template.html ?? defaultTemplates.confirmation.html!;\n await sendEmail({\n to: email,\n subject,\n html: html({ confirmUrl, email }),\n text: template.text?.({ confirmUrl, email }),\n });\n },\n\n async sendWelcome(email: string) {\n const template = templates?.welcome ?? defaultTemplates.welcome;\n const subject = template.subject ?? defaultTemplates.welcome.subject!;\n const html = template.html ?? defaultTemplates.welcome.html!;\n await sendEmail({\n to: email,\n subject,\n html: html({ email }),\n text: template.text?.({ email }),\n });\n },\n\n async sendUnsubscribed(email: string, resubscribeUrl?: string) {\n const template = templates?.unsubscribed ?? defaultTemplates.unsubscribed;\n const subject = template.subject ?? defaultTemplates.unsubscribed.subject!;\n const html = template.html ?? defaultTemplates.unsubscribed.html!;\n await sendEmail({\n to: email,\n subject,\n html: html({ email, resubscribeUrl }),\n text: template.text?.({ email, resubscribeUrl }),\n });\n },\n\n async notifyAdmin(subscriber: Subscriber) {\n if (!adminEmail) return;\n\n await sendEmail({\n to: adminEmail,\n subject: `New newsletter subscriber: ${subscriber.email}`,\n html: `\n <!DOCTYPE html>\n <html>\n <body style=\"font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; line-height: 1.6; color: #333; padding: 20px;\">\n <h2>New Newsletter Subscriber</h2>\n <p><strong>Email:</strong> ${subscriber.email}</p>\n <p><strong>Status:</strong> ${subscriber.status}</p>\n ${subscriber.source ? `<p><strong>Source:</strong> ${subscriber.source}</p>` : ''}\n ${subscriber.tags?.length ? `<p><strong>Tags:</strong> ${subscriber.tags.join(', ')}</p>` : ''}\n <p><strong>Subscribed at:</strong> ${subscriber.createdAt.toISOString()}</p>\n </body>\n </html>\n `,\n });\n },\n };\n}\n","import type { EmailAdapter, EmailAdapterConfig, Subscriber } from '../../types';\n\ninterface MailchimpAdapterConfig extends EmailAdapterConfig {\n apiKey: string;\n server: string; // e.g., 'us1', 'us2', etc.\n listId: string;\n /** If true, use Mailchimp for storage too (adds to list on subscribe) */\n useAsStorage?: boolean;\n}\n\n/**\n * Email adapter for Mailchimp\n * \n * Note: Mailchimp works differently from other adapters. It manages its own\n * subscriber list, so this adapter can optionally act as both email AND storage.\n * \n * @example\n * ```ts\n * import { createMailchimpAdapter } from '@volchok/newsletter-kit/adapters/email';\n * \n * const emailAdapter = createMailchimpAdapter({\n * apiKey: process.env.MAILCHIMP_API_KEY!,\n * server: 'us1',\n * listId: 'your-list-id',\n * from: 'newsletter@yourdomain.com',\n * useAsStorage: true, // Use Mailchimp's list as storage\n * });\n * ```\n */\nexport function createMailchimpAdapter(config: MailchimpAdapterConfig): EmailAdapter {\n const { apiKey, server, listId, from, adminEmail, useAsStorage } = config;\n\n async function getClient() {\n // Dynamic import\n const mailchimp = await import('@mailchimp/mailchimp_marketing');\n mailchimp.default.setConfig({\n apiKey,\n server,\n });\n return mailchimp.default;\n }\n\n async function addOrUpdateMember(email: string, status: 'subscribed' | 'pending') {\n const client = await getClient();\n const subscriberHash = await hashEmail(email);\n\n try {\n await client.lists.setListMember(listId, subscriberHash, {\n email_address: email,\n status_if_new: status,\n });\n } catch (error) {\n // If member doesn't exist, add them\n await client.lists.addListMember(listId, {\n email_address: email,\n status,\n });\n }\n }\n\n async function hashEmail(email: string): Promise<string> {\n const crypto = await import('crypto');\n return crypto.createHash('md5').update(email.toLowerCase()).digest('hex');\n }\n\n // Mailchimp handles its own confirmation emails when status is 'pending'\n // We provide fallback implementations that work with Mailchimp's system\n\n return {\n async sendConfirmation(email: string, _token: string, _confirmUrl: string) {\n if (useAsStorage) {\n // Add to Mailchimp with 'pending' status - Mailchimp sends its own confirmation\n await addOrUpdateMember(email, 'pending');\n }\n // If not using as storage, the storage adapter handles this\n // and we don't send duplicate confirmation emails\n },\n\n async sendWelcome(email: string) {\n // Mailchimp can be configured to send welcome emails automatically\n // via automations. If useAsStorage is true, we update status to subscribed.\n if (useAsStorage) {\n await addOrUpdateMember(email, 'subscribed');\n }\n },\n\n async sendUnsubscribed(email: string) {\n if (useAsStorage) {\n const client = await getClient();\n const subscriberHash = await hashEmail(email);\n await client.lists.updateListMember(listId, subscriberHash, {\n status: 'unsubscribed',\n });\n }\n },\n\n async notifyAdmin(subscriber: Subscriber) {\n if (!adminEmail) return;\n\n // Mailchimp doesn't have a built-in way to notify admins\n // You'd typically set up a webhook or automation for this\n // For now, we log a warning\n console.warn(\n `[newsletter-kit] Mailchimp adapter: Admin notification not implemented. ` +\n `Consider setting up a Mailchimp webhook or automation. ` +\n `New subscriber: ${subscriber.email}`\n );\n },\n };\n}\n\n/**\n * Create a combined Mailchimp adapter that handles both email and storage\n * \n * This is useful when you want Mailchimp to be your single source of truth\n * for subscribers.\n */\nexport function createMailchimpStorageAdapter(config: MailchimpAdapterConfig) {\n const { apiKey, server, listId } = config;\n\n async function getClient() {\n const mailchimp = await import('@mailchimp/mailchimp_marketing');\n mailchimp.default.setConfig({\n apiKey,\n server,\n });\n return mailchimp.default;\n }\n\n async function hashEmail(email: string): Promise<string> {\n const crypto = await import('crypto');\n return crypto.createHash('md5').update(email.toLowerCase()).digest('hex');\n }\n\n return {\n async createSubscriber(input: { email: string; source?: string; tags?: string[] }) {\n const client = await getClient();\n\n await client.lists.addListMember(listId, {\n email_address: input.email,\n status: 'pending', // Mailchimp handles double opt-in\n tags: input.tags,\n merge_fields: {\n SOURCE: input.source || '',\n },\n });\n\n return {\n id: await hashEmail(input.email),\n email: input.email,\n status: 'pending' as const,\n source: input.source,\n tags: input.tags,\n createdAt: new Date(),\n updatedAt: new Date(),\n };\n },\n\n async getSubscriberByEmail(email: string) {\n const client = await getClient();\n const hash = await hashEmail(email);\n\n try {\n const member = await client.lists.getListMember(listId, hash) as {\n email_address: string;\n status: string;\n tags?: Array<{ name: string }>;\n timestamp_signup?: string;\n timestamp_opt?: string;\n last_changed?: string;\n };\n return {\n id: hash,\n email: member.email_address,\n status: member.status === 'subscribed' ? 'confirmed' : member.status,\n tags: member.tags?.map((t) => t.name),\n createdAt: new Date(member.timestamp_signup || member.timestamp_opt || Date.now()),\n updatedAt: new Date(member.last_changed || Date.now()),\n };\n } catch {\n return null;\n }\n },\n\n // Note: Mailchimp doesn't use tokens - it has its own confirmation system\n async getSubscriberByToken() {\n console.warn('[newsletter-kit] Mailchimp uses its own confirmation system');\n return null;\n },\n\n async confirmSubscriber(_token: string) {\n console.warn('[newsletter-kit] Mailchimp handles confirmation automatically');\n return null;\n },\n\n async unsubscribe(email: string) {\n const client = await getClient();\n const hash = await hashEmail(email);\n\n await client.lists.updateListMember(listId, hash, {\n status: 'unsubscribed',\n });\n\n return true;\n },\n };\n}\n"],"mappings":";;;AAoBO,SAAS,oBAAoB,QAA2C;AAC7E,QAAM,EAAE,QAAQ,MAAM,SAAS,WAAW,WAAW,IAAI;AAEzD,iBAAe,UAAU,QAKtB;AAED,UAAM,EAAE,OAAO,IAAI,MAAM,OAAO,QAAQ;AACxC,UAAM,SAAS,IAAI,OAAO,MAAM;AAEhC,UAAM,OAAO,OAAO,KAAK;AAAA,MACvB;AAAA,MACA;AAAA,MACA,IAAI,OAAO;AAAA,MACX,SAAS,OAAO;AAAA,MAChB,MAAM,OAAO;AAAA,MACb,MAAM,OAAO;AAAA,IACf,CAAC;AAAA,EACH;AAEA,QAAM,mBAA6C;AAAA,IACjD,cAAc;AAAA,MACZ,SAAS;AAAA,MACT,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