forked from lavgup/mediawiki.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.d.ts
306 lines (305 loc) · 10.7 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
/**
* A MediaWikiJS object.
* @param options - The configuration options.
* @param options.server - The server of the wiki.
* @param options.path - The path to the api.php file.
* @param [options.botUsername] - The bot's bot username, obtained from Special:BotPasswords.
* @param [options.botPassword] - The bot's bot password, obtained from Special:BotPasswords.
*/
declare class MediaWikiJS {
constructor(options: {
server: string;
path: string;
botUsername?: string;
botPassword?: string;
});
/**
* Logs in to a wiki bot.
* @param username - The bot username of the account to log in to.
* @param password - The bot password of the account to log in to.
* @returns The successful login object.
*/
login(username: string, password: string): Promise<object>;
/**
* Logs out of a wiki bot.
API removes cookies and resets mwToken.
*/
logout(): void;
/**
* Sets the server.
* @param server - The server of the wiki, with the HTTP/HTTPS protocol.
* @param script - The path to the api.php file.
*/
setServer(server: string, script: string): MediaWikiJS;
/**
* @param object - The object to get the first item of.
*/
getFirstItem(object: any): object[];
/**
* Gets only the page titles of a list and formats it into an array.
* @param array - The array to get a list from.
* @param property - The property of the page title in each object.
* @returns The list of all titles.
*/
getList(array: object[], property?: string): string[];
/**
* Gets pages in a category.
* @param category - The category to get pages of.
* @param onlyTitles - Whether to only list the page titles.
*/
getPagesInCategory(category: string, onlyTitles: boolean): Promise<string[] | object[]>;
/**
* @param title - The title of the page to get categories from.
* @param onlyTitles - Whether to only list the page titles.
*/
getArticleCategories(title: string, onlyTitles: boolean): Promise<object[] | string[]>;
/**
* @param keyword - The keyword for the search.
* @param onlyTitles - Whether to only list the page titles.
*/
search(keyword: string, onlyTitles: boolean): Promise<string[] | object[]>;
/**
* Main wrapper for editing pages.
* @param params - Mandatory params for the edit.
*/
doEdit(params: any): Promise<object>;
/**
* Edits the contents of a page.
* @param options - The options for the edit.
* @param options.title - The title of the page to edit.
* @param options.content - The content of the edit.
* @param options.summary - The summary of the edit.
* @param options.minor - Whether to mark the edit as minor.
*/
edit(options: {
title: string;
content: string;
summary: string;
minor: boolean;
}): Promise<object>;
/**
* Appends content to a page.
* @param options - The options for the edit.
* @param options.title - The title of the page to edit.
* @param options.content - The content of the edit.
* @param options.summary - The summary of the edit.
* @param options.minor - Whether to mark the edit as minor.
*/
prepend(options: {
title: string;
content: string;
summary: string;
minor: boolean;
}): Promise<object>;
/**
* Appends content to a page.
* @param options - The options for the edit.
* @param options.title - The title of the page to edit.
* @param options.content - The content of the edit.
* @param options.summary - The summary of the edit.
* @param options.minor - Whether to mark the edit as minor.
*/
append(options: {
title: string;
content: string;
summary: string;
minor: boolean;
}): Promise<object>;
/**
* Undoes a revision.
* @param options - The options for the undo.
* @param options.title - The title of the page of which revision to undo.
* @param options.revision - The revision to undo.
* @param options.summary - The summary of the edit.
*/
undo(options: {
title: string;
revision: string;
summary: string;
}): void;
/**
* Deletes a page.
* @param options - The options for the deletion.
* @param options.title - The title of the page to delete.
* @param options.reason - The reason for deleting the page.
*/
delete(options: {
title: string;
reason: string;
}): Promise<object>;
/**
* Restore revisions of a deleted page.
* @param options - The options for the deletion.
* @param options.title - The title of the page to restore.
* @param options.reason - The reason for restoring this page.
*/
restore(options: {
title: string;
reason: string;
}): Promise<any>;
/**
* Change the protection level of a page.
* @param options - The options for the protection.
* @param options.title - The title of the page to modify the protection level of.
* @param options.protections - The protections to set the page to.
* @param options.expiry - The expiry for the protection.
* @param options.reason - The reason for modifying the page's protection level.
* @param options.cascade - Whether to enable cascading protection.
*/
protect(options: {
title: string;
protections: any;
expiry: string | undefined;
reason: string;
cascade: boolean;
}): Promise<object>;
/**
* Blocks a user.
* @param options - The options for the block.
* @param options.user - The username of the user to block.
* @param options.expiry - The expiry of the block.
* @param options.reason - The reason for the block.
* @param options.autoblock - Whether to automatically block the last used IP address, and any subsequent IP addresses they try to login from.
* @param options.reblock - Whether to overwrite the existing block, if the user is already blocked.
*/
block(options: {
user: string;
expiry: string;
reason: string;
autoblock: boolean;
reblock: boolean;
}): Promise<object>;
/**
* Unblocks a user.
* @param user - The username of the user to unblock.
* @param reason - The reason for the unblock.
*/
unblock(user: string, reason: string): Promise<object>;
/**
* Purges the cache of a list of pages.
* @param titles - The title(s) of the pages to delete.
*/
purge(titles: string[] | string): Promise<object>;
/**
* Sends an email to a user.
* @param options - The options for the email.
* @param options.user - The user to email.
* @param options.subject - The subject of the email.
* @param options.content - The content of the email.
*/
email(options: {
user: string;
subject: string;
content: string;
}): Promise<object>;
/**
* Get all edits by a user.
* @param options - The options for the request.
* @param options.user - The users to retrieve contributions for.
* @param options.start - The start timestamp to return from.
* @param options.namespace - Only list contributions in these namespaces.
* @param options.onlyTitles - Whether to only list the page titles.
*/
getUserContribs(options: {
user: string;
start: string;
namespace: string;
onlyTitles: boolean;
}): Promise<string[]>;
/**
* Creates a new account.
*/
createAccount(username: string, password: string): Promise<object>;
/**
* Moves a page.
* @param options - The options for the move.
* @param options.from - The page title to rename.
* @param options.to - The new page title.
* @param options.reason - The reason for moving this page.
*/
move(options: {
from: string;
to: string;
reason: string;
}): Promise<object>;
/**
* Gets all images on the wiki.
* @param start - The image title to start enumerating from.
* @param onlyTitles - Whether to only list the image titles.
*/
getImages(start: string, onlyTitles: boolean): Promise<string[] | object[]>;
/**
* Gets all images from an article.
* @param options - The options for the request.
* @param options.page - The page to get all its images from.
* @param options.onlyTitles - Whether to only list the image titles.
* @param options.otherOptions - Any other options for the request.
*/
getImagesFromArticle(options: {
page: string;
onlyTitles: boolean;
otherOptions: any;
}): Promise<string[] | object[]>;
/**
* Find all pages that use the given image title.
* @param fileName - Title to search
* @param onlyTitles - Whether to only list the page titles.
*/
getImageUsage(fileName: string, onlyTitles: boolean): Promise<string[]>;
/**
* Get information about the current user.
*/
whoAmI(): Promise<object>;
/**
* Gets information about a given user.
*/
whoIs(username: string): Promise<object>;
/**
* Gets information about multiple users.
*/
whoAre(usernames: string[]): Promise<object[]>;
/**
* Expands all templates within wikitext.
*/
expandTemplates(text: string, title: string): Promise<string>;
/**
* Parses content and returns parser output.
* @param text - Text to parse.
* @param title - Title of page the text belongs to.
*/
parse(text: string, title: string): Promise<string>;
/**
* Enumerate recent changes.
* @param start - The timestamp to start enumerating from.
* @param onlyTitles - Whether to only list the page titles.
*/
getRecentChanges(start: string, onlyTitles: boolean): Promise<string[] | object[]>;
/**
* Return general information about the site.
* @param props - Which information to get
*/
getSiteInfo(props: string[] | string): Promise<object>;
/**
* Returns site statistics.
*/
getSiteStats(): Promise<object>;
/**
* Gets the wiki's MediaWiki version.
*/
getMwVersion(): Promise<string>;
/**
* Returns a list of all pages from a query page.
*/
getQueryPage(queryPage: string, onlyTitles: boolean): Promise<string[] | object[]>;
/**
* Returns all external URLs from the given page.
* @param page - The page to get its external URLs from.
*/
getExternalLinks(page: string): Promise<string[]>;
/**
* Find all pages that link to the given page.
* @param page - Title to search.
* @param onlyTitles - Whether to only list the page titles.
*/
getBackLinks(page: string, onlyTitles: boolean): Promise<string[] | object[]>;
}