@lovable.dev/email-js 0.1.1-rc.2 → 0.1.1-rc.4

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.cjs CHANGED
@@ -1,352 +1,259 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
-
30
- // src/index.ts
31
- var src_exports = {};
32
- __export(src_exports, {
33
- EmailAPIError: () => EmailAPIError,
34
- createAuthEmailHandler: () => createAuthEmailHandler,
35
- createEmailWebhookHandler: () => createEmailWebhookHandler,
36
- getEmailUnsubscribe: () => getEmailUnsubscribe,
37
- listEmailLogs: () => listEmailLogs,
38
- parseEmailWebhookPayload: () => parseEmailWebhookPayload,
39
- sendLovableEmail: () => sendLovableEmail,
40
- setEmailUnsubscribe: () => setEmailUnsubscribe
41
- });
42
- module.exports = __toCommonJS(src_exports);
43
-
44
- // src/auth-email-handler.ts
45
- var import_webhooks_js2 = require("@lovable.dev/webhooks-js");
46
-
47
- // src/http.ts
48
- var DEFAULT_AUTH_HEADER = "Authorization";
49
- var DEFAULT_API_BASE_URL = "https://api.lovable.dev";
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ let _lovable_dev_webhooks_js = require("@lovable.dev/webhooks-js");
50
3
  function resolveApiBaseUrl(apiBaseUrl) {
51
- return (apiBaseUrl ?? DEFAULT_API_BASE_URL).replace(/\/$/, "");
4
+ return (apiBaseUrl ?? "https://api.lovable.dev").replace(/\/$/, "");
52
5
  }
53
6
  var EmailAPIError = class extends Error {
54
- constructor(status, message, retryAfterSeconds, code = null) {
55
- super(message);
56
- this.name = "EmailAPIError";
57
- this.status = status;
58
- this.retryAfterSeconds = retryAfterSeconds;
59
- this.code = code;
60
- }
61
- get retryable() {
62
- return this.status === 429 || this.status >= 500 && this.status < 600;
63
- }
7
+ constructor(status, message, retryAfterSeconds, code = null) {
8
+ super(message);
9
+ this.name = "EmailAPIError";
10
+ this.status = status;
11
+ this.retryAfterSeconds = retryAfterSeconds;
12
+ this.code = code;
13
+ }
14
+ get retryable() {
15
+ return this.status === 429 || this.status >= 500 && this.status < 600;
16
+ }
64
17
  };
65
18
  function parseRetryAfter(header) {
66
- if (!header)
67
- return null;
68
- const parsed = Number(header);
69
- if (!Number.isNaN(parsed))
70
- return parsed;
71
- const date = new Date(header);
72
- if (!Number.isNaN(date.getTime())) {
73
- return Math.max(0, Math.ceil((date.getTime() - Date.now()) / 1e3));
74
- }
75
- return null;
19
+ if (!header) return null;
20
+ const parsed = Number(header);
21
+ if (!Number.isNaN(parsed)) return parsed;
22
+ const date = new Date(header);
23
+ if (!Number.isNaN(date.getTime())) return Math.max(0, Math.ceil((date.getTime() - Date.now()) / 1e3));
24
+ return null;
76
25
  }
77
26
  function buildAuthHeaderValue(apiKey) {
78
- return `Bearer ${apiKey}`;
27
+ return `Bearer ${apiKey}`;
79
28
  }
80
29
  function parseErrorCode(body) {
81
- try {
82
- const parsed = JSON.parse(body);
83
- if (parsed && typeof parsed === "object" && "type" in parsed && typeof parsed.type === "string") {
84
- return parsed.type;
85
- }
86
- } catch {
87
- return null;
88
- }
89
- return null;
30
+ try {
31
+ const parsed = JSON.parse(body);
32
+ if (parsed && typeof parsed === "object" && "type" in parsed && typeof parsed.type === "string") return parsed.type;
33
+ } catch {
34
+ return null;
35
+ }
36
+ return null;
90
37
  }
91
38
  async function throwIfNotOk(response) {
92
- if (response.ok)
93
- return;
94
- const errorText = await response.text();
95
- const safeErrorText = errorText.length > 500 ? `${errorText.slice(0, 500)}...` : errorText;
96
- const retryAfterSeconds = parseRetryAfter(response.headers.get("Retry-After"));
97
- const code = parseErrorCode(errorText);
98
- if (response.status === 429) {
99
- console.error("[email-js] rate limited:", { status: response.status, code, retryAfterSeconds });
100
- }
101
- throw new EmailAPIError(
102
- response.status,
103
- `Email API error: ${response.status} ${safeErrorText}`,
104
- retryAfterSeconds,
105
- code
106
- );
39
+ if (response.ok) return;
40
+ const errorText = await response.text();
41
+ const safeErrorText = errorText.length > 500 ? `${errorText.slice(0, 500)}...` : errorText;
42
+ const retryAfterSeconds = parseRetryAfter(response.headers.get("Retry-After"));
43
+ const code = parseErrorCode(errorText);
44
+ if (response.status === 429) console.error("[email-js] rate limited:", {
45
+ status: response.status,
46
+ code,
47
+ retryAfterSeconds
48
+ });
49
+ throw new EmailAPIError(response.status, `Email API error: ${response.status} ${safeErrorText}`, retryAfterSeconds, code);
107
50
  }
108
51
  async function emailApiRequest(options, path, init = { method: "GET" }) {
109
- if (!options.apiKey) {
110
- throw new Error("Missing Lovable API key");
111
- }
112
- const headers = {
113
- [options.authHeader ?? DEFAULT_AUTH_HEADER]: buildAuthHeaderValue(options.apiKey)
114
- };
115
- if (init.body !== void 0) {
116
- headers["Content-Type"] = "application/json";
117
- }
118
- const response = await fetch(`${resolveApiBaseUrl(options.apiBaseUrl)}${path}`, {
119
- method: init.method,
120
- headers,
121
- body: init.body === void 0 ? void 0 : JSON.stringify(init.body)
122
- });
123
- await throwIfNotOk(response);
124
- return await response.json();
52
+ if (!options.apiKey) throw new Error("Missing Lovable API key");
53
+ const headers = { [options.authHeader ?? "Authorization"]: buildAuthHeaderValue(options.apiKey) };
54
+ if (init.body !== void 0) headers["Content-Type"] = "application/json";
55
+ const response = await fetch(`${resolveApiBaseUrl(options.apiBaseUrl)}${path}`, {
56
+ method: init.method,
57
+ headers,
58
+ body: init.body === void 0 ? void 0 : JSON.stringify(init.body)
59
+ });
60
+ await throwIfNotOk(response);
61
+ return await response.json();
125
62
  }
126
-
127
- // src/email.ts
128
- var DEFAULT_SEND_PATH = "/v1/messaging/email/send";
63
+ //#endregion
64
+ //#region src/email.ts
65
+ const DEFAULT_SEND_PATH = "/v1/messaging/email/send";
129
66
  async function sendLovableEmail(payload, options) {
130
- const apiKey = options.apiKey;
131
- if (!apiKey) {
132
- throw new Error("Missing Lovable API key");
133
- }
134
- const authHeader = options.authHeader ?? DEFAULT_AUTH_HEADER;
135
- const sendUrl = options.sendUrl;
136
- const url = sendUrl || `${resolveApiBaseUrl(options.apiBaseUrl)}${DEFAULT_SEND_PATH}`;
137
- const idempotencyKey = options.idempotencyKey ?? payload.idempotency_key ?? payload.run_id;
138
- const headers = {
139
- [authHeader]: buildAuthHeaderValue(apiKey),
140
- "Content-Type": "application/json"
141
- };
142
- if (idempotencyKey) {
143
- headers["Idempotency-Key"] = idempotencyKey;
144
- }
145
- const response = await fetch(url, {
146
- method: "POST",
147
- headers,
148
- body: JSON.stringify(payload)
149
- });
150
- await throwIfNotOk(response);
151
- return await response.json();
67
+ const apiKey = options.apiKey;
68
+ if (!apiKey) throw new Error("Missing Lovable API key");
69
+ const authHeader = options.authHeader ?? "Authorization";
70
+ const url = options.sendUrl || `${resolveApiBaseUrl(options.apiBaseUrl)}${DEFAULT_SEND_PATH}`;
71
+ const idempotencyKey = options.idempotencyKey ?? payload.idempotency_key ?? payload.run_id;
72
+ const headers = {
73
+ [authHeader]: buildAuthHeaderValue(apiKey),
74
+ "Content-Type": "application/json"
75
+ };
76
+ if (idempotencyKey) headers["Idempotency-Key"] = idempotencyKey;
77
+ const response = await fetch(url, {
78
+ method: "POST",
79
+ headers,
80
+ body: JSON.stringify(payload)
81
+ });
82
+ await throwIfNotOk(response);
83
+ return await response.json();
152
84
  }
153
-
154
- // src/webhook-handler.ts
155
- var import_webhooks_js = require("@lovable.dev/webhooks-js");
156
-
157
- // src/webhook.ts
85
+ //#endregion
86
+ //#region src/webhook.ts
158
87
  function parseEmailWebhookPayload(body) {
159
- const parsed = JSON.parse(body);
160
- if (!parsed || typeof parsed !== "object") {
161
- throw new Error("Invalid email webhook payload: missing version or type");
162
- }
163
- const payload = parsed;
164
- if (typeof payload.version !== "string" || typeof payload.type !== "string") {
165
- throw new Error("Invalid email webhook payload: missing version or type");
166
- }
167
- return payload;
88
+ const parsed = JSON.parse(body);
89
+ if (!parsed || typeof parsed !== "object") throw new Error("Invalid email webhook payload: missing version or type");
90
+ const payload = parsed;
91
+ if (typeof payload.version !== "string" || typeof payload.type !== "string") throw new Error("Invalid email webhook payload: missing version or type");
92
+ return payload;
168
93
  }
169
-
170
- // src/webhook-handler.ts
171
- var WEBHOOK_ERROR_STATUS = {
172
- missing_secret: 401,
173
- missing_timestamp: 401,
174
- invalid_timestamp: 401,
175
- stale_timestamp: 401,
176
- invalid_signature: 401,
177
- body_too_large: 400,
178
- invalid_json: 400,
179
- invalid_payload: 400
94
+ //#endregion
95
+ //#region src/webhook-handler.ts
96
+ const WEBHOOK_ERROR_STATUS = {
97
+ missing_secret: 401,
98
+ missing_timestamp: 401,
99
+ invalid_timestamp: 401,
100
+ stale_timestamp: 401,
101
+ invalid_signature: 401,
102
+ body_too_large: 400,
103
+ invalid_json: 400,
104
+ invalid_payload: 400
180
105
  };
181
106
  function parseEmailWebhookEvent(body) {
182
- return parseEmailWebhookPayload(body);
107
+ return parseEmailWebhookPayload(body);
183
108
  }
184
109
  function createEmailWebhookHandler(options) {
185
- const { apiKey, on } = options;
186
- if (!apiKey) {
187
- throw new Error("Missing Lovable API key");
188
- }
189
- return async (req) => {
190
- if (req.method !== "POST") {
191
- return Response.json({ error: "Method not allowed" }, { status: 405, headers: { Allow: "POST" } });
192
- }
193
- let event;
194
- try {
195
- ({ payload: event } = await (0, import_webhooks_js.verifyWebhookRequest)({ req, secret: apiKey, parser: parseEmailWebhookEvent }));
196
- } catch (error) {
197
- if (error instanceof import_webhooks_js.WebhookError) {
198
- return Response.json({ error: error.message }, { status: WEBHOOK_ERROR_STATUS[error.code] });
199
- }
200
- console.error("[email-js] webhook verification failed:", error);
201
- return Response.json({ error: "Webhook verification failed" }, { status: 500 });
202
- }
203
- if (event.version !== "1") {
204
- return Response.json({ received: true });
205
- }
206
- const handler = on[event.type];
207
- if (handler) {
208
- try {
209
- await handler(event);
210
- } catch (error) {
211
- console.error("[email-js] webhook handler failed:", error);
212
- return Response.json({ error: "Handler failed" }, { status: 500 });
213
- }
214
- }
215
- return Response.json({ received: true });
216
- };
110
+ const { apiKey, on } = options;
111
+ if (!apiKey) throw new Error("Missing Lovable API key");
112
+ return async (req) => {
113
+ if (req.method !== "POST") return Response.json({ error: "Method not allowed" }, {
114
+ status: 405,
115
+ headers: { Allow: "POST" }
116
+ });
117
+ let event;
118
+ try {
119
+ ({payload: event} = await (0, _lovable_dev_webhooks_js.verifyWebhookRequest)({
120
+ req,
121
+ secret: apiKey,
122
+ parser: parseEmailWebhookEvent
123
+ }));
124
+ } catch (error) {
125
+ if (error instanceof _lovable_dev_webhooks_js.WebhookError) return Response.json({ error: error.message }, { status: WEBHOOK_ERROR_STATUS[error.code] });
126
+ console.error("[email-js] webhook verification failed:", error);
127
+ return Response.json({ error: "Webhook verification failed" }, { status: 500 });
128
+ }
129
+ if (event.version !== "1") return Response.json({ received: true });
130
+ const handler = on[event.type];
131
+ if (handler) try {
132
+ await handler(event);
133
+ } catch (error) {
134
+ console.error("[email-js] webhook handler failed:", error);
135
+ return Response.json({ error: "Handler failed" }, { status: 500 });
136
+ }
137
+ return Response.json({ received: true });
138
+ };
217
139
  }
218
-
219
- // src/auth-email-handler.ts
140
+ //#endregion
141
+ //#region src/auth-email-handler.ts
220
142
  function parseAuthEmailWebhookPayload(body) {
221
- const parsed = JSON.parse(body);
222
- const payload = parsed;
223
- if (!parsed || typeof parsed !== "object" || typeof payload.version !== "string" || payload.type !== "auth" || !payload.data || typeof payload.data !== "object" || typeof payload.data.action_type !== "string" || typeof payload.data.email !== "string") {
224
- throw new Error("Invalid auth email webhook payload");
225
- }
226
- return payload;
143
+ const parsed = JSON.parse(body);
144
+ const payload = parsed;
145
+ if (!parsed || typeof parsed !== "object" || typeof payload.version !== "string" || payload.type !== "auth" || !payload.data || typeof payload.data !== "object" || typeof payload.data.action_type !== "string" || typeof payload.data.email !== "string") throw new Error("Invalid auth email webhook payload");
146
+ return payload;
227
147
  }
228
148
  function domainOfAddress(from) {
229
- const match = /@([^@\s<>]+)>?\s*$/.exec(from.trim());
230
- return match?.[1];
149
+ return /@([^@\s<>]+)>?\s*$/.exec(from.trim())?.[1];
231
150
  }
232
151
  function createAuthEmailHandler(options) {
233
- const { apiKey, from, emails } = options;
234
- if (!apiKey) {
235
- throw new Error("Missing Lovable API key");
236
- }
237
- const senderDomain = options.senderDomain ?? domainOfAddress(from);
238
- if (!senderDomain) {
239
- throw new Error(`Cannot derive a sender domain from "${from}"; pass senderDomain`);
240
- }
241
- return async (req) => {
242
- if (req.method !== "POST") {
243
- return Response.json({ error: "Method not allowed" }, { status: 405, headers: { Allow: "POST" } });
244
- }
245
- let event;
246
- try {
247
- ({ payload: event } = await (0, import_webhooks_js2.verifyWebhookRequest)({ req, secret: apiKey, parser: parseAuthEmailWebhookPayload }));
248
- } catch (error) {
249
- if (error instanceof import_webhooks_js2.WebhookError) {
250
- return Response.json({ error: error.message }, { status: WEBHOOK_ERROR_STATUS[error.code] });
251
- }
252
- console.error("[email-js] auth webhook verification failed:", error);
253
- return Response.json({ error: "Webhook verification failed" }, { status: 500 });
254
- }
255
- if (!event.run_id) {
256
- return Response.json({ error: "Missing run_id" }, { status: 400 });
257
- }
258
- if (event.version !== "1") {
259
- return Response.json({ error: `Unsupported payload version: ${event.version}` }, { status: 400 });
260
- }
261
- const actionType = event.data.action_type;
262
- const definition = Object.prototype.hasOwnProperty.call(emails, actionType) ? emails[actionType] : void 0;
263
- if (!definition) {
264
- return Response.json({ error: `Unknown auth email action type: ${actionType}` }, { status: 400 });
265
- }
266
- try {
267
- const { render } = await import("@react-email/render");
268
- const { subject, element } = typeof definition === "function" ? await definition(event.data) : { subject: definition.subject, element: await definition.render(event.data) };
269
- const html = await render(element);
270
- const text = await render(element, { plainText: true });
271
- await sendLovableEmail(
272
- {
273
- run_id: event.run_id,
274
- to: event.data.email,
275
- from,
276
- sender_domain: senderDomain,
277
- subject,
278
- html,
279
- text,
280
- purpose: "transactional",
281
- label: actionType
282
- },
283
- { apiKey, sendUrl: options.sendUrl }
284
- );
285
- } catch (error) {
286
- console.error("[email-js] auth email send failed:", error);
287
- if (error instanceof EmailAPIError && !error.retryable) {
288
- return Response.json({ error: "Email send rejected" }, { status: 400 });
289
- }
290
- return Response.json({ error: "Failed to send email" }, { status: 500 });
291
- }
292
- return Response.json({ success: true, sent: true });
293
- };
152
+ const { apiKey, from, emails } = options;
153
+ if (!apiKey) throw new Error("Missing Lovable API key");
154
+ const senderDomain = options.senderDomain ?? domainOfAddress(from);
155
+ if (!senderDomain) throw new Error(`Cannot derive a sender domain from "${from}"; pass senderDomain`);
156
+ return async (req) => {
157
+ if (req.method !== "POST") return Response.json({ error: "Method not allowed" }, {
158
+ status: 405,
159
+ headers: { Allow: "POST" }
160
+ });
161
+ let event;
162
+ try {
163
+ ({payload: event} = await (0, _lovable_dev_webhooks_js.verifyWebhookRequest)({
164
+ req,
165
+ secret: apiKey,
166
+ parser: parseAuthEmailWebhookPayload
167
+ }));
168
+ } catch (error) {
169
+ if (error instanceof _lovable_dev_webhooks_js.WebhookError) return Response.json({ error: error.message }, { status: WEBHOOK_ERROR_STATUS[error.code] });
170
+ console.error("[email-js] auth webhook verification failed:", error);
171
+ return Response.json({ error: "Webhook verification failed" }, { status: 500 });
172
+ }
173
+ if (!event.run_id) return Response.json({ error: "Missing run_id" }, { status: 400 });
174
+ if (event.version !== "1") return Response.json({ error: `Unsupported payload version: ${event.version}` }, { status: 400 });
175
+ const actionType = event.data.action_type;
176
+ const definition = Object.prototype.hasOwnProperty.call(emails, actionType) ? emails[actionType] : void 0;
177
+ if (!definition) return Response.json({ error: `Unknown auth email action type: ${actionType}` }, { status: 400 });
178
+ try {
179
+ const { render } = await import("@react-email/render");
180
+ const { subject, element } = typeof definition === "function" ? await definition(event.data) : {
181
+ subject: definition.subject,
182
+ element: await definition.render(event.data)
183
+ };
184
+ const html = await render(element);
185
+ const text = await render(element, { plainText: true });
186
+ await sendLovableEmail({
187
+ run_id: event.run_id,
188
+ to: event.data.email,
189
+ from,
190
+ sender_domain: senderDomain,
191
+ subject,
192
+ html,
193
+ text,
194
+ purpose: "transactional",
195
+ label: actionType
196
+ }, {
197
+ apiKey,
198
+ sendUrl: options.sendUrl
199
+ });
200
+ } catch (error) {
201
+ console.error("[email-js] auth email send failed:", error);
202
+ if (error instanceof EmailAPIError && !error.retryable) return Response.json({ error: "Email send rejected" }, { status: 400 });
203
+ return Response.json({ error: "Failed to send email" }, { status: 500 });
204
+ }
205
+ return Response.json({
206
+ success: true,
207
+ sent: true
208
+ });
209
+ };
294
210
  }
295
-
296
- // src/logs.ts
297
- var LOGS_PATH = "/v1/messaging/email/logs";
211
+ //#endregion
212
+ //#region src/logs.ts
213
+ const LOGS_PATH = "/v1/messaging/email/logs";
298
214
  function buildLogsQuery(filters) {
299
- const params = new URLSearchParams();
300
- if (filters.recipient)
301
- params.set("recipient", filters.recipient);
302
- if (filters.event_type)
303
- params.set("event_type", filters.event_type);
304
- if (filters.status)
305
- params.set("status", filters.status);
306
- if (filters.tag)
307
- params.set("tag", filters.tag);
308
- if (filters.since)
309
- params.set("since", filters.since);
310
- if (filters.until)
311
- params.set("until", filters.until);
312
- if (filters.limit !== void 0)
313
- params.set("limit", String(filters.limit));
314
- if (filters.cursor)
315
- params.set("cursor", filters.cursor);
316
- const query = params.toString();
317
- return query ? `?${query}` : "";
215
+ const params = new URLSearchParams();
216
+ if (filters.recipient) params.set("recipient", filters.recipient);
217
+ if (filters.event_type) params.set("event_type", filters.event_type);
218
+ if (filters.status) params.set("status", filters.status);
219
+ if (filters.tag) params.set("tag", filters.tag);
220
+ if (filters.since) params.set("since", filters.since);
221
+ if (filters.until) params.set("until", filters.until);
222
+ if (filters.limit !== void 0) params.set("limit", String(filters.limit));
223
+ if (filters.cursor) params.set("cursor", filters.cursor);
224
+ const query = params.toString();
225
+ return query ? `?${query}` : "";
318
226
  }
319
227
  async function listEmailLogs(filters, options) {
320
- const body = await emailApiRequest(options, `${LOGS_PATH}${buildLogsQuery(filters)}`);
321
- return { ...body, data: body.data ?? [] };
228
+ const body = await emailApiRequest(options, `${LOGS_PATH}${buildLogsQuery(filters)}`);
229
+ return {
230
+ ...body,
231
+ data: body.data ?? []
232
+ };
322
233
  }
323
-
324
- // src/unsubscribe.ts
325
- var UNSUBSCRIBES_PATH = "/v1/messaging/email/unsubscribes";
234
+ //#endregion
235
+ //#region src/unsubscribe.ts
236
+ const UNSUBSCRIBES_PATH = "/v1/messaging/email/unsubscribes";
326
237
  function buildUnsubscribePath(recipient, domain) {
327
- if (!recipient.includes("@")) {
328
- throw new Error("Invalid recipient");
329
- }
330
- const query = new URLSearchParams({ domain }).toString();
331
- return `${UNSUBSCRIBES_PATH}/${encodeURIComponent(recipient)}?${query}`;
238
+ if (!recipient.includes("@")) throw new Error("Invalid recipient");
239
+ const query = new URLSearchParams({ domain }).toString();
240
+ return `${UNSUBSCRIBES_PATH}/${encodeURIComponent(recipient)}?${query}`;
332
241
  }
333
242
  async function getEmailUnsubscribe(request, options) {
334
- return emailApiRequest(options, buildUnsubscribePath(request.recipient, request.domain));
243
+ return emailApiRequest(options, buildUnsubscribePath(request.recipient, request.domain));
335
244
  }
336
245
  async function setEmailUnsubscribe(request, options) {
337
- return emailApiRequest(options, buildUnsubscribePath(request.recipient, request.domain), {
338
- method: "PUT",
339
- body: { subscribed: request.subscribed }
340
- });
246
+ return emailApiRequest(options, buildUnsubscribePath(request.recipient, request.domain), {
247
+ method: "PUT",
248
+ body: { subscribed: request.subscribed }
249
+ });
341
250
  }
342
- // Annotate the CommonJS export names for ESM import in node:
343
- 0 && (module.exports = {
344
- EmailAPIError,
345
- createAuthEmailHandler,
346
- createEmailWebhookHandler,
347
- getEmailUnsubscribe,
348
- listEmailLogs,
349
- parseEmailWebhookPayload,
350
- sendLovableEmail,
351
- setEmailUnsubscribe
352
- });
251
+ //#endregion
252
+ exports.EmailAPIError = EmailAPIError;
253
+ exports.createAuthEmailHandler = createAuthEmailHandler;
254
+ exports.createEmailWebhookHandler = createEmailWebhookHandler;
255
+ exports.getEmailUnsubscribe = getEmailUnsubscribe;
256
+ exports.listEmailLogs = listEmailLogs;
257
+ exports.parseEmailWebhookPayload = parseEmailWebhookPayload;
258
+ exports.sendLovableEmail = sendLovableEmail;
259
+ exports.setEmailUnsubscribe = setEmailUnsubscribe;