From 7e6fa479ad7af0a4cb3108c28cd2964e0a147a74 Mon Sep 17 00:00:00 2001 From: Spencer Alger Date: Tue, 5 Nov 2013 09:57:56 -0700 Subject: [PATCH] Added the browser based test suite, have it running automatically via PhantomJS with grunt, all tests are passing except one, which requires PhantomJS send a body with a DELETE request --- Gruntfile.js | 166 +- dist/elasticsearch.angular.js | 248 +- dist/elasticsearch.angular.min.js | 9 +- dist/elasticsearch.js | 265 +- dist/elasticsearch.min.js | 9 +- package.json | 44 +- scripts/generate/js_api/actions.js | 3 - scripts/generate/logs/index.js | 1 - scripts/generate/yaml_tests/index.js | 24 +- src/lib/api.js | 117 +- src/lib/client_action.js | 16 +- src/lib/connectors/angular.js | 10 +- src/lib/connectors/http.js | 65 +- src/lib/connectors/jquery.js | 6 +- src/lib/connectors/xhr.js | 27 +- src/lib/errors.js | 6 +- src/lib/host.js | 6 +- src/lib/log.js | 15 +- src/lib/loggers/console.js | 13 +- src/lib/transport_request.js | 2 +- src/lib/utils.js | 19 +- test/.jshintrc | 3 +- test/browser_integration/index.html | 22 + test/browser_integration/server.js | 146 + test/browser_integration/yaml_tests.js | 45998 ++++++++++++++++ test/integration/yaml_suite/argv.js | 20 + test/integration/yaml_suite/client_manager.js | 92 + test/integration/yaml_suite/index.js | 617 +- test/integration/yaml_suite/server.js | 23 +- test/integration/yaml_suite/yaml_doc.js | 439 + test/integration/yaml_suite/yaml_file.js | 43 + test/integration/yaml_suite/yaml_tests.json | 10526 ++++ test/unit/http.connection.test.js | 39 + test/unit/node_http_transport.test.js! | 23 - 34 files changed, 58054 insertions(+), 1008 deletions(-) create mode 100644 test/browser_integration/index.html create mode 100644 test/browser_integration/server.js create mode 100644 test/browser_integration/yaml_tests.js create mode 100644 test/integration/yaml_suite/argv.js create mode 100644 test/integration/yaml_suite/client_manager.js create mode 100644 test/integration/yaml_suite/yaml_doc.js create mode 100644 test/integration/yaml_suite/yaml_file.js create mode 100644 test/integration/yaml_suite/yaml_tests.json create mode 100644 test/unit/http.connection.test.js delete mode 100644 test/unit/node_http_transport.test.js! diff --git a/Gruntfile.js b/Gruntfile.js index 573139131..a24018657 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -21,7 +21,8 @@ module.exports = function (grunt) { '<%= grunt.template.today("yyyy-mm-dd") %>\n' + '<%= pkg.homepage ? " * " + pkg.homepage + "\\n" : "" %>' + ' * Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>;' + - ' Licensed <%= pkg.license %> */\n\n' + ' Licensed <%= pkg.license %> */\n' + + ' // built using browserify\n\n' }, clean: { dist: { @@ -48,18 +49,11 @@ module.exports = function (grunt) { src: [ 'src/**/*.js', 'scripts/**/*.js', + 'test/**/*.js -test/browser_integration/yaml_tests.js', 'Gruntfile.js' ], options: { - jshintrc: '.jshintrc' - } - }, - tests: { - src: [ - 'test/**/*.js' - ], - options: { - jshintrc: 'test/.jshintrc' + jshintrc: true } } }, @@ -85,37 +79,66 @@ module.exports = function (grunt) { 'scripts/generate/js_api' ] }, - yaml_suite: { + yaml_tests: { cmd: 'node', args: [ 'scripts/generate/yaml_tests' ] } }, + start: { + integration_server: { + cmd: 'node', + args: [ + 'test/browser_integration/server.js' + ] + } + }, browserify: { - generic: { + client: { files: { '<%= distDir %>/elasticsearch.js': 'src/elasticsearch.js' }, options: { - standalone: 'true', + standalone: 'elasticsearch', ignore: _.union(sharedBrowserfyExclusions, [ 'src/lib/connectors/jquery.js', 'src/lib/connectors/angular.js' ]) } }, - angular: { + angular_client: { files: { '<%= distDir %>/elasticsearch.angular.js': ['src/elasticsearch.angular.js'] }, options: { - standalone: 'true', + standalone: 'elasticsearch', ignore: _.union(sharedBrowserfyExclusions, [ 'src/lib/connectors/jquery.js', 'src/lib/connectors/xhr.js' ]) } + }, + yaml_suite: { + files: { + 'test/browser_integration/yaml_tests.js': ['test/integration/yaml_suite/index.js'] + }, + options: { + external: [ + 'optimist' + ] + } + } + }, + concat: { + dist_banners: { + files: { + '<%= distDir %>/elasticsearch.js': ['<%= distDir %>/elasticsearch.js'], + '<%= distDir %>/elasticsearch.angular.js': ['<%= distDir %>/elasticsearch.angular.js'] + }, + options: { + banner: '<%= meta.banner %>' + } } }, uglify: { @@ -134,68 +157,48 @@ module.exports = function (grunt) { } } } - }//, - // docular: { - // groups: [ - // { - // groupTitle: 'Node', - // groupId: 'example', - // groupIcon: 'icon-beer', - // sections: [ - // { - // id: "client", - // title: "Client", - // scripts: [ - // "src/lib/client.js" - // ], - // docs: [], - // rank : {} - // } - // ] - // } - // ], - // } - // , - // yuidoc: { - // compile: { - // name: '<%= pkg.name %>', - // description: '<%= pkg.description %>', - // version: '<%= pkg.version %>', - // url: '<%= pkg.homepage %>', - // logo: '<%= pkg.logo %>', - // options: { - // paths: 'src', - // themedir: '../yuidoc-bootstrap-theme', - // helpers: [ - // '../yuidoc-bootstrap-theme/helpers/helpers.js' - // ], - // outdir: 'docs' - // } - // } - // } + }, + mocha: { + yaml_suite: { + options: { + // log: true, + run: true, + urls: [ 'http://localhost:8888' ], + timeout: 10e3, + '--web-security': false + } + } + } }); // load plugins - // grunt.loadNpmTasks('grunt-docular'); + grunt.loadNpmTasks('grunt-mocha'); grunt.loadNpmTasks('grunt-browserify'); grunt.loadNpmTasks('grunt-mocha-test'); grunt.loadNpmTasks('grunt-contrib-clean'); grunt.loadNpmTasks('grunt-contrib-watch'); + grunt.loadNpmTasks('grunt-contrib-concat'); grunt.loadNpmTasks('grunt-contrib-uglify'); grunt.loadNpmTasks('grunt-contrib-jshint'); // Default task. grunt.registerTask('default', [ + /*jshint scripturl:true*/ 'jshint', 'mochaTest:unit', - 'generate:yaml_suite', - 'mochaTest:yaml_suite' + 'build', + 'mochaTest:yaml_suite', + 'start:integration_server', + // 'mocha:yaml_suite' -- this will fail because of the way that PhantomJS handle's DELETE requests with body's ]); grunt.registerTask('build', [ 'clean:dist', 'browserify', - 'uglify:dist' + 'uglify:dist', + 'concat:dist_banners', + 'generate:yaml_tests', + 'generate:js_api' ]); grunt.task.registerMultiTask('generate', 'used to generate things', function () { @@ -216,4 +219,51 @@ module.exports = function (grunt) { }); }); + var runningProcs = {}; + + process.on('exit', function () { + _.each(runningProcs, function (proc) { + proc.kill(); + }); + }); + + grunt.task.registerMultiTask('start', 'used to start external processes (like servers)', function () { + var self = this; + + + var proc = require('child_process').spawn( + self.data.cmd, + self.data.args, + { + stdio: ['ignore', 'pipe', 'pipe'] + } + ); + + proc.stdout.on('data', grunt.log.write); + proc.stderr.on('data', function (chunk) { + grunt.log.error(chunk); + proc.kill(); + self.ansyc()(new Error('Error output received')); + clearTimeout(timeoutId); + }); + + runningProcs[self.nameArgs] = proc; + + proc.on('close', function (exitCode) { + delete runningProcs[self.nameArgs]; + }); + + // operates asyncronously to give the processes a moment to start up, not sure if there is a signal for "I'm ready" + var timeoutId = setTimeout(self.async(), 1000); + }); + + grunt.task.registerMultiTask('stop', 'used to stop external processes (like servers)', function () { + var proc = runningProcs[this.nameArgs.replace(/^start:/, 'stop:')]; + if (proc) { + proc.kill(); + } else { + grunt.log.error(this.nameArgs + ' failed to find active process'); + } + }); + }; diff --git a/dist/elasticsearch.angular.js b/dist/elasticsearch.angular.js index acd73b1ff..bd23a9286 100644 --- a/dist/elasticsearch.angular.js +++ b/dist/elasticsearch.angular.js @@ -1,4 +1,9 @@ -!function(e){"object"==typeof exports?module.exports=e():"function"==typeof define&&define.amd?define(e):"undefined"!=typeof window?window.true=e():"undefined"!=typeof global?global.true=e():"undefined"!=typeof self&&(self.true=e())}(function(){var define,module,exports; +/*! elasticsearch-js - v0.0.1 - 2013-11-05 + * https://github.com/elasticsearch/elasticsearch-js + * Copyright (c) 2013 Spencer Alger; Licensed Apache License */ + // built using browserify + +!function(e){"object"==typeof exports?module.exports=e():"function"==typeof define&&define.amd?define(e):"undefined"!=typeof window?window.elasticsearch=e():"undefined"!=typeof global?global.elasticsearch=e():"undefined"!=typeof self&&(self.elasticsearch=e())}(function(){var define,module,exports; return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o/<%=type%>/_mapping/field/<%=field%>', + req: { + index: { + type: 'list' + }, + type: { + type: 'list' + }, + field: { + type: 'list' + } + } + }, + { + fmt: '/<%=index%>/_mapping/field/<%=field%>', + req: { + index: { + type: 'list' + }, + field: { + type: 'list' + } + } + }, + { + fmt: '/_mapping/field/<%=field%>', + req: { + field: { + type: 'list' + } + } + } + ] +}); + + /** * Perform a [indices.getMapping](http://www.elasticsearch.org/guide/reference/api/admin-indices-get-mapping/) request * @@ -13109,9 +13167,9 @@ api.info = ca({ * @param {String} params.preference - Specify the node or shard the operation should be performed on (default: random) * @param {Boolean} params.realtime - Specify whether to perform the operation in realtime or search mode * @param {Boolean} params.refresh - Refresh the shard containing the document before performing the operation - * @param {String|ArrayOfStrings|Boolean} params._source - True or false to return the _source field or not, or a list of fields to return - * @param {String|ArrayOfStrings|Boolean} params._sourceExclude - A list of fields to exclude from the returned _source field - * @param {String|ArrayOfStrings|Boolean} params._sourceInclude - A list of fields to extract and return from the _source field + * @param {String|ArrayOfStrings|Boolean} params.source - True or false to return the _source field or not, or a list of fields to return + * @param {String|ArrayOfStrings|Boolean} params.sourceExclude - A list of fields to exclude from the returned _source field + * @param {String|ArrayOfStrings|Boolean} params.sourceInclude - A list of fields to extract and return from the _source field * @param {String} params.index - The name of the index * @param {String} params.type - The type of the document */ @@ -13133,15 +13191,15 @@ api.mget = ca({ refresh: { type: 'boolean' }, - _source: { + source: { type: 'list', name: '_source' }, - _sourceExclude: { + sourceExclude: { type: 'list', name: '_source_exclude' }, - _sourceInclude: { + sourceInclude: { type: 'list', name: '_source_include' } @@ -13450,10 +13508,9 @@ api.scroll = ca({ * @param {String} params.searchType - Search operation type * @param {Number} params.size - Number of hits to return (default: 10) * @param {String|ArrayOfStrings|Boolean} params.sort - A comma-separated list of : pairs - * @param {String} params.source - The URL-encoded request definition using the Query DSL (instead of using request body) - * @param {String|ArrayOfStrings|Boolean} params._source - True or false to return the _source field or not, or a list of fields to return - * @param {String|ArrayOfStrings|Boolean} params._sourceExclude - A list of fields to exclude from the returned _source field - * @param {String|ArrayOfStrings|Boolean} params._sourceInclude - A list of fields to extract and return from the _source field + * @param {String|ArrayOfStrings|Boolean} params.source - True or false to return the _source field or not, or a list of fields to return + * @param {String|ArrayOfStrings|Boolean} params.sourceExclude - A list of fields to exclude from the returned _source field + * @param {String|ArrayOfStrings|Boolean} params.sourceInclude - A list of fields to extract and return from the _source field * @param {String|ArrayOfStrings|Boolean} params.stats - Specific 'tag' of the request for logging and statistical purposes * @param {String} params.suggestField - Specify which field to use for suggestions * @param {String} [params.suggestMode=missing] - Specify suggest mode @@ -13549,17 +13606,14 @@ api.search = ca({ type: 'list' }, source: { - type: 'string' - }, - _source: { type: 'list', name: '_source' }, - _sourceExclude: { + sourceExclude: { type: 'list', name: '_source_exclude' }, - _sourceInclude: { + sourceInclude: { type: 'list', name: '_source_include' }, @@ -13692,7 +13746,7 @@ api.suggest = ca({ * @param {Date|Number} params.timestamp - Explicit timestamp for the document * @param {Duration} params.ttl - Expiration time for the document * @param {Number} params.version - Explicit version number for concurrency control - * @param {Number} params.versionType - Explicit version number for concurrency control + * @param {String} params.versionType - Specific version type * @param {String} params.id - Document ID * @param {String} params.index - The name of the index * @param {String} params.type - The type of the document @@ -13754,7 +13808,11 @@ api.update = ca({ type: 'number' }, versionType: { - type: 'number', + type: 'enum', + options: [ + 'internal', + 'external' + ], name: 'version_type' } }, @@ -13923,10 +13981,10 @@ var castType = { } }, time: function (param, val, name) { - if (val instanceof Date) { - return val.getTime(); - } else if (_.isNumeric(val)) { + if (typeof val === 'string' || _.isNumeric(val)) { return val; + } else if (val instanceof Date) { + return val.getTime(); } else { throw new TypeError('Invalid ' + name + ': expected some sort of time.'); } @@ -14070,15 +14128,17 @@ function exec(transport, spec, params, cb) { // build a key list on demand spec.paramKeys = _.keys(spec.params); } - var key, param; + var key, param, name; for (i = 0; i < spec.paramKeys.length; i++) { key = spec.paramKeys[i]; param = spec.params[key]; + // param keys don't always match the param name, in those cases it's stored in the param def as "name" + name = param.name || key; try { if (params[key] != null) { - query[key] = castType[param.type] ? castType[param.type](param, params[key], key) : params[key]; - if (param['default'] && query[key] === param['default']) { - delete query[key]; + query[name] = castType[param.type] ? castType[param.type](param, params[key], key) : params[key]; + if (param['default'] && query[name] === param['default']) { + delete query[name]; } } else if (param.required) { throw new TypeError('Missing required parameter ' + key); @@ -14137,6 +14197,11 @@ var defaultClasses = { }; var defaultConfig = { + loggers: [ + { + level: 'warning' + } + ], hosts: [ { host: 'localhost', @@ -14182,24 +14247,28 @@ connectors = _.transform(connectors, function (note, connector, name) { function ClientConfig(config) { _.extend(this, defaultConfig, config); + if (this.log) { + // treat log as an alias for loggers in the config. + this.loggers = this.log; + delete this.log; + } + // validate connectionClass + if (typeof this.connectionClass === 'string') { + this.connectionClass = connectors[_.studlyCase(this.connectionClass)]; + } if (typeof this.connectionClass !== 'function') { - if (typeof connectors[this.connectionClass] === 'function') { - this.connectionClass = connectors[this.connectionClass]; - } else { - throw new TypeError('Invalid connectionClass "' + this.connectionClass + '". ' + + throw new TypeError('Invalid connectionClass "' + this.connectionClass + '". ' + 'Expected a constructor or one of ' + _.keys(connectors).join(', ')); - } } // validate selector + if (typeof this.selector === 'string') { + this.selector = selectors[_.camelCase(this.selector)]; + } if (typeof this.selector !== 'function') { - if (_.has(selectors, this.selector)) { - this.selector = selectors[this.selector]; - } else { - throw new TypeError('Invalid Selector "' + this.selector + '". ' + + throw new TypeError('Invalid Selector "' + this.selector + '". ' + 'Expected a function or one of ' + _.keys(selectors).join(', ')); - } } _.each(defaultClasses, function (DefaultClass, prop) { @@ -14452,7 +14521,7 @@ ConnectionPool.prototype.empty = ConnectionPool.prototype.close; * * @class connections.Angular */ -module.exports = AngularConnection; +module.exports = AngularConnector; var _ = require('../utils'); var ConnectionAbstract = require('../connection'); @@ -14460,12 +14529,12 @@ var ConnectionFault = require('../errors').ConnectionFault; /* global angular */ -function AngularConnection(host, config) { +function AngularConnector(host, config) { ConnectionAbstract.call(this, host, config); } -_.inherits(AngularConnection, ConnectionAbstract); +_.inherits(AngularConnector, ConnectionAbstract); -AngularConnection.prototype.request = function (params, cb) { +AngularConnector.prototype.request = function (params, cb) { var timeoutId; this.$http({ @@ -14483,17 +14552,21 @@ AngularConnection.prototype.request = function (params, cb) { }; // must be overwritten before this connection can be used -AngularConnection.prototype.$http = null; +AngularConnector.prototype.$http = null; },{"../connection":19,"../errors":22,"../utils":33}],22:[function(require,module,exports){ -var _ = require('./utils'), +var process=require("__browserify_process");var _ = require('./utils'), errors = module.exports; function ErrorAbstract(msg, constructor) { this.message = msg; Error.call(this, this.message); - Error.captureStackTrace(this, constructor); + if (process.browser) { + this.stack = ''; + } else { + Error.captureStackTrace(this, constructor); + } } _.inherits(ErrorAbstract, Error); @@ -14598,7 +14671,7 @@ _.each(statusCodes, function (name, status) { errors[status] = StatusCodeError; }); -},{"./utils":33}],23:[function(require,module,exports){ +},{"./utils":33,"__browserify_process":12}],23:[function(require,module,exports){ /** * Class to wrap URLS, formatting them and maintaining their seperate details * @type {[type]} @@ -14688,12 +14761,8 @@ Host.prototype.makeUrl = function (params) { // just stringify the hosts query query = qs.stringify(this.query); } - // prepend the ? if there is actually a valid query string - if (query) { - query = '?' + query; - } - return this.protocol + '://' + this.host + port + path + query; + return this.protocol + '://' + this.host + port + path + (query ? '?' + query : ''); }; },{"./utils":33,"querystring":6,"url":7}],24:[function(require,module,exports){ @@ -14730,7 +14799,7 @@ function Log(config) { this.config = config || {}; var i; - var output = _.isPlainObject(config.log) ? config.log : 'warning'; + var output = config.loggers ? config.loggers : 'warning'; if (_.isString(output) || _.isFinite(output)) { output = [ @@ -14887,7 +14956,7 @@ Log.prototype.addOutput = function (config) { delete config.level; config.levels = levels; - var Logger = loggers[config.type]; + var Logger = loggers[_.studlyCase(config.type)]; if (Logger) { return new Logger(config, this); } else { @@ -14945,7 +15014,7 @@ Log.prototype.info = function (/* ...msg */) { */ Log.prototype.debug = function (/* ...msg */) { if (EventEmitter.listenerCount(this, 'debug')) { - return this.emit('debug', Log.join(arguments) + _.getStackTrace(Log.prototype.debug)); + return this.emit('debug', Log.join(arguments) /*+ _.getStackTrace(Log.prototype.debug)*/); } }; @@ -14963,10 +15032,17 @@ Log.prototype.debug = function (/* ...msg */) { */ Log.prototype.trace = function (method, requestUrl, body, responseBody, responseStatus) { if (EventEmitter.listenerCount(this, 'trace')) { - if (typeof requestUrl === 'object') { - requestUrl = url.format(requestUrl); + if (typeof requestUrl === 'string') { + requestUrl = url.parse(requestUrl, true, true); } - return this.emit('trace', method, requestUrl, body, responseBody, responseStatus); + requestUrl = _.defaults({ + host: 'localhost:9200', + query: _.defaults({ + pretty: true + }, requestUrl.query) + }, requestUrl); + delete requestUrl.auth; + return this.emit('trace', method, url.format(requestUrl), body, responseBody, responseStatus); } }; @@ -15184,10 +15260,9 @@ Console.prototype.setupListeners = function (levels) { */ Console.prototype.onError = _.handler(function (e) { if (console.error && console.trace) { - console.error(e.name === 'Error' ? 'ERROR' : e.name); - console.trace(); + console.error(e.name === 'Error' ? 'ERROR' : e.name, e.stack || e.message); } else { - console.log(e.name === 'Error' ? 'ERROR' : e.name, e.stack); + console.log(e.name === 'Error' ? 'ERROR' : e.name, e.stack || e.message); } }); @@ -15199,7 +15274,7 @@ Console.prototype.onError = _.handler(function (e) { * @param {String} msg - The message to be logged * @return {undefined} */ -Console.prototype.onWarning = console[console.warn ? 'warn' : 'log'].bind(console, 'WARNING'); +Console.prototype.onWarning = _.bindKey(console, console.warn ? 'warn' : 'log', 'WARNING'); /** * Handler for the bridges "info" event @@ -15209,7 +15284,7 @@ Console.prototype.onWarning = console[console.warn ? 'warn' : 'log'].bind(consol * @param {String} msg - The message to be logged * @return {undefined} */ -Console.prototype.onInfo = console[console.info ? 'info' : 'log'].bind(console, 'INFO'); +Console.prototype.onInfo = _.bindKey(console, console.info ? 'info' : 'log', 'INFO'); /** * Handler for the bridges "debug" event @@ -15219,7 +15294,7 @@ Console.prototype.onInfo = console[console.info ? 'info' : 'log'].bind(console, * @param {String} msg - The message to be logged * @return {undefined} */ -Console.prototype.onDebug = console[console.debug ? 'debug' : 'log'].bind(console, 'DEBUG'); +Console.prototype.onDebug = _.bindKey(console, console.debug ? 'debug' : 'log', 'DEBUG'); /** * Handler for the bridges "trace" event @@ -15234,7 +15309,7 @@ Console.prototype.onTrace = _.handler(function (method, url, body, responseBody, message += ' -d "' + body.replace(/"/g, '\\"') + '"'; } message += '\n<- ' + responseStatus + '\n' + responseBody; - console.log('TRACE', message); + console.log('TRACE:\n' + message + '\n\n'); }); },{"../logger":25,"../utils":33}],27:[function(require,module,exports){ @@ -15449,7 +15524,7 @@ TransportRequest.prototype._sendReqWithCon = _.handler(function (err, con) { TransportRequest.prototype._checkRespForFail = _.handler(function (err, body, status) { if (err && this._remainingRetries) { this._remainingRetries--; - this._log.info('Connection error, retrying'); + this._log.error(err.message, '-- retrying'); this._connectionPool.select(this.bound._sendReqWithCon); } else { this._log.info('Request complete'); @@ -15684,6 +15759,10 @@ function adjustWordCase(firstWordCap, otherWordsCap, sep) { if (word.length) { words.push(word); } + // add the leading underscore back to strings the had it originally + if (words.lenth && string.charAt(0) === '_') { + words[0] = '_' + words[0]; + } return words.join(sep); }; } @@ -15937,11 +16016,16 @@ _.makeBoundMethods = function (obj, methods) { _.noop = function () {}; -_.getStackTrace = function (callee) { - var e = {}; - Error.captureStackTrace(e, callee || _.getStackTrace); - return '\n' + e.stack.split('\n').slice(1).join('\n'); -}; +// _.getStackTrace = function (callee) { +// var e = {}; +// if (typeof Error.captureStackTrace === 'function') { +// Error.captureStackTrace(e, callee || _.getStackTrace); +// } else { +// e.stack = (new Error()).stack; +// console.log(e.stack); +// } +// return '\n' + e.stack.split('\n').slice(1).join('\n'); +// }; module.exports = utils; diff --git a/dist/elasticsearch.angular.min.js b/dist/elasticsearch.angular.min.js index 16e819c2e..c27da07b6 100644 --- a/dist/elasticsearch.angular.min.js +++ b/dist/elasticsearch.angular.min.js @@ -1,8 +1,9 @@ -/*! elasticsearch-js - v0.0.1 - 2013-10-29 +/*! elasticsearch-js - v0.0.1 - 2013-11-05 * https://github.com/elasticsearch/elasticsearch-js * Copyright (c) 2013 Spencer Alger; Licensed Apache License */ + // built using browserify -!function(a){"object"==typeof exports?module.exports=a():"function"==typeof define&&define.amd?define(a):"undefined"!=typeof window?window.true=a():"undefined"!=typeof global?global.true=a():"undefined"!=typeof self&&(self.true=a())}(function(){var a;return function b(a,c,d){function e(g,h){if(!c[g]){if(!a[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);throw new Error("Cannot find module '"+g+"'")}var j=c[g]={exports:{}};a[g][0].call(j.exports,function(b){var c=a[g][1][b];return e(c?c:b)},j,j.exports,b,a,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;gf;++f)a.hasOwnProperty(f)&&(e?d=b(d,a[f],f,a):(d=a[f],e=!0));return d},c.substr="b"!=="ab".substr(-1)?function(a,b,c){return 0>b&&(b=a.length+b),a.substr(b,c)}:function(a,b,c){return a.substr(b,c)},c.trim=function(a){return a.trim?a.trim():a.replace(/^\s+|\s+$/g,"")},c.bind=function(){var a=Array.prototype.slice.call(arguments),b=a.shift();if(b.bind)return b.bind.apply(b,a);var c=a.shift();return function(){b.apply(c,a.concat([Array.prototype.slice.call(arguments)]))}},c.create="function"==typeof Object.create?Object.create:e;var l="function"==typeof Object.keys?Object.keys:g,m="function"==typeof Object.getOwnPropertyNames?Object.getOwnPropertyNames:h;if((new Error).hasOwnProperty("description")){var n=function(a,b){return"[object Error]"===j.call(a)&&(b=c.filter(b,function(a){return"description"!==a&&"number"!==a&&"message"!==a})),b};c.keys=function(a){return n(a,l(a))},c.getOwnPropertyNames=function(a){return n(a,m(a))}}else c.keys=l,c.getOwnPropertyNames=m;if("function"==typeof Object.getOwnPropertyDescriptor)try{Object.getOwnPropertyDescriptor({a:1},"a"),c.getOwnPropertyDescriptor=Object.getOwnPropertyDescriptor}catch(o){c.getOwnPropertyDescriptor=function(a,b){try{return Object.getOwnPropertyDescriptor(a,b)}catch(c){return i(a,b)}}}else c.getOwnPropertyDescriptor=i},{}],3:[function(a,b){function c(a,b){return m.isUndefined(b)?""+b:!m.isNumber(b)||!isNaN(b)&&isFinite(b)?m.isFunction(b)||m.isRegExp(b)?b.toString():b:b.toString()}function d(a,b){return m.isString(a)?a.length=0;d--)if(e[d]!=f[d])return!1;for(d=e.length-1;d>=0;d--)if(c=e[d],!h(a[c],b[c]))return!1;return!0}function k(a,b){return a&&b?"[object RegExp]"==Object.prototype.toString.call(b)?b.test(a):a instanceof b?!0:b.call({},a)===!0?!0:!1:!1}function l(a,b,c,d){var e;m.isString(c)&&(d=c,c=null);try{b()}catch(g){e=g}if(d=(c&&c.name?" ("+c.name+").":".")+(d?" "+d:"."),a&&!e&&f(e,c,"Missing expected exception"+d),!a&&k(e,c)&&f(e,c,"Got unwanted exception"+d),a&&e&&c&&!k(e,c)||!a&&e)throw e}var m=a("util"),n=a("_shims"),o=Array.prototype.slice,p=b.exports=g;p.AssertionError=function(a){this.name="AssertionError",this.actual=a.actual,this.expected=a.expected,this.operator=a.operator,this.message=a.message||e(this)},m.inherits(p.AssertionError,Error),p.fail=f,p.ok=g,p.equal=function(a,b,c){a!=b&&f(a,b,c,"==",p.equal)},p.notEqual=function(a,b,c){a==b&&f(a,b,c,"!=",p.notEqual)},p.deepEqual=function(a,b,c){h(a,b)||f(a,b,c,"deepEqual",p.deepEqual)},p.notDeepEqual=function(a,b,c){h(a,b)&&f(a,b,c,"notDeepEqual",p.notDeepEqual)},p.strictEqual=function(a,b,c){a!==b&&f(a,b,c,"===",p.strictEqual)},p.notStrictEqual=function(a,b,c){a===b&&f(a,b,c,"!==",p.notStrictEqual)},p.throws=function(){l.apply(this,[!0].concat(o.call(arguments)))},p.doesNotThrow=function(){l.apply(this,[!1].concat(o.call(arguments)))},p.ifError=function(a){if(a)throw a}},{_shims:2,util:8}],4:[function(a,b){function c(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}var d=a("util");b.exports=c,c.EventEmitter=c,c.prototype._events=void 0,c.prototype._maxListeners=void 0,c.defaultMaxListeners=10,c.prototype.setMaxListeners=function(a){if(!d.isNumber(a)||0>a)throw TypeError("n must be a positive number");return this._maxListeners=a,this},c.prototype.emit=function(a){var b,c,e,f,g,h;if(this._events||(this._events={}),"error"===a&&(!this._events.error||d.isObject(this._events.error)&&!this._events.error.length))throw b=arguments[1],b instanceof Error?b:TypeError('Uncaught, unspecified "error" event.');if(c=this._events[a],d.isUndefined(c))return!1;if(d.isFunction(c))switch(arguments.length){case 1:c.call(this);break;case 2:c.call(this,arguments[1]);break;case 3:c.call(this,arguments[1],arguments[2]);break;default:for(e=arguments.length,f=new Array(e-1),g=1;e>g;g++)f[g-1]=arguments[g];c.apply(this,f)}else if(d.isObject(c)){for(e=arguments.length,f=new Array(e-1),g=1;e>g;g++)f[g-1]=arguments[g];for(h=c.slice(),e=h.length,g=0;e>g;g++)h[g].apply(this,f)}return!0},c.prototype.addListener=function(a,b){var e;if(!d.isFunction(b))throw TypeError("listener must be a function");if(this._events||(this._events={}),this._events.newListener&&this.emit("newListener",a,d.isFunction(b.listener)?b.listener:b),this._events[a]?d.isObject(this._events[a])?this._events[a].push(b):this._events[a]=[this._events[a],b]:this._events[a]=b,d.isObject(this._events[a])&&!this._events[a].warned){var e;e=d.isUndefined(this._maxListeners)?c.defaultMaxListeners:this._maxListeners,e&&e>0&&this._events[a].length>e&&(this._events[a].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[a].length),console.trace())}return this},c.prototype.on=c.prototype.addListener,c.prototype.once=function(a,b){function c(){this.removeListener(a,c),b.apply(this,arguments)}if(!d.isFunction(b))throw TypeError("listener must be a function");return c.listener=b,this.on(a,c),this},c.prototype.removeListener=function(a,b){var c,e,f,g;if(!d.isFunction(b))throw TypeError("listener must be a function");if(!this._events||!this._events[a])return this;if(c=this._events[a],f=c.length,e=-1,c===b||d.isFunction(c.listener)&&c.listener===b)delete this._events[a],this._events.removeListener&&this.emit("removeListener",a,b);else if(d.isObject(c)){for(g=f;g-->0;)if(c[g]===b||c[g].listener&&c[g].listener===b){e=g;break}if(0>e)return this;1===c.length?(c.length=0,delete this._events[a]):c.splice(e,1),this._events.removeListener&&this.emit("removeListener",a,b)}return this},c.prototype.removeAllListeners=function(a){var b,c;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[a]&&delete this._events[a],this;if(0===arguments.length){for(b in this._events)"removeListener"!==b&&this.removeAllListeners(b);return this.removeAllListeners("removeListener"),this._events={},this}if(c=this._events[a],d.isFunction(c))this.removeListener(a,c);else for(;c.length;)this.removeListener(a,c[c.length-1]);return delete this._events[a],this},c.prototype.listeners=function(a){var b;return b=this._events&&this._events[a]?d.isFunction(this._events[a])?[this._events[a]]:this._events[a].slice():[]},c.listenerCount=function(a,b){var c;return c=a._events&&a._events[b]?d.isFunction(a._events[b])?1:a._events[b].length:0}},{util:8}],5:[function(a,b,c){function d(a,b){for(var c=0,d=a.length-1;d>=0;d--){var e=a[d];"."===e?a.splice(d,1):".."===e?(a.splice(d,1),c++):c&&(a.splice(d,1),c--)}if(b)for(;c--;c)a.unshift("..");return a}var e=a("__browserify_process"),f=a("util"),g=a("_shims"),h=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/,i=function(a){return h.exec(a).slice(1)};c.resolve=function(){for(var a="",b=!1,c=arguments.length-1;c>=-1&&!b;c--){var h=c>=0?arguments[c]:e.cwd();if(!f.isString(h))throw new TypeError("Arguments to path.resolve must be strings");h&&(a=h+"/"+a,b="/"===h.charAt(0))}return a=d(g.filter(a.split("/"),function(a){return!!a}),!b).join("/"),(b?"/":"")+a||"."},c.normalize=function(a){var b=c.isAbsolute(a),e="/"===g.substr(a,-1);return a=d(g.filter(a.split("/"),function(a){return!!a}),!b).join("/"),a||b||(a="."),a&&e&&(a+="/"),(b?"/":"")+a},c.isAbsolute=function(a){return"/"===a.charAt(0)},c.join=function(){var a=Array.prototype.slice.call(arguments,0);return c.normalize(g.filter(a,function(a){if(!f.isString(a))throw new TypeError("Arguments to path.join must be strings");return a}).join("/"))},c.relative=function(a,b){function d(a){for(var b=0;b=0&&""===a[c];c--);return b>c?[]:a.slice(b,c-b+1)}a=c.resolve(a).substr(1),b=c.resolve(b).substr(1);for(var e=d(a.split("/")),f=d(b.split("/")),g=Math.min(e.length,f.length),h=g,i=0;g>i;i++)if(e[i]!==f[i]){h=i;break}for(var j=[],i=h;i0&&k>j&&(k=j);for(var l=0;k>l;++l){var m,n,o,p,q=a[l].replace(i,"%20"),r=q.indexOf(c);r>=0?(m=q.substr(0,r),n=q.substr(r+1)):(m=q,n="");try{o=decodeURIComponent(m),p=decodeURIComponent(n)}catch(s){o=f.unescape(m,!0),p=f.unescape(n,!0)}d(h,o)?g.isArray(h[o])?h[o].push(p):h[o]=[h[o],p]:h[o]=p}return h}},{_shims:2,buffer:10,util:8}],7:[function(a,b,c){function d(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}function e(a,b,c){if(a&&j.isObject(a)&&a instanceof d)return a;var e=new d;return e.parse(a,b,c),e}function f(a){return j.isString(a)&&(a=e(a)),a instanceof d?a.format():d.prototype.format.call(a)}function g(a,b){return e(a,!1,!0).resolve(b)}function h(a,b){return a?e(a,!1,!0).resolveObject(b):b}var i={encode:function(a){return a}},j=a("util"),k=a("_shims");c.parse=e,c.resolve=g,c.resolveObject=h,c.format=f,c.Url=d;var l=/^([a-z0-9.+-]+:)/i,m=/:[0-9]*$/,n=["<",">",'"',"`"," ","\r","\n"," "],o=["{","}","|","\\","^","`"].concat(n),p=["'"].concat(o),q=["%","/","?",";","#"].concat(p),r=["/","?","#"],s=255,t=/^[a-z0-9A-Z_-]{0,63}$/,u=/^([a-z0-9A-Z_-]{0,63})(.*)$/,v={javascript:!0,"javascript:":!0},w={javascript:!0,"javascript:":!0},x={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},y=a("querystring");d.prototype.parse=function(a,b,c){if(!j.isString(a))throw new TypeError("Parameter 'url' must be a string, not "+typeof a);var d=a;d=k.trim(d);var e=l.exec(d);if(e){e=e[0];var f=e.toLowerCase();this.protocol=f,d=d.substr(e.length)}if(c||e||d.match(/^\/\/[^@\/]+@[^@\/]+/)){var g="//"===d.substr(0,2);!g||e&&w[e]||(d=d.substr(2),this.slashes=!0)}if(!w[e]&&(g||e&&!x[e])){for(var h=-1,m=0;mn)&&(h=n)}var o,z;z=-1===h?d.lastIndexOf("@"):d.lastIndexOf("@",h),-1!==z&&(o=d.slice(0,z),d=d.slice(z+1),this.auth=decodeURIComponent(o)),h=-1;for(var m=0;mn)&&(h=n)}-1===h&&(h=d.length),this.host=d.slice(0,h),d=d.slice(h),this.parseHost(),this.hostname=this.hostname||"";var A="["===this.hostname[0]&&"]"===this.hostname[this.hostname.length-1];if(!A)for(var B=this.hostname.split(/\./),m=0,C=B.length;C>m;m++){var D=B[m];if(D&&!D.match(t)){for(var E="",F=0,G=D.length;G>F;F++)E+=D.charCodeAt(F)>127?"x":D[F];if(!E.match(t)){var H=B.slice(0,m),I=B.slice(m+1),J=D.match(u);J&&(H.push(J[1]),I.unshift(J[2])),I.length&&(d="/"+I.join(".")+d),this.hostname=H.join(".");break}}}if(this.hostname=this.hostname.length>s?"":this.hostname.toLowerCase(),!A){for(var K=this.hostname.split("."),L=[],m=0;mm;m++){var P=p[m],Q=encodeURIComponent(P);Q===P&&(Q=escape(P)),d=d.split(P).join(Q)}var R=d.indexOf("#");-1!==R&&(this.hash=d.substr(R),d=d.slice(0,R));var S=d.indexOf("?");if(-1!==S?(this.search=d.substr(S),this.query=d.substr(S+1),b&&(this.query=y.parse(this.query)),d=d.slice(0,S)):b&&(this.search="",this.query={}),d&&(this.pathname=d),x[f]&&this.hostname&&!this.pathname&&(this.pathname="/"),this.pathname||this.search){var N=this.pathname||"",M=this.search||"";this.path=N+M}return this.href=this.format(),this},d.prototype.format=function(){var a=this.auth||"";a&&(a=encodeURIComponent(a),a=a.replace(/%3A/i,":"),a+="@");var b=this.protocol||"",c=this.pathname||"",d=this.hash||"",e=!1,f="";this.host?e=a+this.host:this.hostname&&(e=a+(-1===this.hostname.indexOf(":")?this.hostname:"["+this.hostname+"]"),this.port&&(e+=":"+this.port)),this.query&&j.isObject(this.query)&&k.keys(this.query).length&&(f=y.stringify(this.query));var g=this.search||f&&"?"+f||"";return b&&":"!==k.substr(b,-1)&&(b+=":"),this.slashes||(!b||x[b])&&e!==!1?(e="//"+(e||""),c&&"/"!==c.charAt(0)&&(c="/"+c)):e||(e=""),d&&"#"!==d.charAt(0)&&(d="#"+d),g&&"?"!==g.charAt(0)&&(g="?"+g),c=c.replace(/[?#]/g,function(a){return encodeURIComponent(a)}),g=g.replace("#","%23"),b+e+c+g+d},d.prototype.resolve=function(a){return this.resolveObject(e(a,!1,!0)).format()},d.prototype.resolveObject=function(a){if(j.isString(a)){var b=new d;b.parse(a,!1,!0),a=b}var c=new d;if(k.forEach(k.keys(this),function(a){c[a]=this[a]},this),c.hash=a.hash,""===a.href)return c.href=c.format(),c;if(a.slashes&&!a.protocol)return k.forEach(k.keys(a),function(b){"protocol"!==b&&(c[b]=a[b])}),x[c.protocol]&&c.hostname&&!c.pathname&&(c.path=c.pathname="/"),c.href=c.format(),c;if(a.protocol&&a.protocol!==c.protocol){if(!x[a.protocol])return k.forEach(k.keys(a),function(b){c[b]=a[b]}),c.href=c.format(),c;if(c.protocol=a.protocol,a.host||w[a.protocol])c.pathname=a.pathname;else{for(var e=(a.pathname||"").split("/");e.length&&!(a.host=e.shift()););a.host||(a.host=""),a.hostname||(a.hostname=""),""!==e[0]&&e.unshift(""),e.length<2&&e.unshift(""),c.pathname=e.join("/")}if(c.search=a.search,c.query=a.query,c.host=a.host||"",c.auth=a.auth,c.hostname=a.hostname||a.host,c.port=a.port,c.pathname||c.search){var f=c.pathname||"",g=c.search||"";c.path=f+g}return c.slashes=c.slashes||a.slashes,c.href=c.format(),c}var h=c.pathname&&"/"===c.pathname.charAt(0),i=a.host||a.pathname&&"/"===a.pathname.charAt(0),l=i||h||c.host&&a.pathname,m=l,n=c.pathname&&c.pathname.split("/")||[],e=a.pathname&&a.pathname.split("/")||[],o=c.protocol&&!x[c.protocol];if(o&&(c.hostname="",c.port=null,c.host&&(""===n[0]?n[0]=c.host:n.unshift(c.host)),c.host="",a.protocol&&(a.hostname=null,a.port=null,a.host&&(""===e[0]?e[0]=a.host:e.unshift(a.host)),a.host=null),l=l&&(""===e[0]||""===n[0])),i)c.host=a.host||""===a.host?a.host:c.host,c.hostname=a.hostname||""===a.hostname?a.hostname:c.hostname,c.search=a.search,c.query=a.query,n=e;else if(e.length)n||(n=[]),n.pop(),n=n.concat(e),c.search=a.search,c.query=a.query;else if(!j.isNullOrUndefined(a.search)){if(o){c.hostname=c.host=n.shift();var p=c.host&&c.host.indexOf("@")>0?c.host.split("@"):!1;p&&(c.auth=p.shift(),c.host=c.hostname=p.shift())}return c.search=a.search,c.query=a.query,j.isNull(c.pathname)&&j.isNull(c.search)||(c.path=(c.pathname?c.pathname:"")+(c.search?c.search:"")),c.href=c.format(),c}if(!n.length)return c.pathname=null,c.path=c.search?"/"+c.search:null,c.href=c.format(),c;for(var q=n.slice(-1)[0],r=(c.host||a.host)&&("."===q||".."===q)||""===q,s=0,t=n.length;t>=0;t--)q=n[t],"."==q?n.splice(t,1):".."===q?(n.splice(t,1),s++):s&&(n.splice(t,1),s--);if(!l&&!m)for(;s--;s)n.unshift("..");!l||""===n[0]||n[0]&&"/"===n[0].charAt(0)||n.unshift(""),r&&"/"!==k.substr(n.join("/"),-1)&&n.push("");var u=""===n[0]||n[0]&&"/"===n[0].charAt(0);if(o){c.hostname=c.host=u?"":n.length?n.shift():"";var p=c.host&&c.host.indexOf("@")>0?c.host.split("@"):!1;p&&(c.auth=p.shift(),c.host=c.hostname=p.shift())}return l=l||c.host&&n.length,l&&!u&&n.unshift(""),n.length?c.pathname=n.join("/"):(c.pathname=null,c.path=null),j.isNull(c.pathname)&&j.isNull(c.search)||(c.path=(c.pathname?c.pathname:"")+(c.search?c.search:"")),c.auth=a.auth||c.auth,c.slashes=c.slashes||a.slashes,c.href=c.format(),c},d.prototype.parseHost=function(){var a=this.host,b=m.exec(a);b&&(b=b[0],":"!==b&&(this.port=b.substr(1)),a=a.substr(0,a.length-b.length)),a&&(this.hostname=a)}},{_shims:2,querystring:6,util:8}],8:[function(a,b,c){function d(a,b){var d={seen:[],stylize:f};return arguments.length>=3&&(d.depth=arguments[2]),arguments.length>=4&&(d.colors=arguments[3]),o(b)?d.showHidden=b:b&&c._extend(d,b),u(d.showHidden)&&(d.showHidden=!1),u(d.depth)&&(d.depth=2),u(d.colors)&&(d.colors=!1),u(d.customInspect)&&(d.customInspect=!0),d.colors&&(d.stylize=e),h(d,a,d.depth)}function e(a,b){var c=d.styles[b];return c?"["+d.colors[c][0]+"m"+a+"["+d.colors[c][1]+"m":a}function f(a){return a}function g(a){var b={};return G.forEach(a,function(a){b[a]=!0}),b}function h(a,b,d){if(a.customInspect&&b&&z(b.inspect)&&b.inspect!==c.inspect&&(!b.constructor||b.constructor.prototype!==b)){var e=b.inspect(d);return s(e)||(e=h(a,e,d)),e}var f=i(a,b);if(f)return f;var o=G.keys(b),p=g(o);if(a.showHidden&&(o=G.getOwnPropertyNames(b)),0===o.length){if(z(b)){var q=b.name?": "+b.name:"";return a.stylize("[Function"+q+"]","special")}if(v(b))return a.stylize(RegExp.prototype.toString.call(b),"regexp");if(x(b))return a.stylize(Date.prototype.toString.call(b),"date");if(y(b))return j(b)}var r="",t=!1,u=["{","}"];if(n(b)&&(t=!0,u=["[","]"]),z(b)){var w=b.name?": "+b.name:"";r=" [Function"+w+"]"}if(v(b)&&(r=" "+RegExp.prototype.toString.call(b)),x(b)&&(r=" "+Date.prototype.toUTCString.call(b)),y(b)&&(r=" "+j(b)),0===o.length&&(!t||0==b.length))return u[0]+r+u[1];if(0>d)return v(b)?a.stylize(RegExp.prototype.toString.call(b),"regexp"):a.stylize("[Object]","special");a.seen.push(b);var A;return A=t?k(a,b,d,p,o):o.map(function(c){return l(a,b,d,p,c,t)}),a.seen.pop(),m(A,r,u)}function i(a,b){if(u(b))return a.stylize("undefined","undefined");if(s(b)){var c="'"+JSON.stringify(b).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return a.stylize(c,"string")}return r(b)?a.stylize(""+b,"number"):o(b)?a.stylize(""+b,"boolean"):p(b)?a.stylize("null","null"):void 0}function j(a){return"["+Error.prototype.toString.call(a)+"]"}function k(a,b,c,d,e){for(var f=[],g=0,h=b.length;h>g;++g)F(b,String(g))?f.push(l(a,b,c,d,String(g),!0)):f.push("");return G.forEach(e,function(e){e.match(/^\d+$/)||f.push(l(a,b,c,d,e,!0))}),f}function l(a,b,c,d,e,f){var g,i,j;if(j=G.getOwnPropertyDescriptor(b,e)||{value:b[e]},j.get?i=j.set?a.stylize("[Getter/Setter]","special"):a.stylize("[Getter]","special"):j.set&&(i=a.stylize("[Setter]","special")),F(d,e)||(g="["+e+"]"),i||(G.indexOf(a.seen,j.value)<0?(i=p(c)?h(a,j.value,null):h(a,j.value,c-1),i.indexOf("\n")>-1&&(i=f?i.split("\n").map(function(a){return" "+a}).join("\n").substr(2):"\n"+i.split("\n").map(function(a){return" "+a}).join("\n"))):i=a.stylize("[Circular]","special")),u(g)){if(f&&e.match(/^\d+$/))return i;g=JSON.stringify(""+e),g.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(g=g.substr(1,g.length-2),g=a.stylize(g,"name")):(g=g.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),g=a.stylize(g,"string"))}return g+": "+i}function m(a,b,c){var d=0,e=G.reduce(a,function(a,b){return d++,b.indexOf("\n")>=0&&d++,a+b.replace(/\u001b\[\d\d?m/g,"").length+1},0);return e>60?c[0]+(""===b?"":b+"\n ")+" "+a.join(",\n ")+" "+c[1]:c[0]+b+" "+a.join(", ")+" "+c[1]}function n(a){return G.isArray(a)}function o(a){return"boolean"==typeof a}function p(a){return null===a}function q(a){return null==a}function r(a){return"number"==typeof a}function s(a){return"string"==typeof a}function t(a){return"symbol"==typeof a}function u(a){return void 0===a}function v(a){return w(a)&&"[object RegExp]"===C(a)}function w(a){return"object"==typeof a&&a}function x(a){return w(a)&&"[object Date]"===C(a)}function y(a){return w(a)&&"[object Error]"===C(a)}function z(a){return"function"==typeof a}function A(a){return null===a||"boolean"==typeof a||"number"==typeof a||"string"==typeof a||"symbol"==typeof a||"undefined"==typeof a}function B(a){return a&&"object"==typeof a&&"function"==typeof a.copy&&"function"==typeof a.fill&&"function"==typeof a.binarySlice}function C(a){return Object.prototype.toString.call(a)}function D(a){return 10>a?"0"+a.toString(10):a.toString(10)}function E(){var a=new Date,b=[D(a.getHours()),D(a.getMinutes()),D(a.getSeconds())].join(":");return[a.getDate(),I[a.getMonth()],b].join(" ")}function F(a,b){return Object.prototype.hasOwnProperty.call(a,b)}var G=a("_shims"),H=/%[sdj%]/g;c.format=function(a){if(!s(a)){for(var b=[],c=0;c=f)return a;switch(a){case"%s":return String(e[c++]);case"%d":return Number(e[c++]);case"%j":try{return JSON.stringify(e[c++])}catch(b){return"[Circular]"}default:return a}}),h=e[c];f>c;h=e[++c])g+=p(h)||!w(h)?" "+h:" "+d(h);return g},c.inspect=d,d.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},d.styles={special:"cyan",number:"yellow","boolean":"yellow",undefined:"grey","null":"bold",string:"green",date:"magenta",regexp:"red"},c.isArray=n,c.isBoolean=o,c.isNull=p,c.isNullOrUndefined=q,c.isNumber=r,c.isString=s,c.isSymbol=t,c.isUndefined=u,c.isRegExp=v,c.isObject=w,c.isDate=x,c.isError=y,c.isFunction=z,c.isPrimitive=A,c.isBuffer=B;var I=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];c.log=function(){console.log("%s - %s",E(),c.format.apply(c,arguments))},c.inherits=function(a,b){a.super_=b,a.prototype=G.create(b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}})},c._extend=function(a,b){if(!b||!w(b))return a;for(var c=G.keys(b),d=c.length;d--;)a[c[d]]=b[c[d]];return a}},{_shims:2}],9:[function(a,b,c){c.readIEEE754=function(a,b,c,d,e){var f,g,h=8*e-d-1,i=(1<>1,k=-7,l=c?0:e-1,m=c?1:-1,n=a[b+l];for(l+=m,f=n&(1<<-k)-1,n>>=-k,k+=h;k>0;f=256*f+a[b+l],l+=m,k-=8);for(g=f&(1<<-k)-1,f>>=-k,k+=d;k>0;g=256*g+a[b+l],l+=m,k-=8);if(0===f)f=1-j;else{if(f===i)return g?0/0:1/0*(n?-1:1);g+=Math.pow(2,d),f-=j}return(n?-1:1)*g*Math.pow(2,f-d)},c.writeIEEE754=function(a,b,c,d,e,f){var g,h,i,j=8*f-e-1,k=(1<>1,m=23===e?Math.pow(2,-24)-Math.pow(2,-77):0,n=d?f-1:0,o=d?-1:1,p=0>b||0===b&&0>1/b?1:0;for(b=Math.abs(b),isNaN(b)||1/0===b?(h=isNaN(b)?1:0,g=k):(g=Math.floor(Math.log(b)/Math.LN2),b*(i=Math.pow(2,-g))<1&&(g--,i*=2),b+=g+l>=1?m/i:m*Math.pow(2,1-l),b*i>=2&&(g++,i/=2),g+l>=k?(h=0,g=k):g+l>=1?(h=(b*i-1)*Math.pow(2,e),g+=l):(h=b*Math.pow(2,l-1)*Math.pow(2,e),g=0));e>=8;a[c+n]=255&h,n+=o,h/=256,e-=8);for(g=g<0;a[c+n]=255&g,n+=o,g/=256,j-=8);a[c+n-o]|=128*p}},{}],10:[function(a,b,c){function d(a){return a.trim?a.trim():a.replace(/^\s+|\s+$/g,"")}function e(b,c,f){if(E||(E=a("assert")),!(this instanceof e))return new e(b,c,f);if(this.parent=this,this.offset=0,"base64"==c&&"string"==typeof b)for(b=d(b);0!=b.length%4;)b+="=";var h;if("number"==typeof f){this.length=g(c);for(var j=0;j=b?b:a>=0?a:(a+=b,a>=0?a:0))}function g(a){return a=~~Math.ceil(+a),0>a?0:a}function h(a){return(Array.isArray||function(a){return"[object Array]"=={}.toString.apply(a)})(a)}function i(a){return h(a)||e.isBuffer(a)||a&&"object"==typeof a&&"number"==typeof a.length}function j(a){return 16>a?"0"+a.toString(16):a.toString(16)}function k(a){for(var b=[],c=0;ce&&!(e+c>=b.length||e>=a.length);)b[e+c]=a[e],e++;return e}function o(a){try{return decodeURIComponent(a)}catch(b){return String.fromCharCode(65533)}}function p(a,b,c,d){var e=0;return d||(E.ok("boolean"==typeof c,"missing or invalid endian"),E.ok(void 0!==b&&null!==b,"missing offset"),E.ok(b+1=a.length?0:(c?(e=a[b]<<8,b+1=a.length?0:(c?(b+1>>0):(b+2>>0)),e)}function r(a,b,c,d){var e,f;return d||(E.ok("boolean"==typeof c,"missing or invalid endian"),E.ok(void 0!==b&&null!==b,"missing offset"),E.ok(b+1=0,"specified a negative value for writing an unsigned value"),E.ok(b>=a,"value is larger than maximum value for type"),E.ok(Math.floor(a)===a,"value has a fractional component")}function w(a,b,c,d,e){e||(E.ok(void 0!==b&&null!==b,"missing value"),E.ok("boolean"==typeof d,"missing or invalid endian"),E.ok(void 0!==c&&null!==c,"missing offset"),E.ok(c+1>>8*(d?1-f:f)}function x(a,b,c,d,e){e||(E.ok(void 0!==b&&null!==b,"missing value"),E.ok("boolean"==typeof d,"missing or invalid endian"),E.ok(void 0!==c&&null!==c,"missing offset"),E.ok(c+3>>8*(d?3-f:f)}function y(a,b,c){E.ok("number"==typeof a,"cannot write a non-number as a number"),E.ok(b>=a,"value larger than maximum allowed value"),E.ok(a>=c,"value smaller than minimum allowed value"),E.ok(Math.floor(a)===a,"value has a fractional component")}function z(a,b,c){E.ok("number"==typeof a,"cannot write a non-number as a number"),E.ok(b>=a,"value larger than maximum allowed value"),E.ok(a>=c,"value smaller than minimum allowed value")}function A(a,b,c,d,e){e||(E.ok(void 0!==b&&null!==b,"missing value"),E.ok("boolean"==typeof d,"missing or invalid endian"),E.ok(void 0!==c&&null!==c,"missing offset"),E.ok(c+1=0?w(a,b,c,d,e):w(a,65535+b+1,c,d,e)}function B(a,b,c,d,e){e||(E.ok(void 0!==b&&null!==b,"missing value"),E.ok("boolean"==typeof d,"missing or invalid endian"),E.ok(void 0!==c&&null!==c,"missing offset"),E.ok(c+3=0?x(a,b,c,d,e):x(a,4294967295+b+1,c,d,e) +!function(a){"object"==typeof exports?module.exports=a():"function"==typeof define&&define.amd?define(a):"undefined"!=typeof window?window.elasticsearch=a():"undefined"!=typeof global?global.elasticsearch=a():"undefined"!=typeof self&&(self.elasticsearch=a())}(function(){var a;return function b(a,c,d){function e(g,h){if(!c[g]){if(!a[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);throw new Error("Cannot find module '"+g+"'")}var j=c[g]={exports:{}};a[g][0].call(j.exports,function(b){var c=a[g][1][b];return e(c?c:b)},j,j.exports,b,a,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;gf;++f)a.hasOwnProperty(f)&&(e?d=b(d,a[f],f,a):(d=a[f],e=!0));return d},c.substr="b"!=="ab".substr(-1)?function(a,b,c){return 0>b&&(b=a.length+b),a.substr(b,c)}:function(a,b,c){return a.substr(b,c)},c.trim=function(a){return a.trim?a.trim():a.replace(/^\s+|\s+$/g,"")},c.bind=function(){var a=Array.prototype.slice.call(arguments),b=a.shift();if(b.bind)return b.bind.apply(b,a);var c=a.shift();return function(){b.apply(c,a.concat([Array.prototype.slice.call(arguments)]))}},c.create="function"==typeof Object.create?Object.create:e;var l="function"==typeof Object.keys?Object.keys:g,m="function"==typeof Object.getOwnPropertyNames?Object.getOwnPropertyNames:h;if((new Error).hasOwnProperty("description")){var n=function(a,b){return"[object Error]"===j.call(a)&&(b=c.filter(b,function(a){return"description"!==a&&"number"!==a&&"message"!==a})),b};c.keys=function(a){return n(a,l(a))},c.getOwnPropertyNames=function(a){return n(a,m(a))}}else c.keys=l,c.getOwnPropertyNames=m;if("function"==typeof Object.getOwnPropertyDescriptor)try{Object.getOwnPropertyDescriptor({a:1},"a"),c.getOwnPropertyDescriptor=Object.getOwnPropertyDescriptor}catch(o){c.getOwnPropertyDescriptor=function(a,b){try{return Object.getOwnPropertyDescriptor(a,b)}catch(c){return i(a,b)}}}else c.getOwnPropertyDescriptor=i},{}],3:[function(a,b){function c(a,b){return m.isUndefined(b)?""+b:!m.isNumber(b)||!isNaN(b)&&isFinite(b)?m.isFunction(b)||m.isRegExp(b)?b.toString():b:b.toString()}function d(a,b){return m.isString(a)?a.length=0;d--)if(e[d]!=f[d])return!1;for(d=e.length-1;d>=0;d--)if(c=e[d],!h(a[c],b[c]))return!1;return!0}function k(a,b){return a&&b?"[object RegExp]"==Object.prototype.toString.call(b)?b.test(a):a instanceof b?!0:b.call({},a)===!0?!0:!1:!1}function l(a,b,c,d){var e;m.isString(c)&&(d=c,c=null);try{b()}catch(g){e=g}if(d=(c&&c.name?" ("+c.name+").":".")+(d?" "+d:"."),a&&!e&&f(e,c,"Missing expected exception"+d),!a&&k(e,c)&&f(e,c,"Got unwanted exception"+d),a&&e&&c&&!k(e,c)||!a&&e)throw e}var m=a("util"),n=a("_shims"),o=Array.prototype.slice,p=b.exports=g;p.AssertionError=function(a){this.name="AssertionError",this.actual=a.actual,this.expected=a.expected,this.operator=a.operator,this.message=a.message||e(this)},m.inherits(p.AssertionError,Error),p.fail=f,p.ok=g,p.equal=function(a,b,c){a!=b&&f(a,b,c,"==",p.equal)},p.notEqual=function(a,b,c){a==b&&f(a,b,c,"!=",p.notEqual)},p.deepEqual=function(a,b,c){h(a,b)||f(a,b,c,"deepEqual",p.deepEqual)},p.notDeepEqual=function(a,b,c){h(a,b)&&f(a,b,c,"notDeepEqual",p.notDeepEqual)},p.strictEqual=function(a,b,c){a!==b&&f(a,b,c,"===",p.strictEqual)},p.notStrictEqual=function(a,b,c){a===b&&f(a,b,c,"!==",p.notStrictEqual)},p.throws=function(){l.apply(this,[!0].concat(o.call(arguments)))},p.doesNotThrow=function(){l.apply(this,[!1].concat(o.call(arguments)))},p.ifError=function(a){if(a)throw a}},{_shims:2,util:8}],4:[function(a,b){function c(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}var d=a("util");b.exports=c,c.EventEmitter=c,c.prototype._events=void 0,c.prototype._maxListeners=void 0,c.defaultMaxListeners=10,c.prototype.setMaxListeners=function(a){if(!d.isNumber(a)||0>a)throw TypeError("n must be a positive number");return this._maxListeners=a,this},c.prototype.emit=function(a){var b,c,e,f,g,h;if(this._events||(this._events={}),"error"===a&&(!this._events.error||d.isObject(this._events.error)&&!this._events.error.length))throw b=arguments[1],b instanceof Error?b:TypeError('Uncaught, unspecified "error" event.');if(c=this._events[a],d.isUndefined(c))return!1;if(d.isFunction(c))switch(arguments.length){case 1:c.call(this);break;case 2:c.call(this,arguments[1]);break;case 3:c.call(this,arguments[1],arguments[2]);break;default:for(e=arguments.length,f=new Array(e-1),g=1;e>g;g++)f[g-1]=arguments[g];c.apply(this,f)}else if(d.isObject(c)){for(e=arguments.length,f=new Array(e-1),g=1;e>g;g++)f[g-1]=arguments[g];for(h=c.slice(),e=h.length,g=0;e>g;g++)h[g].apply(this,f)}return!0},c.prototype.addListener=function(a,b){var e;if(!d.isFunction(b))throw TypeError("listener must be a function");if(this._events||(this._events={}),this._events.newListener&&this.emit("newListener",a,d.isFunction(b.listener)?b.listener:b),this._events[a]?d.isObject(this._events[a])?this._events[a].push(b):this._events[a]=[this._events[a],b]:this._events[a]=b,d.isObject(this._events[a])&&!this._events[a].warned){var e;e=d.isUndefined(this._maxListeners)?c.defaultMaxListeners:this._maxListeners,e&&e>0&&this._events[a].length>e&&(this._events[a].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[a].length),console.trace())}return this},c.prototype.on=c.prototype.addListener,c.prototype.once=function(a,b){function c(){this.removeListener(a,c),b.apply(this,arguments)}if(!d.isFunction(b))throw TypeError("listener must be a function");return c.listener=b,this.on(a,c),this},c.prototype.removeListener=function(a,b){var c,e,f,g;if(!d.isFunction(b))throw TypeError("listener must be a function");if(!this._events||!this._events[a])return this;if(c=this._events[a],f=c.length,e=-1,c===b||d.isFunction(c.listener)&&c.listener===b)delete this._events[a],this._events.removeListener&&this.emit("removeListener",a,b);else if(d.isObject(c)){for(g=f;g-->0;)if(c[g]===b||c[g].listener&&c[g].listener===b){e=g;break}if(0>e)return this;1===c.length?(c.length=0,delete this._events[a]):c.splice(e,1),this._events.removeListener&&this.emit("removeListener",a,b)}return this},c.prototype.removeAllListeners=function(a){var b,c;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[a]&&delete this._events[a],this;if(0===arguments.length){for(b in this._events)"removeListener"!==b&&this.removeAllListeners(b);return this.removeAllListeners("removeListener"),this._events={},this}if(c=this._events[a],d.isFunction(c))this.removeListener(a,c);else for(;c.length;)this.removeListener(a,c[c.length-1]);return delete this._events[a],this},c.prototype.listeners=function(a){var b;return b=this._events&&this._events[a]?d.isFunction(this._events[a])?[this._events[a]]:this._events[a].slice():[]},c.listenerCount=function(a,b){var c;return c=a._events&&a._events[b]?d.isFunction(a._events[b])?1:a._events[b].length:0}},{util:8}],5:[function(a,b,c){function d(a,b){for(var c=0,d=a.length-1;d>=0;d--){var e=a[d];"."===e?a.splice(d,1):".."===e?(a.splice(d,1),c++):c&&(a.splice(d,1),c--)}if(b)for(;c--;c)a.unshift("..");return a}var e=a("__browserify_process"),f=a("util"),g=a("_shims"),h=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/,i=function(a){return h.exec(a).slice(1)};c.resolve=function(){for(var a="",b=!1,c=arguments.length-1;c>=-1&&!b;c--){var h=c>=0?arguments[c]:e.cwd();if(!f.isString(h))throw new TypeError("Arguments to path.resolve must be strings");h&&(a=h+"/"+a,b="/"===h.charAt(0))}return a=d(g.filter(a.split("/"),function(a){return!!a}),!b).join("/"),(b?"/":"")+a||"."},c.normalize=function(a){var b=c.isAbsolute(a),e="/"===g.substr(a,-1);return a=d(g.filter(a.split("/"),function(a){return!!a}),!b).join("/"),a||b||(a="."),a&&e&&(a+="/"),(b?"/":"")+a},c.isAbsolute=function(a){return"/"===a.charAt(0)},c.join=function(){var a=Array.prototype.slice.call(arguments,0);return c.normalize(g.filter(a,function(a){if(!f.isString(a))throw new TypeError("Arguments to path.join must be strings");return a}).join("/"))},c.relative=function(a,b){function d(a){for(var b=0;b=0&&""===a[c];c--);return b>c?[]:a.slice(b,c-b+1)}a=c.resolve(a).substr(1),b=c.resolve(b).substr(1);for(var e=d(a.split("/")),f=d(b.split("/")),g=Math.min(e.length,f.length),h=g,i=0;g>i;i++)if(e[i]!==f[i]){h=i;break}for(var j=[],i=h;i0&&k>j&&(k=j);for(var l=0;k>l;++l){var m,n,o,p,q=a[l].replace(i,"%20"),r=q.indexOf(c);r>=0?(m=q.substr(0,r),n=q.substr(r+1)):(m=q,n="");try{o=decodeURIComponent(m),p=decodeURIComponent(n)}catch(s){o=f.unescape(m,!0),p=f.unescape(n,!0)}d(h,o)?g.isArray(h[o])?h[o].push(p):h[o]=[h[o],p]:h[o]=p}return h}},{_shims:2,buffer:10,util:8}],7:[function(a,b,c){function d(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}function e(a,b,c){if(a&&j.isObject(a)&&a instanceof d)return a;var e=new d;return e.parse(a,b,c),e}function f(a){return j.isString(a)&&(a=e(a)),a instanceof d?a.format():d.prototype.format.call(a)}function g(a,b){return e(a,!1,!0).resolve(b)}function h(a,b){return a?e(a,!1,!0).resolveObject(b):b}var i={encode:function(a){return a}},j=a("util"),k=a("_shims");c.parse=e,c.resolve=g,c.resolveObject=h,c.format=f,c.Url=d;var l=/^([a-z0-9.+-]+:)/i,m=/:[0-9]*$/,n=["<",">",'"',"`"," ","\r","\n"," "],o=["{","}","|","\\","^","`"].concat(n),p=["'"].concat(o),q=["%","/","?",";","#"].concat(p),r=["/","?","#"],s=255,t=/^[a-z0-9A-Z_-]{0,63}$/,u=/^([a-z0-9A-Z_-]{0,63})(.*)$/,v={javascript:!0,"javascript:":!0},w={javascript:!0,"javascript:":!0},x={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},y=a("querystring");d.prototype.parse=function(a,b,c){if(!j.isString(a))throw new TypeError("Parameter 'url' must be a string, not "+typeof a);var d=a;d=k.trim(d);var e=l.exec(d);if(e){e=e[0];var f=e.toLowerCase();this.protocol=f,d=d.substr(e.length)}if(c||e||d.match(/^\/\/[^@\/]+@[^@\/]+/)){var g="//"===d.substr(0,2);!g||e&&w[e]||(d=d.substr(2),this.slashes=!0)}if(!w[e]&&(g||e&&!x[e])){for(var h=-1,m=0;mn)&&(h=n)}var o,z;z=-1===h?d.lastIndexOf("@"):d.lastIndexOf("@",h),-1!==z&&(o=d.slice(0,z),d=d.slice(z+1),this.auth=decodeURIComponent(o)),h=-1;for(var m=0;mn)&&(h=n)}-1===h&&(h=d.length),this.host=d.slice(0,h),d=d.slice(h),this.parseHost(),this.hostname=this.hostname||"";var A="["===this.hostname[0]&&"]"===this.hostname[this.hostname.length-1];if(!A)for(var B=this.hostname.split(/\./),m=0,C=B.length;C>m;m++){var D=B[m];if(D&&!D.match(t)){for(var E="",F=0,G=D.length;G>F;F++)E+=D.charCodeAt(F)>127?"x":D[F];if(!E.match(t)){var H=B.slice(0,m),I=B.slice(m+1),J=D.match(u);J&&(H.push(J[1]),I.unshift(J[2])),I.length&&(d="/"+I.join(".")+d),this.hostname=H.join(".");break}}}if(this.hostname=this.hostname.length>s?"":this.hostname.toLowerCase(),!A){for(var K=this.hostname.split("."),L=[],m=0;mm;m++){var P=p[m],Q=encodeURIComponent(P);Q===P&&(Q=escape(P)),d=d.split(P).join(Q)}var R=d.indexOf("#");-1!==R&&(this.hash=d.substr(R),d=d.slice(0,R));var S=d.indexOf("?");if(-1!==S?(this.search=d.substr(S),this.query=d.substr(S+1),b&&(this.query=y.parse(this.query)),d=d.slice(0,S)):b&&(this.search="",this.query={}),d&&(this.pathname=d),x[f]&&this.hostname&&!this.pathname&&(this.pathname="/"),this.pathname||this.search){var N=this.pathname||"",M=this.search||"";this.path=N+M}return this.href=this.format(),this},d.prototype.format=function(){var a=this.auth||"";a&&(a=encodeURIComponent(a),a=a.replace(/%3A/i,":"),a+="@");var b=this.protocol||"",c=this.pathname||"",d=this.hash||"",e=!1,f="";this.host?e=a+this.host:this.hostname&&(e=a+(-1===this.hostname.indexOf(":")?this.hostname:"["+this.hostname+"]"),this.port&&(e+=":"+this.port)),this.query&&j.isObject(this.query)&&k.keys(this.query).length&&(f=y.stringify(this.query));var g=this.search||f&&"?"+f||"";return b&&":"!==k.substr(b,-1)&&(b+=":"),this.slashes||(!b||x[b])&&e!==!1?(e="//"+(e||""),c&&"/"!==c.charAt(0)&&(c="/"+c)):e||(e=""),d&&"#"!==d.charAt(0)&&(d="#"+d),g&&"?"!==g.charAt(0)&&(g="?"+g),c=c.replace(/[?#]/g,function(a){return encodeURIComponent(a)}),g=g.replace("#","%23"),b+e+c+g+d},d.prototype.resolve=function(a){return this.resolveObject(e(a,!1,!0)).format()},d.prototype.resolveObject=function(a){if(j.isString(a)){var b=new d;b.parse(a,!1,!0),a=b}var c=new d;if(k.forEach(k.keys(this),function(a){c[a]=this[a]},this),c.hash=a.hash,""===a.href)return c.href=c.format(),c;if(a.slashes&&!a.protocol)return k.forEach(k.keys(a),function(b){"protocol"!==b&&(c[b]=a[b])}),x[c.protocol]&&c.hostname&&!c.pathname&&(c.path=c.pathname="/"),c.href=c.format(),c;if(a.protocol&&a.protocol!==c.protocol){if(!x[a.protocol])return k.forEach(k.keys(a),function(b){c[b]=a[b]}),c.href=c.format(),c;if(c.protocol=a.protocol,a.host||w[a.protocol])c.pathname=a.pathname;else{for(var e=(a.pathname||"").split("/");e.length&&!(a.host=e.shift()););a.host||(a.host=""),a.hostname||(a.hostname=""),""!==e[0]&&e.unshift(""),e.length<2&&e.unshift(""),c.pathname=e.join("/")}if(c.search=a.search,c.query=a.query,c.host=a.host||"",c.auth=a.auth,c.hostname=a.hostname||a.host,c.port=a.port,c.pathname||c.search){var f=c.pathname||"",g=c.search||"";c.path=f+g}return c.slashes=c.slashes||a.slashes,c.href=c.format(),c}var h=c.pathname&&"/"===c.pathname.charAt(0),i=a.host||a.pathname&&"/"===a.pathname.charAt(0),l=i||h||c.host&&a.pathname,m=l,n=c.pathname&&c.pathname.split("/")||[],e=a.pathname&&a.pathname.split("/")||[],o=c.protocol&&!x[c.protocol];if(o&&(c.hostname="",c.port=null,c.host&&(""===n[0]?n[0]=c.host:n.unshift(c.host)),c.host="",a.protocol&&(a.hostname=null,a.port=null,a.host&&(""===e[0]?e[0]=a.host:e.unshift(a.host)),a.host=null),l=l&&(""===e[0]||""===n[0])),i)c.host=a.host||""===a.host?a.host:c.host,c.hostname=a.hostname||""===a.hostname?a.hostname:c.hostname,c.search=a.search,c.query=a.query,n=e;else if(e.length)n||(n=[]),n.pop(),n=n.concat(e),c.search=a.search,c.query=a.query;else if(!j.isNullOrUndefined(a.search)){if(o){c.hostname=c.host=n.shift();var p=c.host&&c.host.indexOf("@")>0?c.host.split("@"):!1;p&&(c.auth=p.shift(),c.host=c.hostname=p.shift())}return c.search=a.search,c.query=a.query,j.isNull(c.pathname)&&j.isNull(c.search)||(c.path=(c.pathname?c.pathname:"")+(c.search?c.search:"")),c.href=c.format(),c}if(!n.length)return c.pathname=null,c.path=c.search?"/"+c.search:null,c.href=c.format(),c;for(var q=n.slice(-1)[0],r=(c.host||a.host)&&("."===q||".."===q)||""===q,s=0,t=n.length;t>=0;t--)q=n[t],"."==q?n.splice(t,1):".."===q?(n.splice(t,1),s++):s&&(n.splice(t,1),s--);if(!l&&!m)for(;s--;s)n.unshift("..");!l||""===n[0]||n[0]&&"/"===n[0].charAt(0)||n.unshift(""),r&&"/"!==k.substr(n.join("/"),-1)&&n.push("");var u=""===n[0]||n[0]&&"/"===n[0].charAt(0);if(o){c.hostname=c.host=u?"":n.length?n.shift():"";var p=c.host&&c.host.indexOf("@")>0?c.host.split("@"):!1;p&&(c.auth=p.shift(),c.host=c.hostname=p.shift())}return l=l||c.host&&n.length,l&&!u&&n.unshift(""),n.length?c.pathname=n.join("/"):(c.pathname=null,c.path=null),j.isNull(c.pathname)&&j.isNull(c.search)||(c.path=(c.pathname?c.pathname:"")+(c.search?c.search:"")),c.auth=a.auth||c.auth,c.slashes=c.slashes||a.slashes,c.href=c.format(),c},d.prototype.parseHost=function(){var a=this.host,b=m.exec(a);b&&(b=b[0],":"!==b&&(this.port=b.substr(1)),a=a.substr(0,a.length-b.length)),a&&(this.hostname=a)}},{_shims:2,querystring:6,util:8}],8:[function(a,b,c){function d(a,b){var d={seen:[],stylize:f};return arguments.length>=3&&(d.depth=arguments[2]),arguments.length>=4&&(d.colors=arguments[3]),o(b)?d.showHidden=b:b&&c._extend(d,b),u(d.showHidden)&&(d.showHidden=!1),u(d.depth)&&(d.depth=2),u(d.colors)&&(d.colors=!1),u(d.customInspect)&&(d.customInspect=!0),d.colors&&(d.stylize=e),h(d,a,d.depth)}function e(a,b){var c=d.styles[b];return c?"["+d.colors[c][0]+"m"+a+"["+d.colors[c][1]+"m":a}function f(a){return a}function g(a){var b={};return G.forEach(a,function(a){b[a]=!0}),b}function h(a,b,d){if(a.customInspect&&b&&z(b.inspect)&&b.inspect!==c.inspect&&(!b.constructor||b.constructor.prototype!==b)){var e=b.inspect(d);return s(e)||(e=h(a,e,d)),e}var f=i(a,b);if(f)return f;var o=G.keys(b),p=g(o);if(a.showHidden&&(o=G.getOwnPropertyNames(b)),0===o.length){if(z(b)){var q=b.name?": "+b.name:"";return a.stylize("[Function"+q+"]","special")}if(v(b))return a.stylize(RegExp.prototype.toString.call(b),"regexp");if(x(b))return a.stylize(Date.prototype.toString.call(b),"date");if(y(b))return j(b)}var r="",t=!1,u=["{","}"];if(n(b)&&(t=!0,u=["[","]"]),z(b)){var w=b.name?": "+b.name:"";r=" [Function"+w+"]"}if(v(b)&&(r=" "+RegExp.prototype.toString.call(b)),x(b)&&(r=" "+Date.prototype.toUTCString.call(b)),y(b)&&(r=" "+j(b)),0===o.length&&(!t||0==b.length))return u[0]+r+u[1];if(0>d)return v(b)?a.stylize(RegExp.prototype.toString.call(b),"regexp"):a.stylize("[Object]","special");a.seen.push(b);var A;return A=t?k(a,b,d,p,o):o.map(function(c){return l(a,b,d,p,c,t)}),a.seen.pop(),m(A,r,u)}function i(a,b){if(u(b))return a.stylize("undefined","undefined");if(s(b)){var c="'"+JSON.stringify(b).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return a.stylize(c,"string")}return r(b)?a.stylize(""+b,"number"):o(b)?a.stylize(""+b,"boolean"):p(b)?a.stylize("null","null"):void 0}function j(a){return"["+Error.prototype.toString.call(a)+"]"}function k(a,b,c,d,e){for(var f=[],g=0,h=b.length;h>g;++g)F(b,String(g))?f.push(l(a,b,c,d,String(g),!0)):f.push("");return G.forEach(e,function(e){e.match(/^\d+$/)||f.push(l(a,b,c,d,e,!0))}),f}function l(a,b,c,d,e,f){var g,i,j;if(j=G.getOwnPropertyDescriptor(b,e)||{value:b[e]},j.get?i=j.set?a.stylize("[Getter/Setter]","special"):a.stylize("[Getter]","special"):j.set&&(i=a.stylize("[Setter]","special")),F(d,e)||(g="["+e+"]"),i||(G.indexOf(a.seen,j.value)<0?(i=p(c)?h(a,j.value,null):h(a,j.value,c-1),i.indexOf("\n")>-1&&(i=f?i.split("\n").map(function(a){return" "+a}).join("\n").substr(2):"\n"+i.split("\n").map(function(a){return" "+a}).join("\n"))):i=a.stylize("[Circular]","special")),u(g)){if(f&&e.match(/^\d+$/))return i;g=JSON.stringify(""+e),g.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(g=g.substr(1,g.length-2),g=a.stylize(g,"name")):(g=g.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),g=a.stylize(g,"string"))}return g+": "+i}function m(a,b,c){var d=0,e=G.reduce(a,function(a,b){return d++,b.indexOf("\n")>=0&&d++,a+b.replace(/\u001b\[\d\d?m/g,"").length+1},0);return e>60?c[0]+(""===b?"":b+"\n ")+" "+a.join(",\n ")+" "+c[1]:c[0]+b+" "+a.join(", ")+" "+c[1]}function n(a){return G.isArray(a)}function o(a){return"boolean"==typeof a}function p(a){return null===a}function q(a){return null==a}function r(a){return"number"==typeof a}function s(a){return"string"==typeof a}function t(a){return"symbol"==typeof a}function u(a){return void 0===a}function v(a){return w(a)&&"[object RegExp]"===C(a)}function w(a){return"object"==typeof a&&a}function x(a){return w(a)&&"[object Date]"===C(a)}function y(a){return w(a)&&"[object Error]"===C(a)}function z(a){return"function"==typeof a}function A(a){return null===a||"boolean"==typeof a||"number"==typeof a||"string"==typeof a||"symbol"==typeof a||"undefined"==typeof a}function B(a){return a&&"object"==typeof a&&"function"==typeof a.copy&&"function"==typeof a.fill&&"function"==typeof a.binarySlice}function C(a){return Object.prototype.toString.call(a)}function D(a){return 10>a?"0"+a.toString(10):a.toString(10)}function E(){var a=new Date,b=[D(a.getHours()),D(a.getMinutes()),D(a.getSeconds())].join(":");return[a.getDate(),I[a.getMonth()],b].join(" ")}function F(a,b){return Object.prototype.hasOwnProperty.call(a,b)}var G=a("_shims"),H=/%[sdj%]/g;c.format=function(a){if(!s(a)){for(var b=[],c=0;c=f)return a;switch(a){case"%s":return String(e[c++]);case"%d":return Number(e[c++]);case"%j":try{return JSON.stringify(e[c++])}catch(b){return"[Circular]"}default:return a}}),h=e[c];f>c;h=e[++c])g+=p(h)||!w(h)?" "+h:" "+d(h);return g},c.inspect=d,d.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},d.styles={special:"cyan",number:"yellow","boolean":"yellow",undefined:"grey","null":"bold",string:"green",date:"magenta",regexp:"red"},c.isArray=n,c.isBoolean=o,c.isNull=p,c.isNullOrUndefined=q,c.isNumber=r,c.isString=s,c.isSymbol=t,c.isUndefined=u,c.isRegExp=v,c.isObject=w,c.isDate=x,c.isError=y,c.isFunction=z,c.isPrimitive=A,c.isBuffer=B;var I=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];c.log=function(){console.log("%s - %s",E(),c.format.apply(c,arguments))},c.inherits=function(a,b){a.super_=b,a.prototype=G.create(b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}})},c._extend=function(a,b){if(!b||!w(b))return a;for(var c=G.keys(b),d=c.length;d--;)a[c[d]]=b[c[d]];return a}},{_shims:2}],9:[function(a,b,c){c.readIEEE754=function(a,b,c,d,e){var f,g,h=8*e-d-1,i=(1<>1,k=-7,l=c?0:e-1,m=c?1:-1,n=a[b+l];for(l+=m,f=n&(1<<-k)-1,n>>=-k,k+=h;k>0;f=256*f+a[b+l],l+=m,k-=8);for(g=f&(1<<-k)-1,f>>=-k,k+=d;k>0;g=256*g+a[b+l],l+=m,k-=8);if(0===f)f=1-j;else{if(f===i)return g?0/0:1/0*(n?-1:1);g+=Math.pow(2,d),f-=j}return(n?-1:1)*g*Math.pow(2,f-d)},c.writeIEEE754=function(a,b,c,d,e,f){var g,h,i,j=8*f-e-1,k=(1<>1,m=23===e?Math.pow(2,-24)-Math.pow(2,-77):0,n=d?f-1:0,o=d?-1:1,p=0>b||0===b&&0>1/b?1:0;for(b=Math.abs(b),isNaN(b)||1/0===b?(h=isNaN(b)?1:0,g=k):(g=Math.floor(Math.log(b)/Math.LN2),b*(i=Math.pow(2,-g))<1&&(g--,i*=2),b+=g+l>=1?m/i:m*Math.pow(2,1-l),b*i>=2&&(g++,i/=2),g+l>=k?(h=0,g=k):g+l>=1?(h=(b*i-1)*Math.pow(2,e),g+=l):(h=b*Math.pow(2,l-1)*Math.pow(2,e),g=0));e>=8;a[c+n]=255&h,n+=o,h/=256,e-=8);for(g=g<0;a[c+n]=255&g,n+=o,g/=256,j-=8);a[c+n-o]|=128*p}},{}],10:[function(a,b,c){function d(a){return a.trim?a.trim():a.replace(/^\s+|\s+$/g,"")}function e(b,c,f){if(E||(E=a("assert")),!(this instanceof e))return new e(b,c,f);if(this.parent=this,this.offset=0,"base64"==c&&"string"==typeof b)for(b=d(b);0!=b.length%4;)b+="=";var h;if("number"==typeof f){this.length=g(c);for(var j=0;j=b?b:a>=0?a:(a+=b,a>=0?a:0))}function g(a){return a=~~Math.ceil(+a),0>a?0:a}function h(a){return(Array.isArray||function(a){return"[object Array]"=={}.toString.apply(a)})(a)}function i(a){return h(a)||e.isBuffer(a)||a&&"object"==typeof a&&"number"==typeof a.length}function j(a){return 16>a?"0"+a.toString(16):a.toString(16)}function k(a){for(var b=[],c=0;ce&&!(e+c>=b.length||e>=a.length);)b[e+c]=a[e],e++;return e}function o(a){try{return decodeURIComponent(a)}catch(b){return String.fromCharCode(65533)}}function p(a,b,c,d){var e=0;return d||(E.ok("boolean"==typeof c,"missing or invalid endian"),E.ok(void 0!==b&&null!==b,"missing offset"),E.ok(b+1=a.length?0:(c?(e=a[b]<<8,b+1=a.length?0:(c?(b+1>>0):(b+2>>0)),e)}function r(a,b,c,d){var e,f;return d||(E.ok("boolean"==typeof c,"missing or invalid endian"),E.ok(void 0!==b&&null!==b,"missing offset"),E.ok(b+1=0,"specified a negative value for writing an unsigned value"),E.ok(b>=a,"value is larger than maximum value for type"),E.ok(Math.floor(a)===a,"value has a fractional component")}function w(a,b,c,d,e){e||(E.ok(void 0!==b&&null!==b,"missing value"),E.ok("boolean"==typeof d,"missing or invalid endian"),E.ok(void 0!==c&&null!==c,"missing offset"),E.ok(c+1>>8*(d?1-f:f)}function x(a,b,c,d,e){e||(E.ok(void 0!==b&&null!==b,"missing value"),E.ok("boolean"==typeof d,"missing or invalid endian"),E.ok(void 0!==c&&null!==c,"missing offset"),E.ok(c+3>>8*(d?3-f:f)}function y(a,b,c){E.ok("number"==typeof a,"cannot write a non-number as a number"),E.ok(b>=a,"value larger than maximum allowed value"),E.ok(a>=c,"value smaller than minimum allowed value"),E.ok(Math.floor(a)===a,"value has a fractional component")}function z(a,b,c){E.ok("number"==typeof a,"cannot write a non-number as a number"),E.ok(b>=a,"value larger than maximum allowed value"),E.ok(a>=c,"value smaller than minimum allowed value")}function A(a,b,c,d,e){e||(E.ok(void 0!==b&&null!==b,"missing value"),E.ok("boolean"==typeof d,"missing or invalid endian"),E.ok(void 0!==c&&null!==c,"missing offset"),E.ok(c+1=0?w(a,b,c,d,e):w(a,65535+b+1,c,d,e)}function B(a,b,c,d,e){e||(E.ok(void 0!==b&&null!==b,"missing value"),E.ok("boolean"==typeof d,"missing or invalid endian"),E.ok(void 0!==c&&null!==c,"missing offset"),E.ok(c+3=0?x(a,b,c,d,e):x(a,4294967295+b+1,c,d,e) }function C(b,c,d,e,f){f||(E.ok(void 0!==c&&null!==c,"missing value"),E.ok("boolean"==typeof e,"missing or invalid endian"),E.ok(void 0!==d&&null!==d,"missing offset"),E.ok(d+3a||a>=this.length)throw new Error("oob");return this[a]},e.prototype.set=function(a,b){if(0>a||a>=this.length)throw new Error("oob");return this[a]=b},e.byteLength=function(a,b){switch(b||"utf8"){case"hex":return a.length/2;case"utf8":case"utf-8":return k(a).length;case"ascii":case"binary":return a.length;case"base64":return m(a).length;default:throw new Error("Unknown encoding")}},e.prototype.utf8Write=function(a,b,c){return e._charsWritten=n(k(a),this,b,c)},e.prototype.asciiWrite=function(a,b,c){return e._charsWritten=n(l(a),this,b,c)},e.prototype.binaryWrite=e.prototype.asciiWrite,e.prototype.base64Write=function(a,b,c){return e._charsWritten=n(m(a),this,b,c)},e.prototype.base64Slice=function(){var b=Array.prototype.slice.apply(this,arguments);return a("base64-js").fromByteArray(b)},e.prototype.utf8Slice=function(){for(var a=Array.prototype.slice.apply(this,arguments),b="",c="",d=0;dd;d++)if(a[d]=j(this[d]),d==c.INSPECT_MAX_BYTES){a[d+1]="...";break}return""},e.prototype.hexSlice=function(a,b){var c=this.length;(!a||0>a)&&(a=0),(!b||0>b||b>c)&&(b=c);for(var d="",e=a;b>e;e++)d+=j(this[e]);return d},e.prototype.toString=function(a,b,c){if(a=String(a||"utf8").toLowerCase(),b=+b||0,"undefined"==typeof c&&(c=this.length),+c==b)return"";switch(a){case"hex":return this.hexSlice(b,c);case"utf8":case"utf-8":return this.utf8Slice(b,c);case"ascii":return this.asciiSlice(b,c);case"binary":return this.binarySlice(b,c);case"base64":return this.base64Slice(b,c);case"ucs2":case"ucs-2":return this.ucs2Slice(b,c);default:throw new Error("Unknown encoding")}},e.prototype.hexWrite=function(a,b,c){b=+b||0;var d=this.length-b;c?(c=+c,c>d&&(c=d)):c=d;var f=a.length;if(f%2)throw new Error("Invalid hex string");c>f/2&&(c=f/2);for(var g=0;c>g;g++){var h=parseInt(a.substr(2*g,2),16);if(isNaN(h))throw new Error("Invalid hex string");this[b+g]=h}return e._charsWritten=2*g,g},e.prototype.write=function(a,b,c,d){if(isFinite(b))isFinite(c)||(d=c,c=void 0);else{var e=d;d=b,b=c,c=e}b=+b||0;var f=this.length-b;switch(c?(c=+c,c>f&&(c=f)):c=f,d=String(d||"utf8").toLowerCase()){case"hex":return this.hexWrite(a,b,c);case"utf8":case"utf-8":return this.utf8Write(a,b,c);case"ascii":return this.asciiWrite(a,b,c);case"binary":return this.binaryWrite(a,b,c);case"base64":return this.base64Write(a,b,c);case"ucs2":case"ucs-2":return this.ucs2Write(a,b,c);default:throw new Error("Unknown encoding")}},e.prototype.slice=function(a,b){var c=this.length;return a=f(a,c,0),b=f(b,c,c),new e(this,b-a,+a)},e.prototype.copy=function(a,b,c,d){var e=this;if(c||(c=0),(void 0===d||isNaN(d))&&(d=this.length),b||(b=0),c>d)throw new Error("sourceEnd < sourceStart");if(d===c)return 0;if(0==a.length||0==e.length)return 0;if(0>b||b>=a.length)throw new Error("targetStart out of bounds");if(0>c||c>=e.length)throw new Error("sourceStart out of bounds");if(0>d||d>e.length)throw new Error("sourceEnd out of bounds");d>this.length&&(d=this.length),a.length-bg;g++)E.ok("undefined"!=typeof this[g],"copying undefined buffer bytes!"),f.push(this[g]);for(var g=b;gc)throw new Error("end < start");if(c===b)return 0;if(0==this.length)return 0;if(0>b||b>=this.length)throw new Error("start out of bounds");if(0>c||c>this.length)throw new Error("end out of bounds");for(var d=b;c>d;d++)this[d]=a},e.isBuffer=function(a){return a instanceof e||a instanceof e},e.concat=function(a,b){if(!h(a))throw new Error("Usage: Buffer.concat(list, [totalLength])\n list should be an Array.");if(0===a.length)return new e(0);if(1===a.length)return a[0];if("number"!=typeof b){b=0;for(var c=0;c=c.length?void 0:c[a]},e.prototype.readUInt16LE=function(a,b){return p(this,a,!1,b)},e.prototype.readUInt16BE=function(a,b){return p(this,a,!0,b)},e.prototype.readUInt32LE=function(a,b){return q(this,a,!1,b)},e.prototype.readUInt32BE=function(a,b){return q(this,a,!0,b)},e.prototype.readInt8=function(a,b){var c,d=this;return b||(E.ok(void 0!==a&&null!==a,"missing offset"),E.ok(a=d.length?void 0:(c=128&d[a],c?-1*(255-d[a]+1):d[a])},e.prototype.readInt16LE=function(a,b){return r(this,a,!1,b)},e.prototype.readInt16BE=function(a,b){return r(this,a,!0,b)},e.prototype.readInt32LE=function(a,b){return s(this,a,!1,b)},e.prototype.readInt32BE=function(a,b){return s(this,a,!0,b)},e.prototype.readFloatLE=function(a,b){return t(this,a,!1,b)},e.prototype.readFloatBE=function(a,b){return t(this,a,!0,b)},e.prototype.readDoubleLE=function(a,b){return u(this,a,!1,b)},e.prototype.readDoubleBE=function(a,b){return u(this,a,!0,b)},e.prototype.writeUInt8=function(a,b,c){var d=this;c||(E.ok(void 0!==a&&null!==a,"missing value"),E.ok(void 0!==b&&null!==b,"missing offset"),E.ok(b=0?d.writeUInt8(a,b,c):d.writeUInt8(255+a+1,b,c)},e.prototype.writeInt16LE=function(a,b,c){A(this,a,b,!1,c)},e.prototype.writeInt16BE=function(a,b,c){A(this,a,b,!0,c)},e.prototype.writeInt32LE=function(a,b,c){B(this,a,b,!1,c)},e.prototype.writeInt32BE=function(a,b,c){B(this,a,b,!0,c)},e.prototype.writeFloatLE=function(a,b,c){C(this,a,b,!1,c)},e.prototype.writeFloatBE=function(a,b,c){C(this,a,b,!0,c)},e.prototype.writeDoubleLE=function(a,b,c){D(this,a,b,!1,c)},e.prototype.writeDoubleBE=function(a,b,c){D(this,a,b,!0,c)}},{"./buffer_ieee754":9,assert:3,"base64-js":11}],11:[function(a,b){!function(){"use strict";function a(a){var b,c,e,f,g,h;if(a.length%4>0)throw"Invalid string. Length must be a multiple of 4";for(g=a.indexOf("="),g=g>0?a.length-g:0,h=[],e=g>0?a.length-4:a.length,b=0,c=0;e>b;b+=4,c+=3)f=d.indexOf(a[b])<<18|d.indexOf(a[b+1])<<12|d.indexOf(a[b+2])<<6|d.indexOf(a[b+3]),h.push((16711680&f)>>16),h.push((65280&f)>>8),h.push(255&f);return 2===g?(f=d.indexOf(a[b])<<2|d.indexOf(a[b+1])>>4,h.push(255&f)):1===g&&(f=d.indexOf(a[b])<<10|d.indexOf(a[b+1])<<4|d.indexOf(a[b+2])>>2,h.push(255&f>>8),h.push(255&f)),h}function c(a){function b(a){return d[63&a>>18]+d[63&a>>12]+d[63&a>>6]+d[63&a]}var c,e,f,g=a.length%3,h="";for(c=0,f=a.length-g;f>c;c+=3)e=(a[c]<<16)+(a[c+1]<<8)+a[c+2],h+=b(e);switch(g){case 1:e=a[a.length-1],h+=d[e>>2],h+=d[63&e<<4],h+="==";break;case 2:e=(a[a.length-2]<<8)+a[a.length-1],h+=d[e>>10],h+=d[63&e>>4],h+=d[63&e<<2],h+="="}return h}var d="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";b.exports.toByteArray=a,b.exports.fromByteArray=c}()},{}],12:[function(a,b){var c=b.exports={};c.nextTick=function(){var a="undefined"!=typeof window&&window.setImmediate,b="undefined"!=typeof window&&window.postMessage&&window.addEventListener;if(a)return function(a){return window.setImmediate(a)};if(b){var c=[];return window.addEventListener("message",function(a){if(a.source===window&&"process-tick"===a.data&&(a.stopPropagation(),c.length>0)){var b=c.shift();b()}},!0),function(a){c.push(a),window.postMessage("process-tick","*")}}return function(a){setTimeout(a,0)}}(),c.title="browser",c.browser=!0,c.env={},c.argv=[],c.binding=function(){throw new Error("process.binding is not supported")},c.cwd=function(){return"/"},c.chdir=function(){throw new Error("process.chdir is not supported")}},{}],13:[function(b,c,d){var e="undefined"!=typeof self?self:"undefined"!=typeof window?window:{};(function(){function b(a,b,c){for(var d=(c||0)-1,e=a?a.length:0;++d-1?0:-1:a?0:-1}function g(a){var b=this.cache,c=typeof a;if("boolean"==c||null==a)b[a]=!0;else{"number"!=c&&"string"!=c&&(c="object");var d="number"==c?a:w+a,e=b[c]||(b[c]={});"object"==c?(e[d]||(e[d]=[])).push(a):e[d]=!0}}function h(a){return a.charCodeAt(0)}function i(a,b){var c=a.criteria,d=b.criteria;if(c!==d){if(c>d||"undefined"==typeof c)return 1;if(d>c||"undefined"==typeof d)return-1}return a.index-b.index}function j(a){var b=-1,c=a.length,d=a[0],e=a[0|c/2],f=a[c-1];if(d&&"object"==typeof d&&e&&"object"==typeof e&&f&&"object"==typeof f)return!1;var h=m();h["false"]=h["null"]=h["true"]=h.undefined=!1;var i=m();for(i.array=a,i.cache=h,i.push=g;++be?0:e);++d-1:void 0}),q&&(o(e),o(f)),g}function y(a,b,c,d,e){(Xd(b)?Tb:fe)(b,function(b,f){var g,h,i=b,j=a[f];if(b&&((h=Xd(b))||ge(b))){for(var k=d.length;k--;)if(g=d[k]==b){j=e[k];break}if(!g){var l;c&&(i=c(j,b),(l="undefined"!=typeof i)&&(j=i)),l||(j=h?Xd(j)?j:[]:ge(j)?j:{}),d.push(b),e.push(j),l||y(j,b,c,d,e)}}else c&&(i=c(j,b),"undefined"==typeof i&&(i=b)),"undefined"!=typeof i&&(j=i);a[f]=j})}function $(a,c,d){var e=-1,g=gb(),h=a?a.length:0,i=[],k=!c&&h>=x&&g===b,m=d||k?l():i;if(k){var n=j(m);n?(g=f,m=n):(k=!1,m=d?m:(o(m),i))}for(;++e3&&"function"==typeof b[c-2])var d=g(b[--c-1],b[c--],2);else c>2&&"function"==typeof b[c-1]&&(d=b[--c]);for(var e=Rd.call(arguments,1,c),f=-1,h=l(),i=l();++fc?Nd(0,f+c):c)||0,Xd(a)?g=e(a,b,c)>-1:"number"==typeof f?g=(Fb(a)?a.indexOf(b,c):e(a,b,c))>-1:fe(a,function(a){return++d>=c?!(g=a===b):void 0}),g}function Pb(a,b,d){var e=!0;b=c.createCallback(b,d,3);var f=-1,g=a?a.length:0;if("number"==typeof g)for(;++ff&&(f=j)}else b=!b&&Fb(a)?h:c.createCallback(b,d,3),Tb(a,function(a,c,d){var g=b(a,c,d);g>e&&(e=g,f=a)});return f}function Yb(a,b,d){var e=1/0,f=e;if(!b&&Xd(a))for(var g=-1,i=a.length;++gj&&(f=j)}else b=!b&&Fb(a)?h:c.createCallback(b,d,3),Tb(a,function(a,c,d){var g=b(a,c,d);e>g&&(e=g,f=a)});return f}function Zb(a,b){var c=-1,d=a?a.length:0;if("number"==typeof d)for(var e=fd(d);++c=x&&d===b;if(i){var k=j(g);k?(d=f,g=k):i=!1}for(;++cd?Nd(0,e+d):d||0}else if(d){var f=wc(a,c);return a[f]===c?f:-1}return b(a,c,d)}function oc(a,b,d){var e=0,f=a?a.length:0;if("number"!=typeof b&&null!=b){var g=f;for(b=c.createCallback(b,d,3);g--&&b(a[g],g,a);)e++}else e=null==b||d?1:b||e;return q(a,0,Od(Nd(0,f-e),f))}function pc(a){for(var c=arguments,d=c.length,e=-1,g=l(),h=-1,i=gb(),k=a?a.length:0,m=[],n=l();++e=x&&j(e?c[e]:n)}a:for(;++hc?Nd(0,d+c):Od(c,d-1))+1);d--;)if(a[d]===b)return d;return-1}function sc(a){for(var b=arguments,c=0,d=b.length,e=a?a.length:0;++cf;){var h=f+g>>>1;d(a[h])1?arguments:arguments[0],b=-1,c=a?Xb(Zb(a,"length")):0,d=fd(0>c?0:c);++b2?bb(a,17,Rd.call(arguments,2),null,b):bb(a,1,null,null,b)}function Ec(a){for(var b=arguments.length>1?t(arguments,!0,!1,1):qb(a),c=-1,d=b.length;++c2?bb(b,19,Rd.call(arguments,2),null,a):bb(b,3,null,null,a)}function Gc(){for(var a=arguments,b=a.length;b--;)if(!zb(a[b]))throw new od;return function(){for(var b=arguments,c=a.length;c--;)b=[a[c].apply(this,b)];return b[0]}}function Hc(a,b,c){var d=typeof a;if(null==a||"function"==d)return g(a,b,c);if("object"!=d)return function(b){return b[a]};var e=Zd(a),f=e[0],h=a[f];return 1!=e.length||h!==h||Ab(h)?function(b){for(var c=e.length,d=!1;c--&&(d=u(b[e[c]],a[e[c]],null,!0)););return d}:function(a){var b=a[f];return h===b&&(0!==h||1/h==1/b)}}function Ic(a,b){return b="number"==typeof b?b:+b||a.length,bb(a,4,null,null,null,b)}function Jc(a,b,c){var d,e,f,g,h,i,j,k=0,l=!1,m=!0;if(!zb(a))throw new od;if(b=Nd(0,b)||0,c===!0){var n=!0;m=!1}else Ab(c)&&(n=c.leading,l="maxWait"in c&&(Nd(b,c.maxWait)||0),m="trailing"in c?c.trailing:m);var o=function(){var c=b-(zd()-g);if(0>=c){e&&ud(e);var l=j;e=i=j=s,l&&(k=zd(),f=a.apply(h,d))}else i=Cd(o,c)},p=function(){i&&ud(i),e=i=j=s,(m||l!==b)&&(k=zd(),f=a.apply(h,d))};return function(){if(d=arguments,g=zd(),h=this,j=m&&(i||!n),l===!1)var c=n&&!i;else{e||n||(k=g);var q=l-(g-k);0>=q?(e&&(e=ud(e)),k=g,f=a.apply(h,d)):e||(e=Cd(p,q))}return i||b===l||(i=Cd(o,b)),c&&(f=a.apply(h,d)),f}}function Kc(a){if(!zb(a))throw new od;var b=Rd.call(arguments,1);return Cd(function(){a.apply(s,b)},1)}function Lc(a,b){if(!zb(a))throw new od;var c=Rd.call(arguments,2);return Cd(function(){a.apply(s,c)},b)}function Mc(a,b){if(!zb(a))throw new od;var c=function(){var d=c.cache,e=b?b.apply(this,arguments):w+arguments[0];return yd.call(d,e)?d[e]:d[e]=a.apply(this,arguments)};return c.cache={},c}function Nc(a){var b,c;if(!zb(a))throw new od;return function(){return b?c:(b=!0,c=a.apply(this,arguments),a=null,c)}}function Oc(a){return bb(a,16,Rd.call(arguments,1))}function Pc(a){return bb(a,32,null,Rd.call(arguments,1))}function Qc(a,b,c){var d=!0,e=!0;if(!zb(a))throw new od;c===!1?d=!1:Ab(c)&&(d="leading"in c?c.leading:d,e="trailing"in c?c.trailing:e),X.leading=d,X.maxWait=b,X.trailing=e;var f=Jc(a,b,X);return f}function Rc(a,b){if(!zb(b))throw new od;return function(){var c=[a];return Ad.apply(c,arguments),b.apply(this,c)}}function Sc(a){return null==a?"":nd(a).replace(be,fb)}function Tc(a){return a}function Uc(a,b){var e=a,f=!b||zb(e);b||(e=d,b=a,a=c),Tb(qb(b),function(c){var d=a[c]=b[c];f&&(e.prototype[c]=function(){var b=this.__wrapped__,c=[b];Ad.apply(c,arguments);var f=d.apply(a,c);return b&&"object"==typeof b&&b===f?this:(f=new e(f),f.__chain__=this.__chain__,f)})})}function Vc(){return a._=rd,this}function Wc(a,b,c){var d=null==a,e=null==b;null==c&&("boolean"==typeof a&&e?(c=a,a=1):e||"boolean"!=typeof b||(c=b,e=!0)),d&&e&&(b=1),a=+a||0,e?(b=a,a=0):b=+b||0;var f=Qd();return c||a%1||b%1?Od(a+f*(b-a+parseFloat("1e-"+((f+"").length-1))),b):a+vd(f*(b-a+1))}function Xc(a,b){if(a){var c=a[b];return zb(c)?a[b]():c}}function Yc(a,b,d){var e=c.templateSettings;a||(a=""),d=de({},d,e);var f,g=de({},d.imports,e.imports),h=Zd(g),i=Mb(g),j=0,l=d.interpolate||I,m="__p += '",n=md((d.escape||I).source+"|"+l.source+"|"+(l===G?D:I).source+"|"+(d.evaluate||I).source+"|$","g");a.replace(n,function(b,c,d,e,g,h){return d||(d=e),m+=a.slice(j,h).replace(K,k),c&&(m+="' +\n__e("+c+") +\n'"),g&&(f=!0,m+="';\n"+g+";\n__p += '"),d&&(m+="' +\n((__t = ("+d+")) == null ? '' : __t) +\n'"),j=h+b.length,b}),m+="';\n";var o=d.variable,p=o;p||(o="obj",m="with ("+o+") {\n"+m+"\n}\n"),m=(f?m.replace(A,""):m).replace(B,"$1").replace(C,"$1;"),m="function("+o+") {\n"+(p?"":o+" || ("+o+" = {});\n")+"var __t, __p = '', __e = _.escape"+(f?", __j = Array.prototype.join;\nfunction print() { __p += __j.call(arguments, '') }\n":";\n")+m+"return __p\n}";var q="\n/*\n//# sourceURL="+(d.sourceURL||"/lodash/template/source["+M++ +"]")+"\n*/";try{var r=id(h,"return "+m+q).apply(s,i)}catch(t){throw t.source=m,t}return b?r(b):(r.source=m,r)}function Zc(a,b,c){a=(a=+a)>-1?a:0;var d=-1,e=fd(a);for(b=g(b,c,1);++d/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:G,variable:"",imports:{_:c}},Id||(db=function(a){if(Ab(a)){n.prototype=a;var b=new n;n.prototype=null}return b||{}});var Wd=Gd?function(a,b){Y.value=b,Gd(a,"__bindData__",Y)}:n,Xd=Jd||function(a){return a&&"object"==typeof a&&"number"==typeof a.length&&Ed.call(a)==O||!1},Yd=function(a){var b,c=a,d=[];if(!c)return d;if(!Z[typeof a])return d;for(b in c)yd.call(c,b)&&d.push(b);return d},Zd=Md?function(a){return Ab(a)?Md(a):[]}:Yd,$d={"&":"&","<":"<",">":">",'"':""","'":"'"},_d=sb($d),ae=md("("+Zd(_d).join("|")+")","g"),be=md("["+Zd($d).join("")+"]","g"),ce=function(a,b,c){var d,e=a,f=e;if(!e)return f;var h=arguments,i=0,j="number"==typeof c?2:h.length;if(j>3&&"function"==typeof h[j-2])var k=g(h[--j-1],h[j--],2);else j>2&&"function"==typeof h[j-1]&&(k=h[--j]);for(;++i/g,H=RegExp("^["+z+"]*0+(?=.$)"),I=/($^)/,J=/\bthis\b/,K=/['\n\r\t\u2028\u2029\\]/g,L=["Array","Boolean","Date","Function","Math","Number","Object","RegExp","String","_","attachEvent","clearTimeout","isFinite","isNaN","parseInt","setImmediate","setTimeout"],M=0,N="[object Arguments]",O="[object Array]",P="[object Boolean]",Q="[object Date]",R="[object Function]",S="[object Number]",T="[object Object]",U="[object RegExp]",V="[object String]",W={};W[R]=!1,W[N]=W[O]=W[P]=W[Q]=W[S]=W[T]=W[U]=W[V]=!0;var X={leading:!1,maxWait:0,trailing:!1},Y={configurable:!1,enumerable:!1,value:null,writable:!1},Z={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,undefined:!1},$={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"},_=Z[typeof window]&&window||this,ab=Z[typeof d]&&d&&!d.nodeType&&d,bb=Z[typeof c]&&c&&!c.nodeType&&c,cb=bb&&bb.exports===ab&&ab,db=Z[typeof e]&&e;!db||db.global!==db&&db.window!==db||(_=db);var eb=r();"function"==typeof a&&"object"==typeof a.amd&&a.amd?(_._=eb,a(function(){return eb})):ab&&bb?cb?(bb.exports=eb)._=eb:ab._=eb:_._=eb}).call(this)},{}],14:[function(a){var b=a("./lib/connectors/angular"),c=a("./lib/transport"),d=a("./lib/client");angular.module("elasticsearch.client",[]).factory("esFactory",["$http","$q",function(a,e){return b.prototype.$http=a,c.prototype._request=c.prototype.request,c.prototype.request=function(a,b){var c=e.defer();return this._request(a,function(a,d,e){"function"==typeof b&&b(a,d,e),a?c.reject(a):c.resolve({body:d,status:e})}),c.promise},function(a){return a=a||{},a.connectionClass=b,new d(a)}}])},{"./lib/client":16,"./lib/connectors/angular":21,"./lib/transport":31}],15:[function(a,b){var c=a("./client_action");a("./errors");var d=b.exports={};d._namespaces=["cluster","indices"],d.bulk=c({methods:["POST","PUT"],params:{consistency:{type:"enum",options:["one","quorum","all"]},refresh:{type:"boolean"},replication:{type:"enum","default":"sync",options:["sync","async"]},type:{type:"string"}},urls:[{fmt:"/<%=index%>/<%=type%>/_bulk",req:{index:{type:"string"},type:{type:"string"}}},{fmt:"/<%=index%>/_bulk",req:{index:{type:"string"}}},{fmt:"/_bulk"}],bulkBody:!0}),d.clearScroll=c({methods:["DELETE"],params:{},urls:[{fmt:"/_search/scroll/<%=scrollId%>",req:{scrollId:{type:"list"}}}]}),d.cluster=function e(a){return this instanceof e?(this.client=a,void 0):new e(a)},d.cluster.prototype.getSettings=c({methods:["GET"],params:{},urls:[{fmt:"/_cluster/settings"}]}),d.cluster.prototype.health=c({methods:["GET"],params:{level:{type:"enum","default":"cluster",options:["cluster","indices","shards"]},local:{type:"boolean"},masterTimeout:{type:"time",name:"master_timeout"},timeout:{type:"time"},waitForActiveShards:{type:"number",name:"wait_for_active_shards"},waitForNodes:{type:"string",name:"wait_for_nodes"},waitForRelocatingShards:{type:"number",name:"wait_for_relocating_shards"},waitForStatus:{type:"enum","default":null,options:["green","yellow","red"],name:"wait_for_status"}},urls:[{fmt:"/_cluster/health/<%=index%>",req:{index:{type:"string"}}},{fmt:"/_cluster/health"}]}),d.cluster.prototype.nodeHotThreads=c({methods:["GET"],params:{interval:{type:"time"},snapshots:{type:"number"},threads:{type:"number"},type:{type:"enum",options:["cpu","wait","block"]}},urls:[{fmt:"/_nodes/<%=nodeId%>/hotthreads",req:{nodeId:{type:"list"}}},{fmt:"/_nodes/hotthreads"}]}),d.cluster.prototype.nodeInfo=c({methods:["GET"],params:{all:{type:"boolean"},clear:{type:"boolean"},http:{type:"boolean"},jvm:{type:"boolean"},network:{type:"boolean"},os:{type:"boolean"},plugin:{type:"boolean"},process:{type:"boolean"},settings:{type:"boolean"},threadPool:{type:"boolean",name:"thread_pool"},timeout:{type:"time"},transport:{type:"boolean"}},urls:[{fmt:"/_nodes/<%=nodeId%>",req:{nodeId:{type:"list"}}},{fmt:"/_nodes"}]}),d.cluster.prototype.nodeShutdown=c({methods:["POST"],params:{delay:{type:"time"},exit:{type:"boolean"}},urls:[{fmt:"/_cluster/nodes/<%=nodeId%>/_shutdown",req:{nodeId:{type:"list"}}},{fmt:"/_shutdown"}]}),d.cluster.prototype.nodeStats=c({methods:["GET"],params:{all:{type:"boolean"},clear:{type:"boolean"},fields:{type:"list"},fs:{type:"boolean"},http:{type:"boolean"},indices:{type:"boolean"},jvm:{type:"boolean"},network:{type:"boolean"},os:{type:"boolean"},process:{type:"boolean"},threadPool:{type:"boolean",name:"thread_pool"},transport:{type:"boolean"}},urls:[{fmt:"/_nodes/<%=nodeId%>/stats",req:{nodeId:{type:"list"}}},{fmt:"/_nodes/stats"}]}),d.cluster.prototype.putSettings=c({methods:["PUT"],params:{},urls:[{fmt:"/_cluster/settings"}]}),d.cluster.prototype.reroute=c({methods:["POST"],params:{dryRun:{type:"boolean",name:"dry_run"},filterMetadata:{type:"boolean",name:"filter_metadata"}},urls:[{fmt:"/_cluster/reroute"}]}),d.cluster.prototype.state=c({methods:["GET"],params:{filterBlocks:{type:"boolean",name:"filter_blocks"},filterIndexTemplates:{type:"boolean",name:"filter_index_templates"},filterIndices:{type:"list",name:"filter_indices"},filterMetadata:{type:"boolean",name:"filter_metadata"},filterNodes:{type:"boolean",name:"filter_nodes"},filterRoutingTable:{type:"boolean",name:"filter_routing_table"},local:{type:"boolean"},masterTimeout:{type:"time",name:"master_timeout"}},urls:[{fmt:"/_cluster/state"}]}),d.count=c({methods:["POST","GET"],params:{ignoreIndices:{type:"enum","default":"none",options:["none","missing"],name:"ignore_indices"},minScore:{type:"number",name:"min_score"},preference:{type:"string"},routing:{type:"string"},source:{type:"string"}},urls:[{fmt:"/<%=index%>/<%=type%>/_count",req:{index:{type:"list"},type:{type:"list"}}},{fmt:"/<%=index%>/_count",req:{index:{type:"list"}}},{fmt:"/_count"}]}),d.create=c({methods:["POST","PUT"],params:{consistency:{type:"enum",options:["one","quorum","all"]},id:{type:"string"},parent:{type:"string"},percolate:{type:"string"},refresh:{type:"boolean"},replication:{type:"enum","default":"sync",options:["sync","async"]},routing:{type:"string"},timeout:{type:"time"},timestamp:{type:"time"},ttl:{type:"duration"},version:{type:"number"},versionType:{type:"enum",options:["internal","external"],name:"version_type"}},urls:[{fmt:"/<%=index%>/<%=type%>/<%=id%>/_create",req:{index:{type:"string"},type:{type:"string"},id:{type:"string"}}},{fmt:"/<%=index%>/<%=type%>",req:{index:{type:"string"},type:{type:"string"}}}]}),d["delete"]=c({methods:["DELETE"],params:{consistency:{type:"enum",options:["one","quorum","all"]},parent:{type:"string"},refresh:{type:"boolean"},replication:{type:"enum","default":"sync",options:["sync","async"]},routing:{type:"string"},timeout:{type:"time"},version:{type:"number"},versionType:{type:"enum",options:["internal","external"],name:"version_type"}},urls:[{fmt:"/<%=index%>/<%=type%>/<%=id%>",req:{index:{type:"string"},type:{type:"string"},id:{type:"string"}}}]}),d.deleteByQuery=c({methods:["DELETE"],params:{analyzer:{type:"string"},consistency:{type:"enum",options:["one","quorum","all"]},defaultOperator:{type:"enum","default":"OR",options:["AND","OR"],name:"default_operator"},df:{type:"string"},ignoreIndices:{type:"enum","default":"none",options:["none","missing"],name:"ignore_indices"},replication:{type:"enum","default":"sync",options:["sync","async"]},q:{type:"string"},routing:{type:"string"},source:{type:"string"},timeout:{type:"time"}},urls:[{fmt:"/<%=index%>/<%=type%>/_query",req:{index:{type:"list"},type:{type:"list"}}},{fmt:"/<%=index%>/_query",req:{index:{type:"list"}}}]}),d.exists=c({methods:["HEAD"],params:{parent:{type:"string"},preference:{type:"string"},realtime:{type:"boolean"},refresh:{type:"boolean"},routing:{type:"string"}},urls:[{fmt:"/<%=index%>/<%=type%>/<%=id%>",opt:{type:{type:"string","default":"_all"}},req:{index:{type:"string"},id:{type:"string"}}}],castExists:!0}),d.explain=c({methods:["GET","POST"],params:{analyzeWildcard:{type:"boolean",name:"analyze_wildcard"},analyzer:{type:"string"},defaultOperator:{type:"enum","default":"OR",options:["AND","OR"],name:"default_operator"},df:{type:"string"},fields:{type:"list"},lenient:{type:"boolean"},lowercaseExpandedTerms:{type:"boolean",name:"lowercase_expanded_terms"},parent:{type:"string"},preference:{type:"string"},q:{type:"string"},routing:{type:"string"},source:{type:"string"},_source:{type:"list",name:"_source"},_sourceExclude:{type:"list",name:"_source_exclude"},_sourceInclude:{type:"list",name:"_source_include"}},urls:[{fmt:"/<%=index%>/<%=type%>/<%=id%>/_explain",req:{index:{type:"string"},type:{type:"string"},id:{type:"string"}}}]}),d.get=c({methods:["GET"],params:{fields:{type:"list"},parent:{type:"string"},preference:{type:"string"},realtime:{type:"boolean"},refresh:{type:"boolean"},routing:{type:"string"},_source:{type:"list",name:"_source"},_sourceExclude:{type:"list",name:"_source_exclude"},_sourceInclude:{type:"list",name:"_source_include"}},urls:[{fmt:"/<%=index%>/<%=type%>/<%=id%>",opt:{type:{type:"string","default":"_all"}},req:{index:{type:"string"},id:{type:"string"}}}]}),d.getSource=c({methods:["GET"],params:{exclude:{type:"list"},include:{type:"list"},parent:{type:"string"},preference:{type:"string"},realtime:{type:"boolean"},refresh:{type:"boolean"},routing:{type:"string"}},urls:[{fmt:"/<%=index%>/<%=type%>/<%=id%>/_source",opt:{type:{type:"string","default":"_all"}},req:{index:{type:"string"},id:{type:"string"}}}]}),d.index=c({methods:["POST","PUT"],params:{consistency:{type:"enum",options:["one","quorum","all"]},opType:{type:"enum","default":"index",options:["index","create"],name:"op_type"},parent:{type:"string"},percolate:{type:"string"},refresh:{type:"boolean"},replication:{type:"enum","default":"sync",options:["sync","async"]},routing:{type:"string"},timeout:{type:"time"},timestamp:{type:"time"},ttl:{type:"duration"},version:{type:"number"},versionType:{type:"enum",options:["internal","external"],name:"version_type"}},urls:[{fmt:"/<%=index%>/<%=type%>/<%=id%>",req:{index:{type:"string"},type:{type:"string"},id:{type:"string"}}},{fmt:"/<%=index%>/<%=type%>",req:{index:{type:"string"},type:{type:"string"}}}]}),d.indices=function f(a){return this instanceof f?(this.client=a,void 0):new f(a)},d.indices.prototype.analyze=c({methods:["GET","POST"],params:{analyzer:{type:"string"},field:{type:"string"},filters:{type:"list"},index:{type:"string"},preferLocal:{type:"boolean",name:"prefer_local"},text:{type:"string"},tokenizer:{type:"string"},format:{type:"enum","default":"detailed",options:["detailed","text"]}},urls:[{fmt:"/<%=index%>/_analyze",req:{index:{type:"string"}}},{fmt:"/_analyze"}]}),d.indices.prototype.clearCache=c({methods:["POST","GET"],params:{fieldData:{type:"boolean",name:"field_data"},fielddata:{type:"boolean"},fields:{type:"list"},filter:{type:"boolean"},filterCache:{type:"boolean",name:"filter_cache"},filterKeys:{type:"boolean",name:"filter_keys"},id:{type:"boolean"},idCache:{type:"boolean",name:"id_cache"},ignoreIndices:{type:"enum","default":"none",options:["none","missing"],name:"ignore_indices"},index:{type:"list"},recycler:{type:"boolean"}},urls:[{fmt:"/<%=index%>/_cache/clear",req:{index:{type:"list"}}},{fmt:"/_cache/clear"}]}),d.indices.prototype.close=c({methods:["POST"],params:{timeout:{type:"time"},masterTimeout:{type:"time",name:"master_timeout"}},urls:[{fmt:"/<%=index%>/_close",req:{index:{type:"string"}}}]}),d.indices.prototype.create=c({methods:["PUT","POST"],params:{timeout:{type:"time"},masterTimeout:{type:"time",name:"master_timeout"}},urls:[{fmt:"/<%=index%>",req:{index:{type:"string"}}}]}),d.indices.prototype["delete"]=c({methods:["DELETE"],params:{timeout:{type:"time"},masterTimeout:{type:"time",name:"master_timeout"}},urls:[{fmt:"/<%=index%>",req:{index:{type:"list"}}},{fmt:"/"}]}),d.indices.prototype.deleteAlias=c({methods:["DELETE"],params:{timeout:{type:"time"},masterTimeout:{type:"time",name:"master_timeout"}},urls:[{fmt:"/<%=index%>/_alias/<%=name%>",req:{index:{type:"string"},name:{type:"string"}}}]}),d.indices.prototype.deleteMapping=c({methods:["DELETE"],params:{masterTimeout:{type:"time",name:"master_timeout"}},urls:[{fmt:"/<%=index%>/<%=type%>",req:{index:{type:"list"},type:{type:"string"}}}]}),d.indices.prototype.deleteTemplate=c({methods:["DELETE"],params:{timeout:{type:"time"},masterTimeout:{type:"time",name:"master_timeout"}},urls:[{fmt:"/_template/<%=name%>",req:{name:{type:"string"}}}]}),d.indices.prototype.deleteWarmer=c({methods:["DELETE"],params:{masterTimeout:{type:"time",name:"master_timeout"}},urls:[{fmt:"/<%=index%>/<%=type%>/_warmer/<%=name%>",req:{index:{type:"list"},type:{type:"list"},name:{type:"string"}}},{fmt:"/<%=index%>/_warmer/<%=name%>",req:{index:{type:"list"},name:{type:"string"}}},{fmt:"/<%=index%>/_warmer",req:{index:{type:"list"}}}]}),d.indices.prototype.exists=c({methods:["HEAD"],params:{},urls:[{fmt:"/<%=index%>",req:{index:{type:"list"}}}],castExists:!0}),d.indices.prototype.existsAlias=c({methods:["HEAD"],params:{ignoreIndices:{type:"enum","default":"none",options:["none","missing"],name:"ignore_indices"}},urls:[{fmt:"/<%=index%>/_alias/<%=name%>",req:{index:{type:"list"},name:{type:"list"}}},{fmt:"/_alias/<%=name%>",req:{name:{type:"list"}}}],castExists:!0}),d.indices.prototype.existsType=c({methods:["HEAD"],params:{ignoreIndices:{type:"enum","default":"none",options:["none","missing"],name:"ignore_indices"}},urls:[{fmt:"/<%=index%>/<%=type%>",req:{index:{type:"list"},type:{type:"list"}}}],castExists:!0}),d.indices.prototype.flush=c({methods:["POST","GET"],params:{force:{type:"boolean"},full:{type:"boolean"},ignoreIndices:{type:"enum","default":"none",options:["none","missing"],name:"ignore_indices"},refresh:{type:"boolean"}},urls:[{fmt:"/<%=index%>/_flush",req:{index:{type:"list"}}},{fmt:"/_flush"}]}),d.indices.prototype.getAlias=c({methods:["GET"],params:{ignoreIndices:{type:"enum","default":"none",options:["none","missing"],name:"ignore_indices"}},urls:[{fmt:"/<%=index%>/_alias/<%=name%>",req:{index:{type:"list"},name:{type:"list"}}},{fmt:"/_alias/<%=name%>",req:{name:{type:"list"}}}]}),d.indices.prototype.getAliases=c({methods:["GET"],params:{timeout:{type:"time"}},urls:[{fmt:"/<%=index%>/_aliases",req:{index:{type:"list"}}},{fmt:"/_aliases"}]}),d.indices.prototype.getMapping=c({methods:["GET"],params:{},urls:[{fmt:"/<%=index%>/<%=type%>/_mapping",req:{index:{type:"list"},type:{type:"list"}}},{fmt:"/<%=index%>/_mapping",req:{index:{type:"list"}}},{fmt:"/_mapping"}]}),d.indices.prototype.getSettings=c({methods:["GET"],params:{},urls:[{fmt:"/<%=index%>/_settings",req:{index:{type:"list"}}},{fmt:"/_settings"}]}),d.indices.prototype.getTemplate=c({methods:["GET"],params:{},urls:[{fmt:"/_template/<%=name%>",req:{name:{type:"string"}}},{fmt:"/_template"}]}),d.indices.prototype.getWarmer=c({methods:["GET"],params:{},urls:[{fmt:"/<%=index%>/<%=type%>/_warmer/<%=name%>",req:{index:{type:"list"},type:{type:"list"},name:{type:"string"}}},{fmt:"/<%=index%>/_warmer/<%=name%>",req:{index:{type:"list"},name:{type:"string"}}},{fmt:"/<%=index%>/_warmer",req:{index:{type:"list"}}}]}),d.indices.prototype.open=c({methods:["POST"],params:{timeout:{type:"time"},masterTimeout:{type:"time",name:"master_timeout"}},urls:[{fmt:"/<%=index%>/_open",req:{index:{type:"string"}}}]}),d.indices.prototype.optimize=c({methods:["POST","GET"],params:{flush:{type:"boolean"},ignoreIndices:{type:"enum","default":"none",options:["none","missing"],name:"ignore_indices"},maxNumSegments:{type:"number",name:"max_num_segments"},onlyExpungeDeletes:{type:"boolean",name:"only_expunge_deletes"},operationThreading:{name:"operation_threading"},refresh:{type:"boolean"},waitForMerge:{type:"boolean",name:"wait_for_merge"}},urls:[{fmt:"/<%=index%>/_optimize",req:{index:{type:"list"}}},{fmt:"/_optimize"}]}),d.indices.prototype.putAlias=c({methods:["PUT"],params:{timeout:{type:"time"},masterTimeout:{type:"time",name:"master_timeout"}},urls:[{fmt:"/<%=index%>/_alias/<%=name%>",req:{index:{type:"string"},name:{type:"string"}}},{fmt:"/_alias/<%=name%>",req:{name:{type:"string"}}},{fmt:"/<%=index%>/_alias",req:{index:{type:"string"}}},{fmt:"/_alias"}]}),d.indices.prototype.putMapping=c({methods:["PUT","POST"],params:{ignoreConflicts:{type:"boolean",name:"ignore_conflicts"},timeout:{type:"time"},masterTimeout:{type:"time",name:"master_timeout"}},urls:[{fmt:"/<%=index%>/<%=type%>/_mapping",req:{index:{type:"list"},type:{type:"string"}}}]}),d.indices.prototype.putSettings=c({methods:["PUT"],params:{masterTimeout:{type:"time",name:"master_timeout"}},urls:[{fmt:"/<%=index%>/_settings",req:{index:{type:"list"}}},{fmt:"/_settings"}]}),d.indices.prototype.putTemplate=c({methods:["PUT","POST"],params:{order:{type:"number"},timeout:{type:"time"},masterTimeout:{type:"time",name:"master_timeout"}},urls:[{fmt:"/_template/<%=name%>",req:{name:{type:"string"}}}]}),d.indices.prototype.putWarmer=c({methods:["PUT"],params:{masterTimeout:{type:"time",name:"master_timeout"}},urls:[{fmt:"/<%=index%>/<%=type%>/_warmer/<%=name%>",req:{index:{type:"list"},type:{type:"list"},name:{type:"string"}}},{fmt:"/<%=index%>/_warmer/<%=name%>",req:{index:{type:"list"},name:{type:"string"}}}]}),d.indices.prototype.refresh=c({methods:["POST","GET"],params:{ignoreIndices:{type:"enum","default":"none",options:["none","missing"],name:"ignore_indices"},operationThreading:{name:"operation_threading"}},urls:[{fmt:"/<%=index%>/_refresh",req:{index:{type:"list"}}},{fmt:"/_refresh"}]}),d.indices.prototype.segments=c({methods:["GET"],params:{ignoreIndices:{type:"enum","default":"none",options:["none","missing"],name:"ignore_indices"},operationThreading:{name:"operation_threading"}},urls:[{fmt:"/<%=index%>/_segments",req:{index:{type:"list"}}},{fmt:"/_segments"}]}),d.indices.prototype.snapshotIndex=c({methods:["POST"],params:{ignoreIndices:{type:"enum","default":"none",options:["none","missing"],name:"ignore_indices"}},urls:[{fmt:"/<%=index%>/_gateway/snapshot",req:{index:{type:"list"}}},{fmt:"/_gateway/snapshot"}]}),d.indices.prototype.stats=c({methods:["GET"],params:{all:{type:"boolean"},clear:{type:"boolean"},completion:{type:"boolean"},completionFields:{type:"list",name:"completion_fields"},docs:{type:"boolean"},fielddata:{type:"boolean"},fielddataFields:{type:"list",name:"fielddata_fields"},fields:{type:"list"},filterCache:{type:"boolean",name:"filter_cache"},flush:{type:"boolean"},get:{type:"boolean"},groups:{type:"boolean"},idCache:{type:"boolean",name:"id_cache"},ignoreIndices:{type:"enum","default":"none",options:["none","missing"],name:"ignore_indices"},indexing:{type:"boolean"},merge:{type:"boolean"},refresh:{type:"boolean"},search:{type:"boolean"},store:{type:"boolean"},warmer:{type:"boolean"}},urls:[{fmt:"/<%=index%>/_stats",req:{index:{type:"list"}}},{fmt:"/_stats"}]}),d.indices.prototype.status=c({methods:["GET"],params:{ignoreIndices:{type:"enum","default":"none",options:["none","missing"],name:"ignore_indices"},operationThreading:{name:"operation_threading"},recovery:{type:"boolean"},snapshot:{type:"boolean"}},urls:[{fmt:"/<%=index%>/_status",req:{index:{type:"list"}}},{fmt:"/_status"}]}),d.indices.prototype.updateAliases=c({methods:["POST"],params:{timeout:{type:"time"},masterTimeout:{type:"time",name:"master_timeout"}},urls:[{fmt:"/_aliases"}]}),d.indices.prototype.validateQuery=c({methods:["GET","POST"],params:{explain:{type:"boolean"},ignoreIndices:{type:"enum","default":"none",options:["none","missing"],name:"ignore_indices"},operationThreading:{name:"operation_threading"},source:{type:"string"},q:{type:"string"}},urls:[{fmt:"/<%=index%>/<%=type%>/_validate/query",req:{index:{type:"list"},type:{type:"list"}}},{fmt:"/<%=index%>/_validate/query",req:{index:{type:"list"}}},{fmt:"/_validate/query"}]}),d.info=c({methods:["GET","HEAD"],params:{},urls:[{fmt:"/"}]}),d.mget=c({methods:["GET","POST"],params:{fields:{type:"list"},preference:{type:"string"},realtime:{type:"boolean"},refresh:{type:"boolean"},_source:{type:"list",name:"_source"},_sourceExclude:{type:"list",name:"_source_exclude"},_sourceInclude:{type:"list",name:"_source_include"}},urls:[{fmt:"/<%=index%>/<%=type%>/_mget",req:{index:{type:"string"},type:{type:"string"}}},{fmt:"/<%=index%>/_mget",req:{index:{type:"string"}}},{fmt:"/_mget"}]}),d.mlt=c({methods:["GET","POST"],params:{boostTerms:{type:"number",name:"boost_terms"},maxDocFreq:{type:"number",name:"max_doc_freq"},maxQueryTerms:{type:"number",name:"max_query_terms"},maxWordLen:{type:"number",name:"max_word_len"},minDocFreq:{type:"number",name:"min_doc_freq"},minTermFreq:{type:"number",name:"min_term_freq"},minWordLen:{type:"number",name:"min_word_len"},mltFields:{type:"list",name:"mlt_fields"},percentTermsToMatch:{type:"number",name:"percent_terms_to_match"},routing:{type:"string"},searchFrom:{type:"number",name:"search_from"},searchIndices:{type:"list",name:"search_indices"},searchQueryHint:{type:"string",name:"search_query_hint"},searchScroll:{type:"string",name:"search_scroll"},searchSize:{type:"number",name:"search_size"},searchSource:{type:"string",name:"search_source"},searchType:{type:"string",name:"search_type"},searchTypes:{type:"list",name:"search_types"},stopWords:{type:"list",name:"stop_words"}},urls:[{fmt:"/<%=index%>/<%=type%>/<%=id%>/_mlt",req:{index:{type:"string"},type:{type:"string"},id:{type:"string"}}}]}),d.msearch=c({methods:["GET","POST"],params:{searchType:{type:"enum",options:["query_then_fetch","query_and_fetch","dfs_query_then_fetch","dfs_query_and_fetch","count","scan"],name:"search_type"}},urls:[{fmt:"/<%=index%>/<%=type%>/_msearch",req:{index:{type:"list"},type:{type:"list"}}},{fmt:"/<%=index%>/_msearch",req:{index:{type:"list"}}},{fmt:"/_msearch"}],bulkBody:!0}),d.percolate=c({methods:["GET","POST"],params:{preferLocal:{type:"boolean",name:"prefer_local"}},urls:[{fmt:"/<%=index%>/<%=type%>/_percolate",req:{index:{type:"string"},type:{type:"string"}}}]}),d.scroll=c({methods:["GET","POST"],params:{scroll:{type:"duration"},scrollId:{type:"string",name:"scroll_id"}},urls:[{fmt:"/_search/scroll/<%=scrollId%>",req:{scrollId:{type:"string"}}},{fmt:"/_search/scroll"}]}),d.search=c({methods:["GET","POST"],params:{analyzer:{type:"string"},analyzeWildcard:{type:"boolean",name:"analyze_wildcard"},defaultOperator:{type:"enum","default":"OR",options:["AND","OR"],name:"default_operator"},df:{type:"string"},explain:{type:"boolean"},fields:{type:"list"},from:{type:"number"},ignoreIndices:{type:"enum","default":"none",options:["none","missing"],name:"ignore_indices"},indicesBoost:{type:"list",name:"indices_boost"},lenient:{type:"boolean"},lowercaseExpandedTerms:{type:"boolean",name:"lowercase_expanded_terms"},preference:{type:"string"},q:{type:"string"},routing:{type:"list"},scroll:{type:"duration"},searchType:{type:"enum",options:["query_then_fetch","query_and_fetch","dfs_query_then_fetch","dfs_query_and_fetch","count","scan"],name:"search_type"},size:{type:"number"},sort:{type:"list"},source:{type:"string"},_source:{type:"list",name:"_source"},_sourceExclude:{type:"list",name:"_source_exclude"},_sourceInclude:{type:"list",name:"_source_include"},stats:{type:"list"},suggestField:{type:"string",name:"suggest_field"},suggestMode:{type:"enum","default":"missing",options:["missing","popular","always"],name:"suggest_mode"},suggestSize:{type:"number",name:"suggest_size"},suggestText:{type:"text",name:"suggest_text"},timeout:{type:"time"},version:{type:"boolean"}},urls:[{fmt:"/<%=index%>/<%=type%>/_search",opt:{index:{type:"list","default":"_all"}},req:{type:{type:"list"}}},{fmt:"/<%=index%>/_search",opt:{index:{type:"list","default":"_all"}}}]}),d.suggest=c({methods:["POST","GET"],params:{ignoreIndices:{type:"enum","default":"none",options:["none","missing"],name:"ignore_indices"},preference:{type:"string"},routing:{type:"string"},source:{type:"string"}},urls:[{fmt:"/<%=index%>/_suggest",req:{index:{type:"list"}}},{fmt:"/_suggest"}]}),d.update=c({methods:["POST"],params:{consistency:{type:"enum",options:["one","quorum","all"]},fields:{type:"list"},lang:{type:"string"},parent:{type:"string"},percolate:{type:"string"},refresh:{type:"boolean"},replication:{type:"enum","default":"sync",options:["sync","async"]},retryOnConflict:{type:"number",name:"retry_on_conflict"},routing:{type:"string"},script:{},timeout:{type:"time"},timestamp:{type:"time"},ttl:{type:"duration"},version:{type:"number"},versionType:{type:"number",name:"version_type"}},urls:[{fmt:"/<%=index%>/<%=type%>/<%=id%>/_update",req:{index:{type:"string"},type:{type:"string"},id:{type:"string"}}}]})},{"./client_action":17,"./errors":22}],16:[function(a,b){function c(a){this.client=this,Object.defineProperty(this,"config",{configurable:!1,enumerable:!1,writable:!1,value:!a||d.isPlainObject(a)?new e(a):a}),this.config.client=this;for(var b=0;b1)this.config.selector(this.connections.alive,a);else try{d.nextTick(a,null,this.config.selector(this.connections.alive))}catch(b){this.config.log.error(b),a(b)}else a()},c.prototype.onStatusChanged=d.handler(function(a,b,c){var d,e,f;if(b===a)return!0;switch(this.config.log.info("connection id:",c.__id,"is",a),a){case"alive":d=this.connections.dead,e=this.connections.alive;break;case"dead":d=this.connections.alive,e=this.connections.dead;break;case"closed":d=this.connections[b]}d&&d.indexOf&&(f=d.indexOf(c),~f&&d.splice(f,1)),e&&e.indexOf&&(f=e.indexOf(c),~f||e.push(c))}),c.prototype._add=function(a){this.index[a.__id]||(this.index[a.__id]=a,a.on("status changed",this.bound.onStatusChanged),a.setStatus("alive"))},c.prototype._remove=function(a){this.index[a.__id]&&(delete this.index[a.__id],a.setStatus("closed"),a.removeListener("status changed",this.bound.onStatusChanged))},c.prototype.setNodes=function(a){var b,c,f,g,h=d.clone(this.index);for(c=0;ca?"0"+a.toString(10):a.toString(10)}function e(a,b){var c=f.repeat(" ",b||2);return a.split(/\r?\n/).map(function(a){return c+a}).join("\n")}var f=(a("./log"),a("./utils"));c.prototype.timestamp=function(){var a=new Date;return a.getUTCFullYear()+"-"+d(a.getUTCMonth()+1)+"-"+d(a.getUTCDate())+"T"+d(a.getUTCHours())+":"+d(a.getUTCMinutes())+":"+d(a.getUTCSeconds())+"Z"},c.prototype.format=function(a,b){return a+": "+this.timestamp()+"\n"+e(b)+"\n\n"},c.prototype.write=function(){throw new Error("This should be overwritten by the logger")},c.prototype.setupListeners=function(a){this.cleanUpListeners(),this.listeningLevels=a,f.each(this.listeningLevels,function(a){var b="on"+f.ucfirst(a);if(!this.bound[b])throw new Error(b+" is not a function");this.bridge.on(a,this.bound[b])},this)},c.prototype.cleanUpListeners=f.handler(function(){f.each(this.listeningLevels,function(a){this.bridge.removeListener(a,this.bound["on"+f.ucfirst(a)])},this)}),c.prototype.onError=f.handler(function(a){this.write("Error"===a.name?"ERROR":a.name,a.stack)}),c.prototype.onWarning=f.handler(function(a){this.write("WARNING",a)}),c.prototype.onInfo=f.handler(function(a){this.write("INFO",a)}),c.prototype.onDebug=f.handler(function(a){this.write("DEBUG",a)}),c.prototype.onTrace=f.handler(function(a,b,c,d,e){var f='curl "'+b.replace(/"/g,'\\"')+'" -X'+a.toUpperCase();c&&(f+=' -d "'+c.replace(/"/g,'\\"')+'"'),f+="\n<- "+e+"\n"+d,this.write("TRACE",f)}),b.exports=c},{"./log":24,"./utils":33}],26:[function(a,b){function c(a,b){d.call(this,a,b),this.color=e.has(a,"color")?!!a.color:!0}b.exports=c;var d=a("../logger"),e=a("../utils");e.inherits(c,d),c.prototype.setupListeners=function(a){this.bound.onWarning=this.onWarning,this.bound.onInfo=this.onInfo,this.bound.onDebug=this.onDebug,d.prototype.setupListeners.call(this,a)},c.prototype.onError=e.handler(function(a){console.error&&console.trace?(console.error("Error"===a.name?"ERROR":a.name),console.trace()):console.log("Error"===a.name?"ERROR":a.name,a.stack)}),c.prototype.onWarning=console[console.warn?"warn":"log"].bind(console,"WARNING"),c.prototype.onInfo=console[console.info?"info":"log"].bind(console,"INFO"),c.prototype.onDebug=console[console.debug?"debug":"log"].bind(console,"DEBUG"),c.prototype.onTrace=e.handler(function(a,b,c,d,e){var f='curl "'+b.replace(/"/g,'\\"')+'" -X'+a.toUpperCase();c&&(f+=' -d "'+c.replace(/"/g,'\\"')+'"'),f+="\n<- "+e+"\n"+d,console.log("TRACE",f)})},{"../logger":25,"../utils":33}],27:[function(a,b){b.exports={random:a("./random"),roundRobin:a("./round_robin")}},{"./random":28,"./round_robin":29}],28:[function(a,b){function c(a){return a[Math.floor(Math.random()*a.length)]}b.exports=c},{}],29:[function(a,b){function c(a){return a.unshift(a.pop()),a[0]}b.exports=c},{}],30:[function(a,b){function c(a){this.client=a}b.exports=c;var d=a("../utils");c.prototype.serialize=function(a,b,c){return null==a?null:"string"==typeof a?a:JSON.stringify(a,b,c)},c.prototype.unserialize=function(a){if("string"!=typeof a)return a;try{return JSON.parse(a)}catch(b){return this.client.log.error(new Error("unable to parse",a)),null}},c.prototype.bulkBody=function(a){var b,c="";if(d.isArray(a))for(b=0;bc||c>=300)&&!e.contains(h,c)&&(a=g[c]?new g[c](d&&d.error):new g.Generic("unknown error")),this._params.castExists&&(a&&a instanceof g.NotFound?(d=!1,a=void 0):d=!a),this._error=a,this._response={body:d,status:c},this.emit("done",this._error,this._response.body,this._response.status)}),c.prototype.abort=function(){return this.aborted=!0,this.__request?(this.__request.abort(),!0):!1},c.prototype.then=function(a,b){this._error?b(this._error):this._response?a(this._response):this.once("done",e.bindKey(this,"then",a,b))}},{"./errors":22,"./utils":33,__browserify_process:12,events:4}],33:[function(a,b){function c(a,b,c){return function(d){for(var e,f,g,h,i=0,j=[],k="";i=97&&122>=e,g=e>=65&&90>=e,(g||!h)&&(k.length&&j.push(k),k=""),(g||h)&&(h&&k.length?k+=f:k=!j.length&&a||j.length&&b?f.toUpperCase():f.toLowerCase());return k.length&&j.push(k),j.join(c)}}var d=a("__browserify_process"),e=a("path"),f=a("lodash"),g=a("util"),h=f.extend({},f,g);f=h,h.inspect=function(a,b){return g.inspect(a,f.defaults(b||{},{showHidden:!0,depth:null,color:!0}))},h.joinPath=e.join,h.reKey=function(a,b,c){if(void 0===c&&(c=!0),"function"!=typeof b)throw new TypeError("invalid transform function");var d={};return f.each(a,function(a,e){d[b(e)]=c&&"object"==typeof a?h.reKey(a,b,c):a}),d},h.deepMerge=function(a,b){return Object.keys(b).forEach(function(c){switch(typeof a[c]){case"undefined":a[c]=b[c];break;case"object":f.isArray(a[c])&&f.isArray(b[c])?a[c]=a[c].concat(b[c]):f.isPlainObject(a[c])&&f.isPlainObject(b[c])&&h.deepMerge(a[c],b[c])}}),a},"String Object PlainObject Array Finite Function RegExp".split(" ").forEach(function(a){var b=f.bindKey(f,"is"+a);h["isArrayOf"+a+"s"]=function(a){return f.isArray(a)&&f.every(a.slice(0,10),b)}}),h.ucfirst=function(a){return a[0].toUpperCase()+a.substring(1).toLowerCase()},h.studlyCase=c(!0,!0,""),h.camelCase=c(!1,!0,""),h.snakeCase=c(!1,!1,"_"),h.toLowerString=function(a){return a?"string"!=typeof a&&(a=a.toString()):a="",a.toLowerCase()},h.toUpperString=function(a){return a?"string"!=typeof a&&(a=a.toString()):a="",a.toUpperCase()},h.isNumeric=function(a){return!isNaN(null===a?0/0:1*a)};var i=/^(\d+(?:\.\d+)?)([Mwdhmsy])$/;h.isInterval=function(a){return!(!a.match||!a.match(i))},h.repeat=function(a,b){return new Array(b+1).join(a)},h.inherits=function(a,b){g.inherits(a,b),a.callSuper=function(a,c){c?f.isArguments(c)?h.applyArgs(b,a,c):h.applyArgs(b,a,arguments,1):b.call(a)}},h.trim=function(a){return"string"==typeof a?a.replace(/^\s+|\s+$/g,""):""},h.collectMatches=function(a,b){for(var c,d=[];(c=b.exec(a))&&(d.push(c),b.global===!0););return d},h.applyArgs=function(a,b,c,d){switch(d=d||0,c.length-d){case 0:return a.call(b);case 1:return a.call(b,c[0+d]);case 2:return a.call(b,c[0+d],c[1+d]);case 3:return a.call(b,c[0+d],c[1+d],c[2+d]);case 4:return a.call(b,c[0+d],c[1+d],c[2+d],c[3+d]);case 5:return a.call(b,c[0+d],c[1+d],c[2+d],c[3+d],c[4+d]);default:return a.apply(b,Array.prototype.slice.call(c,d))}},f.nextTick=function(a){d.nextTick(f.bindKey(f,"applyArgs",a,null,arguments,1))},f.handler=function(a){return a._provideBound=!0,a},f.scheduled=f.handler,f.makeBoundMethods=function(a,b){if(a.bound={},b)f.each(b,function(b){a.bound[b]=f.bindKey(a,b)});else{b=[];for(var c in a)"function"==typeof a[c]&&a[c]._provideBound===!0&&(a.bound[c]=f.bind(a[c],a))}},f.noop=function(){},f.getStackTrace=function(a){var b={};return Error.captureStackTrace(b,a||f.getStackTrace),"\n"+b.stack.split("\n").slice(1).join("\n")},b.exports=h},{__browserify_process:12,lodash:13,path:5,util:8}]},{},[14])(14)}); \ No newline at end of file +return f},ee=function(a,b,c){var d,e=a,f=e;if(!e)return f;if(!Z[typeof e])return f;b=b&&"undefined"==typeof c?b:g(b,c,3);for(d in e)if(b(e[d],d,a)===!1)return f;return f},fe=function(a,b,c){var d,e=a,f=e;if(!e)return f;if(!Z[typeof e])return f;b=b&&"undefined"==typeof c?b:g(b,c,3);for(var h=-1,i=Z[typeof e]&&Zd(e),j=i?i.length:0;++h/g,H=RegExp("^["+z+"]*0+(?=.$)"),I=/($^)/,J=/\bthis\b/,K=/['\n\r\t\u2028\u2029\\]/g,L=["Array","Boolean","Date","Function","Math","Number","Object","RegExp","String","_","attachEvent","clearTimeout","isFinite","isNaN","parseInt","setImmediate","setTimeout"],M=0,N="[object Arguments]",O="[object Array]",P="[object Boolean]",Q="[object Date]",R="[object Function]",S="[object Number]",T="[object Object]",U="[object RegExp]",V="[object String]",W={};W[R]=!1,W[N]=W[O]=W[P]=W[Q]=W[S]=W[T]=W[U]=W[V]=!0;var X={leading:!1,maxWait:0,trailing:!1},Y={configurable:!1,enumerable:!1,value:null,writable:!1},Z={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,undefined:!1},$={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"},_=Z[typeof window]&&window||this,ab=Z[typeof d]&&d&&!d.nodeType&&d,bb=Z[typeof c]&&c&&!c.nodeType&&c,cb=bb&&bb.exports===ab&&ab,db=Z[typeof e]&&e;!db||db.global!==db&&db.window!==db||(_=db);var eb=r();"function"==typeof a&&"object"==typeof a.amd&&a.amd?(_._=eb,a(function(){return eb})):ab&&bb?cb?(bb.exports=eb)._=eb:ab._=eb:_._=eb}).call(this)},{}],14:[function(a){var b=a("./lib/connectors/angular"),c=a("./lib/transport"),d=a("./lib/client");angular.module("elasticsearch.client",[]).factory("esFactory",["$http","$q",function(a,e){return b.prototype.$http=a,c.prototype._request=c.prototype.request,c.prototype.request=function(a,b){var c=e.defer();return this._request(a,function(a,d,e){"function"==typeof b&&b(a,d,e),a?c.reject(a):c.resolve({body:d,status:e})}),c.promise},function(a){return a=a||{},a.connectionClass=b,new d(a)}}])},{"./lib/client":16,"./lib/connectors/angular":21,"./lib/transport":31}],15:[function(a,b){var c=a("./client_action");a("./errors");var d=b.exports={};d._namespaces=["cluster","indices"],d.bulk=c({methods:["POST","PUT"],params:{consistency:{type:"enum",options:["one","quorum","all"]},refresh:{type:"boolean"},replication:{type:"enum","default":"sync",options:["sync","async"]},type:{type:"string"}},urls:[{fmt:"/<%=index%>/<%=type%>/_bulk",req:{index:{type:"string"},type:{type:"string"}}},{fmt:"/<%=index%>/_bulk",req:{index:{type:"string"}}},{fmt:"/_bulk"}],bulkBody:!0}),d.clearScroll=c({methods:["DELETE"],params:{},urls:[{fmt:"/_search/scroll/<%=scrollId%>",req:{scrollId:{type:"list"}}}]}),d.cluster=function e(a){return this instanceof e?(this.client=a,void 0):new e(a)},d.cluster.prototype.getSettings=c({methods:["GET"],params:{},urls:[{fmt:"/_cluster/settings"}]}),d.cluster.prototype.health=c({methods:["GET"],params:{level:{type:"enum","default":"cluster",options:["cluster","indices","shards"]},local:{type:"boolean"},masterTimeout:{type:"time",name:"master_timeout"},timeout:{type:"time"},waitForActiveShards:{type:"number",name:"wait_for_active_shards"},waitForNodes:{type:"string",name:"wait_for_nodes"},waitForRelocatingShards:{type:"number",name:"wait_for_relocating_shards"},waitForStatus:{type:"enum","default":null,options:["green","yellow","red"],name:"wait_for_status"}},urls:[{fmt:"/_cluster/health/<%=index%>",req:{index:{type:"string"}}},{fmt:"/_cluster/health"}]}),d.cluster.prototype.nodeHotThreads=c({methods:["GET"],params:{interval:{type:"time"},snapshots:{type:"number"},threads:{type:"number"},type:{type:"enum",options:["cpu","wait","block"]}},urls:[{fmt:"/_nodes/<%=nodeId%>/hotthreads",req:{nodeId:{type:"list"}}},{fmt:"/_nodes/hotthreads"}]}),d.cluster.prototype.nodeInfo=c({methods:["GET"],params:{all:{type:"boolean"},clear:{type:"boolean"},http:{type:"boolean"},jvm:{type:"boolean"},network:{type:"boolean"},os:{type:"boolean"},plugin:{type:"boolean"},process:{type:"boolean"},settings:{type:"boolean"},threadPool:{type:"boolean",name:"thread_pool"},timeout:{type:"time"},transport:{type:"boolean"}},urls:[{fmt:"/_nodes/<%=nodeId%>",req:{nodeId:{type:"list"}}},{fmt:"/_nodes"}]}),d.cluster.prototype.nodeShutdown=c({methods:["POST"],params:{delay:{type:"time"},exit:{type:"boolean"}},urls:[{fmt:"/_cluster/nodes/<%=nodeId%>/_shutdown",req:{nodeId:{type:"list"}}},{fmt:"/_shutdown"}]}),d.cluster.prototype.nodeStats=c({methods:["GET"],params:{all:{type:"boolean"},clear:{type:"boolean"},fields:{type:"list"},fs:{type:"boolean"},http:{type:"boolean"},indices:{type:"boolean"},jvm:{type:"boolean"},network:{type:"boolean"},os:{type:"boolean"},process:{type:"boolean"},threadPool:{type:"boolean",name:"thread_pool"},transport:{type:"boolean"}},urls:[{fmt:"/_nodes/<%=nodeId%>/stats",req:{nodeId:{type:"list"}}},{fmt:"/_nodes/stats"}]}),d.cluster.prototype.putSettings=c({methods:["PUT"],params:{},urls:[{fmt:"/_cluster/settings"}]}),d.cluster.prototype.reroute=c({methods:["POST"],params:{dryRun:{type:"boolean",name:"dry_run"},filterMetadata:{type:"boolean",name:"filter_metadata"}},urls:[{fmt:"/_cluster/reroute"}]}),d.cluster.prototype.state=c({methods:["GET"],params:{filterBlocks:{type:"boolean",name:"filter_blocks"},filterIndexTemplates:{type:"boolean",name:"filter_index_templates"},filterIndices:{type:"list",name:"filter_indices"},filterMetadata:{type:"boolean",name:"filter_metadata"},filterNodes:{type:"boolean",name:"filter_nodes"},filterRoutingTable:{type:"boolean",name:"filter_routing_table"},local:{type:"boolean"},masterTimeout:{type:"time",name:"master_timeout"}},urls:[{fmt:"/_cluster/state"}]}),d.count=c({methods:["POST","GET"],params:{ignoreIndices:{type:"enum","default":"none",options:["none","missing"],name:"ignore_indices"},minScore:{type:"number",name:"min_score"},preference:{type:"string"},routing:{type:"string"},source:{type:"string"}},urls:[{fmt:"/<%=index%>/<%=type%>/_count",req:{index:{type:"list"},type:{type:"list"}}},{fmt:"/<%=index%>/_count",req:{index:{type:"list"}}},{fmt:"/_count"}]}),d.create=c({methods:["POST","PUT"],params:{consistency:{type:"enum",options:["one","quorum","all"]},id:{type:"string"},parent:{type:"string"},percolate:{type:"string"},refresh:{type:"boolean"},replication:{type:"enum","default":"sync",options:["sync","async"]},routing:{type:"string"},timeout:{type:"time"},timestamp:{type:"time"},ttl:{type:"duration"},version:{type:"number"},versionType:{type:"enum",options:["internal","external"],name:"version_type"}},urls:[{fmt:"/<%=index%>/<%=type%>/<%=id%>/_create",req:{index:{type:"string"},type:{type:"string"},id:{type:"string"}}},{fmt:"/<%=index%>/<%=type%>",req:{index:{type:"string"},type:{type:"string"}}}]}),d["delete"]=c({methods:["DELETE"],params:{consistency:{type:"enum",options:["one","quorum","all"]},parent:{type:"string"},refresh:{type:"boolean"},replication:{type:"enum","default":"sync",options:["sync","async"]},routing:{type:"string"},timeout:{type:"time"},version:{type:"number"},versionType:{type:"enum",options:["internal","external"],name:"version_type"}},urls:[{fmt:"/<%=index%>/<%=type%>/<%=id%>",req:{index:{type:"string"},type:{type:"string"},id:{type:"string"}}}]}),d.deleteByQuery=c({methods:["DELETE"],params:{analyzer:{type:"string"},consistency:{type:"enum",options:["one","quorum","all"]},defaultOperator:{type:"enum","default":"OR",options:["AND","OR"],name:"default_operator"},df:{type:"string"},ignoreIndices:{type:"enum","default":"none",options:["none","missing"],name:"ignore_indices"},replication:{type:"enum","default":"sync",options:["sync","async"]},q:{type:"string"},routing:{type:"string"},source:{type:"string"},timeout:{type:"time"}},urls:[{fmt:"/<%=index%>/<%=type%>/_query",req:{index:{type:"list"},type:{type:"list"}}},{fmt:"/<%=index%>/_query",req:{index:{type:"list"}}}]}),d.exists=c({methods:["HEAD"],params:{parent:{type:"string"},preference:{type:"string"},realtime:{type:"boolean"},refresh:{type:"boolean"},routing:{type:"string"}},urls:[{fmt:"/<%=index%>/<%=type%>/<%=id%>",opt:{type:{type:"string","default":"_all"}},req:{index:{type:"string"},id:{type:"string"}}}],castExists:!0}),d.explain=c({methods:["GET","POST"],params:{analyzeWildcard:{type:"boolean",name:"analyze_wildcard"},analyzer:{type:"string"},defaultOperator:{type:"enum","default":"OR",options:["AND","OR"],name:"default_operator"},df:{type:"string"},fields:{type:"list"},lenient:{type:"boolean"},lowercaseExpandedTerms:{type:"boolean",name:"lowercase_expanded_terms"},parent:{type:"string"},preference:{type:"string"},q:{type:"string"},routing:{type:"string"},source:{type:"list",name:"_source"},sourceExclude:{type:"list",name:"_source_exclude"},sourceInclude:{type:"list",name:"_source_include"}},urls:[{fmt:"/<%=index%>/<%=type%>/<%=id%>/_explain",req:{index:{type:"string"},type:{type:"string"},id:{type:"string"}}}]}),d.get=c({methods:["GET"],params:{fields:{type:"list"},parent:{type:"string"},preference:{type:"string"},realtime:{type:"boolean"},refresh:{type:"boolean"},routing:{type:"string"},source:{type:"list",name:"_source"},sourceExclude:{type:"list",name:"_source_exclude"},sourceInclude:{type:"list",name:"_source_include"}},urls:[{fmt:"/<%=index%>/<%=type%>/<%=id%>",opt:{type:{type:"string","default":"_all"}},req:{index:{type:"string"},id:{type:"string"}}}]}),d.getSource=c({methods:["GET"],params:{exclude:{type:"list"},include:{type:"list"},parent:{type:"string"},preference:{type:"string"},realtime:{type:"boolean"},refresh:{type:"boolean"},routing:{type:"string"}},urls:[{fmt:"/<%=index%>/<%=type%>/<%=id%>/_source",opt:{type:{type:"string","default":"_all"}},req:{index:{type:"string"},id:{type:"string"}}}]}),d.index=c({methods:["POST","PUT"],params:{consistency:{type:"enum",options:["one","quorum","all"]},opType:{type:"enum","default":"index",options:["index","create"],name:"op_type"},parent:{type:"string"},percolate:{type:"string"},refresh:{type:"boolean"},replication:{type:"enum","default":"sync",options:["sync","async"]},routing:{type:"string"},timeout:{type:"time"},timestamp:{type:"time"},ttl:{type:"duration"},version:{type:"number"},versionType:{type:"enum",options:["internal","external"],name:"version_type"}},urls:[{fmt:"/<%=index%>/<%=type%>/<%=id%>",req:{index:{type:"string"},type:{type:"string"},id:{type:"string"}}},{fmt:"/<%=index%>/<%=type%>",req:{index:{type:"string"},type:{type:"string"}}}]}),d.indices=function f(a){return this instanceof f?(this.client=a,void 0):new f(a)},d.indices.prototype.analyze=c({methods:["GET","POST"],params:{analyzer:{type:"string"},field:{type:"string"},filters:{type:"list"},index:{type:"string"},preferLocal:{type:"boolean",name:"prefer_local"},text:{type:"string"},tokenizer:{type:"string"},format:{type:"enum","default":"detailed",options:["detailed","text"]}},urls:[{fmt:"/<%=index%>/_analyze",req:{index:{type:"string"}}},{fmt:"/_analyze"}]}),d.indices.prototype.clearCache=c({methods:["POST","GET"],params:{fieldData:{type:"boolean",name:"field_data"},fielddata:{type:"boolean"},fields:{type:"list"},filter:{type:"boolean"},filterCache:{type:"boolean",name:"filter_cache"},filterKeys:{type:"boolean",name:"filter_keys"},id:{type:"boolean"},idCache:{type:"boolean",name:"id_cache"},ignoreIndices:{type:"enum","default":"none",options:["none","missing"],name:"ignore_indices"},index:{type:"list"},recycler:{type:"boolean"}},urls:[{fmt:"/<%=index%>/_cache/clear",req:{index:{type:"list"}}},{fmt:"/_cache/clear"}]}),d.indices.prototype.close=c({methods:["POST"],params:{timeout:{type:"time"},masterTimeout:{type:"time",name:"master_timeout"}},urls:[{fmt:"/<%=index%>/_close",req:{index:{type:"string"}}}]}),d.indices.prototype.create=c({methods:["PUT","POST"],params:{timeout:{type:"time"},masterTimeout:{type:"time",name:"master_timeout"}},urls:[{fmt:"/<%=index%>",req:{index:{type:"string"}}}]}),d.indices.prototype["delete"]=c({methods:["DELETE"],params:{timeout:{type:"time"},masterTimeout:{type:"time",name:"master_timeout"}},urls:[{fmt:"/<%=index%>",req:{index:{type:"list"}}},{fmt:"/"}]}),d.indices.prototype.deleteAlias=c({methods:["DELETE"],params:{timeout:{type:"time"},masterTimeout:{type:"time",name:"master_timeout"}},urls:[{fmt:"/<%=index%>/_alias/<%=name%>",req:{index:{type:"string"},name:{type:"string"}}}]}),d.indices.prototype.deleteMapping=c({methods:["DELETE"],params:{masterTimeout:{type:"time",name:"master_timeout"}},urls:[{fmt:"/<%=index%>/<%=type%>",req:{index:{type:"list"},type:{type:"string"}}}]}),d.indices.prototype.deleteTemplate=c({methods:["DELETE"],params:{timeout:{type:"time"},masterTimeout:{type:"time",name:"master_timeout"}},urls:[{fmt:"/_template/<%=name%>",req:{name:{type:"string"}}}]}),d.indices.prototype.deleteWarmer=c({methods:["DELETE"],params:{masterTimeout:{type:"time",name:"master_timeout"}},urls:[{fmt:"/<%=index%>/<%=type%>/_warmer/<%=name%>",req:{index:{type:"list"},type:{type:"list"},name:{type:"string"}}},{fmt:"/<%=index%>/_warmer/<%=name%>",req:{index:{type:"list"},name:{type:"string"}}},{fmt:"/<%=index%>/_warmer",req:{index:{type:"list"}}}]}),d.indices.prototype.exists=c({methods:["HEAD"],params:{},urls:[{fmt:"/<%=index%>",req:{index:{type:"list"}}}],castExists:!0}),d.indices.prototype.existsAlias=c({methods:["HEAD"],params:{ignoreIndices:{type:"enum","default":"none",options:["none","missing"],name:"ignore_indices"}},urls:[{fmt:"/<%=index%>/_alias/<%=name%>",req:{index:{type:"list"},name:{type:"list"}}},{fmt:"/_alias/<%=name%>",req:{name:{type:"list"}}}],castExists:!0}),d.indices.prototype.existsType=c({methods:["HEAD"],params:{ignoreIndices:{type:"enum","default":"none",options:["none","missing"],name:"ignore_indices"}},urls:[{fmt:"/<%=index%>/<%=type%>",req:{index:{type:"list"},type:{type:"list"}}}],castExists:!0}),d.indices.prototype.flush=c({methods:["POST","GET"],params:{force:{type:"boolean"},full:{type:"boolean"},ignoreIndices:{type:"enum","default":"none",options:["none","missing"],name:"ignore_indices"},refresh:{type:"boolean"}},urls:[{fmt:"/<%=index%>/_flush",req:{index:{type:"list"}}},{fmt:"/_flush"}]}),d.indices.prototype.getAlias=c({methods:["GET"],params:{ignoreIndices:{type:"enum","default":"none",options:["none","missing"],name:"ignore_indices"}},urls:[{fmt:"/<%=index%>/_alias/<%=name%>",req:{index:{type:"list"},name:{type:"list"}}},{fmt:"/_alias/<%=name%>",req:{name:{type:"list"}}}]}),d.indices.prototype.getAliases=c({methods:["GET"],params:{timeout:{type:"time"}},urls:[{fmt:"/<%=index%>/_aliases",req:{index:{type:"list"}}},{fmt:"/_aliases"}]}),d.indices.prototype.getFieldMapping=c({methods:["GET"],params:{includeDefaults:{type:"boolean",name:"include_defaults"}},urls:[{fmt:"/<%=index%>/<%=type%>/_mapping/field/<%=field%>",req:{index:{type:"list"},type:{type:"list"},field:{type:"list"}}},{fmt:"/<%=index%>/_mapping/field/<%=field%>",req:{index:{type:"list"},field:{type:"list"}}},{fmt:"/_mapping/field/<%=field%>",req:{field:{type:"list"}}}]}),d.indices.prototype.getMapping=c({methods:["GET"],params:{},urls:[{fmt:"/<%=index%>/<%=type%>/_mapping",req:{index:{type:"list"},type:{type:"list"}}},{fmt:"/<%=index%>/_mapping",req:{index:{type:"list"}}},{fmt:"/_mapping"}]}),d.indices.prototype.getSettings=c({methods:["GET"],params:{},urls:[{fmt:"/<%=index%>/_settings",req:{index:{type:"list"}}},{fmt:"/_settings"}]}),d.indices.prototype.getTemplate=c({methods:["GET"],params:{},urls:[{fmt:"/_template/<%=name%>",req:{name:{type:"string"}}},{fmt:"/_template"}]}),d.indices.prototype.getWarmer=c({methods:["GET"],params:{},urls:[{fmt:"/<%=index%>/<%=type%>/_warmer/<%=name%>",req:{index:{type:"list"},type:{type:"list"},name:{type:"string"}}},{fmt:"/<%=index%>/_warmer/<%=name%>",req:{index:{type:"list"},name:{type:"string"}}},{fmt:"/<%=index%>/_warmer",req:{index:{type:"list"}}}]}),d.indices.prototype.open=c({methods:["POST"],params:{timeout:{type:"time"},masterTimeout:{type:"time",name:"master_timeout"}},urls:[{fmt:"/<%=index%>/_open",req:{index:{type:"string"}}}]}),d.indices.prototype.optimize=c({methods:["POST","GET"],params:{flush:{type:"boolean"},ignoreIndices:{type:"enum","default":"none",options:["none","missing"],name:"ignore_indices"},maxNumSegments:{type:"number",name:"max_num_segments"},onlyExpungeDeletes:{type:"boolean",name:"only_expunge_deletes"},operationThreading:{name:"operation_threading"},refresh:{type:"boolean"},waitForMerge:{type:"boolean",name:"wait_for_merge"}},urls:[{fmt:"/<%=index%>/_optimize",req:{index:{type:"list"}}},{fmt:"/_optimize"}]}),d.indices.prototype.putAlias=c({methods:["PUT"],params:{timeout:{type:"time"},masterTimeout:{type:"time",name:"master_timeout"}},urls:[{fmt:"/<%=index%>/_alias/<%=name%>",req:{index:{type:"string"},name:{type:"string"}}},{fmt:"/_alias/<%=name%>",req:{name:{type:"string"}}},{fmt:"/<%=index%>/_alias",req:{index:{type:"string"}}},{fmt:"/_alias"}]}),d.indices.prototype.putMapping=c({methods:["PUT","POST"],params:{ignoreConflicts:{type:"boolean",name:"ignore_conflicts"},timeout:{type:"time"},masterTimeout:{type:"time",name:"master_timeout"}},urls:[{fmt:"/<%=index%>/<%=type%>/_mapping",req:{index:{type:"list"},type:{type:"string"}}}]}),d.indices.prototype.putSettings=c({methods:["PUT"],params:{masterTimeout:{type:"time",name:"master_timeout"}},urls:[{fmt:"/<%=index%>/_settings",req:{index:{type:"list"}}},{fmt:"/_settings"}]}),d.indices.prototype.putTemplate=c({methods:["PUT","POST"],params:{order:{type:"number"},timeout:{type:"time"},masterTimeout:{type:"time",name:"master_timeout"}},urls:[{fmt:"/_template/<%=name%>",req:{name:{type:"string"}}}]}),d.indices.prototype.putWarmer=c({methods:["PUT"],params:{masterTimeout:{type:"time",name:"master_timeout"}},urls:[{fmt:"/<%=index%>/<%=type%>/_warmer/<%=name%>",req:{index:{type:"list"},type:{type:"list"},name:{type:"string"}}},{fmt:"/<%=index%>/_warmer/<%=name%>",req:{index:{type:"list"},name:{type:"string"}}}]}),d.indices.prototype.refresh=c({methods:["POST","GET"],params:{ignoreIndices:{type:"enum","default":"none",options:["none","missing"],name:"ignore_indices"},operationThreading:{name:"operation_threading"}},urls:[{fmt:"/<%=index%>/_refresh",req:{index:{type:"list"}}},{fmt:"/_refresh"}]}),d.indices.prototype.segments=c({methods:["GET"],params:{ignoreIndices:{type:"enum","default":"none",options:["none","missing"],name:"ignore_indices"},operationThreading:{name:"operation_threading"}},urls:[{fmt:"/<%=index%>/_segments",req:{index:{type:"list"}}},{fmt:"/_segments"}]}),d.indices.prototype.snapshotIndex=c({methods:["POST"],params:{ignoreIndices:{type:"enum","default":"none",options:["none","missing"],name:"ignore_indices"}},urls:[{fmt:"/<%=index%>/_gateway/snapshot",req:{index:{type:"list"}}},{fmt:"/_gateway/snapshot"}]}),d.indices.prototype.stats=c({methods:["GET"],params:{all:{type:"boolean"},clear:{type:"boolean"},completion:{type:"boolean"},completionFields:{type:"list",name:"completion_fields"},docs:{type:"boolean"},fielddata:{type:"boolean"},fielddataFields:{type:"list",name:"fielddata_fields"},fields:{type:"list"},filterCache:{type:"boolean",name:"filter_cache"},flush:{type:"boolean"},get:{type:"boolean"},groups:{type:"boolean"},idCache:{type:"boolean",name:"id_cache"},ignoreIndices:{type:"enum","default":"none",options:["none","missing"],name:"ignore_indices"},indexing:{type:"boolean"},merge:{type:"boolean"},refresh:{type:"boolean"},search:{type:"boolean"},store:{type:"boolean"},warmer:{type:"boolean"}},urls:[{fmt:"/<%=index%>/_stats",req:{index:{type:"list"}}},{fmt:"/_stats"}]}),d.indices.prototype.status=c({methods:["GET"],params:{ignoreIndices:{type:"enum","default":"none",options:["none","missing"],name:"ignore_indices"},operationThreading:{name:"operation_threading"},recovery:{type:"boolean"},snapshot:{type:"boolean"}},urls:[{fmt:"/<%=index%>/_status",req:{index:{type:"list"}}},{fmt:"/_status"}]}),d.indices.prototype.updateAliases=c({methods:["POST"],params:{timeout:{type:"time"},masterTimeout:{type:"time",name:"master_timeout"}},urls:[{fmt:"/_aliases"}]}),d.indices.prototype.validateQuery=c({methods:["GET","POST"],params:{explain:{type:"boolean"},ignoreIndices:{type:"enum","default":"none",options:["none","missing"],name:"ignore_indices"},operationThreading:{name:"operation_threading"},source:{type:"string"},q:{type:"string"}},urls:[{fmt:"/<%=index%>/<%=type%>/_validate/query",req:{index:{type:"list"},type:{type:"list"}}},{fmt:"/<%=index%>/_validate/query",req:{index:{type:"list"}}},{fmt:"/_validate/query"}]}),d.info=c({methods:["GET","HEAD"],params:{},urls:[{fmt:"/"}]}),d.mget=c({methods:["GET","POST"],params:{fields:{type:"list"},preference:{type:"string"},realtime:{type:"boolean"},refresh:{type:"boolean"},source:{type:"list",name:"_source"},sourceExclude:{type:"list",name:"_source_exclude"},sourceInclude:{type:"list",name:"_source_include"}},urls:[{fmt:"/<%=index%>/<%=type%>/_mget",req:{index:{type:"string"},type:{type:"string"}}},{fmt:"/<%=index%>/_mget",req:{index:{type:"string"}}},{fmt:"/_mget"}]}),d.mlt=c({methods:["GET","POST"],params:{boostTerms:{type:"number",name:"boost_terms"},maxDocFreq:{type:"number",name:"max_doc_freq"},maxQueryTerms:{type:"number",name:"max_query_terms"},maxWordLen:{type:"number",name:"max_word_len"},minDocFreq:{type:"number",name:"min_doc_freq"},minTermFreq:{type:"number",name:"min_term_freq"},minWordLen:{type:"number",name:"min_word_len"},mltFields:{type:"list",name:"mlt_fields"},percentTermsToMatch:{type:"number",name:"percent_terms_to_match"},routing:{type:"string"},searchFrom:{type:"number",name:"search_from"},searchIndices:{type:"list",name:"search_indices"},searchQueryHint:{type:"string",name:"search_query_hint"},searchScroll:{type:"string",name:"search_scroll"},searchSize:{type:"number",name:"search_size"},searchSource:{type:"string",name:"search_source"},searchType:{type:"string",name:"search_type"},searchTypes:{type:"list",name:"search_types"},stopWords:{type:"list",name:"stop_words"}},urls:[{fmt:"/<%=index%>/<%=type%>/<%=id%>/_mlt",req:{index:{type:"string"},type:{type:"string"},id:{type:"string"}}}]}),d.msearch=c({methods:["GET","POST"],params:{searchType:{type:"enum",options:["query_then_fetch","query_and_fetch","dfs_query_then_fetch","dfs_query_and_fetch","count","scan"],name:"search_type"}},urls:[{fmt:"/<%=index%>/<%=type%>/_msearch",req:{index:{type:"list"},type:{type:"list"}}},{fmt:"/<%=index%>/_msearch",req:{index:{type:"list"}}},{fmt:"/_msearch"}],bulkBody:!0}),d.percolate=c({methods:["GET","POST"],params:{preferLocal:{type:"boolean",name:"prefer_local"}},urls:[{fmt:"/<%=index%>/<%=type%>/_percolate",req:{index:{type:"string"},type:{type:"string"}}}]}),d.scroll=c({methods:["GET","POST"],params:{scroll:{type:"duration"},scrollId:{type:"string",name:"scroll_id"}},urls:[{fmt:"/_search/scroll/<%=scrollId%>",req:{scrollId:{type:"string"}}},{fmt:"/_search/scroll"}]}),d.search=c({methods:["GET","POST"],params:{analyzer:{type:"string"},analyzeWildcard:{type:"boolean",name:"analyze_wildcard"},defaultOperator:{type:"enum","default":"OR",options:["AND","OR"],name:"default_operator"},df:{type:"string"},explain:{type:"boolean"},fields:{type:"list"},from:{type:"number"},ignoreIndices:{type:"enum","default":"none",options:["none","missing"],name:"ignore_indices"},indicesBoost:{type:"list",name:"indices_boost"},lenient:{type:"boolean"},lowercaseExpandedTerms:{type:"boolean",name:"lowercase_expanded_terms"},preference:{type:"string"},q:{type:"string"},routing:{type:"list"},scroll:{type:"duration"},searchType:{type:"enum",options:["query_then_fetch","query_and_fetch","dfs_query_then_fetch","dfs_query_and_fetch","count","scan"],name:"search_type"},size:{type:"number"},sort:{type:"list"},source:{type:"list",name:"_source"},sourceExclude:{type:"list",name:"_source_exclude"},sourceInclude:{type:"list",name:"_source_include"},stats:{type:"list"},suggestField:{type:"string",name:"suggest_field"},suggestMode:{type:"enum","default":"missing",options:["missing","popular","always"],name:"suggest_mode"},suggestSize:{type:"number",name:"suggest_size"},suggestText:{type:"text",name:"suggest_text"},timeout:{type:"time"},version:{type:"boolean"}},urls:[{fmt:"/<%=index%>/<%=type%>/_search",opt:{index:{type:"list","default":"_all"}},req:{type:{type:"list"}}},{fmt:"/<%=index%>/_search",opt:{index:{type:"list","default":"_all"}}}]}),d.suggest=c({methods:["POST","GET"],params:{ignoreIndices:{type:"enum","default":"none",options:["none","missing"],name:"ignore_indices"},preference:{type:"string"},routing:{type:"string"},source:{type:"string"}},urls:[{fmt:"/<%=index%>/_suggest",req:{index:{type:"list"}}},{fmt:"/_suggest"}]}),d.update=c({methods:["POST"],params:{consistency:{type:"enum",options:["one","quorum","all"]},fields:{type:"list"},lang:{type:"string"},parent:{type:"string"},percolate:{type:"string"},refresh:{type:"boolean"},replication:{type:"enum","default":"sync",options:["sync","async"]},retryOnConflict:{type:"number",name:"retry_on_conflict"},routing:{type:"string"},script:{},timeout:{type:"time"},timestamp:{type:"time"},ttl:{type:"duration"},version:{type:"number"},versionType:{type:"enum",options:["internal","external"],name:"version_type"}},urls:[{fmt:"/<%=index%>/<%=type%>/<%=id%>/_update",req:{index:{type:"string"},type:{type:"string"},id:{type:"string"}}}]})},{"./client_action":17,"./errors":22}],16:[function(a,b){function c(a){this.client=this,Object.defineProperty(this,"config",{configurable:!1,enumerable:!1,writable:!1,value:!a||d.isPlainObject(a)?new e(a):a}),this.config.client=this;for(var b=0;b1)this.config.selector(this.connections.alive,a);else try{d.nextTick(a,null,this.config.selector(this.connections.alive))}catch(b){this.config.log.error(b),a(b)}else a()},c.prototype.onStatusChanged=d.handler(function(a,b,c){var d,e,f;if(b===a)return!0;switch(this.config.log.info("connection id:",c.__id,"is",a),a){case"alive":d=this.connections.dead,e=this.connections.alive;break;case"dead":d=this.connections.alive,e=this.connections.dead;break;case"closed":d=this.connections[b]}d&&d.indexOf&&(f=d.indexOf(c),~f&&d.splice(f,1)),e&&e.indexOf&&(f=e.indexOf(c),~f||e.push(c))}),c.prototype._add=function(a){this.index[a.__id]||(this.index[a.__id]=a,a.on("status changed",this.bound.onStatusChanged),a.setStatus("alive"))},c.prototype._remove=function(a){this.index[a.__id]&&(delete this.index[a.__id],a.setStatus("closed"),a.removeListener("status changed",this.bound.onStatusChanged))},c.prototype.setNodes=function(a){var b,c,f,g,h=d.clone(this.index);for(c=0;ca?"0"+a.toString(10):a.toString(10)}function e(a,b){var c=f.repeat(" ",b||2);return a.split(/\r?\n/).map(function(a){return c+a}).join("\n")}var f=(a("./log"),a("./utils"));c.prototype.timestamp=function(){var a=new Date;return a.getUTCFullYear()+"-"+d(a.getUTCMonth()+1)+"-"+d(a.getUTCDate())+"T"+d(a.getUTCHours())+":"+d(a.getUTCMinutes())+":"+d(a.getUTCSeconds())+"Z"},c.prototype.format=function(a,b){return a+": "+this.timestamp()+"\n"+e(b)+"\n\n"},c.prototype.write=function(){throw new Error("This should be overwritten by the logger")},c.prototype.setupListeners=function(a){this.cleanUpListeners(),this.listeningLevels=a,f.each(this.listeningLevels,function(a){var b="on"+f.ucfirst(a);if(!this.bound[b])throw new Error(b+" is not a function");this.bridge.on(a,this.bound[b])},this)},c.prototype.cleanUpListeners=f.handler(function(){f.each(this.listeningLevels,function(a){this.bridge.removeListener(a,this.bound["on"+f.ucfirst(a)])},this)}),c.prototype.onError=f.handler(function(a){this.write("Error"===a.name?"ERROR":a.name,a.stack)}),c.prototype.onWarning=f.handler(function(a){this.write("WARNING",a)}),c.prototype.onInfo=f.handler(function(a){this.write("INFO",a)}),c.prototype.onDebug=f.handler(function(a){this.write("DEBUG",a)}),c.prototype.onTrace=f.handler(function(a,b,c,d,e){var f='curl "'+b.replace(/"/g,'\\"')+'" -X'+a.toUpperCase();c&&(f+=' -d "'+c.replace(/"/g,'\\"')+'"'),f+="\n<- "+e+"\n"+d,this.write("TRACE",f)}),b.exports=c},{"./log":24,"./utils":33}],26:[function(a,b){function c(a,b){d.call(this,a,b),this.color=e.has(a,"color")?!!a.color:!0}b.exports=c;var d=a("../logger"),e=a("../utils");e.inherits(c,d),c.prototype.setupListeners=function(a){this.bound.onWarning=this.onWarning,this.bound.onInfo=this.onInfo,this.bound.onDebug=this.onDebug,d.prototype.setupListeners.call(this,a)},c.prototype.onError=e.handler(function(a){console.error&&console.trace?console.error("Error"===a.name?"ERROR":a.name,a.stack||a.message):console.log("Error"===a.name?"ERROR":a.name,a.stack||a.message)}),c.prototype.onWarning=e.bindKey(console,console.warn?"warn":"log","WARNING"),c.prototype.onInfo=e.bindKey(console,console.info?"info":"log","INFO"),c.prototype.onDebug=e.bindKey(console,console.debug?"debug":"log","DEBUG"),c.prototype.onTrace=e.handler(function(a,b,c,d,e){var f='curl "'+b.replace(/"/g,'\\"')+'" -X'+a.toUpperCase();c&&(f+=' -d "'+c.replace(/"/g,'\\"')+'"'),f+="\n<- "+e+"\n"+d,console.log("TRACE:\n"+f+"\n\n")})},{"../logger":25,"../utils":33}],27:[function(a,b){b.exports={random:a("./random"),roundRobin:a("./round_robin")}},{"./random":28,"./round_robin":29}],28:[function(a,b){function c(a){return a[Math.floor(Math.random()*a.length)]}b.exports=c},{}],29:[function(a,b){function c(a){return a.unshift(a.pop()),a[0]}b.exports=c},{}],30:[function(a,b){function c(a){this.client=a}b.exports=c;var d=a("../utils");c.prototype.serialize=function(a,b,c){return null==a?null:"string"==typeof a?a:JSON.stringify(a,b,c)},c.prototype.unserialize=function(a){if("string"!=typeof a)return a;try{return JSON.parse(a)}catch(b){return this.client.log.error(new Error("unable to parse",a)),null}},c.prototype.bulkBody=function(a){var b,c="";if(d.isArray(a))for(b=0;bc||c>=300)&&!e.contains(h,c)&&(a=g[c]?new g[c](d&&d.error):new g.Generic("unknown error")),this._params.castExists&&(a&&a instanceof g.NotFound?(d=!1,a=void 0):d=!a),this._error=a,this._response={body:d,status:c},this.emit("done",this._error,this._response.body,this._response.status)}),c.prototype.abort=function(){return this.aborted=!0,this.__request?(this.__request.abort(),!0):!1},c.prototype.then=function(a,b){this._error?b(this._error):this._response?a(this._response):this.once("done",e.bindKey(this,"then",a,b))}},{"./errors":22,"./utils":33,__browserify_process:12,events:4}],33:[function(a,b){function c(a,b,c){return function(d){for(var e,f,g,h,i=0,j=[],k="";i=97&&122>=e,g=e>=65&&90>=e,(g||!h)&&(k.length&&j.push(k),k=""),(g||h)&&(h&&k.length?k+=f:k=!j.length&&a||j.length&&b?f.toUpperCase():f.toLowerCase());return k.length&&j.push(k),j.lenth&&"_"===d.charAt(0)&&(j[0]="_"+j[0]),j.join(c)}}var d=a("__browserify_process"),e=a("path"),f=a("lodash"),g=a("util"),h=f.extend({},f,g);f=h,h.inspect=function(a,b){return g.inspect(a,f.defaults(b||{},{showHidden:!0,depth:null,color:!0}))},h.joinPath=e.join,h.reKey=function(a,b,c){if(void 0===c&&(c=!0),"function"!=typeof b)throw new TypeError("invalid transform function");var d={};return f.each(a,function(a,e){d[b(e)]=c&&"object"==typeof a?h.reKey(a,b,c):a}),d},h.deepMerge=function(a,b){return Object.keys(b).forEach(function(c){switch(typeof a[c]){case"undefined":a[c]=b[c];break;case"object":f.isArray(a[c])&&f.isArray(b[c])?a[c]=a[c].concat(b[c]):f.isPlainObject(a[c])&&f.isPlainObject(b[c])&&h.deepMerge(a[c],b[c])}}),a},"String Object PlainObject Array Finite Function RegExp".split(" ").forEach(function(a){var b=f.bindKey(f,"is"+a);h["isArrayOf"+a+"s"]=function(a){return f.isArray(a)&&f.every(a.slice(0,10),b)}}),h.ucfirst=function(a){return a[0].toUpperCase()+a.substring(1).toLowerCase()},h.studlyCase=c(!0,!0,""),h.camelCase=c(!1,!0,""),h.snakeCase=c(!1,!1,"_"),h.toLowerString=function(a){return a?"string"!=typeof a&&(a=a.toString()):a="",a.toLowerCase()},h.toUpperString=function(a){return a?"string"!=typeof a&&(a=a.toString()):a="",a.toUpperCase()},h.isNumeric=function(a){return!isNaN(null===a?0/0:1*a)};var i=/^(\d+(?:\.\d+)?)([Mwdhmsy])$/;h.isInterval=function(a){return!(!a.match||!a.match(i))},h.repeat=function(a,b){return new Array(b+1).join(a)},h.inherits=function(a,b){g.inherits(a,b),a.callSuper=function(a,c){c?f.isArguments(c)?h.applyArgs(b,a,c):h.applyArgs(b,a,arguments,1):b.call(a)}},h.trim=function(a){return"string"==typeof a?a.replace(/^\s+|\s+$/g,""):""},h.collectMatches=function(a,b){for(var c,d=[];(c=b.exec(a))&&(d.push(c),b.global===!0););return d},h.applyArgs=function(a,b,c,d){switch(d=d||0,c.length-d){case 0:return a.call(b);case 1:return a.call(b,c[0+d]);case 2:return a.call(b,c[0+d],c[1+d]);case 3:return a.call(b,c[0+d],c[1+d],c[2+d]);case 4:return a.call(b,c[0+d],c[1+d],c[2+d],c[3+d]);case 5:return a.call(b,c[0+d],c[1+d],c[2+d],c[3+d],c[4+d]);default:return a.apply(b,Array.prototype.slice.call(c,d))}},f.nextTick=function(a){d.nextTick(f.bindKey(f,"applyArgs",a,null,arguments,1))},f.handler=function(a){return a._provideBound=!0,a},f.scheduled=f.handler,f.makeBoundMethods=function(a,b){if(a.bound={},b)f.each(b,function(b){a.bound[b]=f.bindKey(a,b)});else{b=[];for(var c in a)"function"==typeof a[c]&&a[c]._provideBound===!0&&(a.bound[c]=f.bind(a[c],a))}},f.noop=function(){},b.exports=h},{__browserify_process:12,lodash:13,path:5,util:8}]},{},[14])(14)}); \ No newline at end of file diff --git a/dist/elasticsearch.js b/dist/elasticsearch.js index 30ab98268..2ab4b176c 100644 --- a/dist/elasticsearch.js +++ b/dist/elasticsearch.js @@ -1,4 +1,9 @@ -!function(e){"object"==typeof exports?module.exports=e():"function"==typeof define&&define.amd?define(e):"undefined"!=typeof window?window.true=e():"undefined"!=typeof global?global.true=e():"undefined"!=typeof self&&(self.true=e())}(function(){var define,module,exports; +/*! elasticsearch-js - v0.0.1 - 2013-11-05 + * https://github.com/elasticsearch/elasticsearch-js + * Copyright (c) 2013 Spencer Alger; Licensed Apache License */ + // built using browserify + +!function(e){"object"==typeof exports?module.exports=e():"function"==typeof define&&define.amd?define(e):"undefined"!=typeof window?window.elasticsearch=e():"undefined"!=typeof global?global.elasticsearch=e():"undefined"!=typeof self&&(self.elasticsearch=e())}(function(){var define,module,exports; return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o/<%=type%>/_mapping/field/<%=field%>', + req: { + index: { + type: 'list' + }, + type: { + type: 'list' + }, + field: { + type: 'list' + } + } + }, + { + fmt: '/<%=index%>/_mapping/field/<%=field%>', + req: { + index: { + type: 'list' + }, + field: { + type: 'list' + } + } + }, + { + fmt: '/_mapping/field/<%=field%>', + req: { + field: { + type: 'list' + } + } + } + ] +}); + + /** * Perform a [indices.getMapping](http://www.elasticsearch.org/guide/reference/api/admin-indices-get-mapping/) request * @@ -13069,9 +13127,9 @@ api.info = ca({ * @param {String} params.preference - Specify the node or shard the operation should be performed on (default: random) * @param {Boolean} params.realtime - Specify whether to perform the operation in realtime or search mode * @param {Boolean} params.refresh - Refresh the shard containing the document before performing the operation - * @param {String|ArrayOfStrings|Boolean} params._source - True or false to return the _source field or not, or a list of fields to return - * @param {String|ArrayOfStrings|Boolean} params._sourceExclude - A list of fields to exclude from the returned _source field - * @param {String|ArrayOfStrings|Boolean} params._sourceInclude - A list of fields to extract and return from the _source field + * @param {String|ArrayOfStrings|Boolean} params.source - True or false to return the _source field or not, or a list of fields to return + * @param {String|ArrayOfStrings|Boolean} params.sourceExclude - A list of fields to exclude from the returned _source field + * @param {String|ArrayOfStrings|Boolean} params.sourceInclude - A list of fields to extract and return from the _source field * @param {String} params.index - The name of the index * @param {String} params.type - The type of the document */ @@ -13093,15 +13151,15 @@ api.mget = ca({ refresh: { type: 'boolean' }, - _source: { + source: { type: 'list', name: '_source' }, - _sourceExclude: { + sourceExclude: { type: 'list', name: '_source_exclude' }, - _sourceInclude: { + sourceInclude: { type: 'list', name: '_source_include' } @@ -13410,10 +13468,9 @@ api.scroll = ca({ * @param {String} params.searchType - Search operation type * @param {Number} params.size - Number of hits to return (default: 10) * @param {String|ArrayOfStrings|Boolean} params.sort - A comma-separated list of : pairs - * @param {String} params.source - The URL-encoded request definition using the Query DSL (instead of using request body) - * @param {String|ArrayOfStrings|Boolean} params._source - True or false to return the _source field or not, or a list of fields to return - * @param {String|ArrayOfStrings|Boolean} params._sourceExclude - A list of fields to exclude from the returned _source field - * @param {String|ArrayOfStrings|Boolean} params._sourceInclude - A list of fields to extract and return from the _source field + * @param {String|ArrayOfStrings|Boolean} params.source - True or false to return the _source field or not, or a list of fields to return + * @param {String|ArrayOfStrings|Boolean} params.sourceExclude - A list of fields to exclude from the returned _source field + * @param {String|ArrayOfStrings|Boolean} params.sourceInclude - A list of fields to extract and return from the _source field * @param {String|ArrayOfStrings|Boolean} params.stats - Specific 'tag' of the request for logging and statistical purposes * @param {String} params.suggestField - Specify which field to use for suggestions * @param {String} [params.suggestMode=missing] - Specify suggest mode @@ -13509,17 +13566,14 @@ api.search = ca({ type: 'list' }, source: { - type: 'string' - }, - _source: { type: 'list', name: '_source' }, - _sourceExclude: { + sourceExclude: { type: 'list', name: '_source_exclude' }, - _sourceInclude: { + sourceInclude: { type: 'list', name: '_source_include' }, @@ -13652,7 +13706,7 @@ api.suggest = ca({ * @param {Date|Number} params.timestamp - Explicit timestamp for the document * @param {Duration} params.ttl - Expiration time for the document * @param {Number} params.version - Explicit version number for concurrency control - * @param {Number} params.versionType - Explicit version number for concurrency control + * @param {String} params.versionType - Specific version type * @param {String} params.id - Document ID * @param {String} params.index - The name of the index * @param {String} params.type - The type of the document @@ -13714,7 +13768,11 @@ api.update = ca({ type: 'number' }, versionType: { - type: 'number', + type: 'enum', + options: [ + 'internal', + 'external' + ], name: 'version_type' } }, @@ -13883,10 +13941,10 @@ var castType = { } }, time: function (param, val, name) { - if (val instanceof Date) { - return val.getTime(); - } else if (_.isNumeric(val)) { + if (typeof val === 'string' || _.isNumeric(val)) { return val; + } else if (val instanceof Date) { + return val.getTime(); } else { throw new TypeError('Invalid ' + name + ': expected some sort of time.'); } @@ -14030,15 +14088,17 @@ function exec(transport, spec, params, cb) { // build a key list on demand spec.paramKeys = _.keys(spec.params); } - var key, param; + var key, param, name; for (i = 0; i < spec.paramKeys.length; i++) { key = spec.paramKeys[i]; param = spec.params[key]; + // param keys don't always match the param name, in those cases it's stored in the param def as "name" + name = param.name || key; try { if (params[key] != null) { - query[key] = castType[param.type] ? castType[param.type](param, params[key], key) : params[key]; - if (param['default'] && query[key] === param['default']) { - delete query[key]; + query[name] = castType[param.type] ? castType[param.type](param, params[key], key) : params[key]; + if (param['default'] && query[name] === param['default']) { + delete query[name]; } } else if (param.required) { throw new TypeError('Missing required parameter ' + key); @@ -14097,6 +14157,11 @@ var defaultClasses = { }; var defaultConfig = { + loggers: [ + { + level: 'warning' + } + ], hosts: [ { host: 'localhost', @@ -14142,24 +14207,28 @@ connectors = _.transform(connectors, function (note, connector, name) { function ClientConfig(config) { _.extend(this, defaultConfig, config); + if (this.log) { + // treat log as an alias for loggers in the config. + this.loggers = this.log; + delete this.log; + } + // validate connectionClass + if (typeof this.connectionClass === 'string') { + this.connectionClass = connectors[_.studlyCase(this.connectionClass)]; + } if (typeof this.connectionClass !== 'function') { - if (typeof connectors[this.connectionClass] === 'function') { - this.connectionClass = connectors[this.connectionClass]; - } else { - throw new TypeError('Invalid connectionClass "' + this.connectionClass + '". ' + + throw new TypeError('Invalid connectionClass "' + this.connectionClass + '". ' + 'Expected a constructor or one of ' + _.keys(connectors).join(', ')); - } } // validate selector + if (typeof this.selector === 'string') { + this.selector = selectors[_.camelCase(this.selector)]; + } if (typeof this.selector !== 'function') { - if (_.has(selectors, this.selector)) { - this.selector = selectors[this.selector]; - } else { - throw new TypeError('Invalid Selector "' + this.selector + '". ' + + throw new TypeError('Invalid Selector "' + this.selector + '". ' + 'Expected a function or one of ' + _.keys(selectors).join(', ')); - } } _.each(defaultClasses, function (DefaultClass, prop) { @@ -14411,7 +14480,7 @@ ConnectionPool.prototype.empty = ConnectionPool.prototype.close; * * @class connections.Xhr */ -module.exports = XhrConnection; +module.exports = XhrConnector; /* jshint browser:true */ @@ -14419,11 +14488,12 @@ var _ = require('../utils'); var ConnectionAbstract = require('../connection'); var ConnectionFault = require('../errors').ConnectionFault; var TimeoutError = require('../errors').RequestTimeout; +var asyncDefault = !(navigator && /PhantomJS/i.test(navigator.userAgent)); -function XhrConnection(host, config) { +function XhrConnector(host, config) { ConnectionAbstract.call(this, host, config); } -_.inherits(XhrConnection, ConnectionAbstract); +_.inherits(XhrConnector, ConnectionAbstract); /** * Simply returns an XHR object cross browser @@ -14454,43 +14524,53 @@ if (!getXhr) { throw new Error('getXhr(): XMLHttpRequest not available'); } -XhrConnection.prototype.request = function (params, cb) { +XhrConnector.prototype.request = function (params, cb) { var xhr = getXhr(); + var timeout = params.timeout ? params.timeout : 10000; var timeoutId; var url = this.host.makeUrl(params); + var log = this.config.log; + var async = params.async === false ? false : asyncDefault; + if (params.auth) { - xhr.open(params.method, url, true, params.auth.user, params.auth.pass); + xhr.open(params.method, url, async, params.auth.user, params.auth.pass); } else { - xhr.open(params.method, url, true); + xhr.open(params.method, url, async); } xhr.onreadystatechange = function (e) { if (xhr.readyState === 4) { clearTimeout(timeoutId); - cb(xhr.status ? null : new ConnectionFault(), xhr.responseText, xhr.status); + log.trace(params.method, url, params.body, xhr.responseText, xhr.status); + var err = xhr.status ? void 0 : new ConnectionFault(xhr.statusText || 'Request failed to complete.'); + cb(err, xhr.responseText, xhr.status); } }; - if (params.timeout !== Infinity) { + if (timeout !== Infinity) { timeoutId = setTimeout(function () { xhr.onreadystatechange = _.noop; xhr.abort(); cb(new TimeoutError()); - }, params.timeout); + }, timeout); } - xhr.send(params.body || null); + xhr.send(params.body || void 0); }; },{"../connection":19,"../errors":22,"../utils":33}],22:[function(require,module,exports){ -var _ = require('./utils'), +var process=require("__browserify_process");var _ = require('./utils'), errors = module.exports; function ErrorAbstract(msg, constructor) { this.message = msg; Error.call(this, this.message); - Error.captureStackTrace(this, constructor); + if (process.browser) { + this.stack = ''; + } else { + Error.captureStackTrace(this, constructor); + } } _.inherits(ErrorAbstract, Error); @@ -14595,7 +14675,7 @@ _.each(statusCodes, function (name, status) { errors[status] = StatusCodeError; }); -},{"./utils":33}],23:[function(require,module,exports){ +},{"./utils":33,"__browserify_process":12}],23:[function(require,module,exports){ /** * Class to wrap URLS, formatting them and maintaining their seperate details * @type {[type]} @@ -14685,12 +14765,8 @@ Host.prototype.makeUrl = function (params) { // just stringify the hosts query query = qs.stringify(this.query); } - // prepend the ? if there is actually a valid query string - if (query) { - query = '?' + query; - } - return this.protocol + '://' + this.host + port + path + query; + return this.protocol + '://' + this.host + port + path + (query ? '?' + query : ''); }; },{"./utils":33,"querystring":6,"url":7}],24:[function(require,module,exports){ @@ -14727,7 +14803,7 @@ function Log(config) { this.config = config || {}; var i; - var output = _.isPlainObject(config.log) ? config.log : 'warning'; + var output = config.loggers ? config.loggers : 'warning'; if (_.isString(output) || _.isFinite(output)) { output = [ @@ -14884,7 +14960,7 @@ Log.prototype.addOutput = function (config) { delete config.level; config.levels = levels; - var Logger = loggers[config.type]; + var Logger = loggers[_.studlyCase(config.type)]; if (Logger) { return new Logger(config, this); } else { @@ -14942,7 +15018,7 @@ Log.prototype.info = function (/* ...msg */) { */ Log.prototype.debug = function (/* ...msg */) { if (EventEmitter.listenerCount(this, 'debug')) { - return this.emit('debug', Log.join(arguments) + _.getStackTrace(Log.prototype.debug)); + return this.emit('debug', Log.join(arguments) /*+ _.getStackTrace(Log.prototype.debug)*/); } }; @@ -14960,10 +15036,17 @@ Log.prototype.debug = function (/* ...msg */) { */ Log.prototype.trace = function (method, requestUrl, body, responseBody, responseStatus) { if (EventEmitter.listenerCount(this, 'trace')) { - if (typeof requestUrl === 'object') { - requestUrl = url.format(requestUrl); + if (typeof requestUrl === 'string') { + requestUrl = url.parse(requestUrl, true, true); } - return this.emit('trace', method, requestUrl, body, responseBody, responseStatus); + requestUrl = _.defaults({ + host: 'localhost:9200', + query: _.defaults({ + pretty: true + }, requestUrl.query) + }, requestUrl); + delete requestUrl.auth; + return this.emit('trace', method, url.format(requestUrl), body, responseBody, responseStatus); } }; @@ -15181,10 +15264,9 @@ Console.prototype.setupListeners = function (levels) { */ Console.prototype.onError = _.handler(function (e) { if (console.error && console.trace) { - console.error(e.name === 'Error' ? 'ERROR' : e.name); - console.trace(); + console.error(e.name === 'Error' ? 'ERROR' : e.name, e.stack || e.message); } else { - console.log(e.name === 'Error' ? 'ERROR' : e.name, e.stack); + console.log(e.name === 'Error' ? 'ERROR' : e.name, e.stack || e.message); } }); @@ -15196,7 +15278,7 @@ Console.prototype.onError = _.handler(function (e) { * @param {String} msg - The message to be logged * @return {undefined} */ -Console.prototype.onWarning = console[console.warn ? 'warn' : 'log'].bind(console, 'WARNING'); +Console.prototype.onWarning = _.bindKey(console, console.warn ? 'warn' : 'log', 'WARNING'); /** * Handler for the bridges "info" event @@ -15206,7 +15288,7 @@ Console.prototype.onWarning = console[console.warn ? 'warn' : 'log'].bind(consol * @param {String} msg - The message to be logged * @return {undefined} */ -Console.prototype.onInfo = console[console.info ? 'info' : 'log'].bind(console, 'INFO'); +Console.prototype.onInfo = _.bindKey(console, console.info ? 'info' : 'log', 'INFO'); /** * Handler for the bridges "debug" event @@ -15216,7 +15298,7 @@ Console.prototype.onInfo = console[console.info ? 'info' : 'log'].bind(console, * @param {String} msg - The message to be logged * @return {undefined} */ -Console.prototype.onDebug = console[console.debug ? 'debug' : 'log'].bind(console, 'DEBUG'); +Console.prototype.onDebug = _.bindKey(console, console.debug ? 'debug' : 'log', 'DEBUG'); /** * Handler for the bridges "trace" event @@ -15231,7 +15313,7 @@ Console.prototype.onTrace = _.handler(function (method, url, body, responseBody, message += ' -d "' + body.replace(/"/g, '\\"') + '"'; } message += '\n<- ' + responseStatus + '\n' + responseBody; - console.log('TRACE', message); + console.log('TRACE:\n' + message + '\n\n'); }); },{"../logger":25,"../utils":33}],27:[function(require,module,exports){ @@ -15446,7 +15528,7 @@ TransportRequest.prototype._sendReqWithCon = _.handler(function (err, con) { TransportRequest.prototype._checkRespForFail = _.handler(function (err, body, status) { if (err && this._remainingRetries) { this._remainingRetries--; - this._log.info('Connection error, retrying'); + this._log.error(err.message, '-- retrying'); this._connectionPool.select(this.bound._sendReqWithCon); } else { this._log.info('Request complete'); @@ -15681,6 +15763,10 @@ function adjustWordCase(firstWordCap, otherWordsCap, sep) { if (word.length) { words.push(word); } + // add the leading underscore back to strings the had it originally + if (words.lenth && string.charAt(0) === '_') { + words[0] = '_' + words[0]; + } return words.join(sep); }; } @@ -15934,11 +16020,16 @@ _.makeBoundMethods = function (obj, methods) { _.noop = function () {}; -_.getStackTrace = function (callee) { - var e = {}; - Error.captureStackTrace(e, callee || _.getStackTrace); - return '\n' + e.stack.split('\n').slice(1).join('\n'); -}; +// _.getStackTrace = function (callee) { +// var e = {}; +// if (typeof Error.captureStackTrace === 'function') { +// Error.captureStackTrace(e, callee || _.getStackTrace); +// } else { +// e.stack = (new Error()).stack; +// console.log(e.stack); +// } +// return '\n' + e.stack.split('\n').slice(1).join('\n'); +// }; module.exports = utils; diff --git a/dist/elasticsearch.min.js b/dist/elasticsearch.min.js index 00c04f58c..c17c56cd3 100644 --- a/dist/elasticsearch.min.js +++ b/dist/elasticsearch.min.js @@ -1,8 +1,9 @@ -/*! elasticsearch-js - v0.0.1 - 2013-10-29 +/*! elasticsearch-js - v0.0.1 - 2013-11-05 * https://github.com/elasticsearch/elasticsearch-js * Copyright (c) 2013 Spencer Alger; Licensed Apache License */ + // built using browserify -!function(a){"object"==typeof exports?module.exports=a():"function"==typeof define&&define.amd?define(a):"undefined"!=typeof window?window.true=a():"undefined"!=typeof global?global.true=a():"undefined"!=typeof self&&(self.true=a())}(function(){var a;return function b(a,c,d){function e(g,h){if(!c[g]){if(!a[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);throw new Error("Cannot find module '"+g+"'")}var j=c[g]={exports:{}};a[g][0].call(j.exports,function(b){var c=a[g][1][b];return e(c?c:b)},j,j.exports,b,a,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;gf;++f)a.hasOwnProperty(f)&&(e?d=b(d,a[f],f,a):(d=a[f],e=!0));return d},c.substr="b"!=="ab".substr(-1)?function(a,b,c){return 0>b&&(b=a.length+b),a.substr(b,c)}:function(a,b,c){return a.substr(b,c)},c.trim=function(a){return a.trim?a.trim():a.replace(/^\s+|\s+$/g,"")},c.bind=function(){var a=Array.prototype.slice.call(arguments),b=a.shift();if(b.bind)return b.bind.apply(b,a);var c=a.shift();return function(){b.apply(c,a.concat([Array.prototype.slice.call(arguments)]))}},c.create="function"==typeof Object.create?Object.create:e;var l="function"==typeof Object.keys?Object.keys:g,m="function"==typeof Object.getOwnPropertyNames?Object.getOwnPropertyNames:h;if((new Error).hasOwnProperty("description")){var n=function(a,b){return"[object Error]"===j.call(a)&&(b=c.filter(b,function(a){return"description"!==a&&"number"!==a&&"message"!==a})),b};c.keys=function(a){return n(a,l(a))},c.getOwnPropertyNames=function(a){return n(a,m(a))}}else c.keys=l,c.getOwnPropertyNames=m;if("function"==typeof Object.getOwnPropertyDescriptor)try{Object.getOwnPropertyDescriptor({a:1},"a"),c.getOwnPropertyDescriptor=Object.getOwnPropertyDescriptor}catch(o){c.getOwnPropertyDescriptor=function(a,b){try{return Object.getOwnPropertyDescriptor(a,b)}catch(c){return i(a,b)}}}else c.getOwnPropertyDescriptor=i},{}],3:[function(a,b){function c(a,b){return m.isUndefined(b)?""+b:!m.isNumber(b)||!isNaN(b)&&isFinite(b)?m.isFunction(b)||m.isRegExp(b)?b.toString():b:b.toString()}function d(a,b){return m.isString(a)?a.length=0;d--)if(e[d]!=f[d])return!1;for(d=e.length-1;d>=0;d--)if(c=e[d],!h(a[c],b[c]))return!1;return!0}function k(a,b){return a&&b?"[object RegExp]"==Object.prototype.toString.call(b)?b.test(a):a instanceof b?!0:b.call({},a)===!0?!0:!1:!1}function l(a,b,c,d){var e;m.isString(c)&&(d=c,c=null);try{b()}catch(g){e=g}if(d=(c&&c.name?" ("+c.name+").":".")+(d?" "+d:"."),a&&!e&&f(e,c,"Missing expected exception"+d),!a&&k(e,c)&&f(e,c,"Got unwanted exception"+d),a&&e&&c&&!k(e,c)||!a&&e)throw e}var m=a("util"),n=a("_shims"),o=Array.prototype.slice,p=b.exports=g;p.AssertionError=function(a){this.name="AssertionError",this.actual=a.actual,this.expected=a.expected,this.operator=a.operator,this.message=a.message||e(this)},m.inherits(p.AssertionError,Error),p.fail=f,p.ok=g,p.equal=function(a,b,c){a!=b&&f(a,b,c,"==",p.equal)},p.notEqual=function(a,b,c){a==b&&f(a,b,c,"!=",p.notEqual)},p.deepEqual=function(a,b,c){h(a,b)||f(a,b,c,"deepEqual",p.deepEqual)},p.notDeepEqual=function(a,b,c){h(a,b)&&f(a,b,c,"notDeepEqual",p.notDeepEqual)},p.strictEqual=function(a,b,c){a!==b&&f(a,b,c,"===",p.strictEqual)},p.notStrictEqual=function(a,b,c){a===b&&f(a,b,c,"!==",p.notStrictEqual)},p.throws=function(){l.apply(this,[!0].concat(o.call(arguments)))},p.doesNotThrow=function(){l.apply(this,[!1].concat(o.call(arguments)))},p.ifError=function(a){if(a)throw a}},{_shims:2,util:8}],4:[function(a,b){function c(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}var d=a("util");b.exports=c,c.EventEmitter=c,c.prototype._events=void 0,c.prototype._maxListeners=void 0,c.defaultMaxListeners=10,c.prototype.setMaxListeners=function(a){if(!d.isNumber(a)||0>a)throw TypeError("n must be a positive number");return this._maxListeners=a,this},c.prototype.emit=function(a){var b,c,e,f,g,h;if(this._events||(this._events={}),"error"===a&&(!this._events.error||d.isObject(this._events.error)&&!this._events.error.length))throw b=arguments[1],b instanceof Error?b:TypeError('Uncaught, unspecified "error" event.');if(c=this._events[a],d.isUndefined(c))return!1;if(d.isFunction(c))switch(arguments.length){case 1:c.call(this);break;case 2:c.call(this,arguments[1]);break;case 3:c.call(this,arguments[1],arguments[2]);break;default:for(e=arguments.length,f=new Array(e-1),g=1;e>g;g++)f[g-1]=arguments[g];c.apply(this,f)}else if(d.isObject(c)){for(e=arguments.length,f=new Array(e-1),g=1;e>g;g++)f[g-1]=arguments[g];for(h=c.slice(),e=h.length,g=0;e>g;g++)h[g].apply(this,f)}return!0},c.prototype.addListener=function(a,b){var e;if(!d.isFunction(b))throw TypeError("listener must be a function");if(this._events||(this._events={}),this._events.newListener&&this.emit("newListener",a,d.isFunction(b.listener)?b.listener:b),this._events[a]?d.isObject(this._events[a])?this._events[a].push(b):this._events[a]=[this._events[a],b]:this._events[a]=b,d.isObject(this._events[a])&&!this._events[a].warned){var e;e=d.isUndefined(this._maxListeners)?c.defaultMaxListeners:this._maxListeners,e&&e>0&&this._events[a].length>e&&(this._events[a].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[a].length),console.trace())}return this},c.prototype.on=c.prototype.addListener,c.prototype.once=function(a,b){function c(){this.removeListener(a,c),b.apply(this,arguments)}if(!d.isFunction(b))throw TypeError("listener must be a function");return c.listener=b,this.on(a,c),this},c.prototype.removeListener=function(a,b){var c,e,f,g;if(!d.isFunction(b))throw TypeError("listener must be a function");if(!this._events||!this._events[a])return this;if(c=this._events[a],f=c.length,e=-1,c===b||d.isFunction(c.listener)&&c.listener===b)delete this._events[a],this._events.removeListener&&this.emit("removeListener",a,b);else if(d.isObject(c)){for(g=f;g-->0;)if(c[g]===b||c[g].listener&&c[g].listener===b){e=g;break}if(0>e)return this;1===c.length?(c.length=0,delete this._events[a]):c.splice(e,1),this._events.removeListener&&this.emit("removeListener",a,b)}return this},c.prototype.removeAllListeners=function(a){var b,c;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[a]&&delete this._events[a],this;if(0===arguments.length){for(b in this._events)"removeListener"!==b&&this.removeAllListeners(b);return this.removeAllListeners("removeListener"),this._events={},this}if(c=this._events[a],d.isFunction(c))this.removeListener(a,c);else for(;c.length;)this.removeListener(a,c[c.length-1]);return delete this._events[a],this},c.prototype.listeners=function(a){var b;return b=this._events&&this._events[a]?d.isFunction(this._events[a])?[this._events[a]]:this._events[a].slice():[]},c.listenerCount=function(a,b){var c;return c=a._events&&a._events[b]?d.isFunction(a._events[b])?1:a._events[b].length:0}},{util:8}],5:[function(a,b,c){function d(a,b){for(var c=0,d=a.length-1;d>=0;d--){var e=a[d];"."===e?a.splice(d,1):".."===e?(a.splice(d,1),c++):c&&(a.splice(d,1),c--)}if(b)for(;c--;c)a.unshift("..");return a}var e=a("__browserify_process"),f=a("util"),g=a("_shims"),h=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/,i=function(a){return h.exec(a).slice(1)};c.resolve=function(){for(var a="",b=!1,c=arguments.length-1;c>=-1&&!b;c--){var h=c>=0?arguments[c]:e.cwd();if(!f.isString(h))throw new TypeError("Arguments to path.resolve must be strings");h&&(a=h+"/"+a,b="/"===h.charAt(0))}return a=d(g.filter(a.split("/"),function(a){return!!a}),!b).join("/"),(b?"/":"")+a||"."},c.normalize=function(a){var b=c.isAbsolute(a),e="/"===g.substr(a,-1);return a=d(g.filter(a.split("/"),function(a){return!!a}),!b).join("/"),a||b||(a="."),a&&e&&(a+="/"),(b?"/":"")+a},c.isAbsolute=function(a){return"/"===a.charAt(0)},c.join=function(){var a=Array.prototype.slice.call(arguments,0);return c.normalize(g.filter(a,function(a){if(!f.isString(a))throw new TypeError("Arguments to path.join must be strings");return a}).join("/"))},c.relative=function(a,b){function d(a){for(var b=0;b=0&&""===a[c];c--);return b>c?[]:a.slice(b,c-b+1)}a=c.resolve(a).substr(1),b=c.resolve(b).substr(1);for(var e=d(a.split("/")),f=d(b.split("/")),g=Math.min(e.length,f.length),h=g,i=0;g>i;i++)if(e[i]!==f[i]){h=i;break}for(var j=[],i=h;i0&&k>j&&(k=j);for(var l=0;k>l;++l){var m,n,o,p,q=a[l].replace(i,"%20"),r=q.indexOf(c);r>=0?(m=q.substr(0,r),n=q.substr(r+1)):(m=q,n="");try{o=decodeURIComponent(m),p=decodeURIComponent(n)}catch(s){o=f.unescape(m,!0),p=f.unescape(n,!0)}d(h,o)?g.isArray(h[o])?h[o].push(p):h[o]=[h[o],p]:h[o]=p}return h}},{_shims:2,buffer:10,util:8}],7:[function(a,b,c){function d(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}function e(a,b,c){if(a&&j.isObject(a)&&a instanceof d)return a;var e=new d;return e.parse(a,b,c),e}function f(a){return j.isString(a)&&(a=e(a)),a instanceof d?a.format():d.prototype.format.call(a)}function g(a,b){return e(a,!1,!0).resolve(b)}function h(a,b){return a?e(a,!1,!0).resolveObject(b):b}var i={encode:function(a){return a}},j=a("util"),k=a("_shims");c.parse=e,c.resolve=g,c.resolveObject=h,c.format=f,c.Url=d;var l=/^([a-z0-9.+-]+:)/i,m=/:[0-9]*$/,n=["<",">",'"',"`"," ","\r","\n"," "],o=["{","}","|","\\","^","`"].concat(n),p=["'"].concat(o),q=["%","/","?",";","#"].concat(p),r=["/","?","#"],s=255,t=/^[a-z0-9A-Z_-]{0,63}$/,u=/^([a-z0-9A-Z_-]{0,63})(.*)$/,v={javascript:!0,"javascript:":!0},w={javascript:!0,"javascript:":!0},x={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},y=a("querystring");d.prototype.parse=function(a,b,c){if(!j.isString(a))throw new TypeError("Parameter 'url' must be a string, not "+typeof a);var d=a;d=k.trim(d);var e=l.exec(d);if(e){e=e[0];var f=e.toLowerCase();this.protocol=f,d=d.substr(e.length)}if(c||e||d.match(/^\/\/[^@\/]+@[^@\/]+/)){var g="//"===d.substr(0,2);!g||e&&w[e]||(d=d.substr(2),this.slashes=!0)}if(!w[e]&&(g||e&&!x[e])){for(var h=-1,m=0;mn)&&(h=n)}var o,z;z=-1===h?d.lastIndexOf("@"):d.lastIndexOf("@",h),-1!==z&&(o=d.slice(0,z),d=d.slice(z+1),this.auth=decodeURIComponent(o)),h=-1;for(var m=0;mn)&&(h=n)}-1===h&&(h=d.length),this.host=d.slice(0,h),d=d.slice(h),this.parseHost(),this.hostname=this.hostname||"";var A="["===this.hostname[0]&&"]"===this.hostname[this.hostname.length-1];if(!A)for(var B=this.hostname.split(/\./),m=0,C=B.length;C>m;m++){var D=B[m];if(D&&!D.match(t)){for(var E="",F=0,G=D.length;G>F;F++)E+=D.charCodeAt(F)>127?"x":D[F];if(!E.match(t)){var H=B.slice(0,m),I=B.slice(m+1),J=D.match(u);J&&(H.push(J[1]),I.unshift(J[2])),I.length&&(d="/"+I.join(".")+d),this.hostname=H.join(".");break}}}if(this.hostname=this.hostname.length>s?"":this.hostname.toLowerCase(),!A){for(var K=this.hostname.split("."),L=[],m=0;mm;m++){var P=p[m],Q=encodeURIComponent(P);Q===P&&(Q=escape(P)),d=d.split(P).join(Q)}var R=d.indexOf("#");-1!==R&&(this.hash=d.substr(R),d=d.slice(0,R));var S=d.indexOf("?");if(-1!==S?(this.search=d.substr(S),this.query=d.substr(S+1),b&&(this.query=y.parse(this.query)),d=d.slice(0,S)):b&&(this.search="",this.query={}),d&&(this.pathname=d),x[f]&&this.hostname&&!this.pathname&&(this.pathname="/"),this.pathname||this.search){var N=this.pathname||"",M=this.search||"";this.path=N+M}return this.href=this.format(),this},d.prototype.format=function(){var a=this.auth||"";a&&(a=encodeURIComponent(a),a=a.replace(/%3A/i,":"),a+="@");var b=this.protocol||"",c=this.pathname||"",d=this.hash||"",e=!1,f="";this.host?e=a+this.host:this.hostname&&(e=a+(-1===this.hostname.indexOf(":")?this.hostname:"["+this.hostname+"]"),this.port&&(e+=":"+this.port)),this.query&&j.isObject(this.query)&&k.keys(this.query).length&&(f=y.stringify(this.query));var g=this.search||f&&"?"+f||"";return b&&":"!==k.substr(b,-1)&&(b+=":"),this.slashes||(!b||x[b])&&e!==!1?(e="//"+(e||""),c&&"/"!==c.charAt(0)&&(c="/"+c)):e||(e=""),d&&"#"!==d.charAt(0)&&(d="#"+d),g&&"?"!==g.charAt(0)&&(g="?"+g),c=c.replace(/[?#]/g,function(a){return encodeURIComponent(a)}),g=g.replace("#","%23"),b+e+c+g+d},d.prototype.resolve=function(a){return this.resolveObject(e(a,!1,!0)).format()},d.prototype.resolveObject=function(a){if(j.isString(a)){var b=new d;b.parse(a,!1,!0),a=b}var c=new d;if(k.forEach(k.keys(this),function(a){c[a]=this[a]},this),c.hash=a.hash,""===a.href)return c.href=c.format(),c;if(a.slashes&&!a.protocol)return k.forEach(k.keys(a),function(b){"protocol"!==b&&(c[b]=a[b])}),x[c.protocol]&&c.hostname&&!c.pathname&&(c.path=c.pathname="/"),c.href=c.format(),c;if(a.protocol&&a.protocol!==c.protocol){if(!x[a.protocol])return k.forEach(k.keys(a),function(b){c[b]=a[b]}),c.href=c.format(),c;if(c.protocol=a.protocol,a.host||w[a.protocol])c.pathname=a.pathname;else{for(var e=(a.pathname||"").split("/");e.length&&!(a.host=e.shift()););a.host||(a.host=""),a.hostname||(a.hostname=""),""!==e[0]&&e.unshift(""),e.length<2&&e.unshift(""),c.pathname=e.join("/")}if(c.search=a.search,c.query=a.query,c.host=a.host||"",c.auth=a.auth,c.hostname=a.hostname||a.host,c.port=a.port,c.pathname||c.search){var f=c.pathname||"",g=c.search||"";c.path=f+g}return c.slashes=c.slashes||a.slashes,c.href=c.format(),c}var h=c.pathname&&"/"===c.pathname.charAt(0),i=a.host||a.pathname&&"/"===a.pathname.charAt(0),l=i||h||c.host&&a.pathname,m=l,n=c.pathname&&c.pathname.split("/")||[],e=a.pathname&&a.pathname.split("/")||[],o=c.protocol&&!x[c.protocol];if(o&&(c.hostname="",c.port=null,c.host&&(""===n[0]?n[0]=c.host:n.unshift(c.host)),c.host="",a.protocol&&(a.hostname=null,a.port=null,a.host&&(""===e[0]?e[0]=a.host:e.unshift(a.host)),a.host=null),l=l&&(""===e[0]||""===n[0])),i)c.host=a.host||""===a.host?a.host:c.host,c.hostname=a.hostname||""===a.hostname?a.hostname:c.hostname,c.search=a.search,c.query=a.query,n=e;else if(e.length)n||(n=[]),n.pop(),n=n.concat(e),c.search=a.search,c.query=a.query;else if(!j.isNullOrUndefined(a.search)){if(o){c.hostname=c.host=n.shift();var p=c.host&&c.host.indexOf("@")>0?c.host.split("@"):!1;p&&(c.auth=p.shift(),c.host=c.hostname=p.shift())}return c.search=a.search,c.query=a.query,j.isNull(c.pathname)&&j.isNull(c.search)||(c.path=(c.pathname?c.pathname:"")+(c.search?c.search:"")),c.href=c.format(),c}if(!n.length)return c.pathname=null,c.path=c.search?"/"+c.search:null,c.href=c.format(),c;for(var q=n.slice(-1)[0],r=(c.host||a.host)&&("."===q||".."===q)||""===q,s=0,t=n.length;t>=0;t--)q=n[t],"."==q?n.splice(t,1):".."===q?(n.splice(t,1),s++):s&&(n.splice(t,1),s--);if(!l&&!m)for(;s--;s)n.unshift("..");!l||""===n[0]||n[0]&&"/"===n[0].charAt(0)||n.unshift(""),r&&"/"!==k.substr(n.join("/"),-1)&&n.push("");var u=""===n[0]||n[0]&&"/"===n[0].charAt(0);if(o){c.hostname=c.host=u?"":n.length?n.shift():"";var p=c.host&&c.host.indexOf("@")>0?c.host.split("@"):!1;p&&(c.auth=p.shift(),c.host=c.hostname=p.shift())}return l=l||c.host&&n.length,l&&!u&&n.unshift(""),n.length?c.pathname=n.join("/"):(c.pathname=null,c.path=null),j.isNull(c.pathname)&&j.isNull(c.search)||(c.path=(c.pathname?c.pathname:"")+(c.search?c.search:"")),c.auth=a.auth||c.auth,c.slashes=c.slashes||a.slashes,c.href=c.format(),c},d.prototype.parseHost=function(){var a=this.host,b=m.exec(a);b&&(b=b[0],":"!==b&&(this.port=b.substr(1)),a=a.substr(0,a.length-b.length)),a&&(this.hostname=a)}},{_shims:2,querystring:6,util:8}],8:[function(a,b,c){function d(a,b){var d={seen:[],stylize:f};return arguments.length>=3&&(d.depth=arguments[2]),arguments.length>=4&&(d.colors=arguments[3]),o(b)?d.showHidden=b:b&&c._extend(d,b),u(d.showHidden)&&(d.showHidden=!1),u(d.depth)&&(d.depth=2),u(d.colors)&&(d.colors=!1),u(d.customInspect)&&(d.customInspect=!0),d.colors&&(d.stylize=e),h(d,a,d.depth)}function e(a,b){var c=d.styles[b];return c?"["+d.colors[c][0]+"m"+a+"["+d.colors[c][1]+"m":a}function f(a){return a}function g(a){var b={};return G.forEach(a,function(a){b[a]=!0}),b}function h(a,b,d){if(a.customInspect&&b&&z(b.inspect)&&b.inspect!==c.inspect&&(!b.constructor||b.constructor.prototype!==b)){var e=b.inspect(d);return s(e)||(e=h(a,e,d)),e}var f=i(a,b);if(f)return f;var o=G.keys(b),p=g(o);if(a.showHidden&&(o=G.getOwnPropertyNames(b)),0===o.length){if(z(b)){var q=b.name?": "+b.name:"";return a.stylize("[Function"+q+"]","special")}if(v(b))return a.stylize(RegExp.prototype.toString.call(b),"regexp");if(x(b))return a.stylize(Date.prototype.toString.call(b),"date");if(y(b))return j(b)}var r="",t=!1,u=["{","}"];if(n(b)&&(t=!0,u=["[","]"]),z(b)){var w=b.name?": "+b.name:"";r=" [Function"+w+"]"}if(v(b)&&(r=" "+RegExp.prototype.toString.call(b)),x(b)&&(r=" "+Date.prototype.toUTCString.call(b)),y(b)&&(r=" "+j(b)),0===o.length&&(!t||0==b.length))return u[0]+r+u[1];if(0>d)return v(b)?a.stylize(RegExp.prototype.toString.call(b),"regexp"):a.stylize("[Object]","special");a.seen.push(b);var A;return A=t?k(a,b,d,p,o):o.map(function(c){return l(a,b,d,p,c,t)}),a.seen.pop(),m(A,r,u)}function i(a,b){if(u(b))return a.stylize("undefined","undefined");if(s(b)){var c="'"+JSON.stringify(b).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return a.stylize(c,"string")}return r(b)?a.stylize(""+b,"number"):o(b)?a.stylize(""+b,"boolean"):p(b)?a.stylize("null","null"):void 0}function j(a){return"["+Error.prototype.toString.call(a)+"]"}function k(a,b,c,d,e){for(var f=[],g=0,h=b.length;h>g;++g)F(b,String(g))?f.push(l(a,b,c,d,String(g),!0)):f.push("");return G.forEach(e,function(e){e.match(/^\d+$/)||f.push(l(a,b,c,d,e,!0))}),f}function l(a,b,c,d,e,f){var g,i,j;if(j=G.getOwnPropertyDescriptor(b,e)||{value:b[e]},j.get?i=j.set?a.stylize("[Getter/Setter]","special"):a.stylize("[Getter]","special"):j.set&&(i=a.stylize("[Setter]","special")),F(d,e)||(g="["+e+"]"),i||(G.indexOf(a.seen,j.value)<0?(i=p(c)?h(a,j.value,null):h(a,j.value,c-1),i.indexOf("\n")>-1&&(i=f?i.split("\n").map(function(a){return" "+a}).join("\n").substr(2):"\n"+i.split("\n").map(function(a){return" "+a}).join("\n"))):i=a.stylize("[Circular]","special")),u(g)){if(f&&e.match(/^\d+$/))return i;g=JSON.stringify(""+e),g.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(g=g.substr(1,g.length-2),g=a.stylize(g,"name")):(g=g.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),g=a.stylize(g,"string"))}return g+": "+i}function m(a,b,c){var d=0,e=G.reduce(a,function(a,b){return d++,b.indexOf("\n")>=0&&d++,a+b.replace(/\u001b\[\d\d?m/g,"").length+1},0);return e>60?c[0]+(""===b?"":b+"\n ")+" "+a.join(",\n ")+" "+c[1]:c[0]+b+" "+a.join(", ")+" "+c[1]}function n(a){return G.isArray(a)}function o(a){return"boolean"==typeof a}function p(a){return null===a}function q(a){return null==a}function r(a){return"number"==typeof a}function s(a){return"string"==typeof a}function t(a){return"symbol"==typeof a}function u(a){return void 0===a}function v(a){return w(a)&&"[object RegExp]"===C(a)}function w(a){return"object"==typeof a&&a}function x(a){return w(a)&&"[object Date]"===C(a)}function y(a){return w(a)&&"[object Error]"===C(a)}function z(a){return"function"==typeof a}function A(a){return null===a||"boolean"==typeof a||"number"==typeof a||"string"==typeof a||"symbol"==typeof a||"undefined"==typeof a}function B(a){return a&&"object"==typeof a&&"function"==typeof a.copy&&"function"==typeof a.fill&&"function"==typeof a.binarySlice}function C(a){return Object.prototype.toString.call(a)}function D(a){return 10>a?"0"+a.toString(10):a.toString(10)}function E(){var a=new Date,b=[D(a.getHours()),D(a.getMinutes()),D(a.getSeconds())].join(":");return[a.getDate(),I[a.getMonth()],b].join(" ")}function F(a,b){return Object.prototype.hasOwnProperty.call(a,b)}var G=a("_shims"),H=/%[sdj%]/g;c.format=function(a){if(!s(a)){for(var b=[],c=0;c=f)return a;switch(a){case"%s":return String(e[c++]);case"%d":return Number(e[c++]);case"%j":try{return JSON.stringify(e[c++])}catch(b){return"[Circular]"}default:return a}}),h=e[c];f>c;h=e[++c])g+=p(h)||!w(h)?" "+h:" "+d(h);return g},c.inspect=d,d.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},d.styles={special:"cyan",number:"yellow","boolean":"yellow",undefined:"grey","null":"bold",string:"green",date:"magenta",regexp:"red"},c.isArray=n,c.isBoolean=o,c.isNull=p,c.isNullOrUndefined=q,c.isNumber=r,c.isString=s,c.isSymbol=t,c.isUndefined=u,c.isRegExp=v,c.isObject=w,c.isDate=x,c.isError=y,c.isFunction=z,c.isPrimitive=A,c.isBuffer=B;var I=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];c.log=function(){console.log("%s - %s",E(),c.format.apply(c,arguments))},c.inherits=function(a,b){a.super_=b,a.prototype=G.create(b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}})},c._extend=function(a,b){if(!b||!w(b))return a;for(var c=G.keys(b),d=c.length;d--;)a[c[d]]=b[c[d]];return a}},{_shims:2}],9:[function(a,b,c){c.readIEEE754=function(a,b,c,d,e){var f,g,h=8*e-d-1,i=(1<>1,k=-7,l=c?0:e-1,m=c?1:-1,n=a[b+l];for(l+=m,f=n&(1<<-k)-1,n>>=-k,k+=h;k>0;f=256*f+a[b+l],l+=m,k-=8);for(g=f&(1<<-k)-1,f>>=-k,k+=d;k>0;g=256*g+a[b+l],l+=m,k-=8);if(0===f)f=1-j;else{if(f===i)return g?0/0:1/0*(n?-1:1);g+=Math.pow(2,d),f-=j}return(n?-1:1)*g*Math.pow(2,f-d)},c.writeIEEE754=function(a,b,c,d,e,f){var g,h,i,j=8*f-e-1,k=(1<>1,m=23===e?Math.pow(2,-24)-Math.pow(2,-77):0,n=d?f-1:0,o=d?-1:1,p=0>b||0===b&&0>1/b?1:0;for(b=Math.abs(b),isNaN(b)||1/0===b?(h=isNaN(b)?1:0,g=k):(g=Math.floor(Math.log(b)/Math.LN2),b*(i=Math.pow(2,-g))<1&&(g--,i*=2),b+=g+l>=1?m/i:m*Math.pow(2,1-l),b*i>=2&&(g++,i/=2),g+l>=k?(h=0,g=k):g+l>=1?(h=(b*i-1)*Math.pow(2,e),g+=l):(h=b*Math.pow(2,l-1)*Math.pow(2,e),g=0));e>=8;a[c+n]=255&h,n+=o,h/=256,e-=8);for(g=g<0;a[c+n]=255&g,n+=o,g/=256,j-=8);a[c+n-o]|=128*p}},{}],10:[function(a,b,c){function d(a){return a.trim?a.trim():a.replace(/^\s+|\s+$/g,"")}function e(b,c,f){if(E||(E=a("assert")),!(this instanceof e))return new e(b,c,f);if(this.parent=this,this.offset=0,"base64"==c&&"string"==typeof b)for(b=d(b);0!=b.length%4;)b+="=";var h;if("number"==typeof f){this.length=g(c);for(var j=0;j=b?b:a>=0?a:(a+=b,a>=0?a:0))}function g(a){return a=~~Math.ceil(+a),0>a?0:a}function h(a){return(Array.isArray||function(a){return"[object Array]"=={}.toString.apply(a)})(a)}function i(a){return h(a)||e.isBuffer(a)||a&&"object"==typeof a&&"number"==typeof a.length}function j(a){return 16>a?"0"+a.toString(16):a.toString(16)}function k(a){for(var b=[],c=0;ce&&!(e+c>=b.length||e>=a.length);)b[e+c]=a[e],e++;return e}function o(a){try{return decodeURIComponent(a)}catch(b){return String.fromCharCode(65533)}}function p(a,b,c,d){var e=0;return d||(E.ok("boolean"==typeof c,"missing or invalid endian"),E.ok(void 0!==b&&null!==b,"missing offset"),E.ok(b+1=a.length?0:(c?(e=a[b]<<8,b+1=a.length?0:(c?(b+1>>0):(b+2>>0)),e)}function r(a,b,c,d){var e,f;return d||(E.ok("boolean"==typeof c,"missing or invalid endian"),E.ok(void 0!==b&&null!==b,"missing offset"),E.ok(b+1=0,"specified a negative value for writing an unsigned value"),E.ok(b>=a,"value is larger than maximum value for type"),E.ok(Math.floor(a)===a,"value has a fractional component")}function w(a,b,c,d,e){e||(E.ok(void 0!==b&&null!==b,"missing value"),E.ok("boolean"==typeof d,"missing or invalid endian"),E.ok(void 0!==c&&null!==c,"missing offset"),E.ok(c+1>>8*(d?1-f:f)}function x(a,b,c,d,e){e||(E.ok(void 0!==b&&null!==b,"missing value"),E.ok("boolean"==typeof d,"missing or invalid endian"),E.ok(void 0!==c&&null!==c,"missing offset"),E.ok(c+3>>8*(d?3-f:f)}function y(a,b,c){E.ok("number"==typeof a,"cannot write a non-number as a number"),E.ok(b>=a,"value larger than maximum allowed value"),E.ok(a>=c,"value smaller than minimum allowed value"),E.ok(Math.floor(a)===a,"value has a fractional component")}function z(a,b,c){E.ok("number"==typeof a,"cannot write a non-number as a number"),E.ok(b>=a,"value larger than maximum allowed value"),E.ok(a>=c,"value smaller than minimum allowed value")}function A(a,b,c,d,e){e||(E.ok(void 0!==b&&null!==b,"missing value"),E.ok("boolean"==typeof d,"missing or invalid endian"),E.ok(void 0!==c&&null!==c,"missing offset"),E.ok(c+1=0?w(a,b,c,d,e):w(a,65535+b+1,c,d,e)}function B(a,b,c,d,e){e||(E.ok(void 0!==b&&null!==b,"missing value"),E.ok("boolean"==typeof d,"missing or invalid endian"),E.ok(void 0!==c&&null!==c,"missing offset"),E.ok(c+3=0?x(a,b,c,d,e):x(a,4294967295+b+1,c,d,e) +!function(a){"object"==typeof exports?module.exports=a():"function"==typeof define&&define.amd?define(a):"undefined"!=typeof window?window.elasticsearch=a():"undefined"!=typeof global?global.elasticsearch=a():"undefined"!=typeof self&&(self.elasticsearch=a())}(function(){var a;return function b(a,c,d){function e(g,h){if(!c[g]){if(!a[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);throw new Error("Cannot find module '"+g+"'")}var j=c[g]={exports:{}};a[g][0].call(j.exports,function(b){var c=a[g][1][b];return e(c?c:b)},j,j.exports,b,a,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;gf;++f)a.hasOwnProperty(f)&&(e?d=b(d,a[f],f,a):(d=a[f],e=!0));return d},c.substr="b"!=="ab".substr(-1)?function(a,b,c){return 0>b&&(b=a.length+b),a.substr(b,c)}:function(a,b,c){return a.substr(b,c)},c.trim=function(a){return a.trim?a.trim():a.replace(/^\s+|\s+$/g,"")},c.bind=function(){var a=Array.prototype.slice.call(arguments),b=a.shift();if(b.bind)return b.bind.apply(b,a);var c=a.shift();return function(){b.apply(c,a.concat([Array.prototype.slice.call(arguments)]))}},c.create="function"==typeof Object.create?Object.create:e;var l="function"==typeof Object.keys?Object.keys:g,m="function"==typeof Object.getOwnPropertyNames?Object.getOwnPropertyNames:h;if((new Error).hasOwnProperty("description")){var n=function(a,b){return"[object Error]"===j.call(a)&&(b=c.filter(b,function(a){return"description"!==a&&"number"!==a&&"message"!==a})),b};c.keys=function(a){return n(a,l(a))},c.getOwnPropertyNames=function(a){return n(a,m(a))}}else c.keys=l,c.getOwnPropertyNames=m;if("function"==typeof Object.getOwnPropertyDescriptor)try{Object.getOwnPropertyDescriptor({a:1},"a"),c.getOwnPropertyDescriptor=Object.getOwnPropertyDescriptor}catch(o){c.getOwnPropertyDescriptor=function(a,b){try{return Object.getOwnPropertyDescriptor(a,b)}catch(c){return i(a,b)}}}else c.getOwnPropertyDescriptor=i},{}],3:[function(a,b){function c(a,b){return m.isUndefined(b)?""+b:!m.isNumber(b)||!isNaN(b)&&isFinite(b)?m.isFunction(b)||m.isRegExp(b)?b.toString():b:b.toString()}function d(a,b){return m.isString(a)?a.length=0;d--)if(e[d]!=f[d])return!1;for(d=e.length-1;d>=0;d--)if(c=e[d],!h(a[c],b[c]))return!1;return!0}function k(a,b){return a&&b?"[object RegExp]"==Object.prototype.toString.call(b)?b.test(a):a instanceof b?!0:b.call({},a)===!0?!0:!1:!1}function l(a,b,c,d){var e;m.isString(c)&&(d=c,c=null);try{b()}catch(g){e=g}if(d=(c&&c.name?" ("+c.name+").":".")+(d?" "+d:"."),a&&!e&&f(e,c,"Missing expected exception"+d),!a&&k(e,c)&&f(e,c,"Got unwanted exception"+d),a&&e&&c&&!k(e,c)||!a&&e)throw e}var m=a("util"),n=a("_shims"),o=Array.prototype.slice,p=b.exports=g;p.AssertionError=function(a){this.name="AssertionError",this.actual=a.actual,this.expected=a.expected,this.operator=a.operator,this.message=a.message||e(this)},m.inherits(p.AssertionError,Error),p.fail=f,p.ok=g,p.equal=function(a,b,c){a!=b&&f(a,b,c,"==",p.equal)},p.notEqual=function(a,b,c){a==b&&f(a,b,c,"!=",p.notEqual)},p.deepEqual=function(a,b,c){h(a,b)||f(a,b,c,"deepEqual",p.deepEqual)},p.notDeepEqual=function(a,b,c){h(a,b)&&f(a,b,c,"notDeepEqual",p.notDeepEqual)},p.strictEqual=function(a,b,c){a!==b&&f(a,b,c,"===",p.strictEqual)},p.notStrictEqual=function(a,b,c){a===b&&f(a,b,c,"!==",p.notStrictEqual)},p.throws=function(){l.apply(this,[!0].concat(o.call(arguments)))},p.doesNotThrow=function(){l.apply(this,[!1].concat(o.call(arguments)))},p.ifError=function(a){if(a)throw a}},{_shims:2,util:8}],4:[function(a,b){function c(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}var d=a("util");b.exports=c,c.EventEmitter=c,c.prototype._events=void 0,c.prototype._maxListeners=void 0,c.defaultMaxListeners=10,c.prototype.setMaxListeners=function(a){if(!d.isNumber(a)||0>a)throw TypeError("n must be a positive number");return this._maxListeners=a,this},c.prototype.emit=function(a){var b,c,e,f,g,h;if(this._events||(this._events={}),"error"===a&&(!this._events.error||d.isObject(this._events.error)&&!this._events.error.length))throw b=arguments[1],b instanceof Error?b:TypeError('Uncaught, unspecified "error" event.');if(c=this._events[a],d.isUndefined(c))return!1;if(d.isFunction(c))switch(arguments.length){case 1:c.call(this);break;case 2:c.call(this,arguments[1]);break;case 3:c.call(this,arguments[1],arguments[2]);break;default:for(e=arguments.length,f=new Array(e-1),g=1;e>g;g++)f[g-1]=arguments[g];c.apply(this,f)}else if(d.isObject(c)){for(e=arguments.length,f=new Array(e-1),g=1;e>g;g++)f[g-1]=arguments[g];for(h=c.slice(),e=h.length,g=0;e>g;g++)h[g].apply(this,f)}return!0},c.prototype.addListener=function(a,b){var e;if(!d.isFunction(b))throw TypeError("listener must be a function");if(this._events||(this._events={}),this._events.newListener&&this.emit("newListener",a,d.isFunction(b.listener)?b.listener:b),this._events[a]?d.isObject(this._events[a])?this._events[a].push(b):this._events[a]=[this._events[a],b]:this._events[a]=b,d.isObject(this._events[a])&&!this._events[a].warned){var e;e=d.isUndefined(this._maxListeners)?c.defaultMaxListeners:this._maxListeners,e&&e>0&&this._events[a].length>e&&(this._events[a].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[a].length),console.trace())}return this},c.prototype.on=c.prototype.addListener,c.prototype.once=function(a,b){function c(){this.removeListener(a,c),b.apply(this,arguments)}if(!d.isFunction(b))throw TypeError("listener must be a function");return c.listener=b,this.on(a,c),this},c.prototype.removeListener=function(a,b){var c,e,f,g;if(!d.isFunction(b))throw TypeError("listener must be a function");if(!this._events||!this._events[a])return this;if(c=this._events[a],f=c.length,e=-1,c===b||d.isFunction(c.listener)&&c.listener===b)delete this._events[a],this._events.removeListener&&this.emit("removeListener",a,b);else if(d.isObject(c)){for(g=f;g-->0;)if(c[g]===b||c[g].listener&&c[g].listener===b){e=g;break}if(0>e)return this;1===c.length?(c.length=0,delete this._events[a]):c.splice(e,1),this._events.removeListener&&this.emit("removeListener",a,b)}return this},c.prototype.removeAllListeners=function(a){var b,c;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[a]&&delete this._events[a],this;if(0===arguments.length){for(b in this._events)"removeListener"!==b&&this.removeAllListeners(b);return this.removeAllListeners("removeListener"),this._events={},this}if(c=this._events[a],d.isFunction(c))this.removeListener(a,c);else for(;c.length;)this.removeListener(a,c[c.length-1]);return delete this._events[a],this},c.prototype.listeners=function(a){var b;return b=this._events&&this._events[a]?d.isFunction(this._events[a])?[this._events[a]]:this._events[a].slice():[]},c.listenerCount=function(a,b){var c;return c=a._events&&a._events[b]?d.isFunction(a._events[b])?1:a._events[b].length:0}},{util:8}],5:[function(a,b,c){function d(a,b){for(var c=0,d=a.length-1;d>=0;d--){var e=a[d];"."===e?a.splice(d,1):".."===e?(a.splice(d,1),c++):c&&(a.splice(d,1),c--)}if(b)for(;c--;c)a.unshift("..");return a}var e=a("__browserify_process"),f=a("util"),g=a("_shims"),h=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/,i=function(a){return h.exec(a).slice(1)};c.resolve=function(){for(var a="",b=!1,c=arguments.length-1;c>=-1&&!b;c--){var h=c>=0?arguments[c]:e.cwd();if(!f.isString(h))throw new TypeError("Arguments to path.resolve must be strings");h&&(a=h+"/"+a,b="/"===h.charAt(0))}return a=d(g.filter(a.split("/"),function(a){return!!a}),!b).join("/"),(b?"/":"")+a||"."},c.normalize=function(a){var b=c.isAbsolute(a),e="/"===g.substr(a,-1);return a=d(g.filter(a.split("/"),function(a){return!!a}),!b).join("/"),a||b||(a="."),a&&e&&(a+="/"),(b?"/":"")+a},c.isAbsolute=function(a){return"/"===a.charAt(0)},c.join=function(){var a=Array.prototype.slice.call(arguments,0);return c.normalize(g.filter(a,function(a){if(!f.isString(a))throw new TypeError("Arguments to path.join must be strings");return a}).join("/"))},c.relative=function(a,b){function d(a){for(var b=0;b=0&&""===a[c];c--);return b>c?[]:a.slice(b,c-b+1)}a=c.resolve(a).substr(1),b=c.resolve(b).substr(1);for(var e=d(a.split("/")),f=d(b.split("/")),g=Math.min(e.length,f.length),h=g,i=0;g>i;i++)if(e[i]!==f[i]){h=i;break}for(var j=[],i=h;i0&&k>j&&(k=j);for(var l=0;k>l;++l){var m,n,o,p,q=a[l].replace(i,"%20"),r=q.indexOf(c);r>=0?(m=q.substr(0,r),n=q.substr(r+1)):(m=q,n="");try{o=decodeURIComponent(m),p=decodeURIComponent(n)}catch(s){o=f.unescape(m,!0),p=f.unescape(n,!0)}d(h,o)?g.isArray(h[o])?h[o].push(p):h[o]=[h[o],p]:h[o]=p}return h}},{_shims:2,buffer:10,util:8}],7:[function(a,b,c){function d(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}function e(a,b,c){if(a&&j.isObject(a)&&a instanceof d)return a;var e=new d;return e.parse(a,b,c),e}function f(a){return j.isString(a)&&(a=e(a)),a instanceof d?a.format():d.prototype.format.call(a)}function g(a,b){return e(a,!1,!0).resolve(b)}function h(a,b){return a?e(a,!1,!0).resolveObject(b):b}var i={encode:function(a){return a}},j=a("util"),k=a("_shims");c.parse=e,c.resolve=g,c.resolveObject=h,c.format=f,c.Url=d;var l=/^([a-z0-9.+-]+:)/i,m=/:[0-9]*$/,n=["<",">",'"',"`"," ","\r","\n"," "],o=["{","}","|","\\","^","`"].concat(n),p=["'"].concat(o),q=["%","/","?",";","#"].concat(p),r=["/","?","#"],s=255,t=/^[a-z0-9A-Z_-]{0,63}$/,u=/^([a-z0-9A-Z_-]{0,63})(.*)$/,v={javascript:!0,"javascript:":!0},w={javascript:!0,"javascript:":!0},x={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},y=a("querystring");d.prototype.parse=function(a,b,c){if(!j.isString(a))throw new TypeError("Parameter 'url' must be a string, not "+typeof a);var d=a;d=k.trim(d);var e=l.exec(d);if(e){e=e[0];var f=e.toLowerCase();this.protocol=f,d=d.substr(e.length)}if(c||e||d.match(/^\/\/[^@\/]+@[^@\/]+/)){var g="//"===d.substr(0,2);!g||e&&w[e]||(d=d.substr(2),this.slashes=!0)}if(!w[e]&&(g||e&&!x[e])){for(var h=-1,m=0;mn)&&(h=n)}var o,z;z=-1===h?d.lastIndexOf("@"):d.lastIndexOf("@",h),-1!==z&&(o=d.slice(0,z),d=d.slice(z+1),this.auth=decodeURIComponent(o)),h=-1;for(var m=0;mn)&&(h=n)}-1===h&&(h=d.length),this.host=d.slice(0,h),d=d.slice(h),this.parseHost(),this.hostname=this.hostname||"";var A="["===this.hostname[0]&&"]"===this.hostname[this.hostname.length-1];if(!A)for(var B=this.hostname.split(/\./),m=0,C=B.length;C>m;m++){var D=B[m];if(D&&!D.match(t)){for(var E="",F=0,G=D.length;G>F;F++)E+=D.charCodeAt(F)>127?"x":D[F];if(!E.match(t)){var H=B.slice(0,m),I=B.slice(m+1),J=D.match(u);J&&(H.push(J[1]),I.unshift(J[2])),I.length&&(d="/"+I.join(".")+d),this.hostname=H.join(".");break}}}if(this.hostname=this.hostname.length>s?"":this.hostname.toLowerCase(),!A){for(var K=this.hostname.split("."),L=[],m=0;mm;m++){var P=p[m],Q=encodeURIComponent(P);Q===P&&(Q=escape(P)),d=d.split(P).join(Q)}var R=d.indexOf("#");-1!==R&&(this.hash=d.substr(R),d=d.slice(0,R));var S=d.indexOf("?");if(-1!==S?(this.search=d.substr(S),this.query=d.substr(S+1),b&&(this.query=y.parse(this.query)),d=d.slice(0,S)):b&&(this.search="",this.query={}),d&&(this.pathname=d),x[f]&&this.hostname&&!this.pathname&&(this.pathname="/"),this.pathname||this.search){var N=this.pathname||"",M=this.search||"";this.path=N+M}return this.href=this.format(),this},d.prototype.format=function(){var a=this.auth||"";a&&(a=encodeURIComponent(a),a=a.replace(/%3A/i,":"),a+="@");var b=this.protocol||"",c=this.pathname||"",d=this.hash||"",e=!1,f="";this.host?e=a+this.host:this.hostname&&(e=a+(-1===this.hostname.indexOf(":")?this.hostname:"["+this.hostname+"]"),this.port&&(e+=":"+this.port)),this.query&&j.isObject(this.query)&&k.keys(this.query).length&&(f=y.stringify(this.query));var g=this.search||f&&"?"+f||"";return b&&":"!==k.substr(b,-1)&&(b+=":"),this.slashes||(!b||x[b])&&e!==!1?(e="//"+(e||""),c&&"/"!==c.charAt(0)&&(c="/"+c)):e||(e=""),d&&"#"!==d.charAt(0)&&(d="#"+d),g&&"?"!==g.charAt(0)&&(g="?"+g),c=c.replace(/[?#]/g,function(a){return encodeURIComponent(a)}),g=g.replace("#","%23"),b+e+c+g+d},d.prototype.resolve=function(a){return this.resolveObject(e(a,!1,!0)).format()},d.prototype.resolveObject=function(a){if(j.isString(a)){var b=new d;b.parse(a,!1,!0),a=b}var c=new d;if(k.forEach(k.keys(this),function(a){c[a]=this[a]},this),c.hash=a.hash,""===a.href)return c.href=c.format(),c;if(a.slashes&&!a.protocol)return k.forEach(k.keys(a),function(b){"protocol"!==b&&(c[b]=a[b])}),x[c.protocol]&&c.hostname&&!c.pathname&&(c.path=c.pathname="/"),c.href=c.format(),c;if(a.protocol&&a.protocol!==c.protocol){if(!x[a.protocol])return k.forEach(k.keys(a),function(b){c[b]=a[b]}),c.href=c.format(),c;if(c.protocol=a.protocol,a.host||w[a.protocol])c.pathname=a.pathname;else{for(var e=(a.pathname||"").split("/");e.length&&!(a.host=e.shift()););a.host||(a.host=""),a.hostname||(a.hostname=""),""!==e[0]&&e.unshift(""),e.length<2&&e.unshift(""),c.pathname=e.join("/")}if(c.search=a.search,c.query=a.query,c.host=a.host||"",c.auth=a.auth,c.hostname=a.hostname||a.host,c.port=a.port,c.pathname||c.search){var f=c.pathname||"",g=c.search||"";c.path=f+g}return c.slashes=c.slashes||a.slashes,c.href=c.format(),c}var h=c.pathname&&"/"===c.pathname.charAt(0),i=a.host||a.pathname&&"/"===a.pathname.charAt(0),l=i||h||c.host&&a.pathname,m=l,n=c.pathname&&c.pathname.split("/")||[],e=a.pathname&&a.pathname.split("/")||[],o=c.protocol&&!x[c.protocol];if(o&&(c.hostname="",c.port=null,c.host&&(""===n[0]?n[0]=c.host:n.unshift(c.host)),c.host="",a.protocol&&(a.hostname=null,a.port=null,a.host&&(""===e[0]?e[0]=a.host:e.unshift(a.host)),a.host=null),l=l&&(""===e[0]||""===n[0])),i)c.host=a.host||""===a.host?a.host:c.host,c.hostname=a.hostname||""===a.hostname?a.hostname:c.hostname,c.search=a.search,c.query=a.query,n=e;else if(e.length)n||(n=[]),n.pop(),n=n.concat(e),c.search=a.search,c.query=a.query;else if(!j.isNullOrUndefined(a.search)){if(o){c.hostname=c.host=n.shift();var p=c.host&&c.host.indexOf("@")>0?c.host.split("@"):!1;p&&(c.auth=p.shift(),c.host=c.hostname=p.shift())}return c.search=a.search,c.query=a.query,j.isNull(c.pathname)&&j.isNull(c.search)||(c.path=(c.pathname?c.pathname:"")+(c.search?c.search:"")),c.href=c.format(),c}if(!n.length)return c.pathname=null,c.path=c.search?"/"+c.search:null,c.href=c.format(),c;for(var q=n.slice(-1)[0],r=(c.host||a.host)&&("."===q||".."===q)||""===q,s=0,t=n.length;t>=0;t--)q=n[t],"."==q?n.splice(t,1):".."===q?(n.splice(t,1),s++):s&&(n.splice(t,1),s--);if(!l&&!m)for(;s--;s)n.unshift("..");!l||""===n[0]||n[0]&&"/"===n[0].charAt(0)||n.unshift(""),r&&"/"!==k.substr(n.join("/"),-1)&&n.push("");var u=""===n[0]||n[0]&&"/"===n[0].charAt(0);if(o){c.hostname=c.host=u?"":n.length?n.shift():"";var p=c.host&&c.host.indexOf("@")>0?c.host.split("@"):!1;p&&(c.auth=p.shift(),c.host=c.hostname=p.shift())}return l=l||c.host&&n.length,l&&!u&&n.unshift(""),n.length?c.pathname=n.join("/"):(c.pathname=null,c.path=null),j.isNull(c.pathname)&&j.isNull(c.search)||(c.path=(c.pathname?c.pathname:"")+(c.search?c.search:"")),c.auth=a.auth||c.auth,c.slashes=c.slashes||a.slashes,c.href=c.format(),c},d.prototype.parseHost=function(){var a=this.host,b=m.exec(a);b&&(b=b[0],":"!==b&&(this.port=b.substr(1)),a=a.substr(0,a.length-b.length)),a&&(this.hostname=a)}},{_shims:2,querystring:6,util:8}],8:[function(a,b,c){function d(a,b){var d={seen:[],stylize:f};return arguments.length>=3&&(d.depth=arguments[2]),arguments.length>=4&&(d.colors=arguments[3]),o(b)?d.showHidden=b:b&&c._extend(d,b),u(d.showHidden)&&(d.showHidden=!1),u(d.depth)&&(d.depth=2),u(d.colors)&&(d.colors=!1),u(d.customInspect)&&(d.customInspect=!0),d.colors&&(d.stylize=e),h(d,a,d.depth)}function e(a,b){var c=d.styles[b];return c?"["+d.colors[c][0]+"m"+a+"["+d.colors[c][1]+"m":a}function f(a){return a}function g(a){var b={};return G.forEach(a,function(a){b[a]=!0}),b}function h(a,b,d){if(a.customInspect&&b&&z(b.inspect)&&b.inspect!==c.inspect&&(!b.constructor||b.constructor.prototype!==b)){var e=b.inspect(d);return s(e)||(e=h(a,e,d)),e}var f=i(a,b);if(f)return f;var o=G.keys(b),p=g(o);if(a.showHidden&&(o=G.getOwnPropertyNames(b)),0===o.length){if(z(b)){var q=b.name?": "+b.name:"";return a.stylize("[Function"+q+"]","special")}if(v(b))return a.stylize(RegExp.prototype.toString.call(b),"regexp");if(x(b))return a.stylize(Date.prototype.toString.call(b),"date");if(y(b))return j(b)}var r="",t=!1,u=["{","}"];if(n(b)&&(t=!0,u=["[","]"]),z(b)){var w=b.name?": "+b.name:"";r=" [Function"+w+"]"}if(v(b)&&(r=" "+RegExp.prototype.toString.call(b)),x(b)&&(r=" "+Date.prototype.toUTCString.call(b)),y(b)&&(r=" "+j(b)),0===o.length&&(!t||0==b.length))return u[0]+r+u[1];if(0>d)return v(b)?a.stylize(RegExp.prototype.toString.call(b),"regexp"):a.stylize("[Object]","special");a.seen.push(b);var A;return A=t?k(a,b,d,p,o):o.map(function(c){return l(a,b,d,p,c,t)}),a.seen.pop(),m(A,r,u)}function i(a,b){if(u(b))return a.stylize("undefined","undefined");if(s(b)){var c="'"+JSON.stringify(b).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return a.stylize(c,"string")}return r(b)?a.stylize(""+b,"number"):o(b)?a.stylize(""+b,"boolean"):p(b)?a.stylize("null","null"):void 0}function j(a){return"["+Error.prototype.toString.call(a)+"]"}function k(a,b,c,d,e){for(var f=[],g=0,h=b.length;h>g;++g)F(b,String(g))?f.push(l(a,b,c,d,String(g),!0)):f.push("");return G.forEach(e,function(e){e.match(/^\d+$/)||f.push(l(a,b,c,d,e,!0))}),f}function l(a,b,c,d,e,f){var g,i,j;if(j=G.getOwnPropertyDescriptor(b,e)||{value:b[e]},j.get?i=j.set?a.stylize("[Getter/Setter]","special"):a.stylize("[Getter]","special"):j.set&&(i=a.stylize("[Setter]","special")),F(d,e)||(g="["+e+"]"),i||(G.indexOf(a.seen,j.value)<0?(i=p(c)?h(a,j.value,null):h(a,j.value,c-1),i.indexOf("\n")>-1&&(i=f?i.split("\n").map(function(a){return" "+a}).join("\n").substr(2):"\n"+i.split("\n").map(function(a){return" "+a}).join("\n"))):i=a.stylize("[Circular]","special")),u(g)){if(f&&e.match(/^\d+$/))return i;g=JSON.stringify(""+e),g.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(g=g.substr(1,g.length-2),g=a.stylize(g,"name")):(g=g.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),g=a.stylize(g,"string"))}return g+": "+i}function m(a,b,c){var d=0,e=G.reduce(a,function(a,b){return d++,b.indexOf("\n")>=0&&d++,a+b.replace(/\u001b\[\d\d?m/g,"").length+1},0);return e>60?c[0]+(""===b?"":b+"\n ")+" "+a.join(",\n ")+" "+c[1]:c[0]+b+" "+a.join(", ")+" "+c[1]}function n(a){return G.isArray(a)}function o(a){return"boolean"==typeof a}function p(a){return null===a}function q(a){return null==a}function r(a){return"number"==typeof a}function s(a){return"string"==typeof a}function t(a){return"symbol"==typeof a}function u(a){return void 0===a}function v(a){return w(a)&&"[object RegExp]"===C(a)}function w(a){return"object"==typeof a&&a}function x(a){return w(a)&&"[object Date]"===C(a)}function y(a){return w(a)&&"[object Error]"===C(a)}function z(a){return"function"==typeof a}function A(a){return null===a||"boolean"==typeof a||"number"==typeof a||"string"==typeof a||"symbol"==typeof a||"undefined"==typeof a}function B(a){return a&&"object"==typeof a&&"function"==typeof a.copy&&"function"==typeof a.fill&&"function"==typeof a.binarySlice}function C(a){return Object.prototype.toString.call(a)}function D(a){return 10>a?"0"+a.toString(10):a.toString(10)}function E(){var a=new Date,b=[D(a.getHours()),D(a.getMinutes()),D(a.getSeconds())].join(":");return[a.getDate(),I[a.getMonth()],b].join(" ")}function F(a,b){return Object.prototype.hasOwnProperty.call(a,b)}var G=a("_shims"),H=/%[sdj%]/g;c.format=function(a){if(!s(a)){for(var b=[],c=0;c=f)return a;switch(a){case"%s":return String(e[c++]);case"%d":return Number(e[c++]);case"%j":try{return JSON.stringify(e[c++])}catch(b){return"[Circular]"}default:return a}}),h=e[c];f>c;h=e[++c])g+=p(h)||!w(h)?" "+h:" "+d(h);return g},c.inspect=d,d.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},d.styles={special:"cyan",number:"yellow","boolean":"yellow",undefined:"grey","null":"bold",string:"green",date:"magenta",regexp:"red"},c.isArray=n,c.isBoolean=o,c.isNull=p,c.isNullOrUndefined=q,c.isNumber=r,c.isString=s,c.isSymbol=t,c.isUndefined=u,c.isRegExp=v,c.isObject=w,c.isDate=x,c.isError=y,c.isFunction=z,c.isPrimitive=A,c.isBuffer=B;var I=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];c.log=function(){console.log("%s - %s",E(),c.format.apply(c,arguments))},c.inherits=function(a,b){a.super_=b,a.prototype=G.create(b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}})},c._extend=function(a,b){if(!b||!w(b))return a;for(var c=G.keys(b),d=c.length;d--;)a[c[d]]=b[c[d]];return a}},{_shims:2}],9:[function(a,b,c){c.readIEEE754=function(a,b,c,d,e){var f,g,h=8*e-d-1,i=(1<>1,k=-7,l=c?0:e-1,m=c?1:-1,n=a[b+l];for(l+=m,f=n&(1<<-k)-1,n>>=-k,k+=h;k>0;f=256*f+a[b+l],l+=m,k-=8);for(g=f&(1<<-k)-1,f>>=-k,k+=d;k>0;g=256*g+a[b+l],l+=m,k-=8);if(0===f)f=1-j;else{if(f===i)return g?0/0:1/0*(n?-1:1);g+=Math.pow(2,d),f-=j}return(n?-1:1)*g*Math.pow(2,f-d)},c.writeIEEE754=function(a,b,c,d,e,f){var g,h,i,j=8*f-e-1,k=(1<>1,m=23===e?Math.pow(2,-24)-Math.pow(2,-77):0,n=d?f-1:0,o=d?-1:1,p=0>b||0===b&&0>1/b?1:0;for(b=Math.abs(b),isNaN(b)||1/0===b?(h=isNaN(b)?1:0,g=k):(g=Math.floor(Math.log(b)/Math.LN2),b*(i=Math.pow(2,-g))<1&&(g--,i*=2),b+=g+l>=1?m/i:m*Math.pow(2,1-l),b*i>=2&&(g++,i/=2),g+l>=k?(h=0,g=k):g+l>=1?(h=(b*i-1)*Math.pow(2,e),g+=l):(h=b*Math.pow(2,l-1)*Math.pow(2,e),g=0));e>=8;a[c+n]=255&h,n+=o,h/=256,e-=8);for(g=g<0;a[c+n]=255&g,n+=o,g/=256,j-=8);a[c+n-o]|=128*p}},{}],10:[function(a,b,c){function d(a){return a.trim?a.trim():a.replace(/^\s+|\s+$/g,"")}function e(b,c,f){if(E||(E=a("assert")),!(this instanceof e))return new e(b,c,f);if(this.parent=this,this.offset=0,"base64"==c&&"string"==typeof b)for(b=d(b);0!=b.length%4;)b+="=";var h;if("number"==typeof f){this.length=g(c);for(var j=0;j=b?b:a>=0?a:(a+=b,a>=0?a:0))}function g(a){return a=~~Math.ceil(+a),0>a?0:a}function h(a){return(Array.isArray||function(a){return"[object Array]"=={}.toString.apply(a)})(a)}function i(a){return h(a)||e.isBuffer(a)||a&&"object"==typeof a&&"number"==typeof a.length}function j(a){return 16>a?"0"+a.toString(16):a.toString(16)}function k(a){for(var b=[],c=0;ce&&!(e+c>=b.length||e>=a.length);)b[e+c]=a[e],e++;return e}function o(a){try{return decodeURIComponent(a)}catch(b){return String.fromCharCode(65533)}}function p(a,b,c,d){var e=0;return d||(E.ok("boolean"==typeof c,"missing or invalid endian"),E.ok(void 0!==b&&null!==b,"missing offset"),E.ok(b+1=a.length?0:(c?(e=a[b]<<8,b+1=a.length?0:(c?(b+1>>0):(b+2>>0)),e)}function r(a,b,c,d){var e,f;return d||(E.ok("boolean"==typeof c,"missing or invalid endian"),E.ok(void 0!==b&&null!==b,"missing offset"),E.ok(b+1=0,"specified a negative value for writing an unsigned value"),E.ok(b>=a,"value is larger than maximum value for type"),E.ok(Math.floor(a)===a,"value has a fractional component")}function w(a,b,c,d,e){e||(E.ok(void 0!==b&&null!==b,"missing value"),E.ok("boolean"==typeof d,"missing or invalid endian"),E.ok(void 0!==c&&null!==c,"missing offset"),E.ok(c+1>>8*(d?1-f:f)}function x(a,b,c,d,e){e||(E.ok(void 0!==b&&null!==b,"missing value"),E.ok("boolean"==typeof d,"missing or invalid endian"),E.ok(void 0!==c&&null!==c,"missing offset"),E.ok(c+3>>8*(d?3-f:f)}function y(a,b,c){E.ok("number"==typeof a,"cannot write a non-number as a number"),E.ok(b>=a,"value larger than maximum allowed value"),E.ok(a>=c,"value smaller than minimum allowed value"),E.ok(Math.floor(a)===a,"value has a fractional component")}function z(a,b,c){E.ok("number"==typeof a,"cannot write a non-number as a number"),E.ok(b>=a,"value larger than maximum allowed value"),E.ok(a>=c,"value smaller than minimum allowed value")}function A(a,b,c,d,e){e||(E.ok(void 0!==b&&null!==b,"missing value"),E.ok("boolean"==typeof d,"missing or invalid endian"),E.ok(void 0!==c&&null!==c,"missing offset"),E.ok(c+1=0?w(a,b,c,d,e):w(a,65535+b+1,c,d,e)}function B(a,b,c,d,e){e||(E.ok(void 0!==b&&null!==b,"missing value"),E.ok("boolean"==typeof d,"missing or invalid endian"),E.ok(void 0!==c&&null!==c,"missing offset"),E.ok(c+3=0?x(a,b,c,d,e):x(a,4294967295+b+1,c,d,e) }function C(b,c,d,e,f){f||(E.ok(void 0!==c&&null!==c,"missing value"),E.ok("boolean"==typeof e,"missing or invalid endian"),E.ok(void 0!==d&&null!==d,"missing offset"),E.ok(d+3a||a>=this.length)throw new Error("oob");return this[a]},e.prototype.set=function(a,b){if(0>a||a>=this.length)throw new Error("oob");return this[a]=b},e.byteLength=function(a,b){switch(b||"utf8"){case"hex":return a.length/2;case"utf8":case"utf-8":return k(a).length;case"ascii":case"binary":return a.length;case"base64":return m(a).length;default:throw new Error("Unknown encoding")}},e.prototype.utf8Write=function(a,b,c){return e._charsWritten=n(k(a),this,b,c)},e.prototype.asciiWrite=function(a,b,c){return e._charsWritten=n(l(a),this,b,c)},e.prototype.binaryWrite=e.prototype.asciiWrite,e.prototype.base64Write=function(a,b,c){return e._charsWritten=n(m(a),this,b,c)},e.prototype.base64Slice=function(){var b=Array.prototype.slice.apply(this,arguments);return a("base64-js").fromByteArray(b)},e.prototype.utf8Slice=function(){for(var a=Array.prototype.slice.apply(this,arguments),b="",c="",d=0;dd;d++)if(a[d]=j(this[d]),d==c.INSPECT_MAX_BYTES){a[d+1]="...";break}return""},e.prototype.hexSlice=function(a,b){var c=this.length;(!a||0>a)&&(a=0),(!b||0>b||b>c)&&(b=c);for(var d="",e=a;b>e;e++)d+=j(this[e]);return d},e.prototype.toString=function(a,b,c){if(a=String(a||"utf8").toLowerCase(),b=+b||0,"undefined"==typeof c&&(c=this.length),+c==b)return"";switch(a){case"hex":return this.hexSlice(b,c);case"utf8":case"utf-8":return this.utf8Slice(b,c);case"ascii":return this.asciiSlice(b,c);case"binary":return this.binarySlice(b,c);case"base64":return this.base64Slice(b,c);case"ucs2":case"ucs-2":return this.ucs2Slice(b,c);default:throw new Error("Unknown encoding")}},e.prototype.hexWrite=function(a,b,c){b=+b||0;var d=this.length-b;c?(c=+c,c>d&&(c=d)):c=d;var f=a.length;if(f%2)throw new Error("Invalid hex string");c>f/2&&(c=f/2);for(var g=0;c>g;g++){var h=parseInt(a.substr(2*g,2),16);if(isNaN(h))throw new Error("Invalid hex string");this[b+g]=h}return e._charsWritten=2*g,g},e.prototype.write=function(a,b,c,d){if(isFinite(b))isFinite(c)||(d=c,c=void 0);else{var e=d;d=b,b=c,c=e}b=+b||0;var f=this.length-b;switch(c?(c=+c,c>f&&(c=f)):c=f,d=String(d||"utf8").toLowerCase()){case"hex":return this.hexWrite(a,b,c);case"utf8":case"utf-8":return this.utf8Write(a,b,c);case"ascii":return this.asciiWrite(a,b,c);case"binary":return this.binaryWrite(a,b,c);case"base64":return this.base64Write(a,b,c);case"ucs2":case"ucs-2":return this.ucs2Write(a,b,c);default:throw new Error("Unknown encoding")}},e.prototype.slice=function(a,b){var c=this.length;return a=f(a,c,0),b=f(b,c,c),new e(this,b-a,+a)},e.prototype.copy=function(a,b,c,d){var e=this;if(c||(c=0),(void 0===d||isNaN(d))&&(d=this.length),b||(b=0),c>d)throw new Error("sourceEnd < sourceStart");if(d===c)return 0;if(0==a.length||0==e.length)return 0;if(0>b||b>=a.length)throw new Error("targetStart out of bounds");if(0>c||c>=e.length)throw new Error("sourceStart out of bounds");if(0>d||d>e.length)throw new Error("sourceEnd out of bounds");d>this.length&&(d=this.length),a.length-bg;g++)E.ok("undefined"!=typeof this[g],"copying undefined buffer bytes!"),f.push(this[g]);for(var g=b;gc)throw new Error("end < start");if(c===b)return 0;if(0==this.length)return 0;if(0>b||b>=this.length)throw new Error("start out of bounds");if(0>c||c>this.length)throw new Error("end out of bounds");for(var d=b;c>d;d++)this[d]=a},e.isBuffer=function(a){return a instanceof e||a instanceof e},e.concat=function(a,b){if(!h(a))throw new Error("Usage: Buffer.concat(list, [totalLength])\n list should be an Array.");if(0===a.length)return new e(0);if(1===a.length)return a[0];if("number"!=typeof b){b=0;for(var c=0;c=c.length?void 0:c[a]},e.prototype.readUInt16LE=function(a,b){return p(this,a,!1,b)},e.prototype.readUInt16BE=function(a,b){return p(this,a,!0,b)},e.prototype.readUInt32LE=function(a,b){return q(this,a,!1,b)},e.prototype.readUInt32BE=function(a,b){return q(this,a,!0,b)},e.prototype.readInt8=function(a,b){var c,d=this;return b||(E.ok(void 0!==a&&null!==a,"missing offset"),E.ok(a=d.length?void 0:(c=128&d[a],c?-1*(255-d[a]+1):d[a])},e.prototype.readInt16LE=function(a,b){return r(this,a,!1,b)},e.prototype.readInt16BE=function(a,b){return r(this,a,!0,b)},e.prototype.readInt32LE=function(a,b){return s(this,a,!1,b)},e.prototype.readInt32BE=function(a,b){return s(this,a,!0,b)},e.prototype.readFloatLE=function(a,b){return t(this,a,!1,b)},e.prototype.readFloatBE=function(a,b){return t(this,a,!0,b)},e.prototype.readDoubleLE=function(a,b){return u(this,a,!1,b)},e.prototype.readDoubleBE=function(a,b){return u(this,a,!0,b)},e.prototype.writeUInt8=function(a,b,c){var d=this;c||(E.ok(void 0!==a&&null!==a,"missing value"),E.ok(void 0!==b&&null!==b,"missing offset"),E.ok(b=0?d.writeUInt8(a,b,c):d.writeUInt8(255+a+1,b,c)},e.prototype.writeInt16LE=function(a,b,c){A(this,a,b,!1,c)},e.prototype.writeInt16BE=function(a,b,c){A(this,a,b,!0,c)},e.prototype.writeInt32LE=function(a,b,c){B(this,a,b,!1,c)},e.prototype.writeInt32BE=function(a,b,c){B(this,a,b,!0,c)},e.prototype.writeFloatLE=function(a,b,c){C(this,a,b,!1,c)},e.prototype.writeFloatBE=function(a,b,c){C(this,a,b,!0,c)},e.prototype.writeDoubleLE=function(a,b,c){D(this,a,b,!1,c)},e.prototype.writeDoubleBE=function(a,b,c){D(this,a,b,!0,c)}},{"./buffer_ieee754":9,assert:3,"base64-js":11}],11:[function(a,b){!function(){"use strict";function a(a){var b,c,e,f,g,h;if(a.length%4>0)throw"Invalid string. Length must be a multiple of 4";for(g=a.indexOf("="),g=g>0?a.length-g:0,h=[],e=g>0?a.length-4:a.length,b=0,c=0;e>b;b+=4,c+=3)f=d.indexOf(a[b])<<18|d.indexOf(a[b+1])<<12|d.indexOf(a[b+2])<<6|d.indexOf(a[b+3]),h.push((16711680&f)>>16),h.push((65280&f)>>8),h.push(255&f);return 2===g?(f=d.indexOf(a[b])<<2|d.indexOf(a[b+1])>>4,h.push(255&f)):1===g&&(f=d.indexOf(a[b])<<10|d.indexOf(a[b+1])<<4|d.indexOf(a[b+2])>>2,h.push(255&f>>8),h.push(255&f)),h}function c(a){function b(a){return d[63&a>>18]+d[63&a>>12]+d[63&a>>6]+d[63&a]}var c,e,f,g=a.length%3,h="";for(c=0,f=a.length-g;f>c;c+=3)e=(a[c]<<16)+(a[c+1]<<8)+a[c+2],h+=b(e);switch(g){case 1:e=a[a.length-1],h+=d[e>>2],h+=d[63&e<<4],h+="==";break;case 2:e=(a[a.length-2]<<8)+a[a.length-1],h+=d[e>>10],h+=d[63&e>>4],h+=d[63&e<<2],h+="="}return h}var d="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";b.exports.toByteArray=a,b.exports.fromByteArray=c}()},{}],12:[function(a,b){var c=b.exports={};c.nextTick=function(){var a="undefined"!=typeof window&&window.setImmediate,b="undefined"!=typeof window&&window.postMessage&&window.addEventListener;if(a)return function(a){return window.setImmediate(a)};if(b){var c=[];return window.addEventListener("message",function(a){if(a.source===window&&"process-tick"===a.data&&(a.stopPropagation(),c.length>0)){var b=c.shift();b()}},!0),function(a){c.push(a),window.postMessage("process-tick","*")}}return function(a){setTimeout(a,0)}}(),c.title="browser",c.browser=!0,c.env={},c.argv=[],c.binding=function(){throw new Error("process.binding is not supported")},c.cwd=function(){return"/"},c.chdir=function(){throw new Error("process.chdir is not supported")}},{}],13:[function(b,c,d){var e="undefined"!=typeof self?self:"undefined"!=typeof window?window:{};(function(){function b(a,b,c){for(var d=(c||0)-1,e=a?a.length:0;++d-1?0:-1:a?0:-1}function g(a){var b=this.cache,c=typeof a;if("boolean"==c||null==a)b[a]=!0;else{"number"!=c&&"string"!=c&&(c="object");var d="number"==c?a:w+a,e=b[c]||(b[c]={});"object"==c?(e[d]||(e[d]=[])).push(a):e[d]=!0}}function h(a){return a.charCodeAt(0)}function i(a,b){var c=a.criteria,d=b.criteria;if(c!==d){if(c>d||"undefined"==typeof c)return 1;if(d>c||"undefined"==typeof d)return-1}return a.index-b.index}function j(a){var b=-1,c=a.length,d=a[0],e=a[0|c/2],f=a[c-1];if(d&&"object"==typeof d&&e&&"object"==typeof e&&f&&"object"==typeof f)return!1;var h=m();h["false"]=h["null"]=h["true"]=h.undefined=!1;var i=m();for(i.array=a,i.cache=h,i.push=g;++be?0:e);++d-1:void 0}),q&&(o(e),o(f)),g}function y(a,b,c,d,e){(Xd(b)?Tb:fe)(b,function(b,f){var g,h,i=b,j=a[f];if(b&&((h=Xd(b))||ge(b))){for(var k=d.length;k--;)if(g=d[k]==b){j=e[k];break}if(!g){var l;c&&(i=c(j,b),(l="undefined"!=typeof i)&&(j=i)),l||(j=h?Xd(j)?j:[]:ge(j)?j:{}),d.push(b),e.push(j),l||y(j,b,c,d,e)}}else c&&(i=c(j,b),"undefined"==typeof i&&(i=b)),"undefined"!=typeof i&&(j=i);a[f]=j})}function $(a,c,d){var e=-1,g=gb(),h=a?a.length:0,i=[],k=!c&&h>=x&&g===b,m=d||k?l():i;if(k){var n=j(m);n?(g=f,m=n):(k=!1,m=d?m:(o(m),i))}for(;++e3&&"function"==typeof b[c-2])var d=g(b[--c-1],b[c--],2);else c>2&&"function"==typeof b[c-1]&&(d=b[--c]);for(var e=Rd.call(arguments,1,c),f=-1,h=l(),i=l();++fc?Nd(0,f+c):c)||0,Xd(a)?g=e(a,b,c)>-1:"number"==typeof f?g=(Fb(a)?a.indexOf(b,c):e(a,b,c))>-1:fe(a,function(a){return++d>=c?!(g=a===b):void 0}),g}function Pb(a,b,d){var e=!0;b=c.createCallback(b,d,3);var f=-1,g=a?a.length:0;if("number"==typeof g)for(;++ff&&(f=j)}else b=!b&&Fb(a)?h:c.createCallback(b,d,3),Tb(a,function(a,c,d){var g=b(a,c,d);g>e&&(e=g,f=a)});return f}function Yb(a,b,d){var e=1/0,f=e;if(!b&&Xd(a))for(var g=-1,i=a.length;++gj&&(f=j)}else b=!b&&Fb(a)?h:c.createCallback(b,d,3),Tb(a,function(a,c,d){var g=b(a,c,d);e>g&&(e=g,f=a)});return f}function Zb(a,b){var c=-1,d=a?a.length:0;if("number"==typeof d)for(var e=fd(d);++c=x&&d===b;if(i){var k=j(g);k?(d=f,g=k):i=!1}for(;++cd?Nd(0,e+d):d||0}else if(d){var f=wc(a,c);return a[f]===c?f:-1}return b(a,c,d)}function oc(a,b,d){var e=0,f=a?a.length:0;if("number"!=typeof b&&null!=b){var g=f;for(b=c.createCallback(b,d,3);g--&&b(a[g],g,a);)e++}else e=null==b||d?1:b||e;return q(a,0,Od(Nd(0,f-e),f))}function pc(a){for(var c=arguments,d=c.length,e=-1,g=l(),h=-1,i=gb(),k=a?a.length:0,m=[],n=l();++e=x&&j(e?c[e]:n)}a:for(;++hc?Nd(0,d+c):Od(c,d-1))+1);d--;)if(a[d]===b)return d;return-1}function sc(a){for(var b=arguments,c=0,d=b.length,e=a?a.length:0;++cf;){var h=f+g>>>1;d(a[h])1?arguments:arguments[0],b=-1,c=a?Xb(Zb(a,"length")):0,d=fd(0>c?0:c);++b2?bb(a,17,Rd.call(arguments,2),null,b):bb(a,1,null,null,b)}function Ec(a){for(var b=arguments.length>1?t(arguments,!0,!1,1):qb(a),c=-1,d=b.length;++c2?bb(b,19,Rd.call(arguments,2),null,a):bb(b,3,null,null,a)}function Gc(){for(var a=arguments,b=a.length;b--;)if(!zb(a[b]))throw new od;return function(){for(var b=arguments,c=a.length;c--;)b=[a[c].apply(this,b)];return b[0]}}function Hc(a,b,c){var d=typeof a;if(null==a||"function"==d)return g(a,b,c);if("object"!=d)return function(b){return b[a]};var e=Zd(a),f=e[0],h=a[f];return 1!=e.length||h!==h||Ab(h)?function(b){for(var c=e.length,d=!1;c--&&(d=u(b[e[c]],a[e[c]],null,!0)););return d}:function(a){var b=a[f];return h===b&&(0!==h||1/h==1/b)}}function Ic(a,b){return b="number"==typeof b?b:+b||a.length,bb(a,4,null,null,null,b)}function Jc(a,b,c){var d,e,f,g,h,i,j,k=0,l=!1,m=!0;if(!zb(a))throw new od;if(b=Nd(0,b)||0,c===!0){var n=!0;m=!1}else Ab(c)&&(n=c.leading,l="maxWait"in c&&(Nd(b,c.maxWait)||0),m="trailing"in c?c.trailing:m);var o=function(){var c=b-(zd()-g);if(0>=c){e&&ud(e);var l=j;e=i=j=s,l&&(k=zd(),f=a.apply(h,d))}else i=Cd(o,c)},p=function(){i&&ud(i),e=i=j=s,(m||l!==b)&&(k=zd(),f=a.apply(h,d))};return function(){if(d=arguments,g=zd(),h=this,j=m&&(i||!n),l===!1)var c=n&&!i;else{e||n||(k=g);var q=l-(g-k);0>=q?(e&&(e=ud(e)),k=g,f=a.apply(h,d)):e||(e=Cd(p,q))}return i||b===l||(i=Cd(o,b)),c&&(f=a.apply(h,d)),f}}function Kc(a){if(!zb(a))throw new od;var b=Rd.call(arguments,1);return Cd(function(){a.apply(s,b)},1)}function Lc(a,b){if(!zb(a))throw new od;var c=Rd.call(arguments,2);return Cd(function(){a.apply(s,c)},b)}function Mc(a,b){if(!zb(a))throw new od;var c=function(){var d=c.cache,e=b?b.apply(this,arguments):w+arguments[0];return yd.call(d,e)?d[e]:d[e]=a.apply(this,arguments)};return c.cache={},c}function Nc(a){var b,c;if(!zb(a))throw new od;return function(){return b?c:(b=!0,c=a.apply(this,arguments),a=null,c)}}function Oc(a){return bb(a,16,Rd.call(arguments,1))}function Pc(a){return bb(a,32,null,Rd.call(arguments,1))}function Qc(a,b,c){var d=!0,e=!0;if(!zb(a))throw new od;c===!1?d=!1:Ab(c)&&(d="leading"in c?c.leading:d,e="trailing"in c?c.trailing:e),X.leading=d,X.maxWait=b,X.trailing=e;var f=Jc(a,b,X);return f}function Rc(a,b){if(!zb(b))throw new od;return function(){var c=[a];return Ad.apply(c,arguments),b.apply(this,c)}}function Sc(a){return null==a?"":nd(a).replace(be,fb)}function Tc(a){return a}function Uc(a,b){var e=a,f=!b||zb(e);b||(e=d,b=a,a=c),Tb(qb(b),function(c){var d=a[c]=b[c];f&&(e.prototype[c]=function(){var b=this.__wrapped__,c=[b];Ad.apply(c,arguments);var f=d.apply(a,c);return b&&"object"==typeof b&&b===f?this:(f=new e(f),f.__chain__=this.__chain__,f)})})}function Vc(){return a._=rd,this}function Wc(a,b,c){var d=null==a,e=null==b;null==c&&("boolean"==typeof a&&e?(c=a,a=1):e||"boolean"!=typeof b||(c=b,e=!0)),d&&e&&(b=1),a=+a||0,e?(b=a,a=0):b=+b||0;var f=Qd();return c||a%1||b%1?Od(a+f*(b-a+parseFloat("1e-"+((f+"").length-1))),b):a+vd(f*(b-a+1))}function Xc(a,b){if(a){var c=a[b];return zb(c)?a[b]():c}}function Yc(a,b,d){var e=c.templateSettings;a||(a=""),d=de({},d,e);var f,g=de({},d.imports,e.imports),h=Zd(g),i=Mb(g),j=0,l=d.interpolate||I,m="__p += '",n=md((d.escape||I).source+"|"+l.source+"|"+(l===G?D:I).source+"|"+(d.evaluate||I).source+"|$","g");a.replace(n,function(b,c,d,e,g,h){return d||(d=e),m+=a.slice(j,h).replace(K,k),c&&(m+="' +\n__e("+c+") +\n'"),g&&(f=!0,m+="';\n"+g+";\n__p += '"),d&&(m+="' +\n((__t = ("+d+")) == null ? '' : __t) +\n'"),j=h+b.length,b}),m+="';\n";var o=d.variable,p=o;p||(o="obj",m="with ("+o+") {\n"+m+"\n}\n"),m=(f?m.replace(A,""):m).replace(B,"$1").replace(C,"$1;"),m="function("+o+") {\n"+(p?"":o+" || ("+o+" = {});\n")+"var __t, __p = '', __e = _.escape"+(f?", __j = Array.prototype.join;\nfunction print() { __p += __j.call(arguments, '') }\n":";\n")+m+"return __p\n}";var q="\n/*\n//# sourceURL="+(d.sourceURL||"/lodash/template/source["+M++ +"]")+"\n*/";try{var r=id(h,"return "+m+q).apply(s,i)}catch(t){throw t.source=m,t}return b?r(b):(r.source=m,r)}function Zc(a,b,c){a=(a=+a)>-1?a:0;var d=-1,e=fd(a);for(b=g(b,c,1);++d/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:G,variable:"",imports:{_:c}},Id||(db=function(a){if(Ab(a)){n.prototype=a;var b=new n;n.prototype=null}return b||{}});var Wd=Gd?function(a,b){Y.value=b,Gd(a,"__bindData__",Y)}:n,Xd=Jd||function(a){return a&&"object"==typeof a&&"number"==typeof a.length&&Ed.call(a)==O||!1},Yd=function(a){var b,c=a,d=[];if(!c)return d;if(!Z[typeof a])return d;for(b in c)yd.call(c,b)&&d.push(b);return d},Zd=Md?function(a){return Ab(a)?Md(a):[]}:Yd,$d={"&":"&","<":"<",">":">",'"':""","'":"'"},_d=sb($d),ae=md("("+Zd(_d).join("|")+")","g"),be=md("["+Zd($d).join("")+"]","g"),ce=function(a,b,c){var d,e=a,f=e;if(!e)return f;var h=arguments,i=0,j="number"==typeof c?2:h.length;if(j>3&&"function"==typeof h[j-2])var k=g(h[--j-1],h[j--],2);else j>2&&"function"==typeof h[j-1]&&(k=h[--j]);for(;++i/g,H=RegExp("^["+z+"]*0+(?=.$)"),I=/($^)/,J=/\bthis\b/,K=/['\n\r\t\u2028\u2029\\]/g,L=["Array","Boolean","Date","Function","Math","Number","Object","RegExp","String","_","attachEvent","clearTimeout","isFinite","isNaN","parseInt","setImmediate","setTimeout"],M=0,N="[object Arguments]",O="[object Array]",P="[object Boolean]",Q="[object Date]",R="[object Function]",S="[object Number]",T="[object Object]",U="[object RegExp]",V="[object String]",W={};W[R]=!1,W[N]=W[O]=W[P]=W[Q]=W[S]=W[T]=W[U]=W[V]=!0;var X={leading:!1,maxWait:0,trailing:!1},Y={configurable:!1,enumerable:!1,value:null,writable:!1},Z={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,undefined:!1},$={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"},_=Z[typeof window]&&window||this,ab=Z[typeof d]&&d&&!d.nodeType&&d,bb=Z[typeof c]&&c&&!c.nodeType&&c,cb=bb&&bb.exports===ab&&ab,db=Z[typeof e]&&e;!db||db.global!==db&&db.window!==db||(_=db);var eb=r();"function"==typeof a&&"object"==typeof a.amd&&a.amd?(_._=eb,a(function(){return eb})):ab&&bb?cb?(bb.exports=eb)._=eb:ab._=eb:_._=eb}).call(this)},{}],14:[function(a,b){var c={Client:a("./lib/client")};b.exports=c},{"./lib/client":16}],15:[function(a,b){var c=a("./client_action");a("./errors");var d=b.exports={};d._namespaces=["cluster","indices"],d.bulk=c({methods:["POST","PUT"],params:{consistency:{type:"enum",options:["one","quorum","all"]},refresh:{type:"boolean"},replication:{type:"enum","default":"sync",options:["sync","async"]},type:{type:"string"}},urls:[{fmt:"/<%=index%>/<%=type%>/_bulk",req:{index:{type:"string"},type:{type:"string"}}},{fmt:"/<%=index%>/_bulk",req:{index:{type:"string"}}},{fmt:"/_bulk"}],bulkBody:!0}),d.clearScroll=c({methods:["DELETE"],params:{},urls:[{fmt:"/_search/scroll/<%=scrollId%>",req:{scrollId:{type:"list"}}}]}),d.cluster=function e(a){return this instanceof e?(this.client=a,void 0):new e(a)},d.cluster.prototype.getSettings=c({methods:["GET"],params:{},urls:[{fmt:"/_cluster/settings"}]}),d.cluster.prototype.health=c({methods:["GET"],params:{level:{type:"enum","default":"cluster",options:["cluster","indices","shards"]},local:{type:"boolean"},masterTimeout:{type:"time",name:"master_timeout"},timeout:{type:"time"},waitForActiveShards:{type:"number",name:"wait_for_active_shards"},waitForNodes:{type:"string",name:"wait_for_nodes"},waitForRelocatingShards:{type:"number",name:"wait_for_relocating_shards"},waitForStatus:{type:"enum","default":null,options:["green","yellow","red"],name:"wait_for_status"}},urls:[{fmt:"/_cluster/health/<%=index%>",req:{index:{type:"string"}}},{fmt:"/_cluster/health"}]}),d.cluster.prototype.nodeHotThreads=c({methods:["GET"],params:{interval:{type:"time"},snapshots:{type:"number"},threads:{type:"number"},type:{type:"enum",options:["cpu","wait","block"]}},urls:[{fmt:"/_nodes/<%=nodeId%>/hotthreads",req:{nodeId:{type:"list"}}},{fmt:"/_nodes/hotthreads"}]}),d.cluster.prototype.nodeInfo=c({methods:["GET"],params:{all:{type:"boolean"},clear:{type:"boolean"},http:{type:"boolean"},jvm:{type:"boolean"},network:{type:"boolean"},os:{type:"boolean"},plugin:{type:"boolean"},process:{type:"boolean"},settings:{type:"boolean"},threadPool:{type:"boolean",name:"thread_pool"},timeout:{type:"time"},transport:{type:"boolean"}},urls:[{fmt:"/_nodes/<%=nodeId%>",req:{nodeId:{type:"list"}}},{fmt:"/_nodes"}]}),d.cluster.prototype.nodeShutdown=c({methods:["POST"],params:{delay:{type:"time"},exit:{type:"boolean"}},urls:[{fmt:"/_cluster/nodes/<%=nodeId%>/_shutdown",req:{nodeId:{type:"list"}}},{fmt:"/_shutdown"}]}),d.cluster.prototype.nodeStats=c({methods:["GET"],params:{all:{type:"boolean"},clear:{type:"boolean"},fields:{type:"list"},fs:{type:"boolean"},http:{type:"boolean"},indices:{type:"boolean"},jvm:{type:"boolean"},network:{type:"boolean"},os:{type:"boolean"},process:{type:"boolean"},threadPool:{type:"boolean",name:"thread_pool"},transport:{type:"boolean"}},urls:[{fmt:"/_nodes/<%=nodeId%>/stats",req:{nodeId:{type:"list"}}},{fmt:"/_nodes/stats"}]}),d.cluster.prototype.putSettings=c({methods:["PUT"],params:{},urls:[{fmt:"/_cluster/settings"}]}),d.cluster.prototype.reroute=c({methods:["POST"],params:{dryRun:{type:"boolean",name:"dry_run"},filterMetadata:{type:"boolean",name:"filter_metadata"}},urls:[{fmt:"/_cluster/reroute"}]}),d.cluster.prototype.state=c({methods:["GET"],params:{filterBlocks:{type:"boolean",name:"filter_blocks"},filterIndexTemplates:{type:"boolean",name:"filter_index_templates"},filterIndices:{type:"list",name:"filter_indices"},filterMetadata:{type:"boolean",name:"filter_metadata"},filterNodes:{type:"boolean",name:"filter_nodes"},filterRoutingTable:{type:"boolean",name:"filter_routing_table"},local:{type:"boolean"},masterTimeout:{type:"time",name:"master_timeout"}},urls:[{fmt:"/_cluster/state"}]}),d.count=c({methods:["POST","GET"],params:{ignoreIndices:{type:"enum","default":"none",options:["none","missing"],name:"ignore_indices"},minScore:{type:"number",name:"min_score"},preference:{type:"string"},routing:{type:"string"},source:{type:"string"}},urls:[{fmt:"/<%=index%>/<%=type%>/_count",req:{index:{type:"list"},type:{type:"list"}}},{fmt:"/<%=index%>/_count",req:{index:{type:"list"}}},{fmt:"/_count"}]}),d.create=c({methods:["POST","PUT"],params:{consistency:{type:"enum",options:["one","quorum","all"]},id:{type:"string"},parent:{type:"string"},percolate:{type:"string"},refresh:{type:"boolean"},replication:{type:"enum","default":"sync",options:["sync","async"]},routing:{type:"string"},timeout:{type:"time"},timestamp:{type:"time"},ttl:{type:"duration"},version:{type:"number"},versionType:{type:"enum",options:["internal","external"],name:"version_type"}},urls:[{fmt:"/<%=index%>/<%=type%>/<%=id%>/_create",req:{index:{type:"string"},type:{type:"string"},id:{type:"string"}}},{fmt:"/<%=index%>/<%=type%>",req:{index:{type:"string"},type:{type:"string"}}}]}),d["delete"]=c({methods:["DELETE"],params:{consistency:{type:"enum",options:["one","quorum","all"]},parent:{type:"string"},refresh:{type:"boolean"},replication:{type:"enum","default":"sync",options:["sync","async"]},routing:{type:"string"},timeout:{type:"time"},version:{type:"number"},versionType:{type:"enum",options:["internal","external"],name:"version_type"}},urls:[{fmt:"/<%=index%>/<%=type%>/<%=id%>",req:{index:{type:"string"},type:{type:"string"},id:{type:"string"}}}]}),d.deleteByQuery=c({methods:["DELETE"],params:{analyzer:{type:"string"},consistency:{type:"enum",options:["one","quorum","all"]},defaultOperator:{type:"enum","default":"OR",options:["AND","OR"],name:"default_operator"},df:{type:"string"},ignoreIndices:{type:"enum","default":"none",options:["none","missing"],name:"ignore_indices"},replication:{type:"enum","default":"sync",options:["sync","async"]},q:{type:"string"},routing:{type:"string"},source:{type:"string"},timeout:{type:"time"}},urls:[{fmt:"/<%=index%>/<%=type%>/_query",req:{index:{type:"list"},type:{type:"list"}}},{fmt:"/<%=index%>/_query",req:{index:{type:"list"}}}]}),d.exists=c({methods:["HEAD"],params:{parent:{type:"string"},preference:{type:"string"},realtime:{type:"boolean"},refresh:{type:"boolean"},routing:{type:"string"}},urls:[{fmt:"/<%=index%>/<%=type%>/<%=id%>",opt:{type:{type:"string","default":"_all"}},req:{index:{type:"string"},id:{type:"string"}}}],castExists:!0}),d.explain=c({methods:["GET","POST"],params:{analyzeWildcard:{type:"boolean",name:"analyze_wildcard"},analyzer:{type:"string"},defaultOperator:{type:"enum","default":"OR",options:["AND","OR"],name:"default_operator"},df:{type:"string"},fields:{type:"list"},lenient:{type:"boolean"},lowercaseExpandedTerms:{type:"boolean",name:"lowercase_expanded_terms"},parent:{type:"string"},preference:{type:"string"},q:{type:"string"},routing:{type:"string"},source:{type:"string"},_source:{type:"list",name:"_source"},_sourceExclude:{type:"list",name:"_source_exclude"},_sourceInclude:{type:"list",name:"_source_include"}},urls:[{fmt:"/<%=index%>/<%=type%>/<%=id%>/_explain",req:{index:{type:"string"},type:{type:"string"},id:{type:"string"}}}]}),d.get=c({methods:["GET"],params:{fields:{type:"list"},parent:{type:"string"},preference:{type:"string"},realtime:{type:"boolean"},refresh:{type:"boolean"},routing:{type:"string"},_source:{type:"list",name:"_source"},_sourceExclude:{type:"list",name:"_source_exclude"},_sourceInclude:{type:"list",name:"_source_include"}},urls:[{fmt:"/<%=index%>/<%=type%>/<%=id%>",opt:{type:{type:"string","default":"_all"}},req:{index:{type:"string"},id:{type:"string"}}}]}),d.getSource=c({methods:["GET"],params:{exclude:{type:"list"},include:{type:"list"},parent:{type:"string"},preference:{type:"string"},realtime:{type:"boolean"},refresh:{type:"boolean"},routing:{type:"string"}},urls:[{fmt:"/<%=index%>/<%=type%>/<%=id%>/_source",opt:{type:{type:"string","default":"_all"}},req:{index:{type:"string"},id:{type:"string"}}}]}),d.index=c({methods:["POST","PUT"],params:{consistency:{type:"enum",options:["one","quorum","all"]},opType:{type:"enum","default":"index",options:["index","create"],name:"op_type"},parent:{type:"string"},percolate:{type:"string"},refresh:{type:"boolean"},replication:{type:"enum","default":"sync",options:["sync","async"]},routing:{type:"string"},timeout:{type:"time"},timestamp:{type:"time"},ttl:{type:"duration"},version:{type:"number"},versionType:{type:"enum",options:["internal","external"],name:"version_type"}},urls:[{fmt:"/<%=index%>/<%=type%>/<%=id%>",req:{index:{type:"string"},type:{type:"string"},id:{type:"string"}}},{fmt:"/<%=index%>/<%=type%>",req:{index:{type:"string"},type:{type:"string"}}}]}),d.indices=function f(a){return this instanceof f?(this.client=a,void 0):new f(a)},d.indices.prototype.analyze=c({methods:["GET","POST"],params:{analyzer:{type:"string"},field:{type:"string"},filters:{type:"list"},index:{type:"string"},preferLocal:{type:"boolean",name:"prefer_local"},text:{type:"string"},tokenizer:{type:"string"},format:{type:"enum","default":"detailed",options:["detailed","text"]}},urls:[{fmt:"/<%=index%>/_analyze",req:{index:{type:"string"}}},{fmt:"/_analyze"}]}),d.indices.prototype.clearCache=c({methods:["POST","GET"],params:{fieldData:{type:"boolean",name:"field_data"},fielddata:{type:"boolean"},fields:{type:"list"},filter:{type:"boolean"},filterCache:{type:"boolean",name:"filter_cache"},filterKeys:{type:"boolean",name:"filter_keys"},id:{type:"boolean"},idCache:{type:"boolean",name:"id_cache"},ignoreIndices:{type:"enum","default":"none",options:["none","missing"],name:"ignore_indices"},index:{type:"list"},recycler:{type:"boolean"}},urls:[{fmt:"/<%=index%>/_cache/clear",req:{index:{type:"list"}}},{fmt:"/_cache/clear"}]}),d.indices.prototype.close=c({methods:["POST"],params:{timeout:{type:"time"},masterTimeout:{type:"time",name:"master_timeout"}},urls:[{fmt:"/<%=index%>/_close",req:{index:{type:"string"}}}]}),d.indices.prototype.create=c({methods:["PUT","POST"],params:{timeout:{type:"time"},masterTimeout:{type:"time",name:"master_timeout"}},urls:[{fmt:"/<%=index%>",req:{index:{type:"string"}}}]}),d.indices.prototype["delete"]=c({methods:["DELETE"],params:{timeout:{type:"time"},masterTimeout:{type:"time",name:"master_timeout"}},urls:[{fmt:"/<%=index%>",req:{index:{type:"list"}}},{fmt:"/"}]}),d.indices.prototype.deleteAlias=c({methods:["DELETE"],params:{timeout:{type:"time"},masterTimeout:{type:"time",name:"master_timeout"}},urls:[{fmt:"/<%=index%>/_alias/<%=name%>",req:{index:{type:"string"},name:{type:"string"}}}]}),d.indices.prototype.deleteMapping=c({methods:["DELETE"],params:{masterTimeout:{type:"time",name:"master_timeout"}},urls:[{fmt:"/<%=index%>/<%=type%>",req:{index:{type:"list"},type:{type:"string"}}}]}),d.indices.prototype.deleteTemplate=c({methods:["DELETE"],params:{timeout:{type:"time"},masterTimeout:{type:"time",name:"master_timeout"}},urls:[{fmt:"/_template/<%=name%>",req:{name:{type:"string"}}}]}),d.indices.prototype.deleteWarmer=c({methods:["DELETE"],params:{masterTimeout:{type:"time",name:"master_timeout"}},urls:[{fmt:"/<%=index%>/<%=type%>/_warmer/<%=name%>",req:{index:{type:"list"},type:{type:"list"},name:{type:"string"}}},{fmt:"/<%=index%>/_warmer/<%=name%>",req:{index:{type:"list"},name:{type:"string"}}},{fmt:"/<%=index%>/_warmer",req:{index:{type:"list"}}}]}),d.indices.prototype.exists=c({methods:["HEAD"],params:{},urls:[{fmt:"/<%=index%>",req:{index:{type:"list"}}}],castExists:!0}),d.indices.prototype.existsAlias=c({methods:["HEAD"],params:{ignoreIndices:{type:"enum","default":"none",options:["none","missing"],name:"ignore_indices"}},urls:[{fmt:"/<%=index%>/_alias/<%=name%>",req:{index:{type:"list"},name:{type:"list"}}},{fmt:"/_alias/<%=name%>",req:{name:{type:"list"}}}],castExists:!0}),d.indices.prototype.existsType=c({methods:["HEAD"],params:{ignoreIndices:{type:"enum","default":"none",options:["none","missing"],name:"ignore_indices"}},urls:[{fmt:"/<%=index%>/<%=type%>",req:{index:{type:"list"},type:{type:"list"}}}],castExists:!0}),d.indices.prototype.flush=c({methods:["POST","GET"],params:{force:{type:"boolean"},full:{type:"boolean"},ignoreIndices:{type:"enum","default":"none",options:["none","missing"],name:"ignore_indices"},refresh:{type:"boolean"}},urls:[{fmt:"/<%=index%>/_flush",req:{index:{type:"list"}}},{fmt:"/_flush"}]}),d.indices.prototype.getAlias=c({methods:["GET"],params:{ignoreIndices:{type:"enum","default":"none",options:["none","missing"],name:"ignore_indices"}},urls:[{fmt:"/<%=index%>/_alias/<%=name%>",req:{index:{type:"list"},name:{type:"list"}}},{fmt:"/_alias/<%=name%>",req:{name:{type:"list"}}}]}),d.indices.prototype.getAliases=c({methods:["GET"],params:{timeout:{type:"time"}},urls:[{fmt:"/<%=index%>/_aliases",req:{index:{type:"list"}}},{fmt:"/_aliases"}]}),d.indices.prototype.getMapping=c({methods:["GET"],params:{},urls:[{fmt:"/<%=index%>/<%=type%>/_mapping",req:{index:{type:"list"},type:{type:"list"}}},{fmt:"/<%=index%>/_mapping",req:{index:{type:"list"}}},{fmt:"/_mapping"}]}),d.indices.prototype.getSettings=c({methods:["GET"],params:{},urls:[{fmt:"/<%=index%>/_settings",req:{index:{type:"list"}}},{fmt:"/_settings"}]}),d.indices.prototype.getTemplate=c({methods:["GET"],params:{},urls:[{fmt:"/_template/<%=name%>",req:{name:{type:"string"}}},{fmt:"/_template"}]}),d.indices.prototype.getWarmer=c({methods:["GET"],params:{},urls:[{fmt:"/<%=index%>/<%=type%>/_warmer/<%=name%>",req:{index:{type:"list"},type:{type:"list"},name:{type:"string"}}},{fmt:"/<%=index%>/_warmer/<%=name%>",req:{index:{type:"list"},name:{type:"string"}}},{fmt:"/<%=index%>/_warmer",req:{index:{type:"list"}}}]}),d.indices.prototype.open=c({methods:["POST"],params:{timeout:{type:"time"},masterTimeout:{type:"time",name:"master_timeout"}},urls:[{fmt:"/<%=index%>/_open",req:{index:{type:"string"}}}]}),d.indices.prototype.optimize=c({methods:["POST","GET"],params:{flush:{type:"boolean"},ignoreIndices:{type:"enum","default":"none",options:["none","missing"],name:"ignore_indices"},maxNumSegments:{type:"number",name:"max_num_segments"},onlyExpungeDeletes:{type:"boolean",name:"only_expunge_deletes"},operationThreading:{name:"operation_threading"},refresh:{type:"boolean"},waitForMerge:{type:"boolean",name:"wait_for_merge"}},urls:[{fmt:"/<%=index%>/_optimize",req:{index:{type:"list"}}},{fmt:"/_optimize"}]}),d.indices.prototype.putAlias=c({methods:["PUT"],params:{timeout:{type:"time"},masterTimeout:{type:"time",name:"master_timeout"}},urls:[{fmt:"/<%=index%>/_alias/<%=name%>",req:{index:{type:"string"},name:{type:"string"}}},{fmt:"/_alias/<%=name%>",req:{name:{type:"string"}}},{fmt:"/<%=index%>/_alias",req:{index:{type:"string"}}},{fmt:"/_alias"}]}),d.indices.prototype.putMapping=c({methods:["PUT","POST"],params:{ignoreConflicts:{type:"boolean",name:"ignore_conflicts"},timeout:{type:"time"},masterTimeout:{type:"time",name:"master_timeout"}},urls:[{fmt:"/<%=index%>/<%=type%>/_mapping",req:{index:{type:"list"},type:{type:"string"}}}]}),d.indices.prototype.putSettings=c({methods:["PUT"],params:{masterTimeout:{type:"time",name:"master_timeout"}},urls:[{fmt:"/<%=index%>/_settings",req:{index:{type:"list"}}},{fmt:"/_settings"}]}),d.indices.prototype.putTemplate=c({methods:["PUT","POST"],params:{order:{type:"number"},timeout:{type:"time"},masterTimeout:{type:"time",name:"master_timeout"}},urls:[{fmt:"/_template/<%=name%>",req:{name:{type:"string"}}}]}),d.indices.prototype.putWarmer=c({methods:["PUT"],params:{masterTimeout:{type:"time",name:"master_timeout"}},urls:[{fmt:"/<%=index%>/<%=type%>/_warmer/<%=name%>",req:{index:{type:"list"},type:{type:"list"},name:{type:"string"}}},{fmt:"/<%=index%>/_warmer/<%=name%>",req:{index:{type:"list"},name:{type:"string"}}}]}),d.indices.prototype.refresh=c({methods:["POST","GET"],params:{ignoreIndices:{type:"enum","default":"none",options:["none","missing"],name:"ignore_indices"},operationThreading:{name:"operation_threading"}},urls:[{fmt:"/<%=index%>/_refresh",req:{index:{type:"list"}}},{fmt:"/_refresh"}]}),d.indices.prototype.segments=c({methods:["GET"],params:{ignoreIndices:{type:"enum","default":"none",options:["none","missing"],name:"ignore_indices"},operationThreading:{name:"operation_threading"}},urls:[{fmt:"/<%=index%>/_segments",req:{index:{type:"list"}}},{fmt:"/_segments"}]}),d.indices.prototype.snapshotIndex=c({methods:["POST"],params:{ignoreIndices:{type:"enum","default":"none",options:["none","missing"],name:"ignore_indices"}},urls:[{fmt:"/<%=index%>/_gateway/snapshot",req:{index:{type:"list"}}},{fmt:"/_gateway/snapshot"}]}),d.indices.prototype.stats=c({methods:["GET"],params:{all:{type:"boolean"},clear:{type:"boolean"},completion:{type:"boolean"},completionFields:{type:"list",name:"completion_fields"},docs:{type:"boolean"},fielddata:{type:"boolean"},fielddataFields:{type:"list",name:"fielddata_fields"},fields:{type:"list"},filterCache:{type:"boolean",name:"filter_cache"},flush:{type:"boolean"},get:{type:"boolean"},groups:{type:"boolean"},idCache:{type:"boolean",name:"id_cache"},ignoreIndices:{type:"enum","default":"none",options:["none","missing"],name:"ignore_indices"},indexing:{type:"boolean"},merge:{type:"boolean"},refresh:{type:"boolean"},search:{type:"boolean"},store:{type:"boolean"},warmer:{type:"boolean"}},urls:[{fmt:"/<%=index%>/_stats",req:{index:{type:"list"}}},{fmt:"/_stats"}]}),d.indices.prototype.status=c({methods:["GET"],params:{ignoreIndices:{type:"enum","default":"none",options:["none","missing"],name:"ignore_indices"},operationThreading:{name:"operation_threading"},recovery:{type:"boolean"},snapshot:{type:"boolean"}},urls:[{fmt:"/<%=index%>/_status",req:{index:{type:"list"}}},{fmt:"/_status"}]}),d.indices.prototype.updateAliases=c({methods:["POST"],params:{timeout:{type:"time"},masterTimeout:{type:"time",name:"master_timeout"}},urls:[{fmt:"/_aliases"}]}),d.indices.prototype.validateQuery=c({methods:["GET","POST"],params:{explain:{type:"boolean"},ignoreIndices:{type:"enum","default":"none",options:["none","missing"],name:"ignore_indices"},operationThreading:{name:"operation_threading"},source:{type:"string"},q:{type:"string"}},urls:[{fmt:"/<%=index%>/<%=type%>/_validate/query",req:{index:{type:"list"},type:{type:"list"}}},{fmt:"/<%=index%>/_validate/query",req:{index:{type:"list"}}},{fmt:"/_validate/query"}]}),d.info=c({methods:["GET","HEAD"],params:{},urls:[{fmt:"/"}]}),d.mget=c({methods:["GET","POST"],params:{fields:{type:"list"},preference:{type:"string"},realtime:{type:"boolean"},refresh:{type:"boolean"},_source:{type:"list",name:"_source"},_sourceExclude:{type:"list",name:"_source_exclude"},_sourceInclude:{type:"list",name:"_source_include"}},urls:[{fmt:"/<%=index%>/<%=type%>/_mget",req:{index:{type:"string"},type:{type:"string"}}},{fmt:"/<%=index%>/_mget",req:{index:{type:"string"}}},{fmt:"/_mget"}]}),d.mlt=c({methods:["GET","POST"],params:{boostTerms:{type:"number",name:"boost_terms"},maxDocFreq:{type:"number",name:"max_doc_freq"},maxQueryTerms:{type:"number",name:"max_query_terms"},maxWordLen:{type:"number",name:"max_word_len"},minDocFreq:{type:"number",name:"min_doc_freq"},minTermFreq:{type:"number",name:"min_term_freq"},minWordLen:{type:"number",name:"min_word_len"},mltFields:{type:"list",name:"mlt_fields"},percentTermsToMatch:{type:"number",name:"percent_terms_to_match"},routing:{type:"string"},searchFrom:{type:"number",name:"search_from"},searchIndices:{type:"list",name:"search_indices"},searchQueryHint:{type:"string",name:"search_query_hint"},searchScroll:{type:"string",name:"search_scroll"},searchSize:{type:"number",name:"search_size"},searchSource:{type:"string",name:"search_source"},searchType:{type:"string",name:"search_type"},searchTypes:{type:"list",name:"search_types"},stopWords:{type:"list",name:"stop_words"}},urls:[{fmt:"/<%=index%>/<%=type%>/<%=id%>/_mlt",req:{index:{type:"string"},type:{type:"string"},id:{type:"string"}}}]}),d.msearch=c({methods:["GET","POST"],params:{searchType:{type:"enum",options:["query_then_fetch","query_and_fetch","dfs_query_then_fetch","dfs_query_and_fetch","count","scan"],name:"search_type"}},urls:[{fmt:"/<%=index%>/<%=type%>/_msearch",req:{index:{type:"list"},type:{type:"list"}}},{fmt:"/<%=index%>/_msearch",req:{index:{type:"list"}}},{fmt:"/_msearch"}],bulkBody:!0}),d.percolate=c({methods:["GET","POST"],params:{preferLocal:{type:"boolean",name:"prefer_local"}},urls:[{fmt:"/<%=index%>/<%=type%>/_percolate",req:{index:{type:"string"},type:{type:"string"}}}]}),d.scroll=c({methods:["GET","POST"],params:{scroll:{type:"duration"},scrollId:{type:"string",name:"scroll_id"}},urls:[{fmt:"/_search/scroll/<%=scrollId%>",req:{scrollId:{type:"string"}}},{fmt:"/_search/scroll"}]}),d.search=c({methods:["GET","POST"],params:{analyzer:{type:"string"},analyzeWildcard:{type:"boolean",name:"analyze_wildcard"},defaultOperator:{type:"enum","default":"OR",options:["AND","OR"],name:"default_operator"},df:{type:"string"},explain:{type:"boolean"},fields:{type:"list"},from:{type:"number"},ignoreIndices:{type:"enum","default":"none",options:["none","missing"],name:"ignore_indices"},indicesBoost:{type:"list",name:"indices_boost"},lenient:{type:"boolean"},lowercaseExpandedTerms:{type:"boolean",name:"lowercase_expanded_terms"},preference:{type:"string"},q:{type:"string"},routing:{type:"list"},scroll:{type:"duration"},searchType:{type:"enum",options:["query_then_fetch","query_and_fetch","dfs_query_then_fetch","dfs_query_and_fetch","count","scan"],name:"search_type"},size:{type:"number"},sort:{type:"list"},source:{type:"string"},_source:{type:"list",name:"_source"},_sourceExclude:{type:"list",name:"_source_exclude"},_sourceInclude:{type:"list",name:"_source_include"},stats:{type:"list"},suggestField:{type:"string",name:"suggest_field"},suggestMode:{type:"enum","default":"missing",options:["missing","popular","always"],name:"suggest_mode"},suggestSize:{type:"number",name:"suggest_size"},suggestText:{type:"text",name:"suggest_text"},timeout:{type:"time"},version:{type:"boolean"}},urls:[{fmt:"/<%=index%>/<%=type%>/_search",opt:{index:{type:"list","default":"_all"}},req:{type:{type:"list"}}},{fmt:"/<%=index%>/_search",opt:{index:{type:"list","default":"_all"}}}]}),d.suggest=c({methods:["POST","GET"],params:{ignoreIndices:{type:"enum","default":"none",options:["none","missing"],name:"ignore_indices"},preference:{type:"string"},routing:{type:"string"},source:{type:"string"}},urls:[{fmt:"/<%=index%>/_suggest",req:{index:{type:"list"}}},{fmt:"/_suggest"}]}),d.update=c({methods:["POST"],params:{consistency:{type:"enum",options:["one","quorum","all"]},fields:{type:"list"},lang:{type:"string"},parent:{type:"string"},percolate:{type:"string"},refresh:{type:"boolean"},replication:{type:"enum","default":"sync",options:["sync","async"]},retryOnConflict:{type:"number",name:"retry_on_conflict"},routing:{type:"string"},script:{},timeout:{type:"time"},timestamp:{type:"time"},ttl:{type:"duration"},version:{type:"number"},versionType:{type:"number",name:"version_type"}},urls:[{fmt:"/<%=index%>/<%=type%>/<%=id%>/_update",req:{index:{type:"string"},type:{type:"string"},id:{type:"string"}}}]})},{"./client_action":17,"./errors":22}],16:[function(a,b){function c(a){this.client=this,Object.defineProperty(this,"config",{configurable:!1,enumerable:!1,writable:!1,value:!a||d.isPlainObject(a)?new e(a):a}),this.config.client=this;for(var b=0;b1)this.config.selector(this.connections.alive,a);else try{d.nextTick(a,null,this.config.selector(this.connections.alive))}catch(b){this.config.log.error(b),a(b)}else a()},c.prototype.onStatusChanged=d.handler(function(a,b,c){var d,e,f;if(b===a)return!0;switch(this.config.log.info("connection id:",c.__id,"is",a),a){case"alive":d=this.connections.dead,e=this.connections.alive;break;case"dead":d=this.connections.alive,e=this.connections.dead;break;case"closed":d=this.connections[b]}d&&d.indexOf&&(f=d.indexOf(c),~f&&d.splice(f,1)),e&&e.indexOf&&(f=e.indexOf(c),~f||e.push(c))}),c.prototype._add=function(a){this.index[a.__id]||(this.index[a.__id]=a,a.on("status changed",this.bound.onStatusChanged),a.setStatus("alive"))},c.prototype._remove=function(a){this.index[a.__id]&&(delete this.index[a.__id],a.setStatus("closed"),a.removeListener("status changed",this.bound.onStatusChanged))},c.prototype.setNodes=function(a){var b,c,f,g,h=d.clone(this.index);for(c=0;ca?"0"+a.toString(10):a.toString(10)}function e(a,b){var c=f.repeat(" ",b||2);return a.split(/\r?\n/).map(function(a){return c+a}).join("\n")}var f=(a("./log"),a("./utils"));c.prototype.timestamp=function(){var a=new Date;return a.getUTCFullYear()+"-"+d(a.getUTCMonth()+1)+"-"+d(a.getUTCDate())+"T"+d(a.getUTCHours())+":"+d(a.getUTCMinutes())+":"+d(a.getUTCSeconds())+"Z"},c.prototype.format=function(a,b){return a+": "+this.timestamp()+"\n"+e(b)+"\n\n"},c.prototype.write=function(){throw new Error("This should be overwritten by the logger")},c.prototype.setupListeners=function(a){this.cleanUpListeners(),this.listeningLevels=a,f.each(this.listeningLevels,function(a){var b="on"+f.ucfirst(a);if(!this.bound[b])throw new Error(b+" is not a function");this.bridge.on(a,this.bound[b])},this)},c.prototype.cleanUpListeners=f.handler(function(){f.each(this.listeningLevels,function(a){this.bridge.removeListener(a,this.bound["on"+f.ucfirst(a)])},this)}),c.prototype.onError=f.handler(function(a){this.write("Error"===a.name?"ERROR":a.name,a.stack)}),c.prototype.onWarning=f.handler(function(a){this.write("WARNING",a)}),c.prototype.onInfo=f.handler(function(a){this.write("INFO",a)}),c.prototype.onDebug=f.handler(function(a){this.write("DEBUG",a)}),c.prototype.onTrace=f.handler(function(a,b,c,d,e){var f='curl "'+b.replace(/"/g,'\\"')+'" -X'+a.toUpperCase();c&&(f+=' -d "'+c.replace(/"/g,'\\"')+'"'),f+="\n<- "+e+"\n"+d,this.write("TRACE",f)}),b.exports=c},{"./log":24,"./utils":33}],26:[function(a,b){function c(a,b){d.call(this,a,b),this.color=e.has(a,"color")?!!a.color:!0}b.exports=c;var d=a("../logger"),e=a("../utils");e.inherits(c,d),c.prototype.setupListeners=function(a){this.bound.onWarning=this.onWarning,this.bound.onInfo=this.onInfo,this.bound.onDebug=this.onDebug,d.prototype.setupListeners.call(this,a)},c.prototype.onError=e.handler(function(a){console.error&&console.trace?(console.error("Error"===a.name?"ERROR":a.name),console.trace()):console.log("Error"===a.name?"ERROR":a.name,a.stack)}),c.prototype.onWarning=console[console.warn?"warn":"log"].bind(console,"WARNING"),c.prototype.onInfo=console[console.info?"info":"log"].bind(console,"INFO"),c.prototype.onDebug=console[console.debug?"debug":"log"].bind(console,"DEBUG"),c.prototype.onTrace=e.handler(function(a,b,c,d,e){var f='curl "'+b.replace(/"/g,'\\"')+'" -X'+a.toUpperCase();c&&(f+=' -d "'+c.replace(/"/g,'\\"')+'"'),f+="\n<- "+e+"\n"+d,console.log("TRACE",f)})},{"../logger":25,"../utils":33}],27:[function(a,b){b.exports={random:a("./random"),roundRobin:a("./round_robin")}},{"./random":28,"./round_robin":29}],28:[function(a,b){function c(a){return a[Math.floor(Math.random()*a.length)]}b.exports=c},{}],29:[function(a,b){function c(a){return a.unshift(a.pop()),a[0]}b.exports=c},{}],30:[function(a,b){function c(a){this.client=a}b.exports=c;var d=a("../utils");c.prototype.serialize=function(a,b,c){return null==a?null:"string"==typeof a?a:JSON.stringify(a,b,c)},c.prototype.unserialize=function(a){if("string"!=typeof a)return a;try{return JSON.parse(a)}catch(b){return this.client.log.error(new Error("unable to parse",a)),null}},c.prototype.bulkBody=function(a){var b,c="";if(d.isArray(a))for(b=0;bc||c>=300)&&!e.contains(h,c)&&(a=g[c]?new g[c](d&&d.error):new g.Generic("unknown error")),this._params.castExists&&(a&&a instanceof g.NotFound?(d=!1,a=void 0):d=!a),this._error=a,this._response={body:d,status:c},this.emit("done",this._error,this._response.body,this._response.status)}),c.prototype.abort=function(){return this.aborted=!0,this.__request?(this.__request.abort(),!0):!1},c.prototype.then=function(a,b){this._error?b(this._error):this._response?a(this._response):this.once("done",e.bindKey(this,"then",a,b))}},{"./errors":22,"./utils":33,__browserify_process:12,events:4}],33:[function(a,b){function c(a,b,c){return function(d){for(var e,f,g,h,i=0,j=[],k="";i=97&&122>=e,g=e>=65&&90>=e,(g||!h)&&(k.length&&j.push(k),k=""),(g||h)&&(h&&k.length?k+=f:k=!j.length&&a||j.length&&b?f.toUpperCase():f.toLowerCase());return k.length&&j.push(k),j.join(c)}}var d=a("__browserify_process"),e=a("path"),f=a("lodash"),g=a("util"),h=f.extend({},f,g);f=h,h.inspect=function(a,b){return g.inspect(a,f.defaults(b||{},{showHidden:!0,depth:null,color:!0}))},h.joinPath=e.join,h.reKey=function(a,b,c){if(void 0===c&&(c=!0),"function"!=typeof b)throw new TypeError("invalid transform function");var d={};return f.each(a,function(a,e){d[b(e)]=c&&"object"==typeof a?h.reKey(a,b,c):a}),d},h.deepMerge=function(a,b){return Object.keys(b).forEach(function(c){switch(typeof a[c]){case"undefined":a[c]=b[c];break;case"object":f.isArray(a[c])&&f.isArray(b[c])?a[c]=a[c].concat(b[c]):f.isPlainObject(a[c])&&f.isPlainObject(b[c])&&h.deepMerge(a[c],b[c])}}),a},"String Object PlainObject Array Finite Function RegExp".split(" ").forEach(function(a){var b=f.bindKey(f,"is"+a);h["isArrayOf"+a+"s"]=function(a){return f.isArray(a)&&f.every(a.slice(0,10),b)}}),h.ucfirst=function(a){return a[0].toUpperCase()+a.substring(1).toLowerCase()},h.studlyCase=c(!0,!0,""),h.camelCase=c(!1,!0,""),h.snakeCase=c(!1,!1,"_"),h.toLowerString=function(a){return a?"string"!=typeof a&&(a=a.toString()):a="",a.toLowerCase()},h.toUpperString=function(a){return a?"string"!=typeof a&&(a=a.toString()):a="",a.toUpperCase()},h.isNumeric=function(a){return!isNaN(null===a?0/0:1*a)};var i=/^(\d+(?:\.\d+)?)([Mwdhmsy])$/;h.isInterval=function(a){return!(!a.match||!a.match(i))},h.repeat=function(a,b){return new Array(b+1).join(a)},h.inherits=function(a,b){g.inherits(a,b),a.callSuper=function(a,c){c?f.isArguments(c)?h.applyArgs(b,a,c):h.applyArgs(b,a,arguments,1):b.call(a)}},h.trim=function(a){return"string"==typeof a?a.replace(/^\s+|\s+$/g,""):""},h.collectMatches=function(a,b){for(var c,d=[];(c=b.exec(a))&&(d.push(c),b.global===!0););return d},h.applyArgs=function(a,b,c,d){switch(d=d||0,c.length-d){case 0:return a.call(b);case 1:return a.call(b,c[0+d]);case 2:return a.call(b,c[0+d],c[1+d]);case 3:return a.call(b,c[0+d],c[1+d],c[2+d]);case 4:return a.call(b,c[0+d],c[1+d],c[2+d],c[3+d]);case 5:return a.call(b,c[0+d],c[1+d],c[2+d],c[3+d],c[4+d]);default:return a.apply(b,Array.prototype.slice.call(c,d))}},f.nextTick=function(a){d.nextTick(f.bindKey(f,"applyArgs",a,null,arguments,1))},f.handler=function(a){return a._provideBound=!0,a},f.scheduled=f.handler,f.makeBoundMethods=function(a,b){if(a.bound={},b)f.each(b,function(b){a.bound[b]=f.bindKey(a,b)});else{b=[];for(var c in a)"function"==typeof a[c]&&a[c]._provideBound===!0&&(a.bound[c]=f.bind(a[c],a))}},f.noop=function(){},f.getStackTrace=function(a){var b={};return Error.captureStackTrace(b,a||f.getStackTrace),"\n"+b.stack.split("\n").slice(1).join("\n")},b.exports=h},{__browserify_process:12,lodash:13,path:5,util:8}]},{},[14])(14)}); \ No newline at end of file +return f},ee=function(a,b,c){var d,e=a,f=e;if(!e)return f;if(!Z[typeof e])return f;b=b&&"undefined"==typeof c?b:g(b,c,3);for(d in e)if(b(e[d],d,a)===!1)return f;return f},fe=function(a,b,c){var d,e=a,f=e;if(!e)return f;if(!Z[typeof e])return f;b=b&&"undefined"==typeof c?b:g(b,c,3);for(var h=-1,i=Z[typeof e]&&Zd(e),j=i?i.length:0;++h/g,H=RegExp("^["+z+"]*0+(?=.$)"),I=/($^)/,J=/\bthis\b/,K=/['\n\r\t\u2028\u2029\\]/g,L=["Array","Boolean","Date","Function","Math","Number","Object","RegExp","String","_","attachEvent","clearTimeout","isFinite","isNaN","parseInt","setImmediate","setTimeout"],M=0,N="[object Arguments]",O="[object Array]",P="[object Boolean]",Q="[object Date]",R="[object Function]",S="[object Number]",T="[object Object]",U="[object RegExp]",V="[object String]",W={};W[R]=!1,W[N]=W[O]=W[P]=W[Q]=W[S]=W[T]=W[U]=W[V]=!0;var X={leading:!1,maxWait:0,trailing:!1},Y={configurable:!1,enumerable:!1,value:null,writable:!1},Z={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,undefined:!1},$={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"},_=Z[typeof window]&&window||this,ab=Z[typeof d]&&d&&!d.nodeType&&d,bb=Z[typeof c]&&c&&!c.nodeType&&c,cb=bb&&bb.exports===ab&&ab,db=Z[typeof e]&&e;!db||db.global!==db&&db.window!==db||(_=db);var eb=r();"function"==typeof a&&"object"==typeof a.amd&&a.amd?(_._=eb,a(function(){return eb})):ab&&bb?cb?(bb.exports=eb)._=eb:ab._=eb:_._=eb}).call(this)},{}],14:[function(a,b){var c={Client:a("./lib/client")};b.exports=c},{"./lib/client":16}],15:[function(a,b){var c=a("./client_action");a("./errors");var d=b.exports={};d._namespaces=["cluster","indices"],d.bulk=c({methods:["POST","PUT"],params:{consistency:{type:"enum",options:["one","quorum","all"]},refresh:{type:"boolean"},replication:{type:"enum","default":"sync",options:["sync","async"]},type:{type:"string"}},urls:[{fmt:"/<%=index%>/<%=type%>/_bulk",req:{index:{type:"string"},type:{type:"string"}}},{fmt:"/<%=index%>/_bulk",req:{index:{type:"string"}}},{fmt:"/_bulk"}],bulkBody:!0}),d.clearScroll=c({methods:["DELETE"],params:{},urls:[{fmt:"/_search/scroll/<%=scrollId%>",req:{scrollId:{type:"list"}}}]}),d.cluster=function e(a){return this instanceof e?(this.client=a,void 0):new e(a)},d.cluster.prototype.getSettings=c({methods:["GET"],params:{},urls:[{fmt:"/_cluster/settings"}]}),d.cluster.prototype.health=c({methods:["GET"],params:{level:{type:"enum","default":"cluster",options:["cluster","indices","shards"]},local:{type:"boolean"},masterTimeout:{type:"time",name:"master_timeout"},timeout:{type:"time"},waitForActiveShards:{type:"number",name:"wait_for_active_shards"},waitForNodes:{type:"string",name:"wait_for_nodes"},waitForRelocatingShards:{type:"number",name:"wait_for_relocating_shards"},waitForStatus:{type:"enum","default":null,options:["green","yellow","red"],name:"wait_for_status"}},urls:[{fmt:"/_cluster/health/<%=index%>",req:{index:{type:"string"}}},{fmt:"/_cluster/health"}]}),d.cluster.prototype.nodeHotThreads=c({methods:["GET"],params:{interval:{type:"time"},snapshots:{type:"number"},threads:{type:"number"},type:{type:"enum",options:["cpu","wait","block"]}},urls:[{fmt:"/_nodes/<%=nodeId%>/hotthreads",req:{nodeId:{type:"list"}}},{fmt:"/_nodes/hotthreads"}]}),d.cluster.prototype.nodeInfo=c({methods:["GET"],params:{all:{type:"boolean"},clear:{type:"boolean"},http:{type:"boolean"},jvm:{type:"boolean"},network:{type:"boolean"},os:{type:"boolean"},plugin:{type:"boolean"},process:{type:"boolean"},settings:{type:"boolean"},threadPool:{type:"boolean",name:"thread_pool"},timeout:{type:"time"},transport:{type:"boolean"}},urls:[{fmt:"/_nodes/<%=nodeId%>",req:{nodeId:{type:"list"}}},{fmt:"/_nodes"}]}),d.cluster.prototype.nodeShutdown=c({methods:["POST"],params:{delay:{type:"time"},exit:{type:"boolean"}},urls:[{fmt:"/_cluster/nodes/<%=nodeId%>/_shutdown",req:{nodeId:{type:"list"}}},{fmt:"/_shutdown"}]}),d.cluster.prototype.nodeStats=c({methods:["GET"],params:{all:{type:"boolean"},clear:{type:"boolean"},fields:{type:"list"},fs:{type:"boolean"},http:{type:"boolean"},indices:{type:"boolean"},jvm:{type:"boolean"},network:{type:"boolean"},os:{type:"boolean"},process:{type:"boolean"},threadPool:{type:"boolean",name:"thread_pool"},transport:{type:"boolean"}},urls:[{fmt:"/_nodes/<%=nodeId%>/stats",req:{nodeId:{type:"list"}}},{fmt:"/_nodes/stats"}]}),d.cluster.prototype.putSettings=c({methods:["PUT"],params:{},urls:[{fmt:"/_cluster/settings"}]}),d.cluster.prototype.reroute=c({methods:["POST"],params:{dryRun:{type:"boolean",name:"dry_run"},filterMetadata:{type:"boolean",name:"filter_metadata"}},urls:[{fmt:"/_cluster/reroute"}]}),d.cluster.prototype.state=c({methods:["GET"],params:{filterBlocks:{type:"boolean",name:"filter_blocks"},filterIndexTemplates:{type:"boolean",name:"filter_index_templates"},filterIndices:{type:"list",name:"filter_indices"},filterMetadata:{type:"boolean",name:"filter_metadata"},filterNodes:{type:"boolean",name:"filter_nodes"},filterRoutingTable:{type:"boolean",name:"filter_routing_table"},local:{type:"boolean"},masterTimeout:{type:"time",name:"master_timeout"}},urls:[{fmt:"/_cluster/state"}]}),d.count=c({methods:["POST","GET"],params:{ignoreIndices:{type:"enum","default":"none",options:["none","missing"],name:"ignore_indices"},minScore:{type:"number",name:"min_score"},preference:{type:"string"},routing:{type:"string"},source:{type:"string"}},urls:[{fmt:"/<%=index%>/<%=type%>/_count",req:{index:{type:"list"},type:{type:"list"}}},{fmt:"/<%=index%>/_count",req:{index:{type:"list"}}},{fmt:"/_count"}]}),d.create=c({methods:["POST","PUT"],params:{consistency:{type:"enum",options:["one","quorum","all"]},id:{type:"string"},parent:{type:"string"},percolate:{type:"string"},refresh:{type:"boolean"},replication:{type:"enum","default":"sync",options:["sync","async"]},routing:{type:"string"},timeout:{type:"time"},timestamp:{type:"time"},ttl:{type:"duration"},version:{type:"number"},versionType:{type:"enum",options:["internal","external"],name:"version_type"}},urls:[{fmt:"/<%=index%>/<%=type%>/<%=id%>/_create",req:{index:{type:"string"},type:{type:"string"},id:{type:"string"}}},{fmt:"/<%=index%>/<%=type%>",req:{index:{type:"string"},type:{type:"string"}}}]}),d["delete"]=c({methods:["DELETE"],params:{consistency:{type:"enum",options:["one","quorum","all"]},parent:{type:"string"},refresh:{type:"boolean"},replication:{type:"enum","default":"sync",options:["sync","async"]},routing:{type:"string"},timeout:{type:"time"},version:{type:"number"},versionType:{type:"enum",options:["internal","external"],name:"version_type"}},urls:[{fmt:"/<%=index%>/<%=type%>/<%=id%>",req:{index:{type:"string"},type:{type:"string"},id:{type:"string"}}}]}),d.deleteByQuery=c({methods:["DELETE"],params:{analyzer:{type:"string"},consistency:{type:"enum",options:["one","quorum","all"]},defaultOperator:{type:"enum","default":"OR",options:["AND","OR"],name:"default_operator"},df:{type:"string"},ignoreIndices:{type:"enum","default":"none",options:["none","missing"],name:"ignore_indices"},replication:{type:"enum","default":"sync",options:["sync","async"]},q:{type:"string"},routing:{type:"string"},source:{type:"string"},timeout:{type:"time"}},urls:[{fmt:"/<%=index%>/<%=type%>/_query",req:{index:{type:"list"},type:{type:"list"}}},{fmt:"/<%=index%>/_query",req:{index:{type:"list"}}}]}),d.exists=c({methods:["HEAD"],params:{parent:{type:"string"},preference:{type:"string"},realtime:{type:"boolean"},refresh:{type:"boolean"},routing:{type:"string"}},urls:[{fmt:"/<%=index%>/<%=type%>/<%=id%>",opt:{type:{type:"string","default":"_all"}},req:{index:{type:"string"},id:{type:"string"}}}],castExists:!0}),d.explain=c({methods:["GET","POST"],params:{analyzeWildcard:{type:"boolean",name:"analyze_wildcard"},analyzer:{type:"string"},defaultOperator:{type:"enum","default":"OR",options:["AND","OR"],name:"default_operator"},df:{type:"string"},fields:{type:"list"},lenient:{type:"boolean"},lowercaseExpandedTerms:{type:"boolean",name:"lowercase_expanded_terms"},parent:{type:"string"},preference:{type:"string"},q:{type:"string"},routing:{type:"string"},source:{type:"list",name:"_source"},sourceExclude:{type:"list",name:"_source_exclude"},sourceInclude:{type:"list",name:"_source_include"}},urls:[{fmt:"/<%=index%>/<%=type%>/<%=id%>/_explain",req:{index:{type:"string"},type:{type:"string"},id:{type:"string"}}}]}),d.get=c({methods:["GET"],params:{fields:{type:"list"},parent:{type:"string"},preference:{type:"string"},realtime:{type:"boolean"},refresh:{type:"boolean"},routing:{type:"string"},source:{type:"list",name:"_source"},sourceExclude:{type:"list",name:"_source_exclude"},sourceInclude:{type:"list",name:"_source_include"}},urls:[{fmt:"/<%=index%>/<%=type%>/<%=id%>",opt:{type:{type:"string","default":"_all"}},req:{index:{type:"string"},id:{type:"string"}}}]}),d.getSource=c({methods:["GET"],params:{exclude:{type:"list"},include:{type:"list"},parent:{type:"string"},preference:{type:"string"},realtime:{type:"boolean"},refresh:{type:"boolean"},routing:{type:"string"}},urls:[{fmt:"/<%=index%>/<%=type%>/<%=id%>/_source",opt:{type:{type:"string","default":"_all"}},req:{index:{type:"string"},id:{type:"string"}}}]}),d.index=c({methods:["POST","PUT"],params:{consistency:{type:"enum",options:["one","quorum","all"]},opType:{type:"enum","default":"index",options:["index","create"],name:"op_type"},parent:{type:"string"},percolate:{type:"string"},refresh:{type:"boolean"},replication:{type:"enum","default":"sync",options:["sync","async"]},routing:{type:"string"},timeout:{type:"time"},timestamp:{type:"time"},ttl:{type:"duration"},version:{type:"number"},versionType:{type:"enum",options:["internal","external"],name:"version_type"}},urls:[{fmt:"/<%=index%>/<%=type%>/<%=id%>",req:{index:{type:"string"},type:{type:"string"},id:{type:"string"}}},{fmt:"/<%=index%>/<%=type%>",req:{index:{type:"string"},type:{type:"string"}}}]}),d.indices=function f(a){return this instanceof f?(this.client=a,void 0):new f(a)},d.indices.prototype.analyze=c({methods:["GET","POST"],params:{analyzer:{type:"string"},field:{type:"string"},filters:{type:"list"},index:{type:"string"},preferLocal:{type:"boolean",name:"prefer_local"},text:{type:"string"},tokenizer:{type:"string"},format:{type:"enum","default":"detailed",options:["detailed","text"]}},urls:[{fmt:"/<%=index%>/_analyze",req:{index:{type:"string"}}},{fmt:"/_analyze"}]}),d.indices.prototype.clearCache=c({methods:["POST","GET"],params:{fieldData:{type:"boolean",name:"field_data"},fielddata:{type:"boolean"},fields:{type:"list"},filter:{type:"boolean"},filterCache:{type:"boolean",name:"filter_cache"},filterKeys:{type:"boolean",name:"filter_keys"},id:{type:"boolean"},idCache:{type:"boolean",name:"id_cache"},ignoreIndices:{type:"enum","default":"none",options:["none","missing"],name:"ignore_indices"},index:{type:"list"},recycler:{type:"boolean"}},urls:[{fmt:"/<%=index%>/_cache/clear",req:{index:{type:"list"}}},{fmt:"/_cache/clear"}]}),d.indices.prototype.close=c({methods:["POST"],params:{timeout:{type:"time"},masterTimeout:{type:"time",name:"master_timeout"}},urls:[{fmt:"/<%=index%>/_close",req:{index:{type:"string"}}}]}),d.indices.prototype.create=c({methods:["PUT","POST"],params:{timeout:{type:"time"},masterTimeout:{type:"time",name:"master_timeout"}},urls:[{fmt:"/<%=index%>",req:{index:{type:"string"}}}]}),d.indices.prototype["delete"]=c({methods:["DELETE"],params:{timeout:{type:"time"},masterTimeout:{type:"time",name:"master_timeout"}},urls:[{fmt:"/<%=index%>",req:{index:{type:"list"}}},{fmt:"/"}]}),d.indices.prototype.deleteAlias=c({methods:["DELETE"],params:{timeout:{type:"time"},masterTimeout:{type:"time",name:"master_timeout"}},urls:[{fmt:"/<%=index%>/_alias/<%=name%>",req:{index:{type:"string"},name:{type:"string"}}}]}),d.indices.prototype.deleteMapping=c({methods:["DELETE"],params:{masterTimeout:{type:"time",name:"master_timeout"}},urls:[{fmt:"/<%=index%>/<%=type%>",req:{index:{type:"list"},type:{type:"string"}}}]}),d.indices.prototype.deleteTemplate=c({methods:["DELETE"],params:{timeout:{type:"time"},masterTimeout:{type:"time",name:"master_timeout"}},urls:[{fmt:"/_template/<%=name%>",req:{name:{type:"string"}}}]}),d.indices.prototype.deleteWarmer=c({methods:["DELETE"],params:{masterTimeout:{type:"time",name:"master_timeout"}},urls:[{fmt:"/<%=index%>/<%=type%>/_warmer/<%=name%>",req:{index:{type:"list"},type:{type:"list"},name:{type:"string"}}},{fmt:"/<%=index%>/_warmer/<%=name%>",req:{index:{type:"list"},name:{type:"string"}}},{fmt:"/<%=index%>/_warmer",req:{index:{type:"list"}}}]}),d.indices.prototype.exists=c({methods:["HEAD"],params:{},urls:[{fmt:"/<%=index%>",req:{index:{type:"list"}}}],castExists:!0}),d.indices.prototype.existsAlias=c({methods:["HEAD"],params:{ignoreIndices:{type:"enum","default":"none",options:["none","missing"],name:"ignore_indices"}},urls:[{fmt:"/<%=index%>/_alias/<%=name%>",req:{index:{type:"list"},name:{type:"list"}}},{fmt:"/_alias/<%=name%>",req:{name:{type:"list"}}}],castExists:!0}),d.indices.prototype.existsType=c({methods:["HEAD"],params:{ignoreIndices:{type:"enum","default":"none",options:["none","missing"],name:"ignore_indices"}},urls:[{fmt:"/<%=index%>/<%=type%>",req:{index:{type:"list"},type:{type:"list"}}}],castExists:!0}),d.indices.prototype.flush=c({methods:["POST","GET"],params:{force:{type:"boolean"},full:{type:"boolean"},ignoreIndices:{type:"enum","default":"none",options:["none","missing"],name:"ignore_indices"},refresh:{type:"boolean"}},urls:[{fmt:"/<%=index%>/_flush",req:{index:{type:"list"}}},{fmt:"/_flush"}]}),d.indices.prototype.getAlias=c({methods:["GET"],params:{ignoreIndices:{type:"enum","default":"none",options:["none","missing"],name:"ignore_indices"}},urls:[{fmt:"/<%=index%>/_alias/<%=name%>",req:{index:{type:"list"},name:{type:"list"}}},{fmt:"/_alias/<%=name%>",req:{name:{type:"list"}}}]}),d.indices.prototype.getAliases=c({methods:["GET"],params:{timeout:{type:"time"}},urls:[{fmt:"/<%=index%>/_aliases",req:{index:{type:"list"}}},{fmt:"/_aliases"}]}),d.indices.prototype.getFieldMapping=c({methods:["GET"],params:{includeDefaults:{type:"boolean",name:"include_defaults"}},urls:[{fmt:"/<%=index%>/<%=type%>/_mapping/field/<%=field%>",req:{index:{type:"list"},type:{type:"list"},field:{type:"list"}}},{fmt:"/<%=index%>/_mapping/field/<%=field%>",req:{index:{type:"list"},field:{type:"list"}}},{fmt:"/_mapping/field/<%=field%>",req:{field:{type:"list"}}}]}),d.indices.prototype.getMapping=c({methods:["GET"],params:{},urls:[{fmt:"/<%=index%>/<%=type%>/_mapping",req:{index:{type:"list"},type:{type:"list"}}},{fmt:"/<%=index%>/_mapping",req:{index:{type:"list"}}},{fmt:"/_mapping"}]}),d.indices.prototype.getSettings=c({methods:["GET"],params:{},urls:[{fmt:"/<%=index%>/_settings",req:{index:{type:"list"}}},{fmt:"/_settings"}]}),d.indices.prototype.getTemplate=c({methods:["GET"],params:{},urls:[{fmt:"/_template/<%=name%>",req:{name:{type:"string"}}},{fmt:"/_template"}]}),d.indices.prototype.getWarmer=c({methods:["GET"],params:{},urls:[{fmt:"/<%=index%>/<%=type%>/_warmer/<%=name%>",req:{index:{type:"list"},type:{type:"list"},name:{type:"string"}}},{fmt:"/<%=index%>/_warmer/<%=name%>",req:{index:{type:"list"},name:{type:"string"}}},{fmt:"/<%=index%>/_warmer",req:{index:{type:"list"}}}]}),d.indices.prototype.open=c({methods:["POST"],params:{timeout:{type:"time"},masterTimeout:{type:"time",name:"master_timeout"}},urls:[{fmt:"/<%=index%>/_open",req:{index:{type:"string"}}}]}),d.indices.prototype.optimize=c({methods:["POST","GET"],params:{flush:{type:"boolean"},ignoreIndices:{type:"enum","default":"none",options:["none","missing"],name:"ignore_indices"},maxNumSegments:{type:"number",name:"max_num_segments"},onlyExpungeDeletes:{type:"boolean",name:"only_expunge_deletes"},operationThreading:{name:"operation_threading"},refresh:{type:"boolean"},waitForMerge:{type:"boolean",name:"wait_for_merge"}},urls:[{fmt:"/<%=index%>/_optimize",req:{index:{type:"list"}}},{fmt:"/_optimize"}]}),d.indices.prototype.putAlias=c({methods:["PUT"],params:{timeout:{type:"time"},masterTimeout:{type:"time",name:"master_timeout"}},urls:[{fmt:"/<%=index%>/_alias/<%=name%>",req:{index:{type:"string"},name:{type:"string"}}},{fmt:"/_alias/<%=name%>",req:{name:{type:"string"}}},{fmt:"/<%=index%>/_alias",req:{index:{type:"string"}}},{fmt:"/_alias"}]}),d.indices.prototype.putMapping=c({methods:["PUT","POST"],params:{ignoreConflicts:{type:"boolean",name:"ignore_conflicts"},timeout:{type:"time"},masterTimeout:{type:"time",name:"master_timeout"}},urls:[{fmt:"/<%=index%>/<%=type%>/_mapping",req:{index:{type:"list"},type:{type:"string"}}}]}),d.indices.prototype.putSettings=c({methods:["PUT"],params:{masterTimeout:{type:"time",name:"master_timeout"}},urls:[{fmt:"/<%=index%>/_settings",req:{index:{type:"list"}}},{fmt:"/_settings"}]}),d.indices.prototype.putTemplate=c({methods:["PUT","POST"],params:{order:{type:"number"},timeout:{type:"time"},masterTimeout:{type:"time",name:"master_timeout"}},urls:[{fmt:"/_template/<%=name%>",req:{name:{type:"string"}}}]}),d.indices.prototype.putWarmer=c({methods:["PUT"],params:{masterTimeout:{type:"time",name:"master_timeout"}},urls:[{fmt:"/<%=index%>/<%=type%>/_warmer/<%=name%>",req:{index:{type:"list"},type:{type:"list"},name:{type:"string"}}},{fmt:"/<%=index%>/_warmer/<%=name%>",req:{index:{type:"list"},name:{type:"string"}}}]}),d.indices.prototype.refresh=c({methods:["POST","GET"],params:{ignoreIndices:{type:"enum","default":"none",options:["none","missing"],name:"ignore_indices"},operationThreading:{name:"operation_threading"}},urls:[{fmt:"/<%=index%>/_refresh",req:{index:{type:"list"}}},{fmt:"/_refresh"}]}),d.indices.prototype.segments=c({methods:["GET"],params:{ignoreIndices:{type:"enum","default":"none",options:["none","missing"],name:"ignore_indices"},operationThreading:{name:"operation_threading"}},urls:[{fmt:"/<%=index%>/_segments",req:{index:{type:"list"}}},{fmt:"/_segments"}]}),d.indices.prototype.snapshotIndex=c({methods:["POST"],params:{ignoreIndices:{type:"enum","default":"none",options:["none","missing"],name:"ignore_indices"}},urls:[{fmt:"/<%=index%>/_gateway/snapshot",req:{index:{type:"list"}}},{fmt:"/_gateway/snapshot"}]}),d.indices.prototype.stats=c({methods:["GET"],params:{all:{type:"boolean"},clear:{type:"boolean"},completion:{type:"boolean"},completionFields:{type:"list",name:"completion_fields"},docs:{type:"boolean"},fielddata:{type:"boolean"},fielddataFields:{type:"list",name:"fielddata_fields"},fields:{type:"list"},filterCache:{type:"boolean",name:"filter_cache"},flush:{type:"boolean"},get:{type:"boolean"},groups:{type:"boolean"},idCache:{type:"boolean",name:"id_cache"},ignoreIndices:{type:"enum","default":"none",options:["none","missing"],name:"ignore_indices"},indexing:{type:"boolean"},merge:{type:"boolean"},refresh:{type:"boolean"},search:{type:"boolean"},store:{type:"boolean"},warmer:{type:"boolean"}},urls:[{fmt:"/<%=index%>/_stats",req:{index:{type:"list"}}},{fmt:"/_stats"}]}),d.indices.prototype.status=c({methods:["GET"],params:{ignoreIndices:{type:"enum","default":"none",options:["none","missing"],name:"ignore_indices"},operationThreading:{name:"operation_threading"},recovery:{type:"boolean"},snapshot:{type:"boolean"}},urls:[{fmt:"/<%=index%>/_status",req:{index:{type:"list"}}},{fmt:"/_status"}]}),d.indices.prototype.updateAliases=c({methods:["POST"],params:{timeout:{type:"time"},masterTimeout:{type:"time",name:"master_timeout"}},urls:[{fmt:"/_aliases"}]}),d.indices.prototype.validateQuery=c({methods:["GET","POST"],params:{explain:{type:"boolean"},ignoreIndices:{type:"enum","default":"none",options:["none","missing"],name:"ignore_indices"},operationThreading:{name:"operation_threading"},source:{type:"string"},q:{type:"string"}},urls:[{fmt:"/<%=index%>/<%=type%>/_validate/query",req:{index:{type:"list"},type:{type:"list"}}},{fmt:"/<%=index%>/_validate/query",req:{index:{type:"list"}}},{fmt:"/_validate/query"}]}),d.info=c({methods:["GET","HEAD"],params:{},urls:[{fmt:"/"}]}),d.mget=c({methods:["GET","POST"],params:{fields:{type:"list"},preference:{type:"string"},realtime:{type:"boolean"},refresh:{type:"boolean"},source:{type:"list",name:"_source"},sourceExclude:{type:"list",name:"_source_exclude"},sourceInclude:{type:"list",name:"_source_include"}},urls:[{fmt:"/<%=index%>/<%=type%>/_mget",req:{index:{type:"string"},type:{type:"string"}}},{fmt:"/<%=index%>/_mget",req:{index:{type:"string"}}},{fmt:"/_mget"}]}),d.mlt=c({methods:["GET","POST"],params:{boostTerms:{type:"number",name:"boost_terms"},maxDocFreq:{type:"number",name:"max_doc_freq"},maxQueryTerms:{type:"number",name:"max_query_terms"},maxWordLen:{type:"number",name:"max_word_len"},minDocFreq:{type:"number",name:"min_doc_freq"},minTermFreq:{type:"number",name:"min_term_freq"},minWordLen:{type:"number",name:"min_word_len"},mltFields:{type:"list",name:"mlt_fields"},percentTermsToMatch:{type:"number",name:"percent_terms_to_match"},routing:{type:"string"},searchFrom:{type:"number",name:"search_from"},searchIndices:{type:"list",name:"search_indices"},searchQueryHint:{type:"string",name:"search_query_hint"},searchScroll:{type:"string",name:"search_scroll"},searchSize:{type:"number",name:"search_size"},searchSource:{type:"string",name:"search_source"},searchType:{type:"string",name:"search_type"},searchTypes:{type:"list",name:"search_types"},stopWords:{type:"list",name:"stop_words"}},urls:[{fmt:"/<%=index%>/<%=type%>/<%=id%>/_mlt",req:{index:{type:"string"},type:{type:"string"},id:{type:"string"}}}]}),d.msearch=c({methods:["GET","POST"],params:{searchType:{type:"enum",options:["query_then_fetch","query_and_fetch","dfs_query_then_fetch","dfs_query_and_fetch","count","scan"],name:"search_type"}},urls:[{fmt:"/<%=index%>/<%=type%>/_msearch",req:{index:{type:"list"},type:{type:"list"}}},{fmt:"/<%=index%>/_msearch",req:{index:{type:"list"}}},{fmt:"/_msearch"}],bulkBody:!0}),d.percolate=c({methods:["GET","POST"],params:{preferLocal:{type:"boolean",name:"prefer_local"}},urls:[{fmt:"/<%=index%>/<%=type%>/_percolate",req:{index:{type:"string"},type:{type:"string"}}}]}),d.scroll=c({methods:["GET","POST"],params:{scroll:{type:"duration"},scrollId:{type:"string",name:"scroll_id"}},urls:[{fmt:"/_search/scroll/<%=scrollId%>",req:{scrollId:{type:"string"}}},{fmt:"/_search/scroll"}]}),d.search=c({methods:["GET","POST"],params:{analyzer:{type:"string"},analyzeWildcard:{type:"boolean",name:"analyze_wildcard"},defaultOperator:{type:"enum","default":"OR",options:["AND","OR"],name:"default_operator"},df:{type:"string"},explain:{type:"boolean"},fields:{type:"list"},from:{type:"number"},ignoreIndices:{type:"enum","default":"none",options:["none","missing"],name:"ignore_indices"},indicesBoost:{type:"list",name:"indices_boost"},lenient:{type:"boolean"},lowercaseExpandedTerms:{type:"boolean",name:"lowercase_expanded_terms"},preference:{type:"string"},q:{type:"string"},routing:{type:"list"},scroll:{type:"duration"},searchType:{type:"enum",options:["query_then_fetch","query_and_fetch","dfs_query_then_fetch","dfs_query_and_fetch","count","scan"],name:"search_type"},size:{type:"number"},sort:{type:"list"},source:{type:"list",name:"_source"},sourceExclude:{type:"list",name:"_source_exclude"},sourceInclude:{type:"list",name:"_source_include"},stats:{type:"list"},suggestField:{type:"string",name:"suggest_field"},suggestMode:{type:"enum","default":"missing",options:["missing","popular","always"],name:"suggest_mode"},suggestSize:{type:"number",name:"suggest_size"},suggestText:{type:"text",name:"suggest_text"},timeout:{type:"time"},version:{type:"boolean"}},urls:[{fmt:"/<%=index%>/<%=type%>/_search",opt:{index:{type:"list","default":"_all"}},req:{type:{type:"list"}}},{fmt:"/<%=index%>/_search",opt:{index:{type:"list","default":"_all"}}}]}),d.suggest=c({methods:["POST","GET"],params:{ignoreIndices:{type:"enum","default":"none",options:["none","missing"],name:"ignore_indices"},preference:{type:"string"},routing:{type:"string"},source:{type:"string"}},urls:[{fmt:"/<%=index%>/_suggest",req:{index:{type:"list"}}},{fmt:"/_suggest"}]}),d.update=c({methods:["POST"],params:{consistency:{type:"enum",options:["one","quorum","all"]},fields:{type:"list"},lang:{type:"string"},parent:{type:"string"},percolate:{type:"string"},refresh:{type:"boolean"},replication:{type:"enum","default":"sync",options:["sync","async"]},retryOnConflict:{type:"number",name:"retry_on_conflict"},routing:{type:"string"},script:{},timeout:{type:"time"},timestamp:{type:"time"},ttl:{type:"duration"},version:{type:"number"},versionType:{type:"enum",options:["internal","external"],name:"version_type"}},urls:[{fmt:"/<%=index%>/<%=type%>/<%=id%>/_update",req:{index:{type:"string"},type:{type:"string"},id:{type:"string"}}}]})},{"./client_action":17,"./errors":22}],16:[function(a,b){function c(a){this.client=this,Object.defineProperty(this,"config",{configurable:!1,enumerable:!1,writable:!1,value:!a||d.isPlainObject(a)?new e(a):a}),this.config.client=this;for(var b=0;b1)this.config.selector(this.connections.alive,a);else try{d.nextTick(a,null,this.config.selector(this.connections.alive))}catch(b){this.config.log.error(b),a(b)}else a()},c.prototype.onStatusChanged=d.handler(function(a,b,c){var d,e,f;if(b===a)return!0;switch(this.config.log.info("connection id:",c.__id,"is",a),a){case"alive":d=this.connections.dead,e=this.connections.alive;break;case"dead":d=this.connections.alive,e=this.connections.dead;break;case"closed":d=this.connections[b]}d&&d.indexOf&&(f=d.indexOf(c),~f&&d.splice(f,1)),e&&e.indexOf&&(f=e.indexOf(c),~f||e.push(c))}),c.prototype._add=function(a){this.index[a.__id]||(this.index[a.__id]=a,a.on("status changed",this.bound.onStatusChanged),a.setStatus("alive"))},c.prototype._remove=function(a){this.index[a.__id]&&(delete this.index[a.__id],a.setStatus("closed"),a.removeListener("status changed",this.bound.onStatusChanged))},c.prototype.setNodes=function(a){var b,c,f,g,h=d.clone(this.index);for(c=0;ca?"0"+a.toString(10):a.toString(10)}function e(a,b){var c=f.repeat(" ",b||2);return a.split(/\r?\n/).map(function(a){return c+a}).join("\n")}var f=(a("./log"),a("./utils"));c.prototype.timestamp=function(){var a=new Date;return a.getUTCFullYear()+"-"+d(a.getUTCMonth()+1)+"-"+d(a.getUTCDate())+"T"+d(a.getUTCHours())+":"+d(a.getUTCMinutes())+":"+d(a.getUTCSeconds())+"Z"},c.prototype.format=function(a,b){return a+": "+this.timestamp()+"\n"+e(b)+"\n\n"},c.prototype.write=function(){throw new Error("This should be overwritten by the logger")},c.prototype.setupListeners=function(a){this.cleanUpListeners(),this.listeningLevels=a,f.each(this.listeningLevels,function(a){var b="on"+f.ucfirst(a);if(!this.bound[b])throw new Error(b+" is not a function");this.bridge.on(a,this.bound[b])},this)},c.prototype.cleanUpListeners=f.handler(function(){f.each(this.listeningLevels,function(a){this.bridge.removeListener(a,this.bound["on"+f.ucfirst(a)])},this)}),c.prototype.onError=f.handler(function(a){this.write("Error"===a.name?"ERROR":a.name,a.stack)}),c.prototype.onWarning=f.handler(function(a){this.write("WARNING",a)}),c.prototype.onInfo=f.handler(function(a){this.write("INFO",a)}),c.prototype.onDebug=f.handler(function(a){this.write("DEBUG",a)}),c.prototype.onTrace=f.handler(function(a,b,c,d,e){var f='curl "'+b.replace(/"/g,'\\"')+'" -X'+a.toUpperCase();c&&(f+=' -d "'+c.replace(/"/g,'\\"')+'"'),f+="\n<- "+e+"\n"+d,this.write("TRACE",f)}),b.exports=c},{"./log":24,"./utils":33}],26:[function(a,b){function c(a,b){d.call(this,a,b),this.color=e.has(a,"color")?!!a.color:!0}b.exports=c;var d=a("../logger"),e=a("../utils");e.inherits(c,d),c.prototype.setupListeners=function(a){this.bound.onWarning=this.onWarning,this.bound.onInfo=this.onInfo,this.bound.onDebug=this.onDebug,d.prototype.setupListeners.call(this,a)},c.prototype.onError=e.handler(function(a){console.error&&console.trace?console.error("Error"===a.name?"ERROR":a.name,a.stack||a.message):console.log("Error"===a.name?"ERROR":a.name,a.stack||a.message)}),c.prototype.onWarning=e.bindKey(console,console.warn?"warn":"log","WARNING"),c.prototype.onInfo=e.bindKey(console,console.info?"info":"log","INFO"),c.prototype.onDebug=e.bindKey(console,console.debug?"debug":"log","DEBUG"),c.prototype.onTrace=e.handler(function(a,b,c,d,e){var f='curl "'+b.replace(/"/g,'\\"')+'" -X'+a.toUpperCase();c&&(f+=' -d "'+c.replace(/"/g,'\\"')+'"'),f+="\n<- "+e+"\n"+d,console.log("TRACE:\n"+f+"\n\n")})},{"../logger":25,"../utils":33}],27:[function(a,b){b.exports={random:a("./random"),roundRobin:a("./round_robin")}},{"./random":28,"./round_robin":29}],28:[function(a,b){function c(a){return a[Math.floor(Math.random()*a.length)]}b.exports=c},{}],29:[function(a,b){function c(a){return a.unshift(a.pop()),a[0]}b.exports=c},{}],30:[function(a,b){function c(a){this.client=a}b.exports=c;var d=a("../utils");c.prototype.serialize=function(a,b,c){return null==a?null:"string"==typeof a?a:JSON.stringify(a,b,c)},c.prototype.unserialize=function(a){if("string"!=typeof a)return a;try{return JSON.parse(a)}catch(b){return this.client.log.error(new Error("unable to parse",a)),null}},c.prototype.bulkBody=function(a){var b,c="";if(d.isArray(a))for(b=0;bc||c>=300)&&!e.contains(h,c)&&(a=g[c]?new g[c](d&&d.error):new g.Generic("unknown error")),this._params.castExists&&(a&&a instanceof g.NotFound?(d=!1,a=void 0):d=!a),this._error=a,this._response={body:d,status:c},this.emit("done",this._error,this._response.body,this._response.status)}),c.prototype.abort=function(){return this.aborted=!0,this.__request?(this.__request.abort(),!0):!1},c.prototype.then=function(a,b){this._error?b(this._error):this._response?a(this._response):this.once("done",e.bindKey(this,"then",a,b))}},{"./errors":22,"./utils":33,__browserify_process:12,events:4}],33:[function(a,b){function c(a,b,c){return function(d){for(var e,f,g,h,i=0,j=[],k="";i=97&&122>=e,g=e>=65&&90>=e,(g||!h)&&(k.length&&j.push(k),k=""),(g||h)&&(h&&k.length?k+=f:k=!j.length&&a||j.length&&b?f.toUpperCase():f.toLowerCase());return k.length&&j.push(k),j.lenth&&"_"===d.charAt(0)&&(j[0]="_"+j[0]),j.join(c)}}var d=a("__browserify_process"),e=a("path"),f=a("lodash"),g=a("util"),h=f.extend({},f,g);f=h,h.inspect=function(a,b){return g.inspect(a,f.defaults(b||{},{showHidden:!0,depth:null,color:!0}))},h.joinPath=e.join,h.reKey=function(a,b,c){if(void 0===c&&(c=!0),"function"!=typeof b)throw new TypeError("invalid transform function");var d={};return f.each(a,function(a,e){d[b(e)]=c&&"object"==typeof a?h.reKey(a,b,c):a}),d},h.deepMerge=function(a,b){return Object.keys(b).forEach(function(c){switch(typeof a[c]){case"undefined":a[c]=b[c];break;case"object":f.isArray(a[c])&&f.isArray(b[c])?a[c]=a[c].concat(b[c]):f.isPlainObject(a[c])&&f.isPlainObject(b[c])&&h.deepMerge(a[c],b[c])}}),a},"String Object PlainObject Array Finite Function RegExp".split(" ").forEach(function(a){var b=f.bindKey(f,"is"+a);h["isArrayOf"+a+"s"]=function(a){return f.isArray(a)&&f.every(a.slice(0,10),b)}}),h.ucfirst=function(a){return a[0].toUpperCase()+a.substring(1).toLowerCase()},h.studlyCase=c(!0,!0,""),h.camelCase=c(!1,!0,""),h.snakeCase=c(!1,!1,"_"),h.toLowerString=function(a){return a?"string"!=typeof a&&(a=a.toString()):a="",a.toLowerCase()},h.toUpperString=function(a){return a?"string"!=typeof a&&(a=a.toString()):a="",a.toUpperCase()},h.isNumeric=function(a){return!isNaN(null===a?0/0:1*a)};var i=/^(\d+(?:\.\d+)?)([Mwdhmsy])$/;h.isInterval=function(a){return!(!a.match||!a.match(i))},h.repeat=function(a,b){return new Array(b+1).join(a)},h.inherits=function(a,b){g.inherits(a,b),a.callSuper=function(a,c){c?f.isArguments(c)?h.applyArgs(b,a,c):h.applyArgs(b,a,arguments,1):b.call(a)}},h.trim=function(a){return"string"==typeof a?a.replace(/^\s+|\s+$/g,""):""},h.collectMatches=function(a,b){for(var c,d=[];(c=b.exec(a))&&(d.push(c),b.global===!0););return d},h.applyArgs=function(a,b,c,d){switch(d=d||0,c.length-d){case 0:return a.call(b);case 1:return a.call(b,c[0+d]);case 2:return a.call(b,c[0+d],c[1+d]);case 3:return a.call(b,c[0+d],c[1+d],c[2+d]);case 4:return a.call(b,c[0+d],c[1+d],c[2+d],c[3+d]);case 5:return a.call(b,c[0+d],c[1+d],c[2+d],c[3+d],c[4+d]);default:return a.apply(b,Array.prototype.slice.call(c,d))}},f.nextTick=function(a){d.nextTick(f.bindKey(f,"applyArgs",a,null,arguments,1))},f.handler=function(a){return a._provideBound=!0,a},f.scheduled=f.handler,f.makeBoundMethods=function(a,b){if(a.bound={},b)f.each(b,function(b){a.bound[b]=f.bindKey(a,b)});else{b=[];for(var c in a)"function"==typeof a[c]&&a[c]._provideBound===!0&&(a.bound[c]=f.bind(a[c],a))}},f.noop=function(){},b.exports=h},{__browserify_process:12,lodash:13,path:5,util:8}]},{},[14])(14)}); \ No newline at end of file diff --git a/package.json b/package.json index c58cd8a84..ef80b97d2 100644 --- a/package.json +++ b/package.json @@ -7,29 +7,33 @@ "homepage": "https://github.com/elasticsearch/elasticsearch-js", "version": "0.0.1", "devDependencies": { - "grunt": "~0.4.0", - "grunt-contrib-jshint": "~0.6.0", - "grunt-contrib-nodeunit": "~0.2.0", - "js-yaml": "~2.1.0", - "mkdirp": "~0.3.5", - "moment": "~2.2.1", - "should": "~2.0.1", - "grunt-mocha-test": "~0.7.0", - "grunt-contrib-watch": "~0.5.3", - "expect.js": "~0.2.0", - "async": "~0.2.9", - "optimist": "~0.6.0", - "minimatch": "~0.2.12", - "browserify": "~2.35.0", - "grunt-browserify": "~1.2.9", - "grunt-contrib-clean": "~0.5.0", - "grunt-contrib-uglify": "~0.2.5" + "grunt": "*", + "grunt-contrib-jshint": "*", + "grunt-contrib-nodeunit": "*", + "js-yaml": "*", + "mkdirp": "*", + "moment": "*", + "should": "*", + "grunt-mocha-test": "*", + "grunt-contrib-watch": "*", + "expect.js": "*", + "async": "*", + "optimist": "*", + "minimatch": "*", + "browserify": "*", + "grunt-browserify": "*", + "grunt-contrib-clean": "*", + "grunt-contrib-uglify": "*", + "mocha": "*", + "grunt-mocha": "*", + "grunt-contrib-concat": "~0.3.0" }, "license": "Apache License", "dependencies": { - "cli-color": "~0.2.3", - "lodash": "~2.2.1", - "tar": "~0.1.18" + "cli-color": "*", + "lodash": "*", + "tar": "*", + "agentkeepalive": "*" }, "scripts": { "test": "grunt" diff --git a/scripts/generate/js_api/actions.js b/scripts/generate/js_api/actions.js index 255f74cc1..1037d0f51 100644 --- a/scripts/generate/js_api/actions.js +++ b/scripts/generate/js_api/actions.js @@ -35,9 +35,6 @@ function transformFile(entry) { var cmlKey = _.camelCase(key); if (cmlKey !== key) { param.name = key; - if (key.charAt(0) === '_') { - cmlKey = '_' + cmlKey; - } } note[cmlKey] = param; } diff --git a/scripts/generate/logs/index.js b/scripts/generate/logs/index.js index 27b8ffea8..5a1f33589 100644 --- a/scripts/generate/logs/index.js +++ b/scripts/generate/logs/index.js @@ -33,7 +33,6 @@ var es = require('../../../src/elasticsearch'), startingMoment = moment().startOf('day').subtract('days', days), endingMoment = moment().endOf('day').add('days', days), clientConfig = { - maxSockets: 1000, log: { level: 'error' } diff --git a/scripts/generate/yaml_tests/index.js b/scripts/generate/yaml_tests/index.js index 09b4837c0..ae04db0d3 100644 --- a/scripts/generate/yaml_tests/index.js +++ b/scripts/generate/yaml_tests/index.js @@ -4,29 +4,35 @@ */ var fs = require('fs'); var path = require('path'); -var mkdirp = require('mkdirp'); +var jsYaml = require('js-yaml'); var spec = require('../../get_spec'); var clean = require('../../clean'); +var _ = require('../../../src/lib/utils'); -var testDir = path.resolve(__dirname, '../../../test/integration/yaml_suite/tests'); +var testFile = path.resolve(__dirname, '../../../test/integration/yaml_suite/yaml_tests.json'); function download() { - clean(testDir); + var tests = {}; + + clean(testFile); spec.get('test/**/*.yaml') .on('entry', function (entry) { - entry.path = path.resolve(testDir, path.relative('test', entry.path)); - mkdirp.sync(path.dirname(entry.path)); - fs.writeFileSync(entry.path, entry.data, 'utf8'); + var filename = path.relative('test', entry.path); + var file = tests[filename] = []; + jsYaml.loadAll(entry.data, function (doc) { + file.push(doc); + }); }) .on('end', function () { - console.log('download yaml tests to', testDir); + fs.writeFileSync(testFile, JSON.stringify(tests, null, ' '), 'utf8'); + console.log('download yaml tests to', testFile); }); } try { - var stat = fs.statSync(testDir); - if (!stat.isDirectory() || stat.ctime < Date.now() - 86400000) { + var stat = fs.statSync(testFile); + if (!stat.isFile() || stat.ctime < Date.now() - 86400000) { download(); } } catch (e) { diff --git a/src/lib/api.js b/src/lib/api.js index df8a5410b..206faea2c 100644 --- a/src/lib/api.js +++ b/src/lib/api.js @@ -973,10 +973,9 @@ api.exists = ca({ * @param {String} params.preference - Specify the node or shard the operation should be performed on (default: random) * @param {String} params.q - Query in the Lucene query string syntax * @param {String} params.routing - Specific routing value - * @param {String} params.source - The URL-encoded query definition (instead of using the request body) - * @param {String|ArrayOfStrings|Boolean} params._source - True or false to return the _source field or not, or a list of fields to return - * @param {String|ArrayOfStrings|Boolean} params._sourceExclude - A list of fields to exclude from the returned _source field - * @param {String|ArrayOfStrings|Boolean} params._sourceInclude - A list of fields to extract and return from the _source field + * @param {String|ArrayOfStrings|Boolean} params.source - True or false to return the _source field or not, or a list of fields to return + * @param {String|ArrayOfStrings|Boolean} params.sourceExclude - A list of fields to exclude from the returned _source field + * @param {String|ArrayOfStrings|Boolean} params.sourceInclude - A list of fields to extract and return from the _source field * @param {String} params.id - The document ID * @param {String} params.index - The name of the index * @param {String} params.type - The type of the document @@ -1029,17 +1028,14 @@ api.explain = ca({ type: 'string' }, source: { - type: 'string' - }, - _source: { type: 'list', name: '_source' }, - _sourceExclude: { + sourceExclude: { type: 'list', name: '_source_exclude' }, - _sourceInclude: { + sourceInclude: { type: 'list', name: '_source_include' } @@ -1073,9 +1069,9 @@ api.explain = ca({ * @param {Boolean} params.realtime - Specify whether to perform the operation in realtime or search mode * @param {Boolean} params.refresh - Refresh the shard containing the document before performing the operation * @param {String} params.routing - Specific routing value - * @param {String|ArrayOfStrings|Boolean} params._source - True or false to return the _source field or not, or a list of fields to return - * @param {String|ArrayOfStrings|Boolean} params._sourceExclude - A list of fields to exclude from the returned _source field - * @param {String|ArrayOfStrings|Boolean} params._sourceInclude - A list of fields to extract and return from the _source field + * @param {String|ArrayOfStrings|Boolean} params.source - True or false to return the _source field or not, or a list of fields to return + * @param {String|ArrayOfStrings|Boolean} params.sourceExclude - A list of fields to exclude from the returned _source field + * @param {String|ArrayOfStrings|Boolean} params.sourceInclude - A list of fields to extract and return from the _source field * @param {String} params.id - The document ID * @param {String} params.index - The name of the index * @param {String} [params.type=_all] - The type of the document (use `_all` to fetch the first document matching the ID across all types) @@ -1103,15 +1099,15 @@ api.get = ca({ routing: { type: 'string' }, - _source: { + source: { type: 'list', name: '_source' }, - _sourceExclude: { + sourceExclude: { type: 'list', name: '_source_exclude' }, - _sourceInclude: { + sourceInclude: { type: 'list', name: '_source_include' } @@ -1984,6 +1980,63 @@ api.indices.prototype.getAliases = ca({ }); +/** + * Perform a [indices.getFieldMapping](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-get-field-mapping.html) request + * + * @param {Object} params - An object with parameters used to carry out this action + * @param {Boolean} params.includeDefaults - Whether the default mapping values should be returned as well + * @param {String|ArrayOfStrings|Boolean} params.index - A comma-separated list of index names + * @param {String|ArrayOfStrings|Boolean} params.type - A comma-separated list of document types + * @param {String|ArrayOfStrings|Boolean} params.field - A comma-separated list of fields + */ +api.indices.prototype.getFieldMapping = ca({ + methods: [ + 'GET' + ], + params: { + includeDefaults: { + type: 'boolean', + name: 'include_defaults' + } + }, + urls: [ + { + fmt: '/<%=index%>/<%=type%>/_mapping/field/<%=field%>', + req: { + index: { + type: 'list' + }, + type: { + type: 'list' + }, + field: { + type: 'list' + } + } + }, + { + fmt: '/<%=index%>/_mapping/field/<%=field%>', + req: { + index: { + type: 'list' + }, + field: { + type: 'list' + } + } + }, + { + fmt: '/_mapping/field/<%=field%>', + req: { + field: { + type: 'list' + } + } + } + ] +}); + + /** * Perform a [indices.getMapping](http://www.elasticsearch.org/guide/reference/api/admin-indices-get-mapping/) request * @@ -2867,9 +2920,9 @@ api.info = ca({ * @param {String} params.preference - Specify the node or shard the operation should be performed on (default: random) * @param {Boolean} params.realtime - Specify whether to perform the operation in realtime or search mode * @param {Boolean} params.refresh - Refresh the shard containing the document before performing the operation - * @param {String|ArrayOfStrings|Boolean} params._source - True or false to return the _source field or not, or a list of fields to return - * @param {String|ArrayOfStrings|Boolean} params._sourceExclude - A list of fields to exclude from the returned _source field - * @param {String|ArrayOfStrings|Boolean} params._sourceInclude - A list of fields to extract and return from the _source field + * @param {String|ArrayOfStrings|Boolean} params.source - True or false to return the _source field or not, or a list of fields to return + * @param {String|ArrayOfStrings|Boolean} params.sourceExclude - A list of fields to exclude from the returned _source field + * @param {String|ArrayOfStrings|Boolean} params.sourceInclude - A list of fields to extract and return from the _source field * @param {String} params.index - The name of the index * @param {String} params.type - The type of the document */ @@ -2891,15 +2944,15 @@ api.mget = ca({ refresh: { type: 'boolean' }, - _source: { + source: { type: 'list', name: '_source' }, - _sourceExclude: { + sourceExclude: { type: 'list', name: '_source_exclude' }, - _sourceInclude: { + sourceInclude: { type: 'list', name: '_source_include' } @@ -3208,10 +3261,9 @@ api.scroll = ca({ * @param {String} params.searchType - Search operation type * @param {Number} params.size - Number of hits to return (default: 10) * @param {String|ArrayOfStrings|Boolean} params.sort - A comma-separated list of : pairs - * @param {String} params.source - The URL-encoded request definition using the Query DSL (instead of using request body) - * @param {String|ArrayOfStrings|Boolean} params._source - True or false to return the _source field or not, or a list of fields to return - * @param {String|ArrayOfStrings|Boolean} params._sourceExclude - A list of fields to exclude from the returned _source field - * @param {String|ArrayOfStrings|Boolean} params._sourceInclude - A list of fields to extract and return from the _source field + * @param {String|ArrayOfStrings|Boolean} params.source - True or false to return the _source field or not, or a list of fields to return + * @param {String|ArrayOfStrings|Boolean} params.sourceExclude - A list of fields to exclude from the returned _source field + * @param {String|ArrayOfStrings|Boolean} params.sourceInclude - A list of fields to extract and return from the _source field * @param {String|ArrayOfStrings|Boolean} params.stats - Specific 'tag' of the request for logging and statistical purposes * @param {String} params.suggestField - Specify which field to use for suggestions * @param {String} [params.suggestMode=missing] - Specify suggest mode @@ -3307,17 +3359,14 @@ api.search = ca({ type: 'list' }, source: { - type: 'string' - }, - _source: { type: 'list', name: '_source' }, - _sourceExclude: { + sourceExclude: { type: 'list', name: '_source_exclude' }, - _sourceInclude: { + sourceInclude: { type: 'list', name: '_source_include' }, @@ -3450,7 +3499,7 @@ api.suggest = ca({ * @param {Date|Number} params.timestamp - Explicit timestamp for the document * @param {Duration} params.ttl - Expiration time for the document * @param {Number} params.version - Explicit version number for concurrency control - * @param {Number} params.versionType - Explicit version number for concurrency control + * @param {String} params.versionType - Specific version type * @param {String} params.id - Document ID * @param {String} params.index - The name of the index * @param {String} params.type - The type of the document @@ -3512,7 +3561,11 @@ api.update = ca({ type: 'number' }, versionType: { - type: 'number', + type: 'enum', + options: [ + 'internal', + 'external' + ], name: 'version_type' } }, diff --git a/src/lib/client_action.js b/src/lib/client_action.js index 19e12e9c7..e0975bfc3 100644 --- a/src/lib/client_action.js +++ b/src/lib/client_action.js @@ -64,10 +64,10 @@ var castType = { } }, time: function (param, val, name) { - if (val instanceof Date) { - return val.getTime(); - } else if (_.isNumeric(val)) { + if (typeof val === 'string' || _.isNumeric(val)) { return val; + } else if (val instanceof Date) { + return val.getTime(); } else { throw new TypeError('Invalid ' + name + ': expected some sort of time.'); } @@ -211,15 +211,17 @@ function exec(transport, spec, params, cb) { // build a key list on demand spec.paramKeys = _.keys(spec.params); } - var key, param; + var key, param, name; for (i = 0; i < spec.paramKeys.length; i++) { key = spec.paramKeys[i]; param = spec.params[key]; + // param keys don't always match the param name, in those cases it's stored in the param def as "name" + name = param.name || key; try { if (params[key] != null) { - query[key] = castType[param.type] ? castType[param.type](param, params[key], key) : params[key]; - if (param['default'] && query[key] === param['default']) { - delete query[key]; + query[name] = castType[param.type] ? castType[param.type](param, params[key], key) : params[key]; + if (param['default'] && query[name] === param['default']) { + delete query[name]; } } else if (param.required) { throw new TypeError('Missing required parameter ' + key); diff --git a/src/lib/connectors/angular.js b/src/lib/connectors/angular.js index efa35ca36..8d7b7bc23 100644 --- a/src/lib/connectors/angular.js +++ b/src/lib/connectors/angular.js @@ -4,7 +4,7 @@ * * @class connections.Angular */ -module.exports = AngularConnection; +module.exports = AngularConnector; var _ = require('../utils'); var ConnectionAbstract = require('../connection'); @@ -12,12 +12,12 @@ var ConnectionFault = require('../errors').ConnectionFault; /* global angular */ -function AngularConnection(host, config) { +function AngularConnector(host, config) { ConnectionAbstract.call(this, host, config); } -_.inherits(AngularConnection, ConnectionAbstract); +_.inherits(AngularConnector, ConnectionAbstract); -AngularConnection.prototype.request = function (params, cb) { +AngularConnector.prototype.request = function (params, cb) { var timeoutId; this.$http({ @@ -35,4 +35,4 @@ AngularConnection.prototype.request = function (params, cb) { }; // must be overwritten before this connection can be used -AngularConnection.prototype.$http = null; +AngularConnector.prototype.$http = null; diff --git a/src/lib/connectors/http.js b/src/lib/connectors/http.js index a04a1b4fb..8172c0b59 100644 --- a/src/lib/connectors/http.js +++ b/src/lib/connectors/http.js @@ -4,48 +4,48 @@ * @param client {Client} - The Client that this class belongs to * @param config {Object} - Configuration options * @param [config.protocol=http:] {String} - The HTTP protocol that this connection will use, can be set to https: - * @class HttpConnection + * @class HttpConnector */ -module.exports = HttpConnection; +module.exports = HttpConnector; var http = require('http'); var https = require('https'); var _ = require('../utils'); var errors = require('../errors'); var qs = require('querystring'); +var KeepAliveAgent = require('agentkeepalive/lib/agent'); var ConnectionAbstract = require('../connection'); var defaultHeaders = { 'connection': 'keep-alive' }; -function HttpConnection(host, config) { +function HttpConnector(host, config) { ConnectionAbstract.call(this, host, config); - this.agent = new http.Agent({ - keepAlive: true, - // delay between the last data packet received and the first keepalive probe - keepAliveMsecs: 1000, + this.hand = require(this.host.protocol); + this.agent = new KeepAliveAgent({ maxSockets: 1, - maxFreeSockets: this.config.maxFreeSockets + maxKeepAliveRequests: 0, // max requests per keepalive socket, default is 0, no limit. + maxKeepAliveTime: 30000 // keepalive for 30 seconds }); this.on('closed', this.bound.onClosed); - this.once('alive', this.bound.onAlive); + this.on('alive', this.bound.onAlive); } -_.inherits(HttpConnection, ConnectionAbstract); +_.inherits(HttpConnector, ConnectionAbstract); -HttpConnection.prototype.onClosed = _.handler(function () { +HttpConnector.prototype.onClosed = _.handler(function () { this.agent.destroy(); this.removeAllListeners(); }); -HttpConnection.prototype.onAlive = _.handler(function () { +HttpConnector.prototype.onAlive = _.handler(function () { // only set the agents max agents config once the connection is verified to be alive this.agent.maxSockets = this.config.maxSockets; }); -HttpConnection.prototype.makeReqParams = function (params) { +HttpConnector.prototype.makeReqParams = function (params) { var reqParams = { method: params.method, protocol: this.host.protocol + ':', @@ -56,14 +56,31 @@ HttpConnection.prototype.makeReqParams = function (params) { headers: this.host.headers, agent: this.agent }; + var query = this.host.query ? this.host.query : null; + var queryStr; + if (typeof query === 'string') { + query = qs.parse(query); + } - var query = qs.stringify(this.host.query ? _.defaults(params.query, this.host.query) : params.query); - reqParams.path += query ? '?' + query : ''; + if (params.query) { + query = _.defaults({}, + typeof params.query === 'string' ? qs.parse(params.query) : params.query, + query || {} + ); + } + + if (query) { + queryStr = qs.stringify(query); + } + + if (queryStr) { + reqParams.path = reqParams.path + '?' + queryStr; + } return reqParams; }; -HttpConnection.prototype.request = function (params, cb) { +HttpConnector.prototype.request = function (params, cb) { var incoming; var timeoutId; var request; @@ -78,7 +95,7 @@ HttpConnection.prototype.request = function (params, cb) { // general clean-up procedure to run after the request // completes, has an error, or is aborted. - var cleanUp = function (err) { + var cleanUp = _.bind(function (err) { clearTimeout(timeoutId); request && request.removeAllListeners(); @@ -88,22 +105,14 @@ HttpConnection.prototype.request = function (params, cb) { err = void 0; } else { log.error(err); - - if (err instanceof errors.RequestTimeout) { - request.on('error', function catchAbortError() { - request.removeListener('error', catchAbortError); - }); - } else { - this.setStatus('dead'); - } + this.setStatus('dead'); } log.trace(params.method, reqParams, params.body, response, status); cb(err, response, status); - }; + }, this); - - request = http.request(reqParams, function (_incoming) { + request = this.hand.request(reqParams, function (_incoming) { incoming = _incoming; status = incoming.statusCode; incoming.setEncoding('utf8'); diff --git a/src/lib/connectors/jquery.js b/src/lib/connectors/jquery.js index 2ec541b4a..10e58af45 100644 --- a/src/lib/connectors/jquery.js +++ b/src/lib/connectors/jquery.js @@ -5,11 +5,11 @@ * * @class {XhrConnection} */ -module.exports = JqueryConnection; +module.exports = JqueryConnector; -function JqueryConnection() {} +function JqueryConnector() {} -JqueryConnection.prototype.request = function (params, cb) { +JqueryConnector.prototype.request = function (params, cb) { var $xhr = jQuery.ajax(params).done(cb); }; diff --git a/src/lib/connectors/xhr.js b/src/lib/connectors/xhr.js index 43943005f..618686e03 100644 --- a/src/lib/connectors/xhr.js +++ b/src/lib/connectors/xhr.js @@ -3,7 +3,7 @@ * * @class connections.Xhr */ -module.exports = XhrConnection; +module.exports = XhrConnector; /* jshint browser:true */ @@ -11,11 +11,12 @@ var _ = require('../utils'); var ConnectionAbstract = require('../connection'); var ConnectionFault = require('../errors').ConnectionFault; var TimeoutError = require('../errors').RequestTimeout; +var asyncDefault = !(navigator && /PhantomJS/i.test(navigator.userAgent)); -function XhrConnection(host, config) { +function XhrConnector(host, config) { ConnectionAbstract.call(this, host, config); } -_.inherits(XhrConnection, ConnectionAbstract); +_.inherits(XhrConnector, ConnectionAbstract); /** * Simply returns an XHR object cross browser @@ -46,30 +47,36 @@ if (!getXhr) { throw new Error('getXhr(): XMLHttpRequest not available'); } -XhrConnection.prototype.request = function (params, cb) { +XhrConnector.prototype.request = function (params, cb) { var xhr = getXhr(); + var timeout = params.timeout ? params.timeout : 10000; var timeoutId; var url = this.host.makeUrl(params); + var log = this.config.log; + var async = params.async === false ? false : asyncDefault; + if (params.auth) { - xhr.open(params.method, url, true, params.auth.user, params.auth.pass); + xhr.open(params.method, url, async, params.auth.user, params.auth.pass); } else { - xhr.open(params.method, url, true); + xhr.open(params.method, url, async); } xhr.onreadystatechange = function (e) { if (xhr.readyState === 4) { clearTimeout(timeoutId); - cb(xhr.status ? null : new ConnectionFault(), xhr.responseText, xhr.status); + log.trace(params.method, url, params.body, xhr.responseText, xhr.status); + var err = xhr.status ? void 0 : new ConnectionFault(xhr.statusText || 'Request failed to complete.'); + cb(err, xhr.responseText, xhr.status); } }; - if (params.timeout !== Infinity) { + if (timeout !== Infinity) { timeoutId = setTimeout(function () { xhr.onreadystatechange = _.noop; xhr.abort(); cb(new TimeoutError()); - }, params.timeout); + }, timeout); } - xhr.send(params.body || null); + xhr.send(params.body || void 0); }; diff --git a/src/lib/errors.js b/src/lib/errors.js index 19a94a887..bdcd852b9 100644 --- a/src/lib/errors.js +++ b/src/lib/errors.js @@ -5,7 +5,11 @@ function ErrorAbstract(msg, constructor) { this.message = msg; Error.call(this, this.message); - Error.captureStackTrace(this, constructor); + if (process.browser) { + this.stack = ''; + } else { + Error.captureStackTrace(this, constructor); + } } _.inherits(ErrorAbstract, Error); diff --git a/src/lib/host.js b/src/lib/host.js index ddbde889c..8fb50490e 100644 --- a/src/lib/host.js +++ b/src/lib/host.js @@ -87,10 +87,6 @@ Host.prototype.makeUrl = function (params) { // just stringify the hosts query query = qs.stringify(this.query); } - // prepend the ? if there is actually a valid query string - if (query) { - query = '?' + query; - } - return this.protocol + '://' + this.host + port + path + query; + return this.protocol + '://' + this.host + port + path + (query ? '?' + query : ''); }; diff --git a/src/lib/log.js b/src/lib/log.js index 225e51f8a..b2b1cdb73 100755 --- a/src/lib/log.js +++ b/src/lib/log.js @@ -246,7 +246,7 @@ Log.prototype.info = function (/* ...msg */) { */ Log.prototype.debug = function (/* ...msg */) { if (EventEmitter.listenerCount(this, 'debug')) { - return this.emit('debug', Log.join(arguments) + _.getStackTrace(Log.prototype.debug)); + return this.emit('debug', Log.join(arguments) /*+ _.getStackTrace(Log.prototype.debug)*/); } }; @@ -264,10 +264,17 @@ Log.prototype.debug = function (/* ...msg */) { */ Log.prototype.trace = function (method, requestUrl, body, responseBody, responseStatus) { if (EventEmitter.listenerCount(this, 'trace')) { - if (typeof requestUrl === 'object') { - requestUrl = url.format(requestUrl); + if (typeof requestUrl === 'string') { + requestUrl = url.parse(requestUrl, true, true); } - return this.emit('trace', method, requestUrl, body, responseBody, responseStatus); + requestUrl = _.defaults({ + host: 'localhost:9200', + query: _.defaults({ + pretty: true + }, requestUrl.query) + }, requestUrl); + delete requestUrl.auth; + return this.emit('trace', method, url.format(requestUrl), body, responseBody, responseStatus); } }; diff --git a/src/lib/loggers/console.js b/src/lib/loggers/console.js index f6f77c185..7e65b29a5 100644 --- a/src/lib/loggers/console.js +++ b/src/lib/loggers/console.js @@ -49,10 +49,9 @@ Console.prototype.setupListeners = function (levels) { */ Console.prototype.onError = _.handler(function (e) { if (console.error && console.trace) { - console.error(e.name === 'Error' ? 'ERROR' : e.name); - console.trace(); + console.error(e.name === 'Error' ? 'ERROR' : e.name, e.stack || e.message); } else { - console.log(e.name === 'Error' ? 'ERROR' : e.name, e.stack); + console.log(e.name === 'Error' ? 'ERROR' : e.name, e.stack || e.message); } }); @@ -64,7 +63,7 @@ Console.prototype.onError = _.handler(function (e) { * @param {String} msg - The message to be logged * @return {undefined} */ -Console.prototype.onWarning = console[console.warn ? 'warn' : 'log'].bind(console, 'WARNING'); +Console.prototype.onWarning = _.bindKey(console, console.warn ? 'warn' : 'log', 'WARNING'); /** * Handler for the bridges "info" event @@ -74,7 +73,7 @@ Console.prototype.onWarning = console[console.warn ? 'warn' : 'log'].bind(consol * @param {String} msg - The message to be logged * @return {undefined} */ -Console.prototype.onInfo = console[console.info ? 'info' : 'log'].bind(console, 'INFO'); +Console.prototype.onInfo = _.bindKey(console, console.info ? 'info' : 'log', 'INFO'); /** * Handler for the bridges "debug" event @@ -84,7 +83,7 @@ Console.prototype.onInfo = console[console.info ? 'info' : 'log'].bind(console, * @param {String} msg - The message to be logged * @return {undefined} */ -Console.prototype.onDebug = console[console.debug ? 'debug' : 'log'].bind(console, 'DEBUG'); +Console.prototype.onDebug = _.bindKey(console, console.debug ? 'debug' : 'log', 'DEBUG'); /** * Handler for the bridges "trace" event @@ -99,5 +98,5 @@ Console.prototype.onTrace = _.handler(function (method, url, body, responseBody, message += ' -d "' + body.replace(/"/g, '\\"') + '"'; } message += '\n<- ' + responseStatus + '\n' + responseBody; - console.log('TRACE', message); + console.log('TRACE:\n' + message + '\n\n'); }); diff --git a/src/lib/transport_request.js b/src/lib/transport_request.js index e4b50d326..48226aeaf 100644 --- a/src/lib/transport_request.js +++ b/src/lib/transport_request.js @@ -71,7 +71,7 @@ TransportRequest.prototype._sendReqWithCon = _.handler(function (err, con) { TransportRequest.prototype._checkRespForFail = _.handler(function (err, body, status) { if (err && this._remainingRetries) { this._remainingRetries--; - this._log.info('Connection error, retrying'); + this._log.error(err.message, '-- retrying'); this._connectionPool.select(this.bound._sendReqWithCon); } else { this._log.info('Request complete'); diff --git a/src/lib/utils.js b/src/lib/utils.js index 175ec2732..22b2df88e 100644 --- a/src/lib/utils.js +++ b/src/lib/utils.js @@ -156,6 +156,10 @@ function adjustWordCase(firstWordCap, otherWordsCap, sep) { if (word.length) { words.push(word); } + // add the leading underscore back to strings the had it originally + if (words.lenth && string.charAt(0) === '_') { + words[0] = '_' + words[0]; + } return words.join(sep); }; } @@ -409,10 +413,15 @@ _.makeBoundMethods = function (obj, methods) { _.noop = function () {}; -_.getStackTrace = function (callee) { - var e = {}; - Error.captureStackTrace(e, callee || _.getStackTrace); - return '\n' + e.stack.split('\n').slice(1).join('\n'); -}; +// _.getStackTrace = function (callee) { +// var e = {}; +// if (typeof Error.captureStackTrace === 'function') { +// Error.captureStackTrace(e, callee || _.getStackTrace); +// } else { +// e.stack = (new Error()).stack; +// console.log(e.stack); +// } +// return '\n' + e.stack.split('\n').slice(1).join('\n'); +// }; module.exports = utils; diff --git a/test/.jshintrc b/test/.jshintrc index e61e19958..a49cab70f 100644 --- a/test/.jshintrc +++ b/test/.jshintrc @@ -34,6 +34,7 @@ "before": true, "after": true, "it": true, - "beforeEach": true + "beforeEach": true, + "afterEach": true } } diff --git a/test/browser_integration/index.html b/test/browser_integration/index.html new file mode 100644 index 000000000..6ef70ce92 --- /dev/null +++ b/test/browser_integration/index.html @@ -0,0 +1,22 @@ + + + + Mocha Tests + + + +
+ + + + + + + + diff --git a/test/browser_integration/server.js b/test/browser_integration/server.js new file mode 100644 index 000000000..c81504132 --- /dev/null +++ b/test/browser_integration/server.js @@ -0,0 +1,146 @@ +var http = require('http'); +var url = require('url'); +var path = require('path'); +var fs = require('fs'); +var browserify = require('browserify'); +var port = process.argv[2] || 8888; + +var middleware = []; + +Error.stackTraceLimit = Infinity; + +function sendBundle(req, resp, files, opts, extend) { + resp.setHeader('Content-Type', 'application/javascript'); + resp.writeHead(200); + + var b = browserify(files); + + if (typeof extend === 'function') { + extend(b); + } + + var out = b.bundle(opts); + + out.on('data', function (chunk) { + resp.write(chunk); + }); + + out.on('end', function () { + resp.end(); + }); +} + +var server = http.createServer(function (req, resp) { + req.uri = url.parse(req.url).pathname; + req.filename = path.join(__dirname, req.uri); + + resp._end = resp.end; + resp.end = function () { + console.log(this.statusCode, req.uri); + resp._end.apply(resp, arguments); + }; + + var middleIndex = -1; + + function next() { + middleIndex++; + if (middleIndex < middleware.length) { + middleware[middleIndex](req, resp, next); + } else { + resp.writeHead(500); + resp.end('500 Bad Gateway\n'); + } + } + next(); +}); + +middleware.push(function (req, resp, next) { + // resolve filenames + switch (req.uri) { + case '/expect.js': + req.filename = path.join(__dirname, '../../node_modules/expect.js/expect.js'); + break; + case '/mocha.js': + case '/mocha.css': + req.filename = path.join(__dirname, '../../node_modules/mocha', req.uri); + break; + case '/client.js': + req.filename = path.join(__dirname, '../../dist/elasticsearch.js'); + break; + } + next(); +}); + +middleware.push(function (req, resp, next) { + // catch 404's, add directory's index.html + fs.stat(req.filename, function (err, stats) { + if (err) { + resp.writeHead(404, {'Content-Type': 'text/plain'}); + resp.write('404 Not Found\n'); + resp.end(); + } else { + if (stats.isDirectory()) { + req.filename = path.join(req.filename, './index.html'); + } + next(); + } + }); +}); + +middleware.push(function (req, resp, next) { + // static files + var reader = fs.createReadStream(req.filename); + var data = ''; + + reader.on('data', onData); + reader.on('error', onError); + reader.on('end', onEnd); + + function cleanupListeners() { + reader.removeListener('end', onEnd); + reader.removeListener('data', onData); + reader.removeListener('error', onError); + } + + function onData(chunk) { + data += chunk; + } + + function onError(err) { + cleanupListeners(); + console.error(err); + resp.setHeader('Content-Type', 'text/plain'); + resp.writeHead(500); + resp.write(err.message + '\n'); + resp.end(); + } + + function onEnd() { + cleanupListeners(); + var contentType = 'text/plain'; + + switch (req.filename.split('.').pop()) { + case 'js': + contentType = 'application/javascript'; + break; + case 'css': + contentType = 'text/css'; + break; + case 'html': + contentType = 'text/html'; + break; + } + + resp.setHeader('Content-Type', contentType); + resp.writeHead(200); + resp.end( + data + .replace(/\{\{ts\}\}/g, Date.now()) + .replace(/\{\{phantom\}\}/g, req.filename === '/phantom.html' ? '-phantom' : '') + ); + } +}); + +server.listen(parseInt(port, 10), function () { + console.log('server listening on port', server.address().port); +}); diff --git a/test/browser_integration/yaml_tests.js b/test/browser_integration/yaml_tests.js new file mode 100644 index 000000000..8df75215e --- /dev/null +++ b/test/browser_integration/yaml_tests.js @@ -0,0 +1,45998 @@ +;(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o + * MIT Licensed + */ + +"use strict"; + +/** + * Module dependencies. + */ + +var http = require('http'); +var https = require('https'); +var util = require('util'); + +var debug; +if (process.env.NODE_DEBUG && /agentkeepalive/.test(process.env.NODE_DEBUG)) { + debug = function (x) { + console.error('agentkeepalive:', x); + }; +} else { + debug = function () { }; +} + +function Agent(options) { + options = options || {}; + http.Agent.call(this, options); + + var self = this; + // max requests per keepalive socket, default is 0, no limit. + self.maxKeepAliveRequests = parseInt(options.maxKeepAliveRequests, 10) || 0; + // max keep alive time, default 60 seconds. + // if set `maxKeepAliveTime = 0`, will disable keepalive feature. + self.maxKeepAliveTime = parseInt(options.maxKeepAliveTime, 10); + if (isNaN(self.maxKeepAliveTime)) { + self.maxKeepAliveTime = 60000; + } + self.unusedSockets = {}; + self.createSocketCount = 0; + self.timeoutSocketCount = 0; + self.requestFinishedCount = 0; + + // override the `free` event listener + self.removeAllListeners('free'); + self.on('free', function (socket, host, port, localAddress) { + self.requestFinishedCount++; + socket._requestCount++; + var name = host + ':' + port; + if (localAddress) { + name += ':' + localAddress; + } + if (self.requests[name] && self.requests[name].length > 0) { + self.requests[name].shift().onSocket(socket); + if (self.requests[name].length === 0) { + // don't leak + delete self.requests[name]; + } + } else { + // If there are no pending requests just destroy the + // socket and it will get removed from the pool. This + // gets us out of timeout issues and allows us to + // default to Connection:keep-alive. + // socket.destroy(); + if (self.maxKeepAliveTime === 0 || + (self.maxKeepAliveRequests && socket._requestCount >= self.maxKeepAliveRequests)) { + socket.destroy(); + return; + } + + // Avoid duplicitive timeout events by removing timeout listeners set on + // socket by previous requests. node does not do this normally because it + // assumes sockets are too short-lived for it to matter. It becomes a + // problem when sockets are being reused. Steps are being taken to fix + // this issue upstream in node v0.10.0. + // + // See https://github.com/joyent/node/commit/451ff1540ab536237e8d751d241d7fc3391a4087 + if (self.maxKeepAliveTime && socket._events && Array.isArray(socket._events.timeout)) { + socket.removeAllListeners('timeout'); + // Restore the socket's setTimeout() that was remove as collateral + // damage. + socket.setTimeout(self.maxKeepAliveTime, socket._maxKeepAliveTimeout); + } + // keepalive + if (!self.unusedSockets[name]) { + self.unusedSockets[name] = []; + } + self.unusedSockets[name].push(socket); + } + }); +} + +util.inherits(Agent, http.Agent); +module.exports = Agent; + +Agent.prototype.addRequest = function (req, host, port, localAddress) { + var name = host + ':' + port; + if (localAddress) { + name += ':' + localAddress; + } + if (this.unusedSockets[name] && this.unusedSockets[name].length > 0) { + return req.onSocket(this.unusedSockets[name].shift()); + } + return http.Agent.prototype.addRequest.call(this, req, host, port, localAddress); +}; + +Agent.prototype.createSocket = function (name, host, port, localAddress, req) { + var self = this; + var socket = http.Agent.prototype.createSocket.call(this, name, host, port, localAddress, req); + socket._requestCount = 0; + if (self.maxKeepAliveTime) { + socket._maxKeepAliveTimeout = function () { + socket.destroy(); + self.timeoutSocketCount++; + }; + socket.setTimeout(self.maxKeepAliveTime, socket._maxKeepAliveTimeout); + // Disable Nagle's algorithm: http://blog.caustik.com/2012/04/08/scaling-node-js-to-100k-concurrent-connections/ + socket.setNoDelay(true); + } + this.createSocketCount++; + return socket; +}; + +Agent.prototype.removeSocket = function (socket, name, host, port, localAddress) { + if (this.unusedSockets[name]) { + var unusedIndex = this.unusedSockets[name].indexOf(socket); + if (unusedIndex !== -1) { + this.unusedSockets[name].splice(unusedIndex, 1); + if (this.unusedSockets[name].length === 0) { + // don't leak + delete this.unusedSockets[name]; + } + } + } + return http.Agent.prototype.removeSocket.call(this, socket, name, host, port, localAddress); +}; + +function HttpsAgent(options) { + Agent.call(this, options); + this.createConnection = https.globalAgent.createConnection; +} +util.inherits(HttpsAgent, Agent); +HttpsAgent.prototype.defaultPort = 443; + +Agent.HttpsAgent = HttpsAgent; + +},{"__browserify_process":91,"http":72,"https":60,"util":68}],2:[function(require,module,exports){ +var process=require("__browserify_process");/*global setImmediate: false, setTimeout: false, console: false */ +(function () { + + var async = {}; + + // global on the server, window in the browser + var root, previous_async; + + root = this; + if (root != null) { + previous_async = root.async; + } + + async.noConflict = function () { + root.async = previous_async; + return async; + }; + + function only_once(fn) { + var called = false; + return function() { + if (called) throw new Error("Callback was already called."); + called = true; + fn.apply(root, arguments); + } + } + + //// cross-browser compatiblity functions //// + + var _each = function (arr, iterator) { + if (arr.forEach) { + return arr.forEach(iterator); + } + for (var i = 0; i < arr.length; i += 1) { + iterator(arr[i], i, arr); + } + }; + + var _map = function (arr, iterator) { + if (arr.map) { + return arr.map(iterator); + } + var results = []; + _each(arr, function (x, i, a) { + results.push(iterator(x, i, a)); + }); + return results; + }; + + var _reduce = function (arr, iterator, memo) { + if (arr.reduce) { + return arr.reduce(iterator, memo); + } + _each(arr, function (x, i, a) { + memo = iterator(memo, x, i, a); + }); + return memo; + }; + + var _keys = function (obj) { + if (Object.keys) { + return Object.keys(obj); + } + var keys = []; + for (var k in obj) { + if (obj.hasOwnProperty(k)) { + keys.push(k); + } + } + return keys; + }; + + //// exported async module functions //// + + //// nextTick implementation with browser-compatible fallback //// + if (typeof process === 'undefined' || !(process.nextTick)) { + if (typeof setImmediate === 'function') { + async.nextTick = function (fn) { + // not a direct alias for IE10 compatibility + setImmediate(fn); + }; + async.setImmediate = async.nextTick; + } + else { + async.nextTick = function (fn) { + setTimeout(fn, 0); + }; + async.setImmediate = async.nextTick; + } + } + else { + async.nextTick = process.nextTick; + if (typeof setImmediate !== 'undefined') { + async.setImmediate = setImmediate; + } + else { + async.setImmediate = async.nextTick; + } + } + + async.each = function (arr, iterator, callback) { + callback = callback || function () {}; + if (!arr.length) { + return callback(); + } + var completed = 0; + _each(arr, function (x) { + iterator(x, only_once(function (err) { + if (err) { + callback(err); + callback = function () {}; + } + else { + completed += 1; + if (completed >= arr.length) { + callback(null); + } + } + })); + }); + }; + async.forEach = async.each; + + async.eachSeries = function (arr, iterator, callback) { + callback = callback || function () {}; + if (!arr.length) { + return callback(); + } + var completed = 0; + var iterate = function () { + iterator(arr[completed], function (err) { + if (err) { + callback(err); + callback = function () {}; + } + else { + completed += 1; + if (completed >= arr.length) { + callback(null); + } + else { + iterate(); + } + } + }); + }; + iterate(); + }; + async.forEachSeries = async.eachSeries; + + async.eachLimit = function (arr, limit, iterator, callback) { + var fn = _eachLimit(limit); + fn.apply(null, [arr, iterator, callback]); + }; + async.forEachLimit = async.eachLimit; + + var _eachLimit = function (limit) { + + return function (arr, iterator, callback) { + callback = callback || function () {}; + if (!arr.length || limit <= 0) { + return callback(); + } + var completed = 0; + var started = 0; + var running = 0; + + (function replenish () { + if (completed >= arr.length) { + return callback(); + } + + while (running < limit && started < arr.length) { + started += 1; + running += 1; + iterator(arr[started - 1], function (err) { + if (err) { + callback(err); + callback = function () {}; + } + else { + completed += 1; + running -= 1; + if (completed >= arr.length) { + callback(); + } + else { + replenish(); + } + } + }); + } + })(); + }; + }; + + + var doParallel = function (fn) { + return function () { + var args = Array.prototype.slice.call(arguments); + return fn.apply(null, [async.each].concat(args)); + }; + }; + var doParallelLimit = function(limit, fn) { + return function () { + var args = Array.prototype.slice.call(arguments); + return fn.apply(null, [_eachLimit(limit)].concat(args)); + }; + }; + var doSeries = function (fn) { + return function () { + var args = Array.prototype.slice.call(arguments); + return fn.apply(null, [async.eachSeries].concat(args)); + }; + }; + + + var _asyncMap = function (eachfn, arr, iterator, callback) { + var results = []; + arr = _map(arr, function (x, i) { + return {index: i, value: x}; + }); + eachfn(arr, function (x, callback) { + iterator(x.value, function (err, v) { + results[x.index] = v; + callback(err); + }); + }, function (err) { + callback(err, results); + }); + }; + async.map = doParallel(_asyncMap); + async.mapSeries = doSeries(_asyncMap); + async.mapLimit = function (arr, limit, iterator, callback) { + return _mapLimit(limit)(arr, iterator, callback); + }; + + var _mapLimit = function(limit) { + return doParallelLimit(limit, _asyncMap); + }; + + // reduce only has a series version, as doing reduce in parallel won't + // work in many situations. + async.reduce = function (arr, memo, iterator, callback) { + async.eachSeries(arr, function (x, callback) { + iterator(memo, x, function (err, v) { + memo = v; + callback(err); + }); + }, function (err) { + callback(err, memo); + }); + }; + // inject alias + async.inject = async.reduce; + // foldl alias + async.foldl = async.reduce; + + async.reduceRight = function (arr, memo, iterator, callback) { + var reversed = _map(arr, function (x) { + return x; + }).reverse(); + async.reduce(reversed, memo, iterator, callback); + }; + // foldr alias + async.foldr = async.reduceRight; + + var _filter = function (eachfn, arr, iterator, callback) { + var results = []; + arr = _map(arr, function (x, i) { + return {index: i, value: x}; + }); + eachfn(arr, function (x, callback) { + iterator(x.value, function (v) { + if (v) { + results.push(x); + } + callback(); + }); + }, function (err) { + callback(_map(results.sort(function (a, b) { + return a.index - b.index; + }), function (x) { + return x.value; + })); + }); + }; + async.filter = doParallel(_filter); + async.filterSeries = doSeries(_filter); + // select alias + async.select = async.filter; + async.selectSeries = async.filterSeries; + + var _reject = function (eachfn, arr, iterator, callback) { + var results = []; + arr = _map(arr, function (x, i) { + return {index: i, value: x}; + }); + eachfn(arr, function (x, callback) { + iterator(x.value, function (v) { + if (!v) { + results.push(x); + } + callback(); + }); + }, function (err) { + callback(_map(results.sort(function (a, b) { + return a.index - b.index; + }), function (x) { + return x.value; + })); + }); + }; + async.reject = doParallel(_reject); + async.rejectSeries = doSeries(_reject); + + var _detect = function (eachfn, arr, iterator, main_callback) { + eachfn(arr, function (x, callback) { + iterator(x, function (result) { + if (result) { + main_callback(x); + main_callback = function () {}; + } + else { + callback(); + } + }); + }, function (err) { + main_callback(); + }); + }; + async.detect = doParallel(_detect); + async.detectSeries = doSeries(_detect); + + async.some = function (arr, iterator, main_callback) { + async.each(arr, function (x, callback) { + iterator(x, function (v) { + if (v) { + main_callback(true); + main_callback = function () {}; + } + callback(); + }); + }, function (err) { + main_callback(false); + }); + }; + // any alias + async.any = async.some; + + async.every = function (arr, iterator, main_callback) { + async.each(arr, function (x, callback) { + iterator(x, function (v) { + if (!v) { + main_callback(false); + main_callback = function () {}; + } + callback(); + }); + }, function (err) { + main_callback(true); + }); + }; + // all alias + async.all = async.every; + + async.sortBy = function (arr, iterator, callback) { + async.map(arr, function (x, callback) { + iterator(x, function (err, criteria) { + if (err) { + callback(err); + } + else { + callback(null, {value: x, criteria: criteria}); + } + }); + }, function (err, results) { + if (err) { + return callback(err); + } + else { + var fn = function (left, right) { + var a = left.criteria, b = right.criteria; + return a < b ? -1 : a > b ? 1 : 0; + }; + callback(null, _map(results.sort(fn), function (x) { + return x.value; + })); + } + }); + }; + + async.auto = function (tasks, callback) { + callback = callback || function () {}; + var keys = _keys(tasks); + if (!keys.length) { + return callback(null); + } + + var results = {}; + + var listeners = []; + var addListener = function (fn) { + listeners.unshift(fn); + }; + var removeListener = function (fn) { + for (var i = 0; i < listeners.length; i += 1) { + if (listeners[i] === fn) { + listeners.splice(i, 1); + return; + } + } + }; + var taskComplete = function () { + _each(listeners.slice(0), function (fn) { + fn(); + }); + }; + + addListener(function () { + if (_keys(results).length === keys.length) { + callback(null, results); + callback = function () {}; + } + }); + + _each(keys, function (k) { + var task = (tasks[k] instanceof Function) ? [tasks[k]]: tasks[k]; + var taskCallback = function (err) { + var args = Array.prototype.slice.call(arguments, 1); + if (args.length <= 1) { + args = args[0]; + } + if (err) { + var safeResults = {}; + _each(_keys(results), function(rkey) { + safeResults[rkey] = results[rkey]; + }); + safeResults[k] = args; + callback(err, safeResults); + // stop subsequent errors hitting callback multiple times + callback = function () {}; + } + else { + results[k] = args; + async.setImmediate(taskComplete); + } + }; + var requires = task.slice(0, Math.abs(task.length - 1)) || []; + var ready = function () { + return _reduce(requires, function (a, x) { + return (a && results.hasOwnProperty(x)); + }, true) && !results.hasOwnProperty(k); + }; + if (ready()) { + task[task.length - 1](taskCallback, results); + } + else { + var listener = function () { + if (ready()) { + removeListener(listener); + task[task.length - 1](taskCallback, results); + } + }; + addListener(listener); + } + }); + }; + + async.waterfall = function (tasks, callback) { + callback = callback || function () {}; + if (tasks.constructor !== Array) { + var err = new Error('First argument to waterfall must be an array of functions'); + return callback(err); + } + if (!tasks.length) { + return callback(); + } + var wrapIterator = function (iterator) { + return function (err) { + if (err) { + callback.apply(null, arguments); + callback = function () {}; + } + else { + var args = Array.prototype.slice.call(arguments, 1); + var next = iterator.next(); + if (next) { + args.push(wrapIterator(next)); + } + else { + args.push(callback); + } + async.setImmediate(function () { + iterator.apply(null, args); + }); + } + }; + }; + wrapIterator(async.iterator(tasks))(); + }; + + var _parallel = function(eachfn, tasks, callback) { + callback = callback || function () {}; + if (tasks.constructor === Array) { + eachfn.map(tasks, function (fn, callback) { + if (fn) { + fn(function (err) { + var args = Array.prototype.slice.call(arguments, 1); + if (args.length <= 1) { + args = args[0]; + } + callback.call(null, err, args); + }); + } + }, callback); + } + else { + var results = {}; + eachfn.each(_keys(tasks), function (k, callback) { + tasks[k](function (err) { + var args = Array.prototype.slice.call(arguments, 1); + if (args.length <= 1) { + args = args[0]; + } + results[k] = args; + callback(err); + }); + }, function (err) { + callback(err, results); + }); + } + }; + + async.parallel = function (tasks, callback) { + _parallel({ map: async.map, each: async.each }, tasks, callback); + }; + + async.parallelLimit = function(tasks, limit, callback) { + _parallel({ map: _mapLimit(limit), each: _eachLimit(limit) }, tasks, callback); + }; + + async.series = function (tasks, callback) { + callback = callback || function () {}; + if (tasks.constructor === Array) { + async.mapSeries(tasks, function (fn, callback) { + if (fn) { + fn(function (err) { + var args = Array.prototype.slice.call(arguments, 1); + if (args.length <= 1) { + args = args[0]; + } + callback.call(null, err, args); + }); + } + }, callback); + } + else { + var results = {}; + async.eachSeries(_keys(tasks), function (k, callback) { + tasks[k](function (err) { + var args = Array.prototype.slice.call(arguments, 1); + if (args.length <= 1) { + args = args[0]; + } + results[k] = args; + callback(err); + }); + }, function (err) { + callback(err, results); + }); + } + }; + + async.iterator = function (tasks) { + var makeCallback = function (index) { + var fn = function () { + if (tasks.length) { + tasks[index].apply(null, arguments); + } + return fn.next(); + }; + fn.next = function () { + return (index < tasks.length - 1) ? makeCallback(index + 1): null; + }; + return fn; + }; + return makeCallback(0); + }; + + async.apply = function (fn) { + var args = Array.prototype.slice.call(arguments, 1); + return function () { + return fn.apply( + null, args.concat(Array.prototype.slice.call(arguments)) + ); + }; + }; + + var _concat = function (eachfn, arr, fn, callback) { + var r = []; + eachfn(arr, function (x, cb) { + fn(x, function (err, y) { + r = r.concat(y || []); + cb(err); + }); + }, function (err) { + callback(err, r); + }); + }; + async.concat = doParallel(_concat); + async.concatSeries = doSeries(_concat); + + async.whilst = function (test, iterator, callback) { + if (test()) { + iterator(function (err) { + if (err) { + return callback(err); + } + async.whilst(test, iterator, callback); + }); + } + else { + callback(); + } + }; + + async.doWhilst = function (iterator, test, callback) { + iterator(function (err) { + if (err) { + return callback(err); + } + if (test()) { + async.doWhilst(iterator, test, callback); + } + else { + callback(); + } + }); + }; + + async.until = function (test, iterator, callback) { + if (!test()) { + iterator(function (err) { + if (err) { + return callback(err); + } + async.until(test, iterator, callback); + }); + } + else { + callback(); + } + }; + + async.doUntil = function (iterator, test, callback) { + iterator(function (err) { + if (err) { + return callback(err); + } + if (!test()) { + async.doUntil(iterator, test, callback); + } + else { + callback(); + } + }); + }; + + async.queue = function (worker, concurrency) { + if (concurrency === undefined) { + concurrency = 1; + } + function _insert(q, data, pos, callback) { + if(data.constructor !== Array) { + data = [data]; + } + _each(data, function(task) { + var item = { + data: task, + callback: typeof callback === 'function' ? callback : null + }; + + if (pos) { + q.tasks.unshift(item); + } else { + q.tasks.push(item); + } + + if (q.saturated && q.tasks.length === concurrency) { + q.saturated(); + } + async.setImmediate(q.process); + }); + } + + var workers = 0; + var q = { + tasks: [], + concurrency: concurrency, + saturated: null, + empty: null, + drain: null, + push: function (data, callback) { + _insert(q, data, false, callback); + }, + unshift: function (data, callback) { + _insert(q, data, true, callback); + }, + process: function () { + if (workers < q.concurrency && q.tasks.length) { + var task = q.tasks.shift(); + if (q.empty && q.tasks.length === 0) { + q.empty(); + } + workers += 1; + var next = function () { + workers -= 1; + if (task.callback) { + task.callback.apply(task, arguments); + } + if (q.drain && q.tasks.length + workers === 0) { + q.drain(); + } + q.process(); + }; + var cb = only_once(next); + worker(task.data, cb); + } + }, + length: function () { + return q.tasks.length; + }, + running: function () { + return workers; + } + }; + return q; + }; + + async.cargo = function (worker, payload) { + var working = false, + tasks = []; + + var cargo = { + tasks: tasks, + payload: payload, + saturated: null, + empty: null, + drain: null, + push: function (data, callback) { + if(data.constructor !== Array) { + data = [data]; + } + _each(data, function(task) { + tasks.push({ + data: task, + callback: typeof callback === 'function' ? callback : null + }); + if (cargo.saturated && tasks.length === payload) { + cargo.saturated(); + } + }); + async.setImmediate(cargo.process); + }, + process: function process() { + if (working) return; + if (tasks.length === 0) { + if(cargo.drain) cargo.drain(); + return; + } + + var ts = typeof payload === 'number' + ? tasks.splice(0, payload) + : tasks.splice(0); + + var ds = _map(ts, function (task) { + return task.data; + }); + + if(cargo.empty) cargo.empty(); + working = true; + worker(ds, function () { + working = false; + + var args = arguments; + _each(ts, function (data) { + if (data.callback) { + data.callback.apply(null, args); + } + }); + + process(); + }); + }, + length: function () { + return tasks.length; + }, + running: function () { + return working; + } + }; + return cargo; + }; + + var _console_fn = function (name) { + return function (fn) { + var args = Array.prototype.slice.call(arguments, 1); + fn.apply(null, args.concat([function (err) { + var args = Array.prototype.slice.call(arguments, 1); + if (typeof console !== 'undefined') { + if (err) { + if (console.error) { + console.error(err); + } + } + else if (console[name]) { + _each(args, function (x) { + console[name](x); + }); + } + } + }])); + }; + }; + async.log = _console_fn('log'); + async.dir = _console_fn('dir'); + /*async.info = _console_fn('info'); + async.warn = _console_fn('warn'); + async.error = _console_fn('error');*/ + + async.memoize = function (fn, hasher) { + var memo = {}; + var queues = {}; + hasher = hasher || function (x) { + return x; + }; + var memoized = function () { + var args = Array.prototype.slice.call(arguments); + var callback = args.pop(); + var key = hasher.apply(null, args); + if (key in memo) { + callback.apply(null, memo[key]); + } + else if (key in queues) { + queues[key].push(callback); + } + else { + queues[key] = [callback]; + fn.apply(null, args.concat([function () { + memo[key] = arguments; + var q = queues[key]; + delete queues[key]; + for (var i = 0, l = q.length; i < l; i++) { + q[i].apply(null, arguments); + } + }])); + } + }; + memoized.memo = memo; + memoized.unmemoized = fn; + return memoized; + }; + + async.unmemoize = function (fn) { + return function () { + return (fn.unmemoized || fn).apply(null, arguments); + }; + }; + + async.times = function (count, iterator, callback) { + var counter = []; + for (var i = 0; i < count; i++) { + counter.push(i); + } + return async.map(counter, iterator, callback); + }; + + async.timesSeries = function (count, iterator, callback) { + var counter = []; + for (var i = 0; i < count; i++) { + counter.push(i); + } + return async.mapSeries(counter, iterator, callback); + }; + + async.compose = function (/* functions... */) { + var fns = Array.prototype.reverse.call(arguments); + return function () { + var that = this; + var args = Array.prototype.slice.call(arguments); + var callback = args.pop(); + async.reduce(fns, args, function (newargs, fn, cb) { + fn.apply(that, newargs.concat([function () { + var err = arguments[0]; + var nextargs = Array.prototype.slice.call(arguments, 1); + cb(err, nextargs); + }])) + }, + function (err, results) { + callback.apply(that, [err].concat(results)); + }); + }; + }; + + var _applyEach = function (eachfn, fns /*args...*/) { + var go = function () { + var that = this; + var args = Array.prototype.slice.call(arguments); + var callback = args.pop(); + return eachfn(fns, function (fn, cb) { + fn.apply(that, args.concat([cb])); + }, + callback); + }; + if (arguments.length > 2) { + var args = Array.prototype.slice.call(arguments, 2); + return go.apply(this, args); + } + else { + return go; + } + }; + async.applyEach = doParallel(_applyEach); + async.applyEachSeries = doSeries(_applyEach); + + async.forever = function (fn, callback) { + function next(err) { + if (err) { + if (callback) { + return callback(err); + } + throw err; + } + fn(next); + } + next(); + }; + + // AMD / RequireJS + if (typeof define !== 'undefined' && define.amd) { + define([], function () { + return async; + }); + } + // Node.js + else if (typeof module !== 'undefined' && module.exports) { + module.exports = async; + } + // included directly via