Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
name: CI
permissions:
contents: read

on:
workflow_dispatch:
Expand All @@ -20,7 +22,7 @@ jobs:
fail-fast: false
matrix:
node-version: [22.x, 20.x]
cds-version: [8]
cds-version: [9, 8]
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
Expand All @@ -29,7 +31,7 @@ jobs:
node-version: ${{ matrix.node-version }}
- run: npm i -g @sap/cds-dk@${{ matrix.cds-version }}
- run: npm i
- run: npm i @sap/cds@${{ matrix.cds-version }}
- run: if [ ${{ matrix.cds-version }} -eq 8 ]; then npm i -f @sap/cds@8 @cap-js/sqlite@1; fi
- run: cds v
- run: npm run test
env:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
node-version: 20
registry-url: https://registry.npmjs.org/
- name: run tests
run: |
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# macOS
.DS_Store

# Logs
logs
*.log
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,16 @@ All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).
The format is based on [Keep a Changelog](http://keepachangelog.com/).

## Version 0.9.0 - 2025-06-05

### Added

- Support for `@sap/cds^9`

## Version 0.8.3 - 2025-04-09

### Fixed

- Preperation for `@sap/cds^9`

## Version 0.8.2 - 2024-11-27
Expand Down
3 changes: 2 additions & 1 deletion lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@ const _buildSubSelect = (model, { entity, relative, element, next }, row, previo
const targetAlias = _alias(element._target)
const relativeAlias = _alias(relative)

if (!('_relations' in relative)) {
// REVISIT: there seems to be a caching issue in cds^9 when elemets are renamed
if (!('_relations' in relative) || !relative._relations[element.name]) {
const newRelation = Relation.to(relative)
relative._relations = new Proxy(exposeRelation(newRelation), relationHandler(newRelation))
}
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cap-js/audit-logging",
"version": "0.8.3",
"version": "0.9.0",
"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.",
"repository": "cap-js/audit-logging",
"author": "SAP SE (https://www.sap.com)",
Expand All @@ -21,6 +21,7 @@
},
"devDependencies": {
"@cap-js/audit-logging": "file:.",
"@cap-js/cds-test": ">=0",
"@cap-js/sqlite": ">=1",
"axios": "^1",
"eslint": "^9",
Expand Down
2 changes: 1 addition & 1 deletion test/api/api.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ axios.defaults.validateStatus = () => true
cds.env.requires['audit-log'] = {
kind: 'audit-log-to-console',
impl: '../../srv/log2console',
outbox: true
outbox: { kind: 'in-memory-outbox' }
}

const wait = require('node:timers/promises').setTimeout
Expand Down
25 changes: 19 additions & 6 deletions test/personal-data/crud.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -863,6 +863,13 @@ describe('personal data audit logging in CRUD', () => {
}
}

// REVISIT: cds^9 does not replace unmentioned assocs with empty arrays
if (cds.version.split('.')[0] >= 9) {
customer.addresses[0].attachments = []
customer.addresses[1].attachments = []
customer.status.notes = []
}

response = await PATCH(`/crud-1/Customers(${CUSTOMER_ID})`, customer, { auth: ALICE })
expect(response).toMatchObject({ status: 200 })

Expand Down Expand Up @@ -1054,10 +1061,16 @@ describe('personal data audit logging in CRUD', () => {
id: { ID: oldAttachments[1].ID }
},
data_subject: DATA_SUBJECT,
attributes: [
{ name: 'description', old: '***' },
{ name: 'todo', old: oldAttachments[1].todo }
]
attributes:
cds.version.split('.')[0] < 9
? [
{ name: 'description', old: '***' },
{ name: 'todo', old: oldAttachments[1].todo }
]
: [
{ name: 'description', old: '***' }
// REVISIT: entry for "todo" missing in cds^9
]
})
expect(_logs).toContainMatchObject({
user: 'alice',
Expand Down Expand Up @@ -1814,8 +1827,8 @@ describe('personal data audit logging in CRUD', () => {
test('do not log values of sensitive data', async () => {
await POST(`/crud-1/Employees`, { notes: ['bar', 'baz'] }, { auth: ALICE })
expect(_logs.length).toBe(2)
expect(_logs[0].attributes).toEqual([{ name: 'notes', new: '***' }])
expect(_logs[1].attributes).toEqual([{ name: 'notes' }])
expect(_logs).toContainMatchObject({ attributes: [{ name: 'notes', new: '***' }] })
expect(_logs).toContainMatchObject({ attributes: [{ name: 'notes' }] })
})
})

Expand Down
6 changes: 6 additions & 0 deletions test/personal-data/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
{
"dependencies": {
"@cap-js/audit-logging": "*"
},
"cds": {
"runtime": {
"patch_as_upsert": true,
"_put_as_replace": true
}
}
}