Skip to content

Commit 1de04a7

Browse files
authored
Merge pull request #147 from kuzzleio/develop-110-align-notification-responses-format
Align notification responses format
2 parents 8f655b6 + f0f1841 commit 1de04a7

19 files changed

+93
-25
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# next
2+
3+
## Breaking changes
4+
5+
* Align notification response formats #146
6+
17
*__note:__ the # at the end of lines are the pull request numbers on GitHub*
28

39
# 2.2.0

package.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,18 @@
3535
"ws": "^1.1.1"
3636
},
3737
"devDependencies": {
38-
"ora": "^0.4.0",
39-
"webpack": "^1.13.1",
38+
"codecov": "^1.0.1",
4039
"eslint": "^3.7.1",
4140
"eslint-friendly-formatter": "^2.0.6",
42-
"codecov": "^1.0.1",
4341
"istanbul": "0.4.5",
4442
"istanbul-middleware": "0.2.2",
4543
"mocha": "3.2.0",
44+
"ora": "^0.4.0",
4645
"proxyquire": "^1.7.10",
4746
"rewire": "^2.5.2",
4847
"should": "11.1.2",
49-
"sinon": "^1.17.5"
48+
"should-sinon": "0.0.5",
49+
"sinon": "^1.17.5",
50+
"webpack": "^1.13.1"
5051
}
5152
}

src/Document.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ function Document(kuzzleDataCollection, documentId, content) {
2929
},
3030
dataCollection: {
3131
value: kuzzleDataCollection,
32-
enumerable: true
32+
enumerable: false
3333
},
3434
kuzzle: {
3535
value: kuzzleDataCollection.kuzzle,
36-
enumerable: true
36+
enumerable: false
3737
},
3838
// writable properties
3939
id: {

src/Room.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
var
2-
uuid = require('uuid');
2+
uuid = require('uuid'),
3+
Document = require('./Document');
34

45
/**
56
* This is a global callback pattern, called by all asynchronous functions of the Kuzzle object.
@@ -319,6 +320,18 @@ function notificationCallback (data) {
319320
return this.kuzzle.emitEvent('jwtTokenExpired');
320321
}
321322

323+
if (data.controller === 'document') {
324+
data.type = 'document';
325+
data.document = new Document(this.collection, data.result._id, data.result._source);
326+
delete data.result;
327+
}
328+
329+
if (data.controller === 'realtime') {
330+
data.type = 'user';
331+
data.user = {count: data.result.count};
332+
delete data.result;
333+
}
334+
322335
if (this.kuzzle.requestHistory[data.requestId]) {
323336
if (this.subscribeToSelf) {
324337
this.callback(null, data);
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)