resend 6.10.0-preview-workflows.1 → 6.10.0-preview-workflows.2

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.mjs CHANGED
@@ -1,9 +1,7 @@
1
1
  import PostalMime from "postal-mime";
2
2
  import { Webhook } from "svix";
3
-
4
3
  //#region package.json
5
- var version = "6.10.0-preview-workflows.1";
6
-
4
+ var version = "6.10.0-preview-workflows.2";
7
5
  //#endregion
8
6
  //#region src/common/utils/build-pagination-query.ts
9
7
  /**
@@ -18,7 +16,6 @@ function buildPaginationQuery(options) {
18
16
  if ("before" in options && options.before !== void 0) searchParams.set("before", options.before);
19
17
  return searchParams.toString();
20
18
  }
21
-
22
19
  //#endregion
23
20
  //#region src/api-keys/api-keys.ts
24
21
  var ApiKeys = class {
@@ -37,7 +34,126 @@ var ApiKeys = class {
37
34
  return await this.resend.delete(`/api-keys/${id}`);
38
35
  }
39
36
  };
40
-
37
+ //#endregion
38
+ //#region src/automation-run-steps/automation-run-steps.ts
39
+ var AutomationRunSteps = class {
40
+ constructor(resend) {
41
+ this.resend = resend;
42
+ }
43
+ async get(options) {
44
+ return await this.resend.get(`/automations/${options.automationId}/runs/${options.runId}/steps/${options.stepId}`);
45
+ }
46
+ async list(options) {
47
+ const queryString = buildPaginationQuery(options);
48
+ const url = queryString ? `/automations/${options.automationId}/runs/${options.runId}/steps?${queryString}` : `/automations/${options.automationId}/runs/${options.runId}/steps`;
49
+ return await this.resend.get(url);
50
+ }
51
+ };
52
+ //#endregion
53
+ //#region src/automation-runs/automation-runs.ts
54
+ var AutomationRuns = class {
55
+ constructor(resend) {
56
+ this.resend = resend;
57
+ this.steps = new AutomationRunSteps(resend);
58
+ }
59
+ async get(options) {
60
+ return await this.resend.get(`/automations/${options.automationId}/runs/${options.runId}`);
61
+ }
62
+ async list(options) {
63
+ const queryString = buildPaginationQuery(options);
64
+ const url = queryString ? `/automations/${options.automationId}/runs?${queryString}` : `/automations/${options.automationId}/runs`;
65
+ return await this.resend.get(url);
66
+ }
67
+ };
68
+ //#endregion
69
+ //#region src/common/utils/parse-automation-to-api-options.ts
70
+ function parseStepConfig(step) {
71
+ switch (step.type) {
72
+ case "trigger": return {
73
+ ref: step.ref,
74
+ type: step.type,
75
+ config: { event_name: step.config.eventName }
76
+ };
77
+ case "delay": return {
78
+ ref: step.ref,
79
+ type: step.type,
80
+ config: step.config
81
+ };
82
+ case "send_email": return {
83
+ ref: step.ref,
84
+ type: step.type,
85
+ config: {
86
+ template_id: step.config.templateId,
87
+ subject: step.config.subject,
88
+ from: step.config.from,
89
+ reply_to: step.config.replyTo,
90
+ variables: step.config.variables
91
+ }
92
+ };
93
+ case "wait_for_event": return {
94
+ ref: step.ref,
95
+ type: step.type,
96
+ config: {
97
+ event_name: step.config.eventName,
98
+ timeout_seconds: step.config.timeoutSeconds,
99
+ filter_rule: step.config.filterRule
100
+ }
101
+ };
102
+ case "condition": return {
103
+ ref: step.ref,
104
+ type: step.type,
105
+ config: step.config
106
+ };
107
+ }
108
+ }
109
+ function parseEdge(edge) {
110
+ return {
111
+ from: edge.from,
112
+ to: edge.to,
113
+ edge_type: edge.edgeType
114
+ };
115
+ }
116
+ function parseAutomationToApiOptions(automation) {
117
+ return {
118
+ name: automation.name,
119
+ status: automation.status,
120
+ steps: automation.steps.map(parseStepConfig),
121
+ edges: automation.edges.map(parseEdge)
122
+ };
123
+ }
124
+ function parseEventToApiOptions(event) {
125
+ return {
126
+ event: event.event,
127
+ contact_id: event.contactId,
128
+ email: event.email,
129
+ payload: event.payload
130
+ };
131
+ }
132
+ //#endregion
133
+ //#region src/automations/automations.ts
134
+ var Automations = class {
135
+ constructor(resend) {
136
+ this.resend = resend;
137
+ this.runs = new AutomationRuns(this.resend);
138
+ }
139
+ async create(payload) {
140
+ return await this.resend.post("/automations", parseAutomationToApiOptions(payload));
141
+ }
142
+ async list(options = {}) {
143
+ const queryString = buildPaginationQuery(options);
144
+ const url = queryString ? `/automations?${queryString}` : "/automations";
145
+ return await this.resend.get(url);
146
+ }
147
+ async get(id) {
148
+ return await this.resend.get(`/automations/${id}`);
149
+ }
150
+ async remove(id) {
151
+ return await this.resend.delete(`/automations/${id}`);
152
+ }
153
+ async update(id, payload) {
154
+ return await this.resend.patch(`/automations/${id}`, payload);
155
+ }
156
+ };
41
157
  //#endregion
42
158
  //#region src/common/utils/parse-email-to-api-options.ts
43
159
  function parseAttachments(attachments) {
@@ -70,7 +186,6 @@ function parseEmailToApiOptions(email) {
70
186
  topic_id: email.topicId
71
187
  };
72
188
  }
73
-
74
189
  //#endregion
75
190
  //#region src/render.ts
76
191
  async function render(node) {
@@ -82,7 +197,6 @@ async function render(node) {
82
197
  }
83
198
  return render(node);
84
199
  }
85
-
86
200
  //#endregion
87
201
  //#region src/batch/batch.ts
88
202
  var Batch = class {
@@ -110,7 +224,6 @@ var Batch = class {
110
224
  });
111
225
  }
112
226
  };
113
-
114
227
  //#endregion
115
228
  //#region src/broadcasts/broadcasts.ts
116
229
  var Broadcasts = class {
@@ -164,7 +277,6 @@ var Broadcasts = class {
164
277
  });
165
278
  }
166
279
  };
167
-
168
280
  //#endregion
169
281
  //#region src/common/utils/parse-contact-properties-to-api-options.ts
170
282
  function parseContactPropertyFromApi(contactProperty) {
@@ -184,7 +296,6 @@ function parseContactPropertyToApiOptions(contactProperty) {
184
296
  };
185
297
  return { fallback_value: contactProperty.fallbackValue };
186
298
  }
187
-
188
299
  //#endregion
189
300
  //#region src/contact-properties/contact-properties.ts
190
301
  var ContactProperties = class {
@@ -256,7 +367,6 @@ var ContactProperties = class {
256
367
  return await this.resend.delete(`/contact-properties/${id}`);
257
368
  }
258
369
  };
259
-
260
370
  //#endregion
261
371
  //#region src/contacts/segments/contact-segments.ts
262
372
  var ContactSegments = class {
@@ -305,7 +415,6 @@ var ContactSegments = class {
305
415
  return this.resend.delete(`/contacts/${identifier}/segments/${options.segmentId}`);
306
416
  }
307
417
  };
308
-
309
418
  //#endregion
310
419
  //#region src/contacts/topics/contact-topics.ts
311
420
  var ContactTopics = class {
@@ -341,7 +450,6 @@ var ContactTopics = class {
341
450
  return this.resend.get(url);
342
451
  }
343
452
  };
344
-
345
453
  //#endregion
346
454
  //#region src/contacts/contacts.ts
347
455
  var Contacts = class {
@@ -442,7 +550,6 @@ var Contacts = class {
442
550
  return this.resend.delete(`/audiences/${payload.audienceId}/contacts/${payload?.email ? payload?.email : payload?.id}`);
443
551
  }
444
552
  };
445
-
446
553
  //#endregion
447
554
  //#region src/common/utils/parse-domain-to-api-options.ts
448
555
  function parseDomainToApiOptions(domain) {
@@ -456,7 +563,6 @@ function parseDomainToApiOptions(domain) {
456
563
  tls: domain.tls
457
564
  };
458
565
  }
459
-
460
566
  //#endregion
461
567
  //#region src/domains/domains.ts
462
568
  var Domains = class {
@@ -489,7 +595,6 @@ var Domains = class {
489
595
  return await this.resend.post(`/domains/${id}/verify`);
490
596
  }
491
597
  };
492
-
493
598
  //#endregion
494
599
  //#region src/emails/attachments/attachments.ts
495
600
  var Attachments$1 = class {
@@ -507,7 +612,6 @@ var Attachments$1 = class {
507
612
  return await this.resend.get(url);
508
613
  }
509
614
  };
510
-
511
615
  //#endregion
512
616
  //#region src/emails/receiving/attachments/attachments.ts
513
617
  var Attachments = class {
@@ -525,7 +629,6 @@ var Attachments = class {
525
629
  return await this.resend.get(url);
526
630
  }
527
631
  };
528
-
529
632
  //#endregion
530
633
  //#region src/emails/receiving/receiving.ts
531
634
  var Receiving = class {
@@ -643,7 +746,6 @@ var Receiving = class {
643
746
  });
644
747
  }
645
748
  };
646
-
647
749
  //#endregion
648
750
  //#region src/emails/emails.ts
649
751
  var Emails = class {
@@ -674,72 +776,6 @@ var Emails = class {
674
776
  return await this.resend.post(`/emails/${id}/cancel`);
675
777
  }
676
778
  };
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
779
  //#endregion
744
780
  //#region src/events/events.ts
745
781
  var Events = class {
@@ -747,7 +783,7 @@ var Events = class {
747
783
  this.resend = resend;
748
784
  }
749
785
  async send(payload) {
750
- return await this.resend.post("/events/send", parseWorkflowEventToApiOptions(payload));
786
+ return await this.resend.post("/events/send", parseEventToApiOptions(payload));
751
787
  }
752
788
  async create(payload) {
753
789
  return await this.resend.post("/events", payload);
@@ -767,7 +803,6 @@ var Events = class {
767
803
  return await this.resend.delete(`/events/${encodeURIComponent(identifier)}`);
768
804
  }
769
805
  };
770
-
771
806
  //#endregion
772
807
  //#region src/segments/segments.ts
773
808
  var Segments = class {
@@ -789,7 +824,6 @@ var Segments = class {
789
824
  return await this.resend.delete(`/segments/${id}`);
790
825
  }
791
826
  };
792
-
793
827
  //#endregion
794
828
  //#region src/common/utils/get-pagination-query-properties.ts
795
829
  function getPaginationQueryProperties(options = {}) {
@@ -799,7 +833,6 @@ function getPaginationQueryProperties(options = {}) {
799
833
  if (options.limit) query.set("limit", options.limit.toString());
800
834
  return query.size > 0 ? `?${query.toString()}` : "";
801
835
  }
802
-
803
836
  //#endregion
804
837
  //#region src/common/utils/parse-template-to-api-options.ts
805
838
  function parseVariables(variables) {
@@ -821,7 +854,6 @@ function parseTemplateToApiOptions(template) {
821
854
  variables: parseVariables(template.variables)
822
855
  };
823
856
  }
824
-
825
857
  //#endregion
826
858
  //#region src/templates/chainable-template-result.ts
827
859
  var ChainableTemplateResult = class {
@@ -842,7 +874,6 @@ var ChainableTemplateResult = class {
842
874
  return this.publishFn(data.id);
843
875
  }
844
876
  };
845
-
846
877
  //#endregion
847
878
  //#region src/templates/templates.ts
848
879
  var Templates = class {
@@ -883,7 +914,6 @@ var Templates = class {
883
914
  return await this.resend.patch(`/templates/${identifier}`, parseTemplateToApiOptions(payload));
884
915
  }
885
916
  };
886
-
887
917
  //#endregion
888
918
  //#region src/topics/topics.ts
889
919
  var Topics = class {
@@ -937,7 +967,6 @@ var Topics = class {
937
967
  return await this.resend.delete(`/topics/${id}`);
938
968
  }
939
969
  };
940
-
941
970
  //#endregion
942
971
  //#region src/webhooks/webhooks.ts
943
972
  var Webhooks = class {
@@ -969,7 +998,6 @@ var Webhooks = class {
969
998
  });
970
999
  }
971
1000
  };
972
-
973
1001
  //#endregion
974
1002
  //#region src/workflow-run-steps/workflow-run-steps.ts
975
1003
  var WorkflowRunSteps = class {
@@ -977,15 +1005,14 @@ var WorkflowRunSteps = class {
977
1005
  this.resend = resend;
978
1006
  }
979
1007
  async get(options) {
980
- return await this.resend.get(`/workflows/${options.workflowId}/runs/${options.runId}/steps/${options.stepId}`);
1008
+ return await this.resend.get(`/automations/${options.workflowId}/runs/${options.runId}/steps/${options.stepId}`);
981
1009
  }
982
1010
  async list(options) {
983
1011
  const queryString = buildPaginationQuery(options);
984
- const url = queryString ? `/workflows/${options.workflowId}/runs/${options.runId}/steps?${queryString}` : `/workflows/${options.workflowId}/runs/${options.runId}/steps`;
1012
+ const url = queryString ? `/automations/${options.workflowId}/runs/${options.runId}/steps?${queryString}` : `/automations/${options.workflowId}/runs/${options.runId}/steps`;
985
1013
  return await this.resend.get(url);
986
1014
  }
987
1015
  };
988
-
989
1016
  //#endregion
990
1017
  //#region src/workflow-runs/workflow-runs.ts
991
1018
  var WorkflowRuns = class {
@@ -994,15 +1021,14 @@ var WorkflowRuns = class {
994
1021
  this.steps = new WorkflowRunSteps(resend);
995
1022
  }
996
1023
  async get(options) {
997
- return await this.resend.get(`/workflows/${options.workflowId}/runs/${options.runId}`);
1024
+ return await this.resend.get(`/automations/${options.workflowId}/runs/${options.runId}`);
998
1025
  }
999
1026
  async list(options) {
1000
1027
  const queryString = buildPaginationQuery(options);
1001
- const url = queryString ? `/workflows/${options.workflowId}/runs?${queryString}` : `/workflows/${options.workflowId}/runs`;
1028
+ const url = queryString ? `/automations/${options.workflowId}/runs?${queryString}` : `/automations/${options.workflowId}/runs`;
1002
1029
  return await this.resend.get(url);
1003
1030
  }
1004
1031
  };
1005
-
1006
1032
  //#endregion
1007
1033
  //#region src/workflows/workflows.ts
1008
1034
  var Workflows = class {
@@ -1011,24 +1037,23 @@ var Workflows = class {
1011
1037
  this.runs = new WorkflowRuns(this.resend);
1012
1038
  }
1013
1039
  async create(payload) {
1014
- return await this.resend.post("/workflows", parseWorkflowToApiOptions(payload));
1040
+ return await this.resend.post("/automations", parseAutomationToApiOptions(payload));
1015
1041
  }
1016
1042
  async list(options = {}) {
1017
1043
  const queryString = buildPaginationQuery(options);
1018
- const url = queryString ? `/workflows?${queryString}` : "/workflows";
1044
+ const url = queryString ? `/automations?${queryString}` : "/automations";
1019
1045
  return await this.resend.get(url);
1020
1046
  }
1021
1047
  async get(id) {
1022
- return await this.resend.get(`/workflows/${id}`);
1048
+ return await this.resend.get(`/automations/${id}`);
1023
1049
  }
1024
1050
  async remove(id) {
1025
- return await this.resend.delete(`/workflows/${id}`);
1051
+ return await this.resend.delete(`/automations/${id}`);
1026
1052
  }
1027
1053
  async update(id, payload) {
1028
- return await this.resend.patch(`/workflows/${id}`, payload);
1054
+ return await this.resend.patch(`/automations/${id}`, payload);
1029
1055
  }
1030
1056
  };
1031
-
1032
1057
  //#endregion
1033
1058
  //#region src/resend.ts
1034
1059
  const defaultBaseUrl = "https://api.resend.com";
@@ -1041,6 +1066,7 @@ var Resend = class {
1041
1066
  this.apiKeys = new ApiKeys(this);
1042
1067
  this.segments = new Segments(this);
1043
1068
  this.audiences = this.segments;
1069
+ this.automations = new Automations(this);
1044
1070
  this.batch = new Batch(this);
1045
1071
  this.broadcasts = new Broadcasts(this);
1046
1072
  this.contacts = new Contacts(this);
@@ -1171,6 +1197,5 @@ var Resend = class {
1171
1197
  return this.fetchRequest(path, requestOptions);
1172
1198
  }
1173
1199
  };
1174
-
1175
1200
  //#endregion
1176
- export { Resend };
1201
+ export { Resend };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "resend",
3
- "version": "6.10.0-preview-workflows.1",
3
+ "version": "6.10.0-preview-workflows.2",
4
4
  "description": "Node.js library for the Resend API",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.mjs",
@@ -29,6 +29,19 @@
29
29
  }
30
30
  }
31
31
  },
32
+ "scripts": {
33
+ "build": "tsdown src/index.ts --format esm,cjs --dts",
34
+ "integration:nextjs": "cd ./integrations/nextjs && next build --turbopack",
35
+ "lint": "biome check .",
36
+ "lint:fix": "biome check . --write",
37
+ "prepublishOnly": "pnpm run build",
38
+ "test": "vitest run",
39
+ "test:dev": "cross-env TEST_MODE=dev vitest run",
40
+ "test:integrations": "vitest run integrations",
41
+ "test:record": "rimraf --glob \"**/__recordings__\" && cross-env TEST_MODE=record vitest run",
42
+ "test:watch": "vitest",
43
+ "typecheck": "tsc --noEmit"
44
+ },
32
45
  "repository": {
33
46
  "type": "git",
34
47
  "url": "git+https://github.com/resend/resend-node.git"
@@ -41,7 +54,7 @@
41
54
  "homepage": "https://github.com/resend/resend-node#readme",
42
55
  "dependencies": {
43
56
  "postal-mime": "2.7.3",
44
- "svix": "1.84.1"
57
+ "svix": "1.86.0"
45
58
  },
46
59
  "peerDependencies": {
47
60
  "@react-email/render": "*"
@@ -52,34 +65,23 @@
52
65
  }
53
66
  },
54
67
  "devDependencies": {
55
- "@biomejs/biome": "2.3.14",
68
+ "@biomejs/biome": "2.4.6",
56
69
  "@pollyjs/adapter-fetch": "6.0.7",
57
70
  "@pollyjs/core": "6.0.6",
58
71
  "@pollyjs/persister-fs": "6.0.6",
59
72
  "@types/mailparser": "3.4.6",
60
- "@types/node": "24.10.13",
61
- "@types/react": "19.2.13",
73
+ "@types/node": "24.11.0",
74
+ "@types/react": "19.2.14",
62
75
  "cross-env": "10.1.0",
63
- "dotenv": "17.2.4",
76
+ "dotenv": "17.3.1",
64
77
  "pkg-pr-new": "0.0.65",
65
78
  "react": "19.2.4",
66
79
  "react-dom": "19.2.4",
67
- "rimraf": "6.1.2",
68
- "tsdown": "0.20.3",
80
+ "rimraf": "6.1.3",
81
+ "tsdown": "0.21.0",
69
82
  "typescript": "5.9.3",
70
83
  "vitest": "4.0.18",
71
84
  "vitest-fetch-mock": "0.4.5"
72
85
  },
73
- "scripts": {
74
- "build": "tsdown src/index.ts --format esm,cjs --dts",
75
- "integration:nextjs": "cd ./integrations/nextjs && next build --turbopack",
76
- "lint": "biome check .",
77
- "lint:fix": "biome check . --write",
78
- "test": "vitest run",
79
- "test:dev": "cross-env TEST_MODE=dev vitest run",
80
- "test:integrations": "vitest run integrations",
81
- "test:record": "rimraf --glob \"**/__recordings__\" && cross-env TEST_MODE=record vitest run",
82
- "test:watch": "vitest",
83
- "typecheck": "tsc --noEmit"
84
- }
85
- }
86
+ "packageManager": "pnpm@10.30.3"
87
+ }