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

@bemoje/api-util

Package Overview
Dependencies
Maintainers
1
Versions
47
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bemoje/api-util - npm Package Compare versions

Comparing version 0.0.8 to 0.0.9

project.json

4

dist/index.cjs.js
/*!
* @bemoje/api-util v0.0.7
* @bemoje/api-util v0.0.8
* (c) Benjamin Møller Jensen
* Released under the MIT License.
*/"use strict";var nodeUtil=require("@bemoje/node-util"),asyncRetry=require("async-retry"),EventEmitter=require("events"),lodash=require("lodash"),getAppDataPath=require("appdata-path"),level=require("level"),mkdirp=require("mkdirp"),hash=require("object-hash"),path=require("path");function __awaiter(thisArg,_arguments,P,generator){function adopt(value){return value instanceof P?value:new P(function(resolve){resolve(value)})}return new(P||(P=Promise))(function(resolve,reject){function fulfilled(value){try{step(generator.next(value))}catch(e){reject(e)}}function rejected(value){try{step(generator["throw"](value))}catch(e){reject(e)}}function step(result){result.done?resolve(result.value):adopt(result.value).then(fulfilled,rejected)}step((generator=generator.apply(thisArg,_arguments||[])).next())})}function __values(o){var s="function"==typeof Symbol&&Symbol.iterator,m=s&&o[s],i=0;if(m)return m.call(o);if(o&&"number"==typeof o.length)return{next:function(){return o&&i>=o.length&&(o=void 0),{value:o&&o[i++],done:!o}}};throw new TypeError(s?"Object is not iterable.":"Symbol.iterator is not defined.")}function __await(v){return this instanceof __await?(this.v=v,this):new __await(v)}function __asyncGenerator(thisArg,_arguments,generator){function verb(n){g[n]&&(i[n]=function(v){return new Promise(function(a,b){1<q.push([n,v,a,b])||resume(n,v)})})}function resume(n,v){try{step(g[n](v))}catch(e){settle(q[0][3],e)}}function step(r){r.value instanceof __await?Promise.resolve(r.value.v).then(fulfill,reject):settle(q[0][2],r)}function fulfill(value){resume("next",value)}function reject(value){resume("throw",value)}function settle(f,v){(f(v),q.shift(),q.length)&&resume(q[0][0],q[0][1])}if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i,g=generator.apply(thisArg,_arguments||[]),q=[];return i={},verb("next"),verb("throw"),verb("return"),i[Symbol.asyncIterator]=function(){return this},i}function __asyncValues(o){function verb(n){i[n]=o[n]&&function(v){return new Promise(function(resolve,reject){v=o[n](v),settle(resolve,reject,v.done,v.value)})}}function settle(resolve,reject,d,v){Promise.resolve(v).then(function(v){resolve({value:v,done:d})},reject)}if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i,m=o[Symbol.asyncIterator];return m?m.call(o):(o="function"==typeof __values?__values(o):o[Symbol.iterator](),i={},verb("next"),verb("throw"),verb("return"),i[Symbol.asyncIterator]=function(){return this},i)}"function"==typeof SuppressedError?SuppressedError:function(error,suppressed,message){var e=new Error(message);return e.name="SuppressedError",e.error=error,e.suppressed=suppressed,e};class ApiReponseCache{get eventNames(){return["options","hit","miss","get","put","delete","error","expired"]}constructor(options){this.events=new EventEmitter;const _options=Object.assign({},ApiReponseCache.optionsDefaults,options),{name,dirpath,maxAgeMs}=_options;this.emit("options",_options),this.maxAgeMs=maxAgeMs;const dbpath=path.join(dirpath,name);mkdirp.mkdirpSync(dbpath),this.db=new level.Level(dbpath),Object.defineProperty(this,"db",{enumerable:!1})}hashKey(key){return hash(key===void 0?"undefined":key,{algorithm:"sha1",encoding:"base64"})}getOrElse(hash,apiRequest){return __awaiter(this,void 0,void 0,function*(){try{const value=yield this.get(hash);return this.emit("hit",hash),value}catch(e){this.emit("miss",hash);const value=yield apiRequest();return yield this.put(hash,value)}})}get(hash){return __awaiter(this,void 0,void 0,function*(){return yield this.orThrow(()=>__awaiter(this,void 0,void 0,function*(){const serialized=yield this.db.get(hash);return yield this.ensureNotExpired(hash,serialized),this.emit("get",hash),this.parseSerializedValue(serialized)}))})}getSafe(hash){return __awaiter(this,void 0,void 0,function*(){try{const serialized=yield this.db.get(hash);return yield this.ensureNotExpired(hash,serialized),this.emit("get",hash),this.parseSerializedValue(serialized)}catch(error){return}})}has(hash){return __awaiter(this,void 0,void 0,function*(){try{return yield this.db.get(hash),!0}catch(e){return!1}})}put(hash,value){return __awaiter(this,void 0,void 0,function*(){return yield this.orThrow(()=>__awaiter(this,void 0,void 0,function*(){const serialized=this.serializeValue(value);return yield this.db.put(hash,serialized),this.emit("put",hash),value}))})}delete(hash){return __awaiter(this,void 0,void 0,function*(){return yield this.orThrow(()=>__awaiter(this,void 0,void 0,function*(){yield this.db.del(hash),this.emit("delete",hash)}))})}deleteExpired(){var _a,e_1,_b,_c;return __awaiter(this,void 0,void 0,function*(){try{for(var _f,_d=!0,_e=__asyncValues(this.entries());_f=yield _e.next(),_a=_f.done,!_a;_d=!0){_c=_f.value,_d=!1;const _=_c}}catch(e_1_1){e_1={error:e_1_1}}finally{try{_d||_a||!(_b=_e.return)||(yield _b.call(_e))}finally{if(e_1)throw e_1.error}}return this})}deleteEverything(){return __awaiter(this,void 0,void 0,function*(){return yield this.orThrow(()=>__awaiter(this,void 0,void 0,function*(){yield this.db.clear(),this.emit("delete","All cache data was deleted.")}))})}entries(){return __asyncGenerator(this,arguments,function*entries_1(){var _a,e_2,_b,_c;try{try{for(var _f,_d=!0,_e=__asyncValues(this.db.iterator());_f=yield __await(_e.next()),_a=_f.done,!_a;_d=!0){_c=_f.value,_d=!1;const[hash,serialized]=_c;this.isExpired(serialized)&&this.db.del(hash).then(()=>this.emit("expired",hash)),yield yield __await([hash,this.parseSerializedValue(serialized)])}}catch(e_2_1){e_2={error:e_2_1}}finally{try{_d||_a||!(_b=_e.return)||(yield __await(_b.call(_e)))}finally{if(e_2)throw e_2.error}}}catch(error){throw this.emit("error",error)}})}keys(){return __asyncGenerator(this,arguments,function*keys_1(){var _a,e_3,_b,_c;try{try{for(var _f,_d=!0,_e=__asyncValues(this.entries());_f=yield __await(_e.next()),_a=_f.done,!_a;_d=!0){_c=_f.value,_d=!1;const[hash]=_c;yield yield __await(hash)}}catch(e_3_1){e_3={error:e_3_1}}finally{try{_d||_a||!(_b=_e.return)||(yield __await(_b.call(_e)))}finally{if(e_3)throw e_3.error}}}catch(error){throw this.emit("error",error)}})}values(){return __asyncGenerator(this,arguments,function*values_1(){var _a,e_4,_b,_c;try{try{for(var _f,_d=!0,_e=__asyncValues(this.entries());_f=yield __await(_e.next()),_a=_f.done,!_a;_d=!0){_c=_f.value,_d=!1;const[_,value]=_c;yield yield __await(value)}}catch(e_4_1){e_4={error:e_4_1}}finally{try{_d||_a||!(_b=_e.return)||(yield __await(_b.call(_e)))}finally{if(e_4)throw e_4.error}}}catch(error){throw this.emit("error",error)}})}size(){var _a,e_5,_b,_c;return __awaiter(this,void 0,void 0,function*(){let size=0;try{for(var _f,_d=!0,_e=__asyncValues(this.entries());_f=yield _e.next(),_a=_f.done,!_a;_d=!0){_c=_f.value,_d=!1;const _=_c;size++}}catch(e_5_1){e_5={error:e_5_1}}finally{try{_d||_a||!(_b=_e.return)||(yield _b.call(_e))}finally{if(e_5)throw e_5.error}}return size})}ensureNotExpired(hash,serialized){return __awaiter(this,void 0,void 0,function*(){if(this.isExpired(serialized))throw yield this.db.del(hash),this.emit("expired",hash),new Error("Expired")})}isExpired(serialized){return!!this.maxAgeMs&&Date.now()-this.parseSerializedTimestamp(serialized)>this.maxAgeMs}serializeValue(value){return Date.now()+JSON.stringify(value)}parseSerializedTimestamp(serialized){return parseInt(serialized.substring(0,13))}parseSerializedValue(serialized){return JSON.parse(serialized.substring(13))}orThrow(fn){try{return fn()}catch(error){throw this.emit("error",error)}}emit(eventName,arg){return this.events.emit(eventName,arg,this),arg}}ApiReponseCache.optionsDefaults={name:"default",dirpath:getAppDataPath("ApiReponseCache"),maxAgeMs:0};class AbstractApiClient{get eventNames(){return["retry","error","response","ready","options"]}constructor(options={}){var _a;this.events=new EventEmitter,this.retryDefaults={minTimeout:1e3,retries:5,factor:2.5,randomize:!0},this.cacheDefaults={overwrite:!1},options=this.handleOptions(options),(null===(_a=null===options||void 0===options?void 0:options.cache)||void 0===_a?void 0:_a.enable)&&(this.cache=new ApiReponseCache(options.cache));const _sendRequest=options=>__awaiter(this,void 0,void 0,function*(){const{apiRequest,args,retry,cache}=options,_retry=this.handleRetryOptions(retry),_cache=this.handleCacheOptions(cache),getFromCacheOrApi=(bail,attempt)=>__awaiter(this,void 0,void 0,function*(){try{if(!this.cache)return yield apiRequest();const hash=this.cache.hashKey({args,task:apiRequest.toString()});return(null===_cache||void 0===_cache?void 0:_cache.overwrite)&&(yield this.cache.delete(hash)),yield this.cache.getOrElse(hash,apiRequest)}catch(error){const data={attempt,error,args};1<attempt?this.emit("retry",data):this.emit("error",data)}}),response=yield asyncRetry(getFromCacheOrApi,_retry);return this.emit("response",{response,args}),response}),[queue,sendRequest]=nodeUtil.funAsyncRateLimit(_sendRequest.bind(this),options.concurrency);this.queue=queue,this.sendRequest=sendRequest,this.emit("ready","ready")}handleOptions(options){options=lodash.cloneDeep(options);const Constructor=Object.getPrototypeOf(this).constructor;return options.cache||(options.cache={}),options.cache.name||(options.cache.name=Constructor.name),options.concurrency=Object.assign({},Constructor.concurrencyDefaults,options.concurrency),Object.assign(this.retryDefaults,options.retryDefaults),Object.assign(this.cacheDefaults,options.cacheDefaults),this.emit("options",options),options}handleRetryOptions(retryOptions){return retryOptions?Object.assign({},this.retryDefaults,retryOptions):this.retryDefaults}handleCacheOptions(cacheOptions){return cacheOptions?Object.assign({},this.cacheDefaults,cacheOptions):this.cacheDefaults}emit(event,arg){return this.events.emit(event,arg,this),arg}}AbstractApiClient.concurrencyDefaults={concurrency:100,autoStart:!0},exports.AbstractApiClient=AbstractApiClient,exports.ApiReponseCache=ApiReponseCache;
*/"use strict";var _function=require("@bemoje/function"),asyncRetry=require("async-retry"),EventEmitter=require("events"),lodash=require("lodash"),getAppDataPath=require("appdata-path"),level=require("level"),mkdirp=require("mkdirp"),hash=require("object-hash"),path=require("path");function __awaiter(thisArg,_arguments,P,generator){function adopt(value){return value instanceof P?value:new P(function(resolve){resolve(value)})}return new(P||(P=Promise))(function(resolve,reject){function fulfilled(value){try{step(generator.next(value))}catch(e){reject(e)}}function rejected(value){try{step(generator["throw"](value))}catch(e){reject(e)}}function step(result){result.done?resolve(result.value):adopt(result.value).then(fulfilled,rejected)}step((generator=generator.apply(thisArg,_arguments||[])).next())})}function __values(o){var s="function"==typeof Symbol&&Symbol.iterator,m=s&&o[s],i=0;if(m)return m.call(o);if(o&&"number"==typeof o.length)return{next:function(){return o&&i>=o.length&&(o=void 0),{value:o&&o[i++],done:!o}}};throw new TypeError(s?"Object is not iterable.":"Symbol.iterator is not defined.")}function __await(v){return this instanceof __await?(this.v=v,this):new __await(v)}function __asyncGenerator(thisArg,_arguments,generator){function verb(n){g[n]&&(i[n]=function(v){return new Promise(function(a,b){1<q.push([n,v,a,b])||resume(n,v)})})}function resume(n,v){try{step(g[n](v))}catch(e){settle(q[0][3],e)}}function step(r){r.value instanceof __await?Promise.resolve(r.value.v).then(fulfill,reject):settle(q[0][2],r)}function fulfill(value){resume("next",value)}function reject(value){resume("throw",value)}function settle(f,v){(f(v),q.shift(),q.length)&&resume(q[0][0],q[0][1])}if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i,g=generator.apply(thisArg,_arguments||[]),q=[];return i={},verb("next"),verb("throw"),verb("return"),i[Symbol.asyncIterator]=function(){return this},i}function __asyncValues(o){function verb(n){i[n]=o[n]&&function(v){return new Promise(function(resolve,reject){v=o[n](v),settle(resolve,reject,v.done,v.value)})}}function settle(resolve,reject,d,v){Promise.resolve(v).then(function(v){resolve({value:v,done:d})},reject)}if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i,m=o[Symbol.asyncIterator];return m?m.call(o):(o="function"==typeof __values?__values(o):o[Symbol.iterator](),i={},verb("next"),verb("throw"),verb("return"),i[Symbol.asyncIterator]=function(){return this},i)}"function"==typeof SuppressedError?SuppressedError:function(error,suppressed,message){var e=new Error(message);return e.name="SuppressedError",e.error=error,e.suppressed=suppressed,e};class ApiReponseCache{get eventNames(){return["options","hit","miss","get","put","delete","error","expired"]}constructor(options){this.events=new EventEmitter;const _options=Object.assign({},ApiReponseCache.optionsDefaults,options),{name,dirpath,maxAgeMs}=_options;this.emit("options",_options),this.maxAgeMs=maxAgeMs;const dbpath=path.join(dirpath,name);mkdirp.mkdirpSync(dbpath),this.db=new level.Level(dbpath),Object.defineProperty(this,"db",{enumerable:!1})}hashKey(key){return hash(key===void 0?"undefined":key,{algorithm:"sha1",encoding:"base64"})}getOrElse(hash,apiRequest){return __awaiter(this,void 0,void 0,function*(){try{const value=yield this.get(hash);return this.emit("hit",hash),value}catch(e){this.emit("miss",hash);const value=yield apiRequest();return yield this.put(hash,value)}})}get(hash){return __awaiter(this,void 0,void 0,function*(){return yield this.orThrow(()=>__awaiter(this,void 0,void 0,function*(){const serialized=yield this.db.get(hash);return yield this.ensureNotExpired(hash,serialized),this.emit("get",hash),this.parseSerializedValue(serialized)}))})}getSafe(hash){return __awaiter(this,void 0,void 0,function*(){try{const serialized=yield this.db.get(hash);return yield this.ensureNotExpired(hash,serialized),this.emit("get",hash),this.parseSerializedValue(serialized)}catch(error){return}})}has(hash){return __awaiter(this,void 0,void 0,function*(){try{return yield this.db.get(hash),!0}catch(e){return!1}})}put(hash,value){return __awaiter(this,void 0,void 0,function*(){return yield this.orThrow(()=>__awaiter(this,void 0,void 0,function*(){const serialized=this.serializeValue(value);return yield this.db.put(hash,serialized),this.emit("put",hash),value}))})}delete(hash){return __awaiter(this,void 0,void 0,function*(){return yield this.orThrow(()=>__awaiter(this,void 0,void 0,function*(){yield this.db.del(hash),this.emit("delete",hash)}))})}deleteExpired(){var _a,e_1,_b,_c;return __awaiter(this,void 0,void 0,function*(){try{for(var _f,_d=!0,_e=__asyncValues(this.entries());_f=yield _e.next(),_a=_f.done,!_a;_d=!0){_c=_f.value,_d=!1;const _=_c}}catch(e_1_1){e_1={error:e_1_1}}finally{try{_d||_a||!(_b=_e.return)||(yield _b.call(_e))}finally{if(e_1)throw e_1.error}}return this})}deleteEverything(){return __awaiter(this,void 0,void 0,function*(){return yield this.orThrow(()=>__awaiter(this,void 0,void 0,function*(){yield this.db.clear(),this.emit("delete","All cache data was deleted.")}))})}entries(){return __asyncGenerator(this,arguments,function*entries_1(){var _a,e_2,_b,_c;try{try{for(var _f,_d=!0,_e=__asyncValues(this.db.iterator());_f=yield __await(_e.next()),_a=_f.done,!_a;_d=!0){_c=_f.value,_d=!1;const[hash,serialized]=_c;this.isExpired(serialized)&&this.db.del(hash).then(()=>this.emit("expired",hash)),yield yield __await([hash,this.parseSerializedValue(serialized)])}}catch(e_2_1){e_2={error:e_2_1}}finally{try{_d||_a||!(_b=_e.return)||(yield __await(_b.call(_e)))}finally{if(e_2)throw e_2.error}}}catch(error){throw this.emit("error",error)}})}keys(){return __asyncGenerator(this,arguments,function*keys_1(){var _a,e_3,_b,_c;try{try{for(var _f,_d=!0,_e=__asyncValues(this.entries());_f=yield __await(_e.next()),_a=_f.done,!_a;_d=!0){_c=_f.value,_d=!1;const[hash]=_c;yield yield __await(hash)}}catch(e_3_1){e_3={error:e_3_1}}finally{try{_d||_a||!(_b=_e.return)||(yield __await(_b.call(_e)))}finally{if(e_3)throw e_3.error}}}catch(error){throw this.emit("error",error)}})}values(){return __asyncGenerator(this,arguments,function*values_1(){var _a,e_4,_b,_c;try{try{for(var _f,_d=!0,_e=__asyncValues(this.entries());_f=yield __await(_e.next()),_a=_f.done,!_a;_d=!0){_c=_f.value,_d=!1;const[_,value]=_c;yield yield __await(value)}}catch(e_4_1){e_4={error:e_4_1}}finally{try{_d||_a||!(_b=_e.return)||(yield __await(_b.call(_e)))}finally{if(e_4)throw e_4.error}}}catch(error){throw this.emit("error",error)}})}size(){var _a,e_5,_b,_c;return __awaiter(this,void 0,void 0,function*(){let size=0;try{for(var _f,_d=!0,_e=__asyncValues(this.entries());_f=yield _e.next(),_a=_f.done,!_a;_d=!0){_c=_f.value,_d=!1;const _=_c;size++}}catch(e_5_1){e_5={error:e_5_1}}finally{try{_d||_a||!(_b=_e.return)||(yield _b.call(_e))}finally{if(e_5)throw e_5.error}}return size})}ensureNotExpired(hash,serialized){return __awaiter(this,void 0,void 0,function*(){if(this.isExpired(serialized))throw yield this.db.del(hash),this.emit("expired",hash),new Error("Expired")})}isExpired(serialized){return!!this.maxAgeMs&&Date.now()-this.parseSerializedTimestamp(serialized)>this.maxAgeMs}serializeValue(value){return Date.now()+JSON.stringify(value)}parseSerializedTimestamp(serialized){return parseInt(serialized.substring(0,13))}parseSerializedValue(serialized){return JSON.parse(serialized.substring(13))}orThrow(fn){try{return fn()}catch(error){throw this.emit("error",error)}}emit(eventName,arg){return this.events.emit(eventName,arg,this),arg}}ApiReponseCache.optionsDefaults={name:"default",dirpath:getAppDataPath("ApiReponseCache"),maxAgeMs:0};class AbstractApiClient{get eventNames(){return["retry","error","response","ready","options"]}constructor(options={}){var _a;this.events=new EventEmitter,this.retryDefaults={minTimeout:1e3,retries:5,factor:2.5,randomize:!0},this.cacheDefaults={overwrite:!1},options=this.handleOptions(options),(null===(_a=null===options||void 0===options?void 0:options.cache)||void 0===_a?void 0:_a.enable)&&(this.cache=new ApiReponseCache(options.cache));const _sendRequest=options=>__awaiter(this,void 0,void 0,function*(){const{apiRequest,args,retry,cache}=options,_retry=this.handleRetryOptions(retry),_cache=this.handleCacheOptions(cache),getFromCacheOrApi=(bail,attempt)=>__awaiter(this,void 0,void 0,function*(){try{if(!this.cache)return yield apiRequest();const hash=this.cache.hashKey({args,task:apiRequest.toString()});return(null===_cache||void 0===_cache?void 0:_cache.overwrite)&&(yield this.cache.delete(hash)),yield this.cache.getOrElse(hash,apiRequest)}catch(error){const data={attempt,error,args};1<attempt?this.emit("retry",data):this.emit("error",data)}}),response=yield asyncRetry(getFromCacheOrApi,_retry);return this.emit("response",{response,args}),response}),[queue,sendRequest]=_function.funAsyncRateLimit(_sendRequest.bind(this),options.concurrency);this.queue=queue,this.sendRequest=sendRequest,this.emit("ready","ready")}handleOptions(options){options=lodash.cloneDeep(options);const Constructor=Object.getPrototypeOf(this).constructor;return options.cache||(options.cache={}),options.cache.name||(options.cache.name=Constructor.name),options.concurrency=Object.assign({},Constructor.concurrencyDefaults,options.concurrency),Object.assign(this.retryDefaults,options.retryDefaults),Object.assign(this.cacheDefaults,options.cacheDefaults),this.emit("options",options),options}handleRetryOptions(retryOptions){return retryOptions?Object.assign({},this.retryDefaults,retryOptions):this.retryDefaults}handleCacheOptions(cacheOptions){return cacheOptions?Object.assign({},this.cacheDefaults,cacheOptions):this.cacheDefaults}emit(event,arg){return this.events.emit(event,arg,this),arg}}AbstractApiClient.concurrencyDefaults={concurrency:100,autoStart:!0},exports.AbstractApiClient=AbstractApiClient,exports.ApiReponseCache=ApiReponseCache;
//# sourceMappingURL=index.cjs.js.map
/*!
* @bemoje/api-util v0.0.7
* @bemoje/api-util v0.0.8
* (c) Benjamin Møller Jensen
* Released under the MIT License.
*/import{funAsyncRateLimit}from"@bemoje/node-util";import asyncRetry from"async-retry";import EventEmitter from"events";import{cloneDeep}from"lodash";import getAppDataPath from"appdata-path";import{Level}from"level";import{mkdirpSync}from"mkdirp";import hash from"object-hash";import path from"path";function __awaiter(thisArg,_arguments,P,generator){function adopt(value){return value instanceof P?value:new P(function(resolve){resolve(value)})}return new(P||(P=Promise))(function(resolve,reject){function fulfilled(value){try{step(generator.next(value))}catch(e){reject(e)}}function rejected(value){try{step(generator["throw"](value))}catch(e){reject(e)}}function step(result){result.done?resolve(result.value):adopt(result.value).then(fulfilled,rejected)}step((generator=generator.apply(thisArg,_arguments||[])).next())})}function __values(o){var s="function"==typeof Symbol&&Symbol.iterator,m=s&&o[s],i=0;if(m)return m.call(o);if(o&&"number"==typeof o.length)return{next:function(){return o&&i>=o.length&&(o=void 0),{value:o&&o[i++],done:!o}}};throw new TypeError(s?"Object is not iterable.":"Symbol.iterator is not defined.")}function __await(v){return this instanceof __await?(this.v=v,this):new __await(v)}function __asyncGenerator(thisArg,_arguments,generator){function verb(n){g[n]&&(i[n]=function(v){return new Promise(function(a,b){1<q.push([n,v,a,b])||resume(n,v)})})}function resume(n,v){try{step(g[n](v))}catch(e){settle(q[0][3],e)}}function step(r){r.value instanceof __await?Promise.resolve(r.value.v).then(fulfill,reject):settle(q[0][2],r)}function fulfill(value){resume("next",value)}function reject(value){resume("throw",value)}function settle(f,v){(f(v),q.shift(),q.length)&&resume(q[0][0],q[0][1])}if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i,g=generator.apply(thisArg,_arguments||[]),q=[];return i={},verb("next"),verb("throw"),verb("return"),i[Symbol.asyncIterator]=function(){return this},i}function __asyncValues(o){function verb(n){i[n]=o[n]&&function(v){return new Promise(function(resolve,reject){v=o[n](v),settle(resolve,reject,v.done,v.value)})}}function settle(resolve,reject,d,v){Promise.resolve(v).then(function(v){resolve({value:v,done:d})},reject)}if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i,m=o[Symbol.asyncIterator];return m?m.call(o):(o="function"==typeof __values?__values(o):o[Symbol.iterator](),i={},verb("next"),verb("throw"),verb("return"),i[Symbol.asyncIterator]=function(){return this},i)}"function"==typeof SuppressedError?SuppressedError:function(error,suppressed,message){var e=new Error(message);return e.name="SuppressedError",e.error=error,e.suppressed=suppressed,e};class ApiReponseCache{get eventNames(){return["options","hit","miss","get","put","delete","error","expired"]}constructor(options){this.events=new EventEmitter;const _options=Object.assign({},ApiReponseCache.optionsDefaults,options),{name,dirpath,maxAgeMs}=_options;this.emit("options",_options),this.maxAgeMs=maxAgeMs;const dbpath=path.join(dirpath,name);mkdirpSync(dbpath),this.db=new Level(dbpath),Object.defineProperty(this,"db",{enumerable:!1})}hashKey(key){return hash(key===void 0?"undefined":key,{algorithm:"sha1",encoding:"base64"})}getOrElse(hash,apiRequest){return __awaiter(this,void 0,void 0,function*(){try{const value=yield this.get(hash);return this.emit("hit",hash),value}catch(e){this.emit("miss",hash);const value=yield apiRequest();return yield this.put(hash,value)}})}get(hash){return __awaiter(this,void 0,void 0,function*(){return yield this.orThrow(()=>__awaiter(this,void 0,void 0,function*(){const serialized=yield this.db.get(hash);return yield this.ensureNotExpired(hash,serialized),this.emit("get",hash),this.parseSerializedValue(serialized)}))})}getSafe(hash){return __awaiter(this,void 0,void 0,function*(){try{const serialized=yield this.db.get(hash);return yield this.ensureNotExpired(hash,serialized),this.emit("get",hash),this.parseSerializedValue(serialized)}catch(error){return}})}has(hash){return __awaiter(this,void 0,void 0,function*(){try{return yield this.db.get(hash),!0}catch(e){return!1}})}put(hash,value){return __awaiter(this,void 0,void 0,function*(){return yield this.orThrow(()=>__awaiter(this,void 0,void 0,function*(){const serialized=this.serializeValue(value);return yield this.db.put(hash,serialized),this.emit("put",hash),value}))})}delete(hash){return __awaiter(this,void 0,void 0,function*(){return yield this.orThrow(()=>__awaiter(this,void 0,void 0,function*(){yield this.db.del(hash),this.emit("delete",hash)}))})}deleteExpired(){var _a,e_1,_b,_c;return __awaiter(this,void 0,void 0,function*(){try{for(var _f,_d=!0,_e=__asyncValues(this.entries());_f=yield _e.next(),_a=_f.done,!_a;_d=!0){_c=_f.value,_d=!1;const _=_c}}catch(e_1_1){e_1={error:e_1_1}}finally{try{_d||_a||!(_b=_e.return)||(yield _b.call(_e))}finally{if(e_1)throw e_1.error}}return this})}deleteEverything(){return __awaiter(this,void 0,void 0,function*(){return yield this.orThrow(()=>__awaiter(this,void 0,void 0,function*(){yield this.db.clear(),this.emit("delete","All cache data was deleted.")}))})}entries(){return __asyncGenerator(this,arguments,function*entries_1(){var _a,e_2,_b,_c;try{try{for(var _f,_d=!0,_e=__asyncValues(this.db.iterator());_f=yield __await(_e.next()),_a=_f.done,!_a;_d=!0){_c=_f.value,_d=!1;const[hash,serialized]=_c;this.isExpired(serialized)&&this.db.del(hash).then(()=>this.emit("expired",hash)),yield yield __await([hash,this.parseSerializedValue(serialized)])}}catch(e_2_1){e_2={error:e_2_1}}finally{try{_d||_a||!(_b=_e.return)||(yield __await(_b.call(_e)))}finally{if(e_2)throw e_2.error}}}catch(error){throw this.emit("error",error)}})}keys(){return __asyncGenerator(this,arguments,function*keys_1(){var _a,e_3,_b,_c;try{try{for(var _f,_d=!0,_e=__asyncValues(this.entries());_f=yield __await(_e.next()),_a=_f.done,!_a;_d=!0){_c=_f.value,_d=!1;const[hash]=_c;yield yield __await(hash)}}catch(e_3_1){e_3={error:e_3_1}}finally{try{_d||_a||!(_b=_e.return)||(yield __await(_b.call(_e)))}finally{if(e_3)throw e_3.error}}}catch(error){throw this.emit("error",error)}})}values(){return __asyncGenerator(this,arguments,function*values_1(){var _a,e_4,_b,_c;try{try{for(var _f,_d=!0,_e=__asyncValues(this.entries());_f=yield __await(_e.next()),_a=_f.done,!_a;_d=!0){_c=_f.value,_d=!1;const[_,value]=_c;yield yield __await(value)}}catch(e_4_1){e_4={error:e_4_1}}finally{try{_d||_a||!(_b=_e.return)||(yield __await(_b.call(_e)))}finally{if(e_4)throw e_4.error}}}catch(error){throw this.emit("error",error)}})}size(){var _a,e_5,_b,_c;return __awaiter(this,void 0,void 0,function*(){let size=0;try{for(var _f,_d=!0,_e=__asyncValues(this.entries());_f=yield _e.next(),_a=_f.done,!_a;_d=!0){_c=_f.value,_d=!1;const _=_c;size++}}catch(e_5_1){e_5={error:e_5_1}}finally{try{_d||_a||!(_b=_e.return)||(yield _b.call(_e))}finally{if(e_5)throw e_5.error}}return size})}ensureNotExpired(hash,serialized){return __awaiter(this,void 0,void 0,function*(){if(this.isExpired(serialized))throw yield this.db.del(hash),this.emit("expired",hash),new Error("Expired")})}isExpired(serialized){return!!this.maxAgeMs&&Date.now()-this.parseSerializedTimestamp(serialized)>this.maxAgeMs}serializeValue(value){return Date.now()+JSON.stringify(value)}parseSerializedTimestamp(serialized){return parseInt(serialized.substring(0,13))}parseSerializedValue(serialized){return JSON.parse(serialized.substring(13))}orThrow(fn){try{return fn()}catch(error){throw this.emit("error",error)}}emit(eventName,arg){return this.events.emit(eventName,arg,this),arg}}ApiReponseCache.optionsDefaults={name:"default",dirpath:getAppDataPath("ApiReponseCache"),maxAgeMs:0};class AbstractApiClient{get eventNames(){return["retry","error","response","ready","options"]}constructor(options={}){var _a;this.events=new EventEmitter,this.retryDefaults={minTimeout:1e3,retries:5,factor:2.5,randomize:!0},this.cacheDefaults={overwrite:!1},options=this.handleOptions(options),(null===(_a=null===options||void 0===options?void 0:options.cache)||void 0===_a?void 0:_a.enable)&&(this.cache=new ApiReponseCache(options.cache));const _sendRequest=options=>__awaiter(this,void 0,void 0,function*(){const{apiRequest,args,retry,cache}=options,_retry=this.handleRetryOptions(retry),_cache=this.handleCacheOptions(cache),getFromCacheOrApi=(bail,attempt)=>__awaiter(this,void 0,void 0,function*(){try{if(!this.cache)return yield apiRequest();const hash=this.cache.hashKey({args,task:apiRequest.toString()});return(null===_cache||void 0===_cache?void 0:_cache.overwrite)&&(yield this.cache.delete(hash)),yield this.cache.getOrElse(hash,apiRequest)}catch(error){const data={attempt,error,args};1<attempt?this.emit("retry",data):this.emit("error",data)}}),response=yield asyncRetry(getFromCacheOrApi,_retry);return this.emit("response",{response,args}),response}),[queue,sendRequest]=funAsyncRateLimit(_sendRequest.bind(this),options.concurrency);this.queue=queue,this.sendRequest=sendRequest,this.emit("ready","ready")}handleOptions(options){options=cloneDeep(options);const Constructor=Object.getPrototypeOf(this).constructor;return options.cache||(options.cache={}),options.cache.name||(options.cache.name=Constructor.name),options.concurrency=Object.assign({},Constructor.concurrencyDefaults,options.concurrency),Object.assign(this.retryDefaults,options.retryDefaults),Object.assign(this.cacheDefaults,options.cacheDefaults),this.emit("options",options),options}handleRetryOptions(retryOptions){return retryOptions?Object.assign({},this.retryDefaults,retryOptions):this.retryDefaults}handleCacheOptions(cacheOptions){return cacheOptions?Object.assign({},this.cacheDefaults,cacheOptions):this.cacheDefaults}emit(event,arg){return this.events.emit(event,arg,this),arg}}AbstractApiClient.concurrencyDefaults={concurrency:100,autoStart:!0};export{AbstractApiClient,ApiReponseCache};
*/import{funAsyncRateLimit}from"@bemoje/function";import asyncRetry from"async-retry";import EventEmitter from"events";import{cloneDeep}from"lodash";import getAppDataPath from"appdata-path";import{Level}from"level";import{mkdirpSync}from"mkdirp";import hash from"object-hash";import path from"path";function __awaiter(thisArg,_arguments,P,generator){function adopt(value){return value instanceof P?value:new P(function(resolve){resolve(value)})}return new(P||(P=Promise))(function(resolve,reject){function fulfilled(value){try{step(generator.next(value))}catch(e){reject(e)}}function rejected(value){try{step(generator["throw"](value))}catch(e){reject(e)}}function step(result){result.done?resolve(result.value):adopt(result.value).then(fulfilled,rejected)}step((generator=generator.apply(thisArg,_arguments||[])).next())})}function __values(o){var s="function"==typeof Symbol&&Symbol.iterator,m=s&&o[s],i=0;if(m)return m.call(o);if(o&&"number"==typeof o.length)return{next:function(){return o&&i>=o.length&&(o=void 0),{value:o&&o[i++],done:!o}}};throw new TypeError(s?"Object is not iterable.":"Symbol.iterator is not defined.")}function __await(v){return this instanceof __await?(this.v=v,this):new __await(v)}function __asyncGenerator(thisArg,_arguments,generator){function verb(n){g[n]&&(i[n]=function(v){return new Promise(function(a,b){1<q.push([n,v,a,b])||resume(n,v)})})}function resume(n,v){try{step(g[n](v))}catch(e){settle(q[0][3],e)}}function step(r){r.value instanceof __await?Promise.resolve(r.value.v).then(fulfill,reject):settle(q[0][2],r)}function fulfill(value){resume("next",value)}function reject(value){resume("throw",value)}function settle(f,v){(f(v),q.shift(),q.length)&&resume(q[0][0],q[0][1])}if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i,g=generator.apply(thisArg,_arguments||[]),q=[];return i={},verb("next"),verb("throw"),verb("return"),i[Symbol.asyncIterator]=function(){return this},i}function __asyncValues(o){function verb(n){i[n]=o[n]&&function(v){return new Promise(function(resolve,reject){v=o[n](v),settle(resolve,reject,v.done,v.value)})}}function settle(resolve,reject,d,v){Promise.resolve(v).then(function(v){resolve({value:v,done:d})},reject)}if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i,m=o[Symbol.asyncIterator];return m?m.call(o):(o="function"==typeof __values?__values(o):o[Symbol.iterator](),i={},verb("next"),verb("throw"),verb("return"),i[Symbol.asyncIterator]=function(){return this},i)}"function"==typeof SuppressedError?SuppressedError:function(error,suppressed,message){var e=new Error(message);return e.name="SuppressedError",e.error=error,e.suppressed=suppressed,e};class ApiReponseCache{get eventNames(){return["options","hit","miss","get","put","delete","error","expired"]}constructor(options){this.events=new EventEmitter;const _options=Object.assign({},ApiReponseCache.optionsDefaults,options),{name,dirpath,maxAgeMs}=_options;this.emit("options",_options),this.maxAgeMs=maxAgeMs;const dbpath=path.join(dirpath,name);mkdirpSync(dbpath),this.db=new Level(dbpath),Object.defineProperty(this,"db",{enumerable:!1})}hashKey(key){return hash(key===void 0?"undefined":key,{algorithm:"sha1",encoding:"base64"})}getOrElse(hash,apiRequest){return __awaiter(this,void 0,void 0,function*(){try{const value=yield this.get(hash);return this.emit("hit",hash),value}catch(e){this.emit("miss",hash);const value=yield apiRequest();return yield this.put(hash,value)}})}get(hash){return __awaiter(this,void 0,void 0,function*(){return yield this.orThrow(()=>__awaiter(this,void 0,void 0,function*(){const serialized=yield this.db.get(hash);return yield this.ensureNotExpired(hash,serialized),this.emit("get",hash),this.parseSerializedValue(serialized)}))})}getSafe(hash){return __awaiter(this,void 0,void 0,function*(){try{const serialized=yield this.db.get(hash);return yield this.ensureNotExpired(hash,serialized),this.emit("get",hash),this.parseSerializedValue(serialized)}catch(error){return}})}has(hash){return __awaiter(this,void 0,void 0,function*(){try{return yield this.db.get(hash),!0}catch(e){return!1}})}put(hash,value){return __awaiter(this,void 0,void 0,function*(){return yield this.orThrow(()=>__awaiter(this,void 0,void 0,function*(){const serialized=this.serializeValue(value);return yield this.db.put(hash,serialized),this.emit("put",hash),value}))})}delete(hash){return __awaiter(this,void 0,void 0,function*(){return yield this.orThrow(()=>__awaiter(this,void 0,void 0,function*(){yield this.db.del(hash),this.emit("delete",hash)}))})}deleteExpired(){var _a,e_1,_b,_c;return __awaiter(this,void 0,void 0,function*(){try{for(var _f,_d=!0,_e=__asyncValues(this.entries());_f=yield _e.next(),_a=_f.done,!_a;_d=!0){_c=_f.value,_d=!1;const _=_c}}catch(e_1_1){e_1={error:e_1_1}}finally{try{_d||_a||!(_b=_e.return)||(yield _b.call(_e))}finally{if(e_1)throw e_1.error}}return this})}deleteEverything(){return __awaiter(this,void 0,void 0,function*(){return yield this.orThrow(()=>__awaiter(this,void 0,void 0,function*(){yield this.db.clear(),this.emit("delete","All cache data was deleted.")}))})}entries(){return __asyncGenerator(this,arguments,function*entries_1(){var _a,e_2,_b,_c;try{try{for(var _f,_d=!0,_e=__asyncValues(this.db.iterator());_f=yield __await(_e.next()),_a=_f.done,!_a;_d=!0){_c=_f.value,_d=!1;const[hash,serialized]=_c;this.isExpired(serialized)&&this.db.del(hash).then(()=>this.emit("expired",hash)),yield yield __await([hash,this.parseSerializedValue(serialized)])}}catch(e_2_1){e_2={error:e_2_1}}finally{try{_d||_a||!(_b=_e.return)||(yield __await(_b.call(_e)))}finally{if(e_2)throw e_2.error}}}catch(error){throw this.emit("error",error)}})}keys(){return __asyncGenerator(this,arguments,function*keys_1(){var _a,e_3,_b,_c;try{try{for(var _f,_d=!0,_e=__asyncValues(this.entries());_f=yield __await(_e.next()),_a=_f.done,!_a;_d=!0){_c=_f.value,_d=!1;const[hash]=_c;yield yield __await(hash)}}catch(e_3_1){e_3={error:e_3_1}}finally{try{_d||_a||!(_b=_e.return)||(yield __await(_b.call(_e)))}finally{if(e_3)throw e_3.error}}}catch(error){throw this.emit("error",error)}})}values(){return __asyncGenerator(this,arguments,function*values_1(){var _a,e_4,_b,_c;try{try{for(var _f,_d=!0,_e=__asyncValues(this.entries());_f=yield __await(_e.next()),_a=_f.done,!_a;_d=!0){_c=_f.value,_d=!1;const[_,value]=_c;yield yield __await(value)}}catch(e_4_1){e_4={error:e_4_1}}finally{try{_d||_a||!(_b=_e.return)||(yield __await(_b.call(_e)))}finally{if(e_4)throw e_4.error}}}catch(error){throw this.emit("error",error)}})}size(){var _a,e_5,_b,_c;return __awaiter(this,void 0,void 0,function*(){let size=0;try{for(var _f,_d=!0,_e=__asyncValues(this.entries());_f=yield _e.next(),_a=_f.done,!_a;_d=!0){_c=_f.value,_d=!1;const _=_c;size++}}catch(e_5_1){e_5={error:e_5_1}}finally{try{_d||_a||!(_b=_e.return)||(yield _b.call(_e))}finally{if(e_5)throw e_5.error}}return size})}ensureNotExpired(hash,serialized){return __awaiter(this,void 0,void 0,function*(){if(this.isExpired(serialized))throw yield this.db.del(hash),this.emit("expired",hash),new Error("Expired")})}isExpired(serialized){return!!this.maxAgeMs&&Date.now()-this.parseSerializedTimestamp(serialized)>this.maxAgeMs}serializeValue(value){return Date.now()+JSON.stringify(value)}parseSerializedTimestamp(serialized){return parseInt(serialized.substring(0,13))}parseSerializedValue(serialized){return JSON.parse(serialized.substring(13))}orThrow(fn){try{return fn()}catch(error){throw this.emit("error",error)}}emit(eventName,arg){return this.events.emit(eventName,arg,this),arg}}ApiReponseCache.optionsDefaults={name:"default",dirpath:getAppDataPath("ApiReponseCache"),maxAgeMs:0};class AbstractApiClient{get eventNames(){return["retry","error","response","ready","options"]}constructor(options={}){var _a;this.events=new EventEmitter,this.retryDefaults={minTimeout:1e3,retries:5,factor:2.5,randomize:!0},this.cacheDefaults={overwrite:!1},options=this.handleOptions(options),(null===(_a=null===options||void 0===options?void 0:options.cache)||void 0===_a?void 0:_a.enable)&&(this.cache=new ApiReponseCache(options.cache));const _sendRequest=options=>__awaiter(this,void 0,void 0,function*(){const{apiRequest,args,retry,cache}=options,_retry=this.handleRetryOptions(retry),_cache=this.handleCacheOptions(cache),getFromCacheOrApi=(bail,attempt)=>__awaiter(this,void 0,void 0,function*(){try{if(!this.cache)return yield apiRequest();const hash=this.cache.hashKey({args,task:apiRequest.toString()});return(null===_cache||void 0===_cache?void 0:_cache.overwrite)&&(yield this.cache.delete(hash)),yield this.cache.getOrElse(hash,apiRequest)}catch(error){const data={attempt,error,args};1<attempt?this.emit("retry",data):this.emit("error",data)}}),response=yield asyncRetry(getFromCacheOrApi,_retry);return this.emit("response",{response,args}),response}),[queue,sendRequest]=funAsyncRateLimit(_sendRequest.bind(this),options.concurrency);this.queue=queue,this.sendRequest=sendRequest,this.emit("ready","ready")}handleOptions(options){options=cloneDeep(options);const Constructor=Object.getPrototypeOf(this).constructor;return options.cache||(options.cache={}),options.cache.name||(options.cache.name=Constructor.name),options.concurrency=Object.assign({},Constructor.concurrencyDefaults,options.concurrency),Object.assign(this.retryDefaults,options.retryDefaults),Object.assign(this.cacheDefaults,options.cacheDefaults),this.emit("options",options),options}handleRetryOptions(retryOptions){return retryOptions?Object.assign({},this.retryDefaults,retryOptions):this.retryDefaults}handleCacheOptions(cacheOptions){return cacheOptions?Object.assign({},this.cacheDefaults,cacheOptions):this.cacheDefaults}emit(event,arg){return this.events.emit(event,arg,this),arg}}AbstractApiClient.concurrencyDefaults={concurrency:100,autoStart:!0};export{AbstractApiClient,ApiReponseCache};
//# sourceMappingURL=index.esm.js.map
{
"name": "@bemoje/api-util",
"version": "0.0.8",
"version": "0.0.9",
"description": "Utilities for working woth APIs.",

@@ -12,41 +12,5 @@ "main": "dist/index.cjs.js",

"build": "rimraf dist && rollup --config ./rollup.config.js --bundleConfigAsCjs",
"docsmd": "rimraf docs/md && typedoc --out docs/md/ src/index.ts --readme none --plugin typedoc-plugin-markdown --theme markdown --entryDocument index.md --publicPath /docs/md/",
"docshtml": "rimraf docs/html && typedoc --out docs/html --entryPoints src/index.ts",
"prepub": "npm run lint && npm run build && npm run test && npm run docsmd && npm run docshtml",
"viewdocs": "start docs/html/index.html"
"docs": "rimraf ../../docs/api-util && typedoc --out ../../docs/api-util --entryPoints src/index.ts",
"prepub": "npm run lint && npm run build && npm run test && npm run docs"
},
"devDependencies": {
"@rollup/plugin-commonjs": "^25.0.3",
"@rollup/plugin-node-resolve": "^15.1.0",
"@types/async-retry": "^1.4.5",
"@types/cli-color": "^2.0.2",
"@types/commander": "^2.12.2",
"@types/eslint-plugin-prettier": "^3.1.0",
"@types/jest": "^29.5.3",
"@types/lodash": "^4.14.196",
"@types/mkdirp": "^2.0.0",
"@types/node": "^20.4.8",
"@types/object-hash": "^3.0.2",
"@types/pdf-parse": "^1.1.1",
"@types/rimraf": "^4.0.5",
"@types/rollup": "^0.54.0",
"@typescript-eslint/eslint-plugin": "^6.3.0",
"@typescript-eslint/parser": "^6.3.0",
"camel-case": "^4.1.2",
"eslint": "^8.46.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-prettier": "^5.0.0",
"jest": "^29.6.2",
"jest-environment-node": "^29.6.2",
"prettier": "^3.0.1",
"rimraf": "^5.0.1",
"rollup": "^3.27.2",
"rollup-plugin-babel-minify": "^10.0.0",
"rollup-plugin-typescript2": "^0.35.0",
"ts-jest": "^29.1.1",
"ts-node": "^10.9.1",
"tslib": "^2.6.1",
"typedoc-plugin-markdown": "^3.15.4",
"typescript": "^5.1.6"
},
"author": {

@@ -60,3 +24,3 @@ "name": "Benjamin Møller Jensen",

"dependencies": {
"@bemoje/node-util": "latest",
"@bemoje/function": "latest",
"@bemoje/queue": "latest",

@@ -82,3 +46,8 @@ "appdata-path": "^1.0.0",

},
"homepage": "https://github.com/bemoje/tsmono"
"homepage": "https://github.com/bemoje/tsmono",
"devDependencies": {
"@types/async-retry": "^1.4.5",
"@types/lodash": "^4.14.197",
"@types/object-hash": "^3.0.3"
}
}

@@ -17,2 +17,4 @@ # @bemoje/api-util

## Documentation
[api-util docs](https://bemoje.github.io/tsmono/html/api-util/modules.html)

@@ -39,17 +41,1 @@ ##### Donate

Released under the [MIT License](./LICENSE).
## Documentation
- [HTML](https://github.com/bemoje/tsmono/blob/main/pkg/api-util/docs/html/index.html)
- [Markdown](https://github.com/bemoje/tsmono/blob/main/pkg/api-util/docs/md/index.md)
### Classes
- [AbstractApiClient](https://github.com/bemoje/tsmono/blob/main/pkg/api-util/docs/md/classes/AbstractApiClient.md)
- [ApiReponseCache](https://github.com/bemoje/tsmono/blob/main/pkg/api-util/docs/md/classes/ApiReponseCache.md)
### Interfaces
- [IAbstractApiClientOptions](https://github.com/bemoje/tsmono/blob/main/pkg/api-util/docs/md/interfaces/IAbstractApiClientOptions.md)
- [IApiResponseCacheOptions](https://github.com/bemoje/tsmono/blob/main/pkg/api-util/docs/md/interfaces/IApiResponseCacheOptions.md)
- [IAsyncRetryOptions](https://github.com/bemoje/tsmono/blob/main/pkg/api-util/docs/md/interfaces/IAsyncRetryOptions.md)
- [IResponseCacheOptions](https://github.com/bemoje/tsmono/blob/main/pkg/api-util/docs/md/interfaces/IResponseCacheOptions.md)

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc