@sap/cds 9.0.4 → 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.
@@ -49,6 +49,8 @@ const _safeJSONParse = string => {
49
49
  }
50
50
  }
51
51
 
52
+ const _targetName = (name, opts) => (opts.targetPrefix ? opts.targetPrefix + name : name)
53
+
52
54
  // Note: This function can also run for each tenant on startup
53
55
  //
54
56
  // tx1: Fetch messages which are not in process and are not locked (SELECT FOR UPDATE)
@@ -95,7 +97,7 @@ const processTasks = (service, tenant, _opts = {}) => {
95
97
  }
96
98
 
97
99
  const tasksQuery = SELECT.from(tasksEntity)
98
- .where({ target: name })
100
+ .where({ target: _targetName(name, opts) })
99
101
  .orderBy(opts.parallel ? ['status', 'timestamp', 'ID'] : ['timestamp', 'status', 'ID'])
100
102
  .limit(opts.chunkSize)
101
103
  .forUpdate()
@@ -294,6 +296,7 @@ const processTasks = (service, tenant, _opts = {}) => {
294
296
  const _newMsgFrom = msg => {
295
297
  const _fromSend = msg instanceof cds.Request
296
298
  const newMsg = { ...msg }
299
+ if (msg.entity) newMsg.entity = msg.entity // needed for proper `h.for(msg)` handling
297
300
  newMsg._fromSend = _fromSend
298
301
  if (!newMsg.queue) return newMsg
299
302
  if (!newMsg.queue.after && !newMsg.queue.every) return newMsg
@@ -428,7 +431,7 @@ const _createTask = (name, msg, context, taskOpts) => {
428
431
  }
429
432
  const taskMsg = {
430
433
  ID: cds.utils.uuid(),
431
- target: name,
434
+ target: _targetName(name, taskOpts),
432
435
  timestamp: _get100NanosecondTimestampISOString(msg.queue?.after), // needs to be different for each emit
433
436
  msg: JSON.stringify(_msg)
434
437
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sap/cds",
3
- "version": "9.0.4",
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": [