new PaperhiveSource()
Extends
Methods
-
<static> documentToDecor(ph_document)
-
Translates document data into EndpointDecoration.
Parameters:
Name Type Description ph_document
Object Data of a paperhive document. See PaperhiveSource.getDocument
Returns:
- Type
- Decoration
-
<static> fromDocument(adapter, ph_document)
-
Creates a new instance of Paperhivesource from the provided document data
Parameters:
Name Type Description adapter
PaperhiveAdapter The adapter the new source will be associated with.
ph_document
Object Data of a paperhive document. See PaperhiveSource.getDocument
Returns:
New instance of Paperhivesource
- Type
- Paperhivesource
-
<async, static> getDocument(document_id)
-
Fetch document data from the paperhive API
Parameters:
Name Type Description document_id
String The paperhive document id
Throws:
-
If paperhive API request fails
- Type
- Error
Returns:
The document's data
- Type
- Object
-
-
<async, static> guess(adapter, str)
-
Tries to guess a document id from provided string and create a new instance of PaperhiveSource associated with it.
Parameters:
Name Type Description adapter
PaperhiveAdapter The adapter the new source will be associated with.
str
String A string to guess the document id from.
Throws:
-
-
If adapter is missing
- Type
- ReferenceError
-
-
-
If str is not a string
- Type
- TypeError
-
-
-
If str contains no matchable document_id
- Type
- DocloopError
-
Returns:
- Type
- PaperhiveSource
-
-
<async> _updateDecor(session)
-
Calls .updateDecor with SessionData.
Parameters:
Name Type Description session
Session - Inherited From:
Returns:
- Type
- undefined
-
<async> _validate(session)
-
Calls DocloopEndpoint#validate with SessionData
Parameters:
Name Type Description session
Session - Inherited From:
Returns:
- Type
- undefined
-
<async> getData(key)
-
Retrieves data stored alongside the endpoint document.
Parameters:
Name Type Description key
String The key, where the data is stored at.
- Inherited From:
Returns:
Data stored at the key.
- Type
- Object | String | Number
-
<async> getDiscussions()
-
Fetch discussion data form the paperhive API.
Throws:
-
If paperhive API request fails
- Type
- Error
Returns:
- Type
- Object
-
-
match(endpoint_or_identifier)
-
Checks if the provided Object points to the same external Resource as the endpoint's identifier.
Parameters:
Name Type Description endpoint_or_identifier
Identifier | DocloopEndpoint And identifier or any instance of DocloopEndpoint or a class that extends DocloopEndpoint.
- Inherited From:
Returns:
True iff endpoint_or_identifier and the current endpoint point have the same external resource.
- Type
- boolean
-
phDiscussion2Annotation(discussion)
-
Convert discussion data into Annotation
Parameters:
Name Type Description discussion
Object Returns:
- Type
- Annotation
-
phReply2Reply(discussion)
-
Convert reply data into Reply.
Parameters:
Name Type Description discussion
Object Returns:
- Type
- Annotation
-
<async> remove()
-
Removes te endpoint document from the database.
- Inherited From:
Returns:
- Type
- undefined
-
<async> scan()
-
Scan the source for new annotations and replies.
Fires:
- docloop~event:annotation
- docloop~event:reply
Returns:
undefined
-
<async> setData(key, data)
-
Stores arbitrary data alongside the endpoint document.
Parameters:
Name Type Description key
String A key to store the data at.
data
Object | String | Number The data to be stored at the key.
- Inherited From:
Returns:
undefined
-
<async> store()
-
Stores the endpoint to the database as new document. (Using the data from .export)
- Inherited From:
Returns:
The mongo-db id for the inserted document.
- Type
- bson
-
<async> update()
-
Updates document associated with the endpoint using the data from .export.
- Inherited From:
Throws:
-
If this.id is undefined (i.e. the endpoint has not been stored yet)
- Type
- ReferenceError
Returns:
- Type
- undefined
-
<async> updateDecor(sesion_data)
-
This method is meant to be overwritten. //TODO: is this usefull?
Parameters:
Name Type Description sesion_data
SessionData - Inherited From:
- Overrides:
Returns:
- Type
- undefined
-
<async> validate()
-
Validate the source by checking if the associated document's discussion is readable.
- Overrides:
Throws:
-
If document's discussion are not readable
- Type
- DocloopError