@sap-ux/odata-service-inquirer 2.19.0 → 2.19.2

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.
@@ -15,6 +15,7 @@ interface Validity {
15
15
  canSkipCertError?: boolean;
16
16
  }
17
17
  export type SystemAuthType = 'serviceKey' | 'reentranceTicket' | 'basic' | 'unknown';
18
+ export type ConnectionType = 'abap_catalog' | 'odata_path';
18
19
  /**
19
20
  * Class that can be used to determine the connectivity using a service url, system url, or service info (UAA Key details) or reentrance ticket.
20
21
  * This will determine if if the service/catalog is reachable, authentication is required and generates ting messages to guide the user.
@@ -161,6 +162,7 @@ export declare class ConnectionValidator {
161
162
  * @param options.ignoreCertError ignore some certificate errors
162
163
  * @param options.isSystem if true, the url will be treated as a system url rather than a service url
163
164
  * @param options.odataVersion if specified will restrict catalog requests to only the specified odata version
165
+ * @param options.connectType if specified will determine how a system is authenticated, catalog or metadata request
164
166
  * @returns the status code or error returned by the connection attempt
165
167
  * @throws an error if the connection attempt fails and the error is a 500 on App Studio or a non-axios error is caught
166
168
  */
@@ -206,6 +208,7 @@ export declare class ConnectionValidator {
206
208
  * @param connectConfig.serviceInfo the service info
207
209
  * @param connectConfig.odataVersion the odata version to restrict the catalog requests if only a specific version is required
208
210
  * @param connectConfig.destination the destination to connect with
211
+ * @param connectConfig.connectType Override the default connection approach if specified
209
212
  * @throws an error if the connection attempt fails, callers should handle the error
210
213
  */
211
214
  private createSystemConnection;
@@ -268,25 +271,26 @@ export declare class ConnectionValidator {
268
271
  */
269
272
  private validateOdataServiceDestination;
270
273
  /**
271
- * Validates an odata service url format as well as its reachability. Note if this function returns true, this is only an indication that the system is reachable
274
+ * Validates a url format as well as its reachability. Note if this function returns true, this is only an indication that the url or host is reachable
272
275
  * not that a connection has been established. The connection may require separate authentication or other steps (it may be reachable but a cert error was returned).
273
276
  *
274
277
  * @param serviceUrl the url to validate, may be a system or service url.
275
- * Note that if systemAuthType is specified, the url will be treated as a system url (only the origin will be considered)
276
278
  * @param options options for the connection validation
277
279
  * @param options.ignoreCertError ignore some certificate errors
278
280
  * @param options.forceReValidation force re-validation of the url
279
281
  * @param options.isSystem if true, the url will be treated as a system url rather than a service url, this value is retained for subsequent calls
280
282
  * @param options.odataVersion if specified will restrict catalog requests to only the specified odata version
281
283
  * @param options.systemAuthType the system auth type used to create system connections, if not specified or `isSystem` is false or undefined, `basic` is assumed
284
+ * @param options.connectType if specified will be used to determine the endpoint used for authentication
282
285
  * @returns true if the url is reachable, false if not, or an error message string
283
286
  */
284
- validateUrl(serviceUrl: string, { ignoreCertError, forceReValidation, isSystem, odataVersion, systemAuthType }?: {
287
+ validateUrl(serviceUrl: string, { ignoreCertError, forceReValidation, isSystem, odataVersion, systemAuthType, connectType }?: {
285
288
  ignoreCertError?: boolean;
286
289
  forceReValidation?: boolean;
287
290
  isSystem?: boolean;
288
291
  odataVersion?: ODataVersion;
289
292
  systemAuthType?: SystemAuthType;
293
+ connectType?: ConnectionType;
290
294
  }): Promise<ValidationResult>;
291
295
  /**
292
296
  * Sets the instance validity state based on the status code and returns true if the status code indicates that the URL was reachable.
@@ -330,13 +334,15 @@ export declare class ConnectionValidator {
330
334
  * @param options.isSystem if true, the url will be treated as a system url rather than a service url
331
335
  * @param options.sapClient the sap client to use for the connection
332
336
  * @param options.odataVersion if specified will restrict catalog requests to only the specified odata version
337
+ * @param options.connectType if specified this will determine how a connection is authenticated, catalog or service metadata, overiding the default approach
333
338
  * @returns true if the authentication is successful, false if not, or an error message string
334
339
  */
335
- validateAuth(url: string, username?: string, password?: string, { ignoreCertError, sapClient, odataVersion, isSystem }?: {
340
+ validateAuth(url: string, username?: string, password?: string, { ignoreCertError, sapClient, odataVersion, isSystem, connectType }?: {
336
341
  ignoreCertError?: boolean;
337
342
  odataVersion?: ODataVersion;
338
343
  sapClient?: string;
339
344
  isSystem?: boolean;
345
+ connectType?: ConnectionType;
340
346
  }): Promise<{
341
347
  valResult: ValidationResult;
342
348
  errorType?: ERROR_TYPE;
@@ -242,10 +242,11 @@ class ConnectionValidator {
242
242
  * @param options.ignoreCertError ignore some certificate errors
243
243
  * @param options.isSystem if true, the url will be treated as a system url rather than a service url
244
244
  * @param options.odataVersion if specified will restrict catalog requests to only the specified odata version
245
+ * @param options.connectType if specified will determine how a system is authenticated, catalog or metadata request
245
246
  * @returns the status code or error returned by the connection attempt
246
247
  * @throws an error if the connection attempt fails and the error is a 500 on App Studio or a non-axios error is caught
247
248
  */
248
- async checkUrl(url, username, password, { ignoreCertError = false, isSystem = false, odataVersion } = {}) {
249
+ async checkUrl(url, username, password, { ignoreCertError = false, isSystem = false, odataVersion, connectType } = {}) {
249
250
  const isBAS = (0, btp_utils_1.isAppStudio)();
250
251
  try {
251
252
  // Auto add trailing '/' to path
@@ -260,10 +261,13 @@ class ConnectionValidator {
260
261
  }
261
262
  const axiosConfig = this.createAxiosConfig(url, ignoreCertError, username, password);
262
263
  if (isSystem) {
263
- await this.createSystemConnection({ axiosConfig, url, odataVersion });
264
- const systemInfo = await this.serviceProvider.getSystemInfo();
265
- this._connectedUserName = systemInfo?.userName;
266
- this._connectedSystemName = systemInfo?.systemID;
264
+ await this.createSystemConnection({ axiosConfig, url, odataVersion, connectType });
265
+ // For systems (dest or backend systems) using a service endpoint for auth skip this call
266
+ if (connectType !== 'odata_path') {
267
+ const systemInfo = await this.serviceProvider.getSystemInfo();
268
+ this._connectedUserName = systemInfo?.userName;
269
+ this._connectedSystemName = systemInfo?.systemID;
270
+ }
267
271
  }
268
272
  else {
269
273
  // Full service URL
@@ -392,9 +396,10 @@ class ConnectionValidator {
392
396
  * @param connectConfig.serviceInfo the service info
393
397
  * @param connectConfig.odataVersion the odata version to restrict the catalog requests if only a specific version is required
394
398
  * @param connectConfig.destination the destination to connect with
399
+ * @param connectConfig.connectType Override the default connection approach if specified
395
400
  * @throws an error if the connection attempt fails, callers should handle the error
396
401
  */
397
- async createSystemConnection({ axiosConfig, url, serviceInfo, destination, odataVersion }) {
402
+ async createSystemConnection({ axiosConfig, url, serviceInfo, destination, odataVersion, connectType = `abap_catalog` }) {
398
403
  this.resetConnectionState(true);
399
404
  if (this.systemAuthType === 'reentranceTicket' || this.systemAuthType === 'serviceKey') {
400
405
  this._serviceProvider = this.getAbapOnCloudServiceProvider(url, serviceInfo);
@@ -419,24 +424,34 @@ class ConnectionValidator {
419
424
  if (this._serviceProvider) {
420
425
  logger_helper_1.default.attachAxiosLogger(this._serviceProvider.interceptors);
421
426
  }
422
- if (!odataVersion || odataVersion === axios_extension_1.ODataVersion.v2) {
423
- this._catalogV2 = this._serviceProvider.catalog(axios_extension_1.ODataVersion.v2);
424
- }
425
- if (!odataVersion || odataVersion === axios_extension_1.ODataVersion.v4) {
426
- this._catalogV4 = this._serviceProvider.catalog(axios_extension_1.ODataVersion.v4);
427
- }
428
- let v4Requested = false;
429
- try {
430
- if (this._catalogV2) {
431
- await this._catalogV2?.listServices();
427
+ if (connectType === 'abap_catalog') {
428
+ if (!odataVersion || odataVersion === axios_extension_1.ODataVersion.v2) {
429
+ this._catalogV2 = this._serviceProvider.catalog(axios_extension_1.ODataVersion.v2);
430
+ }
431
+ if (!odataVersion || odataVersion === axios_extension_1.ODataVersion.v4) {
432
+ this._catalogV4 = this._serviceProvider.catalog(axios_extension_1.ODataVersion.v4);
433
+ }
434
+ let v4Requested = false;
435
+ try {
436
+ if (this._catalogV2) {
437
+ await this._catalogV2?.listServices();
438
+ }
439
+ else if (this._catalogV4) {
440
+ v4Requested = true;
441
+ await this._catalogV4?.listServices();
442
+ }
432
443
  }
433
- else if (this._catalogV4) {
434
- v4Requested = true;
435
- await this._catalogV4?.listServices();
444
+ catch (error) {
445
+ await this.handleCatalogError(error, v4Requested);
436
446
  }
437
447
  }
438
- catch (error) {
439
- await this.handleCatalogError(error, v4Requested);
448
+ else if (connectType === 'odata_path' && url) {
449
+ // System (backend system or destination) that uses a service for auth since catalog may not be accessible
450
+ // No need to validate service version here as it will be validated by the service prompt
451
+ // Here we only validate connectivity by throwing and handling request errors
452
+ logger_helper_1.default.logger.debug(`Using service request: ${url} to validate authentication.`);
453
+ this._odataService = this._serviceProvider.service(`${url?.pathname}`);
454
+ await this._odataService.get('');
440
455
  }
441
456
  }
442
457
  /**
@@ -508,7 +523,7 @@ class ConnectionValidator {
508
523
  if (this.systemAuthType === 'reentranceTicket' && url) {
509
524
  return (0, axios_extension_1.createForAbapOnCloud)({
510
525
  environment: axios_extension_1.AbapCloudEnvironment.EmbeddedSteampunk,
511
- url: new URL(url.pathname, url.origin).toString(),
526
+ url: url.origin,
512
527
  logger: logger_helper_1.default.logger
513
528
  });
514
529
  }
@@ -572,11 +587,14 @@ class ConnectionValidator {
572
587
  // So while we actually dont know we assume its basic for now since thats the only supported mechanism
573
588
  this.systemAuthType = destination.Authentication === btp_utils_1.Authentication.NO_AUTHENTICATION ? 'basic' : 'unknown';
574
589
  // Since a destination may be a system or a service connection, we need to determine the connection request (catalog or service)
575
- if ((0, btp_utils_1.isFullUrlDestination)(destination) || (0, btp_utils_1.isPartialUrlDestination)(destination)) {
590
+ if ((0, btp_utils_1.isFullUrlDestination)(destination) || (0, btp_utils_1.isPartialUrlDestination)(destination) || servicePath) {
576
591
  return await this.validateOdataServiceDestination(destination, servicePath);
577
592
  }
578
593
  else {
579
- await this.createSystemConnection({ destination, odataVersion });
594
+ await this.createSystemConnection({
595
+ destination,
596
+ odataVersion
597
+ });
580
598
  }
581
599
  return {
582
600
  valResult: this.getValidationResultFromStatusCode(200)
@@ -642,20 +660,20 @@ class ConnectionValidator {
642
660
  };
643
661
  }
644
662
  /**
645
- * Validates an odata service url format as well as its reachability. Note if this function returns true, this is only an indication that the system is reachable
663
+ * Validates a url format as well as its reachability. Note if this function returns true, this is only an indication that the url or host is reachable
646
664
  * not that a connection has been established. The connection may require separate authentication or other steps (it may be reachable but a cert error was returned).
647
665
  *
648
666
  * @param serviceUrl the url to validate, may be a system or service url.
649
- * Note that if systemAuthType is specified, the url will be treated as a system url (only the origin will be considered)
650
667
  * @param options options for the connection validation
651
668
  * @param options.ignoreCertError ignore some certificate errors
652
669
  * @param options.forceReValidation force re-validation of the url
653
670
  * @param options.isSystem if true, the url will be treated as a system url rather than a service url, this value is retained for subsequent calls
654
671
  * @param options.odataVersion if specified will restrict catalog requests to only the specified odata version
655
672
  * @param options.systemAuthType the system auth type used to create system connections, if not specified or `isSystem` is false or undefined, `basic` is assumed
673
+ * @param options.connectType if specified will be used to determine the endpoint used for authentication
656
674
  * @returns true if the url is reachable, false if not, or an error message string
657
675
  */
658
- async validateUrl(serviceUrl, { ignoreCertError = false, forceReValidation = false, isSystem = false, odataVersion, systemAuthType } = {}) {
676
+ async validateUrl(serviceUrl, { ignoreCertError = false, forceReValidation = false, isSystem = false, odataVersion, systemAuthType, connectType } = {}) {
659
677
  if (this.isEmptyString(serviceUrl)) {
660
678
  this.resetValidity();
661
679
  this.validity.urlFormat = false;
@@ -671,10 +689,11 @@ class ConnectionValidator {
671
689
  if (url.origin === 'null') {
672
690
  return (0, i18n_1.t)('errors.invalidUrl', { input: serviceUrl });
673
691
  }
674
- // Dont allow non origin URLs in for re-entrance tickets and system URL's as the error handling would become complex to analyize.
692
+ // Unless connection type is explicitly `odata_path`, dont allow non origin URLs in for re-entrance tickets and system URL's as the error handling would become complex to analyize. If connectType is `odata_path` only the origin will be used to auth and store backend connections.
675
693
  // The connection may succeed but later we will get auth errors since axios-extension does not validate this.
676
- // The new system name would also include the additional paths which would not make sense and would cause the issue when storing the system.
677
- if ((this.systemAuthType === 'reentranceTicket' || isSystem) &&
694
+ // The new system name would also include the additional paths which would not make sense and would cause an issue when storing the system.
695
+ if (connectType !== 'odata_path' &&
696
+ (this.systemAuthType === 'reentranceTicket' || isSystem) &&
678
697
  !(url.pathname.length === 0 || url.pathname === '/')) {
679
698
  return (0, i18n_1.t)('prompts.validationMessages.systemUrlOriginOnlyWarning');
680
699
  }
@@ -690,11 +709,11 @@ class ConnectionValidator {
690
709
  // New URL so reset the validity
691
710
  this.resetValidity();
692
711
  }
693
- // Ignore path if a system url
694
712
  const status = await this.checkUrl(url, undefined, undefined, {
695
713
  ignoreCertError,
696
714
  isSystem,
697
- odataVersion
715
+ odataVersion,
716
+ connectType
698
717
  });
699
718
  logger_helper_1.default.logger.debug(`ConnectionValidator.validateUrl() - status: ${status}; url: ${serviceUrl}`);
700
719
  this.validity.urlFormat = true;
@@ -837,9 +856,10 @@ class ConnectionValidator {
837
856
  * @param options.isSystem if true, the url will be treated as a system url rather than a service url
838
857
  * @param options.sapClient the sap client to use for the connection
839
858
  * @param options.odataVersion if specified will restrict catalog requests to only the specified odata version
859
+ * @param options.connectType if specified this will determine how a connection is authenticated, catalog or service metadata, overiding the default approach
840
860
  * @returns true if the authentication is successful, false if not, or an error message string
841
861
  */
842
- async validateAuth(url, username, password, { ignoreCertError = false, sapClient, odataVersion, isSystem = false } = {}) {
862
+ async validateAuth(url, username, password, { ignoreCertError = false, sapClient, odataVersion, isSystem = false, connectType } = {}) {
843
863
  if (!url) {
844
864
  return { valResult: false };
845
865
  }
@@ -852,7 +872,8 @@ class ConnectionValidator {
852
872
  const status = await this.checkUrl(urlObject, username, password, {
853
873
  ignoreCertError: ignoreCertError,
854
874
  isSystem,
855
- odataVersion
875
+ odataVersion,
876
+ connectType
856
877
  });
857
878
  logger_helper_1.default.logger.debug(`ConnectionValidator.validateAuth() - status: ${status}; url: ${url}`);
858
879
  // Since an exception was not thrown, this is a valid url
@@ -88,7 +88,7 @@ function getSystemServiceQuestion(connectValidator, promptNamespace, promptOptio
88
88
  }
89
89
  }
90
90
  else {
91
- logger_helper_1.default.logger.error((0, i18n_1.t)('error.noCatalogOrServiceAvailable'));
91
+ logger_helper_1.default.logger.error((0, i18n_1.t)('errors.noCatalogOrServiceAvailable'));
92
92
  }
93
93
  }
94
94
  return serviceChoices;
@@ -21,9 +21,10 @@ export type SystemSelectionAnswerType = {
21
21
  * @param connectionValidator the connection validator to use for the connection
22
22
  * @param requiredOdataVersion the required OData version for the service, this will be used to narrow the catalog service connections
23
23
  * @param cachedConnectedSystem - if available passing an already connected system connection will prevent re-authentication for re-entrance ticket and service keys connection types
24
+ * @param connectPath if specified will be used as the authentication path, typically a service path
24
25
  * @returns the validation result of the backend system connection
25
26
  */
26
- export declare function connectWithBackendSystem(backendKey: BackendSystemKey, connectionValidator: ConnectionValidator, requiredOdataVersion?: OdataVersion, cachedConnectedSystem?: ConnectedSystem): Promise<ValidationResult>;
27
+ export declare function connectWithBackendSystem(backendKey: BackendSystemKey, connectionValidator: ConnectionValidator, requiredOdataVersion?: OdataVersion, cachedConnectedSystem?: ConnectedSystem, connectPath?: string): Promise<ValidationResult>;
27
28
  /**
28
29
  * Connects to the specified destination and validates the connection.
29
30
  * Note that a destination may be a system or a service connection.
@@ -27,9 +27,10 @@ exports.CfAbapEnvServiceChoice = 'cfAbapEnvService';
27
27
  * @param connectionValidator the connection validator to use for the connection
28
28
  * @param requiredOdataVersion the required OData version for the service, this will be used to narrow the catalog service connections
29
29
  * @param cachedConnectedSystem - if available passing an already connected system connection will prevent re-authentication for re-entrance ticket and service keys connection types
30
+ * @param connectPath if specified will be used as the authentication path, typically a service path
30
31
  * @returns the validation result of the backend system connection
31
32
  */
32
- async function connectWithBackendSystem(backendKey, connectionValidator, requiredOdataVersion, cachedConnectedSystem) {
33
+ async function connectWithBackendSystem(backendKey, connectionValidator, requiredOdataVersion, cachedConnectedSystem, connectPath) {
33
34
  // Create a new connection with the selected system
34
35
  utils_1.PromptState.resetConnectedSystem();
35
36
  let connectValResult = false;
@@ -41,28 +42,36 @@ async function connectWithBackendSystem(backendKey, connectionValidator, require
41
42
  if (cachedConnectedSystem && cachedConnectedSystem.backendSystem?.url === backendSystem.url) {
42
43
  connectionValidator.setConnectedSystem(cachedConnectedSystem);
43
44
  }
45
+ // If an alternative connection path is specified use this instead of the just the origin (this will imply service auth instead of catalog)
46
+ const backendSystemUrl = new URL(backendSystem.url);
47
+ let connectUrl = backendSystemUrl.origin;
48
+ if (connectPath) {
49
+ connectUrl = new URL(connectPath, backendSystemUrl.origin).toString();
50
+ }
44
51
  // Assumption: non-BAS systems are BackendSystems
45
52
  if (backendSystem.authenticationType === 'reentranceTicket') {
46
53
  // Since we previously allowed paths in the stored backend system URLs for Cloud systems, we need to strip them (only use origin in the validator).
47
- const backendSystemUrl = new URL(backendSystem.url);
48
54
  if (backendSystemUrl.pathname !== '/') {
49
55
  logger_helper_1.default.logger.warn((0, i18n_1.t)('warnings.storedSystemUrlPathNotSupported', { systemUrl: backendSystem.url }));
50
56
  }
51
- connectValResult = await connectionValidator.validateUrl(backendSystemUrl.origin, {
57
+ connectValResult = await connectionValidator.validateUrl(connectUrl, {
52
58
  isSystem: true,
53
59
  odataVersion: (0, utils_1.convertODataVersionType)(requiredOdataVersion),
54
- systemAuthType: 'reentranceTicket'
60
+ systemAuthType: 'reentranceTicket',
61
+ connectType: connectPath ? 'odata_path' : undefined // Assumption that if a connection path is provided its an odata service endpoint
55
62
  });
56
63
  }
57
64
  else if (backendSystem.serviceKeys) {
65
+ // Legacy backend system support
58
66
  connectValResult = await connectionValidator.validateServiceInfo(backendSystem.serviceKeys, (0, utils_1.convertODataVersionType)(requiredOdataVersion));
59
67
  }
60
68
  else if (backendSystem.authenticationType === 'basic' || !backendSystem.authenticationType) {
61
69
  let errorType;
62
- ({ valResult: connectValResult, errorType } = await connectionValidator.validateAuth(backendSystem.url, backendSystem.username, backendSystem.password, {
70
+ ({ valResult: connectValResult, errorType } = await connectionValidator.validateAuth(connectUrl, backendSystem.username, backendSystem.password, {
63
71
  isSystem: true,
64
72
  odataVersion: (0, utils_1.convertODataVersionType)(requiredOdataVersion),
65
- sapClient: backendSystem.client
73
+ sapClient: backendSystem.client,
74
+ connectType: connectPath ? 'odata_path' : undefined // Assumption that if a connection path is provided its an odata service endpoint
66
75
  }));
67
76
  // If authentication failed with existing credentials the user will be prompted to enter new credentials.
68
77
  // We log the error in case there is another issue (unresolveable) with the stored backend configuration.
@@ -34,10 +34,11 @@ const systemSelectionPromptNames = {
34
34
  * @param systemSelection the selected system to validate
35
35
  * @param connectionValidator the active connection validator to use for the connection attempt
36
36
  * @param requiredOdataVersion the required OData version for the selected system, only the specified version will be used to request a service catalog
37
- * @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 cachedConnectedSystem if available passing an already connected system connection will prevent re-authentication for re-entrance ticket and service keys connection types
38
+ * @param connectPath if specified will be used as the connection endpoint instead of service catalogs
38
39
  * @returns the validation result of the selected system connection attempt
39
40
  */
40
- async function validateSystemSelection(systemSelection, connectionValidator, requiredOdataVersion, cachedConnectedSystem) {
41
+ async function validateSystemSelection(systemSelection, connectionValidator, requiredOdataVersion, cachedConnectedSystem, connectPath) {
41
42
  utils_1.PromptState.reset();
42
43
  if (systemSelection.type === 'newSystemChoice' || systemSelection.type === 'cfAbapEnvService') {
43
44
  // Reset the connection state
@@ -47,7 +48,7 @@ async function validateSystemSelection(systemSelection, connectionValidator, req
47
48
  let connectValResult = false;
48
49
  if (systemSelection.type === 'backendSystem') {
49
50
  const backendKey = store_1.BackendSystemKey.from(systemSelection.system);
50
- connectValResult = await (0, prompt_helpers_1.connectWithBackendSystem)(backendKey, connectionValidator, requiredOdataVersion, cachedConnectedSystem);
51
+ connectValResult = await (0, prompt_helpers_1.connectWithBackendSystem)(backendKey, connectionValidator, requiredOdataVersion, cachedConnectedSystem, connectPath);
51
52
  }
52
53
  else if (systemSelection.type === 'destination') {
53
54
  // Partial URL destinations will require additional service path prompt input, so we skip the connection validation here by returning true
@@ -57,7 +58,7 @@ async function validateSystemSelection(systemSelection, connectionValidator, req
57
58
  // connectionValidator.resetConnectionState(true);
58
59
  return true;
59
60
  }
60
- connectValResult = await (0, prompt_helpers_1.connectWithDestination)(systemSelection.system, connectionValidator, requiredOdataVersion);
61
+ connectValResult = await (0, prompt_helpers_1.connectWithDestination)(systemSelection.system, connectionValidator, requiredOdataVersion, connectPath);
61
62
  }
62
63
  return connectValResult;
63
64
  }
@@ -100,6 +101,8 @@ async function getSystemConnectionQuestions(connectionValidator, promptOptions,
100
101
  const destinationFilters = promptOptions?.systemSelection?.destinationFilters;
101
102
  const systemChoices = await (0, prompt_helpers_1.createSystemChoices)(destinationFilters, promptOptions?.systemSelection?.includeCloudFoundryAbapEnvChoice, promptOptions?.systemSelection?.hideNewSystem);
102
103
  let defaultChoiceIndex = (0, prompt_helpers_1.findDefaultSystemSelectionIndex)(systemChoices, promptOptions?.systemSelection?.defaultChoice);
104
+ // Alternative connection path, will override default authentication path (catalog endpoints)
105
+ let connectPath;
103
106
  const shouldOnlyShowDefaultChoice = promptOptions?.systemSelection?.onlyShowDefaultChoice && promptOptions?.systemSelection?.defaultChoice;
104
107
  const questions = [
105
108
  {
@@ -117,6 +120,9 @@ async function getSystemConnectionQuestions(connectionValidator, promptOptions,
117
120
  return 0;
118
121
  }
119
122
  defaultChoiceIndex = (0, prompt_helpers_1.findDefaultSystemSelectionIndex)(systemChoices, promptOptions?.systemSelection?.defaultChoice); // Recalc to allow default choice to be bound to ref from another prompt
123
+ if (defaultChoiceIndex > -1 && typeof promptOptions?.systemSelection?.defaultChoice === 'object') {
124
+ connectPath = promptOptions.systemSelection.defaultChoice.connectPath;
125
+ }
120
126
  return defaultChoiceIndex;
121
127
  },
122
128
  validate: async (selectedSystem) => {
@@ -128,7 +134,7 @@ async function getSystemConnectionQuestions(connectionValidator, promptOptions,
128
134
  if (promptOptions?.systemSelection?.useAutoComplete && selectedSystem.value) {
129
135
  selectedSystemAnswer = selectedSystem.value;
130
136
  }
131
- return (validateSystemSelection(selectedSystemAnswer, connectionValidator, requiredOdataVersion, cachedConnectedSystem) ?? false);
137
+ return (validateSystemSelection(selectedSystemAnswer, connectionValidator, requiredOdataVersion, cachedConnectedSystem, connectPath) ?? false);
132
138
  },
133
139
  additionalMessages: async (selectedSystem) => {
134
140
  if (selectedSystem.type === 'backendSystem' &&
@@ -196,7 +202,7 @@ async function getSystemConnectionQuestions(connectionValidator, promptOptions,
196
202
  if (!selectedSystem) {
197
203
  return false;
198
204
  }
199
- const connectValResult = await validateSystemSelection(selectedSystem, connectionValidator, requiredOdataVersion);
205
+ const connectValResult = await validateSystemSelection(selectedSystem, connectionValidator, requiredOdataVersion, undefined, connectPath);
200
206
  // An issue occurred with the selected system, there is no need to continue on the CLI, log and exit
201
207
  // Note that for connection authentication errors, the result will be true, the user will be prompted to update their credentials in the next prompt
202
208
  if (connectValResult !== true) {
package/dist/types.d.ts CHANGED
@@ -286,11 +286,12 @@ export type SystemSelectionPromptOptions = {
286
286
  * Provide a default choice for the system selection prompt, this is used to pre-select a system based on the system name.
287
287
  * Set as string literal types `NewSystemChoice` or `CfAbapEnvServiceChoice` to specify the default choice to create a new system connection config in VSCode
288
288
  * or to select the Cloud Foundry Abap environments service discovery choice in BAS respectively.
289
- * Supported as object reference `{ value: }` to allow binding to runtime variables of other prompts or as string
290
- *
289
+ * Supported as object reference `{ value: }` to allow binding to runtime variables of other prompts or as string.
290
+ * `{ connectPath }`, if specified this path is appended to the default choice system path and will be used to authenticate instead of a making catalog request
291
291
  */
292
292
  defaultChoice?: string | {
293
293
  value?: string;
294
+ connectPath?: string;
294
295
  };
295
296
  /**
296
297
  * Only show the default choice in the system selection prompt, this is used to skip the system selection prompt if the default choice is already known.
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.19.0",
4
+ "version": "2.19.2",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/SAP/open-ux-tools.git",
@@ -30,14 +30,14 @@
30
30
  "inquirer-autocomplete-prompt": "2.0.1",
31
31
  "os-name": "4.0.1",
32
32
  "@sap-ux/btp-utils": "1.1.9",
33
+ "@sap-ux/axios-extension": "1.25.18",
33
34
  "@sap-ux/fiori-generator-shared": "0.13.81",
34
- "@sap-ux/inquirer-common": "0.11.16",
35
- "@sap-ux/axios-extension": "1.25.17",
36
- "@sap-ux/nodejs-utils": "0.2.16",
37
35
  "@sap-ux/guided-answers-helper": "0.4.2",
38
36
  "@sap-ux/telemetry": "0.6.82",
39
- "@sap-ux/project-access": "1.35.10",
37
+ "@sap-ux/inquirer-common": "0.11.16",
40
38
  "@sap-ux/logger": "0.8.1",
39
+ "@sap-ux/project-access": "1.35.10",
40
+ "@sap-ux/nodejs-utils": "0.2.16",
41
41
  "@sap-ux/project-input-validator": "0.6.64",
42
42
  "@sap-ux/store": "1.5.8"
43
43
  },
@@ -48,11 +48,11 @@
48
48
  "@types/inquirer": "8.2.6",
49
49
  "jest-extended": "6.0.0",
50
50
  "@sap-ux/fiori-generator-shared": "0.13.81",
51
- "@sap-ux/fiori-elements-writer": "2.8.81",
52
- "@sap-ux/fiori-freestyle-writer": "2.5.62",
53
51
  "@sap-ux/feature-toggle": "0.3.7",
52
+ "@sap-ux/fiori-freestyle-writer": "2.5.62",
54
53
  "@sap-ux/odata-service-writer": "0.29.28",
55
- "@sap-ux/cap-config-writer": "0.12.73"
54
+ "@sap-ux/cap-config-writer": "0.12.73",
55
+ "@sap-ux/fiori-elements-writer": "2.8.82"
56
56
  },
57
57
  "engines": {
58
58
  "node": ">=20.x"