@sap-ux/odata-service-inquirer 2.17.2 → 2.18.0
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.
|
@@ -1,16 +1,18 @@
|
|
|
1
|
-
import type { ConfirmQuestion } from '@sap-ux/inquirer-common';
|
|
2
1
|
import type { ConnectionValidator } from '../../../connectionValidator';
|
|
3
2
|
import type { ConvertedMetadata } from '@sap-ux/vocabularies-types';
|
|
3
|
+
import type { Question } from 'inquirer';
|
|
4
4
|
/**
|
|
5
|
-
* Get the value help download confirmation
|
|
5
|
+
* Get the value help download confirmation prompts.
|
|
6
|
+
* Returns an array that may include both the confirm prompt and a CLI-specific hidden prompt
|
|
7
|
+
* to handle the download since validate functions don't execute for confirm prompts in CLI mode.
|
|
6
8
|
*
|
|
7
9
|
* @param connectionValidator - connection validator instance
|
|
8
10
|
* @param promptNamespace - prompt namespace
|
|
9
11
|
* @param convertedMetadataRef - converted metadata reference
|
|
10
12
|
* @param convertedMetadataRef.convertedMetadata - converted metadata
|
|
11
|
-
* @returns value help download
|
|
13
|
+
* @returns value help download prompts (may be 1 or 2 prompts depending on environment)
|
|
12
14
|
*/
|
|
13
15
|
export declare function getValueHelpDownloadPrompt(connectionValidator: ConnectionValidator, promptNamespace?: string, convertedMetadataRef?: {
|
|
14
16
|
convertedMetadata: ConvertedMetadata | undefined;
|
|
15
|
-
}):
|
|
17
|
+
}): Question[];
|
|
16
18
|
//# sourceMappingURL=value-help-download.d.ts.map
|
|
@@ -44,21 +44,65 @@ async function sendValueHelpTelemetry(eventName, properties, measurements) {
|
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
/**
|
|
47
|
-
*
|
|
47
|
+
* Performs the actual value help download when user confirms.
|
|
48
|
+
* Extracted as a separate function to be reused in both YUI (via validate) and CLI (via hidden prompt).
|
|
49
|
+
*
|
|
50
|
+
* @param downloadMetadata - whether user chose to download
|
|
51
|
+
* @param connectionValidator - connection validator instance
|
|
52
|
+
* @param externalServiceRefs - external service references to download
|
|
53
|
+
*/
|
|
54
|
+
async function performValueHelpDownload(downloadMetadata, connectionValidator, externalServiceRefs) {
|
|
55
|
+
delete utils_1.PromptState.odataService.valueListMetadata;
|
|
56
|
+
// Send telemetry when prompt is answered
|
|
57
|
+
await sendValueHelpTelemetry(telemEventValueHelpDownloadPrompted, {
|
|
58
|
+
userChoseToDownload: downloadMetadata
|
|
59
|
+
});
|
|
60
|
+
if (downloadMetadata && connectionValidator.serviceProvider instanceof axios_extension_1.AbapServiceProvider) {
|
|
61
|
+
const startTime = Date.now();
|
|
62
|
+
try {
|
|
63
|
+
const externalServiceMetadata = await connectionValidator.serviceProvider.fetchExternalServices(externalServiceRefs);
|
|
64
|
+
const downloadTimeMs = Date.now() - startTime;
|
|
65
|
+
if (externalServiceMetadata.length > 0) {
|
|
66
|
+
utils_1.PromptState.odataService.valueListMetadata = externalServiceMetadata;
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
logger_helper_1.default.logger.info((0, i18n_1.t)('warnings.noExternalServiceMetdataFetched'));
|
|
70
|
+
}
|
|
71
|
+
// Send success telemetry with measurements
|
|
72
|
+
await sendValueHelpTelemetry(telemEventValueHelpDownloadSuccess, {
|
|
73
|
+
userChoseToDownload: true,
|
|
74
|
+
valueHelpCount: externalServiceMetadata.length
|
|
75
|
+
}, { downloadTimeMs });
|
|
76
|
+
}
|
|
77
|
+
catch (error) {
|
|
78
|
+
const downloadTimeMs = Date.now() - startTime;
|
|
79
|
+
logger_helper_1.default.logger.error(`Failed to fetch external service metadata: ${error}`);
|
|
80
|
+
// Send failure telemetry with measurements
|
|
81
|
+
await sendValueHelpTelemetry(telemEventValueHelpDownloadFailed, {
|
|
82
|
+
userChoseToDownload: true,
|
|
83
|
+
error: error instanceof Error ? error.message : 'Unknown error'
|
|
84
|
+
}, { downloadTimeMs });
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Get the value help download confirmation prompts.
|
|
90
|
+
* Returns an array that may include both the confirm prompt and a CLI-specific hidden prompt
|
|
91
|
+
* to handle the download since validate functions don't execute for confirm prompts in CLI mode.
|
|
48
92
|
*
|
|
49
93
|
* @param connectionValidator - connection validator instance
|
|
50
94
|
* @param promptNamespace - prompt namespace
|
|
51
95
|
* @param convertedMetadataRef - converted metadata reference
|
|
52
96
|
* @param convertedMetadataRef.convertedMetadata - converted metadata
|
|
53
|
-
* @returns value help download
|
|
97
|
+
* @returns value help download prompts (may be 1 or 2 prompts depending on environment)
|
|
54
98
|
*/
|
|
55
99
|
function getValueHelpDownloadPrompt(connectionValidator, promptNamespace, convertedMetadataRef) {
|
|
56
100
|
const promptNamespacePart = `${promptNamespace ? promptNamespace + ':' : ''}`;
|
|
57
101
|
const promptName = `${promptNamespacePart}${types_1.promptNames.valueHelpDownload}`;
|
|
58
102
|
const servicePromptName = `${promptNamespacePart}${types_1.promptNames.serviceSelection}`;
|
|
103
|
+
const cliDownloadPromptName = `${promptNamespacePart}cliValueHelpDownload`;
|
|
59
104
|
let externalServiceRefs;
|
|
60
|
-
|
|
61
|
-
const question = {
|
|
105
|
+
const valueHelpPrompt = {
|
|
62
106
|
when: (answers) => {
|
|
63
107
|
const service = answers?.[servicePromptName];
|
|
64
108
|
const servicePath = service?.servicePath;
|
|
@@ -72,41 +116,29 @@ function getValueHelpDownloadPrompt(connectionValidator, promptNamespace, conver
|
|
|
72
116
|
type: 'confirm',
|
|
73
117
|
message: (0, i18n_1.t)('prompts.valueHelpDownload.message'),
|
|
74
118
|
validate: async (downloadMetadata) => {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
userChoseToDownload: downloadMetadata
|
|
79
|
-
});
|
|
80
|
-
if (downloadMetadata && connectionValidator.serviceProvider instanceof axios_extension_1.AbapServiceProvider) {
|
|
81
|
-
const startTime = Date.now();
|
|
82
|
-
try {
|
|
83
|
-
externalServiceMetadata = await connectionValidator.serviceProvider.fetchExternalServices(externalServiceRefs);
|
|
84
|
-
const downloadTimeMs = Date.now() - startTime;
|
|
85
|
-
if (externalServiceMetadata.length > 0) {
|
|
86
|
-
utils_1.PromptState.odataService.valueListMetadata = externalServiceMetadata;
|
|
87
|
-
}
|
|
88
|
-
else {
|
|
89
|
-
logger_helper_1.default.logger.info((0, i18n_1.t)('warnings.noExternalServiceMetdataFetched'));
|
|
90
|
-
}
|
|
91
|
-
// Send success telemetry with measurements
|
|
92
|
-
await sendValueHelpTelemetry(telemEventValueHelpDownloadSuccess, {
|
|
93
|
-
userChoseToDownload: true,
|
|
94
|
-
valueHelpCount: externalServiceMetadata.length
|
|
95
|
-
}, { downloadTimeMs });
|
|
96
|
-
}
|
|
97
|
-
catch (error) {
|
|
98
|
-
const downloadTimeMs = Date.now() - startTime;
|
|
99
|
-
logger_helper_1.default.logger.error(`Failed to fetch external service metadata: ${error}`);
|
|
100
|
-
// Send failure telemetry with measurements
|
|
101
|
-
await sendValueHelpTelemetry(telemEventValueHelpDownloadFailed, {
|
|
102
|
-
userChoseToDownload: true,
|
|
103
|
-
error: error instanceof Error ? error.message : 'Unknown error'
|
|
104
|
-
}, { downloadTimeMs });
|
|
105
|
-
}
|
|
119
|
+
// Only run download in YUI mode - CLI mode will use the hidden prompt below
|
|
120
|
+
if ((0, utils_1.getPromptHostEnvironment)() !== fiori_generator_shared_1.hostEnvironment.cli) {
|
|
121
|
+
await performValueHelpDownload(downloadMetadata, connectionValidator, externalServiceRefs);
|
|
106
122
|
}
|
|
107
123
|
return true;
|
|
108
124
|
}
|
|
109
125
|
};
|
|
110
|
-
|
|
126
|
+
const questions = [valueHelpPrompt];
|
|
127
|
+
// Add CLI-specific hidden prompt to handle the download
|
|
128
|
+
// This is necessary because validate functions don't execute for confirm prompts in CLI mode
|
|
129
|
+
if ((0, utils_1.getPromptHostEnvironment)() === fiori_generator_shared_1.hostEnvironment.cli) {
|
|
130
|
+
questions.push({
|
|
131
|
+
when: async (answers) => {
|
|
132
|
+
const downloadMetadata = answers?.[promptName];
|
|
133
|
+
if (downloadMetadata !== undefined && externalServiceRefs) {
|
|
134
|
+
await performValueHelpDownload(downloadMetadata, connectionValidator, externalServiceRefs);
|
|
135
|
+
}
|
|
136
|
+
return false; // Hidden prompt - never actually shown
|
|
137
|
+
},
|
|
138
|
+
name: cliDownloadPromptName,
|
|
139
|
+
type: 'input'
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
return questions;
|
|
111
143
|
}
|
|
112
144
|
//# sourceMappingURL=value-help-download.js.map
|
|
@@ -170,7 +170,7 @@ function getSystemServiceQuestion(connectValidator, promptNamespace, promptOptio
|
|
|
170
170
|
/**
|
|
171
171
|
* Only show the value help download prompt when a service has been validated (convertedMetadata is set), is odata version v4 and is an abap connection
|
|
172
172
|
*/
|
|
173
|
-
questions.push(...(0, inquirer_common_1.withCondition)(
|
|
173
|
+
questions.push(...(0, inquirer_common_1.withCondition)((0, value_help_download_1.getValueHelpDownloadPrompt)(connectValidator, promptNamespace, convertedMetadataRef), (answers) => !!(connectValidator.serviceProvider instanceof axios_extension_1.AbapServiceProvider) &&
|
|
174
174
|
!!convertedMetadataRef.convertedMetadata &&
|
|
175
175
|
answers?.[serviceSelectionPromptName]?.serviceODataVersion === axios_extension_1.ODataVersion.v4));
|
|
176
176
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sap-ux/odata-service-inquirer",
|
|
3
3
|
"description": "Prompts module that can prompt users for inputs required for odata service writing",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.18.0",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/SAP/open-ux-tools.git",
|
|
@@ -31,14 +31,14 @@
|
|
|
31
31
|
"os-name": "4.0.1",
|
|
32
32
|
"@sap-ux/axios-extension": "1.25.11",
|
|
33
33
|
"@sap-ux/btp-utils": "1.1.8",
|
|
34
|
-
"@sap-ux/fiori-generator-shared": "0.13.
|
|
34
|
+
"@sap-ux/fiori-generator-shared": "0.13.69",
|
|
35
35
|
"@sap-ux/guided-answers-helper": "0.4.2",
|
|
36
|
-
"@sap-ux/telemetry": "0.6.
|
|
37
|
-
"@sap-ux/inquirer-common": "0.11.
|
|
36
|
+
"@sap-ux/telemetry": "0.6.70",
|
|
37
|
+
"@sap-ux/inquirer-common": "0.11.3",
|
|
38
38
|
"@sap-ux/logger": "0.8.1",
|
|
39
39
|
"@sap-ux/nodejs-utils": "0.2.14",
|
|
40
|
-
"@sap-ux/project-access": "1.35.
|
|
41
|
-
"@sap-ux/project-input-validator": "0.6.
|
|
40
|
+
"@sap-ux/project-access": "1.35.2",
|
|
41
|
+
"@sap-ux/project-input-validator": "0.6.54",
|
|
42
42
|
"@sap-ux/store": "1.5.5"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
@@ -47,12 +47,12 @@
|
|
|
47
47
|
"@types/inquirer-autocomplete-prompt": "2.0.2",
|
|
48
48
|
"@types/inquirer": "8.2.6",
|
|
49
49
|
"jest-extended": "6.0.0",
|
|
50
|
-
"@sap-ux/fiori-generator-shared": "0.13.
|
|
51
|
-
"@sap-ux/fiori-elements-writer": "2.8.
|
|
52
|
-
"@sap-ux/fiori-freestyle-writer": "2.5.
|
|
50
|
+
"@sap-ux/fiori-generator-shared": "0.13.69",
|
|
51
|
+
"@sap-ux/fiori-elements-writer": "2.8.65",
|
|
52
|
+
"@sap-ux/fiori-freestyle-writer": "2.5.48",
|
|
53
53
|
"@sap-ux/feature-toggle": "0.3.6",
|
|
54
|
-
"@sap-ux/odata-service-writer": "0.29.
|
|
55
|
-
"@sap-ux/cap-config-writer": "0.12.
|
|
54
|
+
"@sap-ux/odata-service-writer": "0.29.17",
|
|
55
|
+
"@sap-ux/cap-config-writer": "0.12.60"
|
|
56
56
|
},
|
|
57
57
|
"engines": {
|
|
58
58
|
"node": ">=20.x"
|