import type { MwnTitle } from './title'; import type { Mwn, EditTransform } from './bot'; import type { ApiDeleteParams, ApiEditPageParams, ApiMoveParams, ApiPurgeParams, ApiQueryAllPagesParams, ApiQueryLogEventsParams, ApiQueryRevisionsParams, ApiUndeleteParams } from 'types-mediawiki-api'; import { ApiRevision, LogEvent } from './api_response_types'; export interface MwnPageStatic { new (title: MwnTitle | string, namespace?: number): MwnPage; } export interface MwnPage extends MwnTitle { getTalkPage(): MwnPage; getSubjectPage(): MwnPage; /** * Check if page exists. */ exists(): Promise; /** * Get page wikitext */ text(): Promise; /** * Get page categories * @returns {Promise} Resolved with array of page names */ categories(): Promise; /** * Get templates transcluded on the page * @returns {Promise} Resolved with array of page names */ templates(): Promise; /** * Get links on the page * @returns {Promise} Resolved with array of page names */ links(): Promise; /** * Get list of pages linking to this page * @returns {Promise} */ backlinks(): Promise; /** * Get list of pages transcluding this page * @returns {Promise} */ transclusions(): Promise; /** * Returns list of images on the page * @returns {Promise} - array elements don't include File: prefix */ images(): Promise; /** * Returns list of external links on the page * @returns {Promise} */ externallinks(): Promise; /** * Returns list of subpages of the page * @returns {Promise} */ subpages(options?: ApiQueryAllPagesParams): Promise; /** * Check if page is redirect or not * @returns {Promise} */ isRedirect(): Promise; /** * Get redirect target. * Returns the same page name if the page is not a redirect. * @returns {Promise} */ getRedirectTarget(): Promise; /** * Get username of the page creator * @returns {Promise} */ getCreator(): Promise; /** * Get username of the last deleting admin (or null) * @returns {Promise} */ getDeletingAdmin(): Promise; /** * Get short description, either the local one (for English Wikipedia) * or the one from wikidata. * @param {Object} customOptions * @returns {Promise} */ getDescription(customOptions?: any): Promise; /** * Get the edit history of the page * @param {string|string[]} props - revision properties to fetch, by default content is * excluded * @param {number} [limit=50] - number of revisions to fetch data about * @param {Object} customOptions - custom API options * @returns {Promise} - resolved with array of objects representing * revisions, eg. { revid: 951809097, parentid: 951809097, timestamp: * "2020-04-19T00:45:35Z", comment: "Edit summary" } */ history(props: ApiQueryRevisionsParams['rvprop'], limit: number, customOptions?: ApiQueryRevisionsParams): Promise; historyGen(props: ApiQueryRevisionsParams['rvprop'], customOptions?: ApiQueryRevisionsParams): AsyncGenerator; /** * Get the page logs. * @param {string|string[]} props - data about log entries to fetch * @param {number} limit - max number of log entries to fetch * @param {string} type - type of log to fetch, can either be an letype or leaction * Leave undefined (or null) to fetch all log types * @param {Object} customOptions * @returns {Promise} - resolved with array of objects representing * log entries, eg. { ns: '0', title: 'Main Page', type: 'delete', user: 'Example', * action: 'revision', timestamp: '2020-05-05T17:13:34Z', comment: 'edit summary' } */ logs(props: ApiQueryLogEventsParams['leprop'], limit?: number, type?: string, customOptions?: ApiQueryLogEventsParams): Promise; logsGen(props: ApiQueryLogEventsParams['leprop'], type?: string, customOptions?: ApiQueryLogEventsParams): AsyncGenerator; /** * Get page views data (only for Wikimedia wikis) * @see https://wikitech.wikimedia.org/wiki/Analytics/AQS/Pageviews * @param options */ pageViews(options?: PageViewOptions): Promise; /** * Query the top contributors to the article using the WikiWho API. * This API has a throttling of 2000 requests a day. * Supported for EN, DE, ES, EU, TR Wikipedias only * @see https://wikiwho.wmflabs.org/ */ queryAuthors(): Promise; edit(transform: EditTransform): Promise; save(text: string, summary?: string, options?: ApiEditPageParams): Promise; newSection(header: string, message: string, additionalParams?: ApiEditPageParams): Promise; move(target: string, summary: string, options?: ApiMoveParams): Promise; delete(summary: string, options?: ApiDeleteParams): Promise; undelete(summary: string, options?: ApiUndeleteParams): Promise; purge(options?: ApiPurgeParams): Promise; } export default function (bot: Mwn): MwnPageStatic; export interface PageViewOptions { access?: 'all-access' | 'desktop' | 'mobile-app' | 'mobile-web'; agent?: 'all-agents' | 'user' | 'spider' | 'automated'; granularity?: 'daily' | 'monthly'; start?: Date; end?: Date; } export interface PageViewData { project: string; article: string; granularity: string; timestamp: string; access: string; agent: string; views: number; } export interface AuthorshipData { totalBytes: number; users: Array<{ id: number; name: string; bytes: number; percent: number; }>; }