resend 6.9.3 → 6.10.0-preview-workflows.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +155 -1
- package/dist/index.d.cts +322 -1
- package/dist/index.d.mts +322 -1
- package/dist/index.mjs +155 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -31,7 +31,7 @@ postal_mime = __toESM(postal_mime);
|
|
|
31
31
|
let svix = require("svix");
|
|
32
32
|
|
|
33
33
|
//#region package.json
|
|
34
|
-
var version = "6.
|
|
34
|
+
var version = "6.10.0-preview-workflows.1";
|
|
35
35
|
|
|
36
36
|
//#endregion
|
|
37
37
|
//#region src/common/utils/build-pagination-query.ts
|
|
@@ -704,6 +704,99 @@ var Emails = class {
|
|
|
704
704
|
}
|
|
705
705
|
};
|
|
706
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
|
+
|
|
707
800
|
//#endregion
|
|
708
801
|
//#region src/segments/segments.ts
|
|
709
802
|
var Segments = class {
|
|
@@ -906,6 +999,65 @@ var Webhooks = class {
|
|
|
906
999
|
}
|
|
907
1000
|
};
|
|
908
1001
|
|
|
1002
|
+
//#endregion
|
|
1003
|
+
//#region src/workflow-run-steps/workflow-run-steps.ts
|
|
1004
|
+
var WorkflowRunSteps = class {
|
|
1005
|
+
constructor(resend) {
|
|
1006
|
+
this.resend = resend;
|
|
1007
|
+
}
|
|
1008
|
+
async get(options) {
|
|
1009
|
+
return await this.resend.get(`/workflows/${options.workflowId}/runs/${options.runId}/steps/${options.stepId}`);
|
|
1010
|
+
}
|
|
1011
|
+
async list(options) {
|
|
1012
|
+
const queryString = buildPaginationQuery(options);
|
|
1013
|
+
const url = queryString ? `/workflows/${options.workflowId}/runs/${options.runId}/steps?${queryString}` : `/workflows/${options.workflowId}/runs/${options.runId}/steps`;
|
|
1014
|
+
return await this.resend.get(url);
|
|
1015
|
+
}
|
|
1016
|
+
};
|
|
1017
|
+
|
|
1018
|
+
//#endregion
|
|
1019
|
+
//#region src/workflow-runs/workflow-runs.ts
|
|
1020
|
+
var WorkflowRuns = class {
|
|
1021
|
+
constructor(resend) {
|
|
1022
|
+
this.resend = resend;
|
|
1023
|
+
this.steps = new WorkflowRunSteps(resend);
|
|
1024
|
+
}
|
|
1025
|
+
async get(options) {
|
|
1026
|
+
return await this.resend.get(`/workflows/${options.workflowId}/runs/${options.runId}`);
|
|
1027
|
+
}
|
|
1028
|
+
async list(options) {
|
|
1029
|
+
const queryString = buildPaginationQuery(options);
|
|
1030
|
+
const url = queryString ? `/workflows/${options.workflowId}/runs?${queryString}` : `/workflows/${options.workflowId}/runs`;
|
|
1031
|
+
return await this.resend.get(url);
|
|
1032
|
+
}
|
|
1033
|
+
};
|
|
1034
|
+
|
|
1035
|
+
//#endregion
|
|
1036
|
+
//#region src/workflows/workflows.ts
|
|
1037
|
+
var Workflows = class {
|
|
1038
|
+
constructor(resend) {
|
|
1039
|
+
this.resend = resend;
|
|
1040
|
+
this.runs = new WorkflowRuns(this.resend);
|
|
1041
|
+
}
|
|
1042
|
+
async create(payload) {
|
|
1043
|
+
return await this.resend.post("/workflows", parseWorkflowToApiOptions(payload));
|
|
1044
|
+
}
|
|
1045
|
+
async list(options = {}) {
|
|
1046
|
+
const queryString = buildPaginationQuery(options);
|
|
1047
|
+
const url = queryString ? `/workflows?${queryString}` : "/workflows";
|
|
1048
|
+
return await this.resend.get(url);
|
|
1049
|
+
}
|
|
1050
|
+
async get(id) {
|
|
1051
|
+
return await this.resend.get(`/workflows/${id}`);
|
|
1052
|
+
}
|
|
1053
|
+
async remove(id) {
|
|
1054
|
+
return await this.resend.delete(`/workflows/${id}`);
|
|
1055
|
+
}
|
|
1056
|
+
async update(id, payload) {
|
|
1057
|
+
return await this.resend.patch(`/workflows/${id}`, payload);
|
|
1058
|
+
}
|
|
1059
|
+
};
|
|
1060
|
+
|
|
909
1061
|
//#endregion
|
|
910
1062
|
//#region src/resend.ts
|
|
911
1063
|
const defaultBaseUrl = "https://api.resend.com";
|
|
@@ -924,9 +1076,11 @@ var Resend = class {
|
|
|
924
1076
|
this.contactProperties = new ContactProperties(this);
|
|
925
1077
|
this.domains = new Domains(this);
|
|
926
1078
|
this.emails = new Emails(this);
|
|
1079
|
+
this.events = new Events(this);
|
|
927
1080
|
this.webhooks = new Webhooks(this);
|
|
928
1081
|
this.templates = new Templates(this);
|
|
929
1082
|
this.topics = new Topics(this);
|
|
1083
|
+
this.workflows = new Workflows(this);
|
|
930
1084
|
if (!key) {
|
|
931
1085
|
if (typeof process !== "undefined" && process.env) this.key = process.env.RESEND_API_KEY;
|
|
932
1086
|
if (!this.key) throw new Error("Missing API key. Pass it to the constructor `new Resend(\"re_123\")`");
|
package/dist/index.d.cts
CHANGED
|
@@ -1115,6 +1115,79 @@ type ListReceivingEmailsResponse = {
|
|
|
1115
1115
|
error: ErrorResponse;
|
|
1116
1116
|
};
|
|
1117
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
|
+
id: string;
|
|
1123
|
+
name: string;
|
|
1124
|
+
schema: EventSchemaMap | null;
|
|
1125
|
+
created_at: string;
|
|
1126
|
+
updated_at: string | null;
|
|
1127
|
+
}
|
|
1128
|
+
//#endregion
|
|
1129
|
+
//#region src/events/interfaces/create-event.interface.d.ts
|
|
1130
|
+
interface CreateEventOptions {
|
|
1131
|
+
name: string;
|
|
1132
|
+
schema?: EventSchemaMap | null;
|
|
1133
|
+
}
|
|
1134
|
+
interface CreateEventResponseSuccess {
|
|
1135
|
+
object: 'event';
|
|
1136
|
+
id: string;
|
|
1137
|
+
}
|
|
1138
|
+
type CreateEventResponse = Response<CreateEventResponseSuccess>;
|
|
1139
|
+
//#endregion
|
|
1140
|
+
//#region src/events/interfaces/get-event.interface.d.ts
|
|
1141
|
+
interface GetEventResponseSuccess extends Event {
|
|
1142
|
+
object: 'event';
|
|
1143
|
+
}
|
|
1144
|
+
type GetEventResponse = Response<GetEventResponseSuccess>;
|
|
1145
|
+
//#endregion
|
|
1146
|
+
//#region src/events/interfaces/list-events.interface.d.ts
|
|
1147
|
+
type ListEventsOptions = PaginationOptions;
|
|
1148
|
+
interface ListEventsResponseSuccess {
|
|
1149
|
+
object: 'list';
|
|
1150
|
+
has_more: boolean;
|
|
1151
|
+
data: Event[];
|
|
1152
|
+
}
|
|
1153
|
+
type ListEventsResponse = Response<ListEventsResponseSuccess>;
|
|
1154
|
+
//#endregion
|
|
1155
|
+
//#region src/events/interfaces/remove-event.interface.d.ts
|
|
1156
|
+
interface RemoveEventResponseSuccess extends Pick<Event, 'id'> {
|
|
1157
|
+
object: 'event';
|
|
1158
|
+
deleted: boolean;
|
|
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
|
|
1118
1191
|
//#region src/api-keys/api-keys.d.ts
|
|
1119
1192
|
declare class ApiKeys {
|
|
1120
1193
|
private readonly resend;
|
|
@@ -1240,6 +1313,18 @@ declare class Emails {
|
|
|
1240
1313
|
cancel(id: string): Promise<CancelEmailResponse>;
|
|
1241
1314
|
}
|
|
1242
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
|
|
1243
1328
|
//#region src/segments/interfaces/create-segment-options.interface.d.ts
|
|
1244
1329
|
interface CreateSegmentOptions {
|
|
1245
1330
|
name: string;
|
|
@@ -1719,6 +1804,240 @@ declare class Webhooks {
|
|
|
1719
1804
|
verify(payload: VerifyWebhookOptions): WebhookEventPayload;
|
|
1720
1805
|
}
|
|
1721
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: 'and';
|
|
1829
|
+
rules: ConditionRule[];
|
|
1830
|
+
} | {
|
|
1831
|
+
type: 'or';
|
|
1832
|
+
rules: ConditionRule[];
|
|
1833
|
+
};
|
|
1834
|
+
type TemplateVariableValue = string | number | boolean | {
|
|
1835
|
+
var: string;
|
|
1836
|
+
} | Record<string, string | number | boolean> | Array<string | number | boolean | Record<string, string | number | boolean>>;
|
|
1837
|
+
interface TriggerStepConfig {
|
|
1838
|
+
eventName: string;
|
|
1839
|
+
}
|
|
1840
|
+
interface DelayStepConfig {
|
|
1841
|
+
seconds: number;
|
|
1842
|
+
}
|
|
1843
|
+
interface SendEmailStepConfig {
|
|
1844
|
+
templateId: string;
|
|
1845
|
+
subject?: string;
|
|
1846
|
+
from?: string;
|
|
1847
|
+
replyTo?: string;
|
|
1848
|
+
variables?: Record<string, TemplateVariableValue>;
|
|
1849
|
+
}
|
|
1850
|
+
interface WaitForEventStepConfig {
|
|
1851
|
+
eventName: string;
|
|
1852
|
+
timeoutSeconds?: number;
|
|
1853
|
+
filterRule?: ConditionRule;
|
|
1854
|
+
}
|
|
1855
|
+
type ConditionStepConfig = ConditionRule;
|
|
1856
|
+
type WorkflowStep = {
|
|
1857
|
+
ref: string;
|
|
1858
|
+
type: 'trigger';
|
|
1859
|
+
config: TriggerStepConfig;
|
|
1860
|
+
} | {
|
|
1861
|
+
ref: string;
|
|
1862
|
+
type: 'delay';
|
|
1863
|
+
config: DelayStepConfig;
|
|
1864
|
+
} | {
|
|
1865
|
+
ref: string;
|
|
1866
|
+
type: 'send_email';
|
|
1867
|
+
config: SendEmailStepConfig;
|
|
1868
|
+
} | {
|
|
1869
|
+
ref: string;
|
|
1870
|
+
type: 'wait_for_event';
|
|
1871
|
+
config: WaitForEventStepConfig;
|
|
1872
|
+
} | {
|
|
1873
|
+
ref: string;
|
|
1874
|
+
type: 'condition';
|
|
1875
|
+
config: ConditionStepConfig;
|
|
1876
|
+
};
|
|
1877
|
+
type WorkflowEdgeType = 'default' | 'condition_met' | 'condition_not_met' | 'timeout' | 'event_received';
|
|
1878
|
+
interface WorkflowEdge {
|
|
1879
|
+
from: string;
|
|
1880
|
+
to: string;
|
|
1881
|
+
edgeType?: WorkflowEdgeType;
|
|
1882
|
+
}
|
|
1883
|
+
type WorkflowStepType = WorkflowStep['type'];
|
|
1884
|
+
interface WorkflowResponseStep {
|
|
1885
|
+
id: string;
|
|
1886
|
+
type: WorkflowStepType;
|
|
1887
|
+
config: Record<string, unknown>;
|
|
1888
|
+
}
|
|
1889
|
+
interface WorkflowResponseEdge {
|
|
1890
|
+
id: string;
|
|
1891
|
+
from_step_id: string;
|
|
1892
|
+
to_step_id: string;
|
|
1893
|
+
edge_type: WorkflowEdgeType;
|
|
1894
|
+
}
|
|
1895
|
+
//#endregion
|
|
1896
|
+
//#region src/workflow-run-steps/interfaces/workflow-run-step.d.ts
|
|
1897
|
+
type WorkflowRunStepStatus = 'pending' | 'running' | 'completed' | 'failed' | 'skipped' | 'waiting';
|
|
1898
|
+
interface WorkflowRunStep {
|
|
1899
|
+
object: 'workflow_run_step';
|
|
1900
|
+
id: string;
|
|
1901
|
+
step_id: string;
|
|
1902
|
+
type: WorkflowStepType;
|
|
1903
|
+
config: Record<string, unknown>;
|
|
1904
|
+
status: WorkflowRunStepStatus;
|
|
1905
|
+
started_at: string | null;
|
|
1906
|
+
completed_at: string | null;
|
|
1907
|
+
created_at: string;
|
|
1908
|
+
}
|
|
1909
|
+
type WorkflowRunStepItem = Pick<WorkflowRunStep, 'id' | 'step_id' | 'type' | 'status' | 'started_at' | 'completed_at' | 'created_at'>;
|
|
1910
|
+
//#endregion
|
|
1911
|
+
//#region src/workflow-run-steps/interfaces/get-workflow-run-step.interface.d.ts
|
|
1912
|
+
interface GetWorkflowRunStepOptions {
|
|
1913
|
+
workflowId: string;
|
|
1914
|
+
runId: string;
|
|
1915
|
+
stepId: string;
|
|
1916
|
+
}
|
|
1917
|
+
type GetWorkflowRunStepResponseSuccess = WorkflowRunStep;
|
|
1918
|
+
type GetWorkflowRunStepResponse = Response<GetWorkflowRunStepResponseSuccess>;
|
|
1919
|
+
//#endregion
|
|
1920
|
+
//#region src/workflow-run-steps/interfaces/list-workflow-run-steps.interface.d.ts
|
|
1921
|
+
type ListWorkflowRunStepsOptions = PaginationOptions & {
|
|
1922
|
+
workflowId: string;
|
|
1923
|
+
runId: string;
|
|
1924
|
+
};
|
|
1925
|
+
type ListWorkflowRunStepsResponseSuccess = PaginatedData<WorkflowRunStepItem[]>;
|
|
1926
|
+
type ListWorkflowRunStepsResponse = Response<ListWorkflowRunStepsResponseSuccess>;
|
|
1927
|
+
//#endregion
|
|
1928
|
+
//#region src/workflow-run-steps/workflow-run-steps.d.ts
|
|
1929
|
+
declare class WorkflowRunSteps {
|
|
1930
|
+
private readonly resend;
|
|
1931
|
+
constructor(resend: Resend);
|
|
1932
|
+
get(options: GetWorkflowRunStepOptions): Promise<GetWorkflowRunStepResponse>;
|
|
1933
|
+
list(options: ListWorkflowRunStepsOptions): Promise<ListWorkflowRunStepsResponse>;
|
|
1934
|
+
}
|
|
1935
|
+
//#endregion
|
|
1936
|
+
//#region src/workflow-runs/interfaces/workflow-run.d.ts
|
|
1937
|
+
interface WorkflowRunTrigger {
|
|
1938
|
+
event_name: string;
|
|
1939
|
+
payload?: Record<string, unknown>;
|
|
1940
|
+
}
|
|
1941
|
+
type WorkflowRunStatus = 'running' | 'completed' | 'failed' | 'cancelled';
|
|
1942
|
+
interface WorkflowRun {
|
|
1943
|
+
object: 'workflow_run';
|
|
1944
|
+
id: string;
|
|
1945
|
+
status: WorkflowRunStatus;
|
|
1946
|
+
trigger: WorkflowRunTrigger | null;
|
|
1947
|
+
started_at: string | null;
|
|
1948
|
+
completed_at: string | null;
|
|
1949
|
+
created_at: string;
|
|
1950
|
+
}
|
|
1951
|
+
type WorkflowRunItem = Pick<WorkflowRun, 'id' | 'status' | 'trigger' | 'started_at' | 'completed_at' | 'created_at'>;
|
|
1952
|
+
//#endregion
|
|
1953
|
+
//#region src/workflow-runs/interfaces/get-workflow-run.interface.d.ts
|
|
1954
|
+
interface GetWorkflowRunOptions {
|
|
1955
|
+
workflowId: string;
|
|
1956
|
+
runId: string;
|
|
1957
|
+
}
|
|
1958
|
+
type GetWorkflowRunResponseSuccess = WorkflowRun;
|
|
1959
|
+
type GetWorkflowRunResponse = Response<GetWorkflowRunResponseSuccess>;
|
|
1960
|
+
//#endregion
|
|
1961
|
+
//#region src/workflow-runs/interfaces/list-workflow-runs.interface.d.ts
|
|
1962
|
+
type ListWorkflowRunsOptions = PaginationOptions & {
|
|
1963
|
+
workflowId: string;
|
|
1964
|
+
};
|
|
1965
|
+
type ListWorkflowRunsResponseSuccess = PaginatedData<WorkflowRunItem[]>;
|
|
1966
|
+
type ListWorkflowRunsResponse = Response<ListWorkflowRunsResponseSuccess>;
|
|
1967
|
+
//#endregion
|
|
1968
|
+
//#region src/workflow-runs/workflow-runs.d.ts
|
|
1969
|
+
declare class WorkflowRuns {
|
|
1970
|
+
private readonly resend;
|
|
1971
|
+
readonly steps: WorkflowRunSteps;
|
|
1972
|
+
constructor(resend: Resend);
|
|
1973
|
+
get(options: GetWorkflowRunOptions): Promise<GetWorkflowRunResponse>;
|
|
1974
|
+
list(options: ListWorkflowRunsOptions): Promise<ListWorkflowRunsResponse>;
|
|
1975
|
+
}
|
|
1976
|
+
//#endregion
|
|
1977
|
+
//#region src/workflows/interfaces/workflow.d.ts
|
|
1978
|
+
interface Workflow {
|
|
1979
|
+
id: string;
|
|
1980
|
+
name: string;
|
|
1981
|
+
status: 'enabled' | 'disabled';
|
|
1982
|
+
created_at: string;
|
|
1983
|
+
updated_at: string | null;
|
|
1984
|
+
}
|
|
1985
|
+
type WorkflowStatus = Workflow['status'];
|
|
1986
|
+
//#endregion
|
|
1987
|
+
//#region src/workflows/interfaces/create-workflow-options.interface.d.ts
|
|
1988
|
+
interface CreateWorkflowOptions {
|
|
1989
|
+
name: string;
|
|
1990
|
+
status?: WorkflowStatus;
|
|
1991
|
+
steps: WorkflowStep[];
|
|
1992
|
+
edges: WorkflowEdge[];
|
|
1993
|
+
}
|
|
1994
|
+
interface CreateWorkflowResponseSuccess {
|
|
1995
|
+
object: 'workflow';
|
|
1996
|
+
id: string;
|
|
1997
|
+
}
|
|
1998
|
+
type CreateWorkflowResponse = Response<CreateWorkflowResponseSuccess>;
|
|
1999
|
+
//#endregion
|
|
2000
|
+
//#region src/workflows/interfaces/get-workflow.interface.d.ts
|
|
2001
|
+
interface GetWorkflowResponseSuccess extends Workflow {
|
|
2002
|
+
object: 'workflow';
|
|
2003
|
+
steps: WorkflowResponseStep[];
|
|
2004
|
+
edges: WorkflowResponseEdge[];
|
|
2005
|
+
}
|
|
2006
|
+
type GetWorkflowResponse = Response<GetWorkflowResponseSuccess>;
|
|
2007
|
+
//#endregion
|
|
2008
|
+
//#region src/workflows/interfaces/list-workflows.interface.d.ts
|
|
2009
|
+
type ListWorkflowsOptions = PaginationOptions;
|
|
2010
|
+
type ListWorkflowsResponseSuccess = PaginatedData<Workflow[]>;
|
|
2011
|
+
type ListWorkflowsResponse = Response<ListWorkflowsResponseSuccess>;
|
|
2012
|
+
//#endregion
|
|
2013
|
+
//#region src/workflows/interfaces/remove-workflow.interface.d.ts
|
|
2014
|
+
interface RemoveWorkflowResponseSuccess extends Pick<Workflow, 'id'> {
|
|
2015
|
+
object: 'workflow';
|
|
2016
|
+
deleted: boolean;
|
|
2017
|
+
}
|
|
2018
|
+
type RemoveWorkflowResponse = Response<RemoveWorkflowResponseSuccess>;
|
|
2019
|
+
//#endregion
|
|
2020
|
+
//#region src/workflows/interfaces/update-workflow.interface.d.ts
|
|
2021
|
+
interface UpdateWorkflowOptions {
|
|
2022
|
+
status: WorkflowStatus;
|
|
2023
|
+
}
|
|
2024
|
+
interface UpdateWorkflowResponseSuccess extends Pick<Workflow, 'id' | 'status'> {
|
|
2025
|
+
object: 'workflow';
|
|
2026
|
+
}
|
|
2027
|
+
type UpdateWorkflowResponse = Response<UpdateWorkflowResponseSuccess>;
|
|
2028
|
+
//#endregion
|
|
2029
|
+
//#region src/workflows/workflows.d.ts
|
|
2030
|
+
declare class Workflows {
|
|
2031
|
+
private readonly resend;
|
|
2032
|
+
readonly runs: WorkflowRuns;
|
|
2033
|
+
constructor(resend: Resend);
|
|
2034
|
+
create(payload: CreateWorkflowOptions): Promise<CreateWorkflowResponse>;
|
|
2035
|
+
list(options?: ListWorkflowsOptions): Promise<ListWorkflowsResponse>;
|
|
2036
|
+
get(id: string): Promise<GetWorkflowResponse>;
|
|
2037
|
+
remove(id: string): Promise<RemoveWorkflowResponse>;
|
|
2038
|
+
update(id: string, payload: UpdateWorkflowOptions): Promise<UpdateWorkflowResponse>;
|
|
2039
|
+
}
|
|
2040
|
+
//#endregion
|
|
1722
2041
|
//#region src/resend.d.ts
|
|
1723
2042
|
declare class Resend {
|
|
1724
2043
|
readonly key?: string | undefined;
|
|
@@ -1735,9 +2054,11 @@ declare class Resend {
|
|
|
1735
2054
|
readonly contactProperties: ContactProperties;
|
|
1736
2055
|
readonly domains: Domains;
|
|
1737
2056
|
readonly emails: Emails;
|
|
2057
|
+
readonly events: Events;
|
|
1738
2058
|
readonly webhooks: Webhooks;
|
|
1739
2059
|
readonly templates: Templates;
|
|
1740
2060
|
readonly topics: Topics;
|
|
2061
|
+
readonly workflows: Workflows;
|
|
1741
2062
|
constructor(key?: string | undefined);
|
|
1742
2063
|
fetchRequest<T>(path: string, options?: {}): Promise<Response<T>>;
|
|
1743
2064
|
post<T>(path: string, entity?: unknown, options?: PostOptions & IdempotentRequest): Promise<Response<T>>;
|
|
@@ -1747,4 +2068,4 @@ declare class Resend {
|
|
|
1747
2068
|
delete<T>(path: string, query?: unknown): Promise<Response<T>>;
|
|
1748
2069
|
}
|
|
1749
2070
|
//#endregion
|
|
1750
|
-
export { AddContactSegmentOptions, AddContactSegmentResponse, AddContactSegmentResponseSuccess, ApiContactProperty, ApiKey, Attachment, AttachmentData, Broadcast, CancelEmailResponse, CancelEmailResponseSuccess, 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, 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, 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, ListReceivingEmail, ListReceivingEmailsOptions, ListReceivingEmailsResponse, ListReceivingEmailsResponseSuccess, ListSegmentsOptions, ListSegmentsResponse, ListSegmentsResponseSuccess, ListTemplatesOptions, ListTemplatesResponse, ListTemplatesResponseSuccess, ListTopicsResponse, ListTopicsResponseSuccess, ListWebhooksOptions, ListWebhooksResponse, ListWebhooksResponseSuccess, PaginatedData, PaginationOptions, PatchOptions, PostOptions, PublishTemplateResponse, PublishTemplateResponseSuccess, PutOptions, ReceivingRecord, RemoveApiKeyResponse, RemoveApiKeyResponseSuccess, RemoveBroadcastResponse, RemoveBroadcastResponseSuccess, RemoveContactOptions, RemoveContactPropertyResponse, RemoveContactPropertyResponseSuccess, RemoveContactSegmentOptions, RemoveContactSegmentResponse, RemoveContactSegmentResponseSuccess, RemoveContactsResponse, RemoveContactsResponseSuccess, RemoveDomainsResponse, RemoveDomainsResponseSuccess, RemoveSegmentResponse, RemoveSegmentResponseSuccess, RemoveTemplateResponse, RemoveTemplateResponseSuccess, RemoveTopicResponse, RemoveTopicResponseSuccess, RemoveWebhookResponse, RemoveWebhookResponseSuccess, RequireAtLeastOne, Resend, type Response, Segment, SelectingField, SendBroadcastOptions, SendBroadcastRequestOptions, SendBroadcastResponse, SendBroadcastResponseSuccess, Tag, Template, TemplateVariable, Topic, UpdateBroadcastOptions, UpdateBroadcastResponse, UpdateBroadcastResponseSuccess, UpdateContactOptions, UpdateContactPropertyApiOptions, UpdateContactPropertyOptions, UpdateContactPropertyResponse, UpdateContactPropertyResponseSuccess, UpdateContactResponse, UpdateContactResponseSuccess, UpdateContactTopicsOptions, UpdateContactTopicsRequestOptions, UpdateContactTopicsResponse, UpdateContactTopicsResponseSuccess, UpdateDomainsOptions, UpdateDomainsResponse, UpdateDomainsResponseSuccess, UpdateEmailOptions, UpdateEmailResponse, UpdateEmailResponseSuccess, UpdateTemplateOptions, UpdateTemplateResponse, UpdateTemplateResponseSuccess, UpdateTopicOptions, UpdateTopicResponse, UpdateTopicResponseSuccess, UpdateWebhookOptions, UpdateWebhookResponse, UpdateWebhookResponseSuccess, VerifyDomainsResponse, VerifyDomainsResponseSuccess, Webhook, WebhookEvent, WebhookEventPayload };
|
|
2071
|
+
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, GetWorkflowRunOptions, GetWorkflowRunResponse, GetWorkflowRunResponseSuccess, GetWorkflowRunStepOptions, GetWorkflowRunStepResponse, GetWorkflowRunStepResponseSuccess, 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, ListWorkflowRunStepsOptions, ListWorkflowRunStepsResponse, ListWorkflowRunStepsResponseSuccess, ListWorkflowRunsOptions, ListWorkflowRunsResponse, ListWorkflowRunsResponseSuccess, 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, WorkflowRun, WorkflowRunItem, WorkflowRunStatus, WorkflowRunStep, WorkflowRunStepItem, WorkflowRunStepStatus, WorkflowRunTrigger, WorkflowStatus, WorkflowStep, WorkflowStepType };
|
package/dist/index.d.mts
CHANGED
|
@@ -1115,6 +1115,79 @@ type ListReceivingEmailsResponse = {
|
|
|
1115
1115
|
error: ErrorResponse;
|
|
1116
1116
|
};
|
|
1117
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
|
+
id: string;
|
|
1123
|
+
name: string;
|
|
1124
|
+
schema: EventSchemaMap | null;
|
|
1125
|
+
created_at: string;
|
|
1126
|
+
updated_at: string | null;
|
|
1127
|
+
}
|
|
1128
|
+
//#endregion
|
|
1129
|
+
//#region src/events/interfaces/create-event.interface.d.ts
|
|
1130
|
+
interface CreateEventOptions {
|
|
1131
|
+
name: string;
|
|
1132
|
+
schema?: EventSchemaMap | null;
|
|
1133
|
+
}
|
|
1134
|
+
interface CreateEventResponseSuccess {
|
|
1135
|
+
object: 'event';
|
|
1136
|
+
id: string;
|
|
1137
|
+
}
|
|
1138
|
+
type CreateEventResponse = Response<CreateEventResponseSuccess>;
|
|
1139
|
+
//#endregion
|
|
1140
|
+
//#region src/events/interfaces/get-event.interface.d.ts
|
|
1141
|
+
interface GetEventResponseSuccess extends Event {
|
|
1142
|
+
object: 'event';
|
|
1143
|
+
}
|
|
1144
|
+
type GetEventResponse = Response<GetEventResponseSuccess>;
|
|
1145
|
+
//#endregion
|
|
1146
|
+
//#region src/events/interfaces/list-events.interface.d.ts
|
|
1147
|
+
type ListEventsOptions = PaginationOptions;
|
|
1148
|
+
interface ListEventsResponseSuccess {
|
|
1149
|
+
object: 'list';
|
|
1150
|
+
has_more: boolean;
|
|
1151
|
+
data: Event[];
|
|
1152
|
+
}
|
|
1153
|
+
type ListEventsResponse = Response<ListEventsResponseSuccess>;
|
|
1154
|
+
//#endregion
|
|
1155
|
+
//#region src/events/interfaces/remove-event.interface.d.ts
|
|
1156
|
+
interface RemoveEventResponseSuccess extends Pick<Event, 'id'> {
|
|
1157
|
+
object: 'event';
|
|
1158
|
+
deleted: boolean;
|
|
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
|
|
1118
1191
|
//#region src/api-keys/api-keys.d.ts
|
|
1119
1192
|
declare class ApiKeys {
|
|
1120
1193
|
private readonly resend;
|
|
@@ -1240,6 +1313,18 @@ declare class Emails {
|
|
|
1240
1313
|
cancel(id: string): Promise<CancelEmailResponse>;
|
|
1241
1314
|
}
|
|
1242
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
|
|
1243
1328
|
//#region src/segments/interfaces/create-segment-options.interface.d.ts
|
|
1244
1329
|
interface CreateSegmentOptions {
|
|
1245
1330
|
name: string;
|
|
@@ -1719,6 +1804,240 @@ declare class Webhooks {
|
|
|
1719
1804
|
verify(payload: VerifyWebhookOptions): WebhookEventPayload;
|
|
1720
1805
|
}
|
|
1721
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: 'and';
|
|
1829
|
+
rules: ConditionRule[];
|
|
1830
|
+
} | {
|
|
1831
|
+
type: 'or';
|
|
1832
|
+
rules: ConditionRule[];
|
|
1833
|
+
};
|
|
1834
|
+
type TemplateVariableValue = string | number | boolean | {
|
|
1835
|
+
var: string;
|
|
1836
|
+
} | Record<string, string | number | boolean> | Array<string | number | boolean | Record<string, string | number | boolean>>;
|
|
1837
|
+
interface TriggerStepConfig {
|
|
1838
|
+
eventName: string;
|
|
1839
|
+
}
|
|
1840
|
+
interface DelayStepConfig {
|
|
1841
|
+
seconds: number;
|
|
1842
|
+
}
|
|
1843
|
+
interface SendEmailStepConfig {
|
|
1844
|
+
templateId: string;
|
|
1845
|
+
subject?: string;
|
|
1846
|
+
from?: string;
|
|
1847
|
+
replyTo?: string;
|
|
1848
|
+
variables?: Record<string, TemplateVariableValue>;
|
|
1849
|
+
}
|
|
1850
|
+
interface WaitForEventStepConfig {
|
|
1851
|
+
eventName: string;
|
|
1852
|
+
timeoutSeconds?: number;
|
|
1853
|
+
filterRule?: ConditionRule;
|
|
1854
|
+
}
|
|
1855
|
+
type ConditionStepConfig = ConditionRule;
|
|
1856
|
+
type WorkflowStep = {
|
|
1857
|
+
ref: string;
|
|
1858
|
+
type: 'trigger';
|
|
1859
|
+
config: TriggerStepConfig;
|
|
1860
|
+
} | {
|
|
1861
|
+
ref: string;
|
|
1862
|
+
type: 'delay';
|
|
1863
|
+
config: DelayStepConfig;
|
|
1864
|
+
} | {
|
|
1865
|
+
ref: string;
|
|
1866
|
+
type: 'send_email';
|
|
1867
|
+
config: SendEmailStepConfig;
|
|
1868
|
+
} | {
|
|
1869
|
+
ref: string;
|
|
1870
|
+
type: 'wait_for_event';
|
|
1871
|
+
config: WaitForEventStepConfig;
|
|
1872
|
+
} | {
|
|
1873
|
+
ref: string;
|
|
1874
|
+
type: 'condition';
|
|
1875
|
+
config: ConditionStepConfig;
|
|
1876
|
+
};
|
|
1877
|
+
type WorkflowEdgeType = 'default' | 'condition_met' | 'condition_not_met' | 'timeout' | 'event_received';
|
|
1878
|
+
interface WorkflowEdge {
|
|
1879
|
+
from: string;
|
|
1880
|
+
to: string;
|
|
1881
|
+
edgeType?: WorkflowEdgeType;
|
|
1882
|
+
}
|
|
1883
|
+
type WorkflowStepType = WorkflowStep['type'];
|
|
1884
|
+
interface WorkflowResponseStep {
|
|
1885
|
+
id: string;
|
|
1886
|
+
type: WorkflowStepType;
|
|
1887
|
+
config: Record<string, unknown>;
|
|
1888
|
+
}
|
|
1889
|
+
interface WorkflowResponseEdge {
|
|
1890
|
+
id: string;
|
|
1891
|
+
from_step_id: string;
|
|
1892
|
+
to_step_id: string;
|
|
1893
|
+
edge_type: WorkflowEdgeType;
|
|
1894
|
+
}
|
|
1895
|
+
//#endregion
|
|
1896
|
+
//#region src/workflow-run-steps/interfaces/workflow-run-step.d.ts
|
|
1897
|
+
type WorkflowRunStepStatus = 'pending' | 'running' | 'completed' | 'failed' | 'skipped' | 'waiting';
|
|
1898
|
+
interface WorkflowRunStep {
|
|
1899
|
+
object: 'workflow_run_step';
|
|
1900
|
+
id: string;
|
|
1901
|
+
step_id: string;
|
|
1902
|
+
type: WorkflowStepType;
|
|
1903
|
+
config: Record<string, unknown>;
|
|
1904
|
+
status: WorkflowRunStepStatus;
|
|
1905
|
+
started_at: string | null;
|
|
1906
|
+
completed_at: string | null;
|
|
1907
|
+
created_at: string;
|
|
1908
|
+
}
|
|
1909
|
+
type WorkflowRunStepItem = Pick<WorkflowRunStep, 'id' | 'step_id' | 'type' | 'status' | 'started_at' | 'completed_at' | 'created_at'>;
|
|
1910
|
+
//#endregion
|
|
1911
|
+
//#region src/workflow-run-steps/interfaces/get-workflow-run-step.interface.d.ts
|
|
1912
|
+
interface GetWorkflowRunStepOptions {
|
|
1913
|
+
workflowId: string;
|
|
1914
|
+
runId: string;
|
|
1915
|
+
stepId: string;
|
|
1916
|
+
}
|
|
1917
|
+
type GetWorkflowRunStepResponseSuccess = WorkflowRunStep;
|
|
1918
|
+
type GetWorkflowRunStepResponse = Response<GetWorkflowRunStepResponseSuccess>;
|
|
1919
|
+
//#endregion
|
|
1920
|
+
//#region src/workflow-run-steps/interfaces/list-workflow-run-steps.interface.d.ts
|
|
1921
|
+
type ListWorkflowRunStepsOptions = PaginationOptions & {
|
|
1922
|
+
workflowId: string;
|
|
1923
|
+
runId: string;
|
|
1924
|
+
};
|
|
1925
|
+
type ListWorkflowRunStepsResponseSuccess = PaginatedData<WorkflowRunStepItem[]>;
|
|
1926
|
+
type ListWorkflowRunStepsResponse = Response<ListWorkflowRunStepsResponseSuccess>;
|
|
1927
|
+
//#endregion
|
|
1928
|
+
//#region src/workflow-run-steps/workflow-run-steps.d.ts
|
|
1929
|
+
declare class WorkflowRunSteps {
|
|
1930
|
+
private readonly resend;
|
|
1931
|
+
constructor(resend: Resend);
|
|
1932
|
+
get(options: GetWorkflowRunStepOptions): Promise<GetWorkflowRunStepResponse>;
|
|
1933
|
+
list(options: ListWorkflowRunStepsOptions): Promise<ListWorkflowRunStepsResponse>;
|
|
1934
|
+
}
|
|
1935
|
+
//#endregion
|
|
1936
|
+
//#region src/workflow-runs/interfaces/workflow-run.d.ts
|
|
1937
|
+
interface WorkflowRunTrigger {
|
|
1938
|
+
event_name: string;
|
|
1939
|
+
payload?: Record<string, unknown>;
|
|
1940
|
+
}
|
|
1941
|
+
type WorkflowRunStatus = 'running' | 'completed' | 'failed' | 'cancelled';
|
|
1942
|
+
interface WorkflowRun {
|
|
1943
|
+
object: 'workflow_run';
|
|
1944
|
+
id: string;
|
|
1945
|
+
status: WorkflowRunStatus;
|
|
1946
|
+
trigger: WorkflowRunTrigger | null;
|
|
1947
|
+
started_at: string | null;
|
|
1948
|
+
completed_at: string | null;
|
|
1949
|
+
created_at: string;
|
|
1950
|
+
}
|
|
1951
|
+
type WorkflowRunItem = Pick<WorkflowRun, 'id' | 'status' | 'trigger' | 'started_at' | 'completed_at' | 'created_at'>;
|
|
1952
|
+
//#endregion
|
|
1953
|
+
//#region src/workflow-runs/interfaces/get-workflow-run.interface.d.ts
|
|
1954
|
+
interface GetWorkflowRunOptions {
|
|
1955
|
+
workflowId: string;
|
|
1956
|
+
runId: string;
|
|
1957
|
+
}
|
|
1958
|
+
type GetWorkflowRunResponseSuccess = WorkflowRun;
|
|
1959
|
+
type GetWorkflowRunResponse = Response<GetWorkflowRunResponseSuccess>;
|
|
1960
|
+
//#endregion
|
|
1961
|
+
//#region src/workflow-runs/interfaces/list-workflow-runs.interface.d.ts
|
|
1962
|
+
type ListWorkflowRunsOptions = PaginationOptions & {
|
|
1963
|
+
workflowId: string;
|
|
1964
|
+
};
|
|
1965
|
+
type ListWorkflowRunsResponseSuccess = PaginatedData<WorkflowRunItem[]>;
|
|
1966
|
+
type ListWorkflowRunsResponse = Response<ListWorkflowRunsResponseSuccess>;
|
|
1967
|
+
//#endregion
|
|
1968
|
+
//#region src/workflow-runs/workflow-runs.d.ts
|
|
1969
|
+
declare class WorkflowRuns {
|
|
1970
|
+
private readonly resend;
|
|
1971
|
+
readonly steps: WorkflowRunSteps;
|
|
1972
|
+
constructor(resend: Resend);
|
|
1973
|
+
get(options: GetWorkflowRunOptions): Promise<GetWorkflowRunResponse>;
|
|
1974
|
+
list(options: ListWorkflowRunsOptions): Promise<ListWorkflowRunsResponse>;
|
|
1975
|
+
}
|
|
1976
|
+
//#endregion
|
|
1977
|
+
//#region src/workflows/interfaces/workflow.d.ts
|
|
1978
|
+
interface Workflow {
|
|
1979
|
+
id: string;
|
|
1980
|
+
name: string;
|
|
1981
|
+
status: 'enabled' | 'disabled';
|
|
1982
|
+
created_at: string;
|
|
1983
|
+
updated_at: string | null;
|
|
1984
|
+
}
|
|
1985
|
+
type WorkflowStatus = Workflow['status'];
|
|
1986
|
+
//#endregion
|
|
1987
|
+
//#region src/workflows/interfaces/create-workflow-options.interface.d.ts
|
|
1988
|
+
interface CreateWorkflowOptions {
|
|
1989
|
+
name: string;
|
|
1990
|
+
status?: WorkflowStatus;
|
|
1991
|
+
steps: WorkflowStep[];
|
|
1992
|
+
edges: WorkflowEdge[];
|
|
1993
|
+
}
|
|
1994
|
+
interface CreateWorkflowResponseSuccess {
|
|
1995
|
+
object: 'workflow';
|
|
1996
|
+
id: string;
|
|
1997
|
+
}
|
|
1998
|
+
type CreateWorkflowResponse = Response<CreateWorkflowResponseSuccess>;
|
|
1999
|
+
//#endregion
|
|
2000
|
+
//#region src/workflows/interfaces/get-workflow.interface.d.ts
|
|
2001
|
+
interface GetWorkflowResponseSuccess extends Workflow {
|
|
2002
|
+
object: 'workflow';
|
|
2003
|
+
steps: WorkflowResponseStep[];
|
|
2004
|
+
edges: WorkflowResponseEdge[];
|
|
2005
|
+
}
|
|
2006
|
+
type GetWorkflowResponse = Response<GetWorkflowResponseSuccess>;
|
|
2007
|
+
//#endregion
|
|
2008
|
+
//#region src/workflows/interfaces/list-workflows.interface.d.ts
|
|
2009
|
+
type ListWorkflowsOptions = PaginationOptions;
|
|
2010
|
+
type ListWorkflowsResponseSuccess = PaginatedData<Workflow[]>;
|
|
2011
|
+
type ListWorkflowsResponse = Response<ListWorkflowsResponseSuccess>;
|
|
2012
|
+
//#endregion
|
|
2013
|
+
//#region src/workflows/interfaces/remove-workflow.interface.d.ts
|
|
2014
|
+
interface RemoveWorkflowResponseSuccess extends Pick<Workflow, 'id'> {
|
|
2015
|
+
object: 'workflow';
|
|
2016
|
+
deleted: boolean;
|
|
2017
|
+
}
|
|
2018
|
+
type RemoveWorkflowResponse = Response<RemoveWorkflowResponseSuccess>;
|
|
2019
|
+
//#endregion
|
|
2020
|
+
//#region src/workflows/interfaces/update-workflow.interface.d.ts
|
|
2021
|
+
interface UpdateWorkflowOptions {
|
|
2022
|
+
status: WorkflowStatus;
|
|
2023
|
+
}
|
|
2024
|
+
interface UpdateWorkflowResponseSuccess extends Pick<Workflow, 'id' | 'status'> {
|
|
2025
|
+
object: 'workflow';
|
|
2026
|
+
}
|
|
2027
|
+
type UpdateWorkflowResponse = Response<UpdateWorkflowResponseSuccess>;
|
|
2028
|
+
//#endregion
|
|
2029
|
+
//#region src/workflows/workflows.d.ts
|
|
2030
|
+
declare class Workflows {
|
|
2031
|
+
private readonly resend;
|
|
2032
|
+
readonly runs: WorkflowRuns;
|
|
2033
|
+
constructor(resend: Resend);
|
|
2034
|
+
create(payload: CreateWorkflowOptions): Promise<CreateWorkflowResponse>;
|
|
2035
|
+
list(options?: ListWorkflowsOptions): Promise<ListWorkflowsResponse>;
|
|
2036
|
+
get(id: string): Promise<GetWorkflowResponse>;
|
|
2037
|
+
remove(id: string): Promise<RemoveWorkflowResponse>;
|
|
2038
|
+
update(id: string, payload: UpdateWorkflowOptions): Promise<UpdateWorkflowResponse>;
|
|
2039
|
+
}
|
|
2040
|
+
//#endregion
|
|
1722
2041
|
//#region src/resend.d.ts
|
|
1723
2042
|
declare class Resend {
|
|
1724
2043
|
readonly key?: string | undefined;
|
|
@@ -1735,9 +2054,11 @@ declare class Resend {
|
|
|
1735
2054
|
readonly contactProperties: ContactProperties;
|
|
1736
2055
|
readonly domains: Domains;
|
|
1737
2056
|
readonly emails: Emails;
|
|
2057
|
+
readonly events: Events;
|
|
1738
2058
|
readonly webhooks: Webhooks;
|
|
1739
2059
|
readonly templates: Templates;
|
|
1740
2060
|
readonly topics: Topics;
|
|
2061
|
+
readonly workflows: Workflows;
|
|
1741
2062
|
constructor(key?: string | undefined);
|
|
1742
2063
|
fetchRequest<T>(path: string, options?: {}): Promise<Response<T>>;
|
|
1743
2064
|
post<T>(path: string, entity?: unknown, options?: PostOptions & IdempotentRequest): Promise<Response<T>>;
|
|
@@ -1747,4 +2068,4 @@ declare class Resend {
|
|
|
1747
2068
|
delete<T>(path: string, query?: unknown): Promise<Response<T>>;
|
|
1748
2069
|
}
|
|
1749
2070
|
//#endregion
|
|
1750
|
-
export { AddContactSegmentOptions, AddContactSegmentResponse, AddContactSegmentResponseSuccess, ApiContactProperty, ApiKey, Attachment, AttachmentData, Broadcast, CancelEmailResponse, CancelEmailResponseSuccess, 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, 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, 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, ListReceivingEmail, ListReceivingEmailsOptions, ListReceivingEmailsResponse, ListReceivingEmailsResponseSuccess, ListSegmentsOptions, ListSegmentsResponse, ListSegmentsResponseSuccess, ListTemplatesOptions, ListTemplatesResponse, ListTemplatesResponseSuccess, ListTopicsResponse, ListTopicsResponseSuccess, ListWebhooksOptions, ListWebhooksResponse, ListWebhooksResponseSuccess, PaginatedData, PaginationOptions, PatchOptions, PostOptions, PublishTemplateResponse, PublishTemplateResponseSuccess, PutOptions, ReceivingRecord, RemoveApiKeyResponse, RemoveApiKeyResponseSuccess, RemoveBroadcastResponse, RemoveBroadcastResponseSuccess, RemoveContactOptions, RemoveContactPropertyResponse, RemoveContactPropertyResponseSuccess, RemoveContactSegmentOptions, RemoveContactSegmentResponse, RemoveContactSegmentResponseSuccess, RemoveContactsResponse, RemoveContactsResponseSuccess, RemoveDomainsResponse, RemoveDomainsResponseSuccess, RemoveSegmentResponse, RemoveSegmentResponseSuccess, RemoveTemplateResponse, RemoveTemplateResponseSuccess, RemoveTopicResponse, RemoveTopicResponseSuccess, RemoveWebhookResponse, RemoveWebhookResponseSuccess, RequireAtLeastOne, Resend, type Response, Segment, SelectingField, SendBroadcastOptions, SendBroadcastRequestOptions, SendBroadcastResponse, SendBroadcastResponseSuccess, Tag, Template, TemplateVariable, Topic, UpdateBroadcastOptions, UpdateBroadcastResponse, UpdateBroadcastResponseSuccess, UpdateContactOptions, UpdateContactPropertyApiOptions, UpdateContactPropertyOptions, UpdateContactPropertyResponse, UpdateContactPropertyResponseSuccess, UpdateContactResponse, UpdateContactResponseSuccess, UpdateContactTopicsOptions, UpdateContactTopicsRequestOptions, UpdateContactTopicsResponse, UpdateContactTopicsResponseSuccess, UpdateDomainsOptions, UpdateDomainsResponse, UpdateDomainsResponseSuccess, UpdateEmailOptions, UpdateEmailResponse, UpdateEmailResponseSuccess, UpdateTemplateOptions, UpdateTemplateResponse, UpdateTemplateResponseSuccess, UpdateTopicOptions, UpdateTopicResponse, UpdateTopicResponseSuccess, UpdateWebhookOptions, UpdateWebhookResponse, UpdateWebhookResponseSuccess, VerifyDomainsResponse, VerifyDomainsResponseSuccess, Webhook, WebhookEvent, WebhookEventPayload };
|
|
2071
|
+
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, GetWorkflowRunOptions, GetWorkflowRunResponse, GetWorkflowRunResponseSuccess, GetWorkflowRunStepOptions, GetWorkflowRunStepResponse, GetWorkflowRunStepResponseSuccess, 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, ListWorkflowRunStepsOptions, ListWorkflowRunStepsResponse, ListWorkflowRunStepsResponseSuccess, ListWorkflowRunsOptions, ListWorkflowRunsResponse, ListWorkflowRunsResponseSuccess, 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, WorkflowRun, WorkflowRunItem, WorkflowRunStatus, WorkflowRunStep, WorkflowRunStepItem, WorkflowRunStepStatus, WorkflowRunTrigger, WorkflowStatus, WorkflowStep, WorkflowStepType };
|
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.1";
|
|
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,65 @@ var Webhooks = class {
|
|
|
877
970
|
}
|
|
878
971
|
};
|
|
879
972
|
|
|
973
|
+
//#endregion
|
|
974
|
+
//#region src/workflow-run-steps/workflow-run-steps.ts
|
|
975
|
+
var WorkflowRunSteps = class {
|
|
976
|
+
constructor(resend) {
|
|
977
|
+
this.resend = resend;
|
|
978
|
+
}
|
|
979
|
+
async get(options) {
|
|
980
|
+
return await this.resend.get(`/workflows/${options.workflowId}/runs/${options.runId}/steps/${options.stepId}`);
|
|
981
|
+
}
|
|
982
|
+
async list(options) {
|
|
983
|
+
const queryString = buildPaginationQuery(options);
|
|
984
|
+
const url = queryString ? `/workflows/${options.workflowId}/runs/${options.runId}/steps?${queryString}` : `/workflows/${options.workflowId}/runs/${options.runId}/steps`;
|
|
985
|
+
return await this.resend.get(url);
|
|
986
|
+
}
|
|
987
|
+
};
|
|
988
|
+
|
|
989
|
+
//#endregion
|
|
990
|
+
//#region src/workflow-runs/workflow-runs.ts
|
|
991
|
+
var WorkflowRuns = class {
|
|
992
|
+
constructor(resend) {
|
|
993
|
+
this.resend = resend;
|
|
994
|
+
this.steps = new WorkflowRunSteps(resend);
|
|
995
|
+
}
|
|
996
|
+
async get(options) {
|
|
997
|
+
return await this.resend.get(`/workflows/${options.workflowId}/runs/${options.runId}`);
|
|
998
|
+
}
|
|
999
|
+
async list(options) {
|
|
1000
|
+
const queryString = buildPaginationQuery(options);
|
|
1001
|
+
const url = queryString ? `/workflows/${options.workflowId}/runs?${queryString}` : `/workflows/${options.workflowId}/runs`;
|
|
1002
|
+
return await this.resend.get(url);
|
|
1003
|
+
}
|
|
1004
|
+
};
|
|
1005
|
+
|
|
1006
|
+
//#endregion
|
|
1007
|
+
//#region src/workflows/workflows.ts
|
|
1008
|
+
var Workflows = class {
|
|
1009
|
+
constructor(resend) {
|
|
1010
|
+
this.resend = resend;
|
|
1011
|
+
this.runs = new WorkflowRuns(this.resend);
|
|
1012
|
+
}
|
|
1013
|
+
async create(payload) {
|
|
1014
|
+
return await this.resend.post("/workflows", parseWorkflowToApiOptions(payload));
|
|
1015
|
+
}
|
|
1016
|
+
async list(options = {}) {
|
|
1017
|
+
const queryString = buildPaginationQuery(options);
|
|
1018
|
+
const url = queryString ? `/workflows?${queryString}` : "/workflows";
|
|
1019
|
+
return await this.resend.get(url);
|
|
1020
|
+
}
|
|
1021
|
+
async get(id) {
|
|
1022
|
+
return await this.resend.get(`/workflows/${id}`);
|
|
1023
|
+
}
|
|
1024
|
+
async remove(id) {
|
|
1025
|
+
return await this.resend.delete(`/workflows/${id}`);
|
|
1026
|
+
}
|
|
1027
|
+
async update(id, payload) {
|
|
1028
|
+
return await this.resend.patch(`/workflows/${id}`, payload);
|
|
1029
|
+
}
|
|
1030
|
+
};
|
|
1031
|
+
|
|
880
1032
|
//#endregion
|
|
881
1033
|
//#region src/resend.ts
|
|
882
1034
|
const defaultBaseUrl = "https://api.resend.com";
|
|
@@ -895,9 +1047,11 @@ var Resend = class {
|
|
|
895
1047
|
this.contactProperties = new ContactProperties(this);
|
|
896
1048
|
this.domains = new Domains(this);
|
|
897
1049
|
this.emails = new Emails(this);
|
|
1050
|
+
this.events = new Events(this);
|
|
898
1051
|
this.webhooks = new Webhooks(this);
|
|
899
1052
|
this.templates = new Templates(this);
|
|
900
1053
|
this.topics = new Topics(this);
|
|
1054
|
+
this.workflows = new Workflows(this);
|
|
901
1055
|
if (!key) {
|
|
902
1056
|
if (typeof process !== "undefined" && process.env) this.key = process.env.RESEND_API_KEY;
|
|
903
1057
|
if (!this.key) throw new Error("Missing API key. Pass it to the constructor `new Resend(\"re_123\")`");
|