mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 18:36:30 +01:00 
			
		
		
		
	becca conversion WIP
This commit is contained in:
		| @@ -41,7 +41,7 @@ class Attribute extends Entity { | |||||||
|      * @returns {Note|null} |      * @returns {Note|null} | ||||||
|      */ |      */ | ||||||
|     getNote() { |     getNote() { | ||||||
|         return this.repository.getNote(this.noteId); |         return this.becca.getNote(this.noteId); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
| @@ -56,7 +56,7 @@ class Attribute extends Entity { | |||||||
|             return null; |             return null; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         return this.repository.getNote(this.value); |         return this.becca.getNote(this.value); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|   | |||||||
| @@ -29,12 +29,12 @@ class Branch extends Entity { | |||||||
|  |  | ||||||
|     /** @returns {Note|null} */ |     /** @returns {Note|null} */ | ||||||
|     getNote() { |     getNote() { | ||||||
|         return this.repository.getNote(this.noteId); |         return this.becca.getNote(this.noteId); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     /** @returns {Note|null} */ |     /** @returns {Note|null} */ | ||||||
|     getParentNote() { |     getParentNote() { | ||||||
|         return this.repository.getNote(this.parentNoteId); |         return this.becca.getNote(this.parentNoteId); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     beforeSaving() { |     beforeSaving() { | ||||||
|   | |||||||
| @@ -658,7 +658,7 @@ class Note extends Entity { | |||||||
|     getRelationTarget(name) { |     getRelationTarget(name) { | ||||||
|         const relation = this.getRelation(name); |         const relation = this.getRelation(name); | ||||||
|  |  | ||||||
|         return relation ? this.repository.getNote(relation.value) : null; |         return relation ? this.becca.getNote(relation.value) : null; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
| @@ -668,7 +668,7 @@ class Note extends Entity { | |||||||
|     getOwnedRelationTarget(name) { |     getOwnedRelationTarget(name) { | ||||||
|         const relation = this.getOwnedRelation(name); |         const relation = this.getOwnedRelation(name); | ||||||
|  |  | ||||||
|         return relation ? this.repository.getNote(relation.value) : null; |         return relation ? this.becca.getNote(relation.value) : null; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|   | |||||||
| @@ -8,7 +8,7 @@ const Attribute = require('../../entities/attribute'); | |||||||
| const becca = require("../../services/becca/becca.js"); | const becca = require("../../services/becca/becca.js"); | ||||||
|  |  | ||||||
| function getEffectiveNoteAttributes(req) { | function getEffectiveNoteAttributes(req) { | ||||||
|     const note = repository.getNote(req.params.noteId); |     const note = becca.getNote(req.params.noteId); | ||||||
|  |  | ||||||
|     return note.getAttributes(); |     return note.getAttributes(); | ||||||
| } | } | ||||||
| @@ -19,7 +19,7 @@ function updateNoteAttribute(req) { | |||||||
|  |  | ||||||
|     let attribute; |     let attribute; | ||||||
|     if (body.attributeId) { |     if (body.attributeId) { | ||||||
|         attribute = repository.getAttribute(body.attributeId); |         attribute = becca.getAttribute(body.attributeId); | ||||||
|  |  | ||||||
|         if (attribute.noteId !== noteId) { |         if (attribute.noteId !== noteId) { | ||||||
|             return [400, `Attribute ${body.attributeId} is not owned by ${noteId}`]; |             return [400, `Attribute ${body.attributeId} is not owned by ${noteId}`]; | ||||||
| @@ -116,7 +116,7 @@ function updateNoteAttributes(req) { | |||||||
|     const noteId = req.params.noteId; |     const noteId = req.params.noteId; | ||||||
|     const incomingAttributes = req.body; |     const incomingAttributes = req.body; | ||||||
|  |  | ||||||
|     const note = repository.getNote(noteId); |     const note = becca.getNote(noteId); | ||||||
|  |  | ||||||
|     let existingAttrs = note.getOwnedAttributes(); |     let existingAttrs = note.getOwnedAttributes(); | ||||||
|  |  | ||||||
| @@ -143,7 +143,7 @@ function updateNoteAttributes(req) { | |||||||
|         } |         } | ||||||
|  |  | ||||||
|         if (incAttr.type === 'relation') { |         if (incAttr.type === 'relation') { | ||||||
|             const targetNote = repository.getNote(incAttr.value); |             const targetNote = becca.getNote(incAttr.value); | ||||||
|  |  | ||||||
|             if (!targetNote || targetNote.isDeleted) { |             if (!targetNote || targetNote.isDeleted) { | ||||||
|                 log.error(`Target note of relation ${JSON.stringify(incAttr)} does not exist or is deleted`); |                 log.error(`Target note of relation ${JSON.stringify(incAttr)} does not exist or is deleted`); | ||||||
|   | |||||||
| @@ -17,8 +17,8 @@ const TaskContext = require('../../services/task_context'); | |||||||
| function moveBranchToParent(req) { | function moveBranchToParent(req) { | ||||||
|     const {branchId, parentBranchId} = req.params; |     const {branchId, parentBranchId} = req.params; | ||||||
|  |  | ||||||
|     const parentBranch = repository.getBranch(parentBranchId); |     const parentBranch = becca.getBranch(parentBranchId); | ||||||
|     const branchToMove = repository.getBranch(branchId); |     const branchToMove = becca.getBranch(branchId); | ||||||
|  |  | ||||||
|     if (!parentBranch || !branchToMove) { |     if (!parentBranch || !branchToMove) { | ||||||
|         return [400, `One or both branches ${branchId}, ${parentBranchId} have not been found`]; |         return [400, `One or both branches ${branchId}, ${parentBranchId} have not been found`]; | ||||||
| @@ -53,8 +53,8 @@ function moveBranchToParent(req) { | |||||||
| function moveBranchBeforeNote(req) { | function moveBranchBeforeNote(req) { | ||||||
|     const {branchId, beforeBranchId} = req.params; |     const {branchId, beforeBranchId} = req.params; | ||||||
|  |  | ||||||
|     const branchToMove = repository.getBranch(branchId); |     const branchToMove = becca.getBranch(branchId); | ||||||
|     const beforeBranch = repository.getBranch(beforeBranchId); |     const beforeBranch = becca.getBranch(beforeBranchId); | ||||||
|  |  | ||||||
|     if (!branchToMove) { |     if (!branchToMove) { | ||||||
|         return [404, `Can't find branch ${branchId}`]; |         return [404, `Can't find branch ${branchId}`]; | ||||||
| @@ -95,8 +95,8 @@ function moveBranchBeforeNote(req) { | |||||||
| function moveBranchAfterNote(req) { | function moveBranchAfterNote(req) { | ||||||
|     const {branchId, afterBranchId} = req.params; |     const {branchId, afterBranchId} = req.params; | ||||||
|  |  | ||||||
|     const branchToMove = repository.getBranch(branchId); |     const branchToMove = becca.getBranch(branchId); | ||||||
|     const afterNote = repository.getBranch(afterBranchId); |     const afterNote = becca.getBranch(afterBranchId); | ||||||
|  |  | ||||||
|     const validationResult = treeService.validateParentChild(afterNote.parentNoteId, branchToMove.noteId, branchId); |     const validationResult = treeService.validateParentChild(afterNote.parentNoteId, branchToMove.noteId, branchId); | ||||||
|  |  | ||||||
| @@ -180,7 +180,7 @@ function setExpandedForSubtree(req) { | |||||||
|  |  | ||||||
| function deleteBranch(req) { | function deleteBranch(req) { | ||||||
|     const last = req.query.last === 'true'; |     const last = req.query.last === 'true'; | ||||||
|     const branch = repository.getBranch(req.params.branchId); |     const branch = becca.getBranch(req.params.branchId); | ||||||
|     const taskContext = TaskContext.getInstance(req.query.taskId, 'delete-notes'); |     const taskContext = TaskContext.getInstance(req.query.taskId, 'delete-notes'); | ||||||
|  |  | ||||||
|     const deleteId = utils.randomString(10); |     const deleteId = utils.randomString(10); | ||||||
| @@ -199,7 +199,7 @@ function setPrefix(req) { | |||||||
|     const branchId = req.params.branchId; |     const branchId = req.params.branchId; | ||||||
|     const prefix = utils.isEmptyOrWhitespace(req.body.prefix) ? null : req.body.prefix; |     const prefix = utils.isEmptyOrWhitespace(req.body.prefix) ? null : req.body.prefix; | ||||||
|  |  | ||||||
|     const branch = repository.getBranch(branchId); |     const branch = becca.getBranch(branchId); | ||||||
|     branch.prefix = prefix; |     branch.prefix = prefix; | ||||||
|     branch.save(); |     branch.save(); | ||||||
| } | } | ||||||
|   | |||||||
| @@ -130,7 +130,7 @@ function createSearchNote(req) { | |||||||
|  |  | ||||||
| function getHoistedNote() { | function getHoistedNote() { | ||||||
|     return cls.getHoistedNoteId() && cls.getHoistedNoteId() !== 'root' |     return cls.getHoistedNoteId() && cls.getHoistedNoteId() !== 'root' | ||||||
|         ? repository.getNote(cls.getHoistedNoteId()) |         ? becca.getNote(cls.getHoistedNoteId()) | ||||||
|         : null; |         : null; | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -9,7 +9,7 @@ const log = require("../../services/log"); | |||||||
|  |  | ||||||
| function exportBranch(req, res) { | function exportBranch(req, res) { | ||||||
|     const {branchId, type, format, version, taskId} = req.params; |     const {branchId, type, format, version, taskId} = req.params; | ||||||
|     const branch = repository.getBranch(branchId); |     const branch = becca.getBranch(branchId); | ||||||
|  |  | ||||||
|     if (!branch) { |     if (!branch) { | ||||||
|         const message = `Cannot export branch ${branchId} since it does not exist.`; |         const message = `Cannot export branch ${branchId} since it does not exist.`; | ||||||
|   | |||||||
| @@ -1,7 +1,6 @@ | |||||||
| "use strict"; | "use strict"; | ||||||
|  |  | ||||||
| const protectedSessionService = require('../../services/protected_session'); | const protectedSessionService = require('../../services/protected_session'); | ||||||
| const repository = require('../../services/repository'); |  | ||||||
| const utils = require('../../services/utils'); | const utils = require('../../services/utils'); | ||||||
| const log = require('../../services/log'); | const log = require('../../services/log'); | ||||||
| const noteRevisionService = require('../../services/note_revisions'); | const noteRevisionService = require('../../services/note_revisions'); | ||||||
| @@ -10,12 +9,13 @@ const fs = require('fs'); | |||||||
| const { Readable } = require('stream'); | const { Readable } = require('stream'); | ||||||
| const chokidar = require('chokidar'); | const chokidar = require('chokidar'); | ||||||
| const ws = require('../../services/ws'); | const ws = require('../../services/ws'); | ||||||
|  | const becca = require("../../services/becca/becca.js"); | ||||||
|  |  | ||||||
| function updateFile(req) { | function updateFile(req) { | ||||||
|     const {noteId} = req.params; |     const {noteId} = req.params; | ||||||
|     const file = req.file; |     const file = req.file; | ||||||
|  |  | ||||||
|     const note = repository.getNote(noteId); |     const note = becca.getNote(noteId); | ||||||
|  |  | ||||||
|     if (!note) { |     if (!note) { | ||||||
|         return [404, `Note ${noteId} doesn't exist.`]; |         return [404, `Note ${noteId} doesn't exist.`]; | ||||||
| @@ -44,7 +44,7 @@ function getFilename(note) { | |||||||
| } | } | ||||||
|  |  | ||||||
| function downloadNoteFile(noteId, res, contentDisposition = true) { | function downloadNoteFile(noteId, res, contentDisposition = true) { | ||||||
|     const note = repository.getNote(noteId); |     const note = becca.getNote(noteId); | ||||||
|  |  | ||||||
|     if (!note) { |     if (!note) { | ||||||
|         return res.status(404).send(`Note ${noteId} doesn't exist.`); |         return res.status(404).send(`Note ${noteId} doesn't exist.`); | ||||||
| @@ -79,7 +79,7 @@ function openFile(req, res) { | |||||||
|  |  | ||||||
| function fileContentProvider(req) { | function fileContentProvider(req) { | ||||||
|     // Read file name from route params. |     // Read file name from route params. | ||||||
|     const note = repository.getNote(req.params.noteId); |     const note = becca.getNote(req.params.noteId); | ||||||
|     const fileName = getFilename(note); |     const fileName = getFilename(note); | ||||||
|     let content = note.getContent(); |     let content = note.getContent(); | ||||||
|  |  | ||||||
| @@ -112,7 +112,7 @@ function fileContentProvider(req) { | |||||||
| function saveToTmpDir(req) { | function saveToTmpDir(req) { | ||||||
|     const noteId = req.params.noteId; |     const noteId = req.params.noteId; | ||||||
|  |  | ||||||
|     const note = repository.getNote(noteId); |     const note = becca.getNote(noteId); | ||||||
|  |  | ||||||
|     if (!note) { |     if (!note) { | ||||||
|         return [404,`Note ${noteId} doesn't exist.`]; |         return [404,`Note ${noteId} doesn't exist.`]; | ||||||
|   | |||||||
| @@ -6,7 +6,7 @@ const RESOURCE_DIR = require('../../services/resource_dir').RESOURCE_DIR; | |||||||
| const fs = require('fs'); | const fs = require('fs'); | ||||||
|  |  | ||||||
| function returnImage(req, res) { | function returnImage(req, res) { | ||||||
|     const image = repository.getNote(req.params.noteId); |     const image = becca.getNote(req.params.noteId); | ||||||
|  |  | ||||||
|     if (!image) { |     if (!image) { | ||||||
|         return res.sendStatus(404); |         return res.sendStatus(404); | ||||||
| @@ -28,7 +28,7 @@ function uploadImage(req) { | |||||||
|     const {noteId} = req.query; |     const {noteId} = req.query; | ||||||
|     const {file} = req; |     const {file} = req; | ||||||
|  |  | ||||||
|     const note = repository.getNote(noteId); |     const note = becca.getNote(noteId); | ||||||
|  |  | ||||||
|     if (!note) { |     if (!note) { | ||||||
|         return [404, `Note ${noteId} doesn't exist.`]; |         return [404, `Note ${noteId} doesn't exist.`]; | ||||||
| @@ -50,7 +50,7 @@ function updateImage(req) { | |||||||
|     const {noteId} = req.params; |     const {noteId} = req.params; | ||||||
|     const {file} = req; |     const {file} = req; | ||||||
|  |  | ||||||
|     const note = repository.getNote(noteId); |     const note = becca.getNote(noteId); | ||||||
|  |  | ||||||
|     if (!note) { |     if (!note) { | ||||||
|         return [404, `Note ${noteId} doesn't exist.`]; |         return [404, `Note ${noteId} doesn't exist.`]; | ||||||
|   | |||||||
| @@ -30,7 +30,7 @@ async function importToBranch(req) { | |||||||
|         return [400, "No file has been uploaded"]; |         return [400, "No file has been uploaded"]; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     const parentNote = repository.getNote(parentNoteId); |     const parentNote = becca.getNote(parentNoteId); | ||||||
|  |  | ||||||
|     if (!parentNote) { |     if (!parentNote) { | ||||||
|         return [404, `Note ${parentNoteId} doesn't exist.`]; |         return [404, `Note ${parentNoteId} doesn't exist.`]; | ||||||
|   | |||||||
| @@ -13,7 +13,7 @@ const becca = require("../../services/becca/becca.js"); | |||||||
|  |  | ||||||
| function getNote(req) { | function getNote(req) { | ||||||
|     const noteId = req.params.noteId; |     const noteId = req.params.noteId; | ||||||
|     const note = repository.getNote(noteId); |     const note = becca.getNote(noteId); | ||||||
|  |  | ||||||
|     if (!note) { |     if (!note) { | ||||||
|         return [404, "Note " + noteId + " has not been found."]; |         return [404, "Note " + noteId + " has not been found."]; | ||||||
| @@ -67,7 +67,7 @@ function deleteNote(req) { | |||||||
|     // note how deleteId is separate from taskId - single taskId produces separate deleteId for each "top level" deleted note |     // note how deleteId is separate from taskId - single taskId produces separate deleteId for each "top level" deleted note | ||||||
|     const deleteId = utils.randomString(10); |     const deleteId = utils.randomString(10); | ||||||
|  |  | ||||||
|     const note = repository.getNote(noteId); |     const note = becca.getNote(noteId); | ||||||
|  |  | ||||||
|     const taskContext = TaskContext.getInstance(taskId, 'delete-notes'); |     const taskContext = TaskContext.getInstance(taskId, 'delete-notes'); | ||||||
|  |  | ||||||
| @@ -81,7 +81,7 @@ function deleteNote(req) { | |||||||
| } | } | ||||||
|  |  | ||||||
| function undeleteNote(req) { | function undeleteNote(req) { | ||||||
|     const note = repository.getNote(req.params.noteId); |     const note = becca.getNote(req.params.noteId); | ||||||
|  |  | ||||||
|     const taskContext = TaskContext.getInstance(utils.randomString(10), 'undeleteNotes'); |     const taskContext = TaskContext.getInstance(utils.randomString(10), 'undeleteNotes'); | ||||||
|  |  | ||||||
| @@ -125,7 +125,7 @@ function setNoteTypeMime(req) { | |||||||
|     const type = req.params[1]; |     const type = req.params[1]; | ||||||
|     const mime = req.params[2]; |     const mime = req.params[2]; | ||||||
|  |  | ||||||
|     const note = repository.getNote(noteId); |     const note = becca.getNote(noteId); | ||||||
|     note.type = type; |     note.type = type; | ||||||
|     note.mime = mime; |     note.mime = mime; | ||||||
|     note.save(); |     note.save(); | ||||||
| @@ -150,7 +150,7 @@ function getRelationMap(req) { | |||||||
|  |  | ||||||
|     const questionMarks = noteIds.map(noteId => '?').join(','); |     const questionMarks = noteIds.map(noteId => '?').join(','); | ||||||
|  |  | ||||||
|     const relationMapNote = repository.getNote(relationMapNoteId); |     const relationMapNote = becca.getNote(relationMapNoteId); | ||||||
|  |  | ||||||
|     const displayRelationsVal = relationMapNote.getLabelValue('displayRelations'); |     const displayRelationsVal = relationMapNote.getLabelValue('displayRelations'); | ||||||
|     const displayRelations = !displayRelationsVal ? [] : displayRelationsVal |     const displayRelations = !displayRelationsVal ? [] : displayRelationsVal | ||||||
| @@ -191,7 +191,7 @@ function changeTitle(req) { | |||||||
|     const noteId = req.params.noteId; |     const noteId = req.params.noteId; | ||||||
|     const title = req.body.title; |     const title = req.body.title; | ||||||
|  |  | ||||||
|     const note = repository.getNote(noteId); |     const note = becca.getNote(noteId); | ||||||
|  |  | ||||||
|     if (!note) { |     if (!note) { | ||||||
|         return [404, `Note ${noteId} has not been found`]; |         return [404, `Note ${noteId} has not been found`]; | ||||||
| @@ -246,7 +246,7 @@ function getDeleteNotesPreview(req) { | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     for (const branchId of branchIdsToDelete) { |     for (const branchId of branchIdsToDelete) { | ||||||
|         const branch = repository.getBranch(branchId); |         const branch = becca.getBranch(branchId); | ||||||
|  |  | ||||||
|         if (!branch) { |         if (!branch) { | ||||||
|             log.error(`Branch ${branchId} was not found and delete preview can't be calculated for this note.`); |             log.error(`Branch ${branchId} was not found and delete preview can't be calculated for this note.`); | ||||||
| @@ -280,7 +280,7 @@ function uploadModifiedFile(req) { | |||||||
|     const noteId = req.params.noteId; |     const noteId = req.params.noteId; | ||||||
|     const {filePath} = req.body; |     const {filePath} = req.body; | ||||||
|  |  | ||||||
|     const note = repository.getNote(noteId); |     const note = becca.getNote(noteId); | ||||||
|  |  | ||||||
|     if (!note) { |     if (!note) { | ||||||
|         return [404, `Note ${noteId} has not been found`]; |         return [404, `Note ${noteId} has not been found`]; | ||||||
|   | |||||||
| @@ -30,7 +30,7 @@ async function exec(req) { | |||||||
| } | } | ||||||
|  |  | ||||||
| async function run(req) { | async function run(req) { | ||||||
|     const note = repository.getNote(req.params.noteId); |     const note = becca.getNote(req.params.noteId); | ||||||
|  |  | ||||||
|     const result = await scriptService.executeNote(note, { originEntity: note }); |     const result = await scriptService.executeNote(note, { originEntity: note }); | ||||||
|  |  | ||||||
| @@ -78,7 +78,7 @@ function getWidgetBundles() { | |||||||
|  |  | ||||||
| function getRelationBundles(req) { | function getRelationBundles(req) { | ||||||
|     const noteId = req.params.noteId; |     const noteId = req.params.noteId; | ||||||
|     const note = repository.getNote(noteId); |     const note = becca.getNote(noteId); | ||||||
|     const relationName = req.params.relationName; |     const relationName = req.params.relationName; | ||||||
|  |  | ||||||
|     const attributes = note.getAttributes(); |     const attributes = note.getAttributes(); | ||||||
| @@ -89,7 +89,7 @@ function getRelationBundles(req) { | |||||||
|     const bundles = []; |     const bundles = []; | ||||||
|  |  | ||||||
|     for (const noteId of uniqueNoteIds) { |     for (const noteId of uniqueNoteIds) { | ||||||
|         const note = repository.getNote(noteId); |         const note = becca.getNote(noteId); | ||||||
|  |  | ||||||
|         if (!note.isJavaScript() || note.getScriptEnv() !== 'frontend') { |         if (!note.isJavaScript() || note.getScriptEnv() !== 'frontend') { | ||||||
|             continue; |             continue; | ||||||
| @@ -106,7 +106,7 @@ function getRelationBundles(req) { | |||||||
| } | } | ||||||
|  |  | ||||||
| function getBundle(req) { | function getBundle(req) { | ||||||
|     const note = repository.getNote(req.params.noteId); |     const note = becca.getNote(req.params.noteId); | ||||||
|  |  | ||||||
|     return scriptService.getScriptBundleForFrontend(note); |     return scriptService.getScriptBundleForFrontend(note); | ||||||
| } | } | ||||||
|   | |||||||
| @@ -38,7 +38,7 @@ async function searchFromNoteInt(note) { | |||||||
| } | } | ||||||
|  |  | ||||||
| async function searchFromNote(req) { | async function searchFromNote(req) { | ||||||
|     const note = repository.getNote(req.params.noteId); |     const note = becca.getNote(req.params.noteId); | ||||||
|  |  | ||||||
|     if (!note) { |     if (!note) { | ||||||
|         return [404, `Note ${req.params.noteId} has not been found.`]; |         return [404, `Note ${req.params.noteId} has not been found.`]; | ||||||
| @@ -130,7 +130,7 @@ function getActions(note) { | |||||||
| } | } | ||||||
|  |  | ||||||
| async function searchAndExecute(req) { | async function searchAndExecute(req) { | ||||||
|     const note = repository.getNote(req.params.noteId); |     const note = becca.getNote(req.params.noteId); | ||||||
|  |  | ||||||
|     if (!note) { |     if (!note) { | ||||||
|         return [404, `Note ${req.params.noteId} has not been found.`]; |         return [404, `Note ${req.params.noteId} has not been found.`]; | ||||||
| @@ -150,7 +150,7 @@ async function searchAndExecute(req) { | |||||||
|     const actions = getActions(note); |     const actions = getActions(note); | ||||||
|  |  | ||||||
|     for (const resultNoteId of searchResultNoteIds) { |     for (const resultNoteId of searchResultNoteIds) { | ||||||
|         const resultNote = repository.getNote(resultNoteId); |         const resultNote = becca.getNote(resultNoteId); | ||||||
|  |  | ||||||
|         if (!resultNote || resultNote.isDeleted) { |         if (!resultNote || resultNote.isDeleted) { | ||||||
|             continue; |             continue; | ||||||
|   | |||||||
| @@ -1,12 +1,12 @@ | |||||||
| "use strict"; | "use strict"; | ||||||
|  |  | ||||||
| const similarityService = require('../../services/becca/similarity.js'); | const similarityService = require('../../services/becca/similarity.js'); | ||||||
| const repository = require('../../services/repository'); | const becca = require("../../services/becca/becca.js"); | ||||||
|  |  | ||||||
| async function getSimilarNotes(req) { | async function getSimilarNotes(req) { | ||||||
|     const noteId = req.params.noteId; |     const noteId = req.params.noteId; | ||||||
|  |  | ||||||
|     const note = repository.getNote(noteId); |     const note = becca.getNote(noteId); | ||||||
|  |  | ||||||
|     if (!note) { |     if (!note) { | ||||||
|         return [404, `Note ${noteId} not found.`]; |         return [404, `Note ${noteId} not found.`]; | ||||||
|   | |||||||
| @@ -18,7 +18,7 @@ function getSchema() { | |||||||
| } | } | ||||||
|  |  | ||||||
| function execute(req) { | function execute(req) { | ||||||
|     const note = repository.getNote(req.params.noteId); |     const note = becca.getNote(req.params.noteId); | ||||||
|  |  | ||||||
|     if (!note) { |     if (!note) { | ||||||
|         return [404, `Note ${req.params.noteId} was not found.`]; |         return [404, `Note ${req.params.noteId} was not found.`]; | ||||||
|   | |||||||
| @@ -275,7 +275,7 @@ function BackendScriptApi(currentNote, apiParams) { | |||||||
|         extraOptions.parentNoteId = parentNoteId; |         extraOptions.parentNoteId = parentNoteId; | ||||||
|         extraOptions.title = title; |         extraOptions.title = title; | ||||||
|  |  | ||||||
|         const parentNote = repository.getNote(parentNoteId); |         const parentNote = becca.getNote(parentNoteId); | ||||||
|  |  | ||||||
|         // code note type can be inherited, otherwise text is default |         // code note type can be inherited, otherwise text is default | ||||||
|         extraOptions.type = parentNote.type === 'code' ? 'code' : 'text'; |         extraOptions.type = parentNote.type === 'code' ? 'code' : 'text'; | ||||||
|   | |||||||
| @@ -8,9 +8,10 @@ const repository = require('./repository'); | |||||||
| const Branch = require('../entities/branch'); | const Branch = require('../entities/branch'); | ||||||
| const TaskContext = require("./task_context.js"); | const TaskContext = require("./task_context.js"); | ||||||
| const utils = require('./utils'); | const utils = require('./utils'); | ||||||
|  | const becca = require("./becca/becca.js"); | ||||||
|  |  | ||||||
| function cloneNoteToParent(noteId, parentBranchId, prefix) { | function cloneNoteToParent(noteId, parentBranchId, prefix) { | ||||||
|     const parentBranch = repository.getBranch(parentBranchId); |     const parentBranch = becca.getBranch(parentBranchId); | ||||||
|  |  | ||||||
|     if (isNoteDeleted(noteId) || isNoteDeleted(parentBranch.noteId)) { |     if (isNoteDeleted(noteId) || isNoteDeleted(parentBranch.noteId)) { | ||||||
|         return { success: false, message: 'Note is deleted.' }; |         return { success: false, message: 'Note is deleted.' }; | ||||||
| @@ -73,7 +74,7 @@ function toggleNoteInParent(present, noteId, parentNoteId, prefix) { | |||||||
| } | } | ||||||
|  |  | ||||||
| function cloneNoteAfter(noteId, afterBranchId) { | function cloneNoteAfter(noteId, afterBranchId) { | ||||||
|     const afterNote = repository.getBranch(afterBranchId); |     const afterNote = becca.getBranch(afterBranchId); | ||||||
|  |  | ||||||
|     if (isNoteDeleted(noteId) || isNoteDeleted(afterNote.parentNoteId)) { |     if (isNoteDeleted(noteId) || isNoteDeleted(afterNote.parentNoteId)) { | ||||||
|         return { success: false, message: 'Note is deleted.' }; |         return { success: false, message: 'Note is deleted.' }; | ||||||
| @@ -103,7 +104,7 @@ function cloneNoteAfter(noteId, afterBranchId) { | |||||||
| } | } | ||||||
|  |  | ||||||
| function isNoteDeleted(noteId) { | function isNoteDeleted(noteId) { | ||||||
|     const note = repository.getNote(noteId); |     const note = becca.getNote(noteId); | ||||||
|  |  | ||||||
|     return note.isDeleted; |     return note.isDeleted; | ||||||
| } | } | ||||||
|   | |||||||
| @@ -13,6 +13,7 @@ const Branch = require('../entities/branch'); | |||||||
| const dateUtils = require('./date_utils'); | const dateUtils = require('./date_utils'); | ||||||
| const attributeService = require('./attributes'); | const attributeService = require('./attributes'); | ||||||
| const noteRevisionService = require('./note_revisions'); | const noteRevisionService = require('./note_revisions'); | ||||||
|  | const becca = require("./becca/becca.js"); | ||||||
|  |  | ||||||
| class ConsistencyChecks { | class ConsistencyChecks { | ||||||
|     constructor(autoFix) { |     constructor(autoFix) { | ||||||
| @@ -101,7 +102,7 @@ class ConsistencyChecks { | |||||||
|                       AND notes.noteId IS NULL`, |                       AND notes.noteId IS NULL`, | ||||||
|             ({branchId, noteId}) => { |             ({branchId, noteId}) => { | ||||||
|                 if (this.autoFix) { |                 if (this.autoFix) { | ||||||
|                     const branch = repository.getBranch(branchId); |                     const branch = becca.getBranch(branchId); | ||||||
|                     branch.isDeleted = true; |                     branch.isDeleted = true; | ||||||
|                     branch.save(); |                     branch.save(); | ||||||
|  |  | ||||||
| @@ -120,7 +121,7 @@ class ConsistencyChecks { | |||||||
|                       AND notes.noteId IS NULL`, |                       AND notes.noteId IS NULL`, | ||||||
|             ({branchId, parentNoteId}) => { |             ({branchId, parentNoteId}) => { | ||||||
|                 if (this.autoFix) { |                 if (this.autoFix) { | ||||||
|                     const branch = repository.getBranch(branchId); |                     const branch = becca.getBranch(branchId); | ||||||
|                     branch.parentNoteId = 'root'; |                     branch.parentNoteId = 'root'; | ||||||
|                     branch.save(); |                     branch.save(); | ||||||
|  |  | ||||||
| @@ -138,7 +139,7 @@ class ConsistencyChecks { | |||||||
|                       AND notes.noteId IS NULL`, |                       AND notes.noteId IS NULL`, | ||||||
|             ({attributeId, noteId}) => { |             ({attributeId, noteId}) => { | ||||||
|                 if (this.autoFix) { |                 if (this.autoFix) { | ||||||
|                     const attribute = repository.getAttribute(attributeId); |                     const attribute = becca.getAttribute(attributeId); | ||||||
|                     attribute.isDeleted = true; |                     attribute.isDeleted = true; | ||||||
|                     attribute.save(); |                     attribute.save(); | ||||||
|  |  | ||||||
| @@ -157,7 +158,7 @@ class ConsistencyChecks { | |||||||
|                       AND notes.noteId IS NULL`, |                       AND notes.noteId IS NULL`, | ||||||
|             ({attributeId, noteId}) => { |             ({attributeId, noteId}) => { | ||||||
|                 if (this.autoFix) { |                 if (this.autoFix) { | ||||||
|                     const attribute = repository.getAttribute(attributeId); |                     const attribute = becca.getAttribute(attributeId); | ||||||
|                     attribute.isDeleted = true; |                     attribute.isDeleted = true; | ||||||
|                     attribute.save(); |                     attribute.save(); | ||||||
|  |  | ||||||
| @@ -183,7 +184,7 @@ class ConsistencyChecks { | |||||||
|                       AND branches.isDeleted = 0`, |                       AND branches.isDeleted = 0`, | ||||||
|             ({branchId, noteId}) => { |             ({branchId, noteId}) => { | ||||||
|                 if (this.autoFix) { |                 if (this.autoFix) { | ||||||
|                     const branch = repository.getBranch(branchId); |                     const branch = becca.getBranch(branchId); | ||||||
|                     branch.isDeleted = true; |                     branch.isDeleted = true; | ||||||
|                     branch.save(); |                     branch.save(); | ||||||
|  |  | ||||||
| @@ -202,7 +203,7 @@ class ConsistencyChecks { | |||||||
|               AND branches.isDeleted = 0 |               AND branches.isDeleted = 0 | ||||||
|         `, ({branchId, parentNoteId}) => { |         `, ({branchId, parentNoteId}) => { | ||||||
|             if (this.autoFix) { |             if (this.autoFix) { | ||||||
|                 const branch = repository.getBranch(branchId); |                 const branch = becca.getBranch(branchId); | ||||||
|                 branch.isDeleted = true; |                 branch.isDeleted = true; | ||||||
|                 branch.save(); |                 branch.save(); | ||||||
|  |  | ||||||
| @@ -274,7 +275,7 @@ class ConsistencyChecks { | |||||||
|                       AND type NOT IN ('text', 'code', 'render', 'file', 'image', 'search', 'relation-map', 'book')`, |                       AND type NOT IN ('text', 'code', 'render', 'file', 'image', 'search', 'relation-map', 'book')`, | ||||||
|             ({noteId, type}) => { |             ({noteId, type}) => { | ||||||
|                 if (this.autoFix) { |                 if (this.autoFix) { | ||||||
|                     const note = repository.getNote(noteId); |                     const note = becca.getNote(noteId); | ||||||
|                     note.type = 'file'; // file is a safe option to recover notes if type is not known |                     note.type = 'file'; // file is a safe option to recover notes if type is not known | ||||||
|                     note.save(); |                     note.save(); | ||||||
|  |  | ||||||
| @@ -291,7 +292,7 @@ class ConsistencyChecks { | |||||||
|                     WHERE note_contents.noteId IS NULL`, |                     WHERE note_contents.noteId IS NULL`, | ||||||
|             ({noteId}) => { |             ({noteId}) => { | ||||||
|                 if (this.autoFix) { |                 if (this.autoFix) { | ||||||
|                     const note = repository.getNote(noteId); |                     const note = becca.getNote(noteId); | ||||||
|  |  | ||||||
|                     if (note.isProtected) { |                     if (note.isProtected) { | ||||||
|                         // this is wrong for non-erased notes but we cannot set a valid value for protected notes |                         // this is wrong for non-erased notes but we cannot set a valid value for protected notes | ||||||
| @@ -323,7 +324,7 @@ class ConsistencyChecks { | |||||||
|                       AND content IS NULL`, |                       AND content IS NULL`, | ||||||
|             ({noteId}) => { |             ({noteId}) => { | ||||||
|                 if (this.autoFix) { |                 if (this.autoFix) { | ||||||
|                     const note = repository.getNote(noteId); |                     const note = becca.getNote(noteId); | ||||||
|                     // empty string might be wrong choice for some note types but it's a best guess |                     // empty string might be wrong choice for some note types but it's a best guess | ||||||
|                     note.setContent(''); |                     note.setContent(''); | ||||||
|  |  | ||||||
| @@ -382,7 +383,7 @@ class ConsistencyChecks { | |||||||
|                       AND value = ''`, |                       AND value = ''`, | ||||||
|             ({attributeId}) => { |             ({attributeId}) => { | ||||||
|                 if (this.autoFix) { |                 if (this.autoFix) { | ||||||
|                     const relation = repository.getAttribute(attributeId); |                     const relation = becca.getAttribute(attributeId); | ||||||
|                     relation.isDeleted = true; |                     relation.isDeleted = true; | ||||||
|                     relation.save(); |                     relation.save(); | ||||||
|  |  | ||||||
| @@ -401,7 +402,7 @@ class ConsistencyChecks { | |||||||
|                       AND type != 'relation'`, |                       AND type != 'relation'`, | ||||||
|             ({attributeId, type}) => { |             ({attributeId, type}) => { | ||||||
|                 if (this.autoFix) { |                 if (this.autoFix) { | ||||||
|                     const attribute = repository.getAttribute(attributeId); |                     const attribute = becca.getAttribute(attributeId); | ||||||
|                     attribute.type = 'label'; |                     attribute.type = 'label'; | ||||||
|                     attribute.save(); |                     attribute.save(); | ||||||
|  |  | ||||||
| @@ -420,7 +421,7 @@ class ConsistencyChecks { | |||||||
|                       AND notes.isDeleted = 1`, |                       AND notes.isDeleted = 1`, | ||||||
|             ({attributeId, noteId}) => { |             ({attributeId, noteId}) => { | ||||||
|                 if (this.autoFix) { |                 if (this.autoFix) { | ||||||
|                     const attribute = repository.getAttribute(attributeId); |                     const attribute = becca.getAttribute(attributeId); | ||||||
|                     attribute.isDeleted = true; |                     attribute.isDeleted = true; | ||||||
|                     attribute.save(); |                     attribute.save(); | ||||||
|  |  | ||||||
| @@ -440,7 +441,7 @@ class ConsistencyChecks { | |||||||
|                       AND notes.isDeleted = 1`, |                       AND notes.isDeleted = 1`, | ||||||
|             ({attributeId, targetNoteId}) => { |             ({attributeId, targetNoteId}) => { | ||||||
|                 if (this.autoFix) { |                 if (this.autoFix) { | ||||||
|                     const attribute = repository.getAttribute(attributeId); |                     const attribute = becca.getAttribute(attributeId); | ||||||
|                     attribute.isDeleted = true; |                     attribute.isDeleted = true; | ||||||
|                     attribute.save(); |                     attribute.save(); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -2,6 +2,7 @@ | |||||||
|  |  | ||||||
| const repository = require("../repository"); | const repository = require("../repository"); | ||||||
| const utils = require('../utils'); | const utils = require('../utils'); | ||||||
|  | const becca = require("../becca/becca.js"); | ||||||
|  |  | ||||||
| function exportToOpml(taskContext, branch, version, res) { | function exportToOpml(taskContext, branch, version, res) { | ||||||
|     if (!['1.0', '2.0'].includes(version)) { |     if (!['1.0', '2.0'].includes(version)) { | ||||||
| @@ -13,7 +14,7 @@ function exportToOpml(taskContext, branch, version, res) { | |||||||
|     const note = branch.getNote(); |     const note = branch.getNote(); | ||||||
|  |  | ||||||
|     function exportNoteInner(branchId) { |     function exportNoteInner(branchId) { | ||||||
|         const branch = repository.getBranch(branchId); |         const branch = becca.getBranch(branchId); | ||||||
|         const note = branch.getNote(); |         const note = branch.getNote(); | ||||||
|  |  | ||||||
|         if (note.hasOwnedLabel('excludeFromExport')) { |         if (note.hasOwnedLabel('excludeFromExport')) { | ||||||
|   | |||||||
| @@ -273,7 +273,7 @@ ${content} | |||||||
|             return; |             return; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         const note = repository.getNote(noteMeta.noteId); |         const note = becca.getNote(noteMeta.noteId); | ||||||
|  |  | ||||||
|         notePaths[note.noteId] = filePathPrefix + (noteMeta.dataFileName || noteMeta.dirFileName); |         notePaths[note.noteId] = filePathPrefix + (noteMeta.dataFileName || noteMeta.dirFileName); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -51,9 +51,9 @@ eventService.subscribe(eventService.ENTITY_CREATED, ({ entityName, entity }) => | |||||||
|         runAttachedRelations(entity.getNote(), 'runOnAttributeCreation', entity); |         runAttachedRelations(entity.getNote(), 'runOnAttributeCreation', entity); | ||||||
|  |  | ||||||
|         if (entity.type === 'relation' && entity.name === 'template') { |         if (entity.type === 'relation' && entity.name === 'template') { | ||||||
|             const note = repository.getNote(entity.noteId); |             const note = becca.getNote(entity.noteId); | ||||||
|  |  | ||||||
|             const templateNote = repository.getNote(entity.value); |             const templateNote = becca.getNote(entity.value); | ||||||
|  |  | ||||||
|             if (!templateNote) { |             if (!templateNote) { | ||||||
|                 return; |                 return; | ||||||
|   | |||||||
| @@ -55,7 +55,7 @@ function getImageMimeFromExtension(ext) { | |||||||
| function updateImage(noteId, uploadBuffer, originalName) { | function updateImage(noteId, uploadBuffer, originalName) { | ||||||
|     log.info(`Updating image ${noteId}: ${originalName}`); |     log.info(`Updating image ${noteId}: ${originalName}`); | ||||||
|  |  | ||||||
|     const note = repository.getNote(noteId); |     const note = becca.getNote(noteId); | ||||||
|  |  | ||||||
|     noteRevisionService.createNoteRevision(note); |     noteRevisionService.createNoteRevision(note); | ||||||
|     noteRevisionService.protectNoteRevisions(note); |     noteRevisionService.protectNoteRevisions(note); | ||||||
| @@ -78,7 +78,7 @@ function saveImage(parentNoteId, uploadBuffer, originalName, shrinkImageSwitch) | |||||||
|  |  | ||||||
|     const fileName = sanitizeFilename(originalName); |     const fileName = sanitizeFilename(originalName); | ||||||
|  |  | ||||||
|     const parentNote = repository.getNote(parentNoteId); |     const parentNote = becca.getNote(parentNoteId); | ||||||
|  |  | ||||||
|     const {note} = noteService.createNewNote({ |     const {note} = noteService.createNewNote({ | ||||||
|         parentNoteId, |         parentNoteId, | ||||||
|   | |||||||
| @@ -171,7 +171,7 @@ async function importZip(taskContext, fileBuffer, importRootNote) { | |||||||
|         const noteTitle = utils.getNoteTitle(filePath, taskContext.data.replaceUnderscoresWithSpaces, noteMeta); |         const noteTitle = utils.getNoteTitle(filePath, taskContext.data.replaceUnderscoresWithSpaces, noteMeta); | ||||||
|         const parentNoteId = getParentNoteId(filePath, parentNoteMeta); |         const parentNoteId = getParentNoteId(filePath, parentNoteMeta); | ||||||
|  |  | ||||||
|         let note = repository.getNote(noteId); |         let note = becca.getNote(noteId); | ||||||
|  |  | ||||||
|         if (note) { |         if (note) { | ||||||
|             return; |             return; | ||||||
| @@ -340,7 +340,7 @@ async function importZip(taskContext, fileBuffer, importRootNote) { | |||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         let note = repository.getNote(noteId); |         let note = becca.getNote(noteId); | ||||||
|  |  | ||||||
|         if (note) { |         if (note) { | ||||||
|             note.setContent(content); |             note.setContent(content); | ||||||
| @@ -458,7 +458,7 @@ async function importZip(taskContext, fileBuffer, importRootNote) { | |||||||
|     }); |     }); | ||||||
|  |  | ||||||
|     for (const noteId in createdNoteIds) { // now the noteIds are unique |     for (const noteId in createdNoteIds) { // now the noteIds are unique | ||||||
|         noteService.scanForLinks(repository.getNote(noteId)); |         noteService.scanForLinks(becca.getNote(noteId)); | ||||||
|  |  | ||||||
|         if (!metaFile) { |         if (!metaFile) { | ||||||
|             // if there's no meta file then the notes are created based on the order in that tar file but that |             // if there's no meta file then the notes are created based on the order in that tar file but that | ||||||
|   | |||||||
| @@ -320,7 +320,7 @@ function downloadImages(noteId, content) { | |||||||
|             && (url.length !== 20 || url.toLowerCase().startsWith('http'))) { |             && (url.length !== 20 || url.toLowerCase().startsWith('http'))) { | ||||||
|  |  | ||||||
|             if (url in imageUrlToNoteIdMapping) { |             if (url in imageUrlToNoteIdMapping) { | ||||||
|                 const imageNote = repository.getNote(imageUrlToNoteIdMapping[url]); |                 const imageNote = becca.getNote(imageUrlToNoteIdMapping[url]); | ||||||
|  |  | ||||||
|                 if (!imageNote || imageNote.isDeleted) { |                 if (!imageNote || imageNote.isDeleted) { | ||||||
|                     delete imageUrlToNoteIdMapping[url]; |                     delete imageUrlToNoteIdMapping[url]; | ||||||
| @@ -363,9 +363,9 @@ function downloadImages(noteId, content) { | |||||||
|             // which upon the download of all the images will update the note if the links have not been fixed before |             // which upon the download of all the images will update the note if the links have not been fixed before | ||||||
|  |  | ||||||
|             sql.transactional(() => { |             sql.transactional(() => { | ||||||
|                 const imageNotes = repository.getNotes(Object.values(imageUrlToNoteIdMapping)); |                 const imageNotes = becca.getNotes(Object.values(imageUrlToNoteIdMapping)); | ||||||
|  |  | ||||||
|                 const origNote = repository.getNote(noteId); |                 const origNote = becca.getNote(noteId); | ||||||
|                 const origContent = origNote.getContent(); |                 const origContent = origNote.getContent(); | ||||||
|                 let updatedContent = origContent; |                 let updatedContent = origContent; | ||||||
|  |  | ||||||
| @@ -477,7 +477,7 @@ function saveNoteRevision(note) { | |||||||
| } | } | ||||||
|  |  | ||||||
| function updateNote(noteId, noteUpdates) { | function updateNote(noteId, noteUpdates) { | ||||||
|     const note = repository.getNote(noteId); |     const note = becca.getNote(noteId); | ||||||
|  |  | ||||||
|     if (!note.isContentAvailable) { |     if (!note.isContentAvailable) { | ||||||
|         throw new Error(`Note ${noteId} is not available for change!`); |         throw new Error(`Note ${noteId} is not available for change!`); | ||||||
| @@ -784,7 +784,7 @@ function duplicateSubtreeWithoutRoot(origNoteId, newNoteId) { | |||||||
|         throw new Error('Duplicating root is not possible'); |         throw new Error('Duplicating root is not possible'); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     const origNote = repository.getNote(origNoteId); |     const origNote = becca.getNote(origNoteId); | ||||||
|     const noteIdMapping = getNoteIdMapping(origNote); |     const noteIdMapping = getNoteIdMapping(origNote); | ||||||
|  |  | ||||||
|     for (const childBranch of origNote.getChildBranches()) { |     for (const childBranch of origNote.getChildBranches()) { | ||||||
|   | |||||||
| @@ -155,10 +155,5 @@ module.exports = { | |||||||
|     getEntities, |     getEntities, | ||||||
|     getEntity, |     getEntity, | ||||||
|     getNote, |     getNote, | ||||||
|     getNotes, |  | ||||||
|     getNoteRevision, |  | ||||||
|     getBranch, |  | ||||||
|     getAttribute, |  | ||||||
|     getOption, |  | ||||||
|     updateEntity |     updateEntity | ||||||
| }; | }; | ||||||
|   | |||||||
| @@ -52,8 +52,8 @@ async function executeBundle(bundle, apiParams = {}) { | |||||||
|  * bundle's startNote. |  * bundle's startNote. | ||||||
|  */ |  */ | ||||||
| async function executeScript(script, params, startNoteId, currentNoteId, originEntityName, originEntityId) { | async function executeScript(script, params, startNoteId, currentNoteId, originEntityName, originEntityId) { | ||||||
|     const startNote = repository.getNote(startNoteId); |     const startNote = becca.getNote(startNoteId); | ||||||
|     const currentNote = repository.getNote(currentNoteId); |     const currentNote = becca.getNote(currentNoteId); | ||||||
|     const originEntity = repository.getEntityFromName(originEntityName, originEntityId); |     const originEntity = repository.getEntityFromName(originEntityName, originEntityId); | ||||||
|  |  | ||||||
|     currentNote.content = `return (${script}\r\n)(${getParams(params)})`; |     currentNote.content = `return (${script}\r\n)(${getParams(params)})`; | ||||||
|   | |||||||
| @@ -7,6 +7,7 @@ const syncOptions = require('./sync_options'); | |||||||
| const request = require('./request'); | const request = require('./request'); | ||||||
| const appInfo = require('./app_info'); | const appInfo = require('./app_info'); | ||||||
| const utils = require('./utils'); | const utils = require('./utils'); | ||||||
|  | const becca = require("./becca/becca.js"); | ||||||
|  |  | ||||||
| async function hasSyncServerSchemaAndSeed() { | async function hasSyncServerSchemaAndSeed() { | ||||||
|     const response = await requestToSyncServer('GET', '/api/setup/status'); |     const response = await requestToSyncServer('GET', '/api/setup/status'); | ||||||
| @@ -107,8 +108,8 @@ async function setupSyncFromSyncServer(syncServerHost, syncProxy, username, pass | |||||||
|  |  | ||||||
| function getSyncSeedOptions() { | function getSyncSeedOptions() { | ||||||
|     return [ |     return [ | ||||||
|         repository.getOption('documentId'), |         becca.getOption('documentId'), | ||||||
|         repository.getOption('documentSecret') |         becca.getOption('documentSecret') | ||||||
|     ]; |     ]; | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -156,7 +156,7 @@ function sortNotesByTitle(parentNoteId, foldersFirst = false, reverse = false) { | |||||||
|  |  | ||||||
| function sortNotes(parentNoteId, sortBy, reverse = false) { | function sortNotes(parentNoteId, sortBy, reverse = false) { | ||||||
|     sql.transactional(() => { |     sql.transactional(() => { | ||||||
|         const notes = repository.getNote(parentNoteId).getChildNotes(); |         const notes = becca.getNote(parentNoteId).getChildNotes(); | ||||||
|  |  | ||||||
|         notes.sort((a, b) => a[sortBy] < b[sortBy] ? -1 : 1); |         notes.sort((a, b) => a[sortBy] < b[sortBy] ? -1 : 1); | ||||||
|  |  | ||||||
| @@ -185,7 +185,7 @@ function sortNotes(parentNoteId, sortBy, reverse = false) { | |||||||
|  * @deprecated - this will be removed in the future |  * @deprecated - this will be removed in the future | ||||||
|  */ |  */ | ||||||
| function setNoteToParent(noteId, prefix, parentNoteId) { | function setNoteToParent(noteId, prefix, parentNoteId) { | ||||||
|     const parentNote = repository.getNote(parentNoteId); |     const parentNote = becca.getNote(parentNoteId); | ||||||
|  |  | ||||||
|     if (parentNote && parentNote.isDeleted) { |     if (parentNote && parentNote.isDeleted) { | ||||||
|         throw new Error(`Cannot move note to deleted parent note ${parentNoteId}`); |         throw new Error(`Cannot move note to deleted parent note ${parentNoteId}`); | ||||||
| @@ -206,7 +206,7 @@ function setNoteToParent(noteId, prefix, parentNoteId) { | |||||||
|         branch.save(); |         branch.save(); | ||||||
|     } |     } | ||||||
|     else if (parentNoteId) { |     else if (parentNoteId) { | ||||||
|         const note = repository.getNote(noteId); |         const note = becca.getNote(noteId); | ||||||
|  |  | ||||||
|         if (note.isDeleted) { |         if (note.isDeleted) { | ||||||
|             throw new Error(`Cannot create a branch for ${noteId} which is deleted.`); |             throw new Error(`Cannot create a branch for ${noteId} which is deleted.`); | ||||||
|   | |||||||
| @@ -84,7 +84,7 @@ async function start() { | |||||||
|             isInheritable: Math.random() > 0.1 // 10% are inheritable |             isInheritable: Math.random() > 0.1 // 10% are inheritable | ||||||
|         }); |         }); | ||||||
|  |  | ||||||
|         noteRevisionService.createNoteRevision(await repository.getNote(getRandomNoteId())); |         noteRevisionService.createNoteRevision(await becca.getNote(getRandomNoteId())); | ||||||
|  |  | ||||||
|         notes.push(note.noteId); |         notes.push(note.noteId); | ||||||
|     } |     } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user