Correctly type things that interact with nodemailer.

This commit is contained in:
Sam Rose 2025-02-24 17:27:27 +00:00
parent 1dc52cfa75
commit 81c404f88d
No known key found for this signature in database
3 changed files with 14 additions and 10 deletions

View File

@ -1,3 +1,4 @@
import { SendEmailResponse } from "@budibase/types"
import TestConfiguration from "../../../tests/utilities/TestConfiguration"
import * as workerRequests from "../../../utilities/workerRequests"
@ -5,17 +6,18 @@ jest.mock("../../../utilities/workerRequests", () => ({
sendSmtpEmail: jest.fn(),
}))
function generateResponse(to: string, from: string) {
function generateResponse(to: string, from: string): SendEmailResponse {
return {
success: true,
response: {
message: `Email sent to ${to}.`,
accepted: [to],
envelope: {
from: from,
to: [to],
},
message: `Email sent to ${to}.`,
},
messageId: "messageId",
pending: [],
rejected: [],
response: "response",
}
}

View File

@ -17,6 +17,7 @@
"@budibase/nano": "10.1.5",
"@types/json-schema": "^7.0.15",
"@types/koa": "2.13.4",
"@types/nodemailer": "^6.4.17",
"@types/redlock": "4.0.7",
"koa-useragent": "^4.1.0",
"rimraf": "3.0.2",

View File

@ -1,4 +1,5 @@
import { EmailAttachment, EmailInvite } from "../../../documents"
import SMTPTransport from "nodemailer/lib/smtp-transport"
export enum EmailTemplatePurpose {
CORE = "core",
@ -23,6 +24,6 @@ export interface SendEmailRequest {
invite?: EmailInvite
attachments?: EmailAttachment[]
}
export interface SendEmailResponse extends Record<string, any> {
export interface SendEmailResponse extends SMTPTransport.SentMessageInfo {
message: string
}