@sap-ux/fe-fpm-writer 0.27.1 → 0.27.3
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.js +45 -10
- package/package.json +3 -3
|
@@ -31,12 +31,13 @@ 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");
|
|
33
33
|
const path_1 = require("path");
|
|
34
|
+
const types_1 = require("./types");
|
|
34
35
|
const xmldom_1 = require("@xmldom/xmldom");
|
|
35
36
|
const xpath = __importStar(require("xpath"));
|
|
36
37
|
const xml_formatter_1 = __importDefault(require("xml-formatter"));
|
|
37
38
|
const validate_1 = require("../common/validate");
|
|
38
39
|
const templates_1 = require("../templates");
|
|
39
|
-
const
|
|
40
|
+
const types_2 = require("../prompts/types");
|
|
40
41
|
const PLACEHOLDERS = {
|
|
41
42
|
'id': 'REPLACE_WITH_BUILDING_BLOCK_ID',
|
|
42
43
|
'entitySet': 'REPLACE_WITH_ENTITY',
|
|
@@ -111,22 +112,53 @@ function getOrAddMacrosNamespace(ui5XmlDocument) {
|
|
|
111
112
|
return macrosNamespaceEntry ? macrosNamespaceEntry[0] : 'macros';
|
|
112
113
|
}
|
|
113
114
|
/**
|
|
114
|
-
* Method
|
|
115
|
+
* Method returns default values for metadata path.
|
|
115
116
|
*
|
|
117
|
+
* @param {BuildingBlockType} type - building vlock type.
|
|
118
|
+
* @param {boolean} usePlaceholders - apply placeholder values if value for attribute/property is not provided
|
|
119
|
+
* @returns {MetadataPath} Default values for metadata path.
|
|
120
|
+
*/
|
|
121
|
+
function getDefaultMetaPath(type, usePlaceholders) {
|
|
122
|
+
if (type === types_1.BuildingBlockType.Chart) {
|
|
123
|
+
return {
|
|
124
|
+
metaPath: usePlaceholders ? `/${PLACEHOLDERS.qualifier}` : '',
|
|
125
|
+
contextPath: usePlaceholders ? PLACEHOLDERS.entitySet : ''
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
return {
|
|
129
|
+
metaPath: usePlaceholders ? `/${PLACEHOLDERS.entitySet}/${PLACEHOLDERS.qualifier}` : ''
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Method converts object based metaPath to metadata path.
|
|
134
|
+
*
|
|
135
|
+
* @param {BuildingBlockType} type - building vlock type.
|
|
116
136
|
* @param {BuildingBlockMetaPath} metaPath - object based metaPath.
|
|
117
137
|
* @param {boolean} usePlaceholders - apply placeholder values if value for attribute/property is not provided
|
|
118
|
-
* @returns {
|
|
138
|
+
* @returns {MetadataPath} Resolved metadata path information.
|
|
119
139
|
*/
|
|
120
|
-
function getMetaPath(metaPath, usePlaceholders) {
|
|
140
|
+
function getMetaPath(type, metaPath, usePlaceholders) {
|
|
121
141
|
if (!metaPath) {
|
|
122
|
-
return usePlaceholders
|
|
142
|
+
return getDefaultMetaPath(type, usePlaceholders);
|
|
123
143
|
}
|
|
124
|
-
const { entitySet,
|
|
144
|
+
const { entitySet, bindingContextType = 'absolute' } = metaPath;
|
|
145
|
+
let { qualifier } = metaPath;
|
|
125
146
|
let entityPath = entitySet || (usePlaceholders ? PLACEHOLDERS.entitySet : '');
|
|
126
147
|
const lastIndex = entityPath.lastIndexOf('.');
|
|
127
148
|
entityPath = lastIndex >= 0 ? entityPath.substring?.(lastIndex + 1) : entityPath;
|
|
128
149
|
const qualifierOrPlaceholder = qualifier || (usePlaceholders ? PLACEHOLDERS.qualifier : '');
|
|
129
|
-
|
|
150
|
+
if (type === types_1.BuildingBlockType.Chart) {
|
|
151
|
+
// Special handling for chart - while runtime does not support approach without contextPath
|
|
152
|
+
const qualifierParts = qualifierOrPlaceholder.split('/');
|
|
153
|
+
qualifier = qualifierParts.pop();
|
|
154
|
+
return {
|
|
155
|
+
metaPath: qualifier,
|
|
156
|
+
contextPath: qualifierParts.length ? `/${entityPath}/${qualifierParts.join('/')}` : `/${entityPath}`
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
return {
|
|
160
|
+
metaPath: bindingContextType === 'absolute' ? `/${entityPath}/${qualifierOrPlaceholder}` : qualifierOrPlaceholder
|
|
161
|
+
};
|
|
130
162
|
}
|
|
131
163
|
/**
|
|
132
164
|
* Returns the content of the xml file document.
|
|
@@ -142,8 +174,11 @@ function getTemplateContent(buildingBlockData, viewDocument, fs, usePlaceholders
|
|
|
142
174
|
const templateFilePath = (0, templates_1.getTemplatePath)(`/building-block/${templateFolderName}/View.xml`);
|
|
143
175
|
if (typeof buildingBlockData.metaPath === 'object' || buildingBlockData.metaPath === undefined) {
|
|
144
176
|
// Convert object based metapath to string
|
|
145
|
-
const
|
|
146
|
-
buildingBlockData = { ...buildingBlockData, metaPath };
|
|
177
|
+
const metadataPath = getMetaPath(buildingBlockData.buildingBlockType, buildingBlockData.metaPath, usePlaceholders);
|
|
178
|
+
buildingBlockData = { ...buildingBlockData, metaPath: metadataPath.metaPath };
|
|
179
|
+
if (!buildingBlockData.contextPath && metadataPath.contextPath) {
|
|
180
|
+
buildingBlockData.contextPath = metadataPath.contextPath;
|
|
181
|
+
}
|
|
147
182
|
}
|
|
148
183
|
// Apply placeholders
|
|
149
184
|
if (!buildingBlockData.id) {
|
|
@@ -247,7 +282,7 @@ function getSerializedFileContent(basePath, config, fs) {
|
|
|
247
282
|
return {
|
|
248
283
|
viewOrFragmentPath: {
|
|
249
284
|
content,
|
|
250
|
-
language:
|
|
285
|
+
language: types_2.CodeSnippetLanguage.XML,
|
|
251
286
|
filePathProps
|
|
252
287
|
}
|
|
253
288
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sap-ux/fe-fpm-writer",
|
|
3
3
|
"description": "SAP Fiori elements flexible programming model writer",
|
|
4
|
-
"version": "0.27.
|
|
4
|
+
"version": "0.27.3",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/SAP/open-ux-tools.git",
|
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
"semver": "7.5.4",
|
|
32
32
|
"xml-formatter": "2.6.1",
|
|
33
33
|
"xpath": "0.0.33",
|
|
34
|
-
"@sap-ux/fiori-annotation-api": "0.1.
|
|
35
|
-
"@sap-ux/project-access": "1.26.
|
|
34
|
+
"@sap-ux/fiori-annotation-api": "0.1.36",
|
|
35
|
+
"@sap-ux/project-access": "1.26.7"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@types/inquirer": "8.2.6",
|