@sap/cds 8.9.7 → 8.9.9

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](https://keepachangelog.com/).
5
5
  - This project adheres to [Semantic Versioning](https://semver.org/).
6
6
 
7
+ ## Version 8.9.9 - 2026-03-10
8
+
9
+ ### Fixed
10
+
11
+ - Requests targeting a view with parameters are now correctly send to remote OData services
12
+
13
+ ## Version 8.9.8 - 2025-12-17
14
+
15
+ ### Fixed
16
+
17
+ - `enterprise-messaging-shared`: preserve error listener during reconnect
18
+
7
19
  ## Version 8.9.7 - 2025-11-07
8
20
 
9
21
  ### Fixed
@@ -1,64 +1,66 @@
1
1
  const waitingTime = require('../../common/utils/waitingTime')
2
2
 
3
- const _connectUntilConnected = (client, LOG, x) => {
4
- const _waitingTime = waitingTime(x)
5
- setTimeout(() => {
6
- connect(client, LOG, true)
7
- .then(() => {
8
- LOG._warn && LOG.warn('Reconnected to Enterprise Messaging Client')
9
- })
10
- .catch(() => {
11
- LOG._warn &&
12
- LOG.warn(
13
- `Connection to Enterprise Messaging Client lost: Reconnecting in ${Math.round(_waitingTime / 1000)} s`
14
- )
15
- _connectUntilConnected(client, LOG, x + 1)
16
- })
17
- }, _waitingTime)
3
+ const _rmHandlers = client => {
4
+ client.removeAllListeners('connected')
5
+ client.removeAllListeners('error')
6
+ client.removeAllListeners('disconnected')
18
7
  }
19
8
 
20
9
  const connect = (client, LOG, keepAlive) => {
21
10
  return new Promise((resolve, reject) => {
11
+ _rmHandlers(client)
12
+
22
13
  client
23
14
  .once('connected', function () {
24
- client.removeAllListeners('error')
15
+ _rmHandlers(client)
25
16
 
26
- client.once('error', err => {
27
- if (LOG._error) {
28
- err.message = 'Client error: ' + err.message
29
- LOG.error(err)
30
- }
31
- if (keepAlive) {
32
- client.removeAllListeners('error')
33
- client.removeAllListeners('connected')
34
- _connectUntilConnected(client, LOG, 0)
35
- }
36
- })
17
+ // It's important to _always_ keep an error listener,
18
+ // otherwise it will throw and crash the server
19
+ client.on('error', err => LOG(err?.message))
37
20
 
38
21
  if (keepAlive) {
39
- client.once('disconnected', () => {
40
- client.removeAllListeners('error')
41
- client.removeAllListeners('connected')
42
- _connectUntilConnected(client, LOG, 0)
22
+ client.on('disconnected', () => {
23
+ let connected = false
24
+ client.once('connected', () => {
25
+ LOG('Reconnected')
26
+ connected = true
27
+ })
28
+ let x = 1
29
+ const _untilConnected = async () => {
30
+ if (!connected) {
31
+ LOG('Reconnecting')
32
+ try {
33
+ client.connect()
34
+ } catch {
35
+ // we try again...
36
+ }
37
+ setTimeout(_untilConnected, waitingTime(x++))
38
+ }
39
+ }
40
+ _untilConnected()
43
41
  })
44
42
  }
45
43
 
46
- resolve(this)
44
+ resolve(client)
47
45
  })
48
46
  .once('error', err => {
49
- client.removeAllListeners('connected')
50
- reject(err)
47
+ _rmHandlers(client)
48
+ const e = new Error('Connection error')
49
+ e.cause = err
50
+ reject(e)
51
51
  })
52
52
 
53
- client.connect()
53
+ try {
54
+ client.connect()
55
+ } catch (e) {
56
+ reject(e)
57
+ }
54
58
  })
55
59
  }
56
60
 
57
61
  const disconnect = client => {
58
62
  return new Promise((resolve, reject) => {
59
- client.removeAllListeners('disconnected')
60
- client.removeAllListeners('connected')
61
- client.removeAllListeners('error')
63
+ _rmHandlers(client)
62
64
 
63
65
  client.once('disconnected', () => {
64
66
  client.removeAllListeners('error')
@@ -311,6 +311,12 @@ function _from(from, kind, model) {
311
311
  queryTarget = model && _getQueryTarget(queryTarget, id, model)
312
312
  const params = _params(args, kind, queryTarget)
313
313
  path.push(`${id}${params}`)
314
+ // args are only set in case the entity has parameters.
315
+ // Check model if that is the case and if so, conform to the OData representation for
316
+ // Views with parameters, meaning the actual entity is behind /Set
317
+ if (queryTarget?.params) {
318
+ path.push(`Set`)
319
+ }
314
320
  } else if (typeof curRef === 'string') {
315
321
  queryTarget = model && _getQueryTarget(queryTarget, curRef, model)
316
322
  path.push(curRef)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sap/cds",
3
- "version": "8.9.7",
3
+ "version": "8.9.9",
4
4
  "description": "SAP Cloud Application Programming Model - CDS for Node.js",
5
5
  "homepage": "https://cap.cloud.sap/",
6
6
  "keywords": [