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

@sap-ux/axios-extension

Package Overview
Dependencies
Maintainers
3
Versions
113
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sap-ux/axios-extension - npm Package Compare versions

Comparing version 1.11.5 to 1.11.6

29

dist/abap/lrep-service.js

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

const odata_request_error_1 = require("../base/odata-request-error");
const message_1 = require("./message");
/**

@@ -138,13 +139,19 @@ * Returns the namespace as string.

}
const response = yield this.request({
method: checkResponse.status === 200 ? 'PUT' : 'POST',
url: DTA_PATH_SUFFIX,
data,
params,
headers: {
'Content-Type': 'application/octet-stream'
}
});
this.tryLogResponse(response, 'Deployment successful.');
return response;
try {
const response = yield this.request({
method: checkResponse.status === 200 ? 'PUT' : 'POST',
url: DTA_PATH_SUFFIX,
data,
params,
headers: {
'Content-Type': 'application/octet-stream'
}
});
this.tryLogResponse(response, 'Deployment successful.');
return response;
}
catch (error) {
(0, message_1.logError)({ error, log: this.log });
throw error;
}
});

@@ -151,0 +158,0 @@ }

@@ -76,2 +76,24 @@ import type { Logger } from '@sap-ux/logger';

export declare const prettyPrintTimeInMs: (ms: number) => string;
/**
* Log errors more user friendly if it is a standard Gateway error.
*
* @param e error thrown by Axios after sending a request
* @param e.error error from Axios
* @param e.log logger to be used
* @param e.host optional hostname
* @param e.isDest optional destination flag
*/
export declare function logError({ error, host, log, isDest }: {
error: Error;
host?: string;
log: Logger;
isDest?: boolean;
}): void;
/**
* Get ErrorMessage object from response contain an error as a string.
*
* @param data string value
* @returns undefined if an error object is not found or populated ErrorMessage object
*/
export declare function getErrorMessageFromString(data: unknown): ErrorMessage | undefined;
//# sourceMappingURL=message.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.prettyPrintTimeInMs = exports.prettyPrintError = exports.prettyPrintMessage = void 0;
exports.getErrorMessageFromString = exports.logError = exports.prettyPrintTimeInMs = exports.prettyPrintError = exports.prettyPrintMessage = void 0;
const url_1 = require("url");
const axios_1 = require("axios");
/**

@@ -124,2 +125,47 @@ *

exports.prettyPrintTimeInMs = prettyPrintTimeInMs;
/**
* Log errors more user friendly if it is a standard Gateway error.
*
* @param e error thrown by Axios after sending a request
* @param e.error error from Axios
* @param e.log logger to be used
* @param e.host optional hostname
* @param e.isDest optional destination flag
*/
function logError({ error, host, log, isDest }) {
var _a, _b;
log.error(error.message);
if ((0, axios_1.isAxiosError)(error) && ((_a = error.response) === null || _a === void 0 ? void 0 : _a.data)) {
const errorMessage = getErrorMessageFromString((_b = error.response) === null || _b === void 0 ? void 0 : _b.data);
if (errorMessage) {
prettyPrintError({ error: errorMessage, log: log, host: host, isDest: isDest });
}
else {
log.error(error.response.data.toString());
}
}
}
exports.logError = logError;
/**
* Get ErrorMessage object from response contain an error as a string.
*
* @param data string value
* @returns undefined if an error object is not found or populated ErrorMessage object
*/
function getErrorMessageFromString(data) {
let error;
if (typeof data === 'string') {
try {
const errorMsg = JSON.parse(data);
if (errorMsg.error) {
error = errorMsg.error;
}
}
catch (_a) {
// Not much we can do!
}
}
return error;
}
exports.getErrorMessageFromString = getErrorMessageFromString;
//# sourceMappingURL=message.js.map
/// <reference types="node" />
import type { AxiosResponse, AxiosRequestConfig } from 'axios';
import type { ErrorMessage } from './message';
import { type AxiosResponse, type AxiosRequestConfig } from 'axios';
import { ODataService } from '../base/odata-service';

@@ -164,21 +163,3 @@ /**

protected deleteRepoRequest(appName: string, config: AxiosRequestConfig, tryCount?: number): Promise<AxiosResponse>;
/**
* Log errors more user friendly if it is a standard Gateway error.
*
* @param e error thrown by Axios after sending a request
* @param e.error error from Axios
* @param e.host hostname
*/
protected logError({ error, host }: {
error: Error;
host?: string;
}): void;
/**
* Get ErrorMessage object from response contain an error as a string.
*
* @param data string value
* @returns undefined if an error object is not found or populated ErrorMessage object
*/
protected getErrorMessageFromString(data: unknown): ErrorMessage | undefined;
}
//# sourceMappingURL=ui5-abap-repository-service.d.ts.map

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

(0, message_1.prettyPrintError)({
error: this.getErrorMessageFromString(response === null || response === void 0 ? void 0 : response.data),
error: (0, message_1.getErrorMessageFromString)(response === null || response === void 0 ? void 0 : response.data),
log: this.log,

@@ -157,3 +157,3 @@ host: frontendUrl,

catch (error) {
this.logError({ error, host: frontendUrl });
(0, message_1.logError)({ error, host: frontendUrl, log: this.log, isDest: this.isDest });
throw error;

@@ -196,3 +196,3 @@ }

catch (error) {
this.logError({ error, host });
(0, message_1.logError)({ error, host, log: this.log });
throw error;

@@ -365,43 +365,2 @@ }

}
/**
* Log errors more user friendly if it is a standard Gateway error.
*
* @param e error thrown by Axios after sending a request
* @param e.error error from Axios
* @param e.host hostname
*/
logError({ error, host }) {
var _a, _b;
this.log.error(error.message);
if ((0, odata_request_error_1.isAxiosError)(error) && ((_a = error.response) === null || _a === void 0 ? void 0 : _a.data)) {
const errorMessage = this.getErrorMessageFromString((_b = error.response) === null || _b === void 0 ? void 0 : _b.data);
if (errorMessage) {
(0, message_1.prettyPrintError)({ error: errorMessage, host, log: this.log, isDest: this.isDest });
}
else {
this.log.error(error.response.data.toString());
}
}
}
/**
* Get ErrorMessage object from response contain an error as a string.
*
* @param data string value
* @returns undefined if an error object is not found or populated ErrorMessage object
*/
getErrorMessageFromString(data) {
let error;
if (typeof data === 'string') {
try {
const errorMsg = JSON.parse(data);
if (errorMsg.error) {
error = errorMsg.error;
}
}
catch (_a) {
// Not much we can do!
}
}
return error;
}
}

@@ -408,0 +367,0 @@ exports.Ui5AbapRepositoryService = Ui5AbapRepositoryService;

@@ -8,3 +8,4 @@ import type { AxiosError, AxiosRequestConfig } from 'axios';

export * from './auth';
export * from './abap/message';
export { AxiosError, AxiosRequestConfig, isAxiosError };
//# sourceMappingURL=index.d.ts.map

@@ -25,2 +25,3 @@ "use strict";

__exportStar(require("./auth"), exports);
__exportStar(require("./abap/message"), exports);
//# sourceMappingURL=index.js.map
{
"name": "@sap-ux/axios-extension",
"version": "1.11.5",
"version": "1.11.6",
"description": "Extension of the Axios module adding convenience methods to interact with SAP systems especially with OData services.",

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

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