fix(core): update

This commit is contained in:
2020-10-17 16:38:22 +00:00
parent 00964a7db1
commit 115d461d29
6 changed files with 720 additions and 791 deletions

View File

@ -0,0 +1,43 @@
import { WebStore } from './webstore.classes.webstore';
import * as plugins from './webstore.plugins';
/**
* a cache that can be used to store and retrieve typedrequests
*/
export class TypedrequestCache {
private webstore = new WebStore<plugins.typedrequestInterfaces.ITypedRequest>({
dbName: 'trStore',
storeName: 'trStore',
});
private buildKey(requestArg: plugins.typedrequestInterfaces.ITypedRequest) {
return plugins.smartjson.stringify({
method: requestArg.method,
request: requestArg.request,
});
}
/**
* stores by request
* @param typedrequestarg
*/
public async setByRequest(
typedrequestArg: plugins.typedrequestInterfaces.ITypedRequest
): Promise<void> {
if (!typedrequestArg.response) {
throw new Error('You cannot store requests without a response present');
}
await this.webstore.set(this.buildKey(typedrequestArg), typedrequestArg);
}
/**
* get by full tyoedrequest by partial typedrequest
* @param typedrequestarg
*/
public async getByRequest(
typedrequestArg: plugins.typedrequestInterfaces.ITypedRequest
): Promise<plugins.typedrequestInterfaces.ITypedRequest> {
const result = await this.webstore.get(this.buildKey(typedrequestArg));
return result;
}
}

View File

@ -1,9 +1,15 @@
// pushrocks scope
import * as lik from '@pushrocks/lik';
import * as smartjson from '@pushrocks/smartjson';
import * as smartpromise from '@pushrocks/smartpromise';
import * as smartrx from '@pushrocks/smartrx';
export {
smartpromise
};
export { lik, smartjson, smartpromise, smartrx };
// apiglobal scope
import * as typedrequestInterfaces from '@apiglobal/typedrequest-interfaces';
export { typedrequestInterfaces };
// thirdparty scope
import * as idb from 'idb';