@sap-ux/odata-service-inquirer 2.9.1 → 2.9.3

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.
@@ -174,7 +174,22 @@ function getCFDiscoverPrompts(connectionValidator, promptNamespace, requiredOdat
174
174
  message: (0, i18n_1.t)('prompts.cloudFoundryAbapSystem.message'),
175
175
  validate: async (abapService) => {
176
176
  if (abapService) {
177
- return await validateCFServiceInfo(abapService, connectionValidator, requiredOdataVersion, (0, utils_1.getPromptHostEnvironment)() === fiori_generator_shared_1.hostEnvironment.cli, cachedConnectedSystem);
177
+ const valResult = await validateCFServiceInfo(abapService, connectionValidator, requiredOdataVersion, (0, utils_1.getPromptHostEnvironment)() === fiori_generator_shared_1.hostEnvironment.cli, cachedConnectedSystem);
178
+ // If the system exists already stop progress
179
+ if (!(0, btp_utils_1.isAppStudio)() && valResult === true && connectionValidator.validatedUrl) {
180
+ const existingBackend = (0, utils_1.isBackendSystemKeyExisting)(utils_1.PromptState.backendSystemsCache, connectionValidator.validatedUrl, connectionValidator.validatedClient);
181
+ if (existingBackend) {
182
+ // Invalidate the connection to prevent service selection
183
+ // This is a temp workaround until multiple systems with the same url/client key is supported
184
+ // This is necessary since the ServiceInstanceInfo does not include url/client information
185
+ connectionValidator.resetConnectionState(true);
186
+ // Cannot create a new store system with the same key
187
+ return (0, i18n_1.t)('prompts.validationMessages.backendSystemExistsWarning', {
188
+ backendName: existingBackend.name
189
+ });
190
+ }
191
+ }
192
+ return valResult;
178
193
  }
179
194
  const errorType = prompt_helpers_1.errorHandler.getCurrentErrorType();
180
195
  if (errorType === inquirer_common_1.ERROR_TYPE.NO_ABAP_ENVS) {
@@ -47,7 +47,7 @@ function getAbapOnPremSystemQuestions(systemNamePromptOptions, connectionValidat
47
47
  // This allows re-usability of the credentials prompts where a client prompt was not used (client was loaded from store).
48
48
  const sapClientRef = { sapClient: undefined, isValid: true };
49
49
  const questions = [
50
- (0, shared_prompts_1.getSystemUrlQuestion)(connectValidator, abapOnPremPromptNamespace, requiredOdataVersion),
50
+ (0, shared_prompts_1.getSystemUrlQuestion)(connectValidator, abapOnPremPromptNamespace, requiredOdataVersion, undefined, false),
51
51
  {
52
52
  type: 'input',
53
53
  name: abapOnPremPromptNames.sapClient,
@@ -55,11 +55,20 @@ function getAbapOnPremSystemQuestions(systemNamePromptOptions, connectionValidat
55
55
  guiOptions: {
56
56
  breadcrumb: (0, i18n_1.t)('prompts.sapClient.breadcrumb')
57
57
  },
58
- validate: (client) => {
58
+ validate: (client, prevAnswers) => {
59
59
  const valRes = (0, project_input_validator_1.validateClient)(client);
60
60
  if (valRes === true) {
61
61
  sapClientRef.sapClient = client;
62
62
  sapClientRef.isValid = true;
63
+ // If we also have a system url, warn about existing stored system overwrite
64
+ if (prevAnswers?.[systemUrlPromptName]) {
65
+ const existingBackend = (0, utils_1.isBackendSystemKeyExisting)(utils_1.PromptState.backendSystemsCache, prevAnswers[systemUrlPromptName], client);
66
+ if (existingBackend) {
67
+ return (0, i18n_1.t)('prompts.validationMessages.backendSystemExistsWarning', {
68
+ backendName: existingBackend.name
69
+ });
70
+ }
71
+ }
63
72
  return true;
64
73
  }
65
74
  sapClientRef.sapClient = undefined;
@@ -14,9 +14,10 @@ import { type NewSystemAnswers } from '../new-system/types';
14
14
  * @param promptNamespace The namespace for the prompt, used to identify the prompt instance and namespaced answers.
15
15
  * @param requiredOdataVersion The required OData version for the system connection, only catalogs supporting the specifc odata version will be used.
16
16
  * @param cachedConnectedSystem An existing connection may be passed which will prevent reauthentication
17
+ * @param showExistingSystemWarning if the url exists in secure store a validation message will be returned
17
18
  * @returns the system url prompt
18
19
  */
19
- export declare function getSystemUrlQuestion<T extends Answers>(connectValidator: ConnectionValidator, promptNamespace?: string, requiredOdataVersion?: OdataVersion, cachedConnectedSystem?: ConnectedSystem): InputQuestion<T>;
20
+ export declare function getSystemUrlQuestion<T extends Answers>(connectValidator: ConnectionValidator, promptNamespace?: string, requiredOdataVersion?: OdataVersion, cachedConnectedSystem?: ConnectedSystem, showExistingSystemWarning?: boolean): InputQuestion<T>;
20
21
  /**
21
22
  * Get a prompt for new system name.
22
23
  *
@@ -36,9 +36,10 @@ function systemAuthTypeToAuthenticationType(systemAuthType) {
36
36
  * @param promptNamespace The namespace for the prompt, used to identify the prompt instance and namespaced answers.
37
37
  * @param requiredOdataVersion The required OData version for the system connection, only catalogs supporting the specifc odata version will be used.
38
38
  * @param cachedConnectedSystem An existing connection may be passed which will prevent reauthentication
39
+ * @param showExistingSystemWarning if the url exists in secure store a validation message will be returned
39
40
  * @returns the system url prompt
40
41
  */
41
- function getSystemUrlQuestion(connectValidator, promptNamespace, requiredOdataVersion, cachedConnectedSystem) {
42
+ function getSystemUrlQuestion(connectValidator, promptNamespace, requiredOdataVersion, cachedConnectedSystem, showExistingSystemWarning = true) {
42
43
  const promptName = `${promptNamespace ? promptNamespace + ':' : ''}${types_2.newSystemPromptNames.newSystemUrl}`;
43
44
  const newSystemUrlQuestion = {
44
45
  type: 'input',
@@ -58,7 +59,7 @@ function getSystemUrlQuestion(connectValidator, promptNamespace, requiredOdataVe
58
59
  cachedConnectedSystem.backendSystem?.authenticationType === 'reentranceTicket') {
59
60
  connectValidator.setConnectedSystem(cachedConnectedSystem);
60
61
  }
61
- else {
62
+ else if (showExistingSystemWarning) {
62
63
  const existingBackend = (0, utils_1.isBackendSystemKeyExisting)(utils_1.PromptState.backendSystemsCache, url);
63
64
  if (existingBackend) {
64
65
  // Not a cached connection so re-validate as new backend system entry
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.9.1",
4
+ "version": "2.9.3",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/SAP/open-ux-tools.git",
@@ -31,15 +31,15 @@
31
31
  "os-name": "4.0.1",
32
32
  "@sap-ux/axios-extension": "1.23.0",
33
33
  "@sap-ux/btp-utils": "1.1.4",
34
- "@sap-ux/fiori-generator-shared": "0.13.24",
34
+ "@sap-ux/fiori-generator-shared": "0.13.25",
35
35
  "@sap-ux/guided-answers-helper": "0.4.0",
36
- "@sap-ux/telemetry": "0.6.29",
37
- "@sap-ux/inquirer-common": "0.8.1",
36
+ "@sap-ux/telemetry": "0.6.30",
37
+ "@sap-ux/inquirer-common": "0.8.2",
38
38
  "@sap-ux/logger": "0.7.0",
39
39
  "@sap-ux/nodejs-utils": "0.2.7",
40
40
  "@sap-ux/project-access": "1.32.4",
41
41
  "@sap-ux/project-input-validator": "0.6.26",
42
- "@sap-ux/store": "1.2.0"
42
+ "@sap-ux/store": "1.2.1"
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.24",
52
- "@sap-ux/fiori-elements-writer": "2.7.25",
53
- "@sap-ux/fiori-freestyle-writer": "2.4.52",
51
+ "@sap-ux/fiori-generator-shared": "0.13.25",
52
+ "@sap-ux/fiori-elements-writer": "2.7.26",
53
+ "@sap-ux/fiori-freestyle-writer": "2.4.53",
54
54
  "@sap-ux/feature-toggle": "0.3.2",
55
55
  "@sap-ux/odata-service-writer": "0.27.25",
56
- "@sap-ux/cap-config-writer": "0.12.15"
56
+ "@sap-ux/cap-config-writer": "0.12.16"
57
57
  },
58
58
  "engines": {
59
59
  "node": ">=20.x"