import fs, { ReadStream } from 'fs';
import tough from 'tough-cookie';
import { Agent, Dispatcher } from 'undici';
import { IncomingHttpHeaders } from 'http';

declare class InvalidInterwikiError extends Error {
    constructor(interwiki: string);
}

declare class MediaWikiError extends Error {
    data: unknown;
    constructor(error: unknown);
}

interface Request {
}
declare type ActionRequest = Request;
interface AddActionQueryToken {
    action: 'query';
    token?: string;
}
interface QueryRequest extends Request {
    /**
     * When more results are available, use this to continue.
     */
    continue?: string;
    /**
     * Convert titles to other variants if necessary. Only works if the wiki's content language supports variant conversion. Languages that support variant conversion include ban, en, crh, gan, iu, kk, ku, shi, sr, tg, uz and zh.
     */
    converttitles?: boolean;
    /**
     * Export the current revisions of all given or generated pages.
     */
    export?: boolean;
    /**
     * Return the export XML without wrapping it in an XML result (same format as Special:Export). Can only be used with query+export.
     */
    exportnowrap?: boolean;
    /**
     * Target the given version of the XML dump format when exporting. Can only be used with query+export.
     */
    exportschema?: '0.10' | '0.11';
    /**
     * Include an additional pageids section listing all returned page IDs.
     */
    indexpageids?: boolean;
    /**
     * Whether to get the full URL if the title is an interwiki link.
     */
    iwurl?: boolean;
    /**
     * A list of page IDs to work on.
     */
    pageids?: number | number[];
    /**
     * Return raw query-continue data for continuation.
     */
    rawcontinue?: boolean;
    /**
     * Automatically resolve redirects in query+titles, query+pageids, and query+revids, and in pages returned by query+generator.
     */
    redirects?: boolean;
    /**
     * A list of revision IDs to work on.
     */
    revids?: number | number[];
    /**
     * A list of titles to work on.
     */
    titles?: string | string[];
}
declare type JSONRequest<T extends Request> = T & {
    format: 'json';
    formatversion: 2;
};
declare type NoActionToken<T extends Request> = Omit<T, 'action' | 'token'>;
declare type RequestParameterType = string | number | boolean | string[] | number[] | undefined;

/**
 * Options to block an user.
 */
interface BlockRequest extends ActionRequest {
    action: 'block';
    /**
     * Allow the user to edit their own talk page.
     */
    allowusertalk?: boolean;
    /**
     * Block anonymous users only (i.e. disable anonymous edits for this IP address).
     */
    anononly?: boolean;
    /**
     * Automatically block the last used IP address, and any subsequent IP addresses they try to login from.
     */
    autoblock?: boolean;
    /**
     * Expiry time. May be relative (e.g. `5 months` or `2 weeks`) or absolute (e.g. `2014-09-18T12:34:56Z`). If set to `infinite`, `indefinite`, or `never`, the block will never expire.
     * @default `never`
     */
    expiry?: string;
    /**
     * Prevent account creation.
     */
    nocreate?: boolean;
    /**
     * Prevent user from sending email through the wiki. (Requires the `blockemail` right).
     */
    noemail?: boolean;
    /**
     * If the user is already blocked, overwrite the existing block.
     */
    reblock?: boolean;
    /**
     * Reason for block.
     */
    reason?: string;
    /**
     * User to block.
     */
    user: string;
}
interface BlockResponse extends Response {
    block: {
        allowusertalk?: boolean;
        anononly?: boolean;
        autoblock?: boolean;
        expiry: string;
        hidename?: boolean;
        id: number;
        nocreate?: boolean;
        noemail?: boolean;
        reason: string;
        user: string;
        userID: number;
        watchuser?: boolean;
    };
}

declare type RequireOnlyOne<T, U extends keyof T, V extends keyof T> = Omit<T, U | V> & (({
    [k in U]: T[U];
} & {
    [k in V]?: undefined;
}) | ({
    [k in V]: T[V];
} & {
    [k in U]?: undefined;
}));
declare type RequireOnlyOneFromThree<T, U extends keyof T, V extends keyof T, W extends keyof T> = Omit<T, U | V | W> & (({
    [k in U]: T[U];
} & {
    [k in V | W]?: undefined;
}) | ({
    [k in V]: T[V];
} & {
    [k in U | W]?: undefined;
}) | ({
    [k in W]: T[W];
} & {
    [k in U | V]?: undefined;
}));
declare type MaybeArray<T> = T | T[];

interface BaseDeleteRequest extends ActionRequest {
    action: 'delete';
    /**
     * Page ID of the page to delete.
     */
    pageid: number;
    /**
     * Reason for the deletion. If not set, an automatically generated reason will be used.
     */
    reason?: string;
    /**
     * Title of the page to delete.
     */
    title: string;
}
/**
 * Options to delete a page.
 */
declare type DeleteRequest = RequireOnlyOne<BaseDeleteRequest, 'title', 'pageid'>;
interface DeleteResponse extends Response {
    delete: {
        logid: number;
        reason: string;
        title: string;
    };
}

interface BaseEditRequest extends ActionRequest {
    action: 'edit';
    /**
     * Add this text to the end of the page.
     */
    appendtext?: string;
    /**
     * Mark this edit as a bot edit.
     */
    bot?: boolean;
    /**
     * Don't edit the page if it exists already.
     */
    createonly?: boolean;
    /**
     * Mark this edit as a minor edit.
     */
    minor?: boolean;
    /**
     * Throw an error if the page doesn't exist.
     */
    nocreate?: boolean;
    /**
     * Do not mark this edit as a minor edit even if the "Mark all edits minor by default" user preference is set.
     */
    notminor?: boolean;
    /**
     * Page ID of the page to edit.
     */
    pageid?: number;
    /**
     * Add this text to the beginning of the page.
     */
    prependtext?: string;
    /**
     * Override any errors about the page having been deleted in the meantime.
     */
    recreate?: boolean;
    /**
     * Page content.
     */
    text: string;
    /**
     * Title of the page to edit.
     */
    title?: string;
    /**
     * Undo this revision. The value must be no less than 0.
     */
    undo?: number;
    /**
     * Undo all revisions from undo to this one. If not set, just undo one revision. The value must be no less than 0.
     */
    undoafter?: number;
    /**
     * Edit summary.
     */
    summary?: string;
}
/**
 * Options to edit a page.
 */
declare type EditRequest = RequireOnlyOneFromThree<BaseEditRequest, 'appendtext', 'prependtext', 'text'>;
interface EditResponse extends Response {
    edit: {
        newrevid: number;
        newtimestamp: string;
        oldrevid: number;
        pageid: number;
        result: string;
        title: string;
    };
}

interface LoginRequest extends ActionRequest {
    action: 'login';
    /**
     * User name.
     */
    lgname: string;
    /**
     * Password.
     */
    lgpassword: string;
    /**
     * A "login" token.
     */
    lgtoken: string;
}
interface LoginResponse extends Response {
    login: {
        lguserid: number;
        lgusername: string;
        result: 'Success';
    } | {
        reason: string;
        result: 'Failed';
    };
}

interface BaseMoveRequest extends ActionRequest {
    action: 'move';
    /**
     * Title of the page to rename.
     */
    from: string;
    /**
     * Page ID of the page to rename.
     */
    fromid: number;
    /**
     * Ignore any warnings.
     */
    ignorewarnings?: boolean;
    /**
     * Rename subpages, if applicable.
     */
    movesubpages?: boolean;
    /**
     * Rename the talk page, if it exists.
     */
    movetalk?: boolean;
    /**
     * Don't create a redirect.
     * @default false
     */
    noredirect?: boolean;
    /**
     * Reason for the rename.
     */
    reason?: string;
    /**
     * Title to rename the page to.
     */
    to: string;
}
/**
 * Options to move a page.
 */
declare type MoveRequest = RequireOnlyOne<BaseMoveRequest, 'from', 'fromid'>;
interface MoveResponse extends Response {
    move: {
        from: string;
        reason?: string;
        talkfrom?: string;
        talkto?: string;
        to: string;
    };
}

/**
 * Search the wiki using the OpenSearch protocol.
 */
interface OpenSearchRequest extends ActionRequest {
    /**
     * Maximum number of results to return.
     */
    limit?: number | 'max';
    /**
     * Namespaces to search. Ignored if search begins with a valid namespace prefix.
     * @default 0
     */
    namespace?: number | number[] | '*';
    /**
     * Search profile to use.
    `strict`: Strict profile with few punctuation characters removed but diacritics and stress marks are kept.\n
    `normal`: Few punctuation characters, some diacritics and stopwords removed.
    `normal-subphrases`: Few punctuation characters, some diacritics and stopwords removed. It will match also subphrases (can be subphrases or subpages depending on internal wiki configuration).
    `fuzzy`: Similar to normal with typo correction (two typos supported).
    `fast-fuzzy`: Experimental fuzzy profile (may be removed at any time)
    `fuzzy-subphrases`: Similar to normal with typo correction (two typos supported). It will match also subphrases (can be subphrases or subpages depending on internal wiki configuration).
    `classic`: Classic prefix, few punctuation characters and some diacritics removed.
    `engine_autoselect`: Let the search engine decide on the best profile to use.
     * @default 'engine_autoselect'
     */
    profile?: 'strict' | 'normal' | 'normal-subphrases' | 'fuzzy' | 'fast-fuzzy' | 'fuzzy-subphrases' | 'classic' | 'engine_autoselect';
    /**
     * How to handle redirects.
     */
    redirects?: 'return' | 'resolve';
    /**
     * Search string.
     */
    search: string;
}
declare type OpenSearchResponseArray = [string, string[], string[], string[]];
interface OpenSearchResponse extends Response, OpenSearchResponseArray {
}

/**
 * Parses content and returns parser output.
 */
interface ParseRequest extends ActionRequest {
    action: 'parse';
    /**
     * Content serialization format used for the input text. Only valid when used with `text`.
     */
    contentformat?: 'application/json' | 'application/octet-stream' | 'application/unknown' | 'application/x-binary' | 'text/css' | 'text/javascript' | 'text/plain' | 'text/unknown' | 'text/x-wiki' | 'unknown/unknown';
    /**
     * Content model of the input text. If omitted, title must be specified, and default will be the model of the specified title. Only valid when used with `text`.
     */
    contentmodel?: 'GadgetDefinition' | 'Json.JsonConfig' | 'JsonSchema' | 'Map.JsonConfig' | 'MassMessageListContent' | 'NewsletterContent' | 'Scribunto' | 'SecurePoll' | 'Tabular.JsonConfig' | 'css' | 'flow-board' | 'javascript' | 'json' | 'sanitized-css' | 'text' | 'translate-messagebundle' | 'unknown' | 'wikitext';
    /**
     * Omit edit section links from the parser output.
     */
    disableeditsection?: boolean;
    /**
     * Omit the limit report ("NewPP limit report") from the parser output.
     */
    disablelimitreport?: boolean;
    /**
     * Do not deduplicate inline stylesheets in the parser output.
     */
    disablestylededuplication?: boolean;
    /**
     * Omit table of contents in output.
     */
    disabletoc?: boolean;
    /**
     * Apply mobile main page transformations.
     */
    mainpage?: boolean;
    /**
     * Return parse output in a format suitable for mobile devices.
     */
    mobileformat?: boolean;
    /**
     * Parse the content of this revision. Overrides `page` and `pageid`.
     */
    oldid?: number;
    /**
     * Do a pre-save transform (PST) on the input, but don't parse it. Returns the same wikitext, after a PST has been applied. Only valid when used with `text`.
     */
    onlypst?: boolean;
    /**
     * Parse the content of this page. Cannot be used together with `text` and `title`.
     */
    page?: string;
    /**
     * Parse the content of this page. Overrides `page`.
     */
    pageid?: number;
    /**
     * Parse in preview mode.
     */
    preview?: boolean;
    /**
     * Which pieces of information to get.
     */
    prop?: MaybeArray<'text' | 'langlinks' | 'categories' | 'categorieshtml' | 'links' | 'templates' | 'images' | 'externallinks' | 'sections' | 'revid' | 'displaytitle' | 'subtitle' | 'headhtml' | 'modules' | 'jsconfigvars' | 'encodedjsconfigvars' | 'indicators' | 'iwlinks' | 'wikitext' | 'properties' | 'limitreportdata' | 'limitreporthtml' | 'parsetree' | 'parsewarnings' | 'parsewarningshtml'>;
    /**
     * Do a pre-save transform on the input before parsing it. Only valid when used with `text`.
     */
    pst?: boolean;
    /**
     * If `page` or `pageid` is set to a redirect, resolve it.
     */
    redirects?: boolean;
    /**
     * Revision ID, for `{{REVISIONID}}` and similar variables.
     */
    revid?: number;
    /**
     * Only parse the content of this section number.
     */
    section?: number | 'new';
    /**
     * Parse in section preview mode (enables preview mode too).
     */
    sectionpreview?: boolean;
    /**
     * New section title when `section` is `new`.
     */
    sectiontitle?: string;
    /**
     * Summary to parse.
     */
    summary?: string;
    /**
     * Content format of `templatesandboxtext`.
     */
    templatesandboxcontentformat?: 'application/json' | 'application/octet-stream' | 'application/unknown' | 'application/x-binary' | 'text/css' | 'text/javascript' | 'text/plain' | 'text/unknown' | 'text/x-wiki' | 'unknown/unknown';
    /**
     * Content model of `templatesandboxtext`.
     */
    templatesandboxcontentmodel?: 'GadgetDefinition' | 'Json.JsonConfig' | 'JsonSchema' | 'Map.JsonConfig' | 'MassMessageListContent' | 'NewsletterContent' | 'Scribunto' | 'SecurePoll' | 'Tabular.JsonConfig' | 'css' | 'flow-board' | 'javascript' | 'json' | 'sanitized-css' | 'text' | 'translate-messagebundle' | 'unknown' | 'wikitext';
    /**
     * Template sandbox prefix, as with Special:TemplateSandbox.
     */
    templatesanboxprefix?: string | string[];
    /**
     * Parse the page using this page content in place of the page named by `templatesandboxtitle`.
     */
    templatesandboxtext?: string;
    /**
     * Parse the page using `templatesandboxtext` in place of the contents of the page named here.
     */
    templatesandboxtitle?: string;
    /**
     * Text to parse. Use `title` or `contentmodel` to control the content model.
     */
    text?: string;
    /**
     * Title of page the text belongs to. If omitted, `contentmodel` must be specified, and "API" will be used as the title.
     */
    title?: string;
    /**
     * Apply the selected skin to the parser output. May affect the following properties: `langlinks`, `headitems`, `modules`, `jsconfigvars`, `indicators`.
     */
    useskin?: string;
    /**
     * CSS class to use to wrap the parser output.
     * @default 'mw-parser-output'
     */
    wrapoutputclass?: string;
}
interface ParseResponse extends Response {
    parse: {
        title: string;
        pageid: number;
        revid: number;
        text: string;
        langlinks: Array<{
            lang: string;
            url: string;
            langname: string;
            autonym: string;
            title: string;
        }>;
        categories: Array<{
            sortkey: string;
            category: string;
            hidden?: boolean;
        }>;
        links: Array<{
            ns: number;
            title: string;
            exists: boolean;
        }>;
        templates: Array<{
            ns: number;
            title: string;
            exists: boolean;
        }>;
        images: string[];
        externallinks: string[];
        sections: Array<{
            toclevel: number;
            level: string;
            line: string;
            number: string;
            index: string;
            fromtitle: string;
            byteoffset: number;
            anchor: string;
        }>;
        displaytitle: string;
        iwlinks: Array<{
            prefix: string;
            url: string;
            title: string;
        }>;
        properties: Record<string, string>;
    };
}

declare type ProtectionAction = 'edit' | 'move';
declare type ProtectionLevel = 'all' | 'autoconfirmed' | 'sysop';
interface BaseProtectRequest<Action extends string = ProtectionAction, Level extends string = ProtectionLevel> extends ActionRequest {
    action: 'protect';
    /**
     * Enable cascading protection (i.e. protect transcluded templates and images used in this page). Ignored if none of the given protection levels support cascading.
     */
    cascade?: boolean;
    /**
     * Expiry timestamps. If only one timestamp is set, it'll be used for all protections. Use infinite, `indefinite`, `infinity`, or `never`, for a never-expiring protection.
     */
    expiry?: string;
    /**
     * ID of the page to (un)protect.
     */
    pageid: number;
    /**
     * List of protection levels, formatted `action=level` (e.g. `edit=sysop`). A level of all means everyone is allowed to take the action, i.e. no restriction.
     * Note: Any actions not listed will have restrictions removed.
     */
    protections: MaybeArray<`${Action}=${Level}`> | '';
    /**
     * Reason for (un)protecting.
     */
    reason?: string;
    /**
     * Title of the page to (un)protect. Cannot be used together with pageid.
     */
    title: string;
}
/**
 * Options to protect a page.
 */
declare type ProtectRequest<Action extends string = ProtectionAction, Level extends string = ProtectionLevel> = RequireOnlyOne<BaseProtectRequest<Action, Level>, 'title', 'pageid'>;
interface ProtectResponse extends Response {
    protect: {
        protections: string[];
        reason: string;
        title: string;
    };
}

interface BasePurgeRequest extends ActionRequest {
    action: 'purge';
    /**
     * When more results are available, use this to continue.
     */
    continue?: string;
    /**
     * Convert titles to other variants if necessary. Only works if the wiki's content language supports variant conversion. Languages that support variant conversion include ban, en, crh, gan, iu, kk, ku, shi, sr, tg, uz and zh.
     */
    converttitles?: boolean;
    /**
     * Update the links tables and do other secondary data updates.
     */
    forcelinkupdate?: boolean;
    /**
     * Same as `forcelinkupdate`, and update the links tables for any page that uses this page as a template.
     */
    forcerecursivelinkupdate?: boolean;
    /**
     * A list of page IDs to work on.
     */
    pageids: number | number[];
    /**
     * Automatically resolve redirects.
     */
    redirects?: boolean;
    /**
     * A list of revision IDs to work on.
     */
    revids: number | number[];
    /**
     * A list of titles to work on.
     */
    titles: string | string[];
}
/**
 * Options to purge the cache for the given titles.
 */
declare type PurgeRequest = RequireOnlyOneFromThree<BasePurgeRequest, 'pageids', 'revids', 'titles'>;
interface PurgeResponse extends Response {
    purge: Array<{
        ns: number;
        title: string;
    } & ({
        missing: string;
    } | {
        purged: string;
    })>;
}

interface BaseRollbackRequest extends ActionRequest {
    action: 'rollback';
    /**
     * Mark the reverted edits and the revert as bot edits.
     */
    markbot?: boolean;
    /**
     * Page ID of the page to roll back. Cannot be used together with `title`.
     */
    pageid: number;
    /**
     * Custom edit summary. If empty, default summary will be used.
     */
    summary?: string;
    /**
     * Tags to apply to the rollback.
     */
    tags?: MaybeArray<string>;
    /**
     * Title of the page to roll back. Cannot be used together with `pageid`.
     */
    title: string;
    /**
     * A "rollback" (CSRF) token.
     */
    token: string;
    /**
     * Name of the user whose edits are to be rolled back.
     */
    user: string;
}
/**
 * Options to Rollback the cache for the given titles.
 */
declare type RollbackRequest = RequireOnlyOne<BaseRollbackRequest, 'pageid', 'title'>;
interface RollbackResponse extends Response {
    rollback: {
        last_revid: number;
        old_revid: number;
        pageid: number;
        revid: number;
        summary: string;
        title: string;
    };
}

/**
 * Options to block an user.
 */
interface UnblockRequest extends ActionRequest {
    action: 'unblock';
    /**
     * ID of the block to unblock (obtained through `list=blocks`). Cannot be used together with `user`.
     */
    id?: number;
    /**
     * Reason for unblock.
     */
    reason?: string;
    /**
     * Change tags to apply to the entry in the block log.
     */
    tags?: MaybeArray<string>;
    /**
     * User to unblock. Cannot be used together with `id`.
     */
    user?: string;
}
interface UnblockResponse extends Response {
    unblock: {
        id: string;
        reason: string;
        user: string;
        userid: number;
    };
}

interface BaseUndeleteRequest extends ActionRequest {
    action: 'undelete';
    /**
     * IDs of the file revisions to restore. If both timestamps and fileids are empty, all will be restored.
     */
    fileids?: MaybeArray<number>;
    /**
     * Page ID of the page to delete.
     */
    pageid: number;
    /**
     * Reason for restoring.
     */
    reason?: string;
    /**
     * Change tags to apply to the entry in the deletion log.
     */
    tags?: MaybeArray<string>;
    /**
     * Timestamps of the revisions to undelete. If both timestamps and fileids are empty, all will be undeleted.
     */
    timestamps?: MaybeArray<string>;
    /**
     * Title of the page to undelete.
     */
    title: string;
    /**
     * A "csrf" token.
     */
    token: string;
    /**
     * Undelete all revisions of the associated talk page, if any.
     */
    undeletetalk?: boolean;
}
/**
 * Options to delete a page.
 */
declare type UndeleteRequest = RequireOnlyOne<BaseUndeleteRequest, 'title', 'pageid'>;
interface UndeleteResponse extends Response {
    undelete: {
        fileversions: number;
        reason: string;
        revisions: number;
        title: string;
    };
}

interface BaseUploadRequest extends ActionRequest {
    action: 'upload';
    /**
     * File contents.
     */
    file: ReadStream;
    /**
     * Target filename.
     */
    filename: string;
    /**
     * Ignore any warnings.
     */
    ignorewarnings?: boolean;
    /**
     * URL to fetch the file from.
     */
    url: string;
}
/**
 * Options to upload a file.
 */
declare type UploadRequest = RequireOnlyOne<BaseUploadRequest, 'file', 'url'>;
interface UploadResponse extends Response {
    upload: {
        result: 'Success' | string;
        filename?: string;
    };
}

interface Response$2 {
}
interface QueryResponse<Shortname extends string = string, Name extends string = string, QueryItem = Record<string, unknown>> {
    batchcomplete?: boolean;
    continue?: {
        [key in `${Shortname}continue`]: string;
    };
    query: {
        /**
         * Title normalization converts page titles to their canonical form.
         */
        normalized?: NormalizedInfo[];
        interwiki?: InterwikiInfo[];
        redirects?: RedirectInfo[];
        /**
         * Can show up if `converttitles` is set to true.
         */
        converted?: ConvertedInfo[];
    } & {
        [key in Name]: QueryItem[];
    };
}
interface NormalizedInfo extends Record<string, unknown> {
    fromencoded: boolean;
    from: string;
    to: string;
}
interface InterwikiInfo<Site extends string = string> extends Record<string, unknown> {
    title: `${Site}:${string}`;
    iw: Site;
    /**
     * Available if `iwurl` is set to true.
     */
    url?: string;
}
interface RedirectInfo extends Record<string, unknown> {
    from: string;
    to: string;
    /**
     * May contain a this attribute for those redirects that point to specific sections.
     */
    tofragment?: string;
}
interface ConvertedInfo extends Record<string, unknown> {
    from: string;
    to: string;
}
interface APIError {
    error: {
        code: string;
        info: string;
    };
}

/**
 * Options for `list=allcategories`
 */
interface AllCategoriesRequest extends QueryRequest {
    /**
     * When more results are available, use this to continue.
     */
    accontinue?: string;
    /**
     * Direction to sort in.
     */
    acdir?: 'ascending' | 'descending';
    /**
     * The category to start enumerating from.
     */
    acfrom?: string;
    /**
     * How many categories to return.
     */
    aclimit?: number | 'max';
    /**
     * Only return categories with at most this many members.
     */
    acmax?: number;
    /**
     * Only return categories with at least this many members.
     */
    acmin?: number;
    /**
     * Search for all category titles that begin with this value.
     */
    acprefix?: string;
    /**
     * Which properties to get.
     * `size`: Adds number of pages in the category.
     * `hidden`: Tags categories that are hidden with `__HIDDENCAT__`.
     */
    acprop?: MaybeArray<'size' | 'hidden'>;
    /**
     * The category to stop enumerating at.
     */
    acto?: string;
    list: 'allcategories';
}
interface AllCategoriesItem {
    category: string;
}
declare type AllCategoriesResponse = QueryResponse<'ac', 'allcategories', AllCategoriesItem>;

/**
 * Options for `list=allimages`
 */
interface AllImagesRequest extends QueryRequest {
    /**
     * When more results are available, use this to continue.
     */
    aicontinue?: string;
    /**
     * The direction in which to list.
     */
    aidir?: 'ascending' | 'descending' | 'newer' | 'older';
    /**
     * The timestamp to end enumerating. Can only be used with aisort=timestamp.
     */
    aiend?: string;
    /**
     * How to filter files uploaded by bots. Can only be used with `aisort=timestamp`. Cannot be used together with `aiuser`.
     */
    aifilterbots?: 'all' | 'bots' | 'nobots';
    /**
     * The image title to start enumerating from. Can only be used with `aisort=name`.
     */
    aifrom?: string;
    /**
     * How many images in total to return.
     */
    ailimit?: number | 'max';
    /**
     * Limit to images with at most this many bytes.
     */
    aimaxsize?: number;
    /**
     * Limit to images with at least this many bytes.
     */
    aiminsize?: number;
    /**
     * Search for all image titles that begin with this value. Can only be used with `aisort=name`.
     */
    aiprefix?: string;
    /**
     * Which file information to get.
     */
    aiprop?: MaybeArray<'timestamp' | 'user' | 'userid' | 'comment' | 'parsedcomment' | 'canonicaltitle' | 'url' | 'size' | 'dimensions' | 'sha1' | 'mime' | 'mediatype' | 'metadata' | 'commonmetadata' | 'extmetadata' | 'bitdepth' | 'badfile'>;
    /**
     * Property to sort by.
     */
    aisort?: 'name' | 'timestamp';
    /**
     * The timestamp to start enumerating from. Can only be used with `aisort=timestamp`.
     */
    aistart?: string;
    /**
     * Only return files uploaded by this user. Can only be used with `aisort=timestamp`. Cannot be used together with `aifilterbots`.
     */
    aiuser?: string;
    list: 'allimages';
}
interface AllImagesItem {
    name: string;
    timestamp: string;
    url: string;
    descriptionurl: string;
    descriptionshorturl: string;
    ns: number;
    title: string;
}
declare type AllImagesResponse = QueryResponse<'ai', 'allimages', AllImagesItem>;

/**
 * Options for `list=allpages`
 */
interface AllPagesRequest extends QueryRequest {
    /**
     * When more results are available, use this to continue.
     */
    apcontinue?: string;
    /**
     * Filter based on whether a page has langlinks. Note that this may not consider langlinks added by extensions.
     * @default 'all'
     */
    apfilterlanglinks?: 'all' | 'withlanglinks' | 'withoutlanglinks';
    /**
     * Which pages to list. \
     * Due to miser mode, using this may result in fewer than aplimit results returned before continuing; in extreme cases, zero results may be returned.
     * @default 'all'
     */
    apfilterredir?: 'all' | 'nonredirects' | 'redirects';
    /**
     * The page title to start enumerating from.
     */
    apfrom?: string;
    /**
     * How many total pages to return.
     */
    aplimit?: number | 'max';
    /**
     * Limit to pages with at most this many bytes.
     */
    apmaxsize?: number;
    /**
     * Limit to pages with at least this many bytes.
     */
    apminsize?: number;
    /**
     * The namespace to enumerate.
     */
    apnamespace?: number | number[];
    /**
     * Search for all page titles that begin with this value.
     */
    apprefix?: string;
    /**
     *     The page title to stop enumerating at.
     */
    apto?: string;
    list: 'allpages';
}
interface AllPagesItem {
    pageid: number;
    ns: number;
    title: string;
}
declare type AllPagesResponse = QueryResponse<'ap', 'allpages', AllPagesItem>;

interface BaseCategoryMembersRequest extends QueryRequest {
    /**
     * When more results are available, use this to continue.
     */
    cmcontinue?: string;
    /**
     * In which direction to sort.
     */
    cmdir?: 'ascending' | 'descending' | 'newer' | 'older';
    /**
     * Timestamp to end listing at. Can only be used with `cmsort=timestamp`.
     */
    cmend?: string;
    /**
     * The maximum number of pages to return.
     */
    cmlimit?: number | 'max';
    /**
     * Only include pages in these namespaces. Note that `cmtype=subcat` or `cmtype=file` may be used instead of `cmnamespace=14` or `6`. \
     * Due to miser mode, using this may result in fewer than cmlimit results returned before continuing; in extreme cases, zero results may be returned.
     */
    cmnamespace?: number | number[];
    /**
     * Page ID of the category to enumerate.
     */
    cmpageid: number;
    /**
     * Which pieces of information to include.
     */
    cmprop?: MaybeArray<'ids' | 'title' | 'sortkey' | 'sortkeyprefix' | 'type' | 'timestamp'>;
    /**
     * Property to sort by.
     */
    cmsort?: 'sortkey' | 'timestamp';
    /**
     * Timestamp to start listing from. Can only be used with `cmsort=timestamp`.
     */
    cmstart?: string;
    /**
     * Which category to enumerate (required). Must include the `Category:` prefix.
     */
    cmtitle: string;
    /**
     * Which type of category members to include. Ignored when `cmsort=timestamp` is set.
     */
    cmtype?: MaybeArray<'file' | 'page' | 'subcat'>;
    list: 'categorymembers';
}
/**
 * Options for `list=categorymembers`
 */
declare type CategoryMembersRequest = RequireOnlyOne<BaseCategoryMembersRequest, 'cmpageid', 'cmtitle'>;
interface CategoryMembersItem {
    pageid: number;
    ns: number;
    title: string;
}
declare type CategoryMembersResponse = QueryResponse<'cm', 'categorymembers', CategoryMembersItem>;

/**
 * Options for `list=logevents`
 */
interface LogEventsRequest extends QueryRequest {
    /**
     * Filter log actions to only this action. Overrides `letype`. In the list of possible values, values with the asterisk wildcard such as `action/*` can have different strings after the slash (/).
     */
    leaction?: 'abusefilter/create' | 'abusefilter/hit' | 'abusefilter/modify' | 'abusefilterprivatedetails/access' | 'block/block' | 'block/reblock' | 'block/unblock' | 'contentmodel/change' | 'contentmodel/new' | 'create/create' | 'delete/delete' | 'delete/delete_redir' | 'delete/delete_redir2' | 'delete/event' | 'delete/flow-delete-post' | 'delete/flow-delete-topic' | 'delete/flow-restore-post' | 'delete/flow-restore-topic' | 'delete/restore' | 'delete/revision' | 'gblblock/dwhitelist' | 'gblblock/gblock' | 'gblblock/gblock2' | 'gblblock/gunblock' | 'gblblock/modify' | 'gblblock/whitelist' | 'gblrename/merge' | 'gblrename/promote' | 'gblrename/rename' | 'gblrights/deleteset' | 'gblrights/groupperms' | 'gblrights/groupprms2' | 'gblrights/groupprms3' | 'gblrights/grouprename' | 'gblrights/newset' | 'gblrights/setchange' | 'gblrights/setnewtype' | 'gblrights/setrename' | 'gblrights/usergroups' | 'globalauth/delete' | 'globalauth/hide' | 'globalauth/lock' | 'globalauth/lockandhid' | 'globalauth/setstatus' | 'globalauth/unhide' | 'globalauth/unlock' | 'import/interwiki' | 'import/lqt-to-flow-topic' | 'import/upload' | 'interwiki/*' | 'liquidthreads/merge' | 'liquidthreads/move' | 'liquidthreads/resort' | 'liquidthreads/signatureedit' | 'liquidthreads/split' | 'liquidthreads/subjectedit' | 'lock/flow-lock-topic' | 'lock/flow-restore-topic' | 'managetags/activate' | 'managetags/create' | 'managetags/deactivate' | 'managetags/delete' | 'massmessage/*' | 'massmessage/failure' | 'massmessage/send' | 'massmessage/skipbadns' | 'massmessage/skipnouser' | 'massmessage/skipoptout' | 'merge/merge' | 'move/move' | 'move/move_redir' | 'newsletter/*' | 'newusers/autocreate' | 'newusers/byemail' | 'newusers/create' | 'newusers/create2' | 'newusers/forcecreatelocal' | 'newusers/newusers' | 'notifytranslators/sent' | 'oath/*' | 'pagelang/pagelang' | 'pagetranslation/associate' | 'pagetranslation/deletefnok' | 'pagetranslation/deletefok' | 'pagetranslation/deletelnok' | 'pagetranslation/deletelok' | 'pagetranslation/discourage' | 'pagetranslation/dissociate' | 'pagetranslation/encourage' | 'pagetranslation/mark' | 'pagetranslation/movenok' | 'pagetranslation/moveok' | 'pagetranslation/prioritylanguages' | 'pagetranslation/unmark' | 'patrol/autopatrol' | 'patrol/patrol' | 'protect/modify' | 'protect/move_prot' | 'protect/protect' | 'protect/unprotect' | 'renameuser/renameuser' | 'rights/autopromote' | 'rights/blockautopromote' | 'rights/restoreautopromote' | 'rights/rights' | 'spamblacklist/*' | 'suppress/block' | 'suppress/cadelete' | 'suppress/delete' | 'suppress/event' | 'suppress/flow-restore-post' | 'suppress/flow-restore-topic' | 'suppress/flow-suppress-post' | 'suppress/flow-suppress-topic' | 'suppress/hide-afl' | 'suppress/reblock' | 'suppress/revision' | 'suppress/setstatus' | 'suppress/unhide-afl' | 'tag/update' | 'thanks/*' | 'timedmediahandler/resettranscode' | 'titleblacklist/*' | 'translationreview/group' | 'translationreview/message' | 'upload/overwrite' | 'upload/revert' | 'upload/upload' | 'urlshortener/*' | 'usermerge/*';
    /**
     * In which direction to enumerate.
     */
    ledir?: 'newer' | 'older';
    /**
     * The timestamp to end enumerating.
     */
    leend?: string;
    /**
     * How many total event entries to return.
     */
    lelimit?: number | 'max';
    /**
     * Filter entries to those in the given namespace.
     */
    lenamespace?: number;
    /**
     * Which properties to get.
     */
    leprop?: MaybeArray<'ids' | 'title' | 'type' | 'user' | 'userid' | 'timestamp' | 'comment' | 'details' | 'tags'>;
    /**
     * The timestamp to start enumerating from.
     */
    lestart?: string;
    /**
     * Filter entries to those related to a page.
     */
    letitle?: string;
    /**
     * Filter log entries to only this type.
     */
    letype?: 'abusefilter' | 'abusefilterprivatedetails' | 'block' | 'contentmodel' | 'create' | 'delete' | 'gblblock' | 'gblrename' | 'gblrights' | 'globalauth' | 'import' | 'liquidthreads' | 'managetags' | 'massmessage' | 'merge' | 'move' | 'newsletter' | 'newusers' | 'notifytranslators' | 'oath' | 'pagelang' | 'pagetranslation' | 'patrol' | 'protect' | 'renameuser' | 'rights' | 'spamblacklist' | 'suppress' | 'tag' | 'thanks' | 'timedmediahandler' | 'titleblacklist' | 'translationreview' | 'upload' | 'urlshortener' | 'usermerge';
    /**
     * Filter entries to those made by the given user.
     */
    leuser?: string;
    list: 'logevents';
}
interface LogEventsItem {
    action: string;
    comment: string;
    logid: number;
    logpage: number;
    ns: number;
    pageid: number;
    timestamp: string;
    title: string;
    type: string;
    user: string;
}
declare type LogEventsResponse = QueryResponse<'le', 'logevents', LogEventsItem>;

/**
 * Options for `list=recentchanges`
 */
interface RecentChangesRequest extends QueryRequest {
    list: 'recentchanges';
    /**
     * In which direction to enumerate.
     */
    rcdir?: 'newer' | 'older';
    /**
     * The timestamp to end enumerating.
     */
    rcend?: string;
    /**
     * Don't list changes by this user.
     */
    rcexcludeuser?: string;
    /**
     * How many total changes to return.
     */
    rclimit?: number | 'max';
    /**
     * Filter changes to only these namespaces.
     */
    rcnamespace?: '*' | number | number[];
    /**
     * Include additional pieces of information.
     */
    rcprop?: MaybeArray<'user' | 'userid' | 'comment' | 'flags' | 'timestamp' | 'title' | 'ids' | 'sizes' | 'redirect' | 'patrolled' | 'loginfo' | 'tags' | 'parsedcomment'>;
    /**
     * Show only items that meet these criteria.
     */
    rcshow?: MaybeArray<'!anon' | '!autropatrolled' | '!bot' | '!minor' | '!patrolled' | '!redirect' | 'anon' | 'autopatrolled' | 'bot' | 'minor' | 'patrolled' | 'redirect' | 'unpatrolled'>;
    /**
     * The timestamp to start enumerating from.
     */
    rcstart?: string;
    /**
     * Only list changes by this user.
     */
    rcuser?: string;
    /**
     * Filter entries to those related to a page.
     */
    rctitle?: string;
    /**
     * Only list changes which are the latest revision.
     */
    rctoponly?: boolean;
    /**
     * Which types of changes to show.
     */
    rctype?: MaybeArray<'edit' | 'new' | 'log' | 'categorize'>;
}
interface RecentChangesItem {
    type: string;
    ns: number;
    title: string;
    pageid: number;
    revid: number;
    old_revid: number;
    rcid: number;
    user: string;
    oldlen: number;
    newlen: number;
}
declare type RecentChangesResponse = QueryResponse<'rc', 'recentchanges', RecentChangesItem>;

interface BaseUserContribsRequest extends QueryRequest {
    list: 'usercontribs';
    /**
     * When more results are available, use this to continue.
     */
    uccontinue?: string;
    /**
     * In which direction to enumerate.
     */
    ucdir?: 'newer' | 'older';
    /**
     * The end timestamp to return to, i.e. revisions after this timestamp.
     */
    ucend?: string;
    /**
     * The maximum number of contributions to return.
     */
    uclimit?: number | 'max';
    /**
     * Only list contributions in these namespaces.
     */
    ucnamespace?: number | number[];
    /**
     * Include additional pieces of information.
     */
    ucprop?: MaybeArray<'ids' | 'title' | 'timestamp' | 'comment' | 'parsedcomment' | 'size' | 'sizediff' | 'flags' | 'patrolled' | 'tags'>;
    /**
     * Show only items that meet these criteria.
     */
    ucshow?: MaybeArray<'!autopatrolled' | '!minor' | '!new' | '!patrolled' | '!top' | 'autopatrolled' | 'minor' | 'new' | 'patrolled' | 'top'>;
    /**
     * The start timestamp to return from, i.e. revisions before this timestamp.
     */
    ucstart?: string;
    /**
     * Only list revisions tagged with this tag.
     */
    uctag?: string;
    /**
     * The users to retrieve contributions for.
     */
    ucuser: string | string[];
    /**
     * The user IDs to retrieve contributions for.
     */
    ucuserids: number | number[];
    /**
     * Retrieve contributions for all users whose names begin with this value.
     */
    ucuserprefix: string;
}
/**
 * Options for `list=usercontribs`
 */
declare type UserContribsRequest = RequireOnlyOneFromThree<BaseUserContribsRequest, 'ucuser', 'ucuserids', 'ucuserprefix'>;
interface UserContribsItem {
    userid: number;
    user: string;
    pageid: number;
    revid: number;
    parentid: number;
    ns: number;
    title: string;
    timestamp: string;
    comment: string;
    size: number;
}
declare type UserContribsResponse = QueryResponse<'uc', 'usercontribs', UserContribsItem>;

interface BaseUsersRequest extends QueryRequest {
    list: 'users';
    /**
     * Which pieces of information to include.
     */
    usprop?: MaybeArray<'blockinfo' | 'groups' | 'groupmemberships' | 'implicitgroups' | 'rights' | 'editcount' | 'registration' | 'emailable' | 'gender' | 'centralids' | 'cancreate'>;
    /**
     * A list of users to obtain information for.
     */
    ususers: string | string[];
    /**
     * A list of user IDs to obtain information for.
     */
    ususerids: number | number[];
}
/**
 * Options for `list=users`
 */
declare type UsersRequest = RequireOnlyOne<BaseUsersRequest, 'ususers', 'ususerids'>;
interface UsersItem {
    userid: number;
    name: string;
    groups: string[];
    rights: string[];
}
declare type UsersResponse = QueryResponse<'us', 'users', UsersItem>;

/**
 * Options for `meta=allmessages`.
 */
interface AllMessagesRequest extends QueryRequest {
    /**
     * Arguments to be substituted into message.
     */
    amargs?: string | string[];
    /**
     * Return only messages in this customisation state.
     * @default 'all'
     */
    amcustomised?: 'all' | 'modified' | 'unmodified';
    /**
     * Set to enable parser, will preprocess the wikitext of message (substitute magic words, handle templates, etc.).
     */
    amenableparser?: boolean;
    /**
     * Return only messages with names that contain this string.
     */
    amfilter?: string;
    /**
     * Return messages starting at this message.
     */
    amfrom?: string;
    /**
     * Return messages in this language.
     */
    amlang?: string;
    /**
     * Which messages to output.
     * @default '*'
     */
    ammessages: string | string[];
    /**
     * Also include local messages, i.e. messages that don't exist in the software but do exist as in the MediaWiki namespace. \
     * This lists all MediaWiki-namespace pages, so it will also list those that aren't really messages such as Common.js.
     */
    amincludelocal?: boolean;
    /**
     * If set, do not include the content of the messages in the output.
     */
    amnocontent?: boolean;
    /**
     * Return messages with this prefix.
     */
    amprefix?: string;
    /**
     * Page name to use as context when parsing message (for amenableparser option).
     */
    amtitle?: string;
    /**
     * Return messages ending at this message.
     */
    amto?: string;
    meta: 'allmessages';
}
declare type AllMessagesResponse = QueryResponse<'am', 'allmessages', {
    name: string;
    normalizedname: string;
    '*': string;
}>;

/**
 * Options for `meta=filerepoinfo`.
 */
interface FileRepoInfoRequest extends QueryRequest {
    /**
     * Which repository properties to get (properties available may vary on other wikis). \
     * \
     * Available default options: `canUpload`, `descBaseUrl`, `descriptionCacheExpiry`, `displayname`, `favicon`, `fetchDescription`, `initialCapital`, `local`, `name`, `rootUrl`, `scriptDirUrl`, `thumbUrl`, `url`.
     */
    friprop: string | string[];
    meta: 'filerepoinfo';
}
declare type FileRepoInfoResponse = QueryResponse<'am', 'repos', {
    displayname: string;
    name: string;
    url: string;
}>;

/**
 * Options for `meta=siteinfo`.
 */
interface SiteInfoRequest extends QueryRequest {
    meta: 'siteinfo';
    /**
     * Return only local or only nonlocal entries of the interwiki map.
     */
    sifilteriw?: 'local' | '!local';
    /**
     * Language code for localised language names (best effort) and skin names.
     */
    siinlanguagecode?: string;
    /**
     * Lists the number of users in user groups.
     */
    sinumberingroup?: boolean;
    /**
     * Which information to get.
     */
    siprop: MaybeArray<'general' | 'namespaces' | 'namespacealiases' | 'specialpagealiases' | 'magicwords' | 'interwikimap' | 'dbrepllag' | 'statistics' | 'usergroups' | 'libraries' | 'extensions' | 'fileextensions' | 'rightsinfo' | 'restrictions' | 'languages' | 'languagevariants' | 'skins' | 'extensiontags' | 'functionhooks' | 'showhooks' | 'variables' | 'protocols' | 'defaultoptions' | 'uploaddialog'>;
    /**
     * List all database servers, not just the one lagging the most.
     */
    sishowalldb?: boolean;
}
interface SiteInfoResponse extends Response$2 {
    query: {
        dbrepllag: Array<{
            host: string;
            lag: number;
        }>;
        defaultoptions: Record<string, unknown>;
        extensions: Array<{
            author: string;
            descriptionmsg: string;
            license: string;
            'license-name': string;
            name: string;
            type: string;
            url: string;
            version: string;
        }>;
        extensiontags: string[];
        fileextensions: Array<{
            ext: string;
        }>;
        functionhooks: string[];
        general: {
            allunicodefixes: boolean;
            articlepath: string;
            base: string;
            case: string;
            dbtype: string;
            dbversion: string;
            externalimages: string[];
            favicon: string;
            generator: string;
            imagewhitelistenabled: boolean;
            invalidusernamechars: string;
            lang: string;
            langconversion: boolean;
            legaltitlechars: string;
            linktrail: string;
            logo: string;
            mainpage: string;
            maxarticlesize: number;
            maxuploadsize: number;
            minuploadchunksize: number;
            misermode: boolean;
            phpversion: string;
            readonly: boolean;
            script: string;
            scriptpath: string;
            server: string;
            servername: string;
            sitename: string;
            timezone: string;
            titleconversion: boolean;
            uploadsenabled: boolean;
            wikiid: string;
            writeapi: boolean;
        };
        interwikimap: Array<{
            api?: string;
            local?: boolean;
            prefix: string;
            url: string;
            wikiid?: string;
        } | {
            language: string;
            local: true;
            prefix: string;
            url: string;
        }>;
        languages: Array<{
            bcp47: string;
            code: string;
            name: string;
        }>;
        languagevariants: Record<string, unknown>;
        libraries: Array<{
            name: string;
            version: unknown;
        }>;
        magicwords: Array<{
            aliases: string[];
            'case-sensitive': boolean;
            name: string;
        }>;
        namespaces: Array<{
            canonical?: string;
            content: boolean;
            id: number;
            name: string;
            noincludable: boolean;
            subpages: boolean;
        }>;
        namespacealiases: Array<{
            alias: string;
            id: number;
        }>;
        protocols: string[];
        rightsinfo: {
            text: string;
            url: string;
        };
        restrictions: {
            cascadinglevels: string[];
            levels: string[];
            semiprotectedlevels: string[];
            types: string[];
        };
        showhooks: Array<{
            name: string;
            subscribers: string[];
        }>;
        skins: Array<{
            code: string;
            default?: boolean;
            name: string;
            unusable?: boolean;
        }>;
        specialpagealiases: Array<{
            aliases: string[];
            realname: string;
        }>;
        statistics: {
            activeusers: number;
            admins: number;
            articles: number;
            edits: number;
            images: number;
            jobs: number;
            pages: number;
            users: number;
        };
        uploaddialog: {
            comment: {
                foreign: string;
                local: string;
            };
            fields: {
                categories: boolean;
                date: boolean;
                description: boolean;
            };
            format: {
                description: string;
                filepage: string;
                license: string;
                onwork: string;
                uncategorized: string;
            };
            licensemessages: {
                foreign: string;
                local: string;
            };
        };
        usergroups: Array<{
            name: string;
            rights: string[];
        }>;
        variables: Array<{
            id: string;
            '*': unknown;
        }>;
    };
}

declare type TokenType = 'createaccount' | 'csrf' | 'deleteglobalaccount' | 'login' | 'patrol' | 'rollback' | 'setglobalaccountstatus' | 'userrights' | 'watch';
/**
 * Options for `meta=allmessages`.
 */
interface TokensRequest extends QueryRequest {
    meta: 'tokens';
    /**
     * Types of token to request.
     */
    type: MaybeArray<TokenType>;
}
interface TokensResponse<T extends TokenType = TokenType> extends Response$2 {
    query: {
        tokens: {
            [key in `${T}token`]: string;
        };
    };
}

/**
 * Options for `prop=categories`
 */
interface CategoriesRequest extends QueryRequest {
    prop: 'categories';
    titles: string | string[];
    /**
     * Only list these categories. Useful for checking whether a certain page is in a certain category.
     */
    clcategories?: MaybeArray<string>;
    /**
     * When more results are available, use this to continue.
     */
    clcontinue?: string;
    /**
     * The direction in which to list.
     */
    cldir?: 'ascending' | 'descending';
    /**
     * How many categories to return.
     */
    cllimit?: number | 'max';
    /**
     * Which additional properties to get for each category.
     */
    clprop?: MaybeArray<'hidden' | 'sortkey' | 'timestamp'>;
    /**
     * Which kind of categories to show.
     */
    clshow?: MaybeArray<'!hidden' | 'hidden'>;
}
interface CategoriesItem {
    ns: number;
    pageid: number;
    title: string;
    categories: Array<{
        hidden?: boolean;
        ns: number;
        sortkey: string;
        sortkeyprefix: string;
        timestamp: string;
        title: string;
    }>;
}
declare type CategoriesResponse = QueryResponse<'cl', 'pages', CategoriesItem>;

/**
 * Options for `prop=categoryinfo`
 */
interface CategoryInfoRequest extends QueryRequest {
    prop: 'categoryinfo';
    titles: string | string[];
    /**
     * When more results are available, use this to continue.
     */
    cicontinue?: string;
}
declare type CategoryInfoItem = {
    ns: number;
    title: string;
} & ({
    missing: true;
} | {
    categoryinfo: {
        files: number;
        hidden: boolean;
        pages: number;
        size: number;
        subcats: number;
    };
    missing?: false;
});
declare type CategoryInfoResponse = QueryResponse<'ci', 'pages', CategoryInfoItem>;

/**
 * Options for `prop=contributors`
 */
interface ContributorsRequest extends QueryRequest {
    prop: 'contributors';
    titles: string | string[];
    /**
     * When more results are available, use this to continue.
     */
    pccontinue?: string;
    /**
     * Exclude users in the given groups. Does not include implicit or auto-promoted groups like *, user, or autoconfirmed.
     */
    pcexcludegroup?: MaybeArray<string>;
    /**
     * Exclude users having the given rights. Does not include rights granted by implicit or auto-promoted groups like *, user, or autoconfirmed.
     */
    pcexcluderights?: MaybeArray<string>;
    /**
     * Only include users in the given groups. Does not include implicit or auto-promoted groups like *, user, or autoconfirmed.
     */
    pcgroup?: MaybeArray<string>;
    /**
     * How many contributors to return.
     */
    pclimit?: number | 'max';
    /**
     * Only include users having the given rights. Does not include rights granted by implicit or auto-promoted groups like *, user, or autoconfirmed.
     */
    pcrights?: MaybeArray<string>;
}
declare type ContributorsItem = {
    ns: number;
    title: string;
} & ({
    missing: true;
} | {
    anoncontributors: number;
    contributors: Array<{
        name: string;
        userid: number;
    }>;
    missing?: false;
    pageid: number;
});
declare type ContributorsResponse = QueryResponse<'pc', 'pages', ContributorsItem>;

/**
 * Options for `prop=deletedrevisions`
 */
interface DeletedRevisionsRequest extends QueryRequest {
    prop: 'deletedrevisions';
    titles: string | string[];
    /**
     * When more results are available, use this to continue.
     */
    drvcontinue?: string;
    /**
     * In which direction to enumerate.
     */
    drvdir?: 'newer' | 'older';
    /**
     * The timestamp to stop enumerating at. Ignored when processing a list of revision IDs.
     */
    drvend?: string;
    /**
     * Don't list revisions by this user.
     */
    drvexcludeuser?: string;
    /**
     * Limit how many revisions will be returned.
     */
    drvlimit?: number | 'max';
    /**
     * Which properties to get for each revision.
     */
    drvprop?: MaybeArray<'ids' | 'flags' | 'timestamp' | 'user' | 'userid' | 'size' | 'slotsize' | 'sha1' | 'slotsha1' | 'contentmodel' | 'comment' | 'parsedcomment' | 'content' | 'tags' | 'roles'>;
    /**
     * Only retrieve the content of the section with this identifier.
     */
    drvsection?: string;
    /**
     * Which revision slots to return data for, when slot-related properties are included in drvprops. If omitted, data from the main slot will be returned in a backwards-compatible format.
     */
    drvslots?: string;
    /**
     * The timestamp to start enumerating from. Ignored when processing a list of revision IDs.
     */
    drvstart?: string;
    /**
     * Only list revisions tagged with this tag.
     */
    drvtag?: string;
    /**
     * Only list revisions by this user.
     */
    drvuser?: string;
}
interface DeletedRevisionsItem {
    ns: number;
    title: string;
    deletedrevisions?: Array<{
        minor: boolean;
        parentid: number;
        revid: number;
        roles: string[];
        sha1: string;
        size: number;
        slots: {
            comment: string;
            main: {
                content: string;
                contentformat: string;
                contentmodel: string;
                sha1: string;
                size: number;
            };
            parsedcomment: string;
            tags: string[];
        };
        timestamp: string;
        user: string;
        userid: number;
    }>;
    missing?: true;
    pageid: number;
}
declare type DeletedRevisionsResponse = QueryResponse<'drv', 'pages', DeletedRevisionsItem>;

/**
 * Options for `prop=duplicatefiles`
 */
interface DuplicateFilesRequest extends QueryRequest {
    prop: 'duplicatefiles';
    titles: string | string[];
    /**
     * When more results are available, use this to continue.
     */
    dfcontinue?: string;
    /**
     * In which direction to enumerate.
     */
    dfdir?: 'ascending' | 'descending';
    /**
     * Limit how many revisions will be returned.
     */
    dflimit?: number | 'max';
    /**
     * Look only for files in the local repository.
     */
    dflocalonly?: boolean;
}
interface DuplicateFilesItem {
    duplicatefiles: Array<{
        name: string;
        shared: boolean;
        timestamp: string;
        user: string;
    }>;
    known?: boolean;
    missing?: true;
    ns: number;
    title: string;
}
declare type DuplicateFilesResponse = QueryResponse<'df', 'pages', DuplicateFilesItem>;

/**
 * Options for `prop=extlinks`
 */
interface ExtLinksRequest extends QueryRequest {
    prop: 'extlinks';
    titles: string | string[];
    /**
     * When more results are available, use this to continue.
     */
    elcontinue?: string;
    /**
     * Expand protocol-relative URLs with the canonical protocol.
     */
    elexpandurl?: boolean;
    /**
     * Limit how many revisions will be returned.
     */
    ellimit?: number | 'max';
    /**
     * Protocol of the URL. If empty and elquery is set, the protocol is http. Leave both this and elquery empty to list all external links.
     */
    elprotocol?: MaybeArray<'' | 'bitcoin' | 'ftp' | 'ftps' | 'geo' | 'git' | 'gopher' | 'http' | 'https' | 'irc' | 'ircs' | 'magnet' | 'mailto' | 'mms' | 'news' | 'nntp' | 'redis' | 'sftp' | 'sip' | 'sips' | 'sms' | 'ssh' | 'svn' | 'tel' | 'telnet' | 'urn' | 'worldwind' | 'xmpp'>;
    /**
     * Search string without protocol. Useful for checking whether a certain page contains a certain external url.
     */
    elquery?: string;
}
interface ExtLinksItem {
    extlinks?: Array<{
        url: string;
    }>;
    ns: number;
    pageid: number;
    title: string;
}
declare type ExtLinksResponse = QueryResponse<'el', 'pages', ExtLinksItem>;

/**
 * Options for `prop=fileusage`
 */
interface FileUsageRequest extends QueryRequest {
    prop: 'fileusage';
    titles: string | string[];
    /**
     * When more results are available, use this to continue.
     */
    fucontinue?: string;
    /**
     * Limit how many revisions will be returned.
     */
    fulimit?: number | 'max';
    /**
     * Only include pages in these namespaces.
     */
    funamespace: MaybeArray<number>;
    /**
     * Which properties to get.
     */
    fuprop?: MaybeArray<'pageid' | 'redirect' | 'title'>;
    /**
     * Show only items that meet these criteria.
     */
    fushow?: MaybeArray<'!redirect' | 'redirect'>;
}
interface FileUsageItem {
    fileusage: Array<{
        ns: number;
        pageid: number;
        redirect?: boolean;
        title: string;
    }>;
    ns: number;
    pageid: number;
    title: string;
}
declare type FileUsageResponse = QueryResponse<'fu', 'pages', FileUsageItem>;

/**
 * Options for `prop=imageinfo`
 */
interface ImageInfoRequest extends QueryRequest {
    prop: 'imageinfo';
    titles: string | string[];
    /**
     * When more results are available, use this to continue.
     */
    iicontinue?: string;
    /**
     * Timestamp to stop listing at.
     */
    iiend?: string;
    /**
     * If specified and non-empty, only these keys will be returned for `iiprop=extmetadata`.
     */
    iiextmetadatafilter?: MaybeArray<string>;
    /**
     * What language to fetch extmetadata in. This affects both which translation to fetch, if multiple are available, as well as how things like numbers and various values are formatted.
     */
    iiextmetadatalanguage?: string;
    /**
     * If translations for extmetadata property are available, fetch all of them.
     */
    iiextmetadatamultilang?: boolean;
    /**
     * Limit how many revisions will be returned.
     */
    iilimit?: number | 'max';
    /**
     * Look only for files in the local repository.
     */
    iilocalonly?: boolean;
    /**
     * Version of metadata to use. If latest is specified, use latest version. Defaults to `1` for backwards compatibility.
     */
    iimetadataversion?: number;
    /**
     * Which file information to get.
     */
    iiprop?: MaybeArray<'timestamp' | 'user' | 'userid' | 'comment' | 'parsedcomment' | 'canonicaltitle' | 'url' | 'size' | 'dimensions' | 'sha1' | 'mime' | 'thumbmime' | 'mediatype' | 'metadata' | 'commonmetadata' | 'extmetadata' | 'archivename' | 'bitdepth' | 'uploadwarning' | 'badfile'>;
    /**
     * Timestamp to start listing from.
     */
    iistart?: string;
    /**
     * Similar to `iiurlwidth`.
     */
    iiurlheight?: number;
    /**
     * A handler specific parameter string. For example, PDFs might use page15-100px. `iiurlwidth` must be used and be consistent with `iiurlparam`.
     */
    iiurlparam?: string;
    /**
     * If iiprop=url is set, a URL to an image scaled to this width will be returned.
        For performance reasons if this option is used, no more than 50 scaled images will be returned.
     */
    iiurlwidth?: number;
}
interface ImageInfoItem {
    imageinfo: Array<{
        canonicaltitle: string;
        comment: string;
        commonmetadata: Array<{
            name: string;
            value: unknown;
        }>;
        descriptionshorturl: string;
        descriptionurl: string;
        extmetadata: {
            DateTime: {
                hidden: string;
                source: string;
                value: string;
            };
            ObjectName: {
                hidden: string;
                source: string;
                value: string;
            };
            bitdepth: number;
            mediatype: string;
            mime: string;
        };
        height: number;
        html: string;
        metadata: Array<{
            name: string;
            value: unknown;
        }>;
        parsedcomment: string;
        sha1: string;
        size: number;
        timestamp: string;
        url: string;
        user: string;
        userid: number;
        width: number;
    }>;
    ns: number;
    pageid: number;
    title: string;
}
declare type ImageInfoResponse = QueryResponse<'ii', 'pages', ImageInfoItem>;

/**
 * Options for `prop=images`
 */
interface ImagesRequest extends QueryRequest {
    prop: 'images';
    titles: string | string[];
    /**
     * When more results are available, use this to continue.
     */
    imcontinue?: string;
    /**
     * The direction in which to list.
     */
    imdir?: 'ascending' | 'descending';
    /**
     * Only list these files. Useful for checking whether a certain page has a certain file.
     */
    imimages?: MaybeArray<string>;
    /**
     * How many files to return.
     */
    imlimit?: number | 'max';
}
interface ImagesItem {
    ns: number;
    pageid: number;
    title: string;
    Images: Array<{
        ns: number;
        title: string;
    }>;
}
declare type ImagesResponse = QueryResponse<'im', 'pages', ImagesItem>;

/**
 * Options for `prop=info`
 */
interface InfoRequest extends QueryRequest {
    prop: 'info';
    /**
     * When more results are available, use this to continue.
     */
    incontinue?: string;
    /**
     * The context title to use when determining extra CSS classes (e.g. link colors) when inprop contains linkclasses. Accepts non-existent pages.
     */
    inlinkcontext?: string;
    /**
     * Which additional properties to get.
     */
    inprop?: MaybeArray<'protection' | 'talkid' | 'watched' | 'watchers' | 'visitingwatchers' | 'notificationtimestamp' | 'subjectid' | 'associatedpage' | 'url' | 'preload' | 'displaytitle' | 'varianttitles' | 'linkclasses'>;
    /**
     * Test whether the current user can perform certain actions on the page.
     */
    intestactions?: string | string[];
    /**
     * Detail level for intestactions.
     * @default 'boolean'
     */
    intestactionsdetail?: 'boolean' | 'full' | 'quick';
}
interface InfoItem {
    pageid: number;
    ns: number;
    title: string;
    contentmodel: string;
    pagelanguage: string;
    pagelanguagehtmlcode: string;
    pagelanguagedir: string;
    touched: string;
    lastrevid: number;
    length: number;
    protection: Array<{
        type: string;
        level: string;
        expiry: string;
    }>;
    restrictiontypes: string[];
    watched: boolean;
    watchers: number;
    visitingwatchers: number;
    notificationtimestamp: string;
    fullurl: string;
    editurl: string;
    canonicalurl: string;
    preload: string;
    displaytitle: string;
    varianttitles: Record<string, string>;
}
declare type InfoResponse = QueryResponse<'in', 'pages', InfoItem>;

/**
 * Options for `prop=iwlinks`
 */
interface IwLinksRequest extends QueryRequest {
    prop: 'iwlinks';
    titles: string | string[];
    /**
     * When more results are available, use this to continue.
     */
    iwcontinue?: string;
    /**
     * The direction in which to list.
     */
    iwdir?: 'ascending' | 'descending';
    /**
     * How many interwiki links to return.
     */
    iwlimit?: number | 'max';
    /**
     * Only return interwiki links with this prefix.
     */
    iwprefix?: string;
    /**
     * Which additional properties to get for each interwiki link.
     */
    iwprop?: MaybeArray<'url'>;
    /**
     * Interwiki link to search for. Must be used with `iwprefix`.
     */
    iwtitle?: string;
}
interface IwLinksItem {
    ns: number;
    pageid: number;
    title: string;
    iwlinks: Array<{
        prefix: string;
        title: string;
        url: string;
    }>;
}
declare type IwLinksResponse = QueryResponse<'iw', 'pages', IwLinksItem>;

/**
 * Options for `prop=langlinks`
 */
interface LangLinksRequest extends QueryRequest {
    prop: 'langlinks';
    titles: string | string[];
    /**
     * When more results are available, use this to continue.
     */
    llcontinue?: string;
    /**
     * The direction in which to list.
     */
    lldir?: 'ascending' | 'descending';
    /**
     * Language code for localised language names.
     */
    llinlanguagecode?: string;
    /**
     * Only return language links with this language code.
     */
    lllang?: string;
    /**
     * How many langlinks to return.
     */
    lllimit?: number | 'max';
    /**
     * Which additional properties to get for each interlanguage link.
     */
    llprop?: MaybeArray<'autonym' | 'langname' | 'url'>;
    /**
     * Link to search for. Must be used with `lllang`.
     */
    lltitle?: string;
}
interface LangLinksItem {
    ns: number;
    pageid: number;
    title: string;
    langlinks: Array<{
        autonym: string;
        lang: string;
        langname: string;
        url: string;
        title: string;
    }>;
}
declare type LangLinksResponse = QueryResponse<'ll', 'pages', LangLinksItem>;

/**
 * Options for `prop=links`
 */
interface LinksRequest extends QueryRequest {
    prop: 'links';
    titles: string | string[];
    /**
     * When more results are available, use this to continue.
     */
    plcontinue?: string;
    /**
     * The direction in which to list.
     */
    pldir?: 'ascending' | 'descending';
    /**
     * How many links to return.
     */
    pllimit?: number | 'max';
    /**
     * Show links in these namespaces only.
     */
    plnamespace?: MaybeArray<number>;
    /**
     * Only list links to these titles. Useful for checking whether a certain page links to a certain title.
     */
    pltitles?: MaybeArray<string>;
}
interface LinksItem {
    ns: number;
    pageid: number;
    title: string;
    links: Array<{
        ns: string;
        title: string;
    }>;
}
declare type LinksResponse = QueryResponse<'ll', 'pages', LinksItem>;

/**
 * Options for `prop=linkshere`
 */
interface LinksHereRequest extends QueryRequest {
    prop: 'linkshere';
    titles: string | string[];
    /**
     * When more results are available, use this to continue.
     */
    lhcontinue?: string;
    /**
     * How many to return.
     */
    lhlimit?: number | 'max';
    /**
     * Only include pages in these namespaces.
     */
    lhnamespace?: number | number[];
    /**
     * Which properties to get.
     */
    lhprop?: MaybeArray<'pageid' | 'title' | 'redirect'>;
    /**
     * Show only items that meet these criteria.
     */
    lhshow?: 'redirect' | '!redirect';
}
interface LinksHereItem {
    ns: number;
    pageid: number;
    title: string;
    linkshere: Array<{
        ns: number;
        pageid: number;
        redirect: boolean;
        title: string;
    }>;
}
declare type LinksHereResponse = QueryResponse<'lh', 'pages', LinksHereItem>;

/**
 * Options for `prop=redirects`
 */
interface RedirectsRequest extends QueryRequest {
    prop: 'redirects';
    titles: string | string[];
    /**
     * When more results are available, use this to continue.
     */
    rdcontinue?: string;
    /**
     * The direction in which to list.
     */
    rddir?: 'ascending' | 'descending';
    /**
     * How many Redirects to return.
     */
    rdlimit?: number | 'max';
    /**
     * Show redirects in these namespaces only.
     */
    rdnamespace?: MaybeArray<number>;
    /**
     * Which properties to get.
     */
    rdprop?: MaybeArray<'fragment' | 'pageid' | 'title'>;
    /**
     * Show only items that meet these criteria.
     */
    rdshow?: MaybeArray<'!fragment' | 'fragment'>;
}
interface RedirectsItem {
    ns: number;
    pageid: number;
    title: string;
    redirects: Array<{
        ns: string;
        pageid: number;
        title: string;
    }>;
}
declare type RedirectsResponse = QueryResponse<'rd', 'pages', RedirectsItem>;

interface RevisionsRequest extends QueryRequest {
    prop: 'revisions';
    /**
     * When more results are available, use this to continue.
     */
    rvcontinue?: string;
    /**
     * In which direction to enumerate.
     */
    rvdir?: 'newer' | 'older';
    /**
     * Enumerate up to this timestamp.
     */
    rvend?: string;
    /**
     * Stop enumeration at this revision's timestamp. The revision must exist, but need not belong to this page.
     */
    rvendid?: number;
    /**
     * Exclude revisions made by user.
     */
    rvexcludeuser?: string;
    /**
     * Limit how many revisions will be returned.
     */
    rvlimit?: number | 'max';
    /**
     * Which properties to get for each revision.
     */
    rvprop?: MaybeArray<'ids' | 'flags' | 'timestamp' | 'user' | 'userid' | 'size' | 'slotsize' | 'sha1' | 'slotsha1' | 'contentmodel' | 'comment' | 'parsedcomment' | 'content' | 'tags' | 'roles'>;
    /**
     * Which revision slots to return data for, when slot-related properties are included in rvprops. If omitted, data from the main slot will be returned in a backwards-compatible format.
     */
    rvslots?: 'main' | '*';
    /**
     * From which revision timestamp to start enumeration.
     */
    rvstart?: string;
    /**
     * Start enumeration from this revision's timestamp. The revision must exist, but need not belong to this page.
     */
    rvstartid?: number;
    /**
     * Only list revisions tagged with this tag.
     */
    rvtag?: string;
    /**
     * Only include revisions made by user.
     */
    rvuser?: string;
}
declare type RevisionsItem = {
    ns: number;
    title: string;
} & ({
    missing: true;
} | {
    missing: undefined;
    pageid: number;
    revisions: [
        {
            slots: {
                main: {
                    contentmodel: string;
                    contentformat: string;
                    content: string;
                };
            };
        }
    ];
});
declare type RevisionsResponse = QueryResponse<'rv', 'pages', RevisionsItem>;

/**
 * Options for `prop=templates`
 */
interface TemplatesRequest extends QueryRequest {
    prop: 'templates';
    titles: string | string[];
    /**
     * When more results are available, use this to continue.
     */
    tlcontinue?: string;
    /**
     * The direction in which to list.
     */
    tldir?: 'ascending' | 'descending';
    /**
     * How many templates to return.
     */
    tllimit?: number | 'max';
    /**
     * Show Templates in these namespaces only.
     */
    tlnamespace?: MaybeArray<number>;
    /**
     * Only list these templates. Useful for checking whether a certain page uses a certain template.
     */
    tltemplates?: MaybeArray<string>;
}
interface TemplatesItem {
    ns: number;
    pageid: number;
    title: string;
    Templates: Array<{
        ns: string;
        title: string;
    }>;
}
declare type TemplatesResponse = QueryResponse<'tl', 'pages', TemplatesItem>;

/**
 * Options for `prop=transcludedin`
 */
interface TranscludedInRequest extends QueryRequest {
    prop: 'transcludedin';
    titles: string | string[];
    /**
     * When more results are available, use this to continue.
     */
    ticontinue?: string;
    /**
     * How many to return.
     */
    tilimit?: number | 'max';
    /**
     * Only include pages in these namespaces.
     */
    tinamespace?: number | number[];
    /**
     * Which properties to get.
     */
    tiprop?: MaybeArray<'pageid' | 'title' | 'redirect'>;
    /**
     * Show only items that meet these criteria.
     */
    tishow?: 'redirect' | '!redirect';
}
interface TranscludedInItem {
    ns: number;
    pageid: number;
    title: string;
    transcludedin: Array<{
        ns: number;
        pageid: number;
        redirect: boolean;
        title: string;
    }>;
}
declare type TranscludedInResponse = QueryResponse<'ti', 'pages', TranscludedInItem>;

interface AllActions {
    block: [BlockRequest, BlockResponse];
    delete: [DeleteRequest, DeleteResponse];
    edit: [EditRequest, EditResponse];
    login: [LoginRequest, LoginResponse];
    move: [MoveRequest, MoveResponse];
    opensearch: [OpenSearchRequest, OpenSearchResponse];
    parse: [ParseRequest, ParseResponse];
    protect: [ProtectRequest, ProtectResponse];
    purge: [PurgeRequest, PurgeResponse];
    rollback: [RollbackRequest, RollbackResponse];
    undelete: [UndeleteRequest, UndeleteResponse];
    upload: [UploadRequest, UploadResponse];
}

interface ListQuery {
    allcategories: [AllCategoriesRequest, AllCategoriesResponse, AllCategoriesItem];
    allimages: [AllImagesRequest, AllImagesResponse, AllImagesItem];
    allpages: [AllPagesRequest, AllPagesResponse, AllPagesItem];
    categorymembers: [CategoryMembersRequest, CategoryMembersResponse, CategoryMembersItem];
    logevents: [LogEventsRequest, LogEventsResponse, LogEventsItem];
    recentchanges: [RecentChangesRequest, RecentChangesResponse, RecentChangesItem];
    usercontribs: [UserContribsRequest, UserContribsResponse, UserContribsItem];
    users: [UsersRequest, UsersResponse, UsersItem];
}
interface MetaQuery {
    allmessages: [AllMessagesRequest, AllMessagesResponse];
    filerepoinfo: [FileRepoInfoRequest, FileRepoInfoResponse];
    siteinfo: [SiteInfoRequest, SiteInfoResponse];
    tokens: [TokensRequest, TokensResponse];
}
interface PropQuery {
    categories: [CategoriesRequest, CategoriesResponse, CategoriesItem];
    categoryinfo: [CategoryInfoRequest, CategoryInfoResponse, CategoriesItem];
    contributors: [ContributorsRequest, ContributorsResponse, ContributorsItem];
    deletedrevisions: [DeletedRevisionsRequest, DeletedRevisionsResponse, DeletedRevisionsItem];
    duplicatefiles: [DuplicateFilesRequest, DuplicateFilesResponse, DuplicateFilesItem];
    extlinks: [ExtLinksRequest, ExtLinksResponse, ExtLinksItem];
    fileusage: [FileUsageRequest, FileUsageResponse, FileUsageItem];
    imageinfo: [ImageInfoRequest, ImageInfoResponse, ImageInfoItem];
    images: [ImagesRequest, ImagesResponse, ImagesItem];
    info: [InfoRequest, InfoResponse, InfoItem];
    iwlinks: [IwLinksRequest, IwLinksResponse, IwLinksItem];
    langlinks: [LangLinksRequest, LangLinksResponse, LangLinksItem];
    links: [LinksRequest, LinksResponse, LinksItem];
    linkshere: [LinksHereRequest, LinksHereResponse, LinksHereItem];
    redirects: [RedirectsRequest, RedirectsResponse, RedirectsItem];
    revisions: [RevisionsRequest, RevisionsResponse, RevisionsItem];
    templates: [TemplatesRequest, TemplatesResponse, TemplatesItem];
    transcludedin: [TranscludedInRequest, TranscludedInResponse, TranscludedInItem];
}
declare type AllQuery = ListQuery & MetaQuery & PropQuery;

declare module 'tough-cookie' {
    interface CookieJar {
        store: tough.Store;
    }
}
interface ICookieStoreOptions {
    regex: RegExp | RegExp[];
    path: string;
}
interface ICookieStorage {
    [url: string]: Map<string, tough.Cookie>;
}
interface ICookieStorageJSON {
    [url: string]: Array<Record<string, unknown>>;
}
interface ICookieJarOptions {
    prettify?: boolean;
    store?: ICookieStoreOptions | undefined;
}
declare class CookieJar {
    #private;
    constructor({ prettify, store }?: ICookieJarOptions);
    clear(url: string): void;
    clearAll(): void;
    expire(url?: string): void;
    get(url: string): string;
    set({ cookie, url }: {
        cookie: string;
        url: string;
    }): void;
    private allowCookie;
    private static getHost;
    private save;
}

declare type RequestOptions = Omit<Dispatcher.RequestOptions, 'path'>;
declare type Response$1 = Dispatcher.ResponseData;
declare class RequestManager {
    #private;
    agent: Agent | undefined;
    headers: IncomingHttpHeaders;
    constructor({ agent, headers, jarOptions }?: {
        agent?: Agent;
        headers?: IncomingHttpHeaders;
        jarOptions?: ICookieJarOptions;
    });
    get jar(): Readonly<CookieJar>;
    clear(url: string): void;
    get<T>({ url, qs }: {
        url: string;
        qs: Record<string, string>;
    }): Promise<T>;
    post<T>({ url, form }: {
        url: string;
        form: Record<string, string | fs.ReadStream>;
    }): Promise<T>;
    raw(url: string, fetchOptions?: RequestOptions): Promise<Response$1>;
    private addCookies;
}

declare const sleep: (ms: number) => Promise<never>;

declare type Loaded<T extends Wiki = Wiki> = Required<T>;
declare class Wiki {
    readonly api: string;
    readonly request: RequestManager;
    mainpage?: string;
    base?: string;
    sitename?: string;
    lang?: string;
    readonly?: boolean;
    writeapi?: boolean;
    articlepath?: string;
    scriptpath?: string;
    script?: string;
    server?: string;
    servername?: string;
    wikiid?: string;
    constructor({ api, request }: {
        api: string;
        request?: RequestManager;
    });
    private querystring;
    protected raw<T, U extends Request>(userparams: U, method: 'GET' | 'POST'): Promise<T>;
    get<T, U extends Request = Request>(userparams: U | U & AddActionQueryToken): Promise<T>;
    post<T, U extends Request = Request>(userparams: U | U & AddActionQueryToken): Promise<T>;
    exists(): Promise<boolean>;
    getInterwikis(): Promise<Record<string, string>>;
    getSiteInfo<T extends keyof SiteInfoResponse['query']>(...properties: T[]): Promise<SiteInfoResponse>;
    getPages<T extends string>(_titles: T): Promise<string>;
    getPages<T extends string>(_titles: T[]): Promise<{
        [key in T]?: string;
    }>;
    getToken<Token extends TokenType>(type: Token): Promise<TokensResponse<Token>>;
    getURL(title: string): string;
    load(): Promise<Loaded<this>>;
    pagesExist(_titles: string): Promise<boolean>;
    pagesExist<T extends string>(_titles: T[]): Promise<Record<T, boolean>>;
    parse(params: NoActionToken<ParseRequest>): Promise<ParseResponse>;
    purge<T extends string>(titles: T[]): Promise<Record<T, boolean>>;
    search(params: NoActionToken<OpenSearchRequest>): Promise<OpenSearchResponse>;
    queryList<ListName extends keyof ListQuery = keyof ListQuery>(params: {
        list: ListName;
    } & ListQuery[ListName][0], limit?: number): Promise<Array<ListQuery[ListName][2]>>;
    iterQueryList<ListName extends keyof ListQuery = keyof ListQuery>(params: {
        list: ListName;
    } & ListQuery[ListName][0], limit?: number): AsyncGenerator<ListQuery[ListName][2]>;
    queryProp<PropName extends keyof PropQuery = keyof PropQuery>(params: {
        prop: PropName;
    } & PropQuery[PropName][0], limit?: number): Promise<Array<PropQuery[PropName][2]>>;
    rawQueryProp<PropName extends keyof PropQuery = keyof PropQuery>(params: {
        prop: PropName;
    } & PropQuery[PropName][0]): Promise<PropQuery[PropName][1]['query']>;
    iterQueryProp<PropName extends keyof PropQuery = keyof PropQuery>(params: {
        prop: PropName;
    } & PropQuery[PropName][0], limit?: number): AsyncGenerator<PropQuery[PropName][2]>;
    iterPages(titles: string[]): AsyncGenerator<RevisionsResponse['query']['pages'][0], void, unknown>;
}

declare class Bot<WikiType extends Wiki = Wiki> {
    #private;
    protected csrf: string | null;
    constructor({ password, username, wiki }: {
        password: string;
        username: string;
        wiki: WikiType;
    });
    protected get wiki(): WikiType;
    protected set wiki(wiki: WikiType);
    block(params: NoActionToken<BlockRequest>): Promise<BlockResponse>;
    delete(params: NoActionToken<DeleteRequest>): Promise<DeleteResponse>;
    edit(params: NoActionToken<EditRequest>): Promise<EditResponse>;
    getCSRFToken(force?: boolean): Promise<string>;
    isLoggedIn(): Promise<boolean>;
    login(force?: boolean): Promise<void>;
    logout(): Promise<void>;
    move(params: NoActionToken<MoveRequest>): Promise<MoveResponse>;
    protect(params: NoActionToken<ProtectRequest>): Promise<ProtectResponse>;
    purge(titles: string[]): Promise<Record<string, boolean>>;
    rollback(params: NoActionToken<RollbackRequest>): Promise<RollbackResponse>;
    touch(titles: string[]): Promise<Record<string, boolean>>;
    unblock(params: NoActionToken<UnblockRequest>): Promise<UnblockResponse>;
    undelete(params: NoActionToken<UndeleteRequest>): Promise<UndeleteResponse>;
    upload(params: UploadRequest): Promise<UploadResponse>;
    /**
     * @param { Object } params.filename - Name to use for the uploaded file.
     * @param { Object } params.url - URL of the file to upload.
     * @description Upload an image by an URL. \
     * Not to be confused with the `uploadByUrl` method, which uses MediaWiki's extension. \
     * It will store the image locally in order to upload it.
     */
    whoAmI(): Promise<{
        query: {
            userinfo: {
                id: number;
                name: string;
            };
        };
    }>;
}

declare class FandomWiki extends Wiki {
    readonly interwiki: string;
    id?: number;
    constructor({ interwiki, request }: {
        interwiki: string;
        request: RequestManager;
    });
    getURL(title: string): string;
    load(): Promise<Loaded<this>>;
}

declare class FandomBot extends Bot<FandomWiki> {
    #private;
    constructor({ password, username, wiki }: {
        password: string;
        username: string;
        wiki: FandomWiki;
    });
    setWiki(wiki: FandomWiki): Promise<void>;
}

declare class Fandom {
    static request?: RequestManager;
    readonly request: RequestManager;
    constructor({ cookies, prettyCookies, requestOptions }?: {
        cookies?: string;
        prettyCookies?: boolean;
        requestOptions?: ConstructorParameters<typeof RequestManager>[0];
    });
    static interwiki2path(_interwiki: string): string;
    static getWiki(interwiki: string): FandomWiki;
    static interwiki2api(interwiki: string): string;
    static interwiki2url(interwiki: string): string;
    static url2interwiki(url: string): string;
    getUserAvatar(username: string): Promise<string | null>;
    getUserDiscordTag(username: string): Promise<string | null>;
    getUserId(username: string): Promise<number | null>;
    getUsersIds(usernames: string[]): Promise<Record<string, number>>;
    getWiki(interwiki: string): FandomWiki;
    login({ password, username, wiki }: {
        password: string;
        username: string;
        wiki?: FandomWiki;
    }): Promise<FandomBot>;
}

export { APIError, ActionRequest, AddActionQueryToken, AllActions, AllCategoriesItem, AllCategoriesRequest, AllCategoriesResponse, AllImagesItem, AllImagesRequest, AllImagesResponse, AllMessagesRequest, AllMessagesResponse, AllPagesItem, AllPagesRequest, AllPagesResponse, AllQuery, BlockRequest, BlockResponse, Bot, CategoriesItem, CategoriesRequest, CategoriesResponse, CategoryInfoItem, CategoryInfoRequest, CategoryInfoResponse, CategoryMembersItem, CategoryMembersRequest, CategoryMembersResponse, ContributorsItem, ContributorsRequest, ContributorsResponse, ConvertedInfo, CookieJar, DeleteRequest, DeleteResponse, DeletedRevisionsItem, DeletedRevisionsRequest, DeletedRevisionsResponse, DuplicateFilesItem, DuplicateFilesRequest, DuplicateFilesResponse, EditRequest, EditResponse, ExtLinksItem, ExtLinksRequest, ExtLinksResponse, Fandom, FandomBot, FandomWiki, FileRepoInfoRequest, FileRepoInfoResponse, FileUsageItem, FileUsageRequest, FileUsageResponse, ICookieJarOptions, ICookieStorage, ICookieStorageJSON, ICookieStoreOptions, ImageInfoItem, ImageInfoRequest, ImageInfoResponse, ImagesItem, ImagesRequest, ImagesResponse, InfoItem, InfoRequest, InfoResponse, InterwikiInfo, InvalidInterwikiError, IwLinksItem, IwLinksRequest, IwLinksResponse, JSONRequest, LangLinksItem, LangLinksRequest, LangLinksResponse, LinksHereItem, LinksHereRequest, LinksHereResponse, LinksItem, LinksRequest, LinksResponse, ListQuery, Loaded, LogEventsItem, LogEventsRequest, LogEventsResponse, LoginRequest, LoginResponse, MaybeArray, MediaWikiError, MetaQuery, MoveRequest, MoveResponse, NoActionToken, NormalizedInfo, OpenSearchRequest, OpenSearchResponse, ParseRequest, ParseResponse, PropQuery, ProtectRequest, ProtectResponse, ProtectionAction, ProtectionLevel, PurgeRequest, PurgeResponse, QueryRequest, QueryResponse, RecentChangesItem, RecentChangesRequest, RecentChangesResponse, RedirectInfo, RedirectsItem, RedirectsRequest, RedirectsResponse, Request, RequestManager, RequestParameterType, RequireOnlyOne, RequireOnlyOneFromThree, Response$2 as Response, RevisionsItem, RevisionsRequest, RevisionsResponse, RollbackRequest, RollbackResponse, SiteInfoRequest, SiteInfoResponse, TemplatesItem, TemplatesRequest, TemplatesResponse, TokenType, TokensRequest, TokensResponse, TranscludedInItem, TranscludedInRequest, TranscludedInResponse, UnblockRequest, UnblockResponse, UndeleteRequest, UndeleteResponse, UploadRequest, UploadResponse, UserContribsItem, UserContribsRequest, UserContribsResponse, UsersItem, UsersRequest, UsersResponse, Wiki, sleep };
