varsnap 1.8.0 → 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.
- package/CHANGELOG.md +22 -0
- package/dist/built/varsnap/core.d.ts +2 -4
- package/dist/built/varsnap/core.js +7 -4
- package/dist/built/varsnap/gitbranchenv.d.ts +1 -1
- package/dist/built/varsnap/gitbranchenv.js +2 -1
- package/dist/varsnap.js +376 -412
- package/dist/varsnap.min.js +2 -2
- package/package.json +8 -3
package/dist/varsnap.min.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Varsnap.js v1.8.
|
|
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 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.8.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(n){(0,de.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,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);
|
|
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,10 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "varsnap",
|
|
3
|
-
"version": "1.8.
|
|
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
|
+
".": {
|
|
9
|
+
"require": "./dist/built/index.js",
|
|
10
|
+
"types": "./dist/built/index.d.ts",
|
|
11
|
+
"default": "./dist/built/index.js"
|
|
12
|
+
},
|
|
8
13
|
"./gitbranchenv": "./dist/built/varsnap/gitbranchenv.js",
|
|
9
14
|
"./gitbranchenv.js": "./dist/built/varsnap/gitbranchenv.js"
|
|
10
15
|
},
|
|
@@ -50,7 +55,7 @@
|
|
|
50
55
|
"mocha": "^9.1.3",
|
|
51
56
|
"mochify": "^9.0.0",
|
|
52
57
|
"nyc": "^15.1.0",
|
|
53
|
-
"sinon": "^
|
|
58
|
+
"sinon": "^13.0.0",
|
|
54
59
|
"source-map-support": "^0.5.19",
|
|
55
60
|
"tinyify": "^3.0.0",
|
|
56
61
|
"ts-mocha": "albertyw/ts-mocha",
|
|
@@ -60,7 +65,7 @@
|
|
|
60
65
|
"uglify-js": "^3.12.3"
|
|
61
66
|
},
|
|
62
67
|
"dependencies": {
|
|
63
|
-
"axios": "^0.
|
|
68
|
+
"axios": "^0.26.0"
|
|
64
69
|
},
|
|
65
70
|
"files": [
|
|
66
71
|
"dist/varsnap.*",
|