resend 6.9.2 → 6.10.0-preview-workflows.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 +123 -2
- package/dist/index.d.cts +300 -41
- package/dist/index.d.mts +300 -41
- package/dist/index.mjs +121 -1
- package/package.json +7 -7
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
//#region \0rolldown/runtime.js
|
|
2
3
|
var __create = Object.create;
|
|
3
4
|
var __defProp = Object.defineProperty;
|
|
4
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -30,7 +31,7 @@ postal_mime = __toESM(postal_mime);
|
|
|
30
31
|
let svix = require("svix");
|
|
31
32
|
|
|
32
33
|
//#region package.json
|
|
33
|
-
var version = "6.
|
|
34
|
+
var version = "6.10.0-preview-workflows.0";
|
|
34
35
|
|
|
35
36
|
//#endregion
|
|
36
37
|
//#region src/common/utils/build-pagination-query.ts
|
|
@@ -703,6 +704,99 @@ var Emails = class {
|
|
|
703
704
|
}
|
|
704
705
|
};
|
|
705
706
|
|
|
707
|
+
//#endregion
|
|
708
|
+
//#region src/common/utils/parse-workflow-to-api-options.ts
|
|
709
|
+
function parseStepConfig(step) {
|
|
710
|
+
switch (step.type) {
|
|
711
|
+
case "trigger": return {
|
|
712
|
+
ref: step.ref,
|
|
713
|
+
type: step.type,
|
|
714
|
+
config: { event_name: step.config.eventName }
|
|
715
|
+
};
|
|
716
|
+
case "delay": return {
|
|
717
|
+
ref: step.ref,
|
|
718
|
+
type: step.type,
|
|
719
|
+
config: step.config
|
|
720
|
+
};
|
|
721
|
+
case "send_email": return {
|
|
722
|
+
ref: step.ref,
|
|
723
|
+
type: step.type,
|
|
724
|
+
config: {
|
|
725
|
+
template_id: step.config.templateId,
|
|
726
|
+
subject: step.config.subject,
|
|
727
|
+
from: step.config.from,
|
|
728
|
+
reply_to: step.config.replyTo,
|
|
729
|
+
variables: step.config.variables
|
|
730
|
+
}
|
|
731
|
+
};
|
|
732
|
+
case "wait_for_event": return {
|
|
733
|
+
ref: step.ref,
|
|
734
|
+
type: step.type,
|
|
735
|
+
config: {
|
|
736
|
+
event_name: step.config.eventName,
|
|
737
|
+
timeout_seconds: step.config.timeoutSeconds,
|
|
738
|
+
filter_rule: step.config.filterRule
|
|
739
|
+
}
|
|
740
|
+
};
|
|
741
|
+
case "condition": return {
|
|
742
|
+
ref: step.ref,
|
|
743
|
+
type: step.type,
|
|
744
|
+
config: step.config
|
|
745
|
+
};
|
|
746
|
+
}
|
|
747
|
+
}
|
|
748
|
+
function parseEdge(edge) {
|
|
749
|
+
return {
|
|
750
|
+
from: edge.from,
|
|
751
|
+
to: edge.to,
|
|
752
|
+
edge_type: edge.edgeType
|
|
753
|
+
};
|
|
754
|
+
}
|
|
755
|
+
function parseWorkflowToApiOptions(workflow) {
|
|
756
|
+
return {
|
|
757
|
+
name: workflow.name,
|
|
758
|
+
status: workflow.status,
|
|
759
|
+
steps: workflow.steps?.map(parseStepConfig),
|
|
760
|
+
edges: workflow.edges?.map(parseEdge)
|
|
761
|
+
};
|
|
762
|
+
}
|
|
763
|
+
function parseWorkflowEventToApiOptions(event) {
|
|
764
|
+
return {
|
|
765
|
+
event: event.event,
|
|
766
|
+
contact_id: event.contactId,
|
|
767
|
+
email: event.email,
|
|
768
|
+
payload: event.payload
|
|
769
|
+
};
|
|
770
|
+
}
|
|
771
|
+
|
|
772
|
+
//#endregion
|
|
773
|
+
//#region src/events/events.ts
|
|
774
|
+
var Events = class {
|
|
775
|
+
constructor(resend) {
|
|
776
|
+
this.resend = resend;
|
|
777
|
+
}
|
|
778
|
+
async send(payload) {
|
|
779
|
+
return await this.resend.post("/events/send", parseWorkflowEventToApiOptions(payload));
|
|
780
|
+
}
|
|
781
|
+
async create(payload) {
|
|
782
|
+
return await this.resend.post("/events", payload);
|
|
783
|
+
}
|
|
784
|
+
async get(identifier) {
|
|
785
|
+
return await this.resend.get(`/events/${encodeURIComponent(identifier)}`);
|
|
786
|
+
}
|
|
787
|
+
async list(options = {}) {
|
|
788
|
+
const queryString = buildPaginationQuery(options);
|
|
789
|
+
const url = queryString ? `/events?${queryString}` : "/events";
|
|
790
|
+
return await this.resend.get(url);
|
|
791
|
+
}
|
|
792
|
+
async update(identifier, payload) {
|
|
793
|
+
return await this.resend.patch(`/events/${encodeURIComponent(identifier)}`, payload);
|
|
794
|
+
}
|
|
795
|
+
async remove(identifier) {
|
|
796
|
+
return await this.resend.delete(`/events/${encodeURIComponent(identifier)}`);
|
|
797
|
+
}
|
|
798
|
+
};
|
|
799
|
+
|
|
706
800
|
//#endregion
|
|
707
801
|
//#region src/segments/segments.ts
|
|
708
802
|
var Segments = class {
|
|
@@ -905,6 +999,31 @@ var Webhooks = class {
|
|
|
905
999
|
}
|
|
906
1000
|
};
|
|
907
1001
|
|
|
1002
|
+
//#endregion
|
|
1003
|
+
//#region src/workflows/workflows.ts
|
|
1004
|
+
var Workflows = class {
|
|
1005
|
+
constructor(resend) {
|
|
1006
|
+
this.resend = resend;
|
|
1007
|
+
}
|
|
1008
|
+
async create(payload) {
|
|
1009
|
+
return await this.resend.post("/workflows", parseWorkflowToApiOptions(payload));
|
|
1010
|
+
}
|
|
1011
|
+
async list(options = {}) {
|
|
1012
|
+
const queryString = buildPaginationQuery(options);
|
|
1013
|
+
const url = queryString ? `/workflows?${queryString}` : "/workflows";
|
|
1014
|
+
return await this.resend.get(url);
|
|
1015
|
+
}
|
|
1016
|
+
async get(id) {
|
|
1017
|
+
return await this.resend.get(`/workflows/${id}`);
|
|
1018
|
+
}
|
|
1019
|
+
async remove(id) {
|
|
1020
|
+
return await this.resend.delete(`/workflows/${id}`);
|
|
1021
|
+
}
|
|
1022
|
+
async update(id, payload) {
|
|
1023
|
+
return await this.resend.patch(`/workflows/${id}`, payload);
|
|
1024
|
+
}
|
|
1025
|
+
};
|
|
1026
|
+
|
|
908
1027
|
//#endregion
|
|
909
1028
|
//#region src/resend.ts
|
|
910
1029
|
const defaultBaseUrl = "https://api.resend.com";
|
|
@@ -923,9 +1042,11 @@ var Resend = class {
|
|
|
923
1042
|
this.contactProperties = new ContactProperties(this);
|
|
924
1043
|
this.domains = new Domains(this);
|
|
925
1044
|
this.emails = new Emails(this);
|
|
1045
|
+
this.events = new Events(this);
|
|
926
1046
|
this.webhooks = new Webhooks(this);
|
|
927
1047
|
this.templates = new Templates(this);
|
|
928
1048
|
this.topics = new Topics(this);
|
|
1049
|
+
this.workflows = new Workflows(this);
|
|
929
1050
|
if (!key) {
|
|
930
1051
|
if (typeof process !== "undefined" && process.env) this.key = process.env.RESEND_API_KEY;
|
|
931
1052
|
if (!this.key) throw new Error("Missing API key. Pass it to the constructor `new Resend(\"re_123\")`");
|
package/dist/index.d.cts
CHANGED
|
@@ -7,6 +7,28 @@ interface ApiKey {
|
|
|
7
7
|
name: string;
|
|
8
8
|
}
|
|
9
9
|
//#endregion
|
|
10
|
+
//#region src/common/interfaces/attachment.interface.d.ts
|
|
11
|
+
/**
|
|
12
|
+
* Attachment returned by the signed-URL endpoints:
|
|
13
|
+
* - GET /emails/{id}/attachments
|
|
14
|
+
* - GET /emails/{id}/attachments/{id}
|
|
15
|
+
* - GET /emails/receiving/{id}/attachments
|
|
16
|
+
* - GET /emails/receiving/{id}/attachments/{id}
|
|
17
|
+
*
|
|
18
|
+
* Not to be confused with InboundAttachment, which is the raw metadata
|
|
19
|
+
* embedded inside GET /inbounds/{id} — no signed URL, nullable DB columns.
|
|
20
|
+
*/
|
|
21
|
+
interface AttachmentData {
|
|
22
|
+
id: string;
|
|
23
|
+
filename?: string;
|
|
24
|
+
size: number;
|
|
25
|
+
content_type: string;
|
|
26
|
+
content_disposition: 'inline' | 'attachment';
|
|
27
|
+
content_id?: string;
|
|
28
|
+
download_url: string;
|
|
29
|
+
expires_at: string;
|
|
30
|
+
}
|
|
31
|
+
//#endregion
|
|
10
32
|
//#region src/domains/interfaces/domain.d.ts
|
|
11
33
|
type DomainRegion = 'us-east-1' | 'eu-west-1' | 'sa-east-1' | 'ap-northeast-1';
|
|
12
34
|
type DomainCapabilityStatus = 'enabled' | 'disabled';
|
|
@@ -352,7 +374,14 @@ type Tag = {
|
|
|
352
374
|
};
|
|
353
375
|
//#endregion
|
|
354
376
|
//#region src/batch/interfaces/create-batch-options.interface.d.ts
|
|
355
|
-
|
|
377
|
+
/**
|
|
378
|
+
* Email options for batch sending. Same as CreateEmailOptions but without attachments
|
|
379
|
+
* and scheduledAt, as these are not supported in the batch API.
|
|
380
|
+
*
|
|
381
|
+
* @link https://resend.com/docs/dashboard/emails/batch-sending#limitations
|
|
382
|
+
*/
|
|
383
|
+
type CreateBatchEmailOptions = Omit<CreateEmailOptions, 'attachments' | 'scheduledAt'>;
|
|
384
|
+
type CreateBatchOptions = CreateBatchEmailOptions[];
|
|
356
385
|
interface CreateBatchRequestOptions extends PostOptions, IdempotentRequest {
|
|
357
386
|
/**
|
|
358
387
|
* @default 'strict'
|
|
@@ -939,18 +968,6 @@ type VerifyDomainsResponseSuccess = Pick<Domain, 'id'> & {
|
|
|
939
968
|
};
|
|
940
969
|
type VerifyDomainsResponse = Response<VerifyDomainsResponseSuccess>;
|
|
941
970
|
//#endregion
|
|
942
|
-
//#region src/common/interfaces/attachment.interface.d.ts
|
|
943
|
-
interface Attachment$1 {
|
|
944
|
-
id: string;
|
|
945
|
-
filename?: string;
|
|
946
|
-
size: number;
|
|
947
|
-
content_type: string;
|
|
948
|
-
content_disposition: 'inline' | 'attachment';
|
|
949
|
-
content_id?: string;
|
|
950
|
-
download_url: string;
|
|
951
|
-
expires_at: string;
|
|
952
|
-
}
|
|
953
|
-
//#endregion
|
|
954
971
|
//#region src/emails/attachments/interfaces/get-attachment.interface.d.ts
|
|
955
972
|
interface GetAttachmentOptions {
|
|
956
973
|
emailId: string;
|
|
@@ -958,22 +975,17 @@ interface GetAttachmentOptions {
|
|
|
958
975
|
}
|
|
959
976
|
type GetAttachmentResponseSuccess = {
|
|
960
977
|
object: 'attachment';
|
|
961
|
-
} &
|
|
978
|
+
} & AttachmentData;
|
|
962
979
|
type GetAttachmentResponse = Response<GetAttachmentResponseSuccess>;
|
|
963
980
|
//#endregion
|
|
964
981
|
//#region src/emails/attachments/interfaces/list-attachments.interface.d.ts
|
|
965
982
|
type ListAttachmentsOptions = PaginationOptions & {
|
|
966
983
|
emailId: string;
|
|
967
984
|
};
|
|
968
|
-
interface ListAttachmentsApiResponse {
|
|
969
|
-
object: 'list';
|
|
970
|
-
has_more: boolean;
|
|
971
|
-
data: Attachment$1[];
|
|
972
|
-
}
|
|
973
985
|
interface ListAttachmentsResponseSuccess {
|
|
974
986
|
object: 'list';
|
|
975
987
|
has_more: boolean;
|
|
976
|
-
data:
|
|
988
|
+
data: AttachmentData[];
|
|
977
989
|
}
|
|
978
990
|
type ListAttachmentsResponse = Response<ListAttachmentsResponseSuccess>;
|
|
979
991
|
//#endregion
|
|
@@ -1007,6 +1019,16 @@ interface GetEmailResponseSuccess {
|
|
|
1007
1019
|
}
|
|
1008
1020
|
type GetEmailResponse = Response<GetEmailResponseSuccess>;
|
|
1009
1021
|
//#endregion
|
|
1022
|
+
//#region src/emails/interfaces/list-emails-options.interface.d.ts
|
|
1023
|
+
type ListEmailsOptions = PaginationOptions;
|
|
1024
|
+
type ListEmail = Omit<GetEmailResponseSuccess, 'html' | 'text' | 'tags' | 'object'>;
|
|
1025
|
+
type ListEmailsResponseSuccess = {
|
|
1026
|
+
object: 'list';
|
|
1027
|
+
has_more: boolean;
|
|
1028
|
+
data: ListEmail[];
|
|
1029
|
+
};
|
|
1030
|
+
type ListEmailsResponse = Response<ListEmailsResponseSuccess>;
|
|
1031
|
+
//#endregion
|
|
1010
1032
|
//#region src/emails/interfaces/update-email-options.interface.d.ts
|
|
1011
1033
|
interface UpdateEmailOptions {
|
|
1012
1034
|
id: string;
|
|
@@ -1039,6 +1061,22 @@ interface ForwardReceivingEmailResponseSuccess {
|
|
|
1039
1061
|
type ForwardReceivingEmailResponse = Response<ForwardReceivingEmailResponseSuccess>;
|
|
1040
1062
|
//#endregion
|
|
1041
1063
|
//#region src/emails/receiving/interfaces/get-receiving-email.interface.d.ts
|
|
1064
|
+
/**
|
|
1065
|
+
* Attachment metadata embedded in the GET /inbounds/{id} response.
|
|
1066
|
+
* These are raw DB values — fields are nullable and content_disposition is
|
|
1067
|
+
* not normalized to a literal union.
|
|
1068
|
+
*
|
|
1069
|
+
* Not to be confused with AttachmentData, which is the shape returned by the
|
|
1070
|
+
* dedicated attachment endpoints (includes download_url and expires_at).
|
|
1071
|
+
*/
|
|
1072
|
+
interface InboundAttachment {
|
|
1073
|
+
id: string;
|
|
1074
|
+
filename: string | null;
|
|
1075
|
+
size: number;
|
|
1076
|
+
content_type: string;
|
|
1077
|
+
content_id: string | null;
|
|
1078
|
+
content_disposition: string | null;
|
|
1079
|
+
}
|
|
1042
1080
|
interface GetReceivingEmailResponseSuccess {
|
|
1043
1081
|
object: 'email';
|
|
1044
1082
|
id: string;
|
|
@@ -1051,20 +1089,13 @@ interface GetReceivingEmailResponseSuccess {
|
|
|
1051
1089
|
reply_to: string[] | null;
|
|
1052
1090
|
html: string | null;
|
|
1053
1091
|
text: string | null;
|
|
1054
|
-
headers: Record<string, string
|
|
1092
|
+
headers: Record<string, string> | null;
|
|
1055
1093
|
message_id: string;
|
|
1056
|
-
raw
|
|
1094
|
+
raw?: {
|
|
1057
1095
|
download_url: string;
|
|
1058
1096
|
expires_at: string;
|
|
1059
1097
|
} | null;
|
|
1060
|
-
attachments:
|
|
1061
|
-
id: string;
|
|
1062
|
-
filename: string | null;
|
|
1063
|
-
size: number;
|
|
1064
|
-
content_type: string;
|
|
1065
|
-
content_id: string | null;
|
|
1066
|
-
content_disposition: string | null;
|
|
1067
|
-
}>;
|
|
1098
|
+
attachments: InboundAttachment[];
|
|
1068
1099
|
}
|
|
1069
1100
|
type GetReceivingEmailResponse = Response<GetReceivingEmailResponseSuccess>;
|
|
1070
1101
|
//#endregion
|
|
@@ -1084,6 +1115,79 @@ type ListReceivingEmailsResponse = {
|
|
|
1084
1115
|
error: ErrorResponse;
|
|
1085
1116
|
};
|
|
1086
1117
|
//#endregion
|
|
1118
|
+
//#region src/events/interfaces/event.d.ts
|
|
1119
|
+
type EventSchemaType = 'string' | 'number' | 'boolean' | 'date';
|
|
1120
|
+
type EventSchemaMap = Record<string, EventSchemaType>;
|
|
1121
|
+
interface Event {
|
|
1122
|
+
object: 'event';
|
|
1123
|
+
id: string;
|
|
1124
|
+
name: string;
|
|
1125
|
+
schema: EventSchemaMap | null;
|
|
1126
|
+
created_at: string;
|
|
1127
|
+
updated_at: string | null;
|
|
1128
|
+
}
|
|
1129
|
+
//#endregion
|
|
1130
|
+
//#region src/events/interfaces/create-event.interface.d.ts
|
|
1131
|
+
interface CreateEventOptions {
|
|
1132
|
+
name: string;
|
|
1133
|
+
schema?: EventSchemaMap | null;
|
|
1134
|
+
}
|
|
1135
|
+
interface CreateEventResponseSuccess {
|
|
1136
|
+
object: 'event';
|
|
1137
|
+
id: string;
|
|
1138
|
+
}
|
|
1139
|
+
type CreateEventResponse = Response<CreateEventResponseSuccess>;
|
|
1140
|
+
//#endregion
|
|
1141
|
+
//#region src/events/interfaces/get-event.interface.d.ts
|
|
1142
|
+
type GetEventResponseSuccess = Event;
|
|
1143
|
+
type GetEventResponse = Response<GetEventResponseSuccess>;
|
|
1144
|
+
//#endregion
|
|
1145
|
+
//#region src/events/interfaces/list-events.interface.d.ts
|
|
1146
|
+
type ListEventsOptions = PaginationOptions;
|
|
1147
|
+
interface ListEventsResponseSuccess {
|
|
1148
|
+
object: 'list';
|
|
1149
|
+
has_more: boolean;
|
|
1150
|
+
data: Omit<Event, 'object'>[];
|
|
1151
|
+
}
|
|
1152
|
+
type ListEventsResponse = Response<ListEventsResponseSuccess>;
|
|
1153
|
+
//#endregion
|
|
1154
|
+
//#region src/events/interfaces/remove-event.interface.d.ts
|
|
1155
|
+
interface RemoveEventResponseSuccess {
|
|
1156
|
+
object: 'event';
|
|
1157
|
+
id: string;
|
|
1158
|
+
deleted: true;
|
|
1159
|
+
}
|
|
1160
|
+
type RemoveEventResponse = Response<RemoveEventResponseSuccess>;
|
|
1161
|
+
//#endregion
|
|
1162
|
+
//#region src/events/interfaces/send-event.interface.d.ts
|
|
1163
|
+
type SendEventOptions = {
|
|
1164
|
+
event: string;
|
|
1165
|
+
contactId: string;
|
|
1166
|
+
email?: never;
|
|
1167
|
+
payload?: Record<string, unknown>;
|
|
1168
|
+
} | {
|
|
1169
|
+
event: string;
|
|
1170
|
+
email: string;
|
|
1171
|
+
contactId?: never;
|
|
1172
|
+
payload?: Record<string, unknown>;
|
|
1173
|
+
};
|
|
1174
|
+
interface SendEventResponseSuccess {
|
|
1175
|
+
object: 'workflow_event';
|
|
1176
|
+
event: string;
|
|
1177
|
+
event_instance_id: string;
|
|
1178
|
+
}
|
|
1179
|
+
type SendEventResponse = Response<SendEventResponseSuccess>;
|
|
1180
|
+
//#endregion
|
|
1181
|
+
//#region src/events/interfaces/update-event.interface.d.ts
|
|
1182
|
+
interface UpdateEventOptions {
|
|
1183
|
+
schema: EventSchemaMap | null;
|
|
1184
|
+
}
|
|
1185
|
+
interface UpdateEventResponseSuccess {
|
|
1186
|
+
object: 'event';
|
|
1187
|
+
id: string;
|
|
1188
|
+
}
|
|
1189
|
+
type UpdateEventResponse = Response<UpdateEventResponseSuccess>;
|
|
1190
|
+
//#endregion
|
|
1087
1191
|
//#region src/api-keys/api-keys.d.ts
|
|
1088
1192
|
declare class ApiKeys {
|
|
1089
1193
|
private readonly resend;
|
|
@@ -1175,16 +1279,6 @@ declare class Attachments$1 {
|
|
|
1175
1279
|
list(options: ListAttachmentsOptions): Promise<ListAttachmentsResponse>;
|
|
1176
1280
|
}
|
|
1177
1281
|
//#endregion
|
|
1178
|
-
//#region src/emails/interfaces/list-emails-options.interface.d.ts
|
|
1179
|
-
type ListEmailsOptions = PaginationOptions;
|
|
1180
|
-
type ListEmail = Omit<GetEmailResponseSuccess, 'html' | 'text' | 'tags' | 'object'>;
|
|
1181
|
-
type ListEmailsResponseSuccess = {
|
|
1182
|
-
object: 'list';
|
|
1183
|
-
has_more: boolean;
|
|
1184
|
-
data: ListEmail[];
|
|
1185
|
-
};
|
|
1186
|
-
type ListEmailsResponse = Response<ListEmailsResponseSuccess>;
|
|
1187
|
-
//#endregion
|
|
1188
1282
|
//#region src/emails/receiving/attachments/attachments.d.ts
|
|
1189
1283
|
declare class Attachments {
|
|
1190
1284
|
private readonly resend;
|
|
@@ -1219,6 +1313,18 @@ declare class Emails {
|
|
|
1219
1313
|
cancel(id: string): Promise<CancelEmailResponse>;
|
|
1220
1314
|
}
|
|
1221
1315
|
//#endregion
|
|
1316
|
+
//#region src/events/events.d.ts
|
|
1317
|
+
declare class Events {
|
|
1318
|
+
private readonly resend;
|
|
1319
|
+
constructor(resend: Resend);
|
|
1320
|
+
send(payload: SendEventOptions): Promise<SendEventResponse>;
|
|
1321
|
+
create(payload: CreateEventOptions): Promise<CreateEventResponse>;
|
|
1322
|
+
get(identifier: string): Promise<GetEventResponse>;
|
|
1323
|
+
list(options?: ListEventsOptions): Promise<ListEventsResponse>;
|
|
1324
|
+
update(identifier: string, payload: UpdateEventOptions): Promise<UpdateEventResponse>;
|
|
1325
|
+
remove(identifier: string): Promise<RemoveEventResponse>;
|
|
1326
|
+
}
|
|
1327
|
+
//#endregion
|
|
1222
1328
|
//#region src/segments/interfaces/create-segment-options.interface.d.ts
|
|
1223
1329
|
interface CreateSegmentOptions {
|
|
1224
1330
|
name: string;
|
|
@@ -1698,6 +1804,157 @@ declare class Webhooks {
|
|
|
1698
1804
|
verify(payload: VerifyWebhookOptions): WebhookEventPayload;
|
|
1699
1805
|
}
|
|
1700
1806
|
//#endregion
|
|
1807
|
+
//#region src/workflows/interfaces/workflow-step.interface.d.ts
|
|
1808
|
+
type ConditionRule = {
|
|
1809
|
+
type: 'rule';
|
|
1810
|
+
field: string;
|
|
1811
|
+
operator: 'eq' | 'neq';
|
|
1812
|
+
value: string | number | boolean | null;
|
|
1813
|
+
} | {
|
|
1814
|
+
type: 'rule';
|
|
1815
|
+
field: string;
|
|
1816
|
+
operator: 'gt' | 'gte' | 'lt' | 'lte';
|
|
1817
|
+
value: number;
|
|
1818
|
+
} | {
|
|
1819
|
+
type: 'rule';
|
|
1820
|
+
field: string;
|
|
1821
|
+
operator: 'contains' | 'starts_with' | 'ends_with';
|
|
1822
|
+
value: string;
|
|
1823
|
+
} | {
|
|
1824
|
+
type: 'rule';
|
|
1825
|
+
field: string;
|
|
1826
|
+
operator: 'exists' | 'is_empty';
|
|
1827
|
+
};
|
|
1828
|
+
type TemplateVariableValue = string | number | boolean | {
|
|
1829
|
+
var: string;
|
|
1830
|
+
} | Record<string, string | number | boolean> | Array<string | number | boolean | Record<string, string | number | boolean>>;
|
|
1831
|
+
interface TriggerStepConfig {
|
|
1832
|
+
eventName: string;
|
|
1833
|
+
}
|
|
1834
|
+
interface DelayStepConfig {
|
|
1835
|
+
seconds: number;
|
|
1836
|
+
}
|
|
1837
|
+
interface SendEmailStepConfig {
|
|
1838
|
+
templateId: string;
|
|
1839
|
+
subject?: string;
|
|
1840
|
+
from?: string;
|
|
1841
|
+
replyTo?: string;
|
|
1842
|
+
variables?: Record<string, TemplateVariableValue>;
|
|
1843
|
+
}
|
|
1844
|
+
interface WaitForEventStepConfig {
|
|
1845
|
+
eventName: string;
|
|
1846
|
+
timeoutSeconds?: number;
|
|
1847
|
+
filterRule?: ConditionRule;
|
|
1848
|
+
}
|
|
1849
|
+
type ConditionStepConfig = ConditionRule;
|
|
1850
|
+
type WorkflowStep = {
|
|
1851
|
+
ref: string;
|
|
1852
|
+
type: 'trigger';
|
|
1853
|
+
config: TriggerStepConfig;
|
|
1854
|
+
} | {
|
|
1855
|
+
ref: string;
|
|
1856
|
+
type: 'delay';
|
|
1857
|
+
config: DelayStepConfig;
|
|
1858
|
+
} | {
|
|
1859
|
+
ref: string;
|
|
1860
|
+
type: 'send_email';
|
|
1861
|
+
config: SendEmailStepConfig;
|
|
1862
|
+
} | {
|
|
1863
|
+
ref: string;
|
|
1864
|
+
type: 'wait_for_event';
|
|
1865
|
+
config: WaitForEventStepConfig;
|
|
1866
|
+
} | {
|
|
1867
|
+
ref: string;
|
|
1868
|
+
type: 'condition';
|
|
1869
|
+
config: ConditionStepConfig;
|
|
1870
|
+
};
|
|
1871
|
+
type WorkflowEdgeType = 'default' | 'condition_met' | 'condition_not_met' | 'timeout' | 'event_received';
|
|
1872
|
+
interface WorkflowEdge {
|
|
1873
|
+
from: string;
|
|
1874
|
+
to: string;
|
|
1875
|
+
edgeType?: WorkflowEdgeType;
|
|
1876
|
+
}
|
|
1877
|
+
interface WorkflowResponseStep {
|
|
1878
|
+
id: string;
|
|
1879
|
+
type: string;
|
|
1880
|
+
config: unknown;
|
|
1881
|
+
ref?: string;
|
|
1882
|
+
}
|
|
1883
|
+
interface WorkflowResponseEdge {
|
|
1884
|
+
id: string;
|
|
1885
|
+
from_step_id: string;
|
|
1886
|
+
to_step_id: string;
|
|
1887
|
+
edge_type: string;
|
|
1888
|
+
}
|
|
1889
|
+
//#endregion
|
|
1890
|
+
//#region src/workflows/interfaces/create-workflow-options.interface.d.ts
|
|
1891
|
+
interface CreateWorkflowOptions {
|
|
1892
|
+
name: string;
|
|
1893
|
+
status?: 'enabled' | 'disabled';
|
|
1894
|
+
steps: WorkflowStep[];
|
|
1895
|
+
edges: WorkflowEdge[];
|
|
1896
|
+
}
|
|
1897
|
+
interface CreateWorkflowResponseSuccess {
|
|
1898
|
+
object: 'workflow';
|
|
1899
|
+
id: string;
|
|
1900
|
+
}
|
|
1901
|
+
type CreateWorkflowResponse = Response<CreateWorkflowResponseSuccess>;
|
|
1902
|
+
//#endregion
|
|
1903
|
+
//#region src/workflows/interfaces/workflow.d.ts
|
|
1904
|
+
interface Workflow {
|
|
1905
|
+
object: 'workflow';
|
|
1906
|
+
id: string;
|
|
1907
|
+
name: string;
|
|
1908
|
+
status: 'enabled' | 'disabled';
|
|
1909
|
+
created_at: string;
|
|
1910
|
+
updated_at: string | null;
|
|
1911
|
+
}
|
|
1912
|
+
//#endregion
|
|
1913
|
+
//#region src/workflows/interfaces/get-workflow.interface.d.ts
|
|
1914
|
+
interface GetWorkflowResponseSuccess extends Workflow {
|
|
1915
|
+
steps: WorkflowResponseStep[];
|
|
1916
|
+
edges: WorkflowResponseEdge[];
|
|
1917
|
+
}
|
|
1918
|
+
type GetWorkflowResponse = Response<GetWorkflowResponseSuccess>;
|
|
1919
|
+
//#endregion
|
|
1920
|
+
//#region src/workflows/interfaces/list-workflows.interface.d.ts
|
|
1921
|
+
type ListWorkflowsOptions = PaginationOptions;
|
|
1922
|
+
interface ListWorkflowsResponseSuccess {
|
|
1923
|
+
object: 'list';
|
|
1924
|
+
has_more: boolean;
|
|
1925
|
+
data: Workflow[];
|
|
1926
|
+
}
|
|
1927
|
+
type ListWorkflowsResponse = Response<ListWorkflowsResponseSuccess>;
|
|
1928
|
+
//#endregion
|
|
1929
|
+
//#region src/workflows/interfaces/remove-workflow.interface.d.ts
|
|
1930
|
+
interface RemoveWorkflowResponseSuccess extends Pick<Workflow, 'id'> {
|
|
1931
|
+
object: 'workflow';
|
|
1932
|
+
deleted: boolean;
|
|
1933
|
+
}
|
|
1934
|
+
type RemoveWorkflowResponse = Response<RemoveWorkflowResponseSuccess>;
|
|
1935
|
+
//#endregion
|
|
1936
|
+
//#region src/workflows/interfaces/update-workflow.interface.d.ts
|
|
1937
|
+
interface UpdateWorkflowOptions {
|
|
1938
|
+
status: 'enabled' | 'disabled';
|
|
1939
|
+
}
|
|
1940
|
+
interface UpdateWorkflowResponseSuccess {
|
|
1941
|
+
object: 'workflow';
|
|
1942
|
+
id: string;
|
|
1943
|
+
status: 'enabled' | 'disabled';
|
|
1944
|
+
}
|
|
1945
|
+
type UpdateWorkflowResponse = Response<UpdateWorkflowResponseSuccess>;
|
|
1946
|
+
//#endregion
|
|
1947
|
+
//#region src/workflows/workflows.d.ts
|
|
1948
|
+
declare class Workflows {
|
|
1949
|
+
private readonly resend;
|
|
1950
|
+
constructor(resend: Resend);
|
|
1951
|
+
create(payload: CreateWorkflowOptions): Promise<CreateWorkflowResponse>;
|
|
1952
|
+
list(options?: ListWorkflowsOptions): Promise<ListWorkflowsResponse>;
|
|
1953
|
+
get(id: string): Promise<GetWorkflowResponse>;
|
|
1954
|
+
remove(id: string): Promise<RemoveWorkflowResponse>;
|
|
1955
|
+
update(id: string, payload: UpdateWorkflowOptions): Promise<UpdateWorkflowResponse>;
|
|
1956
|
+
}
|
|
1957
|
+
//#endregion
|
|
1701
1958
|
//#region src/resend.d.ts
|
|
1702
1959
|
declare class Resend {
|
|
1703
1960
|
readonly key?: string | undefined;
|
|
@@ -1714,9 +1971,11 @@ declare class Resend {
|
|
|
1714
1971
|
readonly contactProperties: ContactProperties;
|
|
1715
1972
|
readonly domains: Domains;
|
|
1716
1973
|
readonly emails: Emails;
|
|
1974
|
+
readonly events: Events;
|
|
1717
1975
|
readonly webhooks: Webhooks;
|
|
1718
1976
|
readonly templates: Templates;
|
|
1719
1977
|
readonly topics: Topics;
|
|
1978
|
+
readonly workflows: Workflows;
|
|
1720
1979
|
constructor(key?: string | undefined);
|
|
1721
1980
|
fetchRequest<T>(path: string, options?: {}): Promise<Response<T>>;
|
|
1722
1981
|
post<T>(path: string, entity?: unknown, options?: PostOptions & IdempotentRequest): Promise<Response<T>>;
|
|
@@ -1726,4 +1985,4 @@ declare class Resend {
|
|
|
1726
1985
|
delete<T>(path: string, query?: unknown): Promise<Response<T>>;
|
|
1727
1986
|
}
|
|
1728
1987
|
//#endregion
|
|
1729
|
-
export { AddContactSegmentOptions, AddContactSegmentResponse, AddContactSegmentResponseSuccess, ApiContactProperty, ApiKey, Attachment, Broadcast, CancelEmailResponse, CancelEmailResponseSuccess, Contact, ContactCreatedEvent, ContactDeletedEvent, ContactProperty, ContactSegmentsBaseOptions, ContactTopic, ContactUpdatedEvent, CreateApiKeyOptions, CreateApiKeyRequestOptions, CreateApiKeyResponse, CreateApiKeyResponseSuccess, CreateBatchOptions, CreateBatchRequestOptions, CreateBatchResponse, CreateBatchSuccessResponse, CreateBroadcastOptions, CreateBroadcastRequestOptions, CreateBroadcastResponse, CreateBroadcastResponseSuccess, CreateContactOptions, CreateContactPropertyApiOptions, CreateContactPropertyOptions, CreateContactPropertyResponse, CreateContactPropertyResponseSuccess, CreateContactRequestOptions, CreateContactResponse, CreateContactResponseSuccess, CreateDomainOptions, CreateDomainRequestOptions, CreateDomainResponse, CreateDomainResponseSuccess, CreateEmailOptions, CreateEmailRequestOptions, CreateEmailResponse, CreateEmailResponseSuccess, CreateSegmentOptions, CreateSegmentRequestOptions, CreateSegmentResponse, CreateSegmentResponseSuccess, CreateTemplateOptions, CreateTemplateRequestOptions, CreateTemplateResponse, CreateTemplateResponseSuccess, CreateTopicOptions, CreateTopicResponse, CreateTopicResponseSuccess, CreateWebhookOptions, CreateWebhookRequestOptions, CreateWebhookResponse, CreateWebhookResponseSuccess, Domain, DomainApiOptions, DomainCapabilities, DomainCapabilityStatus, DomainCreatedEvent, DomainDeletedEvent, DomainDkimRecord, DomainNameservers, DomainRecords, DomainRegion, DomainSpfRecord, DomainStatus, DomainUpdatedEvent, DuplicateTemplateResponse, DuplicateTemplateResponseSuccess, EmailApiAttachment, EmailApiOptions, EmailBouncedEvent, EmailClickedEvent, EmailComplainedEvent, EmailDeliveredEvent, EmailDeliveryDelayedEvent, EmailFailedEvent, EmailOpenedEvent, EmailReceivedEvent, EmailScheduledEvent, EmailSentEvent, EmailSuppressedEvent, type ErrorResponse, ForwardReceivingEmailOptions, ForwardReceivingEmailResponse, ForwardReceivingEmailResponseSuccess, GetAttachmentOptions, GetAttachmentResponse, GetAttachmentResponseSuccess, GetBroadcastResponse, GetBroadcastResponseSuccess, GetContactOptions, GetContactPropertyResponse, GetContactPropertyResponseSuccess, GetContactResponse, GetContactResponseSuccess, GetDomainResponse, GetDomainResponseSuccess, GetEmailResponse, GetEmailResponseSuccess, GetOptions, GetReceivingEmailResponse, GetReceivingEmailResponseSuccess, GetSegmentResponse, GetSegmentResponseSuccess, GetTemplateResponse, GetTemplateResponseSuccess, GetTopicOptions, GetTopicResponse, GetTopicResponseSuccess, GetWebhookResponse, GetWebhookResponseSuccess, IdempotentRequest, LegacyCreateContactOptions, ListApiKeysOptions, ListApiKeysResponse, ListApiKeysResponseSuccess,
|
|
1988
|
+
export { AddContactSegmentOptions, AddContactSegmentResponse, AddContactSegmentResponseSuccess, ApiContactProperty, ApiKey, Attachment, AttachmentData, Broadcast, CancelEmailResponse, CancelEmailResponseSuccess, ConditionRule, ConditionStepConfig, Contact, ContactCreatedEvent, ContactDeletedEvent, ContactProperty, ContactSegmentsBaseOptions, ContactTopic, ContactUpdatedEvent, CreateApiKeyOptions, CreateApiKeyRequestOptions, CreateApiKeyResponse, CreateApiKeyResponseSuccess, 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, CreateWorkflowOptions, CreateWorkflowResponse, CreateWorkflowResponseSuccess, DelayStepConfig, Domain, DomainApiOptions, DomainCapabilities, DomainCapabilityStatus, DomainCreatedEvent, DomainDeletedEvent, DomainDkimRecord, DomainNameservers, 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, GetBroadcastResponse, GetBroadcastResponseSuccess, GetContactOptions, GetContactPropertyResponse, GetContactPropertyResponseSuccess, GetContactResponse, GetContactResponseSuccess, GetDomainResponse, GetDomainResponseSuccess, GetEmailResponse, GetEmailResponseSuccess, GetEventResponse, GetEventResponseSuccess, GetOptions, GetReceivingEmailResponse, GetReceivingEmailResponseSuccess, GetSegmentResponse, GetSegmentResponseSuccess, GetTemplateResponse, GetTemplateResponseSuccess, GetTopicOptions, GetTopicResponse, GetTopicResponseSuccess, GetWebhookResponse, GetWebhookResponseSuccess, GetWorkflowResponse, GetWorkflowResponseSuccess, IdempotentRequest, InboundAttachment, LegacyCreateContactOptions, ListApiKeysOptions, ListApiKeysResponse, ListApiKeysResponseSuccess, ListAttachmentsOptions, ListAttachmentsResponse, ListAttachmentsResponseSuccess, 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, ListReceivingEmail, ListReceivingEmailsOptions, ListReceivingEmailsResponse, ListReceivingEmailsResponseSuccess, ListSegmentsOptions, ListSegmentsResponse, ListSegmentsResponseSuccess, ListTemplatesOptions, ListTemplatesResponse, ListTemplatesResponseSuccess, ListTopicsResponse, ListTopicsResponseSuccess, ListWebhooksOptions, ListWebhooksResponse, ListWebhooksResponseSuccess, ListWorkflowsOptions, ListWorkflowsResponse, ListWorkflowsResponseSuccess, PaginatedData, PaginationOptions, PatchOptions, PostOptions, PublishTemplateResponse, PublishTemplateResponseSuccess, PutOptions, ReceivingRecord, RemoveApiKeyResponse, RemoveApiKeyResponseSuccess, RemoveBroadcastResponse, RemoveBroadcastResponseSuccess, RemoveContactOptions, RemoveContactPropertyResponse, RemoveContactPropertyResponseSuccess, RemoveContactSegmentOptions, RemoveContactSegmentResponse, RemoveContactSegmentResponseSuccess, RemoveContactsResponse, RemoveContactsResponseSuccess, RemoveDomainsResponse, RemoveDomainsResponseSuccess, RemoveEventResponse, RemoveEventResponseSuccess, RemoveSegmentResponse, RemoveSegmentResponseSuccess, RemoveTemplateResponse, RemoveTemplateResponseSuccess, RemoveTopicResponse, RemoveTopicResponseSuccess, RemoveWebhookResponse, RemoveWebhookResponseSuccess, RemoveWorkflowResponse, RemoveWorkflowResponseSuccess, RequireAtLeastOne, Resend, type Response, Segment, SelectingField, SendBroadcastOptions, SendBroadcastRequestOptions, SendBroadcastResponse, SendBroadcastResponseSuccess, SendEmailStepConfig, SendEventOptions, SendEventResponse, SendEventResponseSuccess, Tag, Template, TemplateVariable, TemplateVariableValue, Topic, TriggerStepConfig, 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, UpdateWorkflowOptions, UpdateWorkflowResponse, UpdateWorkflowResponseSuccess, VerifyDomainsResponse, VerifyDomainsResponseSuccess, WaitForEventStepConfig, Webhook, WebhookEvent, WebhookEventPayload, Workflow, WorkflowEdge, WorkflowEdgeType, WorkflowResponseEdge, WorkflowResponseStep, WorkflowStep };
|
package/dist/index.d.mts
CHANGED
|
@@ -7,6 +7,28 @@ interface ApiKey {
|
|
|
7
7
|
name: string;
|
|
8
8
|
}
|
|
9
9
|
//#endregion
|
|
10
|
+
//#region src/common/interfaces/attachment.interface.d.ts
|
|
11
|
+
/**
|
|
12
|
+
* Attachment returned by the signed-URL endpoints:
|
|
13
|
+
* - GET /emails/{id}/attachments
|
|
14
|
+
* - GET /emails/{id}/attachments/{id}
|
|
15
|
+
* - GET /emails/receiving/{id}/attachments
|
|
16
|
+
* - GET /emails/receiving/{id}/attachments/{id}
|
|
17
|
+
*
|
|
18
|
+
* Not to be confused with InboundAttachment, which is the raw metadata
|
|
19
|
+
* embedded inside GET /inbounds/{id} — no signed URL, nullable DB columns.
|
|
20
|
+
*/
|
|
21
|
+
interface AttachmentData {
|
|
22
|
+
id: string;
|
|
23
|
+
filename?: string;
|
|
24
|
+
size: number;
|
|
25
|
+
content_type: string;
|
|
26
|
+
content_disposition: 'inline' | 'attachment';
|
|
27
|
+
content_id?: string;
|
|
28
|
+
download_url: string;
|
|
29
|
+
expires_at: string;
|
|
30
|
+
}
|
|
31
|
+
//#endregion
|
|
10
32
|
//#region src/domains/interfaces/domain.d.ts
|
|
11
33
|
type DomainRegion = 'us-east-1' | 'eu-west-1' | 'sa-east-1' | 'ap-northeast-1';
|
|
12
34
|
type DomainCapabilityStatus = 'enabled' | 'disabled';
|
|
@@ -352,7 +374,14 @@ type Tag = {
|
|
|
352
374
|
};
|
|
353
375
|
//#endregion
|
|
354
376
|
//#region src/batch/interfaces/create-batch-options.interface.d.ts
|
|
355
|
-
|
|
377
|
+
/**
|
|
378
|
+
* Email options for batch sending. Same as CreateEmailOptions but without attachments
|
|
379
|
+
* and scheduledAt, as these are not supported in the batch API.
|
|
380
|
+
*
|
|
381
|
+
* @link https://resend.com/docs/dashboard/emails/batch-sending#limitations
|
|
382
|
+
*/
|
|
383
|
+
type CreateBatchEmailOptions = Omit<CreateEmailOptions, 'attachments' | 'scheduledAt'>;
|
|
384
|
+
type CreateBatchOptions = CreateBatchEmailOptions[];
|
|
356
385
|
interface CreateBatchRequestOptions extends PostOptions, IdempotentRequest {
|
|
357
386
|
/**
|
|
358
387
|
* @default 'strict'
|
|
@@ -939,18 +968,6 @@ type VerifyDomainsResponseSuccess = Pick<Domain, 'id'> & {
|
|
|
939
968
|
};
|
|
940
969
|
type VerifyDomainsResponse = Response<VerifyDomainsResponseSuccess>;
|
|
941
970
|
//#endregion
|
|
942
|
-
//#region src/common/interfaces/attachment.interface.d.ts
|
|
943
|
-
interface Attachment$1 {
|
|
944
|
-
id: string;
|
|
945
|
-
filename?: string;
|
|
946
|
-
size: number;
|
|
947
|
-
content_type: string;
|
|
948
|
-
content_disposition: 'inline' | 'attachment';
|
|
949
|
-
content_id?: string;
|
|
950
|
-
download_url: string;
|
|
951
|
-
expires_at: string;
|
|
952
|
-
}
|
|
953
|
-
//#endregion
|
|
954
971
|
//#region src/emails/attachments/interfaces/get-attachment.interface.d.ts
|
|
955
972
|
interface GetAttachmentOptions {
|
|
956
973
|
emailId: string;
|
|
@@ -958,22 +975,17 @@ interface GetAttachmentOptions {
|
|
|
958
975
|
}
|
|
959
976
|
type GetAttachmentResponseSuccess = {
|
|
960
977
|
object: 'attachment';
|
|
961
|
-
} &
|
|
978
|
+
} & AttachmentData;
|
|
962
979
|
type GetAttachmentResponse = Response<GetAttachmentResponseSuccess>;
|
|
963
980
|
//#endregion
|
|
964
981
|
//#region src/emails/attachments/interfaces/list-attachments.interface.d.ts
|
|
965
982
|
type ListAttachmentsOptions = PaginationOptions & {
|
|
966
983
|
emailId: string;
|
|
967
984
|
};
|
|
968
|
-
interface ListAttachmentsApiResponse {
|
|
969
|
-
object: 'list';
|
|
970
|
-
has_more: boolean;
|
|
971
|
-
data: Attachment$1[];
|
|
972
|
-
}
|
|
973
985
|
interface ListAttachmentsResponseSuccess {
|
|
974
986
|
object: 'list';
|
|
975
987
|
has_more: boolean;
|
|
976
|
-
data:
|
|
988
|
+
data: AttachmentData[];
|
|
977
989
|
}
|
|
978
990
|
type ListAttachmentsResponse = Response<ListAttachmentsResponseSuccess>;
|
|
979
991
|
//#endregion
|
|
@@ -1007,6 +1019,16 @@ interface GetEmailResponseSuccess {
|
|
|
1007
1019
|
}
|
|
1008
1020
|
type GetEmailResponse = Response<GetEmailResponseSuccess>;
|
|
1009
1021
|
//#endregion
|
|
1022
|
+
//#region src/emails/interfaces/list-emails-options.interface.d.ts
|
|
1023
|
+
type ListEmailsOptions = PaginationOptions;
|
|
1024
|
+
type ListEmail = Omit<GetEmailResponseSuccess, 'html' | 'text' | 'tags' | 'object'>;
|
|
1025
|
+
type ListEmailsResponseSuccess = {
|
|
1026
|
+
object: 'list';
|
|
1027
|
+
has_more: boolean;
|
|
1028
|
+
data: ListEmail[];
|
|
1029
|
+
};
|
|
1030
|
+
type ListEmailsResponse = Response<ListEmailsResponseSuccess>;
|
|
1031
|
+
//#endregion
|
|
1010
1032
|
//#region src/emails/interfaces/update-email-options.interface.d.ts
|
|
1011
1033
|
interface UpdateEmailOptions {
|
|
1012
1034
|
id: string;
|
|
@@ -1039,6 +1061,22 @@ interface ForwardReceivingEmailResponseSuccess {
|
|
|
1039
1061
|
type ForwardReceivingEmailResponse = Response<ForwardReceivingEmailResponseSuccess>;
|
|
1040
1062
|
//#endregion
|
|
1041
1063
|
//#region src/emails/receiving/interfaces/get-receiving-email.interface.d.ts
|
|
1064
|
+
/**
|
|
1065
|
+
* Attachment metadata embedded in the GET /inbounds/{id} response.
|
|
1066
|
+
* These are raw DB values — fields are nullable and content_disposition is
|
|
1067
|
+
* not normalized to a literal union.
|
|
1068
|
+
*
|
|
1069
|
+
* Not to be confused with AttachmentData, which is the shape returned by the
|
|
1070
|
+
* dedicated attachment endpoints (includes download_url and expires_at).
|
|
1071
|
+
*/
|
|
1072
|
+
interface InboundAttachment {
|
|
1073
|
+
id: string;
|
|
1074
|
+
filename: string | null;
|
|
1075
|
+
size: number;
|
|
1076
|
+
content_type: string;
|
|
1077
|
+
content_id: string | null;
|
|
1078
|
+
content_disposition: string | null;
|
|
1079
|
+
}
|
|
1042
1080
|
interface GetReceivingEmailResponseSuccess {
|
|
1043
1081
|
object: 'email';
|
|
1044
1082
|
id: string;
|
|
@@ -1051,20 +1089,13 @@ interface GetReceivingEmailResponseSuccess {
|
|
|
1051
1089
|
reply_to: string[] | null;
|
|
1052
1090
|
html: string | null;
|
|
1053
1091
|
text: string | null;
|
|
1054
|
-
headers: Record<string, string
|
|
1092
|
+
headers: Record<string, string> | null;
|
|
1055
1093
|
message_id: string;
|
|
1056
|
-
raw
|
|
1094
|
+
raw?: {
|
|
1057
1095
|
download_url: string;
|
|
1058
1096
|
expires_at: string;
|
|
1059
1097
|
} | null;
|
|
1060
|
-
attachments:
|
|
1061
|
-
id: string;
|
|
1062
|
-
filename: string | null;
|
|
1063
|
-
size: number;
|
|
1064
|
-
content_type: string;
|
|
1065
|
-
content_id: string | null;
|
|
1066
|
-
content_disposition: string | null;
|
|
1067
|
-
}>;
|
|
1098
|
+
attachments: InboundAttachment[];
|
|
1068
1099
|
}
|
|
1069
1100
|
type GetReceivingEmailResponse = Response<GetReceivingEmailResponseSuccess>;
|
|
1070
1101
|
//#endregion
|
|
@@ -1084,6 +1115,79 @@ type ListReceivingEmailsResponse = {
|
|
|
1084
1115
|
error: ErrorResponse;
|
|
1085
1116
|
};
|
|
1086
1117
|
//#endregion
|
|
1118
|
+
//#region src/events/interfaces/event.d.ts
|
|
1119
|
+
type EventSchemaType = 'string' | 'number' | 'boolean' | 'date';
|
|
1120
|
+
type EventSchemaMap = Record<string, EventSchemaType>;
|
|
1121
|
+
interface Event {
|
|
1122
|
+
object: 'event';
|
|
1123
|
+
id: string;
|
|
1124
|
+
name: string;
|
|
1125
|
+
schema: EventSchemaMap | null;
|
|
1126
|
+
created_at: string;
|
|
1127
|
+
updated_at: string | null;
|
|
1128
|
+
}
|
|
1129
|
+
//#endregion
|
|
1130
|
+
//#region src/events/interfaces/create-event.interface.d.ts
|
|
1131
|
+
interface CreateEventOptions {
|
|
1132
|
+
name: string;
|
|
1133
|
+
schema?: EventSchemaMap | null;
|
|
1134
|
+
}
|
|
1135
|
+
interface CreateEventResponseSuccess {
|
|
1136
|
+
object: 'event';
|
|
1137
|
+
id: string;
|
|
1138
|
+
}
|
|
1139
|
+
type CreateEventResponse = Response<CreateEventResponseSuccess>;
|
|
1140
|
+
//#endregion
|
|
1141
|
+
//#region src/events/interfaces/get-event.interface.d.ts
|
|
1142
|
+
type GetEventResponseSuccess = Event;
|
|
1143
|
+
type GetEventResponse = Response<GetEventResponseSuccess>;
|
|
1144
|
+
//#endregion
|
|
1145
|
+
//#region src/events/interfaces/list-events.interface.d.ts
|
|
1146
|
+
type ListEventsOptions = PaginationOptions;
|
|
1147
|
+
interface ListEventsResponseSuccess {
|
|
1148
|
+
object: 'list';
|
|
1149
|
+
has_more: boolean;
|
|
1150
|
+
data: Omit<Event, 'object'>[];
|
|
1151
|
+
}
|
|
1152
|
+
type ListEventsResponse = Response<ListEventsResponseSuccess>;
|
|
1153
|
+
//#endregion
|
|
1154
|
+
//#region src/events/interfaces/remove-event.interface.d.ts
|
|
1155
|
+
interface RemoveEventResponseSuccess {
|
|
1156
|
+
object: 'event';
|
|
1157
|
+
id: string;
|
|
1158
|
+
deleted: true;
|
|
1159
|
+
}
|
|
1160
|
+
type RemoveEventResponse = Response<RemoveEventResponseSuccess>;
|
|
1161
|
+
//#endregion
|
|
1162
|
+
//#region src/events/interfaces/send-event.interface.d.ts
|
|
1163
|
+
type SendEventOptions = {
|
|
1164
|
+
event: string;
|
|
1165
|
+
contactId: string;
|
|
1166
|
+
email?: never;
|
|
1167
|
+
payload?: Record<string, unknown>;
|
|
1168
|
+
} | {
|
|
1169
|
+
event: string;
|
|
1170
|
+
email: string;
|
|
1171
|
+
contactId?: never;
|
|
1172
|
+
payload?: Record<string, unknown>;
|
|
1173
|
+
};
|
|
1174
|
+
interface SendEventResponseSuccess {
|
|
1175
|
+
object: 'workflow_event';
|
|
1176
|
+
event: string;
|
|
1177
|
+
event_instance_id: string;
|
|
1178
|
+
}
|
|
1179
|
+
type SendEventResponse = Response<SendEventResponseSuccess>;
|
|
1180
|
+
//#endregion
|
|
1181
|
+
//#region src/events/interfaces/update-event.interface.d.ts
|
|
1182
|
+
interface UpdateEventOptions {
|
|
1183
|
+
schema: EventSchemaMap | null;
|
|
1184
|
+
}
|
|
1185
|
+
interface UpdateEventResponseSuccess {
|
|
1186
|
+
object: 'event';
|
|
1187
|
+
id: string;
|
|
1188
|
+
}
|
|
1189
|
+
type UpdateEventResponse = Response<UpdateEventResponseSuccess>;
|
|
1190
|
+
//#endregion
|
|
1087
1191
|
//#region src/api-keys/api-keys.d.ts
|
|
1088
1192
|
declare class ApiKeys {
|
|
1089
1193
|
private readonly resend;
|
|
@@ -1175,16 +1279,6 @@ declare class Attachments$1 {
|
|
|
1175
1279
|
list(options: ListAttachmentsOptions): Promise<ListAttachmentsResponse>;
|
|
1176
1280
|
}
|
|
1177
1281
|
//#endregion
|
|
1178
|
-
//#region src/emails/interfaces/list-emails-options.interface.d.ts
|
|
1179
|
-
type ListEmailsOptions = PaginationOptions;
|
|
1180
|
-
type ListEmail = Omit<GetEmailResponseSuccess, 'html' | 'text' | 'tags' | 'object'>;
|
|
1181
|
-
type ListEmailsResponseSuccess = {
|
|
1182
|
-
object: 'list';
|
|
1183
|
-
has_more: boolean;
|
|
1184
|
-
data: ListEmail[];
|
|
1185
|
-
};
|
|
1186
|
-
type ListEmailsResponse = Response<ListEmailsResponseSuccess>;
|
|
1187
|
-
//#endregion
|
|
1188
1282
|
//#region src/emails/receiving/attachments/attachments.d.ts
|
|
1189
1283
|
declare class Attachments {
|
|
1190
1284
|
private readonly resend;
|
|
@@ -1219,6 +1313,18 @@ declare class Emails {
|
|
|
1219
1313
|
cancel(id: string): Promise<CancelEmailResponse>;
|
|
1220
1314
|
}
|
|
1221
1315
|
//#endregion
|
|
1316
|
+
//#region src/events/events.d.ts
|
|
1317
|
+
declare class Events {
|
|
1318
|
+
private readonly resend;
|
|
1319
|
+
constructor(resend: Resend);
|
|
1320
|
+
send(payload: SendEventOptions): Promise<SendEventResponse>;
|
|
1321
|
+
create(payload: CreateEventOptions): Promise<CreateEventResponse>;
|
|
1322
|
+
get(identifier: string): Promise<GetEventResponse>;
|
|
1323
|
+
list(options?: ListEventsOptions): Promise<ListEventsResponse>;
|
|
1324
|
+
update(identifier: string, payload: UpdateEventOptions): Promise<UpdateEventResponse>;
|
|
1325
|
+
remove(identifier: string): Promise<RemoveEventResponse>;
|
|
1326
|
+
}
|
|
1327
|
+
//#endregion
|
|
1222
1328
|
//#region src/segments/interfaces/create-segment-options.interface.d.ts
|
|
1223
1329
|
interface CreateSegmentOptions {
|
|
1224
1330
|
name: string;
|
|
@@ -1698,6 +1804,157 @@ declare class Webhooks {
|
|
|
1698
1804
|
verify(payload: VerifyWebhookOptions): WebhookEventPayload;
|
|
1699
1805
|
}
|
|
1700
1806
|
//#endregion
|
|
1807
|
+
//#region src/workflows/interfaces/workflow-step.interface.d.ts
|
|
1808
|
+
type ConditionRule = {
|
|
1809
|
+
type: 'rule';
|
|
1810
|
+
field: string;
|
|
1811
|
+
operator: 'eq' | 'neq';
|
|
1812
|
+
value: string | number | boolean | null;
|
|
1813
|
+
} | {
|
|
1814
|
+
type: 'rule';
|
|
1815
|
+
field: string;
|
|
1816
|
+
operator: 'gt' | 'gte' | 'lt' | 'lte';
|
|
1817
|
+
value: number;
|
|
1818
|
+
} | {
|
|
1819
|
+
type: 'rule';
|
|
1820
|
+
field: string;
|
|
1821
|
+
operator: 'contains' | 'starts_with' | 'ends_with';
|
|
1822
|
+
value: string;
|
|
1823
|
+
} | {
|
|
1824
|
+
type: 'rule';
|
|
1825
|
+
field: string;
|
|
1826
|
+
operator: 'exists' | 'is_empty';
|
|
1827
|
+
};
|
|
1828
|
+
type TemplateVariableValue = string | number | boolean | {
|
|
1829
|
+
var: string;
|
|
1830
|
+
} | Record<string, string | number | boolean> | Array<string | number | boolean | Record<string, string | number | boolean>>;
|
|
1831
|
+
interface TriggerStepConfig {
|
|
1832
|
+
eventName: string;
|
|
1833
|
+
}
|
|
1834
|
+
interface DelayStepConfig {
|
|
1835
|
+
seconds: number;
|
|
1836
|
+
}
|
|
1837
|
+
interface SendEmailStepConfig {
|
|
1838
|
+
templateId: string;
|
|
1839
|
+
subject?: string;
|
|
1840
|
+
from?: string;
|
|
1841
|
+
replyTo?: string;
|
|
1842
|
+
variables?: Record<string, TemplateVariableValue>;
|
|
1843
|
+
}
|
|
1844
|
+
interface WaitForEventStepConfig {
|
|
1845
|
+
eventName: string;
|
|
1846
|
+
timeoutSeconds?: number;
|
|
1847
|
+
filterRule?: ConditionRule;
|
|
1848
|
+
}
|
|
1849
|
+
type ConditionStepConfig = ConditionRule;
|
|
1850
|
+
type WorkflowStep = {
|
|
1851
|
+
ref: string;
|
|
1852
|
+
type: 'trigger';
|
|
1853
|
+
config: TriggerStepConfig;
|
|
1854
|
+
} | {
|
|
1855
|
+
ref: string;
|
|
1856
|
+
type: 'delay';
|
|
1857
|
+
config: DelayStepConfig;
|
|
1858
|
+
} | {
|
|
1859
|
+
ref: string;
|
|
1860
|
+
type: 'send_email';
|
|
1861
|
+
config: SendEmailStepConfig;
|
|
1862
|
+
} | {
|
|
1863
|
+
ref: string;
|
|
1864
|
+
type: 'wait_for_event';
|
|
1865
|
+
config: WaitForEventStepConfig;
|
|
1866
|
+
} | {
|
|
1867
|
+
ref: string;
|
|
1868
|
+
type: 'condition';
|
|
1869
|
+
config: ConditionStepConfig;
|
|
1870
|
+
};
|
|
1871
|
+
type WorkflowEdgeType = 'default' | 'condition_met' | 'condition_not_met' | 'timeout' | 'event_received';
|
|
1872
|
+
interface WorkflowEdge {
|
|
1873
|
+
from: string;
|
|
1874
|
+
to: string;
|
|
1875
|
+
edgeType?: WorkflowEdgeType;
|
|
1876
|
+
}
|
|
1877
|
+
interface WorkflowResponseStep {
|
|
1878
|
+
id: string;
|
|
1879
|
+
type: string;
|
|
1880
|
+
config: unknown;
|
|
1881
|
+
ref?: string;
|
|
1882
|
+
}
|
|
1883
|
+
interface WorkflowResponseEdge {
|
|
1884
|
+
id: string;
|
|
1885
|
+
from_step_id: string;
|
|
1886
|
+
to_step_id: string;
|
|
1887
|
+
edge_type: string;
|
|
1888
|
+
}
|
|
1889
|
+
//#endregion
|
|
1890
|
+
//#region src/workflows/interfaces/create-workflow-options.interface.d.ts
|
|
1891
|
+
interface CreateWorkflowOptions {
|
|
1892
|
+
name: string;
|
|
1893
|
+
status?: 'enabled' | 'disabled';
|
|
1894
|
+
steps: WorkflowStep[];
|
|
1895
|
+
edges: WorkflowEdge[];
|
|
1896
|
+
}
|
|
1897
|
+
interface CreateWorkflowResponseSuccess {
|
|
1898
|
+
object: 'workflow';
|
|
1899
|
+
id: string;
|
|
1900
|
+
}
|
|
1901
|
+
type CreateWorkflowResponse = Response<CreateWorkflowResponseSuccess>;
|
|
1902
|
+
//#endregion
|
|
1903
|
+
//#region src/workflows/interfaces/workflow.d.ts
|
|
1904
|
+
interface Workflow {
|
|
1905
|
+
object: 'workflow';
|
|
1906
|
+
id: string;
|
|
1907
|
+
name: string;
|
|
1908
|
+
status: 'enabled' | 'disabled';
|
|
1909
|
+
created_at: string;
|
|
1910
|
+
updated_at: string | null;
|
|
1911
|
+
}
|
|
1912
|
+
//#endregion
|
|
1913
|
+
//#region src/workflows/interfaces/get-workflow.interface.d.ts
|
|
1914
|
+
interface GetWorkflowResponseSuccess extends Workflow {
|
|
1915
|
+
steps: WorkflowResponseStep[];
|
|
1916
|
+
edges: WorkflowResponseEdge[];
|
|
1917
|
+
}
|
|
1918
|
+
type GetWorkflowResponse = Response<GetWorkflowResponseSuccess>;
|
|
1919
|
+
//#endregion
|
|
1920
|
+
//#region src/workflows/interfaces/list-workflows.interface.d.ts
|
|
1921
|
+
type ListWorkflowsOptions = PaginationOptions;
|
|
1922
|
+
interface ListWorkflowsResponseSuccess {
|
|
1923
|
+
object: 'list';
|
|
1924
|
+
has_more: boolean;
|
|
1925
|
+
data: Workflow[];
|
|
1926
|
+
}
|
|
1927
|
+
type ListWorkflowsResponse = Response<ListWorkflowsResponseSuccess>;
|
|
1928
|
+
//#endregion
|
|
1929
|
+
//#region src/workflows/interfaces/remove-workflow.interface.d.ts
|
|
1930
|
+
interface RemoveWorkflowResponseSuccess extends Pick<Workflow, 'id'> {
|
|
1931
|
+
object: 'workflow';
|
|
1932
|
+
deleted: boolean;
|
|
1933
|
+
}
|
|
1934
|
+
type RemoveWorkflowResponse = Response<RemoveWorkflowResponseSuccess>;
|
|
1935
|
+
//#endregion
|
|
1936
|
+
//#region src/workflows/interfaces/update-workflow.interface.d.ts
|
|
1937
|
+
interface UpdateWorkflowOptions {
|
|
1938
|
+
status: 'enabled' | 'disabled';
|
|
1939
|
+
}
|
|
1940
|
+
interface UpdateWorkflowResponseSuccess {
|
|
1941
|
+
object: 'workflow';
|
|
1942
|
+
id: string;
|
|
1943
|
+
status: 'enabled' | 'disabled';
|
|
1944
|
+
}
|
|
1945
|
+
type UpdateWorkflowResponse = Response<UpdateWorkflowResponseSuccess>;
|
|
1946
|
+
//#endregion
|
|
1947
|
+
//#region src/workflows/workflows.d.ts
|
|
1948
|
+
declare class Workflows {
|
|
1949
|
+
private readonly resend;
|
|
1950
|
+
constructor(resend: Resend);
|
|
1951
|
+
create(payload: CreateWorkflowOptions): Promise<CreateWorkflowResponse>;
|
|
1952
|
+
list(options?: ListWorkflowsOptions): Promise<ListWorkflowsResponse>;
|
|
1953
|
+
get(id: string): Promise<GetWorkflowResponse>;
|
|
1954
|
+
remove(id: string): Promise<RemoveWorkflowResponse>;
|
|
1955
|
+
update(id: string, payload: UpdateWorkflowOptions): Promise<UpdateWorkflowResponse>;
|
|
1956
|
+
}
|
|
1957
|
+
//#endregion
|
|
1701
1958
|
//#region src/resend.d.ts
|
|
1702
1959
|
declare class Resend {
|
|
1703
1960
|
readonly key?: string | undefined;
|
|
@@ -1714,9 +1971,11 @@ declare class Resend {
|
|
|
1714
1971
|
readonly contactProperties: ContactProperties;
|
|
1715
1972
|
readonly domains: Domains;
|
|
1716
1973
|
readonly emails: Emails;
|
|
1974
|
+
readonly events: Events;
|
|
1717
1975
|
readonly webhooks: Webhooks;
|
|
1718
1976
|
readonly templates: Templates;
|
|
1719
1977
|
readonly topics: Topics;
|
|
1978
|
+
readonly workflows: Workflows;
|
|
1720
1979
|
constructor(key?: string | undefined);
|
|
1721
1980
|
fetchRequest<T>(path: string, options?: {}): Promise<Response<T>>;
|
|
1722
1981
|
post<T>(path: string, entity?: unknown, options?: PostOptions & IdempotentRequest): Promise<Response<T>>;
|
|
@@ -1726,4 +1985,4 @@ declare class Resend {
|
|
|
1726
1985
|
delete<T>(path: string, query?: unknown): Promise<Response<T>>;
|
|
1727
1986
|
}
|
|
1728
1987
|
//#endregion
|
|
1729
|
-
export { AddContactSegmentOptions, AddContactSegmentResponse, AddContactSegmentResponseSuccess, ApiContactProperty, ApiKey, Attachment, Broadcast, CancelEmailResponse, CancelEmailResponseSuccess, Contact, ContactCreatedEvent, ContactDeletedEvent, ContactProperty, ContactSegmentsBaseOptions, ContactTopic, ContactUpdatedEvent, CreateApiKeyOptions, CreateApiKeyRequestOptions, CreateApiKeyResponse, CreateApiKeyResponseSuccess, CreateBatchOptions, CreateBatchRequestOptions, CreateBatchResponse, CreateBatchSuccessResponse, CreateBroadcastOptions, CreateBroadcastRequestOptions, CreateBroadcastResponse, CreateBroadcastResponseSuccess, CreateContactOptions, CreateContactPropertyApiOptions, CreateContactPropertyOptions, CreateContactPropertyResponse, CreateContactPropertyResponseSuccess, CreateContactRequestOptions, CreateContactResponse, CreateContactResponseSuccess, CreateDomainOptions, CreateDomainRequestOptions, CreateDomainResponse, CreateDomainResponseSuccess, CreateEmailOptions, CreateEmailRequestOptions, CreateEmailResponse, CreateEmailResponseSuccess, CreateSegmentOptions, CreateSegmentRequestOptions, CreateSegmentResponse, CreateSegmentResponseSuccess, CreateTemplateOptions, CreateTemplateRequestOptions, CreateTemplateResponse, CreateTemplateResponseSuccess, CreateTopicOptions, CreateTopicResponse, CreateTopicResponseSuccess, CreateWebhookOptions, CreateWebhookRequestOptions, CreateWebhookResponse, CreateWebhookResponseSuccess, Domain, DomainApiOptions, DomainCapabilities, DomainCapabilityStatus, DomainCreatedEvent, DomainDeletedEvent, DomainDkimRecord, DomainNameservers, DomainRecords, DomainRegion, DomainSpfRecord, DomainStatus, DomainUpdatedEvent, DuplicateTemplateResponse, DuplicateTemplateResponseSuccess, EmailApiAttachment, EmailApiOptions, EmailBouncedEvent, EmailClickedEvent, EmailComplainedEvent, EmailDeliveredEvent, EmailDeliveryDelayedEvent, EmailFailedEvent, EmailOpenedEvent, EmailReceivedEvent, EmailScheduledEvent, EmailSentEvent, EmailSuppressedEvent, type ErrorResponse, ForwardReceivingEmailOptions, ForwardReceivingEmailResponse, ForwardReceivingEmailResponseSuccess, GetAttachmentOptions, GetAttachmentResponse, GetAttachmentResponseSuccess, GetBroadcastResponse, GetBroadcastResponseSuccess, GetContactOptions, GetContactPropertyResponse, GetContactPropertyResponseSuccess, GetContactResponse, GetContactResponseSuccess, GetDomainResponse, GetDomainResponseSuccess, GetEmailResponse, GetEmailResponseSuccess, GetOptions, GetReceivingEmailResponse, GetReceivingEmailResponseSuccess, GetSegmentResponse, GetSegmentResponseSuccess, GetTemplateResponse, GetTemplateResponseSuccess, GetTopicOptions, GetTopicResponse, GetTopicResponseSuccess, GetWebhookResponse, GetWebhookResponseSuccess, IdempotentRequest, LegacyCreateContactOptions, ListApiKeysOptions, ListApiKeysResponse, ListApiKeysResponseSuccess,
|
|
1988
|
+
export { AddContactSegmentOptions, AddContactSegmentResponse, AddContactSegmentResponseSuccess, ApiContactProperty, ApiKey, Attachment, AttachmentData, Broadcast, CancelEmailResponse, CancelEmailResponseSuccess, ConditionRule, ConditionStepConfig, Contact, ContactCreatedEvent, ContactDeletedEvent, ContactProperty, ContactSegmentsBaseOptions, ContactTopic, ContactUpdatedEvent, CreateApiKeyOptions, CreateApiKeyRequestOptions, CreateApiKeyResponse, CreateApiKeyResponseSuccess, 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, CreateWorkflowOptions, CreateWorkflowResponse, CreateWorkflowResponseSuccess, DelayStepConfig, Domain, DomainApiOptions, DomainCapabilities, DomainCapabilityStatus, DomainCreatedEvent, DomainDeletedEvent, DomainDkimRecord, DomainNameservers, 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, GetBroadcastResponse, GetBroadcastResponseSuccess, GetContactOptions, GetContactPropertyResponse, GetContactPropertyResponseSuccess, GetContactResponse, GetContactResponseSuccess, GetDomainResponse, GetDomainResponseSuccess, GetEmailResponse, GetEmailResponseSuccess, GetEventResponse, GetEventResponseSuccess, GetOptions, GetReceivingEmailResponse, GetReceivingEmailResponseSuccess, GetSegmentResponse, GetSegmentResponseSuccess, GetTemplateResponse, GetTemplateResponseSuccess, GetTopicOptions, GetTopicResponse, GetTopicResponseSuccess, GetWebhookResponse, GetWebhookResponseSuccess, GetWorkflowResponse, GetWorkflowResponseSuccess, IdempotentRequest, InboundAttachment, LegacyCreateContactOptions, ListApiKeysOptions, ListApiKeysResponse, ListApiKeysResponseSuccess, ListAttachmentsOptions, ListAttachmentsResponse, ListAttachmentsResponseSuccess, 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, ListReceivingEmail, ListReceivingEmailsOptions, ListReceivingEmailsResponse, ListReceivingEmailsResponseSuccess, ListSegmentsOptions, ListSegmentsResponse, ListSegmentsResponseSuccess, ListTemplatesOptions, ListTemplatesResponse, ListTemplatesResponseSuccess, ListTopicsResponse, ListTopicsResponseSuccess, ListWebhooksOptions, ListWebhooksResponse, ListWebhooksResponseSuccess, ListWorkflowsOptions, ListWorkflowsResponse, ListWorkflowsResponseSuccess, PaginatedData, PaginationOptions, PatchOptions, PostOptions, PublishTemplateResponse, PublishTemplateResponseSuccess, PutOptions, ReceivingRecord, RemoveApiKeyResponse, RemoveApiKeyResponseSuccess, RemoveBroadcastResponse, RemoveBroadcastResponseSuccess, RemoveContactOptions, RemoveContactPropertyResponse, RemoveContactPropertyResponseSuccess, RemoveContactSegmentOptions, RemoveContactSegmentResponse, RemoveContactSegmentResponseSuccess, RemoveContactsResponse, RemoveContactsResponseSuccess, RemoveDomainsResponse, RemoveDomainsResponseSuccess, RemoveEventResponse, RemoveEventResponseSuccess, RemoveSegmentResponse, RemoveSegmentResponseSuccess, RemoveTemplateResponse, RemoveTemplateResponseSuccess, RemoveTopicResponse, RemoveTopicResponseSuccess, RemoveWebhookResponse, RemoveWebhookResponseSuccess, RemoveWorkflowResponse, RemoveWorkflowResponseSuccess, RequireAtLeastOne, Resend, type Response, Segment, SelectingField, SendBroadcastOptions, SendBroadcastRequestOptions, SendBroadcastResponse, SendBroadcastResponseSuccess, SendEmailStepConfig, SendEventOptions, SendEventResponse, SendEventResponseSuccess, Tag, Template, TemplateVariable, TemplateVariableValue, Topic, TriggerStepConfig, 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, UpdateWorkflowOptions, UpdateWorkflowResponse, UpdateWorkflowResponseSuccess, VerifyDomainsResponse, VerifyDomainsResponseSuccess, WaitForEventStepConfig, Webhook, WebhookEvent, WebhookEventPayload, Workflow, WorkflowEdge, WorkflowEdgeType, WorkflowResponseEdge, WorkflowResponseStep, WorkflowStep };
|
package/dist/index.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import PostalMime from "postal-mime";
|
|
|
2
2
|
import { Webhook } from "svix";
|
|
3
3
|
|
|
4
4
|
//#region package.json
|
|
5
|
-
var version = "6.
|
|
5
|
+
var version = "6.10.0-preview-workflows.0";
|
|
6
6
|
|
|
7
7
|
//#endregion
|
|
8
8
|
//#region src/common/utils/build-pagination-query.ts
|
|
@@ -675,6 +675,99 @@ var Emails = class {
|
|
|
675
675
|
}
|
|
676
676
|
};
|
|
677
677
|
|
|
678
|
+
//#endregion
|
|
679
|
+
//#region src/common/utils/parse-workflow-to-api-options.ts
|
|
680
|
+
function parseStepConfig(step) {
|
|
681
|
+
switch (step.type) {
|
|
682
|
+
case "trigger": return {
|
|
683
|
+
ref: step.ref,
|
|
684
|
+
type: step.type,
|
|
685
|
+
config: { event_name: step.config.eventName }
|
|
686
|
+
};
|
|
687
|
+
case "delay": return {
|
|
688
|
+
ref: step.ref,
|
|
689
|
+
type: step.type,
|
|
690
|
+
config: step.config
|
|
691
|
+
};
|
|
692
|
+
case "send_email": return {
|
|
693
|
+
ref: step.ref,
|
|
694
|
+
type: step.type,
|
|
695
|
+
config: {
|
|
696
|
+
template_id: step.config.templateId,
|
|
697
|
+
subject: step.config.subject,
|
|
698
|
+
from: step.config.from,
|
|
699
|
+
reply_to: step.config.replyTo,
|
|
700
|
+
variables: step.config.variables
|
|
701
|
+
}
|
|
702
|
+
};
|
|
703
|
+
case "wait_for_event": return {
|
|
704
|
+
ref: step.ref,
|
|
705
|
+
type: step.type,
|
|
706
|
+
config: {
|
|
707
|
+
event_name: step.config.eventName,
|
|
708
|
+
timeout_seconds: step.config.timeoutSeconds,
|
|
709
|
+
filter_rule: step.config.filterRule
|
|
710
|
+
}
|
|
711
|
+
};
|
|
712
|
+
case "condition": return {
|
|
713
|
+
ref: step.ref,
|
|
714
|
+
type: step.type,
|
|
715
|
+
config: step.config
|
|
716
|
+
};
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
function parseEdge(edge) {
|
|
720
|
+
return {
|
|
721
|
+
from: edge.from,
|
|
722
|
+
to: edge.to,
|
|
723
|
+
edge_type: edge.edgeType
|
|
724
|
+
};
|
|
725
|
+
}
|
|
726
|
+
function parseWorkflowToApiOptions(workflow) {
|
|
727
|
+
return {
|
|
728
|
+
name: workflow.name,
|
|
729
|
+
status: workflow.status,
|
|
730
|
+
steps: workflow.steps?.map(parseStepConfig),
|
|
731
|
+
edges: workflow.edges?.map(parseEdge)
|
|
732
|
+
};
|
|
733
|
+
}
|
|
734
|
+
function parseWorkflowEventToApiOptions(event) {
|
|
735
|
+
return {
|
|
736
|
+
event: event.event,
|
|
737
|
+
contact_id: event.contactId,
|
|
738
|
+
email: event.email,
|
|
739
|
+
payload: event.payload
|
|
740
|
+
};
|
|
741
|
+
}
|
|
742
|
+
|
|
743
|
+
//#endregion
|
|
744
|
+
//#region src/events/events.ts
|
|
745
|
+
var Events = class {
|
|
746
|
+
constructor(resend) {
|
|
747
|
+
this.resend = resend;
|
|
748
|
+
}
|
|
749
|
+
async send(payload) {
|
|
750
|
+
return await this.resend.post("/events/send", parseWorkflowEventToApiOptions(payload));
|
|
751
|
+
}
|
|
752
|
+
async create(payload) {
|
|
753
|
+
return await this.resend.post("/events", payload);
|
|
754
|
+
}
|
|
755
|
+
async get(identifier) {
|
|
756
|
+
return await this.resend.get(`/events/${encodeURIComponent(identifier)}`);
|
|
757
|
+
}
|
|
758
|
+
async list(options = {}) {
|
|
759
|
+
const queryString = buildPaginationQuery(options);
|
|
760
|
+
const url = queryString ? `/events?${queryString}` : "/events";
|
|
761
|
+
return await this.resend.get(url);
|
|
762
|
+
}
|
|
763
|
+
async update(identifier, payload) {
|
|
764
|
+
return await this.resend.patch(`/events/${encodeURIComponent(identifier)}`, payload);
|
|
765
|
+
}
|
|
766
|
+
async remove(identifier) {
|
|
767
|
+
return await this.resend.delete(`/events/${encodeURIComponent(identifier)}`);
|
|
768
|
+
}
|
|
769
|
+
};
|
|
770
|
+
|
|
678
771
|
//#endregion
|
|
679
772
|
//#region src/segments/segments.ts
|
|
680
773
|
var Segments = class {
|
|
@@ -877,6 +970,31 @@ var Webhooks = class {
|
|
|
877
970
|
}
|
|
878
971
|
};
|
|
879
972
|
|
|
973
|
+
//#endregion
|
|
974
|
+
//#region src/workflows/workflows.ts
|
|
975
|
+
var Workflows = class {
|
|
976
|
+
constructor(resend) {
|
|
977
|
+
this.resend = resend;
|
|
978
|
+
}
|
|
979
|
+
async create(payload) {
|
|
980
|
+
return await this.resend.post("/workflows", parseWorkflowToApiOptions(payload));
|
|
981
|
+
}
|
|
982
|
+
async list(options = {}) {
|
|
983
|
+
const queryString = buildPaginationQuery(options);
|
|
984
|
+
const url = queryString ? `/workflows?${queryString}` : "/workflows";
|
|
985
|
+
return await this.resend.get(url);
|
|
986
|
+
}
|
|
987
|
+
async get(id) {
|
|
988
|
+
return await this.resend.get(`/workflows/${id}`);
|
|
989
|
+
}
|
|
990
|
+
async remove(id) {
|
|
991
|
+
return await this.resend.delete(`/workflows/${id}`);
|
|
992
|
+
}
|
|
993
|
+
async update(id, payload) {
|
|
994
|
+
return await this.resend.patch(`/workflows/${id}`, payload);
|
|
995
|
+
}
|
|
996
|
+
};
|
|
997
|
+
|
|
880
998
|
//#endregion
|
|
881
999
|
//#region src/resend.ts
|
|
882
1000
|
const defaultBaseUrl = "https://api.resend.com";
|
|
@@ -895,9 +1013,11 @@ var Resend = class {
|
|
|
895
1013
|
this.contactProperties = new ContactProperties(this);
|
|
896
1014
|
this.domains = new Domains(this);
|
|
897
1015
|
this.emails = new Emails(this);
|
|
1016
|
+
this.events = new Events(this);
|
|
898
1017
|
this.webhooks = new Webhooks(this);
|
|
899
1018
|
this.templates = new Templates(this);
|
|
900
1019
|
this.topics = new Topics(this);
|
|
1020
|
+
this.workflows = new Workflows(this);
|
|
901
1021
|
if (!key) {
|
|
902
1022
|
if (typeof process !== "undefined" && process.env) this.key = process.env.RESEND_API_KEY;
|
|
903
1023
|
if (!this.key) throw new Error("Missing API key. Pass it to the constructor `new Resend(\"re_123\")`");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "resend",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.10.0-preview-workflows.0",
|
|
4
4
|
"description": "Node.js library for the Resend API",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -52,20 +52,20 @@
|
|
|
52
52
|
}
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
|
-
"@biomejs/biome": "2.3.
|
|
55
|
+
"@biomejs/biome": "2.3.14",
|
|
56
56
|
"@pollyjs/adapter-fetch": "6.0.7",
|
|
57
57
|
"@pollyjs/core": "6.0.6",
|
|
58
58
|
"@pollyjs/persister-fs": "6.0.6",
|
|
59
59
|
"@types/mailparser": "3.4.6",
|
|
60
|
-
"@types/node": "24.10.
|
|
61
|
-
"@types/react": "19.2.
|
|
60
|
+
"@types/node": "24.10.13",
|
|
61
|
+
"@types/react": "19.2.13",
|
|
62
62
|
"cross-env": "10.1.0",
|
|
63
|
-
"dotenv": "17.2.
|
|
64
|
-
"pkg-pr-new": "0.0.
|
|
63
|
+
"dotenv": "17.2.4",
|
|
64
|
+
"pkg-pr-new": "0.0.65",
|
|
65
65
|
"react": "19.2.4",
|
|
66
66
|
"react-dom": "19.2.4",
|
|
67
67
|
"rimraf": "6.1.2",
|
|
68
|
-
"tsdown": "0.20.
|
|
68
|
+
"tsdown": "0.20.3",
|
|
69
69
|
"typescript": "5.9.3",
|
|
70
70
|
"vitest": "4.0.18",
|
|
71
71
|
"vitest-fetch-mock": "0.4.5"
|