@sap-ux/odata-service-inquirer 2.3.2 → 2.3.4
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 +7 -5
- package/dist/index.js +6 -5
- package/dist/prompts/connectionValidator.d.ts +11 -0
- package/dist/prompts/connectionValidator.js +38 -0
- package/dist/prompts/datasources/sap-system/abap-on-btp/questions.d.ts +5 -3
- package/dist/prompts/datasources/sap-system/abap-on-btp/questions.js +29 -9
- package/dist/prompts/datasources/sap-system/credentials/questions.js +1 -1
- package/dist/prompts/datasources/sap-system/new-system/questions.d.ts +4 -10
- package/dist/prompts/datasources/sap-system/new-system/questions.js +3 -2
- package/dist/prompts/datasources/sap-system/new-system/types.d.ts +8 -0
- package/dist/prompts/datasources/sap-system/new-system/types.js +2 -0
- package/dist/prompts/datasources/sap-system/service-selection/service-helper.d.ts +0 -12
- package/dist/prompts/datasources/sap-system/service-selection/service-helper.js +0 -12
- package/dist/prompts/datasources/sap-system/shared-prompts/shared-prompts.d.ts +4 -2
- package/dist/prompts/datasources/sap-system/shared-prompts/shared-prompts.js +9 -1
- package/dist/prompts/datasources/sap-system/system-selection/prompt-helpers.d.ts +3 -2
- package/dist/prompts/datasources/sap-system/system-selection/prompt-helpers.js +8 -2
- package/dist/prompts/datasources/sap-system/system-selection/questions.d.ts +5 -3
- package/dist/prompts/datasources/sap-system/system-selection/questions.js +19 -16
- package/dist/prompts/prompts.d.ts +3 -2
- package/dist/prompts/prompts.js +6 -4
- package/dist/types.d.ts +17 -16
- package/package.json +11 -11
package/dist/index.d.ts
CHANGED
|
@@ -7,9 +7,9 @@ import type { ServiceAnswer } from './prompts/datasources/sap-system/service-sel
|
|
|
7
7
|
import { type SystemSelectionAnswers } from './prompts/datasources/sap-system/system-selection';
|
|
8
8
|
import type { CfAbapEnvServiceChoice, NewSystemChoice, SystemSelectionAnswerType } from './prompts/datasources/sap-system/system-selection/prompt-helpers';
|
|
9
9
|
import type { Annotations } from '@sap-ux/axios-extension';
|
|
10
|
+
import type { CapRuntime, CapService } from '@sap-ux/cap-config-writer';
|
|
10
11
|
import type { TemplateType } from '@sap-ux/fiori-elements-writer';
|
|
11
|
-
import {
|
|
12
|
-
import type { CapService, CapRuntime } from '@sap-ux/cap-config-writer';
|
|
12
|
+
import { type EntityPromptOptions, type OdataServiceAnswers, type OdataServicePromptOptions, type OdataServiceQuestion, type SapSystemType, type ConnectedSystem, DatasourceType, EntityRelatedAnswers, promptNames } from './types';
|
|
13
13
|
/**
|
|
14
14
|
* Get the inquirer prompts for odata service.
|
|
15
15
|
*
|
|
@@ -18,9 +18,10 @@ import type { CapService, CapRuntime } from '@sap-ux/cap-config-writer';
|
|
|
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 and service keys connection types
|
|
21
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
|
|
22
23
|
*/
|
|
23
|
-
declare function getPrompts(promptOptions?: OdataServicePromptOptions, logger?: Logger, enableGuidedAnswers?: boolean, telemetryClient?: ToolsSuiteTelemetryClient, isYUI?: boolean): Promise<{
|
|
24
|
+
declare function getPrompts(promptOptions?: OdataServicePromptOptions, logger?: Logger, enableGuidedAnswers?: boolean, telemetryClient?: ToolsSuiteTelemetryClient, isYUI?: boolean, connectedSystem?: ConnectedSystem): Promise<{
|
|
24
25
|
prompts: OdataServiceQuestion[];
|
|
25
26
|
answers: Partial<OdataServiceAnswers>;
|
|
26
27
|
}>;
|
|
@@ -58,8 +59,9 @@ declare function getEntityRelatedPrompts(metadata: string, templateType: Templat
|
|
|
58
59
|
* @param enableGuidedAnswers - if true, the prompts will use guided answers to help users with validation errors
|
|
59
60
|
* @param telemetryClient - the telemetry client to use for sending telemetry data
|
|
60
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 and service keys connection types
|
|
61
63
|
* @returns the prompt answers
|
|
62
64
|
*/
|
|
63
|
-
declare function prompt(adapter: InquirerAdapter, promptOptions?: OdataServicePromptOptions, logger?: Logger, enableGuidedAnswers?: boolean, telemetryClient?: ToolsSuiteTelemetryClient, isYUI?: boolean): Promise<OdataServiceAnswers>;
|
|
64
|
-
export { CfAbapEnvServiceChoice, DatasourceType, EntityRelatedAnswers, ERROR_TYPE, ErrorHandler, getEntityRelatedPrompts, getPrompts, getSystemSelectionQuestions, NewSystemChoice, OdataVersion, prompt, promptNames, SystemSelectionAnswerType, type CapRuntime, type CapService, type InquirerAdapter, type OdataServiceAnswers, type OdataServicePromptOptions, type SapSystemType };
|
|
65
|
+
declare function prompt(adapter: InquirerAdapter, promptOptions?: OdataServicePromptOptions, logger?: Logger, enableGuidedAnswers?: boolean, telemetryClient?: ToolsSuiteTelemetryClient, isYUI?: boolean, connectedSystem?: ConnectedSystem): Promise<OdataServiceAnswers>;
|
|
66
|
+
export { CfAbapEnvServiceChoice, DatasourceType, EntityRelatedAnswers, ERROR_TYPE, ErrorHandler, getEntityRelatedPrompts, getPrompts, getSystemSelectionQuestions, NewSystemChoice, OdataVersion, prompt, promptNames, SystemSelectionAnswerType, type CapRuntime, type CapService, type InquirerAdapter, type OdataServiceAnswers, type OdataServicePromptOptions, type SapSystemType, type ConnectedSystem };
|
|
65
67
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -31,9 +31,10 @@ 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 and service keys connection types
|
|
34
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
|
|
35
36
|
*/
|
|
36
|
-
async function getPrompts(promptOptions, logger, enableGuidedAnswers = false, telemetryClient, isYUI = false) {
|
|
37
|
+
async function getPrompts(promptOptions, logger, enableGuidedAnswers = false, telemetryClient, isYUI = false, connectedSystem) {
|
|
37
38
|
// prompt texts must be loaded before the prompts are created, wait for the i18n bundle to be initialized
|
|
38
39
|
await (0, i18n_1.initI18nOdataServiceInquirer)();
|
|
39
40
|
if (logger) {
|
|
@@ -47,7 +48,7 @@ async function getPrompts(promptOptions, logger, enableGuidedAnswers = false, te
|
|
|
47
48
|
utils_1.PromptState.isYUI = isYUI;
|
|
48
49
|
(0, inquirer_common_1.setTelemetryClient)(telemetryClient);
|
|
49
50
|
return {
|
|
50
|
-
prompts: await (0, prompts_1.getQuestions)(promptOptions),
|
|
51
|
+
prompts: await (0, prompts_1.getQuestions)(promptOptions, connectedSystem),
|
|
51
52
|
// Return reference to derived answers object that will be populated with user responses (after prompting is complete)
|
|
52
53
|
answers: utils_1.PromptState.odataService
|
|
53
54
|
};
|
|
@@ -97,15 +98,15 @@ function getEntityRelatedPrompts(metadata, templateType, isCapService = false, p
|
|
|
97
98
|
* @param enableGuidedAnswers - if true, the prompts will use guided answers to help users with validation errors
|
|
98
99
|
* @param telemetryClient - the telemetry client to use for sending telemetry data
|
|
99
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 and service keys connection types
|
|
100
102
|
* @returns the prompt answers
|
|
101
103
|
*/
|
|
102
|
-
async function prompt(adapter, promptOptions, logger, enableGuidedAnswers, telemetryClient, isYUI = false) {
|
|
104
|
+
async function prompt(adapter, promptOptions, logger, enableGuidedAnswers, telemetryClient, isYUI = false, connectedSystem) {
|
|
103
105
|
if (adapter?.promptModule && promptOptions?.serviceSelection?.useAutoComplete) {
|
|
104
106
|
const pm = adapter.promptModule;
|
|
105
107
|
pm.registerPrompt('autocomplete', inquirer_autocomplete_prompt_1.default);
|
|
106
108
|
}
|
|
107
|
-
const odataServicePrompts = (await getPrompts(promptOptions, logger, enableGuidedAnswers, telemetryClient, isYUI))
|
|
108
|
-
.prompts;
|
|
109
|
+
const odataServicePrompts = (await getPrompts(promptOptions, logger, enableGuidedAnswers, telemetryClient, isYUI, connectedSystem)).prompts;
|
|
109
110
|
const answers = await adapter.prompt(odataServicePrompts);
|
|
110
111
|
// Add dervied service answers to the answers object
|
|
111
112
|
Object.assign(answers, utils_1.PromptState.odataService);
|
|
@@ -2,6 +2,7 @@ import type { AxiosRequestConfig, CatalogService, ODataService, ServiceInfo, Ser
|
|
|
2
2
|
import { ODataVersion } from '@sap-ux/axios-extension';
|
|
3
3
|
import { type Destination } from '@sap-ux/btp-utils';
|
|
4
4
|
import { ERROR_TYPE } from '@sap-ux/inquirer-common';
|
|
5
|
+
import type { ConnectedSystem } from '../types';
|
|
5
6
|
import type { ValidationResult } from './types';
|
|
6
7
|
/**
|
|
7
8
|
* Structure to store validity information about url to be validated.
|
|
@@ -131,6 +132,16 @@ export declare class ConnectionValidator {
|
|
|
131
132
|
*
|
|
132
133
|
*/
|
|
133
134
|
set connectedSystemName(value: string | undefined);
|
|
135
|
+
/**
|
|
136
|
+
* Setting an existing connected system will prevent re-authentication.
|
|
137
|
+
* This should be used where the user has previously authenticated to prevent re-authentication (e.g. via browser) and the previous
|
|
138
|
+
* connected system is still valid. Only backend systems are currently supported.
|
|
139
|
+
*
|
|
140
|
+
* @param connectedSystem A connected system object containing the service provider and backend system information. Not relevant for destination connections.
|
|
141
|
+
* @param connectedSystem.serviceProvider
|
|
142
|
+
* @param connectedSystem.backendSystem
|
|
143
|
+
*/
|
|
144
|
+
setConnectedSystem({ serviceProvider, backendSystem }: ConnectedSystem): void;
|
|
134
145
|
/**
|
|
135
146
|
* Calls a given service or system url to test its reachability and authentication requirements.
|
|
136
147
|
* If the url is a system url, it will attempt to use the catalog service to get the service info.
|
|
@@ -176,6 +176,39 @@ class ConnectionValidator {
|
|
|
176
176
|
set connectedSystemName(value) {
|
|
177
177
|
this._connectedSystemName = value;
|
|
178
178
|
}
|
|
179
|
+
/**
|
|
180
|
+
* Setting an existing connected system will prevent re-authentication.
|
|
181
|
+
* This should be used where the user has previously authenticated to prevent re-authentication (e.g. via browser) and the previous
|
|
182
|
+
* connected system is still valid. Only backend systems are currently supported.
|
|
183
|
+
*
|
|
184
|
+
* @param connectedSystem A connected system object containing the service provider and backend system information. Not relevant for destination connections.
|
|
185
|
+
* @param connectedSystem.serviceProvider
|
|
186
|
+
* @param connectedSystem.backendSystem
|
|
187
|
+
*/
|
|
188
|
+
setConnectedSystem({ serviceProvider, backendSystem }) {
|
|
189
|
+
// Set the state using the provided ConnectedSystem to prevent re-authentication
|
|
190
|
+
this._serviceProvider = serviceProvider;
|
|
191
|
+
this._catalogV2 = this._serviceProvider.catalog(axios_extension_1.ODataVersion.v2);
|
|
192
|
+
this._catalogV4 = this._serviceProvider.catalog(axios_extension_1.ODataVersion.v4);
|
|
193
|
+
this._validatedUrl = backendSystem?.serviceKeys?.url ?? backendSystem?.url;
|
|
194
|
+
this._connectedUserName = backendSystem?.userDisplayName;
|
|
195
|
+
this._validatedClient = backendSystem?.client;
|
|
196
|
+
this._refreshToken = backendSystem?.refreshToken;
|
|
197
|
+
this._serviceInfo = backendSystem?.serviceKeys;
|
|
198
|
+
this.validity.authenticated = true;
|
|
199
|
+
this.validity.reachable = true;
|
|
200
|
+
this.validity.urlFormat = true;
|
|
201
|
+
this.validity.authRequired = true;
|
|
202
|
+
if (backendSystem?.authenticationType === 'reentranceTicket') {
|
|
203
|
+
this.systemAuthType = 'reentranceTicket';
|
|
204
|
+
}
|
|
205
|
+
else if (backendSystem?.serviceKeys) {
|
|
206
|
+
this.systemAuthType = 'serviceKey';
|
|
207
|
+
}
|
|
208
|
+
else {
|
|
209
|
+
this.systemAuthType = 'basic';
|
|
210
|
+
}
|
|
211
|
+
}
|
|
179
212
|
/**
|
|
180
213
|
* Calls a given service or system url to test its reachability and authentication requirements.
|
|
181
214
|
* If the url is a system url, it will attempt to use the catalog service to get the service info.
|
|
@@ -424,6 +457,11 @@ class ConnectionValidator {
|
|
|
424
457
|
if (!serviceInfo) {
|
|
425
458
|
return false;
|
|
426
459
|
}
|
|
460
|
+
// If we are already authenticated and the url is the same, no need to re-authenticate as this may result in a browser based authentication
|
|
461
|
+
if (serviceInfo.url === this.validatedUrl &&
|
|
462
|
+
JSON.stringify(serviceInfo.uaa) === JSON.stringify(this.serviceInfo?.uaa)) {
|
|
463
|
+
return this.getValidationResultFromStatusCode(200);
|
|
464
|
+
}
|
|
427
465
|
try {
|
|
428
466
|
this.systemAuthType = 'serviceKey';
|
|
429
467
|
await this.createSystemConnection({ serviceInfo, odataVersion, refreshToken });
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { OdataVersion } from '@sap-ux/odata-service-writer';
|
|
2
2
|
import { type ServiceInstanceInfo } from '@sap/cf-tools';
|
|
3
3
|
import type { Question } from 'inquirer';
|
|
4
|
-
import {
|
|
4
|
+
import type { ConnectedSystem, OdataServiceAnswers, OdataServicePromptOptions } from '../../../../types';
|
|
5
5
|
import { ConnectionValidator } from '../../../connectionValidator';
|
|
6
6
|
import { type ServiceAnswer } from '../service-selection';
|
|
7
7
|
declare const systemUrlPromptName: "abapOnBtp:newSystemUrl";
|
|
@@ -21,9 +21,10 @@ interface AbapOnBtpAnswers extends Partial<OdataServiceAnswers> {
|
|
|
21
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).
|
|
22
22
|
*
|
|
23
23
|
* @param promptOptions The prompt options which control the service selection and system name]
|
|
24
|
+
* @param cachedConnectedSystem if available passing an already connected system connection will prevent re-authentication for re-entrance ticket and service keys connection types
|
|
24
25
|
* @returns The list of questions for the ABAP on BTP system
|
|
25
26
|
*/
|
|
26
|
-
export declare function getAbapOnBTPSystemQuestions(promptOptions?: OdataServicePromptOptions): Question<AbapOnBtpAnswers & ServiceAnswer>[];
|
|
27
|
+
export declare function getAbapOnBTPSystemQuestions(promptOptions?: OdataServicePromptOptions, cachedConnectedSystem?: ConnectedSystem): Question<AbapOnBtpAnswers & ServiceAnswer>[];
|
|
27
28
|
/**
|
|
28
29
|
* Get the Cloud Foundry Abap system discovery prompt. This prompt will list all available ABAP environments in the connected Cloud Foundry space.
|
|
29
30
|
* If the Cloud Foundry connection fails, a warning message will be displayed.
|
|
@@ -31,8 +32,9 @@ export declare function getAbapOnBTPSystemQuestions(promptOptions?: OdataService
|
|
|
31
32
|
* @param connectionValidator The connection validator
|
|
32
33
|
* @param promptNamespace
|
|
33
34
|
* @param requiredOdataVersion
|
|
35
|
+
* @param cachedConnectedSystem if available passing an already connected system connection will prevent re-authentication for re-entrance ticket and service keys connection types
|
|
34
36
|
* @returns The Cloud Foundry ABAP system discovery prompt
|
|
35
37
|
*/
|
|
36
|
-
export declare function getCFDiscoverPrompts(connectionValidator: ConnectionValidator, promptNamespace?: string, requiredOdataVersion?: OdataVersion): Question[];
|
|
38
|
+
export declare function getCFDiscoverPrompts(connectionValidator: ConnectionValidator, promptNamespace?: string, requiredOdataVersion?: OdataVersion, cachedConnectedSystem?: ConnectedSystem): Question[];
|
|
37
39
|
export {};
|
|
38
40
|
//# sourceMappingURL=questions.d.ts.map
|
|
@@ -14,9 +14,9 @@ const utils_1 = require("../../../../utils");
|
|
|
14
14
|
const connectionValidator_1 = require("../../../connectionValidator");
|
|
15
15
|
const logger_helper_1 = __importDefault(require("../../../logger-helper"));
|
|
16
16
|
const prompt_helpers_1 = require("../../../prompt-helpers");
|
|
17
|
-
const shared_prompts_1 = require("../shared-prompts/shared-prompts");
|
|
18
17
|
const types_1 = require("../new-system/types");
|
|
19
18
|
const service_selection_1 = require("../service-selection");
|
|
19
|
+
const shared_prompts_1 = require("../shared-prompts/shared-prompts");
|
|
20
20
|
const prompt_helpers_2 = require("../system-selection/prompt-helpers");
|
|
21
21
|
const validators_1 = require("../validators");
|
|
22
22
|
const abapOnBtpPromptNamespace = 'abapOnBtp';
|
|
@@ -31,9 +31,10 @@ const abapOnBtpPromptNames = {
|
|
|
31
31
|
* 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).
|
|
32
32
|
*
|
|
33
33
|
* @param promptOptions The prompt options which control the service selection and system name]
|
|
34
|
+
* @param cachedConnectedSystem if available passing an already connected system connection will prevent re-authentication for re-entrance ticket and service keys connection types
|
|
34
35
|
* @returns The list of questions for the ABAP on BTP system
|
|
35
36
|
*/
|
|
36
|
-
function getAbapOnBTPSystemQuestions(promptOptions) {
|
|
37
|
+
function getAbapOnBTPSystemQuestions(promptOptions, cachedConnectedSystem) {
|
|
37
38
|
utils_1.PromptState.reset();
|
|
38
39
|
const connectValidator = new connectionValidator_1.ConnectionValidator();
|
|
39
40
|
const questions = [];
|
|
@@ -54,7 +55,7 @@ function getAbapOnBTPSystemQuestions(promptOptions) {
|
|
|
54
55
|
});
|
|
55
56
|
// Re-entrance ticket system prompt
|
|
56
57
|
questions.push((0, inquirer_common_1.withCondition)([
|
|
57
|
-
(0, shared_prompts_1.getSystemUrlQuestion)(connectValidator, abapOnBtpPromptNamespace, promptOptions?.serviceSelection?.requiredOdataVersion)
|
|
58
|
+
(0, shared_prompts_1.getSystemUrlQuestion)(connectValidator, abapOnBtpPromptNamespace, promptOptions?.serviceSelection?.requiredOdataVersion, cachedConnectedSystem)
|
|
58
59
|
], (answers) => {
|
|
59
60
|
if (answers?.abapOnBtpAuthType === 'reentranceTicket') {
|
|
60
61
|
connectValidator.systemAuthType = answers.abapOnBtpAuthType;
|
|
@@ -63,8 +64,8 @@ function getAbapOnBTPSystemQuestions(promptOptions) {
|
|
|
63
64
|
return false;
|
|
64
65
|
})[0]);
|
|
65
66
|
// Service Key file prompt
|
|
66
|
-
questions.push((0, inquirer_common_1.withCondition)([getServiceKeyPrompt(connectValidator)], (answers) => answers?.abapOnBtpAuthType === 'serviceKey')[0]);
|
|
67
|
-
questions.push(...(0, inquirer_common_1.withCondition)([...getCFDiscoverPrompts(connectValidator)], (answers) => answers?.abapOnBtpAuthType === 'cloudFoundry'));
|
|
67
|
+
questions.push((0, inquirer_common_1.withCondition)([getServiceKeyPrompt(connectValidator, cachedConnectedSystem)], (answers) => answers?.abapOnBtpAuthType === 'serviceKey')[0]);
|
|
68
|
+
questions.push(...(0, inquirer_common_1.withCondition)([...getCFDiscoverPrompts(connectValidator, undefined, undefined, cachedConnectedSystem)], (answers) => answers?.abapOnBtpAuthType === 'cloudFoundry'));
|
|
68
69
|
// New system store name propmt
|
|
69
70
|
if (promptOptions?.userSystemName?.hide !== true) {
|
|
70
71
|
// New system question will allow user to give the system a user friendly name
|
|
@@ -84,9 +85,10 @@ function getAbapOnBTPSystemQuestions(promptOptions) {
|
|
|
84
85
|
* @param connectionValidator connection validator instance
|
|
85
86
|
* @param requiredOdataVersion
|
|
86
87
|
* @param isCli validation on CLI ill throw rather than returning a validation message as users cannot change previous answers on CLI
|
|
88
|
+
* @param cachedConnectedSystem
|
|
87
89
|
* @returns true if the service info is valid, a validation message if the service info is invalid, or a validation link if the service info is not validated but some help is available
|
|
88
90
|
*/
|
|
89
|
-
async function validateCFServiceInfo(abapService, connectionValidator, requiredOdataVersion, isCli = false) {
|
|
91
|
+
async function validateCFServiceInfo(abapService, connectionValidator, requiredOdataVersion, isCli = false, cachedConnectedSystem) {
|
|
90
92
|
utils_1.PromptState.resetConnectedSystem();
|
|
91
93
|
const cfAbapServiceName = abapService.label;
|
|
92
94
|
const uaaCreds = await (0, cf_tools_1.apiGetInstanceCredentials)(cfAbapServiceName); // should be abapService.serviceName in BAS?
|
|
@@ -109,6 +111,14 @@ async function validateCFServiceInfo(abapService, connectionValidator, requiredO
|
|
|
109
111
|
}
|
|
110
112
|
}
|
|
111
113
|
else {
|
|
114
|
+
// Backend systems validation supports using a cached connections from a previous step execution to prevent re-authentication (e.g. re-opening a browser window)
|
|
115
|
+
// In case the user has changed the URL, do not use the cached connection.
|
|
116
|
+
if (cachedConnectedSystem &&
|
|
117
|
+
cachedConnectedSystem.backendSystem?.url === uaaCreds.credentials.url &&
|
|
118
|
+
JSON.stringify(cachedConnectedSystem.backendSystem.serviceKeys.uaa) ===
|
|
119
|
+
JSON.stringify(uaaCreds.credentials.uaa)) {
|
|
120
|
+
connectionValidator.setConnectedSystem(cachedConnectedSystem);
|
|
121
|
+
}
|
|
112
122
|
valResult = await connectionValidator.validateServiceInfo(uaaCreds.credentials);
|
|
113
123
|
}
|
|
114
124
|
if (!isCli && valResult !== true) {
|
|
@@ -142,9 +152,10 @@ async function validateCFServiceInfo(abapService, connectionValidator, requiredO
|
|
|
142
152
|
* @param connectionValidator The connection validator
|
|
143
153
|
* @param promptNamespace
|
|
144
154
|
* @param requiredOdataVersion
|
|
155
|
+
* @param cachedConnectedSystem if available passing an already connected system connection will prevent re-authentication for re-entrance ticket and service keys connection types
|
|
145
156
|
* @returns The Cloud Foundry ABAP system discovery prompt
|
|
146
157
|
*/
|
|
147
|
-
function getCFDiscoverPrompts(connectionValidator, promptNamespace, requiredOdataVersion) {
|
|
158
|
+
function getCFDiscoverPrompts(connectionValidator, promptNamespace, requiredOdataVersion, cachedConnectedSystem) {
|
|
148
159
|
let choices = [];
|
|
149
160
|
const promptName = `${promptNamespace ? promptNamespace + ':' : ''}${abapOnBtpPromptNames.cloudFoundryAbapSystem}`;
|
|
150
161
|
const questions = [
|
|
@@ -169,7 +180,7 @@ function getCFDiscoverPrompts(connectionValidator, promptNamespace, requiredOdat
|
|
|
169
180
|
message: (0, i18n_1.t)('prompts.cloudFoundryAbapSystem.message'),
|
|
170
181
|
validate: async (abapService) => {
|
|
171
182
|
if (abapService) {
|
|
172
|
-
return await validateCFServiceInfo(abapService, connectionValidator, requiredOdataVersion, (0, utils_1.getPromptHostEnvironment)() === fiori_generator_shared_1.hostEnvironment.cli);
|
|
183
|
+
return await validateCFServiceInfo(abapService, connectionValidator, requiredOdataVersion, (0, utils_1.getPromptHostEnvironment)() === fiori_generator_shared_1.hostEnvironment.cli, cachedConnectedSystem);
|
|
173
184
|
}
|
|
174
185
|
const errorType = prompt_helpers_1.errorHandler.getCurrentErrorType();
|
|
175
186
|
if (errorType === inquirer_common_1.ERROR_TYPE.NO_ABAP_ENVS) {
|
|
@@ -200,9 +211,10 @@ function getCFDiscoverPrompts(connectionValidator, promptNamespace, requiredOdat
|
|
|
200
211
|
* 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.
|
|
201
212
|
*
|
|
202
213
|
* @param connectionValidator a connection validator instance
|
|
214
|
+
* @param cachedConnectedSystem if available passing an already connected system connection will prevent re-authentication for re-entrance ticket and service keys connection types
|
|
203
215
|
* @returns The service key prompt
|
|
204
216
|
*/
|
|
205
|
-
function getServiceKeyPrompt(connectionValidator) {
|
|
217
|
+
function getServiceKeyPrompt(connectionValidator, cachedConnectedSystem) {
|
|
206
218
|
const question = {
|
|
207
219
|
type: 'input',
|
|
208
220
|
name: abapOnBtpPromptNames.serviceKey,
|
|
@@ -218,6 +230,14 @@ function getServiceKeyPrompt(connectionValidator) {
|
|
|
218
230
|
if (typeof serviceKeyValResult === 'string' || typeof serviceKeyValResult === 'boolean') {
|
|
219
231
|
return serviceKeyValResult;
|
|
220
232
|
}
|
|
233
|
+
// Backend systems validation supports using a cached connections from a previous step execution to prevent re-authentication (e.g. re-opening a browser window)
|
|
234
|
+
// In case the user has changed the URL, do not use the cached connection.
|
|
235
|
+
if (cachedConnectedSystem &&
|
|
236
|
+
cachedConnectedSystem.backendSystem?.url === serviceKeyValResult.url &&
|
|
237
|
+
JSON.stringify(cachedConnectedSystem.backendSystem.serviceKeys.uaa) ===
|
|
238
|
+
JSON.stringify(serviceKeyValResult.uaa)) {
|
|
239
|
+
connectionValidator.setConnectedSystem(cachedConnectedSystem);
|
|
240
|
+
}
|
|
221
241
|
const connectValResult = await connectionValidator.validateServiceInfo(serviceKeyValResult);
|
|
222
242
|
if (connectValResult === true && connectionValidator.serviceProvider) {
|
|
223
243
|
utils_1.PromptState.odataService.connectedSystem = {
|
|
@@ -101,7 +101,7 @@ function getCredentialsPrompts(connectionValidator, promptNamespace, sapClient)
|
|
|
101
101
|
*/
|
|
102
102
|
function updatePromptStateWithConnectedSystem(serviceProvider, selectedSystem, { username, password }) {
|
|
103
103
|
utils_1.PromptState.odataService.connectedSystem = {
|
|
104
|
-
serviceProvider
|
|
104
|
+
serviceProvider: (0, utils_1.removeCircularFromServiceProvider)(serviceProvider)
|
|
105
105
|
};
|
|
106
106
|
// Update the existing backend system with the new credentials that may be used to update in the store.
|
|
107
107
|
if (selectedSystem?.type === 'backendSystem') {
|
|
@@ -1,18 +1,12 @@
|
|
|
1
1
|
import type { Question } from 'inquirer';
|
|
2
|
-
import type {
|
|
3
|
-
import {
|
|
4
|
-
/**
|
|
5
|
-
* Internal only answers to service URL prompting not returned with OdataServiceAnswers.
|
|
6
|
-
*/
|
|
7
|
-
export interface NewSystemAnswers {
|
|
8
|
-
[newSystemPromptNames.newSystemType]?: SapSystemType;
|
|
9
|
-
[promptNames.userSystemName]?: string;
|
|
10
|
-
}
|
|
2
|
+
import type { ConnectedSystem, OdataServicePromptOptions } from '../../../../types';
|
|
3
|
+
import { type NewSystemAnswers } from './types';
|
|
11
4
|
/**
|
|
12
5
|
* Provides prompts that allow the creation of a new system connection.
|
|
13
6
|
*
|
|
14
7
|
* @param promptOptions options for the new system prompts see {@link OdataServicePromptOptions}
|
|
8
|
+
* @param connectedSystem if available passing an already connected system connection will prevent re-authentication for re-entrance ticket and service keys connection types
|
|
15
9
|
* @returns questions for creating a new system connection
|
|
16
10
|
*/
|
|
17
|
-
export declare function getNewSystemQuestions(promptOptions?: OdataServicePromptOptions): Question<NewSystemAnswers>[];
|
|
11
|
+
export declare function getNewSystemQuestions(promptOptions?: OdataServicePromptOptions, connectedSystem?: ConnectedSystem): Question<NewSystemAnswers>[];
|
|
18
12
|
//# sourceMappingURL=questions.d.ts.map
|
|
@@ -13,9 +13,10 @@ const types_1 = require("./types");
|
|
|
13
13
|
* Provides prompts that allow the creation of a new system connection.
|
|
14
14
|
*
|
|
15
15
|
* @param promptOptions options for the new system prompts see {@link OdataServicePromptOptions}
|
|
16
|
+
* @param connectedSystem if available passing an already connected system connection will prevent re-authentication for re-entrance ticket and service keys connection types
|
|
16
17
|
* @returns questions for creating a new system connection
|
|
17
18
|
*/
|
|
18
|
-
function getNewSystemQuestions(promptOptions) {
|
|
19
|
+
function getNewSystemQuestions(promptOptions, connectedSystem) {
|
|
19
20
|
const questions = [
|
|
20
21
|
{
|
|
21
22
|
type: 'list',
|
|
@@ -28,7 +29,7 @@ function getNewSystemQuestions(promptOptions) {
|
|
|
28
29
|
}
|
|
29
30
|
];
|
|
30
31
|
questions.push(...(0, inquirer_common_1.withCondition)((0, questions_2.getAbapOnPremQuestions)(promptOptions), (answers) => answers.newSystemType === 'abapOnPrem'));
|
|
31
|
-
questions.push(...(0, inquirer_common_1.withCondition)((0, questions_1.getAbapOnBTPSystemQuestions)(promptOptions), (answers) => answers.newSystemType === 'abapOnBtp'));
|
|
32
|
+
questions.push(...(0, inquirer_common_1.withCondition)((0, questions_1.getAbapOnBTPSystemQuestions)(promptOptions, connectedSystem), (answers) => answers.newSystemType === 'abapOnBtp'));
|
|
32
33
|
return questions;
|
|
33
34
|
}
|
|
34
35
|
//# sourceMappingURL=questions.js.map
|
|
@@ -1,6 +1,14 @@
|
|
|
1
|
+
import { promptNames, type SapSystemType } from '../../../../types';
|
|
1
2
|
export declare const newSystemPromptNames: {
|
|
2
3
|
readonly newSystemType: "newSystemType";
|
|
3
4
|
readonly newSystemUrl: "newSystemUrl";
|
|
4
5
|
readonly newSystemAuthType: "newSystemAuthType";
|
|
5
6
|
};
|
|
7
|
+
/**
|
|
8
|
+
* Internal only answers to service URL prompting not returned with OdataServiceAnswers.
|
|
9
|
+
*/
|
|
10
|
+
export interface NewSystemAnswers {
|
|
11
|
+
[newSystemPromptNames.newSystemType]?: SapSystemType;
|
|
12
|
+
[promptNames.userSystemName]?: string;
|
|
13
|
+
}
|
|
6
14
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.newSystemPromptNames = void 0;
|
|
4
|
+
// eslint-disable-next-line
|
|
5
|
+
const types_1 = require("../../../../types");
|
|
4
6
|
exports.newSystemPromptNames = {
|
|
5
7
|
newSystemType: 'newSystemType',
|
|
6
8
|
newSystemUrl: 'newSystemUrl',
|
|
@@ -7,18 +7,6 @@ import type { ConnectionValidator } from '../../../connectionValidator';
|
|
|
7
7
|
import type { ServiceAnswer } from './types';
|
|
8
8
|
import type { ConvertedMetadata } from '@sap-ux/vocabularies-types';
|
|
9
9
|
export declare const telemEventBASServiceSuccess = "SERVICE_INQUIRER_BAS_SUCCESS";
|
|
10
|
-
/**
|
|
11
|
-
* Refines the error type and logs based on the specified options. This should log more precise error messages based on inputs
|
|
12
|
-
* and the platform making the call i.e. VSC | SBAS. Errors are mapped to GA links if the platform is SBAS.
|
|
13
|
-
*
|
|
14
|
-
* @param options Options
|
|
15
|
-
* @param options.system - sap system used
|
|
16
|
-
* @param options.catRequestErrorTypes - all catalog service request error types, used to do further root cause analysis
|
|
17
|
-
* @param options.rootCauseErrorType - the error type as determined by the caller, will be used if a more precise error type cannot be determined by rca
|
|
18
|
-
* @param options.logMsg - the log message that will be used if a better root cause is not determined
|
|
19
|
-
* @param options.error - the original error, used to determine the error log message if otherwise not determined
|
|
20
|
-
* @param option.reqVersion - specific odata version that is required by the template
|
|
21
|
-
*/
|
|
22
10
|
/**
|
|
23
11
|
* Get the service choices from the specified catalogs.
|
|
24
12
|
*
|
|
@@ -77,18 +77,6 @@ function logServiceCatalogErrorsForHelp(requestErrors, numOfRequests) {
|
|
|
77
77
|
prompt_helpers_1.errorHandler.logErrorMsgs((0, i18n_1.t)('errors.allCatalogServiceRequestsFailed', { version: Object.keys(requestErrors).join(', ') }));
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
|
-
/**
|
|
81
|
-
* Refines the error type and logs based on the specified options. This should log more precise error messages based on inputs
|
|
82
|
-
* and the platform making the call i.e. VSC | SBAS. Errors are mapped to GA links if the platform is SBAS.
|
|
83
|
-
*
|
|
84
|
-
* @param options Options
|
|
85
|
-
* @param options.system - sap system used
|
|
86
|
-
* @param options.catRequestErrorTypes - all catalog service request error types, used to do further root cause analysis
|
|
87
|
-
* @param options.rootCauseErrorType - the error type as determined by the caller, will be used if a more precise error type cannot be determined by rca
|
|
88
|
-
* @param options.logMsg - the log message that will be used if a better root cause is not determined
|
|
89
|
-
* @param options.error - the original error, used to determine the error log message if otherwise not determined
|
|
90
|
-
* @param option.reqVersion - specific odata version that is required by the template
|
|
91
|
-
*/
|
|
92
80
|
/**
|
|
93
81
|
* Get the service choices from the specified catalogs.
|
|
94
82
|
*
|
|
@@ -4,17 +4,19 @@
|
|
|
4
4
|
import { type InputQuestion } from '@sap-ux/inquirer-common';
|
|
5
5
|
import type { OdataVersion } from '@sap-ux/odata-service-writer';
|
|
6
6
|
import type { Answers } from 'inquirer';
|
|
7
|
+
import type { ConnectedSystem } from '../../../../types';
|
|
7
8
|
import type { ConnectionValidator } from '../../../connectionValidator';
|
|
8
|
-
import type
|
|
9
|
+
import { type NewSystemAnswers } from '../new-system/types';
|
|
9
10
|
/**
|
|
10
11
|
* Get the system url prompt. The system url prompt is used to connect to a new system using the user input system url.
|
|
11
12
|
*
|
|
12
13
|
* @param connectValidator a connection validator instance used to validate the system url
|
|
13
14
|
* @param promptNamespace The namespace for the prompt, used to identify the prompt instance and namespaced answers.
|
|
14
15
|
* @param requiredOdataVersion The required OData version for the system connection, only catalogs supporting the specifc odata version will be used.
|
|
16
|
+
* @param cachedConnectedSystem
|
|
15
17
|
* @returns the system url prompt
|
|
16
18
|
*/
|
|
17
|
-
export declare function getSystemUrlQuestion<T extends Answers>(connectValidator: ConnectionValidator, promptNamespace?: string, requiredOdataVersion?: OdataVersion): InputQuestion<T>;
|
|
19
|
+
export declare function getSystemUrlQuestion<T extends Answers>(connectValidator: ConnectionValidator, promptNamespace?: string, requiredOdataVersion?: OdataVersion, cachedConnectedSystem?: ConnectedSystem): InputQuestion<T>;
|
|
18
20
|
/**
|
|
19
21
|
* Get a prompt for new system name.
|
|
20
22
|
*
|
|
@@ -34,9 +34,10 @@ function systemAuthTypeToAuthenticationType(systemAuthType) {
|
|
|
34
34
|
* @param connectValidator a connection validator instance used to validate the system url
|
|
35
35
|
* @param promptNamespace The namespace for the prompt, used to identify the prompt instance and namespaced answers.
|
|
36
36
|
* @param requiredOdataVersion The required OData version for the system connection, only catalogs supporting the specifc odata version will be used.
|
|
37
|
+
* @param cachedConnectedSystem
|
|
37
38
|
* @returns the system url prompt
|
|
38
39
|
*/
|
|
39
|
-
function getSystemUrlQuestion(connectValidator, promptNamespace, requiredOdataVersion) {
|
|
40
|
+
function getSystemUrlQuestion(connectValidator, promptNamespace, requiredOdataVersion, cachedConnectedSystem) {
|
|
40
41
|
const promptName = `${promptNamespace ? promptNamespace + ':' : ''}${types_2.newSystemPromptNames.newSystemUrl}`;
|
|
41
42
|
const newSystemUrlQuestion = {
|
|
42
43
|
type: 'input',
|
|
@@ -49,6 +50,13 @@ function getSystemUrlQuestion(connectValidator, promptNamespace, requiredOdataVe
|
|
|
49
50
|
},
|
|
50
51
|
validate: async (url) => {
|
|
51
52
|
utils_1.PromptState.resetConnectedSystem();
|
|
53
|
+
// Backend systems validation supports using a cached connections from a previous step execution to prevent re-authentication (e.g. re-opening a browser window)
|
|
54
|
+
// Only in the case or re-entrance tickets will we reuse an existing connection.
|
|
55
|
+
if (cachedConnectedSystem &&
|
|
56
|
+
cachedConnectedSystem.backendSystem?.url === url &&
|
|
57
|
+
cachedConnectedSystem.backendSystem?.authenticationType === 'reentranceTicket') {
|
|
58
|
+
connectValidator.setConnectedSystem(cachedConnectedSystem);
|
|
59
|
+
}
|
|
52
60
|
const valResult = await connectValidator.validateUrl(url, {
|
|
53
61
|
isSystem: true,
|
|
54
62
|
odataVersion: (0, utils_1.convertODataVersionType)(requiredOdataVersion)
|
|
@@ -2,7 +2,7 @@ import type { Destination } from '@sap-ux/btp-utils';
|
|
|
2
2
|
import type { OdataVersion } from '@sap-ux/odata-service-writer';
|
|
3
3
|
import type { BackendSystem } from '@sap-ux/store';
|
|
4
4
|
import type { ListChoiceOptions } from 'inquirer';
|
|
5
|
-
import {
|
|
5
|
+
import type { ConnectedSystem, DestinationFilters } from '../../../../types';
|
|
6
6
|
import type { ConnectionValidator } from '../../../connectionValidator';
|
|
7
7
|
import type { ValidationResult } from '../../../types';
|
|
8
8
|
export declare const NewSystemChoice = "!@\u00A3*&937newSystem*X~qy^";
|
|
@@ -20,9 +20,10 @@ export type SystemSelectionAnswerType = {
|
|
|
20
20
|
* @param backendSystem the backend system to connect to
|
|
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
|
+
* @param cachedConnectedSystem - if available passing an already connected system connection will prevent re-authentication for re-entrance ticket and service keys connection types
|
|
23
24
|
* @returns the validation result of the backend system connection
|
|
24
25
|
*/
|
|
25
|
-
export declare function connectWithBackendSystem(backendSystem: BackendSystem, connectionValidator: ConnectionValidator, requiredOdataVersion?: OdataVersion): Promise<ValidationResult>;
|
|
26
|
+
export declare function connectWithBackendSystem(backendSystem: BackendSystem, connectionValidator: ConnectionValidator, requiredOdataVersion?: OdataVersion, cachedConnectedSystem?: ConnectedSystem): Promise<ValidationResult>;
|
|
26
27
|
/**
|
|
27
28
|
* Connects to the specified destination and validates the connection.
|
|
28
29
|
* Note that a destination may be a system or a service connection.
|
|
@@ -10,8 +10,8 @@ exports.getBackendSystemDisplayName = getBackendSystemDisplayName;
|
|
|
10
10
|
exports.createSystemChoices = createSystemChoices;
|
|
11
11
|
exports.findDefaultSystemSelectionIndex = findDefaultSystemSelectionIndex;
|
|
12
12
|
const btp_utils_1 = require("@sap-ux/btp-utils");
|
|
13
|
-
const store_1 = require("@sap-ux/store");
|
|
14
13
|
const inquirer_common_1 = require("@sap-ux/inquirer-common");
|
|
14
|
+
const store_1 = require("@sap-ux/store");
|
|
15
15
|
const i18n_1 = require("../../../../i18n");
|
|
16
16
|
const utils_1 = require("../../../../utils");
|
|
17
17
|
const logger_helper_1 = __importDefault(require("../../../logger-helper"));
|
|
@@ -26,13 +26,19 @@ exports.CfAbapEnvServiceChoice = 'cfAbapEnvService';
|
|
|
26
26
|
* @param backendSystem the backend system to connect to
|
|
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
|
+
* @param cachedConnectedSystem - if available passing an already connected system connection will prevent re-authentication for re-entrance ticket and service keys connection types
|
|
29
30
|
* @returns the validation result of the backend system connection
|
|
30
31
|
*/
|
|
31
|
-
async function connectWithBackendSystem(backendSystem, connectionValidator, requiredOdataVersion) {
|
|
32
|
+
async function connectWithBackendSystem(backendSystem, connectionValidator, requiredOdataVersion, cachedConnectedSystem) {
|
|
32
33
|
// Create a new connection with the selected system
|
|
33
34
|
utils_1.PromptState.resetConnectedSystem();
|
|
34
35
|
let connectValResult = false;
|
|
35
36
|
if (backendSystem) {
|
|
37
|
+
// Backend systems validation supports using a cached service provider to prevent re-authentication (e.g. re-opening a browser window)
|
|
38
|
+
// In case the user has changed the URL, do not use the cached service provider.
|
|
39
|
+
if (cachedConnectedSystem && cachedConnectedSystem.backendSystem?.url === backendSystem.url) {
|
|
40
|
+
connectionValidator.setConnectedSystem(cachedConnectedSystem);
|
|
41
|
+
}
|
|
36
42
|
// Assumption: non-BAS systems are BackendSystems
|
|
37
43
|
if (backendSystem.authenticationType === 'reentranceTicket') {
|
|
38
44
|
connectValResult = await connectionValidator.validateUrl(backendSystem.url, {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Question } from 'inquirer';
|
|
2
|
-
import { type OdataServicePromptOptions, promptNames } from '../../../../types';
|
|
2
|
+
import { type ConnectedSystem, type OdataServicePromptOptions, promptNames } from '../../../../types';
|
|
3
3
|
import { ConnectionValidator } from '../../../connectionValidator';
|
|
4
4
|
import type { ServiceAnswer } from '../service-selection';
|
|
5
5
|
import { type SystemSelectionAnswerType } from './prompt-helpers';
|
|
@@ -16,9 +16,10 @@ export interface SystemSelectionAnswers extends SystemSelectionCredentialsAnswer
|
|
|
16
16
|
* Returns a list of questions for creating a new system configuration or selecting an existing stored system.
|
|
17
17
|
*
|
|
18
18
|
* @param promptOptions prompt options that may be used to customize the questions
|
|
19
|
+
* @param connectedSystem - if available passing an already connected system connection will prevent re-authentication for re-entrance ticket and service keys connection types
|
|
19
20
|
* @returns a list of questions for creating a new system configuration or selecting an existing stored system
|
|
20
21
|
*/
|
|
21
|
-
export declare function getSystemSelectionQuestions(promptOptions?: OdataServicePromptOptions): Promise<Question<SystemSelectionAnswers & ServiceAnswer>[]>;
|
|
22
|
+
export declare function getSystemSelectionQuestions(promptOptions?: OdataServicePromptOptions, connectedSystem?: ConnectedSystem): Promise<Question<SystemSelectionAnswers & ServiceAnswer>[]>;
|
|
22
23
|
/**
|
|
23
24
|
* Returns a list of existing systems, either destinations or backend systems from persistent store, depending on the environment.
|
|
24
25
|
* Note that destinations are only available in BAS environment and must include the destination attribute `WebIDEEnabled` to be listed.
|
|
@@ -26,8 +27,9 @@ export declare function getSystemSelectionQuestions(promptOptions?: OdataService
|
|
|
26
27
|
*
|
|
27
28
|
* @param connectionValidator A reference to the active connection validator, used to validate the service selection and retrieve service details.
|
|
28
29
|
* @param promptOptions prompt options that may be used to customize the questions
|
|
30
|
+
* @param cachedConnectedSystem - if available passing an already connected system connection will prevent re-authentication for re-entrance ticket and service keys connection types
|
|
29
31
|
* @returns a list of existing systems
|
|
30
32
|
*/
|
|
31
|
-
export declare function getSystemConnectionQuestions(connectionValidator: ConnectionValidator, promptOptions?: OdataServicePromptOptions): Promise<Question<SystemSelectionAnswers>[]>;
|
|
33
|
+
export declare function getSystemConnectionQuestions(connectionValidator: ConnectionValidator, promptOptions?: OdataServicePromptOptions, cachedConnectedSystem?: ConnectedSystem): Promise<Question<SystemSelectionAnswers>[]>;
|
|
32
34
|
export {};
|
|
33
35
|
//# sourceMappingURL=questions.d.ts.map
|
|
@@ -14,15 +14,15 @@ const types_1 = require("../../../../types");
|
|
|
14
14
|
const utils_1 = require("../../../../utils");
|
|
15
15
|
const connectionValidator_1 = require("../../../connectionValidator");
|
|
16
16
|
const logger_helper_1 = __importDefault(require("../../../logger-helper"));
|
|
17
|
-
const questions_1 = require("../
|
|
18
|
-
const questions_2 = require("../
|
|
19
|
-
const questions_3 = require("../
|
|
20
|
-
const questions_4 = require("../
|
|
17
|
+
const questions_1 = require("../cf-abap/questions");
|
|
18
|
+
const questions_2 = require("../credentials/questions");
|
|
19
|
+
const questions_3 = require("../new-system/questions");
|
|
20
|
+
const questions_4 = require("../service-selection/questions");
|
|
21
21
|
const validators_1 = require("../validators");
|
|
22
22
|
const prompt_helpers_1 = require("./prompt-helpers");
|
|
23
23
|
const systemSelectionPromptNamespace = 'systemSelection';
|
|
24
|
-
const usernamePromptName = `${systemSelectionPromptNamespace}:${
|
|
25
|
-
const passwordPromptName = `${systemSelectionPromptNamespace}:${
|
|
24
|
+
const usernamePromptName = `${systemSelectionPromptNamespace}:${questions_2.BasicCredentialsPromptNames.systemUsername}`;
|
|
25
|
+
const passwordPromptName = `${systemSelectionPromptNamespace}:${questions_2.BasicCredentialsPromptNames.systemPassword}`;
|
|
26
26
|
const systemSelectionPromptNames = {
|
|
27
27
|
systemSelectionCli: 'systemSelectionCli',
|
|
28
28
|
destinationServicePath: 'destinationServicePath'
|
|
@@ -33,9 +33,10 @@ const systemSelectionPromptNames = {
|
|
|
33
33
|
* @param systemSelection the selected system to validate
|
|
34
34
|
* @param connectionValidator the active connection validator to use for the connection attempt
|
|
35
35
|
* @param requiredOdataVersion the required OData version for the selected system, only the specified version will be used to request a service catalog
|
|
36
|
+
* @param cachedConnectedSystem - if available passing an already connected system connection will prevent re-authentication for re-entrance ticket and service keys connection types
|
|
36
37
|
* @returns the validation result of the selected system connection attempt
|
|
37
38
|
*/
|
|
38
|
-
async function validateSystemSelection(systemSelection, connectionValidator, requiredOdataVersion) {
|
|
39
|
+
async function validateSystemSelection(systemSelection, connectionValidator, requiredOdataVersion, cachedConnectedSystem) {
|
|
39
40
|
utils_1.PromptState.reset();
|
|
40
41
|
if (systemSelection.type === 'newSystemChoice' || systemSelection.type === 'cfAbapEnvService') {
|
|
41
42
|
// Reset the connection state
|
|
@@ -44,7 +45,7 @@ async function validateSystemSelection(systemSelection, connectionValidator, req
|
|
|
44
45
|
}
|
|
45
46
|
let connectValResult = false;
|
|
46
47
|
if (systemSelection.type === 'backendSystem') {
|
|
47
|
-
connectValResult = await (0, prompt_helpers_1.connectWithBackendSystem)(systemSelection.system, connectionValidator, requiredOdataVersion);
|
|
48
|
+
connectValResult = await (0, prompt_helpers_1.connectWithBackendSystem)(systemSelection.system, connectionValidator, requiredOdataVersion, cachedConnectedSystem);
|
|
48
49
|
}
|
|
49
50
|
else if (systemSelection.type === 'destination') {
|
|
50
51
|
// Partial URL destinations will require additional service path prompt input, so we skip the connection validation here by returning true
|
|
@@ -62,22 +63,23 @@ async function validateSystemSelection(systemSelection, connectionValidator, req
|
|
|
62
63
|
* Returns a list of questions for creating a new system configuration or selecting an existing stored system.
|
|
63
64
|
*
|
|
64
65
|
* @param promptOptions prompt options that may be used to customize the questions
|
|
66
|
+
* @param connectedSystem - if available passing an already connected system connection will prevent re-authentication for re-entrance ticket and service keys connection types
|
|
65
67
|
* @returns a list of questions for creating a new system configuration or selecting an existing stored system
|
|
66
68
|
*/
|
|
67
|
-
async function getSystemSelectionQuestions(promptOptions) {
|
|
69
|
+
async function getSystemSelectionQuestions(promptOptions, connectedSystem) {
|
|
68
70
|
utils_1.PromptState.reset();
|
|
69
71
|
const connectValidator = new connectionValidator_1.ConnectionValidator();
|
|
70
|
-
const questions = await getSystemConnectionQuestions(connectValidator, promptOptions);
|
|
72
|
+
const questions = await getSystemConnectionQuestions(connectValidator, promptOptions, connectedSystem);
|
|
71
73
|
// Existing system (BackendSystem or Destination) selected,
|
|
72
74
|
if (!promptOptions?.serviceSelection?.hide) {
|
|
73
|
-
questions.push(...(0, inquirer_common_1.withCondition)((0,
|
|
75
|
+
questions.push(...(0, inquirer_common_1.withCondition)((0, questions_4.getSystemServiceQuestion)(connectValidator, systemSelectionPromptNamespace, promptOptions?.serviceSelection), (answers) => answers.systemSelection?.type !== 'newSystemChoice'));
|
|
74
76
|
}
|
|
75
77
|
// Create new system connection for storage only supported on non-App Studio environments
|
|
76
78
|
if (!(0, btp_utils_1.isAppStudio)()) {
|
|
77
|
-
questions.push(...(0, inquirer_common_1.withCondition)((0,
|
|
79
|
+
questions.push(...(0, inquirer_common_1.withCondition)((0, questions_3.getNewSystemQuestions)(promptOptions, connectedSystem), (answers) => answers.systemSelection?.type === 'newSystemChoice'));
|
|
78
80
|
}
|
|
79
81
|
else {
|
|
80
|
-
questions.push(...(0, inquirer_common_1.withCondition)((0,
|
|
82
|
+
questions.push(...(0, inquirer_common_1.withCondition)((0, questions_1.getCfAbapBASQuestions)(promptOptions?.serviceSelection), (answers) => answers.systemSelection?.type === 'cfAbapEnvService'));
|
|
81
83
|
}
|
|
82
84
|
return questions;
|
|
83
85
|
}
|
|
@@ -88,9 +90,10 @@ async function getSystemSelectionQuestions(promptOptions) {
|
|
|
88
90
|
*
|
|
89
91
|
* @param connectionValidator A reference to the active connection validator, used to validate the service selection and retrieve service details.
|
|
90
92
|
* @param promptOptions prompt options that may be used to customize the questions
|
|
93
|
+
* @param cachedConnectedSystem - if available passing an already connected system connection will prevent re-authentication for re-entrance ticket and service keys connection types
|
|
91
94
|
* @returns a list of existing systems
|
|
92
95
|
*/
|
|
93
|
-
async function getSystemConnectionQuestions(connectionValidator, promptOptions) {
|
|
96
|
+
async function getSystemConnectionQuestions(connectionValidator, promptOptions, cachedConnectedSystem) {
|
|
94
97
|
const requiredOdataVersion = promptOptions?.serviceSelection?.requiredOdataVersion;
|
|
95
98
|
const destinationFilters = promptOptions?.systemSelection?.destinationFilters;
|
|
96
99
|
const systemChoices = await (0, prompt_helpers_1.createSystemChoices)(destinationFilters, promptOptions?.systemSelection?.includeCloudFoundryAbapEnvChoice);
|
|
@@ -117,7 +120,7 @@ async function getSystemConnectionQuestions(connectionValidator, promptOptions)
|
|
|
117
120
|
if (promptOptions?.systemSelection?.useAutoComplete && selectedSystem.value) {
|
|
118
121
|
selectedSystemAnswer = selectedSystem.value;
|
|
119
122
|
}
|
|
120
|
-
return (validateSystemSelection(selectedSystemAnswer, connectionValidator, requiredOdataVersion) ?? false);
|
|
123
|
+
return (validateSystemSelection(selectedSystemAnswer, connectionValidator, requiredOdataVersion, cachedConnectedSystem) ?? false);
|
|
121
124
|
},
|
|
122
125
|
additionalMessages: async (selectedSystem) => {
|
|
123
126
|
// Backend systems credentials may need to be updated
|
|
@@ -192,7 +195,7 @@ async function getSystemConnectionQuestions(connectionValidator, promptOptions)
|
|
|
192
195
|
name: `${systemSelectionPromptNames.systemSelectionCli}`
|
|
193
196
|
});
|
|
194
197
|
}
|
|
195
|
-
questions.push(...(0,
|
|
198
|
+
questions.push(...(0, questions_2.getCredentialsPrompts)(connectionValidator, systemSelectionPromptNamespace));
|
|
196
199
|
return questions;
|
|
197
200
|
}
|
|
198
201
|
//# sourceMappingURL=questions.js.map
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { type OdataServicePromptOptions, type OdataServiceQuestion } from '../types';
|
|
1
|
+
import { type ConnectedSystem, type OdataServicePromptOptions, type OdataServiceQuestion } from '../types';
|
|
2
2
|
/**
|
|
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 and service keys connection types
|
|
6
7
|
* @returns the prompts used to provide input for OData service generation
|
|
7
8
|
*/
|
|
8
|
-
export declare function getQuestions(promptOptions?: OdataServicePromptOptions): Promise<OdataServiceQuestion[]>;
|
|
9
|
+
export declare function getQuestions(promptOptions?: OdataServicePromptOptions, connectedSystem?: ConnectedSystem): Promise<OdataServiceQuestion[]>;
|
|
9
10
|
//# sourceMappingURL=prompts.d.ts.map
|
package/dist/prompts/prompts.js
CHANGED
|
@@ -13,12 +13,13 @@ 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 and service keys connection types
|
|
16
17
|
* @returns the prompts used to provide input for OData service generation
|
|
17
18
|
*/
|
|
18
|
-
async function getQuestions(promptOptions) {
|
|
19
|
+
async function getQuestions(promptOptions, connectedSystem) {
|
|
19
20
|
const questions = [getDatasourceTypeQuestion(promptOptions?.datasourceType)];
|
|
20
21
|
// Add conditional questions depending on the selected source
|
|
21
|
-
questions.push(...(await getDatasourceTypeConditionalQuestions(promptOptions)));
|
|
22
|
+
questions.push(...(await getDatasourceTypeConditionalQuestions(promptOptions, connectedSystem)));
|
|
22
23
|
return questions;
|
|
23
24
|
}
|
|
24
25
|
/**
|
|
@@ -44,11 +45,12 @@ function getDatasourceTypeQuestion(options) {
|
|
|
44
45
|
* Apply addiitonal when conditions based on the datasource type answer.
|
|
45
46
|
*
|
|
46
47
|
* @param promptOptions - options that can control some of the prompt behavior. See {@link OdataServicePromptOptions} for details
|
|
48
|
+
* @param connectedSystem
|
|
47
49
|
* @returns the conditional questions based on the datasource type answer
|
|
48
50
|
*/
|
|
49
|
-
async function getDatasourceTypeConditionalQuestions(promptOptions) {
|
|
51
|
+
async function getDatasourceTypeConditionalQuestions(promptOptions, connectedSystem) {
|
|
50
52
|
const conditionalQuestions = [];
|
|
51
|
-
conditionalQuestions.push(...(0, inquirer_common_1.withCondition)((await (0, system_selection_1.getSystemSelectionQuestions)(promptOptions)), (answers) => answers.datasourceType === types_1.DatasourceType.sapSystem));
|
|
53
|
+
conditionalQuestions.push(...(0, inquirer_common_1.withCondition)((await (0, system_selection_1.getSystemSelectionQuestions)(promptOptions, connectedSystem)), (answers) => answers.datasourceType === types_1.DatasourceType.sapSystem));
|
|
52
54
|
conditionalQuestions.push(...(0, inquirer_common_1.withCondition)([(0, metadata_file_1.getMetadataFileQuestion)(promptOptions?.metadataFilePath)], (answers) => answers.datasourceType === types_1.DatasourceType.metadataFile));
|
|
53
55
|
conditionalQuestions.push(...(0, inquirer_common_1.withCondition)((0, questions_1.getLocalCapProjectPrompts)(promptOptions), (answers) => answers.datasourceType === types_1.DatasourceType.capProject));
|
|
54
56
|
conditionalQuestions.push(...(0, inquirer_common_1.withCondition)((0, questions_2.getServiceUrlQuestions)(promptOptions?.serviceUrl), (answers) => answers.datasourceType === types_1.DatasourceType.odataServiceUrl));
|
package/dist/types.d.ts
CHANGED
|
@@ -74,23 +74,24 @@ export interface OdataServiceAnswers {
|
|
|
74
74
|
* The connected system will allow downstream consumers to access the connected system without creating new connections.
|
|
75
75
|
*
|
|
76
76
|
*/
|
|
77
|
-
connectedSystem?:
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
* The destination information for the connected system
|
|
91
|
-
*/
|
|
92
|
-
destination?: Destination;
|
|
77
|
+
connectedSystem?: ConnectedSystem;
|
|
78
|
+
}
|
|
79
|
+
export interface ConnectedSystem {
|
|
80
|
+
/**
|
|
81
|
+
* Convienence property to pass the connected system
|
|
82
|
+
*/
|
|
83
|
+
serviceProvider: ServiceProvider;
|
|
84
|
+
/**
|
|
85
|
+
* The persistable backend system representation of the connected service provider
|
|
86
|
+
* `newOrUpdated` is set to true if the system was newly created or updated during the connection validation process and should be considered for storage.
|
|
87
|
+
*/
|
|
88
|
+
backendSystem?: BackendSystem & {
|
|
89
|
+
newOrUpdated?: boolean;
|
|
93
90
|
};
|
|
91
|
+
/**
|
|
92
|
+
* The destination information for the connected system
|
|
93
|
+
*/
|
|
94
|
+
destination?: Destination;
|
|
94
95
|
}
|
|
95
96
|
/**
|
|
96
97
|
* Enumeration of prompt names used by OdataServiceInquirerPromptOptions
|
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.3.
|
|
4
|
+
"version": "2.3.4",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/SAP/open-ux-tools.git",
|
|
@@ -30,13 +30,13 @@
|
|
|
30
30
|
"os-name": "4.0.1",
|
|
31
31
|
"@sap-ux/axios-extension": "1.20.0",
|
|
32
32
|
"@sap-ux/btp-utils": "1.0.3",
|
|
33
|
-
"@sap-ux/fiori-generator-shared": "0.11.
|
|
33
|
+
"@sap-ux/fiori-generator-shared": "0.11.2",
|
|
34
34
|
"@sap-ux/guided-answers-helper": "0.2.2",
|
|
35
|
-
"@sap-ux/telemetry": "0.5.
|
|
36
|
-
"@sap-ux/inquirer-common": "0.6.
|
|
35
|
+
"@sap-ux/telemetry": "0.5.77",
|
|
36
|
+
"@sap-ux/inquirer-common": "0.6.39",
|
|
37
37
|
"@sap-ux/logger": "0.6.0",
|
|
38
|
-
"@sap-ux/project-access": "1.29.
|
|
39
|
-
"@sap-ux/project-input-validator": "0.5.
|
|
38
|
+
"@sap-ux/project-access": "1.29.21",
|
|
39
|
+
"@sap-ux/project-input-validator": "0.5.4",
|
|
40
40
|
"@sap-ux/store": "1.0.0"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
@@ -46,12 +46,12 @@
|
|
|
46
46
|
"@types/inquirer": "8.2.6",
|
|
47
47
|
"@types/lodash": "4.14.202",
|
|
48
48
|
"jest-extended": "3.2.4",
|
|
49
|
-
"@sap-ux/fiori-generator-shared": "0.11.
|
|
50
|
-
"@sap-ux/fiori-elements-writer": "2.3.
|
|
51
|
-
"@sap-ux/fiori-freestyle-writer": "2.3.
|
|
49
|
+
"@sap-ux/fiori-generator-shared": "0.11.2",
|
|
50
|
+
"@sap-ux/fiori-elements-writer": "2.3.2",
|
|
51
|
+
"@sap-ux/fiori-freestyle-writer": "2.3.2",
|
|
52
52
|
"@sap-ux/feature-toggle": "0.2.3",
|
|
53
|
-
"@sap-ux/odata-service-writer": "0.26.
|
|
54
|
-
"@sap-ux/cap-config-writer": "0.9.
|
|
53
|
+
"@sap-ux/odata-service-writer": "0.26.16",
|
|
54
|
+
"@sap-ux/cap-config-writer": "0.9.28"
|
|
55
55
|
},
|
|
56
56
|
"engines": {
|
|
57
57
|
"node": ">=18.x"
|