Skip to content

Commit b937aee

Browse files
committed
docs(jsdoc): align library and utility JSDoc style ✏️
- Add @description clauses across shared type exports in Types.ts - Add @description lines across validation helpers under src/utils - Refresh entry-point mailer JSDoc blocks in src/index.ts - Shorten overlong interface briefs to skill word-limit constraints - Standardize dotted sentence style on JSDoc brief and description lines
1 parent 7a9de5e commit b937aee

6 files changed

Lines changed: 41 additions & 13 deletions

File tree

src/Types.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/**
22
* Calendar event invitation data.
3+
* @description Defines calendar payload fields for event invites.
34
*/
45
export interface CalendarInvite {
56
/** Unique identifier for the calendar event */
@@ -24,6 +25,7 @@ export interface CalendarInvite {
2425

2526
/**
2627
* Email attachment data.
28+
* @description Defines attachment payload for SMTP MIME messages.
2729
*/
2830
export interface EmailAttachment {
2931
/** Name of the attached file */
@@ -38,6 +40,7 @@ export interface EmailAttachment {
3840

3941
/**
4042
* Email contact information.
43+
* @description Describes email address and optional display name.
4144
*/
4245
export interface EmailContact {
4346
/** Optional display name for the contact */
@@ -48,6 +51,7 @@ export interface EmailContact {
4851

4952
/**
5053
* Complete email message structure.
54+
* @description Defines sender recipients body and message options.
5155
*/
5256
export interface EmailMessage {
5357
/** Sender email address or contact */
@@ -77,16 +81,19 @@ export interface EmailMessage {
7781
}
7882

7983
/**
80-
* Email recipient type that can be a string, EmailContact object, or array of either.
84+
* Email recipient type.
85+
* @description Allows string object or array recipient formats.
8186
*/
8287
export type EmailRecipient = string | EmailContact | (string | EmailContact)[]
8388

8489
/**
8590
* Email sender interface.
91+
* @description Defines async message send capability contract.
8692
*/
8793
export interface EmailSender {
8894
/**
8995
* Sends an email message.
96+
* @description Sends one message and returns SMTP result data.
9097
* @param message - The email message to send
9198
* @returns Structured SMTP delivery result
9299
* @throws {Error} When message sending fails
@@ -96,10 +103,12 @@ export interface EmailSender {
96103

97104
/**
98105
* Email service interface.
106+
* @description Defines factory for creating SMTP senders.
99107
*/
100108
export interface EmailService {
101109
/**
102-
* Creates an email transporter with SMTP configuration.
110+
* Create email transporter.
111+
* @description Builds sender from SMTP connection configuration.
103112
* @param config - SMTP connection configuration
104113
* @returns Email sender instance
105114
*/
@@ -108,6 +117,7 @@ export interface EmailService {
108117

109118
/**
110119
* Embedded image attachment.
120+
* @description Extends attachment with CID and disposition fields.
111121
*/
112122
export interface EmbeddedImage extends EmailAttachment {
113123
/** Content-ID for referencing in HTML */
@@ -118,6 +128,7 @@ export interface EmbeddedImage extends EmailAttachment {
118128

119129
/**
120130
* Processed email contact.
131+
* @description Represents normalized address for SMTP processing.
121132
*/
122133
export interface ProcessedContact {
123134
/** Email address */
@@ -154,6 +165,7 @@ export interface SmtpPasswordAuthCredential extends SmtpAuthBase<'password'> {
154165

155166
/**
156167
* SMTP connection configuration.
168+
* @description Defines host port auth DKIM and pooling options.
157169
*/
158170
export interface SmtpConnectionConfig {
159171
/** SMTP server hostname */
@@ -172,6 +184,7 @@ export interface SmtpConnectionConfig {
172184

173185
/**
174186
* SMTP connection state.
187+
* @description Holds active sockets and SMTP config reference.
175188
*/
176189
export interface SmtpConnectionState {
177190
/** Raw TCP connection */

src/index.ts

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@ import * as SMTP from '@smtp/index.ts'
33
import * as Utils from '@utils/index.ts'
44

55
/**
6-
* Main email service for sending messages via SMTP.
6+
* Main email service.
7+
* @description Exposes transporter factory for SMTP message sending.
78
*/
89
export const mailer: Types.EmailService = {
910
/**
10-
* Creates an email transporter with SMTP configuration.
11+
* Create email transporter.
12+
* @description Validates config and returns sender abstraction.
1113
* @param config - SMTP connection configuration
1214
* @returns Email sender instance
1315
* @throws {Error} When configuration is invalid
@@ -19,7 +21,8 @@ export const mailer: Types.EmailService = {
1921
}
2022

2123
/**
22-
* Creates email transporter instance.
24+
* Create transporter instance.
25+
* @description Builds sender with pooled or direct clients.
2326
* @param config - SMTP connection configuration
2427
* @returns Email sender implementation
2528
*/
@@ -95,7 +98,7 @@ class SmtpClientPool {
9598

9699
/**
97100
* Acquire pooled SMTP client.
98-
* @description Returns an idle client or creates one.
101+
* @description Returns idle client or creates new one.
99102
* @returns Available SMTP client instance
100103
*/
101104
async acquireClient(): Promise<SMTP.SmtpClient> {
@@ -122,7 +125,7 @@ class SmtpClientPool {
122125

123126
/**
124127
* Release pooled SMTP client.
125-
* @description Marks client idle or hands off to waiting sender.
128+
* @description Marks idle or hands off waiting sender.
126129
* @param client - SMTP client instance to release
127130
*/
128131
releaseClient(client: SMTP.SmtpClient): void {
@@ -155,8 +158,8 @@ class SmtpClientPool {
155158
}
156159

157160
/**
158-
* Increment pooled client usage count.
159-
* @description Tracks sent message count for recycle policy.
161+
* Increment client usage count.
162+
* @description Tracks message count for recycle policy.
160163
* @param client - SMTP client instance to count
161164
*/
162165
markMessageProcessed(client: SMTP.SmtpClient): void {
@@ -166,13 +169,13 @@ class SmtpClientPool {
166169
}
167170

168171
/**
169-
* Default export of the email service.
170-
* @description Main entry point for the Deno-Mailer library.
172+
* Default mailer export.
173+
* @description Provides main library entry for SMTP sending.
171174
*/
172175
export default mailer
173176

174177
/**
175-
* Re-exports all type definitions.
176-
* @description Provides access to all TypeScript interfaces and types.
178+
* Re-export all types.
179+
* @description Exposes shared interfaces and type aliases.
177180
*/
178181
export type * from '@app/Types.ts'

src/utils/Attachment.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import type * as Types from '@app/Types.ts'
22

33
/**
44
* Validates email attachment data.
5+
* @description Checks filename content encoding fields and types.
56
* @param attachment - Attachment to validate
67
* @throws {Error} When attachment validation fails
78
*/
@@ -40,6 +41,7 @@ export function isValidAttachment(attachment: Types.EmailAttachment): void {
4041

4142
/**
4243
* Validates embedded image attachment data.
44+
* @description Reuses attachment checks and validates CID format.
4345
* @param attachment - Embedded attachment to validate
4446
* @throws {Error} When embedded attachment validation fails
4547
*/

src/utils/Config.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import type * as Types from '@app/Types.ts'
22

33
/**
44
* Validates SMTP connection configuration.
5+
* @description Runs nested checks for host port auth and options.
56
* @param config - SMTP configuration to validate
67
* @throws {Error} When configuration validation fails
78
*/
@@ -19,6 +20,7 @@ export function isValidConfig(config: Types.SmtpConnectionConfig): void {
1920

2021
/**
2122
* Validates SMTP authentication credentials.
23+
* @description Checks password and oauth2 shapes and lengths.
2224
* @param auth - Authentication credentials to validate
2325
* @throws {Error} When authentication validation fails
2426
*/
@@ -54,6 +56,7 @@ function validateAuth(auth: Types.SmtpAuthCredential | undefined): void {
5456

5557
/**
5658
* Validates SMTP DKIM configuration.
59+
* @description Ensures domain selector and private key exist.
5760
* @param dkim - DKIM settings to validate
5861
* @throws {Error} When DKIM validation fails
5962
*/
@@ -74,6 +77,7 @@ function validateDkim(dkim: Types.SmtpDkimConfig | undefined): void {
7477

7578
/**
7679
* Validates SMTP host configuration.
80+
* @description Checks host type length and non-empty value.
7781
* @param host - Host string to validate
7882
* @throws {Error} When host validation fails
7983
*/
@@ -94,6 +98,7 @@ function validateHost(host: string): void {
9498

9599
/**
96100
* Validates SMTP pool configuration.
101+
* @description Validates pool booleans and numeric constraints.
97102
* @param pool - Pool settings to validate
98103
* @throws {Error} When pool validation fails
99104
*/
@@ -126,6 +131,7 @@ function validatePool(pool: Types.SmtpPoolConfig | boolean | undefined): void {
126131

127132
/**
128133
* Validates SMTP port configuration.
134+
* @description Checks port type integer and allowed range.
129135
* @param port - Port number to validate
130136
* @throws {Error} When port validation fails
131137
*/
@@ -146,6 +152,7 @@ function validatePort(port: number): void {
146152

147153
/**
148154
* Validates SMTP secure configuration.
155+
* @description Ensures secure flag is boolean type only.
149156
* @param secure - Secure flag to validate
150157
* @throws {Error} When secure validation fails
151158
*/

src/utils/Content.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/**
22
* Generates unique Content-ID for embedded attachments.
3+
* @description Builds random bytes timestamp and domain mailbox id.
34
* @param domain - Domain name for Content-ID (defaults to 'deno-mailer.local')
45
* @returns Generated Content-ID string
56
*/
@@ -15,6 +16,7 @@ export function generateContentId(domain = 'deno-mailer.local'): string {
1516

1617
/**
1718
* Validates Content-ID format.
19+
* @description Checks angle brackets at symbol and length bounds.
1820
* @param cid - Content-ID string to validate
1921
* @throws {Error} When Content-ID validation fails
2022
*/

src/utils/Email.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/**
22
* Validates email address format.
3+
* @description Checks local part domain labels and basic syntax.
34
* @param email - Email address string to validate
45
* @throws {Error} When email validation fails
56
*/

0 commit comments

Comments
 (0)