UNPKG

webgme-engine

Version:

WebGME server and Client API without a GUI

1,580 lines (514 loc) 27.8 kB
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>JSDoc: Module: serialization</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">Module: serialization</h1> <section> <header> </header> <article> <div class="container-overview"> <div class="description"><p>Functions for serializing a webgme project or models. These will work both on the client and server. <br> To include in your module (e.g. Plugin) require via 'common/util/serialization'. <br> <bold>Important!</bold> In order to export, the state must have been persisted in the database before exporting. If you make changes with the core make sure to persist and make a commit (it could be a headless commit too) before attempting to export.</p></div> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="common_util_serialization.js.html">common/util/serialization.js</a>, <a href="common_util_serialization.js.html#line15">line 15</a> </li></ul></dd> </dl> </div> <h3 class="subsection-title">Methods</h3> <h4 class="name" id=".exportModelsToFile"><span class="type-signature">(static) </span>exportModelsToFile<span class="signature">(project, blobClient, parameters, callback<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {Promise}</span></h4> <div class="description"> <p>Exports a selection of models and packages them in webgmexm file which is uploaded to the blob storage.</p> </div> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th>Attributes</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>project</code></td> <td class="type"> <span class="param-type"><a href="ProjectInterface.html">ProjectInterface</a></span> </td> <td class="attributes"> </td> <td class="description last"></td> </tr> <tr> <td class="name"><code>blobClient</code></td> <td class="type"> <span class="param-type"><a href="BlobClient.html">BlobClient</a></span> </td> <td class="attributes"> </td> <td class="description last"></td> </tr> <tr> <td class="name"><code>parameters</code></td> <td class="type"> <span class="param-type"><a href="global.html#object">object</a></span> </td> <td class="attributes"> </td> <td class="description last"><p>One of rootHash, commitHash and branchName and tagName must be given. If more than one is given, the order of precedence is: branchName, commitHash, tagName and rootHash.</p> <h6>Properties</h6> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th>Attributes</th> <th>Default</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>paths</code></td> <td class="type"> <span class="param-type"><a href="global.html#Array">Array</a>.&lt;<a href="global.html#string">string</a>></span> </td> <td class="attributes"> </td> <td class="default"> </td> <td class="description last"><p>Paths to node to export.</p></td> </tr> <tr> <td class="name"><code>rootHash</code></td> <td class="type"> <span class="param-type"><a href="global.html#string">string</a></span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> </td> <td class="description last"><p>The hash of the tree root.</p></td> </tr> <tr> <td class="name"><code>commitHash</code></td> <td class="type"> <span class="param-type"><a href="global.html#string">string</a></span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> </td> <td class="description last"><p>The tree associated with the commitHash.</p></td> </tr> <tr> <td class="name"><code>branchName</code></td> <td class="type"> <span class="param-type"><a href="global.html#string">string</a></span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> </td> <td class="description last"><p>The tree at the given branch.</p></td> </tr> <tr> <td class="name"><code>tagName</code></td> <td class="type"> <span class="param-type"><a href="global.html#string">string</a></span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> </td> <td class="description last"><p>The tree at the given tag.</p></td> </tr> <tr> <td class="name"><code>withAssets</code></td> <td class="type"> <span class="param-type"><a href="global.html#boolean">boolean</a></span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> false </td> <td class="description last"></td> </tr> <tr> <td class="name"><code>outName</code></td> <td class="type"> <span class="param-type"><a href="global.html#string">string</a></span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> </td> <td class="description last"><p>Name of the output blob (.webgmex will be appended).</p></td> </tr> </tbody> </table> </td> </tr> <tr> <td class="name"><code>callback</code></td> <td class="type"> <span class="param-type"><a href="global.html#function">function</a></span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="description last"> <h6>Properties</h6> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>err</code></td> <td class="type"> <span class="param-type"><a href="global.html#Error">Error</a></span> | <span class="param-type"><a href="global.html#null">null</a></span> </td> <td class="description last"><p>If there was an error</p></td> </tr> <tr> <td class="name"><code>result</code></td> <td class="type"> <span class="param-type"><a href="global.html#object">object</a></span> </td> <td class="description last"><p>Data about the exported project</p> <h6>Properties</h6> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>hash</code></td> <td class="type"> <span class="param-type"><a href="global.html#string">string</a></span> </td> <td class="description last"><p>Metadata hash to the exported webgmexm-file</p></td> </tr> <tr> <td class="name"><code>downloadUrl</code></td> <td class="type"> <span class="param-type"><a href="global.html#string">string</a></span> </td> <td class="description last"><p>Download url of the exported webgmexm-file</p></td> </tr> <tr> <td class="name"><code>fileName</code></td> <td class="type"> <span class="param-type"><a href="global.html#string">string</a></span> </td> <td class="description last"><p>The name of the exported webgmexm-file</p></td> </tr> </tbody> </table> </td> </tr> </tbody> </table> </td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="common_util_serialization.js.html">common/util/serialization.js</a>, <a href="common_util_serialization.js.html#line101">line 101</a> </li></ul></dd> </dl> <h5>Returns:</h5> <dl> <dt> Type </dt> <dd> <span class="param-type">Promise</span> </dd> </dl> <h4 class="name" id=".exportProjectToFile"><span class="type-signature">(static) </span>exportProjectToFile<span class="signature">(project, blobClient, parameters, callback<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {Promise}</span></h4> <div class="description"> <p>Exports a snap-shot of the entire project-tree and uploads a webgmex-file on the blob storage.</p> </div> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th>Attributes</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>project</code></td> <td class="type"> <span class="param-type"><a href="ProjectInterface.html">ProjectInterface</a></span> </td> <td class="attributes"> </td> <td class="description last"></td> </tr> <tr> <td class="name"><code>blobClient</code></td> <td class="type"> <span class="param-type"><a href="BlobClient.html">BlobClient</a></span> </td> <td class="attributes"> </td> <td class="description last"></td> </tr> <tr> <td class="name"><code>parameters</code></td> <td class="type"> <span class="param-type"><a href="global.html#object">object</a></span> </td> <td class="attributes"> </td> <td class="description last"><p>One of rootHash, commitHash and branchName and tagName must be given. If more than one is given, the order of precedence is: branchName, commitHash, tagName and rootHash.</p> <h6>Properties</h6> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th>Attributes</th> <th>Default</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>rootHash</code></td> <td class="type"> <span class="param-type"><a href="global.html#string">string</a></span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> </td> <td class="description last"><p>The hash of the tree root.</p></td> </tr> <tr> <td class="name"><code>commitHash</code></td> <td class="type"> <span class="param-type"><a href="global.html#string">string</a></span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> </td> <td class="description last"><p>The tree associated with the commitHash.</p></td> </tr> <tr> <td class="name"><code>branchName</code></td> <td class="type"> <span class="param-type"><a href="global.html#string">string</a></span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> </td> <td class="description last"><p>The tree at the given branch.</p></td> </tr> <tr> <td class="name"><code>tagName</code></td> <td class="type"> <span class="param-type"><a href="global.html#string">string</a></span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> </td> <td class="description last"><p>The tree at the given tag.</p></td> </tr> <tr> <td class="name"><code>withAssets</code></td> <td class="type"> <span class="param-type"><a href="global.html#boolean">boolean</a></span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> false </td> <td class="description last"><p>Bundle the encountered assets linked from attributes.</p></td> </tr> <tr> <td class="name"><code>kind</code></td> <td class="type"> <span class="param-type"><a href="global.html#string">string</a></span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> </td> <td class="description last"><p>If not given will use the one defined in project (if any).</p></td> </tr> <tr> <td class="name"><code>outName</code></td> <td class="type"> <span class="param-type"><a href="global.html#string">string</a></span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> </td> <td class="description last"><p>Name of the output blob (.webgmex will be appended).</p></td> </tr> </tbody> </table> </td> </tr> <tr> <td class="name"><code>callback</code></td> <td class="type"> <span class="param-type"><a href="global.html#function">function</a></span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="description last"> <h6>Properties</h6> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>err</code></td> <td class="type"> <span class="param-type"><a href="global.html#Error">Error</a></span> | <span class="param-type"><a href="global.html#null">null</a></span> </td> <td class="description last"><p>If there was an error</p></td> </tr> <tr> <td class="name"><code>result</code></td> <td class="type"> <span class="param-type"><a href="global.html#object">object</a></span> </td> <td class="description last"><p>Data about the exported project</p> <h6>Properties</h6> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>hash</code></td> <td class="type"> <span class="param-type"><a href="global.html#string">string</a></span> </td> <td class="description last"><p>Metadata hash to the exported webgmex-file</p></td> </tr> <tr> <td class="name"><code>downloadUrl</code></td> <td class="type"> <span class="param-type"><a href="global.html#string">string</a></span> </td> <td class="description last"><p>Download url of the exported webgmex-file</p></td> </tr> <tr> <td class="name"><code>fileName</code></td> <td class="type"> <span class="param-type"><a href="global.html#string">string</a></span> </td> <td class="description last"><p>The name of the exported webgmex-file</p></td> </tr> </tbody> </table> </td> </tr> </tbody> </table> </td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="common_util_serialization.js.html">common/util/serialization.js</a>, <a href="common_util_serialization.js.html#line47">line 47</a> </li></ul></dd> </dl> <h5>Returns:</h5> <dl> <dt> Type </dt> <dd> <span class="param-type">Promise</span> </dd> </dl> </article> </section> </div> <nav> <h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="Server_GMEAuth.html">Server:GMEAuth</a></li><li><a href="Server_SafeStorage.html">Server:SafeStorage</a></li><li><a href="Server_UserProject.html">Server:UserProject</a></li><li><a href="module-Core.html">Core</a></li><li><a href="module-Storage.html">Storage</a></li><li><a href="module-crosscuts.html">crosscuts</a></li><li><a href="module-serialization.html">serialization</a></li></ul><h3>Externals</h3><ul><li><a href="external-Promise.html">Promise</a></li></ul><h3>Classes</h3><ul><li><a href="AddOnBase.html">AddOnBase</a></li><li><a href="AddOnUpdateResult.html">AddOnUpdateResult</a></li><li><a href="Artifact.html">Artifact</a></li><li><a href="BlobClient.html">BlobClient</a></li><li><a href="BlobMetadata.html">BlobMetadata</a></li><li><a href="BlobRunPluginClient.html">BlobRunPluginClient</a></li><li><a href="Client.html">Client</a></li><li><a href="Core.html">Core</a></li><li><a href="ExecutorClient.html">ExecutorClient</a></li><li><a href="GMENode.html">GMENode</a></li><li><a href="GmeLogger.html">GmeLogger</a></li><li><a href="InterPluginResult.html">InterPluginResult</a></li><li><a href="JobInfo.html">JobInfo</a></li><li><a href="OutputInfo.html">OutputInfo</a></li><li><a href="PluginBase.html">PluginBase</a></li><li><a href="PluginConfig.html">PluginConfig</a></li><li><a href="PluginMessage.html">PluginMessage</a></li><li><a href="PluginNodeDescription.html">PluginNodeDescription</a></li><li><a href="PluginResult.html">PluginResult</a></li><li><a href="Project.html">Project</a></li><li><a href="ProjectInterface.html">ProjectInterface</a></li><li><a href="Server_GMEAuth-GMEAuth.html">GMEAuth</a></li><li><a href="Server_SafeStorage-SafeStorage.html">SafeStorage</a></li><li><a href="Server_UserProject-UserProject.html">UserProject</a></li><li><a href="WebsocketRouter.html">WebsocketRouter</a></li><li><a href="WebsocketRouterUser.html">WebsocketRouterUser</a></li></ul><h3>Events</h3><ul><li><a href="Client.html#event:BRANCH_CHANGED">BRANCH_CHANGED</a></li><li><a href="Client.html#event:BRANCH_CLOSED">BRANCH_CLOSED</a></li><li><a href="Client.html#event:BRANCH_OPENED">BRANCH_OPENED</a></li><li><a href="Client.html#event:BRANCH_STATUS_CHANGED">BRANCH_STATUS_CHANGED</a></li><li><a href="Client.html#event:CONNECTED_USERS_CHANGED">CONNECTED_USERS_CHANGED</a></li><li><a href="Client.html#event:NETWORK_STATUS_CHANGED">NETWORK_STATUS_CHANGED</a></li><li><a href="Client.html#event:NOTIFICATION">NOTIFICATION</a></li><li><a href="Client.html#event:PLUGIN_FINISHED">PLUGIN_FINISHED</a></li><li><a href="Client.html#event:PLUGIN_INITIATED">PLUGIN_INITIATED</a></li><li><a href="Client.html#event:PLUGIN_NOTIFICATION">PLUGIN_NOTIFICATION</a></li><li><a href="Client.html#event:PROJECT_CLOSED">PROJECT_CLOSED</a></li><li><a href="Client.html#event:PROJECT_OPENED">PROJECT_OPENED</a></li></ul><h3><a href="global.html">Global</a></h3> </nav> <br class="clear"> <footer> Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.2</a> on Fri Jun 21 2024 09:43:40 GMT-0400 (Eastern Daylight Time) </footer> <script> prettyPrint(); </script> <script src="scripts/linenumber.js"> </script> </body> </html>