@sap-ux/odata-service-writer 0.25.4 → 0.25.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.
@@ -52,19 +52,24 @@ async function setDefaultServiceName(basePath, service, fs) {
52
52
  async function setDefaultServiceModel(basePath, service, fs) {
53
53
  const manifestPath = (0, path_1.join)(await (0, project_access_1.getWebappPath)(basePath, fs), 'manifest.json');
54
54
  const manifest = fs.readJSON(manifestPath);
55
- // Check if manifest has already any dataSource models defined, empty string '' should be used for the first service
56
- const models = manifest?.['sap.ui5']?.models;
57
- if (models) {
58
- // Filter dataSource models by dataSource property
59
- const servicesModels = Object.values(models).filter((model) => model.dataSource);
60
- service.model =
61
- servicesModels.length === 0 ||
62
- servicesModels.find((serviceModel) => serviceModel.dataSource === 'mainService') // model for mainService is ""
63
- ? ''
64
- : service.model ?? service.name;
55
+ if (!service.model) {
56
+ // Check if manifest has already any dataSource models defined, empty string '' should be used for the first service
57
+ const models = manifest?.['sap.ui5']?.models;
58
+ if (models) {
59
+ // Filter dataSource models by dataSource property
60
+ const servicesModels = Object.values(models).filter((model) => model.dataSource);
61
+ service.model =
62
+ servicesModels.length === 0 ||
63
+ (servicesModels.find((serviceModel) => serviceModel.dataSource === constants_1.DEFAULT_DATASOURCE_NAME) &&
64
+ service.name === constants_1.DEFAULT_DATASOURCE_NAME) // model for mainService is ""
65
+ ? ''
66
+ : service.name;
67
+ }
68
+ else {
69
+ // No models defined, that means first one is being added, set model to ''
70
+ service.model = '';
71
+ }
65
72
  }
66
- // No models defined, that means first one is being added, set model to ''
67
- service.model ??= '';
68
73
  }
69
74
  /**
70
75
  * Sets default annotation name for a single annotation of a given service.
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.25.4",
12
+ "version": "0.25.6",
13
13
  "license": "Apache-2.0",
14
14
  "main": "dist/index.js",
15
15
  "files": [
@@ -38,7 +38,7 @@
38
38
  "@types/semver": "7.5.2",
39
39
  "fs-extra": "10.0.0",
40
40
  "lodash": "4.17.21",
41
- "@sap-ux/project-access": "1.29.1"
41
+ "@sap-ux/project-access": "1.29.4"
42
42
  },
43
43
  "engines": {
44
44
  "node": ">=18.x"