@cap-js/audit-logging 0.5.0 → 0.5.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,12 @@ All notable changes to this project will be documented in this file.
4
4
  This project adheres to [Semantic Versioning](http://semver.org/).
5
5
  The format is based on [Keep a Changelog](http://keepachangelog.com/).
6
6
 
7
+ ## Version 0.5.1 - 2023-11-30
8
+
9
+ ### Fixed
10
+
11
+ - Falsy early exit during bootstrapping in case a service does not contain personal data
12
+
7
13
  ## Version 0.5.0 - 2023-11-22
8
14
 
9
15
  ### Added
package/cds-plugin.js CHANGED
@@ -17,7 +17,7 @@ cds.on('served', services => {
17
17
 
18
18
  const relevantEntities = []
19
19
  for (const entity of service.entities) if (hasPersonalData(entity)) relevantEntities.push(entity)
20
- if (!relevantEntities.length) return
20
+ if (!relevantEntities.length) continue
21
21
 
22
22
  for (const entity of relevantEntities) {
23
23
  /*
@@ -17,6 +17,29 @@ const {
17
17
 
18
18
  let audit
19
19
 
20
+ const _applyTransitionRecursively = (transition, data, d) => {
21
+ for (const [k, v] of transition.mapping) {
22
+ if (v.transition) {
23
+ if (Array.isArray(data[k])) {
24
+ d[k] = []
25
+ for (let i = 0; i < data[k].length; i++) {
26
+ d[k].push({ _op: data[k][i]._op })
27
+ if (data[k][i]._old) d[k][i]._old = {}
28
+ _applyTransitionRecursively(v.transition, data[k][i], d[k][i])
29
+ }
30
+ } else {
31
+ d[k] = { _op: data[k]._op }
32
+ if (data[k]._old) d[k]._old = {}
33
+ _applyTransitionRecursively(v.transition, data[k], d[k])
34
+ }
35
+ continue
36
+ } else if (v.ref) {
37
+ if (v.ref[0] in data) d[k] = data[v.ref[0]]
38
+ if (data._old && v.ref[0] in data._old) d._old[k] = data._old[v.ref[0]]
39
+ }
40
+ }
41
+ }
42
+
20
43
  // REVISIT: remove once old database impl is removed
21
44
  const _getDataWithAppliedTransitions = (data, req) => {
22
45
  let d
@@ -26,10 +49,7 @@ const _getDataWithAppliedTransitions = (data, req) => {
26
49
  if (transition) {
27
50
  d = { _op: data._op }
28
51
  if (data._old) d._old = {}
29
- for (const [k, v] of transition.mapping) {
30
- if (v.ref[0] in data) d[k] = data[v.ref[0]]
31
- if (data._old && v.ref[0] in data._old) d._old[k] = data._old[v.ref[0]]
32
- }
52
+ _applyTransitionRecursively(transition, data, d)
33
53
  }
34
54
  return d || data
35
55
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cap-js/audit-logging",
3
- "version": "0.5.0",
3
+ "version": "0.5.1",
4
4
  "description": "CDS plugin providing integration to the SAP Audit Log service as well as out-of-the-box personal data-related audit logging based on annotations.",
5
5
  "repository": "cap-js/audit-logging",
6
6
  "author": "SAP SE (https://www.sap.com)",