varsnap 1.8.2 → 1.8.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
1
  /*
2
- * Varsnap.js v1.8.2
2
+ * Varsnap.js v1.8.3
3
3
  */
4
- !function(t){!function(e){"object"==typeof t&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).varsnap=e()}(function(){function u(t){var n;return function(e){return n||t(n={exports:{},parent:e},n.exports),n.exports}}function c(n,r){return function(){for(var e=new Array(arguments.length),t=0;t<e.length;t++)e[t]=arguments[t];return n.apply(r,e)}}var f=u(function(i,e){!function(o){!function(){"use strict";var t={"Content-Type":"application/x-www-form-urlencoded"};function n(e,t){!h.isUndefined(e)&&h.isUndefined(e["Content-Type"])&&(e["Content-Type"]=t)}var e,r={transitional:{silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},adapter:e="undefined"!=typeof XMLHttpRequest||void 0!==o&&"[object process]"===Object.prototype.toString.call(o)?l({}):e,transformRequest:[function(e,t){{if(j(t,"Accept"),j(t,"Content-Type"),h.isFormData(e)||h.isArrayBuffer(e)||h.isBuffer(e)||h.isStream(e)||h.isFile(e)||h.isBlob(e))return e;if(h.isArrayBufferView(e))return e.buffer;if(h.isURLSearchParams(e))return n(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString();if(h.isObject(e)||t&&"application/json"===t["Content-Type"]){if(n(t,"application/json"),h.isString(t=e))try{return(0,JSON.parse)(t),h.trim(t)}catch(e){if("SyntaxError"!==e.name)throw e}return(0,JSON.stringify)(t)}return e}}],transformResponse:[function(e){var t=this.transitional||r.transitional,n=t&&t.silentJSONParsing,t=t&&t.forcedJSONParsing,n=!n&&"json"===this.responseType;if(n||t&&h.isString(e)&&e.length)try{return JSON.parse(e)}catch(e){if(n){if("SyntaxError"===e.name)throw O(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 200<=e&&e<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};h.forEach(["delete","get","head"],function(e){r.headers[e]={}}),h.forEach(["post","put","patch"],function(e){r.headers[e]=h.merge(t)}),i.exports=r}.call(this)}.call(this,z)}),l=u(function(e,t){"use strict";var d=f({});e.exports=function(p){return new Promise(function(f,n){var e,r=p.data,o=p.headers,t=p.responseType;function i(){p.cancelToken&&p.cancelToken.unsubscribe(e),p.signal&&p.signal.removeEventListener("abort",e)}h.isFormData(r)&&delete o["Content-Type"];var a,s,u=new XMLHttpRequest,c=(p.auth&&(c=p.auth.username||"",a=p.auth.password?unescape(encodeURIComponent(p.auth.password)):"",o.Authorization="Basic "+btoa(c+":"+a)),A(p.baseURL,p.url));function l(){var e;u&&(e="getAllResponseHeaders"in u?R(u.getAllResponseHeaders()):null,e={data:t&&"text"!==t&&"json"!==t?u.response:u.responseText,status:u.status,statusText:u.statusText,headers:e,config:p,request:u},_(function(e){f(e),i()},function(e){n(e),i()},e),u=null)}u.open(p.method.toUpperCase(),S(c,p.params,p.paramsSerializer),!0),u.timeout=p.timeout,"onloadend"in u?u.onloadend=l:u.onreadystatechange=function(){u&&4===u.readyState&&(0!==u.status||u.responseURL&&0===u.responseURL.indexOf("file:"))&&setTimeout(l)},u.onabort=function(){u&&(n(x("Request aborted",p,"ECONNABORTED",u)),u=null)},u.onerror=function(){n(x("Network Error",p,null,u)),u=null},u.ontimeout=function(){var e=p.timeout?"timeout of "+p.timeout+"ms exceeded":"timeout exceeded",t=p.transitional||d.transitional;p.timeoutErrorMessage&&(e=p.timeoutErrorMessage),n(x(e,p,t.clarifyTimeoutError?"ETIMEDOUT":"ECONNABORTED",u)),u=null},h.isStandardBrowserEnv()&&(s=(p.withCredentials||U(c))&&p.xsrfCookieName?P.read(p.xsrfCookieName):void 0)&&(o[p.xsrfHeaderName]=s),"setRequestHeader"in u&&h.forEach(o,function(e,t){void 0===r&&"content-type"===t.toLowerCase()?delete o[t]:u.setRequestHeader(t,e)}),h.isUndefined(p.withCredentials)||(u.withCredentials=!!p.withCredentials),t&&"json"!==t&&(u.responseType=p.responseType),"function"==typeof p.onDownloadProgress&&u.addEventListener("progress",p.onDownloadProgress),"function"==typeof p.onUploadProgress&&u.upload&&u.upload.addEventListener("progress",p.onUploadProgress),(p.cancelToken||p.signal)&&(e=function(e){u&&(n(!e||e.type?new L("canceled"):e),u.abort(),u=null)},p.cancelToken&&p.cancelToken.subscribe(e),p.signal&&(p.signal.aborted?e():p.signal.addEventListener("abort",e))),r=r||null,u.send(r)})}}),t=Object.prototype.toString;function p(e){return Array.isArray(e)}function d(e){return void 0===e}function g(e){return"[object ArrayBuffer]"===t.call(e)}function m(e){return null!==e&&"object"==typeof e}function y(e){if("[object Object]"!==t.call(e))return!1;e=Object.getPrototypeOf(e);return null===e||e===Object.prototype}function b(e,t){if(null!=e)if(p(e="object"!=typeof e?[e]:e))for(var n=0,r=e.length;n<r;n++)t.call(null,e[n],n,e);else for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.call(null,e[o],o,e)}var h={isArray:p,isArrayBuffer:g,isBuffer:function(e){return null!==e&&!d(e)&&null!==e.constructor&&!d(e.constructor)&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)},isFormData:function(e){return"[object FormData]"===t.call(e)},isArrayBufferView:function(e){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&g(e.buffer)},isString:function(e){return"string"==typeof e},isNumber:function(e){return"number"==typeof e},isObject:m,isPlainObject:y,isUndefined:d,isDate:function(e){return"[object Date]"===t.call(e)},isFile:function(e){return"[object File]"===t.call(e)},isBlob:function(e){return"[object Blob]"===t.call(e)},isStream:function(e){return m(e)&&(e=e.pipe,"[object Function]"===t.call(e))},isURLSearchParams:function(e){return"[object URLSearchParams]"===t.call(e)},isStandardBrowserEnv:function(){return("undefined"==typeof navigator||"ReactNative"!==navigator.product&&"NativeScript"!==navigator.product&&"NS"!==navigator.product)&&"undefined"!=typeof window&&"undefined"!=typeof document},forEach:b,merge:function n(){var r={};function e(e,t){y(r[t])&&y(e)?r[t]=n(r[t],e):y(e)?r[t]=n({},e):p(e)?r[t]=e.slice():r[t]=e}for(var t=0,o=arguments.length;t<o;t++)b(arguments[t],e);return r},extend:function(n,e,r){return b(e,function(e,t){n[t]=r&&"function"==typeof e?c(e,r):e}),n},trim:function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}};function w(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var S=function(e,t,n){if(!t)return e;var r,n=n?n(t):h.isURLSearchParams(t)?t.toString():(r=[],h.forEach(t,function(e,t){null!=e&&(h.isArray(e)?t+="[]":e=[e],h.forEach(e,function(e){h.isDate(e)?e=e.toISOString():h.isObject(e)&&(e=JSON.stringify(e)),r.push(w(t)+"="+w(e))}))}),r.join("&"));return n&&(-1!==(t=e.indexOf("#"))&&(e=e.slice(0,t)),e+=(-1===e.indexOf("?")?"?":"&")+n),e},T={};function k(){this.handlers=[]}k.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},k.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},k.prototype.forEach=function(t){h.forEach(this.handlers,function(e){null!==e&&t(e)})};var E,C,n,T=k,j=function(n,r){h.forEach(n,function(e,t){t!==r&&t.toUpperCase()===r.toUpperCase()&&(n[r]=e,delete n[t])})},O=function(e,t,n,r,o){return e.config=t,n&&(e.code=n),e.request=r,e.response=o,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,status:this.response&&this.response.status?this.response.status:null}},e},x=function(e,t,n,r,o){e=new Error(e);return O(e,t,n,r,o)},_=function(e,t,n){var r=n.config.validateStatus;n.status&&r&&!r(n.status)?t(x("Request failed with status code "+n.status,n.config,null,n.request,n)):e(n)},P=h.isStandardBrowserEnv()?{write:function(e,t,n,r,o,i){var a=[];a.push(e+"="+encodeURIComponent(t)),h.isNumber(n)&&a.push("expires="+new Date(n).toGMTString()),h.isString(r)&&a.push("path="+r),h.isString(o)&&a.push("domain="+o),!0===i&&a.push("secure"),document.cookie=a.join("; ")},read:function(e){e=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return e?decodeURIComponent(e[3]):null},remove:function(e){this.write(e,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}},A=function(e,t){return e&&!/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)?(e=e,(n=t)?e.replace(/\/+$/,"")+"/"+n.replace(/^\/+/,""):e):t;var n},N=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"],R=function(e){var t,n,r={};return e&&h.forEach(e.split("\n"),function(e){n=e.indexOf(":"),t=h.trim(e.substr(0,n)).toLowerCase(),n=h.trim(e.substr(n+1)),t&&(r[t]&&0<=N.indexOf(t)||(r[t]="set-cookie"===t?(r[t]||[]).concat([n]):r[t]?r[t]+", "+n:n))}),r},U=h.isStandardBrowserEnv()?(C=/(msie|trident)/i.test(navigator.userAgent),n=document.createElement("a"),E=B(window.location.href),function(e){e=h.isString(e)?B(e):e;return e.protocol===E.protocol&&e.host===E.host}):function(){return!0},L={};function B(e){return C&&(n.setAttribute("href",e),e=n.href),n.setAttribute("href",e),{href:n.href,protocol:n.protocol?n.protocol.replace(/:$/,""):"",host:n.host,search:n.search?n.search.replace(/^\?/,""):"",hash:n.hash?n.hash.replace(/^#/,""):"",hostname:n.hostname,port:n.port,pathname:"/"===n.pathname.charAt(0)?n.pathname:"/"+n.pathname}}function q(e){this.message=e}q.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},q.prototype.__CANCEL__=!0;var r,o,L=q,z={},e=z={};function D(){throw new Error("setTimeout has not been defined")}function V(){throw new Error("clearTimeout has not been defined")}function J(t){if(r===setTimeout)return setTimeout(t,0);if((r===D||!r)&&setTimeout)return r=setTimeout,setTimeout(t,0);try{return r(t,0)}catch(e){try{return r.call(null,t,0)}catch(e){return r.call(this,t,0)}}}try{r="function"==typeof setTimeout?setTimeout:D}catch(e){r=D}try{o="function"==typeof clearTimeout?clearTimeout:V}catch(e){o=V}var F,i=[],I=!1,H=-1;function M(){I&&F&&(I=!1,F.length?i=F.concat(i):H=-1,i.length&&$())}function $(){if(!I){var e=J(M);I=!0;for(var t=i.length;t;){for(F=i,i=[];++H<t;)F&&F[H].run();H=-1,t=i.length}F=null,I=!1,function(t){if(o===clearTimeout)return clearTimeout(t);if((o===V||!o)&&clearTimeout)return o=clearTimeout,clearTimeout(t);try{o(t)}catch(e){try{return o.call(null,t)}catch(e){return o.call(this,t)}}}(e)}}function G(e,t){this.fun=e,this.array=t}function a(){}e.nextTick=function(e){var t=new Array(arguments.length-1);if(1<arguments.length)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];i.push(new G(e,t)),1!==i.length||I||J($)},G.prototype.run=function(){this.fun.apply(null,this.array)},e.title="browser",e.browser=!0,e.env={},e.argv=[],e.version="",e.versions={},e.on=a,e.addListener=a,e.once=a,e.off=a,e.removeListener=a,e.removeAllListeners=a,e.emit=a,e.prependListener=a,e.prependOnceListener=a,e.listeners=function(e){return[]},e.binding=function(e){throw new Error("process.binding is not supported")},e.cwd=function(){return"/"},e.chdir=function(e){throw new Error("process.chdir is not supported")},e.umask=function(){return 0};var X=f({}),W=function(t,n,e){var r=this||X;return h.forEach(e,function(e){t=e.call(r,t,n)}),t},K=function(e){return!(!e||!e.__CANCEL__)},Y=f({});function Q(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new L("canceled")}function Z(t){return Q(t),t.headers=t.headers||{},t.data=W.call(t,t.data,t.headers,t.transformRequest),t.headers=h.merge(t.headers.common||{},t.headers[t.method]||{},t.headers),h.forEach(["delete","get","head","post","put","patch","common"],function(e){delete t.headers[e]}),(t.adapter||Y.adapter)(t).then(function(e){return Q(t),e.data=W.call(t,e.data,e.headers,t.transformResponse),e},function(e){return K(e)||(Q(t),e&&e.response&&(e.response.data=W.call(t,e.response.data,e.response.headers,t.transformResponse))),Promise.reject(e)})}function ee(t,n){n=n||{};var r={};function o(e,t){return h.isPlainObject(e)&&h.isPlainObject(t)?h.merge(e,t):h.isPlainObject(t)?h.merge({},t):h.isArray(t)?t.slice():t}function i(e){return h.isUndefined(n[e])?h.isUndefined(t[e])?void 0:o(void 0,t[e]):o(t[e],n[e])}function e(e){if(!h.isUndefined(n[e]))return o(void 0,n[e])}function a(e){return h.isUndefined(n[e])?h.isUndefined(t[e])?void 0:o(void 0,t[e]):o(void 0,n[e])}function s(e){return e in n?o(t[e],n[e]):e in t?o(void 0,t[e]):void 0}var u={url:e,method:e,data:e,baseURL:a,transformRequest:a,transformResponse:a,paramsSerializer:a,timeout:a,timeoutMessage:a,withCredentials:a,adapter:a,responseType:a,xsrfCookieName:a,xsrfHeaderName:a,onUploadProgress:a,onDownloadProgress:a,decompress:a,maxContentLength:a,maxBodyLength:a,transport:a,httpAgent:a,httpsAgent:a,cancelToken:a,socketPath:a,responseEncoding:a,validateStatus:s};return h.forEach(Object.keys(t).concat(Object.keys(n)),function(e){var t=u[e]||i,n=t(e);h.isUndefined(n)&&t!==s||(r[e]=n)}),r}var te,e="0.25.0",ne={},re=(["object","boolean","number","function","string","symbol"].forEach(function(t,n){ne[t]=function(e){return typeof e===t||"a"+(n<1?"n ":" ")+t}}),{}),oe=(ne.transitional=function(r,o,n){function i(e,t){return"[Axios v0.25.0] Transitional option '"+e+"'"+t+(n?". "+n:"")}return function(e,t,n){if(!1===r)throw new Error(i(t," has been removed"+(o?" in "+o:"")));return o&&!re[t]&&(re[t]=!0,console.warn(i(t," has been deprecated since v"+o+" and will be removed in the near future"))),!r||r(e,t,n)}},{}),ie=(te={assertOptions:function(e,t,n){if("object"!=typeof e)throw new TypeError("options must be an object");for(var r=Object.keys(e),o=r.length;0<o--;){var i=r[o],a=t[i];if(a){var s=e[i],a=void 0===s||a(s,i,e);if(!0!==a)throw new TypeError("option "+i+" must be "+a)}else if(!0!==n)throw Error("Unknown option "+i)}},validators:ne}).validators;function ae(e){this.defaults=e,this.interceptors={request:new T,response:new T}}function se(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");this.promise=new Promise(function(e){t=e});var t,r=this;this.promise.then(function(e){if(r._listeners){for(var t=r._listeners.length,n=0;n<t;n++)r._listeners[n](e);r._listeners=null}}),this.promise.then=function(e){var t,e=new Promise(function(e){r.subscribe(e),t=e}).then(e);return e.cancel=function(){r.unsubscribe(t)},e},e(function(e){r.reason||(r.reason=new L(e),t(r.reason))})}ae.prototype.request=function(e,t){if("string"==typeof e?(t=t||{}).url=e:t=e||{},!t.url)throw new Error("Provided config url is not valid");(t=ee(this.defaults,t)).method?t.method=t.method.toLowerCase():this.defaults.method?t.method=this.defaults.method.toLowerCase():t.method="get";var e=t.transitional,n=(void 0!==e&&te.assertOptions(e,{silentJSONParsing:ie.transitional(ie.boolean),forcedJSONParsing:ie.transitional(ie.boolean),clarifyTimeoutError:ie.transitional(ie.boolean)},!1),[]),r=!0;this.interceptors.request.forEach(function(e){"function"==typeof e.runWhen&&!1===e.runWhen(t)||(r=r&&e.synchronous,n.unshift(e.fulfilled,e.rejected))});var o,i=[];if(this.interceptors.response.forEach(function(e){i.push(e.fulfilled,e.rejected)}),!r){var a=[Z,void 0];for(Array.prototype.unshift.apply(a,n),a=a.concat(i),o=Promise.resolve(t);a.length;)o=o.then(a.shift(),a.shift());return o}for(var s=t;n.length;){var u=n.shift(),c=n.shift();try{s=u(s)}catch(e){c(e);break}}try{o=Z(s)}catch(e){return Promise.reject(e)}for(;i.length;)o=o.then(i.shift(),i.shift());return o},ae.prototype.getUri=function(e){if(!e.url)throw new Error("Provided config url is not valid");return e=ee(this.defaults,e),S(e.url,e.params,e.paramsSerializer).replace(/^\?/,"")},h.forEach(["delete","get","head","options"],function(n){ae.prototype[n]=function(e,t){return this.request(ee(t||{},{method:n,url:e,data:(t||{}).data}))}}),h.forEach(["post","put","patch"],function(r){ae.prototype[r]=function(e,t,n){return this.request(ee(n||{},{method:r,url:e,data:t}))}}),oe=ae,se.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},se.prototype.subscribe=function(e){this.reason?e(this.reason):this._listeners?this._listeners.push(e):this._listeners=[e]},se.prototype.unsubscribe=function(e){!this._listeners||-1!==(e=this._listeners.indexOf(e))&&this._listeners.splice(e,1)},se.source=function(){var t;return{token:new se(function(e){t=e}),cancel:t}};var ue=se,s=function t(n){var e=new oe(n),r=c(oe.prototype.request,e);return h.extend(r,oe.prototype,e),h.extend(r,e),r.create=function(e){return t(ee(n,e))},r}(f({})),ce=(s.Axios=oe,s.Cancel=L,s.CancelToken=ue,s.isCancel=K,s.VERSION=e,s.all=function(e){return Promise.all(e)},s.spread=function(t){return function(e){return t.apply(null,e)}},s.isAxiosError=function(e){return h.isObject(e)&&!0===e.isAxiosError},s.default=s),fe={},v={};return function(y){!function(){"use strict";function d(e,t){var n,r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=h(e))||t&&e&&"number"==typeof e.length)return r&&(e=r),n=0,{s:t=function(){},n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:t};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 o,i=!0,a=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return i=e.done,e},e:function(e){a=!0,o=e},f:function(){try{i||null==r.return||r.return()}finally{if(a)throw o}}}}function h(e,t){if(e){if("string"==typeof e)return c(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Map"===(n="Object"===n&&e.constructor?e.constructor.name:n)||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?c(e,t):void 0}}function c(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function t(e){return(t="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 r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function e(e,t,n){return t&&i(e.prototype,t),n&&i(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}Object.defineProperty(v,"__esModule",{value:!0}),v.varsnap=v.clientName=v.version=void 0,v.version="1.8.2",v.clientName="javascript."+v.version;var u={varsnap:!0,env:"development",branch:"",producerToken:"",consumerToken:"",logger:console},a=[],g=[],f=(e(n,null,[{key:"getConfig",value:function(e,t){if(!e)return"";e=e[t];return e?e.toString().toLowerCase():""}},{key:"setConfig",value:function(e,t,n){return"varsnap"===t&&(e[t]=n="string"==typeof n?"true"===n:n),"env"!==t&&"producerToken"!==t&&"consumerToken"!==t&&"branch"!==t||(e[t]=n),"logger"===t&&(e[t]=n),e}},{key:"getSignature",value:function(e,t){var n="",n=""!==t&&void 0!==t?t:(n=(n=e.toString().split("{")[0]).replace(/^\s+|\s+$/g,"")).replace(/,\s+/g,",");return"javascript."+v.version+"."+n}},{key:"ajax",value:function(e,t){e={method:"POST",url:e,headers:{"Content-Type":"application/x-www-form-urlencoded"},data:new URLSearchParams(t).toString(),responseType:"json"};return n.isNode()&&e.headers&&(e.headers["User-Agent"]="varsnap.js"),(0,ce.default)(e).then(function(e){return e.data}).catch(function(e){return e})}},{key:"debug",value:function(e,t){e.logger&&e.logger.debug(t)}},{key:"log",value:function(e,t){e.logger&&e.logger.log(t)}},{key:"error",value:function(e,t){e.logger&&e.logger.error(t)}},{key:"resetProducers",value:function(){a=[]}},{key:"resetConsumers",value:function(){g=[]}},{key:"getProducers",value:function(){return a}},{key:"getConsumers",value:function(){return g}},{key:"limitString",value:function(e){e=String(e);return e.length<=30?e:e.substring(0,30-"...".length)+"..."}},{key:"isNode",value:function(){return"object"===(void 0===y?"undefined":t(y))&&"undefined"==typeof window}},{key:"getBranch",value:function(e){var t=n.getConfig(e,"branch");return t?new Promise(function(e){return e(t)}):n.isNode()?new Promise(function(n){(0,fe.exec)("git rev-parse --abbrev-ref HEAD",function(e,t){return n(t.trim())})}):new Promise(function(e){return e("")})}}]),n),l=(e(o,[{key:"isEnabled",value:function(){return!!this.config.varsnap&&"production"===f.getConfig(this.config,"env")&&!!f.getConfig(this.config,"producerToken")}},{key:"produce",value:function(t,e){var n=this;return this.isEnabled()?(f.debug(this.config,"Sending call to Varsnap"),Promise.resolve(e).then(function(e){e={producer_token:f.getConfig(n.config,"producerToken"),signature:n.signature,inputs:o.serialize(t),prod_outputs:o.serialize(e)};return f.ajax("https://www.varsnap.com/api/snap/produce/",e).then(function(){return!0}).catch(function(e){if(e.response){if(429===e.response.status)return f.error(n.config,"Cannot produce to Varsnap; Signature at rate limit"),!0;404===e.response.status?f.error(n.config,"Cannot produce to Varsnap; check your producer token"):f.error(n.config,e.response.statusText)}return!1})})):new Promise(function(e){return e(!1)})}}],[{key:"serialize",value:function(e){return JSON.stringify(e)}},{key:"serialize_formatted",value:function(e){return JSON.stringify(e,null,2)}}]),o),m=(e(p,[{key:"isEnabled",value:function(){return!!this.config.varsnap&&"development"===f.getConfig(this.config,"env")&&!!f.getConfig(this.config,"consumerToken")}},{key:"consume",value:function(s){var u=this;if(!this.isEnabled())return new Promise(function(e){return f.error(u.config,"Varsnap not enabled for testing"),e(!1)});var o={consumer_token:f.getConfig(this.config,"consumerToken"),signature:this.signature};return f.ajax("https://www.varsnap.com/api/snap/consume/",o).then(function(e){var t=e;if(!t||"ok"!==t.status)return[new Promise(function(e){return f.error(u.config,"Received error from Varsnap: "+t.status),e(!1)})];0===t.results.length&&f.log(u.config,"No snaps found for signature: "+o.signature);var n,a=[],r=d(t.results);try{for(r.s();!(n=r.n()).done;)!function(){var e,r=n.value,o=p.deserialize(r.inputs),i=p.deserialize(r.prod_outputs),t=void 0;try{t=u.targetFunc.apply(u,function(e){if(Array.isArray(e))return c(e)}(e=o)||function(){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}()||h(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())}catch(e){t=e}t=Promise.resolve(t).then(function(t){var n=l.serialize(i)===l.serialize(t);return u.reportCentral(s,r,i,t,n).then(function(e){u.reportLog(r.id,o,i,t,n,e)}),n});a.push(t)}()}catch(e){r.e(e)}finally{r.f()}return u.reportTrialGroup(s),a}).then(function(e){return Promise.all(e).then(function(e){return e.every(function(e){return e})})}).catch(function(e){return f.error(u.config,"Cannot contact Varsnap: "+e),!1})}},{key:"reportCentral",value:function(e,t,n,r,o){var i=this,e={trial_group_id:e.trial_group_id,consumer_token:f.getConfig(this.config,"consumerToken"),snap_id:t.id,test_outputs:l.serialize(r),matches:o.toString(),snap_outputs_formatted:l.serialize_formatted(n),test_outputs_formatted:l.serialize_formatted(r)};return f.ajax("https://www.varsnap.com/api/trial/produce/",e).then(function(e){return!(!e||"ok"!==e.status)&&e.trial_url}).catch(function(e){return f.error(i.config,"Cannot upload test results to Varsnap: "+e),!1})}},{key:"reportLog",value:function(e,t,n,r,o,i){f.log(this.config,""),f.log(this.config,"Testing with Varsnap uuid: "+e),f.log(this.config,"Signature: "+this.signature),f.log(this.config,"Function input args: "+f.limitString(t)),f.log(this.config,"Production function outputs: "+f.limitString(n)),f.log(this.config,"Your function outputs: "+f.limitString(r)),f.log(this.config,"Matching outputs: "+o);e="Cannot upload trial";i&&(e=String(i)),f.log(this.config,"Trial URL: "+e)}},{key:"reportTrialGroup",value:function(e){f.log(this.config,"Trial Group: "+e.trial_group_url)}}],[{key:"deserialize",value:function(e){if(""!==e)return JSON.parse(e)}}]),p);function p(e,t,n){r(this,p),this.targetFunc=e,this.signature=t,this.config=n}function o(e,t,n){r(this,o),this.targetFunc=e,this.signature=t,this.config=n}function n(){r(this,n)}function s(o,e){function t(){for(var e,t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];try{e=o.apply(void 0,n)}catch(e){throw i.produce(n,e),e}return i.produce(n,e),e}var e=f.getSignature(o,e=void 0===e?"":e),i=new l(o,e,s._config),n=new m(o,e,s._config);return t.producer=i,t.consumer=n,t.signature=e,a.push(i),g.push(n),t}(v.varsnap=s)._config=u,s.updateConfig=function(e){for(var t=s._config,n=0,r=Object.keys(s._config);n<r.length;n++){var o=r[n];Object.prototype.hasOwnProperty.call(e,o)&&(t=f.setConfig(t,o,e[o]))}s._config=t},s.reset=function(){f.resetConsumers(),f.resetProducers()},s.version=v.version,s.runTests=function(){var t,i=f.getConsumers();return 0===i.length?Promise.resolve(!0):(t=i[0].config,f.getBranch(t).then(function(e){return{branch:e,consumer_token:f.getConfig(t,"consumerToken"),client:v.clientName}}).then(function(e){return f.ajax("https://www.varsnap.com/api/trial_group/",e)}).then(function(e){return e}).catch(function(e){e=e&&e.response&&e.response.data&&e.response.data.error?e.response.data.error:e.toString();return f.error(t,"Cannot generate a new Trial Group: "+e),{status:"not ok",project_id:"",trial_group_id:"",trial_group_url:""}}).then(function(e){var t,n=[],r=d(i);try{for(r.s();!(t=r.n()).done;){var o=t.value.consume(e);n.push(o)}}catch(e){r.e(e)}finally{r.f()}return Promise.all(n)}).then(function(e){return e.every(function(e){return e})}))}}.call(this)}.call(this,z),v.varsnap})}("undefined"==typeof Varsnap?Varsnap={}:Varsnap);
4
+ !function(t){!function(e){"object"==typeof t&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).varsnap=e()}(function(){function o(n,r){return function(){for(var e=new Array(arguments.length),t=0;t<e.length;t++)e[t]=arguments[t];return n.apply(r,e)}}var t=Object.prototype.toString;function i(e){return Array.isArray(e)}function n(e){return void 0===e}function r(e){return"[object ArrayBuffer]"===t.call(e)}function B(e){return null!==e&&"object"==typeof e}function a(e){if("[object Object]"!==t.call(e))return!1;e=Object.getPrototypeOf(e);return null===e||e===Object.prototype}function s(e,t){if(null!=e)if(i(e="object"!=typeof e?[e]:e))for(var n=0,r=e.length;n<r;n++)t.call(null,e[n],n,e);else for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.call(null,e[o],o,e)}var h={isArray:i,isArrayBuffer:r,isBuffer:function(e){return null!==e&&!n(e)&&null!==e.constructor&&!n(e.constructor)&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)},isFormData:function(e){return"[object FormData]"===t.call(e)},isArrayBufferView:function(e){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&r(e.buffer)},isString:function(e){return"string"==typeof e},isNumber:function(e){return"number"==typeof e},isObject:B,isPlainObject:a,isUndefined:n,isDate:function(e){return"[object Date]"===t.call(e)},isFile:function(e){return"[object File]"===t.call(e)},isBlob:function(e){return"[object Blob]"===t.call(e)},isStream:function(e){return B(e)&&(e=e.pipe,"[object Function]"===t.call(e))},isURLSearchParams:function(e){return"[object URLSearchParams]"===t.call(e)},isStandardBrowserEnv:function(){return("undefined"==typeof navigator||"ReactNative"!==navigator.product&&"NativeScript"!==navigator.product&&"NS"!==navigator.product)&&"undefined"!=typeof window&&"undefined"!=typeof document},forEach:s,merge:function n(){var r={};function e(e,t){a(r[t])&&a(e)?r[t]=n(r[t],e):a(e)?r[t]=n({},e):i(e)?r[t]=e.slice():r[t]=e}for(var t=0,o=arguments.length;t<o;t++)s(arguments[t],e);return r},extend:function(n,e,r){return s(e,function(e,t){n[t]=r&&"function"==typeof e?o(e,r):e}),n},trim:function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}};function q(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var z=function(e,t,n){if(!t)return e;var r,n=n?n(t):h.isURLSearchParams(t)?t.toString():(r=[],h.forEach(t,function(e,t){null!=e&&(h.isArray(e)?t+="[]":e=[e],h.forEach(e,function(e){h.isDate(e)?e=e.toISOString():h.isObject(e)&&(e=JSON.stringify(e)),r.push(q(t)+"="+q(e))}))}),r.join("&"));return n&&(-1!==(t=e.indexOf("#"))&&(e=e.slice(0,t)),e+=(-1===e.indexOf("?")?"?":"&")+n),e},D={};function e(){this.handlers=[]}e.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},e.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},e.prototype.forEach=function(t){h.forEach(this.handlers,function(e){null!==e&&t(e)})};function V(n,r){h.forEach(n,function(e,t){t!==r&&t.toUpperCase()===r.toUpperCase()&&(n[r]=e,delete n[t])})}var u,J,c,D=e,F=function(e,t,n,r,o){return e.config=t,n&&(e.code=n),e.request=r,e.response=o,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,status:this.response&&this.response.status?this.response.status:null}},e},I={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},g=function(e,t,n,r,o){e=new Error(e);return F(e,t,n,r,o)},H=h.isStandardBrowserEnv()?{write:function(e,t,n,r,o,i){var a=[];a.push(e+"="+encodeURIComponent(t)),h.isNumber(n)&&a.push("expires="+new Date(n).toGMTString()),h.isString(r)&&a.push("path="+r),h.isString(o)&&a.push("domain="+o),!0===i&&a.push("secure"),document.cookie=a.join("; ")},read:function(e){e=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return e?decodeURIComponent(e[3]):null},remove:function(e){this.write(e,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}},M=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"],$=h.isStandardBrowserEnv()?(J=/(msie|trident)/i.test(navigator.userAgent),c=document.createElement("a"),u=G(window.location.href),function(e){e=h.isString(e)?G(e):e;return e.protocol===u.protocol&&e.host===u.host}):function(){return!0},m={};function G(e){return J&&(c.setAttribute("href",e),e=c.href),c.setAttribute("href",e),{href:c.href,protocol:c.protocol?c.protocol.replace(/:$/,""):"",host:c.host,search:c.search?c.search.replace(/^\?/,""):"",hash:c.hash?c.hash.replace(/^#/,""):"",hostname:c.hostname,port:c.port,pathname:"/"===c.pathname.charAt(0)?c.pathname:"/"+c.pathname}}function f(e){this.message=e}f.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},f.prototype.__CANCEL__=!0;function X(d){return new Promise(function(i,a){var e,n=d.data,r=d.headers,s=d.responseType;function u(){d.cancelToken&&d.cancelToken.unsubscribe(e),d.signal&&d.signal.removeEventListener("abort",e)}h.isFormData(n)&&delete r["Content-Type"];var c=new XMLHttpRequest;d.auth&&(o=d.auth.username||"",t=d.auth.password?unescape(encodeURIComponent(d.auth.password)):"",r.Authorization="Basic "+btoa(o+":"+t));o=d.baseURL,t=d.url;var t,o,f,l=o&&!/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)?(o=o,(l=t)?o.replace(/\/+$/,"")+"/"+l.replace(/^\/+/,""):o):t;function p(){var e,t,n,r,o;c&&(t="getAllResponseHeaders"in c?(t=c.getAllResponseHeaders(),o={},t&&h.forEach(t.split("\n"),function(e){r=e.indexOf(":"),n=h.trim(e.substr(0,r)).toLowerCase(),r=h.trim(e.substr(r+1)),!n||o[n]&&0<=M.indexOf(n)||(o[n]="set-cookie"===n?(o[n]||[]).concat([r]):o[n]?o[n]+", "+r:r)}),o):null,t={data:s&&"text"!==s&&"json"!==s?c.response:c.responseText,status:c.status,statusText:c.statusText,headers:t,config:d,request:c},e=t.config.validateStatus,t.status&&e&&!e(t.status)?(e=g("Request failed with status code "+t.status,t.config,null,t.request,t),a(e)):i(t),u(),c=null)}c.open(d.method.toUpperCase(),z(l,d.params,d.paramsSerializer),!0),c.timeout=d.timeout,"onloadend"in c?c.onloadend=p:c.onreadystatechange=function(){c&&4===c.readyState&&(0!==c.status||c.responseURL&&0===c.responseURL.indexOf("file:"))&&setTimeout(p)},c.onabort=function(){c&&(a(g("Request aborted",d,"ECONNABORTED",c)),c=null)},c.onerror=function(){a(g("Network Error",d,null,c)),c=null},c.ontimeout=function(){var e=d.timeout?"timeout of "+d.timeout+"ms exceeded":"timeout exceeded",t=d.transitional||I;d.timeoutErrorMessage&&(e=d.timeoutErrorMessage),a(g(e,d,t.clarifyTimeoutError?"ETIMEDOUT":"ECONNABORTED",c)),c=null},h.isStandardBrowserEnv()&&(f=(d.withCredentials||$(l))&&d.xsrfCookieName?H.read(d.xsrfCookieName):void 0)&&(r[d.xsrfHeaderName]=f),"setRequestHeader"in c&&h.forEach(r,function(e,t){void 0===n&&"content-type"===t.toLowerCase()?delete r[t]:c.setRequestHeader(t,e)}),h.isUndefined(d.withCredentials)||(c.withCredentials=!!d.withCredentials),s&&"json"!==s&&(c.responseType=d.responseType),"function"==typeof d.onDownloadProgress&&c.addEventListener("progress",d.onDownloadProgress),"function"==typeof d.onUploadProgress&&c.upload&&c.upload.addEventListener("progress",d.onUploadProgress),(d.cancelToken||d.signal)&&(e=function(e){c&&(a(!e||e.type?new m("canceled"):e),c.abort(),c=null)},d.cancelToken&&d.cancelToken.subscribe(e),d.signal&&(d.signal.aborted?e():d.signal.addEventListener("abort",e))),n=n||null,c.send(n)})}var l,p,d,m=f,y=l={};function v(){throw new Error("setTimeout has not been defined")}function b(){throw new Error("clearTimeout has not been defined")}function W(t){if(p===setTimeout)return setTimeout(t,0);if((p===v||!p)&&setTimeout)return(p=setTimeout)(t,0);try{return p(t,0)}catch(e){try{return p.call(null,t,0)}catch(e){return p.call(this,t,0)}}}try{p="function"==typeof setTimeout?setTimeout:v}catch(e){p=v}try{d="function"==typeof clearTimeout?clearTimeout:b}catch(e){d=b}var w,S=[],T=!1,k=-1;function K(){T&&w&&(T=!1,w.length?S=w.concat(S):k=-1,S.length&&Y())}function Y(){if(!T){var e=W(K);T=!0;for(var t=S.length;t;){for(w=S,S=[];++k<t;)w&&w[k].run();k=-1,t=S.length}w=null,T=!1,function(t){if(d===clearTimeout)return clearTimeout(t);if((d===b||!d)&&clearTimeout)return(d=clearTimeout)(t);try{d(t)}catch(e){try{return d.call(null,t)}catch(e){return d.call(this,t)}}}(e)}}function Q(e,t){this.fun=e,this.array=t}function E(){}y.nextTick=function(e){var t=new Array(arguments.length-1);if(1<arguments.length)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];S.push(new Q(e,t)),1!==S.length||T||W(Y)},Q.prototype.run=function(){this.fun.apply(null,this.array)},y.title="browser",y.browser=!0,y.env={},y.argv=[],y.version="",y.versions={},y.on=E,y.addListener=E,y.once=E,y.off=E,y.removeListener=E,y.removeAllListeners=E,y.emit=E,y.prependListener=E,y.prependOnceListener=E,y.listeners=function(e){return[]},y.binding=function(e){throw new Error("process.binding is not supported")},y.cwd=function(){return"/"},y.chdir=function(e){throw new Error("process.chdir is not supported")},y.umask=function(){return 0};var C={},j=(!function(o){!function(){"use strict";var t={"Content-Type":"application/x-www-form-urlencoded"};function n(e,t){!h.isUndefined(e)&&h.isUndefined(e["Content-Type"])&&(e["Content-Type"]=t)}var e,r={transitional:I,adapter:e="undefined"!=typeof XMLHttpRequest||void 0!==o&&"[object process]"===Object.prototype.toString.call(o)?X:e,transformRequest:[function(e,t){{if(V(t,"Accept"),V(t,"Content-Type"),h.isFormData(e)||h.isArrayBuffer(e)||h.isBuffer(e)||h.isStream(e)||h.isFile(e)||h.isBlob(e))return e;if(h.isArrayBufferView(e))return e.buffer;if(h.isURLSearchParams(e))return n(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString();if(h.isObject(e)||t&&"application/json"===t["Content-Type"]){if(n(t,"application/json"),h.isString(t=e))try{return(0,JSON.parse)(t),h.trim(t)}catch(e){if("SyntaxError"!==e.name)throw e}return(0,JSON.stringify)(t)}return e}}],transformResponse:[function(e){var t=this.transitional||r.transitional,n=t&&t.silentJSONParsing,t=t&&t.forcedJSONParsing,n=!n&&"json"===this.responseType;if(n||t&&h.isString(e)&&e.length)try{return JSON.parse(e)}catch(e){if(n){if("SyntaxError"===e.name)throw F(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 200<=e&&e<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};h.forEach(["delete","get","head"],function(e){r.headers[e]={}}),h.forEach(["post","put","patch"],function(e){r.headers[e]=h.merge(t)}),C=r}.call(this)}.call(this,l),function(t,n,e){var r=this||C;return h.forEach(e,function(e){t=e.call(r,t,n)}),t}),Z=function(e){return!(!e||!e.__CANCEL__)};function O(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new m("canceled")}function ee(t){return O(t),t.headers=t.headers||{},t.data=j.call(t,t.data,t.headers,t.transformRequest),t.headers=h.merge(t.headers.common||{},t.headers[t.method]||{},t.headers),h.forEach(["delete","get","head","post","put","patch","common"],function(e){delete t.headers[e]}),(t.adapter||C.adapter)(t).then(function(e){return O(t),e.data=j.call(t,e.data,e.headers,t.transformResponse),e},function(e){return Z(e)||(O(t),e&&e.response&&(e.response.data=j.call(t,e.response.data,e.response.headers,t.transformResponse))),Promise.reject(e)})}function _(t,n){n=n||{};var r={};function o(e,t){return h.isPlainObject(e)&&h.isPlainObject(t)?h.merge(e,t):h.isPlainObject(t)?h.merge({},t):h.isArray(t)?t.slice():t}function i(e){return h.isUndefined(n[e])?h.isUndefined(t[e])?void 0:o(void 0,t[e]):o(t[e],n[e])}function e(e){if(!h.isUndefined(n[e]))return o(void 0,n[e])}function a(e){return h.isUndefined(n[e])?h.isUndefined(t[e])?void 0:o(void 0,t[e]):o(void 0,n[e])}function s(e){return e in n?o(t[e],n[e]):e in t?o(void 0,t[e]):void 0}var u={url:e,method:e,data:e,baseURL:a,transformRequest:a,transformResponse:a,paramsSerializer:a,timeout:a,timeoutMessage:a,withCredentials:a,adapter:a,responseType:a,xsrfCookieName:a,xsrfHeaderName:a,onUploadProgress:a,onDownloadProgress:a,decompress:a,maxContentLength:a,maxBodyLength:a,transport:a,httpAgent:a,httpsAgent:a,cancelToken:a,socketPath:a,responseEncoding:a,validateStatus:s};return h.forEach(Object.keys(t).concat(Object.keys(n)),function(e){var t=u[e]||i,n=t(e);h.isUndefined(n)&&t!==s||(r[e]=n)}),r}var te,y="0.26.1",x={},ne=(["object","boolean","number","function","string","symbol"].forEach(function(t,n){x[t]=function(e){return typeof e===t||"a"+(n<1?"n ":" ")+t}}),{}),P=(x.transitional=function(r,o,n){function i(e,t){return"[Axios v0.26.1] Transitional option '"+e+"'"+t+(n?". "+n:"")}return function(e,t,n){if(!1===r)throw new Error(i(t," has been removed"+(o?" in "+o:"")));return o&&!ne[t]&&(ne[t]=!0,console.warn(i(t," has been deprecated since v"+o+" and will be removed in the near future"))),!r||r(e,t,n)}},{}),A=(te={assertOptions:function(e,t,n){if("object"!=typeof e)throw new TypeError("options must be an object");for(var r=Object.keys(e),o=r.length;0<o--;){var i=r[o],a=t[i];if(a){var s=e[i],a=void 0===s||a(s,i,e);if(!0!==a)throw new TypeError("option "+i+" must be "+a)}else if(!0!==n)throw Error("Unknown option "+i)}},validators:x}).validators;function N(e){this.defaults=e,this.interceptors={request:new D,response:new D}}function R(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");this.promise=new Promise(function(e){t=e});var t,r=this;this.promise.then(function(e){if(r._listeners){for(var t=r._listeners.length,n=0;n<t;n++)r._listeners[n](e);r._listeners=null}}),this.promise.then=function(e){var t,e=new Promise(function(e){r.subscribe(e),t=e}).then(e);return e.cancel=function(){r.unsubscribe(t)},e},e(function(e){r.reason||(r.reason=new m(e),t(r.reason))})}N.prototype.request=function(e,t){"string"==typeof e?(t=t||{}).url=e:t=e||{},(t=_(this.defaults,t)).method?t.method=t.method.toLowerCase():this.defaults.method?t.method=this.defaults.method.toLowerCase():t.method="get";var e=t.transitional,n=(void 0!==e&&te.assertOptions(e,{silentJSONParsing:A.transitional(A.boolean),forcedJSONParsing:A.transitional(A.boolean),clarifyTimeoutError:A.transitional(A.boolean)},!1),[]),r=!0;this.interceptors.request.forEach(function(e){"function"==typeof e.runWhen&&!1===e.runWhen(t)||(r=r&&e.synchronous,n.unshift(e.fulfilled,e.rejected))});var o,i=[];if(this.interceptors.response.forEach(function(e){i.push(e.fulfilled,e.rejected)}),!r){var a=[ee,void 0];for(Array.prototype.unshift.apply(a,n),a=a.concat(i),o=Promise.resolve(t);a.length;)o=o.then(a.shift(),a.shift());return o}for(var s=t;n.length;){var u=n.shift(),c=n.shift();try{s=u(s)}catch(e){c(e);break}}try{o=ee(s)}catch(e){return Promise.reject(e)}for(;i.length;)o=o.then(i.shift(),i.shift());return o},N.prototype.getUri=function(e){return e=_(this.defaults,e),z(e.url,e.params,e.paramsSerializer).replace(/^\?/,"")},h.forEach(["delete","get","head","options"],function(n){N.prototype[n]=function(e,t){return this.request(_(t||{},{method:n,url:e,data:(t||{}).data}))}}),h.forEach(["post","put","patch"],function(r){N.prototype[r]=function(e,t,n){return this.request(_(n||{},{method:r,url:e,data:t}))}}),P=N,R.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},R.prototype.subscribe=function(e){this.reason?e(this.reason):this._listeners?this._listeners.push(e):this._listeners=[e]},R.prototype.unsubscribe=function(e){this._listeners&&-1!==(e=this._listeners.indexOf(e))&&this._listeners.splice(e,1)},R.source=function(){var t;return{token:new R(function(e){t=e}),cancel:t}};var re=R,U=function t(n){var e=new P(n),r=o(P.prototype.request,e);return h.extend(r,P.prototype,e),h.extend(r,e),r.create=function(e){return t(_(n,e))},r}(C),oe=(U.Axios=P,U.Cancel=m,U.CancelToken=re,U.isCancel=Z,U.VERSION=y,U.all=function(e){return Promise.all(e)},U.spread=function(t){return function(e){return t.apply(null,e)}},U.isAxiosError=function(e){return h.isObject(e)&&!0===e.isAxiosError},U.default=U),ie={},L={};return function(y){!function(){"use strict";function c(e,t){var n,r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=f(e))||t&&e&&"number"==typeof e.length)return r&&(e=r),n=0,{s:t=function(){},n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:t};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 o,i=!0,a=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return i=e.done,e},e:function(e){a=!0,o=e},f:function(){try{i||null==r.return||r.return()}finally{if(a)throw o}}}}function f(e,t){if(e){if("string"==typeof e)return l(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Map"===(n="Object"===n&&e.constructor?e.constructor.name:n)||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?l(e,t):void 0}}function l(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function t(e){return(t="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 r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function e(e,t,n){t&&o(e.prototype,t),n&&o(e,n),Object.defineProperty(e,"prototype",{writable:!1})}Object.defineProperty(L,"__esModule",{value:!0}),L.varsnap=L.clientName=L.version=void 0,L.version="1.8.3",L.clientName="javascript."+L.version;var n={varsnap:!0,env:"development",branch:"",producerToken:"",consumerToken:"",logger:console},a=[],s=[],p=(e(g,null,[{key:"getConfig",value:function(e,t){if(!e)return"";e=e[t];return e?e.toString().toLowerCase():""}},{key:"setConfig",value:function(e,t,n){return"varsnap"===t&&(e[t]=n="string"==typeof n?"true"===n:n),"env"!==t&&"producerToken"!==t&&"consumerToken"!==t&&"branch"!==t||(e[t]=n),"logger"===t&&(e[t]=n),e}},{key:"getSignature",value:function(e,t){var n="",n=""!==t&&void 0!==t?t:(n=(n=e.toString().split("{")[0]).replace(/^\s+|\s+$/g,"")).replace(/,\s+/g,",");return"javascript."+L.version+"."+n}},{key:"ajax",value:function(e,t){e={method:"POST",url:e,headers:{"Content-Type":"application/x-www-form-urlencoded"},data:new URLSearchParams(t).toString(),responseType:"json"};return g.isNode()&&e.headers&&(e.headers["User-Agent"]="varsnap.js"),(0,oe.default)(e).then(function(e){return e.data}).catch(function(e){return e})}},{key:"debug",value:function(e,t){e.logger&&e.logger.debug(t)}},{key:"log",value:function(e,t){e.logger&&e.logger.log(t)}},{key:"error",value:function(e,t){e.logger&&e.logger.error(t)}},{key:"resetProducers",value:function(){a=[]}},{key:"resetConsumers",value:function(){s=[]}},{key:"getProducers",value:function(){return a}},{key:"getConsumers",value:function(){return s}},{key:"limitString",value:function(e){e=String(e);return e.length<=30?e:e.substring(0,30-"...".length)+"..."}},{key:"isNode",value:function(){return"object"===(void 0===y?"undefined":t(y))&&"undefined"==typeof window}},{key:"getBranch",value:function(e){var t=g.getConfig(e,"branch");return t?new Promise(function(e){return e(t)}):g.isNode()?new Promise(function(n){(0,ie.exec)("git rev-parse --abbrev-ref HEAD",function(e,t){return n(t.trim())})}):new Promise(function(e){return e("")})}}]),g),d=(e(i,[{key:"isEnabled",value:function(){return!!this.config.varsnap&&"production"===p.getConfig(this.config,"env")&&!!p.getConfig(this.config,"producerToken")}},{key:"produce",value:function(t,e){var n=this;return this.isEnabled()?(p.debug(this.config,"Sending call to Varsnap"),Promise.resolve(e).then(function(e){e={producer_token:p.getConfig(n.config,"producerToken"),signature:n.signature,inputs:i.serialize(t),prod_outputs:i.serialize(e)};return p.ajax("https://www.varsnap.com/api/snap/produce/",e).then(function(){return!0}).catch(function(e){if(e.response){if(429===e.response.status)return p.error(n.config,"Cannot produce to Varsnap; Signature at rate limit"),!0;404===e.response.status?p.error(n.config,"Cannot produce to Varsnap; check your producer token"):p.error(n.config,e.response.statusText)}return!1})})):new Promise(function(e){return e(!1)})}}],[{key:"serialize",value:function(e){return JSON.stringify(e)}},{key:"serialize_formatted",value:function(e){return JSON.stringify(e,null,2)}}]),i),u=(e(h,[{key:"isEnabled",value:function(){return!!this.config.varsnap&&"development"===p.getConfig(this.config,"env")&&!!p.getConfig(this.config,"consumerToken")}},{key:"consume",value:function(s){var u=this;if(!this.isEnabled())return new Promise(function(e){return p.error(u.config,"Varsnap not enabled for testing"),e(!1)});var o={consumer_token:p.getConfig(this.config,"consumerToken"),signature:this.signature};return p.ajax("https://www.varsnap.com/api/snap/consume/",o).then(function(e){var t=e;if(!t||"ok"!==t.status)return[new Promise(function(e){return p.error(u.config,"Received error from Varsnap: "+t.status),e(!1)})];0===t.results.length&&p.log(u.config,"No snaps found for signature: "+o.signature);var n,a=[],r=c(t.results);try{for(r.s();!(n=r.n()).done;)!function(){var e,r=n.value,o=h.deserialize(r.inputs),i=h.deserialize(r.prod_outputs),t=void 0;try{t=u.targetFunc.apply(u,function(e){if(Array.isArray(e))return l(e)}(e=o)||function(){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}()||f(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())}catch(e){t=e}t=Promise.resolve(t).then(function(t){var n=d.serialize(i)===d.serialize(t);return u.reportCentral(s,r,i,t,n).then(function(e){u.reportLog(r.id,o,i,t,n,e)}),n});a.push(t)}()}catch(e){r.e(e)}finally{r.f()}return u.reportTrialGroup(s),a}).then(function(e){return Promise.all(e).then(function(e){return e.every(function(e){return e})})}).catch(function(e){return p.error(u.config,"Cannot contact Varsnap: "+e),!1})}},{key:"reportCentral",value:function(e,t,n,r,o){var i=this,e={trial_group_id:e.trial_group_id,consumer_token:p.getConfig(this.config,"consumerToken"),snap_id:t.id,test_outputs:d.serialize(r),matches:o.toString(),snap_outputs_formatted:d.serialize_formatted(n),test_outputs_formatted:d.serialize_formatted(r)};return p.ajax("https://www.varsnap.com/api/trial/produce/",e).then(function(e){return!(!e||"ok"!==e.status)&&e.trial_url}).catch(function(e){return p.error(i.config,"Cannot upload test results to Varsnap: "+e),!1})}},{key:"reportLog",value:function(e,t,n,r,o,i){p.log(this.config,""),p.log(this.config,"Testing with Varsnap uuid: "+e),p.log(this.config,"Signature: "+this.signature),p.log(this.config,"Function input args: "+p.limitString(t)),p.log(this.config,"Production function outputs: "+p.limitString(n)),p.log(this.config,"Your function outputs: "+p.limitString(r)),p.log(this.config,"Matching outputs: "+o);e="Cannot upload trial";i&&(e=String(i)),p.log(this.config,"Trial URL: "+e)}},{key:"reportTrialGroup",value:function(e){p.log(this.config,"Trial Group: "+e.trial_group_url)}}],[{key:"deserialize",value:function(e){if(""!==e)return JSON.parse(e)}}]),h);function h(e,t,n){r(this,h),this.targetFunc=e,this.signature=t,this.config=n}function i(e,t,n){r(this,i),this.targetFunc=e,this.signature=t,this.config=n}function g(){r(this,g)}function m(o,e){function t(){for(var e,t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];try{e=o.apply(void 0,n)}catch(e){throw i.produce(n,e),e}return i.produce(n,e),e}var e=p.getSignature(o,e=void 0===e?"":e),i=new d(o,e,m._config),n=new u(o,e,m._config);return t.producer=i,t.consumer=n,t.signature=e,a.push(i),s.push(n),t}(L.varsnap=m)._config=n,m.updateConfig=function(e){for(var t=m._config,n=0,r=Object.keys(m._config);n<r.length;n++){var o=r[n];Object.prototype.hasOwnProperty.call(e,o)&&(t=p.setConfig(t,o,e[o]))}m._config=t},m.reset=function(){p.resetConsumers(),p.resetProducers()},m.version=L.version,m.runTests=function(){var t,i=p.getConsumers();return 0===i.length?Promise.resolve(!0):(t=i[0].config,p.getBranch(t).then(function(e){return{branch:e,consumer_token:p.getConfig(t,"consumerToken"),client:L.clientName}}).then(function(e){return p.ajax("https://www.varsnap.com/api/trial_group/",e)}).then(function(e){return e}).catch(function(e){e=e&&e.response&&e.response.data&&e.response.data.error?e.response.data.error:e.toString();return p.error(t,"Cannot generate a new Trial Group: "+e),{status:"not ok",project_id:"",trial_group_id:"",trial_group_url:""}}).then(function(e){var t,n=[],r=c(i);try{for(r.s();!(t=r.n()).done;){var o=t.value.consume(e);n.push(o)}}catch(e){r.e(e)}finally{r.f()}return Promise.all(n)}).then(function(e){return e.every(function(e){return e})}))}}.call(this)}.call(this,l),L.varsnap})}("undefined"==typeof Varsnap?Varsnap={}:Varsnap);
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "varsnap",
3
- "version": "1.8.2",
3
+ "version": "1.8.3",
4
4
  "description": "Varsnap Client",
5
5
  "main": "dist/built/index.js",
6
6
  "types": "dist/built/index.d.ts",
7
7
  "exports": {
8
8
  ".": {
9
9
  "require": "./dist/built/index.js",
10
- "default": "./dist/built/index.js",
11
- "types": "./dist/built/index.d.ts"
10
+ "types": "./dist/built/index.d.ts",
11
+ "default": "./dist/built/index.js"
12
12
  },
13
13
  "./gitbranchenv": "./dist/built/varsnap/gitbranchenv.js",
14
14
  "./gitbranchenv.js": "./dist/built/varsnap/gitbranchenv.js"
@@ -65,7 +65,7 @@
65
65
  "uglify-js": "^3.12.3"
66
66
  },
67
67
  "dependencies": {
68
- "axios": "^0.25.0"
68
+ "axios": "^0.26.0"
69
69
  },
70
70
  "files": [
71
71
  "dist/varsnap.*",