@sap/cds 9.6.0 → 9.6.1
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,13 @@
|
|
|
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 9.6.1 - 2025-12-18
|
|
8
|
+
|
|
9
|
+
### Fixed
|
|
10
|
+
|
|
11
|
+
- Status check in case of non-existing subject
|
|
12
|
+
- Gracefully handle bad value when calculating `@Core.OperationAvailable` from `@from`
|
|
13
|
+
|
|
7
14
|
## Version 9.6.0 - 2025-12-16
|
|
8
15
|
|
|
9
16
|
### Added
|
package/lib/compile/for/flows.js
CHANGED
|
@@ -13,12 +13,18 @@ const getFrom = action => {
|
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
function addOperationAvailableToActions(actions, statusEnum, statusElementName) {
|
|
16
|
-
for (const action of Object.values(actions)) {
|
|
16
|
+
action: for (const action of Object.values(actions)) {
|
|
17
17
|
const fromList = getFrom(action)
|
|
18
|
-
const conditions =
|
|
18
|
+
const conditions = []
|
|
19
|
+
for (const from of fromList) {
|
|
19
20
|
const value = from['#'] ? statusEnum[from['#']]?.val ?? from['#'] : from
|
|
20
|
-
|
|
21
|
-
|
|
21
|
+
if (typeof value !== 'string') {
|
|
22
|
+
const msg = `Error while constructing @Core.OperationAvailable for action "${action.name}" of "${action.parent.name}". Value of @from must either be an enum symbol or a raw string.`
|
|
23
|
+
cds.log('cds|edmx').warn(msg)
|
|
24
|
+
continue action
|
|
25
|
+
}
|
|
26
|
+
conditions.push(`$self.${statusElementName} = '${value}'`)
|
|
27
|
+
}
|
|
22
28
|
const condition = `(${conditions.join(' OR ')})`
|
|
23
29
|
const parsedXpr = cds.parse.expr(condition)
|
|
24
30
|
action['@Core.OperationAvailable'] ??= {
|
|
@@ -74,7 +80,7 @@ function addActionsToTarget(targetAnnotation, entity, actions) {
|
|
|
74
80
|
identification.push({
|
|
75
81
|
$Type: 'UI.DataFieldForAction',
|
|
76
82
|
Action: `${entity._service.name}.${actionName}`,
|
|
77
|
-
Label: action[
|
|
83
|
+
Label: action['@Common.Label'] ?? action['@title'] ?? `{i18n>${actionName}}`,
|
|
78
84
|
...(entity['@odata.draft.enabled'] && {
|
|
79
85
|
'@UI.Hidden': {
|
|
80
86
|
'=': true,
|
|
@@ -9,24 +9,20 @@ const FLOW_PREVIOUS = '$flow.previous'
|
|
|
9
9
|
|
|
10
10
|
const $transitions_ = Symbol.for('transitions_')
|
|
11
11
|
|
|
12
|
-
function
|
|
12
|
+
function isCurrentStatusInFrom(result, action, statusElementName, statusEnum) {
|
|
13
13
|
const fromList = getFrom(action)
|
|
14
|
-
const
|
|
14
|
+
const allowed = fromList.filter(from => {
|
|
15
15
|
const value = from['#'] ? (statusEnum[from['#']]?.val ?? statusEnum[from['#']]['$path'].at(-1)) : from
|
|
16
|
-
return
|
|
16
|
+
return result[statusElementName] === value
|
|
17
17
|
})
|
|
18
|
-
return
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
async function isCurrentStatusInFrom(subject, action, statusElementName, statusEnum) {
|
|
22
|
-
const cond = buildAllowedCondition(action, statusElementName, statusEnum)
|
|
23
|
-
const parsedXpr = cds.parse.expr(cond)
|
|
24
|
-
const dbEntity = await SELECT.one.from(subject).where(parsedXpr)
|
|
25
|
-
return dbEntity !== undefined
|
|
18
|
+
return allowed.length
|
|
26
19
|
}
|
|
27
20
|
|
|
28
21
|
async function checkStatus(subject, action, statusElementName, statusEnum) {
|
|
29
|
-
const
|
|
22
|
+
const result = await SELECT.one.from(subject)
|
|
23
|
+
if (!result) cds.error(404)
|
|
24
|
+
|
|
25
|
+
const allowed = isCurrentStatusInFrom(result, action, statusElementName, statusEnum)
|
|
30
26
|
if (!allowed) {
|
|
31
27
|
const from = getFrom(action)
|
|
32
28
|
const fromValues = JSON.stringify(from.flatMap(el => Object.values(el)))
|