mirror of
https://github.com/zadam/trilium.git
synced 2025-10-27 08:16:40 +01:00
updated API docs
This commit is contained in:
@@ -34,14 +34,14 @@ const attributeService = require('./attributes');
|
||||
const dateNoteService = require('./date_notes');
|
||||
const treeService = require('./tree');
|
||||
const config = require('./config');
|
||||
const repository = require('./repository');
|
||||
const axios = require('axios');
|
||||
const dayjs = require('dayjs');
|
||||
const xml2js = require('xml2js');
|
||||
const cloningService = require('./cloning');
|
||||
const appInfo = require('./app_info');
|
||||
const searchService = require('./search/services/search');
|
||||
const SearchContext = require("./search/search_context.js");
|
||||
const SearchContext = require("./search/search_context");
|
||||
const becca = require("../becca/becca");
|
||||
|
||||
/**
|
||||
* This is the main backend API interface for scripts. It's published in the local "api" object.
|
||||
@@ -86,39 +86,21 @@ function BackendScriptApi(currentNote, apiParams) {
|
||||
* @param {string} noteId
|
||||
* @returns {Note|null}
|
||||
*/
|
||||
this.getNote = repository.getNote;
|
||||
this.getNote = becca.getNote;
|
||||
|
||||
/**
|
||||
* @method
|
||||
* @param {string} branchId
|
||||
* @returns {Branch|null}
|
||||
*/
|
||||
this.getBranch = repository.getBranch;
|
||||
this.getBranch = becca.getBranch;
|
||||
|
||||
/**
|
||||
* @method
|
||||
* @param {string} attributeId
|
||||
* @returns {Attribute|null}
|
||||
*/
|
||||
this.getAttribute = repository.getAttribute;
|
||||
|
||||
/**
|
||||
* Retrieves first entity from the SQL's result set.
|
||||
*
|
||||
* @method
|
||||
* @param {string} SQL query
|
||||
* @param {Array.<?>} array of params
|
||||
* @returns {Entity|null}
|
||||
*/
|
||||
this.getEntity = repository.getEntity;
|
||||
|
||||
/**
|
||||
* @method
|
||||
* @param {string} SQL query
|
||||
* @param {Array.<?>} array of params
|
||||
* @returns {Entity[]}
|
||||
*/
|
||||
this.getEntities = repository.getEntities;
|
||||
this.getAttribute = becca.getAttribute;
|
||||
|
||||
/**
|
||||
* This is a powerful search method - you can search by attributes and their values, e.g.:
|
||||
@@ -141,7 +123,7 @@ function BackendScriptApi(currentNote, apiParams) {
|
||||
const noteIds = searchService.findResultsWithQuery(query, new SearchContext(searchParams))
|
||||
.map(sr => sr.noteId);
|
||||
|
||||
return repository.getNotes(noteIds);
|
||||
return becca.getNotes(noteIds);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -149,11 +131,12 @@ function BackendScriptApi(currentNote, apiParams) {
|
||||
* "#dateModified =* MONTH AND #log". See full documentation for all options at: https://github.com/zadam/trilium/wiki/Search
|
||||
*
|
||||
* @method
|
||||
* @param {string} searchString
|
||||
* @param {string} query
|
||||
* @param {Object} [searchParams]
|
||||
* @returns {Note|null}
|
||||
*/
|
||||
this.searchForNote = searchString => {
|
||||
const notes = searchService.searchNoteEntities(searchString);
|
||||
this.searchForNote = (query, searchParams = {}) => {
|
||||
const notes = this.searchForNotes(query, searchParams);
|
||||
|
||||
return notes.length > 0 ? notes[0] : null;
|
||||
};
|
||||
@@ -301,7 +284,7 @@ function BackendScriptApi(currentNote, apiParams) {
|
||||
extraOptions.parentNoteId = parentNoteId;
|
||||
extraOptions.title = title;
|
||||
|
||||
const parentNote = repository.getNote(parentNoteId);
|
||||
const parentNote = becca.getNote(parentNoteId);
|
||||
|
||||
// code note type can be inherited, otherwise text is default
|
||||
extraOptions.type = parentNote.type === 'code' ? 'code' : 'text';
|
||||
@@ -397,7 +380,7 @@ function BackendScriptApi(currentNote, apiParams) {
|
||||
* @method
|
||||
* @param {string} parentNoteId - this note's child notes will be sorted
|
||||
*/
|
||||
this.sortNotesByTitle = treeService.sortNotesByTitle;
|
||||
this.sortNotesByTitle = parentNoteId => treeService.sortNotes(parentNoteId);
|
||||
|
||||
/**
|
||||
* This method finds note by its noteId and prefix and either sets it to the given parentNoteId
|
||||
@@ -474,13 +457,13 @@ module.exports = BackendScriptApi;
|
||||
</div>
|
||||
|
||||
<nav>
|
||||
<h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-sql.html">sql</a></li></ul><h3>Classes</h3><ul><li><a href="ApiToken.html">ApiToken</a></li><li><a href="Attribute.html">Attribute</a></li><li><a href="BackendScriptApi.html">BackendScriptApi</a></li><li><a href="Branch.html">Branch</a></li><li><a href="Entity.html">Entity</a></li><li><a href="Note.html">Note</a></li><li><a href="NoteRevision.html">NoteRevision</a></li><li><a href="Option.html">Option</a></li><li><a href="RecentNote.html">RecentNote</a></li></ul><h3><a href="global.html">Global</a></h3>
|
||||
<h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-sql.html">sql</a></li></ul><h3>Classes</h3><ul><li><a href="ApiToken.html">ApiToken</a></li><li><a href="BackendScriptApi.html">BackendScriptApi</a></li><li><a href="NoteRevision.html">NoteRevision</a></li><li><a href="Option.html">Option</a></li><li><a href="RecentNote.html">RecentNote</a></li></ul><h3><a href="global.html">Global</a></h3>
|
||||
</nav>
|
||||
|
||||
<br class="clear">
|
||||
|
||||
<footer>
|
||||
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a>
|
||||
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.7</a>
|
||||
</footer>
|
||||
|
||||
<script> prettyPrint(); </script>
|
||||
|
||||
Reference in New Issue
Block a user