@sap-ux/fe-fpm-writer 0.24.8 → 0.24.9

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.
@@ -22,6 +22,25 @@ exports.contextParameter = {
22
22
  importType: 'Context',
23
23
  importSource: 'sap/ui/model/odata/v4/Context'
24
24
  };
25
+ /**
26
+ * Method returns file name to use in namespace.
27
+ *
28
+ * @param fileName - event handler file name
29
+ * @param controllerPrefix - controller prefix '.extension'
30
+ * @returns {string} file name part for namespace
31
+ */
32
+ function getFileName(fileName, controllerPrefix) {
33
+ let resolvedName;
34
+ // For name part in namespace we use passed file name or if it's controller extension, then remove 'controller' part from path
35
+ // 'Handler.controller' should be resolved as 'Handler' in namespace
36
+ if (controllerPrefix && fileName.endsWith('.controller')) {
37
+ resolvedName = fileName.replace('.controller', '');
38
+ }
39
+ else {
40
+ resolvedName = fileName;
41
+ }
42
+ return resolvedName;
43
+ }
25
44
  /**
26
45
  * Method creates or updates handler js file and update 'settings.eventHandler' entry with namespace path entry to method.
27
46
  *
@@ -43,7 +62,10 @@ function applyEventHandlerConfiguration(fs, config, eventHandler, eventHandlerOp
43
62
  let controllerPrefix = '';
44
63
  // By default - use config name for created file name
45
64
  let fileName = config.name;
65
+ // Name part used in namespace
66
+ let resolvedName = fileName;
46
67
  if (typeof eventHandler === 'object') {
68
+ controllerPrefix = eventHandler.controllerPrefix;
47
69
  if (eventHandler.fnName) {
48
70
  eventHandlerFnName = eventHandler.fnName;
49
71
  }
@@ -51,8 +73,8 @@ function applyEventHandlerConfiguration(fs, config, eventHandler, eventHandlerOp
51
73
  if (eventHandler.fileName) {
52
74
  // Use passed file name
53
75
  fileName = eventHandler.fileName;
76
+ resolvedName = getFileName(fileName, controllerPrefix);
54
77
  }
55
- controllerPrefix = eventHandler.controllerPrefix;
56
78
  }
57
79
  const ext = typescript ? 'ts' : 'js';
58
80
  const controllerPath = (0, path_1.join)(config.path || '', `${fileName}${controllerSuffix ? '.controller' : ''}.${ext}`);
@@ -73,7 +95,7 @@ function applyEventHandlerConfiguration(fs, config, eventHandler, eventHandlerOp
73
95
  fs.write(controllerPath, content);
74
96
  }
75
97
  // Return full namespace path to method
76
- const fullNamespace = `${config.ns}.${fileName}.${eventHandlerFnName}`;
98
+ const fullNamespace = `${config.ns}.${resolvedName}.${eventHandlerFnName}`;
77
99
  return controllerPrefix ? `${controllerPrefix}.${fullNamespace}` : `${fullNamespace}`;
78
100
  }
79
101
  exports.applyEventHandlerConfiguration = applyEventHandlerConfiguration;
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.24.8",
4
+ "version": "0.24.9",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/SAP/open-ux-tools.git",
@@ -33,7 +33,7 @@
33
33
  "@types/mem-fs": "1.1.2",
34
34
  "@types/mem-fs-editor": "7.0.1",
35
35
  "@types/semver": "7.5.2",
36
- "@sap-ux/project-access": "1.17.4"
36
+ "@sap-ux/project-access": "1.17.5"
37
37
  },
38
38
  "engines": {
39
39
  "node": ">=18.x"