0.3.3 • Published 8 years ago
xwiki-sdk v0.3.3
Important
This is unofficial repository. It has been written for internal use and do not fit common Open Source Project requirements. You still can send PR or issue, but remember this.
Installation
Install and save it to package.json:
npm i xwiki-sdk -SUsage
const XWikiSDK = require('xwiki-sdk'),
sdk = new XWikiSDK('http://localhost:8080'); // replace with your XWiki installation address.
sdk.setAuth('JhonDoe', 'password')
.setWiki('xwiki');
function createUser() {
sdk.setSpace('XWiki');
return sdk.createUser({
first_name: 'Agent',
last_name: 'Smith',
email: 'as@matrix.com',
password: 'drowssap',
}).then((resJSON) => {
console.log('user created', resJSON);
});
}
function createTestPage() {
sdk.setAuth('AgentSmith', 'p@ssw0rd').setSpace('Main');
return sdk.createPage('TestPage', {title: 'Test Page Title', content: 'some content \n\nnew line?'});
}
createUser().then(() => {
return createTestPage();
}).then(() => {
console.log('user and page created');
}).catch((err) => {
console.error(err);
});API
constructor(apiHost: string)Create new instance of SDK and set path to it.setAuth(userName: string, password: string)Set username and password. After calling this, all requests will have HTTP Basic Auth with provided credentials.
setWiki(wikiName: string)Set wiki name.
xwikiby default.setSpace(setSpace: string)Set space name.
XWikiby default.createPage(pageName: string, pageFields: object)Creates page with
pageNameslug.pageFieldsproperties:title- Page titlecontent- Page content
createUser(options: object)Creates user and adds it to "All" group.
optionsproperties:first_namelast_nameemailpasswordactive