@dbom/sdk v1.2.0
DBoM Node SDK
The DBoM SDK for Node.js provides a high level API to interact with a DBoM node. The SDK is designed to be used in the Node.js JavaScript runtime.
Table of Contents
Getting Started
Prerequisites
To build and test, the following prerequisites must be installed first:
- Node.js, version 12 is supported from 12.13.1 and higher
- npm tool version 6 or higher
Development
Clone the project and launch the following commands to install the dependencies and perform various tasks.
In the project root folder:
- Install all dependencies via
npm install
- To run the unit tests, use
npm run test
Usage
The DBoM SDK is available on NPM and can be used as described below
Example:
Install the dbom-sdk
npm install @dbom/sdk
The DBoM SDK can now be imported:
const DbomNode = require('@dbom/sdk');
let dNode = new DbomNode('<gateway-uri>', '<optional-signing-service-uri>', '<optional-api-key>');
Create and Update Asset
let repoID = 'DB1',
channelID = 'C1',
assetID = 'ABC01',
assetBody = {
"standardVersion": 1.0,
"documentName": "BoM for CPU Core i5 3500k",
"documentCreator": "Intel FAB California",
"documentCreatedDate": "2020-03-19",
"assetType": "HardwareComponent",
"assetSubType": "CPUUnit",
"assetManufacturer": "Intel Corporation",
"assetModelNumber": "BX80677I57500",
"assetDescription": "Core i5 3500k Desktop Processor",
"assetMetadata": {
"clockSpeed": "3.4Ghz",
"cpuSocket": "LGA 1151",
"physicalCoreCount": "4",
"supportedMemoryType": "DDR4SDRAM",
"packageWattage": "65",
"packageWeight": "340g"
},
"manufactureSignature": "wsBcBAEBCAAQBQJecxBBCRDhB93OjBXccAAAlAQH/0N2HhaK6fmADG0QxK9i8xIrgncGzvii6OqPzyVtyjA7RrpgA1c5E5wN5eW8XmPaqpMvtP3RenuTlXTH2d647QnzdxYuNOKjVXGuweBMkBqnKBf8hHeH6adBTh6Jlnbt3OndMsE06BMBz59Z/X4tmKoAWXox1EPraAi9+A6BqeB5YHXDQJ6SXsW9fLKoQVECsi0MHOR+CjGcu1R1dyP5s2Vd9jcm+DLXLmxz6zTqS7h1neLMsFm4jIhxYsh5mQ49R4r6Yi76RIMK5G6LxX32BzKb9rTDSKdqRFQAv4JsoZXTPRwlM3MG/FCQWYhtvc6righlAMJOVSXTxy54TPKeXe4==SVL1"
};
(async () => {
try {
// Create an asset
await dNode.createAsset(repoID, channelID, assetID, assetBody);
// Retrive the asset from the gateway
let asset = await dNode.getAsset(repoID, channelID, assetID);
// Update the asset
asset.assetMetadata.supportedMemoryType = 'DDR5SDRAM';
await dNode.updateAsset(repoID, channelID, assetID, assetBody);
} catch (e) {
console.log('ERROR:', e);
}
})();
Attach or Detach SubAsset
// Attaches a child asset to the provided parent asset
let attachRes = await attachSubasset(parentRepoID, parentChannelID, parentAssetID,
childRepoID, childChannelID, childAssetID,
role, subRole);
console.log(attachRes);
// Detaches a child asset from the provided parent asset
let detachRes = await detachSubasset(parentRepoID, parentChannelID, parentAssetID,
childRepoID, childChannelID, childAssetID);
console.log(detachRes);
Validate or Audit the Asset
// Validates the manufacturer signature of an asset via the DBoM Node
let validate = await dNode.validateAsset(repoID, channelID, assetID);
console.log(validate);
// Get the audit trail of an asset via the DBoM Node
let audit = await dNode.auditAsset(repoID, channelID, assetID);
console.log(audit);
Docs
The SDK is annotated with JSDoc Comments. In order to generate HTML documentation run:
npm run generate-docs
Getting help
If you have any queries on the dbom-node-sdk, feel free to reach us on any of our communication channels
If you have questions, concerns, bug reports, etc, please file an issue in this repository's issue tracker.
Getting involved
Find the instructions on how you can contribute in CONTRIBUTING.