resend 6.10.0 → 6.11.0-canary.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.cjs +180 -45
- package/dist/index.d.cts +336 -4
- package/dist/index.d.mts +336 -4
- package/dist/index.mjs +173 -33
- package/package.json +9 -9
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value:
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
//#region \0rolldown/runtime.js
|
|
3
3
|
var __create = Object.create;
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
@@ -7,16 +7,12 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
|
7
7
|
var __getProtoOf = Object.getPrototypeOf;
|
|
8
8
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
9
|
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
}
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
11
|
+
key = keys[i];
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
13
|
+
get: ((k) => from[k]).bind(null, key),
|
|
14
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
15
|
+
});
|
|
20
16
|
}
|
|
21
17
|
return to;
|
|
22
18
|
};
|
|
@@ -24,15 +20,12 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
24
20
|
value: mod,
|
|
25
21
|
enumerable: true
|
|
26
22
|
}) : target, mod));
|
|
27
|
-
|
|
28
23
|
//#endregion
|
|
29
24
|
let postal_mime = require("postal-mime");
|
|
30
25
|
postal_mime = __toESM(postal_mime);
|
|
31
26
|
let svix = require("svix");
|
|
32
|
-
|
|
33
27
|
//#region package.json
|
|
34
|
-
var version = "6.
|
|
35
|
-
|
|
28
|
+
var version = "6.11.0-canary.1";
|
|
36
29
|
//#endregion
|
|
37
30
|
//#region src/common/utils/build-pagination-query.ts
|
|
38
31
|
/**
|
|
@@ -47,7 +40,6 @@ function buildPaginationQuery(options) {
|
|
|
47
40
|
if ("before" in options && options.before !== void 0) searchParams.set("before", options.before);
|
|
48
41
|
return searchParams.toString();
|
|
49
42
|
}
|
|
50
|
-
|
|
51
43
|
//#endregion
|
|
52
44
|
//#region src/api-keys/api-keys.ts
|
|
53
45
|
var ApiKeys = class {
|
|
@@ -66,7 +58,145 @@ var ApiKeys = class {
|
|
|
66
58
|
return await this.resend.delete(`/api-keys/${id}`);
|
|
67
59
|
}
|
|
68
60
|
};
|
|
69
|
-
|
|
61
|
+
//#endregion
|
|
62
|
+
//#region src/automation-runs/automation-runs.ts
|
|
63
|
+
var AutomationRuns = class {
|
|
64
|
+
constructor(resend) {
|
|
65
|
+
this.resend = resend;
|
|
66
|
+
}
|
|
67
|
+
async get(options) {
|
|
68
|
+
return await this.resend.get(`/automations/${options.automationId}/runs/${options.runId}`);
|
|
69
|
+
}
|
|
70
|
+
async list(options) {
|
|
71
|
+
const queryString = buildPaginationQuery(options);
|
|
72
|
+
const searchParams = new URLSearchParams(queryString);
|
|
73
|
+
if (options.status) {
|
|
74
|
+
const statusValue = Array.isArray(options.status) ? options.status.join(",") : options.status;
|
|
75
|
+
searchParams.set("status", statusValue);
|
|
76
|
+
}
|
|
77
|
+
const qs = searchParams.toString();
|
|
78
|
+
const url = qs ? `/automations/${options.automationId}/runs?${qs}` : `/automations/${options.automationId}/runs`;
|
|
79
|
+
return await this.resend.get(url);
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
//#endregion
|
|
83
|
+
//#region src/common/utils/parse-automation-to-api-options.ts
|
|
84
|
+
function parseStepConfig(step) {
|
|
85
|
+
switch (step.type) {
|
|
86
|
+
case "trigger": return {
|
|
87
|
+
key: step.key,
|
|
88
|
+
type: step.type,
|
|
89
|
+
config: { event_name: step.config.eventName }
|
|
90
|
+
};
|
|
91
|
+
case "delay": return {
|
|
92
|
+
key: step.key,
|
|
93
|
+
type: step.type,
|
|
94
|
+
config: step.config
|
|
95
|
+
};
|
|
96
|
+
case "send_email": return {
|
|
97
|
+
key: step.key,
|
|
98
|
+
type: step.type,
|
|
99
|
+
config: {
|
|
100
|
+
template: step.config.template,
|
|
101
|
+
subject: step.config.subject,
|
|
102
|
+
from: step.config.from,
|
|
103
|
+
reply_to: step.config.replyTo
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
case "wait_for_event": return {
|
|
107
|
+
key: step.key,
|
|
108
|
+
type: step.type,
|
|
109
|
+
config: {
|
|
110
|
+
event_name: step.config.eventName,
|
|
111
|
+
timeout: step.config.timeout,
|
|
112
|
+
filter_rule: step.config.filterRule
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
case "condition": return {
|
|
116
|
+
key: step.key,
|
|
117
|
+
type: step.type,
|
|
118
|
+
config: step.config
|
|
119
|
+
};
|
|
120
|
+
case "contact_update": return {
|
|
121
|
+
key: step.key,
|
|
122
|
+
type: step.type,
|
|
123
|
+
config: {
|
|
124
|
+
first_name: step.config.firstName,
|
|
125
|
+
last_name: step.config.lastName,
|
|
126
|
+
unsubscribed: step.config.unsubscribed,
|
|
127
|
+
properties: step.config.properties
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
case "contact_delete": return {
|
|
131
|
+
key: step.key,
|
|
132
|
+
type: step.type,
|
|
133
|
+
config: step.config
|
|
134
|
+
};
|
|
135
|
+
case "add_to_segment": return {
|
|
136
|
+
key: step.key,
|
|
137
|
+
type: step.type,
|
|
138
|
+
config: { segment_id: step.config.segmentId }
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
function parseConnection(connection) {
|
|
143
|
+
return {
|
|
144
|
+
from: connection.from,
|
|
145
|
+
to: connection.to,
|
|
146
|
+
type: connection.type
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
function parseAutomationToApiOptions(automation) {
|
|
150
|
+
return {
|
|
151
|
+
name: automation.name,
|
|
152
|
+
status: automation.status,
|
|
153
|
+
steps: automation.steps.map(parseStepConfig),
|
|
154
|
+
connections: automation.connections.map(parseConnection)
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
function parseEventToApiOptions(event) {
|
|
158
|
+
return {
|
|
159
|
+
event: event.event,
|
|
160
|
+
contact_id: event.contactId,
|
|
161
|
+
email: event.email,
|
|
162
|
+
payload: event.payload
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
//#endregion
|
|
166
|
+
//#region src/automations/automations.ts
|
|
167
|
+
var Automations = class {
|
|
168
|
+
constructor(resend) {
|
|
169
|
+
this.resend = resend;
|
|
170
|
+
this.runs = new AutomationRuns(this.resend);
|
|
171
|
+
}
|
|
172
|
+
async create(payload) {
|
|
173
|
+
return await this.resend.post("/automations", parseAutomationToApiOptions(payload));
|
|
174
|
+
}
|
|
175
|
+
async list(options = {}) {
|
|
176
|
+
const params = [buildPaginationQuery(options)];
|
|
177
|
+
if (options.status) params.push(`status=${encodeURIComponent(options.status)}`);
|
|
178
|
+
const qs = params.filter(Boolean).join("&");
|
|
179
|
+
const url = qs ? `/automations?${qs}` : "/automations";
|
|
180
|
+
return await this.resend.get(url);
|
|
181
|
+
}
|
|
182
|
+
async get(id) {
|
|
183
|
+
return await this.resend.get(`/automations/${id}`);
|
|
184
|
+
}
|
|
185
|
+
async remove(id) {
|
|
186
|
+
return await this.resend.delete(`/automations/${id}`);
|
|
187
|
+
}
|
|
188
|
+
async update(id, payload) {
|
|
189
|
+
const apiPayload = {};
|
|
190
|
+
if (payload.name !== void 0) apiPayload.name = payload.name;
|
|
191
|
+
if (payload.status !== void 0) apiPayload.status = payload.status;
|
|
192
|
+
if (payload.steps !== void 0) apiPayload.steps = payload.steps.map(parseStepConfig);
|
|
193
|
+
if (payload.connections !== void 0) apiPayload.connections = payload.connections.map(parseConnection);
|
|
194
|
+
return await this.resend.patch(`/automations/${id}`, apiPayload);
|
|
195
|
+
}
|
|
196
|
+
async stop(id) {
|
|
197
|
+
return await this.resend.post(`/automations/${id}/stop`);
|
|
198
|
+
}
|
|
199
|
+
};
|
|
70
200
|
//#endregion
|
|
71
201
|
//#region src/common/utils/parse-email-to-api-options.ts
|
|
72
202
|
function parseAttachments(attachments) {
|
|
@@ -99,7 +229,6 @@ function parseEmailToApiOptions(email) {
|
|
|
99
229
|
topic_id: email.topicId
|
|
100
230
|
};
|
|
101
231
|
}
|
|
102
|
-
|
|
103
232
|
//#endregion
|
|
104
233
|
//#region src/render.ts
|
|
105
234
|
async function render(node) {
|
|
@@ -111,7 +240,6 @@ async function render(node) {
|
|
|
111
240
|
}
|
|
112
241
|
return render(node);
|
|
113
242
|
}
|
|
114
|
-
|
|
115
243
|
//#endregion
|
|
116
244
|
//#region src/batch/batch.ts
|
|
117
245
|
var Batch = class {
|
|
@@ -139,7 +267,6 @@ var Batch = class {
|
|
|
139
267
|
});
|
|
140
268
|
}
|
|
141
269
|
};
|
|
142
|
-
|
|
143
270
|
//#endregion
|
|
144
271
|
//#region src/broadcasts/broadcasts.ts
|
|
145
272
|
var Broadcasts = class {
|
|
@@ -193,7 +320,6 @@ var Broadcasts = class {
|
|
|
193
320
|
});
|
|
194
321
|
}
|
|
195
322
|
};
|
|
196
|
-
|
|
197
323
|
//#endregion
|
|
198
324
|
//#region src/common/utils/parse-contact-properties-to-api-options.ts
|
|
199
325
|
function parseContactPropertyFromApi(contactProperty) {
|
|
@@ -213,7 +339,6 @@ function parseContactPropertyToApiOptions(contactProperty) {
|
|
|
213
339
|
};
|
|
214
340
|
return { fallback_value: contactProperty.fallbackValue };
|
|
215
341
|
}
|
|
216
|
-
|
|
217
342
|
//#endregion
|
|
218
343
|
//#region src/contact-properties/contact-properties.ts
|
|
219
344
|
var ContactProperties = class {
|
|
@@ -285,7 +410,6 @@ var ContactProperties = class {
|
|
|
285
410
|
return await this.resend.delete(`/contact-properties/${id}`);
|
|
286
411
|
}
|
|
287
412
|
};
|
|
288
|
-
|
|
289
413
|
//#endregion
|
|
290
414
|
//#region src/contacts/segments/contact-segments.ts
|
|
291
415
|
var ContactSegments = class {
|
|
@@ -334,7 +458,6 @@ var ContactSegments = class {
|
|
|
334
458
|
return this.resend.delete(`/contacts/${identifier}/segments/${options.segmentId}`);
|
|
335
459
|
}
|
|
336
460
|
};
|
|
337
|
-
|
|
338
461
|
//#endregion
|
|
339
462
|
//#region src/contacts/topics/contact-topics.ts
|
|
340
463
|
var ContactTopics = class {
|
|
@@ -370,7 +493,6 @@ var ContactTopics = class {
|
|
|
370
493
|
return this.resend.get(url);
|
|
371
494
|
}
|
|
372
495
|
};
|
|
373
|
-
|
|
374
496
|
//#endregion
|
|
375
497
|
//#region src/contacts/contacts.ts
|
|
376
498
|
var Contacts = class {
|
|
@@ -471,7 +593,6 @@ var Contacts = class {
|
|
|
471
593
|
return this.resend.delete(`/audiences/${payload.audienceId}/contacts/${payload?.email ? payload?.email : payload?.id}`);
|
|
472
594
|
}
|
|
473
595
|
};
|
|
474
|
-
|
|
475
596
|
//#endregion
|
|
476
597
|
//#region src/common/utils/parse-domain-to-api-options.ts
|
|
477
598
|
function parseDomainToApiOptions(domain) {
|
|
@@ -485,7 +606,6 @@ function parseDomainToApiOptions(domain) {
|
|
|
485
606
|
tls: domain.tls
|
|
486
607
|
};
|
|
487
608
|
}
|
|
488
|
-
|
|
489
609
|
//#endregion
|
|
490
610
|
//#region src/domains/domains.ts
|
|
491
611
|
var Domains = class {
|
|
@@ -518,7 +638,6 @@ var Domains = class {
|
|
|
518
638
|
return await this.resend.post(`/domains/${id}/verify`);
|
|
519
639
|
}
|
|
520
640
|
};
|
|
521
|
-
|
|
522
641
|
//#endregion
|
|
523
642
|
//#region src/emails/attachments/attachments.ts
|
|
524
643
|
var Attachments$1 = class {
|
|
@@ -536,7 +655,6 @@ var Attachments$1 = class {
|
|
|
536
655
|
return await this.resend.get(url);
|
|
537
656
|
}
|
|
538
657
|
};
|
|
539
|
-
|
|
540
658
|
//#endregion
|
|
541
659
|
//#region src/emails/receiving/attachments/attachments.ts
|
|
542
660
|
var Attachments = class {
|
|
@@ -554,7 +672,6 @@ var Attachments = class {
|
|
|
554
672
|
return await this.resend.get(url);
|
|
555
673
|
}
|
|
556
674
|
};
|
|
557
|
-
|
|
558
675
|
//#endregion
|
|
559
676
|
//#region src/emails/receiving/receiving.ts
|
|
560
677
|
var Receiving = class {
|
|
@@ -672,7 +789,6 @@ var Receiving = class {
|
|
|
672
789
|
});
|
|
673
790
|
}
|
|
674
791
|
};
|
|
675
|
-
|
|
676
792
|
//#endregion
|
|
677
793
|
//#region src/emails/emails.ts
|
|
678
794
|
var Emails = class {
|
|
@@ -703,7 +819,33 @@ var Emails = class {
|
|
|
703
819
|
return await this.resend.post(`/emails/${id}/cancel`);
|
|
704
820
|
}
|
|
705
821
|
};
|
|
706
|
-
|
|
822
|
+
//#endregion
|
|
823
|
+
//#region src/events/events.ts
|
|
824
|
+
var Events = class {
|
|
825
|
+
constructor(resend) {
|
|
826
|
+
this.resend = resend;
|
|
827
|
+
}
|
|
828
|
+
async send(payload) {
|
|
829
|
+
return await this.resend.post("/events/send", parseEventToApiOptions(payload));
|
|
830
|
+
}
|
|
831
|
+
async create(payload) {
|
|
832
|
+
return await this.resend.post("/events", payload);
|
|
833
|
+
}
|
|
834
|
+
async get(identifier) {
|
|
835
|
+
return await this.resend.get(`/events/${encodeURIComponent(identifier)}`);
|
|
836
|
+
}
|
|
837
|
+
async list(options = {}) {
|
|
838
|
+
const queryString = buildPaginationQuery(options);
|
|
839
|
+
const url = queryString ? `/events?${queryString}` : "/events";
|
|
840
|
+
return await this.resend.get(url);
|
|
841
|
+
}
|
|
842
|
+
async update(identifier, payload) {
|
|
843
|
+
return await this.resend.patch(`/events/${encodeURIComponent(identifier)}`, payload);
|
|
844
|
+
}
|
|
845
|
+
async remove(identifier) {
|
|
846
|
+
return await this.resend.delete(`/events/${encodeURIComponent(identifier)}`);
|
|
847
|
+
}
|
|
848
|
+
};
|
|
707
849
|
//#endregion
|
|
708
850
|
//#region src/logs/logs.ts
|
|
709
851
|
var Logs = class {
|
|
@@ -719,7 +861,6 @@ var Logs = class {
|
|
|
719
861
|
return await this.resend.get(`/logs/${id}`);
|
|
720
862
|
}
|
|
721
863
|
};
|
|
722
|
-
|
|
723
864
|
//#endregion
|
|
724
865
|
//#region src/segments/segments.ts
|
|
725
866
|
var Segments = class {
|
|
@@ -741,7 +882,6 @@ var Segments = class {
|
|
|
741
882
|
return await this.resend.delete(`/segments/${id}`);
|
|
742
883
|
}
|
|
743
884
|
};
|
|
744
|
-
|
|
745
885
|
//#endregion
|
|
746
886
|
//#region src/common/utils/get-pagination-query-properties.ts
|
|
747
887
|
function getPaginationQueryProperties(options = {}) {
|
|
@@ -751,7 +891,6 @@ function getPaginationQueryProperties(options = {}) {
|
|
|
751
891
|
if (options.limit) query.set("limit", options.limit.toString());
|
|
752
892
|
return query.size > 0 ? `?${query.toString()}` : "";
|
|
753
893
|
}
|
|
754
|
-
|
|
755
894
|
//#endregion
|
|
756
895
|
//#region src/common/utils/parse-template-to-api-options.ts
|
|
757
896
|
function parseVariables(variables) {
|
|
@@ -773,7 +912,6 @@ function parseTemplateToApiOptions(template) {
|
|
|
773
912
|
variables: parseVariables(template.variables)
|
|
774
913
|
};
|
|
775
914
|
}
|
|
776
|
-
|
|
777
915
|
//#endregion
|
|
778
916
|
//#region src/templates/chainable-template-result.ts
|
|
779
917
|
var ChainableTemplateResult = class {
|
|
@@ -794,7 +932,6 @@ var ChainableTemplateResult = class {
|
|
|
794
932
|
return this.publishFn(data.id);
|
|
795
933
|
}
|
|
796
934
|
};
|
|
797
|
-
|
|
798
935
|
//#endregion
|
|
799
936
|
//#region src/templates/templates.ts
|
|
800
937
|
var Templates = class {
|
|
@@ -835,7 +972,6 @@ var Templates = class {
|
|
|
835
972
|
return await this.resend.patch(`/templates/${identifier}`, parseTemplateToApiOptions(payload));
|
|
836
973
|
}
|
|
837
974
|
};
|
|
838
|
-
|
|
839
975
|
//#endregion
|
|
840
976
|
//#region src/topics/topics.ts
|
|
841
977
|
var Topics = class {
|
|
@@ -889,7 +1025,6 @@ var Topics = class {
|
|
|
889
1025
|
return await this.resend.delete(`/topics/${id}`);
|
|
890
1026
|
}
|
|
891
1027
|
};
|
|
892
|
-
|
|
893
1028
|
//#endregion
|
|
894
1029
|
//#region src/webhooks/webhooks.ts
|
|
895
1030
|
var Webhooks = class {
|
|
@@ -921,7 +1056,6 @@ var Webhooks = class {
|
|
|
921
1056
|
});
|
|
922
1057
|
}
|
|
923
1058
|
};
|
|
924
|
-
|
|
925
1059
|
//#endregion
|
|
926
1060
|
//#region src/resend.ts
|
|
927
1061
|
const defaultBaseUrl = "https://api.resend.com";
|
|
@@ -931,19 +1065,21 @@ const userAgent = typeof process !== "undefined" && process.env ? process.env.RE
|
|
|
931
1065
|
var Resend = class {
|
|
932
1066
|
constructor(key) {
|
|
933
1067
|
this.key = key;
|
|
934
|
-
this.apiKeys = new ApiKeys(this);
|
|
935
1068
|
this.segments = new Segments(this);
|
|
1069
|
+
this.apiKeys = new ApiKeys(this);
|
|
936
1070
|
this.audiences = this.segments;
|
|
1071
|
+
this.automations = new Automations(this);
|
|
937
1072
|
this.batch = new Batch(this);
|
|
938
1073
|
this.broadcasts = new Broadcasts(this);
|
|
939
|
-
this.contacts = new Contacts(this);
|
|
940
1074
|
this.contactProperties = new ContactProperties(this);
|
|
1075
|
+
this.contacts = new Contacts(this);
|
|
941
1076
|
this.domains = new Domains(this);
|
|
942
1077
|
this.emails = new Emails(this);
|
|
1078
|
+
this.events = new Events(this);
|
|
943
1079
|
this.logs = new Logs(this);
|
|
944
|
-
this.webhooks = new Webhooks(this);
|
|
945
1080
|
this.templates = new Templates(this);
|
|
946
1081
|
this.topics = new Topics(this);
|
|
1082
|
+
this.webhooks = new Webhooks(this);
|
|
947
1083
|
if (!key) {
|
|
948
1084
|
if (typeof process !== "undefined" && process.env) this.key = process.env.RESEND_API_KEY;
|
|
949
1085
|
if (!this.key) throw new Error("Missing API key. Pass it to the constructor `new Resend(\"re_123\")`");
|
|
@@ -1063,6 +1199,5 @@ var Resend = class {
|
|
|
1063
1199
|
return this.fetchRequest(path, requestOptions);
|
|
1064
1200
|
}
|
|
1065
1201
|
};
|
|
1066
|
-
|
|
1067
1202
|
//#endregion
|
|
1068
|
-
exports.Resend = Resend;
|
|
1203
|
+
exports.Resend = Resend;
|