@sap-ux/odata-service-writer 0.27.22 → 0.27.24

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.
@@ -10,7 +10,7 @@ exports.writeMetadata = writeMetadata;
10
10
  exports.removeRemoteServiceAnnotationXmlFiles = removeRemoteServiceAnnotationXmlFiles;
11
11
  exports.writeRemoteServiceAnnotationXmlFiles = writeRemoteServiceAnnotationXmlFiles;
12
12
  exports.getAnnotationNamespaces = getAnnotationNamespaces;
13
- const path_1 = require("path");
13
+ const node_path_1 = require("node: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"));
@@ -25,12 +25,12 @@ const project_access_1 = require("@sap-ux/project-access");
25
25
  * @returns {Promise<void>} A promise that resolves when the cds files have been updated.
26
26
  */
27
27
  async function updateCdsIndexOrServiceFile(fs, annotations) {
28
- const dirPath = (0, path_1.join)(annotations.projectName, project_access_1.DirName.Annotations);
29
- const annotationPath = (0, path_1.normalize)(dirPath).split(/[\\/]/g).join(path_1.posix.sep);
28
+ const dirPath = (0, node_path_1.join)(annotations.projectName, project_access_1.DirName.Annotations);
29
+ const annotationPath = (0, node_path_1.normalize)(dirPath).split(/[\\/]/g).join(node_path_1.posix.sep);
30
30
  const annotationConfig = `\nusing from './${annotationPath}';`;
31
31
  // get index and service file paths
32
- const indexFilePath = (0, path_1.join)(annotations.projectPath, annotations.appPath ?? '', 'index.cds');
33
- const serviceFilePath = (0, path_1.join)(annotations.projectPath, annotations.appPath ?? '', 'services.cds');
32
+ const indexFilePath = (0, node_path_1.join)(annotations.projectPath, annotations.appPath ?? '', 'index.cds');
33
+ const serviceFilePath = (0, node_path_1.join)(annotations.projectPath, annotations.appPath ?? '', 'services.cds');
34
34
  // extend index or service file with annotation config
35
35
  if (indexFilePath && fs.exists(indexFilePath)) {
36
36
  fs.append(indexFilePath, annotationConfig);
@@ -55,7 +55,7 @@ async function updateCdsFilesWithAnnotations(annotations, fs) {
55
55
  if (Array.isArray(annotations)) {
56
56
  for (const annotationName in annotations) {
57
57
  const annotation = annotations[annotationName];
58
- const annotationCdsPath = (0, path_1.join)(annotation.projectPath, annotation.appPath ?? '', annotation.projectName, 'annotations.cds');
58
+ const annotationCdsPath = (0, node_path_1.join)(annotation.projectPath, annotation.appPath ?? '', annotation.projectName, 'annotations.cds');
59
59
  // write into annotations.cds file
60
60
  if (fs.exists(annotationCdsPath)) {
61
61
  fs.append(annotationCdsPath, annotation.cdsFileContents);
@@ -67,7 +67,7 @@ async function updateCdsFilesWithAnnotations(annotations, fs) {
67
67
  }
68
68
  }
69
69
  else {
70
- const annotationCdsPath = (0, path_1.join)(annotations.projectPath, annotations.appPath ?? '', annotations.projectName, 'annotations.cds');
70
+ const annotationCdsPath = (0, node_path_1.join)(annotations.projectPath, annotations.appPath ?? '', annotations.projectName, 'annotations.cds');
71
71
  // write into annotations.cds file
72
72
  fs.write(annotationCdsPath, annotations.cdsFileContents);
73
73
  await updateCdsIndexOrServiceFile(fs, annotations);
@@ -83,12 +83,12 @@ async function updateCdsFilesWithAnnotations(annotations, fs) {
83
83
  * @returns {Promise<void>} A promise that resolves when the cds files have been updated.
84
84
  */
85
85
  async function removeCdsIndexOrServiceFile(fs, annotations) {
86
- const dirPath = (0, path_1.join)(annotations.projectName, project_access_1.DirName.Annotations);
87
- const annotationPath = (0, path_1.normalize)(dirPath).split(/[\\/]/g).join(path_1.posix.sep);
86
+ const dirPath = (0, node_path_1.join)(annotations.projectName, project_access_1.DirName.Annotations);
87
+ const annotationPath = (0, node_path_1.normalize)(dirPath).split(/[\\/]/g).join(node_path_1.posix.sep);
88
88
  const annotationConfig = `\nusing from './${annotationPath}';`;
89
89
  // Get index and service file paths
90
- const indexFilePath = (0, path_1.join)(annotations.projectPath, annotations.appPath ?? '', 'index.cds');
91
- const serviceFilePath = (0, path_1.join)(annotations.projectPath, annotations.appPath ?? '', 'services.cds');
90
+ const indexFilePath = (0, node_path_1.join)(annotations.projectPath, annotations.appPath ?? '', 'index.cds');
91
+ const serviceFilePath = (0, node_path_1.join)(annotations.projectPath, annotations.appPath ?? '', 'services.cds');
92
92
  // Remove annotation config from index or service file
93
93
  if (indexFilePath && fs.exists(indexFilePath)) {
94
94
  // Read old annotations content and replace it with empty string
@@ -116,7 +116,7 @@ async function removeAnnotationsFromCDSFiles(annotations, fs) {
116
116
  if (Array.isArray(annotations)) {
117
117
  for (const annotationName in annotations) {
118
118
  const annotation = annotations[annotationName];
119
- const annotationCdsPath = (0, path_1.join)(annotation.projectPath, annotation.appPath ?? '', annotation.projectName, 'annotations.cds');
119
+ const annotationCdsPath = (0, node_path_1.join)(annotation.projectPath, annotation.appPath ?? '', annotation.projectName, 'annotations.cds');
120
120
  // Remove from annotations.cds file
121
121
  if (fs.exists(annotationCdsPath)) {
122
122
  // Read old annotations content and replace it with empty string
@@ -128,7 +128,7 @@ async function removeAnnotationsFromCDSFiles(annotations, fs) {
128
128
  }
129
129
  }
130
130
  else {
131
- const annotationCdsPath = (0, path_1.join)(annotations.projectPath, annotations.appPath ?? '', annotations.projectName, 'annotations.cds');
131
+ const annotationCdsPath = (0, node_path_1.join)(annotations.projectPath, annotations.appPath ?? '', annotations.projectName, 'annotations.cds');
132
132
  // Write into annotations.cds file
133
133
  if (fs.exists(annotationCdsPath)) {
134
134
  // Read old annotations content and replace it with empty string
@@ -153,7 +153,7 @@ async function writeLocalServiceAnnotationXMLFiles(fs, webappPath, templateRoot,
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)(webappPath, project_access_1.DirName.Annotations, `${service.localAnnotationsName}.xml`), { ...service, namespaces });
156
+ fs.copyTpl((0, node_path_1.join)(templateRoot, 'add', 'annotation.xml'), (0, node_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, webappPath, templateRoot,
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, project_access_1.DirName.LocalService, service.name ?? 'mainService', 'metadata.xml'), (0, prettify_xml_1.default)(service.metadata, { indent: 4 }));
169
+ fs.write((0, node_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
  /**
@@ -183,14 +183,14 @@ async function removeRemoteServiceAnnotationXmlFiles(fs, basePath, serviceName,
183
183
  if (Array.isArray(edmxAnnotations)) {
184
184
  for (const annotationName in edmxAnnotations) {
185
185
  const annotation = edmxAnnotations[annotationName];
186
- const pathToAnnotationFile = (0, path_1.join)(webappPath, project_access_1.DirName.LocalService, serviceName, `${annotation.technicalName}.xml`);
186
+ const pathToAnnotationFile = (0, node_path_1.join)(webappPath, project_access_1.DirName.LocalService, serviceName, `${annotation.technicalName}.xml`);
187
187
  if (fs.exists(pathToAnnotationFile)) {
188
188
  fs.delete(pathToAnnotationFile);
189
189
  }
190
190
  }
191
191
  }
192
192
  else if (edmxAnnotations?.xml) {
193
- const pathToAnnotationFile = (0, path_1.join)(webappPath, project_access_1.DirName.LocalService, serviceName, `${edmxAnnotations.technicalName}.xml`);
193
+ const pathToAnnotationFile = (0, node_path_1.join)(webappPath, project_access_1.DirName.LocalService, serviceName, `${edmxAnnotations.technicalName}.xml`);
194
194
  if (fs.exists(pathToAnnotationFile)) {
195
195
  fs.delete(pathToAnnotationFile);
196
196
  }
@@ -211,12 +211,12 @@ async function writeRemoteServiceAnnotationXmlFiles(fs, basePath, serviceName, e
211
211
  for (const annotationName in edmxAnnotations) {
212
212
  const annotation = edmxAnnotations[annotationName];
213
213
  if (annotation?.xml) {
214
- fs.write((0, path_1.join)(webappPath, project_access_1.DirName.LocalService, serviceName, `${annotation.name}.xml`), (0, prettify_xml_1.default)(annotation.xml, { indent: 4 }));
214
+ fs.write((0, node_path_1.join)(webappPath, project_access_1.DirName.LocalService, serviceName, `${annotation.name}.xml`), (0, prettify_xml_1.default)(annotation.xml, { indent: 4 }));
215
215
  }
216
216
  }
217
217
  }
218
218
  else if (edmxAnnotations?.xml) {
219
- fs.write((0, path_1.join)(webappPath, project_access_1.DirName.LocalService, serviceName, `${edmxAnnotations.name}.xml`), (0, prettify_xml_1.default)(edmxAnnotations.xml, { indent: 4 }));
219
+ fs.write((0, node_path_1.join)(webappPath, project_access_1.DirName.LocalService, serviceName, `${edmxAnnotations.name}.xml`), (0, prettify_xml_1.default)(edmxAnnotations.xml, { indent: 4 }));
220
220
  }
221
221
  }
222
222
  /**
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.enhanceData = enhanceData;
4
- const path_1 = require("path");
4
+ const node_path_1 = require("node:path");
5
5
  const types_1 = require("../types");
6
6
  const constants_1 = require("./constants");
7
7
  const project_access_1 = require("@sap-ux/project-access");
@@ -47,7 +47,7 @@ function generateUniqueServiceName(dataSources, serviceName) {
47
47
  * @param {boolean} update - whether the service update is running
48
48
  */
49
49
  async function setDefaultServiceName(basePath, service, fs, update) {
50
- const manifestPath = (0, path_1.join)(await (0, project_access_1.getWebappPath)(basePath, fs), project_access_1.FileName.Manifest);
50
+ const manifestPath = (0, node_path_1.join)(await (0, project_access_1.getWebappPath)(basePath, fs), project_access_1.FileName.Manifest);
51
51
  const manifest = fs.readJSON(manifestPath);
52
52
  // Check if manifest has already any dataSources defined, DEFAULT_DATASOURCE_NAME should be used for the first service
53
53
  const dataSources = manifest?.['sap.app']?.dataSources;
@@ -77,7 +77,7 @@ async function setDefaultServiceName(basePath, service, fs, update) {
77
77
  * @param {boolean} update - whether the service update is running (if true, makes sure that '' model is updated for the mainService)
78
78
  */
79
79
  async function setDefaultServiceModel(basePath, service, fs, update) {
80
- const manifestPath = (0, path_1.join)(await (0, project_access_1.getWebappPath)(basePath, fs), 'manifest.json');
80
+ const manifestPath = (0, node_path_1.join)(await (0, project_access_1.getWebappPath)(basePath, fs), 'manifest.json');
81
81
  const manifest = fs.readJSON(manifestPath);
82
82
  if (!service.model) {
83
83
  // Check if manifest has already any dataSource models defined, empty string '' should be used for the first service
@@ -158,7 +158,7 @@ async function setDefaultPreviewSettings(basePath, service, fs) {
158
158
  service.previewSettings.destinationInstance = service.destination.instance;
159
159
  }
160
160
  }
161
- const ui5Yamlpath = (0, path_1.join)(basePath, project_access_1.FileName.Ui5Yaml);
161
+ const ui5Yamlpath = (0, node_path_1.join)(basePath, project_access_1.FileName.Ui5Yaml);
162
162
  if (fs.exists(ui5Yamlpath)) {
163
163
  const yamlContents = fs.read(ui5Yamlpath);
164
164
  const ui5Config = await ui5_config_1.UI5Config.newInstance(yamlContents);
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.deleteServiceFromManifest = deleteServiceFromManifest;
7
7
  exports.updateManifest = updateManifest;
8
- const path_1 = require("path");
8
+ const node_path_1 = require("node:path");
9
9
  const i18n_1 = require("../i18n");
10
10
  const project_access_1 = require("@sap-ux/project-access");
11
11
  const semver_1 = __importDefault(require("semver"));
@@ -171,8 +171,8 @@ function removeUnusedAnnotations(fs, webappPath, dataSources, serviceName, creat
171
171
  !createdAnnotations.includes(name)) {
172
172
  const oldAnnotationPath = dataSource.settings?.localUri;
173
173
  // Delete old annotation files
174
- if (oldAnnotationPath && fs.exists((0, path_1.join)(webappPath, oldAnnotationPath))) {
175
- fs.delete((0, path_1.join)(webappPath, oldAnnotationPath));
174
+ if (oldAnnotationPath && fs.exists((0, node_path_1.join)(webappPath, oldAnnotationPath))) {
175
+ fs.delete((0, node_path_1.join)(webappPath, oldAnnotationPath));
176
176
  }
177
177
  // Delete old annotation dataSource netry
178
178
  delete dataSources[name];
@@ -270,8 +270,8 @@ function convertSingleService(webappPath, dataSourceKey, dataSource, fs) {
270
270
  const localFileName = localUriParts[localUriParts.length - 1];
271
271
  settings.localUri = `${project_access_1.DirName.LocalService}/${dataSourceKey}/${localFileName}`;
272
272
  // move related files to service folder
273
- const fromFilePath = (0, path_1.join)(webappPath, localUriParts.join(path_1.sep));
274
- const toFilePath = (0, path_1.join)(webappPath, project_access_1.DirName.LocalService, dataSourceKey, localFileName);
273
+ const fromFilePath = (0, node_path_1.join)(webappPath, localUriParts.join(node_path_1.sep));
274
+ const toFilePath = (0, node_path_1.join)(webappPath, project_access_1.DirName.LocalService, dataSourceKey, localFileName);
275
275
  if (fs.exists(fromFilePath)) {
276
276
  fs.move(fromFilePath, toFilePath);
277
277
  }
@@ -315,7 +315,7 @@ async function addMultipleServiceSupportToManifest(webappPath, manifest, fs) {
315
315
  function removeFileForDataSource(fs, manifestPath, dataSource) {
316
316
  const serviceSettings = dataSource.settings ?? {};
317
317
  if (serviceSettings?.localUri) {
318
- const localUriPath = (0, path_1.join)((0, path_1.dirname)(manifestPath), serviceSettings?.localUri);
318
+ const localUriPath = (0, node_path_1.join)((0, node_path_1.dirname)(manifestPath), serviceSettings?.localUri);
319
319
  if (fs.exists(localUriPath)) {
320
320
  // delete the local data source file
321
321
  fs.delete(localUriPath);
@@ -354,7 +354,7 @@ function removeAnnotations(fs, manifestPath, annotations, dataSources) {
354
354
  */
355
355
  function deleteServiceFromManifest(basePath, service, fs) {
356
356
  const serviceName = service.name ?? 'mainService';
357
- const manifestPath = (0, path_1.join)(basePath, 'webapp', 'manifest.json');
357
+ const manifestPath = (0, node_path_1.join)(basePath, 'webapp', 'manifest.json');
358
358
  // Get component app id
359
359
  const manifest = fs.readJSON(manifestPath);
360
360
  const appProp = 'sap.app';
@@ -400,7 +400,7 @@ function deleteServiceFromManifest(basePath, service, fs) {
400
400
  async function updateManifest(basePath, service, fs, forceServiceUpdate = false) {
401
401
  // Update manifest.json
402
402
  const webappPath = await (0, project_access_1.getWebappPath)(basePath, fs);
403
- const manifestPath = (0, path_1.join)(webappPath, 'manifest.json');
403
+ const manifestPath = (0, node_path_1.join)(webappPath, 'manifest.json');
404
404
  // Get component app id
405
405
  const manifest = fs.readJSON(manifestPath);
406
406
  const appProp = 'sap.app';
package/dist/index.js CHANGED
@@ -4,7 +4,7 @@ exports.getAnnotationNamespaces = exports.ServiceType = exports.OdataVersion = v
4
4
  exports.generate = generate;
5
5
  exports.update = update;
6
6
  exports.remove = remove;
7
- const path_1 = require("path");
7
+ const node_path_1 = require("node:path");
8
8
  const mem_fs_1 = require("mem-fs");
9
9
  const mem_fs_editor_1 = require("mem-fs-editor");
10
10
  const update_1 = require("./update");
@@ -26,7 +26,7 @@ const manifest_1 = require("./data/manifest");
26
26
  */
27
27
  function ensureExists(basePath, files, fs) {
28
28
  files.forEach((path) => {
29
- if (!fs.exists((0, path_1.join)(basePath, path))) {
29
+ if (!fs.exists((0, node_path_1.join)(basePath, path))) {
30
30
  throw new Error((0, i18n_1.t)('error.requiredProjectFileNotFound', { path }));
31
31
  }
32
32
  });
@@ -40,20 +40,20 @@ function ensureExists(basePath, files, fs) {
40
40
  */
41
41
  async function findProjectFiles(basePath, fs) {
42
42
  const files = {};
43
- const parts = basePath.split(path_1.sep);
43
+ const parts = basePath.split(node_path_1.sep);
44
44
  while (parts.length > 0 && (!files.packageJson || !files.ui5Yaml || !files.ui5LocalYaml || !files.ui5MockYaml)) {
45
- const path = parts.join(path_1.sep);
46
- if (!files.packageJson && fs.exists((0, path_1.join)(path, 'package.json'))) {
47
- files.packageJson = (0, path_1.join)(path, 'package.json');
45
+ const path = parts.join(node_path_1.sep);
46
+ if (!files.packageJson && fs.exists((0, node_path_1.join)(path, 'package.json'))) {
47
+ files.packageJson = (0, node_path_1.join)(path, 'package.json');
48
48
  }
49
- if (!files.ui5Yaml && fs.exists((0, path_1.join)(path, 'ui5.yaml'))) {
50
- files.ui5Yaml = (0, path_1.join)(path, 'ui5.yaml');
49
+ if (!files.ui5Yaml && fs.exists((0, node_path_1.join)(path, 'ui5.yaml'))) {
50
+ files.ui5Yaml = (0, node_path_1.join)(path, 'ui5.yaml');
51
51
  }
52
- if (!files.ui5LocalYaml && fs.exists((0, path_1.join)(path, 'ui5-local.yaml'))) {
53
- files.ui5LocalYaml = (0, path_1.join)(path, 'ui5-local.yaml');
52
+ if (!files.ui5LocalYaml && fs.exists((0, node_path_1.join)(path, 'ui5-local.yaml'))) {
53
+ files.ui5LocalYaml = (0, node_path_1.join)(path, 'ui5-local.yaml');
54
54
  }
55
- if (!files.ui5MockYaml && fs.exists((0, path_1.join)(path, 'ui5-mock.yaml'))) {
56
- files.ui5MockYaml = (0, path_1.join)(path, 'ui5-mock.yaml');
55
+ if (!files.ui5MockYaml && fs.exists((0, node_path_1.join)(path, 'ui5-mock.yaml'))) {
56
+ files.ui5MockYaml = (0, node_path_1.join)(path, 'ui5-mock.yaml');
57
57
  }
58
58
  parts.pop();
59
59
  }
@@ -79,7 +79,7 @@ async function generate(basePath, service, fs) {
79
79
  // Set isServiceTypeEdmx true if service is EDMX
80
80
  const isServiceTypeEdmx = service.type === types_1.ServiceType.EDMX;
81
81
  // Prepare template folder for manifest and xml updates
82
- const templateRoot = (0, path_1.join)(__dirname, '../templates');
82
+ const templateRoot = (0, node_path_1.join)(__dirname, '../templates');
83
83
  await (0, manifest_1.updateManifest)(basePath, service, fs);
84
84
  // Dont add backend and mockserver middlewares if service type is CDS
85
85
  if (isServiceTypeEdmx) {
package/dist/update.js CHANGED
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.addServicesData = addServicesData;
4
4
  exports.updateServicesData = updateServicesData;
5
- const path_1 = require("path");
5
+ const node_path_1 = require("node:path");
6
6
  const project_access_1 = require("@sap-ux/project-access");
7
7
  const ui5_config_1 = require("@sap-ux/ui5-config");
8
8
  const mockserver_config_writer_1 = require("@sap-ux/mockserver-config-writer");
@@ -19,7 +19,7 @@ const package_1 = require("./data/package");
19
19
  */
20
20
  async function generateMockserverMiddlewareBasedOnUi5MockYaml(fs, ui5YamlPath, ui5LocalConfigPath, ui5LocalConfig) {
21
21
  // Update ui5-local.yaml with mockserver middleware from ui5-mock.yaml
22
- const ui5MockYamlPath = (0, path_1.join)((0, path_1.dirname)(ui5YamlPath), project_access_1.FileName.Ui5MockYaml);
22
+ const ui5MockYamlPath = (0, node_path_1.join)((0, node_path_1.dirname)(ui5YamlPath), project_access_1.FileName.Ui5MockYaml);
23
23
  const ui5MockYamlConfig = await ui5_config_1.UI5Config.newInstance(fs.read(ui5MockYamlPath));
24
24
  const mockserverMiddlewareFromUi5Mock = ui5MockYamlConfig.findCustomMiddleware('sap-fe-mockserver');
25
25
  if (ui5LocalConfigPath && fs.exists(ui5LocalConfigPath) && ui5LocalConfig && mockserverMiddlewareFromUi5Mock) {
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.27.22",
12
+ "version": "0.27.24",
13
13
  "license": "Apache-2.0",
14
14
  "main": "dist/index.js",
15
15
  "files": [
@@ -27,9 +27,9 @@
27
27
  "mem-fs-editor": "9.4.0",
28
28
  "prettify-xml": "1.2.0",
29
29
  "semver": "7.5.4",
30
- "@sap-ux/project-access": "1.32.1",
31
- "@sap-ux/mockserver-config-writer": "0.9.18",
32
- "@sap-ux/ui5-config": "0.29.5"
30
+ "@sap-ux/mockserver-config-writer": "0.9.20",
31
+ "@sap-ux/project-access": "1.32.3",
32
+ "@sap-ux/ui5-config": "0.29.7"
33
33
  },
34
34
  "devDependencies": {
35
35
  "@types/ejs": "3.1.2",