@sap/cds-dk 9.0.5 → 9.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 (44) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/bin/add.js +9 -6
  3. package/bin/debug.js +14 -7
  4. package/bin/repl.js +9 -2
  5. package/bin/up.js +16 -6
  6. package/lib/build/provider/fiori/index.js +2 -4
  7. package/lib/build/provider/nodejs/index.js +18 -0
  8. package/lib/init/constants.js +11 -10
  9. package/lib/init/index.js +32 -4
  10. package/lib/init/merge.js +4 -1
  11. package/lib/init/plugin.js +0 -33
  12. package/lib/init/projectReader.js +1 -1
  13. package/lib/init/template/ams/files/Chart.yaml.hbs +3 -1
  14. package/lib/init/template/approuter/files/mta.yaml.hbs +2 -1
  15. package/lib/init/template/cloud-logging/files/java-cdsrc.json.hbs +6 -0
  16. package/lib/init/template/cloud-logging/files/package.json.hbs +7 -0
  17. package/lib/init/template/cloud-logging/index.js +9 -10
  18. package/lib/init/template/containerize/index.js +1 -1
  19. package/lib/init/template/data/as-json.js +3 -3
  20. package/lib/init/template/hana/index.js +3 -2
  21. package/lib/init/template/handler/files/extension/package.json +1 -1
  22. package/lib/init/template/html5-repo/files/mta.yaml.hbs +3 -1
  23. package/lib/init/template/html5-repo/index.js +1 -1
  24. package/lib/init/template/http/index.js +55 -53
  25. package/lib/init/template/ias/files/Chart.yaml.hbs +3 -1
  26. package/lib/init/template/ias/files/mta.yaml.hbs +2 -2
  27. package/lib/init/template/ias/index.js +3 -4
  28. package/lib/init/template/mta/index.js +5 -5
  29. package/lib/init/template/multitenancy/index.js +3 -4
  30. package/lib/init/template/nodejs/files/package.json.hbs +1 -1
  31. package/lib/init/template/portal/index.js +1 -1
  32. package/lib/init/template/test/files/package.json +8 -0
  33. package/lib/init/template/test/files/test/test.xs.hbs +36 -0
  34. package/lib/init/template/test/index.js +152 -0
  35. package/lib/init/template/typescript/files/package.json +1 -1
  36. package/lib/init/template/xsuaa/index.js +2 -2
  37. package/lib/lint/Linter.js +1 -4
  38. package/lib/lint/eslintHelp.json +84 -0
  39. package/lib/mtx/auth_manager.js +0 -2
  40. package/lib/util/axios.js +77 -31
  41. package/npm-shrinkwrap.json +33 -33
  42. package/package.json +1 -1
  43. package/lib/init/template/cloud-logging/files/java-cdsrc.json +0 -5
  44. package/lib/lint/generators.js +0 -103
package/lib/util/axios.js CHANGED
@@ -2,7 +2,16 @@ module.exports = {
2
2
  pruneErrors
3
3
  };
4
4
 
5
+ let interceptor
6
+
5
7
  function pruneErrors() {
8
+
9
+ if (interceptor) {
10
+ // Already set up.
11
+ return;
12
+ }
13
+ interceptor = true;
14
+
6
15
  function stacklessError(message) {
7
16
  const { stackTraceLimit } = Error;
8
17
  Error.stackTraceLimit = 0;
@@ -15,56 +24,93 @@ function pruneErrors() {
15
24
  response => response,
16
25
  axError => {
17
26
  const { inspect } = require('util');
27
+
18
28
  let { url, method } = axError.config ?? {};
19
29
  url = url?.replace(/(passcode|refreshToken|clientsecret|key)=[^&]+/g, '$1=...');
30
+
20
31
  const { errno, code, response = {}, message: axMessage } = axError;
21
32
  const prefix = (url && method ? `${method.toUpperCase()} ${url}` : 'Request') + ' failed';
22
33
 
34
+ function fixData(data) {
35
+ if (Buffer.isBuffer(data)) {
36
+ let str = data.toString();
37
+ try {
38
+ data = JSON.parse(str);
39
+ } catch {
40
+ data = str;
41
+ }
42
+ }
43
+ return data;
44
+ }
45
+
46
+ function extractErrorDetails(data) {
47
+ if (!data) return undefined;
48
+
49
+ if (typeof data === "string") {
50
+ if (/<html/i.test(data)) {
51
+ return '(HTML response received. If applicable, ensure the route to MTX is configured correctly in App Router.)';
52
+ }
53
+ if (data.length >= 1000) return undefined;
54
+ return data.trim();
55
+ }
56
+
57
+ if (typeof data === "object") {
58
+ if (data.error_description) return data.error_description; // OAuth RFC
59
+ if (data.error && typeof data.error === "object" && data.error.message) return data.error.message;
60
+ if (data.error && typeof data.error === "string") return data.error;
61
+ if (typeof data.message === "string") return data.message;
62
+ return inspect(data); // fallback
63
+ }
64
+
65
+ return undefined;
66
+ }
67
+
23
68
  let error;
69
+ const debug = require('../').log('req')._debug;
70
+
24
71
  if (errno) {
25
- // System error during request.
26
- const message = prefix
27
- + `: ${errno} ${code}`
28
- + (/\b(ENOTFOUND|EAI_AGAIN)\b/.test(code) ? `. Make sure the URL is correct and the server is running.` : '');
72
+ // System/network errors
73
+ const message = prefix +
74
+ `: ${errno} ${code}` +
75
+ (/\b(ENOTFOUND|EAI_AGAIN)\b/.test(code)
76
+ ? `. Make sure the URL is correct and the server is running.`
77
+ : '');
29
78
  error = stacklessError(message);
30
79
  } else {
31
- // Error after request has been made.
80
+ // HTTP errors
32
81
  const { status, statusText } = response;
33
82
  let { data } = response;
34
- if (Buffer.isBuffer(data)) {
35
- data = data.toString();
36
- try {
37
- data = JSON.parse(data);
38
- } catch (error) { /* unexpected; data will be included in error below */
39
- }
40
- }
41
- const inspectData = data && !data.error_description;
42
- const reason = !inspectData && data?.error /* RFC 6749 */ && (typeof data.error === 'string' ? data.error : inspect(data.error));
43
- const details = inspectData ? inspect(data) : data?.error_description /* RFC 6749 */;
44
- const message = prefix + (
45
- status || statusText || reason || details
46
- ? (status || statusText ? ':' : '') +
47
- (status ? ` ${status}` : '') +
48
- (statusText ? ` ${statusText}` : '') +
49
- (reason ? `. ${reason}` : '') +
50
- (details ? `. Details: ${details}` : '')
51
- : (axMessage ? `: ${axMessage}` : '')
52
- );
83
+ data = fixData(data);
84
+ const details = extractErrorDetails(data);
85
+ const reason = typeof data?.error === "string"
86
+ ? data.error
87
+ : undefined;
88
+ const errObj = debug && typeof data.error === 'object'
89
+ ? inspect(data.error)
90
+ : undefined;
91
+
92
+ const message = prefix +
93
+ (status || statusText || reason || details
94
+ ? (status || statusText ? ':' : '') +
95
+ (status ? ` ${status}` : '') +
96
+ (statusText ? ` ${statusText}` : '') +
97
+ (reason ? `. ${reason}` : '') +
98
+ (details ? `. Details: ${details}` : '') +
99
+ (errObj ? `. Error object: ${errObj}` : '')
100
+ : (axMessage ? `: ${axMessage}` : '')
101
+ );
53
102
 
54
103
  error = stacklessError(message);
55
- if (status) {
56
- error.status = status;
57
- }
104
+ if (status) error.status = status;
58
105
  if (data?.passcode_url) {
59
- error.auth = {
60
- passcode_url: data.passcode_url
61
- };
106
+ error.auth = { passcode_url: data.passcode_url };
62
107
  }
63
108
  }
64
109
 
65
- if (require('../').debug('req')) {
110
+ if (debug) {
66
111
  error.cause = axError;
67
112
  }
113
+
68
114
  return Promise.reject(error);
69
115
  }
70
116
  );
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@sap/cds-dk",
3
- "version": "9.0.5",
3
+ "version": "9.1.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@sap/cds-dk",
9
- "version": "9.0.5",
9
+ "version": "9.1.0",
10
10
  "license": "SEE LICENSE IN LICENSE",
11
11
  "dependencies": {
12
12
  "@cap-js/asyncapi": "^1.0.0",
@@ -42,8 +42,8 @@
42
42
  }
43
43
  },
44
44
  "node_modules/@cap-js/db-service": {
45
- "version": "2.1.1",
46
- "integrity": "sha512-lkT8hQtMGLOWpbZzSWoMfoZe4vByuJZ9PierJPIhgLbayMLyTQ8iMKNgme1FW3nXFPc7JMJlEImskmhOygllAQ==",
45
+ "version": "2.1.2",
46
+ "integrity": "sha512-wbbEhUaSnQnYSC2029CO8MLAag5k/mJAtu6nyJUYfZbjkfr/JnP9lG5ylHg1dQtjRfAjPds+lxZIo35DHwNsVQ==",
47
47
  "devOptional": true,
48
48
  "license": "Apache-2.0",
49
49
  "dependencies": {
@@ -78,8 +78,8 @@
78
78
  }
79
79
  },
80
80
  "node_modules/@eslint/js": {
81
- "version": "9.28.0",
82
- "integrity": "sha512-fnqSjGWd/CoIp4EXIxWVK/sHA6DOHN4+8Ix2cX5ycOY7LG0UY8nHCU5pIp2eaE1Mc7Qd8kHspYNzYXT2ojPLzg==",
81
+ "version": "9.30.1",
82
+ "integrity": "sha512-zXhuECFlyep42KZUhWjfvsmXGX39W8K8LFb8AWXM9gSV9dQB+MrJGLKvW6Zw0Ggnbpw0VHTtrhFXYe3Gym18jg==",
83
83
  "license": "MIT",
84
84
  "peer": true,
85
85
  "engines": {
@@ -90,8 +90,8 @@
90
90
  }
91
91
  },
92
92
  "node_modules/@sap/cds": {
93
- "version": "9.0.3",
94
- "integrity": "sha512-9bMeDY66A8Eh+AkmemK1EdDmquswofn7qISNp9SGiIJ1cmF1LtysiAjs9IR/taHnv7IEacvHUK+A7X3VDm0iQg==",
93
+ "version": "9.1.0",
94
+ "integrity": "sha512-i5bAVbFzi1uN11O4U6SdPKzYDDxc+YDSWMiqt1ryxT0WYrrehJPg5pJQjy4AH1EgRIqa3eqK2RfmHS6SgkBOyg==",
95
95
  "license": "SEE LICENSE IN LICENSE",
96
96
  "dependencies": {
97
97
  "@sap/cds-compiler": "^6",
@@ -120,8 +120,8 @@
120
120
  }
121
121
  },
122
122
  "node_modules/@sap/cds-compiler": {
123
- "version": "6.0.12",
124
- "integrity": "sha512-7X68zXRJNjJfVFI7Qesp/YrCVTNCvmuGLRxdBSbpiZkgz6Wq9q4iTMeUg+8NcCynv+KaS6x1hSDfAEWTL0iLDA==",
123
+ "version": "6.1.0",
124
+ "integrity": "sha512-s71fsxDZKqHn2xvoqoNst54K/BkBzCpiU+8xc0t3nMDXmsLzSC3VfygZGwGAZD8fkxUnXh8oL2XLHWKWcvcdNg==",
125
125
  "license": "SEE LICENSE IN LICENSE",
126
126
  "bin": {
127
127
  "cdsc": "bin/cdsc.js",
@@ -142,8 +142,8 @@
142
142
  }
143
143
  },
144
144
  "node_modules/@sap/cds-mtxs": {
145
- "version": "3.0.1",
146
- "integrity": "sha512-9Jl2GgDueLHn7xuOL0igawT4knNEIogbo7r1OOwh4TPb2nbo3EZqs1/QlkF9OKk6+uD8ei7LXVohRQ/K1lvQEg==",
145
+ "version": "3.1.0",
146
+ "integrity": "sha512-ifE6RdiqIYz8OXOQYlEy0BYSHYN18T0d5kjSejX8svYsRyq//YsdxjybCFzOE3lgbHzfKsmAoe+ANx+99mhOwg==",
147
147
  "license": "SEE LICENSE IN LICENSE",
148
148
  "dependencies": {
149
149
  "@sap/hdi-deploy": "^5"
@@ -261,8 +261,8 @@
261
261
  "license": "MIT"
262
262
  },
263
263
  "node_modules/axios": {
264
- "version": "1.9.0",
265
- "integrity": "sha512-re4CqKTJaURpzbLHtIi6XpDv20/CnpXOtjRY5/CU32L8gU8ek9UIivcfvSWvmKEngmVbrUtPpdDwWDWL7DNHvg==",
264
+ "version": "1.10.0",
265
+ "integrity": "sha512-/1xYAC4MP/HEG+3duIhFr4ZQXR4sQXOIe+o6sdqzeykGLx6Upp/1p8MHqhINOvGeP7xyNHe7tsiJByc4SSVUxw==",
266
266
  "license": "MIT",
267
267
  "dependencies": {
268
268
  "follow-redirects": "^1.15.6",
@@ -564,8 +564,8 @@
564
564
  }
565
565
  },
566
566
  "node_modules/dotenv": {
567
- "version": "16.5.0",
568
- "integrity": "sha512-m/C+AwOAr9/W1UOIZUo232ejMNnJAJtYQjUbHoNTBNTJSvqzzDh7vnrei3o3r3m9blf6ZoDkvcw0VmozNRFJxg==",
567
+ "version": "16.6.1",
568
+ "integrity": "sha512-uBq4egWHTcTt33a72vpSG0z3HnPuIl6NqYcTrKEg2azoEyl2hpW0zqlxysq2pK9HlDIHyHyakeYaYnSAwd8bow==",
569
569
  "license": "BSD-2-Clause",
570
570
  "engines": {
571
571
  "node": ">=12"
@@ -601,8 +601,8 @@
601
601
  }
602
602
  },
603
603
  "node_modules/end-of-stream": {
604
- "version": "1.4.4",
605
- "integrity": "sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q==",
604
+ "version": "1.4.5",
605
+ "integrity": "sha512-ooEGc6HP26xXq/N+GCGOT0JKCLDGrq2bQUZrQ7gyrJiZANJ/8YDTxTpQBXGMn+WbIQXNVpyWymm7KYVICQnyOg==",
606
606
  "license": "MIT",
607
607
  "optional": true,
608
608
  "dependencies": {
@@ -1110,6 +1110,17 @@
1110
1110
  "node": ">=8.6"
1111
1111
  }
1112
1112
  },
1113
+ "node_modules/micromatch/node_modules/picomatch": {
1114
+ "version": "2.3.1",
1115
+ "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==",
1116
+ "license": "MIT",
1117
+ "engines": {
1118
+ "node": ">=8.6"
1119
+ },
1120
+ "funding": {
1121
+ "url": "https://github.com/sponsors/jonschlinkert"
1122
+ }
1123
+ },
1113
1124
  "node_modules/mime": {
1114
1125
  "version": "1.6.0",
1115
1126
  "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==",
@@ -1273,17 +1284,6 @@
1273
1284
  "integrity": "sha512-RA1GjUVMnvYFxuqovrEqZoxxW5NUZqbwKtYz/Tt7nXerk0LbLblQmrsgdeOxV5SFHf0UDggjS/bSeOZwt1pmEQ==",
1274
1285
  "license": "MIT"
1275
1286
  },
1276
- "node_modules/picomatch": {
1277
- "version": "2.3.1",
1278
- "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==",
1279
- "license": "MIT",
1280
- "engines": {
1281
- "node": ">=8.6"
1282
- },
1283
- "funding": {
1284
- "url": "https://github.com/sponsors/jonschlinkert"
1285
- }
1286
- },
1287
1287
  "node_modules/pluralize": {
1288
1288
  "version": "8.0.0",
1289
1289
  "integrity": "sha512-Nc3IT5yHzflTfbjgqWcCPpo7DaKy4FnpB0l/zCAW0Tc7jxAiuqSxHasntB3D7887LSrA93kDJ9IXovxJYxyLCA==",
@@ -1336,8 +1336,8 @@
1336
1336
  "license": "MIT"
1337
1337
  },
1338
1338
  "node_modules/pump": {
1339
- "version": "3.0.2",
1340
- "integrity": "sha512-tUPXtzlGM8FE3P0ZL6DVs/3P58k9nk8/jZeQCurTJylQA8qFYzHFfhBJkuqyE0FifOsQ0uKWekiZ5g8wtr28cw==",
1339
+ "version": "3.0.3",
1340
+ "integrity": "sha512-todwxLMY7/heScKmntwQG8CXVkWUOdYxIvY2s0VWAAMh/nd8SoYiRaKjlr7+iCs984f2P8zvrfWcDDYVb73NfA==",
1341
1341
  "license": "MIT",
1342
1342
  "optional": true,
1343
1343
  "dependencies": {
@@ -1799,8 +1799,8 @@
1799
1799
  "optional": true
1800
1800
  },
1801
1801
  "node_modules/ws": {
1802
- "version": "8.18.2",
1803
- "integrity": "sha512-DMricUmwGZUVr++AEAe2uiVM7UoO9MAVZMDu05UQOaUII0lp+zOzLLU4Xqh/JvTqklB1T4uELaaPBKyjE1r4fQ==",
1802
+ "version": "8.18.3",
1803
+ "integrity": "sha512-PEIGCY5tSlUt50cqyMXfCzX+oOPqN0vuGqWzbcJ2xvnkzkq46oOpz7dQaTDBdfICb4N14+GARUDw2XV2N4tvzg==",
1804
1804
  "license": "MIT",
1805
1805
  "engines": {
1806
1806
  "node": ">=10.0.0"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sap/cds-dk",
3
- "version": "9.0.5",
3
+ "version": "9.1.0",
4
4
  "description": "Command line client and development toolkit for the SAP Cloud Application Programming Model",
5
5
  "homepage": "https://cap.cloud.sap/",
6
6
  "keywords": [
@@ -1,5 +0,0 @@
1
- {
2
- "requires": {
3
- "telemetry": "to-cloud-logging"
4
- }
5
- }
@@ -1,103 +0,0 @@
1
- const os = require('node:os')
2
- const cp = require('node:child_process')
3
- const term = require('../util/term')
4
-
5
- const IS_WIN = os.platform() === 'win32'
6
- const REGEX_FLAGS = /--[a-z,a-z-]+[,\s+]\s+/gm
7
- const REGEX_OPTIONS = /--[a-z,a-z-]+\s[^\s]/gm
8
- const REGEX_SHORTCUT_MAPPINGS = /\s-[a-zA-Z]+, --[a-zA-Z-]+/gm
9
-
10
- module.exports = {
11
- /**
12
- * Generates `cds lint` help string to print when calling `cds lint [-h, --help]`
13
- * by getting available options/shortcuts from installed version of ESLint
14
- * @param {string} eslintCmd - ESLint command to call
15
- * @returns {string} `cds lint` help string
16
- */
17
- genEslintHelp: function (eslintCmd) {
18
- let eslintHelp
19
- try {
20
- eslintHelp = cp
21
- .execSync(`${eslintCmd} -h`, {
22
- cwd: process.cwd(),
23
- shell: IS_WIN,
24
- stdio: 'pipe',
25
- })
26
- .toString()
27
- } catch {
28
- console.log(
29
- `${term.error('Cannot call "eslint -h", install and try again.')}\n`
30
- )
31
- }
32
- const eslintOpts = eslintHelp.split('\n')
33
- const cdslintCmd = eslintOpts[0].replace('eslint', '*cds lint*')
34
- eslintOpts[0] = `
35
- # SYNOPSIS
36
-
37
- ${cdslintCmd}
38
-
39
- Runs environment checks and/or checks the specified models
40
- based on the ESLint framework
41
-
42
- # OPTIONS`
43
- return `${eslintOpts.join('\n ')}\n`
44
- },
45
-
46
- /**
47
- * Generates `cds lint` options array by extracting
48
- * all [--options] and [-shortcuts] strings from help string
49
- * Shortcut order must match order of [options, flags]
50
- * Any options without an shortcut must act as filler (undefined)
51
- * until the shortcuts for the flags start
52
- * @param {string} help - help string and shortcuts array for `cds lint`
53
- * @param {string[]} flags help string and shortcuts array for `cds lint`
54
- * @returns {{
55
- * help: string,
56
- * options: string[],
57
- * shortcuts: string[],
58
- * flags: string[]
59
- * }} `cds lint` allowed options
60
- */
61
- genEslintShortcutsAndOpts: function (help, flags) {
62
- const allOptions = help
63
- .match(REGEX_OPTIONS)
64
- .map((str) => str.split(' ')[0].trim().replace(',', ''))
65
- const shortcutMappings = help
66
- .match(REGEX_SHORTCUT_MAPPINGS)
67
- .map((str) => str.trim().split(/,\s?/))
68
- const optionsWithShortcuts = []
69
- /** @type {string[]} */
70
- let shortcuts = []
71
- const shortcutsForFlags = []
72
- shortcutMappings.forEach(([short, long]) => {
73
- if (!flags.includes(long)) {
74
- optionsWithShortcuts.push(long)
75
- shortcuts.push(short)
76
- } else {
77
- const index = flags.indexOf(long)
78
- flags.splice(index, 1)
79
- flags.unshift(long)
80
- shortcutsForFlags.unshift(short)
81
- }
82
- })
83
- const optionsWithoutShortcuts = allOptions.filter((o) => !optionsWithShortcuts.includes(o))
84
- optionsWithoutShortcuts.forEach(() => {
85
- shortcuts.push(undefined)
86
- })
87
- /** @type {string[]} */
88
- const options = optionsWithShortcuts.concat(optionsWithoutShortcuts)
89
- shortcuts = shortcuts.concat(shortcutsForFlags)
90
- return [help, options, shortcuts, flags]
91
- },
92
-
93
- /**
94
- * Generates a list of ESLint flags by extracting
95
- * all [--options] strings from help string which
96
- * do not require an extra argument
97
- * @param help string from `cds lint [-h, --help]`
98
- * @returns ESLint flags
99
- */
100
- genEslintFlags: help => help
101
- .match(REGEX_FLAGS)
102
- .map(str => str.trim().replace(',', ''))
103
- }