gsweet
Version:
Help with writing scripts to run against gSuite
1,577 lines (397 loc) • 18.1 kB
HTML
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Module: drive/driveOps</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: drive/driveOps</h1>
<section>
<header>
</header>
<article>
<div class="container-overview">
</div>
<h3 class="subsection-title">Members</h3>
<h4 class="name" id="~mimeType"><span class="type-signature">(inner, constant) </span>mimeType<span class="type-signature"></span></h4>
<div class="description">
<p>Enum for the currently supported google mime-types</p>
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="drive_driveOps.js.html">drive/driveOps.js</a>, <a href="drive_driveOps.js.html#line23">line 23</a>
</li></ul></dd>
</dl>
<h3 class="subsection-title">Methods</h3>
<h4 class="name" id="~autoInit"><span class="type-signature">(inner) </span>autoInit<span class="signature">()</span><span class="type-signature"></span></h4>
<div class="description">
<p>In production just call this to set up access to the drive APIs</p>
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="drive_driveOps.js.html">drive/driveOps.js</a>, <a href="drive_driveOps.js.html#line50">line 50</a>
</li></ul></dd>
</dl>
<h4 class="name" id="~getFile"><span class="type-signature">(async, inner) </span>getFile<span class="signature">(withName)</span><span class="type-signature"> → {Promise.<{id:String, name:String}>}</span></h4>
<div class="description">
<p>Get a single file for the passed name. If a single file isn't found an error is thrown.<br>// @ts-ignore</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>withName</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="drive_driveOps.js.html">drive/driveOps.js</a>, <a href="drive_driveOps.js.html#line89">line 89</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
<p>a single object that has the FILE_META_FOR_NAME_SEARCH properties</p>
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Promise.<{id:String, name:String}></span>
</dd>
</dl>
<h5>Example</h5>
<pre class="prettyprint"><code>getFile({withName:"someName"}) //forces exactMatch:true</code></pre>
<h4 class="name" id="~getFileId"><span class="type-signature">(async, inner) </span>getFileId<span class="signature">(withNameObj)</span><span class="type-signature"> → {Promise.<string>}</span></h4>
<div class="description">
<p>Convenience function that returns the id for a file</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>withNameObj</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="drive_driveOps.js.html">drive/driveOps.js</a>, <a href="drive_driveOps.js.html#line104">line 104</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
<p>google id for the file</p>
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Promise.<string></span>
</dd>
</dl>
<h5>Example</h5>
<pre class="prettyprint"><code>getFileId({withName:"SomeName"})</code></pre>
<h4 class="name" id="~getFileNamesInFolder"><span class="type-signature">(async, inner) </span>getFileNamesInFolder<span class="signature">(folderOptions)</span><span class="type-signature"> → {Promise.<Array.<string>>}</span></h4>
<div class="description">
<p>Get just the names of the files in the folder (ofType is optional)</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>folderOptions</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="drive_driveOps.js.html">drive/driveOps.js</a>, <a href="drive_driveOps.js.html#line191">line 191</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
<p>array of strings containing filenames</p>
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Promise.<Array.<string>></span>
</dd>
</dl>
<h5>Example</h5>
<pre class="prettyprint"><code>getFileNamesInFolder({withFolderId:"someId", ofType:mimeType.SPREADSHEET)</code></pre>
<h4 class="name" id="~getFiles"><span class="type-signature">(async, inner) </span>getFiles<span class="signature">(fileOptions)</span><span class="type-signature"> → {Promise.<Array.<{id:String, name:String}>>}</span></h4>
<div class="description">
<p>Get a list of files/folders that match</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>fileOptions</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="drive_driveOps.js.html">drive/driveOps.js</a>, <a href="drive_driveOps.js.html#line61">line 61</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Promise.<Array.<{id:String, name:String}>></span>
</dd>
</dl>
<h5>Example</h5>
<pre class="prettyprint"><code>getFiles({withName:"someName", exactMatch:true})</code></pre>
<h4 class="name" id="~getFilesInFolder"><span class="type-signature">(async, inner) </span>getFilesInFolder<span class="signature">(folderOptions)</span><span class="type-signature"> → {Promise.<Array.<{name, id, mimeType}>>}</span></h4>
<div class="description">
<p>Get all the Files in the passed folderId (ofType is optional)</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>folderOptions</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="drive_driveOps.js.html">drive/driveOps.js</a>, <a href="drive_driveOps.js.html#line161">line 161</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
<p>array of file objects where each object has the properties
specified by the constant <code>FILE_META_FOR_FOLDER_SEARCH</code></p>
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Promise.<Array.<{name, id, mimeType}>></span>
</dd>
</dl>
<h5>Example</h5>
<pre class="prettyprint"><code>getFilesInFolder({withFolderId:"someId", ofType:mimeType:SPREADSHEET})</code></pre>
<h4 class="name" id="~getFilesRecursively"><span class="type-signature">(async, inner) </span>getFilesRecursively<span class="signature">(folderOptions)</span><span class="type-signature"> → {Promise.<Array.<{FILE_META_FOR_FOLDER_SEARCH}>>}</span></h4>
<div class="description">
<p>Get the files in the parent folder and all the children folders (ofType is optional)</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>folderOptions</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="drive_driveOps.js.html">drive/driveOps.js</a>, <a href="drive_driveOps.js.html#line204">line 204</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
<p>array of file objects where each object has the properties
specified by the constant <code>FILE_META_FOR_FOLDER_SEARCH</code></p>
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Promise.<Array.<{FILE_META_FOR_FOLDER_SEARCH}>></span>
</dd>
</dl>
<h5>Example</h5>
<pre class="prettyprint"><code>getFilesRecursively({withFolderId:"someId", ofType:mimeType.SPREADSHEET})</code></pre>
<h4 class="name" id="~getMimeTypeClause"><span class="type-signature">(inner) </span>getMimeTypeClause<span class="signature">(type)</span><span class="type-signature"> → {string}</span></h4>
<div class="description">
<p>Private helper function to look up the mimetype string for the passed enum and construct and "and" clause that
can be used in the API search query. The FILE enum isn't a type the API understands
but we use it to mean any type of file but NOT a folder.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>type</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="drive_driveOps.js.html">drive/driveOps.js</a>, <a href="drive_driveOps.js.html#line235">line 235</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
<p>the additional clause to limit the search for the specified type.
For example if mimeType.SPREADSHEET was passed in, then the clause<br>will be returned.</p>
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">string</span>
</dd>
</dl>
<h5>Example</h5>
<pre class="prettyprint"><code>getMimeTypeClause(mimeType.SPREADSHEET) will return `and mimeType = application/vnd.google-apps.spreadsheet`</code></pre>
<h4 class="name" id="~init"><span class="type-signature">(inner) </span>init<span class="signature">()</span><span class="type-signature"></span></h4>
<div class="description">
<p>Allow access to google drive APIs via the driveService (this version for testing)</p>
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="drive_driveOps.js.html">drive/driveOps.js</a>, <a href="drive_driveOps.js.html#line45">line 45</a>
</li></ul></dd>
</dl>
<h4 class="name" id="~listFiles"><span class="type-signature">(async, inner) </span>listFiles<span class="signature">()</span><span class="type-signature"> → {Promise.<Array.<{FILE_META_FOR_FOLDER_SEARCH}>>}</span></h4>
<div class="description">
<p>Just get the files for the user. Will only return the google API max
of 1000 files.</p>
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="drive_driveOps.js.html">drive/driveOps.js</a>, <a href="drive_driveOps.js.html#line116">line 116</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
<p>array of objects, where each object
has the properties specified by the constant <code>FILE_META_FOR_FOLDER_SEARCH</code></p>
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Promise.<Array.<{FILE_META_FOR_FOLDER_SEARCH}>></span>
</dd>
</dl>
<h5>Example</h5>
<pre class="prettyprint"><code>listFiles()</code></pre>
</article>
</section>
</div>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="Drive_driveOps.module_test.html">test</a></li><li><a href="module-drive_driveOps.html">drive/driveOps</a></li><li><a href="module-Drive_driveOps%2520Integration%2520Tests.html">Drive/driveOps Integration Tests</a></li><li><a href="module-drive_driveService.html">drive/driveService</a></li><li><a href="module-Sheet_sheetOps%2520Integration%2520Tests.html">Sheet/sheetOps Integration Tests</a></li><li><a href="sheets_sheetOps.module_js.html">sheets/sheetOps.js</a></li><li><a href="sheets_sheetService.module_js.html">sheets/sheetService.js</a></li><li><a href="-_sheetOps.module_test.html">test</a></li></ul>
</nav>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Sat May 11 2019 23:52:27 GMT-0700 (Pacific Daylight Time)
</footer>
<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>