/** * `react-native-mail-engine` — public API. * * A thin, ergonomic, fully-typed wrapper over the Nitro HybridObjects. It owns: * - lazy creation of the root native `MailEngine`, * - normalization of friendly inputs (addresses, dates) into bridge structs, * - mapping of native handles into the `MailAccount` / `Mailbox` classes, * - conversion of native rejections into typed {@link MailError}s. * * @packageDocumentation */ import type { MailAccount as NativeMailAccount } from './specs/MailAccount.nitro.js'; import type { MailMailbox as NativeMailMailbox } from './specs/MailMailbox.nitro.js'; import type { MailAddressStruct } from './specs/MailTypes.nitro.js'; import { MailError, type AddressInput, type Attachment, type ConnectConfig, type DateInput, type FetchHeadersOptions, type FetchMessageOptions, type MailboxInfo, type Message, type MessageHeader, type NewMailEvent, type SearchCriteria, type SendMessageOptions } from './types.js'; export * from './types.js'; /** Parse `"Name "` / `"addr"` / `{ name, email }` into a bridge address. */ export declare function parseAddress(input: AddressInput): MailAddressStruct; /** Coerce a `Date` / ISO-or-`YYYY-MM-DD` string / epoch-ms number to epoch ms. */ export declare function toEpochMs(value: DateInput): number; /** A selected mailbox (folder). Obtain via {@link MailAccount.openMailbox}. */ export declare class Mailbox { private readonly native; /** @internal */ constructor(native: NativeMailMailbox); get path(): string; get exists(): number; get unseen(): number; get uidNext(): number; get uidValidity(): number; /** Fetch envelopes + flags (newest first). */ fetchHeaders(options?: FetchHeadersOptions): Promise; /** Fetch + parse a full message (bodies + attachments) by UID. */ fetchMessage(uid: number, options?: FetchMessageOptions): Promise; /** Lazily download a single attachment's bytes. */ fetchAttachment(uid: number, partId: string): Promise; /** Server-side IMAP search; resolves to matching UIDs. */ search(criteria: SearchCriteria): Promise; addFlags(uids: number[], flags: string[]): Promise; removeFlags(uids: number[], flags: string[]): Promise; markSeen(uids: number[], seen?: boolean): Promise; moveMessages(uids: number[], destinationPath: string): Promise; copyMessages(uids: number[], destinationPath: string): Promise; deleteMessages(uids: number[], expunge?: boolean): Promise; /** * Start IMAP IDLE (real-time push). Returns an unsubscribe function; call it to * stop IDLE and return the connection to command mode. * * IDLE holds the account's single connection. **Stop IDLE (call the returned * function) before issuing other commands** on this account — running a fetch / * search / flag op while IDLE is active conflicts on the same connection. * Rejects via `onError` with `ERR_UNSUPPORTED` if the server lacks IDLE. */ idle(onMail: (event: NewMailEvent) => void, onError?: (error: MailError) => void): () => void; /** Close (deselect) the mailbox and release native resources. */ close(): Promise; } /** A live, authenticated account. Obtain via {@link MailEngine.connect}. */ export declare class MailAccount { private readonly native; /** @internal */ constructor(native: NativeMailAccount); get id(): string; get isConnected(): boolean; listMailboxes(): Promise; /** Select a mailbox. Pass `readOnly` (IMAP `EXAMINE`) to avoid state changes. */ openMailbox(path: string, readOnly?: boolean): Promise; createMailbox(path: string): Promise; deleteMailbox(path: string): Promise; renameMailbox(path: string, newPath: string): Promise; /** Send a message over SMTP. */ send(message: SendMessageOptions): Promise; /** IMAP `NOOP` keepalive. */ noop(): Promise; /** Close the connection and release native resources. */ disconnect(): Promise; } export declare const MailEngine: { /** * Open an IMAP (+ optional SMTP) connection and authenticate. Resolves with a * live {@link MailAccount}, or rejects with a {@link MailError}. */ connect(config: ConnectConfig): Promise; }; export type { Attachment }; //# sourceMappingURL=index.d.ts.map