diff --git a/docs/index.html b/docs/index.html index 77a1cdc..b1192b6 100644 --- a/docs/index.html +++ b/docs/index.html @@ -24,6 +24,7 @@ API documentation / Version + 0.8.1 0.6.0 (latest) 0.5.0 0.4.0 diff --git a/docs/opentmi-jsclient/0.8.1/Admin.html b/docs/opentmi-jsclient/0.8.1/Admin.html new file mode 100644 index 0000000..c457eb1 --- /dev/null +++ b/docs/opentmi-jsclient/0.8.1/Admin.html @@ -0,0 +1,630 @@ + + + + + JSDoc: Class: Admin + + + + + + + + + + +
+ +

Class: Admin

+ + + + + + +
+ +
+ +

Admin(transport)

+ + +
+ +
+
+ + + + + + +

new Admin(transport)

+ + + + + + +
+ Admin operations +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
transport + + +Transport + + + + transport layer
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + +

Methods

+ + + + + + + +

reloadWorkers() → {Promise}

+ + + + + + +
+ Reload backend workers - e.g. after upgrade is finished +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ Resolves when reload is ready +
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + + + + + + + + + + +

upgrade(revision, reloadWorkers) → {Promise}

+ + + + + + +
+ Update opentmi server which are connected through Transport +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDefaultDescription
revision + + +string + + + + + + tag/commitId to be deployed
reloadWorkers + + +bool + + + + + + true + + reload workers (default) or not to reload
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ resolves when upgrade is ready +
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + + + + + + + + + + +

version() → {Promise}

+ + + + + + +
+ Get OpenTMI server version details. +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ resolves json object +e.g. { commitId: , tag: , version: , node_modules: {...}..} +
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + + + + + + + + + + +
+ +
+ + + + +
+ + + +
+ + + + + + + \ No newline at end of file diff --git a/docs/opentmi-jsclient/0.8.1/Authentication.html b/docs/opentmi-jsclient/0.8.1/Authentication.html new file mode 100644 index 0000000..d362c51 --- /dev/null +++ b/docs/opentmi-jsclient/0.8.1/Authentication.html @@ -0,0 +1,823 @@ + + + + + JSDoc: Class: Authentication + + + + + + + + + + +
+ +

Class: Authentication

+ + + + + + +
+ +
+ +

Authentication(transport)

+ +
Authentication controller +This class provides login API's like login, logout
+ + +
+ +
+
+ + + + +

Constructor

+ + + +

new Authentication(transport)

+ + + + + + +
+ Constructor for Authentication controller +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
transport + + +Transport + + + + transport layer for communication
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +
Example
+ +
const auth = new Authentication(transport);
+auth
+  .login('user@email.com', 'password')
+  .whoami().then(user => console.log(user.toString()));
+ + + + +
+ + + + + + + + + + + + + + + + +

Methods

+ + + + + + + +

login(email, password) → {Promise.<string>}

+ + + + + + +
+ Login to OpenTMI +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
email + + +string + + + + user email address
password + + +string + + + + user password
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ - return a token +
+ + + +
+
+ Type +
+
+ +Promise.<string> + + +
+
+ + + + + + + + + + + + + +

loginWithToken(token, service) → {Promise.<string>}

+ + + + + + +
+ Login using access token +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDefaultDescription
token + + +string + + + + + + service authentication token
service + + +string + + + + + + github + + token service, default: Github
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ - return token +
+ + + +
+
+ Type +
+
+ +Promise.<string> + + +
+
+ + + + + + + + + + + + + +

logout() → {Promise}

+ + + + + + +
+ Logout +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ resolves when logged out succesfully +
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + + + + + + + + + + +

whoami() → {Promise.<object>}

+ + + + + + +
+ Find out who I'm. +Returns plain object with some details about yourself. +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ resolves user details +
+ + + +
+
+ Type +
+
+ +Promise.<object> + + +
+
+ + + + + + + + + + + + + +
+ +
+ + + + +
+ + + +
+ + + + + + + \ No newline at end of file diff --git a/docs/opentmi-jsclient/0.8.1/Cluster.html b/docs/opentmi-jsclient/0.8.1/Cluster.html new file mode 100644 index 0000000..6f3f0f1 --- /dev/null +++ b/docs/opentmi-jsclient/0.8.1/Cluster.html @@ -0,0 +1,442 @@ + + + + + JSDoc: Class: Cluster + + + + + + + + + + +
+ +

Class: Cluster

+ + + + + + +
+ +
+ +

Cluster(transport)

+ +
Class to manage OpenTMI clusters. +Most of these require admin access.
+ + +
+ +
+
+ + + + +

Constructor

+ + + +

new Cluster(transport)

+ + + + + + +
+ Constructor +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
transport + + +Transport + + + + transport object
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + +

Methods

+ + + + + + + +

refresh() → {undefined}

+ + + + + + +
+ Reload clusters states +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ returns nothing +
+ + + +
+
+ Type +
+
+ +undefined + + +
+
+ + + + + + + + + + + + + +

restartWorkers() → {Promise}

+ + + + + + +
+ Restart workers. Require admin access. +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ resolves when workers are resterted +
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + + + + + + + + + + +
+ +
+ + + + +
+ + + +
+ + + + + + + \ No newline at end of file diff --git a/docs/opentmi-jsclient/0.8.1/Document.html b/docs/opentmi-jsclient/0.8.1/Document.html new file mode 100644 index 0000000..1ec161f --- /dev/null +++ b/docs/opentmi-jsclient/0.8.1/Document.html @@ -0,0 +1,1974 @@ + + + + + JSDoc: Class: Document + + + + + + + + + + +
+ +

Class: Document

+ + + + + + +
+ +
+ +

Document(transport, path, originalJson)

+ +
Low level Document object, which handle modifications and storing
+ + +
+ +
+
+ + + + +

Constructor

+ + + +

new Document(transport, path, originalJson)

+ + + + + + +
+ Document constructor +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
transport + + +Transport + + + + transport layer
path + + +String + + + + Document rest uri
originalJson + + +Object + + + + document data as plain json
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + +

Members

+ + + +

id

+ + + + +
+ Get resource identity +
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + +

version

+ + + + +
+ getter for Document version +
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + +

Methods

+ + + + + + + +

_update(data) → {Promise}

+ + + + + + +
+ Update document +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
data + + +Object + + + + data to be updated
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ resolves when opration success +
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + + + + + + + + + + +

delete() → {Promise}

+ + + + + + +
+ delete this document +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ Resolves when operation success +
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + + + + + + + + + + +

get(key, defaultValue) → {String|Object}

+ + + + + + +
+ Get resource value by Key. +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
key + + +String + + + + key can be nested as well like "a.b.c"
defaultValue + + +String + + + + optional default value
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ value for the key or undefined if not found +
+ + + +
+
+ Type +
+
+ +String +| + +Object + + +
+
+ + + + + + + + + + + + + +

getChanges() → {object}

+ + + + + + +
+ get changes as json object +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ returns changes as plain json +
+ + + +
+
+ Type +
+
+ +object + + +
+
+ + + + + + + + + + + + + +

getOrSet(key, value) → {Resource|value}

+ + + + + + +
+ get or set value to resource. +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
key + + +string + + + + key to be get/set
value + + +* + + + + undefined (default) to get value by key, null to remove key, others to set value
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ value or whole object when set +
+ + + +
+
+ Type +
+
+ +Resource +| + +value + + +
+
+ + + + + + +
Example
+ +
// returns Document
+doc.set('key1', 'myvalue')
+   .set('key2', 'val')
+ + + + + + + + + +

isDirty() → {boolean}

+ + + + + + +
+ returns true when there is changes made by client +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ check if document is "dirty" - has local changes +
+ + + +
+
+ Type +
+
+ +boolean + + +
+
+ + + + + + + + + + + + + +

overwrite(values) → {Document}

+ + + + + + +
+ Overwrite document with new allowedValue +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
values + + +Object + + + + new data
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ document object +
+ + + +
+
+ Type +
+
+ +Document + + +
+
+ + + + + + + + + + + + + +

refresh() → {Promise.<Document>}

+ + + + + + +
+ reload document information from backend. +This also revert all client modified data back that is not saved! +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ resolves Document +
+ + + +
+
+ Type +
+
+ +Promise.<Document> + + +
+
+ + + + + + + + + + + + + +

save(retryCount) → {Promise}

+ + + + + + +
+ Save document. If conflicts happen try merge and save again. +if there is no retries left or some server side changes causes conflict +promise is rejected and reason property tells was it no retries left or merge conflicts. +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDefaultDescription
retryCount + + +Number + + + + + + 2 + + count how many times we try to save.
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ Resolves Document itself when save success +
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + + + + + + + + + + +

set(key, value) → {Document}

+ + + + + + +
+ Set value for a key +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
key + + +String + + + + key for update
value + + +* + + + + value for update
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ returns this +
+ + + +
+
+ Type +
+
+ +Document + + +
+
+ + + + + + + + + + + + + +

toJson() → {object}

+ + + + + + +
+ Get resource data as plain json object +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ returns document as plain json +
+ + + +
+
+ Type +
+
+ +object + + +
+
+ + + + + + + + + + + + + +
+ +
+ + + + +
+ + + +
+ + + + + + + \ No newline at end of file diff --git a/docs/opentmi-jsclient/0.8.1/Event.html b/docs/opentmi-jsclient/0.8.1/Event.html new file mode 100644 index 0000000..f5739be --- /dev/null +++ b/docs/opentmi-jsclient/0.8.1/Event.html @@ -0,0 +1,578 @@ + + + + + JSDoc: Class: Event + + + + + + + + + + +
+ +

Class: Event

+ + + + + + +
+ +
+ +

Event(transport, eventJson)

+ + +
+ +
+
+ + + + + + +

new Event(transport, eventJson)

+ + + + + + +
+ Constructor for Resources model +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
transport + + +Transport + + + + Transport object
eventJson + + +Object + + + + User data as plain json object
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + +

Members

+ + + +

(static) PRIORITIES

+ + + + +
+ get PRIORITIES as array +
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + +

Methods

+ + + + + + + +

priority(value) → {Item|string}

+ + + + + + +
+ Get event priority or set it +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
value + + +String + + + + new name
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ returns item name or Item +
+ + + +
+
+ Type +
+
+ +Item +| + +string + + +
+
+ + + + + + + + + + + + + +

toString() → {string}

+ + + + + + +
+ Get resource info as short string +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ user information as single line +
+ + + +
+
+ Type +
+
+ +string + + +
+
+ + + + + + + + + + + + + +
+ +
+ + + + +
+ + + +
+ + + + + + + \ No newline at end of file diff --git a/docs/opentmi-jsclient/0.8.1/Events.html b/docs/opentmi-jsclient/0.8.1/Events.html new file mode 100644 index 0000000..5a9827f --- /dev/null +++ b/docs/opentmi-jsclient/0.8.1/Events.html @@ -0,0 +1,556 @@ + + + + + JSDoc: Class: Events + + + + + + + + + + +
+ +

Class: Events

+ + + + + + +
+ +
+ +

Events(transport)

+ + +
+ +
+
+ + + + + + +

new Events(transport)

+ + + + + + +
+ Constructor for Resources model +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
transport + + +Transport + + + + transport object
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ + +

Extends

+ + + + +
    +
  • Collection
  • +
+ + + + + + + + + + + + + + + + + +

Methods

+ + + + + + + +

create() → {Event}

+ + + + + + +
+ Create new event +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ event object +
+ + + +
+
+ Type +
+
+ +Event + + +
+
+ + + + + + + + + + + + + +

find() → {UsersQuery}

+ + + + + + +
+ Find Users +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ Returns query object to find Users +
+ + + +
+
+ Type +
+
+ +UsersQuery + + +
+
+ + + + + + + + + + + + + +

update() → {Promise}

+ + + + + + +
+ Update documents +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ not implemented +
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + + + + + + + + + + +
+ +
+ + + + +
+ + + +
+ + + + + + + \ No newline at end of file diff --git a/docs/opentmi-jsclient/0.8.1/EventsQuery.html b/docs/opentmi-jsclient/0.8.1/EventsQuery.html new file mode 100644 index 0000000..9120008 --- /dev/null +++ b/docs/opentmi-jsclient/0.8.1/EventsQuery.html @@ -0,0 +1,2925 @@ + + + + + JSDoc: Class: EventsQuery + + + + + + + + + + +
+ +

Class: EventsQuery

+ + + + + + +
+ +
+ +

EventsQuery()

+ + +
+ +
+
+ + + + + + +

new EventsQuery()

+ + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ + +

Extends

+ + + + + + + + + + + + + + + + + + + + +

Members

+ + + +

query

+ + + + +
+ Return find -part object from query +
+ + + + + + + +
+ + + + + + +
Inherited From:
+
+ + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + +

queryType

+ + + + +
+ Getter for query type. default: find +
+ + + + + + + +
+ + + + + + +
Inherited From:
+
+ + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + +

type

+ + + + +
+ Get query type +'find', 'distinct', ... +
+ + + + + + + +
+ + + + + + +
Inherited From:
+
+ + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + +

Methods

+ + + + + + + +

aggregate() → {MongooseQueryClient}

+ + + + + + +
+ aggregate query +
+ + + + + + + + + + + + + +
+ + + + + + +
Inherited From:
+
+ + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ return itself +
+ + + +
+
+ Type +
+
+ +MongooseQueryClient + + +
+
+ + + + + + + + + + + + + +

asFlat() → {MongooseQueryClient}

+ + + + + + +
+ Result as a flat. +e.g. {"a.b": "b"} +
+ + + + + + + + + + + + + +
+ + + + + + +
Inherited From:
+
+ + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ return itself +
+ + + +
+
+ Type +
+
+ +MongooseQueryClient + + +
+
+ + + + + + + + + + + + + +

asJson() → {MongooseQueryClient}

+ + + + + + +
+ Result as a json +e.g. {"a": {"b": "b"}} +
+ + + + + + + + + + + + + +
+ + + + + + +
Inherited From:
+
+ + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ return itself +
+ + + +
+
+ Type +
+
+ +MongooseQueryClient + + +
+
+ + + + + + + + + + + + + +

count() → {MongooseQueryClient}

+ + + + + + +
+ get just count of match document +
+ + + + + + + + + + + + + +
+ + + + + + +
Inherited From:
+
+ + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ return itself +
+ + + +
+
+ Type +
+
+ +MongooseQueryClient + + +
+
+ + + + + + + + + + + + + +

distinct() → {MongooseQueryClient}

+ + + + + + +
+ do distinct query +
+ + + + + + + + + + + + + +
+ + + + + + +
Inherited From:
+
+ + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ return itself +
+ + + +
+
+ Type +
+
+ +MongooseQueryClient + + +
+
+ + + + + + + + + + + + + +

exec(plain) → {Promise}

+ + + + + + +
+ Execute query based on previous selected options +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDefaultDescription
plain + + +Boolean + + + + + + false + + do not convert to classes
+ + + + + + +
+ + + + + + +
Inherited From:
+
+ + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ - list of objects when 'find' (default) or plain json. +
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + + + + + + + + + + +

facility(value) → {Query}

+ + + + + + +
+ Set/Get facility +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
value + + +string + + + + -
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ - +
+ + + +
+
+ Type +
+
+ +Query + + +
+
+ + + + + + + + + + + + + +

find() → {MongooseQueryClient}

+ + + + + + +
+ do default find query +
+ + + + + + + + + + + + + +
+ + + + + + +
Inherited From:
+
+ + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ returns itself +
+ + + +
+
+ Type +
+
+ +MongooseQueryClient + + +
+
+ + + + + + + + + + + + + +

findOne() → {MongooseQueryClient}

+ + + + + + +
+ fetch only first match document +
+ + + + + + + + + + + + + +
+ + + + + + +
Inherited From:
+
+ + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ return itself +
+ + + +
+
+ Type +
+
+ +MongooseQueryClient + + +
+
+ + + + + + + + + + + + + +

fromString(str) → {MongooseQueryClient}

+ + + + + + +
+ parse query from string +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
str + + +String + + + + uri parameters as a string
+ + + + + + +
+ + + + + + +
Inherited From:
+
+ + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ returns itself +
+ + + +
+
+ Type +
+
+ +MongooseQueryClient + + +
+
+ + + + + + + + + + + + + +

has(something) → {MongooseQueryClient}

+ + + + + + +
+ Document has "something", e.g. {name: "jussi"} +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
something + + +object + + + + object to be included in query
+ + + + + + +
+ + + + + + +
Inherited From:
+
+ + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ return itself +
+ + + +
+
+ Type +
+
+ +MongooseQueryClient + + +
+
+ + + + + + +
Example
+ +
MongooseQueryClient
+   .has({'a': 'b'})
+   .has({'a': 'b'})
+ + + + + + + + + +

limit(limit) → {MongooseQueryClient}

+ + + + + + +
+ limit results +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
limit + + +number + + + + maximum number of results to be fetched
+ + + + + + +
+ + + + + + +
Inherited From:
+
+ + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ return itself +
+ + + +
+
+ Type +
+
+ +MongooseQueryClient + + +
+
+ + + + + + + + + + + + + +

mapReduce(mapFunction) → {MongooseQueryClient}

+ + + + + + +
+ mapReduce +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
mapFunction + + +function +| + +String + + + + map function
+ + + + + + +
+ + + + + + +
Inherited From:
+
+ + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ return itself +
+ + + +
+
+ Type +
+
+ +MongooseQueryClient + + +
+
+ + + + + + + + + + + + + +

populate(fields) → {MongooseQueryClient}

+ + + + + + +
+ Populate selected fields +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
fields + + +array.<string> +| + +String +| + +Object + + + + field(s) to be populated
+ + + + + + +
+ + + + + + +
Inherited From:
+
+ + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ return itself +
+ + + +
+
+ Type +
+
+ +MongooseQueryClient + + +
+
+ + + + + + + + + + + + + +

priority(value) → {Query}

+ + + + + + +
+ Set/Get priority +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
value + + +string + + + + -
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ - +
+ + + +
+
+ Type +
+
+ +Query + + +
+
+ + + + + + + + + + + + + +

select(fields) → {MongooseQueryClient}

+ + + + + + +
+ Select fields +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
fields + + +array.<String> + + + + to be fetch, e.g. ['name']
+ + + + + + +
+ + + + + + +
Inherited From:
+
+ + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ return itself +
+ + + +
+
+ Type +
+
+ +MongooseQueryClient + + +
+
+ + + + + + + + + + + + + +

skip(skip) → {MongooseQueryClient}

+ + + + + + +
+ Skip number of results +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
skip + + +number + + + + number of document to be skip
+ + + + + + +
+ + + + + + +
Inherited From:
+
+ + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ return itself +
+ + + +
+
+ Type +
+
+ +MongooseQueryClient + + +
+
+ + + + + + + + + + + + + +

toString() → {string}

+ + + + + + +
+ Returns query as a url string +
+ + + + + + + + + + + + + +
+ + + + + + +
Inherited From:
+
+ + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ returns query as a url parameters string +
+ + + +
+
+ Type +
+
+ +string + + +
+
+ + + + + + + + + + + + + +
+ +
+ + + + +
+ + + +
+ + + + + + + \ No newline at end of file diff --git a/docs/opentmi-jsclient/0.8.1/Group.html b/docs/opentmi-jsclient/0.8.1/Group.html new file mode 100644 index 0000000..10864cd --- /dev/null +++ b/docs/opentmi-jsclient/0.8.1/Group.html @@ -0,0 +1,526 @@ + + + + + JSDoc: Class: Group + + + + + + + + + + +
+ +

Class: Group

+ + + + + + +
+ +
+ +

Group(transport, groupJson)

+ + +
+ +
+
+ + + + + + +

new Group(transport, groupJson)

+ + + + + + +
+ Constructor for Resources model +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
transport + + +Transport + + + + Transport object
groupJson + + +Object + + + + group as plain json
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + +

Members

+ + + +

name

+ + + + +
+ Get group name +
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + +

Methods

+ + + + + + + +

isAdmin() → {boolean}

+ + + + + + +
+ Check if group is a admin +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ returns true if group is admin +
+ + + +
+
+ Type +
+
+ +boolean + + +
+
+ + + + + + + + + + + + + +

toString() → {string}

+ + + + + + +
+ Get resource info as short string +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ returns group data as single line +
+ + + +
+
+ Type +
+
+ +string + + +
+
+ + + + + + + + + + + + + +
+ +
+ + + + +
+ + + +
+ + + + + + + \ No newline at end of file diff --git a/docs/opentmi-jsclient/0.8.1/Groups.html b/docs/opentmi-jsclient/0.8.1/Groups.html new file mode 100644 index 0000000..1274102 --- /dev/null +++ b/docs/opentmi-jsclient/0.8.1/Groups.html @@ -0,0 +1,448 @@ + + + + + JSDoc: Class: Groups + + + + + + + + + + +
+ +

Class: Groups

+ + + + + + +
+ +
+ +

Groups(transport)

+ + +
+ +
+
+ + + + + + +

new Groups(transport)

+ + + + + + +
+ Constructor for Groups model +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
transport + + +Transport + + + + transport object
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ + +

Extends

+ + + + +
    +
  • Collection
  • +
+ + + + + + + + + + + + + + + + + +

Methods

+ + + + + + + +

find() → {GroupsQuery}

+ + + + + + +
+ Find groups +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ Returns query object to find Groups +
+ + + +
+
+ Type +
+
+ +GroupsQuery + + +
+
+ + + + + + + + + + + + + +

update() → {Promise}

+ + + + + + +
+ Update documents +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ not implemented +
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + + + + + + + + + + +
+ +
+ + + + +
+ + + +
+ + + + + + + \ No newline at end of file diff --git a/docs/opentmi-jsclient/0.8.1/GroupsQuery.html b/docs/opentmi-jsclient/0.8.1/GroupsQuery.html new file mode 100644 index 0000000..c8777a8 --- /dev/null +++ b/docs/opentmi-jsclient/0.8.1/GroupsQuery.html @@ -0,0 +1,2611 @@ + + + + + JSDoc: Class: GroupsQuery + + + + + + + + + + +
+ +

Class: GroupsQuery

+ + + + + + +
+ +
+ +

GroupsQuery()

+ + +
+ +
+
+ + + + + + +

new GroupsQuery()

+ + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ + +

Extends

+ + + + + + + + + + + + + + + + + + + + +

Members

+ + + +

query

+ + + + +
+ Return find -part object from query +
+ + + + + + + +
+ + + + + + +
Inherited From:
+
+ + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + +

queryType

+ + + + +
+ Getter for query type. default: find +
+ + + + + + + +
+ + + + + + +
Inherited From:
+
+ + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + +

type

+ + + + +
+ Get query type +'find', 'distinct', ... +
+ + + + + + + +
+ + + + + + +
Inherited From:
+
+ + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + +

Methods

+ + + + + + + +

aggregate() → {MongooseQueryClient}

+ + + + + + +
+ aggregate query +
+ + + + + + + + + + + + + +
+ + + + + + +
Inherited From:
+
+ + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ return itself +
+ + + +
+
+ Type +
+
+ +MongooseQueryClient + + +
+
+ + + + + + + + + + + + + +

asFlat() → {MongooseQueryClient}

+ + + + + + +
+ Result as a flat. +e.g. {"a.b": "b"} +
+ + + + + + + + + + + + + +
+ + + + + + +
Inherited From:
+
+ + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ return itself +
+ + + +
+
+ Type +
+
+ +MongooseQueryClient + + +
+
+ + + + + + + + + + + + + +

asJson() → {MongooseQueryClient}

+ + + + + + +
+ Result as a json +e.g. {"a": {"b": "b"}} +
+ + + + + + + + + + + + + +
+ + + + + + +
Inherited From:
+
+ + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ return itself +
+ + + +
+
+ Type +
+
+ +MongooseQueryClient + + +
+
+ + + + + + + + + + + + + +

count() → {MongooseQueryClient}

+ + + + + + +
+ get just count of match document +
+ + + + + + + + + + + + + +
+ + + + + + +
Inherited From:
+
+ + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ return itself +
+ + + +
+
+ Type +
+
+ +MongooseQueryClient + + +
+
+ + + + + + + + + + + + + +

distinct() → {MongooseQueryClient}

+ + + + + + +
+ do distinct query +
+ + + + + + + + + + + + + +
+ + + + + + +
Inherited From:
+
+ + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ return itself +
+ + + +
+
+ Type +
+
+ +MongooseQueryClient + + +
+
+ + + + + + + + + + + + + +

exec(plain) → {Promise}

+ + + + + + +
+ Execute query based on previous selected options +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDefaultDescription
plain + + +Boolean + + + + + + false + + do not convert to classes
+ + + + + + +
+ + + + + + +
Inherited From:
+
+ + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ - list of objects when 'find' (default) or plain json. +
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + + + + + + + + + + +

find() → {MongooseQueryClient}

+ + + + + + +
+ do default find query +
+ + + + + + + + + + + + + +
+ + + + + + +
Inherited From:
+
+ + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ returns itself +
+ + + +
+
+ Type +
+
+ +MongooseQueryClient + + +
+
+ + + + + + + + + + + + + +

findOne() → {MongooseQueryClient}

+ + + + + + +
+ fetch only first match document +
+ + + + + + + + + + + + + +
+ + + + + + +
Inherited From:
+
+ + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ return itself +
+ + + +
+
+ Type +
+
+ +MongooseQueryClient + + +
+
+ + + + + + + + + + + + + +

fromString(str) → {MongooseQueryClient}

+ + + + + + +
+ parse query from string +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
str + + +String + + + + uri parameters as a string
+ + + + + + +
+ + + + + + +
Inherited From:
+
+ + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ returns itself +
+ + + +
+
+ Type +
+
+ +MongooseQueryClient + + +
+
+ + + + + + + + + + + + + +

has(something) → {MongooseQueryClient}

+ + + + + + +
+ Document has "something", e.g. {name: "jussi"} +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
something + + +object + + + + object to be included in query
+ + + + + + +
+ + + + + + +
Inherited From:
+
+ + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ return itself +
+ + + +
+
+ Type +
+
+ +MongooseQueryClient + + +
+
+ + + + + + +
Example
+ +
MongooseQueryClient
+   .has({'a': 'b'})
+   .has({'a': 'b'})
+ + + + + + + + + +

limit(limit) → {MongooseQueryClient}

+ + + + + + +
+ limit results +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
limit + + +number + + + + maximum number of results to be fetched
+ + + + + + +
+ + + + + + +
Inherited From:
+
+ + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ return itself +
+ + + +
+
+ Type +
+
+ +MongooseQueryClient + + +
+
+ + + + + + + + + + + + + +

mapReduce(mapFunction) → {MongooseQueryClient}

+ + + + + + +
+ mapReduce +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
mapFunction + + +function +| + +String + + + + map function
+ + + + + + +
+ + + + + + +
Inherited From:
+
+ + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ return itself +
+ + + +
+
+ Type +
+
+ +MongooseQueryClient + + +
+
+ + + + + + + + + + + + + +

populate(fields) → {MongooseQueryClient}

+ + + + + + +
+ Populate selected fields +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
fields + + +array.<string> +| + +String +| + +Object + + + + field(s) to be populated
+ + + + + + +
+ + + + + + +
Inherited From:
+
+ + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ return itself +
+ + + +
+
+ Type +
+
+ +MongooseQueryClient + + +
+
+ + + + + + + + + + + + + +

select(fields) → {MongooseQueryClient}

+ + + + + + +
+ Select fields +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
fields + + +array.<String> + + + + to be fetch, e.g. ['name']
+ + + + + + +
+ + + + + + +
Inherited From:
+
+ + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ return itself +
+ + + +
+
+ Type +
+
+ +MongooseQueryClient + + +
+
+ + + + + + + + + + + + + +

skip(skip) → {MongooseQueryClient}

+ + + + + + +
+ Skip number of results +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
skip + + +number + + + + number of document to be skip
+ + + + + + +
+ + + + + + +
Inherited From:
+
+ + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ return itself +
+ + + +
+
+ Type +
+
+ +MongooseQueryClient + + +
+
+ + + + + + + + + + + + + +

toString() → {string}

+ + + + + + +
+ Returns query as a url string +
+ + + + + + + + + + + + + +
+ + + + + + +
Inherited From:
+
+ + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ returns query as a url parameters string +
+ + + +
+
+ Type +
+
+ +string + + +
+
+ + + + + + + + + + + + + +
+ +
+ + + + +
+ + + +
+ + + + + + + \ No newline at end of file diff --git a/docs/opentmi-jsclient/0.8.1/IsNewDocument.html b/docs/opentmi-jsclient/0.8.1/IsNewDocument.html new file mode 100644 index 0000000..93992ee --- /dev/null +++ b/docs/opentmi-jsclient/0.8.1/IsNewDocument.html @@ -0,0 +1,240 @@ + + + + + JSDoc: Class: IsNewDocument + + + + + + + + + + +
+ +

Class: IsNewDocument

+ + + + + + +
+ +
+ +

IsNewDocument(base) → {NewDocument}

+ + +
+ +
+
+ + + + + + +

new IsNewDocument(base) → {NewDocument}

+ + + + + + +
+ Mix Document object so that it is +possible to store new document +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
base + + +Document + + + + Document object
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ returns mixed Document object +
+ + + +
+
+ Type +
+
+ +NewDocument + + +
+
+ + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + +
+ +
+ + + + +
+ + + +
+ + + + + + + \ No newline at end of file diff --git a/docs/opentmi-jsclient/0.8.1/Item.html b/docs/opentmi-jsclient/0.8.1/Item.html new file mode 100644 index 0000000..ef80d03 --- /dev/null +++ b/docs/opentmi-jsclient/0.8.1/Item.html @@ -0,0 +1,940 @@ + + + + + JSDoc: Class: Item + + + + + + + + + + +
+ +

Class: Item

+ + + + + + +
+ +
+ +

Item(transport, resourceJson)

+ + +
+ +
+
+ + + + + + +

new Item(transport, resourceJson)

+ + + + + + +
+ Manage single resource +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
transport + + +Transport + + + + transport layer
resourceJson + + +object + + + + plain json object
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + +

Methods

+ + + + + + + +

category(value) → {Item|String}

+ + + + + + +
+ Get category or set it +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
value + + +String + + + + new category
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ return category or Item when update new value +
+ + + +
+
+ Type +
+
+ +Item +| + +String + + +
+
+ + + + + + + + + + + + + +

getImage() → {Promise.<buffer>}

+ + + + + + +
+ Get item image as buffer +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ image buffer +
+ + + +
+
+ Type +
+
+ +Promise.<buffer> + + +
+
+ + + + + + + + + + + + + +

manufacturer(name) → {Item|String}

+ + + + + + +
+ Get manufacturer or set it +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
name + + +String + + + + manufacturer name
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ return manufactorer or Item +
+ + + +
+
+ Type +
+
+ +Item +| + +String + + +
+
+ + + + + + + + + + + + + +

name(value) → {Item|string}

+ + + + + + +
+ Get item name or set it +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
value + + +String + + + + new name
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ returns item name or Item +
+ + + +
+
+ Type +
+
+ +Item +| + +string + + +
+
+ + + + + + + + + + + + + +

toString() → {string}

+ + + + + + +
+ Get resource info as short string +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ returns single line about item +
+ + + +
+
+ Type +
+
+ +string + + +
+
+ + + + + + + + + + + + + +
+ +
+ + + + +
+ + + +
+ + + + + + + \ No newline at end of file diff --git a/docs/opentmi-jsclient/0.8.1/Items.html b/docs/opentmi-jsclient/0.8.1/Items.html new file mode 100644 index 0000000..54917db --- /dev/null +++ b/docs/opentmi-jsclient/0.8.1/Items.html @@ -0,0 +1,437 @@ + + + + + JSDoc: Class: Items + + + + + + + + + + +
+ +

Class: Items

+ + + + + + +
+ +
+ +

Items(transport)

+ + +
+ +
+
+ + + + + + +

new Items(transport)

+ + + + + + +
+ Constructor for Items model +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
transport + + +Transport + + + + Transport object
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + +

Methods

+ + + + + + + +

find() → {ResultsQuery}

+ + + + + + +
+ Find Items +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ returns Query object +
+ + + +
+
+ Type +
+
+ +ResultsQuery + + +
+
+ + + + + + + + + + + + + +

update() → {Promise}

+ + + + + + +
+ Update documents +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ not implemented +
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + + + + + + + + + + +
+ +
+ + + + +
+ + + +
+ + + + + + + \ No newline at end of file diff --git a/docs/opentmi-jsclient/0.8.1/ItemsQuery.html b/docs/opentmi-jsclient/0.8.1/ItemsQuery.html new file mode 100644 index 0000000..c20e369 --- /dev/null +++ b/docs/opentmi-jsclient/0.8.1/ItemsQuery.html @@ -0,0 +1,2757 @@ + + + + + JSDoc: Class: ItemsQuery + + + + + + + + + + +
+ +

Class: ItemsQuery

+ + + + + + +
+ +
+ +

ItemsQuery()

+ + +
+ +
+
+ + + + + + +

new ItemsQuery()

+ + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + +

Methods

+ + + + + + + +

available(available) → {ItemsQuery}

+ + + + + + +
+ Find items by availability +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDefaultDescription
available + + +Number + + + + + + 1 + + should be at least 1 or available amount of resources
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ returns this +
+ + + +
+
+ Type +
+
+ +ItemsQuery + + +
+
+ + + + + + + + + + + + + +

barcode(barcode) → {ItemsQuery}

+ + + + + + +
+ Find items by barcode +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
barcode + + +String + + + + barcore to be find
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ returns this +
+ + + +
+
+ Type +
+
+ +ItemsQuery + + +
+
+ + + + + + + + + + + + + +

category(category) → {ItemsQuery}

+ + + + + + +
+ Find items by category +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
category + + +String + + + + resource category, allowed values: +'accessory', 'board', 'component', 'other'
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ returns this +
+ + + +
+
+ Type +
+
+ +ItemsQuery + + +
+
+ + + + + + + + + + + + + +

categoryAccessories() → {ItemsQuery}

+ + + + + + +
+ Find only accessories +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ return this +
+ + + +
+
+ Type +
+
+ +ItemsQuery + + +
+
+ + + + + + + + + + + + + +

categoryBoards() → {ItemsQuery}

+ + + + + + +
+ Find only boards +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ return this +
+ + + +
+
+ Type +
+
+ +ItemsQuery + + +
+
+ + + + + + + + + + + + + +

categoryComponents() → {ItemsQuery}

+ + + + + + +
+ Find only components +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ return this +
+ + + +
+
+ Type +
+
+ +ItemsQuery + + +
+
+ + + + + + + + + + + + + +

categoryOthers() → {ItemsQuery}

+ + + + + + +
+ Find only other category resources +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ return this +
+ + + +
+
+ Type +
+
+ +ItemsQuery + + +
+
+ + + + + + + + + + + + + +

manufacturer(name) → {ItemsQuery}

+ + + + + + +
+ Find items by manufacturer +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
name + + +String + + + + manufacturer
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ return this +
+ + + +
+
+ Type +
+
+ +ItemsQuery + + +
+
+ + + + + + + + + + + + + +

name(name) → {ItemsQuery}

+ + + + + + +
+ Find items by name +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
name + + +String + + + + item name
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ returns this +
+ + + +
+
+ Type +
+
+ +ItemsQuery + + +
+
+ + + + + + + + + + + + + +
+ +
+ + + + + + + +
+ +
+ +

ItemsQuery()

+ + +
+ +
+
+ + + + + + +

new ItemsQuery()

+ + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +
Example
+ +
Loans.find()
+ .loadItems() // populate loan items
+ .loanDate(new Date()) //loaned today
+ .exec() // do query
+ + + + +
+ + + + + + + + + + + + + + + + +

Methods

+ + + + + + + +

available(available) → {ItemsQuery}

+ + + + + + +
+ Find items by availability +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDefaultDescription
available + + +Number + + + + + + 1 + + should be at least 1 or available amount of resources
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ returns this +
+ + + +
+
+ Type +
+
+ +ItemsQuery + + +
+
+ + + + + + + + + + + + + +

barcode(barcode) → {ItemsQuery}

+ + + + + + +
+ Find items by barcode +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
barcode + + +String + + + + barcore to be find
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ returns this +
+ + + +
+
+ Type +
+
+ +ItemsQuery + + +
+
+ + + + + + + + + + + + + +

category(category) → {ItemsQuery}

+ + + + + + +
+ Find items by category +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
category + + +String + + + + resource category, allowed values: +'accessory', 'board', 'component', 'other'
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ returns this +
+ + + +
+
+ Type +
+
+ +ItemsQuery + + +
+
+ + + + + + + + + + + + + +

categoryAccessories() → {ItemsQuery}

+ + + + + + +
+ Find only accessories +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ return this +
+ + + +
+
+ Type +
+
+ +ItemsQuery + + +
+
+ + + + + + + + + + + + + +

categoryBoards() → {ItemsQuery}

+ + + + + + +
+ Find only boards +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ return this +
+ + + +
+
+ Type +
+
+ +ItemsQuery + + +
+
+ + + + + + + + + + + + + +

categoryComponents() → {ItemsQuery}

+ + + + + + +
+ Find only components +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ return this +
+ + + +
+
+ Type +
+
+ +ItemsQuery + + +
+
+ + + + + + + + + + + + + +

categoryOthers() → {ItemsQuery}

+ + + + + + +
+ Find only other category resources +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ return this +
+ + + +
+
+ Type +
+
+ +ItemsQuery + + +
+
+ + + + + + + + + + + + + +

manufacturer(name) → {ItemsQuery}

+ + + + + + +
+ Find items by manufacturer +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
name + + +String + + + + manufacturer
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ return this +
+ + + +
+
+ Type +
+
+ +ItemsQuery + + +
+
+ + + + + + + + + + + + + +

name(name) → {ItemsQuery}

+ + + + + + +
+ Find items by name +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
name + + +String + + + + item name
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ returns this +
+ + + +
+
+ Type +
+
+ +ItemsQuery + + +
+
+ + + + + + + + + + + + + +
+ +
+ + + + +
+ + + +
+ + + + + + + \ No newline at end of file diff --git a/docs/opentmi-jsclient/0.8.1/Loan.html b/docs/opentmi-jsclient/0.8.1/Loan.html new file mode 100644 index 0000000..595d48e --- /dev/null +++ b/docs/opentmi-jsclient/0.8.1/Loan.html @@ -0,0 +1,1205 @@ + + + + + JSDoc: Class: Loan + + + + + + + + + + +
+ +

Class: Loan

+ + + + + + +
+ +
+ +

Loan(transport, resourceJson)

+ + +
+ +
+
+ + + + + + +

new Loan(transport, resourceJson)

+ + + + + + +
+ Manage single resource +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
transport + + +Transport + + + + transport layer
resourceJson + + +object + + + + plain json object
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + +

Methods

+ + + + + + + +

addItem(item) → {LoanItem}

+ + + + + + +
+ Add loan item +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
item + + +Item + + + + object
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ returns Loan +
+ + + +
+
+ Type +
+
+ +LoanItem + + +
+
+ + + + + + + + + + + + + +

loanDate(value) → {Loan|string}

+ + + + + + +
+ Get loan date or set it (admin only) +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
value + + +Date + + + + optional date when updating
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ returns loan date or Loan +
+ + + +
+
+ Type +
+
+ +Loan +| + +string + + +
+
+ + + + + + + + + + + + + +

loaner(value) → {Loan|string}

+ + + + + + +
+ Get loaner or set it (admin only) +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
value + + +String + + + + optoinal loaner id when updating
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ returns loaner id or Loan +
+ + + +
+
+ Type +
+
+ +Loan +| + +string + + +
+
+ + + + + + + + + + + + + +

loanItems() → {LoanItem}

+ + + + + + +
+ Resolve loan items +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ returns LoanItems +
+ + + +
+
+ Type +
+
+ +LoanItem + + +
+
+ + + + + + + + + + + + + +

newLoanItem() → {LoanItem}

+ + + + + + +
+ create new LoanItem class +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ get LoanItem constructor +
+ + + +
+
+ Type +
+
+ +LoanItem + + +
+
+ + + + + + + + + + + + + +

notes(value) → {Loan|String}

+ + + + + + +
+ Get notes or set it (admin only) +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
value + + +Stirng + + + + optional notes when updating
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ returns notes or Loan +
+ + + +
+
+ Type +
+
+ +Loan +| + +String + + +
+
+ + + + + + + + + + + + + +

toString() → {string}

+ + + + + + +
+ Get loan info as short string +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ single line about loan +
+ + + +
+
+ Type +
+
+ +string + + +
+
+ + + + + + + + + + + + + +
+ +
+ + + + +
+ + + +
+ + + + + + + \ No newline at end of file diff --git a/docs/opentmi-jsclient/0.8.1/LoanItem.html b/docs/opentmi-jsclient/0.8.1/LoanItem.html new file mode 100644 index 0000000..3bc710b --- /dev/null +++ b/docs/opentmi-jsclient/0.8.1/LoanItem.html @@ -0,0 +1,1715 @@ + + + + + JSDoc: Class: LoanItem + + + + + + + + + + +
+ +

Class: LoanItem

+ + + + + + +
+ +
+ +

LoanItem(transport, data)

+ + +
+ +
+
+ + + + + + +

new LoanItem(transport, data)

+ + + + + + +
+ LoanItem constructor +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
transport + + +Transport + + + + transport layer
data + + +object + + + + json object
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + +

Members

+ + + +

item

+ + + + +
+ Set item +
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + +

resource

+ + + + +
+ Set resource to loan item +
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + +

Methods

+ + + + + + + +

getItem() → {Item}

+ + + + + + +
+ get Item +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ returns Item +
+ + + +
+
+ Type +
+
+ +Item + + +
+
+ + + + + + + + + + + + + +

getResource() → {Promise.<Resource>}

+ + + + + + +
+ get resource +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ resolves Resource +
+ + + +
+
+ Type +
+
+ +Promise.<Resource> + + +
+
+ + + + + + + + + + + + + +

returnDate() → {Date|undefined}

+ + + + + + +
+ Get return date +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ Date when loan is returned, otherwise undefined. +
+ + + +
+
+ Type +
+
+ +Date +| + +undefined + + +
+
+ + + + + + + + + + + + + +

toJson() → {Object}

+ + + + + + +
+ get item as plain json +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ returns loanitem as plain json +
+ + + +
+
+ Type +
+
+ +Object + + +
+
+ + + + + + + + + + + + + +

toString() → {String}

+ + + + + + +
+ returns loan item as single line +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ loan item details as single line +
+ + + +
+
+ Type +
+
+ +String + + +
+
+ + + + + + + + + + + + + +
+ +
+ + + + + + + +
+ +
+ +

LoanItem()

+ + +
+ +
+
+ + + + + + +

new LoanItem()

+ + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + +

Members

+ + + +

item

+ + + + +
+ Set item +
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + +

resource

+ + + + +
+ Set resource to loan item +
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + +

Methods

+ + + + + + + +

getItem() → {Item}

+ + + + + + +
+ get Item +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ returns Item +
+ + + +
+
+ Type +
+
+ +Item + + +
+
+ + + + + + + + + + + + + +

getResource() → {Promise.<Resource>}

+ + + + + + +
+ get resource +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ resolves Resource +
+ + + +
+
+ Type +
+
+ +Promise.<Resource> + + +
+
+ + + + + + + + + + + + + +

returnDate() → {Date|undefined}

+ + + + + + +
+ Get return date +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ Date when loan is returned, otherwise undefined. +
+ + + +
+
+ Type +
+
+ +Date +| + +undefined + + +
+
+ + + + + + + + + + + + + +

toJson() → {Object}

+ + + + + + +
+ get item as plain json +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ returns loanitem as plain json +
+ + + +
+
+ Type +
+
+ +Object + + +
+
+ + + + + + + + + + + + + +

toString() → {String}

+ + + + + + +
+ returns loan item as single line +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ loan item details as single line +
+ + + +
+
+ Type +
+
+ +String + + +
+
+ + + + + + + + + + + + + +
+ +
+ + + + +
+ + + +
+ + + + + + + \ No newline at end of file diff --git a/docs/opentmi-jsclient/0.8.1/Loans.html b/docs/opentmi-jsclient/0.8.1/Loans.html new file mode 100644 index 0000000..2dac5c8 --- /dev/null +++ b/docs/opentmi-jsclient/0.8.1/Loans.html @@ -0,0 +1,621 @@ + + + + + JSDoc: Class: Loans + + + + + + + + + + +
+ +

Class: Loans

+ + + + + + +
+ +
+ +

Loans(transport)

+ +
Manage Loans
+ + +
+ +
+
+ + + + +

Constructor

+ + + +

new Loans(transport)

+ + + + + + +
+ Constructor for Loans model +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
transport + + +Transport + + + + Transport object
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + +

Methods

+ + + + + + + +

(static) forUser(user, transport) → {Promise.<Array.<Loan>>}

+ + + + + + +
+ Find loans by user +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
user + + +User + + + + user object
transport + + +Transport + + + + transport layer
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ resolves Loans +
+ + + +
+
+ Type +
+
+ +Promise.<Array.<Loan>> + + +
+
+ + + + + + + + + + + + + +

find() → {LoansQuery}

+ + + + + + +
+ Construct Loans query object +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ return loans query +
+ + + +
+
+ Type +
+
+ +LoansQuery + + +
+
+ + + + + + + + + + + + + +

update() → {Promise}

+ + + + + + +
+ Update documents +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ not implemented +
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + + + + + + + + + + +
+ +
+ + + + +
+ + + +
+ + + + + + + \ No newline at end of file diff --git a/docs/opentmi-jsclient/0.8.1/Lock.html b/docs/opentmi-jsclient/0.8.1/Lock.html new file mode 100644 index 0000000..27fe7fe --- /dev/null +++ b/docs/opentmi-jsclient/0.8.1/Lock.html @@ -0,0 +1,550 @@ + + + + + JSDoc: Class: Lock + + + + + + + + + + +
+ +

Class: Lock

+ + + + + + +
+ +
+ +

Lock()

+ + +
+ +
+
+ + + + + + +

new Lock()

+ + + + + + +
+ Lock Constructor +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + +

Methods

+ + + + + + + +

isResolved() → {Boolean}

+ + + + + + +
+ Check if no pending actions +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ True if lock is free +
+ + + +
+
+ Type +
+
+ +Boolean + + +
+
+ + + + + + + + + + + + + +

obtainLock() → {Promise.disposer}

+ + + + + + +
+ Obtain lock. Pending actions will be wait. +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ Disposer to be used with Promise.using() +
+ + + +
+
+ Type +
+
+ +Promise.disposer + + +
+
+ + + + + + +
Example
+ +
Promise.using(lock.obtainLock(), () => Promise.resolve());
+ + + + + + + + + +

withLock(then) → {Promise}

+ + + + + + +
+ Run promise with lock. Parallel promises will be postponed until previous is fulfilled. +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
then + + +function + + + + Promise function to be call
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ resolves/rejects argument given "then" +
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + + + + + + + + + + +
+ +
+ + + + +
+ + + +
+ + + + + + + \ No newline at end of file diff --git a/docs/opentmi-jsclient/0.8.1/MongooseQueryClient.html b/docs/opentmi-jsclient/0.8.1/MongooseQueryClient.html new file mode 100644 index 0000000..549bd1e --- /dev/null +++ b/docs/opentmi-jsclient/0.8.1/MongooseQueryClient.html @@ -0,0 +1,2358 @@ + + + + + JSDoc: Class: MongooseQueryClient + + + + + + + + + + +
+ +

Class: MongooseQueryClient

+ + + + + + +
+ +
+ +

MongooseQueryClient()

+ +
Query class +Is pair for mongoose-query -library which allows to +construct DB queries based on rest query parameters
+ + +
+ +
+
+ + + + +

Constructor

+ + + +

new MongooseQueryClient()

+ + + + + + +
+ Query Constructor +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + +
Example
+ +
mongooseQuery
+  .skip(10)      // skip first 10 docs
+  .limit(10)     // fetch only 10 docs
+  .has({a: '1'}) // find docs where a == '1'
+ + + + +
+ + + + + + + + + + + + + + +

Members

+ + + +

query

+ + + + +
+ Return find -part object from query +
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + +

queryType

+ + + + +
+ Getter for query type. default: find +
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + +

type

+ + + + +
+ Get query type +'find', 'distinct', ... +
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + +

Methods

+ + + + + + + +

aggregate() → {MongooseQueryClient}

+ + + + + + +
+ aggregate query +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ return itself +
+ + + +
+
+ Type +
+
+ +MongooseQueryClient + + +
+
+ + + + + + + + + + + + + +

asFlat() → {MongooseQueryClient}

+ + + + + + +
+ Result as a flat. +e.g. {"a.b": "b"} +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ return itself +
+ + + +
+
+ Type +
+
+ +MongooseQueryClient + + +
+
+ + + + + + + + + + + + + +

asJson() → {MongooseQueryClient}

+ + + + + + +
+ Result as a json +e.g. {"a": {"b": "b"}} +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ return itself +
+ + + +
+
+ Type +
+
+ +MongooseQueryClient + + +
+
+ + + + + + + + + + + + + +

count() → {MongooseQueryClient}

+ + + + + + +
+ get just count of match document +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ return itself +
+ + + +
+
+ Type +
+
+ +MongooseQueryClient + + +
+
+ + + + + + + + + + + + + +

distinct() → {MongooseQueryClient}

+ + + + + + +
+ do distinct query +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ return itself +
+ + + +
+
+ Type +
+
+ +MongooseQueryClient + + +
+
+ + + + + + + + + + + + + +

find() → {MongooseQueryClient}

+ + + + + + +
+ do default find query +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ returns itself +
+ + + +
+
+ Type +
+
+ +MongooseQueryClient + + +
+
+ + + + + + + + + + + + + +

findOne() → {MongooseQueryClient}

+ + + + + + +
+ fetch only first match document +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ return itself +
+ + + +
+
+ Type +
+
+ +MongooseQueryClient + + +
+
+ + + + + + + + + + + + + +

fromString(str) → {MongooseQueryClient}

+ + + + + + +
+ parse query from string +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
str + + +String + + + + uri parameters as a string
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ returns itself +
+ + + +
+
+ Type +
+
+ +MongooseQueryClient + + +
+
+ + + + + + + + + + + + + +

has(something) → {MongooseQueryClient}

+ + + + + + +
+ Document has "something", e.g. {name: "jussi"} +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
something + + +object + + + + object to be included in query
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ return itself +
+ + + +
+
+ Type +
+
+ +MongooseQueryClient + + +
+
+ + + + + + +
Example
+ +
MongooseQueryClient
+   .has({'a': 'b'})
+   .has({'a': 'b'})
+ + + + + + + + + +

limit(limit) → {MongooseQueryClient}

+ + + + + + +
+ limit results +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
limit + + +number + + + + maximum number of results to be fetched
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ return itself +
+ + + +
+
+ Type +
+
+ +MongooseQueryClient + + +
+
+ + + + + + + + + + + + + +

mapReduce(mapFunction) → {MongooseQueryClient}

+ + + + + + +
+ mapReduce +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
mapFunction + + +function +| + +String + + + + map function
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ return itself +
+ + + +
+
+ Type +
+
+ +MongooseQueryClient + + +
+
+ + + + + + + + + + + + + +

populate(fields) → {MongooseQueryClient}

+ + + + + + +
+ Populate selected fields +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
fields + + +array.<string> +| + +String +| + +Object + + + + field(s) to be populated
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ return itself +
+ + + +
+
+ Type +
+
+ +MongooseQueryClient + + +
+
+ + + + + + + + + + + + + +

select(fields) → {MongooseQueryClient}

+ + + + + + +
+ Select fields +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
fields + + +array.<String> + + + + to be fetch, e.g. ['name']
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ return itself +
+ + + +
+
+ Type +
+
+ +MongooseQueryClient + + +
+
+ + + + + + + + + + + + + +

skip(skip) → {MongooseQueryClient}

+ + + + + + +
+ Skip number of results +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
skip + + +number + + + + number of document to be skip
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ return itself +
+ + + +
+
+ Type +
+
+ +MongooseQueryClient + + +
+
+ + + + + + + + + + + + + +

toString() → {string}

+ + + + + + +
+ Returns query as a url string +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ returns query as a url parameters string +
+ + + +
+
+ Type +
+
+ +string + + +
+
+ + + + + + + + + + + + + +
+ +
+ + + + +
+ + + +
+ + + + + + + \ No newline at end of file diff --git a/docs/opentmi-jsclient/0.8.1/QueryBase.html b/docs/opentmi-jsclient/0.8.1/QueryBase.html new file mode 100644 index 0000000..be33012 --- /dev/null +++ b/docs/opentmi-jsclient/0.8.1/QueryBase.html @@ -0,0 +1,2682 @@ + + + + + JSDoc: Class: QueryBase + + + + + + + + + + +
+ +

Class: QueryBase

+ + + + + + +
+ +
+ +

QueryBase(collection, baseClass)

+ + +
+ +
+
+ + + + + + +

new QueryBase(collection, baseClass)

+ + + + + + +
+ Constructor for QueryBase +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
collection + + +Collection + + + + collection object
baseClass + + +Document + + + + Class that collection holds
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ + +

Extends

+ + + + + + + + + + + + + + + + + + + + +

Members

+ + + +

query

+ + + + +
+ Return find -part object from query +
+ + + + + + + +
+ + + + + + +
Inherited From:
+
+ + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + +

queryType

+ + + + +
+ Getter for query type. default: find +
+ + + + + + + +
+ + + + + + +
Inherited From:
+
+ + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + +

type

+ + + + +
+ Get query type +'find', 'distinct', ... +
+ + + + + + + +
+ + + + + + +
Inherited From:
+
+ + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + +

Methods

+ + + + + + + +

aggregate() → {MongooseQueryClient}

+ + + + + + +
+ aggregate query +
+ + + + + + + + + + + + + +
+ + + + + + +
Inherited From:
+
+ + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ return itself +
+ + + +
+
+ Type +
+
+ +MongooseQueryClient + + +
+
+ + + + + + + + + + + + + +

asFlat() → {MongooseQueryClient}

+ + + + + + +
+ Result as a flat. +e.g. {"a.b": "b"} +
+ + + + + + + + + + + + + +
+ + + + + + +
Inherited From:
+
+ + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ return itself +
+ + + +
+
+ Type +
+
+ +MongooseQueryClient + + +
+
+ + + + + + + + + + + + + +

asJson() → {MongooseQueryClient}

+ + + + + + +
+ Result as a json +e.g. {"a": {"b": "b"}} +
+ + + + + + + + + + + + + +
+ + + + + + +
Inherited From:
+
+ + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ return itself +
+ + + +
+
+ Type +
+
+ +MongooseQueryClient + + +
+
+ + + + + + + + + + + + + +

count() → {MongooseQueryClient}

+ + + + + + +
+ get just count of match document +
+ + + + + + + + + + + + + +
+ + + + + + +
Inherited From:
+
+ + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ return itself +
+ + + +
+
+ Type +
+
+ +MongooseQueryClient + + +
+
+ + + + + + + + + + + + + +

distinct() → {MongooseQueryClient}

+ + + + + + +
+ do distinct query +
+ + + + + + + + + + + + + +
+ + + + + + +
Inherited From:
+
+ + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ return itself +
+ + + +
+
+ Type +
+
+ +MongooseQueryClient + + +
+
+ + + + + + + + + + + + + +

exec(plain) → {Promise}

+ + + + + + +
+ Execute query based on previous selected options +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDefaultDescription
plain + + +Boolean + + + + + + false + + do not convert to classes
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ - list of objects when 'find' (default) or plain json. +
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + + + + + + + + + + +

find() → {MongooseQueryClient}

+ + + + + + +
+ do default find query +
+ + + + + + + + + + + + + +
+ + + + + + +
Inherited From:
+
+ + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ returns itself +
+ + + +
+
+ Type +
+
+ +MongooseQueryClient + + +
+
+ + + + + + + + + + + + + +

findOne() → {MongooseQueryClient}

+ + + + + + +
+ fetch only first match document +
+ + + + + + + + + + + + + +
+ + + + + + +
Inherited From:
+
+ + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ return itself +
+ + + +
+
+ Type +
+
+ +MongooseQueryClient + + +
+
+ + + + + + + + + + + + + +

fromString(str) → {MongooseQueryClient}

+ + + + + + +
+ parse query from string +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
str + + +String + + + + uri parameters as a string
+ + + + + + +
+ + + + + + +
Inherited From:
+
+ + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ returns itself +
+ + + +
+
+ Type +
+
+ +MongooseQueryClient + + +
+
+ + + + + + + + + + + + + +

has(something) → {MongooseQueryClient}

+ + + + + + +
+ Document has "something", e.g. {name: "jussi"} +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
something + + +object + + + + object to be included in query
+ + + + + + +
+ + + + + + +
Inherited From:
+
+ + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ return itself +
+ + + +
+
+ Type +
+
+ +MongooseQueryClient + + +
+
+ + + + + + +
Example
+ +
MongooseQueryClient
+   .has({'a': 'b'})
+   .has({'a': 'b'})
+ + + + + + + + + +

limit(limit) → {MongooseQueryClient}

+ + + + + + +
+ limit results +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
limit + + +number + + + + maximum number of results to be fetched
+ + + + + + +
+ + + + + + +
Inherited From:
+
+ + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ return itself +
+ + + +
+
+ Type +
+
+ +MongooseQueryClient + + +
+
+ + + + + + + + + + + + + +

mapReduce(mapFunction) → {MongooseQueryClient}

+ + + + + + +
+ mapReduce +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
mapFunction + + +function +| + +String + + + + map function
+ + + + + + +
+ + + + + + +
Inherited From:
+
+ + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ return itself +
+ + + +
+
+ Type +
+
+ +MongooseQueryClient + + +
+
+ + + + + + + + + + + + + +

populate(fields) → {MongooseQueryClient}

+ + + + + + +
+ Populate selected fields +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
fields + + +array.<string> +| + +String +| + +Object + + + + field(s) to be populated
+ + + + + + +
+ + + + + + +
Inherited From:
+
+ + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ return itself +
+ + + +
+
+ Type +
+
+ +MongooseQueryClient + + +
+
+ + + + + + + + + + + + + +

select(fields) → {MongooseQueryClient}

+ + + + + + +
+ Select fields +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
fields + + +array.<String> + + + + to be fetch, e.g. ['name']
+ + + + + + +
+ + + + + + +
Inherited From:
+
+ + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ return itself +
+ + + +
+
+ Type +
+
+ +MongooseQueryClient + + +
+
+ + + + + + + + + + + + + +

skip(skip) → {MongooseQueryClient}

+ + + + + + +
+ Skip number of results +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
skip + + +number + + + + number of document to be skip
+ + + + + + +
+ + + + + + +
Inherited From:
+
+ + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ return itself +
+ + + +
+
+ Type +
+
+ +MongooseQueryClient + + +
+
+ + + + + + + + + + + + + +

toString() → {string}

+ + + + + + +
+ Returns query as a url string +
+ + + + + + + + + + + + + +
+ + + + + + +
Inherited From:
+
+ + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ returns query as a url parameters string +
+ + + +
+
+ Type +
+
+ +string + + +
+
+ + + + + + + + + + + + + +
+ +
+ + + + +
+ + + +
+ + + + + + + \ No newline at end of file diff --git a/docs/opentmi-jsclient/0.8.1/Resource.html b/docs/opentmi-jsclient/0.8.1/Resource.html new file mode 100644 index 0000000..660194c --- /dev/null +++ b/docs/opentmi-jsclient/0.8.1/Resource.html @@ -0,0 +1,818 @@ + + + + + JSDoc: Class: Resource + + + + + + + + + + +
+ +

Class: Resource

+ + + + + + +
+ +
+ +

Resource(transport, resourceJson)

+ + +
+ +
+
+ + + + + + +

new Resource(transport, resourceJson)

+ + + + + + +
+ Manage single resource +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
transport + + +Transport + + + + transport layer
resourceJson + + +object + + + + plain json object
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + +

Members

+ + + +

hw

+ + + + +
+ Manage hw informations +
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + +
Example
+ +
doc
+ .hw.sn('123')
+ .hw.imei('12334')
+ .hw.firmware.name('aa')
+ .hw.firmware.version('1.0.0')
+ + + + + +

location

+ + + + +
+ Manage location information +
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + +
Example
+ +
// set site and country
+  doc
+   .location.site('oulu')
+   .location.country('finland')
+ 
+ + + + + + + +

Methods

+ + + + + + + +

name(value) → {string|Resource}

+ + + + + + +
+ Get resource name or set it +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
value + + +String + + + + resource name
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ resource name or Resource object +
+ + + +
+
+ Type +
+
+ +string +| + +Resource + + +
+
+ + + + + + + + + + + + + +

toString() → {string}

+ + + + + + +
+ Get resource info as short string +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ single line of resource data +
+ + + +
+
+ Type +
+
+ +string + + +
+
+ + + + + + + + + + + + + +

type(value) → {Resource|String}

+ + + + + + +
+ Get resource type of set it +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
value + + +String + + + + resource type
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ resource type of Resource object +
+ + + +
+
+ Type +
+
+ +Resource +| + +String + + +
+
+ + + + + + + + + + + + + +
+ +
+ + + + +
+ + + +
+ + + + + + + \ No newline at end of file diff --git a/docs/opentmi-jsclient/0.8.1/Resources.html b/docs/opentmi-jsclient/0.8.1/Resources.html new file mode 100644 index 0000000..6a51acf --- /dev/null +++ b/docs/opentmi-jsclient/0.8.1/Resources.html @@ -0,0 +1,545 @@ + + + + + JSDoc: Class: Resources + + + + + + + + + + +
+ +

Class: Resources

+ + + + + + +
+ +
+ +

Resources(transport)

+ + +
+ +
+
+ + + + + + +

new Resources(transport)

+ + + + + + +
+ Constructor for Resources model +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
transport + + +Transport + + + + transport object
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + +

Methods

+ + + + + + + +

create() → {Resource}

+ + + + + + +
+ Create new Resource +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ returns new result +
+ + + +
+
+ Type +
+
+ +Resource + + +
+
+ + + + + + + + + + + + + +

find() → {ResourcesQuery}

+ + + + + + +
+ Find Resources +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ returns Query object +
+ + + +
+
+ Type +
+
+ +ResourcesQuery + + +
+
+ + + + + + + + + + + + + +

update() → {Promise}

+ + + + + + +
+ Update documents +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ not implemented +
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + + + + + + + + + + +
+ +
+ + + + +
+ + + +
+ + + + + + + \ No newline at end of file diff --git a/docs/opentmi-jsclient/0.8.1/ResourcesQuery.html b/docs/opentmi-jsclient/0.8.1/ResourcesQuery.html new file mode 100644 index 0000000..5d9c153 --- /dev/null +++ b/docs/opentmi-jsclient/0.8.1/ResourcesQuery.html @@ -0,0 +1,1724 @@ + + + + + JSDoc: Class: ResourcesQuery + + + + + + + + + + +
+ +

Class: ResourcesQuery

+ + + + + + +
+ +
+ +

ResourcesQuery()

+ + +
+ +
+
+ + + + + + +

new ResourcesQuery()

+ + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + +

Methods

+ + + + + + + +

hasNoParent() → {ResourcesQuery}

+ + + + + + +
+ Resource doesn't have parent +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ returns this +
+ + + +
+
+ Type +
+
+ +ResourcesQuery + + +
+
+ + + + + + + + + + + + + +

hasParent(id) → {ResourcesQuery}

+ + + + + + +
+ Resource has parent +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +String + + + + optional parent resource id
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ returns this +
+ + + +
+
+ Type +
+
+ +ResourcesQuery + + +
+
+ + + + + + + + + + + + + +

haveTag(tag, isTrue) → {ResourcesQuery}

+ + + + + + +
+ Find resources by a tag +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDefaultDescription
tag + + +string + + + + + + tag name
isTrue + + +bool + + + + + + true + + tag value, optional. default: true
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ returns this +
+ + + +
+
+ Type +
+
+ +ResourcesQuery + + +
+
+ + + + + + + + + + + + + +

haveTags(tags) → {ResourcesQuery}

+ + + + + + +
+ Find resources by multiple tags +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
tags + + +array.<String> + + + + array of tag names
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ returns this +
+ + + +
+
+ Type +
+
+ +ResourcesQuery + + +
+
+ + + + + + + + + + + + + +

hwid(id) → {ResourcesQuery}

+ + + + + + +
+ Find resources by hwid +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +String + + + + hardware id as a string
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ returns this +
+ + + +
+
+ Type +
+
+ +ResourcesQuery + + +
+
+ + + + + + + + + + + + + +

hwsn(sn) → {ResourcesQuery}

+ + + + + + +
+ Find resources by serial number +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
sn + + +String + + + + hardware serial number as a string
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ returns this +
+ + + +
+
+ Type +
+
+ +ResourcesQuery + + +
+
+ + + + + + + + + + + + + +

name(name) → {ResourcesQuery}

+ + + + + + +
+ Find resources with name +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
name + + +string + + + + resource name
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ returns this +
+ + + +
+
+ Type +
+
+ +ResourcesQuery + + +
+
+ + + + + + + + + + + + + +

status(status) → {ResourcesQuery}

+ + + + + + +
+ Find resources by status +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
status + + +string + + + + resource status. One of 'active', 'maintenance', 'broken'
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ returns this +
+ + + +
+
+ Type +
+
+ +ResourcesQuery + + +
+
+ + + + + + + + + + + + + +

type(type) → {ResourcesQuery}

+ + + + + + +
+ Find resources by type +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
type + + +string + + + + resource type
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ returns this +
+ + + +
+
+ Type +
+
+ +ResourcesQuery + + +
+
+ + + + + + + + + + + + + +

usageType(usageType) → {ResourcesQuery}

+ + + + + + +
+ Find resources by usage type +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
usageType + + +String + + + + resource usage type
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ returns this +
+ + + +
+
+ Type +
+
+ +ResourcesQuery + + +
+
+ + + + + + + + + + + + + +
+ +
+ + + + +
+ + + +
+ + + + + + + \ No newline at end of file diff --git a/docs/opentmi-jsclient/0.8.1/Results.html b/docs/opentmi-jsclient/0.8.1/Results.html new file mode 100644 index 0000000..aa6c037 --- /dev/null +++ b/docs/opentmi-jsclient/0.8.1/Results.html @@ -0,0 +1,1128 @@ + + + + + JSDoc: Class: Results + + + + + + + + + + +
+ +

Class: Results

+ + + + + + +
+ +
+ +

Results(transport)

+ + +
+ +
+
+ + + + + + +

new Results(transport)

+ + + + + + +
+ Constructor for Resources model +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
transport + + +Transport + + + + Transport object
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + +

Methods

+ + + + + + + +

connect() → {Promise}

+ + + + + + +
+ connects to results related sio namespace +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ resolves when connected +
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + + + + + + + + + + +

create() → {Result}

+ + + + + + +
+ Create new Result +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ returns new result +
+ + + +
+
+ Type +
+
+ +Result + + +
+
+ + + + + + + + + + + + + +

disconnect() → {Promise}

+ + + + + + +
+ Disconnect results related sio namespace +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ resolves when disconnected +
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + + + + + + + + + + +

find() → {ResultsQuery}

+ + + + + + +
+ Find Results +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ returns ResultsQuery object +
+ + + +
+
+ Type +
+
+ +ResultsQuery + + +
+
+ + + + + + +
Example
+ +
Results.find()
+   .limit(10)
+   .exec() // find last 10 results
+ + + + + + + + + +

on(event, callback) → {Promise}

+ + + + + + +
+ Listen results related events +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
event + + +String + + + + event to be listen. Supported events: 'new'
callback + + +function + + + + callback which is called when event received
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ resolves when start listening +
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + + + + + + + + + + +

removeListener(event, callback) → {Promise}

+ + + + + + +
+ remove event listener +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
event + + +String + + + + event name
callback + + +function + + + + callback to be removed
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ resolves when ready +
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + + + + + + + + + + +

update() → {Promise}

+ + + + + + +
+ Update documents +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ not implemented +
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + + + + + + + + + + +
+ +
+ + + + +
+ + + +
+ + + + + + + \ No newline at end of file diff --git a/docs/opentmi-jsclient/0.8.1/ResultsQuery.html b/docs/opentmi-jsclient/0.8.1/ResultsQuery.html new file mode 100644 index 0000000..8f5f869 --- /dev/null +++ b/docs/opentmi-jsclient/0.8.1/ResultsQuery.html @@ -0,0 +1,1228 @@ + + + + + JSDoc: Class: ResultsQuery + + + + + + + + + + +
+ +

Class: ResultsQuery

+ + + + + + +
+ +
+ +

ResultsQuery()

+ + +
+ +
+
+ + + + + + +

new ResultsQuery()

+ + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + +

Methods

+ + + + + + + +

belongToCampaign(campaign) → {ResultsQuery}

+ + + + + + +
+ Find results which belong to campaign +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
campaign + + +String + + + + Campaign name
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ returns this +
+ + + +
+
+ Type +
+
+ +ResultsQuery + + +
+
+ + + + + + + + + + + + + +

belongToJob(job) → {ResultsQuery}

+ + + + + + +
+ Find results which belong to job +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
job + + +String + + + + job name
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ returns this +
+ + + +
+
+ Type +
+
+ +ResultsQuery + + +
+
+ + + + + + + + + + + + + +

containsNote(str) → {ResultsQuery}

+ + + + + + +
+ Find results which note contains text +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
str + + +String + + + + string that contains in note
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ returns this +
+ + + +
+
+ Type +
+
+ +ResultsQuery + + +
+
+ + + + + + + + + + + + + +

isFailed() → {ResultsQuery}

+ + + + + + +
+ Find failed test results +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ returns this +
+ + + +
+
+ Type +
+
+ +ResultsQuery + + +
+
+ + + + + + + + + + + + + +

isHW() → {ResultsQuery}

+ + + + + + +
+ Find results which are using hw dut(s) +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ returns this +
+ + + +
+
+ Type +
+
+ +ResultsQuery + + +
+
+ + + + + + + + + + + + + +

isInconclusive() → {ResultsQuery}

+ + + + + + +
+ Find inconclusive results +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ returns this +
+ + + +
+
+ Type +
+
+ +ResultsQuery + + +
+
+ + + + + + + + + + + + + +

isPass() → {ResultsQuery}

+ + + + + + +
+ Find pass test results +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ returns this +
+ + + +
+
+ Type +
+
+ +ResultsQuery + + +
+
+ + + + + + + + + + + + + +

verdict(verdict) → {ResultsQuery}

+ + + + + + +
+ Find results by verdict +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
verdict + + +String + + + + test verdict
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ returns this +
+ + + +
+
+ Type +
+
+ +ResultsQuery + + +
+
+ + + + + + + + + + + + + +
+ +
+ + + + +
+ + + +
+ + + + + + + \ No newline at end of file diff --git a/docs/opentmi-jsclient/0.8.1/Schemas.html b/docs/opentmi-jsclient/0.8.1/Schemas.html new file mode 100644 index 0000000..0b2ba78 --- /dev/null +++ b/docs/opentmi-jsclient/0.8.1/Schemas.html @@ -0,0 +1,600 @@ + + + + + JSDoc: Class: Schemas + + + + + + + + + + +
+ +

Class: Schemas

+ + + + + + +
+ +
+ +

Schemas(transport)

+ +
Schemas object
+ + +
+ +
+
+ + + + +

Constructor

+ + + +

new Schemas(transport)

+ + + + + + +
+ Constructor for Schemas controller. +Object manage all low level communication and authentication +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
transport + + +Transport + + + + transport layer for communication
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + +

Methods

+ + + + + + + +

collections() → {Promise.<array.<string>>}

+ + + + + + +
+ Get list of available collection names +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ list of collections +
+ + + +
+
+ Type +
+
+ +Promise.<array.<string>> + + +
+
+ + + + + + + + + + + + + +

getAllSchemas() → {Promise.<Array.<Object>>}

+ + + + + + +
+ get all schemas +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ resolves array of schema objects +
+ + + +
+
+ Type +
+
+ +Promise.<Array.<Object>> + + +
+
+ + + + + + + + + + + + + +

schema(collection) → {Promise.<object>}

+ + + + + + +
+ Get collection json schema. +This can be used for example generate html forms. +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
collection + + +String + + + + collection name
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ resolves collection schema as json-schema -format +
+ + + +
+
+ Type +
+
+ +Promise.<object> + + +
+
+ + + + + + + + + + + + + +
+ +
+ + + + +
+ + + +
+ + + + + + + \ No newline at end of file diff --git a/docs/opentmi-jsclient/0.8.1/Testcases.html b/docs/opentmi-jsclient/0.8.1/Testcases.html new file mode 100644 index 0000000..412a651 --- /dev/null +++ b/docs/opentmi-jsclient/0.8.1/Testcases.html @@ -0,0 +1,545 @@ + + + + + JSDoc: Class: Testcases + + + + + + + + + + +
+ +

Class: Testcases

+ + + + + + +
+ +
+ +

Testcases(transport)

+ + +
+ +
+
+ + + + + + +

new Testcases(transport)

+ + + + + + +
+ Constructor for Items model +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
transport + + +Transport + + + + Transport object
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + +

Methods

+ + + + + + + +

create() → {Testcase}

+ + + + + + +
+ Create new test case +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ returns new test case without id +
+ + + +
+
+ Type +
+
+ +Testcase + + +
+
+ + + + + + + + + + + + + +

find() → {TestcasesQuery}

+ + + + + + +
+ Find Testcases +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ returns Query object +
+ + + +
+
+ Type +
+
+ +TestcasesQuery + + +
+
+ + + + + + + + + + + + + +

update() → {Promise}

+ + + + + + +
+ Update documents +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ not implemented +
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + + + + + + + + + + +
+ +
+ + + + +
+ + + +
+ + + + + + + \ No newline at end of file diff --git a/docs/opentmi-jsclient/0.8.1/TestcasesQuery.html b/docs/opentmi-jsclient/0.8.1/TestcasesQuery.html new file mode 100644 index 0000000..71ee51a --- /dev/null +++ b/docs/opentmi-jsclient/0.8.1/TestcasesQuery.html @@ -0,0 +1,698 @@ + + + + + JSDoc: Class: TestcasesQuery + + + + + + + + + + +
+ +

Class: TestcasesQuery

+ + + + + + +
+ +
+ +

TestcasesQuery()

+ + +
+ +
+
+ + + + + + +

new TestcasesQuery()

+ + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + +

Methods

+ + + + + + + +

isArchived() → {TestcasesQuery}

+ + + + + + +
+ Test case is marked as archived +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ returns this +
+ + + +
+
+ Type +
+
+ +TestcasesQuery + + +
+
+ + + + + + + + + + + + + +

isSkip() → {TestcasesQuery}

+ + + + + + +
+ Test case is marked as skip +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ returns this +
+ + + +
+
+ Type +
+
+ +TestcasesQuery + + +
+
+ + + + + + + + + + + + + +

tcid(id) → {ItemsQuery}

+ + + + + + +
+ Find testcases by id +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
id + + +String + + + + testcase id
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ returns this +
+ + + +
+
+ Type +
+
+ +ItemsQuery + + +
+
+ + + + + + + + + + + + + +

type(type) → {TestcasesQuery}

+ + + + + + +
+ Find tests with type +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
type + + +String + + + + test case type e.g. smoke, acceptance,...
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ returns this +
+ + + +
+
+ Type +
+
+ +TestcasesQuery + + +
+
+ + + + + + + + + + + + + +
+ +
+ + + + +
+ + + +
+ + + + + + + \ No newline at end of file diff --git a/docs/opentmi-jsclient/0.8.1/Transport.html b/docs/opentmi-jsclient/0.8.1/Transport.html new file mode 100644 index 0000000..8499a4b --- /dev/null +++ b/docs/opentmi-jsclient/0.8.1/Transport.html @@ -0,0 +1,2328 @@ + + + + + JSDoc: Class: Transport + + + + + + + + + + +
+ +

Class: Transport

+ + + + + + +
+ +
+ +

Transport(host, Rest, IO)

+ + +
+ +
+
+ + + + + + +

new Transport(host, Rest, IO)

+ + + + + + +
+ Constructor for default transport layer +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
host + + +String + + + + opentmi uri
Rest + + +Axios + + + + axios(default) -kind of object which provide REST API
IO + + +SocketIO + + + + socket.io-client(default) -kind of object which provide event based communication
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + +

Members

+ + + +

isConnected

+ + + + +
+ Check if IO is connected +
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + +

isLoggedIn

+ + + + +
+ Check if we have logged in - and have a token +
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + +

latency

+ + + + +
+ get current latency based on IO ping-pong packages +
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + +

refreshToken

+ + + + +
+ Set refreshToken function +
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + +

token

+ + + + +
+ set new token +
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + +

token

+ + + + +
+ get authentication token +
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + +

Methods

+ + + + + + + +

connect(namespace) → {Promise}

+ + + + + + +
+ Connect socketIO +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
namespace + + +string + + + + optional namespace, should start with /
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ resolves IO connection +
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + + + + + + + + + + +

delete(url) → {Promise}

+ + + + + + +
+ delete request +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
url + + +String + + + + uri for request
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ - resolves response object +
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + + + + + + + + + + +

disconnect() → {Promise}

+ + + + + + +
+ Disconnect SIO +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ resolves when IO is disconnected +
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + + + + + + + + + + +

emit(event, data, timeout) → {Promise}

+ + + + + + +
+ Event emitter to the server +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
event + + +string + + + + event name
data + + +object + + + + optional data
timeout + + +number + + + + optional timeout
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ resolves when emit is done +
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + + + + + + + + + + +

get(url, params) → {Promise}

+ + + + + + +
+ HTTP Get request to server +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
url + + +string + + + + path to the server
params + + +object + + + + query parameters
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ - resolves response object +
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + + + + + + + + + + +

post(url, data, headers) → {Promise}

+ + + + + + +
+ HTTP post request to server +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
url + + +string + + + + path to the server
data + + +object + + + + optional json data
headers + + +object + + + + optional headers as json object
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ - resolves response object +
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + + + + + + + + + + +

put(url, data, params) → {Promise}

+ + + + + + +
+ Put request +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
url + + +String + + + + uri for request
data + + +object + + + + json object to be send
params + + +object + + + + json object for query parameters
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ - resolves response object +
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + + + + + + + + + + +

request(req) → {Promise}

+ + + + + + +
+ REST request API +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
req + + +object + + + + axios config -kind of object. +default parameters: +url: '/', +method: 'get'
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ resolves when request success +
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + + + + + + + + + + +

requestIO(req) → {Promise}

+ + + + + + +
+ low level request for IO channel +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
req + + +object + + + + event: , data: [, timeout: +
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ resolves when response is received +
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + + + + + + + + + + +

sio(namespace) → {Promise.<SocketIO-client>}

+ + + + + + +
+ get socketIO instance +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
namespace + + +String + + + + namespace which socket to be get
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ resolves SocketIO-client object for namespace +
+ + + +
+
+ Type +
+
+ +Promise.<SocketIO-client> + + +
+
+ + + + + + + + + + + + + +
+ +
+ + + + +
+ + + +
+ + + + + + + \ No newline at end of file diff --git a/docs/opentmi-jsclient/0.8.1/User.html b/docs/opentmi-jsclient/0.8.1/User.html new file mode 100644 index 0000000..a80dd5d --- /dev/null +++ b/docs/opentmi-jsclient/0.8.1/User.html @@ -0,0 +1,1229 @@ + + + + + JSDoc: Class: User + + + + + + + + + + +
+ +

Class: User

+ + + + + + +
+ +
+ +

User(transport, userJson)

+ + +
+ +
+
+ + + + + + +

new User(transport, userJson)

+ + + + + + +
+ Constructor for Resources model +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
transport + + +Transport + + + + Transport object
userJson + + +Object + + + + User data as plain json object
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + +

Members

+ + + +

name

+ + + + +
+ Get user name +
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + +

Methods

+ + + + + + + +

apikeys() → {String|Object}

+ + + + + + +
+ Get user owned apikeys +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ returns apikeys +
+ + + +
+
+ Type +
+
+ +String +| + +Object + + +
+
+ + + + + + + + + + + + + +

email(email) → {User|string}

+ + + + + + +
+ Get or set email address +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
email + + +String + + + + user email address
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ email address or this when updating +
+ + + +
+
+ Type +
+
+ +User +| + +string + + +
+
+ + + + + + + + + + + + + +

groups() → {Promise.<Array.<Group>>}

+ + + + + + +
+ Get user groups +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ resolves user groups +
+ + + +
+
+ Type +
+
+ +Promise.<Array.<Group>> + + +
+
+ + + + + + + + + + + + + +

isAdmin() → {Promise.<boolean>}

+ + + + + + +
+ Check if user belong to admin group +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ resolves when ready +
+ + + +
+
+ Type +
+
+ +Promise.<boolean> + + +
+
+ + + + + + + + + + + + + +

lastVisited() → {Date}

+ + + + + + +
+ Get last visited date +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ returns last visited as a Date +
+ + + +
+
+ Type +
+
+ +Date + + +
+
+ + + + + + + + + + + + + +

myLoans() → {Promise.<Array.<Loan>>}

+ + + + + + +
+ Resolve user loans +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ resolves user loans +
+ + + +
+
+ Type +
+
+ +Promise.<Array.<Loan>> + + +
+
+ + + + + + + + + + + + + +

registered() → {Date}

+ + + + + + +
+ Get user registeration date +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ returns registered date +
+ + + +
+
+ Type +
+
+ +Date + + +
+
+ + + + + + + + + + + + + +

toString() → {string}

+ + + + + + +
+ Get resource info as short string +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ user information as single line +
+ + + +
+
+ Type +
+
+ +string + + +
+
+ + + + + + + + + + + + + +
+ +
+ + + + +
+ + + +
+ + + + + + + \ No newline at end of file diff --git a/docs/opentmi-jsclient/0.8.1/Users.html b/docs/opentmi-jsclient/0.8.1/Users.html new file mode 100644 index 0000000..b3582e6 --- /dev/null +++ b/docs/opentmi-jsclient/0.8.1/Users.html @@ -0,0 +1,713 @@ + + + + + JSDoc: Class: Users + + + + + + + + + + +
+ +

Class: Users

+ + + + + + +
+ +
+ +

Users(transport)

+ + +
+ +
+
+ + + + + + +

new Users(transport)

+ + + + + + +
+ Constructor for Resources model +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
transport + + +Transport + + + + transport object
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ + +

Extends

+ + + + +
    +
  • Collection
  • +
+ + + + + + + + + + + + + + + + + +

Methods

+ + + + + + + +

(static) WHOAMI(transport) → {Promise.<User>}

+ + + + + + +
+ Find out who am I based on login +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
transport + + +Transport + + + + Transport layer
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ resolves User object +
+ + + +
+
+ Type +
+
+ +Promise.<User> + + +
+
+ + + + + + + + + + + + + +

find() → {UsersQuery}

+ + + + + + +
+ Find Users +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ Returns query object to find Users +
+ + + +
+
+ Type +
+
+ +UsersQuery + + +
+
+ + + + + + + + + + + + + +

update() → {Promise}

+ + + + + + +
+ Update documents +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ not implemented +
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + + + + + + + + + + +

whoami() → {Promise.<User>}

+ + + + + + +
+ Find out who am I based on login +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ resolves User object +
+ + + +
+
+ Type +
+
+ +Promise.<User> + + +
+
+ + + + + + + + + + + + + +
+ +
+ + + + +
+ + + +
+ + + + + + + \ No newline at end of file diff --git a/docs/opentmi-jsclient/0.8.1/UsersQuery.html b/docs/opentmi-jsclient/0.8.1/UsersQuery.html new file mode 100644 index 0000000..1113dab --- /dev/null +++ b/docs/opentmi-jsclient/0.8.1/UsersQuery.html @@ -0,0 +1,2611 @@ + + + + + JSDoc: Class: UsersQuery + + + + + + + + + + +
+ +

Class: UsersQuery

+ + + + + + +
+ +
+ +

UsersQuery()

+ + +
+ +
+
+ + + + + + +

new UsersQuery()

+ + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ + +

Extends

+ + + + + + + + + + + + + + + + + + + + +

Members

+ + + +

query

+ + + + +
+ Return find -part object from query +
+ + + + + + + +
+ + + + + + +
Inherited From:
+
+ + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + +

queryType

+ + + + +
+ Getter for query type. default: find +
+ + + + + + + +
+ + + + + + +
Inherited From:
+
+ + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + +

type

+ + + + +
+ Get query type +'find', 'distinct', ... +
+ + + + + + + +
+ + + + + + +
Inherited From:
+
+ + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + +

Methods

+ + + + + + + +

aggregate() → {MongooseQueryClient}

+ + + + + + +
+ aggregate query +
+ + + + + + + + + + + + + +
+ + + + + + +
Inherited From:
+
+ + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ return itself +
+ + + +
+
+ Type +
+
+ +MongooseQueryClient + + +
+
+ + + + + + + + + + + + + +

asFlat() → {MongooseQueryClient}

+ + + + + + +
+ Result as a flat. +e.g. {"a.b": "b"} +
+ + + + + + + + + + + + + +
+ + + + + + +
Inherited From:
+
+ + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ return itself +
+ + + +
+
+ Type +
+
+ +MongooseQueryClient + + +
+
+ + + + + + + + + + + + + +

asJson() → {MongooseQueryClient}

+ + + + + + +
+ Result as a json +e.g. {"a": {"b": "b"}} +
+ + + + + + + + + + + + + +
+ + + + + + +
Inherited From:
+
+ + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ return itself +
+ + + +
+
+ Type +
+
+ +MongooseQueryClient + + +
+
+ + + + + + + + + + + + + +

count() → {MongooseQueryClient}

+ + + + + + +
+ get just count of match document +
+ + + + + + + + + + + + + +
+ + + + + + +
Inherited From:
+
+ + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ return itself +
+ + + +
+
+ Type +
+
+ +MongooseQueryClient + + +
+
+ + + + + + + + + + + + + +

distinct() → {MongooseQueryClient}

+ + + + + + +
+ do distinct query +
+ + + + + + + + + + + + + +
+ + + + + + +
Inherited From:
+
+ + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ return itself +
+ + + +
+
+ Type +
+
+ +MongooseQueryClient + + +
+
+ + + + + + + + + + + + + +

exec(plain) → {Promise}

+ + + + + + +
+ Execute query based on previous selected options +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDefaultDescription
plain + + +Boolean + + + + + + false + + do not convert to classes
+ + + + + + +
+ + + + + + +
Inherited From:
+
+ + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ - list of objects when 'find' (default) or plain json. +
+ + + +
+
+ Type +
+
+ +Promise + + +
+
+ + + + + + + + + + + + + +

find() → {MongooseQueryClient}

+ + + + + + +
+ do default find query +
+ + + + + + + + + + + + + +
+ + + + + + +
Inherited From:
+
+ + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ returns itself +
+ + + +
+
+ Type +
+
+ +MongooseQueryClient + + +
+
+ + + + + + + + + + + + + +

findOne() → {MongooseQueryClient}

+ + + + + + +
+ fetch only first match document +
+ + + + + + + + + + + + + +
+ + + + + + +
Inherited From:
+
+ + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ return itself +
+ + + +
+
+ Type +
+
+ +MongooseQueryClient + + +
+
+ + + + + + + + + + + + + +

fromString(str) → {MongooseQueryClient}

+ + + + + + +
+ parse query from string +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
str + + +String + + + + uri parameters as a string
+ + + + + + +
+ + + + + + +
Inherited From:
+
+ + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ returns itself +
+ + + +
+
+ Type +
+
+ +MongooseQueryClient + + +
+
+ + + + + + + + + + + + + +

has(something) → {MongooseQueryClient}

+ + + + + + +
+ Document has "something", e.g. {name: "jussi"} +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
something + + +object + + + + object to be included in query
+ + + + + + +
+ + + + + + +
Inherited From:
+
+ + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ return itself +
+ + + +
+
+ Type +
+
+ +MongooseQueryClient + + +
+
+ + + + + + +
Example
+ +
MongooseQueryClient
+   .has({'a': 'b'})
+   .has({'a': 'b'})
+ + + + + + + + + +

limit(limit) → {MongooseQueryClient}

+ + + + + + +
+ limit results +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
limit + + +number + + + + maximum number of results to be fetched
+ + + + + + +
+ + + + + + +
Inherited From:
+
+ + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ return itself +
+ + + +
+
+ Type +
+
+ +MongooseQueryClient + + +
+
+ + + + + + + + + + + + + +

mapReduce(mapFunction) → {MongooseQueryClient}

+ + + + + + +
+ mapReduce +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
mapFunction + + +function +| + +String + + + + map function
+ + + + + + +
+ + + + + + +
Inherited From:
+
+ + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ return itself +
+ + + +
+
+ Type +
+
+ +MongooseQueryClient + + +
+
+ + + + + + + + + + + + + +

populate(fields) → {MongooseQueryClient}

+ + + + + + +
+ Populate selected fields +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
fields + + +array.<string> +| + +String +| + +Object + + + + field(s) to be populated
+ + + + + + +
+ + + + + + +
Inherited From:
+
+ + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ return itself +
+ + + +
+
+ Type +
+
+ +MongooseQueryClient + + +
+
+ + + + + + + + + + + + + +

select(fields) → {MongooseQueryClient}

+ + + + + + +
+ Select fields +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
fields + + +array.<String> + + + + to be fetch, e.g. ['name']
+ + + + + + +
+ + + + + + +
Inherited From:
+
+ + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ return itself +
+ + + +
+
+ Type +
+
+ +MongooseQueryClient + + +
+
+ + + + + + + + + + + + + +

skip(skip) → {MongooseQueryClient}

+ + + + + + +
+ Skip number of results +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
skip + + +number + + + + number of document to be skip
+ + + + + + +
+ + + + + + +
Inherited From:
+
+ + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ return itself +
+ + + +
+
+ Type +
+
+ +MongooseQueryClient + + +
+
+ + + + + + + + + + + + + +

toString() → {string}

+ + + + + + +
+ Returns query as a url string +
+ + + + + + + + + + + + + +
+ + + + + + +
Inherited From:
+
+ + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ returns query as a url parameters string +
+ + + +
+
+ Type +
+
+ +string + + +
+
+ + + + + + + + + + + + + +
+ +
+ + + + +
+ + + +
+ + + + + + + \ No newline at end of file diff --git a/docs/opentmi-jsclient/0.8.1/admin.js.html b/docs/opentmi-jsclient/0.8.1/admin.js.html new file mode 100644 index 0000000..bbaa168 --- /dev/null +++ b/docs/opentmi-jsclient/0.8.1/admin.js.html @@ -0,0 +1,109 @@ + + + + + JSDoc: Source: admin.js + + + + + + + + + + +
+ +

Source: admin.js

+ + + + + + +
+
+
const invariant = require('invariant');
+const {debug} = require('./utils');
+
+class Admin {
+  /**
+   * Admin operations
+   * @param {Transport} transport - transport layer
+   */
+  constructor(transport) {
+    invariant(transport, 'transport is mandatory');
+    this._transport = transport;
+  }
+
+  /**
+   * Get OpenTMI server version details.
+   * @return {Promise} resolves json object
+   * e.g. { commitId: <id>, tag: <tag>, version: <pkg-version>, node_modules: {...}..}
+   */
+  version() {
+    invariant(this._transport.isLoggedIn, 'Transport should be connected');
+    debug('request opentmi version');
+    return this._transport
+      .get('/api/v0/version')
+      .then(response => response.data);
+  }
+
+  /**
+   * Update opentmi server which are connected through Transport
+   * @param {string} revision - tag/commitId to be deployed
+   * @param {bool} reloadWorkers - reload workers (default) or not to reload
+   * @return {Promise} resolves when upgrade is ready
+   */
+  upgrade(revision, reloadWorkers = true) {
+    invariant(this._transport.isLoggedIn, 'Transport should be connected');
+    debug('request to upgrade opentmi revision');
+    return this._transport
+      .post('/api/v0/version', {revision})
+      .then(() => {
+        if (reloadWorkers) {
+          return this.reloadWorkers();
+        }
+        return Promise.resolve();
+      });
+  }
+
+  /**
+   * Reload backend workers - e.g. after upgrade is finished
+   * @return {Promise} Resolves when reload is ready
+   */
+  reloadWorkers() {
+    invariant(this._transport.isLoggedIn, 'Transport should be connected');
+    debug('request to reload backend workers');
+    return this._transport
+      .post('/api/v0/restart');
+  }
+}
+
+module.exports = Admin;
+
+
+
+ + + + +
+ + + +
+ + + + + + + diff --git a/docs/opentmi-jsclient/0.8.1/authentication.js.html b/docs/opentmi-jsclient/0.8.1/authentication.js.html new file mode 100644 index 0000000..1251d1b --- /dev/null +++ b/docs/opentmi-jsclient/0.8.1/authentication.js.html @@ -0,0 +1,152 @@ + + + + + JSDoc: Source: authentication.js + + + + + + + + + + +
+ +

Source: authentication.js

+ + + + + + +
+
+
const invariant = require('invariant');
+const _ = require('lodash');
+const Promise = require('bluebird');
+
+// application modules
+const {debug} = require('./utils');
+
+/**
+ * Authentication controller
+ * This class provides login API's like login, logout
+ * @example
+ * const auth = new Authentication(transport);
+ * auth
+ *   .login('user@email.com', 'password')
+ *   .whoami().then(user => console.log(user.toString()));
+ */
+class Authentication {
+  /**
+   * Constructor for Authentication controller
+   * @param {Transport} transport - transport layer for communication
+   */
+  constructor(transport) {
+    invariant(transport, 'transport is mandatory');
+    this._transport = transport;
+  }
+
+  /**
+   * Login to OpenTMI
+   * @param {string}email user email address
+   * @param {string}password user password
+   * @return {Promise.<string>} - return a token
+   */
+  login(email, password) {
+    invariant(!_.isString(this._transport.token), 'is logged out already!');
+    invariant(_.isString(email), 'email should be string');
+    invariant(_.isString(password), 'password should be string');
+    return this._transport
+      .post('/auth/login', {email, password}, {})
+      .then((response) => {
+        invariant(response.data.token, 'there should be token');
+        debug(`Login response: ${JSON.stringify(response.data)}`);
+        this._transport.token = response.data.token;
+        this._transport.refreshToken = this.login.bind(this, email, password);
+        return this._transport.token;
+      })
+      .catch((error) => {
+        debug(`Login error: ${error.message}`);
+        this._transport.token = undefined;
+        throw error;
+      });
+  }
+
+  /**
+   * Login using access token
+   * @param {string}token service authentication token
+   * @param {string}service token service, default: Github
+   * @return {Promise<string>} - return token
+   */
+  loginWithToken(token, service = 'github') {
+    invariant(!_.isString(this._transport.token), 'is logged out already!');
+    invariant(_.isString(token), 'token should be string');
+    invariant(_.isString(service), 'service should be string');
+    return this._transport
+      .post(`/auth/${service}/token`, {access_token: token}, {}) // eslint-disable-line camelcase
+      .then((response) => {
+        invariant(response.data.token, 'there should be token');
+        debug(`Login response: ${JSON.stringify(response.data)}`);
+        this._transport.token = response.data.token;
+        this._transport.refreshToken = this.loginWithToken.bind(this, token, service);
+        return this._transport.token;
+      })
+      .catch((error) => {
+        debug(`Login error: ${error.message}`);
+        this._transport.token = undefined;
+        throw error;
+      });
+  }
+
+  /**
+   * Find out who I'm.
+   * Returns plain object with some details about yourself.
+   * @return {Promise<object>} resolves user details
+   */
+  whoami() {
+    return this._transport.emit('whoami');
+  }
+
+  /**
+   * Logout
+   * @return {Promise} resolves when logged out succesfully
+   */
+  logout() {
+    invariant(_.isString(this._transport.token), 'you are not logged in, jwt token missing');
+    this._transport._token = undefined;
+    this._transport.refreshToken = undefined;
+    return this._transport.isConnected ?
+      this._transport.disconnect() : Promise.resolve();
+  }
+}
+
+module.exports = Authentication;
+
+
+
+ + + + +
+ + + +
+ + + + + + + diff --git a/docs/opentmi-jsclient/0.8.1/cluster.js.html b/docs/opentmi-jsclient/0.8.1/cluster.js.html new file mode 100644 index 0000000..7e53121 --- /dev/null +++ b/docs/opentmi-jsclient/0.8.1/cluster.js.html @@ -0,0 +1,121 @@ + + + + + JSDoc: Source: cluster.js + + + + + + + + + + +
+ +

Source: cluster.js

+ + + + + + +
+
+
const invariant = require('invariant');
+const _ = require('lodash');
+// application modules
+const {debug} = require('./utils');
+
+/** Class to manage OpenTMI clusters.
+ * Most of these require admin access.
+ *
+ *
+ */
+class Cluster {
+  /**
+   * Constructor
+   * @param {Transport} transport - transport object
+   */
+  constructor(transport) {
+    this._clusters = undefined;
+    this._transport = transport;
+  }
+  get data() {
+    invariant(this._clusters, 'you should call refresh() before data');
+    return this._clusters;
+  }
+  get workers() {
+    invariant(this._clusters, 'you should call refresh() before workers');
+    return _.get(this._clusters, 'workers', undefined);
+  }
+  get status() {
+    invariant(this._clusters, 'you should call refresh() before status');
+    return _.omit(this._clusters, ['workers']);
+  }
+
+  /**
+   * Restart workers. Require admin access.
+   * @return {Promise} resolves when workers are resterted
+   */
+  restartWorkers() {
+    invariant(this._transport.isLoggedIn, 'Transport should be logged in as admin');
+    debug('attempt to restart all workers');
+    return this._transport
+      .post('/api/v0/restart')
+      .then((response) => {
+        debug('workers restarting...', response.data);
+        return response.data;
+      }).catch((error) => {
+        debug(error);
+        throw error;
+      });
+  }
+  /**
+   * Reload clusters states
+   * @returns {undefined} returns nothing
+   */
+  refresh() {
+    // @todo not required yet
+    // invariant(this._transport.isLoggedIn, 'Transport should be logged in');
+    return this._transport
+      .get('/api/v0/clusters')
+      .then((response) => {
+        debug(response.data);
+        this._clusters = response.data;
+      }).catch((error) => {
+        debug(error);
+        this._clusters = undefined;
+        throw error;
+      });
+  }
+}
+
+module.exports = Cluster;
+
+
+
+ + + + +
+ + + +
+ + + + + + + diff --git a/docs/opentmi-jsclient/0.8.1/event.js.html b/docs/opentmi-jsclient/0.8.1/event.js.html new file mode 100644 index 0000000..9cb5209 --- /dev/null +++ b/docs/opentmi-jsclient/0.8.1/event.js.html @@ -0,0 +1,185 @@ + + + + + JSDoc: Source: event.js + + + + + + + + + + +
+ +

Source: event.js

+ + + + + + +
+
+
// 3rd party modules
+const _ = require('lodash');
+const invariant = require('invariant');
+
+// application modules
+const {Document} = require('./utils');
+
+
+class Event extends Document {
+  /**
+   * Constructor for Resources model
+   * @param {Transport} transport - Transport object
+   * @param {Object}eventJson User data as plain json object
+   */
+  constructor(transport, eventJson) {
+    super(transport, '/api/v0/events', eventJson);
+  }
+
+  /**
+   * Get resource info as short string
+   * @return {string} user information as single line
+   */
+  toString() {
+    return `${this.priority()}.${this.facility()}: ${this.msg()}`;
+  }
+  /**
+   * get PRIORITIES as array
+   * @return {Array<string>} list of priorities
+   */
+  static get PRIORITIES() {
+    return ['emerg', 'alert', 'crit', 'err', 'warning', 'notice', 'info', 'debug'];
+  }
+  /**
+   * Get event priority or set it
+   * @param {String}value new name
+   * @return {Item|string} returns item name or Item
+   */
+  priority(value) {
+    if (value) invariant(Event.PRIORITIES.indexOf(value) >= 0, 'Not allowed priority');
+    return this.getOrSet('priority.level', value);
+  }
+
+  resource(obj) {
+    invariant(_.isString(obj.id), 'resource object should have id');
+    return this.getOrSet('ref.resource', obj.id);
+  }
+  result(obj) {
+    invariant(_.isString(obj.id), 'result object should have id');
+    return this.getOrSet('ref.result', obj.id);
+  }
+  testcase(obj) {
+    invariant(_.isString(obj.id), 'testcase object should have id');
+    return this.getOrSet('ref.testcase', obj.id);
+  }
+  emergency() {
+    return this.priority('emerg');
+  }
+  alert() {
+    return this.priority('alert');
+  }
+  critical() {
+    return this.priority('crit');
+  }
+  error() {
+    return this.priority('err');
+  }
+  warning() {
+    return this.priority('warning');
+  }
+  notice() {
+    return this.priority('notice');
+  }
+  info() {
+    return this.priority('info');
+  }
+  debug() {
+    return this.priority('debug');
+  }
+
+  static get FACILITIES() {
+    return ['auth', 'cron', 'daemon', 'mail', 'news', 'syslog', 'user', 'resource', 'testcase'];
+  }
+  facility(value) {
+    if (value) invariant(Event.FACILITIES.indexOf(value) >= 0, 'Not allowed facility');
+    return this.getOrSet('priority.facility', value);
+  }
+  duration(value) {
+    if (value) invariant(_.isNumber(value), 'value should be an number');
+    return this.getOrSet('duration', value);
+  }
+  spare(value) {
+    return this.getOrSet('spare', value);
+  }
+  id(value) {
+    // e.g. PID of the process
+    return this.getOrSet('id', value);
+  }
+  static get MSG_IDS() {
+    return ['ALLOCATED', 'RELEASED', 'ENTER_MAINTENANCE', 'EXIT_MAINTENANCE', 'CREATED', 'DELETED', 'FLASHED'];
+  }
+  msgid(value) {
+    if (value) invariant(Event.MSG_IDS.indexOf(value) >= 0, 'Not allowed msgid');
+    return this.getOrSet('msgid', value);
+  }
+  allocated() {
+    return this.msgid('ALLOCATED');
+  }
+  released() {
+    return this.msgid('RELEASED');
+  }
+  enterMaintenance() {
+    return this.msgid('ENTER_MAINTENANCE');
+  }
+  exitMaintenance() {
+    return this.msgid('EXIT_MAINTENANCE');
+  }
+  created() {
+    return this.msgid('CREATED');
+  }
+  deleted() {
+    return this.msgid('DELETED');
+  }
+  flashed() {
+    return this.msgid('FLASHED');
+  }
+  tag(value) {
+    return this.getOrSet('tag', value);
+  }
+  msg(value) {
+    return this.getOrSet('msg', value);
+  }
+}
+
+module.exports = Event;
+
+
+
+ + + + +
+ + + +
+ + + + + + + diff --git a/docs/opentmi-jsclient/0.8.1/events.js.html b/docs/opentmi-jsclient/0.8.1/events.js.html new file mode 100644 index 0000000..9b52c65 --- /dev/null +++ b/docs/opentmi-jsclient/0.8.1/events.js.html @@ -0,0 +1,133 @@ + + + + + JSDoc: Source: events.js + + + + + + + + + + +
+ +

Source: events.js

+ + + + + + +
+
+
// 3rd party modules
+const invariant = require('invariant');
+const _ = require('lodash');
+
+
+// application modules
+const Event = require('./event');
+const {
+  QueryBase, Document, Collection, notImplemented
+} = require('./utils');
+
+/**
+ * @class EventsQuery
+ * @extends QueryBase
+ */
+class EventsQuery extends QueryBase {
+  /* Find events by _id
+   * @param {string} _id
+   * @return {Query} -
+   */
+  _id(_id) {
+    invariant(_.isString(_id), 'id should be a string');
+    return this.has({_id});
+  }
+  /** Set/Get priority
+   * @param {string} value -
+   * @return {Query} -
+   */
+  priority(value) {
+    invariant(Event.PRIORITIES.indexOf(value) >= 0, 'Not allowed priority');
+    return this.has({'priority.level': value});
+  }
+  /** Set/Get facility
+   * @param {string} value -
+   * @return {Query} -
+   */
+  facility(value) {
+    invariant(Event.FACILITIES.indexOf(value) >= 0, 'Not allowed facility');
+    return this.has({'priority.facility': value});
+  }
+}
+
+/**
+ * @extends Collection
+ */
+class Events extends Collection {
+  /**
+   * Constructor for Resources model
+   * @param {Transport} transport - transport object
+   */
+  constructor(transport) {
+    super(transport, '/api/v0/events');
+    this._notImplemented = notImplemented;
+  }
+
+  /**
+   * Find Users
+   * @return {UsersQuery} Returns query object to find Users
+   */
+  find() {
+    return new EventsQuery(this, Event);
+  }
+
+  /**
+   * Update documents
+   * @return {Promise} not implemented
+   */
+  update() {
+    return this._notImplemented('Events update is not implemented');
+  }
+
+  /**
+   * Create new event
+   * @return {Event} event object
+   */
+  create() {
+    const NewEvent = Document.IsNewDocument(Event);
+    return new NewEvent(this._transport);
+  }
+}
+
+module.exports = Events;
+
+
+
+ + + + +
+ + + +
+ + + + + + + diff --git a/docs/opentmi-jsclient/0.8.1/fonts/OpenSans-Bold-webfont.eot b/docs/opentmi-jsclient/0.8.1/fonts/OpenSans-Bold-webfont.eot new file mode 100644 index 0000000..5d20d91 Binary files /dev/null and b/docs/opentmi-jsclient/0.8.1/fonts/OpenSans-Bold-webfont.eot differ diff --git a/docs/opentmi-jsclient/0.8.1/fonts/OpenSans-Bold-webfont.svg b/docs/opentmi-jsclient/0.8.1/fonts/OpenSans-Bold-webfont.svg new file mode 100644 index 0000000..3ed7be4 --- /dev/null +++ b/docs/opentmi-jsclient/0.8.1/fonts/OpenSans-Bold-webfont.svg @@ -0,0 +1,1830 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/opentmi-jsclient/0.8.1/fonts/OpenSans-Bold-webfont.woff b/docs/opentmi-jsclient/0.8.1/fonts/OpenSans-Bold-webfont.woff new file mode 100644 index 0000000..1205787 Binary files /dev/null and b/docs/opentmi-jsclient/0.8.1/fonts/OpenSans-Bold-webfont.woff differ diff --git a/docs/opentmi-jsclient/0.8.1/fonts/OpenSans-BoldItalic-webfont.eot b/docs/opentmi-jsclient/0.8.1/fonts/OpenSans-BoldItalic-webfont.eot new file mode 100644 index 0000000..1f639a1 Binary files /dev/null and b/docs/opentmi-jsclient/0.8.1/fonts/OpenSans-BoldItalic-webfont.eot differ diff --git a/docs/opentmi-jsclient/0.8.1/fonts/OpenSans-BoldItalic-webfont.svg b/docs/opentmi-jsclient/0.8.1/fonts/OpenSans-BoldItalic-webfont.svg new file mode 100644 index 0000000..6a2607b --- /dev/null +++ b/docs/opentmi-jsclient/0.8.1/fonts/OpenSans-BoldItalic-webfont.svg @@ -0,0 +1,1830 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/opentmi-jsclient/0.8.1/fonts/OpenSans-BoldItalic-webfont.woff b/docs/opentmi-jsclient/0.8.1/fonts/OpenSans-BoldItalic-webfont.woff new file mode 100644 index 0000000..ed760c0 Binary files /dev/null and b/docs/opentmi-jsclient/0.8.1/fonts/OpenSans-BoldItalic-webfont.woff differ diff --git a/docs/opentmi-jsclient/0.8.1/fonts/OpenSans-Italic-webfont.eot b/docs/opentmi-jsclient/0.8.1/fonts/OpenSans-Italic-webfont.eot new file mode 100644 index 0000000..0c8a0ae Binary files /dev/null and b/docs/opentmi-jsclient/0.8.1/fonts/OpenSans-Italic-webfont.eot differ diff --git a/docs/opentmi-jsclient/0.8.1/fonts/OpenSans-Italic-webfont.svg b/docs/opentmi-jsclient/0.8.1/fonts/OpenSans-Italic-webfont.svg new file mode 100644 index 0000000..e1075dc --- /dev/null +++ b/docs/opentmi-jsclient/0.8.1/fonts/OpenSans-Italic-webfont.svg @@ -0,0 +1,1830 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/opentmi-jsclient/0.8.1/fonts/OpenSans-Italic-webfont.woff b/docs/opentmi-jsclient/0.8.1/fonts/OpenSans-Italic-webfont.woff new file mode 100644 index 0000000..ff652e6 Binary files /dev/null and b/docs/opentmi-jsclient/0.8.1/fonts/OpenSans-Italic-webfont.woff differ diff --git a/docs/opentmi-jsclient/0.8.1/fonts/OpenSans-Light-webfont.eot b/docs/opentmi-jsclient/0.8.1/fonts/OpenSans-Light-webfont.eot new file mode 100644 index 0000000..1486840 Binary files /dev/null and b/docs/opentmi-jsclient/0.8.1/fonts/OpenSans-Light-webfont.eot differ diff --git a/docs/opentmi-jsclient/0.8.1/fonts/OpenSans-Light-webfont.svg b/docs/opentmi-jsclient/0.8.1/fonts/OpenSans-Light-webfont.svg new file mode 100644 index 0000000..11a472c --- /dev/null +++ b/docs/opentmi-jsclient/0.8.1/fonts/OpenSans-Light-webfont.svg @@ -0,0 +1,1831 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/opentmi-jsclient/0.8.1/fonts/OpenSans-Light-webfont.woff b/docs/opentmi-jsclient/0.8.1/fonts/OpenSans-Light-webfont.woff new file mode 100644 index 0000000..e786074 Binary files /dev/null and b/docs/opentmi-jsclient/0.8.1/fonts/OpenSans-Light-webfont.woff differ diff --git a/docs/opentmi-jsclient/0.8.1/fonts/OpenSans-LightItalic-webfont.eot b/docs/opentmi-jsclient/0.8.1/fonts/OpenSans-LightItalic-webfont.eot new file mode 100644 index 0000000..8f44592 Binary files /dev/null and b/docs/opentmi-jsclient/0.8.1/fonts/OpenSans-LightItalic-webfont.eot differ diff --git a/docs/opentmi-jsclient/0.8.1/fonts/OpenSans-LightItalic-webfont.svg b/docs/opentmi-jsclient/0.8.1/fonts/OpenSans-LightItalic-webfont.svg new file mode 100644 index 0000000..431d7e3 --- /dev/null +++ b/docs/opentmi-jsclient/0.8.1/fonts/OpenSans-LightItalic-webfont.svg @@ -0,0 +1,1835 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/opentmi-jsclient/0.8.1/fonts/OpenSans-LightItalic-webfont.woff b/docs/opentmi-jsclient/0.8.1/fonts/OpenSans-LightItalic-webfont.woff new file mode 100644 index 0000000..43e8b9e Binary files /dev/null and b/docs/opentmi-jsclient/0.8.1/fonts/OpenSans-LightItalic-webfont.woff differ diff --git a/docs/opentmi-jsclient/0.8.1/fonts/OpenSans-Regular-webfont.eot b/docs/opentmi-jsclient/0.8.1/fonts/OpenSans-Regular-webfont.eot new file mode 100644 index 0000000..6bbc3cf Binary files /dev/null and b/docs/opentmi-jsclient/0.8.1/fonts/OpenSans-Regular-webfont.eot differ diff --git a/docs/opentmi-jsclient/0.8.1/fonts/OpenSans-Regular-webfont.svg b/docs/opentmi-jsclient/0.8.1/fonts/OpenSans-Regular-webfont.svg new file mode 100644 index 0000000..25a3952 --- /dev/null +++ b/docs/opentmi-jsclient/0.8.1/fonts/OpenSans-Regular-webfont.svg @@ -0,0 +1,1831 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/opentmi-jsclient/0.8.1/fonts/OpenSans-Regular-webfont.woff b/docs/opentmi-jsclient/0.8.1/fonts/OpenSans-Regular-webfont.woff new file mode 100644 index 0000000..e231183 Binary files /dev/null and b/docs/opentmi-jsclient/0.8.1/fonts/OpenSans-Regular-webfont.woff differ diff --git a/docs/opentmi-jsclient/0.8.1/global.html b/docs/opentmi-jsclient/0.8.1/global.html new file mode 100644 index 0000000..38f3ad5 --- /dev/null +++ b/docs/opentmi-jsclient/0.8.1/global.html @@ -0,0 +1,757 @@ + + + + + JSDoc: Global + + + + + + + + + + +
+ +

Global

+ + + + + + +
+ +
+ +

+ + +
+ +
+
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + +
+ + + + + + + + + + + + + + + + +

Methods

+ + + + + + + +

beginningOfDay(date) → {Date}

+ + + + + + +
+ return date which are beginnign of given day +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
date + + +Date + + + + input date
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ - date beginning of given day +
+ + + +
+
+ Type +
+
+ +Date + + +
+
+ + + + + + + + + + + + + +

endOfDay(date) → {Date}

+ + + + + + +
+ return date which are end of given day +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
date + + +Date + + + + input date
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ - date end of given day +
+ + + +
+
+ Type +
+
+ +Date + + +
+
+ + + + + + + + + + + + + +

notImplemented(msg) → {Promise.<String>}

+ + + + + + +
+ Rejects with message "not implemented" (default msg) +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
msg + + +String + + + + reject message
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ - reject +
+ + + +
+
+ Type +
+
+ +Promise.<String> + + +
+
+ + + + + + + + + + + + + +

timeSince(when) → {Object}

+ + + + + + +
+ Return object which contains duration between given date and current date +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
when + + +Date + + + + first date to be compared against current date
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+ object which contains durations +
+ + + +
+
+ Type +
+
+ +Object + + +
+
+ + + + + + + + + + + + + +
+ +
+ + + + +
+ + + +
+ + + + + + + \ No newline at end of file diff --git a/docs/opentmi-jsclient/0.8.1/group.js.html b/docs/opentmi-jsclient/0.8.1/group.js.html new file mode 100644 index 0000000..7955368 --- /dev/null +++ b/docs/opentmi-jsclient/0.8.1/group.js.html @@ -0,0 +1,95 @@ + + + + + JSDoc: Source: group.js + + + + + + + + + + +
+ +

Source: group.js

+ + + + + + +
+
+
// 3rd party modules
+// application modules
+const {Document} = require('./utils');
+
+
+class Group extends Document {
+  /**
+   * Constructor for Resources model
+   * @param {Transport} transport - Transport object
+   * @param {Object}groupJson - group as plain json
+   */
+  constructor(transport, groupJson) {
+    super(transport, '/api/v0/groups', groupJson);
+  }
+
+  static fromId(transport, id) {
+    const group = new Group(transport, {_id: id});
+    return group.refresh();
+  }
+
+  /**
+   * Get resource info as short string
+   * @return {string} returns group data as single line
+   */
+  toString() {
+    return `${this.name}`;
+  }
+
+  /**
+   * Get group name
+   * @return {String} returns group name
+   */
+  get name() { return this.get('name'); }
+
+  /**
+   * Check if group is a admin
+   * @return {boolean} returns true if group is admin
+   */
+  isAdmin() {
+    return this.name === 'admin';
+  }
+}
+
+module.exports = Group;
+
+
+
+ + + + +
+ + + +
+ + + + + + + diff --git a/docs/opentmi-jsclient/0.8.1/groups.js.html b/docs/opentmi-jsclient/0.8.1/groups.js.html new file mode 100644 index 0000000..68a791f --- /dev/null +++ b/docs/opentmi-jsclient/0.8.1/groups.js.html @@ -0,0 +1,106 @@ + + + + + JSDoc: Source: groups.js + + + + + + + + + + +
+ +

Source: groups.js

+ + + + + + +
+
+
// 3rd party modules
+const invariant = require('invariant');
+const _ = require('lodash');
+
+
+// application modules
+const Group = require('./group');
+const {QueryBase, Collection, notImplemented} = require('./utils');
+
+/**
+ * @class GroupsQuery
+ * @extends QueryBase
+ */
+class GroupsQuery extends QueryBase {
+  /* Find group by name
+   * @param {string} name
+   * @return {Query}
+   */
+  name(name) {
+    invariant(_.isString(name), 'name should be a string');
+    return this.has({name});
+  }
+}
+
+/**
+ * @extends Collection
+ */
+class Groups extends Collection {
+  /**
+   * Constructor for Groups model
+   * @param {Transport} transport - transport object
+   */
+  constructor(transport) {
+    super(transport, '/api/v0/groups');
+    this._notImplemented = notImplemented;
+  }
+
+  /**
+   * Find groups
+   * @return {GroupsQuery} Returns query object to find Groups
+   */
+  find() {
+    return new GroupsQuery(this, Group);
+  }
+
+  /**
+   * Update documents
+   * @return {Promise} not implemented
+   */
+  update() {
+    return this._notImplemented('Groups update is not implemented');
+  }
+}
+
+module.exports = Groups;
+
+
+
+ + + + +
+ + + +
+ + + + + + + diff --git a/docs/opentmi-jsclient/0.8.1/index.html b/docs/opentmi-jsclient/0.8.1/index.html new file mode 100644 index 0000000..9526e36 --- /dev/null +++ b/docs/opentmi-jsclient/0.8.1/index.html @@ -0,0 +1,125 @@ + + + + + JSDoc: Home + + + + + + + + + + +
+ +

Home

+ + + + + + + + +

opentmi-jsclient 0.8.1

+ + + + + + + + + + + + + + + +
+

opentmi-jsclient

+ +

npm version +CircleCI +Coverage Status +JavaScript Style Guide +License badge +Greenkeeper badge

+

Promise based OpenTMI javascript client for node.js and browser. +Extendable for custom API's provided by opentmi addons.

+

Requirements

+

Documentation

API documentation

+

Installation

npm i opentmi-jsclient

Build

to build minified version to dist -folder run:

+
> npm run build

build api documentations

+
> npm run doc

Note: all available commands are visible when you run: npm run

+

Sample

Node.js

const {Authentication, Transport, Resources} = require('opentmi-client');
+const transport = new Transport('http://localhost:3000')
+const auth = new Authentication(transport);
+auth
+  .login('user@mail.com', 'password')
+  .then(() => transport.connect())
+  .then(() => {
+      const collection = new Resources(transport);
+      return collection.find()
+        .haveTag('fantastic')
+        .exec()
+        .then(resources => resources[0])
+        .then(resource => {
+          return resource
+            .name('new name')
+            .save();
+        });
+  })

Browser

<script src="dist/opentmi-client.js"></script>
+<script>
+const {Authentication, Transport} = opentmiClient;
+const transport = new Transport('http://localhost:3000')
+const auth = new Authentication(transport);
+auth
+  .login('user@mail.com', 'password')
+  .then(() => transport.connect())
+</script>

Note: see more examples from sample -folder.

+

Customize

It is easy to create support for custom API's. See example below:

+
class CustomAPI {
+  constructor(transport) {
+    this._transport = transport;
+  }
+  some() {
+    debug('attempt to get something from custom addon api');
+    return this._transport
+      .get('/addon-api')
+      .then(response => response.data);
+  }
+}
+const customApi = new CustomAPI(transport);
+customApi.some().then(data => console.log(data));

License

MIT

+
+ + + + + + +
+ + + +
+ + + + + + + \ No newline at end of file diff --git a/docs/opentmi-jsclient/0.8.1/item.js.html b/docs/opentmi-jsclient/0.8.1/item.js.html new file mode 100644 index 0000000..c943aa8 --- /dev/null +++ b/docs/opentmi-jsclient/0.8.1/item.js.html @@ -0,0 +1,117 @@ + + + + + JSDoc: Source: item.js + + + + + + + + + + +
+ +

Source: item.js

+ + + + + + +
+
+
// application modules
+const {Document} = require('./utils');
+
+
+class Item extends Document {
+  /**
+   * Manage single resource
+   * @param {Transport} transport - transport layer
+   * @param {object} resourceJson - plain json object
+   */
+  constructor(transport, resourceJson) {
+    super(transport, '/api/v0/items', resourceJson);
+  }
+
+  /**
+   * Get resource info as short string
+   * @return {string} returns single line about item
+   */
+  toString() {
+    return `${this.category()}: ${this.manufacturer() ? this.manufacturer() : ''} - ${this.name()}`;
+  }
+
+  /**
+   * Get item name or set it
+   * @param {String}value new name
+   * @return {Item|string} returns item name or Item
+   */
+  name(value) { return this.getOrSet('name', value); }
+
+  /**
+   * Get category or set it
+   * @param {String}value new category
+   * @returns {Item|String} return category or Item when update new value
+   */
+  category(value) {
+    return this.getOrSet('category', value);
+  }
+
+  /**
+   * Get manufacturer or set it
+   * @param {String}name - manufacturer name
+   * @return {Item|String} return manufactorer or Item
+   */
+  manufacturer(name) {
+    return this.getOrSet('manufacturer.name', name);
+  }
+
+  /**
+   * Get item image as buffer
+   * @return {Promise<buffer>} image buffer
+   */
+  getImage() {
+    return this._transport.get(`${this.path}/image`)
+      .then(response => response.data);
+  }
+
+  barcode(value) { return this.getOrSet('barcode', value); }
+
+  imageSrc(value) { return this.getOrSet('image_src', value); }
+
+  description(value) { return this.getOrSet('text_description', value); }
+
+  reference(value) { return this.getOrSet('external_reference', value); }
+}
+
+module.exports = Item;
+
+
+
+ + + + +
+ + + +
+ + + + + + + diff --git a/docs/opentmi-jsclient/0.8.1/items.js.html b/docs/opentmi-jsclient/0.8.1/items.js.html new file mode 100644 index 0000000..a4f4329 --- /dev/null +++ b/docs/opentmi-jsclient/0.8.1/items.js.html @@ -0,0 +1,175 @@ + + + + + JSDoc: Source: items.js + + + + + + + + + + +
+ +

Source: items.js

+ + + + + + +
+
+
// 3rd party modules
+const _ = require('lodash');
+const invariant = require('invariant');
+
+// application modules
+const Item = require('./item');
+const {QueryBase, Collection, notImplemented} = require('./utils');
+
+/**
+ * @class ItemsQuery
+ */
+class ItemsQuery extends QueryBase {
+  /* Find Items by id
+   * @param {string} id
+   * @return {MongooseQueryClient} returns this
+   */
+  id(id) {
+    invariant(_.isString(id), 'id should be a string');
+    return this.has({_id: id});
+  }
+
+  /**
+   * Find items by barcode
+   * @param {String}barcode barcore to be find
+   * @return {ItemsQuery} returns this
+   */
+  barcode(barcode) {
+    return this.has({barcode});
+  }
+
+  /**
+   * Find items by name
+   * @param {String}name item name
+   * @return {ItemsQuery} returns this
+   */
+  name(name) {
+    return this.has({name});
+  }
+
+  /**
+   * Find items by availability
+   * @param {Number}available - should be at least 1 or available amount of resources
+   * @return {ItemsQuery} returns this
+   */
+  available(available = 1) {
+    invariant(_.isInteger(available), 'available should be a number');
+    return this.has({available: {$gte: available}});
+  }
+
+  /**
+   * Find items by category
+   * @param {String}category - resource category, allowed values:
+   * 'accessory', 'board', 'component', 'other'
+   * @return {ItemsQuery} returns this
+   */
+  category(category) {
+    invariant(_.isString(category), 'category should be a string');
+    const allowedValues = [
+      'accessory',
+      'board',
+      'component',
+      'other'];
+    invariant(allowedValues.indexOf(category) >= -1, 'should be allowed category');
+    return this.has({category});
+  }
+  /**
+   * Find only accessories
+   * @return {ItemsQuery} return this
+   */
+  categoryAccessories() { return this.category('accessory'); }
+  /**
+   * Find only boards
+   * @return {ItemsQuery} return this
+   */
+  categoryBoards() { return this.category('board'); }
+  /**
+   * Find only components
+   * @return {ItemsQuery} return this
+   */
+  categoryComponents() { return this.category('components'); }
+  /**
+   * Find only other category resources
+   * @return {ItemsQuery} return this
+   */
+  categoryOthers() { return this.category('other'); }
+
+  /**
+   * Find items by manufacturer
+   * @param {String}name - manufacturer
+   * @return {ItemsQuery} return this
+   */
+  manufacturer(name) {
+    return this.has({'manufacturer.name': name});
+  }
+}
+
+class Items extends Collection {
+  /**
+   * Constructor for Items model
+   * @param {Transport} transport - Transport object
+   */
+  constructor(transport) {
+    super(transport, '/api/v0/items');
+    this._notImplemented = notImplemented;
+  }
+
+  /**
+   * Find Items
+   * @return {ResultsQuery} returns Query object
+   */
+  find() {
+    return new ItemsQuery(this, Item);
+  }
+
+  /**
+   * Update documents
+   * @return {Promise} not implemented
+   */
+  update() {
+    return this._notImplemented('Item update is not implemented');
+  }
+}
+
+module.exports = Items;
+
+
+
+ + + + +
+ + + +
+ + + + + + + diff --git a/docs/opentmi-jsclient/0.8.1/loan.js.html b/docs/opentmi-jsclient/0.8.1/loan.js.html new file mode 100644 index 0000000..15dbc21 --- /dev/null +++ b/docs/opentmi-jsclient/0.8.1/loan.js.html @@ -0,0 +1,193 @@ + + + + + JSDoc: Source: loan.js + + + + + + + + + + +
+ +

Source: loan.js

+ + + + + + +
+
+
// 3rd party modules
+const _ = require('lodash');
+const invariant = require('invariant');
+// application modules
+const {Document} = require('./utils');
+const Items = require('./items');
+const Resources = require('./resources');
+
+
+/** @class LoanItem */
+class LoanItem {
+  /**
+   * LoanItem constructor
+   * @param {Transport}transport transport layer
+   * @param {object}data json object
+   */
+  constructor(transport, data = {}) {
+    this._data = data;
+    this._transport = transport;
+  }
+  /**
+   * get item as plain json
+   * @return {Object} returns loanitem as plain json
+   */
+  toJson() { return _.cloneDeep(this._data); }
+  /**
+   * returns loan item as single line
+   * @returns {String} loan item details as single line
+   */
+  toString() { return this._data.item; }
+  /**
+   * Get return date
+   * @return {Date|undefined} Date when loan is returned, otherwise undefined.
+   */
+  returnDate() {
+    return this.get('return_date');
+  }
+  /**
+   * get Item
+   * @return {Item} returns Item
+   */
+  getItem() {
+    const items = new Items(this._transport);
+    return items.find().id(this._data.item).exec().then(list => list[0]);
+  }
+
+  /**
+   * Set item
+   * @param {Item}item item to add loan iten
+   */
+  set item(item) {
+    this._data.item = item.id;
+  }
+  /**
+   * get resource
+   * @return {Promise<Resource>} resolves Resource
+   */
+  getResource() {
+    const rs = new Resources(this._transport);
+    return rs.find().id(this._data.resource).exec().then(list => list[0]);
+  }
+
+  /**
+   * Set resource to loan item
+   * @param {Resource}resource unique loan resource
+   */
+  set resource(resource) {
+    this._data.resource = resource.id;
+  }
+}
+
+class Loan extends Document {
+  /**
+   * Manage single resource
+   * @param {Transport} transport - transport layer
+   * @param {object} resourceJson - plain json object
+   */
+  constructor(transport, resourceJson) {
+    super(transport, '/api/v0/loans', resourceJson);
+  }
+
+  /**
+   * Get loan info as short string
+   * @return {string} single line about loan
+   */
+  toString() {
+    return `${this.loaner()}`;
+  }
+
+  /**
+   * Get loan date or set it (admin only)
+   * @param {Date} value optional date when updating
+   * @return {Loan|string} returns loan date or Loan
+   */
+  loanDate(value) { return this.getOrSet('loan_date', value); }
+
+  /**
+   * Get loaner or set it (admin only)
+   * @param {String}value optoinal loaner id when updating
+   * @return {Loan|string} returns loaner id or Loan
+   */
+  loaner(value) { return this.getOrSet('loaner', value); }
+
+  /**
+   * Get notes or set it (admin only)
+   * @param {Stirng}value optional notes when updating
+   * @return {Loan|String} returns notes or Loan
+   */
+  notes(value) { return this.getOrSet('notes', value); }
+
+  /**
+   * Add loan item
+   * @param {Item} item object
+   * @return {LoanItem} returns Loan
+   */
+  addItem(item) {
+    invariant(_.isObject(item), 'item should be object');
+    const items = this.get('loan_items', []);
+    items.push(item.toJson());
+    this.set('loan_items', items);
+    return this;
+  }
+
+  /**
+   * Resolve loan items
+   * @return {LoanItem} returns LoanItems
+   */
+  loanItems() {
+    const items = this.get('loan_items', []);
+    return _.map(items, item => new LoanItem(this._transport, item));
+  }
+
+  /**
+   * create new LoanItem class
+   * @return {LoanItem} get LoanItem constructor
+   */
+  newLoanItem() {
+    return new LoanItem(this._transport);
+  }
+}
+
+module.exports = Loan;
+
+
+
+ + + + +
+ + + +
+ + + + + + + diff --git a/docs/opentmi-jsclient/0.8.1/loans.js.html b/docs/opentmi-jsclient/0.8.1/loans.js.html new file mode 100644 index 0000000..14aae37 --- /dev/null +++ b/docs/opentmi-jsclient/0.8.1/loans.js.html @@ -0,0 +1,161 @@ + + + + + JSDoc: Source: loans.js + + + + + + + + + + +
+ +

Source: loans.js

+ + + + + + +
+
+
// 3rd party modules
+const _ = require('lodash');
+const invariant = require('invariant');
+
+// application modules
+const Loan = require('./loan');
+const {
+  QueryBase, Collection, notImplemented,
+  beginningOfDay, endOfDay
+} = require('./utils');
+
+/**
+ * @class ItemsQuery
+ * @example
+ * Loans.find()
+ *  .loadItems() // populate loan items
+ *  .loanDate(new Date()) //loaned today
+ *  .exec() // do query
+ */
+class LoansQuery extends QueryBase {
+  /**
+   * Populate loaned items
+   * @returns {LoansQuery} returns LoansQuery
+   */
+  loadItems() {
+    return this.populate('items.item');
+  }
+  /**
+   * Populate unique resources
+   * @returns {LoansQuery} returns LoansQuery
+   */
+  loadResources() {
+    return this.populate('items.resource');
+  }
+  /**
+   * Populate loaner (User)
+   * @returns {LoansQuery} returns LoansQuery
+   */
+  loadLoaner() {
+    return this.populate('loaner');
+  }
+  /**
+   * Find loans by loan date
+   * @param {Date}date date when loan happens
+   * @returns {LoansQuery} returns LoansQuery
+   */
+  loanDate(date) {
+    return this.has({loan_date: {$gte: beginningOfDay(date), $lte: endOfDay(date)}});
+  }
+  /**
+   * Find loans by loaner
+   * @param {string}userid user id to be find
+   * @returns {LoansQuery} returns LoansQuery
+   */
+  loaner(userid) {
+    return this.has({loaner: userid});
+  }
+  /**
+   * Find loans which contains note
+   * @param {string}note string that should contains in loan
+   * @returns {LoansQuery} returns LoansQuery
+   */
+  hasNotes(note) {
+    return this.has({notes: `/${note}/`});
+  }
+}
+
+/**
+ * Manage Loans
+ */
+class Loans extends Collection {
+  /**
+   * Constructor for Loans model
+   * @param {Transport} transport - Transport object
+   */
+  constructor(transport) {
+    super(transport, '/api/v0/loans');
+    this._notImplemented = notImplemented;
+  }
+
+  /**
+   * Find loans by user
+   * @param {User}user user object
+   * @param {Transport}transport transport layer
+   * @return {Promise.<Loan[]>} resolves Loans
+   */
+  static forUser(user, transport) {
+    invariant(_.isObject(user), 'user should be an User object');
+    const loans = new Loans(transport);
+    return loans.find().loaner(user.id).exec();
+  }
+
+  /**
+   * Construct Loans query object
+   * @return {LoansQuery} return loans query
+   */
+  find() {
+    return new LoansQuery(this, Loan);
+  }
+
+  /**
+   * Update documents
+   * @return {Promise} not implemented
+   */
+  update() {
+    return this._notImplemented('Loan update is not implemented');
+  }
+}
+
+module.exports = Loans;
+
+
+
+ + + + +
+ + + +
+ + + + + + + diff --git a/docs/opentmi-jsclient/0.8.1/resource.js.html b/docs/opentmi-jsclient/0.8.1/resource.js.html new file mode 100644 index 0000000..5ec0fc1 --- /dev/null +++ b/docs/opentmi-jsclient/0.8.1/resource.js.html @@ -0,0 +1,139 @@ + + + + + JSDoc: Source: resource.js + + + + + + + + + + +
+ +

Source: resource.js

+ + + + + + +
+
+
// application modules
+const {Document} = require('./utils');
+
+
+class Resource extends Document {
+  /**
+   * Manage single resource
+   * @param {Transport} transport - transport layer
+   * @param {object} resourceJson - plain json object
+   */
+  constructor(transport, resourceJson) {
+    super(transport, '/api/v0/resources', resourceJson);
+  }
+
+  /**
+   * Get resource info as short string
+   * @return {string} single line of resource data
+   */
+  toString() {
+    return `${this.id}: ${this.name()}`;
+  }
+
+  /**
+   * Get resource name or set it
+   * @param {String}value resource name
+   * @return {string|Resource} resource name or Resource object
+   */
+  name(value) { return this.getOrSet('name', value); }
+
+  /**
+   * Get resource type of set it
+   * @param {String}value resource type
+   * @return {Resource|String} resource type of Resource object
+   */
+  type(value) { return this.getOrSet('type', value); }
+
+  /**
+   * Manage hw informations
+   * @example
+   * doc
+   *  .hw.sn('123')
+   *  .hw.imei('12334')
+   *  .hw.firmware.name('aa')
+   *  .hw.firmware.version('1.0.0')
+   * @return {Object} hardware object
+   */
+  get hw() {
+    const self = this;
+    const hw = {
+      get firmware() {
+        return {
+          name: function name(value) { return this.getOrSet('hw.firmware.name', value); }.bind(self),
+          version: function version(value) {
+            return this.getOrSet('hw.firmware.version', value);
+          }.bind(self)
+        };
+      },
+      sn: function sn(value) { return this.getOrSet('hw.sn', value); }.bind(this),
+      imei: function imei(value) { return this.getOrSet('hw.imei', value); }.bind(this),
+      id: function id(value) { return this.getOrSet('hw.id', value); }.bind(this)
+    };
+    return hw;
+  }
+  /**
+   * Manage location information
+   * @example
+   *   // set site and country
+   *   doc
+   *    .location.site('oulu')
+   *    .location.country('finland')
+   *  @return {Object} Location object
+   */
+  get location() {
+    const loc = {
+      site: function site(value) { return this.getOrSet('location.site', value); }.bind(this),
+      country: function country(value) { return this.getOrSet('location.country', value); }.bind(this),
+      city: function city(value) { return this.getOrSet('location.city', value); }.bind(this),
+      address: function address(value) { return this.getOrSet('location.address', value); }.bind(this),
+      postcode: function postcode(value) { return this.getOrSet('location.postcode', value); }.bind(this),
+      room: function room(value) { return this.getOrSet('location.room', value); }.bind(this),
+      subRoom: function subRoom(value) { return this.getOrSet('location.subRoom', value); }.bind(this),
+      geo: function geo(value) { return this.getOrSet('location.geo', value); }.bind(this)
+    };
+    return loc;
+  }
+}
+
+module.exports = Resource;
+
+
+
+ + + + +
+ + + +
+ + + + + + + diff --git a/docs/opentmi-jsclient/0.8.1/resources.js.html b/docs/opentmi-jsclient/0.8.1/resources.js.html new file mode 100644 index 0000000..5b85227 --- /dev/null +++ b/docs/opentmi-jsclient/0.8.1/resources.js.html @@ -0,0 +1,218 @@ + + + + + JSDoc: Source: resources.js + + + + + + + + + + +
+ +

Source: resources.js

+ + + + + + +
+
+
// 3rd party modules
+const invariant = require('invariant');
+const _ = require('lodash');
+
+
+// application modules
+const Resource = require('./resource');
+const {
+  QueryBase, Collection, Document, notImplemented
+} = require('./utils');
+
+/**
+ * @class ResourcesQuery
+ */
+class ResourcesQuery extends QueryBase {
+  /* Find resources by id
+   * @param {string} id
+   * @return {MongooseQueryClient} returns this
+   */
+  id(id) {
+    invariant(_.isString(id), 'id should be a string');
+    return this.has({_id: id});
+  }
+
+  /**
+   * Find resources by hwid
+   * @param {String} id hardware id as a string
+   * @return {ResourcesQuery} returns this
+   */
+  hwid(id) {
+    invariant(_.isString(id), 'id should be a string');
+    return this.has({'hw.id': id});
+  }
+
+  /**
+   * Find resources by serial number
+   * @param {String}sn hardware serial number as a string
+   * @return {ResourcesQuery} returns this
+   */
+  hwsn(sn) {
+    invariant(_.isString(sn), 'sn should be a string');
+    return this.has({'hw.sn': sn});
+  }
+
+  /**
+   * Resource has parent
+   * @param {String} id - optional parent resource id
+   * @return {ResourcesQuery} returns this
+   */
+  hasParent(id = undefined) {
+    if (_.isUndefined(id)) {
+      return this.has({parent: {$exists: true}});
+    }
+    return this.has({parent: id});
+  }
+
+  /**
+   * Resource doesn't have parent
+   * @return {ResourcesQuery} returns this
+   */
+  hasNoParent() {
+    return this.has({parent: {$exists: false}});
+  }
+
+  /**
+   * Find resources with name
+   * @param {string} name resource name
+   * @return {ResourcesQuery} returns this
+   */
+  name(name) {
+    invariant(_.isString(name), 'type should be a string');
+    return this.has({name});
+  }
+
+  /**
+   * Find resources by type
+   * @param {string} type resource type
+   * @return {ResourcesQuery} returns this
+   */
+  type(type) {
+    invariant(_.isString(type), 'type should be a string');
+    return this.has({type});
+  }
+
+  /**
+   * Find resources by status
+   * @param {string} status resource status. One of 'active', 'maintenance', 'broken'
+   * @return {ResourcesQuery} returns this
+   */
+  status(status) {
+    const STATUS = ['active', 'maintenance', 'broken'];
+    invariant(STATUS.indexOf(status) >= 0, `Status '${status}' is not one of "${STATUS.join('", "')}"`);
+    return this.has({status: {value: status}});
+  }
+
+  /**
+   * Find resources by usage type
+   * @param {String} usageType resource usage type
+   * @return {ResourcesQuery} returns this
+   */
+  usageType(usageType) {
+    invariant(_.isString(usageType), 'usageType should be a string');
+    return this.has({usage: {type: usageType}});
+  }
+
+  /**
+   * Find resources by a tag
+   * @param {string} tag tag name
+   * @param {bool} isTrue tag value, optional. default: true
+   * @return {ResourcesQuery} returns this
+   */
+  haveTag(tag, isTrue = true) {
+    invariant(_.isBoolean(isTrue), 'isTrue should be a boolean');
+    const obj = {tags: {}};
+    obj.tags[tag] = isTrue;
+    return this.has(obj);
+  }
+
+  /**
+   * Find resources by multiple tags
+   * @param {array<String>} tags array of tag names
+   * @return {ResourcesQuery} returns this
+   */
+  haveTags(tags) {
+    invariant(_.isArray(tags), 'tags should be an array');
+    return _.reduce(tags, (acc, tag) => this.haveTag(tag), this);
+  }
+}
+
+
+class Resources extends Collection {
+  /**
+   * Constructor for Resources model
+   * @param {Transport} transport - transport object
+   */
+  constructor(transport) {
+    super(transport, '/api/v0/resources');
+    this._notImplemented = notImplemented;
+  }
+
+  /**
+   * Find Resources
+   * @return {ResourcesQuery} returns Query object
+   */
+  find() {
+    return new ResourcesQuery(this, Resource);
+  }
+
+  /**
+   * Update documents
+   * @return {Promise} not implemented
+   */
+  update() {
+    return this._notImplemented();
+  }
+
+  /**
+   * Create new Resource
+   * @return {Resource} returns new result
+   */
+  create() {
+    const NewResource = Document.IsNewDocument(Resource);
+    return new NewResource(this._transport);
+  }
+}
+
+module.exports = Resources;
+
+
+
+ + + + +
+ + + +
+ + + + + + + diff --git a/docs/opentmi-jsclient/0.8.1/result.js.html b/docs/opentmi-jsclient/0.8.1/result.js.html new file mode 100644 index 0000000..b70847b --- /dev/null +++ b/docs/opentmi-jsclient/0.8.1/result.js.html @@ -0,0 +1,120 @@ + + + + + JSDoc: Source: result.js + + + + + + + + + + +
+ +

Source: result.js

+ + + + + + +
+
+
// 3rd party modules
+// application modules
+const {Document} = require('./utils');
+
+
+class Result extends Document {
+  /**
+   * Constructor for Resources model
+   * @param {Transport}transport - Transport object
+   * @param {Object}resultJson result as a plain json
+   * @private
+   */
+  constructor(transport, resultJson) {
+    super(transport, '/api/v0/results', resultJson);
+  }
+
+  /**
+   * Get result as short string
+   * @return {string} returns result as single line
+   */
+  toString() {
+    return `${this.time()}: ${this.name} - ${this.verdict()}`;
+  }
+
+  /**
+   * Get test case id
+   * @param {String}value set tc id
+   * @return {string} test case id
+   */
+  tcid(value) {
+    return this.getOrSet('tcid', value);
+  }
+
+  /**
+   * Get test case id
+   */
+  get name() { return this.tcid(); }
+  /**
+   * Get test case id
+   */
+  get testcaseId() { return this.tcid(); }
+
+  /**
+   * Get result verdict
+   * @param {String}value set verdict
+   * @return {String} returns test verdict
+   */
+  verdict(value) {
+    return this.getOrSet('exec.verdict', value);
+  }
+
+  /**
+   * Get result creation time
+   * @returns {Date} result creation time
+   */
+  time() {
+    return this.get('cre.time');
+  }
+
+  /**
+   * Get execution duration
+   * @return {Number} test execution duration
+   */
+  duration() {
+    return this.get('exec.duration');
+  }
+}
+
+module.exports = Result;
+
+
+
+ + + + +
+ + + +
+ + + + + + + diff --git a/docs/opentmi-jsclient/0.8.1/results.js.html b/docs/opentmi-jsclient/0.8.1/results.js.html new file mode 100644 index 0000000..8f76591 --- /dev/null +++ b/docs/opentmi-jsclient/0.8.1/results.js.html @@ -0,0 +1,230 @@ + + + + + JSDoc: Source: results.js + + + + + + + + + + +
+ +

Source: results.js

+ + + + + + +
+
+
// 3rd party modules
+const Promise = require('bluebird');
+const _ = require('lodash');
+const invariant = require('invariant');
+
+// application modules
+const Result = require('./result');
+const {
+  QueryBase, Collection, Document, notImplemented
+} = require('./utils');
+
+/**
+ * @class ResultsQuery
+ */
+class ResultsQuery extends QueryBase {
+  /**
+   * Find results which are using hw dut(s)
+   * @return {ResultsQuery} returns this
+   */
+  isHW() {
+    return this.has({'exec.dut.type': 'hw'});
+  }
+
+  /**
+   * Find results by verdict
+   * @param {String}verdict test verdict
+   * @return {ResultsQuery} returns this
+   */
+  verdict(verdict) {
+    invariant(_.isString(verdict), 'verdictr should be a string');
+    return this.has({'exec.verdict': verdict});
+  }
+
+  /**
+   * Find failed test results
+   * @return {ResultsQuery} returns this
+   */
+  isFailed() {
+    return this.verdict('fail');
+  }
+
+  /**
+   * Find pass test results
+   * @return {ResultsQuery} returns this
+   */
+  isPass() {
+    return this.verdict('pass');
+  }
+
+  /**
+   * Find inconclusive results
+   * @return {ResultsQuery} returns this
+   */
+  isInconclusive() {
+    return this.verdict(('inconclusive'));
+  }
+
+  /**
+   * Find results which belong to campaign
+   * @param {String}campaign Campaign name
+   * @return {ResultsQuery} returns this
+   */
+  belongToCampaign(campaign) {
+    invariant(_.isString(campaign), 'campaign should be a string');
+    return this.has({'campaign.id': campaign});
+  }
+
+  /**
+   * Find results which belong to job
+   * @param {String}job job name
+   * @return {ResultsQuery} returns this
+   */
+  belongToJob(job) {
+    invariant(_.isString(job), 'job should be a string');
+    return this.has({'job.id': job});
+  }
+
+  /**
+   * Find results which note contains text
+   * @param {String}str string that contains in note
+   * @return {ResultsQuery} returns this
+   */
+  containsNote(str) {
+    invariant(_.isString(str), 'str should be a string');
+    return this.has({'exec.note': `/${str}/`});
+  }
+}
+
+class Results extends Collection {
+  /**
+   * Constructor for Resources model
+   * @param {Transport} transport - Transport object
+   */
+  constructor(transport) {
+    super(transport, '/api/v0/results');
+    this._notImplemented = notImplemented;
+    this._namespace = '/results';
+  }
+
+  /**
+   * connects to results related sio namespace
+   * @returns {Promise} resolves when connected
+   */
+  connect() {
+    return this._transport.connect(this._namespace);
+  }
+
+  /**
+   * Disconnect results related sio namespace
+   * @return {Promise} resolves when disconnected
+   */
+  disconnect() {
+    return this._transport.disconnectNamespace(this._namespace);
+  }
+
+  /**
+   * Listen results related events
+   * @param {String}event event to be listen. Supported events: 'new'
+   * @param {Function}callback callback which is called when event received
+   * @return {Promise} resolves when start listening
+   */
+  on(event, callback) {
+    if (event === 'new') {
+      return this._transport.sio('/results')
+        .then((socket) => {
+          socket.on('new', (data) => {
+            const result = new Result(this._transport, data);
+            callback(result);
+          });
+        });
+    }
+    return Promise.reject(new Error(`Event ${event} is not supported`));
+  }
+
+  /**
+   * remove event listener
+   * @param {String}event event name
+   * @param {Function}callback callback to be removed
+   * @return {Promise} resolves when ready
+   */
+  removeListener(event, callback) {
+    if (event === 'new') {
+      return this._transport.sio('/results')
+        .then(socket => socket.removeListener(event, callback));
+    }
+    return Promise.reject(new Error(`Event ${event} is not supported`));
+  }
+
+  /**
+   * Find Results
+   * @return {ResultsQuery} returns ResultsQuery object
+   * @example
+   *  Results.find()
+   *    .limit(10)
+   *    .exec() // find last 10 results
+   */
+  find() {
+    return new ResultsQuery(this, Result);
+  }
+
+  /**
+   * Update documents
+   * @return {Promise} not implemented
+   */
+  update() {
+    return this._notImplemented('results update is not implemented');
+  }
+
+  /**
+   * Create new Result
+   * @return {Result} returns new result
+   */
+  create() {
+    const NewResult = Document.IsNewDocument(Result);
+    return new NewResult(this._transport);
+  }
+}
+
+module.exports = Results;
+
+
+
+ + + + +
+ + + +
+ + + + + + + diff --git a/docs/opentmi-jsclient/0.8.1/schemas.js.html b/docs/opentmi-jsclient/0.8.1/schemas.js.html new file mode 100644 index 0000000..1872b96 --- /dev/null +++ b/docs/opentmi-jsclient/0.8.1/schemas.js.html @@ -0,0 +1,101 @@ + + + + + JSDoc: Source: schemas.js + + + + + + + + + + +
+ +

Source: schemas.js

+ + + + + + +
+
+
const invariant = require('invariant');
+const Promise = require('bluebird');
+const _ = require('lodash');
+
+
+/**
+ * Schemas object
+ */
+class Schemas {
+  /**
+   * Constructor for Schemas controller.
+   * Object manage all low level communication and authentication
+   * @param {Transport} transport - transport layer for communication
+   */
+  constructor(transport) {
+    invariant(transport, 'transport is mandatory');
+    this._transport = transport;
+  }
+
+  /**
+   * Get list of available collection names
+   * @return {Promise.<array<string>>} list of collections
+   */
+  collections() {
+    return this._transport.get('/api/v0/schemas')
+      .then(response => response.data);
+  }
+
+  /**
+   * Get collection json schema.
+   * This can be used for example generate html forms.
+   * @param {String}collection collection name
+   * @return {Promise.<object>} resolves collection schema as json-schema -format
+   */
+  schema(collection) {
+    return this._transport.get(`/api/v0/schemas/${collection}`)
+      .then(response => response.data);
+  }
+
+  /**
+   * get all schemas
+   * @return {Promise.<Object[]>} resolves array of schema objects
+   */
+  getAllSchemas() {
+    return this.collections()
+      .then(colls => Promise.all(_.map(colls, this.schema.bind(this))));
+  }
+}
+
+module.exports = Schemas;
+
+
+
+ + + + +
+ + + +
+ + + + + + + diff --git a/docs/opentmi-jsclient/0.8.1/scripts/linenumber.js b/docs/opentmi-jsclient/0.8.1/scripts/linenumber.js new file mode 100644 index 0000000..8d52f7e --- /dev/null +++ b/docs/opentmi-jsclient/0.8.1/scripts/linenumber.js @@ -0,0 +1,25 @@ +/*global document */ +(function() { + var source = document.getElementsByClassName('prettyprint source linenums'); + var i = 0; + var lineNumber = 0; + var lineId; + var lines; + var totalLines; + var anchorHash; + + if (source && source[0]) { + anchorHash = document.location.hash.substring(1); + lines = source[0].getElementsByTagName('li'); + totalLines = lines.length; + + for (; i < totalLines; i++) { + lineNumber++; + lineId = 'line' + lineNumber; + lines[i].id = lineId; + if (lineId === anchorHash) { + lines[i].className += ' selected'; + } + } + } +})(); diff --git a/docs/opentmi-jsclient/0.8.1/scripts/prettify/Apache-License-2.0.txt b/docs/opentmi-jsclient/0.8.1/scripts/prettify/Apache-License-2.0.txt new file mode 100644 index 0000000..d645695 --- /dev/null +++ b/docs/opentmi-jsclient/0.8.1/scripts/prettify/Apache-License-2.0.txt @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/docs/opentmi-jsclient/0.8.1/scripts/prettify/lang-css.js b/docs/opentmi-jsclient/0.8.1/scripts/prettify/lang-css.js new file mode 100644 index 0000000..041e1f5 --- /dev/null +++ b/docs/opentmi-jsclient/0.8.1/scripts/prettify/lang-css.js @@ -0,0 +1,2 @@ +PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\f\r ]+/,null," \t\r\n "]],[["str",/^"(?:[^\n\f\r"\\]|\\(?:\r\n?|\n|\f)|\\[\S\s])*"/,null],["str",/^'(?:[^\n\f\r'\\]|\\(?:\r\n?|\n|\f)|\\[\S\s])*'/,null],["lang-css-str",/^url\(([^"')]*)\)/i],["kwd",/^(?:url|rgb|!important|@import|@page|@media|@charset|inherit)(?=[^\w-]|$)/i,null],["lang-css-kw",/^(-?(?:[_a-z]|\\[\da-f]+ ?)(?:[\w-]|\\\\[\da-f]+ ?)*)\s*:/i],["com",/^\/\*[^*]*\*+(?:[^*/][^*]*\*+)*\//],["com", +/^(?:<\!--|--\>)/],["lit",/^(?:\d+|\d*\.\d+)(?:%|[a-z]+)?/i],["lit",/^#[\da-f]{3,6}/i],["pln",/^-?(?:[_a-z]|\\[\da-f]+ ?)(?:[\w-]|\\\\[\da-f]+ ?)*/i],["pun",/^[^\s\w"']+/]]),["css"]);PR.registerLangHandler(PR.createSimpleLexer([],[["kwd",/^-?(?:[_a-z]|\\[\da-f]+ ?)(?:[\w-]|\\\\[\da-f]+ ?)*/i]]),["css-kw"]);PR.registerLangHandler(PR.createSimpleLexer([],[["str",/^[^"')]+/]]),["css-str"]); diff --git a/docs/opentmi-jsclient/0.8.1/scripts/prettify/prettify.js b/docs/opentmi-jsclient/0.8.1/scripts/prettify/prettify.js new file mode 100644 index 0000000..eef5ad7 --- /dev/null +++ b/docs/opentmi-jsclient/0.8.1/scripts/prettify/prettify.js @@ -0,0 +1,28 @@ +var q=null;window.PR_SHOULD_USE_CONTINUATION=!0; +(function(){function L(a){function m(a){var f=a.charCodeAt(0);if(f!==92)return f;var b=a.charAt(1);return(f=r[b])?f:"0"<=b&&b<="7"?parseInt(a.substring(1),8):b==="u"||b==="x"?parseInt(a.substring(2),16):a.charCodeAt(1)}function e(a){if(a<32)return(a<16?"\\x0":"\\x")+a.toString(16);a=String.fromCharCode(a);if(a==="\\"||a==="-"||a==="["||a==="]")a="\\"+a;return a}function h(a){for(var f=a.substring(1,a.length-1).match(/\\u[\dA-Fa-f]{4}|\\x[\dA-Fa-f]{2}|\\[0-3][0-7]{0,2}|\\[0-7]{1,2}|\\[\S\s]|[^\\]/g),a= +[],b=[],o=f[0]==="^",c=o?1:0,i=f.length;c122||(d<65||j>90||b.push([Math.max(65,j)|32,Math.min(d,90)|32]),d<97||j>122||b.push([Math.max(97,j)&-33,Math.min(d,122)&-33]))}}b.sort(function(a,f){return a[0]-f[0]||f[1]-a[1]});f=[];j=[NaN,NaN];for(c=0;ci[0]&&(i[1]+1>i[0]&&b.push("-"),b.push(e(i[1])));b.push("]");return b.join("")}function y(a){for(var f=a.source.match(/\[(?:[^\\\]]|\\[\S\s])*]|\\u[\dA-Fa-f]{4}|\\x[\dA-Fa-f]{2}|\\\d+|\\[^\dux]|\(\?[!:=]|[()^]|[^()[\\^]+/g),b=f.length,d=[],c=0,i=0;c=2&&a==="["?f[c]=h(j):a!=="\\"&&(f[c]=j.replace(/[A-Za-z]/g,function(a){a=a.charCodeAt(0);return"["+String.fromCharCode(a&-33,a|32)+"]"}));return f.join("")}for(var t=0,s=!1,l=!1,p=0,d=a.length;p=5&&"lang-"===b.substring(0,5))&&!(o&&typeof o[1]==="string"))c=!1,b="src";c||(r[f]=b)}i=d;d+=f.length;if(c){c=o[1];var j=f.indexOf(c),k=j+c.length;o[2]&&(k=f.length-o[2].length,j=k-c.length);b=b.substring(5);B(l+i,f.substring(0,j),e,p);B(l+i+j,c,C(b,c),p);B(l+i+k,f.substring(k),e,p)}else p.push(l+i,b)}a.e=p}var h={},y;(function(){for(var e=a.concat(m), +l=[],p={},d=0,g=e.length;d=0;)h[n.charAt(k)]=r;r=r[1];n=""+r;p.hasOwnProperty(n)||(l.push(r),p[n]=q)}l.push(/[\S\s]/);y=L(l)})();var t=m.length;return e}function u(a){var m=[],e=[];a.tripleQuotedStrings?m.push(["str",/^(?:'''(?:[^'\\]|\\[\S\s]|''?(?=[^']))*(?:'''|$)|"""(?:[^"\\]|\\[\S\s]|""?(?=[^"]))*(?:"""|$)|'(?:[^'\\]|\\[\S\s])*(?:'|$)|"(?:[^"\\]|\\[\S\s])*(?:"|$))/,q,"'\""]):a.multiLineStrings?m.push(["str",/^(?:'(?:[^'\\]|\\[\S\s])*(?:'|$)|"(?:[^"\\]|\\[\S\s])*(?:"|$)|`(?:[^\\`]|\\[\S\s])*(?:`|$))/, +q,"'\"`"]):m.push(["str",/^(?:'(?:[^\n\r'\\]|\\.)*(?:'|$)|"(?:[^\n\r"\\]|\\.)*(?:"|$))/,q,"\"'"]);a.verbatimStrings&&e.push(["str",/^@"(?:[^"]|"")*(?:"|$)/,q]);var h=a.hashComments;h&&(a.cStyleComments?(h>1?m.push(["com",/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,q,"#"]):m.push(["com",/^#(?:(?:define|elif|else|endif|error|ifdef|include|ifndef|line|pragma|undef|warning)\b|[^\n\r]*)/,q,"#"]),e.push(["str",/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h|[a-z]\w*)>/,q])):m.push(["com",/^#[^\n\r]*/, +q,"#"]));a.cStyleComments&&(e.push(["com",/^\/\/[^\n\r]*/,q]),e.push(["com",/^\/\*[\S\s]*?(?:\*\/|$)/,q]));a.regexLiterals&&e.push(["lang-regex",/^(?:^^\.?|[!+-]|!=|!==|#|%|%=|&|&&|&&=|&=|\(|\*|\*=|\+=|,|-=|->|\/|\/=|:|::|;|<|<<|<<=|<=|=|==|===|>|>=|>>|>>=|>>>|>>>=|[?@[^]|\^=|\^\^|\^\^=|{|\||\|=|\|\||\|\|=|~|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\s*(\/(?=[^*/])(?:[^/[\\]|\\[\S\s]|\[(?:[^\\\]]|\\[\S\s])*(?:]|$))+\/)/]);(h=a.types)&&e.push(["typ",h]);a=(""+a.keywords).replace(/^ | $/g, +"");a.length&&e.push(["kwd",RegExp("^(?:"+a.replace(/[\s,]+/g,"|")+")\\b"),q]);m.push(["pln",/^\s+/,q," \r\n\t\xa0"]);e.push(["lit",/^@[$_a-z][\w$@]*/i,q],["typ",/^(?:[@_]?[A-Z]+[a-z][\w$@]*|\w+_t\b)/,q],["pln",/^[$_a-z][\w$@]*/i,q],["lit",/^(?:0x[\da-f]+|(?:\d(?:_\d+)*\d*(?:\.\d*)?|\.\d\+)(?:e[+-]?\d+)?)[a-z]*/i,q,"0123456789"],["pln",/^\\[\S\s]?/,q],["pun",/^.[^\s\w"-$'./@\\`]*/,q]);return x(m,e)}function D(a,m){function e(a){switch(a.nodeType){case 1:if(k.test(a.className))break;if("BR"===a.nodeName)h(a), +a.parentNode&&a.parentNode.removeChild(a);else for(a=a.firstChild;a;a=a.nextSibling)e(a);break;case 3:case 4:if(p){var b=a.nodeValue,d=b.match(t);if(d){var c=b.substring(0,d.index);a.nodeValue=c;(b=b.substring(d.index+d[0].length))&&a.parentNode.insertBefore(s.createTextNode(b),a.nextSibling);h(a);c||a.parentNode.removeChild(a)}}}}function h(a){function b(a,d){var e=d?a.cloneNode(!1):a,f=a.parentNode;if(f){var f=b(f,1),g=a.nextSibling;f.appendChild(e);for(var h=g;h;h=g)g=h.nextSibling,f.appendChild(h)}return e} +for(;!a.nextSibling;)if(a=a.parentNode,!a)return;for(var a=b(a.nextSibling,0),e;(e=a.parentNode)&&e.nodeType===1;)a=e;d.push(a)}var k=/(?:^|\s)nocode(?:\s|$)/,t=/\r\n?|\n/,s=a.ownerDocument,l;a.currentStyle?l=a.currentStyle.whiteSpace:window.getComputedStyle&&(l=s.defaultView.getComputedStyle(a,q).getPropertyValue("white-space"));var p=l&&"pre"===l.substring(0,3);for(l=s.createElement("LI");a.firstChild;)l.appendChild(a.firstChild);for(var d=[l],g=0;g=0;){var h=m[e];A.hasOwnProperty(h)?window.console&&console.warn("cannot override language handler %s",h):A[h]=a}}function C(a,m){if(!a||!A.hasOwnProperty(a))a=/^\s*=o&&(h+=2);e>=c&&(a+=2)}}catch(w){"console"in window&&console.log(w&&w.stack?w.stack:w)}}var v=["break,continue,do,else,for,if,return,while"],w=[[v,"auto,case,char,const,default,double,enum,extern,float,goto,int,long,register,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"], +"catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"],F=[w,"alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,dynamic_cast,explicit,export,friend,inline,late_check,mutable,namespace,nullptr,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"],G=[w,"abstract,boolean,byte,extends,final,finally,implements,import,instanceof,null,native,package,strictfp,super,synchronized,throws,transient"], +H=[G,"as,base,by,checked,decimal,delegate,descending,dynamic,event,fixed,foreach,from,group,implicit,in,interface,internal,into,is,lock,object,out,override,orderby,params,partial,readonly,ref,sbyte,sealed,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,var"],w=[w,"debugger,eval,export,function,get,null,set,undefined,var,with,Infinity,NaN"],I=[v,"and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"], +J=[v,"alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"],v=[v,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"],K=/^(DIR|FILE|vector|(de|priority_)?queue|list|stack|(const_)?iterator|(multi)?(set|map)|bitset|u?(int|float)\d*)/,N=/\S/,O=u({keywords:[F,H,w,"caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END"+ +I,J,v],hashComments:!0,cStyleComments:!0,multiLineStrings:!0,regexLiterals:!0}),A={};k(O,["default-code"]);k(x([],[["pln",/^[^]*(?:>|$)/],["com",/^<\!--[\S\s]*?(?:--\>|$)/],["lang-",/^<\?([\S\s]+?)(?:\?>|$)/],["lang-",/^<%([\S\s]+?)(?:%>|$)/],["pun",/^(?:<[%?]|[%?]>)/],["lang-",/^]*>([\S\s]+?)<\/xmp\b[^>]*>/i],["lang-js",/^]*>([\S\s]*?)(<\/script\b[^>]*>)/i],["lang-css",/^]*>([\S\s]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i]]), +["default-markup","htm","html","mxml","xhtml","xml","xsl"]);k(x([["pln",/^\s+/,q," \t\r\n"],["atv",/^(?:"[^"]*"?|'[^']*'?)/,q,"\"'"]],[["tag",/^^<\/?[a-z](?:[\w-.:]*\w)?|\/?>$/i],["atn",/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^\s"'>]*(?:[^\s"'/>]|\/(?=\s)))/],["pun",/^[/<->]+/],["lang-js",/^on\w+\s*=\s*"([^"]+)"/i],["lang-js",/^on\w+\s*=\s*'([^']+)'/i],["lang-js",/^on\w+\s*=\s*([^\s"'>]+)/i],["lang-css",/^style\s*=\s*"([^"]+)"/i],["lang-css",/^style\s*=\s*'([^']+)'/i],["lang-css", +/^style\s*=\s*([^\s"'>]+)/i]]),["in.tag"]);k(x([],[["atv",/^[\S\s]+/]]),["uq.val"]);k(u({keywords:F,hashComments:!0,cStyleComments:!0,types:K}),["c","cc","cpp","cxx","cyc","m"]);k(u({keywords:"null,true,false"}),["json"]);k(u({keywords:H,hashComments:!0,cStyleComments:!0,verbatimStrings:!0,types:K}),["cs"]);k(u({keywords:G,cStyleComments:!0}),["java"]);k(u({keywords:v,hashComments:!0,multiLineStrings:!0}),["bsh","csh","sh"]);k(u({keywords:I,hashComments:!0,multiLineStrings:!0,tripleQuotedStrings:!0}), +["cv","py"]);k(u({keywords:"caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END",hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["perl","pl","pm"]);k(u({keywords:J,hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["rb"]);k(u({keywords:w,cStyleComments:!0,regexLiterals:!0}),["js"]);k(u({keywords:"all,and,by,catch,class,else,extends,false,finally,for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then,true,try,unless,until,when,while,yes", +hashComments:3,cStyleComments:!0,multilineStrings:!0,tripleQuotedStrings:!0,regexLiterals:!0}),["coffee"]);k(x([],[["str",/^[\S\s]+/]]),["regex"]);window.prettyPrintOne=function(a,m,e){var h=document.createElement("PRE");h.innerHTML=a;e&&D(h,e);E({g:m,i:e,h:h});return h.innerHTML};window.prettyPrint=function(a){function m(){for(var e=window.PR_SHOULD_USE_CONTINUATION?l.now()+250:Infinity;p=0){var k=k.match(g),f,b;if(b= +!k){b=n;for(var o=void 0,c=b.firstChild;c;c=c.nextSibling)var i=c.nodeType,o=i===1?o?b:c:i===3?N.test(c.nodeValue)?b:o:o;b=(f=o===b?void 0:o)&&"CODE"===f.tagName}b&&(k=f.className.match(g));k&&(k=k[1]);b=!1;for(o=n.parentNode;o;o=o.parentNode)if((o.tagName==="pre"||o.tagName==="code"||o.tagName==="xmp")&&o.className&&o.className.indexOf("prettyprint")>=0){b=!0;break}b||((b=(b=n.className.match(/\blinenums\b(?::(\d+))?/))?b[1]&&b[1].length?+b[1]:!0:!1)&&D(n,b),d={g:k,h:n,i:b},E(d))}}p th:last-child { border-right: 1px solid #ddd; } + +.ancestors, .attribs { color: #999; } +.ancestors a, .attribs a +{ + color: #999 !important; + text-decoration: none; +} + +.clear +{ + clear: both; +} + +.important +{ + font-weight: bold; + color: #950B02; +} + +.yes-def { + text-indent: -1000px; +} + +.type-signature { + color: #aaa; +} + +.name, .signature { + font-family: Consolas, Monaco, 'Andale Mono', monospace; +} + +.details { margin-top: 14px; border-left: 2px solid #DDD; } +.details dt { width: 120px; float: left; padding-left: 10px; padding-top: 6px; } +.details dd { margin-left: 70px; } +.details ul { margin: 0; } +.details ul { list-style-type: none; } +.details li { margin-left: 30px; padding-top: 6px; } +.details pre.prettyprint { margin: 0 } +.details .object-value { padding-top: 0; } + +.description { + margin-bottom: 1em; + margin-top: 1em; +} + +.code-caption +{ + font-style: italic; + font-size: 107%; + margin: 0; +} + +.prettyprint +{ + border: 1px solid #ddd; + width: 80%; + overflow: auto; +} + +.prettyprint.source { + width: inherit; +} + +.prettyprint code +{ + font-size: 100%; + line-height: 18px; + display: block; + padding: 4px 12px; + margin: 0; + background-color: #fff; + color: #4D4E53; +} + +.prettyprint code span.line +{ + display: inline-block; +} + +.prettyprint.linenums +{ + padding-left: 70px; + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; +} + +.prettyprint.linenums ol +{ + padding-left: 0; +} + +.prettyprint.linenums li +{ + border-left: 3px #ddd solid; +} + +.prettyprint.linenums li.selected, +.prettyprint.linenums li.selected * +{ + background-color: lightyellow; +} + +.prettyprint.linenums li * +{ + -webkit-user-select: text; + -moz-user-select: text; + -ms-user-select: text; + user-select: text; +} + +.params .name, .props .name, .name code { + color: #4D4E53; + font-family: Consolas, Monaco, 'Andale Mono', monospace; + font-size: 100%; +} + +.params td.description > p:first-child, +.props td.description > p:first-child +{ + margin-top: 0; + padding-top: 0; +} + +.params td.description > p:last-child, +.props td.description > p:last-child +{ + margin-bottom: 0; + padding-bottom: 0; +} + +.disabled { + color: #454545; +} diff --git a/docs/opentmi-jsclient/0.8.1/styles/prettify-jsdoc.css b/docs/opentmi-jsclient/0.8.1/styles/prettify-jsdoc.css new file mode 100644 index 0000000..5a2526e --- /dev/null +++ b/docs/opentmi-jsclient/0.8.1/styles/prettify-jsdoc.css @@ -0,0 +1,111 @@ +/* JSDoc prettify.js theme */ + +/* plain text */ +.pln { + color: #000000; + font-weight: normal; + font-style: normal; +} + +/* string content */ +.str { + color: #006400; + font-weight: normal; + font-style: normal; +} + +/* a keyword */ +.kwd { + color: #000000; + font-weight: bold; + font-style: normal; +} + +/* a comment */ +.com { + font-weight: normal; + font-style: italic; +} + +/* a type name */ +.typ { + color: #000000; + font-weight: normal; + font-style: normal; +} + +/* a literal value */ +.lit { + color: #006400; + font-weight: normal; + font-style: normal; +} + +/* punctuation */ +.pun { + color: #000000; + font-weight: bold; + font-style: normal; +} + +/* lisp open bracket */ +.opn { + color: #000000; + font-weight: bold; + font-style: normal; +} + +/* lisp close bracket */ +.clo { + color: #000000; + font-weight: bold; + font-style: normal; +} + +/* a markup tag name */ +.tag { + color: #006400; + font-weight: normal; + font-style: normal; +} + +/* a markup attribute name */ +.atn { + color: #006400; + font-weight: normal; + font-style: normal; +} + +/* a markup attribute value */ +.atv { + color: #006400; + font-weight: normal; + font-style: normal; +} + +/* a declaration */ +.dec { + color: #000000; + font-weight: bold; + font-style: normal; +} + +/* a variable name */ +.var { + color: #000000; + font-weight: normal; + font-style: normal; +} + +/* a function name */ +.fun { + color: #000000; + font-weight: bold; + font-style: normal; +} + +/* Specify class=linenums on a pre to get line numbering */ +ol.linenums { + margin-top: 0; + margin-bottom: 0; +} diff --git a/docs/opentmi-jsclient/0.8.1/styles/prettify-tomorrow.css b/docs/opentmi-jsclient/0.8.1/styles/prettify-tomorrow.css new file mode 100644 index 0000000..b6f92a7 --- /dev/null +++ b/docs/opentmi-jsclient/0.8.1/styles/prettify-tomorrow.css @@ -0,0 +1,132 @@ +/* Tomorrow Theme */ +/* Original theme - https://github.com/chriskempson/tomorrow-theme */ +/* Pretty printing styles. Used with prettify.js. */ +/* SPAN elements with the classes below are added by prettyprint. */ +/* plain text */ +.pln { + color: #4d4d4c; } + +@media screen { + /* string content */ + .str { + color: #718c00; } + + /* a keyword */ + .kwd { + color: #8959a8; } + + /* a comment */ + .com { + color: #8e908c; } + + /* a type name */ + .typ { + color: #4271ae; } + + /* a literal value */ + .lit { + color: #f5871f; } + + /* punctuation */ + .pun { + color: #4d4d4c; } + + /* lisp open bracket */ + .opn { + color: #4d4d4c; } + + /* lisp close bracket */ + .clo { + color: #4d4d4c; } + + /* a markup tag name */ + .tag { + color: #c82829; } + + /* a markup attribute name */ + .atn { + color: #f5871f; } + + /* a markup attribute value */ + .atv { + color: #3e999f; } + + /* a declaration */ + .dec { + color: #f5871f; } + + /* a variable name */ + .var { + color: #c82829; } + + /* a function name */ + .fun { + color: #4271ae; } } +/* Use higher contrast and text-weight for printable form. */ +@media print, projection { + .str { + color: #060; } + + .kwd { + color: #006; + font-weight: bold; } + + .com { + color: #600; + font-style: italic; } + + .typ { + color: #404; + font-weight: bold; } + + .lit { + color: #044; } + + .pun, .opn, .clo { + color: #440; } + + .tag { + color: #006; + font-weight: bold; } + + .atn { + color: #404; } + + .atv { + color: #060; } } +/* Style */ +/* +pre.prettyprint { + background: white; + font-family: Consolas, Monaco, 'Andale Mono', monospace; + font-size: 12px; + line-height: 1.5; + border: 1px solid #ccc; + padding: 10px; } +*/ + +/* Specify class=linenums on a pre to get line numbering */ +ol.linenums { + margin-top: 0; + margin-bottom: 0; } + +/* IE indents via margin-left */ +li.L0, +li.L1, +li.L2, +li.L3, +li.L4, +li.L5, +li.L6, +li.L7, +li.L8, +li.L9 { + /* */ } + +/* Alternate shading for lines */ +li.L1, +li.L3, +li.L5, +li.L7, +li.L9 { + /* */ } diff --git a/docs/opentmi-jsclient/0.8.1/testcase.js.html b/docs/opentmi-jsclient/0.8.1/testcase.js.html new file mode 100644 index 0000000..12c5eba --- /dev/null +++ b/docs/opentmi-jsclient/0.8.1/testcase.js.html @@ -0,0 +1,112 @@ + + + + + JSDoc: Source: testcase.js + + + + + + + + + + +
+ +

Source: testcase.js

+ + + + + + +
+
+
// 3rd party modules
+// application modules
+const {Document} = require('./utils');
+
+
+class Testcase extends Document {
+  /**
+   * Constructor for Testcase model
+   * @param {Transport}transport - Transport object
+   * @param {Object}testcaseJson testcase as a plain json
+   * @private
+   */
+  constructor(transport, testcaseJson) {
+    super(transport, '/api/v0/testcases', testcaseJson);
+  }
+
+  /**
+   * Get result as short string
+   * @return {string} returns result as single line
+   */
+  toString() {
+    return `${this.name}: ${this.purpose()} (avg: ${this.duration()}s)`;
+  }
+
+  /**
+   * Get test case id
+   * @param {String|Testcase}value get or set testcase
+   * @return {string} test case id
+   */
+  tcid(value) {
+    return this.getOrSet('tcid', value);
+  }
+
+  /**
+   * Get test case id
+   */
+  get name() { return this.tcid(); }
+  /**
+   * Get test case id
+   */
+  get testcaseId() { return this.tcid(); }
+
+  /**
+   * Get average execution time
+   * @return {Number} test execution duration in seconds
+   */
+  duration() {
+    return this.get('history.durationAvg');
+  }
+
+  /**
+   * Get or set test case purpose
+   * @param {String}purpose purpose of tc
+   * @return {Testcase|String} returns purpose or Testcase
+   */
+  purpose(purpose) {
+    return this.getOrSet('other_info.purpose', purpose);
+  }
+}
+
+module.exports = Testcase;
+
+
+
+ + + + +
+ + + +
+ +
+ Documentation generated by JSDoc 3.5.5 on Mon Jan 07 2019 14:53:59 GMT+0200 (EET) +
+ + + + + diff --git a/docs/opentmi-jsclient/0.8.1/testcases.js.html b/docs/opentmi-jsclient/0.8.1/testcases.js.html new file mode 100644 index 0000000..aff3ea2 --- /dev/null +++ b/docs/opentmi-jsclient/0.8.1/testcases.js.html @@ -0,0 +1,154 @@ + + + + + JSDoc: Source: testcases.js + + + + + + + + + + +
+ +

Source: testcases.js

+ + + + + + +
+
+
// 3rd party modules
+const invariant = require('invariant');
+
+// application modules
+const Testcase = require('./testcase');
+const {
+  QueryBase,
+  Collection,
+  Document,
+  notImplemented
+} = require('./utils');
+
+/**
+ * @class TestcasesQuery
+ */
+class TestcasesQuery extends QueryBase {
+  /**
+   * Find testcases by id
+   * @param {String}id testcase id
+   * @return {ItemsQuery} returns this
+   */
+  tcid(id) {
+    return this.has({tcid: `/${id}/`});
+  }
+
+  /**
+   * Test case is marked as skip
+   * @return {TestcasesQuery} returns this
+   */
+  isSkip() {
+    return this.has({'execution.skip': true});
+  }
+
+  /**
+   * Test case is marked as archived
+   * @return {TestcasesQuery} returns this
+   */
+  isArchived() {
+    return this.has({'archive.value': true});
+  }
+
+  /**
+   * Find tests with type
+   * @param {String}type test case type e.g. smoke, acceptance,...
+   * @return {TestcasesQuery} returns this
+   */
+  type(type) {
+    const ALLOWED_TYPES = [
+      'installation',
+      'compatibility',
+      'smoke',
+      'regression',
+      'acceptance',
+      'alpha',
+      'beta',
+      'stability',
+      'functional',
+      'destructive',
+      'performance',
+      'reliability'
+    ];
+    invariant(ALLOWED_TYPES.indexOf(type) !== 0, 'not allowed type');
+    return this.has({'other_info.type': type});
+  }
+}
+
+class Testcases extends Collection {
+  /**
+   * Constructor for Items model
+   * @param {Transport} transport - Transport object
+   */
+  constructor(transport) {
+    super(transport, '/api/v0/testcases');
+    this._notImplemented = notImplemented;
+  }
+
+  /**
+   * Find Testcases
+   * @return {TestcasesQuery} returns Query object
+   */
+  find() {
+    return new TestcasesQuery(this, Testcase);
+  }
+
+  /**
+   * Update documents
+   * @return {Promise} not implemented
+   */
+  update() {
+    return this._notImplemented('Item update is not implemented');
+  }
+
+  /**
+   * Create new test case
+   * @return {Testcase} returns new test case without id
+   */
+  create() {
+    const NewTestcase = Document.IsNewDocument(Testcase);
+    return new NewTestcase(this._transport);
+  }
+}
+
+module.exports = Testcases;
+
+
+
+ + + + +
+ + + +
+ +
+ Documentation generated by JSDoc 3.5.5 on Mon Jan 07 2019 14:53:59 GMT+0200 (EET) +
+ + + + + diff --git a/docs/opentmi-jsclient/0.8.1/transports_index.js.html b/docs/opentmi-jsclient/0.8.1/transports_index.js.html new file mode 100644 index 0000000..6c4333d --- /dev/null +++ b/docs/opentmi-jsclient/0.8.1/transports_index.js.html @@ -0,0 +1,434 @@ + + + + + JSDoc: Source: transports/index.js + + + + + + + + + + +
+ +

Source: transports/index.js

+ + + + + + +
+
+
// 3rd party modules
+const SocketIO = require('socket.io-client');
+const axios = require('axios');
+const Promise = require('bluebird');
+const invariant = require('invariant');
+const _ = require('lodash');
+const jwtDecode = require('jwt-decode');
+
+// application modules
+const {debug, timeSince, Lock} = require('../utils');
+
+
+class Transport {
+  /**
+   * Constructor for default transport layer
+   * @param {String}host opentmi uri
+   * @param {Axios}Rest axios(default) -kind of object which provide REST API
+   * @param {SocketIO}IO   socket.io-client(default) -kind of object which provide event based communication
+   */
+  constructor(host = '', {Rest = axios, IO = SocketIO} = {}) {
+    this.Rest = Rest;
+    this.IO = IO;
+    this._refreshTokenLock = new Lock();
+    this._refreshTokenFunc = undefined;
+    this._token = undefined;
+    this._host = host;
+    this._latency = undefined;
+    this._ioRequests = {};
+    this._sockets = {};
+  }
+
+  /**
+   * Set refreshToken function
+   * @param {Function}func Promise function that refresh token
+   */
+  set refreshToken(func) {
+    invariant(_.isFunction(func) || _.isUndefined(func), 'func should be function or undefined');
+    this._refreshTokenFunc = func;
+  }
+  _refreshToken() {
+    if (!_.isFunction(this._refreshTokenFunc)) {
+      return Promise.reject(new Error('Refresh token function is missing'));
+    }
+    return this._refreshTokenLock.withLock(() => {
+      this._token = undefined;
+      return this._refreshTokenFunc()
+        .then(() => {
+          invariant(!this._hasTokenExpired(), 'Token is expired');
+        });
+    });
+  }
+  _decodedToken() {
+    return jwtDecode(this._token);
+  }
+  _hasTokenExpired() {
+    const {exp} = this._decodedToken();
+    const now = Date.now() / 1000;
+    return exp < now;
+  }
+
+  get _socket() {
+    return _.get(this._sockets, '');
+  }
+
+  /**
+   * get authentication token
+   * @return {string} returns token
+   */
+  get token() {
+    return this._token;
+  }
+
+  /**
+   * set new token
+   * @param {string} token set token
+   */
+  set token(token) {
+    invariant(_.isUndefined(token) || _.isString(token), 'You should call login() first');
+    this._token = token;
+  }
+
+  /**
+   * get current latency based on IO ping-pong packages
+   * @return {float} returns IO latency
+   */
+  get latency() {
+    return this._latency;
+  }
+
+  /**
+   * Check if we have logged in - and have a token
+   * @return {boolean} returns true have token
+   */
+  get isLoggedIn() {
+    return _.isString(this.token);
+  }
+
+  /**
+   * Check if IO is connected
+   * @return {boolean} returns true when IO is connected
+   */
+  get isConnected() {
+    return !_.isUndefined(this._socket);
+  }
+
+  get _headers() {
+    return this.isLoggedIn ? {Authorization: `Bearer ${this.token}`} : {};
+  }
+
+  _url(path = '') {
+    return `${this._host}${path}`;
+  }
+
+  /**
+   * Connect socketIO
+   * @param {string} namespace - optional namespace, should start with /
+   * @return {Promise} resolves IO connection
+   */
+  connect(namespace = '') {
+    return new Promise((resolve, reject) => {
+      invariant(this.isLoggedIn, 'token is not configured');
+      debug('Create socketIO connection');
+      const options = {
+        query: `token=${this.token}`
+      };
+      if (namespace.length > 0 && !namespace.startsWith('/')) {
+        reject(new Error('namespace should start with /'));
+        return;
+      }
+      const sioUrl = `${this._url()}${namespace}`;
+      debug(`socketIO url: ${sioUrl}, options: ${JSON.stringify(options)}`);
+      const socket = this.IO(sioUrl, options);
+      socket.once('connect', () => resolve(socket));
+      socket.once('reconnect', () => {
+        debug('reconnecting');
+      });
+      socket.once('connect_error', reject);
+      this._sockets[namespace] = socket;
+    }).then((socket) => {
+      debug('SocketIO connected');
+      socket.on('error', (error) => {
+        debug(error);
+      });
+      socket.on('reconnect', () => {
+        debug('socketIO reconnect');
+      });
+      socket.on('reconnect_attempt', () => {
+        debug('socketIO reconnect_attempt');
+      });
+      socket.on('reconnecting', (attempt) => {
+        debug(`socketIO reconnecting, attempt: ${attempt}`);
+      });
+      socket.on('reconnect_error', (error) => {
+        debug(error);
+      });
+      socket.on('reconnect_failed', (error) => {
+        debug(error);
+      });
+      socket.on('exit', () => {
+        debug('Server is attempt to exit...');
+      });
+      socket.on('pong', (latency) => {
+        this._latency = latency;
+        debug(`pong latency: ${latency}ms`);
+      });
+      return socket;
+    })
+      .catch((error) => {
+        debug(`socketIO connection fails: ${error.message}`);
+        throw error;
+      });
+  }
+  /**
+   * Disconnect SIO
+   * @return {Promise} resolves when IO is disconnected
+   */
+  disconnect() {
+    const nss = Object.keys(this._sockets);
+    const pending = _.map(nss, ns => this.disconnectNamespace(ns));
+    return Promise.all(pending);
+  }
+
+  disconnectNamespace(namespace = '') {
+    debug(`Disconnecting ns: ${namespace}`);
+    return this.sio(namespace)
+      .then(socket => new Promise((resolve) => {
+        invariant(socket, 'socket is not open');
+        socket.once('disconnect', resolve);
+        socket.disconnect();
+      }))
+      .then(() => {
+        debug('SocketIO disconnected');
+        _.unset(this._sockets, namespace);
+      });
+  }
+
+  /**
+   * low level request for IO channel
+   * @param {object} req - event: <string>, data: <object>[, timeout: <number]
+   * @returns {Promise} resolves when response is received
+   */
+  requestIO(req) {
+    /* class IOResponse {
+      constructor(req) {
+        this.Request = req;
+        this._time = new Date();
+      }
+      setResponse(data) {
+        this.Response = data;
+      }
+    } */
+    invariant(_.isObject(this._socket), 'Should be Connected');
+    invariant(_.isString(this._token), 'you are not logged in, jwt token missing');
+    invariant(_.isPlainObject(req), 'request should be object');
+    _.defaults(req, {timeout: 600000, data: {}, time: new Date()});
+    invariant(_.isString(req.event), 'event should be string');
+    invariant(_.isPlainObject(req.data), 'data should be object');
+    invariant(_.isNumber(req.timeout), 'timeout should be number');
+    debug(`requestIO: ${JSON.stringify(req)}`);
+    this._ioRequests[req.time] = req;
+    const pending = new Promise((resolve, reject) => {
+      this._socket.emit(req.event, req.data, (error, data) => {
+        if (pending.isPending()) {
+          debug(`Response in ${(new Date() - req.time)}ms`);
+          if (error) reject(error);
+          else resolve(data);
+        } else {
+          debug('Response received too late - Promise was rejected already');
+        }
+      });
+    })
+      .timeout(req.timeout)
+      .catch(Promise.TimeoutError, (error) => {
+        throw error;
+      })
+      .finally(() => {
+        delete this._ioRequests[req.time];
+      });
+    return pending;
+  }
+  /**
+   * Event emitter to the server
+   * @param {string} event - event name
+   * @param {object} data - optional data
+   * @param {number} timeout - optional timeout
+   * @return {Promise} resolves when emit is done
+   */
+  emit(event, data = {}, timeout = undefined) {
+    invariant(_.isString(event), 'event should be a string');
+    return this.requestIO({event, data, timeout});
+  }
+  /**
+   * REST request API
+   * @param {object} req - axios config -kind of object.
+   * default parameters:
+   * url: '/',
+   * method: 'get'
+   * @returns {Promise} resolves when request success
+   */
+  request(req) {
+    const {CancelToken} = this.Rest;
+    const source = CancelToken.source();
+    const config = _.defaults({}, req, {
+      url: '/',
+      method: 'get',
+      baseURL: this._host,
+      headers: this._headers,
+      cancelToken: source.token
+    });
+    debug(`Requesting: ${JSON.stringify(config)}`);
+    const startTime = new Date();
+    return Promise.try(() => this.Rest
+      .request(config)
+      .then((data) => {
+        const duration = timeSince(startTime);
+        debug(`Request finished in ${duration.milliseconds}ms`);
+        return data;
+      })
+      .catch((error) => {
+        if (error.response) {
+          // The request was made and the server responded with a status code
+          // that falls out of the range of 2xx
+          const data = _.get(error, 'response.data', {message: error.message});
+          debug(`Request fails with status ${error.response.status}, ${JSON.stringify(data)}`);
+          const status = _.get(error, 'response.status');
+          if (status === 503) {
+            const retryAfterSeconds = _.get(data, 'retryAfter', 2);
+            req.retryCount = _.get(req, 'retryCount', 1) - 1;
+            if (req.retryCount > 0) {
+              return Promise
+                .delay(retryAfterSeconds * 1000)
+                .then(() => this.request(req));
+            }
+          } else if (status === 401 && this._token) {
+            // Unauthorized
+            if (this._hasTokenExpired()) {
+              return this._refreshToken()
+                .then(() => this.request(req));
+            }
+          }
+          _.set(
+            error, 'message',
+            _.get(
+              error, 'response.data.message', // take message by default
+              _.get(
+                error, 'response.data.error', // then error if message not exists
+                error.message // last option to take original request failure reason
+              )
+            )
+          );
+        } else if (this.Rest.isCancel(error)) {
+          debug(`Request canceled: ${error.message}`);
+        } else if (error.request) {
+          // The request was made but no response was received
+          // `error.request` is an instance of XMLHttpRequest in the browser and an instance of
+          // http.ClientRequest in node.js
+          debug(error.request);
+        } else {
+          // Something happened in setting up the request that triggered an Error
+          debug('Error', error.message);
+        }
+        throw error;
+      }));
+    // source.cancel('Operation canceled by the user
+  }
+
+  /**
+   * HTTP Get request to server
+   * @param {string} url - path to the server
+   * @param {object} params - query parameters
+   * @return {Promise} - resolves response object
+   */
+  get(url, params) {
+    return this.request({url, params});
+  }
+
+  /**
+   * HTTP post request to server
+   * @param {string} url - path to the server
+   * @param {object} data - optional json data
+   * @param {object} headers - optional headers as json object
+   * @return {Promise} - resolves response object
+   */
+  post(url, data, headers = undefined) {
+    return this.request({
+      url, method: 'post', data, headers
+    });
+  }
+
+  /**
+   * Put request
+   * @param {String}url uri for request
+   * @param {object}data json object to be send
+   * @param {object}params json object for query parameters
+   * @return {Promise} - resolves response object
+   */
+  put(url, data, params) {
+    return this.request({
+      url, method: 'put', params, data
+    });
+  }
+
+  /**
+   * delete request
+   * @param {String}url uri for request
+   * @return {Promise} - resolves response object
+   */
+  delete(url) {
+    return this.request({url, method: 'delete'});
+  }
+
+  /**
+   * get socketIO instance
+   * @param {String}namespace namespace which socket to be get
+   * @return {Promise<SocketIO-client>} resolves SocketIO-client object for namespace
+   */
+  sio(namespace = '') {
+    const socket = _.get(this._sockets, namespace);
+    return socket ? Promise.resolve(socket) : Promise.reject(new Error('No socket open for this namespace'));
+  }
+}
+
+module.exports = Transport;
+
+
+
+ + + + +
+ + + +
+ +
+ Documentation generated by JSDoc 3.5.5 on Mon Jan 07 2019 14:53:59 GMT+0200 (EET) +
+ + + + + diff --git a/docs/opentmi-jsclient/0.8.1/user.js.html b/docs/opentmi-jsclient/0.8.1/user.js.html new file mode 100644 index 0000000..8639a33 --- /dev/null +++ b/docs/opentmi-jsclient/0.8.1/user.js.html @@ -0,0 +1,152 @@ + + + + + JSDoc: Source: user.js + + + + + + + + + + +
+ +

Source: user.js

+ + + + + + +
+
+
// 3rd party modules
+const _ = require('lodash');
+const Promise = require('bluebird');
+const invariant = require('invariant');
+
+// application modules
+const {Document} = require('./utils');
+const Group = require('./group');
+const Loans = require('./loans');
+
+
+class User extends Document {
+  /**
+   * Constructor for Resources model
+   * @param {Transport} transport - Transport object
+   * @param {Object}userJson User data as plain json object
+   */
+  constructor(transport, userJson) {
+    invariant(_.isPlainObject(userJson), 'userJson should be an object');
+    invariant(_.isString(userJson._id), '_id should be an string');
+    super(transport, `/api/v0/users/${userJson._id}`, userJson);
+  }
+
+  /**
+   * Get resource info as short string
+   * @return {string} user information as single line
+   */
+  toString() {
+    return `${this.name}`;
+  }
+
+  /**
+   * Get user name
+   * @return {String} returns user name
+   */
+  get name() { return this.get('name'); }
+
+  /**
+   * Get or set email address
+   * @param {String}email user email address
+   * @return {User|string} email address or this when updating
+   */
+  email(email) {
+    return this.getOrSet('email', email);
+  }
+
+  /**
+   * Get user owned apikeys
+   * @return {String|Object} returns apikeys
+   */
+  apikeys() {
+    return this.get('apikeys');
+  }
+
+  /**
+   * Get last visited date
+   * @return {Date} returns last visited as a Date
+   */
+  lastVisited() {
+    return new Date(this.get('lastVisited'));
+  }
+
+  /**
+   * Get user registeration date
+   * @return {Date} returns registered date
+   */
+  registered() {
+    return new Date(this.get('registered'));
+  }
+
+  /**
+   * Get user groups
+   * @return {Promise.<Group[]>} resolves user groups
+   */
+  groups() {
+    const promises = _.map(
+      this.get('groups'),
+      group => Group.fromId(this._transport, group)
+    );
+    return Promise.all(promises);
+  }
+
+  /**
+   * Check if user belong to admin group
+   * @return {Promise.<boolean>} resolves when ready
+   */
+  isAdmin() {
+    return this.groups()
+      .then(groups => !!_.find(groups, g => g.isAdmin()));
+  }
+
+  /**
+   * Resolve user loans
+   * @return {Promise.<Loan[]>} resolves user loans
+   */
+  myLoans() {
+    return Loans.forUser(this, this._transport);
+  }
+}
+
+module.exports = User;
+
+
+
+ + + + +
+ + + +
+ +
+ Documentation generated by JSDoc 3.5.5 on Mon Jan 07 2019 14:53:59 GMT+0200 (EET) +
+ + + + + diff --git a/docs/opentmi-jsclient/0.8.1/users.js.html b/docs/opentmi-jsclient/0.8.1/users.js.html new file mode 100644 index 0000000..bcf315d --- /dev/null +++ b/docs/opentmi-jsclient/0.8.1/users.js.html @@ -0,0 +1,126 @@ + + + + + JSDoc: Source: users.js + + + + + + + + + + +
+ +

Source: users.js

+ + + + + + +
+
+
// 3rd party modules
+const invariant = require('invariant');
+const _ = require('lodash');
+
+
+// application modules
+const User = require('./user');
+const {QueryBase, Collection, notImplemented} = require('./utils');
+
+/**
+ * @class UsersQuery
+ * @extends QueryBase
+ */
+class UsersQuery extends QueryBase {
+  /* Find users by id
+   * @param {string} type
+   * @return {Query}
+   */
+  id(id) {
+    invariant(_.isString(id), 'id should be a string');
+    return this.has({_id: id});
+  }
+}
+
+/**
+ * @extends Collection
+ */
+class Users extends Collection {
+  /**
+   * Constructor for Resources model
+   * @param {Transport} transport - transport object
+   */
+  constructor(transport) {
+    super(transport, '/api/v0/users');
+    this._notImplemented = notImplemented;
+  }
+
+  /**
+   * Find Users
+   * @return {UsersQuery} Returns query object to find Users
+   */
+  find() {
+    return new UsersQuery(this, User);
+  }
+
+  /**
+   * Find out who am I based on login
+   * @return {Promise.<User>} resolves User object
+   */
+  whoami() {
+    return this._transport
+      .get('/auth/me')
+      .then(response => new User(this._transport, response.data));
+  }
+
+  /**
+   * Find out who am I based on login
+   * @param {Transport}transport Transport layer
+   * @return {Promise.<User>} resolves User object
+   */
+  static WHOAMI(transport) {
+    const users = new Users(transport);
+    return users.whoami();
+  }
+
+  /**
+   * Update documents
+   * @return {Promise} not implemented
+   */
+  update() {
+    return this._notImplemented('Users update is not implemented');
+  }
+}
+
+module.exports = Users;
+
+
+
+ + + + +
+ + + +
+ +
+ Documentation generated by JSDoc 3.5.5 on Mon Jan 07 2019 14:53:59 GMT+0200 (EET) +
+ + + + + diff --git a/docs/opentmi-jsclient/0.8.1/utils_Lock.js.html b/docs/opentmi-jsclient/0.8.1/utils_Lock.js.html new file mode 100644 index 0000000..ad5581f --- /dev/null +++ b/docs/opentmi-jsclient/0.8.1/utils_Lock.js.html @@ -0,0 +1,109 @@ + + + + + JSDoc: Source: utils/Lock.js + + + + + + + + + + +
+ +

Source: utils/Lock.js

+ + + + + + +
+
+
const Promise = require('bluebird');
+
+const debug = require('./debug');
+
+
+class Lock {
+  /**
+   * Lock Constructor
+   */
+  constructor() {
+    this._lock = Promise.resolve();
+  }
+
+  /**
+   * Check if no pending actions
+   * @return {Boolean} True if lock is free
+   */
+  isResolved() {
+    return this._lock.isResolved();
+  }
+
+  /**
+   * Obtain lock. Pending actions will be wait.
+   * @example
+   * Promise.using(lock.obtainLock(), () => Promise.resolve());
+   * @return {Promise.disposer} Disposer to be used with Promise.using()
+   */
+  obtainLock() {
+    if (this._lock.isPending()) {
+      debug('wait pending lock');
+      return Promise
+        .join(this._lock)
+        .then(() => this.obtainLock());
+    }
+    let resolvePending;
+    this._lock = new Promise((resolve) => {
+      resolvePending = resolve;
+    });
+    return Promise.try(() => {
+      debug('locked');
+    }).disposer(() => {
+      debug('lock released');
+      resolvePending();
+    });
+  }
+
+  /**
+   * Run promise with lock. Parallel promises will be postponed until previous is fulfilled.
+   * @param {Function}then Promise function to be call
+   * @return {Promise} resolves/rejects argument given "then"
+   */
+  withLock(then) {
+    const lock = this.obtainLock();
+    return Promise.using(lock, then);
+  }
+}
+
+module.exports = Lock;
+
+
+
+ + + + +
+ + + +
+ +
+ Documentation generated by JSDoc 3.5.5 on Mon Jan 07 2019 14:53:59 GMT+0200 (EET) +
+ + + + + diff --git a/docs/opentmi-jsclient/0.8.1/utils_rest_base.js.html b/docs/opentmi-jsclient/0.8.1/utils_rest_base.js.html new file mode 100644 index 0000000..4088fff --- /dev/null +++ b/docs/opentmi-jsclient/0.8.1/utils_rest_base.js.html @@ -0,0 +1,85 @@ + + + + + JSDoc: Source: utils/rest/base.js + + + + + + + + + + +
+ +

Source: utils/rest/base.js

+ + + + + + +
+
+
const invariant = require('invariant');
+const {notImplemented} = require('../utils');
+
+/**
+ * @private
+ */
+class Base {
+  /**
+   * General base constructor for Rest resources
+   * @param {Transport} transport - Transport object<
+   * @param {string} path - path for collection REST API
+   */
+  constructor(transport, path) {
+    invariant(transport, 'transport is mandatory');
+    this._transport = transport;
+    this._path = path;
+    this._notImplemented = notImplemented;
+  }
+  docPath(id) {
+    return `${this._path}/${id}`;
+  }
+  colPath() { return this._path; }
+  /**
+   * set rest path
+   * @param {String}path path uri
+   * @return {Base} returns this
+   */
+  setPath(path) {
+    this._path = path;
+    return this;
+  }
+}
+
+module.exports = Base;
+
+
+
+ + + + +
+ + + +
+ +
+ Documentation generated by JSDoc 3.5.5 on Mon Jan 07 2019 14:53:59 GMT+0200 (EET) +
+ + + + + diff --git a/docs/opentmi-jsclient/0.8.1/utils_rest_document.js.html b/docs/opentmi-jsclient/0.8.1/utils_rest_document.js.html new file mode 100644 index 0000000..29b4cf3 --- /dev/null +++ b/docs/opentmi-jsclient/0.8.1/utils_rest_document.js.html @@ -0,0 +1,286 @@ + + + + + JSDoc: Source: utils/rest/document.js + + + + + + + + + + +
+ +

Source: utils/rest/document.js

+ + + + + + +
+
+
const invariant = require('invariant');
+const _ = require('lodash');
+
+const debug = require('../debug');
+const Base = require('./base');
+const retryUpdate = require('./../retry');
+
+/**
+ * Low level Document object, which handle modifications and storing
+ */
+class Document extends Base {
+  /**
+   * Document constructor
+   * @param {Transport}transport transport layer
+   * @param {String}path Document rest uri
+   * @param {Object}originalJson document data as plain json
+   */
+  constructor(transport, path, originalJson) {
+    super(transport, path);
+    this._idProperty = '_id';
+    if (_.isUndefined(originalJson)) {
+      debug('Construct new document');
+      // new object
+      this._original = undefined;
+      this._resource = {};
+    } else {
+      debug('Construct existing document');
+      // old object
+      invariant(_.isPlainObject(originalJson), 'originalJson should be plain object');
+      invariant(_.isString(originalJson[this._idProperty]), `originalJson should have ${this._idProperty}`);
+      this._original = _.cloneDeep(originalJson);
+      this._resource = _.cloneDeep(originalJson);
+    }
+    this._changes = {};
+    this._update = this._update.bind(this);
+  }
+
+  get isNew() {
+    return _.isUndefined(this._original);
+  }
+
+  /**
+   * Get resource data as plain json object
+   * @return {object} returns document as plain json
+   */
+  toJson() {
+    return _.cloneDeep(this._resource);
+  }
+
+  /**
+   * get changes as json object
+   * @return {object} returns changes as plain json
+   */
+  getChanges() {
+    return _.cloneDeep(this._changes);
+  }
+
+  /**
+   * returns true when there is changes made by client
+   * @return {boolean} check if document is "dirty" - has local changes
+   */
+  isDirty() {
+    return !_.isEqual(this._original, this._resource);
+  }
+
+  /**
+   * Save document. If conflicts happen try merge and save again.
+   * if there is no retries left or some server side changes causes conflict
+   * promise is rejected and reason property tells was it no retries left or merge conflicts.
+   * @param {Number}retryCount count how many times we try to save.
+   * @return {Promise} Resolves Document itself when save success
+   */
+  save(retryCount = 2) {
+    invariant(_.isNumber(retryCount), 'retryCount should be a number');
+    if (this.isDirty()) {
+      debug('Saving existing document');
+      const changes = this.getChanges();
+      invariant(changes[this._idProperty] !==
+        this._original[this._idProperty], `${this._idProperty} is not the same!!`);
+      changes.version = this.version;
+      return retryUpdate(this._original, changes, this._update, retryCount)
+        .then(() => this);
+    }
+    return Promise.reject(new Error('no changes'));
+  }
+
+  /**
+   * Get resource value by Key.
+   * @param {String} key - key can be nested as well like "a.b.c"
+   * @param {String} defaultValue optional default value
+   * @return {String|Object} value for the key or undefined if not found
+   */
+  get(key, defaultValue = undefined) {
+    return _.get(this._resource, key, defaultValue);
+  }
+
+  /**
+   * Set value for a key
+   * @param {String} key key for update
+   * @param {*}value value for update
+   * @return {Document} returns this
+   */
+  set(key, value) {
+    this._dirty = true;
+    if (_.isNull(value)) {
+      _.unset(this._resource, key);
+      this._changes[key] = null;
+    } else {
+      _.set(this._resource, key, value);
+      _.set(this._changes, key, value);
+    }
+    return this;
+  }
+
+  /**
+   * get or set value to resource.
+   * @example
+   * // returns Document
+   * doc.set('key1', 'myvalue')
+   *    .set('key2', 'val')
+   * @param {string} key - key to be get/set
+   * @param {*} value - undefined (default) to get value by key, null to remove key, others to set value
+   * @return {Resource|value} value or whole object when set
+   */
+  getOrSet(key, value = undefined) {
+    if (_.isUndefined(value)) {
+      return this.get(key);
+    }
+    return this.set(key, value);
+  }
+  /**
+   * Overwrite document with new allowedValue
+   * @param {Object} values - new data
+   * @return {Document} document object
+   */
+  overwrite(values) {
+    if (_.isEqual(this._resource, values)) {
+      return this;
+    }
+    if (this.isNew) {
+      this._resource = values;
+    } else {
+      this._changes = values;
+    }
+    return this;
+  }
+  /**
+   * getter for Document version
+   * @return {number} returns document version number
+   */
+  get version() { return this.get('__v'); }
+
+  /**
+   * Get resource identity
+   * @return {string} returns document id
+   */
+  get id() { return this.get(this._idProperty); }
+
+  get path() { return this.docPath(this.id); }
+
+  /**
+   * reload document information from backend.
+   * This also revert all client modified data back that is not saved!
+   * @return {Promise<Document>} resolves Document
+   */
+  refresh() {
+    return this._transport
+      .get(this.path)
+      .then((response) => {
+        this._original = _.cloneDeep(response.data);
+        this._resource = _.cloneDeep(response.data);
+      })
+      .then(() => this);
+  }
+
+  /**
+   * delete this document
+   * @return {Promise} Resolves when operation success
+   */
+  delete() {
+    return this._transport.delete({path: this.path});
+  }
+
+  /**
+   * Update document
+   * @param {Object}data data to be updated
+   * @returns {Promise} resolves when opration success
+   */
+  _update(data) {
+    return this._transport.put(this.path, data);
+  }
+}
+
+/**
+ * Mix Document object so that it is
+ * possible to store new document
+ * @param {Document}base Document object
+ * @return {NewDocument} returns mixed Document object
+ * @constructor
+ */
+function IsNewDocument(base) {
+  class NewDocument extends base {
+    /**
+     * Wrap save method for first save
+     * @return {Promise.<Document>} resolves Document
+     */
+    save() {
+      // wrap save only at the beginning.
+      // when document is stored first time succesfully
+      // wrap original save function.
+      debug('Saving new document');
+      return this._create(this._resource)
+        .then((response) => {
+          this._original = _.cloneDeep(response.data);
+          this._resource = _.cloneDeep(response.data);
+        })
+        .then(() => {
+          this.save = super.save; // continue old behavior
+          this._create = undefined; // no need create -api anymore
+          return this;
+        });
+    }
+    /**
+     * create document
+     * @param {Object}data document data to be stored
+     * @returns {Promise} resolves when opration success
+     */
+    _create(data) {
+      return this._transport.post(this.colPath(), data);
+    }
+  }
+  return NewDocument;
+}
+Document.IsNewDocument = IsNewDocument;
+module.exports = Document;
+
+
+
+ + + + +
+ + + +
+ +
+ Documentation generated by JSDoc 3.5.5 on Mon Jan 07 2019 14:53:59 GMT+0200 (EET) +
+ + + + + diff --git a/docs/opentmi-jsclient/0.8.1/utils_rest_mongooseQueryClient.js.html b/docs/opentmi-jsclient/0.8.1/utils_rest_mongooseQueryClient.js.html new file mode 100644 index 0000000..04f3488 --- /dev/null +++ b/docs/opentmi-jsclient/0.8.1/utils_rest_mongooseQueryClient.js.html @@ -0,0 +1,283 @@ + + + + + JSDoc: Source: utils/rest/mongooseQueryClient.js + + + + + + + + + + +
+ +

Source: utils/rest/mongooseQueryClient.js

+ + + + + + +
+
+
const invariant = require('invariant');
+const _ = require('lodash');
+const querystring = require('querystring');
+
+/** Query class
+ * Is pair for {@link https://github.com/jupe/mongoose-query|mongoose-query} -library which allows to
+ * construct DB queries based on rest query parameters
+ * @example
+ * mongooseQuery
+ *   .skip(10)      // skip first 10 docs
+ *   .limit(10)     // fetch only 10 docs
+ *   .has({a: '1'}) // find docs where a == '1'
+ */
+class MongooseQueryClient {
+  /**
+   * Query Constructor
+   */
+  constructor() {
+    /**
+     * Raw query object which can be converted as url parameter
+     * @type {{q: {}}}
+     * @private
+     */
+    this._query = {q: {}};
+  }
+
+  /**
+   * parse query from string
+   * @param {String}str uri parameters as a string
+   * @returns {MongooseQueryClient} returns itself
+   */
+  fromString(str) {
+    invariant(_.isString(str), 'str should be string');
+    this._query = querystring.parse(str);
+    if (_.has(this._query, 'q')) {
+      this._query.q = JSON.parse(this._query.q);
+    }
+    return this;
+  }
+
+  /**
+   * Returns query as a url string
+   * @return {string} returns query as a url parameters string
+   */
+  toString() {
+    const query = _.cloneDeep(this._query);
+    if (_.isEmpty(query.q)) delete query.q;
+    else query.q = JSON.stringify(query.q);
+    return querystring.stringify(query);
+  }
+
+  /**
+   * Return find -part object from query
+   * @return {MongooseQueryClient._query.q|{}} returns q part of query
+   */
+  get query() {
+    return this._query.q;
+  }
+
+  /**
+   * Get query type
+   * 'find', 'distinct', ...
+   */
+  get type() {
+    return this._query.t;
+  }
+
+  /**
+   * do default find query
+   * @return {MongooseQueryClient} returns itself
+   */
+  find() {
+    this._query.t = 'find';
+    return this;
+  }
+
+  /**
+   * Getter for query type. default: find
+   * @return {String} - query type
+   */
+  get queryType() {
+    return _.get(this._query, 't', 'find');
+  }
+
+  /**
+   * do distinct query
+   * @return {MongooseQueryClient} return itself
+   */
+  distinct() {
+    this._query.t = 'distinct';
+    return this;
+  }
+
+  /**
+   * fetch only first match document
+   * @return {MongooseQueryClient} return itself
+   */
+  findOne() {
+    this._query.t = 'findOne';
+    return this;
+  }
+
+  /**
+   * get just count of match document
+   * @return {MongooseQueryClient} return itself
+   */
+  count() {
+    this._query.t = 'count';
+    return this;
+  }
+
+  /**
+   * aggregate query
+   * @return {MongooseQueryClient} return itself
+   */
+  aggregate() {
+    this._query.t = 'aggregate';
+    return this;
+  }
+
+  /**
+   * mapReduce
+   * @param {Function|String}mapFunction map function
+   * @return {MongooseQueryClient} return itself
+   */
+  mapReduce(mapFunction) {
+    if (_.isFunction(mapFunction)) {
+      this._query.reduce = mapFunction.toString();
+    } else if (_.isString(mapFunction)) {
+      this._query.reduce = mapFunction;
+    } else {
+      invariant(false, 'mapFunction should be string or function');
+    }
+    this._query.t = 'mapReduce';
+    return this;
+  }
+
+  /**
+   * Populate selected fields
+   * @param {array<string>|String|Object} fields field(s) to be populated
+   * @return {MongooseQueryClient} return itself
+   */
+  populate(fields) {
+    invariant(
+      _.isArray(fields) || _.isString(fields) || _.isPlainObject(fields),
+      'fields should be string, array or plain object'
+    );
+    if (_.isString(fields)) {
+      // eslint-disable-next-line no-param-reassign
+      fields = [fields];
+    }
+    if (_.isArray(fields)) {
+      let p = _.get(this._query, 'p', '').split(' ');
+      p = _.filter(p, s => s.length);
+      p.push(...fields);
+      this._query.p = _.uniq(p).join(' ');
+    } else {
+      this._query.p = _.cloneDeep(fields);
+    }
+    return this;
+  }
+
+  /**
+   * Select fields
+   * @param {array<String>} fields to be fetch, e.g. ['name']
+   * @return {MongooseQueryClient} return itself
+   */
+  select(fields) {
+    invariant(_.isArray(fields), 'fields should be array');
+    this._query.f = _.uniq(fields).join(' ');
+    return this;
+  }
+
+  /**
+   * Result as a flat.
+   * e.g. {"a.b": "b"}
+   * @return {MongooseQueryClient} return itself
+   */
+  asFlat() {
+    this._query.fl = true;
+    return this;
+  }
+
+  /**
+   * Result as a json
+   * e.g. {"a": {"b": "b"}}
+   * @return {MongooseQueryClient} return itself
+   */
+  asJson() {
+    this._query.fl = false;
+    return this;
+  }
+
+  /**
+   * limit results
+   * @param {number} limit - maximum number of results to be fetched
+   * @return {MongooseQueryClient} return itself
+   */
+  limit(limit) {
+    invariant(_.isNumber(limit), 'limit should be number');
+    this._query.l = limit;
+    return this;
+  }
+
+  /**
+   * Skip number of results
+   * @param {number} skip - number of document to be skip
+   * @return {MongooseQueryClient} return itself
+   */
+  skip(skip) {
+    invariant(_.isNumber(skip), 'skip should be number');
+    this._query.sk = skip;
+    return this;
+  }
+
+  /**
+   * Document has "something", e.g. {name: "jussi"}
+   * @param {object} something object to be included in query
+   * @return {MongooseQueryClient} return itself
+   * @example
+   *  MongooseQueryClient
+   *    .has({'a': 'b'})
+   *    .has({'a': 'b'})
+   */
+  has(something) {
+    _.isPlainObject(something, 'something should be plain object');
+    _.merge(this._query.q, something);
+    return this;
+  }
+}
+
+module.exports = MongooseQueryClient;
+
+
+
+ + + + +
+ + + +
+ +
+ Documentation generated by JSDoc 3.5.5 on Mon Jan 07 2019 14:53:59 GMT+0200 (EET) +
+ + + + + diff --git a/docs/opentmi-jsclient/0.8.1/utils_rest_queryBase.js.html b/docs/opentmi-jsclient/0.8.1/utils_rest_queryBase.js.html new file mode 100644 index 0000000..d67add7 --- /dev/null +++ b/docs/opentmi-jsclient/0.8.1/utils_rest_queryBase.js.html @@ -0,0 +1,96 @@ + + + + + JSDoc: Source: utils/rest/queryBase.js + + + + + + + + + + +
+ +

Source: utils/rest/queryBase.js

+ + + + + + +
+
+
// 3rd party modules
+const Promise = require('bluebird');
+const _ = require('lodash');
+const invariant = require('invariant');
+
+// application modules
+const MongooseQueryClient = require('./mongooseQueryClient');
+
+/**
+ * @extends MongooseQueryClient
+ */
+class QueryBase extends MongooseQueryClient {
+  /**
+   * Constructor for QueryBase
+   * @param {Collection}collection collection object
+   * @param {Document}baseClass Class that collection holds
+   * @private
+   */
+  constructor(collection, baseClass) {
+    super();
+    this._collection = collection;
+    this._baseClass = baseClass;
+  }
+  /**
+   * Execute query based on previous selected options
+   * @param {Boolean} plain - do not convert to classes
+   * @return {Promise} - list of objects when 'find' (default) or plain json.
+   */
+  exec(plain = false) {
+    invariant(_.isBoolean(plain), 'plain should be boolean');
+    return this._exec()
+      .then((data) => {
+        if (!plain && this.queryType === 'find') {
+          return Promise.map(data, json => new this._baseClass(this._collection._transport, json));
+        }
+        return data;
+      });
+  }
+
+  _exec() {
+    return this._collection._find(this.toString());
+  }
+}
+
+module.exports = QueryBase;
+
+
+
+ + + + +
+ + + +
+ +
+ Documentation generated by JSDoc 3.5.5 on Mon Jan 07 2019 14:53:59 GMT+0200 (EET) +
+ + + + + diff --git a/docs/opentmi-jsclient/0.8.1/utils_utils.js.html b/docs/opentmi-jsclient/0.8.1/utils_utils.js.html new file mode 100644 index 0000000..577ad7c --- /dev/null +++ b/docs/opentmi-jsclient/0.8.1/utils_utils.js.html @@ -0,0 +1,108 @@ + + + + + JSDoc: Source: utils/utils.js + + + + + + + + + + +
+ +

Source: utils/utils.js

+ + + + + + +
+
+
const Promise = require('bluebird');
+
+/**
+ * Return object which contains duration between given date and current date
+ * @param {Date}when first date to be compared against current date
+ * @returns {Object} object which contains durations
+ */
+module.exports.timeSince = (when) => {
+  const obj = {};
+  obj._milliseconds = (new Date()).valueOf() - when.valueOf();
+  obj.milliseconds = obj._milliseconds % 1000;
+  obj._seconds = (obj._milliseconds - obj.milliseconds) / 1000;
+  obj.seconds = obj._seconds % 60;
+  obj._minutes = (obj._seconds - obj.seconds) / 60;
+  obj.minutes = obj._minutes % 60;
+  obj._hours = (obj._minutes - obj.minutes) / 60;
+  obj.hours = obj._hours % 24;
+  obj._days = (obj._hours - obj.hours) / 24;
+  obj.days = obj._days % 365;
+  // finally
+  obj.years = (obj._days - obj.days) / 365;
+  return obj;
+};
+
+/**
+ * Rejects with message "not implemented" (default msg)
+ * @param {String} msg - reject message
+ * @returns {Promise<String>} - reject
+ */
+module.exports.notImplemented = (msg = 'not implemented') => Promise.reject(new Error(msg));
+
+/**
+ * return date which are beginnign of given day
+ * @param {Date} date - input date
+ * @returns {Date} - date beginning of given day
+ */
+module.exports.beginningOfDay = (date) => {
+  const dateZero = new Date(date);
+  dateZero.setHours(0);
+  dateZero.setMinutes(0);
+  dateZero.setSeconds(0);
+  dateZero.setMilliseconds(0);
+  return dateZero;
+};
+/**
+ * return date which are end of given day
+ * @param {Date} date - input date
+ * @returns {Date} - date end of given day
+ */
+module.exports.endOfDay = (date) => {
+  const dateEnd = new Date(date);
+  dateEnd.setHours(23);
+  dateEnd.setMinutes(59);
+  dateEnd.setSeconds(59);
+  dateEnd.setMilliseconds(999);
+  return dateEnd;
+};
+
+
+
+ + + + +
+ + + +
+ +
+ Documentation generated by JSDoc 3.5.5 on Mon Jan 07 2019 14:53:59 GMT+0200 (EET) +
+ + + + + diff --git a/package-lock.json b/package-lock.json index 252586d..ee09425 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "opentmi-jsclient", - "version": "0.8.0", + "version": "0.8.1", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index d31a55c..ed2e727 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "opentmi-jsclient", - "version": "0.8.0", + "version": "0.8.1", "description": "OpenTMI javascript client", "main": "src/index.js", "authors": [