UNPKG

nmos-ledger

Version:

NMOS discovery and registration APIs

182 lines (147 loc) 7.28 kB
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>JSDoc: Source: model/Flow.js</title> <script src="scripts/prettify/prettify.js"> </script> <script src="scripts/prettify/lang-css.js"> </script> <!--[if lt IE 9]> <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css"> <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css"> </head> <body> <div id="main"> <h1 class="page-title">Source: model/Flow.js</h1> <section> <article> <pre class="prettyprint source linenums"><code>/* Copyright 2015 Christine S. MacNeill 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 appli cable 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. */ var Versionned = require('./Versionned.js'); var immutable = require('seamless-immutable'); // Describes a Flow /** * Describes a Flow. Immutable value. * @constructor * @augments Versionned * @param {string} id Globally unique UUID identifier for the Flow. * @param {string} version String formatted PTP timestamp * (&amp;lt;&lt;em>seconds&lt;/em>&amp;gt;:&amp;lt;&lt;em>nanoseconds&lt;/em>&amp;gt;) * indicating precisely when an attribute of the resource * last changed. * @param {string} label Freeform string label for the Flow. * @param {string} description Detailed description of the Flow. * @param {string} format [Format]{@link formats} of the data coming from the * Flow as a URN. * @param {Object.&lt;string, string[]>} tags Key value set of freeform string tags * to aid in filtering Flows. Can be empty. * @param {string} source_id Globally unique UUID for the [source]{@link Source} * which initially created the Flow. * @param {string[]} parents Array of UUIDs representing the Flow IDs of Grains * which came together to generate this Flow. (May * change over the lifetime of this Flow). */ function Flow(id, version, label, description, format, tags, source_id, parents) { this.id = this.generateID(id); this.version = this.generateVersion(version); this.label = this.generateLabel(label); /** * Detailed description of the Flow. * @type {string} * @readonly */ this.description = this.generateDescription(description); /** * [Format]{@link formats} of the data coming from the Flow as a URN. * @type {string} * @readonly */ this.format = this.generateFormat(format); /** * Key value set of freeform string tags to aid in filtering Flows. Can be * empty. * @type {Array.&lt;string, string[]>} * @readonly */ this.tags = this.generateTags(tags); // Treating as a required property /** * Globally unique UUID identifier for the Flow which initially created the * Flow. * @type {string} * @readonly */ this.source_id = this.generateSourceID(source_id); // Array of UUIDs representing the Flow IDs of Grains which came together to // generate this Flow (may change over the lifetime of this Flow /** * Array of UUIDs representing the Flow IDs of Grains which came together to * generate this Flow. (May change over the lifetime of this Flow.) */ this.parents = this.generateParents(parents); return immutable(this, { prototype: Flow.prototype }); } Flow.prototype.validID = Versionned.prototype.validID; Flow.prototype.generateID = Versionned.prototype.generateID; Flow.prototype.validVersion = Versionned.prototype.validVersion; Flow.prototype.generateVersion = Versionned.prototype.generateVersion; Flow.prototype.validLabel = Versionned.prototype.validLabel; Flow.prototype.generateLabel = Versionned.prototype.generateLabel; Flow.prototype.validDescription = Versionned.prototype.validLabel; Flow.prototype.generateDescription = Versionned.prototype.generateLabel; Flow.prototype.validFormat = Versionned.prototype.validFormat; Flow.prototype.generateFormat = Versionned.prototype.generateFormat; Flow.prototype.validTags = Versionned.prototype.validTags; Flow.prototype.generateTags = Versionned.prototype.generateTags; Flow.prototype.validSourceID = Versionned.prototype.validID; Flow.prototype.generateSourceID = Versionned.prototype.generateID; Flow.prototype.validParents = function (parents) { if (arguments.length === 0) return this.validParents(this.parents); return Versionned.prototype.validUUIDArray(parents); } Flow.prototype.generateParents = Versionned.prototype.generateUUIDArray; Flow.prototype.valid = function() { return this.validID(this.id) &amp;&amp; this.validVersion(this.version) &amp;&amp; this.validLabel(this.label) &amp;&amp; this.validDescription(this.description) &amp;&amp; this.validFormat(this.format) &amp;&amp; this.validTags(this.tags) &amp;&amp; this.validSourceID(this.source_id) &amp;&amp; this.validParents(this.parents); } Flow.prototype.stringify = function () { return JSON.stringify(this) }; Flow.prototype.parse = function (json) { if (json === null || json === undefined || arguments.length === 0 || typeof json !== 'string') throw "Cannot parse JSON to a Flow value because it is not a valid input."; var parsed = JSON.parse(json); return new Flow(parsed.id, parsed.version, parsed.label, parsed.description, parsed.format, parsed.tags, parsed.source_id, parsed.parents); } module.exports = Flow; </code></pre> </article> </section> </div> <nav> <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Device.html">Device</a></li><li><a href="Flow.html">Flow</a></li><li><a href="Node.html">Node</a></li><li><a href="NodeAPI.html">NodeAPI</a></li><li><a href="NodeRAMStore.html">NodeRAMStore</a></li><li><a href="Versionned.html">Versionned</a></li></ul><h3>Interfaces</h3><ul><li><a href="NodeStore.html">NodeStore</a></li></ul><h3>Global</h3><ul><li><a href="global.html#capabilities">capabilities</a></li><li><a href="global.html#deviceTypes">deviceTypes</a></li><li><a href="global.html#formats">formats</a></li><li><a href="global.html#statusError">statusError</a></li><li><a href="global.html#transports">transports</a></li></ul> </nav> <br class="clear"> <footer> Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0</a> on Mon Dec 21 2015 17:19:49 GMT+0000 (GMT) </footer> <script> prettyPrint(); </script> <script src="scripts/linenumber.js"> </script> </body> </html>