@sap-ux/adp-tooling 0.8.11 → 0.9.1

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.
@@ -0,0 +1,90 @@
1
+ import type { Editor } from 'mem-fs-editor';
2
+ import type { AdpProjectData, AnnotationsData, ChangeType, InboundContent, ManifestChangeProperties, PropertyValueType } from '../types';
3
+ type InboundChangeData = {
4
+ filePath: string;
5
+ changeWithInboundId: InboundChange | undefined;
6
+ };
7
+ interface InboundChange extends ManifestChangeProperties {
8
+ content: InboundContent;
9
+ }
10
+ /**
11
+ * Writes annotation changes to the specified project path using the provided `mem-fs-editor` instance.
12
+ *
13
+ * @param {string} projectPath - The root path of the project.
14
+ * @param {AnnotationsData} data - The data object containing information about the annotation change.
15
+ * @param {ManifestChangeProperties} change - The annotation data change that will be written.
16
+ * @param {Editor} fs - The `mem-fs-editor` instance used for file operations.
17
+ * @returns {void}
18
+ */
19
+ export declare function writeAnnotationChange(projectPath: string, data: AnnotationsData, change: ManifestChangeProperties, fs: Editor): void;
20
+ /**
21
+ * Writes a given change object to a file within a specified folder in the project's 'changes' directory.
22
+ * If an additional subdirectory is specified, the change file is written there.
23
+ *
24
+ * @param {string} projectPath - The root path of the project.
25
+ * @param {ManifestChangeProperties} change - The change data to be written to the file.
26
+ * @param {string} fileName - The name of the file to write the change data to.
27
+ * @param {Editor} fs - The `mem-fs-editor` instance used for file operations.
28
+ * @param {string} [dir] - An optional subdirectory within the 'changes' directory where the file will be written.
29
+ * @returns {void}
30
+ */
31
+ export declare function writeChangeToFolder(projectPath: string, change: ManifestChangeProperties, fileName: string, fs: Editor, dir?: string): void;
32
+ /**
33
+ * Writes a given change object to a specific file path. The change data is stringified to JSON format before
34
+ * writing. This function is used to directly write changes to a file, without specifying a directory.
35
+ *
36
+ * @param {string} path - The root path of the project.
37
+ * @param {ManifestChangeProperties} change - The change data to be written to the file.
38
+ * @param {Editor} fs - The `mem-fs-editor` instance used for file operations.
39
+ */
40
+ export declare function writeChangeToFile(path: string, change: ManifestChangeProperties, fs: Editor): void;
41
+ /**
42
+ * Parses a string into an object.
43
+ *
44
+ * @param {string} str - The string to be parsed into an object. The string should be in the format of object properties without the surrounding braces.
45
+ * @returns {{ [key: string]: string }} An object constructed from the input string.
46
+ * @example
47
+ * // returns { name: "value" }
48
+ * parseStringToObject('"name":"value"');
49
+ */
50
+ export declare function parseStringToObject(str: string): {
51
+ [key: string]: string;
52
+ };
53
+ /**
54
+ * Attempts to parse a property value as JSON.
55
+ *
56
+ * @param {string} propertyValue - The property value to be parsed.
57
+ * @returns {PropertyValueType} The parsed value if `propertyValue` is valid JSON; otherwise, returns the original `propertyValue`.
58
+ * @example
59
+ * // Returns the object { key: "value" }
60
+ * getParsedPropertyValue('{"key": "value"}');
61
+ *
62
+ * // Returns the string "nonJSONValue" because it cannot be parsed as JSON
63
+ * getParsedPropertyValue('nonJSONValue');
64
+ */
65
+ export declare function getParsedPropertyValue(propertyValue: PropertyValueType): PropertyValueType;
66
+ /**
67
+ * Searches for a change file with a specific inbound ID within a project's change directory.
68
+ *
69
+ * @param {string} projectPath - The root path of the project.
70
+ * @param {string} inboundId - The inbound ID to search for within change files.
71
+ * @returns {InboundChangeData} An object containing the file path and the change object with the matching inbound ID.
72
+ * @throws {Error} Throws an error if the change file cannot be read or if there's an issue accessing the directory.
73
+ */
74
+ export declare function findChangeWithInboundId(projectPath: string, inboundId: string): InboundChangeData;
75
+ /**
76
+ * Constructs a generic change object based on provided parameters.
77
+ *
78
+ * @param data - The base data associated with the change, including project data and timestamp.
79
+ * @param data.projectData - The project specific data.
80
+ * @param data.timestamp - The timestamp.
81
+ * @param {object} content - The content of the change to be applied.
82
+ * @param {ChangeType} changeType - The type of the change.
83
+ * @returns An object representing the change.
84
+ */
85
+ export declare function getGenericChange(data: {
86
+ projectData: AdpProjectData;
87
+ timestamp: number;
88
+ }, content: object, changeType: ChangeType): ManifestChangeProperties;
89
+ export {};
90
+ //# sourceMappingURL=change-utils.d.ts.map
@@ -0,0 +1,186 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getGenericChange = exports.findChangeWithInboundId = exports.getParsedPropertyValue = exports.parseStringToObject = exports.writeChangeToFile = exports.writeChangeToFolder = exports.writeAnnotationChange = void 0;
7
+ const path_1 = __importDefault(require("path"));
8
+ const fs_1 = require("fs");
9
+ /**
10
+ * Writes annotation changes to the specified project path using the provided `mem-fs-editor` instance.
11
+ *
12
+ * @param {string} projectPath - The root path of the project.
13
+ * @param {AnnotationsData} data - The data object containing information about the annotation change.
14
+ * @param {ManifestChangeProperties} change - The annotation data change that will be written.
15
+ * @param {Editor} fs - The `mem-fs-editor` instance used for file operations.
16
+ * @returns {void}
17
+ */
18
+ function writeAnnotationChange(projectPath, data, change, fs) {
19
+ var _a;
20
+ try {
21
+ const { timestamp, annotation } = data;
22
+ const changeFileName = `id_${timestamp}_addAnnotationsToOData.change`;
23
+ const changesFolderPath = path_1.default.join(projectPath, "webapp" /* FolderTypes.WEBAPP */, "changes" /* FolderTypes.CHANGES */);
24
+ const changeFilePath = path_1.default.join(changesFolderPath, "manifest" /* FolderTypes.MANIFEST */, changeFileName);
25
+ const annotationsFolderPath = path_1.default.join(changesFolderPath, "annotations" /* FolderTypes.ANNOTATIONS */);
26
+ writeChangeToFile(changeFilePath, change, fs);
27
+ if (!annotation.filePath) {
28
+ fs.write(path_1.default.join(annotationsFolderPath, (_a = annotation.fileName) !== null && _a !== void 0 ? _a : ''), '');
29
+ }
30
+ else {
31
+ const { filePath, fileName } = annotation;
32
+ const selectedDir = path_1.default.dirname(filePath);
33
+ if (selectedDir !== annotationsFolderPath) {
34
+ fs.copy(filePath, path_1.default.join(annotationsFolderPath, fileName !== null && fileName !== void 0 ? fileName : ''));
35
+ }
36
+ }
37
+ }
38
+ catch (e) {
39
+ throw new Error(`Could not write annotation changes. Reason: ${e.message}`);
40
+ }
41
+ }
42
+ exports.writeAnnotationChange = writeAnnotationChange;
43
+ /**
44
+ * Writes a given change object to a file within a specified folder in the project's 'changes' directory.
45
+ * If an additional subdirectory is specified, the change file is written there.
46
+ *
47
+ * @param {string} projectPath - The root path of the project.
48
+ * @param {ManifestChangeProperties} change - The change data to be written to the file.
49
+ * @param {string} fileName - The name of the file to write the change data to.
50
+ * @param {Editor} fs - The `mem-fs-editor` instance used for file operations.
51
+ * @param {string} [dir] - An optional subdirectory within the 'changes' directory where the file will be written.
52
+ * @returns {void}
53
+ */
54
+ function writeChangeToFolder(projectPath, change, fileName, fs, dir = '') {
55
+ try {
56
+ let targetFolderPath = path_1.default.join(projectPath, "webapp" /* FolderTypes.WEBAPP */, "changes" /* FolderTypes.CHANGES */);
57
+ if (dir) {
58
+ targetFolderPath = path_1.default.join(targetFolderPath, dir);
59
+ }
60
+ const filePath = path_1.default.join(targetFolderPath, fileName);
61
+ writeChangeToFile(filePath, change, fs);
62
+ }
63
+ catch (e) {
64
+ throw new Error(`Could not write change to folder. Reason: ${e.message}`);
65
+ }
66
+ }
67
+ exports.writeChangeToFolder = writeChangeToFolder;
68
+ /**
69
+ * Writes a given change object to a specific file path. The change data is stringified to JSON format before
70
+ * writing. This function is used to directly write changes to a file, without specifying a directory.
71
+ *
72
+ * @param {string} path - The root path of the project.
73
+ * @param {ManifestChangeProperties} change - The change data to be written to the file.
74
+ * @param {Editor} fs - The `mem-fs-editor` instance used for file operations.
75
+ */
76
+ function writeChangeToFile(path, change, fs) {
77
+ try {
78
+ fs.writeJSON(path, change);
79
+ }
80
+ catch (e) {
81
+ throw new Error(`Could not write change to file: ${path}. Reason: ${e.message}`);
82
+ }
83
+ }
84
+ exports.writeChangeToFile = writeChangeToFile;
85
+ /**
86
+ * Parses a string into an object.
87
+ *
88
+ * @param {string} str - The string to be parsed into an object. The string should be in the format of object properties without the surrounding braces.
89
+ * @returns {{ [key: string]: string }} An object constructed from the input string.
90
+ * @example
91
+ * // returns { name: "value" }
92
+ * parseStringToObject('"name":"value"');
93
+ */
94
+ function parseStringToObject(str) {
95
+ return JSON.parse(`{${str}}`);
96
+ }
97
+ exports.parseStringToObject = parseStringToObject;
98
+ /**
99
+ * Attempts to parse a property value as JSON.
100
+ *
101
+ * @param {string} propertyValue - The property value to be parsed.
102
+ * @returns {PropertyValueType} The parsed value if `propertyValue` is valid JSON; otherwise, returns the original `propertyValue`.
103
+ * @example
104
+ * // Returns the object { key: "value" }
105
+ * getParsedPropertyValue('{"key": "value"}');
106
+ *
107
+ * // Returns the string "nonJSONValue" because it cannot be parsed as JSON
108
+ * getParsedPropertyValue('nonJSONValue');
109
+ */
110
+ function getParsedPropertyValue(propertyValue) {
111
+ try {
112
+ const value = JSON.parse(propertyValue);
113
+ return value;
114
+ }
115
+ catch (e) {
116
+ return propertyValue;
117
+ }
118
+ }
119
+ exports.getParsedPropertyValue = getParsedPropertyValue;
120
+ /**
121
+ * Searches for a change file with a specific inbound ID within a project's change directory.
122
+ *
123
+ * @param {string} projectPath - The root path of the project.
124
+ * @param {string} inboundId - The inbound ID to search for within change files.
125
+ * @returns {InboundChangeData} An object containing the file path and the change object with the matching inbound ID.
126
+ * @throws {Error} Throws an error if the change file cannot be read or if there's an issue accessing the directory.
127
+ */
128
+ function findChangeWithInboundId(projectPath, inboundId) {
129
+ var _a;
130
+ let changeObj;
131
+ let filePath = '';
132
+ const pathToInboundChangeFiles = path_1.default.join(projectPath, "webapp" /* FolderTypes.WEBAPP */, "changes" /* FolderTypes.CHANGES */, "manifest" /* FolderTypes.MANIFEST */);
133
+ if (!(0, fs_1.existsSync)(pathToInboundChangeFiles)) {
134
+ return {
135
+ filePath,
136
+ changeWithInboundId: changeObj
137
+ };
138
+ }
139
+ try {
140
+ const file = (0, fs_1.readdirSync)(pathToInboundChangeFiles, { withFileTypes: true }).find((dirent) => dirent.isFile() && dirent.name.includes('changeInbound'));
141
+ if (file) {
142
+ const pathToFile = path_1.default.join(pathToInboundChangeFiles, file.name);
143
+ const change = JSON.parse((0, fs_1.readFileSync)(pathToFile, 'utf-8'));
144
+ if (((_a = change.content) === null || _a === void 0 ? void 0 : _a.inboundId) === inboundId) {
145
+ changeObj = change;
146
+ filePath = pathToFile;
147
+ }
148
+ }
149
+ return {
150
+ filePath,
151
+ changeWithInboundId: changeObj
152
+ };
153
+ }
154
+ catch (e) {
155
+ throw new Error(`Could not find change with inbound id '${inboundId}'. Reason: ${e.message}`);
156
+ }
157
+ }
158
+ exports.findChangeWithInboundId = findChangeWithInboundId;
159
+ /**
160
+ * Constructs a generic change object based on provided parameters.
161
+ *
162
+ * @param data - The base data associated with the change, including project data and timestamp.
163
+ * @param data.projectData - The project specific data.
164
+ * @param data.timestamp - The timestamp.
165
+ * @param {object} content - The content of the change to be applied.
166
+ * @param {ChangeType} changeType - The type of the change.
167
+ * @returns An object representing the change.
168
+ */
169
+ function getGenericChange(data, content, changeType) {
170
+ const { projectData, timestamp } = data;
171
+ const fileName = `id_${timestamp}`;
172
+ return {
173
+ fileName,
174
+ namespace: path_1.default.posix.join(projectData.namespace, "changes" /* FolderTypes.CHANGES */),
175
+ layer: projectData.layer,
176
+ fileType: 'change',
177
+ creation: new Date(timestamp).toISOString(),
178
+ packageName: '$TMP',
179
+ reference: projectData.id,
180
+ support: { generator: '@sap-ux/adp-tooling' },
181
+ changeType,
182
+ content
183
+ };
184
+ }
185
+ exports.getGenericChange = getGenericChange;
186
+ //# sourceMappingURL=change-utils.js.map
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
- export { AdpPreviewConfig, AdpWriterConfig } from './types';
1
+ export * from './types';
2
2
  export * from './preview/adp-preview';
3
3
  export { generate } from './writer';
4
+ export { generateChange } from './writer/editors';
4
5
  export { promptGeneratorInput, PromptDefaults } from './base/prompt';
5
6
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -14,10 +14,13 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.promptGeneratorInput = exports.generate = void 0;
17
+ exports.promptGeneratorInput = exports.generateChange = exports.generate = void 0;
18
+ __exportStar(require("./types"), exports);
18
19
  __exportStar(require("./preview/adp-preview"), exports);
19
20
  var writer_1 = require("./writer");
20
21
  Object.defineProperty(exports, "generate", { enumerable: true, get: function () { return writer_1.generate; } });
22
+ var editors_1 = require("./writer/editors");
23
+ Object.defineProperty(exports, "generateChange", { enumerable: true, get: function () { return editors_1.generateChange; } });
21
24
  var prompt_1 = require("./base/prompt");
22
25
  Object.defineProperty(exports, "promptGeneratorInput", { enumerable: true, get: function () { return prompt_1.promptGeneratorInput; } });
23
26
  //# sourceMappingURL=index.js.map
@@ -95,7 +95,7 @@ class RoutesHandler {
95
95
  this.logger.debug('Bad request. Fragment name was not provided!');
96
96
  return;
97
97
  }
98
- const fullPath = path.join(sourcePath, "changes" /* FolderNames.Changes */, "fragments" /* FolderNames.Fragments */);
98
+ const fullPath = path.join(sourcePath, "changes" /* FolderTypes.CHANGES */, "fragments" /* FolderTypes.FRAGMENTS */);
99
99
  const filePath = path.join(fullPath, `${fragmentName}.fragment.xml`);
100
100
  if (!fs.existsSync(fullPath)) {
101
101
  fs.mkdirSync(fullPath, { recursive: true });
@@ -161,7 +161,7 @@ class RoutesHandler {
161
161
  const project = this.util.getProject();
162
162
  const sourcePath = project.getSourcePath();
163
163
  const projectName = project.getName();
164
- const getPath = (projectPath, fileName, folder = "coding" /* FolderNames.Coding */) => path.join(projectPath, "changes" /* FolderNames.Changes */, folder, fileName).split(path.sep).join(path.posix.sep);
164
+ const getPath = (projectPath, fileName, folder = "coding" /* FolderTypes.CODING */) => path.join(projectPath, "changes" /* FolderTypes.CHANGES */, folder, fileName).split(path.sep).join(path.posix.sep);
165
165
  for (const file of codeExtFiles) {
166
166
  const fileStr = yield file.getString();
167
167
  const change = JSON.parse(fileStr);
@@ -211,7 +211,7 @@ class RoutesHandler {
211
211
  this.logger.debug('Bad request. Controller extension name was not provided!');
212
212
  return;
213
213
  }
214
- const fullPath = path.join(sourcePath, "changes" /* FolderNames.Changes */, "coding" /* FolderNames.Coding */);
214
+ const fullPath = path.join(sourcePath, "changes" /* FolderTypes.CHANGES */, "coding" /* FolderTypes.CODING */);
215
215
  const filePath = path.join(fullPath, `${controllerExtName}.js`);
216
216
  if (!fs.existsSync(fullPath)) {
217
217
  fs.mkdirSync(fullPath, { recursive: true });
package/dist/types.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import type { UI5FlexLayer } from '@sap-ux/project-access';
2
2
  import type { DestinationAbapTarget, UrlAbapTarget } from '@sap-ux/system-access';
3
3
  import type { Adp } from '@sap-ux/ui5-config';
4
+ import type { Editor } from 'mem-fs-editor';
4
5
  export interface DescriptorVariant {
5
6
  layer: UI5FlexLayer;
6
7
  reference: string;
@@ -77,6 +78,20 @@ interface CommonChangeProperties {
77
78
  fileName: string;
78
79
  texts: Record<string, unknown>;
79
80
  }
81
+ export interface ManifestChangeProperties {
82
+ fileName: string;
83
+ fileType: string;
84
+ namespace: string;
85
+ layer: string;
86
+ packageName: string;
87
+ reference: string;
88
+ support: {
89
+ generator: string;
90
+ };
91
+ changeType: string;
92
+ creation: string;
93
+ content: object;
94
+ }
80
95
  export interface AddXMLChange extends CommonChangeProperties {
81
96
  changeType: 'addXML';
82
97
  creation: string;
@@ -102,10 +117,13 @@ export interface CodeExtChange extends CommonChangeProperties {
102
117
  controllerName: string;
103
118
  };
104
119
  }
105
- export declare const enum FolderNames {
106
- Changes = "changes",
107
- Fragments = "fragments",
108
- Coding = "coding"
120
+ export declare const enum FolderTypes {
121
+ CHANGES = "changes",
122
+ FRAGMENTS = "fragments",
123
+ CODING = "coding",
124
+ MANIFEST = "manifest",
125
+ ANNOTATIONS = "annotations",
126
+ WEBAPP = "webapp"
109
127
  }
110
128
  export declare const enum TemplateFileName {
111
129
  Fragment = "fragment.xml",
@@ -125,5 +143,177 @@ export declare const enum HttpStatusCodes {
125
143
  NOT_IMPLEMETED = 501,
126
144
  SERVICE_UNAVAILABLE = 503
127
145
  }
146
+ /**
147
+ * Represents a constructor type that creates an instance of IWriter.
148
+ *
149
+ * @param fs - An instance of Editor used for file system operations.
150
+ * @param projectPath - The root path of the project.
151
+ * @returns An instance of IWriter for handling specific data writing operations.
152
+ */
153
+ export type Writer = new (fs: Editor, projectPath: string) => IWriter<any>;
154
+ /**
155
+ * Generic interface for handling data associated with specific writer operations.
156
+ * Allows for the typing of data passed to IWriter implementations based on the change type.
157
+ *
158
+ * @template T - The subtype of ChangeType that specifies the kind of change and associated data.
159
+ */
160
+ export type IWriterData<T extends ChangeType> = IWriter<GeneratorData<T>>;
161
+ /**
162
+ * Defines a generic interface for writer classes, specialized by the type of data they handle.
163
+ *
164
+ * @template T - The specific type of data the writer will handle, determined by the associated ChangeType.
165
+ */
166
+ export interface IWriter<T> {
167
+ /**
168
+ * Writes the provided data to the project.
169
+ *
170
+ * @param data - The data needed for the writer function, specific to the type of change being made.
171
+ */
172
+ write(data: T): Promise<void>;
173
+ }
174
+ /**
175
+ * Enumerates the types of changes that can be made, each representing a specific kind of modification.
176
+ */
177
+ export declare const enum ChangeType {
178
+ ADD_NEW_MODEL = "appdescr_ui5_addNewModel",
179
+ ADD_ANNOTATIONS_TO_ODATA = "appdescr_app_addAnnotationsToOData",
180
+ CHANGE_DATA_SOURCE = "appdescr_app_changeDataSource",
181
+ ADD_COMPONENT_USAGES = "appdescr_ui5_addComponentUsages",
182
+ ADD_LIBRARY_REFERENCE = "appdescr_ui5_addLibraries",
183
+ CHANGE_INBOUND = "appdescr_app_changeInbound"
184
+ }
185
+ /**
186
+ * Maps a ChangeType to the corresponding data structure needed for that type of change.
187
+ * This conditional type ensures type safety by linking each change type with its relevant data model.
188
+ *
189
+ * @template T - A subtype of ChangeType indicating the specific type of change.
190
+ */
191
+ export type GeneratorData<T extends ChangeType> = T extends ChangeType.ADD_ANNOTATIONS_TO_ODATA ? AnnotationsData : T extends ChangeType.ADD_COMPONENT_USAGES ? ComponentUsagesData : T extends ChangeType.ADD_LIBRARY_REFERENCE ? ComponentUsagesData : T extends ChangeType.ADD_NEW_MODEL ? NewModelData : T extends ChangeType.CHANGE_DATA_SOURCE ? DataSourceData : T extends ChangeType.CHANGE_INBOUND ? InboundData : never;
192
+ export interface AnnotationsData {
193
+ projectData: AdpProjectData;
194
+ timestamp: number;
195
+ /** Indicates whether the annotation is for internal use only. */
196
+ isInternalUsage: boolean;
197
+ annotation: {
198
+ /** Optional name of the annotation file. */
199
+ fileName?: string;
200
+ /** Data source associated with the annotation. */
201
+ dataSource: string;
202
+ /** Path to the annotation file. */
203
+ filePath: string;
204
+ };
205
+ }
206
+ export interface ComponentUsagesData {
207
+ projectData: AdpProjectData;
208
+ timestamp: number;
209
+ component: {
210
+ /** Indicates whether the component is loaded lazily. */
211
+ isLazy: string;
212
+ /** Unique ID for the component usage. */
213
+ usageId: string;
214
+ /** Name of the component. */
215
+ name: string;
216
+ /** Serialized data specific to the component. */
217
+ data: string;
218
+ /** Settings related to the component. */
219
+ settings: string;
220
+ };
221
+ library: {
222
+ /** Reference to the component's library. */
223
+ reference: string;
224
+ /** Optional flag indicating if the library reference is lazy. */
225
+ referenceIsLazy?: string;
226
+ };
227
+ }
228
+ export interface NewModelData {
229
+ projectData: AdpProjectData;
230
+ timestamp: number;
231
+ annotation: {
232
+ /** Name of the OData annotation data source. */
233
+ dataSourceName: string;
234
+ /** Optional URI of the OData annotation data source. */
235
+ dataSourceURI?: string;
236
+ /** Optional settings for the OData annotation. */
237
+ settings?: string;
238
+ };
239
+ service: {
240
+ /** Name of the OData service. */
241
+ name: string;
242
+ /** URI of the OData service. */
243
+ uri: string;
244
+ /** Name of the OData service model. */
245
+ modelName: string;
246
+ /** Version of OData used. */
247
+ version: string;
248
+ /** Settings for the OData service model. */
249
+ modelSettings: string;
250
+ };
251
+ /** Indicates whether annotation mode is added. */
252
+ addAnnotationMode: boolean;
253
+ }
254
+ export interface DataSourceData {
255
+ projectData: AdpProjectData;
256
+ timestamp: number;
257
+ service: {
258
+ /** Data source identifier. */
259
+ name: string;
260
+ /** URI of the data source. */
261
+ uri: string;
262
+ /** Optional maximum age for the data source cache. */
263
+ maxAge?: number;
264
+ /** URI for the OData annotation source. */
265
+ annotationUri: string;
266
+ };
267
+ /** Dictionary mapping data source keys to their values. */
268
+ dataSourcesDictionary: {
269
+ [key: string]: string;
270
+ };
271
+ }
272
+ export interface InboundData {
273
+ projectData: AdpProjectData;
274
+ timestamp: number;
275
+ /** Identifier for the inbound navigation data. */
276
+ inboundId: string;
277
+ flp: {
278
+ /** Title associated with the inbound navigation data. */
279
+ title: PropertyValueType;
280
+ /** Subtitle associated with the inbound navigation data. */
281
+ subTitle: PropertyValueType;
282
+ /** Icon associated with the inbound navigation data. */
283
+ icon: PropertyValueType;
284
+ };
285
+ /** Optional flag indicating if the project is in safe mode. */
286
+ isInSafeMode?: boolean;
287
+ }
288
+ export interface InboundContent {
289
+ inboundId: string;
290
+ entityPropertyChange: {
291
+ propertyPath: string;
292
+ operation: string;
293
+ propertyValue: unknown;
294
+ }[];
295
+ }
296
+ export type DataSourceItem = {
297
+ uri?: string;
298
+ type: string;
299
+ settings: {
300
+ [key: string]: unknown;
301
+ };
302
+ };
303
+ export type PropertyValueType = 'boolean' | 'number' | 'string' | 'binding' | 'object';
304
+ export interface AdpProjectData {
305
+ path: string;
306
+ title: string;
307
+ namespace: string;
308
+ ui5Version: string;
309
+ name: string;
310
+ layer: string;
311
+ environment: string;
312
+ safeMode: boolean;
313
+ sourceSystem: string;
314
+ applicationIdx: string;
315
+ reference: string;
316
+ id: string;
317
+ }
128
318
  export {};
129
319
  //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1,20 @@
1
+ import type { Editor } from 'mem-fs-editor';
2
+ import { ChangeType } from '../../types';
3
+ import type { IWriterData } from '../../types';
4
+ /**
5
+ * Handles the creation of a writer instance based on the generator type.
6
+ */
7
+ export declare class WriterFactory {
8
+ private static writers;
9
+ /**
10
+ * Creates an instance of a writer based on the specified generator type.
11
+ *
12
+ * @param {T} type - The type of the change which will be handled by the writer.
13
+ * @param {Editor} fs - The filesystem editor instance.
14
+ * @param {string} projectPath - The path to the project for which the writer is created.
15
+ * @returns {IWriterData<T>} An instance of the writer associated with the specified generator type.
16
+ * @throws {Error} If the specified generator type is not supported.
17
+ */
18
+ static createWriter<T extends ChangeType>(type: T, fs: Editor, projectPath: string): IWriterData<T>;
19
+ }
20
+ //# sourceMappingURL=writer-factory.d.ts.map
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.WriterFactory = void 0;
4
+ const writers_1 = require("./writers");
5
+ /**
6
+ * Handles the creation of a writer instance based on the generator type.
7
+ */
8
+ class WriterFactory {
9
+ /**
10
+ * Creates an instance of a writer based on the specified generator type.
11
+ *
12
+ * @param {T} type - The type of the change which will be handled by the writer.
13
+ * @param {Editor} fs - The filesystem editor instance.
14
+ * @param {string} projectPath - The path to the project for which the writer is created.
15
+ * @returns {IWriterData<T>} An instance of the writer associated with the specified generator type.
16
+ * @throws {Error} If the specified generator type is not supported.
17
+ */
18
+ static createWriter(type, fs, projectPath) {
19
+ const WriterClass = this.writers.get(type);
20
+ if (!WriterClass) {
21
+ throw new Error(`Unsupported generator type: ${type}`);
22
+ }
23
+ return new WriterClass(fs, projectPath);
24
+ }
25
+ }
26
+ exports.WriterFactory = WriterFactory;
27
+ WriterFactory.writers = new Map([
28
+ ["appdescr_app_addAnnotationsToOData" /* ChangeType.ADD_ANNOTATIONS_TO_ODATA */, writers_1.AnnotationsWriter],
29
+ ["appdescr_ui5_addComponentUsages" /* ChangeType.ADD_COMPONENT_USAGES */, writers_1.ComponentUsagesWriter],
30
+ ["appdescr_ui5_addLibraries" /* ChangeType.ADD_LIBRARY_REFERENCE */, writers_1.ComponentUsagesWriter],
31
+ ["appdescr_ui5_addNewModel" /* ChangeType.ADD_NEW_MODEL */, writers_1.NewModelWriter],
32
+ ["appdescr_app_changeDataSource" /* ChangeType.CHANGE_DATA_SOURCE */, writers_1.DataSourceWriter],
33
+ ["appdescr_app_changeInbound" /* ChangeType.CHANGE_INBOUND */, writers_1.InboundWriter]
34
+ ]);
35
+ //# sourceMappingURL=writer-factory.js.map
@@ -0,0 +1,36 @@
1
+ import type { Editor } from 'mem-fs-editor';
2
+ import type { IWriter, AnnotationsData } from '../../../types';
3
+ /**
4
+ * Handles the creation and writing of annotations data changes for a project.
5
+ */
6
+ export declare class AnnotationsWriter implements IWriter<AnnotationsData> {
7
+ private fs;
8
+ private projectPath;
9
+ /**
10
+ * @param {Editor} fs - The filesystem editor instance.
11
+ * @param {string} projectPath - The root path of the project.
12
+ */
13
+ constructor(fs: Editor, projectPath: string);
14
+ /**
15
+ * Constructs the content for an annotation change based on provided data.
16
+ *
17
+ * @param {AnnotationsData} data - The data object containing information needed to construct the content property.
18
+ * @returns {object} The constructed content object for the annotation change.
19
+ */
20
+ private constructContent;
21
+ /**
22
+ * Determines the appropriate filename for the annotation file based on user answers.
23
+ *
24
+ * @param {AnnotationsData} data - The answers object containing user choices.
25
+ * @returns {string | undefined} The determined filename for the annotation file.
26
+ */
27
+ private getAnnotationFileName;
28
+ /**
29
+ * Writes the annotation change to the project based on the provided data.
30
+ *
31
+ * @param {AnnotationsData} data - The annotations data containing all the necessary information to construct and write the change.
32
+ * @returns {Promise<void>} A promise that resolves when the change writing process is completed.
33
+ */
34
+ write(data: AnnotationsData): Promise<void>;
35
+ }
36
+ //# sourceMappingURL=annotations-writer.d.ts.map