@sap/cds-dk 7.2.0 → 7.3.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 (56) hide show
  1. package/bin/activate.js +2 -2
  2. package/bin/build.js +6 -3
  3. package/bin/compile/index.js +9 -5
  4. package/bin/env.js +0 -3
  5. package/bin/extend.js +25 -3
  6. package/bin/import.js +7 -3
  7. package/bin/push.js +10 -6
  8. package/bin/watch.js +1 -1
  9. package/lib/build/{buildTaskHandler.js → buildPlugin.js} +23 -25
  10. package/lib/build/buildTaskEngine.js +73 -73
  11. package/lib/build/buildTaskFactory.js +6 -23
  12. package/lib/build/buildTaskProvider.js +24 -19
  13. package/lib/build/buildTaskProviderFactory.js +170 -57
  14. package/lib/build/constants.js +4 -4
  15. package/lib/build/index.js +3 -2
  16. package/lib/build/provider/{buildTaskHandlerEdmx.js → edmxBuildPlugin.js} +6 -6
  17. package/lib/build/provider/{buildTaskHandlerFeatureToggles.js → featureToggleBuildPlugin.js} +3 -3
  18. package/lib/build/provider/fiori/index.js +5 -6
  19. package/lib/build/provider/hana/index.js +54 -30
  20. package/lib/build/provider/{buildTaskHandlerInternal.js → internalBuildPlugin.js} +10 -10
  21. package/lib/build/provider/{buildTaskProviderInternal.js → internalBuildTaskProvider.js} +27 -28
  22. package/lib/build/provider/java/index.js +24 -24
  23. package/lib/build/provider/mtx/index.js +4 -4
  24. package/lib/build/provider/mtx/resourcesTarBuilder.js +8 -8
  25. package/lib/build/provider/mtx-extension/index.js +17 -9
  26. package/lib/build/provider/mtx-sidecar/index.js +17 -11
  27. package/lib/build/provider/nodejs/index.js +14 -13
  28. package/lib/client/auth_manager.js +6 -12
  29. package/lib/client/base_command.js +1 -1
  30. package/lib/client/download_legacy.js +48 -0
  31. package/lib/client/params.js +5 -0
  32. package/lib/client/push.js +41 -1
  33. package/lib/client/settings_manager.js +12 -3
  34. package/lib/env/schema.js +36 -0
  35. package/lib/env/schemas/cds-rc.json +101 -0
  36. package/lib/import/common.js +23 -10
  37. package/lib/import/importapi.js +2 -2
  38. package/lib/import/message.js +3 -1
  39. package/lib/import/odata/v4parser.js +23 -7
  40. package/lib/index.js +5 -0
  41. package/lib/init/constants.js +4 -2
  42. package/lib/init/index.js +2 -3
  43. package/lib/init/template/_merging/registry-mta.js +21 -0
  44. package/lib/init/template/approuter/files/mta.yaml.hbs +1 -1
  45. package/lib/init/template/approuter/index.js +9 -9
  46. package/lib/init/template/connectivity/index.js +5 -4
  47. package/lib/init/template/destination/index.js +2 -5
  48. package/lib/init/template/html5-repo/index.js +27 -3
  49. package/lib/init/template/mta/index.js +9 -3
  50. package/lib/init/template/postgres/files/mta.yaml.hbs +27 -0
  51. package/lib/init/template/postgres/files/package.json.hbs +5 -0
  52. package/lib/init/template/postgres/index.js +52 -0
  53. package/lib/init/util/projectReader.js +0 -1
  54. package/lib/util/pruneAxiosErrors.js +22 -8
  55. package/npm-shrinkwrap.json +1829 -23
  56. package/package.json +1 -1
package/bin/activate.js CHANGED
@@ -1,7 +1,7 @@
1
1
  module.exports = Object.assign(activate, {
2
2
  options: ['--subdomain', '--passcode', '--username', '--clientid', '--to', '--sync'],
3
3
  flags: ['--undeploy', '--wsdl'],
4
- shortcuts: ['-s', '-p', '-u', '-c'],
4
+ shortcuts: ['-s', '-p', '-u', '-c', '-2'],
5
5
  help: `
6
6
  # SYNOPSIS
7
7
 
@@ -55,7 +55,7 @@ module.exports = Object.assign(activate, {
55
55
 
56
56
  *cds push* to push an extension to a SaaS app based on current MTX Services
57
57
  (@sap/cds-mtxs).
58
-
58
+
59
59
  https://cap.cloud.sap/docs/guides/multitenancy/mtxs for information on
60
60
  @sap/cds-mtxs.
61
61
 
package/bin/build.js CHANGED
@@ -1,6 +1,7 @@
1
1
  module.exports = Object.assign(build, {
2
- options: ['--project', '--src', '--dest', '--for', '--workspaces', '--use', '--opts', '--log-level', '--options-model', '--clean'],
3
- shortcuts: ['-in', '-s', '-o', '-4', '-ws'],
2
+ options: ['--project', '--src', '--dest', '--for', '--use', '--opts', '--log-level', '--options-model'],
3
+ shortcuts: ['-in', '-s', '-o', '-4'],
4
+ flags: ['--ws', '--clean'],
4
5
  help: `
5
6
  # SYNOPSIS
6
7
 
@@ -88,11 +89,13 @@ module.exports = Object.assign(build, {
88
89
  async function build([project], options = {}) {
89
90
  const path = require('path')
90
91
  const cds = require('../lib/cds')
92
+
93
+ // plugins are loaded based on cds.root path
94
+ cds.root = path.resolve(process.cwd(), project || options.project || '.')
91
95
 
92
96
  // IMPORTANT: call plugins before subsequent access to cds.env
93
97
  await cds.plugins
94
98
 
95
- cds.root = path.resolve(process.cwd(), project || options.project || '.')
96
99
  cds.env = cds.env.for('cds', cds.root);
97
100
  delete options.project // avoid that relative project paths are resolved twice
98
101
 
@@ -114,7 +114,7 @@ module.exports = Object.assign ( compile, {
114
114
  The servers definition used in the generated OpenAPI document. *--openapi:url* is
115
115
  ignored when this option is specified.
116
116
 
117
- *--odata-version* 4.0|4.01
117
+ *--odata-version* 4.0|4.01
118
118
 
119
119
  Adds the OData version's functionality of the input CDS/CSN file to the generated OpenAPI document.
120
120
 
@@ -126,7 +126,7 @@ module.exports = Object.assign ( compile, {
126
126
 
127
127
  A single AsyncAPI document is generated using the details of all input services. Information of _title_
128
128
  and _version_ should be provided as preset.
129
-
129
+
130
130
  # EXAMPLES
131
131
 
132
132
  *cds* compile model.cds
@@ -136,11 +136,13 @@ module.exports = Object.assign ( compile, {
136
136
 
137
137
  `})
138
138
 
139
- function compile_all (root='.') {
139
+ async function compile_all (root='.') {
140
140
 
141
141
  const {exec} = require ('child_process')
142
142
  const cds = require('../../lib') // get the enhanced cds w/ additional compile processors
143
143
 
144
+ await cds.plugins // ensure plugins that extend compile targets are loaded
145
+
144
146
  exec(`find ${root} -name *.cds ! -path '*/node_modules/*'`, (_,stdout)=>{
145
147
  const all = stdout.split('\n').slice(0,-1)
146
148
  const info = `\n/ compiled ${all.length} cds models in`
@@ -156,13 +158,15 @@ function compile_all (root='.') {
156
158
 
157
159
  }
158
160
 
159
- function compile (models, options={}) {
161
+ async function compile (models, options={}) {
160
162
 
161
163
  if (options.all) return compile_all (models[0])
162
164
 
163
165
  const { inspect } = require('util')
164
166
  const cds = require('../../lib') // get the enhanced cds w/ additional compile processors
165
167
 
168
+ await cds.plugins // ensure plugins that extend compile targets are loaded
169
+
166
170
  let model, src, _suffix; //> be filled in below
167
171
  if (!options.as && !/,/.test(options.to)) options.as = 'str'
168
172
  if (options.beta) options.betaMode = true
@@ -278,7 +282,7 @@ function compile (models, options={}) {
278
282
  return console.log (o)
279
283
  }
280
284
 
281
- function suffix4 (x) { return x && ({
285
+ function suffix4 (x) { return x && x !== 'hdbtable' && ({
282
286
  edmx: '.xml',
283
287
  "edmx-v2": '.xml',
284
288
  "edmx-v4": '.xml',
package/bin/env.js CHANGED
@@ -62,9 +62,6 @@ async function env ([cmd, key, value], options={}) {
62
62
  commands[cmd] || ((key = cmd), commands.get)
63
63
  )
64
64
 
65
- // Ensure loading plugins before calling cds.env!
66
- await cds.plugins
67
-
68
65
  let env = cds.env
69
66
  if (options["resolve-bindings"]) {
70
67
  const BindingManager = require('../lib/bind/bindingManager')
package/bin/extend.js CHANGED
@@ -1,6 +1,6 @@
1
1
  module.exports = Object.assign(extend, {
2
- options: ['--directory', '--subdomain', '--passcode', '--username', '--clientid'],
3
- flags: ['--wsdl', '--templates', '--force'],
2
+ options: ['--directory', '--subdomain', '--passcode', '--username', '--clientid', '--tagRule'],
3
+ flags: ['--wsdl', '--templates', '--force', '--download-migrated-projects'],
4
4
  shortcuts: ['-d', '-s', '-p', '-u', '-c'],
5
5
  help: `
6
6
  # SYNOPSIS
@@ -50,13 +50,21 @@ module.exports = Object.assign(extend, {
50
50
  Download only the templates provided by the SaaS application you want to
51
51
  extend.
52
52
 
53
+ *--download-migrated-projects*
54
+
55
+ To be used only after change to @sap/cds-mtxs. Allows to download migrated extension projects.
56
+
57
+ *--tagRule*
58
+
59
+ Rule used to split up migrated extension projects into separate projects (please check migration documentation for more).
60
+
53
61
  # SEE ALSO
54
62
 
55
63
  *cds activate* to activate an extension project.
56
64
 
57
65
  *cds pull* to get the CDS model of a SaaS app based on current MTX Services
58
66
  (@sap/cds-mtxs).
59
-
67
+
60
68
  https://cap.cloud.sap/docs/guides/multitenancy/mtxs for information on
61
69
  @sap/cds-mtxs.
62
70
 
@@ -64,6 +72,20 @@ module.exports = Object.assign(extend, {
64
72
 
65
73
 
66
74
  async function extend ([url], options = {}) {
75
+
76
+ if (options['download-migrated-projects']) {
77
+ const [username, password] = options.username?.split(':') ?? [];
78
+ delete options.user;
79
+
80
+ await require('../lib/client/download_legacy').run({
81
+ ...options,
82
+ url,
83
+ username,
84
+ password
85
+ });
86
+ return
87
+ }
88
+
67
89
  if (options.force) {
68
90
  if (! await require('../lib/client/helper/question').askBooleanQuestion('Using option --force will overwrite existing files. Continue (yN)? ', false, false)) {
69
91
  console.log('Extend cancelled')
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'],
3
+ options: ['--out', '--as', '--include-namespaces', '--from', '--config'],
4
4
  flags: ['--dry', '--force', '--no-copy', '--no-save', '--keep-namespace'],
5
- shortcuts: ['-o', '-as', '-ns', undefined, '-', '-f'],
5
+ shortcuts: ['-o', '-as', '-ns', undefined, '-c', '-', '-f'],
6
6
  help: `
7
7
  # SYNOPSIS
8
8
 
@@ -43,6 +43,9 @@ 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
+
47
+ *-c | --config* <JSON Object>
48
+ Adds the provided JSON Object as custom configuration data to the package.json.
46
49
 
47
50
  *Below options are valid for OData only*
48
51
 
@@ -68,6 +71,7 @@ module.exports = Object.assign(_import, {
68
71
  cds import ~/Downloads/Petstore_OpenAPI.json --from openapi
69
72
  cds import ~/Downloads/BookStore_AsyncAPI.json
70
73
  cds import ~/Downloads/BookStore_AsyncAPI.json --from asyncapi
74
+ cds import ~/Downloads/API_BUSINESS_PARTNER.edmx -c {\\"[production]\\":{\\"credentials\\":{\\"destination\\":\\"UI3_noauth\\",\\"path\\":\\"/sap/cap/odata\\"}}}
71
75
 
72
76
  `})
73
77
  const messages = require('../lib/import/message').getMessages();
@@ -95,7 +99,7 @@ async function _import(file, options = {}) {
95
99
  }
96
100
 
97
101
  // reads the file version
98
- options.inputFileVersion = apiOptions.odataVersion;
102
+ options.inputFileKind = apiOptions.odataVersion ? apiOptions.odataVersion : apiOptions.inputFileKind;
99
103
 
100
104
  // postprocess
101
105
  return await common.postProcess(destFilePath, options, csn, cwd);
package/bin/push.js CHANGED
@@ -1,7 +1,7 @@
1
1
  module.exports = Object.assign(push, {
2
- options: ['--subdomain', '--passcode', '--user', '--client', '--to'],
2
+ options: ['--subdomain', '--passcode', '--user', '--client', '--to', '--sync'],
3
3
  flags: [],
4
- shortcuts: ['-s', '-p', '-u', '-c'],
4
+ shortcuts: ['-s', '-p', '-u', '-c', '-2'],
5
5
  help: `
6
6
  # SYNOPSIS
7
7
 
@@ -13,9 +13,9 @@ module.exports = Object.assign(push, {
13
13
  a local file or as a URL to download it from.
14
14
  A download URL may contain Basic-Auth credentials as in
15
15
  'https://user:pass@host'.
16
-
16
+
17
17
  By default, the current working directory is used as project directory.
18
-
18
+
19
19
  Unless a custom archive is given, the extension project will be
20
20
  automatically built in order to update the generated extension archive. This
21
21
  ensures the most recent extension model is pushed.
@@ -48,13 +48,17 @@ module.exports = Object.assign(push, {
48
48
 
49
49
  Client ID and optionally Client Secret for authentication.
50
50
 
51
+ *--sync*
52
+
53
+ Use the synchronous server API to upload extensions.
54
+
51
55
 
52
56
  # SEE ALSO
53
57
 
54
58
  *cds pull* to get the CDS model of the SaaS app.
55
-
59
+
56
60
  *cds login* for more information on authentication options.
57
-
61
+
58
62
  *cds login* to save project settings and authentication data, simplifying
59
63
  multiple runs of this command.
60
64
 
package/bin/watch.js CHANGED
@@ -60,7 +60,7 @@ const t = module.exports.codes = {
60
60
  }
61
61
  const extDefaults = 'cds,csn,csv,ts,mjs,cjs,js,json,properties,edmx,xml,env'
62
62
  const fioriIncludes = /_?(change|variant)$/ // according to fiori: change,variant,ctrl_variant,ctrl_variant_change,ctrl_variant_management_change.
63
- const ignore = RegExp(`app${sep}.*${sep}?webapp${sep}|node_modules|target|\\.cds-services\\.json$`)
63
+ const ignore = RegExp(`(node_modules\\${sep}|app(\\${sep}.+)?\\${sep}((webapp|dist|target)\\${sep}|\\.cds-services\\.json$|tsconfig\\.json$|.*\\.tsbuildinfo$))`)
64
64
 
65
65
  async function watch ([cwd], {
66
66
  args = ['serve', 'all'],
@@ -2,13 +2,13 @@ const path = require('path')
2
2
  const fs = require('fs').promises
3
3
  const cds = require('../cds')
4
4
 
5
- const { OUTPUT_MODE, OUTPUT_MODE_FILESYSTEM, SEVERITY_INFO, SEVERITY_WARNING, SEVERITY_ERROR, OVERRIDE_METHOD_MSG } = require('./constants')
5
+ const { OUTPUT_MODE, OUTPUT_MODE_FILESYSTEM, SEVERITY_INFO, SEVERITY_WARNING, SEVERITY_ERROR } = require('./constants')
6
6
  const { hasOptionValue, getProperty, relativePaths, BuildMessage } = require('./util')
7
7
 
8
8
  /**
9
- * The build task handler creates the build output for a dedicated build task. It is uniquely identified
10
- * by the build task's <code>use</code> property. It represents the fully qualified node module path
11
- * of the build task handler implementation.
9
+ * The build plugin creates the build output for a dedicated build task. It is uniquely identified
10
+ * by the build task's <code>for</code> or <code>use</code>property. The <code>use</code> property represents
11
+ * the fully qualified node module path of the build plugin implementation.
12
12
  * <p>
13
13
  * The build task engine defines the following protocol. The methods are invoked in descending order:
14
14
  * <ul>
@@ -19,14 +19,11 @@ const { hasOptionValue, getProperty, relativePaths, BuildMessage } = require('./
19
19
  * </ul>
20
20
  * The reflected CSN can be accessed using the async method <code>model()</code>.
21
21
  */
22
- class BuildTaskHandler {
22
+ class BuildPlugin {
23
23
  /**
24
- * @class
24
+ * @constructor
25
25
  */
26
26
  constructor() {
27
- if (new.target === BuildTaskHandler) {
28
- throw new TypeError("Cannot construct BuildTaskHandler instances directly");
29
- }
30
27
  this._written = new Set()
31
28
  this._messages = []
32
29
  }
@@ -47,7 +44,7 @@ class BuildTaskHandler {
47
44
  return this._context
48
45
  }
49
46
  /**
50
- * Returns the build task executed by this build task handler.
47
+ * Returns the build task executed by this build plugin.
51
48
  * @return {object}
52
49
  */
53
50
  get task() {
@@ -56,7 +53,8 @@ class BuildTaskHandler {
56
53
  }
57
54
 
58
55
  /**
59
- * Returns the message object to add build task specific messages. Severity 'Info', 'Warning', and 'Error' are supported.
56
+ * Returns a list of build and compiler messages created by this build plugin.
57
+ * Supported message severities are 'Info', 'Warning', and 'Error'.
60
58
  * @return {Array}
61
59
  */
62
60
  get messages() {
@@ -64,7 +62,7 @@ class BuildTaskHandler {
64
62
  }
65
63
 
66
64
  /**
67
- * Returns the list of files written by this build task handler of current CDS build execution.
65
+ * Returns the list of files written by this build plugin.
68
66
  * @return {Array}
69
67
  */
70
68
  get files() {
@@ -72,14 +70,14 @@ class BuildTaskHandler {
72
70
  }
73
71
 
74
72
  /**
75
- * Returns the priority of this handler as number, where 0 represents the minimum value and
73
+ * Returns the priority of this plugin as number, where 0 represents the minimum value and
76
74
  * Number.MAX_SAFE_INTEGER the maximum value.
77
- * Positive numbers mean higher and negative numbers lower priority. Build task handlers
78
- * with higher priority value are executed before handlers with lower priority.
75
+ * Positive numbers mean higher and negative numbers lower priority. Build plugins
76
+ * with higher priority value are executed before plugins with lower priority.
79
77
  * <br>
80
- * Note: Currently not supported for custom build task handlers as they are always executed
81
- * before the built-in handlers.
82
- * @return {number} the priority for this handler as integer.
78
+ * Note: Currently not supported for custom build plugins as they are always executed
79
+ * before the built-in plugins.
80
+ * @return {number} the priority for this plugin as integer.
83
81
  */
84
82
  get priority() {
85
83
  return 1
@@ -91,26 +89,26 @@ class BuildTaskHandler {
91
89
  init() { }
92
90
 
93
91
  /**
94
- * Called by the framework to create the artifacts of this build task handler.
92
+ * @abstract
93
+ * Called by the framework to create the artifacts of this build plugin.
95
94
  */
96
95
  async build() {
97
- throw new TypeError(OVERRIDE_METHOD_MSG)
98
96
  }
99
97
 
100
98
  /**
101
- * Called by the framework immediately before 'build' to delete any output created by this build task handler.
99
+ * @abstract
100
+ * Called by the framework immediately before 'build' to delete any output created by this build plugin.
102
101
  * <p>
103
102
  * Note: The <code>BuildTaskEngine</code> is cleaning the common generation target folder if the build is
104
103
  * executed in staging mode, e.g. build.target: "gen".
105
104
  */
106
105
  async clean() {
107
- throw new TypeError(OVERRIDE_METHOD_MSG)
108
106
  }
109
107
 
110
108
  /**
111
109
  * Asynchronously write the given content to a given file path.
112
110
  * If the file exists the content is replaced. If the file does not exist, a new file will be created.
113
- * The file name is stored in the list of files written by this build task handler.
111
+ * The file name is stored in the list of files written by this build plugin.
114
112
  * @param {string} dest - absolute or relative file path. Relative paths will be resolved to this task's destination path.
115
113
  * @param {any} data - If data is of type object the JSON-stringified version is written.
116
114
  */
@@ -135,7 +133,7 @@ class BuildTaskHandler {
135
133
  * Copy a file or directory if the build task option 'outputMode' does not have the value 'resultOnly'.
136
134
  * The directory can have contents.
137
135
  * <p>
138
- * Note: The file name is stored in the list of files written by this build task handler.
136
+ * Note: The file name is stored in the list of files written by this build plugin.
139
137
  * </p>
140
138
  * @param {string} src The absolute or relative source path of the file or directory to copy.
141
139
  * Relative paths will be resolved to this task's source path.
@@ -231,4 +229,4 @@ class BuildTaskHandler {
231
229
  return value
232
230
  }
233
231
  }
234
- module.exports = BuildTaskHandler
232
+ module.exports = BuildPlugin