@sap-ux/axios-extension 1.0.2 → 1.1.0
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/README.adoc +4 -4
- package/dist/abap/abap-service-provider.d.ts +17 -1
- package/dist/abap/abap-service-provider.js +21 -5
- package/dist/abap/app-index-service.d.ts +1 -1
- package/dist/abap/app-index-service.js +1 -1
- package/dist/abap/message.js +25 -1
- package/dist/abap/ui5-abap-repository-service.d.ts +13 -10
- package/dist/abap/ui5-abap-repository-service.js +31 -15
- package/dist/auth/connection.js +8 -5
- package/dist/base/service-provider.d.ts +7 -1
- package/dist/base/service-provider.js +10 -2
- package/dist/factory.js +3 -1
- package/package.json +1 -1
package/README.adoc
CHANGED
|
@@ -27,11 +27,11 @@ The generic OData service simplifies the access to the service metadata as well
|
|
|
27
27
|
#### Catalog Service
|
|
28
28
|
Simplified consumption of the SAP catalog service useful for fetching annotations.
|
|
29
29
|
|
|
30
|
-
#### ABAP UI5
|
|
30
|
+
#### ABAP UI5 Repository Service
|
|
31
31
|
Allows deployment of applications to the UI5 ABAP Repository as well as checking deployed applications.
|
|
32
32
|
|
|
33
33
|
#### App Index Service
|
|
34
|
-
A class
|
|
34
|
+
A class representing the app index service allowing to search applications deployed on an ABAP system.
|
|
35
35
|
|
|
36
36
|
#### Layered Repository Service
|
|
37
37
|
Allows deployment of adaptation projects.
|
|
@@ -64,8 +64,8 @@ const provider = createForAbap({
|
|
|
64
64
|
baseURL: 'https://sap.example',
|
|
65
65
|
params: { 'sap-client': client }
|
|
66
66
|
});
|
|
67
|
-
const
|
|
68
|
-
const newTrNumber = await
|
|
67
|
+
const transportRequestService = provider.getAdtService<TransportRequestService>(TransportRequestService);
|
|
68
|
+
const newTrNumber = await transportRequestService.createTransportRequest({
|
|
69
69
|
packageName: 'Z_PACKAGE',
|
|
70
70
|
ui5AppName: 'zappname',
|
|
71
71
|
description: 'A new transport request number for deployment'
|
|
@@ -12,6 +12,10 @@ import { AdtService } from './adt-catalog/services';
|
|
|
12
12
|
export declare class AbapServiceProvider extends ServiceProvider {
|
|
13
13
|
s4Cloud: boolean | undefined;
|
|
14
14
|
protected atoSettings: AtoSettings;
|
|
15
|
+
/**
|
|
16
|
+
* Maintain the public facing URL which is required for destination related flows
|
|
17
|
+
*/
|
|
18
|
+
protected _publicUrl: string;
|
|
15
19
|
/**
|
|
16
20
|
* Get the name of the currently logged in user. This is the basic implementation that could be overwritten by subclasses.
|
|
17
21
|
* The function returns a promise because it may be required to fetch the information from the backend.
|
|
@@ -31,6 +35,18 @@ export declare class AbapServiceProvider extends ServiceProvider {
|
|
|
31
35
|
* @returns ABAP Transport Organizer settings
|
|
32
36
|
*/
|
|
33
37
|
getAtoInfo(): Promise<AtoSettings>;
|
|
38
|
+
/**
|
|
39
|
+
* Set the public facing URL, typically used for a destination related flows.
|
|
40
|
+
*
|
|
41
|
+
* @param host
|
|
42
|
+
*/
|
|
43
|
+
set publicUrl(host: string);
|
|
44
|
+
/**
|
|
45
|
+
* Retrieve the public facing URL, default to Axios base URL if not configured.
|
|
46
|
+
*
|
|
47
|
+
* @returns string Axios baseUrl if public URL is not configured by a destination
|
|
48
|
+
*/
|
|
49
|
+
get publicUrl(): string;
|
|
34
50
|
/**
|
|
35
51
|
* Detect if the given configuration points to an S/4HANA Cloud system.
|
|
36
52
|
*
|
|
@@ -74,7 +90,7 @@ export declare class AbapServiceProvider extends ServiceProvider {
|
|
|
74
90
|
*
|
|
75
91
|
* @example
|
|
76
92
|
* ```ts
|
|
77
|
-
* const
|
|
93
|
+
* const transportRequestService = abapServiceProvider.getAdtService<TransportRequestService>(TransportRequestService);
|
|
78
94
|
* ```
|
|
79
95
|
* @param adtServiceSubclass Subclass of class AdtService, type is specified by using AdtService class constructor signature.
|
|
80
96
|
* @returns Subclass type of class AdtService
|
|
@@ -69,6 +69,22 @@ class AbapServiceProvider extends service_provider_1.ServiceProvider {
|
|
|
69
69
|
return this.atoSettings;
|
|
70
70
|
});
|
|
71
71
|
}
|
|
72
|
+
/**
|
|
73
|
+
* Set the public facing URL, typically used for a destination related flows.
|
|
74
|
+
*
|
|
75
|
+
* @param host
|
|
76
|
+
*/
|
|
77
|
+
set publicUrl(host) {
|
|
78
|
+
this._publicUrl = host;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Retrieve the public facing URL, default to Axios base URL if not configured.
|
|
82
|
+
*
|
|
83
|
+
* @returns string Axios baseUrl if public URL is not configured by a destination
|
|
84
|
+
*/
|
|
85
|
+
get publicUrl() {
|
|
86
|
+
return this._publicUrl || this.defaults.baseURL;
|
|
87
|
+
}
|
|
72
88
|
/**
|
|
73
89
|
* Detect if the given configuration points to an S/4HANA Cloud system.
|
|
74
90
|
*
|
|
@@ -101,8 +117,8 @@ class AbapServiceProvider extends service_provider_1.ServiceProvider {
|
|
|
101
117
|
*/
|
|
102
118
|
getAdtCatalogService() {
|
|
103
119
|
if (!this.services[adt_catalog_service_1.AdtCatalogService.ADT_DISCOVERY_SERVICE_PATH]) {
|
|
104
|
-
const
|
|
105
|
-
this.services[adt_catalog_service_1.AdtCatalogService.ADT_DISCOVERY_SERVICE_PATH] =
|
|
120
|
+
const adtCatalogService = this.createService(adt_catalog_service_1.AdtCatalogService.ADT_DISCOVERY_SERVICE_PATH, adt_catalog_service_1.AdtCatalogService);
|
|
121
|
+
this.services[adt_catalog_service_1.AdtCatalogService.ADT_DISCOVERY_SERVICE_PATH] = adtCatalogService;
|
|
106
122
|
}
|
|
107
123
|
return this.services[adt_catalog_service_1.AdtCatalogService.ADT_DISCOVERY_SERVICE_PATH];
|
|
108
124
|
}
|
|
@@ -171,7 +187,7 @@ class AbapServiceProvider extends service_provider_1.ServiceProvider {
|
|
|
171
187
|
*
|
|
172
188
|
* @example
|
|
173
189
|
* ```ts
|
|
174
|
-
* const
|
|
190
|
+
* const transportRequestService = abapServiceProvider.getAdtService<TransportRequestService>(TransportRequestService);
|
|
175
191
|
* ```
|
|
176
192
|
* @param adtServiceSubclass Subclass of class AdtService, type is specified by using AdtService class constructor signature.
|
|
177
193
|
* @returns Subclass type of class AdtService
|
|
@@ -181,8 +197,8 @@ class AbapServiceProvider extends service_provider_1.ServiceProvider {
|
|
|
181
197
|
const subclassName = adtServiceSubclass.name;
|
|
182
198
|
if (!this.services[subclassName]) {
|
|
183
199
|
// Retrieve ADT schema for the specific input AdtService subclass
|
|
184
|
-
const
|
|
185
|
-
const adtSchema = yield
|
|
200
|
+
const adtCatalogService = this.getAdtCatalogService();
|
|
201
|
+
const adtSchema = yield adtCatalogService.getServiceDefinition(adtServiceSubclass.getAdtCatagory());
|
|
186
202
|
// No ADT schema available neither locally nor from service query.
|
|
187
203
|
if (!adtSchema) {
|
|
188
204
|
return null;
|
|
@@ -7,7 +7,7 @@ export interface App {
|
|
|
7
7
|
}
|
|
8
8
|
export type AppIndex = Partial<App>[];
|
|
9
9
|
/**
|
|
10
|
-
* A class
|
|
10
|
+
* A class representing the app index service allowing to search applications deployed on an ABAP system.
|
|
11
11
|
*/
|
|
12
12
|
export declare abstract class AppIndexService extends Axios implements Service {
|
|
13
13
|
static readonly PATH = "/sap/bc/ui2/app_index";
|
|
@@ -12,7 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.AppIndexService = void 0;
|
|
13
13
|
const axios_1 = require("axios");
|
|
14
14
|
/**
|
|
15
|
-
* A class
|
|
15
|
+
* A class representing the app index service allowing to search applications deployed on an ABAP system.
|
|
16
16
|
*/
|
|
17
17
|
class AppIndexService extends axios_1.Axios {
|
|
18
18
|
/**
|
package/dist/abap/message.js
CHANGED
|
@@ -2,6 +2,30 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.prettyPrintTimeInMs = exports.prettyPrintError = exports.prettyPrintMessage = void 0;
|
|
4
4
|
const url_1 = require("url");
|
|
5
|
+
/**
|
|
6
|
+
*
|
|
7
|
+
* @param severity
|
|
8
|
+
* @param msg
|
|
9
|
+
* @param log
|
|
10
|
+
* @param error
|
|
11
|
+
*/
|
|
12
|
+
function logLevel(severity, msg, log, error = false) {
|
|
13
|
+
if (severity) {
|
|
14
|
+
severity = severity.toLowerCase();
|
|
15
|
+
if (severity === 'success') {
|
|
16
|
+
log.info(msg);
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
if (severity === 'warning') {
|
|
20
|
+
severity = 'warn';
|
|
21
|
+
}
|
|
22
|
+
log[severity](msg);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
error ? log.error(msg) : log.info(msg);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
5
29
|
/**
|
|
6
30
|
* Log a Gateway response.
|
|
7
31
|
*
|
|
@@ -57,7 +81,7 @@ function prettyPrintError({ error, log, host }) {
|
|
|
57
81
|
if (error.innererror) {
|
|
58
82
|
(error.innererror.errordetails || []).forEach((entry) => {
|
|
59
83
|
if (!entry.message.startsWith('<![CDATA')) {
|
|
60
|
-
|
|
84
|
+
logLevel(entry.severity, entry.message, log, true);
|
|
61
85
|
}
|
|
62
86
|
logFullURL({ host, path: error['longtext_url'], log });
|
|
63
87
|
});
|
|
@@ -67,12 +67,15 @@ export declare const abapUrlReplaceMap: Map<RegExp, string>;
|
|
|
67
67
|
*/
|
|
68
68
|
export declare class Ui5AbapRepositoryService extends ODataService {
|
|
69
69
|
static readonly PATH = "/sap/opu/odata/UI5/ABAP_REPOSITORY_SRV";
|
|
70
|
+
private readonly publicUrl;
|
|
70
71
|
/**
|
|
71
72
|
* Extension of the base constructor to set preferred response format if not provided by caller.
|
|
72
73
|
*
|
|
73
|
-
* @param config optional base configuration for Axios
|
|
74
|
+
* @param config optional base configuration for Axios appended with optional fields
|
|
74
75
|
*/
|
|
75
|
-
constructor(config?: AxiosRequestConfig
|
|
76
|
+
constructor(config?: AxiosRequestConfig & {
|
|
77
|
+
publicUrl?: string;
|
|
78
|
+
});
|
|
76
79
|
/**
|
|
77
80
|
* Get information about a deployed application. Returns undefined if the application cannot be found.
|
|
78
81
|
*
|
|
@@ -88,16 +91,16 @@ export declare class Ui5AbapRepositoryService extends ODataService {
|
|
|
88
91
|
* @param config.bsp BSP configuration
|
|
89
92
|
* @param config.testMode if set to true, all requests will be sent, the service checks them, but no actual deployment will happen
|
|
90
93
|
* @param config.safeMode if set then the SafeMode url parameter will be set. SafeMode is by default active, to activate provide false
|
|
91
|
-
* @returns the Axios response object for
|
|
94
|
+
* @returns the Axios response object for further processing
|
|
92
95
|
*/
|
|
93
96
|
deploy({ archive, bsp, testMode, safeMode }: DeployConfig): Promise<AxiosResponse>;
|
|
94
97
|
/**
|
|
95
98
|
* Undeploy an existing app.
|
|
96
99
|
*
|
|
97
|
-
* @param config
|
|
100
|
+
* @param config undeploy config
|
|
98
101
|
* @param config.bsp BSP configuration
|
|
99
102
|
* @param config.testMode if set to true, all requests will be sent, the service checks them, but no actual deployment will happen
|
|
100
|
-
* @returns the Axios response object for
|
|
103
|
+
* @returns the Axios response object for further processing or undefined if no request is sent
|
|
101
104
|
*/
|
|
102
105
|
undeploy({ bsp, testMode }: UndeployConfig): Promise<AxiosResponse | undefined>;
|
|
103
106
|
/**
|
|
@@ -111,8 +114,8 @@ export declare class Ui5AbapRepositoryService extends ODataService {
|
|
|
111
114
|
*
|
|
112
115
|
* @param transport optional transport request id
|
|
113
116
|
* @param testMode optional url parameter to enable test mode
|
|
114
|
-
* @param safeMode optional url
|
|
115
|
-
* @returns the Axios response object for
|
|
117
|
+
* @param safeMode optional url parameter to disable the safe model (safemode=false)
|
|
118
|
+
* @returns the Axios response object for further processing
|
|
116
119
|
*/
|
|
117
120
|
protected createConfig(transport?: string, testMode?: boolean, safeMode?: boolean): AxiosRequestConfig;
|
|
118
121
|
/**
|
|
@@ -133,16 +136,16 @@ export declare class Ui5AbapRepositoryService extends ODataService {
|
|
|
133
136
|
* @param payload request payload
|
|
134
137
|
* @param config additional request config
|
|
135
138
|
* @param tryCount number of attempted deploys (sometimes a repo request fails with a known timeout issue, so we retry)
|
|
136
|
-
* @returns the Axios response object for
|
|
139
|
+
* @returns the Axios response object for further processing
|
|
137
140
|
*/
|
|
138
141
|
protected updateRepoRequest(isExisting: boolean, appName: string, payload: string, config: AxiosRequestConfig, tryCount?: number): Promise<AxiosResponse | undefined>;
|
|
139
142
|
/**
|
|
140
|
-
* Send a request to the
|
|
143
|
+
* Send a request to the backend to delete an application.
|
|
141
144
|
*
|
|
142
145
|
* @param appName application name
|
|
143
146
|
* @param config additional request config
|
|
144
147
|
* @param tryCount number of attempted deploys (sometimes a repo request fails with a known timeout issue, so we retry)
|
|
145
|
-
* @returns the Axios response object for
|
|
148
|
+
* @returns the Axios response object for further processing
|
|
146
149
|
*/
|
|
147
150
|
protected deleteRepoRequest(appName: string, config: AxiosRequestConfig, tryCount?: number): Promise<AxiosResponse>;
|
|
148
151
|
/**
|
|
@@ -42,7 +42,7 @@ class Ui5AbapRepositoryService extends odata_service_1.ODataService {
|
|
|
42
42
|
/**
|
|
43
43
|
* Extension of the base constructor to set preferred response format if not provided by caller.
|
|
44
44
|
*
|
|
45
|
-
* @param config optional base configuration for Axios
|
|
45
|
+
* @param config optional base configuration for Axios appended with optional fields
|
|
46
46
|
*/
|
|
47
47
|
constructor(config) {
|
|
48
48
|
var _a, _b;
|
|
@@ -51,6 +51,7 @@ class Ui5AbapRepositoryService extends odata_service_1.ODataService {
|
|
|
51
51
|
// @see https://axios-http.com/docs/config_defaults
|
|
52
52
|
config.headers['Accept'] = (_b = config.headers['Accept']) !== null && _b !== void 0 ? _b : 'application/json,application/xml,text/plain,*/*';
|
|
53
53
|
super(config);
|
|
54
|
+
this.publicUrl = config.publicUrl || this.defaults.baseURL;
|
|
54
55
|
}
|
|
55
56
|
/**
|
|
56
57
|
* Get information about a deployed application. Returns undefined if the application cannot be found.
|
|
@@ -65,6 +66,7 @@ class Ui5AbapRepositoryService extends odata_service_1.ODataService {
|
|
|
65
66
|
return response.odata();
|
|
66
67
|
}
|
|
67
68
|
catch (error) {
|
|
69
|
+
this.log.debug(`Retrieving application ${app}, error found ${error}`);
|
|
68
70
|
return undefined;
|
|
69
71
|
}
|
|
70
72
|
});
|
|
@@ -77,7 +79,7 @@ class Ui5AbapRepositoryService extends odata_service_1.ODataService {
|
|
|
77
79
|
* @param config.bsp BSP configuration
|
|
78
80
|
* @param config.testMode if set to true, all requests will be sent, the service checks them, but no actual deployment will happen
|
|
79
81
|
* @param config.safeMode if set then the SafeMode url parameter will be set. SafeMode is by default active, to activate provide false
|
|
80
|
-
* @returns the Axios response object for
|
|
82
|
+
* @returns the Axios response object for further processing
|
|
81
83
|
*/
|
|
82
84
|
deploy({ archive, bsp, testMode = false, safeMode }) {
|
|
83
85
|
var _a, _b;
|
|
@@ -110,10 +112,10 @@ class Ui5AbapRepositoryService extends odata_service_1.ODataService {
|
|
|
110
112
|
/**
|
|
111
113
|
* Undeploy an existing app.
|
|
112
114
|
*
|
|
113
|
-
* @param config
|
|
115
|
+
* @param config undeploy config
|
|
114
116
|
* @param config.bsp BSP configuration
|
|
115
117
|
* @param config.testMode if set to true, all requests will be sent, the service checks them, but no actual deployment will happen
|
|
116
|
-
* @returns the Axios response object for
|
|
118
|
+
* @returns the Axios response object for further processing or undefined if no request is sent
|
|
117
119
|
*/
|
|
118
120
|
undeploy({ bsp, testMode = false }) {
|
|
119
121
|
var _a;
|
|
@@ -146,7 +148,7 @@ class Ui5AbapRepositoryService extends odata_service_1.ODataService {
|
|
|
146
148
|
* @returns url to be used in the browser.
|
|
147
149
|
*/
|
|
148
150
|
getAbapFrontendUrl() {
|
|
149
|
-
const url = new URL(this.
|
|
151
|
+
const url = new URL(this.publicUrl);
|
|
150
152
|
exports.abapUrlReplaceMap.forEach((value, key) => {
|
|
151
153
|
url.hostname = url.hostname.replace(key, value);
|
|
152
154
|
});
|
|
@@ -157,8 +159,8 @@ class Ui5AbapRepositoryService extends odata_service_1.ODataService {
|
|
|
157
159
|
*
|
|
158
160
|
* @param transport optional transport request id
|
|
159
161
|
* @param testMode optional url parameter to enable test mode
|
|
160
|
-
* @param safeMode optional url
|
|
161
|
-
* @returns the Axios response object for
|
|
162
|
+
* @param safeMode optional url parameter to disable the safe model (safemode=false)
|
|
163
|
+
* @returns the Axios response object for further processing
|
|
162
164
|
*/
|
|
163
165
|
createConfig(transport, testMode, safeMode) {
|
|
164
166
|
const headers = {
|
|
@@ -205,8 +207,8 @@ class Ui5AbapRepositoryService extends odata_service_1.ODataService {
|
|
|
205
207
|
return (`<entry xmlns="http://www.w3.org/2005/Atom"` +
|
|
206
208
|
` xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"` +
|
|
207
209
|
` xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices"` +
|
|
208
|
-
` xml:base="${this.
|
|
209
|
-
` <id>${this.
|
|
210
|
+
` xml:base="${this.publicUrl}">` +
|
|
211
|
+
` <id>${this.publicUrl}/Repositories('${escapedName}')</id>` +
|
|
210
212
|
` <title type="text">Repositories('${escapedName}')</title>` +
|
|
211
213
|
` <updated>${time}</updated>` +
|
|
212
214
|
` <category term="/UI5/ABAP_REPOSITORY_SRV.Repository" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme"/>` +
|
|
@@ -230,10 +232,10 @@ class Ui5AbapRepositoryService extends odata_service_1.ODataService {
|
|
|
230
232
|
* @param payload request payload
|
|
231
233
|
* @param config additional request config
|
|
232
234
|
* @param tryCount number of attempted deploys (sometimes a repo request fails with a known timeout issue, so we retry)
|
|
233
|
-
* @returns the Axios response object for
|
|
235
|
+
* @returns the Axios response object for further processing
|
|
234
236
|
*/
|
|
235
237
|
updateRepoRequest(isExisting, appName, payload, config, tryCount = 1) {
|
|
236
|
-
var _a;
|
|
238
|
+
var _a, _b;
|
|
237
239
|
return __awaiter(this, void 0, void 0, function* () {
|
|
238
240
|
try {
|
|
239
241
|
// Was the app deployed after the first failed attempt?
|
|
@@ -246,6 +248,7 @@ class Ui5AbapRepositoryService extends odata_service_1.ODataService {
|
|
|
246
248
|
return Promise.resolve(undefined);
|
|
247
249
|
}
|
|
248
250
|
else {
|
|
251
|
+
this.log.info(`${appName} found on target system: ${isExisting}`);
|
|
249
252
|
const response = isExisting
|
|
250
253
|
? yield this.put(`/Repositories('${encodeURIComponent(appName)}')`, payload, config)
|
|
251
254
|
: yield this.post('/Repositories', payload, config);
|
|
@@ -260,6 +263,10 @@ class Ui5AbapRepositoryService extends odata_service_1.ODataService {
|
|
|
260
263
|
}
|
|
261
264
|
return this.updateRepoRequest(isExisting, appName, payload, config, tryCount + 1);
|
|
262
265
|
}
|
|
266
|
+
else if ((_b = config === null || config === void 0 ? void 0 : config.params) === null || _b === void 0 ? void 0 : _b.TestMode) {
|
|
267
|
+
// TestMode returns HTTP 403 but includes details of the uploaded files and request
|
|
268
|
+
return error.response;
|
|
269
|
+
}
|
|
263
270
|
else {
|
|
264
271
|
throw error;
|
|
265
272
|
}
|
|
@@ -267,12 +274,12 @@ class Ui5AbapRepositoryService extends odata_service_1.ODataService {
|
|
|
267
274
|
});
|
|
268
275
|
}
|
|
269
276
|
/**
|
|
270
|
-
* Send a request to the
|
|
277
|
+
* Send a request to the backend to delete an application.
|
|
271
278
|
*
|
|
272
279
|
* @param appName application name
|
|
273
280
|
* @param config additional request config
|
|
274
281
|
* @param tryCount number of attempted deploys (sometimes a repo request fails with a known timeout issue, so we retry)
|
|
275
|
-
* @returns the Axios response object for
|
|
282
|
+
* @returns the Axios response object for further processing
|
|
276
283
|
*/
|
|
277
284
|
deleteRepoRequest(appName, config, tryCount = 1) {
|
|
278
285
|
var _a;
|
|
@@ -308,8 +315,17 @@ class Ui5AbapRepositoryService extends odata_service_1.ODataService {
|
|
|
308
315
|
var _a;
|
|
309
316
|
this.log.error(error.message);
|
|
310
317
|
if ((0, odata_request_error_1.isAxiosError)(error) && ((_a = error.response) === null || _a === void 0 ? void 0 : _a.data)) {
|
|
311
|
-
|
|
312
|
-
|
|
318
|
+
let responseData = error.response.data;
|
|
319
|
+
if (typeof error.response.data === 'string') {
|
|
320
|
+
try {
|
|
321
|
+
responseData = JSON.parse(error.response.data);
|
|
322
|
+
}
|
|
323
|
+
catch (_b) {
|
|
324
|
+
// Not much we can do!
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
if (responseData === null || responseData === void 0 ? void 0 : responseData['error']) {
|
|
328
|
+
(0, message_1.prettyPrintError)({ error: responseData['error'], host, log: this.log });
|
|
313
329
|
}
|
|
314
330
|
else {
|
|
315
331
|
this.log.error(error.response.data);
|
package/dist/auth/connection.js
CHANGED
|
@@ -114,7 +114,7 @@ function isHtmlLoginForm(response) {
|
|
|
114
114
|
}
|
|
115
115
|
/**
|
|
116
116
|
* @param contentTypeHeader contents of Content-Type header (https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Type)
|
|
117
|
-
* @param responseData data
|
|
117
|
+
* @param responseData data received in HTTP response. This is used to infer the Content-Type, if the header is missing or ambiguous
|
|
118
118
|
* @returns content type
|
|
119
119
|
*/
|
|
120
120
|
function getContentType(contentTypeHeader, responseData) {
|
|
@@ -164,11 +164,14 @@ function attachConnectionHandler(provider) {
|
|
|
164
164
|
return response;
|
|
165
165
|
}
|
|
166
166
|
}, (error) => {
|
|
167
|
-
var _a
|
|
167
|
+
var _a;
|
|
168
168
|
// remember xsrf token if provided even on error
|
|
169
|
-
if (
|
|
170
|
-
|
|
171
|
-
|
|
169
|
+
if (error.response) {
|
|
170
|
+
if ((_a = error.response.headers) === null || _a === void 0 ? void 0 : _a[CSRF.ResponseHeaderName]) {
|
|
171
|
+
provider.defaults.headers.common[CSRF.RequestHeaderName] =
|
|
172
|
+
error.response.headers[CSRF.ResponseHeaderName];
|
|
173
|
+
}
|
|
174
|
+
provider.cookies.setCookies(error.response);
|
|
172
175
|
}
|
|
173
176
|
throw error;
|
|
174
177
|
});
|
|
@@ -44,12 +44,18 @@ export declare class ServiceProvider extends Axios implements ServiceProviderExt
|
|
|
44
44
|
*/
|
|
45
45
|
protected generateServiceConfig(path: string): AxiosRequestConfig;
|
|
46
46
|
/**
|
|
47
|
-
* Create a service instance for the given path and
|
|
47
|
+
* Create a service instance for the given path, service class and public URL.
|
|
48
48
|
*
|
|
49
49
|
* @param path path of the service relative to the service provider
|
|
50
50
|
* @param ServiceClass class type to be used to create an instance
|
|
51
51
|
* @returns a service instance
|
|
52
52
|
*/
|
|
53
53
|
protected createService<T extends Service>(path: string, ServiceClass: any): T;
|
|
54
|
+
/**
|
|
55
|
+
* Retrieve the public URL exposing the ABAP UI application.
|
|
56
|
+
*
|
|
57
|
+
* @returns string Axios Base URL
|
|
58
|
+
*/
|
|
59
|
+
protected get publicUrl(): string;
|
|
54
60
|
}
|
|
55
61
|
//# sourceMappingURL=service-provider.d.ts.map
|
|
@@ -39,18 +39,26 @@ class ServiceProvider extends axios_1.Axios {
|
|
|
39
39
|
return Object.assign(Object.assign({}, config), { baseURL: this.defaults.baseURL + path, headers: (_b = (_a = this.defaults.headers) === null || _a === void 0 ? void 0 : _a.common) !== null && _b !== void 0 ? _b : {} });
|
|
40
40
|
}
|
|
41
41
|
/**
|
|
42
|
-
* Create a service instance for the given path and
|
|
42
|
+
* Create a service instance for the given path, service class and public URL.
|
|
43
43
|
*
|
|
44
44
|
* @param path path of the service relative to the service provider
|
|
45
45
|
* @param ServiceClass class type to be used to create an instance
|
|
46
46
|
* @returns a service instance
|
|
47
47
|
*/
|
|
48
48
|
createService(path, ServiceClass) {
|
|
49
|
-
const service = new ServiceClass(this.generateServiceConfig(path));
|
|
49
|
+
const service = new ServiceClass(Object.assign(Object.assign({}, this.generateServiceConfig(path)), { publicUrl: this.publicUrl }));
|
|
50
50
|
service.log = this.log;
|
|
51
51
|
service.interceptors = this.interceptors;
|
|
52
52
|
return service;
|
|
53
53
|
}
|
|
54
|
+
/**
|
|
55
|
+
* Retrieve the public URL exposing the ABAP UI application.
|
|
56
|
+
*
|
|
57
|
+
* @returns string Axios Base URL
|
|
58
|
+
*/
|
|
59
|
+
get publicUrl() {
|
|
60
|
+
return this.defaults.baseURL;
|
|
61
|
+
}
|
|
54
62
|
}
|
|
55
63
|
exports.ServiceProvider = ServiceProvider;
|
|
56
64
|
//# sourceMappingURL=service-provider.js.map
|
package/dist/factory.js
CHANGED
|
@@ -47,7 +47,7 @@ function createInstance(ProviderType, config) {
|
|
|
47
47
|
delete providerConfig.ignoreCertErrors;
|
|
48
48
|
providerConfig.withCredentials = (providerConfig === null || providerConfig === void 0 ? void 0 : providerConfig.auth) && Object.keys(providerConfig.auth).length > 0;
|
|
49
49
|
/**
|
|
50
|
-
* Make axios throw an error for 4xx errors
|
|
50
|
+
* Make axios throw an error for 4xx errors.
|
|
51
51
|
*
|
|
52
52
|
* @param status - http response status
|
|
53
53
|
* @returns success (true) or error (false)
|
|
@@ -157,6 +157,8 @@ function createForDestination(options, destination, destinationServiceInstance)
|
|
|
157
157
|
let provider;
|
|
158
158
|
if ((0, btp_utils_1.isAbapSystem)(destination)) {
|
|
159
159
|
provider = createInstance(abap_1.AbapServiceProvider, providerConfig);
|
|
160
|
+
// For an ABAP destination flow, need to show the destination host URL property instead of the BAS host URL i.e. https://mydest.dest
|
|
161
|
+
provider.publicUrl = destination.Host;
|
|
160
162
|
}
|
|
161
163
|
else {
|
|
162
164
|
provider = createInstance(service_provider_1.ServiceProvider, providerConfig);
|
package/package.json
CHANGED