diff --git a/dist/kuzzle.js b/dist/kuzzle.js index 2f88c449d..0210f7ca4 100644 --- a/dist/kuzzle.js +++ b/dist/kuzzle.js @@ -4,53 +4,74 @@ // Copyright (c) 2010-2012 Robert Kieffer // MIT License - http://opensource.org/licenses/mit-license.php -(function() { - var _global = this; +/*global window, require, define */ +(function(_window) { + 'use strict'; // Unique ID creation requires a high quality random # generator. We feature // detect to determine the best RNG source, normalizing to a function that // returns 128-bits of randomness, since that's what's usually required - var _rng; + var _rng, _mathRNG, _nodeRNG, _whatwgRNG, _previousRoot; + + function setupBrowser() { + // Allow for MSIE11 msCrypto + var _crypto = _window.crypto || _window.msCrypto; + + if (!_rng && _crypto && _crypto.getRandomValues) { + // WHATWG crypto-based RNG - http://wiki.whatwg.org/wiki/Crypto + // + // Moderately fast, high quality + try { + var _rnds8 = new Uint8Array(16); + _whatwgRNG = _rng = function whatwgRNG() { + _crypto.getRandomValues(_rnds8); + return _rnds8; + }; + _rng(); + } catch(e) {} + } - // Node.js crypto-based RNG - http://nodejs.org/docs/v0.6.2/api/crypto.html - // - // Moderately fast, high quality - if (typeof(_global.require) == 'function') { - try { - var _rb = _global.require('crypto').randomBytes; - _rng = _rb && function() {return _rb(16);}; - } catch(e) {} + if (!_rng) { + // Math.random()-based (RNG) + // + // If all else fails, use Math.random(). It's fast, but is of unspecified + // quality. + var _rnds = new Array(16); + _mathRNG = _rng = function() { + for (var i = 0, r; i < 16; i++) { + if ((i & 0x03) === 0) { r = Math.random() * 0x100000000; } + _rnds[i] = r >>> ((i & 0x03) << 3) & 0xff; + } + + return _rnds; + }; + if ('undefined' !== typeof console && console.warn) { + console.warn("[SECURITY] node-uuid: crypto not usable, falling back to insecure Math.random()"); + } + } } - if (!_rng && _global.crypto && crypto.getRandomValues) { - // WHATWG crypto-based RNG - http://wiki.whatwg.org/wiki/Crypto + function setupNode() { + // Node.js crypto-based RNG - http://nodejs.org/docs/v0.6.2/api/crypto.html // // Moderately fast, high quality - var _rnds8 = new Uint8Array(16); - _rng = function whatwgRNG() { - crypto.getRandomValues(_rnds8); - return _rnds8; - }; + if ('function' === typeof require) { + try { + var _rb = require('crypto').randomBytes; + _nodeRNG = _rng = _rb && function() {return _rb(16);}; + _rng(); + } catch(e) {} + } } - if (!_rng) { - // Math.random()-based (RNG) - // - // If all else fails, use Math.random(). It's fast, but is of unspecified - // quality. - var _rnds = new Array(16); - _rng = function() { - for (var i = 0, r; i < 16; i++) { - if ((i & 0x03) === 0) r = Math.random() * 0x100000000; - _rnds[i] = r >>> ((i & 0x03) << 3) & 0xff; - } - - return _rnds; - }; + if (_window) { + setupBrowser(); + } else { + setupNode(); } // Buffer class to use - var BufferClass = typeof(_global.Buffer) == 'function' ? _global.Buffer : Array; + var BufferClass = ('function' === typeof Buffer) ? Buffer : Array; // Maps for number <-> hex string conversion var _byteToHex = []; @@ -119,17 +140,17 @@ options = options || {}; - var clockseq = options.clockseq != null ? options.clockseq : _clockseq; + var clockseq = (options.clockseq != null) ? options.clockseq : _clockseq; // UUID timestamps are 100 nano-second units since the Gregorian epoch, // (1582-10-15 00:00). JSNumbers aren't precise enough for this, so // time is handled internally as 'msecs' (integer milliseconds) and 'nsecs' // (100-nanoseconds offset from msecs) since unix epoch, 1970-01-01 00:00. - var msecs = options.msecs != null ? options.msecs : new Date().getTime(); + var msecs = (options.msecs != null) ? options.msecs : new Date().getTime(); // Per 4.2.1.2, use count of uuid's generated during the current clock // cycle to simulate higher resolution clock - var nsecs = options.nsecs != null ? options.nsecs : _lastNSecs + 1; + var nsecs = (options.nsecs != null) ? options.nsecs : _lastNSecs + 1; // Time since last uuid creation (in msecs) var dt = (msecs - _lastMSecs) + (nsecs - _lastNSecs)/10000; @@ -195,8 +216,8 @@ // Deprecated - 'format' argument, as supported in v1.2 var i = buf && offset || 0; - if (typeof(options) == 'string') { - buf = options == 'binary' ? new BufferClass(16) : null; + if (typeof(options) === 'string') { + buf = (options === 'binary') ? new BufferClass(16) : null; options = null; } options = options || {}; @@ -224,28 +245,32 @@ uuid.parse = parse; uuid.unparse = unparse; uuid.BufferClass = BufferClass; + uuid._rng = _rng; + uuid._mathRNG = _mathRNG; + uuid._nodeRNG = _nodeRNG; + uuid._whatwgRNG = _whatwgRNG; - if (typeof(module) != 'undefined' && module.exports) { + if (('undefined' !== typeof module) && module.exports) { // Publish as node.js module module.exports = uuid; - } else if (typeof define === 'function' && define.amd) { + } else if (typeof define === 'function' && define.amd) { // Publish as AMD module define(function() {return uuid;}); - + } else { // Publish as global (in browsers) - var _previousRoot = _global.uuid; + _previousRoot = _window.uuid; // **`noConflict()` - (browser only) to reset global 'uuid' var** uuid.noConflict = function() { - _global.uuid = _previousRoot; + _window.uuid = _previousRoot; return uuid; }; - _global.uuid = uuid; + _window.uuid = uuid; } -}).call(this); +})('undefined' !== typeof window ? window : null); },{}],2:[function(require,module,exports){ var @@ -264,7 +289,7 @@ var * Kuzzle object constructor. * @param url - URL to the Kuzzle instance * @param [options] - Connection options - * @param {Kuzzle~constructorCallback} [cb] - Handles connection response + * @param {responseCallback} [cb] - Handles connection response * @constructor */ module.exports = Kuzzle = function (url, options, cb) { @@ -289,6 +314,9 @@ module.exports = Kuzzle = function (url, options, cb) { value: {}, writable: true }, + connectCB: { + value: cb + }, eventListeners: { value: { connected: [], @@ -469,7 +497,7 @@ module.exports = Kuzzle = function (url, options, cb) { if (!options || !options.connect || options.connect === 'auto') { - this.connect(cb); + this.connect(); } else { this.state = 'ready'; } @@ -478,7 +506,7 @@ module.exports = Kuzzle = function (url, options, cb) { return this.bluebird.promisifyAll(this, { suffix: 'Promise', filter: function (name, func, target, passes) { - var whitelist = ['connect', 'getAllStatistics', 'getStatistics', 'listCollections', 'now', 'query']; + var whitelist = ['getAllStatistics', 'getStatistics', 'listCollections', 'now', 'query']; return passes && whitelist.indexOf(name) !== -1; } @@ -491,15 +519,14 @@ module.exports = Kuzzle = function (url, options, cb) { /** * Connects to a Kuzzle instance using the provided URL. - * @param {responseCallback} [cb] * @returns {Object} this */ -Kuzzle.prototype.connect = function (cb) { +Kuzzle.prototype.connect = function () { var self = this; if (['initializing', 'ready', 'loggedOff', 'error', 'offline'].indexOf(this.state) === -1) { - if (cb) { - cb(null, self); + if (self.connectCB) { + self.connectCB(null, self); } return self; } @@ -528,8 +555,8 @@ Kuzzle.prototype.connect = function (cb) { listener.fn(); }); - if (cb) { - cb(null, self); + if (self.connectCB) { + self.connectCB(null, self); } }); @@ -540,8 +567,8 @@ Kuzzle.prototype.connect = function (cb) { listener.fn(); }); - if (cb) { - cb(error); + if (self.connectCB) { + self.connectCB(error); } }); @@ -810,6 +837,8 @@ Kuzzle.prototype.flushQueue = function () { * @returns {object} this */ Kuzzle.prototype.listCollections = function (options, cb) { + var collectionType = 'all'; + if (!cb && typeof options === 'function') { cb = options; options = null; @@ -817,7 +846,11 @@ Kuzzle.prototype.listCollections = function (options, cb) { this.callbackRequired('Kuzzle.listCollections', cb); - this.query(null, 'read', 'listCollections', {}, options, function (err, res) { + if (options && options.type) { + collectionType = options.type; + } + + this.query(null, 'read', 'listCollections', {body: {type: collectionType}}, options, function (err, res) { if (err) { return cb(err); } diff --git a/dist/kuzzle.min.js b/dist/kuzzle.min.js index 82aa31191..9188c9edf 100644 --- a/dist/kuzzle.min.js +++ b/dist/kuzzle.min.js @@ -1,3 +1,3 @@ -// Official Javascript SDK for Kuzzle v1.0.9 - License: Apache-2.0 -!function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);var j=new Error("Cannot find module '"+g+"'");throw j.code="MODULE_NOT_FOUND",j}var k=c[g]={exports:{}};b[g][0].call(k.exports,function(a){var c=b[g][1][a];return e(c?c:a)},k,k.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;ge&&(b[d+e++]=n[a])});16>e;)b[d+e++]=0;return b}function c(a,b){var c=b||0,d=m;return d[a[c++]]+d[a[c++]]+d[a[c++]]+d[a[c++]]+"-"+d[a[c++]]+d[a[c++]]+"-"+d[a[c++]]+d[a[c++]]+"-"+d[a[c++]]+d[a[c++]]+"-"+d[a[c++]]+d[a[c++]]+d[a[c++]]+d[a[c++]]+d[a[c++]]+d[a[c++]]}function d(a,b,d){var e=b&&d||0,f=b||[];a=a||{};var g=null!=a.clockseq?a.clockseq:r,h=null!=a.msecs?a.msecs:(new Date).getTime(),i=null!=a.nsecs?a.nsecs:t+1,j=h-s+(i-t)/1e4;if(0>j&&null==a.clockseq&&(g=g+1&16383),(0>j||h>s)&&null==a.nsecs&&(i=0),i>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");s=h,t=i,r=g,h+=122192928e5;var k=(1e4*(268435455&h)+i)%4294967296;f[e++]=k>>>24&255,f[e++]=k>>>16&255,f[e++]=k>>>8&255,f[e++]=255&k;var l=h/4294967296*1e4&268435455;f[e++]=l>>>8&255,f[e++]=255&l,f[e++]=l>>>24&15|16,f[e++]=l>>>16&255,f[e++]=g>>>8|128,f[e++]=255&g;for(var m=a.node||q,n=0;6>n;n++)f[e+n]=m[n];return b?b:c(f)}function e(a,b,d){var e=b&&d||0;"string"==typeof a&&(b="binary"==a?new l(16):null,a=null),a=a||{};var g=a.random||(a.rng||f)();if(g[6]=15&g[6]|64,g[8]=63&g[8]|128,b)for(var h=0;16>h;h++)b[e+h]=g[h];return b||c(g)}var f,g=this;if("function"==typeof g.require)try{var h=g.require("crypto").randomBytes;f=h&&function(){return h(16)}}catch(i){}if(!f&&g.crypto&&crypto.getRandomValues){var j=new Uint8Array(16);f=function(){return crypto.getRandomValues(j),j}}if(!f){var k=new Array(16);f=function(){for(var a,b=0;16>b;b++)0===(3&b)&&(a=4294967296*Math.random()),k[b]=a>>>((3&b)<<3)&255;return k}}for(var l="function"==typeof g.Buffer?g.Buffer:Array,m=[],n={},o=0;256>o;o++)m[o]=(o+256).toString(16).substr(1),n[m[o]]=o;var p=f(),q=[1|p[0],p[1],p[2],p[3],p[4],p[5]],r=16383&(p[6]<<8|p[7]),s=0,t=0,u=e;if(u.v1=d,u.v4=e,u.parse=a,u.unparse=c,u.BufferClass=l,"undefined"!=typeof b&&b.exports)b.exports=u;else if("function"==typeof define&&define.amd)define(function(){return u});else{var v=g.uuid;u.noConflict=function(){return g.uuid=v,u},g.uuid=u}}).call(this)},{}],2:[function(a,b,c){function d(){var a=this,b=Date.now(),c=-1;a.queueTTL>0&&(a.offlineQueue.forEach(function(d,e){d.ts0&&a.offlineQueue.length>a.queueMaxSize&&a.offlineQueue.splice(0,a.offlineQueue.length-a.queueMaxSize)}function e(a,b){var c=Date.now(),d=this;b&&d.socket.once(a.requestId,function(a){b(a.error,a.result)}),d.socket.emit("kuzzle",a),d.requestHistory[a.requestId]=c,Object.keys(d.requestHistory).forEach(function(a){d.requestHistory[a]0?(e.call(a,a.offlineQueue[0].query,a.offlineQueue[0].cb),a.offlineQueue.shift(),setTimeout(function(){f.call(a)},Math.max(0,a.replayInterval))):a.queuing=!1}var g=a("node-uuid"),h=a("./kuzzleDataCollection");b.exports=Kuzzle=function(b,c,d){var e=this;if(!(this instanceof Kuzzle))return new Kuzzle(b,c,d);if(d||"function"!=typeof c||(d=c,c=null),!b||""===b)throw new Error("URL to Kuzzle can't be empty");return Object.defineProperties(this,{collections:{value:{},writable:!0},eventListeners:{value:{connected:[],error:[],disconnected:[],reconnected:[]}},io:{value:null,writable:!0},queuing:{value:!1,writable:!0},requestHistory:{value:{},writable:!0},socket:{value:null,writable:!0},state:{value:"initializing",writable:!0},subscriptions:{value:{pending:{}},writable:!0},autoReconnect:{value:c&&"boolean"==typeof c.autoReconnect?c.autoReconnect:!0,enumerable:!0},index:{value:c&&"string"==typeof c.index?c.index:"mainindex",enumerable:!0},reconnectionDelay:{value:c&&"number"==typeof c.reconnectionDelay?c.reconnectionDelay:1e3,enumerable:!0},url:{value:b,enumerable:!0},autoQueue:{value:!1,enumerable:!0,writable:!0},autoReplay:{value:!1,enumerable:!0,writable:!0},autoResubscribe:{value:!0,enumerable:!0,writable:!0},headers:{value:{},enumerable:!0,writable:!0},metadata:{value:{},enumerable:!0,writable:!0},offlineQueue:{value:[],enumerable:!0,writable:!0},queueFilter:{value:null,enumerable:!0,writable:!0},queueMaxSize:{value:500,enumerable:!0,writable:!0},queueTTL:{value:12e4,enumerable:!0,writable:!0},replayInterval:{value:10,enumerable:!0,writable:!0}}),"undefined"!=typeof window&&window.io?this.io=window.io:this.io=a("socket.io-client"),c&&(Object.keys(c).forEach(function(a){e.hasOwnProperty(a)&&Object.getOwnPropertyDescriptor(e,a).writable&&(e[a]=c[a])}),"auto"===c.offlineMode&&this.autoReconnect&&(this.autoQueue=this.autoReplay=this.autoResubscribe=!0)),Object.defineProperty(this,"isValid",{value:function(){if("loggedOff"===this.state)throw new Error("This Kuzzle object has been invalidated. Did you try to access it after a logout call?")}}),Object.defineProperty(this,"addHeaders",{value:function(a,b){return Object.keys(b).forEach(function(c){a[c]||(a[c]=b[c])}),a}}),Object.defineProperty(this,"callbackRequired",{value:function(a,b){if(!b||"function"!=typeof b)throw new Error(a+": a callback argument is required for read queries")}}),c&&c.connect&&"auto"!==c.connect?this.state="ready":this.connect(d),this.bluebird?this.bluebird.promisifyAll(this,{suffix:"Promise",filter:function(a,b,c,d){var e=["connect","getAllStatistics","getStatistics","listCollections","now","query"];return d&&-1!==e.indexOf(a)}}):this},Kuzzle.prototype.connect=function(a){var b=this;return-1===["initializing","ready","loggedOff","error","offline"].indexOf(this.state)?(a&&a(null,b),b):(b.state="connecting",b.socket=b.io(b.url,{reconnection:b.autoReconnect,reconnectionDelay:b.reconnectionDelay,"force new connection":!0}),b.socket.once("connect",function(){b.state="connected",Object.keys(b.subscriptions).forEach(function(a){Object.keys(b.subscriptions[a]).forEach(function(c){var d=b.subscriptions[a][c];d.renew(d.callback)})}),f.call(b),b.eventListeners.connected.forEach(function(a){a.fn()}),a&&a(null,b)}),b.socket.on("connect_error",function(c){b.state="error",b.eventListeners.error.forEach(function(a){a.fn()}),a&&a(c)}),b.socket.on("disconnect",function(){b.state="offline",b.autoReconnect||b.logout(),b.autoQueue&&(b.queuing=!0),b.eventListeners.disconnected.forEach(function(a){a.fn()})}),b.socket.on("reconnect",function(){b.state="connected",b.autoResubscribe&&Object.keys(b.subscriptions).forEach(function(a){Object.keys(b.subscriptions[a]).forEach(function(c){var d=b.subscriptions[a][c];d.renew(d.callback)})}),b.autoReplay&&(d.call(b),f.call(b)),b.eventListeners.reconnected.forEach(function(a){a.fn()})}),this)},Kuzzle.prototype.addListener=function(a,b){var c,d=Object.keys(this.eventListeners),e=typeof b;if(this.isValid(),-1===d.indexOf(a))throw new Error("["+a+"] is not a known event. Known events: "+d.toString());if("function"!==e)throw new Error("Invalid listener type: expected a function, got a "+e);return c=g.v1(),this.eventListeners[a].push({id:c,fn:b}),c},Kuzzle.prototype.getAllStatistics=function(a,b){return b||"function"!=typeof a||(b=a,a=null),this.callbackRequired("Kuzzle.getAllStatistics",b),this.query(null,"admin","getAllStats",{},a,function(a,c){return a?b(a):void b(null,c.statistics)}),this},Kuzzle.prototype.getStatistics=function(a,b,c){var d;return c||(1===arguments.length?(c=arguments[0],b=null,a=null):(c=arguments[1],"object"==typeof arguments[0]?(b=arguments[0],a=null):(a=arguments[0],b=null))),d=function(b,d){return b?c(b):void(a?c(null,d.statistics):c(null,[d.statistics]))},this.callbackRequired("Kuzzle.getStatistics",c),a?this.query(null,"admin","getStats",{body:{startTime:a}},b,d):this.query(null,"admin","getLastStats",{},b,d),this},Kuzzle.prototype.dataCollectionFactory=function(a,b){return this.isValid(),this.collections[a]||(this.collections[a]=new h(this,a,b)),this.collections[a]},Kuzzle.prototype.flushQueue=function(){return this.offlineQueue=[],this},Kuzzle.prototype.listCollections=function(a,b){return b||"function"!=typeof a||(b=a,a=null),this.callbackRequired("Kuzzle.listCollections",b),this.query(null,"read","listCollections",{},a,function(a,c){return a?b(a):b(null,c.collections)}),this},Kuzzle.prototype.logout=function(){var a;this.state="loggedOff",this.socket.close(),this.socket=null;for(a in this.collections)this.collections.hasOwnProperty(a)&&delete this.collections[a]},Kuzzle.prototype.now=function(a,b){return b||"function"!=typeof a||(b=a,a=null),this.callbackRequired("Kuzzle.now",b),this.query(null,"read","now",{},a,function(a,c){return a?b(a):void b(null,c.now)}),this},Kuzzle.prototype.query=function(a,b,c,f,h,i){var j,k={action:c,controller:b,index:this.index,metadata:this.metadata},l=this;if(this.isValid(),i||"function"!=typeof h||(i=h,h=null),h&&(h.metadata&&Object.keys(h.metadata).forEach(function(a){k.metadata[a]=h.metadata[a]}),h.queuable===!1&&"offline"===l.state))return l;f.metadata&&Object.keys(f.metadata).forEach(function(a){k.metadata[a]=f.metadata[a]});for(j in f)"metadata"!==j&&f.hasOwnProperty(j)&&(k[j]=f[j]);return k=l.addHeaders(k,this.headers),a&&(k.collection=a),k.requestId||(k.requestId=g.v4()),"connected"===l.state||h&&h.queuable===!1?e.call(this,k,i):(l.queuing||-1!==["initializing","connecting"].indexOf(l.state))&&(d.call(this,k,i),l.queueFilter?l.queueFilter(k)&&l.offlineQueue.push({ts:Date.now(),query:k,cb:i}):l.offlineQueue.push({ts:Date.now(),query:k,cb:i})),l},Kuzzle.prototype.removeAllListeners=function(a){var b=Object.keys(this.eventListeners),c=this;if(a){if(-1===b.indexOf(a))throw new Error("["+a+"] is not a known event. Known events: "+b.toString());this.eventListeners[a]=[]}else b.forEach(function(a){c.eventListeners[a]=[]})},Kuzzle.prototype.removeListener=function(a,b){var c=Object.keys(this.eventListeners),d=this;if(-1===c.indexOf(a))throw new Error("["+a+"] is not a known event. Known events: "+c.toString());this.eventListeners[a].forEach(function(c,e){c.id===b&&d.eventListeners[a].splice(e,1)})},Kuzzle.prototype.replayQueue=function(){return"offline"===this.state||this.autoReplay||(d.call(this),f.call(this)),this},Kuzzle.prototype.setHeaders=function(a,b){var c=this;if("object"!=typeof a||Array.isArray(a))throw new Error("Expected a content object, received a "+typeof a);return b?c.headers=a:Object.keys(a).forEach(function(b){c.headers[b]=a[b]}),c},Kuzzle.prototype.startQueuing=function(){return"offline"!==this.state||this.autoQueue||(this.queuing=!0),this},Kuzzle.prototype.stopQueuing=function(){return"offline"!==this.state||this.autoQueue||(this.queuing=!1),this}},{"./kuzzleDataCollection":3,"node-uuid":1,"socket.io-client":void 0}],3:[function(a,b,c){function d(a,b){return Object.defineProperties(this,{collection:{value:b,enumerable:!0},kuzzle:{value:a,enumerable:!0},headers:{value:JSON.parse(JSON.stringify(a.headers)),enumerable:!0,writable:!0}}),this.kuzzle.bluebird?this.kuzzle.bluebird.promisifyAll(this,{suffix:"Promise",filter:function(a,b,c,d){var e=["publishMessage","setHeaders","subscribe"];return d&&-1===e.indexOf(a)}}):this}var e=a("./kuzzleDocument"),f=a("./kuzzleDataMapping"),g=a("./kuzzleRoom");d.prototype.advancedSearch=function(a,b,c){var d,e=this;return c||"function"!=typeof b||(c=b,b=null),e.kuzzle.callbackRequired("KuzzleDataCollection.advancedSearch",c),d=e.kuzzle.addHeaders({body:a},this.headers),e.kuzzle.query(this.collection,"read","search",d,b,function(a,b){var d=[];return a?c(a):(b.hits.hits.forEach(function(a){d.push(e.documentFactory(a._id,a))}),void c(null,{total:b.hits.total,documents:d}))}),this},d.prototype.count=function(a,b,c){var d;return c||"function"!=typeof b||(c=b,b=null),this.kuzzle.callbackRequired("KuzzleDataCollection.count",c),d=this.kuzzle.addHeaders({body:a},this.headers),this.kuzzle.query(this.collection,"read","count",d,b,function(a,b){return a?c(a):void c(null,b.count)}),this},d.prototype.create=function(a,b){var c={};return b||"function"!=typeof a||(b=a,a=null),c=this.kuzzle.addHeaders(c,this.headers),this.kuzzle.query(this.collection,"write","createCollection",c,a,b),this},d.prototype.createDocument=function(a,b,c,d){var f=this,g={},h="create";return"string"!=typeof a&&(d=c,c=b,b=a,a=null),d||"function"!=typeof c||(d=c,c=null),b instanceof e?g=b.toJSON():g.body=b,c&&(h=c.updateIfExist?"createOrUpdate":"create"),a&&(g._id=a),g.persist=!0,g=f.kuzzle.addHeaders(g,f.headers),d?f.kuzzle.query(this.collection,"write",h,g,c,function(a,b){return a?d(a):void d(null,f.documentFactory(b._id,b))}):this.kuzzle.query(this.collection,"write",h,g,c),this},d.prototype["delete"]=function(a,b){var c={};return b||"function"!=typeof a||(b=a,a=null),c=this.kuzzle.addHeaders(c,this.headers),this.kuzzle.query(this.collection,"admin","deleteCollection",c,a,b),this},d.prototype.deleteDocument=function(a,b,c){var d,e={};return"string"==typeof a?(e._id=a,d="delete"):(e.body=a,d="deleteByQuery"),c||"function"!=typeof b||(c=b,b=null),e=this.kuzzle.addHeaders(e,this.headers),c?this.kuzzle.query(this.collection,"write",d,e,b,function(a,b){return a?c(a):void("delete"===d?c(null,[e._id]):c(null,b.ids))}):this.kuzzle.query(this.collection,"write",d,e,b),this},d.prototype.fetchDocument=function(a,b,c){var d={_id:a},e=this;return c||"function"!=typeof b||(c=b,b=null),e.kuzzle.callbackRequired("KuzzleDataCollection.fetch",c),d=e.kuzzle.addHeaders(d,this.headers),e.kuzzle.query(this.collection,"read","get",d,b,function(a,b){return a?c(a):void c(null,e.documentFactory(b._id,b))}),this},d.prototype.fetchAllDocuments=function(a,b){return b||"function"!=typeof a||(b=a,a=null),this.kuzzle.callbackRequired("KuzzleDataCollection.fetchAll",b),this.advancedSearch({},a,b),this},d.prototype.getMapping=function(a,b){var c;return b||"function"!=typeof a||(b=a,a=null),this.kuzzle.callbackRequired("KuzzleDataCollection.getMapping",b),c=new f(this),c.refresh(a,b),this},d.prototype.publishMessage=function(a,b){var c={};return a instanceof e?c=a.toJSON():c.body=a,c.persist=!1,c=this.kuzzle.addHeaders(c,this.headers),this.kuzzle.query(this.collection,"write","publish",c,b),this},d.prototype.putMapping=function(a,b,c){var d;return c||"function"!=typeof b||(c=b,b=null),d=new f(this,a),d.apply(b,c),this},d.prototype.replaceDocument=function(a,b,c,d){var e=this,f={_id:a,body:b};return d||"function"!=typeof c||(d=c,c=null),f=e.kuzzle.addHeaders(f,this.headers),d?e.kuzzle.query(this.collection,"write","createOrUpdate",f,c,function(a,b){return a?d(a):void d(null,e.documentFactory(b._id,b))}):e.kuzzle.query(this.collection,"write","createOrUpdate",f,c),this},d.prototype.subscribe=function(a,b,c){var d;return c||"function"!=typeof b||(c=b,b=null),this.kuzzle.callbackRequired("KuzzleDataCollection.subscribe",c),d=new g(this,b),d.renew(a,c)},d.prototype.truncate=function(a,b){var c={};return b||"function"!=typeof a||(b=a,a=null),c=this.kuzzle.addHeaders(c,this.headers),this.kuzzle.query(this.collection,"admin","truncateCollection",c,a,b),this},d.prototype.updateDocument=function(a,b,c,d){var f={_id:a,body:b},g=this;return d||"function"!=typeof c||(d=c,c=null),f=g.kuzzle.addHeaders(f,this.headers),d?g.kuzzle.query(this.collection,"write","update",f,c,function(a,b){var c;return a?d(a):(c=new e(g,b._id),void d(null,c))}):g.kuzzle.query(this.collection,"write","update",f,c),g},d.prototype.documentFactory=function(a,b){var c=b._source?new e(this,a,b._source):new e(this,a,b);return c},d.prototype.roomFactory=function(a){return new g(this,a)},d.prototype.dataMappingFactory=function(a){return new f(this,a)},d.prototype.setHeaders=function(a,b){return this.kuzzle.setHeaders.call(this,a,b),this},b.exports=d},{"./kuzzleDataMapping":4,"./kuzzleDocument":5,"./kuzzleRoom":6}],4:[function(a,b,c){function d(a,b){return Object.defineProperties(this,{collection:{value:a.collection,eunmerable:!0},kuzzle:{value:a.kuzzle,enumerable:!0},headers:{value:JSON.parse(JSON.stringify(a.headers)),enumerable:!0,writable:!0},mapping:{value:b||{},enumerable:!0,writable:!0}}),this.kuzzle.bluebird?this.kuzzle.bluebird.promisifyAll(this,{suffix:"Promise",filter:function(a,b,c,d){var e=["set","setHeaders"];return d&&-1===e.indexOf(a)}}):this}d.prototype.apply=function(a,b){var c=this,d=this.kuzzle.addHeaders({body:{properties:this.mapping}},this.headers);return b||"function"!=typeof a||(b=a,a=null),c.kuzzle.query(this.collection,"admin","putMapping",d,a,function(a,d){return a?b?b(a):!1:(c.mapping=d._source.properties,void(b&&b(null,c)))}),this},d.prototype.refresh=function(a,b){var c=this,d=this.kuzzle.addHeaders({},this.headers);return b||"function"!=typeof a||(b=a,a=null),this.kuzzle.query(this.collection,"admin","getMapping",d,a,function(a,d){return a?b?b(a):!1:(c.mapping=d.mainindex.mappings[c.collection].properties,void(b&&b(null,c)))}),this},d.prototype.set=function(a,b){return this.mapping[a]=b,this},d.prototype.setHeaders=function(a,b){return this.kuzzle.setHeaders.call(this,a,b),this},b.exports=d},{}],5:[function(a,b,c){function d(a,b,c){return Object.defineProperties(this,{queue:{value:[],writable:!0},refreshing:{value:!1,writable:!0},collection:{value:a.collection,enumerable:!0},dataCollection:{value:a,enumerable:!0},kuzzle:{value:a.kuzzle,enumerable:!0},id:{value:void 0,enumerable:!0,writable:!0},content:{value:{},writable:!0,enumerable:!0},headers:{value:JSON.parse(JSON.stringify(a.headers)),enumerable:!0,writable:!0},version:{value:void 0,enumerable:!0,writable:!0}}),!c&&b&&"object"==typeof b&&(c=b,b=null),c&&(c._version&&(this.version=c._version,delete c._version),this.setContent(c,!0)),b&&(Object.defineProperty(this,"id",{value:b,enumerable:!0}),c||this.refresh()),this.kuzzle.bluebird?this.kuzzle.bluebird.promisifyAll(this,{suffix:"Promise",filter:function(a,b,c,d){var e=["delete","refresh","save"];return d&&-1!==e.indexOf(a)}}):this}function e(){for(var a;this.queue.length>0;)a=this.queue.shift(),this[a.action].apply(this,a.args)}d.prototype.toJSON=function(){var a={};return this.id&&(a._id=this.id),a.body=this.content,a._version=this.version,a=this.kuzzle.addHeaders(a,this.headers)},d.prototype.toString=function(){return JSON.stringify(this.toJSON())},d.prototype["delete"]=function(a,b){var c=this;if(b||"function"!=typeof a||(b=a,a=null),this.refreshing)return this.queue.push({action:"delete",args:[a,b]}),this;if(!this.id)throw new Error("KuzzleDocument.delete: cannot delete a document without a document ID");return b?this.kuzzle.query(this.collection,"write","delete",this.toJSON(),a,function(a){return a?b(a):void b(null,c)}):this.kuzzle.query(this.collection,"write","delete",this.toJSON(),a),this},d.prototype.refresh=function(a,b){var c=this;if(b||"function"!=typeof a||(b=a,a=null),this.refreshing)return this.queue.push({action:"refresh",args:[a,b]}),this;if(!c.id)throw new Error("KuzzleDocument.refresh: cannot retrieve a document if no ID has been provided");return c.refreshing=!0,c.kuzzle.query(c.collection,"read","get",{_id:c.id},a,function(a,d){return a?(c.refreshing=!1,c.queue=[],b?b(a):!1):(c.version=d._version,c.content=d._source,b&&b(null,c),c.refreshing=!1,void e.call(c))}),this},d.prototype.save=function(a,b){var c=this.toJSON(),d=this;return a&&void 0===b&&"function"==typeof a&&(b=a,a=null),d.refreshing?(d.queue.push({action:"save",args:[a,b]}),d):(c.persist=!0,d.kuzzle.query(this.collection,"write","createOrUpdate",c,a,function(a,c){return a?b?b(a):!1:(d.id=c._id,d.version=c._version,void(b&&b(null,d)))}),d)},d.prototype.publish=function(a){var b=this.toJSON();return this.refreshing?(this.queue.push({action:"publish",args:[a]}),this):(b.persist=!1,this.kuzzle.query(this.collection,"write","publish",b,a),this)},d.prototype.setContent=function(a,b){var c=this;return this.refreshing?(this.queue.push({action:"setContent",args:[a,b]}),this):(b?this.content=a:Object.keys(a).forEach(function(b){c.content[b]=a[b]}),this)},d.prototype.subscribe=function(a,b){var c;if(a&&!b&&"function"==typeof a&&(b=a,a=null),this.kuzzle.callbackRequired("KuzzleDocument.subscribe",b),!this.id)throw new Error("KuzzleDocument.subscribe: cannot subscribe to a document if no ID has been provided");return c={ids:{values:[this.id]}},this.dataCollection.subscribe(c,a,b)},d.prototype.setHeaders=function(a,b){return this.kuzzle.setHeaders.call(this,a,b),this},b.exports=d},{}],6:[function(a,b,c){function d(a,b){return Object.defineProperties(this,{callback:{value:null,writable:!0},channel:{value:null,writable:!0},id:{value:g.v4()},notifier:{value:null,writable:!0},queue:{value:[],writable:!0},scope:{value:b&&b.scope?b.scope:"all"},state:{value:b&&b.state?b.state:"done"},subscribing:{value:!1,writable:!0},users:{value:b&&b.users?b.users:"none"},collection:{value:a.collection,enumerable:!0},kuzzle:{value:a.kuzzle,enumerable:!0},filters:{value:null,enumerable:!0,writable:!0},headers:{value:JSON.parse(JSON.stringify(a.headers)),enumerable:!0,writable:!0},metadata:{value:b&&b.metadata?b.metadata:{},enumerable:!0,writable:!0},roomId:{value:null,enumerable:!0,writable:!0},subscribeToSelf:{value:b&&"boolean"==typeof b.subscribeToSelf?b.subscribeToSelf:!0,enumerable:!0,writable:!0}}),this.kuzzle.bluebird?this.kuzzle.bluebird.promisifyAll(this,{suffix:"Promise",filter:function(a,b,c,d){var e=["count"];return d&&-1!==e.indexOf(a)}}):this}function e(a){return a.error?this.callback(a.error):void(this.kuzzle.requestHistory[a.result.requestId]?(this.subscribeToSelf&&this.callback(null,a.result),delete this.kuzzle.requestHistory[a.result.requestId]):this.callback(null,a.result))}function f(){for(var a;this.queue.length>0;)a=this.queue.shift(),this[a.action].apply(this,a.args)}var g=a("node-uuid");d.prototype.count=function(a){var b;return this.kuzzle.callbackRequired("KuzzleRoom.count",a),b=this.kuzzle.addHeaders({body:{roomId:this.roomId}},this.headers),this.subscribing?(this.queue.push({action:"count",args:[a]}),this):(this.kuzzle.query(this.collection,"subscribe","count",b,function(b,c){return b?a(b):void a(null,c.count)}),this)},d.prototype.renew=function(a,b){var c={scope:this.scope,state:this.state,users:this.users},d=this;return!b&&a&&"function"==typeof a&&(b=a,a=null),this.subscribing?(this.queue.push({action:"renew",args:[a,b]}),this):(this.kuzzle.callbackRequired("KuzzleRoom.renew",b),this.unsubscribe(),this.roomId=null,this.subscribing=!0,this.callback=b,this.kuzzle.subscriptions.pending[d.id]=d,a&&(this.filters=a),c.body=this.filters,c=this.kuzzle.addHeaders(c,this.headers),d.kuzzle.query(this.collection,"subscribe","on",c,{metadata:this.metadata},function(a,b){if(delete d.kuzzle.subscriptions.pending[d.id],d.subscribing=!1,a)throw d.queue=[],new Error("Error during Kuzzle subscription: "+a.message);d.roomId=b.roomId,d.channel=b.channel,d.kuzzle.subscriptions[d.roomId]||(d.kuzzle.subscriptions[d.roomId]={}),d.kuzzle.subscriptions[d.roomId][d.id]=d,d.notifier=e.bind(d),d.kuzzle.socket.on(d.channel,d.notifier),f.call(d)}),this)},d.prototype.unsubscribe=function(){var a,b=this,c=b.roomId;return b.subscribing?(b.queue.push({action:"unsubscribe",args:[]}),b):(c&&(b.kuzzle.socket.off(b.channel,this.notifier),1===Object.keys(b.kuzzle.subscriptions[c]).length?(delete b.kuzzle.subscriptions[c],0===Object.keys(b.kuzzle.subscriptions.pending).length?b.kuzzle.query(this.collection,"subscribe","off",{body:{roomId:c}}):a=setInterval(function(){0===Object.keys(b.kuzzle.subscriptions.pending).length&&(b.kuzzle.subscriptions[c]||b.kuzzle.query(b.collection,"subscribe","off",{body:{roomId:c}}),clearInterval(a))},100)):delete b.kuzzle.subscriptions[c][b.id],b.roomId=null),b)},d.prototype.setHeaders=function(a,b){return this.kuzzle.setHeaders.call(this,a,b),this},b.exports=d},{"node-uuid":1}]},{},[2]); +// Official Javascript SDK for Kuzzle v1.1.0 - License: Apache-2.0 +!function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);var j=new Error("Cannot find module '"+g+"'");throw j.code="MODULE_NOT_FOUND",j}var k=c[g]={exports:{}};b[g][0].call(k.exports,function(a){var c=b[g][1][a];return e(c?c:a)},k,k.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;gb;b++)0===(3&b)&&(a=4294967296*Math.random()),e[b]=a>>>((3&b)<<3)&255;return e},"undefined"!=typeof console&&console.warn&&console.warn("[SECURITY] node-uuid: crypto not usable, falling back to insecure Math.random()")}}function e(){if("function"==typeof a)try{var b=a("crypto").randomBytes;l=j=b&&function(){return b(16)},j()}catch(c){}}function f(a,b,c){var d=b&&c||0,e=0;for(b=b||[],a.toLowerCase().replace(/[0-9a-f]{2}/g,function(a){16>e&&(b[d+e++]=q[a])});16>e;)b[d+e++]=0;return b}function g(a,b){var c=b||0,d=p;return d[a[c++]]+d[a[c++]]+d[a[c++]]+d[a[c++]]+"-"+d[a[c++]]+d[a[c++]]+"-"+d[a[c++]]+d[a[c++]]+"-"+d[a[c++]]+d[a[c++]]+"-"+d[a[c++]]+d[a[c++]]+d[a[c++]]+d[a[c++]]+d[a[c++]]+d[a[c++]]}function h(a,b,c){var d=b&&c||0,e=b||[];a=a||{};var f=null!=a.clockseq?a.clockseq:u,h=null!=a.msecs?a.msecs:(new Date).getTime(),i=null!=a.nsecs?a.nsecs:w+1,j=h-v+(i-w)/1e4;if(0>j&&null==a.clockseq&&(f=f+1&16383),(0>j||h>v)&&null==a.nsecs&&(i=0),i>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");v=h,w=i,u=f,h+=122192928e5;var k=(1e4*(268435455&h)+i)%4294967296;e[d++]=k>>>24&255,e[d++]=k>>>16&255,e[d++]=k>>>8&255,e[d++]=255&k;var l=h/4294967296*1e4&268435455;e[d++]=l>>>8&255,e[d++]=255&l,e[d++]=l>>>24&15|16,e[d++]=l>>>16&255,e[d++]=f>>>8|128,e[d++]=255&f;for(var m=a.node||t,n=0;6>n;n++)e[d+n]=m[n];return b?b:g(e)}function i(a,b,c){var d=b&&c||0;"string"==typeof a&&(b="binary"===a?new o(16):null,a=null),a=a||{};var e=a.random||(a.rng||j)();if(e[6]=15&e[6]|64,e[8]=63&e[8]|128,b)for(var f=0;16>f;f++)b[d+f]=e[f];return b||g(e)}var j,k,l,m,n;c?d():e();for(var o="function"==typeof Buffer?Buffer:Array,p=[],q={},r=0;256>r;r++)p[r]=(r+256).toString(16).substr(1),q[p[r]]=r;var s=j(),t=[1|s[0],s[1],s[2],s[3],s[4],s[5]],u=16383&(s[6]<<8|s[7]),v=0,w=0,x=i;x.v1=h,x.v4=i,x.parse=f,x.unparse=g,x.BufferClass=o,x._rng=j,x._mathRNG=k,x._nodeRNG=l,x._whatwgRNG=m,"undefined"!=typeof b&&b.exports?b.exports=x:"function"==typeof define&&define.amd?define(function(){return x}):(n=c.uuid,x.noConflict=function(){return c.uuid=n,x},c.uuid=x)}("undefined"!=typeof window?window:null)},{}],2:[function(a,b,c){function d(){var a=this,b=Date.now(),c=-1;a.queueTTL>0&&(a.offlineQueue.forEach(function(d,e){d.ts0&&a.offlineQueue.length>a.queueMaxSize&&a.offlineQueue.splice(0,a.offlineQueue.length-a.queueMaxSize)}function e(a,b){var c=Date.now(),d=this;b&&d.socket.once(a.requestId,function(a){b(a.error,a.result)}),d.socket.emit("kuzzle",a),d.requestHistory[a.requestId]=c,Object.keys(d.requestHistory).forEach(function(a){d.requestHistory[a]0?(e.call(a,a.offlineQueue[0].query,a.offlineQueue[0].cb),a.offlineQueue.shift(),setTimeout(function(){f.call(a)},Math.max(0,a.replayInterval))):a.queuing=!1}var g=a("node-uuid"),h=a("./kuzzleDataCollection");b.exports=Kuzzle=function(b,c,d){var e=this;if(!(this instanceof Kuzzle))return new Kuzzle(b,c,d);if(d||"function"!=typeof c||(d=c,c=null),!b||""===b)throw new Error("URL to Kuzzle can't be empty");return Object.defineProperties(this,{collections:{value:{},writable:!0},connectCB:{value:d},eventListeners:{value:{connected:[],error:[],disconnected:[],reconnected:[]}},io:{value:null,writable:!0},queuing:{value:!1,writable:!0},requestHistory:{value:{},writable:!0},socket:{value:null,writable:!0},state:{value:"initializing",writable:!0},subscriptions:{value:{pending:{}},writable:!0},autoReconnect:{value:c&&"boolean"==typeof c.autoReconnect?c.autoReconnect:!0,enumerable:!0},index:{value:c&&"string"==typeof c.index?c.index:"mainindex",enumerable:!0},reconnectionDelay:{value:c&&"number"==typeof c.reconnectionDelay?c.reconnectionDelay:1e3,enumerable:!0},url:{value:b,enumerable:!0},autoQueue:{value:!1,enumerable:!0,writable:!0},autoReplay:{value:!1,enumerable:!0,writable:!0},autoResubscribe:{value:!0,enumerable:!0,writable:!0},headers:{value:{},enumerable:!0,writable:!0},metadata:{value:{},enumerable:!0,writable:!0},offlineQueue:{value:[],enumerable:!0,writable:!0},queueFilter:{value:null,enumerable:!0,writable:!0},queueMaxSize:{value:500,enumerable:!0,writable:!0},queueTTL:{value:12e4,enumerable:!0,writable:!0},replayInterval:{value:10,enumerable:!0,writable:!0}}),"undefined"!=typeof window&&window.io?this.io=window.io:this.io=a("socket.io-client"),c&&(Object.keys(c).forEach(function(a){e.hasOwnProperty(a)&&Object.getOwnPropertyDescriptor(e,a).writable&&(e[a]=c[a])}),"auto"===c.offlineMode&&this.autoReconnect&&(this.autoQueue=this.autoReplay=this.autoResubscribe=!0)),Object.defineProperty(this,"isValid",{value:function(){if("loggedOff"===this.state)throw new Error("This Kuzzle object has been invalidated. Did you try to access it after a logout call?")}}),Object.defineProperty(this,"addHeaders",{value:function(a,b){return Object.keys(b).forEach(function(c){a[c]||(a[c]=b[c])}),a}}),Object.defineProperty(this,"callbackRequired",{value:function(a,b){if(!b||"function"!=typeof b)throw new Error(a+": a callback argument is required for read queries")}}),c&&c.connect&&"auto"!==c.connect?this.state="ready":this.connect(),this.bluebird?this.bluebird.promisifyAll(this,{suffix:"Promise",filter:function(a,b,c,d){var e=["getAllStatistics","getStatistics","listCollections","now","query"];return d&&-1!==e.indexOf(a)}}):this},Kuzzle.prototype.connect=function(){var a=this;return-1===["initializing","ready","loggedOff","error","offline"].indexOf(this.state)?(a.connectCB&&a.connectCB(null,a),a):(a.state="connecting",a.socket=a.io(a.url,{reconnection:a.autoReconnect,reconnectionDelay:a.reconnectionDelay,"force new connection":!0}),a.socket.once("connect",function(){a.state="connected",Object.keys(a.subscriptions).forEach(function(b){Object.keys(a.subscriptions[b]).forEach(function(c){var d=a.subscriptions[b][c];d.renew(d.callback)})}),f.call(a),a.eventListeners.connected.forEach(function(a){a.fn()}),a.connectCB&&a.connectCB(null,a)}),a.socket.on("connect_error",function(b){a.state="error",a.eventListeners.error.forEach(function(a){a.fn()}),a.connectCB&&a.connectCB(b)}),a.socket.on("disconnect",function(){a.state="offline",a.autoReconnect||a.logout(),a.autoQueue&&(a.queuing=!0),a.eventListeners.disconnected.forEach(function(a){a.fn()})}),a.socket.on("reconnect",function(){a.state="connected",a.autoResubscribe&&Object.keys(a.subscriptions).forEach(function(b){Object.keys(a.subscriptions[b]).forEach(function(c){var d=a.subscriptions[b][c];d.renew(d.callback)})}),a.autoReplay&&(d.call(a),f.call(a)),a.eventListeners.reconnected.forEach(function(a){a.fn()})}),this)},Kuzzle.prototype.addListener=function(a,b){var c,d=Object.keys(this.eventListeners),e=typeof b;if(this.isValid(),-1===d.indexOf(a))throw new Error("["+a+"] is not a known event. Known events: "+d.toString());if("function"!==e)throw new Error("Invalid listener type: expected a function, got a "+e);return c=g.v1(),this.eventListeners[a].push({id:c,fn:b}),c},Kuzzle.prototype.getAllStatistics=function(a,b){return b||"function"!=typeof a||(b=a,a=null),this.callbackRequired("Kuzzle.getAllStatistics",b),this.query(null,"admin","getAllStats",{},a,function(a,c){return a?b(a):void b(null,c.statistics)}),this},Kuzzle.prototype.getStatistics=function(a,b,c){var d;return c||(1===arguments.length?(c=arguments[0],b=null,a=null):(c=arguments[1],"object"==typeof arguments[0]?(b=arguments[0],a=null):(a=arguments[0],b=null))),d=function(b,d){return b?c(b):void(a?c(null,d.statistics):c(null,[d.statistics]))},this.callbackRequired("Kuzzle.getStatistics",c),a?this.query(null,"admin","getStats",{body:{startTime:a}},b,d):this.query(null,"admin","getLastStats",{},b,d),this},Kuzzle.prototype.dataCollectionFactory=function(a,b){return this.isValid(),this.collections[a]||(this.collections[a]=new h(this,a,b)),this.collections[a]},Kuzzle.prototype.flushQueue=function(){return this.offlineQueue=[],this},Kuzzle.prototype.listCollections=function(a,b){var c="all";return b||"function"!=typeof a||(b=a,a=null),this.callbackRequired("Kuzzle.listCollections",b),a&&a.type&&(c=a.type),this.query(null,"read","listCollections",{body:{type:c}},a,function(a,c){return a?b(a):b(null,c.collections)}),this},Kuzzle.prototype.logout=function(){var a;this.state="loggedOff",this.socket.close(),this.socket=null;for(a in this.collections)this.collections.hasOwnProperty(a)&&delete this.collections[a]},Kuzzle.prototype.now=function(a,b){return b||"function"!=typeof a||(b=a,a=null),this.callbackRequired("Kuzzle.now",b),this.query(null,"read","now",{},a,function(a,c){return a?b(a):void b(null,c.now)}),this},Kuzzle.prototype.query=function(a,b,c,f,h,i){var j,k={action:c,controller:b,index:this.index,metadata:this.metadata},l=this;if(this.isValid(),i||"function"!=typeof h||(i=h,h=null),h&&(h.metadata&&Object.keys(h.metadata).forEach(function(a){k.metadata[a]=h.metadata[a]}),h.queuable===!1&&"offline"===l.state))return l;f.metadata&&Object.keys(f.metadata).forEach(function(a){k.metadata[a]=f.metadata[a]});for(j in f)"metadata"!==j&&f.hasOwnProperty(j)&&(k[j]=f[j]);return k=l.addHeaders(k,this.headers),a&&(k.collection=a),k.requestId||(k.requestId=g.v4()),"connected"===l.state||h&&h.queuable===!1?e.call(this,k,i):(l.queuing||-1!==["initializing","connecting"].indexOf(l.state))&&(d.call(this,k,i),l.queueFilter?l.queueFilter(k)&&l.offlineQueue.push({ts:Date.now(),query:k,cb:i}):l.offlineQueue.push({ts:Date.now(),query:k,cb:i})),l},Kuzzle.prototype.removeAllListeners=function(a){var b=Object.keys(this.eventListeners),c=this;if(a){if(-1===b.indexOf(a))throw new Error("["+a+"] is not a known event. Known events: "+b.toString());this.eventListeners[a]=[]}else b.forEach(function(a){c.eventListeners[a]=[]})},Kuzzle.prototype.removeListener=function(a,b){var c=Object.keys(this.eventListeners),d=this;if(-1===c.indexOf(a))throw new Error("["+a+"] is not a known event. Known events: "+c.toString());this.eventListeners[a].forEach(function(c,e){c.id===b&&d.eventListeners[a].splice(e,1)})},Kuzzle.prototype.replayQueue=function(){return"offline"===this.state||this.autoReplay||(d.call(this),f.call(this)),this},Kuzzle.prototype.setHeaders=function(a,b){var c=this;if("object"!=typeof a||Array.isArray(a))throw new Error("Expected a content object, received a "+typeof a);return b?c.headers=a:Object.keys(a).forEach(function(b){c.headers[b]=a[b]}),c},Kuzzle.prototype.startQueuing=function(){return"offline"!==this.state||this.autoQueue||(this.queuing=!0),this},Kuzzle.prototype.stopQueuing=function(){return"offline"!==this.state||this.autoQueue||(this.queuing=!1),this}},{"./kuzzleDataCollection":3,"node-uuid":1,"socket.io-client":void 0}],3:[function(a,b,c){function d(a,b){return Object.defineProperties(this,{collection:{value:b,enumerable:!0},kuzzle:{value:a,enumerable:!0},headers:{value:JSON.parse(JSON.stringify(a.headers)),enumerable:!0,writable:!0}}),this.kuzzle.bluebird?this.kuzzle.bluebird.promisifyAll(this,{suffix:"Promise",filter:function(a,b,c,d){var e=["publishMessage","setHeaders","subscribe"];return d&&-1===e.indexOf(a)}}):this}var e=a("./kuzzleDocument"),f=a("./kuzzleDataMapping"),g=a("./kuzzleRoom");d.prototype.advancedSearch=function(a,b,c){var d,e=this;return c||"function"!=typeof b||(c=b,b=null),e.kuzzle.callbackRequired("KuzzleDataCollection.advancedSearch",c),d=e.kuzzle.addHeaders({body:a},this.headers),e.kuzzle.query(this.collection,"read","search",d,b,function(a,b){var d=[];return a?c(a):(b.hits.hits.forEach(function(a){d.push(e.documentFactory(a._id,a))}),void c(null,{total:b.hits.total,documents:d}))}),this},d.prototype.count=function(a,b,c){var d;return c||"function"!=typeof b||(c=b,b=null),this.kuzzle.callbackRequired("KuzzleDataCollection.count",c),d=this.kuzzle.addHeaders({body:a},this.headers),this.kuzzle.query(this.collection,"read","count",d,b,function(a,b){return a?c(a):void c(null,b.count)}),this},d.prototype.create=function(a,b){var c={};return b||"function"!=typeof a||(b=a,a=null),c=this.kuzzle.addHeaders(c,this.headers),this.kuzzle.query(this.collection,"write","createCollection",c,a,b),this},d.prototype.createDocument=function(a,b,c,d){var f=this,g={},h="create";return"string"!=typeof a&&(d=c,c=b,b=a,a=null),d||"function"!=typeof c||(d=c,c=null),b instanceof e?g=b.toJSON():g.body=b,c&&(h=c.updateIfExist?"createOrUpdate":"create"),a&&(g._id=a),g.persist=!0,g=f.kuzzle.addHeaders(g,f.headers),d?f.kuzzle.query(this.collection,"write",h,g,c,function(a,b){return a?d(a):void d(null,f.documentFactory(b._id,b))}):this.kuzzle.query(this.collection,"write",h,g,c),this},d.prototype["delete"]=function(a,b){var c={};return b||"function"!=typeof a||(b=a,a=null),c=this.kuzzle.addHeaders(c,this.headers),this.kuzzle.query(this.collection,"admin","deleteCollection",c,a,b),this},d.prototype.deleteDocument=function(a,b,c){var d,e={};return"string"==typeof a?(e._id=a,d="delete"):(e.body=a,d="deleteByQuery"),c||"function"!=typeof b||(c=b,b=null),e=this.kuzzle.addHeaders(e,this.headers),c?this.kuzzle.query(this.collection,"write",d,e,b,function(a,b){return a?c(a):void("delete"===d?c(null,[e._id]):c(null,b.ids))}):this.kuzzle.query(this.collection,"write",d,e,b),this},d.prototype.fetchDocument=function(a,b,c){var d={_id:a},e=this;return c||"function"!=typeof b||(c=b,b=null),e.kuzzle.callbackRequired("KuzzleDataCollection.fetch",c),d=e.kuzzle.addHeaders(d,this.headers),e.kuzzle.query(this.collection,"read","get",d,b,function(a,b){return a?c(a):void c(null,e.documentFactory(b._id,b))}),this},d.prototype.fetchAllDocuments=function(a,b){return b||"function"!=typeof a||(b=a,a=null),this.kuzzle.callbackRequired("KuzzleDataCollection.fetchAll",b),this.advancedSearch({},a,b),this},d.prototype.getMapping=function(a,b){var c;return b||"function"!=typeof a||(b=a,a=null),this.kuzzle.callbackRequired("KuzzleDataCollection.getMapping",b),c=new f(this),c.refresh(a,b),this},d.prototype.publishMessage=function(a,b){var c={};return a instanceof e?c=a.toJSON():c.body=a,c.persist=!1,c=this.kuzzle.addHeaders(c,this.headers),this.kuzzle.query(this.collection,"write","publish",c,b),this},d.prototype.putMapping=function(a,b,c){var d;return c||"function"!=typeof b||(c=b,b=null),d=new f(this,a),d.apply(b,c),this},d.prototype.replaceDocument=function(a,b,c,d){var e=this,f={_id:a,body:b};return d||"function"!=typeof c||(d=c,c=null),f=e.kuzzle.addHeaders(f,this.headers),d?e.kuzzle.query(this.collection,"write","createOrUpdate",f,c,function(a,b){return a?d(a):void d(null,e.documentFactory(b._id,b))}):e.kuzzle.query(this.collection,"write","createOrUpdate",f,c),this},d.prototype.subscribe=function(a,b,c){var d;return c||"function"!=typeof b||(c=b,b=null),this.kuzzle.callbackRequired("KuzzleDataCollection.subscribe",c),d=new g(this,b),d.renew(a,c)},d.prototype.truncate=function(a,b){var c={};return b||"function"!=typeof a||(b=a,a=null),c=this.kuzzle.addHeaders(c,this.headers),this.kuzzle.query(this.collection,"admin","truncateCollection",c,a,b),this},d.prototype.updateDocument=function(a,b,c,d){var f={_id:a,body:b},g=this;return d||"function"!=typeof c||(d=c,c=null),f=g.kuzzle.addHeaders(f,this.headers),d?g.kuzzle.query(this.collection,"write","update",f,c,function(a,b){var c;return a?d(a):(c=new e(g,b._id),void d(null,c))}):g.kuzzle.query(this.collection,"write","update",f,c),g},d.prototype.documentFactory=function(a,b){var c=b._source?new e(this,a,b._source):new e(this,a,b);return c},d.prototype.roomFactory=function(a){return new g(this,a)},d.prototype.dataMappingFactory=function(a){return new f(this,a)},d.prototype.setHeaders=function(a,b){return this.kuzzle.setHeaders.call(this,a,b),this},b.exports=d},{"./kuzzleDataMapping":4,"./kuzzleDocument":5,"./kuzzleRoom":6}],4:[function(a,b,c){function d(a,b){return Object.defineProperties(this,{collection:{value:a.collection,eunmerable:!0},kuzzle:{value:a.kuzzle,enumerable:!0},headers:{value:JSON.parse(JSON.stringify(a.headers)),enumerable:!0,writable:!0},mapping:{value:b||{},enumerable:!0,writable:!0}}),this.kuzzle.bluebird?this.kuzzle.bluebird.promisifyAll(this,{suffix:"Promise",filter:function(a,b,c,d){var e=["set","setHeaders"];return d&&-1===e.indexOf(a)}}):this}d.prototype.apply=function(a,b){var c=this,d=this.kuzzle.addHeaders({body:{properties:this.mapping}},this.headers);return b||"function"!=typeof a||(b=a,a=null),c.kuzzle.query(this.collection,"admin","putMapping",d,a,function(a,d){return a?b?b(a):!1:(c.mapping=d._source.properties,void(b&&b(null,c)))}),this},d.prototype.refresh=function(a,b){var c=this,d=this.kuzzle.addHeaders({},this.headers);return b||"function"!=typeof a||(b=a,a=null),this.kuzzle.query(this.collection,"admin","getMapping",d,a,function(a,d){return a?b?b(a):!1:(c.mapping=d.mainindex.mappings[c.collection].properties,void(b&&b(null,c)))}),this},d.prototype.set=function(a,b){return this.mapping[a]=b,this},d.prototype.setHeaders=function(a,b){return this.kuzzle.setHeaders.call(this,a,b),this},b.exports=d},{}],5:[function(a,b,c){function d(a,b,c){return Object.defineProperties(this,{queue:{value:[],writable:!0},refreshing:{value:!1,writable:!0},collection:{value:a.collection,enumerable:!0},dataCollection:{value:a,enumerable:!0},kuzzle:{value:a.kuzzle,enumerable:!0},id:{value:void 0,enumerable:!0,writable:!0},content:{value:{},writable:!0,enumerable:!0},headers:{value:JSON.parse(JSON.stringify(a.headers)),enumerable:!0,writable:!0},version:{value:void 0,enumerable:!0,writable:!0}}),!c&&b&&"object"==typeof b&&(c=b,b=null),c&&(c._version&&(this.version=c._version,delete c._version),this.setContent(c,!0)),b&&(Object.defineProperty(this,"id",{value:b,enumerable:!0}),c||this.refresh()),this.kuzzle.bluebird?this.kuzzle.bluebird.promisifyAll(this,{suffix:"Promise",filter:function(a,b,c,d){var e=["delete","refresh","save"];return d&&-1!==e.indexOf(a)}}):this}function e(){for(var a;this.queue.length>0;)a=this.queue.shift(),this[a.action].apply(this,a.args)}d.prototype.toJSON=function(){var a={};return this.id&&(a._id=this.id),a.body=this.content,a._version=this.version,a=this.kuzzle.addHeaders(a,this.headers)},d.prototype.toString=function(){return JSON.stringify(this.toJSON())},d.prototype["delete"]=function(a,b){var c=this;if(b||"function"!=typeof a||(b=a,a=null),this.refreshing)return this.queue.push({action:"delete",args:[a,b]}),this;if(!this.id)throw new Error("KuzzleDocument.delete: cannot delete a document without a document ID");return b?this.kuzzle.query(this.collection,"write","delete",this.toJSON(),a,function(a){return a?b(a):void b(null,c)}):this.kuzzle.query(this.collection,"write","delete",this.toJSON(),a),this},d.prototype.refresh=function(a,b){var c=this;if(b||"function"!=typeof a||(b=a,a=null),this.refreshing)return this.queue.push({action:"refresh",args:[a,b]}),this;if(!c.id)throw new Error("KuzzleDocument.refresh: cannot retrieve a document if no ID has been provided");return c.refreshing=!0,c.kuzzle.query(c.collection,"read","get",{_id:c.id},a,function(a,d){return a?(c.refreshing=!1,c.queue=[],b?b(a):!1):(c.version=d._version,c.content=d._source,b&&b(null,c),c.refreshing=!1,void e.call(c))}),this},d.prototype.save=function(a,b){var c=this.toJSON(),d=this;return a&&void 0===b&&"function"==typeof a&&(b=a,a=null),d.refreshing?(d.queue.push({action:"save",args:[a,b]}),d):(c.persist=!0,d.kuzzle.query(this.collection,"write","createOrUpdate",c,a,function(a,c){return a?b?b(a):!1:(d.id=c._id,d.version=c._version,void(b&&b(null,d)))}),d)},d.prototype.publish=function(a){var b=this.toJSON();return this.refreshing?(this.queue.push({action:"publish",args:[a]}),this):(b.persist=!1,this.kuzzle.query(this.collection,"write","publish",b,a),this)},d.prototype.setContent=function(a,b){var c=this;return this.refreshing?(this.queue.push({action:"setContent",args:[a,b]}),this):(b?this.content=a:Object.keys(a).forEach(function(b){c.content[b]=a[b]}),this)},d.prototype.subscribe=function(a,b){var c;if(a&&!b&&"function"==typeof a&&(b=a,a=null),this.kuzzle.callbackRequired("KuzzleDocument.subscribe",b),!this.id)throw new Error("KuzzleDocument.subscribe: cannot subscribe to a document if no ID has been provided");return c={ids:{values:[this.id]}},this.dataCollection.subscribe(c,a,b)},d.prototype.setHeaders=function(a,b){return this.kuzzle.setHeaders.call(this,a,b),this},b.exports=d},{}],6:[function(a,b,c){function d(a,b){return Object.defineProperties(this,{callback:{value:null,writable:!0},channel:{value:null,writable:!0},id:{value:g.v4()},notifier:{value:null,writable:!0},queue:{value:[],writable:!0},scope:{value:b&&b.scope?b.scope:"all"},state:{value:b&&b.state?b.state:"done"},subscribing:{value:!1,writable:!0},users:{value:b&&b.users?b.users:"none"},collection:{value:a.collection,enumerable:!0},kuzzle:{value:a.kuzzle,enumerable:!0},filters:{value:null,enumerable:!0,writable:!0},headers:{value:JSON.parse(JSON.stringify(a.headers)),enumerable:!0,writable:!0},metadata:{value:b&&b.metadata?b.metadata:{},enumerable:!0,writable:!0},roomId:{value:null,enumerable:!0,writable:!0},subscribeToSelf:{value:b&&"boolean"==typeof b.subscribeToSelf?b.subscribeToSelf:!0,enumerable:!0,writable:!0}}),this.kuzzle.bluebird?this.kuzzle.bluebird.promisifyAll(this,{suffix:"Promise",filter:function(a,b,c,d){var e=["count"];return d&&-1!==e.indexOf(a)}}):this}function e(a){return a.error?this.callback(a.error):void(this.kuzzle.requestHistory[a.result.requestId]?(this.subscribeToSelf&&this.callback(null,a.result),delete this.kuzzle.requestHistory[a.result.requestId]):this.callback(null,a.result))}function f(){for(var a;this.queue.length>0;)a=this.queue.shift(),this[a.action].apply(this,a.args)}var g=a("node-uuid");d.prototype.count=function(a){var b;return this.kuzzle.callbackRequired("KuzzleRoom.count",a),b=this.kuzzle.addHeaders({body:{roomId:this.roomId}},this.headers),this.subscribing?(this.queue.push({action:"count",args:[a]}),this):(this.kuzzle.query(this.collection,"subscribe","count",b,function(b,c){return b?a(b):void a(null,c.count)}),this)},d.prototype.renew=function(a,b){var c={scope:this.scope,state:this.state,users:this.users},d=this;return!b&&a&&"function"==typeof a&&(b=a,a=null),this.subscribing?(this.queue.push({action:"renew",args:[a,b]}),this):(this.kuzzle.callbackRequired("KuzzleRoom.renew",b),this.unsubscribe(),this.roomId=null,this.subscribing=!0,this.callback=b,this.kuzzle.subscriptions.pending[d.id]=d,a&&(this.filters=a),c.body=this.filters,c=this.kuzzle.addHeaders(c,this.headers),d.kuzzle.query(this.collection,"subscribe","on",c,{metadata:this.metadata},function(a,b){if(delete d.kuzzle.subscriptions.pending[d.id],d.subscribing=!1,a)throw d.queue=[],new Error("Error during Kuzzle subscription: "+a.message);d.roomId=b.roomId,d.channel=b.channel,d.kuzzle.subscriptions[d.roomId]||(d.kuzzle.subscriptions[d.roomId]={}),d.kuzzle.subscriptions[d.roomId][d.id]=d,d.notifier=e.bind(d),d.kuzzle.socket.on(d.channel,d.notifier),f.call(d)}),this)},d.prototype.unsubscribe=function(){var a,b=this,c=b.roomId;return b.subscribing?(b.queue.push({action:"unsubscribe",args:[]}),b):(c&&(b.kuzzle.socket.off(b.channel,this.notifier),1===Object.keys(b.kuzzle.subscriptions[c]).length?(delete b.kuzzle.subscriptions[c],0===Object.keys(b.kuzzle.subscriptions.pending).length?b.kuzzle.query(this.collection,"subscribe","off",{body:{roomId:c}}):a=setInterval(function(){0===Object.keys(b.kuzzle.subscriptions.pending).length&&(b.kuzzle.subscriptions[c]||b.kuzzle.query(b.collection,"subscribe","off",{body:{roomId:c}}),clearInterval(a))},100)):delete b.kuzzle.subscriptions[c][b.id],b.roomId=null),b)},d.prototype.setHeaders=function(a,b){return this.kuzzle.setHeaders.call(this,a,b),this},b.exports=d},{"node-uuid":1}]},{},[2]); //# sourceMappingURL=kuzzle.min.map \ No newline at end of file diff --git a/dist/kuzzle.min.map b/dist/kuzzle.min.map index 21df24a7d..37b913790 100644 --- a/dist/kuzzle.min.map +++ b/dist/kuzzle.min.map @@ -1 +1 @@ -{"version":3,"sources":["kuzzle.js"],"names":["e","t","n","r","s","o","u","a","require","i","f","Error","code","l","exports","call","length",1,"module","parse","buf","offset","ii","toLowerCase","replace","oct","_hexToByte","unparse","bth","_byteToHex","v1","options","b","clockseq","_clockseq","msecs","Date","getTime","nsecs","_lastNSecs","dt","_lastMSecs","tl","tmh","node","_nodeId","v4","BufferClass","rnds","random","rng","_rng","_global","this","_rb","randomBytes","crypto","getRandomValues","_rnds8","Uint8Array","_rnds","Array","Math","Buffer","toString","substr","_seedBytes","uuid","define","amd","_previousRoot","noConflict",2,"cleanQueue","self","now","lastDocumentIndex","queueTTL","offlineQueue","forEach","query","index","ts","splice","queueMaxSize","emitRequest","request","cb","socket","once","requestId","response","error","result","emit","requestHistory","Object","keys","key","dequeue","shift","setTimeout","max","replayInterval","queuing","KuzzleDataCollection","Kuzzle","url","defineProperties","collections","value","writable","eventListeners","connected","disconnected","reconnected","io","state","subscriptions","pending","autoReconnect","enumerable","reconnectionDelay","autoQueue","autoReplay","autoResubscribe","headers","metadata","queueFilter","window","opt","hasOwnProperty","getOwnPropertyDescriptor","offlineMode","defineProperty","header","errorMessagePrefix","callback","connect","bluebird","promisifyAll","suffix","filter","name","func","target","passes","whitelist","indexOf","prototype","reconnection","force new connection","roomId","subscriptionId","subscription","renew","listener","fn","on","logout","addListener","event","listenerId","knownEvents","listenerType","isValid","push","id","getAllStatistics","callbackRequired","err","res","statistics","getStatistics","timestamp","queryCB","arguments","body","startTime","dataCollectionFactory","collection","flushQueue","listCollections","close","controller","action","attr","object","meta","queuable","addHeaders","removeAllListeners","eventName","removeListener","replayQueue","setHeaders","content","isArray","startQueuing","stopQueuing","./kuzzleDataCollection","node-uuid","socket.io-client","undefined",3,"kuzzle","JSON","stringify","blacklist","KuzzleDocument","KuzzleDataMapping","KuzzleRoom","advancedSearch","filters","documents","hits","doc","documentFactory","_id","total","count","create","data","createDocument","document","toJSON","updateIfExist","persist","deleteDocument","arg","ids","fetchDocument","documentId","fetchAllDocuments","getMapping","kuzzleMapping","refresh","publishMessage","putMapping","mapping","dataMapping","apply","replaceDocument","subscribe","room","truncate","updateDocument","_source","roomFactory","dataMappingFactory","./kuzzleDataMapping","./kuzzleDocument","./kuzzleRoom",4,"kuzzleDataCollection","eunmerable","properties","mainindex","mappings","set","field",5,"queue","refreshing","dataCollection","version","_version","setContent","element","args","save","publish","values",6,"channel","notifier","scope","subscribing","users","subscribeToSelf","notificationCallback","subscribeQuery","unsubscribe","message","bind","interval","off","setInterval","clearInterval"],"mappings":";CAAA,QAAUA,GAAEC,EAAEC,EAAEC,GAAG,QAASC,GAAEC,EAAEC,GAAG,IAAIJ,EAAEG,GAAG,CAAC,IAAIJ,EAAEI,GAAG,CAAC,GAAIE,GAAkB,kBAATC,UAAqBA,OAAQ,KAAIF,GAAGC,EAAE,MAAOA,GAAEF,GAAE,EAAI,IAAGI,EAAE,MAAOA,GAAEJ,GAAE,EAAI,IAAIK,G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AS5K,GACpC6B,MAuCTnC,EAAOJ,QAAUqM,IAEdV,YAAY,SAAS","file":"kuzzle.min.js"} \ No newline at end of file +{"version":3,"sources":["kuzzle.js"],"names":["e","t","n","r","s","o","u","a","require","i","f","Error","code","l","exports","call","length",1,"module","_window","setupBrowser","_crypto","crypto","msCrypto","_rng","getRandomValues","_rnds8","Uint8Array","_whatwgRNG","_rnds","Array","_mathRNG","Math","random","console","warn","setupNode","_rb","randomBytes","_nodeRNG","parse","buf","offset","ii","toLowerCase","replace","oct","_hexToByte","unparse","bth","_byteToHex","v1","options","b","clockseq","_clockseq","msecs","Date","getTime","nsecs","_lastNSecs","dt","_lastMSecs","tl","tmh","node","_nodeId","v4","BufferClass","rnds","rng","_previousRoot","Buffer","toString","substr","_seedBytes","uuid","define","amd","noConflict","window",2,"cleanQueue","self","this","now","lastDocumentIndex","queueTTL","offlineQueue","forEach","query","index","ts","splice","queueMaxSize","emitRequest","request","cb","socket","once","requestId","response","error","result","emit","requestHistory","Object","keys","key","dequeue","shift","setTimeout","max","replayInterval","queuing","KuzzleDataCollection","Kuzzle","url","defineProperties","collections","value","writable","connectCB","eventListeners","connected","disconnected","reconnected","io","state","subscriptions","pending","autoReconnect","enumerable","reconnectionDelay","autoQueue","autoReplay","autoResubscribe","headers","metadata","queueFilter","opt","hasOwnProperty","getOwnPropertyDescriptor","offlineMode","defineProperty","header","errorMessagePrefix","callback","connect","bluebird","promisifyAll","suffix","filter","name","func","target","passes","whitelist","indexOf","prototype","reconnection","force new connection","roomId","subscriptionId","subscription","renew","listener","fn","on","logout","addListener","event","listenerId","knownEvents","listenerType","isValid","push","id","getAllStatistics","callbackRequired","err","res","statistics","getStatistics","timestamp","queryCB","arguments","body","startTime","dataCollectionFactory","collection","flushQueue","listCollections","collectionType","type","close","controller","action","attr","object","meta","queuable","addHeaders","removeAllListeners","eventName","removeListener","replayQueue","setHeaders","content","isArray","startQueuing","stopQueuing","./kuzzleDataCollection","node-uuid","socket.io-client","undefined",3,"kuzzle","JSON","stringify","blacklist","KuzzleDocument","KuzzleDataMapping","KuzzleRoom","advancedSearch","filters","documents","hits","doc","documentFactory","_id","total","count","create","data","createDocument","document","toJSON","updateIfExist","persist","deleteDocument","arg","ids","fetchDocument","documentId","fetchAllDocuments","getMapping","kuzzleMapping","refresh","publishMessage","putMapping","mapping","dataMapping","apply","replaceDocument","subscribe","room","truncate","updateDocument","_source","roomFactory","dataMappingFactory","./kuzzleDataMapping","./kuzzleDocument","./kuzzleRoom",4,"kuzzleDataCollection","eunmerable","properties","mainindex","mappings","set","field",5,"queue","refreshing","dataCollection","version","_version","setContent","element","args","save","publish","values",6,"channel","notifier","scope","subscribing","users","subscribeToSelf","notificationCallback","subscribeQuery","unsubscribe","message","bind","interval","off","setInterval","clearInterval"],"mappings":";CAAA,QAAUA,GAAEC,EAAEC,EAAEC,GAAG,QAASC,GAAEC,EAAEC,GAAG,IAAIJ,EAAEG,GAAG,CAAC,IAAIJ,EAAEI,GAAG,CAAC,GAAIE,GAAkB,kBAATC,UAAqBA,OAAQ,KAAIF,GAAGC,EAAE,MAAOA,GAAEF,GAAE,EAAI,IAAGI,EAAE,MAAOA,GAAEJ,GAAE,EAAI,IAAIK,GAAE,GAAIC,OAAM,uBAAuBN,EAAE,IAAK,MAAMK,GAAEE,KAAK,mBAAmBF,EAAE,GAAIG,GAAEX,EAAEG,IAAIS,WAAYb,GAAEI,GAAG,GAAGU,KAAKF,EAAEC,QAAQ,SAASd,GAAG,GAAIE,GAAED,EAAEI,GAAG,GAAGL,EAAG,OAAOI,GAAEF,EAAEA,EAAEF,IAAIa,EAAEA,EAAEC,QAAQd,EAAEC,EAAEC,EAAEC,GAAG,MAAOD,GAAEG,GAAGS,QAAkD,IAAI,GAA1CL,GAAkB,kBAATD,UAAqBA,QAAgBH,EAAE,EAAEA,EAAEF,EAAEa,OAAOX,IAAID,EAAED,EAAEE,GAAI,OAAOD,KAAKa,GAAG,SAAST,EAAQU,EAAOJ,IAOvd,SAAUK,GACR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AAS","file":"kuzzle.min.js"} \ No newline at end of file diff --git a/package.json b/package.json index a0ab217ed..3cacd4088 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "kuzzle-sdk", - "version": "1.0.9", + "version": "1.1.0", "description": "Official Javascript SDK for Kuzzle", "author": "The Kuzzle Team ", "repository": { diff --git a/src/kuzzle.js b/src/kuzzle.js index 5f600f089..69f1ca88d 100644 --- a/src/kuzzle.js +++ b/src/kuzzle.js @@ -14,7 +14,7 @@ var * Kuzzle object constructor. * @param url - URL to the Kuzzle instance * @param [options] - Connection options - * @param {Kuzzle~constructorCallback} [cb] - Handles connection response + * @param {responseCallback} [cb] - Handles connection response * @constructor */ module.exports = Kuzzle = function (url, options, cb) { @@ -39,6 +39,9 @@ module.exports = Kuzzle = function (url, options, cb) { value: {}, writable: true }, + connectCB: { + value: cb + }, eventListeners: { value: { connected: [], @@ -219,7 +222,7 @@ module.exports = Kuzzle = function (url, options, cb) { if (!options || !options.connect || options.connect === 'auto') { - this.connect(cb); + this.connect(); } else { this.state = 'ready'; } @@ -228,7 +231,7 @@ module.exports = Kuzzle = function (url, options, cb) { return this.bluebird.promisifyAll(this, { suffix: 'Promise', filter: function (name, func, target, passes) { - var whitelist = ['connect', 'getAllStatistics', 'getStatistics', 'listCollections', 'now', 'query']; + var whitelist = ['getAllStatistics', 'getStatistics', 'listCollections', 'now', 'query']; return passes && whitelist.indexOf(name) !== -1; } @@ -241,15 +244,14 @@ module.exports = Kuzzle = function (url, options, cb) { /** * Connects to a Kuzzle instance using the provided URL. - * @param {responseCallback} [cb] * @returns {Object} this */ -Kuzzle.prototype.connect = function (cb) { +Kuzzle.prototype.connect = function () { var self = this; if (['initializing', 'ready', 'loggedOff', 'error', 'offline'].indexOf(this.state) === -1) { - if (cb) { - cb(null, self); + if (self.connectCB) { + self.connectCB(null, self); } return self; } @@ -278,8 +280,8 @@ Kuzzle.prototype.connect = function (cb) { listener.fn(); }); - if (cb) { - cb(null, self); + if (self.connectCB) { + self.connectCB(null, self); } }); @@ -290,8 +292,8 @@ Kuzzle.prototype.connect = function (cb) { listener.fn(); }); - if (cb) { - cb(error); + if (self.connectCB) { + self.connectCB(error); } }); @@ -560,6 +562,8 @@ Kuzzle.prototype.flushQueue = function () { * @returns {object} this */ Kuzzle.prototype.listCollections = function (options, cb) { + var collectionType = 'all'; + if (!cb && typeof options === 'function') { cb = options; options = null; @@ -567,7 +571,11 @@ Kuzzle.prototype.listCollections = function (options, cb) { this.callbackRequired('Kuzzle.listCollections', cb); - this.query(null, 'read', 'listCollections', {}, options, function (err, res) { + if (options && options.type) { + collectionType = options.type; + } + + this.query(null, 'read', 'listCollections', {body: {type: collectionType}}, options, function (err, res) { if (err) { return cb(err); } diff --git a/test/kuzzle/constructor.test.js b/test/kuzzle/constructor.test.js index cf1e4e70d..132a5547e 100644 --- a/test/kuzzle/constructor.test.js +++ b/test/kuzzle/constructor.test.js @@ -167,7 +167,7 @@ describe('Kuzzle constructor', () => { kuzzle = new Kuzzle('nowhere'); should.not.exist(kuzzle.addListenerPromise); - should.exist(kuzzle.connectPromise); + should.not.exist(kuzzle.connectPromise); should.not.exist(kuzzle.dataCollectionFactoryPromise); should.not.exist(kuzzle.flushQueuePromise); should.exist(kuzzle.getAllStatisticsPromise); @@ -205,7 +205,7 @@ describe('Kuzzle constructor', () => { Kuzzle = proxyquire(kuzzleSource, {'socket.io-client' : iostub}); }); - it('should return immediately if not initializing or logged off', function (done) { + it('should return immediately if already connected', function (done) { var kuzzle; this.timeout(200); @@ -216,18 +216,37 @@ describe('Kuzzle constructor', () => { } }); - kuzzle = new Kuzzle('nowhere', {connect: 'manual'}); - kuzzle.state = 'connected'; - kuzzle.connect((err, res) => { + kuzzle = new Kuzzle('nowhere', {connect: 'manual'}, (err, res) => { should(err).be.null(); should(res).be.exactly(kuzzle); should(res.state).be.exactly('connected'); done(); }); + kuzzle.state = 'connected'; + kuzzle.connect(); + }); + + it('should return immediately if trying to reconnect', function (done) { + var kuzzle; + + this.timeout(200); + + Kuzzle = proxyquire(kuzzleSource, { + io: function () { + // does nothing, making the test crash if trying to connect + } + }); + + kuzzle = new Kuzzle('nowhere', {connect: 'manual'}, (err, res) => { + should(err).be.null(); + should(res).be.exactly(kuzzle); + should(res.state).be.exactly('reconnecting'); + done(); + }); + kuzzle.state = 'reconnecting'; - should(kuzzle.connect()).be.exactly(kuzzle); - should(kuzzle.state).be.exactly('reconnecting'); + kuzzle.connect(); }); it('should try to connect when the instance is in a not-connected state', function () { @@ -357,16 +376,17 @@ describe('Kuzzle constructor', () => { this.timeout(500); - kuzzle = new KuzzleRewired('nowhere', {connect: 'manual', autoReplay: false, autoQueue: false}); - kuzzle.io = iostub; - - kuzzle.connect((err, res) => { + kuzzle = new KuzzleRewired('nowhere', {connect: 'manual', autoReplay: false, autoQueue: false}, () => { should(kuzzle.state).be.exactly('connected'); should(dequeued).be.true(); kuzzle.socket.removeAllListeners(); revert(); done(); }); + + kuzzle.io = iostub; + + kuzzle.connect(); }); }); diff --git a/test/kuzzle/methods.test.js b/test/kuzzle/methods.test.js index 91226895f..91ea8e4c6 100644 --- a/test/kuzzle/methods.test.js +++ b/test/kuzzle/methods.test.js @@ -189,7 +189,8 @@ describe('Kuzzle methods', function () { result = {collections: []}; expectedQuery = { controller: 'read', - action: 'listCollections' + action: 'listCollections', + body: {type: 'all'} }; }); @@ -225,6 +226,11 @@ describe('Kuzzle methods', function () { done(); }); }); + + it('should handle options correctly', function (done) { + expectedQuery.body.type = 'foobar'; + kuzzle.listCollections({type: 'foobar'}, () => done()); + }); }); describe('#logout', function () {