@sap-ux/odata-service-inquirer 2.11.5 → 2.11.7

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.
@@ -345,6 +345,14 @@ export declare class ConnectionValidator {
345
345
  * Reset the validity state.
346
346
  */
347
347
  private resetValidity;
348
+ /**
349
+ * Get the specific authorization reason user message. This may be catalog version specific.
350
+ *
351
+ * @param httpStatusCode the http error code returned from a request
352
+ * @param odataVersion optional, the odata version specific request, for example for specific catalog requests
353
+ * @returns the text message indicting the authentication or authorization failure speific to an odata catalog request
354
+ */
355
+ private getAuthFailureReasonText;
348
356
  }
349
357
  export {};
350
358
  //# sourceMappingURL=connectionValidator.d.ts.map
@@ -864,7 +864,10 @@ class ConnectionValidator {
864
864
  return { valResult: true };
865
865
  }
866
866
  else if (this.validity.authenticated === false) {
867
- return { valResult: (0, i18n_1.t)('errors.authenticationFailed'), errorType: inquirer_common_1.ERROR_TYPE.AUTH };
867
+ return {
868
+ valResult: this.getAuthFailureReasonText(status, odataVersion),
869
+ errorType: inquirer_common_1.ERROR_TYPE.AUTH
870
+ };
868
871
  }
869
872
  }
870
873
  return { valResult };
@@ -891,6 +894,33 @@ class ConnectionValidator {
891
894
  this._destinationUrl = undefined;
892
895
  this._destination = undefined;
893
896
  }
897
+ /**
898
+ * Get the specific authorization reason user message. This may be catalog version specific.
899
+ *
900
+ * @param httpStatusCode the http error code returned from a request
901
+ * @param odataVersion optional, the odata version specific request, for example for specific catalog requests
902
+ * @returns the text message indicting the authentication or authorization failure speific to an odata catalog request
903
+ */
904
+ getAuthFailureReasonText(httpStatusCode, odataVersion) {
905
+ let authFailType;
906
+ if ([403, '403'].includes(httpStatusCode)) {
907
+ authFailType = (0, i18n_1.t)('texts.authorizationFailed');
908
+ }
909
+ else if ([401, '401'].includes(httpStatusCode)) {
910
+ authFailType = (0, i18n_1.t)('texts.authenticationFailed');
911
+ }
912
+ let authFailureReason;
913
+ if (odataVersion) {
914
+ authFailureReason = (0, i18n_1.t)('errors.authenticationFailedSpecificCatalog', {
915
+ odataVersion,
916
+ authFailType
917
+ });
918
+ }
919
+ else {
920
+ authFailureReason = (0, i18n_1.t)('errors.authenticationFailedAllCatalogs', { authFailType });
921
+ }
922
+ return authFailureReason;
923
+ }
894
924
  }
895
925
  exports.ConnectionValidator = ConnectionValidator;
896
926
  //# sourceMappingURL=connectionValidator.js.map
@@ -1,6 +1,7 @@
1
1
  import type { InputQuestion, PasswordQuestion, ConfirmQuestion } from '@sap-ux/inquirer-common';
2
2
  import type { Answers } from 'inquirer';
3
3
  import type { ConnectionValidator } from '../../../connectionValidator';
4
+ import type { OdataVersion } from '@sap-ux/odata-service-writer';
4
5
  export declare enum BasicCredentialsPromptNames {
5
6
  systemUsername = "systemUsername",
6
7
  systemPassword = "systemPassword",
@@ -14,10 +15,11 @@ export declare enum BasicCredentialsPromptNames {
14
15
  * @param sapClient
15
16
  * @param sapClient.sapClient the sapClient value to be used along with the credentials validation
16
17
  * @param sapClient.isValid validation of credentials is deferred until a valid sapClient is provided or undefined
18
+ * @param requiredOdataVersion
17
19
  * @returns the credentials prompts
18
20
  */
19
21
  export declare function getCredentialsPrompts<T extends Answers>(connectionValidator: ConnectionValidator, promptNamespace?: string, sapClient?: {
20
22
  sapClient: string | undefined;
21
23
  isValid: boolean;
22
- }): (InputQuestion<T> | PasswordQuestion<T> | ConfirmQuestion<T>)[];
24
+ }, requiredOdataVersion?: OdataVersion): (InputQuestion<T> | PasswordQuestion<T> | ConfirmQuestion<T>)[];
23
25
  //# sourceMappingURL=questions.d.ts.map
@@ -21,9 +21,10 @@ var BasicCredentialsPromptNames;
21
21
  * @param sapClient
22
22
  * @param sapClient.sapClient the sapClient value to be used along with the credentials validation
23
23
  * @param sapClient.isValid validation of credentials is deferred until a valid sapClient is provided or undefined
24
+ * @param requiredOdataVersion
24
25
  * @returns the credentials prompts
25
26
  */
26
- function getCredentialsPrompts(connectionValidator, promptNamespace, sapClient) {
27
+ function getCredentialsPrompts(connectionValidator, promptNamespace, sapClient, requiredOdataVersion) {
27
28
  const usernamePromptName = `${promptNamespace ? promptNamespace + ':' : ''}${BasicCredentialsPromptNames.systemUsername}`;
28
29
  const passwordPromptName = `${promptNamespace ? promptNamespace + ':' : ''}${BasicCredentialsPromptNames.systemPassword}`;
29
30
  const storeCredentialsPromptName = `${promptNamespace ? promptNamespace + ':' : ''}${BasicCredentialsPromptNames.storeSystemCredentials}`;
@@ -79,7 +80,8 @@ function getCredentialsPrompts(connectionValidator, promptNamespace, sapClient)
79
80
  }
80
81
  const { valResult } = await connectionValidator.validateAuth(connectionValidator.validatedUrl, answers?.[usernamePromptName], password, {
81
82
  sapClient: sapClient?.sapClient || selectedSystemClient,
82
- isSystem
83
+ isSystem,
84
+ odataVersion: (0, utils_1.convertODataVersionType)(requiredOdataVersion)
83
85
  });
84
86
  if (valResult === true && connectionValidator.serviceProvider) {
85
87
  updatePromptStateWithConnectedSystem(connectionValidator.serviceProvider, selectedSystem, {
@@ -178,8 +178,7 @@ async function createSystemChoices(destinationFilters, includeCloudFoundryAbapEn
178
178
  }
179
179
  }
180
180
  else {
181
- const backendService = await (0, store_1.getBackendSystemService)();
182
- const backendSystems = await backendService.getAll({ includeSensitiveData: false });
181
+ const backendSystems = await (0, store_1.getAllBackendSystems)(false);
183
182
  // Cache the backend systems
184
183
  utils_1.PromptState.backendSystemsCache = backendSystems;
185
184
  systemChoices = backendSystems.map((system) => {
@@ -202,7 +202,7 @@ async function getSystemConnectionQuestions(connectionValidator, promptOptions,
202
202
  name: `${systemSelectionPromptNames.systemSelectionCli}`
203
203
  });
204
204
  }
205
- questions.push(...(0, questions_2.getCredentialsPrompts)(connectionValidator, systemSelectionPromptNamespace));
205
+ questions.push(...(0, questions_2.getCredentialsPrompts)(connectionValidator, systemSelectionPromptNamespace, undefined, requiredOdataVersion));
206
206
  return questions;
207
207
  }
208
208
  //# sourceMappingURL=questions.js.map
@@ -13,10 +13,7 @@ const store_1 = require("../../../utils/store");
13
13
  * @returns true if the system name is already in use, otherwise false
14
14
  */
15
15
  async function isSystemNameInUse(systemName) {
16
- const backendService = await (0, store_1.getBackendSystemService)();
17
- const backendSystems = await backendService.getAll({
18
- includeSensitiveData: false
19
- });
16
+ const backendSystems = await (0, store_1.getAllBackendSystems)(false);
20
17
  return !!backendSystems.find((system) => system.name === systemName);
21
18
  }
22
19
  /**
@@ -111,7 +111,7 @@
111
111
  "newSystemChoiceLabel": "New System",
112
112
  "hint": "Select a system configuration.",
113
113
  "message": "System",
114
- "authenticationFailedUpdateCredentials": "Authentication failed. Please try updating the credentials."
114
+ "authenticationFailedUpdateCredentials": "$t(texts.authenticationFailed). Please try updating the credentials."
115
115
  },
116
116
  "abapOnBTPType": {
117
117
  "message": "ABAP environment definition source",
@@ -217,7 +217,9 @@
217
217
  "capModelAndServicesLoadError": "An error occurred loading the CAP model and services: {{- error, addMsgWithColonFormatter}}.",
218
218
  "capServiceUrlPathNotDefined": "An error occurred reading CAP service metadata: {{serviceName}}. The CAP service property: `urlPath` is not defined but it is required.",
219
219
  "unknownError": "An error occurred: {{- error, addMsgWithColonFormatter}}.",
220
- "authenticationFailed": "Authentication incorrect: {{error}}.",
220
+ "authenticationFailed": "$t(texts.authenticationFailed): {{error}}.",
221
+ "authenticationFailedSpecificCatalog": "{{authFailType}}: Unable to access the OData V{{odataVersion}} service catalog",
222
+ "authenticationFailedAllCatalogs": "{{authFailType}}: Unable to access any service catalogs",
221
223
  "invalidUrl": "Invalid URL: {{-input, addMsgWithColonFormatter}}.",
222
224
  "connectionError": "A connection error occurred. Ensure the target host is available on the network: {{- error}}",
223
225
  "urlNotFound": "URL not found.",
@@ -241,7 +243,8 @@
241
243
  "unparseableXML": "Unparseable XML was specified: {{-error}}.",
242
244
  "noRelevantEntities": "The template and service selected have no relevant entities that you can use.",
243
245
  "cfInstanceCredentialsNotReturned": "Cannot not retrieve credentials to access: {{serviceInstanceName}}.",
244
- "v2CatalogServiceNoAnnotations": "An error occurred when creating an OData V2 catalog service object. Annotations will not be available: {{-error}}"
246
+ "v2CatalogServiceNoAnnotations": "An error occurred when creating an OData V2 catalog service object. Annotations will not be available: {{-error}}",
247
+ "backendSystemRetrieval": "An error occurred when retrieving the backend systems from the store: {{-error}}"
245
248
  },
246
249
  "warnings": {
247
250
  "largeMetadataDocument": "The metadata for this OData service is very large. It may take some time before this operation completes.",
@@ -262,6 +265,8 @@
262
265
  "httpStatus": "HTTP Status {{httpStatus}}",
263
266
  "checkDestinationAuthConfig": "Please check the SAP BTP destination authentication configuration.",
264
267
  "choiceNameNone": "None",
265
- "passwordStoreWarning": "Passwords are stored in your operating system's credential manager and are protected by its security policies."
268
+ "passwordStoreWarning": "Passwords are stored in your operating system's credential manager and are protected by its security policies.",
269
+ "authorizationFailed": "Authorization failed",
270
+ "authenticationFailed": "Authentication failed"
266
271
  }
267
272
  }
@@ -5,4 +5,11 @@ import { type BackendSystem, type BackendSystemKey, type Service } from '@sap-ux
5
5
  * @returns the backend system service instance
6
6
  */
7
7
  export declare function getBackendSystemService(): Promise<Service<BackendSystem, BackendSystemKey>>;
8
+ /**
9
+ * Fetch all backend systems.
10
+ *
11
+ * @param includeSensitiveData - whether to include sensitive data
12
+ * @returns backened systems
13
+ */
14
+ export declare function getAllBackendSystems(includeSensitiveData?: boolean): Promise<BackendSystem[] | []>;
8
15
  //# sourceMappingURL=store.d.ts.map
@@ -1,7 +1,13 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.getBackendSystemService = getBackendSystemService;
7
+ exports.getAllBackendSystems = getAllBackendSystems;
4
8
  const store_1 = require("@sap-ux/store");
9
+ const logger_helper_1 = __importDefault(require("../prompts/logger-helper"));
10
+ const i18n_1 = require("../i18n");
5
11
  /**
6
12
  * Get the backend system service instance.
7
13
  *
@@ -13,4 +19,23 @@ async function getBackendSystemService() {
13
19
  });
14
20
  return backendService;
15
21
  }
22
+ /**
23
+ * Fetch all backend systems.
24
+ *
25
+ * @param includeSensitiveData - whether to include sensitive data
26
+ * @returns backened systems
27
+ */
28
+ async function getAllBackendSystems(includeSensitiveData = false) {
29
+ let backendSystems = [];
30
+ try {
31
+ const backendService = await getBackendSystemService();
32
+ backendSystems = await backendService.getAll({
33
+ includeSensitiveData
34
+ });
35
+ }
36
+ catch (error) {
37
+ logger_helper_1.default.logger.error((0, i18n_1.t)('errors.backendSystemRetrieval', { error: error.message }));
38
+ }
39
+ return backendSystems;
40
+ }
16
41
  //# sourceMappingURL=store.js.map
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": "2.11.5",
4
+ "version": "2.11.7",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/SAP/open-ux-tools.git",
@@ -30,8 +30,8 @@
30
30
  "inquirer-autocomplete-prompt": "2.0.1",
31
31
  "os-name": "4.0.1",
32
32
  "@sap-ux/axios-extension": "1.24.2",
33
- "@sap-ux/btp-utils": "1.1.5",
34
33
  "@sap-ux/fiori-generator-shared": "0.13.33",
34
+ "@sap-ux/btp-utils": "1.1.5",
35
35
  "@sap-ux/guided-answers-helper": "0.4.1",
36
36
  "@sap-ux/telemetry": "0.6.38",
37
37
  "@sap-ux/inquirer-common": "0.9.3",
@@ -49,11 +49,11 @@
49
49
  "@types/lodash": "4.14.202",
50
50
  "jest-extended": "6.0.0",
51
51
  "@sap-ux/fiori-generator-shared": "0.13.33",
52
- "@sap-ux/fiori-elements-writer": "2.8.0",
53
- "@sap-ux/fiori-freestyle-writer": "2.5.0",
54
- "@sap-ux/feature-toggle": "0.3.4",
52
+ "@sap-ux/fiori-elements-writer": "2.8.3",
53
+ "@sap-ux/fiori-freestyle-writer": "2.5.1",
55
54
  "@sap-ux/odata-service-writer": "0.27.29",
56
- "@sap-ux/cap-config-writer": "0.12.24"
55
+ "@sap-ux/cap-config-writer": "0.12.24",
56
+ "@sap-ux/feature-toggle": "0.3.4"
57
57
  },
58
58
  "engines": {
59
59
  "node": ">=20.x"