Skip to content

Commit bc4dd9c

Browse files
authored
Merge pull request #342 from kuzzleio/5.0.14-proposal
Release 5.0.14
2 parents 70fa266 + fc5afcf commit bc4dd9c

File tree

6 files changed

+43
-14
lines changed

6 files changed

+43
-14
lines changed

package-lock.json

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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "kuzzle-sdk",
3-
"version": "5.0.13",
3+
"version": "5.0.14",
44
"description": "Official Javascript SDK for Kuzzle",
55
"author": "The Kuzzle Team <support@kuzzle.io>",
66
"repository": {

src/MemoryStorage.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ var
55
getKeys = {getter: true, required: ['keys']},
66
getMember = {getter: true, required: ['_id', 'member']},
77
getxScan = {
8-
getter: true,
9-
required: ['_id', 'cursor'],
8+
getter: true,
9+
required: ['_id', 'cursor'],
1010
opts: ['match', 'count'],
1111
mapResults: mapScanResults
1212
},
@@ -129,7 +129,7 @@ var
129129
sismember: getMember,
130130
smembers: getId,
131131
smove: {required: ['_id', 'destination', 'member']},
132-
sort: {getter: true, required: ['_id'], opts: ['alpha', 'by', 'direction', 'get', 'limit']},
132+
sort: {required: ['_id'], opts: ['alpha', 'by', 'direction', 'get', 'limit']},
133133
spop: {required: ['_id'], opts: ['count'], mapResults: mapStringToArray },
134134
srandmember: {getter: true, required: ['_id'], opts: ['count'], mapResults: mapStringToArray},
135135
srem: {required: ['_id', 'members']},
@@ -500,7 +500,7 @@ function mapZrangeResults(results) {
500500
* "<cursor>",
501501
* [
502502
* "value1",
503-
* "value2",
503+
* "value2",
504504
* "..."
505505
* ]
506506
* ]
@@ -514,8 +514,8 @@ function mapZrangeResults(results) {
514514
* "..."
515515
* ]
516516
* }
517-
*
518-
* @param {array.<string|array>} results
517+
*
518+
* @param {array.<string|array>} results
519519
* @return {object}
520520
*/
521521
function mapScanResults(results) {

src/Room.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -311,18 +311,20 @@ Room.prototype.setHeaders = function (content, replace) {
311311
* @returns {*}
312312
*/
313313
function notificationCallback (data) {
314+
var notificationData = Object.assign({}, data);
315+
314316
if (data.type === 'TokenExpired') {
315317
this.kuzzle.jwtToken = undefined;
316318
return this.kuzzle.emitEvent('tokenExpired');
317319
}
318320

319-
if (data.type === 'document') {
320-
data.document = new Document(this.collection, data.result._id, data.result._source, data.result._meta);
321-
delete data.result;
321+
if (notificationData.type === 'document') {
322+
notificationData.document = new Document(this.collection, notificationData.result._id, notificationData.result._source, notificationData.result._meta);
323+
delete notificationData.result;
322324
}
323325

324-
if (this.subscribeToSelf || !data.volatile || data.volatile.sdkInstanceId !== this.kuzzle.id) {
325-
this.callback(null, data);
326+
if (this.subscribeToSelf || !notificationData.volatile || notificationData.volatile.sdkInstanceId !== this.kuzzle.id) {
327+
this.callback(null, notificationData);
326328
}
327329
}
328330

test/MemoryStorage/methods.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1103,7 +1103,7 @@ describe('MemoryStorage methods', function () {
11031103
});
11041104

11051105
it('#sort', function () {
1106-
return testReadCommand(
1106+
return testWriteCommand(
11071107
'sort',
11081108
['key'],
11091109
{alpha: true, by: 'foo', direction: 'asc', get: ['foo', 'bar'], limit: {count: 0, offset: 1}},

test/Room/methods.test.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,33 @@ describe('Room methods', function () {
374374
.be.an.instanceOf(Document);
375375
});
376376

377+
it('should not alter the notification data', function () {
378+
var
379+
data = {
380+
controller: 'document',
381+
type: 'document',
382+
result: {
383+
_id: 'id',
384+
_source: {
385+
foo: 'bar'
386+
}
387+
}
388+
};
389+
390+
notifCB.call(room, data);
391+
392+
should(data).match({
393+
controller: 'document',
394+
type: 'document',
395+
result: {
396+
_id: 'id',
397+
_source: {
398+
foo: 'bar'
399+
}
400+
}
401+
});
402+
});
403+
377404
it('should handle realtime publish notifications', function () {
378405
notifCB.call(room, {
379406
controller: 'realtime',

0 commit comments

Comments
 (0)