Comparing version 1.19.3 to 1.19.4
{ | ||
"name": "wikiapi", | ||
"title": "JavaScript MediaWiki API for node.js", | ||
"version": "1.19.3", | ||
"version": "1.19.4", | ||
"description": "A simple way to access MediaWiki API via JavaScript with simple wikitext parser.", | ||
@@ -6,0 +6,0 @@ "keywords": [ |
@@ -819,6 +819,15 @@ /** | ||
// Reset claim | ||
entity = await wiki.data('Q1841'); | ||
await entity.modify({ claims: [{ P3: "old.wav", remove: true }] }, { bot: 1, summary: 'test edit: Remove specific value' }); | ||
// Warning: If you want to perform multiple operations on the same property, you need to get the entity again! | ||
entity = await wiki.data('Q1841'); | ||
await entity.modify({ claims: [{ P3: "new.wav" }] }, { bot: 1, summary: 'test edit: Add value' }); | ||
// Update claim | ||
await entity.modify({ claims: [{ P17: 'Q213280' }] }, { bot: 1, summary: '' }); | ||
await entity.modify({ claims: [{ P17: 'Q213280' }] }, { bot: 1, summary: 'test edit: Update claim' }); | ||
// Update claim: set country (P17) to 'Test Country 1' (Q213280) ([language, label] as entity) | ||
await entity.modify({ claims: [{ language: 'en', country: [, 'Test Country 1'] }] }, { summary: '' }); | ||
// Remove country (P17) : 'Test Country 1' (Q213280) | ||
@@ -1762,2 +1771,39 @@ await entity.modify({ claims: [{ language: 'en', country: [, 'Test Country 1'], remove: true }] }, { summary: '' }); | ||
// -------------------------------------------------------- | ||
// administration functions 管理功能。 | ||
/** | ||
* @alias delete | ||
* @description delete page | ||
* | ||
* @param {String} title - page title | ||
* @param {Object} [options] - options to run this function | ||
* | ||
* @returns {Promise} Promise object represents response of delete. | ||
* | ||
* @example <caption>delete page [[Page to delete]]</caption> | ||
// <code> | ||
const testwiki = new Wikiapi('test'); | ||
await testwiki.delete('Page to delete', { reason: 'test' }); | ||
// { title: 'Aaaaaaa', reason: 'test', logid: 346223 } | ||
// </code> | ||
* | ||
* @memberof Wikiapi.prototype | ||
*/ | ||
function Wikiapi_delete(title, options) { | ||
function Wikiapi_delete_executor(resolve, reject) { | ||
const wiki = this[KEY_wiki_session]; | ||
// using wiki_API.delete | ||
wiki.page(title).delete(options, (response, error) => { | ||
if (error) { | ||
reject(error); | ||
} else { | ||
resolve(response); | ||
} | ||
}, options); | ||
} | ||
return new Promise(Wikiapi_delete_executor.bind(this)); | ||
} | ||
// -------------------------------------------------------- | ||
// exports | ||
@@ -1850,2 +1896,4 @@ | ||
delete: Wikiapi_delete, | ||
data: Wikiapi_data, | ||
@@ -1852,0 +1900,0 @@ new_data_entity: Wikiapi_new_data_entity, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
2485303
3605