@upyo/core 0.1.0-dev.12 → 0.1.0-dev.14
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 +3 -2
- package/dist/message.js +3 -2
- package/dist/receipt.d.cts +16 -7
- package/dist/receipt.d.ts +16 -7
- package/package.json +1 -1
package/dist/message.cjs
CHANGED
|
@@ -26,8 +26,9 @@ const require_attachment = require('./attachment.cjs');
|
|
|
26
26
|
* an attachment object is invalid.
|
|
27
27
|
*/
|
|
28
28
|
function createMessage(constructor) {
|
|
29
|
+
const sender = typeof constructor.from === "string" ? require_address.parseAddress(constructor.from) ?? throwTypeError(`Invalid sender address: ${JSON.stringify(constructor.from)}`) : constructor.from;
|
|
29
30
|
return {
|
|
30
|
-
sender
|
|
31
|
+
sender,
|
|
31
32
|
recipients: esureArray(constructor.to).map((to) => typeof to === "string" ? require_address.parseAddress(to) ?? throwTypeError(`Invalid recipient address: ${JSON.stringify(to)}`) : to),
|
|
32
33
|
ccRecipients: esureArray(constructor.cc).map((cc) => typeof cc === "string" ? require_address.parseAddress(cc) ?? throwTypeError(`Invalid CC address: ${JSON.stringify(cc)}`) : cc),
|
|
33
34
|
bccRecipients: esureArray(constructor.bcc).map((bcc) => typeof bcc === "string" ? require_address.parseAddress(bcc) ?? throwTypeError(`Invalid BCC address: ${JSON.stringify(bcc)}`) : bcc),
|
|
@@ -38,7 +39,7 @@ function createMessage(constructor) {
|
|
|
38
39
|
filename: attachment.name,
|
|
39
40
|
content: attachment.arrayBuffer().then((b) => new Uint8Array(b)),
|
|
40
41
|
contentType: attachment.type == null || attachment.type === "" ? "application/octet-stream" : attachment.type,
|
|
41
|
-
contentId: ""
|
|
42
|
+
contentId: `${crypto.randomUUID()}@${sender.address.replace(/^[^@]*@/, "")}`
|
|
42
43
|
};
|
|
43
44
|
else if (require_attachment.isAttachment(attachment)) return attachment;
|
|
44
45
|
else throwTypeError(`Invalid attachment: ${JSON.stringify(attachment)}`);
|
package/dist/message.js
CHANGED
|
@@ -26,8 +26,9 @@ import { isAttachment } from "./attachment.js";
|
|
|
26
26
|
* an attachment object is invalid.
|
|
27
27
|
*/
|
|
28
28
|
function createMessage(constructor) {
|
|
29
|
+
const sender = typeof constructor.from === "string" ? parseAddress(constructor.from) ?? throwTypeError(`Invalid sender address: ${JSON.stringify(constructor.from)}`) : constructor.from;
|
|
29
30
|
return {
|
|
30
|
-
sender
|
|
31
|
+
sender,
|
|
31
32
|
recipients: esureArray(constructor.to).map((to) => typeof to === "string" ? parseAddress(to) ?? throwTypeError(`Invalid recipient address: ${JSON.stringify(to)}`) : to),
|
|
32
33
|
ccRecipients: esureArray(constructor.cc).map((cc) => typeof cc === "string" ? parseAddress(cc) ?? throwTypeError(`Invalid CC address: ${JSON.stringify(cc)}`) : cc),
|
|
33
34
|
bccRecipients: esureArray(constructor.bcc).map((bcc) => typeof bcc === "string" ? parseAddress(bcc) ?? throwTypeError(`Invalid BCC address: ${JSON.stringify(bcc)}`) : bcc),
|
|
@@ -38,7 +39,7 @@ function createMessage(constructor) {
|
|
|
38
39
|
filename: attachment.name,
|
|
39
40
|
content: attachment.arrayBuffer().then((b) => new Uint8Array(b)),
|
|
40
41
|
contentType: attachment.type == null || attachment.type === "" ? "application/octet-stream" : attachment.type,
|
|
41
|
-
contentId: ""
|
|
42
|
+
contentId: `${crypto.randomUUID()}@${sender.address.replace(/^[^@]*@/, "")}`
|
|
42
43
|
};
|
|
43
44
|
else if (isAttachment(attachment)) return attachment;
|
|
44
45
|
else throwTypeError(`Invalid attachment: ${JSON.stringify(attachment)}`);
|
package/dist/receipt.d.cts
CHANGED
|
@@ -1,21 +1,30 @@
|
|
|
1
1
|
//#region src/receipt.d.ts
|
|
2
2
|
/**
|
|
3
3
|
* The response from the email service after sending an email message.
|
|
4
|
+
*
|
|
5
|
+
* This type uses a discriminated union to ensure type safety:
|
|
6
|
+
*
|
|
7
|
+
* - Successful sends have a `messageId` but no `errorMessages`
|
|
8
|
+
* - Failed sends have `errorMessages` but no `messageId`
|
|
4
9
|
*/
|
|
5
|
-
|
|
10
|
+
type Receipt = {
|
|
11
|
+
/**
|
|
12
|
+
* Indicates that the email was sent successfully.
|
|
13
|
+
*/
|
|
14
|
+
readonly successful: true;
|
|
6
15
|
/**
|
|
7
16
|
* The unique identifier for the message that was sent.
|
|
8
17
|
*/
|
|
9
18
|
readonly messageId: string;
|
|
19
|
+
} | {
|
|
10
20
|
/**
|
|
11
|
-
*
|
|
12
|
-
* if any. If the email was sent successfully, this array will be empty.
|
|
21
|
+
* Indicates that the email failed to send.
|
|
13
22
|
*/
|
|
14
|
-
readonly
|
|
23
|
+
readonly successful: false;
|
|
15
24
|
/**
|
|
16
|
-
*
|
|
25
|
+
* An array of error messages that occurred during the sending process.
|
|
17
26
|
*/
|
|
18
|
-
readonly
|
|
19
|
-
}
|
|
27
|
+
readonly errorMessages: readonly string[];
|
|
28
|
+
};
|
|
20
29
|
//#endregion
|
|
21
30
|
export { Receipt };
|
package/dist/receipt.d.ts
CHANGED
|
@@ -1,21 +1,30 @@
|
|
|
1
1
|
//#region src/receipt.d.ts
|
|
2
2
|
/**
|
|
3
3
|
* The response from the email service after sending an email message.
|
|
4
|
+
*
|
|
5
|
+
* This type uses a discriminated union to ensure type safety:
|
|
6
|
+
*
|
|
7
|
+
* - Successful sends have a `messageId` but no `errorMessages`
|
|
8
|
+
* - Failed sends have `errorMessages` but no `messageId`
|
|
4
9
|
*/
|
|
5
|
-
|
|
10
|
+
type Receipt = {
|
|
11
|
+
/**
|
|
12
|
+
* Indicates that the email was sent successfully.
|
|
13
|
+
*/
|
|
14
|
+
readonly successful: true;
|
|
6
15
|
/**
|
|
7
16
|
* The unique identifier for the message that was sent.
|
|
8
17
|
*/
|
|
9
18
|
readonly messageId: string;
|
|
19
|
+
} | {
|
|
10
20
|
/**
|
|
11
|
-
*
|
|
12
|
-
* if any. If the email was sent successfully, this array will be empty.
|
|
21
|
+
* Indicates that the email failed to send.
|
|
13
22
|
*/
|
|
14
|
-
readonly
|
|
23
|
+
readonly successful: false;
|
|
15
24
|
/**
|
|
16
|
-
*
|
|
25
|
+
* An array of error messages that occurred during the sending process.
|
|
17
26
|
*/
|
|
18
|
-
readonly
|
|
19
|
-
}
|
|
27
|
+
readonly errorMessages: readonly string[];
|
|
28
|
+
};
|
|
20
29
|
//#endregion
|
|
21
30
|
export { Receipt };
|