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.
Install and save it to package.json:
npm i xwiki-sdk -S
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);
});-
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