Skip to content

Commit

Permalink
Merge branch 'release/0.0.7'
Browse files Browse the repository at this point in the history
  • Loading branch information
DominusKelvin committed Sep 14, 2023
2 parents 89576d2 + 636ff12 commit e8d80f1
Show file tree
Hide file tree
Showing 5 changed files with 116 additions and 4 deletions.
2 changes: 1 addition & 1 deletion accessible/dry.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ const expandedPgInfoBySlug = reduceLibraryContents(LIBRARY_CONTENTS)
/**
* accessible/dry
*
* @type {Dictionary}
* @type {Object}
*/
module.exports = expandedPgInfoBySlug
17 changes: 17 additions & 0 deletions jsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"include": ["lib/**/*", "types/index.d.ts"],
"compilerOptions": {
"types": ["node"],
"typeRoots": ["./types", "./node_modules/@types"],
"lib": ["es2016"],
// silences wrong TS error, we don't compile, we only typecheck
"outDir": "./irrelevant/unused",
"allowJs": true,
"checkJs": true,
"noImplicitThis": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noEmitOnError": true,
"noErrorTruncation": true
}
}
27 changes: 25 additions & 2 deletions lib/private/mail/send.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ module.exports = {
type: {},
defaultsTo: {}
},
attachments: {
type: 'ref',
description: 'An array of attachment objects',
defaultsTo: []
},
to: {
description: 'The email address of the primary recipient.',
extendedDescription:
Expand All @@ -51,6 +56,18 @@ module.exports = {
required: true,
isEmail: true
},
cc: {
type: 'ref',
description:
'Comma separated list or an array of recipients email addresses that will appear on the Cc: field',
defaultsTo: []
},
bcc: {
type: 'ref',
description:
'Comma separated list or an array of recipients email addresses that will appear on the Bcc: field',
defaultsTo: []
},
toName: {
description: 'Name of the primary recipient as displayed in their inbox.',
example: 'Nola Thacker'
Expand Down Expand Up @@ -109,7 +126,10 @@ module.exports = {
mailer,
from: fromAddress,
fromName,
text
text,
cc,
bcc,
attachments
}) {
if (template && !template.startsWith('email-')) {
sails.log.warn(
Expand Down Expand Up @@ -202,7 +222,10 @@ module.exports = {
to,
subject,
text,
html
html,
cc,
bcc,
attachments
})
sails.log.debug('Message sent: %s', smtpInfo.messageId)
break
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sails-hook-mail",
"version": "0.0.6",
"version": "0.0.7",
"description": "The simple elegant way to send emails from a Sails application",
"main": "lib/sails-hook-mail.js",
"scripts": {
Expand Down
72 changes: 72 additions & 0 deletions types/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
interface Sails {
log: LogMethod & LogObject
helpers: Helper
on(event: string, listener: (...args: any[]) => void): void
off(event: string, listener: (...args: any[]) => void): void
emit(event: string, ...args: any[]): void
lift(cb?: (err: Error, sails: Sails) => void): Sails
lower(cb?: (err?: Error) => void): void
load(): Sails
config: Config
renderView: (
relPathToView: string,
_options: Dictionary,
optionalCb?: (err: Error | null, compiledHtml: string) => void
) => Sails & Promise<string>
intercept(callback: (err: Error) => Error): Sails & Promise<string>
}

interface Helper {
mail: {
send: {
with: (params: EmailParams) => Promise<string>
}
}
}
interface EmailParams {
mailer?: string
to: string
subject?: string
template?: string
templateData?: object
}

interface Hook {
inertia: Inertia
}
interface LogMethod {
(...args: any[]): void
}

interface LogObject {
info: LogMethod
warn: LogMethod
error: LogMethod
debug: LogMethod
silly: LogMethod
verbose: LogMethod
}

interface Config {
mailer: string
mail: {
default: string
mailers: {
log: object
smtp: {
transport: 'smtp'
host: string
port: number
encryption: 'tls' | 'ssl'
username?: string
password?: string
}
}
from: {
name: string
address: string
}
}
}

declare const sails: Sails

0 comments on commit e8d80f1

Please sign in to comment.