resend 6.12.3 → 6.13.0-canary.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/dist/index.cjs +82 -31
- package/dist/index.d.cts +94 -5
- package/dist/index.d.mts +94 -5
- package/dist/index.mjs +81 -30
- package/package.json +18 -16
package/dist/index.cjs
CHANGED
|
@@ -23,9 +23,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
23
23
|
//#endregion
|
|
24
24
|
let postal_mime = require("postal-mime");
|
|
25
25
|
postal_mime = __toESM(postal_mime);
|
|
26
|
-
let
|
|
26
|
+
let standardwebhooks = require("standardwebhooks");
|
|
27
27
|
//#region package.json
|
|
28
|
-
var version = "6.
|
|
28
|
+
var version = "6.13.0-canary.0";
|
|
29
29
|
//#endregion
|
|
30
30
|
//#region src/common/utils/build-pagination-query.ts
|
|
31
31
|
/**
|
|
@@ -274,14 +274,14 @@ var Broadcasts = class {
|
|
|
274
274
|
this.resend = resend;
|
|
275
275
|
}
|
|
276
276
|
async create(payload, options = {}) {
|
|
277
|
-
|
|
277
|
+
const html = payload.react ? await render(payload.react) : payload.html;
|
|
278
278
|
return await this.resend.post("/broadcasts", {
|
|
279
279
|
name: payload.name,
|
|
280
280
|
segment_id: payload.segmentId,
|
|
281
281
|
audience_id: payload.audienceId,
|
|
282
282
|
preview_text: payload.previewText,
|
|
283
283
|
from: payload.from,
|
|
284
|
-
html
|
|
284
|
+
html,
|
|
285
285
|
reply_to: payload.replyTo,
|
|
286
286
|
subject: payload.subject,
|
|
287
287
|
text: payload.text,
|
|
@@ -305,13 +305,13 @@ var Broadcasts = class {
|
|
|
305
305
|
return await this.resend.delete(`/broadcasts/${id}`);
|
|
306
306
|
}
|
|
307
307
|
async update(id, payload) {
|
|
308
|
-
|
|
308
|
+
const html = payload.react ? await render(payload.react) : payload.html;
|
|
309
309
|
return await this.resend.patch(`/broadcasts/${id}`, {
|
|
310
310
|
name: payload.name,
|
|
311
311
|
segment_id: payload.segmentId,
|
|
312
312
|
audience_id: payload.audienceId,
|
|
313
313
|
from: payload.from,
|
|
314
|
-
html
|
|
314
|
+
html,
|
|
315
315
|
text: payload.text,
|
|
316
316
|
subject: payload.subject,
|
|
317
317
|
reply_to: payload.replyTo,
|
|
@@ -411,6 +411,51 @@ var ContactProperties = class {
|
|
|
411
411
|
}
|
|
412
412
|
};
|
|
413
413
|
//#endregion
|
|
414
|
+
//#region src/contacts/imports/contact-imports.ts
|
|
415
|
+
var ContactImports = class {
|
|
416
|
+
constructor(resend) {
|
|
417
|
+
this.resend = resend;
|
|
418
|
+
}
|
|
419
|
+
async create(payload, options = {}) {
|
|
420
|
+
const formData = this.buildCreateFormData(payload);
|
|
421
|
+
return this.resend.post("/contacts/imports", formData, options);
|
|
422
|
+
}
|
|
423
|
+
async list(options = {}) {
|
|
424
|
+
const searchParams = new URLSearchParams(buildPaginationQuery(options));
|
|
425
|
+
if (options.status !== void 0) searchParams.set("status", options.status);
|
|
426
|
+
const queryString = searchParams.toString();
|
|
427
|
+
const url = queryString ? `/contacts/imports?${queryString}` : "/contacts/imports";
|
|
428
|
+
return this.resend.get(url);
|
|
429
|
+
}
|
|
430
|
+
async get(id) {
|
|
431
|
+
return this.resend.get(`/contacts/imports/${id}`);
|
|
432
|
+
}
|
|
433
|
+
buildCreateFormData(payload) {
|
|
434
|
+
const formData = new FormData();
|
|
435
|
+
formData.append("file", payload.file);
|
|
436
|
+
this.appendField(formData, "column_map", this.buildColumnMap(payload.columnMap ?? null));
|
|
437
|
+
this.appendField(formData, "on_conflict", payload.onConflict ?? null);
|
|
438
|
+
this.appendField(formData, "on_error", payload.onError ?? null);
|
|
439
|
+
this.appendField(formData, "segments", payload.segments ?? null);
|
|
440
|
+
this.appendField(formData, "topics", payload.topics ?? null);
|
|
441
|
+
return formData;
|
|
442
|
+
}
|
|
443
|
+
buildColumnMap(columnMap) {
|
|
444
|
+
if (columnMap === null) return null;
|
|
445
|
+
return {
|
|
446
|
+
email: columnMap.email,
|
|
447
|
+
first_name: columnMap.firstName,
|
|
448
|
+
last_name: columnMap.lastName,
|
|
449
|
+
unsubscribed: columnMap.unsubscribed,
|
|
450
|
+
properties: columnMap.properties
|
|
451
|
+
};
|
|
452
|
+
}
|
|
453
|
+
appendField(formData, name, value) {
|
|
454
|
+
if (value === null) return;
|
|
455
|
+
formData.append(name, typeof value === "string" ? value : JSON.stringify(value));
|
|
456
|
+
}
|
|
457
|
+
};
|
|
458
|
+
//#endregion
|
|
414
459
|
//#region src/contacts/segments/contact-segments.ts
|
|
415
460
|
var ContactSegments = class {
|
|
416
461
|
constructor(resend) {
|
|
@@ -498,6 +543,7 @@ var ContactTopics = class {
|
|
|
498
543
|
var Contacts = class {
|
|
499
544
|
constructor(resend) {
|
|
500
545
|
this.resend = resend;
|
|
546
|
+
this.imports = new ContactImports(this.resend);
|
|
501
547
|
this.topics = new ContactTopics(this.resend);
|
|
502
548
|
this.segments = new ContactSegments(this.resend);
|
|
503
549
|
}
|
|
@@ -803,8 +849,9 @@ var Emails = class {
|
|
|
803
849
|
return this.create(payload, options);
|
|
804
850
|
}
|
|
805
851
|
async create(payload, options = {}) {
|
|
806
|
-
|
|
807
|
-
|
|
852
|
+
const body = { ...payload };
|
|
853
|
+
if (payload.react) body.html = await render(payload.react);
|
|
854
|
+
return await this.resend.post("/emails", parseEmailToApiOptions(body), options);
|
|
808
855
|
}
|
|
809
856
|
async get(id) {
|
|
810
857
|
return await this.resend.get(`/emails/${id}`);
|
|
@@ -944,16 +991,9 @@ var Templates = class {
|
|
|
944
991
|
return new ChainableTemplateResult(this.performCreate(payload), this.publish.bind(this));
|
|
945
992
|
}
|
|
946
993
|
async performCreate(payload) {
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
this.renderAsync = renderAsync;
|
|
951
|
-
} catch {
|
|
952
|
-
throw new Error("Failed to render React component. Make sure to install `@react-email/render`");
|
|
953
|
-
}
|
|
954
|
-
payload.html = await this.renderAsync(payload.react);
|
|
955
|
-
}
|
|
956
|
-
return this.resend.post("/templates", parseTemplateToApiOptions(payload));
|
|
994
|
+
const body = { ...payload };
|
|
995
|
+
if (payload.react) body.html = await render(payload.react);
|
|
996
|
+
return this.resend.post("/templates", parseTemplateToApiOptions(body));
|
|
957
997
|
}
|
|
958
998
|
async remove(identifier) {
|
|
959
999
|
return await this.resend.delete(`/templates/${identifier}`);
|
|
@@ -1051,10 +1091,10 @@ var Webhooks = class {
|
|
|
1051
1091
|
return await this.resend.delete(`/webhooks/${id}`);
|
|
1052
1092
|
}
|
|
1053
1093
|
verify(payload) {
|
|
1054
|
-
return new
|
|
1055
|
-
"
|
|
1056
|
-
"
|
|
1057
|
-
"
|
|
1094
|
+
return new standardwebhooks.Webhook(payload.webhookSecret).verify(payload.payload, {
|
|
1095
|
+
"webhook-id": payload.headers.id,
|
|
1096
|
+
"webhook-timestamp": payload.headers.timestamp,
|
|
1097
|
+
"webhook-signature": payload.headers.signature
|
|
1058
1098
|
});
|
|
1059
1099
|
}
|
|
1060
1100
|
};
|
|
@@ -1062,10 +1102,14 @@ var Webhooks = class {
|
|
|
1062
1102
|
//#region src/resend.ts
|
|
1063
1103
|
const defaultBaseUrl = "https://api.resend.com";
|
|
1064
1104
|
const defaultUserAgent = `resend-node:${version}`;
|
|
1065
|
-
|
|
1066
|
-
|
|
1105
|
+
function getDefaultBaseUrl() {
|
|
1106
|
+
return typeof process !== "undefined" && process.env ? process.env.RESEND_BASE_URL || defaultBaseUrl : defaultBaseUrl;
|
|
1107
|
+
}
|
|
1108
|
+
function getDefaultUserAgent() {
|
|
1109
|
+
return typeof process !== "undefined" && process.env ? process.env.RESEND_USER_AGENT || defaultUserAgent : defaultUserAgent;
|
|
1110
|
+
}
|
|
1067
1111
|
var Resend = class {
|
|
1068
|
-
constructor(key) {
|
|
1112
|
+
constructor(key, options) {
|
|
1069
1113
|
this.key = key;
|
|
1070
1114
|
this.segments = new Segments(this);
|
|
1071
1115
|
this.apiKeys = new ApiKeys(this);
|
|
@@ -1086,15 +1130,17 @@ var Resend = class {
|
|
|
1086
1130
|
if (typeof process !== "undefined" && process.env) this.key = process.env.RESEND_API_KEY;
|
|
1087
1131
|
if (!this.key) throw new Error("Missing API key. Pass it to the constructor `new Resend(\"re_123\")`");
|
|
1088
1132
|
}
|
|
1133
|
+
this.baseUrl = options?.baseUrl ?? getDefaultBaseUrl();
|
|
1134
|
+
this.userAgent = options?.userAgent ?? getDefaultUserAgent();
|
|
1089
1135
|
this.headers = new Headers({
|
|
1090
1136
|
Authorization: `Bearer ${this.key}`,
|
|
1091
|
-
"User-Agent": userAgent,
|
|
1137
|
+
"User-Agent": this.userAgent,
|
|
1092
1138
|
"Content-Type": "application/json"
|
|
1093
1139
|
});
|
|
1094
1140
|
}
|
|
1095
1141
|
async fetchRequest(path, options = {}) {
|
|
1096
1142
|
try {
|
|
1097
|
-
const response = await fetch(`${baseUrl}${path}`, options);
|
|
1143
|
+
const response = await fetch(`${this.baseUrl}${path}`, options);
|
|
1098
1144
|
if (!response.ok) try {
|
|
1099
1145
|
const rawError = await response.text();
|
|
1100
1146
|
return {
|
|
@@ -1150,11 +1196,13 @@ var Resend = class {
|
|
|
1150
1196
|
}
|
|
1151
1197
|
async post(path, entity, options = {}) {
|
|
1152
1198
|
const headers = new Headers(this.headers);
|
|
1199
|
+
const isFormData = typeof FormData !== "undefined" && entity instanceof FormData;
|
|
1200
|
+
if (isFormData) headers.delete("Content-Type");
|
|
1153
1201
|
if (options.headers) for (const [key, value] of new Headers(options.headers).entries()) headers.set(key, value);
|
|
1154
1202
|
if (options.idempotencyKey) headers.set("Idempotency-Key", options.idempotencyKey);
|
|
1155
1203
|
const requestOptions = {
|
|
1156
1204
|
method: "POST",
|
|
1157
|
-
body: JSON.stringify(entity),
|
|
1205
|
+
body: isFormData ? entity : JSON.stringify(entity),
|
|
1158
1206
|
...options,
|
|
1159
1207
|
headers
|
|
1160
1208
|
};
|
|
@@ -1192,11 +1240,14 @@ var Resend = class {
|
|
|
1192
1240
|
};
|
|
1193
1241
|
return this.fetchRequest(path, requestOptions);
|
|
1194
1242
|
}
|
|
1195
|
-
async delete(path, query) {
|
|
1243
|
+
async delete(path, query, options = {}) {
|
|
1244
|
+
const headers = new Headers(this.headers);
|
|
1245
|
+
if (options.headers) for (const [key, value] of new Headers(options.headers).entries()) headers.set(key, value);
|
|
1196
1246
|
const requestOptions = {
|
|
1197
1247
|
method: "DELETE",
|
|
1198
|
-
body: JSON.stringify(query),
|
|
1199
|
-
|
|
1248
|
+
body: query === void 0 ? void 0 : JSON.stringify(query),
|
|
1249
|
+
...options,
|
|
1250
|
+
headers
|
|
1200
1251
|
};
|
|
1201
1252
|
return this.fetchRequest(path, requestOptions);
|
|
1202
1253
|
}
|
package/dist/index.d.cts
CHANGED
|
@@ -30,6 +30,11 @@ interface AttachmentData {
|
|
|
30
30
|
expires_at: string;
|
|
31
31
|
}
|
|
32
32
|
//#endregion
|
|
33
|
+
//#region src/common/interfaces/delete-option.interface.d.ts
|
|
34
|
+
interface DeleteOptions {
|
|
35
|
+
headers?: HeadersInit;
|
|
36
|
+
}
|
|
37
|
+
//#endregion
|
|
33
38
|
//#region src/domains/interfaces/domain.d.ts
|
|
34
39
|
type DomainRegion = 'us-east-1' | 'eu-west-1' | 'sa-east-1' | 'ap-northeast-1';
|
|
35
40
|
type DomainCapabilityStatus = 'enabled' | 'disabled';
|
|
@@ -941,6 +946,72 @@ type UpdateContactPropertyResponseSuccess = Pick<ContactProperty, 'id'> & {
|
|
|
941
946
|
};
|
|
942
947
|
type UpdateContactPropertyResponse = Response<UpdateContactPropertyResponseSuccess>;
|
|
943
948
|
//#endregion
|
|
949
|
+
//#region src/contacts/imports/interfaces/contact-import.interface.d.ts
|
|
950
|
+
type ContactImportStatus = 'queued' | 'in_progress' | 'completed' | 'failed';
|
|
951
|
+
interface ContactImportCounts {
|
|
952
|
+
total: number;
|
|
953
|
+
created: number;
|
|
954
|
+
updated: number;
|
|
955
|
+
skipped: number;
|
|
956
|
+
failed: number;
|
|
957
|
+
}
|
|
958
|
+
interface ContactImport {
|
|
959
|
+
object: 'contact_import';
|
|
960
|
+
id: string;
|
|
961
|
+
status: ContactImportStatus;
|
|
962
|
+
created_at: string;
|
|
963
|
+
completed_at: string | null;
|
|
964
|
+
counts: ContactImportCounts;
|
|
965
|
+
}
|
|
966
|
+
//#endregion
|
|
967
|
+
//#region src/contacts/imports/interfaces/create-contact-import.interface.d.ts
|
|
968
|
+
type ContactImportOnConflict = 'upsert' | 'skip';
|
|
969
|
+
type ContactImportOnError = 'continue' | 'abort';
|
|
970
|
+
type ContactImportPropertyType = 'string' | 'number' | 'boolean';
|
|
971
|
+
interface ContactImportPropertyMapping {
|
|
972
|
+
column: string;
|
|
973
|
+
type?: ContactImportPropertyType;
|
|
974
|
+
}
|
|
975
|
+
interface ContactImportColumnMap {
|
|
976
|
+
email?: string;
|
|
977
|
+
firstName?: string;
|
|
978
|
+
lastName?: string;
|
|
979
|
+
unsubscribed?: string;
|
|
980
|
+
properties?: Record<string, ContactImportPropertyMapping>;
|
|
981
|
+
}
|
|
982
|
+
interface ContactImportSegment {
|
|
983
|
+
id: string;
|
|
984
|
+
}
|
|
985
|
+
interface ContactImportTopic {
|
|
986
|
+
id: string;
|
|
987
|
+
subscription: 'opt_in' | 'opt_out';
|
|
988
|
+
}
|
|
989
|
+
interface CreateContactImportOptions {
|
|
990
|
+
file: Blob;
|
|
991
|
+
columnMap?: ContactImportColumnMap;
|
|
992
|
+
onConflict?: ContactImportOnConflict;
|
|
993
|
+
onError?: ContactImportOnError;
|
|
994
|
+
segments?: ContactImportSegment[];
|
|
995
|
+
topics?: ContactImportTopic[];
|
|
996
|
+
}
|
|
997
|
+
interface CreateContactImportRequestOptions extends PostOptions {}
|
|
998
|
+
interface CreateContactImportResponseSuccess {
|
|
999
|
+
object: 'contact_import';
|
|
1000
|
+
id: string;
|
|
1001
|
+
}
|
|
1002
|
+
type CreateContactImportResponse = Response<CreateContactImportResponseSuccess>;
|
|
1003
|
+
//#endregion
|
|
1004
|
+
//#region src/contacts/imports/interfaces/get-contact-import.interface.d.ts
|
|
1005
|
+
type GetContactImportResponseSuccess = ContactImport;
|
|
1006
|
+
type GetContactImportResponse = Response<GetContactImportResponseSuccess>;
|
|
1007
|
+
//#endregion
|
|
1008
|
+
//#region src/contacts/imports/interfaces/list-contact-imports.interface.d.ts
|
|
1009
|
+
type ListContactImportsOptions = PaginationOptions & {
|
|
1010
|
+
status?: ContactImportStatus;
|
|
1011
|
+
};
|
|
1012
|
+
type ListContactImportsResponseSuccess = PaginatedData<ContactImport[]>;
|
|
1013
|
+
type ListContactImportsResponse = Response<ListContactImportsResponseSuccess>;
|
|
1014
|
+
//#endregion
|
|
944
1015
|
//#region src/contacts/interfaces/contact.d.ts
|
|
945
1016
|
interface Contact {
|
|
946
1017
|
created_at: string;
|
|
@@ -1524,6 +1595,18 @@ declare class ContactProperties {
|
|
|
1524
1595
|
remove(id: string): Promise<RemoveContactPropertyResponse>;
|
|
1525
1596
|
}
|
|
1526
1597
|
//#endregion
|
|
1598
|
+
//#region src/contacts/imports/contact-imports.d.ts
|
|
1599
|
+
declare class ContactImports {
|
|
1600
|
+
private readonly resend;
|
|
1601
|
+
constructor(resend: Resend);
|
|
1602
|
+
create(payload: CreateContactImportOptions, options?: CreateContactImportRequestOptions): Promise<CreateContactImportResponse>;
|
|
1603
|
+
list(options?: ListContactImportsOptions): Promise<ListContactImportsResponse>;
|
|
1604
|
+
get(id: string): Promise<GetContactImportResponse>;
|
|
1605
|
+
private buildCreateFormData;
|
|
1606
|
+
private buildColumnMap;
|
|
1607
|
+
private appendField;
|
|
1608
|
+
}
|
|
1609
|
+
//#endregion
|
|
1527
1610
|
//#region src/contacts/segments/contact-segments.d.ts
|
|
1528
1611
|
declare class ContactSegments {
|
|
1529
1612
|
private readonly resend;
|
|
@@ -1544,6 +1627,7 @@ declare class ContactTopics {
|
|
|
1544
1627
|
//#region src/contacts/contacts.d.ts
|
|
1545
1628
|
declare class Contacts {
|
|
1546
1629
|
private readonly resend;
|
|
1630
|
+
readonly imports: ContactImports;
|
|
1547
1631
|
readonly topics: ContactTopics;
|
|
1548
1632
|
readonly segments: ContactSegments;
|
|
1549
1633
|
constructor(resend: Resend);
|
|
@@ -1785,7 +1869,6 @@ type UpdateTemplateResponse = Response<UpdateTemplateResponseSuccess>;
|
|
|
1785
1869
|
//#region src/templates/templates.d.ts
|
|
1786
1870
|
declare class Templates {
|
|
1787
1871
|
private readonly resend;
|
|
1788
|
-
private renderAsync?;
|
|
1789
1872
|
constructor(resend: Resend);
|
|
1790
1873
|
create(payload: CreateTemplateOptions): ChainableTemplateResult<CreateTemplateResponse>;
|
|
1791
1874
|
private performCreate;
|
|
@@ -1815,7 +1898,7 @@ interface CreateTopicOptions {
|
|
|
1815
1898
|
type CreateTopicResponseSuccess = Pick<Topic, 'id'>;
|
|
1816
1899
|
type CreateTopicResponse = Response<CreateTopicResponseSuccess>;
|
|
1817
1900
|
//#endregion
|
|
1818
|
-
//#region src/topics/interfaces/get-
|
|
1901
|
+
//#region src/topics/interfaces/get-topic.interface.d.ts
|
|
1819
1902
|
interface GetTopicOptions {
|
|
1820
1903
|
id: string;
|
|
1821
1904
|
}
|
|
@@ -2109,8 +2192,14 @@ declare class Webhooks {
|
|
|
2109
2192
|
}
|
|
2110
2193
|
//#endregion
|
|
2111
2194
|
//#region src/resend.d.ts
|
|
2195
|
+
interface ResendOptions {
|
|
2196
|
+
baseUrl?: string;
|
|
2197
|
+
userAgent?: string;
|
|
2198
|
+
}
|
|
2112
2199
|
declare class Resend {
|
|
2113
2200
|
readonly key?: string | undefined;
|
|
2201
|
+
readonly baseUrl: string;
|
|
2202
|
+
readonly userAgent: string;
|
|
2114
2203
|
private readonly headers;
|
|
2115
2204
|
readonly segments: Segments;
|
|
2116
2205
|
readonly apiKeys: ApiKeys;
|
|
@@ -2130,13 +2219,13 @@ declare class Resend {
|
|
|
2130
2219
|
readonly templates: Templates;
|
|
2131
2220
|
readonly topics: Topics;
|
|
2132
2221
|
readonly webhooks: Webhooks;
|
|
2133
|
-
constructor(key?: string | undefined);
|
|
2222
|
+
constructor(key?: string | undefined, options?: ResendOptions);
|
|
2134
2223
|
fetchRequest<T>(path: string, options?: {}): Promise<Response<T>>;
|
|
2135
2224
|
post<T>(path: string, entity?: unknown, options?: PostOptions & IdempotentRequest): Promise<Response<T>>;
|
|
2136
2225
|
get<T>(path: string, options?: GetOptions): Promise<Response<T>>;
|
|
2137
2226
|
put<T>(path: string, entity: unknown, options?: PutOptions): Promise<Response<T>>;
|
|
2138
2227
|
patch<T>(path: string, entity: unknown, options?: PatchOptions): Promise<Response<T>>;
|
|
2139
|
-
delete<T>(path: string, query?: unknown): Promise<Response<T>>;
|
|
2228
|
+
delete<T>(path: string, query?: unknown, options?: DeleteOptions): Promise<Response<T>>;
|
|
2140
2229
|
}
|
|
2141
2230
|
//#endregion
|
|
2142
|
-
export { AddContactSegmentOptions, AddContactSegmentResponse, AddContactSegmentResponseSuccess, AddToSegmentStepConfig, ApiContactProperty, ApiKey, Attachment, AttachmentData, Automation, AutomationConnection, AutomationConnectionType, AutomationResponseConnection, AutomationResponseStep, AutomationRun, AutomationRunItem, AutomationRunStatus, AutomationRunStep, AutomationRunStepStatus, AutomationStatus, AutomationStep, AutomationStepType, Broadcast, CancelEmailResponse, CancelEmailResponseSuccess, ConditionRule, ConditionStepConfig, Contact, ContactCreatedEvent, ContactDeleteStepConfig, ContactDeletedEvent, ContactProperty, ContactSegmentsBaseOptions, ContactTopic, ContactUpdateStepConfig, ContactUpdatedEvent, CreateApiKeyOptions, CreateApiKeyRequestOptions, CreateApiKeyResponse, CreateApiKeyResponseSuccess, CreateAutomationOptions, CreateAutomationResponse, CreateAutomationResponseSuccess, CreateBatchEmailOptions, CreateBatchOptions, CreateBatchRequestOptions, CreateBatchResponse, CreateBatchSuccessResponse, CreateBroadcastOptions, CreateBroadcastRequestOptions, CreateBroadcastResponse, CreateBroadcastResponseSuccess, CreateContactOptions, CreateContactPropertyApiOptions, CreateContactPropertyOptions, CreateContactPropertyResponse, CreateContactPropertyResponseSuccess, CreateContactRequestOptions, CreateContactResponse, CreateContactResponseSuccess, CreateDomainOptions, CreateDomainRequestOptions, CreateDomainResponse, CreateDomainResponseSuccess, CreateEmailOptions, CreateEmailRequestOptions, CreateEmailResponse, CreateEmailResponseSuccess, CreateEventOptions, CreateEventResponse, CreateEventResponseSuccess, CreateSegmentOptions, CreateSegmentRequestOptions, CreateSegmentResponse, CreateSegmentResponseSuccess, CreateTemplateOptions, CreateTemplateRequestOptions, CreateTemplateResponse, CreateTemplateResponseSuccess, CreateTopicOptions, CreateTopicResponse, CreateTopicResponseSuccess, CreateWebhookOptions, CreateWebhookRequestOptions, CreateWebhookResponse, CreateWebhookResponseSuccess, DelayStepConfig, Domain, DomainApiOptions, DomainCapabilities, DomainCapabilityStatus, DomainCreatedEvent, DomainDeletedEvent, DomainDkimRecord, DomainNameservers, DomainRecordStatus, DomainRecords, DomainRegion, DomainSpfRecord, DomainStatus, DomainUpdatedEvent, DuplicateTemplateResponse, DuplicateTemplateResponseSuccess, EmailApiAttachment, EmailApiOptions, EmailBouncedEvent, EmailClickedEvent, EmailComplainedEvent, EmailDeliveredEvent, EmailDeliveryDelayedEvent, EmailFailedEvent, EmailOpenedEvent, EmailReceivedEvent, EmailScheduledEvent, EmailSentEvent, EmailSuppressedEvent, type ErrorResponse, Event, EventSchemaMap, EventSchemaType, ForwardReceivingEmailOptions, ForwardReceivingEmailResponse, ForwardReceivingEmailResponseSuccess, GetAttachmentOptions, GetAttachmentResponse, GetAttachmentResponseSuccess, GetAutomationResponse, GetAutomationResponseSuccess, GetAutomationRunOptions, GetAutomationRunResponse, GetAutomationRunResponseSuccess, GetBroadcastResponse, GetBroadcastResponseSuccess, GetContactOptions, GetContactPropertyResponse, GetContactPropertyResponseSuccess, GetContactResponse, GetContactResponseSuccess, GetDomainResponse, GetDomainResponseSuccess, GetEmailResponse, GetEmailResponseSuccess, GetEventResponse, GetEventResponseSuccess, GetLogResponse, GetLogResponseSuccess, GetOptions, GetReceivingEmailResponse, GetReceivingEmailResponseSuccess, GetSegmentResponse, GetSegmentResponseSuccess, GetTemplateResponse, GetTemplateResponseSuccess, GetTopicOptions, GetTopicResponse, GetTopicResponseSuccess, GetWebhookResponse, GetWebhookResponseSuccess, IdempotentRequest, InboundAttachment, LegacyCreateContactOptions, ListApiKeysOptions, ListApiKeysResponse, ListApiKeysResponseSuccess, ListAttachmentsOptions, ListAttachmentsResponse, ListAttachmentsResponseSuccess, ListAutomationRunsOptions, ListAutomationRunsResponse, ListAutomationRunsResponseSuccess, ListAutomationsOptions, ListAutomationsResponse, ListAutomationsResponseSuccess, ListBroadcastsOptions, ListBroadcastsResponse, ListBroadcastsResponseSuccess, ListContactPropertiesOptions, ListContactPropertiesResponse, ListContactPropertiesResponseSuccess, ListContactSegmentsOptions, ListContactSegmentsResponse, ListContactSegmentsResponseSuccess, ListContactTopicsOptions, ListContactTopicsRequestOptions, ListContactTopicsResponse, ListContactTopicsResponseSuccess, ListContactsOptions, ListContactsResponse, ListContactsResponseSuccess, ListDomainsOptions, ListDomainsResponse, ListDomainsResponseSuccess, ListEmail, ListEmailsOptions, ListEmailsResponse, ListEmailsResponseSuccess, ListEventsOptions, ListEventsResponse, ListEventsResponseSuccess, ListLogsOptions, ListLogsResponse, ListLogsResponseSuccess, ListReceivingEmail, ListReceivingEmailsOptions, ListReceivingEmailsResponse, ListReceivingEmailsResponseSuccess, ListSegmentsOptions, ListSegmentsResponse, ListSegmentsResponseSuccess, ListTemplatesOptions, ListTemplatesResponse, ListTemplatesResponseSuccess, ListTopicsResponse, ListTopicsResponseSuccess, ListWebhooksOptions, ListWebhooksResponse, ListWebhooksResponseSuccess, Log, PaginatedData, PaginationOptions, PatchOptions, PostOptions, PublishTemplateResponse, PublishTemplateResponseSuccess, PutOptions, ReceivingRecord, RemoveApiKeyResponse, RemoveApiKeyResponseSuccess, RemoveAutomationResponse, RemoveAutomationResponseSuccess, RemoveBroadcastResponse, RemoveBroadcastResponseSuccess, RemoveContactOptions, RemoveContactPropertyResponse, RemoveContactPropertyResponseSuccess, RemoveContactSegmentOptions, RemoveContactSegmentResponse, RemoveContactSegmentResponseSuccess, RemoveContactsResponse, RemoveContactsResponseSuccess, RemoveDomainsResponse, RemoveDomainsResponseSuccess, RemoveEventResponse, RemoveEventResponseSuccess, RemoveSegmentResponse, RemoveSegmentResponseSuccess, RemoveTemplateResponse, RemoveTemplateResponseSuccess, RemoveTopicResponse, RemoveTopicResponseSuccess, RemoveWebhookResponse, RemoveWebhookResponseSuccess, RequireAtLeastOne, Resend, type Response, Segment, SelectingField, SendBroadcastOptions, SendBroadcastRequestOptions, SendBroadcastResponse, SendBroadcastResponseSuccess, SendEmailStepConfig, SendEventOptions, SendEventResponse, SendEventResponseSuccess, StopAutomationResponse, StopAutomationResponseSuccess, Tag, Template, TemplateVariable, TemplateVariableValue, Topic, TrackingCaaRecord, TrackingRecord, TriggerStepConfig, UpdateAutomationOptions, UpdateAutomationResponse, UpdateAutomationResponseSuccess, UpdateBroadcastOptions, UpdateBroadcastResponse, UpdateBroadcastResponseSuccess, UpdateContactOptions, UpdateContactPropertyApiOptions, UpdateContactPropertyOptions, UpdateContactPropertyResponse, UpdateContactPropertyResponseSuccess, UpdateContactResponse, UpdateContactResponseSuccess, UpdateContactTopicsOptions, UpdateContactTopicsRequestOptions, UpdateContactTopicsResponse, UpdateContactTopicsResponseSuccess, UpdateDomainsOptions, UpdateDomainsResponse, UpdateDomainsResponseSuccess, UpdateEmailOptions, UpdateEmailResponse, UpdateEmailResponseSuccess, UpdateEventOptions, UpdateEventResponse, UpdateEventResponseSuccess, UpdateTemplateOptions, UpdateTemplateResponse, UpdateTemplateResponseSuccess, UpdateTopicOptions, UpdateTopicResponse, UpdateTopicResponseSuccess, UpdateWebhookOptions, UpdateWebhookResponse, UpdateWebhookResponseSuccess, VerifyDomainsResponse, VerifyDomainsResponseSuccess, WaitForEventStepConfig, Webhook, WebhookEvent, WebhookEventPayload };
|
|
2231
|
+
export { AddContactSegmentOptions, AddContactSegmentResponse, AddContactSegmentResponseSuccess, AddToSegmentStepConfig, ApiContactProperty, ApiKey, Attachment, AttachmentData, Automation, AutomationConnection, AutomationConnectionType, AutomationResponseConnection, AutomationResponseStep, AutomationRun, AutomationRunItem, AutomationRunStatus, AutomationRunStep, AutomationRunStepStatus, AutomationStatus, AutomationStep, AutomationStepType, Broadcast, CancelEmailResponse, CancelEmailResponseSuccess, ConditionRule, ConditionStepConfig, Contact, ContactCreatedEvent, ContactDeleteStepConfig, ContactDeletedEvent, ContactImport, ContactImportColumnMap, ContactImportCounts, ContactImportOnConflict, ContactImportOnError, ContactImportPropertyMapping, ContactImportPropertyType, ContactImportSegment, ContactImportStatus, ContactImportTopic, ContactProperty, ContactSegmentsBaseOptions, ContactTopic, ContactUpdateStepConfig, ContactUpdatedEvent, CreateApiKeyOptions, CreateApiKeyRequestOptions, CreateApiKeyResponse, CreateApiKeyResponseSuccess, CreateAutomationOptions, CreateAutomationResponse, CreateAutomationResponseSuccess, CreateBatchEmailOptions, CreateBatchOptions, CreateBatchRequestOptions, CreateBatchResponse, CreateBatchSuccessResponse, CreateBroadcastOptions, CreateBroadcastRequestOptions, CreateBroadcastResponse, CreateBroadcastResponseSuccess, CreateContactImportOptions, CreateContactImportRequestOptions, CreateContactImportResponse, CreateContactImportResponseSuccess, CreateContactOptions, CreateContactPropertyApiOptions, CreateContactPropertyOptions, CreateContactPropertyResponse, CreateContactPropertyResponseSuccess, CreateContactRequestOptions, CreateContactResponse, CreateContactResponseSuccess, CreateDomainOptions, CreateDomainRequestOptions, CreateDomainResponse, CreateDomainResponseSuccess, CreateEmailOptions, CreateEmailRequestOptions, CreateEmailResponse, CreateEmailResponseSuccess, CreateEventOptions, CreateEventResponse, CreateEventResponseSuccess, CreateSegmentOptions, CreateSegmentRequestOptions, CreateSegmentResponse, CreateSegmentResponseSuccess, CreateTemplateOptions, CreateTemplateRequestOptions, CreateTemplateResponse, CreateTemplateResponseSuccess, CreateTopicOptions, CreateTopicResponse, CreateTopicResponseSuccess, CreateWebhookOptions, CreateWebhookRequestOptions, CreateWebhookResponse, CreateWebhookResponseSuccess, DelayStepConfig, DeleteOptions, Domain, DomainApiOptions, DomainCapabilities, DomainCapabilityStatus, DomainCreatedEvent, DomainDeletedEvent, DomainDkimRecord, DomainNameservers, DomainRecordStatus, DomainRecords, DomainRegion, DomainSpfRecord, DomainStatus, DomainUpdatedEvent, DuplicateTemplateResponse, DuplicateTemplateResponseSuccess, EmailApiAttachment, EmailApiOptions, EmailBouncedEvent, EmailClickedEvent, EmailComplainedEvent, EmailDeliveredEvent, EmailDeliveryDelayedEvent, EmailFailedEvent, EmailOpenedEvent, EmailReceivedEvent, EmailScheduledEvent, EmailSentEvent, EmailSuppressedEvent, type ErrorResponse, Event, EventSchemaMap, EventSchemaType, ForwardReceivingEmailOptions, ForwardReceivingEmailResponse, ForwardReceivingEmailResponseSuccess, GetAttachmentOptions, GetAttachmentResponse, GetAttachmentResponseSuccess, GetAutomationResponse, GetAutomationResponseSuccess, GetAutomationRunOptions, GetAutomationRunResponse, GetAutomationRunResponseSuccess, GetBroadcastResponse, GetBroadcastResponseSuccess, GetContactImportResponse, GetContactImportResponseSuccess, GetContactOptions, GetContactPropertyResponse, GetContactPropertyResponseSuccess, GetContactResponse, GetContactResponseSuccess, GetDomainResponse, GetDomainResponseSuccess, GetEmailResponse, GetEmailResponseSuccess, GetEventResponse, GetEventResponseSuccess, GetLogResponse, GetLogResponseSuccess, GetOptions, GetReceivingEmailResponse, GetReceivingEmailResponseSuccess, GetSegmentResponse, GetSegmentResponseSuccess, GetTemplateResponse, GetTemplateResponseSuccess, GetTopicOptions, GetTopicResponse, GetTopicResponseSuccess, GetWebhookResponse, GetWebhookResponseSuccess, IdempotentRequest, InboundAttachment, LegacyCreateContactOptions, ListApiKeysOptions, ListApiKeysResponse, ListApiKeysResponseSuccess, ListAttachmentsOptions, ListAttachmentsResponse, ListAttachmentsResponseSuccess, ListAutomationRunsOptions, ListAutomationRunsResponse, ListAutomationRunsResponseSuccess, ListAutomationsOptions, ListAutomationsResponse, ListAutomationsResponseSuccess, ListBroadcastsOptions, ListBroadcastsResponse, ListBroadcastsResponseSuccess, ListContactImportsOptions, ListContactImportsResponse, ListContactImportsResponseSuccess, ListContactPropertiesOptions, ListContactPropertiesResponse, ListContactPropertiesResponseSuccess, ListContactSegmentsOptions, ListContactSegmentsResponse, ListContactSegmentsResponseSuccess, ListContactTopicsOptions, ListContactTopicsRequestOptions, ListContactTopicsResponse, ListContactTopicsResponseSuccess, ListContactsOptions, ListContactsResponse, ListContactsResponseSuccess, ListDomainsOptions, ListDomainsResponse, ListDomainsResponseSuccess, ListEmail, ListEmailsOptions, ListEmailsResponse, ListEmailsResponseSuccess, ListEventsOptions, ListEventsResponse, ListEventsResponseSuccess, ListLogsOptions, ListLogsResponse, ListLogsResponseSuccess, ListReceivingEmail, ListReceivingEmailsOptions, ListReceivingEmailsResponse, ListReceivingEmailsResponseSuccess, ListSegmentsOptions, ListSegmentsResponse, ListSegmentsResponseSuccess, ListTemplatesOptions, ListTemplatesResponse, ListTemplatesResponseSuccess, ListTopicsResponse, ListTopicsResponseSuccess, ListWebhooksOptions, ListWebhooksResponse, ListWebhooksResponseSuccess, Log, PaginatedData, PaginationOptions, PatchOptions, PostOptions, PublishTemplateResponse, PublishTemplateResponseSuccess, PutOptions, ReceivingRecord, RemoveApiKeyResponse, RemoveApiKeyResponseSuccess, RemoveAutomationResponse, RemoveAutomationResponseSuccess, RemoveBroadcastResponse, RemoveBroadcastResponseSuccess, RemoveContactOptions, RemoveContactPropertyResponse, RemoveContactPropertyResponseSuccess, RemoveContactSegmentOptions, RemoveContactSegmentResponse, RemoveContactSegmentResponseSuccess, RemoveContactsResponse, RemoveContactsResponseSuccess, RemoveDomainsResponse, RemoveDomainsResponseSuccess, RemoveEventResponse, RemoveEventResponseSuccess, RemoveSegmentResponse, RemoveSegmentResponseSuccess, RemoveTemplateResponse, RemoveTemplateResponseSuccess, RemoveTopicResponse, RemoveTopicResponseSuccess, RemoveWebhookResponse, RemoveWebhookResponseSuccess, RequireAtLeastOne, Resend, type ResendOptions, type Response, Segment, SelectingField, SendBroadcastOptions, SendBroadcastRequestOptions, SendBroadcastResponse, SendBroadcastResponseSuccess, SendEmailStepConfig, SendEventOptions, SendEventResponse, SendEventResponseSuccess, StopAutomationResponse, StopAutomationResponseSuccess, Tag, Template, TemplateVariable, TemplateVariableValue, Topic, TrackingCaaRecord, TrackingRecord, TriggerStepConfig, UpdateAutomationOptions, UpdateAutomationResponse, UpdateAutomationResponseSuccess, UpdateBroadcastOptions, UpdateBroadcastResponse, UpdateBroadcastResponseSuccess, UpdateContactOptions, UpdateContactPropertyApiOptions, UpdateContactPropertyOptions, UpdateContactPropertyResponse, UpdateContactPropertyResponseSuccess, UpdateContactResponse, UpdateContactResponseSuccess, UpdateContactTopicsOptions, UpdateContactTopicsRequestOptions, UpdateContactTopicsResponse, UpdateContactTopicsResponseSuccess, UpdateDomainsOptions, UpdateDomainsResponse, UpdateDomainsResponseSuccess, UpdateEmailOptions, UpdateEmailResponse, UpdateEmailResponseSuccess, UpdateEventOptions, UpdateEventResponse, UpdateEventResponseSuccess, UpdateTemplateOptions, UpdateTemplateResponse, UpdateTemplateResponseSuccess, UpdateTopicOptions, UpdateTopicResponse, UpdateTopicResponseSuccess, UpdateWebhookOptions, UpdateWebhookResponse, UpdateWebhookResponseSuccess, VerifyDomainsResponse, VerifyDomainsResponseSuccess, WaitForEventStepConfig, Webhook, WebhookEvent, WebhookEventPayload };
|
package/dist/index.d.mts
CHANGED
|
@@ -30,6 +30,11 @@ interface AttachmentData {
|
|
|
30
30
|
expires_at: string;
|
|
31
31
|
}
|
|
32
32
|
//#endregion
|
|
33
|
+
//#region src/common/interfaces/delete-option.interface.d.ts
|
|
34
|
+
interface DeleteOptions {
|
|
35
|
+
headers?: HeadersInit;
|
|
36
|
+
}
|
|
37
|
+
//#endregion
|
|
33
38
|
//#region src/domains/interfaces/domain.d.ts
|
|
34
39
|
type DomainRegion = 'us-east-1' | 'eu-west-1' | 'sa-east-1' | 'ap-northeast-1';
|
|
35
40
|
type DomainCapabilityStatus = 'enabled' | 'disabled';
|
|
@@ -941,6 +946,72 @@ type UpdateContactPropertyResponseSuccess = Pick<ContactProperty, 'id'> & {
|
|
|
941
946
|
};
|
|
942
947
|
type UpdateContactPropertyResponse = Response<UpdateContactPropertyResponseSuccess>;
|
|
943
948
|
//#endregion
|
|
949
|
+
//#region src/contacts/imports/interfaces/contact-import.interface.d.ts
|
|
950
|
+
type ContactImportStatus = 'queued' | 'in_progress' | 'completed' | 'failed';
|
|
951
|
+
interface ContactImportCounts {
|
|
952
|
+
total: number;
|
|
953
|
+
created: number;
|
|
954
|
+
updated: number;
|
|
955
|
+
skipped: number;
|
|
956
|
+
failed: number;
|
|
957
|
+
}
|
|
958
|
+
interface ContactImport {
|
|
959
|
+
object: 'contact_import';
|
|
960
|
+
id: string;
|
|
961
|
+
status: ContactImportStatus;
|
|
962
|
+
created_at: string;
|
|
963
|
+
completed_at: string | null;
|
|
964
|
+
counts: ContactImportCounts;
|
|
965
|
+
}
|
|
966
|
+
//#endregion
|
|
967
|
+
//#region src/contacts/imports/interfaces/create-contact-import.interface.d.ts
|
|
968
|
+
type ContactImportOnConflict = 'upsert' | 'skip';
|
|
969
|
+
type ContactImportOnError = 'continue' | 'abort';
|
|
970
|
+
type ContactImportPropertyType = 'string' | 'number' | 'boolean';
|
|
971
|
+
interface ContactImportPropertyMapping {
|
|
972
|
+
column: string;
|
|
973
|
+
type?: ContactImportPropertyType;
|
|
974
|
+
}
|
|
975
|
+
interface ContactImportColumnMap {
|
|
976
|
+
email?: string;
|
|
977
|
+
firstName?: string;
|
|
978
|
+
lastName?: string;
|
|
979
|
+
unsubscribed?: string;
|
|
980
|
+
properties?: Record<string, ContactImportPropertyMapping>;
|
|
981
|
+
}
|
|
982
|
+
interface ContactImportSegment {
|
|
983
|
+
id: string;
|
|
984
|
+
}
|
|
985
|
+
interface ContactImportTopic {
|
|
986
|
+
id: string;
|
|
987
|
+
subscription: 'opt_in' | 'opt_out';
|
|
988
|
+
}
|
|
989
|
+
interface CreateContactImportOptions {
|
|
990
|
+
file: Blob;
|
|
991
|
+
columnMap?: ContactImportColumnMap;
|
|
992
|
+
onConflict?: ContactImportOnConflict;
|
|
993
|
+
onError?: ContactImportOnError;
|
|
994
|
+
segments?: ContactImportSegment[];
|
|
995
|
+
topics?: ContactImportTopic[];
|
|
996
|
+
}
|
|
997
|
+
interface CreateContactImportRequestOptions extends PostOptions {}
|
|
998
|
+
interface CreateContactImportResponseSuccess {
|
|
999
|
+
object: 'contact_import';
|
|
1000
|
+
id: string;
|
|
1001
|
+
}
|
|
1002
|
+
type CreateContactImportResponse = Response<CreateContactImportResponseSuccess>;
|
|
1003
|
+
//#endregion
|
|
1004
|
+
//#region src/contacts/imports/interfaces/get-contact-import.interface.d.ts
|
|
1005
|
+
type GetContactImportResponseSuccess = ContactImport;
|
|
1006
|
+
type GetContactImportResponse = Response<GetContactImportResponseSuccess>;
|
|
1007
|
+
//#endregion
|
|
1008
|
+
//#region src/contacts/imports/interfaces/list-contact-imports.interface.d.ts
|
|
1009
|
+
type ListContactImportsOptions = PaginationOptions & {
|
|
1010
|
+
status?: ContactImportStatus;
|
|
1011
|
+
};
|
|
1012
|
+
type ListContactImportsResponseSuccess = PaginatedData<ContactImport[]>;
|
|
1013
|
+
type ListContactImportsResponse = Response<ListContactImportsResponseSuccess>;
|
|
1014
|
+
//#endregion
|
|
944
1015
|
//#region src/contacts/interfaces/contact.d.ts
|
|
945
1016
|
interface Contact {
|
|
946
1017
|
created_at: string;
|
|
@@ -1524,6 +1595,18 @@ declare class ContactProperties {
|
|
|
1524
1595
|
remove(id: string): Promise<RemoveContactPropertyResponse>;
|
|
1525
1596
|
}
|
|
1526
1597
|
//#endregion
|
|
1598
|
+
//#region src/contacts/imports/contact-imports.d.ts
|
|
1599
|
+
declare class ContactImports {
|
|
1600
|
+
private readonly resend;
|
|
1601
|
+
constructor(resend: Resend);
|
|
1602
|
+
create(payload: CreateContactImportOptions, options?: CreateContactImportRequestOptions): Promise<CreateContactImportResponse>;
|
|
1603
|
+
list(options?: ListContactImportsOptions): Promise<ListContactImportsResponse>;
|
|
1604
|
+
get(id: string): Promise<GetContactImportResponse>;
|
|
1605
|
+
private buildCreateFormData;
|
|
1606
|
+
private buildColumnMap;
|
|
1607
|
+
private appendField;
|
|
1608
|
+
}
|
|
1609
|
+
//#endregion
|
|
1527
1610
|
//#region src/contacts/segments/contact-segments.d.ts
|
|
1528
1611
|
declare class ContactSegments {
|
|
1529
1612
|
private readonly resend;
|
|
@@ -1544,6 +1627,7 @@ declare class ContactTopics {
|
|
|
1544
1627
|
//#region src/contacts/contacts.d.ts
|
|
1545
1628
|
declare class Contacts {
|
|
1546
1629
|
private readonly resend;
|
|
1630
|
+
readonly imports: ContactImports;
|
|
1547
1631
|
readonly topics: ContactTopics;
|
|
1548
1632
|
readonly segments: ContactSegments;
|
|
1549
1633
|
constructor(resend: Resend);
|
|
@@ -1785,7 +1869,6 @@ type UpdateTemplateResponse = Response<UpdateTemplateResponseSuccess>;
|
|
|
1785
1869
|
//#region src/templates/templates.d.ts
|
|
1786
1870
|
declare class Templates {
|
|
1787
1871
|
private readonly resend;
|
|
1788
|
-
private renderAsync?;
|
|
1789
1872
|
constructor(resend: Resend);
|
|
1790
1873
|
create(payload: CreateTemplateOptions): ChainableTemplateResult<CreateTemplateResponse>;
|
|
1791
1874
|
private performCreate;
|
|
@@ -1815,7 +1898,7 @@ interface CreateTopicOptions {
|
|
|
1815
1898
|
type CreateTopicResponseSuccess = Pick<Topic, 'id'>;
|
|
1816
1899
|
type CreateTopicResponse = Response<CreateTopicResponseSuccess>;
|
|
1817
1900
|
//#endregion
|
|
1818
|
-
//#region src/topics/interfaces/get-
|
|
1901
|
+
//#region src/topics/interfaces/get-topic.interface.d.ts
|
|
1819
1902
|
interface GetTopicOptions {
|
|
1820
1903
|
id: string;
|
|
1821
1904
|
}
|
|
@@ -2109,8 +2192,14 @@ declare class Webhooks {
|
|
|
2109
2192
|
}
|
|
2110
2193
|
//#endregion
|
|
2111
2194
|
//#region src/resend.d.ts
|
|
2195
|
+
interface ResendOptions {
|
|
2196
|
+
baseUrl?: string;
|
|
2197
|
+
userAgent?: string;
|
|
2198
|
+
}
|
|
2112
2199
|
declare class Resend {
|
|
2113
2200
|
readonly key?: string | undefined;
|
|
2201
|
+
readonly baseUrl: string;
|
|
2202
|
+
readonly userAgent: string;
|
|
2114
2203
|
private readonly headers;
|
|
2115
2204
|
readonly segments: Segments;
|
|
2116
2205
|
readonly apiKeys: ApiKeys;
|
|
@@ -2130,13 +2219,13 @@ declare class Resend {
|
|
|
2130
2219
|
readonly templates: Templates;
|
|
2131
2220
|
readonly topics: Topics;
|
|
2132
2221
|
readonly webhooks: Webhooks;
|
|
2133
|
-
constructor(key?: string | undefined);
|
|
2222
|
+
constructor(key?: string | undefined, options?: ResendOptions);
|
|
2134
2223
|
fetchRequest<T>(path: string, options?: {}): Promise<Response<T>>;
|
|
2135
2224
|
post<T>(path: string, entity?: unknown, options?: PostOptions & IdempotentRequest): Promise<Response<T>>;
|
|
2136
2225
|
get<T>(path: string, options?: GetOptions): Promise<Response<T>>;
|
|
2137
2226
|
put<T>(path: string, entity: unknown, options?: PutOptions): Promise<Response<T>>;
|
|
2138
2227
|
patch<T>(path: string, entity: unknown, options?: PatchOptions): Promise<Response<T>>;
|
|
2139
|
-
delete<T>(path: string, query?: unknown): Promise<Response<T>>;
|
|
2228
|
+
delete<T>(path: string, query?: unknown, options?: DeleteOptions): Promise<Response<T>>;
|
|
2140
2229
|
}
|
|
2141
2230
|
//#endregion
|
|
2142
|
-
export { AddContactSegmentOptions, AddContactSegmentResponse, AddContactSegmentResponseSuccess, AddToSegmentStepConfig, ApiContactProperty, ApiKey, Attachment, AttachmentData, Automation, AutomationConnection, AutomationConnectionType, AutomationResponseConnection, AutomationResponseStep, AutomationRun, AutomationRunItem, AutomationRunStatus, AutomationRunStep, AutomationRunStepStatus, AutomationStatus, AutomationStep, AutomationStepType, Broadcast, CancelEmailResponse, CancelEmailResponseSuccess, ConditionRule, ConditionStepConfig, Contact, ContactCreatedEvent, ContactDeleteStepConfig, ContactDeletedEvent, ContactProperty, ContactSegmentsBaseOptions, ContactTopic, ContactUpdateStepConfig, ContactUpdatedEvent, CreateApiKeyOptions, CreateApiKeyRequestOptions, CreateApiKeyResponse, CreateApiKeyResponseSuccess, CreateAutomationOptions, CreateAutomationResponse, CreateAutomationResponseSuccess, CreateBatchEmailOptions, CreateBatchOptions, CreateBatchRequestOptions, CreateBatchResponse, CreateBatchSuccessResponse, CreateBroadcastOptions, CreateBroadcastRequestOptions, CreateBroadcastResponse, CreateBroadcastResponseSuccess, CreateContactOptions, CreateContactPropertyApiOptions, CreateContactPropertyOptions, CreateContactPropertyResponse, CreateContactPropertyResponseSuccess, CreateContactRequestOptions, CreateContactResponse, CreateContactResponseSuccess, CreateDomainOptions, CreateDomainRequestOptions, CreateDomainResponse, CreateDomainResponseSuccess, CreateEmailOptions, CreateEmailRequestOptions, CreateEmailResponse, CreateEmailResponseSuccess, CreateEventOptions, CreateEventResponse, CreateEventResponseSuccess, CreateSegmentOptions, CreateSegmentRequestOptions, CreateSegmentResponse, CreateSegmentResponseSuccess, CreateTemplateOptions, CreateTemplateRequestOptions, CreateTemplateResponse, CreateTemplateResponseSuccess, CreateTopicOptions, CreateTopicResponse, CreateTopicResponseSuccess, CreateWebhookOptions, CreateWebhookRequestOptions, CreateWebhookResponse, CreateWebhookResponseSuccess, DelayStepConfig, Domain, DomainApiOptions, DomainCapabilities, DomainCapabilityStatus, DomainCreatedEvent, DomainDeletedEvent, DomainDkimRecord, DomainNameservers, DomainRecordStatus, DomainRecords, DomainRegion, DomainSpfRecord, DomainStatus, DomainUpdatedEvent, DuplicateTemplateResponse, DuplicateTemplateResponseSuccess, EmailApiAttachment, EmailApiOptions, EmailBouncedEvent, EmailClickedEvent, EmailComplainedEvent, EmailDeliveredEvent, EmailDeliveryDelayedEvent, EmailFailedEvent, EmailOpenedEvent, EmailReceivedEvent, EmailScheduledEvent, EmailSentEvent, EmailSuppressedEvent, type ErrorResponse, Event, EventSchemaMap, EventSchemaType, ForwardReceivingEmailOptions, ForwardReceivingEmailResponse, ForwardReceivingEmailResponseSuccess, GetAttachmentOptions, GetAttachmentResponse, GetAttachmentResponseSuccess, GetAutomationResponse, GetAutomationResponseSuccess, GetAutomationRunOptions, GetAutomationRunResponse, GetAutomationRunResponseSuccess, GetBroadcastResponse, GetBroadcastResponseSuccess, GetContactOptions, GetContactPropertyResponse, GetContactPropertyResponseSuccess, GetContactResponse, GetContactResponseSuccess, GetDomainResponse, GetDomainResponseSuccess, GetEmailResponse, GetEmailResponseSuccess, GetEventResponse, GetEventResponseSuccess, GetLogResponse, GetLogResponseSuccess, GetOptions, GetReceivingEmailResponse, GetReceivingEmailResponseSuccess, GetSegmentResponse, GetSegmentResponseSuccess, GetTemplateResponse, GetTemplateResponseSuccess, GetTopicOptions, GetTopicResponse, GetTopicResponseSuccess, GetWebhookResponse, GetWebhookResponseSuccess, IdempotentRequest, InboundAttachment, LegacyCreateContactOptions, ListApiKeysOptions, ListApiKeysResponse, ListApiKeysResponseSuccess, ListAttachmentsOptions, ListAttachmentsResponse, ListAttachmentsResponseSuccess, ListAutomationRunsOptions, ListAutomationRunsResponse, ListAutomationRunsResponseSuccess, ListAutomationsOptions, ListAutomationsResponse, ListAutomationsResponseSuccess, ListBroadcastsOptions, ListBroadcastsResponse, ListBroadcastsResponseSuccess, ListContactPropertiesOptions, ListContactPropertiesResponse, ListContactPropertiesResponseSuccess, ListContactSegmentsOptions, ListContactSegmentsResponse, ListContactSegmentsResponseSuccess, ListContactTopicsOptions, ListContactTopicsRequestOptions, ListContactTopicsResponse, ListContactTopicsResponseSuccess, ListContactsOptions, ListContactsResponse, ListContactsResponseSuccess, ListDomainsOptions, ListDomainsResponse, ListDomainsResponseSuccess, ListEmail, ListEmailsOptions, ListEmailsResponse, ListEmailsResponseSuccess, ListEventsOptions, ListEventsResponse, ListEventsResponseSuccess, ListLogsOptions, ListLogsResponse, ListLogsResponseSuccess, ListReceivingEmail, ListReceivingEmailsOptions, ListReceivingEmailsResponse, ListReceivingEmailsResponseSuccess, ListSegmentsOptions, ListSegmentsResponse, ListSegmentsResponseSuccess, ListTemplatesOptions, ListTemplatesResponse, ListTemplatesResponseSuccess, ListTopicsResponse, ListTopicsResponseSuccess, ListWebhooksOptions, ListWebhooksResponse, ListWebhooksResponseSuccess, Log, PaginatedData, PaginationOptions, PatchOptions, PostOptions, PublishTemplateResponse, PublishTemplateResponseSuccess, PutOptions, ReceivingRecord, RemoveApiKeyResponse, RemoveApiKeyResponseSuccess, RemoveAutomationResponse, RemoveAutomationResponseSuccess, RemoveBroadcastResponse, RemoveBroadcastResponseSuccess, RemoveContactOptions, RemoveContactPropertyResponse, RemoveContactPropertyResponseSuccess, RemoveContactSegmentOptions, RemoveContactSegmentResponse, RemoveContactSegmentResponseSuccess, RemoveContactsResponse, RemoveContactsResponseSuccess, RemoveDomainsResponse, RemoveDomainsResponseSuccess, RemoveEventResponse, RemoveEventResponseSuccess, RemoveSegmentResponse, RemoveSegmentResponseSuccess, RemoveTemplateResponse, RemoveTemplateResponseSuccess, RemoveTopicResponse, RemoveTopicResponseSuccess, RemoveWebhookResponse, RemoveWebhookResponseSuccess, RequireAtLeastOne, Resend, type Response, Segment, SelectingField, SendBroadcastOptions, SendBroadcastRequestOptions, SendBroadcastResponse, SendBroadcastResponseSuccess, SendEmailStepConfig, SendEventOptions, SendEventResponse, SendEventResponseSuccess, StopAutomationResponse, StopAutomationResponseSuccess, Tag, Template, TemplateVariable, TemplateVariableValue, Topic, TrackingCaaRecord, TrackingRecord, TriggerStepConfig, UpdateAutomationOptions, UpdateAutomationResponse, UpdateAutomationResponseSuccess, UpdateBroadcastOptions, UpdateBroadcastResponse, UpdateBroadcastResponseSuccess, UpdateContactOptions, UpdateContactPropertyApiOptions, UpdateContactPropertyOptions, UpdateContactPropertyResponse, UpdateContactPropertyResponseSuccess, UpdateContactResponse, UpdateContactResponseSuccess, UpdateContactTopicsOptions, UpdateContactTopicsRequestOptions, UpdateContactTopicsResponse, UpdateContactTopicsResponseSuccess, UpdateDomainsOptions, UpdateDomainsResponse, UpdateDomainsResponseSuccess, UpdateEmailOptions, UpdateEmailResponse, UpdateEmailResponseSuccess, UpdateEventOptions, UpdateEventResponse, UpdateEventResponseSuccess, UpdateTemplateOptions, UpdateTemplateResponse, UpdateTemplateResponseSuccess, UpdateTopicOptions, UpdateTopicResponse, UpdateTopicResponseSuccess, UpdateWebhookOptions, UpdateWebhookResponse, UpdateWebhookResponseSuccess, VerifyDomainsResponse, VerifyDomainsResponseSuccess, WaitForEventStepConfig, Webhook, WebhookEvent, WebhookEventPayload };
|
|
2231
|
+
export { AddContactSegmentOptions, AddContactSegmentResponse, AddContactSegmentResponseSuccess, AddToSegmentStepConfig, ApiContactProperty, ApiKey, Attachment, AttachmentData, Automation, AutomationConnection, AutomationConnectionType, AutomationResponseConnection, AutomationResponseStep, AutomationRun, AutomationRunItem, AutomationRunStatus, AutomationRunStep, AutomationRunStepStatus, AutomationStatus, AutomationStep, AutomationStepType, Broadcast, CancelEmailResponse, CancelEmailResponseSuccess, ConditionRule, ConditionStepConfig, Contact, ContactCreatedEvent, ContactDeleteStepConfig, ContactDeletedEvent, ContactImport, ContactImportColumnMap, ContactImportCounts, ContactImportOnConflict, ContactImportOnError, ContactImportPropertyMapping, ContactImportPropertyType, ContactImportSegment, ContactImportStatus, ContactImportTopic, ContactProperty, ContactSegmentsBaseOptions, ContactTopic, ContactUpdateStepConfig, ContactUpdatedEvent, CreateApiKeyOptions, CreateApiKeyRequestOptions, CreateApiKeyResponse, CreateApiKeyResponseSuccess, CreateAutomationOptions, CreateAutomationResponse, CreateAutomationResponseSuccess, CreateBatchEmailOptions, CreateBatchOptions, CreateBatchRequestOptions, CreateBatchResponse, CreateBatchSuccessResponse, CreateBroadcastOptions, CreateBroadcastRequestOptions, CreateBroadcastResponse, CreateBroadcastResponseSuccess, CreateContactImportOptions, CreateContactImportRequestOptions, CreateContactImportResponse, CreateContactImportResponseSuccess, CreateContactOptions, CreateContactPropertyApiOptions, CreateContactPropertyOptions, CreateContactPropertyResponse, CreateContactPropertyResponseSuccess, CreateContactRequestOptions, CreateContactResponse, CreateContactResponseSuccess, CreateDomainOptions, CreateDomainRequestOptions, CreateDomainResponse, CreateDomainResponseSuccess, CreateEmailOptions, CreateEmailRequestOptions, CreateEmailResponse, CreateEmailResponseSuccess, CreateEventOptions, CreateEventResponse, CreateEventResponseSuccess, CreateSegmentOptions, CreateSegmentRequestOptions, CreateSegmentResponse, CreateSegmentResponseSuccess, CreateTemplateOptions, CreateTemplateRequestOptions, CreateTemplateResponse, CreateTemplateResponseSuccess, CreateTopicOptions, CreateTopicResponse, CreateTopicResponseSuccess, CreateWebhookOptions, CreateWebhookRequestOptions, CreateWebhookResponse, CreateWebhookResponseSuccess, DelayStepConfig, DeleteOptions, Domain, DomainApiOptions, DomainCapabilities, DomainCapabilityStatus, DomainCreatedEvent, DomainDeletedEvent, DomainDkimRecord, DomainNameservers, DomainRecordStatus, DomainRecords, DomainRegion, DomainSpfRecord, DomainStatus, DomainUpdatedEvent, DuplicateTemplateResponse, DuplicateTemplateResponseSuccess, EmailApiAttachment, EmailApiOptions, EmailBouncedEvent, EmailClickedEvent, EmailComplainedEvent, EmailDeliveredEvent, EmailDeliveryDelayedEvent, EmailFailedEvent, EmailOpenedEvent, EmailReceivedEvent, EmailScheduledEvent, EmailSentEvent, EmailSuppressedEvent, type ErrorResponse, Event, EventSchemaMap, EventSchemaType, ForwardReceivingEmailOptions, ForwardReceivingEmailResponse, ForwardReceivingEmailResponseSuccess, GetAttachmentOptions, GetAttachmentResponse, GetAttachmentResponseSuccess, GetAutomationResponse, GetAutomationResponseSuccess, GetAutomationRunOptions, GetAutomationRunResponse, GetAutomationRunResponseSuccess, GetBroadcastResponse, GetBroadcastResponseSuccess, GetContactImportResponse, GetContactImportResponseSuccess, GetContactOptions, GetContactPropertyResponse, GetContactPropertyResponseSuccess, GetContactResponse, GetContactResponseSuccess, GetDomainResponse, GetDomainResponseSuccess, GetEmailResponse, GetEmailResponseSuccess, GetEventResponse, GetEventResponseSuccess, GetLogResponse, GetLogResponseSuccess, GetOptions, GetReceivingEmailResponse, GetReceivingEmailResponseSuccess, GetSegmentResponse, GetSegmentResponseSuccess, GetTemplateResponse, GetTemplateResponseSuccess, GetTopicOptions, GetTopicResponse, GetTopicResponseSuccess, GetWebhookResponse, GetWebhookResponseSuccess, IdempotentRequest, InboundAttachment, LegacyCreateContactOptions, ListApiKeysOptions, ListApiKeysResponse, ListApiKeysResponseSuccess, ListAttachmentsOptions, ListAttachmentsResponse, ListAttachmentsResponseSuccess, ListAutomationRunsOptions, ListAutomationRunsResponse, ListAutomationRunsResponseSuccess, ListAutomationsOptions, ListAutomationsResponse, ListAutomationsResponseSuccess, ListBroadcastsOptions, ListBroadcastsResponse, ListBroadcastsResponseSuccess, ListContactImportsOptions, ListContactImportsResponse, ListContactImportsResponseSuccess, ListContactPropertiesOptions, ListContactPropertiesResponse, ListContactPropertiesResponseSuccess, ListContactSegmentsOptions, ListContactSegmentsResponse, ListContactSegmentsResponseSuccess, ListContactTopicsOptions, ListContactTopicsRequestOptions, ListContactTopicsResponse, ListContactTopicsResponseSuccess, ListContactsOptions, ListContactsResponse, ListContactsResponseSuccess, ListDomainsOptions, ListDomainsResponse, ListDomainsResponseSuccess, ListEmail, ListEmailsOptions, ListEmailsResponse, ListEmailsResponseSuccess, ListEventsOptions, ListEventsResponse, ListEventsResponseSuccess, ListLogsOptions, ListLogsResponse, ListLogsResponseSuccess, ListReceivingEmail, ListReceivingEmailsOptions, ListReceivingEmailsResponse, ListReceivingEmailsResponseSuccess, ListSegmentsOptions, ListSegmentsResponse, ListSegmentsResponseSuccess, ListTemplatesOptions, ListTemplatesResponse, ListTemplatesResponseSuccess, ListTopicsResponse, ListTopicsResponseSuccess, ListWebhooksOptions, ListWebhooksResponse, ListWebhooksResponseSuccess, Log, PaginatedData, PaginationOptions, PatchOptions, PostOptions, PublishTemplateResponse, PublishTemplateResponseSuccess, PutOptions, ReceivingRecord, RemoveApiKeyResponse, RemoveApiKeyResponseSuccess, RemoveAutomationResponse, RemoveAutomationResponseSuccess, RemoveBroadcastResponse, RemoveBroadcastResponseSuccess, RemoveContactOptions, RemoveContactPropertyResponse, RemoveContactPropertyResponseSuccess, RemoveContactSegmentOptions, RemoveContactSegmentResponse, RemoveContactSegmentResponseSuccess, RemoveContactsResponse, RemoveContactsResponseSuccess, RemoveDomainsResponse, RemoveDomainsResponseSuccess, RemoveEventResponse, RemoveEventResponseSuccess, RemoveSegmentResponse, RemoveSegmentResponseSuccess, RemoveTemplateResponse, RemoveTemplateResponseSuccess, RemoveTopicResponse, RemoveTopicResponseSuccess, RemoveWebhookResponse, RemoveWebhookResponseSuccess, RequireAtLeastOne, Resend, type ResendOptions, type Response, Segment, SelectingField, SendBroadcastOptions, SendBroadcastRequestOptions, SendBroadcastResponse, SendBroadcastResponseSuccess, SendEmailStepConfig, SendEventOptions, SendEventResponse, SendEventResponseSuccess, StopAutomationResponse, StopAutomationResponseSuccess, Tag, Template, TemplateVariable, TemplateVariableValue, Topic, TrackingCaaRecord, TrackingRecord, TriggerStepConfig, UpdateAutomationOptions, UpdateAutomationResponse, UpdateAutomationResponseSuccess, UpdateBroadcastOptions, UpdateBroadcastResponse, UpdateBroadcastResponseSuccess, UpdateContactOptions, UpdateContactPropertyApiOptions, UpdateContactPropertyOptions, UpdateContactPropertyResponse, UpdateContactPropertyResponseSuccess, UpdateContactResponse, UpdateContactResponseSuccess, UpdateContactTopicsOptions, UpdateContactTopicsRequestOptions, UpdateContactTopicsResponse, UpdateContactTopicsResponseSuccess, UpdateDomainsOptions, UpdateDomainsResponse, UpdateDomainsResponseSuccess, UpdateEmailOptions, UpdateEmailResponse, UpdateEmailResponseSuccess, UpdateEventOptions, UpdateEventResponse, UpdateEventResponseSuccess, UpdateTemplateOptions, UpdateTemplateResponse, UpdateTemplateResponseSuccess, UpdateTopicOptions, UpdateTopicResponse, UpdateTopicResponseSuccess, UpdateWebhookOptions, UpdateWebhookResponse, UpdateWebhookResponseSuccess, VerifyDomainsResponse, VerifyDomainsResponseSuccess, WaitForEventStepConfig, Webhook, WebhookEvent, WebhookEventPayload };
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import PostalMime from "postal-mime";
|
|
2
|
-
import { Webhook } from "
|
|
2
|
+
import { Webhook } from "standardwebhooks";
|
|
3
3
|
//#region package.json
|
|
4
|
-
var version = "6.
|
|
4
|
+
var version = "6.13.0-canary.0";
|
|
5
5
|
//#endregion
|
|
6
6
|
//#region src/common/utils/build-pagination-query.ts
|
|
7
7
|
/**
|
|
@@ -250,14 +250,14 @@ var Broadcasts = class {
|
|
|
250
250
|
this.resend = resend;
|
|
251
251
|
}
|
|
252
252
|
async create(payload, options = {}) {
|
|
253
|
-
|
|
253
|
+
const html = payload.react ? await render(payload.react) : payload.html;
|
|
254
254
|
return await this.resend.post("/broadcasts", {
|
|
255
255
|
name: payload.name,
|
|
256
256
|
segment_id: payload.segmentId,
|
|
257
257
|
audience_id: payload.audienceId,
|
|
258
258
|
preview_text: payload.previewText,
|
|
259
259
|
from: payload.from,
|
|
260
|
-
html
|
|
260
|
+
html,
|
|
261
261
|
reply_to: payload.replyTo,
|
|
262
262
|
subject: payload.subject,
|
|
263
263
|
text: payload.text,
|
|
@@ -281,13 +281,13 @@ var Broadcasts = class {
|
|
|
281
281
|
return await this.resend.delete(`/broadcasts/${id}`);
|
|
282
282
|
}
|
|
283
283
|
async update(id, payload) {
|
|
284
|
-
|
|
284
|
+
const html = payload.react ? await render(payload.react) : payload.html;
|
|
285
285
|
return await this.resend.patch(`/broadcasts/${id}`, {
|
|
286
286
|
name: payload.name,
|
|
287
287
|
segment_id: payload.segmentId,
|
|
288
288
|
audience_id: payload.audienceId,
|
|
289
289
|
from: payload.from,
|
|
290
|
-
html
|
|
290
|
+
html,
|
|
291
291
|
text: payload.text,
|
|
292
292
|
subject: payload.subject,
|
|
293
293
|
reply_to: payload.replyTo,
|
|
@@ -387,6 +387,51 @@ var ContactProperties = class {
|
|
|
387
387
|
}
|
|
388
388
|
};
|
|
389
389
|
//#endregion
|
|
390
|
+
//#region src/contacts/imports/contact-imports.ts
|
|
391
|
+
var ContactImports = class {
|
|
392
|
+
constructor(resend) {
|
|
393
|
+
this.resend = resend;
|
|
394
|
+
}
|
|
395
|
+
async create(payload, options = {}) {
|
|
396
|
+
const formData = this.buildCreateFormData(payload);
|
|
397
|
+
return this.resend.post("/contacts/imports", formData, options);
|
|
398
|
+
}
|
|
399
|
+
async list(options = {}) {
|
|
400
|
+
const searchParams = new URLSearchParams(buildPaginationQuery(options));
|
|
401
|
+
if (options.status !== void 0) searchParams.set("status", options.status);
|
|
402
|
+
const queryString = searchParams.toString();
|
|
403
|
+
const url = queryString ? `/contacts/imports?${queryString}` : "/contacts/imports";
|
|
404
|
+
return this.resend.get(url);
|
|
405
|
+
}
|
|
406
|
+
async get(id) {
|
|
407
|
+
return this.resend.get(`/contacts/imports/${id}`);
|
|
408
|
+
}
|
|
409
|
+
buildCreateFormData(payload) {
|
|
410
|
+
const formData = new FormData();
|
|
411
|
+
formData.append("file", payload.file);
|
|
412
|
+
this.appendField(formData, "column_map", this.buildColumnMap(payload.columnMap ?? null));
|
|
413
|
+
this.appendField(formData, "on_conflict", payload.onConflict ?? null);
|
|
414
|
+
this.appendField(formData, "on_error", payload.onError ?? null);
|
|
415
|
+
this.appendField(formData, "segments", payload.segments ?? null);
|
|
416
|
+
this.appendField(formData, "topics", payload.topics ?? null);
|
|
417
|
+
return formData;
|
|
418
|
+
}
|
|
419
|
+
buildColumnMap(columnMap) {
|
|
420
|
+
if (columnMap === null) return null;
|
|
421
|
+
return {
|
|
422
|
+
email: columnMap.email,
|
|
423
|
+
first_name: columnMap.firstName,
|
|
424
|
+
last_name: columnMap.lastName,
|
|
425
|
+
unsubscribed: columnMap.unsubscribed,
|
|
426
|
+
properties: columnMap.properties
|
|
427
|
+
};
|
|
428
|
+
}
|
|
429
|
+
appendField(formData, name, value) {
|
|
430
|
+
if (value === null) return;
|
|
431
|
+
formData.append(name, typeof value === "string" ? value : JSON.stringify(value));
|
|
432
|
+
}
|
|
433
|
+
};
|
|
434
|
+
//#endregion
|
|
390
435
|
//#region src/contacts/segments/contact-segments.ts
|
|
391
436
|
var ContactSegments = class {
|
|
392
437
|
constructor(resend) {
|
|
@@ -474,6 +519,7 @@ var ContactTopics = class {
|
|
|
474
519
|
var Contacts = class {
|
|
475
520
|
constructor(resend) {
|
|
476
521
|
this.resend = resend;
|
|
522
|
+
this.imports = new ContactImports(this.resend);
|
|
477
523
|
this.topics = new ContactTopics(this.resend);
|
|
478
524
|
this.segments = new ContactSegments(this.resend);
|
|
479
525
|
}
|
|
@@ -779,8 +825,9 @@ var Emails = class {
|
|
|
779
825
|
return this.create(payload, options);
|
|
780
826
|
}
|
|
781
827
|
async create(payload, options = {}) {
|
|
782
|
-
|
|
783
|
-
|
|
828
|
+
const body = { ...payload };
|
|
829
|
+
if (payload.react) body.html = await render(payload.react);
|
|
830
|
+
return await this.resend.post("/emails", parseEmailToApiOptions(body), options);
|
|
784
831
|
}
|
|
785
832
|
async get(id) {
|
|
786
833
|
return await this.resend.get(`/emails/${id}`);
|
|
@@ -920,16 +967,9 @@ var Templates = class {
|
|
|
920
967
|
return new ChainableTemplateResult(this.performCreate(payload), this.publish.bind(this));
|
|
921
968
|
}
|
|
922
969
|
async performCreate(payload) {
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
this.renderAsync = renderAsync;
|
|
927
|
-
} catch {
|
|
928
|
-
throw new Error("Failed to render React component. Make sure to install `@react-email/render`");
|
|
929
|
-
}
|
|
930
|
-
payload.html = await this.renderAsync(payload.react);
|
|
931
|
-
}
|
|
932
|
-
return this.resend.post("/templates", parseTemplateToApiOptions(payload));
|
|
970
|
+
const body = { ...payload };
|
|
971
|
+
if (payload.react) body.html = await render(payload.react);
|
|
972
|
+
return this.resend.post("/templates", parseTemplateToApiOptions(body));
|
|
933
973
|
}
|
|
934
974
|
async remove(identifier) {
|
|
935
975
|
return await this.resend.delete(`/templates/${identifier}`);
|
|
@@ -1028,9 +1068,9 @@ var Webhooks = class {
|
|
|
1028
1068
|
}
|
|
1029
1069
|
verify(payload) {
|
|
1030
1070
|
return new Webhook(payload.webhookSecret).verify(payload.payload, {
|
|
1031
|
-
"
|
|
1032
|
-
"
|
|
1033
|
-
"
|
|
1071
|
+
"webhook-id": payload.headers.id,
|
|
1072
|
+
"webhook-timestamp": payload.headers.timestamp,
|
|
1073
|
+
"webhook-signature": payload.headers.signature
|
|
1034
1074
|
});
|
|
1035
1075
|
}
|
|
1036
1076
|
};
|
|
@@ -1038,10 +1078,14 @@ var Webhooks = class {
|
|
|
1038
1078
|
//#region src/resend.ts
|
|
1039
1079
|
const defaultBaseUrl = "https://api.resend.com";
|
|
1040
1080
|
const defaultUserAgent = `resend-node:${version}`;
|
|
1041
|
-
|
|
1042
|
-
|
|
1081
|
+
function getDefaultBaseUrl() {
|
|
1082
|
+
return typeof process !== "undefined" && process.env ? process.env.RESEND_BASE_URL || defaultBaseUrl : defaultBaseUrl;
|
|
1083
|
+
}
|
|
1084
|
+
function getDefaultUserAgent() {
|
|
1085
|
+
return typeof process !== "undefined" && process.env ? process.env.RESEND_USER_AGENT || defaultUserAgent : defaultUserAgent;
|
|
1086
|
+
}
|
|
1043
1087
|
var Resend = class {
|
|
1044
|
-
constructor(key) {
|
|
1088
|
+
constructor(key, options) {
|
|
1045
1089
|
this.key = key;
|
|
1046
1090
|
this.segments = new Segments(this);
|
|
1047
1091
|
this.apiKeys = new ApiKeys(this);
|
|
@@ -1062,15 +1106,17 @@ var Resend = class {
|
|
|
1062
1106
|
if (typeof process !== "undefined" && process.env) this.key = process.env.RESEND_API_KEY;
|
|
1063
1107
|
if (!this.key) throw new Error("Missing API key. Pass it to the constructor `new Resend(\"re_123\")`");
|
|
1064
1108
|
}
|
|
1109
|
+
this.baseUrl = options?.baseUrl ?? getDefaultBaseUrl();
|
|
1110
|
+
this.userAgent = options?.userAgent ?? getDefaultUserAgent();
|
|
1065
1111
|
this.headers = new Headers({
|
|
1066
1112
|
Authorization: `Bearer ${this.key}`,
|
|
1067
|
-
"User-Agent": userAgent,
|
|
1113
|
+
"User-Agent": this.userAgent,
|
|
1068
1114
|
"Content-Type": "application/json"
|
|
1069
1115
|
});
|
|
1070
1116
|
}
|
|
1071
1117
|
async fetchRequest(path, options = {}) {
|
|
1072
1118
|
try {
|
|
1073
|
-
const response = await fetch(`${baseUrl}${path}`, options);
|
|
1119
|
+
const response = await fetch(`${this.baseUrl}${path}`, options);
|
|
1074
1120
|
if (!response.ok) try {
|
|
1075
1121
|
const rawError = await response.text();
|
|
1076
1122
|
return {
|
|
@@ -1126,11 +1172,13 @@ var Resend = class {
|
|
|
1126
1172
|
}
|
|
1127
1173
|
async post(path, entity, options = {}) {
|
|
1128
1174
|
const headers = new Headers(this.headers);
|
|
1175
|
+
const isFormData = typeof FormData !== "undefined" && entity instanceof FormData;
|
|
1176
|
+
if (isFormData) headers.delete("Content-Type");
|
|
1129
1177
|
if (options.headers) for (const [key, value] of new Headers(options.headers).entries()) headers.set(key, value);
|
|
1130
1178
|
if (options.idempotencyKey) headers.set("Idempotency-Key", options.idempotencyKey);
|
|
1131
1179
|
const requestOptions = {
|
|
1132
1180
|
method: "POST",
|
|
1133
|
-
body: JSON.stringify(entity),
|
|
1181
|
+
body: isFormData ? entity : JSON.stringify(entity),
|
|
1134
1182
|
...options,
|
|
1135
1183
|
headers
|
|
1136
1184
|
};
|
|
@@ -1168,11 +1216,14 @@ var Resend = class {
|
|
|
1168
1216
|
};
|
|
1169
1217
|
return this.fetchRequest(path, requestOptions);
|
|
1170
1218
|
}
|
|
1171
|
-
async delete(path, query) {
|
|
1219
|
+
async delete(path, query, options = {}) {
|
|
1220
|
+
const headers = new Headers(this.headers);
|
|
1221
|
+
if (options.headers) for (const [key, value] of new Headers(options.headers).entries()) headers.set(key, value);
|
|
1172
1222
|
const requestOptions = {
|
|
1173
1223
|
method: "DELETE",
|
|
1174
|
-
body: JSON.stringify(query),
|
|
1175
|
-
|
|
1224
|
+
body: query === void 0 ? void 0 : JSON.stringify(query),
|
|
1225
|
+
...options,
|
|
1226
|
+
headers
|
|
1176
1227
|
};
|
|
1177
1228
|
return this.fetchRequest(path, requestOptions);
|
|
1178
1229
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "resend",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.13.0-canary.0",
|
|
4
4
|
"description": "Node.js library for the Resend API",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"devEngines": {
|
|
15
15
|
"runtime": {
|
|
16
16
|
"name": "node",
|
|
17
|
-
"version": ">=22.
|
|
17
|
+
"version": ">=22.12.0"
|
|
18
18
|
}
|
|
19
19
|
},
|
|
20
20
|
"exports": {
|
|
@@ -29,6 +29,19 @@
|
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
},
|
|
32
|
+
"scripts": {
|
|
33
|
+
"build": "tsdown src/index.ts --format esm,cjs --dts",
|
|
34
|
+
"integration:nextjs": "cd ./e2e/nextjs && next build --turbopack",
|
|
35
|
+
"lint": "biome check .",
|
|
36
|
+
"lint:fix": "biome check . --write",
|
|
37
|
+
"prepublishOnly": "pnpm run build",
|
|
38
|
+
"test": "vitest run --exclude e2e",
|
|
39
|
+
"test:dev": "cross-env TEST_MODE=dev vitest run --exclude e2e",
|
|
40
|
+
"test:e2e": "vitest run e2e",
|
|
41
|
+
"test:record": "rimraf --glob \"**/__recordings__\" && cross-env TEST_MODE=record vitest run --exclude e2e",
|
|
42
|
+
"test:watch": "vitest --exclude e2e",
|
|
43
|
+
"typecheck": "tsc --noEmit"
|
|
44
|
+
},
|
|
32
45
|
"repository": {
|
|
33
46
|
"type": "git",
|
|
34
47
|
"url": "git+https://github.com/resend/resend-node.git"
|
|
@@ -41,7 +54,7 @@
|
|
|
41
54
|
"homepage": "https://github.com/resend/resend-node#readme",
|
|
42
55
|
"dependencies": {
|
|
43
56
|
"postal-mime": "2.7.4",
|
|
44
|
-
"
|
|
57
|
+
"standardwebhooks": "1.0.0"
|
|
45
58
|
},
|
|
46
59
|
"peerDependencies": {
|
|
47
60
|
"@react-email/render": "*"
|
|
@@ -70,16 +83,5 @@
|
|
|
70
83
|
"vitest": "4.1.4",
|
|
71
84
|
"vitest-fetch-mock": "0.4.5"
|
|
72
85
|
},
|
|
73
|
-
"
|
|
74
|
-
|
|
75
|
-
"integration:nextjs": "cd ./e2e/nextjs && next build --turbopack",
|
|
76
|
-
"lint": "biome check .",
|
|
77
|
-
"lint:fix": "biome check . --write",
|
|
78
|
-
"test": "vitest run --exclude e2e",
|
|
79
|
-
"test:dev": "cross-env TEST_MODE=dev vitest run --exclude e2e",
|
|
80
|
-
"test:e2e": "vitest run e2e",
|
|
81
|
-
"test:record": "rimraf --glob \"**/__recordings__\" && cross-env TEST_MODE=record vitest run --exclude e2e",
|
|
82
|
-
"test:watch": "vitest --exclude e2e",
|
|
83
|
-
"typecheck": "tsc --noEmit"
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
+
"packageManager": "pnpm@11.3.0"
|
|
87
|
+
}
|