@upyo/core 0.3.0 → 0.4.0-dev.39
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/message.cjs +7 -7
- package/dist/message.js +7 -7
- package/package.json +1 -1
package/dist/message.cjs
CHANGED
|
@@ -29,11 +29,11 @@ function createMessage(constructor) {
|
|
|
29
29
|
const sender = typeof constructor.from === "string" ? require_address.parseAddress(constructor.from) ?? throwTypeError(`Invalid sender address: ${JSON.stringify(constructor.from)}`) : constructor.from;
|
|
30
30
|
return {
|
|
31
31
|
sender,
|
|
32
|
-
recipients:
|
|
33
|
-
ccRecipients:
|
|
34
|
-
bccRecipients:
|
|
35
|
-
replyRecipients:
|
|
36
|
-
attachments:
|
|
32
|
+
recipients: ensureArray(constructor.to).map((to) => typeof to === "string" ? require_address.parseAddress(to) ?? throwTypeError(`Invalid recipient address: ${JSON.stringify(to)}`) : to),
|
|
33
|
+
ccRecipients: ensureArray(constructor.cc).map((cc) => typeof cc === "string" ? require_address.parseAddress(cc) ?? throwTypeError(`Invalid CC address: ${JSON.stringify(cc)}`) : cc),
|
|
34
|
+
bccRecipients: ensureArray(constructor.bcc).map((bcc) => typeof bcc === "string" ? require_address.parseAddress(bcc) ?? throwTypeError(`Invalid BCC address: ${JSON.stringify(bcc)}`) : bcc),
|
|
35
|
+
replyRecipients: ensureArray(constructor.replyTo).map((replyTo) => typeof replyTo === "string" ? require_address.parseAddress(replyTo) ?? throwTypeError(`Invalid reply-to address: ${JSON.stringify(replyTo)}`) : replyTo),
|
|
36
|
+
attachments: ensureArray(constructor.attachments).map((attachment) => {
|
|
37
37
|
if (attachment instanceof File) return {
|
|
38
38
|
inline: false,
|
|
39
39
|
filename: attachment.name,
|
|
@@ -47,14 +47,14 @@ function createMessage(constructor) {
|
|
|
47
47
|
subject: constructor.subject,
|
|
48
48
|
content: constructor.content,
|
|
49
49
|
priority: constructor.priority ?? "normal",
|
|
50
|
-
tags:
|
|
50
|
+
tags: ensureArray(constructor.tags),
|
|
51
51
|
headers: new Headers(constructor.headers ?? {})
|
|
52
52
|
};
|
|
53
53
|
}
|
|
54
54
|
function throwTypeError(message) {
|
|
55
55
|
throw new TypeError(message);
|
|
56
56
|
}
|
|
57
|
-
function
|
|
57
|
+
function ensureArray(value) {
|
|
58
58
|
return Array.isArray(value) ? value : value == null ? [] : [value];
|
|
59
59
|
}
|
|
60
60
|
|
package/dist/message.js
CHANGED
|
@@ -29,11 +29,11 @@ function createMessage(constructor) {
|
|
|
29
29
|
const sender = typeof constructor.from === "string" ? parseAddress(constructor.from) ?? throwTypeError(`Invalid sender address: ${JSON.stringify(constructor.from)}`) : constructor.from;
|
|
30
30
|
return {
|
|
31
31
|
sender,
|
|
32
|
-
recipients:
|
|
33
|
-
ccRecipients:
|
|
34
|
-
bccRecipients:
|
|
35
|
-
replyRecipients:
|
|
36
|
-
attachments:
|
|
32
|
+
recipients: ensureArray(constructor.to).map((to) => typeof to === "string" ? parseAddress(to) ?? throwTypeError(`Invalid recipient address: ${JSON.stringify(to)}`) : to),
|
|
33
|
+
ccRecipients: ensureArray(constructor.cc).map((cc) => typeof cc === "string" ? parseAddress(cc) ?? throwTypeError(`Invalid CC address: ${JSON.stringify(cc)}`) : cc),
|
|
34
|
+
bccRecipients: ensureArray(constructor.bcc).map((bcc) => typeof bcc === "string" ? parseAddress(bcc) ?? throwTypeError(`Invalid BCC address: ${JSON.stringify(bcc)}`) : bcc),
|
|
35
|
+
replyRecipients: ensureArray(constructor.replyTo).map((replyTo) => typeof replyTo === "string" ? parseAddress(replyTo) ?? throwTypeError(`Invalid reply-to address: ${JSON.stringify(replyTo)}`) : replyTo),
|
|
36
|
+
attachments: ensureArray(constructor.attachments).map((attachment) => {
|
|
37
37
|
if (attachment instanceof File) return {
|
|
38
38
|
inline: false,
|
|
39
39
|
filename: attachment.name,
|
|
@@ -47,14 +47,14 @@ function createMessage(constructor) {
|
|
|
47
47
|
subject: constructor.subject,
|
|
48
48
|
content: constructor.content,
|
|
49
49
|
priority: constructor.priority ?? "normal",
|
|
50
|
-
tags:
|
|
50
|
+
tags: ensureArray(constructor.tags),
|
|
51
51
|
headers: new Headers(constructor.headers ?? {})
|
|
52
52
|
};
|
|
53
53
|
}
|
|
54
54
|
function throwTypeError(message) {
|
|
55
55
|
throw new TypeError(message);
|
|
56
56
|
}
|
|
57
|
-
function
|
|
57
|
+
function ensureArray(value) {
|
|
58
58
|
return Array.isArray(value) ? value : value == null ? [] : [value];
|
|
59
59
|
}
|
|
60
60
|
|