@upyo/core 0.2.0-dev.24 → 0.2.0-dev.26
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/address.cjs +21 -0
- package/dist/address.d.cts +25 -2
- package/dist/address.d.ts +25 -2
- package/dist/address.js +21 -1
- package/dist/index.cjs +1 -0
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/message.d.cts +6 -6
- package/dist/message.d.ts +6 -6
- package/package.json +1 -1
package/dist/address.cjs
CHANGED
|
@@ -128,7 +128,28 @@ function isValidDomainPart(domainPart) {
|
|
|
128
128
|
return false;
|
|
129
129
|
}
|
|
130
130
|
}
|
|
131
|
+
/**
|
|
132
|
+
* Type guard function that checks if a given value is a valid email address.
|
|
133
|
+
*
|
|
134
|
+
* @example
|
|
135
|
+
* ```ts
|
|
136
|
+
* import { isEmailAddress } from "@upyo/core/address";
|
|
137
|
+
*
|
|
138
|
+
* const userInput = "user@example.com";
|
|
139
|
+
* if (isEmailAddress(userInput)) {
|
|
140
|
+
* // TypeScript now knows userInput is EmailAddress type
|
|
141
|
+
* console.log(userInput); // Type: `${string}@${string}`
|
|
142
|
+
* }
|
|
143
|
+
* ```
|
|
144
|
+
*
|
|
145
|
+
* @param email The value to check
|
|
146
|
+
* @returns `true` if the value is a valid email address, `false` otherwise
|
|
147
|
+
*/
|
|
148
|
+
function isEmailAddress(email) {
|
|
149
|
+
return typeof email === "string" && isValidEmail(email);
|
|
150
|
+
}
|
|
131
151
|
|
|
132
152
|
//#endregion
|
|
133
153
|
exports.formatAddress = formatAddress;
|
|
154
|
+
exports.isEmailAddress = isEmailAddress;
|
|
134
155
|
exports.parseAddress = parseAddress;
|
package/dist/address.d.cts
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
//#region src/address.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* A type alias for email address strings that must contain an @ symbol.
|
|
4
|
+
* @since 0.2.0
|
|
5
|
+
*/
|
|
6
|
+
type EmailAddress = `${string}@${string}`;
|
|
2
7
|
/**
|
|
3
8
|
* A pair of name (which is optional) and email address.
|
|
4
9
|
*/
|
|
@@ -10,7 +15,7 @@ interface Address {
|
|
|
10
15
|
/**
|
|
11
16
|
* The email address itself.
|
|
12
17
|
*/
|
|
13
|
-
readonly address:
|
|
18
|
+
readonly address: EmailAddress;
|
|
14
19
|
}
|
|
15
20
|
/**
|
|
16
21
|
* Formats an address object into a string representation. This function is
|
|
@@ -64,5 +69,23 @@ declare function formatAddress(address: Address): string;
|
|
|
64
69
|
* or `undefined` if the input is invalid.
|
|
65
70
|
*/
|
|
66
71
|
declare function parseAddress(address: string): Address | undefined;
|
|
72
|
+
/**
|
|
73
|
+
* Type guard function that checks if a given value is a valid email address.
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* ```ts
|
|
77
|
+
* import { isEmailAddress } from "@upyo/core/address";
|
|
78
|
+
*
|
|
79
|
+
* const userInput = "user@example.com";
|
|
80
|
+
* if (isEmailAddress(userInput)) {
|
|
81
|
+
* // TypeScript now knows userInput is EmailAddress type
|
|
82
|
+
* console.log(userInput); // Type: `${string}@${string}`
|
|
83
|
+
* }
|
|
84
|
+
* ```
|
|
85
|
+
*
|
|
86
|
+
* @param email The value to check
|
|
87
|
+
* @returns `true` if the value is a valid email address, `false` otherwise
|
|
88
|
+
*/
|
|
89
|
+
declare function isEmailAddress(email: unknown): email is EmailAddress;
|
|
67
90
|
//#endregion
|
|
68
|
-
export { Address, formatAddress, parseAddress };
|
|
91
|
+
export { Address, EmailAddress, formatAddress, isEmailAddress, parseAddress };
|
package/dist/address.d.ts
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
//#region src/address.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* A type alias for email address strings that must contain an @ symbol.
|
|
4
|
+
* @since 0.2.0
|
|
5
|
+
*/
|
|
6
|
+
type EmailAddress = `${string}@${string}`;
|
|
2
7
|
/**
|
|
3
8
|
* A pair of name (which is optional) and email address.
|
|
4
9
|
*/
|
|
@@ -10,7 +15,7 @@ interface Address {
|
|
|
10
15
|
/**
|
|
11
16
|
* The email address itself.
|
|
12
17
|
*/
|
|
13
|
-
readonly address:
|
|
18
|
+
readonly address: EmailAddress;
|
|
14
19
|
}
|
|
15
20
|
/**
|
|
16
21
|
* Formats an address object into a string representation. This function is
|
|
@@ -64,5 +69,23 @@ declare function formatAddress(address: Address): string;
|
|
|
64
69
|
* or `undefined` if the input is invalid.
|
|
65
70
|
*/
|
|
66
71
|
declare function parseAddress(address: string): Address | undefined;
|
|
72
|
+
/**
|
|
73
|
+
* Type guard function that checks if a given value is a valid email address.
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* ```ts
|
|
77
|
+
* import { isEmailAddress } from "@upyo/core/address";
|
|
78
|
+
*
|
|
79
|
+
* const userInput = "user@example.com";
|
|
80
|
+
* if (isEmailAddress(userInput)) {
|
|
81
|
+
* // TypeScript now knows userInput is EmailAddress type
|
|
82
|
+
* console.log(userInput); // Type: `${string}@${string}`
|
|
83
|
+
* }
|
|
84
|
+
* ```
|
|
85
|
+
*
|
|
86
|
+
* @param email The value to check
|
|
87
|
+
* @returns `true` if the value is a valid email address, `false` otherwise
|
|
88
|
+
*/
|
|
89
|
+
declare function isEmailAddress(email: unknown): email is EmailAddress;
|
|
67
90
|
//#endregion
|
|
68
|
-
export { Address, formatAddress, parseAddress };
|
|
91
|
+
export { Address, EmailAddress, formatAddress, isEmailAddress, parseAddress };
|
package/dist/address.js
CHANGED
|
@@ -127,6 +127,26 @@ function isValidDomainPart(domainPart) {
|
|
|
127
127
|
return false;
|
|
128
128
|
}
|
|
129
129
|
}
|
|
130
|
+
/**
|
|
131
|
+
* Type guard function that checks if a given value is a valid email address.
|
|
132
|
+
*
|
|
133
|
+
* @example
|
|
134
|
+
* ```ts
|
|
135
|
+
* import { isEmailAddress } from "@upyo/core/address";
|
|
136
|
+
*
|
|
137
|
+
* const userInput = "user@example.com";
|
|
138
|
+
* if (isEmailAddress(userInput)) {
|
|
139
|
+
* // TypeScript now knows userInput is EmailAddress type
|
|
140
|
+
* console.log(userInput); // Type: `${string}@${string}`
|
|
141
|
+
* }
|
|
142
|
+
* ```
|
|
143
|
+
*
|
|
144
|
+
* @param email The value to check
|
|
145
|
+
* @returns `true` if the value is a valid email address, `false` otherwise
|
|
146
|
+
*/
|
|
147
|
+
function isEmailAddress(email) {
|
|
148
|
+
return typeof email === "string" && isValidEmail(email);
|
|
149
|
+
}
|
|
130
150
|
|
|
131
151
|
//#endregion
|
|
132
|
-
export { formatAddress, parseAddress };
|
|
152
|
+
export { formatAddress, isEmailAddress, parseAddress };
|
package/dist/index.cjs
CHANGED
|
@@ -7,4 +7,5 @@ exports.comparePriority = require_priority.comparePriority;
|
|
|
7
7
|
exports.createMessage = require_message.createMessage;
|
|
8
8
|
exports.formatAddress = require_address.formatAddress;
|
|
9
9
|
exports.isAttachment = require_attachment.isAttachment;
|
|
10
|
+
exports.isEmailAddress = require_address.isEmailAddress;
|
|
10
11
|
exports.parseAddress = require_address.parseAddress;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Address, formatAddress, parseAddress } from "./address.cjs";
|
|
1
|
+
import { Address, EmailAddress, formatAddress, isEmailAddress, parseAddress } from "./address.cjs";
|
|
2
2
|
import { Attachment, isAttachment } from "./attachment.cjs";
|
|
3
3
|
import { Priority, comparePriority } from "./priority.cjs";
|
|
4
4
|
import { ImmutableHeaders, Message, MessageConstructor, MessageContent, createMessage } from "./message.cjs";
|
|
5
5
|
import { Receipt } from "./receipt.cjs";
|
|
6
6
|
import { Transport, TransportOptions } from "./transport.cjs";
|
|
7
|
-
export { Address, Attachment, ImmutableHeaders, Message, MessageConstructor, MessageContent, Priority, Receipt, Transport, TransportOptions, comparePriority, createMessage, formatAddress, isAttachment, parseAddress };
|
|
7
|
+
export { Address, Attachment, EmailAddress, ImmutableHeaders, Message, MessageConstructor, MessageContent, Priority, Receipt, Transport, TransportOptions, comparePriority, createMessage, formatAddress, isAttachment, isEmailAddress, parseAddress };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Address, formatAddress, parseAddress } from "./address.js";
|
|
1
|
+
import { Address, EmailAddress, formatAddress, isEmailAddress, parseAddress } from "./address.js";
|
|
2
2
|
import { Attachment, isAttachment } from "./attachment.js";
|
|
3
3
|
import { Priority, comparePriority } from "./priority.js";
|
|
4
4
|
import { ImmutableHeaders, Message, MessageConstructor, MessageContent, createMessage } from "./message.js";
|
|
5
5
|
import { Receipt } from "./receipt.js";
|
|
6
6
|
import { Transport, TransportOptions } from "./transport.js";
|
|
7
|
-
export { Address, Attachment, ImmutableHeaders, Message, MessageConstructor, MessageContent, Priority, Receipt, Transport, TransportOptions, comparePriority, createMessage, formatAddress, isAttachment, parseAddress };
|
|
7
|
+
export { Address, Attachment, EmailAddress, ImmutableHeaders, Message, MessageConstructor, MessageContent, Priority, Receipt, Transport, TransportOptions, comparePriority, createMessage, formatAddress, isAttachment, isEmailAddress, parseAddress };
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { formatAddress, parseAddress } from "./address.js";
|
|
1
|
+
import { formatAddress, isEmailAddress, parseAddress } from "./address.js";
|
|
2
2
|
import { isAttachment } from "./attachment.js";
|
|
3
3
|
import { createMessage } from "./message.js";
|
|
4
4
|
import { comparePriority } from "./priority.js";
|
|
5
5
|
|
|
6
|
-
export { comparePriority, createMessage, formatAddress, isAttachment, parseAddress };
|
|
6
|
+
export { comparePriority, createMessage, formatAddress, isAttachment, isEmailAddress, parseAddress };
|
package/dist/message.d.cts
CHANGED
|
@@ -20,19 +20,19 @@ interface Message {
|
|
|
20
20
|
/**
|
|
21
21
|
* The email addresses of the recipient of the message.
|
|
22
22
|
*/
|
|
23
|
-
readonly recipients: Address[];
|
|
23
|
+
readonly recipients: readonly Address[];
|
|
24
24
|
/**
|
|
25
25
|
* The email addresses of the carbon copy (CC) recipients of the message.
|
|
26
26
|
*/
|
|
27
|
-
readonly ccRecipients: Address[];
|
|
27
|
+
readonly ccRecipients: readonly Address[];
|
|
28
28
|
/**
|
|
29
29
|
* The email addresses of the blind carbon copy (BCC) recipients of the message.
|
|
30
30
|
*/
|
|
31
|
-
readonly bccRecipients: Address[];
|
|
31
|
+
readonly bccRecipients: readonly Address[];
|
|
32
32
|
/**
|
|
33
33
|
* The email addresses of the reply-to recipients of the message.
|
|
34
34
|
*/
|
|
35
|
-
readonly replyRecipients: Address[];
|
|
35
|
+
readonly replyRecipients: readonly Address[];
|
|
36
36
|
/**
|
|
37
37
|
* The attachments included in the email message. These are files that
|
|
38
38
|
* are sent along with the email, such as documents, images, or other
|
|
@@ -40,7 +40,7 @@ interface Message {
|
|
|
40
40
|
* object, which contains information about the attachment such as its
|
|
41
41
|
* filename, content type, and content ID.
|
|
42
42
|
*/
|
|
43
|
-
readonly attachments: Attachment[];
|
|
43
|
+
readonly attachments: readonly Attachment[];
|
|
44
44
|
/**
|
|
45
45
|
* The subject of the email message. This is typically a brief summary
|
|
46
46
|
* of the content of the email, and is used to help the recipient identify
|
|
@@ -67,7 +67,7 @@ interface Message {
|
|
|
67
67
|
/**
|
|
68
68
|
* The tags associated with the email message.
|
|
69
69
|
*/
|
|
70
|
-
readonly tags: string[];
|
|
70
|
+
readonly tags: readonly string[];
|
|
71
71
|
/**
|
|
72
72
|
* The headers of the email message. This is represented by
|
|
73
73
|
* the {@link ImmutableHeaders} type, which is a supertype of
|
package/dist/message.d.ts
CHANGED
|
@@ -20,19 +20,19 @@ interface Message {
|
|
|
20
20
|
/**
|
|
21
21
|
* The email addresses of the recipient of the message.
|
|
22
22
|
*/
|
|
23
|
-
readonly recipients: Address[];
|
|
23
|
+
readonly recipients: readonly Address[];
|
|
24
24
|
/**
|
|
25
25
|
* The email addresses of the carbon copy (CC) recipients of the message.
|
|
26
26
|
*/
|
|
27
|
-
readonly ccRecipients: Address[];
|
|
27
|
+
readonly ccRecipients: readonly Address[];
|
|
28
28
|
/**
|
|
29
29
|
* The email addresses of the blind carbon copy (BCC) recipients of the message.
|
|
30
30
|
*/
|
|
31
|
-
readonly bccRecipients: Address[];
|
|
31
|
+
readonly bccRecipients: readonly Address[];
|
|
32
32
|
/**
|
|
33
33
|
* The email addresses of the reply-to recipients of the message.
|
|
34
34
|
*/
|
|
35
|
-
readonly replyRecipients: Address[];
|
|
35
|
+
readonly replyRecipients: readonly Address[];
|
|
36
36
|
/**
|
|
37
37
|
* The attachments included in the email message. These are files that
|
|
38
38
|
* are sent along with the email, such as documents, images, or other
|
|
@@ -40,7 +40,7 @@ interface Message {
|
|
|
40
40
|
* object, which contains information about the attachment such as its
|
|
41
41
|
* filename, content type, and content ID.
|
|
42
42
|
*/
|
|
43
|
-
readonly attachments: Attachment[];
|
|
43
|
+
readonly attachments: readonly Attachment[];
|
|
44
44
|
/**
|
|
45
45
|
* The subject of the email message. This is typically a brief summary
|
|
46
46
|
* of the content of the email, and is used to help the recipient identify
|
|
@@ -67,7 +67,7 @@ interface Message {
|
|
|
67
67
|
/**
|
|
68
68
|
* The tags associated with the email message.
|
|
69
69
|
*/
|
|
70
|
-
readonly tags: string[];
|
|
70
|
+
readonly tags: readonly string[];
|
|
71
71
|
/**
|
|
72
72
|
* The headers of the email message. This is represented by
|
|
73
73
|
* the {@link ImmutableHeaders} type, which is a supertype of
|