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

axios-cache-interceptor

Package Overview
Dependencies
Maintainers
1
Versions
80
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

axios-cache-interceptor - npm Package Compare versions

Comparing version 0.2.8 to 0.3.0

6

dist/axios/types.d.ts

@@ -59,3 +59,3 @@ import type { AxiosInstance, AxiosInterceptorManager, AxiosPromise, AxiosRequestConfig, AxiosResponse, Method } from 'axios';

};
export declare type CacheAxiosResponse<T = any> = AxiosResponse<T> & {
export declare type CacheAxiosResponse<T = never> = AxiosResponse<T> & {
config: CacheRequestConfig;

@@ -119,3 +119,3 @@ /**

*/
responseInterceptor: AxiosInterceptor<CacheAxiosResponse>;
responseInterceptor: AxiosInterceptor<CacheAxiosResponse<any>>;
}

@@ -136,3 +136,3 @@ /**

request: AxiosInterceptorManager<CacheRequestConfig>;
response: AxiosInterceptorManager<CacheAxiosResponse>;
response: AxiosInterceptorManager<CacheAxiosResponse<never>>;
};

@@ -139,0 +139,0 @@ getUri(config?: CacheRequestConfig): string;

import type { AxiosCacheInstance, CacheAxiosResponse } from '../axios/types';
import type { AxiosInterceptor } from './types';
export declare class CacheResponseInterceptor implements AxiosInterceptor<CacheAxiosResponse> {
export declare class CacheResponseInterceptor<R> implements AxiosInterceptor<CacheAxiosResponse<R>> {
readonly axios: AxiosCacheInstance;

@@ -13,4 +13,4 @@ constructor(axios: AxiosCacheInstance);

private rejectResponse;
onFulfilled: (response: CacheAxiosResponse) => Promise<CacheAxiosResponse>;
onFulfilled: (response: CacheAxiosResponse<R>) => Promise<CacheAxiosResponse<R>>;
}
//# sourceMappingURL=response.d.ts.map
import type { AxiosResponse } from 'axios';
import type { CachePredicateObject } from './types';
export declare function checkPredicateObject(response: AxiosResponse, { statusCheck, containsHeaders: containsHeader, responseMatch }: CachePredicateObject): boolean;
export declare function checkPredicateObject<R>(response: AxiosResponse<R>, { statusCheck, containsHeaders: containsHeader, responseMatch }: CachePredicateObject): boolean;
//# sourceMappingURL=cache-predicate.d.ts.map
import type { AxiosResponse } from 'axios';
import type { CacheRequestConfig } from '../axios/types';
export declare type CachePredicate = CachePredicateObject | ((response: AxiosResponse) => boolean);
export declare type CachePredicate = CachePredicateObject | (<R>(response: AxiosResponse<R>) => boolean);
export declare type CachePredicateObject = {

@@ -5,0 +5,0 @@ /**

{
"name": "axios-cache-interceptor",
"version": "0.2.8",
"version": "0.3.0",
"description": "Cache interceptor for axios",

@@ -49,3 +49,3 @@ "main": "dist/index.js",

"auto-changelog": "^2.3.0",
"axios": "^0.21.1",
"axios": "^0.22.0",
"eslint": "^7.32.0",

@@ -60,3 +60,6 @@ "eslint-config-prettier": "^8.3.0",

"typescript": "^4.4.3"
},
"peerDependencies": {
"axios": "~0.22.0"
}
}

@@ -87,2 +87,29 @@ <br />

## Table of contents
- [Table of contents](#table-of-contents)
- [Installing](#installing)
- [Support list](#support-list)
- [Getting Started](#getting-started)
- [What we support](#what-we-support)
- [Basic Knowledge](#basic-knowledge)
- [Request id](#request-id)
- [Global configuration](#global-configuration)
- [storage](#storage)
- [generateKey](#generatekey)
- [waiting](#waiting)
- [headerInterpreter](#headerinterpreter)
- [requestInterceptor and responseInterceptor](#requestinterceptor-and-responseinterceptor)
- [Per-request configuration](#per-request-configuration)
- [ttl](#ttl)
- [interpretHeader](#interpretheader)
- [methods](#methods)
- [cachePredicate](#cachepredicate)
- [update](#update)
- [Inspiration](#inspiration)
- [License](#license)
- [Contact](#contact)
<br />
## Installing

@@ -102,2 +129,15 @@

## Support list
Below you can check what version of this package is supported by your version of axios.
> **NOTE**: Below v0.3, axios was not configured as a peer dependency
| [Version](https://github.com/ArthurFiorette/axios-cache-interceptor/releases) | [Axios](https://github.com/axios/axios/releases) |
| ----------------------------------------------------------------------------- | ------------------------------------------------ |
| `v0.3` | `>= v0.22` |
| `<= v0.2` | `v0.21` |
<br />
## Getting Started

@@ -104,0 +144,0 @@

@@ -84,3 +84,3 @@ import type {

export type CacheAxiosResponse<T = any> = AxiosResponse<T> & {
export type CacheAxiosResponse<T = never> = AxiosResponse<T> & {
config: CacheRequestConfig;

@@ -153,3 +153,3 @@

*/
responseInterceptor: AxiosInterceptor<CacheAxiosResponse>;
responseInterceptor: AxiosInterceptor<CacheAxiosResponse<any>>;
}

@@ -173,3 +173,3 @@

request: AxiosInterceptorManager<CacheRequestConfig>;
response: AxiosInterceptorManager<CacheAxiosResponse>;
response: AxiosInterceptorManager<CacheAxiosResponse<never>>;
};

@@ -176,0 +176,0 @@

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

export class CacheResponseInterceptor implements AxiosInterceptor<CacheAxiosResponse> {
export class CacheResponseInterceptor<R>
implements AxiosInterceptor<CacheAxiosResponse<R>>
{
constructor(readonly axios: AxiosCacheInstance) {}

@@ -23,4 +25,4 @@

private testCachePredicate = (
response: AxiosResponse,
private testCachePredicate = <R>(
response: AxiosResponse<R>,
{ cache }: CacheConfig

@@ -50,3 +52,5 @@ ): boolean => {

onFulfilled = async (response: CacheAxiosResponse): Promise<CacheAxiosResponse> => {
onFulfilled = async (
response: CacheAxiosResponse<R>
): Promise<CacheAxiosResponse<R>> => {
const key = this.axios.generateKey(response.config);

@@ -53,0 +57,0 @@ response.id = key;

import type { AxiosResponse } from 'axios';
import type { CachePredicateObject } from './types';
export function checkPredicateObject(
response: AxiosResponse,
export function checkPredicateObject<R>(
response: AxiosResponse<R>,
{ statusCheck, containsHeaders: containsHeader, responseMatch }: CachePredicateObject

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

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

| CachePredicateObject
| ((response: AxiosResponse) => boolean);
| (<R>(response: AxiosResponse<R>) => boolean);

@@ -9,0 +9,0 @@ export type CachePredicateObject = {

@@ -6,3 +6,3 @@ {

/* Projects */
"incremental": true, /* Enable incremental compilation */
"incremental": true /* Enable incremental compilation */,
// "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */

@@ -15,3 +15,3 @@ // "tsBuildInfoFile": "./", /* Specify the folder for .tsbuildinfo incremental compilation files. */

/* Language and Environment */
"target": "ESNext", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
"target": "ESNext" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */,
// "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */

@@ -29,3 +29,3 @@ // "jsx": "preserve", /* Specify what JSX code is generated. */

/* Modules */
"module": "CommonJS", /* Specify what module code is generated. */
"module": "CommonJS" /* Specify what module code is generated. */,
// "rootDir": "./", /* Specify the root folder within your source files. */

@@ -48,13 +48,13 @@ // "moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */

/* Emit */
"declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
"declarationMap": true, /* Create sourcemaps for d.ts files. */
"declaration": true /* Generate .d.ts files from TypeScript and JavaScript files in your project. */,
"declarationMap": true /* Create sourcemaps for d.ts files. */,
// "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
"sourceMap": true, /* Create source map files for emitted JavaScript files. */
"sourceMap": true /* Create source map files for emitted JavaScript files. */,
// "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If `declaration` is true, also designates a file that bundles all .d.ts output. */
"outDir": "./dist", /* Specify an output folder for all emitted files. */
"outDir": "./dist" /* Specify an output folder for all emitted files. */,
// "removeComments": true, /* Disable emitting comments. */
// "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. */
"importsNotUsedAsValues": "error", /* Specify emit/checking behavior for imports that are only used for types */
"downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
"importsNotUsedAsValues": "error" /* Specify emit/checking behavior for imports that are only used for types */,
"downlevelIteration": true /* Emit more compliant, but verbose and less performant JavaScript for iteration. */,
// "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */

@@ -65,3 +65,3 @@ // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */

// "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
"newLine": "lf", /* Set the newline character for emitting files. */
"newLine": "lf" /* Set the newline character for emitting files. */,
// "stripInternal": true, /* Disable emitting declarations that have `@internal` in their JSDoc comments. */

@@ -76,24 +76,24 @@ // "noEmitHelpers": true, /* Disable generating custom helper functions like `__extends` in compiled output. */

// "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
"esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables `allowSyntheticDefaultImports` for type compatibility. */
"esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables `allowSyntheticDefaultImports` for type compatibility. */,
// "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
"forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
"forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */,
/* Type Checking */
"strict": true, /* Enable all strict type-checking options. */
"strict": true /* Enable all strict type-checking options. */,
// "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied `any` type.. */
"strictNullChecks": true, /* When type checking, take into account `null` and `undefined`. */
"strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
"strictBindCallApply": true, /* Check that the arguments for `bind`, `call`, and `apply` methods match the original function. */
"strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
"noImplicitThis": true, /* Enable error reporting when `this` is given the type `any`. */
"useUnknownInCatchVariables": true, /* Type catch clause variables as 'unknown' instead of 'any'. */
"alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
"noUnusedLocals": true, /* Enable error reporting when a local variables aren't read. */
"noUnusedParameters": true, /* Raise an error when a function parameter isn't read */
"exactOptionalPropertyTypes": false, /* Interpret optional property types as written, rather than adding 'undefined'. */
"noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
"noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
"noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */
"noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
"noPropertyAccessFromIndexSignature": false, /* Enforces using indexed accessors for keys declared using an indexed type */
"strictNullChecks": true /* When type checking, take into account `null` and `undefined`. */,
"strictFunctionTypes": true /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */,
"strictBindCallApply": true /* Check that the arguments for `bind`, `call`, and `apply` methods match the original function. */,
"strictPropertyInitialization": true /* Check for class properties that are declared but not set in the constructor. */,
"noImplicitThis": true /* Enable error reporting when `this` is given the type `any`. */,
"useUnknownInCatchVariables": true /* Type catch clause variables as 'unknown' instead of 'any'. */,
"alwaysStrict": true /* Ensure 'use strict' is always emitted. */,
"noUnusedLocals": true /* Enable error reporting when a local variables aren't read. */,
"noUnusedParameters": true /* Raise an error when a function parameter isn't read */,
"exactOptionalPropertyTypes": false /* Interpret optional property types as written, rather than adding 'undefined'. */,
"noImplicitReturns": true /* Enable error reporting for codepaths that do not explicitly return in a function. */,
"noFallthroughCasesInSwitch": true /* Enable error reporting for fallthrough cases in switch statements. */,
"noUncheckedIndexedAccess": true /* Include 'undefined' in index signature results */,
"noImplicitOverride": true /* Ensure overriding members in derived classes are marked with an override modifier. */,
"noPropertyAccessFromIndexSignature": false /* Enforces using indexed accessors for keys declared using an indexed type */,
// "allowUnusedLabels": true, /* Disable error reporting for unused labels. */

@@ -104,4 +104,4 @@ // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */

// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
"skipLibCheck": true /* Skip type checking all .d.ts files. */
"skipLibCheck": true /* Skip type checking all .d.ts files. */
}
}

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

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