new DocloopEndpoint(adapter, data)
Parameters:
Name | Type | Description |
---|---|---|
adapter |
DocloopAdapter | |
data |
EndpointData | Set the corresponding proprties on the endpoint object. |
Properties:
Name | Type | Description |
---|---|---|
identifier |
Identifier | Uniquely identifies an external resource |
config |
config | Configuration data |
decor |
Decoration | Extra data for the client for visualization |
adapter |
DocloopAdapter | The adapter an endpoint is associated with |
id |
bson | |
skeleton |
EndpointSkeleton | Getter |
export |
EndpointData | Getter |
Methods
-
<async, abstract, static> guess(str, session_data)
-
This method is meant to be overwritten by a custom endpoint class. Returns a single valid endpoint guessed from the provided string.
Parameters:
Name Type Description str
string A string to guess the Endpoint identifier from
session_data
SessionData Data of the current session associated with this adapter
Returns:
- Type
- ValidEndpoint
-
<async> _updateDecor(session)
-
Calls .updateDecor with SessionData.
Parameters:
Name Type Description session
Session Returns:
- Type
- undefined
-
<async> _validate(session)
-
Calls DocloopEndpoint#validate with SessionData
Parameters:
Name Type Description session
Session 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.
Returns:
Data stored at the key.
- Type
- Object | String | Number
-
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.
Returns:
True iff endpoint_or_identifier and the current endpoint point have the same external resource.
- Type
- boolean
-
<async> remove()
-
Removes te endpoint document from the database.
Returns:
- Type
- 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.
Returns:
undefined
-
<async> store()
-
Stores the endpoint to the database as new document. (Using the data from .export)
Returns:
The mongo-db id for the inserted document.
- Type
- bson
-
<async> update()
-
Updates document associated with the endpoint using the data from .export.
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 Returns:
- Type
- undefined
-
<async, abstract> validate(session_data)
-
This method is meant ot bew overwritten. Checks if the current session has access to the resource pointed at by the endpoint's identifier. Whenever an endpoint passes .validate() the endpoint and any link using this endpoint can be modified during this session.
Parameters:
Name Type Description session_data
SessionData Returns:
- Type
- undefined
Type Definitions
-
Decoration
-
A Decoration object stores all the data the client needs in order to nicely display the resource pointed to by an identfier.
Type:
- Object
Properties:
Name Type Argument Default Description image
String <optional>
null Url of an image
title
String <optional>
'Generic Endpoint' Title of the resource, the identifier points to
details
String <optional>
'unknown' Additonal information concerning the resource, the identfier points to
-
Endpoint
-
An endpoint is an instance of either DocloopEndpoint or any class extending it.
Type:
- Object
-
EndpointClass
-
An endpoint class is either DocloopEndpoint or any class extending it.
Type:
- Class
-
EndpointData
-
Minimal data to instantiate a new Endpoint. Also: all the data the client might need.
Type:
- Object
Properties:
Name Type Argument Description id
String | bson <optional>
The endpoint id.
_id
String | bson <optional>
If id is not present _id will be used. This is handy, if the data comes directly form the database.
identifier
Identifier Uniquely identifies an external resource
config
config <optional>
Configuration data
decor
Decoration <optional>
Extra data for the client for visualization
-
EndpointSkeleton
-
The skeleton of an endpoint is a minimal set of data to identify an endpoint. Since adapters store endpoint data individually, the endpoint id alone is not enough.
Type:
- Object
Properties:
Name Type Description id
bson Endpoint id
adapter
String Adapter id
-
Identifier
-
Identifiers describe external resources to be used by an adapter. They will always have at least the adapter property and the external resource should be uniquely determined by the remaining properties. Two Endpoints can have euqal identifiers, if for example they are part of two different Links.
Type:
- Object
Properties:
Name Type Description adapter
string An adapter id.
Any
* other properties.
-
ValidEndpoint
-
A valid endpoint is an endpoint that passes .validate() for the current session. Iff an endpoint is considered valid for a session, all links associated with this endpoint can be modified during this session.
Type: