From 8ade8fff539c74d79bce3ca921f1e167f5ac1a6c Mon Sep 17 00:00:00 2001 From: Roshni Naveena S Date: Mon, 20 Jan 2025 14:35:35 +0530 Subject: [PATCH 1/7] adding namespace --- index.cds | 1 + 1 file changed, 1 insertion(+) diff --git a/index.cds b/index.cds index 05888092..a08eedba 100644 --- a/index.cds +++ b/index.cds @@ -1,4 +1,5 @@ using { managed, cuid } from '@sap/cds/common'; +namespace sap.changelog; aspect MediaData @(_is_media_data) { url : String; From 25d25435a5bae54eba5e5e41db54c6b632a0619d Mon Sep 17 00:00:00 2001 From: Roshni Naveena S Date: Mon, 20 Jan 2025 14:53:42 +0530 Subject: [PATCH 2/7] Update index.cds --- index.cds | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.cds b/index.cds index a08eedba..1e644203 100644 --- a/index.cds +++ b/index.cds @@ -1,5 +1,5 @@ using { managed, cuid } from '@sap/cds/common'; -namespace sap.changelog; +namespace sap.attachments; aspect MediaData @(_is_media_data) { url : String; From c272266450e3b913fe738f9c25e5d25a1454733c Mon Sep 17 00:00:00 2001 From: Ram Prasad GS Date: Thu, 23 Jan 2025 11:19:22 +0530 Subject: [PATCH 3/7] namespace changes in the plugin --- lib/plugin.js | 3 ++- xmpl/db/attachments.cds | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/plugin.js b/lib/plugin.js index c19d0494..ea3ac2e4 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,6 +23,7 @@ cds.on("loaded", function unfoldModel(csn) { }); cds.once("served", async function registerPluginHandlers() { +if (!("sap.attachments.Attachments" in cds.model.definitions)) return; if (!("Attachments" in cds.model.definitions)) return; const AttachmentsSrv = await cds.connect.to("attachments"); 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; From c8a005dc3382a2f7e5182d28b9bbc4b7c7a0ed47 Mon Sep 17 00:00:00 2001 From: Ram Prasad GS Date: Thu, 23 Jan 2025 11:21:37 +0530 Subject: [PATCH 4/7] adding readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 { // ... From de7bf9fe38db109255c6b541786c10dcb3f7b3fe Mon Sep 17 00:00:00 2001 From: Roshni Naveena S Date: Tue, 28 Jan 2025 20:00:39 +0530 Subject: [PATCH 5/7] Update attachments.cds --- tests/incidents-app/db/attachments.cds | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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; From 1a3f52eb9d5d200d56fd601761e6aa10028fad14 Mon Sep 17 00:00:00 2001 From: Roshni Naveena S Date: Tue, 11 Feb 2025 22:20:10 +0530 Subject: [PATCH 6/7] minor correction --- lib/plugin.js | 4 +--- tests/integration/attachments.test.js | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/plugin.js b/lib/plugin.js index ea3ac2e4..12a8aa13 100644 --- a/lib/plugin.js +++ b/lib/plugin.js @@ -23,9 +23,7 @@ cds.on("loaded", function unfoldModel(csn) { }); cds.once("served", async function registerPluginHandlers() { -if (!("sap.attachments.Attachments" in cds.model.definitions)) return; - 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/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( From ac506c5ec638a9546a3edb953e73440fe7a1fd91 Mon Sep 17 00:00:00 2001 From: Roshni Naveena S Date: Tue, 11 Feb 2025 22:23:56 +0530 Subject: [PATCH 7/7] Update CHANGELOG.md --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) 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