@sap/cds-dk 10.0.6 → 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 (326) hide show
  1. package/CHANGELOG.md +107 -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/nodejs/index.js +4 -2
  117. package/lib/init/template/notifications/index.js +2 -2
  118. package/lib/init/template/portal/files/mta.yaml.hbs +4 -0
  119. package/lib/init/template/portal/index.js +13 -8
  120. package/lib/init/template/postgres/index.js +2 -2
  121. package/lib/init/template/redis/index.js +2 -2
  122. package/lib/init/template/sample/files/db/currencies.cds +2 -0
  123. package/lib/init/template/sample/files/db/data/sap.capire.bookshop-Authors.csv +1 -1
  124. package/lib/init/template/tiny-sample/files/nodejs/db/data/CatalogService.Books.csv +2 -2
  125. package/lib/init/template/workzone-standard/index.js +5 -5
  126. package/lib/init/template/xsuaa/index.js +20 -2
  127. package/lib/lint/eslintHelp.json +1 -1
  128. package/lib/mtx/auth_manager.js +103 -37
  129. package/lib/mtx/params.js +3 -2
  130. package/lib/mtx/settings_manager.js +45 -28
  131. package/lib/mtx/tenant_action.js +0 -1
  132. package/lib/mtx/util/credentials.js +62 -0
  133. package/node_modules/@cap-js/openapi/lib/compile/csdl.js +3 -3
  134. package/node_modules/@cap-js/openapi/lib/compile/csdl2openapi.js +111 -103
  135. package/node_modules/@cap-js/openapi/lib/compile/diagram.js +4 -4
  136. package/node_modules/@cap-js/openapi/lib/compile/types.d.ts +3 -1
  137. package/node_modules/@cap-js/openapi/package.json +3 -3
  138. package/node_modules/@sap/cds/CHANGELOG.md +64 -0
  139. package/node_modules/@sap/cds/app/index.js +5 -4
  140. package/node_modules/@sap/cds/eslint.config.mjs +1 -0
  141. package/node_modules/@sap/cds/lib/compile/for/nodejs.js +1 -0
  142. package/node_modules/@sap/cds/lib/compile/minify.js +14 -10
  143. package/node_modules/@sap/cds/lib/env/cds-env.js +1 -1
  144. package/node_modules/@sap/cds/lib/env/cds-requires.js +22 -11
  145. package/node_modules/@sap/cds/lib/env/defaults.js +4 -1
  146. package/node_modules/@sap/cds/lib/env/schemas/cds-rc.js +5 -2
  147. package/node_modules/@sap/cds/lib/plugins.js +9 -5
  148. package/node_modules/@sap/cds/lib/req/spawn.js +1 -1
  149. package/node_modules/@sap/cds/lib/srv/srv-dispatch.js +1 -1
  150. package/node_modules/@sap/cds/lib/srv/srv-models.js +1 -1
  151. package/node_modules/@sap/cds/lib/utils/cds-utils.js +2 -1
  152. package/node_modules/@sap/cds/libx/_runtime/common/generic/assert.js +2 -3
  153. package/node_modules/@sap/cds/libx/_runtime/common/generic/auth/restrict.js +8 -1
  154. package/node_modules/@sap/cds/libx/_runtime/common/generic/crud.js +18 -8
  155. package/node_modules/@sap/cds/libx/_runtime/fiori/lean-draft.js +25 -17
  156. package/node_modules/@sap/cds/libx/_runtime/messaging/common-utils/authorizedRequest.js +3 -2
  157. package/node_modules/@sap/cds/libx/_runtime/messaging/enterprise-messaging-utils/registerEndpoints.js +9 -3
  158. package/node_modules/@sap/cds/libx/_runtime/remote/Service.js +4 -19
  159. package/node_modules/@sap/cds/libx/_runtime/remote/utils/LruCache.js +42 -0
  160. package/node_modules/@sap/cds/libx/_runtime/remote/utils/client.js +14 -4
  161. package/node_modules/@sap/cds/libx/_runtime/remote/utils/cloudSdkProvider.js +2 -9
  162. package/node_modules/@sap/cds/libx/_runtime/remote/utils/destinationClient.js +150 -0
  163. package/node_modules/@sap/cds/libx/_runtime/remote/utils/error.js +13 -0
  164. package/node_modules/@sap/cds/libx/_runtime/remote/utils/fetchClient.js +26 -18
  165. package/node_modules/@sap/cds/libx/_runtime/remote/utils/query.js +34 -23
  166. package/node_modules/@sap/cds/libx/_runtime/remote/utils/token.js +82 -0
  167. package/node_modules/@sap/cds/libx/_runtime/ucl/Service.js +36 -189
  168. package/node_modules/@sap/cds/libx/common/utils/streaming.js +16 -16
  169. package/node_modules/@sap/cds/libx/http/location.js +3 -3
  170. package/node_modules/@sap/cds/libx/odata/middleware/batch.js +16 -10
  171. package/node_modules/@sap/cds/libx/odata/middleware/metadata.js +9 -6
  172. package/node_modules/@sap/cds/libx/odata/middleware/service-document.js +1 -1
  173. package/node_modules/@sap/cds/libx/odata/parse/afterburner.js +19 -3
  174. package/node_modules/@sap/cds/libx/odata/parse/cqn2odata.js +83 -86
  175. package/node_modules/@sap/cds/libx/queue/SchedulingService.js +17 -2
  176. package/node_modules/@sap/cds/libx/queue/processing.js +1 -3
  177. package/node_modules/@sap/cds/libx/rest/RestAdapter.js +3 -7
  178. package/node_modules/@sap/cds/libx/rest/middleware/delete.js +3 -3
  179. package/node_modules/@sap/cds/libx/rest/middleware/parse.js +13 -8
  180. package/node_modules/@sap/cds/libx/rest/middleware/read.js +3 -3
  181. package/node_modules/@sap/cds/libx/rest/middleware/upsert.js +2 -2
  182. package/node_modules/@sap/cds/package.json +1 -1
  183. package/node_modules/@sap/cds-compiler/CHANGELOG.md +60 -8
  184. package/node_modules/@sap/cds-compiler/bin/cdsc.js +2 -2
  185. package/node_modules/@sap/cds-compiler/doc/IncompatibleChanges_v7.md +46 -19
  186. package/node_modules/@sap/cds-compiler/lib/api/main.js +10 -7
  187. package/node_modules/@sap/cds-compiler/lib/api/options.js +8 -2
  188. package/node_modules/@sap/cds-compiler/lib/base/csnRefs.js +5 -2
  189. package/node_modules/@sap/cds-compiler/lib/base/message-registry.js +4 -0
  190. package/node_modules/@sap/cds-compiler/lib/base/optionProcessor.js +12 -0
  191. package/node_modules/@sap/cds-compiler/lib/checks/enricher.js +1 -0
  192. package/node_modules/@sap/cds-compiler/lib/compiler/assert-consistency.js +8 -7
  193. package/node_modules/@sap/cds-compiler/lib/compiler/checks.js +3 -3
  194. package/node_modules/@sap/cds-compiler/lib/compiler/define.js +301 -75
  195. package/node_modules/@sap/cds-compiler/lib/compiler/dictionaries.js +2 -0
  196. package/node_modules/@sap/cds-compiler/lib/compiler/extend.js +40 -26
  197. package/node_modules/@sap/cds-compiler/lib/compiler/populate.js +45 -60
  198. package/node_modules/@sap/cds-compiler/lib/compiler/propagator.js +16 -7
  199. package/node_modules/@sap/cds-compiler/lib/compiler/resolve.js +41 -15
  200. package/node_modules/@sap/cds-compiler/lib/compiler/shared.js +7 -6
  201. package/node_modules/@sap/cds-compiler/lib/compiler/tweak-assocs.js +62 -50
  202. package/node_modules/@sap/cds-compiler/lib/compiler/utils.js +29 -14
  203. package/node_modules/@sap/cds-compiler/lib/edm/edmAnnoPreprocessor.js +6 -5
  204. package/node_modules/@sap/cds-compiler/lib/gen/CdlGrammar.checksum +1 -1
  205. package/node_modules/@sap/cds-compiler/lib/gen/CdlParser.js +1119 -1109
  206. package/node_modules/@sap/cds-compiler/lib/gen/Dictionary.json +19 -3
  207. package/node_modules/@sap/cds-compiler/lib/json/from-csn.js +10 -16
  208. package/node_modules/@sap/cds-compiler/lib/json/to-csn.js +58 -39
  209. package/node_modules/@sap/cds-compiler/lib/main.d.ts +8 -0
  210. package/node_modules/@sap/cds-compiler/lib/main.js +1 -0
  211. package/node_modules/@sap/cds-compiler/lib/model/csnUtils.js +2 -0
  212. package/node_modules/@sap/cds-compiler/lib/parsers/AstBuildingParser.js +2 -1
  213. package/node_modules/@sap/cds-compiler/lib/parsers/XprTree.js +8 -0
  214. package/node_modules/@sap/cds-compiler/lib/render/toCdl.js +22 -1
  215. package/node_modules/@sap/cds-compiler/lib/render/toSql.js +17 -2
  216. package/node_modules/@sap/cds-compiler/lib/render/utils/common.js +6 -1
  217. package/node_modules/@sap/cds-compiler/lib/render/utils/operators.js +27 -0
  218. package/node_modules/@sap/cds-compiler/lib/render/utils/standardDatabaseFunctions.js +125 -3
  219. package/node_modules/@sap/cds-compiler/lib/tool-lib/revealInternalProperties.js +2 -1
  220. package/node_modules/@sap/cds-compiler/lib/transform/db/applyTransformations.js +3 -0
  221. package/node_modules/@sap/cds-compiler/lib/transform/db/associations.js +8 -2
  222. package/node_modules/@sap/cds-compiler/lib/transform/db/backlinks.js +22 -6
  223. package/node_modules/@sap/cds-compiler/lib/transform/db/constraints.js +62 -1
  224. package/node_modules/@sap/cds-compiler/lib/transform/effective/annotations.js +40 -0
  225. package/node_modules/@sap/cds-compiler/lib/transform/effective/main.js +1 -0
  226. package/node_modules/@sap/cds-compiler/lib/transform/forRelationalDB.js +6 -1
  227. package/node_modules/@sap/cds-compiler/lib/transform/translateAssocsToJoins.js +19 -8
  228. package/node_modules/@sap/cds-compiler/package.json +1 -1
  229. package/node_modules/@sap/cds-mtxs/CHANGELOG.md +51 -0
  230. package/node_modules/@sap/cds-mtxs/bin/cds-mtx-migrate.js +32 -48
  231. package/node_modules/@sap/cds-mtxs/bin/cds-mtx.js +35 -16
  232. package/node_modules/@sap/cds-mtxs/cds-plugin.js +18 -0
  233. package/node_modules/@sap/cds-mtxs/lib/migration/migration.js +3 -408
  234. package/node_modules/@sap/cds-mtxs/lib/utils.js +19 -4
  235. package/node_modules/@sap/cds-mtxs/package.json +1 -1
  236. package/node_modules/@sap/cds-mtxs/srv/cf/abstract-provisioning-service.js +6 -7
  237. package/node_modules/@sap/cds-mtxs/srv/extensibility/linter/annotations.js +5 -2
  238. package/node_modules/@sap/cds-mtxs/srv/extensibility/linter/index.js +6 -5
  239. package/node_modules/@sap/cds-mtxs/srv/extensibility-service.cds +0 -11
  240. package/node_modules/@sap/cds-mtxs/srv/extensibility-service.js +34 -35
  241. package/node_modules/@sap/cds-mtxs/srv/jobs-service.js +30 -24
  242. package/node_modules/@sap/cds-mtxs/srv/model-provider.js +19 -4
  243. package/node_modules/@sap/cds-mtxs/srv/plugins/hana/ctnr-mgr-base.js +6 -3
  244. package/node_modules/@sap/cds-mtxs/srv/plugins/hana/hdi.js +5 -3
  245. package/node_modules/@sap/cds-mtxs/srv/plugins/hana/srv-mgr.js +3 -2
  246. package/node_modules/@sap/cds-mtxs/srv/plugins/hana/tms.js +17 -0
  247. package/node_modules/@sap/cds-mtxs/srv/plugins/hana.js +18 -21
  248. package/node_modules/@sap/xsenv/CHANGELOG.md +7 -0
  249. package/node_modules/@sap/xsenv/package.json +10 -7
  250. package/node_modules/body-parser/node_modules/content-type/README.md +2 -0
  251. package/node_modules/body-parser/node_modules/content-type/dist/index.d.ts +20 -0
  252. package/node_modules/body-parser/node_modules/content-type/dist/index.js +20 -14
  253. package/node_modules/body-parser/node_modules/content-type/dist/index.js.map +1 -1
  254. package/node_modules/body-parser/node_modules/content-type/package.json +1 -1
  255. package/node_modules/hdb/cfg/VERSION +1 -1
  256. package/node_modules/hdb/lib/protocol/ClientInfo.js +16 -3
  257. package/node_modules/hdb/lib/protocol/Connection.js +1 -0
  258. package/node_modules/hdb/package.json +3 -2
  259. package/node_modules/negotiator/lib/accept.js +54 -0
  260. package/node_modules/negotiator/lib/charset.js +10 -34
  261. package/node_modules/negotiator/lib/encoding.js +9 -30
  262. package/node_modules/negotiator/lib/language.js +15 -36
  263. package/node_modules/negotiator/lib/mediaType.js +16 -134
  264. package/node_modules/negotiator/node_modules/content-type/LICENSE +22 -0
  265. package/node_modules/negotiator/node_modules/content-type/README.md +71 -0
  266. package/node_modules/negotiator/node_modules/content-type/dist/index.d.ts +46 -0
  267. package/node_modules/negotiator/node_modules/content-type/dist/index.js +176 -0
  268. package/node_modules/negotiator/node_modules/content-type/dist/index.js.map +1 -0
  269. package/node_modules/negotiator/node_modules/content-type/package.json +52 -0
  270. package/node_modules/negotiator/package.json +16 -10
  271. package/node_modules/qs/.github/THREAT_MODEL.md +3 -3
  272. package/node_modules/qs/CHANGELOG.md +15 -0
  273. package/node_modules/qs/README.md +19 -1
  274. package/node_modules/qs/dist/qs.js +21 -21
  275. package/node_modules/qs/eslint.config.mjs +1 -1
  276. package/node_modules/qs/lib/parse.js +3 -4
  277. package/node_modules/qs/lib/stringify.js +23 -8
  278. package/node_modules/qs/lib/utils.js +10 -3
  279. package/node_modules/qs/package.json +4 -4
  280. package/node_modules/qs/test/parse.js +192 -3
  281. package/node_modules/qs/test/stringify.js +317 -0
  282. package/node_modules/qs/test/utils.js +12 -0
  283. package/node_modules/sax/lib/sax.js +27 -9
  284. package/node_modules/sax/package.json +1 -1
  285. package/node_modules/type-is/node_modules/content-type/README.md +2 -0
  286. package/node_modules/type-is/node_modules/content-type/dist/index.d.ts +20 -0
  287. package/node_modules/type-is/node_modules/content-type/dist/index.js +20 -14
  288. package/node_modules/type-is/node_modules/content-type/dist/index.js.map +1 -1
  289. package/node_modules/type-is/node_modules/content-type/package.json +1 -1
  290. package/node_modules/ws/lib/permessage-deflate.js +3 -1
  291. package/node_modules/ws/package.json +1 -1
  292. package/package.json +5 -5
  293. package/bin/completion/scripts/cds-bash.sh +0 -20
  294. package/bin/completion/scripts/cds-fish.fish +0 -13
  295. package/bin/completion/scripts/cds-ps.ps1 +0 -19
  296. package/bin/completion/scripts/cds-zsh.sh +0 -13
  297. package/lib/deploy/index.js +0 -25
  298. package/lib/import/asyncapi/importAsyncAPI.js +0 -33
  299. package/lib/import/asyncapi/index.js +0 -18
  300. package/lib/import/asyncapi/parserContext.js +0 -372
  301. package/lib/import/asyncapi/utils.js +0 -49
  302. package/lib/init/template/nodejs/files/.gitignore.hbs +0 -34
  303. package/node_modules/@sap/cds/libx/_runtime/ucl/queries.js +0 -61
  304. package/node_modules/@sap/cds-mtxs/lib/migration/extension-project-builder.js +0 -129
  305. package/node_modules/@sap/cds-mtxs/lib/migration/extension-project.js +0 -89
  306. package/node_modules/@sap/cds-mtxs/lib/migration/mtx-adapter.js +0 -230
  307. package/node_modules/negotiator/HISTORY.md +0 -114
  308. /package/{lib → bin}/upgrade/context.js +0 -0
  309. /package/{lib → bin}/upgrade/migrations/cds10/migrations.json +0 -0
  310. /package/{lib → bin}/upgrade/preflight/cds-version.js +0 -0
  311. /package/{lib → bin}/upgrade/preflight/project-type.js +0 -0
  312. /package/{lib → bin}/upgrade/steps/analyze/classification.js +0 -0
  313. /package/{lib → bin}/upgrade/steps/analyze/detector.js +0 -0
  314. /package/{lib → bin}/upgrade/steps/analyze/evaluator.js +0 -0
  315. /package/{lib → bin}/upgrade/steps/analyze/reporter.js +0 -0
  316. /package/{lib → bin}/upgrade/steps/analyze/setup.js +0 -0
  317. /package/{lib → bin}/upgrade/steps/analyze/utils/detection.js +0 -0
  318. /package/{lib → bin}/upgrade/steps/analyze/utils/files.js +0 -0
  319. /package/{lib → bin}/upgrade/steps/analyze/utils/grep.js +0 -0
  320. /package/{lib → bin}/upgrade/steps/analyze/utils/yaml.js +0 -0
  321. /package/{lib → bin}/upgrade/util/workspaces.js +0 -0
  322. /package/{lib → bin}/watch/esm-resolve-registration.js +0 -0
  323. /package/{lib → bin}/watch/livereload-server.js +0 -0
  324. /package/{lib → bin}/watch/node-watch.js +0 -0
  325. /package/{lib → bin}/watch/open.js +0 -0
  326. /package/{lib → bin}/watch/watcher.js +0 -0
@@ -127,6 +127,7 @@ const {
127
127
  dictAdd, dictAddArray, dictForEach, pushToDict,
128
128
  } = require('./dictionaries');
129
129
  const { kindProperties } = require('./base');
130
+ const { CompilerAssertion } = require('../base/error');
130
131
  const {
131
132
  setLink,
132
133
  initItemsLinks,
@@ -277,6 +278,18 @@ function define( model ) {
277
278
  }
278
279
  }
279
280
 
281
+ /**
282
+ * Calculate the absolute name of a main artifact (created via CDL or CSN parser).
283
+ * Detect reserved-namespace violations (name starts with `cds.`).
284
+ * Add artifact to `model.definitions` if the name does not start with `localized.`.
285
+ *
286
+ * Set `_block` links for the artifact and annotations with expression value
287
+ * (also set `kind` to `$annotation` for those).
288
+ *
289
+ * @param {XSN.Artifact} art
290
+ * @param {XSN.SourceAst|XSN.Artifact} block Enclosing block (source or context/service)
291
+ * @param {string} prefix Dot-terminated absolute name prefix, e.g. `A.B.`, or ``
292
+ */
280
293
  function addMainArtifact( art, block, prefix ) {
281
294
  setLink( art, '_block', block );
282
295
  initExprAnnoBlock( art, block, error ); // TODO: why also here?
@@ -303,7 +316,39 @@ function define( model ) {
303
316
  dictAdd( model.definitions, absolute, art );
304
317
  }
305
318
 
306
- // If 'A.B.C' is in 'artifacts', also add 'A' for name resolution
319
+ /**
320
+ * Add a main artifact to the model, like `addMainArtifact` does.
321
+ * Additionally, add all main artifacts in `art.artifacts` to the model, and
322
+ * all extensions in `art.extensions`.
323
+ *
324
+ * @param {XSN.Artifact} art
325
+ * @param {XSN.SourceAst|XSN.Artifact} block Enclosing block (source or context/service)
326
+ * @param {string} prefix Dot-terminated absolute name prefix, e.g. `A.B.`, or ``
327
+ */
328
+ function addBlockArtifact( art, block, prefix ) {
329
+ if (art.kind === 'using')
330
+ return;
331
+ addMainArtifact( art, block, prefix );
332
+ if (art.artifacts) {
333
+ const p = `${ art.name.id }.`;
334
+ // path prefixes (usings) must be added before extensions in artifacts:
335
+ addPathPrefixes( art.artifacts, p );
336
+ dictForEach( art.artifacts, a => addBlockArtifact( a, art, p ) );
337
+ }
338
+ if (art.extensions) { // requires using to be known!
339
+ art.extensions.forEach( e => e.name && addExtension( e, art ) );
340
+ }
341
+ }
342
+
343
+ /**
344
+ * Ensure that every dotted top-level name in `artifacts` has a synthetic `using`
345
+ * proxy for its first path component so that name resolution can find it.
346
+ * E.g. if `artifacts` contains an artifact with block-relative name `B.C`,
347
+ * a `using`-like entry for `B` is inserted (unless one already exists).
348
+ *
349
+ * @param {Object} artifacts Dictionary of artifact definitions keyed by relative name
350
+ * @param {string} prefix Absolute name prefix of the enclosing block, e.g. `"A."`
351
+ */
307
352
  function addPathPrefixes( artifacts, prefix ) {
308
353
  for (const name in artifacts) {
309
354
  const d = artifacts[name];
@@ -331,10 +376,9 @@ function define( model ) {
331
376
 
332
377
  /**
333
378
  * Add the names of a USING declaration to the top-level search environment
334
- * of the source, and set the absolute name referred by the USING
335
- * declaration.
379
+ * of the source, and set the absolute name referred by the USING declaration.
336
380
  *
337
- * @param {XSN.Using} decl Node to be expanded and added to `src`
381
+ * @param {XSN.Using} decl USING declaration to be expanded and added to `src`
338
382
  * @param {XSN.SourceAst} src
339
383
  */
340
384
  function addUsing( decl, src ) {
@@ -360,7 +404,14 @@ function define( model ) {
360
404
  dictAddArray( src.artifacts, name, decl );
361
405
  }
362
406
 
363
- // must be called after addUsing().
407
+ /**
408
+ * Use the namespace declaration as USING declaration if the local name
409
+ * is not already defined in the source (that is why all `addUsing`s must
410
+ * have been called before).
411
+ *
412
+ * @param {XSN.Namespace} namespace Namespace declaration of `src`
413
+ * @param {XSN.SourceAst} src
414
+ */
364
415
  function addNamespace( namespace, src ) {
365
416
  // create using for own namespace:
366
417
  // TODO: should we really do that (in v6)? See also initNamespaceAndUsing().
@@ -377,29 +428,40 @@ function define( model ) {
377
428
  $inferred: 'namespace',
378
429
  };
379
430
  }
380
- function addBlockArtifact( art, block, prefix ) {
381
- if (art.kind === 'using')
382
- return;
383
- addMainArtifact( art, block, prefix );
384
- if (art.artifacts) {
385
- const p = `${ art.name.id }.`;
386
- // path prefixes (usings) must be added before extensions in artifacts:
387
- addPathPrefixes( art.artifacts, p );
388
- dictForEach( art.artifacts, a => addBlockArtifact( a, art, p ) );
389
- }
390
- if (art.extensions) { // requires using to be known!
391
- art.extensions.forEach( e => e.name && addExtension( e, art ) );
392
- }
393
- }
394
431
 
432
+ /**
433
+ * Register an extension block in `model.$collectedExtensions` so it can be
434
+ * applied during the extend phase. For context/service extensions that carry
435
+ * nested `artifacts`, those artifacts are registered in `model.definitions` as
436
+ * well (delegating to `addBlockArtifact`).
437
+ *
438
+ * @param {XSN.Extension} ext The `extend`/`annotate` node from the source AST
439
+ * @param {XSN.SourceAst|XSN.Artifact} block Enclosing block that provides scope
440
+ */
395
441
  function addExtension( ext, block ) {
396
442
  setLink( ext, '_block', block );
397
443
  initExprAnnoBlock( ext, block, error );
398
444
  const absolute = ext.name && resolveUncheckedPath( ext.name, '_uncheckedExtension', ext );
399
445
  if (!absolute) // broken path
400
446
  return;
401
- delete ext.name.path[0]._artifact; // might point to wrong JS object in phase 1 - TODO: still?
447
+
448
+ if (ext.artifacts) {
449
+ // Directly add the artifacts of context and service extension:
450
+ if (!model.$blocks)
451
+ model.$blocks = Object.create( null );
452
+ // Set block number for debugging (--raw-output):
453
+ // eslint-disable-next-line no-multi-assign
454
+ ext.$effectiveSeqNo = model.$blocks[absolute] = (model.$blocks[absolute] || 0) + 1;
455
+ const prefix = `${ absolute }.`;
456
+ dictForEach( ext.artifacts, a => addBlockArtifact( a, ext, prefix ) );
457
+
458
+ if (!ext.expectedKind && !ext.doc &&
459
+ !Object.keys( ext ).some( prop => prop.startsWith( '@' ) ))
460
+ return; // not part of extensions if just nested definitions
461
+ }
402
462
  ext.name.id = absolute; // definition might not be there yet, no _artifact link
463
+ delete ext.name.path[0]._artifact; // might point to wrong JS object in phase 1 - TODO: still?
464
+
403
465
  const location = { file: '' }; // stupid required location
404
466
  const late = model.$collectedExtensions[absolute] ||
405
467
  (model.$collectedExtensions[absolute] = {
@@ -409,19 +471,15 @@ function define( model ) {
409
471
  location,
410
472
  });
411
473
  pushToDict( late, '_extensions', ext );
412
- if (!ext.artifacts)
413
- return;
414
-
415
- // Directly add the artifacts of context and service extension:
416
- if (!model.$blocks)
417
- model.$blocks = Object.create( null );
418
- // Set block number for debugging (--raw-output):
419
- // eslint-disable-next-line no-multi-assign
420
- ext.$effectiveSeqNo = model.$blocks[absolute] = (model.$blocks[absolute] || 0) + 1;
421
- const prefix = `${ absolute }.`;
422
- dictForEach( ext.artifacts, a => addBlockArtifact( a, ext, prefix ) );
423
474
  }
424
475
 
476
+ /**
477
+ * Register a vocabulary artifact in `model.vocabularies` under its absolute name.
478
+ *
479
+ * @param {XSN.Artifact} vocab
480
+ * @param {XSN.SourceAst} block
481
+ * @param {string} prefix Dot-terminated absolute name prefix, or `""`
482
+ */
425
483
  function addVocabulary( vocab, block, prefix ) {
426
484
  setLink( vocab, '_block', block );
427
485
  const { name } = vocab;
@@ -480,6 +538,14 @@ function define( model ) {
480
538
  // Functions called from top-level: initNamespaceAndUsing(), initMainArtifact(),
481
539
  // initVocabulary(), initExtension()
482
540
 
541
+ /**
542
+ * Initialise for a single CDL source: register the "namespace artifact" in
543
+ * `model.definitions` if no real artifact with that name exists,
544
+ * warn when the namespace's last component shadows a builtin name, and
545
+ * report duplicate top-level `using` names introduced by `using` declarations.
546
+ *
547
+ * @param {XSN.SourceAst} src
548
+ */
483
549
  function initNamespaceAndUsing( src ) {
484
550
  if (src.$frontend && src.$frontend !== 'cdl')
485
551
  return;
@@ -518,6 +584,16 @@ function define( model ) {
518
584
  }
519
585
  }
520
586
 
587
+ /**
588
+ * Initialise for a top-level artifact: sets `_parent`/`_subArtifacts` links,
589
+ * check for duplicate definitions, initialise `$self`/`$parameters` aliases,
590
+ * recurse into members, and drive query initialisation for entities/views.
591
+ * Pass `reInit = true` for auto-exposed entities to skip the `_parent` step
592
+ * (their parent link is already set up during auto-exposure).
593
+ *
594
+ * @param {XSN.Artifact} art
595
+ * @param {boolean} [reInit]
596
+ */
521
597
  function initMainArtifact( art, reInit = false ) {
522
598
  if (!reInit) // not for auto-exposed entity
523
599
  initArtifactParentLink( art, model.definitions );
@@ -533,6 +609,13 @@ function define( model ) {
533
609
  }
534
610
  }
535
611
 
612
+ /**
613
+ * Initialise for a vocabulary artifact: sets `_parent`/`_subArtifacts` links,
614
+ * checks for duplicates, recurses into members, and rejects query-based vocabulary
615
+ * definitions (projections on annotation definitions are unsupported).
616
+ *
617
+ * @param {XSN.Artifact} art
618
+ */
536
619
  function initVocabulary( art ) {
537
620
  initArtifactParentLink( art, model.vocabularies );
538
621
  checkRedefinition( art );
@@ -545,10 +628,16 @@ function define( model ) {
545
628
  }
546
629
  }
547
630
 
548
- function initExtension( parent ) {
549
- initMembers( parent );
550
- if (parent.columns)
551
- initSelectItems( parent, parent.columns, parent, true );
631
+ /**
632
+ * Initialise for an `extend`/`annotate` node: recurse into its members
633
+ * and, for `extend … with columns`, initialises the column list in extension context.
634
+ *
635
+ * @param {XSN.Extension} ext The collected super-extension node
636
+ */
637
+ function initExtension( ext ) {
638
+ initMembers( ext );
639
+ if (ext.columns)
640
+ initSelectItems( ext, ext.columns, ext, true );
552
641
  // there are no sub queries in extensions yet
553
642
  // Remark: sub queries not yet allowed in `extend … with columns`
554
643
  }
@@ -588,6 +677,11 @@ function define( model ) {
588
677
  parent._subArtifacts[id.substring( dot + 1 )] = art; // not dictAdd()
589
678
  }
590
679
 
680
+ /**
681
+ * Report a duplicate-definition error for `art` if it was flagged as a redefinition
682
+ * during phase 1. Extensions (`extend`/`annotate`) are silently skipped because
683
+ * they are merged and only kept as `$duplicates` for LSP purposes.
684
+ */
591
685
  // TODO: message ids
592
686
  // Called by initMainArtifact() and initVocabulary() and for members
593
687
  function checkRedefinition( art ) {
@@ -660,24 +754,53 @@ function define( model ) {
660
754
  }
661
755
  }
662
756
 
757
+ /**
758
+ * Initialise all queries of a query-bearing artifact and store them in `$queries`.
759
+ *
760
+ * Also create helper artifacts like for `$projection` and set various links
761
+ * (`_parent`, `_$next`, `_origin`) for the name resolution in queries.
762
+ *
763
+ * Also moves pre-existing `elements` (for basic "specified elements" support)
764
+ * aside into `elements$` so the populate phase can merge them later.
765
+ *
766
+ * @param {XSN.Artifact} art An entity, view, type, or event with a `query` property
767
+ */
663
768
  function initArtifactQuery( art ) {
664
769
  art.$queries = [];
665
- setLink( art, '_from', [] ); // for sequence of resolve steps - TODO: remove
666
- if (!setLink( art, '_leadingQuery', initQueryExpression( art.query, art ) ) )
667
- return; // null or undefined in case of parse error
668
- // if (art._leadingQuery !== art.$queries [0]) throw Error('FOO');
669
- setLink( art._leadingQuery, '_$next', art );
770
+ const leading = initQueryExpression( art.query, art );
771
+ if (!leading)
772
+ return;
773
+ if (leading !== art.$queries[0])
774
+ throw new CompilerAssertion( `Invalid leading query of ${ art.name.id }` );
775
+
776
+ setLink( art, '_origin', leading._origin );
777
+ // Remark: setting _origin to `leading` would break `extend … with columns`
778
+ setLink( leading, '_$next', art );
670
779
  if (art.elements) { // specified element via compilation of client-style CSN
671
- // TODO: consider this part of a revamped on-demand 'extend' functionality
780
+ // TODO: consider this part of the normal 'extend' functionality
672
781
  setLink( art, 'elements$', art.elements );
673
782
  delete art.elements;
674
783
  }
675
784
  }
676
785
 
677
- // art is:
678
- // - entity/event/type for top-level queries (including UNION args)
679
- // - $tableAlias for sub query in FROM - TODO: what about UNION there?
680
- // - $query for real sub query (in columns, WHERE, ...), again: what about UNION there?
786
+ /**
787
+ * Recursively initialise a query expression node — either a `SELECT` or a set
788
+ * operation (`UNION`/`INTERSECT`/…). For `SELECT`, drives `initQuery`,
789
+ * `initTableExpression`, `initMixins`, and the implicit `$self`/`$projection`
790
+ * table-alias registration. For set operations, delegates to each operand and
791
+ * propagates `ORDER BY`/`LIMIT` clauses onto the leading query.
792
+ * Returns the leading query node (the innermost leftmost `SELECT`), or `undefined`
793
+ * on parse error.
794
+ *
795
+ * `art` is:
796
+ * - entity/event/type for top-level queries (including UNION args)
797
+ * - $tableAlias for sub query in FROM - TODO: what about UNION there?
798
+ * - $query for real sub query (in columns, WHERE, ...) - what about UNION there?
799
+ *
800
+ * @param {XSN.Query|null} query
801
+ * @param {XSN.Artifact|XSN.Query} art Owning artifact or parent alias
802
+ * @returns {XSN.Query|undefined}
803
+ */
681
804
  function initQueryExpression( query, art ) {
682
805
  if (!query) // parse error
683
806
  return query;
@@ -705,38 +828,49 @@ function define( model ) {
705
828
  query.$tableAliases.$projection = projection;
706
829
  }
707
830
  initSubQuery( query ); // check for SELECT clauses after from / mixin
831
+ return query;
708
832
  }
709
- else if (query.args) { // UNION, INTERSECT, ..., query in parens
710
- const leading = initQueryExpression( query.args[0], art );
711
- for (const q of query.args.slice(1))
712
- initQueryExpression( q, art );
713
- setLink( query, '_leadingQuery', leading );
714
- if (leading) {
715
- if (query.orderBy) {
716
- leading.$orderBy ??= [ ];
717
- leading.$orderBy.push( ...query.orderBy );
718
- }
719
- if (query.limit) {
720
- leading.$limit ??= [ ];
721
- leading.$limit.push( query.limit );
722
- }
833
+ if (query.args) { // UNION, INTERSECT, ...
834
+ let leading = null; // first SELECT
835
+ for (const q of query.args) {
836
+ const sub = initQueryExpression( q, art );
837
+ leading ??= sub;
723
838
  }
724
- // ORDER BY and LIMIT to be evaluated in leading query
725
- }
726
- else { // with parse error (`select from <EOF>`, `select from E { *, ( select }`)
727
- // TODO: call initQuery() anyway to avoid Error[expr-no-subquery] also for
728
- // UNIONs (test3/Queries/DollarSelf/CorruptedSource.err.cds), see also
729
- // resolveExprNode()
730
- return undefined;
839
+ setLink( query, '_origin', leading?._origin ?? false );
840
+ if (!leading)
841
+ return false; // potentially with parse error, false not overwritten by `??=`
842
+ // ORDER BY and LIMIT to be evaluated according to elements of first SELECT:
843
+ if (query.orderBy) {
844
+ leading.$orderBy ??= [ ];
845
+ leading.$orderBy.push( ...query.orderBy );
846
+ }
847
+ if (query.limit) {
848
+ leading.$limit ??= [ ];
849
+ leading.$limit.push( query.limit );
850
+ }
851
+ return leading;
731
852
  }
732
- return query._leadingQuery || query;
853
+ // with parse error (`select from <EOF>`, `select from E { *, ( select }`)
854
+ // TODO: call initQuery() anyway to avoid Error[expr-no-subquery] also for
855
+ // UNIONs (test3/Queries/DollarSelf/CorruptedSource.err.cds), see also
856
+ // resolveExprNode()
857
+ return undefined;
733
858
  }
734
859
 
860
+ /**
861
+ * Assign `kind: 'select'` and a numeric name to `query`, register it in
862
+ * `main.$queries`, and set up `_block`, `_$next`, `_parent`, `$tableAliases`,
863
+ * and `dependsOn` links needed by the populate and resolve phase.
864
+ *
865
+ * @param {XSN.Query} query
866
+ * @param {XSN.Artifact|XSN.TableAlias} art Owning artifact or enclosing table alias
867
+ */
735
868
  function initQuery( query, art ) {
736
869
  setLink( query, '_block', art._block );
737
870
  const main = art._main || art;
738
871
  setLink( query, '_$next',
739
872
  (art.kind === '$tableAlias' ? art._parent._$next : art ) );
873
+ setLink( query, '_origin', null ); // set later in initTableExpression → addAsAlias
740
874
  query.kind = 'select';
741
875
  query.name = { location: query.location, id: main.$queries.length + 1 };
742
876
  setMemberParent( query, null, main );
@@ -747,6 +881,17 @@ function define( model ) {
747
881
  dependsOnSilent( main, query );
748
882
  }
749
883
 
884
+ /**
885
+ * Initialise a table expression in a FROM clause: path references, sub-selects,
886
+ * and JOIN trees. Path references and sub-selects become `$tableAlias` nodes
887
+ * registered in `query.$tableAliases`. JOIN trees are traversed recursively;
888
+ * each arm with an ON clause becomes a `$join` node whose aliases are also
889
+ * propagated upward via `joinParents` for restriction checking.
890
+ *
891
+ * @param {XSN.TableExpr|null} table
892
+ * @param {XSN.Query} query
893
+ * @param {XSN.JoinNode[]} joinParents Stack of enclosing JOIN nodes with ON clauses
894
+ */
750
895
  // table is table expression in FROM, becomes an alias
751
896
  function initTableExpression( table, query, joinParents ) {
752
897
  if (!table) // parse error
@@ -764,9 +909,6 @@ function define( model ) {
764
909
  }
765
910
  addAsAlias( table, query, joinParents );
766
911
  // _origin is set when we resolve the ref
767
- if (query._parent.kind !== 'select')
768
- query._main._from.push( table ); // store tabref if outside "real" subquery
769
- // (tab refs on the right of union are unnecessary)
770
912
  }
771
913
  else if (table.query) {
772
914
  if (!table.name?.id) {
@@ -816,10 +958,22 @@ function define( model ) {
816
958
  }
817
959
  }
818
960
 
961
+ /**
962
+ * Register `table` as a `$tableAlias` in `query.$tableAliases` and, for JOIN
963
+ * contexts, in each enclosing JOIN node's `$tableAliases` (for alias restriction
964
+ * checks). Report duplicate alias names and warn when a user-written alias
965
+ * starts with `$`.
966
+ *
967
+ * @param {XSN.TableAlias} table
968
+ * @param {XSN.Query} query
969
+ * @param {XSN.JoinNode[]} joinParents
970
+ */
819
971
  function addAsAlias( table, query, joinParents ) {
820
972
  table.kind = '$tableAlias';
821
973
  setLink( table, '_block', query._block );
822
974
  setMemberParent( table, table.name.id, query );
975
+ if (!query._origin)
976
+ setLink( query, '_origin', table );
823
977
  dictAdd( query.$tableAliases, table.name.id, table, ( name, loc, tableAlias ) => {
824
978
  if (tableAlias.name.$inferred === '$internal') {
825
979
  const semanticLoc = tableAlias.query?.name ? tableAlias.query : tableAlias;
@@ -847,6 +1001,12 @@ function define( model ) {
847
1001
  }
848
1002
  }
849
1003
 
1004
+ /**
1005
+ * Walk sub-query nodes embedded inside a SELECT's ON, WHERE, HAVING, column list,
1006
+ * and members, and drive `initQueryExpression` for each.
1007
+ *
1008
+ * @param {XSN.Query|XSN.JoinNode} query
1009
+ */
850
1010
  function initSubQuery( query ) {
851
1011
  if (query.on)
852
1012
  initExprForQuery( query.on, query );
@@ -859,6 +1019,14 @@ function define( model ) {
859
1019
  initMembers( query );
860
1020
  }
861
1021
 
1022
+ /**
1023
+ * Recursively find and initialise sub-query nodes embedded inside an expression
1024
+ * (WHERE, HAVING, ON, column values). Descend into `args` arrays and named
1025
+ * argument objects; calls `initQueryExpression` for any `expr.query` encountered.
1026
+ *
1027
+ * @param {XSN.Expr|XSN.Expr[]|null} expr
1028
+ * @param {XSN.Query} query Enclosing query that owns the expression
1029
+ */
862
1030
  function initExprForQuery( expr, query ) {
863
1031
  // TODO: use traverseExpr()
864
1032
  if (Array.isArray( expr )) { // TODO: old-style $parens ?
@@ -876,6 +1044,14 @@ function define( model ) {
876
1044
  }
877
1045
  }
878
1046
 
1047
+ /**
1048
+ * Initialise all MIXIN definitions of `query`: set parent/block links, check for
1049
+ * duplicates, register each mixin as a `$tableAlias` in `query.$tableAliases`,
1050
+ * and warn when a mixin name starts with `$`.
1051
+ *
1052
+ * @param {XSN.Query} query
1053
+ * @param {XSN.Artifact} art Main artifact owning the query (provides `_block`)
1054
+ */
879
1055
  function initMixins( query, art ) {
880
1056
  forEachInOrder( query, 'mixin', initMixin );
881
1057
 
@@ -898,6 +1074,20 @@ function define( model ) {
898
1074
  }
899
1075
  }
900
1076
 
1077
+ /**
1078
+ * Initialise the select-item list of a query or expand/inline column. Iterates
1079
+ * over `columns` (or `parent.expand`/`parent.inline`) and for each item:
1080
+ * - tracks the first wildcard (`*`) and rejects subsequent ones;
1081
+ * reports a warning when `excluding` is used without a wildcard
1082
+ * - assigns `kind: 'element'`, sets parent/block links, infers a column alias
1083
+ * via `ensureColumnName`, recurses into nested expand/inline, and calls
1084
+ * `initExprForQuery` for sub-queries in column values.
1085
+ *
1086
+ * @param {XSN.Query|XSN.Column} parent Node that owns the column list
1087
+ * @param {XSN.Column[]|null} columns Explicit column array, or `null` to use expand/inline
1088
+ * @param {XSN.Query} user Enclosing query (for semantic location in messages)
1089
+ * @param {boolean} [inExtension] `true` when processing `extend … with columns`
1090
+ */
901
1091
  function initSelectItems( parent, columns, user, inExtension = false ) {
902
1092
  let wildcard = !!inExtension; // no `extend … with columns { * }`
903
1093
  // TODO: forbid expand/inline in ref-where, outside queries (CSN), ...
@@ -1023,10 +1213,16 @@ function define( model ) {
1023
1213
  return col.name.id;
1024
1214
  }
1025
1215
 
1216
+ /**
1217
+ * Report a CDL-style type cast to an anonymous structure or an expand with an
1218
+ * explicit type as a syntax error. Called for every column during select-item
1219
+ * initialisation. Rejection happens here (rather than in `checks.js`) so that
1220
+ * it is also enforced during `parseCdl`.
1221
+ *
1222
+ * @param {XSN.Column} col
1223
+ */
1026
1224
  function checkCdlTypeCast( col ) { // with #13933:
1027
- // We don't allow CDL-style casts to anonymous structures. We reject it already here
1028
- // and not in checks.js to ensure that it's rejected in parseCdl.
1029
- // TODO: via <guard> in CdlGrammar.g4
1225
+ // TODO: do via <guard> in CdlGrammar.g4 ?
1030
1226
  if (col.elements) {
1031
1227
  error( 'type-invalid-cast', [ (col.elements[$location] ?? col.location), col ],
1032
1228
  { '#': 'to-inline-structure' } );
@@ -1042,8 +1238,13 @@ function define( model ) {
1042
1238
  // Members (elements, enum, actions, params): ---------------------------------
1043
1239
 
1044
1240
  /**
1045
- * Set property `_parent` for all elements in `parent` to `parent` and do so
1046
- * recursively for all sub elements.
1241
+ * Initialise for all members of `parent`: resolves the concrete member container
1242
+ * (following `items`/`many` wrappers via `initItemsLinks`), reports a scale-without-
1243
+ * precision error on type extensions, detects inline aspects on managed compositions
1244
+ * (delegating to `initAnonymousAspect`), and then calls `initArtifact` for every
1245
+ * element, enum value, foreign key, action, param, and RETURNS declaration.
1246
+ *
1247
+ * @param {XSN.Artifact|XSN.Element|XSN.Query|XSN.Extension} parent
1047
1248
  */
1048
1249
  function initMembers( parent ) {
1049
1250
  // TODO: combine with initMembers() - better structuring
@@ -1084,6 +1285,18 @@ function define( model ) {
1084
1285
  }
1085
1286
  }
1086
1287
 
1288
+ /**
1289
+ * Initialise the inline aspect that appears as the `targetAspect` of a managed
1290
+ * composition element. Sets up `_outer`, `_parent`, `_block`, `_main`, and
1291
+ * `$self` links on `targetAspect`, promotes its kind to `'aspect'`, and injects
1292
+ * a synthetic `up_` `$navElement` when the composition is directly inside an
1293
+ * entity (so that references to `up_` inside the aspect resolve correctly).
1294
+ *
1295
+ * @param {XSN.Element} parent The composition element that owns the inline aspect
1296
+ * @param {XSN.Element} obj The resolved composition element (may differ via `items`)
1297
+ * @param {XSN.InlineAspect} targetAspect The inline aspect node to initialise
1298
+ * @returns {XSN.InlineAspect}
1299
+ */
1087
1300
  function initAnonymousAspect( parent, obj, targetAspect ) {
1088
1301
  // TODO: main?
1089
1302
  const inEntity = parent._main?.kind === 'entity';
@@ -1118,6 +1331,19 @@ function define( model ) {
1118
1331
  return targetAspect;
1119
1332
  }
1120
1333
 
1334
+ /**
1335
+ * Initialise for a single member (element, enum value, foreign key, action,
1336
+ * function, or parameter). Infers a missing name from the last path component
1337
+ * of `targetElement`/`value`, sets `_block`/`_parent`/`_main` links, checks for
1338
+ * duplicates, recurses into sub-members, and — for action/function params —
1339
+ * sets up the bound `$self` parameter. Also promotes elements with a `value`
1340
+ * expression to calculated elements (`$syntax: 'calc'`) and creates the
1341
+ * companion `$calcDepElement`.
1342
+ *
1343
+ * @param {XSN.Artifact|XSN.Element|XSN.Query} parent Enclosing node
1344
+ * @param {XSN.Element} elem
1345
+ * @param {string} name Relative member name (empty string `''` for RETURNS)
1346
+ */
1121
1347
  // TODO: combine with initMembers()
1122
1348
  function initArtifact( parent, elem, name ) {
1123
1349
  if (!elem.name && !elem._outer) {
@@ -86,6 +86,8 @@ function dictAddArray( dict, name, entry, messageCallback ) {
86
86
  function dictFirst( dict ) {
87
87
  if (!dict)
88
88
  return dict;
89
+ // Remark: previously, we had a loop and returned directly there.
90
+ // Earlier tests showed that this is faster, but SonarQube did not like it.
89
91
  const names = Object.keys( dict );
90
92
  return names.length ? dict[names[0]] : null;
91
93
  }