Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/hcl-tech-software/domino-rest-sdk-node

NodeJS SDK to interact with the HCL Domino REST API
https://github.com/hcl-tech-software/domino-rest-sdk-node

domino rest-api volt-mx volt-mx-go

Last synced: 8 days ago
JSON representation

NodeJS SDK to interact with the HCL Domino REST API

Awesome Lists containing this project

README

        

# Domino REST API Node.js SDK

Domino REST API Node.js SDK is a library that can help Node.js developers to build applications that uses Domino REST API. Domino REST API Node.js SDK also supports TypeScript.

(C) 2023 HCL America Inc. Apache-2.0 license [https://www.apache.org/licenses/LICENSE-2.0](https://www.apache.org/licenses/LICENSE-2.0)

[![npm](https://nodei.co/npm/@hcl-software/domino-rest-sdk-node.png)](https://www.npmjs.com/package/@hcl-software/domino-rest-sdk-node)

## 📔 Documentation

- [Domino REST API documentation](https://opensource.hcltechsw.com/Domino-rest-api/index.html)
- [Using Domino REST API Node.js SDK examples](https://github.com/HCL-TECH-SOFTWARE/domino-rest-sdk-node/tree/main/samples)
- [Github repository](https://github.com/HCL-TECH-SOFTWARE/domino-rest-sdk-node)
- [TypeDoc API documentation](https://opensource.hcltechsw.com/domino-rest-sdk-node/)

## âŦ‡ī¸ Installation

First, have a running Domino REST API server, and next, install [Node.js](https://nodejs.org/en). Make sure the version is `>18.0.0` as Domino REST API Node.js uses the native `fetch` method available on that version. Then run:

```sh
npm install @hcl-software/domino-rest-sdk-node
```

## ⭐ Highlights

- Supports both JavaScript and TypeScript.
- Has built-in methods for the following Domino REST API calls:
- **Basis**:
- `/document`
- `/document/{unid}`
- `/bulk/create`
- `/bulk/{unid}`
- `/bulk/update`
- `/bulk/delete`
- `/query`
- `/richtext/{richTextAs}/{unid}`
- `/lists`
- `/lists/{name}`
- `/listspivot/{name}`
- **Setup**:
- `/design/{designType}/{designName}`
- `/admin/scope`
- `/admin/scopes`

## đŸ“Ļ Importing

You can import the whole SDK via:

```javascript
// Using Node.js `require()`
const drapiSdk = require('@hcl-software/domino-rest-sdk-node');

// Using ES6 imports
import drapiSdk from '@hcl-software/domino-rest-sdk-node';
```

Or, you can import only the modules that you need, like:

```javascript
// Using Node.js `require()`
const { DominoAccess } = require('@hcl-software/domino-rest-sdk-node');

// Using ES6 imports
import { DominoAccess } from '@hcl-software/domino-rest-sdk-node';
```

## đŸ”Ŧ Overview

![Domino REST API Node SDK Model](/docs/sdk-model.png)

Domino REST API Node SDK has four moving parts:

- `DominoAccess`
- `DominoServer`
- `DominoConnector`
- Sessions
- `DominoUserSession`
- `DominoBasisSession`
- `DominoSetupSession`

### ℹī¸ DominoAccess

`DominoAccess` is a class that facilitates your access to the Domino REST API server. It takes in a `baseUrl`, which is your Idp provider, as well as your credentials, such as your `username`, `password`, `scope` and `type` (the authentication type: `basic` or `oauth`).

### ℹī¸ DominoServer

`DominoServer` is a class that gets information on what APIs are available on your current server. It takes in a url to your Domino REST API server as a parameter. This class produces a `DominoConnector` class base on your chosen API.

### ℹī¸ DominoConnector

`DominoConnector` is the class that does the actual communication between the Domino REST API Node SDK and your Domino REST API server.

### ℹī¸ Sessions

Sessions are classes that contains all the operations you can perform on your Domino REST API server. There are three classes under this, namely:

- `DominoUserSession`
- `DominoBasisSession`
- `DominoSetupSession`

`DominoUserSession` has generic request methods, which allows you to perform an operation from scratch.

`DominoBasisSession` contains all built-in methods for BASIS API operations.

`DominoSetupSession` contains all built-in methods for SETUP API operations.

### 🎮 Running a Domino REST API operation using the SDK

Here is an example of how to use the four moving parts mentioned above in order to execute one Domino REST API Node SDK.

```javascript
import drapiSdk from '@hcl-software/domino-rest-sdk-node';

const start = async () => {
const credentials = {
baseUrl: 'http://localhost:8880',
credentials: {
scope: '$DATA',
type: 'basic',
username: 'username',
password: 'password',
},
};
// Create DominoAccess
const dominoAccess = new drapiSdk.DominoAccess(credentials);
// Create DominoServer
const dominoServer = await drapiSdk.DominoServer.getServer('http://localhost:8880');
// Since in this example we will be performing a BASIS API operation (createDocument),
// we will use the DominoBasisSession class in order to use the built-in createDocument method.
const dominoBasisSession = await drapiSdk.DominoBasisSession.getBasisSession(dominoAccess, dominoServer);

// Create a Domino document
await dominoBasisSession.createDocument(...)
.then((document) => console.log(JSON.stringify(document.toJson(), null, 2)))
.catch((error) => console.log(error));
}

start();
```

For other examples, please go to our [examples](/samples/Tutorials%20on%20Domino%20Operations/).