Module: abstractInstances

abstractInstances

Library of common methods for manipulating instances (tiles and extstreams).

Source:

Methods

<static> deleteExternalProps(instance) → {Promise}

Removes the map of extended properties on the instance, in the remote community.

Parameters:
Name Type Description
instance Object
Source:
Returns:

Promise

Type
Promise

<static> find(keyValues, expectOne, cursor) → {Promise}

Find instances in persistence using the provided key-value criteria map. For example:

 {
     'name': 'samplelist',
     'config.number' : 25
 }

On success, the returned promise will be resolved with an array of the located objects (which may be empty if none is found matching the criteria). If failure, the promise will be rejected with an error.

Parameters:
Name Type Description
keyValues Object
expectOne Boolean

If true, the promise will be resolved with at most 1 found item, or null (if none are found).

cursor Boolean

If true, the promise will be resolved with a collection cursor object.

Source:
Returns:

Promise

Type
Promise

<static> findAll(cursor) → {Promise}

Searches persistence for instances. The collection that is searched is defined in subclasses of this class (@see abstractInstances:getCollection). The promise will resolve with an empty array, or populated array, depending on whether any instances exist.

Parameters:
Name Type Description
cursor Boolean

If true, the promise will be resolved with a collection cursor object.

Source:
Returns:

Promise

Type
Promise

<static> findByCommunity(communityName) → {Promise}

Searches persistence for an instance that matches the given community name (the 'community' attribute). The collection that is searched is defined in subclasses of this class (@see abstractInstances:getCollection). If one is not found, the promise will resolve a null (undefined) value.

Parameters:
Name Type Description
communityName String
Source:
Returns:

Promise

Type
Promise

<static> findByDefinitionName(definitionName, cursor) → {Promise}

Searches persistence for instances that matches the given definition name (the 'name' attribute). The collection that is searched is defined in subclasses of this class (@see abstractInstances:getCollection). The promise will resolve with an empty array, or populated array, depending on whether any instances matched the search criteria.

Parameters:
Name Type Description
definitionName String
cursor Boolean

If true, the promise will be resolved with a collection cursor object.

Source:
Returns:

Promise

Type
Promise

<static> findByGuid(guid) → {Promise}

Searches persistence for an instance that matches the given guid (the 'guid' attribute). The collection that is searched is defined in subclasses of this class (@see abstractInstances:getCollection). If one is not found, the promise will resolve a null (undefined) value.

Parameters:
Name Type Description
guid String
Source:
Returns:

Promise

Type
Promise

<static> findByID(instanceID) → {Promise}

Searches persistence for an instance that matches the given ID (the 'id' attribute). The collection that is searched is defined in subclasses of this class (@see abstractInstances:getCollection). If one is not found, the promise will resolve a null (undefined) value.

Parameters:
Name Type Description
instanceID String

Id of the instance to be retrieved.

Source:
Returns:

Promise

Type
Promise

<static> findByScope(scope) → {Promise}

Searches persistence for an instance that matches the given scope (the 'scope' attribute). The collection that is searched is defined in subclasses of this class (@see abstractInstances:getCollection). If one is not found, the promise will resolve a null (undefined) value.

Parameters:
Name Type Description
scope String
Source:
Returns:

Promise

Type
Promise

<static> findByURL(url) → {Promise}

Searches persistence for an instance that matches the given push URL (the 'url' attribute). The collection that is searched is defined in subclasses of this class (@see abstractInstances:getCollection). If one is not found, the promise will resolve a null (undefined) value.

Parameters:
Name Type Description
url String
Source:
Returns:

Promise

Type
Promise

<static> getExternalProps(instance) → {Promise}

Retrieves a map of extended properties set on the instance, in the remote jive community.

Parameters:
Name Type Description
instance Object
Source:
Returns:

Promise

Type
Promise

<static> refreshAccessToken(instance) → {Promise}

Performs an OAuth2 access token refresh with the jive community associated with the passed in instance. If successful, the promise is resolved with the instance object containing the new access token (accessToken). Note that the changes to the instance is not actually saved into persistence at this point.

Parameters:
Name Type Description
instance Object

Must contain the following fields:

Properties
Name Type Description
jiveCommunity String

Points to an existing community

refreshToken String

Refresh token used for acquiring a new access token

Source:
Returns:

Promise

Type
Promise

<static> register(jiveUrl, pushUrl, config, name, code, guid) → {Promise}

Registers a new tile or extstream instance:

  1. Try to locate a community based on the jiveUrl
  2. If no community is located matching the jiveUrl, the returned promise is rejected with an error.
  3. If a community is located, do an OAuth2 access token exchange with that server using the authorization code ('code') provided.
  4. A tile or extstream instance is created (or updated, if it already exists) using the oauth credentials and register parameters, and resolved on the returned promise.
Parameters:
Name Type Description
jiveUrl String
pushUrl String
config Object
name String
code String
guid String
Source:
Returns:

Promise

Type
Promise

<static> remove(instanceID) → {Promise}

Removes an instance from persistence with the specified id (attribute 'id'). The collection that is searched is defined in subclasses of this class (@see abstractInstances:getCollection).

Parameters:
Name Type Description
instanceID String
Source:
Returns:

Promise

Type
Promise

<static> save(instance) → {Promise}

Save an instance to persistence. If the object does not have an id attribute, a random String is assigned. If the object is already present in persistence, it will be updated; otherwise it will be inserted. On success, the returned promise will be resolved with the inserted or updated object; if failure, the promise will be rejected with an error.

Parameters:
Name Type Description
instance Object
Source:
Returns:

Promise

Type
Promise

<static> setExternalProps(instance, props) → {Promise}

Sets a map of extended properties on the instance, in the remote jive community.

Parameters:
Name Type Description
instance Object
props Object
Source:
Returns:

Promise

Type
Promise