# infohub-client

> Client library for CCV3 Infohub API

Latest version **1.0.1** (published 2020-07-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install infohub-client
pnpm add infohub-client
yarn add infohub-client
bun add infohub-client
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2020-07-28 |
| First published | 2020-07-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 24.8 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Maintainers | mjreich |

## Links

- npm: https://www.npmjs.com/package/infohub-client
- Repository: https://github.com/seabourne/infohub-client
- Homepage: https://github.com/seabourne/infohub-client/
- Issues: https://github.com/seabourne/infohub-client/issues
- npm.io page: https://npm.io/package/infohub-client

## Dependencies (3)

- [qs](https://npm.io/package/qs.md) ^6.7.0
- [request](https://npm.io/package/request.md) ^2.88.0
- [underscore](https://npm.io/package/underscore.md) ^1.9.1

## Recent versions

- 1.0.1 (latest) — 2020-07-28

## README

# infohub-client

<!-- Generated by documentation.js. Update this documentation by updating the source code. -->

## 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 present
-   `response.errors.toError()` - returns an `Error` object 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 is `http://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**

-   `options` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** configuration options;
        for now, the only option is `baseURL`, which sets the base URL
        for the information hub service

### getEntity

Gets an entity specified by id.

**Parameters**

-   `id` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** entity id
-   `attrs` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** (optional) attribute parameters

Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)** Promise that resolves to a `response` object.

### getEntities

Gets entities specified by selection parameters.

**Parameters**

-   `sel` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** selection parameters
-   `attrs` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** (optional) attribute parameters
-   `cursor` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** (optional) cursor parameters

Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)** Promise that resolves to a `response` object.

### createEntity

Creates an entity.

**Parameters**

-   `obj` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** entity object

Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)** Promise that resolves to a `response` object.

### updateEntity

Updates an entity specified by id.

**Parameters**

-   `id` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** entity id
-   `obj` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** entity object

Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)** Promise that resolves to a `response` object.

### deleteEntity

Deletes an entity specified by id.

**Parameters**

-   `id` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** entity id

Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)** Promise that resolves to a `response` object.

### deleteEntities

Deletes entities specified by selection parameters.

**Parameters**

-   `sel` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** selection parameters

Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)** Promise that resolves to a `response` object.

### getSchemas

Gets schemas

**Parameters**

-   `sel`  
-   `attrs`  
-   `cursor`  
-   `cache`   (optional, default `true`)

Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)** Promise that resolves to a `response` object.

---
_Source: https://npm.io/package/infohub-client · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
