From 71961e472d1688894cfd6a025a9dc866c303dea6 Mon Sep 17 00:00:00 2001 From: "Dr. David A. Kunz" Date: Thu, 25 Jan 2024 10:56:04 +0100 Subject: [PATCH 1/4] fix: support for cds 7.5.0 --- srv/service.js | 1 + 1 file changed, 1 insertion(+) diff --git a/srv/service.js b/srv/service.js index bbffd82..5d17ea9 100644 --- a/srv/service.js +++ b/srv/service.js @@ -22,6 +22,7 @@ module.exports = class AuditLogService extends Base { this.log = this.emit // NOTE: logSync is not a public API! this.logSync = (...args) => { + if (cds.unboxed) return cds.unboxed(this).send(...args) // for cds >= 7.5.0 if (outboxed) return this.immediate.send(...args) return this.send(...args) } From 0418be5b955d9375c25c29dc3a24b45351ccdd40 Mon Sep 17 00:00:00 2001 From: sjvans <30337871+sjvans@users.noreply.github.com> Date: Tue, 30 Jan 2024 15:22:12 +0100 Subject: [PATCH 2/4] use the not-outboxed service regardless of @sap/cds version (#79) --- srv/service.js | 8 +++----- test/api/srv/api-service.js | 5 ++--- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/srv/service.js b/srv/service.js index 5d17ea9..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,9 +20,9 @@ module.exports = class AuditLogService extends Base { this.log = this.emit // NOTE: logSync is not a public API! this.logSync = (...args) => { - if (cds.unboxed) return cds.unboxed(this).send(...args) // for cds >= 7.5.0 - 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 () { From f6896201f1e5e6c9e34295a49c587fb0347a3856 Mon Sep 17 00:00:00 2001 From: sjvans <30337871+sjvans@users.noreply.github.com> Date: Tue, 30 Jan 2024 15:23:27 +0100 Subject: [PATCH 3/4] Update CHANGELOG.md --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) 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 From 35062ba2983336c26647f96f8753ca66625ebbb7 Mon Sep 17 00:00:00 2001 From: sjvans <30337871+sjvans@users.noreply.github.com> Date: Tue, 30 Jan 2024 15:23:42 +0100 Subject: [PATCH 4/4] Update package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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)",