Skip to content

Commit 35a811a

Browse files
committed
refactor(utils): rename content helper and unify imports ♻️
- Rename ContentId module file to Content and update barrel exports - Switch utils and root index imports to namespace based style - Use type-only re-export in root index for public Types
1 parent 16ff7b8 commit 35a811a

5 files changed

Lines changed: 17 additions & 17 deletions

File tree

src/index.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
import type { EmailMessage, EmailSender, EmailService, SmtpConnectionConfig } from '@app/Types.ts'
2-
import { SmtpClient } from '@smtp/index.ts'
3-
import { isValidConfig } from '@utils/index.ts'
1+
import type * as Types from '@app/Types.ts'
2+
import * as SMTP from '@smtp/index.ts'
3+
import * as Utils from '@utils/index.ts'
44

55
/**
66
* Main email service for sending messages via SMTP.
77
*/
8-
export const mailer: EmailService = {
8+
export const mailer: Types.EmailService = {
99
/**
1010
* Creates an email transporter with SMTP configuration.
1111
* @param config - SMTP connection configuration
1212
* @returns Email sender instance
1313
* @throws {Error} When configuration is invalid
1414
*/
15-
transporter(config: SmtpConnectionConfig): EmailSender {
16-
isValidConfig(config)
15+
transporter(config: Types.SmtpConnectionConfig): Types.EmailSender {
16+
Utils.isValidConfig(config)
1717
return createTransporter(config)
1818
}
1919
}
@@ -23,10 +23,10 @@ export const mailer: EmailService = {
2323
* @param config - SMTP connection configuration
2424
* @returns Email sender implementation
2525
*/
26-
function createTransporter(config: SmtpConnectionConfig): EmailSender {
26+
function createTransporter(config: Types.SmtpConnectionConfig): Types.EmailSender {
2727
return {
28-
async send(message: EmailMessage): Promise<void> {
29-
const client = new SmtpClient(config)
28+
async send(message: Types.EmailMessage): Promise<void> {
29+
const client = new SMTP.SmtpClient(config)
3030
try {
3131
await client.connect()
3232
await client.sendMessage(message)
@@ -47,4 +47,4 @@ export default mailer
4747
* Re-exports all type definitions.
4848
* @description Provides access to all TypeScript interfaces and types.
4949
*/
50-
export * from '@app/Types.ts'
50+
export type * from '@app/Types.ts'

src/utils/Attachment.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import type { EmailAttachment, EmbeddedImage } from '@app/Types.ts'
1+
import type * as Types from '@app/Types.ts'
22

33
/**
44
* Validates email attachment data.
55
* @param attachment - Attachment to validate
66
* @throws {Error} When attachment validation fails
77
*/
8-
export function isValidAttachment(attachment: EmailAttachment): void {
8+
export function isValidAttachment(attachment: Types.EmailAttachment): void {
99
if (!attachment) {
1010
throw new Error('Attachment is required')
1111
}
@@ -43,7 +43,7 @@ export function isValidAttachment(attachment: EmailAttachment): void {
4343
* @param attachment - Embedded attachment to validate
4444
* @throws {Error} When embedded attachment validation fails
4545
*/
46-
export function isValidEmbedded(attachment: EmbeddedImage): void {
46+
export function isValidEmbedded(attachment: Types.EmbeddedImage): void {
4747
isValidAttachment(attachment)
4848
if (!attachment.cid) {
4949
throw new Error('Embedded attachment Content-ID is required')

src/utils/Config.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import type { SmtpAuthCredential, SmtpConnectionConfig } from '@app/Types.ts'
1+
import type * as Types from '@app/Types.ts'
22

33
/**
44
* Validates SMTP connection configuration.
55
* @param config - SMTP configuration to validate
66
* @throws {Error} When configuration validation fails
77
*/
8-
export function isValidConfig(config: SmtpConnectionConfig): void {
8+
export function isValidConfig(config: Types.SmtpConnectionConfig): void {
99
if (!config) {
1010
throw new Error('Configuration is required')
1111
}
@@ -20,7 +20,7 @@ export function isValidConfig(config: SmtpConnectionConfig): void {
2020
* @param auth - Authentication credentials to validate
2121
* @throws {Error} When authentication validation fails
2222
*/
23-
function validateAuth(auth: SmtpAuthCredential | undefined): void {
23+
function validateAuth(auth: Types.SmtpAuthCredential | undefined): void {
2424
if (auth) {
2525
if (!auth.user || auth.user.length === 0) {
2626
throw new Error('SMTP auth user is required')

src/utils/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
export * from '@utils/Attachment.ts'
22
export * from '@utils/Config.ts'
3-
export * from '@utils/ContentId.ts'
3+
export * from '@utils/Content.ts'
44
export * from '@utils/Email.ts'

0 commit comments

Comments
 (0)