Skip to content

Commit 975b7d4

Browse files
author
STAFYNIAK Sacha
committed
Merge remote-tracking branch 'origin/develop'
Conflicts: dist/kuzzle.min.js dist/kuzzle.min.map
2 parents ab135fa + 6bcac11 commit 975b7d4

17 files changed

+973
-70
lines changed

CHANGELOG.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# 1.9.0
2+
3+
## Features
4+
* Implement new roles functionalities (`KuzzleSecurity.isActionAllowed`, `KuzzleSecurity.getMyRights`, `KuzzleSecurity.getUserRights`)
5+
* Implement the elasticsearch autorefresh features (`Kuzzle.refreshIndex`, `Kuzzle.getAutoRefresh`, `Kuzzle.setAutoRefresh`)
6+
* Implement the `Kuzzle.updateSelf` method that allow to update current user
7+
* Fix issues #81, #82, #73 & #76
8+
9+
## List of merged PR
10+
* Merge pull request #88 from kuzzleio/KUZ-574-getRights-methods - _Sébastien Cottinet_
11+
* Merge pull request #90 from kuzzleio/rename-policies - _Kévin Blondel_
12+
* Merge pull request #85 from kuzzleio/fix-rc-83-update-and-delete-consistency - _Sébastien Cottinet_
13+
* Merge pull request #87 from kuzzleio/KUZ-480-isActionAllowed - _Sébastien Cottinet_
14+
* Merge pull request #86 from kuzzleio/fix-rc-81-refactor-factory-signature - _Kévin Blondel_
15+
* Merge pull request #84 from kuzzleio/fix-rc-73-paginate-fetchAll - _Sébastien Cottinet_
16+
* Merge pull request #83 from kuzzleio/fix-rc-76-secure-dataCollectionFactory - _Kévin Blondel_
17+
* Merge pull request #80 from kuzzleio/kuz-463-es-autorefresh - _Sébastien Cottinet_

dist/kuzzle.js

Lines changed: 147 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1410,6 +1410,136 @@ Kuzzle.prototype.getServerInfo = function (options, cb) {
14101410
return this;
14111411
};
14121412

1413+
/**
1414+
* Forces an index refresh
1415+
*
1416+
* @param {string} index - The index to refresh. Defaults to Kuzzle.defaultIndex
1417+
* @param {object} options - Optional arguments
1418+
* @param {responseCallback} cb - Handles the query response
1419+
* @returns {Kuzzle}
1420+
*/
1421+
Kuzzle.prototype.refreshIndex = function () {
1422+
var
1423+
index,
1424+
options,
1425+
cb;
1426+
1427+
Array.prototype.slice.call(arguments).forEach(function(arg) {
1428+
switch (typeof arg) {
1429+
case 'string':
1430+
index = arg;
1431+
break;
1432+
case 'object':
1433+
options = arg;
1434+
break;
1435+
case 'function':
1436+
cb = arg;
1437+
break;
1438+
}
1439+
});
1440+
1441+
if (!index) {
1442+
if (!this.defaultIndex) {
1443+
throw new Error('Kuzzle.refreshIndex: index required');
1444+
}
1445+
index = this.defaultIndex;
1446+
}
1447+
1448+
this.query({ index: index, controller: 'admin', action: 'refreshIndex'}, {}, options, cb);
1449+
1450+
return this;
1451+
};
1452+
1453+
/**
1454+
* Returns de current autoRefresh status for the given index
1455+
*
1456+
* @param {string} index - The index to get the status from. Defaults to Kuzzle.defaultIndex
1457+
* @param {object} options - Optinal arguments
1458+
* @param {responseCallback} cb - Handles the query response
1459+
* @returns {object} this
1460+
*/
1461+
Kuzzle.prototype.getAutoRefresh = function () {
1462+
var
1463+
index,
1464+
options,
1465+
cb;
1466+
1467+
Array.prototype.slice.call(arguments).forEach(function (arg) {
1468+
switch (typeof arg) {
1469+
case 'string':
1470+
index = arg;
1471+
break;
1472+
case 'object':
1473+
options = arg;
1474+
break;
1475+
case 'function':
1476+
cb = arg;
1477+
break;
1478+
}
1479+
});
1480+
1481+
if (!index) {
1482+
if (!this.defaultIndex) {
1483+
throw new Error('Kuzzle.getAutoRefresh: index required');
1484+
}
1485+
index = this.defaultIndex;
1486+
}
1487+
1488+
this.callbackRequired('Kuzzle.getAutoRefresh', cb);
1489+
this.query({ index: index, controller: 'admin', action: 'getAutoRefresh'}, {}, options, cb);
1490+
1491+
return this;
1492+
};
1493+
1494+
/**
1495+
* (Un)Sets the autoRefresh flag on the given index
1496+
*
1497+
* @param {string} index - the index to modify. Defaults to Kuzzle.defaultIndex
1498+
* @param {boolean} autoRefresh - The autoRefresh value to set
1499+
* @param {object} options - Optional arguments
1500+
* @param {responseCallback} cb - Handles the query result
1501+
* @returns {object} this
1502+
*/
1503+
Kuzzle.prototype.setAutoRefresh = function () {
1504+
var
1505+
index,
1506+
autoRefresh,
1507+
options,
1508+
cb;
1509+
1510+
Array.prototype.slice.call(arguments).forEach(function (arg) {
1511+
switch (typeof arg) {
1512+
case 'string':
1513+
index = arg;
1514+
break;
1515+
case 'boolean':
1516+
autoRefresh = arg;
1517+
break;
1518+
case 'object':
1519+
options = arg;
1520+
break;
1521+
case 'function':
1522+
cb = arg;
1523+
break;
1524+
}
1525+
});
1526+
1527+
if (!index) {
1528+
if (!this.defaultIndex) {
1529+
throw new Error('Kuzzle.setAutoRefresh: index required');
1530+
}
1531+
index = this.defaultIndex;
1532+
}
1533+
1534+
if (autoRefresh === undefined) {
1535+
throw new Error('Kuzzle.setAutoRefresh: autoRefresh value is required');
1536+
}
1537+
1538+
this.query({ index: index, controller: 'admin', action: 'setAutoRefresh'}, { body: { autoRefresh: autoRefresh }}, options, cb);
1539+
1540+
return this;
1541+
};
1542+
14131543
/**
14141544
* Return the current Kuzzle's UTC Epoch time, in milliseconds
14151545
* @param {object} [options] - Optional parameters
@@ -1958,8 +2088,6 @@ KuzzleDataCollection.prototype.deleteDocument = function (arg, options, cb) {
19582088
} else {
19592089
this.kuzzle.query(this.buildQueryArgs('write', action), data, options);
19602090
}
1961-
1962-
return this;
19632091
};
19642092

19652093
/**
@@ -2564,7 +2692,7 @@ KuzzleDocument.prototype.delete = function (options, cb) {
25642692
options = null;
25652693
}
25662694

2567-
if (!this.id) {
2695+
if (!self.id) {
25682696
throw new Error('KuzzleDocument.delete: cannot delete a document without a document ID');
25692697
}
25702698

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

2577-
cb(null, self);
2705+
cb(null, self.id);
25782706
});
25792707
} else {
25802708
this.kuzzle.query(this.dataCollection.buildQueryArgs('write', 'delete'), this.serialize(), options);
25812709
}
2582-
2583-
return this;
25842710
};
25852711

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

38073933
if (cb) {
3808-
self.kuzzle.query(this.buildQueryArgs(action), data, options, function (err, res) {
3934+
self.kuzzle.query(this.buildQueryArgs(action), data, options, function (err) {
38093935
if (err) {
38103936
return cb(err);
38113937
}
38123938

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

40394165
if (cb) {
40404166
self.kuzzle.query(this.buildQueryArgs(action), data, options, function (err, res) {
4167+
var updatedContent = {};
4168+
40414169
if (err) {
40424170
return cb(err);
40434171
}
40444172

4045-
cb(null, res.result._id);
4173+
Object.keys(res.result._source).forEach(function (property) {
4174+
if (property !== 'roles') {
4175+
updatedContent[property] = res.result._source[property];
4176+
}
4177+
});
4178+
4179+
updatedContent.roles = res.result._source.roles.map(function (role) {
4180+
return role._id;
4181+
});
4182+
4183+
cb(null, new KuzzleProfile(self, res.result._id, updatedContent));
40464184
});
40474185
} else {
40484186
self.kuzzle.query(this.buildQueryArgs(action), data);

dist/kuzzle.min.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/kuzzle.min.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "kuzzle-sdk",
3-
"version": "1.8.0",
3+
"version": "1.9.0",
44
"description": "Official Javascript SDK for Kuzzle",
55
"author": "The Kuzzle Team <[email protected]>",
66
"repository": {
@@ -41,6 +41,7 @@
4141
"mocha": "2.4.5",
4242
"proxyquire": "^1.7.3",
4343
"rewire": "^2.5.0",
44-
"should": "8.2.2"
44+
"should": "8.2.2",
45+
"sinon": "^1.17.4"
4546
}
4647
}

0 commit comments

Comments
 (0)