@sap/cds-dk 10.0.7 → 10.1.0

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 (302) hide show
  1. package/CHANGELOG.md +94 -0
  2. package/bin/add.js +7 -23
  3. package/bin/bind.js +10 -0
  4. package/bin/build.js +20 -34
  5. package/bin/cds.js +1 -1
  6. package/bin/compile/index.js +15 -41
  7. package/bin/completion/completionFs.js +11 -8
  8. package/bin/completion/index.js +592 -80
  9. package/bin/completion/scripts/cds.fish +568 -0
  10. package/bin/completion/scripts/cds.ps1 +329 -0
  11. package/bin/completion/scripts/cds.sh +261 -0
  12. package/bin/completion/scripts/cds.zsh +230 -0
  13. package/bin/completion/templates/cds-tmpl.fish +65 -0
  14. package/bin/completion/templates/cds-tmpl.ps1 +208 -0
  15. package/bin/completion/templates/cds-tmpl.sh +93 -0
  16. package/bin/completion/templates/cds-tmpl.zsh +74 -0
  17. package/bin/deploy/index.js +7 -1
  18. package/bin/deploy/options.js +25 -0
  19. package/{lib → bin}/deploy/to-hana/hana.js +8 -8
  20. package/{lib → bin}/deploy/to-hana/hdiDeployUtil.js +1 -1
  21. package/bin/deploy/{to-hana.js → to-hana/index.js} +1 -1
  22. package/{lib → bin}/deploy/to-hana/mtaUtil.js +1 -1
  23. package/bin/deploy/to-sql.js +0 -2
  24. package/bin/export.js +35 -5
  25. package/bin/help/export.md +3 -0
  26. package/bin/help.js +1 -5
  27. package/bin/import.js +6 -0
  28. package/bin/init.js +5 -24
  29. package/bin/inspect.js +6 -0
  30. package/bin/login.js +26 -20
  31. package/bin/pull.js +19 -6
  32. package/bin/push.js +19 -6
  33. package/bin/up.js +14 -11
  34. package/{lib → bin}/upgrade/constants.js +1 -1
  35. package/bin/{upgrade.js → upgrade/index.js} +2 -2
  36. package/{lib → bin}/upgrade/preflight/consistency.js +1 -1
  37. package/{lib → bin}/upgrade/preflight/index.js +1 -1
  38. package/{lib → bin}/upgrade/steps/analyze/index.js +1 -1
  39. package/{lib → bin}/upgrade/steps/install.js +1 -1
  40. package/{lib → bin}/upgrade/steps/openrewrite.js +1 -1
  41. package/{lib → bin}/upgrade/steps/removals.js +1 -1
  42. package/{lib → bin}/upgrade/steps/rewrite.js +1 -1
  43. package/{lib → bin}/upgrade/steps/verify.js +1 -1
  44. package/{lib/upgrade/index.js → bin/upgrade/upgrade.js} +2 -2
  45. package/{lib → bin}/upgrade/util/pom.js +2 -2
  46. package/{lib → bin}/upgrade/util/prompt.js +1 -1
  47. package/bin/util/containerize.js +8 -4
  48. package/bin/version.js +10 -1
  49. package/{lib → bin}/watch/hot-reload.js +1 -1
  50. package/bin/{watch.js → watch/index.js} +17 -9
  51. package/{lib → bin}/watch/livereload-connect.js +1 -1
  52. package/{lib → bin}/watch/vite-watch.js +1 -1
  53. package/{lib → bin}/watch/watched.js +2 -2
  54. package/lib/build/constants.js +1 -1
  55. package/lib/build/plugins/fiori/index.js +31 -2
  56. package/lib/build/plugins/internal.js +4 -2
  57. package/lib/build/plugins/mtx-sidecar/index.js +7 -8
  58. package/lib/build/plugins/nodejs/index.js +64 -7
  59. package/lib/compile/to_asyncapi.js +1 -1
  60. package/lib/env/schema.js +16 -0
  61. package/lib/env/schemas/cds-rc.js +1 -76
  62. package/lib/import/importapi.js +2 -3
  63. package/lib/import/message.js +0 -2
  64. package/lib/init/constants.js +2 -1
  65. package/lib/init/index.js +2 -2
  66. package/lib/init/merge.js +123 -280
  67. package/lib/init/plugin.js +3 -1
  68. package/lib/init/projectReader.js +22 -6
  69. package/lib/init/registries/xs-app.js +3 -5
  70. package/lib/init/template/ai/files/mta.yaml.hbs +1 -1
  71. package/lib/init/template/ai/index.js +14 -2
  72. package/lib/init/template/ams/index.js +2 -2
  73. package/lib/init/template/app-frontend/files/containerize.yaml.hbs +2 -2
  74. package/lib/init/template/app-frontend/index.js +4 -4
  75. package/lib/init/template/application-logging/index.js +2 -2
  76. package/lib/init/template/approuter/files/package.json +1 -1
  77. package/lib/init/template/approuter/index.js +8 -3
  78. package/lib/init/template/attachments/files/package.json.hbs +1 -1
  79. package/lib/init/template/attachments/index.js +2 -2
  80. package/lib/init/template/audit-logging/index.js +2 -2
  81. package/lib/init/template/cloud-logging/files/package.json.hbs +4 -4
  82. package/lib/init/template/cloud-logging/index.js +2 -2
  83. package/lib/init/template/completion/completionSetup.js +36 -39
  84. package/lib/init/template/connectivity/index.js +2 -2
  85. package/lib/init/template/data/as-csv.js +15 -5
  86. package/lib/init/template/data/as-json.js +114 -42
  87. package/lib/init/template/data/index.js +16 -2
  88. package/lib/init/template/destination/index.js +2 -2
  89. package/lib/init/template/dynatrace/files/package.json.hbs +3 -3
  90. package/lib/init/template/dynatrace/index.js +2 -2
  91. package/lib/init/template/enterprise-messaging/index.js +2 -2
  92. package/lib/init/template/enterprise-messaging-shared/index.js +2 -2
  93. package/lib/init/template/extensibility/files/mta.yaml.hbs +11 -0
  94. package/lib/init/template/extensibility/files/xs-security.json.hbs +1 -1
  95. package/lib/init/template/extensibility/index.js +3 -3
  96. package/lib/init/template/github-actions/index.js +2 -2
  97. package/lib/init/template/hana/index.js +3 -2
  98. package/lib/init/template/hana-serverless/files/db/package.json +14 -0
  99. package/lib/init/template/hana-serverless/files/identity.values.yaml.hbs +10 -0
  100. package/lib/init/template/hana-serverless/files/mta.yaml.hbs +64 -0
  101. package/lib/init/template/hana-serverless/files/package.json.hbs +35 -0
  102. package/lib/init/template/hana-serverless/files/src/.hdiconfig +139 -0
  103. package/lib/init/template/hana-serverless/files/undeploy.json +7 -0
  104. package/lib/init/template/hana-serverless/files/values.yaml.hbs +18 -0
  105. package/lib/init/template/hana-serverless/index.js +184 -0
  106. package/lib/init/template/html5-repo/files/containerize.yaml.hbs +2 -2
  107. package/lib/init/template/html5-repo/files/mta.yaml.hbs +5 -0
  108. package/lib/init/template/html5-repo/index.js +18 -14
  109. package/lib/init/template/http/index.js +123 -26
  110. package/lib/init/template/ias/index.js +2 -2
  111. package/lib/init/template/kafka/index.js +2 -2
  112. package/lib/init/template/kyma/index.js +7 -5
  113. package/lib/init/template/malware-scanner/index.js +2 -2
  114. package/lib/init/template/mta/files/mta.yaml.hbs +1 -1
  115. package/lib/init/template/multitenancy/index.js +18 -3
  116. package/lib/init/template/notifications/index.js +2 -2
  117. package/lib/init/template/portal/files/mta.yaml.hbs +4 -0
  118. package/lib/init/template/portal/index.js +13 -8
  119. package/lib/init/template/postgres/index.js +2 -2
  120. package/lib/init/template/redis/index.js +2 -2
  121. package/lib/init/template/sample/files/db/currencies.cds +2 -0
  122. package/lib/init/template/sample/files/db/data/sap.capire.bookshop-Authors.csv +1 -1
  123. package/lib/init/template/tiny-sample/files/nodejs/db/data/CatalogService.Books.csv +2 -2
  124. package/lib/init/template/workzone-standard/index.js +5 -5
  125. package/lib/init/template/xsuaa/index.js +20 -2
  126. package/lib/lint/eslintHelp.json +1 -1
  127. package/lib/mtx/auth_manager.js +103 -37
  128. package/lib/mtx/params.js +3 -2
  129. package/lib/mtx/settings_manager.js +45 -28
  130. package/lib/mtx/tenant_action.js +0 -1
  131. package/lib/mtx/util/credentials.js +62 -0
  132. package/node_modules/@sap/cds/CHANGELOG.md +57 -0
  133. package/node_modules/@sap/cds/app/index.js +5 -4
  134. package/node_modules/@sap/cds/eslint.config.mjs +1 -0
  135. package/node_modules/@sap/cds/lib/compile/minify.js +14 -10
  136. package/node_modules/@sap/cds/lib/env/cds-env.js +1 -1
  137. package/node_modules/@sap/cds/lib/env/cds-requires.js +22 -11
  138. package/node_modules/@sap/cds/lib/env/defaults.js +4 -1
  139. package/node_modules/@sap/cds/lib/env/schemas/cds-rc.js +5 -2
  140. package/node_modules/@sap/cds/lib/plugins.js +9 -5
  141. package/node_modules/@sap/cds/lib/req/spawn.js +1 -1
  142. package/node_modules/@sap/cds/lib/srv/srv-dispatch.js +1 -1
  143. package/node_modules/@sap/cds/lib/srv/srv-models.js +1 -1
  144. package/node_modules/@sap/cds/lib/utils/cds-utils.js +2 -1
  145. package/node_modules/@sap/cds/libx/_runtime/common/generic/assert.js +2 -3
  146. package/node_modules/@sap/cds/libx/_runtime/common/generic/auth/restrict.js +8 -1
  147. package/node_modules/@sap/cds/libx/_runtime/common/generic/crud.js +18 -8
  148. package/node_modules/@sap/cds/libx/_runtime/fiori/lean-draft.js +25 -17
  149. package/node_modules/@sap/cds/libx/_runtime/messaging/enterprise-messaging-utils/registerEndpoints.js +9 -3
  150. package/node_modules/@sap/cds/libx/_runtime/remote/Service.js +4 -19
  151. package/node_modules/@sap/cds/libx/_runtime/remote/utils/LruCache.js +42 -0
  152. package/node_modules/@sap/cds/libx/_runtime/remote/utils/client.js +14 -4
  153. package/node_modules/@sap/cds/libx/_runtime/remote/utils/cloudSdkProvider.js +2 -9
  154. package/node_modules/@sap/cds/libx/_runtime/remote/utils/destinationClient.js +150 -0
  155. package/node_modules/@sap/cds/libx/_runtime/remote/utils/error.js +13 -0
  156. package/node_modules/@sap/cds/libx/_runtime/remote/utils/fetchClient.js +26 -18
  157. package/node_modules/@sap/cds/libx/_runtime/remote/utils/query.js +34 -23
  158. package/node_modules/@sap/cds/libx/_runtime/remote/utils/token.js +82 -0
  159. package/node_modules/@sap/cds/libx/_runtime/ucl/Service.js +36 -189
  160. package/node_modules/@sap/cds/libx/common/utils/streaming.js +16 -16
  161. package/node_modules/@sap/cds/libx/http/location.js +3 -3
  162. package/node_modules/@sap/cds/libx/odata/middleware/batch.js +16 -10
  163. package/node_modules/@sap/cds/libx/odata/middleware/metadata.js +9 -6
  164. package/node_modules/@sap/cds/libx/odata/middleware/service-document.js +1 -1
  165. package/node_modules/@sap/cds/libx/odata/parse/afterburner.js +19 -3
  166. package/node_modules/@sap/cds/libx/odata/parse/cqn2odata.js +83 -86
  167. package/node_modules/@sap/cds/libx/queue/SchedulingService.js +17 -2
  168. package/node_modules/@sap/cds/libx/queue/processing.js +1 -3
  169. package/node_modules/@sap/cds/libx/rest/RestAdapter.js +3 -7
  170. package/node_modules/@sap/cds/libx/rest/middleware/delete.js +3 -3
  171. package/node_modules/@sap/cds/libx/rest/middleware/parse.js +13 -8
  172. package/node_modules/@sap/cds/libx/rest/middleware/read.js +3 -3
  173. package/node_modules/@sap/cds/libx/rest/middleware/upsert.js +2 -2
  174. package/node_modules/@sap/cds/package.json +1 -1
  175. package/node_modules/@sap/cds-compiler/CHANGELOG.md +60 -8
  176. package/node_modules/@sap/cds-compiler/bin/cdsc.js +2 -2
  177. package/node_modules/@sap/cds-compiler/doc/IncompatibleChanges_v7.md +46 -19
  178. package/node_modules/@sap/cds-compiler/lib/api/main.js +10 -7
  179. package/node_modules/@sap/cds-compiler/lib/api/options.js +8 -2
  180. package/node_modules/@sap/cds-compiler/lib/base/csnRefs.js +5 -2
  181. package/node_modules/@sap/cds-compiler/lib/base/message-registry.js +4 -0
  182. package/node_modules/@sap/cds-compiler/lib/base/optionProcessor.js +12 -0
  183. package/node_modules/@sap/cds-compiler/lib/checks/enricher.js +1 -0
  184. package/node_modules/@sap/cds-compiler/lib/compiler/assert-consistency.js +8 -7
  185. package/node_modules/@sap/cds-compiler/lib/compiler/checks.js +3 -3
  186. package/node_modules/@sap/cds-compiler/lib/compiler/define.js +301 -75
  187. package/node_modules/@sap/cds-compiler/lib/compiler/dictionaries.js +2 -0
  188. package/node_modules/@sap/cds-compiler/lib/compiler/extend.js +40 -26
  189. package/node_modules/@sap/cds-compiler/lib/compiler/populate.js +45 -60
  190. package/node_modules/@sap/cds-compiler/lib/compiler/propagator.js +16 -7
  191. package/node_modules/@sap/cds-compiler/lib/compiler/resolve.js +41 -15
  192. package/node_modules/@sap/cds-compiler/lib/compiler/shared.js +7 -6
  193. package/node_modules/@sap/cds-compiler/lib/compiler/tweak-assocs.js +62 -50
  194. package/node_modules/@sap/cds-compiler/lib/compiler/utils.js +29 -14
  195. package/node_modules/@sap/cds-compiler/lib/edm/edmAnnoPreprocessor.js +6 -5
  196. package/node_modules/@sap/cds-compiler/lib/gen/CdlGrammar.checksum +1 -1
  197. package/node_modules/@sap/cds-compiler/lib/gen/CdlParser.js +1119 -1109
  198. package/node_modules/@sap/cds-compiler/lib/gen/Dictionary.json +19 -3
  199. package/node_modules/@sap/cds-compiler/lib/json/from-csn.js +10 -16
  200. package/node_modules/@sap/cds-compiler/lib/json/to-csn.js +58 -39
  201. package/node_modules/@sap/cds-compiler/lib/main.d.ts +8 -0
  202. package/node_modules/@sap/cds-compiler/lib/main.js +1 -0
  203. package/node_modules/@sap/cds-compiler/lib/model/csnUtils.js +2 -0
  204. package/node_modules/@sap/cds-compiler/lib/parsers/AstBuildingParser.js +2 -1
  205. package/node_modules/@sap/cds-compiler/lib/parsers/XprTree.js +8 -0
  206. package/node_modules/@sap/cds-compiler/lib/render/toCdl.js +22 -1
  207. package/node_modules/@sap/cds-compiler/lib/render/toSql.js +17 -2
  208. package/node_modules/@sap/cds-compiler/lib/render/utils/common.js +6 -1
  209. package/node_modules/@sap/cds-compiler/lib/render/utils/operators.js +27 -0
  210. package/node_modules/@sap/cds-compiler/lib/render/utils/standardDatabaseFunctions.js +125 -3
  211. package/node_modules/@sap/cds-compiler/lib/tool-lib/revealInternalProperties.js +2 -1
  212. package/node_modules/@sap/cds-compiler/lib/transform/db/applyTransformations.js +3 -0
  213. package/node_modules/@sap/cds-compiler/lib/transform/db/associations.js +8 -2
  214. package/node_modules/@sap/cds-compiler/lib/transform/db/backlinks.js +22 -6
  215. package/node_modules/@sap/cds-compiler/lib/transform/db/constraints.js +62 -1
  216. package/node_modules/@sap/cds-compiler/lib/transform/effective/annotations.js +40 -0
  217. package/node_modules/@sap/cds-compiler/lib/transform/effective/main.js +1 -0
  218. package/node_modules/@sap/cds-compiler/lib/transform/forRelationalDB.js +6 -1
  219. package/node_modules/@sap/cds-compiler/lib/transform/translateAssocsToJoins.js +19 -8
  220. package/node_modules/@sap/cds-compiler/package.json +1 -1
  221. package/node_modules/@sap/cds-mtxs/CHANGELOG.md +15 -0
  222. package/node_modules/@sap/cds-mtxs/bin/cds-mtx.js +34 -16
  223. package/node_modules/@sap/cds-mtxs/lib/utils.js +19 -4
  224. package/node_modules/@sap/cds-mtxs/package.json +1 -1
  225. package/node_modules/@sap/cds-mtxs/srv/cf/abstract-provisioning-service.js +1 -1
  226. package/node_modules/@sap/cds-mtxs/srv/extensibility-service.js +22 -13
  227. package/node_modules/@sap/cds-mtxs/srv/model-provider.js +17 -2
  228. package/node_modules/@sap/cds-mtxs/srv/plugins/hana/ctnr-mgr-base.js +1 -1
  229. package/node_modules/@sap/cds-mtxs/srv/plugins/hana.js +4 -8
  230. package/node_modules/@sap/xsenv/CHANGELOG.md +7 -0
  231. package/node_modules/@sap/xsenv/package.json +10 -7
  232. package/node_modules/body-parser/node_modules/content-type/README.md +2 -0
  233. package/node_modules/body-parser/node_modules/content-type/dist/index.d.ts +20 -0
  234. package/node_modules/body-parser/node_modules/content-type/dist/index.js +20 -14
  235. package/node_modules/body-parser/node_modules/content-type/dist/index.js.map +1 -1
  236. package/node_modules/body-parser/node_modules/content-type/package.json +1 -1
  237. package/node_modules/hdb/cfg/VERSION +1 -1
  238. package/node_modules/hdb/lib/protocol/ClientInfo.js +16 -3
  239. package/node_modules/hdb/lib/protocol/Connection.js +1 -0
  240. package/node_modules/hdb/package.json +3 -2
  241. package/node_modules/negotiator/lib/accept.js +54 -0
  242. package/node_modules/negotiator/lib/charset.js +10 -34
  243. package/node_modules/negotiator/lib/encoding.js +9 -30
  244. package/node_modules/negotiator/lib/language.js +15 -36
  245. package/node_modules/negotiator/lib/mediaType.js +16 -134
  246. package/node_modules/negotiator/node_modules/content-type/LICENSE +22 -0
  247. package/node_modules/negotiator/node_modules/content-type/README.md +71 -0
  248. package/node_modules/negotiator/node_modules/content-type/dist/index.d.ts +46 -0
  249. package/node_modules/negotiator/node_modules/content-type/dist/index.js +176 -0
  250. package/node_modules/negotiator/node_modules/content-type/dist/index.js.map +1 -0
  251. package/node_modules/negotiator/node_modules/content-type/package.json +52 -0
  252. package/node_modules/negotiator/package.json +16 -10
  253. package/node_modules/qs/.github/THREAT_MODEL.md +3 -3
  254. package/node_modules/qs/CHANGELOG.md +15 -0
  255. package/node_modules/qs/README.md +19 -1
  256. package/node_modules/qs/dist/qs.js +21 -21
  257. package/node_modules/qs/eslint.config.mjs +1 -1
  258. package/node_modules/qs/lib/parse.js +3 -4
  259. package/node_modules/qs/lib/stringify.js +23 -8
  260. package/node_modules/qs/lib/utils.js +10 -3
  261. package/node_modules/qs/package.json +4 -4
  262. package/node_modules/qs/test/parse.js +192 -3
  263. package/node_modules/qs/test/stringify.js +317 -0
  264. package/node_modules/qs/test/utils.js +12 -0
  265. package/node_modules/type-is/node_modules/content-type/README.md +2 -0
  266. package/node_modules/type-is/node_modules/content-type/dist/index.d.ts +20 -0
  267. package/node_modules/type-is/node_modules/content-type/dist/index.js +20 -14
  268. package/node_modules/type-is/node_modules/content-type/dist/index.js.map +1 -1
  269. package/node_modules/type-is/node_modules/content-type/package.json +1 -1
  270. package/node_modules/ws/lib/permessage-deflate.js +3 -1
  271. package/node_modules/ws/package.json +1 -1
  272. package/package.json +3 -3
  273. package/bin/completion/scripts/cds-bash.sh +0 -20
  274. package/bin/completion/scripts/cds-fish.fish +0 -13
  275. package/bin/completion/scripts/cds-ps.ps1 +0 -19
  276. package/bin/completion/scripts/cds-zsh.sh +0 -13
  277. package/lib/deploy/index.js +0 -25
  278. package/lib/import/asyncapi/importAsyncAPI.js +0 -33
  279. package/lib/import/asyncapi/index.js +0 -18
  280. package/lib/import/asyncapi/parserContext.js +0 -454
  281. package/lib/import/asyncapi/utils.js +0 -49
  282. package/node_modules/@sap/cds/libx/_runtime/ucl/queries.js +0 -61
  283. package/node_modules/negotiator/HISTORY.md +0 -114
  284. /package/{lib → bin}/upgrade/context.js +0 -0
  285. /package/{lib → bin}/upgrade/migrations/cds10/migrations.json +0 -0
  286. /package/{lib → bin}/upgrade/preflight/cds-version.js +0 -0
  287. /package/{lib → bin}/upgrade/preflight/project-type.js +0 -0
  288. /package/{lib → bin}/upgrade/steps/analyze/classification.js +0 -0
  289. /package/{lib → bin}/upgrade/steps/analyze/detector.js +0 -0
  290. /package/{lib → bin}/upgrade/steps/analyze/evaluator.js +0 -0
  291. /package/{lib → bin}/upgrade/steps/analyze/reporter.js +0 -0
  292. /package/{lib → bin}/upgrade/steps/analyze/setup.js +0 -0
  293. /package/{lib → bin}/upgrade/steps/analyze/utils/detection.js +0 -0
  294. /package/{lib → bin}/upgrade/steps/analyze/utils/files.js +0 -0
  295. /package/{lib → bin}/upgrade/steps/analyze/utils/grep.js +0 -0
  296. /package/{lib → bin}/upgrade/steps/analyze/utils/yaml.js +0 -0
  297. /package/{lib → bin}/upgrade/util/workspaces.js +0 -0
  298. /package/{lib → bin}/watch/esm-resolve-registration.js +0 -0
  299. /package/{lib → bin}/watch/livereload-server.js +0 -0
  300. /package/{lib → bin}/watch/node-watch.js +0 -0
  301. /package/{lib → bin}/watch/open.js +0 -0
  302. /package/{lib → bin}/watch/watcher.js +0 -0
@@ -93,6 +93,10 @@ function tweakAssocs( model ) {
93
93
 
94
94
  if (art.query) {
95
95
  traverseQueryPost(art.query, null, (query) => {
96
+ forEachGeneric( query, '$tableAliases', ( mixin ) => {
97
+ if (mixin.$backlink?._redirected)
98
+ pushLink( model, '_associations', mixin );
99
+ } );
96
100
  forEachGeneric( query, 'elements', handleQueryElements );
97
101
  });
98
102
  }
@@ -338,16 +342,6 @@ function tweakAssocs( model ) {
338
342
  }
339
343
 
340
344
  function propagateBacklink( assoc, _originAssoc ) {
341
- // const origin = originAssoc.$backlink;
342
- // if (assoc.target._artifact === originAssoc.target._artifact) {
343
- // // no redirection → backlink is the same → no need to traverse ON-condition
344
- // const backlink = { location: weakLocation( origin.location ), target: {} };
345
- // setLink( backlink, '_origin', origin._origin );
346
- // setLink( backlink, '_outer', assoc );
347
- // assoc.$backlink = backlink;
348
- // // TODO: _redirected
349
- // }
350
- // else {
351
345
  checkBacklinkPartner( assoc );
352
346
  // console.log('PB:',assoc._main.name.id,assoc.name.id,originAssoc.name.id,
353
347
  // !!originAssoc.on,!!assoc.on,!!assoc.$backlink)
@@ -370,17 +364,21 @@ function tweakAssocs( model ) {
370
364
  setLink( backlink, '_redirected', null ); // no further processing
371
365
  return;
372
366
  }
373
- if (backlink._redirected?.length === 0)
367
+ if (!backlink._redirected?.length)
374
368
  return;
375
369
  // all of the following necessary?
376
370
  setLink( backlink, '_main', elem._main );
377
371
  setLink( backlink, '_parent', elem._parent );
378
372
  setLink( backlink, '_effectiveType', backlink );
379
373
  backlink.name = origin.name;
380
- if (origin.on)
374
+ if (origin.on) {
381
375
  rewriteCondition( backlink, origin );
382
- else if (origin.foreignKeys)
383
- rewriteKeys( backlink, origin );
376
+ if (backlink.$errorReported)
377
+ setLink( backlink, '_redirected', null ); // no further processing
378
+ }
379
+ else if (rewriteKeys( backlink, origin )) {
380
+ setLink( backlink, '_redirected', null ); // no further processing
381
+ }
384
382
  }
385
383
 
386
384
  /**
@@ -419,10 +417,11 @@ function tweakAssocs( model ) {
419
417
  function rewriteKeys( elem, assoc ) {
420
418
  addConditionFromAssocPublishing( elem, assoc, null );
421
419
  if (elem.on)
422
- return; // foreign keys were transformed into ON-condition
420
+ return false; // foreign keys were transformed into ON-condition
423
421
 
424
422
  // TODO: split this function: create foreign keys without `targetElement`
425
423
  // already in Phase 2: redirectImplicitly()
424
+ let withIssue = false;
426
425
  elem.foreignKeys = Object.create(null); // set already here (also for zero foreign keys)
427
426
  forEachInOrder( assoc, 'foreignKeys', ( orig, name ) => {
428
427
  const location = weakRefLocation( elem.target );
@@ -431,10 +430,11 @@ function tweakAssocs( model ) {
431
430
  setLink( fk, '_effectiveType', fk );
432
431
  fk.targetElement = copyExpr( orig.targetElement, location );
433
432
  if (elem._redirected)
434
- rewriteKey( elem, fk );
433
+ withIssue = rewriteKey( elem, fk ) || withIssue;
435
434
  } );
436
435
  if (elem.foreignKeys) // Possibly no fk was set
437
436
  elem.foreignKeys[$inferred] = 'rewrite';
437
+ return withIssue;
438
438
  }
439
439
 
440
440
  function rewriteKey( elem, fk ) {
@@ -458,8 +458,9 @@ function tweakAssocs( model ) {
458
458
  message( 'ref-missing-backlink-element',
459
459
  [ (outer.value || outer.name).location, outer ],
460
460
  { '#': (outer.value ? 'std' : 'def'), id: undef.id } );
461
- // TODO: more info if element was already missing in "intermediate" projection
462
- // TODO: collect all missing elements?
461
+ // TODO: more info if element was already missing in "intermediate" projection
462
+ // TODO: collect all missing elements?
463
+ return true;
463
464
  }
464
465
  else {
465
466
  setArtifactLink( targetElement.path[0], null );
@@ -476,7 +477,7 @@ function tweakAssocs( model ) {
476
477
  target: alias._main,
477
478
  name: elem.name?.id,
478
479
  } );
479
- return null;
480
+ return true;
480
481
  }
481
482
  }
482
483
  else {
@@ -489,9 +490,10 @@ function tweakAssocs( model ) {
489
490
  const item = targetElement.path[0];
490
491
  setArtifactLink( item, projectedKey.elem );
491
492
  setArtifactLink( targetElement, projectedKey.elem );
492
- return projectedKey.elem;
493
+ return false; // ok
493
494
  }
494
- return null;
495
+ // TODO: check message if this is reached
496
+ return true;
495
497
  }
496
498
 
497
499
  /**
@@ -534,7 +536,7 @@ function tweakAssocs( model ) {
534
536
  // TODO: Only report once for multi-include chains, see
535
537
  // Associations/SubElements/UnmanagedInSubElement.err.cds
536
538
  error( 'type-unsupported-rewrite', [ elem.location, elem ], { '#': 'sub-element' } );
537
- removeArtifactLinks();
539
+ removeArtifactLinks( elem );
538
540
  return;
539
541
  }
540
542
  const nav = (elem._main?.query && elem.value)
@@ -551,7 +553,7 @@ function tweakAssocs( model ) {
551
553
  if (!navigation) { // TODO: what about $projection.assoc as myAssoc ?
552
554
  if (elem._columnParent) {
553
555
  error( 'rewrite-not-supported', [ elem.target.location, elem ], { '#': 'inline-expand' } );
554
- removeArtifactLinks();
556
+ removeArtifactLinks( elem );
555
557
  }
556
558
  return; // should not happen: $projection, $magic, or ref to const
557
559
  }
@@ -566,31 +568,31 @@ function tweakAssocs( model ) {
566
568
  }
567
569
  else if (elem._columnParent) {
568
570
  error( 'rewrite-not-supported', [ elem.target.location, elem ], { '#': 'inline-expand' } );
569
- removeArtifactLinks();
571
+ removeArtifactLinks( elem );
570
572
  return;
571
573
  }
572
574
  else {
573
575
  // TODO: support that, now that the ON condition is rewritten in the right order
574
576
  error( null, [ elem.value.location, elem ], {},
575
577
  'Selecting unmanaged associations from a sub query is not supported' );
576
- removeArtifactLinks();
578
+ removeArtifactLinks( elem );
577
579
  return;
578
580
  }
579
581
 
580
582
  addConditionFromAssocPublishing( elem, assoc, nav );
581
583
  elem.on.$inferred = 'rewrite';
584
+ }
582
585
 
583
- /**
584
- * Clear all `_artifact` links in the ON-condition to avoid follow-up
585
- * issues during ON-condition rewriting of associations that inherit
586
- * the ON-condition.
587
- */
588
- function removeArtifactLinks() {
589
- traverseExpr( elem.on, 'rewrite-on', elem, (expr) => {
590
- setArtifactLink( expr, null );
591
- return traverseExpr.SKIP; // TODO: necessary?
592
- } );
593
- }
586
+ /**
587
+ * Clear all `_artifact` links in the ON-condition to avoid follow-up
588
+ * issues during ON-condition rewriting of associations that inherit
589
+ * the ON-condition.
590
+ */
591
+ function removeArtifactLinks( elem ) {
592
+ traverseExpr( elem.on, 'rewrite-on', elem, (expr) => {
593
+ setArtifactLink( expr, null );
594
+ return traverseExpr.SKIP; // TODO: necessary?
595
+ } );
594
596
  }
595
597
 
596
598
  /**
@@ -639,16 +641,22 @@ function tweakAssocs( model ) {
639
641
  }
640
642
  }
641
643
 
642
- elem.on = {
643
- op: { val: 'ixpr', location },
644
- args: [
645
- { ...elem.on, $parens: [ assoc.location ] },
646
- { val: 'and', literal: 'token', location },
647
- filterToCondition( lastStep, elem, nav ),
648
- ],
649
- location,
650
- $inferred: 'copy',
651
- };
644
+ // Empty filters don't add anything to the ON-condition.
645
+ if (lastStep.where.args?.length) {
646
+ elem.on = {
647
+ op: { val: 'ixpr', location },
648
+ args: [
649
+ { ...elem.on, $parens: [ assoc.location ] },
650
+ { val: 'and', literal: 'token', location },
651
+ filterToCondition( lastStep, elem, nav ),
652
+ ],
653
+ location,
654
+ $inferred: 'copy',
655
+ };
656
+ }
657
+ else if (elem.on && !elem.on.$inferred) {
658
+ elem.on.$inferred = 'copy';
659
+ }
652
660
 
653
661
  // Published paths with filters are always associations, never
654
662
  // compositions, hence we need to change the type to avoid type propagation.
@@ -843,6 +851,8 @@ function tweakAssocs( model ) {
843
851
  message( 'ref-missing-backlink-element',
844
852
  [ (outer.value || outer.name).location, outer ],
845
853
  { '#': (outer.value ? 'std' : 'def'), id: undef.id } );
854
+ assoc.$errorReported = true; // for `_redirected: null` later
855
+ // (do not set now, then we would see just the first missing element)
846
856
  // TODO: more info if element was already missing in "intermediate" projection
847
857
  // TODO: collect all missing elements?
848
858
  }
@@ -1220,14 +1230,16 @@ function findRewriteTarget( expr, index, env, user ) {
1220
1230
  return [ env.elements[item.id], index ];
1221
1231
  return [ null, expr.path.length ];
1222
1232
  }
1223
- const items = (env._leadingQuery || env)._combined?.[item.id];
1233
+ const items = (env.$queries?.[0] || env)._combined?.[item.id];
1224
1234
  const allNavs = !items || Array.isArray(items) ? items : [ items ];
1225
1235
 
1226
1236
  // If the annotation target itself has a table alias, require projections of that
1227
1237
  // table alias. Of course, that only works if we're talking about the same query.
1228
- const tableAlias = (user._main?._origin === item._artifact?._main &&
1229
- user.value?.path[0]?._navigation?.kind === '$tableAlias')
1230
- ? user.value.path[0]._navigation : null;
1238
+ const valueNav = user.value?.path[0]?._navigation;
1239
+ const tableAlias = (valueNav?.kind === '$tableAlias' &&
1240
+ user._main?._origin?._origin === item._artifact?._main)
1241
+ ? valueNav
1242
+ : null;
1231
1243
 
1232
1244
  // Look at all table aliase that could project `item` and only select
1233
1245
  // those that have actual projections.
@@ -8,7 +8,7 @@
8
8
 
9
9
  'use strict';
10
10
 
11
- const { dictAdd, dictFirst } = require('./dictionaries');
11
+ const { dictAdd } = require('./dictionaries');
12
12
  const { Location, weakLocation } = require('../base/location');
13
13
  const { XsnName, XsnArtifact } = require('./xsn-model');
14
14
 
@@ -158,7 +158,7 @@ function initItemsLinks( obj, block ) {
158
158
  * is most often the property `elem.name.id`.
159
159
  *
160
160
  * If argument `prop` is provided, add `elem` to the dictionary of that name,
161
- * e.g. `elements`. TODO: remove `prop`.
161
+ * e.g. `elements`. TODO: remove `prop` and `name`, rename to `setParentAndMain`.
162
162
  */
163
163
  function setMemberParent( elem, name, parent, prop ) {
164
164
  if (prop) { // extension or structure include
@@ -342,6 +342,26 @@ function withAssociation( ref, test = testFunctionPlaceholder, alsoTestLast = fa
342
342
  return false;
343
343
  }
344
344
 
345
+
346
+ function hasSecurityAnno( ext ) {
347
+ return ext['@restrict'] || ext['@requires'] ||
348
+ Object.keys( ext ).some( prop => prop.startsWith( '@ams.' ) );
349
+ }
350
+
351
+ function extensionRefContext( ext ) {
352
+ if (ext.kind === 'annotate') {
353
+ if (hasSecurityAnno( ext ))
354
+ return 'annotate-sec';
355
+ }
356
+ else if (ext.artifacts || ext.$syntax === 'empty') {
357
+ // extend … with definitions (or friends) or bare { extend: "ref" } in CSN
358
+ // TODO v8: not for `extend context` and `extend service` → !ext.expectedKind ?
359
+ if (!ext.doc && !Object.keys( ext ).some( a => a.charAt(0) === '@') )
360
+ return 'annotate';
361
+ }
362
+ return ext.kind;
363
+ }
364
+
345
365
  /**
346
366
  * Return string 'A.B.C' for parsed source `A.B.C` (is vector of ids with
347
367
  * locations).
@@ -639,17 +659,6 @@ function traverseQueryExtra( main, callback ) {
639
659
  }
640
660
  }
641
661
 
642
- /**
643
- * Returns what was available at view._from[0] before:
644
- * (think first whether to really use this function)
645
- */
646
- function viewFromPrimary( view ) {
647
- let query = view.$queries?.[0];
648
- while (query?._origin?.kind === 'select') // sub query in from
649
- query = query._origin;
650
- return dictFirst( query?.$tableAliases );
651
- }
652
-
653
662
  /**
654
663
  * About Helper property $expand for faster the XSN-to-CSN transformation
655
664
  * - null/undefined: artifact, member, items does not contain expanded members
@@ -730,6 +739,10 @@ function targetCantBeAspect( elem, calledForTargetAspectProp, definitions ) { //
730
739
  return null;
731
740
  }
732
741
 
742
+ function isLeadingQuery( query ) {
743
+ return query === query._main?.$queries?.[0];
744
+ }
745
+
733
746
  function userQuery( user ) {
734
747
  // TODO: we need _query links set by the definer
735
748
  while (user._main) {
@@ -898,6 +911,8 @@ module.exports = {
898
911
  initDollarParameters,
899
912
  initBoundSelfParam,
900
913
  withAssociation,
914
+ hasSecurityAnno,
915
+ extensionRefContext,
901
916
  pathName,
902
917
  hasSpecialPathItemProp,
903
918
  augmentPath,
@@ -909,10 +924,10 @@ module.exports = {
909
924
  forEachQueryExpr,
910
925
  traverseQueryPost,
911
926
  traverseQueryExtra,
912
- viewFromPrimary,
913
927
  setExpandStatus,
914
928
  isDirectComposition,
915
929
  targetCantBeAspect,
930
+ isLeadingQuery,
916
931
  userQuery,
917
932
  userParam,
918
933
  pathStartsWithSelf,
@@ -10,12 +10,12 @@ const { forEachGeneric } = require('../model/csnUtils');
10
10
  * These transformations are available today:
11
11
  *
12
12
  * Analytical Scenario:
13
- * If a structure is annotated with @Aggregation.ApplySupported.PropertyRestrictions
13
+ * V2 analytical clients don't understand OData V4 vocabulary annotations, therefore
14
+ * if a structure is annotated with '@Aggregation.ApplySupported.PropertyRestrictions'
14
15
  * then a number of annotation rewrites are done to this structure and to the
15
- * elements of this structure
16
- * Also the key properties of all structure elements are removed and a new
17
- * artificial key element 'key _ID : String' is inserted at first position of
18
- * the elements dictionary
16
+ * elements of this structure. Also, the key properties of all structure elements are
17
+ * removed and a new artificial key element 'key _ID : String' is inserted at first position of
18
+ * the elements dictionary.
19
19
  *
20
20
  * PDM (Personal Data Management)
21
21
  * Planned but not yet implemented annotation rewriting (pending to finalization)
@@ -48,6 +48,7 @@ function addToSetAttr( carrier, propName, propValue, removeFromType = true ) {
48
48
  }
49
49
 
50
50
  function applyAppSpecificLateCsnTransformationOnElement( options, element, struct, error ) {
51
+ // see "Analytical Scenario" in the module-level comment for why this transformation is needed
51
52
  if (options.isV2() && struct['@Aggregation.ApplySupported.PropertyRestrictions'])
52
53
  mapAnnotationAssignment(element, struct, GenerateAnalyticalAnnotations());
53
54
 
@@ -1 +1 @@
1
- 230b7681d344570b9cdb67a5c9bb0f86
1
+ bfa8a04d3ff1bc96f00a7f8d532f11d0