Hello SAP Community!
I’m happy to introduce you to the sap-cap-sdm-plugin
, a plugin designed to streamline the integration between CAP (Node.js) and DMS (Document Management Service).
This idea came when I stumbled upon Daniel’s blog post about cds.plugins
. In his example, Daniel creates a custom annotation that appends an emoji to the end of the text for properties that are annotated with it. Although simplistic, his example gave me some ideas.
Before developing sap-cap-sdm-plugin
, I conceived the sap-cloud-cmis-client
library, aiming to streamline the integration between CAP/cloud-sdk projects and DMS on Cloud Foundry. Although useful, it fell short of providing a truly effortless experience for developers, which prompted me to explore this relatively new possibility.
The main goal was clear: Provide a tool where developers could integrate their CAP projects with SAP DMS by just annotating their entities using @Sdm.Entity
and @Sdm.Field
, while the plugin would handles the technical details in the background.
After addressing numerous questions, reviewing extensive documentation, and investing some hours, sap-cap-sdm-plugin
came into existence.
Here’s a step-by-step guide:
npm i sap-cap-sdm-plugin
Add it to the `cds.requires` section of your package.json.
"cds": {
"requires": {
"sap-cap-sdm-plugin": {
"impl": "sap-cap-sdm-plugin",
"settings": {
"destination": "<YOUR_SDM_DESTINATION_NAME>",
"repositoryId": "<YOUR_REPOSITORY_ID>" // Optional. Remove if you have only one repository.
}
}
}
}
You have to specify the destination
related to the DMS service. If you have multiple repositories, you can optionally specify the repositoryId
you want to use.
Since it’s CAP, you can also set specific configurations for different profiles.
"cds": {
"requires": {
"sap-cap-sdm-plugin": {
"impl": "sap-cap-sdm-plugin",
"[development]": { // development profile
"settings": {
"destination": "<YOUR_SDM_DESTINATION_NAME>",
"repositoryId": "123"
}
},
"[production]": { // production profile
"settings": {
"destination": "<YOUR_SDM_DESTINATION_NAME>",
"repositoryId": "456"
}
}
}
}
}
Create an entity that should be “linked” to the DMS, using the right annotations.
service SampleService {
@cds.persistence.skip
@Sdm.Entity
entity Files {
key id : String @Sdm.Field : { type : 'property', path : 'cmis:objectId' };
name : String @Sdm.Field : { type : 'property', path : 'cmis:name' };
content : LargeBinary @Core.MediaType : contentType @Core.ContentDisposition.Filename : name;
contentType : String @Core.IsMediaType
@Sdm.Field : { type : 'property', path : 'cmis:contentStreamMimeType' };
createdBy : String @Sdm.Field : { type : 'property', path : 'cmis:createdBy' };
creationDate : Date @Sdm.Field : { type : 'property', path : 'cmis:creationDate' };
}
}
With this setup, you can perform basic CRUD operations directly on DMS, using this OData Entity as a “proxy”.
For additional functionalities, you may refer to examples provided in the example folder.
While sap-cap-sdm-plugin
is efficient for a majority of scenarios, it has its limitations, like not supporting versioned repositories, thumbnail generation, among others. I’m on it and looking forward to enhancing its capabilities. Your feedback is invaluable, so don’t hesitate to share your thoughts or seek assistance on GitHub.
Hope you like it 🙂
Vinícius Barrionuevo