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.
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
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
The DBoM SDK is available on NPM and can be used as described below
Example:
Install the dbom-sdk
npm install @dbom/sdkThe DBoM SDK can now be imported:
constDbomNode=require('@dbom/sdk');letdNode=newDbomNode('<gateway-uri>','<optional-signing-service-uri>','<optional-api-key>');letrepoID='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 assetawaitdNode.createAsset(repoID,channelID,assetID,assetBody);// Retrive the asset from the gatewayletasset=awaitdNode.getAsset(repoID,channelID,assetID);// Update the assetasset.assetMetadata.supportedMemoryType='DDR5SDRAM';awaitdNode.updateAsset(repoID,channelID,assetID,assetBody);}catch(e){console.log('ERROR:',e);}})();// Attaches a child asset to the provided parent assetletattachRes=awaitattachSubasset(parentRepoID,parentChannelID,parentAssetID,childRepoID,childChannelID,childAssetID,role,subRole);console.log(attachRes);// Detaches a child asset from the provided parent assetletdetachRes=awaitdetachSubasset(parentRepoID,parentChannelID,parentAssetID,childRepoID,childChannelID,childAssetID);console.log(detachRes);// Validates the manufacturer signature of an asset via the DBoM Nodeletvalidate=awaitdNode.validateAsset(repoID,channelID,assetID);console.log(validate);// Get the audit trail of an asset via the DBoM Nodeletaudit=awaitdNode.auditAsset(repoID,channelID,assetID);console.log(audit);The SDK is annotated with JSDoc Comments. In order to generate HTML documentation run:
npm run generate-docsIf 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.
Find the instructions on how you can contribute in CONTRIBUTING.