Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop'
Browse files Browse the repository at this point in the history
Conflicts:
	dist/kuzzle.min.js
	dist/kuzzle.min.map
  • Loading branch information
STAFYNIAK Sacha committed Jun 8, 2016
2 parents ab135fa + 6bcac11 commit 975b7d4
Show file tree
Hide file tree
Showing 17 changed files with 973 additions and 70 deletions.
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# 1.9.0

## Features
* Implement new roles functionalities (`KuzzleSecurity.isActionAllowed`, `KuzzleSecurity.getMyRights`, `KuzzleSecurity.getUserRights`)
* Implement the elasticsearch autorefresh features (`Kuzzle.refreshIndex`, `Kuzzle.getAutoRefresh`, `Kuzzle.setAutoRefresh`)
* Implement the `Kuzzle.updateSelf` method that allow to update current user
* Fix issues #81, #82, #73 & #76

## List of merged PR
* Merge pull request #88 from kuzzleio/KUZ-574-getRights-methods - _Sébastien Cottinet_
* Merge pull request #90 from kuzzleio/rename-policies - _Kévin Blondel_
* Merge pull request #85 from kuzzleio/fix-rc-83-update-and-delete-consistency - _Sébastien Cottinet_
* Merge pull request #87 from kuzzleio/KUZ-480-isActionAllowed - _Sébastien Cottinet_
* Merge pull request #86 from kuzzleio/fix-rc-81-refactor-factory-signature - _Kévin Blondel_
* Merge pull request #84 from kuzzleio/fix-rc-73-paginate-fetchAll - _Sébastien Cottinet_
* Merge pull request #83 from kuzzleio/fix-rc-76-secure-dataCollectionFactory - _Kévin Blondel_
* Merge pull request #80 from kuzzleio/kuz-463-es-autorefresh - _Sébastien Cottinet_
156 changes: 147 additions & 9 deletions dist/kuzzle.js
Original file line number Diff line number Diff line change
Expand Up @@ -1410,6 +1410,136 @@ Kuzzle.prototype.getServerInfo = function (options, cb) {
return this;
};

/**
* Forces an index refresh
*
* @param {string} index - The index to refresh. Defaults to Kuzzle.defaultIndex
* @param {object} options - Optional arguments
* @param {responseCallback} cb - Handles the query response
* @returns {Kuzzle}
*/
Kuzzle.prototype.refreshIndex = function () {
var
index,
options,
cb;

Array.prototype.slice.call(arguments).forEach(function(arg) {
switch (typeof arg) {
case 'string':
index = arg;
break;
case 'object':
options = arg;
break;
case 'function':
cb = arg;
break;
}
});

if (!index) {
if (!this.defaultIndex) {
throw new Error('Kuzzle.refreshIndex: index required');
}
index = this.defaultIndex;
}

this.query({ index: index, controller: 'admin', action: 'refreshIndex'}, {}, options, cb);

return this;
};

/**
* Returns de current autoRefresh status for the given index
*
* @param {string} index - The index to get the status from. Defaults to Kuzzle.defaultIndex
* @param {object} options - Optinal arguments
* @param {responseCallback} cb - Handles the query response
* @returns {object} this
*/
Kuzzle.prototype.getAutoRefresh = function () {
var
index,
options,
cb;

Array.prototype.slice.call(arguments).forEach(function (arg) {
switch (typeof arg) {
case 'string':
index = arg;
break;
case 'object':
options = arg;
break;
case 'function':
cb = arg;
break;
}
});

if (!index) {
if (!this.defaultIndex) {
throw new Error('Kuzzle.getAutoRefresh: index required');
}
index = this.defaultIndex;
}

this.callbackRequired('Kuzzle.getAutoRefresh', cb);
this.query({ index: index, controller: 'admin', action: 'getAutoRefresh'}, {}, options, cb);

return this;
};

/**
* (Un)Sets the autoRefresh flag on the given index
*
* @param {string} index - the index to modify. Defaults to Kuzzle.defaultIndex
* @param {boolean} autoRefresh - The autoRefresh value to set
* @param {object} options - Optional arguments
* @param {responseCallback} cb - Handles the query result
* @returns {object} this
*/
Kuzzle.prototype.setAutoRefresh = function () {
var
index,
autoRefresh,
options,
cb;

Array.prototype.slice.call(arguments).forEach(function (arg) {
switch (typeof arg) {
case 'string':
index = arg;
break;
case 'boolean':
autoRefresh = arg;
break;
case 'object':
options = arg;
break;
case 'function':
cb = arg;
break;
}
});

if (!index) {
if (!this.defaultIndex) {
throw new Error('Kuzzle.setAutoRefresh: index required');
}
index = this.defaultIndex;
}

if (autoRefresh === undefined) {
throw new Error('Kuzzle.setAutoRefresh: autoRefresh value is required');
}

this.query({ index: index, controller: 'admin', action: 'setAutoRefresh'}, { body: { autoRefresh: autoRefresh }}, options, cb);

return this;
};

/**
* Return the current Kuzzle's UTC Epoch time, in milliseconds
* @param {object} [options] - Optional parameters
Expand Down Expand Up @@ -1958,8 +2088,6 @@ KuzzleDataCollection.prototype.deleteDocument = function (arg, options, cb) {
} else {
this.kuzzle.query(this.buildQueryArgs('write', action), data, options);
}

return this;
};

/**
Expand Down Expand Up @@ -2564,7 +2692,7 @@ KuzzleDocument.prototype.delete = function (options, cb) {
options = null;
}

if (!this.id) {
if (!self.id) {
throw new Error('KuzzleDocument.delete: cannot delete a document without a document ID');
}

Expand All @@ -2574,13 +2702,11 @@ KuzzleDocument.prototype.delete = function (options, cb) {
return cb(err);
}

cb(null, self);
cb(null, self.id);
});
} else {
this.kuzzle.query(this.dataCollection.buildQueryArgs('write', 'delete'), this.serialize(), options);
}

return this;
};

/**
Expand Down Expand Up @@ -3805,12 +3931,12 @@ KuzzleSecurity.prototype.updateRole = function (id, content, options, cb) {
data.body = content;

if (cb) {
self.kuzzle.query(this.buildQueryArgs(action), data, options, function (err, res) {
self.kuzzle.query(this.buildQueryArgs(action), data, options, function (err) {
if (err) {
return cb(err);
}

cb(null, res.result._id);
cb(null, new KuzzleRole(self, id, content));
});
} else {
self.kuzzle.query(this.buildQueryArgs(action), data);
Expand Down Expand Up @@ -4038,11 +4164,23 @@ KuzzleSecurity.prototype.updateProfile = function (id, content, options, cb) {

if (cb) {
self.kuzzle.query(this.buildQueryArgs(action), data, options, function (err, res) {
var updatedContent = {};

if (err) {
return cb(err);
}

cb(null, res.result._id);
Object.keys(res.result._source).forEach(function (property) {
if (property !== 'roles') {
updatedContent[property] = res.result._source[property];
}
});

updatedContent.roles = res.result._source.roles.map(function (role) {
return role._id;
});

cb(null, new KuzzleProfile(self, res.result._id, updatedContent));
});
} else {
self.kuzzle.query(this.buildQueryArgs(action), data);
Expand Down
6 changes: 3 additions & 3 deletions dist/kuzzle.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/kuzzle.min.map

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "kuzzle-sdk",
"version": "1.8.0",
"version": "1.9.0",
"description": "Official Javascript SDK for Kuzzle",
"author": "The Kuzzle Team <support@kuzzle.io>",
"repository": {
Expand Down Expand Up @@ -41,6 +41,7 @@
"mocha": "2.4.5",
"proxyquire": "^1.7.3",
"rewire": "^2.5.0",
"should": "8.2.2"
"should": "8.2.2",
"sinon": "^1.17.4"
}
}
Loading

0 comments on commit 975b7d4

Please sign in to comment.