axios-cache-interceptor
Advanced tools
Comparing version 0.7.1 to 0.7.2
@@ -9,10 +9,5 @@ import type { AxiosDefaults, AxiosInstance, AxiosInterceptorManager, AxiosRequestConfig, AxiosResponse } from 'axios'; | ||
config: CacheRequestConfig<D>; | ||
/** | ||
* The id used for this request. if config specified an id, the id | ||
* will be returned | ||
*/ | ||
/** The id used for this request. if config specified an id, the id will be returned */ | ||
id: string; | ||
/** | ||
* A simple boolean to check whether this request was cached or not | ||
*/ | ||
/** A simple boolean to check whether this request was cached or not */ | ||
cached: boolean; | ||
@@ -27,4 +22,4 @@ }; | ||
/** | ||
* An id for this request, if this request is used in cache, only | ||
* the last request made with this id will be returned. | ||
* An id for this request, if this request is used in cache, only the last request made | ||
* with this id will be returned. | ||
* | ||
@@ -42,4 +37,4 @@ * @default undefined | ||
/** | ||
* Same as the AxiosInstance but with CacheRequestConfig as a config | ||
* type and CacheAxiosResponse as response type. | ||
* Same as the AxiosInstance but with CacheRequestConfig as a config type and | ||
* CacheAxiosResponse as response type. | ||
* | ||
@@ -70,5 +65,3 @@ * @see AxiosInstance | ||
}; | ||
/** | ||
* @template D The type that the request body use | ||
*/ | ||
/** @template D The type that the request body use */ | ||
getUri<D>(config?: CacheRequestConfig<D>): string; | ||
@@ -75,0 +68,0 @@ /** |
@@ -14,4 +14,4 @@ import type { Method } from 'axios'; | ||
* | ||
* When using `interpretHeader: true`, this value will only be used | ||
* if the interpreter can't determine their TTL value to override this | ||
* When using `interpretHeader: true`, this value will only be used if the interpreter | ||
* can't determine their TTL value to override this | ||
* | ||
@@ -24,4 +24,4 @@ * **Note**: a custom storage implementation may not respect this. | ||
/** | ||
* If this interceptor should configure the cache from the request | ||
* cache header When used, the ttl property is ignored | ||
* If this interceptor should configure the cache from the request cache header When | ||
* used, the ttl property is ignored | ||
* | ||
@@ -44,5 +44,4 @@ * @default false | ||
/** | ||
* Once the request is resolved, this specifies what requests should | ||
* we change the cache. Can be used to update the request or delete | ||
* other caches. | ||
* Once the request is resolved, this specifies what requests should we change the | ||
* cache. Can be used to update the request or delete other caches. | ||
* | ||
@@ -53,4 +52,3 @@ * If the function returns nothing, the entry is deleted | ||
* | ||
* The id used is the same as the id on `CacheRequestConfig['id']`, | ||
* auto-generated or not. | ||
* The id used is the same as the id on `CacheRequestConfig['id']`, auto-generated or not. | ||
* | ||
@@ -61,4 +59,4 @@ * @default {{}} | ||
/** | ||
* If the request should handle ETag and If-None-Match support. Use | ||
* a string to force a custom value or true to use the response ETag | ||
* If the request should handle ETag and If-None-Match support. Use a string to force a | ||
* custom value or true to use the response ETag | ||
* | ||
@@ -70,5 +68,4 @@ * @default false | ||
/** | ||
* Use If-Modified-Since header in this request. Use a date to force | ||
* a custom value or true to use the last cached timestamp. If never | ||
* cached before, the header is not set. | ||
* Use If-Modified-Since header in this request. Use a date to force a custom value or | ||
* true to use the last cached timestamp. If never cached before, the header is not set. | ||
* | ||
@@ -88,11 +85,9 @@ * @default false | ||
/** | ||
* The function used to create different keys for each request. | ||
* Defaults to a function that priorizes the id, and if not | ||
* specified, a string is generated using the method, baseUrl, | ||
* params, and url | ||
* The function used to create different keys for each request. Defaults to a function | ||
* that priorizes the id, and if not specified, a string is generated using the method, | ||
* baseUrl, params, and url | ||
*/ | ||
generateKey: KeyGenerator; | ||
/** | ||
* A simple object that holds all deferred objects until it is | ||
* resolved or rejected. | ||
* A simple object that holds all deferred objects until it is resolved or rejected. | ||
* | ||
@@ -103,15 +98,11 @@ * Can be used to listen when a request is cached or not. | ||
/** | ||
* The function to parse and interpret response headers. Only used | ||
* if cache.interpretHeader is true. | ||
* The function to parse and interpret response headers. Only used if | ||
* cache.interpretHeader is true. | ||
*/ | ||
headerInterpreter: HeadersInterpreter; | ||
/** | ||
* The request interceptor that will be used to handle the cache. | ||
*/ | ||
/** The request interceptor that will be used to handle the cache. */ | ||
requestInterceptor: AxiosInterceptor<CacheRequestConfig<any>>; | ||
/** | ||
* The response interceptor that will be used to handle the cache. | ||
*/ | ||
/** The response interceptor that will be used to handle the cache. */ | ||
responseInterceptor: AxiosInterceptor<CacheAxiosResponse<any, any>>; | ||
} | ||
//# sourceMappingURL=cache.d.ts.map |
@@ -1,1 +0,1 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.useCache=useCache;var _interpreter=require("../header/interpreter");var _request=require("../interceptors/request");var _response=require("../interceptors/response");var _memory=require("../storage/memory");var _keyGenerator=require("../util/key-generator");var _excluded=["storage","generateKey","waiting","headerInterpreter","requestInterceptor","responseInterceptor"];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 _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;}function _objectWithoutProperties(source,excluded){if(source==null)return{};var target=_objectWithoutPropertiesLoose(source,excluded);var key,i;if(Object.getOwnPropertySymbols){var sourceSymbolKeys=Object.getOwnPropertySymbols(source);for(i=0;i<sourceSymbolKeys.length;i++){key=sourceSymbolKeys[i];if(excluded.indexOf(key)>=0)continue;if(!Object.prototype.propertyIsEnumerable.call(source,key))continue;target[key]=source[key];}}return target;}function _objectWithoutPropertiesLoose(source,excluded){if(source==null)return{};var target={};var sourceKeys=Object.keys(source);var key,i;for(i=0;i<sourceKeys.length;i++){key=sourceKeys[i];if(excluded.indexOf(key)>=0)continue;target[key]=source[key];}return target;}function useCache(axios){var _ref=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{},storage=_ref.storage,generateKey=_ref.generateKey,waiting=_ref.waiting,headerInterpreter=_ref.headerInterpreter,requestInterceptor=_ref.requestInterceptor,responseInterceptor=_ref.responseInterceptor,cacheOptions=_objectWithoutProperties(_ref,_excluded);var axiosCache=axios;axiosCache.storage=storage||new _memory.MemoryAxiosStorage({});axiosCache.generateKey=generateKey||_keyGenerator.defaultKeyGenerator;axiosCache.waiting=waiting||{};axiosCache.headerInterpreter=headerInterpreter||_interpreter.defaultHeaderInterpreter;axiosCache.requestInterceptor=requestInterceptor||new _request.CacheRequestInterceptor(axiosCache);axiosCache.responseInterceptor=responseInterceptor||new _response.CacheResponseInterceptor(axiosCache);axiosCache.defaults=_objectSpread(_objectSpread({},axios.defaults),{},{cache:_objectSpread({ttl:1000*60*5,interpretHeader:false,methods:['get'],cachePredicate:{statusCheck:[200,399]},etag:false,modifiedSince:false,update:{}},cacheOptions)});axiosCache.requestInterceptor.use();axiosCache.responseInterceptor.use();return axiosCache;} | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.useCache=useCache;var _interpreter=require("../header/interpreter");var _request=require("../interceptors/request");var _response=require("../interceptors/response");var _memory=require("../storage/memory");var _keyGenerator=require("../util/key-generator");var _excluded=["storage","generateKey","waiting","headerInterpreter","requestInterceptor","responseInterceptor"];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 _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;}function _objectWithoutProperties(source,excluded){if(source==null)return{};var target=_objectWithoutPropertiesLoose(source,excluded);var key,i;if(Object.getOwnPropertySymbols){var sourceSymbolKeys=Object.getOwnPropertySymbols(source);for(i=0;i<sourceSymbolKeys.length;i++){key=sourceSymbolKeys[i];if(excluded.indexOf(key)>=0)continue;if(!Object.prototype.propertyIsEnumerable.call(source,key))continue;target[key]=source[key];}}return target;}function _objectWithoutPropertiesLoose(source,excluded){if(source==null)return{};var target={};var sourceKeys=Object.keys(source);var key,i;for(i=0;i<sourceKeys.length;i++){key=sourceKeys[i];if(excluded.indexOf(key)>=0)continue;target[key]=source[key];}return target;}function useCache(axios){var _ref=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{},storage=_ref.storage,generateKey=_ref.generateKey,waiting=_ref.waiting,headerInterpreter=_ref.headerInterpreter,requestInterceptor=_ref.requestInterceptor,responseInterceptor=_ref.responseInterceptor,cacheOptions=_objectWithoutProperties(_ref,_excluded);var axiosCache=axios;axiosCache.storage=storage||new _memory.MemoryAxiosStorage();axiosCache.generateKey=generateKey||_keyGenerator.defaultKeyGenerator;axiosCache.waiting=waiting||{};axiosCache.headerInterpreter=headerInterpreter||_interpreter.defaultHeaderInterpreter;axiosCache.requestInterceptor=requestInterceptor||new _request.CacheRequestInterceptor(axiosCache);axiosCache.responseInterceptor=responseInterceptor||new _response.CacheResponseInterceptor(axiosCache);axiosCache.defaults=_objectSpread(_objectSpread({},axios.defaults),{},{cache:_objectSpread({ttl:1000*60*5,interpretHeader:false,methods:['get'],cachePredicate:{statusCheck:[200,399]},etag:false,modifiedSince:false,update:{}},cacheOptions)});axiosCache.requestInterceptor.use();axiosCache.responseInterceptor.use();return axiosCache;} |
@@ -13,5 +13,5 @@ /** | ||
* @param header The header object to interpret. | ||
* @returns `false` if cache should not be used. `undefined` when | ||
* provided headers was not enough to determine a valid value. Or a | ||
* `number` containing the number of **milliseconds** to cache the response. | ||
* @returns `false` if cache should not be used. `undefined` when provided headers was not | ||
* enough to determine a valid value. Or a `number` containing the number of | ||
* **milliseconds** to cache the response. | ||
*/ | ||
@@ -23,5 +23,5 @@ export declare type HeadersInterpreter = (headers?: Record<string, string>) => MaybeTtl; | ||
* @param header The header string to interpret. | ||
* @returns `false` if cache should not be used. `undefined` when | ||
* provided headers was not enough to determine a valid value. Or a | ||
* `number` containing the number of **milliseconds** to cache the response. | ||
* @returns `false` if cache should not be used. `undefined` when provided headers was not | ||
* enough to determine a valid value. Or a `number` containing the number of | ||
* **milliseconds** to cache the response. | ||
*/ | ||
@@ -28,0 +28,0 @@ export declare type HeaderInterpreter = (header: string, headers: Record<string, string>) => MaybeTtl; |
@@ -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",b="proxy-revalidate",v="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[b]),this.public=x(r[v]),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(b),this.public&&e.push(v),"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,b=p(t,c),v=e;return v.storage=r||new i.MemoryAxiosStorage({}),v.generateKey=s||u.defaultKeyGenerator,v.waiting=l||{},v.headerInterpreter=d||n.defaultHeaderInterpreter,v.requestInterceptor=h||new a.CacheRequestInterceptor(v),v.responseInterceptor=y||new o.CacheResponseInterceptor(v),v.defaults=f(f({},e.defaults),{},{cache:f({ttl:3e5,interpretHeader:!1,methods:["get"],cachePredicate:{statusCheck:[200,399]},etag:!1,modifiedSince:!1,update:{}},b)}),v.requestInterceptor.use(),v.responseInterceptor.use(),v};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,i,u=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),f(this,"use",(function(){u.axios.interceptors.request.use(u.onFulfilled)})),f(this,"onFulfilled",(r=regeneratorRuntime.mark((function t(r){var a,o,i,s,f;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!1!==r.cache){t.next=2;break}return t.abrupt("return",r);case 2:if(r.cache=c(c({},u.axios.defaults.cache),r.cache),u.isMethodAllowed(r.method,r.cache)){t.next=5;break}return t.abrupt("return",r);case 5:return a=u.axios.generateKey(r),t.next=8,u.axios.storage.get(a);case 8:if("empty"!=(o=t.sent).state&&"stale"!==o.state){t.next=22;break}if(!u.axios.waiting[a]){t.next=15;break}return t.next=13,u.axios.storage.get(a);case 13:return o=t.sent,t.abrupt("break",22);case 15:return u.axios.waiting[a]=(0,n.deferred)(),null===(i=u.axios.waiting[a])||void 0===i||i.catch((function(){})),t.next=19,u.axios.storage.set(a,{state:"loading",data:o.data});case 19:return"stale"===o.state&&u.setRevalidationHeaders(o,r),r.validateStatus=e.createValidateStatus(r.validateStatus),t.abrupt("return",r);case 22:if("loading"!==o.state){t.next=39;break}if(f=u.axios.waiting[a]){t.next=28;break}return t.next=27,u.axios.storage.remove(a);case 27:return t.abrupt("return",r);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",r);case 37:t.next=40;break;case 39:s=o.data;case 40:return r.adapter=function(){return Promise.resolve({config:r,data:s.data,headers:s.headers,status:s.status,statusText:s.statusText,cached:!0,id:a})},t.abrupt("return",r);case 42:case"end":return t.stop()}}),t,null,[[28,34]])})),i=function(){var e=this,t=arguments;return new Promise((function(n,a){var o=r.apply(e,t);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(e){return i.apply(this,arguments)})),f(this,"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(this,"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())})),this.axios=t};t.CacheRequestInterceptor=l,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}t.CacheResponseInterceptor=function e(t){var r,u,s=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),l(this,"use",(function(){s.axios.interceptors.response.use(s.onFulfilled)})),l(this,"onFulfilled",(r=f(regeneratorRuntime.mark((function e(t){var r,n,i,u,f,l,p,d;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(r=s.cachedResponse(t)).cached){e.next=3;break}return e.abrupt("return",r);case 3:if(r.config.cache){e.next=5;break}return e.abrupt("return",c(c({},r),{},{cached:!1}));case 5:return n=r.config.cache,e.next=8,s.axios.storage.get(r.id);case 8:if("stale"!==(i=e.sent).state&&"empty"!==i.state&&"cached"!==i.state){e.next=11;break}return e.abrupt("return",r);case 11:if(i.data||s.testCachePredicate(r,n)){e.next=15;break}return e.next=14,s.rejectResponse(r.id);case 14:return e.abrupt("return",r);case 15:if(delete r.headers[a.Header.XAxiosCacheEtag],delete r.headers[a.Header.XAxiosCacheLastModified],n.etag&&!0!==n.etag&&(r.headers[a.Header.XAxiosCacheEtag]=n.etag),n.modifiedSince&&(r.headers[a.Header.XAxiosCacheLastModified]=!0===n.modifiedSince?"use-cache-timestamp":n.modifiedSince.toUTCString()),u=n.ttl||-1,null==n||!n.interpretHeader){e.next=27;break}if(!1!==(f=s.axios.headerInterpreter(r.headers))){e.next=26;break}return e.next=25,s.rejectResponse(r.id);case 25:return e.abrupt("return",r);case 26:u=f||0===f?f:u;case 27:return l=304==r.status&&i.data?(r.cached=!0,r.data=i.data.data,r.status=i.data.status,r.statusText=i.data.statusText,r.headers=c(c({},i.data.headers),r.headers),i.data):{data:r.data,status:r.status,statusText:r.statusText,headers:r.headers},p={state:"cached",ttl:u,createdAt:Date.now(),data:l},null!=n&&n.update&&(0,o.updateCache)(s.axios.storage,r.data,n.update),d=s.axios.waiting[r.id],e.next=33,null==d?void 0:d.resolve(p.data);case 33:return delete s.axios.waiting[r.id],e.next=36,s.axios.storage.set(r.id,p);case 36:return e.abrupt("return",r);case 37:case"end":return e.stop()}}),e)}))),function(e){return r.apply(this,arguments)})),l(this,"testCachePredicate",(function(e,t){var r=t.cachePredicate;return"function"==typeof r&&r(e)||"object"===i(r)&&(0,n.checkPredicateObject)(e,r)})),l(this,"rejectResponse",(u=f(regeneratorRuntime.mark((function e(t){var r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,s.axios.storage.remove(t);case 2:null===(r=s.axios.waiting[t])||void 0===r||r.reject(null),delete s.axios.waiting[t];case 4:case"end":return e.stop()}}),e)}))),function(e){return u.apply(this,arguments)})),l(this,"cachedResponse",(function(e){return c({id:s.axios.generateKey(e.config),cached:e.cached||!1},e)})),this.axios=t}},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,u,c,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:r.DEFAULT_KEY_PREFIX;return i(this,r),p(f(n=t.call(this)),"find",(a=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)}))),function(e){return a.apply(this,arguments)})),p(f(n),"set",(u=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)}))),function(e,t){return u.apply(this,arguments)})),p(f(n),"remove",(c=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)}))),function(e){return c.apply(this,arguments)})),n.storage=e,n.prefix=s,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,a,u,c=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return i(this,r),p(f(e=t.call(this)),"find",(n=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)}))),function(e){return n.apply(this,arguments)})),p(f(e),"set",(a=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)}))),function(e,t){return a.apply(this,arguments)})),p(f(e),"remove",(u=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)}))),function(e){return u.apply(this,arguments)})),e.storage=c,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,r,n=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),o(this,"get",(t=regeneratorRuntime.mark((function t(r){var a,o;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,n.find(r);case 2:if(!("cached"!==(a=t.sent).state||a.createdAt+a.ttl>Date.now())){t.next=5;break}return t.abrupt("return",a);case 5:if(!e.keepIfStale(a)){t.next=10;break}return o={data:a.data,state:"stale",createdAt:a.createdAt},t.next=9,n.set(r,o);case 9:return t.abrupt("return",o);case 10:return t.next=12,n.remove(r);case 12:return t.abrupt("return",{state:"empty"});case 13:case"end":return t.stop()}}),t)})),r=function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,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(e){return r.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={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})); | ||
//# sourceMappingURL=index.bundle.js.map |
@@ -1,3 +0,5 @@ | ||
import type { AxiosRequestConfig } from 'axios'; | ||
import type { AxiosRequestConfig, Method } from 'axios'; | ||
import type { CacheProperties } from '..'; | ||
import type { AxiosCacheInstance, CacheRequestConfig } from '../cache/axios'; | ||
import type { StaleStorageValue } from '../storage/types'; | ||
import type { AxiosInterceptor } from './types'; | ||
@@ -7,12 +9,17 @@ export declare class CacheRequestInterceptor<D> implements AxiosInterceptor<CacheRequestConfig<D>> { | ||
constructor(axios: AxiosCacheInstance); | ||
use: () => void; | ||
onFulfilled: (config: CacheRequestConfig<D>) => Promise<CacheRequestConfig<D>>; | ||
private isMethodAllowed; | ||
private setRevalidationHeaders; | ||
readonly use: () => void; | ||
readonly onFulfilled: (config: CacheRequestConfig<D>) => Promise<CacheRequestConfig<D>>; | ||
static readonly isMethodAllowed: (method: Method, properties: Partial<CacheProperties>) => boolean; | ||
static readonly setRevalidationHeaders: <D_1>(cache: StaleStorageValue, config: AxiosRequestConfig<D_1> & { | ||
id?: string | undefined; | ||
cache?: false | Partial<CacheProperties> | undefined; | ||
} & { | ||
cache: Partial<CacheProperties>; | ||
}) => void; | ||
/** | ||
* Creates a new validateStatus function that will use the one | ||
* already used and also accept status code 304. | ||
* Creates a new validateStatus function that will use the one already used and also | ||
* accept status code 304. | ||
*/ | ||
static createValidateStatus: (oldValidate?: AxiosRequestConfig['validateStatus']) => (status: number) => boolean; | ||
static readonly createValidateStatus: (oldValidate?: AxiosRequestConfig['validateStatus']) => (status: number) => boolean; | ||
} | ||
//# sourceMappingURL=request.d.ts.map |
@@ -1,1 +0,1 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.CacheRequestInterceptor=void 0;var _fastDefer=require("fast-defer");var _headers=require("../util/headers");function _createForOfIteratorHelper(o,allowArrayLike){var it=typeof Symbol!=="undefined"&&o[Symbol.iterator]||o["@@iterator"];if(!it){if(Array.isArray(o)||(it=_unsupportedIterableToArray(o))||allowArrayLike&&o&&typeof o.length==="number"){if(it)o=it;var i=0;var F=function F(){};return{s:F,n:function n(){if(i>=o.length)return{done:true};return{done:false,value:o[i++]};},e:function e(_e){throw _e;},f:F};}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 normalCompletion=true,didErr=false,err;return{s:function s(){it=it.call(o);},n:function n(){var step=it.next();normalCompletion=step.done;return step;},e:function e(_e2){didErr=true;err=_e2;},f:function f(){try{if(!normalCompletion&&it.return!=null)it.return();}finally{if(didErr)throw err;}}};}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 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 CacheRequestInterceptor=function CacheRequestInterceptor(axios){var _this=this;_classCallCheck(this,CacheRequestInterceptor);_defineProperty(this,"use",function(){_this.axios.interceptors.request.use(_this.onFulfilled);});_defineProperty(this,"onFulfilled",function(){var _ref=_asyncToGenerator(regeneratorRuntime.mark(function _callee(config){var key,cache,_this$axios$waiting$k,cachedResponse,_deferred;return regeneratorRuntime.wrap(function _callee$(_context){while(1){switch(_context.prev=_context.next){case 0:if(!(config.cache===false)){_context.next=2;break;}return _context.abrupt("return",config);case 2:config.cache=_objectSpread(_objectSpread({},_this.axios.defaults.cache),config.cache);if(_this.isMethodAllowed(config.method,config.cache)){_context.next=5;break;}return _context.abrupt("return",config);case 5:key=_this.axios.generateKey(config);_context.next=8;return _this.axios.storage.get(key);case 8:cache=_context.sent;if(!(cache.state=='empty'||cache.state==='stale')){_context.next=22;break;}if(!_this.axios.waiting[key]){_context.next=15;break;}_context.next=13;return _this.axios.storage.get(key);case 13:cache=_context.sent;return _context.abrupt("break",22);case 15:_this.axios.waiting[key]=(0,_fastDefer.deferred)();(_this$axios$waiting$k=_this.axios.waiting[key])===null||_this$axios$waiting$k===void 0?void 0:_this$axios$waiting$k.catch(function(){return undefined;});_context.next=19;return _this.axios.storage.set(key,{state:'loading',data:cache.data});case 19:if(cache.state==='stale'){_this.setRevalidationHeaders(cache,config);}config.validateStatus=CacheRequestInterceptor.createValidateStatus(config.validateStatus);return _context.abrupt("return",config);case 22:if(!(cache.state==='loading')){_context.next=39;break;}_deferred=_this.axios.waiting[key];if(_deferred){_context.next=28;break;}_context.next=27;return _this.axios.storage.remove(key);case 27:return _context.abrupt("return",config);case 28:_context.prev=28;_context.next=31;return _deferred;case 31:cachedResponse=_context.sent;_context.next=37;break;case 34:_context.prev=34;_context.t0=_context["catch"](28);return _context.abrupt("return",config);case 37:_context.next=40;break;case 39:cachedResponse=cache.data;case 40:config.adapter=function(){return Promise.resolve({config:config,data:cachedResponse.data,headers:cachedResponse.headers,status:cachedResponse.status,statusText:cachedResponse.statusText,cached:true,id:key});};return _context.abrupt("return",config);case 42:case"end":return _context.stop();}}},_callee,null,[[28,34]]);}));return function(_x){return _ref.apply(this,arguments);};}());_defineProperty(this,"isMethodAllowed",function(method,properties){var requestMethod=method.toLowerCase();var _iterator=_createForOfIteratorHelper(properties.methods||[]),_step;try{for(_iterator.s();!(_step=_iterator.n()).done;){var _method=_step.value;if(_method.toLowerCase()===requestMethod){return true;}}}catch(err){_iterator.e(err);}finally{_iterator.f();}return false;});_defineProperty(this,"setRevalidationHeaders",function(cache,config){config.headers||(config.headers={});var _config$cache=config.cache,etag=_config$cache.etag,modifiedSince=_config$cache.modifiedSince;if(etag){var _cache$data;var etagValue=etag===true?(_cache$data=cache.data)===null||_cache$data===void 0?void 0:_cache$data.headers[_headers.Header.ETag]:etag;if(etagValue){config.headers[_headers.Header.IfNoneMatch]=etagValue;}}if(modifiedSince){config.headers[_headers.Header.IfModifiedSince]=modifiedSince===true?cache.data.headers[_headers.Header.LastModified]||new Date(cache.createdAt).toUTCString():modifiedSince.toUTCString();}});this.axios=axios;};exports.CacheRequestInterceptor=CacheRequestInterceptor;_defineProperty(CacheRequestInterceptor,"createValidateStatus",function(oldValidate){return function(status){return oldValidate?oldValidate(status)||status===304:status>=200&&status<300||status===304;};}); | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.CacheRequestInterceptor=void 0;var _fastDefer=require("fast-defer");var _headers=require("../util/headers");function _createForOfIteratorHelper(o,allowArrayLike){var it=typeof Symbol!=="undefined"&&o[Symbol.iterator]||o["@@iterator"];if(!it){if(Array.isArray(o)||(it=_unsupportedIterableToArray(o))||allowArrayLike&&o&&typeof o.length==="number"){if(it)o=it;var i=0;var F=function F(){};return{s:F,n:function n(){if(i>=o.length)return{done:true};return{done:false,value:o[i++]};},e:function e(_e){throw _e;},f:F};}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 normalCompletion=true,didErr=false,err;return{s:function s(){it=it.call(o);},n:function n(){var step=it.next();normalCompletion=step.done;return step;},e:function e(_e2){didErr=true;err=_e2;},f:function f(){try{if(!normalCompletion&&it.return!=null)it.return();}finally{if(didErr)throw err;}}};}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 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 CacheRequestInterceptor=function CacheRequestInterceptor(axios){var _this=this;_classCallCheck(this,CacheRequestInterceptor);_defineProperty(this,"use",function(){_this.axios.interceptors.request.use(_this.onFulfilled);});_defineProperty(this,"onFulfilled",function(){var _ref=_asyncToGenerator(regeneratorRuntime.mark(function _callee(config){var key,cache,_this$axios$waiting$k,cachedResponse,_deferred;return regeneratorRuntime.wrap(function _callee$(_context){while(1){switch(_context.prev=_context.next){case 0:if(!(config.cache===false)){_context.next=2;break;}return _context.abrupt("return",config);case 2:config.cache=_objectSpread(_objectSpread({},_this.axios.defaults.cache),config.cache);if(CacheRequestInterceptor.isMethodAllowed(config.method,config.cache)){_context.next=5;break;}return _context.abrupt("return",config);case 5:key=_this.axios.generateKey(config);_context.next=8;return _this.axios.storage.get(key);case 8:cache=_context.sent;if(!(cache.state=='empty'||cache.state==='stale')){_context.next=22;break;}if(!_this.axios.waiting[key]){_context.next=15;break;}_context.next=13;return _this.axios.storage.get(key);case 13:cache=_context.sent;return _context.abrupt("break",22);case 15:_this.axios.waiting[key]=(0,_fastDefer.deferred)();(_this$axios$waiting$k=_this.axios.waiting[key])===null||_this$axios$waiting$k===void 0?void 0:_this$axios$waiting$k.catch(function(){return undefined;});_context.next=19;return _this.axios.storage.set(key,{state:'loading',data:cache.data});case 19:if(cache.state==='stale'){CacheRequestInterceptor.setRevalidationHeaders(cache,config);}config.validateStatus=CacheRequestInterceptor.createValidateStatus(config.validateStatus);return _context.abrupt("return",config);case 22:if(!(cache.state==='loading')){_context.next=39;break;}_deferred=_this.axios.waiting[key];if(_deferred){_context.next=28;break;}_context.next=27;return _this.axios.storage.remove(key);case 27:return _context.abrupt("return",config);case 28:_context.prev=28;_context.next=31;return _deferred;case 31:cachedResponse=_context.sent;_context.next=37;break;case 34:_context.prev=34;_context.t0=_context["catch"](28);return _context.abrupt("return",config);case 37:_context.next=40;break;case 39:cachedResponse=cache.data;case 40:config.adapter=function(){return Promise.resolve({config:config,data:cachedResponse.data,headers:cachedResponse.headers,status:cachedResponse.status,statusText:cachedResponse.statusText,cached:true,id:key});};return _context.abrupt("return",config);case 42:case"end":return _context.stop();}}},_callee,null,[[28,34]]);}));return function(_x){return _ref.apply(this,arguments);};}());this.axios=axios;};exports.CacheRequestInterceptor=CacheRequestInterceptor;_defineProperty(CacheRequestInterceptor,"isMethodAllowed",function(method,properties){var requestMethod=method.toLowerCase();var _iterator=_createForOfIteratorHelper(properties.methods||[]),_step;try{for(_iterator.s();!(_step=_iterator.n()).done;){var _method=_step.value;if(_method.toLowerCase()===requestMethod){return true;}}}catch(err){_iterator.e(err);}finally{_iterator.f();}return false;});_defineProperty(CacheRequestInterceptor,"setRevalidationHeaders",function(cache,config){config.headers||(config.headers={});var _config$cache=config.cache,etag=_config$cache.etag,modifiedSince=_config$cache.modifiedSince;if(etag){var _cache$data;var etagValue=etag===true?(_cache$data=cache.data)===null||_cache$data===void 0?void 0:_cache$data.headers[_headers.Header.ETag]:etag;if(etagValue){config.headers[_headers.Header.IfNoneMatch]=etagValue;}}if(modifiedSince){config.headers[_headers.Header.IfModifiedSince]=modifiedSince===true?cache.data.headers[_headers.Header.LastModified]||new Date(cache.createdAt).toUTCString():modifiedSince.toUTCString();}});_defineProperty(CacheRequestInterceptor,"createValidateStatus",function(oldValidate){return function(status){return oldValidate?oldValidate(status)||status===304:status>=200&&status<300||status===304;};}); |
import type { AxiosResponse } from 'axios'; | ||
import type { AxiosCacheInstance, CacheAxiosResponse } from '../cache/axios'; | ||
import type { CacheProperties } from '../cache/cache'; | ||
import type { CachedResponse } from '../storage/types'; | ||
import type { AxiosInterceptor } from './types'; | ||
@@ -7,12 +9,14 @@ export declare class CacheResponseInterceptor<R, D> implements AxiosInterceptor<CacheAxiosResponse<R, D>> { | ||
constructor(axios: AxiosCacheInstance); | ||
use: () => void; | ||
onFulfilled: (axiosResponse: AxiosResponse<R, D>) => Promise<CacheAxiosResponse<R, D>>; | ||
private testCachePredicate; | ||
readonly use: () => void; | ||
readonly onFulfilled: (axiosResponse: AxiosResponse<R, D>) => Promise<CacheAxiosResponse<R, D>>; | ||
/** Rejects cache for this response. Also update the waiting list for this key by rejecting it. */ | ||
readonly rejectResponse: (key: string) => Promise<void>; | ||
readonly cachedResponse: (response: AxiosResponse<R, D>) => CacheAxiosResponse<R, D>; | ||
static readonly testCachePredicate: <R_1>(response: AxiosResponse<R_1, any>, cache: CacheProperties) => boolean; | ||
/** | ||
* Rejects cache for this response. Also update the waiting list for | ||
* this key by rejecting it. | ||
* Creates the new date to the cache by the provided response. Also handles possible 304 | ||
* Not Modified by updating response properties. | ||
*/ | ||
private rejectResponse; | ||
private cachedResponse; | ||
static readonly createCacheData: <R_1, D_1>(response: CacheAxiosResponse<R_1, D_1>, cache?: CachedResponse | undefined) => CachedResponse; | ||
} | ||
//# sourceMappingURL=response.d.ts.map |
@@ -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&&!_this.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=response.status==304&&cache.data?function(){response.cached=true;response.data=cache.data.data;response.status=cache.data.status;response.statusText=cache.data.statusText;response.headers=_objectSpread(_objectSpread({},cache.data.headers),response.headers);return cache.data;}():{data:response.data,status:response.status,statusText:response.statusText,headers:response.headers};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,"testCachePredicate",function(response,cache){var cachePredicate=cache.cachePredicate;return typeof cachePredicate==='function'&&cachePredicate(response)||_typeof(cachePredicate)==='object'&&(0,_cachePredicate.checkPredicateObject)(response,cachePredicate);});_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; | ||
"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};}); |
@@ -5,4 +5,4 @@ export interface AxiosInterceptor<T> { | ||
/** | ||
* Should apply this interceptor to an already provided axios | ||
* instance. Does not call this method explicitly. | ||
* Should apply this interceptor to an already provided axios instance. Does not call | ||
* this method explicitly. | ||
*/ | ||
@@ -9,0 +9,0 @@ use(): void; |
@@ -7,3 +7,3 @@ import type { NotEmptyStorageValue } from '..'; | ||
readonly prefix: string; | ||
static DEFAULT_KEY_PREFIX: string; | ||
static readonly DEFAULT_KEY_PREFIX = "a-c-i"; | ||
/** | ||
@@ -14,6 +14,6 @@ * @param storage Any browser storage, like sessionStorage or localStorage | ||
constructor(storage: Storage, prefix?: string); | ||
find: (key: string) => Promise<StorageValue>; | ||
set: (key: string, value: NotEmptyStorageValue) => Promise<void>; | ||
remove: (key: string) => Promise<void>; | ||
readonly find: (key: string) => Promise<StorageValue>; | ||
readonly set: (key: string, value: NotEmptyStorageValue) => Promise<void>; | ||
readonly remove: (key: string) => Promise<void>; | ||
} | ||
//# sourceMappingURL=browser.d.ts.map |
@@ -6,6 +6,6 @@ import { AxiosStorage } from './storage'; | ||
constructor(storage?: Record<string, StorageValue>); | ||
find: (key: string) => Promise<StorageValue>; | ||
set: (key: string, value: NotEmptyStorageValue) => Promise<void>; | ||
remove: (key: string) => Promise<void>; | ||
readonly find: (key: string) => Promise<StorageValue>; | ||
readonly set: (key: string, value: NotEmptyStorageValue) => Promise<void>; | ||
readonly remove: (key: string) => Promise<void>; | ||
} | ||
//# sourceMappingURL=memory.d.ts.map |
@@ -5,6 +5,6 @@ import type { CachedStorageValue, NotEmptyStorageValue } from '..'; | ||
/** | ||
* Returns the cached value for the given key. The get method is | ||
* what takes care to invalidate the values. | ||
* Returns the cached value for the given key. The get method is what takes care to | ||
* invalidate the values. | ||
*/ | ||
protected abstract find: (key: string) => Promise<StorageValue>; | ||
protected abstract readonly find: (key: string) => Promise<StorageValue>; | ||
/** | ||
@@ -15,13 +15,9 @@ * Sets a new value for the given key | ||
*/ | ||
abstract set: (key: string, value: NotEmptyStorageValue) => Promise<void>; | ||
/** | ||
* Removes the value for the given key | ||
*/ | ||
abstract remove: (key: string) => Promise<void>; | ||
get: (key: string) => Promise<StorageValue>; | ||
/** | ||
* Returns true if a invalid cache should still be kept | ||
*/ | ||
static keepIfStale: ({ data }: CachedStorageValue) => boolean; | ||
abstract readonly set: (key: string, value: NotEmptyStorageValue) => Promise<void>; | ||
/** Removes the value for the given key */ | ||
abstract readonly remove: (key: string) => Promise<void>; | ||
readonly get: (key: string) => Promise<StorageValue>; | ||
/** Returns true if a invalid cache should still be kept */ | ||
static readonly keepIfStale: ({ data }: CachedStorageValue) => boolean; | ||
} | ||
//# sourceMappingURL=storage.d.ts.map |
@@ -7,5 +7,3 @@ export declare type CachedResponse = { | ||
}; | ||
/** | ||
* The value returned for a given key. | ||
*/ | ||
/** The value returned for a given key. */ | ||
export declare type StorageValue = StaleStorageValue | CachedStorageValue | LoadingStorageValue | EmptyStorageValue; | ||
@@ -21,6 +19,3 @@ export declare type NotEmptyStorageValue = Exclude<StorageValue, EmptyStorageValue>; | ||
data: CachedResponse; | ||
/** | ||
* The number in milliseconds to wait after createdAt before the | ||
* value is considered stale. | ||
*/ | ||
/** The number in milliseconds to wait after createdAt before the value is considered stale. */ | ||
ttl: number; | ||
@@ -32,10 +27,8 @@ createdAt: number; | ||
/** | ||
* Only present if the previous state was `stale`. So, in case the | ||
* new response comes without a value, this data is used | ||
* Only present if the previous state was `stale`. So, in case the new response comes | ||
* without a value, this data is used | ||
*/ | ||
data?: CachedResponse; | ||
ttl?: number; | ||
/** | ||
* Defined when the state is cached | ||
*/ | ||
/** Defined when the state is cached */ | ||
createdAt?: undefined; | ||
@@ -47,5 +40,3 @@ state: 'loading'; | ||
ttl?: undefined; | ||
/** | ||
* Defined when the state is cached | ||
*/ | ||
/** Defined when the state is cached */ | ||
createdAt?: undefined; | ||
@@ -52,0 +43,0 @@ state: 'empty'; |
@@ -28,10 +28,8 @@ export declare enum Header { | ||
IfNoneMatch = "if-none-match", | ||
/** | ||
* @link https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control | ||
*/ | ||
/** @link https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control */ | ||
CacheControl = "cache-control", | ||
/** | ||
* ```txt | ||
* ETag: W/"<etag_value>" | ||
* ETag: "<etag_value>" | ||
* ETag: W / '<etag_value>'; | ||
* ETag: '<etag_value>'; | ||
* ``` | ||
@@ -68,6 +66,5 @@ * | ||
/** | ||
* Used internally to mark the cache item as being revalidatable and | ||
* enabling stale cache state Contains a string of ASCII characters | ||
* that can be used as ETag for `If-Match` header Provided by user | ||
* using `cache.etag` value. | ||
* Used internally to mark the cache item as being revalidatable and enabling stale | ||
* cache state Contains a string of ASCII characters that can be used as ETag for | ||
* `If-Match` header Provided by user using `cache.etag` value. | ||
* | ||
@@ -80,8 +77,7 @@ * ```txt | ||
/** | ||
* Used internally to mark the cache item as being revalidatable and | ||
* enabling stale cache state may contain `'use-cache-timestamp'` if | ||
* `cache.modifiedSince` is `true`, otherwise will contain a date | ||
* from `cache.modifiedSince`. If a date is provided, it can be used | ||
* for `If-Modified-Since` header, otherwise the cache timestamp can | ||
* be used for `If-Modified-Since` header. | ||
* Used internally to mark the cache item as being revalidatable and enabling stale | ||
* cache state may contain `'use-cache-timestamp'` if `cache.modifiedSince` is `true`, | ||
* otherwise will contain a date from `cache.modifiedSince`. If a date is provided, it | ||
* can be used for `If-Modified-Since` header, otherwise the cache timestamp can be used | ||
* for `If-Modified-Since` header. | ||
* | ||
@@ -88,0 +84,0 @@ * ```txt |
@@ -6,22 +6,16 @@ import type { AxiosResponse } from 'axios'; | ||
/** | ||
* The status predicate, if a tuple is returned, the first and | ||
* seconds value means the interval (inclusive) accepted. Can also | ||
* be a function. | ||
* The status predicate, if a tuple is returned, the first and seconds value means the | ||
* interval (inclusive) accepted. Can also be a function. | ||
*/ | ||
statusCheck?: [start: number, end: number] | ((status: number) => boolean); | ||
/** | ||
* Matches if the response header container all keys. A tuple also | ||
* checks for values. Can also be a predicate. | ||
* Matches if the response header container all keys. A tuple also checks for values. | ||
* Can also be a predicate. | ||
*/ | ||
containsHeaders?: Record<string, true | string | ((header: string) => boolean)>; | ||
/** | ||
* Check if the desired response matches this predicate. | ||
*/ | ||
/** Check if the desired response matches this predicate. */ | ||
responseMatch?: <T = any>(res: T | undefined) => boolean; | ||
}; | ||
/** | ||
* A simple function that receives a cache request config and should | ||
* return a string id for it. | ||
*/ | ||
/** A simple function that receives a cache request config and should return a string id for it. */ | ||
export declare type KeyGenerator = <R>(options: CacheRequestConfig<R>) => string; | ||
//# sourceMappingURL=types.d.ts.map |
import type { AxiosStorage } from '../storage/storage'; | ||
import type { CachedStorageValue, LoadingStorageValue, StorageValue } from '../storage/types'; | ||
export declare type CacheUpdater = 'delete' | ((cached: Exclude<StorageValue, LoadingStorageValue>, newData: any) => CachedStorageValue | void); | ||
/** | ||
* Function to update all caches, from CacheProperties.update, with | ||
* the new data. | ||
*/ | ||
/** Function to update all caches, from CacheProperties.update, with the new data. */ | ||
export declare function updateCache<T = any>(storage: AxiosStorage, data: T, entries: Record<string, CacheUpdater>): Promise<void>; | ||
//# sourceMappingURL=update-cache.d.ts.map |
{ | ||
"name": "axios-cache-interceptor", | ||
"version": "0.7.1", | ||
"version": "0.7.2", | ||
"description": "Cache interceptor for axios", | ||
@@ -67,9 +67,9 @@ "main": "./dist/index.js", | ||
"eslint-plugin-prettier": "^4.0.0", | ||
"jest": "^27.4.0", | ||
"jest": "^27.4.4", | ||
"prettier": "^2.3.2", | ||
"prettier-plugin-jsdoc": "^0.3.23", | ||
"prettier-plugin-organize-imports": "^2.3.3", | ||
"terser-webpack-plugin": "^5.2.5", | ||
"ts-jest": "^27.1.1", | ||
"typescript": "^4.4.3", | ||
"typescript": "^4.5.3", | ||
"weak-napi": "^2.0.2", | ||
"webpack": "^5.65.0", | ||
@@ -76,0 +76,0 @@ "webpack-cli": "^4.9.1" |
@@ -49,3 +49,3 @@ <br /> | ||
><img | ||
src="https://img.shields.io/bundlephobia/minzip/axios-cache-interceptor?style=flat" | ||
src="https://img.shields.io/bundlephobia/minzip/axios-cache-interceptor/latest?style=flat" | ||
target="_blank" | ||
@@ -52,0 +52,0 @@ alt="Size" /></a |
@@ -17,11 +17,6 @@ import type { | ||
/** | ||
* The id used for this request. if config specified an id, the id | ||
* will be returned | ||
*/ | ||
/** The id used for this request. if config specified an id, the id will be returned */ | ||
id: string; | ||
/** | ||
* A simple boolean to check whether this request was cached or not | ||
*/ | ||
/** A simple boolean to check whether this request was cached or not */ | ||
cached: boolean; | ||
@@ -37,4 +32,4 @@ }; | ||
/** | ||
* An id for this request, if this request is used in cache, only | ||
* the last request made with this id will be returned. | ||
* An id for this request, if this request is used in cache, only the last request made | ||
* with this id will be returned. | ||
* | ||
@@ -54,4 +49,4 @@ * @default undefined | ||
/** | ||
* Same as the AxiosInstance but with CacheRequestConfig as a config | ||
* type and CacheAxiosResponse as response type. | ||
* Same as the AxiosInstance but with CacheRequestConfig as a config type and | ||
* CacheAxiosResponse as response type. | ||
* | ||
@@ -90,5 +85,3 @@ * @see AxiosInstance | ||
/** | ||
* @template D The type that the request body use | ||
*/ | ||
/** @template D The type that the request body use */ | ||
getUri<D>(config?: CacheRequestConfig<D>): string; | ||
@@ -95,0 +88,0 @@ |
@@ -15,4 +15,4 @@ import type { Method } from 'axios'; | ||
* | ||
* When using `interpretHeader: true`, this value will only be used | ||
* if the interpreter can't determine their TTL value to override this | ||
* When using `interpretHeader: true`, this value will only be used if the interpreter | ||
* can't determine their TTL value to override this | ||
* | ||
@@ -26,4 +26,4 @@ * **Note**: a custom storage implementation may not respect this. | ||
/** | ||
* If this interceptor should configure the cache from the request | ||
* cache header When used, the ttl property is ignored | ||
* If this interceptor should configure the cache from the request cache header When | ||
* used, the ttl property is ignored | ||
* | ||
@@ -49,5 +49,4 @@ * @default false | ||
/** | ||
* Once the request is resolved, this specifies what requests should | ||
* we change the cache. Can be used to update the request or delete | ||
* other caches. | ||
* Once the request is resolved, this specifies what requests should we change the | ||
* cache. Can be used to update the request or delete other caches. | ||
* | ||
@@ -58,4 +57,3 @@ * If the function returns nothing, the entry is deleted | ||
* | ||
* The id used is the same as the id on `CacheRequestConfig['id']`, | ||
* auto-generated or not. | ||
* The id used is the same as the id on `CacheRequestConfig['id']`, auto-generated or not. | ||
* | ||
@@ -67,4 +65,4 @@ * @default {{}} | ||
/** | ||
* If the request should handle ETag and If-None-Match support. Use | ||
* a string to force a custom value or true to use the response ETag | ||
* If the request should handle ETag and If-None-Match support. Use a string to force a | ||
* custom value or true to use the response ETag | ||
* | ||
@@ -77,5 +75,4 @@ * @default false | ||
/** | ||
* Use If-Modified-Since header in this request. Use a date to force | ||
* a custom value or true to use the last cached timestamp. If never | ||
* cached before, the header is not set. | ||
* Use If-Modified-Since header in this request. Use a date to force a custom value or | ||
* true to use the last cached timestamp. If never cached before, the header is not set. | ||
* | ||
@@ -97,6 +94,5 @@ * @default false | ||
/** | ||
* The function used to create different keys for each request. | ||
* Defaults to a function that priorizes the id, and if not | ||
* specified, a string is generated using the method, baseUrl, | ||
* params, and url | ||
* The function used to create different keys for each request. Defaults to a function | ||
* that priorizes the id, and if not specified, a string is generated using the method, | ||
* baseUrl, params, and url | ||
*/ | ||
@@ -106,4 +102,3 @@ generateKey: KeyGenerator; | ||
/** | ||
* A simple object that holds all deferred objects until it is | ||
* resolved or rejected. | ||
* A simple object that holds all deferred objects until it is resolved or rejected. | ||
* | ||
@@ -115,16 +110,12 @@ * Can be used to listen when a request is cached or not. | ||
/** | ||
* The function to parse and interpret response headers. Only used | ||
* if cache.interpretHeader is true. | ||
* The function to parse and interpret response headers. Only used if | ||
* cache.interpretHeader is true. | ||
*/ | ||
headerInterpreter: HeadersInterpreter; | ||
/** | ||
* The request interceptor that will be used to handle the cache. | ||
*/ | ||
/** The request interceptor that will be used to handle the cache. */ | ||
requestInterceptor: AxiosInterceptor<CacheRequestConfig<any>>; | ||
/** | ||
* The response interceptor that will be used to handle the cache. | ||
*/ | ||
/** The response interceptor that will be used to handle the cache. */ | ||
responseInterceptor: AxiosInterceptor<CacheAxiosResponse<any, any>>; | ||
} |
@@ -33,3 +33,3 @@ import type { AxiosInstance } from 'axios'; | ||
axiosCache.storage = storage || new MemoryAxiosStorage({}); | ||
axiosCache.storage = storage || new MemoryAxiosStorage(); | ||
axiosCache.generateKey = generateKey || defaultKeyGenerator; | ||
@@ -36,0 +36,0 @@ axiosCache.waiting = waiting || {}; |
@@ -14,5 +14,5 @@ /** | ||
* @param header The header object to interpret. | ||
* @returns `false` if cache should not be used. `undefined` when | ||
* provided headers was not enough to determine a valid value. Or a | ||
* `number` containing the number of **milliseconds** to cache the response. | ||
* @returns `false` if cache should not be used. `undefined` when provided headers was not | ||
* enough to determine a valid value. Or a `number` containing the number of | ||
* **milliseconds** to cache the response. | ||
*/ | ||
@@ -25,5 +25,5 @@ export type HeadersInterpreter = (headers?: Record<string, string>) => MaybeTtl; | ||
* @param header The header string to interpret. | ||
* @returns `false` if cache should not be used. `undefined` when | ||
* provided headers was not enough to determine a valid value. Or a | ||
* `number` containing the number of **milliseconds** to cache the response. | ||
* @returns `false` if cache should not be used. `undefined` when provided headers was not | ||
* enough to determine a valid value. Or a `number` containing the number of | ||
* **milliseconds** to cache the response. | ||
*/ | ||
@@ -30,0 +30,0 @@ export type HeaderInterpreter = ( |
@@ -23,7 +23,7 @@ import type { AxiosRequestConfig, Method } from 'axios'; | ||
public use = (): void => { | ||
readonly use = (): void => { | ||
this.axios.interceptors.request.use(this.onFulfilled); | ||
}; | ||
public onFulfilled = async ( | ||
readonly onFulfilled = async ( | ||
config: CacheRequestConfig<D> | ||
@@ -40,3 +40,3 @@ ): Promise<CacheRequestConfig<D>> => { | ||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion | ||
!this.isMethodAllowed(config.method!, config.cache) | ||
!CacheRequestInterceptor.isMethodAllowed(config.method!, config.cache) | ||
) { | ||
@@ -54,5 +54,5 @@ return config; | ||
/** | ||
* This checks for simultaneous access to a new key. The js | ||
* event loop jumps on the first await statement, so the second | ||
* (asynchronous call) request may have already started executing. | ||
* This checks for simultaneous access to a new key. The js event loop jumps on the | ||
* first await statement, so the second (asynchronous call) request may have already | ||
* started executing. | ||
*/ | ||
@@ -70,4 +70,4 @@ if (this.axios.waiting[key]) { | ||
/** | ||
* Add a default reject handler to catch when the request is | ||
* aborted without others waiting for it. | ||
* Add a default reject handler to catch when the request is aborted without others | ||
* waiting for it. | ||
*/ | ||
@@ -83,3 +83,3 @@ this.axios.waiting[key]?.catch(() => undefined); | ||
//@ts-expect-error type infer couldn't resolve this | ||
this.setRevalidationHeaders(cache, config); | ||
CacheRequestInterceptor.setRevalidationHeaders(cache, config); | ||
} | ||
@@ -118,4 +118,4 @@ | ||
/** | ||
* Even though the response interceptor receives this one from | ||
* here, it has been configured to ignore cached responses: true | ||
* Even though the response interceptor receives this one from here, it has been | ||
* configured to ignore cached responses: true | ||
*/ | ||
@@ -135,3 +135,3 @@ Promise.resolve<CacheAxiosResponse<any, D>>({ | ||
private isMethodAllowed = ( | ||
static readonly isMethodAllowed = ( | ||
method: Method, | ||
@@ -151,3 +151,3 @@ properties: Partial<CacheProperties> | ||
private setRevalidationHeaders = ( | ||
static readonly setRevalidationHeaders = <D>( | ||
cache: StaleStorageValue, | ||
@@ -178,6 +178,8 @@ config: CacheRequestConfig<D> & { cache: Partial<CacheProperties> } | ||
/** | ||
* Creates a new validateStatus function that will use the one | ||
* already used and also accept status code 304. | ||
* Creates a new validateStatus function that will use the one already used and also | ||
* accept status code 304. | ||
*/ | ||
static createValidateStatus = (oldValidate?: AxiosRequestConfig['validateStatus']) => { | ||
static readonly createValidateStatus = ( | ||
oldValidate?: AxiosRequestConfig['validateStatus'] | ||
) => { | ||
return (status: number): boolean => { | ||
@@ -184,0 +186,0 @@ return oldValidate |
import type { AxiosResponse } from 'axios'; | ||
import type { AxiosCacheInstance, CacheAxiosResponse } from '../cache/axios'; | ||
import type { CacheProperties } from '../cache/cache'; | ||
import type { CachedStorageValue } from '../storage/types'; | ||
import type { CachedResponse, CachedStorageValue } from '../storage/types'; | ||
import { checkPredicateObject } from '../util/cache-predicate'; | ||
@@ -15,7 +15,7 @@ import { Header } from '../util/headers'; | ||
public use = (): void => { | ||
readonly use = (): void => { | ||
this.axios.interceptors.response.use(this.onFulfilled); | ||
}; | ||
public onFulfilled = async ( | ||
readonly onFulfilled = async ( | ||
axiosResponse: AxiosResponse<R, D> | ||
@@ -44,3 +44,3 @@ ): Promise<CacheAxiosResponse<R, D>> => { | ||
cache.state === 'empty' || | ||
// Should not hit here because of later response.cached check | ||
// Should not hit here because of previous response.cached check | ||
cache.state === 'cached' | ||
@@ -55,3 +55,3 @@ ) { | ||
!cache.data && | ||
!this.testCachePredicate(response, cacheConfig) | ||
!CacheResponseInterceptor.testCachePredicate(response, cacheConfig) | ||
) { | ||
@@ -91,26 +91,4 @@ await this.rejectResponse(response.id); | ||
const data = | ||
response.status == 304 && cache.data | ||
? (() => { | ||
// Rust syntax <3 | ||
response.cached = true; | ||
response.data = cache.data.data; | ||
response.status = cache.data.status; | ||
response.statusText = cache.data.statusText; | ||
const data = CacheResponseInterceptor.createCacheData(response, cache.data); | ||
// We may have new headers. | ||
response.headers = { | ||
...cache.data.headers, | ||
...response.headers | ||
}; | ||
return cache.data; | ||
})() | ||
: { | ||
data: response.data, | ||
status: response.status, | ||
statusText: response.statusText, | ||
headers: response.headers | ||
}; | ||
const newCache: CachedStorageValue = { | ||
@@ -141,3 +119,22 @@ state: 'cached', | ||
private testCachePredicate = <R>( | ||
/** Rejects cache for this response. Also update the waiting list for this key by rejecting it. */ | ||
readonly rejectResponse = async (key: string) => { | ||
// Update the cache to empty to prevent infinite loading state | ||
await this.axios.storage.remove(key); | ||
// Reject the deferred if present | ||
this.axios.waiting[key]?.reject(null); | ||
delete this.axios.waiting[key]; | ||
}; | ||
readonly cachedResponse = (response: AxiosResponse<R, D>): CacheAxiosResponse<R, D> => { | ||
return { | ||
id: this.axios.generateKey(response.config), | ||
// The request interceptor response.cache will return true or undefined. And true only when the response was cached. | ||
cached: (response as CacheAxiosResponse<R, D>).cached || false, | ||
...response | ||
}; | ||
}; | ||
static readonly testCachePredicate = <R>( | ||
response: AxiosResponse<R>, | ||
@@ -156,24 +153,34 @@ cache: CacheProperties | ||
/** | ||
* Rejects cache for this response. Also update the waiting list for | ||
* this key by rejecting it. | ||
* Creates the new date to the cache by the provided response. Also handles possible 304 | ||
* Not Modified by updating response properties. | ||
*/ | ||
private rejectResponse = async (key: string) => { | ||
// Update the cache to empty to prevent infinite loading state | ||
await this.axios.storage.remove(key); | ||
// Reject the deferred if present | ||
this.axios.waiting[key]?.reject(null); | ||
delete this.axios.waiting[key]; | ||
}; | ||
static readonly createCacheData = <R, D>( | ||
response: CacheAxiosResponse<R, D>, | ||
cache?: CachedResponse | ||
): CachedResponse => { | ||
if (response.status === 304 && cache) { | ||
// Set the cache information into the response object | ||
response.cached = true; | ||
response.data = cache.data; | ||
response.status = cache.status; | ||
response.statusText = cache.statusText; | ||
private cachedResponse = (response: AxiosResponse<R, D>): CacheAxiosResponse<R, D> => { | ||
// Update possible new headers | ||
response.headers = { | ||
...cache.headers, | ||
...response.headers | ||
}; | ||
// return the old cache | ||
return cache; | ||
} | ||
// New Response | ||
return { | ||
id: this.axios.generateKey(response.config), | ||
/** | ||
* The request interceptor response.cache will return true or | ||
* undefined. And true only when the response was cached. | ||
*/ | ||
cached: (response as CacheAxiosResponse<R, D>).cached || false, | ||
...response | ||
data: response.data, | ||
status: response.status, | ||
statusText: response.statusText, | ||
headers: response.headers | ||
}; | ||
}; | ||
} |
@@ -6,6 +6,6 @@ export interface AxiosInterceptor<T> { | ||
/** | ||
* Should apply this interceptor to an already provided axios | ||
* instance. Does not call this method explicitly. | ||
* Should apply this interceptor to an already provided axios instance. Does not call | ||
* this method explicitly. | ||
*/ | ||
use(): void; | ||
} |
@@ -6,3 +6,3 @@ import type { NotEmptyStorageValue } from '..'; | ||
export class BrowserAxiosStorage extends AxiosStorage { | ||
public static DEFAULT_KEY_PREFIX = 'a-c-i'; | ||
public static readonly DEFAULT_KEY_PREFIX = 'a-c-i'; | ||
@@ -20,3 +20,3 @@ /** | ||
public find = async (key: string): Promise<StorageValue> => { | ||
readonly find = async (key: string): Promise<StorageValue> => { | ||
const json = this.storage.getItem(`${this.prefix}:${key}`); | ||
@@ -26,9 +26,9 @@ return json ? JSON.parse(json) : { state: 'empty' }; | ||
public set = async (key: string, value: NotEmptyStorageValue): Promise<void> => { | ||
readonly set = async (key: string, value: NotEmptyStorageValue): Promise<void> => { | ||
return this.storage.setItem(`${this.prefix}:${key}`, JSON.stringify(value)); | ||
}; | ||
public remove = async (key: string): Promise<void> => { | ||
readonly remove = async (key: string): Promise<void> => { | ||
return this.storage.removeItem(`${this.prefix}:${key}`); | ||
}; | ||
} |
@@ -9,13 +9,13 @@ import { AxiosStorage } from './storage'; | ||
public find = async (key: string): Promise<StorageValue> => { | ||
readonly find = async (key: string): Promise<StorageValue> => { | ||
return this.storage[key] || { state: 'empty' }; | ||
}; | ||
public set = async (key: string, value: NotEmptyStorageValue): Promise<void> => { | ||
readonly set = async (key: string, value: NotEmptyStorageValue): Promise<void> => { | ||
this.storage[key] = value; | ||
}; | ||
public remove = async (key: string): Promise<void> => { | ||
readonly remove = async (key: string): Promise<void> => { | ||
delete this.storage[key]; | ||
}; | ||
} |
@@ -7,6 +7,6 @@ import type { CachedStorageValue, NotEmptyStorageValue } from '..'; | ||
/** | ||
* Returns the cached value for the given key. The get method is | ||
* what takes care to invalidate the values. | ||
* Returns the cached value for the given key. The get method is what takes care to | ||
* invalidate the values. | ||
*/ | ||
protected abstract find: (key: string) => Promise<StorageValue>; | ||
protected abstract readonly find: (key: string) => Promise<StorageValue>; | ||
@@ -18,10 +18,8 @@ /** | ||
*/ | ||
public abstract set: (key: string, value: NotEmptyStorageValue) => Promise<void>; | ||
abstract readonly set: (key: string, value: NotEmptyStorageValue) => Promise<void>; | ||
/** | ||
* Removes the value for the given key | ||
*/ | ||
public abstract remove: (key: string) => Promise<void>; | ||
/** Removes the value for the given key */ | ||
abstract readonly remove: (key: string) => Promise<void>; | ||
public get = async (key: string): Promise<StorageValue> => { | ||
readonly get = async (key: string): Promise<StorageValue> => { | ||
const value = await this.find(key); | ||
@@ -52,6 +50,4 @@ | ||
/** | ||
* Returns true if a invalid cache should still be kept | ||
*/ | ||
static keepIfStale = ({ data }: CachedStorageValue): boolean => { | ||
/** Returns true if a invalid cache should still be kept */ | ||
static readonly keepIfStale = ({ data }: CachedStorageValue): boolean => { | ||
if (data?.headers) { | ||
@@ -58,0 +54,0 @@ return ( |
@@ -8,5 +8,3 @@ export type CachedResponse = { | ||
/** | ||
* The value returned for a given key. | ||
*/ | ||
/** The value returned for a given key. */ | ||
export type StorageValue = | ||
@@ -29,6 +27,3 @@ | StaleStorageValue | ||
data: CachedResponse; | ||
/** | ||
* The number in milliseconds to wait after createdAt before the | ||
* value is considered stale. | ||
*/ | ||
/** The number in milliseconds to wait after createdAt before the value is considered stale. */ | ||
ttl: number; | ||
@@ -41,4 +36,4 @@ createdAt: number; | ||
/** | ||
* Only present if the previous state was `stale`. So, in case the | ||
* new response comes without a value, this data is used | ||
* Only present if the previous state was `stale`. So, in case the new response comes | ||
* without a value, this data is used | ||
*/ | ||
@@ -48,5 +43,3 @@ data?: CachedResponse; | ||
/** | ||
* Defined when the state is cached | ||
*/ | ||
/** Defined when the state is cached */ | ||
createdAt?: undefined; | ||
@@ -60,7 +53,5 @@ state: 'loading'; | ||
/** | ||
* Defined when the state is cached | ||
*/ | ||
/** Defined when the state is cached */ | ||
createdAt?: undefined; | ||
state: 'empty'; | ||
}; |
@@ -31,5 +31,3 @@ export enum Header { | ||
/** | ||
* @link https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control | ||
*/ | ||
/** @link https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control */ | ||
CacheControl = 'cache-control', | ||
@@ -39,4 +37,4 @@ | ||
* ```txt | ||
* ETag: W/"<etag_value>" | ||
* ETag: "<etag_value>" | ||
* ETag: W / '<etag_value>'; | ||
* ETag: '<etag_value>'; | ||
* ``` | ||
@@ -77,6 +75,5 @@ * | ||
/** | ||
* Used internally to mark the cache item as being revalidatable and | ||
* enabling stale cache state Contains a string of ASCII characters | ||
* that can be used as ETag for `If-Match` header Provided by user | ||
* using `cache.etag` value. | ||
* Used internally to mark the cache item as being revalidatable and enabling stale | ||
* cache state Contains a string of ASCII characters that can be used as ETag for | ||
* `If-Match` header Provided by user using `cache.etag` value. | ||
* | ||
@@ -90,8 +87,7 @@ * ```txt | ||
/** | ||
* Used internally to mark the cache item as being revalidatable and | ||
* enabling stale cache state may contain `'use-cache-timestamp'` if | ||
* `cache.modifiedSince` is `true`, otherwise will contain a date | ||
* from `cache.modifiedSince`. If a date is provided, it can be used | ||
* for `If-Modified-Since` header, otherwise the cache timestamp can | ||
* be used for `If-Modified-Since` header. | ||
* Used internally to mark the cache item as being revalidatable and enabling stale | ||
* cache state may contain `'use-cache-timestamp'` if `cache.modifiedSince` is `true`, | ||
* otherwise will contain a date from `cache.modifiedSince`. If a date is provided, it | ||
* can be used for `If-Modified-Since` header, otherwise the cache timestamp can be used | ||
* for `If-Modified-Since` header. | ||
* | ||
@@ -98,0 +94,0 @@ * ```txt |
@@ -10,5 +10,4 @@ import type { AxiosResponse } from 'axios'; | ||
/** | ||
* The status predicate, if a tuple is returned, the first and | ||
* seconds value means the interval (inclusive) accepted. Can also | ||
* be a function. | ||
* The status predicate, if a tuple is returned, the first and seconds value means the | ||
* interval (inclusive) accepted. Can also be a function. | ||
*/ | ||
@@ -18,17 +17,12 @@ statusCheck?: [start: number, end: number] | ((status: number) => boolean); | ||
/** | ||
* Matches if the response header container all keys. A tuple also | ||
* checks for values. Can also be a predicate. | ||
* Matches if the response header container all keys. A tuple also checks for values. | ||
* Can also be a predicate. | ||
*/ | ||
containsHeaders?: Record<string, true | string | ((header: string) => boolean)>; | ||
/** | ||
* Check if the desired response matches this predicate. | ||
*/ | ||
/** Check if the desired response matches this predicate. */ | ||
responseMatch?: <T = any>(res: T | undefined) => boolean; | ||
}; | ||
/** | ||
* A simple function that receives a cache request config and should | ||
* return a string id for it. | ||
*/ | ||
/** A simple function that receives a cache request config and should return a string id for it. */ | ||
export type KeyGenerator = <R>(options: CacheRequestConfig<R>) => string; |
@@ -15,6 +15,3 @@ import type { AxiosStorage } from '../storage/storage'; | ||
/** | ||
* Function to update all caches, from CacheProperties.update, with | ||
* the new data. | ||
*/ | ||
/** Function to update all caches, from CacheProperties.update, with the new data. */ | ||
export async function updateCache<T = any>( | ||
@@ -21,0 +18,0 @@ storage: AxiosStorage, |
@@ -52,3 +52,3 @@ { | ||
// "removeComments": true, /* Disable emitting comments. */ | ||
// "noEmit": true, /* Disable emitting files from a compilation. */ | ||
"noEmit": true, /* Disable emitting files from a compilation. */ | ||
// "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */ | ||
@@ -55,0 +55,0 @@ "importsNotUsedAsValues": "error" /* Specify emit/checking behavior for imports that are only used for types */, |
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
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
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
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
238464
1763