Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add list options and fix status object #64482

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 22 additions & 2 deletions types/imapflow/index.d.ts
Expand Up @@ -49,7 +49,10 @@ export class ImapFlow extends EventEmitter {
/**
* @see {@link https://imapflow.com/module-imapflow-ImapFlow.html#list}
*/
list(): Promise<ListResponse[]>;
list(options?: {
statusQuery?: StatusQuery,
specialUseHints?: SpecialUseHints,
}): Promise<ListResponse[]>;

listTree(): Promise<ListTreeResponse>;

Expand Down Expand Up @@ -293,7 +296,7 @@ export interface SearchObject {

export interface StatusObject {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can extend this interface from StatusQuery. The interface has the same properties.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

export interface StatusObject {
    path: string;
    messages?: number;
    recent?: number;
    uid?: number;
    uidValidity?: bigint;
    unseen?: number;
    highestModSeq?: bigint;
}


export interface StatusQuery {
    messages?: boolean;
    recent?: boolean;
    uidNext?: boolean;
    uidValidity?: boolean;
    unseen?: boolean;
    highestModseq?: boolean;
}

They have a different structure.

export interface StatusObject {
  path: string;
  uid?: number;
}

export interface StatusQuery {
  uidNext?: boolean;
}

Therefore, they cannot be StatusQuery extends StatusObject or StatusObject extends StatusQuery.

path: string;
message?: number;
messages?: number;
recent?: number;
uid?: number;
uidValidity?: bigint;
Expand All @@ -318,6 +321,7 @@ export interface ListResponse {
specialUse: string;
listed: boolean;
subscribed: boolean;
status?: StatusObject;
}

export interface ListTreeResponse {
Expand Down Expand Up @@ -362,3 +366,19 @@ export interface Logger {
warn: (obj: object) => void;
error: (obj: object) => void;
}

export interface StatusQuery {
messages?: boolean;
recent?: boolean;
uidNext?: boolean;
uidValidity?: boolean;
unseen?: boolean;
highestModseq?: boolean;
}

export interface SpecialUseHints {
sent: string;
trash: string;
junk: string;
drafts: string;
}