Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/Kuzzle.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ function Kuzzle (host, options, cb) {
'queryError',
'discarded'
],
writeable: false
writable: false
},
queuing: {
value: false,
Expand Down Expand Up @@ -198,6 +198,10 @@ function Kuzzle (host, options, cb) {
value: undefined,
enumerable: true,
writable: true
},
sdkVersion: {
value: (typeof SDKVERSION === 'undefined') ? require('../package.json').version : SDKVERSION,
writable: false
}
});

Expand Down Expand Up @@ -1437,6 +1441,8 @@ Kuzzle.prototype.query = function (queryArgs, query, options, cb) {
object.requestId = uuid.v4();
}

object.volatile.sdkVersion = this.sdkVersion;

if (self.state === 'connected' || (options && options.queuable === false)) {
if (self.state === 'connected') {
emitRequest.call(this, object, cb);
Expand Down
6 changes: 2 additions & 4 deletions test/kuzzle/query.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,12 @@ var
NetworkWrapperMock = require('../mocks/networkWrapper.mock'),
Kuzzle = rewire('../../src/Kuzzle');


describe('Query management', function () {
describe('#emitRequest', function () {
var
emitRequest = Kuzzle.__get__('emitRequest'),
kuzzle;


beforeEach(function () {
kuzzle = new Kuzzle('somewhere', {connect: 'manual'});
kuzzle.network = new NetworkWrapperMock('somewhere');
Expand Down Expand Up @@ -125,7 +123,7 @@ describe('Query management', function () {
collection: 'collection',
controller: 'controller',
index: 'index',
volatile: {},
volatile: { sdkVersion: kuzzle.sdkVersion },
requestId: sinon.match(/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i)
});
});
Expand All @@ -141,7 +139,7 @@ describe('Query management', function () {
collection: 'collection',
controller: 'controller',
index: 'index',
volatile: {},
volatile: { sdkVersion: kuzzle.sdkVersion },
requestId: sinon.match(/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i)
}, sinon.match(function(f) {return f === cb;}));
});
Expand Down
3 changes: 2 additions & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ module.exports = {
new webpack.IgnorePlugin(/ws/),
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.DefinePlugin({
global: 'window'
global: 'window',
SDKVERSION: JSON.stringify(version)
}),
new webpack.BannerPlugin('Kuzzle javascript SDK version ' + version),
new webpack.optimize.UglifyJsPlugin({
Expand Down