Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
API docs update
zadam56c7b7f5bd06
diff --git a/docs/backend_api/BackendScriptApi.html b/docs/backend_api/BackendScriptApi.htmlindex bcc2ef0fb8..d1cd08ae69 100644--- a/docs/backend_api/BackendScriptApi.html+++ b/docs/backend_api/BackendScriptApi.html@@ -396,7 +396,7 @@ the backend.<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#line291">line 291</a>+ <a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line327">line 327</a></li></ul></dd>@@ -534,13 +534,18 @@ the backend.- <h4 class="name" id="createNote"><span class="type-signature"></span>createNote<span class="signature">(extraOptions<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Promise.<{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"> → {Promise.<{note: <a href="Note.html">Note</a>, branch: <a href="Branch.html">Branch</a>}>}</span></h4>+<div class="description">+ Create data note - data in this context means object serializable to JSON. Created note will be of type 'code' and+JSON MIME type. See also createNote() for more options.+</div>+@@ -562,11 +567,206 @@ the backend.<th>Type</th>- <th>Attributes</th>++++ <th class="last">Description</th>+ </tr>+ </thead>++ <tbody>+++ <tr>++ <td class="name"><code>parentNoteId</code></td>+++ <td class="type">+++<span class="param-type">string</span>++++ </td>++++++ <td class="description last"></td>+ </tr>++++ <tr>++ <td class="name"><code>title</code></td>+++ <td class="type">+++<span class="param-type">string</span>++++ </td>++++++ <td class="description last"></td>+ </tr>++++ <tr>++ <td class="name"><code>content</code></td>+++ <td class="type">+++<span class="param-type">object</span>++++ </td>++++++ <td class="description last"></td>+ </tr>+++ </tbody>+</table>+++++++<dl class="details">+++++++++++++++++++++++++++ <dt class="tag-source">Source:</dt>+ <dd class="tag-source"><ul class="dummy"><li>+ <a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line204">line 204</a>+ </li></ul></dd>++++++++</dl>++++++++++++++++<h5>Returns:</h5>+++++<dl>+ <dt>+ Type+ </dt>+ <dd>++<span class="param-type">Promise.<{note: <a href="Note.html">Note</a>, branch: <a href="Branch.html">Branch</a>}></span>+++ </dd>+</dl>++++++++++++++ <h4 class="name" id="createNote"><span class="type-signature"></span>createNote<span class="signature">(params<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Promise.<{note: <a href="Note.html">Note</a>, branch: <a href="Branch.html">Branch</a>}>}</span></h4>+++++++++++++++ <h5>Parameters:</h5>+++<table class="params">+ <thead>+ <tr>++ <th>Name</th>+ <th>Type</th>+- <th>Default</th>+ <th>Attributes</th>++<th class="last">Description</th>@@ -578,7 +778,7 @@ the backend.<tr>- <td class="name"><code>extraOptions</code></td>+ <td class="name"><code>params</code></td><td class="type">@@ -603,12 +803,6 @@ the backend.- <td class="default">-- {}-- </td>-<td class="description last"></td></tr>@@ -651,7 +845,7 @@ the backend.<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#line195">line 195</a>+ <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></li></ul></dd>@@ -709,6 +903,207 @@ the backend.+ <h4 class="name" id="createTextNote"><span class="type-signature"></span>createTextNote<span class="signature">(parentNoteId, title, content)</span><span class="type-signature"> → {Promise.<{note: <a href="Note.html">Note</a>, branch: <a href="Branch.html">Branch</a>}>}</span></h4>+++++++<div class="description">+ Create text note. See also createNote() for more options.+</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>parentNoteId</code></td>+++ <td class="type">+++<span class="param-type">string</span>++++ </td>++++++ <td class="description last"></td>+ </tr>++++ <tr>++ <td class="name"><code>title</code></td>+++ <td class="type">+++<span class="param-type">string</span>++++ </td>++++++ <td class="description last"></td>+ </tr>++++ <tr>++ <td class="name"><code>content</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#line188">line 188</a>+ </li></ul></dd>++++++++</dl>++++++++++++++++<h5>Returns:</h5>+++++<dl>+ <dt>+ Type+ </dt>+ <dd>++<span class="param-type">Promise.<{note: <a href="Note.html">Note</a>, branch: <a href="Branch.html">Branch</a>}></span>+++ </dd>+</dl>+++++++++++++<h4 class="name" id="ensureNoteIsAbsentFromParent"><span class="type-signature"></span>ensureNoteIsAbsentFromParent<span class="signature">(noteId, parentNoteId)</span><span class="type-signature"> → {Promise.<void>}</span></h4>@@ -1136,7 +1531,7 @@ the backend.<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#line296">line 296</a>+ <a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line332">line 332</a></li></ul></dd>@@ -1600,7 +1995,7 @@ the backend.<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#line219">line 219</a>+ <a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line255">line 255</a></li></ul></dd>@@ -2368,7 +2763,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#line238">line 238</a>+ <a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line274">line 274</a></li></ul></dd>@@ -3021,7 +3416,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#line210">line 210</a>+ <a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line246">line 246</a></li></ul></dd>@@ -3199,7 +3594,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#line229">line 229</a>+ <a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line265">line 265</a></li></ul></dd>@@ -3354,7 +3749,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#line247">line 247</a>+ <a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line283">line 283</a></li></ul></dd>@@ -3504,7 +3899,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#line202">line 202</a>+ <a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line238">line 238</a></li></ul></dd>@@ -4007,7 +4402,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#line268">line 268</a>+ <a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line304">line 304</a></li></ul></dd>@@ -4140,7 +4535,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#line254">line 254</a>+ <a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line290">line 290</a></li></ul></dd>@@ -4515,7 +4910,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#line281">line 281</a>+ <a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line317">line 317</a></li></ul></dd>diff --git a/docs/backend_api/global.html b/docs/backend_api/global.htmlindex 542cf911b8..2221a896e2 100644--- a/docs/backend_api/global.html+++ b/docs/backend_api/global.html@@ -325,12 +325,8 @@<th>Type</th>- <th>Attributes</th>-- <th>Default</th>-<th class="last">Description</th></tr>@@ -341,74 +337,72 @@<tr>- <td class="name"><code>json</code></td>+ <td class="name"><code>parentNoteId</code></td><td class="type">-<span class="param-type">boolean</span>+<span class="param-type">string</span></td>- <td class="attributes">-- <optional><br>---- </td>-- <td class="default">-- false-- </td>-- <td class="description last">should the note be JSON</td>+ <td class="description last">MANDATORY</td></tr><tr>- <td class="name"><code>isProtected</code></td>+ <td class="name"><code>title</code></td><td class="type">-<span class="param-type">boolean</span>+<span class="param-type">string</span></td>- <td class="attributes">-- <optional><br>--- </td>+ <td class="description last">MANDATORY</td>+ </tr>++++ <tr>++ <td class="name"><code>content</code></td>+++ <td class="type">- <td class="default">-- false- </td>+<span class="param-type">string</span>+|++<span class="param-type">buffer</span>++++ </td>+- <td class="description last">should the note be protected</td>+++ <td class="description last">MANDATORY</td></tr>@@ -428,98 +422,125 @@</td>- <td class="attributes">-- <optional><br>--- </td>+ <td class="description last">text, code, file, image, search, book, relation-map - MANDATORY</td>+ </tr>++++ <tr>++ <td class="name"><code>mime</code></td>+++ <td class="type">- <td class="default">-- 'text'- </td>+<span class="param-type">string</span>++++ </td>+++- <td class="description last">note type</td>+ <td class="description last">value is derived from default mimes for type</td></tr><tr>- <td class="name"><code>mime</code></td>+ <td class="name"><code>isProtected</code></td><td class="type">-<span class="param-type">string</span>+<span class="param-type">boolean</span></td>- <td class="attributes">-- <optional><br>--- </td>+ <td class="description last">default is false</td>+ </tr>++++ <tr>++ <td class="name"><code>isExpanded</code></td>+++ <td class="type">- <td class="default">- 'text/html'-- </td>+<span class="param-type">boolean</span>++++ </td>+- <td class="description last">MIME type of the note</td>+++ <td class="description last">default is false</td></tr><tr>- <td class="name"><code>attributes</code></td>+ <td class="name"><code>prefix</code></td><td class="type">-<span class="param-type">Array.<<a href="global.html#CreateNoteAttribute">CreateNoteAttribute</a>></span>+<span class="param-type">string</span></td>- <td class="attributes">-- <optional><br>--- </td>+ <td class="description last">default is empty string</td>+ </tr>++++ <tr>++ <td class="name"><code>notePosition</code></td>+++ <td class="type">- <td class="default">-- []- </td>+<span class="param-type">int</span>++++ </td>+++- <td class="description last">attributes to be created for this note</td>+ <td class="description last">default is last existing notePosition in a parent + 10</td></tr>@@ -558,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#line180">line 180</a>+ <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></li></ul></dd>diff --git a/docs/backend_api/services_backend_script_api.js.html b/docs/backend_api/services_backend_script_api.js.htmlindex 0fbb86466d..725fe064ea 100644--- a/docs/backend_api/services_backend_script_api.js.html+++ b/docs/backend_api/services_backend_script_api.js.html@@ -205,19 +205,55 @@ function BackendScriptApi(currentNote, apiParams) {* @property {string} [value] - attribute value*/+ /**+ * Create text note. See also createNote() for more options.+ *+ * @param {string} parentNoteId+ * @param {string} title+ * @param {string} content+ * @return {Promise<{note: Note, branch: Branch}>}+ */+ this.createTextNote = async (parentNoteId, title, content = '') => await noteService.createNewNote({+ parentNoteId,+ title,+ content,+ type: 'text'+ });++ /**+ * Create data note - data in this context means object serializable to JSON. Created note will be of type 'code' and+ * JSON MIME type. See also createNote() for more options.+ *+ * @param {string} parentNoteId+ * @param {string} title+ * @param {object} content+ * @return {Promise<{note: Note, branch: Branch}>}+ */+ this.createDataNote = async (parentNoteId, title, content = {}) => await noteService.createNewNote({+ parentNoteId,+ title,+ content: JSON.stringify(content),+ type: 'code',+ mime: 'application/json'+ });+/*** @typedef {object} CreateNoteParams- * @property {boolean} [json=false] - should the note be JSON- * @property {boolean} [isProtected=false] - should the note be protected- * @property {string} [type='text'] - note type- * @property {string} [mime='text/html'] - MIME type of the note- * @property {CreateNoteAttribute[]} [attributes=[]] - attributes to be created for this note+ * @property {string} parentNoteId - MANDATORY+ * @property {string} title - MANDATORY+ * @property {string|buffer} content - MANDATORY+ * @property {string} type - text, code, file, image, search, book, relation-map - MANDATORY+ * @property {string} mime - value is derived from default mimes for type+ * @property {boolean} isProtected - default is false+ * @property {boolean} isExpanded - default is false+ * @property {string} prefix - default is empty string+ * @property {int} notePosition - default is last existing notePosition in a parent + 10*//*** @method*- * @param {CreateNoteParams} [extraOptions={}]+ * @param {CreateNoteParams} [params]* @returns {Promise<{note: Note, branch: Branch}>} object contains newly created entities note and branch*/this.createNote = noteService.createNewNote;