Correctly type things that interact with nodemailer.
This commit is contained in:
parent
1dc52cfa75
commit
81c404f88d
|
@ -1,3 +1,4 @@
|
||||||
|
import { SendEmailResponse } from "@budibase/types"
|
||||||
import TestConfiguration from "../../../tests/utilities/TestConfiguration"
|
import TestConfiguration from "../../../tests/utilities/TestConfiguration"
|
||||||
import * as workerRequests from "../../../utilities/workerRequests"
|
import * as workerRequests from "../../../utilities/workerRequests"
|
||||||
|
|
||||||
|
@ -5,17 +6,18 @@ jest.mock("../../../utilities/workerRequests", () => ({
|
||||||
sendSmtpEmail: jest.fn(),
|
sendSmtpEmail: jest.fn(),
|
||||||
}))
|
}))
|
||||||
|
|
||||||
function generateResponse(to: string, from: string) {
|
function generateResponse(to: string, from: string): SendEmailResponse {
|
||||||
return {
|
return {
|
||||||
success: true,
|
message: `Email sent to ${to}.`,
|
||||||
response: {
|
|
||||||
accepted: [to],
|
accepted: [to],
|
||||||
envelope: {
|
envelope: {
|
||||||
from: from,
|
from: from,
|
||||||
to: [to],
|
to: [to],
|
||||||
},
|
},
|
||||||
message: `Email sent to ${to}.`,
|
messageId: "messageId",
|
||||||
},
|
pending: [],
|
||||||
|
rejected: [],
|
||||||
|
response: "response",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
"@budibase/nano": "10.1.5",
|
"@budibase/nano": "10.1.5",
|
||||||
"@types/json-schema": "^7.0.15",
|
"@types/json-schema": "^7.0.15",
|
||||||
"@types/koa": "2.13.4",
|
"@types/koa": "2.13.4",
|
||||||
|
"@types/nodemailer": "^6.4.17",
|
||||||
"@types/redlock": "4.0.7",
|
"@types/redlock": "4.0.7",
|
||||||
"koa-useragent": "^4.1.0",
|
"koa-useragent": "^4.1.0",
|
||||||
"rimraf": "3.0.2",
|
"rimraf": "3.0.2",
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import { EmailAttachment, EmailInvite } from "../../../documents"
|
import { EmailAttachment, EmailInvite } from "../../../documents"
|
||||||
|
import SMTPTransport from "nodemailer/lib/smtp-transport"
|
||||||
|
|
||||||
export enum EmailTemplatePurpose {
|
export enum EmailTemplatePurpose {
|
||||||
CORE = "core",
|
CORE = "core",
|
||||||
|
@ -23,6 +24,6 @@ export interface SendEmailRequest {
|
||||||
invite?: EmailInvite
|
invite?: EmailInvite
|
||||||
attachments?: EmailAttachment[]
|
attachments?: EmailAttachment[]
|
||||||
}
|
}
|
||||||
export interface SendEmailResponse extends Record<string, any> {
|
export interface SendEmailResponse extends SMTPTransport.SentMessageInfo {
|
||||||
message: string
|
message: string
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue