@sap/cds-dk 8.2.2 → 8.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 (52) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/bin/cds.js +10 -9
  3. package/bin/compile/index.js +6 -2
  4. package/bin/deploy/index.js +22 -3
  5. package/bin/import.js +24 -14
  6. package/bin/repl.js +21 -8
  7. package/bin/util/fuzzySearch.js +8 -5
  8. package/bin/watch.js +1 -1
  9. package/lib/build/plugins/helm/files/subcharts/content-deployment/Chart.yaml +1 -1
  10. package/lib/build/plugins/helm/files/subcharts/content-deployment/values.schema.json +1 -1
  11. package/lib/build/plugins/helm/files/subcharts/content-deployment/values.yaml +1 -1
  12. package/lib/build/plugins/helm/files/subcharts/web-application/Chart.yaml +1 -1
  13. package/lib/build/plugins/helm/files/subcharts/web-application/templates/virtual-service.yaml +23 -12
  14. package/lib/build/plugins/helm/files/subcharts/web-application/values.schema.json +1 -1
  15. package/lib/build/plugins/helm/files/subcharts/web-application/values.yaml +2 -2
  16. package/lib/compile/to-mermaid.js +87 -0
  17. package/lib/import/common.js +40 -17
  18. package/lib/import/importapi.js +3 -3
  19. package/lib/import/openapi/importOpenAPI.js +42 -4
  20. package/lib/init/merge.js +2 -2
  21. package/lib/init/mvn.js +2 -2
  22. package/lib/init/projectReader.js +3 -1
  23. package/lib/init/registries/xs-app.js +10 -0
  24. package/lib/init/template/cf-manifest/index.js +2 -0
  25. package/lib/init/template/cloud-logging/files/mta.yaml.hbs +13 -2
  26. package/lib/init/template/cloud-logging/files/{package.json → package.json.hbs} +5 -1
  27. package/lib/init/template/cloud-logging/index.js +4 -3
  28. package/lib/init/template/data/as-csv.js +6 -0
  29. package/lib/init/template/data/as-json.js +8 -1
  30. package/lib/init/template/data/index.js +1 -1
  31. package/lib/init/template/destination/files/mta.yaml.hbs +5 -5
  32. package/lib/init/template/dynatrace/files/mta.yaml.hbs +22 -6
  33. package/lib/init/template/dynatrace/files/package.json.hbs +5 -2
  34. package/lib/init/template/dynatrace/files/values.yaml +15 -0
  35. package/lib/init/template/dynatrace/index.js +10 -5
  36. package/lib/init/template/handler/index.js +16 -1
  37. package/lib/init/template/helm/files/values.yaml.hbs +2 -2
  38. package/lib/init/template/helm/index.js +6 -1
  39. package/lib/init/template/html5-repo/files/app-package.json.hbs +3 -1
  40. package/lib/init/template/html5-repo/files/ui5-deploy.yaml.hbs +7 -0
  41. package/lib/init/template/html5-repo/index.js +3 -1
  42. package/lib/init/template/mta/files/mta.yaml.hbs +1 -1
  43. package/lib/init/template/mta/index.js +2 -0
  44. package/lib/init/template/typer/index.js +2 -1
  45. package/lib/init/template/workzone-standard/files/manifest.json.hbs +15 -1
  46. package/lib/init/template/workzone-standard/files/mta.yaml.hbs +11 -2
  47. package/lib/init/template/workzone-standard/files/xs-app.json.hbs +18 -0
  48. package/lib/init/template/workzone-standard/index.js +25 -7
  49. package/lib/mtx/auth_manager.js +7 -5
  50. package/lib/mtx/util/errors.js +4 -4
  51. package/npm-shrinkwrap.json +53 -44
  52. package/package.json +1 -1
@@ -5,6 +5,7 @@ const { bold } = require('../../../util/term')
5
5
  const { copyRenderedYAML } = require('../../../util/fs')
6
6
  const { readProject } = require('../../projectReader')
7
7
  const { merge, sort } = require('../../merge')
8
+ const { mvn } = require('../../add')
8
9
 
9
10
  module.exports = class MtaTemplate extends require('../../plugin') {
10
11
 
@@ -23,6 +24,7 @@ module.exports = class MtaTemplate extends require('../../plugin') {
23
24
  }
24
25
  await merge(__dirname, 'files/package.json').into('package.json')
25
26
  await sort('package.json', 'devDependencies')
27
+ if (project.isJava) await mvn.add('cf')
26
28
  }
27
29
 
28
30
  async finalize() {
@@ -1,7 +1,7 @@
1
1
  const { join } = require('path')
2
2
  const { readProject } = require('../../projectReader')
3
3
  const { merge, mergeGitignore } = require('../../merge')
4
- const { warn, dim } = require('../../../util/term')
4
+ const { warn, dim, bold } = require('../../../util/term')
5
5
  const { TYPER } = require('../../constants').OPTIONS
6
6
  const { exists, read } = require('../../../cds').utils
7
7
 
@@ -30,6 +30,7 @@ module.exports = class TyperTemplate extends require('../../plugin') {
30
30
  await merge(template('package.json')).into('package.json')
31
31
  await mergeGitignore('.gitignore', template('gitignore'))
32
32
  console.log(dim(` Adding '@cds-models' to .gitignore to ignore generated types`)) // REVISIT: other facets are silent wrt. what they change
33
+ console.log(dim(' Added new dependencies to the project. Run ') + bold('npm i') + dim(' to install.'))
33
34
  try {
34
35
  await merge(source).into(target)
35
36
  } catch (e) {
@@ -1,6 +1,20 @@
1
1
  {
2
+ "sap.app": {
3
+ "crossNavigation": {
4
+ "inbounds": {
5
+ "{{uiApp}}-display": {
6
+ "semanticObject": "{{uiApp}}",
7
+ "action": "display",
8
+ "signature": {
9
+ "parameters": {},
10
+ "additionalParameters": "allowed"
11
+ }
12
+ }
13
+ }
14
+ }
15
+ },
2
16
  "sap.cloud": {
3
17
  "public": true,
4
- "service": "{{appName}}.service"
18
+ "service": "{{strippedAppName}}.service"
5
19
  }
6
20
  }
@@ -1,5 +1,13 @@
1
1
  ---
2
2
  modules:
3
+ - name: {{appName}}-srv
4
+ type: {{language}}
5
+ path: {{& srvPath}}
6
+ provides:
7
+ - name: srv-api # required by consumers of CAP services (e.g. approuter)
8
+ properties:
9
+ srv-url: ${default-url}
10
+
3
11
  - name: {{appName}}-destinations
4
12
  type: com.sap.application.content
5
13
  requires:
@@ -25,13 +33,14 @@ modules:
25
33
  - Name: {{appName}}-html5-repository
26
34
  ServiceInstanceName: {{appName}}-html5-repo-host
27
35
  ServiceKeyName: {{appName}}-html5-repo-host-key
28
- sap.cloud.service: {{appName}}.service
36
+ sap.cloud.service: {{strippedAppName}}.service
29
37
  - Name: {{appName}}-auth
30
38
  Authentication: OAuth2UserTokenExchange
31
39
  ServiceInstanceName: {{appName}}-auth
32
40
  ServiceKeyName: {{appName}}-auth-key
33
- sap.cloud.service: {{appName}}.service
41
+ sap.cloud.service: {{strippedAppName}}.service
34
42
 
43
+ resources:
35
44
  - name: {{appName}}-destination
36
45
  type: org.cloudfoundry.managed-service
37
46
  parameters:
@@ -0,0 +1,18 @@
1
+ {
2
+ "authenticationMethod": "route",
3
+ "routes": [
4
+ {
5
+ "source": "^/?odata/(.*)$",
6
+ "target": "/odata/$1",
7
+ "destination": "{{appName}}-srv-api",
8
+ {{#hasXsuaa}}"authenticationType": "xsuaa",{{/hasXsuaa}}
9
+ "csrfProtection": true
10
+ },
11
+ {
12
+ "source": "^(.*)$",
13
+ "target": "$1",
14
+ "service": "html5-apps-repo-rt"{{#hasXsuaa}},
15
+ "authenticationType": "xsuaa"{{/hasXsuaa}}
16
+ }
17
+ ]
18
+ }
@@ -2,7 +2,8 @@ const cds = require('../../../cds')
2
2
  const { readProject } = require('../../projectReader')
3
3
  const { merge } = require('../../merge')
4
4
  const { join } = require('path')
5
- const { destination, destinations } = require('../../registries/mta')
5
+ const { destination, destinations, srv4 } = require('../../registries/mta')
6
+ const { odataApi } = require('../../registries/xs-app')
6
7
 
7
8
  module.exports = class extends require('../../plugin') {
8
9
 
@@ -28,19 +29,36 @@ module.exports = class extends require('../../plugin') {
28
29
  async run() {
29
30
  const project = readProject()
30
31
  const { appUIPaths, appPath } = project
31
- await Promise.all(appUIPaths.map(p =>
32
- merge(__dirname, 'files/manifest.json.hbs').into(join(appPath, p, 'webapp/manifest.json'), { project })
33
- ))
32
+ await Promise.all(appUIPaths.map(p => {
33
+ project.uiApp = p
34
+ return merge(__dirname, 'files/manifest.json.hbs').into(join(appPath, p, 'webapp/manifest.json'), { project })
35
+ }))
34
36
  await merge({ cds: { requires: { workzone: true } } }).into('package.json')
35
37
  }
36
38
 
37
39
  async combine() {
38
40
  const project = readProject()
39
- const { hasMta } = project
41
+ const { hasMta, srvPath, apps, appPath } = project
42
+
43
+ await Promise.all(apps.map(async ({app}) => {
44
+ const additions = [odataApi]
45
+ const overwrites = [{
46
+ item: [odataApi, 'destination'],
47
+ withValue: `${project.appName}-srv-api`
48
+ }]
49
+ project.app = app
50
+ await merge(__dirname, 'files/xs-app.json.hbs').into(join(appPath, app, 'xs-app.json'), { with: project, additions, overwrites })
51
+ }))
40
52
 
41
53
  if (hasMta) {
42
- const additions = [destinations, destination]
43
- await merge(__dirname, 'files/mta.yaml.hbs').into('mta.yaml', { with: project, additions })
54
+ const srv = srv4(srvPath)
55
+ const additions = [srv, destinations, destination,
56
+ {
57
+ in: [destination, 'requires'],
58
+ where: { name: 'srv-api' }
59
+ }
60
+ ]
61
+ await merge(__dirname, 'files/mta.yaml.hbs').into('mta.yaml', { with: project, additions })
44
62
  }
45
63
  }
46
64
  }
@@ -67,7 +67,7 @@ function reqParams(method, params) {
67
67
  }
68
68
 
69
69
  async function fetchToken(params) {
70
- if (params.has('token') || !(params.has('refreshToken') || params.has('passcode') || !params.has('passcodeUrl'))) {
70
+ if (params.has('token') || !(params.has('refreshToken') || params.has('passcode') || params.has('clientid') || !params.has('passcodeUrl'))) {
71
71
  return;
72
72
  }
73
73
 
@@ -99,18 +99,20 @@ async function fetchToken(params) {
99
99
  if (error) {
100
100
  let message;
101
101
  if (REASONS.invalid_scope.test(error.message)) {
102
- message = 'token has invalid scope. Check if your user has the required roles';
102
+ message = 'token has invalid scope. Ensure your user has the required roles';
103
103
  } else if (error.status === 404) {
104
- message = 'token endpoint not found. Check if MTX is running with extensibility enabled';
104
+ message = 'token endpoint not found. Ensure that MTX is running with extensibility enabled';
105
105
  } else if (error.message.includes('<html')) { // should already be caught when fetching passcode URL
106
- message = 'HTML response received. Check if route to MTX is configured correctly in App Router';
106
+ message = 'HTML response received. Ensure the route to MTX is configured correctly in App Router';
107
107
  } else if (error.status === 401) {
108
108
  message = `invalid credentials`;
109
109
  if (params.has('passcode')) {
110
- message += `. Check if passcode is correct`;
110
+ message += `. Ensure the passcode is correct`;
111
111
  if (params.has('passcodeUrl')) {
112
112
  message += `. Passcode URL: ${params.get('passcodeUrl')}`;
113
113
  }
114
+ } else if (params.has('clientid')) {
115
+ message += `. Ensure the client credentials are correct`;
114
116
  }
115
117
  } else {
116
118
  message = 'error on token request';
@@ -5,11 +5,11 @@ function handleHttpError(error, params, { url, command } = {}) {
5
5
  const prefix = `Request to ${url} failed`;
6
6
  switch (error.status) {
7
7
  case 401:
8
- throw getMessage(`${prefix}: invalid authentication.\nRetry with valid passcode${
9
- params.has('passcodeUrl') ? ` from ${params.get('passcodeUrl')}` : ''
10
- } or username/password (required if SaaS app is configured with mocked-auth).`, { error, command });
8
+ throw getMessage(`${prefix}: invalid authentication` + (
9
+ params.has('username') ? `. Ensure that username and password are correct` : ''
10
+ ), { error, command });
11
11
  case 403:
12
- throw getMessage(prefix + ': insufficient authorization. Ensure client has all necessary roles.', { error, command });
12
+ throw getMessage(prefix + ': insufficient authorization. Ensure the user has all necessary roles.', { error, command });
13
13
  case 404:
14
14
  throw getMessage(prefix + ': resource not found.', { error, command });
15
15
  case 422:
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@sap/cds-dk",
3
- "version": "8.2.2",
3
+ "version": "8.3.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@sap/cds-dk",
9
- "version": "8.2.2",
9
+ "version": "8.3.0",
10
10
  "license": "SEE LICENSE IN LICENSE",
11
11
  "dependencies": {
12
12
  "@cap-js/asyncapi": "^1.0.0",
@@ -54,7 +54,7 @@
54
54
  }
55
55
  },
56
56
  "node_modules/@cap-js/openapi": {
57
- "version": "1.0.5",
57
+ "version": "1.0.6",
58
58
  "license": "SEE LICENSE IN LICENSE",
59
59
  "dependencies": {
60
60
  "pluralize": "^8.0.0"
@@ -99,7 +99,7 @@
99
99
  }
100
100
  },
101
101
  "node_modules/@eslint-community/regexpp": {
102
- "version": "4.11.0",
102
+ "version": "4.11.1",
103
103
  "license": "MIT",
104
104
  "engines": {
105
105
  "node": "^12.0.0 || ^14.0.0 || >=16.0.0"
@@ -117,6 +117,13 @@
117
117
  "node": "^18.18.0 || ^20.9.0 || >=21.1.0"
118
118
  }
119
119
  },
120
+ "node_modules/@eslint/core": {
121
+ "version": "0.6.0",
122
+ "license": "Apache-2.0",
123
+ "engines": {
124
+ "node": "^18.18.0 || ^20.9.0 || >=21.1.0"
125
+ }
126
+ },
120
127
  "node_modules/@eslint/eslintrc": {
121
128
  "version": "3.1.0",
122
129
  "license": "MIT",
@@ -139,7 +146,7 @@
139
146
  }
140
147
  },
141
148
  "node_modules/@eslint/js": {
142
- "version": "9.10.0",
149
+ "version": "9.11.1",
143
150
  "license": "MIT",
144
151
  "engines": {
145
152
  "node": "^18.18.0 || ^20.9.0 || >=21.1.0"
@@ -153,7 +160,7 @@
153
160
  }
154
161
  },
155
162
  "node_modules/@eslint/plugin-kit": {
156
- "version": "0.1.0",
163
+ "version": "0.2.0",
157
164
  "license": "Apache-2.0",
158
165
  "dependencies": {
159
166
  "levn": "^0.4.1"
@@ -214,7 +221,7 @@
214
221
  }
215
222
  },
216
223
  "node_modules/@sap/cds": {
217
- "version": "8.2.2",
224
+ "version": "8.3.0",
218
225
  "license": "SEE LICENSE IN LICENSE",
219
226
  "dependencies": {
220
227
  "@sap/cds-compiler": ">=5.1",
@@ -240,7 +247,7 @@
240
247
  }
241
248
  },
242
249
  "node_modules/@sap/cds-compiler": {
243
- "version": "5.2.0",
250
+ "version": "5.3.0",
244
251
  "license": "SEE LICENSE IN LICENSE",
245
252
  "dependencies": {
246
253
  "antlr4": "4.9.3"
@@ -276,7 +283,7 @@
276
283
  }
277
284
  },
278
285
  "node_modules/@sap/cds-mtxs": {
279
- "version": "2.1.0",
286
+ "version": "2.2.0",
280
287
  "license": "SEE LICENSE IN LICENSE",
281
288
  "dependencies": {
282
289
  "@sap/hdi-deploy": ">=4",
@@ -288,7 +295,7 @@
288
295
  }
289
296
  },
290
297
  "node_modules/@sap/eslint-plugin-cds": {
291
- "version": "3.0.5",
298
+ "version": "3.1.0",
292
299
  "license": "See LICENSE file",
293
300
  "dependencies": {
294
301
  "@sap/cds": ">=7",
@@ -302,13 +309,13 @@
302
309
  }
303
310
  },
304
311
  "node_modules/@sap/hdi": {
305
- "version": "4.5.2",
312
+ "version": "4.6.0",
306
313
  "license": "See LICENSE file",
307
314
  "dependencies": {
308
- "async": "3.2.3"
315
+ "async": "^3.2.3"
309
316
  },
310
317
  "engines": {
311
- "node": ">=12 <=20"
318
+ "node": ">=18 <=20"
312
319
  },
313
320
  "peerDependencies": {
314
321
  "@sap/hana-client": "^2 >= 2.5",
@@ -324,16 +331,15 @@
324
331
  }
325
332
  },
326
333
  "node_modules/@sap/hdi-deploy": {
327
- "version": "5.2.3",
328
- "hasInstallScript": true,
334
+ "version": "5.3.2",
329
335
  "license": "See LICENSE file",
330
336
  "dependencies": {
331
- "@sap/hdi": "4.5.2",
332
- "@sap/xsenv": "5.2.0",
333
- "async": "3.2.6",
334
- "dotenv": "16.4.5",
335
- "handlebars": "4.7.8",
336
- "micromatch": "4.0.8"
337
+ "@sap/hdi": "^4.6.0",
338
+ "@sap/xsenv": "^5.2.0",
339
+ "async": "^3.2.6",
340
+ "dotenv": "^16.4.5",
341
+ "handlebars": "^4.7.8",
342
+ "micromatch": "^4.0.8"
337
343
  },
338
344
  "engines": {
339
345
  "node": "^18.0.0 || ^20.0.0"
@@ -351,22 +357,26 @@
351
357
  }
352
358
  }
353
359
  },
354
- "node_modules/@sap/hdi/node_modules/async": {
355
- "version": "3.2.3",
356
- "license": "MIT"
357
- },
358
360
  "node_modules/@sap/xsenv": {
359
- "version": "5.2.0",
361
+ "version": "5.3.0",
360
362
  "license": "SEE LICENSE IN LICENSE file",
361
363
  "dependencies": {
362
- "debug": "4.3.5",
363
- "node-cache": "^5.1.0",
364
+ "debug": "4.3.7",
365
+ "node-cache": "^5.1.2",
364
366
  "verror": "1.10.1"
365
367
  },
366
368
  "engines": {
367
369
  "node": "^18.0.0 || ^20.0.0"
368
370
  }
369
371
  },
372
+ "node_modules/@types/estree": {
373
+ "version": "1.0.6",
374
+ "license": "MIT"
375
+ },
376
+ "node_modules/@types/json-schema": {
377
+ "version": "7.0.15",
378
+ "license": "MIT"
379
+ },
370
380
  "node_modules/accepts": {
371
381
  "version": "1.3.8",
372
382
  "license": "MIT",
@@ -734,10 +744,10 @@
734
744
  }
735
745
  },
736
746
  "node_modules/debug": {
737
- "version": "4.3.5",
747
+ "version": "4.3.7",
738
748
  "license": "MIT",
739
749
  "dependencies": {
740
- "ms": "2.1.2"
750
+ "ms": "^2.1.3"
741
751
  },
742
752
  "engines": {
743
753
  "node": ">=6.0"
@@ -880,18 +890,21 @@
880
890
  }
881
891
  },
882
892
  "node_modules/eslint": {
883
- "version": "9.10.0",
893
+ "version": "9.11.1",
884
894
  "license": "MIT",
885
895
  "dependencies": {
886
896
  "@eslint-community/eslint-utils": "^4.2.0",
887
897
  "@eslint-community/regexpp": "^4.11.0",
888
898
  "@eslint/config-array": "^0.18.0",
899
+ "@eslint/core": "^0.6.0",
889
900
  "@eslint/eslintrc": "^3.1.0",
890
- "@eslint/js": "9.10.0",
891
- "@eslint/plugin-kit": "^0.1.0",
901
+ "@eslint/js": "9.11.1",
902
+ "@eslint/plugin-kit": "^0.2.0",
892
903
  "@humanwhocodes/module-importer": "^1.0.1",
893
904
  "@humanwhocodes/retry": "^0.3.0",
894
905
  "@nodelib/fs.walk": "^1.2.8",
906
+ "@types/estree": "^1.0.6",
907
+ "@types/json-schema": "^7.0.15",
895
908
  "ajv": "^6.12.4",
896
909
  "chalk": "^4.0.0",
897
910
  "cross-spawn": "^7.0.2",
@@ -937,7 +950,7 @@
937
950
  }
938
951
  },
939
952
  "node_modules/eslint-scope": {
940
- "version": "8.0.2",
953
+ "version": "8.1.0",
941
954
  "license": "BSD-2-Clause",
942
955
  "dependencies": {
943
956
  "esrecurse": "^4.3.0",
@@ -951,7 +964,7 @@
951
964
  }
952
965
  },
953
966
  "node_modules/eslint-visitor-keys": {
954
- "version": "4.0.0",
967
+ "version": "4.1.0",
955
968
  "license": "Apache-2.0",
956
969
  "engines": {
957
970
  "node": "^18.18.0 || ^20.9.0 || >=21.1.0"
@@ -961,12 +974,12 @@
961
974
  }
962
975
  },
963
976
  "node_modules/espree": {
964
- "version": "10.1.0",
977
+ "version": "10.2.0",
965
978
  "license": "BSD-2-Clause",
966
979
  "dependencies": {
967
980
  "acorn": "^8.12.0",
968
981
  "acorn-jsx": "^5.3.2",
969
- "eslint-visitor-keys": "^4.0.0"
982
+ "eslint-visitor-keys": "^4.1.0"
970
983
  },
971
984
  "engines": {
972
985
  "node": "^18.18.0 || ^20.9.0 || >=21.1.0"
@@ -1364,7 +1377,7 @@
1364
1377
  }
1365
1378
  },
1366
1379
  "node_modules/hdb": {
1367
- "version": "0.19.9",
1380
+ "version": "0.19.10",
1368
1381
  "license": "Apache-2.0",
1369
1382
  "dependencies": {
1370
1383
  "iconv-lite": "^0.4.18"
@@ -1649,7 +1662,7 @@
1649
1662
  "optional": true
1650
1663
  },
1651
1664
  "node_modules/ms": {
1652
- "version": "2.1.2",
1665
+ "version": "2.1.3",
1653
1666
  "license": "MIT"
1654
1667
  },
1655
1668
  "node_modules/mustache": {
@@ -1680,7 +1693,7 @@
1680
1693
  "license": "MIT"
1681
1694
  },
1682
1695
  "node_modules/node-abi": {
1683
- "version": "3.67.0",
1696
+ "version": "3.68.0",
1684
1697
  "license": "MIT",
1685
1698
  "optional": true,
1686
1699
  "dependencies": {
@@ -2089,10 +2102,6 @@
2089
2102
  "node": ">= 0.8"
2090
2103
  }
2091
2104
  },
2092
- "node_modules/send/node_modules/ms": {
2093
- "version": "2.1.3",
2094
- "license": "MIT"
2095
- },
2096
2105
  "node_modules/serve-static": {
2097
2106
  "version": "1.16.2",
2098
2107
  "license": "MIT",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sap/cds-dk",
3
- "version": "8.2.2",
3
+ "version": "8.3.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": [