@sap-ux/axios-extension 1.11.4 → 1.11.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/abap/lrep-service.js +18 -11
- package/dist/abap/message.d.ts +22 -0
- package/dist/abap/message.js +47 -1
- package/dist/abap/ui5-abap-repository-service.d.ts +1 -20
- package/dist/abap/ui5-abap-repository-service.js +3 -44
- package/dist/auth/reentrance-ticket/index.js +6 -5
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/package.json +2 -2
|
@@ -14,6 +14,7 @@ const axios_1 = require("axios");
|
|
|
14
14
|
const logger_1 = require("@sap-ux/logger");
|
|
15
15
|
const fs_1 = require("fs");
|
|
16
16
|
const odata_request_error_1 = require("../base/odata-request-error");
|
|
17
|
+
const message_1 = require("./message");
|
|
17
18
|
/**
|
|
18
19
|
* Returns the namespace as string.
|
|
19
20
|
*
|
|
@@ -134,17 +135,23 @@ class LayeredRepositoryService extends axios_1.Axios {
|
|
|
134
135
|
if (params['package'].toUpperCase() !== '$TMP') {
|
|
135
136
|
params['changelist'] = config.transport;
|
|
136
137
|
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
138
|
+
try {
|
|
139
|
+
const response = yield this.request({
|
|
140
|
+
method: checkResponse.status === 200 ? 'PUT' : 'POST',
|
|
141
|
+
url: DTA_PATH_SUFFIX,
|
|
142
|
+
data,
|
|
143
|
+
params,
|
|
144
|
+
headers: {
|
|
145
|
+
'Content-Type': 'application/octet-stream'
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
this.tryLogResponse(response, 'Deployment successful.');
|
|
149
|
+
return response;
|
|
150
|
+
}
|
|
151
|
+
catch (error) {
|
|
152
|
+
(0, message_1.logError)({ error, log: this.log });
|
|
153
|
+
throw error;
|
|
154
|
+
}
|
|
148
155
|
});
|
|
149
156
|
}
|
|
150
157
|
/**
|
package/dist/abap/message.d.ts
CHANGED
|
@@ -73,4 +73,26 @@ export declare function prettyPrintError({ error, log, host, isDest }: {
|
|
|
73
73
|
* @returns user friendly string
|
|
74
74
|
*/
|
|
75
75
|
export declare const prettyPrintTimeInMs: (ms: number) => string;
|
|
76
|
+
/**
|
|
77
|
+
* Log errors more user friendly if it is a standard Gateway error.
|
|
78
|
+
*
|
|
79
|
+
* @param e error thrown by Axios after sending a request
|
|
80
|
+
* @param e.error error from Axios
|
|
81
|
+
* @param e.log logger to be used
|
|
82
|
+
* @param e.host optional hostname
|
|
83
|
+
* @param e.isDest optional destination flag
|
|
84
|
+
*/
|
|
85
|
+
export declare function logError({ error, host, log, isDest }: {
|
|
86
|
+
error: Error;
|
|
87
|
+
host?: string;
|
|
88
|
+
log: Logger;
|
|
89
|
+
isDest?: boolean;
|
|
90
|
+
}): void;
|
|
91
|
+
/**
|
|
92
|
+
* Get ErrorMessage object from response contain an error as a string.
|
|
93
|
+
*
|
|
94
|
+
* @param data string value
|
|
95
|
+
* @returns undefined if an error object is not found or populated ErrorMessage object
|
|
96
|
+
*/
|
|
97
|
+
export declare function getErrorMessageFromString(data: unknown): ErrorMessage | undefined;
|
|
76
98
|
//# sourceMappingURL=message.d.ts.map
|
package/dist/abap/message.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.prettyPrintTimeInMs = exports.prettyPrintError = exports.prettyPrintMessage = void 0;
|
|
3
|
+
exports.getErrorMessageFromString = exports.logError = exports.prettyPrintTimeInMs = exports.prettyPrintError = exports.prettyPrintMessage = void 0;
|
|
4
4
|
const url_1 = require("url");
|
|
5
|
+
const axios_1 = require("axios");
|
|
5
6
|
/**
|
|
6
7
|
*
|
|
7
8
|
* @param severity
|
|
@@ -121,4 +122,49 @@ const prettyPrintTimeInMs = (ms) => {
|
|
|
121
122
|
}
|
|
122
123
|
};
|
|
123
124
|
exports.prettyPrintTimeInMs = prettyPrintTimeInMs;
|
|
125
|
+
/**
|
|
126
|
+
* Log errors more user friendly if it is a standard Gateway error.
|
|
127
|
+
*
|
|
128
|
+
* @param e error thrown by Axios after sending a request
|
|
129
|
+
* @param e.error error from Axios
|
|
130
|
+
* @param e.log logger to be used
|
|
131
|
+
* @param e.host optional hostname
|
|
132
|
+
* @param e.isDest optional destination flag
|
|
133
|
+
*/
|
|
134
|
+
function logError({ error, host, log, isDest }) {
|
|
135
|
+
var _a, _b;
|
|
136
|
+
log.error(error.message);
|
|
137
|
+
if ((0, axios_1.isAxiosError)(error) && ((_a = error.response) === null || _a === void 0 ? void 0 : _a.data)) {
|
|
138
|
+
const errorMessage = getErrorMessageFromString((_b = error.response) === null || _b === void 0 ? void 0 : _b.data);
|
|
139
|
+
if (errorMessage) {
|
|
140
|
+
prettyPrintError({ error: errorMessage, log: log, host: host, isDest: isDest });
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
log.error(error.response.data.toString());
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
exports.logError = logError;
|
|
148
|
+
/**
|
|
149
|
+
* Get ErrorMessage object from response contain an error as a string.
|
|
150
|
+
*
|
|
151
|
+
* @param data string value
|
|
152
|
+
* @returns undefined if an error object is not found or populated ErrorMessage object
|
|
153
|
+
*/
|
|
154
|
+
function getErrorMessageFromString(data) {
|
|
155
|
+
let error;
|
|
156
|
+
if (typeof data === 'string') {
|
|
157
|
+
try {
|
|
158
|
+
const errorMsg = JSON.parse(data);
|
|
159
|
+
if (errorMsg.error) {
|
|
160
|
+
error = errorMsg.error;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
catch (_a) {
|
|
164
|
+
// Not much we can do!
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
return error;
|
|
168
|
+
}
|
|
169
|
+
exports.getErrorMessageFromString = getErrorMessageFromString;
|
|
124
170
|
//# sourceMappingURL=message.js.map
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import type
|
|
3
|
-
import type { ErrorMessage } from './message';
|
|
2
|
+
import { type AxiosResponse, type AxiosRequestConfig } from 'axios';
|
|
4
3
|
import { ODataService } from '../base/odata-service';
|
|
5
4
|
/**
|
|
6
5
|
* Required configuration a transportable object.
|
|
@@ -161,23 +160,5 @@ export declare class Ui5AbapRepositoryService extends ODataService {
|
|
|
161
160
|
* @returns the Axios response object for further processing
|
|
162
161
|
*/
|
|
163
162
|
protected deleteRepoRequest(appName: string, config: AxiosRequestConfig, tryCount?: number): Promise<AxiosResponse>;
|
|
164
|
-
/**
|
|
165
|
-
* Log errors more user friendly if it is a standard Gateway error.
|
|
166
|
-
*
|
|
167
|
-
* @param e error thrown by Axios after sending a request
|
|
168
|
-
* @param e.error error from Axios
|
|
169
|
-
* @param e.host hostname
|
|
170
|
-
*/
|
|
171
|
-
protected logError({ error, host }: {
|
|
172
|
-
error: Error;
|
|
173
|
-
host?: string;
|
|
174
|
-
}): void;
|
|
175
|
-
/**
|
|
176
|
-
* Get ErrorMessage object from response contain an error as a string.
|
|
177
|
-
*
|
|
178
|
-
* @param data string value
|
|
179
|
-
* @returns undefined if an error object is not found or populated ErrorMessage object
|
|
180
|
-
*/
|
|
181
|
-
protected getErrorMessageFromString(data: unknown): ErrorMessage | undefined;
|
|
182
163
|
}
|
|
183
164
|
//# sourceMappingURL=ui5-abap-repository-service.d.ts.map
|
|
@@ -144,7 +144,7 @@ class Ui5AbapRepositoryService extends odata_service_1.ODataService {
|
|
|
144
144
|
else {
|
|
145
145
|
// Test mode returns a HTTP response code of 403 so we dont want to show all error messages
|
|
146
146
|
(0, message_1.prettyPrintError)({
|
|
147
|
-
error:
|
|
147
|
+
error: (0, message_1.getErrorMessageFromString)(response === null || response === void 0 ? void 0 : response.data),
|
|
148
148
|
log: this.log,
|
|
149
149
|
host: frontendUrl,
|
|
150
150
|
isDest: this.isDest
|
|
@@ -153,7 +153,7 @@ class Ui5AbapRepositoryService extends odata_service_1.ODataService {
|
|
|
153
153
|
return response;
|
|
154
154
|
}
|
|
155
155
|
catch (error) {
|
|
156
|
-
|
|
156
|
+
(0, message_1.logError)({ error, host: frontendUrl, log: this.log, isDest: this.isDest });
|
|
157
157
|
throw error;
|
|
158
158
|
}
|
|
159
159
|
});
|
|
@@ -191,7 +191,7 @@ class Ui5AbapRepositoryService extends odata_service_1.ODataService {
|
|
|
191
191
|
}
|
|
192
192
|
}
|
|
193
193
|
catch (error) {
|
|
194
|
-
|
|
194
|
+
(0, message_1.logError)({ error, host, log: this.log });
|
|
195
195
|
throw error;
|
|
196
196
|
}
|
|
197
197
|
});
|
|
@@ -359,47 +359,6 @@ class Ui5AbapRepositoryService extends odata_service_1.ODataService {
|
|
|
359
359
|
}
|
|
360
360
|
});
|
|
361
361
|
}
|
|
362
|
-
/**
|
|
363
|
-
* Log errors more user friendly if it is a standard Gateway error.
|
|
364
|
-
*
|
|
365
|
-
* @param e error thrown by Axios after sending a request
|
|
366
|
-
* @param e.error error from Axios
|
|
367
|
-
* @param e.host hostname
|
|
368
|
-
*/
|
|
369
|
-
logError({ error, host }) {
|
|
370
|
-
var _a, _b;
|
|
371
|
-
this.log.error(error.message);
|
|
372
|
-
if ((0, odata_request_error_1.isAxiosError)(error) && ((_a = error.response) === null || _a === void 0 ? void 0 : _a.data)) {
|
|
373
|
-
const errorMessage = this.getErrorMessageFromString((_b = error.response) === null || _b === void 0 ? void 0 : _b.data);
|
|
374
|
-
if (errorMessage) {
|
|
375
|
-
(0, message_1.prettyPrintError)({ error: errorMessage, host, log: this.log, isDest: this.isDest });
|
|
376
|
-
}
|
|
377
|
-
else {
|
|
378
|
-
this.log.error(error.response.data.toString());
|
|
379
|
-
}
|
|
380
|
-
}
|
|
381
|
-
}
|
|
382
|
-
/**
|
|
383
|
-
* Get ErrorMessage object from response contain an error as a string.
|
|
384
|
-
*
|
|
385
|
-
* @param data string value
|
|
386
|
-
* @returns undefined if an error object is not found or populated ErrorMessage object
|
|
387
|
-
*/
|
|
388
|
-
getErrorMessageFromString(data) {
|
|
389
|
-
let error;
|
|
390
|
-
if (typeof data === 'string') {
|
|
391
|
-
try {
|
|
392
|
-
const errorMsg = JSON.parse(data);
|
|
393
|
-
if (errorMsg.error) {
|
|
394
|
-
error = errorMsg.error;
|
|
395
|
-
}
|
|
396
|
-
}
|
|
397
|
-
catch (_a) {
|
|
398
|
-
// Not much we can do!
|
|
399
|
-
}
|
|
400
|
-
}
|
|
401
|
-
return error;
|
|
402
|
-
}
|
|
403
362
|
}
|
|
404
363
|
exports.Ui5AbapRepositoryService = Ui5AbapRepositoryService;
|
|
405
364
|
Ui5AbapRepositoryService.PATH = '/sap/opu/odata/UI5/ABAP_REPOSITORY_SRV';
|
|
@@ -16,9 +16,9 @@ const abap_system_1 = require("./abap-system");
|
|
|
16
16
|
const redirect_1 = require("./redirect");
|
|
17
17
|
/**
|
|
18
18
|
* DO NOT USE THIS SERVICE ENDPOINT DIRECTLY.
|
|
19
|
-
*
|
|
19
|
+
* It might be removed in the future without notice.
|
|
20
20
|
*/
|
|
21
|
-
const ADT_REENTRANCE_ENDPOINT = '/sap/bc/
|
|
21
|
+
const ADT_REENTRANCE_ENDPOINT = '/sap/bc/sec/reentrance';
|
|
22
22
|
/**
|
|
23
23
|
* Get the reentrance ticket from the backend.
|
|
24
24
|
*
|
|
@@ -30,15 +30,16 @@ const ADT_REENTRANCE_ENDPOINT = '/sap/bc/adt/core/http/reentranceticket';
|
|
|
30
30
|
function getReentranceTicket({ backendUrl, logger, timeout = connection_1.defaultTimeout }) {
|
|
31
31
|
return __awaiter(this, void 0, void 0, function* () {
|
|
32
32
|
return new Promise((resolve, reject) => {
|
|
33
|
-
var _a;
|
|
33
|
+
var _a, _b;
|
|
34
34
|
const backend = new abap_system_1.ABAPSystem(backendUrl);
|
|
35
35
|
// Start local server to listen to redirect call, with timeout
|
|
36
36
|
const { server, redirectUrl } = (0, redirect_1.setupRedirectHandling)({ resolve, reject, timeout, backend, logger });
|
|
37
37
|
server.listen();
|
|
38
38
|
const redirectPort = server.address().port;
|
|
39
39
|
// Open browser to handle SAML flow and return the reentrance ticket
|
|
40
|
-
const
|
|
41
|
-
|
|
40
|
+
const scenario = (_a = process.env.SCENARIO) !== null && _a !== void 0 ? _a : 'FIORI';
|
|
41
|
+
const url = `${backend.uiHostname()}${ADT_REENTRANCE_ENDPOINT}?scenario=${scenario}&redirect-url=${redirectUrl(redirectPort)}`;
|
|
42
|
+
(_b = open(url)) === null || _b === void 0 ? void 0 : _b.catch((error) => logger.error(error));
|
|
42
43
|
});
|
|
43
44
|
});
|
|
44
45
|
}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -22,4 +22,5 @@ __exportStar(require("./base/service-provider"), exports);
|
|
|
22
22
|
__exportStar(require("./abap"), exports);
|
|
23
23
|
__exportStar(require("./factory"), exports);
|
|
24
24
|
__exportStar(require("./auth"), exports);
|
|
25
|
+
__exportStar(require("./abap/message"), exports);
|
|
25
26
|
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sap-ux/axios-extension",
|
|
3
|
-
"version": "1.11.
|
|
3
|
+
"version": "1.11.6",
|
|
4
4
|
"description": "Extension of the Axios module adding convenience methods to interact with SAP systems especially with OData services.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"@types/lodash": "4.14.202",
|
|
30
30
|
"nock": "13.4.0",
|
|
31
31
|
"supertest": "6.3.3",
|
|
32
|
-
"@sap-ux/project-access": "1.19.
|
|
32
|
+
"@sap-ux/project-access": "1.19.6"
|
|
33
33
|
},
|
|
34
34
|
"files": [
|
|
35
35
|
"dist",
|