@sap-ux/odata-service-inquirer 2.18.13 → 2.19.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/prompts/connectionValidator.d.ts +10 -4
- package/dist/prompts/connectionValidator.js +55 -34
- package/dist/prompts/datasources/sap-system/service-selection/questions.js +1 -1
- package/dist/prompts/datasources/sap-system/system-selection/prompt-helpers.d.ts +2 -1
- package/dist/prompts/datasources/sap-system/system-selection/prompt-helpers.js +15 -6
- package/dist/prompts/datasources/sap-system/system-selection/questions.js +12 -6
- package/dist/prompts/edmx/questions.js +11 -3
- package/dist/translations/odata-service-inquirer.i18n.json +2 -1
- package/dist/types.d.ts +3 -2
- package/package.json +1 -1
|
@@ -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
|
|
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
|
-
|
|
265
|
-
|
|
266
|
-
|
|
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 (
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
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
|
-
|
|
434
|
-
|
|
435
|
-
await this._catalogV4?.listServices();
|
|
444
|
+
catch (error) {
|
|
445
|
+
await this.handleCatalogError(error, v4Requested);
|
|
436
446
|
}
|
|
437
447
|
}
|
|
438
|
-
|
|
439
|
-
|
|
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:
|
|
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({
|
|
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
|
|
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
|
-
//
|
|
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
|
|
677
|
-
if (
|
|
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)('
|
|
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(
|
|
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(
|
|
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
|
|
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) {
|
|
@@ -250,14 +250,22 @@ function getTableLayoutQuestions(templateType, odataVersion, isCapService, metad
|
|
|
250
250
|
defaultTableType = undefined;
|
|
251
251
|
return prevAnswers.tableType;
|
|
252
252
|
},
|
|
253
|
-
additionalMessages: () => {
|
|
254
|
-
|
|
253
|
+
additionalMessages: (selectedTableType) => {
|
|
254
|
+
// Show responsive table info whenever ResponsiveTable is selected
|
|
255
|
+
if (selectedTableType === 'ResponsiveTable') {
|
|
256
|
+
return {
|
|
257
|
+
message: (0, i18n_1.t)('prompts.tableType.responsiveTableInfo'),
|
|
258
|
+
severity: yeoman_ui_types_1.Severity.information
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
// Show default type info when the default is selected
|
|
262
|
+
if (defaultTableType === 'AnalyticalTable' && selectedTableType === 'AnalyticalTable') {
|
|
255
263
|
return {
|
|
256
264
|
message: (0, i18n_1.t)('prompts.tableType.analyticalTableDefault'),
|
|
257
265
|
severity: yeoman_ui_types_1.Severity.information
|
|
258
266
|
};
|
|
259
267
|
}
|
|
260
|
-
else if (defaultTableType === 'TreeTable') {
|
|
268
|
+
else if (defaultTableType === 'TreeTable' && selectedTableType === 'TreeTable') {
|
|
261
269
|
return {
|
|
262
270
|
message: (0, i18n_1.t)('prompts.tableType.treeTableDefault'),
|
|
263
271
|
severity: yeoman_ui_types_1.Severity.information
|
|
@@ -167,7 +167,8 @@
|
|
|
167
167
|
"choiceResponsive": "Responsive",
|
|
168
168
|
"choiceTree": "Tree",
|
|
169
169
|
"analyticalTableDefault": "The 'Analytical' table type is chosen by default because the selected entity supports it.",
|
|
170
|
-
"treeTableDefault": "The 'Tree' table type is chosen by default because the selected entity supports it."
|
|
170
|
+
"treeTableDefault": "The 'Tree' table type is chosen by default because the selected entity supports it.",
|
|
171
|
+
"responsiveTableInfo": "Only use the responsive table if the total number of items in the table doesn't exceed 200."
|
|
171
172
|
},
|
|
172
173
|
"hierarchyQualifier": {
|
|
173
174
|
"message": "Hierarchy Qualifier",
|
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.
|
|
4
|
+
"version": "2.19.1",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/SAP/open-ux-tools.git",
|