diff --git a/CHANGELOG.md b/CHANGELOG.md index 35e775e2..4c9816f8 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 1.1.10 + +### Changed + +- Usage while importing changed from `using { Attachments } from '@cap-js/attachments'` to `using { sap.attachments.Attachments } from '@cap-js/attachments'`. + ## Version 1.1.9 ### Added diff --git a/README.md b/README.md index 220bd1ba..b69f369c 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ In this guide, we use the [Incidents Management reference sample app](https://gi To use Attachments, simply add an element referring to the pre-defined `Attachments` type as follows: ```cds -using { Attachments } from '@cap-js/attachments'; +using { sap.attachments.Attachments } from '@cap-js/attachments'; entity Incidents { // ... diff --git a/index.cds b/index.cds index 77169e18..a8ffc0a0 100644 --- a/index.cds +++ b/index.cds @@ -1,4 +1,5 @@ using { managed, cuid } from '@sap/cds/common'; +namespace sap.attachments; aspect MediaData @(_is_media_data) { url : String; diff --git a/lib/plugin.js b/lib/plugin.js index c19d0494..12a8aa13 100644 --- a/lib/plugin.js +++ b/lib/plugin.js @@ -5,7 +5,7 @@ const DEBUG = LOG._debug ? LOG.debug : undefined; const attachmentIDRegex = /\/\w+\(.*ID=([0-9a-fA-F-]{36})/; cds.on("loaded", function unfoldModel(csn) { - if (!("Attachments" in csn.definitions)) return; + if (!("sap.attachments.Attachments" in csn.definitions)) return; const csnCopy = structuredClone(csn) cds.linked(csnCopy).forall("Composition", (comp) => { if (comp._target && comp._target["@_is_media_data"] && comp.parent && comp.is2many) { @@ -23,8 +23,7 @@ cds.on("loaded", function unfoldModel(csn) { }); cds.once("served", async function registerPluginHandlers() { - if (!("Attachments" in cds.model.definitions)) return; - + if (!("sap.attachments.Attachments" in cds.model.definitions)) return; const AttachmentsSrv = await cds.connect.to("attachments"); // Searching all associations to attachments to add respective handlers diff --git a/tests/incidents-app/db/attachments.cds b/tests/incidents-app/db/attachments.cds index f58acd59..68b203d7 100644 --- a/tests/incidents-app/db/attachments.cds +++ b/tests/incidents-app/db/attachments.cds @@ -1,6 +1,6 @@ using { sap.capire.incidents as my } from './schema'; -using { Attachments } from '@cap-js/attachments'; +using { sap.attachments.Attachments } from '@cap-js/attachments'; extend my.Incidents with { attachments: Composition of many Attachments; diff --git a/tests/integration/attachments.test.js b/tests/integration/attachments.test.js index e7216b4e..746febbf 100644 --- a/tests/integration/attachments.test.js +++ b/tests/integration/attachments.test.js @@ -72,7 +72,7 @@ describe("Tests for uploading/deleting attachments through API calls - in-memory } catch (err) { expect(err).to.be.undefined; } - +// api call, table name //read attachment in active table try { const response = await GET( diff --git a/xmpl/db/attachments.cds b/xmpl/db/attachments.cds index c2b281cb..f5c4418e 100644 --- a/xmpl/db/attachments.cds +++ b/xmpl/db/attachments.cds @@ -1,6 +1,6 @@ using { sap.capire.incidents as my } from '@capire/incidents/db/schema'; -using { Attachments } from '@cap-js/attachments'; +using { sap.attachments.Attachments } from '@cap-js/attachments'; extend my.Incidents with { attachments: Composition of many Attachments;