@sap/cds-dk 8.0.3 → 8.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 (43) hide show
  1. package/CHANGELOG.md +51 -1
  2. package/bin/bind.js +3 -3
  3. package/bin/cds.js +11 -15
  4. package/bin/init.js +3 -6
  5. package/bin/version.js +7 -6
  6. package/lib/build/buildTaskFactory.js +29 -12
  7. package/lib/build/constants.js +1 -1
  8. package/lib/build/provider/hana/index.js +5 -6
  9. package/lib/build/provider/internalBuildTaskProvider.js +2 -35
  10. package/lib/build/provider/mtx/resourcesTarBuilder.js +2 -2
  11. package/lib/build/provider/mtx-sidecar/index.js +10 -3
  12. package/lib/cds.js +1 -0
  13. package/lib/compile/to-mermaid.js +27 -12
  14. package/lib/compile/to_openapi.js +2 -1
  15. package/lib/deploy/to-hana/hana.js +10 -8
  16. package/lib/deploy/to-hana/hdiDeployUtil.js +10 -1
  17. package/lib/import/common.js +1 -1
  18. package/lib/import/message.js +2 -2
  19. package/lib/import/odata/v2parser.js +2 -2
  20. package/lib/init/bas.js +73 -32
  21. package/lib/init/constants.js +5 -2
  22. package/lib/init/index.js +6 -4
  23. package/lib/init/merge.js +5 -3
  24. package/lib/init/projectReader.js +3 -4
  25. package/lib/init/template/audit-logging/files/package.sidecar.json +7 -0
  26. package/lib/init/template/audit-logging/index.js +1 -1
  27. package/lib/init/template/cf-manifest/index.js +4 -0
  28. package/lib/init/template/data/as-json.js +22 -12
  29. package/lib/init/template/data/index.js +1 -1
  30. package/lib/init/template/helm-unified-runtime/index.js +3 -1
  31. package/lib/init/template/http/index.js +37 -28
  32. package/lib/init/template/multitenancy/index.js +9 -31
  33. package/lib/init/template/sample/files/app/admin-books/webapp/manifest.json +0 -1
  34. package/lib/init/template/sample/files/app/browse/webapp/manifest.json +0 -1
  35. package/lib/init/template/sample/files/nodejs/admin-service.js +13 -8
  36. package/lib/init/template/sample/files/nodejs/cat-service.js +27 -15
  37. package/lib/init/template/sample/files/srv/cat-service.cds +5 -1
  38. package/lib/init/template/typescript/files/package.json +3 -3
  39. package/lib/init/template/workzone/index.js +0 -3
  40. package/lib/init/template/xsuaa/index.js +10 -3
  41. package/lib/mtx/push.js +3 -1
  42. package/npm-shrinkwrap.json +19 -16
  43. package/package.json +1 -1
@@ -1,12 +1,17 @@
1
- const cds = require('@sap/cds/lib')
1
+ const cds = require('@sap/cds')
2
2
 
3
3
  module.exports = class AdminService extends cds.ApplicationService { init(){
4
- this.before ('NEW','Books.drafts', genid)
4
+
5
+ const { Books } = this.entities
6
+
7
+ /**
8
+ * Generate IDs for new Books drafts
9
+ */
10
+ this.before ('NEW', Books.drafts, async (req) => {
11
+ if (req.data.ID) return
12
+ const { ID:id1 } = await SELECT.one.from(Books).columns('max(ID) as ID')
13
+ const { ID:id2 } = await SELECT.one.from(Books.drafts).columns('max(ID) as ID')
14
+ req.data.ID = Math.max(id1||0, id2||0) + 1
15
+ })
5
16
  return super.init()
6
17
  }}
7
-
8
- /** Generate primary keys for target entity in request */
9
- async function genid (req) {
10
- const {ID} = await cds.tx(req).run (SELECT.one.from(req.target.actives).columns('max(ID) as ID'))
11
- req.data.ID = ID - ID % 100 + 100 + 1
12
- }
@@ -1,26 +1,38 @@
1
1
  const cds = require('@sap/cds')
2
- const { Books } = cds.entities ('sap.capire.bookshop')
3
2
 
4
- class CatalogService extends cds.ApplicationService { init(){
3
+ class CatalogService extends cds.ApplicationService { init() {
5
4
 
6
- // Reduce stock of ordered books if available stock suffices
7
- this.on ('submitOrder', async req => {
8
- const {book,quantity} = req.data
9
- let {stock} = await SELECT `stock` .from (Books,book)
10
- if (stock >= quantity) {
11
- await UPDATE (Books,book) .with (`stock -=`, quantity)
12
- await this.emit ('OrderedBook', { book, quantity, buyer:req.user.id })
13
- return { stock }
14
- }
15
- else return req.error (409,`${quantity} exceeds stock for book #${book}`)
16
- })
5
+ const { Books } = cds.entities('sap.capire.bookshop')
6
+ const { ListOfBooks } = this.entities
17
7
 
18
8
  // Add some discount for overstocked books
19
- this.after ('each','ListOfBooks', book => {
9
+ this.after('each', ListOfBooks, book => {
20
10
  if (book.stock > 111) book.title += ` -- 11% discount!`
21
11
  })
22
12
 
13
+ // Reduce stock of ordered books if available stock suffices
14
+ this.on('submitOrder', async req => {
15
+ let { book:id, quantity } = req.data
16
+ let book = await SELECT.one.from (Books, id, b => b.stock)
17
+
18
+ // Validate input data
19
+ if (!book) return req.error (404, `Book #${id} doesn't exist`)
20
+ if (quantity < 1) return req.error (400, `quantity has to be 1 or more`)
21
+ if (!book.stock || quantity > book.stock) return req.error (409, `${quantity} exceeds stock for book #${id}`)
22
+
23
+ // Reduce stock in database and return updated stock value
24
+ await UPDATE (Books, id) .with ({ stock: book.stock -= quantity })
25
+ return book
26
+ })
27
+
28
+ // Emit event when an order has been submitted
29
+ this.after('submitOrder', async (_,req) => {
30
+ let { book, quantity } = req.data
31
+ await this.emit('OrderedBook', { book, quantity, buyer: req.user.id })
32
+ })
33
+
34
+ // Delegate requests to the underlying generic service
23
35
  return super.init()
24
36
  }}
25
37
 
26
- module.exports = { CatalogService }
38
+ module.exports = CatalogService
@@ -11,6 +11,10 @@ service CatalogService {
11
11
  } excluding { createdBy, modifiedBy };
12
12
 
13
13
  @requires: 'authenticated-user'
14
- action submitOrder ( book: Books:ID, quantity: Integer ) returns { stock: Integer };
14
+ action submitOrder (
15
+ book : Books:ID @mandatory,
16
+ quantity: Integer @mandatory
17
+ ) returns { stock: Integer };
18
+
15
19
  event OrderedBook : { book: Books:ID; quantity: Integer; buyer: String };
16
20
  }
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "devDependencies": {
3
- "typescript": "^5",
4
- "@cap-js/cds-types": "<1",
5
- "@types/node": "^20"
3
+ "@cap-js/cds-types": "^0.6",
4
+ "@types/node": "^20",
5
+ "typescript": "^5"
6
6
  },
7
7
  "scripts": {
8
8
  "watch": "cds-ts w",
@@ -1,7 +1,4 @@
1
1
  module.exports = class extends require('../../plugin') {
2
- help() {
3
- return 'SAP BTP Work Zone'
4
- }
5
2
 
6
3
  requires() {
7
4
  return ['workzone-standard']
@@ -39,7 +39,7 @@ module.exports = class XsuaaTemplate extends require('../../plugin') {
39
39
  const additions = [srv, xsuaa]
40
40
  const mtxSidecar = mtxSidecar4(isJava ? 'mtx/sidecar' : 'gen/mtx/sidecar')
41
41
  if (hasMultitenancy && isJava) additions.push(mtxSidecar)
42
-
42
+ const overwrites = hasMultitenancy ? [{ item: [xsuaa, 'parameters.config.tenant-mode'], withValue: 'shared' }] : []
43
43
  const relationships = [{
44
44
  insert: [xsuaa, 'name'],
45
45
  into: [srv, 'requires', 'name']
@@ -48,11 +48,18 @@ module.exports = class XsuaaTemplate extends require('../../plugin') {
48
48
  insert: [xsuaa, 'name'],
49
49
  into: [mtxSidecar, 'requires', 'name']
50
50
  })
51
- await merge(__dirname, 'files/mta.yaml.hbs').into('mta.yaml', { project, additions, relationships })
51
+
52
+ await merge(__dirname, 'files/mta.yaml.hbs').into('mta.yaml', { project, additions, overwrites, relationships })
52
53
  }
53
54
 
54
55
  if (hasHelm || hasHelmUnifiedRuntime) {
55
- await merge(__dirname, 'files/values.yaml.hbs').into('chart/values.yaml', { with: project })
56
+ const overwrites = hasMultitenancy ? [{
57
+ item: [{
58
+ in: 'xsuaa',
59
+ where: { serviceOfferingName: 'xsuaa' }
60
+ }, 'parameters.tenant-mode'], withValue: 'shared'
61
+ }] : []
62
+ await merge(__dirname, 'files/values.yaml.hbs').into('chart/values.yaml', { with: project, overwrites })
56
63
 
57
64
  await merge({
58
65
  xsuaa: {
package/lib/mtx/push.js CHANGED
@@ -95,7 +95,9 @@ module.exports = class Push {
95
95
  }, 5 * 60 * 1000);
96
96
 
97
97
  const interval = setInterval(async () => {
98
- const { status, error = 'cds push failed' } = (await axios.get(jobUrl, options)).data;
98
+ const jobResult = await axios.get(jobUrl, options);
99
+ const { status, tasks } = jobResult.data;
100
+ const error = tasks[0]?.error ?? 'cds push failed'
99
101
  if (status === JOB_STATUS.FINISHED || status === JOB_STATUS.FAILED) {
100
102
  clearInterval(interval);
101
103
  clearTimeout(timeout);
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@sap/cds-dk",
3
- "version": "8.0.3",
3
+ "version": "8.1.1",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@sap/cds-dk",
9
- "version": "8.0.3",
9
+ "version": "8.1.1",
10
10
  "license": "SEE LICENSE IN LICENSE",
11
11
  "dependencies": {
12
12
  "@cap-js/asyncapi": "^1.0.0",
@@ -42,21 +42,24 @@
42
42
  }
43
43
  },
44
44
  "node_modules/@cap-js/db-service": {
45
- "version": "1.11.0",
45
+ "version": "1.12.0",
46
46
  "license": "SEE LICENSE",
47
47
  "optional": true,
48
+ "dependencies": {
49
+ "generic-pool": "^3.9.0"
50
+ },
48
51
  "peerDependencies": {
49
52
  "@sap/cds": ">=7.9"
50
53
  }
51
54
  },
52
55
  "node_modules/@cap-js/openapi": {
53
- "version": "1.0.4",
56
+ "version": "1.0.5",
54
57
  "license": "SEE LICENSE IN LICENSE",
55
58
  "dependencies": {
56
59
  "pluralize": "^8.0.0"
57
60
  },
58
61
  "peerDependencies": {
59
- "@sap/cds": ">=7.3"
62
+ "@sap/cds": ">=7.6"
60
63
  }
61
64
  },
62
65
  "node_modules/@cap-js/sqlite": {
@@ -102,7 +105,7 @@
102
105
  }
103
106
  },
104
107
  "node_modules/@eslint/config-array": {
105
- "version": "0.17.0",
108
+ "version": "0.17.1",
106
109
  "license": "Apache-2.0",
107
110
  "dependencies": {
108
111
  "@eslint/object-schema": "^2.1.4",
@@ -135,7 +138,7 @@
135
138
  }
136
139
  },
137
140
  "node_modules/@eslint/js": {
138
- "version": "9.7.0",
141
+ "version": "9.8.0",
139
142
  "license": "MIT",
140
143
  "engines": {
141
144
  "node": "^18.18.0 || ^20.9.0 || >=21.1.0"
@@ -200,7 +203,7 @@
200
203
  }
201
204
  },
202
205
  "node_modules/@sap/cds": {
203
- "version": "8.0.4",
206
+ "version": "8.1.0",
204
207
  "license": "SEE LICENSE IN LICENSE",
205
208
  "dependencies": {
206
209
  "@sap/cds-compiler": ">=5",
@@ -226,7 +229,7 @@
226
229
  }
227
230
  },
228
231
  "node_modules/@sap/cds-compiler": {
229
- "version": "5.0.6",
232
+ "version": "5.1.2",
230
233
  "license": "SEE LICENSE IN LICENSE",
231
234
  "dependencies": {
232
235
  "antlr4": "4.9.3"
@@ -262,7 +265,7 @@
262
265
  }
263
266
  },
264
267
  "node_modules/@sap/cds-mtxs": {
265
- "version": "2.0.3",
268
+ "version": "2.0.5",
266
269
  "license": "SEE LICENSE IN LICENSE",
267
270
  "dependencies": {
268
271
  "@sap/hdi-deploy": ">=4",
@@ -446,7 +449,7 @@
446
449
  "license": "MIT"
447
450
  },
448
451
  "node_modules/axios": {
449
- "version": "1.7.2",
452
+ "version": "1.7.3",
450
453
  "license": "MIT",
451
454
  "dependencies": {
452
455
  "follow-redirects": "^1.15.6",
@@ -866,14 +869,14 @@
866
869
  }
867
870
  },
868
871
  "node_modules/eslint": {
869
- "version": "9.7.0",
872
+ "version": "9.8.0",
870
873
  "license": "MIT",
871
874
  "dependencies": {
872
875
  "@eslint-community/eslint-utils": "^4.2.0",
873
876
  "@eslint-community/regexpp": "^4.11.0",
874
- "@eslint/config-array": "^0.17.0",
877
+ "@eslint/config-array": "^0.17.1",
875
878
  "@eslint/eslintrc": "^3.1.0",
876
- "@eslint/js": "9.7.0",
879
+ "@eslint/js": "9.8.0",
877
880
  "@humanwhocodes/module-importer": "^1.0.1",
878
881
  "@humanwhocodes/retry": "^0.3.0",
879
882
  "@nodelib/fs.walk": "^1.2.8",
@@ -2301,7 +2304,7 @@
2301
2304
  }
2302
2305
  },
2303
2306
  "node_modules/uglify-js": {
2304
- "version": "3.19.0",
2307
+ "version": "3.19.1",
2305
2308
  "license": "BSD-2-Clause",
2306
2309
  "optional": true,
2307
2310
  "bin": {
@@ -2422,7 +2425,7 @@
2422
2425
  }
2423
2426
  },
2424
2427
  "node_modules/yaml": {
2425
- "version": "2.4.5",
2428
+ "version": "2.5.0",
2426
2429
  "license": "ISC",
2427
2430
  "bin": {
2428
2431
  "yaml": "bin.mjs"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sap/cds-dk",
3
- "version": "8.0.3",
3
+ "version": "8.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": [