updated API docs

This commit is contained in:
zadam 2020-09-30 22:48:30 +02:00
parent dd020baee5
commit 4f92fbf8a5
33 changed files with 2391 additions and 2833 deletions

View File

@ -293,7 +293,7 @@
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.4</a>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a>
</footer>
<script> prettyPrint(); </script>

View File

@ -106,7 +106,7 @@
<td class="description last"></td>
<td class="description last">immutable</td>
</tr>
@ -129,7 +129,7 @@
<td class="description last"></td>
<td class="description last">immutable</td>
</tr>
@ -152,7 +152,7 @@
<td class="description last"></td>
<td class="description last">immutable</td>
</tr>
@ -175,7 +175,7 @@
<td class="description last"></td>
<td class="description last">immutable</td>
</tr>
@ -244,7 +244,7 @@
<td class="description last"></td>
<td class="description last">immutable</td>
</tr>
@ -378,7 +378,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="entities_attribute.js.html">entities/attribute.js</a>, <a href="entities_attribute.js.html#line30">line 30</a>
<a href="entities_attribute.js.html">entities/attribute.js</a>, <a href="entities_attribute.js.html#line26">line 26</a>
</li></ul></dd>
@ -445,7 +445,112 @@
<h4 class="name" id="getNote"><span class="type-signature">(async) </span>getNote<span class="signature">()</span><span class="type-signature"> &rarr; {Promise.&lt;(<a href="Note.html">Note</a>|null)>}</span></h4>
<h4 class="name" id="getNote"><span class="type-signature"></span>getNote<span class="signature">()</span><span class="type-signature"> &rarr; {<a href="Note.html">Note</a>|null}</span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="entities_attribute.js.html">entities/attribute.js</a>, <a href="entities_attribute.js.html#line40">line 40</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type"><a href="Note.html">Note</a></span>
|
<span class="param-type">null</span>
</dd>
</dl>
<h4 class="name" id="getTargetNote"><span class="type-signature"></span>getTargetNote<span class="signature">()</span><span class="type-signature"> &rarr; {<a href="Note.html">Note</a>|null}</span></h4>
@ -529,109 +634,10 @@
</dt>
<dd>
<span class="param-type">Promise.&lt;(<a href="Note.html">Note</a>|null)></span>
<span class="param-type"><a href="Note.html">Note</a></span>
|
</dd>
</dl>
<h4 class="name" id="getTargetNote"><span class="type-signature">(async) </span>getTargetNote<span class="signature">()</span><span class="type-signature"> &rarr; {Promise.&lt;(<a href="Note.html">Note</a>|null)>}</span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="entities_attribute.js.html">entities/attribute.js</a>, <a href="entities_attribute.js.html#line54">line 54</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Promise.&lt;(<a href="Note.html">Note</a>|null)></span>
<span class="param-type">null</span>
</dd>
@ -697,7 +703,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="entities_attribute.js.html">entities/attribute.js</a>, <a href="entities_attribute.js.html#line69">line 69</a>
<a href="entities_attribute.js.html">entities/attribute.js</a>, <a href="entities_attribute.js.html#line62">line 62</a>
</li></ul></dd>
@ -767,7 +773,7 @@
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.4</a>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a>
</footer>
<script> prettyPrint(); </script>

View File

@ -471,7 +471,7 @@
<h4 class="name" id="createDataNote"><span class="type-signature"></span>createDataNote<span class="signature">(parentNoteId, title, content)</span><span class="type-signature"> &rarr; {Promise.&lt;{note: <a href="Note.html">Note</a>, branch: <a href="Branch.html">Branch</a>}>}</span></h4>
<h4 class="name" id="createDataNote"><span class="type-signature"></span>createDataNote<span class="signature">(parentNoteId, title, content)</span><span class="type-signature"> &rarr; {Object}</span></h4>
@ -619,7 +619,7 @@ JSON MIME type. See also createNewNote() for more options.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line204">line 204</a>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line205">line 205</a>
</li></ul></dd>
@ -655,7 +655,7 @@ JSON MIME type. See also createNewNote() for more options.
</dt>
<dd>
<span class="param-type">Promise.&lt;{note: <a href="Note.html">Note</a>, branch: <a href="Branch.html">Branch</a>}></span>
<span class="param-type">Object</span>
</dd>
@ -673,7 +673,7 @@ JSON MIME type. See also createNewNote() for more options.
<h4 class="name" id="createNewNote"><span class="type-signature"></span>createNewNote<span class="signature">(params<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {Promise.&lt;{note: <a href="Note.html">Note</a>, branch: <a href="Branch.html">Branch</a>}>}</span></h4>
<h4 class="name" id="createNewNote"><span class="type-signature"></span>createNewNote<span class="signature">(params<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {Object}</span></h4>
@ -782,7 +782,7 @@ JSON MIME type. See also createNewNote() for more options.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line231">line 231</a>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line232">line 232</a>
</li></ul></dd>
@ -822,7 +822,7 @@ JSON MIME type. See also createNewNote() for more options.
</dt>
<dd>
<span class="param-type">Promise.&lt;{note: <a href="Note.html">Note</a>, branch: <a href="Branch.html">Branch</a>}></span>
<span class="param-type">Object</span>
</dd>
@ -840,7 +840,7 @@ JSON MIME type. See also createNewNote() for more options.
<h4 class="name" id="createNote"><span class="type-signature"></span>createNote<span class="signature">(parentNoteId, title, content<span class="signature-attributes">opt</span>, extraOptions<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {Promise.&lt;{note: <a href="Note.html">Note</a>, branch: <a href="Branch.html">Branch</a>}>}</span></h4>
<h4 class="name" id="createNote"><span class="type-signature"></span>createNote<span class="signature">(parentNoteId, title, content<span class="signature-attributes">opt</span>, extraOptions<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {Object}</span></h4>
@ -1054,7 +1054,7 @@ JSON MIME type. See also createNewNote() for more options.
<dt class="important tag-deprecated">Deprecated:</dt><dd><ul class="dummy"><li>please use createNote() API method instead</li></ul></dd>
<dt class="important tag-deprecated">Deprecated:</dt><dd><ul class="dummy"><li>please use createNewNote() API method instead</li></ul></dd>
@ -1068,7 +1068,7 @@ JSON MIME type. See also createNewNote() for more options.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line259">line 259</a>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line260">line 260</a>
</li></ul></dd>
@ -1108,7 +1108,7 @@ JSON MIME type. See also createNewNote() for more options.
</dt>
<dd>
<span class="param-type">Promise.&lt;{note: <a href="Note.html">Note</a>, branch: <a href="Branch.html">Branch</a>}></span>
<span class="param-type">Object</span>
</dd>
@ -1126,7 +1126,7 @@ JSON MIME type. See also createNewNote() for more options.
<h4 class="name" id="createTextNote"><span class="type-signature"></span>createTextNote<span class="signature">(parentNoteId, title, content)</span><span class="type-signature"> &rarr; {Promise.&lt;{note: <a href="Note.html">Note</a>, branch: <a href="Branch.html">Branch</a>}>}</span></h4>
<h4 class="name" id="createTextNote"><span class="type-signature"></span>createTextNote<span class="signature">(parentNoteId, title, content)</span><span class="type-signature"> &rarr; {Object}</span></h4>
@ -1273,7 +1273,7 @@ JSON MIME type. See also createNewNote() for more options.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line188">line 188</a>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line189">line 189</a>
</li></ul></dd>
@ -1309,7 +1309,7 @@ JSON MIME type. See also createNewNote() for more options.
</dt>
<dd>
<span class="param-type">Promise.&lt;{note: <a href="Note.html">Note</a>, branch: <a href="Branch.html">Branch</a>}></span>
<span class="param-type">Object</span>
</dd>
@ -1327,7 +1327,7 @@ JSON MIME type. See also createNewNote() for more options.
<h4 class="name" id="ensureNoteIsAbsentFromParent"><span class="type-signature"></span>ensureNoteIsAbsentFromParent<span class="signature">(noteId, parentNoteId)</span><span class="type-signature"> &rarr; {Promise.&lt;void>}</span></h4>
<h4 class="name" id="ensureNoteIsAbsentFromParent"><span class="type-signature"></span>ensureNoteIsAbsentFromParent<span class="signature">(noteId, parentNoteId)</span><span class="type-signature"> &rarr; {void}</span></h4>
@ -1451,7 +1451,7 @@ JSON MIME type. See also createNewNote() for more options.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line159">line 159</a>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line160">line 160</a>
</li></ul></dd>
@ -1487,7 +1487,7 @@ JSON MIME type. See also createNewNote() for more options.
</dt>
<dd>
<span class="param-type">Promise.&lt;void></span>
<span class="param-type">void</span>
</dd>
@ -1505,7 +1505,7 @@ JSON MIME type. See also createNewNote() for more options.
<h4 class="name" id="ensureNoteIsPresentInParent"><span class="type-signature"></span>ensureNoteIsPresentInParent<span class="signature">(noteId, parentNoteId, prefix)</span><span class="type-signature"> &rarr; {Promise.&lt;void>}</span></h4>
<h4 class="name" id="ensureNoteIsPresentInParent"><span class="type-signature"></span>ensureNoteIsPresentInParent<span class="signature">(noteId, parentNoteId, prefix)</span><span class="type-signature"> &rarr; {void}</span></h4>
@ -1652,7 +1652,7 @@ JSON MIME type. See also createNewNote() for more options.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line149">line 149</a>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line150">line 150</a>
</li></ul></dd>
@ -1688,7 +1688,7 @@ JSON MIME type. See also createNewNote() for more options.
</dt>
<dd>
<span class="param-type">Promise.&lt;void></span>
<span class="param-type">void</span>
</dd>
@ -1754,7 +1754,7 @@ JSON MIME type. See also createNewNote() for more options.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line398">line 398</a>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line397">line 397</a>
</li></ul></dd>
@ -1815,7 +1815,7 @@ JSON MIME type. See also createNewNote() for more options.
<h4 class="name" id="getAttribute"><span class="type-signature"></span>getAttribute<span class="signature">(attributeId)</span><span class="type-signature"> &rarr; {Promise.&lt;(<a href="Attribute.html">Attribute</a>|null)>}</span></h4>
<h4 class="name" id="getAttribute"><span class="type-signature"></span>getAttribute<span class="signature">(attributeId)</span><span class="type-signature"> &rarr; {<a href="Attribute.html">Attribute</a>|null}</span></h4>
@ -1948,7 +1948,10 @@ JSON MIME type. See also createNewNote() for more options.
</dt>
<dd>
<span class="param-type">Promise.&lt;(<a href="Attribute.html">Attribute</a>|null)></span>
<span class="param-type"><a href="Attribute.html">Attribute</a></span>
|
<span class="param-type">null</span>
</dd>
@ -1966,7 +1969,7 @@ JSON MIME type. See also createNewNote() for more options.
<h4 class="name" id="getBranch"><span class="type-signature"></span>getBranch<span class="signature">(branchId)</span><span class="type-signature"> &rarr; {Promise.&lt;(<a href="Branch.html">Branch</a>|null)>}</span></h4>
<h4 class="name" id="getBranch"><span class="type-signature"></span>getBranch<span class="signature">(branchId)</span><span class="type-signature"> &rarr; {<a href="Branch.html">Branch</a>|null}</span></h4>
@ -2099,7 +2102,10 @@ JSON MIME type. See also createNewNote() for more options.
</dt>
<dd>
<span class="param-type">Promise.&lt;(<a href="Branch.html">Branch</a>|null)></span>
<span class="param-type"><a href="Branch.html">Branch</a></span>
|
<span class="param-type">null</span>
</dd>
@ -2117,7 +2123,7 @@ JSON MIME type. See also createNewNote() for more options.
<h4 class="name" id="getDateNote"><span class="type-signature"></span>getDateNote<span class="signature">(date)</span><span class="type-signature"> &rarr; {Promise.&lt;(<a href="Note.html">Note</a>|null)>}</span></h4>
<h4 class="name" id="getDateNote"><span class="type-signature"></span>getDateNote<span class="signature">(date)</span><span class="type-signature"> &rarr; {<a href="Note.html">Note</a>|null}</span></h4>
@ -2218,7 +2224,7 @@ JSON MIME type. See also createNewNote() for more options.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line315">line 315</a>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line318">line 318</a>
</li></ul></dd>
@ -2254,7 +2260,10 @@ JSON MIME type. See also createNewNote() for more options.
</dt>
<dd>
<span class="param-type">Promise.&lt;(<a href="Note.html">Note</a>|null)></span>
<span class="param-type"><a href="Note.html">Note</a></span>
|
<span class="param-type">null</span>
</dd>
@ -2272,7 +2281,7 @@ JSON MIME type. See also createNewNote() for more options.
<h4 class="name" id="getEntities"><span class="type-signature"></span>getEntities<span class="signature">(SQL, array)</span><span class="type-signature"> &rarr; {Promise.&lt;Array.&lt;<a href="Entity.html">Entity</a>>>}</span></h4>
<h4 class="name" id="getEntities"><span class="type-signature"></span>getEntities<span class="signature">(SQL, array)</span><span class="type-signature"> &rarr; {Array.&lt;<a href="Entity.html">Entity</a>>}</span></h4>
@ -2392,7 +2401,7 @@ JSON MIME type. See also createNewNote() for more options.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line94">line 94</a>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line87">line 87</a>
</li></ul></dd>
@ -2428,7 +2437,7 @@ JSON MIME type. See also createNewNote() for more options.
</dt>
<dd>
<span class="param-type">Promise.&lt;Array.&lt;<a href="Entity.html">Entity</a>>></span>
<span class="param-type">Array.&lt;<a href="Entity.html">Entity</a>></span>
</dd>
@ -2446,7 +2455,7 @@ JSON MIME type. See also createNewNote() for more options.
<h4 class="name" id="getEntity"><span class="type-signature"></span>getEntity<span class="signature">(SQL, array)</span><span class="type-signature"> &rarr; {Promise.&lt;(<a href="Entity.html">Entity</a>|null)>}</span></h4>
<h4 class="name" id="getEntity"><span class="type-signature"></span>getEntity<span class="signature">(SQL, array)</span><span class="type-signature"> &rarr; {<a href="Entity.html">Entity</a>|null}</span></h4>
@ -2570,7 +2579,7 @@ JSON MIME type. See also createNewNote() for more options.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line86">line 86</a>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line79">line 79</a>
</li></ul></dd>
@ -2606,158 +2615,10 @@ JSON MIME type. See also createNewNote() for more options.
</dt>
<dd>
<span class="param-type">Promise.&lt;(<a href="Entity.html">Entity</a>|null)></span>
<span class="param-type"><a href="Entity.html">Entity</a></span>
|
</dd>
</dl>
<h4 class="name" id="getImage"><span class="type-signature"></span>getImage<span class="signature">(imageId)</span><span class="type-signature"> &rarr; {Promise.&lt;(Image|null)>}</span></h4>
<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>imageId</code></td>
<td class="type">
<span class="param-type">string</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="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line76">line 76</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Promise.&lt;(Image|null)></span>
<span class="param-type">null</span>
</dd>
@ -2885,7 +2746,7 @@ if some action needs to happen on only one specific instance.
<h4 class="name" id="getMonthNote"><span class="type-signature"></span>getMonthNote<span class="signature">(date)</span><span class="type-signature"> &rarr; {Promise.&lt;(<a href="Note.html">Note</a>|null)>}</span></h4>
<h4 class="name" id="getMonthNote"><span class="type-signature"></span>getMonthNote<span class="signature">(date)</span><span class="type-signature"> &rarr; {<a href="Note.html">Note</a>|null}</span></h4>
@ -2986,7 +2847,7 @@ if some action needs to happen on only one specific instance.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line342">line 342</a>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line345">line 345</a>
</li></ul></dd>
@ -3022,7 +2883,10 @@ if some action needs to happen on only one specific instance.
</dt>
<dd>
<span class="param-type">Promise.&lt;(<a href="Note.html">Note</a>|null)></span>
<span class="param-type"><a href="Note.html">Note</a></span>
|
<span class="param-type">null</span>
</dd>
@ -3040,7 +2904,7 @@ if some action needs to happen on only one specific instance.
<h4 class="name" id="getNote"><span class="type-signature"></span>getNote<span class="signature">(noteId)</span><span class="type-signature"> &rarr; {Promise.&lt;(<a href="Note.html">Note</a>|null)>}</span></h4>
<h4 class="name" id="getNote"><span class="type-signature"></span>getNote<span class="signature">(noteId)</span><span class="type-signature"> &rarr; {<a href="Note.html">Note</a>|null}</span></h4>
@ -3173,7 +3037,10 @@ if some action needs to happen on only one specific instance.
</dt>
<dd>
<span class="param-type">Promise.&lt;(<a href="Note.html">Note</a>|null)></span>
<span class="param-type"><a href="Note.html">Note</a></span>
|
<span class="param-type">null</span>
</dd>
@ -3191,7 +3058,7 @@ if some action needs to happen on only one specific instance.
<h4 class="name" id="getNotesWithLabel"><span class="type-signature"></span>getNotesWithLabel<span class="signature">(name, value<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {Promise.&lt;Array.&lt;<a href="Note.html">Note</a>>>}</span></h4>
<h4 class="name" id="getNotesWithLabel"><span class="type-signature"></span>getNotesWithLabel<span class="signature">(name, value<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {Array.&lt;<a href="Note.html">Note</a>>}</span></h4>
@ -3335,7 +3202,7 @@ if some action needs to happen on only one specific instance.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line128">line 128</a>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line129">line 129</a>
</li></ul></dd>
@ -3371,7 +3238,7 @@ if some action needs to happen on only one specific instance.
</dt>
<dd>
<span class="param-type">Promise.&lt;Array.&lt;<a href="Note.html">Note</a>>></span>
<span class="param-type">Array.&lt;<a href="Note.html">Note</a>></span>
</dd>
@ -3389,7 +3256,7 @@ if some action needs to happen on only one specific instance.
<h4 class="name" id="getNoteWithLabel"><span class="type-signature"></span>getNoteWithLabel<span class="signature">(name, value<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {Promise.&lt;(<a href="Note.html">Note</a>|null)>}</span></h4>
<h4 class="name" id="getNoteWithLabel"><span class="type-signature"></span>getNoteWithLabel<span class="signature">(name, value<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {<a href="Note.html">Note</a>|null}</span></h4>
@ -3533,7 +3400,7 @@ if some action needs to happen on only one specific instance.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line138">line 138</a>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line139">line 139</a>
</li></ul></dd>
@ -3569,7 +3436,10 @@ if some action needs to happen on only one specific instance.
</dt>
<dd>
<span class="param-type">Promise.&lt;(<a href="Note.html">Note</a>|null)></span>
<span class="param-type"><a href="Note.html">Note</a></span>
|
<span class="param-type">null</span>
</dd>
@ -3587,7 +3457,7 @@ if some action needs to happen on only one specific instance.
<h4 class="name" id="getRootCalendarNote"><span class="type-signature"></span>getRootCalendarNote<span class="signature">()</span><span class="type-signature"> &rarr; {Promise.&lt;(<a href="Note.html">Note</a>|null)>}</span></h4>
<h4 class="name" id="getRootCalendarNote"><span class="type-signature"></span>getRootCalendarNote<span class="signature">()</span><span class="type-signature"> &rarr; {<a href="Note.html">Note</a>|null}</span></h4>
@ -3639,7 +3509,7 @@ if some action needs to happen on only one specific instance.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line306">line 306</a>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line309">line 309</a>
</li></ul></dd>
@ -3675,7 +3545,10 @@ if some action needs to happen on only one specific instance.
</dt>
<dd>
<span class="param-type">Promise.&lt;(<a href="Note.html">Note</a>|null)></span>
<span class="param-type"><a href="Note.html">Note</a></span>
|
<span class="param-type">null</span>
</dd>
@ -3693,7 +3566,7 @@ if some action needs to happen on only one specific instance.
<h4 class="name" id="getTodayNote"><span class="type-signature"></span>getTodayNote<span class="signature">()</span><span class="type-signature"> &rarr; {Promise.&lt;(<a href="Note.html">Note</a>|null)>}</span></h4>
<h4 class="name" id="getTodayNote"><span class="type-signature"></span>getTodayNote<span class="signature">()</span><span class="type-signature"> &rarr; {<a href="Note.html">Note</a>|null}</span></h4>
@ -3745,7 +3618,7 @@ if some action needs to happen on only one specific instance.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line323">line 323</a>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line326">line 326</a>
</li></ul></dd>
@ -3781,7 +3654,10 @@ if some action needs to happen on only one specific instance.
</dt>
<dd>
<span class="param-type">Promise.&lt;(<a href="Note.html">Note</a>|null)></span>
<span class="param-type"><a href="Note.html">Note</a></span>
|
<span class="param-type">null</span>
</dd>
@ -3799,7 +3675,7 @@ if some action needs to happen on only one specific instance.
<h4 class="name" id="getWeekNote"><span class="type-signature"></span>getWeekNote<span class="signature">(date, options)</span><span class="type-signature"> &rarr; {Promise.&lt;(<a href="Note.html">Note</a>|null)>}</span></h4>
<h4 class="name" id="getWeekNote"><span class="type-signature"></span>getWeekNote<span class="signature">(date, options)</span><span class="type-signature"> &rarr; {<a href="Note.html">Note</a>|null}</span></h4>
@ -3923,7 +3799,7 @@ if some action needs to happen on only one specific instance.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line333">line 333</a>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line336">line 336</a>
</li></ul></dd>
@ -3959,7 +3835,10 @@ if some action needs to happen on only one specific instance.
</dt>
<dd>
<span class="param-type">Promise.&lt;(<a href="Note.html">Note</a>|null)></span>
<span class="param-type"><a href="Note.html">Note</a></span>
|
<span class="param-type">null</span>
</dd>
@ -3977,7 +3856,7 @@ if some action needs to happen on only one specific instance.
<h4 class="name" id="getYearNote"><span class="type-signature"></span>getYearNote<span class="signature">(year)</span><span class="type-signature"> &rarr; {Promise.&lt;(<a href="Note.html">Note</a>|null)>}</span></h4>
<h4 class="name" id="getYearNote"><span class="type-signature"></span>getYearNote<span class="signature">(year)</span><span class="type-signature"> &rarr; {<a href="Note.html">Note</a>|null}</span></h4>
@ -4078,7 +3957,7 @@ if some action needs to happen on only one specific instance.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line351">line 351</a>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line354">line 354</a>
</li></ul></dd>
@ -4114,7 +3993,10 @@ if some action needs to happen on only one specific instance.
</dt>
<dd>
<span class="param-type">Promise.&lt;(<a href="Note.html">Note</a>|null)></span>
<span class="param-type"><a href="Note.html">Note</a></span>
|
<span class="param-type">null</span>
</dd>
@ -4228,7 +4110,7 @@ if some action needs to happen on only one specific instance.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line298">line 298</a>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line301">line 301</a>
</li></ul></dd>
@ -4314,7 +4196,7 @@ if some action needs to happen on only one specific instance.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line393">line 393</a>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line392">line 392</a>
</li></ul></dd>
@ -4350,7 +4232,7 @@ if some action needs to happen on only one specific instance.
<h4 class="name" id="searchForNote"><span class="type-signature"></span>searchForNote<span class="signature">(searchString)</span><span class="type-signature"> &rarr; {Promise.&lt;(<a href="Note.html">Note</a>|null)>}</span></h4>
<h4 class="name" id="searchForNote"><span class="type-signature"></span>searchForNote<span class="signature">(searchString)</span><span class="type-signature"> &rarr; {<a href="Note.html">Note</a>|null}</span></h4>
@ -4359,7 +4241,7 @@ if some action needs to happen on only one specific instance.
<div class="description">
This is a powerful search method - you can search by attributes and their values, e.g.:
"@dateModified =* MONTH AND @log". See full documentation for all options at: https://github.com/zadam/trilium/wiki/Search
"#dateModified =* MONTH AND #log". See full documentation for all options at: https://github.com/zadam/trilium/wiki/Search
</div>
@ -4452,7 +4334,7 @@ if some action needs to happen on only one specific instance.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line114">line 114</a>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line115">line 115</a>
</li></ul></dd>
@ -4488,7 +4370,10 @@ if some action needs to happen on only one specific instance.
</dt>
<dd>
<span class="param-type">Promise.&lt;(<a href="Note.html">Note</a>|null)></span>
<span class="param-type"><a href="Note.html">Note</a></span>
|
<span class="param-type">null</span>
</dd>
@ -4506,7 +4391,7 @@ if some action needs to happen on only one specific instance.
<h4 class="name" id="searchForNotes"><span class="type-signature"></span>searchForNotes<span class="signature">(searchString)</span><span class="type-signature"> &rarr; {Promise.&lt;Array.&lt;<a href="Note.html">Note</a>>>}</span></h4>
<h4 class="name" id="searchForNotes"><span class="type-signature"></span>searchForNotes<span class="signature">(query, searchContext<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {Array.&lt;<a href="Note.html">Note</a>>}</span></h4>
@ -4515,7 +4400,7 @@ if some action needs to happen on only one specific instance.
<div class="description">
This is a powerful search method - you can search by attributes and their values, e.g.:
"@dateModified =* MONTH AND @log". See full documentation for all options at: https://github.com/zadam/trilium/wiki/Search
"#dateModified =* MONTH AND #log". See full documentation for all options at: https://github.com/zadam/trilium/wiki/Search
</div>
@ -4539,6 +4424,8 @@ if some action needs to happen on only one specific instance.
<th>Type</th>
<th>Attributes</th>
@ -4551,7 +4438,7 @@ if some action needs to happen on only one specific instance.
<tr>
<td class="name"><code>searchString</code></td>
<td class="name"><code>query</code></td>
<td class="type">
@ -4564,6 +4451,47 @@ if some action needs to happen on only one specific instance.
</td>
<td class="attributes">
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>searchContext</code></td>
<td class="type">
<span class="param-type">SearchContext</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
@ -4608,7 +4536,7 @@ if some action needs to happen on only one specific instance.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line104">line 104</a>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line98">line 98</a>
</li></ul></dd>
@ -4644,7 +4572,7 @@ if some action needs to happen on only one specific instance.
</dt>
<dd>
<span class="param-type">Promise.&lt;Array.&lt;<a href="Note.html">Note</a>>></span>
<span class="param-type">Array.&lt;<a href="Note.html">Note</a>></span>
</dd>
@ -4817,7 +4745,7 @@ This method looks similar to toggleNoteInParent() but differs because we're look
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line372">line 372</a>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line374">line 374</a>
</li></ul></dd>
@ -4950,7 +4878,7 @@ This method looks similar to toggleNoteInParent() but differs because we're look
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line358">line 358</a>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line360">line 360</a>
</li></ul></dd>
@ -4975,16 +4903,6 @@ This method looks similar to toggleNoteInParent() but differs because we're look
<h5>Returns:</h5>
<div class="param-desc">
Promise<void>
</div>
@ -4996,7 +4914,7 @@ This method looks similar to toggleNoteInParent() but differs because we're look
<h4 class="name" id="toggleNoteInParent"><span class="type-signature"></span>toggleNoteInParent<span class="signature">(present, noteId, parentNoteId, prefix)</span><span class="type-signature"> &rarr; {Promise.&lt;void>}</span></h4>
<h4 class="name" id="toggleNoteInParent"><span class="type-signature"></span>toggleNoteInParent<span class="signature">(present, noteId, parentNoteId, prefix)</span><span class="type-signature"> &rarr; {void}</span></h4>
@ -5166,7 +5084,7 @@ This method looks similar to toggleNoteInParent() but differs because we're look
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line171">line 171</a>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line172">line 172</a>
</li></ul></dd>
@ -5202,7 +5120,7 @@ This method looks similar to toggleNoteInParent() but differs because we're look
</dt>
<dd>
<span class="param-type">Promise.&lt;void></span>
<span class="param-type">void</span>
</dd>
@ -5220,7 +5138,7 @@ This method looks similar to toggleNoteInParent() but differs because we're look
<h4 class="name" id="transactional"><span class="type-signature"></span>transactional<span class="signature">(func)</span><span class="type-signature"> &rarr; {Promise.&lt;?>}</span></h4>
<h4 class="name" id="transactional"><span class="type-signature"></span>transactional<span class="signature">(func)</span><span class="type-signature"> &rarr; {?}</span></h4>
@ -5230,9 +5148,6 @@ This method looks similar to toggleNoteInParent() but differs because we're look
<div class="description">
This functions wraps code which is supposed to be running in transaction. If transaction already
exists, then we'll use that transaction.
This method is required only when script has label manualTransactionHandling, all other scripts are
transactional by default.
</div>
@ -5325,7 +5240,7 @@ transactional by default.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line385">line 385</a>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line384">line 384</a>
</li></ul></dd>
@ -5365,7 +5280,7 @@ transactional by default.
</dt>
<dd>
<span class="param-type">Promise.&lt;?></span>
<span class="param-type">?</span>
</dd>
@ -5399,7 +5314,7 @@ transactional by default.
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.4</a>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a>
</footer>
<script> prettyPrint(); </script>

View File

@ -107,7 +107,7 @@ Each note can have multiple (at least one) branches, meaning it can be placed in
<td class="description last">primary key</td>
<td class="description last">primary key, immutable</td>
</tr>
@ -130,7 +130,7 @@ Each note can have multiple (at least one) branches, meaning it can be placed in
<td class="description last"></td>
<td class="description last">immutable</td>
</tr>
@ -153,7 +153,7 @@ Each note can have multiple (at least one) branches, meaning it can be placed in
<td class="description last"></td>
<td class="description last">immutable</td>
</tr>
@ -356,7 +356,7 @@ Each note can have multiple (at least one) branches, meaning it can be placed in
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="entities_branch.js.html">entities/branch.js</a>, <a href="entities_branch.js.html#line25">line 25</a>
<a href="entities_branch.js.html">entities/branch.js</a>, <a href="entities_branch.js.html#line24">line 24</a>
</li></ul></dd>
@ -423,7 +423,7 @@ Each note can have multiple (at least one) branches, meaning it can be placed in
<h4 class="name" id="getNote"><span class="type-signature">(async) </span>getNote<span class="signature">()</span><span class="type-signature"> &rarr; {Promise.&lt;(<a href="Note.html">Note</a>|null)>}</span></h4>
<h4 class="name" id="getNote"><span class="type-signature"></span>getNote<span class="signature">()</span><span class="type-signature"> &rarr; {<a href="Note.html">Note</a>|null}</span></h4>
@ -471,7 +471,7 @@ Each note can have multiple (at least one) branches, meaning it can be placed in
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="entities_branch.js.html">entities/branch.js</a>, <a href="entities_branch.js.html#line32">line 32</a>
<a href="entities_branch.js.html">entities/branch.js</a>, <a href="entities_branch.js.html#line31">line 31</a>
</li></ul></dd>
@ -507,7 +507,10 @@ Each note can have multiple (at least one) branches, meaning it can be placed in
</dt>
<dd>
<span class="param-type">Promise.&lt;(<a href="Note.html">Note</a>|null)></span>
<span class="param-type"><a href="Note.html">Note</a></span>
|
<span class="param-type">null</span>
</dd>
@ -525,7 +528,7 @@ Each note can have multiple (at least one) branches, meaning it can be placed in
<h4 class="name" id="getParentNote"><span class="type-signature">(async) </span>getParentNote<span class="signature">()</span><span class="type-signature"> &rarr; {Promise.&lt;(<a href="Note.html">Note</a>|null)>}</span></h4>
<h4 class="name" id="getParentNote"><span class="type-signature"></span>getParentNote<span class="signature">()</span><span class="type-signature"> &rarr; {<a href="Note.html">Note</a>|null}</span></h4>
@ -573,7 +576,7 @@ Each note can have multiple (at least one) branches, meaning it can be placed in
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="entities_branch.js.html">entities/branch.js</a>, <a href="entities_branch.js.html#line37">line 37</a>
<a href="entities_branch.js.html">entities/branch.js</a>, <a href="entities_branch.js.html#line36">line 36</a>
</li></ul></dd>
@ -609,7 +612,10 @@ Each note can have multiple (at least one) branches, meaning it can be placed in
</dt>
<dd>
<span class="param-type">Promise.&lt;(<a href="Note.html">Note</a>|null)></span>
<span class="param-type"><a href="Note.html">Note</a></span>
|
<span class="param-type">null</span>
</dd>
@ -643,7 +649,7 @@ Each note can have multiple (at least one) branches, meaning it can be placed in
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.4</a>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a>
</footer>
<script> prettyPrint(); </script>

View File

@ -150,7 +150,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="entities_entity.js.html">entities/entity.js</a>, <a href="entities_entity.js.html#line9">line 9</a>
<a href="entities_entity.js.html">entities/entity.js</a>, <a href="entities_entity.js.html#line10">line 10</a>
</li></ul></dd>
@ -218,7 +218,7 @@
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.4</a>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a>
</footer>
<script> prettyPrint(); </script>

File diff suppressed because it is too large Load Diff

View File

@ -198,29 +198,6 @@
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>contentLength</code></td>
<td class="type">
<span class="param-type">int</span>
</td>
<td class="description last"></td>
</tr>
@ -421,7 +398,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="entities_note_revision.js.html">entities/note_revision.js</a>, <a href="entities_note_revision.js.html#line35">line 35</a>
<a href="entities_note_revision.js.html">entities/note_revision.js</a>, <a href="entities_note_revision.js.html#line28">line 28</a>
</li></ul></dd>
@ -488,7 +465,7 @@
<h4 class="name" id="getContent"><span class="type-signature">(async) </span>getContent<span class="signature">()</span><span class="type-signature"> &rarr; {Promise.&lt;*>}</span></h4>
<h4 class="name" id="getContent"><span class="type-signature"></span>getContent<span class="signature">()</span><span class="type-signature"> &rarr; {*}</span></h4>
@ -536,7 +513,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="entities_note_revision.js.html">entities/note_revision.js</a>, <a href="entities_note_revision.js.html#line69">line 69</a>
<a href="entities_note_revision.js.html">entities/note_revision.js</a>, <a href="entities_note_revision.js.html#line68">line 68</a>
</li></ul></dd>
@ -572,7 +549,7 @@
</dt>
<dd>
<span class="param-type">Promise.&lt;*></span>
<span class="param-type">*</span>
</dd>
@ -638,7 +615,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="entities_note_revision.js.html">entities/note_revision.js</a>, <a href="entities_note_revision.js.html#line55">line 55</a>
<a href="entities_note_revision.js.html">entities/note_revision.js</a>, <a href="entities_note_revision.js.html#line54">line 54</a>
</li></ul></dd>
@ -691,108 +668,6 @@
<h4 class="name" id="setContent"><span class="type-signature">(async) </span>setContent<span class="signature">()</span><span class="type-signature"> &rarr; {Promise}</span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="entities_note_revision.js.html">entities/note_revision.js</a>, <a href="entities_note_revision.js.html#line105">line 105</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Promise</span>
</dd>
</dl>
@ -814,7 +689,7 @@
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.4</a>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a>
</footer>
<script> prettyPrint(); </script>

View File

@ -237,7 +237,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="entities_option.js.html">entities/option.js</a>, <a href="entities_option.js.html#line22">line 22</a>
<a href="entities_option.js.html">entities/option.js</a>, <a href="entities_option.js.html#line17">line 17</a>
</li></ul></dd>
@ -316,7 +316,7 @@
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.4</a>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a>
</footer>
<script> prettyPrint(); </script>

View File

@ -293,7 +293,7 @@
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.4</a>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a>
</footer>
<script> prettyPrint(); </script>

View File

@ -75,7 +75,7 @@ module.exports = ApiToken;</code></pre>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.4</a>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a>
</footer>
<script> prettyPrint(); </script>

View File

@ -28,21 +28,22 @@
<article>
<pre class="prettyprint source linenums"><code>"use strict";
const Entity = require('./entity');
const repository = require('../services/repository');
const dateUtils = require('../services/date_utils');
const sql = require('../services/sql');
const promotedAttributeDefinitionParser = require("../services/promoted_attribute_definition_parser");
/**
* Attribute is key value pair owned by a note.
*
* @property {string} attributeId
* @property {string} noteId
* @property {string} type
* @property {string} name
* @property {string} attributeId - immutable
* @property {string} noteId - immutable
* @property {string} type - immutable
* @property {string} name - immutable
* @property {string} value
* @property {int} position
* @property {boolean} isInheritable
* @property {boolean} isInheritable - immutable
* @property {boolean} isDeleted
* @property {string|null} deleteId - ID identifying delete transaction
* @property {string} utcDateCreated
@ -59,27 +60,19 @@ class Attribute extends Entity {
super(row);
this.isInheritable = !!this.isInheritable;
if (this.isDefinition()) {
try {
this.value = JSON.parse(this.value);
}
catch (e) {
}
}
}
/**
* @returns {Promise&lt;Note|null>}
* @returns {Note|null}
*/
async getNote() {
return await repository.getNote(this.noteId);
getNote() {
return this.repository.getNote(this.noteId);
}
/**
* @returns {Promise&lt;Note|null>}
* @returns {Note|null}
*/
async getTargetNote() {
getTargetNote() {
if (this.type !== 'relation') {
throw new Error(`Attribute ${this.attributeId} is not relation`);
}
@ -88,17 +81,31 @@ class Attribute extends Entity {
return null;
}
return await repository.getNote(this.value);
return this.repository.getNote(this.value);
}
/**
* @return {boolean}
*/
isDefinition() {
return this.type === 'label-definition' || this.type === 'relation-definition';
return this.type === 'label' &amp;&amp; (this.name.startsWith('label:') || this.name.startsWith('relation:'));
}
async beforeSaving() {
getDefinition() {
return promotedAttributeDefinitionParser.parse(this.value);
}
getDefinedName() {
if (this.type === 'label' &amp;&amp; this.name.startsWith('label:')) {
return this.name.substr(6);
} else if (this.type === 'label' &amp;&amp; this.name.startsWith('relation:')) {
return this.name.substr(9);
} else {
return this.name;
}
}
beforeSaving() {
if (!this.value) {
if (this.type === 'relation') {
throw new Error(`Cannot save relation ${this.name} since it does not target any note.`);
@ -109,7 +116,7 @@ class Attribute extends Entity {
}
if (this.position === undefined) {
this.position = 1 + await sql.getValue(`SELECT COALESCE(MAX(position), 0) FROM attributes WHERE noteId = ?`, [this.noteId]);
this.position = 1 + sql.getValue(`SELECT COALESCE(MAX(position), 0) FROM attributes WHERE noteId = ?`, [this.noteId]);
}
if (!this.isInheritable) {
@ -131,20 +138,14 @@ class Attribute extends Entity {
}
}
// cannot be static!
updatePojo(pojo) {
delete pojo.isOwned;
delete pojo.__note;
}
createClone(type, name, value) {
createClone(type, name, value, isInheritable) {
return new Attribute({
noteId: this.noteId,
type: type,
name: name,
value: value,
position: this.position,
isInheritable: this.isInheritable,
isInheritable: isInheritable,
isDeleted: false,
utcDateCreated: this.utcDateCreated,
utcDateModified: this.utcDateModified
@ -152,7 +153,8 @@ class Attribute extends Entity {
}
}
module.exports = Attribute;</code></pre>
module.exports = Attribute;
</code></pre>
</article>
</section>
@ -168,7 +170,7 @@ module.exports = Attribute;</code></pre>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.4</a>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a>
</footer>
<script> prettyPrint(); </script>

View File

@ -30,16 +30,15 @@
const Entity = require('./entity');
const dateUtils = require('../services/date_utils');
const repository = require('../services/repository');
const sql = require('../services/sql');
/**
* Branch represents note's placement in the tree - it's essentially pair of noteId and parentNoteId.
* Each note can have multiple (at least one) branches, meaning it can be placed into multiple places in the tree.
*
* @property {string} branchId - primary key
* @property {string} noteId
* @property {string} parentNoteId
* @property {string} branchId - primary key, immutable
* @property {string} noteId - immutable
* @property {string} parentNoteId - immutable
* @property {int} notePosition
* @property {string} prefix
* @property {boolean} isExpanded
@ -56,19 +55,19 @@ class Branch extends Entity {
// notePosition is not part of hash because it would produce a lot of updates in case of reordering
static get hashedProperties() { return ["branchId", "noteId", "parentNoteId", "isDeleted", "deleteId", "prefix"]; }
/** @returns {Promise&lt;Note|null>} */
async getNote() {
return await repository.getNote(this.noteId);
/** @returns {Note|null} */
getNote() {
return this.repository.getNote(this.noteId);
}
/** @returns {Promise&lt;Note|null>} */
async getParentNote() {
return await repository.getNote(this.parentNoteId);
/** @returns {Note|null} */
getParentNote() {
return this.repository.getNote(this.parentNoteId);
}
async beforeSaving() {
beforeSaving() {
if (this.notePosition === undefined) {
const maxNotePos = await sql.getValue('SELECT MAX(notePosition) FROM branches WHERE parentNoteId = ? AND isDeleted = 0', [this.parentNoteId]);
const maxNotePos = sql.getValue('SELECT MAX(notePosition) FROM branches WHERE parentNoteId = ? AND isDeleted = 0', [this.parentNoteId]);
this.notePosition = maxNotePos === null ? 0 : maxNotePos + 10;
}
@ -105,7 +104,8 @@ class Branch extends Entity {
}
}
module.exports = Branch;</code></pre>
module.exports = Branch;
</code></pre>
</article>
</section>
@ -121,7 +121,7 @@ module.exports = Branch;</code></pre>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.4</a>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a>
</footer>
<script> prettyPrint(); </script>

View File

@ -29,6 +29,7 @@
<pre class="prettyprint source linenums"><code>"use strict";
const utils = require('../services/utils');
let repo = null;
class Entity {
/**
@ -53,14 +54,7 @@ class Entity {
const origHash = this.hash;
this.hash = this.generateHash();
if (this.forcedChange) {
this.isChanged = true;
delete this.forcedChange;
}
else {
this.isChanged = origHash !== this.hash;
}
this.isChanged = origHash !== this.hash;
}
generateIdIfNecessary() {
@ -79,14 +73,23 @@ class Entity {
return utils.hash(contentToHash).substr(0, 10);
}
async save() {
await require('../services/repository').updateEntity(this);
get repository() {
if (!repo) {
repo = require('../services/repository');
}
return repo;
}
save() {
this.repository.updateEntity(this);
return this;
}
}
module.exports = Entity;</code></pre>
module.exports = Entity;
</code></pre>
</article>
</section>
@ -102,7 +105,7 @@ module.exports = Entity;</code></pre>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.4</a>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a>
</footer>
<script> prettyPrint(); </script>

View File

@ -31,16 +31,13 @@
const Entity = require('./entity');
const Attribute = require('./attribute');
const protectedSessionService = require('../services/protected_session');
const repository = require('../services/repository');
const sql = require('../services/sql');
const utils = require('../services/utils');
const dateUtils = require('../services/date_utils');
const syncTableService = require('../services/sync_table');
const entityChangesService = require('../services/entity_changes.js');
const LABEL = 'label';
const LABEL_DEFINITION = 'label-definition';
const RELATION = 'relation';
const RELATION_DEFINITION = 'relation-definition';
/**
* This represents a Note which is a central object in the Trilium Notes project.
@ -49,7 +46,6 @@ const RELATION_DEFINITION = 'relation-definition';
* @property {string} type - one of "text", "code", "file" or "render"
* @property {string} mime - MIME type, e.g. "text/html"
* @property {string} title - note title
* @property {int} contentLength - length of content
* @property {boolean} isProtected - true if note is protected
* @property {boolean} isDeleted - true if note is deleted
* @property {string|null} deleteId - ID identifying delete transaction
@ -95,14 +91,14 @@ class Note extends Entity {
* part of Note entity with it's own sync. Reasons behind this hybrid design has been:
*
* - content can be quite large and it's not necessary to load it / fill memory for any note access even if we don't need a content, especially for bulk operations like search
* - changes in the note metadata or title should not trigger note content sync (so we keep separate utcDateModified and sync rows)
* - changes in the note metadata or title should not trigger note content sync (so we keep separate utcDateModified and entity changes records)
* - but to the user note content and title changes are one and the same - single dateModified (so all changes must go through Note and content is not a separate entity)
*/
/** @returns {Promise&lt;*>} */
async getContent(silentNotFoundError = false) {
/** @returns {*} */
getContent(silentNotFoundError = false) {
if (this.content === undefined) {
const res = await sql.getRow(`SELECT content, hash FROM note_contents WHERE noteId = ?`, [this.noteId]);
const res = sql.getRow(`SELECT content, hash FROM note_contents WHERE noteId = ?`, [this.noteId]);
if (!res) {
if (silentNotFoundError) {
@ -135,9 +131,20 @@ class Note extends Entity {
}
}
/** @returns {Promise&lt;*>} */
async getJsonContent() {
const content = await this.getContent();
/** @returns {{contentLength, dateModified, utcDateModified}} */
getContentMetadata() {
return sql.getRow(`
SELECT
LENGTH(content) AS contentLength,
dateModified,
utcDateModified
FROM note_contents
WHERE noteId = ?`, [this.noteId]);
}
/** @returns {*} */
getJsonContent() {
const content = this.getContent();
if (!content || !content.trim()) {
return null;
@ -146,24 +153,24 @@ class Note extends Entity {
return JSON.parse(content);
}
/** @returns {Promise} */
async setContent(content) {
setContent(content) {
if (content === null || content === undefined) {
throw new Error(`Cannot set null content to note ${this.noteId}`);
}
content = Buffer.isBuffer(content) ? content : Buffer.from(content);
// force updating note itself so that dateModified is represented correctly even for the content
this.forcedChange = true;
this.contentLength = content.byteLength;
await this.save();
if (this.isStringNote()) {
content = content.toString();
}
else {
content = Buffer.isBuffer(content) ? content : Buffer.from(content);
}
this.content = content;
const pojo = {
noteId: this.noteId,
content: content,
dateModified: dateUtils.localNowDateTime(),
utcDateModified: dateUtils.utcNowDateTime(),
hash: utils.hash(this.noteId + "|" + content.toString())
};
@ -177,14 +184,13 @@ class Note extends Entity {
}
}
await sql.upsert("note_contents", "noteId", pojo);
sql.upsert("note_contents", "noteId", pojo);
await syncTableService.addNoteContentSync(this.noteId);
entityChangesService.addNoteContentEntityChange(this.noteId);
}
/** @returns {Promise} */
async setJsonContent(content) {
await this.setContent(JSON.stringify(content, null, '\t'));
setJsonContent(content) {
this.setContent(JSON.stringify(content, null, '\t'));
}
/** @returns {boolean} true if this note is the root of the note tree. Root note has "root" noteId */
@ -232,8 +238,8 @@ class Note extends Entity {
return null;
}
async loadOwnedAttributesToCache() {
this.__ownedAttributeCache = await repository.getEntities(`SELECT * FROM attributes WHERE isDeleted = 0 AND noteId = ?`, [this.noteId]);
loadOwnedAttributesToCache() {
this.__ownedAttributeCache = this.repository.getEntities(`SELECT * FROM attributes WHERE isDeleted = 0 AND noteId = ?`, [this.noteId]);
return this.__ownedAttributeCache;
}
@ -243,11 +249,11 @@ class Note extends Entity {
*
* @param {string} [type] - (optional) attribute type to filter
* @param {string} [name] - (optional) attribute name to filter
* @returns {Promise&lt;Attribute[]>} note's "owned" attributes - excluding inherited ones
* @returns {Attribute[]} note's "owned" attributes - excluding inherited ones
*/
async getOwnedAttributes(type, name) {
getOwnedAttributes(type, name) {
if (!this.__ownedAttributeCache) {
await this.loadOwnedAttributesToCache();
this.loadOwnedAttributesToCache();
}
if (type &amp;&amp; name) {
@ -265,31 +271,31 @@ class Note extends Entity {
}
/**
* @returns {Promise&lt;Attribute>} attribute belonging to this specific note (excludes inherited attributes)
* @returns {Attribute} attribute belonging to this specific note (excludes inherited attributes)
*
* This method can be significantly faster than the getAttribute()
*/
async getOwnedAttribute(type, name) {
const attrs = await this.getOwnedAttributes(type, name);
getOwnedAttribute(type, name) {
const attrs = this.getOwnedAttributes(type, name);
return attrs.length > 0 ? attrs[0] : null;
}
/**
* @returns {Promise&lt;Attribute[]>} relations targetting this specific note
* @returns {Attribute[]} relations targetting this specific note
*/
async getTargetRelations() {
return await repository.getEntities("SELECT * FROM attributes WHERE type = 'relation' AND isDeleted = 0 AND value = ?", [this.noteId]);
getTargetRelations() {
return this.repository.getEntities("SELECT * FROM attributes WHERE type = 'relation' AND isDeleted = 0 AND value = ?", [this.noteId]);
}
/**
* @param {string} [type] - (optional) attribute type to filter
* @param {string} [name] - (optional) attribute name to filter
* @returns {Promise&lt;Attribute[]>} all note's attributes, including inherited ones
* @returns {Attribute[]} all note's attributes, including inherited ones
*/
async getAttributes(type, name) {
getAttributes(type, name) {
if (!this.__attributeCache) {
await this.loadAttributesToCache();
this.loadAttributesToCache();
}
if (type &amp;&amp; name) {
@ -308,67 +314,51 @@ class Note extends Entity {
/**
* @param {string} [name] - label name to filter
* @returns {Promise&lt;Attribute[]>} all note's labels (attributes with type label), including inherited ones
* @returns {Attribute[]} all note's labels (attributes with type label), including inherited ones
*/
async getLabels(name) {
return await this.getAttributes(LABEL, name);
getLabels(name) {
return this.getAttributes(LABEL, name);
}
/**
* @param {string} [name] - label name to filter
* @returns {Promise&lt;Attribute[]>} all note's labels (attributes with type label), excluding inherited ones
* @returns {Attribute[]} all note's labels (attributes with type label), excluding inherited ones
*/
async getOwnedLabels(name) {
return await this.getOwnedAttributes(LABEL, name);
}
/**
* @param {string} [name] - label name to filter
* @returns {Promise&lt;Attribute[]>} all note's label definitions, including inherited ones
*/
async getLabelDefinitions(name) {
return await this.getAttributes(LABEL_DEFINITION, name);
getOwnedLabels(name) {
return this.getOwnedAttributes(LABEL, name);
}
/**
* @param {string} [name] - relation name to filter
* @returns {Promise&lt;Attribute[]>} all note's relations (attributes with type relation), including inherited ones
* @returns {Attribute[]} all note's relations (attributes with type relation), including inherited ones
*/
async getRelations(name) {
return await this.getAttributes(RELATION, name);
getRelations(name) {
return this.getAttributes(RELATION, name);
}
/**
* @param {string} [name] - relation name to filter
* @returns {Promise&lt;Attribute[]>} all note's relations (attributes with type relation), excluding inherited ones
* @returns {Attribute[]} all note's relations (attributes with type relation), excluding inherited ones
*/
async getOwnedRelations(name) {
return await this.getOwnedAttributes(RELATION, name);
getOwnedRelations(name) {
return this.getOwnedAttributes(RELATION, name);
}
/**
* @param {string} [name] - relation name to filter
* @returns {Promise&lt;Note[]>}
* @returns {Note[]}
*/
async getRelationTargets(name) {
const relations = await this.getRelations(name);
getRelationTargets(name) {
const relations = this.getRelations(name);
const targets = [];
for (const relation of relations) {
targets.push(await relation.getTargetNote());
targets.push(relation.getTargetNote());
}
return targets;
}
/**
* @param {string} [name] - relation name to filter
* @returns {Promise&lt;Attribute[]>} all note's relation definitions including inherited ones
*/
async getRelationDefinitions(name) {
return await this.getAttributes(RELATION_DEFINITION, name);
}
/**
* Clear note's attributes cache to force fresh reload for next attribute request.
* Cache is note instance scoped.
@ -378,9 +368,8 @@ class Note extends Entity {
this.__ownedAttributeCache = null;
}
/** @returns {Promise&lt;void>} */
async loadAttributesToCache() {
const attributes = await repository.getEntities(`
loadAttributesToCache() {
const attributes = this.repository.getEntities(`
WITH RECURSIVE
tree(noteId, level) AS (
SELECT ?, 0
@ -412,6 +401,7 @@ class Note extends Entity {
return false;
}
// FIXME: this code is quite questionable, one problem is that other caches (TreeCache, NoteCache) have nothing like that
if (attr.isDefinition()) {
const firstDefinitionIndex = attributes.findIndex(el => el.type === attr.type &amp;&amp; el.name === attr.name);
@ -419,15 +409,15 @@ class Note extends Entity {
return firstDefinitionIndex === index;
}
else {
const definitionAttr = attributes.find(el => el.type === attr.type + '-definition' &amp;&amp; el.name === attr.name);
const definitionAttr = attributes.find(el => el.type === 'label' &amp;&amp; el.name === attr.type + ':' + attr.name);
if (!definitionAttr) {
return true;
}
const definition = definitionAttr.value;
const definition = definitionAttr.getDefinition();
if (definition.multiplicityType === 'multivalue') {
if (definition.multiplicity === 'multi') {
return true;
}
else {
@ -439,38 +429,34 @@ class Note extends Entity {
}
});
for (const attr of filteredAttributes) {
attr.isOwned = attr.noteId === this.noteId;
}
this.__attributeCache = filteredAttributes;
}
/**
* @param {string} type - attribute type (label, relation, etc.)
* @param {string} name - attribute name
* @returns {Promise&lt;boolean>} true if note has an attribute with given type and name (including inherited)
* @returns {boolean} true if note has an attribute with given type and name (including inherited)
*/
async hasAttribute(type, name) {
return !!await this.getAttribute(type, name);
hasAttribute(type, name) {
return !!this.getAttribute(type, name);
}
/**
* @param {string} type - attribute type (label, relation, etc.)
* @param {string} name - attribute name
* @returns {Promise&lt;boolean>} true if note has an attribute with given type and name (excluding inherited)
* @returns {boolean} true if note has an attribute with given type and name (excluding inherited)
*/
async hasOwnedAttribute(type, name) {
return !!await this.getOwnedAttribute(type, name);
hasOwnedAttribute(type, name) {
return !!this.getOwnedAttribute(type, name);
}
/**
* @param {string} type - attribute type (label, relation, etc.)
* @param {string} name - attribute name
* @returns {Promise&lt;Attribute>} attribute of given type and name. If there's more such attributes, first is returned. Returns null if there's no such attribute belonging to this note.
* @returns {Attribute} attribute of given type and name. If there's more such attributes, first is returned. Returns null if there's no such attribute belonging to this note.
*/
async getAttribute(type, name) {
const attributes = await this.getAttributes();
getAttribute(type, name) {
const attributes = this.getAttributes();
return attributes.find(attr => attr.type === type &amp;&amp; attr.name === name);
}
@ -478,10 +464,10 @@ class Note extends Entity {
/**
* @param {string} type - attribute type (label, relation, etc.)
* @param {string} name - attribute name
* @returns {Promise&lt;string|null>} attribute value of given type and name or null if no such attribute exists.
* @returns {string|null} attribute value of given type and name or null if no such attribute exists.
*/
async getAttributeValue(type, name) {
const attr = await this.getAttribute(type, name);
getAttributeValue(type, name) {
const attr = this.getAttribute(type, name);
return attr ? attr.value : null;
}
@ -489,10 +475,10 @@ class Note extends Entity {
/**
* @param {string} type - attribute type (label, relation, etc.)
* @param {string} name - attribute name
* @returns {Promise&lt;string|null>} attribute value of given type and name or null if no such attribute exists.
* @returns {string|null} attribute value of given type and name or null if no such attribute exists.
*/
async getOwnedAttributeValue(type, name) {
const attr = await this.getOwnedAttribute(type, name);
getOwnedAttributeValue(type, name) {
const attr = this.getOwnedAttribute(type, name);
return attr ? attr.value : null;
}
@ -504,14 +490,13 @@ class Note extends Entity {
* @param {boolean} enabled - toggle On or Off
* @param {string} name - attribute name
* @param {string} [value] - attribute value (optional)
* @returns {Promise&lt;void>}
*/
async toggleAttribute(type, enabled, name, value) {
toggleAttribute(type, enabled, name, value) {
if (enabled) {
await this.setAttribute(type, name, value);
this.setAttribute(type, name, value);
}
else {
await this.removeAttribute(type, name, value);
this.removeAttribute(type, name, value);
}
}
@ -521,16 +506,15 @@ class Note extends Entity {
* @param {string} type - attribute type (label, relation, etc.)
* @param {string} name - attribute name
* @param {string} [value] - attribute value (optional)
* @returns {Promise&lt;void>}
*/
async setAttribute(type, name, value) {
const attributes = await this.loadOwnedAttributesToCache();
setAttribute(type, name, value) {
const attributes = this.loadOwnedAttributesToCache();
let attr = attributes.find(attr => attr.type === type &amp;&amp; attr.name === name);
if (attr) {
if (attr.value !== value) {
attr.value = value;
await attr.save();
attr.save();
this.invalidateAttributeCache();
}
@ -543,7 +527,7 @@ class Note extends Entity {
value: value !== undefined ? value : ""
});
await attr.save();
attr.save();
this.invalidateAttributeCache();
}
@ -555,15 +539,14 @@ class Note extends Entity {
* @param {string} type - attribute type (label, relation, etc.)
* @param {string} name - attribute name
* @param {string} [value] - attribute value (optional)
* @returns {Promise&lt;void>}
*/
async removeAttribute(type, name, value) {
const attributes = await this.loadOwnedAttributesToCache();
removeAttribute(type, name, value) {
const attributes = this.loadOwnedAttributesToCache();
for (const attribute of attributes) {
if (attribute.type === type &amp;&amp; attribute.name === name &amp;&amp; (value === undefined || value === attribute.value)) {
attribute.isDeleted = true;
await attribute.save();
attribute.save();
this.invalidateAttributeCache();
}
@ -571,121 +554,123 @@ class Note extends Entity {
}
/**
* @return {Promise&lt;Attribute>}
* @return {Attribute}
*/
async addAttribute(type, name, value = "") {
addAttribute(type, name, value = "", isInheritable = false, position = 1000) {
const attr = new Attribute({
noteId: this.noteId,
type: type,
name: name,
value: value
value: value,
isInheritable: isInheritable,
position: position
});
await attr.save();
attr.save();
this.invalidateAttributeCache();
return attr;
}
async addLabel(name, value = "") {
return await this.addAttribute(LABEL, name, value);
addLabel(name, value = "", isInheritable = false) {
return this.addAttribute(LABEL, name, value, isInheritable);
}
async addRelation(name, targetNoteId) {
return await this.addAttribute(RELATION, name, targetNoteId);
addRelation(name, targetNoteId, isInheritable = false) {
return this.addAttribute(RELATION, name, targetNoteId, isInheritable);
}
/**
* @param {string} name - label name
* @returns {Promise&lt;boolean>} true if label exists (including inherited)
* @returns {boolean} true if label exists (including inherited)
*/
async hasLabel(name) { return await this.hasAttribute(LABEL, name); }
hasLabel(name) { return this.hasAttribute(LABEL, name); }
/**
* @param {string} name - label name
* @returns {Promise&lt;boolean>} true if label exists (excluding inherited)
* @returns {boolean} true if label exists (excluding inherited)
*/
async hasOwnedLabel(name) { return await this.hasOwnedAttribute(LABEL, name); }
hasOwnedLabel(name) { return this.hasOwnedAttribute(LABEL, name); }
/**
* @param {string} name - relation name
* @returns {Promise&lt;boolean>} true if relation exists (including inherited)
* @returns {boolean} true if relation exists (including inherited)
*/
async hasRelation(name) { return await this.hasAttribute(RELATION, name); }
hasRelation(name) { return this.hasAttribute(RELATION, name); }
/**
* @param {string} name - relation name
* @returns {Promise&lt;boolean>} true if relation exists (excluding inherited)
* @returns {boolean} true if relation exists (excluding inherited)
*/
async hasOwnedRelation(name) { return await this.hasOwnedAttribute(RELATION, name); }
hasOwnedRelation(name) { return this.hasOwnedAttribute(RELATION, name); }
/**
* @param {string} name - label name
* @returns {Promise&lt;Attribute|null>} label if it exists, null otherwise
* @returns {Attribute|null} label if it exists, null otherwise
*/
async getLabel(name) { return await this.getAttribute(LABEL, name); }
getLabel(name) { return this.getAttribute(LABEL, name); }
/**
* @param {string} name - label name
* @returns {Promise&lt;Attribute|null>} label if it exists, null otherwise
* @returns {Attribute|null} label if it exists, null otherwise
*/
async getOwnedLabel(name) { return await this.getOwnedAttribute(LABEL, name); }
getOwnedLabel(name) { return this.getOwnedAttribute(LABEL, name); }
/**
* @param {string} name - relation name
* @returns {Promise&lt;Attribute|null>} relation if it exists, null otherwise
* @returns {Attribute|null} relation if it exists, null otherwise
*/
async getRelation(name) { return await this.getAttribute(RELATION, name); }
getRelation(name) { return this.getAttribute(RELATION, name); }
/**
* @param {string} name - relation name
* @returns {Promise&lt;Attribute|null>} relation if it exists, null otherwise
* @returns {Attribute|null} relation if it exists, null otherwise
*/
async getOwnedRelation(name) { return await this.getOwnedAttribute(RELATION, name); }
getOwnedRelation(name) { return this.getOwnedAttribute(RELATION, name); }
/**
* @param {string} name - label name
* @returns {Promise&lt;string|null>} label value if label exists, null otherwise
* @returns {string|null} label value if label exists, null otherwise
*/
async getLabelValue(name) { return await this.getAttributeValue(LABEL, name); }
getLabelValue(name) { return this.getAttributeValue(LABEL, name); }
/**
* @param {string} name - label name
* @returns {Promise&lt;string|null>} label value if label exists, null otherwise
* @returns {string|null} label value if label exists, null otherwise
*/
async getOwnedLabelValue(name) { return await this.getOwnedAttributeValue(LABEL, name); }
getOwnedLabelValue(name) { return this.getOwnedAttributeValue(LABEL, name); }
/**
* @param {string} name - relation name
* @returns {Promise&lt;string|null>} relation value if relation exists, null otherwise
* @returns {string|null} relation value if relation exists, null otherwise
*/
async getRelationValue(name) { return await this.getAttributeValue(RELATION, name); }
getRelationValue(name) { return this.getAttributeValue(RELATION, name); }
/**
* @param {string} name - relation name
* @returns {Promise&lt;string|null>} relation value if relation exists, null otherwise
* @returns {string|null} relation value if relation exists, null otherwise
*/
async getOwnedRelationValue(name) { return await this.getOwnedAttributeValue(RELATION, name); }
getOwnedRelationValue(name) { return this.getOwnedAttributeValue(RELATION, name); }
/**
* @param {string} name
* @returns {Promise&lt;Note>|null} target note of the relation or null (if target is empty or note was not found)
* @returns {Note|null} target note of the relation or null (if target is empty or note was not found)
*/
async getRelationTarget(name) {
const relation = await this.getRelation(name);
getRelationTarget(name) {
const relation = this.getRelation(name);
return relation ? await repository.getNote(relation.value) : null;
return relation ? this.repository.getNote(relation.value) : null;
}
/**
* @param {string} name
* @returns {Promise&lt;Note>|null} target note of the relation or null (if target is empty or note was not found)
* @returns {Note|null} target note of the relation or null (if target is empty or note was not found)
*/
async getOwnedRelationTarget(name) {
const relation = await this.getOwnedRelation(name);
getOwnedRelationTarget(name) {
const relation = this.getOwnedRelation(name);
return relation ? await repository.getNote(relation.value) : null;
return relation ? this.repository.getNote(relation.value) : null;
}
/**
@ -694,9 +679,8 @@ class Note extends Entity {
* @param {boolean} enabled - toggle On or Off
* @param {string} name - label name
* @param {string} [value] - label value (optional)
* @returns {Promise&lt;void>}
*/
async toggleLabel(enabled, name, value) { return await this.toggleAttribute(LABEL, enabled, name, value); }
toggleLabel(enabled, name, value) { return this.toggleAttribute(LABEL, enabled, name, value); }
/**
* Based on enabled, relation is either set or removed.
@ -704,51 +688,46 @@ class Note extends Entity {
* @param {boolean} enabled - toggle On or Off
* @param {string} name - relation name
* @param {string} [value] - relation value (noteId)
* @returns {Promise&lt;void>}
*/
async toggleRelation(enabled, name, value) { return await this.toggleAttribute(RELATION, enabled, name, value); }
toggleRelation(enabled, name, value) { return this.toggleAttribute(RELATION, enabled, name, value); }
/**
* Update's given label's value or creates it if it doesn't exist
*
* @param {string} name - label name
* @param {string} [value] - label value
* @returns {Promise&lt;void>}
*/
async setLabel(name, value) { return await this.setAttribute(LABEL, name, value); }
setLabel(name, value) { return this.setAttribute(LABEL, name, value); }
/**
* Update's given relation's value or creates it if it doesn't exist
*
* @param {string} name - relation name
* @param {string} [value] - relation value (noteId)
* @returns {Promise&lt;void>}
*/
async setRelation(name, value) { return await this.setAttribute(RELATION, name, value); }
setRelation(name, value) { return this.setAttribute(RELATION, name, value); }
/**
* Remove label name-value pair, if it exists.
*
* @param {string} name - label name
* @param {string} [value] - label value
* @returns {Promise&lt;void>}
*/
async removeLabel(name, value) { return await this.removeAttribute(LABEL, name, value); }
removeLabel(name, value) { return this.removeAttribute(LABEL, name, value); }
/**
* Remove relation name-value pair, if it exists.
*
* @param {string} name - relation name
* @param {string} [value] - relation value (noteId)
* @returns {Promise&lt;void>}
*/
async removeRelation(name, value) { return await this.removeAttribute(RELATION, name, value); }
removeRelation(name, value) { return this.removeAttribute(RELATION, name, value); }
/**
* @return {Promise&lt;string[]>} return list of all descendant noteIds of this note. Returning just noteIds because number of notes can be huge. Includes also this note's noteId
* @return {string[]} return list of all descendant noteIds of this note. Returning just noteIds because number of notes can be huge. Includes also this note's noteId
*/
async getDescendantNoteIds() {
return await sql.getColumn(`
getDescendantNoteIds() {
return sql.getColumn(`
WITH RECURSIVE
tree(noteId) AS (
SELECT ?
@ -768,9 +747,9 @@ class Note extends Entity {
* @param {string} type - attribute type (label, relation, etc.)
* @param {string} name - attribute name
* @param {string} [value] - attribute value
* @returns {Promise&lt;Note[]>}
* @returns {Note[]}
*/
async getDescendantNotesWithAttribute(type, name, value) {
getDescendantNotesWithAttribute(type, name, value) {
const params = [this.noteId, name];
let valueCondition = "";
@ -779,7 +758,7 @@ class Note extends Entity {
valueCondition = " AND attributes.value = ?";
}
const notes = await repository.getEntities(`
const notes = this.repository.getEntities(`
WITH RECURSIVE
tree(noteId) AS (
SELECT ?
@ -806,36 +785,36 @@ class Note extends Entity {
*
* @param {string} name - label name
* @param {string} [value] - label value
* @returns {Promise&lt;Note[]>}
* @returns {Note[]}
*/
async getDescendantNotesWithLabel(name, value) { return await this.getDescendantNotesWithAttribute(LABEL, name, value); }
getDescendantNotesWithLabel(name, value) { return this.getDescendantNotesWithAttribute(LABEL, name, value); }
/**
* Finds descendant notes with given relation name and value. Only own relations are considered, not inherited ones
*
* @param {string} name - relation name
* @param {string} [value] - relation value
* @returns {Promise&lt;Note[]>}
* @returns {Note[]}
*/
async getDescendantNotesWithRelation(name, value) { return await this.getDescendantNotesWithAttribute(RELATION, name, value); }
getDescendantNotesWithRelation(name, value) { return this.getDescendantNotesWithAttribute(RELATION, name, value); }
/**
* Returns note revisions of this note.
*
* @returns {Promise&lt;NoteRevision[]>}
* @returns {NoteRevision[]}
*/
async getRevisions() {
return await repository.getEntities("SELECT * FROM note_revisions WHERE noteId = ?", [this.noteId]);
getRevisions() {
return this.repository.getEntities("SELECT * FROM note_revisions WHERE noteId = ?", [this.noteId]);
}
/**
* Get list of links coming out of this note.
*
* @deprecated - not intended for general use
* @returns {Promise&lt;Attribute[]>}
* @returns {Attribute[]}
*/
async getLinks() {
return await repository.getEntities(`
getLinks() {
return this.repository.getEntities(`
SELECT *
FROM attributes
WHERE noteId = ? AND
@ -845,24 +824,24 @@ class Note extends Entity {
}
/**
* @returns {Promise&lt;Branch[]>}
* @returns {Branch[]}
*/
async getBranches() {
return await repository.getEntities("SELECT * FROM branches WHERE isDeleted = 0 AND noteId = ?", [this.noteId]);
getBranches() {
return this.repository.getEntities("SELECT * FROM branches WHERE isDeleted = 0 AND noteId = ?", [this.noteId]);
}
/**
* @returns {boolean} - true if note has children
*/
async hasChildren() {
return (await this.getChildNotes()).length > 0;
hasChildren() {
return (this.getChildNotes()).length > 0;
}
/**
* @returns {Promise&lt;Note[]>} child notes of this note
* @returns {Note[]} child notes of this note
*/
async getChildNotes() {
return await repository.getEntities(`
getChildNotes() {
return this.repository.getEntities(`
SELECT notes.*
FROM branches
JOIN notes USING(noteId)
@ -873,10 +852,10 @@ class Note extends Entity {
}
/**
* @returns {Promise&lt;Branch[]>} child branches of this note
* @returns {Branch[]} child branches of this note
*/
async getChildBranches() {
return await repository.getEntities(`
getChildBranches() {
return this.repository.getEntities(`
SELECT branches.*
FROM branches
WHERE branches.isDeleted = 0
@ -885,10 +864,10 @@ class Note extends Entity {
}
/**
* @returns {Promise&lt;Note[]>} parent notes of this note (note can have multiple parents because of cloning)
* @returns {Note[]} parent notes of this note (note can have multiple parents because of cloning)
*/
async getParentNotes() {
return await repository.getEntities(`
getParentNotes() {
return this.repository.getEntities(`
SELECT parent_notes.*
FROM
branches AS child_tree
@ -899,17 +878,17 @@ class Note extends Entity {
}
/**
* @return {Promise&lt;string[][]>} - array of notePaths (each represented by array of noteIds constituting the particular note path)
* @return {string[][]} - array of notePaths (each represented by array of noteIds constituting the particular note path)
*/
async getAllNotePaths() {
getAllNotePaths() {
if (this.noteId === 'root') {
return [['root']];
}
const notePaths = [];
for (const parentNote of await this.getParentNotes()) {
for (const parentPath of await parentNote.getAllNotePaths()) {
for (const parentNote of this.getParentNotes()) {
for (const parentPath of parentNote.getAllNotePaths()) {
parentPath.push(this.noteId);
notePaths.push(parentPath);
}
@ -918,12 +897,22 @@ class Note extends Entity {
return notePaths;
}
getRelationDefinitions() {
return this.getLabels()
.filter(l => l.name.startsWith("relation:"));
}
getLabelDefinitions() {
return this.getLabels()
.filter(l => l.name.startsWith("relation:"));
}
/**
* @param ancestorNoteId
* @return {Promise&lt;boolean>} - true if ancestorNoteId occurs in at least one of the note's paths
* @return {boolean} - true if ancestorNoteId occurs in at least one of the note's paths
*/
async isDescendantOfNote(ancestorNoteId) {
const notePaths = await this.getAllNotePaths();
isDescendantOfNote(ancestorNoteId) {
const notePaths = this.getAllNotePaths();
return notePaths.some(path => path.includes(ancestorNoteId));
}
@ -941,10 +930,6 @@ class Note extends Entity {
this.utcDateCreated = dateUtils.utcNowDateTime();
}
if (this.contentLength === undefined) {
this.contentLength = -1;
}
super.beforeSaving();
if (this.isChanged) {
@ -974,7 +959,8 @@ class Note extends Entity {
}
}
module.exports = Note;</code></pre>
module.exports = Note;
</code></pre>
</article>
</section>
@ -990,7 +976,7 @@ module.exports = Note;</code></pre>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.4</a>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a>
</footer>
<script> prettyPrint(); </script>

View File

@ -30,11 +30,10 @@
const Entity = require('./entity');
const protectedSessionService = require('../services/protected_session');
const repository = require('../services/repository');
const utils = require('../services/utils');
const sql = require('../services/sql');
const dateUtils = require('../services/date_utils');
const syncTableService = require('../services/sync_table');
const entityChangesService = require('../services/entity_changes.js');
/**
* NoteRevision represents snapshot of note's title and content at some point in the past. It's used for seamless note versioning.
@ -44,7 +43,6 @@ const syncTableService = require('../services/sync_table');
* @property {string} type
* @property {string} mime
* @property {string} title
* @property {int} contentLength
* @property {boolean} isErased
* @property {boolean} isProtected
* @property {string} dateLastEdited
@ -58,11 +56,12 @@ const syncTableService = require('../services/sync_table');
class NoteRevision extends Entity {
static get entityName() { return "note_revisions"; }
static get primaryKeyName() { return "noteRevisionId"; }
static get hashedProperties() { return ["noteRevisionId", "noteId", "title", "contentLength", "isErased", "isProtected", "dateLastEdited", "dateCreated", "utcDateLastEdited", "utcDateCreated", "utcDateModified"]; }
static get hashedProperties() { return ["noteRevisionId", "noteId", "title", "isErased", "isProtected", "dateLastEdited", "dateCreated", "utcDateLastEdited", "utcDateCreated", "utcDateModified"]; }
constructor(row) {
super(row);
this.isErased = !!this.isErased;
this.isProtected = !!this.isProtected;
if (this.isProtected) {
@ -75,8 +74,8 @@ class NoteRevision extends Entity {
}
}
async getNote() {
return await repository.getNote(this.noteId);
getNote() {
return this.repository.getNote(this.noteId);
}
/** @returns {boolean} true if the note has string content (not binary) */
@ -93,10 +92,10 @@ class NoteRevision extends Entity {
* This is the same approach as is used for Note's content.
*/
/** @returns {Promise&lt;*>} */
async getContent(silentNotFoundError = false) {
/** @returns {*} */
getContent(silentNotFoundError = false) {
if (this.content === undefined) {
const res = await sql.getRow(`SELECT content, hash FROM note_revision_contents WHERE noteRevisionId = ?`, [this.noteRevisionId]);
const res = sql.getRow(`SELECT content, hash FROM note_revision_contents WHERE noteRevisionId = ?`, [this.noteRevisionId]);
if (!res) {
if (silentNotFoundError) {
@ -129,13 +128,7 @@ class NoteRevision extends Entity {
}
}
/** @returns {Promise} */
async setContent(content) {
// force updating note itself so that utcDateModified is represented correctly even for the content
this.forcedChange = true;
this.contentLength = content === null ? 0 : content.length;
await this.save();
setContent(content) {
this.content = content;
const pojo = {
@ -154,9 +147,9 @@ class NoteRevision extends Entity {
}
}
await sql.upsert("note_revision_contents", "noteRevisionId", pojo);
sql.upsert("note_revision_contents", "noteRevisionId", pojo);
await syncTableService.addNoteRevisionContentSync(this.noteRevisionId);
entityChangesService.addNoteRevisionContentEntityChange(this.noteRevisionId);
}
beforeSaving() {
@ -183,7 +176,8 @@ class NoteRevision extends Entity {
}
}
module.exports = NoteRevision;</code></pre>
module.exports = NoteRevision;
</code></pre>
</article>
</section>
@ -199,7 +193,7 @@ module.exports = NoteRevision;</code></pre>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.4</a>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a>
</footer>
<script> prettyPrint(); </script>

View File

@ -82,7 +82,7 @@ module.exports = Option;</code></pre>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.4</a>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a>
</footer>
<script> prettyPrint(); </script>

View File

@ -75,7 +75,7 @@ module.exports = RecentNote;</code></pre>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.4</a>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a>
</footer>
<script> prettyPrint(); </script>

View File

@ -391,7 +391,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line212">line 212</a>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line213">line 213</a>
</li></ul></dd>
@ -579,7 +579,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line173">line 173</a>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line174">line 174</a>
</li></ul></dd>
@ -767,7 +767,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line233">line 233</a>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line234">line 234</a>
</li></ul></dd>
@ -1053,7 +1053,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line240">line 240</a>
<a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line241">line 241</a>
</li></ul></dd>
@ -1089,7 +1089,7 @@
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.4</a>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a>
</footer>
<script> prettyPrint(); </script>

View File

@ -56,7 +56,7 @@
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.4</a>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a>
</footer>
<script> prettyPrint(); </script>

View File

@ -38,9 +38,9 @@ const repository = require('./repository');
const axios = require('axios');
const dayjs = require('dayjs');
const cloningService = require('./cloning');
const ws = require('./ws.js');
const appInfo = require('./app_info');
const searchService = require('./search');
const searchService = require('./search/services/search');
const SearchContext = require("./search/search_context.js");
/**
* This is the main backend API interface for scripts. It's published in the local "api" object.
@ -78,38 +78,31 @@ function BackendScriptApi(currentNote, apiParams) {
/**
* @method
* @param {string} noteId
* @returns {Promise&lt;Note|null>}
* @returns {Note|null}
*/
this.getNote = repository.getNote;
/**
* @method
* @param {string} branchId
* @returns {Promise&lt;Branch|null>}
* @returns {Branch|null}
*/
this.getBranch = repository.getBranch;
/**
* @method
* @param {string} attributeId
* @returns {Promise&lt;Attribute|null>}
* @returns {Attribute|null}
*/
this.getAttribute = repository.getAttribute;
/**
* @method
* @param {string} imageId
* @returns {Promise&lt;Image|null>}
*/
this.getImage = repository.getImage;
/**
* Retrieves first entity from the SQL's result set.
*
* @method
* @param {string} SQL query
* @param {Array.&lt;?>} array of params
* @returns {Promise&lt;Entity|null>}
* @returns {Entity|null}
*/
this.getEntity = repository.getEntity;
@ -117,30 +110,38 @@ function BackendScriptApi(currentNote, apiParams) {
* @method
* @param {string} SQL query
* @param {Array.&lt;?>} array of params
* @returns {Promise&lt;Entity[]>}
* @returns {Entity[]}
*/
this.getEntities = repository.getEntities;
/**
* This is a powerful search method - you can search by attributes and their values, e.g.:
* "@dateModified =* MONTH AND @log". See full documentation for all options at: https://github.com/zadam/trilium/wiki/Search
* "#dateModified =* MONTH AND #log". See full documentation for all options at: https://github.com/zadam/trilium/wiki/Search
*
* @method
* @param {string} searchString
* @returns {Promise&lt;Note[]>}
* @param {string} query
* @param {SearchContext} [searchContext]
* @returns {Note[]}
*/
this.searchForNotes = searchService.searchForNotes;
this.searchForNotes = (query, searchContext) => {
searchContext = searchContext || new SearchContext();
const noteIds = searchService.findNotesWithQuery(query, searchContext)
.map(sr => sr.noteId);
return repository.getNotes(noteIds);
};
/**
* This is a powerful search method - you can search by attributes and their values, e.g.:
* "@dateModified =* MONTH AND @log". See full documentation for all options at: https://github.com/zadam/trilium/wiki/Search
* "#dateModified =* MONTH AND #log". See full documentation for all options at: https://github.com/zadam/trilium/wiki/Search
*
* @method
* @param {string} searchString
* @returns {Promise&lt;Note|null>}
* @returns {Note|null}
*/
this.searchForNote = async searchString => {
const notes = await searchService.searchForNotes(searchString);
this.searchForNote = searchString => {
const notes = searchService.searchNoteEntities(searchString);
return notes.length > 0 ? notes[0] : null;
};
@ -151,7 +152,7 @@ function BackendScriptApi(currentNote, apiParams) {
* @method
* @param {string} name - attribute name
* @param {string} [value] - attribute value
* @returns {Promise&lt;Note[]>}
* @returns {Note[]}
*/
this.getNotesWithLabel = attributeService.getNotesWithLabel;
@ -161,7 +162,7 @@ function BackendScriptApi(currentNote, apiParams) {
* @method
* @param {string} name - attribute name
* @param {string} [value] - attribute value
* @returns {Promise&lt;Note|null>}
* @returns {Note|null}
*/
this.getNoteWithLabel = attributeService.getNoteWithLabel;
@ -172,7 +173,7 @@ function BackendScriptApi(currentNote, apiParams) {
* @param {string} noteId
* @param {string} parentNoteId
* @param {string} prefix - if branch will be create between note and parent note, set this prefix
* @returns {Promise&lt;void>}
* @returns {void}
*/
this.ensureNoteIsPresentInParent = cloningService.ensureNoteIsPresentInParent;
@ -182,7 +183,7 @@ function BackendScriptApi(currentNote, apiParams) {
* @method
* @param {string} noteId
* @param {string} parentNoteId
* @returns {Promise&lt;void>}
* @returns {void}
*/
this.ensureNoteIsAbsentFromParent = cloningService.ensureNoteIsAbsentFromParent;
@ -194,7 +195,7 @@ function BackendScriptApi(currentNote, apiParams) {
* @param {string} noteId
* @param {string} parentNoteId
* @param {string} prefix - if branch will be create between note and parent note, set this prefix
* @returns {Promise&lt;void>}
* @returns {void}
*/
this.toggleNoteInParent = cloningService.toggleNoteInParent;
@ -211,9 +212,9 @@ function BackendScriptApi(currentNote, apiParams) {
* @param {string} parentNoteId
* @param {string} title
* @param {string} content
* @return {Promise&lt;{note: Note, branch: Branch}>}
* @return {{note: Note, branch: Branch}}
*/
this.createTextNote = async (parentNoteId, title, content = '') => await noteService.createNewNote({
this.createTextNote = (parentNoteId, title, content = '') => noteService.createNewNote({
parentNoteId,
title,
content,
@ -227,9 +228,9 @@ function BackendScriptApi(currentNote, apiParams) {
* @param {string} parentNoteId
* @param {string} title
* @param {object} content
* @return {Promise&lt;{note: Note, branch: Branch}>}
* @return {{note: Note, branch: Branch}}
*/
this.createDataNote = async (parentNoteId, title, content = {}) => await noteService.createNewNote({
this.createDataNote = (parentNoteId, title, content = {}) => noteService.createNewNote({
parentNoteId,
title,
content: JSON.stringify(content, null, '\t'),
@ -254,7 +255,7 @@ function BackendScriptApi(currentNote, apiParams) {
* @method
*
* @param {CreateNewNoteParams} [params]
* @returns {Promise&lt;{note: Note, branch: Branch}>} object contains newly created entities note and branch
* @returns {{note: Note, branch: Branch}} object contains newly created entities note and branch
*/
this.createNewNote = noteService.createNewNote;
@ -276,19 +277,19 @@ function BackendScriptApi(currentNote, apiParams) {
/**
* @method
* @deprecated please use createNote() API method instead
* @deprecated please use createNewNote() API method instead
*
* @param {string} parentNoteId - create new note under this parent
* @param {string} title
* @param {string} [content=""]
* @param {CreateNoteExtraOptions} [extraOptions={}]
* @returns {Promise&lt;{note: Note, branch: Branch}>} object contains newly created entities note and branch
* @returns {{note: Note, branch: Branch}} object contains newly created entities note and branch
*/
this.createNote = async (parentNoteId, title, content = "", extraOptions= {}) => {
this.createNote = (parentNoteId, title, content = "", extraOptions= {}) => {
extraOptions.parentNoteId = parentNoteId;
extraOptions.title = title;
const parentNote = await repository.getNote(parentNoteId);
const parentNote = repository.getNote(parentNoteId);
// code note type can be inherited, otherwise text is default
extraOptions.type = parentNote.type === 'code' ? 'code' : 'text';
@ -303,19 +304,21 @@ function BackendScriptApi(currentNote, apiParams) {
extraOptions.content = content;
}
const {note, branch} = await noteService.createNewNote(extraOptions);
return sql.transactional(() => {
const {note, branch} = noteService.createNewNote(extraOptions);
for (const attr of extraOptions.attributes || []) {
await attributeService.createAttribute({
noteId: note.noteId,
type: attr.type,
name: attr.name,
value: attr.value,
isInheritable: !!attr.isInheritable
});
}
for (const attr of extraOptions.attributes || []) {
attributeService.createAttribute({
noteId: note.noteId,
type: attr.type,
name: attr.name,
value: attr.value,
isInheritable: !!attr.isInheritable
});
}
return {note, branch};
return {note, branch};
});
};
/**
@ -329,7 +332,7 @@ function BackendScriptApi(currentNote, apiParams) {
* Returns root note of the calendar.
*
* @method
* @returns {Promise&lt;Note|null>}
* @returns {Note|null}
*/
this.getRootCalendarNote = dateNoteService.getRootCalendarNote;
@ -338,7 +341,7 @@ function BackendScriptApi(currentNote, apiParams) {
*
* @method
* @param {string} date in YYYY-MM-DD format
* @returns {Promise&lt;Note|null>}
* @returns {Note|null}
*/
this.getDateNote = dateNoteService.getDateNote;
@ -346,7 +349,7 @@ function BackendScriptApi(currentNote, apiParams) {
* Returns today's day note. If such note doesn't exist, it is created.
*
* @method
* @returns {Promise&lt;Note|null>}
* @returns {Note|null}
*/
this.getTodayNote = dateNoteService.getTodayNote;
@ -356,7 +359,7 @@ function BackendScriptApi(currentNote, apiParams) {
* @method
* @param {string} date in YYYY-MM-DD format
* @param {object} options - "startOfTheWeek" - either "monday" (default) or "sunday"
* @returns {Promise&lt;Note|null>}
* @returns {Note|null}
*/
this.getWeekNote = dateNoteService.getWeekNote;
@ -365,7 +368,7 @@ function BackendScriptApi(currentNote, apiParams) {
*
* @method
* @param {string} date in YYYY-MM format
* @returns {Promise&lt;Note|null>}
* @returns {Note|null}
*/
this.getMonthNote = dateNoteService.getMonthNote;
@ -374,14 +377,13 @@ function BackendScriptApi(currentNote, apiParams) {
*
* @method
* @param {string} year in YYYY format
* @returns {Promise&lt;Note|null>}
* @returns {Note|null}
*/
this.getYearNote = dateNoteService.getYearNote;
/**
* @method
* @param {string} parentNoteId - this note's child notes will be sorted
* @returns Promise&lt;void>
*/
this.sortNotesAlphabetically = treeService.sortNotesAlphabetically;
@ -403,12 +405,9 @@ function BackendScriptApi(currentNote, apiParams) {
* This functions wraps code which is supposed to be running in transaction. If transaction already
* exists, then we'll use that transaction.
*
* This method is required only when script has label manualTransactionHandling, all other scripts are
* transactional by default.
*
* @method
* @param {function} func
* @returns {Promise&lt;?>} result of func callback
* @returns {?} result of func callback
*/
this.transactional = sql.transactional;
@ -443,7 +442,7 @@ module.exports = BackendScriptApi;
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.4</a>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a>
</footer>
<script> prettyPrint(); </script>

View File

@ -93,7 +93,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="entities_branch.js.html">entities/branch.js</a>, <a href="entities_branch.js.html#line3">line 3</a>
<a href="entities_branch.js.html">entities/branch.js</a>, <a href="entities_branch.js.html#line2">line 2</a>
</li></ul></dd>
@ -661,7 +661,7 @@
<h4 class="name" id="getParentNote"><span class="type-signature">(async) </span>getParentNote<span class="signature">()</span><span class="type-signature"> &rarr; {<a href="NoteShort.html">NoteShort</a>}</span></h4>
<h4 class="name" id="getNoteFromCache"><span class="type-signature"></span>getNoteFromCache<span class="signature">()</span><span class="type-signature"> &rarr; {<a href="NoteShort.html">NoteShort</a>}</span></h4>
@ -763,7 +763,7 @@
<h4 class="name" id="isTopLevel"><span class="type-signature"></span>isTopLevel<span class="signature">()</span><span class="type-signature"> &rarr; {boolean}</span></h4>
<h4 class="name" id="getParentNote"><span class="type-signature">(async) </span>getParentNote<span class="signature">()</span><span class="type-signature"> &rarr; {<a href="NoteShort.html">NoteShort</a>}</span></h4>
@ -836,6 +836,108 @@
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type"><a href="NoteShort.html">NoteShort</a></span>
</dd>
</dl>
<h4 class="name" id="isTopLevel"><span class="type-signature"></span>isTopLevel<span class="signature">()</span><span class="type-signature"> &rarr; {boolean}</span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="entities_branch.js.html">entities/branch.js</a>, <a href="entities_branch.js.html#line42">line 42</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
@ -885,7 +987,7 @@
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.4</a>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a>
</footer>
<script> prettyPrint(); </script>

View File

@ -1556,7 +1556,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line289">line 289</a>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line287">line 287</a>
</li></ul></dd>
@ -1712,7 +1712,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line394">line 394</a>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line392">line 392</a>
</li></ul></dd>
@ -1892,7 +1892,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line281">line 281</a>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line279">line 279</a>
</li></ul></dd>
@ -2025,7 +2025,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line243">line 243</a>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line241">line 241</a>
</li></ul></dd>
@ -2131,7 +2131,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line295">line 295</a>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line293">line 293</a>
</li></ul></dd>
@ -2237,7 +2237,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line309">line 309</a>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line307">line 307</a>
</li></ul></dd>
@ -2391,7 +2391,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line303">line 303</a>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line301">line 301</a>
</li></ul></dd>
@ -2528,7 +2528,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line360">line 360</a>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line358">line 358</a>
</li></ul></dd>
@ -2635,7 +2635,7 @@ if some action needs to happen on only one specific instance.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line236">line 236</a>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line234">line 234</a>
</li></ul></dd>
@ -2790,7 +2790,7 @@ if some action needs to happen on only one specific instance.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line369">line 369</a>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line367">line 367</a>
</li></ul></dd>
@ -2946,7 +2946,7 @@ if some action needs to happen on only one specific instance.
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line208">line 208</a>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line206">line 206</a>
</li></ul></dd>
@ -3147,7 +3147,7 @@ otherwise (by e.g. createNoteLink())
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line220">line 220</a>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line218">line 218</a>
</li></ul></dd>
@ -3253,7 +3253,7 @@ otherwise (by e.g. createNoteLink())
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line351">line 351</a>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line349">line 349</a>
</li></ul></dd>
@ -3408,7 +3408,7 @@ otherwise (by e.g. createNoteLink())
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line378">line 378</a>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line376">line 376</a>
</li></ul></dd>
@ -3559,7 +3559,7 @@ otherwise (by e.g. createNoteLink())
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line250">line 250</a>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line248">line 248</a>
</li></ul></dd>
@ -3667,7 +3667,7 @@ otherwise (by e.g. createNoteLink())
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line321">line 321</a>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line319">line 319</a>
</li></ul></dd>
@ -3823,7 +3823,7 @@ otherwise (by e.g. createNoteLink())
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line332">line 332</a>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line330">line 330</a>
</li></ul></dd>
@ -3979,7 +3979,139 @@ otherwise (by e.g. createNoteLink())
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line341">line 341</a>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line339">line 339</a>
</li></ul></dd>
</dl>
<h4 class="name" id="refreshIncludedNote"><span class="type-signature"></span>refreshIncludedNote<span class="signature">(includedNoteId)</span><span class="type-signature"></span></h4>
<div class="description">
This will refresh all currently opened notes which have included note specified in the parameter
</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>includedNoteId</code></td>
<td class="type">
</td>
<td class="description last">noteId of the included note</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line410">line 410</a>
</li></ul></dd>
@ -4065,7 +4197,7 @@ otherwise (by e.g. createNoteLink())
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line272">line 272</a>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line270">line 270</a>
</li></ul></dd>
@ -4202,7 +4334,7 @@ otherwise (by e.g. createNoteLink())
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line228">line 228</a>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line226">line 226</a>
</li></ul></dd>
@ -4516,7 +4648,7 @@ Internally this serializes the anonymous function into string and sends it to ba
<div class="description">
This is a powerful search method - you can search by attributes and their values, e.g.:
"@dateModified =* MONTH AND @log". See full documentation for all options at: https://github.com/zadam/trilium/wiki/Search
"#dateModified =* MONTH AND #log". See full documentation for all options at: https://github.com/zadam/trilium/wiki/Search
</div>
@ -4609,7 +4741,7 @@ Internally this serializes the anonymous function into string and sends it to ba
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line196">line 196</a>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line194">line 194</a>
</li></ul></dd>
@ -4672,7 +4804,7 @@ Internally this serializes the anonymous function into string and sends it to ba
<div class="description">
This is a powerful search method - you can search by attributes and their values, e.g.:
"@dateModified =* MONTH AND @log". See full documentation for all options at: https://github.com/zadam/trilium/wiki/Search
"#dateModified =* MONTH AND #log". See full documentation for all options at: https://github.com/zadam/trilium/wiki/Search
</div>
@ -4920,7 +5052,7 @@ Internally this serializes the anonymous function into string and sends it to ba
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line387">line 387</a>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line385">line 385</a>
</li></ul></dd>
@ -5071,7 +5203,7 @@ Internally this serializes the anonymous function into string and sends it to ba
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line315">line 315</a>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line313">line 313</a>
</li></ul></dd>
@ -5208,7 +5340,7 @@ Internally this serializes the anonymous function into string and sends it to ba
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line266">line 266</a>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line264">line 264</a>
</li></ul></dd>
@ -5345,7 +5477,7 @@ Internally this serializes the anonymous function into string and sends it to ba
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line258">line 258</a>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line256">line 256</a>
</li></ul></dd>
@ -5437,7 +5569,7 @@ Typical use case is when new note has been created, we should wait until it is s
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line405">line 405</a>
<a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line403">line 403</a>
</li></ul></dd>
@ -5489,7 +5621,7 @@ Typical use case is when new note has been created, we should wait until it is s
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.4</a>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a>
</footer>
<script> prettyPrint(); </script>

View File

@ -93,7 +93,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="entities_note_complement.js.html">entities/note_complement.js</a>, <a href="entities_note_complement.js.html#line5">line 5</a>
<a href="entities_note_complement.js.html">entities/note_complement.js</a>, <a href="entities_note_complement.js.html#line4">line 4</a>
</li></ul></dd>
@ -143,6 +143,122 @@
<h4 class="name" id="combinedDateModified"><span class="type-signature"></span>combinedDateModified<span class="type-signature"></span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="entities_note_complement.js.html">entities/note_complement.js</a>, <a href="entities_note_complement.js.html#line32">line 32</a>
</li></ul></dd>
</dl>
<h4 class="name" id="combinedUtcDateModified"><span class="type-signature"></span>combinedUtcDateModified<span class="type-signature"></span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="entities_note_complement.js.html">entities/note_complement.js</a>, <a href="entities_note_complement.js.html#line35">line 35</a>
</li></ul></dd>
</dl>
<h4 class="name" id="content"><span class="type-signature"></span>content<span class="type-signature"></span></h4>
@ -183,7 +299,65 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="entities_note_complement.js.html">entities/note_complement.js</a>, <a href="entities_note_complement.js.html#line10">line 10</a>
<a href="entities_note_complement.js.html">entities/note_complement.js</a>, <a href="entities_note_complement.js.html#line12">line 12</a>
</li></ul></dd>
</dl>
<h4 class="name" id="contentLength"><span class="type-signature"></span>contentLength<span class="type-signature"></span></h4>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="entities_note_complement.js.html">entities/note_complement.js</a>, <a href="entities_note_complement.js.html#line15">line 15</a>
</li></ul></dd>
@ -241,7 +415,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="entities_note_complement.js.html">entities/note_complement.js</a>, <a href="entities_note_complement.js.html#line13">line 13</a>
<a href="entities_note_complement.js.html">entities/note_complement.js</a>, <a href="entities_note_complement.js.html#line18">line 18</a>
</li></ul></dd>
@ -299,7 +473,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="entities_note_complement.js.html">entities/note_complement.js</a>, <a href="entities_note_complement.js.html#line16">line 16</a>
<a href="entities_note_complement.js.html">entities/note_complement.js</a>, <a href="entities_note_complement.js.html#line21">line 21</a>
</li></ul></dd>
@ -415,7 +589,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="entities_note_complement.js.html">entities/note_complement.js</a>, <a href="entities_note_complement.js.html#line19">line 19</a>
<a href="entities_note_complement.js.html">entities/note_complement.js</a>, <a href="entities_note_complement.js.html#line24">line 24</a>
</li></ul></dd>
@ -473,7 +647,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="entities_note_complement.js.html">entities/note_complement.js</a>, <a href="entities_note_complement.js.html#line22">line 22</a>
<a href="entities_note_complement.js.html">entities/note_complement.js</a>, <a href="entities_note_complement.js.html#line27">line 27</a>
</li></ul></dd>
@ -513,7 +687,7 @@
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.4</a>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a>
</footer>
<script> prettyPrint(); </script>

File diff suppressed because it is too large Load Diff

View File

@ -26,7 +26,9 @@
<section>
<article>
<pre class="prettyprint source linenums"><code>class Attribute {
<pre class="prettyprint source linenums"><code>import promotedAttributeDefinitionParser from '../services/promoted_attribute_definition_parser.js';
class Attribute {
constructor(treeCache, row) {
this.treeCache = treeCache;
@ -47,29 +49,75 @@
/** @param {int} position */
this.position = row.position;
/** @param {boolean} isInheritable */
this.isInheritable = row.isInheritable;
this.isInheritable = !!row.isInheritable;
}
/** @returns {NoteShort} */
async getNote() {
return await this.treeCache.getNote(this.noteId);
getNote() {
return this.treeCache.notes[this.noteId];
}
get jsonValue() {
try {
return JSON.parse(this.value);
}
catch (e) {
return null;
}
get targetNoteId() { // alias
return this.type === 'relation' ? this.value : undefined;
}
get isAutoLink() {
return this.type === 'relation' &amp;&amp; ['internalLink', 'imageLink', 'relationMapLink', 'includeNoteLink'].includes(this.name);
}
get toString() {
return `Attribute(attributeId=${this.attributeId}, type=${this.type}, name=${this.name}, value=${this.value})`;
}
/**
* @return {boolean} - returns true if this attribute has the potential to influence the note in the argument.
* That can happen in multiple ways:
* 1. attribute is owned by the note
* 2. attribute is owned by the template of the note
* 3. attribute is owned by some note's ancestor and is inheritable
*/
isAffecting(affectedNote) {
if (!affectedNote) {
return false;
}
const attrNote = this.getNote();
if (!attrNote) {
// the note (owner of the attribute) is not even loaded into the cache so it should not affect anything else
return false;
}
const owningNotes = [affectedNote, ...affectedNote.getTemplateNotes()];
for (const owningNote of owningNotes) {
if (owningNote.noteId === attrNote.noteId) {
return true;
}
}
if (this.isInheritable) {
for (const owningNote of owningNotes) {
if (owningNote.hasAncestor(attrNote)) {
return true;
}
}
}
return false;
}
isDefinition() {
return this.type === 'label' &amp;&amp; (this.name.startsWith('label:') || this.name.startsWith('relation:'));
}
getDefinition() {
return promotedAttributeDefinitionParser.parse(this.value);
}
}
export default Attribute;</code></pre>
export default Attribute;
</code></pre>
</article>
</section>
@ -85,7 +133,7 @@ export default Attribute;</code></pre>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.4</a>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a>
</footer>
<script> prettyPrint(); </script>

View File

@ -56,6 +56,11 @@ class Branch {
return this.treeCache.getNote(this.noteId);
}
/** @returns {NoteShort} */
getNoteFromCache() {
return this.treeCache.getNoteFromCache(this.noteId);
}
/** @returns {NoteShort} */
async getParentNote() {
return this.treeCache.getNote(this.parentNoteId);
@ -87,7 +92,7 @@ export default Branch;</code></pre>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.4</a>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a>
</footer>
<script> prettyPrint(); </script>

View File

@ -34,9 +34,14 @@ class NoteComplement {
/** @param {string} */
this.noteId = row.noteId;
/** @param {string} */
/**
* @param {string} - can either contain the whole content (in e.g. string notes), only part (large text notes) or nothing at all (binary notes, images)
*/
this.content = row.content;
/** @param {int} */
this.contentLength = row.contentLength;
/** @param {string} */
this.dateCreated = row.dateCreated;
@ -48,10 +53,19 @@ class NoteComplement {
/** @param {string} */
this.utcDateModified = row.utcDateModified;
// "combined" date modified give larger out of note's and note_content's dateModified
/** @param {string} */
this.combinedDateModified = row.combinedDateModified;
/** @param {string} */
this.combinedUtcDateModified = row.combinedUtcDateModified;
}
}
export default NoteComplement;</code></pre>
export default NoteComplement;
</code></pre>
</article>
</section>
@ -67,7 +81,7 @@ export default NoteComplement;</code></pre>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.4</a>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a>
</footer>
<script> prettyPrint(); </script>

View File

@ -28,13 +28,14 @@
<article>
<pre class="prettyprint source linenums"><code>import server from '../services/server.js';
import Attribute from './attribute.js';
import noteAttributeCache from "../services/note_attribute_cache.js";
const LABEL = 'label';
const LABEL_DEFINITION = 'label-definition';
const RELATION = 'relation';
const RELATION_DEFINITION = 'relation-definition';
/**
* FIXME: since there's no "full note" anymore we can rename this to Note
*
* This note's representation is used in note tree and is kept in TreeCache.
*/
class NoteShort {
@ -70,8 +71,6 @@ class NoteShort {
this.noteId = row.noteId;
/** @param {string} */
this.title = row.title;
/** @param {int} */
this.contentLength = row.contentLength;
/** @param {boolean} */
this.isProtected = !!row.isProtected;
/** @param {string} one of 'text', 'code', 'file' or 'render' */
@ -83,6 +82,10 @@ class NoteShort {
}
addParent(parentNoteId, branchId) {
if (parentNoteId === 'none') {
return;
}
if (!this.parents.includes(parentNoteId)) {
this.parents.push(parentNoteId);
}
@ -97,6 +100,10 @@ class NoteShort {
this.childToBranch[childNoteId] = branchId;
this.sortChildren();
}
sortChildren() {
const branchIdPos = {};
for (const branchId of Object.values(this.childToBranch)) {
@ -184,9 +191,9 @@ class NoteShort {
getOwnedAttributes(type, name) {
const attrs = this.attributes
.map(attributeId => this.treeCache.attributes[attributeId])
.filter(attr => !!attr);
.filter(Boolean); // filter out nulls;
return this.__filterAttrs(attrs, type, name)
return this.__filterAttrs(attrs, type, name);
}
/**
@ -195,48 +202,66 @@ class NoteShort {
* @returns {Attribute[]} all note's attributes, including inherited ones
*/
getAttributes(type, name) {
const ownedAttributes = this.getOwnedAttributes();
return this.__filterAttrs(this.__getCachedAttributes([]), type, name);
}
const attrArrs = [
ownedAttributes
];
for (const templateAttr of ownedAttributes.filter(oa => oa.type === 'relation' &amp;&amp; oa.name === 'template')) {
const templateNote = this.treeCache.getNoteFromCache(templateAttr.value);
if (templateNote) {
attrArrs.push(templateNote.getAttributes());
}
__getCachedAttributes(path) {
// notes/clones cannot form tree cycles, it is possible to create attribute inheritance cycle via templates
// when template instance is a parent of template itself
if (path.includes(this.noteId)) {
return [];
}
if (this.noteId !== 'root') {
for (const parentNote of this.getParentNotes()) {
// these virtual parent-child relationships are also loaded into frontend tree cache
if (parentNote.type !== 'search') {
attrArrs.push(parentNote.getInheritableAttributes());
if (!(this.noteId in noteAttributeCache.attributes)) {
const newPath = [...path, this.noteId];
const attrArrs = [ this.getOwnedAttributes() ];
if (this.noteId !== 'root') {
for (const parentNote of this.getParentNotes()) {
// these virtual parent-child relationships are also loaded into frontend tree cache
if (parentNote.type !== 'search') {
attrArrs.push(parentNote.__getInheritableAttributes(newPath));
}
}
}
for (const templateAttr of attrArrs.flat().filter(attr => attr.type === 'relation' &amp;&amp; attr.name === 'template')) {
const templateNote = this.treeCache.notes[templateAttr.value];
if (templateNote &amp;&amp; templateNote.noteId !== this.noteId) {
attrArrs.push(templateNote.__getCachedAttributes(newPath));
}
}
noteAttributeCache.attributes[this.noteId] = [];
const addedAttributeIds = new Set();
for (const attr of attrArrs.flat()) {
if (!addedAttributeIds.has(attr.attributeId)) {
addedAttributeIds.add(attr.attributeId);
noteAttributeCache.attributes[this.noteId].push(attr);
}
}
}
const attributes = attrArrs.flat();
return this.__filterAttrs(attributes, type, name);
return noteAttributeCache.attributes[this.noteId];
}
__filterAttrs(attributes, type, name) {
if (type &amp;&amp; name) {
if (!type &amp;&amp; !name) {
return attributes;
} else if (type &amp;&amp; name) {
return attributes.filter(attr => attr.type === type &amp;&amp; attr.name === name);
} else if (type) {
return attributes.filter(attr => attr.type === type);
} else if (name) {
return attributes.filter(attr => attr.name === name);
} else {
return attributes;
}
}
getInheritableAttributes() {
const attrs = this.getAttributes();
__getInheritableAttributes(path) {
const attrs = this.__getCachedAttributes(path);
return attrs.filter(attr => attr.isInheritable);
}
@ -257,14 +282,6 @@ class NoteShort {
return this.getAttributes(LABEL, name);
}
/**
* @param {string} [name] - label name to filter
* @returns {Attribute[]} all note's label definitions, including inherited ones
*/
getLabelDefinitions(name) {
return this.getAttributes(LABEL_DEFINITION, name);
}
/**
* @param {string} [name] - relation name to filter
* @returns {Attribute[]} all note's relations (attributes with type relation), including inherited ones
@ -281,14 +298,6 @@ class NoteShort {
return this.getAttributes(RELATION, name);
}
/**
* @param {string} [name] - relation name to filter
* @returns {Attribute[]} all note's relation definitions including inherited ones
*/
getRelationDefinitions(name) {
return this.getAttributes(RELATION_DEFINITION, name);
}
/**
* @param {string} type - attribute type (label, relation, etc.)
* @param {string} name - attribute name
@ -448,6 +457,35 @@ class NoteShort {
return targets;
}
/**
* @returns {NoteShort[]}
*/
getTemplateNotes() {
const relations = this.getRelations('template');
return relations.map(rel => this.treeCache.notes[rel.value]);
}
hasAncestor(ancestorNote) {
if (this.noteId === ancestorNote.noteId) {
return true;
}
for (const templateNote of this.getTemplateNotes()) {
if (templateNote.hasAncestor(ancestorNote)) {
return true;
}
}
for (const parentNote of this.getParentNotes()) {
if (parentNote.hasAncestor(ancestorNote)) {
return true;
}
}
return false;
}
/**
* Clear note's attributes cache to force fresh reload for next attribute request.
* Cache is note instance scoped.
@ -466,6 +504,26 @@ class NoteShort {
.map(attributeId => this.treeCache.attributes[attributeId]);
}
/**
* Get relations which target this note
*
* @returns {NoteShort[]}
*/
async getTargetRelationSourceNotes() {
const targetRelations = this.getTargetRelations();
return await this.treeCache.getNotes(targetRelations.map(tr => tr.noteId));
}
/**
* Return note complement which is most importantly note's content
*
* @return {Promise&lt;NoteComplement>}
*/
async getNoteComplement() {
return await this.treeCache.getNoteComplement(this.noteId);
}
get toString() {
return `Note(noteId=${this.noteId}, title=${this.title})`;
}
@ -483,7 +541,8 @@ class NoteShort {
}
}
export default NoteShort;</code></pre>
export default NoteShort;
</code></pre>
</article>
</section>
@ -499,7 +558,7 @@ export default NoteShort;</code></pre>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.4</a>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a>
</footer>
<script> prettyPrint(); </script>

View File

@ -608,7 +608,7 @@ separately but should behave uniformly for the user.
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.4</a>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a>
</footer>
<script> prettyPrint(); </script>

View File

@ -56,7 +56,7 @@
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.4</a>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a>
</footer>
<script> prettyPrint(); </script>

View File

@ -95,7 +95,7 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, $contain
* @return {Promise&lt;void>}
*/
this.activateNewNote = async notePath => {
await ws.waitForMaxKnownSyncId();
await ws.waitForMaxKnownEntityChangeId();
await appContext.tabManager.getActiveTabContext().setNote(notePath);
appContext.triggerEvent('focusAndSelectTitle');
@ -115,7 +115,7 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, $contain
* @param {ToolbarButtonOptions} opts
*/
this.addButtonToToolbar = opts => {
const buttonId = "toolbar-button-" + opts.title.replace(/[^a-zA-Z0-9]/g, "-");
const buttonId = "toolbar-button-" + opts.title.replace(/\s/g, "-");
const button = $('&lt;button>')
.addClass("btn btn-sm")
@ -180,7 +180,7 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, $contain
if (ret.success) {
// wait until all the changes done in the script has been synced to frontend before continuing
await ws.waitForSyncId(ret.maxSyncId);
await ws.waitForEntityChangeId(ret.maxEntityChangeId);
return ret.executionResult;
}
@ -197,25 +197,23 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, $contain
/**
* This is a powerful search method - you can search by attributes and their values, e.g.:
* "@dateModified =* MONTH AND @log". See full documentation for all options at: https://github.com/zadam/trilium/wiki/Search
* "#dateModified =* MONTH AND #log". See full documentation for all options at: https://github.com/zadam/trilium/wiki/Search
*
* @method
* @param {string} searchString
* @returns {Promise&lt;NoteShort[]>}
*/
this.searchForNotes = async searchString => {
const noteIds = await this.runOnServer(async searchString => {
const notes = await api.searchForNotes(searchString);
return notes.map(note => note.noteId);
}, [searchString]);
const noteIds = await this.runOnBackend(
searchString => api.searchForNotes(searchString).map(note => note.noteId),
[searchString]);
return await treeCache.getNotes(noteIds);
};
/**
* This is a powerful search method - you can search by attributes and their values, e.g.:
* "@dateModified =* MONTH AND @log". See full documentation for all options at: https://github.com/zadam/trilium/wiki/Search
* "#dateModified =* MONTH AND #log". See full documentation for all options at: https://github.com/zadam/trilium/wiki/Search
*
* @method
* @param {string} searchString
@ -430,10 +428,18 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, $contain
*
* @method
*/
this.waitUntilSynced = ws.waitForMaxKnownSyncId;
this.waitUntilSynced = ws.waitForMaxKnownEntityChangeId;
/**
* This will refresh all currently opened notes which have included note specified in the parameter
*
* @param includedNoteId - noteId of the included note
*/
this.refreshIncludedNote = includedNoteId => appContext.triggerEvent('refreshIncludedNote', {noteId: includedNoteId});
}
export default FrontendScriptApi;</code></pre>
export default FrontendScriptApi;
</code></pre>
</article>
</section>
@ -449,7 +455,7 @@ export default FrontendScriptApi;</code></pre>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.4</a>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a>
</footer>
<script> prettyPrint(); </script>

View File

@ -57,12 +57,14 @@ export default class CollapsibleWidget extends TabAwareWidget {
doRender() {
this.$widget = $(WIDGET_TPL);
this.contentSized();
this.$widget.find('[data-target]').attr('data-target', "#" + this.componentId);
this.$bodyWrapper = this.$widget.find('.body-wrapper');
this.$bodyWrapper.attr('id', this.componentId); // for toggle to work we need id
this.widgetName = this.constructor.name;
// not using constructor name because of webpack mangling class names ...
this.widgetName = this.widgetTitle.replace(/[^[a-zA-Z0-9]/g, "_");
if (!options.is(this.widgetName + 'Collapsed')) {
this.$bodyWrapper.collapse("show");
@ -97,8 +99,6 @@ export default class CollapsibleWidget extends TabAwareWidget {
this.initialized = this.doRenderBody();
this.decorateWidget();
return this.$widget;
}
saveCollapsed(collapse) {
@ -126,7 +126,8 @@ export default class CollapsibleWidget extends TabAwareWidget {
isExpanded() {
return this.$bodyWrapper.hasClass("show");
}
}</code></pre>
}
</code></pre>
</article>
</section>
@ -142,7 +143,7 @@ export default class CollapsibleWidget extends TabAwareWidget {
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.4</a>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a>
</footer>
<script> prettyPrint(); </script>

View File

@ -249,7 +249,7 @@ function BackendScriptApi(currentNote, apiParams) {
/**
* @method
* @deprecated please use createNewNote() API method instead
* @deprecated please use createTextNote() with similar API for simpler use cases or createNewNote() for more complex needs
*
* @param {string} parentNoteId - create new note under this parent
* @param {string} title