Design Hub developer guide - storage plugins

Design Hub storage plugins automatically save compounds to external databases. These plugins are NodeJS modules, stored in a folder set by Design Hub's configuration file.

Prerequisites

  • an instance of Design Hub available for development purposes, i.e.: the ability to stop and start it, to try different configuration options

  • familiarity with JavaScript, NodeJS and its module system

Storage plugins

This plugin type is intended to save important information from a design set, to a shared idea database.

Life-cycle

Design Hub scans the services directory to find all storage plugins and loads them on start.

images/download/attachments/17269851/storage_plugin_life_cycle_%282%29.png

Specification

Export plugins are NodeJS modules , denoted by their filename: *.storage.js and the location in the services directory as configured during installation.

An export plugin exports the following required properties:

Name

Type

Description

name

string

Unique identifier of the plugin, used by Design Hub for identification and internal communication. If multiple plugins use the same identifier, the last one to be loaded overrides the others.

insertSnapshot

function

The main function of the plugin, called when chemists save a snapshot, once for each snapshot. The function should have a void return type.

Arguments:

  • snapshot (Object) data structure containing chemical structure and metadata. See specification below.

  • this includes domain, roomName and URL for this room

Required: yes

updateSnapshot

function

Called when chemists change the metadata of a snapshot, once for each change. The function should have a void return type.

Arguments:

  • snapshot (Object) data structure containing structures and comments. See specification below.

  • this includes domain, roomName and URL for this room

Required: no

domains

array of strings

List of domains where this plugin may be used, when authentication is enabled in Design Hub. Use * to allow any domain. If no authentication is setup, this option has no effect. To query the configured domains, send a GET request to /domains or open /domains in your browser.

enablePrivateDataStorage

boolean

Configures the application to enable this plugin in rooms that are set to private. Private rooms are visible only to their owner and those invited.

Required: no

Default: false

Snapshot data specification

Below is an example of a snapshot object, with inline description of the individual attributes.

{
//String, mrv source of the chemical structure
"structure": "<cml><MDocument>...</MDocument></cml>",
//String, base64 encoded PNG image at 500x400
"image": "data:image/png;base64,iVBORw0KG...5CYII=",
//String, display name of the author of this structure
"author": "Susan",
//Number, millisecond resolution UNIX timestamp of the authoring
//of this structure
"timestamp": 1436786661609,
//String, uploaded or drawn, indicates the source of this item
"type": "drawn",
//String, action item given when making this snapshot
"task": "check IP by Friday",
//Object, key-value data returned by real time plugins for "reports"
"data": {
//key: String, label of real time plugin
//value: Object, key-value pairs of data returned
"Calculated Properties": {
"Mass": 344.43,
"cLogP": 1.74
}
}
}

Examples

You can find a brief selection of plugins in our Github repository for: Oracle, JChem Oracle Cartridge, Postgres, JChem Postgres Cartridge and MySQL.