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

@timetac/js-client-library

Package Overview
Dependencies
Maintainers
1
Versions
214
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@timetac/js-client-library - npm Package Compare versions

Comparing version 0.15.0 to 0.16.0

24

dist/utils/axiosSetup.js

@@ -20,3 +20,3 @@ "use strict";

const createResponseRejectedInterceptor = (interceptorParams) => (error) => __awaiter(void 0, void 0, void 0, function* () {
var _a, _b, _c;
var _a, _b;
if (interceptorParams.config.settings.shouldAutoRefreshToken && error.response) {

@@ -33,4 +33,5 @@ const untouchedRequest = error.config;

}
catch (error) {
const status = (_c = (_b = error.raw) === null || _b === void 0 ? void 0 : _b.response) === null || _c === void 0 ? void 0 : _c.status;
catch (e) {
const error = e;
const status = (_b = error.response) === null || _b === void 0 ? void 0 : _b.status;
if (status === 497) {

@@ -55,18 +56,3 @@ if (interceptorParams.config.settings.onTokenRefreshFailed != null) {

}
let toThrow;
if (error.code != null && error.code.length > 0) {
toThrow = {
statusCode: parseInt(error.code),
message: error.message,
raw: error,
};
}
else {
toThrow = {
statusCode: undefined,
message: error.message,
raw: error,
};
}
throw toThrow;
throw error;
});

@@ -73,0 +59,0 @@ exports.createResponseRejectedInterceptor = createResponseRejectedInterceptor;

@@ -13,17 +13,2 @@ "use strict";

exports.createRawApiResponse = void 0;
function handleResponse(axiosResponse) {
var _a, _b;
if (isRawApiResponse(axiosResponse.data) && axiosResponse.data.Success) {
axiosResponse.data._ignoreTypeGuard = undefined;
return axiosResponse.data;
}
const optionalResponse = axiosResponse.data;
throw {
response: optionalResponse,
_plainError: axiosResponse,
message: (_a = optionalResponse === null || optionalResponse === void 0 ? void 0 : optionalResponse.ErrorMessage) !== null && _a !== void 0 ? _a : (axiosResponse.status != 200 ? axiosResponse.statusText : 'Unsuccessful response'),
code: (_b = optionalResponse === null || optionalResponse === void 0 ? void 0 : optionalResponse.Error) !== null && _b !== void 0 ? _b : axiosResponse.status,
stack: new Error().stack,
};
}
function isRawApiResponse(response) {

@@ -39,4 +24,36 @@ const hasHost = 'Host' in response;

function createRawApiResponse(promise) {
var _a, _b, _c, _d, _e;
return __awaiter(this, void 0, void 0, function* () {
return promise.then(handleResponse);
let axiosResponse;
try {
axiosResponse = yield promise;
}
catch (e) {
const error = e;
if (((_a = error.response) === null || _a === void 0 ? void 0 : _a.data) != null && 'Success' in error.response.data) {
axiosResponse = error.response;
}
else {
throw {
_plainError: error,
message: error.message,
code: (_b = error.response) === null || _b === void 0 ? void 0 : _b.status,
stack: (_c = error.stack) !== null && _c !== void 0 ? _c : new Error().stack,
};
}
}
if (isRawApiResponse(axiosResponse.data) && axiosResponse.data.Success) {
axiosResponse.data._ignoreTypeGuard = undefined;
return axiosResponse.data;
}
else {
const optionalResponse = axiosResponse.data;
throw {
response: optionalResponse,
_plainError: axiosResponse,
message: (_d = optionalResponse === null || optionalResponse === void 0 ? void 0 : optionalResponse.ErrorMessage) !== null && _d !== void 0 ? _d : (axiosResponse.status != 200 ? axiosResponse.statusText : 'Unsuccessful response'),
code: (_e = optionalResponse === null || optionalResponse === void 0 ? void 0 : optionalResponse.Error) !== null && _e !== void 0 ? _e : axiosResponse.status,
stack: new Error().stack,
};
}
});

@@ -43,0 +60,0 @@ }

@@ -16,3 +16,3 @@ "use strict";

function toApiResponse(promise) {
var _a, _b, _c;
var _a, _b, _c, _d, _e;
return __awaiter(this, void 0, void 0, function* () {

@@ -25,9 +25,13 @@ let resolved;

const error = e;
throw {
response: resolved === null || resolved === void 0 ? void 0 : resolved.data,
_plainError: error,
message: error.message,
code: resolved === null || resolved === void 0 ? void 0 : resolved.status,
stack: (_a = error.stack) !== null && _a !== void 0 ? _a : new Error().stack,
};
if (((_a = error.response) === null || _a === void 0 ? void 0 : _a.data) != null && 'Success' in error.response.data) {
resolved = error.response;
}
else {
throw {
_plainError: error,
message: error.message,
code: (_b = error.response) === null || _b === void 0 ? void 0 : _b.status,
stack: (_c = error.stack) !== null && _c !== void 0 ? _c : new Error().stack,
};
}
}

@@ -44,4 +48,4 @@ const apiResponse = resolved.data;

_plainError: resolved,
message: (_b = apiResponse.ErrorMessage) !== null && _b !== void 0 ? _b : (resolved.status != 200 ? resolved.statusText : 'Unsuccessful response'),
code: (_c = apiResponse.Error) !== null && _c !== void 0 ? _c : resolved.status,
message: (_d = apiResponse.ErrorMessage) !== null && _d !== void 0 ? _d : (resolved.status != 200 ? resolved.statusText : 'Unsuccessful response'),
code: (_e = apiResponse.Error) !== null && _e !== void 0 ? _e : resolved.status,
stack: new Error().stack,

@@ -48,0 +52,0 @@ };

{
"name": "@timetac/js-client-library",
"version": "0.15.0",
"version": "0.16.0",
"description": "TimeTac API JS client library",

@@ -51,7 +51,6 @@ "homepage": "https://github.com/TimeTac/js-client-library#readme",

"eslint-plugin-jsx-a11y": "^6.4.1",
"eslint-plugin-simple-import-sort": "^7.0.0",
"husky-v4": "^4.3.8",
"jest": "^26.6.3",
"jest-ts-auto-mock": "^2.0.0",
"lint-staged": "^10.5.4",
"lint-staged": "^11.0.0",
"prettier": "^2.2.1",

@@ -58,0 +57,0 @@ "ts-auto-mock": "^3.1.2",

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