sap-cloud-cmis-client
TypeScript icon, indicating that this package has built-in type declarations

1.3.1 • Public • Published

A JavaScript CMIS Client for SAP Cloud SDK

sap-cloud-cmis-client is a specialized CMIS client designed for the SAP Cloud SDK (JavaScript) and CAP (NodeJS). It consolidates the SAP-provided OpenAPI specifications into one cohesive package. Additionally, I've baked in some developer-friendly utilities to streamline your integration process and enhance productivity.

📦 Installation

npm install sap-cloud-cmis-client

🚧 Prerequisites

To interface with the SAP Document Management Service, consider one of the two approaches below:

  1. Destination Setup: Bind your project to an instance of the Destination Service and establish a destination that targets the SDM service.
  2. SDM Direct Binding: Simply bind your project to an instance of the SDM Service.

In both approaches, destinations are used. The key difference is that for the second method, the destination is generated at runtime. More details here.

🛠️ Usage:

Before invoking any other methods, it's essential to call getRepositories. This ensures a connection to the instance and fetches all available repositories.

TypeScript

import { CmisClient } from 'sap-cloud-cmis-client';

const cmisClient = new CmisClient({ destinationName: 'YOUR_DESTINATION_NAME' });

// Load repositories
await cmisClient.getRepositories();

// Retrieve all descendants from the root folder
const descendants = await cmisClient.getDescendants();
console.log(descendants);

JavaScript

const { CmisClient } = require('sap-cloud-cmis-client');
const cmisClient = new CmisClient({ destinationName: 'YOUR_DESTINATION_NAME' });

// Load repositories
await cmisClient.getRepositories();

// Retrieve all descendants from the root folder
const descendants = await cmisClient.getDescendants();
console.log(descendants);

🚀 Examples

💡 Basic CRUD with Cloud Application Programming (CAP)

This example demonstrates basic Create, Read, Update, and Delete operations. It's a great starting point if you are wondering how to start.

Usage:

cd examples/cap-js/
npm install
cds serve

There are also some integration tests available in the /test directory.

API

I've chosen to split the API between the services specified by CMIS 1.1 that are available, and the helpers introduced by SAP to enhance the user experience with SAP DMS.

Table of Contents

  1. CMIS Services
  2. SAP DMS Helpers

CMIS Services

ACL

addAclProperty

Adds the given ACEs to the ACL of an object. CMIS 1.1 Reference

getACLProperty

Retrieves the current ACL applied to a specific object, optionally expressed using only CMIS-defined permissions. CMIS 1.1 Reference

removeAclProperty

Removes the given ACEs from the ACL of an object. CMIS 1.1 Reference

Discovery

cmisQuery

Executes a CMIS query statement against the contents of the repository. CMIS 1.1 Reference

Navigation

getChildren

Gets the list of child objects contained in the specified folder. CMIS 1.1 Reference

getDescendants

Gets the set of descendant objects contained in the specified folder or any of its child-folders. CMIS 1.1 Reference

getFolderTree

Gets the set of descendant folder objects contained in the specified folder. CMIS 1.1 Reference

getParent

Gets the parent folder(s) for the specified fileable object. CMIS 1.1 Reference

Object

appendContentStream

ApAppends to the content stream for the specified document object. CMIS 1.1 Reference

createDocument

Creates a document object of the specified type (given by the cmis:objectTypeId property) in the (optionally) specified location. CMIS 1.1 Reference

createDocumentFromSource

Creates a document object as a copy of the given source document in the (optionally) specified location. CMIS 1.1 Reference

createFolder

Creates a folder object of the specified type in the specified location. CMIS 1.1 Reference

deleteObject

Deletes the specified object. If the object is a PWC the checkout is discarded. CMIS 1.1 Reference

deleteTree

Deletes the specified folder object and all of its child- and descendant-objects. CMIS 1.1 Reference

getAllowableActions

Gets the list of allowable actions for an object. CMIS 1.1 Reference

getObject

Gets the specified information for the object. CMIS 1.1 Reference

getProperties

Gets the list of properties for the object. CMIS 1.1 Reference

moveObject

Moves the specified file-able object from one folder to another. CMIS 1.1 Reference

updateProperties

Updates properties and secondary types of the specified object. CMIS 1.1 Reference

Repository

createType

Creates a new type definition that is a subtype of an existing specified parent type. CMIS 1.1 Reference

getRepositories

Returns a list of CMIS repositories available from this CMIS service endpoint. CMIS 1.1 Reference

getRepositoryInfo

Returns information about the CMIS repository, the optional capabilities it supports and its access control information if applicable. CMIS 1.1 Reference

getTypeChildren

Returns the list of object-types defined for the repository that are children of the specified type. CMIS 1.1 Reference

getTypeDefinition

Gets the definition of the specified object-type. CMIS 1.1 Reference

getTypeDescendants

Returns the set of the descendant object-types defined for the Repository under the specified type. CMIS 1.1 Reference

Versioning

cancelCheckOut

Reverses the effect of a check-out. Removes the Private Working Copy of the checked-out document, allowing other documents in the version series to be checked out again. If the private working copy has been created by createDocument, cancelCheckOut will delete the created document. CMIS 1.1 Reference

checkIn

Checks-in the Private Working Copy document. CMIS 1.1 Reference

checkOut

Create a private working copy (PWC) of the document. CMIS 1.1 Reference

SAP DMS Helpers

createFavorite

Creates favorite link object for the specified object if favorites repository is configured. With this call, the server creates a user folder in favorites repositories, creates a sap:link file to the object and applies user ACL.

createShare

Creates a folder of sap:share type under the specified repository. Supported only by Collaboration enabled repositories.

downloadFile

Returns the requested document content directly or redirects to a URL that provides the document content.

createLink

Creates a sap:link type object under a specified repository for which the name and URL for the link should be provided.

deletePermanetly

Serves as a delete operation in the recycle bin, enabling the permanent deletion of objects from the recycle bin.

generateThumbnail

Generates a thumbnail for a given document id.

getDeletedChildren

Returns the list of child objects deleted from the specified folder. This is one of the recycle bin APIs that provides information about the immediate children deleted from a specified folder. When the folder objectId is not mentioned, the root is considered by default.

restoreObject

It restores the deleted object. This is one of the recycle bin APIs that recovers deleted objects. The objectId can be of a document or a folder.

zipCreationForDownload

Creates a ZIP object temporarily on server which can be downloaded using Zip Content Downloaded API with provided folder/multiple object Ids

zipDownload

Downloads the ZIP that has been created using ZIP Content Creation API for a Folder/ Multiple files on the server for the same session

zipExtractAndUpload

Creates a folder with the zip name and all the contents inside the zip, folder or document are created inside it. The maximum size that can be uploaded is 4GB and the maximum entries in zip can be 10000.

Readme

Keywords

Package Sidebar

Install

npm i sap-cloud-cmis-client

Weekly Downloads

31

Version

1.3.1

License

MIT

Unpacked Size

561 kB

Total Files

700

Last publish

Collaborators

  • vneecious