@sap-ux/adp-tooling 0.18.72 → 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.addCustomSectionFragment)(this.util.getProject().getSourcePath(), change, fs, logger);
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 addCustomSectionFragment(basePath: string, change: AppDescriptorV4Change, fs: Editor, logger: Logger): void;
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.addCustomSectionFragment = addCustomSectionFragment;
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 addCustomSectionFragment(basePath, change, fs, logger) {
75
+ function addCustomFragment(basePath, change, fs, logger) {
39
76
  const propertyValue = change.content.entityPropertyChange.propertyValue;
40
- const isCustomSectionPropertyPath = change.content.entityPropertyChange.propertyPath.startsWith('content/body/sections/');
41
- if (isCustomSectionPropertyPath && hasTemplate(propertyValue)) {
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', exports.customFragmentConfig.path);
87
+ const fragmentTemplatePath = (0, node_path_1.join)(__dirname, '../../templates/rta', config.path);
51
88
  const text = fs.read(fragmentTemplatePath);
52
- const template = (0, ejs_1.render)(text, exports.customFragmentConfig.getData());
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.72",
12
+ "version": "0.18.75",
13
13
  "license": "Apache-2.0",
14
14
  "author": "@SAP/ux-tools-team",
15
15
  "main": "dist/index.js",
@@ -36,17 +36,17 @@
36
36
  "prompts": "2.4.2",
37
37
  "sanitize-filename": "1.6.3",
38
38
  "uuid": "10.0.0",
39
- "@sap-ux/axios-extension": "1.25.15",
39
+ "@sap-ux/axios-extension": "1.25.16",
40
40
  "@sap-ux/btp-utils": "1.1.9",
41
- "@sap-ux/i18n": "0.3.7",
42
- "@sap-ux/inquirer-common": "0.11.12",
41
+ "@sap-ux/i18n": "0.3.9",
42
+ "@sap-ux/inquirer-common": "0.11.14",
43
43
  "@sap-ux/logger": "0.8.1",
44
44
  "@sap-ux/nodejs-utils": "0.2.16",
45
- "@sap-ux/odata-service-writer": "0.29.24",
46
- "@sap-ux/project-access": "1.35.7",
47
- "@sap-ux/project-input-validator": "0.6.60",
45
+ "@sap-ux/odata-service-writer": "0.29.26",
46
+ "@sap-ux/project-access": "1.35.9",
47
+ "@sap-ux/project-input-validator": "0.6.62",
48
48
  "@sap-ux/store": "1.5.7",
49
- "@sap-ux/system-access": "0.6.56",
49
+ "@sap-ux/system-access": "0.6.57",
50
50
  "@sap-ux/ui5-config": "0.29.19",
51
51
  "@sap-ux/ui5-info": "0.13.13"
52
52
  },
@@ -67,7 +67,7 @@
67
67
  "express": "4.22.1",
68
68
  "nock": "13.4.0",
69
69
  "rimraf": "6.1.3",
70
- "supertest": "7.1.4",
70
+ "supertest": "7.2.2",
71
71
  "@sap-ux/store": "1.5.7"
72
72
  },
73
73
  "engines": {
@@ -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>