@frontegg/rest-api
Advanced tools
Comparing version 3.0.111 to 3.0.112
@@ -1,2 +0,2 @@ | ||
export interface ISettingsResponse { | ||
export interface ISettingsResponse extends IPublicSettingsResponse { | ||
address?: string; | ||
@@ -3,0 +3,0 @@ timezone?: string; |
50
fetch.js
@@ -136,2 +136,30 @@ import _extends from "@babel/runtime/helpers/esm/extends"; | ||
const handleError = async (response, context) => { | ||
var _errorMessage, _context$logLevel, _context$logLevel2; | ||
if (response.status === 413) { | ||
throw new FronteggApiError('Error request is too large', response.status); | ||
} | ||
let errorMessage; | ||
try { | ||
errorMessage = await response.text(); | ||
errorMessage = JSON.parse(errorMessage); | ||
} catch (e) { | ||
errorMessage = undefined; | ||
} | ||
const contentType = response.headers.get("content-type"); | ||
if ((_errorMessage = errorMessage) != null && _errorMessage.errors) { | ||
errorMessage = errorMessage.errors.join(', '); | ||
} else if (typeof errorMessage !== 'string' || !(contentType != null && contentType.includes("application/json"))) { | ||
errorMessage = `Error ${response.status} - ${response.statusText}`; | ||
} | ||
if (response.status >= 400 && response.status < 500 && ['warn'].includes((_context$logLevel = context.logLevel) != null ? _context$logLevel : '')) console.warn(errorMessage);else if (response.status === 500 && ['warn', 'error'].includes((_context$logLevel2 = context.logLevel) != null ? _context$logLevel2 : '')) console.error(errorMessage); | ||
throw new FronteggApiError(errorMessage, response.status); | ||
}; | ||
const sendRequest = async opts => { | ||
@@ -156,23 +184,3 @@ var _opts$method, _ref, _opts$credentials; | ||
if (!response.ok) { | ||
var _context$logLevel, _context$logLevel2; | ||
if (response.status === 413) { | ||
throw new FronteggApiError('Error request is too large', response.status); | ||
} | ||
let errorMessage; | ||
try { | ||
errorMessage = await response.text(); | ||
errorMessage = JSON.parse(errorMessage); | ||
} catch (e) {} | ||
if (errorMessage.errors) { | ||
errorMessage = errorMessage.errors.join(', '); | ||
} else if (typeof errorMessage !== 'string') { | ||
errorMessage = `Error ${response.status} - ${response.statusText}`; | ||
} | ||
if (response.status >= 400 && response.status < 500 && ['warn'].includes((_context$logLevel = context.logLevel) != null ? _context$logLevel : '')) console.warn(errorMessage);else if (response.status === 500 && ['warn', 'error'].includes((_context$logLevel2 = context.logLevel) != null ? _context$logLevel2 : '')) console.error(errorMessage); | ||
throw new FronteggApiError(errorMessage, response.status); | ||
handleError(response, context); | ||
} | ||
@@ -179,0 +187,0 @@ |
@@ -1,2 +0,2 @@ | ||
/** @license Frontegg v3.0.111 | ||
/** @license Frontegg v3.0.112 | ||
* | ||
@@ -3,0 +3,0 @@ * This source code is licensed under the MIT license found in the |
@@ -152,2 +152,30 @@ "use strict"; | ||
const handleError = async (response, context) => { | ||
var _errorMessage, _context$logLevel, _context$logLevel2; | ||
if (response.status === 413) { | ||
throw new _error.FronteggApiError('Error request is too large', response.status); | ||
} | ||
let errorMessage; | ||
try { | ||
errorMessage = await response.text(); | ||
errorMessage = JSON.parse(errorMessage); | ||
} catch (e) { | ||
errorMessage = undefined; | ||
} | ||
const contentType = response.headers.get("content-type"); | ||
if ((_errorMessage = errorMessage) != null && _errorMessage.errors) { | ||
errorMessage = errorMessage.errors.join(', '); | ||
} else if (typeof errorMessage !== 'string' || !(contentType != null && contentType.includes("application/json"))) { | ||
errorMessage = `Error ${response.status} - ${response.statusText}`; | ||
} | ||
if (response.status >= 400 && response.status < 500 && ['warn'].includes((_context$logLevel = context.logLevel) != null ? _context$logLevel : '')) console.warn(errorMessage);else if (response.status === 500 && ['warn', 'error'].includes((_context$logLevel2 = context.logLevel) != null ? _context$logLevel2 : '')) console.error(errorMessage); | ||
throw new _error.FronteggApiError(errorMessage, response.status); | ||
}; | ||
const sendRequest = async opts => { | ||
@@ -173,23 +201,3 @@ var _opts$method, _ref, _opts$credentials; | ||
if (!response.ok) { | ||
var _context$logLevel, _context$logLevel2; | ||
if (response.status === 413) { | ||
throw new _error.FronteggApiError('Error request is too large', response.status); | ||
} | ||
let errorMessage; | ||
try { | ||
errorMessage = await response.text(); | ||
errorMessage = JSON.parse(errorMessage); | ||
} catch (e) {} | ||
if (errorMessage.errors) { | ||
errorMessage = errorMessage.errors.join(', '); | ||
} else if (typeof errorMessage !== 'string') { | ||
errorMessage = `Error ${response.status} - ${response.statusText}`; | ||
} | ||
if (response.status >= 400 && response.status < 500 && ['warn'].includes((_context$logLevel = context.logLevel) != null ? _context$logLevel : '')) console.warn(errorMessage);else if (response.status === 500 && ['warn', 'error'].includes((_context$logLevel2 = context.logLevel) != null ? _context$logLevel2 : '')) console.error(errorMessage); | ||
throw new _error.FronteggApiError(errorMessage, response.status); | ||
handleError(response, context); | ||
} | ||
@@ -196,0 +204,0 @@ |
@@ -1,2 +0,2 @@ | ||
/** @license Frontegg v3.0.111 | ||
/** @license Frontegg v3.0.112 | ||
* | ||
@@ -3,0 +3,0 @@ * This source code is licensed under the MIT license found in the |
{ | ||
"name": "@frontegg/rest-api", | ||
"version": "3.0.111", | ||
"version": "3.0.112", | ||
"main": "./node/index.js", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
335043
9354