@sap-ux/odata-service-inquirer 2.2.27 → 2.2.28
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 +2 -2
- package/dist/prompts/datasources/sap-system/abap-on-btp/questions.js +5 -5
- package/dist/prompts/datasources/sap-system/abap-on-prem/questions.js +3 -3
- package/dist/prompts/datasources/sap-system/new-system/questions.d.ts +2 -28
- package/dist/prompts/datasources/sap-system/new-system/questions.js +2 -138
- package/dist/prompts/datasources/sap-system/shared-prompts/shared-prompts.d.ts +28 -0
- package/dist/prompts/datasources/sap-system/shared-prompts/shared-prompts.js +141 -0
- package/dist/prompts/datasources/sap-system/system-selection/prompt-helpers.d.ts +4 -1
- package/dist/prompts/datasources/sap-system/system-selection/prompt-helpers.js +2 -2
- package/dist/prompts/datasources/sap-system/system-selection/questions.d.ts +1 -7
- package/dist/prompts/logger-helper.js +5 -1
- package/dist/utils/index.d.ts +9 -0
- package/dist/utils/index.js +15 -0
- package/package.json +8 -8
package/dist/index.d.ts
CHANGED
|
@@ -4,8 +4,8 @@ import { OdataVersion } from '@sap-ux/odata-service-writer';
|
|
|
4
4
|
import { type ToolsSuiteTelemetryClient } from '@sap-ux/telemetry';
|
|
5
5
|
import type { Question } from 'inquirer';
|
|
6
6
|
import type { ServiceAnswer } from './prompts/datasources/sap-system/service-selection';
|
|
7
|
-
import { type SystemSelectionAnswers
|
|
8
|
-
import type { CfAbapEnvServiceChoice, NewSystemChoice } from './prompts/datasources/sap-system/system-selection/prompt-helpers';
|
|
7
|
+
import { type SystemSelectionAnswers } from './prompts/datasources/sap-system/system-selection';
|
|
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
10
|
import type { TemplateType } from '@sap-ux/fiori-elements-writer';
|
|
11
11
|
import { DatasourceType, promptNames, type OdataServiceAnswers, type OdataServicePromptOptions, type OdataServiceQuestion, type SapSystemType, type EntityPromptOptions, EntityRelatedAnswers } from './types';
|
|
@@ -14,7 +14,7 @@ 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
|
|
17
|
+
const shared_prompts_1 = require("../shared-prompts/shared-prompts");
|
|
18
18
|
const types_1 = require("../new-system/types");
|
|
19
19
|
const service_selection_1 = require("../service-selection");
|
|
20
20
|
const prompt_helpers_2 = require("../system-selection/prompt-helpers");
|
|
@@ -54,7 +54,7 @@ function getAbapOnBTPSystemQuestions(promptOptions) {
|
|
|
54
54
|
});
|
|
55
55
|
// Re-entrance ticket system prompt
|
|
56
56
|
questions.push((0, inquirer_common_1.withCondition)([
|
|
57
|
-
(0,
|
|
57
|
+
(0, shared_prompts_1.getSystemUrlQuestion)(connectValidator, abapOnBtpPromptNamespace, promptOptions?.serviceSelection?.requiredOdataVersion)
|
|
58
58
|
], (answers) => {
|
|
59
59
|
if (answers?.abapOnBtpAuthType === 'reentranceTicket') {
|
|
60
60
|
connectValidator.systemAuthType = answers.abapOnBtpAuthType;
|
|
@@ -68,7 +68,7 @@ function getAbapOnBTPSystemQuestions(promptOptions) {
|
|
|
68
68
|
// New system store name propmt
|
|
69
69
|
if (promptOptions?.userSystemName?.hide !== true) {
|
|
70
70
|
// New system question will allow user to give the system a user friendly name
|
|
71
|
-
questions.push((0, inquirer_common_1.withCondition)([(0,
|
|
71
|
+
questions.push((0, inquirer_common_1.withCondition)([(0, shared_prompts_1.getUserSystemNameQuestion)(connectValidator, abapOnBtpPromptNamespace)], () => !!connectValidator.validatedUrl &&
|
|
72
72
|
connectValidator.validity.reachable === true &&
|
|
73
73
|
(connectValidator.validity.authenticated ?? connectValidator.validity.authRequired !== true))[0]);
|
|
74
74
|
}
|
|
@@ -130,7 +130,7 @@ async function validateCFServiceInfo(abapService, connectionValidator, requiredO
|
|
|
130
130
|
// Connected system name is only used for VSCode as a default stored system name
|
|
131
131
|
connectionValidator.connectedSystemName = await (0, btp_utils_1.generateABAPCloudDestinationName)(cfAbapServiceName);
|
|
132
132
|
utils_1.PromptState.odataService.connectedSystem = {
|
|
133
|
-
serviceProvider: connectionValidator.serviceProvider
|
|
133
|
+
serviceProvider: (0, utils_1.removeCircularFromServiceProvider)(connectionValidator.serviceProvider)
|
|
134
134
|
};
|
|
135
135
|
}
|
|
136
136
|
return true;
|
|
@@ -221,7 +221,7 @@ function getServiceKeyPrompt(connectionValidator) {
|
|
|
221
221
|
const connectValResult = await connectionValidator.validateServiceInfo(serviceKeyValResult);
|
|
222
222
|
if (connectValResult === true && connectionValidator.serviceProvider) {
|
|
223
223
|
utils_1.PromptState.odataService.connectedSystem = {
|
|
224
|
-
serviceProvider: connectionValidator.serviceProvider
|
|
224
|
+
serviceProvider: (0, utils_1.removeCircularFromServiceProvider)(connectionValidator.serviceProvider)
|
|
225
225
|
};
|
|
226
226
|
}
|
|
227
227
|
return connectValResult;
|
|
@@ -8,7 +8,7 @@ const i18n_1 = require("../../../../i18n");
|
|
|
8
8
|
const utils_1 = require("../../../../utils");
|
|
9
9
|
const connectionValidator_1 = require("../../../connectionValidator");
|
|
10
10
|
const questions_1 = require("../credentials/questions");
|
|
11
|
-
const
|
|
11
|
+
const shared_prompts_1 = require("../shared-prompts/shared-prompts");
|
|
12
12
|
const types_1 = require("../new-system/types");
|
|
13
13
|
const service_selection_1 = require("../service-selection");
|
|
14
14
|
const abapOnPremPromptNamespace = 'abapOnPrem';
|
|
@@ -47,7 +47,7 @@ function getAbapOnPremSystemQuestions(systemNamePromptOptions, connectionValidat
|
|
|
47
47
|
// This allows re-usability of the credentials prompts where a client prompt was not used (client was loaded from store).
|
|
48
48
|
const sapClientRef = { sapClient: undefined, isValid: true };
|
|
49
49
|
const questions = [
|
|
50
|
-
(0,
|
|
50
|
+
(0, shared_prompts_1.getSystemUrlQuestion)(connectValidator, abapOnPremPromptNamespace, requiredOdataVersion),
|
|
51
51
|
{
|
|
52
52
|
type: 'input',
|
|
53
53
|
name: abapOnPremPromptNames.sapClient,
|
|
@@ -71,7 +71,7 @@ function getAbapOnPremSystemQuestions(systemNamePromptOptions, connectionValidat
|
|
|
71
71
|
];
|
|
72
72
|
if (systemNamePromptOptions?.hide !== true) {
|
|
73
73
|
// New system question will allow user to give the system a user friendly name
|
|
74
|
-
questions.push((0, inquirer_common_1.withCondition)([(0,
|
|
74
|
+
questions.push((0, inquirer_common_1.withCondition)([(0, shared_prompts_1.getUserSystemNameQuestion)(connectValidator, abapOnPremPromptNamespace)], (answers) => !!answers?.[systemUrlPromptName] &&
|
|
75
75
|
connectValidator.validity.reachable === true &&
|
|
76
76
|
(connectValidator.validity.authenticated || connectValidator.validity.authRequired === false))[0]);
|
|
77
77
|
}
|
|
@@ -1,12 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*/
|
|
4
|
-
import { type InputQuestion } from '@sap-ux/inquirer-common';
|
|
5
|
-
import type { OdataVersion } from '@sap-ux/odata-service-writer';
|
|
6
|
-
import type { Answers, Question } from 'inquirer';
|
|
7
|
-
import type { OdataServicePromptOptions, SapSystemType } from '../../../../types';
|
|
8
|
-
import { promptNames } from '../../../../types';
|
|
9
|
-
import type { ConnectionValidator } from '../../../connectionValidator';
|
|
1
|
+
import type { Question } from 'inquirer';
|
|
2
|
+
import type { OdataServicePromptOptions, SapSystemType, promptNames } from '../../../../types';
|
|
10
3
|
import { newSystemPromptNames } from './types';
|
|
11
4
|
/**
|
|
12
5
|
* Internal only answers to service URL prompting not returned with OdataServiceAnswers.
|
|
@@ -22,23 +15,4 @@ export interface NewSystemAnswers {
|
|
|
22
15
|
* @returns questions for creating a new system connection
|
|
23
16
|
*/
|
|
24
17
|
export declare function getNewSystemQuestions(promptOptions?: OdataServicePromptOptions): Question<NewSystemAnswers>[];
|
|
25
|
-
/**
|
|
26
|
-
* Get the system url prompt. The system url prompt is used to connect to a new system using the user input system url.
|
|
27
|
-
*
|
|
28
|
-
* @param connectValidator a connection validator instance used to validate the system url
|
|
29
|
-
* @param promptNamespace The namespace for the prompt, used to identify the prompt instance and namespaced answers.
|
|
30
|
-
* @param requiredOdataVersion The required OData version for the system connection, only catalogs supporting the specifc odata version will be used.
|
|
31
|
-
* @returns the system url prompt
|
|
32
|
-
*/
|
|
33
|
-
export declare function getSystemUrlQuestion<T extends Answers>(connectValidator: ConnectionValidator, promptNamespace?: string, requiredOdataVersion?: OdataVersion): InputQuestion<T>;
|
|
34
|
-
/**
|
|
35
|
-
* Get a prompt for new system name.
|
|
36
|
-
*
|
|
37
|
-
* @param connectValidator A reference to the active connection validator,
|
|
38
|
-
* at prompt execution time the connection properties will be used to create a new BackendSystem, set into the PromptState.odataService.connectedSystem
|
|
39
|
-
* @param promptNamespace The namespace for the prompt, used to identify the prompt instance and namespaced answers.
|
|
40
|
-
* This prevents conflicts with other prompts of the same types where the same prompt is used by multiple other prompts but cannot share the name.
|
|
41
|
-
* @returns the new system name prompt
|
|
42
|
-
*/
|
|
43
|
-
export declare function getUserSystemNameQuestion(connectValidator: ConnectionValidator, promptNamespace?: string): InputQuestion<Partial<NewSystemAnswers>>;
|
|
44
18
|
//# sourceMappingURL=questions.d.ts.map
|
|
@@ -1,40 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getNewSystemQuestions = getNewSystemQuestions;
|
|
4
|
-
exports.getSystemUrlQuestion = getSystemUrlQuestion;
|
|
5
|
-
exports.getUserSystemNameQuestion = getUserSystemNameQuestion;
|
|
6
4
|
/**
|
|
7
5
|
* New system prompting questions for re-use in multiple sap-system datasource prompt sets.
|
|
8
6
|
*/
|
|
9
7
|
const inquirer_common_1 = require("@sap-ux/inquirer-common");
|
|
10
|
-
const store_1 = require("@sap-ux/store");
|
|
11
8
|
const i18n_1 = require("../../../../i18n");
|
|
12
|
-
const types_1 = require("../../../../types");
|
|
13
|
-
const utils_1 = require("../../../../utils");
|
|
14
9
|
const questions_1 = require("../abap-on-btp/questions");
|
|
15
10
|
const questions_2 = require("../abap-on-prem/questions");
|
|
16
|
-
const
|
|
17
|
-
const validators_1 = require("../validators");
|
|
18
|
-
const types_2 = require("./types");
|
|
19
|
-
/**
|
|
20
|
-
* Convert the system connection scheme (Service Key, Rentrance Ticket, etc) to the store specific authentication type.
|
|
21
|
-
* Note the absence of CF Discovery, in this case the service key file (UAA) is also used for the Abap connectivity.
|
|
22
|
-
*
|
|
23
|
-
* @param systemAuthType The system authentication type
|
|
24
|
-
* @returns The store specific authentication type
|
|
25
|
-
*/
|
|
26
|
-
function systemAuthTypeToAuthenticationType(systemAuthType) {
|
|
27
|
-
switch (systemAuthType) {
|
|
28
|
-
case 'serviceKey':
|
|
29
|
-
return store_1.AuthenticationType.OAuth2RefreshToken;
|
|
30
|
-
case 'reentranceTicket':
|
|
31
|
-
return store_1.AuthenticationType.ReentranceTicket;
|
|
32
|
-
case 'basic':
|
|
33
|
-
return store_1.AuthenticationType.Basic;
|
|
34
|
-
default:
|
|
35
|
-
return undefined;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
11
|
+
const types_1 = require("./types");
|
|
38
12
|
/**
|
|
39
13
|
* Provides prompts that allow the creation of a new system connection.
|
|
40
14
|
*
|
|
@@ -45,7 +19,7 @@ function getNewSystemQuestions(promptOptions) {
|
|
|
45
19
|
const questions = [
|
|
46
20
|
{
|
|
47
21
|
type: 'list',
|
|
48
|
-
name:
|
|
22
|
+
name: types_1.newSystemPromptNames.newSystemType,
|
|
49
23
|
choices: [
|
|
50
24
|
{ name: (0, i18n_1.t)('prompts.newSystemType.choiceAbapOnBtp'), value: 'abapOnBtp' },
|
|
51
25
|
{ name: (0, i18n_1.t)('prompts.newSystemType.choiceAbapOnPrem'), value: 'abapOnPrem' }
|
|
@@ -57,114 +31,4 @@ function getNewSystemQuestions(promptOptions) {
|
|
|
57
31
|
questions.push(...(0, inquirer_common_1.withCondition)((0, questions_1.getAbapOnBTPSystemQuestions)(promptOptions), (answers) => answers.newSystemType === 'abapOnBtp'));
|
|
58
32
|
return questions;
|
|
59
33
|
}
|
|
60
|
-
/**
|
|
61
|
-
* Get the system url prompt. The system url prompt is used to connect to a new system using the user input system url.
|
|
62
|
-
*
|
|
63
|
-
* @param connectValidator a connection validator instance used to validate the system url
|
|
64
|
-
* @param promptNamespace The namespace for the prompt, used to identify the prompt instance and namespaced answers.
|
|
65
|
-
* @param requiredOdataVersion The required OData version for the system connection, only catalogs supporting the specifc odata version will be used.
|
|
66
|
-
* @returns the system url prompt
|
|
67
|
-
*/
|
|
68
|
-
function getSystemUrlQuestion(connectValidator, promptNamespace, requiredOdataVersion) {
|
|
69
|
-
const promptName = `${promptNamespace ? promptNamespace + ':' : ''}${types_2.newSystemPromptNames.newSystemUrl}`;
|
|
70
|
-
const newSystemUrlQuestion = {
|
|
71
|
-
type: 'input',
|
|
72
|
-
name: promptName,
|
|
73
|
-
message: (0, i18n_1.t)('prompts.systemUrl.message'),
|
|
74
|
-
guiOptions: {
|
|
75
|
-
hint: (0, i18n_1.t)('prompts.systemUrl.description'),
|
|
76
|
-
mandatory: true,
|
|
77
|
-
breadcrumb: true
|
|
78
|
-
},
|
|
79
|
-
validate: async (url) => {
|
|
80
|
-
utils_1.PromptState.resetConnectedSystem();
|
|
81
|
-
const valResult = await connectValidator.validateUrl(url, {
|
|
82
|
-
isSystem: true,
|
|
83
|
-
odataVersion: (0, utils_1.convertODataVersionType)(requiredOdataVersion)
|
|
84
|
-
});
|
|
85
|
-
// If basic auth not required we should have an active connection (could be a re-entrance ticket supported system url)
|
|
86
|
-
if (valResult === true) {
|
|
87
|
-
if (!connectValidator.validity.authRequired && connectValidator.serviceProvider) {
|
|
88
|
-
utils_1.PromptState.odataService.connectedSystem = {
|
|
89
|
-
serviceProvider: connectValidator.serviceProvider
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
else {
|
|
93
|
-
connectValidator.systemAuthType = 'basic';
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
return valResult;
|
|
97
|
-
}
|
|
98
|
-
};
|
|
99
|
-
return newSystemUrlQuestion;
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* Get a prompt for new system name.
|
|
103
|
-
*
|
|
104
|
-
* @param connectValidator A reference to the active connection validator,
|
|
105
|
-
* at prompt execution time the connection properties will be used to create a new BackendSystem, set into the PromptState.odataService.connectedSystem
|
|
106
|
-
* @param promptNamespace The namespace for the prompt, used to identify the prompt instance and namespaced answers.
|
|
107
|
-
* This prevents conflicts with other prompts of the same types where the same prompt is used by multiple other prompts but cannot share the name.
|
|
108
|
-
* @returns the new system name prompt
|
|
109
|
-
*/
|
|
110
|
-
function getUserSystemNameQuestion(connectValidator, promptNamespace) {
|
|
111
|
-
let defaultSystemName;
|
|
112
|
-
let userModifiedSystemName = false;
|
|
113
|
-
const promptNamespacePart = `${promptNamespace ? promptNamespace + ':' : ''}`;
|
|
114
|
-
const promptName = `${promptNamespacePart}${types_1.promptNames.userSystemName}`;
|
|
115
|
-
const newSystemNamePrompt = {
|
|
116
|
-
type: 'input',
|
|
117
|
-
guiOptions: {
|
|
118
|
-
hint: (0, i18n_1.t)('prompts.systemName.hint'),
|
|
119
|
-
applyDefaultWhenDirty: true,
|
|
120
|
-
breadcrumb: true,
|
|
121
|
-
mandatory: true
|
|
122
|
-
},
|
|
123
|
-
name: promptName,
|
|
124
|
-
message: (0, i18n_1.t)('prompts.systemName.message'),
|
|
125
|
-
default: async () => {
|
|
126
|
-
const systemName = connectValidator.connectedSystemName;
|
|
127
|
-
if (systemName && !userModifiedSystemName) {
|
|
128
|
-
defaultSystemName = await (0, prompt_helpers_1.suggestSystemName)(systemName, connectValidator.validatedClient);
|
|
129
|
-
return defaultSystemName;
|
|
130
|
-
}
|
|
131
|
-
return defaultSystemName;
|
|
132
|
-
},
|
|
133
|
-
validate: async (systemName) => {
|
|
134
|
-
if (!systemName) {
|
|
135
|
-
return false;
|
|
136
|
-
}
|
|
137
|
-
let isValid = false;
|
|
138
|
-
// Dont validate the suggested default system name
|
|
139
|
-
if (systemName === defaultSystemName) {
|
|
140
|
-
isValid = true;
|
|
141
|
-
}
|
|
142
|
-
else {
|
|
143
|
-
userModifiedSystemName = true;
|
|
144
|
-
defaultSystemName = systemName;
|
|
145
|
-
isValid = await (0, validators_1.validateSystemName)(systemName);
|
|
146
|
-
}
|
|
147
|
-
if (isValid === true) {
|
|
148
|
-
// Update or create the BackendSystem with the new system details for persistent storage
|
|
149
|
-
if (connectValidator.validatedUrl && utils_1.PromptState.odataService.connectedSystem) {
|
|
150
|
-
const backendSystem = new store_1.BackendSystem({
|
|
151
|
-
authenticationType: systemAuthTypeToAuthenticationType(connectValidator.systemAuthType),
|
|
152
|
-
name: systemName,
|
|
153
|
-
url: connectValidator.validatedUrl,
|
|
154
|
-
client: connectValidator.validatedClient,
|
|
155
|
-
username: connectValidator.axiosConfig?.auth?.username,
|
|
156
|
-
password: connectValidator.axiosConfig?.auth?.password,
|
|
157
|
-
serviceKeys: connectValidator.serviceInfo,
|
|
158
|
-
userDisplayName: connectValidator.connectedUserName,
|
|
159
|
-
refreshToken: connectValidator.refreshToken
|
|
160
|
-
});
|
|
161
|
-
utils_1.PromptState.odataService.connectedSystem.backendSystem = backendSystem;
|
|
162
|
-
utils_1.PromptState.odataService.connectedSystem.backendSystem.newOrUpdated = true;
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
return isValid;
|
|
166
|
-
}
|
|
167
|
-
};
|
|
168
|
-
return newSystemNamePrompt;
|
|
169
|
-
}
|
|
170
34
|
//# sourceMappingURL=questions.js.map
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* New system prompting questions for re-use in multiple sap-system datasource prompt sets.
|
|
3
|
+
*/
|
|
4
|
+
import { type InputQuestion } from '@sap-ux/inquirer-common';
|
|
5
|
+
import type { OdataVersion } from '@sap-ux/odata-service-writer';
|
|
6
|
+
import type { Answers } from 'inquirer';
|
|
7
|
+
import type { ConnectionValidator } from '../../../connectionValidator';
|
|
8
|
+
import type { NewSystemAnswers } from '../new-system/questions';
|
|
9
|
+
/**
|
|
10
|
+
* 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
|
+
* @param connectValidator a connection validator instance used to validate the system url
|
|
13
|
+
* @param promptNamespace The namespace for the prompt, used to identify the prompt instance and namespaced answers.
|
|
14
|
+
* @param requiredOdataVersion The required OData version for the system connection, only catalogs supporting the specifc odata version will be used.
|
|
15
|
+
* @returns the system url prompt
|
|
16
|
+
*/
|
|
17
|
+
export declare function getSystemUrlQuestion<T extends Answers>(connectValidator: ConnectionValidator, promptNamespace?: string, requiredOdataVersion?: OdataVersion): InputQuestion<T>;
|
|
18
|
+
/**
|
|
19
|
+
* Get a prompt for new system name.
|
|
20
|
+
*
|
|
21
|
+
* @param connectValidator A reference to the active connection validator,
|
|
22
|
+
* at prompt execution time the connection properties will be used to create a new BackendSystem, set into the PromptState.odataService.connectedSystem
|
|
23
|
+
* @param promptNamespace The namespace for the prompt, used to identify the prompt instance and namespaced answers.
|
|
24
|
+
* This prevents conflicts with other prompts of the same types where the same prompt is used by multiple other prompts but cannot share the name.
|
|
25
|
+
* @returns the new system name prompt
|
|
26
|
+
*/
|
|
27
|
+
export declare function getUserSystemNameQuestion(connectValidator: ConnectionValidator, promptNamespace?: string): InputQuestion<Partial<NewSystemAnswers>>;
|
|
28
|
+
//# sourceMappingURL=shared-prompts.d.ts.map
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getSystemUrlQuestion = getSystemUrlQuestion;
|
|
4
|
+
exports.getUserSystemNameQuestion = getUserSystemNameQuestion;
|
|
5
|
+
const store_1 = require("@sap-ux/store");
|
|
6
|
+
const i18n_1 = require("../../../../i18n");
|
|
7
|
+
const types_1 = require("../../../../types");
|
|
8
|
+
const utils_1 = require("../../../../utils");
|
|
9
|
+
const types_2 = require("../new-system/types");
|
|
10
|
+
const prompt_helpers_1 = require("../prompt-helpers");
|
|
11
|
+
const validators_1 = require("../validators");
|
|
12
|
+
/**
|
|
13
|
+
* Convert the system connection scheme (Service Key, Rentrance Ticket, etc) to the store specific authentication type.
|
|
14
|
+
* Note the absence of CF Discovery, in this case the service key file (UAA) is also used for the Abap connectivity.
|
|
15
|
+
*
|
|
16
|
+
* @param systemAuthType The system authentication type
|
|
17
|
+
* @returns The store specific authentication type
|
|
18
|
+
*/
|
|
19
|
+
function systemAuthTypeToAuthenticationType(systemAuthType) {
|
|
20
|
+
switch (systemAuthType) {
|
|
21
|
+
case 'serviceKey':
|
|
22
|
+
return store_1.AuthenticationType.OAuth2RefreshToken;
|
|
23
|
+
case 'reentranceTicket':
|
|
24
|
+
return store_1.AuthenticationType.ReentranceTicket;
|
|
25
|
+
case 'basic':
|
|
26
|
+
return store_1.AuthenticationType.Basic;
|
|
27
|
+
default:
|
|
28
|
+
return undefined;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Get the system url prompt. The system url prompt is used to connect to a new system using the user input system url.
|
|
33
|
+
*
|
|
34
|
+
* @param connectValidator a connection validator instance used to validate the system url
|
|
35
|
+
* @param promptNamespace The namespace for the prompt, used to identify the prompt instance and namespaced answers.
|
|
36
|
+
* @param requiredOdataVersion The required OData version for the system connection, only catalogs supporting the specifc odata version will be used.
|
|
37
|
+
* @returns the system url prompt
|
|
38
|
+
*/
|
|
39
|
+
function getSystemUrlQuestion(connectValidator, promptNamespace, requiredOdataVersion) {
|
|
40
|
+
const promptName = `${promptNamespace ? promptNamespace + ':' : ''}${types_2.newSystemPromptNames.newSystemUrl}`;
|
|
41
|
+
const newSystemUrlQuestion = {
|
|
42
|
+
type: 'input',
|
|
43
|
+
name: promptName,
|
|
44
|
+
message: (0, i18n_1.t)('prompts.systemUrl.message'),
|
|
45
|
+
guiOptions: {
|
|
46
|
+
hint: (0, i18n_1.t)('prompts.systemUrl.description'),
|
|
47
|
+
mandatory: true,
|
|
48
|
+
breadcrumb: true
|
|
49
|
+
},
|
|
50
|
+
validate: async (url) => {
|
|
51
|
+
utils_1.PromptState.resetConnectedSystem();
|
|
52
|
+
const valResult = await connectValidator.validateUrl(url, {
|
|
53
|
+
isSystem: true,
|
|
54
|
+
odataVersion: (0, utils_1.convertODataVersionType)(requiredOdataVersion)
|
|
55
|
+
});
|
|
56
|
+
// If basic auth not required we should have an active connection (could be a re-entrance ticket supported system url)
|
|
57
|
+
if (valResult === true) {
|
|
58
|
+
if (!connectValidator.validity.authRequired && connectValidator.serviceProvider) {
|
|
59
|
+
utils_1.PromptState.odataService.connectedSystem = {
|
|
60
|
+
serviceProvider: (0, utils_1.removeCircularFromServiceProvider)(connectValidator.serviceProvider)
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
connectValidator.systemAuthType = 'basic';
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return valResult;
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
return newSystemUrlQuestion;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Get a prompt for new system name.
|
|
74
|
+
*
|
|
75
|
+
* @param connectValidator A reference to the active connection validator,
|
|
76
|
+
* at prompt execution time the connection properties will be used to create a new BackendSystem, set into the PromptState.odataService.connectedSystem
|
|
77
|
+
* @param promptNamespace The namespace for the prompt, used to identify the prompt instance and namespaced answers.
|
|
78
|
+
* This prevents conflicts with other prompts of the same types where the same prompt is used by multiple other prompts but cannot share the name.
|
|
79
|
+
* @returns the new system name prompt
|
|
80
|
+
*/
|
|
81
|
+
function getUserSystemNameQuestion(connectValidator, promptNamespace) {
|
|
82
|
+
let defaultSystemName;
|
|
83
|
+
let userModifiedSystemName = false;
|
|
84
|
+
const promptNamespacePart = `${promptNamespace ? promptNamespace + ':' : ''}`;
|
|
85
|
+
const promptName = `${promptNamespacePart}${types_1.promptNames.userSystemName}`;
|
|
86
|
+
const newSystemNamePrompt = {
|
|
87
|
+
type: 'input',
|
|
88
|
+
guiOptions: {
|
|
89
|
+
hint: (0, i18n_1.t)('prompts.systemName.hint'),
|
|
90
|
+
applyDefaultWhenDirty: true,
|
|
91
|
+
breadcrumb: true,
|
|
92
|
+
mandatory: true
|
|
93
|
+
},
|
|
94
|
+
name: promptName,
|
|
95
|
+
message: (0, i18n_1.t)('prompts.systemName.message'),
|
|
96
|
+
default: async () => {
|
|
97
|
+
const systemName = connectValidator.connectedSystemName;
|
|
98
|
+
if (systemName && !userModifiedSystemName) {
|
|
99
|
+
defaultSystemName = await (0, prompt_helpers_1.suggestSystemName)(systemName, connectValidator.validatedClient);
|
|
100
|
+
return defaultSystemName;
|
|
101
|
+
}
|
|
102
|
+
return defaultSystemName;
|
|
103
|
+
},
|
|
104
|
+
validate: async (systemName) => {
|
|
105
|
+
if (!systemName) {
|
|
106
|
+
return false;
|
|
107
|
+
}
|
|
108
|
+
let isValid = false;
|
|
109
|
+
// Dont validate the suggested default system name
|
|
110
|
+
if (systemName === defaultSystemName) {
|
|
111
|
+
isValid = true;
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
userModifiedSystemName = true;
|
|
115
|
+
defaultSystemName = systemName;
|
|
116
|
+
isValid = await (0, validators_1.validateSystemName)(systemName);
|
|
117
|
+
}
|
|
118
|
+
if (isValid === true) {
|
|
119
|
+
// Update or create the BackendSystem with the new system details for persistent storage
|
|
120
|
+
if (connectValidator.validatedUrl && utils_1.PromptState.odataService.connectedSystem) {
|
|
121
|
+
const backendSystem = new store_1.BackendSystem({
|
|
122
|
+
authenticationType: systemAuthTypeToAuthenticationType(connectValidator.systemAuthType),
|
|
123
|
+
name: systemName,
|
|
124
|
+
url: connectValidator.validatedUrl,
|
|
125
|
+
client: connectValidator.validatedClient,
|
|
126
|
+
username: connectValidator.axiosConfig?.auth?.username,
|
|
127
|
+
password: connectValidator.axiosConfig?.auth?.password,
|
|
128
|
+
serviceKeys: connectValidator.serviceInfo,
|
|
129
|
+
userDisplayName: connectValidator.connectedUserName,
|
|
130
|
+
refreshToken: connectValidator.refreshToken
|
|
131
|
+
});
|
|
132
|
+
utils_1.PromptState.odataService.connectedSystem.backendSystem = backendSystem;
|
|
133
|
+
utils_1.PromptState.odataService.connectedSystem.backendSystem.newOrUpdated = true;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
return isValid;
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
return newSystemNamePrompt;
|
|
140
|
+
}
|
|
141
|
+
//# sourceMappingURL=shared-prompts.js.map
|
|
@@ -4,12 +4,15 @@ import type { BackendSystem } from '@sap-ux/store';
|
|
|
4
4
|
import type { ListChoiceOptions } from 'inquirer';
|
|
5
5
|
import { type DestinationFilters } from '../../../../types';
|
|
6
6
|
import type { ConnectionValidator } from '../../../connectionValidator';
|
|
7
|
-
import { type SystemSelectionAnswerType } from './questions';
|
|
8
7
|
import type { ValidationResult } from '../../../types';
|
|
9
8
|
export declare const NewSystemChoice = "!@\u00A3*&937newSystem*X~qy^";
|
|
10
9
|
export type NewSystemChoice = typeof NewSystemChoice;
|
|
11
10
|
export declare const CfAbapEnvServiceChoice = "cfAbapEnvService";
|
|
12
11
|
export type CfAbapEnvServiceChoice = typeof CfAbapEnvServiceChoice;
|
|
12
|
+
export type SystemSelectionAnswerType = {
|
|
13
|
+
type: 'destination' | 'backendSystem' | 'newSystemChoice' | CfAbapEnvServiceChoice;
|
|
14
|
+
system: Destination | BackendSystem | NewSystemChoice | CfAbapEnvServiceChoice;
|
|
15
|
+
};
|
|
13
16
|
/**
|
|
14
17
|
* Connects to the specified backend system and validates the connection.
|
|
15
18
|
* Note this will return true in the case of basic auth validation failure to defer validation to the credentials prompt.
|
|
@@ -63,7 +63,7 @@ async function connectWithBackendSystem(backendSystem, connectionValidator, requ
|
|
|
63
63
|
// If the connection is successful, we will return the connected system from the inquirer
|
|
64
64
|
if (connectValResult === true && connectionValidator.serviceProvider) {
|
|
65
65
|
utils_1.PromptState.odataService.connectedSystem = {
|
|
66
|
-
serviceProvider: connectionValidator.serviceProvider,
|
|
66
|
+
serviceProvider: (0, utils_1.removeCircularFromServiceProvider)(connectionValidator.serviceProvider),
|
|
67
67
|
backendSystem
|
|
68
68
|
};
|
|
69
69
|
}
|
|
@@ -91,7 +91,7 @@ async function connectWithDestination(destination, connectionValidator, required
|
|
|
91
91
|
// If the connection is successful, we will return the connected system from the inquirer
|
|
92
92
|
if (connectValResult === true && connectionValidator.serviceProvider) {
|
|
93
93
|
utils_1.PromptState.odataService.connectedSystem = {
|
|
94
|
-
serviceProvider: connectionValidator.serviceProvider,
|
|
94
|
+
serviceProvider: (0, utils_1.removeCircularFromServiceProvider)(connectionValidator.serviceProvider),
|
|
95
95
|
destination
|
|
96
96
|
};
|
|
97
97
|
}
|
|
@@ -1,16 +1,10 @@
|
|
|
1
|
-
import type { Destination } from '@sap-ux/btp-utils';
|
|
2
|
-
import type { BackendSystem } from '@sap-ux/store';
|
|
3
1
|
import type { Question } from 'inquirer';
|
|
4
2
|
import { type OdataServicePromptOptions, promptNames } from '../../../../types';
|
|
5
3
|
import { ConnectionValidator } from '../../../connectionValidator';
|
|
6
4
|
import type { ServiceAnswer } from '../service-selection';
|
|
7
|
-
import { type
|
|
5
|
+
import { type SystemSelectionAnswerType } from './prompt-helpers';
|
|
8
6
|
declare const usernamePromptName: "systemSelection:systemUsername";
|
|
9
7
|
declare const passwordPromptName: "systemSelection:systemPassword";
|
|
10
|
-
export type SystemSelectionAnswerType = {
|
|
11
|
-
type: 'destination' | 'backendSystem' | 'newSystemChoice' | CfAbapEnvServiceChoice;
|
|
12
|
-
system: Destination | BackendSystem | NewSystemChoice | CfAbapEnvServiceChoice;
|
|
13
|
-
};
|
|
14
8
|
interface SystemSelectionCredentialsAnswers {
|
|
15
9
|
[usernamePromptName]?: string;
|
|
16
10
|
[passwordPromptName]?: string;
|
|
@@ -64,6 +64,10 @@ class LoggerHelper {
|
|
|
64
64
|
* @param interceptors.response the axios response interceptor
|
|
65
65
|
*/
|
|
66
66
|
static attachAxiosLogger(interceptors) {
|
|
67
|
+
// Dont log response data, which can be huge (edmx) unless log level is explictly set to `trace` (@vscode-logging/logger)
|
|
68
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
69
|
+
const logResponseData = typeof LoggerHelper.logger.getLogLevel === 'function' &&
|
|
70
|
+
LoggerHelper.logger.getLogLevel() === 'trace';
|
|
67
71
|
const debugLogger = LoggerHelper.logger.debug.bind(LoggerHelper.logger);
|
|
68
72
|
interceptors.request.use((request) => {
|
|
69
73
|
return AxiosLogger.requestLogger(request, {
|
|
@@ -80,7 +84,7 @@ class LoggerHelper {
|
|
|
80
84
|
});
|
|
81
85
|
interceptors.response.use((response) => {
|
|
82
86
|
return AxiosLogger.responseLogger(response, {
|
|
83
|
-
data:
|
|
87
|
+
data: logResponseData,
|
|
84
88
|
prefixText: '@sap-ux/odata-service-inquirer',
|
|
85
89
|
status: true,
|
|
86
90
|
headers: true,
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ServiceProvider } from '@sap-ux/axios-extension';
|
|
1
2
|
import { ODataVersion } from '@sap-ux/axios-extension';
|
|
2
3
|
import { type HostEnvironmentId } from '@sap-ux/fiori-generator-shared';
|
|
3
4
|
import { OdataVersion } from '@sap-ux/odata-service-writer';
|
|
@@ -55,5 +56,13 @@ export declare function convertODataVersionType(odataVersion?: OdataVersion): OD
|
|
|
55
56
|
* @returns the default index if only one item is available, otherwise undefined
|
|
56
57
|
*/
|
|
57
58
|
export declare function getDefaultChoiceIndex(list: ListChoiceOptions[]): number | undefined;
|
|
59
|
+
/**
|
|
60
|
+
* Temp fix for circular dependency issue within the service provider winston logger, causing issues with serialization in Yeoman generators.
|
|
61
|
+
* More investigation is needed to determine what properties are required from the service provider for subsequent flows.
|
|
62
|
+
*
|
|
63
|
+
* @param serviceProvider - instance of the service provider
|
|
64
|
+
* @returns the service provider with the circular dependencies removed
|
|
65
|
+
*/
|
|
66
|
+
export declare function removeCircularFromServiceProvider(serviceProvider: ServiceProvider): ServiceProvider;
|
|
58
67
|
export { PromptState };
|
|
59
68
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/utils/index.js
CHANGED
|
@@ -10,6 +10,7 @@ exports.xmlToJson = xmlToJson;
|
|
|
10
10
|
exports.originToRelative = originToRelative;
|
|
11
11
|
exports.convertODataVersionType = convertODataVersionType;
|
|
12
12
|
exports.getDefaultChoiceIndex = getDefaultChoiceIndex;
|
|
13
|
+
exports.removeCircularFromServiceProvider = removeCircularFromServiceProvider;
|
|
13
14
|
const axios_extension_1 = require("@sap-ux/axios-extension");
|
|
14
15
|
const btp_utils_1 = require("@sap-ux/btp-utils");
|
|
15
16
|
const fiori_generator_shared_1 = require("@sap-ux/fiori-generator-shared");
|
|
@@ -127,4 +128,18 @@ function getDefaultChoiceIndex(list) {
|
|
|
127
128
|
}
|
|
128
129
|
return undefined;
|
|
129
130
|
}
|
|
131
|
+
/**
|
|
132
|
+
* Temp fix for circular dependency issue within the service provider winston logger, causing issues with serialization in Yeoman generators.
|
|
133
|
+
* More investigation is needed to determine what properties are required from the service provider for subsequent flows.
|
|
134
|
+
*
|
|
135
|
+
* @param serviceProvider - instance of the service provider
|
|
136
|
+
* @returns the service provider with the circular dependencies removed
|
|
137
|
+
*/
|
|
138
|
+
function removeCircularFromServiceProvider(serviceProvider) {
|
|
139
|
+
for (const service in serviceProvider.services) {
|
|
140
|
+
delete serviceProvider[service].log;
|
|
141
|
+
}
|
|
142
|
+
delete serviceProvider.log;
|
|
143
|
+
return serviceProvider;
|
|
144
|
+
}
|
|
130
145
|
//# sourceMappingURL=index.js.map
|
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.2.
|
|
4
|
+
"version": "2.2.28",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/SAP/open-ux-tools.git",
|
|
@@ -28,12 +28,12 @@
|
|
|
28
28
|
"i18next": "23.5.1",
|
|
29
29
|
"inquirer-autocomplete-prompt": "2.0.1",
|
|
30
30
|
"os-name": "4.0.1",
|
|
31
|
-
"@sap-ux/btp-utils": "1.0.2",
|
|
32
|
-
"@sap-ux/fiori-generator-shared": "0.9.11",
|
|
33
31
|
"@sap-ux/axios-extension": "1.19.2",
|
|
32
|
+
"@sap-ux/btp-utils": "1.0.2",
|
|
33
|
+
"@sap-ux/fiori-generator-shared": "0.10.0",
|
|
34
34
|
"@sap-ux/guided-answers-helper": "0.2.1",
|
|
35
35
|
"@sap-ux/telemetry": "0.5.72",
|
|
36
|
-
"@sap-ux/inquirer-common": "0.6.
|
|
36
|
+
"@sap-ux/inquirer-common": "0.6.33",
|
|
37
37
|
"@sap-ux/logger": "0.6.0",
|
|
38
38
|
"@sap-ux/project-access": "1.29.18",
|
|
39
39
|
"@sap-ux/project-input-validator": "0.5.0",
|
|
@@ -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.
|
|
50
|
-
"@sap-ux/fiori-elements-writer": "2.1.
|
|
51
|
-
"@sap-ux/fiori-freestyle-writer": "2.2.
|
|
49
|
+
"@sap-ux/fiori-generator-shared": "0.10.0",
|
|
50
|
+
"@sap-ux/fiori-elements-writer": "2.1.36",
|
|
51
|
+
"@sap-ux/fiori-freestyle-writer": "2.2.6",
|
|
52
52
|
"@sap-ux/feature-toggle": "0.2.3",
|
|
53
53
|
"@sap-ux/odata-service-writer": "0.26.13",
|
|
54
|
-
"@sap-ux/cap-config-writer": "0.9.
|
|
54
|
+
"@sap-ux/cap-config-writer": "0.9.23"
|
|
55
55
|
},
|
|
56
56
|
"engines": {
|
|
57
57
|
"node": ">=18.x"
|