@sap-ux/odata-service-inquirer 0.5.60 → 0.6.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/i18n.js +15 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +10 -9
- package/dist/prompts/connectionValidator.d.ts +63 -12
- package/dist/prompts/connectionValidator.js +208 -50
- package/dist/prompts/datasources/cap-project/questions.js +2 -1
- package/dist/prompts/datasources/sap-system/abap-on-btp/questions.d.ts +3 -2
- package/dist/prompts/datasources/sap-system/abap-on-btp/questions.js +10 -10
- package/dist/prompts/datasources/sap-system/abap-on-prem/questions.d.ts +9 -11
- package/dist/prompts/datasources/sap-system/abap-on-prem/questions.js +21 -55
- package/dist/prompts/datasources/sap-system/credentials/questions.d.ts +21 -0
- package/dist/prompts/datasources/sap-system/credentials/questions.js +123 -0
- package/dist/prompts/datasources/sap-system/new-system/questions.d.ts +4 -26
- package/dist/prompts/datasources/sap-system/new-system/questions.js +18 -168
- package/dist/prompts/datasources/sap-system/new-system/types.d.ts +0 -10
- package/dist/prompts/datasources/sap-system/service-selection/index.d.ts +3 -0
- package/dist/prompts/datasources/sap-system/service-selection/index.js +19 -0
- package/dist/prompts/datasources/sap-system/service-selection/questions.d.ts +15 -0
- package/dist/prompts/datasources/sap-system/service-selection/questions.js +146 -0
- package/dist/prompts/datasources/sap-system/service-selection/service-helper.d.ts +71 -0
- package/dist/prompts/datasources/sap-system/service-selection/service-helper.js +282 -0
- package/dist/prompts/datasources/sap-system/service-selection/types.d.ts +11 -0
- package/dist/prompts/datasources/sap-system/service-selection/types.js +3 -0
- package/dist/prompts/datasources/sap-system/system-selection/index.d.ts +2 -0
- package/dist/prompts/datasources/sap-system/system-selection/index.js +18 -0
- package/dist/prompts/datasources/sap-system/system-selection/prompt-helpers.d.ts +44 -0
- package/dist/prompts/datasources/sap-system/system-selection/prompt-helpers.js +190 -0
- package/dist/prompts/datasources/sap-system/system-selection/questions.d.ts +40 -0
- package/dist/prompts/datasources/sap-system/system-selection/questions.js +182 -0
- package/dist/prompts/datasources/sap-system/validators.d.ts +8 -0
- package/dist/prompts/datasources/sap-system/validators.js +17 -0
- package/dist/prompts/datasources/service-url/questions.js +4 -3
- package/dist/prompts/datasources/service-url/validators.js +8 -9
- package/dist/prompts/prompt-helpers.d.ts +2 -3
- package/dist/prompts/prompt-helpers.js +4 -13
- package/dist/prompts/prompts.js +5 -34
- package/dist/prompts/validators.d.ts +1 -1
- package/dist/prompts/validators.js +1 -1
- package/dist/translations/odata-service-inquirer.i18n.json +25 -37
- package/dist/types.d.ts +57 -45
- package/dist/types.js +7 -41
- package/dist/utils/index.d.ts +5 -18
- package/dist/utils/index.js +10 -55
- package/package.json +10 -9
- package/dist/error-handler/error-handler.d.ts +0 -184
- package/dist/error-handler/error-handler.js +0 -465
- package/dist/prompts/datasources/sap-system/abap-on-btp/cf-helper.d.ts +0 -9
- package/dist/prompts/datasources/sap-system/abap-on-btp/cf-helper.js +0 -54
- package/dist/prompts/datasources/sap-system/new-system/service-helper.d.ts +0 -43
- package/dist/prompts/datasources/sap-system/new-system/service-helper.js +0 -175
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.abapOnPremInternalPromptNames = void 0;
|
|
4
3
|
exports.getAbapOnPremQuestions = getAbapOnPremQuestions;
|
|
5
4
|
exports.getAbapOnPremSystemQuestions = getAbapOnPremSystemQuestions;
|
|
6
5
|
const inquirer_common_1 = require("@sap-ux/inquirer-common");
|
|
@@ -8,16 +7,17 @@ const project_input_validator_1 = require("@sap-ux/project-input-validator");
|
|
|
8
7
|
const i18n_1 = require("../../../../i18n");
|
|
9
8
|
const utils_1 = require("../../../../utils");
|
|
10
9
|
const connectionValidator_1 = require("../../../connectionValidator");
|
|
11
|
-
const questions_1 = require("../
|
|
10
|
+
const questions_1 = require("../credentials/questions");
|
|
11
|
+
const questions_2 = require("../new-system/questions");
|
|
12
12
|
const types_1 = require("../new-system/types");
|
|
13
|
+
const service_selection_1 = require("../service-selection");
|
|
13
14
|
const abapOnPremPromptNamespace = 'abapOnPrem';
|
|
14
15
|
const systemUrlPromptName = `${abapOnPremPromptNamespace}:${types_1.newSystemPromptNames.newSystemUrl}`;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
})(abapOnPremInternalPromptNames || (exports.abapOnPremInternalPromptNames = abapOnPremInternalPromptNames = {}));
|
|
16
|
+
const usernamePromptName = `${abapOnPremPromptNamespace}:${questions_1.BasicCredentialsPromptNames.systemUsername}`;
|
|
17
|
+
const passwordPromptName = `${abapOnPremPromptNamespace}:${questions_1.BasicCredentialsPromptNames.systemPassword}`;
|
|
18
|
+
const abapOnPremPromptNames = {
|
|
19
|
+
sapClient: 'sapClient'
|
|
20
|
+
};
|
|
21
21
|
/**
|
|
22
22
|
* Get the Abap on-premise datasource questions.
|
|
23
23
|
*
|
|
@@ -30,7 +30,7 @@ function getAbapOnPremQuestions(promptOptions) {
|
|
|
30
30
|
// Prompt options
|
|
31
31
|
const requiredOdataVersion = promptOptions?.serviceSelection?.requiredOdataVersion;
|
|
32
32
|
const questions = getAbapOnPremSystemQuestions(promptOptions?.userSystemName, connectValidator, requiredOdataVersion);
|
|
33
|
-
questions.push(...(0,
|
|
33
|
+
questions.push(...(0, service_selection_1.getSystemServiceQuestion)(connectValidator, abapOnPremPromptNamespace, promptOptions));
|
|
34
34
|
return questions;
|
|
35
35
|
}
|
|
36
36
|
/**
|
|
@@ -43,12 +43,14 @@ function getAbapOnPremQuestions(promptOptions) {
|
|
|
43
43
|
*/
|
|
44
44
|
function getAbapOnPremSystemQuestions(systemNamePromptOptions, connectionValidator, requiredOdataVersion) {
|
|
45
45
|
const connectValidator = connectionValidator ?? new connectionValidator_1.ConnectionValidator();
|
|
46
|
-
|
|
46
|
+
// Object reference to access dynamic sapClient value in prompts where the previous answers are not available.
|
|
47
|
+
// This allows re-usability of the credentials prompts where a client prompt was not used (client was loaded from store).
|
|
48
|
+
const sapClientRef = { sapClient: undefined, isValid: true };
|
|
47
49
|
const questions = [
|
|
48
|
-
(0,
|
|
50
|
+
(0, questions_2.getSystemUrlQuestion)(connectValidator, abapOnPremPromptNamespace, requiredOdataVersion),
|
|
49
51
|
{
|
|
50
52
|
type: 'input',
|
|
51
|
-
name:
|
|
53
|
+
name: abapOnPremPromptNames.sapClient,
|
|
52
54
|
message: (0, i18n_1.t)('prompts.sapClient.message'),
|
|
53
55
|
guiOptions: {
|
|
54
56
|
breadcrumb: (0, i18n_1.t)('prompts.sapClient.breadcrumb')
|
|
@@ -56,58 +58,22 @@ function getAbapOnPremSystemQuestions(systemNamePromptOptions, connectionValidat
|
|
|
56
58
|
validate: (client) => {
|
|
57
59
|
const valRes = (0, project_input_validator_1.validateClient)(client);
|
|
58
60
|
if (valRes === true) {
|
|
59
|
-
|
|
61
|
+
sapClientRef.sapClient = client;
|
|
62
|
+
sapClientRef.isValid = true;
|
|
60
63
|
return true;
|
|
61
64
|
}
|
|
62
|
-
|
|
65
|
+
sapClientRef.sapClient = undefined;
|
|
66
|
+
sapClientRef.isValid = false;
|
|
63
67
|
return valRes;
|
|
64
68
|
}
|
|
65
69
|
},
|
|
66
|
-
|
|
67
|
-
when: () => connectValidator.isAuthRequired(),
|
|
68
|
-
type: 'input',
|
|
69
|
-
name: abapOnPremInternalPromptNames.systemUsername,
|
|
70
|
-
message: (0, i18n_1.t)('prompts.systemUsername.message'),
|
|
71
|
-
guiOptions: {
|
|
72
|
-
mandatory: true
|
|
73
|
-
},
|
|
74
|
-
default: '',
|
|
75
|
-
validate: (user) => user?.length > 0
|
|
76
|
-
},
|
|
77
|
-
{
|
|
78
|
-
when: () => connectValidator.isAuthRequired(),
|
|
79
|
-
type: 'password',
|
|
80
|
-
guiOptions: {
|
|
81
|
-
mandatory: true
|
|
82
|
-
},
|
|
83
|
-
name: abapOnPremInternalPromptNames.systemPassword,
|
|
84
|
-
message: (0, i18n_1.t)('prompts.systemPassword.message'),
|
|
85
|
-
guiType: 'login',
|
|
86
|
-
mask: '*',
|
|
87
|
-
default: '',
|
|
88
|
-
validate: async (password, answers) => {
|
|
89
|
-
if (!(connectValidator.validatedUrl && answers.abapSystemUsername && password && validClient)) {
|
|
90
|
-
return false;
|
|
91
|
-
}
|
|
92
|
-
const valResult = await connectValidator.validateAuth(connectValidator.validatedUrl, answers.abapSystemUsername, password, {
|
|
93
|
-
sapClient: answers.sapClient,
|
|
94
|
-
isSystem: true
|
|
95
|
-
});
|
|
96
|
-
if (valResult === true && connectValidator.serviceProvider) {
|
|
97
|
-
utils_1.PromptState.odataService.connectedSystem = {
|
|
98
|
-
serviceProvider: connectValidator.serviceProvider
|
|
99
|
-
};
|
|
100
|
-
return true;
|
|
101
|
-
}
|
|
102
|
-
return valResult;
|
|
103
|
-
}
|
|
104
|
-
}
|
|
70
|
+
...(0, questions_1.getCredentialsPrompts)(connectValidator, abapOnPremPromptNamespace, sapClientRef)
|
|
105
71
|
];
|
|
106
72
|
if (systemNamePromptOptions?.hide !== true) {
|
|
107
73
|
// New system question will allow user to give the system a user friendly name
|
|
108
|
-
questions.push((0, inquirer_common_1.withCondition)([(0,
|
|
74
|
+
questions.push((0, inquirer_common_1.withCondition)([(0, questions_2.getUserSystemNameQuestion)(connectValidator, abapOnPremPromptNamespace)], (answers) => !!answers?.[systemUrlPromptName] &&
|
|
109
75
|
connectValidator.validity.reachable === true &&
|
|
110
|
-
(connectValidator.validity.authenticated || connectValidator.validity.authRequired
|
|
76
|
+
(connectValidator.validity.authenticated || connectValidator.validity.authRequired === false))[0]);
|
|
111
77
|
}
|
|
112
78
|
return questions;
|
|
113
79
|
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Answers, Question } from 'inquirer';
|
|
2
|
+
import type { ConnectionValidator } from '../../../connectionValidator';
|
|
3
|
+
export declare enum BasicCredentialsPromptNames {
|
|
4
|
+
systemUsername = "systemUsername",
|
|
5
|
+
systemPassword = "systemPassword"
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Re-usable credentials prompts for connection to systems using basic auth.
|
|
9
|
+
*
|
|
10
|
+
* @param connectionValidator the connection validator to be used for the credentials validation
|
|
11
|
+
* @param promptNamespace the namespace to be used for the prompts when used multiple times in the same prompt set
|
|
12
|
+
* @param sapClient
|
|
13
|
+
* @param sapClient.sapClient the sapClient value to be used along with the credentials validation
|
|
14
|
+
* @param sapClient.isValid validation of credentials is deferred until a valid sapClient is provided or undefined
|
|
15
|
+
* @returns the credentials prompts
|
|
16
|
+
*/
|
|
17
|
+
export declare function getCredentialsPrompts<T extends Answers>(connectionValidator: ConnectionValidator, promptNamespace?: string, sapClient?: {
|
|
18
|
+
sapClient: string | undefined;
|
|
19
|
+
isValid: boolean;
|
|
20
|
+
}): Question<T>[];
|
|
21
|
+
//# sourceMappingURL=questions.d.ts.map
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BasicCredentialsPromptNames = void 0;
|
|
4
|
+
exports.getCredentialsPrompts = getCredentialsPrompts;
|
|
5
|
+
const btp_utils_1 = require("@sap-ux/btp-utils");
|
|
6
|
+
const i18n_1 = require("../../../../i18n");
|
|
7
|
+
const types_1 = require("../../../../types");
|
|
8
|
+
const utils_1 = require("../../../../utils");
|
|
9
|
+
var BasicCredentialsPromptNames;
|
|
10
|
+
(function (BasicCredentialsPromptNames) {
|
|
11
|
+
BasicCredentialsPromptNames["systemUsername"] = "systemUsername";
|
|
12
|
+
BasicCredentialsPromptNames["systemPassword"] = "systemPassword";
|
|
13
|
+
})(BasicCredentialsPromptNames || (exports.BasicCredentialsPromptNames = BasicCredentialsPromptNames = {}));
|
|
14
|
+
/**
|
|
15
|
+
* Re-usable credentials prompts for connection to systems using basic auth.
|
|
16
|
+
*
|
|
17
|
+
* @param connectionValidator the connection validator to be used for the credentials validation
|
|
18
|
+
* @param promptNamespace the namespace to be used for the prompts when used multiple times in the same prompt set
|
|
19
|
+
* @param sapClient
|
|
20
|
+
* @param sapClient.sapClient the sapClient value to be used along with the credentials validation
|
|
21
|
+
* @param sapClient.isValid validation of credentials is deferred until a valid sapClient is provided or undefined
|
|
22
|
+
* @returns the credentials prompts
|
|
23
|
+
*/
|
|
24
|
+
function getCredentialsPrompts(connectionValidator, promptNamespace, sapClient) {
|
|
25
|
+
const usernamePromptName = `${promptNamespace ? promptNamespace + ':' : ''}${BasicCredentialsPromptNames.systemUsername}`;
|
|
26
|
+
const passwordPromptName = `${promptNamespace ? promptNamespace + ':' : ''}${BasicCredentialsPromptNames.systemPassword}`;
|
|
27
|
+
// Optimization to prevent re-checking of auth
|
|
28
|
+
let authRequired;
|
|
29
|
+
return [
|
|
30
|
+
{
|
|
31
|
+
when: async () => {
|
|
32
|
+
authRequired = await connectionValidator.isAuthRequired();
|
|
33
|
+
return connectionValidator.systemAuthType === 'basic' && authRequired;
|
|
34
|
+
},
|
|
35
|
+
type: 'input',
|
|
36
|
+
name: usernamePromptName,
|
|
37
|
+
message: (0, i18n_1.t)('prompts.systemUsername.message'),
|
|
38
|
+
guiOptions: {
|
|
39
|
+
mandatory: true
|
|
40
|
+
},
|
|
41
|
+
default: '',
|
|
42
|
+
validate: (user) => user?.length > 0
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
when: () => connectionValidator.systemAuthType === 'basic' && authRequired,
|
|
46
|
+
type: 'password',
|
|
47
|
+
guiOptions: {
|
|
48
|
+
mandatory: true,
|
|
49
|
+
applyDefaultWhenDirty: true // Reset when the system changes, this avoids automatic reauth with the existing creds if the user changes the system selection
|
|
50
|
+
},
|
|
51
|
+
guiType: 'login',
|
|
52
|
+
name: passwordPromptName,
|
|
53
|
+
message: (0, i18n_1.t)('prompts.systemPassword.message'),
|
|
54
|
+
mask: '*',
|
|
55
|
+
default: '',
|
|
56
|
+
validate: async (password, answers) => {
|
|
57
|
+
if (!(connectionValidator.validatedUrl &&
|
|
58
|
+
answers?.[usernamePromptName] &&
|
|
59
|
+
password &&
|
|
60
|
+
(sapClient?.isValid || !sapClient))) {
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
// We may have a previously selected system
|
|
64
|
+
const selectedSystem = answers?.[types_1.promptNames.systemSelection];
|
|
65
|
+
let selectedSystemClient;
|
|
66
|
+
let isSystem = true;
|
|
67
|
+
if (selectedSystem?.type === 'backendSystem') {
|
|
68
|
+
selectedSystemClient = selectedSystem.system?.client;
|
|
69
|
+
}
|
|
70
|
+
else if (selectedSystem?.type === 'destination') {
|
|
71
|
+
// Note no need to set the client as its specified by the destination itself
|
|
72
|
+
const destination = selectedSystem.system;
|
|
73
|
+
if ((0, btp_utils_1.isFullUrlDestination)(destination) || (0, btp_utils_1.isPartialUrlDestination)(destination)) {
|
|
74
|
+
isSystem = false;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
const { valResult } = await connectionValidator.validateAuth(connectionValidator.validatedUrl, answers?.[usernamePromptName], password, {
|
|
78
|
+
sapClient: sapClient?.sapClient || selectedSystemClient,
|
|
79
|
+
isSystem
|
|
80
|
+
});
|
|
81
|
+
if (valResult === true && connectionValidator.serviceProvider) {
|
|
82
|
+
updatePromptStateWithConnectedSystem(connectionValidator.serviceProvider, selectedSystem, {
|
|
83
|
+
username: answers?.[usernamePromptName],
|
|
84
|
+
password: password
|
|
85
|
+
});
|
|
86
|
+
return true;
|
|
87
|
+
}
|
|
88
|
+
return valResult;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
];
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Updates the prompt state with the connected system.
|
|
95
|
+
*
|
|
96
|
+
* @param serviceProvider the connected system service provider which is used to update the prompt state
|
|
97
|
+
* @param selectedSystem the selected system, either a backend system or a destination
|
|
98
|
+
* @param credentials
|
|
99
|
+
* @param credentials.username the username
|
|
100
|
+
* @param credentials.password the password
|
|
101
|
+
*/
|
|
102
|
+
function updatePromptStateWithConnectedSystem(serviceProvider, selectedSystem, { username, password }) {
|
|
103
|
+
utils_1.PromptState.odataService.connectedSystem = {
|
|
104
|
+
serviceProvider
|
|
105
|
+
};
|
|
106
|
+
// Update the existing backend system with the new credentials that may be used to update in the store.
|
|
107
|
+
if (selectedSystem?.type === 'backendSystem') {
|
|
108
|
+
const backendSystem = selectedSystem.system;
|
|
109
|
+
// Have the credentials changed..
|
|
110
|
+
if (backendSystem.username !== username || backendSystem.password !== password) {
|
|
111
|
+
utils_1.PromptState.odataService.connectedSystem.backendSystem = Object.assign(backendSystem, {
|
|
112
|
+
username: username,
|
|
113
|
+
password,
|
|
114
|
+
newOrUpdated: true
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
// If the connection is successful and a destination was selected, assign the connected destination to the prompt state.
|
|
118
|
+
}
|
|
119
|
+
else if (selectedSystem?.type === 'destination') {
|
|
120
|
+
utils_1.PromptState.odataService.connectedSystem.destination = selectedSystem.system;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
//# sourceMappingURL=questions.js.map
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* New system prompting questions for re-use in multiple sap-system datasource prompt sets.
|
|
3
|
+
*/
|
|
1
4
|
import { type InputQuestion } from '@sap-ux/inquirer-common';
|
|
2
5
|
import type { OdataVersion } from '@sap-ux/odata-service-writer';
|
|
3
6
|
import type { Answers, Question } from 'inquirer';
|
|
4
|
-
import type {
|
|
7
|
+
import type { OdataServicePromptOptions, SapSystemType } from '../../../../types';
|
|
5
8
|
import { promptNames } from '../../../../types';
|
|
6
9
|
import type { ConnectionValidator } from '../../../connectionValidator';
|
|
7
10
|
import { newSystemPromptNames } from './types';
|
|
8
|
-
export declare const newSystemChoiceValue = "!@\u00A3*&937newSystem*X~qy^";
|
|
9
11
|
/**
|
|
10
12
|
* Internal only answers to service URL prompting not returned with OdataServiceAnswers.
|
|
11
13
|
*/
|
|
@@ -13,12 +15,6 @@ export interface NewSystemAnswers {
|
|
|
13
15
|
[newSystemPromptNames.newSystemType]?: SapSystemType;
|
|
14
16
|
[promptNames.userSystemName]?: string;
|
|
15
17
|
}
|
|
16
|
-
declare const systemSelectionPromptNames: {
|
|
17
|
-
readonly system: "system";
|
|
18
|
-
};
|
|
19
|
-
export interface SystemSelectionAnswer extends OdataServiceAnswers {
|
|
20
|
-
[systemSelectionPromptNames.system]?: string;
|
|
21
|
-
}
|
|
22
18
|
/**
|
|
23
19
|
* Provides prompts that allow the creation of a new system connection.
|
|
24
20
|
*
|
|
@@ -45,22 +41,4 @@ export declare function getSystemUrlQuestion<T extends Answers>(connectValidator
|
|
|
45
41
|
* @returns the new system name prompt
|
|
46
42
|
*/
|
|
47
43
|
export declare function getUserSystemNameQuestion(connectValidator: ConnectionValidator, promptNamespace?: string): InputQuestion<Partial<NewSystemAnswers>>;
|
|
48
|
-
/**
|
|
49
|
-
* Create a value for the service selection prompt message, which may include thge active connected user name.
|
|
50
|
-
*
|
|
51
|
-
* @param username The connected user name
|
|
52
|
-
* @returns The service selection prompt message
|
|
53
|
-
*/
|
|
54
|
-
export declare function getSelectedServiceLabel(username: string | undefined): string;
|
|
55
|
-
/**
|
|
56
|
-
* Get the service selection prompt for a system connection. The service selection prompt is used to select a service from the system catalog.
|
|
57
|
-
*
|
|
58
|
-
* @param connectValidator A reference to the active connection validator, used to validate the service selection and retrieve service details.
|
|
59
|
-
* @param promptNamespace The namespace for the prompt, used to identify the prompt instance and namespaced answers.
|
|
60
|
-
* This is used to avoid conflicts with other prompts of the same types.
|
|
61
|
-
* @param promptOptions Options for the service selection prompt see {@link OdataServicePromptOptions}
|
|
62
|
-
* @returns the service selection prompt
|
|
63
|
-
*/
|
|
64
|
-
export declare function getSystemServiceQuestion<T extends Answers>(connectValidator: ConnectionValidator, promptNamespace: string, promptOptions?: OdataServicePromptOptions): Question<T>[];
|
|
65
|
-
export {};
|
|
66
44
|
//# sourceMappingURL=questions.d.ts.map
|
|
@@ -1,37 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.newSystemChoiceValue = void 0;
|
|
7
3
|
exports.getNewSystemQuestions = getNewSystemQuestions;
|
|
8
4
|
exports.getSystemUrlQuestion = getSystemUrlQuestion;
|
|
9
5
|
exports.getUserSystemNameQuestion = getUserSystemNameQuestion;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const axios_extension_1 = require("@sap-ux/axios-extension");
|
|
6
|
+
/**
|
|
7
|
+
* New system prompting questions for re-use in multiple sap-system datasource prompt sets.
|
|
8
|
+
*/
|
|
14
9
|
const inquirer_common_1 = require("@sap-ux/inquirer-common");
|
|
15
10
|
const store_1 = require("@sap-ux/store");
|
|
16
11
|
const i18n_1 = require("../../../../i18n");
|
|
17
12
|
const types_1 = require("../../../../types");
|
|
18
13
|
const utils_1 = require("../../../../utils");
|
|
14
|
+
const questions_1 = require("../abap-on-btp/questions");
|
|
15
|
+
const questions_2 = require("../abap-on-prem/questions");
|
|
19
16
|
const prompt_helpers_1 = require("../prompt-helpers");
|
|
20
17
|
const validators_1 = require("../validators");
|
|
21
|
-
const service_helper_1 = require("./service-helper");
|
|
22
18
|
const types_2 = require("./types");
|
|
23
|
-
const questions_1 = require("../abap-on-prem/questions");
|
|
24
|
-
const questions_2 = require("../abap-on-btp/questions");
|
|
25
|
-
const logger_helper_1 = __importDefault(require("../../../logger-helper"));
|
|
26
|
-
const prompt_helpers_2 = require("../../../prompt-helpers");
|
|
27
|
-
const error_handler_1 = require("../../../../error-handler/error-handler");
|
|
28
|
-
// New system choice value is a hard to guess string to avoid conflicts with existing system names or user named systems
|
|
29
|
-
// since it will be used as a new system value in the system selection prompt.
|
|
30
|
-
exports.newSystemChoiceValue = '!@£*&937newSystem*X~qy^';
|
|
31
|
-
const cliServicePromptName = 'cliServiceSelection';
|
|
32
|
-
const systemSelectionPromptNames = {
|
|
33
|
-
system: 'system'
|
|
34
|
-
};
|
|
35
19
|
/**
|
|
36
20
|
* Convert the system connection scheme (Service Key, Rentrance Ticket, etc) to the store specific authentication type.
|
|
37
21
|
* Note the absence of CF Discovery, in this case the service key file (UAA) is also used for the Abap connectivity.
|
|
@@ -69,8 +53,8 @@ function getNewSystemQuestions(promptOptions) {
|
|
|
69
53
|
message: (0, i18n_1.t)('prompts.newSystemType.message')
|
|
70
54
|
}
|
|
71
55
|
];
|
|
72
|
-
questions.push(...(0, inquirer_common_1.withCondition)((0,
|
|
73
|
-
questions.push(...(0, inquirer_common_1.withCondition)((0,
|
|
56
|
+
questions.push(...(0, inquirer_common_1.withCondition)((0, questions_2.getAbapOnPremQuestions)(promptOptions), (answers) => answers.newSystemType === 'abapOnPrem'));
|
|
57
|
+
questions.push(...(0, inquirer_common_1.withCondition)((0, questions_1.getAbapOnBTPSystemQuestions)(promptOptions), (answers) => answers.newSystemType === 'abapOnBtp'));
|
|
74
58
|
return questions;
|
|
75
59
|
}
|
|
76
60
|
/**
|
|
@@ -97,11 +81,16 @@ function getSystemUrlQuestion(connectValidator, promptNamespace, requiredOdataVe
|
|
|
97
81
|
isSystem: true,
|
|
98
82
|
odataVersion: (0, utils_1.convertODataVersionType)(requiredOdataVersion)
|
|
99
83
|
});
|
|
100
|
-
// If basic auth not required we should have an active connection
|
|
101
|
-
if (valResult === true
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
84
|
+
// If basic auth not required we should have an active connection (could be a re-entrance ticket supported system url)
|
|
85
|
+
if (valResult === true) {
|
|
86
|
+
if (!connectValidator.validity.authRequired && connectValidator.serviceProvider) {
|
|
87
|
+
utils_1.PromptState.odataService.connectedSystem = {
|
|
88
|
+
serviceProvider: connectValidator.serviceProvider
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
connectValidator.systemAuthType = 'basic';
|
|
93
|
+
}
|
|
105
94
|
}
|
|
106
95
|
return valResult;
|
|
107
96
|
}
|
|
@@ -169,6 +158,7 @@ function getUserSystemNameQuestion(connectValidator, promptNamespace) {
|
|
|
169
158
|
refreshToken: connectValidator.refreshToken
|
|
170
159
|
});
|
|
171
160
|
utils_1.PromptState.odataService.connectedSystem.backendSystem = backendSystem;
|
|
161
|
+
utils_1.PromptState.odataService.connectedSystem.backendSystem.newOrUpdated = true;
|
|
172
162
|
}
|
|
173
163
|
}
|
|
174
164
|
return isValid;
|
|
@@ -176,144 +166,4 @@ function getUserSystemNameQuestion(connectValidator, promptNamespace) {
|
|
|
176
166
|
};
|
|
177
167
|
return newSystemNamePrompt;
|
|
178
168
|
}
|
|
179
|
-
/**
|
|
180
|
-
* Create a value for the service selection prompt message, which may include thge active connected user name.
|
|
181
|
-
*
|
|
182
|
-
* @param username The connected user name
|
|
183
|
-
* @returns The service selection prompt message
|
|
184
|
-
*/
|
|
185
|
-
function getSelectedServiceLabel(username) {
|
|
186
|
-
let message = (0, i18n_1.t)('prompts.systemService.message');
|
|
187
|
-
if (username) {
|
|
188
|
-
message = message.concat(` ${(0, i18n_1.t)('texts.forUserName', { username })}`);
|
|
189
|
-
}
|
|
190
|
-
return message;
|
|
191
|
-
}
|
|
192
|
-
/**
|
|
193
|
-
* Get the service selection prompt for a system connection. The service selection prompt is used to select a service from the system catalog.
|
|
194
|
-
*
|
|
195
|
-
* @param connectValidator A reference to the active connection validator, used to validate the service selection and retrieve service details.
|
|
196
|
-
* @param promptNamespace The namespace for the prompt, used to identify the prompt instance and namespaced answers.
|
|
197
|
-
* This is used to avoid conflicts with other prompts of the same types.
|
|
198
|
-
* @param promptOptions Options for the service selection prompt see {@link OdataServicePromptOptions}
|
|
199
|
-
* @returns the service selection prompt
|
|
200
|
-
*/
|
|
201
|
-
function getSystemServiceQuestion(connectValidator, promptNamespace, promptOptions) {
|
|
202
|
-
let serviceChoices = [];
|
|
203
|
-
// Prevent re-requesting services repeatedly by only requesting them once and when the system or client is changed
|
|
204
|
-
let previousSystemUrl;
|
|
205
|
-
let previousClient;
|
|
206
|
-
let previousService;
|
|
207
|
-
const requiredOdataVersion = promptOptions?.serviceSelection?.requiredOdataVersion;
|
|
208
|
-
const newSystemServiceQuestion = {
|
|
209
|
-
when: () => connectValidator.validity.authenticated || connectValidator.validity.authRequired === false,
|
|
210
|
-
name: `${promptNamespace}:${types_1.promptNames.serviceSelection}`,
|
|
211
|
-
type: promptOptions?.serviceSelection?.useAutoComplete ? 'autocomplete' : 'list',
|
|
212
|
-
message: () => getSelectedServiceLabel(connectValidator.connectedUserName),
|
|
213
|
-
guiOptions: {
|
|
214
|
-
breadcrumb: (0, i18n_1.t)('prompts.systemService.breadcrumb'),
|
|
215
|
-
mandatory: true,
|
|
216
|
-
applyDefaultWhenDirty: true
|
|
217
|
-
},
|
|
218
|
-
source: (prevAnswers, input) => (0, inquirer_common_1.searchChoices)(input, serviceChoices),
|
|
219
|
-
choices: async () => {
|
|
220
|
-
if (serviceChoices.length === 0 ||
|
|
221
|
-
previousSystemUrl !== connectValidator.validatedUrl ||
|
|
222
|
-
previousClient !== connectValidator.validatedClient) {
|
|
223
|
-
let catalogs = [];
|
|
224
|
-
if (requiredOdataVersion && connectValidator.catalogs[requiredOdataVersion]) {
|
|
225
|
-
catalogs.push(connectValidator.catalogs[requiredOdataVersion]);
|
|
226
|
-
}
|
|
227
|
-
else {
|
|
228
|
-
catalogs = Object.values(connectValidator.catalogs).filter((cat) => cat !== undefined);
|
|
229
|
-
}
|
|
230
|
-
previousSystemUrl = connectValidator.validatedUrl;
|
|
231
|
-
previousClient = connectValidator.validatedClient;
|
|
232
|
-
serviceChoices = await (0, service_helper_1.getServiceChoices)(catalogs);
|
|
233
|
-
}
|
|
234
|
-
return serviceChoices;
|
|
235
|
-
},
|
|
236
|
-
additionalMessages: (selectedService) => getSelectedServiceMessage(serviceChoices, selectedService, connectValidator, requiredOdataVersion),
|
|
237
|
-
default: () => (0, utils_1.getDefaultChoiceIndex)(serviceChoices),
|
|
238
|
-
// Warning: only executes in YUI not cli
|
|
239
|
-
validate: async (service) => {
|
|
240
|
-
if (!connectValidator.validatedUrl) {
|
|
241
|
-
return false;
|
|
242
|
-
}
|
|
243
|
-
// if no choices are available and an error is present, return the error message
|
|
244
|
-
if (serviceChoices.length === 0 && prompt_helpers_2.errorHandler.hasError()) {
|
|
245
|
-
return error_handler_1.ErrorHandler.getHelpForError(error_handler_1.ERROR_TYPE.SERVICES_UNAVAILABLE) ?? false;
|
|
246
|
-
}
|
|
247
|
-
// Dont re-request the same service details
|
|
248
|
-
if (service && previousService?.servicePath !== service.servicePath) {
|
|
249
|
-
previousService = service;
|
|
250
|
-
return (0, service_helper_1.getServiceDetails)(service, connectValidator);
|
|
251
|
-
}
|
|
252
|
-
return true;
|
|
253
|
-
}
|
|
254
|
-
};
|
|
255
|
-
const questions = [newSystemServiceQuestion];
|
|
256
|
-
// Only for CLI use as `list` prompt validation does not run on CLI
|
|
257
|
-
if ((0, utils_1.getHostEnvironment)() === types_1.hostEnvironment.cli) {
|
|
258
|
-
questions.push({
|
|
259
|
-
when: async (answers) => {
|
|
260
|
-
const selectedService = answers?.[`${promptNamespace}:${types_1.promptNames.serviceSelection}`];
|
|
261
|
-
if (selectedService && connectValidator.validatedUrl) {
|
|
262
|
-
const result = await (0, service_helper_1.getServiceDetails)(selectedService, connectValidator);
|
|
263
|
-
if (typeof result === 'string') {
|
|
264
|
-
logger_helper_1.default.logger.error(result);
|
|
265
|
-
throw new Error(result);
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
if (serviceChoices.length === 0 && prompt_helpers_2.errorHandler.hasError()) {
|
|
269
|
-
const noServicesError = error_handler_1.ErrorHandler.getHelpForError(error_handler_1.ERROR_TYPE.SERVICES_UNAVAILABLE).toString();
|
|
270
|
-
throw new Error(noServicesError);
|
|
271
|
-
}
|
|
272
|
-
return false;
|
|
273
|
-
},
|
|
274
|
-
name: `${promptNamespace}:${cliServicePromptName}`
|
|
275
|
-
});
|
|
276
|
-
}
|
|
277
|
-
return questions;
|
|
278
|
-
}
|
|
279
|
-
/**
|
|
280
|
-
* Get the service selection prompt additional message. This prompt will make an additional call to the system backend
|
|
281
|
-
* to retrieve the service type and display a warning message if the service type is not UI.
|
|
282
|
-
*
|
|
283
|
-
* @param serviceChoices a list of service choices
|
|
284
|
-
* @param selectedService the selected service
|
|
285
|
-
* @param connectValidator the connection validator
|
|
286
|
-
* @param requiredOdataVersion the required OData version for the service
|
|
287
|
-
* @returns the service selection prompt additional message
|
|
288
|
-
*/
|
|
289
|
-
async function getSelectedServiceMessage(serviceChoices, selectedService, connectValidator, requiredOdataVersion) {
|
|
290
|
-
if (serviceChoices?.length === 0) {
|
|
291
|
-
if (requiredOdataVersion) {
|
|
292
|
-
return {
|
|
293
|
-
message: (0, i18n_1.t)('prompts.warnings.noServicesAvailableForOdataVersion', {
|
|
294
|
-
odataVersion: requiredOdataVersion
|
|
295
|
-
}),
|
|
296
|
-
severity: yeoman_ui_types_1.Severity.warning
|
|
297
|
-
};
|
|
298
|
-
}
|
|
299
|
-
else {
|
|
300
|
-
return {
|
|
301
|
-
message: (0, i18n_1.t)('prompts.warnings.noServicesAvailable'),
|
|
302
|
-
severity: yeoman_ui_types_1.Severity.warning
|
|
303
|
-
};
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
if (selectedService) {
|
|
307
|
-
let serviceType = selectedService.serviceType;
|
|
308
|
-
if (selectedService.serviceODataVersion === axios_extension_1.ODataVersion.v2) {
|
|
309
|
-
serviceType = await (0, service_helper_1.getServiceType)(selectedService.servicePath, selectedService.serviceType, connectValidator.catalogs[axios_extension_1.ODataVersion.v2]);
|
|
310
|
-
}
|
|
311
|
-
if (serviceType && serviceType !== axios_extension_1.ServiceType.UI) {
|
|
312
|
-
return {
|
|
313
|
-
message: (0, i18n_1.t)('prompts.warnings.nonUIServiceTypeWarningMessage', { serviceType: 'A2X' }),
|
|
314
|
-
severity: yeoman_ui_types_1.Severity.warning
|
|
315
|
-
};
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
169
|
//# sourceMappingURL=questions.js.map
|
|
@@ -1,13 +1,3 @@
|
|
|
1
|
-
import type { ODataVersion } from '@sap-ux/axios-extension';
|
|
2
|
-
/**
|
|
3
|
-
* Sap System service answer
|
|
4
|
-
*/
|
|
5
|
-
export type ServiceAnswer = {
|
|
6
|
-
servicePath: string;
|
|
7
|
-
serviceODataVersion: ODataVersion;
|
|
8
|
-
toString: () => string;
|
|
9
|
-
serviceType?: string;
|
|
10
|
-
};
|
|
11
1
|
export declare const newSystemPromptNames: {
|
|
12
2
|
readonly newSystemType: "newSystemType";
|
|
13
3
|
readonly newSystemUrl: "newSystemUrl";
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./questions"), exports);
|
|
18
|
+
__exportStar(require("./types"), exports);
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Question } from 'inquirer';
|
|
2
|
+
import type { OdataServicePromptOptions } from '../../../../types';
|
|
3
|
+
import type { ConnectionValidator } from '../../../connectionValidator';
|
|
4
|
+
import { type ServiceAnswer } from './types';
|
|
5
|
+
/**
|
|
6
|
+
* Get the service selection prompt for an Abap system connection (on-prem or on-btp). The service selection prompt is used to select a service from the system catalog.
|
|
7
|
+
*
|
|
8
|
+
* @param connectValidator A reference to the active connection validator, used to validate the service selection and retrieve service details.
|
|
9
|
+
* @param promptNamespace The namespace for the prompt, used to identify the prompt instance and namespaced answers.
|
|
10
|
+
* This is used to avoid conflicts with other prompts of the same types.
|
|
11
|
+
* @param promptOptions Options for the service selection prompt see {@link OdataServicePromptOptions}
|
|
12
|
+
* @returns the service selection prompt
|
|
13
|
+
*/
|
|
14
|
+
export declare function getSystemServiceQuestion(connectValidator: ConnectionValidator, promptNamespace: string, promptOptions?: OdataServicePromptOptions): Question<ServiceAnswer>[];
|
|
15
|
+
//# sourceMappingURL=questions.d.ts.map
|