@sap-ux/adp-tooling 0.18.74 → 0.18.75
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.
|
@@ -234,7 +234,7 @@ class AdpPreview {
|
|
|
234
234
|
await (0, change_handler_1.addAnnotationFile)(this.util.getProject().getSourcePath(), this.util.getProject().getRootPath(), change, fs, logger, this.provider);
|
|
235
235
|
}
|
|
236
236
|
if ((0, change_handler_1.isV4DescriptorChange)(change)) {
|
|
237
|
-
(0, descriptor_change_handler_1.
|
|
237
|
+
(0, descriptor_change_handler_1.addCustomFragment)(this.util.getProject().getSourcePath(), change, fs, logger);
|
|
238
238
|
}
|
|
239
239
|
break;
|
|
240
240
|
default:
|
|
@@ -7,6 +7,12 @@ export declare const customFragmentConfig: {
|
|
|
7
7
|
ids: Record<string, string>;
|
|
8
8
|
};
|
|
9
9
|
};
|
|
10
|
+
export declare const customColumnFragmentConfig: {
|
|
11
|
+
path: string;
|
|
12
|
+
getData: () => {
|
|
13
|
+
ids: Record<string, string>;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
10
16
|
/**
|
|
11
17
|
* Checks if the given object has a 'template' property of type string.
|
|
12
18
|
*
|
|
@@ -24,5 +30,5 @@ export declare function hasTemplate(obj: unknown): obj is {
|
|
|
24
30
|
* @param fs - The mem-fs-editor instance for file operations.
|
|
25
31
|
* @param logger - The logger instance for logging information and errors.
|
|
26
32
|
*/
|
|
27
|
-
export declare function
|
|
33
|
+
export declare function addCustomFragment(basePath: string, change: AppDescriptorV4Change, fs: Editor, logger: Logger): void;
|
|
28
34
|
//# sourceMappingURL=descriptor-change-handler.d.ts.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.customFragmentConfig = void 0;
|
|
3
|
+
exports.customColumnFragmentConfig = exports.customFragmentConfig = void 0;
|
|
4
4
|
exports.hasTemplate = hasTemplate;
|
|
5
|
-
exports.
|
|
5
|
+
exports.addCustomFragment = addCustomFragment;
|
|
6
6
|
const node_path_1 = require("node:path");
|
|
7
7
|
const utils_1 = require("./utils");
|
|
8
8
|
const node_crypto_1 = require("node:crypto");
|
|
@@ -18,6 +18,17 @@ exports.customFragmentConfig = {
|
|
|
18
18
|
};
|
|
19
19
|
}
|
|
20
20
|
};
|
|
21
|
+
exports.customColumnFragmentConfig = {
|
|
22
|
+
path: 'v4/mdc-custom-column-config.xml',
|
|
23
|
+
getData: () => {
|
|
24
|
+
const uuid = (0, node_crypto_1.randomBytes)(4).toString('hex');
|
|
25
|
+
return {
|
|
26
|
+
ids: {
|
|
27
|
+
text: `text-${uuid}`
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
};
|
|
21
32
|
/**
|
|
22
33
|
* Checks if the given object has a 'template' property of type string.
|
|
23
34
|
*
|
|
@@ -27,6 +38,32 @@ exports.customFragmentConfig = {
|
|
|
27
38
|
function hasTemplate(obj) {
|
|
28
39
|
return typeof obj === 'object' && obj !== null && 'template' in obj && typeof obj.template === 'string';
|
|
29
40
|
}
|
|
41
|
+
/**
|
|
42
|
+
* Gets config based on change property path.
|
|
43
|
+
*
|
|
44
|
+
* @param change - The AppDescriptorV4Change object containing change details.
|
|
45
|
+
* @returns The configuration object or undefined if no matching config is found.
|
|
46
|
+
*/
|
|
47
|
+
function getConfig(change) {
|
|
48
|
+
const propertyPath = change.content.entityPropertyChange.propertyPath;
|
|
49
|
+
const isCustomSectionPropertyPath = propertyPath.startsWith('content/body/sections/');
|
|
50
|
+
// Pattern matches:
|
|
51
|
+
// - controlConfiguration/@com.sap.vocabularies.UI.v1.LineItem/columns/columnId
|
|
52
|
+
// - controlConfiguration/@com.sap.vocabularies.UI.v1.LineItem#qualifier/columns/columnId
|
|
53
|
+
// - controlConfiguration/navigationPath/@com.sap.vocabularies.UI.v1.LineItem/columns/columnId
|
|
54
|
+
// - controlConfiguration/navigationPath/@com.sap.vocabularies.UI.v1.LineItem#qualifier/columns/columnId
|
|
55
|
+
// Safe: propertyPath comes from AppDescriptorV4Change which is validated manifest content.
|
|
56
|
+
// The pattern is bounded: fixed prefix "controlConfiguration/", optional navigation segment,
|
|
57
|
+
// annotation term, optional qualifier, "/columns/", and column ID - no nested quantifiers.
|
|
58
|
+
const isCustomColumnPropertyPath = /^controlConfiguration\/(?:[^/@]+\/)?@[^/]+\.LineItem(?:#[^/]+)?\/columns\/[^/]+$/.test(propertyPath);
|
|
59
|
+
if (isCustomSectionPropertyPath) {
|
|
60
|
+
return exports.customFragmentConfig;
|
|
61
|
+
}
|
|
62
|
+
else if (isCustomColumnPropertyPath) {
|
|
63
|
+
return exports.customColumnFragmentConfig;
|
|
64
|
+
}
|
|
65
|
+
return undefined;
|
|
66
|
+
}
|
|
30
67
|
/**
|
|
31
68
|
* Adds a custom XML fragment file based on the provided AppDescriptorV4Change and template configuration.
|
|
32
69
|
*
|
|
@@ -35,10 +72,10 @@ function hasTemplate(obj) {
|
|
|
35
72
|
* @param fs - The mem-fs-editor instance for file operations.
|
|
36
73
|
* @param logger - The logger instance for logging information and errors.
|
|
37
74
|
*/
|
|
38
|
-
function
|
|
75
|
+
function addCustomFragment(basePath, change, fs, logger) {
|
|
39
76
|
const propertyValue = change.content.entityPropertyChange.propertyValue;
|
|
40
|
-
const
|
|
41
|
-
if (
|
|
77
|
+
const config = getConfig(change);
|
|
78
|
+
if (hasTemplate(propertyValue) && config) {
|
|
42
79
|
const { template } = propertyValue;
|
|
43
80
|
const path = (0, utils_1.getFragmentPathFromTemplate)(template, change);
|
|
44
81
|
try {
|
|
@@ -47,9 +84,17 @@ function addCustomSectionFragment(basePath, change, fs, logger) {
|
|
|
47
84
|
}
|
|
48
85
|
const fragmentPath = `${path}.fragment.xml`;
|
|
49
86
|
const fullPath = (0, node_path_1.join)(basePath, fragmentPath);
|
|
50
|
-
const fragmentTemplatePath = (0, node_path_1.join)(__dirname, '../../templates/rta',
|
|
87
|
+
const fragmentTemplatePath = (0, node_path_1.join)(__dirname, '../../templates/rta', config.path);
|
|
51
88
|
const text = fs.read(fragmentTemplatePath);
|
|
52
|
-
|
|
89
|
+
// Safe: Template files are from our own codebase (templates/rta/), config.path is from getConfig()
|
|
90
|
+
// which only returns predefined paths (customFragmentConfig or customColumnFragmentConfig).
|
|
91
|
+
// Template data comes from controlled config.getData() which only generates UUIDs for IDs.
|
|
92
|
+
const template = (0, ejs_1.render)(text, {
|
|
93
|
+
viewName: undefined,
|
|
94
|
+
controlType: undefined,
|
|
95
|
+
targetAggregation: undefined,
|
|
96
|
+
...config.getData()
|
|
97
|
+
});
|
|
53
98
|
fs.write(fullPath, template);
|
|
54
99
|
logger.info(`XML Fragment "${fragmentPath}" was created`);
|
|
55
100
|
}
|
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"bugs": {
|
|
10
10
|
"url": "https://github.com/SAP/open-ux-tools/issues?q=is%3Aopen+is%3Aissue+label%3Abug+label%3Aadp-tooling"
|
|
11
11
|
},
|
|
12
|
-
"version": "0.18.
|
|
12
|
+
"version": "0.18.75",
|
|
13
13
|
"license": "Apache-2.0",
|
|
14
14
|
"author": "@SAP/ux-tools-team",
|
|
15
15
|
"main": "dist/index.js",
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
<core:FragmentDefinition xmlns:core="sap.ui.core" xmlns="sap.m" xmlns:table="sap.ui.mdc.table"><% if (targetAggregation && controlType && viewName) { %>
|
|
2
|
+
<!-- viewName: <%= viewName %> -->
|
|
3
|
+
<!-- controlType: <%= controlType %> -->
|
|
4
|
+
<!-- targetAggregation: <%= targetAggregation %> --> <% } %>
|
|
5
|
+
<Text id="<%- ids.text %>" text="Sample data"/>
|
|
6
|
+
</core:FragmentDefinition>
|