UNPKG

mwn

Version:

JavaScript & TypeScript MediaWiki bot framework for Node.js

54 lines (53 loc) 1.84 kB
/** * The entry point for all API calls to wikis is the * mwn#request() method in bot.ts. This function uses * the Request and Response classes defined in this file. */ import { AxiosRequestConfig, AxiosResponse } from 'axios'; import * as OAuth from 'oauth-1.0a'; import type { ApiParams, Mwn } from './bot'; import { ApiResponse } from './api_response_types'; export interface RawRequestParams extends AxiosRequestConfig { retryNumber?: number; } export declare class Request { apiParams: ApiParams; requestParams: RawRequestParams; bot: Mwn; constructor(bot: Mwn, apiParams: ApiParams, requestParams: RawRequestParams); process(): Promise<void>; getMethod(): string; MULTIPART_THRESHOLD: number; hasLongFields: boolean; preprocessParams(): void; fillRequestOptions(): Promise<void>; applyAuthentication(): void; /** * Get OAuth Authorization header */ makeOAuthHeader(params: OAuth.RequestOptions): OAuth.Header; handleGet(): void; handlePost(): Promise<void>; useMultipartFormData(): boolean; handlePostMultipartFormData(): Promise<void>; } export declare class Response { bot: Mwn; params: ApiParams; requestOptions: RawRequestParams; rawResponse: AxiosResponse<ApiResponse>; response: ApiResponse; constructor(bot: Mwn, params: ApiParams, requestOptions: RawRequestParams); process(rawResponse: AxiosResponse<ApiResponse>): Promise<ApiResponse>; initialCheck(): Promise<void>; showWarnings(): void; handleErrors(): Promise<void | ApiResponse>; retry(): Promise<ApiResponse>; dieWithError(error: any): Promise<never>; /** * This handles errors at the network level * @param {Object} error */ handleRequestFailure(error: any): Promise<ApiResponse>; logError(err: any): void; }