@commercetools/sdk-middleware-http
Advanced tools
Comparing version 4.0.10 to 5.0.0
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : | ||
typeof define === 'function' && define.amd ? define(['exports'], factory) : | ||
(factory((global.CommercetoolsSdkMiddlewareHttp = {}))); | ||
}(this, (function (exports) { 'use strict'; | ||
(global = global || self, factory(global.CommercetoolsSdkMiddlewareHttp = {})); | ||
}(this, function (exports) { 'use strict'; | ||
@@ -396,3 +396,3 @@ function _typeof(obj) { | ||
}))); | ||
})); | ||
//# sourceMappingURL=commercetools-sdk-middleware-http.umd.js.map |
@@ -1,2 +0,2 @@ | ||
!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):r(e.CommercetoolsSdkMiddlewareHttp={})}(this,function(e){"use strict";function m(e){return(m="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 q(o){for(var e=1;e<arguments.length;e++){var i=null!=arguments[e]?arguments[e]:{},r=Object.keys(i);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(i).filter(function(e){return Object.getOwnPropertyDescriptor(i,e).enumerable}))),r.forEach(function(e){var r,t,n;r=o,n=i[t=e],t in r?Object.defineProperty(r,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):r[t]=n})}return o}function S(e,r){if(null==e)return{};var t,n,o=function(e,r){if(null==e)return{};var t,n,o={},i=Object.keys(e);for(n=0;n<i.length;n++)t=i[n],0<=r.indexOf(t)||(o[t]=e[t]);return o}(e,r);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)t=i[n],0<=r.indexOf(t)||Object.prototype.propertyIsEnumerable.call(e,t)&&(o[t]=e[t])}return o}var r=require("./_global"),i=require("./_inherit-if-required"),t=require("./_object-dp").f,n=require("./_object-gopn").f,a=require("./_is-regexp"),u=require("./_flags"),s=r.RegExp,c=s,l=s.prototype,o=/a/g,f=/a/g,p=new s(o)!==o;if(require("./_descriptors")&&(!p||require("./_fails")(function(){return f[require("./_wks")("match")]=!1,s(o)!=o||s(f)==f||"/a/i"!=s(o,"i")}))){s=function(e,r){var t=this instanceof s,n=a(e),o=void 0===r;return!t&&n&&e.constructor===s&&o?e:i(p?new c(n&&!o?e.source:e,r):c((n=e instanceof s)?e.source:e,n&&o?u.call(e):r),t?this:l,s)};for(var d=function(r){r in s||t(s,r,{configurable:!0,get:function(){return c[r]},set:function(e){c[r]=e}})},h=n(c),y=0;h.length>y;)d(h[y++]);(l.constructor=s).prototype=l,require("./_redefine")(r,"RegExp",s)}require("./_set-species")("RegExp"),require("./_fix-re-wks")("match",1,function(n,o,e){return[function(e){var r=n(this),t=null==e?void 0:e[o];return void 0!==t?t.call(e,r):new RegExp(e)[o](String(r))},e]});var g=require("./_object-dp").f,v=Function.prototype,b=/^\s*function ([^ (]*)/,_="name";_ in v||require("./_descriptors")&&g(v,_,{configurable:!0,get:function(){try{return(""+this).match(b)[1]}catch(e){return""}}}),require("./_descriptors")&&"g"!=/./g.flags&&require("./_object-dp").f(RegExp.prototype,"flags",{configurable:!0,get:require("./_flags")}),require("./es6.regexp.flags");var w=require("./_an-object"),L=require("./_flags"),O=require("./_descriptors"),j="toString",x=/./[j],C=function(e){require("./_redefine")(RegExp.prototype,j,e,!0)};require("./_fails")(function(){return"/a/b"!=x.call({source:"a",flags:"b"})})?C(function(){var e=w(this);return"/".concat(e.source,"/","flags"in e?e.flags:!O&&e instanceof RegExp?L.call(e):void 0)}):x.name!=j&&C(function(){return x.call(this)}),require("./_fix-re-wks")("replace",2,function(o,i,a){return[function(e,r){var t=o(this),n=null==e?void 0:e[i];return void 0!==n?n.call(e,t,r):a.call(String(t),e,r)},a]});var R=require("./_export");function E(e,r){var t=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{};this.status=this.statusCode=this.code=e,this.message=r,Object.assign(this,t),this.name=this.constructor.name,this.constructor.prototype.__proto__=Error.prototype,Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}function M(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++)r[t]=arguments[t];E.call.apply(E,[this,0].concat(r))}function T(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++)r[t]=arguments[t];E.call.apply(E,[this].concat(r))}function k(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++)r[t]=arguments[t];E.call.apply(E,[this,400].concat(r))}function A(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++)r[t]=arguments[t];E.call.apply(E,[this,401].concat(r))}function P(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++)r[t]=arguments[t];E.call.apply(E,[this,403].concat(r))}function D(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++)r[t]=arguments[t];E.call.apply(E,[this,404].concat(r))}function H(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++)r[t]=arguments[t];E.call.apply(E,[this,409].concat(r))}function N(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++)r[t]=arguments[t];E.call.apply(E,[this,500].concat(r))}function B(){for(var e=arguments.length,r=new Array(e),t=0;t<e;t++)r[t]=arguments[t];E.call.apply(E,[this,503].concat(r))}function V(e){switch(e){case 0:return M;case 400:return k;case 401:return A;case 403:return P;case 404:return D;case 409:return H;case 500:return N;case 503:return B;default:return}}R(R.S+R.F,"Object",{assign:require("./_object-assign")});for(var z=Object.freeze({NetworkError:M,HttpError:T,BadRequest:k,Unauthorized:A,Forbidden:P,NotFound:D,ConcurrentModification:H,InternalServerError:N,ServiceUnavailable:B,default:V}),F=require("./es6.array.iterator"),G=require("./_object-keys"),I=require("./_redefine"),U=require("./_global"),J=require("./_hide"),$=require("./_iterators"),K=require("./_wks"),Q=K("iterator"),W=K("toStringTag"),X=$.Array,Y={CSSRuleList:!0,CSSStyleDeclaration:!1,CSSValueList:!1,ClientRectList:!1,DOMRectList:!1,DOMStringList:!1,DOMTokenList:!0,DataTransferItemList:!1,FileList:!1,HTMLAllCollection:!1,HTMLCollection:!1,HTMLFormElement:!1,HTMLSelectElement:!1,MediaList:!0,MimeTypeArray:!1,NamedNodeMap:!1,NodeList:!0,PaintRequestList:!1,Plugin:!1,PluginArray:!1,SVGLengthList:!1,SVGNumberList:!1,SVGPathSegList:!1,SVGPointList:!1,SVGStringList:!1,SVGTransformList:!1,SourceBufferList:!1,StyleSheetList:!0,TextTrackCueList:!1,TextTrackList:!1,TouchList:!1},Z=G(Y),ee=0;ee<Z.length;ee++){var re,te=Z[ee],ne=Y[te],oe=U[te],ie=oe&&oe.prototype;if(ie&&(ie[Q]||J(ie,Q,X),ie[W]||J(ie,W,te),$[te]=X,ne))for(re in F)ie[re]||I(ie,re,F[re],!0)}function ae(e){if(e.raw)return e.raw();if(!e.forEach)return{};var t={};return e.forEach(function(e,r){t[r]=e}),t}function ue(e,r,t,n,o){return n&&0!==e?Math.min(Math.round((Math.random()+1)*r*Math.pow(2,e)),o):r}function se(e,r){r&&(e.headers.authorization&&(e.headers.authorization=["Bearer ********"]),e.headers.Authorization&&(e.headers.Authorization=["Bearer ********"]))}e.errors=z,e.createHttpMiddleware=function(e){var o=e.host,c=e.credentialsMode,l=e.includeResponseHeaders,f=e.includeOriginalRequest,r=e.maskSensitiveHeaderData,p=void 0===r||r,d=e.enableRetry,t=e.retryConfig,n=(t=void 0===t?{}:t).maxRetries,h=void 0===n?10:n,i=t.backoff,y=void 0===i||i,a=t.retryDelay,g=void 0===a?200:a,u=t.maxDelay,v=void 0===u?1/0:u,b=e.fetch;if(!b&&"undefined"==typeof fetch)throw new Error("`fetch` is not available. Please pass in `fetch` as an option or have it globally available.");return b||(b=fetch),function(s){return function(i,a){var e=o.replace(/\/$/,"")+i.uri,r="string"==typeof i.body||Buffer.isBuffer(i.body)?i.body:JSON.stringify(i.body||void 0),t=q({"Content-Type":["application/json"]},i.headers,r?{"Content-Length":Buffer.byteLength(r).toString()}:null),n=q({method:i.method,headers:t},c?{credentials:c}:{},r?{body:r}:null),u=0;!function t(){b(e,n).then(function(o){if(!o.ok)return 503===o.status&&d&&u<h?(setTimeout(t,ue(u,g,0,y,v)),void(u+=1)):void o.text().then(function(e){var r;try{r=JSON.parse(e)}catch(t){r=e}var t=function(e){var r=e.statusCode,t=e.message,n=S(e,["statusCode","message"]),o=t||"Unexpected non-JSON error response";404===r&&(o="URI not found: ".concat(n.originalRequest.uri));var i=V(r);return i?new i(o,n):new T(r,o,n)}(q({statusCode:o.status,originalRequest:i,retryCount:u,headers:ae(o.headers)},"object"===m(r)?{message:r.message,body:r}:{message:r,body:r}));se(t.originalRequest,p);var n=q({},a,{error:t,statusCode:o.status});s(i,n)});o.json().then(function(e){var r=q({},a,{body:e,statusCode:o.status});l&&(r.headers=ae(o.headers)),f&&(r.request=q({},n),se(r.request,p)),s(i,r)})},function(e){if(d&&u<h)return setTimeout(t,ue(u,g,0,y,v)),void(u+=1);var r=new M(e.message,{originalRequest:i,retryCount:u});se(r.originalRequest,p),s(i,q({},a,{error:r,statusCode:0}))})}()}}},e.getErrorByCode=V,Object.defineProperty(e,"__esModule",{value:!0})}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).CommercetoolsSdkMiddlewareHttp={})}(this,function(e){"use strict";function m(e){return(m="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 w(o){for(var e=1;e<arguments.length;e++){var a=null!=arguments[e]?arguments[e]:{},t=Object.keys(a);"function"==typeof Object.getOwnPropertySymbols&&(t=t.concat(Object.getOwnPropertySymbols(a).filter(function(e){return Object.getOwnPropertyDescriptor(a,e).enumerable}))),t.forEach(function(e){var t,r,n;t=o,n=a[r=e],r in t?Object.defineProperty(t,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[r]=n})}return o}function O(e,t){if(null==e)return{};var r,n,o=function(e,t){if(null==e)return{};var r,n,o={},a=Object.keys(e);for(n=0;n<a.length;n++)r=a[n],0<=t.indexOf(r)||(o[r]=e[r]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(n=0;n<a.length;n++)r=a[n],0<=t.indexOf(r)||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}function n(e,t){var r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{};this.status=this.statusCode=this.code=e,this.message=t,Object.assign(this,r),this.name=this.constructor.name,this.constructor.prototype.__proto__=Error.prototype,Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}function S(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];n.call.apply(n,[this,0].concat(t))}function j(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];n.call.apply(n,[this].concat(t))}function t(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];n.call.apply(n,[this,400].concat(t))}function r(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];n.call.apply(n,[this,401].concat(t))}function o(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];n.call.apply(n,[this,403].concat(t))}function a(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];n.call.apply(n,[this,404].concat(t))}function i(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];n.call.apply(n,[this,409].concat(t))}function s(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];n.call.apply(n,[this,500].concat(t))}function c(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];n.call.apply(n,[this,503].concat(t))}function C(e){switch(e){case 0:return S;case 400:return t;case 401:return r;case 403:return o;case 404:return a;case 409:return i;case 500:return s;case 503:return c;default:return}}var u=Object.freeze({NetworkError:S,HttpError:j,BadRequest:t,Unauthorized:r,Forbidden:o,NotFound:a,ConcurrentModification:i,InternalServerError:s,ServiceUnavailable:c,default:C});function E(e){if(e.raw)return e.raw();if(!e.forEach)return{};var r={};return e.forEach(function(e,t){r[t]=e}),r}function A(e,t,r,n,o){return n&&0!==e?Math.min(Math.round((Math.random()+1)*t*Math.pow(2,e)),o):t}function R(e,t){t&&(e.headers.authorization&&(e.headers.authorization=["Bearer ********"]),e.headers.Authorization&&(e.headers.Authorization=["Bearer ********"]))}e.errors=u,e.createHttpMiddleware=function(e){var o=e.host,u=e.credentialsMode,l=e.includeResponseHeaders,f=e.includeOriginalRequest,t=e.maskSensitiveHeaderData,d=void 0===t||t,y=e.enableRetry,r=e.retryConfig,n=(r=void 0===r?{}:r).maxRetries,h=void 0===n?10:n,a=r.backoff,p=void 0===a||a,i=r.retryDelay,v=void 0===i?200:i,s=r.maxDelay,b=void 0===s?1/0:s,g=e.fetch;if(!g&&"undefined"==typeof fetch)throw new Error("`fetch` is not available. Please pass in `fetch` as an option or have it globally available.");return g||(g=fetch),function(c){return function(a,i){var e=o.replace(/\/$/,"")+a.uri,t="string"==typeof a.body||Buffer.isBuffer(a.body)?a.body:JSON.stringify(a.body||void 0),r=w({"Content-Type":["application/json"]},a.headers,t?{"Content-Length":Buffer.byteLength(t).toString()}:null),n=w({method:a.method,headers:r},u?{credentials:u}:{},t?{body:t}:null),s=0;!function r(){g(e,n).then(function(o){if(!o.ok)return 503===o.status&&y&&s<h?(setTimeout(r,A(s,v,0,p,b)),void(s+=1)):void o.text().then(function(e){var t;try{t=JSON.parse(e)}catch(r){t=e}var r=function(e){var t=e.statusCode,r=e.message,n=O(e,["statusCode","message"]),o=r||"Unexpected non-JSON error response";404===t&&(o="URI not found: ".concat(n.originalRequest.uri));var a=C(t);return a?new a(o,n):new j(t,o,n)}(w({statusCode:o.status,originalRequest:a,retryCount:s,headers:E(o.headers)},"object"===m(t)?{message:t.message,body:t}:{message:t,body:t}));R(r.originalRequest,d);var n=w({},i,{error:r,statusCode:o.status});c(a,n)});o.json().then(function(e){var t=w({},i,{body:e,statusCode:o.status});l&&(t.headers=E(o.headers)),f&&(t.request=w({},n),R(t.request,d)),c(a,t)})},function(e){if(y&&s<h)return setTimeout(r,A(s,v,0,p,b)),void(s+=1);var t=new S(e.message,{originalRequest:a,retryCount:s});R(t.originalRequest,d),c(a,w({},i,{error:t,statusCode:0}))})}()}}},e.getErrorByCode=C,Object.defineProperty(e,"__esModule",{value:!0})}); | ||
//# sourceMappingURL=commercetools-sdk-middleware-http.umd.min.js.map |
@@ -7,3 +7,3 @@ { | ||
"name": "@commercetools/sdk-middleware-http", | ||
"version": "4.0.10", | ||
"version": "5.0.0", | ||
"description": "Middleware for http requests, to use with @commercetools/sdk-client", | ||
@@ -39,6 +39,6 @@ "keywords": [ | ||
"devDependencies": { | ||
"nock": "10.0.4", | ||
"nock": "10.0.6", | ||
"node-fetch": "2.3.0" | ||
}, | ||
"gitHead": "4d5391c295c7a1b83ddf94564a8a45b3290a16ca" | ||
"gitHead": "313ea01030d33fb6c262c9cce428d19b5008ec9f" | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
0
112477
998