@sap-ux/odata-service-inquirer 2.13.10 → 2.14.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/index.js +2 -1
- package/dist/prompts/datasources/cap-project/cap-helpers.js +19 -2
- package/dist/prompts/datasources/cap-project/questions.js +3 -1
- package/dist/prompts/datasources/sap-system/service-selection/service-helper.d.ts +2 -2
- package/dist/prompts/datasources/sap-system/service-selection/service-helper.js +12 -4
- package/dist/translations/odata-service-inquirer.i18n.json +2 -1
- package/dist/types.d.ts +5 -0
- package/package.json +11 -11
package/dist/index.js
CHANGED
|
@@ -102,7 +102,8 @@ function getEntityRelatedPrompts(metadata, templateType, isCapService = false, p
|
|
|
102
102
|
* @returns the prompt answers
|
|
103
103
|
*/
|
|
104
104
|
async function prompt(adapter, promptOptions, logger, enableGuidedAnswers, telemetryClient, isYUI = false, connectedSystem) {
|
|
105
|
-
if (adapter?.promptModule &&
|
|
105
|
+
if (adapter?.promptModule &&
|
|
106
|
+
(promptOptions?.serviceSelection?.useAutoComplete ?? promptOptions?.capProject?.useAutoComplete)) {
|
|
106
107
|
const pm = adapter.promptModule;
|
|
107
108
|
pm.registerPrompt('autocomplete', inquirer_autocomplete_prompt_1.default);
|
|
108
109
|
}
|
|
@@ -14,15 +14,32 @@ const logger_helper_1 = __importDefault(require("../../logger-helper"));
|
|
|
14
14
|
const prompt_helpers_1 = require("../../prompt-helpers");
|
|
15
15
|
const inquirer_common_1 = require("@sap-ux/inquirer-common");
|
|
16
16
|
const promises_1 = require("node:fs/promises");
|
|
17
|
+
const fiori_generator_shared_1 = require("@sap-ux/fiori-generator-shared");
|
|
18
|
+
const node_process_1 = require("node:process");
|
|
17
19
|
exports.enterCapPathChoiceValue = 'enterCapPath';
|
|
18
20
|
/**
|
|
19
|
-
*
|
|
21
|
+
* Searches for CAP project root paths from given paths, searching up to 2 parent levels if needed in CLI environment.
|
|
22
|
+
* Returns sorted paths with priority given to projects matching the original paths, and tracks duplicate folder names.
|
|
20
23
|
*
|
|
21
|
-
* @param paths -
|
|
24
|
+
* @param paths - Array of file system paths to search for CAP projects
|
|
22
25
|
* @returns The CAP project paths and the number of folders with the same name
|
|
23
26
|
*/
|
|
24
27
|
async function getCapProjectPaths(paths) {
|
|
25
28
|
const capProjectRoots = await (0, project_access_1.findCapProjects)({ wsFolders: paths });
|
|
29
|
+
if (capProjectRoots.length === 0 && (0, fiori_generator_shared_1.getHostEnvironment)() === fiori_generator_shared_1.hostEnvironment.cli) {
|
|
30
|
+
// If no CAP projects found, search parent directories (up to 2 levels)
|
|
31
|
+
const parentPath = (0, node_path_1.dirname)((0, node_process_1.cwd)());
|
|
32
|
+
const grandparentPath = (0, node_path_1.dirname)(parentPath);
|
|
33
|
+
// Second call is needed, since we don't want to traverse the whole fs
|
|
34
|
+
const capProjectsUp = await (0, project_access_1.findCapProjects)({
|
|
35
|
+
wsFolders: [parentPath, grandparentPath],
|
|
36
|
+
noTraversal: true
|
|
37
|
+
});
|
|
38
|
+
if (capProjectsUp.length > 0) {
|
|
39
|
+
// Add only the first found project from parent search, since we only want the current project's parent
|
|
40
|
+
capProjectRoots.push(capProjectsUp[0]);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
26
43
|
const capRootPaths = [];
|
|
27
44
|
// Keep track of duplicate folder names to append the path to the name when displaying the choices
|
|
28
45
|
const folderNameCount = new Map();
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getLocalCapProjectPrompts = getLocalCapProjectPrompts;
|
|
4
|
+
const inquirer_common_1 = require("@sap-ux/inquirer-common");
|
|
4
5
|
const odata_service_writer_1 = require("@sap-ux/odata-service-writer");
|
|
5
6
|
const project_access_1 = require("@sap-ux/project-access");
|
|
6
7
|
const fiori_generator_shared_1 = require("@sap-ux/fiori-generator-shared");
|
|
@@ -56,13 +57,14 @@ function getLocalCapProjectPrompts(promptOptions) {
|
|
|
56
57
|
capChoices = await (0, cap_helpers_1.getCapProjectChoices)(promptOptions?.[types_1.promptNames.capProject]?.capSearchPaths ?? []);
|
|
57
58
|
return capChoices?.length > 1;
|
|
58
59
|
},
|
|
59
|
-
type: 'list',
|
|
60
|
+
type: promptOptions?.[types_1.promptNames.capProject]?.useAutoComplete ? 'autocomplete' : 'list',
|
|
60
61
|
name: types_1.promptNames.capProject,
|
|
61
62
|
message: (0, i18n_1.t)('prompts.capProject.message'),
|
|
62
63
|
default: () => {
|
|
63
64
|
const defChoice = getDefaultCapChoice(capChoices, defaultCapPath);
|
|
64
65
|
return defChoice;
|
|
65
66
|
},
|
|
67
|
+
source: (prevAnswers, input) => (0, inquirer_common_1.searchChoices)(input, capChoices),
|
|
66
68
|
choices: () => capChoices,
|
|
67
69
|
guiOptions: {
|
|
68
70
|
applyDefaultWhenDirty: true,
|
|
@@ -2,10 +2,10 @@ import { type IMessageSeverity } from '@sap-devx/yeoman-ui-types';
|
|
|
2
2
|
import { type CatalogService, ServiceType, V2CatalogService } from '@sap-ux/axios-extension';
|
|
3
3
|
import type { Destination } from '@sap-ux/btp-utils';
|
|
4
4
|
import { OdataVersion } from '@sap-ux/odata-service-writer';
|
|
5
|
+
import type { ConvertedMetadata } from '@sap-ux/vocabularies-types';
|
|
5
6
|
import type { ListChoiceOptions } from 'inquirer';
|
|
6
7
|
import type { ConnectionValidator } from '../../../connectionValidator';
|
|
7
8
|
import type { ServiceAnswer } from './types';
|
|
8
|
-
import type { ConvertedMetadata } from '@sap-ux/vocabularies-types';
|
|
9
9
|
export declare const telemEventBASServiceSuccess = "SERVICE_INQUIRER_BAS_SUCCESS";
|
|
10
10
|
/**
|
|
11
11
|
* Get the service choices from the specified catalogs.
|
|
@@ -75,7 +75,7 @@ type ShowCollabDraftWarnOptions = {
|
|
|
75
75
|
* and the edmx metadata must be provided
|
|
76
76
|
* @returns the service selection prompt additional message
|
|
77
77
|
*/
|
|
78
|
-
export declare function getSelectedServiceMessage(serviceChoices: ListChoiceOptions<ServiceAnswer>[], selectedService: ServiceAnswer, connectValidator: ConnectionValidator, { requiredOdataVersion, hasAnnotations, showCollabDraftWarnOptions }: {
|
|
78
|
+
export declare function getSelectedServiceMessage(serviceChoices: ListChoiceOptions<ServiceAnswer>[], selectedService: ServiceAnswer | undefined, connectValidator: ConnectionValidator, { requiredOdataVersion, hasAnnotations, showCollabDraftWarnOptions }: {
|
|
79
79
|
requiredOdataVersion?: OdataVersion;
|
|
80
80
|
hasAnnotations?: boolean;
|
|
81
81
|
showCollabDraftWarnOptions?: ShowCollabDraftWarnOptions;
|
|
@@ -69,9 +69,9 @@ const createServiceChoices = (serviceInfos) => {
|
|
|
69
69
|
* @param numOfRequests the number of catalog service requests made
|
|
70
70
|
*/
|
|
71
71
|
function logServiceCatalogErrorsForHelp(requestErrors, numOfRequests) {
|
|
72
|
-
const catalogRequesErrors = Object.
|
|
73
|
-
catalogRequesErrors.forEach((error) => {
|
|
74
|
-
prompt_helpers_1.errorHandler.logErrorMsgs(error); //
|
|
72
|
+
const catalogRequesErrors = Object.entries(requestErrors);
|
|
73
|
+
catalogRequesErrors.forEach(([odataVersion, error]) => {
|
|
74
|
+
prompt_helpers_1.errorHandler.logErrorMsgs(error, (0, i18n_1.t)('warnings.missingServices', { odataVersion })); // Error state is set for later processing
|
|
75
75
|
});
|
|
76
76
|
// If all requests failed, log a generic message, this will be stored in the error handler
|
|
77
77
|
if (numOfRequests === catalogRequesErrors.length) {
|
|
@@ -122,7 +122,8 @@ async function getServiceChoices(catalogs, serviceFilter) {
|
|
|
122
122
|
// Flatten the array of arrays
|
|
123
123
|
let flatServices = listServicesRequests?.flat() ?? [];
|
|
124
124
|
logger_helper_1.default.logger.debug(`Number of services available: ${flatServices.length}`);
|
|
125
|
-
|
|
125
|
+
// If no services or any catalog errors log the message to the error handler for later processing
|
|
126
|
+
if (flatServices.length === 0 || Object.keys(requestErrors).length > 0) {
|
|
126
127
|
logServiceCatalogErrorsForHelp(requestErrors, catalogs.length);
|
|
127
128
|
}
|
|
128
129
|
if (serviceFilter) {
|
|
@@ -342,5 +343,12 @@ async function getSelectedServiceMessage(serviceChoices, selectedService, connec
|
|
|
342
343
|
};
|
|
343
344
|
}
|
|
344
345
|
}
|
|
346
|
+
// If any catalog request errors, show an info message. We know this is a catalog error since there is no service selected.
|
|
347
|
+
if (prompt_helpers_1.errorHandler.getErrorMsg()) {
|
|
348
|
+
return {
|
|
349
|
+
message: `${prompt_helpers_1.errorHandler.getErrorMsg()} ${(0, i18n_1.t)('texts.seeLogForDetails')}`,
|
|
350
|
+
severity: yeoman_ui_types_1.Severity.information
|
|
351
|
+
};
|
|
352
|
+
}
|
|
345
353
|
}
|
|
346
354
|
//# sourceMappingURL=service-helper.js.map
|
|
@@ -261,7 +261,8 @@
|
|
|
261
261
|
"certificateErrors": "A certificate error occurred when connecting to the host: {{-url}}. Certificate error: {{error}}.",
|
|
262
262
|
"allowingUnauthorizedCertsNode": "Setting the `NODE_TLS_REJECT_UNAUTHORIZED` environment variable to `0` makes TLS connections and HTTPS requests insecure by disabling certificate verification. It is important to understand the security risks when using this setting.",
|
|
263
263
|
"certErrorIgnoredByNodeSetting": "An SSL certificate error is being ignored by the 'NODE_TLS_REJECT_UNAUTHORIZED=0' Node.js setting. This makes TLS connections and HTTPS requests insecure by disabling certificate verification. For details of the certification error, see the logs.",
|
|
264
|
-
"noExternalServiceMetdataFetched": "No external service metadata were fetched. $t(texts.seeLogForDetails)."
|
|
264
|
+
"noExternalServiceMetdataFetched": "No external service metadata were fetched. $t(texts.seeLogForDetails).",
|
|
265
|
+
"missingServices": "OData V{{odataVersion}} services are not available."
|
|
265
266
|
},
|
|
266
267
|
"texts": {
|
|
267
268
|
"suggestedSystemNameClient": ", client {{client}}",
|
package/dist/types.d.ts
CHANGED
|
@@ -216,6 +216,11 @@ export type CapProjectPromptOptions = {
|
|
|
216
216
|
* The default selected CAP project choice, this is used to pre-select a CAP project based on the CAP project path.
|
|
217
217
|
*/
|
|
218
218
|
defaultChoice?: string;
|
|
219
|
+
/**
|
|
220
|
+
* Use autocomplete for project selection instead of list (CLI only).
|
|
221
|
+
* Note: inquirer-autocomplete-prompt module is used for this feature and has to be registered with the inquirer instance.
|
|
222
|
+
*/
|
|
223
|
+
useAutoComplete?: boolean;
|
|
219
224
|
};
|
|
220
225
|
export type CapServicePromptOptions = {
|
|
221
226
|
/**
|
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.14.1",
|
|
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.6",
|
|
33
33
|
"@sap-ux/btp-utils": "1.1.6",
|
|
34
|
-
"@sap-ux/fiori-generator-shared": "0.13.
|
|
34
|
+
"@sap-ux/fiori-generator-shared": "0.13.50",
|
|
35
35
|
"@sap-ux/guided-answers-helper": "0.4.2",
|
|
36
|
-
"@sap-ux/telemetry": "0.6.
|
|
37
|
-
"@sap-ux/inquirer-common": "0.10.
|
|
36
|
+
"@sap-ux/telemetry": "0.6.52",
|
|
37
|
+
"@sap-ux/inquirer-common": "0.10.9",
|
|
38
38
|
"@sap-ux/logger": "0.8.0",
|
|
39
39
|
"@sap-ux/nodejs-utils": "0.2.11",
|
|
40
|
-
"@sap-ux/project-access": "1.33.
|
|
41
|
-
"@sap-ux/project-input-validator": "0.6.
|
|
40
|
+
"@sap-ux/project-access": "1.33.2",
|
|
41
|
+
"@sap-ux/project-input-validator": "0.6.42",
|
|
42
42
|
"@sap-ux/store": "1.4.2"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
@@ -48,12 +48,12 @@
|
|
|
48
48
|
"@types/inquirer": "8.2.6",
|
|
49
49
|
"@types/lodash": "4.14.202",
|
|
50
50
|
"jest-extended": "6.0.0",
|
|
51
|
-
"@sap-ux/fiori-generator-shared": "0.13.
|
|
52
|
-
"@sap-ux/fiori-elements-writer": "2.8.
|
|
53
|
-
"@sap-ux/fiori-freestyle-writer": "2.5.
|
|
51
|
+
"@sap-ux/fiori-generator-shared": "0.13.50",
|
|
52
|
+
"@sap-ux/fiori-elements-writer": "2.8.35",
|
|
53
|
+
"@sap-ux/fiori-freestyle-writer": "2.5.25",
|
|
54
54
|
"@sap-ux/feature-toggle": "0.3.5",
|
|
55
|
-
"@sap-ux/odata-service-writer": "0.29.
|
|
56
|
-
"@sap-ux/cap-config-writer": "0.12.
|
|
55
|
+
"@sap-ux/odata-service-writer": "0.29.5",
|
|
56
|
+
"@sap-ux/cap-config-writer": "0.12.41"
|
|
57
57
|
},
|
|
58
58
|
"engines": {
|
|
59
59
|
"node": ">=20.x"
|