Skip to content

Commit b25a3b5

Browse files
authored
chore: housekeeping re cds^9 + prep v0.9.0 (#148)
- [x] make 9 jobs required for merge
1 parent 1692cfa commit b25a3b5

File tree

9 files changed

+46
-12
lines changed

9 files changed

+46
-12
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
name: CI
2+
permissions:
3+
contents: read
24

35
on:
46
workflow_dispatch:
@@ -20,7 +22,7 @@ jobs:
2022
fail-fast: false
2123
matrix:
2224
node-version: [22.x, 20.x]
23-
cds-version: [8]
25+
cds-version: [9, 8]
2426
steps:
2527
- uses: actions/checkout@v2
2628
- name: Use Node.js ${{ matrix.node-version }}
@@ -29,7 +31,7 @@ jobs:
2931
node-version: ${{ matrix.node-version }}
3032
- run: npm i -g @sap/cds-dk@${{ matrix.cds-version }}
3133
- run: npm i
32-
- run: npm i @sap/cds@${{ matrix.cds-version }}
34+
- run: if [ ${{ matrix.cds-version }} -eq 8 ]; then npm i -f @sap/cds@8 @cap-js/sqlite@1; fi
3335
- run: cds v
3436
- run: npm run test
3537
env:

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
- uses: actions/checkout@v3
1515
- uses: actions/setup-node@v3
1616
with:
17-
node-version: 18
17+
node-version: 20
1818
registry-url: https://registry.npmjs.org/
1919
- name: run tests
2020
run: |

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# macOS
2+
.DS_Store
3+
14
# Logs
25
logs
36
*.log

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,16 @@ All notable changes to this project will be documented in this file.
44
This project adheres to [Semantic Versioning](http://semver.org/).
55
The format is based on [Keep a Changelog](http://keepachangelog.com/).
66

7+
## Version 0.9.0 - 2025-06-05
8+
9+
### Added
10+
11+
- Support for `@sap/cds^9`
12+
713
## Version 0.8.3 - 2025-04-09
814

15+
### Fixed
16+
917
- Preperation for `@sap/cds^9`
1018

1119
## Version 0.8.2 - 2024-11-27

lib/utils.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,8 @@ const _buildSubSelect = (model, { entity, relative, element, next }, row, previo
123123
const targetAlias = _alias(element._target)
124124
const relativeAlias = _alias(relative)
125125

126-
if (!('_relations' in relative)) {
126+
// REVISIT: there seems to be a caching issue in cds^9 when elemets are renamed
127+
if (!('_relations' in relative) || !relative._relations[element.name]) {
127128
const newRelation = Relation.to(relative)
128129
relative._relations = new Proxy(exposeRelation(newRelation), relationHandler(newRelation))
129130
}

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@cap-js/audit-logging",
3-
"version": "0.8.3",
3+
"version": "0.9.0",
44
"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.",
55
"repository": "cap-js/audit-logging",
66
"author": "SAP SE (https://www.sap.com)",
@@ -21,6 +21,7 @@
2121
},
2222
"devDependencies": {
2323
"@cap-js/audit-logging": "file:.",
24+
"@cap-js/cds-test": ">=0",
2425
"@cap-js/sqlite": ">=1",
2526
"axios": "^1",
2627
"eslint": "^9",

test/api/api.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ axios.defaults.validateStatus = () => true
88
cds.env.requires['audit-log'] = {
99
kind: 'audit-log-to-console',
1010
impl: '../../srv/log2console',
11-
outbox: true
11+
outbox: { kind: 'in-memory-outbox' }
1212
}
1313

1414
const wait = require('node:timers/promises').setTimeout

test/personal-data/crud.test.js

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -863,6 +863,13 @@ describe('personal data audit logging in CRUD', () => {
863863
}
864864
}
865865

866+
// REVISIT: cds^9 does not replace unmentioned assocs with empty arrays
867+
if (cds.version.split('.')[0] >= 9) {
868+
customer.addresses[0].attachments = []
869+
customer.addresses[1].attachments = []
870+
customer.status.notes = []
871+
}
872+
866873
response = await PATCH(`/crud-1/Customers(${CUSTOMER_ID})`, customer, { auth: ALICE })
867874
expect(response).toMatchObject({ status: 200 })
868875

@@ -1054,10 +1061,16 @@ describe('personal data audit logging in CRUD', () => {
10541061
id: { ID: oldAttachments[1].ID }
10551062
},
10561063
data_subject: DATA_SUBJECT,
1057-
attributes: [
1058-
{ name: 'description', old: '***' },
1059-
{ name: 'todo', old: oldAttachments[1].todo }
1060-
]
1064+
attributes:
1065+
cds.version.split('.')[0] < 9
1066+
? [
1067+
{ name: 'description', old: '***' },
1068+
{ name: 'todo', old: oldAttachments[1].todo }
1069+
]
1070+
: [
1071+
{ name: 'description', old: '***' }
1072+
// REVISIT: entry for "todo" missing in cds^9
1073+
]
10611074
})
10621075
expect(_logs).toContainMatchObject({
10631076
user: 'alice',
@@ -1814,8 +1827,8 @@ describe('personal data audit logging in CRUD', () => {
18141827
test('do not log values of sensitive data', async () => {
18151828
await POST(`/crud-1/Employees`, { notes: ['bar', 'baz'] }, { auth: ALICE })
18161829
expect(_logs.length).toBe(2)
1817-
expect(_logs[0].attributes).toEqual([{ name: 'notes', new: '***' }])
1818-
expect(_logs[1].attributes).toEqual([{ name: 'notes' }])
1830+
expect(_logs).toContainMatchObject({ attributes: [{ name: 'notes', new: '***' }] })
1831+
expect(_logs).toContainMatchObject({ attributes: [{ name: 'notes' }] })
18191832
})
18201833
})
18211834

test/personal-data/package.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
{
22
"dependencies": {
33
"@cap-js/audit-logging": "*"
4+
},
5+
"cds": {
6+
"runtime": {
7+
"patch_as_upsert": true,
8+
"_put_as_replace": true
9+
}
410
}
511
}

0 commit comments

Comments
 (0)