@sap-ux/odata-service-inquirer 0.7.14 → 0.8.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.
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { type InquirerAdapter } from '@sap-ux/inquirer-common';
|
|
2
|
+
import type { Question } from 'inquirer';
|
|
2
3
|
import { type Logger } from '@sap-ux/logger';
|
|
3
4
|
import { OdataVersion } from '@sap-ux/odata-service-writer';
|
|
4
5
|
import { type ToolsSuiteTelemetryClient } from '@sap-ux/telemetry';
|
|
5
6
|
import { ERROR_TYPE, ErrorHandler } from '@sap-ux/inquirer-common';
|
|
6
|
-
import { SystemSelectionAnswerType } from './prompts/datasources/sap-system/system-selection';
|
|
7
|
+
import { type SystemSelectionAnswers, SystemSelectionAnswerType } from './prompts/datasources/sap-system/system-selection';
|
|
8
|
+
import type { ServiceAnswer } from './prompts/datasources/sap-system/service-selection';
|
|
7
9
|
import type { NewSystemChoice, CfAbapEnvServiceChoice } from './prompts/datasources/sap-system/system-selection/prompt-helpers';
|
|
8
10
|
import { DatasourceType, promptNames, type CapRuntime, type CapService, type OdataServiceAnswers, type OdataServicePromptOptions, type OdataServiceQuestion, type SapSystemType } from './types';
|
|
9
11
|
/**
|
|
@@ -20,6 +22,16 @@ declare function getPrompts(promptOptions?: OdataServicePromptOptions, logger?:
|
|
|
20
22
|
prompts: OdataServiceQuestion[];
|
|
21
23
|
answers: Partial<OdataServiceAnswers>;
|
|
22
24
|
}>;
|
|
25
|
+
/**
|
|
26
|
+
* Get the system selection questions.
|
|
27
|
+
*
|
|
28
|
+
* @param promptOptions - options that can control some of the prompt behavior. See {@link OdataServicePromptOptions} for details
|
|
29
|
+
* @returns the prompts used to provide input for system selection and a reference to the answers object which will be populated with the user's responses once `inquirer.prompt` returns
|
|
30
|
+
*/
|
|
31
|
+
declare function getSystemSelectionQuestions(promptOptions?: OdataServicePromptOptions): Promise<{
|
|
32
|
+
prompts: Question<SystemSelectionAnswers & ServiceAnswer>[];
|
|
33
|
+
answers: Partial<OdataServiceAnswers>;
|
|
34
|
+
}>;
|
|
23
35
|
/**
|
|
24
36
|
* Prompt for odata service writer inputs.
|
|
25
37
|
*
|
|
@@ -32,5 +44,5 @@ declare function getPrompts(promptOptions?: OdataServicePromptOptions, logger?:
|
|
|
32
44
|
* @returns the prompt answers
|
|
33
45
|
*/
|
|
34
46
|
declare function prompt(adapter: InquirerAdapter, promptOptions?: OdataServicePromptOptions, logger?: Logger, enableGuidedAnswers?: boolean, telemetryClient?: ToolsSuiteTelemetryClient, isYUI?: boolean): Promise<OdataServiceAnswers>;
|
|
35
|
-
export { DatasourceType, ERROR_TYPE, ErrorHandler, getPrompts, OdataVersion, prompt, promptNames, SystemSelectionAnswerType, type CapRuntime, type CapService, type InquirerAdapter, type OdataServiceAnswers, type OdataServicePromptOptions, type SapSystemType, NewSystemChoice, CfAbapEnvServiceChoice };
|
|
47
|
+
export { DatasourceType, ERROR_TYPE, ErrorHandler, getPrompts, OdataVersion, prompt, promptNames, SystemSelectionAnswerType, type CapRuntime, type CapService, type InquirerAdapter, type OdataServiceAnswers, type OdataServicePromptOptions, type SapSystemType, NewSystemChoice, CfAbapEnvServiceChoice, getSystemSelectionQuestions };
|
|
36
48
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.promptNames = exports.OdataVersion = exports.ErrorHandler = exports.ERROR_TYPE = exports.DatasourceType = void 0;
|
|
7
7
|
exports.getPrompts = getPrompts;
|
|
8
8
|
exports.prompt = prompt;
|
|
9
|
+
exports.getSystemSelectionQuestions = getSystemSelectionQuestions;
|
|
9
10
|
const odata_service_writer_1 = require("@sap-ux/odata-service-writer");
|
|
10
11
|
Object.defineProperty(exports, "OdataVersion", { enumerable: true, get: function () { return odata_service_writer_1.OdataVersion; } });
|
|
11
12
|
const inquirer_autocomplete_prompt_1 = __importDefault(require("inquirer-autocomplete-prompt"));
|
|
@@ -14,6 +15,7 @@ Object.defineProperty(exports, "ERROR_TYPE", { enumerable: true, get: function (
|
|
|
14
15
|
Object.defineProperty(exports, "ErrorHandler", { enumerable: true, get: function () { return inquirer_common_1.ErrorHandler; } });
|
|
15
16
|
const i18n_1 = require("./i18n");
|
|
16
17
|
const prompts_1 = require("./prompts");
|
|
18
|
+
const system_selection_1 = require("./prompts/datasources/sap-system/system-selection");
|
|
17
19
|
const logger_helper_1 = __importDefault(require("./prompts/logger-helper"));
|
|
18
20
|
const types_1 = require("./types");
|
|
19
21
|
Object.defineProperty(exports, "DatasourceType", { enumerable: true, get: function () { return types_1.DatasourceType; } });
|
|
@@ -48,6 +50,18 @@ async function getPrompts(promptOptions, logger, enableGuidedAnswers = false, te
|
|
|
48
50
|
answers: utils_1.PromptState.odataService
|
|
49
51
|
};
|
|
50
52
|
}
|
|
53
|
+
/**
|
|
54
|
+
* Get the system selection questions.
|
|
55
|
+
*
|
|
56
|
+
* @param promptOptions - options that can control some of the prompt behavior. See {@link OdataServicePromptOptions} for details
|
|
57
|
+
* @returns the prompts used to provide input for system selection and a reference to the answers object which will be populated with the user's responses once `inquirer.prompt` returns
|
|
58
|
+
*/
|
|
59
|
+
async function getSystemSelectionQuestions(promptOptions) {
|
|
60
|
+
return {
|
|
61
|
+
prompts: await (0, system_selection_1.getSystemSelectionQuestions)(promptOptions),
|
|
62
|
+
answers: utils_1.PromptState.odataService
|
|
63
|
+
};
|
|
64
|
+
}
|
|
51
65
|
/**
|
|
52
66
|
* Prompt for odata service writer inputs.
|
|
53
67
|
*
|
|
@@ -70,8 +70,9 @@ async function getSystemSelectionQuestions(promptOptions) {
|
|
|
70
70
|
const connectValidator = new connectionValidator_1.ConnectionValidator();
|
|
71
71
|
const questions = await getSystemConnectionQuestions(connectValidator, promptOptions);
|
|
72
72
|
// Existing system (BackendSystem or Destination) selected,
|
|
73
|
-
|
|
74
|
-
|
|
73
|
+
if (!promptOptions?.serviceSelection?.hide) {
|
|
74
|
+
questions.push(...(0, inquirer_common_1.withCondition)((0, questions_3.getSystemServiceQuestion)(connectValidator, systemSelectionPromptNamespace, promptOptions?.serviceSelection), (answers) => answers.systemSelection?.type !== 'newSystemChoice'));
|
|
75
|
+
}
|
|
75
76
|
// Create new system connection for storage only supported on non-App Studio environments
|
|
76
77
|
if (!(0, btp_utils_1.isAppStudio)()) {
|
|
77
78
|
questions.push(...(0, inquirer_common_1.withCondition)((0, questions_2.getNewSystemQuestions)(promptOptions), (answers) => answers.systemSelection?.type === 'newSystemChoice'));
|
|
@@ -92,6 +93,7 @@ async function getSystemConnectionQuestions(connectionValidator, promptOptions)
|
|
|
92
93
|
const destinationFilters = promptOptions?.systemSelection?.destinationFilters;
|
|
93
94
|
const systemChoices = await (0, prompt_helpers_1.createSystemChoices)(destinationFilters, promptOptions?.systemSelection?.includeCloudFoundryAbapEnvChoice);
|
|
94
95
|
const defaultChoiceIndex = (0, prompt_helpers_1.findDefaultSystemSelectionIndex)(systemChoices, promptOptions?.systemSelection?.defaultChoice);
|
|
96
|
+
const shouldOnlyShowDefaultChoice = promptOptions?.systemSelection?.onlyShowDefaultChoice && promptOptions?.systemSelection?.defaultChoice;
|
|
95
97
|
const questions = [
|
|
96
98
|
{
|
|
97
99
|
type: promptOptions?.systemSelection?.useAutoComplete ? 'autocomplete' : 'list',
|
|
@@ -102,8 +104,8 @@ async function getSystemConnectionQuestions(connectionValidator, promptOptions)
|
|
|
102
104
|
hint: (0, i18n_1.t)('prompts.systemSelection.hint')
|
|
103
105
|
},
|
|
104
106
|
source: (prevAnswers, input) => (0, inquirer_common_1.searchChoices)(input, systemChoices),
|
|
105
|
-
choices: systemChoices,
|
|
106
|
-
default: defaultChoiceIndex,
|
|
107
|
+
choices: shouldOnlyShowDefaultChoice ? [systemChoices[defaultChoiceIndex]] : systemChoices,
|
|
108
|
+
default: shouldOnlyShowDefaultChoice ? 0 : defaultChoiceIndex,
|
|
107
109
|
validate: async (selectedSystem) => {
|
|
108
110
|
if (!selectedSystem) {
|
|
109
111
|
return false;
|
package/dist/types.d.ts
CHANGED
|
@@ -238,6 +238,12 @@ export type SystemSelectionPromptOptions = {
|
|
|
238
238
|
*
|
|
239
239
|
*/
|
|
240
240
|
defaultChoice?: string;
|
|
241
|
+
/**
|
|
242
|
+
* Only show the default choice in the system selection prompt, this is used to skip the system selection prompt if the default choice is already known.
|
|
243
|
+
* If the `defaultChoice` value is not found in the systems choices, or the `defaultChoice` option is not specified,
|
|
244
|
+
* this option will not be applied and the full list of choices will be presented to the user.
|
|
245
|
+
*/
|
|
246
|
+
onlyShowDefaultChoice?: boolean;
|
|
241
247
|
};
|
|
242
248
|
export type MetadataPromptOptions = {
|
|
243
249
|
/**
|
|
@@ -255,6 +261,11 @@ export type ServiceSelectionPromptOptions = {
|
|
|
255
261
|
* Used to validate the selected service is of the required odata version
|
|
256
262
|
*/
|
|
257
263
|
requiredOdataVersion?: OdataVersion;
|
|
264
|
+
/**
|
|
265
|
+
* This allows the prompt to be excluded where consuming generators only require the system connection functionality.
|
|
266
|
+
* If the service selection prompt is hidden then the odata service related answer properties will not be returned.
|
|
267
|
+
*/
|
|
268
|
+
hide?: boolean;
|
|
258
269
|
} & Pick<CommonPromptOptions, 'additionalMessages'>;
|
|
259
270
|
export type SystemNamePromptOptions = {
|
|
260
271
|
/**
|
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": "0.
|
|
4
|
+
"version": "0.8.0",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/SAP/open-ux-tools.git",
|
|
@@ -28,14 +28,14 @@
|
|
|
28
28
|
"os-name": "4.0.1",
|
|
29
29
|
"@sap-ux/axios-extension": "1.17.8",
|
|
30
30
|
"@sap-ux/btp-utils": "0.17.2",
|
|
31
|
+
"@sap-ux/fiori-generator-shared": "0.7.17",
|
|
31
32
|
"@sap-ux/guided-answers-helper": "0.1.1",
|
|
32
33
|
"@sap-ux/telemetry": "0.5.50",
|
|
33
|
-
"@sap-ux/fiori-generator-shared": "0.7.17",
|
|
34
34
|
"@sap-ux/inquirer-common": "0.5.15",
|
|
35
35
|
"@sap-ux/logger": "0.6.0",
|
|
36
36
|
"@sap-ux/project-access": "1.28.10",
|
|
37
|
-
"@sap-ux/
|
|
38
|
-
"@sap-ux/
|
|
37
|
+
"@sap-ux/store": "1.0.0",
|
|
38
|
+
"@sap-ux/project-input-validator": "0.3.4"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@sap-devx/yeoman-ui-types": "1.14.4",
|
|
@@ -44,8 +44,8 @@
|
|
|
44
44
|
"@types/lodash": "4.14.202",
|
|
45
45
|
"jest-extended": "3.2.4",
|
|
46
46
|
"@sap-ux/fiori-generator-shared": "0.7.17",
|
|
47
|
-
"@sap-ux/
|
|
48
|
-
"@sap-ux/
|
|
47
|
+
"@sap-ux/feature-toggle": "0.2.3",
|
|
48
|
+
"@sap-ux/odata-service-writer": "0.25.0"
|
|
49
49
|
},
|
|
50
50
|
"engines": {
|
|
51
51
|
"node": ">=18.x"
|