@sap/cds-dk 6.7.1 → 6.8.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 (123) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/bin/deploy/index.js +1 -1
  3. package/bin/import.js +5 -3
  4. package/bin/login.js +29 -9
  5. package/bin/migrate.js +6 -2
  6. package/bin/watch.js +16 -0
  7. package/lib/bind/bindingUtil.js +2 -2
  8. package/lib/bind/userCdsrcJsonStorageProvider.js +1 -1
  9. package/lib/client/auth_manager.js +3 -1
  10. package/lib/client/helper/errors.js +6 -1
  11. package/lib/client/params.js +22 -20
  12. package/lib/client/settings_manager.js +17 -3
  13. package/lib/compile/openapi/csdl2openapi.js +4 -1
  14. package/lib/import/asyncapi/importAsyncAPI.js +32 -0
  15. package/lib/import/asyncapi/index.js +15 -0
  16. package/lib/import/asyncapi/parserContext.js +351 -0
  17. package/lib/import/asyncapi/utils.js +18 -0
  18. package/lib/import/common.js +21 -67
  19. package/lib/import/importapi.js +23 -2
  20. package/lib/import/message.js +11 -1
  21. package/lib/import/odata/index.js +14 -11
  22. package/lib/import/odata/metadataconverter/MetadataConverter.js +35 -35
  23. package/lib/import/odata/util/MultiMap.js +5 -5
  24. package/lib/import/odata/v2parser.js +1 -0
  25. package/lib/import/odata/v4parser.js +1281 -1139
  26. package/lib/init/constants.js +10 -3
  27. package/lib/init/template/_merging/registry-mta.js +33 -36
  28. package/lib/init/template/approuter/files/mtxs-configmap-java.yaml +20 -0
  29. package/lib/init/template/approuter/files/mtxs-configmap-nodejs.yaml +12 -0
  30. package/lib/init/template/approuter/index.js +24 -33
  31. package/lib/init/template/auditlog/files/package.json.hbs +27 -0
  32. package/lib/init/template/auditlog/index.js +12 -6
  33. package/lib/init/template/cf-manifest/index.js +1 -1
  34. package/lib/init/template/connectivity/index.js +1 -1
  35. package/lib/init/template/destinations/index.js +4 -2
  36. package/lib/init/template/enterprise-messaging/files/package.json.hbs +19 -0
  37. package/lib/init/template/enterprise-messaging/index.js +15 -13
  38. package/lib/init/template/enterprise-messaging-shared/files/event-mesh.json.hbs +31 -0
  39. package/lib/init/template/enterprise-messaging-shared/files/mta.yaml.hbs +15 -0
  40. package/lib/init/template/enterprise-messaging-shared/files/package.json.hbs +22 -0
  41. package/lib/init/template/enterprise-messaging-shared/files/values.yaml +7 -0
  42. package/lib/init/template/enterprise-messaging-shared/index.js +51 -0
  43. package/lib/init/template/extensibility/files/package.json.hbs +20 -0
  44. package/lib/init/template/extensibility/index.js +4 -16
  45. package/lib/init/template/file-based-messaging/files/package.json.hbs +19 -0
  46. package/lib/init/template/file-based-messaging/index.js +25 -0
  47. package/lib/init/template/hana/files/package.json.hbs +33 -0
  48. package/lib/init/template/hana/index.js +38 -65
  49. package/lib/init/template/helm/chart/templates/_deployment_helpers.tpl +0 -12
  50. package/lib/init/template/helm/chart/templates/_helpers.tpl +1 -121
  51. package/lib/init/template/helm/index.js +1 -1
  52. package/lib/init/template/html5-repo/index.js +1 -1
  53. package/lib/init/template/java/index.js +2 -2
  54. package/lib/init/template/kibana-logging/files/package.json.hbs +17 -0
  55. package/lib/init/template/kibana-logging/index.js +6 -19
  56. package/lib/init/template/lint/index.js +1 -1
  57. package/lib/init/template/mta/index.js +2 -2
  58. package/lib/init/template/multitenancy/files/mtxs-configmap-java.yaml +3 -5
  59. package/lib/init/template/multitenancy/files/mtxs-configmap-nodejs.yaml +3 -10
  60. package/lib/init/template/multitenancy/files/package.json.hbs +5 -4
  61. package/lib/init/template/multitenancy/index.js +22 -19
  62. package/lib/init/template/nodejs/files/.vscode/launch.json +11 -3
  63. package/lib/init/template/nodejs/index.js +1 -1
  64. package/lib/init/template/pipeline/index.js +1 -1
  65. package/lib/init/template/redis-messaging/files/mta.yaml.hbs +14 -0
  66. package/lib/init/template/redis-messaging/files/package.json.hbs +22 -0
  67. package/lib/init/template/redis-messaging/index.js +50 -0
  68. package/lib/init/template/samples/index.js +3 -3
  69. package/lib/init/template/sqlite/files/package.json.hbs +12 -4
  70. package/lib/init/template/sqlite/index.js +5 -1
  71. package/lib/init/template/toggles/files/package.json.hbs +20 -0
  72. package/lib/init/template/toggles/index.js +3 -9
  73. package/lib/init/template/xsuaa/files/package.json.hbs +28 -0
  74. package/lib/init/template/xsuaa/index.js +8 -23
  75. package/lib/init/util/{md5Tracking.js → md5.js} +1 -1
  76. package/lib/init/util/merge.js +4 -9
  77. package/lib/init/util/{mvnArchetypeUtil.js → mvn.js} +3 -0
  78. package/lib/init/util/projectReader.js +25 -107
  79. package/lib/init/util/xml.js +56 -0
  80. package/lib/lint/checks.js +1 -1
  81. package/lib/lint/io.js +1 -1
  82. package/lib/{init/util/commandUtil.js → util/command.js} +4 -2
  83. package/lib/{init/util/fsUtil.js → util/fs.js} +2 -2
  84. package/npm-shrinkwrap.json +335 -2212
  85. package/package.json +5 -4
  86. package/lib/init/template/approuter/files/cds.cdsrc.json +0 -7
  87. package/lib/init/template/approuter/files/cds.cdsrc.json.hbs +0 -9
  88. package/lib/init/template/approuter/files/cds.package.json +0 -9
  89. package/lib/init/template/approuter/files/cds.package.json.hbs +0 -11
  90. package/lib/init/template/auditlog/files/dependencies.package.json +0 -5
  91. package/lib/init/template/enterprise-messaging/files/cds.package.json +0 -9
  92. package/lib/init/template/enterprise-messaging/files/cds.profile.package.json.hbs +0 -11
  93. package/lib/init/template/enterprise-messaging/files/cdsrc.json +0 -7
  94. package/lib/init/template/enterprise-messaging/files/cdsrc.json.hbs +0 -9
  95. package/lib/init/template/extensibility/files/cds.package.json +0 -7
  96. package/lib/init/template/extensibility/files/cds.package.json.hbs +0 -9
  97. package/lib/init/template/extensibility/files/cdsrc.json +0 -5
  98. package/lib/init/template/extensibility/files/cdsrc.json.hbs +0 -7
  99. package/lib/init/template/hana/files/java/cds.json.hbs +0 -7
  100. package/lib/init/template/hana/files/java/cds.profile.json.hbs +0 -12
  101. package/lib/init/template/hana/files/java/cds.shortcut.json.hbs +0 -5
  102. package/lib/init/template/hana/files/java/cds.shortcut.profile.json.hbs +0 -8
  103. package/lib/init/template/hana/files/nodejs/cds.json.hbs +0 -9
  104. package/lib/init/template/hana/files/nodejs/cds.profile.json.hbs +0 -14
  105. package/lib/init/template/hana/files/nodejs/cds.shortcut.json.hbs +0 -7
  106. package/lib/init/template/hana/files/nodejs/cds.shortcut.profile.json.hbs +0 -10
  107. package/lib/init/template/hana/files/nodejs/dependencies.package.json +0 -5
  108. package/lib/init/template/helm/chart/templates/_sapcp_helpers.tpl +0 -103
  109. package/lib/init/template/kibana-logging/files/cds.profile.package.json.hbs +0 -9
  110. package/lib/init/template/toggles/files/cds.package.json +0 -7
  111. package/lib/init/template/toggles/files/cds.package.json.hbs +0 -9
  112. package/lib/init/template/toggles/files/cdsrc.json +0 -5
  113. package/lib/init/template/toggles/files/cdsrc.json.hbs +0 -7
  114. package/lib/init/template/xsuaa/files/cds.cdsrc.json +0 -7
  115. package/lib/init/template/xsuaa/files/cds.cdsrc.json.hbs +0 -9
  116. package/lib/init/template/xsuaa/files/cds.package.json +0 -9
  117. package/lib/init/template/xsuaa/files/cds.package.json.hbs +0 -11
  118. package/lib/init/template/xsuaa/files/dependencies.package.json +0 -6
  119. package/lib/init/util/versionCompare.js +0 -73
  120. /package/lib/init/template/hana/files/{java/db → db}/package.json +0 -0
  121. /package/lib/init/template/hana/files/{common/src → src}/.hdiconfig +0 -0
  122. /package/lib/init/template/hana/files/{common/undeploy.json → undeploy.json} +0 -0
  123. /package/lib/init/util/{templateUtil.js → template.js} +0 -0
package/CHANGELOG.md CHANGED
@@ -7,6 +7,37 @@ 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 6.8.0 - 2023-05-04
11
+
12
+ ### Added
13
+
14
+ - `cds add file-based-messaging` adds configuration for file-based messaging (Node.js).
15
+ - `cds add redis-messaging` adds configuration for Redis messaging (Node.js).
16
+ - `cds add enterprise-messaging-shared` adds configuration for Event Mesh support with `kind = 'enterprise-messaging-shared'` (Node.js).
17
+ - `cds import` now supports OData V4 EDMX file containing multiple `Schemas` with single `EntityContainer`.
18
+ - `cds import` now supports importing of AsyncAPI documents.
19
+ - `cds login -m <clientid>[:<key>]` now supports X.509 (mTLS) credential-type in XSUAA binding of @sap/cds-mtxs.
20
+
21
+ ### Changed
22
+
23
+ - `cds init` uses latest Maven Java archetype version 1.34.0 for creating Java projects.
24
+
25
+
26
+ ### Fixed
27
+
28
+ - `cds-ts watch` now honors a `tsconfig.json` in the project
29
+ - launch script for `CAP projects` in VS Code fixed
30
+
31
+ ## Version 6.7.2 - 2023-04-27
32
+
33
+ ### Added
34
+
35
+ - Added option `--skip-verification` to command `cds migrate`. It skips the extension verification to save memory. Requires `@sap/cds-mtxs@1.7.3`.
36
+
37
+ ### Fixed
38
+
39
+ - Swagger UI no longer fails with an error `Value of 'namespaceAndName' parameter must be in the following format: <namespace>.<name>`
40
+
10
41
  ## Version 6.7.1 - 2023-04-19
11
42
 
12
43
  ### Changed
@@ -120,7 +120,7 @@ async function update_package_json (kind, model, database) {
120
120
  else if (kind === 'sqlite') requires.db.credentials = { database:'db.sqlite' }
121
121
  if (schema_evolution) requires.db.schema_evolution = schema_evolution
122
122
  await writeFile (package_json, JSON.stringify(conf,null,2))
123
- console.log (`/> ${ exists ? 'updated' : 'created' } .${path.sep}package_json`)
123
+ console.log (`/> ${ exists ? 'updated' : 'created' } .${path.sep}package.json`)
124
124
  }
125
125
 
126
126
  /* eslint no-console: off */
package/bin/import.js CHANGED
@@ -12,7 +12,7 @@ module.exports = Object.assign(_import, {
12
12
  Imports the given source and converts it to CSN.
13
13
  Currently following file formats are supported.
14
14
  - EDMX and XML for OData V2 and V4
15
- - JSON for OpenAPI
15
+ - JSON for OpenAPI and AsyncAPI
16
16
 
17
17
  Without any options the source is copied to ./srv/external and the csn
18
18
  output written next to it. Finally it will add an entry for the imported
@@ -40,7 +40,7 @@ module.exports = Object.assign(_import, {
40
40
  Forcefully overwrites the contents in the CDS file and updates the checksum
41
41
 
42
42
  *--from*
43
- Imports the model from the one of the given options "edmx" or "openapi".
43
+ Imports the model from the one of the given options "edmx", "openapi" or "asyncapi".
44
44
 
45
45
  *Below options are valid for OData only*
46
46
 
@@ -63,6 +63,8 @@ module.exports = Object.assign(_import, {
63
63
  cds import ~/Downloads/API_BUSINESS_PARTNER.edmx --include-namespaces "\x2A"
64
64
  cds import ~/Downloads/Petstore_OpenAPI.json
65
65
  cds import ~/Downloads/Petstore_OpenAPI.json --from openapi
66
+ cds import ~/Downloads/BookStore_AsyncAPI.json
67
+ cds import ~/Downloads/BookStore_AsyncAPI.json --from asyncapi
66
68
 
67
69
  `})
68
70
  const messages = require('../lib/import/message').getMessages();
@@ -90,7 +92,7 @@ async function _import(file, options = {}) {
90
92
  }
91
93
 
92
94
  //reads the file version
93
- options.inputFileVersion = apiOptions.inputFileVersion;
95
+ options.inputFileVersion = apiOptions.odataVersion;
94
96
 
95
97
  // postprocess
96
98
  return await common.postProcess(destFilePath, options, csn, cwd);
package/bin/login.js CHANGED
@@ -1,6 +1,6 @@
1
1
  module.exports = Object.assign(login, {
2
- options: ['--subdomain', '--directory', '--passcode', '--user', '--client'],
3
- shortcuts: ['-s', '-d', '-p', '-u', '-c'],
2
+ options: ['--subdomain', '--directory', '--passcode', '--user', '--client', '--mtls'],
3
+ shortcuts: ['-s', '-d', '-p', '-u', '-c', '-m'],
4
4
  flags: ['--plain'],
5
5
  get help() {
6
6
  const config = require('../lib/client/settings_manager').SettingsManager.config
@@ -84,10 +84,25 @@ module.exports = Object.assign(login, {
84
84
 
85
85
  *-c* | *--client* <clientid>[:<clientsecret>]
86
86
 
87
- Client ID and optionally Client Secret for authentication. If omitted, Client Secret will be
88
- queried interactively.
87
+ Client Credentials (Client ID and optionally Client Secret) for authentication.
88
+ If omitted, Client Secret will be queried interactively.
89
89
 
90
- Neither Client ID nor Client Secret will be saved, only the resulting token.
90
+ Obtain the Client Credentials from the UAA binding of MTXS.
91
+
92
+ Client Credentials will not be saved, only the resulting token.
93
+
94
+ Note: Productive secrets should not be specified on a command line, since this might expose them to
95
+ unauthorized users on the same machine!
96
+
97
+ *-m* | *--mtls* <clientid>[:<key>]
98
+
99
+ Client Credentials (Client ID and optionally Client-Certificate Private Key in Base64 encoding)
100
+ for authentication. If omitted, Private Key will be queried interactively (avoid newline characters
101
+ when pasting it).
102
+
103
+ Obtain the Client Credentials from the UAA binding of MTXS.
104
+
105
+ Client Credentials will not be saved, only the resulting token.
91
106
 
92
107
  Note: Productive secrets should not be specified on a command line, since this might expose them to
93
108
  unauthorized users on the same machine!
@@ -121,14 +136,19 @@ module.exports = Object.assign(login, {
121
136
  async function login ([url], options = {}) {
122
137
  const [username, password] = options.user?.split(':') ?? [];
123
138
  delete options.user;
124
- const [clientid, clientsecret] = options.client?.split(':') ?? [];
125
- delete options.client;
139
+ if (options.client) {
140
+ const [clientid, clientsecret] = options.client.split(':');
141
+ delete options.client;
142
+ Object.assign(options, { clientid, clientsecret });
143
+ } else if (options.mtls) {
144
+ const [clientid, key = 'ask'] = options.mtls.split(':');
145
+ delete options.mtls;
146
+ Object.assign(options, { clientid, key });
147
+ }
126
148
  Object.assign(options, {
127
149
  url,
128
150
  username,
129
151
  password,
130
- clientid,
131
- clientsecret,
132
152
  tokenStorage: options.plain ? 'plain' : 'keyring',
133
153
  renewLogin: true,
134
154
  saveData: true
package/bin/migrate.js CHANGED
@@ -1,11 +1,11 @@
1
1
  module.exports = Object.assign(migrate, {
2
2
  options: ['--directory', '--tag', '--tagRule'],
3
3
  shortcuts: ['-d'],
4
- flags: ['--dry', '--force', '--cleanup', '--resolve-bindings'],
4
+ flags: ['--dry', '--force', '--skip-verification', '--cleanup', '--resolve-bindings'],
5
5
  help: `
6
6
  # SYNOPSIS
7
7
 
8
- *cds migrate* <tenant1|"*">[,<tenant2>] [-d <directory>] [--tag <tag>] [--tagRule <tag rule>] [--dry] [--force]
8
+ *cds migrate* <tenant1|"*">[,<tenant2>] [-d <directory>] [--tag <tag>] [--tagRule <tag rule>] [--dry] [--force] [--skip-verification]
9
9
 
10
10
  Migrate extensions created with @sap/cds-mtx to extensions for @sap/cds-mtxs
11
11
 
@@ -33,6 +33,10 @@ module.exports = Object.assign(migrate, {
33
33
 
34
34
  Do a dry-run only. Only run a verification of the extension migration.
35
35
 
36
+ *--skip-verification
37
+
38
+ Skip verification step. Does not check for potential deployment differences.
39
+
36
40
  *--cleanup* (beta)
37
41
 
38
42
  Removes all metadata containers created by @sap/cds-mtx.
package/bin/watch.js CHANGED
@@ -79,6 +79,10 @@ async function watch ([cwd], {
79
79
  _args: JSON.stringify(args),
80
80
  _options: JSON.stringify(options)
81
81
  })
82
+ if (process.env.CDS_TYPESCRIPT) {
83
+ const tsNodeRegister = localOrGlobal('ts-node', 'register')
84
+ env.NODE_OPTIONS = `-r ${tsNodeRegister} ` + (env.NODE_OPTIONS || '')
85
+ }
82
86
 
83
87
  // allow running w/o or partial local node_modules, also add cds-dk for its sqlite
84
88
  env.NODE_PATH = [...paths(cwd||process.cwd()), ...paths(__dirname)].join(delimiter)
@@ -190,6 +194,18 @@ function paths (dir) {
190
194
  return parts.map ((_,i,a)=> a.slice(0,n-i).join(sep)+nm).filter(p => fs.existsSync(p))
191
195
  }
192
196
 
197
+ function localOrGlobal (id, pathInMod) {
198
+ // require package.json to get a stable root path of the moduloe, not its main script
199
+ const modPath = require.resolve (id+'/package.json', { paths:[ process.cwd(), npmGlobalModules() ] })
200
+ return resolve(modPath, '..', pathInMod)
201
+ }
202
+
203
+ function npmGlobalModules() {
204
+ try {
205
+ return require ('child_process').execSync('npm root -g').toString().trim()
206
+ } catch (err) { return }
207
+ }
208
+
193
209
  //
194
210
  // Child process impl launched by watch
195
211
  //
@@ -5,8 +5,8 @@ const KindToRequiresNameMap = {
5
5
  xsuaa: 'auth',
6
6
  'hana-cloud': 'db',
7
7
  hana: 'db',
8
- 'hana-mt': 'db',
9
- 'sql-mt': 'db',
8
+ 'hana-mt': 'db', // For compatibility only
9
+ 'sql-mt': 'db', // For compatibility only
10
10
  destinations: 'destinations',
11
11
  connectivity: 'connectivity',
12
12
  'audit-log': 'audit-log',
@@ -9,7 +9,7 @@ const fs = require('fs').promises;
9
9
  const { highlight } = require('../util/term');
10
10
  const { logger } = require('./bindingUtil');
11
11
 
12
- const commandUtil = require('../init/util/commandUtil');
12
+ const commandUtil = require('../util/command');
13
13
 
14
14
  const CDSRC_FILENAME = '.cdsrc-private.json';
15
15
  const GIT_IGNORE_FILE = '.gitignore';
@@ -31,8 +31,10 @@ function getTokenUrl(params) {
31
31
  } else if (params.has('passcode')) {
32
32
  tokenUrl.search += `&passcode=${encodeURIComponent(params.get('passcode'))}`;
33
33
  }
34
- if (params.has('clientid')) {
34
+ if (params.has('clientsecret')) {
35
35
  tokenUrl.search += `&clientid=${encodeURIComponent(params.get('clientid'))}&clientsecret=${encodeURIComponent(params.get('clientsecret'))}`;
36
+ } else if (params.has('key')) {
37
+ tokenUrl.search += `&clientid=${encodeURIComponent(params.get('clientid'))}&key=${encodeURIComponent(params.get('key'))}`;
36
38
  }
37
39
  return tokenUrl.toString();
38
40
  }
@@ -1,11 +1,16 @@
1
+ const cds = require('../../cds');
1
2
  const { getMessage } = require('./logging');
2
3
 
4
+ const DEBUG = cds.debug('cli');
5
+
3
6
  class CliError extends Error {
4
7
  // noinspection JSAnnotator
5
8
  constructor(message, { error, command } = {}) {
6
9
  const help = command && getCommandHelp(command);
7
10
  const stackLimit = Error.stackTraceLimit;
8
- Error.stackTraceLimit = 0
11
+ if (!DEBUG) {
12
+ Error.stackTraceLimit = 0
13
+ }
9
14
  super(getMessage(message, { error, help }));
10
15
  Error.stackTraceLimit = stackLimit;
11
16
  }
@@ -125,7 +125,7 @@ class Param {
125
125
  : this.obfuscate === ObfuscationLevel.none && (!this.abbreviate || process.env.DEBUG)
126
126
  ? this.val
127
127
  : this.obfuscate === ObfuscationLevel.partial && process.env.DEBUG && typeof this.val === 'string'
128
- ? this.val.substr(0, DISCLOSURE_LENGTH) + '...' + this.val.substr(-DISCLOSURE_LENGTH)
128
+ ? this.val.slice(0, DISCLOSURE_LENGTH) + '...' + this.val.slice(-DISCLOSURE_LENGTH)
129
129
  : '...';
130
130
  }
131
131
 
@@ -158,24 +158,16 @@ class Param {
158
158
  */
159
159
  class BasicParams {
160
160
  constructor() {
161
- // NON-PERSISTED PARAMS
162
- // - general
161
+ // GENERAL PARAMS
162
+ // - non-persisted
163
163
  this.projectFolder = new Param('projectFolder', '');
164
164
  this.directory = this.projectFolder.newAlias('directory');
165
165
 
166
- // - auth-related
167
- this.passcode = new Param('passcode', '', { obfuscate: ObfuscationLevel.partial });
168
- this.tokenStorage = new Param('tokenStorage', undefined, { allowedValues: ['plain', 'keyring'] });
169
- this.plain = new Param('plain', false, { internal: true }); // for backward compatibility - ignored
170
- this.saveData = new Param('saveData', false, { internal: true });
171
- this.renewLogin = new Param('renewLogin', false);
172
- this.username = new Param('username', '', { persist: Persistence.setting }); // only saved against localhost (non-productive); as setting due to ambiguous app URL
173
- this.password = new Param('password', '', { obfuscate: ObfuscationLevel.full });
174
- this.isEmptyPassword = new Param('isEmptyPassword', false, { internal: true, persist: Persistence.setting }); // extra param so we can ensure we never save a password
175
- this.clientid = new Param('clientid', '');
176
- this.clientsecret = new Param('clientsecret', '', { obfuscate: ObfuscationLevel.partial });
166
+ // - non-persisted, internal
167
+ this.reqAuth = new Param('reqAuth', null, { obfuscate: ObfuscationLevel.full, internal: true });
168
+ this.clearOtherTokenStorage = new Param('clearOtherTokenStorage', false, { internal: true });
177
169
 
178
- // PERSISTED PARAMS (SETTINGS)
170
+ // - persisted
179
171
  this.appUrl = new Param('appUrl', '', { persist: Persistence.setting });
180
172
  this.url = this.appUrl.newAlias('url');
181
173
  this.from = this.appUrl.newAlias('from');
@@ -186,14 +178,24 @@ class BasicParams {
186
178
  this.passcode_url = this.passcodeUrl.newAlias('passcode_url');
187
179
  this.tokenUrl = new Param('tokenUrl', '', { persist: Persistence.setting, abbreviate: true })
188
180
 
189
- // PERSISTED AUTH PARAMS
181
+ // AUTH PARAMS
182
+ // - non-persisted
183
+ this.passcode = new Param('passcode', '', { obfuscate: ObfuscationLevel.partial });
184
+ this.tokenStorage = new Param('tokenStorage', undefined, { allowedValues: ['plain', 'keyring'] });
185
+ this.plain = new Param('plain', false, { internal: true }); // for backward compatibility - superseded by tokenStorage
186
+ this.saveData = new Param('saveData', false, { internal: true });
187
+ this.renewLogin = new Param('renewLogin', false);
188
+ this.password = new Param('password', '', { obfuscate: ObfuscationLevel.full });
189
+ this.clientid = new Param('clientid', '');
190
+ this.clientsecret = new Param('clientsecret', '', { obfuscate: ObfuscationLevel.partial });
191
+ this.key = new Param('key', '', { obfuscate: ObfuscationLevel.partial }); // private key of client certificate
192
+
193
+ // - persisted
194
+ this.username = new Param('username', '', { persist: Persistence.setting }); // only saved against localhost (non-productive); as setting due to ambiguous app URL
195
+ this.isEmptyPassword = new Param('isEmptyPassword', false, { internal: true, persist: Persistence.setting }); // extra param so we can ensure we never save a password
190
196
  this.token = new Param('token', '', { persist: Persistence.auth, obfuscate: ObfuscationLevel.partial });
191
197
  this.tokenExpirationDate = new Param('tokenExpirationDate', Number.MAX_SAFE_INTEGER, { persist: Persistence.auth });
192
198
  this.refreshToken = new Param('refreshToken', '', { persist: Persistence.auth, obfuscate: ObfuscationLevel.partial });
193
-
194
- // INTERNAL PARAMS (HIDDEN FROM USER, COMPUTED)
195
- this.reqAuth = new Param('reqAuth', null, { obfuscate: ObfuscationLevel.full, internal: true });
196
- this.clearOtherTokenStorage = new Param('clearOtherTokenStorage', false, { internal: true });
197
199
  }
198
200
  }
199
201
 
@@ -328,6 +328,13 @@ class SettingsManager {
328
328
  throw new CliError('Clientsecret cannot be empty');
329
329
  }
330
330
  }
331
+ async function addKey() {
332
+ params.set('key', await Question.askQuestion('key: ', undefined, true));
333
+ console.log();
334
+ if (params.get('key') === '') {
335
+ throw new CliError('Key cannot be empty');
336
+ }
337
+ }
331
338
  async function addPasscode() {
332
339
  const prompt = `Passcode${params.get('passcodeUrl') ? ' (visit ' + params.get('passcodeUrl') + ' to generate)' : ''}: `;
333
340
  params.set('passcode', (await Question.askQuestion(prompt, undefined, true)).trim());
@@ -387,8 +394,15 @@ class SettingsManager {
387
394
  return;
388
395
  }
389
396
 
390
- if (params.get('clientid') && !params.get('clientsecret') && !logout) {
391
- await addClientSecret();
397
+ if (params.get('clientid') && !logout) {
398
+ if (params.has('key')) {
399
+ if (params.get('key') === 'ask') {
400
+ params.delete('key');
401
+ await addKey();
402
+ }
403
+ } else if (!params.has('clientsecret')) {
404
+ await addClientSecret();
405
+ }
392
406
  }
393
407
 
394
408
  const auth = {
@@ -398,7 +412,7 @@ class SettingsManager {
398
412
 
399
413
  setRelevantAuth(auth);
400
414
 
401
- if (!logout && !params.has('token') && !params.has('passcode') && !params.has('clientsecret')) {
415
+ if (!logout && !params.has('token') && !params.has('passcode') && !params.has('clientsecret') && !params.has('key')) {
402
416
  await addPasscode();
403
417
  }
404
418
  }
@@ -38,7 +38,7 @@ const TITLE_SUFFIX = {
38
38
  const ODM_ANNOTATIONS = Object.freeze(
39
39
  {
40
40
  '@ODM.entityName': 'x-sap-odm-entity-name',
41
- '@ODM.oid': 'x-sap-odm-oid',
41
+ '@ODM.oid': 'x-sap-odm-oid'
42
42
  });
43
43
 
44
44
  /**
@@ -59,6 +59,8 @@ module.exports.csdl2openapi = function (
59
59
  maxLevels: maxLevels = 5
60
60
  } = {}
61
61
  ) {
62
+ // as preProcess below mutates the csdl, copy it before, to avoid side-effects on the caller side
63
+ csdl = JSON.parse(JSON.stringify(csdl))
62
64
  serviceRoot = serviceRoot || (scheme + '://' + host + basePath);
63
65
  const queryOptionPrefix = csdl.$Version <= '4.0' ? '$' : '';
64
66
  const typesToInline = {}; // filled in schema() and used in inlineTypes()
@@ -1838,6 +1840,7 @@ see [Expand](http://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part1-prot
1838
1840
  if (Object.keys(schemaProperties).length > 0)
1839
1841
  schemas[schemaName].properties = schemaProperties;
1840
1842
 
1843
+ if (suffix === SUFFIX.read && type["@ODM.root"]) schemas[schemaName]["x-sap-root-entity"] = type["@ODM.root"]
1841
1844
  odmExtensions(type, schemas[schemaName]);
1842
1845
 
1843
1846
  if (suffix === SUFFIX.create && required.length > 0)
@@ -0,0 +1,32 @@
1
+
2
+ const ParserContext = require("./parserContext");
3
+ const cdsDkVersion = require("../../../package.json").version;
4
+
5
+ function importAsyncAPI(input) {
6
+ const context = new ParserContext(input);
7
+ return convertToCSN(context);
8
+ }
9
+
10
+ function convertToCSN(context) {
11
+ const csn = {
12
+ meta: {
13
+ creator: `cds-dk ${cdsDkVersion}`
14
+ },
15
+ $version: '2.0',
16
+ definitions: {}
17
+ };
18
+
19
+ Object.entries(context.services).forEach(([key, value]) => {
20
+ const events = value.events;
21
+ const types = value.types;
22
+ delete value.events;
23
+ delete value.types;
24
+
25
+ csn.definitions[key] = value;
26
+ Object.assign(csn.definitions, events, types);
27
+ });
28
+
29
+ return csn;
30
+ }
31
+
32
+ module.exports = { importAsyncAPI }
@@ -0,0 +1,15 @@
1
+ const { importAsyncAPI } = require("./importAsyncAPI");
2
+ const { validateAsyncAPI } = require('./utils');
3
+
4
+ /* The starting function for conversion of AsyncAPI document to csn*/
5
+ function asyncapi2csn(source) {
6
+ //validate asyncapi document
7
+ const content = JSON.parse(source);
8
+ validateAsyncAPI(content);
9
+
10
+ return importAsyncAPI(content);
11
+ }
12
+
13
+ module.exports = {
14
+ asyncapi2csn
15
+ }