resend 6.37.0 → 6.38.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 +35 -21
- package/dist/index.d.cts +1 -0
- package/dist/index.d.mts +1 -0
- package/dist/index.mjs +35 -21
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -57,7 +57,7 @@ const MOVE_THREAD_FOLDERS = [
|
|
|
57
57
|
];
|
|
58
58
|
//#endregion
|
|
59
59
|
//#region package.json
|
|
60
|
-
var version = "6.
|
|
60
|
+
var version = "6.38.1";
|
|
61
61
|
//#endregion
|
|
62
62
|
//#region src/common/utils/build-pagination-query.ts
|
|
63
63
|
function buildPaginationUrl(base, options) {
|
|
@@ -119,12 +119,37 @@ var AutomationRuns = class {
|
|
|
119
119
|
};
|
|
120
120
|
//#endregion
|
|
121
121
|
//#region src/common/utils/parse-automation-to-api-options.ts
|
|
122
|
+
const TRIGGER_FIELDS = { eventName: "event_name" };
|
|
123
|
+
const SEND_EMAIL_FIELDS = {
|
|
124
|
+
template: "template",
|
|
125
|
+
subject: "subject",
|
|
126
|
+
from: "from",
|
|
127
|
+
replyTo: "reply_to",
|
|
128
|
+
topicId: "topic_id"
|
|
129
|
+
};
|
|
130
|
+
const WAIT_FOR_EVENT_FIELDS = {
|
|
131
|
+
eventName: "event_name",
|
|
132
|
+
timeout: "timeout",
|
|
133
|
+
filterRule: "filter_rule"
|
|
134
|
+
};
|
|
135
|
+
const CONTACT_UPDATE_FIELDS = {
|
|
136
|
+
firstName: "first_name",
|
|
137
|
+
lastName: "last_name",
|
|
138
|
+
unsubscribed: "unsubscribed",
|
|
139
|
+
properties: "properties"
|
|
140
|
+
};
|
|
141
|
+
const ADD_TO_SEGMENT_FIELDS = { segmentId: "segment_id" };
|
|
142
|
+
function renameFields(config, fields) {
|
|
143
|
+
const result = {};
|
|
144
|
+
for (const sdkField of Object.keys(fields)) result[fields[sdkField]] = config[sdkField];
|
|
145
|
+
return result;
|
|
146
|
+
}
|
|
122
147
|
function parseStepConfig(step) {
|
|
123
148
|
switch (step.type) {
|
|
124
149
|
case "trigger": return {
|
|
125
150
|
key: step.key,
|
|
126
151
|
type: step.type,
|
|
127
|
-
config:
|
|
152
|
+
config: renameFields(step.config, TRIGGER_FIELDS)
|
|
128
153
|
};
|
|
129
154
|
case "delay": return {
|
|
130
155
|
key: step.key,
|
|
@@ -134,21 +159,12 @@ function parseStepConfig(step) {
|
|
|
134
159
|
case "send_email": return {
|
|
135
160
|
key: step.key,
|
|
136
161
|
type: step.type,
|
|
137
|
-
config:
|
|
138
|
-
template: step.config.template,
|
|
139
|
-
subject: step.config.subject,
|
|
140
|
-
from: step.config.from,
|
|
141
|
-
reply_to: step.config.replyTo
|
|
142
|
-
}
|
|
162
|
+
config: renameFields(step.config, SEND_EMAIL_FIELDS)
|
|
143
163
|
};
|
|
144
164
|
case "wait_for_event": return {
|
|
145
165
|
key: step.key,
|
|
146
166
|
type: step.type,
|
|
147
|
-
config:
|
|
148
|
-
event_name: step.config.eventName,
|
|
149
|
-
timeout: step.config.timeout,
|
|
150
|
-
filter_rule: step.config.filterRule
|
|
151
|
-
}
|
|
167
|
+
config: renameFields(step.config, WAIT_FOR_EVENT_FIELDS)
|
|
152
168
|
};
|
|
153
169
|
case "condition": return {
|
|
154
170
|
key: step.key,
|
|
@@ -158,12 +174,7 @@ function parseStepConfig(step) {
|
|
|
158
174
|
case "contact_update": return {
|
|
159
175
|
key: step.key,
|
|
160
176
|
type: step.type,
|
|
161
|
-
config:
|
|
162
|
-
first_name: step.config.firstName,
|
|
163
|
-
last_name: step.config.lastName,
|
|
164
|
-
unsubscribed: step.config.unsubscribed,
|
|
165
|
-
properties: step.config.properties
|
|
166
|
-
}
|
|
177
|
+
config: renameFields(step.config, CONTACT_UPDATE_FIELDS)
|
|
167
178
|
};
|
|
168
179
|
case "contact_delete": return {
|
|
169
180
|
key: step.key,
|
|
@@ -173,7 +184,7 @@ function parseStepConfig(step) {
|
|
|
173
184
|
case "add_to_segment": return {
|
|
174
185
|
key: step.key,
|
|
175
186
|
type: step.type,
|
|
176
|
-
config:
|
|
187
|
+
config: renameFields(step.config, ADD_TO_SEGMENT_FIELDS)
|
|
177
188
|
};
|
|
178
189
|
}
|
|
179
190
|
}
|
|
@@ -632,6 +643,9 @@ var ContactTopics = class {
|
|
|
632
643
|
};
|
|
633
644
|
//#endregion
|
|
634
645
|
//#region src/contacts/contacts.ts
|
|
646
|
+
function isLegacyCreateContactOptions(payload) {
|
|
647
|
+
return "audienceId" in payload && Boolean(payload.audienceId);
|
|
648
|
+
}
|
|
635
649
|
var Contacts = class {
|
|
636
650
|
constructor(resend) {
|
|
637
651
|
this.resend = resend;
|
|
@@ -640,7 +654,7 @@ var Contacts = class {
|
|
|
640
654
|
this.segments = new ContactSegments(this.resend);
|
|
641
655
|
}
|
|
642
656
|
async create(payload, requestOptions = {}) {
|
|
643
|
-
if (
|
|
657
|
+
if (isLegacyCreateContactOptions(payload)) {
|
|
644
658
|
if ("segments" in payload || "topics" in payload) return {
|
|
645
659
|
data: null,
|
|
646
660
|
headers: null,
|
package/dist/index.d.cts
CHANGED
package/dist/index.d.mts
CHANGED
package/dist/index.mjs
CHANGED
|
@@ -33,7 +33,7 @@ const MOVE_THREAD_FOLDERS = [
|
|
|
33
33
|
];
|
|
34
34
|
//#endregion
|
|
35
35
|
//#region package.json
|
|
36
|
-
var version = "6.
|
|
36
|
+
var version = "6.38.1";
|
|
37
37
|
//#endregion
|
|
38
38
|
//#region src/common/utils/build-pagination-query.ts
|
|
39
39
|
function buildPaginationUrl(base, options) {
|
|
@@ -95,12 +95,37 @@ var AutomationRuns = class {
|
|
|
95
95
|
};
|
|
96
96
|
//#endregion
|
|
97
97
|
//#region src/common/utils/parse-automation-to-api-options.ts
|
|
98
|
+
const TRIGGER_FIELDS = { eventName: "event_name" };
|
|
99
|
+
const SEND_EMAIL_FIELDS = {
|
|
100
|
+
template: "template",
|
|
101
|
+
subject: "subject",
|
|
102
|
+
from: "from",
|
|
103
|
+
replyTo: "reply_to",
|
|
104
|
+
topicId: "topic_id"
|
|
105
|
+
};
|
|
106
|
+
const WAIT_FOR_EVENT_FIELDS = {
|
|
107
|
+
eventName: "event_name",
|
|
108
|
+
timeout: "timeout",
|
|
109
|
+
filterRule: "filter_rule"
|
|
110
|
+
};
|
|
111
|
+
const CONTACT_UPDATE_FIELDS = {
|
|
112
|
+
firstName: "first_name",
|
|
113
|
+
lastName: "last_name",
|
|
114
|
+
unsubscribed: "unsubscribed",
|
|
115
|
+
properties: "properties"
|
|
116
|
+
};
|
|
117
|
+
const ADD_TO_SEGMENT_FIELDS = { segmentId: "segment_id" };
|
|
118
|
+
function renameFields(config, fields) {
|
|
119
|
+
const result = {};
|
|
120
|
+
for (const sdkField of Object.keys(fields)) result[fields[sdkField]] = config[sdkField];
|
|
121
|
+
return result;
|
|
122
|
+
}
|
|
98
123
|
function parseStepConfig(step) {
|
|
99
124
|
switch (step.type) {
|
|
100
125
|
case "trigger": return {
|
|
101
126
|
key: step.key,
|
|
102
127
|
type: step.type,
|
|
103
|
-
config:
|
|
128
|
+
config: renameFields(step.config, TRIGGER_FIELDS)
|
|
104
129
|
};
|
|
105
130
|
case "delay": return {
|
|
106
131
|
key: step.key,
|
|
@@ -110,21 +135,12 @@ function parseStepConfig(step) {
|
|
|
110
135
|
case "send_email": return {
|
|
111
136
|
key: step.key,
|
|
112
137
|
type: step.type,
|
|
113
|
-
config:
|
|
114
|
-
template: step.config.template,
|
|
115
|
-
subject: step.config.subject,
|
|
116
|
-
from: step.config.from,
|
|
117
|
-
reply_to: step.config.replyTo
|
|
118
|
-
}
|
|
138
|
+
config: renameFields(step.config, SEND_EMAIL_FIELDS)
|
|
119
139
|
};
|
|
120
140
|
case "wait_for_event": return {
|
|
121
141
|
key: step.key,
|
|
122
142
|
type: step.type,
|
|
123
|
-
config:
|
|
124
|
-
event_name: step.config.eventName,
|
|
125
|
-
timeout: step.config.timeout,
|
|
126
|
-
filter_rule: step.config.filterRule
|
|
127
|
-
}
|
|
143
|
+
config: renameFields(step.config, WAIT_FOR_EVENT_FIELDS)
|
|
128
144
|
};
|
|
129
145
|
case "condition": return {
|
|
130
146
|
key: step.key,
|
|
@@ -134,12 +150,7 @@ function parseStepConfig(step) {
|
|
|
134
150
|
case "contact_update": return {
|
|
135
151
|
key: step.key,
|
|
136
152
|
type: step.type,
|
|
137
|
-
config:
|
|
138
|
-
first_name: step.config.firstName,
|
|
139
|
-
last_name: step.config.lastName,
|
|
140
|
-
unsubscribed: step.config.unsubscribed,
|
|
141
|
-
properties: step.config.properties
|
|
142
|
-
}
|
|
153
|
+
config: renameFields(step.config, CONTACT_UPDATE_FIELDS)
|
|
143
154
|
};
|
|
144
155
|
case "contact_delete": return {
|
|
145
156
|
key: step.key,
|
|
@@ -149,7 +160,7 @@ function parseStepConfig(step) {
|
|
|
149
160
|
case "add_to_segment": return {
|
|
150
161
|
key: step.key,
|
|
151
162
|
type: step.type,
|
|
152
|
-
config:
|
|
163
|
+
config: renameFields(step.config, ADD_TO_SEGMENT_FIELDS)
|
|
153
164
|
};
|
|
154
165
|
}
|
|
155
166
|
}
|
|
@@ -608,6 +619,9 @@ var ContactTopics = class {
|
|
|
608
619
|
};
|
|
609
620
|
//#endregion
|
|
610
621
|
//#region src/contacts/contacts.ts
|
|
622
|
+
function isLegacyCreateContactOptions(payload) {
|
|
623
|
+
return "audienceId" in payload && Boolean(payload.audienceId);
|
|
624
|
+
}
|
|
611
625
|
var Contacts = class {
|
|
612
626
|
constructor(resend) {
|
|
613
627
|
this.resend = resend;
|
|
@@ -616,7 +630,7 @@ var Contacts = class {
|
|
|
616
630
|
this.segments = new ContactSegments(this.resend);
|
|
617
631
|
}
|
|
618
632
|
async create(payload, requestOptions = {}) {
|
|
619
|
-
if (
|
|
633
|
+
if (isLegacyCreateContactOptions(payload)) {
|
|
620
634
|
if ("segments" in payload || "topics" in payload) return {
|
|
621
635
|
data: null,
|
|
622
636
|
headers: null,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "resend",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.38.1",
|
|
4
4
|
"description": "Node.js library for the Resend API",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -77,11 +77,11 @@
|
|
|
77
77
|
"pkg-pr-new": "0.0.88",
|
|
78
78
|
"react": "19.3.0",
|
|
79
79
|
"react-dom": "19.3.0",
|
|
80
|
-
"rimraf": "6.1.
|
|
80
|
+
"rimraf": "6.1.4",
|
|
81
81
|
"tsdown": "0.23.0",
|
|
82
82
|
"typescript": "6.0.3",
|
|
83
|
-
"vitest": "4.1.
|
|
83
|
+
"vitest": "4.1.12",
|
|
84
84
|
"vitest-fetch-mock": "0.4.5"
|
|
85
85
|
},
|
|
86
|
-
"packageManager": "pnpm@
|
|
86
|
+
"packageManager": "pnpm@12.18.0"
|
|
87
87
|
}
|