infohub-client v1.0.1
infohub-client
InformationHub
Information Hub Access. Simple shim for the Information Hub Data API. Provides CRUD operations.
For now, only implements operations on entities -- Create, Update, Read, Read Multiple, Delete and Delete Multiple. To be extended as we get a better idea of actual requirements.
The selection, attribute and cursor parameters passed to operations have the same format as defined by the Information Hub Data API.
The response object returned by operations has the same properties as defined by the Information Hub Data API. In addition, it is annotated with these methods:
response.anyProblems()- returns true if errors are presentresponse.errors.toError()- returns anErrorobject for the response errors (undefined if there are no errors)response.errors.throw()- throws an error if there are response errors; does nothing otherwise
The Information Hub Access module accepts these configuration properties:
baseURL- The base URL for the Information Hub Data API; default ishttp://localhost/dataapi/, note the trailing slash (/).
For use in Nxus projects, wrap this client as the proxy for a NxusModule to pass in configuration from nxus config:
import {NxusModule} from 'nxus-core'
import {default as Client} from 'infohub-client'
class InformationHub extends NxusModule {
constructor(options) {
super()
this.client = new Client({baseURL: this.config.baseURL})
this.__proxy.use(this.client)
}} var informationHub = InformationHub.getProxy()
export {InformationHub as default, informationHub}
Parameters
optionsObject configuration options; for now, the only option isbaseURL, which sets the base URL for the information hub service
getEntity
Gets an entity specified by id.
Parameters
Returns Promise Promise that resolves to a response object.
getEntities
Gets entities specified by selection parameters.
Parameters
selObject selection parametersattrsObject (optional) attribute parameterscursorObject (optional) cursor parameters
Returns Promise Promise that resolves to a response object.
createEntity
Creates an entity.
Parameters
objObject entity object
Returns Promise Promise that resolves to a response object.
updateEntity
Updates an entity specified by id.
Parameters
Returns Promise Promise that resolves to a response object.
deleteEntity
Deletes an entity specified by id.
Parameters
idstring entity id
Returns Promise Promise that resolves to a response object.
deleteEntities
Deletes entities specified by selection parameters.
Parameters
selObject selection parameters
Returns Promise Promise that resolves to a response object.
getSchemas
Gets schemas
Parameters
selattrscursorcache(optional, defaulttrue)
Returns Promise Promise that resolves to a response object.
5 years ago