@sap-ux/odata-service-inquirer 0.5.29 → 0.5.30
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.
|
@@ -152,6 +152,13 @@ export declare class ConnectionValidator {
|
|
|
152
152
|
* @param connectConfig.odataVersion the odata version to restrict the catalog requests if only a specific version is required
|
|
153
153
|
*/
|
|
154
154
|
private createSystemConnection;
|
|
155
|
+
/**
|
|
156
|
+
* Check if we should attempt to use the v4 catalog service as a fallback.
|
|
157
|
+
*
|
|
158
|
+
* @param statusCode http status code, if not provided will return false as we cannot determine the reason for v2 catalog request failure
|
|
159
|
+
* @returns true if we should attempt the v4 catalog service
|
|
160
|
+
*/
|
|
161
|
+
private shouldAttemptV4Catalog;
|
|
155
162
|
/**
|
|
156
163
|
* Callback for when the refresh token changes.
|
|
157
164
|
*
|
|
@@ -281,12 +281,22 @@ class ConnectionValidator {
|
|
|
281
281
|
if (!odataVersion || odataVersion === axios_extension_1.ODataVersion.v4) {
|
|
282
282
|
this._catalogV4 = this._serviceProvider.catalog(axios_extension_1.ODataVersion.v4);
|
|
283
283
|
}
|
|
284
|
+
let v4Requested = false;
|
|
284
285
|
try {
|
|
285
|
-
|
|
286
|
+
if (this._catalogV2) {
|
|
287
|
+
await this._catalogV2?.listServices();
|
|
288
|
+
}
|
|
289
|
+
else if (this._catalogV4) {
|
|
290
|
+
v4Requested = true;
|
|
291
|
+
await this._catalogV4?.listServices();
|
|
292
|
+
}
|
|
286
293
|
}
|
|
287
294
|
catch (error) {
|
|
288
|
-
// We will try the v4 catalog if v2 returns a 404
|
|
289
|
-
|
|
295
|
+
// We will try the v4 catalog if v2 returns a 404 or an auth code. Try the v4 catalog with the credentials provided also
|
|
296
|
+
// as the user may not be authorized for the v2 catalog specifically.
|
|
297
|
+
if (this._catalogV4 &&
|
|
298
|
+
!v4Requested &&
|
|
299
|
+
this.shouldAttemptV4Catalog(error.response?.status)) {
|
|
290
300
|
await this._catalogV4.listServices();
|
|
291
301
|
}
|
|
292
302
|
else {
|
|
@@ -294,6 +304,19 @@ class ConnectionValidator {
|
|
|
294
304
|
}
|
|
295
305
|
}
|
|
296
306
|
}
|
|
307
|
+
/**
|
|
308
|
+
* Check if we should attempt to use the v4 catalog service as a fallback.
|
|
309
|
+
*
|
|
310
|
+
* @param statusCode http status code, if not provided will return false as we cannot determine the reason for v2 catalog request failure
|
|
311
|
+
* @returns true if we should attempt the v4 catalog service
|
|
312
|
+
*/
|
|
313
|
+
shouldAttemptV4Catalog(statusCode) {
|
|
314
|
+
if (!statusCode) {
|
|
315
|
+
return false;
|
|
316
|
+
}
|
|
317
|
+
const errorType = error_handler_1.ErrorHandler.getErrorType(statusCode);
|
|
318
|
+
return errorType === error_handler_1.ERROR_TYPE.NOT_FOUND || errorType === error_handler_1.ERROR_TYPE.AUTH;
|
|
319
|
+
}
|
|
297
320
|
/**
|
|
298
321
|
* Callback for when the refresh token changes.
|
|
299
322
|
*
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sap-ux/odata-service-inquirer",
|
|
3
3
|
"description": "Prompts module that can prompt users for inputs required for odata service writing",
|
|
4
|
-
"version": "0.5.
|
|
4
|
+
"version": "0.5.30",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/SAP/open-ux-tools.git",
|