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
44 changes: 11 additions & 33 deletions dist/kuzzle.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,12 @@
// shim for using process in browser

var process = module.exports = {};

// cached from whatever global is present so that test runners that stub it
// don't break things. But we need to wrap it in a try catch in case it is
// wrapped in strict mode code which doesn't define any globals. It's inside a
// function because try/catches deoptimize in certain engines.

var cachedSetTimeout;
var cachedClearTimeout;

(function () {
try {
cachedSetTimeout = setTimeout;
} catch (e) {
cachedSetTimeout = function () {
throw new Error('setTimeout is not defined');
}
}
try {
cachedClearTimeout = clearTimeout;
} catch (e) {
cachedClearTimeout = function () {
throw new Error('clearTimeout is not defined');
}
}
} ())
var queue = [];
var draining = false;
var currentQueue;
var queueIndex = -1;

function cleanUpNextTick() {
if (!draining || !currentQueue) {
return;
}
draining = false;
if (currentQueue.length) {
queue = currentQueue.concat(queue);
Expand All @@ -51,7 +23,7 @@ function drainQueue() {
if (draining) {
return;
}
var timeout = cachedSetTimeout(cleanUpNextTick);
var timeout = setTimeout(cleanUpNextTick);
draining = true;

var len = queue.length;
Expand All @@ -68,7 +40,7 @@ function drainQueue() {
}
currentQueue = null;
draining = false;
cachedClearTimeout(timeout);
clearTimeout(timeout);
}

process.nextTick = function (fun) {
Expand All @@ -80,7 +52,7 @@ process.nextTick = function (fun) {
}
queue.push(new Item(fun, args));
if (queue.length === 1 && !draining) {
cachedSetTimeout(drainQueue, 0);
setTimeout(drainQueue, 0);
}
};

Expand Down Expand Up @@ -2245,9 +2217,10 @@ KuzzleDataCollection.prototype.getMapping = function (options, cb) {
*
* @param {object} document - either a KuzzleDocument instance or a JSON object
* @param {object} [options] - optional arguments
* @param {responseCallback} [cb] - Returns a raw Kuzzle response
* @returns {*} this
*/
KuzzleDataCollection.prototype.publishMessage = function (document, options) {
KuzzleDataCollection.prototype.publishMessage = function (document, options, cb) {
var data = {};

if (document instanceof KuzzleDocument) {
Expand All @@ -2257,7 +2230,7 @@ KuzzleDataCollection.prototype.publishMessage = function (document, options) {
}

data = this.kuzzle.addHeaders(data, this.headers);
this.kuzzle.query(this.buildQueryArgs('write', 'publish'), data, options);
this.kuzzle.query(this.buildQueryArgs('write', 'publish'), data, options, cb);

return this;
};
Expand Down Expand Up @@ -2566,6 +2539,11 @@ KuzzleDataMapping.prototype.refresh = function (options, cb) {
if (res.result[self.collection.index]) {
if (res.result[self.collection.index].mappings[self.collection.collection]) {
self.mapping = res.result[self.collection.index].mappings[self.collection.collection].properties;

// Mappings can be empty. The mapping property should never be "undefined"
if (self.mapping === undefined) {
self.mapping = {};
}
} else {
return cb ? cb(new Error('No mapping found for collection ' + self.collection.collection)) : false;
}
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.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "kuzzle-sdk",
"version": "1.9.2",
"version": "1.9.3",
"description": "Official Javascript SDK for Kuzzle",
"author": "The Kuzzle Team <support@kuzzle.io>",
"repository": {
Expand Down
5 changes: 3 additions & 2 deletions src/kuzzleDataCollection.js
Original file line number Diff line number Diff line change
Expand Up @@ -402,9 +402,10 @@ KuzzleDataCollection.prototype.getMapping = function (options, cb) {
*
* @param {object} document - either a KuzzleDocument instance or a JSON object
* @param {object} [options] - optional arguments
* @param {responseCallback} [cb] - Returns a raw Kuzzle response
* @returns {*} this
*/
KuzzleDataCollection.prototype.publishMessage = function (document, options) {
KuzzleDataCollection.prototype.publishMessage = function (document, options, cb) {
var data = {};

if (document instanceof KuzzleDocument) {
Expand All @@ -414,7 +415,7 @@ KuzzleDataCollection.prototype.publishMessage = function (document, options) {
}

data = this.kuzzle.addHeaders(data, this.headers);
this.kuzzle.query(this.buildQueryArgs('write', 'publish'), data, options);
this.kuzzle.query(this.buildQueryArgs('write', 'publish'), data, options, cb);

return this;
};
Expand Down