@sap/cds 7.9.2 → 7.9.3

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.
package/CHANGELOG.md CHANGED
@@ -4,6 +4,18 @@
4
4
  - The format is based on [Keep a Changelog](http://keepachangelog.com/).
5
5
  - This project adheres to [Semantic Versioning](http://semver.org/).
6
6
 
7
+
8
+ ## Version 7.9.3 - 2024-06-27
9
+
10
+ ### Fixed
11
+
12
+ - `cds compile --to serviceinfo` returns the correct URL path for Java applications.
13
+ - Prevent HANA deadlocks when processing outbox table
14
+ - Invalid cache for `SiblingEntity` requests
15
+ - `cds.test` recommends version 7 of `chai-as-promised`. Version 8 is ESM-only and does not work with `cds.test` at the moment.
16
+ - Loading of `cds.plugins` now respects the (internal!) property `cds.env.plugins` again.
17
+ - `req.data` and `req.INSERT.entries` were not pointing to same object if it contains more than one entry.
18
+
7
19
  ## Version 7.9.2 - 2024-05-22
8
20
 
9
21
  ### Fixed
@@ -19,7 +31,7 @@
19
31
  ### Fixed
20
32
 
21
33
  - `cds.compile.to.sql` doesn't fail for older compiler versions if `postgres` keywords aren't defined
22
- - `cds compile --to serviceinfo` no longer detects a Java project if there is a poml.xml file in a subfolder of `app/`
34
+ - `cds compile --to serviceinfo` no longer detects a Java project if there is a pom.xml file in a subfolder of `app/`
23
35
  - `acquireTimeoutMillis` is ensured if custom pool config is provided
24
36
 
25
37
  ## Version 7.9.0 - 2024-04-30
@@ -3,7 +3,14 @@ const LOG = cds.log('auth')
3
3
 
4
4
  // _require for better error message
5
5
  const _require = require('../../libx/_runtime/common/utils/require')
6
- const xssec = _require('@sap/xssec')
6
+
7
+ let xssec = _require('@sap/xssec')
8
+ let xssec4 = false
9
+ // use v3 compat api
10
+ if (xssec.v3) {
11
+ xssec = xssec.v3
12
+ xssec4 = true
13
+ }
7
14
 
8
15
  // getter function extracted to show deprecation warning only once
9
16
  const _getTokenInfo = tokenInfo => tokenInfo
@@ -46,6 +53,13 @@ module.exports = function ias_auth(config) {
46
53
 
47
54
  return (req, _, next) => {
48
55
  const token = req.headers.authorization?.split(/^bearer /i)[1]
56
+
57
+ if (!token && xssec4) {
58
+ LOG._debug && LOG.debug('No authorization header provided, continuing with default user.')
59
+ req.user = new cds.User.default()
60
+ return next()
61
+ }
62
+
49
63
  xssec.createSecurityContext(token, credentials, 'IAS', function (err, securityContext, tokenInfo) {
50
64
  // REVISIT: ias impl not as sophisticated as xsuaa impl, so we need to be more tolerant here -> xssec issue 221
51
65
  // if (err && !tokenInfo) {
@@ -3,7 +3,14 @@ const LOG = cds.log('auth')
3
3
 
4
4
  // _require for better error message
5
5
  const _require = require('../../libx/_runtime/common/utils/require')
6
- const xssec = _require('@sap/xssec')
6
+
7
+ let xssec = _require('@sap/xssec')
8
+ let xssec4 = false
9
+ // use v3 compat api
10
+ if (xssec.v3) {
11
+ xssec = xssec.v3
12
+ xssec4 = true
13
+ }
7
14
 
8
15
  // getter function extracted to show deprecation warning only once
9
16
  const _getTokenInfo = tokenInfo => tokenInfo
@@ -13,7 +20,7 @@ module.exports = function jwt_auth(config) {
13
20
 
14
21
  if (!credentials) {
15
22
  let msg = `Authentication kind "${kind}" configured, but no XSUAA instance bound to application.`
16
- msg += ' Either bind an IAS instance, or switch to an authentication kind that does not require a binding.'
23
+ msg += ' Either bind an XSUAA instance, or switch to an authentication kind that does not require a binding.'
17
24
  throw new Error(msg)
18
25
  }
19
26
 
@@ -48,6 +55,13 @@ module.exports = function jwt_auth(config) {
48
55
 
49
56
  return (req, _, next) => {
50
57
  const token = req.headers.authorization?.split(/^bearer /i)[1]
58
+
59
+ if (!token && xssec4) {
60
+ LOG._debug && LOG.debug('No authorization header provided, continuing with default user.')
61
+ req.user = new cds.User.default()
62
+ return next()
63
+ }
64
+
51
65
  xssec.createSecurityContext(token, credentials, function (err, securityContext, tokenInfo) {
52
66
  if (err && !tokenInfo) {
53
67
  // here, there is a general problem, .e.g., bad credentials -> throw the error
@@ -90,7 +90,7 @@ module.exports = (model, options={}) => {
90
90
  const javaPrefixDefault = 'odata/v4/'
91
91
  const roots = [ cds.env.folders.db, cds.env.folders.srv ].map(d => join(root, d))
92
92
  for (let r of roots) {
93
- const file = isfile (join (r,'../src/main/resources/application.yaml'))
93
+ const file = isfile (join (r,'./src/main/resources/application.yaml'))
94
94
  if (file) {
95
95
  const yaml = cds.load.yaml(file)
96
96
  for (let yamlDoc of Array.isArray(yaml) ? yaml : [yaml]) {
package/lib/plugins.js CHANGED
@@ -30,7 +30,7 @@ exports.fetch = function (DEV = process.env.NODE_ENV !== 'production') {
30
30
  exports.activate = async function () {
31
31
  const DEBUG = cds.debug ('plugins', {label:'cds'})
32
32
  DEBUG && console.time ('[cds] - loaded plugins in')
33
- const plugins = exports.fetch(), { local } = cds.utils
33
+ const { plugins } = cds.env, { local } = cds.utils
34
34
  await Promise.all (Object.entries(plugins) .map (async ([ plugin, conf ]) => {
35
35
  DEBUG?.(`loading plugin ${plugin}:`, { impl: local(conf.impl) })
36
36
  // TODO: support ESM plugins. But see cap/cds/pull/1838#issuecomment-1177200 !
@@ -170,7 +170,7 @@ class Test extends require('./axios') {
170
170
  function require (mod) { try { return module.require(mod) } catch(e) {
171
171
  if (e.code === 'MODULE_NOT_FOUND') throw new Error (`
172
172
  Failed to load required package '${mod}'. Please add it thru:
173
- npm add -D chai@4 chai-as-promised chai-subset
173
+ npm add -D chai@4 chai-as-promised@7 chai-subset
174
174
  `)}}
175
175
  }
176
176
  get assert() { return this.chai.assert }
@@ -194,7 +194,7 @@ class AbstractEdmStructuredType extends EdmType {
194
194
  if (!this._navigationProperties) {
195
195
  this._navigationProperties = new Map(this.getBaseType() ? this.getBaseType().getNavigationProperties() : [])
196
196
  for (const [name, property] of this.getOwnNavigationProperties()) {
197
- if (ignoreSibling && name === 'SiblingEntity') continue;
197
+ if (!cds.env.fiori.lean_draft && ignoreSibling && name === 'SiblingEntity') continue; // This will cause subtle caching bugs but will enable expand=* in old draft
198
198
  this._navigationProperties.set(name, property)
199
199
  }
200
200
  }
@@ -2,13 +2,32 @@ const cds = require('../../cds')
2
2
  const { cqn2cqn4sql } = require('../../common/utils/cqn2cqn4sql')
3
3
  const { generateAliases } = require('../utils/generateAliases')
4
4
 
5
+ /**
6
+ * Restores the link of `req.data` and `req.query` in case `req.query` was overwritten.
7
+ * Only applicable for `UPDATE`s and `INSERT`s.
8
+ *
9
+ * @param { import('@sap/cds').Request } req
10
+ */
5
11
  const _restoreLink = req => {
6
12
  if (req.query.INSERT?.entries) {
7
- return (req.data = Array.isArray(req.query.INSERT.entries) ? req.query.INSERT.entries[0] : req.query.INSERT.entries)
13
+ if (Array.isArray(req.query.INSERT.entries)) req.data = req.query.INSERT.entries[0]
14
+ else req.data = req.query.INSERT.entries
15
+ } else if (req.query.UPDATE?.data) {
16
+ req.data = req.query.UPDATE.data
8
17
  }
18
+ }
19
+
20
+ const _isLinked = req => {
21
+ if (req.query.INSERT?.entries) {
22
+ if (Array.isArray(req.query.INSERT.entries)) return req.data === req.query.INSERT.entries[0]
23
+ return req.data === req.query.INSERT.entries
24
+ }
25
+
9
26
  if (req.query.UPDATE?.data) {
10
- return (req.data = req.query.UPDATE.data)
27
+ return req.data === req.query.UPDATE.data
11
28
  }
29
+
30
+ return false
12
31
  }
13
32
 
14
33
  function handler(req) {
@@ -30,14 +49,17 @@ function handler(req) {
30
49
 
31
50
  const _streaming = cds.env.features.stream_compat && req.query._streaming
32
51
 
52
+ // for restore link to req.data
53
+ const linked = _isLinked(req)
54
+
33
55
  // convert to sql cqn
34
56
  req.query = cqn2cqn4sql(req.query, this.model, { service: this })
35
57
 
58
+ // REVISIT: should not be necessary
36
59
  // restore link to req.data
37
- _restoreLink(req)
60
+ if (linked) _restoreLink(req)
38
61
 
39
62
  if (_streaming) req.query._streaming = _streaming
40
-
41
63
  generateAliases(req.query)
42
64
  }
43
65
 
@@ -61,7 +61,7 @@ const processMessages = async (service, tenant, _opts = {}) => {
61
61
  try {
62
62
  const messagesQuery = SELECT.from(messagesEntity)
63
63
  .where({ target: name })
64
- .orderBy('timestamp')
64
+ .orderBy(['timestamp', 'ID'])
65
65
  .limit(opts.chunkSize)
66
66
  .forUpdate()
67
67
  if (opts.maxAttempts) messagesQuery.where({ attempts: { '<': opts.maxAttempts } })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sap/cds",
3
- "version": "7.9.2",
3
+ "version": "7.9.3",
4
4
  "description": "SAP Cloud Application Programming Model - CDS for Node.js",
5
5
  "homepage": "https://cap.cloud.sap/",
6
6
  "keywords": [
@@ -37,10 +37,5 @@
37
37
  "@sap/cds-compiler": "^4",
38
38
  "@sap/cds-fiori": "^1",
39
39
  "@sap/cds-foss": "^5.0.0"
40
- },
41
- "cds": {
42
- "plugins": [
43
- "@sap/cds-fiori"
44
- ]
45
40
  }
46
41
  }