@sap/cds 6.2.2 → 6.2.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,20 @@
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 6.2.4 - 2022-11-04
8
+
9
+ ### Fixed
10
+
11
+ - Draft ownership was erroneously checked for bound actions on active instances
12
+
13
+ ## Version 6.2.3 - 2022-10-21
14
+
15
+ ### Fixed
16
+
17
+ - New continuation for incoming messages
18
+ - `cds.test` no longer fails if used in ESM modules with `mocha` (`ERR_REQUIRE_ESM` error)
19
+ - Collection-bound actions/functions don't need draft ownership check
20
+
7
21
  ## Version 6.2.2 - 2022-10-13
8
22
 
9
23
  ### Fixed
package/lib/index.js CHANGED
@@ -138,7 +138,8 @@ _global ('parse','CDL','CQL','CXL')
138
138
  // Check Node.js version
139
139
  if (process.env.CDS_STRICT_NODE_VERSION !== 'false') {
140
140
  const v = version => { let vv = version.split('.'); return { version, major: +vv[0], minor: +vv[1] }}
141
- const required = v('14.15'), given = v(process.version.match(/^v(\d+\.\d+)/)[1])
141
+ const required = v(_require('../package.json').engines.node.match(/>=(.*)/)[1])
142
+ const given = v(process.version.match(/^v(\d+\.\d+)/)[1])
142
143
  if (given.major < required.major || given.major === required.major && given.minor < required.minor) process.exit (process.stderr.write (`
143
144
  Node.js v${required.version} or higher is required for @sap/cds.
144
145
  Current v${given.version} does not satisfy this.
@@ -136,7 +136,7 @@ exports.find = function find (base, patterns='*', filter=()=>true) {
136
136
 
137
137
  // internal utility to load a file through ESM or CommonJs. TODO find a better place.
138
138
  exports._import = id => require(id)
139
- if (!global.test && !global.it) {
139
+ if (typeof jest === 'undefined') { // jest's ESM support is experimental: https://jestjs.io/docs/ecmascript-modules
140
140
  const { pathToFileURL } = require('url')
141
141
  exports._import = id => {
142
142
  if (extname(id) === '.ts') return require(id) // ts-node w/ ESM not working (cap/issues#11980)
@@ -77,7 +77,7 @@ const _getRoot = req => {
77
77
  return root
78
78
  }
79
79
 
80
- const _getDraftDataFromExistingDraft = async (req, root) => {
80
+ const _getDraftDataFromExistingDraft = async (req, root, isBoundAction) => {
81
81
  if (!root) return []
82
82
  if (root?.IsActiveEntity === false) {
83
83
  const query = _getSelectDraftDataCqn(root.entityName, root.where)
@@ -85,6 +85,9 @@ const _getDraftDataFromExistingDraft = async (req, root) => {
85
85
  return result
86
86
  }
87
87
 
88
+ // do not expect validate draft ownership for action call on active instances
89
+ if (isBoundAction) return []
90
+
88
91
  const rootWhere = getKeysCondition(req)
89
92
  const query = _getSelectDraftDataCqn(ensureNoDraftsSuffix(req.target.name), rootWhere)
90
93
  const result = await cds.tx(req).run(query)
@@ -147,8 +150,8 @@ const _deleteCancel = async function (req) {
147
150
  }
148
151
 
149
152
  const _validateDraftBoundAction = async function (req) {
150
- const result = await _getDraftDataFromExistingDraft(req, _getRoot(req))
151
153
  const isBoundAction = true
154
+ const result = await _getDraftDataFromExistingDraft(req, _getRoot(req), isBoundAction)
152
155
  if (result && result.length > 0) _validateDraft(req, result, isBoundAction)
153
156
  }
154
157
 
@@ -160,7 +163,8 @@ const _registerBoundActionHandlers = function (entityName, actions) {
160
163
  action.kind === 'action' &&
161
164
  action.name !== 'draftPrepare' &&
162
165
  action.name !== 'draftEdit' &&
163
- action.name !== 'draftActivate'
166
+ action.name !== 'draftActivate' &&
167
+ !action['@cds.odata.bindingparameter.collection']
164
168
  )
165
169
 
166
170
  for (const action of boundActions) {
@@ -81,11 +81,14 @@ class MessagingService extends OutboxService {
81
81
  const _msg = typeof event === 'object' ? event : { event, data, headers }
82
82
  if (_msg instanceof cds.Event) return super.emit(_msg)
83
83
  if (_msg.inbound && !cds.context) {
84
- cds.context = { tenant: _msg.tenant, user: cds.User.privileged }
85
- if (cds.model) {
86
- const ctx = cds.context
87
- ctx.model = await ExtendedModels.model4(ctx.tenant, ctx.features)
88
- }
84
+ return cds._context.run({ tenant: _msg.tenant, user: cds.User.privileged }, async () => {
85
+ if (cds.model) {
86
+ const ctx = cds.context
87
+ ctx.model = await ExtendedModels.model4(ctx.tenant, ctx.features)
88
+ }
89
+ const msg = new cds.Event(this.message4(_msg))
90
+ return super.emit(msg)
91
+ })
89
92
  }
90
93
  const msg = new cds.Event(this.message4(_msg))
91
94
  return super.emit(msg)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sap/cds",
3
- "version": "6.2.2",
3
+ "version": "6.2.4",
4
4
  "description": "SAP Cloud Application Programming Model - CDS for Node.js",
5
5
  "homepage": "https://cap.cloud.sap/",
6
6
  "keywords": [
@@ -27,7 +27,7 @@
27
27
  "LICENSE"
28
28
  ],
29
29
  "engines": {
30
- "node": ">=14.15.0"
30
+ "node": ">=14.18.0"
31
31
  },
32
32
  "dependencies": {
33
33
  "@sap/cds-compiler": "^3.2.0",