@sap/cds 9.0.3 → 9.1.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.
@@ -36,6 +36,7 @@ const _isProviderTenant = tenant =>
36
36
  cds.requires.multitenancy.t0 === tenant
37
37
 
38
38
  const _hasPersistentQueue = tenant => {
39
+ if (!cds.db) return false // no persistence configured
39
40
  if (cds.requires.multitenancy && tenant && _isProviderTenant(tenant)) return false // no persistence for provider account
40
41
  return true
41
42
  }
@@ -48,6 +49,8 @@ const _safeJSONParse = string => {
48
49
  }
49
50
  }
50
51
 
52
+ const _targetName = (name, opts) => (opts.targetPrefix ? opts.targetPrefix + name : name)
53
+
51
54
  // Note: This function can also run for each tenant on startup
52
55
  //
53
56
  // tx1: Fetch messages which are not in process and are not locked (SELECT FOR UPDATE)
@@ -94,7 +97,7 @@ const processTasks = (service, tenant, _opts = {}) => {
94
97
  }
95
98
 
96
99
  const tasksQuery = SELECT.from(tasksEntity)
97
- .where({ target: name })
100
+ .where({ target: _targetName(name, opts) })
98
101
  .orderBy(opts.parallel ? ['status', 'timestamp', 'ID'] : ['timestamp', 'status', 'ID'])
99
102
  .limit(opts.chunkSize)
100
103
  .forUpdate()
@@ -293,6 +296,7 @@ const processTasks = (service, tenant, _opts = {}) => {
293
296
  const _newMsgFrom = msg => {
294
297
  const _fromSend = msg instanceof cds.Request
295
298
  const newMsg = { ...msg }
299
+ if (msg.entity) newMsg.entity = msg.entity // needed for proper `h.for(msg)` handling
296
300
  newMsg._fromSend = _fromSend
297
301
  if (!newMsg.queue) return newMsg
298
302
  if (!newMsg.queue.after && !newMsg.queue.every) return newMsg
@@ -427,7 +431,7 @@ const _createTask = (name, msg, context, taskOpts) => {
427
431
  }
428
432
  const taskMsg = {
429
433
  ID: cds.utils.uuid(),
430
- target: name,
434
+ target: _targetName(name, taskOpts),
431
435
  timestamp: _get100NanosecondTimestampISOString(msg.queue?.after), // needs to be different for each emit
432
436
  msg: JSON.stringify(_msg)
433
437
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sap/cds",
3
- "version": "9.0.3",
3
+ "version": "9.1.0",
4
4
  "description": "SAP Cloud Application Programming Model - CDS for Node.js",
5
5
  "homepage": "https://cap.cloud.sap/",
6
6
  "keywords": [