@sap/cds-dk 7.9.4 → 8.0.2

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.
Files changed (286) hide show
  1. package/CHANGELOG.md +2116 -0
  2. package/bin/add.js +18 -52
  3. package/bin/bind.js +2 -2
  4. package/bin/build.js +29 -4
  5. package/bin/cds.js +23 -11
  6. package/bin/compile/index.js +7 -6
  7. package/bin/completion/index.js +70 -46
  8. package/bin/completion/scripts/cds-bash.sh +4 -1
  9. package/bin/completion/scripts/cds-fish.fish +13 -0
  10. package/bin/completion/scripts/cds-ps.ps1 +2 -1
  11. package/bin/completion/scripts/cds-zsh.sh +2 -1
  12. package/bin/deploy/index.js +6 -5
  13. package/bin/deploy/to-sqlite.js +2 -2
  14. package/bin/extend.js +19 -50
  15. package/bin/help.js +2 -2
  16. package/bin/init.js +10 -77
  17. package/bin/login.js +13 -5
  18. package/bin/migrate.js +1 -1
  19. package/bin/pull.js +11 -0
  20. package/bin/repl.js +3 -0
  21. package/bin/test.js +5 -0
  22. package/bin/version.js +7 -7
  23. package/bin/watch.js +2 -11
  24. package/lib/bind/KubernetesApiAccessor.js +10 -9
  25. package/lib/build/buildTaskEngine.js +11 -7
  26. package/lib/build/buildTaskFactory.js +15 -43
  27. package/lib/build/buildTaskProviderFactory.js +16 -44
  28. package/lib/build/constants.js +3 -3
  29. package/lib/build/index.js +2 -2
  30. package/lib/build/{buildPlugin.js → plugin.js} +65 -46
  31. package/lib/{init/template/helm/files → build/plugins/helm/files/subcharts}/content-deployment/Chart.yaml +1 -1
  32. package/lib/{init/template/helm/files → build/plugins/helm/files/subcharts}/content-deployment/values.yaml +1 -1
  33. package/lib/{init/template/helm/files → build/plugins/helm/files/subcharts}/service-instance/Chart.yaml +1 -1
  34. package/lib/{init/template/helm/files → build/plugins/helm/files/subcharts}/service-instance/templates/_helpers.tpl +7 -0
  35. package/lib/build/plugins/helm/files/subcharts/service-instance/templates/servicebinding.yaml +32 -0
  36. package/lib/{init/template/helm/files → build/plugins/helm/files/subcharts}/service-instance/templates/serviceinstance.yaml +3 -0
  37. package/lib/{init/template/helm/files → build/plugins/helm/files/subcharts}/service-instance/values.schema.json +63 -0
  38. package/lib/{init/template/helm/files → build/plugins/helm/files/subcharts}/service-instance/values.yaml +23 -1
  39. package/lib/{init/template/helm/files → build/plugins/helm/files/subcharts}/web-application/Chart.yaml +1 -1
  40. package/lib/{init/template/helm/files → build/plugins/helm/files/subcharts}/web-application/templates/deployment.yaml +2 -0
  41. package/lib/build/plugins/helm/files/subcharts/web-application/templates/hpa.yaml +22 -0
  42. package/lib/{init/template/helm/files → build/plugins/helm/files/subcharts}/web-application/templates/pod-disruption-budget.yaml +1 -0
  43. package/lib/{init/template/helm/files → build/plugins/helm/files/subcharts}/web-application/values.schema.json +49 -0
  44. package/lib/{init/template/helm/files → build/plugins/helm/files/subcharts}/web-application/values.yaml +8 -2
  45. package/lib/{init/template/helm/files/chart → build/plugins/helm/files}/templates/_deployment_helpers.tpl +5 -0
  46. package/lib/build/plugins/helm/files/templates/_helpers.tpl +13 -0
  47. package/lib/build/plugins/helm/index.js +81 -0
  48. package/lib/build/plugins.js +12 -15
  49. package/lib/build/provider/featureToggleBuildPlugin.js +7 -39
  50. package/lib/build/provider/hana/2migration.js +168 -124
  51. package/lib/build/provider/hana/index.js +20 -25
  52. package/lib/build/provider/hana/template/.hdiconfig-all +3 -0
  53. package/lib/build/provider/hana/template/.hdiconfig-cloud +3 -0
  54. package/lib/build/provider/hana/template/package.json +4 -3
  55. package/lib/build/provider/internalBuildPlugin.js +32 -97
  56. package/lib/build/provider/internalBuildTaskProvider.js +10 -46
  57. package/lib/build/provider/java/index.js +2 -3
  58. package/lib/build/provider/mtx/index.js +5 -4
  59. package/lib/build/provider/mtx-extension/index.js +5 -2
  60. package/lib/build/provider/mtx-sidecar/index.js +2 -2
  61. package/lib/build/util.js +83 -12
  62. package/lib/compile/to-mermaid.js +108 -0
  63. package/lib/compile/to_asyncapi.js +7 -0
  64. package/lib/compile/to_openapi.js +7 -0
  65. package/lib/deploy/to-hana/hana.js +37 -34
  66. package/lib/deploy/to-hana/hdiDeployUtil.js +8 -6
  67. package/lib/env/schemas/cds-rc.js +1 -1
  68. package/lib/import/common.js +2 -2
  69. package/lib/import/odata/metadataconverter/MetadataConverter.js +4 -4
  70. package/lib/import/odata/v2parser.js +83 -197
  71. package/lib/import/odata/v4parser.js +1 -38
  72. package/lib/import/openapi/importOpenAPI.js +164 -42
  73. package/lib/index.js +10 -12
  74. package/lib/init/bas.js +91 -0
  75. package/lib/init/constants.js +16 -10
  76. package/lib/init/index.js +74 -150
  77. package/lib/init/merge.js +12 -20
  78. package/lib/init/mvn.js +103 -150
  79. package/lib/init/plugin.js +11 -7
  80. package/lib/init/projectReader.js +53 -19
  81. package/lib/init/registries/mta.js +51 -6
  82. package/lib/init/template/application-logging/files/package.json.hbs +7 -0
  83. package/lib/init/template/application-logging/index.js +13 -1
  84. package/lib/init/template/approuter/files/containerize.yaml.hbs +10 -0
  85. package/lib/init/template/approuter/files/mta.yaml.hbs +1 -2
  86. package/lib/init/template/approuter/files/values.yaml.hbs +19 -4
  87. package/lib/init/template/approuter/files/xs-app.json.hbs +12 -3
  88. package/lib/init/template/approuter/index.js +29 -25
  89. package/lib/init/template/attachments/files/mta.yaml.hbs +14 -0
  90. package/lib/init/template/attachments/files/package.json.hbs +5 -0
  91. package/lib/init/template/attachments/files/values.yaml +7 -0
  92. package/lib/init/template/attachments/index.js +53 -0
  93. package/lib/init/template/audit-logging/files/mta.yaml.hbs +14 -0
  94. package/lib/init/template/audit-logging/files/package.json.hbs +7 -0
  95. package/lib/init/template/audit-logging/index.js +66 -0
  96. package/lib/init/template/cf-manifest/index.js +4 -0
  97. package/lib/init/template/completion/completionSetup.js +54 -33
  98. package/lib/init/template/completion/index.js +7 -1
  99. package/lib/init/template/connectivity/index.js +4 -4
  100. package/lib/init/template/containerize/files/containerize.yaml.hbs +26 -0
  101. package/lib/init/template/containerize/index.js +24 -0
  102. package/lib/init/template/data/index.js +4 -0
  103. package/lib/init/template/destination/files/mta.yaml.hbs +25 -1
  104. package/lib/init/template/destination/index.js +12 -2
  105. package/lib/init/template/enterprise-messaging/index.js +6 -3
  106. package/lib/init/template/enterprise-messaging-shared/index.js +5 -1
  107. package/lib/init/template/extensibility/files/package.json.hbs +1 -1
  108. package/lib/init/template/extensibility/files/xs-security.json.hbs +2 -8
  109. package/lib/init/template/extensibility/index.js +3 -1
  110. package/lib/init/template/file-based-messaging/index.js +4 -0
  111. package/lib/init/template/h2/index.js +4 -0
  112. package/lib/init/template/hana/files/containerize.yaml.hbs +10 -0
  113. package/lib/init/template/hana/files/db/package.json +3 -2
  114. package/lib/init/template/hana/files/package.json.hbs +4 -7
  115. package/lib/init/template/hana/files/src/.hdiconfig +3 -0
  116. package/lib/init/template/hana/files/values.yaml.hbs +1 -2
  117. package/lib/init/template/hana/index.js +15 -7
  118. package/lib/init/template/helm/files/Chart.yaml.hbs +2 -3
  119. package/lib/init/template/helm/files/values.schema.json +2173 -0
  120. package/lib/init/template/helm/files/values.yaml.hbs +11 -6
  121. package/lib/init/template/helm/index.js +77 -18
  122. package/lib/init/template/helm-unified-runtime/index.js +19 -56
  123. package/lib/init/template/html5-repo/files/app-package.json.hbs +11 -7
  124. package/lib/init/template/html5-repo/files/manifest.json +13 -0
  125. package/lib/init/template/html5-repo/files/mta.yaml.hbs +41 -8
  126. package/lib/init/template/html5-repo/files/ui5-deploy.yaml.hbs +21 -0
  127. package/lib/init/template/html5-repo/files/ui5.yaml.hbs +2 -29
  128. package/lib/init/template/html5-repo/files/values.yaml.hbs +6 -2
  129. package/lib/init/template/html5-repo/files/xs-app.json.hbs +21 -8
  130. package/lib/init/template/html5-repo/index.js +33 -30
  131. package/lib/init/template/http/index.js +36 -12
  132. package/lib/init/template/java/index.js +18 -12
  133. package/lib/init/template/kafka/index.js +4 -0
  134. package/lib/init/template/lint/index.js +7 -2
  135. package/lib/init/template/liquibase/index.js +4 -0
  136. package/lib/init/template/local-messaging/index.js +4 -0
  137. package/lib/init/template/malware-scanner/files/mta.yaml.hbs +14 -0
  138. package/lib/init/template/malware-scanner/files/package.json.hbs +17 -0
  139. package/lib/init/template/malware-scanner/files/values.yaml +7 -0
  140. package/lib/init/template/malware-scanner/index.js +47 -0
  141. package/lib/init/template/mta/files/mta.yaml.hbs +3 -3
  142. package/lib/init/template/mta/files/package.json +1 -1
  143. package/lib/init/template/mta/index.js +4 -0
  144. package/lib/init/template/mtx/index.js +4 -0
  145. package/lib/init/template/multitenancy/files/containerize.yaml.hbs +10 -0
  146. package/lib/init/template/multitenancy/files/mta.yaml.hbs +0 -1
  147. package/lib/init/template/multitenancy/files/package.json.hbs +1 -1
  148. package/lib/init/template/multitenancy/files/package.sidecar.json.hbs +6 -5
  149. package/lib/init/template/multitenancy/files/values.yaml.hbs +14 -24
  150. package/lib/init/template/multitenancy/index.js +50 -28
  151. package/lib/init/template/nodejs/files/eslint.config.mjs +2 -0
  152. package/lib/init/template/nodejs/files/package.json.hbs +2 -3
  153. package/lib/init/template/nodejs/index.js +4 -0
  154. package/lib/init/template/notifications/files/mta.yaml.hbs +2 -2
  155. package/lib/init/template/notifications/index.js +4 -0
  156. package/lib/init/template/pipeline/files/.pipeline/config.yml +1 -1
  157. package/lib/init/template/pipeline/files/Jenkinsfile +1 -1
  158. package/lib/init/template/pipeline/index.js +4 -0
  159. package/lib/init/template/portal/files/mta.yaml.hbs +52 -0
  160. package/lib/init/template/portal/files/package.json.hbs +11 -0
  161. package/lib/init/template/portal/files/package.sidecar.json +7 -0
  162. package/lib/init/template/portal/files/portal-site/CommonDataModel.json.hbs +97 -0
  163. package/lib/init/template/portal/files/portal-site/i18n/catalog.properties +1 -0
  164. package/lib/init/template/portal/files/portal-site/i18n/catalog_de.properties +1 -0
  165. package/lib/init/template/portal/files/portal-site/i18n/group.properties +1 -0
  166. package/lib/init/template/portal/files/portal-site/i18n/group_de.properties +1 -0
  167. package/lib/init/template/portal/index.js +84 -0
  168. package/lib/init/template/postgres/index.js +5 -1
  169. package/lib/init/template/redis-messaging/index.js +4 -0
  170. package/lib/init/template/sample/files/app/admin-books/webapp/i18n/i18n_de.properties +3 -0
  171. package/lib/init/template/sample/files/app/admin-books/webapp/i18n/i18n_en.properties +3 -0
  172. package/lib/init/template/sample/files/app/admin-books/webapp/manifest.json +13 -1
  173. package/lib/init/template/sample/files/app/browse/webapp/i18n/i18n.properties +2 -2
  174. package/lib/init/template/sample/files/app/browse/webapp/i18n/i18n_de.properties +3 -0
  175. package/lib/init/template/sample/files/app/browse/webapp/i18n/i18n_en.properties +4 -0
  176. package/lib/init/template/sample/files/app/browse/webapp/manifest.json +3 -3
  177. package/lib/init/template/sample/files/app/index.html +1 -1
  178. package/lib/init/template/sample/files/db/data/sap.capire.bookshop-Authors.csv +5 -5
  179. package/lib/init/template/sample/files/db/data/sap.capire.bookshop-Books.csv +6 -6
  180. package/lib/init/template/sample/files/db/data/sap.capire.bookshop-Books_texts.csv +5 -5
  181. package/lib/init/template/sample/files/db/data/sap.capire.bookshop-Genres.csv +16 -16
  182. package/lib/init/template/sample/files/nodejs/cat-service.js +2 -2
  183. package/lib/init/template/sample/files/package.json.hbs +3 -0
  184. package/lib/init/template/sample/index.js +16 -9
  185. package/lib/init/template/sqlite/index.js +4 -0
  186. package/lib/init/template/tiny-sample/files/nodejs/db/data/my.bookshop-Books.csv +3 -3
  187. package/lib/init/template/tiny-sample/files/nodejs/srv/cat-service.cds.hbs +1 -1
  188. package/lib/init/template/tiny-sample/index.js +4 -0
  189. package/lib/init/template/toggles/files/package.json.hbs +1 -1
  190. package/lib/init/template/toggles/index.js +4 -0
  191. package/lib/init/template/typer/index.js +4 -0
  192. package/lib/init/template/typescript/files/package.json +12 -0
  193. package/lib/init/template/typescript/files/tsconfig.json +13 -0
  194. package/lib/init/template/typescript/index.js +39 -0
  195. package/lib/init/template/workzone/index.js +5 -0
  196. package/lib/init/template/workzone-standard/files/manifest.json.hbs +6 -0
  197. package/lib/init/template/workzone-standard/index.js +30 -0
  198. package/lib/init/template/xsuaa/files/package.json.hbs +1 -1
  199. package/lib/init/template/xsuaa/files/values.yaml.hbs +3 -2
  200. package/lib/init/template/xsuaa/index.js +11 -7
  201. package/lib/init/validate.js +27 -0
  202. package/lib/lint/generators.js +1 -1
  203. package/lib/lint/io.js +25 -7
  204. package/lib/mtx/auth_manager.js +64 -30
  205. package/lib/mtx/download_legacy.js +2 -2
  206. package/lib/mtx/index.js +0 -4
  207. package/lib/mtx/params.js +32 -38
  208. package/lib/mtx/pull.js +151 -43
  209. package/lib/mtx/push.js +3 -3
  210. package/lib/mtx/settings_manager.js +75 -35
  211. package/lib/mtx/tenant_action.js +1 -1
  212. package/lib/mtx/util/cf.js +1 -1
  213. package/lib/mtx/util/fs.js +26 -1
  214. package/lib/mtx/util/logging.js +7 -3
  215. package/lib/util/command.js +0 -2
  216. package/lib/util/fs.js +2 -3
  217. package/lib/util/question.js +28 -0
  218. package/lib/util/term.js +5 -3
  219. package/npm-shrinkwrap.json +231 -1089
  220. package/package.json +13 -8
  221. package/bin/activate.js +0 -77
  222. package/lib/compile/asyncapi/channels.js +0 -22
  223. package/lib/compile/asyncapi/components/messageTraits/index.js +0 -89
  224. package/lib/compile/asyncapi/components/messages/index.js +0 -173
  225. package/lib/compile/asyncapi/components/schemas/annotations.js +0 -33
  226. package/lib/compile/asyncapi/components/schemas/array.js +0 -8
  227. package/lib/compile/asyncapi/components/schemas/cache.js +0 -14
  228. package/lib/compile/asyncapi/components/schemas/definition.js +0 -187
  229. package/lib/compile/asyncapi/components/schemas/enum.js +0 -16
  230. package/lib/compile/asyncapi/components/schemas/examples.js +0 -10
  231. package/lib/compile/asyncapi/components/schemas/index.js +0 -14
  232. package/lib/compile/asyncapi/components/schemas/localized.js +0 -29
  233. package/lib/compile/asyncapi/components/schemas/primitiveElement.js +0 -41
  234. package/lib/compile/asyncapi/components/schemas/ref.js +0 -45
  235. package/lib/compile/asyncapi/components/schemas/utils.js +0 -108
  236. package/lib/compile/asyncapi/index.js +0 -247
  237. package/lib/compile/asyncapi/message.js +0 -13
  238. package/lib/compile/asyncapi/utils.js +0 -27
  239. package/lib/compile/openapi/csdl2openapi.js +0 -2448
  240. package/lib/compile/openapi/index.js +0 -68
  241. package/lib/init/template/helm/files/chart/templates/NOTES.txt +0 -14
  242. package/lib/init/template/helm/files/chart/templates/_helpers.tpl +0 -28
  243. package/lib/init/template/helm/files/chart/values.root.schema.json +0 -61
  244. package/lib/init/template/helm/files/chart/values.schema.json +0 -366
  245. package/lib/init/template/helm-unified-runtime/files/Chart.yaml.hbs +0 -10
  246. package/lib/init/template/helm-unified-runtime/files/templates/_deployment_helpers.tpl +0 -90
  247. package/lib/init/template/helm-unified-runtime/files/templates/_helpers.tpl +0 -28
  248. package/lib/init/template/helm-unified-runtime/files/values.root.schema.json +0 -61
  249. package/lib/init/template/helm-unified-runtime/files/values.schema.json +0 -366
  250. package/lib/init/template/helm-unified-runtime/files/values.yaml.hbs +0 -26
  251. package/lib/init/template/helm-unified-runtime/package.json +0 -4
  252. package/lib/init/template/multitenancy/files/mtxs-configmap-java-approuter.yaml +0 -20
  253. package/lib/init/template/multitenancy/files/mtxs-configmap-java.yaml +0 -18
  254. package/lib/init/template/multitenancy/files/mtxs-configmap-nodejs-approuter.yaml +0 -12
  255. package/lib/init/template/multitenancy/files/mtxs-configmap-nodejs.yaml +0 -12
  256. package/lib/init/template/multitenancy/files/saas-registry-secret.yaml +0 -9
  257. package/lib/init/template/nodejs/files/eslint.config.js +0 -13
  258. package/lib/init/template/notebook/index.js +0 -11
  259. package/lib/init/template/samples/index.js +0 -9
  260. package/lib/mtx/activate.js +0 -238
  261. package/lib/mtx/extend.js +0 -173
  262. package/lib/util/exec.d.ts +0 -54
  263. package/lib/util/exec.js +0 -211
  264. /package/lib/{init/template/approuter/files → build/plugins/helm/files/plugins/approuter}/approuter-configmap.yaml +0 -0
  265. /package/lib/{init/template/connectivity/files → build/plugins/helm/files/plugins/connectivity}/connectivity-proxy-info.yaml +0 -0
  266. /package/lib/{init/template/html5-repo/files → build/plugins/helm/files/plugins/html5-repo}/html5-apps-deployer-configmap.yaml +0 -0
  267. /package/lib/{init/template/helm/files → build/plugins/helm/files/subcharts}/content-deployment/templates/_helpers.tpl +0 -0
  268. /package/lib/{init/template/helm/files → build/plugins/helm/files/subcharts}/content-deployment/templates/job.yaml +0 -0
  269. /package/lib/{init/template/helm/files → build/plugins/helm/files/subcharts}/content-deployment/templates/secret.yaml +0 -0
  270. /package/lib/{init/template/helm/files → build/plugins/helm/files/subcharts}/content-deployment/templates/service-account.yaml +0 -0
  271. /package/lib/{init/template/helm/files → build/plugins/helm/files/subcharts}/content-deployment/templates/service-binding.yaml +0 -0
  272. /package/lib/{init/template/helm/files → build/plugins/helm/files/subcharts}/content-deployment/values.schema.json +0 -0
  273. /package/lib/{init/template/helm/files → build/plugins/helm/files/subcharts}/web-application/templates/NOTES.txt +0 -0
  274. /package/lib/{init/template/helm/files → build/plugins/helm/files/subcharts}/web-application/templates/_api.tpl +0 -0
  275. /package/lib/{init/template/helm/files → build/plugins/helm/files/subcharts}/web-application/templates/_helpers.tpl +0 -0
  276. /package/lib/{init/template/helm/files → build/plugins/helm/files/subcharts}/web-application/templates/api-rule.yaml +0 -0
  277. /package/lib/{init/template/helm/files → build/plugins/helm/files/subcharts}/web-application/templates/network-policy.yaml +0 -0
  278. /package/lib/{init/template/helm/files → build/plugins/helm/files/subcharts}/web-application/templates/rbac.yaml +0 -0
  279. /package/lib/{init/template/helm/files → build/plugins/helm/files/subcharts}/web-application/templates/secret.yaml +0 -0
  280. /package/lib/{init/template/helm/files → build/plugins/helm/files/subcharts}/web-application/templates/service-account.yaml +0 -0
  281. /package/lib/{init/template/helm/files → build/plugins/helm/files/subcharts}/web-application/templates/service-binding.yaml +0 -0
  282. /package/lib/{init/template/helm/files → build/plugins/helm/files/subcharts}/web-application/templates/service.yaml +0 -0
  283. /package/lib/{init/template/helm/files → build/plugins/helm/files/subcharts}/web-application/templates/virtual-service.yaml +0 -0
  284. /package/lib/{init/template/helm-unified-runtime → build/plugins/helm}/files/templates/NOTES.txt +0 -0
  285. /package/lib/init/template/{nodejs/files → java}/.cdsrc.json +0 -0
  286. /package/lib/init/template/tiny-sample/files/nodejs/db/{data-model.cds → schema.cds} +0 -0
@@ -77,6 +77,7 @@ function _initialize(parserContext) {
77
77
  parserContext.allInheritedEntityTypes = [];
78
78
  parserContext.allowedNamespaces = [];
79
79
  parserContext.allowAllNamespaces = false;
80
+ parserContext.mockServerUc = true;
80
81
  }
81
82
 
82
83
  // Function to extract allowed namespace attributes from given set of attributes
@@ -138,12 +139,16 @@ function _isValidEDMX(jsonObj) {
138
139
  return isValid;
139
140
  }
140
141
 
141
- function _hasEntityContainer(jsonObj) {
142
- let isEntityContainerPresent = !!jsonObj["edmx:Edmx"]["edmx:DataServices"].Schema.EntityContainer;
143
- if (!isEntityContainerPresent) {
144
- throw new Error(messages.MISSING_ENTITY_CONTAINER);
142
+ function _settingMockServerUc(jsonObj, parserContext) {
143
+ let EntityContainerObj = jsonObj["edmx:Edmx"]["edmx:DataServices"].Schema.EntityContainer;
144
+ // Setting mockerserverUc to false when there is no EntityContainer or when the EntityContainer exists but has no elements inside it
145
+ if (!EntityContainerObj || (EntityContainerObj && !EntityContainerObj.EntitySet && !EntityContainerObj.FunctionImport && !EntityContainerObj.AssociationSet)) {
146
+ parserContext.mockServerUc = false;
147
+ }
148
+ // Importer throws an error if AssociationSet is present without corresponding entitySets
149
+ else if ((EntityContainerObj && !EntityContainerObj.EntitySet && EntityContainerObj.AssociationSet)) {
150
+ throw new Error(messages.MISSING_ENTITY_SETS);
145
151
  }
146
- return isEntityContainerPresent;
147
152
  }
148
153
 
149
154
  function _isValidEDMXProvided(jsonObj) {
@@ -156,13 +161,6 @@ function _isValidEDMXProvided(jsonObj) {
156
161
  return isValid;
157
162
  }
158
163
 
159
- function _validateEDMX(jsonObj) {
160
- return (
161
- _isValidEDMXProvided(jsonObj) &&
162
- _hasEntityContainer(jsonObj)
163
- );
164
- }
165
-
166
164
  function _getServiceNameSpace(jsonObj) {
167
165
  let schemaArr = jsonObj["edmx:Edmx"]["edmx:DataServices"].Schema;
168
166
  let schema = schemaArr;
@@ -183,12 +181,21 @@ function _getServiceNameSpace(jsonObj) {
183
181
  return null;
184
182
  }
185
183
 
184
+ function _checkAssociation(associationSet, parserContext) {
185
+ Object.keys(associationSet).forEach((i) => {
186
+ if (!parserContext.allEntitiesMC.includes(associationSet[i]._attributes.EntitySet)) {
187
+ throw new Error(messages.UNRESOLVED_TYPE + `'${associationSet[i]._attributes.EntitySet}'`);
188
+ }
189
+ });
190
+ }
191
+
186
192
  function _extractAssociationSet(associationSet, parserContext) {
187
193
  let associations = {};
188
194
  Object.keys(associationSet).forEach((key) => {
189
195
  if (key === "_attributes") {
190
196
  associations.Name = associationSet[key].Name;
191
197
  associations.End = associationSet.End;
198
+ _checkAssociation(associations.End, parserContext);
192
199
  parserContext.allAssociationSets[associationSet[key].Association] = associations;
193
200
  }
194
201
  });
@@ -319,8 +326,23 @@ function _extractFunctionImport(functionImport, parserContext) {
319
326
  });
320
327
  }
321
328
 
329
+ function _checkFunctionImports(functionImports, parserContext) {
330
+ if(functionImports.length) {
331
+ functionImports.forEach((functionImport) => {
332
+ if (functionImport._attributes.EntitySet && !parserContext.allEntitiesMC.includes(functionImport._attributes.EntitySet)) {
333
+ throw new Error(messages.UNRESOLVED_TYPE + `'${functionImport._attributes.EntitySet}'`);
334
+ }
335
+ });
336
+ } else {
337
+ if (functionImports._attributes.EntitySet && !parserContext.allEntitiesMC.includes(functionImports._attributes.EntitySet)) {
338
+ throw new Error(messages.UNRESOLVED_TYPE + `'${functionImports._attributes.EntitySet}'`);
339
+ }
340
+ }
341
+ }
342
+
322
343
  //extracting the function imports from the metadata
323
344
  function _extractAllFunctionImports(functionImports, parserContext) {
345
+ _checkFunctionImports(functionImports, parserContext)
324
346
  if (functionImports.length) {
325
347
  //Has many function imports in metadata
326
348
  for (let i = 0; i < functionImports.length; i++) {
@@ -1077,19 +1099,19 @@ function _generateCSNEntityProperties(entityKeysList, entityPropertiesMap, parse
1077
1099
  return csnEntity;
1078
1100
  }
1079
1101
 
1080
- function _getAssociatedEntity(associationEnds, toRole, isAssociationSetMissing, mockServerUc, parserContext) {
1102
+ function _getAssociatedEntity(associationEnds, toRole, isAssociationSetMissing, parserContext) {
1081
1103
  let entityName;
1082
1104
  let entitySetName;
1083
1105
  let entityTypeName;
1084
1106
  Object.keys(associationEnds).forEach((i) => {
1085
1107
  if (toRole === associationEnds[i]._attributes.Role) {
1086
- if (isAssociationSetMissing) {
1108
+ if (isAssociationSetMissing && parserContext.mockServerUc) {
1087
1109
  entityTypeName = associationEnds[i]._attributes.Type;
1088
1110
  entitySetName = parserContext.allEntitySetMapMC[entityTypeName][0];
1089
- } else {
1111
+ } else {
1090
1112
  entitySetName = associationEnds[i]._attributes.EntitySet;
1091
1113
  }
1092
- if (mockServerUc) {
1114
+ if (parserContext.mockServerUc) {
1093
1115
  entityName = parserContext.serviceNamespace + "." + entitySetName;
1094
1116
  } else {
1095
1117
  entityName = parserContext.allEntitySetMap[entitySetName];
@@ -1099,7 +1121,7 @@ function _getAssociatedEntity(associationEnds, toRole, isAssociationSetMissing,
1099
1121
  return entityName;
1100
1122
  }
1101
1123
 
1102
- function _getCSNMultiplicity(associationEnds, toRole, entityName, mockServerUc, parserContext) {
1124
+ function _getCSNMultiplicity(associationEnds, toRole, entityName, parserContext) {
1103
1125
  let csn = "";
1104
1126
  let multiplicity;
1105
1127
  let attributes;
@@ -1107,7 +1129,7 @@ function _getCSNMultiplicity(associationEnds, toRole, entityName, mockServerUc,
1107
1129
  Object.keys(associationEnds).forEach((i) => {
1108
1130
  if (!stop) {
1109
1131
  attributes = associationEnds[i]._attributes;
1110
- if (mockServerUc) {
1132
+ if (parserContext.mockServerUc) {
1111
1133
  let entityNameWithOutNS = parserContext.allEntitySetMap[_extractEntityFromNamespace(entityName)];
1112
1134
  if (
1113
1135
  toRole === attributes.Role &&
@@ -1121,7 +1143,7 @@ function _getCSNMultiplicity(associationEnds, toRole, entityName, mockServerUc,
1121
1143
  toRole === attributes.Role &&
1122
1144
  entityName === attributes.Type
1123
1145
  ) {
1124
- // eslint-disable-line no-lonely-if
1146
+
1125
1147
  multiplicity = attributes.Multiplicity;
1126
1148
  stop = true;
1127
1149
  }
@@ -1140,137 +1162,15 @@ function _getCSNMultiplicity(associationEnds, toRole, entityName, mockServerUc,
1140
1162
  return csn;
1141
1163
  }
1142
1164
 
1143
- function _getCSNRefrenentialCondition(navPropName, from, to) {
1144
- let csn = "{\n";
1145
- csn = csn + '"ref": [\n';
1146
- csn = csn + '"' + navPropName + '",\n';
1147
- csn = csn + '"' + from + '"\n';
1148
- csn = csn + "]\n";
1149
- csn = csn + "},\n";
1150
-
1151
- csn = csn + '"=",\n';
1152
-
1153
- csn = csn + "{\n";
1154
- csn = csn + '"ref": [\n';
1155
- csn = csn + '"' + to + '"';
1156
- csn = csn + "]\n";
1157
- csn = csn + "}\n";
1158
- return csn;
1159
- }
1160
-
1161
- function _getCSNMultipleRefrenentialConditions(refConstraints, navPropName, role) {
1162
- let csn = "";
1163
- csn = csn + '"on": [\n';
1164
- Object.keys(refConstraints).forEach((i) => {
1165
- let roleName = refConstraints[i].Principal._attributes.Role;
1166
- let principalProperties = refConstraints[i].Principal.PropertyRef;
1167
- let dependentProperties = refConstraints[i].Dependent.PropertyRef;
1168
- let from = "";
1169
- let to = "";
1170
- if (roleName && roleName === role) {
1171
- from = principalProperties._attributes.Name;
1172
- to = dependentProperties._attributes.Name;
1173
- } else {
1174
- from = dependentProperties._attributes.Name;
1175
- to = principalProperties._attributes.Name;
1176
- }
1177
- csn = csn + _getCSNRefrenentialCondition(navPropName, from, to);
1178
- if (i < refConstraints.length - 1) {
1179
- csn = csn + ",\n";
1180
- csn = csn + '"and",\n';
1181
- }
1182
- });
1183
- csn = csn + "]\n";
1184
- return csn;
1185
- }
1186
-
1187
- function _getCSNRefrenentialConditions(refConstraints, navPropName, role) {
1188
- let csn = "";
1189
- let from;
1190
- let to;
1191
- let roleName = refConstraints.Principal._attributes.Role;
1192
- let principalProperties = refConstraints.Principal.PropertyRef;
1193
- let dependentProperties = refConstraints.Dependent.PropertyRef;
1194
- if (dependentProperties.length > 0) {
1195
- // Multiple principal and dependents within Referential Constraint
1196
- csn = csn + '"on": [\n';
1197
- Object.keys(dependentProperties).forEach((i) => {
1198
- if (roleName && roleName === role) {
1199
- from = principalProperties[i]._attributes.Name;
1200
- to = dependentProperties[i]._attributes.Name;
1201
- } else {
1202
- from = dependentProperties[i]._attributes.Name;
1203
- to = principalProperties[i]._attributes.Name;
1204
- }
1205
- csn = csn + _getCSNRefrenentialCondition(navPropName, from, to);
1206
- if (i < dependentProperties.length - 1) {
1207
- csn = csn + ",\n";
1208
- csn = csn + '"and",\n';
1209
- }
1210
- });
1211
- csn = csn + "]\n";
1212
- } else {
1213
- // Single principal and dependents within Referential Constraint
1214
- csn = csn + '"on": [\n';
1215
- if (roleName && roleName === role) {
1216
- from = principalProperties._attributes.Name;
1217
- to = dependentProperties._attributes.Name;
1218
- } else {
1219
- from = dependentProperties._attributes.Name;
1220
- to = principalProperties._attributes.Name;
1221
- }
1222
- csn = csn + _getCSNRefrenentialCondition(navPropName, from, to);
1223
- csn = csn + "]\n";
1224
- }
1225
- return csn;
1226
- }
1227
-
1228
- function _getCSNRefrenentialConstraints(associations, navPropName, toRole) {
1229
- let csn = "";
1230
- let endProperties;
1231
- let matchingRole = "";
1232
- let refConstraints = associations.ReferentialConstraint;
1233
- if (!refConstraints) {
1234
- return csn;
1235
- }
1236
- endProperties = associations.End;
1237
- Object.keys(endProperties).forEach((i) => {
1238
- let role = endProperties[i]._attributes.Role;
1239
- if (role && role === toRole) {
1240
- matchingRole = endProperties[i]._attributes.Role;
1241
- }
1242
- });
1243
- if (refConstraints.length > 0) {
1244
- // Multiple referential constraints within Association
1245
- csn = csn +
1246
- _getCSNMultipleRefrenentialConditions(
1247
- refConstraints,
1248
- navPropName,
1249
- matchingRole
1250
- );
1251
- } else {
1252
- // Single referential constraint within Association
1253
- csn = csn +
1254
- _getCSNRefrenentialConditions(
1255
- refConstraints,
1256
- navPropName,
1257
- matchingRole
1258
- );
1259
- }
1260
- return csn;
1261
- }
1262
-
1263
1165
  function _getCSNAssociatedRefrenentialConstraints(
1264
1166
  associations,
1265
1167
  toRole,
1266
1168
  entityName,
1267
1169
  navPropName,
1268
- mockServerUc,
1269
1170
  parserContext
1270
1171
  ) {
1271
1172
  let csn = "";
1272
1173
  let multiplicity;
1273
- let referentialConstraint;
1274
1174
  csn = csn + '"target": "' + entityName + '"';
1275
1175
  if (!associations) {
1276
1176
  return csn;
@@ -1279,21 +1179,12 @@ function _getCSNAssociatedRefrenentialConstraints(
1279
1179
  associations.End,
1280
1180
  toRole,
1281
1181
  entityName,
1282
- mockServerUc,
1283
1182
  parserContext
1284
1183
  );
1285
1184
  if (multiplicity) {
1286
1185
  csn = csn + ",\n" + multiplicity;
1287
1186
  }
1288
- referentialConstraint = _getCSNRefrenentialConstraints(
1289
- associations,
1290
- navPropName,
1291
- toRole,
1292
- mockServerUc
1293
- );
1294
- if (referentialConstraint) {
1295
- csn = csn + ",\n" + referentialConstraint;
1296
- }
1187
+
1297
1188
  return csn;
1298
1189
  }
1299
1190
 
@@ -1301,7 +1192,6 @@ function _getCSNAssociatedEntitySet(
1301
1192
  relationshipName,
1302
1193
  toRole,
1303
1194
  navPropName,
1304
- mockServerUc,
1305
1195
  parserContext
1306
1196
  ) {
1307
1197
  let associationSet = parserContext.allAssociationSets[relationshipName];
@@ -1313,13 +1203,11 @@ function _getCSNAssociatedEntitySet(
1313
1203
  if (associationSet === undefined) {
1314
1204
  isAssociationSetMissing = true;
1315
1205
  }
1316
-
1317
1206
  let associationEnd = associationSet ? associationSet.End : association.End;
1318
1207
  let entityName = _getAssociatedEntity(
1319
1208
  associationEnd,
1320
1209
  toRole,
1321
1210
  isAssociationSetMissing,
1322
- mockServerUc,
1323
1211
  parserContext
1324
1212
  );
1325
1213
  let differentAssociationNames;
@@ -1341,7 +1229,6 @@ function _getCSNAssociatedEntitySet(
1341
1229
  toRole,
1342
1230
  entityName,
1343
1231
  navPropName,
1344
- mockServerUc,
1345
1232
  parserContext
1346
1233
  );
1347
1234
  }
@@ -1371,7 +1258,7 @@ function _findAssociationType(relationshipName, fromRole, parserContext) {
1371
1258
  return '"type": "cds.' + (associationType === "composition" ? 'Composition"' : 'Association"') + ',\n';
1372
1259
  }
1373
1260
 
1374
- function _getServiceEntityNavigationProperty(navPropAttributes, mockServerUc, parserContext) {
1261
+ function _getServiceEntityNavigationProperty(navPropAttributes, parserContext) {
1375
1262
  let csn = "";
1376
1263
  let navPropName;
1377
1264
  let relationshipName;
@@ -1392,12 +1279,6 @@ function _getServiceEntityNavigationProperty(navPropAttributes, mockServerUc, pa
1392
1279
  if (allowedNamespaceAttributes.length) {
1393
1280
  csn += _generateNamespaceAttributes(allowedNamespaceAttributes, false);
1394
1281
  }
1395
- // annotation for on conditions
1396
- csn = csn + `"@cds.ambiguous": "missing on condition?",\n`;
1397
-
1398
- //Code for notNull working but change is not reflecting when we use: cds compile {file-path} -2 edmx > {newFileName}
1399
- /*if (navPropAttributes.Nullable === "false")
1400
- csn = csn + '"notNull": true,\n';*/
1401
1282
 
1402
1283
  // if documentation exists for navigation property
1403
1284
  if (navPropDoc)
@@ -1409,7 +1290,6 @@ function _getServiceEntityNavigationProperty(navPropAttributes, mockServerUc, pa
1409
1290
  relationshipName,
1410
1291
  toRole,
1411
1292
  navPropName,
1412
- mockServerUc,
1413
1293
  parserContext
1414
1294
  );
1415
1295
  // Convert managed associations and compositions in unmanaged with empty key to avoid
@@ -1425,7 +1305,6 @@ function _getServiceEntityNavigationProperty(navPropAttributes, mockServerUc, pa
1425
1305
  function _generateCSNEntityNavigationProperties(
1426
1306
  entityNavigationPropertiesMap,
1427
1307
  hasProperties,
1428
- mockServerUc,
1429
1308
  parserContext
1430
1309
  ) {
1431
1310
  let csn = "";
@@ -1447,7 +1326,6 @@ function _generateCSNEntityNavigationProperties(
1447
1326
  csn = csn +
1448
1327
  _getServiceEntityNavigationProperty(
1449
1328
  navPropAttributes,
1450
- mockServerUc,
1451
1329
  parserContext
1452
1330
  );
1453
1331
  if (i < entityNavProperties.length - 1) {
@@ -1474,7 +1352,6 @@ function _constructServiceEntity(
1474
1352
  entityNavigationPropertiesMap,
1475
1353
  entityAttributes,
1476
1354
  ignorePersistenceSkip,
1477
- mockServerUc,
1478
1355
  documentation,
1479
1356
  parserContext
1480
1357
  ) {
@@ -1547,7 +1424,6 @@ function _constructServiceEntity(
1547
1424
  _generateCSNEntityNavigationProperties(
1548
1425
  entityNavigationPropertiesMap,
1549
1426
  hasProperties,
1550
- mockServerUc,
1551
1427
  parserContext
1552
1428
  );
1553
1429
  csnEntity = csnEntity + "}\n";
@@ -1591,7 +1467,7 @@ function _addBlobElement(properties) {
1591
1467
  properties['blob'] = blobElement;
1592
1468
  }
1593
1469
 
1594
- function _parseServiceEntity(entityName, entity, ignorePersistenceSkip, mockServerUc, parserContext) {
1470
+ function _parseServiceEntity(entityName, entity, ignorePersistenceSkip, parserContext) {
1595
1471
  let entityAttributes;
1596
1472
  let entityKeysList;
1597
1473
  let entityPropertiesMap;
@@ -1642,18 +1518,17 @@ function _parseServiceEntity(entityName, entity, ignorePersistenceSkip, mockServ
1642
1518
  entityNavigationPropertiesMap,
1643
1519
  entityAttributes,
1644
1520
  ignorePersistenceSkip,
1645
- mockServerUc,
1646
1521
  documentation,
1647
1522
  parserContext
1648
1523
  );
1649
1524
  }
1650
1525
 
1651
- function _getEntitesWithNamesFromEntitySets(entityJson, mockServerUc, parserContext) {
1652
- const getEntityName = mockServerUc
1526
+ function _getEntitesWithNamesFromEntitySets(entityJson, parserContext) {
1527
+ const getEntityName = parserContext.mockServerUc
1653
1528
  ? (entity) => parserContext.allEntitySetMapMC[parserContext.serviceNamespace + "." + _getEntityName(entity)]
1654
1529
  : (entity) => [_getEntityName(entity)];
1655
1530
 
1656
- const isNameInEntitySet = mockServerUc
1531
+ const isNameInEntitySet = parserContext.mockServerUc
1657
1532
  ? (name) => parserContext.allEntitiesMC.indexOf(name) >= 0
1658
1533
  : (name) => parserContext.allEntities.indexOf(name) >= 0;
1659
1534
 
@@ -1693,31 +1568,30 @@ function _getEntitesWithNamesFromEntityTypes(entityJson, parserContext) {
1693
1568
  return entities;
1694
1569
  }
1695
1570
 
1696
- function _parsingServiceEntities(entitiesWithNames, ignorePersistenceSkip, mockServerUc, parserContext) {
1571
+ function _parsingServiceEntities(entitiesWithNames, ignorePersistenceSkip, parserContext) {
1697
1572
  return entitiesWithNames.map((entityWithName) =>
1698
1573
  entityWithName.name.map((entityName) =>
1699
1574
  _parseServiceEntity(
1700
1575
  entityName,
1701
1576
  entityWithName.entity,
1702
1577
  ignorePersistenceSkip,
1703
- mockServerUc,
1704
1578
  parserContext
1705
1579
  )
1706
1580
  ).join("},") + "}"
1707
1581
  );
1708
1582
  }
1709
1583
 
1710
- function _getServiceEntitites(entityJson = [], ignorePersistenceSkip, mockServerUc, parserContext) {
1584
+ function _getServiceEntitites(entityJson = [], ignorePersistenceSkip, parserContext) {
1711
1585
  const entities = Array.isArray(entityJson) ? entityJson : [entityJson];
1712
1586
  let entitiesWithNames = []; // [0]-> entity set, [1]-> entity type
1713
1587
  let parsedEntities = []; // [0]-> entity set, [1]-> entity type
1714
1588
 
1715
- entitiesWithNames[0] = _getEntitesWithNamesFromEntitySets(entities, mockServerUc, parserContext);
1589
+ entitiesWithNames[0] = _getEntitesWithNamesFromEntitySets(entities, parserContext);
1716
1590
  entitiesWithNames[1] = _getEntitesWithNamesFromEntityTypes(entities, parserContext);
1717
1591
 
1718
1592
  for (let i = 0; i < 2; i++) {
1719
1593
  if (entitiesWithNames[i].length) {
1720
- parsedEntities[i] = _parsingServiceEntities(entitiesWithNames[i], ignorePersistenceSkip, mockServerUc, parserContext);
1594
+ parsedEntities[i] = _parsingServiceEntities(entitiesWithNames[i], ignorePersistenceSkip, parserContext);
1721
1595
  }
1722
1596
  }
1723
1597
 
@@ -1747,33 +1621,28 @@ function _getServiceEntitites(entityJson = [], ignorePersistenceSkip, mockServer
1747
1621
  return "";
1748
1622
  }
1749
1623
 
1750
- function _generateEDMXJSON2CSN(jsonObj, ignorePersistenceSkip, mockServerUc, parserContext) {
1624
+ function _checkEntityType(entityJson, parserContext) {
1625
+ const entity = Object.values(entityJson).map(item => item._attributes.Name);
1626
+
1627
+ Object.keys(parserContext.allEntities).forEach((i) => {
1628
+ if (!entity.includes(parserContext.allEntities[i])) {
1629
+ throw new Error(messages.UNRESOLVED_TYPE + `'${parserContext.allEntities[i]}'`);
1630
+ }
1631
+ });
1632
+ }
1633
+
1634
+ function _generateEDMXJSON2CSN(jsonObj, ignorePersistenceSkip, parserContext) {
1751
1635
  const csn = {};
1752
1636
  csn.meta = {};
1753
1637
  csn.meta.creator = 'cds-dk ' + versionInfo;
1754
1638
  csn.$version = '2.0';
1755
1639
  csn.definitions = {};
1756
1640
 
1757
- // Extract association sets
1758
- let associationSets = jsonObj["edmx:Edmx"]["edmx:DataServices"].Schema.EntityContainer.AssociationSet;
1759
- if (associationSets) {
1760
- _extractAllAssociationSets(associationSets, parserContext);
1761
- }
1762
1641
  // Extract associations
1763
1642
  const associations = jsonObj["edmx:Edmx"]["edmx:DataServices"].Schema.Association;
1764
1643
  if (associations) {
1765
1644
  _extractAllAssociations(associations, parserContext);
1766
1645
  }
1767
- // Extract entities from EntitySets
1768
- const entitySets = jsonObj["edmx:Edmx"]["edmx:DataServices"].Schema.EntityContainer.EntitySet;
1769
- if (entitySets) {
1770
- _extractAllEntityFromEntitySets(entitySets, parserContext);
1771
- }
1772
- // Extract function imports
1773
- const functionImports = jsonObj["edmx:Edmx"]["edmx:DataServices"].Schema.EntityContainer.FunctionImport;
1774
- if (functionImports) {
1775
- _extractAllFunctionImports(functionImports, parserContext);
1776
- }
1777
1646
  // Extract complex types
1778
1647
  const complexTypes = jsonObj["edmx:Edmx"]["edmx:DataServices"].Schema.ComplexType;
1779
1648
  if (complexTypes) {
@@ -1784,7 +1653,7 @@ function _generateEDMXJSON2CSN(jsonObj, ignorePersistenceSkip, mockServerUc, par
1784
1653
  const entityJson = jsonObj["edmx:Edmx"]["edmx:DataServices"].Schema.EntityType;
1785
1654
  const definitions = [];
1786
1655
 
1787
- if (mockServerUc) {
1656
+ if (parserContext.mockServerUc) {
1788
1657
  let def = '"' + parserContext.serviceNamespace + '": {"kind": "service"' + ',\n' + '"@cds.external": true';
1789
1658
  let serviceDoc = jsonObj["edmx:Edmx"]["edmx:DataServices"]["Schema"].EntityContainer.Documentation;
1790
1659
  let namespaceAttributes = namespaceAttributeFilter(
@@ -1799,10 +1668,26 @@ function _generateEDMXJSON2CSN(jsonObj, ignorePersistenceSkip, mockServerUc, par
1799
1668
  def += _generateNamespaceAttributes(namespaceAttributes, true);
1800
1669
  def += "}";
1801
1670
  definitions.push(def);
1671
+ // Extract entities from EntitySets
1672
+ const entitySets = jsonObj["edmx:Edmx"]["edmx:DataServices"].Schema.EntityContainer.EntitySet;
1673
+ if (entitySets) {
1674
+ _extractAllEntityFromEntitySets(entitySets, parserContext);
1675
+ _checkEntityType(entityJson, parserContext);
1676
+ }
1677
+ // Extract association sets
1678
+ let associationSets = jsonObj["edmx:Edmx"]["edmx:DataServices"].Schema.EntityContainer.AssociationSet;
1679
+ if (associationSets) {
1680
+ _extractAllAssociationSets(associationSets, parserContext);
1681
+ }
1682
+ // Extract function imports
1683
+ const functionImports = jsonObj["edmx:Edmx"]["edmx:DataServices"].Schema.EntityContainer.FunctionImport;
1684
+ if (functionImports) {
1685
+ _extractAllFunctionImports(functionImports, parserContext);
1686
+ }
1802
1687
  }
1803
1688
 
1804
1689
  if (entityJson) {
1805
- definitions.push(_getServiceEntitites(entityJson, ignorePersistenceSkip, mockServerUc, parserContext));
1690
+ definitions.push(_getServiceEntitites(entityJson, ignorePersistenceSkip, parserContext));
1806
1691
  }
1807
1692
 
1808
1693
  // If complex type exists
@@ -1832,6 +1717,7 @@ function getEdmxv2CSN(edmx2jsonModel, ignorePersistenceSkip, mockServerUc, conte
1832
1717
 
1833
1718
  const parserContext = {};
1834
1719
  _initialize(parserContext);
1720
+ parserContext.mockServerUc = mockServerUc
1835
1721
 
1836
1722
  if (!context.include_all_namespaces && context.namespaces.length) {
1837
1723
  parserContext.allowedNamespaces = parserContext.allowedNamespaces.concat(context.namespaces)
@@ -1840,7 +1726,8 @@ function getEdmxv2CSN(edmx2jsonModel, ignorePersistenceSkip, mockServerUc, conte
1840
1726
  parserContext.allowAllNamespaces = true;
1841
1727
  }
1842
1728
 
1843
- isValid = _validateEDMX(edmx2jsonModel);
1729
+ isValid = _isValidEDMXProvided(edmx2jsonModel);
1730
+ _settingMockServerUc(edmx2jsonModel, parserContext)
1844
1731
  if (isValid) {
1845
1732
  parserContext.serviceNamespace = _getServiceNameSpace(edmx2jsonModel);
1846
1733
  context.schemaNamespace = parserContext.serviceNamespace; // required for `--keep-namespace` scenario
@@ -1853,7 +1740,6 @@ function getEdmxv2CSN(edmx2jsonModel, ignorePersistenceSkip, mockServerUc, conte
1853
1740
  csnDataModel = _generateEDMXJSON2CSN(
1854
1741
  edmx2jsonModel,
1855
1742
  ignorePersistenceSkip,
1856
- mockServerUc,
1857
1743
  parserContext
1858
1744
  );
1859
1745
  }
@@ -636,21 +636,7 @@ function _generateStructuredDataTypeCsn(dataType, propertyObject, isPrimaryKey,
636
636
 
637
637
  function _parseAssociationProperty(foreignReference, associationNode, parserContext) {
638
638
  const associationProperty = {};
639
- let foreignKeys;
640
- // var foreignReference = associationNode.$Type;
641
- let refConstraint = associationNode.$ReferentialConstraint;
642
- let data;
643
- let ref;
644
-
645
639
  associationProperty.type = (associationNode.$OnDelete === 'Cascade') ? 'cds.Composition' : 'cds.Association';
646
- // annotation for ON condition
647
- associationProperty["@cds.ambiguous"] = 'missing on condition?';
648
- // associationProperty.target = associationNode.$Type;
649
-
650
- // Code for NavigationProperty for notNull
651
- // if (!associationProperty.$Nullable) {
652
- // associationProperty["notNull"] = true;
653
- // }
654
640
 
655
641
  let resolvedEntityName;
656
642
  let entityTypeMapping = (
@@ -686,29 +672,6 @@ function _parseAssociationProperty(foreignReference, associationNode, parserCont
686
672
  } else {
687
673
  associationProperty.cardinality.max = 1;
688
674
  }
689
- // on -> "SalesOrders.CustomerID=CustomerID and SalesOrders.Type=Type"
690
- if (refConstraint) {
691
- associationProperty.on = [];
692
- foreignKeys = Object.keys(refConstraint);
693
-
694
- for (let i = 0; i < foreignKeys.length; i++) {
695
- data = {};
696
- ref = [];
697
- ref.push(foreignReference);
698
- ref.push(refConstraint[foreignKeys[i]]);
699
- data.ref = ref;
700
- associationProperty.on.push(data);
701
- associationProperty.on.push('=');
702
- data = {};
703
- ref = [];
704
- ref.push(foreignKeys[i]);
705
- data.ref = ref;
706
- associationProperty.on.push(data);
707
- if (i < foreignKeys.length - 1) {
708
- associationProperty.on.push(' and ');
709
- }
710
- }
711
- }
712
675
  // Convert managed associations and compositions in unmanaged with empty key to avoid
713
676
  // "generation" of keys, that do not exist in the external service.
714
677
  if (common.checkForEmptyKeys(associationProperty, "V4")) {
@@ -1723,7 +1686,7 @@ function _generateEDMX2JSON(edmx, name_space) {
1723
1686
  const v4Conv = MetadataConverterFactory.createEdmxV40XmlToV40Json(name_space);
1724
1687
  v4Conv.execute(inputBuffer, (error, json, missingReferencedDocuments) => {
1725
1688
  if (missingReferencedDocuments?.length > 0) {
1726
- console.log(missingReferencedDocuments); // eslint-disable-line no-console
1689
+ console.log(missingReferencedDocuments);
1727
1690
  }
1728
1691
  resolve(json);
1729
1692
  });