0;)o=n[i],e&&o._target!==e||(o.unsubscribe(t),a=!0);return a},O.prototype.delimiter=".",O.prototype.setMaxListeners=function(e){e!==i&&(this._maxListeners=e,this._conf||(this._conf={}),this._conf.maxListeners=e)},O.prototype.getMaxListeners=function(){return this._maxListeners},O.prototype.event="",O.prototype.once=function(e,t,n){return this._once(e,t,!1,n)},O.prototype.prependOnceListener=function(e,t,n){return this._once(e,t,!0,n)},O.prototype._once=function(e,t,n,o){return this._many(e,1,t,n,o)},O.prototype.many=function(e,t,n,o){return this._many(e,t,n,!1,o)},O.prototype.prependMany=function(e,t,n,o){return this._many(e,t,n,!0,o)},O.prototype._many=function(e,t,n,o,i){var a=this;if("function"!=typeof n)throw new Error("many only accepts instances of Function");function r(){return 0==--t&&a.off(e,r),n.apply(this,arguments)}return r._origin=n,this._on(e,r,o,i)},O.prototype.emit=function(){if(!this._events&&!this._all)return!1;this._events||d.call(this);var e,t,n,o,i,a,r=arguments[0],s=this.wildcard;if("newListener"===r&&!this._newListener&&!this._events.newListener)return!1;if(s&&(e=r,"newListener"!==r&&"removeListener"!==r&&"object"==typeof r)){if(n=r.length,l)for(o=0;o3)for(t=new Array(p-1),i=1;i3)for(n=new Array(c-1),a=1;a1)for(o=0;o+10&&p._listeners.length>this._maxListeners&&(p._listeners.warned=!0,m.call(this,p._listeners.length,u))):p._listeners=t,!0;return!0}.call(this,t,n,o),l):(this._events[t]?("function"==typeof this._events[t]&&(this._events[t]=[this._events[t]]),o?this._events[t].unshift(n):this._events[t].push(n),!this._events[t].warned&&this._maxListeners>0&&this._events[t].length>this._maxListeners&&(this._events[t].warned=!0,m.call(this,this._events[t].length,t))):this._events[t]=n,l)},O.prototype.off=function(e,t){if("function"!=typeof t)throw new Error("removeListener only takes instances of Function");var n,o=[];if(this.wildcard){var i="string"==typeof e?e.split(this.delimiter):e.slice();if(!(o=E.call(this,null,i,this.listenerTree,0)))return this}else{if(!this._events[e])return this;n=this._events[e],o.push({_listeners:n})}for(var a=0;a0){for(n=0,o=(t=this._all).length;n0;)"function"==typeof(n=s[t[a]])?o.push(n):o.push.apply(o,n);return o}if(this.wildcard){if(!(r=this.listenerTree))return[];var l=[],u="string"==typeof e?e.split(this.delimiter):e.slice();return E.call(this,l,u,r,0),l}return s&&(n=s[e])?"function"==typeof n?[n]:n:[]},O.prototype.eventNames=function(e){var t=this._events;return this.wildcard?function e(t,n,o,i){for(var a,r,s,l,u=c(t),p=u.length,d=t._listeners;p-- >0;)a=t[r=u[p]],s="_listeners"===r?o:o?o.concat(r):[r],l=i||"symbol"==typeof r,d&&n.push(l?s:s.join(this.delimiter)),"object"==typeof a&&e.call(this,a,n,s,l);return n}.call(this,this.listenerTree,[],null,e):t?c(t):[]},O.prototype.listenerCount=function(e){return this.listeners(e).length},O.prototype.hasListeners=function(e){if(this.wildcard){var t=[],n="string"==typeof e?e.split(this.delimiter):e.slice();return E.call(this,t,n,this.listenerTree,0),t.length>0}var o=this._events,a=this._all;return!!(a&&a.length||o&&(e===i?c(o).length:o[e]))},O.prototype.listenersAny=function(){return this._all?this._all:[]},O.prototype.waitFor=function(e,t){var n=this,o=typeof t;return"number"===o?t={timeout:t}:"function"===o&&(t={filter:t}),T((t=b(t,{timeout:0,filter:i,handleError:!1,Promise:Promise,overload:!1},{filter:w,Promise:g})).Promise,function(o,i,a){function r(){var a=t.filter;if(!a||a.apply(n,arguments))if(n.off(e,r),t.handleError){var s=arguments[0];s?i(s):o(y.apply(null,arguments).slice(1))}else o(y.apply(null,arguments))}a(function(){n.off(e,r)}),n._on(e,r,!1)},{timeout:t.timeout,overload:t.overload})};var x=O.prototype;Object.defineProperties(O,{defaultMaxListeners:{get:function(){return x._maxListeners},set:function(e){if("number"!=typeof e||e<0||Number.isNaN(e))throw TypeError("n must be a non-negative number");x._maxListeners=e},enumerable:!0},once:{value:function(e,t,n){return T((n=b(n,{Promise:Promise,timeout:0,overload:!1},{Promise:g})).Promise,function(n,o,i){var a;if("function"==typeof e.addEventListener)return a=function(){n(y.apply(null,arguments))},i(function(){e.removeEventListener(t,a)}),void e.addEventListener(t,a,{once:!0});var r,s=function(){r&&e.removeListener("error",r),n(y.apply(null,arguments))};"error"!==t&&(r=function(n){e.removeListener(t,s),o(n)},e.once("error",r)),i(function(){r&&e.removeListener("error",r),e.removeListener(t,s)}),e.once(t,s)},{timeout:n.timeout,overload:n.overload})},writable:!0,configurable:!0}}),Object.defineProperties(x,{_maxListeners:{value:10,writable:!0,configurable:!0},_observers:{value:null,writable:!0,configurable:!0}}),"object"==typeof n?t.exports=O:new Function("","return this")().EventEmitter2=O}()}).call(this)}).call(this,e("_process"),e("timers").setImmediate)},{_process:37,timers:38}],7:[function(e,t,n){t.exports=e("./lib/axios")},{"./lib/axios":9}],8:[function(e,t,n){"use strict";var o=e("./../utils"),i=e("./../core/settle"),a=e("./../helpers/cookies"),r=e("./../helpers/buildURL"),s=e("../core/buildFullPath"),l=e("./../helpers/parseHeaders"),u=e("./../helpers/isURLSameOrigin"),p=e("../core/createError");t.exports=function(e){return new Promise(function(t,n){var c=e.data,d=e.headers,f=e.responseType;o.isFormData(c)&&delete d["Content-Type"];var m=new XMLHttpRequest;if(e.auth){var y=e.auth.username||"",h=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";d.Authorization="Basic "+btoa(y+":"+h)}var v=s(e.baseURL,e.url);function b(){if(m){var o="getAllResponseHeaders"in m?l(m.getAllResponseHeaders()):null,a={data:f&&"text"!==f&&"json"!==f?m.response:m.responseText,status:m.status,statusText:m.statusText,headers:o,config:e,request:m};i(t,n,a),m=null}}if(m.open(e.method.toUpperCase(),r(v,e.params,e.paramsSerializer),!0),m.timeout=e.timeout,"onloadend"in m?m.onloadend=b:m.onreadystatechange=function(){m&&4===m.readyState&&(0!==m.status||m.responseURL&&0===m.responseURL.indexOf("file:"))&&setTimeout(b)},m.onabort=function(){m&&(n(p("Request aborted",e,"ECONNABORTED",m)),m=null)},m.onerror=function(){n(p("Network Error",e,null,m)),m=null},m.ontimeout=function(){var t="timeout of "+e.timeout+"ms exceeded";e.timeoutErrorMessage&&(t=e.timeoutErrorMessage),n(p(t,e,e.transitional&&e.transitional.clarifyTimeoutError?"ETIMEDOUT":"ECONNABORTED",m)),m=null},o.isStandardBrowserEnv()){var g=(e.withCredentials||u(v))&&e.xsrfCookieName?a.read(e.xsrfCookieName):void 0;g&&(d[e.xsrfHeaderName]=g)}"setRequestHeader"in m&&o.forEach(d,function(e,t){void 0===c&&"content-type"===t.toLowerCase()?delete d[t]:m.setRequestHeader(t,e)}),o.isUndefined(e.withCredentials)||(m.withCredentials=!!e.withCredentials),f&&"json"!==f&&(m.responseType=e.responseType),"function"==typeof e.onDownloadProgress&&m.addEventListener("progress",e.onDownloadProgress),"function"==typeof e.onUploadProgress&&m.upload&&m.upload.addEventListener("progress",e.onUploadProgress),e.cancelToken&&e.cancelToken.promise.then(function(e){m&&(m.abort(),n(e),m=null)}),c||(c=null),m.send(c)})}},{"../core/buildFullPath":15,"../core/createError":16,"./../core/settle":20,"./../helpers/buildURL":24,"./../helpers/cookies":26,"./../helpers/isURLSameOrigin":29,"./../helpers/parseHeaders":31,"./../utils":34}],9:[function(e,t,n){"use strict";var o=e("./utils"),i=e("./helpers/bind"),a=e("./core/Axios"),r=e("./core/mergeConfig");function s(e){var t=new a(e),n=i(a.prototype.request,t);return o.extend(n,a.prototype,t),o.extend(n,t),n}var l=s(e("./defaults"));l.Axios=a,l.create=function(e){return s(r(l.defaults,e))},l.Cancel=e("./cancel/Cancel"),l.CancelToken=e("./cancel/CancelToken"),l.isCancel=e("./cancel/isCancel"),l.all=function(e){return Promise.all(e)},l.spread=e("./helpers/spread"),l.isAxiosError=e("./helpers/isAxiosError"),t.exports=l,t.exports.default=l},{"./cancel/Cancel":10,"./cancel/CancelToken":11,"./cancel/isCancel":12,"./core/Axios":13,"./core/mergeConfig":19,"./defaults":22,"./helpers/bind":23,"./helpers/isAxiosError":28,"./helpers/spread":32,"./utils":34}],10:[function(e,t,n){"use strict";function o(e){this.message=e}o.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},o.prototype.__CANCEL__=!0,t.exports=o},{}],11:[function(e,t,n){"use strict";var o=e("./Cancel");function i(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");var t;this.promise=new Promise(function(e){t=e});var n=this;e(function(e){n.reason||(n.reason=new o(e),t(n.reason))})}i.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},i.source=function(){var e;return{token:new i(function(t){e=t}),cancel:e}},t.exports=i},{"./Cancel":10}],12:[function(e,t,n){"use strict";t.exports=function(e){return!(!e||!e.__CANCEL__)}},{}],13:[function(e,t,n){"use strict";var o=e("./../utils"),i=e("../helpers/buildURL"),a=e("./InterceptorManager"),r=e("./dispatchRequest"),s=e("./mergeConfig"),l=e("../helpers/validator"),u=l.validators;function p(e){this.defaults=e,this.interceptors={request:new a,response:new a}}p.prototype.request=function(e){"string"==typeof e?(e=arguments[1]||{}).url=arguments[0]:e=e||{},(e=s(this.defaults,e)).method?e.method=e.method.toLowerCase():this.defaults.method?e.method=this.defaults.method.toLowerCase():e.method="get";var t=e.transitional;void 0!==t&&l.assertOptions(t,{silentJSONParsing:u.transitional(u.boolean,"1.0.0"),forcedJSONParsing:u.transitional(u.boolean,"1.0.0"),clarifyTimeoutError:u.transitional(u.boolean,"1.0.0")},!1);var n=[],o=!0;this.interceptors.request.forEach(function(t){"function"==typeof t.runWhen&&!1===t.runWhen(e)||(o=o&&t.synchronous,n.unshift(t.fulfilled,t.rejected))});var i,a=[];if(this.interceptors.response.forEach(function(e){a.push(e.fulfilled,e.rejected)}),!o){var p=[r,void 0];for(Array.prototype.unshift.apply(p,n),p=p.concat(a),i=Promise.resolve(e);p.length;)i=i.then(p.shift(),p.shift());return i}for(var c=e;n.length;){var d=n.shift(),f=n.shift();try{c=d(c)}catch(e){f(e);break}}try{i=r(c)}catch(e){return Promise.reject(e)}for(;a.length;)i=i.then(a.shift(),a.shift());return i},p.prototype.getUri=function(e){return e=s(this.defaults,e),i(e.url,e.params,e.paramsSerializer).replace(/^\?/,"")},o.forEach(["delete","get","head","options"],function(e){p.prototype[e]=function(t,n){return this.request(s(n||{},{method:e,url:t,data:(n||{}).data}))}}),o.forEach(["post","put","patch"],function(e){p.prototype[e]=function(t,n,o){return this.request(s(o||{},{method:e,url:t,data:n}))}}),t.exports=p},{"../helpers/buildURL":24,"../helpers/validator":33,"./../utils":34,"./InterceptorManager":14,"./dispatchRequest":17,"./mergeConfig":19}],14:[function(e,t,n){"use strict";var o=e("./../utils");function i(){this.handlers=[]}i.prototype.use=function(e,t,n){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!n&&n.synchronous,runWhen:n?n.runWhen:null}),this.handlers.length-1},i.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},i.prototype.forEach=function(e){o.forEach(this.handlers,function(t){null!==t&&e(t)})},t.exports=i},{"./../utils":34}],15:[function(e,t,n){"use strict";var o=e("../helpers/isAbsoluteURL"),i=e("../helpers/combineURLs");t.exports=function(e,t){return e&&!o(t)?i(e,t):t}},{"../helpers/combineURLs":25,"../helpers/isAbsoluteURL":27}],16:[function(e,t,n){"use strict";var o=e("./enhanceError");t.exports=function(e,t,n,i,a){var r=new Error(e);return o(r,t,n,i,a)}},{"./enhanceError":18}],17:[function(e,t,n){"use strict";var o=e("./../utils"),i=e("./transformData"),a=e("../cancel/isCancel"),r=e("../defaults");function s(e){e.cancelToken&&e.cancelToken.throwIfRequested()}t.exports=function(e){return s(e),e.headers=e.headers||{},e.data=i.call(e,e.data,e.headers,e.transformRequest),e.headers=o.merge(e.headers.common||{},e.headers[e.method]||{},e.headers),o.forEach(["delete","get","head","post","put","patch","common"],function(t){delete e.headers[t]}),(e.adapter||r.adapter)(e).then(function(t){return s(e),t.data=i.call(e,t.data,t.headers,e.transformResponse),t},function(t){return a(t)||(s(e),t&&t.response&&(t.response.data=i.call(e,t.response.data,t.response.headers,e.transformResponse))),Promise.reject(t)})}},{"../cancel/isCancel":12,"../defaults":22,"./../utils":34,"./transformData":21}],18:[function(e,t,n){"use strict";t.exports=function(e,t,n,o,i){return e.config=t,n&&(e.code=n),e.request=o,e.response=i,e.isAxiosError=!0,e.toJSON=function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code}},e}},{}],19:[function(e,t,n){"use strict";var o=e("../utils");t.exports=function(e,t){t=t||{};var n={},i=["url","method","data"],a=["headers","auth","proxy","params"],r=["baseURL","transformRequest","transformResponse","paramsSerializer","timeout","timeoutMessage","withCredentials","adapter","responseType","xsrfCookieName","xsrfHeaderName","onUploadProgress","onDownloadProgress","decompress","maxContentLength","maxBodyLength","maxRedirects","transport","httpAgent","httpsAgent","cancelToken","socketPath","responseEncoding"],s=["validateStatus"];function l(e,t){return o.isPlainObject(e)&&o.isPlainObject(t)?o.merge(e,t):o.isPlainObject(t)?o.merge({},t):o.isArray(t)?t.slice():t}function u(i){o.isUndefined(t[i])?o.isUndefined(e[i])||(n[i]=l(void 0,e[i])):n[i]=l(e[i],t[i])}o.forEach(i,function(e){o.isUndefined(t[e])||(n[e]=l(void 0,t[e]))}),o.forEach(a,u),o.forEach(r,function(i){o.isUndefined(t[i])?o.isUndefined(e[i])||(n[i]=l(void 0,e[i])):n[i]=l(void 0,t[i])}),o.forEach(s,function(o){o in t?n[o]=l(e[o],t[o]):o in e&&(n[o]=l(void 0,e[o]))});var p=i.concat(a).concat(r).concat(s),c=Object.keys(e).concat(Object.keys(t)).filter(function(e){return-1===p.indexOf(e)});return o.forEach(c,u),n}},{"../utils":34}],20:[function(e,t,n){"use strict";var o=e("./createError");t.exports=function(e,t,n){var i=n.config.validateStatus;n.status&&i&&!i(n.status)?t(o("Request failed with status code "+n.status,n.config,null,n.request,n)):e(n)}},{"./createError":16}],21:[function(e,t,n){"use strict";var o=e("./../utils"),i=e("./../defaults");t.exports=function(e,t,n){var a=this||i;return o.forEach(n,function(n){e=n.call(a,e,t)}),e}},{"./../defaults":22,"./../utils":34}],22:[function(e,t,n){(function(n){(function(){"use strict";var o=e("./utils"),i=e("./helpers/normalizeHeaderName"),a=e("./core/enhanceError"),r={"Content-Type":"application/x-www-form-urlencoded"};function s(e,t){!o.isUndefined(e)&&o.isUndefined(e["Content-Type"])&&(e["Content-Type"]=t)}var l,u={transitional:{silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},adapter:("undefined"!=typeof XMLHttpRequest?l=e("./adapters/xhr"):void 0!==n&&"[object process]"===Object.prototype.toString.call(n)&&(l=e("./adapters/http")),l),transformRequest:[function(e,t){return i(t,"Accept"),i(t,"Content-Type"),o.isFormData(e)||o.isArrayBuffer(e)||o.isBuffer(e)||o.isStream(e)||o.isFile(e)||o.isBlob(e)?e:o.isArrayBufferView(e)?e.buffer:o.isURLSearchParams(e)?(s(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):o.isObject(e)||t&&"application/json"===t["Content-Type"]?(s(t,"application/json"),function(e,t,n){if(o.isString(e))try{return(t||JSON.parse)(e),o.trim(e)}catch(e){if("SyntaxError"!==e.name)throw e}return(n||JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){var t=this.transitional,n=t&&t.silentJSONParsing,i=t&&t.forcedJSONParsing,r=!n&&"json"===this.responseType;if(r||i&&o.isString(e)&&e.length)try{return JSON.parse(e)}catch(e){if(r){if("SyntaxError"===e.name)throw a(e,this,"E_JSON_PARSE");throw e}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,validateStatus:function(e){return e>=200&&e<300}};u.headers={common:{Accept:"application/json, text/plain, */*"}},o.forEach(["delete","get","head"],function(e){u.headers[e]={}}),o.forEach(["post","put","patch"],function(e){u.headers[e]=o.merge(r)}),t.exports=u}).call(this)}).call(this,e("_process"))},{"./adapters/http":8,"./adapters/xhr":8,"./core/enhanceError":18,"./helpers/normalizeHeaderName":30,"./utils":34,_process:37}],23:[function(e,t,n){"use strict";t.exports=function(e,t){return function(){for(var n=new Array(arguments.length),o=0;o=0)return;r[t]="set-cookie"===t?(r[t]?r[t]:[]).concat([n]):r[t]?r[t]+", "+n:n}}),r):r}},{"./../utils":34}],32:[function(e,t,n){"use strict";t.exports=function(e){return function(t){return e.apply(null,t)}}},{}],33:[function(e,t,n){"use strict";var o=e("./../../package.json"),i={};["object","boolean","number","function","string","symbol"].forEach(function(e,t){i[e]=function(n){return typeof n===e||"a"+(t<1?"n ":" ")+e}});var a={},r=o.version.split(".");function s(e,t){for(var n=t?t.split("."):r,o=e.split("."),i=0;i<3;i++){if(n[i]>o[i])return!0;if(n[i]0;){var a=o[i],r=t[a];if(r){var s=e[a],l=void 0===s||r(s,a,e);if(!0!==l)throw new TypeError("option "+a+" must be "+l)}else if(!0!==n)throw Error("Unknown option "+a)}},validators:i}},{"./../../package.json":35}],34:[function(e,t,n){"use strict";var o=e("./helpers/bind"),i=Object.prototype.toString;function a(e){return"[object Array]"===i.call(e)}function r(e){return void 0===e}function s(e){return null!==e&&"object"==typeof e}function l(e){if("[object Object]"!==i.call(e))return!1;var t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}function u(e){return"[object Function]"===i.call(e)}function p(e,t){if(null!==e&&void 0!==e)if("object"!=typeof e&&(e=[e]),a(e))for(var n=0,o=e.length;n=1.5*n;return Math.round(e/n)+" "+o+(i?"s":"")}t.exports=function(e,t){t=t||{};var n=typeof e;if("string"===n&&e.length>0)return function(e){if((e=String(e)).length>100)return;var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(!t)return;var n=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return n*l;case"weeks":case"week":case"w":return n*s;case"days":case"day":case"d":return n*r;case"hours":case"hour":case"hrs":case"hr":case"h":return n*a;case"minutes":case"minute":case"mins":case"min":case"m":return n*i;case"seconds":case"second":case"secs":case"sec":case"s":return n*o;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return n;default:return}}(e);if("number"===n&&isFinite(e))return t.long?function(e){var t=Math.abs(e);if(t>=r)return u(e,t,r,"day");if(t>=a)return u(e,t,a,"hour");if(t>=i)return u(e,t,i,"minute");if(t>=o)return u(e,t,o,"second");return e+" ms"}(e):function(e){var t=Math.abs(e);if(t>=r)return Math.round(e/r)+"d";if(t>=a)return Math.round(e/a)+"h";if(t>=i)return Math.round(e/i)+"m";if(t>=o)return Math.round(e/o)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},{}],37:[function(e,t,n){var o,i,a=t.exports={};function r(){throw new Error("setTimeout has not been defined")}function s(){throw new Error("clearTimeout has not been defined")}function l(e){if(o===setTimeout)return setTimeout(e,0);if((o===r||!o)&&setTimeout)return o=setTimeout,setTimeout(e,0);try{return o(e,0)}catch(t){try{return o.call(null,e,0)}catch(t){return o.call(this,e,0)}}}!function(){try{o="function"==typeof setTimeout?setTimeout:r}catch(e){o=r}try{i="function"==typeof clearTimeout?clearTimeout:s}catch(e){i=s}}();var u,p=[],c=!1,d=-1;function f(){c&&u&&(c=!1,u.length?p=u.concat(p):d=-1,p.length&&m())}function m(){if(!c){var e=l(f);c=!0;for(var t=p.length;t;){for(u=p,p=[];++d1)for(var n=1;n=0&&(e._idleTimeoutId=setTimeout(function(){e._onTimeout&&e._onTimeout()},t))},n.setImmediate="function"==typeof t?t:function(e){var t=l++,o=!(arguments.length<2)&&r.call(arguments,1);return s[t]=!0,i(function(){s[t]&&(o?e.apply(null,o):e.call(null),n.clearImmediate(t))}),t},n.clearImmediate="function"==typeof o?o:function(e){delete s[e]}}).call(this)}).call(this,e("timers").setImmediate,e("timers").clearImmediate)},{"process/browser.js":37,timers:38}],39:[function(e,t,n){t.exports={name:"@pm2/js-api",version:"0.8.0",description:"PM2.io API Client for Javascript",main:"index.js",unpkg:"dist/keymetrics.es5.min.js",engines:{node:">=4.0"},scripts:{test:"mocha test/*",build:"mkdir -p dist; browserify -s Keymetrics -r ./ > ./dist/keymetrics.es5.js",dist:"mkdir -p dist; browserify -s Keymetrics -r ./ | uglifyjs -c warnings=false -m > ./dist/keymetrics.es5.min.js",doc:"jsdoc -r ./src --readme ./README.md -d doc -t ./node_modules/minami",clean:"rm dist/*",prepare:"npm run build && npm run dist"},repository:{type:"git",url:"git+https://github.com/keymetrics/km.js.git"},keywords:["keymetrics","api","dashboard","monitoring","wrapper"],author:"Keymetrics Team",license:"Apache-2",bugs:{url:"https://github.com/keymetrics/km.js/issues"},homepage:"https://github.com/keymetrics/km.js#readme",dependencies:{async:"^2.6.3",extrareqp2:"^1.0.0",debug:"~4.3.1",eventemitter2:"^6.3.1",ws:"^7.0.0"},devDependencies:{"@babel/core":"^7.0.0","@babel/preset-env":"^7.0.0",babelify:"10.0.0",browserify:"^17.0.0",jsdoc:"^3.4.2",minami:"^1.1.1",mocha:"^7.0.0",should:"*","uglify-es":"~3.3.9"},browserify:{debug:!0,transform:[["babelify",{presets:[["@babel/preset-env",{debug:!1,forceAllTransforms:!0}]],sourceMaps:!0}]]},browser:{"./src/auth_strategies/embed_strategy.js":!1,ws:!1}}},{}],40:[function(e,t,n){t.exports={actions:[{route:{name:"/api/bucket/:id/actions/trigger",type:"POST"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],params:[{name:":id",type:"string",description:"bucket id",optional:!1}],body:[{name:"server_name",type:"string",description:"the name of the server",optional:!1,defaultvalue:null},{name:"process_id",type:"number",description:"the id of the process",optional:!0,defaultvalue:null},{name:"app_name",type:"number",description:"the name of the process",optional:!0,defaultvalue:null},{name:"action_name",type:"string",description:"the name of the action to trigger",optional:!1,defaultvalue:null},{name:"opts",type:"object",description:"any specific options to be passed to the function",optional:!0,defaultvalue:null}],code:[{type:"500",description:"database error",optional:!1},{type:"200",description:"succesfully run the action",optional:!1}],response:[{name:"success",type:"boolean",description:"succesully sended the action to PM2",optional:!1,defaultvalue:null}],name:"triggerAction",longname:"Actions.triggerAction",scope:"route"},{route:{name:"/api/bucket/:id/actions/triggerPM2",type:"POST"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],params:[{name:":id",type:"string",description:"bucket id",optional:!1}],body:[{name:"server_name",type:"string",description:"the name of the server",optional:!1,defaultvalue:null},{name:"method_name",type:"string",description:"the name of the pm2 method to trigger",optional:!1,defaultvalue:null},{name:"app_name",type:"string",description:"the name of the application",optional:!1,defaultvalue:null}],code:[{type:"500",description:"database error",optional:!1},{type:"400",description:"failed action",optional:!1},{type:"200",description:"succesfully run the action",optional:!1}],response:[{name:"success",type:"boolean",description:"succesully sended the action to PM2",optional:!1,defaultvalue:null}],name:"triggerPM2Action",longname:"Actions.triggerPM2Action",scope:"route"},{route:{name:"/api/bucket/:id/actions/triggerScopedAction",type:"POST"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],params:[{name:":id",type:"string",description:"bucket id",optional:!1}],body:[{name:"server_name",type:"string",description:"the name of the server",optional:!1,defaultvalue:null},{name:"action_name",type:"string",description:"the name of the pm2 method to trigger",optional:!1,defaultvalue:null},{name:"app_name",type:"string",description:"the name of the application",optional:!1,defaultvalue:null},{name:"pm_id",type:"number",description:"the id of the process",optional:!1,defaultvalue:null},{name:"opts",type:"object",description:"custom parameters to give to the action",optional:!0,defaultvalue:null}],code:[{type:"500",description:"database error",optional:!1},{type:"200",description:"succesfully run the action",optional:!1}],response:[{name:".",type:"object",description:"the action sended to the process",optional:!1,defaultvalue:null}],name:"triggerScopedAction",longname:"Actions.triggerScopedAction",scope:"route"}],bucket:{alert:{analyzer:[{route:{name:"/api/bucket/:id/alerts/analyzer",type:"POST"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],params:[{name:":id",type:"string",description:"bucket id",optional:!1}],body:[{name:"size",type:"integer",description:"line limit, default to 20",optional:!0,defaultvalue:null},{name:"from",type:"integer",description:"offset limit",optional:!0,defaultvalue:null}],code:[{type:"500",description:"database error",optional:!1},{type:"200",description:"list all alerts",optional:!1}],name:"list",longname:"Bucket.alert.analyzer.list",scope:"route",async:!0},{route:{name:"/api/bucket/:id/alerts/analyzer/:alert",type:"PUT"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],params:[{name:":id",type:"string",description:"bucket id",optional:!1},{name:":alert",type:"string",description:"alert id",optional:!1}],body:[{name:"useful",type:"boolean",description:"",optional:!1,defaultvalue:null}],code:[{type:"500",description:"database error",optional:!1},{type:"200",description:"content modified",optional:!1}],name:"editState",longname:"Bucket.alert.analyzer.editState",scope:"route"},{route:{name:"/api/bucket/:id/alerts/analyzer/:analyzer/config",type:"PUT"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],params:[{name:":id",type:"string",description:"bucket id",optional:!1},{name:":analyzer",type:"string",description:"analyzer name",optional:!1}],body:[{name:"blacklist",type:"object",description:"",optional:!1,defaultvalue:null},{name:"blacklist.apps",type:"array",description:"",optional:!0,defaultvalue:null},{name:"blacklist.servers",type:"array",description:"",optional:!0,defaultvalue:null},{name:"blacklist.metrics",type:"array",description:"",optional:!0,defaultvalue:null},{name:"threshold",type:"number",description:"",optional:!1,defaultvalue:null},{name:"window",type:"number",description:"",optional:!1,defaultvalue:null}],code:[{type:"500",description:"database error",optional:!1},{type:"200",description:"content modified",optional:!1}],name:"updateConfig",longname:"Bucket.alert.analyzer.updateConfig",scope:"route"}],default:[{route:{name:"/api/bucket/:id/alerts",type:"POST"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],params:[{name:":id",type:"string",description:"bucket id",optional:!1}],body:[{name:"name",type:"string",description:"Alert name",optional:!1,defaultvalue:null},{name:"enabled",type:"boolean",description:"Alert's state",optional:!0,defaultvalue:null},{name:"type",type:"string",description:"Should be `metric`, `event` or `webcheck`",optional:!1,defaultvalue:null},{name:"initiator",type:"string",description:"Should be metric name or event name",optional:!1,defaultvalue:null},{name:"options",type:"object",description:"",optional:!1,defaultvalue:null},{name:"options.operator",type:"string",description:"Should be `>`, `<`, `=`, `>=` or `<=`",optional:!0,defaultvalue:null},{name:"options.threshold",type:"number",description:"Value to reach to send an alert",optional:!0,defaultvalue:null},{name:"options.act",type:"string",description:"Should be `always`, `opposite`, `first` or `diff`",optional:!0,defaultvalue:null},{name:"options.timerange",type:"number",description:"Timerange to check, in seconds",optional:!0,defaultvalue:null},{name:"scope",type:"object",description:"",optional:!1,defaultvalue:null},{name:"scope.apps",type:"object",description:"Array of strings with apps name (can be empty)",optional:!0,defaultvalue:null},{name:"scope.servers",type:"object",description:"Array of strings with servers name (can be empty)",optional:!0,defaultvalue:null},{name:"scope.initiators",type:"object",description:"Array of strings with initiators name (need to be set if no apps or servers)",optional:!0,defaultvalue:null},{name:"scope.sources",type:"object",description:"Array of strings with sources name (can be empty)",optional:!0,defaultvalue:null},{name:"actions",type:"object",description:"List of actions to trigger",optional:!1,defaultvalue:null},{name:"actions[].type",type:"string",description:"Type of action",optional:!0,defaultvalue:null},{name:"actions[].params",type:"object",description:"Params for action",optional:!0,defaultvalue:null}],code:[{type:"500",description:"database error",optional:!1},{type:"400",description:"missing parameters",optional:!1},{type:"200",description:"successfuly created alert",optional:!1}],name:"create",longname:"Bucket.alert.create",scope:"route"},{route:{name:"/api/bucket/:id/alerts/:alert",type:"DELETE"},params:[{name:":id",type:"string",description:"bucket id",optional:!1},{name:":alert",type:"string",description:"alert id",optional:!1}],code:[{type:"500",description:"database error",optional:!1},{type:"204",description:"successfuly deleted alert",optional:!1}],name:"delete",longname:"Bucket.alert.delete",scope:"route",authentication:!1},{route:{name:"/api/bucket/:id/alerts/",type:"GET"},params:[{name:":id",type:"string",description:"bucket id",optional:!1}],code:[{type:"500",description:"database error",optional:!1},{type:"200",description:"list all alerts",optional:!1}],name:"list",longname:"Bucket.alert.list",scope:"route",authentication:!1},{route:{name:"/api/bucket/:id/alerts/:alert",type:"PUT"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],params:[{name:":id",type:"string",description:"bucket id",optional:!1},{name:":alert",type:"string",description:"alert id",optional:!1}],body:[{name:"name",type:"string",description:"Alert name",optional:!0,defaultvalue:null},{name:"enabled",type:"boolean",description:"Alert's state",optional:!0,defaultvalue:null},{name:"type",type:"string",description:"Should be `metric`, `event` or `webcheck`",optional:!0,defaultvalue:null},{name:"initiator",type:"string",description:"Should be metric name or event name",optional:!0,defaultvalue:null},{name:"options",type:"object",description:"",optional:!0,defaultvalue:null},{name:"options.operator",type:"string",description:"Should be `>`, `<`, `=`, `<=` or `>=`",optional:!0,defaultvalue:null},{name:"options.threshold",type:"number",description:"Value to reach to send an alert",optional:!0,defaultvalue:null},{name:"options.act",type:"string",description:"Should be `always`, `opposite`, `first` or `diff`",optional:!0,defaultvalue:null},{name:"options.timerange",type:"number",description:"Timerange to check, in seconds",optional:!0,defaultvalue:null},{name:"scope",type:"object",description:"",optional:!0,defaultvalue:null},{name:"scope.apps",type:"array",description:"Array of strings with apps name (can be empty)",optional:!0,defaultvalue:null},{name:"scope.servers",type:"array",description:"Array of strings with servers name (can be empty)",optional:!0,defaultvalue:null},{name:"scope.initiators",type:"object",description:"Array of strings with initiators name (need to be set if no apps or servers)",optional:!0,defaultvalue:null},{name:"scope.sources",type:"object",description:"Array of strings with sources name (can be empty)",optional:!0,defaultvalue:null},{name:"actions",type:"array",description:"List of actions to trigger",optional:!0,defaultvalue:null},{name:"actions[].type",type:"string",description:"Type of action",optional:!0,defaultvalue:null},{name:"actions[].params",type:"object",description:"Params for action",optional:!0,defaultvalue:null}],code:[{type:"500",description:"database error",optional:!1},{type:"400",description:"missing parameters",optional:!1},{type:"404",description:"alert not found",optional:!1},{type:"200",description:"successfuly created alert",optional:!1}],name:"updateAlert",longname:"Bucket.alert.updateAlert",scope:"route"},{route:{name:"/api/bucket/:id/alerts/:alert",type:"GET"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],params:[{name:":id",type:"string",description:"bucket id",optional:!1},{name:":alert",type:"string",description:"alert id",optional:!1}],code:[{type:"500",description:"database error",optional:!1},{type:"404",description:"alert not found",optional:!1},{type:"200",description:"successfuly returned alert",optional:!1}],name:"get",longname:"Bucket.alert.get",scope:"route",async:!0},{route:{name:"/api/bucket/:id/alerts/:alert/sample",type:"POST"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],params:[{name:":id",type:"string",description:"bucket id",optional:!1},{name:":alert",type:"string",description:"alert id",optional:!1}],code:[{type:"500",description:"database error",optional:!1},{type:"404",description:"alert not found",optional:!1},{type:"202",description:"successfuly sended alert actions",optional:!1}],name:"triggerSample",longname:"Bucket.alert.triggerSample",scope:"route"},{route:{name:"/api/bucket/:id/alerts/update",type:"POST"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],params:[{name:":id",type:"string",description:"bucket id",optional:!1}],body:[{name:"triggers",type:"object",description:"",optional:!1,defaultvalue:null}],code:[{type:"500",description:"database error",optional:!1},{type:"400",description:"missing triggers parameter",optional:!1},{type:"200",description:"succesfully update triggers",optional:!1}],response:[{name:"triggers",type:"object",description:"new triggers object",optional:!1,defaultvalue:null}],name:"update",longname:"Bucket.alert.update",scope:"route"},{route:{name:"/api/bucket/:id/alerts/updateSlack",type:"POST"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],params:[{name:":id",type:"string",description:"bucket id",optional:!1}],body:[{name:"slack",type:"object",description:"",optional:!1,defaultvalue:null},{name:"slack.active",type:"boolean",description:"",optional:!0,defaultvalue:null},{name:"slack.url",type:"boolean",description:"needed if active is set to true",optional:!0,defaultvalue:null}],code:[{type:"500",description:"database error",optional:!1},{type:"400",description:"missing triggers parameter",optional:!1},{type:"200",description:"succesfully update triggers",optional:!1}],response:[{name:"bucket",type:"object",description:"",optional:!1,defaultvalue:null}],name:"updateSlack",longname:"Bucket.alert.updateSlack",scope:"route"},{route:{name:"/api/bucket/:id/alerts/updateWebhooks",type:"POST"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],params:[{name:":id",type:"string",description:"bucket id",optional:!1}],body:[{name:"webhooks",type:"object",description:"",optional:!1,defaultvalue:null},{name:"webhooks.active",type:"boolean",description:"",optional:!0,defaultvalue:null},{name:"webhooks.url",type:"boolean",description:"needed if active is set to true",optional:!0,defaultvalue:null}],code:[{type:"500",description:"database error",optional:!1},{type:"400",description:"missing triggers parameter",optional:!1},{type:"200",description:"succesfully update triggers",optional:!1}],response:[{name:"bucket",type:"object",description:"",optional:!1,defaultvalue:null}],name:"updateWebhooks",longname:"Bucket.alert.updateWebhooks",scope:"route"}]},application:[{route:{name:"/api/bucket/:id/applications",type:"GET"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],params:[{name:":id",type:"string",description:"bucket id",optional:!1}],code:[{type:"500",description:"database error",optional:!1},{type:"200",description:"successfuly retrieved applications",optional:!1}],name:"list",longname:"Bucket.application.list",scope:"route",async:!0},{route:{name:"/api/bucket/:id/applications/:application",type:"GET"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],params:[{name:":id",type:"string",description:"bucket id",optional:!1},{name:":application",type:"string",description:"application id",optional:!1}],code:[{type:"500",description:"database error",optional:!1},{type:"404",description:"application not found",optional:!1},{type:"200",description:"successfuly retrieved application",optional:!1}],name:"get",longname:"Bucket.application.get",scope:"route",async:!0},{route:{name:"/api/bucket/:id/applications",type:"POST"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],params:[{name:":id",type:"string",description:"bucket id",optional:!1}],body:[{name:"name",type:"string",description:"",optional:!1,defaultvalue:null},{name:"domains",type:"object",description:"Array of string with domains",optional:!1,defaultvalue:null}],code:[{type:"500",description:"database error",optional:!1},{type:"400",description:"missing parameters",optional:!1},{type:"200",description:"successfuly created application",optional:!1}],name:"create",longname:"Bucket.application.create",scope:"route",async:!0},{route:{name:"/api/bucket/:id/applications/:application",type:"PUT"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],params:[{name:":id",type:"string",description:"bucket id",optional:!1},{name:":application",type:"string",description:"application id",optional:!1}],body:[{name:"name",type:"string",description:"",optional:!0,defaultvalue:null},{name:"domains",type:"object",description:"",optional:!0,defaultvalue:null}],code:[{type:"500",description:"database error",optional:!1},{type:"400",description:"missing parameters",optional:!1},{type:"200",description:"successfuly updated application",optional:!1}],name:"update",longname:"Bucket.application.update",scope:"route",async:!0},{route:{name:"/api/bucket/:id/applications/:application",type:"DELETE"},params:[{name:":id",type:"string",description:"bucket id",optional:!1},{name:":application",type:"string",description:"application id",optional:!1}],code:[{type:"500",description:"database error",optional:!1},{type:"204",description:"successfuly deleted application",optional:!1}],name:"delete",longname:"Bucket.application.delete",scope:"route",async:!0,authentication:!1},{route:{name:"/api/bucket/:id/applications/:application/preview",type:"GET"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],params:[{name:":id",type:"string",description:"bucket id",optional:!1},{name:":application",type:"string",description:"application id",optional:!1}],code:[{type:"500",description:"database error",optional:!1},{type:"404",description:"preview not found",optional:!1},{type:"200",description:"successfuly retrieved application screenshot",optional:!1}],name:"getPreview",longname:"Bucket.application.getPreview",scope:"route",async:!0},{route:{name:"/api/bucket/:id/applications/:application/report",type:"GET"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],params:[{name:":id",type:"string",description:"bucket id",optional:!1},{name:":application",type:"string",description:"application id",optional:!1}],code:[{type:"500",description:"database error",optional:!1},{type:"404",description:"report not found",optional:!1},{type:"200",description:"successfuly retrieved application report",optional:!1}],name:"getReports",longname:"Bucket.application.getReports",scope:"route",async:!0}],billing:[{route:{name:"/api/bucket/:id/payment/subscribe",type:"POST"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],params:[{name:":id",type:"string",description:"bucket id",optional:!1}],body:[{name:"plan",type:"string",description:"name of the plan to upgrade to",optional:!1,defaultvalue:null},{name:"stripe_token",type:"string",description:"a card token created by stripe",optional:!0,defaultvalue:null},{name:"coupon_id",type:"string",description:"the id of the stripe coupon",optional:!0,defaultvalue:null}],code:[{type:"400",description:"missing/invalid parameters",optional:!1},{type:"403",description:"need a credit card OR not allowed to subscribe to the plan",optional:!1},{type:"500",description:"stripe/database error",optional:!1},{type:"200",description:"succesfully upgraded",optional:!1}],response:[{name:"bucket",type:"object",description:"the bucket object",optional:!1,defaultvalue:null},{name:"subscription",type:"object",description:"the subscription object attached to the subscription",optional:!1,defaultvalue:null}],name:"subscribe",longname:"Bucket.billing.subscribe",scope:"route",async:!0},{route:{name:"/api/bucket/:id/payment/subscribe/:paymentIntent",type:"POST"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],params:[{name:":id",type:"string",description:"bucket id",optional:!1},{name:":paymentIntent",type:"string",description:"paymentIntent id",optional:!1}],body:[{name:"plan",type:"string",description:"name of the plan to upgrade to",optional:!1,defaultvalue:null}],code:[{type:"400",description:"missing/invalid parameters",optional:!1},{type:"500",description:"stripe/database error",optional:!1},{type:"200",description:"succesfully upgraded",optional:!1}],response:[{name:"bucket",type:"object",description:"the bucket object",optional:!1,defaultvalue:null}],name:"paymentIntentSucceed",longname:"Bucket.billing.paymentIntentSucceed",scope:"route",async:!0},{route:{name:"/api/bucket/:id/payment/trial",type:"PUT"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],params:[{name:":id",type:"string",description:"bucket id",optional:!1}],body:[{name:"plan",type:"string",description:"Plan to trial",optional:!1,defaultvalue:null}],code:[{type:"400",description:"can't claim trial",optional:!1},{type:"200",description:"trial launched",optional:!1}],response:[{name:"duration",type:"string",description:"the duration of the trial",optional:!1,defaultvalue:null},{name:"plan",type:"string",description:"the plan of the trial",optional:!1,defaultvalue:null}],name:"startTrial",longname:"Bucket.billing.startTrial",scope:"route",async:!0},{route:{name:"/api/bucket/:id/payment/invoices",type:"GET"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],params:[{name:":id",type:"string",description:"bucket id",optional:!1}],code:[{type:"400",description:"Missing/invalid parameters",optional:!1},{type:"404",description:"This bucket hasn't invoices",optional:!1},{type:"200",description:"succesfully returns invoices",optional:!1}],response:[{name:".",type:"array",description:"array of invoices",optional:!1,defaultvalue:null}],name:"getInvoices",longname:"Bucket.billing.getInvoices",scope:"route"},{route:{name:"/api/bucket/:id/payment/receipts",type:"GET"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],params:[{name:":id",type:"string",description:"bucket id",optional:!1}],code:[{type:"400",description:"Missing/invalid parameters",optional:!1},{type:"404",description:"This bucket hasn't receipts",optional:!1},{type:"200",description:"succesfully returns receipts",optional:!1}],response:[{name:".",type:"array",description:"array of receipts",optional:!1,defaultvalue:null}],name:"getReceipts",longname:"Bucket.billing.getReceipts",scope:"route"},{route:{name:"/api/bucket/:id/payment/subscription",type:"GET"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],params:[{name:":id",type:"string",description:"bucket id",optional:!1}],code:[{type:"404",description:"the bucket doesnt have any subscription",optional:!1},{type:"500",description:"database error",optional:!1},{type:"200",description:"succesfully retrieved the subscription",optional:!1}],response:[{name:".",type:"object",description:"subscription object",optional:!1,defaultvalue:null}],name:"getSubcription",longname:"Bucket.billing.getSubcription",scope:"route"},{route:{name:"/api/bucket/:id/payment/subscription/state",type:"GET"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],params:[{name:":id",type:"string",description:"bucket id",optional:!1}],code:[{type:"404",description:"the bucket doesnt have any subscription",optional:!1},{type:"500",description:"database error",optional:!1},{type:"200",description:"succesfully retrieved the subscription",optional:!1}],response:[{name:"status",type:"string",description:"stripe state of the subscription",optional:!1,defaultvalue:null},{name:"plan",type:"string",description:"stripe plan name of the subscription",optional:!1,defaultvalue:null},{name:"canceled_at",type:"string",description:"if he sub has been cancelled, add the date",optional:!1,defaultvalue:null}],name:"getSubcriptionState",longname:"Bucket.billing.getSubcriptionState",scope:"route",async:!0},{route:{name:"/api/bucket/:id/payment/cards",type:"POST"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],params:[{name:":id",type:"string",description:"bucket id",optional:!1}],body:[{name:"token",type:"string",description:"card token generated by stripe",optional:!1,defaultvalue:null}],code:[{type:"400",description:"missing parameters",optional:!1},{type:"500",description:"stripe error",optional:!1},{type:"200",description:"succesfully added the card",optional:!1}],response:[{name:"data",type:"object",description:"stripe credit card Object",optional:!1,defaultvalue:null}],name:"attachCreditCard",longname:"Bucket.billing.attachCreditCard",scope:"route",async:!0},{route:{name:"/api/bucket/:id/payment/cards",type:"GET"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],params:[{name:":id",type:"string",description:"bucket id",optional:!1}],code:[{type:"500",description:"stripe error",optional:!1},{type:"404",description:"the user doesn't have any default card",optional:!1},{type:"200",description:"succesfully retieved the charges",optional:!1}],response:[{name:"data",type:"array",description:"list of stripe cards object",optional:!1,defaultvalue:null}],name:"fetchCreditCards",longname:"Bucket.billing.fetchCreditCards",scope:"route"},{route:{name:"/api/bucket/:id/payment/card/:card_id",type:"GET"},authentication:!0,params:[{name:":id",type:"string",description:"bucket id",optional:!1},{name:":card_id",type:"string",description:"the stripe id of the card",optional:!1}],header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],code:[{type:"500",description:"stripe error",optional:!1},{type:"400",description:"missing parameters card_id",optional:!1},{type:"404",description:"the user doesn't have any default card",optional:!1},{type:"200",description:"succesfully retieved the card",optional:!1}],response:[{name:"data",type:"array",description:"stripe card object",optional:!1,defaultvalue:null}],name:"fetchCreditCard",longname:"Bucket.billing.fetchCreditCard",scope:"route"},{route:{name:"/api/bucket/:id/payment/card",type:"GET"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],params:[{name:":id",type:"string",description:"bucket id",optional:!1}],code:[{type:"500",description:"stripe error",optional:!1},{type:"404",description:"the user doesn't have any default card",optional:!1},{type:"200",description:"succesfully retieved the card",optional:!1}],response:[{name:"data",type:"array",description:"stripe card object",optional:!1,defaultvalue:null}],name:"fetchDefaultCreditCard",longname:"Bucket.billing.fetchDefaultCreditCard",scope:"route",async:!0},{route:{name:"/api/bucket/:id/payment/card",type:"PUT"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],params:[{name:":id",type:"string",description:"bucket id",optional:!1}],body:[{name:"id",type:"string",description:"stripe card id",optional:!1,defaultvalue:null},{name:"address_line1",type:"string",description:"",optional:!0,defaultvalue:null},{name:"address_country",type:"string",description:"",optional:!0,defaultvalue:null},{name:"address_zip",type:"string",description:"",optional:!0,defaultvalue:null},{name:"address_city",type:"string",description:"",optional:!0,defaultvalue:null}],code:[{type:"500",description:"stripe error",optional:!1},{type:"400",description:"missing parameters, you need to specify a card",optional:!1},{type:"200",description:"succesfully updated the card",optional:!1}],response:[{name:"data",type:"array",description:"stripe card object",optional:!1,defaultvalue:null}],name:"updateCreditCard",longname:"Bucket.billing.updateCreditCard",scope:"route"},{route:{name:"/api/bucket/:id/payment/card/:card_id",type:"DELETE"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],params:[{name:":id",type:"string",description:"bucket id",optional:!1},{name:":card_id",type:"string",description:"the stripe id of the card",optional:!1}],code:[{type:"500",description:"stripe error",optional:!1},{type:"400",description:"missing parameters card_id",optional:!1},{type:"200",description:"succesfully retieved the card",optional:!1},{type:"403",description:"the user must have one card active when having a subscription",optional:!1}],response:[{name:".",type:"object",description:"stripe card object",optional:!1,defaultvalue:null}],name:"deleteCreditCard",longname:"Bucket.billing.deleteCreditCard",scope:"route",async:!0},{route:{name:"/api/bucket/:id/payment/card/:card_id/default",type:"POST"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],params:[{name:":id",type:"string",description:"bucket id",optional:!1},{name:":card_id",type:"string",description:"the stripe id of the card",optional:!1}],code:[{type:"500",description:"stripe error",optional:!1},{type:"400",description:"missing parameters card_id",optional:!1},{type:"200",description:"succesfully set the card as default",optional:!1}],response:[{name:"data",type:"object",description:"stripe card object",optional:!1,defaultvalue:null}],name:"setDefaultCard",longname:"Bucket.billing.setDefaultCard",scope:"route",async:!0},{route:{name:"/api/bucket/:id/payment",type:"GET"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],params:[{name:":id",type:"string",description:"bucket id",optional:!1}],code:[{type:"500",description:"stripe error",optional:!1},{type:"400",description:"missing parameters card_id",optional:!1},{type:"200",description:"succesfully retrieved the metadata",optional:!1}],response:[{name:".",type:"object",description:"stripe metadata object",optional:!1,defaultvalue:null}],name:"fetchMetadata",longname:"Bucket.billing.fetchMetadata",scope:"route"},{route:{name:"/api/bucket/:id/payment",type:"PUT"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],params:[{name:":id",type:"string",description:"bucket id",optional:!1}],body:[{name:"metadata",type:"object",description:"the metadata you can update",optional:!1,defaultvalue:null},{name:"metadata.vat_number",type:"string",description:"",optional:!0,defaultvalue:null},{name:"metadata.company_name",type:"string",description:"",optional:!0,defaultvalue:null},{name:"metadata.receipt_email",type:"string",description:"",optional:!0,defaultvalue:null}],code:[{type:"500",description:"stripe error",optional:!1},{type:"400",description:"missing parameters, you need to specify a card",optional:!1},{type:"200",description:"succesfully updated the card",optional:!1}],response:[{name:"data",type:"array",description:"stripe customer metadata object",optional:!1,defaultvalue:null}],name:"updateMetadata",longname:"Bucket.billing.updateMetadata",scope:"route",async:!0},{route:{name:"/api/bucket/:id/payment/banks",type:"POST"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],params:[{name:":id",type:"string",description:"bucket id",optional:!1}],body:[{name:"iban",type:"string",description:"the iban used to recognize the account",optional:!0,defaultvalue:null},{name:"type",type:"string",description:"the type of the bank account (currently only sepa is available)",optional:!1,defaultvalue:null},{name:"name",type:"string",description:"name of the bank account owner",optional:!1,defaultvalue:null}],code:[{type:"400",description:"missing parameters",optional:!1},{type:"500",description:"stripe error",optional:!1},{type:"200",description:"succesfully added the account",optional:!1}],response:[{name:"data",type:"object",description:"stripe credit card Object",optional:!1,defaultvalue:null}],name:"attachBankAccount",longname:"Bucket.billing.attachBankAccount",scope:"route"},{route:{name:"/api/bucket/:id/payment/banks",type:"GET"},authentication:!0,params:[{name:":id",type:"string",description:"bucket id",optional:!1}],header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],code:[{type:"500",description:"stripe error",optional:!1},{type:"404",description:"the user doesn't have any default account",optional:!1},{type:"200",description:"succesfully retieved the card",optional:!1}],response:[{name:"data",type:"object",description:"stripe source object",optional:!1,defaultvalue:null}],name:"fetchBankAccount",longname:"Bucket.billing.fetchBankAccount",scope:"route"},{route:{name:"/api/bucket/:id/payment/banks",type:"DELETE"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],params:[{name:":id",type:"string",description:"bucket id",optional:!1}],code:[{type:"500",description:"stripe error",optional:!1},{type:"200",description:"succesfully retieved the card",optional:!1},{type:"404",description:"the user doesn't have any default account",optional:!1}],response:[{name:".",type:"object",description:"stripe source object",optional:!1,defaultvalue:null}],name:"deleteBankAccount",longname:"Bucket.billing.deleteBankAccount",scope:"route"}],dashboardschema:[{route:{name:"/api/bucket/:id/dashboardSchema/",type:"PUT"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],params:[{name:":id",type:"string",description:"bucket id",optional:!1}],body:[{name:"name",type:"string",description:"the name of the dashboard",optional:!1,defaultvalue:null},{name:"data",type:"object",description:"the list of component that compose the dashboard",optional:!1,defaultvalue:null},{name:"mode",type:"string",description:"the dashboard mode",optional:!1,defaultvalue:null},{name:"image",type:"object",description:"background image for the dashboard",optional:!1,defaultvalue:null}],code:[{type:"500",description:"database error",optional:!1},{type:"200",description:"succesfully created dashboard",optional:!1},{type:"400",description:"Invalid params",optional:!1}],response:[{name:".",type:"dashboard",description:"complete dashboard object from database",optional:!1,defaultvalue:null}],name:"create",longname:"Bucket.dashboardschema.create",scope:"route"},{route:{name:"/api/bucket/:id/dashboardSchema/",type:"GET"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],params:[{name:":id",type:"string",description:"bucket id",optional:!1}],code:[{type:"500",description:"database error",optional:!1},{type:"200",description:"succesfully retrieved data",optional:!1},{type:"400",description:"Invalid params",optional:!1}],response:[{name:".",type:"array",description:"array of servers status",optional:!1,defaultvalue:null}],name:"retrieveAll",longname:"Bucket.dashboardschema.retrieveAll",scope:"route"},{route:{name:"/api/bucket/:id/dashboardSchema/:dashid/visualization",type:"GET"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],params:[{name:":id",type:"string",description:"bucket id",optional:!1},{name:":dashid",type:"string",description:"dashboard id",optional:!1}],code:[{type:"500",description:"database error",optional:!1},{type:"200",description:"succesfully retrieved data",optional:!1},{type:"404",description:"dashboard not found",optional:!1},{type:"400",description:"Invalid params",optional:!1}],response:[{name:".",type:"array",description:"array of dashboards",optional:!1,defaultvalue:null}],name:"visualization",longname:"Bucket.dashboardschema.visualization",scope:"route"},{route:{name:"/api/bucket/:id/dashboardSchema/:dashid",type:"GET"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],params:[{name:":id",type:"string",description:"bucket id",optional:!1},{name:":dashid",type:"string",description:"dashboard id",optional:!1}],code:[{type:"500",description:"database error",optional:!1},{type:"200",description:"succesfully retrieved data",optional:!1},{type:"404",description:"dashboard not found",optional:!1},{type:"400",description:"Invalid params",optional:!1}],response:[{name:".",type:"array",description:"array of dashboards",optional:!1,defaultvalue:null}],name:"retrieve",longname:"Bucket.dashboardschema.retrieve",scope:"route"},{route:{name:"/api/bucket/:id/dashboardSchema/:dashid",type:"DELETE"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],params:[{name:":id",type:"string",description:"bucket id",optional:!1},{name:":dashid",type:"string",description:"dashboard id",optional:!1}],code:[{type:"500",description:"database error",optional:!1},{type:"200",description:"succesfully deleted dashboard",optional:!1},{type:"400",description:"Invalid params",optional:!1},{type:"404",description:"dashboard not found",optional:!1}],response:[{name:".",type:"array",description:"array of dashboards",optional:!1,defaultvalue:null}],name:"remove",longname:"Bucket.dashboardschema.remove",scope:"route"},{route:{name:"/api/bucket/:id/dashboardSchema/:dashId",type:"POST"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],params:[{name:":id",type:"string",description:"bucket id",optional:!1},{name:":dashId",type:"string",description:"dashboard id",optional:!1}],body:[{name:"name",type:"string",description:"the name of the dashboard",optional:!1,defaultvalue:null},{name:"data",type:"object",description:"the data to populate the dashboard",optional:!1,defaultvalue:null}],code:[{type:"500",description:"database error",optional:!1},{type:"200",description:"succesfully retrieved data",optional:!1},{type:"404",description:"dashboard not found",optional:!1},{type:"400",description:"Invalid params",optional:!1}],response:[{name:".",type:"array",description:"array of servers status",optional:!1,defaultvalue:null}],name:"update",longname:"Bucket.dashboardschema.update",scope:"route"}],server:[{route:{name:"/api/bucket/:id/data/deleteServer",type:"POST"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],params:[{name:":id",type:"string",description:"bucket id",optional:!1}],body:[{name:"server_name",type:"string",description:"the name of server",optional:!1,defaultvalue:null}],code:[{type:"500",description:"database error",optional:!1},{type:"406",description:"require an action before delete",optional:!1},{type:"400",description:"missing or invalid parameters",optional:!1},{type:"200",description:"successfully deleted",optional:!1}],response:[{name:"success",type:"boolean",description:"can be true or false",optional:!1,defaultvalue:null},{name:"msg",type:"string",description:"response",optional:!1,defaultvalue:null}],name:"deleteServer",longname:"Bucket.server.deleteServer",scope:"route"}],webcheck:[{route:{name:"/api/bucket/:id/webchecks/metrics",type:"GET"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],params:[{name:":id",type:"string",description:"bucket id",optional:!1}],code:[{type:"500",description:"database error",optional:!1},{type:"200",description:"successfuly retrieved webchecks metrics",optional:!1}],name:"listMetrics",longname:"Bucket.webcheck.listMetrics",scope:"route"},{route:{name:"/api/bucket/:id/webchecks/regions",type:"GET"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],params:[{name:":id",type:"string",description:"bucket id",optional:!1}],code:[{type:"500",description:"database error",optional:!1},{type:"200",description:"successfuly retrieved webchecks regions",optional:!1}],name:"listRegions",longname:"Bucket.webcheck.listRegions",scope:"route"},{route:{name:"/api/bucket/:id/webchecks/:webcheck/metrics",type:"POST"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],params:[{name:":id",type:"string",description:"bucket id",optional:!1},{name:":webcheck",type:"string",description:"webcheck id",optional:!1}],body:[{name:"start",type:"string",description:"",optional:!0,defaultvalue:null},{name:"metrics",type:"array",description:"",optional:!0,defaultvalue:null},{name:"end",type:"string",description:"",optional:!0,defaultvalue:null}],code:[{type:"500",description:"database error",optional:!1},{type:"200",description:"successfuly retrieved webchecks regions",optional:!1}],name:"getMetrics",longname:"Bucket.webcheck.getMetrics",scope:"route",async:!0},{route:{name:"/api/bucket/:id/webchecks",type:"GET"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],params:[{name:":id",type:"string",description:"bucket id",optional:!1}],query:[{name:"application",type:"string",description:"Application's id to filter",optional:!0,defaultvalue:null}],code:[{type:"500",description:"database error",optional:!1},{type:"200",description:"successfuly retrieved webchecks",optional:!1}],name:"list",longname:"Bucket.webcheck.list",scope:"route"},{route:{name:"/api/bucket/:id/webchecks/:webcheck",type:"GET"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],params:[{name:":id",type:"string",description:"bucket id",optional:!1},{name:":webcheck",type:"string",description:"webcheck id",optional:!1}],code:[{type:"500",description:"database error",optional:!1},{type:"404",description:"webcheck not found",optional:!1},{type:"200",description:"successfuly retrieved webcheck",optional:!1}],name:"get",longname:"Bucket.webcheck.get",scope:"route"},{route:{name:"/api/bucket/:id/webchecks",type:"POST"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],params:[{name:":id",type:"string",description:"bucket id",optional:!1}],body:[{name:"name",type:"string",description:"Webcheck name",optional:!1,defaultvalue:null},{name:"enabled",type:"boolean",description:"Webcheck's state",optional:!0,defaultvalue:null},{name:"target",type:"object",description:"",optional:!1,defaultvalue:null},{name:"target.type",type:"string",description:"Should be `http`, `https` or `tcp`",optional:!0,defaultvalue:null},{name:"target.port",type:"number",description:"Target's port",optional:!0,defaultvalue:null},{name:"target.address",type:"string",description:"Target's IP/domain",optional:!0,defaultvalue:null},{name:"target.path",type:"string",description:"HTTP Path (only for http/https)",optional:!0,defaultvalue:null},{name:"target.is_frontend",type:"boolean",description:"Enable or disable frontend metrics (via puppeteer)",optional:!0,defaultvalue:null},{name:"body",type:"string",description:"Body need to match this regex to succeed webcheck (only for http/https)",optional:!0,defaultvalue:null},{name:"interval",type:"number",description:"Webcheck's interval check (ms)",optional:!1,defaultvalue:null},{name:"timeout",type:"number",description:"Webcheck's timeout (ms)",optional:!1,defaultvalue:null},{name:"source",type:"object",description:"",optional:!1,defaultvalue:null},{name:"source.region",type:"string",description:"Webcheck's worker region",optional:!0,defaultvalue:null},{name:"retry",type:"object",description:"",optional:!1,defaultvalue:null},{name:"retry.max",type:"number",description:"Max webcheck's retry before mark as failed",optional:!0,defaultvalue:null},{name:"retry.interval",type:"number",description:"Webcheck's retry interval (ms)",optional:!0,defaultvalue:null},{name:"alerts",type:"object",description:"List of alerts (cf. Alert type)",optional:!1,defaultvalue:null},{name:"application",type:"string",description:"Application's id",optional:!0,defaultvalue:null}],code:[{type:"500",description:"database error",optional:!1},{type:"400",description:"missing parameters",optional:!1},{type:"200",description:"successfuly created webcheck",optional:!1}],name:"create",longname:"Bucket.webcheck.create",scope:"route"},{route:{name:"/api/bucket/:id/webchecks/:webcheck",type:"PUT"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],params:[{name:":id",type:"string",description:"bucket id",optional:!1},{name:":webcheck",type:"string",description:"webcheck id",optional:!1}],body:[{name:"name",type:"string",description:"Webcheck name",optional:!0,defaultvalue:null},{name:"enabled",type:"boolean",description:"Webcheck's state",optional:!0,defaultvalue:null},{name:"target",type:"object",description:"",optional:!0,defaultvalue:null},{name:"target.type",type:"string",description:"Should be `http`, `https` or `tcp`",optional:!0,defaultvalue:null},{name:"target.port",type:"number",description:"Target's port",optional:!0,defaultvalue:null},{name:"target.address",type:"string",description:"Target's IP/domain",optional:!0,defaultvalue:null},{name:"target.path",type:"string",description:"HTTP Path (only for http/https)",optional:!0,defaultvalue:null},{name:"target.is_frontend",type:"boolean",description:"Enable or disable frontend metrics (via puppeteer)",optional:!0,defaultvalue:null},{name:"body",type:"string",description:"Body need to match this regex to succeed webcheck (only for http/https)",optional:!0,defaultvalue:null},{name:"interval",type:"number",description:"Webcheck's interval check (ms)",optional:!0,defaultvalue:null},{name:"timeout",type:"number",description:"Webcheck's timeout (ms)",optional:!0,defaultvalue:null},{name:"source",type:"object",description:"",optional:!0,defaultvalue:null},{name:"source.region",type:"string",description:"Webcheck's worker region",optional:!0,defaultvalue:null},{name:"retry",type:"object",description:"",optional:!0,defaultvalue:null},{name:"retry.max",type:"number",description:"Max webcheck's retry before mark as failed",optional:!0,defaultvalue:null},{name:"retry.interval",type:"number",description:"Webcheck's retry interval (ms)",optional:!0,defaultvalue:null},{name:"alerts",type:"object",description:"List of alerts (cf. Alert type)",optional:!0,defaultvalue:null},{name:"application",type:"string",description:"Application's id",optional:!0,defaultvalue:null}],code:[{type:"500",description:"database error",optional:!1},{type:"400",description:"missing parameters",optional:!1},{type:"200",description:"successfuly updated webcheck",optional:!1}],name:"update",longname:"Bucket.webcheck.update",scope:"route"},{route:{name:"/api/bucket/:id/webchecks/:webcheck",type:"DELETE"},params:[{name:":id",type:"string",description:"bucket id",optional:!1},{name:":webcheck",type:"string",description:"webcheck id",optional:!1}],code:[{type:"500",description:"database error",optional:!1},{type:"204",description:"successfuly deleted webcheck",optional:!1}],name:"delete",longname:"Bucket.webcheck.delete",scope:"route",authentication:!1}],default:[{route:{name:"/api/bucket/:id/feedback",type:"PUT"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],params:[{name:":id",type:"string",description:"bucket id",optional:!1}],body:[{name:"feedback",type:"string",description:"the feedback text",optional:!1,defaultvalue:null}],code:[{type:"500",description:"database error",optional:!1},{type:"400",description:"missing feedback field",optional:!1},{type:"200",description:"succesfully registered the feedback",optional:!1}],response:[{name:"feedback",type:"string",description:"the feedback that hasn't been registered",optional:!1,defaultvalue:null}],name:"sendFeedback",longname:"Bucket.sendFeedback",scope:"route"},{name:"retrieveUsers",route:{name:"/api/bucket/:id/users_authorized",type:"GET"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],params:[{name:":id",type:"string",description:"bucket id",optional:!1}],code:[{type:"500",description:"database error",optional:!1},{type:"200",description:"succesfully retrieved bucket's members",optional:!1}],response:[{name:".",type:"array",description:"a array of user containing their email, username and roles",optional:!1,defaultvalue:null}],longname:"Bucket.retrieveUsers",scope:"route"},{name:"currentRole",route:{name:"/api/bucket/:id/current_role",type:"GET"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],params:[{name:":id",type:"string",description:"bucket id",optional:!1}],code:[{type:"200",description:"succesfully retrieved the use role",optional:!1}],response:[{name:"role",type:"string",description:"the user role",optional:!1,defaultvalue:null}],longname:"Bucket.currentRole",scope:"route"},{route:{name:"/api/bucket/:id/manage_notif",type:"POST"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],params:[{name:":id",type:"string",description:"bucket id",optional:!1}],body:[{name:"email",type:"string",description:"the user email",optional:!1,defaultvalue:null},{name:"state",type:"string",description:"the notification state you want to set for that user\n (either 'email' or 'nonde)",optional:!1,defaultvalue:null}],code:[{type:"500",description:"database error",optional:!1},{type:"404",description:"user not found",optional:!1}],response:[{name:".",type:"array",description:"array of state for each user",optional:!1,defaultvalue:null}],name:"setNotificationState",longname:"Bucket.setNotificationState",scope:"route"},{name:"inviteUser",route:{name:"/api/bucket/:id/add_user",type:"POST"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],params:[{name:":id",type:"string",description:"bucket id",optional:!1}],body:[{name:"email",type:"string",description:"the email of the user",optional:!1,defaultvalue:null}],code:[{type:"400",description:"missing/invalid parameters",optional:!1},{type:"403",description:"you cant invit more users because you hit the bucket limit",optional:!1},{type:"200",description:"succesfully invited the user (either directly or by email)",optional:!1}],response:[{name:"invitations",type:"array",description:"the list of invitations actually active",optional:!1,defaultvalue:null}],longname:"Bucket.inviteUser",scope:"route"},{route:{name:"/api/bucket/:id/invitation",type:"DELETE"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],params:[{name:":id",type:"string",description:"bucket id",optional:!1}],query:[{name:"email",type:"string",description:"the email of the invitation you want to delete",optional:!0,defaultvalue:null}],code:[{type:"400",description:"invalid/missing parameters",optional:!1},{type:"500",description:"database error",optional:!1},{type:"200",description:"succesfully deleted the invitation",optional:!1}],response:[{name:"invitations",type:"array",description:"the list of invitations actually active",optional:!1,defaultvalue:null}],name:"removeInvitation",longname:"Bucket.removeInvitation",scope:"route"},{route:{name:"/api/bucket/:id/remove_user",type:"POST"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],params:[{name:":id",type:"string",description:"bucket id",optional:!1}],body:[{name:"email",type:"string",description:"the email of the user you want to remove",optional:!1,defaultvalue:null}],code:[{type:"400",description:"missing/invalid parameters",optional:!1},{type:"404",description:"user not found",optional:!1},{type:"403",description:"impossible to remove the owner from the bucket",optional:!1},{type:"500",description:"database error",optional:!1}],response:[{name:".",type:"array",description:"a array of user containing their email, username and roles",optional:!1,defaultvalue:null}],name:"removeUser",longname:"Bucket.removeUser",scope:"route"},{route:{name:"/api/bucket/:id/promote_user",type:"POST"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],params:[{name:":id",type:"string",description:"bucket id",optional:!1}],body:[{name:"email",type:"string",description:"the email of the user you want to change the role",optional:!1,defaultvalue:null},{name:"role",type:"string",description:"the role you want to set",optional:!1,defaultvalue:null}],code:[{type:"400",description:"invalid/missing parameters",optional:!1},{type:"404",description:"user not found",optional:!1},{type:"403",description:"impossible to set the role of the owner",optional:!1}],response:[{name:".",type:"array",description:"a array of user containing their email, username and roles",optional:!1,defaultvalue:null}],name:"setUserRole",longname:"Bucket.setUserRole",scope:"route"},{name:"retrieveAll",route:{name:"/api/bucket/",type:"GET"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],code:[{type:"500",description:"database error",optional:!1},{type:"200",description:"succesfully fetched bucket",optional:!1}],response:[{name:".",type:"array",description:"array of buckets",optional:!1,defaultvalue:null}],longname:"Bucket.retrieveAll",scope:"route"},{name:"create",route:{name:"/api/bucket/create_classic",type:"POST"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],body:[{name:"name",type:"string",description:"the name of the bucket",optional:!1,defaultvalue:null},{name:"comment",type:"string",description:"any comments that will be written under the bucket name",optional:!0,defaultvalue:null},{name:"app_url",type:"string",description:"",optional:!0,defaultvalue:null}],code:[{type:"400",description:"missing parameters",optional:!1},{type:"403",description:"you cant create any more bucket",optional:!1},{type:"500",description:"database error",optional:!1},{type:"200",description:"succesfully created a bucket",optional:!1}],response:[{name:"bucket",type:"object",description:"the created bucket",optional:!1,defaultvalue:null}],longname:"Bucket.create",scope:"route"},{deprecated:!0,route:{name:"/api/bucket/:id/start_trial",type:"PUT"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],params:[{name:":id",type:"string",description:"bucket id",optional:!1}],code:[{type:"400",description:"can't claim trial",optional:!1},{type:"200",description:"trial launched",optional:!1}],response:[{name:"duration",type:"string",description:"the duration of the trial",optional:!1,defaultvalue:null},{name:"plan",type:"string",description:"the plan of the trial",optional:!1,defaultvalue:null}],name:"claimTrial",longname:"Bucket.claimTrial",scope:"route"},{deprecated:!0,name:"upgrade",route:{name:"/api/bucket/:id/upgrade",type:"POST"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],params:[{name:":id",type:"string",description:"bucket id",optional:!1}],body:[{name:"plan",type:"string",description:"name of the plan to upgrade to",optional:!1,defaultvalue:null},{name:"stripe_token",type:"string",description:"a card token created by stripe",optional:!0,defaultvalue:null},{name:"coupon_id",type:"string",description:"the id of the stripe coupon",optional:!0,defaultvalue:null}],code:[{type:"400",description:"missing/invalid parameters",optional:!1},{type:"403",description:"need a credit card OR not allowed to subscribe to the plan",optional:!1},{type:"500",description:"stripe/database error",optional:!1},{type:"200",description:"succesfully upgraded",optional:!1}],response:[{name:"bucket",type:"object",description:"the bucket object",optional:!1,defaultvalue:null},{name:"subscription",type:"object",description:"the subscription object attached to the subscription",optional:!1,defaultvalue:null}],longname:"Bucket.upgrade",scope:"route"},{name:"retrieve",route:{name:"/api/bucket/:id",type:"GET"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],params:[{name:":id",type:"string",description:"bucket id",optional:!1}],code:[{type:"200",description:"succesfully retrieved the bucket",optional:!1}],response:[{name:".",type:"object",description:"bucket object",optional:!1,defaultvalue:null}],longname:"Bucket.retrieve",scope:"route"},{route:{name:"/api/bucket/:id",type:"PUT"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],params:[{name:":id",type:"string",description:"bucket id",optional:!1}],body:[{name:"name",type:"string",description:"",optional:!0,defaultvalue:null},{name:"comment",type:"string",description:"",optional:!0,defaultvalue:null},{name:"app_url",type:"string",description:"",optional:!0,defaultvalue:null},{name:"configuration",type:"string",description:"",optional:!0,defaultvalue:null}],code:[{type:"500",description:"database error",optional:!1},{type:"400",description:"missing parameters",optional:!1}],response:[{name:".",type:"object",description:"bucket object",optional:!1,defaultvalue:null}],name:"update",longname:"Bucket.update",scope:"route",async:!0},{name:"retrieveServers",route:{name:"/api/bucket/:id/meta_servers",type:"GET"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],params:[{name:":id",type:"string",description:"bucket id",optional:!1}],code:[{type:"500",description:"database error",optional:!1},{type:"200",description:"succesfully retrieved the server's metadata",optional:!1}],response:[{name:".",type:"array",description:"servers metadata",optional:!1,defaultvalue:null}],longname:"Bucket.retrieveServers",scope:"route"},{route:{name:"/api/bucket/:id",type:"DELETE"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],params:[{name:":id",type:"string",description:"bucket id",optional:!1}],code:[{type:"500",description:"database error",optional:!1},{type:"200",description:"succesfully deleted the bucket",optional:!1}],response:[{name:".",type:"object",description:"the deleted bucket",optional:!1,defaultvalue:null}],name:"destroy",longname:"Bucket.destroy",scope:"route"},{route:{name:"/api/bucket/:id/transfer_ownership",type:"POST"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],params:[{name:":id",type:"string",description:"bucket id",optional:!1}],body:[{name:"new_owner",type:"string",description:"the wanted owner's email",optional:!1,defaultvalue:null}],code:[{type:"400",description:"Missing/invalid parameters",optional:!1},{type:"404",description:"user not found",optional:!1},{type:"403",description:"the new owner need to have a active credit card",optional:!1},{type:"200",description:"succesfully transfered the bucket, old owner is now admin",optional:!1}],response:[{name:".",type:"object",description:"bucket object",optional:!1,defaultvalue:null}],name:"transferOwnership",longname:"Bucket.transferOwnership",scope:"route"},{route:{name:"/api/bucket/:id/user_options",type:"PUT"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],params:[{name:":id",type:"string",description:"bucket id",optional:!1}],body:[{name:"options",type:"object",description:"user options",optional:!1,defaultvalue:null}],code:[{type:"200",description:"succesfully update user options",optional:!1},{type:"400",description:"missing parameters",optional:!1}],response:[{name:"bucket",type:"object",description:"",optional:!1,defaultvalue:null}],name:"updateUserOptions",longname:"Bucket.updateUserOptions",scope:"route"}]},dashboard:[{route:{name:"/api/bucket/:id/dashboard/",type:"GET"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],params:[{name:":id",type:"string",description:"bucket id",optional:!1}],code:[{type:"500",description:"database error",optional:!1},{type:"200",description:"succesfully retrieved data",optional:!1},{type:"400",description:"Invalid params",optional:!1}],response:[{name:".",type:"array",description:"array of servers status",optional:!1,defaultvalue:null}],name:"retrieveAll",longname:"Dashboard.retrieveAll",scope:"route"},{route:{name:"/api/bucket/:id/dashboard/:dashid",type:"GET"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],params:[{name:":id",type:"string",description:"bucket id",optional:!1},{name:":dashid",type:"string",description:"dashboard id",optional:!1}],code:[{type:"500",description:"database error",optional:!1},{type:"200",description:"succesfully retrieved data",optional:!1},{type:"404",description:"dashboard not found",optional:!1},{type:"400",description:"Invalid params",optional:!1}],response:[{name:".",type:"array",description:"array of dashboards",optional:!1,defaultvalue:null}],name:"retrieve",longname:"Dashboard.retrieve",scope:"route"},{route:{name:"/api/bucket/:id/dashboard/:dashid",type:"DELETE"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],params:[{name:":id",type:"string",description:"bucket id",optional:!1},{name:":dashid",type:"string",description:"dashboard id",optional:!1}],code:[{type:"500",description:"database error",optional:!1},{type:"200",description:"succesfully deleted dashboard",optional:!1},{type:"400",description:"Invalid params",optional:!1},{type:"404",description:"dashboard not found",optional:!1}],response:[{name:".",type:"array",description:"array of dashboards",optional:!1,defaultvalue:null}],name:"remove",longname:"Dashboard.remove",scope:"route"},{route:{name:"/api/bucket/:id/dashboard/:dashId",type:"POST"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],params:[{name:":id",type:"string",description:"bucket id",optional:!1},{name:":dashId",type:"string",description:"dashboard id",optional:!1}],body:[{name:"name",type:"string",description:"the name of the dashboard",optional:!1,defaultvalue:null},{name:"children",type:"object",description:"the list of component that compose the dashboard",optional:!1,defaultvalue:null}],code:[{type:"500",description:"database error",optional:!1},{type:"200",description:"succesfully retrieved data",optional:!1},{type:"404",description:"dashboard not found",optional:!1},{type:"400",description:"Invalid params",optional:!1}],response:[{name:".",type:"array",description:"array of servers status",optional:!1,defaultvalue:null}],name:"update",longname:"Dashboard.update",scope:"route"},{route:{name:"/api/bucket/:id/dashboard/",type:"PUT"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],params:[{name:":id",type:"string",description:"bucket id",optional:!1}],body:[{name:"name",type:"string",description:"the name of the dashboard",optional:!1,defaultvalue:null},{name:"children",type:"object",description:"the list of component that compose the dashboard",optional:!1,defaultvalue:null}],code:[{type:"500",description:"database error",optional:!1},{type:"200",description:"succesfully created dashboard",optional:!1},{type:"400",description:"Invalid params",optional:!1}],response:[{name:".",type:"dashboard",description:"complete dashboard object from database",optional:!1,defaultvalue:null}],name:"create",longname:"Dashboard.create",scope:"route"}],data:{dependencies:[{route:{name:"/api/bucket/:id/data/dependencies/",type:"POST"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],params:[{name:":id",type:"string",description:"bucket id",optional:!1}],body:[{name:"app_name",type:"string",description:"the application name",optional:!1,defaultvalue:null},{name:"server_name",type:"string",description:"filter by server name",optional:!0,defaultvalue:null}],code:[{type:"500",description:"database error",optional:!1},{type:"200",description:"succesfully retrieved data",optional:!1},{type:"400",description:"missing parameters",optional:!1}],response:[{name:".",type:"array",description:"recorded dependencies",optional:!1,defaultvalue:null}],examples:["km.data.dependencies.retrieve(bucket._id, {\n app_name: 'my_api'\n })"],name:"retrieve",longname:"Data.dependencies.retrieve",scope:"route"}],events:[{route:{name:"/api/bucket/:id/data/events",type:"POST"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],params:[{name:":id",type:"string",description:"bucket id",optional:!1}],body:[{name:"event_name",type:"string",description:"the event name to retrieve",optional:!1,defaultvalue:null},{name:"start",type:"date",description:"from which date to retrieve events",optional:!0,defaultvalue:null},{name:"end",type:"date",description:"to which date to retrieve events",optional:!0,defaultvalue:null},{name:"app_name",type:"string",description:"filter events by app source",optional:!0,defaultvalue:null},{name:"server_name",type:"string",description:"filter events by server source",optional:!0,defaultvalue:null},{name:"limit",type:"number",description:"limit the number of events to retrieve",optional:!0,defaultvalue:100},{name:"offset",type:"number",description:"offset research by X",optional:!0,defaultvalue:0}],code:[{type:"500",description:"database error",optional:!1},{type:"400",description:"invalid parameters",optional:!1},{type:"200",description:"succesfully retrieved data",optional:!1}],response:[{name:".",type:"array",description:"array of events",optional:!1,defaultvalue:null}],name:"retrieve",longname:"Data.events.retrieve",scope:"route"},{route:{name:"/api/bucket/:id/data/eventsKeysByApp",type:"GET"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],params:[{name:":id",type:"string",description:"bucket id",optional:!1}],code:[{type:"500",description:"database error",optional:!1},{type:"400",description:"invalid parameters",optional:!1},{type:"200",description:"succesfully retrieved data",optional:!1}],response:[{name:".",type:"array",description:"array of object representing events emitted for each application name",optional:!1,defaultvalue:null}],name:"retrieveMetadatas",longname:"Data.events.retrieveMetadatas",scope:"route"},{route:{name:"/api/bucket/:id/data/events/stats",type:"POST"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],params:[{name:":id",type:"string",description:"bucket id",optional:!1}],body:[{name:"event_name",type:"string",description:"the event name to retrieve",optional:!1,defaultvalue:null},{name:"app_name",type:"string",description:"filter events by app source",optional:!0,defaultvalue:null},{name:"server_name",type:"string",description:"filter events by server source",optional:!0,defaultvalue:null},{name:"days",type:"number",description:"limit the number of days of data",optional:!0,defaultvalue:2},{name:"interval",type:"string",description:"interval of time between two point",optional:!0,defaultvalue:"minute"}],code:[{type:"500",description:"database error",optional:!1},{type:"400",description:"invalid parameters",optional:!1},{type:"200",description:"succesfully retrieved data",optional:!1}],response:[{name:".",type:"array",description:"array of point (each point is one dimensional array, X are at 0 and Y at 1)",optional:!1,defaultvalue:null}],name:"retrieveHistogram",longname:"Data.events.retrieveHistogram",scope:"route"},{route:{name:"/api/bucket/:id/data/events/delete_all",type:"DELETE"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],params:[{name:":id",type:"string",description:"bucket id",optional:!1}],code:[{type:"500",description:"database error",optional:!1},{type:"200",description:"succesfully deleted data",optional:!1}],response:[{name:".",type:"array",description:"array of object representing events emitted for each application name",optional:!1,defaultvalue:null}],name:"deleteAll",longname:"Data.events.deleteAll",scope:"route"}],exceptions:[{route:{name:"/api/bucket/:id/data/exceptions",type:"POST"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],params:[{name:":id",type:"string",description:"bucket id",optional:!1}],body:[{name:"server_name",type:"string",description:"filter exceptions by server source",optional:!0,defaultvalue:null},{name:"app_name",type:"string",description:"filter exceptions by app source",optional:!0,defaultvalue:null},{name:"before",type:"string",description:"filter out exceptions older than X (in minutes)",optional:!0,defaultvalue:null}],code:[{type:"500",description:"database error",optional:!1},{type:"200",description:"succesfully retrieved data",optional:!1}],response:[{name:".",type:"array",description:"array of exceptions",optional:!1,defaultvalue:null}],name:"retrieve",longname:"Data.exceptions.retrieve",scope:"route"},{route:{name:"/api/bucket/:id/data/exceptions/summary",type:"GET"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],params:[{name:":id",type:"string",description:"bucket id",optional:!1}],code:[{type:"500",description:"database error",optional:!1},{type:"200",description:"succesfully retrieved data",optional:!1}],response:[{name:".",type:"array",description:"array of object containing exceptions for each application for each server",optional:!1,defaultvalue:null}],name:"retrieveSummary",longname:"Data.exceptions.retrieveSummary",scope:"route"},{route:{name:"/api/bucket/:id/data/exceptions/delete_all",type:"POST"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],params:[{name:":id",type:"string",description:"bucket id",optional:!1}],code:[{type:"500",description:"database error",optional:!1},{type:"200",description:"succesfully retrieved data",optional:!1}],name:"deleteAll",longname:"Data.exceptions.deleteAll",scope:"route"},{route:{name:"/api/bucket/:id/data/exceptions/delete",type:"POST"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],params:[{name:":id",type:"string",description:"bucket id",optional:!1}],body:[{name:"identifier",type:"string",description:"exception identifier",optional:!0,defaultvalue:null},{name:"app_name",type:"string",description:"the application on which exception happened",optional:!0,defaultvalue:null},{name:"server_name",type:"string",description:"the server on which exception happened",optional:!0,defaultvalue:null}],code:[{type:"500",description:"database error",optional:!1},{type:"200",description:"succesfully retrieved data",optional:!1},{type:"400",description:"missing/invalid parameters",optional:!1}],response:[{name:".",type:"array",description:"array of deleted exceptions",optional:!1,defaultvalue:null}],name:"delete",longname:"Data.exceptions.delete",scope:"route"}],issues:[{route:{name:"/api/bucket/:id/data/issues/list",type:"POST"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],params:[{name:":id",type:"string",description:"bucket id",optional:!1}],body:[{name:"server_name",type:"string",description:"filter exceptions by server source",optional:!0,defaultvalue:null},{name:"app_name",type:"string",description:"filter exceptions by app source needed if initiator+source not provided",optional:!0,defaultvalue:null},{name:"before",type:"string",description:"exclude exceptions older than 'before' minutes",optional:!0,defaultvalue:null},{name:"initiator",type:"string",description:"filter exceptions by initiator (node/golang/browser/webcheck...) needed with source",optional:!0,defaultvalue:null},{name:"source",type:"string",description:"filter exceptions by source (browser app id, webcheck id...)",optional:!0,defaultvalue:null},{name:"tags",type:"array",description:"array of string to filter tags",optional:!0,defaultvalue:null}],code:[{type:"500",description:"database error",optional:!1},{type:"200",description:"succesfully retrieved data",optional:!1}],response:[{name:".",type:"array",description:"array of exceptions",optional:!1,defaultvalue:null}],name:"list",longname:"Data.issues.list",scope:"route",async:!0},{route:{name:"/api/bucket/:id/data/issues/occurrences/:identifier",type:"GET"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],params:[{name:":id",type:"string",description:"bucket id",optional:!1},{name:":identifier",type:"string",description:"issue identifier",optional:!1}],query:[{name:"from",type:"number",description:"",optional:!0,defaultvalue:null},{name:"search_after",type:"number",description:"",optional:!0,defaultvalue:null}],code:[{type:"500",description:"database error",optional:!1},{type:"200",description:"succesfully retrieved data",optional:!1}],response:[{name:".",type:"array",description:"array of occurrences id",optional:!1,defaultvalue:null}],name:"listOccurencesForIdentifier",longname:"Data.issues.listOccurencesForIdentifier",scope:"route",async:!0},{route:{name:"/api/bucket/:id/data/issues/replay/:uuid",type:"GET"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],params:[{name:":id",type:"string",description:"bucket id",optional:!1},{name:":uuid",type:"string",description:"replay id",optional:!1}],code:[{type:"500",description:"database error",optional:!1},{type:"200",description:"succesfully retrieved data",optional:!1}],response:[{name:"replay",type:"string",description:"",optional:!1,defaultvalue:null}],name:"getReplay",longname:"Data.issues.getReplay",scope:"route",async:!0},{route:{name:"/api/bucket/:id/data/issues/histogram",type:"POST"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],params:[{name:":id",type:"string",description:"bucket id",optional:!1}],body:[{name:"app_name",type:"string",description:"a specific app name",optional:!0,defaultvalue:null},{name:"start",type:"string",description:"ignore issue before this date",optional:!0,defaultvalue:null},{name:"identifier",type:"string",description:"a specific issue identifier",optional:!0,defaultvalue:null},{name:"interval",type:"string",description:"ignore issue before this date",optional:!0,defaultvalue:null},{name:"end",type:"string",description:"ignore issue after this date",optional:!0,defaultvalue:null},{name:"includeFixed",type:"boolean",description:"choose to ignore or not the fixed occurences",optional:!0,defaultvalue:!1},{name:"initiator",type:"string",description:"filter exceptions by initiator (node/golang/browser/webcheck...) needed with source",optional:!0,defaultvalue:null},{name:"source",type:"string",description:"filter exceptions by source (browser app id, webcheck id...)",optional:!0,defaultvalue:null},{name:"tags",type:"array",description:"array of string to filter tags",optional:!0,defaultvalue:null},{name:"includeEmptyDocs",type:"boolean",description:"add empty docs",optional:!0,defaultvalue:!1},{name:"invertedTags",type:"boolean",description:"filter issue without tags",optional:!0,defaultvalue:!1}],code:[{type:"500",description:"database error",optional:!1},{type:"200",description:"succesfully retrieved data",optional:!1}],response:[{name:".",type:"array",description:"array of object containing exceptions for each application for each server",optional:!1,defaultvalue:null}],name:"retrieveHistogram",longname:"Data.issues.retrieveHistogram",scope:"route"},{route:{name:"/api/bucket/:id/data/issues/ocurrences",type:"POST"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],params:[{name:":id",type:"string",description:"bucket id",optional:!1}],body:[{name:"identifier",type:"object",description:"find occurence by using an issue identifier",optional:!0,defaultvalue:null},{name:"occurrence_id",type:"object",description:"find ocurrence by his id",optional:!0,defaultvalue:null},{name:"includeFixed",type:"boolean",description:"choose to ignore or not the fixed occurences",optional:!0,defaultvalue:!1},{name:"limit",type:"number",description:"limit",optional:!0,defaultvalue:null}],code:[{type:"500",description:"database error",optional:!1},{type:"200",description:"succesfully retrieved data",optional:!1}],response:[{name:".",type:"array",description:"array of object containing ocurrences",optional:!1,defaultvalue:null}],name:"findOccurences",longname:"Data.issues.findOccurences",scope:"route",async:!0},{route:{name:"/api/bucket/:id/data/issues/search",type:"POST"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],params:[{name:":id",type:"string",description:"bucket id",optional:!1}],body:[{name:"message",type:"string",description:"find occurence that match this message",optional:!1,defaultvalue:null},{name:"includeFixed",type:"boolean",description:"choose to ignore or not the fixed occurences",optional:!0,defaultvalue:!1}],code:[{type:"500",description:"database error",optional:!1},{type:"200",description:"succesfully retrieved data",optional:!1}],response:[{name:".",type:"array",description:"array of object containing exceptions for each application for each server",optional:!1,defaultvalue:null}],name:"search",longname:"Data.issues.search",scope:"route"},{route:{name:"/api/bucket/:id/data/issues/summary/:aggregateBy",type:"GET"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],params:[{name:":id",type:"string",description:"bucket id",optional:!1},{name:":aggregateBy",type:"string",description:"servers, apps, initiators or sources",optional:!1}],code:[{type:"500",description:"database error",optional:!1},{type:"200",description:"succesfully retrieved data",optional:!1}],response:[{name:".",type:"array",description:"issues count aggregated",optional:!1,defaultvalue:null}],name:"summary",longname:"Data.issues.summary",scope:"route",async:!0},{route:{name:"/api/bucket/:id/data/issues",type:"DELETE"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],params:[{name:":id",type:"string",description:"bucket id",optional:!1}],query:[{name:"app_name",type:"string",description:"an specific application to delete application",optional:!0,defaultvalue:null}],code:[{type:"500",description:"database error",optional:!1},{type:"200",description:"succesfully retrieved data",optional:!1}],name:"deleteAll",longname:"Data.issues.deleteAll",scope:"route"},{route:{name:"/api/bucket/:id/data/issues/:identifier",type:"DELETE"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],params:[{name:":id",type:"string",description:"bucket id",optional:!1},{name:":identifier",type:"string",description:"the identifier of issue that you want to delete",optional:!1}],code:[{type:"500",description:"database error",optional:!1},{type:"200",description:"succesfully retrieved data",optional:!1},{type:"400",description:"missing/invalid parameters",optional:!1}],response:[{name:".",type:"array",description:"array of deleted exceptions",optional:!1,defaultvalue:null}],name:"delete",longname:"Data.issues.delete",scope:"route"}],logs:[{route:{name:"/api/bucket/:id/data/logs",type:"POST"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],params:[{name:":id",type:"string",description:"bucket id",optional:!1}],body:[{name:"app_name",type:"string",description:"the application name",optional:!0,defaultvalue:null},{name:"server_name",type:"string",description:"filter by server name",optional:!0,defaultvalue:null},{name:"before",type:"string",description:"only search log oldest than ",optional:!0,defaultvalue:null},{name:"after",type:"string",description:"only search log newer than ",optional:!0,defaultvalue:null},{name:"size",type:"integer",description:"line limit, default to 100",optional:!0,defaultvalue:null},{name:"from",type:"integer",description:"offset limit",optional:!0,defaultvalue:null}],code:[{type:"500",description:"database error",optional:!1},{type:"200",description:"succesfully retrieved data",optional:!1},{type:"400",description:"missing parameters",optional:!1}],response:[{name:".",type:"array",description:"recorded dependencies",optional:!1,defaultvalue:null}],examples:["km.data.logs.retrieve(bucket._id, {\n app_name: 'my_api'\n })"],name:"retrieve",longname:"Data.logs.retrieve",scope:"route"},{route:{name:"/api/bucket/:id/data/logs/histogram",type:"POST"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],params:[{name:":id",type:"string",description:"bucket id",optional:!1}],body:[{name:"app_name",type:"object",description:"a specific app name",optional:!0,defaultvalue:null},{name:"start",type:"object",description:"ignore log before this date",optional:!0,defaultvalue:null},{name:"interval",type:"object",description:"ignore log before this date",optional:!0,defaultvalue:null},{name:"end",type:"object",description:"ignore log after this date",optional:!0,defaultvalue:null}],code:[{type:"500",description:"database error",optional:!1},{type:"200",description:"succesfully retrieved data",optional:!1}],response:[{name:".",type:"array",description:"array of object containing exceptions for each application for each server",optional:!1,defaultvalue:null}],name:"retrieveHistogram",longname:"Data.logs.retrieveHistogram",scope:"route"}],metrics:[{route:{name:"/api/bucket/:id/data/metrics/aggregations",type:"POST"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],params:[{name:":id",type:"string",description:"bucket id",optional:!1}],body:[{name:"aggregations",type:"object",description:"array of aggregations to compute",optional:!1,defaultvalue:null},{name:"aggregations[].name",type:"string",description:"the name of metric to compute the graph",optional:!1,defaultvalue:null},{name:"aggregations[].types",type:"array",description:"type of aggregation (e.g. ['histogram', 'servers'])",optional:!1,defaultvalue:null},{name:"aggregations[].start",type:"date",description:"oldest documents to aggregate on",optional:!1,defaultvalue:null},{name:"aggregations[].end",type:"date",description:"newest documents to aggregate on",optional:!0,defaultvalue:null},{name:"aggregations[].apps",type:"array",description:"filter source applications to aggregate on",optional:!0,defaultvalue:null},{name:"aggregations[].interval",type:"number",description:"interval between two points",optional:!0,defaultvalue:null},{name:"aggregations[].servers",type:"array",description:"filter source server to aggregate on",optional:!0,defaultvalue:null},{name:"aggregations[].initiator",type:"string",description:"filter source initiator to aggregate on",optional:!0,defaultvalue:null},{name:"aggregations[].webcheck",type:"string",description:"filter source webcheck to aggregate on",optional:!0,defaultvalue:null},{name:"aggregations[].collector",type:"string",description:"filter source collector to aggregate on",optional:!0,defaultvalue:null},{name:"aggregations[].tags",type:"array",description:"filter tags to aggregate on",optional:!0,defaultvalue:null}],code:[{type:"500",description:"database error",optional:!1},{type:"200",description:"succesfully retrieved data",optional:!1}],response:[{name:".",type:"array",description:"aggregations",optional:!1,defaultvalue:null}],examples:["// Example #1: Retrieve HTTP metrics of app INTERACTION, WEB-API, WORKER from all servers\n km.data.metrics.retrieveAggregations(bucket._id, {\n aggregations: [\n {\n 'start': 'now-5m',\n 'apps': ['INTERACTION', 'WEB-API', 'WORKER'],\n 'types': ['histogram', 'apps', 'servers'],\n 'name': 'HTTP'\n }\n ]\n})\n\n // Example #2: Retrieve HTTP metrics of ALL apps from all servers\n km.data.metrics.retrieveAggregations(bucket._id, {\n aggregations: [\n {\n 'start': 'now-1d',\n 'types': ['histogram', 'apps', 'servers'],\n 'name': 'HTTP'\n }\n ]\n})"],name:"retrieveAggregations",longname:"Data.metrics.retrieveAggregations",scope:"route"},{route:{name:"/api/bucket/:id/data/metrics/histogram",type:"POST"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],params:[{name:":id",type:"string",description:"bucket id",optional:!1}],body:[{name:"app_name",type:"string",description:"filter probes by app source",optional:!0,defaultvalue:null},{name:"server_name",type:"string",description:"filter probes by server source",optional:!0,defaultvalue:null},{name:"interval",type:"string",description:"interval of time between two point",optional:!0,defaultvalue:"minute"},{name:"before",type:"string",description:"filter out probes that are after X minute",optional:!0,defaultvalue:60}],code:[{type:"500",description:"database error",optional:!1},{type:"200",description:"succesfully retrieved data",optional:!1}],response:[{name:"server_name",type:"object",description:"",optional:!1,defaultvalue:null},{name:"server_name.app_name",type:"object",description:"",optional:!1,defaultvalue:null},{name:"server_name.app_name.metrics",type:"object",description:"",optional:!1,defaultvalue:null},{name:"server_name.app_name.metrics.agg_type",type:"string",description:"the type of aggregation for this probe",optional:!1,defaultvalue:null},{name:"server_name.app_name.metrics_name.timestamps_and_stats",type:"array",description:"array of point",optional:!1,defaultvalue:null}],name:"retrieveHistogram",longname:"Data.metrics.retrieveHistogram",scope:"route"},{route:{name:"/api/bucket/:id/data/metrics/histogramPrecise",type:"POST"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],params:[{name:":id",type:"string",description:"bucket id",optional:!1}],body:[{name:"probe",type:"string",description:"probe name",optional:!1,defaultvalue:null},{name:"app",type:"string",description:"filter probes by app source",optional:!1,defaultvalue:null},{name:"server",type:"string",description:"filter probes by server source",optional:!1,defaultvalue:null},{name:"after",type:"string",description:"interval of time between two point (now-5d, now-5m...)",optional:!0,defaultvalue:null}],code:[{type:"500",description:"database error",optional:!1},{type:"200",description:"succesfully retrieved data",optional:!1}],response:[{name:"Array",type:"array",description:"of points",optional:!1,defaultvalue:null}],name:"retrieveHistogramPrecise",longname:"Data.metrics.retrieveHistogramPrecise",scope:"route"},{route:{name:"/api/bucket/:id/data/metrics/list",type:"POST"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],params:[{name:":id",type:"string",description:"bucket id",optional:!1}],body:[{name:"servers",type:"object",description:"filter metrics by app name",optional:!0,defaultvalue:null},{name:"apps",type:"object",description:"filter metrics by server name",optional:!0,defaultvalue:null},{name:"initiator",type:"string",description:"filter metrics by a specific initiator",optional:!0,defaultvalue:null},{name:"source",type:"string",description:"filter metrics by a specific source",optional:!0,defaultvalue:null},{name:"collector",type:"string",description:"filter metrics by a specific collector",optional:!0,defaultvalue:null},{name:"webcheck",type:"string",description:"filter metrics by a specific webcheck",optional:!0,defaultvalue:null}],code:[{type:"500",description:"database error",optional:!1},{type:"200",description:"succesfully retrieved data",optional:!1}],name:"retrieveList",longname:"Data.metrics.retrieveList",scope:"route"},{route:{name:"/api/bucket/:id/data/metrics",type:"POST"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],params:[{name:":id",type:"string",description:"bucket id",optional:!1}],body:[{name:"app_name",type:"string",description:"filter metrics by app source",optional:!1,defaultvalue:null},{name:"server_name",type:"string",description:"filter metrics by server source",optional:!0,defaultvalue:null},{name:"before",type:"string",description:"filter out metrics that are after X minute",optional:!0,defaultvalue:720}],code:[{type:"500",description:"database error",optional:!1},{type:"200",description:"succesfully retrieved data",optional:!1}],name:"retrieveMetadatas",longname:"Data.metrics.retrieveMetadatas",scope:"route"}],notifications:[{route:{name:"/api/bucket/:id/data/notifications",type:"POST"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],params:[{name:":id",type:"string",description:"bucket id",optional:!1}],body:[{name:"type",type:"string",description:"Type of notification",optional:!0,defaultvalue:null},{name:"before",type:"string",description:"we search logs before this date (lower than)",optional:!0,defaultvalue:null},{name:"after",type:"string",description:"we search logs after this date (greater than)",optional:!0,defaultvalue:null},{name:"size",type:"number",description:"",optional:!0,defaultvalue:null},{name:"from",type:"number",description:"",optional:!0,defaultvalue:null},{name:"type",type:"string",description:"type of notification",optional:!0,defaultvalue:null},{name:"providers",type:"array",description:"find notifications with this providers",optional:!0,defaultvalue:null},{name:"contacts",type:"array",description:"find notifications with this contact",optional:!0,defaultvalue:null},{name:"size",type:"integer",description:"line limit, default to 20",optional:!0,defaultvalue:null},{name:"from",type:"integer",description:"offset limit",optional:!0,defaultvalue:null}],code:[{type:"500",description:"database error",optional:!1},{type:"200",description:"succesfully retrieved data",optional:!1}],tags:[{originalTitle:"reponse",title:"reponse",text:"{Array} . array of traces",value:"{Array} . array of traces",optional:!1,type:null}],name:"list",longname:"Data.notifications.list",scope:"route",async:!0},{route:{name:"/api/bucket/:id/data/notifications/:notification",type:"GET"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],params:[{name:":id",type:"string",description:"bucket id",optional:!1},{name:":notification",type:"string",description:"notification id",optional:!1}],code:[{type:"500",description:"database error",optional:!1},{type:"200",description:"succesfully retrieved data",optional:!1}],tags:[{originalTitle:"reponse",title:"reponse",text:"{Object} . notification",value:"{Object} . notification",optional:!1,type:null}],name:"retrieve",longname:"Data.notifications.retrieve",scope:"route",async:!0}],outliers:[{route:{name:"/api/bucket/:id/data/outliers/",type:"POST"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],params:[{name:":id",type:"string",description:"bucket id",optional:!1}],body:[{name:"app_name",type:"string",description:"the application name",optional:!0,defaultvalue:null},{name:"server_name",type:"string",description:"filter by server name",optional:!0,defaultvalue:null},{name:"start",type:"string",description:"only search outlier newer than ",optional:!0,defaultvalue:null},{name:"end",type:"string",description:"only search outlier older than ",optional:!0,defaultvalue:null}],code:[{type:"500",description:"database error",optional:!1},{type:"200",description:"succesfully retrieved data",optional:!1},{type:"400",description:"missing parameters",optional:!1}],response:[{name:".",type:"array",description:"recorded dependencies",optional:!1,defaultvalue:null}],examples:["km.data.outliers.retrieve(bucket._id, {\n app_name: 'my_api'\n })"],name:"retrieve",longname:"Data.outliers.retrieve",scope:"route"}],processes:[{route:{name:"/api/bucket/:id/data/processEvents",type:"POST"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],params:[{name:":id",type:"string",description:"bucket id",optional:!1}],body:[{name:"app_name",type:"string",description:"filter events by app source",optional:!0,defaultvalue:null},{name:"server_name",type:"string",description:"filter events by server source",optional:!0,defaultvalue:null},{name:"before",type:"string",description:"filter out events that are after X minute",optional:!0,defaultvalue:60}],code:[{type:"500",description:"database error",optional:!1},{type:"200",description:"succesfully retrieved data",optional:!1}],response:[{name:".",type:"array",description:"array of process events",optional:!1,defaultvalue:null}],name:"retrieveEvents",longname:"Data.processes.retrieveEvents",scope:"route"},{route:{name:"/api/bucket/:id/data/processEvents/deployments",type:"POST"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],params:[{name:":id",type:"string",description:"bucket id",optional:!1}],body:[{name:"app_name",type:"string",description:"filter events by app source",optional:!0,defaultvalue:null},{name:"server_name",type:"string",description:"filter events by server source",optional:!0,defaultvalue:null}],code:[{type:"500",description:"database error",optional:!1},{type:"200",description:"succesfully retrieved data",optional:!1}],response:[{name:".",type:"array",description:"array of deployments",optional:!1,defaultvalue:null}],name:"retrieveDeployments",longname:"Data.processes.retrieveDeployments",scope:"route"}],profiling:[{route:{name:"/api/bucket/:id/data/profilings/:filename",type:"GET"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],params:[{name:":id",type:"string",description:"bucket id",optional:!1},{name:":filename",type:"string",description:"filename",optional:!1}],code:[{type:"500",description:"database error",optional:!1},{type:"400",description:"invalid parameters",optional:!1}],response:[{name:".",type:"object",description:"return profile data",optional:!1,defaultvalue:null}],name:"retrieve",longname:"Data.profiling.retrieve",scope:"route"},{route:{name:"/api/bucket/:id/data/profilings/:filename/download",type:"GET"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],params:[{name:":id",type:"string",description:"bucket id",optional:!1},{name:":filename",type:"string",description:"filename",optional:!1}],code:[{type:"500",description:"database error",optional:!1},{type:"400",description:"invalid parameters",optional:!1}],response:[{name:".",type:"file",description:"return a file",optional:!1,defaultvalue:null}],name:"download",longname:"Data.profiling.download",scope:"route"},{route:{name:"/api/bucket/:id/data/profilings",type:"POST"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],params:[{name:":id",type:"string",description:"bucket id",optional:!1}],body:[{name:"apps",type:"object",description:"",optional:!0,defaultvalue:null},{name:"servers",type:"object",description:"",optional:!0,defaultvalue:null},{name:"from",type:"object",description:"",optional:!0,defaultvalue:null},{name:"size",type:"object",description:"",optional:!0,defaultvalue:null},{name:"type",type:"object",description:"",optional:!0,defaultvalue:null}],code:[{type:"500",description:"database error",optional:!1},{type:"200",description:"succesfully retrieved data",optional:!1}],response:[{name:".",type:"array",description:"array of object containing profilings",optional:!1,defaultvalue:null}],name:"list",longname:"Data.profiling.list",scope:"route"},{route:{name:"/api/bucket/:id/data/profilings/:filename",type:"DELETE"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],params:[{name:":id",type:"string",description:"bucket id",optional:!1},{name:":filename",type:"string",description:"filename",optional:!1}],code:[{type:"500",description:"database error",optional:!1},{type:"400",description:"invalid parameters",optional:!1}],response:[{name:".",type:"file",description:"return a file",optional:!1,defaultvalue:null}],name:"delete",longname:"Data.profiling.delete",scope:"route"}],status:[{route:{name:"/api/bucket/:id/data/status",type:"GET"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],params:[{name:":id",type:"string",description:"bucket id",optional:!1}],code:[{type:"500",description:"database error",optional:!1},{type:"200",description:"succesfully retrieved data",optional:!1}],tags:[{originalTitle:"reponse",title:"reponse",text:"{Array} . array of servers status",value:"{Array} . array of servers status",optional:!1,type:null}],name:"retrieve",longname:"Data.status.retrieve",scope:"route",async:!0},{route:{name:"/api/bucket/:id/data/status/blacklisted",type:"GET"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],params:[{name:":id",type:"string",description:"bucket id",optional:!1}],code:[{type:"500",description:"database error",optional:!1},{type:"200",description:"succesfully retrieved data",optional:!1}],tags:[{originalTitle:"reponse",title:"reponse",text:"{Array} . array of servers status",value:"{Array} . array of servers status",optional:!1,type:null}],name:"retrieveBlacklisted",longname:"Data.status.retrieveBlacklisted",scope:"route",async:!0}],traces:[{route:{name:"/api/bucket/:id/data/traces",type:"POST"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],params:[{name:":id",type:"string",description:"bucket id",optional:!1}],body:[{name:"includeSpans",type:"boolean",description:"",optional:!0,defaultvalue:!0},{name:"serviceName",type:"string",description:"",optional:!0,defaultvalue:null},{name:"limit",type:"string",description:"default: 10, max: 100",optional:!0,defaultvalue:null},{name:"kind",type:"string",description:"",optional:!0,defaultvalue:null},{name:"minDuration",type:"number",description:"",optional:!0,defaultvalue:null},{name:"start",type:"string",description:"date",optional:!0,defaultvalue:null},{name:"end",type:"string",description:"date",optional:!0,defaultvalue:null},{name:"tags",type:"array",description:"Query string array like [error=500, error, ...]",optional:!0,defaultvalue:null},{name:"orderBy",type:"string",description:"Default: newest, enum: oldest, newest, shortest, longest",optional:!0,defaultvalue:null},{name:"spanName",type:"string",description:"",optional:!0,defaultvalue:null}],code:[{type:"500",description:"database error",optional:!1},{type:"200",description:"succesfully retrieved data",optional:!1}],tags:[{originalTitle:"reponse",title:"reponse",text:"{Array} . array of traces",value:"{Array} . array of traces",optional:!1,type:null}],name:"list",longname:"Data.traces.list",scope:"route",async:!0},{route:{name:"/api/bucket/:id/data/traces/:trace",type:"GET"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],params:[{name:":id",type:"string",description:"bucket id",optional:!1},{name:":trace",type:"string",description:"trace id",optional:!1}],code:[{type:"500",description:"database error",optional:!1},{type:"200",description:"succesfully retrieved data",optional:!1}],tags:[{originalTitle:"reponse",title:"reponse",text:"{Object} . trace",value:"{Object} . trace",optional:!1,type:null}],name:"retrieve",longname:"Data.traces.retrieve",scope:"route",async:!0},{route:{name:"/api/bucket/:id/data/traces/services",type:"GET"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],params:[{name:":id",type:"string",description:"bucket id",optional:!1}],code:[{type:"500",description:"database error",optional:!1},{type:"200",description:"succesfully retrieved data",optional:!1}],response:[{name:"services,",type:"object",description:"spans names",optional:!1,defaultvalue:null}],name:"getServices",longname:"Data.traces.getServices",scope:"route",async:!0},{route:{name:"/api/bucket/:id/data/traces/tags",type:"GET"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],params:[{name:":id",type:"string",description:"bucket id",optional:!1}],code:[{type:"500",description:"database error",optional:!1},{type:"200",description:"succesfully retrieved data",optional:!1}],response:[{name:"tags",type:"array",description:"",optional:!1,defaultvalue:null}],name:"getTags",longname:"Data.traces.getTags",scope:"route",async:!0},{route:{name:"/api/bucket/:id/data/traces/histogram/tag",type:"POST"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],params:[{name:":id",type:"string",description:"bucket id",optional:!1}],body:[{name:"tag",type:"string",description:"",optional:!1,defaultvalue:null},{name:"start",type:"string",description:"date",optional:!0,defaultvalue:null},{name:"end",type:"string",description:"date",optional:!0,defaultvalue:null},{name:"serviceName",type:"string",description:"",optional:!0,defaultvalue:null},{name:"spanName",type:"string",description:"",optional:!0,defaultvalue:null}],code:[{type:"500",description:"database error",optional:!1},{type:"200",description:"succesfully retrieved data",optional:!1}],response:[{name:"aggregation",type:"array",description:"",optional:!1,defaultvalue:null}],name:"getHistogramByTag",longname:"Data.traces.getHistogramByTag",scope:"route",async:!0},{route:{name:"/api/bucket/:id/data/traces/aggregation/tag",type:"POST"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],params:[{name:":id",type:"string",description:"bucket id",optional:!1}],body:[{name:"tag",type:"string",description:"",optional:!1,defaultvalue:null},{name:"start",type:"string",description:"date",optional:!0,defaultvalue:null},{name:"end",type:"string",description:"date",optional:!0,defaultvalue:null},{name:"serviceName",type:"string",description:"",optional:!0,defaultvalue:null},{name:"spanName",type:"string",description:"",optional:!0,defaultvalue:null}],code:[{type:"500",description:"database error",optional:!1},{type:"200",description:"succesfully retrieved data",optional:!1}],response:[{name:"aggregation",type:"array",description:"",optional:!1,defaultvalue:null}],name:"getTagsValue",longname:"Data.traces.getTagsValue",scope:"route",async:!0},{route:{name:"/api/bucket/:id/data/traces/aggregation/duration",type:"POST"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],params:[{name:":id",type:"string",description:"bucket id",optional:!1}],body:[{name:"start",type:"string",description:"date",optional:!0,defaultvalue:null},{name:"end",type:"string",description:"date",optional:!0,defaultvalue:null},{name:"serviceName",type:"string",description:"",optional:!0,defaultvalue:null},{name:"spanName",type:"string",description:"",optional:!0,defaultvalue:null},{name:"tags",type:"array",description:"",optional:!0,defaultvalue:null}],code:[{type:"500",description:"database error",optional:!1},{type:"200",description:"succesfully retrieved data",optional:!1}],response:[{name:"aggregation",type:"array",description:"",optional:!1,defaultvalue:null}],name:"getDurationAvg",longname:"Data.traces.getDurationAvg",scope:"route",async:!0}],transactions:[{route:{name:"/api/bucket/:id/data/transactions/v2/histogram",type:"POST"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],params:[{name:":id",type:"string",description:"bucket id",optional:!1}],body:[{name:"app_name",type:"string",description:"filter transactions by app source",optional:!0,defaultvalue:null},{name:"server_name",type:"string",description:"filter transactions by server source",optional:!0,defaultvalue:null},{name:"interval",type:"string",description:"interval of time between two point",optional:!0,defaultvalue:"minute"},{name:"before",type:"string",description:"filter out transactions that are after X minute",optional:!0,defaultvalue:60}],code:[{type:"500",description:"database error",optional:!1},{type:"200",description:"succesfully retrieved data",optional:!1}],response:[{name:".",type:"array",description:"array of times series containing points",optional:!1,defaultvalue:null}],name:"retrieveHistogram",longname:"Data.transactions.retrieveHistogram",scope:"route"},{route:{name:"/api/bucket/:id/data/transactions/v2/summary",type:"POST"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],params:[{name:":id",type:"string",description:"bucket id",optional:!1}],body:[{name:"app_name",type:"string",description:"filter transactions by app source",optional:!0,defaultvalue:null},{name:"server_name",type:"string",description:"filter transactions by server source",optional:!0,defaultvalue:null}],code:[{type:"500",description:"database error",optional:!1},{type:"200",description:"succesfully retrieved data",optional:!1}],response:[{name:"server_name",type:"object",description:"",optional:!1,defaultvalue:null},{name:"server_name.app_name",type:"object",description:"transaction object",optional:!1,defaultvalue:null}],name:"retrieveSummary",longname:"Data.transactions.retrieveSummary",scope:"route"},{route:{name:"/api/bucket/:id/data/transactions/v2/delete",type:"POST"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],params:[{name:":id",type:"string",description:"bucket id",optional:!1}],query:[{name:"app_name",type:"string",description:"filter transactions by app source",optional:!0,defaultvalue:null},{name:"server_name",type:"string",description:"filter transactions by server source",optional:!0,defaultvalue:null}],code:[{type:"500",description:"database error",optional:!1},{type:"200",description:"succesfully retrieved data",optional:!1}],response:[{name:"server_name",type:"object",description:"",optional:!1,defaultvalue:null},{name:"server_name.app_name",type:"object",description:"transaction object",optional:!1,defaultvalue:null}],name:"delete",longname:"Data.transactions.delete",scope:"route"}]},misc:[{route:{name:"/api/misc/changelog",type:"GET"},code:[{type:"500",description:"database error",optional:!1},{type:"200",description:"succesfully retrieved data",optional:!1},{type:"400",description:"Invalid params",optional:!1}],response:[{name:"changelog",type:"array",description:"articles",optional:!1,defaultvalue:null}],name:"listChangelogArticles",longname:"Misc.listChangelogArticles",scope:"route",params:[],authentication:!1},{route:{name:"/api/misc/release/pm2",type:"GET"},code:[{type:"500",description:"database error",optional:!1},{type:"200",description:"succesfully retrieved data",optional:!1},{type:"400",description:"Invalid params",optional:!1}],response:[{name:"pm2_version",type:"string",description:"latest version",optional:!1,defaultvalue:null}],name:"retrievePM2Version",longname:"Misc.retrievePM2Version",scope:"route",params:[],authentication:!1},{route:{name:"/api/misc/release/nodejs/:version",type:"GET"},params:[{name:":version",type:"string",description:"semver version range",optional:!1}],code:[{type:"500",description:"database error",optional:!1},{type:"200",description:"succesfully retrieved data",optional:!1},{type:"400",description:"Invalid params",optional:!1}],response:[{name:".",type:"array",description:"array of releases matching the range requested",optional:!1,defaultvalue:null}],name:"retrieveNodeRelease",longname:"Misc.retrieveNodeRelease",scope:"route",authentication:!1},{route:{name:"/api/misc/plans",type:"GET"},code:[{type:"500",description:"database error",optional:!1},{type:"200",description:"succesfully retrieved data",optional:!1},{type:"400",description:"Invalid params",optional:!1}],response:[{name:".",type:"object",description:"list of plans keyed by plan name",optional:!1,defaultvalue:null}],name:"retrievePlans",longname:"Misc.retrievePlans",scope:"route",params:[],authentication:!1},{route:{name:"/api/misc/stripe/retrieveCoupon",type:"POST"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],body:[{name:"coupon",type:"string",description:"the coupon name",optional:!1,defaultvalue:null}],code:[{type:"500",description:"stripe error",optional:!1},{type:"200",description:"succesfully retrieved the metadata",optional:!1}],response:[{name:"coupon",type:"object",description:"the coupon object",optional:!1,defaultvalue:null}],name:"retrieveCoupon",longname:"Misc.retrieveCoupon",scope:"route",params:[]},{route:{name:"/api/misc/stripe/retrieveCompany",type:"POST"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],body:[{name:"vat_id",type:"string",description:"the vat id of the company",optional:!1,defaultvalue:null}],code:[{type:"500",description:"stripe error",optional:!1},{type:"200",description:"succesfully retrieved the metadata",optional:!1}],response:[{name:".",type:"object",description:"metadata about company",optional:!1,defaultvalue:null}],name:"retrieveCompany",longname:"Misc.retrieveCompany",scope:"route",params:[]},{route:{name:"/api/misc/stripe/retrieveVat",type:"POST"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],body:[{name:"country",type:"string",description:"country code of the user",optional:!0,defaultvalue:null}],code:[{type:"500",description:"stripe error",optional:!1},{type:"200",description:"succesfully retrieved the metadata",optional:!1}],response:[{name:"coupon",type:"object",description:"the coupon object",optional:!1,defaultvalue:null}],name:"retrieveVAT",longname:"Misc.retrieveVAT",scope:"route",params:[]}],node:[{route:{name:"/api/node/default",type:"GET"},response:[{name:"node",type:"object",description:"Return node object",optional:!1,defaultvalue:null}],name:"getDefaultNode",longname:"Node.getDefaultNode",scope:"route",params:[],authentication:!1}],orchestration:[{route:{name:"/api/bucket/:id/balance",type:"POST"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],code:[{type:"500",description:"balancing error",optional:!1},{type:"403",description:"already on new node or not premium",optional:!1},{type:"200",description:"succesfully balanced the bucket",optional:!1}],response:[{name:"migration",type:"object",description:"is equal true if succesfull",optional:!1,defaultvalue:null}],name:"selfSend",longname:"Orchestration.selfSend",scope:"route",params:[]}],tokens:[{route:{name:"/api/users/token/",type:"GET"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],code:[{type:"500",description:"database error",optional:!1},{type:"200",description:"successfully retrieved",optional:!1}],response:[{name:".",type:"object",description:"array of tokens",optional:!1,defaultvalue:null}],name:"retrieve",longname:"Tokens.retrieve",scope:"route",params:[]},{route:{name:"/api/users/token/:id",type:"DELETE"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],params:[{name:":id",type:"string",description:"token id",optional:!1}],code:[{type:"500",description:"database error",optional:!1},{type:"404",description:"token not found",optional:!1},{type:"200",description:"refresh token has been deleted and all access token that have been created with it",optional:!1}],response:[{name:".",type:"object",description:"array of tokens",optional:!1,defaultvalue:null}],name:"remove",longname:"Tokens.remove",scope:"route"},{route:{name:"/api/users/token/",type:"PUT"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],body:[{name:"scope",type:"object",description:"a valid oauth scope",optional:!1,defaultvalue:null}],code:[{type:"409",description:"the otp is already enabled for the user, you can only delete it",optional:!1},{type:"200",description:"the otp can be registered for the account, return the full response",optional:!1}],response:[{name:".",type:"object",description:"generated token",optional:!1,defaultvalue:null}],name:"create",longname:"Tokens.create",scope:"route",params:[]}],user:{otp:[{route:{name:"/api/users/otp",type:"GET"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],code:[{type:"409",description:"the otp is already enabled for the user, you can only delete it",optional:!1},{type:"200",description:"the otp can be registered for the account, return the full response",optional:!1}],response:[{name:"user",type:"object",description:"user model",optional:!1,defaultvalue:null},{name:"key",type:"string",description:"otp secret key",optional:!1,defaultvalue:null},{name:"qrImage",type:"string",description:"url to the QrCode",optional:!1,defaultvalue:null}],name:"retrieve",longname:"User.otp.retrieve",scope:"route",params:[]},{route:{name:"/api/users/otp",type:"POST"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],body:[{name:"otpKey",type:"string",description:"secret key used to generate OTP code",optional:!1,defaultvalue:null},{name:"otpToken",type:"string",description:"a currently valid OTP code generated with the otpKey",optional:!1,defaultvalue:null}],code:[{type:"400",description:"missing parameters",optional:!1},{type:"403",description:"the code asked to add the OTP from user account is invalid",optional:!1},{type:"500",description:"error from database",optional:!1},{type:"200",description:"the otp has been registered for the user",optional:!1}],name:"enable",longname:"User.otp.enable",scope:"route",params:[]},{route:{name:"/api/users/otp",type:"DELETE"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],query:[{name:"otpToken",type:"string",description:"a currently valid OTP code",optional:!1,defaultvalue:null}],code:[{type:"400",description:"missing parameters",optional:!1},{type:"403",description:"the code asked to remove the OTP from user account is invalid",optional:!1},{type:"500",description:"error from database",optional:!1},{type:"200",description:"the otp has been deleted for the user",optional:!1}],name:"disable",longname:"User.otp.disable",scope:"route",params:[]}],providers:[{route:{name:"/api/users/integrations",type:"GET"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],code:[{type:"200",description:"succesfully retrieved providers",optional:!1}],response:[{name:".",type:"array",description:"array of providers for user account",optional:!1,defaultvalue:null}],name:"retrieve",longname:"User.providers.retrieve",scope:"route",params:[]},{route:{name:"/api/users/integrations",type:"POST"},authentication:!0,body:[{name:"name",type:"string",description:"the provider name",optional:!1,defaultvalue:null}],header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],code:[{type:"400",description:"invalid parameters",optional:!1},{type:"403",description:"the user already have this provider",optional:!1},{type:"200",description:"succesfully added the provider",optional:!1}],name:"add",longname:"User.providers.add",scope:"route",params:[]},{route:{name:"/api/users/integrations/:name",type:"DELETE"},authentication:!0,params:[{name:":name",type:"string",description:"the provider name",optional:!1}],header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],code:[{type:"400",description:"invalid parameters or provider isn't implemented",optional:!1},{type:"403",description:"the provider isn't enabled",optional:!1},{type:"200",description:"succesfully removed the provider",optional:!1}],name:"remove",longname:"User.providers.remove",scope:"route"}],default:[{name:"retrieve",route:{name:"/api/users/isLogged",type:"GET"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],code:[{type:"200",description:"the user has been retrieved",optional:!1}],response:[{name:"user",type:"object",description:"user model",optional:!1,defaultvalue:null}],longname:"User.retrieve",scope:"route"},{route:{name:"/api/users/show/:id",type:"GET"},params:[{name:":id",type:"string",description:"user id",optional:!1}],code:[{type:"500",description:"database error",optional:!1},{type:"400",description:"invalid parameters (no id provided)",optional:!1},{type:"404",description:"no user account where found",optional:!1},{type:"200",description:"the mail has been sent to the provided email",optional:!1}],response:[{name:"String",type:"",description:"email user email",optional:!1,defaultvalue:null},{name:"String",type:"",description:"username user pseudo",optional:!1,defaultvalue:null}],name:"show",longname:"User.show",scope:"route",authentication:!1},{route:{name:"/api/users/update",type:"POST"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],body:[{name:"username",type:"string",description:"",optional:!0,defaultvalue:null},{name:"email",type:"string",description:"",optional:!0,defaultvalue:null},{name:"old_password",type:"string",description:"",optional:!0,defaultvalue:null},{name:"new_password",type:"string",description:"",optional:!0,defaultvalue:null},{name:"info",type:"object",description:"",optional:!0,defaultvalue:null}],code:[{type:"500",description:"database error",optional:!1},{type:"400",description:"missing parameters, no data to update",optional:!1},{type:"403",description:"when updating the password, it need a new one",optional:!1},{type:"406",description:"when updating the password, the old one is false",optional:!1},{type:"409",description:"when updating email or username\n another user already have one of those two",optional:!1},{type:"200",description:"succesfully updated the card",optional:!1}],response:[{name:".",type:"object",description:"user object",optional:!1,defaultvalue:null}],name:"update",longname:"User.update",scope:"route",params:[]},{route:{name:"/api/users/delete",type:"DELETE"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],code:[{type:"500",description:"database error",optional:!1},{type:"403",description:"permission denied (hold buckets)",optional:!1},{type:"200",description:"succesfully deleted the user",optional:!1}],response:[{name:".",type:"object",description:"user object",optional:!1,defaultvalue:null}],name:"delete",longname:"User.delete",scope:"route",params:[]}]},auth:[{name:"retrieveToken",route:{name:"/api/oauth/token",type:"POST"},service:{name:"OAUTH"},body:[{name:"client_id",type:"string",description:"the public id of your oauth application",optional:!1,defaultvalue:null},{name:"refresh_token",type:"string",description:"refresh token you retrieved via authorize endpoint",optional:!1,defaultvalue:null},{name:"grant_type",type:"string",description:"",optional:!1,defaultvalue:"refresh_token"}],code:[{type:"400",description:"invalid parameters (missing or not correct)",optional:!1}],response:[{name:"access_token",type:"string",description:"a fresh access_token",optional:!1,defaultvalue:null},{name:"refresh_token",type:"string",description:"the refresh token you used",optional:!1,defaultvalue:null},{name:"expire_at",type:"string",description:"UTC date at which the token will be considered\n as invalid",optional:!1,defaultvalue:null},{name:"token_type",type:"string",description:"the type of token to use, for now its always Bearer",optional:!1,defaultvalue:null}],longname:"Auth.retrieveToken",scope:"route",authentication:!1},{name:"requestNewPassword",route:{name:"/api/oauth/reset_password",type:"POST"},service:{name:"OAUTH"},body:[{name:"email",type:"string",description:"email of the account that want a password reset",optional:!1,defaultvalue:null}],code:[{type:"500",description:"the database failed to register the token to reset the mail",optional:!1},{type:"400",description:"missing parameters",optional:!1},{type:"404",description:"no user account where found with the provided email",optional:!1},{type:"200",description:"the mail has been sent to the provided email",optional:!1}],longname:"Auth.requestNewPassword",scope:"route",authentication:!1},{name:"sendEmailLink",route:{name:"/api/oauth/send_email_link",type:"POST"},service:{name:"OAUTH"},code:[{type:"500",description:"the database failed to register the token to reset the mail",optional:!1},{type:"401",description:"need to authenticated",optional:!1},{type:"200",description:"the mail has been sent to the provided email",optional:!1}],longname:"Auth.sendEmailLink",scope:"route",authentication:!1},{name:"validEmail",route:{name:"/api/oauth/valid_email/:token",type:"GET"},params:[{description:"the token to validate the account",name:":token",optional:!1,type:null}],service:{name:"OAUTH"},code:[{type:"500",description:"the database failed to valid email",optional:!1},{type:"404",description:"need to authenticated",optional:!1},{type:"301",description:"the email has been valided",optional:!1}],longname:"Auth.validEmail",scope:"route",authentication:!1},{route:{name:"/api/oauth/register",type:"GET"},service:{name:"OAUTH"},body:[{name:"username",type:"string",description:"",optional:!1,defaultvalue:null},{name:"email",type:"string",description:"",optional:!1,defaultvalue:null},{name:"password",type:"string",description:"",optional:!1,defaultvalue:null},{name:"role",type:"string",description:"job title in user company",optional:!0,defaultvalue:null},{name:"company",type:"string",description:"company name",optional:!0,defaultvalue:null},{name:"accept_terms",type:"integer",description:"",optional:!1,defaultvalue:null}],code:[{type:"500",description:"either the registeration of new user is disabled or\nthe database failed to register the user",optional:!1},{type:"409",description:"the user field are already used by another user",optional:!1},{type:"200",description:"the user has been created",optional:!1}],response:[{name:"user",type:"object",description:"user model",optional:!1,defaultvalue:null},{name:"access_token",type:"object",description:"access token issued for the user",optional:!1,defaultvalue:null},{name:"refreshToken",type:"object",description:"refresh token issued for the user",optional:!1,defaultvalue:null}],name:"register",longname:"Auth.register",scope:"route",authentication:!1},{route:{name:"/api/oauth/revoke",type:"POST"},service:{name:"OAUTH"},authentication:!0,header:[{name:"Authorization",type:"string",description:"bearer access token issued for the user",optional:!1,defaultvalue:null}],code:[{type:"404",description:"token not found",optional:!1},{type:"500",description:"database error",optional:!1},{type:"200",description:"the token has been succesfully deleted,\n if there was access token generated with this token, they\n have been deleted too",optional:!1}],name:"revoke",longname:"Auth.revoke",scope:"route"}]}},{}],41:[function(e,t,n){"use strict";function o(e){"@babel/helpers - typeof";return(o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function i(e,t){for(var n=0;n0&&s("Call to '".concat(t.route.name,"' from ").concat(o.replace(" at ",""))),new Promise(function(o,i){r.extract(t,Array.prototype.slice.call(n)).then(function(n){if(t.service&&t.service.baseURL){var a=t.service.baseURL;a="/"===a[a.length-1]?a.substr(0,a.length-1):a,n.url=a+n.url}e.request(n).then(o,i)}).catch(i)})}}}])&&i(t.prototype,n),o&&i(t,o),Object.defineProperty(t,"prototype",{writable:!1}),e}()},{"./utils/validator":48,debug:4}],45:[function(e,t,n){"use strict";function o(e){"@babel/helpers - typeof";return(o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function i(e,t){for(var n=0;n0&&s("namespace ".concat(this.name," contains namespaces : \n").concat(this.namespaces.map(function(e){return e.name}).join("\n"),"\n")),this.endpoints.length>0&&s("Namespace ".concat(this.name," contains endpoints : \n").concat(this.endpoints.map(function(e){return e.route.name}).join("\n"),"\n"))}var t,n,a;return t=e,(n=[{key:"addNamespace",value:function(t){if(!t||t.name===this.name)throw new Error("A namespace must not have the same name as the parent namespace");if(!(t instanceof e))throw new Error("addNamespace only accept Namespace instance");this.namespaces.push(t),this[t.name]=t}},{key:"addEndpoint",value:function(e){if(!e||e.name===this.name)throw new Error("A endpoint must not have the same name as a namespace");if(!(e instanceof r))throw new Error("addNamespace only accept Namespace instance");this.endpoints.push(e),this[e.name]=e.build(this.http)}}])&&i(t.prototype,n),a&&i(t,a),Object.defineProperty(t,"prototype",{writable:!1}),e}()},{"./endpoint":44,debug:4}],47:[function(e,t,n){"use strict";function o(e){"@babel/helpers - typeof";return(o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function i(e,t){for(var n=0;n0&&u("Emptying requests queue (size: ".concat(this._queue.length,")"));this._queue.length>0;){var e=this._queue.shift();this.request(e.request).then(e.resolve,e.reject)}}},{key:"_resolveBucketEndpoint",value:function(e){var t=this;if(!e)return Promise.reject(new Error("Missing argument : bucketID"));if(!this._endpoints.has(e)){var n=this._extrareqp2.request({url:"/api/bucket/".concat(e),method:"GET",headers:{Authorization:"Bearer ".concat(this.tokens.access_token)}}).then(function(e){return e.data.node.endpoints.web}).catch(function(n){throw t._endpoints.delete(e),n});this._endpoints.set(e,n)}return this._endpoints.get(e)}},{key:"request",value:function(e){var t=this;return new Promise(function(n,o){m.series([function(i){return!0===t.authenticated||!1===e.authentication?i():(p("Queued request to ".concat(e.url)),t._queue.push({resolve:n,reject:o,request:e}),i(-1))},function(n){if(!e.url.match(/bucket\/[0-9a-fA-F]{24}/))return n();var o=e.url.split("/")[3];t._resolveBucketEndpoint(o).then(function(t){return e.baseURL=t,n()}).catch(n)},function(n){var o=function(e){return n(null,e)};p("Making request to ".concat(e.url)),e.headers||(e.headers={}),e.headers.Authorization="Bearer ".concat(t.tokens.access_token),t._extrareqp2.request(e).then(o).catch(function(i){var a=i.response;if(a&&401!==a.status)return n(a);p("Got unautenticated response, buffering request from now ..."),t.authenticated=!1,p("Asking to the oauth flow to retrieve new tokens");var r=function(){t.oauth_flow.retrieveTokens(t.km,function(i,r){if(i)return p("Failed to retrieve new tokens : ".concat(i.message||i)),n(a);p("Succesfully retrieved new tokens"),t._updateTokens(null,r,function(i,r){return i?n(a):(p("Re-buffering call to ".concat(e.url," since authenticated now")),e.headers.Authorization="Bearer ".concat(t.tokens.access_token),t._extrareqp2.request(e).then(o).catch(n))})})};if(e.url==t.opts.services.OAUTH+"/api/oauth/token")return setTimeout(r.bind(t),500);r()})}],function(e,t){if(-1!==e)return e?o(e):n(t[2])})})}},{key:"_updateTokens",value:function(e,t,n){var o=this;if(e)return console.error("Error while retrieving tokens:",e),this.oauth_flow.deleteTokens(this.km),console.error(e.response?e.response.data:e.stack);if(!t||!t.access_token||!t.refresh_token)throw new Error("Invalid tokens");this.tokens=t,p("Registered new access_token : ".concat(t.access_token)),this._websockets.forEach(function(e){return e.updateAuthorization(t.access_token)}),this._extrareqp2.defaults.headers.common.Authorization="Bearer ".concat(t.access_token),this._extrareqp2.request({url:"/api/bucket",method:"GET",headers:{Authorization:"Bearer ".concat(t.access_token)}}).then(function(e){return p("Cached ".concat(e.data.length," buckets for current user")),o.authenticated=!0,o._queueUpdater(),"function"==typeof n?n(null,!0):null}).catch(function(e){return console.error("Error while retrieving buckets"),console.error(e.response?e.response.data:e),"function"==typeof n?n(e):null})}},{key:"useStrategy",value:function(e,t){if(t||(t={}),t.client_id||(t.client_id=this.opts.OAUTH_CLIENT_ID),"object"===o(e)){if(this.oauth_flow=e,!this.oauth_flow.retrieveTokens||!this.oauth_flow.deleteTokens)throw new Error("You must implement the Strategy interface to use it");return this.oauth_flow.retrieveTokens(this.km,this._updateTokens.bind(this))}if(void 0===s.implementations(e))throw new Error("The flow named ".concat(e," doesn't exist"));var n=s.implementations(e);if(n.condition&&l.ENVIRONNEMENT!==n.condition)throw new Error("The flow ".concat(e," is reserved for ").concat(n.condition," environment"));var i=n.nodule;return this.oauth_flow=new i(t),this.oauth_flow.retrieveTokens(this.km,this._updateTokens.bind(this))}},{key:"editSocketFilters",value:function(e,t){if(0===t.indexOf("**"))throw new Error("You need to provide a bucket public id.");var n=(t=t.split(":"))[0],o=t.slice(2).join(":"),i=this._websockets.find(function(e){return e.bucketPublic===n});this._bucketFilters.has(n)||this._bucketFilters.set(n,[]);var a=this._bucketFilters.get(n);"push"===e?a.push(o):a.splice(a.indexOf(o),1),i&&i.send(JSON.stringify({action:"sub",public_id:n,filters:Array.from(new Set(a))}))}},{key:"subscribe",value:function(e,t){var n=this;return new Promise(function(t,o){u("Request endpoints for ".concat(e)),n.km.bucket.retrieve(e).then(function(i){var a=i.data,r=!1,s=a.node.endpoints,l=s.realtime||s.web;l=l.replace("http","ws"),n.opts.IS_DEBUG&&(l=l.replace(":3000",":4020")),c("Found endpoint for ".concat(e," : ").concat(l));var p=new d("".concat(l,"/primus"),n.tokens.access_token);p.bucketPublic=a.public_id,p.connected=!1,p.bucket=e;var f=null;p.onmaxreconnect=function(e){if(!r)return r=!0,o(new Error("Connection timeout"))},p.onopen=function(){if(u("Connected to ws endpoint : ".concat(l," (bucket: ").concat(e,")")),p.connected=!0,n.realtime.emit("".concat(a.public_id,":connected")),p.send(JSON.stringify({action:"sub",public_id:a.public_id,filters:Array.from(new Set(n._bucketFilters.get(a.public_id)))})),null!==f&&(clearInterval(f),f=null),f=setInterval(function(){p.ping()}.bind(n),5e3),!r)return r=!0,t(p)},p.onunexpectedresponse=function(e,t){return 401===t.statusCode?n.oauth_flow.retrieveTokens(n.km,function(e,t){if(e)return u("Failed to retrieve tokens for ws: ".concat(e.message));u("Succesfully retrieved new tokens for ws"),n._updateTokens(null,t,function(e,t){return e?u("Failed to update tokens for ws: ".concat(e.message)):p._tryReconnect()})}):p._tryReconnect()},p.onerror=function(t){c("Error on ".concat(l," (bucket: ").concat(e,")")),c(t),n.realtime.emit("".concat(a.public_id,":error"),t)},p.onclose=function(){u("Closing ws connection ".concat(l," (bucket: ").concat(e,")")),p.connected=!1,n.realtime.emit("".concat(a.public_id,":disconnected")),null!==f&&(clearInterval(f),f=null)},p.onmessage=function(t){c("Received message for bucket ".concat(e," (").concat((t.data.length/1e3).toFixed(1)," Kb)"));var o=null;try{o=JSON.parse(t.data)}catch(t){return c("Receive not json message for bucket ".concat(e))}var i=o.data[1];Object.keys(i).forEach(function(e){"server_name"!==e&&n.realtime.emit("".concat(a.public_id,":").concat(i.server_name||"none",":").concat(e),i[e])})},n._websockets.push(p)}).catch(o)})}},{key:"unsubscribe",value:function(e,t){var n=this;return new Promise(function(t,o){u("Unsubscribe from realtime for ".concat(e));var i=n._websockets.find(function(t){return t.bucket===e});return i?(i.close(1e3,"Disconnecting"),u("Succesfully unsubscribed from realtime for ".concat(e)),t()):o(new Error("Realtime wasn't connected to ".concat(e)))})}}])&&i(t.prototype,n),a&&i(t,a),Object.defineProperty(t,"prototype",{writable:!1}),e}()},{"../constants":1,"./auth_strategies/strategy":43,"./utils/websocket":49,async:2,debug:4,eventemitter2:6,extrareqp2:7}],48:[function(e,t,n){"use strict";function o(e){"@babel/helpers - typeof";return(o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function i(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return a(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return a(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var o=0,i=function(){};return{s:i,n:function(){return o>=e.length?{done:!0}:{done:!1,value:e[o++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var r,s=!0,l=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return s=e.done,e},e:function(e){l=!0,r=e},f:function(){try{s||null==n.return||n.return()}finally{if(l)throw r}}}}function a(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=new Array(t);n0)return r(new Error("Expected to receive an object for post data but received ".concat(o(j))));var E,A=i(e.body||[]);try{for(A.s();!(E=A.n()).done;){var S=E.value,O=!0===S.name.includes("[]");if(!n(j[S.name])&&!1===O&&!1===S.optional&&null===S.defaultvalue)return r(new Error("Missing mandatory field ".concat(S.name," to make a POST request on ").concat(e.route.name)));if(o(j[S.name])!==S.type&&!1===O&&!1===S.optional&&null===S.defaultvalue)return r(new Error("Invalid type for field ".concat(S.name,", expected ").concat(S.type," but got ").concat(o(j[S.name]))));n(j[S.name])&&(s.data[S.name]=j[S.name]),!1===S.optional&&null!==S.defaultvalue&&(s.data[S.name]=S.defaultvalue)}}catch(e){A.e(e)}finally{A.f()}break;case"DELETE":var x,C=i(e.params||[]);try{for(C.s();!(x=C.n()).done;){var P=x.value,L=t.shift();if("string"!=typeof L&&!1===P.optional)return r(new Error("Expected to receive string argument for ".concat(P.name," to match but got ").concat(L)));L?s.url=s.url.replace(P.name,L):!1===P.optional&&null!==P.defaultvalue&&(s.url=s.url.replace(P.name,P.defaultvalue))}}catch(e){C.e(e)}finally{C.f()}var z,B=i(e.query||[]);try{for(B.s();!(z=B.n()).done;){var D=z.value,F=t.shift();if("string"!=typeof F&&!1===D.optional)return r(new Error("Expected to receive string argument for ".concat(D.name," query but got ").concat(F)));F?s.params[D.name]=F:!1===D.optional&&null!==D.defaultvalue&&(s.params[D.name]=D.defaultvalue)}}catch(e){B.e(e)}finally{B.f()}break;default:return r(new Error("Invalid endpoint declaration, invalid method ".concat(e.route.type," found")))}return a(s)})}}],(n=null)&&r(t.prototype,n),a&&r(t,a),Object.defineProperty(t,"prototype",{writable:!1}),e}()},{}],49:[function(e,t,n){"use strict";var o=e("ws"),i=e("debug")("kmjs:network:_ws"),a="function"!=typeof o?WebSocket:o,r={debug:!1,automaticOpen:!0,reconnectOnError:!0,reconnectInterval:1e3,maxReconnectInterval:1e4,reconnectDecay:1,timeoutInterval:2e3,maxReconnectAttempts:1/0,randomRatio:3,reconnectOnCleanClose:!1},s=function(e,t,n,o){n||(n=[]),o||(o=[]),this.CONNECTING=0,this.OPEN=1,this.CLOSING=2,this.CLOSED=3,this._url=e,this._token=t,this._protocols=n,this._options=Object.assign({},r,o),this._messageQueue=[],this._reconnectAttempts=0,this.readyState=this.CONNECTING,"function"==typeof this._options.debug?this._debug=this._options.debug:this._options.debug?this._debug=console.log.bind(console):this._debug=function(){},this._options.automaticOpen&&this.open()};s.prototype.updateAuthorization=function(e){this._token=e},s.prototype.open=function(){i("open");var e=this._socket=new a("".concat(this._url,"?token=").concat(this._token),this._protocols);if(this._options.binaryType&&(e.binaryType=this._options.binaryType),this._options.maxReconnectAttempts&&this._options.maxReconnectAttemptsthis._options.maxReconnectInterval?this._options.maxReconnectInterval:n,this._options.randomRatio?(e=n/this._options.randomRatio,t=n,Math.random()*(t-e)+e):n},s.prototype._syncState=function(){this.readyState=this._socket.readyState},t.exports=s},{debug:4,ws:3}],"/":[function(e,t,n){"use strict";t.exports=e("./src/keymetrics.js")},{"./src/keymetrics.js":45}]},{},[])("/")});
diff --git a/node_modules/@pm2/js-api/index.js b/node_modules/@pm2/js-api/index.js
new file mode 100644
index 0000000..66e9a5b
--- /dev/null
+++ b/node_modules/@pm2/js-api/index.js
@@ -0,0 +1 @@
+module.exports = require('./src/keymetrics.js')
diff --git a/node_modules/@pm2/js-api/node_modules/async/CHANGELOG.md b/node_modules/@pm2/js-api/node_modules/async/CHANGELOG.md
new file mode 100644
index 0000000..ec6b871
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/async/CHANGELOG.md
@@ -0,0 +1,278 @@
+# v2.6.4
+- Fix potential prototype pollution exploit (#1828)
+
+# v2.6.3
+- Updated lodash to squelch a security warning (#1675)
+
+# v2.6.2
+- Updated lodash to squelch a security warning (#1620)
+
+# v2.6.1
+- Updated lodash to prevent `npm audit` warnings. (#1532, #1533)
+- Made `async-es` more optimized for webpack users (#1517)
+- Fixed a stack overflow with large collections and a synchronous iterator (#1514)
+- Various small fixes/chores (#1505, #1511, #1527, #1530)
+
+# v2.6.0
+- Added missing aliases for many methods. Previously, you could not (e.g.) `require('async/find')` or use `async.anyLimit`. (#1483)
+- Improved `queue` performance. (#1448, #1454)
+- Add missing sourcemap (#1452, #1453)
+- Various doc updates (#1448, #1471, #1483)
+
+# v2.5.0
+- Added `concatLimit`, the `Limit` equivalent of [`concat`](https://caolan.github.io/async/docs.html#concat) ([#1426](https://github.com/caolan/async/issues/1426), [#1430](https://github.com/caolan/async/pull/1430))
+- `concat` improvements: it now preserves order, handles falsy values and the `iteratee` callback takes a variable number of arguments ([#1437](https://github.com/caolan/async/issues/1437), [#1436](https://github.com/caolan/async/pull/1436))
+- Fixed an issue in `queue` where there was a size discrepancy between `workersList().length` and `running()` ([#1428](https://github.com/caolan/async/issues/1428), [#1429](https://github.com/caolan/async/pull/1429))
+- Various doc fixes ([#1422](https://github.com/caolan/async/issues/1422), [#1424](https://github.com/caolan/async/pull/1424))
+
+# v2.4.1
+- Fixed a bug preventing functions wrapped with `timeout()` from being re-used. ([#1418](https://github.com/caolan/async/issues/1418), [#1419](https://github.com/caolan/async/issues/1419))
+
+# v2.4.0
+- Added `tryEach`, for running async functions in parallel, where you only expect one to succeed. ([#1365](https://github.com/caolan/async/issues/1365), [#687](https://github.com/caolan/async/issues/687))
+- Improved performance, most notably in `parallel` and `waterfall` ([#1395](https://github.com/caolan/async/issues/1395))
+- Added `queue.remove()`, for removing items in a `queue` ([#1397](https://github.com/caolan/async/issues/1397), [#1391](https://github.com/caolan/async/issues/1391))
+- Fixed using `eval`, preventing Async from running in pages with Content Security Policy ([#1404](https://github.com/caolan/async/issues/1404), [#1403](https://github.com/caolan/async/issues/1403))
+- Fixed errors thrown in an `asyncify`ed function's callback being caught by the underlying Promise ([#1408](https://github.com/caolan/async/issues/1408))
+- Fixed timing of `queue.empty()` ([#1367](https://github.com/caolan/async/issues/1367))
+- Various doc fixes ([#1314](https://github.com/caolan/async/issues/1314), [#1394](https://github.com/caolan/async/issues/1394), [#1412](https://github.com/caolan/async/issues/1412))
+
+# v2.3.0
+- Added support for ES2017 `async` functions. Wherever you can pass a Node-style/CPS function that uses a callback, you can also pass an `async` function. Previously, you had to wrap `async` functions with `asyncify`. The caveat is that it will only work if `async` functions are supported natively in your environment, transpiled implementations can't be detected. ([#1386](https://github.com/caolan/async/issues/1386), [#1390](https://github.com/caolan/async/issues/1390))
+- Small doc fix ([#1392](https://github.com/caolan/async/issues/1392))
+
+# v2.2.0
+- Added `groupBy`, and the `Series`/`Limit` equivalents, analogous to [`_.groupBy`](http://lodash.com/docs#groupBy) ([#1364](https://github.com/caolan/async/issues/1364))
+- Fixed `transform` bug when `callback` was not passed ([#1381](https://github.com/caolan/async/issues/1381))
+- Added note about `reflect` to `parallel` docs ([#1385](https://github.com/caolan/async/issues/1385))
+
+# v2.1.5
+- Fix `auto` bug when function names collided with Array.prototype ([#1358](https://github.com/caolan/async/issues/1358))
+- Improve some error messages ([#1349](https://github.com/caolan/async/issues/1349))
+- Avoid stack overflow case in queue
+- Fixed an issue in `some`, `every` and `find` where processing would continue after the result was determined.
+- Cleanup implementations of `some`, `every` and `find`
+
+# v2.1.3
+- Make bundle size smaller
+- Create optimized hotpath for `filter` in array case.
+
+# v2.1.2
+- Fixed a stackoverflow bug with `detect`, `some`, `every` on large inputs ([#1293](https://github.com/caolan/async/issues/1293)).
+
+# v2.1.0
+
+- `retry` and `retryable` now support an optional `errorFilter` function that determines if the `task` should retry on the error ([#1256](https://github.com/caolan/async/issues/1256), [#1261](https://github.com/caolan/async/issues/1261))
+- Optimized array iteration in `race`, `cargo`, `queue`, and `priorityQueue` ([#1253](https://github.com/caolan/async/issues/1253))
+- Added alias documentation to doc site ([#1251](https://github.com/caolan/async/issues/1251), [#1254](https://github.com/caolan/async/issues/1254))
+- Added [BootStrap scrollspy](http://getbootstrap.com/javascript/#scrollspy) to docs to highlight in the sidebar the current method being viewed ([#1289](https://github.com/caolan/async/issues/1289), [#1300](https://github.com/caolan/async/issues/1300))
+- Various minor doc fixes ([#1263](https://github.com/caolan/async/issues/1263), [#1264](https://github.com/caolan/async/issues/1264), [#1271](https://github.com/caolan/async/issues/1271), [#1278](https://github.com/caolan/async/issues/1278), [#1280](https://github.com/caolan/async/issues/1280), [#1282](https://github.com/caolan/async/issues/1282), [#1302](https://github.com/caolan/async/issues/1302))
+
+# v2.0.1
+
+- Significantly optimized all iteration based collection methods such as `each`, `map`, `filter`, etc ([#1245](https://github.com/caolan/async/issues/1245), [#1246](https://github.com/caolan/async/issues/1246), [#1247](https://github.com/caolan/async/issues/1247)).
+
+# v2.0.0
+
+Lots of changes here!
+
+First and foremost, we have a slick new [site for docs](https://caolan.github.io/async/). Special thanks to [**@hargasinski**](https://github.com/hargasinski) for his work converting our old docs to `jsdoc` format and implementing the new website. Also huge ups to [**@ivanseidel**](https://github.com/ivanseidel) for designing our new logo. It was a long process for both of these tasks, but I think these changes turned out extraordinary well.
+
+The biggest feature is modularization. You can now `require("async/series")` to only require the `series` function. Every Async library function is available this way. You still can `require("async")` to require the entire library, like you could do before.
+
+We also provide Async as a collection of ES2015 modules. You can now `import {each} from 'async-es'` or `import waterfall from 'async-es/waterfall'`. If you are using only a few Async functions, and are using a ES bundler such as Rollup, this can significantly lower your build size.
+
+Major thanks to [**@Kikobeats**](github.com/Kikobeats), [**@aearly**](github.com/aearly) and [**@megawac**](github.com/megawac) for doing the majority of the modularization work, as well as [**@jdalton**](github.com/jdalton) and [**@Rich-Harris**](github.com/Rich-Harris) for advisory work on the general modularization strategy.
+
+Another one of the general themes of the 2.0 release is standardization of what an "async" function is. We are now more strictly following the node-style continuation passing style. That is, an async function is a function that:
+
+1. Takes a variable number of arguments
+2. The last argument is always a callback
+3. The callback can accept any number of arguments
+4. The first argument passed to the callback will be treated as an error result, if the argument is truthy
+5. Any number of result arguments can be passed after the "error" argument
+6. The callback is called once and exactly once, either on the same tick or later tick of the JavaScript event loop.
+
+There were several cases where Async accepted some functions that did not strictly have these properties, most notably `auto`, `every`, `some`, `filter`, `reject` and `detect`.
+
+Another theme is performance. We have eliminated internal deferrals in all cases where they make sense. For example, in `waterfall` and `auto`, there was a `setImmediate` between each task -- these deferrals have been removed. A `setImmediate` call can add up to 1ms of delay. This might not seem like a lot, but it can add up if you are using many Async functions in the course of processing a HTTP request, for example. Nearly all asynchronous functions that do I/O already have some sort of deferral built in, so the extra deferral is unnecessary. The trade-off of this change is removing our built-in stack-overflow defense. Many synchronous callback calls in series can quickly overflow the JS call stack. If you do have a function that is sometimes synchronous (calling its callback on the same tick), and are running into stack overflows, wrap it with `async.ensureAsync()`.
+
+Another big performance win has been re-implementing `queue`, `cargo`, and `priorityQueue` with [doubly linked lists](https://en.wikipedia.org/wiki/Doubly_linked_list) instead of arrays. This has lead to queues being an order of [magnitude faster on large sets of tasks](https://github.com/caolan/async/pull/1205).
+
+## New Features
+
+- Async is now modularized. Individual functions can be `require()`d from the main package. (`require('async/auto')`) ([#984](https://github.com/caolan/async/issues/984), [#996](https://github.com/caolan/async/issues/996))
+- Async is also available as a collection of ES2015 modules in the new `async-es` package. (`import {forEachSeries} from 'async-es'`) ([#984](https://github.com/caolan/async/issues/984), [#996](https://github.com/caolan/async/issues/996))
+- Added `race`, analogous to `Promise.race()`. It will run an array of async tasks in parallel and will call its callback with the result of the first task to respond. ([#568](https://github.com/caolan/async/issues/568), [#1038](https://github.com/caolan/async/issues/1038))
+- Collection methods now accept ES2015 iterators. Maps, Sets, and anything that implements the iterator spec can now be passed directly to `each`, `map`, `parallel`, etc.. ([#579](https://github.com/caolan/async/issues/579), [#839](https://github.com/caolan/async/issues/839), [#1074](https://github.com/caolan/async/issues/1074))
+- Added `mapValues`, for mapping over the properties of an object and returning an object with the same keys. ([#1157](https://github.com/caolan/async/issues/1157), [#1177](https://github.com/caolan/async/issues/1177))
+- Added `timeout`, a wrapper for an async function that will make the task time-out after the specified time. ([#1007](https://github.com/caolan/async/issues/1007), [#1027](https://github.com/caolan/async/issues/1027))
+- Added `reflect` and `reflectAll`, analagous to [`Promise.reflect()`](http://bluebirdjs.com/docs/api/reflect.html), a wrapper for async tasks that always succeeds, by gathering results and errors into an object. ([#942](https://github.com/caolan/async/issues/942), [#1012](https://github.com/caolan/async/issues/1012), [#1095](https://github.com/caolan/async/issues/1095))
+- `constant` supports dynamic arguments -- it will now always use its last argument as the callback. ([#1016](https://github.com/caolan/async/issues/1016), [#1052](https://github.com/caolan/async/issues/1052))
+- `setImmediate` and `nextTick` now support arguments to partially apply to the deferred function, like the node-native versions do. ([#940](https://github.com/caolan/async/issues/940), [#1053](https://github.com/caolan/async/issues/1053))
+- `auto` now supports resolving cyclic dependencies using [Kahn's algorithm](https://en.wikipedia.org/wiki/Topological_sorting#Kahn.27s_algorithm) ([#1140](https://github.com/caolan/async/issues/1140)).
+- Added `autoInject`, a relative of `auto` that automatically spreads a task's dependencies as arguments to the task function. ([#608](https://github.com/caolan/async/issues/608), [#1055](https://github.com/caolan/async/issues/1055), [#1099](https://github.com/caolan/async/issues/1099), [#1100](https://github.com/caolan/async/issues/1100))
+- You can now limit the concurrency of `auto` tasks. ([#635](https://github.com/caolan/async/issues/635), [#637](https://github.com/caolan/async/issues/637))
+- Added `retryable`, a relative of `retry` that wraps an async function, making it retry when called. ([#1058](https://github.com/caolan/async/issues/1058))
+- `retry` now supports specifying a function that determines the next time interval, useful for exponential backoff, logging and other retry strategies. ([#1161](https://github.com/caolan/async/issues/1161))
+- `retry` will now pass all of the arguments the task function was resolved with to the callback ([#1231](https://github.com/caolan/async/issues/1231)).
+- Added `q.unsaturated` -- callback called when a `queue`'s number of running workers falls below a threshold. ([#868](https://github.com/caolan/async/issues/868), [#1030](https://github.com/caolan/async/issues/1030), [#1033](https://github.com/caolan/async/issues/1033), [#1034](https://github.com/caolan/async/issues/1034))
+- Added `q.error` -- a callback called whenever a `queue` task calls its callback with an error. ([#1170](https://github.com/caolan/async/issues/1170))
+- `applyEach` and `applyEachSeries` now pass results to the final callback. ([#1088](https://github.com/caolan/async/issues/1088))
+
+## Breaking changes
+
+- Calling a callback more than once is considered an error, and an error will be thrown. This had an explicit breaking change in `waterfall`. If you were relying on this behavior, you should more accurately represent your control flow as an event emitter or stream. ([#814](https://github.com/caolan/async/issues/814), [#815](https://github.com/caolan/async/issues/815), [#1048](https://github.com/caolan/async/issues/1048), [#1050](https://github.com/caolan/async/issues/1050))
+- `auto` task functions now always take the callback as the last argument. If a task has dependencies, the `results` object will be passed as the first argument. To migrate old task functions, wrap them with [`_.flip`](https://lodash.com/docs#flip) ([#1036](https://github.com/caolan/async/issues/1036), [#1042](https://github.com/caolan/async/issues/1042))
+- Internal `setImmediate` calls have been refactored away. This may make existing flows vulnerable to stack overflows if you use many synchronous functions in series. Use `ensureAsync` to work around this. ([#696](https://github.com/caolan/async/issues/696), [#704](https://github.com/caolan/async/issues/704), [#1049](https://github.com/caolan/async/issues/1049), [#1050](https://github.com/caolan/async/issues/1050))
+- `map` used to return an object when iterating over an object. `map` now always returns an array, like in other libraries. The previous object behavior has been split out into `mapValues`. ([#1157](https://github.com/caolan/async/issues/1157), [#1177](https://github.com/caolan/async/issues/1177))
+- `filter`, `reject`, `some`, `every`, `detect` and their families like `{METHOD}Series` and `{METHOD}Limit` now expect an error as the first callback argument, rather than just a simple boolean. Pass `null` as the first argument, or use `fs.access` instead of `fs.exists`. ([#118](https://github.com/caolan/async/issues/118), [#774](https://github.com/caolan/async/issues/774), [#1028](https://github.com/caolan/async/issues/1028), [#1041](https://github.com/caolan/async/issues/1041))
+- `{METHOD}` and `{METHOD}Series` are now implemented in terms of `{METHOD}Limit`. This is a major internal simplification, and is not expected to cause many problems, but it does subtly affect how functions execute internally. ([#778](https://github.com/caolan/async/issues/778), [#847](https://github.com/caolan/async/issues/847))
+- `retry`'s callback is now optional. Previously, omitting the callback would partially apply the function, meaning it could be passed directly as a task to `series` or `auto`. The partially applied "control-flow" behavior has been separated out into `retryable`. ([#1054](https://github.com/caolan/async/issues/1054), [#1058](https://github.com/caolan/async/issues/1058))
+- The test function for `whilst`, `until`, and `during` used to be passed non-error args from the iteratee function's callback, but this led to weirdness where the first call of the test function would be passed no args. We have made it so the test function is never passed extra arguments, and only the `doWhilst`, `doUntil`, and `doDuring` functions pass iteratee callback arguments to the test function ([#1217](https://github.com/caolan/async/issues/1217), [#1224](https://github.com/caolan/async/issues/1224))
+- The `q.tasks` array has been renamed `q._tasks` and is now implemented as a doubly linked list (DLL). Any code that used to interact with this array will need to be updated to either use the provided helpers or support DLLs ([#1205](https://github.com/caolan/async/issues/1205)).
+- The timing of the `q.saturated()` callback in a `queue` has been modified to better reflect when tasks pushed to the queue will start queueing. ([#724](https://github.com/caolan/async/issues/724), [#1078](https://github.com/caolan/async/issues/1078))
+- Removed `iterator` method in favour of [ES2015 iterator protocol](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Iterators_and_Generators ) which natively supports arrays ([#1237](https://github.com/caolan/async/issues/1237))
+- Dropped support for Component, Jam, SPM, and Volo ([#1175](https://github.com/caolan/async/issues/1175), #[#176](https://github.com/caolan/async/issues/176))
+
+## Bug Fixes
+
+- Improved handling of no dependency cases in `auto` & `autoInject` ([#1147](https://github.com/caolan/async/issues/1147)).
+- Fixed a bug where the callback generated by `asyncify` with `Promises` could resolve twice ([#1197](https://github.com/caolan/async/issues/1197)).
+- Fixed several documented optional callbacks not actually being optional ([#1223](https://github.com/caolan/async/issues/1223)).
+
+## Other
+
+- Added `someSeries` and `everySeries` for symmetry, as well as a complete set of `any`/`anyLimit`/`anySeries` and `all`/`/allLmit`/`allSeries` aliases.
+- Added `find` as an alias for `detect. (as well as `findLimit` and `findSeries`).
+- Various doc fixes ([#1005](https://github.com/caolan/async/issues/1005), [#1008](https://github.com/caolan/async/issues/1008), [#1010](https://github.com/caolan/async/issues/1010), [#1015](https://github.com/caolan/async/issues/1015), [#1021](https://github.com/caolan/async/issues/1021), [#1037](https://github.com/caolan/async/issues/1037), [#1039](https://github.com/caolan/async/issues/1039), [#1051](https://github.com/caolan/async/issues/1051), [#1102](https://github.com/caolan/async/issues/1102), [#1107](https://github.com/caolan/async/issues/1107), [#1121](https://github.com/caolan/async/issues/1121), [#1123](https://github.com/caolan/async/issues/1123), [#1129](https://github.com/caolan/async/issues/1129), [#1135](https://github.com/caolan/async/issues/1135), [#1138](https://github.com/caolan/async/issues/1138), [#1141](https://github.com/caolan/async/issues/1141), [#1153](https://github.com/caolan/async/issues/1153), [#1216](https://github.com/caolan/async/issues/1216), [#1217](https://github.com/caolan/async/issues/1217), [#1232](https://github.com/caolan/async/issues/1232), [#1233](https://github.com/caolan/async/issues/1233), [#1236](https://github.com/caolan/async/issues/1236), [#1238](https://github.com/caolan/async/issues/1238))
+
+Thank you [**@aearly**](github.com/aearly) and [**@megawac**](github.com/megawac) for taking the lead on version 2 of async.
+
+------------------------------------------
+
+# v1.5.2
+- Allow using `"constructor"` as an argument in `memoize` ([#998](https://github.com/caolan/async/issues/998))
+- Give a better error messsage when `auto` dependency checking fails ([#994](https://github.com/caolan/async/issues/994))
+- Various doc updates ([#936](https://github.com/caolan/async/issues/936), [#956](https://github.com/caolan/async/issues/956), [#979](https://github.com/caolan/async/issues/979), [#1002](https://github.com/caolan/async/issues/1002))
+
+# v1.5.1
+- Fix issue with `pause` in `queue` with concurrency enabled ([#946](https://github.com/caolan/async/issues/946))
+- `while` and `until` now pass the final result to callback ([#963](https://github.com/caolan/async/issues/963))
+- `auto` will properly handle concurrency when there is no callback ([#966](https://github.com/caolan/async/issues/966))
+- `auto` will no. properly stop execution when an error occurs ([#988](https://github.com/caolan/async/issues/988), [#993](https://github.com/caolan/async/issues/993))
+- Various doc fixes ([#971](https://github.com/caolan/async/issues/971), [#980](https://github.com/caolan/async/issues/980))
+
+# v1.5.0
+
+- Added `transform`, analogous to [`_.transform`](http://lodash.com/docs#transform) ([#892](https://github.com/caolan/async/issues/892))
+- `map` now returns an object when an object is passed in, rather than array with non-numeric keys. `map` will begin always returning an array with numeric indexes in the next major release. ([#873](https://github.com/caolan/async/issues/873))
+- `auto` now accepts an optional `concurrency` argument to limit the number o. running tasks ([#637](https://github.com/caolan/async/issues/637))
+- Added `queue#workersList()`, to retrieve the lis. of currently running tasks. ([#891](https://github.com/caolan/async/issues/891))
+- Various code simplifications ([#896](https://github.com/caolan/async/issues/896), [#904](https://github.com/caolan/async/issues/904))
+- Various doc fixes :scroll: ([#890](https://github.com/caolan/async/issues/890), [#894](https://github.com/caolan/async/issues/894), [#903](https://github.com/caolan/async/issues/903), [#905](https://github.com/caolan/async/issues/905), [#912](https://github.com/caolan/async/issues/912))
+
+# v1.4.2
+
+- Ensure coverage files don't get published on npm ([#879](https://github.com/caolan/async/issues/879))
+
+# v1.4.1
+
+- Add in overlooked `detectLimit` method ([#866](https://github.com/caolan/async/issues/866))
+- Removed unnecessary files from npm releases ([#861](https://github.com/caolan/async/issues/861))
+- Removed usage of a reserved word to prevent :boom: in older environments ([#870](https://github.com/caolan/async/issues/870))
+
+# v1.4.0
+
+- `asyncify` now supports promises ([#840](https://github.com/caolan/async/issues/840))
+- Added `Limit` versions of `filter` and `reject` ([#836](https://github.com/caolan/async/issues/836))
+- Add `Limit` versions of `detect`, `some` and `every` ([#828](https://github.com/caolan/async/issues/828), [#829](https://github.com/caolan/async/issues/829))
+- `some`, `every` and `detect` now short circuit early ([#828](https://github.com/caolan/async/issues/828), [#829](https://github.com/caolan/async/issues/829))
+- Improve detection of the global object ([#804](https://github.com/caolan/async/issues/804)), enabling use in WebWorkers
+- `whilst` now called with arguments from iterator ([#823](https://github.com/caolan/async/issues/823))
+- `during` now gets called with arguments from iterator ([#824](https://github.com/caolan/async/issues/824))
+- Code simplifications and optimizations aplenty ([diff](https://github.com/caolan/async/compare/v1.3.0...v1.4.0))
+
+
+# v1.3.0
+
+New Features:
+- Added `constant`
+- Added `asyncify`/`wrapSync` for making sync functions work with callbacks. ([#671](https://github.com/caolan/async/issues/671), [#806](https://github.com/caolan/async/issues/806))
+- Added `during` and `doDuring`, which are like `whilst` with an async truth test. ([#800](https://github.com/caolan/async/issues/800))
+- `retry` now accepts an `interval` parameter to specify a delay between retries. ([#793](https://github.com/caolan/async/issues/793))
+- `async` should work better in Web Workers due to better `root` detection ([#804](https://github.com/caolan/async/issues/804))
+- Callbacks are now optional in `whilst`, `doWhilst`, `until`, and `doUntil` ([#642](https://github.com/caolan/async/issues/642))
+- Various internal updates ([#786](https://github.com/caolan/async/issues/786), [#801](https://github.com/caolan/async/issues/801), [#802](https://github.com/caolan/async/issues/802), [#803](https://github.com/caolan/async/issues/803))
+- Various doc fixes ([#790](https://github.com/caolan/async/issues/790), [#794](https://github.com/caolan/async/issues/794))
+
+Bug Fixes:
+- `cargo` now exposes the `payload` size, and `cargo.payload` can be changed on the fly after the `cargo` is created. ([#740](https://github.com/caolan/async/issues/740), [#744](https://github.com/caolan/async/issues/744), [#783](https://github.com/caolan/async/issues/783))
+
+
+# v1.2.1
+
+Bug Fix:
+
+- Small regression with synchronous iterator behavior in `eachSeries` with a 1-element array. Before 1.1.0, `eachSeries`'s callback was called on the same tick, which this patch restores. In 2.0.0, it will be called on the next tick. ([#782](https://github.com/caolan/async/issues/782))
+
+
+# v1.2.0
+
+New Features:
+
+- Added `timesLimit` ([#743](https://github.com/caolan/async/issues/743))
+- `concurrency` can be changed after initialization in `queue` by setting `q.concurrency`. The new concurrency will be reflected the next time a task is processed. ([#747](https://github.com/caolan/async/issues/747), [#772](https://github.com/caolan/async/issues/772))
+
+Bug Fixes:
+
+- Fixed a regression in `each` and family with empty arrays that have additional properties. ([#775](https://github.com/caolan/async/issues/775), [#777](https://github.com/caolan/async/issues/777))
+
+
+# v1.1.1
+
+Bug Fix:
+
+- Small regression with synchronous iterator behavior in `eachSeries` with a 1-element array. Before 1.1.0, `eachSeries`'s callback was called on the same tick, which this patch restores. In 2.0.0, it will be called on the next tick. ([#782](https://github.com/caolan/async/issues/782))
+
+
+# v1.1.0
+
+New Features:
+
+- `cargo` now supports all of the same methods and event callbacks as `queue`.
+- Added `ensureAsync` - A wrapper that ensures an async function calls its callback on a later tick. ([#769](https://github.com/caolan/async/issues/769))
+- Optimized `map`, `eachOf`, and `waterfall` families of functions
+- Passing a `null` or `undefined` array to `map`, `each`, `parallel` and families will be treated as an empty array ([#667](https://github.com/caolan/async/issues/667)).
+- The callback is now optional for the composed results of `compose` and `seq`. ([#618](https://github.com/caolan/async/issues/618))
+- Reduced file size by 4kb, (minified version by 1kb)
+- Added code coverage through `nyc` and `coveralls` ([#768](https://github.com/caolan/async/issues/768))
+
+Bug Fixes:
+
+- `forever` will no longer stack overflow with a synchronous iterator ([#622](https://github.com/caolan/async/issues/622))
+- `eachLimit` and other limit functions will stop iterating once an error occurs ([#754](https://github.com/caolan/async/issues/754))
+- Always pass `null` in callbacks when there is no error ([#439](https://github.com/caolan/async/issues/439))
+- Ensure proper conditions when calling `drain()` after pushing an empty data set to a queue ([#668](https://github.com/caolan/async/issues/668))
+- `each` and family will properly handle an empty array ([#578](https://github.com/caolan/async/issues/578))
+- `eachSeries` and family will finish if the underlying array is modified during execution ([#557](https://github.com/caolan/async/issues/557))
+- `queue` will throw if a non-function is passed to `q.push()` ([#593](https://github.com/caolan/async/issues/593))
+- Doc fixes ([#629](https://github.com/caolan/async/issues/629), [#766](https://github.com/caolan/async/issues/766))
+
+
+# v1.0.0
+
+No known breaking changes, we are simply complying with semver from here on out.
+
+Changes:
+
+- Start using a changelog!
+- Add `forEachOf` for iterating over Objects (or to iterate Arrays with indexes available) ([#168](https://github.com/caolan/async/issues/168) [#704](https://github.com/caolan/async/issues/704) [#321](https://github.com/caolan/async/issues/321))
+- Detect deadlocks in `auto` ([#663](https://github.com/caolan/async/issues/663))
+- Better support for require.js ([#527](https://github.com/caolan/async/issues/527))
+- Throw if queue created with concurrency `0` ([#714](https://github.com/caolan/async/issues/714))
+- Fix unneeded iteration in `queue.resume()` ([#758](https://github.com/caolan/async/issues/758))
+- Guard against timer mocking overriding `setImmediate` ([#609](https://github.com/caolan/async/issues/609) [#611](https://github.com/caolan/async/issues/611))
+- Miscellaneous doc fixes ([#542](https://github.com/caolan/async/issues/542) [#596](https://github.com/caolan/async/issues/596) [#615](https://github.com/caolan/async/issues/615) [#628](https://github.com/caolan/async/issues/628) [#631](https://github.com/caolan/async/issues/631) [#690](https://github.com/caolan/async/issues/690) [#729](https://github.com/caolan/async/issues/729))
+- Use single noop function internally ([#546](https://github.com/caolan/async/issues/546))
+- Optimize internal `_each`, `_map` and `_keys` functions.
diff --git a/node_modules/@pm2/js-api/node_modules/async/LICENSE b/node_modules/@pm2/js-api/node_modules/async/LICENSE
new file mode 100644
index 0000000..b18aed6
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/async/LICENSE
@@ -0,0 +1,19 @@
+Copyright (c) 2010-2018 Caolan McMahon
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
diff --git a/node_modules/@pm2/js-api/node_modules/async/README.md b/node_modules/@pm2/js-api/node_modules/async/README.md
new file mode 100644
index 0000000..49cf950
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/async/README.md
@@ -0,0 +1,56 @@
+
+
+[](https://travis-ci.org/caolan/async)
+[](https://www.npmjs.com/package/async)
+[](https://coveralls.io/r/caolan/async?branch=master)
+[](https://gitter.im/caolan/async?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
+[](https://www.libhive.com/providers/npm/packages/async)
+[](https://www.jsdelivr.com/package/npm/async)
+
+
+Async is a utility module which provides straight-forward, powerful functions for working with [asynchronous JavaScript](http://caolan.github.io/async/global.html). Although originally designed for use with [Node.js](https://nodejs.org/) and installable via `npm install --save async`, it can also be used directly in the browser.
+
+This version of the package is optimized for the Node.js environment. If you use Async with webpack, install [`async-es`](https://www.npmjs.com/package/async-es) instead.
+
+For Documentation, visit
+
+*For Async v1.5.x documentation, go [HERE](https://github.com/caolan/async/blob/v1.5.2/README.md)*
+
+
+```javascript
+// for use with Node-style callbacks...
+var async = require("async");
+
+var obj = {dev: "/dev.json", test: "/test.json", prod: "/prod.json"};
+var configs = {};
+
+async.forEachOf(obj, (value, key, callback) => {
+ fs.readFile(__dirname + value, "utf8", (err, data) => {
+ if (err) return callback(err);
+ try {
+ configs[key] = JSON.parse(data);
+ } catch (e) {
+ return callback(e);
+ }
+ callback();
+ });
+}, err => {
+ if (err) console.error(err.message);
+ // configs is now a map of JSON data
+ doSomethingWith(configs);
+});
+```
+
+```javascript
+var async = require("async");
+
+// ...or ES2017 async functions
+async.mapLimit(urls, 5, async function(url) {
+ const response = await fetch(url)
+ return response.body
+}, (err, results) => {
+ if (err) throw err
+ // results is now an array of the response bodies
+ console.log(results)
+})
+```
diff --git a/node_modules/@pm2/js-api/node_modules/async/all.js b/node_modules/@pm2/js-api/node_modules/async/all.js
new file mode 100644
index 0000000..d0565b0
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/async/all.js
@@ -0,0 +1,50 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+var _createTester = require('./internal/createTester');
+
+var _createTester2 = _interopRequireDefault(_createTester);
+
+var _doParallel = require('./internal/doParallel');
+
+var _doParallel2 = _interopRequireDefault(_doParallel);
+
+var _notId = require('./internal/notId');
+
+var _notId2 = _interopRequireDefault(_notId);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * Returns `true` if every element in `coll` satisfies an async test. If any
+ * iteratee call returns `false`, the main `callback` is immediately called.
+ *
+ * @name every
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @alias all
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {AsyncFunction} iteratee - An async truth test to apply to each item
+ * in the collection in parallel.
+ * The iteratee must complete with a boolean result value.
+ * Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called after all the
+ * `iteratee` functions have finished. Result will be either `true` or `false`
+ * depending on the values of the async tests. Invoked with (err, result).
+ * @example
+ *
+ * async.every(['file1','file2','file3'], function(filePath, callback) {
+ * fs.access(filePath, function(err) {
+ * callback(null, !err)
+ * });
+ * }, function(err, result) {
+ * // if result is true then every file exists
+ * });
+ */
+exports.default = (0, _doParallel2.default)((0, _createTester2.default)(_notId2.default, _notId2.default));
+module.exports = exports['default'];
\ No newline at end of file
diff --git a/node_modules/@pm2/js-api/node_modules/async/allLimit.js b/node_modules/@pm2/js-api/node_modules/async/allLimit.js
new file mode 100644
index 0000000..a1a759a
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/async/allLimit.js
@@ -0,0 +1,42 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+var _createTester = require('./internal/createTester');
+
+var _createTester2 = _interopRequireDefault(_createTester);
+
+var _doParallelLimit = require('./internal/doParallelLimit');
+
+var _doParallelLimit2 = _interopRequireDefault(_doParallelLimit);
+
+var _notId = require('./internal/notId');
+
+var _notId2 = _interopRequireDefault(_notId);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * The same as [`every`]{@link module:Collections.every} but runs a maximum of `limit` async operations at a time.
+ *
+ * @name everyLimit
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.every]{@link module:Collections.every}
+ * @alias allLimit
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {number} limit - The maximum number of async operations at a time.
+ * @param {AsyncFunction} iteratee - An async truth test to apply to each item
+ * in the collection in parallel.
+ * The iteratee must complete with a boolean result value.
+ * Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called after all the
+ * `iteratee` functions have finished. Result will be either `true` or `false`
+ * depending on the values of the async tests. Invoked with (err, result).
+ */
+exports.default = (0, _doParallelLimit2.default)((0, _createTester2.default)(_notId2.default, _notId2.default));
+module.exports = exports['default'];
\ No newline at end of file
diff --git a/node_modules/@pm2/js-api/node_modules/async/allSeries.js b/node_modules/@pm2/js-api/node_modules/async/allSeries.js
new file mode 100644
index 0000000..23bfebb
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/async/allSeries.js
@@ -0,0 +1,37 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+var _everyLimit = require('./everyLimit');
+
+var _everyLimit2 = _interopRequireDefault(_everyLimit);
+
+var _doLimit = require('./internal/doLimit');
+
+var _doLimit2 = _interopRequireDefault(_doLimit);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * The same as [`every`]{@link module:Collections.every} but runs only a single async operation at a time.
+ *
+ * @name everySeries
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.every]{@link module:Collections.every}
+ * @alias allSeries
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {AsyncFunction} iteratee - An async truth test to apply to each item
+ * in the collection in series.
+ * The iteratee must complete with a boolean result value.
+ * Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called after all the
+ * `iteratee` functions have finished. Result will be either `true` or `false`
+ * depending on the values of the async tests. Invoked with (err, result).
+ */
+exports.default = (0, _doLimit2.default)(_everyLimit2.default, 1);
+module.exports = exports['default'];
\ No newline at end of file
diff --git a/node_modules/@pm2/js-api/node_modules/async/any.js b/node_modules/@pm2/js-api/node_modules/async/any.js
new file mode 100644
index 0000000..a8e70f7
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/async/any.js
@@ -0,0 +1,52 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+var _createTester = require('./internal/createTester');
+
+var _createTester2 = _interopRequireDefault(_createTester);
+
+var _doParallel = require('./internal/doParallel');
+
+var _doParallel2 = _interopRequireDefault(_doParallel);
+
+var _identity = require('lodash/identity');
+
+var _identity2 = _interopRequireDefault(_identity);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * Returns `true` if at least one element in the `coll` satisfies an async test.
+ * If any iteratee call returns `true`, the main `callback` is immediately
+ * called.
+ *
+ * @name some
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @alias any
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {AsyncFunction} iteratee - An async truth test to apply to each item
+ * in the collections in parallel.
+ * The iteratee should complete with a boolean `result` value.
+ * Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called as soon as any
+ * iteratee returns `true`, or after all the iteratee functions have finished.
+ * Result will be either `true` or `false` depending on the values of the async
+ * tests. Invoked with (err, result).
+ * @example
+ *
+ * async.some(['file1','file2','file3'], function(filePath, callback) {
+ * fs.access(filePath, function(err) {
+ * callback(null, !err)
+ * });
+ * }, function(err, result) {
+ * // if result is true then at least one of the files exists
+ * });
+ */
+exports.default = (0, _doParallel2.default)((0, _createTester2.default)(Boolean, _identity2.default));
+module.exports = exports['default'];
\ No newline at end of file
diff --git a/node_modules/@pm2/js-api/node_modules/async/anyLimit.js b/node_modules/@pm2/js-api/node_modules/async/anyLimit.js
new file mode 100644
index 0000000..24ca3f4
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/async/anyLimit.js
@@ -0,0 +1,43 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+var _createTester = require('./internal/createTester');
+
+var _createTester2 = _interopRequireDefault(_createTester);
+
+var _doParallelLimit = require('./internal/doParallelLimit');
+
+var _doParallelLimit2 = _interopRequireDefault(_doParallelLimit);
+
+var _identity = require('lodash/identity');
+
+var _identity2 = _interopRequireDefault(_identity);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * The same as [`some`]{@link module:Collections.some} but runs a maximum of `limit` async operations at a time.
+ *
+ * @name someLimit
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.some]{@link module:Collections.some}
+ * @alias anyLimit
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {number} limit - The maximum number of async operations at a time.
+ * @param {AsyncFunction} iteratee - An async truth test to apply to each item
+ * in the collections in parallel.
+ * The iteratee should complete with a boolean `result` value.
+ * Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called as soon as any
+ * iteratee returns `true`, or after all the iteratee functions have finished.
+ * Result will be either `true` or `false` depending on the values of the async
+ * tests. Invoked with (err, result).
+ */
+exports.default = (0, _doParallelLimit2.default)((0, _createTester2.default)(Boolean, _identity2.default));
+module.exports = exports['default'];
\ No newline at end of file
diff --git a/node_modules/@pm2/js-api/node_modules/async/anySeries.js b/node_modules/@pm2/js-api/node_modules/async/anySeries.js
new file mode 100644
index 0000000..dc24ed2
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/async/anySeries.js
@@ -0,0 +1,38 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+var _someLimit = require('./someLimit');
+
+var _someLimit2 = _interopRequireDefault(_someLimit);
+
+var _doLimit = require('./internal/doLimit');
+
+var _doLimit2 = _interopRequireDefault(_doLimit);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * The same as [`some`]{@link module:Collections.some} but runs only a single async operation at a time.
+ *
+ * @name someSeries
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.some]{@link module:Collections.some}
+ * @alias anySeries
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {AsyncFunction} iteratee - An async truth test to apply to each item
+ * in the collections in series.
+ * The iteratee should complete with a boolean `result` value.
+ * Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called as soon as any
+ * iteratee returns `true`, or after all the iteratee functions have finished.
+ * Result will be either `true` or `false` depending on the values of the async
+ * tests. Invoked with (err, result).
+ */
+exports.default = (0, _doLimit2.default)(_someLimit2.default, 1);
+module.exports = exports['default'];
\ No newline at end of file
diff --git a/node_modules/@pm2/js-api/node_modules/async/apply.js b/node_modules/@pm2/js-api/node_modules/async/apply.js
new file mode 100644
index 0000000..f590fa5
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/async/apply.js
@@ -0,0 +1,68 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+exports.default = function (fn /*, ...args*/) {
+ var args = (0, _slice2.default)(arguments, 1);
+ return function () /*callArgs*/{
+ var callArgs = (0, _slice2.default)(arguments);
+ return fn.apply(null, args.concat(callArgs));
+ };
+};
+
+var _slice = require('./internal/slice');
+
+var _slice2 = _interopRequireDefault(_slice);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+;
+
+/**
+ * Creates a continuation function with some arguments already applied.
+ *
+ * Useful as a shorthand when combined with other control flow functions. Any
+ * arguments passed to the returned function are added to the arguments
+ * originally passed to apply.
+ *
+ * @name apply
+ * @static
+ * @memberOf module:Utils
+ * @method
+ * @category Util
+ * @param {Function} fn - The function you want to eventually apply all
+ * arguments to. Invokes with (arguments...).
+ * @param {...*} arguments... - Any number of arguments to automatically apply
+ * when the continuation is called.
+ * @returns {Function} the partially-applied function
+ * @example
+ *
+ * // using apply
+ * async.parallel([
+ * async.apply(fs.writeFile, 'testfile1', 'test1'),
+ * async.apply(fs.writeFile, 'testfile2', 'test2')
+ * ]);
+ *
+ *
+ * // the same process without using apply
+ * async.parallel([
+ * function(callback) {
+ * fs.writeFile('testfile1', 'test1', callback);
+ * },
+ * function(callback) {
+ * fs.writeFile('testfile2', 'test2', callback);
+ * }
+ * ]);
+ *
+ * // It's possible to pass any number of additional arguments when calling the
+ * // continuation:
+ *
+ * node> var fn = async.apply(sys.puts, 'one');
+ * node> fn('two', 'three');
+ * one
+ * two
+ * three
+ */
+module.exports = exports['default'];
\ No newline at end of file
diff --git a/node_modules/@pm2/js-api/node_modules/async/applyEach.js b/node_modules/@pm2/js-api/node_modules/async/applyEach.js
new file mode 100644
index 0000000..06c0845
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/async/applyEach.js
@@ -0,0 +1,51 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+var _applyEach = require('./internal/applyEach');
+
+var _applyEach2 = _interopRequireDefault(_applyEach);
+
+var _map = require('./map');
+
+var _map2 = _interopRequireDefault(_map);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * Applies the provided arguments to each function in the array, calling
+ * `callback` after all functions have completed. If you only provide the first
+ * argument, `fns`, then it will return a function which lets you pass in the
+ * arguments as if it were a single function call. If more arguments are
+ * provided, `callback` is required while `args` is still optional.
+ *
+ * @name applyEach
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @category Control Flow
+ * @param {Array|Iterable|Object} fns - A collection of {@link AsyncFunction}s
+ * to all call with the same arguments
+ * @param {...*} [args] - any number of separate arguments to pass to the
+ * function.
+ * @param {Function} [callback] - the final argument should be the callback,
+ * called when all functions have completed processing.
+ * @returns {Function} - If only the first argument, `fns`, is provided, it will
+ * return a function which lets you pass in the arguments as if it were a single
+ * function call. The signature is `(..args, callback)`. If invoked with any
+ * arguments, `callback` is required.
+ * @example
+ *
+ * async.applyEach([enableSearch, updateSchema], 'bucket', callback);
+ *
+ * // partial application example:
+ * async.each(
+ * buckets,
+ * async.applyEach([enableSearch, updateSchema]),
+ * callback
+ * );
+ */
+exports.default = (0, _applyEach2.default)(_map2.default);
+module.exports = exports['default'];
\ No newline at end of file
diff --git a/node_modules/@pm2/js-api/node_modules/async/applyEachSeries.js b/node_modules/@pm2/js-api/node_modules/async/applyEachSeries.js
new file mode 100644
index 0000000..ad80280
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/async/applyEachSeries.js
@@ -0,0 +1,37 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+var _applyEach = require('./internal/applyEach');
+
+var _applyEach2 = _interopRequireDefault(_applyEach);
+
+var _mapSeries = require('./mapSeries');
+
+var _mapSeries2 = _interopRequireDefault(_mapSeries);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * The same as [`applyEach`]{@link module:ControlFlow.applyEach} but runs only a single async operation at a time.
+ *
+ * @name applyEachSeries
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @see [async.applyEach]{@link module:ControlFlow.applyEach}
+ * @category Control Flow
+ * @param {Array|Iterable|Object} fns - A collection of {@link AsyncFunction}s to all
+ * call with the same arguments
+ * @param {...*} [args] - any number of separate arguments to pass to the
+ * function.
+ * @param {Function} [callback] - the final argument should be the callback,
+ * called when all functions have completed processing.
+ * @returns {Function} - If only the first argument is provided, it will return
+ * a function which lets you pass in the arguments as if it were a single
+ * function call.
+ */
+exports.default = (0, _applyEach2.default)(_mapSeries2.default);
+module.exports = exports['default'];
\ No newline at end of file
diff --git a/node_modules/@pm2/js-api/node_modules/async/asyncify.js b/node_modules/@pm2/js-api/node_modules/async/asyncify.js
new file mode 100644
index 0000000..5e3fc91
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/async/asyncify.js
@@ -0,0 +1,110 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = asyncify;
+
+var _isObject = require('lodash/isObject');
+
+var _isObject2 = _interopRequireDefault(_isObject);
+
+var _initialParams = require('./internal/initialParams');
+
+var _initialParams2 = _interopRequireDefault(_initialParams);
+
+var _setImmediate = require('./internal/setImmediate');
+
+var _setImmediate2 = _interopRequireDefault(_setImmediate);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * Take a sync function and make it async, passing its return value to a
+ * callback. This is useful for plugging sync functions into a waterfall,
+ * series, or other async functions. Any arguments passed to the generated
+ * function will be passed to the wrapped function (except for the final
+ * callback argument). Errors thrown will be passed to the callback.
+ *
+ * If the function passed to `asyncify` returns a Promise, that promises's
+ * resolved/rejected state will be used to call the callback, rather than simply
+ * the synchronous return value.
+ *
+ * This also means you can asyncify ES2017 `async` functions.
+ *
+ * @name asyncify
+ * @static
+ * @memberOf module:Utils
+ * @method
+ * @alias wrapSync
+ * @category Util
+ * @param {Function} func - The synchronous function, or Promise-returning
+ * function to convert to an {@link AsyncFunction}.
+ * @returns {AsyncFunction} An asynchronous wrapper of the `func`. To be
+ * invoked with `(args..., callback)`.
+ * @example
+ *
+ * // passing a regular synchronous function
+ * async.waterfall([
+ * async.apply(fs.readFile, filename, "utf8"),
+ * async.asyncify(JSON.parse),
+ * function (data, next) {
+ * // data is the result of parsing the text.
+ * // If there was a parsing error, it would have been caught.
+ * }
+ * ], callback);
+ *
+ * // passing a function returning a promise
+ * async.waterfall([
+ * async.apply(fs.readFile, filename, "utf8"),
+ * async.asyncify(function (contents) {
+ * return db.model.create(contents);
+ * }),
+ * function (model, next) {
+ * // `model` is the instantiated model object.
+ * // If there was an error, this function would be skipped.
+ * }
+ * ], callback);
+ *
+ * // es2017 example, though `asyncify` is not needed if your JS environment
+ * // supports async functions out of the box
+ * var q = async.queue(async.asyncify(async function(file) {
+ * var intermediateStep = await processFile(file);
+ * return await somePromise(intermediateStep)
+ * }));
+ *
+ * q.push(files);
+ */
+function asyncify(func) {
+ return (0, _initialParams2.default)(function (args, callback) {
+ var result;
+ try {
+ result = func.apply(this, args);
+ } catch (e) {
+ return callback(e);
+ }
+ // if result is Promise object
+ if ((0, _isObject2.default)(result) && typeof result.then === 'function') {
+ result.then(function (value) {
+ invokeCallback(callback, null, value);
+ }, function (err) {
+ invokeCallback(callback, err.message ? err : new Error(err));
+ });
+ } else {
+ callback(null, result);
+ }
+ });
+}
+
+function invokeCallback(callback, error, value) {
+ try {
+ callback(error, value);
+ } catch (e) {
+ (0, _setImmediate2.default)(rethrow, e);
+ }
+}
+
+function rethrow(error) {
+ throw error;
+}
+module.exports = exports['default'];
\ No newline at end of file
diff --git a/node_modules/@pm2/js-api/node_modules/async/auto.js b/node_modules/@pm2/js-api/node_modules/async/auto.js
new file mode 100644
index 0000000..26c1d56
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/async/auto.js
@@ -0,0 +1,289 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+exports.default = function (tasks, concurrency, callback) {
+ if (typeof concurrency === 'function') {
+ // concurrency is optional, shift the args.
+ callback = concurrency;
+ concurrency = null;
+ }
+ callback = (0, _once2.default)(callback || _noop2.default);
+ var keys = (0, _keys2.default)(tasks);
+ var numTasks = keys.length;
+ if (!numTasks) {
+ return callback(null);
+ }
+ if (!concurrency) {
+ concurrency = numTasks;
+ }
+
+ var results = {};
+ var runningTasks = 0;
+ var hasError = false;
+
+ var listeners = Object.create(null);
+
+ var readyTasks = [];
+
+ // for cycle detection:
+ var readyToCheck = []; // tasks that have been identified as reachable
+ // without the possibility of returning to an ancestor task
+ var uncheckedDependencies = {};
+
+ (0, _baseForOwn2.default)(tasks, function (task, key) {
+ if (!(0, _isArray2.default)(task)) {
+ // no dependencies
+ enqueueTask(key, [task]);
+ readyToCheck.push(key);
+ return;
+ }
+
+ var dependencies = task.slice(0, task.length - 1);
+ var remainingDependencies = dependencies.length;
+ if (remainingDependencies === 0) {
+ enqueueTask(key, task);
+ readyToCheck.push(key);
+ return;
+ }
+ uncheckedDependencies[key] = remainingDependencies;
+
+ (0, _arrayEach2.default)(dependencies, function (dependencyName) {
+ if (!tasks[dependencyName]) {
+ throw new Error('async.auto task `' + key + '` has a non-existent dependency `' + dependencyName + '` in ' + dependencies.join(', '));
+ }
+ addListener(dependencyName, function () {
+ remainingDependencies--;
+ if (remainingDependencies === 0) {
+ enqueueTask(key, task);
+ }
+ });
+ });
+ });
+
+ checkForDeadlocks();
+ processQueue();
+
+ function enqueueTask(key, task) {
+ readyTasks.push(function () {
+ runTask(key, task);
+ });
+ }
+
+ function processQueue() {
+ if (readyTasks.length === 0 && runningTasks === 0) {
+ return callback(null, results);
+ }
+ while (readyTasks.length && runningTasks < concurrency) {
+ var run = readyTasks.shift();
+ run();
+ }
+ }
+
+ function addListener(taskName, fn) {
+ var taskListeners = listeners[taskName];
+ if (!taskListeners) {
+ taskListeners = listeners[taskName] = [];
+ }
+
+ taskListeners.push(fn);
+ }
+
+ function taskComplete(taskName) {
+ var taskListeners = listeners[taskName] || [];
+ (0, _arrayEach2.default)(taskListeners, function (fn) {
+ fn();
+ });
+ processQueue();
+ }
+
+ function runTask(key, task) {
+ if (hasError) return;
+
+ var taskCallback = (0, _onlyOnce2.default)(function (err, result) {
+ runningTasks--;
+ if (arguments.length > 2) {
+ result = (0, _slice2.default)(arguments, 1);
+ }
+ if (err) {
+ var safeResults = {};
+ (0, _baseForOwn2.default)(results, function (val, rkey) {
+ safeResults[rkey] = val;
+ });
+ safeResults[key] = result;
+ hasError = true;
+ listeners = Object.create(null);
+
+ callback(err, safeResults);
+ } else {
+ results[key] = result;
+ taskComplete(key);
+ }
+ });
+
+ runningTasks++;
+ var taskFn = (0, _wrapAsync2.default)(task[task.length - 1]);
+ if (task.length > 1) {
+ taskFn(results, taskCallback);
+ } else {
+ taskFn(taskCallback);
+ }
+ }
+
+ function checkForDeadlocks() {
+ // Kahn's algorithm
+ // https://en.wikipedia.org/wiki/Topological_sorting#Kahn.27s_algorithm
+ // http://connalle.blogspot.com/2013/10/topological-sortingkahn-algorithm.html
+ var currentTask;
+ var counter = 0;
+ while (readyToCheck.length) {
+ currentTask = readyToCheck.pop();
+ counter++;
+ (0, _arrayEach2.default)(getDependents(currentTask), function (dependent) {
+ if (--uncheckedDependencies[dependent] === 0) {
+ readyToCheck.push(dependent);
+ }
+ });
+ }
+
+ if (counter !== numTasks) {
+ throw new Error('async.auto cannot execute tasks due to a recursive dependency');
+ }
+ }
+
+ function getDependents(taskName) {
+ var result = [];
+ (0, _baseForOwn2.default)(tasks, function (task, key) {
+ if ((0, _isArray2.default)(task) && (0, _baseIndexOf2.default)(task, taskName, 0) >= 0) {
+ result.push(key);
+ }
+ });
+ return result;
+ }
+};
+
+var _arrayEach = require('lodash/_arrayEach');
+
+var _arrayEach2 = _interopRequireDefault(_arrayEach);
+
+var _baseForOwn = require('lodash/_baseForOwn');
+
+var _baseForOwn2 = _interopRequireDefault(_baseForOwn);
+
+var _baseIndexOf = require('lodash/_baseIndexOf');
+
+var _baseIndexOf2 = _interopRequireDefault(_baseIndexOf);
+
+var _isArray = require('lodash/isArray');
+
+var _isArray2 = _interopRequireDefault(_isArray);
+
+var _keys = require('lodash/keys');
+
+var _keys2 = _interopRequireDefault(_keys);
+
+var _noop = require('lodash/noop');
+
+var _noop2 = _interopRequireDefault(_noop);
+
+var _slice = require('./internal/slice');
+
+var _slice2 = _interopRequireDefault(_slice);
+
+var _once = require('./internal/once');
+
+var _once2 = _interopRequireDefault(_once);
+
+var _onlyOnce = require('./internal/onlyOnce');
+
+var _onlyOnce2 = _interopRequireDefault(_onlyOnce);
+
+var _wrapAsync = require('./internal/wrapAsync');
+
+var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+module.exports = exports['default'];
+
+/**
+ * Determines the best order for running the {@link AsyncFunction}s in `tasks`, based on
+ * their requirements. Each function can optionally depend on other functions
+ * being completed first, and each function is run as soon as its requirements
+ * are satisfied.
+ *
+ * If any of the {@link AsyncFunction}s pass an error to their callback, the `auto` sequence
+ * will stop. Further tasks will not execute (so any other functions depending
+ * on it will not run), and the main `callback` is immediately called with the
+ * error.
+ *
+ * {@link AsyncFunction}s also receive an object containing the results of functions which
+ * have completed so far as the first argument, if they have dependencies. If a
+ * task function has no dependencies, it will only be passed a callback.
+ *
+ * @name auto
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @category Control Flow
+ * @param {Object} tasks - An object. Each of its properties is either a
+ * function or an array of requirements, with the {@link AsyncFunction} itself the last item
+ * in the array. The object's key of a property serves as the name of the task
+ * defined by that property, i.e. can be used when specifying requirements for
+ * other tasks. The function receives one or two arguments:
+ * * a `results` object, containing the results of the previously executed
+ * functions, only passed if the task has any dependencies,
+ * * a `callback(err, result)` function, which must be called when finished,
+ * passing an `error` (which can be `null`) and the result of the function's
+ * execution.
+ * @param {number} [concurrency=Infinity] - An optional `integer` for
+ * determining the maximum number of tasks that can be run in parallel. By
+ * default, as many as possible.
+ * @param {Function} [callback] - An optional callback which is called when all
+ * the tasks have been completed. It receives the `err` argument if any `tasks`
+ * pass an error to their callback. Results are always returned; however, if an
+ * error occurs, no further `tasks` will be performed, and the results object
+ * will only contain partial results. Invoked with (err, results).
+ * @returns undefined
+ * @example
+ *
+ * async.auto({
+ * // this function will just be passed a callback
+ * readData: async.apply(fs.readFile, 'data.txt', 'utf-8'),
+ * showData: ['readData', function(results, cb) {
+ * // results.readData is the file's contents
+ * // ...
+ * }]
+ * }, callback);
+ *
+ * async.auto({
+ * get_data: function(callback) {
+ * console.log('in get_data');
+ * // async code to get some data
+ * callback(null, 'data', 'converted to array');
+ * },
+ * make_folder: function(callback) {
+ * console.log('in make_folder');
+ * // async code to create a directory to store a file in
+ * // this is run at the same time as getting the data
+ * callback(null, 'folder');
+ * },
+ * write_file: ['get_data', 'make_folder', function(results, callback) {
+ * console.log('in write_file', JSON.stringify(results));
+ * // once there is some data and the directory exists,
+ * // write the data to a file in the directory
+ * callback(null, 'filename');
+ * }],
+ * email_link: ['write_file', function(results, callback) {
+ * console.log('in email_link', JSON.stringify(results));
+ * // once the file is written let's email a link to it...
+ * // results.write_file contains the filename returned by write_file.
+ * callback(null, {'file':results.write_file, 'email':'user@example.com'});
+ * }]
+ * }, function(err, results) {
+ * console.log('err = ', err);
+ * console.log('results = ', results);
+ * });
+ */
\ No newline at end of file
diff --git a/node_modules/@pm2/js-api/node_modules/async/autoInject.js b/node_modules/@pm2/js-api/node_modules/async/autoInject.js
new file mode 100644
index 0000000..bfbe7e8
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/async/autoInject.js
@@ -0,0 +1,170 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = autoInject;
+
+var _auto = require('./auto');
+
+var _auto2 = _interopRequireDefault(_auto);
+
+var _baseForOwn = require('lodash/_baseForOwn');
+
+var _baseForOwn2 = _interopRequireDefault(_baseForOwn);
+
+var _arrayMap = require('lodash/_arrayMap');
+
+var _arrayMap2 = _interopRequireDefault(_arrayMap);
+
+var _isArray = require('lodash/isArray');
+
+var _isArray2 = _interopRequireDefault(_isArray);
+
+var _trim = require('lodash/trim');
+
+var _trim2 = _interopRequireDefault(_trim);
+
+var _wrapAsync = require('./internal/wrapAsync');
+
+var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+var FN_ARGS = /^(?:async\s+)?(function)?\s*[^\(]*\(\s*([^\)]*)\)/m;
+var FN_ARG_SPLIT = /,/;
+var FN_ARG = /(=.+)?(\s*)$/;
+var STRIP_COMMENTS = /((\/\/.*$)|(\/\*[\s\S]*?\*\/))/mg;
+
+function parseParams(func) {
+ func = func.toString().replace(STRIP_COMMENTS, '');
+ func = func.match(FN_ARGS)[2].replace(' ', '');
+ func = func ? func.split(FN_ARG_SPLIT) : [];
+ func = func.map(function (arg) {
+ return (0, _trim2.default)(arg.replace(FN_ARG, ''));
+ });
+ return func;
+}
+
+/**
+ * A dependency-injected version of the [async.auto]{@link module:ControlFlow.auto} function. Dependent
+ * tasks are specified as parameters to the function, after the usual callback
+ * parameter, with the parameter names matching the names of the tasks it
+ * depends on. This can provide even more readable task graphs which can be
+ * easier to maintain.
+ *
+ * If a final callback is specified, the task results are similarly injected,
+ * specified as named parameters after the initial error parameter.
+ *
+ * The autoInject function is purely syntactic sugar and its semantics are
+ * otherwise equivalent to [async.auto]{@link module:ControlFlow.auto}.
+ *
+ * @name autoInject
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @see [async.auto]{@link module:ControlFlow.auto}
+ * @category Control Flow
+ * @param {Object} tasks - An object, each of whose properties is an {@link AsyncFunction} of
+ * the form 'func([dependencies...], callback). The object's key of a property
+ * serves as the name of the task defined by that property, i.e. can be used
+ * when specifying requirements for other tasks.
+ * * The `callback` parameter is a `callback(err, result)` which must be called
+ * when finished, passing an `error` (which can be `null`) and the result of
+ * the function's execution. The remaining parameters name other tasks on
+ * which the task is dependent, and the results from those tasks are the
+ * arguments of those parameters.
+ * @param {Function} [callback] - An optional callback which is called when all
+ * the tasks have been completed. It receives the `err` argument if any `tasks`
+ * pass an error to their callback, and a `results` object with any completed
+ * task results, similar to `auto`.
+ * @example
+ *
+ * // The example from `auto` can be rewritten as follows:
+ * async.autoInject({
+ * get_data: function(callback) {
+ * // async code to get some data
+ * callback(null, 'data', 'converted to array');
+ * },
+ * make_folder: function(callback) {
+ * // async code to create a directory to store a file in
+ * // this is run at the same time as getting the data
+ * callback(null, 'folder');
+ * },
+ * write_file: function(get_data, make_folder, callback) {
+ * // once there is some data and the directory exists,
+ * // write the data to a file in the directory
+ * callback(null, 'filename');
+ * },
+ * email_link: function(write_file, callback) {
+ * // once the file is written let's email a link to it...
+ * // write_file contains the filename returned by write_file.
+ * callback(null, {'file':write_file, 'email':'user@example.com'});
+ * }
+ * }, function(err, results) {
+ * console.log('err = ', err);
+ * console.log('email_link = ', results.email_link);
+ * });
+ *
+ * // If you are using a JS minifier that mangles parameter names, `autoInject`
+ * // will not work with plain functions, since the parameter names will be
+ * // collapsed to a single letter identifier. To work around this, you can
+ * // explicitly specify the names of the parameters your task function needs
+ * // in an array, similar to Angular.js dependency injection.
+ *
+ * // This still has an advantage over plain `auto`, since the results a task
+ * // depends on are still spread into arguments.
+ * async.autoInject({
+ * //...
+ * write_file: ['get_data', 'make_folder', function(get_data, make_folder, callback) {
+ * callback(null, 'filename');
+ * }],
+ * email_link: ['write_file', function(write_file, callback) {
+ * callback(null, {'file':write_file, 'email':'user@example.com'});
+ * }]
+ * //...
+ * }, function(err, results) {
+ * console.log('err = ', err);
+ * console.log('email_link = ', results.email_link);
+ * });
+ */
+function autoInject(tasks, callback) {
+ var newTasks = {};
+
+ (0, _baseForOwn2.default)(tasks, function (taskFn, key) {
+ var params;
+ var fnIsAsync = (0, _wrapAsync.isAsync)(taskFn);
+ var hasNoDeps = !fnIsAsync && taskFn.length === 1 || fnIsAsync && taskFn.length === 0;
+
+ if ((0, _isArray2.default)(taskFn)) {
+ params = taskFn.slice(0, -1);
+ taskFn = taskFn[taskFn.length - 1];
+
+ newTasks[key] = params.concat(params.length > 0 ? newTask : taskFn);
+ } else if (hasNoDeps) {
+ // no dependencies, use the function as-is
+ newTasks[key] = taskFn;
+ } else {
+ params = parseParams(taskFn);
+ if (taskFn.length === 0 && !fnIsAsync && params.length === 0) {
+ throw new Error("autoInject task functions require explicit parameters.");
+ }
+
+ // remove callback param
+ if (!fnIsAsync) params.pop();
+
+ newTasks[key] = params.concat(newTask);
+ }
+
+ function newTask(results, taskCb) {
+ var newArgs = (0, _arrayMap2.default)(params, function (name) {
+ return results[name];
+ });
+ newArgs.push(taskCb);
+ (0, _wrapAsync2.default)(taskFn).apply(null, newArgs);
+ }
+ });
+
+ (0, _auto2.default)(newTasks, callback);
+}
+module.exports = exports['default'];
\ No newline at end of file
diff --git a/node_modules/@pm2/js-api/node_modules/async/bower.json b/node_modules/@pm2/js-api/node_modules/async/bower.json
new file mode 100644
index 0000000..7dbeb14
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/async/bower.json
@@ -0,0 +1,17 @@
+{
+ "name": "async",
+ "main": "dist/async.js",
+ "ignore": [
+ "bower_components",
+ "lib",
+ "mocha_test",
+ "node_modules",
+ "perf",
+ "support",
+ "**/.*",
+ "*.config.js",
+ "*.json",
+ "index.js",
+ "Makefile"
+ ]
+}
diff --git a/node_modules/@pm2/js-api/node_modules/async/cargo.js b/node_modules/@pm2/js-api/node_modules/async/cargo.js
new file mode 100644
index 0000000..c7e59c7
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/async/cargo.js
@@ -0,0 +1,94 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = cargo;
+
+var _queue = require('./internal/queue');
+
+var _queue2 = _interopRequireDefault(_queue);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * A cargo of tasks for the worker function to complete. Cargo inherits all of
+ * the same methods and event callbacks as [`queue`]{@link module:ControlFlow.queue}.
+ * @typedef {Object} CargoObject
+ * @memberOf module:ControlFlow
+ * @property {Function} length - A function returning the number of items
+ * waiting to be processed. Invoke like `cargo.length()`.
+ * @property {number} payload - An `integer` for determining how many tasks
+ * should be process per round. This property can be changed after a `cargo` is
+ * created to alter the payload on-the-fly.
+ * @property {Function} push - Adds `task` to the `queue`. The callback is
+ * called once the `worker` has finished processing the task. Instead of a
+ * single task, an array of `tasks` can be submitted. The respective callback is
+ * used for every task in the list. Invoke like `cargo.push(task, [callback])`.
+ * @property {Function} saturated - A callback that is called when the
+ * `queue.length()` hits the concurrency and further tasks will be queued.
+ * @property {Function} empty - A callback that is called when the last item
+ * from the `queue` is given to a `worker`.
+ * @property {Function} drain - A callback that is called when the last item
+ * from the `queue` has returned from the `worker`.
+ * @property {Function} idle - a function returning false if there are items
+ * waiting or being processed, or true if not. Invoke like `cargo.idle()`.
+ * @property {Function} pause - a function that pauses the processing of tasks
+ * until `resume()` is called. Invoke like `cargo.pause()`.
+ * @property {Function} resume - a function that resumes the processing of
+ * queued tasks when the queue is paused. Invoke like `cargo.resume()`.
+ * @property {Function} kill - a function that removes the `drain` callback and
+ * empties remaining tasks from the queue forcing it to go idle. Invoke like `cargo.kill()`.
+ */
+
+/**
+ * Creates a `cargo` object with the specified payload. Tasks added to the
+ * cargo will be processed altogether (up to the `payload` limit). If the
+ * `worker` is in progress, the task is queued until it becomes available. Once
+ * the `worker` has completed some tasks, each callback of those tasks is
+ * called. Check out [these](https://camo.githubusercontent.com/6bbd36f4cf5b35a0f11a96dcd2e97711ffc2fb37/68747470733a2f2f662e636c6f75642e6769746875622e636f6d2f6173736574732f313637363837312f36383130382f62626330636662302d356632392d313165322d393734662d3333393763363464633835382e676966) [animations](https://camo.githubusercontent.com/f4810e00e1c5f5f8addbe3e9f49064fd5d102699/68747470733a2f2f662e636c6f75642e6769746875622e636f6d2f6173736574732f313637363837312f36383130312f38346339323036362d356632392d313165322d383134662d3964336430323431336266642e676966)
+ * for how `cargo` and `queue` work.
+ *
+ * While [`queue`]{@link module:ControlFlow.queue} passes only one task to one of a group of workers
+ * at a time, cargo passes an array of tasks to a single worker, repeating
+ * when the worker is finished.
+ *
+ * @name cargo
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @see [async.queue]{@link module:ControlFlow.queue}
+ * @category Control Flow
+ * @param {AsyncFunction} worker - An asynchronous function for processing an array
+ * of queued tasks. Invoked with `(tasks, callback)`.
+ * @param {number} [payload=Infinity] - An optional `integer` for determining
+ * how many tasks should be processed per round; if omitted, the default is
+ * unlimited.
+ * @returns {module:ControlFlow.CargoObject} A cargo object to manage the tasks. Callbacks can
+ * attached as certain properties to listen for specific events during the
+ * lifecycle of the cargo and inner queue.
+ * @example
+ *
+ * // create a cargo object with payload 2
+ * var cargo = async.cargo(function(tasks, callback) {
+ * for (var i=0; i async.dir(hello, 'world');
+ * {hello: 'world'}
+ */
+exports.default = (0, _consoleFunc2.default)('dir');
+module.exports = exports['default'];
\ No newline at end of file
diff --git a/node_modules/@pm2/js-api/node_modules/async/dist/async.js b/node_modules/@pm2/js-api/node_modules/async/dist/async.js
new file mode 100644
index 0000000..61c7588
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/async/dist/async.js
@@ -0,0 +1,5612 @@
+(function (global, factory) {
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
+ typeof define === 'function' && define.amd ? define(['exports'], factory) :
+ (factory((global.async = global.async || {})));
+}(this, (function (exports) { 'use strict';
+
+function slice(arrayLike, start) {
+ start = start|0;
+ var newLen = Math.max(arrayLike.length - start, 0);
+ var newArr = Array(newLen);
+ for(var idx = 0; idx < newLen; idx++) {
+ newArr[idx] = arrayLike[start + idx];
+ }
+ return newArr;
+}
+
+/**
+ * Creates a continuation function with some arguments already applied.
+ *
+ * Useful as a shorthand when combined with other control flow functions. Any
+ * arguments passed to the returned function are added to the arguments
+ * originally passed to apply.
+ *
+ * @name apply
+ * @static
+ * @memberOf module:Utils
+ * @method
+ * @category Util
+ * @param {Function} fn - The function you want to eventually apply all
+ * arguments to. Invokes with (arguments...).
+ * @param {...*} arguments... - Any number of arguments to automatically apply
+ * when the continuation is called.
+ * @returns {Function} the partially-applied function
+ * @example
+ *
+ * // using apply
+ * async.parallel([
+ * async.apply(fs.writeFile, 'testfile1', 'test1'),
+ * async.apply(fs.writeFile, 'testfile2', 'test2')
+ * ]);
+ *
+ *
+ * // the same process without using apply
+ * async.parallel([
+ * function(callback) {
+ * fs.writeFile('testfile1', 'test1', callback);
+ * },
+ * function(callback) {
+ * fs.writeFile('testfile2', 'test2', callback);
+ * }
+ * ]);
+ *
+ * // It's possible to pass any number of additional arguments when calling the
+ * // continuation:
+ *
+ * node> var fn = async.apply(sys.puts, 'one');
+ * node> fn('two', 'three');
+ * one
+ * two
+ * three
+ */
+var apply = function(fn/*, ...args*/) {
+ var args = slice(arguments, 1);
+ return function(/*callArgs*/) {
+ var callArgs = slice(arguments);
+ return fn.apply(null, args.concat(callArgs));
+ };
+};
+
+var initialParams = function (fn) {
+ return function (/*...args, callback*/) {
+ var args = slice(arguments);
+ var callback = args.pop();
+ fn.call(this, args, callback);
+ };
+};
+
+/**
+ * Checks if `value` is the
+ * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
+ * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is an object, else `false`.
+ * @example
+ *
+ * _.isObject({});
+ * // => true
+ *
+ * _.isObject([1, 2, 3]);
+ * // => true
+ *
+ * _.isObject(_.noop);
+ * // => true
+ *
+ * _.isObject(null);
+ * // => false
+ */
+function isObject(value) {
+ var type = typeof value;
+ return value != null && (type == 'object' || type == 'function');
+}
+
+var hasSetImmediate = typeof setImmediate === 'function' && setImmediate;
+var hasNextTick = typeof process === 'object' && typeof process.nextTick === 'function';
+
+function fallback(fn) {
+ setTimeout(fn, 0);
+}
+
+function wrap(defer) {
+ return function (fn/*, ...args*/) {
+ var args = slice(arguments, 1);
+ defer(function () {
+ fn.apply(null, args);
+ });
+ };
+}
+
+var _defer;
+
+if (hasSetImmediate) {
+ _defer = setImmediate;
+} else if (hasNextTick) {
+ _defer = process.nextTick;
+} else {
+ _defer = fallback;
+}
+
+var setImmediate$1 = wrap(_defer);
+
+/**
+ * Take a sync function and make it async, passing its return value to a
+ * callback. This is useful for plugging sync functions into a waterfall,
+ * series, or other async functions. Any arguments passed to the generated
+ * function will be passed to the wrapped function (except for the final
+ * callback argument). Errors thrown will be passed to the callback.
+ *
+ * If the function passed to `asyncify` returns a Promise, that promises's
+ * resolved/rejected state will be used to call the callback, rather than simply
+ * the synchronous return value.
+ *
+ * This also means you can asyncify ES2017 `async` functions.
+ *
+ * @name asyncify
+ * @static
+ * @memberOf module:Utils
+ * @method
+ * @alias wrapSync
+ * @category Util
+ * @param {Function} func - The synchronous function, or Promise-returning
+ * function to convert to an {@link AsyncFunction}.
+ * @returns {AsyncFunction} An asynchronous wrapper of the `func`. To be
+ * invoked with `(args..., callback)`.
+ * @example
+ *
+ * // passing a regular synchronous function
+ * async.waterfall([
+ * async.apply(fs.readFile, filename, "utf8"),
+ * async.asyncify(JSON.parse),
+ * function (data, next) {
+ * // data is the result of parsing the text.
+ * // If there was a parsing error, it would have been caught.
+ * }
+ * ], callback);
+ *
+ * // passing a function returning a promise
+ * async.waterfall([
+ * async.apply(fs.readFile, filename, "utf8"),
+ * async.asyncify(function (contents) {
+ * return db.model.create(contents);
+ * }),
+ * function (model, next) {
+ * // `model` is the instantiated model object.
+ * // If there was an error, this function would be skipped.
+ * }
+ * ], callback);
+ *
+ * // es2017 example, though `asyncify` is not needed if your JS environment
+ * // supports async functions out of the box
+ * var q = async.queue(async.asyncify(async function(file) {
+ * var intermediateStep = await processFile(file);
+ * return await somePromise(intermediateStep)
+ * }));
+ *
+ * q.push(files);
+ */
+function asyncify(func) {
+ return initialParams(function (args, callback) {
+ var result;
+ try {
+ result = func.apply(this, args);
+ } catch (e) {
+ return callback(e);
+ }
+ // if result is Promise object
+ if (isObject(result) && typeof result.then === 'function') {
+ result.then(function(value) {
+ invokeCallback(callback, null, value);
+ }, function(err) {
+ invokeCallback(callback, err.message ? err : new Error(err));
+ });
+ } else {
+ callback(null, result);
+ }
+ });
+}
+
+function invokeCallback(callback, error, value) {
+ try {
+ callback(error, value);
+ } catch (e) {
+ setImmediate$1(rethrow, e);
+ }
+}
+
+function rethrow(error) {
+ throw error;
+}
+
+var supportsSymbol = typeof Symbol === 'function';
+
+function isAsync(fn) {
+ return supportsSymbol && fn[Symbol.toStringTag] === 'AsyncFunction';
+}
+
+function wrapAsync(asyncFn) {
+ return isAsync(asyncFn) ? asyncify(asyncFn) : asyncFn;
+}
+
+function applyEach$1(eachfn) {
+ return function(fns/*, ...args*/) {
+ var args = slice(arguments, 1);
+ var go = initialParams(function(args, callback) {
+ var that = this;
+ return eachfn(fns, function (fn, cb) {
+ wrapAsync(fn).apply(that, args.concat(cb));
+ }, callback);
+ });
+ if (args.length) {
+ return go.apply(this, args);
+ }
+ else {
+ return go;
+ }
+ };
+}
+
+/** Detect free variable `global` from Node.js. */
+var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
+
+/** Detect free variable `self`. */
+var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
+
+/** Used as a reference to the global object. */
+var root = freeGlobal || freeSelf || Function('return this')();
+
+/** Built-in value references. */
+var Symbol$1 = root.Symbol;
+
+/** Used for built-in method references. */
+var objectProto = Object.prototype;
+
+/** Used to check objects for own properties. */
+var hasOwnProperty = objectProto.hasOwnProperty;
+
+/**
+ * Used to resolve the
+ * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
+ * of values.
+ */
+var nativeObjectToString = objectProto.toString;
+
+/** Built-in value references. */
+var symToStringTag$1 = Symbol$1 ? Symbol$1.toStringTag : undefined;
+
+/**
+ * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
+ *
+ * @private
+ * @param {*} value The value to query.
+ * @returns {string} Returns the raw `toStringTag`.
+ */
+function getRawTag(value) {
+ var isOwn = hasOwnProperty.call(value, symToStringTag$1),
+ tag = value[symToStringTag$1];
+
+ try {
+ value[symToStringTag$1] = undefined;
+ var unmasked = true;
+ } catch (e) {}
+
+ var result = nativeObjectToString.call(value);
+ if (unmasked) {
+ if (isOwn) {
+ value[symToStringTag$1] = tag;
+ } else {
+ delete value[symToStringTag$1];
+ }
+ }
+ return result;
+}
+
+/** Used for built-in method references. */
+var objectProto$1 = Object.prototype;
+
+/**
+ * Used to resolve the
+ * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
+ * of values.
+ */
+var nativeObjectToString$1 = objectProto$1.toString;
+
+/**
+ * Converts `value` to a string using `Object.prototype.toString`.
+ *
+ * @private
+ * @param {*} value The value to convert.
+ * @returns {string} Returns the converted string.
+ */
+function objectToString(value) {
+ return nativeObjectToString$1.call(value);
+}
+
+/** `Object#toString` result references. */
+var nullTag = '[object Null]';
+var undefinedTag = '[object Undefined]';
+
+/** Built-in value references. */
+var symToStringTag = Symbol$1 ? Symbol$1.toStringTag : undefined;
+
+/**
+ * The base implementation of `getTag` without fallbacks for buggy environments.
+ *
+ * @private
+ * @param {*} value The value to query.
+ * @returns {string} Returns the `toStringTag`.
+ */
+function baseGetTag(value) {
+ if (value == null) {
+ return value === undefined ? undefinedTag : nullTag;
+ }
+ return (symToStringTag && symToStringTag in Object(value))
+ ? getRawTag(value)
+ : objectToString(value);
+}
+
+/** `Object#toString` result references. */
+var asyncTag = '[object AsyncFunction]';
+var funcTag = '[object Function]';
+var genTag = '[object GeneratorFunction]';
+var proxyTag = '[object Proxy]';
+
+/**
+ * Checks if `value` is classified as a `Function` object.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is a function, else `false`.
+ * @example
+ *
+ * _.isFunction(_);
+ * // => true
+ *
+ * _.isFunction(/abc/);
+ * // => false
+ */
+function isFunction(value) {
+ if (!isObject(value)) {
+ return false;
+ }
+ // The use of `Object#toString` avoids issues with the `typeof` operator
+ // in Safari 9 which returns 'object' for typed arrays and other constructors.
+ var tag = baseGetTag(value);
+ return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
+}
+
+/** Used as references for various `Number` constants. */
+var MAX_SAFE_INTEGER = 9007199254740991;
+
+/**
+ * Checks if `value` is a valid array-like length.
+ *
+ * **Note:** This method is loosely based on
+ * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
+ * @example
+ *
+ * _.isLength(3);
+ * // => true
+ *
+ * _.isLength(Number.MIN_VALUE);
+ * // => false
+ *
+ * _.isLength(Infinity);
+ * // => false
+ *
+ * _.isLength('3');
+ * // => false
+ */
+function isLength(value) {
+ return typeof value == 'number' &&
+ value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
+}
+
+/**
+ * Checks if `value` is array-like. A value is considered array-like if it's
+ * not a function and has a `value.length` that's an integer greater than or
+ * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
+ * @example
+ *
+ * _.isArrayLike([1, 2, 3]);
+ * // => true
+ *
+ * _.isArrayLike(document.body.children);
+ * // => true
+ *
+ * _.isArrayLike('abc');
+ * // => true
+ *
+ * _.isArrayLike(_.noop);
+ * // => false
+ */
+function isArrayLike(value) {
+ return value != null && isLength(value.length) && !isFunction(value);
+}
+
+// A temporary value used to identify if the loop should be broken.
+// See #1064, #1293
+var breakLoop = {};
+
+/**
+ * This method returns `undefined`.
+ *
+ * @static
+ * @memberOf _
+ * @since 2.3.0
+ * @category Util
+ * @example
+ *
+ * _.times(2, _.noop);
+ * // => [undefined, undefined]
+ */
+function noop() {
+ // No operation performed.
+}
+
+function once(fn) {
+ return function () {
+ if (fn === null) return;
+ var callFn = fn;
+ fn = null;
+ callFn.apply(this, arguments);
+ };
+}
+
+var iteratorSymbol = typeof Symbol === 'function' && Symbol.iterator;
+
+var getIterator = function (coll) {
+ return iteratorSymbol && coll[iteratorSymbol] && coll[iteratorSymbol]();
+};
+
+/**
+ * The base implementation of `_.times` without support for iteratee shorthands
+ * or max array length checks.
+ *
+ * @private
+ * @param {number} n The number of times to invoke `iteratee`.
+ * @param {Function} iteratee The function invoked per iteration.
+ * @returns {Array} Returns the array of results.
+ */
+function baseTimes(n, iteratee) {
+ var index = -1,
+ result = Array(n);
+
+ while (++index < n) {
+ result[index] = iteratee(index);
+ }
+ return result;
+}
+
+/**
+ * Checks if `value` is object-like. A value is object-like if it's not `null`
+ * and has a `typeof` result of "object".
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
+ * @example
+ *
+ * _.isObjectLike({});
+ * // => true
+ *
+ * _.isObjectLike([1, 2, 3]);
+ * // => true
+ *
+ * _.isObjectLike(_.noop);
+ * // => false
+ *
+ * _.isObjectLike(null);
+ * // => false
+ */
+function isObjectLike(value) {
+ return value != null && typeof value == 'object';
+}
+
+/** `Object#toString` result references. */
+var argsTag = '[object Arguments]';
+
+/**
+ * The base implementation of `_.isArguments`.
+ *
+ * @private
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is an `arguments` object,
+ */
+function baseIsArguments(value) {
+ return isObjectLike(value) && baseGetTag(value) == argsTag;
+}
+
+/** Used for built-in method references. */
+var objectProto$3 = Object.prototype;
+
+/** Used to check objects for own properties. */
+var hasOwnProperty$2 = objectProto$3.hasOwnProperty;
+
+/** Built-in value references. */
+var propertyIsEnumerable = objectProto$3.propertyIsEnumerable;
+
+/**
+ * Checks if `value` is likely an `arguments` object.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is an `arguments` object,
+ * else `false`.
+ * @example
+ *
+ * _.isArguments(function() { return arguments; }());
+ * // => true
+ *
+ * _.isArguments([1, 2, 3]);
+ * // => false
+ */
+var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {
+ return isObjectLike(value) && hasOwnProperty$2.call(value, 'callee') &&
+ !propertyIsEnumerable.call(value, 'callee');
+};
+
+/**
+ * Checks if `value` is classified as an `Array` object.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is an array, else `false`.
+ * @example
+ *
+ * _.isArray([1, 2, 3]);
+ * // => true
+ *
+ * _.isArray(document.body.children);
+ * // => false
+ *
+ * _.isArray('abc');
+ * // => false
+ *
+ * _.isArray(_.noop);
+ * // => false
+ */
+var isArray = Array.isArray;
+
+/**
+ * This method returns `false`.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.13.0
+ * @category Util
+ * @returns {boolean} Returns `false`.
+ * @example
+ *
+ * _.times(2, _.stubFalse);
+ * // => [false, false]
+ */
+function stubFalse() {
+ return false;
+}
+
+/** Detect free variable `exports`. */
+var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;
+
+/** Detect free variable `module`. */
+var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;
+
+/** Detect the popular CommonJS extension `module.exports`. */
+var moduleExports = freeModule && freeModule.exports === freeExports;
+
+/** Built-in value references. */
+var Buffer = moduleExports ? root.Buffer : undefined;
+
+/* Built-in method references for those with the same name as other `lodash` methods. */
+var nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined;
+
+/**
+ * Checks if `value` is a buffer.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.3.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
+ * @example
+ *
+ * _.isBuffer(new Buffer(2));
+ * // => true
+ *
+ * _.isBuffer(new Uint8Array(2));
+ * // => false
+ */
+var isBuffer = nativeIsBuffer || stubFalse;
+
+/** Used as references for various `Number` constants. */
+var MAX_SAFE_INTEGER$1 = 9007199254740991;
+
+/** Used to detect unsigned integer values. */
+var reIsUint = /^(?:0|[1-9]\d*)$/;
+
+/**
+ * Checks if `value` is a valid array-like index.
+ *
+ * @private
+ * @param {*} value The value to check.
+ * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
+ * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
+ */
+function isIndex(value, length) {
+ var type = typeof value;
+ length = length == null ? MAX_SAFE_INTEGER$1 : length;
+
+ return !!length &&
+ (type == 'number' ||
+ (type != 'symbol' && reIsUint.test(value))) &&
+ (value > -1 && value % 1 == 0 && value < length);
+}
+
+/** `Object#toString` result references. */
+var argsTag$1 = '[object Arguments]';
+var arrayTag = '[object Array]';
+var boolTag = '[object Boolean]';
+var dateTag = '[object Date]';
+var errorTag = '[object Error]';
+var funcTag$1 = '[object Function]';
+var mapTag = '[object Map]';
+var numberTag = '[object Number]';
+var objectTag = '[object Object]';
+var regexpTag = '[object RegExp]';
+var setTag = '[object Set]';
+var stringTag = '[object String]';
+var weakMapTag = '[object WeakMap]';
+
+var arrayBufferTag = '[object ArrayBuffer]';
+var dataViewTag = '[object DataView]';
+var float32Tag = '[object Float32Array]';
+var float64Tag = '[object Float64Array]';
+var int8Tag = '[object Int8Array]';
+var int16Tag = '[object Int16Array]';
+var int32Tag = '[object Int32Array]';
+var uint8Tag = '[object Uint8Array]';
+var uint8ClampedTag = '[object Uint8ClampedArray]';
+var uint16Tag = '[object Uint16Array]';
+var uint32Tag = '[object Uint32Array]';
+
+/** Used to identify `toStringTag` values of typed arrays. */
+var typedArrayTags = {};
+typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
+typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
+typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
+typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
+typedArrayTags[uint32Tag] = true;
+typedArrayTags[argsTag$1] = typedArrayTags[arrayTag] =
+typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
+typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
+typedArrayTags[errorTag] = typedArrayTags[funcTag$1] =
+typedArrayTags[mapTag] = typedArrayTags[numberTag] =
+typedArrayTags[objectTag] = typedArrayTags[regexpTag] =
+typedArrayTags[setTag] = typedArrayTags[stringTag] =
+typedArrayTags[weakMapTag] = false;
+
+/**
+ * The base implementation of `_.isTypedArray` without Node.js optimizations.
+ *
+ * @private
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
+ */
+function baseIsTypedArray(value) {
+ return isObjectLike(value) &&
+ isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
+}
+
+/**
+ * The base implementation of `_.unary` without support for storing metadata.
+ *
+ * @private
+ * @param {Function} func The function to cap arguments for.
+ * @returns {Function} Returns the new capped function.
+ */
+function baseUnary(func) {
+ return function(value) {
+ return func(value);
+ };
+}
+
+/** Detect free variable `exports`. */
+var freeExports$1 = typeof exports == 'object' && exports && !exports.nodeType && exports;
+
+/** Detect free variable `module`. */
+var freeModule$1 = freeExports$1 && typeof module == 'object' && module && !module.nodeType && module;
+
+/** Detect the popular CommonJS extension `module.exports`. */
+var moduleExports$1 = freeModule$1 && freeModule$1.exports === freeExports$1;
+
+/** Detect free variable `process` from Node.js. */
+var freeProcess = moduleExports$1 && freeGlobal.process;
+
+/** Used to access faster Node.js helpers. */
+var nodeUtil = (function() {
+ try {
+ // Use `util.types` for Node.js 10+.
+ var types = freeModule$1 && freeModule$1.require && freeModule$1.require('util').types;
+
+ if (types) {
+ return types;
+ }
+
+ // Legacy `process.binding('util')` for Node.js < 10.
+ return freeProcess && freeProcess.binding && freeProcess.binding('util');
+ } catch (e) {}
+}());
+
+/* Node.js helper references. */
+var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
+
+/**
+ * Checks if `value` is classified as a typed array.
+ *
+ * @static
+ * @memberOf _
+ * @since 3.0.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
+ * @example
+ *
+ * _.isTypedArray(new Uint8Array);
+ * // => true
+ *
+ * _.isTypedArray([]);
+ * // => false
+ */
+var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
+
+/** Used for built-in method references. */
+var objectProto$2 = Object.prototype;
+
+/** Used to check objects for own properties. */
+var hasOwnProperty$1 = objectProto$2.hasOwnProperty;
+
+/**
+ * Creates an array of the enumerable property names of the array-like `value`.
+ *
+ * @private
+ * @param {*} value The value to query.
+ * @param {boolean} inherited Specify returning inherited property names.
+ * @returns {Array} Returns the array of property names.
+ */
+function arrayLikeKeys(value, inherited) {
+ var isArr = isArray(value),
+ isArg = !isArr && isArguments(value),
+ isBuff = !isArr && !isArg && isBuffer(value),
+ isType = !isArr && !isArg && !isBuff && isTypedArray(value),
+ skipIndexes = isArr || isArg || isBuff || isType,
+ result = skipIndexes ? baseTimes(value.length, String) : [],
+ length = result.length;
+
+ for (var key in value) {
+ if ((inherited || hasOwnProperty$1.call(value, key)) &&
+ !(skipIndexes && (
+ // Safari 9 has enumerable `arguments.length` in strict mode.
+ key == 'length' ||
+ // Node.js 0.10 has enumerable non-index properties on buffers.
+ (isBuff && (key == 'offset' || key == 'parent')) ||
+ // PhantomJS 2 has enumerable non-index properties on typed arrays.
+ (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
+ // Skip index properties.
+ isIndex(key, length)
+ ))) {
+ result.push(key);
+ }
+ }
+ return result;
+}
+
+/** Used for built-in method references. */
+var objectProto$5 = Object.prototype;
+
+/**
+ * Checks if `value` is likely a prototype object.
+ *
+ * @private
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
+ */
+function isPrototype(value) {
+ var Ctor = value && value.constructor,
+ proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto$5;
+
+ return value === proto;
+}
+
+/**
+ * Creates a unary function that invokes `func` with its argument transformed.
+ *
+ * @private
+ * @param {Function} func The function to wrap.
+ * @param {Function} transform The argument transform.
+ * @returns {Function} Returns the new function.
+ */
+function overArg(func, transform) {
+ return function(arg) {
+ return func(transform(arg));
+ };
+}
+
+/* Built-in method references for those with the same name as other `lodash` methods. */
+var nativeKeys = overArg(Object.keys, Object);
+
+/** Used for built-in method references. */
+var objectProto$4 = Object.prototype;
+
+/** Used to check objects for own properties. */
+var hasOwnProperty$3 = objectProto$4.hasOwnProperty;
+
+/**
+ * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
+ *
+ * @private
+ * @param {Object} object The object to query.
+ * @returns {Array} Returns the array of property names.
+ */
+function baseKeys(object) {
+ if (!isPrototype(object)) {
+ return nativeKeys(object);
+ }
+ var result = [];
+ for (var key in Object(object)) {
+ if (hasOwnProperty$3.call(object, key) && key != 'constructor') {
+ result.push(key);
+ }
+ }
+ return result;
+}
+
+/**
+ * Creates an array of the own enumerable property names of `object`.
+ *
+ * **Note:** Non-object values are coerced to objects. See the
+ * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
+ * for more details.
+ *
+ * @static
+ * @since 0.1.0
+ * @memberOf _
+ * @category Object
+ * @param {Object} object The object to query.
+ * @returns {Array} Returns the array of property names.
+ * @example
+ *
+ * function Foo() {
+ * this.a = 1;
+ * this.b = 2;
+ * }
+ *
+ * Foo.prototype.c = 3;
+ *
+ * _.keys(new Foo);
+ * // => ['a', 'b'] (iteration order is not guaranteed)
+ *
+ * _.keys('hi');
+ * // => ['0', '1']
+ */
+function keys(object) {
+ return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
+}
+
+function createArrayIterator(coll) {
+ var i = -1;
+ var len = coll.length;
+ return function next() {
+ return ++i < len ? {value: coll[i], key: i} : null;
+ }
+}
+
+function createES2015Iterator(iterator) {
+ var i = -1;
+ return function next() {
+ var item = iterator.next();
+ if (item.done)
+ return null;
+ i++;
+ return {value: item.value, key: i};
+ }
+}
+
+function createObjectIterator(obj) {
+ var okeys = keys(obj);
+ var i = -1;
+ var len = okeys.length;
+ return function next() {
+ var key = okeys[++i];
+ if (key === '__proto__') {
+ return next();
+ }
+ return i < len ? {value: obj[key], key: key} : null;
+ };
+}
+
+function iterator(coll) {
+ if (isArrayLike(coll)) {
+ return createArrayIterator(coll);
+ }
+
+ var iterator = getIterator(coll);
+ return iterator ? createES2015Iterator(iterator) : createObjectIterator(coll);
+}
+
+function onlyOnce(fn) {
+ return function() {
+ if (fn === null) throw new Error("Callback was already called.");
+ var callFn = fn;
+ fn = null;
+ callFn.apply(this, arguments);
+ };
+}
+
+function _eachOfLimit(limit) {
+ return function (obj, iteratee, callback) {
+ callback = once(callback || noop);
+ if (limit <= 0 || !obj) {
+ return callback(null);
+ }
+ var nextElem = iterator(obj);
+ var done = false;
+ var running = 0;
+ var looping = false;
+
+ function iterateeCallback(err, value) {
+ running -= 1;
+ if (err) {
+ done = true;
+ callback(err);
+ }
+ else if (value === breakLoop || (done && running <= 0)) {
+ done = true;
+ return callback(null);
+ }
+ else if (!looping) {
+ replenish();
+ }
+ }
+
+ function replenish () {
+ looping = true;
+ while (running < limit && !done) {
+ var elem = nextElem();
+ if (elem === null) {
+ done = true;
+ if (running <= 0) {
+ callback(null);
+ }
+ return;
+ }
+ running += 1;
+ iteratee(elem.value, elem.key, onlyOnce(iterateeCallback));
+ }
+ looping = false;
+ }
+
+ replenish();
+ };
+}
+
+/**
+ * The same as [`eachOf`]{@link module:Collections.eachOf} but runs a maximum of `limit` async operations at a
+ * time.
+ *
+ * @name eachOfLimit
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.eachOf]{@link module:Collections.eachOf}
+ * @alias forEachOfLimit
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {number} limit - The maximum number of async operations at a time.
+ * @param {AsyncFunction} iteratee - An async function to apply to each
+ * item in `coll`. The `key` is the item's key, or index in the case of an
+ * array.
+ * Invoked with (item, key, callback).
+ * @param {Function} [callback] - A callback which is called when all
+ * `iteratee` functions have finished, or an error occurs. Invoked with (err).
+ */
+function eachOfLimit(coll, limit, iteratee, callback) {
+ _eachOfLimit(limit)(coll, wrapAsync(iteratee), callback);
+}
+
+function doLimit(fn, limit) {
+ return function (iterable, iteratee, callback) {
+ return fn(iterable, limit, iteratee, callback);
+ };
+}
+
+// eachOf implementation optimized for array-likes
+function eachOfArrayLike(coll, iteratee, callback) {
+ callback = once(callback || noop);
+ var index = 0,
+ completed = 0,
+ length = coll.length;
+ if (length === 0) {
+ callback(null);
+ }
+
+ function iteratorCallback(err, value) {
+ if (err) {
+ callback(err);
+ } else if ((++completed === length) || value === breakLoop) {
+ callback(null);
+ }
+ }
+
+ for (; index < length; index++) {
+ iteratee(coll[index], index, onlyOnce(iteratorCallback));
+ }
+}
+
+// a generic version of eachOf which can handle array, object, and iterator cases.
+var eachOfGeneric = doLimit(eachOfLimit, Infinity);
+
+/**
+ * Like [`each`]{@link module:Collections.each}, except that it passes the key (or index) as the second argument
+ * to the iteratee.
+ *
+ * @name eachOf
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @alias forEachOf
+ * @category Collection
+ * @see [async.each]{@link module:Collections.each}
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {AsyncFunction} iteratee - A function to apply to each
+ * item in `coll`.
+ * The `key` is the item's key, or index in the case of an array.
+ * Invoked with (item, key, callback).
+ * @param {Function} [callback] - A callback which is called when all
+ * `iteratee` functions have finished, or an error occurs. Invoked with (err).
+ * @example
+ *
+ * var obj = {dev: "/dev.json", test: "/test.json", prod: "/prod.json"};
+ * var configs = {};
+ *
+ * async.forEachOf(obj, function (value, key, callback) {
+ * fs.readFile(__dirname + value, "utf8", function (err, data) {
+ * if (err) return callback(err);
+ * try {
+ * configs[key] = JSON.parse(data);
+ * } catch (e) {
+ * return callback(e);
+ * }
+ * callback();
+ * });
+ * }, function (err) {
+ * if (err) console.error(err.message);
+ * // configs is now a map of JSON data
+ * doSomethingWith(configs);
+ * });
+ */
+var eachOf = function(coll, iteratee, callback) {
+ var eachOfImplementation = isArrayLike(coll) ? eachOfArrayLike : eachOfGeneric;
+ eachOfImplementation(coll, wrapAsync(iteratee), callback);
+};
+
+function doParallel(fn) {
+ return function (obj, iteratee, callback) {
+ return fn(eachOf, obj, wrapAsync(iteratee), callback);
+ };
+}
+
+function _asyncMap(eachfn, arr, iteratee, callback) {
+ callback = callback || noop;
+ arr = arr || [];
+ var results = [];
+ var counter = 0;
+ var _iteratee = wrapAsync(iteratee);
+
+ eachfn(arr, function (value, _, callback) {
+ var index = counter++;
+ _iteratee(value, function (err, v) {
+ results[index] = v;
+ callback(err);
+ });
+ }, function (err) {
+ callback(err, results);
+ });
+}
+
+/**
+ * Produces a new collection of values by mapping each value in `coll` through
+ * the `iteratee` function. The `iteratee` is called with an item from `coll`
+ * and a callback for when it has finished processing. Each of these callback
+ * takes 2 arguments: an `error`, and the transformed item from `coll`. If
+ * `iteratee` passes an error to its callback, the main `callback` (for the
+ * `map` function) is immediately called with the error.
+ *
+ * Note, that since this function applies the `iteratee` to each item in
+ * parallel, there is no guarantee that the `iteratee` functions will complete
+ * in order. However, the results array will be in the same order as the
+ * original `coll`.
+ *
+ * If `map` is passed an Object, the results will be an Array. The results
+ * will roughly be in the order of the original Objects' keys (but this can
+ * vary across JavaScript engines).
+ *
+ * @name map
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {AsyncFunction} iteratee - An async function to apply to each item in
+ * `coll`.
+ * The iteratee should complete with the transformed item.
+ * Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called when all `iteratee`
+ * functions have finished, or an error occurs. Results is an Array of the
+ * transformed items from the `coll`. Invoked with (err, results).
+ * @example
+ *
+ * async.map(['file1','file2','file3'], fs.stat, function(err, results) {
+ * // results is now an array of stats for each file
+ * });
+ */
+var map = doParallel(_asyncMap);
+
+/**
+ * Applies the provided arguments to each function in the array, calling
+ * `callback` after all functions have completed. If you only provide the first
+ * argument, `fns`, then it will return a function which lets you pass in the
+ * arguments as if it were a single function call. If more arguments are
+ * provided, `callback` is required while `args` is still optional.
+ *
+ * @name applyEach
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @category Control Flow
+ * @param {Array|Iterable|Object} fns - A collection of {@link AsyncFunction}s
+ * to all call with the same arguments
+ * @param {...*} [args] - any number of separate arguments to pass to the
+ * function.
+ * @param {Function} [callback] - the final argument should be the callback,
+ * called when all functions have completed processing.
+ * @returns {Function} - If only the first argument, `fns`, is provided, it will
+ * return a function which lets you pass in the arguments as if it were a single
+ * function call. The signature is `(..args, callback)`. If invoked with any
+ * arguments, `callback` is required.
+ * @example
+ *
+ * async.applyEach([enableSearch, updateSchema], 'bucket', callback);
+ *
+ * // partial application example:
+ * async.each(
+ * buckets,
+ * async.applyEach([enableSearch, updateSchema]),
+ * callback
+ * );
+ */
+var applyEach = applyEach$1(map);
+
+function doParallelLimit(fn) {
+ return function (obj, limit, iteratee, callback) {
+ return fn(_eachOfLimit(limit), obj, wrapAsync(iteratee), callback);
+ };
+}
+
+/**
+ * The same as [`map`]{@link module:Collections.map} but runs a maximum of `limit` async operations at a time.
+ *
+ * @name mapLimit
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.map]{@link module:Collections.map}
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {number} limit - The maximum number of async operations at a time.
+ * @param {AsyncFunction} iteratee - An async function to apply to each item in
+ * `coll`.
+ * The iteratee should complete with the transformed item.
+ * Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called when all `iteratee`
+ * functions have finished, or an error occurs. Results is an array of the
+ * transformed items from the `coll`. Invoked with (err, results).
+ */
+var mapLimit = doParallelLimit(_asyncMap);
+
+/**
+ * The same as [`map`]{@link module:Collections.map} but runs only a single async operation at a time.
+ *
+ * @name mapSeries
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.map]{@link module:Collections.map}
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {AsyncFunction} iteratee - An async function to apply to each item in
+ * `coll`.
+ * The iteratee should complete with the transformed item.
+ * Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called when all `iteratee`
+ * functions have finished, or an error occurs. Results is an array of the
+ * transformed items from the `coll`. Invoked with (err, results).
+ */
+var mapSeries = doLimit(mapLimit, 1);
+
+/**
+ * The same as [`applyEach`]{@link module:ControlFlow.applyEach} but runs only a single async operation at a time.
+ *
+ * @name applyEachSeries
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @see [async.applyEach]{@link module:ControlFlow.applyEach}
+ * @category Control Flow
+ * @param {Array|Iterable|Object} fns - A collection of {@link AsyncFunction}s to all
+ * call with the same arguments
+ * @param {...*} [args] - any number of separate arguments to pass to the
+ * function.
+ * @param {Function} [callback] - the final argument should be the callback,
+ * called when all functions have completed processing.
+ * @returns {Function} - If only the first argument is provided, it will return
+ * a function which lets you pass in the arguments as if it were a single
+ * function call.
+ */
+var applyEachSeries = applyEach$1(mapSeries);
+
+/**
+ * A specialized version of `_.forEach` for arrays without support for
+ * iteratee shorthands.
+ *
+ * @private
+ * @param {Array} [array] The array to iterate over.
+ * @param {Function} iteratee The function invoked per iteration.
+ * @returns {Array} Returns `array`.
+ */
+function arrayEach(array, iteratee) {
+ var index = -1,
+ length = array == null ? 0 : array.length;
+
+ while (++index < length) {
+ if (iteratee(array[index], index, array) === false) {
+ break;
+ }
+ }
+ return array;
+}
+
+/**
+ * Creates a base function for methods like `_.forIn` and `_.forOwn`.
+ *
+ * @private
+ * @param {boolean} [fromRight] Specify iterating from right to left.
+ * @returns {Function} Returns the new base function.
+ */
+function createBaseFor(fromRight) {
+ return function(object, iteratee, keysFunc) {
+ var index = -1,
+ iterable = Object(object),
+ props = keysFunc(object),
+ length = props.length;
+
+ while (length--) {
+ var key = props[fromRight ? length : ++index];
+ if (iteratee(iterable[key], key, iterable) === false) {
+ break;
+ }
+ }
+ return object;
+ };
+}
+
+/**
+ * The base implementation of `baseForOwn` which iterates over `object`
+ * properties returned by `keysFunc` and invokes `iteratee` for each property.
+ * Iteratee functions may exit iteration early by explicitly returning `false`.
+ *
+ * @private
+ * @param {Object} object The object to iterate over.
+ * @param {Function} iteratee The function invoked per iteration.
+ * @param {Function} keysFunc The function to get the keys of `object`.
+ * @returns {Object} Returns `object`.
+ */
+var baseFor = createBaseFor();
+
+/**
+ * The base implementation of `_.forOwn` without support for iteratee shorthands.
+ *
+ * @private
+ * @param {Object} object The object to iterate over.
+ * @param {Function} iteratee The function invoked per iteration.
+ * @returns {Object} Returns `object`.
+ */
+function baseForOwn(object, iteratee) {
+ return object && baseFor(object, iteratee, keys);
+}
+
+/**
+ * The base implementation of `_.findIndex` and `_.findLastIndex` without
+ * support for iteratee shorthands.
+ *
+ * @private
+ * @param {Array} array The array to inspect.
+ * @param {Function} predicate The function invoked per iteration.
+ * @param {number} fromIndex The index to search from.
+ * @param {boolean} [fromRight] Specify iterating from right to left.
+ * @returns {number} Returns the index of the matched value, else `-1`.
+ */
+function baseFindIndex(array, predicate, fromIndex, fromRight) {
+ var length = array.length,
+ index = fromIndex + (fromRight ? 1 : -1);
+
+ while ((fromRight ? index-- : ++index < length)) {
+ if (predicate(array[index], index, array)) {
+ return index;
+ }
+ }
+ return -1;
+}
+
+/**
+ * The base implementation of `_.isNaN` without support for number objects.
+ *
+ * @private
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
+ */
+function baseIsNaN(value) {
+ return value !== value;
+}
+
+/**
+ * A specialized version of `_.indexOf` which performs strict equality
+ * comparisons of values, i.e. `===`.
+ *
+ * @private
+ * @param {Array} array The array to inspect.
+ * @param {*} value The value to search for.
+ * @param {number} fromIndex The index to search from.
+ * @returns {number} Returns the index of the matched value, else `-1`.
+ */
+function strictIndexOf(array, value, fromIndex) {
+ var index = fromIndex - 1,
+ length = array.length;
+
+ while (++index < length) {
+ if (array[index] === value) {
+ return index;
+ }
+ }
+ return -1;
+}
+
+/**
+ * The base implementation of `_.indexOf` without `fromIndex` bounds checks.
+ *
+ * @private
+ * @param {Array} array The array to inspect.
+ * @param {*} value The value to search for.
+ * @param {number} fromIndex The index to search from.
+ * @returns {number} Returns the index of the matched value, else `-1`.
+ */
+function baseIndexOf(array, value, fromIndex) {
+ return value === value
+ ? strictIndexOf(array, value, fromIndex)
+ : baseFindIndex(array, baseIsNaN, fromIndex);
+}
+
+/**
+ * Determines the best order for running the {@link AsyncFunction}s in `tasks`, based on
+ * their requirements. Each function can optionally depend on other functions
+ * being completed first, and each function is run as soon as its requirements
+ * are satisfied.
+ *
+ * If any of the {@link AsyncFunction}s pass an error to their callback, the `auto` sequence
+ * will stop. Further tasks will not execute (so any other functions depending
+ * on it will not run), and the main `callback` is immediately called with the
+ * error.
+ *
+ * {@link AsyncFunction}s also receive an object containing the results of functions which
+ * have completed so far as the first argument, if they have dependencies. If a
+ * task function has no dependencies, it will only be passed a callback.
+ *
+ * @name auto
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @category Control Flow
+ * @param {Object} tasks - An object. Each of its properties is either a
+ * function or an array of requirements, with the {@link AsyncFunction} itself the last item
+ * in the array. The object's key of a property serves as the name of the task
+ * defined by that property, i.e. can be used when specifying requirements for
+ * other tasks. The function receives one or two arguments:
+ * * a `results` object, containing the results of the previously executed
+ * functions, only passed if the task has any dependencies,
+ * * a `callback(err, result)` function, which must be called when finished,
+ * passing an `error` (which can be `null`) and the result of the function's
+ * execution.
+ * @param {number} [concurrency=Infinity] - An optional `integer` for
+ * determining the maximum number of tasks that can be run in parallel. By
+ * default, as many as possible.
+ * @param {Function} [callback] - An optional callback which is called when all
+ * the tasks have been completed. It receives the `err` argument if any `tasks`
+ * pass an error to their callback. Results are always returned; however, if an
+ * error occurs, no further `tasks` will be performed, and the results object
+ * will only contain partial results. Invoked with (err, results).
+ * @returns undefined
+ * @example
+ *
+ * async.auto({
+ * // this function will just be passed a callback
+ * readData: async.apply(fs.readFile, 'data.txt', 'utf-8'),
+ * showData: ['readData', function(results, cb) {
+ * // results.readData is the file's contents
+ * // ...
+ * }]
+ * }, callback);
+ *
+ * async.auto({
+ * get_data: function(callback) {
+ * console.log('in get_data');
+ * // async code to get some data
+ * callback(null, 'data', 'converted to array');
+ * },
+ * make_folder: function(callback) {
+ * console.log('in make_folder');
+ * // async code to create a directory to store a file in
+ * // this is run at the same time as getting the data
+ * callback(null, 'folder');
+ * },
+ * write_file: ['get_data', 'make_folder', function(results, callback) {
+ * console.log('in write_file', JSON.stringify(results));
+ * // once there is some data and the directory exists,
+ * // write the data to a file in the directory
+ * callback(null, 'filename');
+ * }],
+ * email_link: ['write_file', function(results, callback) {
+ * console.log('in email_link', JSON.stringify(results));
+ * // once the file is written let's email a link to it...
+ * // results.write_file contains the filename returned by write_file.
+ * callback(null, {'file':results.write_file, 'email':'user@example.com'});
+ * }]
+ * }, function(err, results) {
+ * console.log('err = ', err);
+ * console.log('results = ', results);
+ * });
+ */
+var auto = function (tasks, concurrency, callback) {
+ if (typeof concurrency === 'function') {
+ // concurrency is optional, shift the args.
+ callback = concurrency;
+ concurrency = null;
+ }
+ callback = once(callback || noop);
+ var keys$$1 = keys(tasks);
+ var numTasks = keys$$1.length;
+ if (!numTasks) {
+ return callback(null);
+ }
+ if (!concurrency) {
+ concurrency = numTasks;
+ }
+
+ var results = {};
+ var runningTasks = 0;
+ var hasError = false;
+
+ var listeners = Object.create(null);
+
+ var readyTasks = [];
+
+ // for cycle detection:
+ var readyToCheck = []; // tasks that have been identified as reachable
+ // without the possibility of returning to an ancestor task
+ var uncheckedDependencies = {};
+
+ baseForOwn(tasks, function (task, key) {
+ if (!isArray(task)) {
+ // no dependencies
+ enqueueTask(key, [task]);
+ readyToCheck.push(key);
+ return;
+ }
+
+ var dependencies = task.slice(0, task.length - 1);
+ var remainingDependencies = dependencies.length;
+ if (remainingDependencies === 0) {
+ enqueueTask(key, task);
+ readyToCheck.push(key);
+ return;
+ }
+ uncheckedDependencies[key] = remainingDependencies;
+
+ arrayEach(dependencies, function (dependencyName) {
+ if (!tasks[dependencyName]) {
+ throw new Error('async.auto task `' + key +
+ '` has a non-existent dependency `' +
+ dependencyName + '` in ' +
+ dependencies.join(', '));
+ }
+ addListener(dependencyName, function () {
+ remainingDependencies--;
+ if (remainingDependencies === 0) {
+ enqueueTask(key, task);
+ }
+ });
+ });
+ });
+
+ checkForDeadlocks();
+ processQueue();
+
+ function enqueueTask(key, task) {
+ readyTasks.push(function () {
+ runTask(key, task);
+ });
+ }
+
+ function processQueue() {
+ if (readyTasks.length === 0 && runningTasks === 0) {
+ return callback(null, results);
+ }
+ while(readyTasks.length && runningTasks < concurrency) {
+ var run = readyTasks.shift();
+ run();
+ }
+
+ }
+
+ function addListener(taskName, fn) {
+ var taskListeners = listeners[taskName];
+ if (!taskListeners) {
+ taskListeners = listeners[taskName] = [];
+ }
+
+ taskListeners.push(fn);
+ }
+
+ function taskComplete(taskName) {
+ var taskListeners = listeners[taskName] || [];
+ arrayEach(taskListeners, function (fn) {
+ fn();
+ });
+ processQueue();
+ }
+
+
+ function runTask(key, task) {
+ if (hasError) return;
+
+ var taskCallback = onlyOnce(function(err, result) {
+ runningTasks--;
+ if (arguments.length > 2) {
+ result = slice(arguments, 1);
+ }
+ if (err) {
+ var safeResults = {};
+ baseForOwn(results, function(val, rkey) {
+ safeResults[rkey] = val;
+ });
+ safeResults[key] = result;
+ hasError = true;
+ listeners = Object.create(null);
+
+ callback(err, safeResults);
+ } else {
+ results[key] = result;
+ taskComplete(key);
+ }
+ });
+
+ runningTasks++;
+ var taskFn = wrapAsync(task[task.length - 1]);
+ if (task.length > 1) {
+ taskFn(results, taskCallback);
+ } else {
+ taskFn(taskCallback);
+ }
+ }
+
+ function checkForDeadlocks() {
+ // Kahn's algorithm
+ // https://en.wikipedia.org/wiki/Topological_sorting#Kahn.27s_algorithm
+ // http://connalle.blogspot.com/2013/10/topological-sortingkahn-algorithm.html
+ var currentTask;
+ var counter = 0;
+ while (readyToCheck.length) {
+ currentTask = readyToCheck.pop();
+ counter++;
+ arrayEach(getDependents(currentTask), function (dependent) {
+ if (--uncheckedDependencies[dependent] === 0) {
+ readyToCheck.push(dependent);
+ }
+ });
+ }
+
+ if (counter !== numTasks) {
+ throw new Error(
+ 'async.auto cannot execute tasks due to a recursive dependency'
+ );
+ }
+ }
+
+ function getDependents(taskName) {
+ var result = [];
+ baseForOwn(tasks, function (task, key) {
+ if (isArray(task) && baseIndexOf(task, taskName, 0) >= 0) {
+ result.push(key);
+ }
+ });
+ return result;
+ }
+};
+
+/**
+ * A specialized version of `_.map` for arrays without support for iteratee
+ * shorthands.
+ *
+ * @private
+ * @param {Array} [array] The array to iterate over.
+ * @param {Function} iteratee The function invoked per iteration.
+ * @returns {Array} Returns the new mapped array.
+ */
+function arrayMap(array, iteratee) {
+ var index = -1,
+ length = array == null ? 0 : array.length,
+ result = Array(length);
+
+ while (++index < length) {
+ result[index] = iteratee(array[index], index, array);
+ }
+ return result;
+}
+
+/** `Object#toString` result references. */
+var symbolTag = '[object Symbol]';
+
+/**
+ * Checks if `value` is classified as a `Symbol` primitive or object.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
+ * @example
+ *
+ * _.isSymbol(Symbol.iterator);
+ * // => true
+ *
+ * _.isSymbol('abc');
+ * // => false
+ */
+function isSymbol(value) {
+ return typeof value == 'symbol' ||
+ (isObjectLike(value) && baseGetTag(value) == symbolTag);
+}
+
+/** Used as references for various `Number` constants. */
+var INFINITY = 1 / 0;
+
+/** Used to convert symbols to primitives and strings. */
+var symbolProto = Symbol$1 ? Symbol$1.prototype : undefined;
+var symbolToString = symbolProto ? symbolProto.toString : undefined;
+
+/**
+ * The base implementation of `_.toString` which doesn't convert nullish
+ * values to empty strings.
+ *
+ * @private
+ * @param {*} value The value to process.
+ * @returns {string} Returns the string.
+ */
+function baseToString(value) {
+ // Exit early for strings to avoid a performance hit in some environments.
+ if (typeof value == 'string') {
+ return value;
+ }
+ if (isArray(value)) {
+ // Recursively convert values (susceptible to call stack limits).
+ return arrayMap(value, baseToString) + '';
+ }
+ if (isSymbol(value)) {
+ return symbolToString ? symbolToString.call(value) : '';
+ }
+ var result = (value + '');
+ return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
+}
+
+/**
+ * The base implementation of `_.slice` without an iteratee call guard.
+ *
+ * @private
+ * @param {Array} array The array to slice.
+ * @param {number} [start=0] The start position.
+ * @param {number} [end=array.length] The end position.
+ * @returns {Array} Returns the slice of `array`.
+ */
+function baseSlice(array, start, end) {
+ var index = -1,
+ length = array.length;
+
+ if (start < 0) {
+ start = -start > length ? 0 : (length + start);
+ }
+ end = end > length ? length : end;
+ if (end < 0) {
+ end += length;
+ }
+ length = start > end ? 0 : ((end - start) >>> 0);
+ start >>>= 0;
+
+ var result = Array(length);
+ while (++index < length) {
+ result[index] = array[index + start];
+ }
+ return result;
+}
+
+/**
+ * Casts `array` to a slice if it's needed.
+ *
+ * @private
+ * @param {Array} array The array to inspect.
+ * @param {number} start The start position.
+ * @param {number} [end=array.length] The end position.
+ * @returns {Array} Returns the cast slice.
+ */
+function castSlice(array, start, end) {
+ var length = array.length;
+ end = end === undefined ? length : end;
+ return (!start && end >= length) ? array : baseSlice(array, start, end);
+}
+
+/**
+ * Used by `_.trim` and `_.trimEnd` to get the index of the last string symbol
+ * that is not found in the character symbols.
+ *
+ * @private
+ * @param {Array} strSymbols The string symbols to inspect.
+ * @param {Array} chrSymbols The character symbols to find.
+ * @returns {number} Returns the index of the last unmatched string symbol.
+ */
+function charsEndIndex(strSymbols, chrSymbols) {
+ var index = strSymbols.length;
+
+ while (index-- && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}
+ return index;
+}
+
+/**
+ * Used by `_.trim` and `_.trimStart` to get the index of the first string symbol
+ * that is not found in the character symbols.
+ *
+ * @private
+ * @param {Array} strSymbols The string symbols to inspect.
+ * @param {Array} chrSymbols The character symbols to find.
+ * @returns {number} Returns the index of the first unmatched string symbol.
+ */
+function charsStartIndex(strSymbols, chrSymbols) {
+ var index = -1,
+ length = strSymbols.length;
+
+ while (++index < length && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {}
+ return index;
+}
+
+/**
+ * Converts an ASCII `string` to an array.
+ *
+ * @private
+ * @param {string} string The string to convert.
+ * @returns {Array} Returns the converted array.
+ */
+function asciiToArray(string) {
+ return string.split('');
+}
+
+/** Used to compose unicode character classes. */
+var rsAstralRange = '\\ud800-\\udfff';
+var rsComboMarksRange = '\\u0300-\\u036f';
+var reComboHalfMarksRange = '\\ufe20-\\ufe2f';
+var rsComboSymbolsRange = '\\u20d0-\\u20ff';
+var rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange;
+var rsVarRange = '\\ufe0e\\ufe0f';
+
+/** Used to compose unicode capture groups. */
+var rsZWJ = '\\u200d';
+
+/** Used to detect strings with [zero-width joiners or code points from the astral planes](http://eev.ee/blog/2015/09/12/dark-corners-of-unicode/). */
+var reHasUnicode = RegExp('[' + rsZWJ + rsAstralRange + rsComboRange + rsVarRange + ']');
+
+/**
+ * Checks if `string` contains Unicode symbols.
+ *
+ * @private
+ * @param {string} string The string to inspect.
+ * @returns {boolean} Returns `true` if a symbol is found, else `false`.
+ */
+function hasUnicode(string) {
+ return reHasUnicode.test(string);
+}
+
+/** Used to compose unicode character classes. */
+var rsAstralRange$1 = '\\ud800-\\udfff';
+var rsComboMarksRange$1 = '\\u0300-\\u036f';
+var reComboHalfMarksRange$1 = '\\ufe20-\\ufe2f';
+var rsComboSymbolsRange$1 = '\\u20d0-\\u20ff';
+var rsComboRange$1 = rsComboMarksRange$1 + reComboHalfMarksRange$1 + rsComboSymbolsRange$1;
+var rsVarRange$1 = '\\ufe0e\\ufe0f';
+
+/** Used to compose unicode capture groups. */
+var rsAstral = '[' + rsAstralRange$1 + ']';
+var rsCombo = '[' + rsComboRange$1 + ']';
+var rsFitz = '\\ud83c[\\udffb-\\udfff]';
+var rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')';
+var rsNonAstral = '[^' + rsAstralRange$1 + ']';
+var rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}';
+var rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]';
+var rsZWJ$1 = '\\u200d';
+
+/** Used to compose unicode regexes. */
+var reOptMod = rsModifier + '?';
+var rsOptVar = '[' + rsVarRange$1 + ']?';
+var rsOptJoin = '(?:' + rsZWJ$1 + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*';
+var rsSeq = rsOptVar + reOptMod + rsOptJoin;
+var rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')';
+
+/** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */
+var reUnicode = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g');
+
+/**
+ * Converts a Unicode `string` to an array.
+ *
+ * @private
+ * @param {string} string The string to convert.
+ * @returns {Array} Returns the converted array.
+ */
+function unicodeToArray(string) {
+ return string.match(reUnicode) || [];
+}
+
+/**
+ * Converts `string` to an array.
+ *
+ * @private
+ * @param {string} string The string to convert.
+ * @returns {Array} Returns the converted array.
+ */
+function stringToArray(string) {
+ return hasUnicode(string)
+ ? unicodeToArray(string)
+ : asciiToArray(string);
+}
+
+/**
+ * Converts `value` to a string. An empty string is returned for `null`
+ * and `undefined` values. The sign of `-0` is preserved.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Lang
+ * @param {*} value The value to convert.
+ * @returns {string} Returns the converted string.
+ * @example
+ *
+ * _.toString(null);
+ * // => ''
+ *
+ * _.toString(-0);
+ * // => '-0'
+ *
+ * _.toString([1, 2, 3]);
+ * // => '1,2,3'
+ */
+function toString(value) {
+ return value == null ? '' : baseToString(value);
+}
+
+/** Used to match leading and trailing whitespace. */
+var reTrim = /^\s+|\s+$/g;
+
+/**
+ * Removes leading and trailing whitespace or specified characters from `string`.
+ *
+ * @static
+ * @memberOf _
+ * @since 3.0.0
+ * @category String
+ * @param {string} [string=''] The string to trim.
+ * @param {string} [chars=whitespace] The characters to trim.
+ * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
+ * @returns {string} Returns the trimmed string.
+ * @example
+ *
+ * _.trim(' abc ');
+ * // => 'abc'
+ *
+ * _.trim('-_-abc-_-', '_-');
+ * // => 'abc'
+ *
+ * _.map([' foo ', ' bar '], _.trim);
+ * // => ['foo', 'bar']
+ */
+function trim(string, chars, guard) {
+ string = toString(string);
+ if (string && (guard || chars === undefined)) {
+ return string.replace(reTrim, '');
+ }
+ if (!string || !(chars = baseToString(chars))) {
+ return string;
+ }
+ var strSymbols = stringToArray(string),
+ chrSymbols = stringToArray(chars),
+ start = charsStartIndex(strSymbols, chrSymbols),
+ end = charsEndIndex(strSymbols, chrSymbols) + 1;
+
+ return castSlice(strSymbols, start, end).join('');
+}
+
+var FN_ARGS = /^(?:async\s+)?(function)?\s*[^\(]*\(\s*([^\)]*)\)/m;
+var FN_ARG_SPLIT = /,/;
+var FN_ARG = /(=.+)?(\s*)$/;
+var STRIP_COMMENTS = /((\/\/.*$)|(\/\*[\s\S]*?\*\/))/mg;
+
+function parseParams(func) {
+ func = func.toString().replace(STRIP_COMMENTS, '');
+ func = func.match(FN_ARGS)[2].replace(' ', '');
+ func = func ? func.split(FN_ARG_SPLIT) : [];
+ func = func.map(function (arg){
+ return trim(arg.replace(FN_ARG, ''));
+ });
+ return func;
+}
+
+/**
+ * A dependency-injected version of the [async.auto]{@link module:ControlFlow.auto} function. Dependent
+ * tasks are specified as parameters to the function, after the usual callback
+ * parameter, with the parameter names matching the names of the tasks it
+ * depends on. This can provide even more readable task graphs which can be
+ * easier to maintain.
+ *
+ * If a final callback is specified, the task results are similarly injected,
+ * specified as named parameters after the initial error parameter.
+ *
+ * The autoInject function is purely syntactic sugar and its semantics are
+ * otherwise equivalent to [async.auto]{@link module:ControlFlow.auto}.
+ *
+ * @name autoInject
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @see [async.auto]{@link module:ControlFlow.auto}
+ * @category Control Flow
+ * @param {Object} tasks - An object, each of whose properties is an {@link AsyncFunction} of
+ * the form 'func([dependencies...], callback). The object's key of a property
+ * serves as the name of the task defined by that property, i.e. can be used
+ * when specifying requirements for other tasks.
+ * * The `callback` parameter is a `callback(err, result)` which must be called
+ * when finished, passing an `error` (which can be `null`) and the result of
+ * the function's execution. The remaining parameters name other tasks on
+ * which the task is dependent, and the results from those tasks are the
+ * arguments of those parameters.
+ * @param {Function} [callback] - An optional callback which is called when all
+ * the tasks have been completed. It receives the `err` argument if any `tasks`
+ * pass an error to their callback, and a `results` object with any completed
+ * task results, similar to `auto`.
+ * @example
+ *
+ * // The example from `auto` can be rewritten as follows:
+ * async.autoInject({
+ * get_data: function(callback) {
+ * // async code to get some data
+ * callback(null, 'data', 'converted to array');
+ * },
+ * make_folder: function(callback) {
+ * // async code to create a directory to store a file in
+ * // this is run at the same time as getting the data
+ * callback(null, 'folder');
+ * },
+ * write_file: function(get_data, make_folder, callback) {
+ * // once there is some data and the directory exists,
+ * // write the data to a file in the directory
+ * callback(null, 'filename');
+ * },
+ * email_link: function(write_file, callback) {
+ * // once the file is written let's email a link to it...
+ * // write_file contains the filename returned by write_file.
+ * callback(null, {'file':write_file, 'email':'user@example.com'});
+ * }
+ * }, function(err, results) {
+ * console.log('err = ', err);
+ * console.log('email_link = ', results.email_link);
+ * });
+ *
+ * // If you are using a JS minifier that mangles parameter names, `autoInject`
+ * // will not work with plain functions, since the parameter names will be
+ * // collapsed to a single letter identifier. To work around this, you can
+ * // explicitly specify the names of the parameters your task function needs
+ * // in an array, similar to Angular.js dependency injection.
+ *
+ * // This still has an advantage over plain `auto`, since the results a task
+ * // depends on are still spread into arguments.
+ * async.autoInject({
+ * //...
+ * write_file: ['get_data', 'make_folder', function(get_data, make_folder, callback) {
+ * callback(null, 'filename');
+ * }],
+ * email_link: ['write_file', function(write_file, callback) {
+ * callback(null, {'file':write_file, 'email':'user@example.com'});
+ * }]
+ * //...
+ * }, function(err, results) {
+ * console.log('err = ', err);
+ * console.log('email_link = ', results.email_link);
+ * });
+ */
+function autoInject(tasks, callback) {
+ var newTasks = {};
+
+ baseForOwn(tasks, function (taskFn, key) {
+ var params;
+ var fnIsAsync = isAsync(taskFn);
+ var hasNoDeps =
+ (!fnIsAsync && taskFn.length === 1) ||
+ (fnIsAsync && taskFn.length === 0);
+
+ if (isArray(taskFn)) {
+ params = taskFn.slice(0, -1);
+ taskFn = taskFn[taskFn.length - 1];
+
+ newTasks[key] = params.concat(params.length > 0 ? newTask : taskFn);
+ } else if (hasNoDeps) {
+ // no dependencies, use the function as-is
+ newTasks[key] = taskFn;
+ } else {
+ params = parseParams(taskFn);
+ if (taskFn.length === 0 && !fnIsAsync && params.length === 0) {
+ throw new Error("autoInject task functions require explicit parameters.");
+ }
+
+ // remove callback param
+ if (!fnIsAsync) params.pop();
+
+ newTasks[key] = params.concat(newTask);
+ }
+
+ function newTask(results, taskCb) {
+ var newArgs = arrayMap(params, function (name) {
+ return results[name];
+ });
+ newArgs.push(taskCb);
+ wrapAsync(taskFn).apply(null, newArgs);
+ }
+ });
+
+ auto(newTasks, callback);
+}
+
+// Simple doubly linked list (https://en.wikipedia.org/wiki/Doubly_linked_list) implementation
+// used for queues. This implementation assumes that the node provided by the user can be modified
+// to adjust the next and last properties. We implement only the minimal functionality
+// for queue support.
+function DLL() {
+ this.head = this.tail = null;
+ this.length = 0;
+}
+
+function setInitial(dll, node) {
+ dll.length = 1;
+ dll.head = dll.tail = node;
+}
+
+DLL.prototype.removeLink = function(node) {
+ if (node.prev) node.prev.next = node.next;
+ else this.head = node.next;
+ if (node.next) node.next.prev = node.prev;
+ else this.tail = node.prev;
+
+ node.prev = node.next = null;
+ this.length -= 1;
+ return node;
+};
+
+DLL.prototype.empty = function () {
+ while(this.head) this.shift();
+ return this;
+};
+
+DLL.prototype.insertAfter = function(node, newNode) {
+ newNode.prev = node;
+ newNode.next = node.next;
+ if (node.next) node.next.prev = newNode;
+ else this.tail = newNode;
+ node.next = newNode;
+ this.length += 1;
+};
+
+DLL.prototype.insertBefore = function(node, newNode) {
+ newNode.prev = node.prev;
+ newNode.next = node;
+ if (node.prev) node.prev.next = newNode;
+ else this.head = newNode;
+ node.prev = newNode;
+ this.length += 1;
+};
+
+DLL.prototype.unshift = function(node) {
+ if (this.head) this.insertBefore(this.head, node);
+ else setInitial(this, node);
+};
+
+DLL.prototype.push = function(node) {
+ if (this.tail) this.insertAfter(this.tail, node);
+ else setInitial(this, node);
+};
+
+DLL.prototype.shift = function() {
+ return this.head && this.removeLink(this.head);
+};
+
+DLL.prototype.pop = function() {
+ return this.tail && this.removeLink(this.tail);
+};
+
+DLL.prototype.toArray = function () {
+ var arr = Array(this.length);
+ var curr = this.head;
+ for(var idx = 0; idx < this.length; idx++) {
+ arr[idx] = curr.data;
+ curr = curr.next;
+ }
+ return arr;
+};
+
+DLL.prototype.remove = function (testFn) {
+ var curr = this.head;
+ while(!!curr) {
+ var next = curr.next;
+ if (testFn(curr)) {
+ this.removeLink(curr);
+ }
+ curr = next;
+ }
+ return this;
+};
+
+function queue(worker, concurrency, payload) {
+ if (concurrency == null) {
+ concurrency = 1;
+ }
+ else if(concurrency === 0) {
+ throw new Error('Concurrency must not be zero');
+ }
+
+ var _worker = wrapAsync(worker);
+ var numRunning = 0;
+ var workersList = [];
+
+ var processingScheduled = false;
+ function _insert(data, insertAtFront, callback) {
+ if (callback != null && typeof callback !== 'function') {
+ throw new Error('task callback must be a function');
+ }
+ q.started = true;
+ if (!isArray(data)) {
+ data = [data];
+ }
+ if (data.length === 0 && q.idle()) {
+ // call drain immediately if there are no tasks
+ return setImmediate$1(function() {
+ q.drain();
+ });
+ }
+
+ for (var i = 0, l = data.length; i < l; i++) {
+ var item = {
+ data: data[i],
+ callback: callback || noop
+ };
+
+ if (insertAtFront) {
+ q._tasks.unshift(item);
+ } else {
+ q._tasks.push(item);
+ }
+ }
+
+ if (!processingScheduled) {
+ processingScheduled = true;
+ setImmediate$1(function() {
+ processingScheduled = false;
+ q.process();
+ });
+ }
+ }
+
+ function _next(tasks) {
+ return function(err){
+ numRunning -= 1;
+
+ for (var i = 0, l = tasks.length; i < l; i++) {
+ var task = tasks[i];
+
+ var index = baseIndexOf(workersList, task, 0);
+ if (index === 0) {
+ workersList.shift();
+ } else if (index > 0) {
+ workersList.splice(index, 1);
+ }
+
+ task.callback.apply(task, arguments);
+
+ if (err != null) {
+ q.error(err, task.data);
+ }
+ }
+
+ if (numRunning <= (q.concurrency - q.buffer) ) {
+ q.unsaturated();
+ }
+
+ if (q.idle()) {
+ q.drain();
+ }
+ q.process();
+ };
+ }
+
+ var isProcessing = false;
+ var q = {
+ _tasks: new DLL(),
+ concurrency: concurrency,
+ payload: payload,
+ saturated: noop,
+ unsaturated:noop,
+ buffer: concurrency / 4,
+ empty: noop,
+ drain: noop,
+ error: noop,
+ started: false,
+ paused: false,
+ push: function (data, callback) {
+ _insert(data, false, callback);
+ },
+ kill: function () {
+ q.drain = noop;
+ q._tasks.empty();
+ },
+ unshift: function (data, callback) {
+ _insert(data, true, callback);
+ },
+ remove: function (testFn) {
+ q._tasks.remove(testFn);
+ },
+ process: function () {
+ // Avoid trying to start too many processing operations. This can occur
+ // when callbacks resolve synchronously (#1267).
+ if (isProcessing) {
+ return;
+ }
+ isProcessing = true;
+ while(!q.paused && numRunning < q.concurrency && q._tasks.length){
+ var tasks = [], data = [];
+ var l = q._tasks.length;
+ if (q.payload) l = Math.min(l, q.payload);
+ for (var i = 0; i < l; i++) {
+ var node = q._tasks.shift();
+ tasks.push(node);
+ workersList.push(node);
+ data.push(node.data);
+ }
+
+ numRunning += 1;
+
+ if (q._tasks.length === 0) {
+ q.empty();
+ }
+
+ if (numRunning === q.concurrency) {
+ q.saturated();
+ }
+
+ var cb = onlyOnce(_next(tasks));
+ _worker(data, cb);
+ }
+ isProcessing = false;
+ },
+ length: function () {
+ return q._tasks.length;
+ },
+ running: function () {
+ return numRunning;
+ },
+ workersList: function () {
+ return workersList;
+ },
+ idle: function() {
+ return q._tasks.length + numRunning === 0;
+ },
+ pause: function () {
+ q.paused = true;
+ },
+ resume: function () {
+ if (q.paused === false) { return; }
+ q.paused = false;
+ setImmediate$1(q.process);
+ }
+ };
+ return q;
+}
+
+/**
+ * A cargo of tasks for the worker function to complete. Cargo inherits all of
+ * the same methods and event callbacks as [`queue`]{@link module:ControlFlow.queue}.
+ * @typedef {Object} CargoObject
+ * @memberOf module:ControlFlow
+ * @property {Function} length - A function returning the number of items
+ * waiting to be processed. Invoke like `cargo.length()`.
+ * @property {number} payload - An `integer` for determining how many tasks
+ * should be process per round. This property can be changed after a `cargo` is
+ * created to alter the payload on-the-fly.
+ * @property {Function} push - Adds `task` to the `queue`. The callback is
+ * called once the `worker` has finished processing the task. Instead of a
+ * single task, an array of `tasks` can be submitted. The respective callback is
+ * used for every task in the list. Invoke like `cargo.push(task, [callback])`.
+ * @property {Function} saturated - A callback that is called when the
+ * `queue.length()` hits the concurrency and further tasks will be queued.
+ * @property {Function} empty - A callback that is called when the last item
+ * from the `queue` is given to a `worker`.
+ * @property {Function} drain - A callback that is called when the last item
+ * from the `queue` has returned from the `worker`.
+ * @property {Function} idle - a function returning false if there are items
+ * waiting or being processed, or true if not. Invoke like `cargo.idle()`.
+ * @property {Function} pause - a function that pauses the processing of tasks
+ * until `resume()` is called. Invoke like `cargo.pause()`.
+ * @property {Function} resume - a function that resumes the processing of
+ * queued tasks when the queue is paused. Invoke like `cargo.resume()`.
+ * @property {Function} kill - a function that removes the `drain` callback and
+ * empties remaining tasks from the queue forcing it to go idle. Invoke like `cargo.kill()`.
+ */
+
+/**
+ * Creates a `cargo` object with the specified payload. Tasks added to the
+ * cargo will be processed altogether (up to the `payload` limit). If the
+ * `worker` is in progress, the task is queued until it becomes available. Once
+ * the `worker` has completed some tasks, each callback of those tasks is
+ * called. Check out [these](https://camo.githubusercontent.com/6bbd36f4cf5b35a0f11a96dcd2e97711ffc2fb37/68747470733a2f2f662e636c6f75642e6769746875622e636f6d2f6173736574732f313637363837312f36383130382f62626330636662302d356632392d313165322d393734662d3333393763363464633835382e676966) [animations](https://camo.githubusercontent.com/f4810e00e1c5f5f8addbe3e9f49064fd5d102699/68747470733a2f2f662e636c6f75642e6769746875622e636f6d2f6173736574732f313637363837312f36383130312f38346339323036362d356632392d313165322d383134662d3964336430323431336266642e676966)
+ * for how `cargo` and `queue` work.
+ *
+ * While [`queue`]{@link module:ControlFlow.queue} passes only one task to one of a group of workers
+ * at a time, cargo passes an array of tasks to a single worker, repeating
+ * when the worker is finished.
+ *
+ * @name cargo
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @see [async.queue]{@link module:ControlFlow.queue}
+ * @category Control Flow
+ * @param {AsyncFunction} worker - An asynchronous function for processing an array
+ * of queued tasks. Invoked with `(tasks, callback)`.
+ * @param {number} [payload=Infinity] - An optional `integer` for determining
+ * how many tasks should be processed per round; if omitted, the default is
+ * unlimited.
+ * @returns {module:ControlFlow.CargoObject} A cargo object to manage the tasks. Callbacks can
+ * attached as certain properties to listen for specific events during the
+ * lifecycle of the cargo and inner queue.
+ * @example
+ *
+ * // create a cargo object with payload 2
+ * var cargo = async.cargo(function(tasks, callback) {
+ * for (var i=0; i true
+ */
+function identity(value) {
+ return value;
+}
+
+function _createTester(check, getResult) {
+ return function(eachfn, arr, iteratee, cb) {
+ cb = cb || noop;
+ var testPassed = false;
+ var testResult;
+ eachfn(arr, function(value, _, callback) {
+ iteratee(value, function(err, result) {
+ if (err) {
+ callback(err);
+ } else if (check(result) && !testResult) {
+ testPassed = true;
+ testResult = getResult(true, value);
+ callback(null, breakLoop);
+ } else {
+ callback();
+ }
+ });
+ }, function(err) {
+ if (err) {
+ cb(err);
+ } else {
+ cb(null, testPassed ? testResult : getResult(false));
+ }
+ });
+ };
+}
+
+function _findGetResult(v, x) {
+ return x;
+}
+
+/**
+ * Returns the first value in `coll` that passes an async truth test. The
+ * `iteratee` is applied in parallel, meaning the first iteratee to return
+ * `true` will fire the detect `callback` with that result. That means the
+ * result might not be the first item in the original `coll` (in terms of order)
+ * that passes the test.
+
+ * If order within the original `coll` is important, then look at
+ * [`detectSeries`]{@link module:Collections.detectSeries}.
+ *
+ * @name detect
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @alias find
+ * @category Collections
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {AsyncFunction} iteratee - A truth test to apply to each item in `coll`.
+ * The iteratee must complete with a boolean value as its result.
+ * Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called as soon as any
+ * iteratee returns `true`, or after all the `iteratee` functions have finished.
+ * Result will be the first item in the array that passes the truth test
+ * (iteratee) or the value `undefined` if none passed. Invoked with
+ * (err, result).
+ * @example
+ *
+ * async.detect(['file1','file2','file3'], function(filePath, callback) {
+ * fs.access(filePath, function(err) {
+ * callback(null, !err)
+ * });
+ * }, function(err, result) {
+ * // result now equals the first file in the list that exists
+ * });
+ */
+var detect = doParallel(_createTester(identity, _findGetResult));
+
+/**
+ * The same as [`detect`]{@link module:Collections.detect} but runs a maximum of `limit` async operations at a
+ * time.
+ *
+ * @name detectLimit
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.detect]{@link module:Collections.detect}
+ * @alias findLimit
+ * @category Collections
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {number} limit - The maximum number of async operations at a time.
+ * @param {AsyncFunction} iteratee - A truth test to apply to each item in `coll`.
+ * The iteratee must complete with a boolean value as its result.
+ * Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called as soon as any
+ * iteratee returns `true`, or after all the `iteratee` functions have finished.
+ * Result will be the first item in the array that passes the truth test
+ * (iteratee) or the value `undefined` if none passed. Invoked with
+ * (err, result).
+ */
+var detectLimit = doParallelLimit(_createTester(identity, _findGetResult));
+
+/**
+ * The same as [`detect`]{@link module:Collections.detect} but runs only a single async operation at a time.
+ *
+ * @name detectSeries
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.detect]{@link module:Collections.detect}
+ * @alias findSeries
+ * @category Collections
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {AsyncFunction} iteratee - A truth test to apply to each item in `coll`.
+ * The iteratee must complete with a boolean value as its result.
+ * Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called as soon as any
+ * iteratee returns `true`, or after all the `iteratee` functions have finished.
+ * Result will be the first item in the array that passes the truth test
+ * (iteratee) or the value `undefined` if none passed. Invoked with
+ * (err, result).
+ */
+var detectSeries = doLimit(detectLimit, 1);
+
+function consoleFunc(name) {
+ return function (fn/*, ...args*/) {
+ var args = slice(arguments, 1);
+ args.push(function (err/*, ...args*/) {
+ var args = slice(arguments, 1);
+ if (typeof console === 'object') {
+ if (err) {
+ if (console.error) {
+ console.error(err);
+ }
+ } else if (console[name]) {
+ arrayEach(args, function (x) {
+ console[name](x);
+ });
+ }
+ }
+ });
+ wrapAsync(fn).apply(null, args);
+ };
+}
+
+/**
+ * Logs the result of an [`async` function]{@link AsyncFunction} to the
+ * `console` using `console.dir` to display the properties of the resulting object.
+ * Only works in Node.js or in browsers that support `console.dir` and
+ * `console.error` (such as FF and Chrome).
+ * If multiple arguments are returned from the async function,
+ * `console.dir` is called on each argument in order.
+ *
+ * @name dir
+ * @static
+ * @memberOf module:Utils
+ * @method
+ * @category Util
+ * @param {AsyncFunction} function - The function you want to eventually apply
+ * all arguments to.
+ * @param {...*} arguments... - Any number of arguments to apply to the function.
+ * @example
+ *
+ * // in a module
+ * var hello = function(name, callback) {
+ * setTimeout(function() {
+ * callback(null, {hello: name});
+ * }, 1000);
+ * };
+ *
+ * // in the node repl
+ * node> async.dir(hello, 'world');
+ * {hello: 'world'}
+ */
+var dir = consoleFunc('dir');
+
+/**
+ * The post-check version of [`during`]{@link module:ControlFlow.during}. To reflect the difference in
+ * the order of operations, the arguments `test` and `fn` are switched.
+ *
+ * Also a version of [`doWhilst`]{@link module:ControlFlow.doWhilst} with asynchronous `test` function.
+ * @name doDuring
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @see [async.during]{@link module:ControlFlow.during}
+ * @category Control Flow
+ * @param {AsyncFunction} fn - An async function which is called each time
+ * `test` passes. Invoked with (callback).
+ * @param {AsyncFunction} test - asynchronous truth test to perform before each
+ * execution of `fn`. Invoked with (...args, callback), where `...args` are the
+ * non-error args from the previous callback of `fn`.
+ * @param {Function} [callback] - A callback which is called after the test
+ * function has failed and repeated execution of `fn` has stopped. `callback`
+ * will be passed an error if one occurred, otherwise `null`.
+ */
+function doDuring(fn, test, callback) {
+ callback = onlyOnce(callback || noop);
+ var _fn = wrapAsync(fn);
+ var _test = wrapAsync(test);
+
+ function next(err/*, ...args*/) {
+ if (err) return callback(err);
+ var args = slice(arguments, 1);
+ args.push(check);
+ _test.apply(this, args);
+ }
+
+ function check(err, truth) {
+ if (err) return callback(err);
+ if (!truth) return callback(null);
+ _fn(next);
+ }
+
+ check(null, true);
+
+}
+
+/**
+ * The post-check version of [`whilst`]{@link module:ControlFlow.whilst}. To reflect the difference in
+ * the order of operations, the arguments `test` and `iteratee` are switched.
+ *
+ * `doWhilst` is to `whilst` as `do while` is to `while` in plain JavaScript.
+ *
+ * @name doWhilst
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @see [async.whilst]{@link module:ControlFlow.whilst}
+ * @category Control Flow
+ * @param {AsyncFunction} iteratee - A function which is called each time `test`
+ * passes. Invoked with (callback).
+ * @param {Function} test - synchronous truth test to perform after each
+ * execution of `iteratee`. Invoked with any non-error callback results of
+ * `iteratee`.
+ * @param {Function} [callback] - A callback which is called after the test
+ * function has failed and repeated execution of `iteratee` has stopped.
+ * `callback` will be passed an error and any arguments passed to the final
+ * `iteratee`'s callback. Invoked with (err, [results]);
+ */
+function doWhilst(iteratee, test, callback) {
+ callback = onlyOnce(callback || noop);
+ var _iteratee = wrapAsync(iteratee);
+ var next = function(err/*, ...args*/) {
+ if (err) return callback(err);
+ var args = slice(arguments, 1);
+ if (test.apply(this, args)) return _iteratee(next);
+ callback.apply(null, [null].concat(args));
+ };
+ _iteratee(next);
+}
+
+/**
+ * Like ['doWhilst']{@link module:ControlFlow.doWhilst}, except the `test` is inverted. Note the
+ * argument ordering differs from `until`.
+ *
+ * @name doUntil
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @see [async.doWhilst]{@link module:ControlFlow.doWhilst}
+ * @category Control Flow
+ * @param {AsyncFunction} iteratee - An async function which is called each time
+ * `test` fails. Invoked with (callback).
+ * @param {Function} test - synchronous truth test to perform after each
+ * execution of `iteratee`. Invoked with any non-error callback results of
+ * `iteratee`.
+ * @param {Function} [callback] - A callback which is called after the test
+ * function has passed and repeated execution of `iteratee` has stopped. `callback`
+ * will be passed an error and any arguments passed to the final `iteratee`'s
+ * callback. Invoked with (err, [results]);
+ */
+function doUntil(iteratee, test, callback) {
+ doWhilst(iteratee, function() {
+ return !test.apply(this, arguments);
+ }, callback);
+}
+
+/**
+ * Like [`whilst`]{@link module:ControlFlow.whilst}, except the `test` is an asynchronous function that
+ * is passed a callback in the form of `function (err, truth)`. If error is
+ * passed to `test` or `fn`, the main callback is immediately called with the
+ * value of the error.
+ *
+ * @name during
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @see [async.whilst]{@link module:ControlFlow.whilst}
+ * @category Control Flow
+ * @param {AsyncFunction} test - asynchronous truth test to perform before each
+ * execution of `fn`. Invoked with (callback).
+ * @param {AsyncFunction} fn - An async function which is called each time
+ * `test` passes. Invoked with (callback).
+ * @param {Function} [callback] - A callback which is called after the test
+ * function has failed and repeated execution of `fn` has stopped. `callback`
+ * will be passed an error, if one occurred, otherwise `null`.
+ * @example
+ *
+ * var count = 0;
+ *
+ * async.during(
+ * function (callback) {
+ * return callback(null, count < 5);
+ * },
+ * function (callback) {
+ * count++;
+ * setTimeout(callback, 1000);
+ * },
+ * function (err) {
+ * // 5 seconds have passed
+ * }
+ * );
+ */
+function during(test, fn, callback) {
+ callback = onlyOnce(callback || noop);
+ var _fn = wrapAsync(fn);
+ var _test = wrapAsync(test);
+
+ function next(err) {
+ if (err) return callback(err);
+ _test(check);
+ }
+
+ function check(err, truth) {
+ if (err) return callback(err);
+ if (!truth) return callback(null);
+ _fn(next);
+ }
+
+ _test(check);
+}
+
+function _withoutIndex(iteratee) {
+ return function (value, index, callback) {
+ return iteratee(value, callback);
+ };
+}
+
+/**
+ * Applies the function `iteratee` to each item in `coll`, in parallel.
+ * The `iteratee` is called with an item from the list, and a callback for when
+ * it has finished. If the `iteratee` passes an error to its `callback`, the
+ * main `callback` (for the `each` function) is immediately called with the
+ * error.
+ *
+ * Note, that since this function applies `iteratee` to each item in parallel,
+ * there is no guarantee that the iteratee functions will complete in order.
+ *
+ * @name each
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @alias forEach
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {AsyncFunction} iteratee - An async function to apply to
+ * each item in `coll`. Invoked with (item, callback).
+ * The array index is not passed to the iteratee.
+ * If you need the index, use `eachOf`.
+ * @param {Function} [callback] - A callback which is called when all
+ * `iteratee` functions have finished, or an error occurs. Invoked with (err).
+ * @example
+ *
+ * // assuming openFiles is an array of file names and saveFile is a function
+ * // to save the modified contents of that file:
+ *
+ * async.each(openFiles, saveFile, function(err){
+ * // if any of the saves produced an error, err would equal that error
+ * });
+ *
+ * // assuming openFiles is an array of file names
+ * async.each(openFiles, function(file, callback) {
+ *
+ * // Perform operation on file here.
+ * console.log('Processing file ' + file);
+ *
+ * if( file.length > 32 ) {
+ * console.log('This file name is too long');
+ * callback('File name too long');
+ * } else {
+ * // Do work to process file here
+ * console.log('File processed');
+ * callback();
+ * }
+ * }, function(err) {
+ * // if any of the file processing produced an error, err would equal that error
+ * if( err ) {
+ * // One of the iterations produced an error.
+ * // All processing will now stop.
+ * console.log('A file failed to process');
+ * } else {
+ * console.log('All files have been processed successfully');
+ * }
+ * });
+ */
+function eachLimit(coll, iteratee, callback) {
+ eachOf(coll, _withoutIndex(wrapAsync(iteratee)), callback);
+}
+
+/**
+ * The same as [`each`]{@link module:Collections.each} but runs a maximum of `limit` async operations at a time.
+ *
+ * @name eachLimit
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.each]{@link module:Collections.each}
+ * @alias forEachLimit
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {number} limit - The maximum number of async operations at a time.
+ * @param {AsyncFunction} iteratee - An async function to apply to each item in
+ * `coll`.
+ * The array index is not passed to the iteratee.
+ * If you need the index, use `eachOfLimit`.
+ * Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called when all
+ * `iteratee` functions have finished, or an error occurs. Invoked with (err).
+ */
+function eachLimit$1(coll, limit, iteratee, callback) {
+ _eachOfLimit(limit)(coll, _withoutIndex(wrapAsync(iteratee)), callback);
+}
+
+/**
+ * The same as [`each`]{@link module:Collections.each} but runs only a single async operation at a time.
+ *
+ * @name eachSeries
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.each]{@link module:Collections.each}
+ * @alias forEachSeries
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {AsyncFunction} iteratee - An async function to apply to each
+ * item in `coll`.
+ * The array index is not passed to the iteratee.
+ * If you need the index, use `eachOfSeries`.
+ * Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called when all
+ * `iteratee` functions have finished, or an error occurs. Invoked with (err).
+ */
+var eachSeries = doLimit(eachLimit$1, 1);
+
+/**
+ * Wrap an async function and ensure it calls its callback on a later tick of
+ * the event loop. If the function already calls its callback on a next tick,
+ * no extra deferral is added. This is useful for preventing stack overflows
+ * (`RangeError: Maximum call stack size exceeded`) and generally keeping
+ * [Zalgo](http://blog.izs.me/post/59142742143/designing-apis-for-asynchrony)
+ * contained. ES2017 `async` functions are returned as-is -- they are immune
+ * to Zalgo's corrupting influences, as they always resolve on a later tick.
+ *
+ * @name ensureAsync
+ * @static
+ * @memberOf module:Utils
+ * @method
+ * @category Util
+ * @param {AsyncFunction} fn - an async function, one that expects a node-style
+ * callback as its last argument.
+ * @returns {AsyncFunction} Returns a wrapped function with the exact same call
+ * signature as the function passed in.
+ * @example
+ *
+ * function sometimesAsync(arg, callback) {
+ * if (cache[arg]) {
+ * return callback(null, cache[arg]); // this would be synchronous!!
+ * } else {
+ * doSomeIO(arg, callback); // this IO would be asynchronous
+ * }
+ * }
+ *
+ * // this has a risk of stack overflows if many results are cached in a row
+ * async.mapSeries(args, sometimesAsync, done);
+ *
+ * // this will defer sometimesAsync's callback if necessary,
+ * // preventing stack overflows
+ * async.mapSeries(args, async.ensureAsync(sometimesAsync), done);
+ */
+function ensureAsync(fn) {
+ if (isAsync(fn)) return fn;
+ return initialParams(function (args, callback) {
+ var sync = true;
+ args.push(function () {
+ var innerArgs = arguments;
+ if (sync) {
+ setImmediate$1(function () {
+ callback.apply(null, innerArgs);
+ });
+ } else {
+ callback.apply(null, innerArgs);
+ }
+ });
+ fn.apply(this, args);
+ sync = false;
+ });
+}
+
+function notId(v) {
+ return !v;
+}
+
+/**
+ * Returns `true` if every element in `coll` satisfies an async test. If any
+ * iteratee call returns `false`, the main `callback` is immediately called.
+ *
+ * @name every
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @alias all
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {AsyncFunction} iteratee - An async truth test to apply to each item
+ * in the collection in parallel.
+ * The iteratee must complete with a boolean result value.
+ * Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called after all the
+ * `iteratee` functions have finished. Result will be either `true` or `false`
+ * depending on the values of the async tests. Invoked with (err, result).
+ * @example
+ *
+ * async.every(['file1','file2','file3'], function(filePath, callback) {
+ * fs.access(filePath, function(err) {
+ * callback(null, !err)
+ * });
+ * }, function(err, result) {
+ * // if result is true then every file exists
+ * });
+ */
+var every = doParallel(_createTester(notId, notId));
+
+/**
+ * The same as [`every`]{@link module:Collections.every} but runs a maximum of `limit` async operations at a time.
+ *
+ * @name everyLimit
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.every]{@link module:Collections.every}
+ * @alias allLimit
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {number} limit - The maximum number of async operations at a time.
+ * @param {AsyncFunction} iteratee - An async truth test to apply to each item
+ * in the collection in parallel.
+ * The iteratee must complete with a boolean result value.
+ * Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called after all the
+ * `iteratee` functions have finished. Result will be either `true` or `false`
+ * depending on the values of the async tests. Invoked with (err, result).
+ */
+var everyLimit = doParallelLimit(_createTester(notId, notId));
+
+/**
+ * The same as [`every`]{@link module:Collections.every} but runs only a single async operation at a time.
+ *
+ * @name everySeries
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.every]{@link module:Collections.every}
+ * @alias allSeries
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {AsyncFunction} iteratee - An async truth test to apply to each item
+ * in the collection in series.
+ * The iteratee must complete with a boolean result value.
+ * Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called after all the
+ * `iteratee` functions have finished. Result will be either `true` or `false`
+ * depending on the values of the async tests. Invoked with (err, result).
+ */
+var everySeries = doLimit(everyLimit, 1);
+
+/**
+ * The base implementation of `_.property` without support for deep paths.
+ *
+ * @private
+ * @param {string} key The key of the property to get.
+ * @returns {Function} Returns the new accessor function.
+ */
+function baseProperty(key) {
+ return function(object) {
+ return object == null ? undefined : object[key];
+ };
+}
+
+function filterArray(eachfn, arr, iteratee, callback) {
+ var truthValues = new Array(arr.length);
+ eachfn(arr, function (x, index, callback) {
+ iteratee(x, function (err, v) {
+ truthValues[index] = !!v;
+ callback(err);
+ });
+ }, function (err) {
+ if (err) return callback(err);
+ var results = [];
+ for (var i = 0; i < arr.length; i++) {
+ if (truthValues[i]) results.push(arr[i]);
+ }
+ callback(null, results);
+ });
+}
+
+function filterGeneric(eachfn, coll, iteratee, callback) {
+ var results = [];
+ eachfn(coll, function (x, index, callback) {
+ iteratee(x, function (err, v) {
+ if (err) {
+ callback(err);
+ } else {
+ if (v) {
+ results.push({index: index, value: x});
+ }
+ callback();
+ }
+ });
+ }, function (err) {
+ if (err) {
+ callback(err);
+ } else {
+ callback(null, arrayMap(results.sort(function (a, b) {
+ return a.index - b.index;
+ }), baseProperty('value')));
+ }
+ });
+}
+
+function _filter(eachfn, coll, iteratee, callback) {
+ var filter = isArrayLike(coll) ? filterArray : filterGeneric;
+ filter(eachfn, coll, wrapAsync(iteratee), callback || noop);
+}
+
+/**
+ * Returns a new array of all the values in `coll` which pass an async truth
+ * test. This operation is performed in parallel, but the results array will be
+ * in the same order as the original.
+ *
+ * @name filter
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @alias select
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {Function} iteratee - A truth test to apply to each item in `coll`.
+ * The `iteratee` is passed a `callback(err, truthValue)`, which must be called
+ * with a boolean argument once it has completed. Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called after all the
+ * `iteratee` functions have finished. Invoked with (err, results).
+ * @example
+ *
+ * async.filter(['file1','file2','file3'], function(filePath, callback) {
+ * fs.access(filePath, function(err) {
+ * callback(null, !err)
+ * });
+ * }, function(err, results) {
+ * // results now equals an array of the existing files
+ * });
+ */
+var filter = doParallel(_filter);
+
+/**
+ * The same as [`filter`]{@link module:Collections.filter} but runs a maximum of `limit` async operations at a
+ * time.
+ *
+ * @name filterLimit
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.filter]{@link module:Collections.filter}
+ * @alias selectLimit
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {number} limit - The maximum number of async operations at a time.
+ * @param {Function} iteratee - A truth test to apply to each item in `coll`.
+ * The `iteratee` is passed a `callback(err, truthValue)`, which must be called
+ * with a boolean argument once it has completed. Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called after all the
+ * `iteratee` functions have finished. Invoked with (err, results).
+ */
+var filterLimit = doParallelLimit(_filter);
+
+/**
+ * The same as [`filter`]{@link module:Collections.filter} but runs only a single async operation at a time.
+ *
+ * @name filterSeries
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.filter]{@link module:Collections.filter}
+ * @alias selectSeries
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {Function} iteratee - A truth test to apply to each item in `coll`.
+ * The `iteratee` is passed a `callback(err, truthValue)`, which must be called
+ * with a boolean argument once it has completed. Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called after all the
+ * `iteratee` functions have finished. Invoked with (err, results)
+ */
+var filterSeries = doLimit(filterLimit, 1);
+
+/**
+ * Calls the asynchronous function `fn` with a callback parameter that allows it
+ * to call itself again, in series, indefinitely.
+
+ * If an error is passed to the callback then `errback` is called with the
+ * error, and execution stops, otherwise it will never be called.
+ *
+ * @name forever
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @category Control Flow
+ * @param {AsyncFunction} fn - an async function to call repeatedly.
+ * Invoked with (next).
+ * @param {Function} [errback] - when `fn` passes an error to it's callback,
+ * this function will be called, and execution stops. Invoked with (err).
+ * @example
+ *
+ * async.forever(
+ * function(next) {
+ * // next is suitable for passing to things that need a callback(err [, whatever]);
+ * // it will result in this function being called again.
+ * },
+ * function(err) {
+ * // if next is called with a value in its first parameter, it will appear
+ * // in here as 'err', and execution will stop.
+ * }
+ * );
+ */
+function forever(fn, errback) {
+ var done = onlyOnce(errback || noop);
+ var task = wrapAsync(ensureAsync(fn));
+
+ function next(err) {
+ if (err) return done(err);
+ task(next);
+ }
+ next();
+}
+
+/**
+ * The same as [`groupBy`]{@link module:Collections.groupBy} but runs a maximum of `limit` async operations at a time.
+ *
+ * @name groupByLimit
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.groupBy]{@link module:Collections.groupBy}
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {number} limit - The maximum number of async operations at a time.
+ * @param {AsyncFunction} iteratee - An async function to apply to each item in
+ * `coll`.
+ * The iteratee should complete with a `key` to group the value under.
+ * Invoked with (value, callback).
+ * @param {Function} [callback] - A callback which is called when all `iteratee`
+ * functions have finished, or an error occurs. Result is an `Object` whoses
+ * properties are arrays of values which returned the corresponding key.
+ */
+var groupByLimit = function(coll, limit, iteratee, callback) {
+ callback = callback || noop;
+ var _iteratee = wrapAsync(iteratee);
+ mapLimit(coll, limit, function(val, callback) {
+ _iteratee(val, function(err, key) {
+ if (err) return callback(err);
+ return callback(null, {key: key, val: val});
+ });
+ }, function(err, mapResults) {
+ var result = {};
+ // from MDN, handle object having an `hasOwnProperty` prop
+ var hasOwnProperty = Object.prototype.hasOwnProperty;
+
+ for (var i = 0; i < mapResults.length; i++) {
+ if (mapResults[i]) {
+ var key = mapResults[i].key;
+ var val = mapResults[i].val;
+
+ if (hasOwnProperty.call(result, key)) {
+ result[key].push(val);
+ } else {
+ result[key] = [val];
+ }
+ }
+ }
+
+ return callback(err, result);
+ });
+};
+
+/**
+ * Returns a new object, where each value corresponds to an array of items, from
+ * `coll`, that returned the corresponding key. That is, the keys of the object
+ * correspond to the values passed to the `iteratee` callback.
+ *
+ * Note: Since this function applies the `iteratee` to each item in parallel,
+ * there is no guarantee that the `iteratee` functions will complete in order.
+ * However, the values for each key in the `result` will be in the same order as
+ * the original `coll`. For Objects, the values will roughly be in the order of
+ * the original Objects' keys (but this can vary across JavaScript engines).
+ *
+ * @name groupBy
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {AsyncFunction} iteratee - An async function to apply to each item in
+ * `coll`.
+ * The iteratee should complete with a `key` to group the value under.
+ * Invoked with (value, callback).
+ * @param {Function} [callback] - A callback which is called when all `iteratee`
+ * functions have finished, or an error occurs. Result is an `Object` whoses
+ * properties are arrays of values which returned the corresponding key.
+ * @example
+ *
+ * async.groupBy(['userId1', 'userId2', 'userId3'], function(userId, callback) {
+ * db.findById(userId, function(err, user) {
+ * if (err) return callback(err);
+ * return callback(null, user.age);
+ * });
+ * }, function(err, result) {
+ * // result is object containing the userIds grouped by age
+ * // e.g. { 30: ['userId1', 'userId3'], 42: ['userId2']};
+ * });
+ */
+var groupBy = doLimit(groupByLimit, Infinity);
+
+/**
+ * The same as [`groupBy`]{@link module:Collections.groupBy} but runs only a single async operation at a time.
+ *
+ * @name groupBySeries
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.groupBy]{@link module:Collections.groupBy}
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {number} limit - The maximum number of async operations at a time.
+ * @param {AsyncFunction} iteratee - An async function to apply to each item in
+ * `coll`.
+ * The iteratee should complete with a `key` to group the value under.
+ * Invoked with (value, callback).
+ * @param {Function} [callback] - A callback which is called when all `iteratee`
+ * functions have finished, or an error occurs. Result is an `Object` whoses
+ * properties are arrays of values which returned the corresponding key.
+ */
+var groupBySeries = doLimit(groupByLimit, 1);
+
+/**
+ * Logs the result of an `async` function to the `console`. Only works in
+ * Node.js or in browsers that support `console.log` and `console.error` (such
+ * as FF and Chrome). If multiple arguments are returned from the async
+ * function, `console.log` is called on each argument in order.
+ *
+ * @name log
+ * @static
+ * @memberOf module:Utils
+ * @method
+ * @category Util
+ * @param {AsyncFunction} function - The function you want to eventually apply
+ * all arguments to.
+ * @param {...*} arguments... - Any number of arguments to apply to the function.
+ * @example
+ *
+ * // in a module
+ * var hello = function(name, callback) {
+ * setTimeout(function() {
+ * callback(null, 'hello ' + name);
+ * }, 1000);
+ * };
+ *
+ * // in the node repl
+ * node> async.log(hello, 'world');
+ * 'hello world'
+ */
+var log = consoleFunc('log');
+
+/**
+ * The same as [`mapValues`]{@link module:Collections.mapValues} but runs a maximum of `limit` async operations at a
+ * time.
+ *
+ * @name mapValuesLimit
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.mapValues]{@link module:Collections.mapValues}
+ * @category Collection
+ * @param {Object} obj - A collection to iterate over.
+ * @param {number} limit - The maximum number of async operations at a time.
+ * @param {AsyncFunction} iteratee - A function to apply to each value and key
+ * in `coll`.
+ * The iteratee should complete with the transformed value as its result.
+ * Invoked with (value, key, callback).
+ * @param {Function} [callback] - A callback which is called when all `iteratee`
+ * functions have finished, or an error occurs. `result` is a new object consisting
+ * of each key from `obj`, with each transformed value on the right-hand side.
+ * Invoked with (err, result).
+ */
+function mapValuesLimit(obj, limit, iteratee, callback) {
+ callback = once(callback || noop);
+ var newObj = {};
+ var _iteratee = wrapAsync(iteratee);
+ eachOfLimit(obj, limit, function(val, key, next) {
+ _iteratee(val, key, function (err, result) {
+ if (err) return next(err);
+ newObj[key] = result;
+ next();
+ });
+ }, function (err) {
+ callback(err, newObj);
+ });
+}
+
+/**
+ * A relative of [`map`]{@link module:Collections.map}, designed for use with objects.
+ *
+ * Produces a new Object by mapping each value of `obj` through the `iteratee`
+ * function. The `iteratee` is called each `value` and `key` from `obj` and a
+ * callback for when it has finished processing. Each of these callbacks takes
+ * two arguments: an `error`, and the transformed item from `obj`. If `iteratee`
+ * passes an error to its callback, the main `callback` (for the `mapValues`
+ * function) is immediately called with the error.
+ *
+ * Note, the order of the keys in the result is not guaranteed. The keys will
+ * be roughly in the order they complete, (but this is very engine-specific)
+ *
+ * @name mapValues
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @category Collection
+ * @param {Object} obj - A collection to iterate over.
+ * @param {AsyncFunction} iteratee - A function to apply to each value and key
+ * in `coll`.
+ * The iteratee should complete with the transformed value as its result.
+ * Invoked with (value, key, callback).
+ * @param {Function} [callback] - A callback which is called when all `iteratee`
+ * functions have finished, or an error occurs. `result` is a new object consisting
+ * of each key from `obj`, with each transformed value on the right-hand side.
+ * Invoked with (err, result).
+ * @example
+ *
+ * async.mapValues({
+ * f1: 'file1',
+ * f2: 'file2',
+ * f3: 'file3'
+ * }, function (file, key, callback) {
+ * fs.stat(file, callback);
+ * }, function(err, result) {
+ * // result is now a map of stats for each file, e.g.
+ * // {
+ * // f1: [stats for file1],
+ * // f2: [stats for file2],
+ * // f3: [stats for file3]
+ * // }
+ * });
+ */
+
+var mapValues = doLimit(mapValuesLimit, Infinity);
+
+/**
+ * The same as [`mapValues`]{@link module:Collections.mapValues} but runs only a single async operation at a time.
+ *
+ * @name mapValuesSeries
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.mapValues]{@link module:Collections.mapValues}
+ * @category Collection
+ * @param {Object} obj - A collection to iterate over.
+ * @param {AsyncFunction} iteratee - A function to apply to each value and key
+ * in `coll`.
+ * The iteratee should complete with the transformed value as its result.
+ * Invoked with (value, key, callback).
+ * @param {Function} [callback] - A callback which is called when all `iteratee`
+ * functions have finished, or an error occurs. `result` is a new object consisting
+ * of each key from `obj`, with each transformed value on the right-hand side.
+ * Invoked with (err, result).
+ */
+var mapValuesSeries = doLimit(mapValuesLimit, 1);
+
+function has(obj, key) {
+ return key in obj;
+}
+
+/**
+ * Caches the results of an async function. When creating a hash to store
+ * function results against, the callback is omitted from the hash and an
+ * optional hash function can be used.
+ *
+ * If no hash function is specified, the first argument is used as a hash key,
+ * which may work reasonably if it is a string or a data type that converts to a
+ * distinct string. Note that objects and arrays will not behave reasonably.
+ * Neither will cases where the other arguments are significant. In such cases,
+ * specify your own hash function.
+ *
+ * The cache of results is exposed as the `memo` property of the function
+ * returned by `memoize`.
+ *
+ * @name memoize
+ * @static
+ * @memberOf module:Utils
+ * @method
+ * @category Util
+ * @param {AsyncFunction} fn - The async function to proxy and cache results from.
+ * @param {Function} hasher - An optional function for generating a custom hash
+ * for storing results. It has all the arguments applied to it apart from the
+ * callback, and must be synchronous.
+ * @returns {AsyncFunction} a memoized version of `fn`
+ * @example
+ *
+ * var slow_fn = function(name, callback) {
+ * // do something
+ * callback(null, result);
+ * };
+ * var fn = async.memoize(slow_fn);
+ *
+ * // fn can now be used as if it were slow_fn
+ * fn('some name', function() {
+ * // callback
+ * });
+ */
+function memoize(fn, hasher) {
+ var memo = Object.create(null);
+ var queues = Object.create(null);
+ hasher = hasher || identity;
+ var _fn = wrapAsync(fn);
+ var memoized = initialParams(function memoized(args, callback) {
+ var key = hasher.apply(null, args);
+ if (has(memo, key)) {
+ setImmediate$1(function() {
+ callback.apply(null, memo[key]);
+ });
+ } else if (has(queues, key)) {
+ queues[key].push(callback);
+ } else {
+ queues[key] = [callback];
+ _fn.apply(null, args.concat(function(/*args*/) {
+ var args = slice(arguments);
+ memo[key] = args;
+ var q = queues[key];
+ delete queues[key];
+ for (var i = 0, l = q.length; i < l; i++) {
+ q[i].apply(null, args);
+ }
+ }));
+ }
+ });
+ memoized.memo = memo;
+ memoized.unmemoized = fn;
+ return memoized;
+}
+
+/**
+ * Calls `callback` on a later loop around the event loop. In Node.js this just
+ * calls `process.nextTick`. In the browser it will use `setImmediate` if
+ * available, otherwise `setTimeout(callback, 0)`, which means other higher
+ * priority events may precede the execution of `callback`.
+ *
+ * This is used internally for browser-compatibility purposes.
+ *
+ * @name nextTick
+ * @static
+ * @memberOf module:Utils
+ * @method
+ * @see [async.setImmediate]{@link module:Utils.setImmediate}
+ * @category Util
+ * @param {Function} callback - The function to call on a later loop around
+ * the event loop. Invoked with (args...).
+ * @param {...*} args... - any number of additional arguments to pass to the
+ * callback on the next tick.
+ * @example
+ *
+ * var call_order = [];
+ * async.nextTick(function() {
+ * call_order.push('two');
+ * // call_order now equals ['one','two']
+ * });
+ * call_order.push('one');
+ *
+ * async.setImmediate(function (a, b, c) {
+ * // a, b, and c equal 1, 2, and 3
+ * }, 1, 2, 3);
+ */
+var _defer$1;
+
+if (hasNextTick) {
+ _defer$1 = process.nextTick;
+} else if (hasSetImmediate) {
+ _defer$1 = setImmediate;
+} else {
+ _defer$1 = fallback;
+}
+
+var nextTick = wrap(_defer$1);
+
+function _parallel(eachfn, tasks, callback) {
+ callback = callback || noop;
+ var results = isArrayLike(tasks) ? [] : {};
+
+ eachfn(tasks, function (task, key, callback) {
+ wrapAsync(task)(function (err, result) {
+ if (arguments.length > 2) {
+ result = slice(arguments, 1);
+ }
+ results[key] = result;
+ callback(err);
+ });
+ }, function (err) {
+ callback(err, results);
+ });
+}
+
+/**
+ * Run the `tasks` collection of functions in parallel, without waiting until
+ * the previous function has completed. If any of the functions pass an error to
+ * its callback, the main `callback` is immediately called with the value of the
+ * error. Once the `tasks` have completed, the results are passed to the final
+ * `callback` as an array.
+ *
+ * **Note:** `parallel` is about kicking-off I/O tasks in parallel, not about
+ * parallel execution of code. If your tasks do not use any timers or perform
+ * any I/O, they will actually be executed in series. Any synchronous setup
+ * sections for each task will happen one after the other. JavaScript remains
+ * single-threaded.
+ *
+ * **Hint:** Use [`reflect`]{@link module:Utils.reflect} to continue the
+ * execution of other tasks when a task fails.
+ *
+ * It is also possible to use an object instead of an array. Each property will
+ * be run as a function and the results will be passed to the final `callback`
+ * as an object instead of an array. This can be a more readable way of handling
+ * results from {@link async.parallel}.
+ *
+ * @name parallel
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @category Control Flow
+ * @param {Array|Iterable|Object} tasks - A collection of
+ * [async functions]{@link AsyncFunction} to run.
+ * Each async function can complete with any number of optional `result` values.
+ * @param {Function} [callback] - An optional callback to run once all the
+ * functions have completed successfully. This function gets a results array
+ * (or object) containing all the result arguments passed to the task callbacks.
+ * Invoked with (err, results).
+ *
+ * @example
+ * async.parallel([
+ * function(callback) {
+ * setTimeout(function() {
+ * callback(null, 'one');
+ * }, 200);
+ * },
+ * function(callback) {
+ * setTimeout(function() {
+ * callback(null, 'two');
+ * }, 100);
+ * }
+ * ],
+ * // optional callback
+ * function(err, results) {
+ * // the results array will equal ['one','two'] even though
+ * // the second function had a shorter timeout.
+ * });
+ *
+ * // an example using an object instead of an array
+ * async.parallel({
+ * one: function(callback) {
+ * setTimeout(function() {
+ * callback(null, 1);
+ * }, 200);
+ * },
+ * two: function(callback) {
+ * setTimeout(function() {
+ * callback(null, 2);
+ * }, 100);
+ * }
+ * }, function(err, results) {
+ * // results is now equals to: {one: 1, two: 2}
+ * });
+ */
+function parallelLimit(tasks, callback) {
+ _parallel(eachOf, tasks, callback);
+}
+
+/**
+ * The same as [`parallel`]{@link module:ControlFlow.parallel} but runs a maximum of `limit` async operations at a
+ * time.
+ *
+ * @name parallelLimit
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @see [async.parallel]{@link module:ControlFlow.parallel}
+ * @category Control Flow
+ * @param {Array|Iterable|Object} tasks - A collection of
+ * [async functions]{@link AsyncFunction} to run.
+ * Each async function can complete with any number of optional `result` values.
+ * @param {number} limit - The maximum number of async operations at a time.
+ * @param {Function} [callback] - An optional callback to run once all the
+ * functions have completed successfully. This function gets a results array
+ * (or object) containing all the result arguments passed to the task callbacks.
+ * Invoked with (err, results).
+ */
+function parallelLimit$1(tasks, limit, callback) {
+ _parallel(_eachOfLimit(limit), tasks, callback);
+}
+
+/**
+ * A queue of tasks for the worker function to complete.
+ * @typedef {Object} QueueObject
+ * @memberOf module:ControlFlow
+ * @property {Function} length - a function returning the number of items
+ * waiting to be processed. Invoke with `queue.length()`.
+ * @property {boolean} started - a boolean indicating whether or not any
+ * items have been pushed and processed by the queue.
+ * @property {Function} running - a function returning the number of items
+ * currently being processed. Invoke with `queue.running()`.
+ * @property {Function} workersList - a function returning the array of items
+ * currently being processed. Invoke with `queue.workersList()`.
+ * @property {Function} idle - a function returning false if there are items
+ * waiting or being processed, or true if not. Invoke with `queue.idle()`.
+ * @property {number} concurrency - an integer for determining how many `worker`
+ * functions should be run in parallel. This property can be changed after a
+ * `queue` is created to alter the concurrency on-the-fly.
+ * @property {Function} push - add a new task to the `queue`. Calls `callback`
+ * once the `worker` has finished processing the task. Instead of a single task,
+ * a `tasks` array can be submitted. The respective callback is used for every
+ * task in the list. Invoke with `queue.push(task, [callback])`,
+ * @property {Function} unshift - add a new task to the front of the `queue`.
+ * Invoke with `queue.unshift(task, [callback])`.
+ * @property {Function} remove - remove items from the queue that match a test
+ * function. The test function will be passed an object with a `data` property,
+ * and a `priority` property, if this is a
+ * [priorityQueue]{@link module:ControlFlow.priorityQueue} object.
+ * Invoked with `queue.remove(testFn)`, where `testFn` is of the form
+ * `function ({data, priority}) {}` and returns a Boolean.
+ * @property {Function} saturated - a callback that is called when the number of
+ * running workers hits the `concurrency` limit, and further tasks will be
+ * queued.
+ * @property {Function} unsaturated - a callback that is called when the number
+ * of running workers is less than the `concurrency` & `buffer` limits, and
+ * further tasks will not be queued.
+ * @property {number} buffer - A minimum threshold buffer in order to say that
+ * the `queue` is `unsaturated`.
+ * @property {Function} empty - a callback that is called when the last item
+ * from the `queue` is given to a `worker`.
+ * @property {Function} drain - a callback that is called when the last item
+ * from the `queue` has returned from the `worker`.
+ * @property {Function} error - a callback that is called when a task errors.
+ * Has the signature `function(error, task)`.
+ * @property {boolean} paused - a boolean for determining whether the queue is
+ * in a paused state.
+ * @property {Function} pause - a function that pauses the processing of tasks
+ * until `resume()` is called. Invoke with `queue.pause()`.
+ * @property {Function} resume - a function that resumes the processing of
+ * queued tasks when the queue is paused. Invoke with `queue.resume()`.
+ * @property {Function} kill - a function that removes the `drain` callback and
+ * empties remaining tasks from the queue forcing it to go idle. No more tasks
+ * should be pushed to the queue after calling this function. Invoke with `queue.kill()`.
+ */
+
+/**
+ * Creates a `queue` object with the specified `concurrency`. Tasks added to the
+ * `queue` are processed in parallel (up to the `concurrency` limit). If all
+ * `worker`s are in progress, the task is queued until one becomes available.
+ * Once a `worker` completes a `task`, that `task`'s callback is called.
+ *
+ * @name queue
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @category Control Flow
+ * @param {AsyncFunction} worker - An async function for processing a queued task.
+ * If you want to handle errors from an individual task, pass a callback to
+ * `q.push()`. Invoked with (task, callback).
+ * @param {number} [concurrency=1] - An `integer` for determining how many
+ * `worker` functions should be run in parallel. If omitted, the concurrency
+ * defaults to `1`. If the concurrency is `0`, an error is thrown.
+ * @returns {module:ControlFlow.QueueObject} A queue object to manage the tasks. Callbacks can
+ * attached as certain properties to listen for specific events during the
+ * lifecycle of the queue.
+ * @example
+ *
+ * // create a queue object with concurrency 2
+ * var q = async.queue(function(task, callback) {
+ * console.log('hello ' + task.name);
+ * callback();
+ * }, 2);
+ *
+ * // assign a callback
+ * q.drain = function() {
+ * console.log('all items have been processed');
+ * };
+ *
+ * // add some items to the queue
+ * q.push({name: 'foo'}, function(err) {
+ * console.log('finished processing foo');
+ * });
+ * q.push({name: 'bar'}, function (err) {
+ * console.log('finished processing bar');
+ * });
+ *
+ * // add some items to the queue (batch-wise)
+ * q.push([{name: 'baz'},{name: 'bay'},{name: 'bax'}], function(err) {
+ * console.log('finished processing item');
+ * });
+ *
+ * // add some items to the front of the queue
+ * q.unshift({name: 'bar'}, function (err) {
+ * console.log('finished processing bar');
+ * });
+ */
+var queue$1 = function (worker, concurrency) {
+ var _worker = wrapAsync(worker);
+ return queue(function (items, cb) {
+ _worker(items[0], cb);
+ }, concurrency, 1);
+};
+
+/**
+ * The same as [async.queue]{@link module:ControlFlow.queue} only tasks are assigned a priority and
+ * completed in ascending priority order.
+ *
+ * @name priorityQueue
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @see [async.queue]{@link module:ControlFlow.queue}
+ * @category Control Flow
+ * @param {AsyncFunction} worker - An async function for processing a queued task.
+ * If you want to handle errors from an individual task, pass a callback to
+ * `q.push()`.
+ * Invoked with (task, callback).
+ * @param {number} concurrency - An `integer` for determining how many `worker`
+ * functions should be run in parallel. If omitted, the concurrency defaults to
+ * `1`. If the concurrency is `0`, an error is thrown.
+ * @returns {module:ControlFlow.QueueObject} A priorityQueue object to manage the tasks. There are two
+ * differences between `queue` and `priorityQueue` objects:
+ * * `push(task, priority, [callback])` - `priority` should be a number. If an
+ * array of `tasks` is given, all tasks will be assigned the same priority.
+ * * The `unshift` method was removed.
+ */
+var priorityQueue = function(worker, concurrency) {
+ // Start with a normal queue
+ var q = queue$1(worker, concurrency);
+
+ // Override push to accept second parameter representing priority
+ q.push = function(data, priority, callback) {
+ if (callback == null) callback = noop;
+ if (typeof callback !== 'function') {
+ throw new Error('task callback must be a function');
+ }
+ q.started = true;
+ if (!isArray(data)) {
+ data = [data];
+ }
+ if (data.length === 0) {
+ // call drain immediately if there are no tasks
+ return setImmediate$1(function() {
+ q.drain();
+ });
+ }
+
+ priority = priority || 0;
+ var nextNode = q._tasks.head;
+ while (nextNode && priority >= nextNode.priority) {
+ nextNode = nextNode.next;
+ }
+
+ for (var i = 0, l = data.length; i < l; i++) {
+ var item = {
+ data: data[i],
+ priority: priority,
+ callback: callback
+ };
+
+ if (nextNode) {
+ q._tasks.insertBefore(nextNode, item);
+ } else {
+ q._tasks.push(item);
+ }
+ }
+ setImmediate$1(q.process);
+ };
+
+ // Remove unshift function
+ delete q.unshift;
+
+ return q;
+};
+
+/**
+ * Runs the `tasks` array of functions in parallel, without waiting until the
+ * previous function has completed. Once any of the `tasks` complete or pass an
+ * error to its callback, the main `callback` is immediately called. It's
+ * equivalent to `Promise.race()`.
+ *
+ * @name race
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @category Control Flow
+ * @param {Array} tasks - An array containing [async functions]{@link AsyncFunction}
+ * to run. Each function can complete with an optional `result` value.
+ * @param {Function} callback - A callback to run once any of the functions have
+ * completed. This function gets an error or result from the first function that
+ * completed. Invoked with (err, result).
+ * @returns undefined
+ * @example
+ *
+ * async.race([
+ * function(callback) {
+ * setTimeout(function() {
+ * callback(null, 'one');
+ * }, 200);
+ * },
+ * function(callback) {
+ * setTimeout(function() {
+ * callback(null, 'two');
+ * }, 100);
+ * }
+ * ],
+ * // main callback
+ * function(err, result) {
+ * // the result will be equal to 'two' as it finishes earlier
+ * });
+ */
+function race(tasks, callback) {
+ callback = once(callback || noop);
+ if (!isArray(tasks)) return callback(new TypeError('First argument to race must be an array of functions'));
+ if (!tasks.length) return callback();
+ for (var i = 0, l = tasks.length; i < l; i++) {
+ wrapAsync(tasks[i])(callback);
+ }
+}
+
+/**
+ * Same as [`reduce`]{@link module:Collections.reduce}, only operates on `array` in reverse order.
+ *
+ * @name reduceRight
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.reduce]{@link module:Collections.reduce}
+ * @alias foldr
+ * @category Collection
+ * @param {Array} array - A collection to iterate over.
+ * @param {*} memo - The initial state of the reduction.
+ * @param {AsyncFunction} iteratee - A function applied to each item in the
+ * array to produce the next step in the reduction.
+ * The `iteratee` should complete with the next state of the reduction.
+ * If the iteratee complete with an error, the reduction is stopped and the
+ * main `callback` is immediately called with the error.
+ * Invoked with (memo, item, callback).
+ * @param {Function} [callback] - A callback which is called after all the
+ * `iteratee` functions have finished. Result is the reduced value. Invoked with
+ * (err, result).
+ */
+function reduceRight (array, memo, iteratee, callback) {
+ var reversed = slice(array).reverse();
+ reduce(reversed, memo, iteratee, callback);
+}
+
+/**
+ * Wraps the async function in another function that always completes with a
+ * result object, even when it errors.
+ *
+ * The result object has either the property `error` or `value`.
+ *
+ * @name reflect
+ * @static
+ * @memberOf module:Utils
+ * @method
+ * @category Util
+ * @param {AsyncFunction} fn - The async function you want to wrap
+ * @returns {Function} - A function that always passes null to it's callback as
+ * the error. The second argument to the callback will be an `object` with
+ * either an `error` or a `value` property.
+ * @example
+ *
+ * async.parallel([
+ * async.reflect(function(callback) {
+ * // do some stuff ...
+ * callback(null, 'one');
+ * }),
+ * async.reflect(function(callback) {
+ * // do some more stuff but error ...
+ * callback('bad stuff happened');
+ * }),
+ * async.reflect(function(callback) {
+ * // do some more stuff ...
+ * callback(null, 'two');
+ * })
+ * ],
+ * // optional callback
+ * function(err, results) {
+ * // values
+ * // results[0].value = 'one'
+ * // results[1].error = 'bad stuff happened'
+ * // results[2].value = 'two'
+ * });
+ */
+function reflect(fn) {
+ var _fn = wrapAsync(fn);
+ return initialParams(function reflectOn(args, reflectCallback) {
+ args.push(function callback(error, cbArg) {
+ if (error) {
+ reflectCallback(null, { error: error });
+ } else {
+ var value;
+ if (arguments.length <= 2) {
+ value = cbArg;
+ } else {
+ value = slice(arguments, 1);
+ }
+ reflectCallback(null, { value: value });
+ }
+ });
+
+ return _fn.apply(this, args);
+ });
+}
+
+/**
+ * A helper function that wraps an array or an object of functions with `reflect`.
+ *
+ * @name reflectAll
+ * @static
+ * @memberOf module:Utils
+ * @method
+ * @see [async.reflect]{@link module:Utils.reflect}
+ * @category Util
+ * @param {Array|Object|Iterable} tasks - The collection of
+ * [async functions]{@link AsyncFunction} to wrap in `async.reflect`.
+ * @returns {Array} Returns an array of async functions, each wrapped in
+ * `async.reflect`
+ * @example
+ *
+ * let tasks = [
+ * function(callback) {
+ * setTimeout(function() {
+ * callback(null, 'one');
+ * }, 200);
+ * },
+ * function(callback) {
+ * // do some more stuff but error ...
+ * callback(new Error('bad stuff happened'));
+ * },
+ * function(callback) {
+ * setTimeout(function() {
+ * callback(null, 'two');
+ * }, 100);
+ * }
+ * ];
+ *
+ * async.parallel(async.reflectAll(tasks),
+ * // optional callback
+ * function(err, results) {
+ * // values
+ * // results[0].value = 'one'
+ * // results[1].error = Error('bad stuff happened')
+ * // results[2].value = 'two'
+ * });
+ *
+ * // an example using an object instead of an array
+ * let tasks = {
+ * one: function(callback) {
+ * setTimeout(function() {
+ * callback(null, 'one');
+ * }, 200);
+ * },
+ * two: function(callback) {
+ * callback('two');
+ * },
+ * three: function(callback) {
+ * setTimeout(function() {
+ * callback(null, 'three');
+ * }, 100);
+ * }
+ * };
+ *
+ * async.parallel(async.reflectAll(tasks),
+ * // optional callback
+ * function(err, results) {
+ * // values
+ * // results.one.value = 'one'
+ * // results.two.error = 'two'
+ * // results.three.value = 'three'
+ * });
+ */
+function reflectAll(tasks) {
+ var results;
+ if (isArray(tasks)) {
+ results = arrayMap(tasks, reflect);
+ } else {
+ results = {};
+ baseForOwn(tasks, function(task, key) {
+ results[key] = reflect.call(this, task);
+ });
+ }
+ return results;
+}
+
+function reject$1(eachfn, arr, iteratee, callback) {
+ _filter(eachfn, arr, function(value, cb) {
+ iteratee(value, function(err, v) {
+ cb(err, !v);
+ });
+ }, callback);
+}
+
+/**
+ * The opposite of [`filter`]{@link module:Collections.filter}. Removes values that pass an `async` truth test.
+ *
+ * @name reject
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.filter]{@link module:Collections.filter}
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {Function} iteratee - An async truth test to apply to each item in
+ * `coll`.
+ * The should complete with a boolean value as its `result`.
+ * Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called after all the
+ * `iteratee` functions have finished. Invoked with (err, results).
+ * @example
+ *
+ * async.reject(['file1','file2','file3'], function(filePath, callback) {
+ * fs.access(filePath, function(err) {
+ * callback(null, !err)
+ * });
+ * }, function(err, results) {
+ * // results now equals an array of missing files
+ * createFiles(results);
+ * });
+ */
+var reject = doParallel(reject$1);
+
+/**
+ * The same as [`reject`]{@link module:Collections.reject} but runs a maximum of `limit` async operations at a
+ * time.
+ *
+ * @name rejectLimit
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.reject]{@link module:Collections.reject}
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {number} limit - The maximum number of async operations at a time.
+ * @param {Function} iteratee - An async truth test to apply to each item in
+ * `coll`.
+ * The should complete with a boolean value as its `result`.
+ * Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called after all the
+ * `iteratee` functions have finished. Invoked with (err, results).
+ */
+var rejectLimit = doParallelLimit(reject$1);
+
+/**
+ * The same as [`reject`]{@link module:Collections.reject} but runs only a single async operation at a time.
+ *
+ * @name rejectSeries
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.reject]{@link module:Collections.reject}
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {Function} iteratee - An async truth test to apply to each item in
+ * `coll`.
+ * The should complete with a boolean value as its `result`.
+ * Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called after all the
+ * `iteratee` functions have finished. Invoked with (err, results).
+ */
+var rejectSeries = doLimit(rejectLimit, 1);
+
+/**
+ * Creates a function that returns `value`.
+ *
+ * @static
+ * @memberOf _
+ * @since 2.4.0
+ * @category Util
+ * @param {*} value The value to return from the new function.
+ * @returns {Function} Returns the new constant function.
+ * @example
+ *
+ * var objects = _.times(2, _.constant({ 'a': 1 }));
+ *
+ * console.log(objects);
+ * // => [{ 'a': 1 }, { 'a': 1 }]
+ *
+ * console.log(objects[0] === objects[1]);
+ * // => true
+ */
+function constant$1(value) {
+ return function() {
+ return value;
+ };
+}
+
+/**
+ * Attempts to get a successful response from `task` no more than `times` times
+ * before returning an error. If the task is successful, the `callback` will be
+ * passed the result of the successful task. If all attempts fail, the callback
+ * will be passed the error and result (if any) of the final attempt.
+ *
+ * @name retry
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @category Control Flow
+ * @see [async.retryable]{@link module:ControlFlow.retryable}
+ * @param {Object|number} [opts = {times: 5, interval: 0}| 5] - Can be either an
+ * object with `times` and `interval` or a number.
+ * * `times` - The number of attempts to make before giving up. The default
+ * is `5`.
+ * * `interval` - The time to wait between retries, in milliseconds. The
+ * default is `0`. The interval may also be specified as a function of the
+ * retry count (see example).
+ * * `errorFilter` - An optional synchronous function that is invoked on
+ * erroneous result. If it returns `true` the retry attempts will continue;
+ * if the function returns `false` the retry flow is aborted with the current
+ * attempt's error and result being returned to the final callback.
+ * Invoked with (err).
+ * * If `opts` is a number, the number specifies the number of times to retry,
+ * with the default interval of `0`.
+ * @param {AsyncFunction} task - An async function to retry.
+ * Invoked with (callback).
+ * @param {Function} [callback] - An optional callback which is called when the
+ * task has succeeded, or after the final failed attempt. It receives the `err`
+ * and `result` arguments of the last attempt at completing the `task`. Invoked
+ * with (err, results).
+ *
+ * @example
+ *
+ * // The `retry` function can be used as a stand-alone control flow by passing
+ * // a callback, as shown below:
+ *
+ * // try calling apiMethod 3 times
+ * async.retry(3, apiMethod, function(err, result) {
+ * // do something with the result
+ * });
+ *
+ * // try calling apiMethod 3 times, waiting 200 ms between each retry
+ * async.retry({times: 3, interval: 200}, apiMethod, function(err, result) {
+ * // do something with the result
+ * });
+ *
+ * // try calling apiMethod 10 times with exponential backoff
+ * // (i.e. intervals of 100, 200, 400, 800, 1600, ... milliseconds)
+ * async.retry({
+ * times: 10,
+ * interval: function(retryCount) {
+ * return 50 * Math.pow(2, retryCount);
+ * }
+ * }, apiMethod, function(err, result) {
+ * // do something with the result
+ * });
+ *
+ * // try calling apiMethod the default 5 times no delay between each retry
+ * async.retry(apiMethod, function(err, result) {
+ * // do something with the result
+ * });
+ *
+ * // try calling apiMethod only when error condition satisfies, all other
+ * // errors will abort the retry control flow and return to final callback
+ * async.retry({
+ * errorFilter: function(err) {
+ * return err.message === 'Temporary error'; // only retry on a specific error
+ * }
+ * }, apiMethod, function(err, result) {
+ * // do something with the result
+ * });
+ *
+ * // to retry individual methods that are not as reliable within other
+ * // control flow functions, use the `retryable` wrapper:
+ * async.auto({
+ * users: api.getUsers.bind(api),
+ * payments: async.retryable(3, api.getPayments.bind(api))
+ * }, function(err, results) {
+ * // do something with the results
+ * });
+ *
+ */
+function retry(opts, task, callback) {
+ var DEFAULT_TIMES = 5;
+ var DEFAULT_INTERVAL = 0;
+
+ var options = {
+ times: DEFAULT_TIMES,
+ intervalFunc: constant$1(DEFAULT_INTERVAL)
+ };
+
+ function parseTimes(acc, t) {
+ if (typeof t === 'object') {
+ acc.times = +t.times || DEFAULT_TIMES;
+
+ acc.intervalFunc = typeof t.interval === 'function' ?
+ t.interval :
+ constant$1(+t.interval || DEFAULT_INTERVAL);
+
+ acc.errorFilter = t.errorFilter;
+ } else if (typeof t === 'number' || typeof t === 'string') {
+ acc.times = +t || DEFAULT_TIMES;
+ } else {
+ throw new Error("Invalid arguments for async.retry");
+ }
+ }
+
+ if (arguments.length < 3 && typeof opts === 'function') {
+ callback = task || noop;
+ task = opts;
+ } else {
+ parseTimes(options, opts);
+ callback = callback || noop;
+ }
+
+ if (typeof task !== 'function') {
+ throw new Error("Invalid arguments for async.retry");
+ }
+
+ var _task = wrapAsync(task);
+
+ var attempt = 1;
+ function retryAttempt() {
+ _task(function(err) {
+ if (err && attempt++ < options.times &&
+ (typeof options.errorFilter != 'function' ||
+ options.errorFilter(err))) {
+ setTimeout(retryAttempt, options.intervalFunc(attempt));
+ } else {
+ callback.apply(null, arguments);
+ }
+ });
+ }
+
+ retryAttempt();
+}
+
+/**
+ * A close relative of [`retry`]{@link module:ControlFlow.retry}. This method
+ * wraps a task and makes it retryable, rather than immediately calling it
+ * with retries.
+ *
+ * @name retryable
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @see [async.retry]{@link module:ControlFlow.retry}
+ * @category Control Flow
+ * @param {Object|number} [opts = {times: 5, interval: 0}| 5] - optional
+ * options, exactly the same as from `retry`
+ * @param {AsyncFunction} task - the asynchronous function to wrap.
+ * This function will be passed any arguments passed to the returned wrapper.
+ * Invoked with (...args, callback).
+ * @returns {AsyncFunction} The wrapped function, which when invoked, will
+ * retry on an error, based on the parameters specified in `opts`.
+ * This function will accept the same parameters as `task`.
+ * @example
+ *
+ * async.auto({
+ * dep1: async.retryable(3, getFromFlakyService),
+ * process: ["dep1", async.retryable(3, function (results, cb) {
+ * maybeProcessData(results.dep1, cb);
+ * })]
+ * }, callback);
+ */
+var retryable = function (opts, task) {
+ if (!task) {
+ task = opts;
+ opts = null;
+ }
+ var _task = wrapAsync(task);
+ return initialParams(function (args, callback) {
+ function taskFn(cb) {
+ _task.apply(null, args.concat(cb));
+ }
+
+ if (opts) retry(opts, taskFn, callback);
+ else retry(taskFn, callback);
+
+ });
+};
+
+/**
+ * Run the functions in the `tasks` collection in series, each one running once
+ * the previous function has completed. If any functions in the series pass an
+ * error to its callback, no more functions are run, and `callback` is
+ * immediately called with the value of the error. Otherwise, `callback`
+ * receives an array of results when `tasks` have completed.
+ *
+ * It is also possible to use an object instead of an array. Each property will
+ * be run as a function, and the results will be passed to the final `callback`
+ * as an object instead of an array. This can be a more readable way of handling
+ * results from {@link async.series}.
+ *
+ * **Note** that while many implementations preserve the order of object
+ * properties, the [ECMAScript Language Specification](http://www.ecma-international.org/ecma-262/5.1/#sec-8.6)
+ * explicitly states that
+ *
+ * > The mechanics and order of enumerating the properties is not specified.
+ *
+ * So if you rely on the order in which your series of functions are executed,
+ * and want this to work on all platforms, consider using an array.
+ *
+ * @name series
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @category Control Flow
+ * @param {Array|Iterable|Object} tasks - A collection containing
+ * [async functions]{@link AsyncFunction} to run in series.
+ * Each function can complete with any number of optional `result` values.
+ * @param {Function} [callback] - An optional callback to run once all the
+ * functions have completed. This function gets a results array (or object)
+ * containing all the result arguments passed to the `task` callbacks. Invoked
+ * with (err, result).
+ * @example
+ * async.series([
+ * function(callback) {
+ * // do some stuff ...
+ * callback(null, 'one');
+ * },
+ * function(callback) {
+ * // do some more stuff ...
+ * callback(null, 'two');
+ * }
+ * ],
+ * // optional callback
+ * function(err, results) {
+ * // results is now equal to ['one', 'two']
+ * });
+ *
+ * async.series({
+ * one: function(callback) {
+ * setTimeout(function() {
+ * callback(null, 1);
+ * }, 200);
+ * },
+ * two: function(callback){
+ * setTimeout(function() {
+ * callback(null, 2);
+ * }, 100);
+ * }
+ * }, function(err, results) {
+ * // results is now equal to: {one: 1, two: 2}
+ * });
+ */
+function series(tasks, callback) {
+ _parallel(eachOfSeries, tasks, callback);
+}
+
+/**
+ * Returns `true` if at least one element in the `coll` satisfies an async test.
+ * If any iteratee call returns `true`, the main `callback` is immediately
+ * called.
+ *
+ * @name some
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @alias any
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {AsyncFunction} iteratee - An async truth test to apply to each item
+ * in the collections in parallel.
+ * The iteratee should complete with a boolean `result` value.
+ * Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called as soon as any
+ * iteratee returns `true`, or after all the iteratee functions have finished.
+ * Result will be either `true` or `false` depending on the values of the async
+ * tests. Invoked with (err, result).
+ * @example
+ *
+ * async.some(['file1','file2','file3'], function(filePath, callback) {
+ * fs.access(filePath, function(err) {
+ * callback(null, !err)
+ * });
+ * }, function(err, result) {
+ * // if result is true then at least one of the files exists
+ * });
+ */
+var some = doParallel(_createTester(Boolean, identity));
+
+/**
+ * The same as [`some`]{@link module:Collections.some} but runs a maximum of `limit` async operations at a time.
+ *
+ * @name someLimit
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.some]{@link module:Collections.some}
+ * @alias anyLimit
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {number} limit - The maximum number of async operations at a time.
+ * @param {AsyncFunction} iteratee - An async truth test to apply to each item
+ * in the collections in parallel.
+ * The iteratee should complete with a boolean `result` value.
+ * Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called as soon as any
+ * iteratee returns `true`, or after all the iteratee functions have finished.
+ * Result will be either `true` or `false` depending on the values of the async
+ * tests. Invoked with (err, result).
+ */
+var someLimit = doParallelLimit(_createTester(Boolean, identity));
+
+/**
+ * The same as [`some`]{@link module:Collections.some} but runs only a single async operation at a time.
+ *
+ * @name someSeries
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.some]{@link module:Collections.some}
+ * @alias anySeries
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {AsyncFunction} iteratee - An async truth test to apply to each item
+ * in the collections in series.
+ * The iteratee should complete with a boolean `result` value.
+ * Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called as soon as any
+ * iteratee returns `true`, or after all the iteratee functions have finished.
+ * Result will be either `true` or `false` depending on the values of the async
+ * tests. Invoked with (err, result).
+ */
+var someSeries = doLimit(someLimit, 1);
+
+/**
+ * Sorts a list by the results of running each `coll` value through an async
+ * `iteratee`.
+ *
+ * @name sortBy
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {AsyncFunction} iteratee - An async function to apply to each item in
+ * `coll`.
+ * The iteratee should complete with a value to use as the sort criteria as
+ * its `result`.
+ * Invoked with (item, callback).
+ * @param {Function} callback - A callback which is called after all the
+ * `iteratee` functions have finished, or an error occurs. Results is the items
+ * from the original `coll` sorted by the values returned by the `iteratee`
+ * calls. Invoked with (err, results).
+ * @example
+ *
+ * async.sortBy(['file1','file2','file3'], function(file, callback) {
+ * fs.stat(file, function(err, stats) {
+ * callback(err, stats.mtime);
+ * });
+ * }, function(err, results) {
+ * // results is now the original array of files sorted by
+ * // modified date
+ * });
+ *
+ * // By modifying the callback parameter the
+ * // sorting order can be influenced:
+ *
+ * // ascending order
+ * async.sortBy([1,9,3,5], function(x, callback) {
+ * callback(null, x);
+ * }, function(err,result) {
+ * // result callback
+ * });
+ *
+ * // descending order
+ * async.sortBy([1,9,3,5], function(x, callback) {
+ * callback(null, x*-1); //<- x*-1 instead of x, turns the order around
+ * }, function(err,result) {
+ * // result callback
+ * });
+ */
+function sortBy (coll, iteratee, callback) {
+ var _iteratee = wrapAsync(iteratee);
+ map(coll, function (x, callback) {
+ _iteratee(x, function (err, criteria) {
+ if (err) return callback(err);
+ callback(null, {value: x, criteria: criteria});
+ });
+ }, function (err, results) {
+ if (err) return callback(err);
+ callback(null, arrayMap(results.sort(comparator), baseProperty('value')));
+ });
+
+ function comparator(left, right) {
+ var a = left.criteria, b = right.criteria;
+ return a < b ? -1 : a > b ? 1 : 0;
+ }
+}
+
+/**
+ * Sets a time limit on an asynchronous function. If the function does not call
+ * its callback within the specified milliseconds, it will be called with a
+ * timeout error. The code property for the error object will be `'ETIMEDOUT'`.
+ *
+ * @name timeout
+ * @static
+ * @memberOf module:Utils
+ * @method
+ * @category Util
+ * @param {AsyncFunction} asyncFn - The async function to limit in time.
+ * @param {number} milliseconds - The specified time limit.
+ * @param {*} [info] - Any variable you want attached (`string`, `object`, etc)
+ * to timeout Error for more information..
+ * @returns {AsyncFunction} Returns a wrapped function that can be used with any
+ * of the control flow functions.
+ * Invoke this function with the same parameters as you would `asyncFunc`.
+ * @example
+ *
+ * function myFunction(foo, callback) {
+ * doAsyncTask(foo, function(err, data) {
+ * // handle errors
+ * if (err) return callback(err);
+ *
+ * // do some stuff ...
+ *
+ * // return processed data
+ * return callback(null, data);
+ * });
+ * }
+ *
+ * var wrapped = async.timeout(myFunction, 1000);
+ *
+ * // call `wrapped` as you would `myFunction`
+ * wrapped({ bar: 'bar' }, function(err, data) {
+ * // if `myFunction` takes < 1000 ms to execute, `err`
+ * // and `data` will have their expected values
+ *
+ * // else `err` will be an Error with the code 'ETIMEDOUT'
+ * });
+ */
+function timeout(asyncFn, milliseconds, info) {
+ var fn = wrapAsync(asyncFn);
+
+ return initialParams(function (args, callback) {
+ var timedOut = false;
+ var timer;
+
+ function timeoutCallback() {
+ var name = asyncFn.name || 'anonymous';
+ var error = new Error('Callback function "' + name + '" timed out.');
+ error.code = 'ETIMEDOUT';
+ if (info) {
+ error.info = info;
+ }
+ timedOut = true;
+ callback(error);
+ }
+
+ args.push(function () {
+ if (!timedOut) {
+ callback.apply(null, arguments);
+ clearTimeout(timer);
+ }
+ });
+
+ // setup timer and call original function
+ timer = setTimeout(timeoutCallback, milliseconds);
+ fn.apply(null, args);
+ });
+}
+
+/* Built-in method references for those with the same name as other `lodash` methods. */
+var nativeCeil = Math.ceil;
+var nativeMax = Math.max;
+
+/**
+ * The base implementation of `_.range` and `_.rangeRight` which doesn't
+ * coerce arguments.
+ *
+ * @private
+ * @param {number} start The start of the range.
+ * @param {number} end The end of the range.
+ * @param {number} step The value to increment or decrement by.
+ * @param {boolean} [fromRight] Specify iterating from right to left.
+ * @returns {Array} Returns the range of numbers.
+ */
+function baseRange(start, end, step, fromRight) {
+ var index = -1,
+ length = nativeMax(nativeCeil((end - start) / (step || 1)), 0),
+ result = Array(length);
+
+ while (length--) {
+ result[fromRight ? length : ++index] = start;
+ start += step;
+ }
+ return result;
+}
+
+/**
+ * The same as [times]{@link module:ControlFlow.times} but runs a maximum of `limit` async operations at a
+ * time.
+ *
+ * @name timesLimit
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @see [async.times]{@link module:ControlFlow.times}
+ * @category Control Flow
+ * @param {number} count - The number of times to run the function.
+ * @param {number} limit - The maximum number of async operations at a time.
+ * @param {AsyncFunction} iteratee - The async function to call `n` times.
+ * Invoked with the iteration index and a callback: (n, next).
+ * @param {Function} callback - see [async.map]{@link module:Collections.map}.
+ */
+function timeLimit(count, limit, iteratee, callback) {
+ var _iteratee = wrapAsync(iteratee);
+ mapLimit(baseRange(0, count, 1), limit, _iteratee, callback);
+}
+
+/**
+ * Calls the `iteratee` function `n` times, and accumulates results in the same
+ * manner you would use with [map]{@link module:Collections.map}.
+ *
+ * @name times
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @see [async.map]{@link module:Collections.map}
+ * @category Control Flow
+ * @param {number} n - The number of times to run the function.
+ * @param {AsyncFunction} iteratee - The async function to call `n` times.
+ * Invoked with the iteration index and a callback: (n, next).
+ * @param {Function} callback - see {@link module:Collections.map}.
+ * @example
+ *
+ * // Pretend this is some complicated async factory
+ * var createUser = function(id, callback) {
+ * callback(null, {
+ * id: 'user' + id
+ * });
+ * };
+ *
+ * // generate 5 users
+ * async.times(5, function(n, next) {
+ * createUser(n, function(err, user) {
+ * next(err, user);
+ * });
+ * }, function(err, users) {
+ * // we should now have 5 users
+ * });
+ */
+var times = doLimit(timeLimit, Infinity);
+
+/**
+ * The same as [times]{@link module:ControlFlow.times} but runs only a single async operation at a time.
+ *
+ * @name timesSeries
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @see [async.times]{@link module:ControlFlow.times}
+ * @category Control Flow
+ * @param {number} n - The number of times to run the function.
+ * @param {AsyncFunction} iteratee - The async function to call `n` times.
+ * Invoked with the iteration index and a callback: (n, next).
+ * @param {Function} callback - see {@link module:Collections.map}.
+ */
+var timesSeries = doLimit(timeLimit, 1);
+
+/**
+ * A relative of `reduce`. Takes an Object or Array, and iterates over each
+ * element in series, each step potentially mutating an `accumulator` value.
+ * The type of the accumulator defaults to the type of collection passed in.
+ *
+ * @name transform
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {*} [accumulator] - The initial state of the transform. If omitted,
+ * it will default to an empty Object or Array, depending on the type of `coll`
+ * @param {AsyncFunction} iteratee - A function applied to each item in the
+ * collection that potentially modifies the accumulator.
+ * Invoked with (accumulator, item, key, callback).
+ * @param {Function} [callback] - A callback which is called after all the
+ * `iteratee` functions have finished. Result is the transformed accumulator.
+ * Invoked with (err, result).
+ * @example
+ *
+ * async.transform([1,2,3], function(acc, item, index, callback) {
+ * // pointless async:
+ * process.nextTick(function() {
+ * acc.push(item * 2)
+ * callback(null)
+ * });
+ * }, function(err, result) {
+ * // result is now equal to [2, 4, 6]
+ * });
+ *
+ * @example
+ *
+ * async.transform({a: 1, b: 2, c: 3}, function (obj, val, key, callback) {
+ * setImmediate(function () {
+ * obj[key] = val * 2;
+ * callback();
+ * })
+ * }, function (err, result) {
+ * // result is equal to {a: 2, b: 4, c: 6}
+ * })
+ */
+function transform (coll, accumulator, iteratee, callback) {
+ if (arguments.length <= 3) {
+ callback = iteratee;
+ iteratee = accumulator;
+ accumulator = isArray(coll) ? [] : {};
+ }
+ callback = once(callback || noop);
+ var _iteratee = wrapAsync(iteratee);
+
+ eachOf(coll, function(v, k, cb) {
+ _iteratee(accumulator, v, k, cb);
+ }, function(err) {
+ callback(err, accumulator);
+ });
+}
+
+/**
+ * It runs each task in series but stops whenever any of the functions were
+ * successful. If one of the tasks were successful, the `callback` will be
+ * passed the result of the successful task. If all tasks fail, the callback
+ * will be passed the error and result (if any) of the final attempt.
+ *
+ * @name tryEach
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @category Control Flow
+ * @param {Array|Iterable|Object} tasks - A collection containing functions to
+ * run, each function is passed a `callback(err, result)` it must call on
+ * completion with an error `err` (which can be `null`) and an optional `result`
+ * value.
+ * @param {Function} [callback] - An optional callback which is called when one
+ * of the tasks has succeeded, or all have failed. It receives the `err` and
+ * `result` arguments of the last attempt at completing the `task`. Invoked with
+ * (err, results).
+ * @example
+ * async.tryEach([
+ * function getDataFromFirstWebsite(callback) {
+ * // Try getting the data from the first website
+ * callback(err, data);
+ * },
+ * function getDataFromSecondWebsite(callback) {
+ * // First website failed,
+ * // Try getting the data from the backup website
+ * callback(err, data);
+ * }
+ * ],
+ * // optional callback
+ * function(err, results) {
+ * Now do something with the data.
+ * });
+ *
+ */
+function tryEach(tasks, callback) {
+ var error = null;
+ var result;
+ callback = callback || noop;
+ eachSeries(tasks, function(task, callback) {
+ wrapAsync(task)(function (err, res/*, ...args*/) {
+ if (arguments.length > 2) {
+ result = slice(arguments, 1);
+ } else {
+ result = res;
+ }
+ error = err;
+ callback(!err);
+ });
+ }, function () {
+ callback(error, result);
+ });
+}
+
+/**
+ * Undoes a [memoize]{@link module:Utils.memoize}d function, reverting it to the original,
+ * unmemoized form. Handy for testing.
+ *
+ * @name unmemoize
+ * @static
+ * @memberOf module:Utils
+ * @method
+ * @see [async.memoize]{@link module:Utils.memoize}
+ * @category Util
+ * @param {AsyncFunction} fn - the memoized function
+ * @returns {AsyncFunction} a function that calls the original unmemoized function
+ */
+function unmemoize(fn) {
+ return function () {
+ return (fn.unmemoized || fn).apply(null, arguments);
+ };
+}
+
+/**
+ * Repeatedly call `iteratee`, while `test` returns `true`. Calls `callback` when
+ * stopped, or an error occurs.
+ *
+ * @name whilst
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @category Control Flow
+ * @param {Function} test - synchronous truth test to perform before each
+ * execution of `iteratee`. Invoked with ().
+ * @param {AsyncFunction} iteratee - An async function which is called each time
+ * `test` passes. Invoked with (callback).
+ * @param {Function} [callback] - A callback which is called after the test
+ * function has failed and repeated execution of `iteratee` has stopped. `callback`
+ * will be passed an error and any arguments passed to the final `iteratee`'s
+ * callback. Invoked with (err, [results]);
+ * @returns undefined
+ * @example
+ *
+ * var count = 0;
+ * async.whilst(
+ * function() { return count < 5; },
+ * function(callback) {
+ * count++;
+ * setTimeout(function() {
+ * callback(null, count);
+ * }, 1000);
+ * },
+ * function (err, n) {
+ * // 5 seconds have passed, n = 5
+ * }
+ * );
+ */
+function whilst(test, iteratee, callback) {
+ callback = onlyOnce(callback || noop);
+ var _iteratee = wrapAsync(iteratee);
+ if (!test()) return callback(null);
+ var next = function(err/*, ...args*/) {
+ if (err) return callback(err);
+ if (test()) return _iteratee(next);
+ var args = slice(arguments, 1);
+ callback.apply(null, [null].concat(args));
+ };
+ _iteratee(next);
+}
+
+/**
+ * Repeatedly call `iteratee` until `test` returns `true`. Calls `callback` when
+ * stopped, or an error occurs. `callback` will be passed an error and any
+ * arguments passed to the final `iteratee`'s callback.
+ *
+ * The inverse of [whilst]{@link module:ControlFlow.whilst}.
+ *
+ * @name until
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @see [async.whilst]{@link module:ControlFlow.whilst}
+ * @category Control Flow
+ * @param {Function} test - synchronous truth test to perform before each
+ * execution of `iteratee`. Invoked with ().
+ * @param {AsyncFunction} iteratee - An async function which is called each time
+ * `test` fails. Invoked with (callback).
+ * @param {Function} [callback] - A callback which is called after the test
+ * function has passed and repeated execution of `iteratee` has stopped. `callback`
+ * will be passed an error and any arguments passed to the final `iteratee`'s
+ * callback. Invoked with (err, [results]);
+ */
+function until(test, iteratee, callback) {
+ whilst(function() {
+ return !test.apply(this, arguments);
+ }, iteratee, callback);
+}
+
+/**
+ * Runs the `tasks` array of functions in series, each passing their results to
+ * the next in the array. However, if any of the `tasks` pass an error to their
+ * own callback, the next function is not executed, and the main `callback` is
+ * immediately called with the error.
+ *
+ * @name waterfall
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @category Control Flow
+ * @param {Array} tasks - An array of [async functions]{@link AsyncFunction}
+ * to run.
+ * Each function should complete with any number of `result` values.
+ * The `result` values will be passed as arguments, in order, to the next task.
+ * @param {Function} [callback] - An optional callback to run once all the
+ * functions have completed. This will be passed the results of the last task's
+ * callback. Invoked with (err, [results]).
+ * @returns undefined
+ * @example
+ *
+ * async.waterfall([
+ * function(callback) {
+ * callback(null, 'one', 'two');
+ * },
+ * function(arg1, arg2, callback) {
+ * // arg1 now equals 'one' and arg2 now equals 'two'
+ * callback(null, 'three');
+ * },
+ * function(arg1, callback) {
+ * // arg1 now equals 'three'
+ * callback(null, 'done');
+ * }
+ * ], function (err, result) {
+ * // result now equals 'done'
+ * });
+ *
+ * // Or, with named functions:
+ * async.waterfall([
+ * myFirstFunction,
+ * mySecondFunction,
+ * myLastFunction,
+ * ], function (err, result) {
+ * // result now equals 'done'
+ * });
+ * function myFirstFunction(callback) {
+ * callback(null, 'one', 'two');
+ * }
+ * function mySecondFunction(arg1, arg2, callback) {
+ * // arg1 now equals 'one' and arg2 now equals 'two'
+ * callback(null, 'three');
+ * }
+ * function myLastFunction(arg1, callback) {
+ * // arg1 now equals 'three'
+ * callback(null, 'done');
+ * }
+ */
+var waterfall = function(tasks, callback) {
+ callback = once(callback || noop);
+ if (!isArray(tasks)) return callback(new Error('First argument to waterfall must be an array of functions'));
+ if (!tasks.length) return callback();
+ var taskIndex = 0;
+
+ function nextTask(args) {
+ var task = wrapAsync(tasks[taskIndex++]);
+ args.push(onlyOnce(next));
+ task.apply(null, args);
+ }
+
+ function next(err/*, ...args*/) {
+ if (err || taskIndex === tasks.length) {
+ return callback.apply(null, arguments);
+ }
+ nextTask(slice(arguments, 1));
+ }
+
+ nextTask([]);
+};
+
+/**
+ * An "async function" in the context of Async is an asynchronous function with
+ * a variable number of parameters, with the final parameter being a callback.
+ * (`function (arg1, arg2, ..., callback) {}`)
+ * The final callback is of the form `callback(err, results...)`, which must be
+ * called once the function is completed. The callback should be called with a
+ * Error as its first argument to signal that an error occurred.
+ * Otherwise, if no error occurred, it should be called with `null` as the first
+ * argument, and any additional `result` arguments that may apply, to signal
+ * successful completion.
+ * The callback must be called exactly once, ideally on a later tick of the
+ * JavaScript event loop.
+ *
+ * This type of function is also referred to as a "Node-style async function",
+ * or a "continuation passing-style function" (CPS). Most of the methods of this
+ * library are themselves CPS/Node-style async functions, or functions that
+ * return CPS/Node-style async functions.
+ *
+ * Wherever we accept a Node-style async function, we also directly accept an
+ * [ES2017 `async` function]{@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function}.
+ * In this case, the `async` function will not be passed a final callback
+ * argument, and any thrown error will be used as the `err` argument of the
+ * implicit callback, and the return value will be used as the `result` value.
+ * (i.e. a `rejected` of the returned Promise becomes the `err` callback
+ * argument, and a `resolved` value becomes the `result`.)
+ *
+ * Note, due to JavaScript limitations, we can only detect native `async`
+ * functions and not transpilied implementations.
+ * Your environment must have `async`/`await` support for this to work.
+ * (e.g. Node > v7.6, or a recent version of a modern browser).
+ * If you are using `async` functions through a transpiler (e.g. Babel), you
+ * must still wrap the function with [asyncify]{@link module:Utils.asyncify},
+ * because the `async function` will be compiled to an ordinary function that
+ * returns a promise.
+ *
+ * @typedef {Function} AsyncFunction
+ * @static
+ */
+
+/**
+ * Async is a utility module which provides straight-forward, powerful functions
+ * for working with asynchronous JavaScript. Although originally designed for
+ * use with [Node.js](http://nodejs.org) and installable via
+ * `npm install --save async`, it can also be used directly in the browser.
+ * @module async
+ * @see AsyncFunction
+ */
+
+
+/**
+ * A collection of `async` functions for manipulating collections, such as
+ * arrays and objects.
+ * @module Collections
+ */
+
+/**
+ * A collection of `async` functions for controlling the flow through a script.
+ * @module ControlFlow
+ */
+
+/**
+ * A collection of `async` utility functions.
+ * @module Utils
+ */
+
+var index = {
+ apply: apply,
+ applyEach: applyEach,
+ applyEachSeries: applyEachSeries,
+ asyncify: asyncify,
+ auto: auto,
+ autoInject: autoInject,
+ cargo: cargo,
+ compose: compose,
+ concat: concat,
+ concatLimit: concatLimit,
+ concatSeries: concatSeries,
+ constant: constant,
+ detect: detect,
+ detectLimit: detectLimit,
+ detectSeries: detectSeries,
+ dir: dir,
+ doDuring: doDuring,
+ doUntil: doUntil,
+ doWhilst: doWhilst,
+ during: during,
+ each: eachLimit,
+ eachLimit: eachLimit$1,
+ eachOf: eachOf,
+ eachOfLimit: eachOfLimit,
+ eachOfSeries: eachOfSeries,
+ eachSeries: eachSeries,
+ ensureAsync: ensureAsync,
+ every: every,
+ everyLimit: everyLimit,
+ everySeries: everySeries,
+ filter: filter,
+ filterLimit: filterLimit,
+ filterSeries: filterSeries,
+ forever: forever,
+ groupBy: groupBy,
+ groupByLimit: groupByLimit,
+ groupBySeries: groupBySeries,
+ log: log,
+ map: map,
+ mapLimit: mapLimit,
+ mapSeries: mapSeries,
+ mapValues: mapValues,
+ mapValuesLimit: mapValuesLimit,
+ mapValuesSeries: mapValuesSeries,
+ memoize: memoize,
+ nextTick: nextTick,
+ parallel: parallelLimit,
+ parallelLimit: parallelLimit$1,
+ priorityQueue: priorityQueue,
+ queue: queue$1,
+ race: race,
+ reduce: reduce,
+ reduceRight: reduceRight,
+ reflect: reflect,
+ reflectAll: reflectAll,
+ reject: reject,
+ rejectLimit: rejectLimit,
+ rejectSeries: rejectSeries,
+ retry: retry,
+ retryable: retryable,
+ seq: seq,
+ series: series,
+ setImmediate: setImmediate$1,
+ some: some,
+ someLimit: someLimit,
+ someSeries: someSeries,
+ sortBy: sortBy,
+ timeout: timeout,
+ times: times,
+ timesLimit: timeLimit,
+ timesSeries: timesSeries,
+ transform: transform,
+ tryEach: tryEach,
+ unmemoize: unmemoize,
+ until: until,
+ waterfall: waterfall,
+ whilst: whilst,
+
+ // aliases
+ all: every,
+ allLimit: everyLimit,
+ allSeries: everySeries,
+ any: some,
+ anyLimit: someLimit,
+ anySeries: someSeries,
+ find: detect,
+ findLimit: detectLimit,
+ findSeries: detectSeries,
+ forEach: eachLimit,
+ forEachSeries: eachSeries,
+ forEachLimit: eachLimit$1,
+ forEachOf: eachOf,
+ forEachOfSeries: eachOfSeries,
+ forEachOfLimit: eachOfLimit,
+ inject: reduce,
+ foldl: reduce,
+ foldr: reduceRight,
+ select: filter,
+ selectLimit: filterLimit,
+ selectSeries: filterSeries,
+ wrapSync: asyncify
+};
+
+exports['default'] = index;
+exports.apply = apply;
+exports.applyEach = applyEach;
+exports.applyEachSeries = applyEachSeries;
+exports.asyncify = asyncify;
+exports.auto = auto;
+exports.autoInject = autoInject;
+exports.cargo = cargo;
+exports.compose = compose;
+exports.concat = concat;
+exports.concatLimit = concatLimit;
+exports.concatSeries = concatSeries;
+exports.constant = constant;
+exports.detect = detect;
+exports.detectLimit = detectLimit;
+exports.detectSeries = detectSeries;
+exports.dir = dir;
+exports.doDuring = doDuring;
+exports.doUntil = doUntil;
+exports.doWhilst = doWhilst;
+exports.during = during;
+exports.each = eachLimit;
+exports.eachLimit = eachLimit$1;
+exports.eachOf = eachOf;
+exports.eachOfLimit = eachOfLimit;
+exports.eachOfSeries = eachOfSeries;
+exports.eachSeries = eachSeries;
+exports.ensureAsync = ensureAsync;
+exports.every = every;
+exports.everyLimit = everyLimit;
+exports.everySeries = everySeries;
+exports.filter = filter;
+exports.filterLimit = filterLimit;
+exports.filterSeries = filterSeries;
+exports.forever = forever;
+exports.groupBy = groupBy;
+exports.groupByLimit = groupByLimit;
+exports.groupBySeries = groupBySeries;
+exports.log = log;
+exports.map = map;
+exports.mapLimit = mapLimit;
+exports.mapSeries = mapSeries;
+exports.mapValues = mapValues;
+exports.mapValuesLimit = mapValuesLimit;
+exports.mapValuesSeries = mapValuesSeries;
+exports.memoize = memoize;
+exports.nextTick = nextTick;
+exports.parallel = parallelLimit;
+exports.parallelLimit = parallelLimit$1;
+exports.priorityQueue = priorityQueue;
+exports.queue = queue$1;
+exports.race = race;
+exports.reduce = reduce;
+exports.reduceRight = reduceRight;
+exports.reflect = reflect;
+exports.reflectAll = reflectAll;
+exports.reject = reject;
+exports.rejectLimit = rejectLimit;
+exports.rejectSeries = rejectSeries;
+exports.retry = retry;
+exports.retryable = retryable;
+exports.seq = seq;
+exports.series = series;
+exports.setImmediate = setImmediate$1;
+exports.some = some;
+exports.someLimit = someLimit;
+exports.someSeries = someSeries;
+exports.sortBy = sortBy;
+exports.timeout = timeout;
+exports.times = times;
+exports.timesLimit = timeLimit;
+exports.timesSeries = timesSeries;
+exports.transform = transform;
+exports.tryEach = tryEach;
+exports.unmemoize = unmemoize;
+exports.until = until;
+exports.waterfall = waterfall;
+exports.whilst = whilst;
+exports.all = every;
+exports.allLimit = everyLimit;
+exports.allSeries = everySeries;
+exports.any = some;
+exports.anyLimit = someLimit;
+exports.anySeries = someSeries;
+exports.find = detect;
+exports.findLimit = detectLimit;
+exports.findSeries = detectSeries;
+exports.forEach = eachLimit;
+exports.forEachSeries = eachSeries;
+exports.forEachLimit = eachLimit$1;
+exports.forEachOf = eachOf;
+exports.forEachOfSeries = eachOfSeries;
+exports.forEachOfLimit = eachOfLimit;
+exports.inject = reduce;
+exports.foldl = reduce;
+exports.foldr = reduceRight;
+exports.select = filter;
+exports.selectLimit = filterLimit;
+exports.selectSeries = filterSeries;
+exports.wrapSync = asyncify;
+
+Object.defineProperty(exports, '__esModule', { value: true });
+
+})));
diff --git a/node_modules/@pm2/js-api/node_modules/async/dist/async.min.js b/node_modules/@pm2/js-api/node_modules/async/dist/async.min.js
new file mode 100644
index 0000000..0b9e113
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/async/dist/async.min.js
@@ -0,0 +1,2 @@
+!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(n.async=n.async||{})}(this,function(n){"use strict";function t(n,t){t|=0;for(var e=Math.max(n.length-t,0),r=Array(e),u=0;u-1&&n%1==0&&n<=Tt}function d(n){return null!=n&&v(n.length)&&!y(n)}function m(){}function g(n){return function(){if(null!==n){var t=n;n=null,t.apply(this,arguments)}}}function b(n,t){for(var e=-1,r=Array(n);++e-1&&n%1==0&&nu?0:u+t),e=e>u?u:e,e<0&&(e+=u),u=t>e?0:e-t>>>0,t>>>=0;for(var i=Array(u);++r=r?n:Z(n,t,e)}function tn(n,t){for(var e=n.length;e--&&J(t,n[e],0)>-1;);return e}function en(n,t){for(var e=-1,r=n.length;++e-1;);return e}function rn(n){return n.split("")}function un(n){return Xe.test(n)}function on(n){return n.match(mr)||[]}function cn(n){return un(n)?on(n):rn(n)}function fn(n){return null==n?"":Y(n)}function an(n,t,e){if(n=fn(n),n&&(e||void 0===t))return n.replace(gr,"");if(!n||!(t=Y(t)))return n;var r=cn(n),u=cn(t),i=en(r,u),o=tn(r,u)+1;return nn(r,i,o).join("")}function ln(n){return n=n.toString().replace(kr,""),n=n.match(br)[2].replace(" ",""),n=n?n.split(jr):[],n=n.map(function(n){return an(n.replace(Sr,""))})}function sn(n,t){var e={};N(n,function(n,t){function r(t,e){var r=K(u,function(n){return t[n]});r.push(e),a(n).apply(null,r)}var u,i=f(n),o=!i&&1===n.length||i&&0===n.length;if(Pt(n))u=n.slice(0,-1),n=n[n.length-1],e[t]=u.concat(u.length>0?r:n);else if(o)e[t]=n;else{if(u=ln(n),0===n.length&&!i&&0===u.length)throw new Error("autoInject task functions require explicit parameters.");i||u.pop(),e[t]=u.concat(r)}}),Ve(e,t)}function pn(){this.head=this.tail=null,this.length=0}function hn(n,t){n.length=1,n.head=n.tail=t}function yn(n,t,e){function r(n,t,e){if(null!=e&&"function"!=typeof e)throw new Error("task callback must be a function");if(s.started=!0,Pt(n)||(n=[n]),0===n.length&&s.idle())return lt(function(){s.drain()});for(var r=0,u=n.length;r0&&c.splice(i,1),u.callback.apply(u,arguments),null!=t&&s.error(t,u.data)}o<=s.concurrency-s.buffer&&s.unsaturated(),s.idle()&&s.drain(),s.process()}}if(null==t)t=1;else if(0===t)throw new Error("Concurrency must not be zero");var i=a(n),o=0,c=[],f=!1,l=!1,s={_tasks:new pn,concurrency:t,payload:e,saturated:m,unsaturated:m,buffer:t/4,empty:m,drain:m,error:m,started:!1,paused:!1,push:function(n,t){r(n,!1,t)},kill:function(){s.drain=m,s._tasks.empty()},unshift:function(n,t){r(n,!0,t)},remove:function(n){s._tasks.remove(n)},process:function(){if(!l){for(l=!0;!s.paused&&o2&&(i=t(arguments,1)),u[e]=i,r(n)})},function(n){r(n,u)})}function Dn(n,t){Vn(Fe,n,t)}function Rn(n,t,e){Vn(q(t),n,e)}function Cn(n,t){if(t=g(t||m),!Pt(n))return t(new TypeError("First argument to race must be an array of functions"));if(!n.length)return t();for(var e=0,r=n.length;er?1:0}var u=a(t);Ie(n,function(n,t){u(n,function(e,r){return e?t(e):void t(null,{value:n,criteria:r})})},function(n,t){return n?e(n):void e(null,K(t.sort(r),Bn("value")))})}function Xn(n,t,e){var r=a(n);return ct(function(u,i){function o(){var t=n.name||"anonymous",r=new Error('Callback function "'+t+'" timed out.');r.code="ETIMEDOUT",e&&(r.info=e),f=!0,i(r)}var c,f=!1;u.push(function(){f||(i.apply(null,arguments),clearTimeout(c))}),c=setTimeout(o,t),r.apply(null,u)})}function Yn(n,t,e,r){for(var u=-1,i=iu(uu((t-n)/(e||1)),0),o=Array(i);i--;)o[r?i:++u]=n,n+=e;return o}function Zn(n,t,e,r){var u=a(e);Ue(Yn(0,n,1),t,u,r)}function nt(n,t,e,r){arguments.length<=3&&(r=e,e=t,t=Pt(n)?[]:{}),r=g(r||m);var u=a(e);Fe(n,function(n,e,r){u(t,n,e,r)},function(n){r(n,t)})}function tt(n,e){var r,u=null;e=e||m,Ur(n,function(n,e){a(n)(function(n,i){r=arguments.length>2?t(arguments,1):i,u=n,e(!n)})},function(){e(u,r)})}function et(n){return function(){return(n.unmemoized||n).apply(null,arguments)}}function rt(n,e,r){r=U(r||m);var u=a(e);if(!n())return r(null);var i=function(e){if(e)return r(e);if(n())return u(i);var o=t(arguments,1);r.apply(null,[null].concat(o))};u(i)}function ut(n,t,e){rt(function(){return!n.apply(this,arguments)},t,e)}var it,ot=function(n){var e=t(arguments,1);return function(){var r=t(arguments);return n.apply(null,e.concat(r))}},ct=function(n){return function(){var e=t(arguments),r=e.pop();n.call(this,e,r)}},ft="function"==typeof setImmediate&&setImmediate,at="object"==typeof process&&"function"==typeof process.nextTick;it=ft?setImmediate:at?process.nextTick:r;var lt=u(it),st="function"==typeof Symbol,pt="object"==typeof global&&global&&global.Object===Object&&global,ht="object"==typeof self&&self&&self.Object===Object&&self,yt=pt||ht||Function("return this")(),vt=yt.Symbol,dt=Object.prototype,mt=dt.hasOwnProperty,gt=dt.toString,bt=vt?vt.toStringTag:void 0,jt=Object.prototype,St=jt.toString,kt="[object Null]",Lt="[object Undefined]",Ot=vt?vt.toStringTag:void 0,wt="[object AsyncFunction]",xt="[object Function]",Et="[object GeneratorFunction]",At="[object Proxy]",Tt=9007199254740991,_t={},Bt="function"==typeof Symbol&&Symbol.iterator,Ft=function(n){return Bt&&n[Bt]&&n[Bt]()},It="[object Arguments]",Mt=Object.prototype,Ut=Mt.hasOwnProperty,qt=Mt.propertyIsEnumerable,zt=S(function(){return arguments}())?S:function(n){return j(n)&&Ut.call(n,"callee")&&!qt.call(n,"callee")},Pt=Array.isArray,Vt="object"==typeof n&&n&&!n.nodeType&&n,Dt=Vt&&"object"==typeof module&&module&&!module.nodeType&&module,Rt=Dt&&Dt.exports===Vt,Ct=Rt?yt.Buffer:void 0,$t=Ct?Ct.isBuffer:void 0,Wt=$t||k,Nt=9007199254740991,Qt=/^(?:0|[1-9]\d*)$/,Gt="[object Arguments]",Ht="[object Array]",Jt="[object Boolean]",Kt="[object Date]",Xt="[object Error]",Yt="[object Function]",Zt="[object Map]",ne="[object Number]",te="[object Object]",ee="[object RegExp]",re="[object Set]",ue="[object String]",ie="[object WeakMap]",oe="[object ArrayBuffer]",ce="[object DataView]",fe="[object Float32Array]",ae="[object Float64Array]",le="[object Int8Array]",se="[object Int16Array]",pe="[object Int32Array]",he="[object Uint8Array]",ye="[object Uint8ClampedArray]",ve="[object Uint16Array]",de="[object Uint32Array]",me={};me[fe]=me[ae]=me[le]=me[se]=me[pe]=me[he]=me[ye]=me[ve]=me[de]=!0,me[Gt]=me[Ht]=me[oe]=me[Jt]=me[ce]=me[Kt]=me[Xt]=me[Yt]=me[Zt]=me[ne]=me[te]=me[ee]=me[re]=me[ue]=me[ie]=!1;var ge="object"==typeof n&&n&&!n.nodeType&&n,be=ge&&"object"==typeof module&&module&&!module.nodeType&&module,je=be&&be.exports===ge,Se=je&&pt.process,ke=function(){try{var n=be&&be.require&&be.require("util").types;return n?n:Se&&Se.binding&&Se.binding("util")}catch(n){}}(),Le=ke&&ke.isTypedArray,Oe=Le?w(Le):O,we=Object.prototype,xe=we.hasOwnProperty,Ee=Object.prototype,Ae=A(Object.keys,Object),Te=Object.prototype,_e=Te.hasOwnProperty,Be=P(z,1/0),Fe=function(n,t,e){var r=d(n)?V:Be;r(n,a(t),e)},Ie=D(R),Me=l(Ie),Ue=C(R),qe=P(Ue,1),ze=l(qe),Pe=W(),Ve=function(n,e,r){function u(n,t){j.push(function(){f(n,t)})}function i(){if(0===j.length&&0===v)return r(null,y);for(;j.length&&v2&&(u=t(arguments,1)),e){var i={};N(y,function(n,t){i[t]=n}),i[n]=u,d=!0,b=Object.create(null),r(e,i)}else y[n]=u,c(n)});v++;var i=a(e[e.length-1]);e.length>1?i(y,u):i(u)}}function l(){for(var n,t=0;S.length;)n=S.pop(),t++,$(s(n),function(n){0===--k[n]&&S.push(n)});if(t!==h)throw new Error("async.auto cannot execute tasks due to a recursive dependency")}function s(t){var e=[];return N(n,function(n,r){Pt(n)&&J(n,t,0)>=0&&e.push(r)}),e}"function"==typeof e&&(r=e,e=null),r=g(r||m);var p=_(n),h=p.length;if(!h)return r(null);e||(e=h);var y={},v=0,d=!1,b=Object.create(null),j=[],S=[],k={};N(n,function(t,e){if(!Pt(t))return u(e,[t]),void S.push(e);var r=t.slice(0,t.length-1),i=r.length;return 0===i?(u(e,t),void S.push(e)):(k[e]=i,void $(r,function(c){if(!n[c])throw new Error("async.auto task `"+e+"` has a non-existent dependency `"+c+"` in "+r.join(", "));o(c,function(){i--,0===i&&u(e,t)})}))}),l(),i()},De="[object Symbol]",Re=1/0,Ce=vt?vt.prototype:void 0,$e=Ce?Ce.toString:void 0,We="\\ud800-\\udfff",Ne="\\u0300-\\u036f",Qe="\\ufe20-\\ufe2f",Ge="\\u20d0-\\u20ff",He=Ne+Qe+Ge,Je="\\ufe0e\\ufe0f",Ke="\\u200d",Xe=RegExp("["+Ke+We+He+Je+"]"),Ye="\\ud800-\\udfff",Ze="\\u0300-\\u036f",nr="\\ufe20-\\ufe2f",tr="\\u20d0-\\u20ff",er=Ze+nr+tr,rr="\\ufe0e\\ufe0f",ur="["+Ye+"]",ir="["+er+"]",or="\\ud83c[\\udffb-\\udfff]",cr="(?:"+ir+"|"+or+")",fr="[^"+Ye+"]",ar="(?:\\ud83c[\\udde6-\\uddff]){2}",lr="[\\ud800-\\udbff][\\udc00-\\udfff]",sr="\\u200d",pr=cr+"?",hr="["+rr+"]?",yr="(?:"+sr+"(?:"+[fr,ar,lr].join("|")+")"+hr+pr+")*",vr=hr+pr+yr,dr="(?:"+[fr+ir+"?",ir,ar,lr,ur].join("|")+")",mr=RegExp(or+"(?="+or+")|"+dr+vr,"g"),gr=/^\s+|\s+$/g,br=/^(?:async\s+)?(function)?\s*[^\(]*\(\s*([^\)]*)\)/m,jr=/,/,Sr=/(=.+)?(\s*)$/,kr=/((\/\/.*$)|(\/\*[\s\S]*?\*\/))/gm;pn.prototype.removeLink=function(n){return n.prev?n.prev.next=n.next:this.head=n.next,n.next?n.next.prev=n.prev:this.tail=n.prev,n.prev=n.next=null,this.length-=1,n},pn.prototype.empty=function(){for(;this.head;)this.shift();return this},pn.prototype.insertAfter=function(n,t){t.prev=n,t.next=n.next,n.next?n.next.prev=t:this.tail=t,n.next=t,this.length+=1},pn.prototype.insertBefore=function(n,t){t.prev=n.prev,t.next=n,n.prev?n.prev.next=t:this.head=t,n.prev=t,this.length+=1},pn.prototype.unshift=function(n){this.head?this.insertBefore(this.head,n):hn(this,n)},pn.prototype.push=function(n){this.tail?this.insertAfter(this.tail,n):hn(this,n)},pn.prototype.shift=function(){return this.head&&this.removeLink(this.head)},pn.prototype.pop=function(){return this.tail&&this.removeLink(this.tail)},pn.prototype.toArray=function(){for(var n=Array(this.length),t=this.head,e=0;e=u.priority;)u=u.next;for(var i=0,o=n.length;i 32 ) {
+ * console.log('This file name is too long');
+ * callback('File name too long');
+ * } else {
+ * // Do work to process file here
+ * console.log('File processed');
+ * callback();
+ * }
+ * }, function(err) {
+ * // if any of the file processing produced an error, err would equal that error
+ * if( err ) {
+ * // One of the iterations produced an error.
+ * // All processing will now stop.
+ * console.log('A file failed to process');
+ * } else {
+ * console.log('All files have been processed successfully');
+ * }
+ * });
+ */
+function eachLimit(coll, iteratee, callback) {
+ (0, _eachOf2.default)(coll, (0, _withoutIndex2.default)((0, _wrapAsync2.default)(iteratee)), callback);
+}
+module.exports = exports['default'];
\ No newline at end of file
diff --git a/node_modules/@pm2/js-api/node_modules/async/eachLimit.js b/node_modules/@pm2/js-api/node_modules/async/eachLimit.js
new file mode 100644
index 0000000..fff721b
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/async/eachLimit.js
@@ -0,0 +1,45 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = eachLimit;
+
+var _eachOfLimit = require('./internal/eachOfLimit');
+
+var _eachOfLimit2 = _interopRequireDefault(_eachOfLimit);
+
+var _withoutIndex = require('./internal/withoutIndex');
+
+var _withoutIndex2 = _interopRequireDefault(_withoutIndex);
+
+var _wrapAsync = require('./internal/wrapAsync');
+
+var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * The same as [`each`]{@link module:Collections.each} but runs a maximum of `limit` async operations at a time.
+ *
+ * @name eachLimit
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.each]{@link module:Collections.each}
+ * @alias forEachLimit
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {number} limit - The maximum number of async operations at a time.
+ * @param {AsyncFunction} iteratee - An async function to apply to each item in
+ * `coll`.
+ * The array index is not passed to the iteratee.
+ * If you need the index, use `eachOfLimit`.
+ * Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called when all
+ * `iteratee` functions have finished, or an error occurs. Invoked with (err).
+ */
+function eachLimit(coll, limit, iteratee, callback) {
+ (0, _eachOfLimit2.default)(limit)(coll, (0, _withoutIndex2.default)((0, _wrapAsync2.default)(iteratee)), callback);
+}
+module.exports = exports['default'];
\ No newline at end of file
diff --git a/node_modules/@pm2/js-api/node_modules/async/eachOf.js b/node_modules/@pm2/js-api/node_modules/async/eachOf.js
new file mode 100644
index 0000000..055b9bd
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/async/eachOf.js
@@ -0,0 +1,111 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+exports.default = function (coll, iteratee, callback) {
+ var eachOfImplementation = (0, _isArrayLike2.default)(coll) ? eachOfArrayLike : eachOfGeneric;
+ eachOfImplementation(coll, (0, _wrapAsync2.default)(iteratee), callback);
+};
+
+var _isArrayLike = require('lodash/isArrayLike');
+
+var _isArrayLike2 = _interopRequireDefault(_isArrayLike);
+
+var _breakLoop = require('./internal/breakLoop');
+
+var _breakLoop2 = _interopRequireDefault(_breakLoop);
+
+var _eachOfLimit = require('./eachOfLimit');
+
+var _eachOfLimit2 = _interopRequireDefault(_eachOfLimit);
+
+var _doLimit = require('./internal/doLimit');
+
+var _doLimit2 = _interopRequireDefault(_doLimit);
+
+var _noop = require('lodash/noop');
+
+var _noop2 = _interopRequireDefault(_noop);
+
+var _once = require('./internal/once');
+
+var _once2 = _interopRequireDefault(_once);
+
+var _onlyOnce = require('./internal/onlyOnce');
+
+var _onlyOnce2 = _interopRequireDefault(_onlyOnce);
+
+var _wrapAsync = require('./internal/wrapAsync');
+
+var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+// eachOf implementation optimized for array-likes
+function eachOfArrayLike(coll, iteratee, callback) {
+ callback = (0, _once2.default)(callback || _noop2.default);
+ var index = 0,
+ completed = 0,
+ length = coll.length;
+ if (length === 0) {
+ callback(null);
+ }
+
+ function iteratorCallback(err, value) {
+ if (err) {
+ callback(err);
+ } else if (++completed === length || value === _breakLoop2.default) {
+ callback(null);
+ }
+ }
+
+ for (; index < length; index++) {
+ iteratee(coll[index], index, (0, _onlyOnce2.default)(iteratorCallback));
+ }
+}
+
+// a generic version of eachOf which can handle array, object, and iterator cases.
+var eachOfGeneric = (0, _doLimit2.default)(_eachOfLimit2.default, Infinity);
+
+/**
+ * Like [`each`]{@link module:Collections.each}, except that it passes the key (or index) as the second argument
+ * to the iteratee.
+ *
+ * @name eachOf
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @alias forEachOf
+ * @category Collection
+ * @see [async.each]{@link module:Collections.each}
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {AsyncFunction} iteratee - A function to apply to each
+ * item in `coll`.
+ * The `key` is the item's key, or index in the case of an array.
+ * Invoked with (item, key, callback).
+ * @param {Function} [callback] - A callback which is called when all
+ * `iteratee` functions have finished, or an error occurs. Invoked with (err).
+ * @example
+ *
+ * var obj = {dev: "/dev.json", test: "/test.json", prod: "/prod.json"};
+ * var configs = {};
+ *
+ * async.forEachOf(obj, function (value, key, callback) {
+ * fs.readFile(__dirname + value, "utf8", function (err, data) {
+ * if (err) return callback(err);
+ * try {
+ * configs[key] = JSON.parse(data);
+ * } catch (e) {
+ * return callback(e);
+ * }
+ * callback();
+ * });
+ * }, function (err) {
+ * if (err) console.error(err.message);
+ * // configs is now a map of JSON data
+ * doSomethingWith(configs);
+ * });
+ */
+module.exports = exports['default'];
\ No newline at end of file
diff --git a/node_modules/@pm2/js-api/node_modules/async/eachOfLimit.js b/node_modules/@pm2/js-api/node_modules/async/eachOfLimit.js
new file mode 100644
index 0000000..30a1329
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/async/eachOfLimit.js
@@ -0,0 +1,41 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = eachOfLimit;
+
+var _eachOfLimit2 = require('./internal/eachOfLimit');
+
+var _eachOfLimit3 = _interopRequireDefault(_eachOfLimit2);
+
+var _wrapAsync = require('./internal/wrapAsync');
+
+var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * The same as [`eachOf`]{@link module:Collections.eachOf} but runs a maximum of `limit` async operations at a
+ * time.
+ *
+ * @name eachOfLimit
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.eachOf]{@link module:Collections.eachOf}
+ * @alias forEachOfLimit
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {number} limit - The maximum number of async operations at a time.
+ * @param {AsyncFunction} iteratee - An async function to apply to each
+ * item in `coll`. The `key` is the item's key, or index in the case of an
+ * array.
+ * Invoked with (item, key, callback).
+ * @param {Function} [callback] - A callback which is called when all
+ * `iteratee` functions have finished, or an error occurs. Invoked with (err).
+ */
+function eachOfLimit(coll, limit, iteratee, callback) {
+ (0, _eachOfLimit3.default)(limit)(coll, (0, _wrapAsync2.default)(iteratee), callback);
+}
+module.exports = exports['default'];
\ No newline at end of file
diff --git a/node_modules/@pm2/js-api/node_modules/async/eachOfSeries.js b/node_modules/@pm2/js-api/node_modules/async/eachOfSeries.js
new file mode 100644
index 0000000..9dfd711
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/async/eachOfSeries.js
@@ -0,0 +1,35 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+var _eachOfLimit = require('./eachOfLimit');
+
+var _eachOfLimit2 = _interopRequireDefault(_eachOfLimit);
+
+var _doLimit = require('./internal/doLimit');
+
+var _doLimit2 = _interopRequireDefault(_doLimit);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * The same as [`eachOf`]{@link module:Collections.eachOf} but runs only a single async operation at a time.
+ *
+ * @name eachOfSeries
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.eachOf]{@link module:Collections.eachOf}
+ * @alias forEachOfSeries
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {AsyncFunction} iteratee - An async function to apply to each item in
+ * `coll`.
+ * Invoked with (item, key, callback).
+ * @param {Function} [callback] - A callback which is called when all `iteratee`
+ * functions have finished, or an error occurs. Invoked with (err).
+ */
+exports.default = (0, _doLimit2.default)(_eachOfLimit2.default, 1);
+module.exports = exports['default'];
\ No newline at end of file
diff --git a/node_modules/@pm2/js-api/node_modules/async/eachSeries.js b/node_modules/@pm2/js-api/node_modules/async/eachSeries.js
new file mode 100644
index 0000000..55c7840
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/async/eachSeries.js
@@ -0,0 +1,37 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+var _eachLimit = require('./eachLimit');
+
+var _eachLimit2 = _interopRequireDefault(_eachLimit);
+
+var _doLimit = require('./internal/doLimit');
+
+var _doLimit2 = _interopRequireDefault(_doLimit);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * The same as [`each`]{@link module:Collections.each} but runs only a single async operation at a time.
+ *
+ * @name eachSeries
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.each]{@link module:Collections.each}
+ * @alias forEachSeries
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {AsyncFunction} iteratee - An async function to apply to each
+ * item in `coll`.
+ * The array index is not passed to the iteratee.
+ * If you need the index, use `eachOfSeries`.
+ * Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called when all
+ * `iteratee` functions have finished, or an error occurs. Invoked with (err).
+ */
+exports.default = (0, _doLimit2.default)(_eachLimit2.default, 1);
+module.exports = exports['default'];
\ No newline at end of file
diff --git a/node_modules/@pm2/js-api/node_modules/async/ensureAsync.js b/node_modules/@pm2/js-api/node_modules/async/ensureAsync.js
new file mode 100644
index 0000000..1f57aec
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/async/ensureAsync.js
@@ -0,0 +1,73 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = ensureAsync;
+
+var _setImmediate = require('./internal/setImmediate');
+
+var _setImmediate2 = _interopRequireDefault(_setImmediate);
+
+var _initialParams = require('./internal/initialParams');
+
+var _initialParams2 = _interopRequireDefault(_initialParams);
+
+var _wrapAsync = require('./internal/wrapAsync');
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * Wrap an async function and ensure it calls its callback on a later tick of
+ * the event loop. If the function already calls its callback on a next tick,
+ * no extra deferral is added. This is useful for preventing stack overflows
+ * (`RangeError: Maximum call stack size exceeded`) and generally keeping
+ * [Zalgo](http://blog.izs.me/post/59142742143/designing-apis-for-asynchrony)
+ * contained. ES2017 `async` functions are returned as-is -- they are immune
+ * to Zalgo's corrupting influences, as they always resolve on a later tick.
+ *
+ * @name ensureAsync
+ * @static
+ * @memberOf module:Utils
+ * @method
+ * @category Util
+ * @param {AsyncFunction} fn - an async function, one that expects a node-style
+ * callback as its last argument.
+ * @returns {AsyncFunction} Returns a wrapped function with the exact same call
+ * signature as the function passed in.
+ * @example
+ *
+ * function sometimesAsync(arg, callback) {
+ * if (cache[arg]) {
+ * return callback(null, cache[arg]); // this would be synchronous!!
+ * } else {
+ * doSomeIO(arg, callback); // this IO would be asynchronous
+ * }
+ * }
+ *
+ * // this has a risk of stack overflows if many results are cached in a row
+ * async.mapSeries(args, sometimesAsync, done);
+ *
+ * // this will defer sometimesAsync's callback if necessary,
+ * // preventing stack overflows
+ * async.mapSeries(args, async.ensureAsync(sometimesAsync), done);
+ */
+function ensureAsync(fn) {
+ if ((0, _wrapAsync.isAsync)(fn)) return fn;
+ return (0, _initialParams2.default)(function (args, callback) {
+ var sync = true;
+ args.push(function () {
+ var innerArgs = arguments;
+ if (sync) {
+ (0, _setImmediate2.default)(function () {
+ callback.apply(null, innerArgs);
+ });
+ } else {
+ callback.apply(null, innerArgs);
+ }
+ });
+ fn.apply(this, args);
+ sync = false;
+ });
+}
+module.exports = exports['default'];
\ No newline at end of file
diff --git a/node_modules/@pm2/js-api/node_modules/async/every.js b/node_modules/@pm2/js-api/node_modules/async/every.js
new file mode 100644
index 0000000..d0565b0
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/async/every.js
@@ -0,0 +1,50 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+var _createTester = require('./internal/createTester');
+
+var _createTester2 = _interopRequireDefault(_createTester);
+
+var _doParallel = require('./internal/doParallel');
+
+var _doParallel2 = _interopRequireDefault(_doParallel);
+
+var _notId = require('./internal/notId');
+
+var _notId2 = _interopRequireDefault(_notId);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * Returns `true` if every element in `coll` satisfies an async test. If any
+ * iteratee call returns `false`, the main `callback` is immediately called.
+ *
+ * @name every
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @alias all
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {AsyncFunction} iteratee - An async truth test to apply to each item
+ * in the collection in parallel.
+ * The iteratee must complete with a boolean result value.
+ * Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called after all the
+ * `iteratee` functions have finished. Result will be either `true` or `false`
+ * depending on the values of the async tests. Invoked with (err, result).
+ * @example
+ *
+ * async.every(['file1','file2','file3'], function(filePath, callback) {
+ * fs.access(filePath, function(err) {
+ * callback(null, !err)
+ * });
+ * }, function(err, result) {
+ * // if result is true then every file exists
+ * });
+ */
+exports.default = (0, _doParallel2.default)((0, _createTester2.default)(_notId2.default, _notId2.default));
+module.exports = exports['default'];
\ No newline at end of file
diff --git a/node_modules/@pm2/js-api/node_modules/async/everyLimit.js b/node_modules/@pm2/js-api/node_modules/async/everyLimit.js
new file mode 100644
index 0000000..a1a759a
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/async/everyLimit.js
@@ -0,0 +1,42 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+var _createTester = require('./internal/createTester');
+
+var _createTester2 = _interopRequireDefault(_createTester);
+
+var _doParallelLimit = require('./internal/doParallelLimit');
+
+var _doParallelLimit2 = _interopRequireDefault(_doParallelLimit);
+
+var _notId = require('./internal/notId');
+
+var _notId2 = _interopRequireDefault(_notId);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * The same as [`every`]{@link module:Collections.every} but runs a maximum of `limit` async operations at a time.
+ *
+ * @name everyLimit
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.every]{@link module:Collections.every}
+ * @alias allLimit
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {number} limit - The maximum number of async operations at a time.
+ * @param {AsyncFunction} iteratee - An async truth test to apply to each item
+ * in the collection in parallel.
+ * The iteratee must complete with a boolean result value.
+ * Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called after all the
+ * `iteratee` functions have finished. Result will be either `true` or `false`
+ * depending on the values of the async tests. Invoked with (err, result).
+ */
+exports.default = (0, _doParallelLimit2.default)((0, _createTester2.default)(_notId2.default, _notId2.default));
+module.exports = exports['default'];
\ No newline at end of file
diff --git a/node_modules/@pm2/js-api/node_modules/async/everySeries.js b/node_modules/@pm2/js-api/node_modules/async/everySeries.js
new file mode 100644
index 0000000..23bfebb
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/async/everySeries.js
@@ -0,0 +1,37 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+var _everyLimit = require('./everyLimit');
+
+var _everyLimit2 = _interopRequireDefault(_everyLimit);
+
+var _doLimit = require('./internal/doLimit');
+
+var _doLimit2 = _interopRequireDefault(_doLimit);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * The same as [`every`]{@link module:Collections.every} but runs only a single async operation at a time.
+ *
+ * @name everySeries
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.every]{@link module:Collections.every}
+ * @alias allSeries
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {AsyncFunction} iteratee - An async truth test to apply to each item
+ * in the collection in series.
+ * The iteratee must complete with a boolean result value.
+ * Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called after all the
+ * `iteratee` functions have finished. Result will be either `true` or `false`
+ * depending on the values of the async tests. Invoked with (err, result).
+ */
+exports.default = (0, _doLimit2.default)(_everyLimit2.default, 1);
+module.exports = exports['default'];
\ No newline at end of file
diff --git a/node_modules/@pm2/js-api/node_modules/async/filter.js b/node_modules/@pm2/js-api/node_modules/async/filter.js
new file mode 100644
index 0000000..54772d5
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/async/filter.js
@@ -0,0 +1,45 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+var _filter = require('./internal/filter');
+
+var _filter2 = _interopRequireDefault(_filter);
+
+var _doParallel = require('./internal/doParallel');
+
+var _doParallel2 = _interopRequireDefault(_doParallel);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * Returns a new array of all the values in `coll` which pass an async truth
+ * test. This operation is performed in parallel, but the results array will be
+ * in the same order as the original.
+ *
+ * @name filter
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @alias select
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {Function} iteratee - A truth test to apply to each item in `coll`.
+ * The `iteratee` is passed a `callback(err, truthValue)`, which must be called
+ * with a boolean argument once it has completed. Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called after all the
+ * `iteratee` functions have finished. Invoked with (err, results).
+ * @example
+ *
+ * async.filter(['file1','file2','file3'], function(filePath, callback) {
+ * fs.access(filePath, function(err) {
+ * callback(null, !err)
+ * });
+ * }, function(err, results) {
+ * // results now equals an array of the existing files
+ * });
+ */
+exports.default = (0, _doParallel2.default)(_filter2.default);
+module.exports = exports['default'];
\ No newline at end of file
diff --git a/node_modules/@pm2/js-api/node_modules/async/filterLimit.js b/node_modules/@pm2/js-api/node_modules/async/filterLimit.js
new file mode 100644
index 0000000..06216f7
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/async/filterLimit.js
@@ -0,0 +1,37 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+var _filter = require('./internal/filter');
+
+var _filter2 = _interopRequireDefault(_filter);
+
+var _doParallelLimit = require('./internal/doParallelLimit');
+
+var _doParallelLimit2 = _interopRequireDefault(_doParallelLimit);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * The same as [`filter`]{@link module:Collections.filter} but runs a maximum of `limit` async operations at a
+ * time.
+ *
+ * @name filterLimit
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.filter]{@link module:Collections.filter}
+ * @alias selectLimit
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {number} limit - The maximum number of async operations at a time.
+ * @param {Function} iteratee - A truth test to apply to each item in `coll`.
+ * The `iteratee` is passed a `callback(err, truthValue)`, which must be called
+ * with a boolean argument once it has completed. Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called after all the
+ * `iteratee` functions have finished. Invoked with (err, results).
+ */
+exports.default = (0, _doParallelLimit2.default)(_filter2.default);
+module.exports = exports['default'];
\ No newline at end of file
diff --git a/node_modules/@pm2/js-api/node_modules/async/filterSeries.js b/node_modules/@pm2/js-api/node_modules/async/filterSeries.js
new file mode 100644
index 0000000..e48d966
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/async/filterSeries.js
@@ -0,0 +1,35 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+var _filterLimit = require('./filterLimit');
+
+var _filterLimit2 = _interopRequireDefault(_filterLimit);
+
+var _doLimit = require('./internal/doLimit');
+
+var _doLimit2 = _interopRequireDefault(_doLimit);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * The same as [`filter`]{@link module:Collections.filter} but runs only a single async operation at a time.
+ *
+ * @name filterSeries
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.filter]{@link module:Collections.filter}
+ * @alias selectSeries
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {Function} iteratee - A truth test to apply to each item in `coll`.
+ * The `iteratee` is passed a `callback(err, truthValue)`, which must be called
+ * with a boolean argument once it has completed. Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called after all the
+ * `iteratee` functions have finished. Invoked with (err, results)
+ */
+exports.default = (0, _doLimit2.default)(_filterLimit2.default, 1);
+module.exports = exports['default'];
\ No newline at end of file
diff --git a/node_modules/@pm2/js-api/node_modules/async/find.js b/node_modules/@pm2/js-api/node_modules/async/find.js
new file mode 100644
index 0000000..db46783
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/async/find.js
@@ -0,0 +1,61 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+var _identity = require('lodash/identity');
+
+var _identity2 = _interopRequireDefault(_identity);
+
+var _createTester = require('./internal/createTester');
+
+var _createTester2 = _interopRequireDefault(_createTester);
+
+var _doParallel = require('./internal/doParallel');
+
+var _doParallel2 = _interopRequireDefault(_doParallel);
+
+var _findGetResult = require('./internal/findGetResult');
+
+var _findGetResult2 = _interopRequireDefault(_findGetResult);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * Returns the first value in `coll` that passes an async truth test. The
+ * `iteratee` is applied in parallel, meaning the first iteratee to return
+ * `true` will fire the detect `callback` with that result. That means the
+ * result might not be the first item in the original `coll` (in terms of order)
+ * that passes the test.
+
+ * If order within the original `coll` is important, then look at
+ * [`detectSeries`]{@link module:Collections.detectSeries}.
+ *
+ * @name detect
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @alias find
+ * @category Collections
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {AsyncFunction} iteratee - A truth test to apply to each item in `coll`.
+ * The iteratee must complete with a boolean value as its result.
+ * Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called as soon as any
+ * iteratee returns `true`, or after all the `iteratee` functions have finished.
+ * Result will be the first item in the array that passes the truth test
+ * (iteratee) or the value `undefined` if none passed. Invoked with
+ * (err, result).
+ * @example
+ *
+ * async.detect(['file1','file2','file3'], function(filePath, callback) {
+ * fs.access(filePath, function(err) {
+ * callback(null, !err)
+ * });
+ * }, function(err, result) {
+ * // result now equals the first file in the list that exists
+ * });
+ */
+exports.default = (0, _doParallel2.default)((0, _createTester2.default)(_identity2.default, _findGetResult2.default));
+module.exports = exports['default'];
\ No newline at end of file
diff --git a/node_modules/@pm2/js-api/node_modules/async/findLimit.js b/node_modules/@pm2/js-api/node_modules/async/findLimit.js
new file mode 100644
index 0000000..6bf6560
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/async/findLimit.js
@@ -0,0 +1,48 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+var _identity = require('lodash/identity');
+
+var _identity2 = _interopRequireDefault(_identity);
+
+var _createTester = require('./internal/createTester');
+
+var _createTester2 = _interopRequireDefault(_createTester);
+
+var _doParallelLimit = require('./internal/doParallelLimit');
+
+var _doParallelLimit2 = _interopRequireDefault(_doParallelLimit);
+
+var _findGetResult = require('./internal/findGetResult');
+
+var _findGetResult2 = _interopRequireDefault(_findGetResult);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * The same as [`detect`]{@link module:Collections.detect} but runs a maximum of `limit` async operations at a
+ * time.
+ *
+ * @name detectLimit
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.detect]{@link module:Collections.detect}
+ * @alias findLimit
+ * @category Collections
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {number} limit - The maximum number of async operations at a time.
+ * @param {AsyncFunction} iteratee - A truth test to apply to each item in `coll`.
+ * The iteratee must complete with a boolean value as its result.
+ * Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called as soon as any
+ * iteratee returns `true`, or after all the `iteratee` functions have finished.
+ * Result will be the first item in the array that passes the truth test
+ * (iteratee) or the value `undefined` if none passed. Invoked with
+ * (err, result).
+ */
+exports.default = (0, _doParallelLimit2.default)((0, _createTester2.default)(_identity2.default, _findGetResult2.default));
+module.exports = exports['default'];
\ No newline at end of file
diff --git a/node_modules/@pm2/js-api/node_modules/async/findSeries.js b/node_modules/@pm2/js-api/node_modules/async/findSeries.js
new file mode 100644
index 0000000..6fe16c9
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/async/findSeries.js
@@ -0,0 +1,38 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+var _detectLimit = require('./detectLimit');
+
+var _detectLimit2 = _interopRequireDefault(_detectLimit);
+
+var _doLimit = require('./internal/doLimit');
+
+var _doLimit2 = _interopRequireDefault(_doLimit);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * The same as [`detect`]{@link module:Collections.detect} but runs only a single async operation at a time.
+ *
+ * @name detectSeries
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.detect]{@link module:Collections.detect}
+ * @alias findSeries
+ * @category Collections
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {AsyncFunction} iteratee - A truth test to apply to each item in `coll`.
+ * The iteratee must complete with a boolean value as its result.
+ * Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called as soon as any
+ * iteratee returns `true`, or after all the `iteratee` functions have finished.
+ * Result will be the first item in the array that passes the truth test
+ * (iteratee) or the value `undefined` if none passed. Invoked with
+ * (err, result).
+ */
+exports.default = (0, _doLimit2.default)(_detectLimit2.default, 1);
+module.exports = exports['default'];
\ No newline at end of file
diff --git a/node_modules/@pm2/js-api/node_modules/async/foldl.js b/node_modules/@pm2/js-api/node_modules/async/foldl.js
new file mode 100644
index 0000000..3fb8019
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/async/foldl.js
@@ -0,0 +1,78 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = reduce;
+
+var _eachOfSeries = require('./eachOfSeries');
+
+var _eachOfSeries2 = _interopRequireDefault(_eachOfSeries);
+
+var _noop = require('lodash/noop');
+
+var _noop2 = _interopRequireDefault(_noop);
+
+var _once = require('./internal/once');
+
+var _once2 = _interopRequireDefault(_once);
+
+var _wrapAsync = require('./internal/wrapAsync');
+
+var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * Reduces `coll` into a single value using an async `iteratee` to return each
+ * successive step. `memo` is the initial state of the reduction. This function
+ * only operates in series.
+ *
+ * For performance reasons, it may make sense to split a call to this function
+ * into a parallel map, and then use the normal `Array.prototype.reduce` on the
+ * results. This function is for situations where each step in the reduction
+ * needs to be async; if you can get the data before reducing it, then it's
+ * probably a good idea to do so.
+ *
+ * @name reduce
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @alias inject
+ * @alias foldl
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {*} memo - The initial state of the reduction.
+ * @param {AsyncFunction} iteratee - A function applied to each item in the
+ * array to produce the next step in the reduction.
+ * The `iteratee` should complete with the next state of the reduction.
+ * If the iteratee complete with an error, the reduction is stopped and the
+ * main `callback` is immediately called with the error.
+ * Invoked with (memo, item, callback).
+ * @param {Function} [callback] - A callback which is called after all the
+ * `iteratee` functions have finished. Result is the reduced value. Invoked with
+ * (err, result).
+ * @example
+ *
+ * async.reduce([1,2,3], 0, function(memo, item, callback) {
+ * // pointless async:
+ * process.nextTick(function() {
+ * callback(null, memo + item)
+ * });
+ * }, function(err, result) {
+ * // result is now equal to the last value of memo, which is 6
+ * });
+ */
+function reduce(coll, memo, iteratee, callback) {
+ callback = (0, _once2.default)(callback || _noop2.default);
+ var _iteratee = (0, _wrapAsync2.default)(iteratee);
+ (0, _eachOfSeries2.default)(coll, function (x, i, callback) {
+ _iteratee(memo, x, function (err, v) {
+ memo = v;
+ callback(err);
+ });
+ }, function (err) {
+ callback(err, memo);
+ });
+}
+module.exports = exports['default'];
\ No newline at end of file
diff --git a/node_modules/@pm2/js-api/node_modules/async/foldr.js b/node_modules/@pm2/js-api/node_modules/async/foldr.js
new file mode 100644
index 0000000..3d17d32
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/async/foldr.js
@@ -0,0 +1,44 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = reduceRight;
+
+var _reduce = require('./reduce');
+
+var _reduce2 = _interopRequireDefault(_reduce);
+
+var _slice = require('./internal/slice');
+
+var _slice2 = _interopRequireDefault(_slice);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * Same as [`reduce`]{@link module:Collections.reduce}, only operates on `array` in reverse order.
+ *
+ * @name reduceRight
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.reduce]{@link module:Collections.reduce}
+ * @alias foldr
+ * @category Collection
+ * @param {Array} array - A collection to iterate over.
+ * @param {*} memo - The initial state of the reduction.
+ * @param {AsyncFunction} iteratee - A function applied to each item in the
+ * array to produce the next step in the reduction.
+ * The `iteratee` should complete with the next state of the reduction.
+ * If the iteratee complete with an error, the reduction is stopped and the
+ * main `callback` is immediately called with the error.
+ * Invoked with (memo, item, callback).
+ * @param {Function} [callback] - A callback which is called after all the
+ * `iteratee` functions have finished. Result is the reduced value. Invoked with
+ * (err, result).
+ */
+function reduceRight(array, memo, iteratee, callback) {
+ var reversed = (0, _slice2.default)(array).reverse();
+ (0, _reduce2.default)(reversed, memo, iteratee, callback);
+}
+module.exports = exports['default'];
\ No newline at end of file
diff --git a/node_modules/@pm2/js-api/node_modules/async/forEach.js b/node_modules/@pm2/js-api/node_modules/async/forEach.js
new file mode 100644
index 0000000..4b20af3
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/async/forEach.js
@@ -0,0 +1,82 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = eachLimit;
+
+var _eachOf = require('./eachOf');
+
+var _eachOf2 = _interopRequireDefault(_eachOf);
+
+var _withoutIndex = require('./internal/withoutIndex');
+
+var _withoutIndex2 = _interopRequireDefault(_withoutIndex);
+
+var _wrapAsync = require('./internal/wrapAsync');
+
+var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * Applies the function `iteratee` to each item in `coll`, in parallel.
+ * The `iteratee` is called with an item from the list, and a callback for when
+ * it has finished. If the `iteratee` passes an error to its `callback`, the
+ * main `callback` (for the `each` function) is immediately called with the
+ * error.
+ *
+ * Note, that since this function applies `iteratee` to each item in parallel,
+ * there is no guarantee that the iteratee functions will complete in order.
+ *
+ * @name each
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @alias forEach
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {AsyncFunction} iteratee - An async function to apply to
+ * each item in `coll`. Invoked with (item, callback).
+ * The array index is not passed to the iteratee.
+ * If you need the index, use `eachOf`.
+ * @param {Function} [callback] - A callback which is called when all
+ * `iteratee` functions have finished, or an error occurs. Invoked with (err).
+ * @example
+ *
+ * // assuming openFiles is an array of file names and saveFile is a function
+ * // to save the modified contents of that file:
+ *
+ * async.each(openFiles, saveFile, function(err){
+ * // if any of the saves produced an error, err would equal that error
+ * });
+ *
+ * // assuming openFiles is an array of file names
+ * async.each(openFiles, function(file, callback) {
+ *
+ * // Perform operation on file here.
+ * console.log('Processing file ' + file);
+ *
+ * if( file.length > 32 ) {
+ * console.log('This file name is too long');
+ * callback('File name too long');
+ * } else {
+ * // Do work to process file here
+ * console.log('File processed');
+ * callback();
+ * }
+ * }, function(err) {
+ * // if any of the file processing produced an error, err would equal that error
+ * if( err ) {
+ * // One of the iterations produced an error.
+ * // All processing will now stop.
+ * console.log('A file failed to process');
+ * } else {
+ * console.log('All files have been processed successfully');
+ * }
+ * });
+ */
+function eachLimit(coll, iteratee, callback) {
+ (0, _eachOf2.default)(coll, (0, _withoutIndex2.default)((0, _wrapAsync2.default)(iteratee)), callback);
+}
+module.exports = exports['default'];
\ No newline at end of file
diff --git a/node_modules/@pm2/js-api/node_modules/async/forEachLimit.js b/node_modules/@pm2/js-api/node_modules/async/forEachLimit.js
new file mode 100644
index 0000000..fff721b
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/async/forEachLimit.js
@@ -0,0 +1,45 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = eachLimit;
+
+var _eachOfLimit = require('./internal/eachOfLimit');
+
+var _eachOfLimit2 = _interopRequireDefault(_eachOfLimit);
+
+var _withoutIndex = require('./internal/withoutIndex');
+
+var _withoutIndex2 = _interopRequireDefault(_withoutIndex);
+
+var _wrapAsync = require('./internal/wrapAsync');
+
+var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * The same as [`each`]{@link module:Collections.each} but runs a maximum of `limit` async operations at a time.
+ *
+ * @name eachLimit
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.each]{@link module:Collections.each}
+ * @alias forEachLimit
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {number} limit - The maximum number of async operations at a time.
+ * @param {AsyncFunction} iteratee - An async function to apply to each item in
+ * `coll`.
+ * The array index is not passed to the iteratee.
+ * If you need the index, use `eachOfLimit`.
+ * Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called when all
+ * `iteratee` functions have finished, or an error occurs. Invoked with (err).
+ */
+function eachLimit(coll, limit, iteratee, callback) {
+ (0, _eachOfLimit2.default)(limit)(coll, (0, _withoutIndex2.default)((0, _wrapAsync2.default)(iteratee)), callback);
+}
+module.exports = exports['default'];
\ No newline at end of file
diff --git a/node_modules/@pm2/js-api/node_modules/async/forEachOf.js b/node_modules/@pm2/js-api/node_modules/async/forEachOf.js
new file mode 100644
index 0000000..055b9bd
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/async/forEachOf.js
@@ -0,0 +1,111 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+exports.default = function (coll, iteratee, callback) {
+ var eachOfImplementation = (0, _isArrayLike2.default)(coll) ? eachOfArrayLike : eachOfGeneric;
+ eachOfImplementation(coll, (0, _wrapAsync2.default)(iteratee), callback);
+};
+
+var _isArrayLike = require('lodash/isArrayLike');
+
+var _isArrayLike2 = _interopRequireDefault(_isArrayLike);
+
+var _breakLoop = require('./internal/breakLoop');
+
+var _breakLoop2 = _interopRequireDefault(_breakLoop);
+
+var _eachOfLimit = require('./eachOfLimit');
+
+var _eachOfLimit2 = _interopRequireDefault(_eachOfLimit);
+
+var _doLimit = require('./internal/doLimit');
+
+var _doLimit2 = _interopRequireDefault(_doLimit);
+
+var _noop = require('lodash/noop');
+
+var _noop2 = _interopRequireDefault(_noop);
+
+var _once = require('./internal/once');
+
+var _once2 = _interopRequireDefault(_once);
+
+var _onlyOnce = require('./internal/onlyOnce');
+
+var _onlyOnce2 = _interopRequireDefault(_onlyOnce);
+
+var _wrapAsync = require('./internal/wrapAsync');
+
+var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+// eachOf implementation optimized for array-likes
+function eachOfArrayLike(coll, iteratee, callback) {
+ callback = (0, _once2.default)(callback || _noop2.default);
+ var index = 0,
+ completed = 0,
+ length = coll.length;
+ if (length === 0) {
+ callback(null);
+ }
+
+ function iteratorCallback(err, value) {
+ if (err) {
+ callback(err);
+ } else if (++completed === length || value === _breakLoop2.default) {
+ callback(null);
+ }
+ }
+
+ for (; index < length; index++) {
+ iteratee(coll[index], index, (0, _onlyOnce2.default)(iteratorCallback));
+ }
+}
+
+// a generic version of eachOf which can handle array, object, and iterator cases.
+var eachOfGeneric = (0, _doLimit2.default)(_eachOfLimit2.default, Infinity);
+
+/**
+ * Like [`each`]{@link module:Collections.each}, except that it passes the key (or index) as the second argument
+ * to the iteratee.
+ *
+ * @name eachOf
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @alias forEachOf
+ * @category Collection
+ * @see [async.each]{@link module:Collections.each}
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {AsyncFunction} iteratee - A function to apply to each
+ * item in `coll`.
+ * The `key` is the item's key, or index in the case of an array.
+ * Invoked with (item, key, callback).
+ * @param {Function} [callback] - A callback which is called when all
+ * `iteratee` functions have finished, or an error occurs. Invoked with (err).
+ * @example
+ *
+ * var obj = {dev: "/dev.json", test: "/test.json", prod: "/prod.json"};
+ * var configs = {};
+ *
+ * async.forEachOf(obj, function (value, key, callback) {
+ * fs.readFile(__dirname + value, "utf8", function (err, data) {
+ * if (err) return callback(err);
+ * try {
+ * configs[key] = JSON.parse(data);
+ * } catch (e) {
+ * return callback(e);
+ * }
+ * callback();
+ * });
+ * }, function (err) {
+ * if (err) console.error(err.message);
+ * // configs is now a map of JSON data
+ * doSomethingWith(configs);
+ * });
+ */
+module.exports = exports['default'];
\ No newline at end of file
diff --git a/node_modules/@pm2/js-api/node_modules/async/forEachOfLimit.js b/node_modules/@pm2/js-api/node_modules/async/forEachOfLimit.js
new file mode 100644
index 0000000..30a1329
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/async/forEachOfLimit.js
@@ -0,0 +1,41 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = eachOfLimit;
+
+var _eachOfLimit2 = require('./internal/eachOfLimit');
+
+var _eachOfLimit3 = _interopRequireDefault(_eachOfLimit2);
+
+var _wrapAsync = require('./internal/wrapAsync');
+
+var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * The same as [`eachOf`]{@link module:Collections.eachOf} but runs a maximum of `limit` async operations at a
+ * time.
+ *
+ * @name eachOfLimit
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.eachOf]{@link module:Collections.eachOf}
+ * @alias forEachOfLimit
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {number} limit - The maximum number of async operations at a time.
+ * @param {AsyncFunction} iteratee - An async function to apply to each
+ * item in `coll`. The `key` is the item's key, or index in the case of an
+ * array.
+ * Invoked with (item, key, callback).
+ * @param {Function} [callback] - A callback which is called when all
+ * `iteratee` functions have finished, or an error occurs. Invoked with (err).
+ */
+function eachOfLimit(coll, limit, iteratee, callback) {
+ (0, _eachOfLimit3.default)(limit)(coll, (0, _wrapAsync2.default)(iteratee), callback);
+}
+module.exports = exports['default'];
\ No newline at end of file
diff --git a/node_modules/@pm2/js-api/node_modules/async/forEachOfSeries.js b/node_modules/@pm2/js-api/node_modules/async/forEachOfSeries.js
new file mode 100644
index 0000000..9dfd711
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/async/forEachOfSeries.js
@@ -0,0 +1,35 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+var _eachOfLimit = require('./eachOfLimit');
+
+var _eachOfLimit2 = _interopRequireDefault(_eachOfLimit);
+
+var _doLimit = require('./internal/doLimit');
+
+var _doLimit2 = _interopRequireDefault(_doLimit);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * The same as [`eachOf`]{@link module:Collections.eachOf} but runs only a single async operation at a time.
+ *
+ * @name eachOfSeries
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.eachOf]{@link module:Collections.eachOf}
+ * @alias forEachOfSeries
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {AsyncFunction} iteratee - An async function to apply to each item in
+ * `coll`.
+ * Invoked with (item, key, callback).
+ * @param {Function} [callback] - A callback which is called when all `iteratee`
+ * functions have finished, or an error occurs. Invoked with (err).
+ */
+exports.default = (0, _doLimit2.default)(_eachOfLimit2.default, 1);
+module.exports = exports['default'];
\ No newline at end of file
diff --git a/node_modules/@pm2/js-api/node_modules/async/forEachSeries.js b/node_modules/@pm2/js-api/node_modules/async/forEachSeries.js
new file mode 100644
index 0000000..55c7840
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/async/forEachSeries.js
@@ -0,0 +1,37 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+var _eachLimit = require('./eachLimit');
+
+var _eachLimit2 = _interopRequireDefault(_eachLimit);
+
+var _doLimit = require('./internal/doLimit');
+
+var _doLimit2 = _interopRequireDefault(_doLimit);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * The same as [`each`]{@link module:Collections.each} but runs only a single async operation at a time.
+ *
+ * @name eachSeries
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.each]{@link module:Collections.each}
+ * @alias forEachSeries
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {AsyncFunction} iteratee - An async function to apply to each
+ * item in `coll`.
+ * The array index is not passed to the iteratee.
+ * If you need the index, use `eachOfSeries`.
+ * Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called when all
+ * `iteratee` functions have finished, or an error occurs. Invoked with (err).
+ */
+exports.default = (0, _doLimit2.default)(_eachLimit2.default, 1);
+module.exports = exports['default'];
\ No newline at end of file
diff --git a/node_modules/@pm2/js-api/node_modules/async/forever.js b/node_modules/@pm2/js-api/node_modules/async/forever.js
new file mode 100644
index 0000000..6c7b8a4
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/async/forever.js
@@ -0,0 +1,65 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = forever;
+
+var _noop = require('lodash/noop');
+
+var _noop2 = _interopRequireDefault(_noop);
+
+var _onlyOnce = require('./internal/onlyOnce');
+
+var _onlyOnce2 = _interopRequireDefault(_onlyOnce);
+
+var _ensureAsync = require('./ensureAsync');
+
+var _ensureAsync2 = _interopRequireDefault(_ensureAsync);
+
+var _wrapAsync = require('./internal/wrapAsync');
+
+var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * Calls the asynchronous function `fn` with a callback parameter that allows it
+ * to call itself again, in series, indefinitely.
+
+ * If an error is passed to the callback then `errback` is called with the
+ * error, and execution stops, otherwise it will never be called.
+ *
+ * @name forever
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @category Control Flow
+ * @param {AsyncFunction} fn - an async function to call repeatedly.
+ * Invoked with (next).
+ * @param {Function} [errback] - when `fn` passes an error to it's callback,
+ * this function will be called, and execution stops. Invoked with (err).
+ * @example
+ *
+ * async.forever(
+ * function(next) {
+ * // next is suitable for passing to things that need a callback(err [, whatever]);
+ * // it will result in this function being called again.
+ * },
+ * function(err) {
+ * // if next is called with a value in its first parameter, it will appear
+ * // in here as 'err', and execution will stop.
+ * }
+ * );
+ */
+function forever(fn, errback) {
+ var done = (0, _onlyOnce2.default)(errback || _noop2.default);
+ var task = (0, _wrapAsync2.default)((0, _ensureAsync2.default)(fn));
+
+ function next(err) {
+ if (err) return done(err);
+ task(next);
+ }
+ next();
+}
+module.exports = exports['default'];
\ No newline at end of file
diff --git a/node_modules/@pm2/js-api/node_modules/async/groupBy.js b/node_modules/@pm2/js-api/node_modules/async/groupBy.js
new file mode 100644
index 0000000..755cba7
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/async/groupBy.js
@@ -0,0 +1,54 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+var _doLimit = require('./internal/doLimit');
+
+var _doLimit2 = _interopRequireDefault(_doLimit);
+
+var _groupByLimit = require('./groupByLimit');
+
+var _groupByLimit2 = _interopRequireDefault(_groupByLimit);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * Returns a new object, where each value corresponds to an array of items, from
+ * `coll`, that returned the corresponding key. That is, the keys of the object
+ * correspond to the values passed to the `iteratee` callback.
+ *
+ * Note: Since this function applies the `iteratee` to each item in parallel,
+ * there is no guarantee that the `iteratee` functions will complete in order.
+ * However, the values for each key in the `result` will be in the same order as
+ * the original `coll`. For Objects, the values will roughly be in the order of
+ * the original Objects' keys (but this can vary across JavaScript engines).
+ *
+ * @name groupBy
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {AsyncFunction} iteratee - An async function to apply to each item in
+ * `coll`.
+ * The iteratee should complete with a `key` to group the value under.
+ * Invoked with (value, callback).
+ * @param {Function} [callback] - A callback which is called when all `iteratee`
+ * functions have finished, or an error occurs. Result is an `Object` whoses
+ * properties are arrays of values which returned the corresponding key.
+ * @example
+ *
+ * async.groupBy(['userId1', 'userId2', 'userId3'], function(userId, callback) {
+ * db.findById(userId, function(err, user) {
+ * if (err) return callback(err);
+ * return callback(null, user.age);
+ * });
+ * }, function(err, result) {
+ * // result is object containing the userIds grouped by age
+ * // e.g. { 30: ['userId1', 'userId3'], 42: ['userId2']};
+ * });
+ */
+exports.default = (0, _doLimit2.default)(_groupByLimit2.default, Infinity);
+module.exports = exports['default'];
\ No newline at end of file
diff --git a/node_modules/@pm2/js-api/node_modules/async/groupByLimit.js b/node_modules/@pm2/js-api/node_modules/async/groupByLimit.js
new file mode 100644
index 0000000..fec13f8
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/async/groupByLimit.js
@@ -0,0 +1,71 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+exports.default = function (coll, limit, iteratee, callback) {
+ callback = callback || _noop2.default;
+ var _iteratee = (0, _wrapAsync2.default)(iteratee);
+ (0, _mapLimit2.default)(coll, limit, function (val, callback) {
+ _iteratee(val, function (err, key) {
+ if (err) return callback(err);
+ return callback(null, { key: key, val: val });
+ });
+ }, function (err, mapResults) {
+ var result = {};
+ // from MDN, handle object having an `hasOwnProperty` prop
+ var hasOwnProperty = Object.prototype.hasOwnProperty;
+
+ for (var i = 0; i < mapResults.length; i++) {
+ if (mapResults[i]) {
+ var key = mapResults[i].key;
+ var val = mapResults[i].val;
+
+ if (hasOwnProperty.call(result, key)) {
+ result[key].push(val);
+ } else {
+ result[key] = [val];
+ }
+ }
+ }
+
+ return callback(err, result);
+ });
+};
+
+var _noop = require('lodash/noop');
+
+var _noop2 = _interopRequireDefault(_noop);
+
+var _mapLimit = require('./mapLimit');
+
+var _mapLimit2 = _interopRequireDefault(_mapLimit);
+
+var _wrapAsync = require('./internal/wrapAsync');
+
+var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+;
+/**
+ * The same as [`groupBy`]{@link module:Collections.groupBy} but runs a maximum of `limit` async operations at a time.
+ *
+ * @name groupByLimit
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.groupBy]{@link module:Collections.groupBy}
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {number} limit - The maximum number of async operations at a time.
+ * @param {AsyncFunction} iteratee - An async function to apply to each item in
+ * `coll`.
+ * The iteratee should complete with a `key` to group the value under.
+ * Invoked with (value, callback).
+ * @param {Function} [callback] - A callback which is called when all `iteratee`
+ * functions have finished, or an error occurs. Result is an `Object` whoses
+ * properties are arrays of values which returned the corresponding key.
+ */
+module.exports = exports['default'];
\ No newline at end of file
diff --git a/node_modules/@pm2/js-api/node_modules/async/groupBySeries.js b/node_modules/@pm2/js-api/node_modules/async/groupBySeries.js
new file mode 100644
index 0000000..b94805e
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/async/groupBySeries.js
@@ -0,0 +1,37 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+var _doLimit = require('./internal/doLimit');
+
+var _doLimit2 = _interopRequireDefault(_doLimit);
+
+var _groupByLimit = require('./groupByLimit');
+
+var _groupByLimit2 = _interopRequireDefault(_groupByLimit);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * The same as [`groupBy`]{@link module:Collections.groupBy} but runs only a single async operation at a time.
+ *
+ * @name groupBySeries
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.groupBy]{@link module:Collections.groupBy}
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {number} limit - The maximum number of async operations at a time.
+ * @param {AsyncFunction} iteratee - An async function to apply to each item in
+ * `coll`.
+ * The iteratee should complete with a `key` to group the value under.
+ * Invoked with (value, callback).
+ * @param {Function} [callback] - A callback which is called when all `iteratee`
+ * functions have finished, or an error occurs. Result is an `Object` whoses
+ * properties are arrays of values which returned the corresponding key.
+ */
+exports.default = (0, _doLimit2.default)(_groupByLimit2.default, 1);
+module.exports = exports['default'];
\ No newline at end of file
diff --git a/node_modules/@pm2/js-api/node_modules/async/index.js b/node_modules/@pm2/js-api/node_modules/async/index.js
new file mode 100644
index 0000000..c39d8d8
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/async/index.js
@@ -0,0 +1,582 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.wrapSync = exports.selectSeries = exports.selectLimit = exports.select = exports.foldr = exports.foldl = exports.inject = exports.forEachOfLimit = exports.forEachOfSeries = exports.forEachOf = exports.forEachLimit = exports.forEachSeries = exports.forEach = exports.findSeries = exports.findLimit = exports.find = exports.anySeries = exports.anyLimit = exports.any = exports.allSeries = exports.allLimit = exports.all = exports.whilst = exports.waterfall = exports.until = exports.unmemoize = exports.tryEach = exports.transform = exports.timesSeries = exports.timesLimit = exports.times = exports.timeout = exports.sortBy = exports.someSeries = exports.someLimit = exports.some = exports.setImmediate = exports.series = exports.seq = exports.retryable = exports.retry = exports.rejectSeries = exports.rejectLimit = exports.reject = exports.reflectAll = exports.reflect = exports.reduceRight = exports.reduce = exports.race = exports.queue = exports.priorityQueue = exports.parallelLimit = exports.parallel = exports.nextTick = exports.memoize = exports.mapValuesSeries = exports.mapValuesLimit = exports.mapValues = exports.mapSeries = exports.mapLimit = exports.map = exports.log = exports.groupBySeries = exports.groupByLimit = exports.groupBy = exports.forever = exports.filterSeries = exports.filterLimit = exports.filter = exports.everySeries = exports.everyLimit = exports.every = exports.ensureAsync = exports.eachSeries = exports.eachOfSeries = exports.eachOfLimit = exports.eachOf = exports.eachLimit = exports.each = exports.during = exports.doWhilst = exports.doUntil = exports.doDuring = exports.dir = exports.detectSeries = exports.detectLimit = exports.detect = exports.constant = exports.concatSeries = exports.concatLimit = exports.concat = exports.compose = exports.cargo = exports.autoInject = exports.auto = exports.asyncify = exports.applyEachSeries = exports.applyEach = exports.apply = undefined;
+
+var _apply = require('./apply');
+
+var _apply2 = _interopRequireDefault(_apply);
+
+var _applyEach = require('./applyEach');
+
+var _applyEach2 = _interopRequireDefault(_applyEach);
+
+var _applyEachSeries = require('./applyEachSeries');
+
+var _applyEachSeries2 = _interopRequireDefault(_applyEachSeries);
+
+var _asyncify = require('./asyncify');
+
+var _asyncify2 = _interopRequireDefault(_asyncify);
+
+var _auto = require('./auto');
+
+var _auto2 = _interopRequireDefault(_auto);
+
+var _autoInject = require('./autoInject');
+
+var _autoInject2 = _interopRequireDefault(_autoInject);
+
+var _cargo = require('./cargo');
+
+var _cargo2 = _interopRequireDefault(_cargo);
+
+var _compose = require('./compose');
+
+var _compose2 = _interopRequireDefault(_compose);
+
+var _concat = require('./concat');
+
+var _concat2 = _interopRequireDefault(_concat);
+
+var _concatLimit = require('./concatLimit');
+
+var _concatLimit2 = _interopRequireDefault(_concatLimit);
+
+var _concatSeries = require('./concatSeries');
+
+var _concatSeries2 = _interopRequireDefault(_concatSeries);
+
+var _constant = require('./constant');
+
+var _constant2 = _interopRequireDefault(_constant);
+
+var _detect = require('./detect');
+
+var _detect2 = _interopRequireDefault(_detect);
+
+var _detectLimit = require('./detectLimit');
+
+var _detectLimit2 = _interopRequireDefault(_detectLimit);
+
+var _detectSeries = require('./detectSeries');
+
+var _detectSeries2 = _interopRequireDefault(_detectSeries);
+
+var _dir = require('./dir');
+
+var _dir2 = _interopRequireDefault(_dir);
+
+var _doDuring = require('./doDuring');
+
+var _doDuring2 = _interopRequireDefault(_doDuring);
+
+var _doUntil = require('./doUntil');
+
+var _doUntil2 = _interopRequireDefault(_doUntil);
+
+var _doWhilst = require('./doWhilst');
+
+var _doWhilst2 = _interopRequireDefault(_doWhilst);
+
+var _during = require('./during');
+
+var _during2 = _interopRequireDefault(_during);
+
+var _each = require('./each');
+
+var _each2 = _interopRequireDefault(_each);
+
+var _eachLimit = require('./eachLimit');
+
+var _eachLimit2 = _interopRequireDefault(_eachLimit);
+
+var _eachOf = require('./eachOf');
+
+var _eachOf2 = _interopRequireDefault(_eachOf);
+
+var _eachOfLimit = require('./eachOfLimit');
+
+var _eachOfLimit2 = _interopRequireDefault(_eachOfLimit);
+
+var _eachOfSeries = require('./eachOfSeries');
+
+var _eachOfSeries2 = _interopRequireDefault(_eachOfSeries);
+
+var _eachSeries = require('./eachSeries');
+
+var _eachSeries2 = _interopRequireDefault(_eachSeries);
+
+var _ensureAsync = require('./ensureAsync');
+
+var _ensureAsync2 = _interopRequireDefault(_ensureAsync);
+
+var _every = require('./every');
+
+var _every2 = _interopRequireDefault(_every);
+
+var _everyLimit = require('./everyLimit');
+
+var _everyLimit2 = _interopRequireDefault(_everyLimit);
+
+var _everySeries = require('./everySeries');
+
+var _everySeries2 = _interopRequireDefault(_everySeries);
+
+var _filter = require('./filter');
+
+var _filter2 = _interopRequireDefault(_filter);
+
+var _filterLimit = require('./filterLimit');
+
+var _filterLimit2 = _interopRequireDefault(_filterLimit);
+
+var _filterSeries = require('./filterSeries');
+
+var _filterSeries2 = _interopRequireDefault(_filterSeries);
+
+var _forever = require('./forever');
+
+var _forever2 = _interopRequireDefault(_forever);
+
+var _groupBy = require('./groupBy');
+
+var _groupBy2 = _interopRequireDefault(_groupBy);
+
+var _groupByLimit = require('./groupByLimit');
+
+var _groupByLimit2 = _interopRequireDefault(_groupByLimit);
+
+var _groupBySeries = require('./groupBySeries');
+
+var _groupBySeries2 = _interopRequireDefault(_groupBySeries);
+
+var _log = require('./log');
+
+var _log2 = _interopRequireDefault(_log);
+
+var _map = require('./map');
+
+var _map2 = _interopRequireDefault(_map);
+
+var _mapLimit = require('./mapLimit');
+
+var _mapLimit2 = _interopRequireDefault(_mapLimit);
+
+var _mapSeries = require('./mapSeries');
+
+var _mapSeries2 = _interopRequireDefault(_mapSeries);
+
+var _mapValues = require('./mapValues');
+
+var _mapValues2 = _interopRequireDefault(_mapValues);
+
+var _mapValuesLimit = require('./mapValuesLimit');
+
+var _mapValuesLimit2 = _interopRequireDefault(_mapValuesLimit);
+
+var _mapValuesSeries = require('./mapValuesSeries');
+
+var _mapValuesSeries2 = _interopRequireDefault(_mapValuesSeries);
+
+var _memoize = require('./memoize');
+
+var _memoize2 = _interopRequireDefault(_memoize);
+
+var _nextTick = require('./nextTick');
+
+var _nextTick2 = _interopRequireDefault(_nextTick);
+
+var _parallel = require('./parallel');
+
+var _parallel2 = _interopRequireDefault(_parallel);
+
+var _parallelLimit = require('./parallelLimit');
+
+var _parallelLimit2 = _interopRequireDefault(_parallelLimit);
+
+var _priorityQueue = require('./priorityQueue');
+
+var _priorityQueue2 = _interopRequireDefault(_priorityQueue);
+
+var _queue = require('./queue');
+
+var _queue2 = _interopRequireDefault(_queue);
+
+var _race = require('./race');
+
+var _race2 = _interopRequireDefault(_race);
+
+var _reduce = require('./reduce');
+
+var _reduce2 = _interopRequireDefault(_reduce);
+
+var _reduceRight = require('./reduceRight');
+
+var _reduceRight2 = _interopRequireDefault(_reduceRight);
+
+var _reflect = require('./reflect');
+
+var _reflect2 = _interopRequireDefault(_reflect);
+
+var _reflectAll = require('./reflectAll');
+
+var _reflectAll2 = _interopRequireDefault(_reflectAll);
+
+var _reject = require('./reject');
+
+var _reject2 = _interopRequireDefault(_reject);
+
+var _rejectLimit = require('./rejectLimit');
+
+var _rejectLimit2 = _interopRequireDefault(_rejectLimit);
+
+var _rejectSeries = require('./rejectSeries');
+
+var _rejectSeries2 = _interopRequireDefault(_rejectSeries);
+
+var _retry = require('./retry');
+
+var _retry2 = _interopRequireDefault(_retry);
+
+var _retryable = require('./retryable');
+
+var _retryable2 = _interopRequireDefault(_retryable);
+
+var _seq = require('./seq');
+
+var _seq2 = _interopRequireDefault(_seq);
+
+var _series = require('./series');
+
+var _series2 = _interopRequireDefault(_series);
+
+var _setImmediate = require('./setImmediate');
+
+var _setImmediate2 = _interopRequireDefault(_setImmediate);
+
+var _some = require('./some');
+
+var _some2 = _interopRequireDefault(_some);
+
+var _someLimit = require('./someLimit');
+
+var _someLimit2 = _interopRequireDefault(_someLimit);
+
+var _someSeries = require('./someSeries');
+
+var _someSeries2 = _interopRequireDefault(_someSeries);
+
+var _sortBy = require('./sortBy');
+
+var _sortBy2 = _interopRequireDefault(_sortBy);
+
+var _timeout = require('./timeout');
+
+var _timeout2 = _interopRequireDefault(_timeout);
+
+var _times = require('./times');
+
+var _times2 = _interopRequireDefault(_times);
+
+var _timesLimit = require('./timesLimit');
+
+var _timesLimit2 = _interopRequireDefault(_timesLimit);
+
+var _timesSeries = require('./timesSeries');
+
+var _timesSeries2 = _interopRequireDefault(_timesSeries);
+
+var _transform = require('./transform');
+
+var _transform2 = _interopRequireDefault(_transform);
+
+var _tryEach = require('./tryEach');
+
+var _tryEach2 = _interopRequireDefault(_tryEach);
+
+var _unmemoize = require('./unmemoize');
+
+var _unmemoize2 = _interopRequireDefault(_unmemoize);
+
+var _until = require('./until');
+
+var _until2 = _interopRequireDefault(_until);
+
+var _waterfall = require('./waterfall');
+
+var _waterfall2 = _interopRequireDefault(_waterfall);
+
+var _whilst = require('./whilst');
+
+var _whilst2 = _interopRequireDefault(_whilst);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+exports.default = {
+ apply: _apply2.default,
+ applyEach: _applyEach2.default,
+ applyEachSeries: _applyEachSeries2.default,
+ asyncify: _asyncify2.default,
+ auto: _auto2.default,
+ autoInject: _autoInject2.default,
+ cargo: _cargo2.default,
+ compose: _compose2.default,
+ concat: _concat2.default,
+ concatLimit: _concatLimit2.default,
+ concatSeries: _concatSeries2.default,
+ constant: _constant2.default,
+ detect: _detect2.default,
+ detectLimit: _detectLimit2.default,
+ detectSeries: _detectSeries2.default,
+ dir: _dir2.default,
+ doDuring: _doDuring2.default,
+ doUntil: _doUntil2.default,
+ doWhilst: _doWhilst2.default,
+ during: _during2.default,
+ each: _each2.default,
+ eachLimit: _eachLimit2.default,
+ eachOf: _eachOf2.default,
+ eachOfLimit: _eachOfLimit2.default,
+ eachOfSeries: _eachOfSeries2.default,
+ eachSeries: _eachSeries2.default,
+ ensureAsync: _ensureAsync2.default,
+ every: _every2.default,
+ everyLimit: _everyLimit2.default,
+ everySeries: _everySeries2.default,
+ filter: _filter2.default,
+ filterLimit: _filterLimit2.default,
+ filterSeries: _filterSeries2.default,
+ forever: _forever2.default,
+ groupBy: _groupBy2.default,
+ groupByLimit: _groupByLimit2.default,
+ groupBySeries: _groupBySeries2.default,
+ log: _log2.default,
+ map: _map2.default,
+ mapLimit: _mapLimit2.default,
+ mapSeries: _mapSeries2.default,
+ mapValues: _mapValues2.default,
+ mapValuesLimit: _mapValuesLimit2.default,
+ mapValuesSeries: _mapValuesSeries2.default,
+ memoize: _memoize2.default,
+ nextTick: _nextTick2.default,
+ parallel: _parallel2.default,
+ parallelLimit: _parallelLimit2.default,
+ priorityQueue: _priorityQueue2.default,
+ queue: _queue2.default,
+ race: _race2.default,
+ reduce: _reduce2.default,
+ reduceRight: _reduceRight2.default,
+ reflect: _reflect2.default,
+ reflectAll: _reflectAll2.default,
+ reject: _reject2.default,
+ rejectLimit: _rejectLimit2.default,
+ rejectSeries: _rejectSeries2.default,
+ retry: _retry2.default,
+ retryable: _retryable2.default,
+ seq: _seq2.default,
+ series: _series2.default,
+ setImmediate: _setImmediate2.default,
+ some: _some2.default,
+ someLimit: _someLimit2.default,
+ someSeries: _someSeries2.default,
+ sortBy: _sortBy2.default,
+ timeout: _timeout2.default,
+ times: _times2.default,
+ timesLimit: _timesLimit2.default,
+ timesSeries: _timesSeries2.default,
+ transform: _transform2.default,
+ tryEach: _tryEach2.default,
+ unmemoize: _unmemoize2.default,
+ until: _until2.default,
+ waterfall: _waterfall2.default,
+ whilst: _whilst2.default,
+
+ // aliases
+ all: _every2.default,
+ allLimit: _everyLimit2.default,
+ allSeries: _everySeries2.default,
+ any: _some2.default,
+ anyLimit: _someLimit2.default,
+ anySeries: _someSeries2.default,
+ find: _detect2.default,
+ findLimit: _detectLimit2.default,
+ findSeries: _detectSeries2.default,
+ forEach: _each2.default,
+ forEachSeries: _eachSeries2.default,
+ forEachLimit: _eachLimit2.default,
+ forEachOf: _eachOf2.default,
+ forEachOfSeries: _eachOfSeries2.default,
+ forEachOfLimit: _eachOfLimit2.default,
+ inject: _reduce2.default,
+ foldl: _reduce2.default,
+ foldr: _reduceRight2.default,
+ select: _filter2.default,
+ selectLimit: _filterLimit2.default,
+ selectSeries: _filterSeries2.default,
+ wrapSync: _asyncify2.default
+}; /**
+ * An "async function" in the context of Async is an asynchronous function with
+ * a variable number of parameters, with the final parameter being a callback.
+ * (`function (arg1, arg2, ..., callback) {}`)
+ * The final callback is of the form `callback(err, results...)`, which must be
+ * called once the function is completed. The callback should be called with a
+ * Error as its first argument to signal that an error occurred.
+ * Otherwise, if no error occurred, it should be called with `null` as the first
+ * argument, and any additional `result` arguments that may apply, to signal
+ * successful completion.
+ * The callback must be called exactly once, ideally on a later tick of the
+ * JavaScript event loop.
+ *
+ * This type of function is also referred to as a "Node-style async function",
+ * or a "continuation passing-style function" (CPS). Most of the methods of this
+ * library are themselves CPS/Node-style async functions, or functions that
+ * return CPS/Node-style async functions.
+ *
+ * Wherever we accept a Node-style async function, we also directly accept an
+ * [ES2017 `async` function]{@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function}.
+ * In this case, the `async` function will not be passed a final callback
+ * argument, and any thrown error will be used as the `err` argument of the
+ * implicit callback, and the return value will be used as the `result` value.
+ * (i.e. a `rejected` of the returned Promise becomes the `err` callback
+ * argument, and a `resolved` value becomes the `result`.)
+ *
+ * Note, due to JavaScript limitations, we can only detect native `async`
+ * functions and not transpilied implementations.
+ * Your environment must have `async`/`await` support for this to work.
+ * (e.g. Node > v7.6, or a recent version of a modern browser).
+ * If you are using `async` functions through a transpiler (e.g. Babel), you
+ * must still wrap the function with [asyncify]{@link module:Utils.asyncify},
+ * because the `async function` will be compiled to an ordinary function that
+ * returns a promise.
+ *
+ * @typedef {Function} AsyncFunction
+ * @static
+ */
+
+/**
+ * Async is a utility module which provides straight-forward, powerful functions
+ * for working with asynchronous JavaScript. Although originally designed for
+ * use with [Node.js](http://nodejs.org) and installable via
+ * `npm install --save async`, it can also be used directly in the browser.
+ * @module async
+ * @see AsyncFunction
+ */
+
+/**
+ * A collection of `async` functions for manipulating collections, such as
+ * arrays and objects.
+ * @module Collections
+ */
+
+/**
+ * A collection of `async` functions for controlling the flow through a script.
+ * @module ControlFlow
+ */
+
+/**
+ * A collection of `async` utility functions.
+ * @module Utils
+ */
+
+exports.apply = _apply2.default;
+exports.applyEach = _applyEach2.default;
+exports.applyEachSeries = _applyEachSeries2.default;
+exports.asyncify = _asyncify2.default;
+exports.auto = _auto2.default;
+exports.autoInject = _autoInject2.default;
+exports.cargo = _cargo2.default;
+exports.compose = _compose2.default;
+exports.concat = _concat2.default;
+exports.concatLimit = _concatLimit2.default;
+exports.concatSeries = _concatSeries2.default;
+exports.constant = _constant2.default;
+exports.detect = _detect2.default;
+exports.detectLimit = _detectLimit2.default;
+exports.detectSeries = _detectSeries2.default;
+exports.dir = _dir2.default;
+exports.doDuring = _doDuring2.default;
+exports.doUntil = _doUntil2.default;
+exports.doWhilst = _doWhilst2.default;
+exports.during = _during2.default;
+exports.each = _each2.default;
+exports.eachLimit = _eachLimit2.default;
+exports.eachOf = _eachOf2.default;
+exports.eachOfLimit = _eachOfLimit2.default;
+exports.eachOfSeries = _eachOfSeries2.default;
+exports.eachSeries = _eachSeries2.default;
+exports.ensureAsync = _ensureAsync2.default;
+exports.every = _every2.default;
+exports.everyLimit = _everyLimit2.default;
+exports.everySeries = _everySeries2.default;
+exports.filter = _filter2.default;
+exports.filterLimit = _filterLimit2.default;
+exports.filterSeries = _filterSeries2.default;
+exports.forever = _forever2.default;
+exports.groupBy = _groupBy2.default;
+exports.groupByLimit = _groupByLimit2.default;
+exports.groupBySeries = _groupBySeries2.default;
+exports.log = _log2.default;
+exports.map = _map2.default;
+exports.mapLimit = _mapLimit2.default;
+exports.mapSeries = _mapSeries2.default;
+exports.mapValues = _mapValues2.default;
+exports.mapValuesLimit = _mapValuesLimit2.default;
+exports.mapValuesSeries = _mapValuesSeries2.default;
+exports.memoize = _memoize2.default;
+exports.nextTick = _nextTick2.default;
+exports.parallel = _parallel2.default;
+exports.parallelLimit = _parallelLimit2.default;
+exports.priorityQueue = _priorityQueue2.default;
+exports.queue = _queue2.default;
+exports.race = _race2.default;
+exports.reduce = _reduce2.default;
+exports.reduceRight = _reduceRight2.default;
+exports.reflect = _reflect2.default;
+exports.reflectAll = _reflectAll2.default;
+exports.reject = _reject2.default;
+exports.rejectLimit = _rejectLimit2.default;
+exports.rejectSeries = _rejectSeries2.default;
+exports.retry = _retry2.default;
+exports.retryable = _retryable2.default;
+exports.seq = _seq2.default;
+exports.series = _series2.default;
+exports.setImmediate = _setImmediate2.default;
+exports.some = _some2.default;
+exports.someLimit = _someLimit2.default;
+exports.someSeries = _someSeries2.default;
+exports.sortBy = _sortBy2.default;
+exports.timeout = _timeout2.default;
+exports.times = _times2.default;
+exports.timesLimit = _timesLimit2.default;
+exports.timesSeries = _timesSeries2.default;
+exports.transform = _transform2.default;
+exports.tryEach = _tryEach2.default;
+exports.unmemoize = _unmemoize2.default;
+exports.until = _until2.default;
+exports.waterfall = _waterfall2.default;
+exports.whilst = _whilst2.default;
+exports.all = _every2.default;
+exports.allLimit = _everyLimit2.default;
+exports.allSeries = _everySeries2.default;
+exports.any = _some2.default;
+exports.anyLimit = _someLimit2.default;
+exports.anySeries = _someSeries2.default;
+exports.find = _detect2.default;
+exports.findLimit = _detectLimit2.default;
+exports.findSeries = _detectSeries2.default;
+exports.forEach = _each2.default;
+exports.forEachSeries = _eachSeries2.default;
+exports.forEachLimit = _eachLimit2.default;
+exports.forEachOf = _eachOf2.default;
+exports.forEachOfSeries = _eachOfSeries2.default;
+exports.forEachOfLimit = _eachOfLimit2.default;
+exports.inject = _reduce2.default;
+exports.foldl = _reduce2.default;
+exports.foldr = _reduceRight2.default;
+exports.select = _filter2.default;
+exports.selectLimit = _filterLimit2.default;
+exports.selectSeries = _filterSeries2.default;
+exports.wrapSync = _asyncify2.default;
\ No newline at end of file
diff --git a/node_modules/@pm2/js-api/node_modules/async/inject.js b/node_modules/@pm2/js-api/node_modules/async/inject.js
new file mode 100644
index 0000000..3fb8019
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/async/inject.js
@@ -0,0 +1,78 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = reduce;
+
+var _eachOfSeries = require('./eachOfSeries');
+
+var _eachOfSeries2 = _interopRequireDefault(_eachOfSeries);
+
+var _noop = require('lodash/noop');
+
+var _noop2 = _interopRequireDefault(_noop);
+
+var _once = require('./internal/once');
+
+var _once2 = _interopRequireDefault(_once);
+
+var _wrapAsync = require('./internal/wrapAsync');
+
+var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * Reduces `coll` into a single value using an async `iteratee` to return each
+ * successive step. `memo` is the initial state of the reduction. This function
+ * only operates in series.
+ *
+ * For performance reasons, it may make sense to split a call to this function
+ * into a parallel map, and then use the normal `Array.prototype.reduce` on the
+ * results. This function is for situations where each step in the reduction
+ * needs to be async; if you can get the data before reducing it, then it's
+ * probably a good idea to do so.
+ *
+ * @name reduce
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @alias inject
+ * @alias foldl
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {*} memo - The initial state of the reduction.
+ * @param {AsyncFunction} iteratee - A function applied to each item in the
+ * array to produce the next step in the reduction.
+ * The `iteratee` should complete with the next state of the reduction.
+ * If the iteratee complete with an error, the reduction is stopped and the
+ * main `callback` is immediately called with the error.
+ * Invoked with (memo, item, callback).
+ * @param {Function} [callback] - A callback which is called after all the
+ * `iteratee` functions have finished. Result is the reduced value. Invoked with
+ * (err, result).
+ * @example
+ *
+ * async.reduce([1,2,3], 0, function(memo, item, callback) {
+ * // pointless async:
+ * process.nextTick(function() {
+ * callback(null, memo + item)
+ * });
+ * }, function(err, result) {
+ * // result is now equal to the last value of memo, which is 6
+ * });
+ */
+function reduce(coll, memo, iteratee, callback) {
+ callback = (0, _once2.default)(callback || _noop2.default);
+ var _iteratee = (0, _wrapAsync2.default)(iteratee);
+ (0, _eachOfSeries2.default)(coll, function (x, i, callback) {
+ _iteratee(memo, x, function (err, v) {
+ memo = v;
+ callback(err);
+ });
+ }, function (err) {
+ callback(err, memo);
+ });
+}
+module.exports = exports['default'];
\ No newline at end of file
diff --git a/node_modules/@pm2/js-api/node_modules/async/internal/DoublyLinkedList.js b/node_modules/@pm2/js-api/node_modules/async/internal/DoublyLinkedList.js
new file mode 100644
index 0000000..7e71728
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/async/internal/DoublyLinkedList.js
@@ -0,0 +1,88 @@
+"use strict";
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = DLL;
+// Simple doubly linked list (https://en.wikipedia.org/wiki/Doubly_linked_list) implementation
+// used for queues. This implementation assumes that the node provided by the user can be modified
+// to adjust the next and last properties. We implement only the minimal functionality
+// for queue support.
+function DLL() {
+ this.head = this.tail = null;
+ this.length = 0;
+}
+
+function setInitial(dll, node) {
+ dll.length = 1;
+ dll.head = dll.tail = node;
+}
+
+DLL.prototype.removeLink = function (node) {
+ if (node.prev) node.prev.next = node.next;else this.head = node.next;
+ if (node.next) node.next.prev = node.prev;else this.tail = node.prev;
+
+ node.prev = node.next = null;
+ this.length -= 1;
+ return node;
+};
+
+DLL.prototype.empty = function () {
+ while (this.head) this.shift();
+ return this;
+};
+
+DLL.prototype.insertAfter = function (node, newNode) {
+ newNode.prev = node;
+ newNode.next = node.next;
+ if (node.next) node.next.prev = newNode;else this.tail = newNode;
+ node.next = newNode;
+ this.length += 1;
+};
+
+DLL.prototype.insertBefore = function (node, newNode) {
+ newNode.prev = node.prev;
+ newNode.next = node;
+ if (node.prev) node.prev.next = newNode;else this.head = newNode;
+ node.prev = newNode;
+ this.length += 1;
+};
+
+DLL.prototype.unshift = function (node) {
+ if (this.head) this.insertBefore(this.head, node);else setInitial(this, node);
+};
+
+DLL.prototype.push = function (node) {
+ if (this.tail) this.insertAfter(this.tail, node);else setInitial(this, node);
+};
+
+DLL.prototype.shift = function () {
+ return this.head && this.removeLink(this.head);
+};
+
+DLL.prototype.pop = function () {
+ return this.tail && this.removeLink(this.tail);
+};
+
+DLL.prototype.toArray = function () {
+ var arr = Array(this.length);
+ var curr = this.head;
+ for (var idx = 0; idx < this.length; idx++) {
+ arr[idx] = curr.data;
+ curr = curr.next;
+ }
+ return arr;
+};
+
+DLL.prototype.remove = function (testFn) {
+ var curr = this.head;
+ while (!!curr) {
+ var next = curr.next;
+ if (testFn(curr)) {
+ this.removeLink(curr);
+ }
+ curr = next;
+ }
+ return this;
+};
+module.exports = exports["default"];
\ No newline at end of file
diff --git a/node_modules/@pm2/js-api/node_modules/async/internal/applyEach.js b/node_modules/@pm2/js-api/node_modules/async/internal/applyEach.js
new file mode 100644
index 0000000..322e03c
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/async/internal/applyEach.js
@@ -0,0 +1,38 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = applyEach;
+
+var _slice = require('./slice');
+
+var _slice2 = _interopRequireDefault(_slice);
+
+var _initialParams = require('./initialParams');
+
+var _initialParams2 = _interopRequireDefault(_initialParams);
+
+var _wrapAsync = require('./wrapAsync');
+
+var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+function applyEach(eachfn) {
+ return function (fns /*, ...args*/) {
+ var args = (0, _slice2.default)(arguments, 1);
+ var go = (0, _initialParams2.default)(function (args, callback) {
+ var that = this;
+ return eachfn(fns, function (fn, cb) {
+ (0, _wrapAsync2.default)(fn).apply(that, args.concat(cb));
+ }, callback);
+ });
+ if (args.length) {
+ return go.apply(this, args);
+ } else {
+ return go;
+ }
+ };
+}
+module.exports = exports['default'];
\ No newline at end of file
diff --git a/node_modules/@pm2/js-api/node_modules/async/internal/breakLoop.js b/node_modules/@pm2/js-api/node_modules/async/internal/breakLoop.js
new file mode 100644
index 0000000..1065058
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/async/internal/breakLoop.js
@@ -0,0 +1,9 @@
+"use strict";
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+// A temporary value used to identify if the loop should be broken.
+// See #1064, #1293
+exports.default = {};
+module.exports = exports["default"];
\ No newline at end of file
diff --git a/node_modules/@pm2/js-api/node_modules/async/internal/consoleFunc.js b/node_modules/@pm2/js-api/node_modules/async/internal/consoleFunc.js
new file mode 100644
index 0000000..603f48e
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/async/internal/consoleFunc.js
@@ -0,0 +1,42 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = consoleFunc;
+
+var _arrayEach = require('lodash/_arrayEach');
+
+var _arrayEach2 = _interopRequireDefault(_arrayEach);
+
+var _slice = require('./slice');
+
+var _slice2 = _interopRequireDefault(_slice);
+
+var _wrapAsync = require('./wrapAsync');
+
+var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+function consoleFunc(name) {
+ return function (fn /*, ...args*/) {
+ var args = (0, _slice2.default)(arguments, 1);
+ args.push(function (err /*, ...args*/) {
+ var args = (0, _slice2.default)(arguments, 1);
+ if (typeof console === 'object') {
+ if (err) {
+ if (console.error) {
+ console.error(err);
+ }
+ } else if (console[name]) {
+ (0, _arrayEach2.default)(args, function (x) {
+ console[name](x);
+ });
+ }
+ }
+ });
+ (0, _wrapAsync2.default)(fn).apply(null, args);
+ };
+}
+module.exports = exports['default'];
\ No newline at end of file
diff --git a/node_modules/@pm2/js-api/node_modules/async/internal/createTester.js b/node_modules/@pm2/js-api/node_modules/async/internal/createTester.js
new file mode 100644
index 0000000..ce96e8b
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/async/internal/createTester.js
@@ -0,0 +1,44 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = _createTester;
+
+var _noop = require('lodash/noop');
+
+var _noop2 = _interopRequireDefault(_noop);
+
+var _breakLoop = require('./breakLoop');
+
+var _breakLoop2 = _interopRequireDefault(_breakLoop);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+function _createTester(check, getResult) {
+ return function (eachfn, arr, iteratee, cb) {
+ cb = cb || _noop2.default;
+ var testPassed = false;
+ var testResult;
+ eachfn(arr, function (value, _, callback) {
+ iteratee(value, function (err, result) {
+ if (err) {
+ callback(err);
+ } else if (check(result) && !testResult) {
+ testPassed = true;
+ testResult = getResult(true, value);
+ callback(null, _breakLoop2.default);
+ } else {
+ callback();
+ }
+ });
+ }, function (err) {
+ if (err) {
+ cb(err);
+ } else {
+ cb(null, testPassed ? testResult : getResult(false));
+ }
+ });
+ };
+}
+module.exports = exports['default'];
\ No newline at end of file
diff --git a/node_modules/@pm2/js-api/node_modules/async/internal/doLimit.js b/node_modules/@pm2/js-api/node_modules/async/internal/doLimit.js
new file mode 100644
index 0000000..963c608
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/async/internal/doLimit.js
@@ -0,0 +1,12 @@
+"use strict";
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = doLimit;
+function doLimit(fn, limit) {
+ return function (iterable, iteratee, callback) {
+ return fn(iterable, limit, iteratee, callback);
+ };
+}
+module.exports = exports["default"];
\ No newline at end of file
diff --git a/node_modules/@pm2/js-api/node_modules/async/internal/doParallel.js b/node_modules/@pm2/js-api/node_modules/async/internal/doParallel.js
new file mode 100644
index 0000000..bb40207
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/async/internal/doParallel.js
@@ -0,0 +1,23 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = doParallel;
+
+var _eachOf = require('../eachOf');
+
+var _eachOf2 = _interopRequireDefault(_eachOf);
+
+var _wrapAsync = require('./wrapAsync');
+
+var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+function doParallel(fn) {
+ return function (obj, iteratee, callback) {
+ return fn(_eachOf2.default, obj, (0, _wrapAsync2.default)(iteratee), callback);
+ };
+}
+module.exports = exports['default'];
\ No newline at end of file
diff --git a/node_modules/@pm2/js-api/node_modules/async/internal/doParallelLimit.js b/node_modules/@pm2/js-api/node_modules/async/internal/doParallelLimit.js
new file mode 100644
index 0000000..a7e963d
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/async/internal/doParallelLimit.js
@@ -0,0 +1,23 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = doParallelLimit;
+
+var _eachOfLimit = require('./eachOfLimit');
+
+var _eachOfLimit2 = _interopRequireDefault(_eachOfLimit);
+
+var _wrapAsync = require('./wrapAsync');
+
+var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+function doParallelLimit(fn) {
+ return function (obj, limit, iteratee, callback) {
+ return fn((0, _eachOfLimit2.default)(limit), obj, (0, _wrapAsync2.default)(iteratee), callback);
+ };
+}
+module.exports = exports['default'];
\ No newline at end of file
diff --git a/node_modules/@pm2/js-api/node_modules/async/internal/eachOfLimit.js b/node_modules/@pm2/js-api/node_modules/async/internal/eachOfLimit.js
new file mode 100644
index 0000000..6f6fe55
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/async/internal/eachOfLimit.js
@@ -0,0 +1,74 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = _eachOfLimit;
+
+var _noop = require('lodash/noop');
+
+var _noop2 = _interopRequireDefault(_noop);
+
+var _once = require('./once');
+
+var _once2 = _interopRequireDefault(_once);
+
+var _iterator = require('./iterator');
+
+var _iterator2 = _interopRequireDefault(_iterator);
+
+var _onlyOnce = require('./onlyOnce');
+
+var _onlyOnce2 = _interopRequireDefault(_onlyOnce);
+
+var _breakLoop = require('./breakLoop');
+
+var _breakLoop2 = _interopRequireDefault(_breakLoop);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+function _eachOfLimit(limit) {
+ return function (obj, iteratee, callback) {
+ callback = (0, _once2.default)(callback || _noop2.default);
+ if (limit <= 0 || !obj) {
+ return callback(null);
+ }
+ var nextElem = (0, _iterator2.default)(obj);
+ var done = false;
+ var running = 0;
+ var looping = false;
+
+ function iterateeCallback(err, value) {
+ running -= 1;
+ if (err) {
+ done = true;
+ callback(err);
+ } else if (value === _breakLoop2.default || done && running <= 0) {
+ done = true;
+ return callback(null);
+ } else if (!looping) {
+ replenish();
+ }
+ }
+
+ function replenish() {
+ looping = true;
+ while (running < limit && !done) {
+ var elem = nextElem();
+ if (elem === null) {
+ done = true;
+ if (running <= 0) {
+ callback(null);
+ }
+ return;
+ }
+ running += 1;
+ iteratee(elem.value, elem.key, (0, _onlyOnce2.default)(iterateeCallback));
+ }
+ looping = false;
+ }
+
+ replenish();
+ };
+}
+module.exports = exports['default'];
\ No newline at end of file
diff --git a/node_modules/@pm2/js-api/node_modules/async/internal/filter.js b/node_modules/@pm2/js-api/node_modules/async/internal/filter.js
new file mode 100644
index 0000000..74f3986
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/async/internal/filter.js
@@ -0,0 +1,75 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = _filter;
+
+var _arrayMap = require('lodash/_arrayMap');
+
+var _arrayMap2 = _interopRequireDefault(_arrayMap);
+
+var _isArrayLike = require('lodash/isArrayLike');
+
+var _isArrayLike2 = _interopRequireDefault(_isArrayLike);
+
+var _baseProperty = require('lodash/_baseProperty');
+
+var _baseProperty2 = _interopRequireDefault(_baseProperty);
+
+var _noop = require('lodash/noop');
+
+var _noop2 = _interopRequireDefault(_noop);
+
+var _wrapAsync = require('./wrapAsync');
+
+var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+function filterArray(eachfn, arr, iteratee, callback) {
+ var truthValues = new Array(arr.length);
+ eachfn(arr, function (x, index, callback) {
+ iteratee(x, function (err, v) {
+ truthValues[index] = !!v;
+ callback(err);
+ });
+ }, function (err) {
+ if (err) return callback(err);
+ var results = [];
+ for (var i = 0; i < arr.length; i++) {
+ if (truthValues[i]) results.push(arr[i]);
+ }
+ callback(null, results);
+ });
+}
+
+function filterGeneric(eachfn, coll, iteratee, callback) {
+ var results = [];
+ eachfn(coll, function (x, index, callback) {
+ iteratee(x, function (err, v) {
+ if (err) {
+ callback(err);
+ } else {
+ if (v) {
+ results.push({ index: index, value: x });
+ }
+ callback();
+ }
+ });
+ }, function (err) {
+ if (err) {
+ callback(err);
+ } else {
+ callback(null, (0, _arrayMap2.default)(results.sort(function (a, b) {
+ return a.index - b.index;
+ }), (0, _baseProperty2.default)('value')));
+ }
+ });
+}
+
+function _filter(eachfn, coll, iteratee, callback) {
+ var filter = (0, _isArrayLike2.default)(coll) ? filterArray : filterGeneric;
+ filter(eachfn, coll, (0, _wrapAsync2.default)(iteratee), callback || _noop2.default);
+}
+module.exports = exports['default'];
\ No newline at end of file
diff --git a/node_modules/@pm2/js-api/node_modules/async/internal/findGetResult.js b/node_modules/@pm2/js-api/node_modules/async/internal/findGetResult.js
new file mode 100644
index 0000000..f8d3fe0
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/async/internal/findGetResult.js
@@ -0,0 +1,10 @@
+"use strict";
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = _findGetResult;
+function _findGetResult(v, x) {
+ return x;
+}
+module.exports = exports["default"];
\ No newline at end of file
diff --git a/node_modules/@pm2/js-api/node_modules/async/internal/getIterator.js b/node_modules/@pm2/js-api/node_modules/async/internal/getIterator.js
new file mode 100644
index 0000000..3eadd24
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/async/internal/getIterator.js
@@ -0,0 +1,13 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+exports.default = function (coll) {
+ return iteratorSymbol && coll[iteratorSymbol] && coll[iteratorSymbol]();
+};
+
+var iteratorSymbol = typeof Symbol === 'function' && Symbol.iterator;
+
+module.exports = exports['default'];
\ No newline at end of file
diff --git a/node_modules/@pm2/js-api/node_modules/async/internal/initialParams.js b/node_modules/@pm2/js-api/node_modules/async/internal/initialParams.js
new file mode 100644
index 0000000..df02cb1
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/async/internal/initialParams.js
@@ -0,0 +1,21 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+exports.default = function (fn) {
+ return function () /*...args, callback*/{
+ var args = (0, _slice2.default)(arguments);
+ var callback = args.pop();
+ fn.call(this, args, callback);
+ };
+};
+
+var _slice = require('./slice');
+
+var _slice2 = _interopRequireDefault(_slice);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+module.exports = exports['default'];
\ No newline at end of file
diff --git a/node_modules/@pm2/js-api/node_modules/async/internal/iterator.js b/node_modules/@pm2/js-api/node_modules/async/internal/iterator.js
new file mode 100644
index 0000000..886beb5
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/async/internal/iterator.js
@@ -0,0 +1,61 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = iterator;
+
+var _isArrayLike = require('lodash/isArrayLike');
+
+var _isArrayLike2 = _interopRequireDefault(_isArrayLike);
+
+var _getIterator = require('./getIterator');
+
+var _getIterator2 = _interopRequireDefault(_getIterator);
+
+var _keys = require('lodash/keys');
+
+var _keys2 = _interopRequireDefault(_keys);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+function createArrayIterator(coll) {
+ var i = -1;
+ var len = coll.length;
+ return function next() {
+ return ++i < len ? { value: coll[i], key: i } : null;
+ };
+}
+
+function createES2015Iterator(iterator) {
+ var i = -1;
+ return function next() {
+ var item = iterator.next();
+ if (item.done) return null;
+ i++;
+ return { value: item.value, key: i };
+ };
+}
+
+function createObjectIterator(obj) {
+ var okeys = (0, _keys2.default)(obj);
+ var i = -1;
+ var len = okeys.length;
+ return function next() {
+ var key = okeys[++i];
+ if (key === '__proto__') {
+ return next();
+ }
+ return i < len ? { value: obj[key], key: key } : null;
+ };
+}
+
+function iterator(coll) {
+ if ((0, _isArrayLike2.default)(coll)) {
+ return createArrayIterator(coll);
+ }
+
+ var iterator = (0, _getIterator2.default)(coll);
+ return iterator ? createES2015Iterator(iterator) : createObjectIterator(coll);
+}
+module.exports = exports['default'];
\ No newline at end of file
diff --git a/node_modules/@pm2/js-api/node_modules/async/internal/map.js b/node_modules/@pm2/js-api/node_modules/async/internal/map.js
new file mode 100644
index 0000000..f4f2aa5
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/async/internal/map.js
@@ -0,0 +1,35 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = _asyncMap;
+
+var _noop = require('lodash/noop');
+
+var _noop2 = _interopRequireDefault(_noop);
+
+var _wrapAsync = require('./wrapAsync');
+
+var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+function _asyncMap(eachfn, arr, iteratee, callback) {
+ callback = callback || _noop2.default;
+ arr = arr || [];
+ var results = [];
+ var counter = 0;
+ var _iteratee = (0, _wrapAsync2.default)(iteratee);
+
+ eachfn(arr, function (value, _, callback) {
+ var index = counter++;
+ _iteratee(value, function (err, v) {
+ results[index] = v;
+ callback(err);
+ });
+ }, function (err) {
+ callback(err, results);
+ });
+}
+module.exports = exports['default'];
\ No newline at end of file
diff --git a/node_modules/@pm2/js-api/node_modules/async/internal/notId.js b/node_modules/@pm2/js-api/node_modules/async/internal/notId.js
new file mode 100644
index 0000000..0106c92
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/async/internal/notId.js
@@ -0,0 +1,10 @@
+"use strict";
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = notId;
+function notId(v) {
+ return !v;
+}
+module.exports = exports["default"];
\ No newline at end of file
diff --git a/node_modules/@pm2/js-api/node_modules/async/internal/once.js b/node_modules/@pm2/js-api/node_modules/async/internal/once.js
new file mode 100644
index 0000000..f0c379f
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/async/internal/once.js
@@ -0,0 +1,15 @@
+"use strict";
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = once;
+function once(fn) {
+ return function () {
+ if (fn === null) return;
+ var callFn = fn;
+ fn = null;
+ callFn.apply(this, arguments);
+ };
+}
+module.exports = exports["default"];
\ No newline at end of file
diff --git a/node_modules/@pm2/js-api/node_modules/async/internal/onlyOnce.js b/node_modules/@pm2/js-api/node_modules/async/internal/onlyOnce.js
new file mode 100644
index 0000000..f2e3001
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/async/internal/onlyOnce.js
@@ -0,0 +1,15 @@
+"use strict";
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = onlyOnce;
+function onlyOnce(fn) {
+ return function () {
+ if (fn === null) throw new Error("Callback was already called.");
+ var callFn = fn;
+ fn = null;
+ callFn.apply(this, arguments);
+ };
+}
+module.exports = exports["default"];
\ No newline at end of file
diff --git a/node_modules/@pm2/js-api/node_modules/async/internal/parallel.js b/node_modules/@pm2/js-api/node_modules/async/internal/parallel.js
new file mode 100644
index 0000000..c97293b
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/async/internal/parallel.js
@@ -0,0 +1,42 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = _parallel;
+
+var _noop = require('lodash/noop');
+
+var _noop2 = _interopRequireDefault(_noop);
+
+var _isArrayLike = require('lodash/isArrayLike');
+
+var _isArrayLike2 = _interopRequireDefault(_isArrayLike);
+
+var _slice = require('./slice');
+
+var _slice2 = _interopRequireDefault(_slice);
+
+var _wrapAsync = require('./wrapAsync');
+
+var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+function _parallel(eachfn, tasks, callback) {
+ callback = callback || _noop2.default;
+ var results = (0, _isArrayLike2.default)(tasks) ? [] : {};
+
+ eachfn(tasks, function (task, key, callback) {
+ (0, _wrapAsync2.default)(task)(function (err, result) {
+ if (arguments.length > 2) {
+ result = (0, _slice2.default)(arguments, 1);
+ }
+ results[key] = result;
+ callback(err);
+ });
+ }, function (err) {
+ callback(err, results);
+ });
+}
+module.exports = exports['default'];
\ No newline at end of file
diff --git a/node_modules/@pm2/js-api/node_modules/async/internal/queue.js b/node_modules/@pm2/js-api/node_modules/async/internal/queue.js
new file mode 100644
index 0000000..19534a7
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/async/internal/queue.js
@@ -0,0 +1,204 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = queue;
+
+var _baseIndexOf = require('lodash/_baseIndexOf');
+
+var _baseIndexOf2 = _interopRequireDefault(_baseIndexOf);
+
+var _isArray = require('lodash/isArray');
+
+var _isArray2 = _interopRequireDefault(_isArray);
+
+var _noop = require('lodash/noop');
+
+var _noop2 = _interopRequireDefault(_noop);
+
+var _onlyOnce = require('./onlyOnce');
+
+var _onlyOnce2 = _interopRequireDefault(_onlyOnce);
+
+var _setImmediate = require('./setImmediate');
+
+var _setImmediate2 = _interopRequireDefault(_setImmediate);
+
+var _DoublyLinkedList = require('./DoublyLinkedList');
+
+var _DoublyLinkedList2 = _interopRequireDefault(_DoublyLinkedList);
+
+var _wrapAsync = require('./wrapAsync');
+
+var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+function queue(worker, concurrency, payload) {
+ if (concurrency == null) {
+ concurrency = 1;
+ } else if (concurrency === 0) {
+ throw new Error('Concurrency must not be zero');
+ }
+
+ var _worker = (0, _wrapAsync2.default)(worker);
+ var numRunning = 0;
+ var workersList = [];
+
+ var processingScheduled = false;
+ function _insert(data, insertAtFront, callback) {
+ if (callback != null && typeof callback !== 'function') {
+ throw new Error('task callback must be a function');
+ }
+ q.started = true;
+ if (!(0, _isArray2.default)(data)) {
+ data = [data];
+ }
+ if (data.length === 0 && q.idle()) {
+ // call drain immediately if there are no tasks
+ return (0, _setImmediate2.default)(function () {
+ q.drain();
+ });
+ }
+
+ for (var i = 0, l = data.length; i < l; i++) {
+ var item = {
+ data: data[i],
+ callback: callback || _noop2.default
+ };
+
+ if (insertAtFront) {
+ q._tasks.unshift(item);
+ } else {
+ q._tasks.push(item);
+ }
+ }
+
+ if (!processingScheduled) {
+ processingScheduled = true;
+ (0, _setImmediate2.default)(function () {
+ processingScheduled = false;
+ q.process();
+ });
+ }
+ }
+
+ function _next(tasks) {
+ return function (err) {
+ numRunning -= 1;
+
+ for (var i = 0, l = tasks.length; i < l; i++) {
+ var task = tasks[i];
+
+ var index = (0, _baseIndexOf2.default)(workersList, task, 0);
+ if (index === 0) {
+ workersList.shift();
+ } else if (index > 0) {
+ workersList.splice(index, 1);
+ }
+
+ task.callback.apply(task, arguments);
+
+ if (err != null) {
+ q.error(err, task.data);
+ }
+ }
+
+ if (numRunning <= q.concurrency - q.buffer) {
+ q.unsaturated();
+ }
+
+ if (q.idle()) {
+ q.drain();
+ }
+ q.process();
+ };
+ }
+
+ var isProcessing = false;
+ var q = {
+ _tasks: new _DoublyLinkedList2.default(),
+ concurrency: concurrency,
+ payload: payload,
+ saturated: _noop2.default,
+ unsaturated: _noop2.default,
+ buffer: concurrency / 4,
+ empty: _noop2.default,
+ drain: _noop2.default,
+ error: _noop2.default,
+ started: false,
+ paused: false,
+ push: function (data, callback) {
+ _insert(data, false, callback);
+ },
+ kill: function () {
+ q.drain = _noop2.default;
+ q._tasks.empty();
+ },
+ unshift: function (data, callback) {
+ _insert(data, true, callback);
+ },
+ remove: function (testFn) {
+ q._tasks.remove(testFn);
+ },
+ process: function () {
+ // Avoid trying to start too many processing operations. This can occur
+ // when callbacks resolve synchronously (#1267).
+ if (isProcessing) {
+ return;
+ }
+ isProcessing = true;
+ while (!q.paused && numRunning < q.concurrency && q._tasks.length) {
+ var tasks = [],
+ data = [];
+ var l = q._tasks.length;
+ if (q.payload) l = Math.min(l, q.payload);
+ for (var i = 0; i < l; i++) {
+ var node = q._tasks.shift();
+ tasks.push(node);
+ workersList.push(node);
+ data.push(node.data);
+ }
+
+ numRunning += 1;
+
+ if (q._tasks.length === 0) {
+ q.empty();
+ }
+
+ if (numRunning === q.concurrency) {
+ q.saturated();
+ }
+
+ var cb = (0, _onlyOnce2.default)(_next(tasks));
+ _worker(data, cb);
+ }
+ isProcessing = false;
+ },
+ length: function () {
+ return q._tasks.length;
+ },
+ running: function () {
+ return numRunning;
+ },
+ workersList: function () {
+ return workersList;
+ },
+ idle: function () {
+ return q._tasks.length + numRunning === 0;
+ },
+ pause: function () {
+ q.paused = true;
+ },
+ resume: function () {
+ if (q.paused === false) {
+ return;
+ }
+ q.paused = false;
+ (0, _setImmediate2.default)(q.process);
+ }
+ };
+ return q;
+}
+module.exports = exports['default'];
\ No newline at end of file
diff --git a/node_modules/@pm2/js-api/node_modules/async/internal/reject.js b/node_modules/@pm2/js-api/node_modules/async/internal/reject.js
new file mode 100644
index 0000000..5dbfcfb
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/async/internal/reject.js
@@ -0,0 +1,21 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = reject;
+
+var _filter = require('./filter');
+
+var _filter2 = _interopRequireDefault(_filter);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+function reject(eachfn, arr, iteratee, callback) {
+ (0, _filter2.default)(eachfn, arr, function (value, cb) {
+ iteratee(value, function (err, v) {
+ cb(err, !v);
+ });
+ }, callback);
+}
+module.exports = exports['default'];
\ No newline at end of file
diff --git a/node_modules/@pm2/js-api/node_modules/async/internal/setImmediate.js b/node_modules/@pm2/js-api/node_modules/async/internal/setImmediate.js
new file mode 100644
index 0000000..3545f2b
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/async/internal/setImmediate.js
@@ -0,0 +1,42 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.hasNextTick = exports.hasSetImmediate = undefined;
+exports.fallback = fallback;
+exports.wrap = wrap;
+
+var _slice = require('./slice');
+
+var _slice2 = _interopRequireDefault(_slice);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+var hasSetImmediate = exports.hasSetImmediate = typeof setImmediate === 'function' && setImmediate;
+var hasNextTick = exports.hasNextTick = typeof process === 'object' && typeof process.nextTick === 'function';
+
+function fallback(fn) {
+ setTimeout(fn, 0);
+}
+
+function wrap(defer) {
+ return function (fn /*, ...args*/) {
+ var args = (0, _slice2.default)(arguments, 1);
+ defer(function () {
+ fn.apply(null, args);
+ });
+ };
+}
+
+var _defer;
+
+if (hasSetImmediate) {
+ _defer = setImmediate;
+} else if (hasNextTick) {
+ _defer = process.nextTick;
+} else {
+ _defer = fallback;
+}
+
+exports.default = wrap(_defer);
\ No newline at end of file
diff --git a/node_modules/@pm2/js-api/node_modules/async/internal/slice.js b/node_modules/@pm2/js-api/node_modules/async/internal/slice.js
new file mode 100644
index 0000000..56f10c0
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/async/internal/slice.js
@@ -0,0 +1,16 @@
+"use strict";
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = slice;
+function slice(arrayLike, start) {
+ start = start | 0;
+ var newLen = Math.max(arrayLike.length - start, 0);
+ var newArr = Array(newLen);
+ for (var idx = 0; idx < newLen; idx++) {
+ newArr[idx] = arrayLike[start + idx];
+ }
+ return newArr;
+}
+module.exports = exports["default"];
\ No newline at end of file
diff --git a/node_modules/@pm2/js-api/node_modules/async/internal/withoutIndex.js b/node_modules/@pm2/js-api/node_modules/async/internal/withoutIndex.js
new file mode 100644
index 0000000..2bd3579
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/async/internal/withoutIndex.js
@@ -0,0 +1,12 @@
+"use strict";
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = _withoutIndex;
+function _withoutIndex(iteratee) {
+ return function (value, index, callback) {
+ return iteratee(value, callback);
+ };
+}
+module.exports = exports["default"];
\ No newline at end of file
diff --git a/node_modules/@pm2/js-api/node_modules/async/internal/wrapAsync.js b/node_modules/@pm2/js-api/node_modules/async/internal/wrapAsync.js
new file mode 100644
index 0000000..bc6c966
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/async/internal/wrapAsync.js
@@ -0,0 +1,25 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.isAsync = undefined;
+
+var _asyncify = require('../asyncify');
+
+var _asyncify2 = _interopRequireDefault(_asyncify);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+var supportsSymbol = typeof Symbol === 'function';
+
+function isAsync(fn) {
+ return supportsSymbol && fn[Symbol.toStringTag] === 'AsyncFunction';
+}
+
+function wrapAsync(asyncFn) {
+ return isAsync(asyncFn) ? (0, _asyncify2.default)(asyncFn) : asyncFn;
+}
+
+exports.default = wrapAsync;
+exports.isAsync = isAsync;
\ No newline at end of file
diff --git a/node_modules/@pm2/js-api/node_modules/async/log.js b/node_modules/@pm2/js-api/node_modules/async/log.js
new file mode 100644
index 0000000..c643867
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/async/log.js
@@ -0,0 +1,41 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+var _consoleFunc = require('./internal/consoleFunc');
+
+var _consoleFunc2 = _interopRequireDefault(_consoleFunc);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * Logs the result of an `async` function to the `console`. Only works in
+ * Node.js or in browsers that support `console.log` and `console.error` (such
+ * as FF and Chrome). If multiple arguments are returned from the async
+ * function, `console.log` is called on each argument in order.
+ *
+ * @name log
+ * @static
+ * @memberOf module:Utils
+ * @method
+ * @category Util
+ * @param {AsyncFunction} function - The function you want to eventually apply
+ * all arguments to.
+ * @param {...*} arguments... - Any number of arguments to apply to the function.
+ * @example
+ *
+ * // in a module
+ * var hello = function(name, callback) {
+ * setTimeout(function() {
+ * callback(null, 'hello ' + name);
+ * }, 1000);
+ * };
+ *
+ * // in the node repl
+ * node> async.log(hello, 'world');
+ * 'hello world'
+ */
+exports.default = (0, _consoleFunc2.default)('log');
+module.exports = exports['default'];
\ No newline at end of file
diff --git a/node_modules/@pm2/js-api/node_modules/async/map.js b/node_modules/@pm2/js-api/node_modules/async/map.js
new file mode 100644
index 0000000..67c9cda
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/async/map.js
@@ -0,0 +1,54 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+var _doParallel = require('./internal/doParallel');
+
+var _doParallel2 = _interopRequireDefault(_doParallel);
+
+var _map = require('./internal/map');
+
+var _map2 = _interopRequireDefault(_map);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * Produces a new collection of values by mapping each value in `coll` through
+ * the `iteratee` function. The `iteratee` is called with an item from `coll`
+ * and a callback for when it has finished processing. Each of these callback
+ * takes 2 arguments: an `error`, and the transformed item from `coll`. If
+ * `iteratee` passes an error to its callback, the main `callback` (for the
+ * `map` function) is immediately called with the error.
+ *
+ * Note, that since this function applies the `iteratee` to each item in
+ * parallel, there is no guarantee that the `iteratee` functions will complete
+ * in order. However, the results array will be in the same order as the
+ * original `coll`.
+ *
+ * If `map` is passed an Object, the results will be an Array. The results
+ * will roughly be in the order of the original Objects' keys (but this can
+ * vary across JavaScript engines).
+ *
+ * @name map
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {AsyncFunction} iteratee - An async function to apply to each item in
+ * `coll`.
+ * The iteratee should complete with the transformed item.
+ * Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called when all `iteratee`
+ * functions have finished, or an error occurs. Results is an Array of the
+ * transformed items from the `coll`. Invoked with (err, results).
+ * @example
+ *
+ * async.map(['file1','file2','file3'], fs.stat, function(err, results) {
+ * // results is now an array of stats for each file
+ * });
+ */
+exports.default = (0, _doParallel2.default)(_map2.default);
+module.exports = exports['default'];
\ No newline at end of file
diff --git a/node_modules/@pm2/js-api/node_modules/async/mapLimit.js b/node_modules/@pm2/js-api/node_modules/async/mapLimit.js
new file mode 100644
index 0000000..c8b60d8
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/async/mapLimit.js
@@ -0,0 +1,37 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+var _doParallelLimit = require('./internal/doParallelLimit');
+
+var _doParallelLimit2 = _interopRequireDefault(_doParallelLimit);
+
+var _map = require('./internal/map');
+
+var _map2 = _interopRequireDefault(_map);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * The same as [`map`]{@link module:Collections.map} but runs a maximum of `limit` async operations at a time.
+ *
+ * @name mapLimit
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.map]{@link module:Collections.map}
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {number} limit - The maximum number of async operations at a time.
+ * @param {AsyncFunction} iteratee - An async function to apply to each item in
+ * `coll`.
+ * The iteratee should complete with the transformed item.
+ * Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called when all `iteratee`
+ * functions have finished, or an error occurs. Results is an array of the
+ * transformed items from the `coll`. Invoked with (err, results).
+ */
+exports.default = (0, _doParallelLimit2.default)(_map2.default);
+module.exports = exports['default'];
\ No newline at end of file
diff --git a/node_modules/@pm2/js-api/node_modules/async/mapSeries.js b/node_modules/@pm2/js-api/node_modules/async/mapSeries.js
new file mode 100644
index 0000000..61b42d0
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/async/mapSeries.js
@@ -0,0 +1,36 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+var _mapLimit = require('./mapLimit');
+
+var _mapLimit2 = _interopRequireDefault(_mapLimit);
+
+var _doLimit = require('./internal/doLimit');
+
+var _doLimit2 = _interopRequireDefault(_doLimit);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * The same as [`map`]{@link module:Collections.map} but runs only a single async operation at a time.
+ *
+ * @name mapSeries
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.map]{@link module:Collections.map}
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {AsyncFunction} iteratee - An async function to apply to each item in
+ * `coll`.
+ * The iteratee should complete with the transformed item.
+ * Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called when all `iteratee`
+ * functions have finished, or an error occurs. Results is an array of the
+ * transformed items from the `coll`. Invoked with (err, results).
+ */
+exports.default = (0, _doLimit2.default)(_mapLimit2.default, 1);
+module.exports = exports['default'];
\ No newline at end of file
diff --git a/node_modules/@pm2/js-api/node_modules/async/mapValues.js b/node_modules/@pm2/js-api/node_modules/async/mapValues.js
new file mode 100644
index 0000000..3d838ca
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/async/mapValues.js
@@ -0,0 +1,63 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+var _mapValuesLimit = require('./mapValuesLimit');
+
+var _mapValuesLimit2 = _interopRequireDefault(_mapValuesLimit);
+
+var _doLimit = require('./internal/doLimit');
+
+var _doLimit2 = _interopRequireDefault(_doLimit);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * A relative of [`map`]{@link module:Collections.map}, designed for use with objects.
+ *
+ * Produces a new Object by mapping each value of `obj` through the `iteratee`
+ * function. The `iteratee` is called each `value` and `key` from `obj` and a
+ * callback for when it has finished processing. Each of these callbacks takes
+ * two arguments: an `error`, and the transformed item from `obj`. If `iteratee`
+ * passes an error to its callback, the main `callback` (for the `mapValues`
+ * function) is immediately called with the error.
+ *
+ * Note, the order of the keys in the result is not guaranteed. The keys will
+ * be roughly in the order they complete, (but this is very engine-specific)
+ *
+ * @name mapValues
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @category Collection
+ * @param {Object} obj - A collection to iterate over.
+ * @param {AsyncFunction} iteratee - A function to apply to each value and key
+ * in `coll`.
+ * The iteratee should complete with the transformed value as its result.
+ * Invoked with (value, key, callback).
+ * @param {Function} [callback] - A callback which is called when all `iteratee`
+ * functions have finished, or an error occurs. `result` is a new object consisting
+ * of each key from `obj`, with each transformed value on the right-hand side.
+ * Invoked with (err, result).
+ * @example
+ *
+ * async.mapValues({
+ * f1: 'file1',
+ * f2: 'file2',
+ * f3: 'file3'
+ * }, function (file, key, callback) {
+ * fs.stat(file, callback);
+ * }, function(err, result) {
+ * // result is now a map of stats for each file, e.g.
+ * // {
+ * // f1: [stats for file1],
+ * // f2: [stats for file2],
+ * // f3: [stats for file3]
+ * // }
+ * });
+ */
+
+exports.default = (0, _doLimit2.default)(_mapValuesLimit2.default, Infinity);
+module.exports = exports['default'];
\ No newline at end of file
diff --git a/node_modules/@pm2/js-api/node_modules/async/mapValuesLimit.js b/node_modules/@pm2/js-api/node_modules/async/mapValuesLimit.js
new file mode 100644
index 0000000..912a8b5
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/async/mapValuesLimit.js
@@ -0,0 +1,61 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = mapValuesLimit;
+
+var _eachOfLimit = require('./eachOfLimit');
+
+var _eachOfLimit2 = _interopRequireDefault(_eachOfLimit);
+
+var _noop = require('lodash/noop');
+
+var _noop2 = _interopRequireDefault(_noop);
+
+var _once = require('./internal/once');
+
+var _once2 = _interopRequireDefault(_once);
+
+var _wrapAsync = require('./internal/wrapAsync');
+
+var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * The same as [`mapValues`]{@link module:Collections.mapValues} but runs a maximum of `limit` async operations at a
+ * time.
+ *
+ * @name mapValuesLimit
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.mapValues]{@link module:Collections.mapValues}
+ * @category Collection
+ * @param {Object} obj - A collection to iterate over.
+ * @param {number} limit - The maximum number of async operations at a time.
+ * @param {AsyncFunction} iteratee - A function to apply to each value and key
+ * in `coll`.
+ * The iteratee should complete with the transformed value as its result.
+ * Invoked with (value, key, callback).
+ * @param {Function} [callback] - A callback which is called when all `iteratee`
+ * functions have finished, or an error occurs. `result` is a new object consisting
+ * of each key from `obj`, with each transformed value on the right-hand side.
+ * Invoked with (err, result).
+ */
+function mapValuesLimit(obj, limit, iteratee, callback) {
+ callback = (0, _once2.default)(callback || _noop2.default);
+ var newObj = {};
+ var _iteratee = (0, _wrapAsync2.default)(iteratee);
+ (0, _eachOfLimit2.default)(obj, limit, function (val, key, next) {
+ _iteratee(val, key, function (err, result) {
+ if (err) return next(err);
+ newObj[key] = result;
+ next();
+ });
+ }, function (err) {
+ callback(err, newObj);
+ });
+}
+module.exports = exports['default'];
\ No newline at end of file
diff --git a/node_modules/@pm2/js-api/node_modules/async/mapValuesSeries.js b/node_modules/@pm2/js-api/node_modules/async/mapValuesSeries.js
new file mode 100644
index 0000000..b378c4a
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/async/mapValuesSeries.js
@@ -0,0 +1,37 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+var _mapValuesLimit = require('./mapValuesLimit');
+
+var _mapValuesLimit2 = _interopRequireDefault(_mapValuesLimit);
+
+var _doLimit = require('./internal/doLimit');
+
+var _doLimit2 = _interopRequireDefault(_doLimit);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * The same as [`mapValues`]{@link module:Collections.mapValues} but runs only a single async operation at a time.
+ *
+ * @name mapValuesSeries
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.mapValues]{@link module:Collections.mapValues}
+ * @category Collection
+ * @param {Object} obj - A collection to iterate over.
+ * @param {AsyncFunction} iteratee - A function to apply to each value and key
+ * in `coll`.
+ * The iteratee should complete with the transformed value as its result.
+ * Invoked with (value, key, callback).
+ * @param {Function} [callback] - A callback which is called when all `iteratee`
+ * functions have finished, or an error occurs. `result` is a new object consisting
+ * of each key from `obj`, with each transformed value on the right-hand side.
+ * Invoked with (err, result).
+ */
+exports.default = (0, _doLimit2.default)(_mapValuesLimit2.default, 1);
+module.exports = exports['default'];
\ No newline at end of file
diff --git a/node_modules/@pm2/js-api/node_modules/async/memoize.js b/node_modules/@pm2/js-api/node_modules/async/memoize.js
new file mode 100644
index 0000000..1f2b566
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/async/memoize.js
@@ -0,0 +1,101 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = memoize;
+
+var _identity = require('lodash/identity');
+
+var _identity2 = _interopRequireDefault(_identity);
+
+var _slice = require('./internal/slice');
+
+var _slice2 = _interopRequireDefault(_slice);
+
+var _setImmediate = require('./internal/setImmediate');
+
+var _setImmediate2 = _interopRequireDefault(_setImmediate);
+
+var _initialParams = require('./internal/initialParams');
+
+var _initialParams2 = _interopRequireDefault(_initialParams);
+
+var _wrapAsync = require('./internal/wrapAsync');
+
+var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+function has(obj, key) {
+ return key in obj;
+}
+
+/**
+ * Caches the results of an async function. When creating a hash to store
+ * function results against, the callback is omitted from the hash and an
+ * optional hash function can be used.
+ *
+ * If no hash function is specified, the first argument is used as a hash key,
+ * which may work reasonably if it is a string or a data type that converts to a
+ * distinct string. Note that objects and arrays will not behave reasonably.
+ * Neither will cases where the other arguments are significant. In such cases,
+ * specify your own hash function.
+ *
+ * The cache of results is exposed as the `memo` property of the function
+ * returned by `memoize`.
+ *
+ * @name memoize
+ * @static
+ * @memberOf module:Utils
+ * @method
+ * @category Util
+ * @param {AsyncFunction} fn - The async function to proxy and cache results from.
+ * @param {Function} hasher - An optional function for generating a custom hash
+ * for storing results. It has all the arguments applied to it apart from the
+ * callback, and must be synchronous.
+ * @returns {AsyncFunction} a memoized version of `fn`
+ * @example
+ *
+ * var slow_fn = function(name, callback) {
+ * // do something
+ * callback(null, result);
+ * };
+ * var fn = async.memoize(slow_fn);
+ *
+ * // fn can now be used as if it were slow_fn
+ * fn('some name', function() {
+ * // callback
+ * });
+ */
+function memoize(fn, hasher) {
+ var memo = Object.create(null);
+ var queues = Object.create(null);
+ hasher = hasher || _identity2.default;
+ var _fn = (0, _wrapAsync2.default)(fn);
+ var memoized = (0, _initialParams2.default)(function memoized(args, callback) {
+ var key = hasher.apply(null, args);
+ if (has(memo, key)) {
+ (0, _setImmediate2.default)(function () {
+ callback.apply(null, memo[key]);
+ });
+ } else if (has(queues, key)) {
+ queues[key].push(callback);
+ } else {
+ queues[key] = [callback];
+ _fn.apply(null, args.concat(function () /*args*/{
+ var args = (0, _slice2.default)(arguments);
+ memo[key] = args;
+ var q = queues[key];
+ delete queues[key];
+ for (var i = 0, l = q.length; i < l; i++) {
+ q[i].apply(null, args);
+ }
+ }));
+ }
+ });
+ memoized.memo = memo;
+ memoized.unmemoized = fn;
+ return memoized;
+}
+module.exports = exports['default'];
\ No newline at end of file
diff --git a/node_modules/@pm2/js-api/node_modules/async/nextTick.js b/node_modules/@pm2/js-api/node_modules/async/nextTick.js
new file mode 100644
index 0000000..886f58e
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/async/nextTick.js
@@ -0,0 +1,51 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+var _setImmediate = require('./internal/setImmediate');
+
+/**
+ * Calls `callback` on a later loop around the event loop. In Node.js this just
+ * calls `process.nextTick`. In the browser it will use `setImmediate` if
+ * available, otherwise `setTimeout(callback, 0)`, which means other higher
+ * priority events may precede the execution of `callback`.
+ *
+ * This is used internally for browser-compatibility purposes.
+ *
+ * @name nextTick
+ * @static
+ * @memberOf module:Utils
+ * @method
+ * @see [async.setImmediate]{@link module:Utils.setImmediate}
+ * @category Util
+ * @param {Function} callback - The function to call on a later loop around
+ * the event loop. Invoked with (args...).
+ * @param {...*} args... - any number of additional arguments to pass to the
+ * callback on the next tick.
+ * @example
+ *
+ * var call_order = [];
+ * async.nextTick(function() {
+ * call_order.push('two');
+ * // call_order now equals ['one','two']
+ * });
+ * call_order.push('one');
+ *
+ * async.setImmediate(function (a, b, c) {
+ * // a, b, and c equal 1, 2, and 3
+ * }, 1, 2, 3);
+ */
+var _defer;
+
+if (_setImmediate.hasNextTick) {
+ _defer = process.nextTick;
+} else if (_setImmediate.hasSetImmediate) {
+ _defer = setImmediate;
+} else {
+ _defer = _setImmediate.fallback;
+}
+
+exports.default = (0, _setImmediate.wrap)(_defer);
+module.exports = exports['default'];
\ No newline at end of file
diff --git a/node_modules/@pm2/js-api/node_modules/async/package.json b/node_modules/@pm2/js-api/node_modules/async/package.json
new file mode 100644
index 0000000..76b3db7
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/async/package.json
@@ -0,0 +1,80 @@
+{
+ "name": "async",
+ "description": "Higher-order functions and common patterns for asynchronous code",
+ "version": "2.6.4",
+ "main": "dist/async.js",
+ "author": "Caolan McMahon",
+ "homepage": "https://caolan.github.io/async/",
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/caolan/async.git"
+ },
+ "bugs": {
+ "url": "https://github.com/caolan/async/issues"
+ },
+ "keywords": [
+ "async",
+ "callback",
+ "module",
+ "utility"
+ ],
+ "dependencies": {
+ "lodash": "^4.17.14"
+ },
+ "devDependencies": {
+ "babel-cli": "^6.24.0",
+ "babel-core": "^6.26.3",
+ "babel-plugin-add-module-exports": "^0.2.1",
+ "babel-plugin-istanbul": "^2.0.1",
+ "babel-plugin-transform-es2015-modules-commonjs": "^6.26.2",
+ "babel-preset-es2015": "^6.3.13",
+ "babel-preset-es2017": "^6.22.0",
+ "babelify": "^8.0.0",
+ "benchmark": "^2.1.1",
+ "bluebird": "^3.4.6",
+ "browserify": "^16.2.2",
+ "chai": "^4.1.2",
+ "cheerio": "^0.22.0",
+ "coveralls": "^3.0.1",
+ "es6-promise": "^2.3.0",
+ "eslint": "^2.13.1",
+ "fs-extra": "^0.26.7",
+ "gh-pages-deploy": "^0.5.0",
+ "jsdoc": "^3.4.0",
+ "karma": "^2.0.2",
+ "karma-browserify": "^5.2.0",
+ "karma-firefox-launcher": "^1.1.0",
+ "karma-mocha": "^1.2.0",
+ "karma-mocha-reporter": "^2.2.0",
+ "mocha": "^5.2.0",
+ "native-promise-only": "^0.8.0-a",
+ "nyc": "^11.8.0",
+ "rimraf": "^2.5.0",
+ "rollup": "^0.36.3",
+ "rollup-plugin-node-resolve": "^2.0.0",
+ "rollup-plugin-npm": "^2.0.0",
+ "rsvp": "^3.0.18",
+ "semver": "^5.5.0",
+ "uglify-js": "~2.7.3",
+ "yargs": "^11.0.0"
+ },
+ "scripts": {
+ "coverage": "nyc npm run mocha-node-test -- --grep @nycinvalid --invert",
+ "coveralls": "npm run coverage && nyc report --reporter=text-lcov | coveralls",
+ "jsdoc": "jsdoc -c ./support/jsdoc/jsdoc.json && node support/jsdoc/jsdoc-fix-html.js",
+ "lint": "eslint lib/ mocha_test/ perf/memory.js perf/suites.js perf/benchmark.js support/build/ support/*.js karma.conf.js",
+ "mocha-browser-test": "karma start",
+ "mocha-node-test": "mocha mocha_test/ --compilers js:babel-core/register",
+ "mocha-test": "npm run mocha-node-test && npm run mocha-browser-test",
+ "test": "npm run lint && npm run mocha-node-test"
+ },
+ "license": "MIT",
+ "gh-pages-deploy": {
+ "staticpath": "docs"
+ },
+ "nyc": {
+ "exclude": [
+ "mocha_test"
+ ]
+ }
+}
\ No newline at end of file
diff --git a/node_modules/@pm2/js-api/node_modules/async/parallel.js b/node_modules/@pm2/js-api/node_modules/async/parallel.js
new file mode 100644
index 0000000..da28a4d
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/async/parallel.js
@@ -0,0 +1,90 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = parallelLimit;
+
+var _eachOf = require('./eachOf');
+
+var _eachOf2 = _interopRequireDefault(_eachOf);
+
+var _parallel = require('./internal/parallel');
+
+var _parallel2 = _interopRequireDefault(_parallel);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * Run the `tasks` collection of functions in parallel, without waiting until
+ * the previous function has completed. If any of the functions pass an error to
+ * its callback, the main `callback` is immediately called with the value of the
+ * error. Once the `tasks` have completed, the results are passed to the final
+ * `callback` as an array.
+ *
+ * **Note:** `parallel` is about kicking-off I/O tasks in parallel, not about
+ * parallel execution of code. If your tasks do not use any timers or perform
+ * any I/O, they will actually be executed in series. Any synchronous setup
+ * sections for each task will happen one after the other. JavaScript remains
+ * single-threaded.
+ *
+ * **Hint:** Use [`reflect`]{@link module:Utils.reflect} to continue the
+ * execution of other tasks when a task fails.
+ *
+ * It is also possible to use an object instead of an array. Each property will
+ * be run as a function and the results will be passed to the final `callback`
+ * as an object instead of an array. This can be a more readable way of handling
+ * results from {@link async.parallel}.
+ *
+ * @name parallel
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @category Control Flow
+ * @param {Array|Iterable|Object} tasks - A collection of
+ * [async functions]{@link AsyncFunction} to run.
+ * Each async function can complete with any number of optional `result` values.
+ * @param {Function} [callback] - An optional callback to run once all the
+ * functions have completed successfully. This function gets a results array
+ * (or object) containing all the result arguments passed to the task callbacks.
+ * Invoked with (err, results).
+ *
+ * @example
+ * async.parallel([
+ * function(callback) {
+ * setTimeout(function() {
+ * callback(null, 'one');
+ * }, 200);
+ * },
+ * function(callback) {
+ * setTimeout(function() {
+ * callback(null, 'two');
+ * }, 100);
+ * }
+ * ],
+ * // optional callback
+ * function(err, results) {
+ * // the results array will equal ['one','two'] even though
+ * // the second function had a shorter timeout.
+ * });
+ *
+ * // an example using an object instead of an array
+ * async.parallel({
+ * one: function(callback) {
+ * setTimeout(function() {
+ * callback(null, 1);
+ * }, 200);
+ * },
+ * two: function(callback) {
+ * setTimeout(function() {
+ * callback(null, 2);
+ * }, 100);
+ * }
+ * }, function(err, results) {
+ * // results is now equals to: {one: 1, two: 2}
+ * });
+ */
+function parallelLimit(tasks, callback) {
+ (0, _parallel2.default)(_eachOf2.default, tasks, callback);
+}
+module.exports = exports['default'];
\ No newline at end of file
diff --git a/node_modules/@pm2/js-api/node_modules/async/parallelLimit.js b/node_modules/@pm2/js-api/node_modules/async/parallelLimit.js
new file mode 100644
index 0000000..a026526
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/async/parallelLimit.js
@@ -0,0 +1,40 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = parallelLimit;
+
+var _eachOfLimit = require('./internal/eachOfLimit');
+
+var _eachOfLimit2 = _interopRequireDefault(_eachOfLimit);
+
+var _parallel = require('./internal/parallel');
+
+var _parallel2 = _interopRequireDefault(_parallel);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * The same as [`parallel`]{@link module:ControlFlow.parallel} but runs a maximum of `limit` async operations at a
+ * time.
+ *
+ * @name parallelLimit
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @see [async.parallel]{@link module:ControlFlow.parallel}
+ * @category Control Flow
+ * @param {Array|Iterable|Object} tasks - A collection of
+ * [async functions]{@link AsyncFunction} to run.
+ * Each async function can complete with any number of optional `result` values.
+ * @param {number} limit - The maximum number of async operations at a time.
+ * @param {Function} [callback] - An optional callback to run once all the
+ * functions have completed successfully. This function gets a results array
+ * (or object) containing all the result arguments passed to the task callbacks.
+ * Invoked with (err, results).
+ */
+function parallelLimit(tasks, limit, callback) {
+ (0, _parallel2.default)((0, _eachOfLimit2.default)(limit), tasks, callback);
+}
+module.exports = exports['default'];
\ No newline at end of file
diff --git a/node_modules/@pm2/js-api/node_modules/async/priorityQueue.js b/node_modules/@pm2/js-api/node_modules/async/priorityQueue.js
new file mode 100644
index 0000000..3a5f023
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/async/priorityQueue.js
@@ -0,0 +1,98 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+exports.default = function (worker, concurrency) {
+ // Start with a normal queue
+ var q = (0, _queue2.default)(worker, concurrency);
+
+ // Override push to accept second parameter representing priority
+ q.push = function (data, priority, callback) {
+ if (callback == null) callback = _noop2.default;
+ if (typeof callback !== 'function') {
+ throw new Error('task callback must be a function');
+ }
+ q.started = true;
+ if (!(0, _isArray2.default)(data)) {
+ data = [data];
+ }
+ if (data.length === 0) {
+ // call drain immediately if there are no tasks
+ return (0, _setImmediate2.default)(function () {
+ q.drain();
+ });
+ }
+
+ priority = priority || 0;
+ var nextNode = q._tasks.head;
+ while (nextNode && priority >= nextNode.priority) {
+ nextNode = nextNode.next;
+ }
+
+ for (var i = 0, l = data.length; i < l; i++) {
+ var item = {
+ data: data[i],
+ priority: priority,
+ callback: callback
+ };
+
+ if (nextNode) {
+ q._tasks.insertBefore(nextNode, item);
+ } else {
+ q._tasks.push(item);
+ }
+ }
+ (0, _setImmediate2.default)(q.process);
+ };
+
+ // Remove unshift function
+ delete q.unshift;
+
+ return q;
+};
+
+var _isArray = require('lodash/isArray');
+
+var _isArray2 = _interopRequireDefault(_isArray);
+
+var _noop = require('lodash/noop');
+
+var _noop2 = _interopRequireDefault(_noop);
+
+var _setImmediate = require('./setImmediate');
+
+var _setImmediate2 = _interopRequireDefault(_setImmediate);
+
+var _queue = require('./queue');
+
+var _queue2 = _interopRequireDefault(_queue);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+module.exports = exports['default'];
+
+/**
+ * The same as [async.queue]{@link module:ControlFlow.queue} only tasks are assigned a priority and
+ * completed in ascending priority order.
+ *
+ * @name priorityQueue
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @see [async.queue]{@link module:ControlFlow.queue}
+ * @category Control Flow
+ * @param {AsyncFunction} worker - An async function for processing a queued task.
+ * If you want to handle errors from an individual task, pass a callback to
+ * `q.push()`.
+ * Invoked with (task, callback).
+ * @param {number} concurrency - An `integer` for determining how many `worker`
+ * functions should be run in parallel. If omitted, the concurrency defaults to
+ * `1`. If the concurrency is `0`, an error is thrown.
+ * @returns {module:ControlFlow.QueueObject} A priorityQueue object to manage the tasks. There are two
+ * differences between `queue` and `priorityQueue` objects:
+ * * `push(task, priority, [callback])` - `priority` should be a number. If an
+ * array of `tasks` is given, all tasks will be assigned the same priority.
+ * * The `unshift` method was removed.
+ */
\ No newline at end of file
diff --git a/node_modules/@pm2/js-api/node_modules/async/queue.js b/node_modules/@pm2/js-api/node_modules/async/queue.js
new file mode 100644
index 0000000..0ca8ba2
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/async/queue.js
@@ -0,0 +1,130 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+exports.default = function (worker, concurrency) {
+ var _worker = (0, _wrapAsync2.default)(worker);
+ return (0, _queue2.default)(function (items, cb) {
+ _worker(items[0], cb);
+ }, concurrency, 1);
+};
+
+var _queue = require('./internal/queue');
+
+var _queue2 = _interopRequireDefault(_queue);
+
+var _wrapAsync = require('./internal/wrapAsync');
+
+var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+module.exports = exports['default'];
+
+/**
+ * A queue of tasks for the worker function to complete.
+ * @typedef {Object} QueueObject
+ * @memberOf module:ControlFlow
+ * @property {Function} length - a function returning the number of items
+ * waiting to be processed. Invoke with `queue.length()`.
+ * @property {boolean} started - a boolean indicating whether or not any
+ * items have been pushed and processed by the queue.
+ * @property {Function} running - a function returning the number of items
+ * currently being processed. Invoke with `queue.running()`.
+ * @property {Function} workersList - a function returning the array of items
+ * currently being processed. Invoke with `queue.workersList()`.
+ * @property {Function} idle - a function returning false if there are items
+ * waiting or being processed, or true if not. Invoke with `queue.idle()`.
+ * @property {number} concurrency - an integer for determining how many `worker`
+ * functions should be run in parallel. This property can be changed after a
+ * `queue` is created to alter the concurrency on-the-fly.
+ * @property {Function} push - add a new task to the `queue`. Calls `callback`
+ * once the `worker` has finished processing the task. Instead of a single task,
+ * a `tasks` array can be submitted. The respective callback is used for every
+ * task in the list. Invoke with `queue.push(task, [callback])`,
+ * @property {Function} unshift - add a new task to the front of the `queue`.
+ * Invoke with `queue.unshift(task, [callback])`.
+ * @property {Function} remove - remove items from the queue that match a test
+ * function. The test function will be passed an object with a `data` property,
+ * and a `priority` property, if this is a
+ * [priorityQueue]{@link module:ControlFlow.priorityQueue} object.
+ * Invoked with `queue.remove(testFn)`, where `testFn` is of the form
+ * `function ({data, priority}) {}` and returns a Boolean.
+ * @property {Function} saturated - a callback that is called when the number of
+ * running workers hits the `concurrency` limit, and further tasks will be
+ * queued.
+ * @property {Function} unsaturated - a callback that is called when the number
+ * of running workers is less than the `concurrency` & `buffer` limits, and
+ * further tasks will not be queued.
+ * @property {number} buffer - A minimum threshold buffer in order to say that
+ * the `queue` is `unsaturated`.
+ * @property {Function} empty - a callback that is called when the last item
+ * from the `queue` is given to a `worker`.
+ * @property {Function} drain - a callback that is called when the last item
+ * from the `queue` has returned from the `worker`.
+ * @property {Function} error - a callback that is called when a task errors.
+ * Has the signature `function(error, task)`.
+ * @property {boolean} paused - a boolean for determining whether the queue is
+ * in a paused state.
+ * @property {Function} pause - a function that pauses the processing of tasks
+ * until `resume()` is called. Invoke with `queue.pause()`.
+ * @property {Function} resume - a function that resumes the processing of
+ * queued tasks when the queue is paused. Invoke with `queue.resume()`.
+ * @property {Function} kill - a function that removes the `drain` callback and
+ * empties remaining tasks from the queue forcing it to go idle. No more tasks
+ * should be pushed to the queue after calling this function. Invoke with `queue.kill()`.
+ */
+
+/**
+ * Creates a `queue` object with the specified `concurrency`. Tasks added to the
+ * `queue` are processed in parallel (up to the `concurrency` limit). If all
+ * `worker`s are in progress, the task is queued until one becomes available.
+ * Once a `worker` completes a `task`, that `task`'s callback is called.
+ *
+ * @name queue
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @category Control Flow
+ * @param {AsyncFunction} worker - An async function for processing a queued task.
+ * If you want to handle errors from an individual task, pass a callback to
+ * `q.push()`. Invoked with (task, callback).
+ * @param {number} [concurrency=1] - An `integer` for determining how many
+ * `worker` functions should be run in parallel. If omitted, the concurrency
+ * defaults to `1`. If the concurrency is `0`, an error is thrown.
+ * @returns {module:ControlFlow.QueueObject} A queue object to manage the tasks. Callbacks can
+ * attached as certain properties to listen for specific events during the
+ * lifecycle of the queue.
+ * @example
+ *
+ * // create a queue object with concurrency 2
+ * var q = async.queue(function(task, callback) {
+ * console.log('hello ' + task.name);
+ * callback();
+ * }, 2);
+ *
+ * // assign a callback
+ * q.drain = function() {
+ * console.log('all items have been processed');
+ * };
+ *
+ * // add some items to the queue
+ * q.push({name: 'foo'}, function(err) {
+ * console.log('finished processing foo');
+ * });
+ * q.push({name: 'bar'}, function (err) {
+ * console.log('finished processing bar');
+ * });
+ *
+ * // add some items to the queue (batch-wise)
+ * q.push([{name: 'baz'},{name: 'bay'},{name: 'bax'}], function(err) {
+ * console.log('finished processing item');
+ * });
+ *
+ * // add some items to the front of the queue
+ * q.unshift({name: 'bar'}, function (err) {
+ * console.log('finished processing bar');
+ * });
+ */
\ No newline at end of file
diff --git a/node_modules/@pm2/js-api/node_modules/async/race.js b/node_modules/@pm2/js-api/node_modules/async/race.js
new file mode 100644
index 0000000..6713c74
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/async/race.js
@@ -0,0 +1,70 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = race;
+
+var _isArray = require('lodash/isArray');
+
+var _isArray2 = _interopRequireDefault(_isArray);
+
+var _noop = require('lodash/noop');
+
+var _noop2 = _interopRequireDefault(_noop);
+
+var _once = require('./internal/once');
+
+var _once2 = _interopRequireDefault(_once);
+
+var _wrapAsync = require('./internal/wrapAsync');
+
+var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * Runs the `tasks` array of functions in parallel, without waiting until the
+ * previous function has completed. Once any of the `tasks` complete or pass an
+ * error to its callback, the main `callback` is immediately called. It's
+ * equivalent to `Promise.race()`.
+ *
+ * @name race
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @category Control Flow
+ * @param {Array} tasks - An array containing [async functions]{@link AsyncFunction}
+ * to run. Each function can complete with an optional `result` value.
+ * @param {Function} callback - A callback to run once any of the functions have
+ * completed. This function gets an error or result from the first function that
+ * completed. Invoked with (err, result).
+ * @returns undefined
+ * @example
+ *
+ * async.race([
+ * function(callback) {
+ * setTimeout(function() {
+ * callback(null, 'one');
+ * }, 200);
+ * },
+ * function(callback) {
+ * setTimeout(function() {
+ * callback(null, 'two');
+ * }, 100);
+ * }
+ * ],
+ * // main callback
+ * function(err, result) {
+ * // the result will be equal to 'two' as it finishes earlier
+ * });
+ */
+function race(tasks, callback) {
+ callback = (0, _once2.default)(callback || _noop2.default);
+ if (!(0, _isArray2.default)(tasks)) return callback(new TypeError('First argument to race must be an array of functions'));
+ if (!tasks.length) return callback();
+ for (var i = 0, l = tasks.length; i < l; i++) {
+ (0, _wrapAsync2.default)(tasks[i])(callback);
+ }
+}
+module.exports = exports['default'];
\ No newline at end of file
diff --git a/node_modules/@pm2/js-api/node_modules/async/reduce.js b/node_modules/@pm2/js-api/node_modules/async/reduce.js
new file mode 100644
index 0000000..3fb8019
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/async/reduce.js
@@ -0,0 +1,78 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = reduce;
+
+var _eachOfSeries = require('./eachOfSeries');
+
+var _eachOfSeries2 = _interopRequireDefault(_eachOfSeries);
+
+var _noop = require('lodash/noop');
+
+var _noop2 = _interopRequireDefault(_noop);
+
+var _once = require('./internal/once');
+
+var _once2 = _interopRequireDefault(_once);
+
+var _wrapAsync = require('./internal/wrapAsync');
+
+var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * Reduces `coll` into a single value using an async `iteratee` to return each
+ * successive step. `memo` is the initial state of the reduction. This function
+ * only operates in series.
+ *
+ * For performance reasons, it may make sense to split a call to this function
+ * into a parallel map, and then use the normal `Array.prototype.reduce` on the
+ * results. This function is for situations where each step in the reduction
+ * needs to be async; if you can get the data before reducing it, then it's
+ * probably a good idea to do so.
+ *
+ * @name reduce
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @alias inject
+ * @alias foldl
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {*} memo - The initial state of the reduction.
+ * @param {AsyncFunction} iteratee - A function applied to each item in the
+ * array to produce the next step in the reduction.
+ * The `iteratee` should complete with the next state of the reduction.
+ * If the iteratee complete with an error, the reduction is stopped and the
+ * main `callback` is immediately called with the error.
+ * Invoked with (memo, item, callback).
+ * @param {Function} [callback] - A callback which is called after all the
+ * `iteratee` functions have finished. Result is the reduced value. Invoked with
+ * (err, result).
+ * @example
+ *
+ * async.reduce([1,2,3], 0, function(memo, item, callback) {
+ * // pointless async:
+ * process.nextTick(function() {
+ * callback(null, memo + item)
+ * });
+ * }, function(err, result) {
+ * // result is now equal to the last value of memo, which is 6
+ * });
+ */
+function reduce(coll, memo, iteratee, callback) {
+ callback = (0, _once2.default)(callback || _noop2.default);
+ var _iteratee = (0, _wrapAsync2.default)(iteratee);
+ (0, _eachOfSeries2.default)(coll, function (x, i, callback) {
+ _iteratee(memo, x, function (err, v) {
+ memo = v;
+ callback(err);
+ });
+ }, function (err) {
+ callback(err, memo);
+ });
+}
+module.exports = exports['default'];
\ No newline at end of file
diff --git a/node_modules/@pm2/js-api/node_modules/async/reduceRight.js b/node_modules/@pm2/js-api/node_modules/async/reduceRight.js
new file mode 100644
index 0000000..3d17d32
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/async/reduceRight.js
@@ -0,0 +1,44 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = reduceRight;
+
+var _reduce = require('./reduce');
+
+var _reduce2 = _interopRequireDefault(_reduce);
+
+var _slice = require('./internal/slice');
+
+var _slice2 = _interopRequireDefault(_slice);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * Same as [`reduce`]{@link module:Collections.reduce}, only operates on `array` in reverse order.
+ *
+ * @name reduceRight
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.reduce]{@link module:Collections.reduce}
+ * @alias foldr
+ * @category Collection
+ * @param {Array} array - A collection to iterate over.
+ * @param {*} memo - The initial state of the reduction.
+ * @param {AsyncFunction} iteratee - A function applied to each item in the
+ * array to produce the next step in the reduction.
+ * The `iteratee` should complete with the next state of the reduction.
+ * If the iteratee complete with an error, the reduction is stopped and the
+ * main `callback` is immediately called with the error.
+ * Invoked with (memo, item, callback).
+ * @param {Function} [callback] - A callback which is called after all the
+ * `iteratee` functions have finished. Result is the reduced value. Invoked with
+ * (err, result).
+ */
+function reduceRight(array, memo, iteratee, callback) {
+ var reversed = (0, _slice2.default)(array).reverse();
+ (0, _reduce2.default)(reversed, memo, iteratee, callback);
+}
+module.exports = exports['default'];
\ No newline at end of file
diff --git a/node_modules/@pm2/js-api/node_modules/async/reflect.js b/node_modules/@pm2/js-api/node_modules/async/reflect.js
new file mode 100644
index 0000000..098ba86
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/async/reflect.js
@@ -0,0 +1,81 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = reflect;
+
+var _initialParams = require('./internal/initialParams');
+
+var _initialParams2 = _interopRequireDefault(_initialParams);
+
+var _slice = require('./internal/slice');
+
+var _slice2 = _interopRequireDefault(_slice);
+
+var _wrapAsync = require('./internal/wrapAsync');
+
+var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * Wraps the async function in another function that always completes with a
+ * result object, even when it errors.
+ *
+ * The result object has either the property `error` or `value`.
+ *
+ * @name reflect
+ * @static
+ * @memberOf module:Utils
+ * @method
+ * @category Util
+ * @param {AsyncFunction} fn - The async function you want to wrap
+ * @returns {Function} - A function that always passes null to it's callback as
+ * the error. The second argument to the callback will be an `object` with
+ * either an `error` or a `value` property.
+ * @example
+ *
+ * async.parallel([
+ * async.reflect(function(callback) {
+ * // do some stuff ...
+ * callback(null, 'one');
+ * }),
+ * async.reflect(function(callback) {
+ * // do some more stuff but error ...
+ * callback('bad stuff happened');
+ * }),
+ * async.reflect(function(callback) {
+ * // do some more stuff ...
+ * callback(null, 'two');
+ * })
+ * ],
+ * // optional callback
+ * function(err, results) {
+ * // values
+ * // results[0].value = 'one'
+ * // results[1].error = 'bad stuff happened'
+ * // results[2].value = 'two'
+ * });
+ */
+function reflect(fn) {
+ var _fn = (0, _wrapAsync2.default)(fn);
+ return (0, _initialParams2.default)(function reflectOn(args, reflectCallback) {
+ args.push(function callback(error, cbArg) {
+ if (error) {
+ reflectCallback(null, { error: error });
+ } else {
+ var value;
+ if (arguments.length <= 2) {
+ value = cbArg;
+ } else {
+ value = (0, _slice2.default)(arguments, 1);
+ }
+ reflectCallback(null, { value: value });
+ }
+ });
+
+ return _fn.apply(this, args);
+ });
+}
+module.exports = exports['default'];
\ No newline at end of file
diff --git a/node_modules/@pm2/js-api/node_modules/async/reflectAll.js b/node_modules/@pm2/js-api/node_modules/async/reflectAll.js
new file mode 100644
index 0000000..966e83d
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/async/reflectAll.js
@@ -0,0 +1,105 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = reflectAll;
+
+var _reflect = require('./reflect');
+
+var _reflect2 = _interopRequireDefault(_reflect);
+
+var _isArray = require('lodash/isArray');
+
+var _isArray2 = _interopRequireDefault(_isArray);
+
+var _arrayMap2 = require('lodash/_arrayMap');
+
+var _arrayMap3 = _interopRequireDefault(_arrayMap2);
+
+var _baseForOwn = require('lodash/_baseForOwn');
+
+var _baseForOwn2 = _interopRequireDefault(_baseForOwn);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * A helper function that wraps an array or an object of functions with `reflect`.
+ *
+ * @name reflectAll
+ * @static
+ * @memberOf module:Utils
+ * @method
+ * @see [async.reflect]{@link module:Utils.reflect}
+ * @category Util
+ * @param {Array|Object|Iterable} tasks - The collection of
+ * [async functions]{@link AsyncFunction} to wrap in `async.reflect`.
+ * @returns {Array} Returns an array of async functions, each wrapped in
+ * `async.reflect`
+ * @example
+ *
+ * let tasks = [
+ * function(callback) {
+ * setTimeout(function() {
+ * callback(null, 'one');
+ * }, 200);
+ * },
+ * function(callback) {
+ * // do some more stuff but error ...
+ * callback(new Error('bad stuff happened'));
+ * },
+ * function(callback) {
+ * setTimeout(function() {
+ * callback(null, 'two');
+ * }, 100);
+ * }
+ * ];
+ *
+ * async.parallel(async.reflectAll(tasks),
+ * // optional callback
+ * function(err, results) {
+ * // values
+ * // results[0].value = 'one'
+ * // results[1].error = Error('bad stuff happened')
+ * // results[2].value = 'two'
+ * });
+ *
+ * // an example using an object instead of an array
+ * let tasks = {
+ * one: function(callback) {
+ * setTimeout(function() {
+ * callback(null, 'one');
+ * }, 200);
+ * },
+ * two: function(callback) {
+ * callback('two');
+ * },
+ * three: function(callback) {
+ * setTimeout(function() {
+ * callback(null, 'three');
+ * }, 100);
+ * }
+ * };
+ *
+ * async.parallel(async.reflectAll(tasks),
+ * // optional callback
+ * function(err, results) {
+ * // values
+ * // results.one.value = 'one'
+ * // results.two.error = 'two'
+ * // results.three.value = 'three'
+ * });
+ */
+function reflectAll(tasks) {
+ var results;
+ if ((0, _isArray2.default)(tasks)) {
+ results = (0, _arrayMap3.default)(tasks, _reflect2.default);
+ } else {
+ results = {};
+ (0, _baseForOwn2.default)(tasks, function (task, key) {
+ results[key] = _reflect2.default.call(this, task);
+ });
+ }
+ return results;
+}
+module.exports = exports['default'];
\ No newline at end of file
diff --git a/node_modules/@pm2/js-api/node_modules/async/reject.js b/node_modules/@pm2/js-api/node_modules/async/reject.js
new file mode 100644
index 0000000..53802b5
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/async/reject.js
@@ -0,0 +1,45 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+var _reject = require('./internal/reject');
+
+var _reject2 = _interopRequireDefault(_reject);
+
+var _doParallel = require('./internal/doParallel');
+
+var _doParallel2 = _interopRequireDefault(_doParallel);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * The opposite of [`filter`]{@link module:Collections.filter}. Removes values that pass an `async` truth test.
+ *
+ * @name reject
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.filter]{@link module:Collections.filter}
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {Function} iteratee - An async truth test to apply to each item in
+ * `coll`.
+ * The should complete with a boolean value as its `result`.
+ * Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called after all the
+ * `iteratee` functions have finished. Invoked with (err, results).
+ * @example
+ *
+ * async.reject(['file1','file2','file3'], function(filePath, callback) {
+ * fs.access(filePath, function(err) {
+ * callback(null, !err)
+ * });
+ * }, function(err, results) {
+ * // results now equals an array of missing files
+ * createFiles(results);
+ * });
+ */
+exports.default = (0, _doParallel2.default)(_reject2.default);
+module.exports = exports['default'];
\ No newline at end of file
diff --git a/node_modules/@pm2/js-api/node_modules/async/rejectLimit.js b/node_modules/@pm2/js-api/node_modules/async/rejectLimit.js
new file mode 100644
index 0000000..74bba7f
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/async/rejectLimit.js
@@ -0,0 +1,37 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+var _reject = require('./internal/reject');
+
+var _reject2 = _interopRequireDefault(_reject);
+
+var _doParallelLimit = require('./internal/doParallelLimit');
+
+var _doParallelLimit2 = _interopRequireDefault(_doParallelLimit);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * The same as [`reject`]{@link module:Collections.reject} but runs a maximum of `limit` async operations at a
+ * time.
+ *
+ * @name rejectLimit
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.reject]{@link module:Collections.reject}
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {number} limit - The maximum number of async operations at a time.
+ * @param {Function} iteratee - An async truth test to apply to each item in
+ * `coll`.
+ * The should complete with a boolean value as its `result`.
+ * Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called after all the
+ * `iteratee` functions have finished. Invoked with (err, results).
+ */
+exports.default = (0, _doParallelLimit2.default)(_reject2.default);
+module.exports = exports['default'];
\ No newline at end of file
diff --git a/node_modules/@pm2/js-api/node_modules/async/rejectSeries.js b/node_modules/@pm2/js-api/node_modules/async/rejectSeries.js
new file mode 100644
index 0000000..f905588
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/async/rejectSeries.js
@@ -0,0 +1,35 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+var _rejectLimit = require('./rejectLimit');
+
+var _rejectLimit2 = _interopRequireDefault(_rejectLimit);
+
+var _doLimit = require('./internal/doLimit');
+
+var _doLimit2 = _interopRequireDefault(_doLimit);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * The same as [`reject`]{@link module:Collections.reject} but runs only a single async operation at a time.
+ *
+ * @name rejectSeries
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.reject]{@link module:Collections.reject}
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {Function} iteratee - An async truth test to apply to each item in
+ * `coll`.
+ * The should complete with a boolean value as its `result`.
+ * Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called after all the
+ * `iteratee` functions have finished. Invoked with (err, results).
+ */
+exports.default = (0, _doLimit2.default)(_rejectLimit2.default, 1);
+module.exports = exports['default'];
\ No newline at end of file
diff --git a/node_modules/@pm2/js-api/node_modules/async/retry.js b/node_modules/@pm2/js-api/node_modules/async/retry.js
new file mode 100644
index 0000000..6a1aa1e
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/async/retry.js
@@ -0,0 +1,156 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = retry;
+
+var _noop = require('lodash/noop');
+
+var _noop2 = _interopRequireDefault(_noop);
+
+var _constant = require('lodash/constant');
+
+var _constant2 = _interopRequireDefault(_constant);
+
+var _wrapAsync = require('./internal/wrapAsync');
+
+var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * Attempts to get a successful response from `task` no more than `times` times
+ * before returning an error. If the task is successful, the `callback` will be
+ * passed the result of the successful task. If all attempts fail, the callback
+ * will be passed the error and result (if any) of the final attempt.
+ *
+ * @name retry
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @category Control Flow
+ * @see [async.retryable]{@link module:ControlFlow.retryable}
+ * @param {Object|number} [opts = {times: 5, interval: 0}| 5] - Can be either an
+ * object with `times` and `interval` or a number.
+ * * `times` - The number of attempts to make before giving up. The default
+ * is `5`.
+ * * `interval` - The time to wait between retries, in milliseconds. The
+ * default is `0`. The interval may also be specified as a function of the
+ * retry count (see example).
+ * * `errorFilter` - An optional synchronous function that is invoked on
+ * erroneous result. If it returns `true` the retry attempts will continue;
+ * if the function returns `false` the retry flow is aborted with the current
+ * attempt's error and result being returned to the final callback.
+ * Invoked with (err).
+ * * If `opts` is a number, the number specifies the number of times to retry,
+ * with the default interval of `0`.
+ * @param {AsyncFunction} task - An async function to retry.
+ * Invoked with (callback).
+ * @param {Function} [callback] - An optional callback which is called when the
+ * task has succeeded, or after the final failed attempt. It receives the `err`
+ * and `result` arguments of the last attempt at completing the `task`. Invoked
+ * with (err, results).
+ *
+ * @example
+ *
+ * // The `retry` function can be used as a stand-alone control flow by passing
+ * // a callback, as shown below:
+ *
+ * // try calling apiMethod 3 times
+ * async.retry(3, apiMethod, function(err, result) {
+ * // do something with the result
+ * });
+ *
+ * // try calling apiMethod 3 times, waiting 200 ms between each retry
+ * async.retry({times: 3, interval: 200}, apiMethod, function(err, result) {
+ * // do something with the result
+ * });
+ *
+ * // try calling apiMethod 10 times with exponential backoff
+ * // (i.e. intervals of 100, 200, 400, 800, 1600, ... milliseconds)
+ * async.retry({
+ * times: 10,
+ * interval: function(retryCount) {
+ * return 50 * Math.pow(2, retryCount);
+ * }
+ * }, apiMethod, function(err, result) {
+ * // do something with the result
+ * });
+ *
+ * // try calling apiMethod the default 5 times no delay between each retry
+ * async.retry(apiMethod, function(err, result) {
+ * // do something with the result
+ * });
+ *
+ * // try calling apiMethod only when error condition satisfies, all other
+ * // errors will abort the retry control flow and return to final callback
+ * async.retry({
+ * errorFilter: function(err) {
+ * return err.message === 'Temporary error'; // only retry on a specific error
+ * }
+ * }, apiMethod, function(err, result) {
+ * // do something with the result
+ * });
+ *
+ * // to retry individual methods that are not as reliable within other
+ * // control flow functions, use the `retryable` wrapper:
+ * async.auto({
+ * users: api.getUsers.bind(api),
+ * payments: async.retryable(3, api.getPayments.bind(api))
+ * }, function(err, results) {
+ * // do something with the results
+ * });
+ *
+ */
+function retry(opts, task, callback) {
+ var DEFAULT_TIMES = 5;
+ var DEFAULT_INTERVAL = 0;
+
+ var options = {
+ times: DEFAULT_TIMES,
+ intervalFunc: (0, _constant2.default)(DEFAULT_INTERVAL)
+ };
+
+ function parseTimes(acc, t) {
+ if (typeof t === 'object') {
+ acc.times = +t.times || DEFAULT_TIMES;
+
+ acc.intervalFunc = typeof t.interval === 'function' ? t.interval : (0, _constant2.default)(+t.interval || DEFAULT_INTERVAL);
+
+ acc.errorFilter = t.errorFilter;
+ } else if (typeof t === 'number' || typeof t === 'string') {
+ acc.times = +t || DEFAULT_TIMES;
+ } else {
+ throw new Error("Invalid arguments for async.retry");
+ }
+ }
+
+ if (arguments.length < 3 && typeof opts === 'function') {
+ callback = task || _noop2.default;
+ task = opts;
+ } else {
+ parseTimes(options, opts);
+ callback = callback || _noop2.default;
+ }
+
+ if (typeof task !== 'function') {
+ throw new Error("Invalid arguments for async.retry");
+ }
+
+ var _task = (0, _wrapAsync2.default)(task);
+
+ var attempt = 1;
+ function retryAttempt() {
+ _task(function (err) {
+ if (err && attempt++ < options.times && (typeof options.errorFilter != 'function' || options.errorFilter(err))) {
+ setTimeout(retryAttempt, options.intervalFunc(attempt));
+ } else {
+ callback.apply(null, arguments);
+ }
+ });
+ }
+
+ retryAttempt();
+}
+module.exports = exports['default'];
\ No newline at end of file
diff --git a/node_modules/@pm2/js-api/node_modules/async/retryable.js b/node_modules/@pm2/js-api/node_modules/async/retryable.js
new file mode 100644
index 0000000..002bfb0
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/async/retryable.js
@@ -0,0 +1,65 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+exports.default = function (opts, task) {
+ if (!task) {
+ task = opts;
+ opts = null;
+ }
+ var _task = (0, _wrapAsync2.default)(task);
+ return (0, _initialParams2.default)(function (args, callback) {
+ function taskFn(cb) {
+ _task.apply(null, args.concat(cb));
+ }
+
+ if (opts) (0, _retry2.default)(opts, taskFn, callback);else (0, _retry2.default)(taskFn, callback);
+ });
+};
+
+var _retry = require('./retry');
+
+var _retry2 = _interopRequireDefault(_retry);
+
+var _initialParams = require('./internal/initialParams');
+
+var _initialParams2 = _interopRequireDefault(_initialParams);
+
+var _wrapAsync = require('./internal/wrapAsync');
+
+var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+module.exports = exports['default'];
+
+/**
+ * A close relative of [`retry`]{@link module:ControlFlow.retry}. This method
+ * wraps a task and makes it retryable, rather than immediately calling it
+ * with retries.
+ *
+ * @name retryable
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @see [async.retry]{@link module:ControlFlow.retry}
+ * @category Control Flow
+ * @param {Object|number} [opts = {times: 5, interval: 0}| 5] - optional
+ * options, exactly the same as from `retry`
+ * @param {AsyncFunction} task - the asynchronous function to wrap.
+ * This function will be passed any arguments passed to the returned wrapper.
+ * Invoked with (...args, callback).
+ * @returns {AsyncFunction} The wrapped function, which when invoked, will
+ * retry on an error, based on the parameters specified in `opts`.
+ * This function will accept the same parameters as `task`.
+ * @example
+ *
+ * async.auto({
+ * dep1: async.retryable(3, getFromFlakyService),
+ * process: ["dep1", async.retryable(3, function (results, cb) {
+ * maybeProcessData(results.dep1, cb);
+ * })]
+ * }, callback);
+ */
\ No newline at end of file
diff --git a/node_modules/@pm2/js-api/node_modules/async/select.js b/node_modules/@pm2/js-api/node_modules/async/select.js
new file mode 100644
index 0000000..54772d5
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/async/select.js
@@ -0,0 +1,45 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+var _filter = require('./internal/filter');
+
+var _filter2 = _interopRequireDefault(_filter);
+
+var _doParallel = require('./internal/doParallel');
+
+var _doParallel2 = _interopRequireDefault(_doParallel);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * Returns a new array of all the values in `coll` which pass an async truth
+ * test. This operation is performed in parallel, but the results array will be
+ * in the same order as the original.
+ *
+ * @name filter
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @alias select
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {Function} iteratee - A truth test to apply to each item in `coll`.
+ * The `iteratee` is passed a `callback(err, truthValue)`, which must be called
+ * with a boolean argument once it has completed. Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called after all the
+ * `iteratee` functions have finished. Invoked with (err, results).
+ * @example
+ *
+ * async.filter(['file1','file2','file3'], function(filePath, callback) {
+ * fs.access(filePath, function(err) {
+ * callback(null, !err)
+ * });
+ * }, function(err, results) {
+ * // results now equals an array of the existing files
+ * });
+ */
+exports.default = (0, _doParallel2.default)(_filter2.default);
+module.exports = exports['default'];
\ No newline at end of file
diff --git a/node_modules/@pm2/js-api/node_modules/async/selectLimit.js b/node_modules/@pm2/js-api/node_modules/async/selectLimit.js
new file mode 100644
index 0000000..06216f7
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/async/selectLimit.js
@@ -0,0 +1,37 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+var _filter = require('./internal/filter');
+
+var _filter2 = _interopRequireDefault(_filter);
+
+var _doParallelLimit = require('./internal/doParallelLimit');
+
+var _doParallelLimit2 = _interopRequireDefault(_doParallelLimit);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * The same as [`filter`]{@link module:Collections.filter} but runs a maximum of `limit` async operations at a
+ * time.
+ *
+ * @name filterLimit
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.filter]{@link module:Collections.filter}
+ * @alias selectLimit
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {number} limit - The maximum number of async operations at a time.
+ * @param {Function} iteratee - A truth test to apply to each item in `coll`.
+ * The `iteratee` is passed a `callback(err, truthValue)`, which must be called
+ * with a boolean argument once it has completed. Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called after all the
+ * `iteratee` functions have finished. Invoked with (err, results).
+ */
+exports.default = (0, _doParallelLimit2.default)(_filter2.default);
+module.exports = exports['default'];
\ No newline at end of file
diff --git a/node_modules/@pm2/js-api/node_modules/async/selectSeries.js b/node_modules/@pm2/js-api/node_modules/async/selectSeries.js
new file mode 100644
index 0000000..e48d966
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/async/selectSeries.js
@@ -0,0 +1,35 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+var _filterLimit = require('./filterLimit');
+
+var _filterLimit2 = _interopRequireDefault(_filterLimit);
+
+var _doLimit = require('./internal/doLimit');
+
+var _doLimit2 = _interopRequireDefault(_doLimit);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * The same as [`filter`]{@link module:Collections.filter} but runs only a single async operation at a time.
+ *
+ * @name filterSeries
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.filter]{@link module:Collections.filter}
+ * @alias selectSeries
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {Function} iteratee - A truth test to apply to each item in `coll`.
+ * The `iteratee` is passed a `callback(err, truthValue)`, which must be called
+ * with a boolean argument once it has completed. Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called after all the
+ * `iteratee` functions have finished. Invoked with (err, results)
+ */
+exports.default = (0, _doLimit2.default)(_filterLimit2.default, 1);
+module.exports = exports['default'];
\ No newline at end of file
diff --git a/node_modules/@pm2/js-api/node_modules/async/seq.js b/node_modules/@pm2/js-api/node_modules/async/seq.js
new file mode 100644
index 0000000..ff86ef9
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/async/seq.js
@@ -0,0 +1,91 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = seq;
+
+var _noop = require('lodash/noop');
+
+var _noop2 = _interopRequireDefault(_noop);
+
+var _slice = require('./internal/slice');
+
+var _slice2 = _interopRequireDefault(_slice);
+
+var _reduce = require('./reduce');
+
+var _reduce2 = _interopRequireDefault(_reduce);
+
+var _wrapAsync = require('./internal/wrapAsync');
+
+var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
+
+var _arrayMap = require('lodash/_arrayMap');
+
+var _arrayMap2 = _interopRequireDefault(_arrayMap);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * Version of the compose function that is more natural to read. Each function
+ * consumes the return value of the previous function. It is the equivalent of
+ * [compose]{@link module:ControlFlow.compose} with the arguments reversed.
+ *
+ * Each function is executed with the `this` binding of the composed function.
+ *
+ * @name seq
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @see [async.compose]{@link module:ControlFlow.compose}
+ * @category Control Flow
+ * @param {...AsyncFunction} functions - the asynchronous functions to compose
+ * @returns {Function} a function that composes the `functions` in order
+ * @example
+ *
+ * // Requires lodash (or underscore), express3 and dresende's orm2.
+ * // Part of an app, that fetches cats of the logged user.
+ * // This example uses `seq` function to avoid overnesting and error
+ * // handling clutter.
+ * app.get('/cats', function(request, response) {
+ * var User = request.models.User;
+ * async.seq(
+ * _.bind(User.get, User), // 'User.get' has signature (id, callback(err, data))
+ * function(user, fn) {
+ * user.getCats(fn); // 'getCats' has signature (callback(err, data))
+ * }
+ * )(req.session.user_id, function (err, cats) {
+ * if (err) {
+ * console.error(err);
+ * response.json({ status: 'error', message: err.message });
+ * } else {
+ * response.json({ status: 'ok', message: 'Cats found', data: cats });
+ * }
+ * });
+ * });
+ */
+function seq() /*...functions*/{
+ var _functions = (0, _arrayMap2.default)(arguments, _wrapAsync2.default);
+ return function () /*...args*/{
+ var args = (0, _slice2.default)(arguments);
+ var that = this;
+
+ var cb = args[args.length - 1];
+ if (typeof cb == 'function') {
+ args.pop();
+ } else {
+ cb = _noop2.default;
+ }
+
+ (0, _reduce2.default)(_functions, args, function (newargs, fn, cb) {
+ fn.apply(that, newargs.concat(function (err /*, ...nextargs*/) {
+ var nextargs = (0, _slice2.default)(arguments, 1);
+ cb(err, nextargs);
+ }));
+ }, function (err, results) {
+ cb.apply(that, [err].concat(results));
+ });
+ };
+}
+module.exports = exports['default'];
\ No newline at end of file
diff --git a/node_modules/@pm2/js-api/node_modules/async/series.js b/node_modules/@pm2/js-api/node_modules/async/series.js
new file mode 100644
index 0000000..e8c2928
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/async/series.js
@@ -0,0 +1,85 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = series;
+
+var _parallel = require('./internal/parallel');
+
+var _parallel2 = _interopRequireDefault(_parallel);
+
+var _eachOfSeries = require('./eachOfSeries');
+
+var _eachOfSeries2 = _interopRequireDefault(_eachOfSeries);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * Run the functions in the `tasks` collection in series, each one running once
+ * the previous function has completed. If any functions in the series pass an
+ * error to its callback, no more functions are run, and `callback` is
+ * immediately called with the value of the error. Otherwise, `callback`
+ * receives an array of results when `tasks` have completed.
+ *
+ * It is also possible to use an object instead of an array. Each property will
+ * be run as a function, and the results will be passed to the final `callback`
+ * as an object instead of an array. This can be a more readable way of handling
+ * results from {@link async.series}.
+ *
+ * **Note** that while many implementations preserve the order of object
+ * properties, the [ECMAScript Language Specification](http://www.ecma-international.org/ecma-262/5.1/#sec-8.6)
+ * explicitly states that
+ *
+ * > The mechanics and order of enumerating the properties is not specified.
+ *
+ * So if you rely on the order in which your series of functions are executed,
+ * and want this to work on all platforms, consider using an array.
+ *
+ * @name series
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @category Control Flow
+ * @param {Array|Iterable|Object} tasks - A collection containing
+ * [async functions]{@link AsyncFunction} to run in series.
+ * Each function can complete with any number of optional `result` values.
+ * @param {Function} [callback] - An optional callback to run once all the
+ * functions have completed. This function gets a results array (or object)
+ * containing all the result arguments passed to the `task` callbacks. Invoked
+ * with (err, result).
+ * @example
+ * async.series([
+ * function(callback) {
+ * // do some stuff ...
+ * callback(null, 'one');
+ * },
+ * function(callback) {
+ * // do some more stuff ...
+ * callback(null, 'two');
+ * }
+ * ],
+ * // optional callback
+ * function(err, results) {
+ * // results is now equal to ['one', 'two']
+ * });
+ *
+ * async.series({
+ * one: function(callback) {
+ * setTimeout(function() {
+ * callback(null, 1);
+ * }, 200);
+ * },
+ * two: function(callback){
+ * setTimeout(function() {
+ * callback(null, 2);
+ * }, 100);
+ * }
+ * }, function(err, results) {
+ * // results is now equal to: {one: 1, two: 2}
+ * });
+ */
+function series(tasks, callback) {
+ (0, _parallel2.default)(_eachOfSeries2.default, tasks, callback);
+}
+module.exports = exports['default'];
\ No newline at end of file
diff --git a/node_modules/@pm2/js-api/node_modules/async/setImmediate.js b/node_modules/@pm2/js-api/node_modules/async/setImmediate.js
new file mode 100644
index 0000000..e52f7c5
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/async/setImmediate.js
@@ -0,0 +1,45 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+var _setImmediate = require('./internal/setImmediate');
+
+var _setImmediate2 = _interopRequireDefault(_setImmediate);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * Calls `callback` on a later loop around the event loop. In Node.js this just
+ * calls `setImmediate`. In the browser it will use `setImmediate` if
+ * available, otherwise `setTimeout(callback, 0)`, which means other higher
+ * priority events may precede the execution of `callback`.
+ *
+ * This is used internally for browser-compatibility purposes.
+ *
+ * @name setImmediate
+ * @static
+ * @memberOf module:Utils
+ * @method
+ * @see [async.nextTick]{@link module:Utils.nextTick}
+ * @category Util
+ * @param {Function} callback - The function to call on a later loop around
+ * the event loop. Invoked with (args...).
+ * @param {...*} args... - any number of additional arguments to pass to the
+ * callback on the next tick.
+ * @example
+ *
+ * var call_order = [];
+ * async.nextTick(function() {
+ * call_order.push('two');
+ * // call_order now equals ['one','two']
+ * });
+ * call_order.push('one');
+ *
+ * async.setImmediate(function (a, b, c) {
+ * // a, b, and c equal 1, 2, and 3
+ * }, 1, 2, 3);
+ */
+exports.default = _setImmediate2.default;
+module.exports = exports['default'];
\ No newline at end of file
diff --git a/node_modules/@pm2/js-api/node_modules/async/some.js b/node_modules/@pm2/js-api/node_modules/async/some.js
new file mode 100644
index 0000000..a8e70f7
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/async/some.js
@@ -0,0 +1,52 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+var _createTester = require('./internal/createTester');
+
+var _createTester2 = _interopRequireDefault(_createTester);
+
+var _doParallel = require('./internal/doParallel');
+
+var _doParallel2 = _interopRequireDefault(_doParallel);
+
+var _identity = require('lodash/identity');
+
+var _identity2 = _interopRequireDefault(_identity);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * Returns `true` if at least one element in the `coll` satisfies an async test.
+ * If any iteratee call returns `true`, the main `callback` is immediately
+ * called.
+ *
+ * @name some
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @alias any
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {AsyncFunction} iteratee - An async truth test to apply to each item
+ * in the collections in parallel.
+ * The iteratee should complete with a boolean `result` value.
+ * Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called as soon as any
+ * iteratee returns `true`, or after all the iteratee functions have finished.
+ * Result will be either `true` or `false` depending on the values of the async
+ * tests. Invoked with (err, result).
+ * @example
+ *
+ * async.some(['file1','file2','file3'], function(filePath, callback) {
+ * fs.access(filePath, function(err) {
+ * callback(null, !err)
+ * });
+ * }, function(err, result) {
+ * // if result is true then at least one of the files exists
+ * });
+ */
+exports.default = (0, _doParallel2.default)((0, _createTester2.default)(Boolean, _identity2.default));
+module.exports = exports['default'];
\ No newline at end of file
diff --git a/node_modules/@pm2/js-api/node_modules/async/someLimit.js b/node_modules/@pm2/js-api/node_modules/async/someLimit.js
new file mode 100644
index 0000000..24ca3f4
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/async/someLimit.js
@@ -0,0 +1,43 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+var _createTester = require('./internal/createTester');
+
+var _createTester2 = _interopRequireDefault(_createTester);
+
+var _doParallelLimit = require('./internal/doParallelLimit');
+
+var _doParallelLimit2 = _interopRequireDefault(_doParallelLimit);
+
+var _identity = require('lodash/identity');
+
+var _identity2 = _interopRequireDefault(_identity);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * The same as [`some`]{@link module:Collections.some} but runs a maximum of `limit` async operations at a time.
+ *
+ * @name someLimit
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.some]{@link module:Collections.some}
+ * @alias anyLimit
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {number} limit - The maximum number of async operations at a time.
+ * @param {AsyncFunction} iteratee - An async truth test to apply to each item
+ * in the collections in parallel.
+ * The iteratee should complete with a boolean `result` value.
+ * Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called as soon as any
+ * iteratee returns `true`, or after all the iteratee functions have finished.
+ * Result will be either `true` or `false` depending on the values of the async
+ * tests. Invoked with (err, result).
+ */
+exports.default = (0, _doParallelLimit2.default)((0, _createTester2.default)(Boolean, _identity2.default));
+module.exports = exports['default'];
\ No newline at end of file
diff --git a/node_modules/@pm2/js-api/node_modules/async/someSeries.js b/node_modules/@pm2/js-api/node_modules/async/someSeries.js
new file mode 100644
index 0000000..dc24ed2
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/async/someSeries.js
@@ -0,0 +1,38 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+var _someLimit = require('./someLimit');
+
+var _someLimit2 = _interopRequireDefault(_someLimit);
+
+var _doLimit = require('./internal/doLimit');
+
+var _doLimit2 = _interopRequireDefault(_doLimit);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * The same as [`some`]{@link module:Collections.some} but runs only a single async operation at a time.
+ *
+ * @name someSeries
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @see [async.some]{@link module:Collections.some}
+ * @alias anySeries
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {AsyncFunction} iteratee - An async truth test to apply to each item
+ * in the collections in series.
+ * The iteratee should complete with a boolean `result` value.
+ * Invoked with (item, callback).
+ * @param {Function} [callback] - A callback which is called as soon as any
+ * iteratee returns `true`, or after all the iteratee functions have finished.
+ * Result will be either `true` or `false` depending on the values of the async
+ * tests. Invoked with (err, result).
+ */
+exports.default = (0, _doLimit2.default)(_someLimit2.default, 1);
+module.exports = exports['default'];
\ No newline at end of file
diff --git a/node_modules/@pm2/js-api/node_modules/async/sortBy.js b/node_modules/@pm2/js-api/node_modules/async/sortBy.js
new file mode 100644
index 0000000..ee5e93d
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/async/sortBy.js
@@ -0,0 +1,91 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = sortBy;
+
+var _arrayMap = require('lodash/_arrayMap');
+
+var _arrayMap2 = _interopRequireDefault(_arrayMap);
+
+var _baseProperty = require('lodash/_baseProperty');
+
+var _baseProperty2 = _interopRequireDefault(_baseProperty);
+
+var _map = require('./map');
+
+var _map2 = _interopRequireDefault(_map);
+
+var _wrapAsync = require('./internal/wrapAsync');
+
+var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * Sorts a list by the results of running each `coll` value through an async
+ * `iteratee`.
+ *
+ * @name sortBy
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {AsyncFunction} iteratee - An async function to apply to each item in
+ * `coll`.
+ * The iteratee should complete with a value to use as the sort criteria as
+ * its `result`.
+ * Invoked with (item, callback).
+ * @param {Function} callback - A callback which is called after all the
+ * `iteratee` functions have finished, or an error occurs. Results is the items
+ * from the original `coll` sorted by the values returned by the `iteratee`
+ * calls. Invoked with (err, results).
+ * @example
+ *
+ * async.sortBy(['file1','file2','file3'], function(file, callback) {
+ * fs.stat(file, function(err, stats) {
+ * callback(err, stats.mtime);
+ * });
+ * }, function(err, results) {
+ * // results is now the original array of files sorted by
+ * // modified date
+ * });
+ *
+ * // By modifying the callback parameter the
+ * // sorting order can be influenced:
+ *
+ * // ascending order
+ * async.sortBy([1,9,3,5], function(x, callback) {
+ * callback(null, x);
+ * }, function(err,result) {
+ * // result callback
+ * });
+ *
+ * // descending order
+ * async.sortBy([1,9,3,5], function(x, callback) {
+ * callback(null, x*-1); //<- x*-1 instead of x, turns the order around
+ * }, function(err,result) {
+ * // result callback
+ * });
+ */
+function sortBy(coll, iteratee, callback) {
+ var _iteratee = (0, _wrapAsync2.default)(iteratee);
+ (0, _map2.default)(coll, function (x, callback) {
+ _iteratee(x, function (err, criteria) {
+ if (err) return callback(err);
+ callback(null, { value: x, criteria: criteria });
+ });
+ }, function (err, results) {
+ if (err) return callback(err);
+ callback(null, (0, _arrayMap2.default)(results.sort(comparator), (0, _baseProperty2.default)('value')));
+ });
+
+ function comparator(left, right) {
+ var a = left.criteria,
+ b = right.criteria;
+ return a < b ? -1 : a > b ? 1 : 0;
+ }
+}
+module.exports = exports['default'];
\ No newline at end of file
diff --git a/node_modules/@pm2/js-api/node_modules/async/timeout.js b/node_modules/@pm2/js-api/node_modules/async/timeout.js
new file mode 100644
index 0000000..b5cb505
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/async/timeout.js
@@ -0,0 +1,89 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = timeout;
+
+var _initialParams = require('./internal/initialParams');
+
+var _initialParams2 = _interopRequireDefault(_initialParams);
+
+var _wrapAsync = require('./internal/wrapAsync');
+
+var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * Sets a time limit on an asynchronous function. If the function does not call
+ * its callback within the specified milliseconds, it will be called with a
+ * timeout error. The code property for the error object will be `'ETIMEDOUT'`.
+ *
+ * @name timeout
+ * @static
+ * @memberOf module:Utils
+ * @method
+ * @category Util
+ * @param {AsyncFunction} asyncFn - The async function to limit in time.
+ * @param {number} milliseconds - The specified time limit.
+ * @param {*} [info] - Any variable you want attached (`string`, `object`, etc)
+ * to timeout Error for more information..
+ * @returns {AsyncFunction} Returns a wrapped function that can be used with any
+ * of the control flow functions.
+ * Invoke this function with the same parameters as you would `asyncFunc`.
+ * @example
+ *
+ * function myFunction(foo, callback) {
+ * doAsyncTask(foo, function(err, data) {
+ * // handle errors
+ * if (err) return callback(err);
+ *
+ * // do some stuff ...
+ *
+ * // return processed data
+ * return callback(null, data);
+ * });
+ * }
+ *
+ * var wrapped = async.timeout(myFunction, 1000);
+ *
+ * // call `wrapped` as you would `myFunction`
+ * wrapped({ bar: 'bar' }, function(err, data) {
+ * // if `myFunction` takes < 1000 ms to execute, `err`
+ * // and `data` will have their expected values
+ *
+ * // else `err` will be an Error with the code 'ETIMEDOUT'
+ * });
+ */
+function timeout(asyncFn, milliseconds, info) {
+ var fn = (0, _wrapAsync2.default)(asyncFn);
+
+ return (0, _initialParams2.default)(function (args, callback) {
+ var timedOut = false;
+ var timer;
+
+ function timeoutCallback() {
+ var name = asyncFn.name || 'anonymous';
+ var error = new Error('Callback function "' + name + '" timed out.');
+ error.code = 'ETIMEDOUT';
+ if (info) {
+ error.info = info;
+ }
+ timedOut = true;
+ callback(error);
+ }
+
+ args.push(function () {
+ if (!timedOut) {
+ callback.apply(null, arguments);
+ clearTimeout(timer);
+ }
+ });
+
+ // setup timer and call original function
+ timer = setTimeout(timeoutCallback, milliseconds);
+ fn.apply(null, args);
+ });
+}
+module.exports = exports['default'];
\ No newline at end of file
diff --git a/node_modules/@pm2/js-api/node_modules/async/times.js b/node_modules/@pm2/js-api/node_modules/async/times.js
new file mode 100644
index 0000000..b5ca24d
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/async/times.js
@@ -0,0 +1,50 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+var _timesLimit = require('./timesLimit');
+
+var _timesLimit2 = _interopRequireDefault(_timesLimit);
+
+var _doLimit = require('./internal/doLimit');
+
+var _doLimit2 = _interopRequireDefault(_doLimit);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * Calls the `iteratee` function `n` times, and accumulates results in the same
+ * manner you would use with [map]{@link module:Collections.map}.
+ *
+ * @name times
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @see [async.map]{@link module:Collections.map}
+ * @category Control Flow
+ * @param {number} n - The number of times to run the function.
+ * @param {AsyncFunction} iteratee - The async function to call `n` times.
+ * Invoked with the iteration index and a callback: (n, next).
+ * @param {Function} callback - see {@link module:Collections.map}.
+ * @example
+ *
+ * // Pretend this is some complicated async factory
+ * var createUser = function(id, callback) {
+ * callback(null, {
+ * id: 'user' + id
+ * });
+ * };
+ *
+ * // generate 5 users
+ * async.times(5, function(n, next) {
+ * createUser(n, function(err, user) {
+ * next(err, user);
+ * });
+ * }, function(err, users) {
+ * // we should now have 5 users
+ * });
+ */
+exports.default = (0, _doLimit2.default)(_timesLimit2.default, Infinity);
+module.exports = exports['default'];
\ No newline at end of file
diff --git a/node_modules/@pm2/js-api/node_modules/async/timesLimit.js b/node_modules/@pm2/js-api/node_modules/async/timesLimit.js
new file mode 100644
index 0000000..aad8495
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/async/timesLimit.js
@@ -0,0 +1,42 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = timeLimit;
+
+var _mapLimit = require('./mapLimit');
+
+var _mapLimit2 = _interopRequireDefault(_mapLimit);
+
+var _baseRange = require('lodash/_baseRange');
+
+var _baseRange2 = _interopRequireDefault(_baseRange);
+
+var _wrapAsync = require('./internal/wrapAsync');
+
+var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * The same as [times]{@link module:ControlFlow.times} but runs a maximum of `limit` async operations at a
+ * time.
+ *
+ * @name timesLimit
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @see [async.times]{@link module:ControlFlow.times}
+ * @category Control Flow
+ * @param {number} count - The number of times to run the function.
+ * @param {number} limit - The maximum number of async operations at a time.
+ * @param {AsyncFunction} iteratee - The async function to call `n` times.
+ * Invoked with the iteration index and a callback: (n, next).
+ * @param {Function} callback - see [async.map]{@link module:Collections.map}.
+ */
+function timeLimit(count, limit, iteratee, callback) {
+ var _iteratee = (0, _wrapAsync2.default)(iteratee);
+ (0, _mapLimit2.default)((0, _baseRange2.default)(0, count, 1), limit, _iteratee, callback);
+}
+module.exports = exports['default'];
\ No newline at end of file
diff --git a/node_modules/@pm2/js-api/node_modules/async/timesSeries.js b/node_modules/@pm2/js-api/node_modules/async/timesSeries.js
new file mode 100644
index 0000000..f187a35
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/async/timesSeries.js
@@ -0,0 +1,32 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+var _timesLimit = require('./timesLimit');
+
+var _timesLimit2 = _interopRequireDefault(_timesLimit);
+
+var _doLimit = require('./internal/doLimit');
+
+var _doLimit2 = _interopRequireDefault(_doLimit);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * The same as [times]{@link module:ControlFlow.times} but runs only a single async operation at a time.
+ *
+ * @name timesSeries
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @see [async.times]{@link module:ControlFlow.times}
+ * @category Control Flow
+ * @param {number} n - The number of times to run the function.
+ * @param {AsyncFunction} iteratee - The async function to call `n` times.
+ * Invoked with the iteration index and a callback: (n, next).
+ * @param {Function} callback - see {@link module:Collections.map}.
+ */
+exports.default = (0, _doLimit2.default)(_timesLimit2.default, 1);
+module.exports = exports['default'];
\ No newline at end of file
diff --git a/node_modules/@pm2/js-api/node_modules/async/transform.js b/node_modules/@pm2/js-api/node_modules/async/transform.js
new file mode 100644
index 0000000..84ee217
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/async/transform.js
@@ -0,0 +1,87 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = transform;
+
+var _isArray = require('lodash/isArray');
+
+var _isArray2 = _interopRequireDefault(_isArray);
+
+var _noop = require('lodash/noop');
+
+var _noop2 = _interopRequireDefault(_noop);
+
+var _eachOf = require('./eachOf');
+
+var _eachOf2 = _interopRequireDefault(_eachOf);
+
+var _once = require('./internal/once');
+
+var _once2 = _interopRequireDefault(_once);
+
+var _wrapAsync = require('./internal/wrapAsync');
+
+var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * A relative of `reduce`. Takes an Object or Array, and iterates over each
+ * element in series, each step potentially mutating an `accumulator` value.
+ * The type of the accumulator defaults to the type of collection passed in.
+ *
+ * @name transform
+ * @static
+ * @memberOf module:Collections
+ * @method
+ * @category Collection
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
+ * @param {*} [accumulator] - The initial state of the transform. If omitted,
+ * it will default to an empty Object or Array, depending on the type of `coll`
+ * @param {AsyncFunction} iteratee - A function applied to each item in the
+ * collection that potentially modifies the accumulator.
+ * Invoked with (accumulator, item, key, callback).
+ * @param {Function} [callback] - A callback which is called after all the
+ * `iteratee` functions have finished. Result is the transformed accumulator.
+ * Invoked with (err, result).
+ * @example
+ *
+ * async.transform([1,2,3], function(acc, item, index, callback) {
+ * // pointless async:
+ * process.nextTick(function() {
+ * acc.push(item * 2)
+ * callback(null)
+ * });
+ * }, function(err, result) {
+ * // result is now equal to [2, 4, 6]
+ * });
+ *
+ * @example
+ *
+ * async.transform({a: 1, b: 2, c: 3}, function (obj, val, key, callback) {
+ * setImmediate(function () {
+ * obj[key] = val * 2;
+ * callback();
+ * })
+ * }, function (err, result) {
+ * // result is equal to {a: 2, b: 4, c: 6}
+ * })
+ */
+function transform(coll, accumulator, iteratee, callback) {
+ if (arguments.length <= 3) {
+ callback = iteratee;
+ iteratee = accumulator;
+ accumulator = (0, _isArray2.default)(coll) ? [] : {};
+ }
+ callback = (0, _once2.default)(callback || _noop2.default);
+ var _iteratee = (0, _wrapAsync2.default)(iteratee);
+
+ (0, _eachOf2.default)(coll, function (v, k, cb) {
+ _iteratee(accumulator, v, k, cb);
+ }, function (err) {
+ callback(err, accumulator);
+ });
+}
+module.exports = exports['default'];
\ No newline at end of file
diff --git a/node_modules/@pm2/js-api/node_modules/async/tryEach.js b/node_modules/@pm2/js-api/node_modules/async/tryEach.js
new file mode 100644
index 0000000..f4e4c97
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/async/tryEach.js
@@ -0,0 +1,81 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = tryEach;
+
+var _noop = require('lodash/noop');
+
+var _noop2 = _interopRequireDefault(_noop);
+
+var _eachSeries = require('./eachSeries');
+
+var _eachSeries2 = _interopRequireDefault(_eachSeries);
+
+var _wrapAsync = require('./internal/wrapAsync');
+
+var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
+
+var _slice = require('./internal/slice');
+
+var _slice2 = _interopRequireDefault(_slice);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * It runs each task in series but stops whenever any of the functions were
+ * successful. If one of the tasks were successful, the `callback` will be
+ * passed the result of the successful task. If all tasks fail, the callback
+ * will be passed the error and result (if any) of the final attempt.
+ *
+ * @name tryEach
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @category Control Flow
+ * @param {Array|Iterable|Object} tasks - A collection containing functions to
+ * run, each function is passed a `callback(err, result)` it must call on
+ * completion with an error `err` (which can be `null`) and an optional `result`
+ * value.
+ * @param {Function} [callback] - An optional callback which is called when one
+ * of the tasks has succeeded, or all have failed. It receives the `err` and
+ * `result` arguments of the last attempt at completing the `task`. Invoked with
+ * (err, results).
+ * @example
+ * async.tryEach([
+ * function getDataFromFirstWebsite(callback) {
+ * // Try getting the data from the first website
+ * callback(err, data);
+ * },
+ * function getDataFromSecondWebsite(callback) {
+ * // First website failed,
+ * // Try getting the data from the backup website
+ * callback(err, data);
+ * }
+ * ],
+ * // optional callback
+ * function(err, results) {
+ * Now do something with the data.
+ * });
+ *
+ */
+function tryEach(tasks, callback) {
+ var error = null;
+ var result;
+ callback = callback || _noop2.default;
+ (0, _eachSeries2.default)(tasks, function (task, callback) {
+ (0, _wrapAsync2.default)(task)(function (err, res /*, ...args*/) {
+ if (arguments.length > 2) {
+ result = (0, _slice2.default)(arguments, 1);
+ } else {
+ result = res;
+ }
+ error = err;
+ callback(!err);
+ });
+ }, function () {
+ callback(error, result);
+ });
+}
+module.exports = exports['default'];
\ No newline at end of file
diff --git a/node_modules/@pm2/js-api/node_modules/async/unmemoize.js b/node_modules/@pm2/js-api/node_modules/async/unmemoize.js
new file mode 100644
index 0000000..08f9f9f
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/async/unmemoize.js
@@ -0,0 +1,25 @@
+"use strict";
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = unmemoize;
+/**
+ * Undoes a [memoize]{@link module:Utils.memoize}d function, reverting it to the original,
+ * unmemoized form. Handy for testing.
+ *
+ * @name unmemoize
+ * @static
+ * @memberOf module:Utils
+ * @method
+ * @see [async.memoize]{@link module:Utils.memoize}
+ * @category Util
+ * @param {AsyncFunction} fn - the memoized function
+ * @returns {AsyncFunction} a function that calls the original unmemoized function
+ */
+function unmemoize(fn) {
+ return function () {
+ return (fn.unmemoized || fn).apply(null, arguments);
+ };
+}
+module.exports = exports["default"];
\ No newline at end of file
diff --git a/node_modules/@pm2/js-api/node_modules/async/until.js b/node_modules/@pm2/js-api/node_modules/async/until.js
new file mode 100644
index 0000000..29955ab
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/async/until.js
@@ -0,0 +1,41 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = until;
+
+var _whilst = require('./whilst');
+
+var _whilst2 = _interopRequireDefault(_whilst);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * Repeatedly call `iteratee` until `test` returns `true`. Calls `callback` when
+ * stopped, or an error occurs. `callback` will be passed an error and any
+ * arguments passed to the final `iteratee`'s callback.
+ *
+ * The inverse of [whilst]{@link module:ControlFlow.whilst}.
+ *
+ * @name until
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @see [async.whilst]{@link module:ControlFlow.whilst}
+ * @category Control Flow
+ * @param {Function} test - synchronous truth test to perform before each
+ * execution of `iteratee`. Invoked with ().
+ * @param {AsyncFunction} iteratee - An async function which is called each time
+ * `test` fails. Invoked with (callback).
+ * @param {Function} [callback] - A callback which is called after the test
+ * function has passed and repeated execution of `iteratee` has stopped. `callback`
+ * will be passed an error and any arguments passed to the final `iteratee`'s
+ * callback. Invoked with (err, [results]);
+ */
+function until(test, iteratee, callback) {
+ (0, _whilst2.default)(function () {
+ return !test.apply(this, arguments);
+ }, iteratee, callback);
+}
+module.exports = exports['default'];
\ No newline at end of file
diff --git a/node_modules/@pm2/js-api/node_modules/async/waterfall.js b/node_modules/@pm2/js-api/node_modules/async/waterfall.js
new file mode 100644
index 0000000..d547d6b
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/async/waterfall.js
@@ -0,0 +1,113 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+
+exports.default = function (tasks, callback) {
+ callback = (0, _once2.default)(callback || _noop2.default);
+ if (!(0, _isArray2.default)(tasks)) return callback(new Error('First argument to waterfall must be an array of functions'));
+ if (!tasks.length) return callback();
+ var taskIndex = 0;
+
+ function nextTask(args) {
+ var task = (0, _wrapAsync2.default)(tasks[taskIndex++]);
+ args.push((0, _onlyOnce2.default)(next));
+ task.apply(null, args);
+ }
+
+ function next(err /*, ...args*/) {
+ if (err || taskIndex === tasks.length) {
+ return callback.apply(null, arguments);
+ }
+ nextTask((0, _slice2.default)(arguments, 1));
+ }
+
+ nextTask([]);
+};
+
+var _isArray = require('lodash/isArray');
+
+var _isArray2 = _interopRequireDefault(_isArray);
+
+var _noop = require('lodash/noop');
+
+var _noop2 = _interopRequireDefault(_noop);
+
+var _once = require('./internal/once');
+
+var _once2 = _interopRequireDefault(_once);
+
+var _slice = require('./internal/slice');
+
+var _slice2 = _interopRequireDefault(_slice);
+
+var _onlyOnce = require('./internal/onlyOnce');
+
+var _onlyOnce2 = _interopRequireDefault(_onlyOnce);
+
+var _wrapAsync = require('./internal/wrapAsync');
+
+var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+module.exports = exports['default'];
+
+/**
+ * Runs the `tasks` array of functions in series, each passing their results to
+ * the next in the array. However, if any of the `tasks` pass an error to their
+ * own callback, the next function is not executed, and the main `callback` is
+ * immediately called with the error.
+ *
+ * @name waterfall
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @category Control Flow
+ * @param {Array} tasks - An array of [async functions]{@link AsyncFunction}
+ * to run.
+ * Each function should complete with any number of `result` values.
+ * The `result` values will be passed as arguments, in order, to the next task.
+ * @param {Function} [callback] - An optional callback to run once all the
+ * functions have completed. This will be passed the results of the last task's
+ * callback. Invoked with (err, [results]).
+ * @returns undefined
+ * @example
+ *
+ * async.waterfall([
+ * function(callback) {
+ * callback(null, 'one', 'two');
+ * },
+ * function(arg1, arg2, callback) {
+ * // arg1 now equals 'one' and arg2 now equals 'two'
+ * callback(null, 'three');
+ * },
+ * function(arg1, callback) {
+ * // arg1 now equals 'three'
+ * callback(null, 'done');
+ * }
+ * ], function (err, result) {
+ * // result now equals 'done'
+ * });
+ *
+ * // Or, with named functions:
+ * async.waterfall([
+ * myFirstFunction,
+ * mySecondFunction,
+ * myLastFunction,
+ * ], function (err, result) {
+ * // result now equals 'done'
+ * });
+ * function myFirstFunction(callback) {
+ * callback(null, 'one', 'two');
+ * }
+ * function mySecondFunction(arg1, arg2, callback) {
+ * // arg1 now equals 'one' and arg2 now equals 'two'
+ * callback(null, 'three');
+ * }
+ * function myLastFunction(arg1, callback) {
+ * // arg1 now equals 'three'
+ * callback(null, 'done');
+ * }
+ */
\ No newline at end of file
diff --git a/node_modules/@pm2/js-api/node_modules/async/whilst.js b/node_modules/@pm2/js-api/node_modules/async/whilst.js
new file mode 100644
index 0000000..9c4d8f6
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/async/whilst.js
@@ -0,0 +1,72 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = whilst;
+
+var _noop = require('lodash/noop');
+
+var _noop2 = _interopRequireDefault(_noop);
+
+var _slice = require('./internal/slice');
+
+var _slice2 = _interopRequireDefault(_slice);
+
+var _onlyOnce = require('./internal/onlyOnce');
+
+var _onlyOnce2 = _interopRequireDefault(_onlyOnce);
+
+var _wrapAsync = require('./internal/wrapAsync');
+
+var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * Repeatedly call `iteratee`, while `test` returns `true`. Calls `callback` when
+ * stopped, or an error occurs.
+ *
+ * @name whilst
+ * @static
+ * @memberOf module:ControlFlow
+ * @method
+ * @category Control Flow
+ * @param {Function} test - synchronous truth test to perform before each
+ * execution of `iteratee`. Invoked with ().
+ * @param {AsyncFunction} iteratee - An async function which is called each time
+ * `test` passes. Invoked with (callback).
+ * @param {Function} [callback] - A callback which is called after the test
+ * function has failed and repeated execution of `iteratee` has stopped. `callback`
+ * will be passed an error and any arguments passed to the final `iteratee`'s
+ * callback. Invoked with (err, [results]);
+ * @returns undefined
+ * @example
+ *
+ * var count = 0;
+ * async.whilst(
+ * function() { return count < 5; },
+ * function(callback) {
+ * count++;
+ * setTimeout(function() {
+ * callback(null, count);
+ * }, 1000);
+ * },
+ * function (err, n) {
+ * // 5 seconds have passed, n = 5
+ * }
+ * );
+ */
+function whilst(test, iteratee, callback) {
+ callback = (0, _onlyOnce2.default)(callback || _noop2.default);
+ var _iteratee = (0, _wrapAsync2.default)(iteratee);
+ if (!test()) return callback(null);
+ var next = function (err /*, ...args*/) {
+ if (err) return callback(err);
+ if (test()) return _iteratee(next);
+ var args = (0, _slice2.default)(arguments, 1);
+ callback.apply(null, [null].concat(args));
+ };
+ _iteratee(next);
+}
+module.exports = exports['default'];
\ No newline at end of file
diff --git a/node_modules/@pm2/js-api/node_modules/async/wrapSync.js b/node_modules/@pm2/js-api/node_modules/async/wrapSync.js
new file mode 100644
index 0000000..5e3fc91
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/async/wrapSync.js
@@ -0,0 +1,110 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = asyncify;
+
+var _isObject = require('lodash/isObject');
+
+var _isObject2 = _interopRequireDefault(_isObject);
+
+var _initialParams = require('./internal/initialParams');
+
+var _initialParams2 = _interopRequireDefault(_initialParams);
+
+var _setImmediate = require('./internal/setImmediate');
+
+var _setImmediate2 = _interopRequireDefault(_setImmediate);
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+/**
+ * Take a sync function and make it async, passing its return value to a
+ * callback. This is useful for plugging sync functions into a waterfall,
+ * series, or other async functions. Any arguments passed to the generated
+ * function will be passed to the wrapped function (except for the final
+ * callback argument). Errors thrown will be passed to the callback.
+ *
+ * If the function passed to `asyncify` returns a Promise, that promises's
+ * resolved/rejected state will be used to call the callback, rather than simply
+ * the synchronous return value.
+ *
+ * This also means you can asyncify ES2017 `async` functions.
+ *
+ * @name asyncify
+ * @static
+ * @memberOf module:Utils
+ * @method
+ * @alias wrapSync
+ * @category Util
+ * @param {Function} func - The synchronous function, or Promise-returning
+ * function to convert to an {@link AsyncFunction}.
+ * @returns {AsyncFunction} An asynchronous wrapper of the `func`. To be
+ * invoked with `(args..., callback)`.
+ * @example
+ *
+ * // passing a regular synchronous function
+ * async.waterfall([
+ * async.apply(fs.readFile, filename, "utf8"),
+ * async.asyncify(JSON.parse),
+ * function (data, next) {
+ * // data is the result of parsing the text.
+ * // If there was a parsing error, it would have been caught.
+ * }
+ * ], callback);
+ *
+ * // passing a function returning a promise
+ * async.waterfall([
+ * async.apply(fs.readFile, filename, "utf8"),
+ * async.asyncify(function (contents) {
+ * return db.model.create(contents);
+ * }),
+ * function (model, next) {
+ * // `model` is the instantiated model object.
+ * // If there was an error, this function would be skipped.
+ * }
+ * ], callback);
+ *
+ * // es2017 example, though `asyncify` is not needed if your JS environment
+ * // supports async functions out of the box
+ * var q = async.queue(async.asyncify(async function(file) {
+ * var intermediateStep = await processFile(file);
+ * return await somePromise(intermediateStep)
+ * }));
+ *
+ * q.push(files);
+ */
+function asyncify(func) {
+ return (0, _initialParams2.default)(function (args, callback) {
+ var result;
+ try {
+ result = func.apply(this, args);
+ } catch (e) {
+ return callback(e);
+ }
+ // if result is Promise object
+ if ((0, _isObject2.default)(result) && typeof result.then === 'function') {
+ result.then(function (value) {
+ invokeCallback(callback, null, value);
+ }, function (err) {
+ invokeCallback(callback, err.message ? err : new Error(err));
+ });
+ } else {
+ callback(null, result);
+ }
+ });
+}
+
+function invokeCallback(callback, error, value) {
+ try {
+ callback(error, value);
+ } catch (e) {
+ (0, _setImmediate2.default)(rethrow, e);
+ }
+}
+
+function rethrow(error) {
+ throw error;
+}
+module.exports = exports['default'];
\ No newline at end of file
diff --git a/node_modules/@pm2/js-api/node_modules/eventemitter2/LICENSE.txt b/node_modules/@pm2/js-api/node_modules/eventemitter2/LICENSE.txt
new file mode 100644
index 0000000..3f021f5
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/eventemitter2/LICENSE.txt
@@ -0,0 +1,21 @@
+
+The MIT License (MIT)
+
+Copyright (c) 2016 Paolo Fragomeni and Contributors
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the 'Software'), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is furnished
+to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/node_modules/@pm2/js-api/node_modules/eventemitter2/README.md b/node_modules/@pm2/js-api/node_modules/eventemitter2/README.md
new file mode 100644
index 0000000..a1a7222
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/eventemitter2/README.md
@@ -0,0 +1,809 @@
+[](https://travis-ci.org/EventEmitter2/EventEmitter2)
+[](https://coveralls.io/github/EventEmitter2/EventEmitter2?branch=v6.4.3)
+[](http://badge.fury.io/js/eventemitter2)
+[](https://david-dm.org/asyncly/eventemitter2)
+[]()
+
+# SYNOPSIS
+
+EventEmitter2 is an implementation of the EventEmitter module found in Node.js.
+In addition to having a better benchmark performance than EventEmitter and being browser-compatible,
+it also extends the interface of EventEmitter with many additional non-breaking features.
+
+If you like this project please show your support with a [GitHub :star:](https://github.com/EventEmitter2/EventEmitter2/stargazers)!
+
+# DESCRIPTION
+
+### FEATURES
+ - ES5 compatible UMD module, that supports node.js, browser and workers of any kind
+ - Namespaces/Wildcards
+ - [Any](#emitteronanylistener) listeners
+ - Times To Listen (TTL), extends the `once` concept with [`many`](#emittermanyevent--eventns-timestolisten-listener-options)
+ - [Async listeners](#emitteronevent-listener-options-objectboolean) (using setImmediate|setTimeout|nextTick) with promise|async function support
+ - The [emitAsync](#emitteremitasyncevent--eventns-arg1-arg2-) method to return the results of the listeners via Promise.all
+ - Subscription methods ([on](#emitteronevent-listener-options-objectboolean), [once](#emitterprependoncelistenerevent--eventns-listener-options), [many](#emittermanyevent--eventns-timestolisten-listener-options), ...) can return a
+ [listener](#listener) object that makes it easy to remove the subscription when needed - just call the listener.off() method.
+ - Feature-rich [waitFor](#emitterwaitforevent--eventns-options) method to wait for events using promises
+ - [listenTo](#listentotargetemitter-events-objectevent--eventns-function-options) & [stopListeningTo](#stoplisteningtotarget-object-event-event--eventns-boolean) methods
+ for listening to an external event emitter of any kind and propagate its events through itself using optional reducers/filters
+ - Extended version of the [events.once](#eventemitter2onceemitter-event--eventns-options) method from the [node events API](https://nodejs.org/api/events.html#events_events_once_emitter_name)
+ - Browser & Workers environment compatibility
+ - Demonstrates good performance in benchmarks
+
+```
+Platform: win32, x64, 15267MB
+Node version: v13.11.0
+CPU: 4 x AMD Ryzen 3 2200U with Radeon Vega Mobile Gfx @ 2495MHz
+----------------------------------------------------------------
+EventEmitterHeatUp x 2,897,056 ops/sec ±3.86% (67 runs sampled)
+EventEmitter x 3,232,934 ops/sec ±3.50% (65 runs sampled)
+EventEmitter2 x 12,261,042 ops/sec ±4.72% (59 runs sampled)
+EventEmitter2 (wild) x 242,751 ops/sec ±5.15% (68 runs sampled)
+EventEmitter2 (wild) using plain events x 358,916 ops/sec ±2.58% (78 runs sampled)
+EventEmitter2 (wild) emitting ns x 1,837,323 ops/sec ±3.50% (72 runs sampled)
+EventEmitter2 (wild) emitting a plain event x 2,743,707 ops/sec ±4.08% (65 runs sampled)
+EventEmitter3 x 10,380,258 ops/sec ±3.93% (67 runs sampled)
+
+Fastest is EventEmitter2
+```
+
+### What's new
+
+To find out what's new see the project [CHANGELOG](https://github.com/EventEmitter2/EventEmitter2/blob/master/CHANGELOG.md)
+
+### Differences (Non-breaking, compatible with existing EventEmitter)
+
+ - The EventEmitter2 constructor takes an optional configuration object with the following default values:
+```javascript
+var EventEmitter2 = require('eventemitter2');
+var emitter = new EventEmitter2({
+
+ // set this to `true` to use wildcards
+ wildcard: false,
+
+ // the delimiter used to segment namespaces
+ delimiter: '.',
+
+ // set this to `true` if you want to emit the newListener event
+ newListener: false,
+
+ // set this to `true` if you want to emit the removeListener event
+ removeListener: false,
+
+ // the maximum amount of listeners that can be assigned to an event
+ maxListeners: 10,
+
+ // show event name in memory leak message when more than maximum amount of listeners is assigned
+ verboseMemoryLeak: false,
+
+ // disable throwing uncaughtException if an error event is emitted and it has no listeners
+ ignoreErrors: false
+});
+```
+
+ - Getting the actual event that fired.
+
+```javascript
+emitter.on('foo.*', function(value1, value2) {
+ console.log(this.event, value1, value2);
+});
+
+emitter.emit('foo.bar', 1, 2); // 'foo.bar' 1 2
+emitter.emit(['foo', 'bar'], 3, 4); // 'foo.bar' 3 4
+
+emitter.emit(Symbol(), 5, 6); // Symbol() 5 6
+emitter.emit(['foo', Symbol()], 7, 8); // ['foo', Symbol()] 7 8
+```
+**Note**: Generally this.event is normalized to a string ('event', 'event.test'),
+except the cases when event is a symbol or namespace contains a symbol.
+In these cases this.event remains as is (symbol and array).
+
+ - Fire an event N times and then remove it, an extension of the `once` concept.
+
+```javascript
+emitter.many('foo', 4, function() {
+ console.log('hello');
+});
+```
+
+ - Pass in a namespaced event as an array rather than a delimited string.
+
+```javascript
+emitter.many(['foo', 'bar', 'bazz'], 4, function() {
+ console.log('hello');
+});
+```
+
+# Installing
+
+```console
+$ npm install eventemitter2
+```
+
+Or you can use unpkg.com CDN to import this [module](https://unpkg.com/eventemitter2) as a script directly from the browser
+
+# API
+
+### Types definition
+- `Event`: string | symbol
+- `EventNS`: string | Event []
+
+## Class EventEmitter2
+
+### instance:
+- [emit(event: event | eventNS, ...values: any[]): boolean](#emitteremitevent--eventns-arg1-arg2-);
+
+- [emitAsync(event: event | eventNS, ...values: any[]): Promise](#emitteremitasyncevent--eventns-arg1-arg2-)
+
+- [addListener(event: event | eventNS, listener: ListenerFn, boolean|options?: object): this|Listener](#emitteraddlistenerevent-listener-options-objectboolean)
+
+- [on(event: event | eventNS, listener: ListenerFn, boolean|options?: object): this|Listener](#emitteraddlistenerevent-listener-options-objectboolean)
+
+- [once(event: event | eventNS, listener: ListenerFn, boolean|options?: object): this|Listener](#emitteronceevent--eventns-listener-options)
+
+- [many(event: event | eventNS, timesToListen: number, listener: ListenerFn, boolean|options?: object): this|Listener](#emittermanyevent--eventns-timestolisten-listener-options)
+
+- [prependMany(event: event | eventNS, timesToListen: number, listener: ListenerFn, boolean|options?: object): this|Listener](#emitterprependanylistener)
+
+- [prependOnceListener(event: event | eventNS, listener: ListenerFn, boolean|options?: object): this|Listener](#emitterprependoncelistenerevent--eventns-listener-options)
+
+- [prependListener(event: event | eventNS, listener: ListenerFn, boolean|options?: object): this|Listener](#emitterprependlistenerevent-listener-options)
+
+- [prependAny(listener: EventAndListener): this](#emitterprependanylistener)
+
+- [onAny(listener: EventAndListener): this](#emitteronanylistener)
+
+- [offAny(listener: ListenerFn): this](#emitteroffanylistener)
+
+- [removeListener(event: event | eventNS, listener: ListenerFn): this](#emitterremovelistenerevent--eventns-listener)
+
+- [off(event: event | eventNS, listener: ListenerFn): this](#emitteroffevent--eventns-listener)
+
+- [removeAllListeners(event?: event | eventNS): this](#emitterremovealllistenersevent--eventns)
+
+- [setMaxListeners(n: number): void](#emittersetmaxlistenersn)
+
+- [getMaxListeners(): number](#emittergetmaxlisteners)
+
+- [eventNames(nsAsArray?: boolean): string[]](#emittereventnamesnsasarray)
+
+- [listeners(event: event | eventNS): ListenerFn[]](#emitterlistenersevent--eventns)
+
+- [listenersAny(): ListenerFn[]](#emitterlistenersany)
+
+- [hasListeners(event?: event | eventNS): Boolean](#haslistenersevent--eventnsstringboolean)
+
+- [waitFor(event: event | eventNS, timeout?: number): CancelablePromise](#emitterwaitforevent--eventns-timeout)
+
+- [waitFor(event: event | eventNS, filter?: WaitForFilter): CancelablePromise](#emitterwaitforevent--eventns-filter)
+
+- [waitFor(event: event | eventNS, options?: WaitForOptions): CancelablePromise](#emitterwaitforevent--eventns-options)
+
+- [listenTo(target: GeneralEventEmitter, event: event | eventNS, options?: ListenToOptions): this](#listentotargetemitter-events-objectevent--eventns-function-options)
+
+- [listenTo(target: GeneralEventEmitter, events: (event | eventNS)[], options?: ListenToOptions): this](#listentotargetemitter-events-event--eventns-options)
+
+- [listenTo(target: GeneralEventEmitter, events: Object, options?: ListenToOptions): this](#listentotargetemitter-events-objectevent--eventns-function-options)
+
+- [stopListeningTo(target?: GeneralEventEmitter, event?: event | eventNS): Boolean](#stoplisteningtarget-object-event-event--eventns-boolean)
+
+### static:
+
+- [static once(emitter: EventEmitter2, event: string | symbol, options?: OnceOptions): CancelablePromise](#eventemitter2onceemitter-event--eventns-options)
+
+- [static defaultMaxListeners: number](#eventemitter2defaultmaxlisteners)
+
+The `event` argument specified in the API declaration can be a string or symbol for a simple event emitter
+and a string|symbol|Array(string|symbol) in a case of a wildcard emitter;
+
+When an `EventEmitter` instance experiences an error, the typical action is
+to emit an `error` event. Error events are treated as a special case.
+If there is no listener for it, then the default action is to print a stack
+trace and exit the program.
+
+All EventEmitters emit the event `newListener` when new listeners are
+added. EventEmitters also emit the event `removeListener` when listeners are
+removed, and `removeListenerAny` when listeners added through `onAny` are
+removed.
+
+
+**Namespaces** with **Wildcards**
+To use namespaces/wildcards, pass the `wildcard` option into the EventEmitter
+constructor. When namespaces/wildcards are enabled, events can either be
+strings (`foo.bar`) separated by a delimiter or arrays (`['foo', 'bar']`). The
+delimiter is also configurable as a constructor option.
+
+An event name passed to any event emitter method can contain a wild card (the
+`*` character). If the event name is a string, a wildcard may appear as `foo.*`.
+If the event name is an array, the wildcard may appear as `['foo', '*']`.
+
+If either of the above described events were passed to the `on` method,
+subsequent emits such as the following would be observed...
+
+```javascript
+emitter.emit(Symbol());
+emitter.emit('foo');
+emitter.emit('foo.bazz');
+emitter.emit(['foo', 'bar']);
+emitter.emit(['foo', Symbol()]);
+```
+
+**NOTE:** An event name may use more than one wildcard. For example,
+`foo.*.bar.*` is a valid event name, and would match events such as
+`foo.x.bar.y`, or `['foo', 'bazz', 'bar', 'test']`
+
+# Multi-level Wildcards
+A double wildcard (the string `**`) matches any number of levels (zero or more) of events. So if for example `'foo.**'` is passed to the `on` method, the following events would be observed:
+
+````javascript
+emitter.emit('foo');
+emitter.emit('foo.bar');
+emitter.emit('foo.bar.baz');
+emitter.emit(['foo', Symbol(), 'baz']);
+````
+
+On the other hand, if the single-wildcard event name was passed to the on method, the callback would only observe the second of these events.
+
+
+### emitter.addListener(event, listener, options?: object|boolean)
+### emitter.on(event, listener, options?: object|boolean)
+
+Adds a listener to the end of the listeners array for the specified event.
+
+```javascript
+emitter.on('data', function(value1, value2, value3, ...) {
+ console.log('The event was raised!');
+});
+```
+```javascript
+emitter.on('data', function(value) {
+ console.log('The event was raised!');
+});
+```
+
+**Options:**
+
+- `async:boolean= false`- invoke the listener in async mode using setImmediate (fallback to setTimeout if not available)
+or process.nextTick depending on the `nextTick` option.
+
+- `nextTick:boolean= false`- use process.nextTick instead of setImmediate to invoke the listener asynchronously.
+
+- `promisify:boolean= false`- additionally wraps the listener to a Promise for later invocation using `emitAsync` method.
+This option will be activated by default if its value is `undefined`
+and the listener function is an `asynchronous function` (whose constructor name is `AsyncFunction`).
+
+- `objectify:boolean= false`- activates returning a [listener](#listener) object instead of 'this' by the subscription method.
+
+#### listener
+The listener object has the following properties:
+- `emitter: EventEmitter2` - reference to the event emitter instance
+- `event: event|eventNS` - subscription event
+- `listener: Function` - reference to the listener
+- `off(): Function`- removes the listener (voids the subscription)
+
+````javascript
+var listener= emitter.on('event', function(){
+ console.log('hello!');
+}, {objectify: true});
+
+emitter.emit('event');
+
+listener.off();
+````
+
+**Note:** If the options argument is `true` it will be considered as `{promisify: true}`
+
+**Note:** If the options argument is `false` it will be considered as `{async: true}`
+
+```javascript
+var EventEmitter2= require('eventemitter2');
+var emitter= new EventEmitter2();
+
+emitter.on('event', function(){
+ console.log('The event was raised!');
+}, {async: true});
+
+emitter.emit('event');
+console.log('emitted');
+```
+Since the `async` option was set the output from the code above is as follows:
+````
+emitted
+The event was raised!
+````
+
+If the listener is an async function or function which returns a promise, use the `promisify` option as follows:
+
+```javascript
+var EventEmitter2= require('eventemitter2');
+var emitter= new EventEmitter2();
+
+emitter.on('event', function(){
+ console.log('The event was raised!');
+ return new Promise(function(resolve){
+ console.log('listener resolved');
+ setTimeout(resolve, 1000);
+ });
+}, {promisify: true});
+
+emitter.emitAsync('event').then(function(){
+ console.log('all listeners were resolved!');
+});
+
+console.log('emitted');
+````
+Output:
+````
+emitted
+The event was raised!
+listener resolved
+all listeners were resolved!
+````
+If the `promisify` option is false (default value) the output of the same code is as follows:
+````
+The event was raised!
+listener resolved
+emitted
+all listeners were resolved!
+````
+
+
+### emitter.prependListener(event, listener, options?)
+
+Adds a listener to the beginning of the listeners array for the specified event.
+
+```javascript
+emitter.prependListener('data', function(value1, value2, value3, ...) {
+ console.log('The event was raised!');
+});
+```
+
+**options:**
+
+`options?`: See the [addListener options](#emitteronevent-listener-options-objectboolean)
+
+### emitter.onAny(listener)
+
+Adds a listener that will be fired when any event is emitted. The event name is passed as the first argument to the callback.
+
+```javascript
+emitter.onAny(function(event, value) {
+ console.log('All events trigger this.');
+});
+```
+
+### emitter.prependAny(listener)
+
+Adds a listener that will be fired when any event is emitted. The event name is passed as the first argument to the callback. The listener is added to the beginning of the listeners array
+
+```javascript
+emitter.prependAny(function(event, value) {
+ console.log('All events trigger this.');
+});
+```
+
+### emitter.offAny(listener)
+
+Removes the listener that will be fired when any event is emitted.
+
+```javascript
+emitter.offAny(function(value) {
+ console.log('The event was raised!');
+});
+```
+
+#### emitter.once(event | eventNS, listener, options?)
+
+Adds a **one time** listener for the event. The listener is invoked
+only the first time the event is fired, after which it is removed.
+
+```javascript
+emitter.once('get', function (value) {
+ console.log('Ah, we have our first value!');
+});
+```
+
+**options:**
+
+`options?`: See the [addListener options](#emitteronevent-listener-options-objectboolean)
+
+#### emitter.prependOnceListener(event | eventNS, listener, options?)
+
+Adds a **one time** listener for the event. The listener is invoked
+only the first time the event is fired, after which it is removed.
+The listener is added to the beginning of the listeners array
+
+```javascript
+emitter.prependOnceListener('get', function (value) {
+ console.log('Ah, we have our first value!');
+});
+```
+
+**options:**
+
+`options?`: See the [addListener options](#emitteronevent-listener-options-objectboolean)
+
+### emitter.many(event | eventNS, timesToListen, listener, options?)
+
+Adds a listener that will execute **n times** for the event before being
+removed. The listener is invoked only the first **n times** the event is
+fired, after which it is removed.
+
+```javascript
+emitter.many('get', 4, function (value) {
+ console.log('This event will be listened to exactly four times.');
+});
+```
+
+**options:**
+
+`options?`: See the [addListener options](#emitteronevent-listener-options-objectboolean)
+
+### emitter.prependMany(event | eventNS, timesToListen, listener, options?)
+
+Adds a listener that will execute **n times** for the event before being
+removed. The listener is invoked only the first **n times** the event is
+fired, after which it is removed.
+The listener is added to the beginning of the listeners array.
+
+```javascript
+emitter.many('get', 4, function (value) {
+ console.log('This event will be listened to exactly four times.');
+});
+```
+
+**options:**
+
+`options?`: See the [addListener options](#emitteronevent-listener-options-objectboolean)
+
+### emitter.removeListener(event | eventNS, listener)
+### emitter.off(event | eventNS, listener)
+
+Remove a listener from the listener array for the specified event.
+**Caution**: Calling this method changes the array indices in the listener array behind the listener.
+
+```javascript
+var callback = function(value) {
+ console.log('someone connected!');
+};
+emitter.on('get', callback);
+// ...
+emitter.removeListener('get', callback);
+```
+
+
+### emitter.removeAllListeners([event | eventNS])
+
+Removes all listeners, or those of the specified event.
+
+
+### emitter.setMaxListeners(n)
+
+By default EventEmitters will print a warning if more than 10 listeners
+are added to it. This is a useful default which helps finding memory leaks.
+Obviously not all Emitters should be limited to 10. This function allows
+that to be increased. Set to zero for unlimited.
+
+
+### emitter.getMaxListeners()
+
+Returns the current max listener value for the EventEmitter which is either set by emitter.setMaxListeners(n) or defaults to EventEmitter2.defaultMaxListeners
+
+
+### emitter.listeners(event | eventNS)
+
+Returns an array of listeners for the specified event. This array can be
+manipulated, e.g. to remove listeners.
+
+```javascript
+emitter.on('get', function(value) {
+ console.log('someone connected!');
+});
+console.log(emitter.listeners('get')); // [ [Function] ]
+```
+
+### emitter.listenersAny()
+
+Returns an array of listeners that are listening for any event that is
+specified. This array can be manipulated, e.g. to remove listeners.
+
+```javascript
+emitter.onAny(function(value) {
+ console.log('someone connected!');
+});
+console.log(emitter.listenersAny()[0]); // [ [Function] ]
+```
+
+### emitter.emit(event | eventNS, [arg1], [arg2], [...])
+Execute each of the listeners that may be listening for the specified event
+name in order with the list of arguments.
+
+### emitter.emitAsync(event | eventNS, [arg1], [arg2], [...])
+
+Return the results of the listeners via [Promise.all](https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/Promise/all).
+Only this method doesn't work [IE](http://caniuse.com/#search=promise).
+
+```javascript
+emitter.on('get',function(i) {
+ return new Promise(function(resolve){
+ setTimeout(function(){
+ resolve(i+3);
+ },50);
+ });
+});
+emitter.on('get',function(i) {
+ return new Promise(function(resolve){
+ resolve(i+2)
+ });
+});
+emitter.on('get',function(i) {
+ return Promise.resolve(i+1);
+});
+emitter.on('get',function(i) {
+ return i+0;
+});
+emitter.on('get',function(i) {
+ // noop
+});
+
+emitter.emitAsync('get',0)
+.then(function(results){
+ console.log(results); // [3,2,1,0,undefined]
+});
+```
+
+### emitter.waitFor(event | eventNS, [options])
+### emitter.waitFor(event | eventNS, [timeout])
+### emitter.waitFor(event | eventNS, [filter])
+
+Returns a thenable object (promise interface) that resolves when a specific event occurs
+
+````javascript
+emitter.waitFor('event').then(function (data) {
+ console.log(data); // ['bar']
+});
+
+emitter.emit('event', 'bar');
+````
+
+````javascript
+emitter.waitFor('event', {
+ // handle first event data argument as an error (err, ...data)
+ handleError: false,
+ // the timeout for resolving the promise before it is rejected with an error (Error: timeout).
+ timeout: 0,
+ //filter function to determine acceptable values for resolving the promise.
+ filter: function(arg0, arg1){
+ return arg0==='foo' && arg1==='bar'
+ },
+ Promise: Promise, // Promise constructor to use,
+ overload: false // overload cancellation api in a case of external Promise class
+}).then(function(data){
+ console.log(data); // ['foo', 'bar']
+});
+
+emitter.emit('event', 'foo', 'bar')
+````
+
+````javascript
+var promise= emitter.waitFor('event');
+
+promise.then(null, function(error){
+ console.log(error); //Error: canceled
+});
+
+promise.cancel(); //stop listening the event and reject the promise
+````
+
+````javascript
+emitter.waitFor('event', {
+ handleError: true
+}).then(null, function(error){
+ console.log(error); //Error: custom error
+});
+
+emitter.emit('event', new Error('custom error')); // reject the promise
+````
+### emitter.eventNames(nsAsArray)
+
+Returns an array listing the events for which the emitter has registered listeners.
+```javascript
+var emitter= new EventEmitter2();
+emitter.on('foo', () => {});
+emitter.on('bar', () => {});
+emitter.on(Symbol('test'), () => {});
+emitter.on(['foo', Symbol('test2')], () => {});
+
+console.log(emitter.eventNames());
+// Prints: [ 'bar', 'foo', [ 'foo', Symbol(test2) ], [ 'foo', Symbol(test2) ] ]
+```
+**Note**: Listeners order not guaranteed
+### listenTo(targetEmitter, events: event | eventNS, options?)
+
+### listenTo(targetEmitter, events: (event | eventNS)[], options?)
+
+### listenTo(targetEmitter, events: Object, options?)
+
+Listens to the events emitted by an external emitter and propagate them through itself.
+The target object could be of any type that implements methods for subscribing and unsubscribing to its events.
+By default this method attempts to use `addListener`/`removeListener`, `on`/`off` and `addEventListener`/`removeEventListener` pairs,
+but you able to define own hooks `on(event, handler)` and `off(event, handler)` in the options object to use
+custom subscription API. In these hooks `this` refers to the target object.
+
+The options object has the following interface:
+- `on(event, handler): void`
+- `off(event, handler): void`
+- `reducer: (Function) | (Object): Boolean`
+
+In case you selected the `newListener` and `removeListener` options when creating the emitter,
+the subscription to the events of the target object will be conditional,
+depending on whether there are listeners in the emitter that could listen them.
+
+````javascript
+var EventEmitter2 = require('EventEmitter2');
+var http = require('http');
+
+var server = http.createServer(function(request, response){
+ console.log(request.url);
+ response.end('Hello Node.js Server!')
+}).listen(3000);
+
+server.on('connection', function(req, socket, head){
+ console.log('connect');
+});
+
+// activate the ability to attach listeners on demand
+var emitter= new EventEmitter2({
+ newListener: true,
+ removeListener: true
+});
+
+emitter.listenTo(server, {
+ 'connection': 'localConnection',
+ 'close': 'close'
+}, {
+ reducers: {
+ connection: function(event){
+ console.log('event name:' + event.name); //'localConnection'
+ console.log('original event name:' + event.original); //'connection'
+ return event.data[0].remoteAddress==='::1';
+ }
+ }
+});
+
+emitter.on('localConnection', function(socket){
+ console.log('local connection', socket.remoteAddress);
+});
+
+setTimeout(function(){
+ emitter.stopListeningTo(server);
+}, 30000);
+````
+An example of using a wildcard emitter in a browser:
+````javascript
+const ee= new EventEmitter2({
+ wildcard: true
+});
+
+ee.listenTo(document.querySelector('#test'), {
+ 'click': 'div.click',
+ 'mouseup': 'div.mouseup',
+ 'mousedown': 'div.mousedown'
+});
+
+ee.on('div.*', function(evt){
+ console.log('listenTo: '+ evt.type);
+});
+
+setTimeout(function(){
+ ee.stopListeningTo(document.querySelector('#test'));
+}, 30000);
+````
+
+### stopListeningTo(target?: Object, event: event | eventNS): Boolean
+
+Stops listening the targets. Returns true if some listener was removed.
+
+### hasListeners(event | eventNS?:String):Boolean
+
+Checks whether emitter has any listeners.
+
+### emitter.listeners(event | eventNS)
+
+Returns the array of listeners for the event named eventName.
+In wildcard mode this method returns namespaces as strings:
+````javascript
+var emitter= new EventEmitter2({
+ wildcard: true
+});
+emitter.on('a.b.c', function(){});
+emitter.on(['z', 'x', 'c'], function(){});
+console.log(emitter.eventNames()) // [ 'z.x.c', 'a.b.c' ]
+````
+If some namespace contains a Symbol member or the `nsAsArray` option is set the method will return namespace as an array of its members;
+````javascript
+var emitter= new EventEmitter2({
+ wildcard: true
+});
+emitter.on('a.b.c', function(){});
+emitter.on(['z', 'x', Symbol()], function(){});
+console.log(emitter.eventNames()) // [ [ 'z', 'x', Symbol() ], 'a.b.c' ]
+````
+
+### EventEmitter2.once(emitter, event | eventNS, [options])
+Creates a cancellable Promise that is fulfilled when the EventEmitter emits the given event or that is rejected
+when the EventEmitter emits 'error'.
+The Promise will resolve with an array of all the arguments emitted to the given event.
+This method is intentionally generic and works with the web platform EventTarget interface,
+which has no special 'error' event semantics and does not listen to the 'error' event.
+
+Basic example:
+````javascript
+var emitter= new EventEmitter2();
+
+EventEmitter2.once(emitter, 'event', {
+ timeout: 0,
+ Promise: Promise, // a custom Promise constructor
+ overload: false // overload promise cancellation api if exists with library implementation
+}).then(function(data){
+ console.log(data); // [1, 2, 3]
+});
+
+emitter.emit('event', 1, 2, 3);
+````
+With timeout option:
+````javascript
+EventEmitter2.once(emitter, 'event', {
+ timeout: 1000
+}).then(null, function(err){
+ console.log(err); // Error: timeout
+});
+````
+The library promise cancellation API:
+````javascript
+promise= EventEmitter2.once(emitter, 'event');
+// notice: the cancel method exists only in the first promise chain
+promise.then(null, function(err){
+ console.log(err); // Error: canceled
+});
+
+promise.cancel();
+````
+Using the custom Promise class (**[bluebird.js](https://www.npmjs.com/package/bluebird)**):
+````javascript
+var BBPromise = require("bluebird");
+
+EventEmitter2.once(emitter, 'event', {
+ Promise: BBPromise
+}).then(function(data){
+ console.log(data); // [4, 5, 6]
+});
+
+emitter.emit('event', 4, 5, 6);
+````
+
+````javascript
+var BBPromise = require("bluebird");
+
+BBPromise.config({
+ // if false or options.overload enabled, the library cancellation API will be used
+ cancellation: true
+});
+
+var promise= EventEmitter2.once(emitter, 'event', {
+ Promise: BBPromise,
+ overload: false // use bluebird cancellation API
+}).then(function(data){
+ // notice: never executed due to BlueBird cancellation logic
+}, function(err){
+ // notice: never executed due to BlueBird cancellation logic
+});
+
+promise.cancel();
+
+emitter.emit('event', 'never handled');
+````
+
+### EventEmitter2.defaultMaxListeners
+
+Sets default max listeners count globally for all instances, including those created before the change is made.
diff --git a/node_modules/@pm2/js-api/node_modules/eventemitter2/eventemitter2.d.ts b/node_modules/@pm2/js-api/node_modules/eventemitter2/eventemitter2.d.ts
new file mode 100644
index 0000000..230825b
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/eventemitter2/eventemitter2.d.ts
@@ -0,0 +1,156 @@
+export type event = (symbol|string);
+export type eventNS = string|event[];
+
+export interface ConstructorOptions {
+ /**
+ * @default false
+ * @description set this to `true` to use wildcards.
+ */
+ wildcard?: boolean,
+ /**
+ * @default '.'
+ * @description the delimiter used to segment namespaces.
+ */
+ delimiter?: string,
+ /**
+ * @default false
+ * @description set this to `true` if you want to emit the newListener events.
+ */
+ newListener?: boolean,
+ /**
+ * @default false
+ * @description set this to `true` if you want to emit the removeListener events.
+ */
+ removeListener?: boolean,
+ /**
+ * @default 10
+ * @description the maximum amount of listeners that can be assigned to an event.
+ */
+ maxListeners?: number
+ /**
+ * @default false
+ * @description show event name in memory leak message when more than maximum amount of listeners is assigned, default false
+ */
+ verboseMemoryLeak?: boolean
+ /**
+ * @default false
+ * @description disable throwing uncaughtException if an error event is emitted and it has no listeners
+ */
+ ignoreErrors?: boolean
+}
+export interface ListenerFn {
+ (...values: any[]): void;
+}
+export interface EventAndListener {
+ (event: string | string[], ...values: any[]): void;
+}
+
+export interface WaitForFilter { (...values: any[]): boolean }
+
+export interface WaitForOptions {
+ /**
+ * @default 0
+ */
+ timeout: number,
+ /**
+ * @default null
+ */
+ filter: WaitForFilter,
+ /**
+ * @default false
+ */
+ handleError: boolean,
+ /**
+ * @default Promise
+ */
+ Promise: Function,
+ /**
+ * @default false
+ */
+ overload: boolean
+}
+
+export interface CancelablePromise extends Promise{
+ cancel(reason: string): undefined
+}
+
+export interface OnceOptions {
+ /**
+ * @default 0
+ */
+ timeout: number,
+ /**
+ * @default Promise
+ */
+ Promise: Function,
+ /**
+ * @default false
+ */
+ overload: boolean
+}
+
+export interface ListenToOptions {
+ on?: { (event: event | eventNS, handler: ListenerFn): void },
+ off?: { (event: event | eventNS, handler: ListenerFn): void },
+ reducers: Function | Object
+}
+
+export interface GeneralEventEmitter{
+ addEventListener(event: event, handler: ListenerFn): this,
+ removeEventListener(event: event, handler: ListenerFn): this,
+ addListener?(event: event, handler: ListenerFn): this,
+ removeListener?(event: event, handler: ListenerFn): this,
+ on?(event: event, handler: ListenerFn): this,
+ off?(event: event, handler: ListenerFn): this
+}
+
+export interface OnOptions {
+ async?: boolean,
+ promisify?: boolean,
+ nextTick?: boolean,
+ objectify?: boolean
+}
+
+export interface Listener {
+ emitter: EventEmitter2;
+ event: event|eventNS;
+ listener: ListenerFn;
+ off(): this;
+}
+
+export declare class EventEmitter2 {
+ constructor(options?: ConstructorOptions)
+ emit(event: event | eventNS, ...values: any[]): boolean;
+ emitAsync(event: event | eventNS, ...values: any[]): Promise;
+ addListener(event: event | eventNS, listener: ListenerFn): this|Listener;
+ on(event: event | eventNS, listener: ListenerFn, options?: boolean|OnOptions): this|Listener;
+ prependListener(event: event | eventNS, listener: ListenerFn, options?: boolean|OnOptions): this|Listener;
+ once(event: event | eventNS, listener: ListenerFn, options?: true|OnOptions): this|Listener;
+ prependOnceListener(event: event | eventNS, listener: ListenerFn, options?: boolean|OnOptions): this|Listener;
+ many(event: event | eventNS, timesToListen: number, listener: ListenerFn, options?: boolean|OnOptions): this|Listener;
+ prependMany(event: event | eventNS, timesToListen: number, listener: ListenerFn, options?: boolean|OnOptions): this|Listener;
+ onAny(listener: EventAndListener): this;
+ prependAny(listener: EventAndListener): this;
+ offAny(listener: ListenerFn): this;
+ removeListener(event: event | eventNS, listener: ListenerFn): this;
+ off(event: event | eventNS, listener: ListenerFn): this;
+ removeAllListeners(event?: event | eventNS): this;
+ setMaxListeners(n: number): void;
+ getMaxListeners(): number;
+ eventNames(nsAsArray?: boolean): (event|eventNS)[];
+ listenerCount(event?: event | eventNS): number
+ listeners(event?: event | eventNS): ListenerFn[]
+ listenersAny(): ListenerFn[]
+ waitFor(event: event | eventNS, timeout?: number): CancelablePromise
+ waitFor(event: event | eventNS, filter?: WaitForFilter): CancelablePromise
+ waitFor(event: event | eventNS, options?: WaitForOptions): CancelablePromise
+ listenTo(target: GeneralEventEmitter, events: event | eventNS, options?: ListenToOptions): this;
+ listenTo(target: GeneralEventEmitter, events: event[], options?: ListenToOptions): this;
+ listenTo(target: GeneralEventEmitter, events: Object, options?: ListenToOptions): this;
+ stopListeningTo(target?: GeneralEventEmitter, event?: event | eventNS): Boolean;
+ hasListeners(event?: String): Boolean
+ static once(emitter: EventEmitter2, event: event | eventNS, options?: OnceOptions): CancelablePromise;
+ static defaultMaxListeners: number;
+}
+
+export default EventEmitter2;
diff --git a/node_modules/@pm2/js-api/node_modules/eventemitter2/index.js b/node_modules/@pm2/js-api/node_modules/eventemitter2/index.js
new file mode 100644
index 0000000..6f583b5
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/eventemitter2/index.js
@@ -0,0 +1 @@
+module.exports = require('./lib/eventemitter2');
diff --git a/node_modules/@pm2/js-api/node_modules/eventemitter2/lib/eventemitter2.js b/node_modules/@pm2/js-api/node_modules/eventemitter2/lib/eventemitter2.js
new file mode 100644
index 0000000..7c2e550
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/eventemitter2/lib/eventemitter2.js
@@ -0,0 +1,1629 @@
+/*!
+ * EventEmitter2
+ * https://github.com/hij1nx/EventEmitter2
+ *
+ * Copyright (c) 2013 hij1nx
+ * Licensed under the MIT license.
+ */
+;!function(undefined) {
+ var hasOwnProperty= Object.hasOwnProperty;
+ var isArray = Array.isArray ? Array.isArray : function _isArray(obj) {
+ return Object.prototype.toString.call(obj) === "[object Array]";
+ };
+ var defaultMaxListeners = 10;
+ var nextTickSupported= typeof process=='object' && typeof process.nextTick=='function';
+ var symbolsSupported= typeof Symbol==='function';
+ var reflectSupported= typeof Reflect === 'object';
+ var setImmediateSupported= typeof setImmediate === 'function';
+ var _setImmediate= setImmediateSupported ? setImmediate : setTimeout;
+ var ownKeys= symbolsSupported? (reflectSupported && typeof Reflect.ownKeys==='function'? Reflect.ownKeys : function(obj){
+ var arr= Object.getOwnPropertyNames(obj);
+ arr.push.apply(arr, Object.getOwnPropertySymbols(obj));
+ return arr;
+ }) : Object.keys;
+
+ function init() {
+ this._events = {};
+ if (this._conf) {
+ configure.call(this, this._conf);
+ }
+ }
+
+ function configure(conf) {
+ if (conf) {
+ this._conf = conf;
+
+ conf.delimiter && (this.delimiter = conf.delimiter);
+
+ if(conf.maxListeners!==undefined){
+ this._maxListeners= conf.maxListeners;
+ }
+
+ conf.wildcard && (this.wildcard = conf.wildcard);
+ conf.newListener && (this._newListener = conf.newListener);
+ conf.removeListener && (this._removeListener = conf.removeListener);
+ conf.verboseMemoryLeak && (this.verboseMemoryLeak = conf.verboseMemoryLeak);
+ conf.ignoreErrors && (this.ignoreErrors = conf.ignoreErrors);
+
+ if (this.wildcard) {
+ this.listenerTree = {};
+ }
+ }
+ }
+
+ function logPossibleMemoryLeak(count, eventName) {
+ var errorMsg = '(node) warning: possible EventEmitter memory ' +
+ 'leak detected. ' + count + ' listeners added. ' +
+ 'Use emitter.setMaxListeners() to increase limit.';
+
+ if(this.verboseMemoryLeak){
+ errorMsg += ' Event name: ' + eventName + '.';
+ }
+
+ if(typeof process !== 'undefined' && process.emitWarning){
+ var e = new Error(errorMsg);
+ e.name = 'MaxListenersExceededWarning';
+ e.emitter = this;
+ e.count = count;
+ process.emitWarning(e);
+ } else {
+ console.error(errorMsg);
+
+ if (console.trace){
+ console.trace();
+ }
+ }
+ }
+
+ var toArray = function (a, b, c) {
+ var n = arguments.length;
+ switch (n) {
+ case 0:
+ return [];
+ case 1:
+ return [a];
+ case 2:
+ return [a, b];
+ case 3:
+ return [a, b, c];
+ default:
+ var arr = new Array(n);
+ while (n--) {
+ arr[n] = arguments[n];
+ }
+ return arr;
+ }
+ };
+
+ function toObject(keys, values) {
+ var obj = {};
+ var key;
+ var len = keys.length;
+ var valuesCount = values ? values.length : 0;
+ for (var i = 0; i < len; i++) {
+ key = keys[i];
+ obj[key] = i < valuesCount ? values[i] : undefined;
+ }
+ return obj;
+ }
+
+ function TargetObserver(emitter, target, options) {
+ this._emitter = emitter;
+ this._target = target;
+ this._listeners = {};
+ this._listenersCount = 0;
+
+ var on, off;
+
+ if (options.on || options.off) {
+ on = options.on;
+ off = options.off;
+ }
+
+ if (target.addEventListener) {
+ on = target.addEventListener;
+ off = target.removeEventListener;
+ } else if (target.addListener) {
+ on = target.addListener;
+ off = target.removeListener;
+ } else if (target.on) {
+ on = target.on;
+ off = target.off;
+ }
+
+ if (!on && !off) {
+ throw Error('target does not implement any known event API');
+ }
+
+ if (typeof on !== 'function') {
+ throw TypeError('on method must be a function');
+ }
+
+ if (typeof off !== 'function') {
+ throw TypeError('off method must be a function');
+ }
+
+ this._on = on;
+ this._off = off;
+
+ var _observers= emitter._observers;
+ if(_observers){
+ _observers.push(this);
+ }else{
+ emitter._observers= [this];
+ }
+ }
+
+ Object.assign(TargetObserver.prototype, {
+ subscribe: function(event, localEvent, reducer){
+ var observer= this;
+ var target= this._target;
+ var emitter= this._emitter;
+ var listeners= this._listeners;
+ var handler= function(){
+ var args= toArray.apply(null, arguments);
+ var eventObj= {
+ data: args,
+ name: localEvent,
+ original: event
+ };
+ if(reducer){
+ var result= reducer.call(target, eventObj);
+ if(result!==false){
+ emitter.emit.apply(emitter, [eventObj.name].concat(args))
+ }
+ return;
+ }
+ emitter.emit.apply(emitter, [localEvent].concat(args));
+ };
+
+
+ if(listeners[event]){
+ throw Error('Event \'' + event + '\' is already listening');
+ }
+
+ this._listenersCount++;
+
+ if(emitter._newListener && emitter._removeListener && !observer._onNewListener){
+
+ this._onNewListener = function (_event) {
+ if (_event === localEvent && listeners[event] === null) {
+ listeners[event] = handler;
+ observer._on.call(target, event, handler);
+ }
+ };
+
+ emitter.on('newListener', this._onNewListener);
+
+ this._onRemoveListener= function(_event){
+ if(_event === localEvent && !emitter.hasListeners(_event) && listeners[event]){
+ listeners[event]= null;
+ observer._off.call(target, event, handler);
+ }
+ };
+
+ listeners[event]= null;
+
+ emitter.on('removeListener', this._onRemoveListener);
+ }else{
+ listeners[event]= handler;
+ observer._on.call(target, event, handler);
+ }
+ },
+
+ unsubscribe: function(event){
+ var observer= this;
+ var listeners= this._listeners;
+ var emitter= this._emitter;
+ var handler;
+ var events;
+ var off= this._off;
+ var target= this._target;
+ var i;
+
+ if(event && typeof event!=='string'){
+ throw TypeError('event must be a string');
+ }
+
+ function clearRefs(){
+ if(observer._onNewListener){
+ emitter.off('newListener', observer._onNewListener);
+ emitter.off('removeListener', observer._onRemoveListener);
+ observer._onNewListener= null;
+ observer._onRemoveListener= null;
+ }
+ var index= findTargetIndex.call(emitter, observer);
+ emitter._observers.splice(index, 1);
+ }
+
+ if(event){
+ handler= listeners[event];
+ if(!handler) return;
+ off.call(target, event, handler);
+ delete listeners[event];
+ if(!--this._listenersCount){
+ clearRefs();
+ }
+ }else{
+ events= ownKeys(listeners);
+ i= events.length;
+ while(i-->0){
+ event= events[i];
+ off.call(target, event, listeners[event]);
+ }
+ this._listeners= {};
+ this._listenersCount= 0;
+ clearRefs();
+ }
+ }
+ });
+
+ function resolveOptions(options, schema, reducers, allowUnknown) {
+ var computedOptions = Object.assign({}, schema);
+
+ if (!options) return computedOptions;
+
+ if (typeof options !== 'object') {
+ throw TypeError('options must be an object')
+ }
+
+ var keys = Object.keys(options);
+ var length = keys.length;
+ var option, value;
+ var reducer;
+
+ function reject(reason) {
+ throw Error('Invalid "' + option + '" option value' + (reason ? '. Reason: ' + reason : ''))
+ }
+
+ for (var i = 0; i < length; i++) {
+ option = keys[i];
+ if (!allowUnknown && !hasOwnProperty.call(schema, option)) {
+ throw Error('Unknown "' + option + '" option');
+ }
+ value = options[option];
+ if (value !== undefined) {
+ reducer = reducers[option];
+ computedOptions[option] = reducer ? reducer(value, reject) : value;
+ }
+ }
+ return computedOptions;
+ }
+
+ function constructorReducer(value, reject) {
+ if (typeof value !== 'function' || !value.hasOwnProperty('prototype')) {
+ reject('value must be a constructor');
+ }
+ return value;
+ }
+
+ function makeTypeReducer(types) {
+ var message= 'value must be type of ' + types.join('|');
+ var len= types.length;
+ var firstType= types[0];
+ var secondType= types[1];
+
+ if (len === 1) {
+ return function (v, reject) {
+ if (typeof v === firstType) {
+ return v;
+ }
+ reject(message);
+ }
+ }
+
+ if (len === 2) {
+ return function (v, reject) {
+ var kind= typeof v;
+ if (kind === firstType || kind === secondType) return v;
+ reject(message);
+ }
+ }
+
+ return function (v, reject) {
+ var kind = typeof v;
+ var i = len;
+ while (i-- > 0) {
+ if (kind === types[i]) return v;
+ }
+ reject(message);
+ }
+ }
+
+ var functionReducer= makeTypeReducer(['function']);
+
+ var objectFunctionReducer= makeTypeReducer(['object', 'function']);
+
+ function makeCancelablePromise(Promise, executor, options) {
+ var isCancelable;
+ var callbacks;
+ var timer= 0;
+ var subscriptionClosed;
+
+ var promise = new Promise(function (resolve, reject, onCancel) {
+ options= resolveOptions(options, {
+ timeout: 0,
+ overload: false
+ }, {
+ timeout: function(value, reject){
+ value*= 1;
+ if (typeof value !== 'number' || value < 0 || !Number.isFinite(value)) {
+ reject('timeout must be a positive number');
+ }
+ return value;
+ }
+ });
+
+ isCancelable = !options.overload && typeof Promise.prototype.cancel === 'function' && typeof onCancel === 'function';
+
+ function cleanup() {
+ if (callbacks) {
+ callbacks = null;
+ }
+ if (timer) {
+ clearTimeout(timer);
+ timer = 0;
+ }
+ }
+
+ var _resolve= function(value){
+ cleanup();
+ resolve(value);
+ };
+
+ var _reject= function(err){
+ cleanup();
+ reject(err);
+ };
+
+ if (isCancelable) {
+ executor(_resolve, _reject, onCancel);
+ } else {
+ callbacks = [function(reason){
+ _reject(reason || Error('canceled'));
+ }];
+ executor(_resolve, _reject, function (cb) {
+ if (subscriptionClosed) {
+ throw Error('Unable to subscribe on cancel event asynchronously')
+ }
+ if (typeof cb !== 'function') {
+ throw TypeError('onCancel callback must be a function');
+ }
+ callbacks.push(cb);
+ });
+ subscriptionClosed= true;
+ }
+
+ if (options.timeout > 0) {
+ timer= setTimeout(function(){
+ var reason= Error('timeout');
+ reason.code = 'ETIMEDOUT'
+ timer= 0;
+ promise.cancel(reason);
+ reject(reason);
+ }, options.timeout);
+ }
+ });
+
+ if (!isCancelable) {
+ promise.cancel = function (reason) {
+ if (!callbacks) {
+ return;
+ }
+ var length = callbacks.length;
+ for (var i = 1; i < length; i++) {
+ callbacks[i](reason);
+ }
+ // internal callback to reject the promise
+ callbacks[0](reason);
+ callbacks = null;
+ };
+ }
+
+ return promise;
+ }
+
+ function findTargetIndex(observer) {
+ var observers = this._observers;
+ if(!observers){
+ return -1;
+ }
+ var len = observers.length;
+ for (var i = 0; i < len; i++) {
+ if (observers[i]._target === observer) return i;
+ }
+ return -1;
+ }
+
+ // Attention, function return type now is array, always !
+ // It has zero elements if no any matches found and one or more
+ // elements (leafs) if there are matches
+ //
+ function searchListenerTree(handlers, type, tree, i, typeLength) {
+ if (!tree) {
+ return null;
+ }
+
+ if (i === 0) {
+ var kind = typeof type;
+ if (kind === 'string') {
+ var ns, n, l = 0, j = 0, delimiter = this.delimiter, dl = delimiter.length;
+ if ((n = type.indexOf(delimiter)) !== -1) {
+ ns = new Array(5);
+ do {
+ ns[l++] = type.slice(j, n);
+ j = n + dl;
+ } while ((n = type.indexOf(delimiter, j)) !== -1);
+
+ ns[l++] = type.slice(j);
+ type = ns;
+ typeLength = l;
+ } else {
+ type = [type];
+ typeLength = 1;
+ }
+ } else if (kind === 'object') {
+ typeLength = type.length;
+ } else {
+ type = [type];
+ typeLength = 1;
+ }
+ }
+
+ var listeners= null, branch, xTree, xxTree, isolatedBranch, endReached, currentType = type[i],
+ nextType = type[i + 1], branches, _listeners;
+
+ if (i === typeLength) {
+ //
+ // If at the end of the event(s) list and the tree has listeners
+ // invoke those listeners.
+ //
+
+ if(tree._listeners) {
+ if (typeof tree._listeners === 'function') {
+ handlers && handlers.push(tree._listeners);
+ listeners = [tree];
+ } else {
+ handlers && handlers.push.apply(handlers, tree._listeners);
+ listeners = [tree];
+ }
+ }
+ } else {
+
+ if (currentType === '*') {
+ //
+ // If the event emitted is '*' at this part
+ // or there is a concrete match at this patch
+ //
+ branches = ownKeys(tree);
+ n = branches.length;
+ while (n-- > 0) {
+ branch = branches[n];
+ if (branch !== '_listeners') {
+ _listeners = searchListenerTree(handlers, type, tree[branch], i + 1, typeLength);
+ if (_listeners) {
+ if (listeners) {
+ listeners.push.apply(listeners, _listeners);
+ } else {
+ listeners = _listeners;
+ }
+ }
+ }
+ }
+ return listeners;
+ } else if (currentType === '**') {
+ endReached = (i + 1 === typeLength || (i + 2 === typeLength && nextType === '*'));
+ if (endReached && tree._listeners) {
+ // The next element has a _listeners, add it to the handlers.
+ listeners = searchListenerTree(handlers, type, tree, typeLength, typeLength);
+ }
+
+ branches = ownKeys(tree);
+ n = branches.length;
+ while (n-- > 0) {
+ branch = branches[n];
+ if (branch !== '_listeners') {
+ if (branch === '*' || branch === '**') {
+ if (tree[branch]._listeners && !endReached) {
+ _listeners = searchListenerTree(handlers, type, tree[branch], typeLength, typeLength);
+ if (_listeners) {
+ if (listeners) {
+ listeners.push.apply(listeners, _listeners);
+ } else {
+ listeners = _listeners;
+ }
+ }
+ }
+ _listeners = searchListenerTree(handlers, type, tree[branch], i, typeLength);
+ } else if (branch === nextType) {
+ _listeners = searchListenerTree(handlers, type, tree[branch], i + 2, typeLength);
+ } else {
+ // No match on this one, shift into the tree but not in the type array.
+ _listeners = searchListenerTree(handlers, type, tree[branch], i, typeLength);
+ }
+ if (_listeners) {
+ if (listeners) {
+ listeners.push.apply(listeners, _listeners);
+ } else {
+ listeners = _listeners;
+ }
+ }
+ }
+ }
+ return listeners;
+ } else if (tree[currentType]) {
+ listeners = searchListenerTree(handlers, type, tree[currentType], i + 1, typeLength);
+ }
+ }
+
+ xTree = tree['*'];
+ if (xTree) {
+ //
+ // If the listener tree will allow any match for this part,
+ // then recursively explore all branches of the tree
+ //
+ searchListenerTree(handlers, type, xTree, i + 1, typeLength);
+ }
+
+ xxTree = tree['**'];
+ if (xxTree) {
+ if (i < typeLength) {
+ if (xxTree._listeners) {
+ // If we have a listener on a '**', it will catch all, so add its handler.
+ searchListenerTree(handlers, type, xxTree, typeLength, typeLength);
+ }
+
+ // Build arrays of matching next branches and others.
+ branches= ownKeys(xxTree);
+ n= branches.length;
+ while(n-->0){
+ branch= branches[n];
+ if (branch !== '_listeners') {
+ if (branch === nextType) {
+ // We know the next element will match, so jump twice.
+ searchListenerTree(handlers, type, xxTree[branch], i + 2, typeLength);
+ } else if (branch === currentType) {
+ // Current node matches, move into the tree.
+ searchListenerTree(handlers, type, xxTree[branch], i + 1, typeLength);
+ } else {
+ isolatedBranch = {};
+ isolatedBranch[branch] = xxTree[branch];
+ searchListenerTree(handlers, type, {'**': isolatedBranch}, i + 1, typeLength);
+ }
+ }
+ }
+ } else if (xxTree._listeners) {
+ // We have reached the end and still on a '**'
+ searchListenerTree(handlers, type, xxTree, typeLength, typeLength);
+ } else if (xxTree['*'] && xxTree['*']._listeners) {
+ searchListenerTree(handlers, type, xxTree['*'], typeLength, typeLength);
+ }
+ }
+
+ return listeners;
+ }
+
+ function growListenerTree(type, listener, prepend) {
+ var len = 0, j = 0, i, delimiter = this.delimiter, dl= delimiter.length, ns;
+
+ if(typeof type==='string') {
+ if ((i = type.indexOf(delimiter)) !== -1) {
+ ns = new Array(5);
+ do {
+ ns[len++] = type.slice(j, i);
+ j = i + dl;
+ } while ((i = type.indexOf(delimiter, j)) !== -1);
+
+ ns[len++] = type.slice(j);
+ }else{
+ ns= [type];
+ len= 1;
+ }
+ }else{
+ ns= type;
+ len= type.length;
+ }
+
+ //
+ // Looks for two consecutive '**', if so, don't add the event at all.
+ //
+ if (len > 1) {
+ for (i = 0; i + 1 < len; i++) {
+ if (ns[i] === '**' && ns[i + 1] === '**') {
+ return;
+ }
+ }
+ }
+
+
+
+ var tree = this.listenerTree, name;
+
+ for (i = 0; i < len; i++) {
+ name = ns[i];
+
+ tree = tree[name] || (tree[name] = {});
+
+ if (i === len - 1) {
+ if (!tree._listeners) {
+ tree._listeners = listener;
+ } else {
+ if (typeof tree._listeners === 'function') {
+ tree._listeners = [tree._listeners];
+ }
+
+ if (prepend) {
+ tree._listeners.unshift(listener);
+ } else {
+ tree._listeners.push(listener);
+ }
+
+ if (
+ !tree._listeners.warned &&
+ this._maxListeners > 0 &&
+ tree._listeners.length > this._maxListeners
+ ) {
+ tree._listeners.warned = true;
+ logPossibleMemoryLeak.call(this, tree._listeners.length, name);
+ }
+ }
+ return true;
+ }
+ }
+
+ return true;
+ }
+
+ function collectTreeEvents(tree, events, root, asArray){
+ var branches= ownKeys(tree);
+ var i= branches.length;
+ var branch, branchName, path;
+ var hasListeners= tree['_listeners'];
+ var isArrayPath;
+
+ while(i-->0){
+ branchName= branches[i];
+
+ branch= tree[branchName];
+
+ if(branchName==='_listeners'){
+ path= root;
+ }else {
+ path = root ? root.concat(branchName) : [branchName];
+ }
+
+ isArrayPath= asArray || typeof branchName==='symbol';
+
+ hasListeners && events.push(isArrayPath? path : path.join(this.delimiter));
+
+ if(typeof branch==='object'){
+ collectTreeEvents.call(this, branch, events, path, isArrayPath);
+ }
+ }
+
+ return events;
+ }
+
+ function recursivelyGarbageCollect(root) {
+ var keys = ownKeys(root);
+ var i= keys.length;
+ var obj, key, flag;
+ while(i-->0){
+ key = keys[i];
+ obj = root[key];
+
+ if(obj){
+ flag= true;
+ if(key !== '_listeners' && !recursivelyGarbageCollect(obj)){
+ delete root[key];
+ }
+ }
+ }
+
+ return flag;
+ }
+
+ function Listener(emitter, event, listener){
+ this.emitter= emitter;
+ this.event= event;
+ this.listener= listener;
+ }
+
+ Listener.prototype.off= function(){
+ this.emitter.off(this.event, this.listener);
+ return this;
+ };
+
+ function setupListener(event, listener, options){
+ if (options === true) {
+ promisify = true;
+ } else if (options === false) {
+ async = true;
+ } else {
+ if (!options || typeof options !== 'object') {
+ throw TypeError('options should be an object or true');
+ }
+ var async = options.async;
+ var promisify = options.promisify;
+ var nextTick = options.nextTick;
+ var objectify = options.objectify;
+ }
+
+ if (async || nextTick || promisify) {
+ var _listener = listener;
+ var _origin = listener._origin || listener;
+
+ if (nextTick && !nextTickSupported) {
+ throw Error('process.nextTick is not supported');
+ }
+
+ if (promisify === undefined) {
+ promisify = listener.constructor.name === 'AsyncFunction';
+ }
+
+ listener = function () {
+ var args = arguments;
+ var context = this;
+ var event = this.event;
+
+ return promisify ? (nextTick ? Promise.resolve() : new Promise(function (resolve) {
+ _setImmediate(resolve);
+ }).then(function () {
+ context.event = event;
+ return _listener.apply(context, args)
+ })) : (nextTick ? process.nextTick : _setImmediate)(function () {
+ context.event = event;
+ _listener.apply(context, args)
+ });
+ };
+
+ listener._async = true;
+ listener._origin = _origin;
+ }
+
+ return [listener, objectify? new Listener(this, event, listener): this];
+ }
+
+ function EventEmitter(conf) {
+ this._events = {};
+ this._newListener = false;
+ this._removeListener = false;
+ this.verboseMemoryLeak = false;
+ configure.call(this, conf);
+ }
+
+ EventEmitter.EventEmitter2 = EventEmitter; // backwards compatibility for exporting EventEmitter property
+
+ EventEmitter.prototype.listenTo= function(target, events, options){
+ if(typeof target!=='object'){
+ throw TypeError('target musts be an object');
+ }
+
+ var emitter= this;
+
+ options = resolveOptions(options, {
+ on: undefined,
+ off: undefined,
+ reducers: undefined
+ }, {
+ on: functionReducer,
+ off: functionReducer,
+ reducers: objectFunctionReducer
+ });
+
+ function listen(events){
+ if(typeof events!=='object'){
+ throw TypeError('events must be an object');
+ }
+
+ var reducers= options.reducers;
+ var index= findTargetIndex.call(emitter, target);
+ var observer;
+
+ if(index===-1){
+ observer= new TargetObserver(emitter, target, options);
+ }else{
+ observer= emitter._observers[index];
+ }
+
+ var keys= ownKeys(events);
+ var len= keys.length;
+ var event;
+ var isSingleReducer= typeof reducers==='function';
+
+ for(var i=0; i 0) {
+ observer = observers[i];
+ if (!target || observer._target === target) {
+ observer.unsubscribe(event);
+ matched= true;
+ }
+ }
+
+ return matched;
+ };
+
+ // By default EventEmitters will print a warning if more than
+ // 10 listeners are added to it. This is a useful default which
+ // helps finding memory leaks.
+ //
+ // Obviously not all Emitters should be limited to 10. This function allows
+ // that to be increased. Set to zero for unlimited.
+
+ EventEmitter.prototype.delimiter = '.';
+
+ EventEmitter.prototype.setMaxListeners = function(n) {
+ if (n !== undefined) {
+ this._maxListeners = n;
+ if (!this._conf) this._conf = {};
+ this._conf.maxListeners = n;
+ }
+ };
+
+ EventEmitter.prototype.getMaxListeners = function() {
+ return this._maxListeners;
+ };
+
+ EventEmitter.prototype.event = '';
+
+ EventEmitter.prototype.once = function(event, fn, options) {
+ return this._once(event, fn, false, options);
+ };
+
+ EventEmitter.prototype.prependOnceListener = function(event, fn, options) {
+ return this._once(event, fn, true, options);
+ };
+
+ EventEmitter.prototype._once = function(event, fn, prepend, options) {
+ return this._many(event, 1, fn, prepend, options);
+ };
+
+ EventEmitter.prototype.many = function(event, ttl, fn, options) {
+ return this._many(event, ttl, fn, false, options);
+ };
+
+ EventEmitter.prototype.prependMany = function(event, ttl, fn, options) {
+ return this._many(event, ttl, fn, true, options);
+ };
+
+ EventEmitter.prototype._many = function(event, ttl, fn, prepend, options) {
+ var self = this;
+
+ if (typeof fn !== 'function') {
+ throw new Error('many only accepts instances of Function');
+ }
+
+ function listener() {
+ if (--ttl === 0) {
+ self.off(event, listener);
+ }
+ return fn.apply(this, arguments);
+ }
+
+ listener._origin = fn;
+
+ return this._on(event, listener, prepend, options);
+ };
+
+ EventEmitter.prototype.emit = function() {
+ if (!this._events && !this._all) {
+ return false;
+ }
+
+ this._events || init.call(this);
+
+ var type = arguments[0], ns, wildcard= this.wildcard;
+ var args,l,i,j, containsSymbol;
+
+ if (type === 'newListener' && !this._newListener) {
+ if (!this._events.newListener) {
+ return false;
+ }
+ }
+
+ if (wildcard) {
+ ns= type;
+ if(type!=='newListener' && type!=='removeListener'){
+ if (typeof type === 'object') {
+ l = type.length;
+ if (symbolsSupported) {
+ for (i = 0; i < l; i++) {
+ if (typeof type[i] === 'symbol') {
+ containsSymbol = true;
+ break;
+ }
+ }
+ }
+ if (!containsSymbol) {
+ type = type.join(this.delimiter);
+ }
+ }
+ }
+ }
+
+ var al = arguments.length;
+ var handler;
+
+ if (this._all && this._all.length) {
+ handler = this._all.slice();
+
+ for (i = 0, l = handler.length; i < l; i++) {
+ this.event = type;
+ switch (al) {
+ case 1:
+ handler[i].call(this, type);
+ break;
+ case 2:
+ handler[i].call(this, type, arguments[1]);
+ break;
+ case 3:
+ handler[i].call(this, type, arguments[1], arguments[2]);
+ break;
+ default:
+ handler[i].apply(this, arguments);
+ }
+ }
+ }
+
+ if (wildcard) {
+ handler = [];
+ searchListenerTree.call(this, handler, ns, this.listenerTree, 0, l);
+ } else {
+ handler = this._events[type];
+ if (typeof handler === 'function') {
+ this.event = type;
+ switch (al) {
+ case 1:
+ handler.call(this);
+ break;
+ case 2:
+ handler.call(this, arguments[1]);
+ break;
+ case 3:
+ handler.call(this, arguments[1], arguments[2]);
+ break;
+ default:
+ args = new Array(al - 1);
+ for (j = 1; j < al; j++) args[j - 1] = arguments[j];
+ handler.apply(this, args);
+ }
+ return true;
+ } else if (handler) {
+ // need to make copy of handlers because list can change in the middle
+ // of emit call
+ handler = handler.slice();
+ }
+ }
+
+ if (handler && handler.length) {
+ if (al > 3) {
+ args = new Array(al - 1);
+ for (j = 1; j < al; j++) args[j - 1] = arguments[j];
+ }
+ for (i = 0, l = handler.length; i < l; i++) {
+ this.event = type;
+ switch (al) {
+ case 1:
+ handler[i].call(this);
+ break;
+ case 2:
+ handler[i].call(this, arguments[1]);
+ break;
+ case 3:
+ handler[i].call(this, arguments[1], arguments[2]);
+ break;
+ default:
+ handler[i].apply(this, args);
+ }
+ }
+ return true;
+ } else if (!this.ignoreErrors && !this._all && type === 'error') {
+ if (arguments[1] instanceof Error) {
+ throw arguments[1]; // Unhandled 'error' event
+ } else {
+ throw new Error("Uncaught, unspecified 'error' event.");
+ }
+ }
+
+ return !!this._all;
+ };
+
+ EventEmitter.prototype.emitAsync = function() {
+ if (!this._events && !this._all) {
+ return false;
+ }
+
+ this._events || init.call(this);
+
+ var type = arguments[0], wildcard= this.wildcard, ns, containsSymbol;
+ var args,l,i,j;
+
+ if (type === 'newListener' && !this._newListener) {
+ if (!this._events.newListener) { return Promise.resolve([false]); }
+ }
+
+ if (wildcard) {
+ ns= type;
+ if(type!=='newListener' && type!=='removeListener'){
+ if (typeof type === 'object') {
+ l = type.length;
+ if (symbolsSupported) {
+ for (i = 0; i < l; i++) {
+ if (typeof type[i] === 'symbol') {
+ containsSymbol = true;
+ break;
+ }
+ }
+ }
+ if (!containsSymbol) {
+ type = type.join(this.delimiter);
+ }
+ }
+ }
+ }
+
+ var promises= [];
+
+ var al = arguments.length;
+ var handler;
+
+ if (this._all) {
+ for (i = 0, l = this._all.length; i < l; i++) {
+ this.event = type;
+ switch (al) {
+ case 1:
+ promises.push(this._all[i].call(this, type));
+ break;
+ case 2:
+ promises.push(this._all[i].call(this, type, arguments[1]));
+ break;
+ case 3:
+ promises.push(this._all[i].call(this, type, arguments[1], arguments[2]));
+ break;
+ default:
+ promises.push(this._all[i].apply(this, arguments));
+ }
+ }
+ }
+
+ if (wildcard) {
+ handler = [];
+ searchListenerTree.call(this, handler, ns, this.listenerTree, 0);
+ } else {
+ handler = this._events[type];
+ }
+
+ if (typeof handler === 'function') {
+ this.event = type;
+ switch (al) {
+ case 1:
+ promises.push(handler.call(this));
+ break;
+ case 2:
+ promises.push(handler.call(this, arguments[1]));
+ break;
+ case 3:
+ promises.push(handler.call(this, arguments[1], arguments[2]));
+ break;
+ default:
+ args = new Array(al - 1);
+ for (j = 1; j < al; j++) args[j - 1] = arguments[j];
+ promises.push(handler.apply(this, args));
+ }
+ } else if (handler && handler.length) {
+ handler = handler.slice();
+ if (al > 3) {
+ args = new Array(al - 1);
+ for (j = 1; j < al; j++) args[j - 1] = arguments[j];
+ }
+ for (i = 0, l = handler.length; i < l; i++) {
+ this.event = type;
+ switch (al) {
+ case 1:
+ promises.push(handler[i].call(this));
+ break;
+ case 2:
+ promises.push(handler[i].call(this, arguments[1]));
+ break;
+ case 3:
+ promises.push(handler[i].call(this, arguments[1], arguments[2]));
+ break;
+ default:
+ promises.push(handler[i].apply(this, args));
+ }
+ }
+ } else if (!this.ignoreErrors && !this._all && type === 'error') {
+ if (arguments[1] instanceof Error) {
+ return Promise.reject(arguments[1]); // Unhandled 'error' event
+ } else {
+ return Promise.reject("Uncaught, unspecified 'error' event.");
+ }
+ }
+
+ return Promise.all(promises);
+ };
+
+ EventEmitter.prototype.on = function(type, listener, options) {
+ return this._on(type, listener, false, options);
+ };
+
+ EventEmitter.prototype.prependListener = function(type, listener, options) {
+ return this._on(type, listener, true, options);
+ };
+
+ EventEmitter.prototype.onAny = function(fn) {
+ return this._onAny(fn, false);
+ };
+
+ EventEmitter.prototype.prependAny = function(fn) {
+ return this._onAny(fn, true);
+ };
+
+ EventEmitter.prototype.addListener = EventEmitter.prototype.on;
+
+ EventEmitter.prototype._onAny = function(fn, prepend){
+ if (typeof fn !== 'function') {
+ throw new Error('onAny only accepts instances of Function');
+ }
+
+ if (!this._all) {
+ this._all = [];
+ }
+
+ // Add the function to the event listener collection.
+ if(prepend){
+ this._all.unshift(fn);
+ }else{
+ this._all.push(fn);
+ }
+
+ return this;
+ };
+
+ EventEmitter.prototype._on = function(type, listener, prepend, options) {
+ if (typeof type === 'function') {
+ this._onAny(type, listener);
+ return this;
+ }
+
+ if (typeof listener !== 'function') {
+ throw new Error('on only accepts instances of Function');
+ }
+ this._events || init.call(this);
+
+ var returnValue= this, temp;
+
+ if (options !== undefined) {
+ temp = setupListener.call(this, type, listener, options);
+ listener = temp[0];
+ returnValue = temp[1];
+ }
+
+ // To avoid recursion in the case that type == "newListeners"! Before
+ // adding it to the listeners, first emit "newListeners".
+ if (this._newListener) {
+ this.emit('newListener', type, listener);
+ }
+
+ if (this.wildcard) {
+ growListenerTree.call(this, type, listener, prepend);
+ return returnValue;
+ }
+
+ if (!this._events[type]) {
+ // Optimize the case of one listener. Don't need the extra array object.
+ this._events[type] = listener;
+ } else {
+ if (typeof this._events[type] === 'function') {
+ // Change to array.
+ this._events[type] = [this._events[type]];
+ }
+
+ // If we've already got an array, just add
+ if(prepend){
+ this._events[type].unshift(listener);
+ }else{
+ this._events[type].push(listener);
+ }
+
+ // Check for listener leak
+ if (
+ !this._events[type].warned &&
+ this._maxListeners > 0 &&
+ this._events[type].length > this._maxListeners
+ ) {
+ this._events[type].warned = true;
+ logPossibleMemoryLeak.call(this, this._events[type].length, type);
+ }
+ }
+
+ return returnValue;
+ };
+
+ EventEmitter.prototype.off = function(type, listener) {
+ if (typeof listener !== 'function') {
+ throw new Error('removeListener only takes instances of Function');
+ }
+
+ var handlers,leafs=[];
+
+ if(this.wildcard) {
+ var ns = typeof type === 'string' ? type.split(this.delimiter) : type.slice();
+ leafs = searchListenerTree.call(this, null, ns, this.listenerTree, 0);
+ if(!leafs) return this;
+ } else {
+ // does not use listeners(), so no side effect of creating _events[type]
+ if (!this._events[type]) return this;
+ handlers = this._events[type];
+ leafs.push({_listeners:handlers});
+ }
+
+ for (var iLeaf=0; iLeaf 0) {
+ fns = this._all;
+ for(i = 0, l = fns.length; i < l; i++) {
+ if(fn === fns[i]) {
+ fns.splice(i, 1);
+ if (this._removeListener)
+ this.emit("removeListenerAny", fn);
+ return this;
+ }
+ }
+ } else {
+ fns = this._all;
+ if (this._removeListener) {
+ for(i = 0, l = fns.length; i < l; i++)
+ this.emit("removeListenerAny", fns[i]);
+ }
+ this._all = [];
+ }
+ return this;
+ };
+
+ EventEmitter.prototype.removeListener = EventEmitter.prototype.off;
+
+ EventEmitter.prototype.removeAllListeners = function (type) {
+ if (type === undefined) {
+ !this._events || init.call(this);
+ return this;
+ }
+
+ if (this.wildcard) {
+ var leafs = searchListenerTree.call(this, null, type, this.listenerTree, 0), leaf, i;
+ if (!leafs) return this;
+ for (i = 0; i < leafs.length; i++) {
+ leaf = leafs[i];
+ leaf._listeners = null;
+ }
+ this.listenerTree && recursivelyGarbageCollect(this.listenerTree);
+ } else if (this._events) {
+ this._events[type] = null;
+ }
+ return this;
+ };
+
+ EventEmitter.prototype.listeners = function (type) {
+ var _events = this._events;
+ var keys, listeners, allListeners;
+ var i;
+ var listenerTree;
+
+ if (type === undefined) {
+ if (this.wildcard) {
+ throw Error('event name required for wildcard emitter');
+ }
+
+ if (!_events) {
+ return [];
+ }
+
+ keys = ownKeys(_events);
+ i = keys.length;
+ allListeners = [];
+ while (i-- > 0) {
+ listeners = _events[keys[i]];
+ if (typeof listeners === 'function') {
+ allListeners.push(listeners);
+ } else {
+ allListeners.push.apply(allListeners, listeners);
+ }
+ }
+ return allListeners;
+ } else {
+ if (this.wildcard) {
+ listenerTree= this.listenerTree;
+ if(!listenerTree) return [];
+ var handlers = [];
+ var ns = typeof type === 'string' ? type.split(this.delimiter) : type.slice();
+ searchListenerTree.call(this, handlers, ns, listenerTree, 0);
+ return handlers;
+ }
+
+ if (!_events) {
+ return [];
+ }
+
+ listeners = _events[type];
+
+ if (!listeners) {
+ return [];
+ }
+ return typeof listeners === 'function' ? [listeners] : listeners;
+ }
+ };
+
+ EventEmitter.prototype.eventNames = function(nsAsArray){
+ var _events= this._events;
+ return this.wildcard? collectTreeEvents.call(this, this.listenerTree, [], null, nsAsArray) : (_events? ownKeys(_events) : []);
+ };
+
+ EventEmitter.prototype.listenerCount = function(type) {
+ return this.listeners(type).length;
+ };
+
+ EventEmitter.prototype.hasListeners = function (type) {
+ if (this.wildcard) {
+ var handlers = [];
+ var ns = typeof type === 'string' ? type.split(this.delimiter) : type.slice();
+ searchListenerTree.call(this, handlers, ns, this.listenerTree, 0);
+ return handlers.length > 0;
+ }
+
+ var _events = this._events;
+ var _all = this._all;
+
+ return !!(_all && _all.length || _events && (type === undefined ? ownKeys(_events).length : _events[type]));
+ };
+
+ EventEmitter.prototype.listenersAny = function() {
+
+ if(this._all) {
+ return this._all;
+ }
+ else {
+ return [];
+ }
+
+ };
+
+ EventEmitter.prototype.waitFor = function (event, options) {
+ var self = this;
+ var type = typeof options;
+ if (type === 'number') {
+ options = {timeout: options};
+ } else if (type === 'function') {
+ options = {filter: options};
+ }
+
+ options= resolveOptions(options, {
+ timeout: 0,
+ filter: undefined,
+ handleError: false,
+ Promise: Promise,
+ overload: false
+ }, {
+ filter: functionReducer,
+ Promise: constructorReducer
+ });
+
+ return makeCancelablePromise(options.Promise, function (resolve, reject, onCancel) {
+ function listener() {
+ var filter= options.filter;
+ if (filter && !filter.apply(self, arguments)) {
+ return;
+ }
+ self.off(event, listener);
+ if (options.handleError) {
+ var err = arguments[0];
+ err ? reject(err) : resolve(toArray.apply(null, arguments).slice(1));
+ } else {
+ resolve(toArray.apply(null, arguments));
+ }
+ }
+
+ onCancel(function(){
+ self.off(event, listener);
+ });
+
+ self._on(event, listener, false);
+ }, {
+ timeout: options.timeout,
+ overload: options.overload
+ })
+ };
+
+ function once(emitter, name, options) {
+ options= resolveOptions(options, {
+ Promise: Promise,
+ timeout: 0,
+ overload: false
+ }, {
+ Promise: constructorReducer
+ });
+
+ var _Promise= options.Promise;
+
+ return makeCancelablePromise(_Promise, function(resolve, reject, onCancel){
+ var handler;
+ if (typeof emitter.addEventListener === 'function') {
+ handler= function () {
+ resolve(toArray.apply(null, arguments));
+ };
+
+ onCancel(function(){
+ emitter.removeEventListener(name, handler);
+ });
+
+ emitter.addEventListener(
+ name,
+ handler,
+ {once: true}
+ );
+ return;
+ }
+
+ var eventListener = function(){
+ errorListener && emitter.removeListener('error', errorListener);
+ resolve(toArray.apply(null, arguments));
+ };
+
+ var errorListener;
+
+ if (name !== 'error') {
+ errorListener = function (err){
+ emitter.removeListener(name, eventListener);
+ reject(err);
+ };
+
+ emitter.once('error', errorListener);
+ }
+
+ onCancel(function(){
+ errorListener && emitter.removeListener('error', errorListener);
+ emitter.removeListener(name, eventListener);
+ });
+
+ emitter.once(name, eventListener);
+ }, {
+ timeout: options.timeout,
+ overload: options.overload
+ });
+ }
+
+ var prototype= EventEmitter.prototype;
+
+ Object.defineProperties(EventEmitter, {
+ defaultMaxListeners: {
+ get: function () {
+ return prototype._maxListeners;
+ },
+ set: function (n) {
+ if (typeof n !== 'number' || n < 0 || Number.isNaN(n)) {
+ throw TypeError('n must be a non-negative number')
+ }
+ prototype._maxListeners = n;
+ },
+ enumerable: true
+ },
+ once: {
+ value: once,
+ writable: true,
+ configurable: true
+ }
+ });
+
+ Object.defineProperties(prototype, {
+ _maxListeners: {
+ value: defaultMaxListeners,
+ writable: true,
+ configurable: true
+ },
+ _observers: {value: null, writable: true, configurable: true}
+ });
+
+ if (typeof define === 'function' && define.amd) {
+ // AMD. Register as an anonymous module.
+ define(function() {
+ return EventEmitter;
+ });
+ } else if (typeof exports === 'object') {
+ // CommonJS
+ module.exports = EventEmitter;
+ }
+ else {
+ // global for any kind of environment.
+ var _global= new Function('','return this')();
+ _global.EventEmitter2 = EventEmitter;
+ }
+}();
diff --git a/node_modules/@pm2/js-api/node_modules/eventemitter2/package.json b/node_modules/@pm2/js-api/node_modules/eventemitter2/package.json
new file mode 100644
index 0000000..bf56eed
--- /dev/null
+++ b/node_modules/@pm2/js-api/node_modules/eventemitter2/package.json
@@ -0,0 +1,89 @@
+{
+ "name": "eventemitter2",
+ "version": "6.4.9",
+ "description": "A feature-rich Node.js event emitter implementation with namespaces, wildcards, TTL, async listeners and browser/worker support.",
+ "keywords": [
+ "event",
+ "events",
+ "emitter",
+ "eventemitter",
+ "addEventListener",
+ "addListener",
+ "pub/sub",
+ "emit",
+ "emits",
+ "on",
+ "once",
+ "publish",
+ "subscribe"
+ ],
+ "author": "hij1nx http://twitter.com/hij1nx",
+ "contributors": [
+ "Eric Elliott",
+ "Charlie Robbins http://twitter.com/indexzero",
+ "Jameson Lee http://twitter.com/Jamesonjlee",
+ "Jeroen van Duffelen http://www.twitter.com/jvduf",
+ "Fedor Indutny http://www.twitter.com/indutny"
+ ],
+ "license": "MIT",
+ "repository": "git://github.com/hij1nx/EventEmitter2.git",
+ "devDependencies": {
+ "benchmark": "^2.1.4",
+ "bluebird": "^3.7.2",
+ "coveralls": "^3.0.11",
+ "mocha": "^7.1.1",
+ "nodeunit": "*",
+ "nyc": "^15.0.0"
+ },
+ "main": "./lib/eventemitter2.js",
+ "scripts": {
+ "test": "mocha ./test/loader.js --exit --timeout=3000",
+ "test:legacy": "nodeunit test/simple/ test/wildcardEvents/",
+ "test:coverage": "nyc --check-coverage npm run test",
+ "coverage:report": "nyc report --reporter=html --reporter=text",
+ "coveralls": "nyc report --reporter=text-lcov | coveralls",
+ "benchmark": "node test/perf/benchmark.js",
+ "prepublishOnly": "npm run test:coverage",
+ "postversion": "git push && git push --tags"
+ },
+ "files": [
+ "lib/eventemitter2.js",
+ "index.js",
+ "eventemitter2.d.ts"
+ ],
+ "typings": "./eventemitter2.d.ts",
+ "typescript": {
+ "definition": "./eventemitter2.d.ts"
+ },
+ "nyc": {
+ "lines": 80,
+ "functions": 80,
+ "branches": 75,
+ "statements": 80,
+ "watermarks": {
+ "lines": [
+ 80,
+ 95
+ ],
+ "functions": [
+ 80,
+ 95
+ ],
+ "branches": [
+ 80,
+ 95
+ ],
+ "statements": [
+ 80,
+ 95
+ ]
+ },
+ "include": [
+ "lib/**/*.js"
+ ],
+ "reporter": [
+ "lcov",
+ "text-summary"
+ ]
+ }
+}
diff --git a/node_modules/@pm2/js-api/package.json b/node_modules/@pm2/js-api/package.json
new file mode 100644
index 0000000..5c9d960
--- /dev/null
+++ b/node_modules/@pm2/js-api/package.json
@@ -0,0 +1,77 @@
+{
+ "name": "@pm2/js-api",
+ "version": "0.8.0",
+ "description": "PM2.io API Client for Javascript",
+ "main": "index.js",
+ "unpkg": "dist/keymetrics.es5.min.js",
+ "engines": {
+ "node": ">=4.0"
+ },
+ "scripts": {
+ "test": "mocha test/*",
+ "build": "mkdir -p dist; browserify -s Keymetrics -r ./ > ./dist/keymetrics.es5.js",
+ "dist": "mkdir -p dist; browserify -s Keymetrics -r ./ | uglifyjs -c warnings=false -m > ./dist/keymetrics.es5.min.js",
+ "doc": "jsdoc -r ./src --readme ./README.md -d doc -t ./node_modules/minami",
+ "clean": "rm dist/*",
+ "prepare": "npm run build && npm run dist"
+ },
+ "repository": {
+ "type": "git",
+ "url": "git+https://github.com/keymetrics/km.js.git"
+ },
+ "keywords": [
+ "keymetrics",
+ "api",
+ "dashboard",
+ "monitoring",
+ "wrapper"
+ ],
+ "author": "Keymetrics Team",
+ "license": "Apache-2",
+ "bugs": {
+ "url": "https://github.com/keymetrics/km.js/issues"
+ },
+ "homepage": "https://github.com/keymetrics/km.js#readme",
+ "dependencies": {
+ "async": "^2.6.3",
+ "extrareqp2": "^1.0.0",
+ "debug": "~4.3.1",
+ "eventemitter2": "^6.3.1",
+ "ws": "^7.0.0"
+ },
+ "devDependencies": {
+ "@babel/core": "^7.0.0",
+ "@babel/preset-env": "^7.0.0",
+ "babelify": "10.0.0",
+ "browserify": "^17.0.0",
+ "jsdoc": "^3.4.2",
+ "minami": "^1.1.1",
+ "mocha": "^7.0.0",
+ "should": "*",
+ "uglify-es": "~3.3.9"
+ },
+ "browserify": {
+ "debug": true,
+ "transform": [
+ [
+ "babelify",
+ {
+ "presets": [
+ [
+ "@babel/preset-env",
+ {
+ "debug": false,
+ "forceAllTransforms": true
+ }
+ ]
+ ],
+ "sourceMaps": true
+ }
+ ]
+ ]
+ },
+ "browser": {
+ "./src/auth_strategies/embed_strategy.js": false,
+ "ws": false
+ }
+}
diff --git a/node_modules/@pm2/js-api/src/api_mappings.json b/node_modules/@pm2/js-api/src/api_mappings.json
new file mode 100644
index 0000000..cf892cc
--- /dev/null
+++ b/node_modules/@pm2/js-api/src/api_mappings.json
@@ -0,0 +1 @@
+{"actions":[{"route":{"name":"/api/bucket/:id/actions/trigger","type":"POST"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"params":[{"name":":id","type":"string","description":"bucket id","optional":false}],"body":[{"name":"server_name","type":"string","description":"the name of the server","optional":false,"defaultvalue":null},{"name":"process_id","type":"number","description":"the id of the process","optional":true,"defaultvalue":null},{"name":"app_name","type":"number","description":"the name of the process","optional":true,"defaultvalue":null},{"name":"action_name","type":"string","description":"the name of the action to trigger","optional":false,"defaultvalue":null},{"name":"opts","type":"object","description":"any specific options to be passed to the function","optional":true,"defaultvalue":null}],"code":[{"type":"500","description":"database error","optional":false},{"type":"200","description":"succesfully run the action","optional":false}],"response":[{"name":"success","type":"boolean","description":"succesully sended the action to PM2","optional":false,"defaultvalue":null}],"name":"triggerAction","longname":"Actions.triggerAction","scope":"route"},{"route":{"name":"/api/bucket/:id/actions/triggerPM2","type":"POST"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"params":[{"name":":id","type":"string","description":"bucket id","optional":false}],"body":[{"name":"server_name","type":"string","description":"the name of the server","optional":false,"defaultvalue":null},{"name":"method_name","type":"string","description":"the name of the pm2 method to trigger","optional":false,"defaultvalue":null},{"name":"app_name","type":"string","description":"the name of the application","optional":false,"defaultvalue":null}],"code":[{"type":"500","description":"database error","optional":false},{"type":"400","description":"failed action","optional":false},{"type":"200","description":"succesfully run the action","optional":false}],"response":[{"name":"success","type":"boolean","description":"succesully sended the action to PM2","optional":false,"defaultvalue":null}],"name":"triggerPM2Action","longname":"Actions.triggerPM2Action","scope":"route"},{"route":{"name":"/api/bucket/:id/actions/triggerScopedAction","type":"POST"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"params":[{"name":":id","type":"string","description":"bucket id","optional":false}],"body":[{"name":"server_name","type":"string","description":"the name of the server","optional":false,"defaultvalue":null},{"name":"action_name","type":"string","description":"the name of the pm2 method to trigger","optional":false,"defaultvalue":null},{"name":"app_name","type":"string","description":"the name of the application","optional":false,"defaultvalue":null},{"name":"pm_id","type":"number","description":"the id of the process","optional":false,"defaultvalue":null},{"name":"opts","type":"object","description":"custom parameters to give to the action","optional":true,"defaultvalue":null}],"code":[{"type":"500","description":"database error","optional":false},{"type":"200","description":"succesfully run the action","optional":false}],"response":[{"name":".","type":"object","description":"the action sended to the process","optional":false,"defaultvalue":null}],"name":"triggerScopedAction","longname":"Actions.triggerScopedAction","scope":"route"}],"bucket":{"alert":{"analyzer":[{"route":{"name":"/api/bucket/:id/alerts/analyzer","type":"POST"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"params":[{"name":":id","type":"string","description":"bucket id","optional":false}],"body":[{"name":"size","type":"integer","description":"line limit, default to 20","optional":true,"defaultvalue":null},{"name":"from","type":"integer","description":"offset limit","optional":true,"defaultvalue":null}],"code":[{"type":"500","description":"database error","optional":false},{"type":"200","description":"list all alerts","optional":false}],"name":"list","longname":"Bucket.alert.analyzer.list","scope":"route","async":true},{"route":{"name":"/api/bucket/:id/alerts/analyzer/:alert","type":"PUT"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"params":[{"name":":id","type":"string","description":"bucket id","optional":false},{"name":":alert","type":"string","description":"alert id","optional":false}],"body":[{"name":"useful","type":"boolean","description":"","optional":false,"defaultvalue":null}],"code":[{"type":"500","description":"database error","optional":false},{"type":"200","description":"content modified","optional":false}],"name":"editState","longname":"Bucket.alert.analyzer.editState","scope":"route"},{"route":{"name":"/api/bucket/:id/alerts/analyzer/:analyzer/config","type":"PUT"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"params":[{"name":":id","type":"string","description":"bucket id","optional":false},{"name":":analyzer","type":"string","description":"analyzer name","optional":false}],"body":[{"name":"blacklist","type":"object","description":"","optional":false,"defaultvalue":null},{"name":"blacklist.apps","type":"array","description":"","optional":true,"defaultvalue":null},{"name":"blacklist.servers","type":"array","description":"","optional":true,"defaultvalue":null},{"name":"blacklist.metrics","type":"array","description":"","optional":true,"defaultvalue":null},{"name":"threshold","type":"number","description":"","optional":false,"defaultvalue":null},{"name":"window","type":"number","description":"","optional":false,"defaultvalue":null}],"code":[{"type":"500","description":"database error","optional":false},{"type":"200","description":"content modified","optional":false}],"name":"updateConfig","longname":"Bucket.alert.analyzer.updateConfig","scope":"route"}],"default":[{"route":{"name":"/api/bucket/:id/alerts","type":"POST"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"params":[{"name":":id","type":"string","description":"bucket id","optional":false}],"body":[{"name":"name","type":"string","description":"Alert name","optional":false,"defaultvalue":null},{"name":"enabled","type":"boolean","description":"Alert's state","optional":true,"defaultvalue":null},{"name":"type","type":"string","description":"Should be `metric`, `event` or `webcheck`","optional":false,"defaultvalue":null},{"name":"initiator","type":"string","description":"Should be metric name or event name","optional":false,"defaultvalue":null},{"name":"options","type":"object","description":"","optional":false,"defaultvalue":null},{"name":"options.operator","type":"string","description":"Should be `>`, `<`, `=`, `>=` or `<=`","optional":true,"defaultvalue":null},{"name":"options.threshold","type":"number","description":"Value to reach to send an alert","optional":true,"defaultvalue":null},{"name":"options.act","type":"string","description":"Should be `always`, `opposite`, `first` or `diff`","optional":true,"defaultvalue":null},{"name":"options.timerange","type":"number","description":"Timerange to check, in seconds","optional":true,"defaultvalue":null},{"name":"scope","type":"object","description":"","optional":false,"defaultvalue":null},{"name":"scope.apps","type":"object","description":"Array of strings with apps name (can be empty)","optional":true,"defaultvalue":null},{"name":"scope.servers","type":"object","description":"Array of strings with servers name (can be empty)","optional":true,"defaultvalue":null},{"name":"scope.initiators","type":"object","description":"Array of strings with initiators name (need to be set if no apps or servers)","optional":true,"defaultvalue":null},{"name":"scope.sources","type":"object","description":"Array of strings with sources name (can be empty)","optional":true,"defaultvalue":null},{"name":"actions","type":"object","description":"List of actions to trigger","optional":false,"defaultvalue":null},{"name":"actions[].type","type":"string","description":"Type of action","optional":true,"defaultvalue":null},{"name":"actions[].params","type":"object","description":"Params for action","optional":true,"defaultvalue":null}],"code":[{"type":"500","description":"database error","optional":false},{"type":"400","description":"missing parameters","optional":false},{"type":"200","description":"successfuly created alert","optional":false}],"name":"create","longname":"Bucket.alert.create","scope":"route"},{"route":{"name":"/api/bucket/:id/alerts/:alert","type":"DELETE"},"params":[{"name":":id","type":"string","description":"bucket id","optional":false},{"name":":alert","type":"string","description":"alert id","optional":false}],"code":[{"type":"500","description":"database error","optional":false},{"type":"204","description":"successfuly deleted alert","optional":false}],"name":"delete","longname":"Bucket.alert.delete","scope":"route","authentication":false},{"route":{"name":"/api/bucket/:id/alerts/","type":"GET"},"params":[{"name":":id","type":"string","description":"bucket id","optional":false}],"code":[{"type":"500","description":"database error","optional":false},{"type":"200","description":"list all alerts","optional":false}],"name":"list","longname":"Bucket.alert.list","scope":"route","authentication":false},{"route":{"name":"/api/bucket/:id/alerts/:alert","type":"PUT"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"params":[{"name":":id","type":"string","description":"bucket id","optional":false},{"name":":alert","type":"string","description":"alert id","optional":false}],"body":[{"name":"name","type":"string","description":"Alert name","optional":true,"defaultvalue":null},{"name":"enabled","type":"boolean","description":"Alert's state","optional":true,"defaultvalue":null},{"name":"type","type":"string","description":"Should be `metric`, `event` or `webcheck`","optional":true,"defaultvalue":null},{"name":"initiator","type":"string","description":"Should be metric name or event name","optional":true,"defaultvalue":null},{"name":"options","type":"object","description":"","optional":true,"defaultvalue":null},{"name":"options.operator","type":"string","description":"Should be `>`, `<`, `=`, `<=` or `>=`","optional":true,"defaultvalue":null},{"name":"options.threshold","type":"number","description":"Value to reach to send an alert","optional":true,"defaultvalue":null},{"name":"options.act","type":"string","description":"Should be `always`, `opposite`, `first` or `diff`","optional":true,"defaultvalue":null},{"name":"options.timerange","type":"number","description":"Timerange to check, in seconds","optional":true,"defaultvalue":null},{"name":"scope","type":"object","description":"","optional":true,"defaultvalue":null},{"name":"scope.apps","type":"array","description":"Array of strings with apps name (can be empty)","optional":true,"defaultvalue":null},{"name":"scope.servers","type":"array","description":"Array of strings with servers name (can be empty)","optional":true,"defaultvalue":null},{"name":"scope.initiators","type":"object","description":"Array of strings with initiators name (need to be set if no apps or servers)","optional":true,"defaultvalue":null},{"name":"scope.sources","type":"object","description":"Array of strings with sources name (can be empty)","optional":true,"defaultvalue":null},{"name":"actions","type":"array","description":"List of actions to trigger","optional":true,"defaultvalue":null},{"name":"actions[].type","type":"string","description":"Type of action","optional":true,"defaultvalue":null},{"name":"actions[].params","type":"object","description":"Params for action","optional":true,"defaultvalue":null}],"code":[{"type":"500","description":"database error","optional":false},{"type":"400","description":"missing parameters","optional":false},{"type":"404","description":"alert not found","optional":false},{"type":"200","description":"successfuly created alert","optional":false}],"name":"updateAlert","longname":"Bucket.alert.updateAlert","scope":"route"},{"route":{"name":"/api/bucket/:id/alerts/:alert","type":"GET"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"params":[{"name":":id","type":"string","description":"bucket id","optional":false},{"name":":alert","type":"string","description":"alert id","optional":false}],"code":[{"type":"500","description":"database error","optional":false},{"type":"404","description":"alert not found","optional":false},{"type":"200","description":"successfuly returned alert","optional":false}],"name":"get","longname":"Bucket.alert.get","scope":"route","async":true},{"route":{"name":"/api/bucket/:id/alerts/:alert/sample","type":"POST"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"params":[{"name":":id","type":"string","description":"bucket id","optional":false},{"name":":alert","type":"string","description":"alert id","optional":false}],"code":[{"type":"500","description":"database error","optional":false},{"type":"404","description":"alert not found","optional":false},{"type":"202","description":"successfuly sended alert actions","optional":false}],"name":"triggerSample","longname":"Bucket.alert.triggerSample","scope":"route"},{"route":{"name":"/api/bucket/:id/alerts/update","type":"POST"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"params":[{"name":":id","type":"string","description":"bucket id","optional":false}],"body":[{"name":"triggers","type":"object","description":"","optional":false,"defaultvalue":null}],"code":[{"type":"500","description":"database error","optional":false},{"type":"400","description":"missing triggers parameter","optional":false},{"type":"200","description":"succesfully update triggers","optional":false}],"response":[{"name":"triggers","type":"object","description":"new triggers object","optional":false,"defaultvalue":null}],"name":"update","longname":"Bucket.alert.update","scope":"route"},{"route":{"name":"/api/bucket/:id/alerts/updateSlack","type":"POST"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"params":[{"name":":id","type":"string","description":"bucket id","optional":false}],"body":[{"name":"slack","type":"object","description":"","optional":false,"defaultvalue":null},{"name":"slack.active","type":"boolean","description":"","optional":true,"defaultvalue":null},{"name":"slack.url","type":"boolean","description":"needed if active is set to true","optional":true,"defaultvalue":null}],"code":[{"type":"500","description":"database error","optional":false},{"type":"400","description":"missing triggers parameter","optional":false},{"type":"200","description":"succesfully update triggers","optional":false}],"response":[{"name":"bucket","type":"object","description":"","optional":false,"defaultvalue":null}],"name":"updateSlack","longname":"Bucket.alert.updateSlack","scope":"route"},{"route":{"name":"/api/bucket/:id/alerts/updateWebhooks","type":"POST"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"params":[{"name":":id","type":"string","description":"bucket id","optional":false}],"body":[{"name":"webhooks","type":"object","description":"","optional":false,"defaultvalue":null},{"name":"webhooks.active","type":"boolean","description":"","optional":true,"defaultvalue":null},{"name":"webhooks.url","type":"boolean","description":"needed if active is set to true","optional":true,"defaultvalue":null}],"code":[{"type":"500","description":"database error","optional":false},{"type":"400","description":"missing triggers parameter","optional":false},{"type":"200","description":"succesfully update triggers","optional":false}],"response":[{"name":"bucket","type":"object","description":"","optional":false,"defaultvalue":null}],"name":"updateWebhooks","longname":"Bucket.alert.updateWebhooks","scope":"route"}]},"application":[{"route":{"name":"/api/bucket/:id/applications","type":"GET"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"params":[{"name":":id","type":"string","description":"bucket id","optional":false}],"code":[{"type":"500","description":"database error","optional":false},{"type":"200","description":"successfuly retrieved applications","optional":false}],"name":"list","longname":"Bucket.application.list","scope":"route","async":true},{"route":{"name":"/api/bucket/:id/applications/:application","type":"GET"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"params":[{"name":":id","type":"string","description":"bucket id","optional":false},{"name":":application","type":"string","description":"application id","optional":false}],"code":[{"type":"500","description":"database error","optional":false},{"type":"404","description":"application not found","optional":false},{"type":"200","description":"successfuly retrieved application","optional":false}],"name":"get","longname":"Bucket.application.get","scope":"route","async":true},{"route":{"name":"/api/bucket/:id/applications","type":"POST"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"params":[{"name":":id","type":"string","description":"bucket id","optional":false}],"body":[{"name":"name","type":"string","description":"","optional":false,"defaultvalue":null},{"name":"domains","type":"object","description":"Array of string with domains","optional":false,"defaultvalue":null}],"code":[{"type":"500","description":"database error","optional":false},{"type":"400","description":"missing parameters","optional":false},{"type":"200","description":"successfuly created application","optional":false}],"name":"create","longname":"Bucket.application.create","scope":"route","async":true},{"route":{"name":"/api/bucket/:id/applications/:application","type":"PUT"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"params":[{"name":":id","type":"string","description":"bucket id","optional":false},{"name":":application","type":"string","description":"application id","optional":false}],"body":[{"name":"name","type":"string","description":"","optional":true,"defaultvalue":null},{"name":"domains","type":"object","description":"","optional":true,"defaultvalue":null}],"code":[{"type":"500","description":"database error","optional":false},{"type":"400","description":"missing parameters","optional":false},{"type":"200","description":"successfuly updated application","optional":false}],"name":"update","longname":"Bucket.application.update","scope":"route","async":true},{"route":{"name":"/api/bucket/:id/applications/:application","type":"DELETE"},"params":[{"name":":id","type":"string","description":"bucket id","optional":false},{"name":":application","type":"string","description":"application id","optional":false}],"code":[{"type":"500","description":"database error","optional":false},{"type":"204","description":"successfuly deleted application","optional":false}],"name":"delete","longname":"Bucket.application.delete","scope":"route","async":true,"authentication":false},{"route":{"name":"/api/bucket/:id/applications/:application/preview","type":"GET"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"params":[{"name":":id","type":"string","description":"bucket id","optional":false},{"name":":application","type":"string","description":"application id","optional":false}],"code":[{"type":"500","description":"database error","optional":false},{"type":"404","description":"preview not found","optional":false},{"type":"200","description":"successfuly retrieved application screenshot","optional":false}],"name":"getPreview","longname":"Bucket.application.getPreview","scope":"route","async":true},{"route":{"name":"/api/bucket/:id/applications/:application/report","type":"GET"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"params":[{"name":":id","type":"string","description":"bucket id","optional":false},{"name":":application","type":"string","description":"application id","optional":false}],"code":[{"type":"500","description":"database error","optional":false},{"type":"404","description":"report not found","optional":false},{"type":"200","description":"successfuly retrieved application report","optional":false}],"name":"getReports","longname":"Bucket.application.getReports","scope":"route","async":true}],"billing":[{"route":{"name":"/api/bucket/:id/payment/subscribe","type":"POST"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"params":[{"name":":id","type":"string","description":"bucket id","optional":false}],"body":[{"name":"plan","type":"string","description":"name of the plan to upgrade to","optional":false,"defaultvalue":null},{"name":"stripe_token","type":"string","description":"a card token created by stripe","optional":true,"defaultvalue":null},{"name":"coupon_id","type":"string","description":"the id of the stripe coupon","optional":true,"defaultvalue":null}],"code":[{"type":"400","description":"missing/invalid parameters","optional":false},{"type":"403","description":"need a credit card OR not allowed to subscribe to the plan","optional":false},{"type":"500","description":"stripe/database error","optional":false},{"type":"200","description":"succesfully upgraded","optional":false}],"response":[{"name":"bucket","type":"object","description":"the bucket object","optional":false,"defaultvalue":null},{"name":"subscription","type":"object","description":"the subscription object attached to the subscription","optional":false,"defaultvalue":null}],"name":"subscribe","longname":"Bucket.billing.subscribe","scope":"route","async":true},{"route":{"name":"/api/bucket/:id/payment/subscribe/:paymentIntent","type":"POST"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"params":[{"name":":id","type":"string","description":"bucket id","optional":false},{"name":":paymentIntent","type":"string","description":"paymentIntent id","optional":false}],"body":[{"name":"plan","type":"string","description":"name of the plan to upgrade to","optional":false,"defaultvalue":null}],"code":[{"type":"400","description":"missing/invalid parameters","optional":false},{"type":"500","description":"stripe/database error","optional":false},{"type":"200","description":"succesfully upgraded","optional":false}],"response":[{"name":"bucket","type":"object","description":"the bucket object","optional":false,"defaultvalue":null}],"name":"paymentIntentSucceed","longname":"Bucket.billing.paymentIntentSucceed","scope":"route","async":true},{"route":{"name":"/api/bucket/:id/payment/trial","type":"PUT"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"params":[{"name":":id","type":"string","description":"bucket id","optional":false}],"body":[{"name":"plan","type":"string","description":"Plan to trial","optional":false,"defaultvalue":null}],"code":[{"type":"400","description":"can't claim trial","optional":false},{"type":"200","description":"trial launched","optional":false}],"response":[{"name":"duration","type":"string","description":"the duration of the trial","optional":false,"defaultvalue":null},{"name":"plan","type":"string","description":"the plan of the trial","optional":false,"defaultvalue":null}],"name":"startTrial","longname":"Bucket.billing.startTrial","scope":"route","async":true},{"route":{"name":"/api/bucket/:id/payment/invoices","type":"GET"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"params":[{"name":":id","type":"string","description":"bucket id","optional":false}],"code":[{"type":"400","description":"Missing/invalid parameters","optional":false},{"type":"404","description":"This bucket hasn't invoices","optional":false},{"type":"200","description":"succesfully returns invoices","optional":false}],"response":[{"name":".","type":"array","description":"array of invoices","optional":false,"defaultvalue":null}],"name":"getInvoices","longname":"Bucket.billing.getInvoices","scope":"route"},{"route":{"name":"/api/bucket/:id/payment/receipts","type":"GET"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"params":[{"name":":id","type":"string","description":"bucket id","optional":false}],"code":[{"type":"400","description":"Missing/invalid parameters","optional":false},{"type":"404","description":"This bucket hasn't receipts","optional":false},{"type":"200","description":"succesfully returns receipts","optional":false}],"response":[{"name":".","type":"array","description":"array of receipts","optional":false,"defaultvalue":null}],"name":"getReceipts","longname":"Bucket.billing.getReceipts","scope":"route"},{"route":{"name":"/api/bucket/:id/payment/subscription","type":"GET"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"params":[{"name":":id","type":"string","description":"bucket id","optional":false}],"code":[{"type":"404","description":"the bucket doesnt have any subscription","optional":false},{"type":"500","description":"database error","optional":false},{"type":"200","description":"succesfully retrieved the subscription","optional":false}],"response":[{"name":".","type":"object","description":"subscription object","optional":false,"defaultvalue":null}],"name":"getSubcription","longname":"Bucket.billing.getSubcription","scope":"route"},{"route":{"name":"/api/bucket/:id/payment/subscription/state","type":"GET"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"params":[{"name":":id","type":"string","description":"bucket id","optional":false}],"code":[{"type":"404","description":"the bucket doesnt have any subscription","optional":false},{"type":"500","description":"database error","optional":false},{"type":"200","description":"succesfully retrieved the subscription","optional":false}],"response":[{"name":"status","type":"string","description":"stripe state of the subscription","optional":false,"defaultvalue":null},{"name":"plan","type":"string","description":"stripe plan name of the subscription","optional":false,"defaultvalue":null},{"name":"canceled_at","type":"string","description":"if he sub has been cancelled, add the date","optional":false,"defaultvalue":null}],"name":"getSubcriptionState","longname":"Bucket.billing.getSubcriptionState","scope":"route","async":true},{"route":{"name":"/api/bucket/:id/payment/cards","type":"POST"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"params":[{"name":":id","type":"string","description":"bucket id","optional":false}],"body":[{"name":"token","type":"string","description":"card token generated by stripe","optional":false,"defaultvalue":null}],"code":[{"type":"400","description":"missing parameters","optional":false},{"type":"500","description":"stripe error","optional":false},{"type":"200","description":"succesfully added the card","optional":false}],"response":[{"name":"data","type":"object","description":"stripe credit card Object","optional":false,"defaultvalue":null}],"name":"attachCreditCard","longname":"Bucket.billing.attachCreditCard","scope":"route","async":true},{"route":{"name":"/api/bucket/:id/payment/cards","type":"GET"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"params":[{"name":":id","type":"string","description":"bucket id","optional":false}],"code":[{"type":"500","description":"stripe error","optional":false},{"type":"404","description":"the user doesn't have any default card","optional":false},{"type":"200","description":"succesfully retieved the charges","optional":false}],"response":[{"name":"data","type":"array","description":"list of stripe cards object","optional":false,"defaultvalue":null}],"name":"fetchCreditCards","longname":"Bucket.billing.fetchCreditCards","scope":"route"},{"route":{"name":"/api/bucket/:id/payment/card/:card_id","type":"GET"},"authentication":true,"params":[{"name":":id","type":"string","description":"bucket id","optional":false},{"name":":card_id","type":"string","description":"the stripe id of the card","optional":false}],"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"code":[{"type":"500","description":"stripe error","optional":false},{"type":"400","description":"missing parameters card_id","optional":false},{"type":"404","description":"the user doesn't have any default card","optional":false},{"type":"200","description":"succesfully retieved the card","optional":false}],"response":[{"name":"data","type":"array","description":"stripe card object","optional":false,"defaultvalue":null}],"name":"fetchCreditCard","longname":"Bucket.billing.fetchCreditCard","scope":"route"},{"route":{"name":"/api/bucket/:id/payment/card","type":"GET"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"params":[{"name":":id","type":"string","description":"bucket id","optional":false}],"code":[{"type":"500","description":"stripe error","optional":false},{"type":"404","description":"the user doesn't have any default card","optional":false},{"type":"200","description":"succesfully retieved the card","optional":false}],"response":[{"name":"data","type":"array","description":"stripe card object","optional":false,"defaultvalue":null}],"name":"fetchDefaultCreditCard","longname":"Bucket.billing.fetchDefaultCreditCard","scope":"route","async":true},{"route":{"name":"/api/bucket/:id/payment/card","type":"PUT"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"params":[{"name":":id","type":"string","description":"bucket id","optional":false}],"body":[{"name":"id","type":"string","description":"stripe card id","optional":false,"defaultvalue":null},{"name":"address_line1","type":"string","description":"","optional":true,"defaultvalue":null},{"name":"address_country","type":"string","description":"","optional":true,"defaultvalue":null},{"name":"address_zip","type":"string","description":"","optional":true,"defaultvalue":null},{"name":"address_city","type":"string","description":"","optional":true,"defaultvalue":null}],"code":[{"type":"500","description":"stripe error","optional":false},{"type":"400","description":"missing parameters, you need to specify a card","optional":false},{"type":"200","description":"succesfully updated the card","optional":false}],"response":[{"name":"data","type":"array","description":"stripe card object","optional":false,"defaultvalue":null}],"name":"updateCreditCard","longname":"Bucket.billing.updateCreditCard","scope":"route"},{"route":{"name":"/api/bucket/:id/payment/card/:card_id","type":"DELETE"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"params":[{"name":":id","type":"string","description":"bucket id","optional":false},{"name":":card_id","type":"string","description":"the stripe id of the card","optional":false}],"code":[{"type":"500","description":"stripe error","optional":false},{"type":"400","description":"missing parameters card_id","optional":false},{"type":"200","description":"succesfully retieved the card","optional":false},{"type":"403","description":"the user must have one card active when having a subscription","optional":false}],"response":[{"name":".","type":"object","description":"stripe card object","optional":false,"defaultvalue":null}],"name":"deleteCreditCard","longname":"Bucket.billing.deleteCreditCard","scope":"route","async":true},{"route":{"name":"/api/bucket/:id/payment/card/:card_id/default","type":"POST"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"params":[{"name":":id","type":"string","description":"bucket id","optional":false},{"name":":card_id","type":"string","description":"the stripe id of the card","optional":false}],"code":[{"type":"500","description":"stripe error","optional":false},{"type":"400","description":"missing parameters card_id","optional":false},{"type":"200","description":"succesfully set the card as default","optional":false}],"response":[{"name":"data","type":"object","description":"stripe card object","optional":false,"defaultvalue":null}],"name":"setDefaultCard","longname":"Bucket.billing.setDefaultCard","scope":"route","async":true},{"route":{"name":"/api/bucket/:id/payment","type":"GET"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"params":[{"name":":id","type":"string","description":"bucket id","optional":false}],"code":[{"type":"500","description":"stripe error","optional":false},{"type":"400","description":"missing parameters card_id","optional":false},{"type":"200","description":"succesfully retrieved the metadata","optional":false}],"response":[{"name":".","type":"object","description":"stripe metadata object","optional":false,"defaultvalue":null}],"name":"fetchMetadata","longname":"Bucket.billing.fetchMetadata","scope":"route"},{"route":{"name":"/api/bucket/:id/payment","type":"PUT"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"params":[{"name":":id","type":"string","description":"bucket id","optional":false}],"body":[{"name":"metadata","type":"object","description":"the metadata you can update","optional":false,"defaultvalue":null},{"name":"metadata.vat_number","type":"string","description":"","optional":true,"defaultvalue":null},{"name":"metadata.company_name","type":"string","description":"","optional":true,"defaultvalue":null},{"name":"metadata.receipt_email","type":"string","description":"","optional":true,"defaultvalue":null}],"code":[{"type":"500","description":"stripe error","optional":false},{"type":"400","description":"missing parameters, you need to specify a card","optional":false},{"type":"200","description":"succesfully updated the card","optional":false}],"response":[{"name":"data","type":"array","description":"stripe customer metadata object","optional":false,"defaultvalue":null}],"name":"updateMetadata","longname":"Bucket.billing.updateMetadata","scope":"route","async":true},{"route":{"name":"/api/bucket/:id/payment/banks","type":"POST"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"params":[{"name":":id","type":"string","description":"bucket id","optional":false}],"body":[{"name":"iban","type":"string","description":"the iban used to recognize the account","optional":true,"defaultvalue":null},{"name":"type","type":"string","description":"the type of the bank account (currently only sepa is available)","optional":false,"defaultvalue":null},{"name":"name","type":"string","description":"name of the bank account owner","optional":false,"defaultvalue":null}],"code":[{"type":"400","description":"missing parameters","optional":false},{"type":"500","description":"stripe error","optional":false},{"type":"200","description":"succesfully added the account","optional":false}],"response":[{"name":"data","type":"object","description":"stripe credit card Object","optional":false,"defaultvalue":null}],"name":"attachBankAccount","longname":"Bucket.billing.attachBankAccount","scope":"route"},{"route":{"name":"/api/bucket/:id/payment/banks","type":"GET"},"authentication":true,"params":[{"name":":id","type":"string","description":"bucket id","optional":false}],"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"code":[{"type":"500","description":"stripe error","optional":false},{"type":"404","description":"the user doesn't have any default account","optional":false},{"type":"200","description":"succesfully retieved the card","optional":false}],"response":[{"name":"data","type":"object","description":"stripe source object","optional":false,"defaultvalue":null}],"name":"fetchBankAccount","longname":"Bucket.billing.fetchBankAccount","scope":"route"},{"route":{"name":"/api/bucket/:id/payment/banks","type":"DELETE"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"params":[{"name":":id","type":"string","description":"bucket id","optional":false}],"code":[{"type":"500","description":"stripe error","optional":false},{"type":"200","description":"succesfully retieved the card","optional":false},{"type":"404","description":"the user doesn't have any default account","optional":false}],"response":[{"name":".","type":"object","description":"stripe source object","optional":false,"defaultvalue":null}],"name":"deleteBankAccount","longname":"Bucket.billing.deleteBankAccount","scope":"route"}],"dashboardschema":[{"route":{"name":"/api/bucket/:id/dashboardSchema/","type":"PUT"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"params":[{"name":":id","type":"string","description":"bucket id","optional":false}],"body":[{"name":"name","type":"string","description":"the name of the dashboard","optional":false,"defaultvalue":null},{"name":"data","type":"object","description":"the list of component that compose the dashboard","optional":false,"defaultvalue":null},{"name":"mode","type":"string","description":"the dashboard mode","optional":false,"defaultvalue":null},{"name":"image","type":"object","description":"background image for the dashboard","optional":false,"defaultvalue":null}],"code":[{"type":"500","description":"database error","optional":false},{"type":"200","description":"succesfully created dashboard","optional":false},{"type":"400","description":"Invalid params","optional":false}],"response":[{"name":".","type":"dashboard","description":"complete dashboard object from database","optional":false,"defaultvalue":null}],"name":"create","longname":"Bucket.dashboardschema.create","scope":"route"},{"route":{"name":"/api/bucket/:id/dashboardSchema/","type":"GET"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"params":[{"name":":id","type":"string","description":"bucket id","optional":false}],"code":[{"type":"500","description":"database error","optional":false},{"type":"200","description":"succesfully retrieved data","optional":false},{"type":"400","description":"Invalid params","optional":false}],"response":[{"name":".","type":"array","description":"array of servers status","optional":false,"defaultvalue":null}],"name":"retrieveAll","longname":"Bucket.dashboardschema.retrieveAll","scope":"route"},{"route":{"name":"/api/bucket/:id/dashboardSchema/:dashid/visualization","type":"GET"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"params":[{"name":":id","type":"string","description":"bucket id","optional":false},{"name":":dashid","type":"string","description":"dashboard id","optional":false}],"code":[{"type":"500","description":"database error","optional":false},{"type":"200","description":"succesfully retrieved data","optional":false},{"type":"404","description":"dashboard not found","optional":false},{"type":"400","description":"Invalid params","optional":false}],"response":[{"name":".","type":"array","description":"array of dashboards","optional":false,"defaultvalue":null}],"name":"visualization","longname":"Bucket.dashboardschema.visualization","scope":"route"},{"route":{"name":"/api/bucket/:id/dashboardSchema/:dashid","type":"GET"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"params":[{"name":":id","type":"string","description":"bucket id","optional":false},{"name":":dashid","type":"string","description":"dashboard id","optional":false}],"code":[{"type":"500","description":"database error","optional":false},{"type":"200","description":"succesfully retrieved data","optional":false},{"type":"404","description":"dashboard not found","optional":false},{"type":"400","description":"Invalid params","optional":false}],"response":[{"name":".","type":"array","description":"array of dashboards","optional":false,"defaultvalue":null}],"name":"retrieve","longname":"Bucket.dashboardschema.retrieve","scope":"route"},{"route":{"name":"/api/bucket/:id/dashboardSchema/:dashid","type":"DELETE"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"params":[{"name":":id","type":"string","description":"bucket id","optional":false},{"name":":dashid","type":"string","description":"dashboard id","optional":false}],"code":[{"type":"500","description":"database error","optional":false},{"type":"200","description":"succesfully deleted dashboard","optional":false},{"type":"400","description":"Invalid params","optional":false},{"type":"404","description":"dashboard not found","optional":false}],"response":[{"name":".","type":"array","description":"array of dashboards","optional":false,"defaultvalue":null}],"name":"remove","longname":"Bucket.dashboardschema.remove","scope":"route"},{"route":{"name":"/api/bucket/:id/dashboardSchema/:dashId","type":"POST"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"params":[{"name":":id","type":"string","description":"bucket id","optional":false},{"name":":dashId","type":"string","description":"dashboard id","optional":false}],"body":[{"name":"name","type":"string","description":"the name of the dashboard","optional":false,"defaultvalue":null},{"name":"data","type":"object","description":"the data to populate the dashboard","optional":false,"defaultvalue":null}],"code":[{"type":"500","description":"database error","optional":false},{"type":"200","description":"succesfully retrieved data","optional":false},{"type":"404","description":"dashboard not found","optional":false},{"type":"400","description":"Invalid params","optional":false}],"response":[{"name":".","type":"array","description":"array of servers status","optional":false,"defaultvalue":null}],"name":"update","longname":"Bucket.dashboardschema.update","scope":"route"}],"server":[{"route":{"name":"/api/bucket/:id/data/deleteServer","type":"POST"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"params":[{"name":":id","type":"string","description":"bucket id","optional":false}],"body":[{"name":"server_name","type":"string","description":"the name of server","optional":false,"defaultvalue":null}],"code":[{"type":"500","description":"database error","optional":false},{"type":"406","description":"require an action before delete","optional":false},{"type":"400","description":"missing or invalid parameters","optional":false},{"type":"200","description":"successfully deleted","optional":false}],"response":[{"name":"success","type":"boolean","description":"can be true or false","optional":false,"defaultvalue":null},{"name":"msg","type":"string","description":"response","optional":false,"defaultvalue":null}],"name":"deleteServer","longname":"Bucket.server.deleteServer","scope":"route"}],"webcheck":[{"route":{"name":"/api/bucket/:id/webchecks/metrics","type":"GET"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"params":[{"name":":id","type":"string","description":"bucket id","optional":false}],"code":[{"type":"500","description":"database error","optional":false},{"type":"200","description":"successfuly retrieved webchecks metrics","optional":false}],"name":"listMetrics","longname":"Bucket.webcheck.listMetrics","scope":"route"},{"route":{"name":"/api/bucket/:id/webchecks/regions","type":"GET"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"params":[{"name":":id","type":"string","description":"bucket id","optional":false}],"code":[{"type":"500","description":"database error","optional":false},{"type":"200","description":"successfuly retrieved webchecks regions","optional":false}],"name":"listRegions","longname":"Bucket.webcheck.listRegions","scope":"route"},{"route":{"name":"/api/bucket/:id/webchecks/:webcheck/metrics","type":"POST"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"params":[{"name":":id","type":"string","description":"bucket id","optional":false},{"name":":webcheck","type":"string","description":"webcheck id","optional":false}],"body":[{"name":"start","type":"string","description":"","optional":true,"defaultvalue":null},{"name":"metrics","type":"array","description":"","optional":true,"defaultvalue":null},{"name":"end","type":"string","description":"","optional":true,"defaultvalue":null}],"code":[{"type":"500","description":"database error","optional":false},{"type":"200","description":"successfuly retrieved webchecks regions","optional":false}],"name":"getMetrics","longname":"Bucket.webcheck.getMetrics","scope":"route","async":true},{"route":{"name":"/api/bucket/:id/webchecks","type":"GET"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"params":[{"name":":id","type":"string","description":"bucket id","optional":false}],"query":[{"name":"application","type":"string","description":"Application's id to filter","optional":true,"defaultvalue":null}],"code":[{"type":"500","description":"database error","optional":false},{"type":"200","description":"successfuly retrieved webchecks","optional":false}],"name":"list","longname":"Bucket.webcheck.list","scope":"route"},{"route":{"name":"/api/bucket/:id/webchecks/:webcheck","type":"GET"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"params":[{"name":":id","type":"string","description":"bucket id","optional":false},{"name":":webcheck","type":"string","description":"webcheck id","optional":false}],"code":[{"type":"500","description":"database error","optional":false},{"type":"404","description":"webcheck not found","optional":false},{"type":"200","description":"successfuly retrieved webcheck","optional":false}],"name":"get","longname":"Bucket.webcheck.get","scope":"route"},{"route":{"name":"/api/bucket/:id/webchecks","type":"POST"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"params":[{"name":":id","type":"string","description":"bucket id","optional":false}],"body":[{"name":"name","type":"string","description":"Webcheck name","optional":false,"defaultvalue":null},{"name":"enabled","type":"boolean","description":"Webcheck's state","optional":true,"defaultvalue":null},{"name":"target","type":"object","description":"","optional":false,"defaultvalue":null},{"name":"target.type","type":"string","description":"Should be `http`, `https` or `tcp`","optional":true,"defaultvalue":null},{"name":"target.port","type":"number","description":"Target's port","optional":true,"defaultvalue":null},{"name":"target.address","type":"string","description":"Target's IP/domain","optional":true,"defaultvalue":null},{"name":"target.path","type":"string","description":"HTTP Path (only for http/https)","optional":true,"defaultvalue":null},{"name":"target.is_frontend","type":"boolean","description":"Enable or disable frontend metrics (via puppeteer)","optional":true,"defaultvalue":null},{"name":"body","type":"string","description":"Body need to match this regex to succeed webcheck (only for http/https)","optional":true,"defaultvalue":null},{"name":"interval","type":"number","description":"Webcheck's interval check (ms)","optional":false,"defaultvalue":null},{"name":"timeout","type":"number","description":"Webcheck's timeout (ms)","optional":false,"defaultvalue":null},{"name":"source","type":"object","description":"","optional":false,"defaultvalue":null},{"name":"source.region","type":"string","description":"Webcheck's worker region","optional":true,"defaultvalue":null},{"name":"retry","type":"object","description":"","optional":false,"defaultvalue":null},{"name":"retry.max","type":"number","description":"Max webcheck's retry before mark as failed","optional":true,"defaultvalue":null},{"name":"retry.interval","type":"number","description":"Webcheck's retry interval (ms)","optional":true,"defaultvalue":null},{"name":"alerts","type":"object","description":"List of alerts (cf. Alert type)","optional":false,"defaultvalue":null},{"name":"application","type":"string","description":"Application's id","optional":true,"defaultvalue":null}],"code":[{"type":"500","description":"database error","optional":false},{"type":"400","description":"missing parameters","optional":false},{"type":"200","description":"successfuly created webcheck","optional":false}],"name":"create","longname":"Bucket.webcheck.create","scope":"route"},{"route":{"name":"/api/bucket/:id/webchecks/:webcheck","type":"PUT"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"params":[{"name":":id","type":"string","description":"bucket id","optional":false},{"name":":webcheck","type":"string","description":"webcheck id","optional":false}],"body":[{"name":"name","type":"string","description":"Webcheck name","optional":true,"defaultvalue":null},{"name":"enabled","type":"boolean","description":"Webcheck's state","optional":true,"defaultvalue":null},{"name":"target","type":"object","description":"","optional":true,"defaultvalue":null},{"name":"target.type","type":"string","description":"Should be `http`, `https` or `tcp`","optional":true,"defaultvalue":null},{"name":"target.port","type":"number","description":"Target's port","optional":true,"defaultvalue":null},{"name":"target.address","type":"string","description":"Target's IP/domain","optional":true,"defaultvalue":null},{"name":"target.path","type":"string","description":"HTTP Path (only for http/https)","optional":true,"defaultvalue":null},{"name":"target.is_frontend","type":"boolean","description":"Enable or disable frontend metrics (via puppeteer)","optional":true,"defaultvalue":null},{"name":"body","type":"string","description":"Body need to match this regex to succeed webcheck (only for http/https)","optional":true,"defaultvalue":null},{"name":"interval","type":"number","description":"Webcheck's interval check (ms)","optional":true,"defaultvalue":null},{"name":"timeout","type":"number","description":"Webcheck's timeout (ms)","optional":true,"defaultvalue":null},{"name":"source","type":"object","description":"","optional":true,"defaultvalue":null},{"name":"source.region","type":"string","description":"Webcheck's worker region","optional":true,"defaultvalue":null},{"name":"retry","type":"object","description":"","optional":true,"defaultvalue":null},{"name":"retry.max","type":"number","description":"Max webcheck's retry before mark as failed","optional":true,"defaultvalue":null},{"name":"retry.interval","type":"number","description":"Webcheck's retry interval (ms)","optional":true,"defaultvalue":null},{"name":"alerts","type":"object","description":"List of alerts (cf. Alert type)","optional":true,"defaultvalue":null},{"name":"application","type":"string","description":"Application's id","optional":true,"defaultvalue":null}],"code":[{"type":"500","description":"database error","optional":false},{"type":"400","description":"missing parameters","optional":false},{"type":"200","description":"successfuly updated webcheck","optional":false}],"name":"update","longname":"Bucket.webcheck.update","scope":"route"},{"route":{"name":"/api/bucket/:id/webchecks/:webcheck","type":"DELETE"},"params":[{"name":":id","type":"string","description":"bucket id","optional":false},{"name":":webcheck","type":"string","description":"webcheck id","optional":false}],"code":[{"type":"500","description":"database error","optional":false},{"type":"204","description":"successfuly deleted webcheck","optional":false}],"name":"delete","longname":"Bucket.webcheck.delete","scope":"route","authentication":false}],"default":[{"route":{"name":"/api/bucket/:id/feedback","type":"PUT"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"params":[{"name":":id","type":"string","description":"bucket id","optional":false}],"body":[{"name":"feedback","type":"string","description":"the feedback text","optional":false,"defaultvalue":null}],"code":[{"type":"500","description":"database error","optional":false},{"type":"400","description":"missing feedback field","optional":false},{"type":"200","description":"succesfully registered the feedback","optional":false}],"response":[{"name":"feedback","type":"string","description":"the feedback that hasn't been registered","optional":false,"defaultvalue":null}],"name":"sendFeedback","longname":"Bucket.sendFeedback","scope":"route"},{"name":"retrieveUsers","route":{"name":"/api/bucket/:id/users_authorized","type":"GET"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"params":[{"name":":id","type":"string","description":"bucket id","optional":false}],"code":[{"type":"500","description":"database error","optional":false},{"type":"200","description":"succesfully retrieved bucket's members","optional":false}],"response":[{"name":".","type":"array","description":"a array of user containing their email, username and roles","optional":false,"defaultvalue":null}],"longname":"Bucket.retrieveUsers","scope":"route"},{"name":"currentRole","route":{"name":"/api/bucket/:id/current_role","type":"GET"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"params":[{"name":":id","type":"string","description":"bucket id","optional":false}],"code":[{"type":"200","description":"succesfully retrieved the use role","optional":false}],"response":[{"name":"role","type":"string","description":"the user role","optional":false,"defaultvalue":null}],"longname":"Bucket.currentRole","scope":"route"},{"route":{"name":"/api/bucket/:id/manage_notif","type":"POST"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"params":[{"name":":id","type":"string","description":"bucket id","optional":false}],"body":[{"name":"email","type":"string","description":"the user email","optional":false,"defaultvalue":null},{"name":"state","type":"string","description":"the notification state you want to set for that user\n (either 'email' or 'nonde)","optional":false,"defaultvalue":null}],"code":[{"type":"500","description":"database error","optional":false},{"type":"404","description":"user not found","optional":false}],"response":[{"name":".","type":"array","description":"array of state for each user","optional":false,"defaultvalue":null}],"name":"setNotificationState","longname":"Bucket.setNotificationState","scope":"route"},{"name":"inviteUser","route":{"name":"/api/bucket/:id/add_user","type":"POST"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"params":[{"name":":id","type":"string","description":"bucket id","optional":false}],"body":[{"name":"email","type":"string","description":"the email of the user","optional":false,"defaultvalue":null}],"code":[{"type":"400","description":"missing/invalid parameters","optional":false},{"type":"403","description":"you cant invit more users because you hit the bucket limit","optional":false},{"type":"200","description":"succesfully invited the user (either directly or by email)","optional":false}],"response":[{"name":"invitations","type":"array","description":"the list of invitations actually active","optional":false,"defaultvalue":null}],"longname":"Bucket.inviteUser","scope":"route"},{"route":{"name":"/api/bucket/:id/invitation","type":"DELETE"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"params":[{"name":":id","type":"string","description":"bucket id","optional":false}],"query":[{"name":"email","type":"string","description":"the email of the invitation you want to delete","optional":true,"defaultvalue":null}],"code":[{"type":"400","description":"invalid/missing parameters","optional":false},{"type":"500","description":"database error","optional":false},{"type":"200","description":"succesfully deleted the invitation","optional":false}],"response":[{"name":"invitations","type":"array","description":"the list of invitations actually active","optional":false,"defaultvalue":null}],"name":"removeInvitation","longname":"Bucket.removeInvitation","scope":"route"},{"route":{"name":"/api/bucket/:id/remove_user","type":"POST"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"params":[{"name":":id","type":"string","description":"bucket id","optional":false}],"body":[{"name":"email","type":"string","description":"the email of the user you want to remove","optional":false,"defaultvalue":null}],"code":[{"type":"400","description":"missing/invalid parameters","optional":false},{"type":"404","description":"user not found","optional":false},{"type":"403","description":"impossible to remove the owner from the bucket","optional":false},{"type":"500","description":"database error","optional":false}],"response":[{"name":".","type":"array","description":"a array of user containing their email, username and roles","optional":false,"defaultvalue":null}],"name":"removeUser","longname":"Bucket.removeUser","scope":"route"},{"route":{"name":"/api/bucket/:id/promote_user","type":"POST"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"params":[{"name":":id","type":"string","description":"bucket id","optional":false}],"body":[{"name":"email","type":"string","description":"the email of the user you want to change the role","optional":false,"defaultvalue":null},{"name":"role","type":"string","description":"the role you want to set","optional":false,"defaultvalue":null}],"code":[{"type":"400","description":"invalid/missing parameters","optional":false},{"type":"404","description":"user not found","optional":false},{"type":"403","description":"impossible to set the role of the owner","optional":false}],"response":[{"name":".","type":"array","description":"a array of user containing their email, username and roles","optional":false,"defaultvalue":null}],"name":"setUserRole","longname":"Bucket.setUserRole","scope":"route"},{"name":"retrieveAll","route":{"name":"/api/bucket/","type":"GET"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"code":[{"type":"500","description":"database error","optional":false},{"type":"200","description":"succesfully fetched bucket","optional":false}],"response":[{"name":".","type":"array","description":"array of buckets","optional":false,"defaultvalue":null}],"longname":"Bucket.retrieveAll","scope":"route"},{"name":"create","route":{"name":"/api/bucket/create_classic","type":"POST"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"body":[{"name":"name","type":"string","description":"the name of the bucket","optional":false,"defaultvalue":null},{"name":"comment","type":"string","description":"any comments that will be written under the bucket name","optional":true,"defaultvalue":null},{"name":"app_url","type":"string","description":"","optional":true,"defaultvalue":null}],"code":[{"type":"400","description":"missing parameters","optional":false},{"type":"403","description":"you cant create any more bucket","optional":false},{"type":"500","description":"database error","optional":false},{"type":"200","description":"succesfully created a bucket","optional":false}],"response":[{"name":"bucket","type":"object","description":"the created bucket","optional":false,"defaultvalue":null}],"longname":"Bucket.create","scope":"route"},{"deprecated":true,"route":{"name":"/api/bucket/:id/start_trial","type":"PUT"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"params":[{"name":":id","type":"string","description":"bucket id","optional":false}],"code":[{"type":"400","description":"can't claim trial","optional":false},{"type":"200","description":"trial launched","optional":false}],"response":[{"name":"duration","type":"string","description":"the duration of the trial","optional":false,"defaultvalue":null},{"name":"plan","type":"string","description":"the plan of the trial","optional":false,"defaultvalue":null}],"name":"claimTrial","longname":"Bucket.claimTrial","scope":"route"},{"deprecated":true,"name":"upgrade","route":{"name":"/api/bucket/:id/upgrade","type":"POST"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"params":[{"name":":id","type":"string","description":"bucket id","optional":false}],"body":[{"name":"plan","type":"string","description":"name of the plan to upgrade to","optional":false,"defaultvalue":null},{"name":"stripe_token","type":"string","description":"a card token created by stripe","optional":true,"defaultvalue":null},{"name":"coupon_id","type":"string","description":"the id of the stripe coupon","optional":true,"defaultvalue":null}],"code":[{"type":"400","description":"missing/invalid parameters","optional":false},{"type":"403","description":"need a credit card OR not allowed to subscribe to the plan","optional":false},{"type":"500","description":"stripe/database error","optional":false},{"type":"200","description":"succesfully upgraded","optional":false}],"response":[{"name":"bucket","type":"object","description":"the bucket object","optional":false,"defaultvalue":null},{"name":"subscription","type":"object","description":"the subscription object attached to the subscription","optional":false,"defaultvalue":null}],"longname":"Bucket.upgrade","scope":"route"},{"name":"retrieve","route":{"name":"/api/bucket/:id","type":"GET"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"params":[{"name":":id","type":"string","description":"bucket id","optional":false}],"code":[{"type":"200","description":"succesfully retrieved the bucket","optional":false}],"response":[{"name":".","type":"object","description":"bucket object","optional":false,"defaultvalue":null}],"longname":"Bucket.retrieve","scope":"route"},{"route":{"name":"/api/bucket/:id","type":"PUT"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"params":[{"name":":id","type":"string","description":"bucket id","optional":false}],"body":[{"name":"name","type":"string","description":"","optional":true,"defaultvalue":null},{"name":"comment","type":"string","description":"","optional":true,"defaultvalue":null},{"name":"app_url","type":"string","description":"","optional":true,"defaultvalue":null},{"name":"configuration","type":"string","description":"","optional":true,"defaultvalue":null}],"code":[{"type":"500","description":"database error","optional":false},{"type":"400","description":"missing parameters","optional":false}],"response":[{"name":".","type":"object","description":"bucket object","optional":false,"defaultvalue":null}],"name":"update","longname":"Bucket.update","scope":"route","async":true},{"name":"retrieveServers","route":{"name":"/api/bucket/:id/meta_servers","type":"GET"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"params":[{"name":":id","type":"string","description":"bucket id","optional":false}],"code":[{"type":"500","description":"database error","optional":false},{"type":"200","description":"succesfully retrieved the server's metadata","optional":false}],"response":[{"name":".","type":"array","description":"servers metadata","optional":false,"defaultvalue":null}],"longname":"Bucket.retrieveServers","scope":"route"},{"route":{"name":"/api/bucket/:id","type":"DELETE"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"params":[{"name":":id","type":"string","description":"bucket id","optional":false}],"code":[{"type":"500","description":"database error","optional":false},{"type":"200","description":"succesfully deleted the bucket","optional":false}],"response":[{"name":".","type":"object","description":"the deleted bucket","optional":false,"defaultvalue":null}],"name":"destroy","longname":"Bucket.destroy","scope":"route"},{"route":{"name":"/api/bucket/:id/transfer_ownership","type":"POST"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"params":[{"name":":id","type":"string","description":"bucket id","optional":false}],"body":[{"name":"new_owner","type":"string","description":"the wanted owner's email","optional":false,"defaultvalue":null}],"code":[{"type":"400","description":"Missing/invalid parameters","optional":false},{"type":"404","description":"user not found","optional":false},{"type":"403","description":"the new owner need to have a active credit card","optional":false},{"type":"200","description":"succesfully transfered the bucket, old owner is now admin","optional":false}],"response":[{"name":".","type":"object","description":"bucket object","optional":false,"defaultvalue":null}],"name":"transferOwnership","longname":"Bucket.transferOwnership","scope":"route"},{"route":{"name":"/api/bucket/:id/user_options","type":"PUT"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"params":[{"name":":id","type":"string","description":"bucket id","optional":false}],"body":[{"name":"options","type":"object","description":"user options","optional":false,"defaultvalue":null}],"code":[{"type":"200","description":"succesfully update user options","optional":false},{"type":"400","description":"missing parameters","optional":false}],"response":[{"name":"bucket","type":"object","description":"","optional":false,"defaultvalue":null}],"name":"updateUserOptions","longname":"Bucket.updateUserOptions","scope":"route"}]},"dashboard":[{"route":{"name":"/api/bucket/:id/dashboard/","type":"GET"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"params":[{"name":":id","type":"string","description":"bucket id","optional":false}],"code":[{"type":"500","description":"database error","optional":false},{"type":"200","description":"succesfully retrieved data","optional":false},{"type":"400","description":"Invalid params","optional":false}],"response":[{"name":".","type":"array","description":"array of servers status","optional":false,"defaultvalue":null}],"name":"retrieveAll","longname":"Dashboard.retrieveAll","scope":"route"},{"route":{"name":"/api/bucket/:id/dashboard/:dashid","type":"GET"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"params":[{"name":":id","type":"string","description":"bucket id","optional":false},{"name":":dashid","type":"string","description":"dashboard id","optional":false}],"code":[{"type":"500","description":"database error","optional":false},{"type":"200","description":"succesfully retrieved data","optional":false},{"type":"404","description":"dashboard not found","optional":false},{"type":"400","description":"Invalid params","optional":false}],"response":[{"name":".","type":"array","description":"array of dashboards","optional":false,"defaultvalue":null}],"name":"retrieve","longname":"Dashboard.retrieve","scope":"route"},{"route":{"name":"/api/bucket/:id/dashboard/:dashid","type":"DELETE"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"params":[{"name":":id","type":"string","description":"bucket id","optional":false},{"name":":dashid","type":"string","description":"dashboard id","optional":false}],"code":[{"type":"500","description":"database error","optional":false},{"type":"200","description":"succesfully deleted dashboard","optional":false},{"type":"400","description":"Invalid params","optional":false},{"type":"404","description":"dashboard not found","optional":false}],"response":[{"name":".","type":"array","description":"array of dashboards","optional":false,"defaultvalue":null}],"name":"remove","longname":"Dashboard.remove","scope":"route"},{"route":{"name":"/api/bucket/:id/dashboard/:dashId","type":"POST"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"params":[{"name":":id","type":"string","description":"bucket id","optional":false},{"name":":dashId","type":"string","description":"dashboard id","optional":false}],"body":[{"name":"name","type":"string","description":"the name of the dashboard","optional":false,"defaultvalue":null},{"name":"children","type":"object","description":"the list of component that compose the dashboard","optional":false,"defaultvalue":null}],"code":[{"type":"500","description":"database error","optional":false},{"type":"200","description":"succesfully retrieved data","optional":false},{"type":"404","description":"dashboard not found","optional":false},{"type":"400","description":"Invalid params","optional":false}],"response":[{"name":".","type":"array","description":"array of servers status","optional":false,"defaultvalue":null}],"name":"update","longname":"Dashboard.update","scope":"route"},{"route":{"name":"/api/bucket/:id/dashboard/","type":"PUT"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"params":[{"name":":id","type":"string","description":"bucket id","optional":false}],"body":[{"name":"name","type":"string","description":"the name of the dashboard","optional":false,"defaultvalue":null},{"name":"children","type":"object","description":"the list of component that compose the dashboard","optional":false,"defaultvalue":null}],"code":[{"type":"500","description":"database error","optional":false},{"type":"200","description":"succesfully created dashboard","optional":false},{"type":"400","description":"Invalid params","optional":false}],"response":[{"name":".","type":"dashboard","description":"complete dashboard object from database","optional":false,"defaultvalue":null}],"name":"create","longname":"Dashboard.create","scope":"route"}],"data":{"dependencies":[{"route":{"name":"/api/bucket/:id/data/dependencies/","type":"POST"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"params":[{"name":":id","type":"string","description":"bucket id","optional":false}],"body":[{"name":"app_name","type":"string","description":"the application name","optional":false,"defaultvalue":null},{"name":"server_name","type":"string","description":"filter by server name","optional":true,"defaultvalue":null}],"code":[{"type":"500","description":"database error","optional":false},{"type":"200","description":"succesfully retrieved data","optional":false},{"type":"400","description":"missing parameters","optional":false}],"response":[{"name":".","type":"array","description":"recorded dependencies","optional":false,"defaultvalue":null}],"examples":["km.data.dependencies.retrieve(bucket._id, {\n app_name: 'my_api'\n })"],"name":"retrieve","longname":"Data.dependencies.retrieve","scope":"route"}],"events":[{"route":{"name":"/api/bucket/:id/data/events","type":"POST"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"params":[{"name":":id","type":"string","description":"bucket id","optional":false}],"body":[{"name":"event_name","type":"string","description":"the event name to retrieve","optional":false,"defaultvalue":null},{"name":"start","type":"date","description":"from which date to retrieve events","optional":true,"defaultvalue":null},{"name":"end","type":"date","description":"to which date to retrieve events","optional":true,"defaultvalue":null},{"name":"app_name","type":"string","description":"filter events by app source","optional":true,"defaultvalue":null},{"name":"server_name","type":"string","description":"filter events by server source","optional":true,"defaultvalue":null},{"name":"limit","type":"number","description":"limit the number of events to retrieve","optional":true,"defaultvalue":100},{"name":"offset","type":"number","description":"offset research by X","optional":true,"defaultvalue":0}],"code":[{"type":"500","description":"database error","optional":false},{"type":"400","description":"invalid parameters","optional":false},{"type":"200","description":"succesfully retrieved data","optional":false}],"response":[{"name":".","type":"array","description":"array of events","optional":false,"defaultvalue":null}],"name":"retrieve","longname":"Data.events.retrieve","scope":"route"},{"route":{"name":"/api/bucket/:id/data/eventsKeysByApp","type":"GET"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"params":[{"name":":id","type":"string","description":"bucket id","optional":false}],"code":[{"type":"500","description":"database error","optional":false},{"type":"400","description":"invalid parameters","optional":false},{"type":"200","description":"succesfully retrieved data","optional":false}],"response":[{"name":".","type":"array","description":"array of object representing events emitted for each application name","optional":false,"defaultvalue":null}],"name":"retrieveMetadatas","longname":"Data.events.retrieveMetadatas","scope":"route"},{"route":{"name":"/api/bucket/:id/data/events/stats","type":"POST"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"params":[{"name":":id","type":"string","description":"bucket id","optional":false}],"body":[{"name":"event_name","type":"string","description":"the event name to retrieve","optional":false,"defaultvalue":null},{"name":"app_name","type":"string","description":"filter events by app source","optional":true,"defaultvalue":null},{"name":"server_name","type":"string","description":"filter events by server source","optional":true,"defaultvalue":null},{"name":"days","type":"number","description":"limit the number of days of data","optional":true,"defaultvalue":2},{"name":"interval","type":"string","description":"interval of time between two point","optional":true,"defaultvalue":"minute"}],"code":[{"type":"500","description":"database error","optional":false},{"type":"400","description":"invalid parameters","optional":false},{"type":"200","description":"succesfully retrieved data","optional":false}],"response":[{"name":".","type":"array","description":"array of point (each point is one dimensional array, X are at 0 and Y at 1)","optional":false,"defaultvalue":null}],"name":"retrieveHistogram","longname":"Data.events.retrieveHistogram","scope":"route"},{"route":{"name":"/api/bucket/:id/data/events/delete_all","type":"DELETE"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"params":[{"name":":id","type":"string","description":"bucket id","optional":false}],"code":[{"type":"500","description":"database error","optional":false},{"type":"200","description":"succesfully deleted data","optional":false}],"response":[{"name":".","type":"array","description":"array of object representing events emitted for each application name","optional":false,"defaultvalue":null}],"name":"deleteAll","longname":"Data.events.deleteAll","scope":"route"}],"exceptions":[{"route":{"name":"/api/bucket/:id/data/exceptions","type":"POST"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"params":[{"name":":id","type":"string","description":"bucket id","optional":false}],"body":[{"name":"server_name","type":"string","description":"filter exceptions by server source","optional":true,"defaultvalue":null},{"name":"app_name","type":"string","description":"filter exceptions by app source","optional":true,"defaultvalue":null},{"name":"before","type":"string","description":"filter out exceptions older than X (in minutes)","optional":true,"defaultvalue":null}],"code":[{"type":"500","description":"database error","optional":false},{"type":"200","description":"succesfully retrieved data","optional":false}],"response":[{"name":".","type":"array","description":"array of exceptions","optional":false,"defaultvalue":null}],"name":"retrieve","longname":"Data.exceptions.retrieve","scope":"route"},{"route":{"name":"/api/bucket/:id/data/exceptions/summary","type":"GET"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"params":[{"name":":id","type":"string","description":"bucket id","optional":false}],"code":[{"type":"500","description":"database error","optional":false},{"type":"200","description":"succesfully retrieved data","optional":false}],"response":[{"name":".","type":"array","description":"array of object containing exceptions for each application for each server","optional":false,"defaultvalue":null}],"name":"retrieveSummary","longname":"Data.exceptions.retrieveSummary","scope":"route"},{"route":{"name":"/api/bucket/:id/data/exceptions/delete_all","type":"POST"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"params":[{"name":":id","type":"string","description":"bucket id","optional":false}],"code":[{"type":"500","description":"database error","optional":false},{"type":"200","description":"succesfully retrieved data","optional":false}],"name":"deleteAll","longname":"Data.exceptions.deleteAll","scope":"route"},{"route":{"name":"/api/bucket/:id/data/exceptions/delete","type":"POST"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"params":[{"name":":id","type":"string","description":"bucket id","optional":false}],"body":[{"name":"identifier","type":"string","description":"exception identifier","optional":true,"defaultvalue":null},{"name":"app_name","type":"string","description":"the application on which exception happened","optional":true,"defaultvalue":null},{"name":"server_name","type":"string","description":"the server on which exception happened","optional":true,"defaultvalue":null}],"code":[{"type":"500","description":"database error","optional":false},{"type":"200","description":"succesfully retrieved data","optional":false},{"type":"400","description":"missing/invalid parameters","optional":false}],"response":[{"name":".","type":"array","description":"array of deleted exceptions","optional":false,"defaultvalue":null}],"name":"delete","longname":"Data.exceptions.delete","scope":"route"}],"issues":[{"route":{"name":"/api/bucket/:id/data/issues/list","type":"POST"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"params":[{"name":":id","type":"string","description":"bucket id","optional":false}],"body":[{"name":"server_name","type":"string","description":"filter exceptions by server source","optional":true,"defaultvalue":null},{"name":"app_name","type":"string","description":"filter exceptions by app source needed if initiator+source not provided","optional":true,"defaultvalue":null},{"name":"before","type":"string","description":"exclude exceptions older than 'before' minutes","optional":true,"defaultvalue":null},{"name":"initiator","type":"string","description":"filter exceptions by initiator (node/golang/browser/webcheck...) needed with source","optional":true,"defaultvalue":null},{"name":"source","type":"string","description":"filter exceptions by source (browser app id, webcheck id...)","optional":true,"defaultvalue":null},{"name":"tags","type":"array","description":"array of string to filter tags","optional":true,"defaultvalue":null}],"code":[{"type":"500","description":"database error","optional":false},{"type":"200","description":"succesfully retrieved data","optional":false}],"response":[{"name":".","type":"array","description":"array of exceptions","optional":false,"defaultvalue":null}],"name":"list","longname":"Data.issues.list","scope":"route","async":true},{"route":{"name":"/api/bucket/:id/data/issues/occurrences/:identifier","type":"GET"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"params":[{"name":":id","type":"string","description":"bucket id","optional":false},{"name":":identifier","type":"string","description":"issue identifier","optional":false}],"query":[{"name":"from","type":"number","description":"","optional":true,"defaultvalue":null},{"name":"search_after","type":"number","description":"","optional":true,"defaultvalue":null}],"code":[{"type":"500","description":"database error","optional":false},{"type":"200","description":"succesfully retrieved data","optional":false}],"response":[{"name":".","type":"array","description":"array of occurrences id","optional":false,"defaultvalue":null}],"name":"listOccurencesForIdentifier","longname":"Data.issues.listOccurencesForIdentifier","scope":"route","async":true},{"route":{"name":"/api/bucket/:id/data/issues/replay/:uuid","type":"GET"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"params":[{"name":":id","type":"string","description":"bucket id","optional":false},{"name":":uuid","type":"string","description":"replay id","optional":false}],"code":[{"type":"500","description":"database error","optional":false},{"type":"200","description":"succesfully retrieved data","optional":false}],"response":[{"name":"replay","type":"string","description":"","optional":false,"defaultvalue":null}],"name":"getReplay","longname":"Data.issues.getReplay","scope":"route","async":true},{"route":{"name":"/api/bucket/:id/data/issues/histogram","type":"POST"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"params":[{"name":":id","type":"string","description":"bucket id","optional":false}],"body":[{"name":"app_name","type":"string","description":"a specific app name","optional":true,"defaultvalue":null},{"name":"start","type":"string","description":"ignore issue before this date","optional":true,"defaultvalue":null},{"name":"identifier","type":"string","description":"a specific issue identifier","optional":true,"defaultvalue":null},{"name":"interval","type":"string","description":"ignore issue before this date","optional":true,"defaultvalue":null},{"name":"end","type":"string","description":"ignore issue after this date","optional":true,"defaultvalue":null},{"name":"includeFixed","type":"boolean","description":"choose to ignore or not the fixed occurences","optional":true,"defaultvalue":false},{"name":"initiator","type":"string","description":"filter exceptions by initiator (node/golang/browser/webcheck...) needed with source","optional":true,"defaultvalue":null},{"name":"source","type":"string","description":"filter exceptions by source (browser app id, webcheck id...)","optional":true,"defaultvalue":null},{"name":"tags","type":"array","description":"array of string to filter tags","optional":true,"defaultvalue":null},{"name":"includeEmptyDocs","type":"boolean","description":"add empty docs","optional":true,"defaultvalue":false},{"name":"invertedTags","type":"boolean","description":"filter issue without tags","optional":true,"defaultvalue":false}],"code":[{"type":"500","description":"database error","optional":false},{"type":"200","description":"succesfully retrieved data","optional":false}],"response":[{"name":".","type":"array","description":"array of object containing exceptions for each application for each server","optional":false,"defaultvalue":null}],"name":"retrieveHistogram","longname":"Data.issues.retrieveHistogram","scope":"route"},{"route":{"name":"/api/bucket/:id/data/issues/ocurrences","type":"POST"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"params":[{"name":":id","type":"string","description":"bucket id","optional":false}],"body":[{"name":"identifier","type":"object","description":"find occurence by using an issue identifier","optional":true,"defaultvalue":null},{"name":"occurrence_id","type":"object","description":"find ocurrence by his id","optional":true,"defaultvalue":null},{"name":"includeFixed","type":"boolean","description":"choose to ignore or not the fixed occurences","optional":true,"defaultvalue":false},{"name":"limit","type":"number","description":"limit","optional":true,"defaultvalue":null}],"code":[{"type":"500","description":"database error","optional":false},{"type":"200","description":"succesfully retrieved data","optional":false}],"response":[{"name":".","type":"array","description":"array of object containing ocurrences","optional":false,"defaultvalue":null}],"name":"findOccurences","longname":"Data.issues.findOccurences","scope":"route","async":true},{"route":{"name":"/api/bucket/:id/data/issues/search","type":"POST"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"params":[{"name":":id","type":"string","description":"bucket id","optional":false}],"body":[{"name":"message","type":"string","description":"find occurence that match this message","optional":false,"defaultvalue":null},{"name":"includeFixed","type":"boolean","description":"choose to ignore or not the fixed occurences","optional":true,"defaultvalue":false}],"code":[{"type":"500","description":"database error","optional":false},{"type":"200","description":"succesfully retrieved data","optional":false}],"response":[{"name":".","type":"array","description":"array of object containing exceptions for each application for each server","optional":false,"defaultvalue":null}],"name":"search","longname":"Data.issues.search","scope":"route"},{"route":{"name":"/api/bucket/:id/data/issues/summary/:aggregateBy","type":"GET"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"params":[{"name":":id","type":"string","description":"bucket id","optional":false},{"name":":aggregateBy","type":"string","description":"servers, apps, initiators or sources","optional":false}],"code":[{"type":"500","description":"database error","optional":false},{"type":"200","description":"succesfully retrieved data","optional":false}],"response":[{"name":".","type":"array","description":"issues count aggregated","optional":false,"defaultvalue":null}],"name":"summary","longname":"Data.issues.summary","scope":"route","async":true},{"route":{"name":"/api/bucket/:id/data/issues","type":"DELETE"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"params":[{"name":":id","type":"string","description":"bucket id","optional":false}],"query":[{"name":"app_name","type":"string","description":"an specific application to delete application","optional":true,"defaultvalue":null}],"code":[{"type":"500","description":"database error","optional":false},{"type":"200","description":"succesfully retrieved data","optional":false}],"name":"deleteAll","longname":"Data.issues.deleteAll","scope":"route"},{"route":{"name":"/api/bucket/:id/data/issues/:identifier","type":"DELETE"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"params":[{"name":":id","type":"string","description":"bucket id","optional":false},{"name":":identifier","type":"string","description":"the identifier of issue that you want to delete","optional":false}],"code":[{"type":"500","description":"database error","optional":false},{"type":"200","description":"succesfully retrieved data","optional":false},{"type":"400","description":"missing/invalid parameters","optional":false}],"response":[{"name":".","type":"array","description":"array of deleted exceptions","optional":false,"defaultvalue":null}],"name":"delete","longname":"Data.issues.delete","scope":"route"}],"logs":[{"route":{"name":"/api/bucket/:id/data/logs","type":"POST"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"params":[{"name":":id","type":"string","description":"bucket id","optional":false}],"body":[{"name":"app_name","type":"string","description":"the application name","optional":true,"defaultvalue":null},{"name":"server_name","type":"string","description":"filter by server name","optional":true,"defaultvalue":null},{"name":"before","type":"string","description":"only search log oldest than ","optional":true,"defaultvalue":null},{"name":"after","type":"string","description":"only search log newer than ","optional":true,"defaultvalue":null},{"name":"size","type":"integer","description":"line limit, default to 100","optional":true,"defaultvalue":null},{"name":"from","type":"integer","description":"offset limit","optional":true,"defaultvalue":null}],"code":[{"type":"500","description":"database error","optional":false},{"type":"200","description":"succesfully retrieved data","optional":false},{"type":"400","description":"missing parameters","optional":false}],"response":[{"name":".","type":"array","description":"recorded dependencies","optional":false,"defaultvalue":null}],"examples":["km.data.logs.retrieve(bucket._id, {\n app_name: 'my_api'\n })"],"name":"retrieve","longname":"Data.logs.retrieve","scope":"route"},{"route":{"name":"/api/bucket/:id/data/logs/histogram","type":"POST"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"params":[{"name":":id","type":"string","description":"bucket id","optional":false}],"body":[{"name":"app_name","type":"object","description":"a specific app name","optional":true,"defaultvalue":null},{"name":"start","type":"object","description":"ignore log before this date","optional":true,"defaultvalue":null},{"name":"interval","type":"object","description":"ignore log before this date","optional":true,"defaultvalue":null},{"name":"end","type":"object","description":"ignore log after this date","optional":true,"defaultvalue":null}],"code":[{"type":"500","description":"database error","optional":false},{"type":"200","description":"succesfully retrieved data","optional":false}],"response":[{"name":".","type":"array","description":"array of object containing exceptions for each application for each server","optional":false,"defaultvalue":null}],"name":"retrieveHistogram","longname":"Data.logs.retrieveHistogram","scope":"route"}],"metrics":[{"route":{"name":"/api/bucket/:id/data/metrics/aggregations","type":"POST"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"params":[{"name":":id","type":"string","description":"bucket id","optional":false}],"body":[{"name":"aggregations","type":"object","description":"array of aggregations to compute","optional":false,"defaultvalue":null},{"name":"aggregations[].name","type":"string","description":"the name of metric to compute the graph","optional":false,"defaultvalue":null},{"name":"aggregations[].types","type":"array","description":"type of aggregation (e.g. ['histogram', 'servers'])","optional":false,"defaultvalue":null},{"name":"aggregations[].start","type":"date","description":"oldest documents to aggregate on","optional":false,"defaultvalue":null},{"name":"aggregations[].end","type":"date","description":"newest documents to aggregate on","optional":true,"defaultvalue":null},{"name":"aggregations[].apps","type":"array","description":"filter source applications to aggregate on","optional":true,"defaultvalue":null},{"name":"aggregations[].interval","type":"number","description":"interval between two points","optional":true,"defaultvalue":null},{"name":"aggregations[].servers","type":"array","description":"filter source server to aggregate on","optional":true,"defaultvalue":null},{"name":"aggregations[].initiator","type":"string","description":"filter source initiator to aggregate on","optional":true,"defaultvalue":null},{"name":"aggregations[].webcheck","type":"string","description":"filter source webcheck to aggregate on","optional":true,"defaultvalue":null},{"name":"aggregations[].collector","type":"string","description":"filter source collector to aggregate on","optional":true,"defaultvalue":null},{"name":"aggregations[].tags","type":"array","description":"filter tags to aggregate on","optional":true,"defaultvalue":null}],"code":[{"type":"500","description":"database error","optional":false},{"type":"200","description":"succesfully retrieved data","optional":false}],"response":[{"name":".","type":"array","description":"aggregations","optional":false,"defaultvalue":null}],"examples":["// Example #1: Retrieve HTTP metrics of app INTERACTION, WEB-API, WORKER from all servers\n km.data.metrics.retrieveAggregations(bucket._id, {\n aggregations: [\n {\n 'start': 'now-5m',\n 'apps': ['INTERACTION', 'WEB-API', 'WORKER'],\n 'types': ['histogram', 'apps', 'servers'],\n 'name': 'HTTP'\n }\n ]\n})\n\n // Example #2: Retrieve HTTP metrics of ALL apps from all servers\n km.data.metrics.retrieveAggregations(bucket._id, {\n aggregations: [\n {\n 'start': 'now-1d',\n 'types': ['histogram', 'apps', 'servers'],\n 'name': 'HTTP'\n }\n ]\n})"],"name":"retrieveAggregations","longname":"Data.metrics.retrieveAggregations","scope":"route"},{"route":{"name":"/api/bucket/:id/data/metrics/histogram","type":"POST"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"params":[{"name":":id","type":"string","description":"bucket id","optional":false}],"body":[{"name":"app_name","type":"string","description":"filter probes by app source","optional":true,"defaultvalue":null},{"name":"server_name","type":"string","description":"filter probes by server source","optional":true,"defaultvalue":null},{"name":"interval","type":"string","description":"interval of time between two point","optional":true,"defaultvalue":"minute"},{"name":"before","type":"string","description":"filter out probes that are after X minute","optional":true,"defaultvalue":60}],"code":[{"type":"500","description":"database error","optional":false},{"type":"200","description":"succesfully retrieved data","optional":false}],"response":[{"name":"server_name","type":"object","description":"","optional":false,"defaultvalue":null},{"name":"server_name.app_name","type":"object","description":"","optional":false,"defaultvalue":null},{"name":"server_name.app_name.metrics","type":"object","description":"","optional":false,"defaultvalue":null},{"name":"server_name.app_name.metrics.agg_type","type":"string","description":"the type of aggregation for this probe","optional":false,"defaultvalue":null},{"name":"server_name.app_name.metrics_name.timestamps_and_stats","type":"array","description":"array of point","optional":false,"defaultvalue":null}],"name":"retrieveHistogram","longname":"Data.metrics.retrieveHistogram","scope":"route"},{"route":{"name":"/api/bucket/:id/data/metrics/histogramPrecise","type":"POST"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"params":[{"name":":id","type":"string","description":"bucket id","optional":false}],"body":[{"name":"probe","type":"string","description":"probe name","optional":false,"defaultvalue":null},{"name":"app","type":"string","description":"filter probes by app source","optional":false,"defaultvalue":null},{"name":"server","type":"string","description":"filter probes by server source","optional":false,"defaultvalue":null},{"name":"after","type":"string","description":"interval of time between two point (now-5d, now-5m...)","optional":true,"defaultvalue":null}],"code":[{"type":"500","description":"database error","optional":false},{"type":"200","description":"succesfully retrieved data","optional":false}],"response":[{"name":"Array","type":"array","description":"of points","optional":false,"defaultvalue":null}],"name":"retrieveHistogramPrecise","longname":"Data.metrics.retrieveHistogramPrecise","scope":"route"},{"route":{"name":"/api/bucket/:id/data/metrics/list","type":"POST"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"params":[{"name":":id","type":"string","description":"bucket id","optional":false}],"body":[{"name":"servers","type":"object","description":"filter metrics by app name","optional":true,"defaultvalue":null},{"name":"apps","type":"object","description":"filter metrics by server name","optional":true,"defaultvalue":null},{"name":"initiator","type":"string","description":"filter metrics by a specific initiator","optional":true,"defaultvalue":null},{"name":"source","type":"string","description":"filter metrics by a specific source","optional":true,"defaultvalue":null},{"name":"collector","type":"string","description":"filter metrics by a specific collector","optional":true,"defaultvalue":null},{"name":"webcheck","type":"string","description":"filter metrics by a specific webcheck","optional":true,"defaultvalue":null}],"code":[{"type":"500","description":"database error","optional":false},{"type":"200","description":"succesfully retrieved data","optional":false}],"name":"retrieveList","longname":"Data.metrics.retrieveList","scope":"route"},{"route":{"name":"/api/bucket/:id/data/metrics","type":"POST"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"params":[{"name":":id","type":"string","description":"bucket id","optional":false}],"body":[{"name":"app_name","type":"string","description":"filter metrics by app source","optional":false,"defaultvalue":null},{"name":"server_name","type":"string","description":"filter metrics by server source","optional":true,"defaultvalue":null},{"name":"before","type":"string","description":"filter out metrics that are after X minute","optional":true,"defaultvalue":720}],"code":[{"type":"500","description":"database error","optional":false},{"type":"200","description":"succesfully retrieved data","optional":false}],"name":"retrieveMetadatas","longname":"Data.metrics.retrieveMetadatas","scope":"route"}],"notifications":[{"route":{"name":"/api/bucket/:id/data/notifications","type":"POST"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"params":[{"name":":id","type":"string","description":"bucket id","optional":false}],"body":[{"name":"type","type":"string","description":"Type of notification","optional":true,"defaultvalue":null},{"name":"before","type":"string","description":"we search logs before this date (lower than)","optional":true,"defaultvalue":null},{"name":"after","type":"string","description":"we search logs after this date (greater than)","optional":true,"defaultvalue":null},{"name":"size","type":"number","description":"","optional":true,"defaultvalue":null},{"name":"from","type":"number","description":"","optional":true,"defaultvalue":null},{"name":"type","type":"string","description":"type of notification","optional":true,"defaultvalue":null},{"name":"providers","type":"array","description":"find notifications with this providers","optional":true,"defaultvalue":null},{"name":"contacts","type":"array","description":"find notifications with this contact","optional":true,"defaultvalue":null},{"name":"size","type":"integer","description":"line limit, default to 20","optional":true,"defaultvalue":null},{"name":"from","type":"integer","description":"offset limit","optional":true,"defaultvalue":null}],"code":[{"type":"500","description":"database error","optional":false},{"type":"200","description":"succesfully retrieved data","optional":false}],"tags":[{"originalTitle":"reponse","title":"reponse","text":"{Array} . array of traces","value":"{Array} . array of traces","optional":false,"type":null}],"name":"list","longname":"Data.notifications.list","scope":"route","async":true},{"route":{"name":"/api/bucket/:id/data/notifications/:notification","type":"GET"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"params":[{"name":":id","type":"string","description":"bucket id","optional":false},{"name":":notification","type":"string","description":"notification id","optional":false}],"code":[{"type":"500","description":"database error","optional":false},{"type":"200","description":"succesfully retrieved data","optional":false}],"tags":[{"originalTitle":"reponse","title":"reponse","text":"{Object} . notification","value":"{Object} . notification","optional":false,"type":null}],"name":"retrieve","longname":"Data.notifications.retrieve","scope":"route","async":true}],"outliers":[{"route":{"name":"/api/bucket/:id/data/outliers/","type":"POST"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"params":[{"name":":id","type":"string","description":"bucket id","optional":false}],"body":[{"name":"app_name","type":"string","description":"the application name","optional":true,"defaultvalue":null},{"name":"server_name","type":"string","description":"filter by server name","optional":true,"defaultvalue":null},{"name":"start","type":"string","description":"only search outlier newer than ","optional":true,"defaultvalue":null},{"name":"end","type":"string","description":"only search outlier older than ","optional":true,"defaultvalue":null}],"code":[{"type":"500","description":"database error","optional":false},{"type":"200","description":"succesfully retrieved data","optional":false},{"type":"400","description":"missing parameters","optional":false}],"response":[{"name":".","type":"array","description":"recorded dependencies","optional":false,"defaultvalue":null}],"examples":["km.data.outliers.retrieve(bucket._id, {\n app_name: 'my_api'\n })"],"name":"retrieve","longname":"Data.outliers.retrieve","scope":"route"}],"processes":[{"route":{"name":"/api/bucket/:id/data/processEvents","type":"POST"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"params":[{"name":":id","type":"string","description":"bucket id","optional":false}],"body":[{"name":"app_name","type":"string","description":"filter events by app source","optional":true,"defaultvalue":null},{"name":"server_name","type":"string","description":"filter events by server source","optional":true,"defaultvalue":null},{"name":"before","type":"string","description":"filter out events that are after X minute","optional":true,"defaultvalue":60}],"code":[{"type":"500","description":"database error","optional":false},{"type":"200","description":"succesfully retrieved data","optional":false}],"response":[{"name":".","type":"array","description":"array of process events","optional":false,"defaultvalue":null}],"name":"retrieveEvents","longname":"Data.processes.retrieveEvents","scope":"route"},{"route":{"name":"/api/bucket/:id/data/processEvents/deployments","type":"POST"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"params":[{"name":":id","type":"string","description":"bucket id","optional":false}],"body":[{"name":"app_name","type":"string","description":"filter events by app source","optional":true,"defaultvalue":null},{"name":"server_name","type":"string","description":"filter events by server source","optional":true,"defaultvalue":null}],"code":[{"type":"500","description":"database error","optional":false},{"type":"200","description":"succesfully retrieved data","optional":false}],"response":[{"name":".","type":"array","description":"array of deployments","optional":false,"defaultvalue":null}],"name":"retrieveDeployments","longname":"Data.processes.retrieveDeployments","scope":"route"}],"profiling":[{"route":{"name":"/api/bucket/:id/data/profilings/:filename","type":"GET"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"params":[{"name":":id","type":"string","description":"bucket id","optional":false},{"name":":filename","type":"string","description":"filename","optional":false}],"code":[{"type":"500","description":"database error","optional":false},{"type":"400","description":"invalid parameters","optional":false}],"response":[{"name":".","type":"object","description":"return profile data","optional":false,"defaultvalue":null}],"name":"retrieve","longname":"Data.profiling.retrieve","scope":"route"},{"route":{"name":"/api/bucket/:id/data/profilings/:filename/download","type":"GET"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"params":[{"name":":id","type":"string","description":"bucket id","optional":false},{"name":":filename","type":"string","description":"filename","optional":false}],"code":[{"type":"500","description":"database error","optional":false},{"type":"400","description":"invalid parameters","optional":false}],"response":[{"name":".","type":"file","description":"return a file","optional":false,"defaultvalue":null}],"name":"download","longname":"Data.profiling.download","scope":"route"},{"route":{"name":"/api/bucket/:id/data/profilings","type":"POST"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"params":[{"name":":id","type":"string","description":"bucket id","optional":false}],"body":[{"name":"apps","type":"object","description":"","optional":true,"defaultvalue":null},{"name":"servers","type":"object","description":"","optional":true,"defaultvalue":null},{"name":"from","type":"object","description":"","optional":true,"defaultvalue":null},{"name":"size","type":"object","description":"","optional":true,"defaultvalue":null},{"name":"type","type":"object","description":"","optional":true,"defaultvalue":null}],"code":[{"type":"500","description":"database error","optional":false},{"type":"200","description":"succesfully retrieved data","optional":false}],"response":[{"name":".","type":"array","description":"array of object containing profilings","optional":false,"defaultvalue":null}],"name":"list","longname":"Data.profiling.list","scope":"route"},{"route":{"name":"/api/bucket/:id/data/profilings/:filename","type":"DELETE"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"params":[{"name":":id","type":"string","description":"bucket id","optional":false},{"name":":filename","type":"string","description":"filename","optional":false}],"code":[{"type":"500","description":"database error","optional":false},{"type":"400","description":"invalid parameters","optional":false}],"response":[{"name":".","type":"file","description":"return a file","optional":false,"defaultvalue":null}],"name":"delete","longname":"Data.profiling.delete","scope":"route"}],"status":[{"route":{"name":"/api/bucket/:id/data/status","type":"GET"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"params":[{"name":":id","type":"string","description":"bucket id","optional":false}],"code":[{"type":"500","description":"database error","optional":false},{"type":"200","description":"succesfully retrieved data","optional":false}],"tags":[{"originalTitle":"reponse","title":"reponse","text":"{Array} . array of servers status","value":"{Array} . array of servers status","optional":false,"type":null}],"name":"retrieve","longname":"Data.status.retrieve","scope":"route","async":true},{"route":{"name":"/api/bucket/:id/data/status/blacklisted","type":"GET"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"params":[{"name":":id","type":"string","description":"bucket id","optional":false}],"code":[{"type":"500","description":"database error","optional":false},{"type":"200","description":"succesfully retrieved data","optional":false}],"tags":[{"originalTitle":"reponse","title":"reponse","text":"{Array} . array of servers status","value":"{Array} . array of servers status","optional":false,"type":null}],"name":"retrieveBlacklisted","longname":"Data.status.retrieveBlacklisted","scope":"route","async":true}],"traces":[{"route":{"name":"/api/bucket/:id/data/traces","type":"POST"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"params":[{"name":":id","type":"string","description":"bucket id","optional":false}],"body":[{"name":"includeSpans","type":"boolean","description":"","optional":true,"defaultvalue":true},{"name":"serviceName","type":"string","description":"","optional":true,"defaultvalue":null},{"name":"limit","type":"string","description":"default: 10, max: 100","optional":true,"defaultvalue":null},{"name":"kind","type":"string","description":"","optional":true,"defaultvalue":null},{"name":"minDuration","type":"number","description":"","optional":true,"defaultvalue":null},{"name":"start","type":"string","description":"date","optional":true,"defaultvalue":null},{"name":"end","type":"string","description":"date","optional":true,"defaultvalue":null},{"name":"tags","type":"array","description":"Query string array like [error=500, error, ...]","optional":true,"defaultvalue":null},{"name":"orderBy","type":"string","description":"Default: newest, enum: oldest, newest, shortest, longest","optional":true,"defaultvalue":null},{"name":"spanName","type":"string","description":"","optional":true,"defaultvalue":null}],"code":[{"type":"500","description":"database error","optional":false},{"type":"200","description":"succesfully retrieved data","optional":false}],"tags":[{"originalTitle":"reponse","title":"reponse","text":"{Array} . array of traces","value":"{Array} . array of traces","optional":false,"type":null}],"name":"list","longname":"Data.traces.list","scope":"route","async":true},{"route":{"name":"/api/bucket/:id/data/traces/:trace","type":"GET"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"params":[{"name":":id","type":"string","description":"bucket id","optional":false},{"name":":trace","type":"string","description":"trace id","optional":false}],"code":[{"type":"500","description":"database error","optional":false},{"type":"200","description":"succesfully retrieved data","optional":false}],"tags":[{"originalTitle":"reponse","title":"reponse","text":"{Object} . trace","value":"{Object} . trace","optional":false,"type":null}],"name":"retrieve","longname":"Data.traces.retrieve","scope":"route","async":true},{"route":{"name":"/api/bucket/:id/data/traces/services","type":"GET"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"params":[{"name":":id","type":"string","description":"bucket id","optional":false}],"code":[{"type":"500","description":"database error","optional":false},{"type":"200","description":"succesfully retrieved data","optional":false}],"response":[{"name":"services,","type":"object","description":"spans names","optional":false,"defaultvalue":null}],"name":"getServices","longname":"Data.traces.getServices","scope":"route","async":true},{"route":{"name":"/api/bucket/:id/data/traces/tags","type":"GET"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"params":[{"name":":id","type":"string","description":"bucket id","optional":false}],"code":[{"type":"500","description":"database error","optional":false},{"type":"200","description":"succesfully retrieved data","optional":false}],"response":[{"name":"tags","type":"array","description":"","optional":false,"defaultvalue":null}],"name":"getTags","longname":"Data.traces.getTags","scope":"route","async":true},{"route":{"name":"/api/bucket/:id/data/traces/histogram/tag","type":"POST"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"params":[{"name":":id","type":"string","description":"bucket id","optional":false}],"body":[{"name":"tag","type":"string","description":"","optional":false,"defaultvalue":null},{"name":"start","type":"string","description":"date","optional":true,"defaultvalue":null},{"name":"end","type":"string","description":"date","optional":true,"defaultvalue":null},{"name":"serviceName","type":"string","description":"","optional":true,"defaultvalue":null},{"name":"spanName","type":"string","description":"","optional":true,"defaultvalue":null}],"code":[{"type":"500","description":"database error","optional":false},{"type":"200","description":"succesfully retrieved data","optional":false}],"response":[{"name":"aggregation","type":"array","description":"","optional":false,"defaultvalue":null}],"name":"getHistogramByTag","longname":"Data.traces.getHistogramByTag","scope":"route","async":true},{"route":{"name":"/api/bucket/:id/data/traces/aggregation/tag","type":"POST"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"params":[{"name":":id","type":"string","description":"bucket id","optional":false}],"body":[{"name":"tag","type":"string","description":"","optional":false,"defaultvalue":null},{"name":"start","type":"string","description":"date","optional":true,"defaultvalue":null},{"name":"end","type":"string","description":"date","optional":true,"defaultvalue":null},{"name":"serviceName","type":"string","description":"","optional":true,"defaultvalue":null},{"name":"spanName","type":"string","description":"","optional":true,"defaultvalue":null}],"code":[{"type":"500","description":"database error","optional":false},{"type":"200","description":"succesfully retrieved data","optional":false}],"response":[{"name":"aggregation","type":"array","description":"","optional":false,"defaultvalue":null}],"name":"getTagsValue","longname":"Data.traces.getTagsValue","scope":"route","async":true},{"route":{"name":"/api/bucket/:id/data/traces/aggregation/duration","type":"POST"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"params":[{"name":":id","type":"string","description":"bucket id","optional":false}],"body":[{"name":"start","type":"string","description":"date","optional":true,"defaultvalue":null},{"name":"end","type":"string","description":"date","optional":true,"defaultvalue":null},{"name":"serviceName","type":"string","description":"","optional":true,"defaultvalue":null},{"name":"spanName","type":"string","description":"","optional":true,"defaultvalue":null},{"name":"tags","type":"array","description":"","optional":true,"defaultvalue":null}],"code":[{"type":"500","description":"database error","optional":false},{"type":"200","description":"succesfully retrieved data","optional":false}],"response":[{"name":"aggregation","type":"array","description":"","optional":false,"defaultvalue":null}],"name":"getDurationAvg","longname":"Data.traces.getDurationAvg","scope":"route","async":true}],"transactions":[{"route":{"name":"/api/bucket/:id/data/transactions/v2/histogram","type":"POST"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"params":[{"name":":id","type":"string","description":"bucket id","optional":false}],"body":[{"name":"app_name","type":"string","description":"filter transactions by app source","optional":true,"defaultvalue":null},{"name":"server_name","type":"string","description":"filter transactions by server source","optional":true,"defaultvalue":null},{"name":"interval","type":"string","description":"interval of time between two point","optional":true,"defaultvalue":"minute"},{"name":"before","type":"string","description":"filter out transactions that are after X minute","optional":true,"defaultvalue":60}],"code":[{"type":"500","description":"database error","optional":false},{"type":"200","description":"succesfully retrieved data","optional":false}],"response":[{"name":".","type":"array","description":"array of times series containing points","optional":false,"defaultvalue":null}],"name":"retrieveHistogram","longname":"Data.transactions.retrieveHistogram","scope":"route"},{"route":{"name":"/api/bucket/:id/data/transactions/v2/summary","type":"POST"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"params":[{"name":":id","type":"string","description":"bucket id","optional":false}],"body":[{"name":"app_name","type":"string","description":"filter transactions by app source","optional":true,"defaultvalue":null},{"name":"server_name","type":"string","description":"filter transactions by server source","optional":true,"defaultvalue":null}],"code":[{"type":"500","description":"database error","optional":false},{"type":"200","description":"succesfully retrieved data","optional":false}],"response":[{"name":"server_name","type":"object","description":"","optional":false,"defaultvalue":null},{"name":"server_name.app_name","type":"object","description":"transaction object","optional":false,"defaultvalue":null}],"name":"retrieveSummary","longname":"Data.transactions.retrieveSummary","scope":"route"},{"route":{"name":"/api/bucket/:id/data/transactions/v2/delete","type":"POST"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"params":[{"name":":id","type":"string","description":"bucket id","optional":false}],"query":[{"name":"app_name","type":"string","description":"filter transactions by app source","optional":true,"defaultvalue":null},{"name":"server_name","type":"string","description":"filter transactions by server source","optional":true,"defaultvalue":null}],"code":[{"type":"500","description":"database error","optional":false},{"type":"200","description":"succesfully retrieved data","optional":false}],"response":[{"name":"server_name","type":"object","description":"","optional":false,"defaultvalue":null},{"name":"server_name.app_name","type":"object","description":"transaction object","optional":false,"defaultvalue":null}],"name":"delete","longname":"Data.transactions.delete","scope":"route"}]},"misc":[{"route":{"name":"/api/misc/changelog","type":"GET"},"code":[{"type":"500","description":"database error","optional":false},{"type":"200","description":"succesfully retrieved data","optional":false},{"type":"400","description":"Invalid params","optional":false}],"response":[{"name":"changelog","type":"array","description":"articles","optional":false,"defaultvalue":null}],"name":"listChangelogArticles","longname":"Misc.listChangelogArticles","scope":"route","params":[],"authentication":false},{"route":{"name":"/api/misc/release/pm2","type":"GET"},"code":[{"type":"500","description":"database error","optional":false},{"type":"200","description":"succesfully retrieved data","optional":false},{"type":"400","description":"Invalid params","optional":false}],"response":[{"name":"pm2_version","type":"string","description":"latest version","optional":false,"defaultvalue":null}],"name":"retrievePM2Version","longname":"Misc.retrievePM2Version","scope":"route","params":[],"authentication":false},{"route":{"name":"/api/misc/release/nodejs/:version","type":"GET"},"params":[{"name":":version","type":"string","description":"semver version range","optional":false}],"code":[{"type":"500","description":"database error","optional":false},{"type":"200","description":"succesfully retrieved data","optional":false},{"type":"400","description":"Invalid params","optional":false}],"response":[{"name":".","type":"array","description":"array of releases matching the range requested","optional":false,"defaultvalue":null}],"name":"retrieveNodeRelease","longname":"Misc.retrieveNodeRelease","scope":"route","authentication":false},{"route":{"name":"/api/misc/plans","type":"GET"},"code":[{"type":"500","description":"database error","optional":false},{"type":"200","description":"succesfully retrieved data","optional":false},{"type":"400","description":"Invalid params","optional":false}],"response":[{"name":".","type":"object","description":"list of plans keyed by plan name","optional":false,"defaultvalue":null}],"name":"retrievePlans","longname":"Misc.retrievePlans","scope":"route","params":[],"authentication":false},{"route":{"name":"/api/misc/stripe/retrieveCoupon","type":"POST"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"body":[{"name":"coupon","type":"string","description":"the coupon name","optional":false,"defaultvalue":null}],"code":[{"type":"500","description":"stripe error","optional":false},{"type":"200","description":"succesfully retrieved the metadata","optional":false}],"response":[{"name":"coupon","type":"object","description":"the coupon object","optional":false,"defaultvalue":null}],"name":"retrieveCoupon","longname":"Misc.retrieveCoupon","scope":"route","params":[]},{"route":{"name":"/api/misc/stripe/retrieveCompany","type":"POST"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"body":[{"name":"vat_id","type":"string","description":"the vat id of the company","optional":false,"defaultvalue":null}],"code":[{"type":"500","description":"stripe error","optional":false},{"type":"200","description":"succesfully retrieved the metadata","optional":false}],"response":[{"name":".","type":"object","description":"metadata about company","optional":false,"defaultvalue":null}],"name":"retrieveCompany","longname":"Misc.retrieveCompany","scope":"route","params":[]},{"route":{"name":"/api/misc/stripe/retrieveVat","type":"POST"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"body":[{"name":"country","type":"string","description":"country code of the user","optional":true,"defaultvalue":null}],"code":[{"type":"500","description":"stripe error","optional":false},{"type":"200","description":"succesfully retrieved the metadata","optional":false}],"response":[{"name":"coupon","type":"object","description":"the coupon object","optional":false,"defaultvalue":null}],"name":"retrieveVAT","longname":"Misc.retrieveVAT","scope":"route","params":[]}],"node":[{"route":{"name":"/api/node/default","type":"GET"},"response":[{"name":"node","type":"object","description":"Return node object","optional":false,"defaultvalue":null}],"name":"getDefaultNode","longname":"Node.getDefaultNode","scope":"route","params":[],"authentication":false}],"orchestration":[{"route":{"name":"/api/bucket/:id/balance","type":"POST"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"code":[{"type":"500","description":"balancing error","optional":false},{"type":"403","description":"already on new node or not premium","optional":false},{"type":"200","description":"succesfully balanced the bucket","optional":false}],"response":[{"name":"migration","type":"object","description":"is equal true if succesfull","optional":false,"defaultvalue":null}],"name":"selfSend","longname":"Orchestration.selfSend","scope":"route","params":[]}],"tokens":[{"route":{"name":"/api/users/token/","type":"GET"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"code":[{"type":"500","description":"database error","optional":false},{"type":"200","description":"successfully retrieved","optional":false}],"response":[{"name":".","type":"object","description":"array of tokens","optional":false,"defaultvalue":null}],"name":"retrieve","longname":"Tokens.retrieve","scope":"route","params":[]},{"route":{"name":"/api/users/token/:id","type":"DELETE"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"params":[{"name":":id","type":"string","description":"token id","optional":false}],"code":[{"type":"500","description":"database error","optional":false},{"type":"404","description":"token not found","optional":false},{"type":"200","description":"refresh token has been deleted and all access token that have been created with it","optional":false}],"response":[{"name":".","type":"object","description":"array of tokens","optional":false,"defaultvalue":null}],"name":"remove","longname":"Tokens.remove","scope":"route"},{"route":{"name":"/api/users/token/","type":"PUT"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"body":[{"name":"scope","type":"object","description":"a valid oauth scope","optional":false,"defaultvalue":null}],"code":[{"type":"409","description":"the otp is already enabled for the user, you can only delete it","optional":false},{"type":"200","description":"the otp can be registered for the account, return the full response","optional":false}],"response":[{"name":".","type":"object","description":"generated token","optional":false,"defaultvalue":null}],"name":"create","longname":"Tokens.create","scope":"route","params":[]}],"user":{"otp":[{"route":{"name":"/api/users/otp","type":"GET"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"code":[{"type":"409","description":"the otp is already enabled for the user, you can only delete it","optional":false},{"type":"200","description":"the otp can be registered for the account, return the full response","optional":false}],"response":[{"name":"user","type":"object","description":"user model","optional":false,"defaultvalue":null},{"name":"key","type":"string","description":"otp secret key","optional":false,"defaultvalue":null},{"name":"qrImage","type":"string","description":"url to the QrCode","optional":false,"defaultvalue":null}],"name":"retrieve","longname":"User.otp.retrieve","scope":"route","params":[]},{"route":{"name":"/api/users/otp","type":"POST"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"body":[{"name":"otpKey","type":"string","description":"secret key used to generate OTP code","optional":false,"defaultvalue":null},{"name":"otpToken","type":"string","description":"a currently valid OTP code generated with the otpKey","optional":false,"defaultvalue":null}],"code":[{"type":"400","description":"missing parameters","optional":false},{"type":"403","description":"the code asked to add the OTP from user account is invalid","optional":false},{"type":"500","description":"error from database","optional":false},{"type":"200","description":"the otp has been registered for the user","optional":false}],"name":"enable","longname":"User.otp.enable","scope":"route","params":[]},{"route":{"name":"/api/users/otp","type":"DELETE"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"query":[{"name":"otpToken","type":"string","description":"a currently valid OTP code","optional":false,"defaultvalue":null}],"code":[{"type":"400","description":"missing parameters","optional":false},{"type":"403","description":"the code asked to remove the OTP from user account is invalid","optional":false},{"type":"500","description":"error from database","optional":false},{"type":"200","description":"the otp has been deleted for the user","optional":false}],"name":"disable","longname":"User.otp.disable","scope":"route","params":[]}],"providers":[{"route":{"name":"/api/users/integrations","type":"GET"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"code":[{"type":"200","description":"succesfully retrieved providers","optional":false}],"response":[{"name":".","type":"array","description":"array of providers for user account","optional":false,"defaultvalue":null}],"name":"retrieve","longname":"User.providers.retrieve","scope":"route","params":[]},{"route":{"name":"/api/users/integrations","type":"POST"},"authentication":true,"body":[{"name":"name","type":"string","description":"the provider name","optional":false,"defaultvalue":null}],"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"code":[{"type":"400","description":"invalid parameters","optional":false},{"type":"403","description":"the user already have this provider","optional":false},{"type":"200","description":"succesfully added the provider","optional":false}],"name":"add","longname":"User.providers.add","scope":"route","params":[]},{"route":{"name":"/api/users/integrations/:name","type":"DELETE"},"authentication":true,"params":[{"name":":name","type":"string","description":"the provider name","optional":false}],"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"code":[{"type":"400","description":"invalid parameters or provider isn't implemented","optional":false},{"type":"403","description":"the provider isn't enabled","optional":false},{"type":"200","description":"succesfully removed the provider","optional":false}],"name":"remove","longname":"User.providers.remove","scope":"route"}],"default":[{"name":"retrieve","route":{"name":"/api/users/isLogged","type":"GET"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"code":[{"type":"200","description":"the user has been retrieved","optional":false}],"response":[{"name":"user","type":"object","description":"user model","optional":false,"defaultvalue":null}],"longname":"User.retrieve","scope":"route"},{"route":{"name":"/api/users/show/:id","type":"GET"},"params":[{"name":":id","type":"string","description":"user id","optional":false}],"code":[{"type":"500","description":"database error","optional":false},{"type":"400","description":"invalid parameters (no id provided)","optional":false},{"type":"404","description":"no user account where found","optional":false},{"type":"200","description":"the mail has been sent to the provided email","optional":false}],"response":[{"name":"String","type":"","description":"email user email","optional":false,"defaultvalue":null},{"name":"String","type":"","description":"username user pseudo","optional":false,"defaultvalue":null}],"name":"show","longname":"User.show","scope":"route","authentication":false},{"route":{"name":"/api/users/update","type":"POST"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"body":[{"name":"username","type":"string","description":"","optional":true,"defaultvalue":null},{"name":"email","type":"string","description":"","optional":true,"defaultvalue":null},{"name":"old_password","type":"string","description":"","optional":true,"defaultvalue":null},{"name":"new_password","type":"string","description":"","optional":true,"defaultvalue":null},{"name":"info","type":"object","description":"","optional":true,"defaultvalue":null}],"code":[{"type":"500","description":"database error","optional":false},{"type":"400","description":"missing parameters, no data to update","optional":false},{"type":"403","description":"when updating the password, it need a new one","optional":false},{"type":"406","description":"when updating the password, the old one is false","optional":false},{"type":"409","description":"when updating email or username\n another user already have one of those two","optional":false},{"type":"200","description":"succesfully updated the card","optional":false}],"response":[{"name":".","type":"object","description":"user object","optional":false,"defaultvalue":null}],"name":"update","longname":"User.update","scope":"route","params":[]},{"route":{"name":"/api/users/delete","type":"DELETE"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"code":[{"type":"500","description":"database error","optional":false},{"type":"403","description":"permission denied (hold buckets)","optional":false},{"type":"200","description":"succesfully deleted the user","optional":false}],"response":[{"name":".","type":"object","description":"user object","optional":false,"defaultvalue":null}],"name":"delete","longname":"User.delete","scope":"route","params":[]}]},"auth":[{"name":"retrieveToken","route":{"name":"/api/oauth/token","type":"POST"},"service":{"name":"OAUTH"},"body":[{"name":"client_id","type":"string","description":"the public id of your oauth application","optional":false,"defaultvalue":null},{"name":"refresh_token","type":"string","description":"refresh token you retrieved via authorize endpoint","optional":false,"defaultvalue":null},{"name":"grant_type","type":"string","description":"","optional":false,"defaultvalue":"refresh_token"}],"code":[{"type":"400","description":"invalid parameters (missing or not correct)","optional":false}],"response":[{"name":"access_token","type":"string","description":"a fresh access_token","optional":false,"defaultvalue":null},{"name":"refresh_token","type":"string","description":"the refresh token you used","optional":false,"defaultvalue":null},{"name":"expire_at","type":"string","description":"UTC date at which the token will be considered\n as invalid","optional":false,"defaultvalue":null},{"name":"token_type","type":"string","description":"the type of token to use, for now its always Bearer","optional":false,"defaultvalue":null}],"longname":"Auth.retrieveToken","scope":"route","authentication":false},{"name":"requestNewPassword","route":{"name":"/api/oauth/reset_password","type":"POST"},"service":{"name":"OAUTH"},"body":[{"name":"email","type":"string","description":"email of the account that want a password reset","optional":false,"defaultvalue":null}],"code":[{"type":"500","description":"the database failed to register the token to reset the mail","optional":false},{"type":"400","description":"missing parameters","optional":false},{"type":"404","description":"no user account where found with the provided email","optional":false},{"type":"200","description":"the mail has been sent to the provided email","optional":false}],"longname":"Auth.requestNewPassword","scope":"route","authentication":false},{"name":"sendEmailLink","route":{"name":"/api/oauth/send_email_link","type":"POST"},"service":{"name":"OAUTH"},"code":[{"type":"500","description":"the database failed to register the token to reset the mail","optional":false},{"type":"401","description":"need to authenticated","optional":false},{"type":"200","description":"the mail has been sent to the provided email","optional":false}],"longname":"Auth.sendEmailLink","scope":"route","authentication":false},{"name":"validEmail","route":{"name":"/api/oauth/valid_email/:token","type":"GET"},"params":[{"description":"the token to validate the account","name":":token","optional":false,"type":null}],"service":{"name":"OAUTH"},"code":[{"type":"500","description":"the database failed to valid email","optional":false},{"type":"404","description":"need to authenticated","optional":false},{"type":"301","description":"the email has been valided","optional":false}],"longname":"Auth.validEmail","scope":"route","authentication":false},{"route":{"name":"/api/oauth/register","type":"GET"},"service":{"name":"OAUTH"},"body":[{"name":"username","type":"string","description":"","optional":false,"defaultvalue":null},{"name":"email","type":"string","description":"","optional":false,"defaultvalue":null},{"name":"password","type":"string","description":"","optional":false,"defaultvalue":null},{"name":"role","type":"string","description":"job title in user company","optional":true,"defaultvalue":null},{"name":"company","type":"string","description":"company name","optional":true,"defaultvalue":null},{"name":"accept_terms","type":"integer","description":"","optional":false,"defaultvalue":null}],"code":[{"type":"500","description":"either the registeration of new user is disabled or\nthe database failed to register the user","optional":false},{"type":"409","description":"the user field are already used by another user","optional":false},{"type":"200","description":"the user has been created","optional":false}],"response":[{"name":"user","type":"object","description":"user model","optional":false,"defaultvalue":null},{"name":"access_token","type":"object","description":"access token issued for the user","optional":false,"defaultvalue":null},{"name":"refreshToken","type":"object","description":"refresh token issued for the user","optional":false,"defaultvalue":null}],"name":"register","longname":"Auth.register","scope":"route","authentication":false},{"route":{"name":"/api/oauth/revoke","type":"POST"},"service":{"name":"OAUTH"},"authentication":true,"header":[{"name":"Authorization","type":"string","description":"bearer access token issued for the user","optional":false,"defaultvalue":null}],"code":[{"type":"404","description":"token not found","optional":false},{"type":"500","description":"database error","optional":false},{"type":"200","description":"the token has been succesfully deleted,\n if there was access token generated with this token, they\n have been deleted too","optional":false}],"name":"revoke","longname":"Auth.revoke","scope":"route"}]}
\ No newline at end of file
diff --git a/node_modules/@pm2/js-api/src/auth_strategies/browser_strategy.js b/node_modules/@pm2/js-api/src/auth_strategies/browser_strategy.js
new file mode 100644
index 0000000..486b06f
--- /dev/null
+++ b/node_modules/@pm2/js-api/src/auth_strategies/browser_strategy.js
@@ -0,0 +1,67 @@
+/* global URLSearchParams, URL, localStorage */
+'use strict'
+
+const AuthStrategy = require('./strategy')
+
+module.exports = class BrowserFlow extends AuthStrategy {
+ removeUrlToken (refreshToken) {
+ let url = window.location.href
+ let params = `?access_token=${refreshToken}&token_type=refresh_token`
+ let newUrl = url.replace(params, '')
+ window.history.pushState('', '', newUrl)
+ }
+
+ retrieveTokens (km, cb) {
+ let verifyToken = (refresh) => {
+ return km.auth.retrieveToken({
+ client_id: this.client_id,
+ refresh_token: refresh
+ })
+ }
+
+ // parse the url since it can contain tokens
+ let url = new URL(window.location)
+ this.response_mode = this.response_mode === 'query' ? 'search' : this.response_mode
+ let params = new URLSearchParams(url[this.response_mode])
+
+ if (params.get('access_token') !== null) {
+ // verify that the access_token in parameters is valid
+ verifyToken(params.get('access_token'))
+ .then((res) => {
+ this.removeUrlToken(res.data.refresh_token)
+ // Save refreshToken in localstorage
+ localStorage.setItem('km_refresh_token', params.get('access_token'))
+ let tokens = res.data
+ return cb(null, tokens)
+ }).catch(cb)
+ } else if (typeof localStorage !== 'undefined' && localStorage.getItem('km_refresh_token') !== null) {
+ // maybe in the local storage ?
+ verifyToken(localStorage.getItem('km_refresh_token'))
+ .then((res) => {
+ this.removeUrlToken(res.data.refresh_token)
+ let tokens = res.data
+ return cb(null, tokens)
+ }).catch(cb)
+ } else {
+ // otherwise we need to get a refresh token
+ window.location = `${this.oauth_endpoint}${this.oauth_query}&redirect_uri=${window.location}`
+ }
+ }
+
+ deleteTokens (km) {
+ return new Promise((resolve, reject) => {
+ // revoke the refreshToken
+ km.auth.revoke()
+ .then(res => console.log('Token successfuly revoked!'))
+ .catch(err => console.error(`Error when trying to revoke token: ${err.message}`))
+ // We need to remove from storage and redirect user in every case (cf. https://github.com/keymetrics/pm2-io-js-api/issues/49)
+ // remove the token from the localStorage
+ localStorage.removeItem('km_refresh_token')
+ setTimeout(_ => {
+ // redirect after few miliseconds so any user code will run
+ window.location = `${this.oauth_endpoint}${this.oauth_query}`
+ }, 500)
+ return resolve()
+ })
+ }
+}
diff --git a/node_modules/@pm2/js-api/src/auth_strategies/embed_strategy.js b/node_modules/@pm2/js-api/src/auth_strategies/embed_strategy.js
new file mode 100644
index 0000000..07d1232
--- /dev/null
+++ b/node_modules/@pm2/js-api/src/auth_strategies/embed_strategy.js
@@ -0,0 +1,138 @@
+
+'use strict'
+
+const AuthStrategy = require('./strategy.js')
+const http = require('http')
+const fs = require('fs')
+const url = require('url')
+const exec = require('child_process').exec
+const async = require('async')
+const path = require('path')
+const os = require('os')
+
+module.exports = class EmbedStrategy extends AuthStrategy {
+ // try to find a token
+ retrieveTokens (km, cb) {
+ let verifyToken = (refresh) => {
+ return km.auth.retrieveToken({
+ client_id: this.client_id,
+ refresh_token: refresh
+ })
+ }
+ async.tryEach([
+ // try to find the token via the environement
+ (next) => {
+ if (!process.env.KM_TOKEN) {
+ return next(new Error('No token in env'))
+ }
+ verifyToken(process.env.KM_TOKEN)
+ .then((res) => {
+ return next(null, res.data)
+ })
+ .catch(next)
+ },
+ // try to find it in the file system
+ (next) => {
+ fs.readFile(path.resolve(os.homedir(), '.keymetrics-tokens'), (err, tokens) => {
+ if (err) return next(err)
+
+ // verify that the token is valid
+ tokens = JSON.parse(tokens || '{}')
+ if (new Date(tokens.expire_at) > new Date(new Date().toISOString())) {
+ return next(null, tokens)
+ }
+
+ verifyToken(tokens.refresh_token)
+ .then((res) => {
+ return next(null, res.data)
+ })
+ .catch(next)
+ })
+ },
+ // otherwise make the whole flow
+ (next) => {
+ return this.launch((data) => {
+ // verify that the token is valid
+ verifyToken(data.access_token)
+ .then((res) => {
+ return next(null, res.data)
+ })
+ .catch(next)
+ })
+ }
+ ], (err, result) => {
+ if (result.refresh_token) {
+ let file = path.resolve(os.homedir(), '.keymetrics-tokens')
+ fs.writeFile(file, JSON.stringify(result), () => {
+ return cb(err, result)
+ })
+ } else {
+ return cb(err, result)
+ }
+ })
+ }
+
+ launch (cb) {
+ let shutdown = false
+ let server = http.createServer((req, res) => {
+ // only handle one request
+ if (shutdown === true) return res.end()
+ shutdown = true
+
+ let query = url.parse(req.url, true).query
+
+ res.write(` You can go back to your terminal now :) `)
+ res.end()
+ server.close()
+ return cb(query)
+ })
+ server.listen(43532, () => {
+ this.open(`${this.oauth_endpoint}${this.oauth_query}`)
+ })
+ }
+
+ open (target, appName, callback) {
+ let opener
+ const escape = function (s) {
+ return s.replace(/"/g, '\\"')
+ }
+
+ if (typeof (appName) === 'function') {
+ callback = appName
+ appName = null
+ }
+
+ switch (process.platform) {
+ case 'darwin': {
+ opener = appName ? `open -a "${escape(appName)}"` : `open`
+ break
+ }
+ case 'win32': {
+ opener = appName ? `start "" ${escape(appName)}"` : `start ""`
+ break
+ }
+ default: {
+ opener = appName ? escape(appName) : `xdg-open`
+ break
+ }
+ }
+
+ if (process.env.SUDO_USER) {
+ opener = 'sudo -u ' + process.env.SUDO_USER + ' ' + opener
+ }
+ return exec(`${opener} "${escape(target)}"`, callback)
+ }
+
+ deleteTokens (km) {
+ return new Promise((resolve, reject) => {
+ // revoke the refreshToken
+ km.auth.revoke()
+ .then(res => {
+ // remove the token from the filesystem
+ let file = path.resolve(os.homedir(), '.keymetrics-tokens')
+ fs.unlinkSync(file)
+ return resolve(res)
+ }).catch(reject)
+ })
+ }
+}
diff --git a/node_modules/@pm2/js-api/src/auth_strategies/standalone_strategy.js b/node_modules/@pm2/js-api/src/auth_strategies/standalone_strategy.js
new file mode 100644
index 0000000..c57e172
--- /dev/null
+++ b/node_modules/@pm2/js-api/src/auth_strategies/standalone_strategy.js
@@ -0,0 +1,33 @@
+
+'use strict'
+
+const AuthStrategy = require('./strategy')
+
+module.exports = class StandaloneFlow extends AuthStrategy {
+ retrieveTokens (km, cb) {
+ if (this._opts.refresh_token && this._opts.access_token) {
+ // if both access and refresh tokens are provided, we are good
+ return cb(null, {
+ access_token: this._opts.access_token,
+ refresh_token: this._opts.refresh_token
+ })
+ } else if (this._opts.refresh_token && this._opts.client_id) {
+ // we can also make a request to get an access token
+ km.auth.retrieveToken({
+ client_id: this._opts.client_id,
+ refresh_token: this._opts.refresh_token
+ }).then((res) => {
+ let tokens = res.data
+ return cb(null, tokens)
+ }).catch(cb)
+ } else {
+ // otherwise the flow isn't used correctly
+ throw new Error(`If you want to use the standalone flow you need to provide either
+ a refresh and access token OR a refresh token and a client id`)
+ }
+ }
+
+ deleteTokens (km) {
+ return km.auth.revoke
+ }
+}
diff --git a/node_modules/@pm2/js-api/src/auth_strategies/strategy.js b/node_modules/@pm2/js-api/src/auth_strategies/strategy.js
new file mode 100644
index 0000000..a42e5d3
--- /dev/null
+++ b/node_modules/@pm2/js-api/src/auth_strategies/strategy.js
@@ -0,0 +1,57 @@
+
+'use strict'
+
+const constants = require('../../constants.js')
+
+const AuthStrategy = class AuthStrategy {
+ constructor (opts) {
+ this._opts = opts
+ this.client_id = opts.client_id || opts.OAUTH_CLIENT_ID
+ if (!this.client_id) {
+ throw new Error('You must always provide a application id for any of the strategies')
+ }
+ this.scope = opts.scope || 'all'
+ this.response_mode = opts.reponse_mode || 'query'
+
+ let optsOauthEndpoint = null
+ if (opts && opts.services) {
+ optsOauthEndpoint = opts.services.OAUTH || opts.services.API
+ }
+ const oauthEndpoint = constants.services.OAUTH || constants.services.API
+ this.oauth_endpoint = `${optsOauthEndpoint || oauthEndpoint}`
+ if (this.oauth_endpoint[this.oauth_endpoint.length - 1] === '/' && constants.OAUTH_AUTHORIZE_ENDPOINT[0] === '/') {
+ this.oauth_endpoint = this.oauth_endpoint.substr(0, this.oauth_endpoint.length - 1)
+ }
+ this.oauth_endpoint += constants.OAUTH_AUTHORIZE_ENDPOINT
+ this.oauth_query = `?client_id=${opts.client_id}&response_mode=${this.response_mode}` +
+ `&response_type=token&scope=${this.scope}`
+ }
+
+ retrieveTokens () {
+ throw new Error('You need to implement a retrieveTokens function inside your strategy')
+ }
+
+ deleteTokens () {
+ throw new Error('You need to implement a deleteTokens function inside your strategy')
+ }
+
+ static implementations (name) {
+ const flows = {
+ 'embed': {
+ nodule: require('./embed_strategy'),
+ condition: 'node'
+ },
+ 'browser': {
+ nodule: require('./browser_strategy'),
+ condition: 'browser'
+ },
+ 'standalone': {
+ nodule: require('./standalone_strategy'),
+ condition: null
+ }
+ }
+ return name ? flows[name] : null
+ }
+}
+
+module.exports = AuthStrategy
diff --git a/node_modules/@pm2/js-api/src/endpoint.js b/node_modules/@pm2/js-api/src/endpoint.js
new file mode 100644
index 0000000..8776d0a
--- /dev/null
+++ b/node_modules/@pm2/js-api/src/endpoint.js
@@ -0,0 +1,34 @@
+
+'use strict'
+
+const RequestValidator = require('./utils/validator')
+const debug = require('debug')('kmjs:endpoint')
+
+module.exports = class Endpoint {
+ constructor (opts) {
+ Object.assign(this, opts)
+ }
+
+ build (http) {
+ let endpoint = this
+ return function () {
+ let callsite = new Error().stack.split('\n')[2]
+ if (callsite && callsite.length > 0) {
+ debug(`Call to '${endpoint.route.name}' from ${callsite.replace(' at ', '')}`)
+ }
+ return new Promise((resolve, reject) => {
+ RequestValidator.extract(endpoint, Array.prototype.slice.call(arguments))
+ .then((opts) => {
+ // Different service than default, setup base url in url
+ if (endpoint.service && endpoint.service.baseURL) {
+ let base = endpoint.service.baseURL
+ base = base[base.length - 1] === '/' ? base.substr(0, base.length - 1) : base
+ opts.url = base + opts.url
+ }
+ http.request(opts).then(resolve, reject)
+ })
+ .catch(reject)
+ })
+ }
+ }
+}
diff --git a/node_modules/@pm2/js-api/src/keymetrics.js b/node_modules/@pm2/js-api/src/keymetrics.js
new file mode 100644
index 0000000..51050fc
--- /dev/null
+++ b/node_modules/@pm2/js-api/src/keymetrics.js
@@ -0,0 +1,78 @@
+
+'use strict'
+
+const Namespace = require('./namespace')
+const constants = require('../constants')
+const NetworkWrapper = require('./network')
+const logger = require('debug')('kmjs')
+
+const Keymetrics = class Keymetrics {
+ /**
+ * @constructor
+ * Keymetrics
+ *
+ * @param {Object} [opts]
+ * @param {String} [opts.OAUTH_CLIENT_ID] the oauth client ID used to authenticate to KM
+ * @param {Object} [opts.services] base url for differents services
+ * @param {String} [opts.mappings] api mappings
+ */
+ constructor (opts) {
+ logger('init keymetrics instance')
+ this.opts = Object.assign(constants, opts)
+
+ logger('init network client (http/ws)')
+ this._network = new NetworkWrapper(this, this.opts)
+
+ const mapping = opts && opts.mappings ? opts.mappings : require('./api_mappings.json')
+ logger(`Using mappings provided in ${opts && opts.mappings ? 'options' : 'package'}`)
+
+ // build namespaces at startup
+ logger('building namespaces')
+ let root = new Namespace(mapping, {
+ name: 'root',
+ http: this._network,
+ services: this.opts.services
+ })
+ logger('exposing namespaces')
+ for (let key in root) {
+ if (key === 'name' || key === 'opts') continue
+ this[key] = root[key]
+ }
+ logger(`attached namespaces : ${Object.keys(this)}`)
+
+ this.realtime = this._network.realtime
+ }
+
+ /**
+ * Use a specific flow to retrieve an access token on behalf the user
+ * @param {String|Function} flow either a flow name or a custom implementation
+ * @param {Object} [opts]
+ * @param {String} [opts.client_id] the OAuth client ID to use to identify the application
+ * default to the one defined when instancing Keymetrics and fallback to 795984050 (custom tokens)
+ * @throws invalid use of this function, either the flow don't exist or isn't correctly implemented
+ */
+ use (flow, opts) {
+ logger(`using ${flow} authentication strategy`)
+ this._network.useStrategy(flow, opts)
+ // the logout is dependent of the auth flow so we need it to be initialize
+ // but also we need to give the access of the instance, so we inject it here
+ this.auth.logout = () => {
+ return this._network.oauth_flow.deleteTokens(this)
+ }
+ return this
+ }
+
+ /**
+ * API date lag, in millisecond. This is the difference between the current browser date and the
+ * approximated API date. This is useful to compute duration between dates returned by the API
+ * and "now".
+ * @example
+ * const apiDate = moment().add(km.apiDateLag)
+ * const timeSinceLastUpdate = apiDate.diff(server.updated_at)
+ */
+ get apiDateLag () {
+ return this._network.apiDateLag
+ }
+}
+
+module.exports = Keymetrics
diff --git a/node_modules/@pm2/js-api/src/namespace.js b/node_modules/@pm2/js-api/src/namespace.js
new file mode 100644
index 0000000..c8f3672
--- /dev/null
+++ b/node_modules/@pm2/js-api/src/namespace.js
@@ -0,0 +1,76 @@
+
+'use strict'
+
+const Endpoint = require('./endpoint')
+const logger = require('debug')('kmjs:namespace')
+
+module.exports = class Namespace {
+ constructor (mapping, opts) {
+ logger(`initialization namespace ${opts.name}`)
+ this.name = opts.name
+ this.http = opts.http
+ this.endpoints = []
+ this.namespaces = []
+
+ logger(`building namespace ${opts.name}`)
+ for (let name in mapping) {
+ let child = mapping[name]
+ if (typeof mapping === 'object' && !child.route) {
+ // ignore the 'default' namespace that should bind to the parent namespace
+ if (name === 'default') {
+ // create the namespace
+ const defaultNamespace = new Namespace(child, { name, http: this.http, services: opts.services })
+ this.namespaces.push(defaultNamespace)
+ // bind property of the default namespace to this namespace
+ for (let key in defaultNamespace) {
+ if (key === 'name' || key === 'opts') continue
+ this[key] = defaultNamespace[key]
+ }
+ continue
+ }
+ // if the parent namespace is a object, the child are namespace too
+ this.addNamespace(new Namespace(child, { name, http: this.http, services: opts.services }))
+ } else {
+ // otherwise its an endpoint
+ if (child.service && opts.services && opts.services[child.service.name]) {
+ child.service.baseURL = opts.services[child.service.name]
+ }
+ this.addEndpoint(new Endpoint(child))
+ }
+ }
+
+ // logging namespaces
+ if (this.namespaces.length > 0) {
+ logger(`namespace ${this.name} contains namespaces : \n${this.namespaces.map(namespace => namespace.name).join('\n')}\n`)
+ }
+
+ // logging endpoints
+ if (this.endpoints.length > 0) {
+ logger(`Namespace ${this.name} contains endpoints : \n${this.endpoints.map(endpoint => endpoint.route.name).join('\n')}\n`)
+ }
+ }
+
+ addNamespace (namespace) {
+ if (!namespace || namespace.name === this.name) {
+ throw new Error(`A namespace must not have the same name as the parent namespace`)
+ }
+ if (!(namespace instanceof Namespace)) {
+ throw new Error(`addNamespace only accept Namespace instance`)
+ }
+
+ this.namespaces.push(namespace)
+ this[namespace.name] = namespace
+ }
+
+ addEndpoint (endpoint) {
+ if (!endpoint || endpoint.name === this.name) {
+ throw new Error(`A endpoint must not have the same name as a namespace`)
+ }
+ if (!(endpoint instanceof Endpoint)) {
+ throw new Error(`addNamespace only accept Namespace instance`)
+ }
+
+ this.endpoints.push(endpoint)
+ this[endpoint.name] = endpoint.build(this.http)
+ }
+}
diff --git a/node_modules/@pm2/js-api/src/network.js b/node_modules/@pm2/js-api/src/network.js
new file mode 100644
index 0000000..b372f93
--- /dev/null
+++ b/node_modules/@pm2/js-api/src/network.js
@@ -0,0 +1,464 @@
+
+'use strict'
+
+const extrareqp2 = require('extrareqp2')
+const AuthStrategy = require('./auth_strategies/strategy')
+const constants = require('../constants')
+const logger = require('debug')('kmjs:network')
+const loggerHttp = require('debug')('kmjs:network:http')
+const loggerWS = require('debug')('kmjs:network:ws')
+const WS = require('./utils/websocket')
+const EventEmitter = require('eventemitter2')
+const async = require('async')
+
+const BUFFERIZED = -1
+
+module.exports = class NetworkWrapper {
+ constructor (km, opts) {
+ logger('init network manager')
+ opts.baseURL = opts.services.API
+ this.opts = opts
+ this.opts.maxRedirects = 0
+ this.tokens = {
+ refresh_token: null,
+ access_token: null
+ }
+ this.km = km
+ this._queue = []
+ this._extrareqp2 = extrareqp2.create(opts)
+ this._websockets = []
+ this._endpoints = new Map()
+ this._bucketFilters = new Map()
+
+ this.apiDateLag = 0
+
+ this.realtime = new EventEmitter({
+ wildcard: true,
+ delimiter: ':',
+ newListener: false,
+ maxListeners: 100
+ })
+ // https://github.com/EventEmitter2/EventEmitter2/issues/214
+ const self = this
+ const realtimeOn = this.realtime.on
+ this.realtime.on = function () {
+ self.editSocketFilters('push', arguments[0])
+ return realtimeOn.apply(self.realtime, arguments)
+ }
+ const realtimeOff = this.realtime.off
+ this.realtime.off = function () {
+ self.editSocketFilters('remove', arguments[0])
+ return realtimeOff.apply(self.realtime, arguments)
+ }
+ this.realtime.subscribe = this.subscribe.bind(this)
+ this.realtime.unsubscribe = this.unsubscribe.bind(this)
+ this.authenticated = false
+ this._setupDateLag()
+ }
+
+ _setupDateLag () {
+ const updateApiDateLag = response => {
+ if (response && response.headers && response.headers.date) {
+ const headerDate = new Date(response.headers.date)
+ const clientDate = new Date()
+
+ // The header date is likely to be truncated to the second, so truncate the client date too
+ headerDate.setMilliseconds(0)
+ clientDate.setMilliseconds(0)
+
+ this.apiDateLag = headerDate - clientDate
+ }
+ }
+
+ this._extrareqp2.interceptors.response.use(
+ response => {
+ updateApiDateLag(response)
+ return response
+ },
+ error => {
+ updateApiDateLag(error.response)
+ return Promise.reject(error)
+ }
+ )
+ }
+
+ _queueUpdater () {
+ if (this.authenticated === false) return
+
+ if (this._queue.length > 0) {
+ logger(`Emptying requests queue (size: ${this._queue.length})`)
+ }
+
+ // when we are authenticated we can clear the queue
+ while (this._queue.length > 0) {
+ let promise = this._queue.shift()
+ // make the request
+ this.request(promise.request).then(promise.resolve, promise.reject)
+ }
+ }
+
+ /**
+ * Resolve the endpoint of the node to make the request to
+ * because each bucket might be on a different node
+ * @param {String} bucketID the bucket id
+ *
+ * @return {Promise}
+ */
+ _resolveBucketEndpoint (bucketID) {
+ if (!bucketID) return Promise.reject(new Error(`Missing argument : bucketID`))
+
+ if (!this._endpoints.has(bucketID)) {
+ const promise = this._extrareqp2.request({
+ url: `/api/bucket/${bucketID}`,
+ method: 'GET',
+ headers: {
+ Authorization: `Bearer ${this.tokens.access_token}`
+ }
+ })
+ .then((res) => {
+ return res.data.node.endpoints.web
+ })
+ .catch((e) => {
+ this._endpoints.delete(bucketID)
+ throw e
+ })
+
+ this._endpoints.set(bucketID, promise)
+ }
+
+ return this._endpoints.get(bucketID)
+ }
+
+ /**
+ * Send a http request
+ * @param {Object} opts
+ * @param {String} [opts.method=GET] http method
+ * @param {String} opts.url the full URL
+ * @param {Object} [opts.data] body data
+ * @param {Object} [opts.params] url params
+ *
+ * @return {Promise}
+ */
+ request (httpOpts) {
+ return new Promise((resolve, reject) => {
+ async.series([
+ // verify that we don't need to buffer the request because authentication
+ next => {
+ if (this.authenticated === true || httpOpts.authentication === false) return next()
+
+ loggerHttp(`Queued request to ${httpOpts.url}`)
+ this._queue.push({
+ resolve,
+ reject,
+ request: httpOpts
+ })
+ // we need to stop the flow here
+ return next(BUFFERIZED)
+ },
+ // we need to verify that the baseURL is correct
+ (next) => {
+ if (!httpOpts.url.match(/bucket\/[0-9a-fA-F]{24}/)) return next()
+ // parse the bucket id from URL
+ let bucketID = httpOpts.url.split('/')[3]
+ // we need to retrieve where to send the request depending on the backend
+ this._resolveBucketEndpoint(bucketID)
+ .then(endpoint => {
+ httpOpts.baseURL = endpoint
+ // then continue the flow
+ return next()
+ }).catch(next)
+ },
+ // if the request has not been bufferized, make the request
+ next => {
+ // super trick to transform a promise response to a callback
+ const successNext = res => next(null, res)
+ loggerHttp(`Making request to ${httpOpts.url}`)
+
+ if (!httpOpts.headers) {
+ httpOpts.headers = {}
+ }
+ httpOpts.headers.Authorization = `Bearer ${this.tokens.access_token}`
+
+ this._extrareqp2.request(httpOpts)
+ .then(successNext)
+ .catch((error) => {
+ let response = error.response
+ // we only need to handle when code is 401 (which mean unauthenticated)
+ if (response && response.status !== 401) return next(response)
+ loggerHttp(`Got unautenticated response, buffering request from now ...`)
+
+ // we tell the client to not send authenticated request anymore
+ this.authenticated = false
+
+ loggerHttp(`Asking to the oauth flow to retrieve new tokens`)
+
+ var q = () => {
+ this.oauth_flow.retrieveTokens(this.km, (err, data) => {
+ // if it fail, we fail the whole request
+ if (err) {
+ loggerHttp(`Failed to retrieve new tokens : ${err.message || err}`)
+ return next(response)
+ }
+ // if its good, we try to update the tokens
+ loggerHttp(`Succesfully retrieved new tokens`)
+ this._updateTokens(null, data, (err, authenticated) => {
+ // if it fail, we fail the whole request
+ if (err) return next(response)
+ // then we can rebuffer the request
+ loggerHttp(`Re-buffering call to ${httpOpts.url} since authenticated now`)
+ httpOpts.headers.Authorization = `Bearer ${this.tokens.access_token}`
+ return this._extrareqp2.request(httpOpts).then(successNext).catch(next)
+ })
+ })
+ }
+ if (httpOpts.url == this.opts.services.OAUTH + '/api/oauth/token') {
+ // Avoid infinite recursive loop to retrieveToken
+ return setTimeout(q.bind(this), 500)
+ }
+ q()
+ })
+ }
+ ], (err, results) => {
+ // if the flow is stoped because the request has been
+ // buferred, we don't need to do anything
+ if (err === BUFFERIZED) return
+ return err ? reject(err) : resolve(results[2])
+ })
+ })
+ }
+
+ /**
+ * Update the access token used by all the networking clients
+ * @param {Error} err if any erro
+ * @param {String} accessToken the token you want to use
+ * @param {Function} [cb] invoked with
+ * @private
+ */
+ _updateTokens (err, data, cb) {
+ if (err) {
+ console.error('Error while retrieving tokens:', err)
+ // Try to logout/login user
+ this.oauth_flow.deleteTokens(this.km)
+ return console.error(err.response ? err.response.data : err.stack)
+ }
+ if (!data || !data.access_token || !data.refresh_token) throw new Error('Invalid tokens')
+
+ this.tokens = data
+
+ loggerHttp(`Registered new access_token : ${data.access_token}`)
+ this._websockets.forEach(websocket => websocket.updateAuthorization(data.access_token))
+ this._extrareqp2.defaults.headers.common['Authorization'] = `Bearer ${data.access_token}`
+ this._extrareqp2.request({
+ url: '/api/bucket',
+ method: 'GET',
+ headers: {
+ Authorization: `Bearer ${data.access_token}`
+ }
+ }).then((res) => {
+ loggerHttp(`Cached ${res.data.length} buckets for current user`)
+ this.authenticated = true
+ this._queueUpdater()
+ return typeof cb === 'function' ? cb(null, true) : null
+ }).catch((err) => {
+ console.error('Error while retrieving buckets')
+ console.error(err.response ? err.response.data : err)
+ return typeof cb === 'function' ? cb(err) : null
+ })
+ }
+
+ /**
+ * Specify a strategy to use when authenticating to server
+ * @param {String|Function} flow the name of the flow to use or a custom implementation
+ * @param {Object} [opts]
+ * @param {String} [opts.client_id] the OAuth client ID to use to identify the application
+ * default to the one defined when instancing Keymetrics and fallback to 795984050 (custom tokens)
+ * @throws invalid use of this function, either the flow don't exist or isn't correctly implemented
+ */
+ useStrategy (flow, opts) {
+ if (!opts) opts = {}
+ // if client not provided here, use the one given in the instance
+ if (!opts.client_id) {
+ opts.client_id = this.opts.OAUTH_CLIENT_ID
+ }
+
+ // in the case of flow being a custom implementation
+ if (typeof flow === 'object') {
+ this.oauth_flow = flow
+ if (!this.oauth_flow.retrieveTokens || !this.oauth_flow.deleteTokens) {
+ throw new Error('You must implement the Strategy interface to use it')
+ }
+ return this.oauth_flow.retrieveTokens(this.km, this._updateTokens.bind(this))
+ }
+ // otherwise fallback on the flow that are implemented
+ if (typeof AuthStrategy.implementations(flow) === 'undefined') {
+ throw new Error(`The flow named ${flow} doesn't exist`)
+ }
+ let flowMeta = AuthStrategy.implementations(flow)
+
+ // verify that the environnement condition is meet
+ if (flowMeta.condition && constants.ENVIRONNEMENT !== flowMeta.condition) {
+ throw new Error(`The flow ${flow} is reserved for ${flowMeta.condition} environment`)
+ }
+ let FlowImpl = flowMeta.nodule
+ this.oauth_flow = new FlowImpl(opts)
+ return this.oauth_flow.retrieveTokens(this.km, this._updateTokens.bind(this))
+ }
+
+ editSocketFilters (type, event) {
+ if (event.indexOf('**') === 0) throw new Error('You need to provide a bucket public id.')
+ event = event.split(':')
+ const bucketPublicId = event[0]
+ const filter = event.slice(2).join(':')
+ const socket = this._websockets.find(socket => socket.bucketPublic === bucketPublicId)
+ if (!this._bucketFilters.has(bucketPublicId)) this._bucketFilters.set(bucketPublicId, [])
+ const filters = this._bucketFilters.get(bucketPublicId)
+
+ if (type === 'push') {
+ filters.push(filter)
+ } else {
+ filters.splice(filters.indexOf(filter), 1)
+ }
+
+ if (!socket) return
+ socket.send(JSON.stringify({
+ action: 'sub',
+ public_id: bucketPublicId,
+ filters: Array.from(new Set(filters)) // avoid duplicates
+ }))
+ }
+
+ /**
+ * Subscribe to realtime from bucket
+ * @param {String} bucketId bucket id
+ * @param {Object} [opts]
+ *
+ * @return {Promise}
+ */
+ subscribe (bucketId, opts) {
+ return new Promise((resolve, reject) => {
+ logger(`Request endpoints for ${bucketId}`)
+ this.km.bucket.retrieve(bucketId)
+ .then((res) => {
+ let bucket = res.data
+ let connected = false
+
+ const endpoints = bucket.node.endpoints
+ let endpoint = endpoints.realtime || endpoints.web
+ endpoint = endpoint.replace('http', 'ws')
+ if (this.opts.IS_DEBUG) {
+ endpoint = endpoint.replace(':3000', ':4020')
+ }
+ loggerWS(`Found endpoint for ${bucketId} : ${endpoint}`)
+
+ // connect websocket client to the realtime endpoint
+ let socket = new WS(`${endpoint}/primus`, this.tokens.access_token)
+ socket.bucketPublic = bucket.public_id
+ socket.connected = false
+ socket.bucket = bucketId
+
+ let keepAliveHandler = function () {
+ socket.ping()
+ }
+ let keepAliveInterval = null
+
+ let onConnect = () => {
+ logger(`Connected to ws endpoint : ${endpoint} (bucket: ${bucketId})`)
+ socket.connected = true
+ this.realtime.emit(`${bucket.public_id}:connected`)
+
+ socket.send(JSON.stringify({
+ action: 'sub',
+ public_id: bucket.public_id,
+ filters: Array.from(new Set(this._bucketFilters.get(bucket.public_id))) // avoid duplicates
+ }))
+
+ if (keepAliveInterval !== null) {
+ clearInterval(keepAliveInterval)
+ keepAliveInterval = null
+ }
+ keepAliveInterval = setInterval(keepAliveHandler.bind(this), 5000)
+ if (!connected) {
+ connected = true
+ return resolve(socket)
+ }
+ }
+ socket.onmaxreconnect = _ => {
+ if (!connected) {
+ connected = true
+ return reject(new Error('Connection timeout'))
+ }
+ }
+ socket.onopen = onConnect
+
+ socket.onunexpectedresponse = (req, res) => {
+ if (res.statusCode === 401) {
+ return this.oauth_flow.retrieveTokens(this.km, (err, data) => {
+ if (err) return logger(`Failed to retrieve tokens for ws: ${err.message}`)
+ logger(`Succesfully retrieved new tokens for ws`)
+ this._updateTokens(null, data, (err, authenticated) => {
+ if (err) return logger(`Failed to update tokens for ws: ${err.message}`)
+ return socket._tryReconnect()
+ })
+ })
+ }
+ return socket._tryReconnect()
+ }
+ socket.onerror = (err) => {
+ loggerWS(`Error on ${endpoint} (bucket: ${bucketId})`)
+ loggerWS(err)
+
+ this.realtime.emit(`${bucket.public_id}:error`, err)
+ }
+
+ socket.onclose = () => {
+ logger(`Closing ws connection ${endpoint} (bucket: ${bucketId})`)
+ socket.connected = false
+ this.realtime.emit(`${bucket.public_id}:disconnected`)
+
+ if (keepAliveInterval !== null) {
+ clearInterval(keepAliveInterval)
+ keepAliveInterval = null
+ }
+ }
+
+ // broadcast in the bus
+ socket.onmessage = (msg) => {
+ loggerWS(`Received message for bucket ${bucketId} (${(msg.data.length / 1000).toFixed(1)} Kb)`)
+ let data = null
+ try {
+ data = JSON.parse(msg.data)
+ } catch (e) {
+ return loggerWS(`Receive not json message for bucket ${bucketId}`)
+ }
+ let packet = data.data[1]
+ Object.keys(packet).forEach((event) => {
+ if (event === 'server_name') return
+ this.realtime.emit(`${bucket.public_id}:${packet.server_name || 'none'}:${event}`, packet[event])
+ })
+ }
+
+ this._websockets.push(socket)
+ }).catch(reject)
+ })
+ }
+
+ /**
+ * Unsubscribe realtime from bucket
+ * @param {String} bucketId bucket id
+ * @param {Object} [opts]
+ *
+ * @return {Promise}
+ */
+ unsubscribe (bucketId, opts) {
+ return new Promise((resolve, reject) => {
+ logger(`Unsubscribe from realtime for ${bucketId}`)
+ let socket = this._websockets.find(socket => socket.bucket === bucketId)
+ if (!socket) {
+ return reject(new Error(`Realtime wasn't connected to ${bucketId}`))
+ }
+ socket.close(1000, 'Disconnecting')
+ logger(`Succesfully unsubscribed from realtime for ${bucketId}`)
+ return resolve()
+ })
+ }
+}
diff --git a/node_modules/@pm2/js-api/src/utils/validator.js b/node_modules/@pm2/js-api/src/utils/validator.js
new file mode 100644
index 0000000..bef80de
--- /dev/null
+++ b/node_modules/@pm2/js-api/src/utils/validator.js
@@ -0,0 +1,164 @@
+
+'use strict'
+
+module.exports = class RequestValidator {
+ /**
+ * Extract httpOptions from the endpoint definition
+ * and the data given by the user
+ *
+ * @param {Object} endpoint endpoint definition
+ * @param {Array} args arguments given by the user
+ * @return {Promise} resolve to the http options need to make the request
+ */
+ static extract (endpoint, args) {
+ let isDefined = val => val !== null && typeof val !== 'undefined'
+
+ return new Promise((resolve, reject) => {
+ let httpOpts = {
+ params: {},
+ data: {},
+ url: endpoint.route.name + '',
+ method: endpoint.route.type,
+ authentication: endpoint.authentication || false
+ }
+
+ switch (endpoint.route.type) {
+ // GET request, we assume data will only be in the query or url params
+ case 'GET': {
+ for (let param of (endpoint.params || [])) {
+ let value = args.shift()
+ // params should always be a string since they will be replaced in the url
+ if (typeof value !== 'string' && param.optional === false) {
+ return reject(new Error(`Expected to receive string argument for ${param.name} to match but got ${value}`))
+ }
+ if (value) {
+ // if value is given, use it
+ httpOpts.url = httpOpts.url.replace(param.name, value)
+ } else if (param.optional === false && param.defaultvalue !== null) {
+ // use default value if available
+ httpOpts.url = httpOpts.url.replace(param.name, param.defaultvalue)
+ }
+ }
+ for (let param of (endpoint.query || [])) {
+ let value = args.shift()
+ // query should always be a string since they will be replaced in the url
+ if (typeof value !== 'string' && param.optional === false) {
+ return reject(new Error(`Expected to receive string argument for ${param.name} query but got ${value}`))
+ }
+ // set query value
+ if (value) {
+ // if value is given, use it
+ httpOpts.params[param.name] = value
+ } else if (param.optional === false && param.defaultvalue !== null) {
+ // use default value if available
+ httpOpts.params[param.name] = param.defaultvalue
+ }
+ }
+ break
+ }
+ // for PUT, POST and PATCH request, only params and body are authorized
+ case 'PUT':
+ case 'POST':
+ case 'PATCH': {
+ for (let param of (endpoint.params || [])) {
+ let value = args.shift()
+ // params should always be a string since they will be replaced in the url
+ if (typeof value !== 'string' && param.optional === false) {
+ return reject(new Error(`Expected to receive string argument for ${param.name} to match but got ${value}`))
+ }
+ // replace param in url
+ if (value) {
+ // if value is given, use it
+ httpOpts.url = httpOpts.url.replace(param.name, value)
+ } else if (param.optional === false && param.defaultvalue !== null) {
+ // use default value if available
+ httpOpts.url = httpOpts.url.replace(param.name, param.defaultvalue)
+ }
+ }
+ for (let param of (endpoint.query || [])) {
+ let value = args.shift()
+ // query should always be a string since they will be replaced in the url
+ if (typeof value !== 'string' && param.optional === false) {
+ return reject(new Error(`Expected to receive string argument for ${param.name} query but got ${value}`))
+ }
+ // set query value
+ if (value) {
+ // if value is given, use it
+ httpOpts.params[param.name] = value
+ } else if (param.optional === false && param.defaultvalue !== null) {
+ // use default value if available
+ httpOpts.params[param.name] = param.defaultvalue
+ }
+ }
+ // if we don't have any arguments, break
+ if (args.length === 0) break
+ let data = args[0]
+ if (typeof data !== 'object' && endpoint.body.length > 0) {
+ return reject(new Error(`Expected to receive an object for post data but received ${typeof data}`))
+ }
+ for (let field of (endpoint.body || [])) {
+ let isSubfield = field.name.includes('[]') === true
+
+ // verify that the mandatory field are here
+ if (!isDefined(data[field.name]) && isSubfield === false && field.optional === false && field.defaultvalue === null) {
+ return reject(new Error(`Missing mandatory field ${field.name} to make a POST request on ${endpoint.route.name}`))
+ }
+ // verify that the mandatory field are the good type
+ if (typeof data[field.name] !== field.type && isSubfield === false && field.optional === false && field.defaultvalue === null) { // eslint-disable-line
+ return reject(new Error(`Invalid type for field ${field.name}, expected ${field.type} but got ${typeof data[field.name]}`))
+ }
+
+ // add it to the request only when its present
+ if (isDefined(data[field.name])) {
+ httpOpts.data[field.name] = data[field.name]
+ }
+
+ // or else its not optional and has a default value
+ if (field.optional === false && field.defaultvalue !== null) {
+ httpOpts.data[field.name] = field.defaultvalue
+ }
+ }
+ break
+ }
+ // DELETE can have params or query parameters
+ case 'DELETE': {
+ for (let param of (endpoint.params || [])) {
+ let value = args.shift()
+ // params should always be a string since they will be replaced in the url
+ if (typeof value !== 'string' && param.optional === false) {
+ return reject(new Error(`Expected to receive string argument for ${param.name} to match but got ${value}`))
+ }
+ // replace param in url
+ if (value) {
+ // if value is given, use it
+ httpOpts.url = httpOpts.url.replace(param.name, value)
+ } else if (param.optional === false && param.defaultvalue !== null) {
+ // use default value if available
+ httpOpts.url = httpOpts.url.replace(param.name, param.defaultvalue)
+ }
+ }
+ for (let param of (endpoint.query || [])) {
+ let value = args.shift()
+ // query should always be a string
+ if (typeof value !== 'string' && param.optional === false) {
+ return reject(new Error(`Expected to receive string argument for ${param.name} query but got ${value}`))
+ }
+ // replace param in url
+ if (value) {
+ // if value is given, use it
+ httpOpts.params[param.name] = value
+ } else if (param.optional === false && param.defaultvalue !== null) {
+ // use default value if available
+ httpOpts.params[param.name] = param.defaultvalue
+ }
+ }
+ break
+ }
+ default: {
+ return reject(new Error(`Invalid endpoint declaration, invalid method ${endpoint.route.type} found`))
+ }
+ }
+ return resolve(httpOpts)
+ })
+ }
+}
diff --git a/node_modules/@pm2/js-api/src/utils/websocket.js b/node_modules/@pm2/js-api/src/utils/websocket.js
new file mode 100644
index 0000000..553289d
--- /dev/null
+++ b/node_modules/@pm2/js-api/src/utils/websocket.js
@@ -0,0 +1,181 @@
+/* global WebSocket */
+
+'use strict'
+
+const ws = require('ws')
+const debug = require('debug')('kmjs:network:_ws')
+
+const _WebSocket = typeof ws !== 'function' ? WebSocket : ws
+
+const defaultOptions = {
+ debug: false,
+ automaticOpen: true,
+ reconnectOnError: true,
+ reconnectInterval: 1000,
+ maxReconnectInterval: 10000,
+ reconnectDecay: 1,
+ timeoutInterval: 2000,
+ maxReconnectAttempts: Infinity,
+ randomRatio: 3,
+ reconnectOnCleanClose: false
+}
+
+const ReconnectableWebSocket = function (url, token, protocols, options) {
+ if (!protocols) protocols = []
+ if (!options) options = []
+
+ this.CONNECTING = 0
+ this.OPEN = 1
+ this.CLOSING = 2
+ this.CLOSED = 3
+
+ this._url = url
+ this._token = token
+ this._protocols = protocols
+ this._options = Object.assign({}, defaultOptions, options)
+ this._messageQueue = []
+ this._reconnectAttempts = 0
+ this.readyState = this.CONNECTING
+
+ if (typeof this._options.debug === 'function') {
+ this._debug = this._options.debug
+ } else if (this._options.debug) {
+ this._debug = console.log.bind(console)
+ } else {
+ this._debug = function () {}
+ }
+
+ if (this._options.automaticOpen) this.open()
+}
+
+ReconnectableWebSocket.prototype.updateAuthorization = function (authorization) {
+ this._token = authorization
+}
+
+ReconnectableWebSocket.prototype.open = function () {
+ debug('open')
+ var socket = this._socket = new _WebSocket(`${this._url}?token=${this._token}`, this._protocols)
+
+ if (this._options.binaryType) {
+ socket.binaryType = this._options.binaryType
+ }
+
+ if (this._options.maxReconnectAttempts && this._options.maxReconnectAttempts < this._reconnectAttempts) {
+ return this.onmaxreconnect()
+ }
+
+ this._syncState()
+
+ if (socket.on) {
+ socket.on('unexpected-response', this._onunexpectedresponse)
+ }
+ socket.onmessage = this._onmessage.bind(this)
+ socket.onopen = this._onopen.bind(this)
+ socket.onclose = this._onclose.bind(this)
+ socket.onerror = this._onerror.bind(this)
+}
+
+ReconnectableWebSocket.prototype.send = function (data) {
+ debug('send')
+ if (this._socket && this._socket.readyState === _WebSocket.OPEN && this._messageQueue.length === 0) {
+ this._socket.send(data)
+ } else {
+ this._messageQueue.push(data)
+ }
+}
+
+ReconnectableWebSocket.prototype.ping = function () {
+ debug('ping')
+ if (this._socket.ping && this._socket && this._socket.readyState === _WebSocket.OPEN && this._messageQueue.length === 0) {
+ this._socket.ping()
+ }
+}
+
+ReconnectableWebSocket.prototype.close = function (code, reason) {
+ debug('close')
+ if (typeof code === 'undefined') code = 1000
+
+ if (this._socket) this._socket.close(code, reason)
+}
+
+ReconnectableWebSocket.prototype._onunexpectedresponse = function (req, res) {
+ debug('unexpected-response')
+ this.onunexpectedresponse && this.onunexpectedresponse(req, res)
+}
+
+ReconnectableWebSocket.prototype._onmessage = function (message) {
+ debug('onmessage')
+ this.onmessage && this.onmessage(message)
+}
+
+ReconnectableWebSocket.prototype._onopen = function (event) {
+ debug('onopen')
+ this._syncState()
+ this._flushQueue()
+ if (this._reconnectAttempts !== 0) {
+ this.onreconnect && this.onreconnect()
+ }
+ this._reconnectAttempts = 0
+
+ this.onopen && this.onopen(event)
+}
+
+ReconnectableWebSocket.prototype._onclose = function (event) {
+ debug('onclose', event)
+ this._syncState()
+ this._debug('WebSocket: connection is broken', event)
+
+ this.onclose && this.onclose(event)
+
+ this._tryReconnect(event)
+}
+
+ReconnectableWebSocket.prototype._onerror = function (event) {
+ debug('onerror', event)
+ // To avoid undetermined state, we close socket on error
+ this._socket.close()
+ this._syncState()
+
+ this._debug('WebSocket: error', event)
+
+ this.onerror && this.onerror(event)
+
+ if (this._options.reconnectOnError) this._tryReconnect(event)
+}
+
+ReconnectableWebSocket.prototype._tryReconnect = function (event) {
+ var self = this
+ debug('Trying to reconnect')
+ if (event.wasClean && !this._options.reconnectOnCleanClose) {
+ return
+ }
+ setTimeout(function () {
+ if (self.readyState === self.CLOSING || self.readyState === self.CLOSED) {
+ self._reconnectAttempts++
+ self.open()
+ }
+ }, this._getTimeout())
+}
+
+ReconnectableWebSocket.prototype._flushQueue = function () {
+ while (this._messageQueue.length !== 0) {
+ var data = this._messageQueue.shift()
+ this._socket.send(data)
+ }
+}
+
+ReconnectableWebSocket.prototype._getTimeout = function () {
+ var timeout = this._options.reconnectInterval * Math.pow(this._options.reconnectDecay, this._reconnectAttempts)
+ timeout = timeout > this._options.maxReconnectInterval ? this._options.maxReconnectInterval : timeout
+ return this._options.randomRatio ? getRandom(timeout / this._options.randomRatio, timeout) : timeout
+}
+
+ReconnectableWebSocket.prototype._syncState = function () {
+ this.readyState = this._socket.readyState
+}
+
+function getRandom (min, max) {
+ return Math.random() * (max - min) + min
+}
+
+module.exports = ReconnectableWebSocket
diff --git a/node_modules/@pm2/pm2-version-check/README.md b/node_modules/@pm2/pm2-version-check/README.md
new file mode 100644
index 0000000..ea2ab21
--- /dev/null
+++ b/node_modules/@pm2/pm2-version-check/README.md
@@ -0,0 +1,8 @@
+
+# @pm2/pm2-version-check
+
+This module is included in all major PM2 version to retrieve the latest PM2 version and gather some metrics about PM2 usage (PM2 version being runned, Node.js version, Platform, Uptime)
+
+## LICENSE
+
+MIT
diff --git a/node_modules/@pm2/pm2-version-check/index.js b/node_modules/@pm2/pm2-version-check/index.js
new file mode 100644
index 0000000..3826146
--- /dev/null
+++ b/node_modules/@pm2/pm2-version-check/index.js
@@ -0,0 +1,54 @@
+
+const https = require('https');
+const debug = require('debug')('pm2:version-check')
+const qs = require('querystring')
+
+var VersionCheck = {}
+
+VersionCheck.runCheck = function(params, cb) {
+ var path = null
+
+ if (cb == null && typeof(params) == 'function') {
+ cb = params
+ path = '/check'
+ } else {
+ path = '/check?' + qs.stringify(params)
+ }
+
+ var options = {
+ host: 'version.pm2.io',
+ path: path,
+ strictSSL: false,
+ timeout: 1200,
+ rejectUnauthorized: false
+ }
+
+ var req = https.get(options, function(res) {
+ if (res.statusCode != 200) return false
+ var bodyChunks = []
+ res.on('data', function(chunk) {
+ bodyChunks.push(chunk)
+ }).on('end', function() {
+ var body = Buffer.concat(bodyChunks)
+ try {
+ var data = JSON.parse(body)
+ return cb ? cb(null, data) : null
+ } catch(e) {
+ return cb ? cb(new Error('Could not parse result')) : null
+ }
+ })
+ })
+
+ req.on('error', function(e) {
+ debug('ERROR: ' + e.message)
+ return cb ? cb(e) : null
+ })
+}
+
+module.exports = VersionCheck
+
+if (require.main === module) {
+ VersionCheck.runCheck((err, dt) => {
+ console.log(err, dt)
+ })
+}
diff --git a/node_modules/@pm2/pm2-version-check/package.json b/node_modules/@pm2/pm2-version-check/package.json
new file mode 100644
index 0000000..cfd7823
--- /dev/null
+++ b/node_modules/@pm2/pm2-version-check/package.json
@@ -0,0 +1,11 @@
+{
+ "name": "@pm2/pm2-version-check",
+ "version": "1.0.4",
+ "description": "Module to check latest PM2 version",
+ "main": "index.js",
+ "author": "Alexandre Strzelewicz",
+ "license": "MIT",
+ "dependencies": {
+ "debug": "^4.3.1"
+ }
+}
diff --git a/node_modules/@tootallnate/quickjs-emscripten/LICENSE b/node_modules/@tootallnate/quickjs-emscripten/LICENSE
new file mode 100644
index 0000000..07499f6
--- /dev/null
+++ b/node_modules/@tootallnate/quickjs-emscripten/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+quickjs-emscripten copyright (c) 2019 Jake Teton-Landis
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/node_modules/@tootallnate/quickjs-emscripten/README.md b/node_modules/@tootallnate/quickjs-emscripten/README.md
new file mode 100644
index 0000000..70658a5
--- /dev/null
+++ b/node_modules/@tootallnate/quickjs-emscripten/README.md
@@ -0,0 +1,597 @@
+# quickjs-emscripten
+
+Javascript/Typescript bindings for QuickJS, a modern Javascript interpreter,
+compiled to WebAssembly.
+
+- Safely evaluate untrusted Javascript (up to ES2020).
+- Create and manipulate values inside the QuickJS runtime ([more][values]).
+- Expose host functions to the QuickJS runtime ([more][functions]).
+- Execute synchronous code that uses asynchronous functions, with [asyncify][asyncify].
+
+[Github] | [NPM] | [API Documentation][api] | [Examples][tests]
+
+```typescript
+import { getQuickJS } from "quickjs-emscripten"
+
+async function main() {
+ const QuickJS = await getQuickJS()
+ const vm = QuickJS.newContext()
+
+ const world = vm.newString("world")
+ vm.setProp(vm.global, "NAME", world)
+ world.dispose()
+
+ const result = vm.evalCode(`"Hello " + NAME + "!"`)
+ if (result.error) {
+ console.log("Execution failed:", vm.dump(result.error))
+ result.error.dispose()
+ } else {
+ console.log("Success:", vm.dump(result.value))
+ result.value.dispose()
+ }
+
+ vm.dispose()
+}
+
+main()
+```
+
+[github]: https://github.com/justjake/quickjs-emscripten
+[npm]: https://www.npmjs.com/package/quickjs-emscripten
+[api]: https://github.com/justjake/quickjs-emscripten/blob/main/doc/modules.md
+[tests]: https://github.com/justjake/quickjs-emscripten/blob/main/ts/quickjs.test.ts
+[values]: #interfacing-with-the-interpreter
+[asyncify]: #asyncify
+[functions]: #exposing-apis
+
+## Usage
+
+Install from `npm`: `npm install --save quickjs-emscripten` or `yarn add quickjs-emscripten`.
+
+The root entrypoint of this library is the `getQuickJS` function, which returns
+a promise that resolves to a [QuickJS singleton](./doc/classes/quickjs.md) when
+the QuickJS WASM module is ready.
+
+Once `getQuickJS` has been awaited at least once, you also can use the `getQuickJSSync`
+function to directly access the singleton engine in your synchronous code.
+
+### Safely evaluate Javascript code
+
+See [QuickJS.evalCode](https://github.com/justjake/quickjs-emscripten/blob/main/doc/classes/quickjs.md#evalcode)
+
+```typescript
+import { getQuickJS, shouldInterruptAfterDeadline } from "quickjs-emscripten"
+
+getQuickJS().then((QuickJS) => {
+ const result = QuickJS.evalCode("1 + 1", {
+ shouldInterrupt: shouldInterruptAfterDeadline(Date.now() + 1000),
+ memoryLimitBytes: 1024 * 1024,
+ })
+ console.log(result)
+})
+```
+
+### Interfacing with the interpreter
+
+You can use [QuickJSContext](https://github.com/justjake/quickjs-emscripten/blob/main/doc/classes/QuickJSContext.md)
+to build a scripting environment by modifying globals and exposing functions
+into the QuickJS interpreter.
+
+Each `QuickJSContext` instance has its own environment -- globals, built-in
+classes -- and actions from one context won't leak into other contexts or
+runtimes (with one exception, see [Asyncify][asyncify]).
+
+Every context is created inside a
+[QuickJSRuntime](https://github.com/justjake/quickjs-emscripten/blob/main/doc/classes/QuickJSRuntime.md).
+A runtime represents a Javascript heap, and you can even share values between
+contexts in the same runtime.
+
+```typescript
+const vm = QuickJS.newContext()
+let state = 0
+
+const fnHandle = vm.newFunction("nextId", () => {
+ return vm.newNumber(++state)
+})
+
+vm.setProp(vm.global, "nextId", fnHandle)
+fnHandle.dispose()
+
+const nextId = vm.unwrapResult(vm.evalCode(`nextId(); nextId(); nextId()`))
+console.log("vm result:", vm.getNumber(nextId), "native state:", state)
+
+nextId.dispose()
+vm.dispose()
+```
+
+When you create a context from a top-level API like in the example above,
+instead of by calling `runtime.newContext()`, a runtime is automatically created
+for the lifetime of the context, and disposed of when you dispose the context.
+
+#### Runtime
+
+The runtime has APIs for CPU and memory limits that apply to all contexts within
+the runtime in aggregate. You can also use the runtime to configure EcmaScript
+module loading.
+
+```typescript
+const runtime = QuickJS.newRuntime()
+// "Should be enough for everyone" -- attributed to B. Gates
+runtime.setMemoryLimit(1024 * 640)
+// Limit stack size
+runtime.setMaxStackSize(1024 * 320)
+// Interrupt computation after 1024 calls to the interrupt handler
+let interruptCycles = 0
+runtime.setInterruptHandler(() => ++interruptCycles > 1024)
+// Toy module system that always returns the module name
+// as the default export
+runtime.setModuleLoader((moduleName) => `export default '${moduleName}'`)
+const context = runtime.newContext()
+const ok = context.evalCode(`
+import fooName from './foo.js'
+globalThis.result = fooName
+`)
+context.unwrapResult(ok).dispose()
+// logs "foo.js"
+console.log(context.getProp(context.global, "result").consume(context.dump))
+context.dispose()
+runtime.dispose()
+```
+
+### Memory Management
+
+Many methods in this library return handles to memory allocated inside the
+WebAssembly heap. These types cannot be garbage-collected as usual in
+Javascript. Instead, you must manually manage their memory by calling a
+`.dispose()` method to free the underlying resources. Once a handle has been
+disposed, it cannot be used anymore. Note that in the example above, we call
+`.dispose()` on each handle once it is no longer needed.
+
+Calling `QuickJSContext.dispose()` will throw a RuntimeError if you've forgotten to
+dispose any handles associated with that VM, so it's good practice to create a
+new VM instance for each of your tests, and to call `vm.dispose()` at the end
+of every test.
+
+```typescript
+const vm = QuickJS.newContext()
+const numberHandle = vm.newNumber(42)
+// Note: numberHandle not disposed, so it leaks memory.
+vm.dispose()
+// throws RuntimeError: abort(Assertion failed: list_empty(&rt->gc_obj_list), at: quickjs/quickjs.c,1963,JS_FreeRuntime)
+```
+
+Here are some strategies to reduce the toil of calling `.dispose()` on each
+handle you create:
+
+#### Scope
+
+A
+[`Scope`](https://github.com/justjake/quickjs-emscripten/blob/main/doc/classes/scope.md#class-scope)
+instance manages a set of disposables and calls their `.dispose()`
+method in the reverse order in which they're added to the scope. Here's the
+"Interfacing with the interpreter" example re-written using `Scope`:
+
+```typescript
+Scope.withScope((scope) => {
+ const vm = scope.manage(QuickJS.newContext())
+ let state = 0
+
+ const fnHandle = scope.manage(
+ vm.newFunction("nextId", () => {
+ return vm.newNumber(++state)
+ })
+ )
+
+ vm.setProp(vm.global, "nextId", fnHandle)
+
+ const nextId = scope.manage(vm.unwrapResult(vm.evalCode(`nextId(); nextId(); nextId()`)))
+ console.log("vm result:", vm.getNumber(nextId), "native state:", state)
+
+ // When the withScope block exits, it calls scope.dispose(), which in turn calls
+ // the .dispose() methods of all the disposables managed by the scope.
+})
+```
+
+You can also create `Scope` instances with `new Scope()` if you want to manage
+calling `scope.dispose()` yourself.
+
+#### `Lifetime.consume(fn)`
+
+[`Lifetime.consume`](https://github.com/justjake/quickjs-emscripten/blob/main/doc/classes/lifetime.md#consume)
+is sugar for the common pattern of using a handle and then
+immediately disposing of it. `Lifetime.consume` takes a `map` function that
+produces a result of any type. The `map` fuction is called with the handle,
+then the handle is disposed, then the result is returned.
+
+Here's the "Interfacing with interpreter" example re-written using `.consume()`:
+
+```typescript
+const vm = QuickJS.newContext()
+let state = 0
+
+vm.newFunction("nextId", () => {
+ return vm.newNumber(++state)
+}).consume((fnHandle) => vm.setProp(vm.global, "nextId", fnHandle))
+
+vm.unwrapResult(vm.evalCode(`nextId(); nextId(); nextId()`)).consume((nextId) =>
+ console.log("vm result:", vm.getNumber(nextId), "native state:", state)
+)
+
+vm.dispose()
+```
+
+Generally working with `Scope` leads to more straight-forward code, but
+`Lifetime.consume` can be handy sugar as part of a method call chain.
+
+### Exposing APIs
+
+To add APIs inside the QuickJS environment, you'll need to create objects to
+define the shape of your API, and add properties and functions to those objects
+to allow code inside QuickJS to call code on the host.
+
+By default, no host functionality is exposed to code running inside QuickJS.
+
+```typescript
+const vm = QuickJS.newContext()
+// `console.log`
+const logHandle = vm.newFunction("log", (...args) => {
+ const nativeArgs = args.map(vm.dump)
+ console.log("QuickJS:", ...nativeArgs)
+})
+// Partially implement `console` object
+const consoleHandle = vm.newObject()
+vm.setProp(consoleHandle, "log", logHandle)
+vm.setProp(vm.global, "console", consoleHandle)
+consoleHandle.dispose()
+logHandle.dispose()
+
+vm.unwrapResult(vm.evalCode(`console.log("Hello from QuickJS!")`)).dispose()
+```
+
+#### Promises
+
+To expose an asynchronous function that _returns a promise_ to callers within
+QuickJS, your function can return the handle of a `QuickJSDeferredPromise`
+created via `context.newPromise()`.
+
+When you resolve a `QuickJSDeferredPromise` -- and generally whenever async
+behavior completes for the VM -- pending listeners inside QuickJS may not
+execute immediately. Your code needs to explicitly call
+`runtime.executePendingJobs()` to resume execution inside QuickJS. This API
+gives your code maximum control to _schedule_ when QuickJS will block the host's
+event loop by resuming execution.
+
+To work with QuickJS handles that contain a promise inside the environment, you
+can convert the QuickJSHandle into a native promise using
+`context.resolvePromise()`. Take care with this API to avoid 'deadlocks' where
+the host awaits a guest promise, but the guest cannot make progress until the
+host calls `runtime.executePendingJobs()`. The simplest way to avoid this kind
+of deadlock is to always schedule `executePendingJobs` after any promise is
+settled.
+
+```typescript
+const vm = QuickJS.newContext()
+const fakeFileSystem = new Map([["example.txt", "Example file content"]])
+
+// Function that simulates reading data asynchronously
+const readFileHandle = vm.newFunction("readFile", (pathHandle) => {
+ const path = vm.getString(pathHandle)
+ const promise = vm.newPromise()
+ setTimeout(() => {
+ const content = fakeFileSystem.get(path)
+ promise.resolve(vm.newString(content || ""))
+ }, 100)
+ // IMPORTANT: Once you resolve an async action inside QuickJS,
+ // call runtime.executePendingJobs() to run any code that was
+ // waiting on the promise or callback.
+ promise.settled.then(vm.runtime.executePendingJobs)
+ return promise.handle
+})
+readFileHandle.consume((handle) => vm.setProp(vm.global, "readFile", handle))
+
+// Evaluate code that uses `readFile`, which returns a promise
+const result = vm.evalCode(`(async () => {
+ const content = await readFile('example.txt')
+ return content.toUpperCase()
+})()`)
+const promiseHandle = vm.unwrapResult(result)
+
+// Convert the promise handle into a native promise and await it.
+// If code like this deadlocks, make sure you are calling
+// runtime.executePendingJobs appropriately.
+const resolvedResult = await vm.resolvePromise(promiseHandle)
+promiseHandle.dispose()
+const resolvedHandle = vm.unwrapResult(resolvedResult)
+console.log("Result:", vm.getString(resolvedHandle))
+resolvedHandle.dispose()
+```
+
+#### Asyncify
+
+Sometimes, we want to create a function that's synchronous from the perspective
+of QuickJS, but prefer to implement that function _asynchronously_ in your host
+code. The most obvious use-case is for EcmaScript module loading. The underlying
+QuickJS C library expects the module loader function to return synchronously,
+but loading data synchronously in the browser or server is somewhere between "a
+bad idea" and "impossible". QuickJS also doesn't expose an API to "pause" the
+execution of a runtime, and adding such an API is tricky due to the VM's
+implementation.
+
+As a work-around, we provide an alternate build of QuickJS processed by
+Emscripten/Binaryen's [ASYNCIFY](https://emscripten.org/docs/porting/asyncify.html)
+compiler transform. Here's how Emscripten's documentation describes Asyncify:
+
+> Asyncify lets synchronous C or C++ code interact with asynchronous \[host] JavaScript. This allows things like:
+>
+> - A synchronous call in C that yields to the event loop, which allows browser events to be handled.
+>
+> - A synchronous call in C that waits for an asynchronous operation in \[host] JS to complete.
+>
+> Asyncify automatically transforms ... code into a form that can be paused and
+> resumed ..., so that it is asynchronous (hence the name “Asyncify”) even though
+> \[it is written] in a normal synchronous way.
+
+This means we can suspend an _entire WebAssembly module_ (which could contain
+multiple runtimes and contexts) while our host Javascript loads data
+asynchronously, and then resume execution once the data load completes. This is
+a very handy superpower, but it comes with a couple of major limitations:
+
+1. _An asyncified WebAssembly module can only suspend to wait for a single
+ asynchronous call at a time_. You may call back into a suspended WebAssembly
+ module eg. to create a QuickJS value to return a result, but the system will
+ crash if this call tries to suspend again. Take a look at Emscripten's documentation
+ on [reentrancy](https://emscripten.org/docs/porting/asyncify.html#reentrancy).
+
+2. _Asyncified code is bigger and runs slower_. The asyncified build of
+ Quickjs-emscripten library is 1M, 2x larger than the 500K of the default
+ version. There may be room for further
+ [optimization](https://emscripten.org/docs/porting/asyncify.html#optimizing)
+ Of our build in the future.
+
+To use asyncify features, use the following functions:
+
+- [newAsyncRuntime][]: create a runtime inside a new WebAssembly module.
+- [newAsyncContext][]: create runtime and context together inside a new
+ WebAssembly module.
+- [newQuickJSAsyncWASMModule][]: create an empty WebAssembly module.
+
+[newasyncruntime]: https://github.com/justjake/quickjs-emscripten/blob/main/doc/modules.md#newasyncruntime
+[newasynccontext]: https://github.com/justjake/quickjs-emscripten/blob/main/doc/modules.md#newasynccontext
+[newquickjsasyncwasmmodule]: https://github.com/justjake/quickjs-emscripten/blob/main/doc/modules.md#newquickjsasyncwasmmodule
+
+These functions are asynchronous because they always create a new underlying
+WebAssembly module so that each instance can suspend and resume independently,
+and instantiating a WebAssembly module is an async operation. This also adds
+substantial overhead compared to creating a runtime or context inside an
+existing module; if you only need to wait for a single async action at a time,
+you can create a single top-level module and create runtimes or contexts inside
+of it.
+
+##### Async module loader
+
+Here's an example of valuating a script that loads React asynchronously as an ES
+module. In our example, we're loading from the filesystem for reproducibility,
+but you can use this technique to load using `fetch`.
+
+```typescript
+const module = await newQuickJSAsyncWASMModule()
+const runtime = module.newRuntime()
+const path = await import("path")
+const { promises: fs } = await import("fs")
+
+const importsPath = path.join(__dirname, "../examples/imports") + "/"
+// Module loaders can return promises.
+// Execution will suspend until the promise resolves.
+runtime.setModuleLoader((moduleName) => {
+ const modulePath = path.join(importsPath, moduleName)
+ if (!modulePath.startsWith(importsPath)) {
+ throw new Error("out of bounds")
+ }
+ console.log("loading", moduleName, "from", modulePath)
+ return fs.readFile(modulePath, "utf-8")
+})
+
+// evalCodeAsync is required when execution may suspend.
+const context = runtime.newContext()
+const result = await context.evalCodeAsync(`
+import * as React from 'esm.sh/react@17'
+import * as ReactDOMServer from 'esm.sh/react-dom@17/server'
+const e = React.createElement
+globalThis.html = ReactDOMServer.renderToStaticMarkup(
+ e('div', null, e('strong', null, 'Hello world!'))
+)
+`)
+context.unwrapResult(result).dispose()
+const html = context.getProp(context.global, "html").consume(context.getString)
+console.log(html) // Hello world!
+```
+
+##### Async on host, sync in QuickJS
+
+Here's an example of turning an async function into a sync function inside the
+VM.
+
+```typescript
+const context = await newAsyncContext()
+const path = await import("path")
+const { promises: fs } = await import("fs")
+
+const importsPath = path.join(__dirname, "../examples/imports") + "/"
+const readFileHandle = context.newAsyncifiedFunction("readFile", async (pathHandle) => {
+ const pathString = path.join(importsPath, context.getString(pathHandle))
+ if (!pathString.startsWith(importsPath)) {
+ throw new Error("out of bounds")
+ }
+ const data = await fs.readFile(pathString, "utf-8")
+ return context.newString(data)
+})
+readFileHandle.consume((fn) => context.setProp(context.global, "readFile", fn))
+
+// evalCodeAsync is required when execution may suspend.
+const result = await context.evalCodeAsync(`
+// Not a promise! Sync! vvvvvvvvvvvvvvvvvvvv
+const data = JSON.parse(readFile('data.json'))
+data.map(x => x.toUpperCase()).join(' ')
+`)
+const upperCaseData = context.unwrapResult(result).consume(context.getString)
+console.log(upperCaseData) // 'VERY USEFUL DATA'
+```
+
+### Testing your code
+
+This library is complicated to use, so please consider automated testing your
+implementation. We highly writing your test suite to run with both the "release"
+build variant of quickjs-emscripten, and also the [DEBUG_SYNC] build variant.
+The debug sync build variant has extra instrumentation code for detecting memory
+leaks.
+
+The class [TestQuickJSWASMModule] exposes the memory leak detection API, although
+this API is only accurate when using `DEBUG_SYNC` variant.
+
+```typescript
+// Define your test suite in a function, so that you can test against
+// different module loaders.
+function myTests(moduleLoader: () => Promise) {
+ let QuickJS: TestQuickJSWASMModule
+ beforeEach(async () => {
+ // Get a unique TestQuickJSWASMModule instance for each test.
+ const wasmModule = await moduleLoader()
+ QuickJS = new TestQuickJSWASMModule(wasmModule)
+ })
+ afterEach(() => {
+ // Assert that the test disposed all handles. The DEBUG_SYNC build
+ // variant will show detailed traces for each leak.
+ QuickJS.assertNoMemoryAllocated()
+ })
+
+ it("works well", () => {
+ // TODO: write a test using QuickJS
+ const context = QuickJS.newContext()
+ context.unwrapResult(context.evalCode("1 + 1")).dispose()
+ context.dispose()
+ })
+}
+
+// Run the test suite against a matrix of module loaders.
+describe("Check for memory leaks with QuickJS DEBUG build", () => {
+ const moduleLoader = memoizePromiseFactory(() => newQuickJSWASMModule(DEBUG_SYNC))
+ myTests(moduleLoader)
+})
+
+describe("Realistic test with QuickJS RELEASE build", () => {
+ myTests(getQuickJS)
+})
+```
+
+For more testing examples, please explore the typescript source of [quickjs-emscripten][ts] repository.
+
+[ts]: https://github.com/justjake/quickjs-emscripten/blob/main/ts
+[debug_sync]: https://github.com/justjake/quickjs-emscripten/blob/main/doc/modules.md#debug_sync
+[testquickjswasmmodule]: https://github.com/justjake/quickjs-emscripten/blob/main/doc/classes/TestQuickJSWASMModule.md
+
+### Debugging
+
+- Switch to a DEBUG build variant of the WebAssembly module to see debug log messages from the C part of this library.
+- Set `process.env.QTS_DEBUG` to see debug log messages from the Javascript part of this library.
+
+### More Documentation
+
+[Github] | [NPM] | [API Documentation][api] | [Examples][tests]
+
+## Background
+
+This was inspired by seeing https://github.com/maple3142/duktape-eval
+[on Hacker News](https://news.ycombinator.com/item?id=21946565) and Figma's
+blogposts about using building a Javascript plugin runtime:
+
+- [How Figma built the Figma plugin system](https://www.figma.com/blog/how-we-built-the-figma-plugin-system/): Describes the LowLevelJavascriptVm interface.
+- [An update on plugin security](https://www.figma.com/blog/an-update-on-plugin-security/): Figma switches to QuickJS.
+
+## Status & Roadmap
+
+**Stability**: Because the version number of this project is below `1.0.0`,
+\*expect occasional breaking API changes.
+
+**Security**: This project makes every effort to be secure, but has not been
+audited. Please use with care in production settings.
+
+**Roadmap**: I work on this project in my free time, for fun. Here's I'm
+thinking comes next. Last updated 2022-03-18.
+
+1. Further work on module loading APIs:
+
+ - Create modules via Javascript, instead of source text.
+ - Scan source text for imports, for ahead of time or concurrent loading.
+ (This is possible with third-party tools, so lower priority.)
+
+2. Higher-level tools for reading QuickJS values:
+
+ - Type guard functions: `context.isArray(handle)`, `context.isPromise(handle)`, etc.
+ - Iteration utilities: `context.getIterable(handle)`, `context.iterateObjectEntries(handle)`.
+ This better supports user-level code to deserialize complex handle objects.
+
+3. Higher-level tools for creating QuickJS values:
+
+ - Devise a way to avoid needing to mess around with handles when setting up
+ the environment.
+ - Consider integrating
+ [quickjs-emscripten-sync](https://github.com/reearth/quickjs-emscripten-sync)
+ for automatic translation.
+ - Consider class-based or interface-type-based marshalling.
+
+4. EcmaScript Modules / WebAssembly files / Deno support. This requires me to
+ learn a lot of new things, but should be interesting for modern browser usage.
+
+5. SQLite integration.
+
+## Related
+
+- Duktape wrapped in Wasm: https://github.com/maple3142/duktape-eval/blob/main/src/Makefile
+- QuickJS wrapped in C++: https://github.com/ftk/quickjspp
+
+## Developing
+
+This library is implemented in two languages: C (compiled to WASM with
+Emscripten), and Typescript.
+
+### The C parts
+
+The ./c directory contains C code that wraps the QuickJS C library (in ./quickjs).
+Public functions (those starting with `QTS_`) in ./c/interface.c are
+automatically exported to native code (via a generated header) and to
+Typescript (via a generated FFI class). See ./generate.ts for how this works.
+
+The C code builds as both with `emscripten` (using `emcc`), to produce WASM (or
+ASM.js) and with `clang`. Build outputs are checked in, so you can iterate on
+the Javascript parts of the library without setting up the Emscripten toolchain.
+
+Intermediate object files from QuickJS end up in ./build/quickjs/.
+
+This project uses `emscripten 3.1.32`.
+
+- On ARM64, you should install `emscripten` on your machine. For example on macOS, `brew install emscripten`.
+- If _the correct version of emcc_ is not in your PATH, compilation falls back to using Docker.
+ On ARM64, this is 10-50x slower than native compilation, but it's just fine on x64.
+
+Related NPM scripts:
+
+- `yarn update-quickjs` will sync the ./quickjs folder with a
+ github repo tracking the upstream QuickJS.
+- `yarn make-debug` will rebuild C outputs into ./build/wrapper
+- `yarn make-release` will rebuild C outputs in release mode, which is the mode
+ that should be checked into the repo.
+
+### The Typescript parts
+
+The ./ts directory contains Typescript types and wraps the generated Emscripten
+FFI in a more usable interface.
+
+You'll need `node` and `yarn`. Install dependencies with `yarn install`.
+
+- `yarn build` produces ./dist.
+- `yarn test` runs the tests.
+- `yarn test --watch` watches for changes and re-runs the tests.
+
+### Yarn updates
+
+Just run `yarn set version from sources` to upgrade the Yarn release.
diff --git a/node_modules/@tootallnate/quickjs-emscripten/c/interface.c b/node_modules/@tootallnate/quickjs-emscripten/c/interface.c
new file mode 100644
index 0000000..0126cff
--- /dev/null
+++ b/node_modules/@tootallnate/quickjs-emscripten/c/interface.c
@@ -0,0 +1,819 @@
+/**
+ * interface.c
+ *
+ * We primarily use JSValue* (pointer to JSValue) when communicating with the
+ * host javascript environment, because pointers are trivial to use for calls
+ * into emscripten because they're just a number!
+ *
+ * As with the quickjs.h API, a JSValueConst* value is "borrowed" and should
+ * not be freed. A JSValue* is "owned" and should be freed by the owner.
+ *
+ * Functions starting with "QTS_" are exported by generate.ts to:
+ * - interface.h for native C code.
+ * - ffi.ts for emscripten.
+ *
+ * We support building the following build outputs:
+ *
+ * ## 1. Native machine code
+ * For internal development testing purposes.
+ *
+ * ## 2. WASM via Emscripten
+ * For general production use.
+ *
+ * ## 3. Experimental: Asyncified WASM via Emscripten with -s ASYNCIFY=1.
+ * This variant supports treating async host Javascript calls as synchronous
+ * from the perspective of the WASM c code.
+ *
+ * The way this works is described here:
+ * https://emscripten.org/docs/porting/asyncify.html
+ *
+ * In this variant, any call into our C code could return a promise if it ended
+ * up suspended. We mark the methods we suspect might suspend due to users' code
+ * as returning MaybeAsync(T). This information is ignored for the regular
+ * build.
+ */
+
+#ifdef __EMSCRIPTEN__
+#include
+#endif
+
+#include // For NAN
+#include
+#include
+#include
+#ifdef QTS_SANITIZE_LEAK
+#include
+#endif
+
+#include "../quickjs/cutils.h"
+#include "../quickjs/quickjs-libc.h"
+#include "../quickjs/quickjs.h"
+
+#define PKG "quickjs-emscripten: "
+
+#ifdef QTS_DEBUG_MODE
+#define QTS_DEBUG(msg) qts_log(msg);
+#define QTS_DUMP(value) qts_dump(ctx, value);
+#else
+#define QTS_DEBUG(msg) ;
+#define QTS_DUMP(value) ;
+#endif
+
+/**
+ * Signal to our FFI code generator that this string argument should be passed as a pointer
+ * allocated by the caller on the heap, not a JS string on the stack.
+ * https://github.com/emscripten-core/emscripten/issues/6860#issuecomment-405818401
+ */
+#define BorrowedHeapChar const char
+#define OwnedHeapChar char
+#define JSBorrowedChar const char
+
+/**
+ * Signal to our FFI code generator that this function should be called
+ * asynchronously when compiled with ASYNCIFY.
+ */
+#define MaybeAsync(T) T
+
+/**
+ * Signal to our FFI code generator that this function is only available in
+ * ASYNCIFY builds.
+ */
+#define AsyncifyOnly(T) T
+
+#define JSVoid void
+
+#define EvalFlags int
+#define EvalDetectModule int
+
+void qts_log(char *msg) {
+ fputs(PKG, stderr);
+ fputs(msg, stderr);
+ fputs("\n", stderr);
+}
+
+void qts_dump(JSContext *ctx, JSValueConst value) {
+ const char *str = JS_ToCString(ctx, value);
+ if (!str) {
+ QTS_DEBUG("QTS_DUMP: can't dump");
+ return;
+ }
+ fputs(str, stderr);
+ JS_FreeCString(ctx, str);
+ putchar('\n');
+}
+
+void copy_prop_if_needed(JSContext *ctx, JSValueConst dest, JSValueConst src, const char *prop_name) {
+ JSAtom prop_atom = JS_NewAtom(ctx, prop_name);
+ JSValue dest_prop = JS_GetProperty(ctx, dest, prop_atom);
+ if (JS_IsUndefined(dest_prop)) {
+ JSValue src_prop = JS_GetProperty(ctx, src, prop_atom);
+ if (!JS_IsUndefined(src_prop) && !JS_IsException(src_prop)) {
+ JS_SetProperty(ctx, dest, prop_atom, src_prop);
+ }
+ } else {
+ JS_FreeValue(ctx, dest_prop);
+ }
+ JS_FreeAtom(ctx, prop_atom);
+}
+
+JSValue *jsvalue_to_heap(JSValueConst value) {
+ JSValue *result = malloc(sizeof(JSValue));
+ if (result) {
+ // Could be better optimized, but at -0z / -ftlo, it
+ // appears to produce the same binary code as a memcpy.
+ *result = value;
+ }
+ return result;
+}
+
+JSValue *QTS_Throw(JSContext *ctx, JSValueConst *error) {
+ JSValue copy = JS_DupValue(ctx, *error);
+ return jsvalue_to_heap(JS_Throw(ctx, copy));
+}
+
+JSValue *QTS_NewError(JSContext *ctx) {
+ return jsvalue_to_heap(JS_NewError(ctx));
+}
+
+/**
+ * Limits.
+ */
+
+/**
+ * Memory limit. Set to -1 to disable.
+ */
+void QTS_RuntimeSetMemoryLimit(JSRuntime *rt, size_t limit) {
+ JS_SetMemoryLimit(rt, limit);
+}
+
+/**
+ * Memory diagnostics
+ */
+
+JSValue *QTS_RuntimeComputeMemoryUsage(JSRuntime *rt, JSContext *ctx) {
+ JSMemoryUsage s;
+ JS_ComputeMemoryUsage(rt, &s);
+
+ // Note that we're going to allocate more memory just to report the memory usage.
+ // A more sound approach would be to bind JSMemoryUsage struct directly - but that's
+ // a lot of work. This should be okay in the mean time.
+ JSValue result = JS_NewObject(ctx);
+
+ // Manually generated via editor-fu from JSMemoryUsage struct definition in quickjs.h
+ JS_SetPropertyStr(ctx, result, "malloc_limit", JS_NewInt64(ctx, s.malloc_limit));
+ JS_SetPropertyStr(ctx, result, "memory_used_size", JS_NewInt64(ctx, s.memory_used_size));
+ JS_SetPropertyStr(ctx, result, "malloc_count", JS_NewInt64(ctx, s.malloc_count));
+ JS_SetPropertyStr(ctx, result, "memory_used_count", JS_NewInt64(ctx, s.memory_used_count));
+ JS_SetPropertyStr(ctx, result, "atom_count", JS_NewInt64(ctx, s.atom_count));
+ JS_SetPropertyStr(ctx, result, "atom_size", JS_NewInt64(ctx, s.atom_size));
+ JS_SetPropertyStr(ctx, result, "str_count", JS_NewInt64(ctx, s.str_count));
+ JS_SetPropertyStr(ctx, result, "str_size", JS_NewInt64(ctx, s.str_size));
+ JS_SetPropertyStr(ctx, result, "obj_count", JS_NewInt64(ctx, s.obj_count));
+ JS_SetPropertyStr(ctx, result, "obj_size", JS_NewInt64(ctx, s.obj_size));
+ JS_SetPropertyStr(ctx, result, "prop_count", JS_NewInt64(ctx, s.prop_count));
+ JS_SetPropertyStr(ctx, result, "prop_size", JS_NewInt64(ctx, s.prop_size));
+ JS_SetPropertyStr(ctx, result, "shape_count", JS_NewInt64(ctx, s.shape_count));
+ JS_SetPropertyStr(ctx, result, "shape_size", JS_NewInt64(ctx, s.shape_size));
+ JS_SetPropertyStr(ctx, result, "js_func_count", JS_NewInt64(ctx, s.js_func_count));
+ JS_SetPropertyStr(ctx, result, "js_func_size", JS_NewInt64(ctx, s.js_func_size));
+ JS_SetPropertyStr(ctx, result, "js_func_code_size", JS_NewInt64(ctx, s.js_func_code_size));
+ JS_SetPropertyStr(ctx, result, "js_func_pc2line_count", JS_NewInt64(ctx, s.js_func_pc2line_count));
+ JS_SetPropertyStr(ctx, result, "js_func_pc2line_size", JS_NewInt64(ctx, s.js_func_pc2line_size));
+ JS_SetPropertyStr(ctx, result, "c_func_count", JS_NewInt64(ctx, s.c_func_count));
+ JS_SetPropertyStr(ctx, result, "array_count", JS_NewInt64(ctx, s.array_count));
+ JS_SetPropertyStr(ctx, result, "fast_array_count", JS_NewInt64(ctx, s.fast_array_count));
+ JS_SetPropertyStr(ctx, result, "fast_array_elements", JS_NewInt64(ctx, s.fast_array_elements));
+ JS_SetPropertyStr(ctx, result, "binary_object_count", JS_NewInt64(ctx, s.binary_object_count));
+ JS_SetPropertyStr(ctx, result, "binary_object_size", JS_NewInt64(ctx, s.binary_object_size));
+
+ return jsvalue_to_heap(result);
+}
+
+OwnedHeapChar *QTS_RuntimeDumpMemoryUsage(JSRuntime *rt) {
+ char *result = malloc(sizeof(char) * 1024);
+ FILE *memfile = fmemopen(result, 1024, "w");
+ JSMemoryUsage s;
+ JS_ComputeMemoryUsage(rt, &s);
+ JS_DumpMemoryUsage(memfile, &s, rt);
+ fclose(memfile);
+ return result;
+}
+
+int QTS_RecoverableLeakCheck() {
+#ifdef QTS_SANITIZE_LEAK
+ return __lsan_do_recoverable_leak_check();
+#else
+ return 0;
+#endif
+}
+
+int QTS_BuildIsSanitizeLeak() {
+#ifdef QTS_SANITIZE_LEAK
+ return 1;
+#else
+ return 0;
+#endif
+}
+
+#ifdef QTS_ASYNCIFY
+EM_JS(void, set_asyncify_stack_size, (size_t size), {
+ Asyncify.StackSize = size || 81920;
+});
+#endif
+
+/**
+ * Set the stack size limit, in bytes. Set to 0 to disable.
+ */
+void QTS_RuntimeSetMaxStackSize(JSRuntime *rt, size_t stack_size) {
+#ifdef QTS_ASYNCIFY
+ set_asyncify_stack_size(stack_size);
+#endif
+ JS_SetMaxStackSize(rt, stack_size);
+}
+
+/**
+ * Constant pointers. Because we always use JSValue* from the host Javascript environment,
+ * we need helper fuctions to return pointers to these constants.
+ */
+
+JSValueConst QTS_Undefined = JS_UNDEFINED;
+JSValueConst *QTS_GetUndefined() {
+ return &QTS_Undefined;
+}
+
+JSValueConst QTS_Null = JS_NULL;
+JSValueConst *QTS_GetNull() {
+ return &QTS_Null;
+}
+
+JSValueConst QTS_False = JS_FALSE;
+JSValueConst *QTS_GetFalse() {
+ return &QTS_False;
+}
+
+JSValueConst QTS_True = JS_TRUE;
+JSValueConst *QTS_GetTrue() {
+ return &QTS_True;
+}
+
+/**
+ * Standard FFI functions
+ */
+
+JSRuntime *QTS_NewRuntime() {
+ return JS_NewRuntime();
+}
+
+void QTS_FreeRuntime(JSRuntime *rt) {
+ JS_FreeRuntime(rt);
+}
+
+JSContext *QTS_NewContext(JSRuntime *rt) {
+ return JS_NewContext(rt);
+}
+
+void QTS_FreeContext(JSContext *ctx) {
+ JS_FreeContext(ctx);
+}
+
+void QTS_FreeValuePointer(JSContext *ctx, JSValue *value) {
+ JS_FreeValue(ctx, *value);
+ free(value);
+}
+
+void QTS_FreeValuePointerRuntime(JSRuntime *rt, JSValue *value) {
+ JS_FreeValueRT(rt, *value);
+ free(value);
+}
+
+void QTS_FreeVoidPointer(JSContext *ctx, JSVoid *ptr) {
+ js_free(ctx, ptr);
+}
+
+void QTS_FreeCString(JSContext *ctx, JSBorrowedChar *str) {
+ JS_FreeCString(ctx, str);
+}
+
+JSValue *QTS_DupValuePointer(JSContext *ctx, JSValueConst *val) {
+ return jsvalue_to_heap(JS_DupValue(ctx, *val));
+}
+
+JSValue *QTS_NewObject(JSContext *ctx) {
+ return jsvalue_to_heap(JS_NewObject(ctx));
+}
+
+JSValue *QTS_NewObjectProto(JSContext *ctx, JSValueConst *proto) {
+ return jsvalue_to_heap(JS_NewObjectProto(ctx, *proto));
+}
+
+JSValue *QTS_NewArray(JSContext *ctx) {
+ return jsvalue_to_heap(JS_NewArray(ctx));
+}
+
+JSValue *QTS_NewFloat64(JSContext *ctx, double num) {
+ return jsvalue_to_heap(JS_NewFloat64(ctx, num));
+}
+
+double QTS_GetFloat64(JSContext *ctx, JSValueConst *value) {
+ double result = NAN;
+ JS_ToFloat64(ctx, &result, *value);
+ return result;
+}
+
+JSValue *QTS_NewString(JSContext *ctx, BorrowedHeapChar *string) {
+ return jsvalue_to_heap(JS_NewString(ctx, string));
+}
+
+JSBorrowedChar *QTS_GetString(JSContext *ctx, JSValueConst *value) {
+ return JS_ToCString(ctx, *value);
+}
+
+JSValue qts_get_symbol_key(JSContext *ctx, JSValueConst *value) {
+ JSValue global = JS_GetGlobalObject(ctx);
+ JSValue Symbol = JS_GetPropertyStr(ctx, global, "Symbol");
+ JS_FreeValue(ctx, global);
+
+ JSValue Symbol_keyFor = JS_GetPropertyStr(ctx, Symbol, "keyFor");
+ JSValue key = JS_Call(ctx, Symbol_keyFor, Symbol, 1, value);
+ JS_FreeValue(ctx, Symbol_keyFor);
+ JS_FreeValue(ctx, Symbol);
+ return key;
+}
+
+JSValue *QTS_NewSymbol(JSContext *ctx, BorrowedHeapChar *description, int isGlobal) {
+ JSValue global = JS_GetGlobalObject(ctx);
+ JSValue Symbol = JS_GetPropertyStr(ctx, global, "Symbol");
+ JS_FreeValue(ctx, global);
+ JSValue descriptionValue = JS_NewString(ctx, description);
+ JSValue symbol;
+
+ if (isGlobal != 0) {
+ JSValue Symbol_for = JS_GetPropertyStr(ctx, Symbol, "for");
+ symbol = JS_Call(ctx, Symbol_for, Symbol, 1, &descriptionValue);
+ JS_FreeValue(ctx, descriptionValue);
+ JS_FreeValue(ctx, Symbol_for);
+ JS_FreeValue(ctx, Symbol);
+ return jsvalue_to_heap(symbol);
+ }
+
+ symbol = JS_Call(ctx, Symbol, JS_UNDEFINED, 1, &descriptionValue);
+ JS_FreeValue(ctx, descriptionValue);
+ JS_FreeValue(ctx, Symbol);
+
+ return jsvalue_to_heap(symbol);
+}
+
+MaybeAsync(JSBorrowedChar *) QTS_GetSymbolDescriptionOrKey(JSContext *ctx, JSValueConst *value) {
+ JSBorrowedChar *result;
+
+ JSValue key = qts_get_symbol_key(ctx, value);
+ if (!JS_IsUndefined(key)) {
+ result = JS_ToCString(ctx, key);
+ JS_FreeValue(ctx, key);
+ return result;
+ }
+
+ JSValue description = JS_GetPropertyStr(ctx, *value, "description");
+ result = JS_ToCString(ctx, description);
+ JS_FreeValue(ctx, description);
+ return result;
+}
+
+int QTS_IsGlobalSymbol(JSContext *ctx, JSValueConst *value) {
+ JSValue key = qts_get_symbol_key(ctx, value);
+ int undefined = JS_IsUndefined(key);
+ JS_FreeValue(ctx, key);
+
+ if (undefined) {
+ return 0;
+ } else {
+ return 1;
+ }
+}
+
+int QTS_IsJobPending(JSRuntime *rt) {
+ return JS_IsJobPending(rt);
+}
+
+/*
+ runs pending jobs (Promises/async functions) until it encounters
+ an exception or it executed the passed maxJobsToExecute jobs.
+
+ Passing a negative value will run the loop until there are no more
+ pending jobs or an exception happened
+
+ Returns the executed number of jobs or the exception encountered
+*/
+MaybeAsync(JSValue *) QTS_ExecutePendingJob(JSRuntime *rt, int maxJobsToExecute, JSContext **lastJobContext) {
+ JSContext *pctx;
+ int status = 1;
+ int executed = 0;
+ while (executed != maxJobsToExecute && status == 1) {
+ status = JS_ExecutePendingJob(rt, &pctx);
+ if (status == -1) {
+ *lastJobContext = pctx;
+ return jsvalue_to_heap(JS_GetException(pctx));
+ } else if (status == 1) {
+ *lastJobContext = pctx;
+ executed++;
+ }
+ }
+#ifdef QTS_DEBUG_MODE
+ char msg[500];
+ sprintf(msg, "QTS_ExecutePendingJob(executed: %d, pctx: %p, lastJobExecuted: %p)", executed, pctx, *lastJobContext);
+ QTS_DEBUG(msg)
+#endif
+ return jsvalue_to_heap(JS_NewFloat64(pctx, executed));
+}
+
+MaybeAsync(JSValue *) QTS_GetProp(JSContext *ctx, JSValueConst *this_val, JSValueConst *prop_name) {
+ JSAtom prop_atom = JS_ValueToAtom(ctx, *prop_name);
+ JSValue prop_val = JS_GetProperty(ctx, *this_val, prop_atom);
+ JS_FreeAtom(ctx, prop_atom);
+ return jsvalue_to_heap(prop_val);
+}
+
+MaybeAsync(void) QTS_SetProp(JSContext *ctx, JSValueConst *this_val, JSValueConst *prop_name, JSValueConst *prop_value) {
+ JSAtom prop_atom = JS_ValueToAtom(ctx, *prop_name);
+ JSValue extra_prop_value = JS_DupValue(ctx, *prop_value);
+ // TODO: should we use DefineProperty internally if this object doesn't have the property yet?
+ JS_SetProperty(ctx, *this_val, prop_atom, extra_prop_value); // consumes extra_prop_value
+ JS_FreeAtom(ctx, prop_atom);
+}
+
+void QTS_DefineProp(JSContext *ctx, JSValueConst *this_val, JSValueConst *prop_name, JSValueConst *prop_value, JSValueConst *get, JSValueConst *set, bool configurable, bool enumerable, bool has_value) {
+ JSAtom prop_atom = JS_ValueToAtom(ctx, *prop_name);
+
+ int flags = 0;
+ if (configurable) {
+ flags = flags | JS_PROP_CONFIGURABLE;
+ if (has_value) {
+ flags = flags | JS_PROP_HAS_CONFIGURABLE;
+ }
+ }
+ if (enumerable) {
+ flags = flags | JS_PROP_ENUMERABLE;
+ if (has_value) {
+ flags = flags | JS_PROP_HAS_ENUMERABLE;
+ }
+ }
+ if (!JS_IsUndefined(*get)) {
+ flags = flags | JS_PROP_HAS_GET;
+ }
+ if (!JS_IsUndefined(*set)) {
+ flags = flags | JS_PROP_HAS_SET;
+ }
+ if (has_value) {
+ flags = flags | JS_PROP_HAS_VALUE;
+ }
+
+ JS_DefineProperty(ctx, *this_val, prop_atom, *prop_value, *get, *set, flags);
+ JS_FreeAtom(ctx, prop_atom);
+}
+
+MaybeAsync(JSValue *) QTS_Call(JSContext *ctx, JSValueConst *func_obj, JSValueConst *this_obj, int argc, JSValueConst **argv_ptrs) {
+ // convert array of pointers to array of values
+ JSValueConst argv[argc];
+ int i;
+ for (i = 0; i < argc; i++) {
+ argv[i] = *(argv_ptrs[i]);
+ }
+
+ return jsvalue_to_heap(JS_Call(ctx, *func_obj, *this_obj, argc, argv));
+}
+
+/**
+ * If maybe_exception is an exception, get the error.
+ * Otherwise, return NULL.
+ */
+JSValue *QTS_ResolveException(JSContext *ctx, JSValue *maybe_exception) {
+ if (JS_IsException(*maybe_exception)) {
+ return jsvalue_to_heap(JS_GetException(ctx));
+ }
+
+ return NULL;
+}
+
+MaybeAsync(JSBorrowedChar *) QTS_Dump(JSContext *ctx, JSValueConst *obj) {
+ JSValue obj_json_value = JS_JSONStringify(ctx, *obj, JS_UNDEFINED, JS_UNDEFINED);
+ if (!JS_IsException(obj_json_value)) {
+ const char *obj_json_chars = JS_ToCString(ctx, obj_json_value);
+ JS_FreeValue(ctx, obj_json_value);
+ if (obj_json_chars != NULL) {
+ JSValue enumerable_props = JS_ParseJSON(ctx, obj_json_chars, strlen(obj_json_chars), "");
+ JS_FreeCString(ctx, obj_json_chars);
+ if (!JS_IsException(enumerable_props)) {
+ // Copy common non-enumerable props for different object types.
+ // Errors:
+ copy_prop_if_needed(ctx, enumerable_props, *obj, "name");
+ copy_prop_if_needed(ctx, enumerable_props, *obj, "message");
+ copy_prop_if_needed(ctx, enumerable_props, *obj, "stack");
+
+ // Serialize again.
+ JSValue enumerable_json = JS_JSONStringify(ctx, enumerable_props, JS_UNDEFINED, JS_UNDEFINED);
+ JS_FreeValue(ctx, enumerable_props);
+
+ JSBorrowedChar *result = QTS_GetString(ctx, &enumerable_json);
+ JS_FreeValue(ctx, enumerable_json);
+ return result;
+ }
+ }
+ }
+
+#ifdef QTS_DEBUG_MODE
+ qts_log("Error dumping JSON:");
+ js_std_dump_error(ctx);
+#endif
+
+ // Fallback: convert to string
+ return QTS_GetString(ctx, obj);
+}
+
+MaybeAsync(JSValue *) QTS_Eval(JSContext *ctx, BorrowedHeapChar *js_code, const char *filename, EvalDetectModule detectModule, EvalFlags evalFlags) {
+ size_t js_code_len = strlen(js_code);
+
+ if (detectModule) {
+ if (JS_DetectModule((const char *)js_code, js_code_len)) {
+ QTS_DEBUG("QTS_Eval: Detected module = true");
+ evalFlags |= JS_EVAL_TYPE_MODULE;
+ } else {
+ QTS_DEBUG("QTS_Eval: Detected module = false");
+ }
+ } else {
+ QTS_DEBUG("QTS_Eval: do not detect module");
+ }
+
+ return jsvalue_to_heap(JS_Eval(ctx, js_code, strlen(js_code), filename, evalFlags));
+}
+
+OwnedHeapChar *QTS_Typeof(JSContext *ctx, JSValueConst *value) {
+ const char *result = "unknown";
+ uint32_t tag = JS_VALUE_GET_TAG(*value);
+
+ if (JS_IsNumber(*value)) {
+ result = "number";
+ } else if (JS_IsBigInt(ctx, *value)) {
+ result = "bigint";
+ } else if (JS_IsBigFloat(*value)) {
+ result = "bigfloat";
+ } else if (JS_IsBigDecimal(*value)) {
+ result = "bigdecimal";
+ } else if (JS_IsFunction(ctx, *value)) {
+ result = "function";
+ } else if (JS_IsBool(*value)) {
+ result = "boolean";
+ } else if (JS_IsNull(*value)) {
+ result = "object";
+ } else if (JS_IsUndefined(*value)) {
+ result = "undefined";
+ } else if (JS_IsUninitialized(*value)) {
+ result = "undefined";
+ } else if (JS_IsString(*value)) {
+ result = "string";
+ } else if (JS_IsSymbol(*value)) {
+ result = "symbol";
+ } else if (JS_IsObject(*value)) {
+ result = "object";
+ }
+
+ char *out = strdup(result);
+ return out;
+}
+
+JSValue *QTS_GetGlobalObject(JSContext *ctx) {
+ return jsvalue_to_heap(JS_GetGlobalObject(ctx));
+}
+
+JSValue *QTS_NewPromiseCapability(JSContext *ctx, JSValue **resolve_funcs_out) {
+ JSValue resolve_funcs[2];
+ JSValue promise = JS_NewPromiseCapability(ctx, resolve_funcs);
+ resolve_funcs_out[0] = jsvalue_to_heap(resolve_funcs[0]);
+ resolve_funcs_out[1] = jsvalue_to_heap(resolve_funcs[1]);
+ return jsvalue_to_heap(promise);
+}
+
+void QTS_TestStringArg(const char *string) {
+ // pass
+}
+
+int QTS_BuildIsDebug() {
+#ifdef QTS_DEBUG_MODE
+ return 1;
+#else
+ return 0;
+#endif
+}
+
+int QTS_BuildIsAsyncify() {
+#ifdef QTS_ASYNCIFY
+ return 1;
+#else
+ return 0;
+#endif
+}
+
+// ----------------------------------------------------------------------------
+// Module loading helpers
+
+// ----------------------------------------------------------------------------
+// C -> Host Callbacks
+// Note: inside EM_JS, we need to use ['...'] subscript syntax for accessing JS
+// objects, because in optimized builds, Closure compiler will mangle all the
+// names.
+
+// -------------------
+// function: C -> Host
+#ifdef __EMSCRIPTEN__
+EM_JS(MaybeAsync(JSValue *), qts_host_call_function, (JSContext * ctx, JSValueConst *this_ptr, int argc, JSValueConst *argv, uint32_t magic_func_id), {
+#ifdef QTS_ASYNCIFY
+ const asyncify = {['handleSleep'] : Asyncify.handleSleep};
+#else
+ const asyncify = undefined;
+#endif
+ return Module['callbacks']['callFunction'](asyncify, ctx, this_ptr, argc, argv, magic_func_id);
+});
+#endif
+
+// Function: QuickJS -> C
+JSValue qts_call_function(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv, int magic) {
+ JSValue *result_ptr = qts_host_call_function(ctx, &this_val, argc, argv, magic);
+ if (result_ptr == NULL) {
+ return JS_UNDEFINED;
+ }
+ JSValue result = *result_ptr;
+ free(result_ptr);
+ return result;
+}
+
+// Function: Host -> QuickJS
+JSValue *QTS_NewFunction(JSContext *ctx, uint32_t func_id, const char *name) {
+#ifdef QTS_DEBUG_MODE
+ char msg[500];
+ sprintf(msg, "new_function(name: %s, magic: %d)", name, func_id);
+ QTS_DEBUG(msg)
+#endif
+ JSValue func_obj = JS_NewCFunctionMagic(
+ /* context */ ctx,
+ /* JSCFunctionMagic* */ &qts_call_function,
+ /* name */ name,
+ /* min argc */ 0,
+ /* function type */ JS_CFUNC_generic_magic,
+ /* magic: fn id */ func_id);
+ return jsvalue_to_heap(func_obj);
+}
+
+JSValueConst *QTS_ArgvGetJSValueConstPointer(JSValueConst *argv, int index) {
+ return &argv[index];
+}
+
+// --------------------
+// interrupt: C -> Host
+#ifdef __EMSCRIPTEN__
+EM_JS(int, qts_host_interrupt_handler, (JSRuntime * rt), {
+ // Async not supported here.
+ // #ifdef QTS_ASYNCIFY
+ // const asyncify = Asyncify;
+ // #else
+ const asyncify = undefined;
+ // #endif
+ return Module['callbacks']['shouldInterrupt'](asyncify, rt);
+});
+#endif
+
+// interrupt: QuickJS -> C
+int qts_interrupt_handler(JSRuntime *rt, void *_unused) {
+ return qts_host_interrupt_handler(rt);
+}
+
+// interrupt: Host -> QuickJS
+void QTS_RuntimeEnableInterruptHandler(JSRuntime *rt) {
+ JS_SetInterruptHandler(rt, &qts_interrupt_handler, NULL);
+}
+
+void QTS_RuntimeDisableInterruptHandler(JSRuntime *rt) {
+ JS_SetInterruptHandler(rt, NULL, NULL);
+}
+
+// --------------------
+// load module: C -> Host
+// TODO: a future version can support host returning JSModuleDef* directly;
+// for now we only support loading module source code.
+
+/*
+The module loading model under ASYNCIFY is convoluted. We need to make sure we
+never have an async request running concurrently for loading modules.
+
+The first implemenation looked like this:
+
+C HOST SUSPENDED
+qts_host_load_module(name) ------> false
+ call rt.loadModule(name) false
+ Start async load module false
+ Suspend C true
+ Async load complete true
+ < --------------- QTS_CompileModule(source) true
+QTS_Eval(source, COMPILE_ONLY) true
+Loaded module has import true
+qts_host_load_module(dep) -------> true
+ call rt.loadModule(dep) true
+ Start async load module true
+ ALREADY SUSPENDED, CRASH
+
+We can solve this in two different ways:
+
+1. Return to C as soon as we async load the module source.
+ That way, we unsuspend before calling QTS_CompileModule.
+2. Once we load the module, use a new API to detect and async
+ load the module's downstream dependencies. This way
+ they're loaded synchronously so we don't need to suspend "again".
+
+Probably we could optimize (2) to make it more performant, eg with parallel
+loading, but (1) seems much easier to implement in the sort run.
+*/
+
+JSModuleDef *qts_compile_module(JSContext *ctx, const char *module_name, BorrowedHeapChar *module_body) {
+#ifdef QTS_DEBUG_MODE
+ char msg[500];
+ sprintf(msg, "QTS_CompileModule(ctx: %p, name: %s, bodyLength: %lu)", ctx, module_name, strlen(module_body));
+ QTS_DEBUG(msg)
+#endif
+ JSValue func_val = JS_Eval(ctx, module_body, strlen(module_body), module_name, JS_EVAL_TYPE_MODULE | JS_EVAL_FLAG_COMPILE_ONLY);
+ if (JS_IsException(func_val)) {
+ return NULL;
+ }
+ // TODO: Is exception ok?
+ // TODO: set import.meta?
+ JSModuleDef *module = JS_VALUE_GET_PTR(func_val);
+ JS_FreeValue(ctx, func_val);
+ return module;
+}
+
+#ifdef __EMSCRIPTEN__
+EM_JS(MaybeAsync(char *), qts_host_load_module_source, (JSRuntime * rt, JSContext *ctx, const char *module_name), {
+#ifdef QTS_ASYNCIFY
+ const asyncify = {['handleSleep'] : Asyncify.handleSleep};
+#else
+ const asyncify = undefined;
+#endif
+ // https://emscripten.org/docs/api_reference/preamble.js.html#UTF8ToString
+ const moduleNameString = UTF8ToString(module_name);
+ return Module['callbacks']['loadModuleSource'](asyncify, rt, ctx, moduleNameString);
+});
+
+EM_JS(MaybeAsync(char *), qts_host_normalize_module, (JSRuntime * rt, JSContext *ctx, const char *module_base_name, const char *module_name), {
+#ifdef QTS_ASYNCIFY
+ const asyncify = {['handleSleep'] : Asyncify.handleSleep};
+#else
+ const asyncify = undefined;
+#endif
+ // https://emscripten.org/docs/api_reference/preamble.js.html#UTF8ToString
+ const moduleBaseNameString = UTF8ToString(module_base_name);
+ const moduleNameString = UTF8ToString(module_name);
+ return Module['callbacks']['normalizeModule'](asyncify, rt, ctx, moduleBaseNameString, moduleNameString);
+});
+#endif
+
+// load module: QuickJS -> C
+// See js_module_loader in quickjs/quickjs-libc.c:567
+JSModuleDef *qts_load_module(JSContext *ctx, const char *module_name, void *_unused) {
+ JSRuntime *rt = JS_GetRuntime(ctx);
+#ifdef QTS_DEBUG_MODE
+ char msg[500];
+ sprintf(msg, "qts_load_module(rt: %p, ctx: %p, name: %s)", rt, ctx, module_name);
+ QTS_DEBUG(msg)
+#endif
+ char *module_source = qts_host_load_module_source(rt, ctx, module_name);
+ if (module_source == NULL) {
+ return NULL;
+ }
+
+ JSModuleDef *module = qts_compile_module(ctx, module_name, module_source);
+ free(module_source);
+ return module;
+}
+
+char *qts_normalize_module(JSContext *ctx, const char *module_base_name, const char *module_name, void *_unused) {
+ JSRuntime *rt = JS_GetRuntime(ctx);
+#ifdef QTS_DEBUG_MODE
+ char msg[500];
+ sprintf(msg, "qts_normalize_module(rt: %p, ctx: %p, base_name: %s, name: %s)", rt, ctx, module_base_name, module_name);
+ QTS_DEBUG(msg)
+#endif
+ char *em_module_name = qts_host_normalize_module(rt, ctx, module_base_name, module_name);
+ char *js_module_name = js_strdup(ctx, em_module_name);
+ free(em_module_name);
+ return js_module_name;
+}
+
+// Load module: Host -> QuickJS
+void QTS_RuntimeEnableModuleLoader(JSRuntime *rt, int use_custom_normalize) {
+ JSModuleNormalizeFunc *module_normalize = NULL; /* use default name normalizer */
+ if (use_custom_normalize) {
+ module_normalize = &qts_normalize_module;
+ }
+ JS_SetModuleLoaderFunc(rt, module_normalize, &qts_load_module, NULL);
+}
+
+void QTS_RuntimeDisableModuleLoader(JSRuntime *rt) {
+ JS_SetModuleLoaderFunc(rt, NULL, NULL, NULL);
+}
\ No newline at end of file
diff --git a/node_modules/@tootallnate/quickjs-emscripten/dist/asyncify-helpers.d.ts b/node_modules/@tootallnate/quickjs-emscripten/dist/asyncify-helpers.d.ts
new file mode 100644
index 0000000..f3bb599
--- /dev/null
+++ b/node_modules/@tootallnate/quickjs-emscripten/dist/asyncify-helpers.d.ts
@@ -0,0 +1,24 @@
+declare function awaitYield(value: T | Promise): Generator, T, T>;
+declare function awaitYieldOf(generator: Generator, T, Yielded>): Generator, T, T>;
+export type AwaitYield = typeof awaitYield & {
+ of: typeof awaitYieldOf;
+};
+/**
+ * Create a function that may or may not be async, using a generator
+ *
+ * Within the generator, call `yield* awaited(maybePromise)` to await a value
+ * that may or may not be a promise.
+ *
+ * If the inner function never yields a promise, it will return synchronously.
+ */
+export declare function maybeAsyncFn<
+/** Function arguments */
+Args extends any[], This,
+/** Function return type */
+Return,
+/** Yields to unwrap */
+Yielded>(that: This, fn: (this: This, awaited: AwaitYield, ...args: Args) => Generator, Return, Yielded>): (...args: Args) => Return | Promise;
+export type MaybeAsyncBlock = (this: This, awaited: AwaitYield, ...args: Args) => Generator, Return, Yielded>;
+export declare function maybeAsync(that: This, startGenerator: (this: This, await: AwaitYield) => Generator, Return, Yielded>): Return | Promise;
+export declare function awaitEachYieldedPromise(gen: Generator, Returned, Yielded>): Returned | Promise;
+export {};
diff --git a/node_modules/@tootallnate/quickjs-emscripten/dist/asyncify-helpers.js b/node_modules/@tootallnate/quickjs-emscripten/dist/asyncify-helpers.js
new file mode 100644
index 0000000..c140dde
--- /dev/null
+++ b/node_modules/@tootallnate/quickjs-emscripten/dist/asyncify-helpers.js
@@ -0,0 +1,53 @@
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.awaitEachYieldedPromise = exports.maybeAsync = exports.maybeAsyncFn = void 0;
+function* awaitYield(value) {
+ return (yield value);
+}
+function awaitYieldOf(generator) {
+ return awaitYield(awaitEachYieldedPromise(generator));
+}
+const AwaitYield = awaitYield;
+AwaitYield.of = awaitYieldOf;
+/**
+ * Create a function that may or may not be async, using a generator
+ *
+ * Within the generator, call `yield* awaited(maybePromise)` to await a value
+ * that may or may not be a promise.
+ *
+ * If the inner function never yields a promise, it will return synchronously.
+ */
+function maybeAsyncFn(that, fn) {
+ return (...args) => {
+ const generator = fn.call(that, AwaitYield, ...args);
+ return awaitEachYieldedPromise(generator);
+ };
+}
+exports.maybeAsyncFn = maybeAsyncFn;
+class Example {
+ constructor() {
+ this.maybeAsyncMethod = maybeAsyncFn(this, function* (awaited, a) {
+ yield* awaited(new Promise((resolve) => setTimeout(resolve, a)));
+ return 5;
+ });
+ }
+}
+function maybeAsync(that, startGenerator) {
+ const generator = startGenerator.call(that, AwaitYield);
+ return awaitEachYieldedPromise(generator);
+}
+exports.maybeAsync = maybeAsync;
+function awaitEachYieldedPromise(gen) {
+ function handleNextStep(step) {
+ if (step.done) {
+ return step.value;
+ }
+ if (step.value instanceof Promise) {
+ return step.value.then((value) => handleNextStep(gen.next(value)), (error) => handleNextStep(gen.throw(error)));
+ }
+ return handleNextStep(gen.next(step.value));
+ }
+ return handleNextStep(gen.next());
+}
+exports.awaitEachYieldedPromise = awaitEachYieldedPromise;
+//# sourceMappingURL=asyncify-helpers.js.map
\ No newline at end of file
diff --git a/node_modules/@tootallnate/quickjs-emscripten/dist/asyncify-helpers.js.map b/node_modules/@tootallnate/quickjs-emscripten/dist/asyncify-helpers.js.map
new file mode 100644
index 0000000..10dcc46
--- /dev/null
+++ b/node_modules/@tootallnate/quickjs-emscripten/dist/asyncify-helpers.js.map
@@ -0,0 +1 @@
+{"version":3,"file":"asyncify-helpers.js","sourceRoot":"","sources":["../ts/asyncify-helpers.ts"],"names":[],"mappings":";;;AAAA,QAAQ,CAAC,CAAC,UAAU,CAAI,KAAqB;IAC3C,OAAO,CAAC,MAAM,KAAK,CAAM,CAAA;AAC3B,CAAC;AAED,SAAS,YAAY,CACnB,SAA4D;IAE5D,OAAO,UAAU,CAAC,uBAAuB,CAAC,SAAS,CAAC,CAAC,CAAA;AACvD,CAAC;AAMD,MAAM,UAAU,GAAe,UAAwB,CAAA;AACvD,UAAU,CAAC,EAAE,GAAG,YAAY,CAAA;AAE5B;;;;;;;GAOG;AACH,SAAgB,YAAY,CAS1B,IAAU,EACV,EAI2D;IAE3D,OAAO,CAAC,GAAG,IAAU,EAAE,EAAE;QACvB,MAAM,SAAS,GAAG,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,UAAU,EAAE,GAAG,IAAI,CAAC,CAAA;QACpD,OAAO,uBAAuB,CAAC,SAAS,CAAC,CAAA;IAC3C,CAAC,CAAA;AACH,CAAC;AApBD,oCAoBC;AAED,MAAM,OAAO;IAAb;QACU,qBAAgB,GAAG,YAAY,CAAC,IAAI,EAAE,QAAQ,CAAC,EAAE,OAAO,EAAE,CAAS;YACzE,KAAK,CAAC,CAAC,OAAO,CAAC,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,CAAA;YAChE,OAAO,CAAC,CAAA;QACV,CAAC,CAAC,CAAA;IACJ,CAAC;CAAA;AAQD,SAAgB,UAAU,CACxB,IAAU,EACV,cAG2D;IAE3D,MAAM,SAAS,GAAG,cAAc,CAAC,IAAI,CAAC,IAAI,EAAE,UAAU,CAAC,CAAA;IACvD,OAAO,uBAAuB,CAAC,SAAS,CAAC,CAAA;AAC3C,CAAC;AATD,gCASC;AAED,SAAgB,uBAAuB,CACrC,GAA6D;IAI7D,SAAS,cAAc,CAAC,IAAgB;QACtC,IAAI,IAAI,CAAC,IAAI,EAAE;YACb,OAAO,IAAI,CAAC,KAAK,CAAA;SAClB;QAED,IAAI,IAAI,CAAC,KAAK,YAAY,OAAO,EAAE;YACjC,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CACpB,CAAC,KAAK,EAAE,EAAE,CAAC,cAAc,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAC1C,CAAC,KAAK,EAAE,EAAE,CAAC,cAAc,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAC5C,CAAA;SACF;QAED,OAAO,cAAc,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAA;IAC7C,CAAC;IAED,OAAO,cAAc,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAA;AACnC,CAAC;AArBD,0DAqBC","sourcesContent":["function* awaitYield(value: T | Promise) {\n return (yield value) as T\n}\n\nfunction awaitYieldOf(\n generator: Generator, T, Yielded>\n): Generator, T, T> {\n return awaitYield(awaitEachYieldedPromise(generator))\n}\n\nexport type AwaitYield = typeof awaitYield & {\n of: typeof awaitYieldOf\n}\n\nconst AwaitYield: AwaitYield = awaitYield as AwaitYield\nAwaitYield.of = awaitYieldOf\n\n/**\n * Create a function that may or may not be async, using a generator\n *\n * Within the generator, call `yield* awaited(maybePromise)` to await a value\n * that may or may not be a promise.\n *\n * If the inner function never yields a promise, it will return synchronously.\n */\nexport function maybeAsyncFn<\n /** Function arguments */\n Args extends any[],\n This,\n /** Function return type */\n Return,\n /** Yields to unwrap */\n Yielded\n>(\n that: This,\n fn: (\n this: This,\n awaited: AwaitYield,\n ...args: Args\n ) => Generator, Return, Yielded>\n): (...args: Args) => Return | Promise {\n return (...args: Args) => {\n const generator = fn.call(that, AwaitYield, ...args)\n return awaitEachYieldedPromise(generator)\n }\n}\n\nclass Example {\n private maybeAsyncMethod = maybeAsyncFn(this, function* (awaited, a: number) {\n yield* awaited(new Promise((resolve) => setTimeout(resolve, a)))\n return 5\n })\n}\n\nexport type MaybeAsyncBlock = (\n this: This,\n awaited: AwaitYield,\n ...args: Args\n) => Generator, Return, Yielded>\n\nexport function maybeAsync(\n that: This,\n startGenerator: (\n this: This,\n await: AwaitYield\n ) => Generator, Return, Yielded>\n): Return | Promise {\n const generator = startGenerator.call(that, AwaitYield)\n return awaitEachYieldedPromise(generator)\n}\n\nexport function awaitEachYieldedPromise(\n gen: Generator, Returned, Yielded>\n): Returned | Promise {\n type NextResult = ReturnType\n\n function handleNextStep(step: NextResult): Returned | Promise {\n if (step.done) {\n return step.value\n }\n\n if (step.value instanceof Promise) {\n return step.value.then(\n (value) => handleNextStep(gen.next(value)),\n (error) => handleNextStep(gen.throw(error))\n )\n }\n\n return handleNextStep(gen.next(step.value))\n }\n\n return handleNextStep(gen.next())\n}\n"]}
\ No newline at end of file
diff --git a/node_modules/@tootallnate/quickjs-emscripten/dist/context-asyncify.d.ts b/node_modules/@tootallnate/quickjs-emscripten/dist/context-asyncify.d.ts
new file mode 100644
index 0000000..290a9ec
--- /dev/null
+++ b/node_modules/@tootallnate/quickjs-emscripten/dist/context-asyncify.d.ts
@@ -0,0 +1,48 @@
+import { QuickJSContext } from "./context";
+import { QuickJSAsyncEmscriptenModule } from "./emscripten-types";
+import { QuickJSAsyncFFI } from "./variants";
+import { JSRuntimePointer } from "./types-ffi";
+import { Lifetime } from "./lifetime";
+import { QuickJSModuleCallbacks } from "./module";
+import { QuickJSAsyncRuntime } from "./runtime-asyncify";
+import { ContextEvalOptions, QuickJSHandle } from "./types";
+import { VmCallResult } from "./vm-interface";
+export type AsyncFunctionImplementation = (this: QuickJSHandle, ...args: QuickJSHandle[]) => Promise | void>;
+/**
+ * Asyncified version of [[QuickJSContext]].
+ *
+ * *Asyncify* allows normally synchronous code to wait for asynchronous Promises
+ * or callbacks. The asyncified version of QuickJSContext can wait for async
+ * host functions as though they were synchronous.
+ */
+export declare class QuickJSAsyncContext extends QuickJSContext {
+ runtime: QuickJSAsyncRuntime;
+ /** @private */
+ protected module: QuickJSAsyncEmscriptenModule;
+ /** @private */
+ protected ffi: QuickJSAsyncFFI;
+ /** @private */
+ protected rt: Lifetime;
+ /** @private */
+ protected callbacks: QuickJSModuleCallbacks;
+ /**
+ * Asyncified version of [[evalCode]].
+ */
+ evalCodeAsync(code: string, filename?: string,
+ /** See [[EvalFlags]] for number semantics */
+ options?: number | ContextEvalOptions): Promise>;
+ /**
+ * Similar to [[newFunction]].
+ * Convert an async host Javascript function into a synchronous QuickJS function value.
+ *
+ * Whenever QuickJS calls this function, the VM's stack will be unwound while
+ * waiting the async function to complete, and then restored when the returned
+ * promise resolves.
+ *
+ * Asyncified functions must never call other asyncified functions or
+ * `import`, even indirectly, because the stack cannot be unwound twice.
+ *
+ * See [Emscripten's docs on Asyncify](https://emscripten.org/docs/porting/asyncify.html).
+ */
+ newAsyncifiedFunction(name: string, fn: AsyncFunctionImplementation): QuickJSHandle;
+}
diff --git a/node_modules/@tootallnate/quickjs-emscripten/dist/context-asyncify.js b/node_modules/@tootallnate/quickjs-emscripten/dist/context-asyncify.js
new file mode 100644
index 0000000..7b3fe56
--- /dev/null
+++ b/node_modules/@tootallnate/quickjs-emscripten/dist/context-asyncify.js
@@ -0,0 +1,58 @@
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.QuickJSAsyncContext = void 0;
+const context_1 = require("./context");
+const debug_1 = require("./debug");
+const types_1 = require("./types");
+/**
+ * Asyncified version of [[QuickJSContext]].
+ *
+ * *Asyncify* allows normally synchronous code to wait for asynchronous Promises
+ * or callbacks. The asyncified version of QuickJSContext can wait for async
+ * host functions as though they were synchronous.
+ */
+class QuickJSAsyncContext extends context_1.QuickJSContext {
+ /**
+ * Asyncified version of [[evalCode]].
+ */
+ async evalCodeAsync(code, filename = "eval.js",
+ /** See [[EvalFlags]] for number semantics */
+ options) {
+ const detectModule = (options === undefined ? 1 : 0);
+ const flags = (0, types_1.evalOptionsToFlags)(options);
+ let resultPtr = 0;
+ try {
+ resultPtr = await this.memory
+ .newHeapCharPointer(code)
+ .consume((charHandle) => this.ffi.QTS_Eval_MaybeAsync(this.ctx.value, charHandle.value, filename, detectModule, flags));
+ }
+ catch (error) {
+ (0, debug_1.debugLog)("QTS_Eval_MaybeAsync threw", error);
+ throw error;
+ }
+ const errorPtr = this.ffi.QTS_ResolveException(this.ctx.value, resultPtr);
+ if (errorPtr) {
+ this.ffi.QTS_FreeValuePointer(this.ctx.value, resultPtr);
+ return { error: this.memory.heapValueHandle(errorPtr) };
+ }
+ return { value: this.memory.heapValueHandle(resultPtr) };
+ }
+ /**
+ * Similar to [[newFunction]].
+ * Convert an async host Javascript function into a synchronous QuickJS function value.
+ *
+ * Whenever QuickJS calls this function, the VM's stack will be unwound while
+ * waiting the async function to complete, and then restored when the returned
+ * promise resolves.
+ *
+ * Asyncified functions must never call other asyncified functions or
+ * `import`, even indirectly, because the stack cannot be unwound twice.
+ *
+ * See [Emscripten's docs on Asyncify](https://emscripten.org/docs/porting/asyncify.html).
+ */
+ newAsyncifiedFunction(name, fn) {
+ return this.newFunction(name, fn);
+ }
+}
+exports.QuickJSAsyncContext = QuickJSAsyncContext;
+//# sourceMappingURL=context-asyncify.js.map
\ No newline at end of file
diff --git a/node_modules/@tootallnate/quickjs-emscripten/dist/context-asyncify.js.map b/node_modules/@tootallnate/quickjs-emscripten/dist/context-asyncify.js.map
new file mode 100644
index 0000000..93695e2
--- /dev/null
+++ b/node_modules/@tootallnate/quickjs-emscripten/dist/context-asyncify.js.map
@@ -0,0 +1 @@
+{"version":3,"file":"context-asyncify.js","sourceRoot":"","sources":["../ts/context-asyncify.ts"],"names":[],"mappings":";;;AAAA,uCAA0C;AAC1C,mCAAkC;AAOlC,mCAA+E;AAQ/E;;;;;;GAMG;AACH,MAAa,mBAAoB,SAAQ,wBAAc;IAWrD;;OAEG;IACH,KAAK,CAAC,aAAa,CACjB,IAAY,EACZ,WAAmB,SAAS;IAC5B,6CAA6C;IAC7C,OAAqC;QAErC,MAAM,YAAY,GAAG,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAqB,CAAA;QACxE,MAAM,KAAK,GAAG,IAAA,0BAAkB,EAAC,OAAO,CAAc,CAAA;QACtD,IAAI,SAAS,GAAG,CAAmB,CAAA;QACnC,IAAI;YACF,SAAS,GAAG,MAAM,IAAI,CAAC,MAAM;iBAC1B,kBAAkB,CAAC,IAAI,CAAC;iBACxB,OAAO,CAAC,CAAC,UAAU,EAAE,EAAE,CACtB,IAAI,CAAC,GAAG,CAAC,mBAAmB,CAC1B,IAAI,CAAC,GAAG,CAAC,KAAK,EACd,UAAU,CAAC,KAAK,EAChB,QAAQ,EACR,YAAY,EACZ,KAAK,CACN,CACF,CAAA;SACJ;QAAC,OAAO,KAAK,EAAE;YACd,IAAA,gBAAQ,EAAC,2BAA2B,EAAE,KAAK,CAAC,CAAA;YAC5C,MAAM,KAAK,CAAA;SACZ;QACD,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,oBAAoB,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,SAAS,CAAC,CAAA;QACzE,IAAI,QAAQ,EAAE;YACZ,IAAI,CAAC,GAAG,CAAC,oBAAoB,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,SAAS,CAAC,CAAA;YACxD,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,QAAQ,CAAC,EAAE,CAAA;SACxD;QACD,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,SAAS,CAAC,EAAE,CAAA;IAC1D,CAAC;IAED;;;;;;;;;;;;OAYG;IACH,qBAAqB,CAAC,IAAY,EAAE,EAA+B;QACjE,OAAO,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,EAAS,CAAC,CAAA;IAC1C,CAAC;CACF;AA/DD,kDA+DC","sourcesContent":["import { QuickJSContext } from \"./context\"\nimport { debugLog } from \"./debug\"\nimport { QuickJSAsyncEmscriptenModule } from \"./emscripten-types\"\nimport { QuickJSAsyncFFI } from \"./variants\"\nimport { EvalDetectModule, EvalFlags, JSRuntimePointer, JSValuePointer } from \"./types-ffi\"\nimport { Lifetime } from \"./lifetime\"\nimport { QuickJSModuleCallbacks } from \"./module\"\nimport { QuickJSAsyncRuntime } from \"./runtime-asyncify\"\nimport { ContextEvalOptions, evalOptionsToFlags, QuickJSHandle } from \"./types\"\nimport { VmCallResult } from \"./vm-interface\"\n\nexport type AsyncFunctionImplementation = (\n this: QuickJSHandle,\n ...args: QuickJSHandle[]\n) => Promise | void>\n\n/**\n * Asyncified version of [[QuickJSContext]].\n *\n * *Asyncify* allows normally synchronous code to wait for asynchronous Promises\n * or callbacks. The asyncified version of QuickJSContext can wait for async\n * host functions as though they were synchronous.\n */\nexport class QuickJSAsyncContext extends QuickJSContext {\n public declare runtime: QuickJSAsyncRuntime\n /** @private */\n protected declare module: QuickJSAsyncEmscriptenModule\n /** @private */\n protected declare ffi: QuickJSAsyncFFI\n /** @private */\n protected declare rt: Lifetime\n /** @private */\n protected declare callbacks: QuickJSModuleCallbacks\n\n /**\n * Asyncified version of [[evalCode]].\n */\n async evalCodeAsync(\n code: string,\n filename: string = \"eval.js\",\n /** See [[EvalFlags]] for number semantics */\n options?: number | ContextEvalOptions\n ): Promise> {\n const detectModule = (options === undefined ? 1 : 0) as EvalDetectModule\n const flags = evalOptionsToFlags(options) as EvalFlags\n let resultPtr = 0 as JSValuePointer\n try {\n resultPtr = await this.memory\n .newHeapCharPointer(code)\n .consume((charHandle) =>\n this.ffi.QTS_Eval_MaybeAsync(\n this.ctx.value,\n charHandle.value,\n filename,\n detectModule,\n flags\n )\n )\n } catch (error) {\n debugLog(\"QTS_Eval_MaybeAsync threw\", error)\n throw error\n }\n const errorPtr = this.ffi.QTS_ResolveException(this.ctx.value, resultPtr)\n if (errorPtr) {\n this.ffi.QTS_FreeValuePointer(this.ctx.value, resultPtr)\n return { error: this.memory.heapValueHandle(errorPtr) }\n }\n return { value: this.memory.heapValueHandle(resultPtr) }\n }\n\n /**\n * Similar to [[newFunction]].\n * Convert an async host Javascript function into a synchronous QuickJS function value.\n *\n * Whenever QuickJS calls this function, the VM's stack will be unwound while\n * waiting the async function to complete, and then restored when the returned\n * promise resolves.\n *\n * Asyncified functions must never call other asyncified functions or\n * `import`, even indirectly, because the stack cannot be unwound twice.\n *\n * See [Emscripten's docs on Asyncify](https://emscripten.org/docs/porting/asyncify.html).\n */\n newAsyncifiedFunction(name: string, fn: AsyncFunctionImplementation): QuickJSHandle {\n return this.newFunction(name, fn as any)\n }\n}\n"]}
\ No newline at end of file
diff --git a/node_modules/@tootallnate/quickjs-emscripten/dist/context.d.ts b/node_modules/@tootallnate/quickjs-emscripten/dist/context.d.ts
new file mode 100644
index 0000000..d30d199
--- /dev/null
+++ b/node_modules/@tootallnate/quickjs-emscripten/dist/context.d.ts
@@ -0,0 +1,371 @@
+import { QuickJSDeferredPromise } from "./deferred-promise";
+import type { EitherModule } from "./emscripten-types";
+import { JSBorrowedCharPointer, JSContextPointer, JSRuntimePointer, JSValueConstPointer, JSValuePointer } from "./types-ffi";
+import { Disposable, Lifetime, Scope } from "./lifetime";
+import { ModuleMemory } from "./memory";
+import { QuickJSModuleCallbacks } from "./module";
+import { QuickJSRuntime } from "./runtime";
+import { ContextEvalOptions, EitherFFI, JSValue, PromiseExecutor, QuickJSHandle } from "./types";
+import { LowLevelJavascriptVm, SuccessOrFail, VmCallResult, VmFunctionImplementation, VmPropertyDescriptor } from "./vm-interface";
+/**
+ * Property key for getting or setting a property on a handle with
+ * [[QuickJSContext.getProp]], [[QuickJSContext.setProp]], or [[QuickJSContext.defineProp]].
+ */
+export type QuickJSPropertyKey = number | string | QuickJSHandle;
+/**
+ * @private
+ */
+declare class ContextMemory extends ModuleMemory implements Disposable {
+ readonly owner: QuickJSRuntime;
+ readonly ctx: Lifetime;
+ readonly rt: Lifetime;
+ readonly module: EitherModule;
+ readonly ffi: EitherFFI;
+ readonly scope: Scope;
+ /** @private */
+ constructor(args: {
+ owner: QuickJSRuntime;
+ module: EitherModule;
+ ffi: EitherFFI;
+ ctx: Lifetime;
+ rt: Lifetime;
+ ownedLifetimes?: Disposable[];
+ });
+ get alive(): boolean;
+ dispose(): void;
+ /**
+ * Track `lifetime` so that it is disposed when this scope is disposed.
+ */
+ manage(lifetime: T): T;
+ copyJSValue: (ptr: JSValuePointer | JSValueConstPointer) => any;
+ freeJSValue: (ptr: JSValuePointer) => void;
+ consumeJSCharPointer(ptr: JSBorrowedCharPointer): string;
+ heapValueHandle(ptr: JSValuePointer): JSValue;
+}
+/**
+ * QuickJSContext wraps a QuickJS Javascript context (JSContext*) within a
+ * runtime. The contexts within the same runtime may exchange objects freely.
+ * You can think of separate runtimes like different domains in a browser, and
+ * the contexts within a runtime like the different windows open to the same
+ * domain. The {@link runtime} references the context's runtime.
+ *
+ * This class's methods return {@link QuickJSHandle}, which wrap C pointers (JSValue*).
+ * It's the caller's responsibility to call `.dispose()` on any
+ * handles you create to free memory once you're done with the handle.
+ *
+ * Use {@link QuickJSRuntime.newContext} or {@link QuickJSWASMModule.newContext}
+ * to create a new QuickJSContext.
+ *
+ * Create QuickJS values inside the interpreter with methods like
+ * [[newNumber]], [[newString]], [[newArray]], [[newObject]],
+ * [[newFunction]], and [[newPromise]].
+ *
+ * Call [[setProp]] or [[defineProp]] to customize objects. Use those methods
+ * with [[global]] to expose the values you create to the interior of the
+ * interpreter, so they can be used in [[evalCode]].
+ *
+ * Use [[evalCode]] or [[callFunction]] to execute Javascript inside the VM. If
+ * you're using asynchronous code inside the QuickJSContext, you may need to also
+ * call [[executePendingJobs]]. Executing code inside the runtime returns a
+ * result object representing successful execution or an error. You must dispose
+ * of any such results to avoid leaking memory inside the VM.
+ *
+ * Implement memory and CPU constraints at the runtime level, using [[runtime]].
+ * See {@link QuickJSRuntime} for more information.
+ *
+ */
+export declare class QuickJSContext implements LowLevelJavascriptVm, Disposable {
+ /**
+ * The runtime that created this context.
+ */
+ readonly runtime: QuickJSRuntime;
+ /** @private */
+ protected readonly ctx: Lifetime;
+ /** @private */
+ protected readonly rt: Lifetime;
+ /** @private */
+ protected readonly module: EitherModule;
+ /** @private */
+ protected readonly ffi: EitherFFI;
+ /** @private */
+ protected memory: ContextMemory;
+ /** @private */
+ protected _undefined: QuickJSHandle | undefined;
+ /** @private */
+ protected _null: QuickJSHandle | undefined;
+ /** @private */
+ protected _false: QuickJSHandle | undefined;
+ /** @private */
+ protected _true: QuickJSHandle | undefined;
+ /** @private */
+ protected _global: QuickJSHandle | undefined;
+ /** @private */
+ protected _BigInt: QuickJSHandle | undefined;
+ /**
+ * Use {@link QuickJS.createVm} to create a QuickJSContext instance.
+ */
+ constructor(args: {
+ module: EitherModule;
+ ffi: EitherFFI;
+ ctx: Lifetime;
+ rt: Lifetime;
+ runtime: QuickJSRuntime;
+ ownedLifetimes?: Disposable[];
+ callbacks: QuickJSModuleCallbacks;
+ });
+ get alive(): boolean;
+ /**
+ * Dispose of this VM's underlying resources.
+ *
+ * @throws Calling this method without disposing of all created handles
+ * will result in an error.
+ */
+ dispose(): void;
+ /**
+ * [`undefined`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/undefined).
+ */
+ get undefined(): QuickJSHandle;
+ /**
+ * [`null`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/null).
+ */
+ get null(): QuickJSHandle;
+ /**
+ * [`true`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/true).
+ */
+ get true(): QuickJSHandle;
+ /**
+ * [`false`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/false).
+ */
+ get false(): QuickJSHandle;
+ /**
+ * [`global`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects).
+ * A handle to the global object inside the interpreter.
+ * You can set properties to create global variables.
+ */
+ get global(): QuickJSHandle;
+ /**
+ * Converts a Javascript number into a QuickJS value.
+ */
+ newNumber(num: number): QuickJSHandle;
+ /**
+ * Create a QuickJS [string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String) value.
+ */
+ newString(str: string): QuickJSHandle;
+ /**
+ * Create a QuickJS [symbol](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol) value.
+ * No two symbols created with this function will be the same value.
+ */
+ newUniqueSymbol(description: string | symbol): QuickJSHandle;
+ /**
+ * Get a symbol from the [global registry](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol#shared_symbols_in_the_global_symbol_registry) for the given key.
+ * All symbols created with the same key will be the same value.
+ */
+ newSymbolFor(key: string | symbol): QuickJSHandle;
+ /**
+ * Create a QuickJS [bigint](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt) value.
+ */
+ newBigInt(num: bigint): QuickJSHandle;
+ /**
+ * `{}`.
+ * Create a new QuickJS [object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Object_initializer).
+ *
+ * @param prototype - Like [`Object.create`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/create).
+ */
+ newObject(prototype?: QuickJSHandle): QuickJSHandle;
+ /**
+ * `[]`.
+ * Create a new QuickJS [array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array).
+ */
+ newArray(): QuickJSHandle;
+ /**
+ * Create a new [[QuickJSDeferredPromise]]. Use `deferred.resolve(handle)` and
+ * `deferred.reject(handle)` to fulfill the promise handle available at `deferred.handle`.
+ * Note that you are responsible for calling `deferred.dispose()` to free the underlying
+ * resources; see the documentation on [[QuickJSDeferredPromise]] for details.
+ */
+ newPromise(): QuickJSDeferredPromise;
+ /**
+ * Create a new [[QuickJSDeferredPromise]] that resolves when the
+ * given native Promise resolves. Rejections will be coerced
+ * to a QuickJS error.
+ *
+ * You can still resolve/reject the created promise "early" using its methods.
+ */
+ newPromise(promise: Promise): QuickJSDeferredPromise;
+ /**
+ * Construct a new native Promise, and then convert it into a
+ * [[QuickJSDeferredPromise]].
+ *
+ * You can still resolve/reject the created promise "early" using its methods.
+ */
+ newPromise(newPromiseFn: PromiseExecutor): QuickJSDeferredPromise;
+ /**
+ * Convert a Javascript function into a QuickJS function value.
+ * See [[VmFunctionImplementation]] for more details.
+ *
+ * A [[VmFunctionImplementation]] should not free its arguments or its return
+ * value. A VmFunctionImplementation should also not retain any references to
+ * its return value.
+ *
+ * To implement an async function, create a promise with [[newPromise]], then
+ * return the deferred promise handle from `deferred.handle` from your
+ * function implementation:
+ *
+ * ```
+ * const deferred = vm.newPromise()
+ * someNativeAsyncFunction().then(deferred.resolve)
+ * return deferred.handle
+ * ```
+ */
+ newFunction(name: string, fn: VmFunctionImplementation): QuickJSHandle;
+ newError(error: {
+ name: string;
+ message: string;
+ }): QuickJSHandle;
+ newError(message: string): QuickJSHandle;
+ newError(): QuickJSHandle;
+ /**
+ * `typeof` operator. **Not** [standards compliant](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/typeof).
+ *
+ * @remarks
+ * Does not support BigInt values correctly.
+ */
+ typeof(handle: QuickJSHandle): string;
+ /**
+ * Converts `handle` into a Javascript number.
+ * @returns `NaN` on error, otherwise a `number`.
+ */
+ getNumber(handle: QuickJSHandle): number;
+ /**
+ * Converts `handle` to a Javascript string.
+ */
+ getString(handle: QuickJSHandle): string;
+ /**
+ * Converts `handle` into a Javascript symbol. If the symbol is in the global
+ * registry in the guest, it will be created with Symbol.for on the host.
+ */
+ getSymbol(handle: QuickJSHandle): symbol;
+ /**
+ * Converts `handle` to a Javascript bigint.
+ */
+ getBigInt(handle: QuickJSHandle): bigint;
+ /**
+ * `Promise.resolve(value)`.
+ * Convert a handle containing a Promise-like value inside the VM into an
+ * actual promise on the host.
+ *
+ * @remarks
+ * You may need to call [[executePendingJobs]] to ensure that the promise is resolved.
+ *
+ * @param promiseLikeHandle - A handle to a Promise-like value with a `.then(onSuccess, onError)` method.
+ */
+ resolvePromise(promiseLikeHandle: QuickJSHandle): Promise>;
+ /**
+ * `handle[key]`.
+ * Get a property from a JSValue.
+ *
+ * @param key - The property may be specified as a JSValue handle, or as a
+ * Javascript string (which will be converted automatically).
+ */
+ getProp(handle: QuickJSHandle, key: QuickJSPropertyKey): QuickJSHandle;
+ /**
+ * `handle[key] = value`.
+ * Set a property on a JSValue.
+ *
+ * @remarks
+ * Note that the QuickJS authors recommend using [[defineProp]] to define new
+ * properties.
+ *
+ * @param key - The property may be specified as a JSValue handle, or as a
+ * Javascript string or number (which will be converted automatically to a JSValue).
+ */
+ setProp(handle: QuickJSHandle, key: QuickJSPropertyKey, value: QuickJSHandle): void;
+ /**
+ * [`Object.defineProperty(handle, key, descriptor)`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperty).
+ *
+ * @param key - The property may be specified as a JSValue handle, or as a
+ * Javascript string or number (which will be converted automatically to a JSValue).
+ */
+ defineProp(handle: QuickJSHandle, key: QuickJSPropertyKey, descriptor: VmPropertyDescriptor): void;
+ /**
+ * [`func.call(thisVal, ...args)`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/call).
+ * Call a JSValue as a function.
+ *
+ * See [[unwrapResult]], which will throw if the function returned an error, or
+ * return the result handle directly. If evaluation returned a handle containing
+ * a promise, use [[resolvePromise]] to convert it to a native promise and
+ * [[executePendingJobs]] to finish evaluating the promise.
+ *
+ * @returns A result. If the function threw synchronously, `result.error` be a
+ * handle to the exception. Otherwise `result.value` will be a handle to the
+ * value.
+ */
+ callFunction(func: QuickJSHandle, thisVal: QuickJSHandle, ...args: QuickJSHandle[]): VmCallResult;
+ /**
+ * Like [`eval(code)`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval#Description).
+ * Evaluates the Javascript source `code` in the global scope of this VM.
+ * When working with async code, you many need to call [[executePendingJobs]]
+ * to execute callbacks pending after synchronous evaluation returns.
+ *
+ * See [[unwrapResult]], which will throw if the function returned an error, or
+ * return the result handle directly. If evaluation returned a handle containing
+ * a promise, use [[resolvePromise]] to convert it to a native promise and
+ * [[executePendingJobs]] to finish evaluating the promise.
+ *
+ * *Note*: to protect against infinite loops, provide an interrupt handler to
+ * [[setInterruptHandler]]. You can use [[shouldInterruptAfterDeadline]] to
+ * create a time-based deadline.
+ *
+ * @returns The last statement's value. If the code threw synchronously,
+ * `result.error` will be a handle to the exception. If execution was
+ * interrupted, the error will have name `InternalError` and message
+ * `interrupted`.
+ */
+ evalCode(code: string, filename?: string,
+ /**
+ * If no options are passed, a heuristic will be used to detect if `code` is
+ * an ES module.
+ *
+ * See [[EvalFlags]] for number semantics.
+ */
+ options?: number | ContextEvalOptions): VmCallResult;
+ /**
+ * Throw an error in the VM, interrupted whatever current execution is in progress when execution resumes.
+ * @experimental
+ */
+ throw(error: Error | QuickJSHandle): any;
+ /**
+ * @private
+ */
+ protected borrowPropertyKey(key: QuickJSPropertyKey): QuickJSHandle;
+ /**
+ * @private
+ */
+ getMemory(rt: JSRuntimePointer): ContextMemory;
+ /**
+ * Dump a JSValue to Javascript in a best-effort fashion.
+ * Returns `handle.toString()` if it cannot be serialized to JSON.
+ */
+ dump(handle: QuickJSHandle): any;
+ /**
+ * Unwrap a SuccessOrFail result such as a [[VmCallResult]] or a
+ * [[ExecutePendingJobsResult]], where the fail branch contains a handle to a QuickJS error value.
+ * If the result is a success, returns the value.
+ * If the result is an error, converts the error to a native object and throws the error.
+ */
+ unwrapResult(result: SuccessOrFail