@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
@@ -0,0 +1,230 @@
1
+ #!/bin/zsh
2
+ # This file was generated from bin/completion/templates/cds-tmpl.zsh by
3
+ # 'cds completion --generate' and is written to bin/completion/scripts/cds.zsh.
4
+ #
5
+ # Do not edit directly — modify the template and regenerate.
6
+ #
7
+ # Completion strategy (fastest-first):
8
+ # 1. Shortcuts — single-character aliases resolved before any other logic.
9
+ # 2. Top-level — all known subcommands when no subcommand has been typed yet.
10
+ # 3. Flags — matched when the current token starts with '-'.
11
+ # 3.5. Option values — static values for known flags (e.g. --to sqlite).
12
+ # 3.6. Comma values — comma-separable list (e.g. cds add ai,hana).
13
+ # 4. File positionals — files/dirs for subcommands that take a path argument.
14
+ # 4.6. String positionals — fixed word list (e.g. cds help <tab>).
15
+ # 5. Dynamic fallback — calls 'cds completion' for anything not covered above.
16
+ #
17
+ # Zsh uses $words (1-based token array) and $CURRENT (index of cursor token).
18
+ # Completions are added with compadd instead of bash's COMPREPLY.
19
+ # 'case ... esac && return' exits the function when a case arm matched.
20
+
21
+ CDS_COMMAND="cds"
22
+
23
+ _completeCds() {
24
+ local current="${words[CURRENT]}"
25
+ local previous="${words[CURRENT-1]}"
26
+ # The subcommand is always the second token (index 2 in 1-based zsh arrays).
27
+ local cmd="${words[2]}"
28
+ # Step 1: resolve single-character shortcuts to their canonical command name.
29
+ case "$cmd" in
30
+ i) cmd=init ;;
31
+ a) cmd=add ;;
32
+ y) cmd=bind ;;
33
+ m) cmd=import ;;
34
+ c) cmd=compile ;;
35
+ p) cmd=parse ;;
36
+ s) cmd=serve ;;
37
+ w) cmd=watch ;;
38
+ e) cmd=env ;;
39
+ b) cmd=build ;;
40
+ d) cmd=deploy ;;
41
+ l) cmd=login ;;
42
+ o) cmd=logout ;;
43
+ t) cmd=test ;;
44
+ v) cmd=version ;;
45
+ h) cmd=help ;;
46
+ r) cmd=repl ;;
47
+ esac
48
+
49
+ # Step 2: top-level — offer all known subcommands when no subcommand has been
50
+ # typed yet ($words is 1-based; ≤ 2 means "cds <cursor>").
51
+ if [[ "${#words[@]}" -le 2 ]]; then
52
+ compadd -S '' -- "add" "bind" "build" "compile" "completion" "debug" "deploy" "env" "eval" "export" "gen" "help" "import" "init" "inspect" "lint" "login" "logout" "minify" "mock" "parse" "pull" "push" "repl" "run" "serve" "subscribe" "test" "unsubscribe" "up" "upgrade" "upgrade-tenant" "version" "watch"
53
+ return
54
+ fi
55
+
56
+ # Step 3: flag/option completion — only triggered when the token starts with '-'.
57
+ # 'case ... esac && return' exits the function when a case arm matched.
58
+ if [[ "$current" == -* ]]; then
59
+ case "$cmd" in
60
+ add) compadd -S '' -- "--base" "--cdm" "--cloudevents" "--content-type" "--data:for" "--dry" "--filter" "--for" "--for-app" "--force" "--into" "--java:mvn" "--keys-only" "--out" "--package" "--plan" "--records" "--sap" "--shell" "--unified-runtime" "--with-telemetry" "--y" ;;
61
+ bind) compadd -S '' -- "--credentials" "--exec" "--for" "--kind" "--no-create-service-key" "--on" "--out" "--output-file" "--to" "--to-app-services" ;;
62
+ build) compadd -S '' -- "--dest" "--for" "--log-level" "--no-clean" "--no-ws-pack" "--options-model" "--opts" "--project" "--src" "--ws" "--ws-pack" ;;
63
+ compile) compadd -S '' -- "--all" "--asyncapi:merged" "--beta" "--clean" "--conceptual" "--dest" "--dialect" "--docs" "--files" "--flavor" "--for" "--from" "--lang" "--locations" "--log-level" "--min" "--odata-version" "--openapi:config-file" "--openapi:diagram" "--openapi:servers" "--openapi:url" "--parse" "--plain" "--resolved" "--service" "--sort" "--sources" "--sql-dialect" "--to" ;;
64
+ completion) compadd -S '' -- "--add" "--curr" "--generate" "--line" "--prev" "--profile" "--remove" "--shell" ;;
65
+ debug) compadd -S '' -- "--cf" "--force" "--host" "--k8s" "--no-devtools" "--port" ;;
66
+ deploy) compadd -S '' -- "--auto-undeploy" "--delta-from" "--dry" "--for" "--model-only" "--no-build" "--no-save" "--on" "--out" "--resolve-bindings" "--script" "--store-credentials" "--to" "--tunnel-address" "--vcap-file" "--with-auto-schema-evolution" "--with-mocks" "--xdry" ;;
67
+ env) compadd -S '' -- "--for" "--json" "--keys" "--list" "--mocked" "--process-env" "--properties" "--raw" "--resolve-bindings" "--sources" ;;
68
+ export) compadd -S '' -- "--artifact" "--as" "--cleanse" "--data" "--debug" "--dry" "--for" "--from" "--inspect" "--keep" "--mvn" "--plugin" "--reuse" "--services" "--skip" "--texts" "--to" ;;
69
+ import) compadd -S '' -- "--as" "--asyncapi" "--config" "--data-product" "--dependencies" "--destination" "--dry" "--edmx" "--for" "--force" "--from" "--group" "--include-namespaces" "--into-namespace" "--keep-namespace" "--name" "--no-copy" "--no-save" "--odata" "--odata-v2-annotations" "--openapi" "--out" "--resolve-bindings" "--rfc" "--services" ;;
70
+ init) compadd -S '' -- "--add" "--base" "--force" "--java" "--java:mvn" "--java:package" "--lint:custom" "--lint:custom:example" "--no-db" "--nodejs" "--verbose" ;;
71
+ inspect) compadd -S '' -- "--kind" "--list" "--stats" ;;
72
+ lint) compadd -S '' -- "--cache" "--cache-file" "--cache-location" "--cache-strategy" "--color" "--concurrency" "--config" "--debug" "--env-info" "--exit-on-fatal-error" "--ext" "--fix" "--fix-dry-run" "--fix-type" "--flag" "--format" "--global" "--help" "--ignore-pattern" "--init" "--inspect-config" "--max-warnings" "--mcp" "--no-color" "--no-config-lookup" "--no-error-on-unmatched-pattern" "--no-ignore" "--no-inline-config" "--no-warn-ignored" "--output-file" "--parser" "--parser-options" "--pass-on-no-patterns" "--pass-on-unpruned-suppressions" "--plugin" "--print-config" "--prune-suppressions" "--quiet" "--report-unused-disable-directives" "--report-unused-disable-directives-severity" "--report-unused-inline-configs" "--rule" "--stats" "--stdin" "--stdin-filename" "--suppress-all" "--suppress-rule" "--suppressions-location" "--version" ;;
73
+ login) compadd -S '' -- "--client" "--mtls" "--passcode" "--plain" "--save-refresh-token" "--subdomain" "--user" ;;
74
+ logout) compadd -S '' -- "--clear-invalid" "--delete-settings" "--subdomain" "--url" ;;
75
+ minify) compadd -S '' -- "--cleanse" "--debug" "--dry" "--inspect" "--keep" "--skip" ;;
76
+ mock) compadd -S '' -- "--at" "--from" "--in-memory" "--in-memory?" "--mocked" "--port" "--project" "--projects" "--resolve-bindings" "--service" "--to" "--watch" "--with" "--with-bindings" "--with-mocks" "--with-mtx" "--workers" ;;
77
+ parse) compadd -S '' -- "--all" "--asyncapi:merged" "--beta" "--clean" "--conceptual" "--dest" "--dialect" "--docs" "--files" "--flavor" "--for" "--from" "--lang" "--locations" "--log-level" "--min" "--odata-version" "--openapi:config-file" "--openapi:diagram" "--openapi:servers" "--openapi:url" "--parse" "--plain" "--resolved" "--service" "--sort" "--sources" "--sql-dialect" "--to" ;;
78
+ pull) compadd -S '' -- "--client" "--from" "--mtls" "--passcode" "--subdomain" "--user" ;;
79
+ push) compadd -S '' -- "--async" "--client" "--mtls" "--passcode" "--subdomain" "--sync" "--to" "--user" ;;
80
+ repl) compadd -S '' -- "--ql" "--run" "--use" ;;
81
+ run) compadd -S '' -- "--at" "--from" "--in-memory" "--in-memory?" "--mocked" "--port" "--project" "--projects" "--resolve-bindings" "--service" "--to" "--watch" "--with" "--with-bindings" "--with-mocks" "--with-mtx" "--workers" ;;
82
+ serve) compadd -S '' -- "--at" "--from" "--in-memory" "--in-memory?" "--mocked" "--port" "--project" "--projects" "--resolve-bindings" "--service" "--to" "--watch" "--with" "--with-bindings" "--with-mocks" "--with-mtx" "--workers" ;;
83
+ subscribe) compadd -S '' -- "--body" "--local" "--resolve-bindings" "--to" "--user" ;;
84
+ test) compadd -S '' -- "--exclude" "--failed" "--files" "--include" "--list" "--passed" "--quiet" "--recent" "--silent" "--timeout" "--unmute" "--verbose" "--workers" ;;
85
+ unsubscribe) compadd -S '' -- "--from" "--local" "--resolve-bindings" "--user" ;;
86
+ up) compadd -S '' -- "--namespace" "--overlay" "--to" ;;
87
+ upgrade) compadd -S '' -- "--at" "--fix" "--local" "--report" "--resolve-bindings" "--user" ;;
88
+ upgrade-tenant) compadd -S '' -- "--at" "--local" "--resolve-bindings" "--user" ;;
89
+ version) compadd -S '' -- "--abs" "--all" "--depth" "--info" "--json" "--markdown" "--omit" ;;
90
+ watch) compadd -S '' -- "--debug" "--exclude" "--experimental-hot-reload" "--ext" "--in-memory" "--in-memory?" "--include" "--inspect" "--inspect-brk" "--livereload" "--open" "--port" "--with-mocks" "--with-mtx" ;;
91
+ esac && return
92
+ fi
93
+
94
+ # Step 3.5: option-value completion — triggered when the previous word is a known option.
95
+ case "$cmd" in
96
+ bind)
97
+ case "$previous" in
98
+ --on) compadd -S '' -- "cf" "k8s" ; return ;;
99
+ --out) _files ; return ;;
100
+ --output-file) _files ; return ;;
101
+ esac ;;
102
+ build)
103
+ case "$previous" in
104
+ --for) compadd -S '' -- "hana" "helm" "java" "mtx" "mtx-extension" "mtx-sidecar" "nodejs" ; return ;;
105
+ --log-level) compadd -S '' -- "debug" "error" "info" "warn" ; return ;;
106
+ --dest) _files -/ ; return ;;
107
+ --src) _files -/ ; return ;;
108
+ esac ;;
109
+ compile)
110
+ case "$previous" in
111
+ --to) compadd -S '' -- "asyncapi" "cdl" "edm" "edmx" "edmx-v2" "edmx-v4" "hana" "hdbtable" "json" "openapi" "sql" "xsuaa" "yml" ; return ;;
112
+ --for) compadd -S '' -- "odata" "sql" ; return ;;
113
+ --dialect) compadd -S '' -- "h2" "hana" "postgres" "sqlite" ; return ;;
114
+ --sql-dialect) compadd -S '' -- "h2" "hana" "postgres" "sqlite" ; return ;;
115
+ --log-level) compadd -S '' -- "debug" "error" "info" "warn" ; return ;;
116
+ --odata-version) compadd -S '' -- "4.0" "4.01" ; return ;;
117
+ --flavor) compadd -S '' -- "files" "inferred" "parsed" "sources" "xtended" ; return ;;
118
+ --service) compadd -S '' -- "all" ; return ;;
119
+ --lang) compadd -S '' -- "all" ; return ;;
120
+ --dest) _files -/ ; return ;;
121
+ esac ;;
122
+ completion)
123
+ case "$previous" in
124
+ --shell) compadd -S '' -- "bash" "fish" "gitbash" "ps" "zsh" ; return ;;
125
+ esac ;;
126
+ deploy)
127
+ case "$previous" in
128
+ --to) compadd -S '' -- "hana" "sqlite" ; return ;;
129
+ --on) compadd -S '' -- "cf" "k8s" ; return ;;
130
+ esac ;;
131
+ import)
132
+ case "$previous" in
133
+ --from) compadd -S '' -- "asyncapi" "edmx" "openapi" ; return ;;
134
+ --as) compadd -S '' -- "cds" "csn" "json" ; return ;;
135
+ esac ;;
136
+ init)
137
+ case "$previous" in
138
+ --java:package) _files -/ ; return ;;
139
+ esac ;;
140
+ inspect)
141
+ case "$previous" in
142
+ --kind) compadd -S '' -- "aspect" "entity" "service" "type" ; return ;;
143
+ esac ;;
144
+ parse)
145
+ case "$previous" in
146
+ --to) compadd -S '' -- "asyncapi" "cdl" "edm" "edmx" "edmx-v2" "edmx-v4" "hana" "hdbtable" "json" "openapi" "sql" "xsuaa" "yml" ; return ;;
147
+ --for) compadd -S '' -- "odata" "sql" ; return ;;
148
+ --dialect) compadd -S '' -- "h2" "hana" "postgres" "sqlite" ; return ;;
149
+ --sql-dialect) compadd -S '' -- "h2" "hana" "postgres" "sqlite" ; return ;;
150
+ --log-level) compadd -S '' -- "debug" "error" "info" "warn" ; return ;;
151
+ --odata-version) compadd -S '' -- "4.0" "4.01" ; return ;;
152
+ --flavor) compadd -S '' -- "files" "inferred" "parsed" "sources" "xtended" ; return ;;
153
+ --service) compadd -S '' -- "all" ; return ;;
154
+ --lang) compadd -S '' -- "all" ; return ;;
155
+ --dest) _files -/ ; return ;;
156
+ esac ;;
157
+ up)
158
+ case "$previous" in
159
+ --to) compadd -S '' -- "cf" "k8s" ; return ;;
160
+ esac ;;
161
+ version)
162
+ case "$previous" in
163
+ --omit) compadd -S '' -- "dev" "optional" "peer" ; return ;;
164
+ esac ;;
165
+ watch)
166
+ case "$previous" in
167
+ --experimental-hot-reload) compadd -S '' -- "false" "true" ; return ;;
168
+ --livereload) compadd -S '' -- "false" ; return ;;
169
+ --include) _files -/ ; return ;;
170
+ --exclude) _files -/ ; return ;;
171
+ esac ;;
172
+
173
+ esac
174
+
175
+ # Step 3.6: comma-separated option-value completion.
176
+ case "$cmd" in
177
+ add)
178
+ case "$previous" in
179
+ *)
180
+ [[ "$previous" == -* ]] && return
181
+ local -a _used=("${(s:,:)current}")
182
+ local prefix="${(j:,:)_used[1,-2]}" partial="${_used[-1]}"
183
+ [[ -n "$prefix" ]] && prefix="$prefix,"
184
+ local -a _all=("ai" "ams" "app-frontend" "application-logging" "approuter" "attachments" "audit-logging" "cf-manifest" "cjs" "cloud-logging" "completion" "connectivity" "console" "data" "destination" "dynatrace" "enterprise-messaging" "enterprise-messaging-shared" "event-mesh" "event-mesh-shared" "extensibility" "extension" "file-based-messaging" "github-actions" "h2" "hana" "hana-serverless" "handler" "html5-repo" "http" "ias" "initial" "kafka" "kyma" "lint" "liquibase" "local-messaging" "malware-scanner" "mta" "mtx" "multitenancy" "notifications" "pipeline" "portal" "postgres" "react" "redis" "redis-messaging" "sample" "side-by-side-extensibility" "sqlite" "telemetry" "test" "tiny-sample" "toggles" "typer" "typescript" "ui5" "vue" "workzone" "workzone-standard" "xsuaa") _result=()
185
+ for v in "${_all[@]}"; do
186
+ (( ${_used[(Ie)$v]} )) && continue
187
+ [[ "$v" == "$partial"* ]] && _result+=("$v")
188
+ done
189
+ compadd -p "$prefix" -S '' -- "${_result[@]}" ; return ;;
190
+ esac ;;
191
+ init)
192
+ case "$previous" in
193
+ --add)
194
+ local -a _used=("${(s:,:)current}")
195
+ local prefix="${(j:,:)_used[1,-2]}" partial="${_used[-1]}"
196
+ [[ -n "$prefix" ]] && prefix="$prefix,"
197
+ local -a _all=("ai" "ams" "app-frontend" "application-logging" "approuter" "attachments" "audit-logging" "cf-manifest" "cjs" "cloud-logging" "completion" "connectivity" "console" "data" "destination" "dynatrace" "enterprise-messaging" "enterprise-messaging-shared" "event-mesh" "event-mesh-shared" "extensibility" "extension" "file-based-messaging" "github-actions" "h2" "hana" "hana-serverless" "handler" "html5-repo" "http" "ias" "initial" "kafka" "kyma" "lint" "liquibase" "local-messaging" "malware-scanner" "mta" "mtx" "multitenancy" "notifications" "pipeline" "portal" "postgres" "react" "redis" "redis-messaging" "sample" "side-by-side-extensibility" "sqlite" "telemetry" "test" "tiny-sample" "toggles" "typer" "typescript" "ui5" "vue" "workzone" "workzone-standard" "xsuaa") _result=()
198
+ for v in "${_all[@]}"; do
199
+ (( ${_used[(Ie)$v]} )) && continue
200
+ [[ "$v" == "$partial"* ]] && _result+=("$v")
201
+ done
202
+ compadd -p "$prefix" -S '' -- "${_result[@]}" ; return ;;
203
+ esac ;;
204
+
205
+ esac
206
+
207
+ # Step 4: file-sentinel positionals — emit files and return.
208
+ case "$cmd" in
209
+ compile) _files -g '(*.cds|*.json)' ; return ;;
210
+ deploy) _files -g '(*.cds|*.json)' ; return ;;
211
+ import) _files -g '(*.json|*.xml|*.edmx)' ; return ;;
212
+ inspect) _files -g '(*.cds|*.json)' ; return ;;
213
+ parse) _files -g '(*.cds|*.json)' ; return ;;
214
+ esac
215
+
216
+ # Step 4.6: string positionals (e.g. cds help <tab>) — return after matching.
217
+ case "$cmd" in
218
+ help) compadd -S '' -- "add" "bind" "build" "compile" "completion" "debug" "deploy" "env" "eval" "export" "gen" "help" "import" "init" "inspect" "lint" "login" "logout" "minify" "mock" "parse" "pull" "push" "repl" "run" "serve" "subscribe" "test" "unsubscribe" "up" "upgrade" "upgrade-tenant" "version" "watch" ; return ;;
219
+ esac && return
220
+
221
+ # Step 5: dynamic fallback — calls 'cds completion' for subcommands whose arguments
222
+ # cannot be determined statically (e.g. service names, model names, unknown flags).
223
+ # Single-quoting $prev/$curr prevents bare word 'h' from being interpreted
224
+ # as the 'help' shortcut by the completion handler before it is processed.
225
+ # compadd -S '' suppresses the trailing space zsh normally appends after a completion.
226
+ compadd -S '' -- $(${CDS_COMMAND} completion --shell zsh --prev "'${words[CURRENT-1]}'" --curr "'${words[CURRENT]}'" --line "'${words[*]}'")
227
+ }
228
+
229
+ # Register the completion function for the 'cds' command.
230
+ compdef _completeCds ${CDS_COMMAND}
@@ -0,0 +1,65 @@
1
+ #!/bin/fish
2
+ # This file was generated from bin/completion/templates/cds-tmpl.fish by
3
+ # 'cds completion --generate' and is written to bin/completion/scripts/cds.fish.
4
+ #
5
+ # Do not edit directly — modify the template and regenerate.
6
+ #
7
+ # Fish's completion model differs from bash/zsh: instead of one catch-all function,
8
+ # each subcommand and flag gets its own 'complete' line with a condition (-n).
9
+ # The static section covers all known commands, flags, and positionals up-front;
10
+ # _completeCdsDynamic handles the rest.
11
+ #
12
+ # Key fish completion flags used below:
13
+ # -c <cmd> : the command this completion applies to
14
+ # -n <cond> : only activate when the condition returns 0 (success)
15
+ # -f : do not complete with file names (required when -a provides the values)
16
+ # -a : argument values shown as completions
17
+
18
+ # Erase any previously-loaded completions for 'cds' so stale entries from older
19
+ # versions of this file do not accumulate across shell restarts.
20
+ complete -c cds -e
21
+
22
+ # Static completions: one 'complete' call per known command, flag, or positional.
23
+ # __fish_use_subcommand — returns 0 (true) when no subcommand token has been typed yet.
24
+ # __fish_seen_subcommand_from <tokens> — returns 0 when any of <tokens> is on the line.
25
+ {{COMMAND_COMPLETIONS}}
26
+
27
+ # Helper for comma-separated option values (e.g. --add ai,ams,<tab>).
28
+ # Call with the full list of valid values as arguments:
29
+ # _cdsCommaComplete val1 val2 val3
30
+ # Reads the current token, splits on commas, omits already-used values,
31
+ # and echoes remaining candidates prefixed with the already-typed portion.
32
+ function _cdsCommaComplete
33
+ set -l all_values $argv
34
+ set -l cur (commandline -ct)
35
+ set -l parts (string split , $cur)
36
+ set -l prefix (string join , $parts[1..-2])
37
+ set -l partial $parts[-1]
38
+ if test (count $parts) -gt 1
39
+ set prefix $prefix","
40
+ end
41
+ for v in $all_values
42
+ if contains $v $parts[1..-2]
43
+ continue
44
+ end
45
+ if string match -q "$partial*" $v
46
+ echo $prefix$v
47
+ end
48
+ end
49
+ end
50
+
51
+ # Dynamic fallback — called for subcommands whose arguments cannot be determined
52
+ # statically (e.g. service names, model names, unknown flags).
53
+ # File paths for commands like compile/deploy are handled by the static FILE() sentinel above.
54
+ # Single-quoting $previous/$current prevents bare word 'h' from being interpreted
55
+ # as the 'help' shortcut by the completion handler before it is processed.
56
+ function _completeCdsDynamic
57
+ set -l tokens (commandline -opc)
58
+ set -l current (commandline -ct)
59
+ set -l previous $tokens[-1]
60
+ set -l line (commandline -cp)
61
+ cds completion --shell fish --prev "'$previous'" --curr "'$current'" --line "'$line'"
62
+ end
63
+ # Activate the dynamic fallback only after a known subcommand (or its shortcut) has been
64
+ # seen, so it does not shadow the static top-level command list.
65
+ complete -c cds -f -n '__fish_seen_subcommand_from {{CMD_LIST_WITH_SHORTCUTS}}' --arguments "(_completeCdsDynamic)"
@@ -0,0 +1,208 @@
1
+ # This file was generated from bin/completion/templates/cds-tmpl.ps1 by
2
+ # 'cds completion --generate' and is written to bin/completion/scripts/cds.ps1.
3
+ #
4
+ # Do not edit directly — modify the template and regenerate.
5
+ #
6
+ # All static completion data is stored in a single hashtable ($_CDS_COMPLETIONS)
7
+ # for O(1) lookup. The ScriptBlock registered with Register-ArgumentCompleter
8
+ # follows the same fastest-first strategy as the bash/zsh templates:
9
+ # 1. Top-level commands — when cursor is on the subcommand token.
10
+ # 2. Shortcut resolution — single-char alias → canonical command name.
11
+ # 3. Flags — when $wordToComplete starts with '-'.
12
+ # 3.5. Option values — static values for known flags (e.g. --to sqlite).
13
+ # 3.6. Comma values — comma-separable list (e.g. cds add ai,hana).
14
+ # 4. Positionals — static known values per subcommand.
15
+ # 4.5. File sentinel — files only (flags shown only when $wordToComplete starts with '-').
16
+ # 5. Dynamic fallback — calls 'cds completion' for everything else.
17
+
18
+ $_CDS_COMMAND = "cds"
19
+
20
+ # Completion data map:
21
+ # __commands — array of all top-level subcommand names
22
+ # __shortcuts — hashtable of shortcut → canonical command name
23
+ # __positionals — hashtable of command → array of known positional string values
24
+ # __optionValues — hashtable of command → hashtable of flag → array of values,
25
+ # or one of the file sentinels ':file', ':dir', ':file:ext1,ext2'
26
+ # __commaCases — hashtable of command → hashtable of flag → array of comma-separable values
27
+ # <cmd> — array of flags/options for that subcommand (used by step 3)
28
+ $_CDS_COMPLETIONS = @{
29
+ '__commands' = @({{CMD_ARRAY}});
30
+ '__shortcuts' = @{
31
+ {{SHORTCUT_ENTRIES}}
32
+ };
33
+ '__positionals' = @{
34
+ {{POSITIONAL_ENTRIES}}
35
+ };
36
+ '__optionValues' = @{
37
+ {{OPTION_VALUE_ENTRIES}}
38
+ };
39
+ '__commaCases' = @{
40
+ {{COMMA_ENTRIES}}
41
+ };
42
+ {{CMD_ENTRIES}}
43
+ }
44
+
45
+ # $wordToComplete : the token currently being typed (may be empty if cursor is after a space)
46
+ # $commandAst : the full parsed command AST; .CommandElements is the token array
47
+ # $cursorPosition : byte offset of the cursor in the command string
48
+ Register-ArgumentCompleter -Native -CommandName $_CDS_COMMAND -ScriptBlock {
49
+ param($wordToComplete, $commandAst, $cursorPosition)
50
+
51
+ $map = $_CDS_COMPLETIONS
52
+ $cmdSegments = $commandAst.CommandElements
53
+ if ($null -eq $wordToComplete) { $wordToComplete = '' }
54
+
55
+ # Helper: emit file/dir completions for a sentinel value.
56
+ # Sentinel formats: ':file' (any file), ':dir' (directories only),
57
+ # ':file:ext1,ext2' (files with specific extensions).
58
+ # Uses relative paths (preserving any typed prefix) so the completed text stays short.
59
+ function _CdsFileComplete($sentinel, $word) {
60
+ $base = if ($word) { $word } else { '' }
61
+ $search = if ($word) { "$word*" } else { '*' }
62
+ # Parse extension list from ':file:cds,json' → @('.cds', '.json')
63
+ $exts = if ($sentinel -like ':file:*') {
64
+ ($sentinel -replace '^:file:', '').Split(',') | ForEach-Object { ".$_" }
65
+ } else { $null }
66
+ if ($sentinel -eq ':dir') {
67
+ Get-ChildItem -Path $search -Directory -ErrorAction SilentlyContinue |
68
+ ForEach-Object {
69
+ $rel = $base + $_.Name
70
+ [System.Management.Automation.CompletionResult]::new($rel, $_.Name, 'ProviderItem', $_.Name)
71
+ }
72
+ } else {
73
+ Get-ChildItem -Path $search -File -ErrorAction SilentlyContinue |
74
+ Where-Object { $null -eq $exts -or $exts -contains $_.Extension } |
75
+ ForEach-Object {
76
+ $rel = $base + $_.Name
77
+ [System.Management.Automation.CompletionResult]::new($rel, $_.Name, 'ProviderItem', $_.Name)
78
+ }
79
+ }
80
+ }
81
+
82
+ # Step 1: top-level command completion — cursor is on the subcommand token itself.
83
+ # Either no subcommand yet (count=1) or the user is still typing it (count=2, partial match).
84
+ $isTopLevel = $cmdSegments.Count -eq 1 -or ($cmdSegments.Count -eq 2 -and $wordToComplete -ne '' -and $cmdSegments[1].Extent.Text -eq $wordToComplete)
85
+ if ($isTopLevel) {
86
+ foreach ($cmd in $map['__commands']) {
87
+ if ($cmd.StartsWith($wordToComplete)) {
88
+ [System.Management.Automation.CompletionResult]::new($cmd, $cmd, 'ParameterValue', $cmd)
89
+ }
90
+ }
91
+ return
92
+ }
93
+
94
+ # Step 2: resolve shortcut to canonical command name so the rest of the
95
+ # logic only needs to handle canonical names.
96
+ $subCmd = $cmdSegments[1].Extent.Text
97
+ $resolved = $map['__shortcuts'][$subCmd]
98
+ if ($null -ne $resolved) { $subCmd = $resolved }
99
+
100
+ # Compute $previousWord — the token immediately before the cursor.
101
+ # When $wordToComplete is empty the cursor is after a space, so the last completed
102
+ # token is the previous word. When non-empty the cursor is mid-token, so look one
103
+ # further back. EndOffset filtering keeps only tokens that end before the cursor.
104
+ $prevCandidates = $cmdSegments | Where-Object { $_.Extent.EndOffset -le $cursorPosition }
105
+ $previousWord = if ($wordToComplete -eq '') {
106
+ ($prevCandidates | Select-Object -Last 1).Extent.Text
107
+ } else {
108
+ ($prevCandidates | Select-Object -Last 2 | Select-Object -First 1).Extent.Text
109
+ }
110
+
111
+ # Step 3: flag/option completion — triggered when $wordToComplete starts with '-'.
112
+ if ($wordToComplete.StartsWith('-')) {
113
+ $entry = $map[$subCmd]
114
+ if ($null -ne $entry) {
115
+ foreach ($opt in $entry) {
116
+ if ($opt.StartsWith($wordToComplete)) {
117
+ [System.Management.Automation.CompletionResult]::new($opt, $opt, 'ParameterValue', $opt)
118
+ }
119
+ }
120
+ return
121
+ }
122
+ }
123
+
124
+ # Step 3.5: option-value completion — triggered when the previous word is a known option.
125
+ $optVals = $map['__optionValues'][$subCmd]
126
+ if ($null -ne $optVals) {
127
+ $entry = $optVals[$previousWord]
128
+ if ($null -ne $entry) {
129
+ if ($entry -eq ':dir' -or $entry -eq ':file' -or $entry -like ':file:*') {
130
+ _CdsFileComplete $entry $wordToComplete
131
+ } else {
132
+ foreach ($val in $entry) {
133
+ if ($val.StartsWith($wordToComplete)) {
134
+ [System.Management.Automation.CompletionResult]::new($val, $val, 'ParameterValue', $val)
135
+ }
136
+ }
137
+ }
138
+ return
139
+ }
140
+ }
141
+
142
+ # Step 3.6: comma-separated option-value completion.
143
+ $commaVals = $map['__commaCases'][$subCmd]
144
+ if ($null -ne $commaVals) {
145
+ # Primary lookup: previous word is the option flag (e.g. '--add').
146
+ $entry = $commaVals[$previousWord]
147
+ if ($null -eq $entry -and $previousWord.EndsWith(',')) {
148
+ # Space-separated continuation: user typed "cds add ai, <tab>" so $previousWord="ai,"
149
+ # and $wordToComplete is empty. Scan backwards through segments to find the flag.
150
+ $prevSegs = @($cmdSegments | ForEach-Object { $_.Extent.Text })
151
+ $prevIdx = [array]::LastIndexOf($prevSegs, $previousWord) - 1
152
+ while ($prevIdx -ge 0 -and -not $prevSegs[$prevIdx].StartsWith('-')) { $prevIdx-- }
153
+ if ($prevIdx -ge 0) { $entry = $commaVals[$prevSegs[$prevIdx]] }
154
+ }
155
+ # Positional fallback: previous word is not a flag (it's the subcommand or a value).
156
+ if ($null -eq $entry -and -not $previousWord.StartsWith('-')) {
157
+ $entry = $commaVals['_']
158
+ }
159
+ if ($null -ne $entry) {
160
+ # For space-separated comma continuation, fold previousWord into the prefix/alreadyUsed.
161
+ $spaceComma = $previousWord.EndsWith(',')
162
+ $commaWord = if ($spaceComma) { $previousWord + $wordToComplete } else { $wordToComplete }
163
+ $parts = $commaWord.Split(',')
164
+ $prefix = if ($parts.Count -gt 1) { ($parts[0..($parts.Count-2)] -join ',') + ',' } else { '' }
165
+ $partial = $parts[-1]
166
+ $alreadyUsed = @{}
167
+ foreach ($u in $parts[0..($parts.Count-2)]) { if ($u) { $alreadyUsed[$u] = $true } }
168
+ foreach ($val in $entry) {
169
+ if (-not $alreadyUsed.ContainsKey($val) -and $val.StartsWith($partial)) {
170
+ # When space-separated (prev="ai,"), PS replaces only $wordToComplete (=''),
171
+ # so return just $val — the prefix is already on the line.
172
+ $full = if ($spaceComma) { $val } else { $prefix + $val }
173
+ [System.Management.Automation.CompletionResult]::new($full, $val, 'ParameterValue', $val)
174
+ }
175
+ }
176
+ return
177
+ }
178
+ }
179
+
180
+ # Step 4: static string positionals (e.g. cds help <tab>).
181
+ $positionals = $map['__positionals'][$subCmd]
182
+ if ($null -ne $positionals) {
183
+ $matched = $false
184
+ foreach ($pos in $positionals) {
185
+ if ($pos.StartsWith($wordToComplete)) {
186
+ [System.Management.Automation.CompletionResult]::new($pos, $pos, 'ParameterValue', $pos)
187
+ $matched = $true
188
+ }
189
+ }
190
+ if ($matched) { return }
191
+ }
192
+
193
+ # Step 4.5: default file sentinel — files only, no flags appended.
194
+ $defaultFile = $map['__optionValues'][$subCmd]?['_']
195
+ if ($null -ne $defaultFile) {
196
+ _CdsFileComplete $defaultFile $wordToComplete
197
+ return
198
+ }
199
+
200
+ # Step 5: dynamic fallback — calls 'cds completion' for subcommands whose arguments
201
+ # cannot be determined statically (e.g. service names, model names, unknown flags).
202
+ # Single-quoting $previousWord/$wordToComplete prevents bare word 'h' from being
203
+ # interpreted as the 'help' shortcut by the completion handler.
204
+ $options = & $_CDS_COMMAND completion --shell ps --prev "'$previousWord'" --curr "'$wordToComplete'" --line "'$commandAst'"
205
+ foreach ($option in $options) {
206
+ [System.Management.Automation.CompletionResult]::new($option, $option, 'ParameterValue', $option)
207
+ }
208
+ }
@@ -0,0 +1,93 @@
1
+ #!/bin/bash
2
+ # This file was generated from bin/completion/templates/cds-tmpl.sh by
3
+ # 'cds completion --generate' and is written to bin/completion/scripts/cds.sh.
4
+ #
5
+ # Do not edit directly — modify the template and regenerate.
6
+ #
7
+ # Completion strategy (fastest-first):
8
+ # 1. Shortcuts — single-character aliases resolved before any other logic.
9
+ # 2. Top-level — all known subcommands when no subcommand has been typed yet.
10
+ # 3. Flags — matched when the current token starts with '-'.
11
+ # 3.5. Option values — static values for known flags (e.g. --to sqlite).
12
+ # 3.6. Comma values — comma-separable list (e.g. cds add ai,hana).
13
+ # 4. File positionals — files/dirs for subcommands that take a path argument.
14
+ # 4.6. String positionals — fixed word list (e.g. cds help <tab>).
15
+ # 5. Dynamic fallback — calls 'cds completion' for anything not covered above.
16
+ #
17
+ # compopt -o nospace suppresses the trailing space bash normally appends after a
18
+ # completion, which is required for path completions (so the user can keep typing
19
+ # a subdirectory) and for flag names (so '=' can follow immediately).
20
+ CDS_COMMAND="cds"
21
+
22
+ _completeCds()
23
+ {
24
+ local current previous cmd
25
+ COMPREPLY=()
26
+ current="${COMP_WORDS[COMP_CWORD]}"
27
+ previous="${COMP_WORDS[COMP_CWORD - 1]}"
28
+ # The subcommand is always the second token (index 1).
29
+ cmd="${COMP_WORDS[1]}"
30
+ # Step 1: resolve single-character shortcuts to their canonical command name
31
+ # so that subsequent case statements only need to handle canonical names.
32
+ {{SHORTCUT_CASE}}
33
+ # Step 2: top-level — offer all known subcommands when no subcommand has been
34
+ # typed yet (COMP_WORDS includes the command itself, so ≤ 2 means "cds <cursor>").
35
+ if [[ "${#COMP_WORDS[@]}" -le 2 ]]; then
36
+ COMPREPLY=( $(compgen -W "{{COMMANDS}}" -- "$current") )
37
+ compopt -o nospace
38
+ return 0
39
+ fi
40
+
41
+ # Step 3: flag/option completion — only triggered when the token starts with '-'.
42
+ if [[ "$current" == -* ]]; then
43
+ case "$cmd" in
44
+ {{FLAG_CASES}}
45
+ esac
46
+ if [[ "${#COMPREPLY[@]}" -gt 0 ]]; then
47
+ compopt -o nospace
48
+ return 0
49
+ fi
50
+ fi
51
+
52
+ # Step 3.5: option-value completion — triggered when the previous word is a known option.
53
+ case "$cmd" in
54
+ {{OPTION_VALUE_CASES}}
55
+ esac
56
+
57
+ # Step 3.6: comma-separated option-value completion.
58
+ # Splits $current on commas, filters out already-used values, prepends the prefix.
59
+ case "$cmd" in
60
+ {{COMMA_CASES}}
61
+ esac
62
+
63
+ # Step 4: file-sentinel positionals — fill COMPREPLY with files and return.
64
+ case "$cmd" in
65
+ {{FILE_CASES}}
66
+ esac
67
+ if [[ "${#COMPREPLY[@]}" -gt 0 ]]; then
68
+ compopt -o nospace
69
+ return 0
70
+ fi
71
+
72
+ # Step 4.6: string positionals (e.g. cds help <tab>).
73
+ case "$cmd" in
74
+ {{STRING_POSITIONAL_CASES}}
75
+ esac
76
+ if [[ "${#COMPREPLY[@]}" -gt 0 ]]; then
77
+ compopt -o nospace
78
+ return 0
79
+ fi
80
+
81
+ # Step 5: dynamic fallback — calls 'cds completion' for subcommands whose arguments
82
+ # cannot be determined statically (e.g. service names, model names, unknown flags).
83
+ # Single-quoting $previous/$current prevents bare word 'h' from being interpreted
84
+ # as the 'help' shortcut by the completion handler before it is processed.
85
+ local options
86
+ options=$($CDS_COMMAND completion --shell bash --prev "'$previous'" --curr "'$current'" --line "'${COMP_WORDS[*]}'")
87
+ COMPREPLY=( $(compgen -W "${options}" -- "${current}") )
88
+ compopt -o nospace
89
+ return 0
90
+ }
91
+
92
+ # Register the completion function for the 'cds' command.
93
+ complete -F _completeCds "$CDS_COMMAND"