Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

axios-cache-interceptor

Package Overview
Dependencies
Maintainers
1
Versions
80
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

axios-cache-interceptor - npm Package Compare versions

Comparing version 0.7.2 to 0.7.3

2

dist/header/interpreter.js

@@ -1,1 +0,1 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.defaultHeaderInterpreter=void 0;var _cacheControl=require("@tusbar/cache-control");var _headers=require("../util/headers");var defaultHeaderInterpreter=function defaultHeaderInterpreter(){var headers=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};if(_headers.Header.CacheControl in headers){return interpretCacheControl(headers[_headers.Header.CacheControl],headers);}if(_headers.Header.Expires in headers){return interpretExpires(headers[_headers.Header.Expires],headers);}return undefined;};exports.defaultHeaderInterpreter=defaultHeaderInterpreter;var interpretExpires=function interpretExpires(expires){var milliseconds=Date.parse(expires)-Date.now();return milliseconds>=0?milliseconds:false;};var interpretCacheControl=function interpretCacheControl(cacheControl,headers){var _parse=(0,_cacheControl.parse)(cacheControl),noCache=_parse.noCache,noStore=_parse.noStore,mustRevalidate=_parse.mustRevalidate,maxAge=_parse.maxAge,immutable=_parse.immutable;if(noCache||noStore){return false;}if(immutable){return 1000*60*60*24*365;}if(mustRevalidate){return 0;}if(maxAge){var age=headers[_headers.Header.Age];if(!age){return maxAge*1000;}return maxAge*1000-Number(age)*1000;}return undefined;};
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.defaultHeaderInterpreter=void 0;var _cacheParser=require("cache-parser");var _headers=require("../util/headers");var defaultHeaderInterpreter=function defaultHeaderInterpreter(){var headers=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};if(_headers.Header.CacheControl in headers){return interpretCacheControl(headers[_headers.Header.CacheControl],headers);}if(_headers.Header.Expires in headers){return interpretExpires(headers[_headers.Header.Expires],headers);}return undefined;};exports.defaultHeaderInterpreter=defaultHeaderInterpreter;var interpretExpires=function interpretExpires(expires){var milliseconds=Date.parse(expires)-Date.now();return milliseconds>=0?milliseconds:false;};var interpretCacheControl=function interpretCacheControl(cacheControl,headers){var _parse=(0,_cacheParser.parse)(cacheControl),noCache=_parse.noCache,noStore=_parse.noStore,mustRevalidate=_parse.mustRevalidate,maxAge=_parse.maxAge,immutable=_parse.immutable;if(noCache||noStore){return false;}if(immutable){return 1000*60*60*24*365;}if(mustRevalidate){return 0;}if(maxAge){var age=headers[_headers.Header.Age];if(!age){return maxAge*1000;}return maxAge*1000-Number(age)*1000;}return undefined;};

@@ -1,2 +0,2 @@

!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.AxiosCacheInterceptor=t():e.AxiosCacheInterceptor=t()}(self,(function(){return e={532:e=>{"use strict";function t(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,a,o=[],i=!0,u=!1;try{for(r=r.call(e);!(i=(n=r.next()).done)&&(o.push(n.value),!t||o.length!==t);i=!0);}catch(e){u=!0,a=e}finally{try{i||null==r.return||r.return()}finally{if(u)throw a}}return o}}(e,t)||function(e,t){if(e){if("string"==typeof e)return r(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?r(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function r(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function n(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}var a=/([a-zA-Z][a-zA-Z_-]*)\s*(?:=(?:"([^"]*)"|([^ \t",;]*)))?/g,o="max-age",i="s-maxage",u="max-stale",c="min-fresh",s="immutable",f="must-revalidate",l="no-cache",p="no-store",d="no-transform",h="only-if-cached",y="private",v="proxy-revalidate",b="public",m="stale-while-revalidate",g="stale-if-error";function x(e){return null===e}function w(e){if(!e)return null;var t=Number.parseInt(e,10);return!Number.isFinite(t)||t<0?null:t}var O=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.maxAge=null,this.sharedMaxAge=null,this.maxStale=null,this.maxStaleDuration=null,this.minFresh=null,this.immutable=null,this.mustRevalidate=null,this.noCache=null,this.noStore=null,this.noTransform=null,this.onlyIfCached=null,this.private=null,this.proxyRevalidate=null,this.public=null,this.staleWhileRevalidate=null,this.staleIfError=null}var r,O,j;return r=e,(O=[{key:"parse",value:function(e){if(!e||0===e.length)return this;var r={},n=e.match(a)||[];return Array.prototype.forEach.call(n,(function(e){var n=e.split("=",2),a=t(n,1)[0],o=null;n.length>1&&(o=n[1].trim()),r[a.toLowerCase()]=o})),this.maxAge=w(r[o]),this.sharedMaxAge=w(r[i]),this.maxStale=x(r[u]),this.maxStaleDuration=w(r[u]),this.maxStaleDuration&&(this.maxStale=!0),this.minFresh=w(r[c]),this.immutable=x(r[s]),this.mustRevalidate=x(r[f]),this.noCache=x(r[l]),this.noStore=x(r[p]),this.noTransform=x(r[d]),this.onlyIfCached=x(r[h]),this.private=x(r[y]),this.proxyRevalidate=x(r[v]),this.public=x(r[b]),this.staleWhileRevalidate=w(r[m]),this.staleIfError=w(r[g]),this}},{key:"format",value:function(){var e=[];return"number"==typeof this.maxAge&&e.push("".concat(o,"=").concat(this.maxAge)),"number"==typeof this.sharedMaxAge&&e.push("".concat(i,"=").concat(this.sharedMaxAge)),this.maxStale&&("number"==typeof this.maxStaleDuration?e.push("".concat(u,"=").concat(this.maxStaleDuration)):e.push(u)),"number"==typeof this.minFresh&&e.push("".concat(c,"=").concat(this.minFresh)),this.immutable&&e.push(s),this.mustRevalidate&&e.push(f),this.noCache&&e.push(l),this.noStore&&e.push(p),this.noTransform&&e.push(d),this.onlyIfCached&&e.push(h),this.private&&e.push(y),this.proxyRevalidate&&e.push(v),this.public&&e.push(b),"number"==typeof this.staleWhileRevalidate&&e.push("".concat(m,"=").concat(this.staleWhileRevalidate)),"number"==typeof this.staleIfError&&e.push("".concat(g,"=").concat(this.staleIfError)),e.join(", ")}}])&&n(r.prototype,O),j&&n(r,j),e}();e.exports={CacheControl:O,parse:function(e){return(new O).parse(e)},format:function(e){return e instanceof O?e.format():O.prototype.format.call(e)}}},623:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.useCache=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.storage,s=t.generateKey,l=t.waiting,d=t.headerInterpreter,h=t.requestInterceptor,y=t.responseInterceptor,v=p(t,c),b=e;return b.storage=r||new i.MemoryAxiosStorage,b.generateKey=s||u.defaultKeyGenerator,b.waiting=l||{},b.headerInterpreter=d||n.defaultHeaderInterpreter,b.requestInterceptor=h||new a.CacheRequestInterceptor(b),b.responseInterceptor=y||new o.CacheResponseInterceptor(b),b.defaults=f(f({},e.defaults),{},{cache:f({ttl:3e5,interpretHeader:!1,methods:["get"],cachePredicate:{statusCheck:[200,399]},etag:!1,modifiedSince:!1,update:{}},v)}),b.requestInterceptor.use(),b.responseInterceptor.use(),b};var n=r(110),a=r(278),o=r(299),i=r(470),u=r(571),c=["storage","generateKey","waiting","headerInterpreter","requestInterceptor","responseInterceptor"];function s(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function f(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?s(Object(r),!0).forEach((function(t){l(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):s(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function l(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function p(e,t){if(null==e)return{};var r,n,a=function(e,t){if(null==e)return{};var r,n,a={},o=Object.keys(e);for(n=0;n<o.length;n++)r=o[n],t.indexOf(r)>=0||(a[r]=e[r]);return a}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(n=0;n<o.length;n++)r=o[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(a[r]=e[r])}return a}},110:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.defaultHeaderInterpreter=void 0;var n=r(532),a=r(50);t.defaultHeaderInterpreter=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return a.Header.CacheControl in e?i(e[a.Header.CacheControl],e):a.Header.Expires in e?o(e[a.Header.Expires],e):void 0};var o=function(e){var t=Date.parse(e)-Date.now();return t>=0&&t},i=function(e,t){var r=(0,n.parse)(e),o=r.noCache,i=r.noStore,u=r.mustRevalidate,c=r.maxAge,s=r.immutable;if(o||i)return!1;if(s)return 31536e6;if(u)return 0;if(c){var f=t[a.Header.Age];return f?1e3*c-1e3*Number(f):1e3*c}}},138:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(623);Object.keys(n).forEach((function(e){"default"!==e&&"__esModule"!==e&&(e in t&&t[e]===n[e]||Object.defineProperty(t,e,{enumerable:!0,get:function(){return n[e]}}))}));var a=r(795);Object.keys(a).forEach((function(e){"default"!==e&&"__esModule"!==e&&(e in t&&t[e]===a[e]||Object.defineProperty(t,e,{enumerable:!0,get:function(){return a[e]}}))}));var o=r(470);Object.keys(o).forEach((function(e){"default"!==e&&"__esModule"!==e&&(e in t&&t[e]===o[e]||Object.defineProperty(t,e,{enumerable:!0,get:function(){return o[e]}}))}));var i=r(433);Object.keys(i).forEach((function(e){"default"!==e&&"__esModule"!==e&&(e in t&&t[e]===i[e]||Object.defineProperty(t,e,{enumerable:!0,get:function(){return i[e]}}))}))},278:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CacheRequestInterceptor=void 0;var n=r(549),a=r(50);function o(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return i(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?i(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,a=function(){};return{s:a,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:a}}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,u=!0,c=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return u=e.done,e},e:function(e){c=!0,o=e},f:function(){try{u||null==r.return||r.return()}finally{if(c)throw o}}}}function i(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function u(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function c(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?u(Object(r),!0).forEach((function(t){f(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):u(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function s(e,t,r,n,a,o,i){try{var u=e[o](i),c=u.value}catch(e){return void r(e)}u.done?t(c):Promise.resolve(c).then(n,a)}function f(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var l=function e(t){var r=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),f(this,"use",(function(){r.axios.interceptors.request.use(r.onFulfilled)})),f(this,"onFulfilled",function(){var t,a=(t=regeneratorRuntime.mark((function t(a){var o,i,u,s,f;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!1!==a.cache){t.next=2;break}return t.abrupt("return",a);case 2:if(a.cache=c(c({},r.axios.defaults.cache),a.cache),e.isMethodAllowed(a.method,a.cache)){t.next=5;break}return t.abrupt("return",a);case 5:return o=r.axios.generateKey(a),t.next=8,r.axios.storage.get(o);case 8:if("empty"!=(i=t.sent).state&&"stale"!==i.state){t.next=22;break}if(!r.axios.waiting[o]){t.next=15;break}return t.next=13,r.axios.storage.get(o);case 13:return i=t.sent,t.abrupt("break",22);case 15:return r.axios.waiting[o]=(0,n.deferred)(),null===(u=r.axios.waiting[o])||void 0===u||u.catch((function(){})),t.next=19,r.axios.storage.set(o,{state:"loading",data:i.data});case 19:return"stale"===i.state&&e.setRevalidationHeaders(i,a),a.validateStatus=e.createValidateStatus(a.validateStatus),t.abrupt("return",a);case 22:if("loading"!==i.state){t.next=39;break}if(f=r.axios.waiting[o]){t.next=28;break}return t.next=27,r.axios.storage.remove(o);case 27:return t.abrupt("return",a);case 28:return t.prev=28,t.next=31,f;case 31:s=t.sent,t.next=37;break;case 34:return t.prev=34,t.t0=t.catch(28),t.abrupt("return",a);case 37:t.next=40;break;case 39:s=i.data;case 40:return a.adapter=function(){return Promise.resolve({config:a,data:s.data,headers:s.headers,status:s.status,statusText:s.statusText,cached:!0,id:o})},t.abrupt("return",a);case 42:case"end":return t.stop()}}),t,null,[[28,34]])})),function(){var e=this,r=arguments;return new Promise((function(n,a){var o=t.apply(e,r);function i(e){s(o,n,a,i,u,"next",e)}function u(e){s(o,n,a,i,u,"throw",e)}i(void 0)}))});return function(e){return a.apply(this,arguments)}}()),this.axios=t};t.CacheRequestInterceptor=l,f(l,"isMethodAllowed",(function(e,t){var r,n=e.toLowerCase(),a=o(t.methods||[]);try{for(a.s();!(r=a.n()).done;)if(r.value.toLowerCase()===n)return!0}catch(e){a.e(e)}finally{a.f()}return!1})),f(l,"setRevalidationHeaders",(function(e,t){t.headers||(t.headers={});var r=t.cache,n=r.etag,o=r.modifiedSince;if(n){var i,u=!0===n?null===(i=e.data)||void 0===i?void 0:i.headers[a.Header.ETag]:n;u&&(t.headers[a.Header.IfNoneMatch]=u)}o&&(t.headers[a.Header.IfModifiedSince]=!0===o?e.data.headers[a.Header.LastModified]||new Date(e.createdAt).toUTCString():o.toUTCString())})),f(l,"createValidateStatus",(function(e){return function(t){return e?e(t)||304===t:t>=200&&t<300||304===t}}))},299:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CacheResponseInterceptor=void 0;var n=r(904),a=r(50),o=r(939);function i(e){return i="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},i(e)}function u(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function c(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?u(Object(r),!0).forEach((function(t){l(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):u(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function s(e,t,r,n,a,o,i){try{var u=e[o](i),c=u.value}catch(e){return void r(e)}u.done?t(c):Promise.resolve(c).then(n,a)}function f(e){return function(){var t=this,r=arguments;return new Promise((function(n,a){var o=e.apply(t,r);function i(e){s(o,n,a,i,u,"next",e)}function u(e){s(o,n,a,i,u,"throw",e)}i(void 0)}))}}function l(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var p=function e(t){var r=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),l(this,"use",(function(){r.axios.interceptors.response.use(r.onFulfilled)})),l(this,"onFulfilled",function(){var t=f(regeneratorRuntime.mark((function t(n){var i,u,s,f,l,p,d,h;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(i=r.cachedResponse(n)).cached){t.next=3;break}return t.abrupt("return",i);case 3:if(i.config.cache){t.next=5;break}return t.abrupt("return",c(c({},i),{},{cached:!1}));case 5:return u=i.config.cache,t.next=8,r.axios.storage.get(i.id);case 8:if("stale"!==(s=t.sent).state&&"empty"!==s.state&&"cached"!==s.state){t.next=11;break}return t.abrupt("return",i);case 11:if(s.data||e.testCachePredicate(i,u)){t.next=15;break}return t.next=14,r.rejectResponse(i.id);case 14:return t.abrupt("return",i);case 15:if(delete i.headers[a.Header.XAxiosCacheEtag],delete i.headers[a.Header.XAxiosCacheLastModified],u.etag&&!0!==u.etag&&(i.headers[a.Header.XAxiosCacheEtag]=u.etag),u.modifiedSince&&(i.headers[a.Header.XAxiosCacheLastModified]=!0===u.modifiedSince?"use-cache-timestamp":u.modifiedSince.toUTCString()),f=u.ttl||-1,null==u||!u.interpretHeader){t.next=27;break}if(!1!==(l=r.axios.headerInterpreter(i.headers))){t.next=26;break}return t.next=25,r.rejectResponse(i.id);case 25:return t.abrupt("return",i);case 26:f=l||0===l?l:f;case 27:return p=e.createCacheData(i,s.data),d={state:"cached",ttl:f,createdAt:Date.now(),data:p},null!=u&&u.update&&(0,o.updateCache)(r.axios.storage,i.data,u.update),h=r.axios.waiting[i.id],t.next=33,null==h?void 0:h.resolve(d.data);case 33:return delete r.axios.waiting[i.id],t.next=36,r.axios.storage.set(i.id,d);case 36:return t.abrupt("return",i);case 37:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()),l(this,"rejectResponse",function(){var e=f(regeneratorRuntime.mark((function e(t){var n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,r.axios.storage.remove(t);case 2:null===(n=r.axios.waiting[t])||void 0===n||n.reject(null),delete r.axios.waiting[t];case 4:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()),l(this,"cachedResponse",(function(e){return c({id:r.axios.generateKey(e.config),cached:e.cached||!1},e)})),this.axios=t};t.CacheResponseInterceptor=p,l(p,"testCachePredicate",(function(e,t){var r=t.cachePredicate;return"function"==typeof r&&r(e)||"object"===i(r)&&(0,n.checkPredicateObject)(e,r)})),l(p,"createCacheData",(function(e,t){return 304===e.status&&t?(e.cached=!0,e.data=t.data,e.status=t.status,e.statusText=t.statusText,e.headers=c(c({},t.headers),e.headers),t):{data:e.data,status:e.status,statusText:e.statusText,headers:e.headers}}))},795:(e,t,r)=>{"use strict";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},n(e)}function a(e,t,r,n,a,o,i){try{var u=e[o](i),c=u.value}catch(e){return void r(e)}u.done?t(c):Promise.resolve(c).then(n,a)}function o(e){return function(){var t=this,r=arguments;return new Promise((function(n,o){var i=e.apply(t,r);function u(e){a(i,n,o,u,c,"next",e)}function c(e){a(i,n,o,u,c,"throw",e)}u(void 0)}))}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function u(e,t){return u=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},u(e,t)}function c(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=l(e);if(t){var a=l(this).constructor;r=Reflect.construct(n,arguments,a)}else r=n.apply(this,arguments);return s(this,r)}}function s(e,t){if(t&&("object"===n(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return f(e)}function f(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function l(e){return l=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},l(e)}function p(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}Object.defineProperty(t,"__esModule",{value:!0}),t.BrowserAxiosStorage=void 0;var d=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&u(e,t)}(r,e);var t=c(r);function r(e){var n,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:r.DEFAULT_KEY_PREFIX;return i(this,r),p(f(n=t.call(this)),"find",function(){var e=o(regeneratorRuntime.mark((function e(t){var r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=n.storage.getItem("".concat(n.prefix,":").concat(t)),e.abrupt("return",r?JSON.parse(r):{state:"empty"});case 2:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()),p(f(n),"set",function(){var e=o(regeneratorRuntime.mark((function e(t,r){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",n.storage.setItem("".concat(n.prefix,":").concat(t),JSON.stringify(r)));case 1:case"end":return e.stop()}}),e)})));return function(t,r){return e.apply(this,arguments)}}()),p(f(n),"remove",function(){var e=o(regeneratorRuntime.mark((function e(t){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",n.storage.removeItem("".concat(n.prefix,":").concat(t)));case 1:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()),n.storage=e,n.prefix=a,n}return r}(r(433).AxiosStorage);t.BrowserAxiosStorage=d,p(d,"DEFAULT_KEY_PREFIX","a-c-i")},470:(e,t,r)=>{"use strict";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},n(e)}function a(e,t,r,n,a,o,i){try{var u=e[o](i),c=u.value}catch(e){return void r(e)}u.done?t(c):Promise.resolve(c).then(n,a)}function o(e){return function(){var t=this,r=arguments;return new Promise((function(n,o){var i=e.apply(t,r);function u(e){a(i,n,o,u,c,"next",e)}function c(e){a(i,n,o,u,c,"throw",e)}u(void 0)}))}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function u(e,t){return u=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},u(e,t)}function c(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=l(e);if(t){var a=l(this).constructor;r=Reflect.construct(n,arguments,a)}else r=n.apply(this,arguments);return s(this,r)}}function s(e,t){if(t&&("object"===n(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return f(e)}function f(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function l(e){return l=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},l(e)}function p(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}Object.defineProperty(t,"__esModule",{value:!0}),t.MemoryAxiosStorage=void 0;var d=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&u(e,t)}(r,e);var t=c(r);function r(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return i(this,r),p(f(e=t.call(this)),"find",function(){var t=o(regeneratorRuntime.mark((function t(r){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",e.storage[r]||{state:"empty"});case 1:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()),p(f(e),"set",function(){var t=o(regeneratorRuntime.mark((function t(r,n){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e.storage[r]=n;case 1:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}()),p(f(e),"remove",function(){var t=o(regeneratorRuntime.mark((function t(r){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:delete e.storage[r];case 1:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()),e.storage=n,e}return r}(r(433).AxiosStorage);t.MemoryAxiosStorage=d},433:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AxiosStorage=void 0;var n=r(50);function a(e,t,r,n,a,o,i){try{var u=e[o](i),c=u.value}catch(e){return void r(e)}u.done?t(c):Promise.resolve(c).then(n,a)}function o(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var i=function e(){var t=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),o(this,"get",function(){var r,n=(r=regeneratorRuntime.mark((function r(n){var a,o;return regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,t.find(n);case 2:if(!("cached"!==(a=r.sent).state||a.createdAt+a.ttl>Date.now())){r.next=5;break}return r.abrupt("return",a);case 5:if(!e.keepIfStale(a)){r.next=10;break}return o={data:a.data,state:"stale",createdAt:a.createdAt},r.next=9,t.set(n,o);case 9:return r.abrupt("return",o);case 10:return r.next=12,t.remove(n);case 12:return r.abrupt("return",{state:"empty"});case 13:case"end":return r.stop()}}),r)})),function(){var e=this,t=arguments;return new Promise((function(n,o){var i=r.apply(e,t);function u(e){a(i,n,o,u,c,"next",e)}function c(e){a(i,n,o,u,c,"throw",e)}u(void 0)}))});return function(e){return n.apply(this,arguments)}}())};t.AxiosStorage=i,o(i,"keepIfStale",(function(e){var t=e.data;return!(null==t||!t.headers)&&(n.Header.ETag in t.headers||n.Header.LastModified in t.headers||n.Header.XAxiosCacheEtag in t.headers||n.Header.XAxiosCacheLastModified in t.headers)}))},904:(e,t)=>{"use strict";function r(e){return r="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},r(e)}function n(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}Object.defineProperty(t,"__esModule",{value:!0}),t.checkPredicateObject=function(e,t){var a,o,i=t.statusCheck,u=t.containsHeaders,c=t.responseMatch;if(i)if("function"==typeof i){if(!i(e.status))return!1}else{var s=(o=2,function(e){if(Array.isArray(e))return e}(a=i)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,a,o=[],i=!0,u=!1;try{for(r=r.call(e);!(i=(n=r.next()).done)&&(o.push(n.value),!t||o.length!==t);i=!0);}catch(e){u=!0,a=e}finally{try{i||null==r.return||r.return()}finally{if(u)throw a}}return o}}(a,o)||function(e,t){if(e){if("string"==typeof e)return n(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?n(e,t):void 0}}(a,o)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),f=s[0],l=s[1];if(e.status<f||e.status>l)return!1}if(u)for(var p in u){var d=u[p],h=e.headers[p];if(!h)return!1;switch(r(d)){case"string":if(h!=d)return!1;break;case"function":if(!d(h))return!1}}return!(c&&!c(e.data))}},50:(e,t)=>{"use strict";var r;Object.defineProperty(t,"__esModule",{value:!0}),t.Header=void 0,t.Header=r,function(e){e.IfModifiedSince="if-modified-since",e.LastModified="last-modified",e.IfNoneMatch="if-none-match",e.CacheControl="cache-control",e.ETag="etag",e.Expires="expires",e.Age="age",e.ContentType="content-type",e.XAxiosCacheEtag="x-axios-cache-etag",e.XAxiosCacheLastModified="x-axios-cache-last-modified"}(r||(t.Header=r={}))},571:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.defaultKeyGenerator=void 0;var r=/^\/|\/+$/g;t.defaultKeyGenerator=function(e){var t=e.baseURL,n=void 0===t?"":t,a=e.url,o=void 0===a?"":a,i=e.method,u=e.params,c=e.id;if(c)return String(c);n=n.replace(r,""),o=o.replace(r,"");var s=(null==i?void 0:i.toLowerCase())||"get",f=u?JSON.stringify(u,Object.keys(u).sort()):"{}";return"".concat(s,"::").concat(n+(o&&n?"/":"")+o,"::").concat(f)}},939:(e,t)=>{"use strict";function r(e,t,r,n,a,o,i){try{var u=e[o](i),c=u.value}catch(e){return void r(e)}u.done?t(c):Promise.resolve(c).then(n,a)}function n(e){return function(){var t=this,n=arguments;return new Promise((function(a,o){var i=e.apply(t,n);function u(e){r(i,a,o,u,c,"next",e)}function c(e){r(i,a,o,u,c,"throw",e)}u(void 0)}))}}function a(){return(a=n(regeneratorRuntime.mark((function e(t,r,n){var a,o,i,u;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:e.t0=regeneratorRuntime.keys(n);case 1:if((e.t1=e.t0()).done){e.next=22;break}if(a=e.t1.value,"delete"!==(o=n[a])){e.next=8;break}return e.next=7,t.remove(a);case 7:return e.abrupt("continue",1);case 8:return e.next=10,t.get(a);case 10:if("loading"!==(i=e.sent).state){e.next=13;break}throw new Error("cannot update the cache while loading");case 13:if(void 0!==(u=o(i,r))){e.next=18;break}return e.next=17,t.remove(a);case 17:return e.abrupt("continue",1);case 18:return e.next=20,t.set(a,u);case 20:e.next=1;break;case 22:case"end":return e.stop()}}),e)})))).apply(this,arguments)}Object.defineProperty(t,"__esModule",{value:!0}),t.updateCache=function(e,t,r){return a.apply(this,arguments)}},549:(e,t)=>{var r,n;r=t,n=Symbol("fast-defer"),r.deferred=function(){var e,t,r=new Promise(((r,n)=>{e=r,t=n}));return r.resolve=e,r.reject=t,r[n]=1,r},r.isDeferred=function(e){return!!e&&!!e[n]}}},t={},r=function r(n){var a=t[n];if(void 0!==a)return a.exports;var o=t[n]={exports:{}};return e[n](o,o.exports,r),o.exports}(138),r;var e,t,r}));
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.AxiosCacheInterceptor=t():e.AxiosCacheInterceptor=t()}(self,(function(){return e={623:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.useCache=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.storage,s=t.generateKey,l=t.waiting,d=t.headerInterpreter,h=t.requestInterceptor,v=t.responseInterceptor,y=p(t,c),b=e;return b.storage=r||new i.MemoryAxiosStorage,b.generateKey=s||u.defaultKeyGenerator,b.waiting=l||{},b.headerInterpreter=d||n.defaultHeaderInterpreter,b.requestInterceptor=h||new a.CacheRequestInterceptor(b),b.responseInterceptor=v||new o.CacheResponseInterceptor(b),b.defaults=f(f({},e.defaults),{},{cache:f({ttl:3e5,interpretHeader:!1,methods:["get"],cachePredicate:{statusCheck:[200,399]},etag:!1,modifiedSince:!1,update:{}},y)}),b.requestInterceptor.use(),b.responseInterceptor.use(),b};var n=r(110),a=r(278),o=r(299),i=r(470),u=r(571),c=["storage","generateKey","waiting","headerInterpreter","requestInterceptor","responseInterceptor"];function s(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function f(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?s(Object(r),!0).forEach((function(t){l(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):s(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function l(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function p(e,t){if(null==e)return{};var r,n,a=function(e,t){if(null==e)return{};var r,n,a={},o=Object.keys(e);for(n=0;n<o.length;n++)r=o[n],t.indexOf(r)>=0||(a[r]=e[r]);return a}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(n=0;n<o.length;n++)r=o[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(a[r]=e[r])}return a}},110:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.defaultHeaderInterpreter=void 0;var n=r(86),a=r(50);t.defaultHeaderInterpreter=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return a.Header.CacheControl in e?i(e[a.Header.CacheControl],e):a.Header.Expires in e?o(e[a.Header.Expires],e):void 0};var o=function(e){var t=Date.parse(e)-Date.now();return t>=0&&t},i=function(e,t){var r=(0,n.parse)(e),o=r.noCache,i=r.noStore,u=r.mustRevalidate,c=r.maxAge,s=r.immutable;if(o||i)return!1;if(s)return 31536e6;if(u)return 0;if(c){var f=t[a.Header.Age];return f?1e3*c-1e3*Number(f):1e3*c}}},138:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(623);Object.keys(n).forEach((function(e){"default"!==e&&"__esModule"!==e&&(e in t&&t[e]===n[e]||Object.defineProperty(t,e,{enumerable:!0,get:function(){return n[e]}}))}));var a=r(795);Object.keys(a).forEach((function(e){"default"!==e&&"__esModule"!==e&&(e in t&&t[e]===a[e]||Object.defineProperty(t,e,{enumerable:!0,get:function(){return a[e]}}))}));var o=r(470);Object.keys(o).forEach((function(e){"default"!==e&&"__esModule"!==e&&(e in t&&t[e]===o[e]||Object.defineProperty(t,e,{enumerable:!0,get:function(){return o[e]}}))}));var i=r(433);Object.keys(i).forEach((function(e){"default"!==e&&"__esModule"!==e&&(e in t&&t[e]===i[e]||Object.defineProperty(t,e,{enumerable:!0,get:function(){return i[e]}}))}))},278:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CacheRequestInterceptor=void 0;var n=r(549),a=r(50);function o(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return i(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?i(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,a=function(){};return{s:a,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:a}}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,u=!0,c=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return u=e.done,e},e:function(e){c=!0,o=e},f:function(){try{u||null==r.return||r.return()}finally{if(c)throw o}}}}function i(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function u(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function c(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?u(Object(r),!0).forEach((function(t){f(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):u(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function s(e,t,r,n,a,o,i){try{var u=e[o](i),c=u.value}catch(e){return void r(e)}u.done?t(c):Promise.resolve(c).then(n,a)}function f(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var l=function e(t){var r=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),f(this,"use",(function(){r.axios.interceptors.request.use(r.onFulfilled)})),f(this,"onFulfilled",function(){var t,a=(t=regeneratorRuntime.mark((function t(a){var o,i,u,s,f;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!1!==a.cache){t.next=2;break}return t.abrupt("return",a);case 2:if(a.cache=c(c({},r.axios.defaults.cache),a.cache),e.isMethodAllowed(a.method,a.cache)){t.next=5;break}return t.abrupt("return",a);case 5:return o=r.axios.generateKey(a),t.next=8,r.axios.storage.get(o);case 8:if("empty"!=(i=t.sent).state&&"stale"!==i.state){t.next=22;break}if(!r.axios.waiting[o]){t.next=15;break}return t.next=13,r.axios.storage.get(o);case 13:return i=t.sent,t.abrupt("break",22);case 15:return r.axios.waiting[o]=(0,n.deferred)(),null===(u=r.axios.waiting[o])||void 0===u||u.catch((function(){})),t.next=19,r.axios.storage.set(o,{state:"loading",data:i.data});case 19:return"stale"===i.state&&e.setRevalidationHeaders(i,a),a.validateStatus=e.createValidateStatus(a.validateStatus),t.abrupt("return",a);case 22:if("loading"!==i.state){t.next=39;break}if(f=r.axios.waiting[o]){t.next=28;break}return t.next=27,r.axios.storage.remove(o);case 27:return t.abrupt("return",a);case 28:return t.prev=28,t.next=31,f;case 31:s=t.sent,t.next=37;break;case 34:return t.prev=34,t.t0=t.catch(28),t.abrupt("return",a);case 37:t.next=40;break;case 39:s=i.data;case 40:return a.adapter=function(){return Promise.resolve({config:a,data:s.data,headers:s.headers,status:s.status,statusText:s.statusText,cached:!0,id:o})},t.abrupt("return",a);case 42:case"end":return t.stop()}}),t,null,[[28,34]])})),function(){var e=this,r=arguments;return new Promise((function(n,a){var o=t.apply(e,r);function i(e){s(o,n,a,i,u,"next",e)}function u(e){s(o,n,a,i,u,"throw",e)}i(void 0)}))});return function(e){return a.apply(this,arguments)}}()),this.axios=t};t.CacheRequestInterceptor=l,f(l,"isMethodAllowed",(function(e,t){var r,n=e.toLowerCase(),a=o(t.methods||[]);try{for(a.s();!(r=a.n()).done;)if(r.value.toLowerCase()===n)return!0}catch(e){a.e(e)}finally{a.f()}return!1})),f(l,"setRevalidationHeaders",(function(e,t){t.headers||(t.headers={});var r=t.cache,n=r.etag,o=r.modifiedSince;if(n){var i,u=!0===n?null===(i=e.data)||void 0===i?void 0:i.headers[a.Header.ETag]:n;u&&(t.headers[a.Header.IfNoneMatch]=u)}o&&(t.headers[a.Header.IfModifiedSince]=!0===o?e.data.headers[a.Header.LastModified]||new Date(e.createdAt).toUTCString():o.toUTCString())})),f(l,"createValidateStatus",(function(e){return function(t){return e?e(t)||304===t:t>=200&&t<300||304===t}}))},299:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CacheResponseInterceptor=void 0;var n=r(904),a=r(50),o=r(939);function i(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function u(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?i(Object(r),!0).forEach((function(t){f(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):i(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function c(e,t,r,n,a,o,i){try{var u=e[o](i),c=u.value}catch(e){return void r(e)}u.done?t(c):Promise.resolve(c).then(n,a)}function s(e){return function(){var t=this,r=arguments;return new Promise((function(n,a){var o=e.apply(t,r);function i(e){c(o,n,a,i,u,"next",e)}function u(e){c(o,n,a,i,u,"throw",e)}i(void 0)}))}}function f(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var l=function e(t){var r=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),f(this,"use",(function(){r.axios.interceptors.response.use(r.onFulfilled)})),f(this,"onFulfilled",function(){var t=s(regeneratorRuntime.mark((function t(i){var c,s,f,l,p,d,h,v;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(c=r.cachedResponse(i)).cached){t.next=3;break}return t.abrupt("return",c);case 3:if(c.config.cache){t.next=5;break}return t.abrupt("return",u(u({},c),{},{cached:!1}));case 5:return s=c.config.cache,t.next=8,r.axios.storage.get(c.id);case 8:if("stale"!==(f=t.sent).state&&"empty"!==f.state&&"cached"!==f.state){t.next=11;break}return t.abrupt("return",c);case 11:if(f.data||(0,n.shouldCacheResponse)(c,s)){t.next=15;break}return t.next=14,r.rejectResponse(c.id);case 14:return t.abrupt("return",c);case 15:if(delete c.headers[a.Header.XAxiosCacheEtag],delete c.headers[a.Header.XAxiosCacheLastModified],s.etag&&!0!==s.etag&&(c.headers[a.Header.XAxiosCacheEtag]=s.etag),s.modifiedSince&&(c.headers[a.Header.XAxiosCacheLastModified]=!0===s.modifiedSince?"use-cache-timestamp":s.modifiedSince.toUTCString()),l=s.ttl||-1,null==s||!s.interpretHeader){t.next=27;break}if(!1!==(p=r.axios.headerInterpreter(c.headers))){t.next=26;break}return t.next=25,r.rejectResponse(c.id);case 25:return t.abrupt("return",c);case 26:l=p||0===p?p:l;case 27:return d=e.createCacheData(c,f.data),h={state:"cached",ttl:l,createdAt:Date.now(),data:d},null!=s&&s.update&&(0,o.updateCache)(r.axios.storage,c.data,s.update),v=r.axios.waiting[c.id],t.next=33,null==v?void 0:v.resolve(h.data);case 33:return delete r.axios.waiting[c.id],t.next=36,r.axios.storage.set(c.id,h);case 36:return t.abrupt("return",c);case 37:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()),f(this,"rejectResponse",function(){var e=s(regeneratorRuntime.mark((function e(t){var n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,r.axios.storage.remove(t);case 2:null===(n=r.axios.waiting[t])||void 0===n||n.reject(null),delete r.axios.waiting[t];case 4:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()),f(this,"cachedResponse",(function(e){return u({id:r.axios.generateKey(e.config),cached:e.cached||!1},e)})),this.axios=t};t.CacheResponseInterceptor=l,f(l,"createCacheData",(function(e,t){return 304===e.status&&t?(e.cached=!0,e.data=t.data,e.status=t.status,e.statusText=t.statusText,e.headers=u(u({},t.headers),e.headers),t):{data:e.data,status:e.status,statusText:e.statusText,headers:e.headers}}))},795:(e,t,r)=>{"use strict";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},n(e)}function a(e,t,r,n,a,o,i){try{var u=e[o](i),c=u.value}catch(e){return void r(e)}u.done?t(c):Promise.resolve(c).then(n,a)}function o(e){return function(){var t=this,r=arguments;return new Promise((function(n,o){var i=e.apply(t,r);function u(e){a(i,n,o,u,c,"next",e)}function c(e){a(i,n,o,u,c,"throw",e)}u(void 0)}))}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function u(e,t){return u=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},u(e,t)}function c(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=l(e);if(t){var a=l(this).constructor;r=Reflect.construct(n,arguments,a)}else r=n.apply(this,arguments);return s(this,r)}}function s(e,t){if(t&&("object"===n(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return f(e)}function f(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function l(e){return l=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},l(e)}function p(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}Object.defineProperty(t,"__esModule",{value:!0}),t.BrowserAxiosStorage=void 0;var d=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&u(e,t)}(r,e);var t=c(r);function r(e){var n,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:r.DEFAULT_KEY_PREFIX;return i(this,r),p(f(n=t.call(this)),"find",function(){var e=o(regeneratorRuntime.mark((function e(t){var r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=n.storage.getItem("".concat(n.prefix,":").concat(t)),e.abrupt("return",r?JSON.parse(r):{state:"empty"});case 2:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()),p(f(n),"set",function(){var e=o(regeneratorRuntime.mark((function e(t,r){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",n.storage.setItem("".concat(n.prefix,":").concat(t),JSON.stringify(r)));case 1:case"end":return e.stop()}}),e)})));return function(t,r){return e.apply(this,arguments)}}()),p(f(n),"remove",function(){var e=o(regeneratorRuntime.mark((function e(t){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",n.storage.removeItem("".concat(n.prefix,":").concat(t)));case 1:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()),n.storage=e,n.prefix=a,n}return r}(r(433).AxiosStorage);t.BrowserAxiosStorage=d,p(d,"DEFAULT_KEY_PREFIX","a-c-i")},470:(e,t,r)=>{"use strict";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},n(e)}function a(e,t,r,n,a,o,i){try{var u=e[o](i),c=u.value}catch(e){return void r(e)}u.done?t(c):Promise.resolve(c).then(n,a)}function o(e){return function(){var t=this,r=arguments;return new Promise((function(n,o){var i=e.apply(t,r);function u(e){a(i,n,o,u,c,"next",e)}function c(e){a(i,n,o,u,c,"throw",e)}u(void 0)}))}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function u(e,t){return u=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},u(e,t)}function c(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=l(e);if(t){var a=l(this).constructor;r=Reflect.construct(n,arguments,a)}else r=n.apply(this,arguments);return s(this,r)}}function s(e,t){if(t&&("object"===n(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return f(e)}function f(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function l(e){return l=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},l(e)}function p(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}Object.defineProperty(t,"__esModule",{value:!0}),t.MemoryAxiosStorage=void 0;var d=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&u(e,t)}(r,e);var t=c(r);function r(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return i(this,r),p(f(e=t.call(this)),"find",function(){var t=o(regeneratorRuntime.mark((function t(r){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",e.storage[r]||{state:"empty"});case 1:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()),p(f(e),"set",function(){var t=o(regeneratorRuntime.mark((function t(r,n){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:e.storage[r]=n;case 1:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}()),p(f(e),"remove",function(){var t=o(regeneratorRuntime.mark((function t(r){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:delete e.storage[r];case 1:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()),e.storage=n,e}return r}(r(433).AxiosStorage);t.MemoryAxiosStorage=d},433:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AxiosStorage=void 0;var n=r(50);function a(e,t,r,n,a,o,i){try{var u=e[o](i),c=u.value}catch(e){return void r(e)}u.done?t(c):Promise.resolve(c).then(n,a)}function o(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var i=function e(){var t=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),o(this,"get",function(){var r,n=(r=regeneratorRuntime.mark((function r(n){var a,o;return regeneratorRuntime.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,t.find(n);case 2:if(!("cached"!==(a=r.sent).state||a.createdAt+a.ttl>Date.now())){r.next=5;break}return r.abrupt("return",a);case 5:if(!e.keepIfStale(a)){r.next=10;break}return o={data:a.data,state:"stale",createdAt:a.createdAt},r.next=9,t.set(n,o);case 9:return r.abrupt("return",o);case 10:return r.next=12,t.remove(n);case 12:return r.abrupt("return",{state:"empty"});case 13:case"end":return r.stop()}}),r)})),function(){var e=this,t=arguments;return new Promise((function(n,o){var i=r.apply(e,t);function u(e){a(i,n,o,u,c,"next",e)}function c(e){a(i,n,o,u,c,"throw",e)}u(void 0)}))});return function(e){return n.apply(this,arguments)}}())};t.AxiosStorage=i,o(i,"keepIfStale",(function(e){var t=e.data;return!(null==t||!t.headers)&&(n.Header.ETag in t.headers||n.Header.LastModified in t.headers||n.Header.XAxiosCacheEtag in t.headers||n.Header.XAxiosCacheLastModified in t.headers)}))},904:(e,t)=>{"use strict";function r(e){return r="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},r(e)}function n(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,a,o=[],i=!0,u=!1;try{for(r=r.call(e);!(i=(n=r.next()).done)&&(o.push(n.value),!t||o.length!==t);i=!0);}catch(e){u=!0,a=e}finally{try{i||null==r.return||r.return()}finally{if(u)throw a}}return o}}(e,t)||function(e,t){if(e){if("string"==typeof e)return a(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?a(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function a(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function o(e,t){var a=t.statusCheck,o=t.containsHeaders,i=t.responseMatch;if(a)if("function"==typeof a){if(!a(e.status))return!1}else{var u=n(a,2),c=u[0],s=u[1];if(e.status<c||e.status>s)return!1}if(o)for(var f in o){var l=o[f],p=e.headers[f];if(!p)return!1;switch(r(l)){case"string":if(p!=l)return!1;break;case"function":if(!l(p))return!1}}return!(i&&!i(e.data))}Object.defineProperty(t,"__esModule",{value:!0}),t.isCachePredicateValid=o,t.shouldCacheResponse=function(e,t){var r=t.cachePredicate;return"function"==typeof r?r(e):o(e,r)}},50:(e,t)=>{"use strict";var r;Object.defineProperty(t,"__esModule",{value:!0}),t.Header=void 0,t.Header=r,function(e){e.IfModifiedSince="if-modified-since",e.LastModified="last-modified",e.IfNoneMatch="if-none-match",e.CacheControl="cache-control",e.ETag="etag",e.Expires="expires",e.Age="age",e.ContentType="content-type",e.XAxiosCacheEtag="x-axios-cache-etag",e.XAxiosCacheLastModified="x-axios-cache-last-modified"}(r||(t.Header=r={}))},571:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.defaultKeyGenerator=void 0;var r=/^\/|\/+$/g;t.defaultKeyGenerator=function(e){var t=e.baseURL,n=void 0===t?"":t,a=e.url,o=void 0===a?"":a,i=e.method,u=e.params,c=e.id;if(c)return String(c);n=n.replace(r,""),o=o.replace(r,"");var s=(null==i?void 0:i.toLowerCase())||"get",f=u?JSON.stringify(u,Object.keys(u).sort()):"{}";return"".concat(s,"::").concat(n+(o&&n?"/":"")+o,"::").concat(f)}},939:(e,t)=>{"use strict";function r(e,t,r,n,a,o,i){try{var u=e[o](i),c=u.value}catch(e){return void r(e)}u.done?t(c):Promise.resolve(c).then(n,a)}function n(e){return function(){var t=this,n=arguments;return new Promise((function(a,o){var i=e.apply(t,n);function u(e){r(i,a,o,u,c,"next",e)}function c(e){r(i,a,o,u,c,"throw",e)}u(void 0)}))}}function a(){return(a=n(regeneratorRuntime.mark((function e(t,r,n){var a,o,i,u;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:e.t0=regeneratorRuntime.keys(n);case 1:if((e.t1=e.t0()).done){e.next=22;break}if(a=e.t1.value,"delete"!==(o=n[a])){e.next=8;break}return e.next=7,t.remove(a);case 7:return e.abrupt("continue",1);case 8:return e.next=10,t.get(a);case 10:if("loading"!==(i=e.sent).state){e.next=13;break}throw new Error("cannot update the cache while loading");case 13:if(void 0!==(u=o(i,r))){e.next=18;break}return e.next=17,t.remove(a);case 17:return e.abrupt("continue",1);case 18:return e.next=20,t.set(a,u);case 20:e.next=1;break;case 22:case"end":return e.stop()}}),e)})))).apply(this,arguments)}Object.defineProperty(t,"__esModule",{value:!0}),t.updateCache=function(e,t,r){return a.apply(this,arguments)}},86:(e,t)=>{!function(e){var t=Symbol("cache-parser"),r={immutable:"immutable",maxAge:"max-age",maxStale:"max-stale",minFresh:"min-fresh",mustRevalidate:"must-revalidate",mustUnderstand:"must-understand",noCache:"no-cache",noStore:"no-store",noTransform:"no-transform",onlyIfCached:"only-if-cached",private:"private",proxyRevalidate:"proxy-revalidate",public:"public",sMaxAge:"s-maxage",staleIfError:"stale-if-error",staleWhileRevalidate:"stale-while-revalidate"};for(var n in r)r[r[n]]=n;function a(e){return("string"==typeof e||"number"==typeof e)&&(e=Number(e))>=0&&e<1/0}function o(e){return!0===e||"number"==typeof e||"string"==typeof e&&"false"!==e}e.Directive=r,e.toDuration=a,e.toBoolean=o,e.isCacheControl=function(e){return!!e&&!!e[t]},e.tokenize=function(e){if(!e||"object"!=typeof e)return[];var t=[];return o(e.immutable)&&t.push(r.immutable),a(e.maxAge)&&t.push(r.maxAge+"="+Number(e.maxAge)),a(e.maxStale)&&t.push(r.maxStale+"="+Number(e.maxStale)),a(e.minFresh)&&t.push(r.minFresh+"="+Number(e.minFresh)),o(e.mustRevalidate)&&t.push(r.mustRevalidate),o(e.mustUnderstand)&&t.push(r.mustUnderstand),o(e.noCache)&&t.push(r.noCache),o(e.noStore)&&t.push(r.noStore),o(e.noTransform)&&t.push(r.noTransform),o(e.onlyIfCached)&&t.push(r.onlyIfCached),o(e.private)&&t.push(r.private),o(e.proxyRevalidate)&&t.push(r.proxyRevalidate),o(e.public)&&t.push(r.public),a(e.sMaxAge)&&t.push(r.sMaxAge+"="+Number(e.sMaxAge)),a(e.staleIfError)&&t.push(r.staleIfError+"="+Number(e.staleIfError)),a(e.staleWhileRevalidate)&&t.push(r.staleWhileRevalidate+"="+Number(e.staleWhileRevalidate)),t},e.parse=function(e){var n=Object.defineProperty({},t,{configurable:!1,enumerable:!1,writable:!1,value:1});if(!e||"string"!=typeof e)return n;var i={},u=e.toLowerCase().replace(/\s+/g,"").split(",");for(var c in u){var s=u[c].split("=",2);i[s[0]]=1===s.length||s[1]}return o(i[r.immutable])&&(n.immutable=!0),a(i[r.maxAge])&&(n.maxAge=Number(i[r.maxAge])),a(i[r.maxStale])&&(n.maxStale=Number(i[r.maxStale])),a(i[r.minFresh])&&(n.minFresh=Number(i[r.minFresh])),o(i[r.mustRevalidate])&&(n.mustRevalidate=!0),o(i[r.mustUnderstand])&&(n.mustUnderstand=!0),o(i[r.noCache])&&(n.noCache=!0),o(i[r.noStore])&&(n.noStore=!0),o(i[r.noTransform])&&(n.noTransform=!0),o(i[r.onlyIfCached])&&(n.onlyIfCached=!0),o(i[r.private])&&(n.private=!0),o(i[r.proxyRevalidate])&&(n.proxyRevalidate=!0),o(i[r.public])&&(n.public=!0),a(i[r.sMaxAge])&&(n.sMaxAge=Number(i[r.sMaxAge])),a(i[r.staleIfError])&&(n.staleIfError=Number(i[r.staleIfError])),a(i[r.staleWhileRevalidate])&&(n.staleWhileRevalidate=Number(i[r.staleWhileRevalidate])),n}}(t)},549:(e,t)=>{var r,n;r=t,n=Symbol("fast-defer"),r.deferred=function(){var e,t,r=new Promise(((r,n)=>{e=r,t=n}));return r.resolve=e,r.reject=t,r[n]=1,r},r.isDeferred=function(e){return!!e&&!!e[n]}}},t={},r=function r(n){var a=t[n];if(void 0!==a)return a.exports;var o=t[n]={exports:{}};return e[n](o,o.exports,r),o.exports}(138),r;var e,t,r}));
//# sourceMappingURL=index.bundle.js.map
import type { AxiosResponse } from 'axios';
import type { AxiosCacheInstance, CacheAxiosResponse } from '../cache/axios';
import type { CacheProperties } from '../cache/cache';
import type { CachedResponse } from '../storage/types';

@@ -14,3 +13,2 @@ import type { AxiosInterceptor } from './types';

readonly cachedResponse: (response: AxiosResponse<R, D>) => CacheAxiosResponse<R, D>;
static readonly testCachePredicate: <R_1>(response: AxiosResponse<R_1, any>, cache: CacheProperties) => boolean;
/**

@@ -17,0 +15,0 @@ * Creates the new date to the cache by the provided response. Also handles possible 304

@@ -1,1 +0,1 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.CacheResponseInterceptor=void 0;var _cachePredicate=require("../util/cache-predicate");var _headers=require("../util/headers");var _updateCache=require("../util/update-cache");function _typeof(obj){"@babel/helpers - typeof";if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){_typeof=function _typeof(obj){return typeof obj;};}else{_typeof=function _typeof(obj){return obj&&typeof Symbol==="function"&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj;};}return _typeof(obj);}function ownKeys(object,enumerableOnly){var keys=Object.keys(object);if(Object.getOwnPropertySymbols){var symbols=Object.getOwnPropertySymbols(object);if(enumerableOnly){symbols=symbols.filter(function(sym){return Object.getOwnPropertyDescriptor(object,sym).enumerable;});}keys.push.apply(keys,symbols);}return keys;}function _objectSpread(target){for(var i=1;i<arguments.length;i++){var source=arguments[i]!=null?arguments[i]:{};if(i%2){ownKeys(Object(source),true).forEach(function(key){_defineProperty(target,key,source[key]);});}else if(Object.getOwnPropertyDescriptors){Object.defineProperties(target,Object.getOwnPropertyDescriptors(source));}else{ownKeys(Object(source)).forEach(function(key){Object.defineProperty(target,key,Object.getOwnPropertyDescriptor(source,key));});}}return target;}function asyncGeneratorStep(gen,resolve,reject,_next,_throw,key,arg){try{var info=gen[key](arg);var value=info.value;}catch(error){reject(error);return;}if(info.done){resolve(value);}else{Promise.resolve(value).then(_next,_throw);}}function _asyncToGenerator(fn){return function(){var self=this,args=arguments;return new Promise(function(resolve,reject){var gen=fn.apply(self,args);function _next(value){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"next",value);}function _throw(err){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"throw",err);}_next(undefined);});};}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}var CacheResponseInterceptor=function CacheResponseInterceptor(axios){var _this=this;_classCallCheck(this,CacheResponseInterceptor);_defineProperty(this,"use",function(){_this.axios.interceptors.response.use(_this.onFulfilled);});_defineProperty(this,"onFulfilled",function(){var _ref=_asyncToGenerator(regeneratorRuntime.mark(function _callee(axiosResponse){var response,cacheConfig,cache,ttl,expirationTime,data,newCache,deferred;return regeneratorRuntime.wrap(function _callee$(_context){while(1){switch(_context.prev=_context.next){case 0:response=_this.cachedResponse(axiosResponse);if(!response.cached){_context.next=3;break;}return _context.abrupt("return",response);case 3:if(response.config.cache){_context.next=5;break;}return _context.abrupt("return",_objectSpread(_objectSpread({},response),{},{cached:false}));case 5:cacheConfig=response.config.cache;_context.next=8;return _this.axios.storage.get(response.id);case 8:cache=_context.sent;if(!(cache.state==='stale'||cache.state==='empty'||cache.state==='cached')){_context.next=11;break;}return _context.abrupt("return",response);case 11:if(!(!cache.data&&!CacheResponseInterceptor.testCachePredicate(response,cacheConfig))){_context.next=15;break;}_context.next=14;return _this.rejectResponse(response.id);case 14:return _context.abrupt("return",response);case 15:delete response.headers[_headers.Header.XAxiosCacheEtag];delete response.headers[_headers.Header.XAxiosCacheLastModified];if(cacheConfig.etag&&cacheConfig.etag!==true){response.headers[_headers.Header.XAxiosCacheEtag]=cacheConfig.etag;}if(cacheConfig.modifiedSince){response.headers[_headers.Header.XAxiosCacheLastModified]=cacheConfig.modifiedSince===true?'use-cache-timestamp':cacheConfig.modifiedSince.toUTCString();}ttl=cacheConfig.ttl||-1;if(!(cacheConfig!==null&&cacheConfig!==void 0&&cacheConfig.interpretHeader)){_context.next=27;break;}expirationTime=_this.axios.headerInterpreter(response.headers);if(!(expirationTime===false)){_context.next=26;break;}_context.next=25;return _this.rejectResponse(response.id);case 25:return _context.abrupt("return",response);case 26:ttl=expirationTime||expirationTime===0?expirationTime:ttl;case 27:data=CacheResponseInterceptor.createCacheData(response,cache.data);newCache={state:'cached',ttl:ttl,createdAt:Date.now(),data:data};if(cacheConfig!==null&&cacheConfig!==void 0&&cacheConfig.update){(0,_updateCache.updateCache)(_this.axios.storage,response.data,cacheConfig.update);}deferred=_this.axios.waiting[response.id];_context.next=33;return deferred===null||deferred===void 0?void 0:deferred.resolve(newCache.data);case 33:delete _this.axios.waiting[response.id];_context.next=36;return _this.axios.storage.set(response.id,newCache);case 36:return _context.abrupt("return",response);case 37:case"end":return _context.stop();}}},_callee);}));return function(_x){return _ref.apply(this,arguments);};}());_defineProperty(this,"rejectResponse",function(){var _ref2=_asyncToGenerator(regeneratorRuntime.mark(function _callee2(key){var _this$axios$waiting$k;return regeneratorRuntime.wrap(function _callee2$(_context2){while(1){switch(_context2.prev=_context2.next){case 0:_context2.next=2;return _this.axios.storage.remove(key);case 2:(_this$axios$waiting$k=_this.axios.waiting[key])===null||_this$axios$waiting$k===void 0?void 0:_this$axios$waiting$k.reject(null);delete _this.axios.waiting[key];case 4:case"end":return _context2.stop();}}},_callee2);}));return function(_x2){return _ref2.apply(this,arguments);};}());_defineProperty(this,"cachedResponse",function(response){return _objectSpread({id:_this.axios.generateKey(response.config),cached:response.cached||false},response);});this.axios=axios;};exports.CacheResponseInterceptor=CacheResponseInterceptor;_defineProperty(CacheResponseInterceptor,"testCachePredicate",function(response,cache){var cachePredicate=cache.cachePredicate;return typeof cachePredicate==='function'&&cachePredicate(response)||_typeof(cachePredicate)==='object'&&(0,_cachePredicate.checkPredicateObject)(response,cachePredicate);});_defineProperty(CacheResponseInterceptor,"createCacheData",function(response,cache){if(response.status===304&&cache){response.cached=true;response.data=cache.data;response.status=cache.status;response.statusText=cache.statusText;response.headers=_objectSpread(_objectSpread({},cache.headers),response.headers);return cache;}return{data:response.data,status:response.status,statusText:response.statusText,headers:response.headers};});
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.CacheResponseInterceptor=void 0;var _cachePredicate=require("../util/cache-predicate");var _headers=require("../util/headers");var _updateCache=require("../util/update-cache");function ownKeys(object,enumerableOnly){var keys=Object.keys(object);if(Object.getOwnPropertySymbols){var symbols=Object.getOwnPropertySymbols(object);if(enumerableOnly){symbols=symbols.filter(function(sym){return Object.getOwnPropertyDescriptor(object,sym).enumerable;});}keys.push.apply(keys,symbols);}return keys;}function _objectSpread(target){for(var i=1;i<arguments.length;i++){var source=arguments[i]!=null?arguments[i]:{};if(i%2){ownKeys(Object(source),true).forEach(function(key){_defineProperty(target,key,source[key]);});}else if(Object.getOwnPropertyDescriptors){Object.defineProperties(target,Object.getOwnPropertyDescriptors(source));}else{ownKeys(Object(source)).forEach(function(key){Object.defineProperty(target,key,Object.getOwnPropertyDescriptor(source,key));});}}return target;}function asyncGeneratorStep(gen,resolve,reject,_next,_throw,key,arg){try{var info=gen[key](arg);var value=info.value;}catch(error){reject(error);return;}if(info.done){resolve(value);}else{Promise.resolve(value).then(_next,_throw);}}function _asyncToGenerator(fn){return function(){var self=this,args=arguments;return new Promise(function(resolve,reject){var gen=fn.apply(self,args);function _next(value){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"next",value);}function _throw(err){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"throw",err);}_next(undefined);});};}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}var CacheResponseInterceptor=function CacheResponseInterceptor(axios){var _this=this;_classCallCheck(this,CacheResponseInterceptor);_defineProperty(this,"use",function(){_this.axios.interceptors.response.use(_this.onFulfilled);});_defineProperty(this,"onFulfilled",function(){var _ref=_asyncToGenerator(regeneratorRuntime.mark(function _callee(axiosResponse){var response,cacheConfig,cache,ttl,expirationTime,data,newCache,deferred;return regeneratorRuntime.wrap(function _callee$(_context){while(1){switch(_context.prev=_context.next){case 0:response=_this.cachedResponse(axiosResponse);if(!response.cached){_context.next=3;break;}return _context.abrupt("return",response);case 3:if(response.config.cache){_context.next=5;break;}return _context.abrupt("return",_objectSpread(_objectSpread({},response),{},{cached:false}));case 5:cacheConfig=response.config.cache;_context.next=8;return _this.axios.storage.get(response.id);case 8:cache=_context.sent;if(!(cache.state==='stale'||cache.state==='empty'||cache.state==='cached')){_context.next=11;break;}return _context.abrupt("return",response);case 11:if(!(!cache.data&&!(0,_cachePredicate.shouldCacheResponse)(response,cacheConfig))){_context.next=15;break;}_context.next=14;return _this.rejectResponse(response.id);case 14:return _context.abrupt("return",response);case 15:delete response.headers[_headers.Header.XAxiosCacheEtag];delete response.headers[_headers.Header.XAxiosCacheLastModified];if(cacheConfig.etag&&cacheConfig.etag!==true){response.headers[_headers.Header.XAxiosCacheEtag]=cacheConfig.etag;}if(cacheConfig.modifiedSince){response.headers[_headers.Header.XAxiosCacheLastModified]=cacheConfig.modifiedSince===true?'use-cache-timestamp':cacheConfig.modifiedSince.toUTCString();}ttl=cacheConfig.ttl||-1;if(!(cacheConfig!==null&&cacheConfig!==void 0&&cacheConfig.interpretHeader)){_context.next=27;break;}expirationTime=_this.axios.headerInterpreter(response.headers);if(!(expirationTime===false)){_context.next=26;break;}_context.next=25;return _this.rejectResponse(response.id);case 25:return _context.abrupt("return",response);case 26:ttl=expirationTime||expirationTime===0?expirationTime:ttl;case 27:data=CacheResponseInterceptor.createCacheData(response,cache.data);newCache={state:'cached',ttl:ttl,createdAt:Date.now(),data:data};if(cacheConfig!==null&&cacheConfig!==void 0&&cacheConfig.update){(0,_updateCache.updateCache)(_this.axios.storage,response.data,cacheConfig.update);}deferred=_this.axios.waiting[response.id];_context.next=33;return deferred===null||deferred===void 0?void 0:deferred.resolve(newCache.data);case 33:delete _this.axios.waiting[response.id];_context.next=36;return _this.axios.storage.set(response.id,newCache);case 36:return _context.abrupt("return",response);case 37:case"end":return _context.stop();}}},_callee);}));return function(_x){return _ref.apply(this,arguments);};}());_defineProperty(this,"rejectResponse",function(){var _ref2=_asyncToGenerator(regeneratorRuntime.mark(function _callee2(key){var _this$axios$waiting$k;return regeneratorRuntime.wrap(function _callee2$(_context2){while(1){switch(_context2.prev=_context2.next){case 0:_context2.next=2;return _this.axios.storage.remove(key);case 2:(_this$axios$waiting$k=_this.axios.waiting[key])===null||_this$axios$waiting$k===void 0?void 0:_this$axios$waiting$k.reject(null);delete _this.axios.waiting[key];case 4:case"end":return _context2.stop();}}},_callee2);}));return function(_x2){return _ref2.apply(this,arguments);};}());_defineProperty(this,"cachedResponse",function(response){return _objectSpread({id:_this.axios.generateKey(response.config),cached:response.cached||false},response);});this.axios=axios;};exports.CacheResponseInterceptor=CacheResponseInterceptor;_defineProperty(CacheResponseInterceptor,"createCacheData",function(response,cache){if(response.status===304&&cache){response.cached=true;response.data=cache.data;response.status=cache.status;response.statusText=cache.statusText;response.headers=_objectSpread(_objectSpread({},cache.headers),response.headers);return cache;}return{data:response.data,status:response.status,statusText:response.statusText,headers:response.headers};});
import type { AxiosResponse } from 'axios';
import type { CacheProperties } from '..';
import type { CachePredicateObject } from './types';
export declare function checkPredicateObject<R>(response: AxiosResponse<R>, { statusCheck, containsHeaders, responseMatch }: CachePredicateObject): boolean;
/** Returns true if the response should be cached */
export declare function shouldCacheResponse<R>(response: AxiosResponse<R>, { cachePredicate }: CacheProperties): boolean;
export declare function isCachePredicateValid<R>(response: AxiosResponse<R>, { statusCheck, containsHeaders, responseMatch }: CachePredicateObject): boolean;
//# sourceMappingURL=cache-predicate.d.ts.map

@@ -1,1 +0,1 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.checkPredicateObject=checkPredicateObject;function _typeof(obj){"@babel/helpers - typeof";if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){_typeof=function _typeof(obj){return typeof obj;};}else{_typeof=function _typeof(obj){return obj&&typeof Symbol==="function"&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj;};}return _typeof(obj);}function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_unsupportedIterableToArray(arr,i)||_nonIterableRest();}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");}function _unsupportedIterableToArray(o,minLen){if(!o)return;if(typeof o==="string")return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);if(n==="Object"&&o.constructor)n=o.constructor.name;if(n==="Map"||n==="Set")return Array.from(o);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray(o,minLen);}function _arrayLikeToArray(arr,len){if(len==null||len>arr.length)len=arr.length;for(var i=0,arr2=new Array(len);i<len;i++){arr2[i]=arr[i];}return arr2;}function _iterableToArrayLimit(arr,i){var _i=arr==null?null:typeof Symbol!=="undefined"&&arr[Symbol.iterator]||arr["@@iterator"];if(_i==null)return;var _arr=[];var _n=true;var _d=false;var _s,_e;try{for(_i=_i.call(arr);!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break;}}catch(err){_d=true;_e=err;}finally{try{if(!_n&&_i["return"]!=null)_i["return"]();}finally{if(_d)throw _e;}}return _arr;}function _arrayWithHoles(arr){if(Array.isArray(arr))return arr;}function checkPredicateObject(response,_ref){var statusCheck=_ref.statusCheck,containsHeaders=_ref.containsHeaders,responseMatch=_ref.responseMatch;if(statusCheck){if(typeof statusCheck==='function'){if(!statusCheck(response.status)){return false;}}else{var _statusCheck=_slicedToArray(statusCheck,2),start=_statusCheck[0],end=_statusCheck[1];if(response.status<start||response.status>end){return false;}}}if(containsHeaders){for(var headerName in containsHeaders){var value=containsHeaders[headerName];var header=response.headers[headerName];if(!header){return false;}switch(_typeof(value)){case'string':if(header!=value){return false;}break;case'function':if(!value(header)){return false;}break;}}}if(responseMatch&&!responseMatch(response.data)){return false;}return true;}
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.isCachePredicateValid=isCachePredicateValid;exports.shouldCacheResponse=shouldCacheResponse;function _typeof(obj){"@babel/helpers - typeof";if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){_typeof=function _typeof(obj){return typeof obj;};}else{_typeof=function _typeof(obj){return obj&&typeof Symbol==="function"&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj;};}return _typeof(obj);}function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_unsupportedIterableToArray(arr,i)||_nonIterableRest();}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");}function _unsupportedIterableToArray(o,minLen){if(!o)return;if(typeof o==="string")return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);if(n==="Object"&&o.constructor)n=o.constructor.name;if(n==="Map"||n==="Set")return Array.from(o);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray(o,minLen);}function _arrayLikeToArray(arr,len){if(len==null||len>arr.length)len=arr.length;for(var i=0,arr2=new Array(len);i<len;i++){arr2[i]=arr[i];}return arr2;}function _iterableToArrayLimit(arr,i){var _i=arr==null?null:typeof Symbol!=="undefined"&&arr[Symbol.iterator]||arr["@@iterator"];if(_i==null)return;var _arr=[];var _n=true;var _d=false;var _s,_e;try{for(_i=_i.call(arr);!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break;}}catch(err){_d=true;_e=err;}finally{try{if(!_n&&_i["return"]!=null)_i["return"]();}finally{if(_d)throw _e;}}return _arr;}function _arrayWithHoles(arr){if(Array.isArray(arr))return arr;}function shouldCacheResponse(response,_ref){var cachePredicate=_ref.cachePredicate;if(typeof cachePredicate==='function'){return cachePredicate(response);}return isCachePredicateValid(response,cachePredicate);}function isCachePredicateValid(response,_ref2){var statusCheck=_ref2.statusCheck,containsHeaders=_ref2.containsHeaders,responseMatch=_ref2.responseMatch;if(statusCheck){if(typeof statusCheck==='function'){if(!statusCheck(response.status)){return false;}}else{var _statusCheck=_slicedToArray(statusCheck,2),start=_statusCheck[0],end=_statusCheck[1];if(response.status<start||response.status>end){return false;}}}if(containsHeaders){for(var headerName in containsHeaders){var value=containsHeaders[headerName];var header=response.headers[headerName];if(!header){return false;}switch(_typeof(value)){case'string':if(header!=value){return false;}break;case'function':if(!value(header)){return false;}break;}}}if(responseMatch&&!responseMatch(response.data)){return false;}return true;}
{
"name": "axios-cache-interceptor",
"version": "0.7.2",
"version": "0.7.3",
"description": "Cache interceptor for axios",
"main": "./dist/index.js",
"browser": "./dist/index.bundle.js",
"jsdelivr": "./dist/index.bundle.js",

@@ -45,3 +46,3 @@ "unpkg": "./dist/index.bundle.js",

"dependencies": {
"@tusbar/cache-control": "^0.6.1",
"cache-parser": "^1.1.1",
"fast-defer": "^1.1.2"

@@ -59,4 +60,4 @@ },

"@types/webpack": "^5.28.0",
"@typescript-eslint/eslint-plugin": "^5.4.0",
"@typescript-eslint/parser": "^5.4.0",
"@typescript-eslint/eslint-plugin": "^5.7.0",
"@typescript-eslint/parser": "^5.7.0",
"auto-changelog": "^2.3.0",

@@ -63,0 +64,0 @@ "axios": "~0.24.0",

@@ -1,2 +0,2 @@

import { parse } from '@tusbar/cache-control';
import { parse } from 'cache-parser';
import { Header } from '../util/headers';

@@ -3,0 +3,0 @@ import type { HeaderInterpreter, HeadersInterpreter } from './types';

@@ -5,3 +5,3 @@ import type { AxiosResponse } from 'axios';

import type { CachedResponse, CachedStorageValue } from '../storage/types';
import { checkPredicateObject } from '../util/cache-predicate';
import { shouldCacheResponse } from '../util/cache-predicate';
import { Header } from '../util/headers';

@@ -54,3 +54,3 @@ import { updateCache } from '../util/update-cache';

!cache.data &&
!CacheResponseInterceptor.testCachePredicate(response, cacheConfig)
!shouldCacheResponse(response, cacheConfig)
) {

@@ -136,15 +136,2 @@ await this.rejectResponse(response.id);

static readonly testCachePredicate = <R>(
response: AxiosResponse<R>,
cache: CacheProperties
): boolean => {
const cachePredicate = cache.cachePredicate;
return (
(typeof cachePredicate === 'function' && cachePredicate(response)) ||
(typeof cachePredicate === 'object' &&
checkPredicateObject(response, cachePredicate))
);
};
/**

@@ -151,0 +138,0 @@ * Creates the new date to the cache by the provided response. Also handles possible 304

import type { AxiosResponse } from 'axios';
import type { CacheProperties } from '..';
import type { CachePredicateObject } from './types';
export function checkPredicateObject<R>(
/** Returns true if the response should be cached */
export function shouldCacheResponse<R>(
response: AxiosResponse<R>,
{ cachePredicate }: CacheProperties
) {
if (typeof cachePredicate === 'function') {
return cachePredicate(response);
}
return isCachePredicateValid(response, cachePredicate);
}
export function isCachePredicateValid<R>(
response: AxiosResponse<R>,
{ statusCheck, containsHeaders, responseMatch }: CachePredicateObject

@@ -7,0 +20,0 @@ ): boolean {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc