@sap-ux/adp-tooling 0.12.134 → 0.12.136

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.
@@ -25,12 +25,11 @@ export declare function writeAnnotationChange(projectPath: string, timestamp: nu
25
25
  *
26
26
  * @param {string} projectPath - The root path of the project.
27
27
  * @param {ManifestChangeProperties} change - The change data to be written to the file.
28
- * @param {string} fileName - The name of the file to write the change data to.
29
28
  * @param {Editor} fs - The `mem-fs-editor` instance used for file operations.
30
29
  * @param {string} [dir] - An optional subdirectory within the 'changes' directory where the file will be written.
31
30
  * @returns {void}
32
31
  */
33
- export declare function writeChangeToFolder(projectPath: string, change: ManifestChangeProperties, fileName: string, fs: Editor, dir?: string): void;
32
+ export declare function writeChangeToFolder(projectPath: string, change: ManifestChangeProperties, fs: Editor, dir?: string): void;
34
33
  /**
35
34
  * Writes a given change object to a specific file path. The change data is stringified to JSON format before
36
35
  * writing. This function is used to directly write changes to a file, without specifying a directory.
@@ -14,6 +14,7 @@ exports.getChange = getChange;
14
14
  const path_1 = __importDefault(require("path"));
15
15
  const fs_1 = require("fs");
16
16
  const project_access_1 = require("@sap-ux/project-access");
17
+ const types_1 = require("../types");
17
18
  const ejs_1 = require("ejs");
18
19
  /**
19
20
  * Writes annotation changes to the specified project path using the provided `mem-fs-editor` instance.
@@ -30,9 +31,8 @@ function writeAnnotationChange(projectPath, timestamp, annotation, change, fs) {
30
31
  const changesFolderPath = path_1.default.join(projectPath, project_access_1.DirName.Webapp, project_access_1.DirName.Changes);
31
32
  const annotationsFolderPath = path_1.default.join(changesFolderPath, project_access_1.DirName.Annotations);
32
33
  if (change) {
33
- const changeFileName = `id_${timestamp}_addAnnotationsToOData.change`;
34
+ const changeFileName = `${change.fileName}.change`;
34
35
  const changeFilePath = path_1.default.join(changesFolderPath, changeFileName);
35
- change.fileName = `${change.fileName}_addAnnotationsToOData`;
36
36
  writeChangeToFile(changeFilePath, change, fs);
37
37
  }
38
38
  if (!annotation.filePath) {
@@ -63,17 +63,17 @@ function writeAnnotationChange(projectPath, timestamp, annotation, change, fs) {
63
63
  *
64
64
  * @param {string} projectPath - The root path of the project.
65
65
  * @param {ManifestChangeProperties} change - The change data to be written to the file.
66
- * @param {string} fileName - The name of the file to write the change data to.
67
66
  * @param {Editor} fs - The `mem-fs-editor` instance used for file operations.
68
67
  * @param {string} [dir] - An optional subdirectory within the 'changes' directory where the file will be written.
69
68
  * @returns {void}
70
69
  */
71
- function writeChangeToFolder(projectPath, change, fileName, fs, dir = '') {
70
+ function writeChangeToFolder(projectPath, change, fs, dir = '') {
72
71
  try {
73
72
  let targetFolderPath = path_1.default.join(projectPath, project_access_1.DirName.Webapp, project_access_1.DirName.Changes);
74
73
  if (dir) {
75
74
  targetFolderPath = path_1.default.join(targetFolderPath, dir);
76
75
  }
76
+ const fileName = `${change.fileName}.change`;
77
77
  const filePath = path_1.default.join(targetFolderPath, fileName);
78
78
  writeChangeToFile(filePath, change, fs);
79
79
  }
@@ -219,8 +219,13 @@ function findChangeWithInboundId(projectPath, inboundId) {
219
219
  * @returns - An object representing the change
220
220
  */
221
221
  function getChange({ id, layer, namespace }, timestamp, content, changeType) {
222
+ const changeName = types_1.ChangeTypeMap[changeType];
223
+ if (!changeName) {
224
+ throw new Error(`Could not extract the change name from the change type: ${changeType}`);
225
+ }
226
+ const fileName = `id_${timestamp}_${changeName}`;
222
227
  return {
223
- fileName: `id_${timestamp}`,
228
+ fileName,
224
229
  namespace: path_1.default.posix.join(namespace, project_access_1.DirName.Changes),
225
230
  layer,
226
231
  fileType: 'change',
package/dist/types.d.ts CHANGED
@@ -317,6 +317,10 @@ export declare const enum ChangeType {
317
317
  ADD_LIBRARY_REFERENCE = "appdescr_ui5_addLibraries",
318
318
  CHANGE_INBOUND = "appdescr_app_changeInbound"
319
319
  }
320
+ /**
321
+ * A mapping of ChangeType values to their respective change names.
322
+ */
323
+ export declare const ChangeTypeMap: Record<ChangeType, string>;
320
324
  /**
321
325
  * Maps a ChangeType to the corresponding data structure needed for that type of change.
322
326
  * This conditional type ensures type safety by linking each change type with its relevant data model.
package/dist/types.js CHANGED
@@ -1,3 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ChangeTypeMap = void 0;
4
+ /**
5
+ * A mapping of ChangeType values to their respective change names.
6
+ */
7
+ exports.ChangeTypeMap = {
8
+ ["appdescr_ui5_addNewModel" /* ChangeType.ADD_NEW_MODEL */]: 'addNewModel',
9
+ ["appdescr_app_addAnnotationsToOData" /* ChangeType.ADD_ANNOTATIONS_TO_ODATA */]: 'addAnnotationsToOData',
10
+ ["appdescr_app_changeDataSource" /* ChangeType.CHANGE_DATA_SOURCE */]: 'changeDataSource',
11
+ ["appdescr_ui5_addComponentUsages" /* ChangeType.ADD_COMPONENT_USAGES */]: 'addComponentUsages',
12
+ ["appdescr_ui5_addLibraries" /* ChangeType.ADD_LIBRARY_REFERENCE */]: 'addLibraries',
13
+ ["appdescr_app_changeInbound" /* ChangeType.CHANGE_INBOUND */]: 'changeInbound'
14
+ };
3
15
  //# sourceMappingURL=types.js.map
@@ -62,14 +62,14 @@ class ComponentUsagesWriter {
62
62
  const componentUsagesContent = this.constructContent(data);
63
63
  const timestamp = Date.now();
64
64
  const compUsagesChange = (0, change_utils_1.getChange)(data.variant, timestamp, componentUsagesContent, "appdescr_ui5_addComponentUsages" /* ChangeType.ADD_COMPONENT_USAGES */);
65
- (0, change_utils_1.writeChangeToFolder)(this.projectPath, compUsagesChange, `id_${timestamp}_addComponentUsages.change`, this.fs);
65
+ (0, change_utils_1.writeChangeToFolder)(this.projectPath, compUsagesChange, this.fs);
66
66
  if (!('library' in data)) {
67
67
  return;
68
68
  }
69
69
  const libRefContent = this.constructLibContent(data);
70
70
  const libTimestamp = timestamp + 1;
71
71
  const refLibChange = (0, change_utils_1.getChange)(data.variant, libTimestamp, libRefContent, "appdescr_ui5_addLibraries" /* ChangeType.ADD_LIBRARY_REFERENCE */);
72
- (0, change_utils_1.writeChangeToFolder)(this.projectPath, refLibChange, `id_${libTimestamp}_addLibraries.change`, this.fs);
72
+ (0, change_utils_1.writeChangeToFolder)(this.projectPath, refLibChange, this.fs);
73
73
  }
74
74
  }
75
75
  exports.ComponentUsagesWriter = ComponentUsagesWriter;
@@ -57,12 +57,12 @@ class DataSourceWriter {
57
57
  const timestamp = Date.now();
58
58
  const content = this.constructContent(id, uri, maxAge);
59
59
  const change = (0, change_utils_1.getChange)(variant, timestamp, content, "appdescr_app_changeDataSource" /* ChangeType.CHANGE_DATA_SOURCE */);
60
- (0, change_utils_1.writeChangeToFolder)(this.projectPath, change, `id_${timestamp}_changeDataSource.change`, this.fs);
60
+ (0, change_utils_1.writeChangeToFolder)(this.projectPath, change, this.fs);
61
61
  if (annotationId && annotationUri) {
62
62
  const annotationContent = this.constructContent(annotationId, annotationUri);
63
63
  const annotationTs = timestamp + 1;
64
64
  const annotationChange = (0, change_utils_1.getChange)(variant, annotationTs, annotationContent, "appdescr_app_changeDataSource" /* ChangeType.CHANGE_DATA_SOURCE */);
65
- (0, change_utils_1.writeChangeToFolder)(this.projectPath, annotationChange, `id_${annotationTs}_changeDataSource.change`, this.fs);
65
+ (0, change_utils_1.writeChangeToFolder)(this.projectPath, annotationChange, this.fs);
66
66
  }
67
67
  }
68
68
  }
@@ -73,7 +73,7 @@ class InboundWriter {
73
73
  if (!changeWithInboundId) {
74
74
  const content = this.constructContent(data);
75
75
  const change = (0, change_utils_1.getChange)(data.variant, timestamp, content, "appdescr_app_changeInbound" /* ChangeType.CHANGE_INBOUND */);
76
- (0, change_utils_1.writeChangeToFolder)(this.projectPath, change, `id_${timestamp}_changeInbound.change`, this.fs);
76
+ (0, change_utils_1.writeChangeToFolder)(this.projectPath, change, this.fs);
77
77
  }
78
78
  else {
79
79
  if (changeWithInboundId.content) {
@@ -66,7 +66,7 @@ class NewModelWriter {
66
66
  const timestamp = Date.now();
67
67
  const content = this.constructContent(data);
68
68
  const change = (0, change_utils_1.getChange)(data.variant, timestamp, content, "appdescr_ui5_addNewModel" /* ChangeType.ADD_NEW_MODEL */);
69
- (0, change_utils_1.writeChangeToFolder)(this.projectPath, change, `id_${timestamp}_addNewModel.change`, this.fs);
69
+ (0, change_utils_1.writeChangeToFolder)(this.projectPath, change, this.fs);
70
70
  }
71
71
  }
72
72
  exports.NewModelWriter = NewModelWriter;
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.12.134",
12
+ "version": "0.12.136",
13
13
  "license": "Apache-2.0",
14
14
  "author": "@SAP/ux-tools-team",
15
15
  "main": "dist/index.js",
@@ -40,7 +40,7 @@
40
40
  "@sap-ux/project-input-validator": "0.3.4",
41
41
  "@sap-ux/system-access": "0.5.31",
42
42
  "@sap-ux/ui5-config": "0.26.2",
43
- "@sap-ux/odata-service-writer": "0.26.2",
43
+ "@sap-ux/odata-service-writer": "0.26.3",
44
44
  "@sap-ux/i18n": "0.2.1"
45
45
  },
46
46
  "devDependencies": {