Library of common methods for manipulating instances (tiles and extstreams).
Methods
-
<static> deleteExternalProps(instance) → {Promise}
-
Removes the map of extended properties on the instance, in the remote community.
Parameters:
Name Type Description instanceObject 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 keyValuesObject expectOneBoolean If true, the promise will be resolved with at most 1 found item, or null (if none are found).
cursorBoolean If true, the promise will be resolved with a collection cursor object.
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 cursorBoolean If true, the promise will be resolved with a collection cursor object.
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 communityNameString 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 definitionNameString cursorBoolean If true, the promise will be resolved with a collection cursor object.
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 guidString 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 instanceIDString Id of the instance to be retrieved.
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 scopeString 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 urlString 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 instanceObject 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 instanceObject Must contain the following fields:
Properties
Name Type Description jiveCommunityString Points to an existing community
refreshTokenString Refresh token used for acquiring a new access token
Returns:
Promise
- Type
- Promise
-
<static> register(jiveUrl, pushUrl, config, name, code, guid) → {Promise}
-
Registers a new tile or extstream instance:
- Try to locate a community based on the jiveUrl
- If no community is located matching the jiveUrl, the returned promise is rejected with an error.
- If a community is located, do an OAuth2 access token exchange with that server using the authorization code ('code') provided.
- 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 jiveUrlString pushUrlString configObject nameString codeString guidString 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 instanceIDString 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 instanceObject 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 instanceObject propsObject Returns:
Promise
- Type
- Promise