@sap-ux/odata-service-writer 0.26.4 → 0.26.6

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.
@@ -24,12 +24,11 @@ export declare function removeAnnotationsFromCDSFiles(annotations: CdsAnnotation
24
24
  * Writes local copies of metadata.xml and local annotations.
25
25
  *
26
26
  * @param {Editor} fs - the memfs editor instance
27
- * @param {string} basePath - the root path of an existing UI5 application
28
27
  * @param {string} webappPath - the webapp path of an existing UI5 application
29
28
  * @param {string} templateRoot - path to the file templates
30
29
  * @param {OdataService} service - the OData service instance with EDMX type
31
30
  */
32
- export declare function writeLocalServiceAnnotationXMLFiles(fs: Editor, basePath: string, webappPath: string, templateRoot: string, service: EdmxOdataService): Promise<void>;
31
+ export declare function writeLocalServiceAnnotationXMLFiles(fs: Editor, webappPath: string, templateRoot: string, service: EdmxOdataService): Promise<void>;
33
32
  /**
34
33
  * Writes local copy of metadata.xml.
35
34
  *
@@ -46,7 +45,7 @@ export declare function writeMetadata(fs: Editor, webappPath: string, service: E
46
45
  * @param {string} serviceName - Name of The OData service.
47
46
  * @param {OdataService} edmxAnnotations - The OData service annotations.
48
47
  */
49
- export declare function removeRemoteServiceAnnotationXmlFiles(fs: Editor, basePath: string, serviceName: string, edmxAnnotations: EdmxAnnotationsInfo | EdmxAnnotationsInfo[]): void;
48
+ export declare function removeRemoteServiceAnnotationXmlFiles(fs: Editor, basePath: string, serviceName: string, edmxAnnotations: EdmxAnnotationsInfo | EdmxAnnotationsInfo[]): Promise<void>;
50
49
  /**
51
50
  * Writes annotation XML files for EDMX service annotations.
52
51
  *
@@ -55,7 +54,7 @@ export declare function removeRemoteServiceAnnotationXmlFiles(fs: Editor, basePa
55
54
  * @param {string} serviceName - Name of The OData service.
56
55
  * @param {OdataService} edmxAnnotations - The OData service annotations.
57
56
  */
58
- export declare function writeRemoteServiceAnnotationXmlFiles(fs: Editor, basePath: string, serviceName: string, edmxAnnotations: EdmxAnnotationsInfo | EdmxAnnotationsInfo[]): void;
57
+ export declare function writeRemoteServiceAnnotationXmlFiles(fs: Editor, basePath: string, serviceName: string, edmxAnnotations: EdmxAnnotationsInfo | EdmxAnnotationsInfo[]): Promise<void>;
59
58
  /**
60
59
  * Returns the namespaces parsed from the specified metadata and annotations.
61
60
  *
@@ -14,6 +14,7 @@ const path_1 = require("path");
14
14
  const fast_xml_parser_1 = require("fast-xml-parser");
15
15
  const i18n_1 = require("../i18n");
16
16
  const prettify_xml_1 = __importDefault(require("prettify-xml"));
17
+ const project_access_1 = require("@sap-ux/project-access");
17
18
  /**
18
19
  * Updates the cds index or service file with the provided annotations.
19
20
  * This function takes an Editor instance and cds annotations
@@ -24,7 +25,7 @@ const prettify_xml_1 = __importDefault(require("prettify-xml"));
24
25
  * @returns {Promise<void>} A promise that resolves when the cds files have been updated.
25
26
  */
26
27
  async function updateCdsIndexOrServiceFile(fs, annotations) {
27
- const dirPath = (0, path_1.join)(annotations.projectName, 'annotations');
28
+ const dirPath = (0, path_1.join)(annotations.projectName, project_access_1.DirName.Annotations);
28
29
  const annotationPath = (0, path_1.normalize)(dirPath).split(/[\\/]/g).join(path_1.posix.sep);
29
30
  const annotationConfig = `\nusing from './${annotationPath}';`;
30
31
  // get index and service file paths
@@ -82,7 +83,7 @@ async function updateCdsFilesWithAnnotations(annotations, fs) {
82
83
  * @returns {Promise<void>} A promise that resolves when the cds files have been updated.
83
84
  */
84
85
  async function removeCdsIndexOrServiceFile(fs, annotations) {
85
- const dirPath = (0, path_1.join)(annotations.projectName, 'annotations');
86
+ const dirPath = (0, path_1.join)(annotations.projectName, project_access_1.DirName.Annotations);
86
87
  const annotationPath = (0, path_1.normalize)(dirPath).split(/[\\/]/g).join(path_1.posix.sep);
87
88
  const annotationConfig = `\nusing from './${annotationPath}';`;
88
89
  // Get index and service file paths
@@ -142,18 +143,17 @@ async function removeAnnotationsFromCDSFiles(annotations, fs) {
142
143
  * Writes local copies of metadata.xml and local annotations.
143
144
  *
144
145
  * @param {Editor} fs - the memfs editor instance
145
- * @param {string} basePath - the root path of an existing UI5 application
146
146
  * @param {string} webappPath - the webapp path of an existing UI5 application
147
147
  * @param {string} templateRoot - path to the file templates
148
148
  * @param {OdataService} service - the OData service instance with EDMX type
149
149
  */
150
- async function writeLocalServiceAnnotationXMLFiles(fs, basePath, webappPath, templateRoot, service) {
150
+ async function writeLocalServiceAnnotationXMLFiles(fs, webappPath, templateRoot, service) {
151
151
  // Write metadata.xml file
152
152
  await writeMetadata(fs, webappPath, service);
153
153
  // Adds local annotations to datasources section of manifest.json and writes the annotations file
154
154
  if (service.localAnnotationsName) {
155
155
  const namespaces = getAnnotationNamespaces(service);
156
- fs.copyTpl((0, path_1.join)(templateRoot, 'add', 'annotation.xml'), (0, path_1.join)(basePath, 'webapp', 'annotations', `${service.localAnnotationsName}.xml`), { ...service, namespaces });
156
+ fs.copyTpl((0, path_1.join)(templateRoot, 'add', 'annotation.xml'), (0, path_1.join)(webappPath, project_access_1.DirName.Annotations, `${service.localAnnotationsName}.xml`), { ...service, namespaces });
157
157
  }
158
158
  }
159
159
  /**
@@ -166,7 +166,7 @@ async function writeLocalServiceAnnotationXMLFiles(fs, basePath, webappPath, tem
166
166
  async function writeMetadata(fs, webappPath, service) {
167
167
  if (service.metadata) {
168
168
  // mainService should be used in case there is no name defined for service
169
- fs.write((0, path_1.join)(webappPath, 'localService', service.name ?? 'mainService', 'metadata.xml'), (0, prettify_xml_1.default)(service.metadata, { indent: 4 }));
169
+ fs.write((0, path_1.join)(webappPath, project_access_1.DirName.LocalService, service.name ?? 'mainService', 'metadata.xml'), (0, prettify_xml_1.default)(service.metadata, { indent: 4 }));
170
170
  }
171
171
  }
172
172
  /**
@@ -177,19 +177,20 @@ async function writeMetadata(fs, webappPath, service) {
177
177
  * @param {string} serviceName - Name of The OData service.
178
178
  * @param {OdataService} edmxAnnotations - The OData service annotations.
179
179
  */
180
- function removeRemoteServiceAnnotationXmlFiles(fs, basePath, serviceName, edmxAnnotations) {
180
+ async function removeRemoteServiceAnnotationXmlFiles(fs, basePath, serviceName, edmxAnnotations) {
181
+ const webappPath = await (0, project_access_1.getWebappPath)(basePath, fs);
181
182
  // Write annotation xml if annotations are provided and service type is EDMX
182
183
  if (Array.isArray(edmxAnnotations)) {
183
184
  for (const annotationName in edmxAnnotations) {
184
185
  const annotation = edmxAnnotations[annotationName];
185
- const pathToAnnotationFile = (0, path_1.join)(basePath, 'webapp', 'localService', serviceName, `${annotation.technicalName}.xml`);
186
+ const pathToAnnotationFile = (0, path_1.join)(webappPath, project_access_1.DirName.LocalService, serviceName, `${annotation.technicalName}.xml`);
186
187
  if (fs.exists(pathToAnnotationFile)) {
187
188
  fs.delete(pathToAnnotationFile);
188
189
  }
189
190
  }
190
191
  }
191
192
  else if (edmxAnnotations?.xml) {
192
- const pathToAnnotationFile = (0, path_1.join)(basePath, 'webapp', 'localService', serviceName, `${edmxAnnotations.technicalName}.xml`);
193
+ const pathToAnnotationFile = (0, path_1.join)(webappPath, project_access_1.DirName.LocalService, serviceName, `${edmxAnnotations.technicalName}.xml`);
193
194
  if (fs.exists(pathToAnnotationFile)) {
194
195
  fs.delete(pathToAnnotationFile);
195
196
  }
@@ -203,18 +204,19 @@ function removeRemoteServiceAnnotationXmlFiles(fs, basePath, serviceName, edmxAn
203
204
  * @param {string} serviceName - Name of The OData service.
204
205
  * @param {OdataService} edmxAnnotations - The OData service annotations.
205
206
  */
206
- function writeRemoteServiceAnnotationXmlFiles(fs, basePath, serviceName, edmxAnnotations) {
207
+ async function writeRemoteServiceAnnotationXmlFiles(fs, basePath, serviceName, edmxAnnotations) {
208
+ const webappPath = await (0, project_access_1.getWebappPath)(basePath, fs);
207
209
  // Write annotation xml if annotations are provided and service type is EDMX
208
210
  if (Array.isArray(edmxAnnotations)) {
209
211
  for (const annotationName in edmxAnnotations) {
210
212
  const annotation = edmxAnnotations[annotationName];
211
213
  if (annotation?.xml) {
212
- fs.write((0, path_1.join)(basePath, 'webapp', 'localService', serviceName, `${annotation.technicalName}.xml`), (0, prettify_xml_1.default)(annotation.xml, { indent: 4 }));
214
+ fs.write((0, path_1.join)(webappPath, project_access_1.DirName.LocalService, serviceName, `${annotation.technicalName}.xml`), (0, prettify_xml_1.default)(annotation.xml, { indent: 4 }));
213
215
  }
214
216
  }
215
217
  }
216
218
  else if (edmxAnnotations?.xml) {
217
- fs.write((0, path_1.join)(basePath, 'webapp', 'localService', serviceName, `${edmxAnnotations.technicalName}.xml`), (0, prettify_xml_1.default)(edmxAnnotations.xml, { indent: 4 }));
219
+ fs.write((0, path_1.join)(webappPath, project_access_1.DirName.LocalService, serviceName, `${edmxAnnotations.technicalName}.xml`), (0, prettify_xml_1.default)(edmxAnnotations.xml, { indent: 4 }));
218
220
  }
219
221
  }
220
222
  /**
package/dist/delete.js CHANGED
@@ -63,7 +63,7 @@ async function deleteServiceData(basePath, paths, service, fs) {
63
63
  ui5MockConfig.removeServiceFromMockServerMiddleware(service.path, serviceAnnotationPaths);
64
64
  fs.write(paths.ui5MockYaml, ui5MockConfig.toString());
65
65
  }
66
- (0, annotations_1.removeRemoteServiceAnnotationXmlFiles)(fs, basePath, service.name, service.annotations);
66
+ await (0, annotations_1.removeRemoteServiceAnnotationXmlFiles)(fs, basePath, service.name, service.annotations);
67
67
  }
68
68
  }
69
69
  //# sourceMappingURL=delete.js.map
package/dist/update.js CHANGED
@@ -94,7 +94,7 @@ async function addServicesData(basePath, paths, templateRoot, service, fs) {
94
94
  extendBackendMiddleware(fs, service, ui5MockConfig, paths.ui5MockYaml);
95
95
  }
96
96
  }
97
- await (0, annotations_1.writeLocalServiceAnnotationXMLFiles)(fs, basePath, webappPath, templateRoot, service);
97
+ await (0, annotations_1.writeLocalServiceAnnotationXMLFiles)(fs, webappPath, templateRoot, service);
98
98
  }
99
99
  // service update should not trigger the package.json update
100
100
  if (paths.packageJson && paths.ui5Yaml) {
@@ -103,7 +103,7 @@ async function addServicesData(basePath, paths, templateRoot, service, fs) {
103
103
  if (paths.ui5LocalYaml && ui5LocalConfig) {
104
104
  fs.write(paths.ui5LocalYaml, ui5LocalConfig.toString());
105
105
  }
106
- (0, annotations_1.writeRemoteServiceAnnotationXmlFiles)(fs, basePath, service.name ?? 'mainService', service.annotations);
106
+ await (0, annotations_1.writeRemoteServiceAnnotationXmlFiles)(fs, basePath, service.name ?? 'mainService', service.annotations);
107
107
  }
108
108
  /**
109
109
  * Updates services data in ui5-*.yaml files.
@@ -155,6 +155,6 @@ async function updateServicesData(basePath, paths, service, fs) {
155
155
  await (0, annotations_1.writeMetadata)(fs, webappPath, service);
156
156
  }
157
157
  // Write new annotations files
158
- (0, annotations_1.writeRemoteServiceAnnotationXmlFiles)(fs, basePath, service.name ?? 'mainService', service.annotations);
158
+ await (0, annotations_1.writeRemoteServiceAnnotationXmlFiles)(fs, basePath, service.name ?? 'mainService', service.annotations);
159
159
  }
160
160
  //# sourceMappingURL=update.js.map
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%3Aodata-service-writer"
11
11
  },
12
- "version": "0.26.4",
12
+ "version": "0.26.6",
13
13
  "license": "Apache-2.0",
14
14
  "main": "dist/index.js",
15
15
  "files": [
@@ -27,8 +27,8 @@
27
27
  "mem-fs-editor": "9.4.0",
28
28
  "prettify-xml": "1.2.0",
29
29
  "semver": "7.5.4",
30
- "@sap-ux/mockserver-config-writer": "0.8.2",
31
- "@sap-ux/project-access": "1.29.9",
30
+ "@sap-ux/mockserver-config-writer": "0.8.4",
31
+ "@sap-ux/project-access": "1.29.11",
32
32
  "@sap-ux/ui5-config": "0.26.2"
33
33
  },
34
34
  "devDependencies": {