@sap/wing-service-explorer
Advanced tools
Comparing version 1.7.3 to 1.8.0
@@ -27,2 +27,3 @@ import { IChildLogger } from "@vscode-logging/types"; | ||
getServices(connectionDetails: ConnectionDetails): Promise<any>; | ||
private convertProxy; | ||
protected sendRequest(url: string, urlPath: string, proxy: string, json: boolean, headers?: any): Promise<any>; | ||
@@ -29,0 +30,0 @@ protected filterDestinationByWebIDEUsage(listOfDestinationsObj: any, webIDEUsage: string): any; |
@@ -14,3 +14,2 @@ "use strict"; | ||
const _ = require("lodash"); | ||
const request = require("request"); | ||
const vkbeautify = require("vkbeautify"); | ||
@@ -20,2 +19,3 @@ const messages_1 = require("./i18n/messages"); | ||
const defaultLogger_1 = require("./defaultLogger"); | ||
const axios_1 = require("axios"); | ||
class ServiceExplorer { | ||
@@ -74,28 +74,35 @@ constructor(h2oURL, proxy, logger) { | ||
} | ||
convertProxy(proxy) { | ||
if (!proxy) { | ||
return undefined; | ||
} | ||
const proxyUrl = new URL(proxy); | ||
return { | ||
port: Number(proxyUrl.port), | ||
host: proxyUrl.hostname, | ||
}; | ||
} | ||
sendRequest(url, urlPath, proxy, json, headers) { | ||
var _a; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const prop = { | ||
json, | ||
strictSSL: false, | ||
proxy, | ||
const config = { | ||
url: url.concat(urlPath), | ||
method: "GET", | ||
proxy: this.convertProxy(proxy), | ||
headers, | ||
}; | ||
this.serviceExplorerlogger.debug(this.sendRequest.name, { url: url, urlPath: urlPath }); | ||
return new Promise((resolve, reject) => { | ||
request.get(url.concat(urlPath), prop, (err, resp, body) => { | ||
if (err) { | ||
this.serviceExplorerlogger.error(this.sendRequest.name, { error: err }); | ||
reject(err); | ||
} | ||
else { | ||
if (resp.statusCode === ServiceExplorer.STATUS_NOT_AUTH) { | ||
reject(ServiceExplorer.ERROR_NEED_AUTH); | ||
} | ||
else { | ||
this.serviceExplorerlogger.trace(this.sendRequest.name, { responseBody: body }); | ||
resolve(body); | ||
} | ||
} | ||
}); | ||
}); | ||
this.serviceExplorerlogger.debug(this.sendRequest.name, { url, urlPath }); | ||
try { | ||
const response = yield axios_1.default.request(config); | ||
const { data } = response; | ||
this.serviceExplorerlogger.trace(this.sendRequest.name, { responseBody: data }); | ||
return data; | ||
} | ||
catch (err) { | ||
if (((_a = err.response) === null || _a === void 0 ? void 0 : _a.status) === ServiceExplorer.STATUS_NOT_AUTH) { | ||
throw new Error(ServiceExplorer.ERROR_NEED_AUTH); | ||
} | ||
this.serviceExplorerlogger.error(this.sendRequest.name, { err }); | ||
throw err; | ||
} | ||
}); | ||
@@ -110,38 +117,39 @@ } | ||
sendMetaDataRequest(serviceMetadataUrl, headers) { | ||
this.serviceExplorerlogger.debug(this.sendMetaDataRequest.name, { url: serviceMetadataUrl }); | ||
return new Promise((resolve, reject) => { | ||
request.get(serviceMetadataUrl, { strictSSL: false, proxy: this.proxy, headers }, (err, resp, body) => { | ||
if (err) { | ||
this.serviceExplorerlogger.error(this.sendMetaDataRequest.name, { error: err }); | ||
reject(err); | ||
var _a; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
this.serviceExplorerlogger.debug(this.sendMetaDataRequest.name, { url: serviceMetadataUrl }); | ||
try { | ||
const config = { | ||
url: serviceMetadataUrl, | ||
method: "GET", | ||
proxy: this.convertProxy(this.proxy), | ||
headers, | ||
}; | ||
const response = yield axios_1.default.request(config); | ||
const { data } = response; | ||
const beautifiedBody = vkbeautify.xml(data); | ||
this.serviceExplorerlogger.trace(this.sendMetaDataRequest.name, { | ||
receivedMetaDataBody: beautifiedBody, | ||
}); | ||
return beautifiedBody; | ||
} | ||
catch (err) { | ||
const status = (_a = err.response) === null || _a === void 0 ? void 0 : _a.status; | ||
if (status === ServiceExplorer.STATUS_NOT_AUTH) { | ||
const errorMessage = ServiceExplorer.ERROR_NEED_AUTH; | ||
this.serviceExplorerlogger.error(this.sendMetaDataRequest.name, { | ||
receivedStatusCode: status, | ||
error: "ERROR_NEED_AUTH", | ||
returnedErrorMessage: errorMessage, | ||
}); | ||
throw new Error(errorMessage); | ||
} | ||
else { | ||
if (resp.statusCode === ServiceExplorer.STATUS_NOT_AUTH) { | ||
const errorMessage = ServiceExplorer.ERROR_NEED_AUTH; | ||
this.serviceExplorerlogger.error(this.sendMetaDataRequest.name, { | ||
receivedStatusCode: resp.statusCode, | ||
error: "ERROR_NEED_AUTH", | ||
returnedErrorMessage: errorMessage, | ||
}); | ||
reject(errorMessage); | ||
} | ||
else if (resp.statusCode !== ServiceExplorer.STATUS_SUCCESS) { | ||
const errorMessage = messages_1.messages.ERROR_RETRIEVE_METADATA; | ||
this.serviceExplorerlogger.debug(this.sendMetaDataRequest.name, { | ||
receivedStatusCode: resp.statusCode, | ||
error: "ERROR_RETRIEVE_METADATA", | ||
returnedErrorMessage: errorMessage, | ||
receivedMetaDataBody: body, | ||
}); | ||
reject(errorMessage); | ||
} | ||
else { | ||
const beautifiedBody = vkbeautify.xml(body); | ||
this.serviceExplorerlogger.trace(this.sendMetaDataRequest.name, { | ||
receivedMetaDataBody: beautifiedBody, | ||
}); | ||
resolve(beautifiedBody); | ||
} | ||
} | ||
}); | ||
const errorMessage = messages_1.messages.ERROR_RETRIEVE_METADATA; | ||
this.serviceExplorerlogger.debug(this.sendMetaDataRequest.name, { | ||
receivedStatusCode: status, | ||
error: err, | ||
returnedErrorMessage: errorMessage, | ||
}); | ||
throw new Error(errorMessage); | ||
} | ||
}); | ||
@@ -148,0 +156,0 @@ } |
{ | ||
"name": "@sap/wing-service-explorer", | ||
"version": "1.7.3", | ||
"version": "1.8.0", | ||
"description": "Provide the ability to explore SAP services", | ||
@@ -26,5 +26,5 @@ "license": "See LICENSE.txt", | ||
"lodash": "4.17.21", | ||
"request": "2.88.0", | ||
"axios": "^0.21.1", | ||
"vkbeautify": "0.99.3", | ||
"xml2js": "0.4.19", | ||
"xml2js": "0.5.0", | ||
"fs-extra": "7.0.1", | ||
@@ -43,3 +43,2 @@ "@vscode-logging/types": "~0.1.1", | ||
"@types/node": "^12.0.8", | ||
"@types/request": "2.48.1", | ||
"@types/sinon": "^7.0.13", | ||
@@ -64,3 +63,4 @@ "@types/vkbeautify": "^0.99.2", | ||
"typescript": "^3.9.7", | ||
"ts-node": "^8.3.0" | ||
"ts-node": "^8.3.0", | ||
"axios-mock-adapter": "1.21.2" | ||
}, | ||
@@ -67,0 +67,0 @@ "engines": { |
@@ -64,2 +64,1 @@ # @sap/wing-service-explorer | ||
Returns a list of destinations which contain an additional property named **XFSystemName**. | ||
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6036
367367
64
+ Addedaxios@^0.21.1
+ Addedaxios@0.21.4(transitive)
+ Addedfollow-redirects@1.15.9(transitive)
+ Addedxml2js@0.5.0(transitive)
+ Addedxmlbuilder@11.0.1(transitive)
- Removedrequest@2.88.0
- Removedajv@6.12.6(transitive)
- Removedasn1@0.2.6(transitive)
- Removedassert-plus@1.0.0(transitive)
- Removedasynckit@0.4.0(transitive)
- Removedaws-sign2@0.7.0(transitive)
- Removedaws4@1.13.2(transitive)
- Removedbcrypt-pbkdf@1.0.2(transitive)
- Removedcaseless@0.12.0(transitive)
- Removedcombined-stream@1.0.8(transitive)
- Removedcore-util-is@1.0.2(transitive)
- Removeddashdash@1.14.1(transitive)
- Removeddelayed-stream@1.0.0(transitive)
- Removedecc-jsbn@0.1.2(transitive)
- Removedextend@3.0.2(transitive)
- Removedextsprintf@1.3.0(transitive)
- Removedfast-deep-equal@3.1.3(transitive)
- Removedfast-json-stable-stringify@2.1.0(transitive)
- Removedforever-agent@0.6.1(transitive)
- Removedform-data@2.3.3(transitive)
- Removedgetpass@0.1.7(transitive)
- Removedhar-schema@2.0.0(transitive)
- Removedhar-validator@5.1.5(transitive)
- Removedhttp-signature@1.2.0(transitive)
- Removedis-typedarray@1.0.0(transitive)
- Removedisstream@0.1.2(transitive)
- Removedjsbn@0.1.1(transitive)
- Removedjson-schema@0.4.0(transitive)
- Removedjson-schema-traverse@0.4.1(transitive)
- Removedjson-stringify-safe@5.0.1(transitive)
- Removedjsprim@1.4.2(transitive)
- Removedmime-db@1.52.0(transitive)
- Removedmime-types@2.1.35(transitive)
- Removedoauth-sign@0.9.0(transitive)
- Removedperformance-now@2.1.0(transitive)
- Removedpsl@1.15.0(transitive)
- Removedpunycode@1.4.12.3.1(transitive)
- Removedqs@6.5.3(transitive)
- Removedrequest@2.88.0(transitive)
- Removedsafe-buffer@5.2.1(transitive)
- Removedsafer-buffer@2.1.2(transitive)
- Removedsshpk@1.18.0(transitive)
- Removedtough-cookie@2.4.3(transitive)
- Removedtunnel-agent@0.6.0(transitive)
- Removedtweetnacl@0.14.5(transitive)
- Removeduri-js@4.4.1(transitive)
- Removeduuid@3.4.0(transitive)
- Removedverror@1.10.0(transitive)
- Removedxml2js@0.4.19(transitive)
- Removedxmlbuilder@9.0.7(transitive)
Updatedxml2js@0.5.0