@hcl-software/domino-rest-sdk-node
v0.2.0
Published
NodeJS library to interact with a HCL Domino compatible REST API
Downloads
22
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
📔 Documentation
- Domino REST API documentation
- Using Domino REST API Node.js SDK examples
- Github repository
- TypeDoc API documentation
⬇️ Installation
First, have a running Domino REST API server, and next, install Node.js. 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:
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
- Basis:
📦 Importing
You can import the whole SDK via:
// 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:
// 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 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.
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.