@sap-ux/odata-service-inquirer 2.10.0 → 2.11.1

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.md CHANGED
@@ -1,4 +1,6 @@
1
- # @sap-ux/odata-service-inquirer
1
+ [![Changelog](https://img.shields.io/badge/changelog-8A2BE2)](https://github.com/SAP/open-ux-tools/blob/main/packages/odata-service-inquirer/CHANGELOG.md) [![Github repo](https://img.shields.io/badge/github-repo-blue)](https://github.com/SAP/open-ux-tools/tree/main/packages/odata-service-inquirer)
2
+
3
+ # [`@sap-ux/odata-service-inquirer`](https://github.com/SAP/open-ux-tools/tree/main/packages/odata-service-inquirer)
2
4
 
3
5
  Provides Inquirer based end-user prompting to allow selection of a service from multiple data source types. This involves acquiring a connection to backend systems and retrieving edmx metadata for services provided by the catalog, from a local file or CAP project. This module also provides prompts that may be used to gather user selections to define the main and navigation entities and related prompts relating to application layout and annotation generation when creating a UI5 application using the `@sap-ux/fiori-freestyle-writer` and `@sap-ux/fiori-elements-writer` modules.
4
6
 
@@ -81,4 +83,4 @@ Read [License](./LICENSE).
81
83
  SAP UI5 Application
82
84
  Inquirer
83
85
  Prompting
84
- Generator
86
+ Generator
@@ -1,9 +1,10 @@
1
- import type { InputQuestion, PasswordQuestion } from '@sap-ux/inquirer-common';
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
4
  export declare enum BasicCredentialsPromptNames {
5
5
  systemUsername = "systemUsername",
6
- systemPassword = "systemPassword"
6
+ systemPassword = "systemPassword",
7
+ storeSystemCredentials = "storeSystemCredentials"
7
8
  }
8
9
  /**
9
10
  * Re-usable credentials prompts for connection to systems using basic auth.
@@ -18,5 +19,5 @@ export declare enum BasicCredentialsPromptNames {
18
19
  export declare function getCredentialsPrompts<T extends Answers>(connectionValidator: ConnectionValidator, promptNamespace?: string, sapClient?: {
19
20
  sapClient: string | undefined;
20
21
  isValid: boolean;
21
- }): (InputQuestion<T> | PasswordQuestion<T>)[];
22
+ }): (InputQuestion<T> | PasswordQuestion<T> | ConfirmQuestion<T>)[];
22
23
  //# sourceMappingURL=questions.d.ts.map
@@ -11,6 +11,7 @@ var BasicCredentialsPromptNames;
11
11
  (function (BasicCredentialsPromptNames) {
12
12
  BasicCredentialsPromptNames["systemUsername"] = "systemUsername";
13
13
  BasicCredentialsPromptNames["systemPassword"] = "systemPassword";
14
+ BasicCredentialsPromptNames["storeSystemCredentials"] = "storeSystemCredentials";
14
15
  })(BasicCredentialsPromptNames || (exports.BasicCredentialsPromptNames = BasicCredentialsPromptNames = {}));
15
16
  /**
16
17
  * Re-usable credentials prompts for connection to systems using basic auth.
@@ -25,9 +26,10 @@ var BasicCredentialsPromptNames;
25
26
  function getCredentialsPrompts(connectionValidator, promptNamespace, sapClient) {
26
27
  const usernamePromptName = `${promptNamespace ? promptNamespace + ':' : ''}${BasicCredentialsPromptNames.systemUsername}`;
27
28
  const passwordPromptName = `${promptNamespace ? promptNamespace + ':' : ''}${BasicCredentialsPromptNames.systemPassword}`;
29
+ const storeCredentialsPromptName = `${promptNamespace ? promptNamespace + ':' : ''}${BasicCredentialsPromptNames.storeSystemCredentials}`;
28
30
  // Optimization to prevent re-checking of auth
29
31
  let authRequired;
30
- return [
32
+ const credentialsPrompts = [
31
33
  {
32
34
  when: async () => {
33
35
  authRequired = await connectionValidator.isAuthRequired();
@@ -83,7 +85,7 @@ function getCredentialsPrompts(connectionValidator, promptNamespace, sapClient)
83
85
  updatePromptStateWithConnectedSystem(connectionValidator.serviceProvider, selectedSystem, {
84
86
  username: answers?.[usernamePromptName],
85
87
  password: password
86
- });
88
+ }); // Store credentials temporarily - will be conditionally kept/removed in store credentials prompt
87
89
  return true;
88
90
  }
89
91
  return valResult;
@@ -100,9 +102,42 @@ function getCredentialsPrompts(connectionValidator, promptNamespace, sapClient)
100
102
  severity: yeoman_ui_types_1.Severity.warning
101
103
  };
102
104
  }
105
+ // Lower priority than the cert error warning - we can only show one at a time, hence this should always be last
106
+ if (utils_1.PromptState.odataService.connectedSystem?.backendSystem) {
107
+ return {
108
+ message: (0, i18n_1.t)('texts.passwordStoreWarning'),
109
+ severity: yeoman_ui_types_1.Severity.warning
110
+ };
111
+ }
103
112
  }
104
113
  }
105
114
  ];
115
+ const confirmCredentialStoragePrompt = {
116
+ when: (answers) => !!(connectionValidator.systemAuthType === 'basic' &&
117
+ authRequired &&
118
+ connectionValidator.validity.authenticated &&
119
+ answers[passwordPromptName]),
120
+ type: 'confirm',
121
+ name: storeCredentialsPromptName,
122
+ message: (0, i18n_1.t)('prompts.storeSystemCredentials.message'),
123
+ default: false,
124
+ guiOptions: {
125
+ breadcrumb: (0, i18n_1.t)('prompts.storeSystemCredentials.breadcrumb')
126
+ },
127
+ validate: async (storeCredentials) => {
128
+ if (utils_1.PromptState.odataService.connectedSystem?.backendSystem) {
129
+ const backendSystem = utils_1.PromptState.odataService.connectedSystem.backendSystem;
130
+ utils_1.PromptState.odataService.connectedSystem.backendSystem = Object.assign(backendSystem, {
131
+ newOrUpdated: storeCredentials
132
+ });
133
+ }
134
+ return true;
135
+ }
136
+ };
137
+ if (!(0, btp_utils_1.isAppStudio)()) {
138
+ credentialsPrompts.push(confirmCredentialStoragePrompt);
139
+ }
140
+ return credentialsPrompts;
106
141
  }
107
142
  /**
108
143
  * Updates the prompt state with the connected system.
@@ -120,13 +155,12 @@ function updatePromptStateWithConnectedSystem(serviceProvider, selectedSystem, {
120
155
  // Update the existing backend system with the new credentials that may be used to update in the store.
121
156
  if (selectedSystem?.type === 'backendSystem') {
122
157
  const backendSystem = selectedSystem.system;
123
- // Have the credentials changed..
158
+ // Have the credentials changed..?
124
159
  if (backendSystem.username !== username || backendSystem.password !== password) {
125
160
  utils_1.PromptState.odataService.connectedSystem.backendSystem = Object.assign(backendSystem, {
126
161
  username: username,
127
- password,
128
- userDisplayName: username,
129
- newOrUpdated: true
162
+ password: password,
163
+ userDisplayName: username
130
164
  });
131
165
  }
132
166
  // If the connection is successful and a destination was selected, assign the connected destination to the prompt state.
@@ -7,6 +7,8 @@ import type { Answers } from 'inquirer';
7
7
  import type { ConnectedSystem } from '../../../../types';
8
8
  import type { ConnectionValidator } from '../../../connectionValidator';
9
9
  import { type NewSystemAnswers } from '../new-system/types';
10
+ import type { SystemSelectionAnswers } from '../system-selection/questions';
11
+ import type { AbapOnPremAnswers } from '../abap-on-prem/questions';
10
12
  /**
11
13
  * Get the system url prompt. The system url prompt is used to connect to a new system using the user input system url.
12
14
  *
@@ -27,5 +29,5 @@ export declare function getSystemUrlQuestion<T extends Answers>(connectValidator
27
29
  * This prevents conflicts with other prompts of the same types where the same prompt is used by multiple other prompts but cannot share the name.
28
30
  * @returns the new system name prompt
29
31
  */
30
- export declare function getUserSystemNameQuestion(connectValidator: ConnectionValidator, promptNamespace?: string): InputQuestion<Partial<NewSystemAnswers>>;
32
+ export declare function getUserSystemNameQuestion(connectValidator: ConnectionValidator, promptNamespace?: string): InputQuestion<Partial<NewSystemAnswers & AbapOnPremAnswers & SystemSelectionAnswers>>;
31
33
  //# sourceMappingURL=shared-prompts.d.ts.map
@@ -10,6 +10,7 @@ const types_2 = require("../new-system/types");
10
10
  const prompt_helpers_1 = require("../prompt-helpers");
11
11
  const validators_1 = require("../validators");
12
12
  const yeoman_ui_types_1 = require("@sap-devx/yeoman-ui-types");
13
+ const questions_1 = require("../credentials/questions");
13
14
  /**
14
15
  * Convert the system connection scheme (Service Key, Rentrance Ticket, etc) to the store specific authentication type.
15
16
  * Note the absence of CF Discovery, in this case the service key file (UAA) is also used for the Abap connectivity.
@@ -129,7 +130,7 @@ function getUserSystemNameQuestion(connectValidator, promptNamespace) {
129
130
  }
130
131
  return defaultSystemName;
131
132
  },
132
- validate: async (systemName) => {
133
+ validate: async (systemName, previousAnswers) => {
133
134
  if (!systemName) {
134
135
  return false;
135
136
  }
@@ -143,6 +144,7 @@ function getUserSystemNameQuestion(connectValidator, promptNamespace) {
143
144
  defaultSystemName = systemName;
144
145
  isValid = await (0, validators_1.validateSystemName)(systemName);
145
146
  }
147
+ const shouldStoreCreds = !!previousAnswers?.[`${promptNamespacePart}${questions_1.BasicCredentialsPromptNames.storeSystemCredentials}`];
146
148
  if (isValid === true) {
147
149
  // Update or create the BackendSystem with the new system details for persistent storage
148
150
  if (connectValidator.validatedUrl && utils_1.PromptState.odataService.connectedSystem) {
@@ -151,8 +153,8 @@ function getUserSystemNameQuestion(connectValidator, promptNamespace) {
151
153
  name: systemName,
152
154
  url: connectValidator.validatedUrl,
153
155
  client: connectValidator.validatedClient,
154
- username: connectValidator.axiosConfig?.auth?.username,
155
- password: connectValidator.axiosConfig?.auth?.password,
156
+ username: shouldStoreCreds ? connectValidator.axiosConfig?.auth?.username : undefined,
157
+ password: shouldStoreCreds ? connectValidator.axiosConfig?.auth?.password : undefined,
156
158
  serviceKeys: connectValidator.serviceInfo, // This will not be persisted and is only used to determine cached connection equality for CF provided uaa keys
157
159
  userDisplayName: connectValidator.connectedUserName,
158
160
  systemType: (0, store_1.getBackendSystemType)({
@@ -125,7 +125,6 @@ async function getSystemConnectionQuestions(connectionValidator, promptOptions,
125
125
  return (validateSystemSelection(selectedSystemAnswer, connectionValidator, requiredOdataVersion, cachedConnectedSystem) ?? false);
126
126
  },
127
127
  additionalMessages: async (selectedSystem) => {
128
- // Backend systems credentials may need to be updated
129
128
  if (selectedSystem.type === 'backendSystem' &&
130
129
  connectionValidator.systemAuthType === 'basic' &&
131
130
  (await connectionValidator.isAuthRequired())) {
@@ -84,6 +84,10 @@
84
84
  "systemPassword": {
85
85
  "message": "Password"
86
86
  },
87
+ "storeSystemCredentials": {
88
+ "message": "Do you want to store the system credentials?",
89
+ "breadcrumb": "Store Credentials"
90
+ },
87
91
  "systemService": {
88
92
  "message": "Service",
89
93
  "breadcrumb": "Service",
@@ -257,6 +261,7 @@
257
261
  "forUserName": "(for user [{{username}}])",
258
262
  "httpStatus": "HTTP Status {{httpStatus}}",
259
263
  "checkDestinationAuthConfig": "Please check the SAP BTP destination authentication configuration.",
260
- "choiceNameNone": "None"
264
+ "choiceNameNone": "None",
265
+ "passwordStoreWarning": "Passwords are stored in your operating system's credential manager and are protected by its security policies."
261
266
  }
262
267
  }
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.10.0",
4
+ "version": "2.11.1",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/SAP/open-ux-tools.git",
@@ -29,17 +29,17 @@
29
29
  "i18next": "25.3.0",
30
30
  "inquirer-autocomplete-prompt": "2.0.1",
31
31
  "os-name": "4.0.1",
32
- "@sap-ux/axios-extension": "1.24.1",
33
- "@sap-ux/btp-utils": "1.1.4",
34
- "@sap-ux/fiori-generator-shared": "0.13.31",
35
- "@sap-ux/guided-answers-helper": "0.4.0",
36
- "@sap-ux/telemetry": "0.6.36",
37
- "@sap-ux/inquirer-common": "0.9.0",
38
- "@sap-ux/logger": "0.7.0",
39
- "@sap-ux/nodejs-utils": "0.2.7",
40
- "@sap-ux/project-access": "1.32.7",
41
- "@sap-ux/project-input-validator": "0.6.29",
42
- "@sap-ux/store": "1.3.2"
32
+ "@sap-ux/axios-extension": "1.24.2",
33
+ "@sap-ux/btp-utils": "1.1.5",
34
+ "@sap-ux/fiori-generator-shared": "0.13.32",
35
+ "@sap-ux/guided-answers-helper": "0.4.1",
36
+ "@sap-ux/telemetry": "0.6.37",
37
+ "@sap-ux/inquirer-common": "0.9.1",
38
+ "@sap-ux/logger": "0.7.1",
39
+ "@sap-ux/nodejs-utils": "0.2.8",
40
+ "@sap-ux/project-access": "1.32.8",
41
+ "@sap-ux/project-input-validator": "0.6.30",
42
+ "@sap-ux/store": "1.3.3"
43
43
  },
44
44
  "devDependencies": {
45
45
  "@sap-ux/vocabularies-types": "0.13.0",
@@ -48,12 +48,12 @@
48
48
  "@types/inquirer": "8.2.6",
49
49
  "@types/lodash": "4.14.202",
50
50
  "jest-extended": "6.0.0",
51
- "@sap-ux/fiori-generator-shared": "0.13.31",
52
- "@sap-ux/fiori-elements-writer": "2.7.34",
53
- "@sap-ux/fiori-freestyle-writer": "2.4.59",
54
- "@sap-ux/feature-toggle": "0.3.3",
55
- "@sap-ux/odata-service-writer": "0.27.28",
56
- "@sap-ux/cap-config-writer": "0.12.22"
51
+ "@sap-ux/fiori-generator-shared": "0.13.32",
52
+ "@sap-ux/fiori-elements-writer": "2.7.36",
53
+ "@sap-ux/fiori-freestyle-writer": "2.4.60",
54
+ "@sap-ux/feature-toggle": "0.3.4",
55
+ "@sap-ux/odata-service-writer": "0.27.29",
56
+ "@sap-ux/cap-config-writer": "0.12.23"
57
57
  },
58
58
  "engines": {
59
59
  "node": ">=20.x"