@sap-ux/odata-service-inquirer 2.7.3 → 2.8.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/dist/index.d.ts CHANGED
@@ -18,7 +18,7 @@ import { type EntityPromptOptions, type OdataServiceAnswers, type OdataServicePr
18
18
  * @param enableGuidedAnswers - if true, the prompts will use guided answers to help users with validation errors
19
19
  * @param telemetryClient - the telemetry client to use for sending telemetry data
20
20
  * @param isYUI - if true, the prompt is being called from the Yeoman UI extension host
21
- * @param connectedSystem - if available passing an already connected system connection will prevent re-authentication for re-entrance ticket connection types
21
+ * @param connectedSystem - if available passing an already connected system connection will prevent re-authentication for re-entrance ticket and service keys connection types
22
22
  * @returns the prompts used to provide input for odata service generation and a reference to the answers object which will be populated with the user's responses once `inquirer.prompt` returns
23
23
  */
24
24
  declare function getPrompts(promptOptions?: OdataServicePromptOptions, logger?: Logger, enableGuidedAnswers?: boolean, telemetryClient?: ToolsSuiteTelemetryClient, isYUI?: boolean, connectedSystem?: ConnectedSystem): Promise<{
@@ -59,7 +59,7 @@ declare function getEntityRelatedPrompts(metadata: string, templateType: Templat
59
59
  * @param enableGuidedAnswers - if true, the prompts will use guided answers to help users with validation errors
60
60
  * @param telemetryClient - the telemetry client to use for sending telemetry data
61
61
  * @param isYUI - if true, the prompt is being called from the Yeoman UI extension host
62
- * @param connectedSystem - if available passing an already connected system connection will prevent re-authentication for re-entrance ticket connection types
62
+ * @param connectedSystem - if available passing an already connected system connection will prevent re-authentication for re-entrance ticket and service keys connection types
63
63
  * @returns the prompt answers
64
64
  */
65
65
  declare function prompt(adapter: InquirerAdapter, promptOptions?: OdataServicePromptOptions, logger?: Logger, enableGuidedAnswers?: boolean, telemetryClient?: ToolsSuiteTelemetryClient, isYUI?: boolean, connectedSystem?: ConnectedSystem): Promise<OdataServiceAnswers>;
package/dist/index.js CHANGED
@@ -31,7 +31,7 @@ const utils_1 = require("./utils");
31
31
  * @param enableGuidedAnswers - if true, the prompts will use guided answers to help users with validation errors
32
32
  * @param telemetryClient - the telemetry client to use for sending telemetry data
33
33
  * @param isYUI - if true, the prompt is being called from the Yeoman UI extension host
34
- * @param connectedSystem - if available passing an already connected system connection will prevent re-authentication for re-entrance ticket connection types
34
+ * @param connectedSystem - if available passing an already connected system connection will prevent re-authentication for re-entrance ticket and service keys connection types
35
35
  * @returns the prompts used to provide input for odata service generation and a reference to the answers object which will be populated with the user's responses once `inquirer.prompt` returns
36
36
  */
37
37
  async function getPrompts(promptOptions, logger, enableGuidedAnswers = false, telemetryClient, isYUI = false, connectedSystem) {
@@ -98,7 +98,7 @@ function getEntityRelatedPrompts(metadata, templateType, isCapService = false, p
98
98
  * @param enableGuidedAnswers - if true, the prompts will use guided answers to help users with validation errors
99
99
  * @param telemetryClient - the telemetry client to use for sending telemetry data
100
100
  * @param isYUI - if true, the prompt is being called from the Yeoman UI extension host
101
- * @param connectedSystem - if available passing an already connected system connection will prevent re-authentication for re-entrance ticket connection types
101
+ * @param connectedSystem - if available passing an already connected system connection will prevent re-authentication for re-entrance ticket and service keys connection types
102
102
  * @returns the prompt answers
103
103
  */
104
104
  async function prompt(adapter, promptOptions, logger, enableGuidedAnswers, telemetryClient, isYUI = false, connectedSystem) {
@@ -392,8 +392,7 @@ class ConnectionValidator {
392
392
  async createSystemConnection({ axiosConfig, url, serviceInfo, destination, odataVersion, refreshToken }) {
393
393
  this.resetConnectionState();
394
394
  this.resetValidity();
395
- // Handle existing stored service keys for backward compatibility
396
- if (this.systemAuthType === 'reentranceTicket' || serviceInfo) {
395
+ if (this.systemAuthType === 'reentranceTicket' || this.systemAuthType === 'serviceKey') {
397
396
  this._serviceProvider = this.getAbapOnCloudServiceProvider(url, serviceInfo, refreshToken);
398
397
  }
399
398
  else if (destination) {
@@ -508,7 +507,6 @@ class ConnectionValidator {
508
507
  url: new URL(url.pathname, url.origin).toString()
509
508
  });
510
509
  }
511
- // Remains for existing stored service keys (backward compatibility)
512
510
  if (this.systemAuthType === 'serviceKey' && serviceInfo) {
513
511
  return (0, axios_extension_1.createForAbapOnCloud)({
514
512
  environment: axios_extension_1.AbapCloudEnvironment.Standalone,
@@ -539,7 +537,6 @@ class ConnectionValidator {
539
537
  return this.getValidationResultFromStatusCode(200);
540
538
  }
541
539
  try {
542
- // Remains for backwards compatibility with existing systems
543
540
  this.systemAuthType = 'serviceKey';
544
541
  await this.createSystemConnection({ serviceInfo, odataVersion, refreshToken });
545
542
  // Cache the user info
@@ -7,22 +7,25 @@ import { type ServiceAnswer } from '../service-selection';
7
7
  declare const systemUrlPromptName: "abapOnBtp:newSystemUrl";
8
8
  declare const abapOnBtpPromptNames: {
9
9
  readonly abapOnBtpAuthType: "abapOnBtpAuthType";
10
+ readonly serviceKey: "serviceKey";
10
11
  readonly cloudFoundryAbapSystem: "cloudFoundryAbapSystem";
11
12
  };
12
- export type AbapOnBTPType = 'cloudFoundry' | 'reentranceTicket';
13
+ export type AbapOnBTPType = 'cloudFoundry' | 'serviceKey' | 'reentranceTicket';
13
14
  interface AbapOnBtpAnswers extends Partial<OdataServiceAnswers> {
14
15
  [abapOnBtpPromptNames.abapOnBtpAuthType]?: AbapOnBTPType;
15
16
  [systemUrlPromptName]?: string;
17
+ [abapOnBtpPromptNames.serviceKey]?: string;
16
18
  [abapOnBtpPromptNames.cloudFoundryAbapSystem]?: ServiceInstanceInfo;
17
19
  }
18
20
  /**
19
- * Get the questions for the ABAP on BTP system within the VSCode platform. The questions will prompt the user for the system type (Cloud Foundry, Re-entrance Ticket).
21
+ * Get the questions for the ABAP on BTP system within the VSCode platform. The questions will prompt the user for the system type (Cloud Foundry, Service Key, Re-entrance Ticket).
20
22
  *
21
23
  * @param promptOptions The prompt options which control the service selection and system name]
22
- * @param cachedConnectedSystem if available passing an already connected system connection will prevent re-authentication for re-entrance ticket connection types
24
+ * @param cachedConnectedSystem if available passing an already connected system connection will prevent re-authentication for re-entrance ticket and service keys connection types
25
+ * @param serviceKeyToggle Feature toggle to enable/disable the BTP service key option - enabled by default
23
26
  * @returns The list of questions for the ABAP on BTP system
24
27
  */
25
- export declare function getAbapOnBTPSystemQuestions(promptOptions?: OdataServicePromptOptions, cachedConnectedSystem?: ConnectedSystem): Question<AbapOnBtpAnswers & ServiceAnswer>[];
28
+ export declare function getAbapOnBTPSystemQuestions(promptOptions?: OdataServicePromptOptions, cachedConnectedSystem?: ConnectedSystem, serviceKeyToggle?: boolean): Question<AbapOnBtpAnswers & ServiceAnswer>[];
26
29
  /**
27
30
  * Get the Cloud Foundry Abap system discovery prompt. This prompt will list all available ABAP environments in the connected Cloud Foundry space.
28
31
  * If the Cloud Foundry connection fails, a warning message will be displayed.
@@ -30,7 +33,7 @@ export declare function getAbapOnBTPSystemQuestions(promptOptions?: OdataService
30
33
  * @param connectionValidator The connection validator
31
34
  * @param promptNamespace
32
35
  * @param requiredOdataVersion
33
- * @param cachedConnectedSystem if available passing an already connected system connection will prevent re-authentication for re-entrance ticket connection types
36
+ * @param cachedConnectedSystem if available passing an already connected system connection will prevent re-authentication for re-entrance ticket and service keys connection types
34
37
  * @returns The Cloud Foundry ABAP system discovery prompt
35
38
  */
36
39
  export declare function getCFDiscoverPrompts(connectionValidator: ConnectionValidator, promptNamespace?: string, requiredOdataVersion?: OdataVersion, cachedConnectedSystem?: ConnectedSystem): Question[];
@@ -18,21 +18,26 @@ const types_1 = require("../new-system/types");
18
18
  const service_selection_1 = require("../service-selection");
19
19
  const shared_prompts_1 = require("../shared-prompts/shared-prompts");
20
20
  const prompt_helpers_2 = require("../system-selection/prompt-helpers");
21
+ const validators_1 = require("../validators");
22
+ const feature_toggle_1 = require("@sap-ux/feature-toggle");
21
23
  const abapOnBtpPromptNamespace = 'abapOnBtp';
22
24
  const systemUrlPromptName = `${abapOnBtpPromptNamespace}:${types_1.newSystemPromptNames.newSystemUrl}`;
23
25
  const cliCfAbapServicePromptName = 'cliCfAbapService';
24
26
  const abapOnBtpPromptNames = {
25
27
  'abapOnBtpAuthType': 'abapOnBtpAuthType',
28
+ 'serviceKey': 'serviceKey',
26
29
  'cloudFoundryAbapSystem': 'cloudFoundryAbapSystem'
27
30
  };
31
+ const SERVICE_KEY_FEATURE_TOGGLE = 'sap.ux.appGenerator.testBetaFeatures.disableBtpServiceKeyAuth';
28
32
  /**
29
- * Get the questions for the ABAP on BTP system within the VSCode platform. The questions will prompt the user for the system type (Cloud Foundry, Re-entrance Ticket).
33
+ * Get the questions for the ABAP on BTP system within the VSCode platform. The questions will prompt the user for the system type (Cloud Foundry, Service Key, Re-entrance Ticket).
30
34
  *
31
35
  * @param promptOptions The prompt options which control the service selection and system name]
32
- * @param cachedConnectedSystem if available passing an already connected system connection will prevent re-authentication for re-entrance ticket connection types
36
+ * @param cachedConnectedSystem if available passing an already connected system connection will prevent re-authentication for re-entrance ticket and service keys connection types
37
+ * @param serviceKeyToggle Feature toggle to enable/disable the BTP service key option - enabled by default
33
38
  * @returns The list of questions for the ABAP on BTP system
34
39
  */
35
- function getAbapOnBTPSystemQuestions(promptOptions, cachedConnectedSystem) {
40
+ function getAbapOnBTPSystemQuestions(promptOptions, cachedConnectedSystem, serviceKeyToggle = (0, feature_toggle_1.isFeatureEnabled)(SERVICE_KEY_FEATURE_TOGGLE)) {
36
41
  utils_1.PromptState.reset();
37
42
  const connectValidator = new connectionValidator_1.ConnectionValidator();
38
43
  const questions = [];
@@ -41,6 +46,15 @@ function getAbapOnBTPSystemQuestions(promptOptions, cachedConnectedSystem) {
41
46
  name: abapOnBtpPromptNames.abapOnBtpAuthType,
42
47
  choices: [
43
48
  { name: (0, i18n_1.t)('prompts.abapOnBTPType.choiceCloudFoundry'), value: 'cloudFoundry' },
49
+ // Feature toggle the service key option - enabled by default, can be disabled via VS Code settings or ENV
50
+ ...(!serviceKeyToggle
51
+ ? [
52
+ {
53
+ name: (0, i18n_1.t)('prompts.abapOnBTPType.choiceServiceKey'),
54
+ value: 'serviceKey'
55
+ }
56
+ ]
57
+ : []),
44
58
  { name: (0, i18n_1.t)('prompts.abapOnBTPType.choiceReentranceTicket'), value: 'reentranceTicket' }
45
59
  ],
46
60
  message: (0, i18n_1.t)('prompts.abapOnBTPType.message'),
@@ -60,6 +74,10 @@ function getAbapOnBTPSystemQuestions(promptOptions, cachedConnectedSystem) {
60
74
  }
61
75
  return false;
62
76
  })[0]);
77
+ // Service Key file prompt - enabled by default
78
+ if (!serviceKeyToggle) {
79
+ questions.push((0, inquirer_common_1.withCondition)([getServiceKeyPrompt(connectValidator, cachedConnectedSystem)], (answers) => answers?.abapOnBtpAuthType === 'serviceKey')[0]);
80
+ }
63
81
  questions.push(...(0, inquirer_common_1.withCondition)([...getCFDiscoverPrompts(connectValidator, undefined, undefined, cachedConnectedSystem)], (answers) => answers?.abapOnBtpAuthType === 'cloudFoundry'));
64
82
  // New system store name propmt
65
83
  if (promptOptions?.userSystemName?.hide !== true) {
@@ -73,8 +91,8 @@ function getAbapOnBTPSystemQuestions(promptOptions, cachedConnectedSystem) {
73
91
  return questions;
74
92
  }
75
93
  /**
76
- * Validate the service info (returned from cf-tools APIs) for an ABAP on BTP system. This function will validate the connection to the ABAP system and on BAS will create a new destination.
77
- * Updates the prompt state with the connected system to be later used for catalog service selection.
94
+ * Validate the service info (returned from cf-tools APIs) for an ABAP on BTP system. This function will validate the service key file, or on BAS will create a new destination,
95
+ * and validate the connection to the ABAP system. Updates the prompt state with the connected system to be later used for catalog service selection.
78
96
  *
79
97
  * @param abapService the abap service as provided by CF tools {@link ServiceInstanceInfo}
80
98
  * @param connectionValidator connection validator instance
@@ -147,7 +165,7 @@ async function validateCFServiceInfo(abapService, connectionValidator, requiredO
147
165
  * @param connectionValidator The connection validator
148
166
  * @param promptNamespace
149
167
  * @param requiredOdataVersion
150
- * @param cachedConnectedSystem if available passing an already connected system connection will prevent re-authentication for re-entrance ticket connection types
168
+ * @param cachedConnectedSystem if available passing an already connected system connection will prevent re-authentication for re-entrance ticket and service keys connection types
151
169
  * @returns The Cloud Foundry ABAP system discovery prompt
152
170
  */
153
171
  function getCFDiscoverPrompts(connectionValidator, promptNamespace, requiredOdataVersion, cachedConnectedSystem) {
@@ -202,4 +220,46 @@ function getCFDiscoverPrompts(connectionValidator, promptNamespace, requiredOdat
202
220
  }
203
221
  return questions;
204
222
  }
223
+ /**
224
+ * Get the service key prompt for the ABAP on BTP system. This prompt will allow the user to select a service key file from the file system.
225
+ *
226
+ * @param connectionValidator a connection validator instance
227
+ * @param cachedConnectedSystem if available passing an already connected system connection will prevent re-authentication for re-entrance ticket and service keys connection types
228
+ * @returns The service key prompt
229
+ */
230
+ function getServiceKeyPrompt(connectionValidator, cachedConnectedSystem) {
231
+ const question = {
232
+ type: 'input',
233
+ name: abapOnBtpPromptNames.serviceKey,
234
+ message: (0, i18n_1.t)('prompts.serviceKey.message'),
235
+ guiType: 'file-browser',
236
+ guiOptions: {
237
+ hint: (0, i18n_1.t)('prompts.serviceKey.hint'),
238
+ mandatory: true
239
+ },
240
+ validate: async (keyPath) => {
241
+ utils_1.PromptState.resetConnectedSystem();
242
+ const serviceKeyValResult = (0, validators_1.validateServiceKey)(keyPath);
243
+ if (typeof serviceKeyValResult === 'string' || typeof serviceKeyValResult === 'boolean') {
244
+ return serviceKeyValResult;
245
+ }
246
+ // Backend systems validation supports using a cached connections from a previous step execution to prevent re-authentication (e.g. re-opening a browser window)
247
+ // In case the user has changed the URL, do not use the cached connection.
248
+ if (cachedConnectedSystem &&
249
+ cachedConnectedSystem.backendSystem?.url === serviceKeyValResult.url &&
250
+ JSON.stringify(cachedConnectedSystem.backendSystem.serviceKeys.uaa) ===
251
+ JSON.stringify(serviceKeyValResult.uaa)) {
252
+ connectionValidator.setConnectedSystem(cachedConnectedSystem);
253
+ }
254
+ const connectValResult = await connectionValidator.validateServiceInfo(serviceKeyValResult);
255
+ if (connectValResult === true && connectionValidator.serviceProvider) {
256
+ utils_1.PromptState.odataService.connectedSystem = {
257
+ serviceProvider: (0, utils_1.removeCircularFromServiceProvider)(connectionValidator.serviceProvider)
258
+ };
259
+ }
260
+ return connectValResult;
261
+ }
262
+ };
263
+ return question;
264
+ }
205
265
  //# sourceMappingURL=questions.js.map
@@ -49,7 +49,6 @@ async function connectWithBackendSystem(backendKey, connectionValidator, require
49
49
  });
50
50
  }
51
51
  else if (backendSystem.serviceKeys) {
52
- // Handle existing stored service keys for backward compatibility
53
52
  connectValResult = await connectionValidator.validateServiceInfo(backendSystem.serviceKeys, (0, utils_1.convertODataVersionType)(requiredOdataVersion), backendSystem.refreshToken);
54
53
  }
55
54
  else if (backendSystem.authenticationType === 'basic' || !backendSystem.authenticationType) {
@@ -3,7 +3,7 @@ import { type ConnectedSystem, type OdataServicePromptOptions, type OdataService
3
3
  * Get the prompts for the OData service inquirer.
4
4
  *
5
5
  * @param promptOptions - options that can control some of the prompt behavior. See {@link OdataServicePromptOptions} for details
6
- * @param connectedSystem - if available passing an already connected system connection will prevent re-authentication for re-entrance ticket connection types
6
+ * @param connectedSystem - if available passing an already connected system connection will prevent re-authentication for re-entrance ticket and service keys connection types
7
7
  * @returns the prompts used to provide input for OData service generation
8
8
  */
9
9
  export declare function getQuestions(promptOptions?: OdataServicePromptOptions, connectedSystem?: ConnectedSystem): Promise<OdataServiceQuestion[]>;
@@ -13,7 +13,7 @@ const prompt_helpers_1 = require("./prompt-helpers");
13
13
  * Get the prompts for the OData service inquirer.
14
14
  *
15
15
  * @param promptOptions - options that can control some of the prompt behavior. See {@link OdataServicePromptOptions} for details
16
- * @param connectedSystem - if available passing an already connected system connection will prevent re-authentication for re-entrance ticket connection types
16
+ * @param connectedSystem - if available passing an already connected system connection will prevent re-authentication for re-entrance ticket and service keys connection types
17
17
  * @returns the prompts used to provide input for OData service generation
18
18
  */
19
19
  async function getQuestions(promptOptions, connectedSystem) {
@@ -110,8 +110,15 @@
110
110
  "abapOnBTPType": {
111
111
  "message": "ABAP environment definition source",
112
112
  "choiceReentranceTicket": "Use Reentrance Ticket",
113
+ "choiceServiceKey": "Upload a Service Key File",
113
114
  "choiceCloudFoundry": "Discover a Cloud Foundry Service"
114
115
  },
116
+ "serviceKey": {
117
+ "message": "Service Key File Path",
118
+ "hint": "Select a local file that defines the service connection for an ABAP Environment on SAP Business Technology Platform.",
119
+ "incompleteServiceKeyInfo": "The service keys file does not contain the required information. Check the file is valid and try again.",
120
+ "unparseableServiceKey": "The service keys file does not contain a valid JSON format. Check the formatting and try again."
121
+ },
115
122
  "cloudFoundryAbapSystem": {
116
123
  "message": "ABAP environment",
117
124
  "hint": "Enter the name of the Cloud Foundry service that contains the ABAP Environment instance."
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.7.3",
4
+ "version": "2.8.1",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/SAP/open-ux-tools.git",
@@ -29,12 +29,12 @@
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.22.6",
32
+ "@sap-ux/axios-extension": "1.22.7",
33
33
  "@sap-ux/btp-utils": "1.1.1",
34
- "@sap-ux/fiori-generator-shared": "0.13.12",
34
+ "@sap-ux/fiori-generator-shared": "0.13.13",
35
35
  "@sap-ux/guided-answers-helper": "0.4.0",
36
36
  "@sap-ux/telemetry": "0.6.19",
37
- "@sap-ux/inquirer-common": "0.7.38",
37
+ "@sap-ux/inquirer-common": "0.7.40",
38
38
  "@sap-ux/logger": "0.7.0",
39
39
  "@sap-ux/nodejs-utils": "0.2.3",
40
40
  "@sap-ux/project-access": "1.30.13",
@@ -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.12",
52
- "@sap-ux/fiori-elements-writer": "2.6.5",
53
- "@sap-ux/fiori-freestyle-writer": "2.4.40",
54
- "@sap-ux/feature-toggle": "0.3.0",
51
+ "@sap-ux/fiori-generator-shared": "0.13.13",
52
+ "@sap-ux/fiori-elements-writer": "2.7.2",
53
+ "@sap-ux/fiori-freestyle-writer": "2.4.41",
54
+ "@sap-ux/feature-toggle": "0.3.1",
55
55
  "@sap-ux/odata-service-writer": "0.27.18",
56
- "@sap-ux/cap-config-writer": "0.12.3"
56
+ "@sap-ux/cap-config-writer": "0.12.4"
57
57
  },
58
58
  "engines": {
59
59
  "node": ">=20.x"