varsnap 1.6.7 → 1.7.0

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.6.7
2
+ * Varsnap.js v1.7.0
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(){var o=function(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)}},t=Object.prototype.toString;function i(e){return"[object Array]"===t.call(e)}function n(e){return void 0===e}function r(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 l={isArray:i,isArrayBuffer:function(e){return"[object ArrayBuffer]"===t.call(e)},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"undefined"!=typeof FormData&&e instanceof FormData},isArrayBufferView:function(e){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&e.buffer instanceof ArrayBuffer},isString:function(e){return"string"==typeof e},isNumber:function(e){return"number"==typeof e},isObject:r,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 r(e)&&(e=e.pipe,"[object Function]"===t.call(e))},isURLSearchParams:function(e){return"undefined"!=typeof URLSearchParams&&e instanceof URLSearchParams},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.replace(/^\s*/,"").replace(/\s*$/,"")}};function u(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function p(e,t,n){return t&&(n=n?n(t):l.isURLSearchParams(t)?t.toString():(r=[],l.forEach(t,function(e,t){null!=e&&(l.isArray(e)?t+="[]":e=[e],l.forEach(e,function(e){l.isDate(e)?e=e.toISOString():l.isObject(e)&&(e=JSON.stringify(e)),r.push(u(t)+"="+u(e))}))}),r.join("&")))&&(-1!==(t=e.indexOf("#"))&&(e=e.slice(0,t)),e+=(-1===e.indexOf("?")?"?":"&")+n),e;var r}var c={};function e(){this.handlers=[]}e.prototype.use=function(e,t){return this.handlers.push({fulfilled:e,rejected:t}),this.handlers.length-1},e.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},e.prototype.forEach=function(t){l.forEach(this.handlers,function(e){null!==e&&t(e)})};function f(t,n,e){return l.forEach(e,function(e){t=e(t,n)}),t}function d(e){return!(!e||!e.__CANCEL__)}function h(n,r){l.forEach(n,function(e,t){t!==r&&t.toUpperCase()===r.toUpperCase()&&(n[r]=e,delete n[t])})}function g(e,t,n,r,o){return e=new Error(e),n=n,r=r,o=o,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}},e}function m(f){return new Promise(function(s,u){var n=f.data,r=f.headers;l.isFormData(n)&&delete r["Content-Type"];var c=new XMLHttpRequest;f.auth&&(i=f.auth.username||"",e=f.auth.password?unescape(encodeURIComponent(f.auth.password)):"",r.Authorization="Basic "+btoa(i+":"+e));var e,t,o,i=(t=f.baseURL,i=f.url,t&&!/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(i)?(e=t,(t=i)?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e):i);if(c.open(f.method.toUpperCase(),p(i,f.params,f.paramsSerializer),!0),c.timeout=f.timeout,c.onreadystatechange=function(){var e,t,n,r,o,i,a;c&&4===c.readyState&&(0!==c.status||c.responseURL&&0===c.responseURL.indexOf("file:"))&&(t="getAllResponseHeaders"in c?(r=c.getAllResponseHeaders(),a={},r&&l.forEach(r.split("\n"),function(e){i=e.indexOf(":"),o=l.trim(e.substr(0,i)).toLowerCase(),i=l.trim(e.substr(i+1)),o&&(a[o]&&0<=k.indexOf(o)||(a[o]="set-cookie"===o?(a[o]||[]).concat([i]):a[o]?a[o]+", "+i:i))}),a):null,n={data:f.responseType&&"text"!==f.responseType?c.response:c.responseText,status:c.status,statusText:c.statusText,headers:t,config:f,request:c},e=s,r=u,n=(t=n).config.validateStatus,t.status&&n&&!n(t.status)?r(g("Request failed with status code "+t.status,t.config,null,t.request,t)):e(t),c=null)},c.onabort=function(){c&&(u(g("Request aborted",f,"ECONNABORTED",c)),c=null)},c.onerror=function(){u(g("Network Error",f,null,c)),c=null},c.ontimeout=function(){var e="timeout of "+f.timeout+"ms exceeded";f.timeoutErrorMessage&&(e=f.timeoutErrorMessage),u(g(e,f,"ECONNABORTED",c)),c=null},l.isStandardBrowserEnv()&&(o=(f.withCredentials||j(i))&&f.xsrfCookieName?T.read(f.xsrfCookieName):void 0)&&(r[f.xsrfHeaderName]=o),"setRequestHeader"in c&&l.forEach(r,function(e,t){void 0===n&&"content-type"===t.toLowerCase()?delete r[t]:c.setRequestHeader(t,e)}),l.isUndefined(f.withCredentials)||(c.withCredentials=!!f.withCredentials),f.responseType)try{c.responseType=f.responseType}catch(e){if("json"!==f.responseType)throw e}"function"==typeof f.onDownloadProgress&&c.addEventListener("progress",f.onDownloadProgress),"function"==typeof f.onUploadProgress&&c.upload&&c.upload.addEventListener("progress",f.onUploadProgress),f.cancelToken&&f.cancelToken.promise.then(function(e){c&&(c.abort(),u(e),c=null)}),c.send(n=n||null)})}var y,v,w,b,C,S,c=e,T=l.isStandardBrowserEnv()?{write:function(e,t,n,r,o,i){var a=[];a.push(e+"="+encodeURIComponent(t)),l.isNumber(n)&&a.push("expires="+new Date(n).toGMTString()),l.isString(r)&&a.push("path="+r),l.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(){}},k=["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"],j=l.isStandardBrowserEnv()?(C=/(msie|trident)/i.test(navigator.userAgent),S=document.createElement("a"),b=A(window.location.href),function(e){e=l.isString(e)?A(e):e;return e.protocol===b.protocol&&e.host===b.host}):function(){return!0},E=y={};function A(e){return C&&(S.setAttribute("href",e),e=S.href),S.setAttribute("href",e),{href:S.href,protocol:S.protocol?S.protocol.replace(/:$/,""):"",host:S.host,search:S.search?S.search.replace(/^\?/,""):"",hash:S.hash?S.hash.replace(/^#/,""):"",hostname:S.hostname,port:S.port,pathname:"/"===S.pathname.charAt(0)?S.pathname:"/"+S.pathname}}function x(){throw new Error("setTimeout has not been defined")}function O(){throw new Error("clearTimeout has not been defined")}function R(t){if(v===setTimeout)return setTimeout(t,0);if((v===x||!v)&&setTimeout)return v=setTimeout,setTimeout(t,0);try{return v(t,0)}catch(e){try{return v.call(null,t,0)}catch(e){return v.call(this,t,0)}}}!function(){try{v="function"==typeof setTimeout?setTimeout:x}catch(e){v=x}try{w="function"==typeof clearTimeout?clearTimeout:O}catch(e){w=O}}();var _,P=[],N=!1,U=-1;function L(){N&&_&&(N=!1,_.length?P=_.concat(P):U=-1,P.length&&B())}function B(){if(!N){var e=R(L);N=!0;for(var t=P.length;t;){for(_=P,P=[];++U<t;)_&&_[U].run();U=-1,t=P.length}_=null,N=!1,function(t){if(w===clearTimeout)return clearTimeout(t);if((w===O||!w)&&clearTimeout)return w=clearTimeout,clearTimeout(t);try{w(t)}catch(e){try{return w.call(null,t)}catch(e){return w.call(this,t)}}}(e)}}function q(e,t){this.fun=e,this.array=t}function z(){}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];P.push(new q(e,t)),1!==P.length||N||R(B)},q.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=z,E.addListener=z,E.once=z,E.off=z,E.removeListener=z,E.removeAllListeners=z,E.emit=z,E.prependListener=z,E.prependOnceListener=z,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 I={};function D(e){e.cancelToken&&e.cancelToken.throwIfRequested()}!function(o){!function(){"use strict";var t={"Content-Type":"application/x-www-form-urlencoded"};function n(e,t){!l.isUndefined(e)&&l.isUndefined(e["Content-Type"])&&(e["Content-Type"]=t)}var e,r={adapter:e="undefined"!=typeof XMLHttpRequest||void 0!==o&&"[object process]"===Object.prototype.toString.call(o)?m:e,transformRequest:[function(e,t){return h(t,"Accept"),h(t,"Content-Type"),l.isFormData(e)||l.isArrayBuffer(e)||l.isBuffer(e)||l.isStream(e)||l.isFile(e)||l.isBlob(e)?e:l.isArrayBufferView(e)?e.buffer:l.isURLSearchParams(e)?(n(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):l.isObject(e)?(n(t,"application/json;charset=utf-8"),JSON.stringify(e)):e}],transformResponse:[function(e){if("string"==typeof e)try{e=JSON.parse(e)}catch(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, */*"}}};l.forEach(["delete","get","head"],function(e){r.headers[e]={}}),l.forEach(["post","put","patch"],function(e){r.headers[e]=l.merge(t)}),I=r}.call(this)}.call(this,y);function F(t){return D(t),t.headers=t.headers||{},t.data=f(t.data,t.headers,t.transformRequest),t.headers=l.merge(t.headers.common||{},t.headers[t.method]||{},t.headers),l.forEach(["delete","get","head","post","put","patch","common"],function(e){delete t.headers[e]}),(t.adapter||I.adapter)(t).then(function(e){return D(t),e.data=f(e.data,e.headers,t.transformResponse),e},function(e){return d(e)||(D(t),e&&e.response&&(e.response.data=f(e.response.data,e.response.headers,t.transformResponse))),Promise.reject(e)})}function V(t,n){n=n||{};var r={},e=["url","method","data"],o=["headers","auth","proxy","params"],i=["baseURL","transformRequest","transformResponse","paramsSerializer","timeout","timeoutMessage","withCredentials","adapter","responseType","xsrfCookieName","xsrfHeaderName","onUploadProgress","onDownloadProgress","decompress","maxContentLength","maxBodyLength","maxRedirects","transport","httpAgent","httpsAgent","cancelToken","socketPath","responseEncoding"],a=["validateStatus"];function s(e,t){return l.isPlainObject(e)&&l.isPlainObject(t)?l.merge(e,t):l.isPlainObject(t)?l.merge({},t):l.isArray(t)?t.slice():t}function u(e){l.isUndefined(n[e])?l.isUndefined(t[e])||(r[e]=s(void 0,t[e])):r[e]=s(t[e],n[e])}l.forEach(e,function(e){l.isUndefined(n[e])||(r[e]=s(void 0,n[e]))}),l.forEach(o,u),l.forEach(i,function(e){l.isUndefined(n[e])?l.isUndefined(t[e])||(r[e]=s(void 0,t[e])):r[e]=s(void 0,n[e])}),l.forEach(a,function(e){e in n?r[e]=s(t[e],n[e]):e in t&&(r[e]=s(void 0,t[e]))});var c=e.concat(o).concat(i).concat(a),a=Object.keys(t).concat(Object.keys(n)).filter(function(e){return-1===c.indexOf(e)});return l.forEach(a,u),r}var H={};function M(e){this.defaults=e,this.interceptors={request:new c,response:new c}}M.prototype.request=function(e){"string"==typeof e?(e=arguments[1]||{}).url=arguments[0]:e=e||{},(e=V(this.defaults,e)).method?e.method=e.method.toLowerCase():this.defaults.method?e.method=this.defaults.method.toLowerCase():e.method="get";var t=[F,void 0],n=Promise.resolve(e);for(this.interceptors.request.forEach(function(e){t.unshift(e.fulfilled,e.rejected)}),this.interceptors.response.forEach(function(e){t.push(e.fulfilled,e.rejected)});t.length;)n=n.then(t.shift(),t.shift());return n},M.prototype.getUri=function(e){return e=V(this.defaults,e),p(e.url,e.params,e.paramsSerializer).replace(/^\?/,"")},l.forEach(["delete","get","head","options"],function(n){M.prototype[n]=function(e,t){return this.request(V(t||{},{method:n,url:e,data:(t||{}).data}))}}),l.forEach(["post","put","patch"],function(r){M.prototype[r]=function(e,t,n){return this.request(V(n||{},{method:r,url:e,data:t}))}});var H=M,J={};function $(e){this.message=e}function G(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 J(e),t(n.reason))})}$.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},$.prototype.__CANCEL__=!0,J=$,G.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},G.source=function(){var t;return{token:new G(function(e){t=e}),cancel:t}};E=G;function X(e){var t=new H(e),e=o(H.prototype.request,t);return l.extend(e,H.prototype,t),l.extend(e,t),e}var K=X(I);K.Axios=H,K.create=function(e){return X(V(K.defaults,e))},K.Cancel=J,K.CancelToken=E,K.isCancel=d,K.all=function(e){return Promise.all(e)},K.spread=function(t){return function(e){return t.apply(null,e)}},K.isAxiosError=function(e){return"object"==typeof e&&!0===e.isAxiosError};var Y=K.default=K;Array.isArray;function Q(e){switch(typeof e){case"string":return e;case"boolean":return e?"true":"false";case"number":return isFinite(e)?e:"";default:return""}}var W=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)};function Z(e,t){if(e.map)return e.map(t);for(var n=[],r=0;r<e.length;r++)n.push(t(e[r],r));return n}var ee=Object.keys||function(e){var t,n=[];for(t in e)Object.prototype.hasOwnProperty.call(e,t)&&n.push(t);return n},te=function(n,r,o,e){return r=r||"&",o=o||"=","object"==typeof(n=null===n?void 0:n)?Z(ee(n),function(e){var t=encodeURIComponent(Q(e))+o;return W(n[e])?Z(n[e],function(e){return t+encodeURIComponent(Q(e))}).join(r):t+encodeURIComponent(Q(n[e]))}).join(r):e?encodeURIComponent(Q(e))+o+encodeURIComponent(Q(n)):""},ne={};return function(y){!function(){"use strict";function c(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=f(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,t=function(){};return{s:t,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},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(){n=n.call(e)},n:function(){var e=n.next();return i=e.done,e},e:function(e){a=!0,o=e},f:function(){try{i||null==n.return||n.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 n(e){return(n="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){return t&&o(e.prototype,t),n&&o(e,n),e}Object.defineProperty(ne,"__esModule",{value:!0}),ne.varsnap=ne.clientName=ne.version=void 0,ne.version="v1.6.7",ne.clientName="javascript."+ne.version;var t={varsnap:!0,env:"development",producerToken:"",consumerToken:"",logger:console},a=[],s=[],p=(e(g,null,[{key:"getConfig",value:function(e,t){if(!e)return"";t=e[t];return t?t.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||(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."+ne.version+"."+n}},{key:"ajax",value:function(e,t){t={method:"POST",url:e,headers:{"Content-Type":"application/x-www-form-urlencoded"},data:te(t),responseType:"json"};return"object"===(void 0===y?"undefined":n(y))&&"undefined"==typeof window&&(t.headers["User-Agent"]="varsnap.js"),Y.default(t).then(function(e){return e.data})}},{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)+"..."}}]),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,r={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,snap_outputs_formatted:d.serialize_formatted(n),test_outputs_formatted:d.serialize_formatted(r)};return p.ajax("https://www.varsnap.com/api/trial/produce/",r).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);o="Cannot upload trial";i&&(o=String(i)),p.log(this.config,"Trial URL: "+o)}},{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){var t=p.getSignature(o,e=void 0===e?"":e),i=new d(o,t,m._config),n=new u(o,t,m._config),e=function(){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};return e.producer=i,e.consumer=n,e.signature=t,a.push(i),s.push(n),e}(ne.varsnap=m)._config=t,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=ne.version,m.runTests=function(){var t,e,i=p.getConsumers();return 0===i.length?Promise.resolve(!0):(t=i[0].config,e={consumer_token:p.getConfig(t,"consumerToken"),client:ne.clientName},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,y),ne.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 e(t){var n;return function(e){return n||t(n={exports:{},parent:e},n.exports),n.exports}}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 n=e(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)?a({}):e,transformRequest:[function(e,t){return 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)?e:h.isArrayBufferView(e)?e.buffer:h.isURLSearchParams(e)?(n(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):h.isObject(e)||t&&"application/json"===t["Content-Type"]?(n(t,"application/json"),function(e){if(h.isString(e))try{return(0,JSON.parse)(e),h.trim(e)}catch(e){if("SyntaxError"!==e.name)throw e}return(0,JSON.stringify)(e)}(e)):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 b(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,N)}),a=e(function(e,t){"use strict";var d=n({});e.exports=function(p){return new Promise(function(t,n){var e,r=p.data,o=p.headers,i=p.responseType;function a(){p.cancelToken&&p.cancelToken.unsubscribe(e),p.signal&&p.signal.removeEventListener("abort",e)}h.isFormData(r)&&delete o["Content-Type"];var s,u=new XMLHttpRequest;p.auth&&(s=p.auth.username||"",f=p.auth.password?unescape(encodeURIComponent(p.auth.password)):"",o.Authorization="Basic "+btoa(s+":"+f));var c,f=k(p.baseURL,p.url);function l(){var e;u&&(e="getAllResponseHeaders"in u?j(u.getAllResponseHeaders()):null,e={data:i&&"text"!==i&&"json"!==i?u.response:u.responseText,status:u.status,statusText:u.statusText,headers:e,config:p,request:u},S(function(e){t(e),a()},function(e){n(e),a()},e),u=null)}u.open(p.method.toUpperCase(),g(f,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(w("Request aborted",p,"ECONNABORTED",u)),u=null)},u.onerror=function(){n(w("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(w(e,p,t.clarifyTimeoutError?"ETIMEDOUT":"ECONNABORTED",u)),u=null},h.isStandardBrowserEnv()&&(c=(p.withCredentials||E(f))&&p.xsrfCookieName?T.read(p.xsrfCookieName):void 0)&&(o[p.xsrfHeaderName]=c),"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),i&&"json"!==i&&(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 O("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 i(e){return"[object Array]"===t.call(e)}function r(e){return void 0===e}function s(e){return null!==e&&"object"==typeof e}function u(e){if("[object Object]"!==t.call(e))return!1;e=Object.getPrototypeOf(e);return null===e||e===Object.prototype}function c(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:function(e){return"[object ArrayBuffer]"===t.call(e)},isBuffer:function(e){return null!==e&&!r(e)&&null!==e.constructor&&!r(e.constructor)&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)},isFormData:function(e){return"undefined"!=typeof FormData&&e instanceof FormData},isArrayBufferView:function(e){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&e.buffer instanceof ArrayBuffer},isString:function(e){return"string"==typeof e},isNumber:function(e){return"number"==typeof e},isObject:s,isPlainObject:u,isUndefined:r,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 s(e)&&(e=e.pipe,"[object Function]"===t.call(e))},isURLSearchParams:function(e){return"undefined"!=typeof URLSearchParams&&e instanceof URLSearchParams},isStandardBrowserEnv:function(){return("undefined"==typeof navigator||"ReactNative"!==navigator.product&&"NativeScript"!==navigator.product&&"NS"!==navigator.product)&&"undefined"!=typeof window&&"undefined"!=typeof document},forEach:c,merge:function n(){var r={};function e(e,t){u(r[t])&&u(e)?r[t]=n(r[t],e):u(e)?r[t]=n({},e):i(e)?r[t]=e.slice():r[t]=e}for(var t=0,o=arguments.length;t<o;t++)c(arguments[t],e);return r},extend:function(n,e,r){return c(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 f(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var g=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(f(t)+"="+f(e))}))}),r.join("&"));return n&&(-1!==(t=e.indexOf("#"))&&(e=e.slice(0,t)),e+=(-1===e.indexOf("?")?"?":"&")+n),e},l={};function p(){this.handlers=[]}p.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},p.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},p.prototype.forEach=function(t){h.forEach(this.handlers,function(e){null!==e&&t(e)})};var d,m,y,l=p,v=function(n,r){h.forEach(n,function(e,t){t!==r&&t.toUpperCase()===r.toUpperCase()&&(n[r]=e,delete n[t])})},b=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},w=function(e,t,n,r,o){e=new Error(e);return b(e,t,n,r,o)},S=function(e,t,n){var r=n.config.validateStatus;n.status&&r&&!r(n.status)?t(w("Request failed with status code "+n.status,n.config,null,n.request,n)):e(n)},T=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(){}},k=function(e,t){return e&&!/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(t)?(n=e,(e=t)?n.replace(/\/+$/,"")+"/"+e.replace(/^\/+/,""):n):t;var n},C=["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"],j=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<=C.indexOf(t)||(r[t]="set-cookie"===t?(r[t]||[]).concat([n]):r[t]?r[t]+", "+n:n))}),r},E=h.isStandardBrowserEnv()?(m=/(msie|trident)/i.test(navigator.userAgent),y=document.createElement("a"),d=x(window.location.href),function(e){e=h.isString(e)?x(e):e;return e.protocol===d.protocol&&e.host===d.host}):function(){return!0},O={};function x(e){return m&&(y.setAttribute("href",e),e=y.href),y.setAttribute("href",e),{href:y.href,protocol:y.protocol?y.protocol.replace(/:$/,""):"",host:y.host,search:y.search?y.search.replace(/^\?/,""):"",hash:y.hash?y.hash.replace(/^#/,""):"",hostname:y.hostname,port:y.port,pathname:"/"===y.pathname.charAt(0)?y.pathname:"/"+y.pathname}}function A(e){this.message=e}A.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},A.prototype.__CANCEL__=!0;var _,P,O=A,N={},R=N={};function U(){throw new Error("setTimeout has not been defined")}function L(){throw new Error("clearTimeout has not been defined")}function B(t){if(_===setTimeout)return setTimeout(t,0);if((_===U||!_)&&setTimeout)return _=setTimeout,setTimeout(t,0);try{return _(t,0)}catch(e){try{return _.call(null,t,0)}catch(e){return _.call(this,t,0)}}}!function(){try{_="function"==typeof setTimeout?setTimeout:U}catch(e){_=U}try{P="function"==typeof clearTimeout?clearTimeout:L}catch(e){P=L}}();var q,z=[],I=!1,D=-1;function F(){I&&q&&(I=!1,q.length?z=q.concat(z):D=-1,z.length&&V())}function V(){if(!I){var e=B(F);I=!0;for(var t=z.length;t;){for(q=z,z=[];++D<t;)q&&q[D].run();D=-1,t=z.length}q=null,I=!1,function(t){if(P===clearTimeout)return clearTimeout(t);if((P===L||!P)&&clearTimeout)return P=clearTimeout,clearTimeout(t);try{P(t)}catch(e){try{return P.call(null,t)}catch(e){return P.call(this,t)}}}(e)}}function J(e,t){this.fun=e,this.array=t}function H(){}R.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];z.push(new J(e,t)),1!==z.length||I||B(V)},J.prototype.run=function(){this.fun.apply(null,this.array)},R.title="browser",R.browser=!0,R.env={},R.argv=[],R.version="",R.versions={},R.on=H,R.addListener=H,R.once=H,R.off=H,R.removeListener=H,R.removeAllListeners=H,R.emit=H,R.prependListener=H,R.prependOnceListener=H,R.listeners=function(e){return[]},R.binding=function(e){throw new Error("process.binding is not supported")},R.cwd=function(){return"/"},R.chdir=function(e){throw new Error("process.chdir is not supported")},R.umask=function(){return 0};var M=n({}),$=function(t,n,e){var r=this||M;return h.forEach(e,function(e){t=e.call(r,t,n)}),t},G=function(e){return!(!e||!e.__CANCEL__)},X=n({});function W(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new O("canceled")}function K(t){return W(t),t.headers=t.headers||{},t.data=$.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||X.adapter)(t).then(function(e){return W(t),e.data=$.call(t,e.data,e.headers,t.transformResponse),e},function(e){return G(e)||(W(t),e&&e.response&&(e.response.data=$.call(t,e.response.data,e.response.headers,t.transformResponse))),Promise.reject(e)})}function Y(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 Q,Z="0.24.0",ee={};["object","boolean","number","function","string","symbol"].forEach(function(t,n){ee[t]=function(e){return typeof e===t||"a"+(n<1?"n ":" ")+t}});var te={};ee.transitional=function(r,o,n){function i(e,t){return"[Axios v0.24.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&&!te[t]&&(te[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)}};var ne={},re=(Q={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],s=void 0===s||a(s,i,e);if(!0!==s)throw new TypeError("option "+i+" must be "+s)}else if(!0!==n)throw Error("Unknown option "+i)}},validators:ee}).validators;function oe(e){this.defaults=e,this.interceptors={request:new l,response:new l}}function ie(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");var t;this.promise=new Promise(function(e){t=e});var 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 O(e),t(r.reason))})}oe.prototype.request=function(t){"string"==typeof t?(t=arguments[1]||{}).url=arguments[0]:t=t||{},(t=Y(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;void 0!==e&&Q.assertOptions(e,{silentJSONParsing:re.transitional(re.boolean),forcedJSONParsing:re.transitional(re.boolean),clarifyTimeoutError:re.transitional(re.boolean)},!1);var n=[],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=[K,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=K(s)}catch(e){return Promise.reject(e)}for(;i.length;)o=o.then(i.shift(),i.shift());return o},oe.prototype.getUri=function(e){return e=Y(this.defaults,e),g(e.url,e.params,e.paramsSerializer).replace(/^\?/,"")},h.forEach(["delete","get","head","options"],function(n){oe.prototype[n]=function(e,t){return this.request(Y(t||{},{method:n,url:e,data:(t||{}).data}))}}),h.forEach(["post","put","patch"],function(r){oe.prototype[r]=function(e,t,n){return this.request(Y(n||{},{method:r,url:e,data:t}))}}),ne=oe,ie.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},ie.prototype.subscribe=function(e){this.reason?e(this.reason):this._listeners?this._listeners.push(e):this._listeners=[e]},ie.prototype.unsubscribe=function(e){!this._listeners||-1!==(e=this._listeners.indexOf(e))&&this._listeners.splice(e,1)},ie.source=function(){var t;return{token:new ie(function(e){t=e}),cancel:t}};var ae=ie,R=function t(n){var e=new ne(n),r=o(ne.prototype.request,e);return h.extend(r,ne.prototype,e),h.extend(r,e),r.create=function(e){return t(Y(n,e))},r}(n({}));R.Axios=ne,R.Cancel=O,R.CancelToken=ae,R.isCancel=G,R.VERSION=Z,R.all=function(e){return Promise.all(e)},R.spread=function(t){return function(e){return t.apply(null,e)}},R.isAxiosError=function(e){return"object"==typeof e&&!0===e.isAxiosError};var se=R.default=R;Array.isArray;function ue(e){switch(typeof e){case"string":return e;case"boolean":return e?"true":"false";case"number":return isFinite(e)?e:"";default:return""}}var ce=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)};function fe(e,t){if(e.map)return e.map(t);for(var n=[],r=0;r<e.length;r++)n.push(t(e[r],r));return n}var le=Object.keys||function(e){var t,n=[];for(t in e)Object.prototype.hasOwnProperty.call(e,t)&&n.push(t);return n},pe=function(n,r,o,e){return r=r||"&",o=o||"=","object"==typeof(n=null===n?void 0:n)?fe(le(n),function(e){var t=encodeURIComponent(ue(e))+o;return ce(n[e])?fe(n[e],function(e){return t+encodeURIComponent(ue(e))}).join(r):t+encodeURIComponent(ue(n[e]))}).join(r):e?encodeURIComponent(ue(e))+o+encodeURIComponent(ue(n)):""},de={},he={};return function(y){!function(){"use strict";function c(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=f(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,t=function(){};return{s:t,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},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(){n=n.call(e)},n:function(){var e=n.next();return i=e.done,e},e:function(e){a=!0,o=e},f:function(){try{i||null==n.return||n.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){return t&&o(e.prototype,t),n&&o(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}Object.defineProperty(he,"__esModule",{value:!0}),he.varsnap=he.clientName=he.version=void 0,he.version="1.7.0",he.clientName="javascript."+he.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"";t=e[t];return t?t.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."+he.version+"."+n}},{key:"ajax",value:function(e,t){t={method:"POST",url:e,headers:{"Content-Type":"application/x-www-form-urlencoded"},data:pe(t),responseType:"json"};return g.isNode()&&t.headers&&(t.headers["User-Agent"]="varsnap.js"),(0,se.default)(t).then(function(e){return e.data})}},{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(r){(0,de.exec)("git rev-parse --abbrev-ref HEAD",function(e,t,n){return r(t)})}):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,r={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,snap_outputs_formatted:d.serialize_formatted(n),test_outputs_formatted:d.serialize_formatted(r)};return p.ajax("https://www.varsnap.com/api/trial/produce/",r).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);o="Cannot upload trial";i&&(o=String(i)),p.log(this.config,"Trial URL: "+o)}},{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 n=p.getSignature(o,e=void 0===e?"":e),i=new d(o,n,m._config),e=new u(o,n,m._config);return t.producer=i,t.consumer=e,t.signature=n,a.push(i),s.push(e),t}(he.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=he.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:he.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,N),he.varsnap})}("undefined"==typeof Varsnap?Varsnap={}:Varsnap);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "varsnap",
3
- "version": "1.6.7",
3
+ "version": "1.7.0",
4
4
  "description": "Varsnap Client",
5
5
  "main": "dist/built/index.js",
6
6
  "types": "dist/built/index.d.ts",
@@ -34,28 +34,29 @@
34
34
  "@istanbuljs/nyc-config-typescript": "^1.0.1",
35
35
  "@types/browserify": "^12.0.36",
36
36
  "@types/chai": "^4.2.14",
37
- "@types/mocha": "^8.2.0",
38
- "@typescript-eslint/eslint-plugin": "^4.11.1",
39
- "@typescript-eslint/parser": "^4.11.1",
37
+ "@types/mocha": "^9.0.0",
38
+ "@types/sinon": "^10.0.4",
39
+ "@typescript-eslint/eslint-plugin": "^5.6.0",
40
+ "@typescript-eslint/parser": "^5.6.0",
40
41
  "babel-plugin-istanbul": "^6.0.0",
41
42
  "babelify": "^10.0.0",
42
43
  "browserify": "^17.0.0",
43
44
  "chai": "^4.2.0",
44
- "eslint": "^7.16.0",
45
- "mocha": "^8.2.1",
46
- "mochify": "^7.0.0",
45
+ "eslint": "^8.4.1",
46
+ "mocha": "^9.1.3",
47
+ "mochify": "^9.0.0",
47
48
  "nyc": "^15.1.0",
48
- "sinon": "^10.0.0",
49
+ "sinon": "^12.0.1",
49
50
  "source-map-support": "^0.5.19",
50
51
  "tinyify": "^3.0.0",
51
- "ts-mocha": "^8.0.0",
52
- "ts-node": "^9.1.1",
52
+ "ts-mocha": "albertyw/ts-mocha",
53
+ "ts-node": "^10.1.0",
53
54
  "tsify": "^5.0.2",
54
55
  "typescript": "^4.1.3",
55
56
  "uglify-js": "^3.12.3"
56
57
  },
57
58
  "dependencies": {
58
- "axios": "^0.21.1"
59
+ "axios": "^0.24.0"
59
60
  },
60
61
  "files": [
61
62
  "dist/varsnap.*",