diff --git a/CHANGELOG.md b/CHANGELOG.md index 5928dce..804dd01 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ 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.6.0 - tbd + +### Added + +- Support for @sap/cds^7.5 + ## Version 0.5.2 - 2023-12-08 ### Fixed diff --git a/package.json b/package.json index 4a514c9..e1d6d14 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@cap-js/audit-logging", - "version": "0.5.2", + "version": "0.6.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)", diff --git a/srv/service.js b/srv/service.js index bbffd82..9176be7 100644 --- a/srv/service.js +++ b/srv/service.js @@ -4,8 +4,6 @@ const Base = cds.outboxed ? cds.Service : require('@sap/cds/libx/_runtime/messag module.exports = class AuditLogService extends Base { async init() { - const outboxed = this.immediate instanceof cds.Service - // add common audit log entry fields this.before('*', req => { const { tenant, user, timestamp } = cds.context @@ -22,8 +20,9 @@ module.exports = class AuditLogService extends Base { this.log = this.emit // NOTE: logSync is not a public API! this.logSync = (...args) => { - if (outboxed) return this.immediate.send(...args) - return this.send(...args) + if (cds.unboxed) return cds.unboxed(this).send(...args) //> cds >= 7.5 + if (this.immediate instanceof cds.Service) return this.immediate.send(...args) //> cds ~ 7.4 + return this.send(...args) //> cds <= 7.3 } } } diff --git a/test/api/srv/api-service.js b/test/api/srv/api-service.js index 14a2cb4..d9a11f7 100644 --- a/test/api/srv/api-service.js +++ b/test/api/srv/api-service.js @@ -1,14 +1,13 @@ module.exports = async function () { const audit = await cds.connect.to('audit-log') - const outboxed = audit.immediate instanceof cds.Service this.on('testEmit', async function () { await audit.emit('foo', { bar: 'baz' }) }) this.on('testSend', async function () { - if (outboxed) await audit.immediate.send('foo', { bar: 'baz' }) - else await audit.send('foo', { bar: 'baz' }) + // only works with cds^7.5, but we don't execute the tests with prior cds versions + await cds.unboxed(audit).send('foo', { bar: 'baz' }) }) this.on('testLog', async function () {