@sap/cds-dk 7.3.1 → 7.4.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/bin/add.js +2 -0
  2. package/bin/build.js +24 -14
  3. package/bin/cds.js +4 -4
  4. package/bin/compile/index.js +11 -0
  5. package/bin/init.js +1 -1
  6. package/bin/migrate.js +2 -2
  7. package/bin/repl.js +0 -2
  8. package/bin/subscribe.js +10 -5
  9. package/bin/unsubscribe.js +10 -5
  10. package/bin/upgrade.js +10 -5
  11. package/bin/watch.js +5 -0
  12. package/bin/watched.js +1 -1
  13. package/lib/build/buildTaskFactory.js +1 -1
  14. package/lib/build/constants.js +1 -0
  15. package/lib/build/provider/edmxBuildPlugin.js +7 -3
  16. package/lib/build/provider/featureToggleBuildPlugin.js +2 -3
  17. package/lib/build/provider/hana/2migration.js +4 -4
  18. package/lib/build/provider/hana/index.js +20 -10
  19. package/lib/build/provider/java/index.js +2 -2
  20. package/lib/build/provider/nodejs/index.js +77 -56
  21. package/lib/client/auth_manager.js +1 -1
  22. package/lib/client/base_command.js +8 -18
  23. package/lib/client/download_legacy.js +0 -3
  24. package/lib/client/params.js +5 -4
  25. package/lib/client/pull.js +9 -1
  26. package/lib/client/settings_manager.js +22 -21
  27. package/lib/compile/asyncapi/components/schemas/annotations.js +20 -0
  28. package/lib/compile/openapi/csdl2openapi.js +3 -3
  29. package/lib/deploy/to-hana/hana.js +53 -35
  30. package/lib/index.js +6 -4
  31. package/lib/init/constants.js +3 -4
  32. package/lib/init/index.js +9 -4
  33. package/lib/init/template/approuter/files/package.json +1 -1
  34. package/lib/init/template/enterprise-messaging/files/event-mesh.json.hbs +1 -1
  35. package/lib/init/template/enterprise-messaging/index.js +1 -1
  36. package/lib/init/template/enterprise-messaging-shared/files/event-mesh.json.hbs +1 -1
  37. package/lib/init/template/enterprise-messaging-shared/index.js +19 -5
  38. package/lib/init/template/hana/files/db/package.json +1 -1
  39. package/lib/init/template/helm/index.js +1 -1
  40. package/lib/init/template/local-messaging/files/package.json.hbs +15 -0
  41. package/lib/init/template/local-messaging/index.js +25 -0
  42. package/lib/init/template/multitenancy/index.js +3 -5
  43. package/lib/init/template/nodejs/files/.gitignore.hbs +3 -0
  44. package/lib/init/template/notifications/files/package.json.hbs +1 -10
  45. package/lib/init/template/notifications/index.js +7 -16
  46. package/lib/init/template/postgres/index.js +4 -3
  47. package/lib/init/template/templateBase.js +0 -13
  48. package/lib/init/template/typer/files/package.json +1 -1
  49. package/lib/init/util/projectReader.js +1 -0
  50. package/npm-shrinkwrap.json +377 -330
  51. package/package.json +1 -1
  52. package/lib/init/template/notifications/files/notificationtypes.json.hbs +0 -16
@@ -4,7 +4,7 @@
4
4
  "@sap/approuter": "^14.0.0"
5
5
  },
6
6
  "engines": {
7
- "node": "^18.0.0"
7
+ "node": "^20.0.0"
8
8
  },
9
9
  "scripts": {
10
10
  "start": "node node_modules/@sap/approuter/approuter.js"
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "emname": "{{appName}}-emname",
3
3
  "version": "1.1.0",
4
- "namespace": "default/{{appName}}/1",
4
+ "namespace": "default/{{cleanedAppName}}/1",
5
5
  "options": {
6
6
  "management": true,
7
7
  "messagingrest": true,
@@ -23,6 +23,7 @@ module.exports = class EnterpriseMessagingTemplate extends require('../templateB
23
23
  const project = await readProject()
24
24
  const { configFile } = project
25
25
  await mergeJSON(configFile, join(__dirname, 'files', 'package.json.hbs'), project)
26
+ await mergeJSON('event-mesh.json', join(__dirname, 'files', 'event-mesh.json.hbs'), project)
26
27
  }
27
28
 
28
29
  async runDependentMerging(context = {}) {
@@ -30,7 +31,6 @@ module.exports = class EnterpriseMessagingTemplate extends require('../templateB
30
31
  const { hasXsuaa, hasHelm, hasMta, isNodejs, srvPath, appName } = project
31
32
 
32
33
  if (hasMta) {
33
- await mergeJSON('event-mesh.json', join(__dirname, 'files', 'event-mesh.json.hbs'), project)
34
34
  const srv = (isNodejs ? srvNode4 : srvJava4)(srvPath)
35
35
  await mergeYAML(
36
36
  'mta.yaml',
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "emname": "{{appName}}-emname",
3
3
  "version": "1.1.0",
4
- "namespace": "default/{{appName}}/1",
4
+ "namespace": "default/{{cleanedAppName}}/1",
5
5
  "options": {
6
6
  "management": true,
7
7
  "messagingrest": true,
@@ -3,14 +3,14 @@ const cds = require('../../../cds')
3
3
  const { read } = cds.utils
4
4
  const { readProject } = require('../../util/projectReader')
5
5
  const { mergeJSON, mergeYAML } = require('../../util/merge')
6
+ const { parseMd5File, writeMd5File } = require('../../util/md5')
6
7
  const { srvNode4, srvJava4, enterpriseMessaging } = require('../_merging/registry-mta')
7
8
 
8
9
  module.exports = class EnterpriseMessagingSharedTemplate extends require('../templateBase') {
9
10
 
10
11
  async canRun() {
11
- const { hasMta, hasHelm, isJava } = await readProject()
12
- if (isJava) throw `'cds add enterprise-messaging-shared' is not available for Java yet`
13
- if (hasHelm && !hasMta) throw `'cds add enterprise-messaging-shared' is not available for Kyma yet`
12
+ const { isJava } = await readProject()
13
+ if (isJava) throw `'cds add enterprise-messaging-shared' is not available for Java yet`
14
14
  return true
15
15
  }
16
16
 
@@ -26,9 +26,9 @@ module.exports = class EnterpriseMessagingSharedTemplate extends require('../tem
26
26
  await mergeJSON('event-mesh.json', join(__dirname, 'files', 'event-mesh.json.hbs'), project)
27
27
  }
28
28
 
29
- async runDependentMerging() {
29
+ async runDependentMerging(context = {}) {
30
30
  const project = await readProject()
31
- const { hasMta, isNodejs, srvPath } = project
31
+ const { hasMta, hasHelm, isNodejs, srvPath } = project
32
32
 
33
33
  if (hasMta) {
34
34
  const srv = (isNodejs ? srvNode4 : srvJava4)(srvPath)
@@ -45,5 +45,19 @@ module.exports = class EnterpriseMessagingSharedTemplate extends require('../tem
45
45
  }
46
46
  )
47
47
  }
48
+
49
+ if (hasHelm) {
50
+ let isIndependentCommand = false
51
+ if (Object.keys(context).length == 0){
52
+ isIndependentCommand = true
53
+ context.oldTrackingData = context.newTrackingData = await parseMd5File(join('chart', '.cds-add-helm-files.md5'))
54
+ }
55
+ await mergeYAML(join('chart', 'values.yaml'), join(__dirname, 'files', 'values.yaml'))
56
+ const HelmTemplate = require(`../helm`);
57
+ const helmTemplate = new HelmTemplate(context.oldTrackingData, context.newTrackingData);
58
+ isIndependentCommand = isIndependentCommand | await helmTemplate.addSubChart('service-instance');
59
+ await helmTemplate.addDependency('service-instance', 'event-mesh');
60
+ if (isIndependentCommand) await writeMd5File(join('chart', '.cds-add-helm-files.md5'), context.newTrackingData)
61
+ }
48
62
  }
49
63
  }
@@ -4,7 +4,7 @@
4
4
  "@sap/hdi-deploy": "^4"
5
5
  },
6
6
  "engines": {
7
- "node": "^16 || ^18"
7
+ "node": "^20.0.0"
8
8
  },
9
9
  "scripts": {
10
10
  "start": "node node_modules/@sap/hdi-deploy/deploy.js",
@@ -14,7 +14,7 @@ module.exports = class HelmTemplate extends require('../templateBase') {
14
14
  }
15
15
 
16
16
  getRelatedFacets() {
17
- return ['hana', 'xsuaa', 'enterprise-messaging', 'destination' , 'multitenancy', 'extensibility', 'approuter', 'connectivity']
17
+ return ['hana', 'xsuaa', 'enterprise-messaging', 'enterprise-messaging-shared', 'destination' , 'multitenancy', 'extensibility', 'approuter', 'connectivity']
18
18
  }
19
19
 
20
20
  static hasFacet() {
@@ -0,0 +1,15 @@
1
+ {
2
+ "cds": {
3
+ "requires": {
4
+ {{#profile}}
5
+ "[{{profile}}]": {
6
+ {{/profile}}
7
+ "messaging": {
8
+ "kind": "local-messaging"
9
+ }
10
+ {{#profile}}
11
+ }
12
+ {{/profile}}
13
+ }
14
+ }
15
+ }
@@ -0,0 +1,25 @@
1
+ const { join } = require('path')
2
+ const cds = require('../../../cds')
3
+ const { read } = cds.utils
4
+ const { readProject } = require('../../util/projectReader')
5
+ const { mergeJSON } = require('../../util/merge')
6
+
7
+ module.exports = class LocalMessagingTemplate extends require('../templateBase') {
8
+
9
+ async canRun() {
10
+ const { isJava } = await readProject()
11
+ if (isJava) throw `'cds add local-messaging' is not available for Java yet`
12
+ return true
13
+ }
14
+
15
+ static hasFacet(env) {
16
+ return env.requires?.messaging?.kind === 'local-messaging'
17
+ }
18
+
19
+ async run() {
20
+ const project = await readProject()
21
+ const { configFile } = project
22
+ project.shortcut = !(await read(configFile)).cds?.requires?.messaging?.kind
23
+ await mergeJSON(configFile, join(__dirname, 'files', 'package.json.hbs'), project)
24
+ }
25
+ }
@@ -1,6 +1,6 @@
1
1
  const { join } = require('path')
2
2
  const cds = require('../../../cds')
3
- const { exists, read, write } = cds.utils
3
+ const { read, write } = cds.utils
4
4
  const { APPROUTER, HANA, KIBANA } = require('../../constants').OPTIONS
5
5
  const mvn = require('../../util/mvn')
6
6
  const { readProject } = require('../../util/projectReader')
@@ -17,11 +17,9 @@ const {
17
17
  module.exports = class MultitenancyTemplate extends require('../templateBase') {
18
18
 
19
19
  static hasFacet(env) {
20
- // REVISIT: Check if this can be simplified
21
20
  const { options } = cds.cli.options
22
- return options?.add?.has('mtx') || options?.add?.has('multitenancy') ||
23
- !!env.requires?.multitenancy || !!env.requires?.db?.multiTenant ||
24
- exists(join('mtx', 'sidecar')) || false
21
+ // REVISIT: Check if this can be simplified
22
+ return options?.add?.has('mtx') || options?.add?.has('multitenancy') || !!env.requires?.multitenancy || false
25
23
  }
26
24
 
27
25
  getRelatedFacets() {
@@ -29,3 +29,6 @@ mta_archives/
29
29
  # IDEs
30
30
  # .vscode
31
31
  # .idea
32
+
33
+ # @cap-js/cds-typer
34
+ @cds-models
@@ -1,14 +1,5 @@
1
1
  {
2
2
  "dependencies": {
3
3
  "@cap-js/notifications": "*"
4
- },
5
- "cds":{
6
- "requires":{
7
- "notifications":{
8
- "types" : "notificationtypes.json",
9
- "destination" : "SAP_Notifications",
10
- "prefix": "{{ appName }}"
11
- }
12
- }
13
4
  }
14
- }
5
+ }
@@ -1,6 +1,4 @@
1
1
  const { join } = require('path')
2
- const cds = require('../../../cds')
3
- const { exists } = cds.utils
4
2
  const { readProject } = require('../../util/projectReader')
5
3
  const { mergeJSON, mergeYAML } = require('../../util/merge')
6
4
  const { DESTINATION } = require('../../constants').OPTIONS
@@ -17,7 +15,7 @@ module.exports = class NotificationsTemplate extends require('../templateBase')
17
15
  const project = await readProject()
18
16
  const { isJava } = project
19
17
  if (isJava) {
20
- throw `'cds add notifications' is not available for JAVA yet`
18
+ throw `'cds add notifications' is not available for Java yet`
21
19
  }
22
20
  return true
23
21
  }
@@ -27,26 +25,19 @@ module.exports = class NotificationsTemplate extends require('../templateBase')
27
25
  }
28
26
 
29
27
  async run() {
30
- const project = await readProject();
31
- const { configFile } = project;
32
-
33
- // create notificationtypes if it doesn't exist
34
- if (!exists('notificationtypes.json')) {
35
- await mergeJSON('notificationtypes.json', join(__dirname, 'files', 'notificationtypes.json.hbs'), project);
36
- }
37
-
38
- //update package.json
39
- await mergeJSON(configFile, join(__dirname, 'files', 'package.json.hbs'), project);
28
+ const project = await readProject()
29
+ const { configFile } = project
30
+ await mergeJSON(configFile, join(__dirname, 'files', 'package.json.hbs'), project)
40
31
  }
41
32
 
42
33
  async runDependentMerging() {
43
- const project = await readProject();
44
- const { hasMta } = project;
34
+ const project = await readProject()
35
+ const { hasMta } = project
45
36
 
46
37
  if (hasMta) {
47
38
  await mergeYAML('mta.yaml', join(__dirname, 'files', 'mta.yaml.hbs'), project, {
48
39
  additions: [notificationTypesDeployer]
49
- });
40
+ })
50
41
  }
51
42
  }
52
43
  }
@@ -3,13 +3,13 @@ const cds = require('../../../cds')
3
3
  const { read } = cds.utils
4
4
  const { readProject } = require('../../util/projectReader')
5
5
  const { mergeJSON, mergeYAML } = require('../../util/merge')
6
+ const mvn = require('../../util/mvn')
6
7
  const { srvNode4, srvJava4, postgres, postgresDeployer } = require('../_merging/registry-mta')
7
8
 
8
9
  module.exports = class PostgresTemplate extends require('../templateBase') {
9
10
 
10
11
  async canRun() {
11
- const { hasMta, hasHelm, isJava } = await readProject(this.options)
12
- if (isJava) throw `'cds add postgres' is not available for Java yet`
12
+ const { hasMta, hasHelm } = await readProject(this.options)
13
13
  if (hasHelm && !hasMta) throw `'cds add postgres' is not available for Kyma yet`
14
14
  return true
15
15
  }
@@ -20,9 +20,10 @@ module.exports = class PostgresTemplate extends require('../templateBase') {
20
20
 
21
21
  async run() {
22
22
  const project = await readProject(this.options)
23
- const { configFile } = project
23
+ const { configFile, isJava } = project
24
24
  project.shortcut = !(await read(configFile)).cds?.requires?.db?.kind
25
25
  await mergeJSON(configFile, join(__dirname, 'files', 'package.json.hbs'), project)
26
+ if (isJava) await mvn.add('postgresql')
26
27
  await this.runDependentMerging()
27
28
  }
28
29
 
@@ -1,6 +1,4 @@
1
1
  const cds = require('../../cds')
2
- const { exists } = require('../../cds').utils
3
- const { PROJECT_TYPE } = require('../constants')
4
2
 
5
3
  module.exports = class TemplateBase {
6
4
 
@@ -99,15 +97,4 @@ module.exports = class TemplateBase {
99
97
  */
100
98
  async finalize() {
101
99
  }
102
-
103
- /**
104
- * Returns the project type
105
- * @see PROJECT_TYPE
106
- * @returns PROJECT_TYPE for current project
107
- */
108
- getProjectType() {
109
- if (exists('pom.xml')) return PROJECT_TYPE.java;
110
- if (exists('package.json')) return PROJECT_TYPE.nodejs;
111
- return PROJECT_TYPE.unknown;
112
- }
113
100
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "devDependencies": {
3
- "@cap-js/cds-typer": "^0"
3
+ "@cap-js/cds-typer": ">=0.1"
4
4
  },
5
5
  "imports": {
6
6
  "#cds-models/*": "./@cds-models/*/index.js"
@@ -83,6 +83,7 @@ module.exports = new class ProjectReader {
83
83
  get appPath() { return env.folders.app ?? 'app' },
84
84
  get appVersion() { return appVersion },
85
85
  get appName() { return appName },
86
+ get cleanedAppName() { return appName.replace('_', '-') }, // Required when _ isn't allowed in the namespace
86
87
  get appId() { return appId },
87
88
  get appDescription() { return appDescription },
88
89
  }