@sap/cds 7.6.3 → 7.6.4

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,15 @@
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
+ ## Version 7.6.4 - 2024-02-21
8
+
9
+ ### Fixed
10
+
11
+ - Emitting multiple message with an in-memory outbox
12
+ - Occasional crash for invalid draft requests
13
+ - On the index page, aditional links now show up again for non-OData services.
14
+ - Handling of thenables for queries
15
+
7
16
  ## Version 7.6.3 - 2024-02-13
8
17
 
9
18
  ### Fixed
package/app/index.js CHANGED
@@ -53,12 +53,12 @@ function _entities_in (service) {
53
53
  }
54
54
 
55
55
  function _moreLinks (srv, entity) {
56
- return odata(srv) ? (srv.$linkProviders || [])
56
+ return (srv.$linkProviders || [])
57
57
  .map (linkProv => linkProv(entity))
58
- .filter (l => l && l.href && l.name)
59
- .sort ((l1, l2) => l1.name.localeCompare(l2))
58
+ .filter (l => l?.href && l?.name)
59
+ .sort ((l1, l2) => l1.name.localeCompare(l2.name))
60
60
  .map (l => ` <a class="preview" href="${l.href}" title="${l.title||l.name}"> &rarr; ${l.name}</a>`)
61
- .join (' ') : ''
61
+ .join (' ')
62
62
  }
63
63
 
64
64
  function _project(){
package/lib/ql/Query.js CHANGED
@@ -34,7 +34,7 @@ class Query {
34
34
  const srv = this._srv || cds.db || cds.error `Can't execute query as no primary database is connected.`
35
35
  const q = new AsyncResource('await cds.query')
36
36
  // Temporary solution for cds.stream in .then. Remove with the next major release.
37
- return (r,e) => q.runInAsyncScope (srv.run, srv, this) .then(rt => { rt = this._stream && rt ? Object.values(rt)[0] : rt; r(rt) }, e)
37
+ return (r,e) => q.runInAsyncScope (srv.run, srv, this) .then(rt => { rt = this._stream && rt ? Object.values(rt)[0] : rt; return r(rt) }, e)
38
38
  }
39
39
 
40
40
  _target4 (...args) {
@@ -111,11 +111,13 @@ class HttpHeaderReader extends commons.http.HttpHeaderReader {
111
111
  throw new Error('Expected valid type at index ' + this._index + ' but found ' + this._getCurrentChar())
112
112
  }
113
113
 
114
- this._readChar('/')
114
+ if (type === '*') try { this._readChar('/') } catch {}
115
+ else this._readChar('/')
115
116
 
116
117
  let subtype
117
- if (type === '*') subtype = this._readChar('*')
118
+ if (type === '*') try { subtype = this._readChar('*') } catch {}
118
119
  if (!subtype) subtype = this._checkChar('*') ? '*' : this._readToken()
120
+ if (!subtype && type === '*') subtype = '*'
119
121
  if (!subtype) {
120
122
  throw new Error('Expected valid subtype at index ' + this._index + ' but found ' + this._getCurrentChar())
121
123
  }
@@ -549,6 +549,7 @@ const Read = {
549
549
  unchanged: async function (run, query) {
550
550
  LOG.debug('List Editing Status: Unchanged')
551
551
  const draftsQuery = query._drafts
552
+ if (!draftsQuery) throw new Error('Invalid draft request')
552
553
  draftsQuery.SELECT.count = undefined
553
554
  draftsQuery.SELECT.orderBy = undefined
554
555
  draftsQuery.SELECT.limit = null
@@ -564,6 +565,8 @@ const Read = {
564
565
  ownDrafts: async function (run, query) {
565
566
  LOG.debug('List Editing Status: Own Draft')
566
567
 
568
+ if (!query._drafts) throw new Error('Invalid draft request')
569
+
567
570
  // read active from draft
568
571
  if (!query._drafts._target?.name.endsWith('.drafts')) {
569
572
  const result = await run(query._drafts)
@@ -758,6 +761,8 @@ const Read = {
758
761
 
759
762
  activesFromDrafts: async function (run, query, { isLocked = true }) {
760
763
  const draftsQuery = query._drafts
764
+ if (!draftsQuery) throw new Error('Invalid draft request')
765
+
761
766
  const additionalCols = draftsQuery.SELECT.columns
762
767
  ? draftsQuery.SELECT.columns.filter(
763
768
  c => c.ref && ['DraftAdministrativeData', 'DraftAdministrativeData_DraftUUID'].includes(c.ref[0])
@@ -281,10 +281,10 @@ function outboxed(srv, customOpts) {
281
281
  // REVISIT: Also allow maxAttempts for in-memory outbox?
282
282
  for (const _req of context[$stored_reqs]) {
283
283
  try {
284
- if (req.reply) await originalSrv.send(req)
285
- else await originalSrv.emit(req)
284
+ if (_req.reply) await originalSrv.send(_req)
285
+ else await originalSrv.emit(_req)
286
286
  } catch (e) {
287
- LOG.error('Emit failed', { event: req.event, cause: e })
287
+ LOG.error('Emit failed', { event: _req.event, cause: e })
288
288
  if (isStandardError(e)) cds.exit(1)
289
289
  }
290
290
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sap/cds",
3
- "version": "7.6.3",
3
+ "version": "7.6.4",
4
4
  "description": "SAP Cloud Application Programming Model - CDS for Node.js",
5
5
  "homepage": "https://cap.cloud.sap/",
6
6
  "keywords": [