npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

sci-rest-client

v1.4.0

Published

NodeJS based client for the SAP Cloud Integration REST API

Downloads

53

Readme

SIT SIT

Integration Content API client for SAP Cloud Integration

This package simplifies the access to the Integration Content API for SAP Cloud Integration. It hides all the technical implementation details like

  • url construction
  • csrf token handling
  • zipping and encoding of artifact content

and offers a clean and easy-to-use interface for managing and querying integration artifacts of design and runtime.

By now the following artifact types are supported

  • Integration packages (C(reate), R(ead), U(pdate), D(elete))
  • Integration flows (CRU)
  • Message mappings (CRU)
  • Value mappings (CR)
  • Script collections (CRU)

Furthermore the package offers methods to create and update artifacts based on artifact directories by reading and extracting the required information for the corresponding API call from the artifact metadata file.

Getting Started

Install the package

npm install sci-rest-client

Import the package like follows and initialize the client (ESM)

import SCIRestClient from 'sci-rest-client';

const SCIRestClient = new SCIRestClient({
    apiEndpoint: '<apiEndpoint>', // e.g. https://sandbox.api.sap.com/cpi/api/v1
    username: '<username>',
    password: '<password>',
});

Get all integration packages

const integrationPackages = await SCIRestClient.getIntegrationPackages();

Get a single integration package

const integrationPackage = await SCIRestClient.getIntegrationPackage('packageId');

Delete an integration package

await sciRestClient.deleteIntegrationPackage('packageId');

Create an artifact

const artifact = await this.createArtifact({
    Id: '<artifactId>',
    Type: '<IntegrationFlow | MessageMapping | ValueMapping | ScriptCollection>',
    Name: '<artifactName>'
    Content: '<base64EncodedZip>'
    PackageId: '<integrationPackageId>',
});

Update an artifact

await this.updateArtifact({
    Id: '<artifactId>',
    Version: '<artifactVersion'>,
    Type: '<IntegrationFlow | MessageMapping | ValueMapping | ScriptCollection>',
    Name: '<artifactName>'
    Content: '<base64EncodedZip>'
});

This method is a little special. If the update fails due to a version that doesn't exist, a new version is created under the hood and the update is triggered again automatically.

Create an artifact from an artifact directory

const integrationFlow = await SCIRestClient.createArtifactFromDirectory('<integrationPackageId>', '<pathToArtifactDirectory>');

The method reads and extracts the required information (id, version, name and artifact type) from the artifacts metadata file found under META-INF/MANIFEST.MF inside the artifact diretory.

Update an artifact from an artifact directory

await SCIRestClient.updateArtifactFromDirectory('<pathToArtifactDirectory>');

Again the method reads and extracts the necessary infos from the metadata file mentioned above. updateArtifact(...) is used under the hood, so new versions will be created automatically if necessary.

Create new artifact version

await this.createNewArtifactVersion('<artifactId>', '<artifactVersion>', '<artifactType');

The method creates a new version of the artifact, but this is just a placeholder. Afterwards to content needs to uploaded via updateArtifact(...). It's recommended to just call the update method directly in case you don't need any special logic for creating new versions.

Check if API action is supported for artifact

import APIAction from 'sci-rest-client/client/APIAction';

// const isActionSupported = sciRestClient.isActionSupported(APIAction.Update, '<pathToArtifactDirectory>');
const isActionSupported = sciRestClient.isActionSupportedForArtifactType(APIAction.Update, 'IntegrationFlow');

if(isActionSupported) {
    ...
}

The available APIActions are: Create, Read, Update, Delete and New_Version.

Get artifact type

const artifactType = sciRestClient.getArtifactType('<pathToArtifactDirectory>');

Get artifact artifact metadata

const artifactMetadata = sciRestClient.getArtifactMetadata('<pathToArtifactDirectory>');

Returns an object containing the id, name, version and type of the artifact in the specified directory.

Test

The package is implemented in TypeScript and Vitest is used as a test framework. The tests need to run against a real Integration content API endpoint. The API endpoint and the credentials are read from environment variables. For executing the tests create a .envfile inside the root directory of the package

SCI_API_USER=<Username>
SCI_API_PASSWORD=<Password>
SCI_API_ENDPOINT=https://sandbox.api.sap.com/cpi/api/v1

or set the necessary environment variables manually.

In order to run tests execute

npm test

which will display the test runs and their results on the terminal.

For more details run

npm run test:ui

which will show the test results (and much more) on a web page.

Both commands will listen to file changes and execute the corresponding tests again.

Contributing

We welcome any type of contribution (code contributions, pull requests, issues) to this project equally.

ESLint and SonarQube are used to ensure code quality. A Git commit hook will fix lint findings automatically (if possible) and prevent commits with linting errors. Prettier is used for formatting. Staged changes will be formatted automatically before committing.

Release management

release-please is used for release management and automatic CHANGELOG generation. For the latter it's important that commit messages follow the Conventional Commit messages style.

Support

Please use the GitHub bug tracking system to post questions, bug reports or to create pull requests.

License

This project is licensed under the Apache Software License, version 2.0 except as noted otherwise in the LICENSE file.