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

@servicetitan/ajax-handlers

Package Overview
Dependencies
Maintainers
7
Versions
209
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@servicetitan/ajax-handlers - npm Package Compare versions

Comparing version 22.21.1 to 22.21.2

9

dist/__mocks__/handlers.d.ts

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

import { AsyncResponseResolverReturnType, MockedResponse, ResponseComposition, RestContext, RestRequest } from 'msw';
export interface RequestCountsData {
requestCounts: {
[key: string]: number;
};
}
export declare function withRequestCount(resolver: (req: RestRequest, res: ResponseComposition, ctx: RestContext, requestCounts: {
[key: string]: number;
}) => AsyncResponseResolverReturnType<MockedResponse>): (req: RestRequest, res: ResponseComposition, ctx: RestContext) => AsyncResponseResolverReturnType<MockedResponse<any>>;
export declare const handlers: import("msw").RestHandler<import("msw/lib/glossary-de6278a9").M<import("msw/lib/glossary-de6278a9").h>>[];
//# sourceMappingURL=handlers.d.ts.map

2

dist/__mocks__/handlers.js
import { rest, } from 'msw';
// Higher order function to keep track of request counts in session storage
function withRequestCount(resolver) {
export function withRequestCount(resolver) {
return (req, res, ctx) => {

@@ -5,0 +5,0 @@ var _a, _b;

@@ -9,2 +9,3 @@ import { SymbolToken } from '@servicetitan/react-ioc';

}
export declare const RETRY_LIMIT = 3;
export declare function withMicroservice<T>(baseURL: string, authURL: string, tokens: SymbolToken<string>[], UnwrappedComponent: ComponentType<T>, extraHeaders?: {

@@ -11,0 +12,0 @@ [key: string]: any;

@@ -28,2 +28,13 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {

import { useEffect } from 'react';
export const RETRY_LIMIT = 3;
function retryRequest(config) {
var _a;
if (!config.metadata) {
config.metadata = { retries: 1 };
}
else {
config.metadata.retries = ((_a = config.metadata.retries) !== null && _a !== void 0 ? _a : 0) + 1;
}
return axios(config);
}
export function withMicroservice(baseURL, authURL, tokens, UnwrappedComponent, extraHeaders, options) {

@@ -153,3 +164,3 @@ var _MicroserviceAuthStore_abortAuthRequest, _MicroserviceAuthStore_doAuthRequest, _MicroserviceAuthStore_addAuthHeaders, _MicroserviceAuthStore_baseURLMatchesConfig, _MicroserviceAuthStore_isAuthRequestConfig;

this.axiosResponseInterceptor = axios.interceptors.response.use(response => response, error => {
var _a, _b;
var _a, _b, _c, _d;
if (!this.isMounted) {

@@ -168,2 +179,7 @@ return Promise.reject(error);

}
if (((_c = (_b = config.metadata) === null || _b === void 0 ? void 0 : _b.retries) !== null && _c !== void 0 ? _c : 0) >= RETRY_LIMIT) {
// eslint-disable-next-line no-console
console.error(`withMicroservice has reached request retry limit for ${config.url}`);
return Promise.reject(axiosError);
}
if (this.isFetching) {

@@ -173,3 +189,3 @@ // Queue up request while the auth token is being fetched by another request

this.requestQueue.push(() => {
resolve(axios(config));
resolve(retryRequest(config));
});

@@ -180,5 +196,5 @@ });

const newHeaders = __classPrivateFieldGet(this, _MicroserviceAuthStore_addAuthHeaders, "f").call(this, config);
if (newHeaders.Authorization !== ((_b = config.headers) === null || _b === void 0 ? void 0 : _b.Authorization) &&
if (newHeaders.Authorization !== ((_d = config.headers) === null || _d === void 0 ? void 0 : _d.Authorization) &&
this.authToken !== '') {
return axios(config);
return retryRequest(config);
}

@@ -193,3 +209,3 @@ return __classPrivateFieldGet(this, _MicroserviceAuthStore_doAuthRequest, "f").call(this).then(() => {

this.requestQueue = [];
return axios(config);
return retryRequest(config);
});

@@ -196,0 +212,0 @@ });

{
"name": "@servicetitan/ajax-handlers",
"version": "22.21.1",
"version": "22.21.2",
"description": "",

@@ -5,0 +5,0 @@ "repository": {

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