Skip to content

Instantly share code, notes, and snippets.

@zevaverbach
Created May 16, 2021 20:12
Embed
What would you like to do?
ImapFlow Type Declaration File -- not complete
declare module "imapflow" {
type SequenceString = string;
export interface FetchQueryObject {
uid?: boolean;
flags?: boolean;
bodyStructure?: boolean;
envelope?: boolean;
internalDate?: boolean;
size?: boolean;
source?: boolean | object;
threadId?: string;
labels?: boolean;
headers?: boolean | Array<string>;
bodyParts?: Array<string>;
}
export interface SearchObject {
seq?: SequenceString;
answered?: boolean;
deleted?: boolean;
draft?: boolean;
flagged?: boolean;
seen?: boolean;
all?: boolean;
new?: boolean;
old?: boolean;
recent?: boolean;
from?: string;
to?: string;
cc?: string;
bcc?: string;
subject?: string;
larger?: number;
smaller?: number;
uid?: SequenceString;
modseq?: BigInt;
emailId?: string;
threadId?: string;
before?: Date | string;
on?: Date | string;
since?: Date | string;
sentBefore?: Date | string;
sentOn?: Date | string;
sentSince?: Date | string;
keyword?: string;
unKeyWord?: string;
header?: object;
or?: Array<SearchObject>;
}
export interface MailboxLockObject {
path: string;
release(): void;
}
export interface MessageAddressObject {
name?: string;
address?: string;
}
export interface MessageEnvelopeObject {
date?: Date;
subject?: string;
messageId?: string;
inReplyTo?: string;
from?: Array<MessageAddressObject>;
sender?: Array<MessageAddressObject>;
replyTo?: Array<MessageAddressObject>;
to?: Array<MessageAddressObject>;
cc?: Array<MessageAddressObject>;
bcc?: Array<MessageAddressObject>;
}
export interface MessageStructureObject {
part: string;
type: string;
parameters?: object;
id?: string;
encoding?: string;
size?: number;
envelope?: MessageEnvelopeObject;
disposition?: string;
// was 'object' before
dispositionParameters?: any;
childNodes: Array<MessageStructureObject>;
}
export interface FetchMessageObject {
seq: number;
uid: number;
source?: Buffer;
modseq?: BigInt;
emailId?: string;
threadId?: string;
labels?: Set<string>;
size?: number;
flags?: Set<string>;
envelope?: MessageEnvelopeObject;
bodyStructure?: MessageStructureObject;
internalDate?: Date;
bodyParts?: Map<string, Buffer>;
headers?: Buffer;
}
export interface DownloadObject {
meta: object;
// was 'ReadableStream' before
content: any;
}
export class ImapFlow {
constructor(options: object);
connect(): void;
getMailboxLock(path: string, options?: object): Promise<MailboxLockObject>;
search(query: SearchObject, options?: object): Promise<Array<number>>;
fetch(
range: SequenceString | Array<number> | SearchObject,
query?: FetchQueryObject,
options?: object
): Promise<AsyncGenerator<FetchMessageObject>>;
download(
range: SequenceString,
part?: string,
options?: object
): Promise<DownloadObject>;
logout(): void;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment