@sap/cds-dk 9.0.6 → 9.1.1

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 (45) hide show
  1. package/CHANGELOG.md +41 -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/index.d.ts +3 -0
  7. package/lib/build/provider/fiori/index.js +2 -4
  8. package/lib/deploy/to-hana/hana.js +9 -4
  9. package/lib/init/constants.js +12 -11
  10. package/lib/init/index.js +36 -5
  11. package/lib/init/merge.js +4 -1
  12. package/lib/init/plugin.js +0 -33
  13. package/lib/init/projectReader.js +1 -1
  14. package/lib/init/template/ams/files/Chart.yaml.hbs +3 -1
  15. package/lib/init/template/approuter/files/mta.yaml.hbs +2 -1
  16. package/lib/init/template/cloud-logging/files/java-cdsrc.json.hbs +6 -0
  17. package/lib/init/template/cloud-logging/files/package.json.hbs +7 -0
  18. package/lib/init/template/cloud-logging/index.js +9 -10
  19. package/lib/init/template/containerize/index.js +1 -1
  20. package/lib/init/template/data/as-json.js +3 -3
  21. package/lib/init/template/hana/index.js +3 -2
  22. package/lib/init/template/handler/files/extension/package.json +1 -1
  23. package/lib/init/template/html5-repo/files/mta.yaml.hbs +3 -1
  24. package/lib/init/template/html5-repo/index.js +1 -1
  25. package/lib/init/template/http/index.js +56 -54
  26. package/lib/init/template/ias/files/Chart.yaml.hbs +3 -1
  27. package/lib/init/template/ias/files/mta.yaml.hbs +2 -2
  28. package/lib/init/template/ias/index.js +3 -4
  29. package/lib/init/template/mta/index.js +5 -5
  30. package/lib/init/template/multitenancy/index.js +3 -4
  31. package/lib/init/template/nodejs/files/package.json.hbs +1 -1
  32. package/lib/init/template/portal/index.js +1 -1
  33. package/lib/init/template/test/files/package.json +8 -0
  34. package/lib/init/template/test/files/test/test.xs.hbs +36 -0
  35. package/lib/init/template/test/index.js +152 -0
  36. package/lib/init/template/typescript/files/package.json +1 -1
  37. package/lib/init/template/xsuaa/index.js +2 -2
  38. package/lib/lint/Linter.js +1 -4
  39. package/lib/lint/eslintHelp.json +84 -0
  40. package/lib/mtx/auth_manager.js +0 -2
  41. package/lib/util/axios.js +77 -31
  42. package/npm-shrinkwrap.json +24 -21
  43. package/package.json +3 -2
  44. package/lib/init/template/cloud-logging/files/java-cdsrc.json +0 -5
  45. 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.6",
3
+ "version": "9.1.1",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@sap/cds-dk",
9
- "version": "9.0.6",
9
+ "version": "9.1.1",
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.2",
46
- "integrity": "sha512-wbbEhUaSnQnYSC2029CO8MLAag5k/mJAtu6nyJUYfZbjkfr/JnP9lG5ylHg1dQtjRfAjPds+lxZIo35DHwNsVQ==",
45
+ "version": "2.2.0",
46
+ "integrity": "sha512-C5n8Qy8MwOGWjpXS44CskaEZt8YKrEEs4AtJyBSfJ6+aKMu/ynqpXh0Up4Ql0XX2Frq2PwNU8Ohai/04wxd46g==",
47
47
  "devOptional": true,
48
48
  "license": "Apache-2.0",
49
49
  "dependencies": {
@@ -65,21 +65,21 @@
65
65
  }
66
66
  },
67
67
  "node_modules/@cap-js/sqlite": {
68
- "version": "2.0.1",
69
- "integrity": "sha512-QahmUBueZ5fvzal7WpcUN83EKrtnIxJCtGGGqXmJraeBZY/wDx+NqOGFiiZ9UE05lUSvYtPJw4JJ+d3f5aCy8w==",
68
+ "version": "2.0.2",
69
+ "integrity": "sha512-oNg2f56sfELshyp0eSmYYwG1lt4Zmc135sLIzS8iykHdRVxxJpTrPj0jx0Y4Hc6sfC9u25LRXVu/ZKqjm9Yu+Q==",
70
70
  "license": "Apache-2.0",
71
71
  "optional": true,
72
72
  "dependencies": {
73
73
  "@cap-js/db-service": "^2",
74
- "better-sqlite3": "^11.0.0"
74
+ "better-sqlite3": "^12.0.0"
75
75
  },
76
76
  "peerDependencies": {
77
77
  "@sap/cds": ">=9"
78
78
  }
79
79
  },
80
80
  "node_modules/@eslint/js": {
81
- "version": "9.29.0",
82
- "integrity": "sha512-3PIF4cBw/y+1u2EazflInpV+lYsSG0aByVIQzAgb1m1MhHFSbqTyNqtBKHgWf/9Ykud+DhILS9EGkmekVhbKoQ==",
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.4",
94
- "integrity": "sha512-KaGI9DHLfs8SD44zgNQuODKOU5n8c4fer3a0hg2kmqvmTtATswnW4QuU9b8Wddx+bkoJDQYs8IZjAkWq21perw==",
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.14",
124
- "integrity": "sha512-glxvrrOABemDHxR6BOUSJdZ+H+aZ0PadreGML862ZIeJJ0AUAjwIiT6gV5i6cgbXGXI7+aG70/DRB+W4H8jAsQ==",
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"
@@ -291,14 +291,17 @@
291
291
  "optional": true
292
292
  },
293
293
  "node_modules/better-sqlite3": {
294
- "version": "11.10.0",
295
- "integrity": "sha512-EwhOpyXiOEL/lKzHz9AW1msWFNzGc/z+LzeB3/jnFJpxu+th2yqvzsSWas1v9jgs9+xiXJcD5A8CJxAG2TaghQ==",
294
+ "version": "12.2.0",
295
+ "integrity": "sha512-eGbYq2CT+tos1fBwLQ/tkBt9J5M3JEHjku4hbvQUePCckkvVf14xWj+1m7dGoK81M/fOjFT7yM9UMeKT/+vFLQ==",
296
296
  "hasInstallScript": true,
297
297
  "license": "MIT",
298
298
  "optional": true,
299
299
  "dependencies": {
300
300
  "bindings": "^1.5.0",
301
301
  "prebuild-install": "^7.1.1"
302
+ },
303
+ "engines": {
304
+ "node": "20.x || 22.x || 23.x || 24.x"
302
305
  }
303
306
  },
304
307
  "node_modules/bindings": {
@@ -564,8 +567,8 @@
564
567
  }
565
568
  },
566
569
  "node_modules/dotenv": {
567
- "version": "16.5.0",
568
- "integrity": "sha512-m/C+AwOAr9/W1UOIZUo232ejMNnJAJtYQjUbHoNTBNTJSvqzzDh7vnrei3o3r3m9blf6ZoDkvcw0VmozNRFJxg==",
570
+ "version": "16.6.1",
571
+ "integrity": "sha512-uBq4egWHTcTt33a72vpSG0z3HnPuIl6NqYcTrKEg2azoEyl2hpW0zqlxysq2pK9HlDIHyHyakeYaYnSAwd8bow==",
569
572
  "license": "BSD-2-Clause",
570
573
  "engines": {
571
574
  "node": ">=12"
@@ -1799,8 +1802,8 @@
1799
1802
  "optional": true
1800
1803
  },
1801
1804
  "node_modules/ws": {
1802
- "version": "8.18.2",
1803
- "integrity": "sha512-DMricUmwGZUVr++AEAe2uiVM7UoO9MAVZMDu05UQOaUII0lp+zOzLLU4Xqh/JvTqklB1T4uELaaPBKyjE1r4fQ==",
1805
+ "version": "8.18.3",
1806
+ "integrity": "sha512-PEIGCY5tSlUt50cqyMXfCzX+oOPqN0vuGqWzbcJ2xvnkzkq46oOpz7dQaTDBdfICb4N14+GARUDw2XV2N4tvzg==",
1804
1807
  "license": "MIT",
1805
1808
  "engines": {
1806
1809
  "node": ">=10.0.0"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sap/cds-dk",
3
- "version": "9.0.6",
3
+ "version": "9.1.1",
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": [
@@ -42,7 +42,8 @@
42
42
  "LICENSE",
43
43
  "npm-shrinkwrap.json",
44
44
  "package.json",
45
- "readme.md"
45
+ "readme.md",
46
+ "index.d.ts"
46
47
  ],
47
48
  "_hasShrinkwrap": true
48
49
  }
@@ -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
- }