@sap-ux/fe-fpm-writer 0.25.6 → 0.26.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/building-block/index.d.ts +13 -1
- package/dist/building-block/index.js +99 -6
- package/dist/building-block/prompts/questions/building-blocks.d.ts +11 -0
- package/dist/building-block/prompts/questions/building-blocks.js +29 -0
- package/dist/building-block/prompts/questions/chart.d.ts +12 -0
- package/dist/building-block/prompts/questions/chart.js +127 -0
- package/dist/building-block/prompts/questions/filter-bar.d.ts +12 -0
- package/dist/building-block/prompts/questions/filter-bar.js +86 -0
- package/dist/building-block/prompts/questions/index.d.ts +5 -0
- package/dist/building-block/prompts/questions/index.js +21 -0
- package/dist/building-block/prompts/questions/table.d.ts +12 -0
- package/dist/building-block/prompts/questions/table.js +251 -0
- package/dist/building-block/prompts/utils/index.d.ts +5 -0
- package/dist/building-block/prompts/utils/index.js +21 -0
- package/dist/building-block/prompts/utils/project.d.ts +9 -0
- package/dist/building-block/prompts/utils/project.js +14 -0
- package/dist/building-block/prompts/utils/questions.d.ts +93 -0
- package/dist/building-block/prompts/utils/questions.js +343 -0
- package/dist/building-block/prompts/utils/service.d.ts +68 -0
- package/dist/building-block/prompts/utils/service.js +198 -0
- package/dist/building-block/prompts/utils/xml.d.ts +27 -0
- package/dist/building-block/prompts/utils/xml.js +104 -0
- package/dist/building-block/types.d.ts +16 -1
- package/dist/i18n.d.ts +17 -0
- package/dist/i18n.js +54 -0
- package/dist/index.d.ts +5 -2
- package/dist/index.js +7 -1
- package/dist/prompts/api.d.ts +82 -0
- package/dist/prompts/api.js +177 -0
- package/dist/prompts/index.d.ts +4 -0
- package/dist/prompts/index.js +19 -0
- package/dist/prompts/map.d.ts +37 -0
- package/dist/prompts/map.js +23 -0
- package/dist/prompts/translations/i18n.en.json +170 -0
- package/dist/prompts/types.d.ts +48 -0
- package/dist/prompts/types.js +20 -0
- package/dist/prompts/utils.d.ts +10 -0
- package/dist/prompts/utils.js +23 -0
- package/package.json +12 -3
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Editor } from 'mem-fs-editor';
|
|
2
|
-
import type
|
|
2
|
+
import { type BuildingBlock, type BuildingBlockConfig } from './types';
|
|
3
|
+
import { type CodeSnippet } from '../prompts/types';
|
|
3
4
|
/**
|
|
4
5
|
* Generates a building block into the provided xml view file.
|
|
5
6
|
*
|
|
@@ -9,4 +10,15 @@ import type { BuildingBlock, BuildingBlockConfig } from './types';
|
|
|
9
10
|
* @returns {Editor} the updated memfs editor instance
|
|
10
11
|
*/
|
|
11
12
|
export declare function generateBuildingBlock<T extends BuildingBlock>(basePath: string, config: BuildingBlockConfig<T>, fs?: Editor): Editor;
|
|
13
|
+
/**
|
|
14
|
+
* Gets the serialized content of the updated view file.
|
|
15
|
+
*
|
|
16
|
+
* @param {string} basePath - The base path
|
|
17
|
+
* @param {BuildingBlockConfig} config - The building block configuration
|
|
18
|
+
* @param {Editor} [fs] - The memfs editor instance
|
|
19
|
+
* @returns {{ [questionName: string]: CodeSnippet }} An object with serialized code snippet content and file props
|
|
20
|
+
*/
|
|
21
|
+
export declare function getSerializedFileContent<T extends BuildingBlock>(basePath: string, config: BuildingBlockConfig<T>, fs?: Editor): {
|
|
22
|
+
[questionName: string]: CodeSnippet;
|
|
23
|
+
};
|
|
12
24
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.generateBuildingBlock = void 0;
|
|
29
|
+
exports.getSerializedFileContent = exports.generateBuildingBlock = void 0;
|
|
30
30
|
const mem_fs_1 = require("mem-fs");
|
|
31
31
|
const mem_fs_editor_1 = require("mem-fs-editor");
|
|
32
32
|
const ejs_1 = require("ejs");
|
|
@@ -36,6 +36,12 @@ const xpath = __importStar(require("xpath"));
|
|
|
36
36
|
const xml_formatter_1 = __importDefault(require("xml-formatter"));
|
|
37
37
|
const validate_1 = require("../common/validate");
|
|
38
38
|
const templates_1 = require("../templates");
|
|
39
|
+
const types_1 = require("../prompts/types");
|
|
40
|
+
const PLACEHOLDERS = {
|
|
41
|
+
'id': 'REPLACE_WITH_BUILDING_BLOCK_ID',
|
|
42
|
+
'entitySet': 'REPLACE_WITH_ENTITY',
|
|
43
|
+
'qualifier': 'REPLACE_WITH_A_QUALIFIER'
|
|
44
|
+
};
|
|
39
45
|
/**
|
|
40
46
|
* Generates a building block into the provided xml view file.
|
|
41
47
|
*
|
|
@@ -105,20 +111,59 @@ function getOrAddMacrosNamespace(ui5XmlDocument) {
|
|
|
105
111
|
return macrosNamespaceEntry ? macrosNamespaceEntry[0] : 'macros';
|
|
106
112
|
}
|
|
107
113
|
/**
|
|
108
|
-
*
|
|
114
|
+
* Method converts object based metaPath to string.
|
|
115
|
+
*
|
|
116
|
+
* @param {BuildingBlockMetaPath} metaPath - object based metaPath.
|
|
117
|
+
* @param {boolean} usePlaceholders - apply placeholder values if value for attribute/property is not provided
|
|
118
|
+
* @returns {string} Resolved string metaPath.
|
|
119
|
+
*/
|
|
120
|
+
function getMetaPath(metaPath, usePlaceholders) {
|
|
121
|
+
if (!metaPath) {
|
|
122
|
+
return usePlaceholders ? `/${PLACEHOLDERS.entitySet}/${PLACEHOLDERS.qualifier}` : '';
|
|
123
|
+
}
|
|
124
|
+
const { entitySet, qualifier, bindingContextType = 'absolute' } = metaPath;
|
|
125
|
+
let entityPath = entitySet || (usePlaceholders ? PLACEHOLDERS.entitySet : '');
|
|
126
|
+
const lastIndex = entityPath.lastIndexOf('.');
|
|
127
|
+
entityPath = lastIndex >= 0 ? entityPath.substring?.(lastIndex + 1) : entityPath;
|
|
128
|
+
const qualifierOrPlaceholder = qualifier || (usePlaceholders ? PLACEHOLDERS.qualifier : '');
|
|
129
|
+
return bindingContextType === 'absolute' ? `/${entityPath}/${qualifierOrPlaceholder}` : qualifierOrPlaceholder;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Returns the content of the xml file document.
|
|
109
133
|
*
|
|
110
134
|
* @param {BuildingBlock} buildingBlockData - the building block data
|
|
111
135
|
* @param {Document} viewDocument - the view xml file document
|
|
112
136
|
* @param {Editor} fs - the memfs editor instance
|
|
113
|
-
* @
|
|
137
|
+
* @param {boolean} usePlaceholders - apply placeholder values if value for attribute/property is not provided
|
|
138
|
+
* @returns {string} the template xml file content
|
|
114
139
|
*/
|
|
115
|
-
function
|
|
140
|
+
function getTemplateContent(buildingBlockData, viewDocument, fs, usePlaceholders) {
|
|
116
141
|
const templateFolderName = buildingBlockData.buildingBlockType;
|
|
117
142
|
const templateFilePath = (0, templates_1.getTemplatePath)(`/building-block/${templateFolderName}/View.xml`);
|
|
118
|
-
|
|
119
|
-
|
|
143
|
+
if (typeof buildingBlockData.metaPath === 'object' || buildingBlockData.metaPath === undefined) {
|
|
144
|
+
// Convert object based metapath to string
|
|
145
|
+
const metaPath = getMetaPath(buildingBlockData.metaPath, usePlaceholders);
|
|
146
|
+
buildingBlockData = { ...buildingBlockData, metaPath };
|
|
147
|
+
}
|
|
148
|
+
// Apply placeholders
|
|
149
|
+
if (!buildingBlockData.id) {
|
|
150
|
+
buildingBlockData.id = PLACEHOLDERS.id;
|
|
151
|
+
}
|
|
152
|
+
return (0, ejs_1.render)(fs.read(templateFilePath), {
|
|
153
|
+
macrosNamespace: viewDocument ? getOrAddMacrosNamespace(viewDocument) : 'macros',
|
|
120
154
|
data: buildingBlockData
|
|
121
155
|
}, {});
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Returns the template xml file document.
|
|
159
|
+
*
|
|
160
|
+
* @param {BuildingBlock} buildingBlockData - the building block data
|
|
161
|
+
* @param {Document} viewDocument - the view xml file document
|
|
162
|
+
* @param {Editor} fs - the memfs editor instance
|
|
163
|
+
* @returns {Document} the template xml file document
|
|
164
|
+
*/
|
|
165
|
+
function getTemplateDocument(buildingBlockData, viewDocument, fs) {
|
|
166
|
+
const templateContent = getTemplateContent(buildingBlockData, viewDocument, fs);
|
|
122
167
|
const errorHandler = (level, message) => {
|
|
123
168
|
throw new Error(`Unable to parse template file with building block data. Details: [${level}] - ${message}`);
|
|
124
169
|
};
|
|
@@ -160,4 +205,52 @@ function updateViewFile(basePath, viewPath, aggregationPath, viewDocument, templ
|
|
|
160
205
|
}
|
|
161
206
|
return fs;
|
|
162
207
|
}
|
|
208
|
+
/**
|
|
209
|
+
* Gets the properties for the file if the relative path is defined.
|
|
210
|
+
*
|
|
211
|
+
* @param {string} basePath - The base path
|
|
212
|
+
* @param {string} relativePath - The relative path to the file in the config
|
|
213
|
+
* @returns {FilePathProps} An object with file properties
|
|
214
|
+
*/
|
|
215
|
+
function getFilePathProps(basePath, relativePath) {
|
|
216
|
+
if (relativePath) {
|
|
217
|
+
return {
|
|
218
|
+
fileName: (0, path_1.parse)(relativePath).base,
|
|
219
|
+
relativePath,
|
|
220
|
+
fullPath: (0, path_1.join)(basePath, relativePath)
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
return {};
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Gets the serialized content of the updated view file.
|
|
227
|
+
*
|
|
228
|
+
* @param {string} basePath - The base path
|
|
229
|
+
* @param {BuildingBlockConfig} config - The building block configuration
|
|
230
|
+
* @param {Editor} [fs] - The memfs editor instance
|
|
231
|
+
* @returns {{ [questionName: string]: CodeSnippet }} An object with serialized code snippet content and file props
|
|
232
|
+
*/
|
|
233
|
+
function getSerializedFileContent(basePath, config, fs) {
|
|
234
|
+
if (!config.buildingBlockData?.buildingBlockType) {
|
|
235
|
+
return {};
|
|
236
|
+
}
|
|
237
|
+
// Validate the base and view paths
|
|
238
|
+
if (!fs) {
|
|
239
|
+
fs = (0, mem_fs_editor_1.create)((0, mem_fs_1.create)());
|
|
240
|
+
}
|
|
241
|
+
// Read the view xml and template files and get content of the view xml file
|
|
242
|
+
const xmlDocument = config.viewOrFragmentPath
|
|
243
|
+
? getUI5XmlDocument(basePath, config.viewOrFragmentPath, fs)
|
|
244
|
+
: undefined;
|
|
245
|
+
const content = getTemplateContent(config.buildingBlockData, xmlDocument, fs, true);
|
|
246
|
+
const filePathProps = getFilePathProps(basePath, config.viewOrFragmentPath);
|
|
247
|
+
return {
|
|
248
|
+
viewOrFragmentPath: {
|
|
249
|
+
content,
|
|
250
|
+
language: types_1.CodeSnippetLanguage.XML,
|
|
251
|
+
filePathProps
|
|
252
|
+
}
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
exports.getSerializedFileContent = getSerializedFileContent;
|
|
163
256
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Answers, Prompts, PromptsType } from '../../../prompts/types';
|
|
2
|
+
export interface BuildingBlockTypePromptsAnswer extends Answers {
|
|
3
|
+
buildingBlockType: PromptsType;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Returns a list of prompts required to generate building blocks.
|
|
7
|
+
*
|
|
8
|
+
* @returns The list of prompts for building block types selection.
|
|
9
|
+
*/
|
|
10
|
+
export declare function getBuildingBlockTypePrompts(): Promise<Prompts<BuildingBlockTypePromptsAnswer>>;
|
|
11
|
+
//# sourceMappingURL=building-blocks.d.ts.map
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getBuildingBlockTypePrompts = void 0;
|
|
4
|
+
const i18n_1 = require("../../../i18n");
|
|
5
|
+
const types_1 = require("../../types");
|
|
6
|
+
/**
|
|
7
|
+
* Returns a list of prompts required to generate building blocks.
|
|
8
|
+
*
|
|
9
|
+
* @returns The list of prompts for building block types selection.
|
|
10
|
+
*/
|
|
11
|
+
async function getBuildingBlockTypePrompts() {
|
|
12
|
+
const t = (0, i18n_1.translate)(i18n_1.i18nNamespaces.buildingBlock, 'prompts.super.');
|
|
13
|
+
return {
|
|
14
|
+
questions: [
|
|
15
|
+
{
|
|
16
|
+
type: 'list',
|
|
17
|
+
name: 'buildingBlockType',
|
|
18
|
+
message: t('buildingBlockType.message'),
|
|
19
|
+
choices: [
|
|
20
|
+
{ name: t('buildingBlockType.choices.chart'), value: types_1.BuildingBlockType.Chart },
|
|
21
|
+
{ name: t('buildingBlockType.choices.filterBar'), value: types_1.BuildingBlockType.FilterBar },
|
|
22
|
+
{ name: t('buildingBlockType.choices.table'), value: types_1.BuildingBlockType.Table }
|
|
23
|
+
]
|
|
24
|
+
}
|
|
25
|
+
]
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
exports.getBuildingBlockTypePrompts = getBuildingBlockTypePrompts;
|
|
29
|
+
//# sourceMappingURL=building-blocks.js.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Answers } from 'inquirer';
|
|
2
|
+
import type { PromptContext, Prompts } from '../../../prompts/types';
|
|
3
|
+
import type { BuildingBlockConfig, Chart } from '../../types';
|
|
4
|
+
export type ChartPromptsAnswer = BuildingBlockConfig<Chart> & Answers;
|
|
5
|
+
/**
|
|
6
|
+
* Returns a list of prompts required to generate a chart building block.
|
|
7
|
+
*
|
|
8
|
+
* @param context - prompt context including data about project
|
|
9
|
+
* @returns Prompt with questions for chart.
|
|
10
|
+
*/
|
|
11
|
+
export declare function getChartBuildingBlockPrompts(context: PromptContext): Promise<Prompts<ChartPromptsAnswer>>;
|
|
12
|
+
//# sourceMappingURL=chart.d.ts.map
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getChartBuildingBlockPrompts = void 0;
|
|
4
|
+
const i18n_1 = require("../../../i18n");
|
|
5
|
+
const utils_1 = require("../utils");
|
|
6
|
+
const types_1 = require("../../types");
|
|
7
|
+
const defaultAnswers = {
|
|
8
|
+
id: 'Chart',
|
|
9
|
+
bindingContextType: 'absolute'
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Returns a list of prompts required to generate a chart building block.
|
|
13
|
+
*
|
|
14
|
+
* @param context - prompt context including data about project
|
|
15
|
+
* @returns Prompt with questions for chart.
|
|
16
|
+
*/
|
|
17
|
+
async function getChartBuildingBlockPrompts(context) {
|
|
18
|
+
const { project } = context;
|
|
19
|
+
const t = (0, i18n_1.translate)(i18n_1.i18nNamespaces.buildingBlock, 'prompts.chart.');
|
|
20
|
+
return {
|
|
21
|
+
questions: [
|
|
22
|
+
(0, utils_1.getViewOrFragmentPathPrompt)(context, t('viewOrFragmentPath.validate'), {
|
|
23
|
+
message: t('viewOrFragmentPath.message'),
|
|
24
|
+
guiOptions: {
|
|
25
|
+
mandatory: true,
|
|
26
|
+
dependantPromptNames: ['aggregationPath', 'buildingBlockData.filterBar']
|
|
27
|
+
}
|
|
28
|
+
}),
|
|
29
|
+
(0, utils_1.getBuildingBlockIdPrompt)(context, t('id.validation'), {
|
|
30
|
+
message: t('id.message'),
|
|
31
|
+
default: defaultAnswers.id,
|
|
32
|
+
guiOptions: {
|
|
33
|
+
mandatory: true
|
|
34
|
+
}
|
|
35
|
+
}),
|
|
36
|
+
(0, utils_1.getBindingContextTypePrompt)({
|
|
37
|
+
message: t('bindingContextType'),
|
|
38
|
+
default: defaultAnswers.bindingContextType,
|
|
39
|
+
guiOptions: {
|
|
40
|
+
mandatory: true,
|
|
41
|
+
dependantPromptNames: ['buildingBlockData.metaPath.qualifier']
|
|
42
|
+
}
|
|
43
|
+
}),
|
|
44
|
+
...(project && (0, utils_1.isCapProject)(project)
|
|
45
|
+
? [
|
|
46
|
+
await (0, utils_1.getCAPServicePrompt)(context, {
|
|
47
|
+
message: t('service'),
|
|
48
|
+
guiOptions: {
|
|
49
|
+
mandatory: true,
|
|
50
|
+
dependantPromptNames: []
|
|
51
|
+
}
|
|
52
|
+
})
|
|
53
|
+
]
|
|
54
|
+
: []),
|
|
55
|
+
(0, utils_1.getEntityPrompt)(context, {
|
|
56
|
+
message: t('entity'),
|
|
57
|
+
guiOptions: {
|
|
58
|
+
mandatory: true,
|
|
59
|
+
dependantPromptNames: ['buildingBlockData.metaPath.qualifier']
|
|
60
|
+
}
|
|
61
|
+
}),
|
|
62
|
+
(0, utils_1.getAnnotationPathQualifierPrompt)(context, {
|
|
63
|
+
message: t('qualifier'),
|
|
64
|
+
guiOptions: {
|
|
65
|
+
mandatory: true,
|
|
66
|
+
placeholder: t('qualifierPlaceholder'),
|
|
67
|
+
hint: t('valuesDependentOnEntityTypeInfo')
|
|
68
|
+
}
|
|
69
|
+
}, ["com.sap.vocabularies.UI.v1.Chart" /* UIAnnotationTerms.Chart */]),
|
|
70
|
+
(0, utils_1.getAggregationPathPrompt)(context, {
|
|
71
|
+
message: t('aggregation'),
|
|
72
|
+
guiOptions: {
|
|
73
|
+
mandatory: true
|
|
74
|
+
}
|
|
75
|
+
}),
|
|
76
|
+
(0, utils_1.getFilterBarIdPrompt)(context, {
|
|
77
|
+
message: t('filterBar.message'),
|
|
78
|
+
type: 'list',
|
|
79
|
+
guiOptions: {
|
|
80
|
+
placeholder: t('filterBar.placeholder'),
|
|
81
|
+
creation: { placeholder: t('filterBar.inputPlaceholder') }
|
|
82
|
+
}
|
|
83
|
+
}),
|
|
84
|
+
{
|
|
85
|
+
type: 'checkbox',
|
|
86
|
+
name: 'buildingBlockData.personalization',
|
|
87
|
+
message: t('personalization.message'),
|
|
88
|
+
choices: [
|
|
89
|
+
{ name: t('personalization.choices.type'), value: 'Type' },
|
|
90
|
+
{ name: t('personalization.choices.item'), value: 'Item' },
|
|
91
|
+
{ name: t('personalization.choices.sort'), value: 'Sort' }
|
|
92
|
+
],
|
|
93
|
+
guiOptions: {
|
|
94
|
+
placeholder: t('personalization.placeholder'),
|
|
95
|
+
selectType: 'static'
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
type: 'list',
|
|
100
|
+
name: 'buildingBlockData.selectionMode',
|
|
101
|
+
message: t('selectionMode.message'),
|
|
102
|
+
choices: [
|
|
103
|
+
{ name: t('selectionMode.choices.single'), value: 'Single' },
|
|
104
|
+
{ name: t('selectionMode.choices.multiple'), value: 'Multiple' }
|
|
105
|
+
],
|
|
106
|
+
guiOptions: {
|
|
107
|
+
selectType: 'static'
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
type: 'input',
|
|
112
|
+
name: 'buildingBlockData.selectionChange',
|
|
113
|
+
message: t('selectionChange'),
|
|
114
|
+
guiOptions: {
|
|
115
|
+
placeholder: t('selectionChangePlaceholder')
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
],
|
|
119
|
+
initialAnswers: {
|
|
120
|
+
buildingBlockData: {
|
|
121
|
+
buildingBlockType: types_1.BuildingBlockType.Chart
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
exports.getChartBuildingBlockPrompts = getChartBuildingBlockPrompts;
|
|
127
|
+
//# sourceMappingURL=chart.js.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Answers } from 'inquirer';
|
|
2
|
+
import type { Prompts, PromptContext } from '../../../prompts/types';
|
|
3
|
+
import type { BuildingBlockConfig, FilterBar } from '../../types';
|
|
4
|
+
export type FilterBarPromptsAnswer = BuildingBlockConfig<FilterBar> & Answers;
|
|
5
|
+
/**
|
|
6
|
+
* Returns a list of prompts required to generate a filterbar building block.
|
|
7
|
+
*
|
|
8
|
+
* @param context - prompt context including data about project
|
|
9
|
+
* @returns Prompt with questions for filterbar.
|
|
10
|
+
*/
|
|
11
|
+
export declare function getFilterBarBuildingBlockPrompts(context: PromptContext): Promise<Prompts<FilterBarPromptsAnswer>>;
|
|
12
|
+
//# sourceMappingURL=filter-bar.d.ts.map
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getFilterBarBuildingBlockPrompts = void 0;
|
|
4
|
+
const i18n_1 = require("../../../i18n");
|
|
5
|
+
const utils_1 = require("../utils");
|
|
6
|
+
const types_1 = require("../../types");
|
|
7
|
+
const defaultAnswers = {
|
|
8
|
+
id: 'FilterBar'
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Returns a list of prompts required to generate a filterbar building block.
|
|
12
|
+
*
|
|
13
|
+
* @param context - prompt context including data about project
|
|
14
|
+
* @returns Prompt with questions for filterbar.
|
|
15
|
+
*/
|
|
16
|
+
async function getFilterBarBuildingBlockPrompts(context) {
|
|
17
|
+
const { project } = context;
|
|
18
|
+
const t = (0, i18n_1.translate)(i18n_1.i18nNamespaces.buildingBlock, 'prompts.filterBar.');
|
|
19
|
+
return {
|
|
20
|
+
questions: [
|
|
21
|
+
(0, utils_1.getViewOrFragmentPathPrompt)(context, t('viewOrFragmentPath.validate'), {
|
|
22
|
+
message: t('viewOrFragmentPath.message'),
|
|
23
|
+
guiOptions: {
|
|
24
|
+
mandatory: true,
|
|
25
|
+
dependantPromptNames: ['aggregationPath']
|
|
26
|
+
}
|
|
27
|
+
}),
|
|
28
|
+
(0, utils_1.getBuildingBlockIdPrompt)(context, t('id.validation'), {
|
|
29
|
+
message: t('id.message'),
|
|
30
|
+
default: defaultAnswers.id,
|
|
31
|
+
guiOptions: {
|
|
32
|
+
mandatory: true
|
|
33
|
+
}
|
|
34
|
+
}),
|
|
35
|
+
...(project && (0, utils_1.isCapProject)(project)
|
|
36
|
+
? [
|
|
37
|
+
await (0, utils_1.getCAPServicePrompt)(context, {
|
|
38
|
+
message: t('service'),
|
|
39
|
+
guiOptions: {
|
|
40
|
+
mandatory: true,
|
|
41
|
+
dependantPromptNames: []
|
|
42
|
+
}
|
|
43
|
+
})
|
|
44
|
+
]
|
|
45
|
+
: []),
|
|
46
|
+
(0, utils_1.getAggregationPathPrompt)(context, {
|
|
47
|
+
message: t('aggregation'),
|
|
48
|
+
guiOptions: {
|
|
49
|
+
mandatory: true
|
|
50
|
+
}
|
|
51
|
+
}),
|
|
52
|
+
(0, utils_1.getEntityPrompt)(context, {
|
|
53
|
+
message: t('entity'),
|
|
54
|
+
guiOptions: {
|
|
55
|
+
mandatory: true,
|
|
56
|
+
dependantPromptNames: ['buildingBlockData.metaPath.qualifier']
|
|
57
|
+
}
|
|
58
|
+
}),
|
|
59
|
+
(0, utils_1.getAnnotationPathQualifierPrompt)(context, {
|
|
60
|
+
message: t('qualifier'),
|
|
61
|
+
guiOptions: {
|
|
62
|
+
mandatory: true,
|
|
63
|
+
placeholder: t('qualifierPlaceholder'),
|
|
64
|
+
hint: t('valuesDependentOnEntityTypeInfo')
|
|
65
|
+
}
|
|
66
|
+
}, ["com.sap.vocabularies.UI.v1.SelectionFields" /* UIAnnotationTerms.SelectionFields */]),
|
|
67
|
+
{
|
|
68
|
+
type: 'input',
|
|
69
|
+
name: 'buildingBlockData.filterChanged',
|
|
70
|
+
message: t('filterChanged')
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
type: 'input',
|
|
74
|
+
name: 'buildingBlockData.search',
|
|
75
|
+
message: t('search')
|
|
76
|
+
}
|
|
77
|
+
],
|
|
78
|
+
initialAnswers: {
|
|
79
|
+
buildingBlockData: {
|
|
80
|
+
buildingBlockType: types_1.BuildingBlockType.FilterBar
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
exports.getFilterBarBuildingBlockPrompts = getFilterBarBuildingBlockPrompts;
|
|
86
|
+
//# sourceMappingURL=filter-bar.js.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./building-blocks"), exports);
|
|
18
|
+
__exportStar(require("./chart"), exports);
|
|
19
|
+
__exportStar(require("./filter-bar"), exports);
|
|
20
|
+
__exportStar(require("./table"), exports);
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Answers } from 'inquirer';
|
|
2
|
+
import type { PromptContext, Prompts } from '../../../prompts/types';
|
|
3
|
+
import type { BuildingBlockConfig, Table } from '../../types';
|
|
4
|
+
export type TablePromptsAnswer = BuildingBlockConfig<Table> & Answers;
|
|
5
|
+
/**
|
|
6
|
+
* Returns a list of prompts required to generate a table building block.
|
|
7
|
+
*
|
|
8
|
+
* @param context - prompt context including data about project
|
|
9
|
+
* @returns Prompt with questions for table.
|
|
10
|
+
*/
|
|
11
|
+
export declare function getTableBuildingBlockPrompts(context: PromptContext): Promise<Prompts<TablePromptsAnswer>>;
|
|
12
|
+
//# sourceMappingURL=table.d.ts.map
|