@sap/cds-dk 8.2.3 → 8.4.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 (84) hide show
  1. package/CHANGELOG.md +66 -11
  2. package/bin/build.js +1 -1
  3. package/bin/cds.js +17 -4
  4. package/bin/compile/index.js +12 -3
  5. package/bin/deploy/index.js +22 -3
  6. package/bin/env.js +3 -2
  7. package/bin/import.js +24 -14
  8. package/bin/init.js +8 -4
  9. package/bin/repl.js +21 -8
  10. package/bin/util/fuzzySearch.js +8 -5
  11. package/lib/build/plugins/helm/files/subcharts/content-deployment/Chart.yaml +1 -1
  12. package/lib/build/plugins/helm/files/subcharts/content-deployment/values.schema.json +1 -1
  13. package/lib/build/plugins/helm/files/subcharts/content-deployment/values.yaml +1 -1
  14. package/lib/build/plugins/helm/files/subcharts/web-application/Chart.yaml +1 -1
  15. package/lib/build/plugins/helm/files/subcharts/web-application/templates/virtual-service.yaml +23 -12
  16. package/lib/build/plugins/helm/files/subcharts/web-application/values.schema.json +1 -1
  17. package/lib/build/plugins/helm/files/subcharts/web-application/values.yaml +2 -2
  18. package/lib/build/util.js +32 -20
  19. package/lib/compile/to-mermaid.js +87 -0
  20. package/lib/deploy/to-hana/hana.js +2 -21
  21. package/lib/env/schemas/cds-rc.js +174 -2
  22. package/lib/import/asyncapi/parserContext.js +4 -30
  23. package/lib/import/common.js +2 -2
  24. package/lib/import/importapi.js +3 -3
  25. package/lib/import/odata/v2parser.js +3 -2
  26. package/lib/import/openapi/importOpenAPI.js +622 -537
  27. package/lib/import/openapi/utilities.js +7 -2
  28. package/lib/init/constants.js +2 -1
  29. package/lib/init/index.js +4 -0
  30. package/lib/init/merge.js +2 -2
  31. package/lib/init/mvn.js +2 -2
  32. package/lib/init/projectReader.js +2 -1
  33. package/lib/init/registries/mta.js +8 -1
  34. package/lib/init/registries/xs-app.js +10 -0
  35. package/lib/init/template/approuter/files/package.json +1 -1
  36. package/lib/init/template/cf-manifest/files/manifest.yml.hbs +3 -1
  37. package/lib/init/template/cf-manifest/index.js +2 -0
  38. package/lib/init/template/cloud-logging/files/mta.yaml.hbs +13 -2
  39. package/lib/init/template/cloud-logging/files/{package.json → package.json.hbs} +5 -1
  40. package/lib/init/template/cloud-logging/index.js +4 -3
  41. package/lib/init/template/data/as-csv.js +6 -0
  42. package/lib/init/template/data/as-json.js +8 -1
  43. package/lib/init/template/data/index.js +1 -1
  44. package/lib/init/template/destination/files/mta.yaml.hbs +5 -5
  45. package/lib/init/template/dynatrace/files/mta.yaml.hbs +22 -6
  46. package/lib/init/template/dynatrace/files/package.json.hbs +5 -2
  47. package/lib/init/template/dynatrace/files/values.yaml +15 -0
  48. package/lib/init/template/dynatrace/index.js +10 -5
  49. package/lib/init/template/enterprise-messaging-shared/index.js +1 -1
  50. package/lib/init/template/file-based-messaging/index.js +1 -1
  51. package/lib/init/template/hana/files/package.json.hbs +2 -0
  52. package/lib/init/template/hana/index.js +1 -1
  53. package/lib/init/template/handler/index.js +16 -1
  54. package/lib/init/template/helm/files/values.yaml.hbs +2 -2
  55. package/lib/init/template/helm/index.js +6 -1
  56. package/lib/init/template/html5-repo/files/app-package.json.hbs +3 -1
  57. package/lib/init/template/html5-repo/files/ui5-deploy.yaml.hbs +7 -0
  58. package/lib/init/template/html5-repo/index.js +3 -1
  59. package/lib/init/template/local-messaging/index.js +1 -1
  60. package/lib/init/template/mta/files/mta.yaml.hbs +1 -1
  61. package/lib/init/template/mta/index.js +2 -0
  62. package/lib/init/template/nodejs/files/.vscode/extensions.json +0 -5
  63. package/lib/init/template/nodejs/files/.vscode/settings.json +1 -1
  64. package/lib/init/template/nodejs/files/.vscode/tasks.json +0 -2
  65. package/lib/init/template/nodejs/files/package.json.hbs +1 -1
  66. package/lib/init/template/postgres/index.js +1 -1
  67. package/lib/init/template/redis-messaging/index.js +1 -1
  68. package/lib/init/template/side-by-side-extensibility/files/mta.yaml.hbs +40 -0
  69. package/lib/init/template/side-by-side-extensibility/files/package.json.hbs +17 -0
  70. package/lib/init/template/side-by-side-extensibility/index.js +34 -0
  71. package/lib/init/template/typer/index.js +2 -1
  72. package/lib/init/template/typescript/files/package.json +2 -2
  73. package/lib/init/template/workzone-standard/files/manifest.json.hbs +15 -1
  74. package/lib/init/template/workzone-standard/files/mta.yaml.hbs +11 -2
  75. package/lib/init/template/workzone-standard/files/xs-app.json.hbs +18 -0
  76. package/lib/init/template/workzone-standard/index.js +25 -7
  77. package/lib/init/template/xsuaa/index.js +1 -1
  78. package/lib/mtx/auth_manager.js +7 -5
  79. package/lib/mtx/util/errors.js +4 -4
  80. package/lib/util/fs.js +1 -1
  81. package/lib/util/jsonc.js +1 -1
  82. package/lib/util/jsonc.pegjs +6 -2
  83. package/npm-shrinkwrap.json +78 -149
  84. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -7,6 +7,55 @@ This project adheres to [Semantic Versioning](http://semver.org/).
7
7
 
8
8
  The format is based on [Keep a Changelog](http://keepachangelog.com/).
9
9
 
10
+ ## Version 8.4.0 - 2024-10-29
11
+
12
+ ### Added
13
+
14
+ - Added support for `import` and `export` for auto-completion in `package.json` and `.cdsrc.json`.
15
+ - `cds add side-by-side-extensibility` adds configuration for logic extensibility via extension points (Java).
16
+ - `cds init --java` can be used as an alias to `cds init --add java`.
17
+ - Add cds schema for `helm` build plugin.
18
+
19
+ ### Changed
20
+
21
+ - `cds init` does not put comments in JSON files within `.vscode/`.
22
+ - `cds import --from asyncapi` now uses CloudEvents type in `@topic` annotation.
23
+ - `cds deploy` does not fall back to the deprecated `hanatrial` service plan any more.
24
+
25
+ ### Fixed
26
+
27
+ - `cds env` now colors is output honoring settings like `FORCE_COLOR`.
28
+ - `cds add` commands correctly detect Java/Node in Microsoft PowerShell.
29
+ - `cds add hana` doesn't add `dependencies` to `.cdsrc.json` any more.
30
+ - `cds add cf-manifest` uses the new `sap_java_buildpack_jakarta` buildpack.
31
+ - `cds build --production` now correctly formats console log output.
32
+ - `cds add` correctly handles entries like `cds.requires.auth` if the following configuration is scoped in a profile.
33
+ - `cds add` plugins can use a shortcut for their options.
34
+ - `cds import` fix for no entity schema in OData V2.
35
+
36
+ ## Version 8.3.0 - 2024-09-30
37
+
38
+ ### Added
39
+
40
+ - `cds add mta`, `cds add helm` and `cds add cf-manifest` execute the `mvn cds:add -Dfeature CF/K8S` under the hood for Java projects.
41
+ - `cds compile --to mermaid` now supports `mta.yaml` to generate a visualization of your deployment descriptor.
42
+ - `cds add data` now also generates data for models imported with `cds import`.
43
+ - `cds add data` now also supports structured types.
44
+ - `cds deploy` now can also write its DDL statements to a separate log file with the `--out <file>` parameter.
45
+ - `cds add dynatrace` is now supported for Kyma.
46
+ - `cds import --name ...` to be used in RFC importer (`@sap/cds-rfc`).
47
+ - `cds add cloud-logging --with-telemetry` and `cds add dynatrace` are added to the `production` profile by default and respect the `for` option.
48
+
49
+ ### Changed
50
+
51
+ - `cds add sample` now uses `@ui5/cli` version 4.
52
+ - `cds import` now throws a warning for OpenAPI files containing recursive data types.
53
+
54
+ ### Fixed
55
+
56
+ - `cds add workzone`-created apps can now directly be added via Content Manager in SAP Build Work Zone.
57
+ - Less obtrusive warning about `cds` instead of `cds-ts` in Typescript projects.
58
+
10
59
  ## Version 8.2.3 - 2024-09-25
11
60
 
12
61
  ### Fixed
@@ -41,7 +90,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/).
41
90
  - `cds add dynatrace` adds configuration for Dynatrace.
42
91
  - `cds add cloud-logging` adds configuration for SAP Cloud Logging. Option `--with-telemetry` allows for configuration with telemetry.
43
92
  - `cds version` shows version information for `@cap-js/db-service`.
44
- - `cds add portal` now adds portal configuration for Kyma.
93
+ - `cds add portal` now adds SAP Cloud Portal configuration for Kyma.
45
94
  - `cds add handler` allows to create handler stubs (for Java only, beta)
46
95
  - `cds init --add java --no-db` lets you create a Java project without persistent database.
47
96
  - `cds import` supports plugins.
@@ -122,7 +171,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/).
122
171
  - `cds compile --to mermaid` no longer fails for complex queries like joins.
123
172
  - `cds build --for mtx-sidecar` now correctly supports different `srv` folder name.
124
173
  - `cds add audit-log` in combination with `cds add multitenancy` correctly adds the audit-log dependency to the MTX sidecar.
125
- - `cds build` adds the correct hdbtabledata file paths to the hana result set.
174
+ - `cds build` adds the correct hdbtabledata file paths to the HANA result set.
126
175
  - `cds add` plugins can now correctly interpret `cds.cli` properties.
127
176
  - `cds deploy --to hana --dry` now shows correct files with their content.
128
177
  - `cds version` now reports the correct version of `@sap/cds` if this one is installed locally along with a local `@sap/cds-dk` installation.
@@ -252,7 +301,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/).
252
301
  - `cds login` eagerly fetches the passcode URL (if supported by `@sap/cds-mtxs`) and prints it on prompt.
253
302
  - `cds extend` and `cds activate` have been deprecated and are now removed. (You can still migrate and download projects, see `cds migrate --help` and `cds extend --help`.)
254
303
  - Remove obsolete classic MTX checks and enforce `@sap/cds` >= 7.
255
- - `cds build` uses cds.compile.to.hana API with `@sap/cds` 8.
304
+ - `cds build` uses `cds.compile.to.hana` API with `@sap/cds` 8.
256
305
  - `cds bind` and `cds deploy` use direct http requests instead of `cf curl`.
257
306
  - `cds build --for java` no longer generates localized EDMX files by default. It can be enabled using `contentLocalizedEdmx` build task option.
258
307
  - `@cap-js/sqlite`/`better-sqlite3` is used in dependencies instead of `sqlite3`.
@@ -265,6 +314,11 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/).
265
314
 
266
315
  - `cds add notebook` is removed. CAP Jupyter Notebooks have been replaced by custom CAP Notebooks for VS Code which are now part of the CDS Editor. See https://cap.cloud.sap/docs/tools/#add-cds-editor for more.
267
316
 
317
+ ## Version 7.9.8 - 2024-09-17
318
+
319
+ ### Fixed
320
+
321
+ - BDSA-2024-6188: vulnerability with express.js 4.19.2
268
322
 
269
323
  ## Version 7.9.7 - 2024-08-22
270
324
 
@@ -349,7 +403,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/).
349
403
  - `cds add` doesn't fail for projects with a minimal `package.json` w/o `name` and `version` fields
350
404
  - `cds add data` can be executed in projects w/o `package.json` and `.cdsrc.json` files.
351
405
  - `cds add sample` does not fail if the `srv` folder doesn't exist.
352
- - `cds add helm` fixed xsuaa tenant-mode not updating on adding `multitenancy`
406
+ - `cds add helm` fixed XSUAA tenant-mode not updating on adding `multitenancy`
353
407
  - `cds watched` cannot be called from command line anymore.
354
408
  - `cds login` now correctly handles the case of an expired refresh token and gives more information about token-request errors.
355
409
  - `cds login` now refreshes the token URL if it had previously reverted to a legacy URL.
@@ -631,11 +685,11 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/).
631
685
  - `cds add connectivity` does not add `connectivity: true` to your `package.json` any more.
632
686
  - `cds watch` now ignores more files/folders: `app/(webapp|dist|target)`, `app/*/(webapp|dist|target)`, `tsconfig.json`, `*.tsbuildinfo`
633
687
  - `cds build` now uses `compile.to.hdbtable` if no migration tables exist.
634
- - Refactoring `cds build plugin` API
688
+ - `cds build` plugin API is refactored.
635
689
 
636
690
  ### Fixed
637
691
 
638
- - `cds login` now prints shorter errors. (Set `DEBUG=req` in env to see all details again.)
692
+ - `cds login` now prints shorter errors (set `DEBUG=req` in env to see all details again).
639
693
  - Fixed issue when creating a CAP project in SAP Business Application Studio's template wizard.
640
694
  - `cds import` now handles name collision within a Schema for OData V4 EDMX.
641
695
  - `cds build` for mtx extension projects no longer creates CSN containing unresolved model associations.
@@ -681,7 +735,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/).
681
735
 
682
736
  ### Removed
683
737
 
684
- - Undocumented facet `cds add auditlog`
738
+ - `cds add auditlog` facet.
685
739
 
686
740
  ## Version 7.1.1 - 2023-08-10
687
741
 
@@ -704,7 +758,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/).
704
758
 
705
759
  - Calls from Business Application Studio `New Project from Template` wizard are now handled correctly.
706
760
  - `cds add cf-manifest` correctly generates the XSUAA instance name.
707
- - `cds build` always uses the configured hana build task when building the MTX sidecar.
761
+ - `cds build` always uses the configured HANA build task when building the MTX sidecar.
708
762
  - `cds import` OData V4 EDMX fix for Annotation Alias and Namespace value replacement.
709
763
 
710
764
  ### Changed
@@ -1187,7 +1241,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/).
1187
1241
  - `cds import` switch from `@openapi.schema` to `@JSON.Schema`.
1188
1242
  - `cds add mtx` will now add configuration for streamlined MTX. It effectively acts as a shortcut for `cds add multitenancy,toggles,extensibility`
1189
1243
  - `cds add mtx` no longer includes `hana` and `xsuaa`. To achieve the same effect as before, run `cds add mtx && cds add hana,xsuaa --for production`.
1190
- - `cds bind -2 <xsuaa service instance>` binds the CDS `auth` service to the xsuaa instance. Previously `uaa` was used. This requires `@sap/cds` 6 or higher.
1244
+ - `cds bind -2 <xsuaa service instance>` binds the CDS `auth` service to the XSUAA instance. Previously `uaa` was used. This requires `@sap/cds` 6 or higher.
1191
1245
  - `cds add lint:dev` updated to adjust to new api structure of `@sap/eslint-plugin-cds` v2.5.0
1192
1246
  - `cds init` uses latest Maven Java archetype version 1.27.0 for creating Java projects.
1193
1247
  - `cds login localhost:<port> -u <username>` now saves username (and empty password, if applicable) with project settings for convenience.
@@ -1384,7 +1438,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/).
1384
1438
  - `cds import` bug fixed for `--force` flag. Now overwrites the correct file content.
1385
1439
  - `cds import` fix will no longer capture unwanted annotations in the CSN for OData V4.
1386
1440
  - `cds import` now support annotations for properties of type `Type Definition`
1387
- - `cds import` fix for supporting valid datatypes in unbounded function imports for OData V4.
1441
+ - `cds import` fix for supporting valid data types in unbounded function imports for OData V4.
1388
1442
  - `cds import` bug fixed for missing data imports for parameters with entity type not mapped to an entity set.
1389
1443
  - `cds import` now supports properties with complex type for OData V4.
1390
1444
  - `cds import` fix will now throw error if the key property of an entity is of type `Collection` for both OData V2 and V4 edmx.
@@ -1521,9 +1575,10 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/).
1521
1575
  - `cds lint` now limits all file extensions to those allowed by the @sap/eslint-plugin-cds ESLint configuration
1522
1576
 
1523
1577
  ## Version 4.6.0 - 2021-11-02
1578
+
1524
1579
  ### Added
1525
1580
 
1526
- - `cds bind` binds the given service to a hana instance by storing the credentials in `.cdsrc.json` in your user home directory [beta].
1581
+ - `cds bind` binds the given service to a HANA instance by storing the credentials in `.cdsrc.json` in your user home directory [beta].
1527
1582
  - `cds import` introduced option `--include-namespaces` which imports the custom defined namespaces.
1528
1583
  - `cds import` preserve documentation in CSN file for actions and functions from OData V4 EDMX file.
1529
1584
  - `cds import` now supports reading values of the `as` option from cds.env
package/bin/build.js CHANGED
@@ -148,7 +148,7 @@ async function build([project], options = {}) {
148
148
  // IMPORTANT: call plugins before subsequent access to cds.env
149
149
  await cds.plugins
150
150
 
151
- cds.env = cds.env.for('cds', cds.root);
151
+ cds.env = cds.env.for('cds', cds.root)
152
152
  delete options.project // avoid that relative project paths are resolved twice
153
153
 
154
154
  if (typeof options["options-model"] === "string") {
package/bin/cds.js CHANGED
@@ -68,6 +68,10 @@ const cli = {
68
68
  const flags = all.filter(([,f]) => f.type === 'boolean')
69
69
  const options = all.filter(([,o]) => o.type !== 'boolean')
70
70
  task.options.push(...options.map(([key]) => '--'+key))
71
+ task.shortcuts.push(...options.map(([_, { short }]) => short ? '-'+short : undefined).filter(Boolean))
72
+ const byShortcut = (a, b) => (b.short ? 1 : 0) - (a.short ? 1 : 0)
73
+ task.options.sort(byShortcut)
74
+ task.shortcuts.sort(byShortcut)
71
75
  task.flags.push(...flags.map(([key]) => '--'+key))
72
76
  }
73
77
  }
@@ -77,11 +81,12 @@ const cli = {
77
81
 
78
82
  if (args[1]?.['resolve-bindings']) await _resolveBindings({ silent: cmd === 'env' })
79
83
 
80
- // cds.root may for some subcommands not point to the correct directory (e.g. cds w where users can pass a project directory)
81
- // showing the full detected path should give the user an idea whether this info is relevant for them
84
+ // warn users if they are using cds instead of cds-ts in a TypeScript project
82
85
  const tsconfig = path.join(cds.root ?? '.', 'tsconfig.json')
83
- if (!process.env.CDS_TYPESCRIPT && fs.existsSync(tsconfig)) {
84
- console.info(`Detected ${tsconfig}. If this is a TypeScript project, consider running commands using cds-ts instead of cds.`)
86
+ if (!process.env.CDS_TYPESCRIPT && cds.cli?.command === 'serve' && fs.existsSync(tsconfig)) {
87
+ // cds.root may for some subcommands not point to the correct directory (e.g. cds w where users can pass a project directory)
88
+ // showing the full detected path should give the user an idea whether this info is relevant for them
89
+ console.error(`Detected ${tsconfig}. If this is a TypeScript project, consider running commands using 'cds-ts' instead of 'cds'.\n`)
85
90
  }
86
91
  return await task.apply(this, args)
87
92
  }
@@ -137,6 +142,14 @@ const cli = {
137
142
  add (k, e[path[0]] = v)
138
143
  }
139
144
 
145
+ // always use 'plain' log format for cds-dk logging
146
+ // by default 'plain' log format is used for development while 'json' format is used for production, see cap/cds/blob/main/lib/env/defaults.js#L97
147
+ // the json formatter logs stringified JSON which causing any line breaks to get replaced by '\n'
148
+ // using the env variable ensures that cds.env isn't loaded too early
149
+ env ??= {}
150
+ env.log ??= {}
151
+ env.log.format = 'plain'
152
+
140
153
  // if (env) require('../lib/cds').env.add (env) //> avoid loading env
141
154
  // unless it has already explicitly been set by the user
142
155
  if (env) process.env.CDS_CONFIG ??= JSON.stringify(env)
@@ -4,7 +4,7 @@ const {colors} = require('../../lib/util/term')
4
4
  module.exports = Object.assign ( compile, {
5
5
  handleCompletion,
6
6
  options: [
7
- '--from', '--service', '--lang', '--for', '--to', '--dest', '--log-level', '--flavor', '--dialect', '--sql-dialect', '--openapi:url', '--openapi:servers', '--odata-version'
7
+ '--from', '--service', '--lang', '--for', '--to', '--dest', '--log-level', '--flavor', '--dialect', '--sql-dialect', '--openapi:url', '--openapi:servers', '--openapi:config-file', '--odata-version'
8
8
  ],
9
9
  shortcuts: [
10
10
  undefined, '-s', '-l', '-4', '-2', '-o', undefined, '-f'
@@ -135,6 +135,11 @@ module.exports = Object.assign ( compile, {
135
135
 
136
136
  Include YUML diagram in the generated OpenAPI document, default: *false*.
137
137
 
138
+ *--openapi:config-file* filename
139
+
140
+ The passed configuration file will be read to generate the OpenAPI document, incorporating all specified options.
141
+ Precedence of Options: Inline options specified in the command line will take precedence over those defined in the configuration file.
142
+
138
143
  *--asyncapi:merged*
139
144
 
140
145
  A single AsyncAPI document is generated using the details of all input services. Information of _title_
@@ -230,8 +235,12 @@ async function compile (models, options={}) {
230
235
  const messages = options.messages = []
231
236
 
232
237
  if (Array.isArray(models) && models.length > 0) { // any arguments?
233
- model = cds.load (models, options)
234
- src = models[0] .replace (/\.[^.]+$/,'') //> excluding source file extension, e.g. .cds
238
+ if (/mta.*\.ya?ml/.test(models[0])) {
239
+ model = Promise.resolve(models[0])
240
+ } else {
241
+ model = cds.load (models, options)
242
+ src = models[0] .replace (/\.[^.]+$/,'') //> excluding source file extension, e.g. .cds
243
+ }
235
244
  } else if (!process.stdin.isTTY && process.argv[1].endsWith('cds')) { // else check for stdin
236
245
  model = readModelFromStdin()
237
246
  src = 'stdin'
@@ -1,7 +1,7 @@
1
1
  module.exports = Object.assign(deploy, {
2
- options: ['--to', '--for', '--tunnel-address', '--vcap-file', '--delta-from' ],
2
+ options: ['--to', '--for', '--out', '--tunnel-address', '--vcap-file', '--delta-from' ],
3
3
  flags: ['--no-save', '--auto-undeploy', '--dry', '--xdry', '--with-mocks', '--store-credentials', '--model-only', '--script', '--with-auto-schema-evolution' ],
4
- shortcuts: ['-2', '-4'],
4
+ shortcuts: ['-2', '-4', '-o'],
5
5
  help: `
6
6
  # SYNOPSIS
7
7
 
@@ -37,6 +37,11 @@ module.exports = Object.assign(deploy, {
37
37
 
38
38
  Just print the SQL statements without executing them.
39
39
 
40
+ *--out* | *-o* <file>
41
+
42
+ Write the DDL statements to the given file.
43
+ Not available in combination with '--to hana'.
44
+
40
45
  *--with-mocks*
41
46
 
42
47
  Also create tables for all entities from imported models.
@@ -134,10 +139,19 @@ async function deploy(_model, options) { // NOSONAR
134
139
  }
135
140
  try {
136
141
  options.messages = []
137
- if(options.script) options.dry = true // to ensure that we don't accidentally execute any SQLs
142
+ if (options.script) options.dry = true // to ensure that we don't accidentally execute any SQLs
143
+ if (options.out) {
144
+ ensureVersion(cds.version, 8, 3, `Option --out is available with @sap/cds >= 8.3.0, current version is ${cds.version}`)
145
+ options.schema_log = []
146
+ }
147
+
138
148
  await deployer.deploy(_model, _db, options)
139
149
  const log = this.log || _log
140
150
  if (options.messages.length) log (options.messages, options)
151
+
152
+ if (options.out) {
153
+ await cds.utils.write (options.out, options.schema_log.join('\n'))
154
+ }
141
155
  } catch (e) {
142
156
  if (e.code === 'MODEL_NOT_FOUND') {
143
157
  if (!_model) throw new Error('No .cds models found, please specify one as an argument')
@@ -153,3 +167,8 @@ function _log (messages, options) {
153
167
  messages = sortMessagesSeverityAware (messages)
154
168
  cds._log (messages, options)
155
169
  }
170
+
171
+ function ensureVersion(version, reqMajor, reqMinor, message) {
172
+ const [major, minor] = version.split('.').map(Number)
173
+ if (major < reqMajor || (major === reqMajor && minor < reqMinor)) throw message
174
+ }
package/bin/env.js CHANGED
@@ -72,6 +72,7 @@ async function env ([cmd, key, value], options={}) {
72
72
 
73
73
 
74
74
  const { inspect, format } = require('node:util')
75
+ const {colors} = require('../lib/util/term')
75
76
  const commands = {
76
77
 
77
78
  json: (env,k,v,o) => commands.get (env,k,v,{...o,json:true}),
@@ -87,7 +88,7 @@ const commands = {
87
88
  },
88
89
 
89
90
  get (conf, key, val, options) {
90
- let fmt = x => inspect (x, {depth:22,colors:true})
91
+ let fmt = x => inspect (x, {depth:22, colors})
91
92
 
92
93
  let obj = (
93
94
  !key ? conf
@@ -96,7 +97,7 @@ const commands = {
96
97
  : conf.get(key.replace(/^cds\./,''))
97
98
  )
98
99
 
99
- if (!process.stdout.isTTY) {
100
+ if (!colors) {
100
101
  fmt = x => typeof x !== 'object' ? x : JSON.stringify(x,0,2)
101
102
  }
102
103
  if (options.json) {
package/bin/import.js CHANGED
@@ -1,8 +1,8 @@
1
1
  module.exports = Object.assign(_import, {
2
2
  _name: 'import',
3
- options: ['--out', '--as', '--include-namespaces', '--from', '--config', '--destination'],
3
+ options: ['--out', '--as', '--name', '--include-namespaces', '--from', '--config', '--destination'],
4
4
  flags: ['--dry', '--force', '--no-copy', '--no-save', '--keep-namespace', '--beta'],
5
- shortcuts: ['-o', '-as', '-ns', undefined, '-c', undefined, '-', '-f'],
5
+ shortcuts: ['-o', '-as', '-n', '-ns', undefined, '-c', undefined, '-', '-f'],
6
6
  help: `
7
7
  # SYNOPSIS
8
8
 
@@ -43,7 +43,7 @@ module.exports = Object.assign(_import, {
43
43
  *--from*
44
44
  Imports the model from the one of the given options "edmx", "openapi" or
45
45
  "asyncapi".
46
-
46
+
47
47
  *-c | --config* <JSON Object>
48
48
  Adds the provided JSON Object as custom configuration data to the package.json.
49
49
 
@@ -51,6 +51,10 @@ module.exports = Object.assign(_import, {
51
51
  Enables beta mode in cds import.
52
52
  - Populates default value for optional action and function parameters in the CSN or CDS.
53
53
 
54
+ *--destination*
55
+ Destination name under which the remote service can be reached.
56
+ Not supported by import types "edmx", "openapi" or "asyncapi".
57
+
54
58
  *Below options are valid for OData only*
55
59
 
56
60
  *--keep-namespace*
@@ -62,10 +66,11 @@ module.exports = Object.assign(_import, {
62
66
  For OData V2 attributes with the namespace "sap" & "m" are captured by
63
67
  default.
64
68
 
65
- *--destination*
66
- Destination name under which the remote service can be reached.
67
- Not supported by import types "edmx", "openapi" or "asyncapi".
69
+ *Below options are valid for RFC only*
68
70
 
71
+ *-n | --name*
72
+ The name of the module to be imported
73
+ Requires valid system credentials as the import connects to the system to fetch the metadata.
69
74
 
70
75
  # EXAMPLES
71
76
 
@@ -85,20 +90,25 @@ const messages = require('../lib/import/message').getMessages();
85
90
  const common = require('../lib/import/common');
86
91
  const cdsImport = require('../lib/index');
87
92
 
88
- async function _import(file, options = {}) {
89
- let csn = "";
93
+ async function _import(args, options = {}) {
94
+ let csn = '';
90
95
  let apiOptions = {};
91
96
  // preprocess
92
97
  let cwd = process.cwd();
93
- if (Array.isArray(file)) file = file[0];
94
- if (!file) return this.help('import');
95
98
  // process options
96
99
  await common.processOptions(options, apiOptions);
97
- const srcFilePath = await common.preProcess(file, options, cwd);
98
100
 
99
101
  const cds = require('../lib/cds')
100
102
  await cds.plugins
101
103
 
104
+ let file
105
+ let input
106
+ if (!options.name) {
107
+ file = Array.isArray(args) ? args[0] : args
108
+ if (!file) return this.help('import')
109
+ input = await common.preProcess(file, options, cwd);
110
+ }
111
+
102
112
  // process - csn generation
103
113
  // if --from option is given, call api directly accordingly
104
114
  if (options.from) {
@@ -106,14 +116,14 @@ async function _import(file, options = {}) {
106
116
  // the required plugin might not be installed, e.g. rfc importer
107
117
  throw messages.UNSUPPORTED_FROM_OPTION;
108
118
  }
109
- csn = await cdsImport.import.from[options.from](srcFilePath, apiOptions);
119
+ csn = await cdsImport.import.from[options.from](input, apiOptions);
110
120
  } else {
111
- csn = await cdsImport.import(srcFilePath, apiOptions);
121
+ csn = await cdsImport.import(input, apiOptions);
112
122
  }
113
123
 
114
124
  // reads the file version
115
125
  options.inputFileKind = apiOptions.odataVersion ? apiOptions.odataVersion : apiOptions.inputFileKind;
116
126
 
117
127
  // postprocess
118
- return await common.postProcess(file, options, csn, cwd);
128
+ return await common.postProcess(apiOptions.file ?? file, options, csn, cwd);
119
129
  }
package/bin/init.js CHANGED
@@ -9,7 +9,7 @@ module.exports = Object.assign(init, {
9
9
  handleCompletion,
10
10
  options: ['--add', '--java:mvn', '--java:package', '--lint:custom', '--lint:custom:example', '--no-db'],
11
11
  shortcuts: ['-a'],
12
- flags: ['--force', '--verbose'],
12
+ flags: ['--java', '--force', '--verbose'],
13
13
  help: `
14
14
  # SYNOPSIS
15
15
 
@@ -20,6 +20,10 @@ module.exports = Object.assign(init, {
20
20
 
21
21
  # OPTIONS
22
22
 
23
+ *--java*
24
+
25
+ Create a CAP Java project.
26
+
23
27
  *--add* <feature | comma-separated list of features>
24
28
 
25
29
  Add one or more features while creating the project.
@@ -40,10 +44,10 @@ ${require('../lib/init').help()}
40
44
  # EXAMPLES
41
45
 
42
46
  *cds init* bookshop
43
- *cds init* bookshop --add java
44
- *cds init* bookshop --add java,hana
47
+ *cds init* bookshop --java
48
+ *cds init* bookshop --add hana
45
49
  *cds init* bookshop --add multitenancy,mta
46
- *cds init* --add java --java:mvn groupId=myGroup,artifactId=newId,package=my.company
50
+ *cds init* --java --java:mvn groupId=myGroup,artifactId=newId,package=my.company
47
51
 
48
52
  # SEE ALSO
49
53
 
package/bin/repl.js CHANGED
@@ -1,4 +1,4 @@
1
-
1
+
2
2
  module.exports = Object.assign (repl, { options: [], help: `
3
3
  # SYNOPSIS
4
4
 
@@ -24,7 +24,9 @@ async function repl (_, options={}) {
24
24
 
25
25
 
26
26
  const repl = require('repl').start ({
27
- ...options, ignoreUndefined: true,
27
+ ...options,
28
+ ignoreUndefined: true,
29
+ useGlobal: true,
28
30
  writer: o => {
29
31
  if (!o || typeof o !== 'object') return o
30
32
  return inspect(o).replace(/\[Object: null prototype\] /g, '')
@@ -32,12 +34,23 @@ async function repl (_, options={}) {
32
34
  })
33
35
 
34
36
  Object.defineProperty (cds,'repl',{value:repl})
35
- cds.lazify (Object.assign (repl.context,{ cds,
36
-
37
- Foo: lazy => new cds.entity ({name:'Foo'}),
38
- Bar: lazy => new cds.entity ({name:'Bar'}),
39
- expect: lazy => cds.test.expect,
40
- }))
37
+ cds.extend (repl.context) .with ( class {
38
+ get Foo() { return ctx.Foo ??= new cds.entity({ name: 'Foo' }) }; set Foo(v) { ctx.Foo = v }
39
+ get Bar() { return ctx.Bar ??= new cds.entity({ name: 'Bar' }) }; set Bar(v) { ctx.Bar = v }
40
+ get expect() { return ctx.expect ??= cds.test.expect }; set expect(v) { ctx.expect = v }
41
+ } .prototype )
42
+ const ctx={}
43
+
44
+ repl.defineCommand ('run', {
45
+ help: 'Runs a cds server in the given CAP project folder, which can be a module name like @capire/bookshop.',
46
+ async action (project) {
47
+ // await cds.exec ('--project', project, '--port', '0')
48
+ await cds.test (project)
49
+ console.log ('Following are made avaliable as global variables:')
50
+ console.log ('- cds.services:', Object.keys(cds.services)); Object.assign (repl.context, cds.services)
51
+ console.log ('- cds.entities:', Object.keys(cds.entities)); Object.assign (repl.context, cds.entities)
52
+ }
53
+ })
41
54
 
42
55
  repl.history = new Array(222)
43
56
  const home = process.env.HOME || process.env.USERPROFILE
@@ -8,7 +8,7 @@
8
8
  */
9
9
 
10
10
 
11
- const cache = {};
11
+ const cache = new Map();
12
12
 
13
13
 
14
14
  module.exports = (input, list, log) => {
@@ -52,8 +52,9 @@ module.exports = (input, list, log) => {
52
52
 
53
53
  const levDistance = (a, b) => {
54
54
 
55
- if (cache[a] && cache[a][b]) {
56
- return cache[a][b];
55
+ const cachedObj = cache.get(a)?.get(b);
56
+ if (cachedObj) {
57
+ return cachedObj;
57
58
  }
58
59
 
59
60
  if (a.length === 0) {
@@ -81,7 +82,9 @@ const levDistance = (a, b) => {
81
82
 
82
83
 
83
84
  const addToCache = (a, b, value) => {
84
- cache[a] = cache[a] || {};
85
- cache[a][b] = value;
85
+ if (!cache.has(a)) {
86
+ cache.set(a, new Map());
87
+ }
88
+ cache.get(a).set(b, value);
86
89
  return value;
87
90
  }
@@ -2,4 +2,4 @@ apiVersion: v2
2
2
  description: A Helm Chart for creating a Content Deployment job
3
3
  name: content-deployment
4
4
  type: application
5
- version: 1.6.2
5
+ version: 1.6.3
@@ -528,7 +528,7 @@
528
528
  "title": "Image tag",
529
529
  "type": "string",
530
530
  "$comment": "Copied from https://github.com/containers/image/blob/18d58d29fdc4fc32fb8a8a6d186b829b217f1bf5/docker/reference/regexp.go#L68-L70",
531
- "pattern": "^((?:(?:[a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9])(?:(?:\\.(?:[a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9]))+)?(?::[0-9]+)?/)?[a-z0-9]+(?:(?:(?:[._]|__|[-]*)[a-z0-9]+)+)?(?:(?:/[a-z0-9]+(?:(?:(?:[._]|__|[-]*)[a-z0-9]+)+)?)+)?)(?::([\\w][\\w.-]{0,127}))?(?:@([A-Za-z][A-Za-z0-9]*(?:[-_+.][A-Za-z][A-Za-z0-9]*)*[:][[:xdigit:]]{32,}))?$"
531
+ "pattern": "^((?:(?:[a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9])(?:(?:\\.(?:[a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9]))+)?(?::[0-9]+)?/)?[a-z0-9]+(?:(?:(?:[._]|__|[-]*)[a-zA-Z0-9]+)+)?(?:(?:/[a-z0-9]+(?:(?:(?:[._]|__|[-]*)[a-z0-9]+)+)?)+)?)(?::([\\w][\\w.-]{0,127}))?(?:@([A-Za-z][A-Za-z0-9]*(?:[-_+.][A-Za-z][A-Za-z0-9]*)*[:][[:xdigit:]]{32,}))?$"
532
532
  },
533
533
  "ImagePullPolicy": {
534
534
  "title": "ImagePullPolicy",
@@ -15,7 +15,7 @@ global:
15
15
  _internal:
16
16
  content-deployment:
17
17
  versions:
18
- 1.6.2: true
18
+ 1.6.3: true
19
19
  # Will be used instead of the `.Chart.Name`, e.g. when generating the Deployment name.
20
20
  # nameOverride: name
21
21
 
@@ -3,4 +3,4 @@ description: A Helm chart for web app
3
3
  kubeVersion: '>= 1.21'
4
4
  name: web-application
5
5
  type: application
6
- version: 1.17.0
6
+ version: 1.17.2
@@ -1,4 +1,4 @@
1
- {{- if include "web-application.internal.TENANT_HOST_PATTERN" . -}}
1
+ {{- if and .Values.expose.enabled (include "web-application.internal.TENANT_HOST_PATTERN" .) -}}
2
2
  apiVersion: networking.istio.io/v1beta1
3
3
  kind: VirtualService
4
4
  metadata:
@@ -10,7 +10,26 @@ spec:
10
10
  hosts:
11
11
  - "*"
12
12
  http:
13
- - corsPolicy:
13
+ {{- range $httpRule := .Values.expose.rules }}
14
+ - match:
15
+ - uri:
16
+ regex: {{ $httpRule.path }}
17
+ {{- if $httpRule.methods }}
18
+ method:
19
+ regex: ^({{ join "|" $httpRule.methods }})$
20
+ {{- end }}
21
+ headers:
22
+ Host:
23
+ regex: {{ tpl (include "web-application.internal.TENANT_HOST_PATTERN" $) $ }}
24
+ route:
25
+ - weight: 100
26
+ destination:
27
+ host: "{{ include "web-application.fullname" $ }}.{{ $.Release.Namespace }}.svc.cluster.local"
28
+ {{- if $httpRule.corsPolicy }}
29
+ corsPolicy:
30
+ {{ $httpRule.corsPolicy | toYaml | nindent 8 }}
31
+ {{- else }}
32
+ corsPolicy:
14
33
  allowHeaders:
15
34
  - Authorization
16
35
  - Content-Type
@@ -23,14 +42,6 @@ spec:
23
42
  - PATCH
24
43
  allowOrigins:
25
44
  - regex: .*
26
- match:
27
- - uri:
28
- regex: /.*
29
- headers:
30
- Host:
31
- regex: {{ tpl (include "web-application.internal.TENANT_HOST_PATTERN" .) . }}
32
- route:
33
- - weight: 100
34
- destination:
35
- host: "{{ include "web-application.fullname" . }}.{{ .Release.Namespace }}.svc.cluster.local"
45
+ {{- end }}
46
+ {{- end }}
36
47
  {{- end }}
@@ -1326,7 +1326,7 @@
1326
1326
  "title": "Image tag",
1327
1327
  "type": "string",
1328
1328
  "$comment": "Copied from https://github.com/containers/image/blob/18d58d29fdc4fc32fb8a8a6d186b829b217f1bf5/docker/reference/regexp.go#L68-L70",
1329
- "pattern": "^((?:(?:[a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9])(?:(?:\\.(?:[a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9]))+)?(?::[0-9]+)?/)?[a-z0-9]+(?:(?:(?:[._]|__|[-]*)[a-z0-9]+)+)?(?:(?:/[a-z0-9]+(?:(?:(?:[._]|__|[-]*)[a-z0-9]+)+)?)+)?)(?::([\\w][\\w.-]{0,127}))?(?:@([A-Za-z][A-Za-z0-9]*(?:[-_+.][A-Za-z][A-Za-z0-9]*)*[:][[:xdigit:]]{32,}))?$"
1329
+ "pattern": "^((?:(?:[a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9])(?:(?:\\.(?:[a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9]))+)?(?::[0-9]+)?/)?[a-z0-9]+(?:(?:(?:[._]|__|[-]*)[a-zA-Z0-9]+)+)?(?:(?:/[a-z0-9]+(?:(?:(?:[._]|__|[-]*)[a-z0-9]+)+)?)+)?)(?::([\\w][\\w.-]{0,127}))?(?:@([A-Za-z][A-Za-z0-9]*(?:[-_+.][A-Za-z][A-Za-z0-9]*)*[:][[:xdigit:]]{32,}))?$"
1330
1330
  },
1331
1331
  "ImagePullPolicy": {
1332
1332
  "title": "ImagePullPolicy",
@@ -15,7 +15,7 @@ global:
15
15
  _internal:
16
16
  web-application:
17
17
  versions:
18
- 1.17.0: true
18
+ 1.17.2: true
19
19
  ## Will be used instead of the `.Chart.Name`, e.g. when generating the Deployment name.
20
20
  # nameOverride: name
21
21
 
@@ -159,7 +159,7 @@ expose:
159
159
  # Rules represents collection of Rule to apply.
160
160
  rules:
161
161
  - accessStrategies:
162
- - handler: allow
162
+ - handler: no_auth
163
163
  methods:
164
164
  - GET
165
165
  - POST