@sap-ux/ui-service-inquirer 0.0.13 → 0.0.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/prompts/configuration/questions.d.ts +3 -2
- package/dist/prompts/configuration/questions.js +115 -83
- package/dist/prompts/prompt-helper.d.ts +14 -0
- package/dist/prompts/prompt-helper.js +21 -1
- package/dist/prompts/prompts.d.ts +3 -2
- package/dist/prompts/prompts.js +3 -2
- package/dist/types.d.ts +4 -0
- package/package.json +4 -4
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { type Logger } from '@sap-ux/logger';
|
|
2
|
-
import type
|
|
2
|
+
import { type ServiceConfigOptions, type ServiceConfigQuestion } from '../../types';
|
|
3
3
|
/**
|
|
4
4
|
* Get the configuration questions.
|
|
5
5
|
*
|
|
6
6
|
* @param logger - logger instance to use for logging
|
|
7
|
+
* @param options - configuration options for prompts
|
|
7
8
|
* @returns the configuration questions
|
|
8
9
|
*/
|
|
9
|
-
export declare function getConfigQuestions(logger: Logger): ServiceConfigQuestion[];
|
|
10
|
+
export declare function getConfigQuestions(logger: Logger, options?: ServiceConfigOptions): ServiceConfigQuestion[];
|
|
10
11
|
//# sourceMappingURL=questions.d.ts.map
|
|
@@ -10,11 +10,11 @@ const prompt_state_1 = require("../prompt-state");
|
|
|
10
10
|
* Get the configuration questions.
|
|
11
11
|
*
|
|
12
12
|
* @param logger - logger instance to use for logging
|
|
13
|
+
* @param options - configuration options for prompts
|
|
13
14
|
* @returns the configuration questions
|
|
14
15
|
*/
|
|
15
|
-
function getConfigQuestions(logger) {
|
|
16
|
+
function getConfigQuestions(logger, options) {
|
|
16
17
|
prompt_state_1.PromptState.resetServiceConfig();
|
|
17
|
-
let draftEnabled = true;
|
|
18
18
|
const abapTarget = (0, prompt_helper_1.createAbapTarget)(prompt_state_1.PromptState.systemSelection.connectedSystem?.destination, prompt_state_1.PromptState.systemSelection.connectedSystem?.backendSystem);
|
|
19
19
|
const packagePrompts = (0, abap_deploy_config_inquirer_1.getPackagePrompts)({
|
|
20
20
|
packageAutocomplete: {
|
|
@@ -37,100 +37,132 @@ function getConfigQuestions(logger) {
|
|
|
37
37
|
default: 'ztestapp'
|
|
38
38
|
}
|
|
39
39
|
}, true, true);
|
|
40
|
-
const configPrompts = [
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
40
|
+
const configPrompts = [getServiceNameQuestion(logger, options)];
|
|
41
|
+
if ((0, prompt_helper_1.defaultOrShowDraftQuestion)(options?.useDraftEnabled)) {
|
|
42
|
+
configPrompts.push(getDraftEnabledQuestion(logger));
|
|
43
|
+
}
|
|
44
|
+
if ((0, prompt_helper_1.defaultOrShowAppGenLaunchQuestion)(options?.useLaunchGen)) {
|
|
45
|
+
configPrompts.push(getAppGenLaunchQuestion());
|
|
46
|
+
}
|
|
47
|
+
return [...packagePrompts, ...transportPrompts, ...configPrompts];
|
|
48
|
+
}
|
|
49
|
+
exports.getConfigQuestions = getConfigQuestions;
|
|
50
|
+
/**
|
|
51
|
+
* Returns the service name question.
|
|
52
|
+
*
|
|
53
|
+
* @param logger - logger instance to use for logging
|
|
54
|
+
* @param options - configuration options for prompts
|
|
55
|
+
* @returns question for service name
|
|
56
|
+
*/
|
|
57
|
+
function getServiceNameQuestion(logger, options) {
|
|
58
|
+
return {
|
|
59
|
+
when: async (answers) => {
|
|
60
|
+
if (!!answers.packageManual || !!answers.packageAutocomplete) {
|
|
61
|
+
try {
|
|
62
|
+
const packageValue = answers.packageManual || answers.packageAutocomplete;
|
|
63
|
+
if (packageValue) {
|
|
64
|
+
prompt_state_1.PromptState.serviceConfig.content =
|
|
65
|
+
(await prompt_state_1.PromptState.systemSelection.objectGenerator?.getContent(packageValue)) ?? '';
|
|
66
|
+
const content = JSON.parse(prompt_state_1.PromptState.serviceConfig?.content);
|
|
67
|
+
if ((0, prompt_helper_1.defaultOrShowDraftQuestion)(options?.useDraftEnabled)) {
|
|
50
68
|
content.businessObject.projectionBehavior.withDraft = true;
|
|
51
|
-
prompt_state_1.PromptState.serviceConfig.content = JSON.stringify(content);
|
|
52
|
-
prompt_state_1.PromptState.serviceConfig.serviceName =
|
|
53
|
-
content.businessService.serviceBinding.serviceBindingName;
|
|
54
69
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
70
|
+
prompt_state_1.PromptState.serviceConfig.content = JSON.stringify(content);
|
|
71
|
+
prompt_state_1.PromptState.serviceConfig.serviceName =
|
|
72
|
+
content.businessService.serviceBinding.serviceBindingName;
|
|
58
73
|
}
|
|
59
74
|
}
|
|
60
|
-
return !!prompt_state_1.PromptState.serviceConfig.serviceName || !!prompt_state_1.PromptState.serviceConfig.content;
|
|
61
|
-
},
|
|
62
|
-
type: 'expand',
|
|
63
|
-
name: 'serviceName',
|
|
64
|
-
guiOptions: {
|
|
65
|
-
breadcrumb: (0, i18n_1.t)('prompts.serviceNameBreadcrumb')
|
|
66
|
-
},
|
|
67
|
-
message: (0, i18n_1.t)('prompts.serviceName'),
|
|
68
|
-
choices: () => (0, prompt_helper_1.getServiceNameChoices)(prompt_state_1.PromptState.serviceConfig.serviceName),
|
|
69
|
-
default: () => 0,
|
|
70
|
-
validate: async () => {
|
|
71
|
-
try {
|
|
72
|
-
const validation = await prompt_state_1.PromptState.systemSelection.objectGenerator?.validateContent(prompt_state_1.PromptState.serviceConfig.content);
|
|
73
|
-
if (validation?.severity === 'ERROR') {
|
|
74
|
-
return await (0, prompt_helper_1.getValidationErrorLink)();
|
|
75
|
-
}
|
|
76
|
-
return true;
|
|
77
|
-
}
|
|
78
75
|
catch (e) {
|
|
79
|
-
logger
|
|
80
|
-
return await (0, prompt_helper_1.getValidationErrorLink)();
|
|
76
|
+
logger?.error(`${(0, i18n_1.t)('error.fetchingContentForServiceBinding')}: ${e.message}`);
|
|
81
77
|
}
|
|
82
78
|
}
|
|
79
|
+
return !!prompt_state_1.PromptState.serviceConfig.serviceName || !!prompt_state_1.PromptState.serviceConfig.content;
|
|
83
80
|
},
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
prompt_state_1.PromptState.serviceConfig.content = JSON.stringify(content);
|
|
98
|
-
try {
|
|
99
|
-
const validation = await prompt_state_1.PromptState.systemSelection.objectGenerator?.validateContent(prompt_state_1.PromptState.serviceConfig.content);
|
|
100
|
-
if (validation?.severity === 'ERROR') {
|
|
101
|
-
return (0, i18n_1.t)('error.validatingContent');
|
|
102
|
-
}
|
|
103
|
-
draftEnabled = input;
|
|
104
|
-
}
|
|
105
|
-
catch (error) {
|
|
106
|
-
logger.error(error.message);
|
|
107
|
-
}
|
|
108
|
-
draftEnabled = input;
|
|
81
|
+
type: 'expand',
|
|
82
|
+
name: 'serviceName',
|
|
83
|
+
guiOptions: {
|
|
84
|
+
breadcrumb: (0, i18n_1.t)('prompts.serviceNameBreadcrumb')
|
|
85
|
+
},
|
|
86
|
+
message: (0, i18n_1.t)('prompts.serviceName'),
|
|
87
|
+
choices: () => (0, prompt_helper_1.getServiceNameChoices)(prompt_state_1.PromptState.serviceConfig.serviceName),
|
|
88
|
+
default: () => 0,
|
|
89
|
+
validate: async () => {
|
|
90
|
+
try {
|
|
91
|
+
const validation = await prompt_state_1.PromptState.systemSelection.objectGenerator?.validateContent(prompt_state_1.PromptState.serviceConfig.content);
|
|
92
|
+
if (validation?.severity === 'ERROR') {
|
|
93
|
+
return await (0, prompt_helper_1.getValidationErrorLink)();
|
|
109
94
|
}
|
|
110
95
|
return true;
|
|
111
96
|
}
|
|
97
|
+
catch (e) {
|
|
98
|
+
logger.error(`${(0, i18n_1.t)('error.validatingContent')}: ${e.message}`);
|
|
99
|
+
return await (0, prompt_helper_1.getValidationErrorLink)();
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Returns the draft enabled question.
|
|
106
|
+
*
|
|
107
|
+
* @param logger - logger instance to use for logging
|
|
108
|
+
* @returns question for draft enabled
|
|
109
|
+
*/
|
|
110
|
+
function getDraftEnabledQuestion(logger) {
|
|
111
|
+
let draftEnabled = true;
|
|
112
|
+
return {
|
|
113
|
+
name: 'draftEnabled',
|
|
114
|
+
type: 'confirm',
|
|
115
|
+
message: (0, i18n_1.t)('prompts.draftEnabled'),
|
|
116
|
+
guiOptions: {
|
|
117
|
+
breadcrumb: true,
|
|
118
|
+
mandatory: true
|
|
112
119
|
},
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
severity: yeoman_ui_types_1.Severity.information
|
|
126
|
-
};
|
|
120
|
+
default: true,
|
|
121
|
+
validate: async (input) => {
|
|
122
|
+
if (input !== draftEnabled && prompt_state_1.PromptState.serviceConfig.content) {
|
|
123
|
+
const content = JSON.parse(prompt_state_1.PromptState.serviceConfig.content);
|
|
124
|
+
content.businessObject.projectionBehavior.withDraft = input;
|
|
125
|
+
prompt_state_1.PromptState.serviceConfig.content = JSON.stringify(content);
|
|
126
|
+
try {
|
|
127
|
+
const validation = await prompt_state_1.PromptState.systemSelection.objectGenerator?.validateContent(prompt_state_1.PromptState.serviceConfig.content);
|
|
128
|
+
if (validation?.severity === 'ERROR') {
|
|
129
|
+
return (0, i18n_1.t)('error.validatingContent');
|
|
130
|
+
}
|
|
131
|
+
draftEnabled = input;
|
|
127
132
|
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
133
|
+
catch (error) {
|
|
134
|
+
logger.error(error.message);
|
|
135
|
+
}
|
|
136
|
+
draftEnabled = input;
|
|
137
|
+
}
|
|
138
|
+
return true;
|
|
131
139
|
}
|
|
132
|
-
|
|
133
|
-
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Returns the app gen launch question.
|
|
144
|
+
*
|
|
145
|
+
* @returns question for app gen launch
|
|
146
|
+
*/
|
|
147
|
+
function getAppGenLaunchQuestion() {
|
|
148
|
+
return {
|
|
149
|
+
name: 'launchAppGen',
|
|
150
|
+
type: 'confirm',
|
|
151
|
+
message: (0, i18n_1.t)('prompts.launchAppGen'),
|
|
152
|
+
guiOptions: {
|
|
153
|
+
breadcrumb: (0, i18n_1.t)('prompts.launchAppGenBreadcrumb')
|
|
154
|
+
},
|
|
155
|
+
additionalMessages: (val) => {
|
|
156
|
+
let additionalMessage;
|
|
157
|
+
if (val) {
|
|
158
|
+
additionalMessage = {
|
|
159
|
+
message: (0, i18n_1.t)('info.appGenLaunch'),
|
|
160
|
+
severity: yeoman_ui_types_1.Severity.information
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
return additionalMessage;
|
|
164
|
+
},
|
|
165
|
+
default: false
|
|
166
|
+
};
|
|
134
167
|
}
|
|
135
|
-
exports.getConfigQuestions = getConfigQuestions;
|
|
136
168
|
//# sourceMappingURL=questions.js.map
|
|
@@ -39,4 +39,18 @@ export declare function getServiceNameChoices(serviceName: string): ListChoiceOp
|
|
|
39
39
|
* @returns the validation error link
|
|
40
40
|
*/
|
|
41
41
|
export declare function getValidationErrorLink(): Promise<ValidationLink>;
|
|
42
|
+
/**
|
|
43
|
+
* Determines if the draft enabled prompt is shown.
|
|
44
|
+
*
|
|
45
|
+
* @param useDraftEnabled - user provided value for draft enabled
|
|
46
|
+
* @returns boolean
|
|
47
|
+
*/
|
|
48
|
+
export declare function defaultOrShowDraftQuestion(useDraftEnabled?: boolean): boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Determines if the app gen launch prompt is shown.
|
|
51
|
+
*
|
|
52
|
+
* @param useLaunchGen - user provided value for app gen launch
|
|
53
|
+
* @returns boolean
|
|
54
|
+
*/
|
|
55
|
+
export declare function defaultOrShowAppGenLaunchQuestion(useLaunchGen?: boolean): boolean;
|
|
42
56
|
//# sourceMappingURL=prompt-helper.d.ts.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getValidationErrorLink = exports.getServiceNameChoices = exports.createAbapTarget = exports.getAbapCDSViews = exports.getBusinessObjects = void 0;
|
|
3
|
+
exports.defaultOrShowAppGenLaunchQuestion = exports.defaultOrShowDraftQuestion = exports.getValidationErrorLink = exports.getServiceNameChoices = exports.createAbapTarget = exports.getAbapCDSViews = exports.getBusinessObjects = void 0;
|
|
4
4
|
const axios_extension_1 = require("@sap-ux/axios-extension");
|
|
5
5
|
const btp_utils_1 = require("@sap-ux/btp-utils");
|
|
6
6
|
const guided_answers_helper_1 = require("@sap-ux/guided-answers-helper");
|
|
@@ -76,4 +76,24 @@ async function getValidationErrorLink() {
|
|
|
76
76
|
return inquirer_common_1.ErrorHandler.getHelpLink(guided_answers_helper_1.HELP_NODES.UI_SERVICE_GENERATOR, inquirer_common_1.ERROR_TYPE.INTERNAL_SERVER_ERROR, (0, i18n_1.t)('error.validatingContent'));
|
|
77
77
|
}
|
|
78
78
|
exports.getValidationErrorLink = getValidationErrorLink;
|
|
79
|
+
/**
|
|
80
|
+
* Determines if the draft enabled prompt is shown.
|
|
81
|
+
*
|
|
82
|
+
* @param useDraftEnabled - user provided value for draft enabled
|
|
83
|
+
* @returns boolean
|
|
84
|
+
*/
|
|
85
|
+
function defaultOrShowDraftQuestion(useDraftEnabled) {
|
|
86
|
+
return useDraftEnabled ?? true;
|
|
87
|
+
}
|
|
88
|
+
exports.defaultOrShowDraftQuestion = defaultOrShowDraftQuestion;
|
|
89
|
+
/**
|
|
90
|
+
* Determines if the app gen launch prompt is shown.
|
|
91
|
+
*
|
|
92
|
+
* @param useLaunchGen - user provided value for app gen launch
|
|
93
|
+
* @returns boolean
|
|
94
|
+
*/
|
|
95
|
+
function defaultOrShowAppGenLaunchQuestion(useLaunchGen) {
|
|
96
|
+
return useLaunchGen ?? true;
|
|
97
|
+
}
|
|
98
|
+
exports.defaultOrShowAppGenLaunchQuestion = defaultOrShowAppGenLaunchQuestion;
|
|
79
99
|
//# sourceMappingURL=prompt-helper.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Logger } from '@sap-ux/logger';
|
|
2
2
|
import type { Question } from 'inquirer';
|
|
3
|
-
import type { ServiceConfig, ServiceConfigQuestion, SystemSelectionAnswers, UiServiceAnswers } from '../types';
|
|
3
|
+
import type { ServiceConfig, ServiceConfigOptions, ServiceConfigQuestion, SystemSelectionAnswers, UiServiceAnswers } from '../types';
|
|
4
4
|
/**
|
|
5
5
|
* Get the system selection prompts.
|
|
6
6
|
*
|
|
@@ -17,10 +17,11 @@ export declare function getSystemSelectionPrompts(answers?: UiServiceAnswers, sy
|
|
|
17
17
|
* Get the configuration prompts.
|
|
18
18
|
*
|
|
19
19
|
* @param systemSelectionAnswers - the system selection answers to use if system selection prompting was skipped
|
|
20
|
+
* @param options - configuration options for prompts
|
|
20
21
|
* @param logger - optional logger instance to use for logging
|
|
21
22
|
* @returns the configuration prompts
|
|
22
23
|
*/
|
|
23
|
-
export declare function getConfigPrompts(systemSelectionAnswers: SystemSelectionAnswers, logger?: Logger): {
|
|
24
|
+
export declare function getConfigPrompts(systemSelectionAnswers: SystemSelectionAnswers, options?: ServiceConfigOptions, logger?: Logger): {
|
|
24
25
|
prompts: ServiceConfigQuestion[];
|
|
25
26
|
answers: Partial<ServiceConfig>;
|
|
26
27
|
};
|
package/dist/prompts/prompts.js
CHANGED
|
@@ -30,10 +30,11 @@ exports.getSystemSelectionPrompts = getSystemSelectionPrompts;
|
|
|
30
30
|
* Get the configuration prompts.
|
|
31
31
|
*
|
|
32
32
|
* @param systemSelectionAnswers - the system selection answers to use if system selection prompting was skipped
|
|
33
|
+
* @param options - configuration options for prompts
|
|
33
34
|
* @param logger - optional logger instance to use for logging
|
|
34
35
|
* @returns the configuration prompts
|
|
35
36
|
*/
|
|
36
|
-
function getConfigPrompts(systemSelectionAnswers, logger) {
|
|
37
|
+
function getConfigPrompts(systemSelectionAnswers, options, logger) {
|
|
37
38
|
if (logger) {
|
|
38
39
|
logger_helper_1.default.logger = logger;
|
|
39
40
|
}
|
|
@@ -41,7 +42,7 @@ function getConfigPrompts(systemSelectionAnswers, logger) {
|
|
|
41
42
|
Object.assign(prompt_state_1.PromptState.systemSelection, systemSelectionAnswers);
|
|
42
43
|
}
|
|
43
44
|
return {
|
|
44
|
-
prompts: (0, questions_1.getConfigQuestions)(logger_helper_1.default.logger),
|
|
45
|
+
prompts: (0, questions_1.getConfigQuestions)(logger_helper_1.default.logger, options),
|
|
45
46
|
answers: prompt_state_1.PromptState.serviceConfig
|
|
46
47
|
};
|
|
47
48
|
}
|
package/dist/types.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sap-ux/ui-service-inquirer",
|
|
3
3
|
"description": "Generator for creating UI Service",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.15",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/SAP/open-ux-tools.git",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"@sap-ux/guided-answers-helper": "0.2.1",
|
|
30
30
|
"@sap-ux/inquirer-common": "0.6.33",
|
|
31
31
|
"@sap-ux/logger": "0.6.0",
|
|
32
|
-
"@sap-ux/odata-service-inquirer": "2.2.
|
|
32
|
+
"@sap-ux/odata-service-inquirer": "2.2.30",
|
|
33
33
|
"@sap-ux/telemetry": "0.5.72"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
@@ -44,9 +44,9 @@
|
|
|
44
44
|
"rimraf": "5.0.5",
|
|
45
45
|
"typescript": "5.3.3",
|
|
46
46
|
"yeoman-test": "6.3.0",
|
|
47
|
-
"@sap-ux/jest-file-matchers": "0.2.1",
|
|
48
47
|
"@sap-ux/store": "1.0.0",
|
|
49
|
-
"@sap-ux/system-access": "0.5.34"
|
|
48
|
+
"@sap-ux/system-access": "0.5.34",
|
|
49
|
+
"@sap-ux/jest-file-matchers": "0.2.1"
|
|
50
50
|
},
|
|
51
51
|
"engines": {
|
|
52
52
|
"node": ">=18.x"
|