scriptable-testlab
Version:
A lightweight, efficient tool designed to manage and update scripts for Scriptable.
89 lines (86 loc) • 2.61 kB
TypeScript
import { AbsMail } from 'scriptable-abstract';
interface MailState {
toRecipients: string[];
ccRecipients: string[];
bccRecipients: string[];
subject: string;
body: string;
isBodyHTML: boolean;
preferredSendingEmailAddress: string;
attachments: Array<{
type: 'image' | 'file' | 'data';
data: any;
mimeType?: string;
filename?: string;
}>;
}
/**
* Mock implementation of Scriptable's Mail.
* Provides functionality for composing and sending emails.
* @implements Mail
*/
declare class MockMail extends AbsMail<MailState> {
private static _instance;
static get instance(): MockMail;
constructor();
get toRecipients(): string[];
set toRecipients(value: string[]);
get ccRecipients(): string[];
set ccRecipients(value: string[]);
get bccRecipients(): string[];
set bccRecipients(value: string[]);
get subject(): string;
set subject(value: string);
get body(): string;
set body(value: string);
get isBodyHTML(): boolean;
set isBodyHTML(value: boolean);
get preferredSendingEmailAddress(): string;
set preferredSendingEmailAddress(value: string);
/**
* Send the mail.
* @returns A promise that resolves when the mail is sent
*/
send(): Promise<void>;
/**
* Adds an image attachment to the mail.
* @param image - Image to add to the mail
*/
addImageAttachment(image: Image): void;
/**
* Adds a file attachment to the mail.
* @param filePath - Path of file to add to the mail
*/
addFileAttachment(filePath: string): void;
/**
* Adds a data attachment to the mail.
* @param data - Data representation of file to add to the mail
* @param mimeType - MIME type of file represented by the data
* @param filename - Name of the file represented by the data
*/
addDataAttachment(data: Data, mimeType: string, filename: string): void;
/**
* Get the last composed email details
* @returns The details of the last composed email
*/
getLastComposedEmail(): {
toRecipients: string[];
ccRecipients: string[];
bccRecipients: string[];
subject: string;
body: string;
isBodyHTML: boolean;
attachments: Array<{
type: 'image' | 'file' | 'data';
data: any;
mimeType?: string;
filename?: string;
}>;
preferredSendingEmailAddress: string;
};
/**
* Clear the last composed email details
*/
clear(): void;
}
export { MockMail };