Home Reference Source Repository
import Api from 'schema-mapper-api'
public class | source

Api

Main interface to communicate with a store

Constructor Summary

Public Constructor
public

Create a new Api instance

Member Summary

Public Members
public

Cached ProjectCollection

Protected Members
protected

Websocket client used for communication with a store

Method Summary

Public Methods
public

Apply a change to the store

public

Apply multiple changes to the store

public

createPutItemStream(projectId: String, schemaId: String, projectVersion: Number, listen: Boolean): Stream

Create a write stream to store items

public

delItem(projectId: String, schemaId: String, itemId: String): Promise

Remove an item

public

Retrieve all projects at all versions

public

Retrieve a ProjectCollection

public

on(topic: String, cb: Function)

Listen to events from the store

public

putItem(projectId: String, schemaId: String, item: Item, projectVersion: Number): Promise

Store an item

Protected Methods
protected

handleResponse(response: Object): *

Handles websocket result

Public Constructors

public constructor(url: String) source

Create a new Api instance

Params:

NameTypeAttributeDescription
url String

The store server url to connect to

Public Members

public projectCollection: ProjectCollection source

Cached ProjectCollection

Protected Members

protected websocketClient: WebsocketClient source

Websocket client used for communication with a store

Public Methods

public applyChange(change: Change): Promise source

Apply a change to the store

Params:

NameTypeAttributeDescription
change Change

Return:

Promise

public applyChanges(changes: Changes): Promise source

Apply multiple changes to the store

Params:

NameTypeAttributeDescription
changes Changes

Array of changes

Return:

Promise

public createPutItemStream(projectId: String, schemaId: String, projectVersion: Number, listen: Boolean): Stream source

Create a write stream to store items

Params:

NameTypeAttributeDescription
projectId String
schemaId String
projectVersion Number
listen Boolean

Whether you want to listen for results or not

Return:

Stream

Stream that accepts items as a JSON object

public delItem(projectId: String, schemaId: String, itemId: String): Promise source

Remove an item

Params:

NameTypeAttributeDescription
projectId String
schemaId String
itemId String

Return:

Promise

public getAllProjects(): Object source

Retrieve all projects at all versions

Return:

Object

All projects

public getProjectCollection(): ProjectCollection source

Retrieve a ProjectCollection

public on(topic: String, cb: Function) source

Listen to events from the store

Params:

NameTypeAttributeDescription
topic String

Topic to listen to

cb Function

Callback to call when an event has happened

public putItem(projectId: String, schemaId: String, item: Item, projectVersion: Number): Promise source

Store an item

Params:

NameTypeAttributeDescription
projectId String
schemaId String
item Item
projectVersion Number

Return:

Promise

Protected Methods

protected handleResponse(response: Object): * source

Handles websocket result

Params:

NameTypeAttributeDescription
response Object

Return:

*

Result