resend 6.36.1 → 6.38.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +47 -21
- package/dist/index.d.cts +5 -4
- package/dist/index.d.mts +5 -4
- package/dist/index.mjs +47 -21
- package/package.json +3 -3
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.0";
|
|
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
|
}
|
|
@@ -240,9 +251,24 @@ var Automations = class {
|
|
|
240
251
|
};
|
|
241
252
|
//#endregion
|
|
242
253
|
//#region src/common/utils/parse-email-to-api-options.ts
|
|
254
|
+
function encodeBase64(bytes) {
|
|
255
|
+
if (typeof Buffer !== "undefined") return Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength).toString("base64");
|
|
256
|
+
let binary = "";
|
|
257
|
+
for (let i = 0; i < bytes.length; i += 32768) binary += String.fromCharCode(...bytes.subarray(i, i + 32768));
|
|
258
|
+
return btoa(binary);
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* JSON.stringify turns a Uint8Array into an object of indexes and an
|
|
262
|
+
* ArrayBuffer into `{}`, so binary content is sent as base64 instead.
|
|
263
|
+
*/
|
|
264
|
+
function parseAttachmentContent(content) {
|
|
265
|
+
if (ArrayBuffer.isView(content)) return encodeBase64(new Uint8Array(content.buffer, content.byteOffset, content.byteLength));
|
|
266
|
+
if (content instanceof ArrayBuffer) return encodeBase64(new Uint8Array(content));
|
|
267
|
+
return content;
|
|
268
|
+
}
|
|
243
269
|
function parseAttachments(attachments) {
|
|
244
270
|
return attachments?.map((attachment) => ({
|
|
245
|
-
content: attachment.content,
|
|
271
|
+
content: parseAttachmentContent(attachment.content),
|
|
246
272
|
filename: attachment.filename,
|
|
247
273
|
path: attachment.path,
|
|
248
274
|
content_type: attachment.contentType,
|
package/dist/index.d.cts
CHANGED
|
@@ -317,6 +317,7 @@ export interface SendEmailStepConfig {
|
|
|
317
317
|
subject?: string;
|
|
318
318
|
from?: string;
|
|
319
319
|
replyTo?: string;
|
|
320
|
+
topicId?: string;
|
|
320
321
|
}
|
|
321
322
|
export interface WaitForEventStepConfig {
|
|
322
323
|
eventName: string;
|
|
@@ -618,8 +619,8 @@ export interface CreateEmailResponseSuccess {
|
|
|
618
619
|
}
|
|
619
620
|
export type CreateEmailResponse = Response<CreateEmailResponseSuccess>;
|
|
620
621
|
export interface Attachment {
|
|
621
|
-
/** Content of an attached file. */
|
|
622
|
-
content?: string | Buffer;
|
|
622
|
+
/** Content of an attached file, as a base64 string or binary data, which is sent as base64. */
|
|
623
|
+
content?: string | Buffer | Uint8Array | ArrayBuffer;
|
|
623
624
|
/** Name of attached file. */
|
|
624
625
|
filename?: string | false | undefined;
|
|
625
626
|
/** Path where the attachment file is hosted */
|
|
@@ -1829,8 +1830,8 @@ interface InboxDraftAttachment {
|
|
|
1829
1830
|
size: number;
|
|
1830
1831
|
}
|
|
1831
1832
|
interface InboxDraftContentAttachmentOptions {
|
|
1832
|
-
/** Content of the file, as a base64 string or
|
|
1833
|
-
content: string | Buffer;
|
|
1833
|
+
/** Content of the file, as a base64 string or binary data, which is sent as base64. */
|
|
1834
|
+
content: string | Buffer | Uint8Array | ArrayBuffer;
|
|
1834
1835
|
path?: never;
|
|
1835
1836
|
filename: string;
|
|
1836
1837
|
contentType: string;
|
package/dist/index.d.mts
CHANGED
|
@@ -317,6 +317,7 @@ export interface SendEmailStepConfig {
|
|
|
317
317
|
subject?: string;
|
|
318
318
|
from?: string;
|
|
319
319
|
replyTo?: string;
|
|
320
|
+
topicId?: string;
|
|
320
321
|
}
|
|
321
322
|
export interface WaitForEventStepConfig {
|
|
322
323
|
eventName: string;
|
|
@@ -618,8 +619,8 @@ export interface CreateEmailResponseSuccess {
|
|
|
618
619
|
}
|
|
619
620
|
export type CreateEmailResponse = Response<CreateEmailResponseSuccess>;
|
|
620
621
|
export interface Attachment {
|
|
621
|
-
/** Content of an attached file. */
|
|
622
|
-
content?: string | Buffer;
|
|
622
|
+
/** Content of an attached file, as a base64 string or binary data, which is sent as base64. */
|
|
623
|
+
content?: string | Buffer | Uint8Array | ArrayBuffer;
|
|
623
624
|
/** Name of attached file. */
|
|
624
625
|
filename?: string | false | undefined;
|
|
625
626
|
/** Path where the attachment file is hosted */
|
|
@@ -1829,8 +1830,8 @@ interface InboxDraftAttachment {
|
|
|
1829
1830
|
size: number;
|
|
1830
1831
|
}
|
|
1831
1832
|
interface InboxDraftContentAttachmentOptions {
|
|
1832
|
-
/** Content of the file, as a base64 string or
|
|
1833
|
-
content: string | Buffer;
|
|
1833
|
+
/** Content of the file, as a base64 string or binary data, which is sent as base64. */
|
|
1834
|
+
content: string | Buffer | Uint8Array | ArrayBuffer;
|
|
1834
1835
|
path?: never;
|
|
1835
1836
|
filename: string;
|
|
1836
1837
|
contentType: string;
|
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.0";
|
|
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
|
}
|
|
@@ -216,9 +227,24 @@ var Automations = class {
|
|
|
216
227
|
};
|
|
217
228
|
//#endregion
|
|
218
229
|
//#region src/common/utils/parse-email-to-api-options.ts
|
|
230
|
+
function encodeBase64(bytes) {
|
|
231
|
+
if (typeof Buffer !== "undefined") return Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength).toString("base64");
|
|
232
|
+
let binary = "";
|
|
233
|
+
for (let i = 0; i < bytes.length; i += 32768) binary += String.fromCharCode(...bytes.subarray(i, i + 32768));
|
|
234
|
+
return btoa(binary);
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* JSON.stringify turns a Uint8Array into an object of indexes and an
|
|
238
|
+
* ArrayBuffer into `{}`, so binary content is sent as base64 instead.
|
|
239
|
+
*/
|
|
240
|
+
function parseAttachmentContent(content) {
|
|
241
|
+
if (ArrayBuffer.isView(content)) return encodeBase64(new Uint8Array(content.buffer, content.byteOffset, content.byteLength));
|
|
242
|
+
if (content instanceof ArrayBuffer) return encodeBase64(new Uint8Array(content));
|
|
243
|
+
return content;
|
|
244
|
+
}
|
|
219
245
|
function parseAttachments(attachments) {
|
|
220
246
|
return attachments?.map((attachment) => ({
|
|
221
|
-
content: attachment.content,
|
|
247
|
+
content: parseAttachmentContent(attachment.content),
|
|
222
248
|
filename: attachment.filename,
|
|
223
249
|
path: attachment.path,
|
|
224
250
|
content_type: attachment.contentType,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "resend",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.38.0",
|
|
4
4
|
"description": "Node.js library for the Resend API",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -77,10 +77,10 @@
|
|
|
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
86
|
"packageManager": "pnpm@11.27.0"
|