mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 10:26:08 +01:00 
			
		
		
		
	rename becca entities to have B-prefix, #3476
This commit is contained in:
		| @@ -1,10 +1,10 @@ | ||||
| const Note = require('../../src/becca/entities/note'); | ||||
| const Branch = require('../../src/becca/entities/branch'); | ||||
| const Attribute = require('../../src/becca/entities/attribute'); | ||||
| const Note = require('../../src/becca/entities/bnote.js'); | ||||
| const Branch = require('../../src/becca/entities/bbranch.js'); | ||||
| const Attribute = require('../../src/becca/entities/battribute.js'); | ||||
| const becca = require('../../src/becca/becca'); | ||||
| const randtoken = require('rand-token').generator({source: 'crypto'}); | ||||
|  | ||||
| /** @returns {Note} */ | ||||
| /** @returns {BNote} */ | ||||
| function findNoteByTitle(searchResults, title) { | ||||
|     return searchResults | ||||
|         .map(sr => becca.notes[sr.noteId]) | ||||
| @@ -17,7 +17,7 @@ class NoteBuilder { | ||||
|     } | ||||
|  | ||||
|     label(name, value = '', isInheritable = false) { | ||||
|         new Attribute({ | ||||
|         new BAttribute({ | ||||
|             attributeId: id(), | ||||
|             noteId: this.note.noteId, | ||||
|             type: 'label', | ||||
| @@ -30,7 +30,7 @@ class NoteBuilder { | ||||
|     } | ||||
|  | ||||
|     relation(name, targetNote) { | ||||
|         new Attribute({ | ||||
|         new BAttribute({ | ||||
|             attributeId: id(), | ||||
|             noteId: this.note.noteId, | ||||
|             type: 'relation', | ||||
| @@ -42,7 +42,7 @@ class NoteBuilder { | ||||
|     } | ||||
|  | ||||
|     child(childNoteBuilder, prefix = "") { | ||||
|         new Branch({ | ||||
|         new BBranch({ | ||||
|             branchId: id(), | ||||
|             noteId: childNoteBuilder.note.noteId, | ||||
|             parentNoteId: this.note.noteId, | ||||
| @@ -66,7 +66,7 @@ function note(title, extraParams = {}) { | ||||
|         mime: 'text/html' | ||||
|     }, extraParams); | ||||
|  | ||||
|     const note = new Note(row); | ||||
|     const note = new BNote(row); | ||||
|  | ||||
|     return new NoteBuilder(note); | ||||
| } | ||||
|   | ||||
| @@ -1,6 +1,6 @@ | ||||
| const searchService = require('../../src/services/search/services/search'); | ||||
| const Note = require('../../src/becca/entities/note'); | ||||
| const Branch = require('../../src/becca/entities/branch'); | ||||
| const Note = require('../../src/becca/entities/bnote.js'); | ||||
| const Branch = require('../../src/becca/entities/bbranch.js'); | ||||
| const SearchContext = require('../../src/services/search/search_context'); | ||||
| const dateUtils = require('../../src/services/date_utils'); | ||||
| const becca = require('../../src/becca/becca'); | ||||
| @@ -12,8 +12,8 @@ describe("Search", () => { | ||||
|     beforeEach(() => { | ||||
|         becca.reset(); | ||||
|  | ||||
|         rootNote = new NoteBuilder(new Note({noteId: 'root', title: 'root', type: 'text'})); | ||||
|         new Branch({branchId: 'none_root', noteId: 'root', parentNoteId: 'none', notePosition: 10}); | ||||
|         rootNote = new NoteBuilder(new BNote({noteId: 'root', title: 'root', type: 'text'})); | ||||
|         new BBranch({branchId: 'none_root', noteId: 'root', parentNoteId: 'none', notePosition: 10}); | ||||
|     }); | ||||
|  | ||||
|     it("simple path match", () => { | ||||
|   | ||||
| @@ -12,7 +12,7 @@ class Becca { | ||||
|     } | ||||
|  | ||||
|     reset() { | ||||
|         /** @type {Object.<String, Note>} */ | ||||
|         /** @type {Object.<String, BNote>} */ | ||||
|         this.notes = {}; | ||||
|         /** @type {Object.<String, Branch>} */ | ||||
|         this.branches = {}; | ||||
| @@ -72,12 +72,12 @@ class Becca { | ||||
|         this.dirtyNoteSetCache(); | ||||
|     } | ||||
|  | ||||
|     /** @returns {Note|null} */ | ||||
|     /** @returns {BNote|null} */ | ||||
|     getNote(noteId) { | ||||
|         return this.notes[noteId]; | ||||
|     } | ||||
|  | ||||
|     /** @returns {Note[]} */ | ||||
|     /** @returns {BNote[]} */ | ||||
|     getNotes(noteIds, ignoreMissing = false) { | ||||
|         const filteredNotes = []; | ||||
|  | ||||
| @@ -113,12 +113,12 @@ class Becca { | ||||
|         return this.childParentToBranch[`${childNoteId}-${parentNoteId}`]; | ||||
|     } | ||||
|  | ||||
|     /** @returns {NoteRevision|null} */ | ||||
|     /** @returns {BNoteRevision|null} */ | ||||
|     getNoteRevision(noteRevisionId) { | ||||
|         const row = sql.getRow("SELECT * FROM note_revisions WHERE noteRevisionId = ?", [noteRevisionId]); | ||||
|  | ||||
|         const NoteRevision = require("./entities/note_revision"); // avoiding circular dependency problems | ||||
|         return row ? new NoteRevision(row) : null; | ||||
|         const BNoteRevision = require("./entities/bnote_revision"); // avoiding circular dependency problems | ||||
|         return row ? new BNoteRevision(row) : null; | ||||
|     } | ||||
|  | ||||
|     /** @returns {Option|null} */ | ||||
| @@ -155,19 +155,19 @@ class Becca { | ||||
|         return this[camelCaseEntityName][entityId]; | ||||
|     } | ||||
|  | ||||
|     /** @returns {RecentNote[]} */ | ||||
|     /** @returns {BRecentNote[]} */ | ||||
|     getRecentNotesFromQuery(query, params = []) { | ||||
|         const rows = sql.getRows(query, params); | ||||
|  | ||||
|         const RecentNote = require("./entities/recent_note"); // avoiding circular dependency problems | ||||
|         return rows.map(row => new RecentNote(row)); | ||||
|         const BRecentNote = require("./entities/brecent_note"); // avoiding circular dependency problems | ||||
|         return rows.map(row => new BRecentNote(row)); | ||||
|     } | ||||
|  | ||||
|     /** @returns {NoteRevision[]} */ | ||||
|     /** @returns {BNoteRevision[]} */ | ||||
|     getNoteRevisionsFromQuery(query, params = []) { | ||||
|         const rows = sql.getRows(query, params); | ||||
|  | ||||
|         const NoteRevision = require("./entities/note_revision"); // avoiding circular dependency problems | ||||
|         const BNoteRevision = require("./entities/bnote_revision"); // avoiding circular dependency problems | ||||
|         return rows.map(row => new NoteRevision(row)); | ||||
|     } | ||||
|  | ||||
|   | ||||
| @@ -5,11 +5,11 @@ const eventService = require('../services/events'); | ||||
| const becca = require('./becca'); | ||||
| const sqlInit = require('../services/sql_init'); | ||||
| const log = require('../services/log'); | ||||
| const Note = require('./entities/note'); | ||||
| const Branch = require('./entities/branch'); | ||||
| const Attribute = require('./entities/attribute'); | ||||
| const Option = require('./entities/option'); | ||||
| const EtapiToken = require("./entities/etapi_token"); | ||||
| const BNote = require('./entities/bnote'); | ||||
| const BBranch = require('./entities/bbranch'); | ||||
| const BAttribute = require('./entities/battribute'); | ||||
| const BOption = require('./entities/boption'); | ||||
| const BEtapiToken = require("./entities/betapi_token"); | ||||
| const cls = require("../services/cls"); | ||||
| const entityConstructor = require("../becca/entity_constructor"); | ||||
|  | ||||
| @@ -31,23 +31,23 @@ function load() { | ||||
|     // this is worth it for becca load since it happens every run and blocks the app until finished | ||||
|  | ||||
|     for (const row of sql.getRawRows(`SELECT noteId, title, type, mime, isProtected, dateCreated, dateModified, utcDateCreated, utcDateModified FROM notes WHERE isDeleted = 0`)) { | ||||
|         new Note().update(row).init(); | ||||
|         new BNote().update(row).init(); | ||||
|     } | ||||
|  | ||||
|     for (const row of sql.getRawRows(`SELECT branchId, noteId, parentNoteId, prefix, notePosition, isExpanded, utcDateModified FROM branches WHERE isDeleted = 0`)) { | ||||
|         new Branch().update(row).init(); | ||||
|         new BBranch().update(row).init(); | ||||
|     } | ||||
|  | ||||
|     for (const row of sql.getRawRows(`SELECT attributeId, noteId, type, name, value, isInheritable, position, utcDateModified FROM attributes WHERE isDeleted = 0`)) { | ||||
|         new Attribute().update(row).init(); | ||||
|         new BAttribute().update(row).init(); | ||||
|     } | ||||
|  | ||||
|     for (const row of sql.getRows(`SELECT name, value, isSynced, utcDateModified FROM options`)) { | ||||
|         new Option(row); | ||||
|         new BOption(row); | ||||
|     } | ||||
|  | ||||
|     for (const row of sql.getRows(`SELECT etapiTokenId, name, tokenHash, utcDateCreated, utcDateModified FROM etapi_tokens WHERE isDeleted = 0`)) { | ||||
|         new EtapiToken(row); | ||||
|         new BEtapiToken(row); | ||||
|     } | ||||
|  | ||||
|     for (const noteId in becca.notes) { | ||||
|   | ||||
| @@ -2,7 +2,6 @@ | ||||
|  | ||||
| const becca = require('./becca'); | ||||
| const cls = require('../services/cls'); | ||||
| const protectedSessionService = require('../services/protected_session'); | ||||
| const log = require('../services/log'); | ||||
|  | ||||
| function isNotePathArchived(notePath) { | ||||
|   | ||||
| @@ -13,7 +13,7 @@ let becca = null; | ||||
| /** | ||||
|  * Base class for all backend entities. | ||||
|  */ | ||||
| class AbstractEntity { | ||||
| class AbstractBeccaEntity { | ||||
|     /** @protected */ | ||||
|     beforeSaving() { | ||||
|         this.generateIdIfNecessary(); | ||||
| @@ -167,4 +167,4 @@ class AbstractEntity { | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| module.exports = AbstractEntity; | ||||
| module.exports = AbstractBeccaEntity; | ||||
| @@ -1,7 +1,7 @@ | ||||
| "use strict"; | ||||
| 
 | ||||
| const Note = require('./note'); | ||||
| const AbstractEntity = require("./abstract_entity"); | ||||
| const BNote = require('./bnote'); | ||||
| const AbstractBeccaEntity = require("./abstract_becca_entity"); | ||||
| const sql = require("../../services/sql"); | ||||
| const dateUtils = require("../../services/date_utils"); | ||||
| const promotedAttributeDefinitionParser = require("../../services/promoted_attribute_definition_parser"); | ||||
| @@ -11,9 +11,9 @@ const {sanitizeAttributeName} = require("../../services/sanitize_attribute_name" | ||||
|  * Attribute is an abstract concept which has two real uses - label (key - value pair) | ||||
|  * and relation (representing named relationship between source and target note) | ||||
|  * | ||||
|  * @extends AbstractEntity | ||||
|  * @extends AbstractBeccaEntity | ||||
|  */ | ||||
| class Attribute extends AbstractEntity { | ||||
| class BAttribute extends AbstractBeccaEntity { | ||||
|     static get entityName() { return "attributes"; } | ||||
|     static get primaryKeyName() { return "attributeId"; } | ||||
|     static get hashedProperties() { return ["attributeId", "noteId", "type", "name", "value", "isInheritable"]; } | ||||
| @@ -70,7 +70,7 @@ class Attribute extends AbstractEntity { | ||||
| 
 | ||||
|         if (!(this.noteId in this.becca.notes)) { | ||||
|             // entities can come out of order in sync, create skeleton which will be filled later
 | ||||
|             this.becca.addNote(this.noteId, new Note({noteId: this.noteId})); | ||||
|             this.becca.addNote(this.noteId, new BNote({noteId: this.noteId})); | ||||
|         } | ||||
| 
 | ||||
|         this.becca.notes[this.noteId].ownedAttributes.push(this); | ||||
| @@ -124,7 +124,7 @@ class Attribute extends AbstractEntity { | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * @returns {Note|null} | ||||
|      * @returns {BNote|null} | ||||
|      */ | ||||
|     getNote() { | ||||
|         const note = this.becca.getNote(this.noteId); | ||||
| @@ -137,7 +137,7 @@ class Attribute extends AbstractEntity { | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * @returns {Note|null} | ||||
|      * @returns {BNote|null} | ||||
|      */ | ||||
|     getTargetNote() { | ||||
|         if (this.type !== 'relation') { | ||||
| @@ -217,7 +217,7 @@ class Attribute extends AbstractEntity { | ||||
|     } | ||||
| 
 | ||||
|     createClone(type, name, value, isInheritable) { | ||||
|         return new Attribute({ | ||||
|         return new BAttribute({ | ||||
|             noteId: this.noteId, | ||||
|             type: type, | ||||
|             name: name, | ||||
| @@ -229,4 +229,4 @@ class Attribute extends AbstractEntity { | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| module.exports = Attribute; | ||||
| module.exports = BAttribute; | ||||
| @@ -1,7 +1,7 @@ | ||||
| "use strict"; | ||||
| 
 | ||||
| const Note = require('./note'); | ||||
| const AbstractEntity = require("./abstract_entity"); | ||||
| const BNote = require('./bnote'); | ||||
| const AbstractBeccaEntity = require("./abstract_becca_entity"); | ||||
| const dateUtils = require("../../services/date_utils"); | ||||
| const utils = require("../../services/utils"); | ||||
| const TaskContext = require("../../services/task_context"); | ||||
| @@ -15,9 +15,9 @@ const log = require("../../services/log"); | ||||
|  * Note that you should not rely on the branch's identity, since it can change easily with a note's move. | ||||
|  * Always check noteId instead. | ||||
|  * | ||||
|  * @extends AbstractEntity | ||||
|  * @extends AbstractBeccaEntity | ||||
|  */ | ||||
| class Branch extends AbstractEntity { | ||||
| class BBranch extends AbstractBeccaEntity { | ||||
|     static get entityName() { return "branches"; } | ||||
|     static get primaryKeyName() { return "branchId"; } | ||||
|     // notePosition is not part of hash because it would produce a lot of updates in case of reordering
 | ||||
| @@ -93,11 +93,11 @@ class Branch extends AbstractEntity { | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     /** @returns {Note} */ | ||||
|     /** @returns {BNote} */ | ||||
|     get childNote() { | ||||
|         if (!(this.noteId in this.becca.notes)) { | ||||
|             // entities can come out of order in sync/import, create skeleton which will be filled later
 | ||||
|             this.becca.addNote(this.noteId, new Note({noteId: this.noteId})); | ||||
|             this.becca.addNote(this.noteId, new BNote({noteId: this.noteId})); | ||||
|         } | ||||
| 
 | ||||
|         return this.becca.notes[this.noteId]; | ||||
| @@ -107,11 +107,11 @@ class Branch extends AbstractEntity { | ||||
|         return this.childNote; | ||||
|     } | ||||
| 
 | ||||
|     /** @returns {Note|undefined} - root branch will have undefined parent, all other branches have to have a parent note */ | ||||
|     /** @returns {BNote|undefined} - root branch will have undefined parent, all other branches have to have a parent note */ | ||||
|     get parentNote() { | ||||
|         if (!(this.parentNoteId in this.becca.notes) && this.parentNoteId !== 'none') { | ||||
|             // entities can come out of order in sync/import, create skeleton which will be filled later
 | ||||
|             this.becca.addNote(this.parentNoteId, new Note({noteId: this.parentNoteId})); | ||||
|             this.becca.addNote(this.parentNoteId, new BNote({noteId: this.parentNoteId})); | ||||
|         } | ||||
| 
 | ||||
|         return this.becca.notes[this.parentNoteId]; | ||||
| @@ -263,7 +263,7 @@ class Branch extends AbstractEntity { | ||||
|             existingBranch.notePosition = notePosition; | ||||
|             return existingBranch; | ||||
|         } else { | ||||
|             return new Branch({ | ||||
|             return new BBranch({ | ||||
|                 noteId: this.noteId, | ||||
|                 parentNoteId: parentNoteId, | ||||
|                 notePosition: notePosition, | ||||
| @@ -274,4 +274,4 @@ class Branch extends AbstractEntity { | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| module.exports = Branch; | ||||
| module.exports = BBranch; | ||||
| @@ -1,7 +1,7 @@ | ||||
| "use strict"; | ||||
| 
 | ||||
| const dateUtils = require('../../services/date_utils'); | ||||
| const AbstractEntity = require("./abstract_entity"); | ||||
| const AbstractBeccaEntity = require("./abstract_becca_entity"); | ||||
| 
 | ||||
| /** | ||||
|  * EtapiToken is an entity representing token used to authenticate against Trilium REST API from client applications. | ||||
| @@ -12,9 +12,9 @@ const AbstractEntity = require("./abstract_entity"); | ||||
|  * The format user is presented with is "<etapiTokenId>_<tokenHash>". This is also called "authToken" to distinguish it | ||||
|  * from tokenHash and token. | ||||
|  * | ||||
|  * @extends AbstractEntity | ||||
|  * @extends AbstractBeccaEntity | ||||
|  */ | ||||
| class EtapiToken extends AbstractEntity { | ||||
| class BEtapiToken extends AbstractBeccaEntity { | ||||
|     static get entityName() { return "etapi_tokens"; } | ||||
|     static get primaryKeyName() { return "etapiTokenId"; } | ||||
|     static get hashedProperties() { return ["etapiTokenId", "name", "tokenHash", "utcDateCreated", "utcDateModified", "isDeleted"]; } | ||||
| @@ -75,4 +75,4 @@ class EtapiToken extends AbstractEntity { | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| module.exports = EtapiToken; | ||||
| module.exports = BEtapiToken; | ||||
| @@ -6,8 +6,8 @@ const sql = require('../../services/sql'); | ||||
| const utils = require('../../services/utils'); | ||||
| const dateUtils = require('../../services/date_utils'); | ||||
| const entityChangesService = require('../../services/entity_changes'); | ||||
| const AbstractEntity = require("./abstract_entity"); | ||||
| const NoteRevision = require("./note_revision"); | ||||
| const AbstractBeccaEntity = require("./abstract_becca_entity"); | ||||
| const BNoteRevision = require("./bnote_revision"); | ||||
| const TaskContext = require("../../services/task_context"); | ||||
| const dayjs = require("dayjs"); | ||||
| const utc = require('dayjs/plugin/utc'); | ||||
| @@ -19,9 +19,9 @@ const RELATION = 'relation'; | ||||
| /** | ||||
|  * Trilium's main entity which can represent text note, image, code note, file attachment etc. | ||||
|  * | ||||
|  * @extends AbstractEntity | ||||
|  * @extends AbstractBeccaEntity | ||||
|  */ | ||||
| class Note extends AbstractEntity { | ||||
| class BNote extends AbstractBeccaEntity { | ||||
|     static get entityName() { return "notes"; } | ||||
|     static get primaryKeyName() { return "noteId"; } | ||||
|     static get hashedProperties() { return ["noteId", "title", "isProtected", "type", "mime"]; } | ||||
| @@ -92,10 +92,10 @@ class Note extends AbstractEntity { | ||||
|         /** @type {Branch[]} | ||||
|          * @private */ | ||||
|         this.parentBranches = []; | ||||
|         /** @type {Note[]} | ||||
|         /** @type {BNote[]} | ||||
|          * @private */ | ||||
|         this.parents = []; | ||||
|         /** @type {Note[]} | ||||
|         /** @type {BNote[]} | ||||
|          * @private*/ | ||||
|         this.children = []; | ||||
|         /** @type {Attribute[]} | ||||
| @@ -115,7 +115,7 @@ class Note extends AbstractEntity { | ||||
| 
 | ||||
|         this.becca.addNote(this.noteId, this); | ||||
| 
 | ||||
|         /** @type {Note[]|null} | ||||
|         /** @type {BNote[]|null} | ||||
|          * @private */ | ||||
|         this.ancestorCache = null; | ||||
| 
 | ||||
| @@ -173,12 +173,12 @@ class Note extends AbstractEntity { | ||||
|         return this.parentBranches; | ||||
|     } | ||||
| 
 | ||||
|     /** @returns {Note[]} */ | ||||
|     /** @returns {BNote[]} */ | ||||
|     getParentNotes() { | ||||
|         return this.parents; | ||||
|     } | ||||
| 
 | ||||
|     /** @returns {Note[]} */ | ||||
|     /** @returns {BNote[]} */ | ||||
|     getChildNotes() { | ||||
|         return this.children; | ||||
|     } | ||||
| @@ -832,7 +832,7 @@ class Note extends AbstractEntity { | ||||
|         return !!this.targetRelations.find(rel => rel.name === 'template'); | ||||
|     } | ||||
| 
 | ||||
|     /** @returns {Note[]} */ | ||||
|     /** @returns {BNote[]} */ | ||||
|     getSubtreeNotesIncludingTemplated() { | ||||
|         const set = new Set(); | ||||
| 
 | ||||
| @@ -863,7 +863,7 @@ class Note extends AbstractEntity { | ||||
|         return Array.from(set); | ||||
|     } | ||||
| 
 | ||||
|     /** @return {Note[]} */ | ||||
|     /** @return {BNote[]} */ | ||||
|     getSearchResultNotes() { | ||||
|         if (this.type !== 'search') { | ||||
|             return []; | ||||
| @@ -885,7 +885,7 @@ class Note extends AbstractEntity { | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * @returns {{notes: Note[], relationships: Array.<{parentNoteId: string, childNoteId: string}>}} | ||||
|      * @returns {{notes: BNote[], relationships: Array.<{parentNoteId: string, childNoteId: string}>}} | ||||
|      */ | ||||
|     getSubtree({includeArchived = true, includeHidden = false, resolveSearch = false} = {}) { | ||||
|         const noteSet = new Set(); | ||||
| @@ -1005,7 +1005,7 @@ class Note extends AbstractEntity { | ||||
|         return this.getAttributes().length; | ||||
|     } | ||||
| 
 | ||||
|     /** @returns {Note[]} */ | ||||
|     /** @returns {BNote[]} */ | ||||
|     getAncestors() { | ||||
|         if (!this.ancestorCache) { | ||||
|             const noteIds = new Set(); | ||||
| @@ -1050,7 +1050,7 @@ class Note extends AbstractEntity { | ||||
|         return this.targetRelations; | ||||
|     } | ||||
| 
 | ||||
|     /** @returns {Note[]} - returns only notes which are templated, does not include their subtrees | ||||
|     /** @returns {BNote[]} - returns only notes which are templated, does not include their subtrees | ||||
|      *                     in effect returns notes which are influenced by note's non-inheritable attributes */ | ||||
|     getTemplatedNotes() { | ||||
|         const arr = [this]; | ||||
| @@ -1084,7 +1084,7 @@ class Note extends AbstractEntity { | ||||
| 
 | ||||
|     getNoteRevisions() { | ||||
|         return sql.getRows("SELECT * FROM note_revisions WHERE noteId = ?", [this.noteId]) | ||||
|             .map(row => new NoteRevision(row)); | ||||
|             .map(row => new BNoteRevision(row)); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
| @@ -1137,9 +1137,9 @@ class Note extends AbstractEntity { | ||||
|             } | ||||
|         } | ||||
|         else { | ||||
|             const Attribute = require("./attribute"); | ||||
|             const BAttribute = require("./battribute"); | ||||
| 
 | ||||
|             new Attribute({ | ||||
|             new BAttribute({ | ||||
|                 noteId: this.noteId, | ||||
|                 type: type, | ||||
|                 name: name, | ||||
| @@ -1177,7 +1177,7 @@ class Note extends AbstractEntity { | ||||
|      * @return {Attribute} | ||||
|      */ | ||||
|     addAttribute(type, name, value = "", isInheritable = false, position = 1000) { | ||||
|         const Attribute = require("./attribute"); | ||||
|         const BAttribute = require("./battribute"); | ||||
| 
 | ||||
|         return new Attribute({ | ||||
|             noteId: this.noteId, | ||||
| @@ -1359,7 +1359,7 @@ class Note extends AbstractEntity { | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * @return {NoteRevision|null} | ||||
|      * @return {BNoteRevision|null} | ||||
|      */ | ||||
|     saveNoteRevision() { | ||||
|         const content = this.getContent(); | ||||
| @@ -1370,7 +1370,7 @@ class Note extends AbstractEntity { | ||||
| 
 | ||||
|         const contentMetadata = this.getContentMetadata(); | ||||
| 
 | ||||
|         const noteRevision = new NoteRevision({ | ||||
|         const noteRevision = new BNoteRevision({ | ||||
|             noteId: this.noteId, | ||||
|             // title and text should be decrypted now
 | ||||
|             title: this.title, | ||||
| @@ -1434,4 +1434,4 @@ class Note extends AbstractEntity { | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| module.exports = Note; | ||||
| module.exports = BNote; | ||||
| @@ -6,15 +6,15 @@ const sql = require('../../services/sql'); | ||||
| const dateUtils = require('../../services/date_utils'); | ||||
| const becca = require('../becca'); | ||||
| const entityChangesService = require('../../services/entity_changes'); | ||||
| const AbstractEntity = require("./abstract_entity"); | ||||
| const AbstractBeccaEntity = require("./abstract_becca_entity"); | ||||
| 
 | ||||
| /** | ||||
|  * NoteRevision represents snapshot of note's title and content at some point in the past. | ||||
|  * It's used for seamless note versioning. | ||||
|  * | ||||
|  * @extends AbstractEntity | ||||
|  * @extends AbstractBeccaEntity | ||||
|  */ | ||||
| class NoteRevision extends AbstractEntity { | ||||
| class BNoteRevision extends AbstractBeccaEntity { | ||||
|     static get entityName() { return "note_revisions"; } | ||||
|     static get primaryKeyName() { return "noteRevisionId"; } | ||||
|     static get hashedProperties() { return ["noteRevisionId", "noteId", "title", "isProtected", "dateLastEdited", "dateCreated", "utcDateLastEdited", "utcDateCreated", "utcDateModified"]; } | ||||
| @@ -190,4 +190,4 @@ class NoteRevision extends AbstractEntity { | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| module.exports = NoteRevision; | ||||
| module.exports = BNoteRevision; | ||||
| @@ -1,14 +1,14 @@ | ||||
| "use strict"; | ||||
| 
 | ||||
| const dateUtils = require('../../services/date_utils'); | ||||
| const AbstractEntity = require("./abstract_entity"); | ||||
| const AbstractBeccaEntity = require("./abstract_becca_entity"); | ||||
| 
 | ||||
| /** | ||||
|  * Option represents name-value pair, either directly configurable by the user or some system property. | ||||
|  * | ||||
|  * @extends AbstractEntity | ||||
|  * @extends AbstractBeccaEntity | ||||
|  */ | ||||
| class Option extends AbstractEntity { | ||||
| class BOption extends AbstractBeccaEntity { | ||||
|     static get entityName() { return "options"; } | ||||
|     static get primaryKeyName() { return "name"; } | ||||
|     static get hashedProperties() { return ["name", "value"]; } | ||||
| @@ -44,4 +44,4 @@ class Option extends AbstractEntity { | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| module.exports = Option; | ||||
| module.exports = BOption; | ||||
| @@ -1,14 +1,14 @@ | ||||
| "use strict"; | ||||
| 
 | ||||
| const dateUtils = require('../../services/date_utils'); | ||||
| const AbstractEntity = require("./abstract_entity"); | ||||
| const AbstractBeccaEntity = require("./abstract_becca_entity"); | ||||
| 
 | ||||
| /** | ||||
|  * RecentNote represents recently visited note. | ||||
|  * | ||||
|  * @extends AbstractEntity | ||||
|  * @extends AbstractBeccaEntity | ||||
|  */ | ||||
| class RecentNote extends AbstractEntity { | ||||
| class BRecentNote extends AbstractBeccaEntity { | ||||
|     static get entityName() { return "recent_notes"; } | ||||
|     static get primaryKeyName() { return "noteId"; } | ||||
| 
 | ||||
| @@ -32,4 +32,4 @@ class RecentNote extends AbstractEntity { | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| module.exports = RecentNote; | ||||
| module.exports = BRecentNote; | ||||
| @@ -1,21 +1,21 @@ | ||||
| const Note = require('./entities/note'); | ||||
| const NoteRevision = require('./entities/note_revision'); | ||||
| const Branch = require('./entities/branch'); | ||||
| const Attribute = require('./entities/attribute'); | ||||
| const RecentNote = require('./entities/recent_note'); | ||||
| const EtapiToken = require('./entities/etapi_token'); | ||||
| const Option = require('./entities/option'); | ||||
| const BNote = require('./entities/bnote'); | ||||
| const BNoteRevision = require('./entities/bnote_revision'); | ||||
| const BBranch = require('./entities/bbranch'); | ||||
| const BAttribute = require('./entities/battribute'); | ||||
| const BRecentNote = require('./entities/brecent_note'); | ||||
| const BEtapiToken = require('./entities/betapi_token'); | ||||
| const BOption = require('./entities/boption'); | ||||
|  | ||||
| const ENTITY_NAME_TO_ENTITY = { | ||||
|     "attributes": Attribute, | ||||
|     "branches": Branch, | ||||
|     "notes": Note, | ||||
|     "note_contents": Note, | ||||
|     "note_revisions": NoteRevision, | ||||
|     "note_revision_contents": NoteRevision, | ||||
|     "recent_notes": RecentNote, | ||||
|     "etapi_tokens": EtapiToken, | ||||
|     "options": Option | ||||
|     "attributes": BAttribute, | ||||
|     "branches": BBranch, | ||||
|     "notes": BNote, | ||||
|     "note_contents": BNote, | ||||
|     "note_revisions": BNoteRevision, | ||||
|     "note_revision_contents": BNoteRevision, | ||||
|     "recent_notes": BRecentNote, | ||||
|     "etapi_tokens": BEtapiToken, | ||||
|     "options": BOption | ||||
| }; | ||||
|  | ||||
| function getEntityFromEntityName(entityName) { | ||||
|   | ||||
| @@ -40,7 +40,7 @@ function filterUrlValue(value) { | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * @param {Note} note | ||||
|  * @param {BNote} note | ||||
|  */ | ||||
| function buildRewardMap(note) { | ||||
|     // Need to use Map instead of object: https://github.com/zadam/trilium/issues/1895 | ||||
|   | ||||
| @@ -1,7 +1,7 @@ | ||||
| const becca = require("../becca/becca"); | ||||
| const eu = require("./etapi_utils"); | ||||
| const mappers = require("./mappers"); | ||||
| const Branch = require("../becca/entities/branch"); | ||||
| const BBranch = require("../becca/entities/bbranch"); | ||||
| const entityChangesService = require("../services/entity_changes"); | ||||
| const v = require("./validators"); | ||||
|  | ||||
| @@ -37,7 +37,7 @@ function register(router) { | ||||
|             return res.status(200).json(mappers.mapBranchToPojo(existing)); | ||||
|         } else { | ||||
|             try { | ||||
|                 const branch = new Branch(params).save(); | ||||
|                 const branch = new BBranch(params).save(); | ||||
|  | ||||
|                 res.status(201).json(mappers.mapBranchToPojo(branch)); | ||||
|             } catch (e) { | ||||
|   | ||||
| @@ -110,7 +110,7 @@ export default class NoteDetailWidget extends NoteContextAwareWidget { | ||||
|  | ||||
|             const files = [...e.originalEvent.dataTransfer.files]; // chrome has issue that dataTransfer.files empties after async operation | ||||
|  | ||||
|             const importService = await import("../services/import.js"); | ||||
|             const importService = await import("../services/import"); | ||||
|  | ||||
|             importService.uploadFiles(activeNote.noteId, files, { | ||||
|                 safeImport: true, | ||||
|   | ||||
| @@ -3,7 +3,7 @@ | ||||
| const sql = require('../../services/sql'); | ||||
| const log = require('../../services/log'); | ||||
| const attributeService = require('../../services/attributes'); | ||||
| const Attribute = require('../../becca/entities/attribute'); | ||||
| const BAttribute = require('../../becca/entities/battribute'); | ||||
| const becca = require("../../becca/becca"); | ||||
| const ValidationError = require("../../errors/validation_error"); | ||||
| const NotFoundError = require("../../errors/not_found_error"); | ||||
| @@ -53,7 +53,7 @@ function updateNoteAttribute(req) { | ||||
|             return {}; | ||||
|         } | ||||
|  | ||||
|         attribute = new Attribute({ | ||||
|         attribute = new BAttribute({ | ||||
|             noteId: noteId, | ||||
|             name: body.name, | ||||
|             type: body.type | ||||
| @@ -89,7 +89,7 @@ function setNoteAttribute(req) { | ||||
|         const params = {...body}; | ||||
|         params.noteId = noteId; // noteId must be set before calling constructor for proper initialization | ||||
|  | ||||
|         new Attribute(params).save(); | ||||
|         new BAttribute(params).save(); | ||||
|     } | ||||
| } | ||||
|  | ||||
| @@ -97,7 +97,7 @@ function addNoteAttribute(req) { | ||||
|     const noteId = req.params.noteId; | ||||
|     const body = req.body; | ||||
|  | ||||
|     new Attribute({...body, noteId}).save(); | ||||
|     new BAttribute({...body, noteId}).save(); | ||||
| } | ||||
|  | ||||
| function deleteNoteAttribute(req) { | ||||
| @@ -206,7 +206,7 @@ function createRelation(req) { | ||||
|     let attribute = becca.getAttribute(attributeId); | ||||
|  | ||||
|     if (!attribute) { | ||||
|         attribute = new Attribute({ | ||||
|         attribute = new BAttribute({ | ||||
|             noteId: sourceNoteId, | ||||
|             name: name, | ||||
|             type: 'relation', | ||||
|   | ||||
| @@ -10,7 +10,7 @@ const ws = require('../../services/ws'); | ||||
| const log = require('../../services/log'); | ||||
| const utils = require('../../services/utils'); | ||||
| const path = require('path'); | ||||
| const Attribute = require('../../becca/entities/attribute'); | ||||
| const BAttribute = require('../../becca/entities/battribute'); | ||||
| const htmlSanitizer = require('../../services/html_sanitizer'); | ||||
| const {formatAttrForSearch} = require("../../services/attribute_formatter"); | ||||
|  | ||||
| @@ -131,13 +131,13 @@ function processContent(images, note, content) { | ||||
|  | ||||
|             const {note: imageNote, url} = imageService.saveImage(note.noteId, buffer, filename, true); | ||||
|  | ||||
|             new Attribute({ | ||||
|             new BAttribute({ | ||||
|                 noteId: imageNote.noteId, | ||||
|                 type: 'label', | ||||
|                 name: 'archived' | ||||
|             }).save(); // so that these image notes don't show up in search / autocomplete | ||||
|  | ||||
|             new Attribute({ | ||||
|             new BAttribute({ | ||||
|                 noteId: note.noteId, | ||||
|                 type: 'relation', | ||||
|                 name: 'imageLink', | ||||
|   | ||||
| @@ -39,7 +39,7 @@ function getNoteRevision(req) { | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * @param {NoteRevision} noteRevision | ||||
|  * @param {BNoteRevision} noteRevision | ||||
|  * @return {string} | ||||
|  */ | ||||
| function getRevisionFilename(noteRevision) { | ||||
|   | ||||
| @@ -1,11 +1,11 @@ | ||||
| "use strict"; | ||||
|  | ||||
| const RecentNote = require('../../becca/entities/recent_note'); | ||||
| const BRecentNote = require('../../becca/entities/brecent_note'); | ||||
| const sql = require('../../services/sql'); | ||||
| const dateUtils = require('../../services/date_utils'); | ||||
|  | ||||
| function addRecentNote(req) { | ||||
|     new RecentNote({ | ||||
|     new BRecentNote({ | ||||
|         noteId: req.body.noteId, | ||||
|         notePath: req.body.notePath | ||||
|     }).save(); | ||||
|   | ||||
| @@ -5,7 +5,7 @@ const imageService = require('../../services/image'); | ||||
| const dateNoteService = require('../../services/date_notes'); | ||||
| const noteService = require('../../services/notes'); | ||||
| const attributeService = require('../../services/attributes'); | ||||
| const {sanitizeAttributeName} = require("../../services/sanitize_attribute_name.js"); | ||||
| const {sanitizeAttributeName} = require("../../services/sanitize_attribute_name"); | ||||
|  | ||||
| function uploadImage(req) { | ||||
|     const file = req.file; | ||||
|   | ||||
| @@ -12,7 +12,7 @@ const entityChangesService = require('../services/entity_changes'); | ||||
| const csurf = require('csurf'); | ||||
| const {createPartialContentHandler} = require("express-partial-content"); | ||||
| const rateLimit = require("express-rate-limit"); | ||||
| const AbstractEntity = require("../becca/entities/abstract_entity"); | ||||
| const AbstractBeccaEntity = require("../becca/entities/abstract_becca_entity"); | ||||
| const NotFoundError = require("../errors/not_found_error"); | ||||
| const ValidationError = require("../errors/validation_error"); | ||||
|  | ||||
| @@ -319,22 +319,22 @@ function register(app) { | ||||
|  | ||||
| /** Handling common patterns. If entity is not caught, serialization to JSON will fail */ | ||||
| function convertEntitiesToPojo(result) { | ||||
|     if (result instanceof AbstractEntity) { | ||||
|     if (result instanceof AbstractBeccaEntity) { | ||||
|         result = result.getPojo(); | ||||
|     } | ||||
|     else if (Array.isArray(result)) { | ||||
|         for (const idx in result) { | ||||
|             if (result[idx] instanceof AbstractEntity) { | ||||
|             if (result[idx] instanceof AbstractBeccaEntity) { | ||||
|                 result[idx] = result[idx].getPojo(); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|     else { | ||||
|         if (result && result.note instanceof AbstractEntity) { | ||||
|         if (result && result.note instanceof AbstractBeccaEntity) { | ||||
|             result.note = result.note.getPojo(); | ||||
|         } | ||||
|  | ||||
|         if (result && result.branch instanceof AbstractEntity) { | ||||
|         if (result && result.branch instanceof AbstractBeccaEntity) { | ||||
|             result.branch = result.branch.getPojo(); | ||||
|         } | ||||
|     } | ||||
|   | ||||
| @@ -4,7 +4,7 @@ const sqlInit = require('../services/sql_init'); | ||||
| const setupService = require('../services/setup'); | ||||
| const utils = require('../services/utils'); | ||||
| const assetPath = require("../services/asset_path"); | ||||
| const appPath = require("../services/app_path.js"); | ||||
| const appPath = require("../services/app_path"); | ||||
|  | ||||
| function setupPage(req, res) { | ||||
|     if (sqlInit.isDbInitialized()) { | ||||
|   | ||||
| @@ -3,13 +3,13 @@ | ||||
| const searchService = require('./search/services/search'); | ||||
| const sql = require('./sql'); | ||||
| const becca = require('../becca/becca'); | ||||
| const Attribute = require('../becca/entities/attribute'); | ||||
| const BAttribute = require('../becca/entities/battribute'); | ||||
| const {formatAttrForSearch} = require("./attribute_formatter"); | ||||
| const BUILTIN_ATTRIBUTES = require("./builtin_attributes"); | ||||
|  | ||||
| const ATTRIBUTE_TYPES = [ 'label', 'relation' ]; | ||||
|  | ||||
| /** @returns {Note[]} */ | ||||
| /** @returns {BNote[]} */ | ||||
| function getNotesWithLabel(name, value) { | ||||
|     const query = formatAttrForSearch({type: 'label', name, value}, true); | ||||
|     return searchService.searchNotes(query, { | ||||
| @@ -19,7 +19,7 @@ function getNotesWithLabel(name, value) { | ||||
| } | ||||
|  | ||||
| // TODO: should be in search service | ||||
| /** @returns {Note|null} */ | ||||
| /** @returns {BNote|null} */ | ||||
| function getNoteWithLabel(name, value = undefined) { | ||||
|     // optimized version (~20 times faster) without using normal search, useful for e.g. finding date notes | ||||
|     const attrs = becca.findAttributes('label', name); | ||||
| @@ -76,7 +76,7 @@ function createRelation(noteId, name, targetNoteId) { | ||||
| } | ||||
|  | ||||
| function createAttribute(attribute) { | ||||
|     return new Attribute(attribute).save(); | ||||
|     return new BAttribute(attribute).save(); | ||||
| } | ||||
|  | ||||
| function getAttributeNames(type, nameLike) { | ||||
|   | ||||
| @@ -27,9 +27,9 @@ const exportService = require("./export/zip"); | ||||
|  * @hideconstructor | ||||
|  */ | ||||
| function BackendScriptApi(currentNote, apiParams) { | ||||
|     /** @property {Note} note where script started executing */ | ||||
|     /** @property {BNote} note where script started executing */ | ||||
|     this.startNote = apiParams.startNote; | ||||
|     /** @property {Note} note where script is currently executing. Don't mix this up with concept of active note */ | ||||
|     /** @property {BNote} note where script is currently executing. Don't mix this up with concept of active note */ | ||||
|     this.currentNote = currentNote; | ||||
|     /** @property {Entity} entity whose event triggered this executions */ | ||||
|     this.originEntity = apiParams.originEntity; | ||||
| @@ -61,7 +61,7 @@ function BackendScriptApi(currentNote, apiParams) { | ||||
|     /** | ||||
|      * @method | ||||
|      * @param {string} noteId | ||||
|      * @returns {Note|null} | ||||
|      * @returns {BNote|null} | ||||
|      */ | ||||
|     this.getNote = noteId => becca.getNote(noteId); | ||||
|  | ||||
| @@ -86,7 +86,7 @@ function BackendScriptApi(currentNote, apiParams) { | ||||
|      * @method | ||||
|      * @param {string} query | ||||
|      * @param {Object} [searchParams] | ||||
|      * @returns {Note[]} | ||||
|      * @returns {BNote[]} | ||||
|      */ | ||||
|     this.searchForNotes = (query, searchParams = {}) => { | ||||
|         if (searchParams.includeArchivedNotes === undefined) { | ||||
| @@ -110,7 +110,7 @@ function BackendScriptApi(currentNote, apiParams) { | ||||
|      * @method | ||||
|      * @param {string} query | ||||
|      * @param {Object} [searchParams] | ||||
|      * @returns {Note|null} | ||||
|      * @returns {BNote|null} | ||||
|      */ | ||||
|     this.searchForNote = (query, searchParams = {}) => { | ||||
|         const notes = this.searchForNotes(query, searchParams); | ||||
| @@ -124,7 +124,7 @@ function BackendScriptApi(currentNote, apiParams) { | ||||
|      * @method | ||||
|      * @param {string} name - attribute name | ||||
|      * @param {string} [value] - attribute value | ||||
|      * @returns {Note[]} | ||||
|      * @returns {BNote[]} | ||||
|      */ | ||||
|     this.getNotesWithLabel = attributeService.getNotesWithLabel; | ||||
|  | ||||
| @@ -134,7 +134,7 @@ function BackendScriptApi(currentNote, apiParams) { | ||||
|      * @method | ||||
|      * @param {string} name - attribute name | ||||
|      * @param {string} [value] - attribute value | ||||
|      * @returns {Note|null} | ||||
|      * @returns {BNote|null} | ||||
|      */ | ||||
|     this.getNoteWithLabel = attributeService.getNoteWithLabel; | ||||
|  | ||||
| @@ -184,7 +184,7 @@ function BackendScriptApi(currentNote, apiParams) { | ||||
|      * @param {string} parentNoteId | ||||
|      * @param {string} title | ||||
|      * @param {string} content | ||||
|      * @return {{note: Note, branch: Branch}} - object having "note" and "branch" keys representing respective objects | ||||
|      * @return {{note: BNote, branch: Branch}} - object having "note" and "branch" keys representing respective objects | ||||
|      */ | ||||
|     this.createTextNote = (parentNoteId, title, content = '') => noteService.createNewNote({ | ||||
|         parentNoteId, | ||||
| @@ -200,7 +200,7 @@ function BackendScriptApi(currentNote, apiParams) { | ||||
|      * @param {string} parentNoteId | ||||
|      * @param {string} title | ||||
|      * @param {object} content | ||||
|      * @return {{note: Note, branch: Branch}} object having "note" and "branch" keys representing respective objects | ||||
|      * @return {{note: BNote, branch: Branch}} object having "note" and "branch" keys representing respective objects | ||||
|      */ | ||||
|     this.createDataNote = (parentNoteId, title, content = {}) => noteService.createNewNote({ | ||||
|         parentNoteId, | ||||
| @@ -227,7 +227,7 @@ function BackendScriptApi(currentNote, apiParams) { | ||||
|      * @method | ||||
|      * | ||||
|      * @param {CreateNewNoteParams} [params] | ||||
|      * @returns {{note: Note, branch: Branch}} object contains newly created entities note and branch | ||||
|      * @returns {{note: BNote, branch: Branch}} object contains newly created entities note and branch | ||||
|      */ | ||||
|     this.createNewNote = noteService.createNewNote; | ||||
|  | ||||
| @@ -255,7 +255,7 @@ function BackendScriptApi(currentNote, apiParams) { | ||||
|      * @param {string} title | ||||
|      * @param {string} [content=""] | ||||
|      * @param {CreateNoteExtraOptions} [extraOptions={}] | ||||
|      * @returns {{note: Note, branch: Branch}} object contains newly created entities note and branch | ||||
|      * @returns {{note: BNote, branch: Branch}} object contains newly created entities note and branch | ||||
|      */ | ||||
|     this.createNote = (parentNoteId, title, content = "", extraOptions= {}) => { | ||||
|         extraOptions.parentNoteId = parentNoteId; | ||||
| @@ -326,7 +326,7 @@ function BackendScriptApi(currentNote, apiParams) { | ||||
|      * Returns root note of the calendar. | ||||
|      * | ||||
|      * @method | ||||
|      * @returns {Note|null} | ||||
|      * @returns {BNote|null} | ||||
|      */ | ||||
|     this.getRootCalendarNote = dateNoteService.getRootCalendarNote; | ||||
|  | ||||
| @@ -335,8 +335,8 @@ function BackendScriptApi(currentNote, apiParams) { | ||||
|      * | ||||
|      * @method | ||||
|      * @param {string} date in YYYY-MM-DD format | ||||
|      * @param {Note} [rootNote] - specify calendar root note, normally leave empty to use default calendar | ||||
|      * @returns {Note|null} | ||||
|      * @param {BNote} [rootNote] - specify calendar root note, normally leave empty to use default calendar | ||||
|      * @returns {BNote|null} | ||||
|      * @deprecated use getDayNote instead | ||||
|      */ | ||||
|     this.getDateNote = dateNoteService.getDayNote; | ||||
| @@ -346,8 +346,8 @@ function BackendScriptApi(currentNote, apiParams) { | ||||
|      * | ||||
|      * @method | ||||
|      * @param {string} date in YYYY-MM-DD format | ||||
|      * @param {Note} [rootNote] - specify calendar root note, normally leave empty to use default calendar | ||||
|      * @returns {Note|null} | ||||
|      * @param {BNote} [rootNote] - specify calendar root note, normally leave empty to use default calendar | ||||
|      * @returns {BNote|null} | ||||
|      */ | ||||
|     this.getDayNote = dateNoteService.getDayNote; | ||||
|  | ||||
| @@ -355,8 +355,8 @@ function BackendScriptApi(currentNote, apiParams) { | ||||
|      * Returns today's day note. If such note doesn't exist, it is created. | ||||
|      * | ||||
|      * @method | ||||
|      * @param {Note} [rootNote] - specify calendar root note, normally leave empty to use default calendar | ||||
|      * @returns {Note|null} | ||||
|      * @param {BNote} [rootNote] - specify calendar root note, normally leave empty to use default calendar | ||||
|      * @returns {BNote|null} | ||||
|      */ | ||||
|     this.getTodayNote = dateNoteService.getTodayNote; | ||||
|  | ||||
| @@ -366,8 +366,8 @@ function BackendScriptApi(currentNote, apiParams) { | ||||
|      * @method | ||||
|      * @param {string} date in YYYY-MM-DD format | ||||
|      * @param {object} [options] - "startOfTheWeek" - either "monday" (default) or "sunday" | ||||
|      * @param {Note} [rootNote] - specify calendar root note, normally leave empty to use default calendar | ||||
|      * @returns {Note|null} | ||||
|      * @param {BNote} [rootNote] - specify calendar root note, normally leave empty to use default calendar | ||||
|      * @returns {BNote|null} | ||||
|      */ | ||||
|     this.getWeekNote = dateNoteService.getWeekNote; | ||||
|  | ||||
| @@ -376,8 +376,8 @@ function BackendScriptApi(currentNote, apiParams) { | ||||
|      * | ||||
|      * @method | ||||
|      * @param {string} date in YYYY-MM format | ||||
|      * @param {Note} [rootNote] - specify calendar root note, normally leave empty to use default calendar | ||||
|      * @returns {Note|null} | ||||
|      * @param {BNote} [rootNote] - specify calendar root note, normally leave empty to use default calendar | ||||
|      * @returns {BNote|null} | ||||
|      */ | ||||
|     this.getMonthNote = dateNoteService.getMonthNote; | ||||
|  | ||||
| @@ -386,8 +386,8 @@ function BackendScriptApi(currentNote, apiParams) { | ||||
|      * | ||||
|      * @method | ||||
|      * @param {string} year in YYYY format | ||||
|      * @param {Note} [rootNote] - specify calendar root note, normally leave empty to use default calendar | ||||
|      * @returns {Note|null} | ||||
|      * @param {BNote} [rootNote] - specify calendar root note, normally leave empty to use default calendar | ||||
|      * @returns {BNote|null} | ||||
|      */ | ||||
|     this.getYearNote = dateNoteService.getYearNote; | ||||
|  | ||||
|   | ||||
| @@ -3,7 +3,7 @@ | ||||
| const sql = require('./sql'); | ||||
| const eventChangesService = require('./entity_changes'); | ||||
| const treeService = require('./tree'); | ||||
| const Branch = require('../becca/entities/branch'); | ||||
| const BBranch = require('../becca/entities/bbranch'); | ||||
| const becca = require("../becca/becca"); | ||||
| const beccaService = require("../becca/becca_service"); | ||||
| const log = require("./log"); | ||||
| @@ -28,7 +28,7 @@ function cloneNoteToNote(noteId, parentNoteId, prefix) { | ||||
|         return validationResult; | ||||
|     } | ||||
|  | ||||
|     const branch = new Branch({ | ||||
|     const branch = new BBranch({ | ||||
|         noteId: noteId, | ||||
|         parentNoteId: parentNoteId, | ||||
|         prefix: prefix, | ||||
| @@ -78,7 +78,7 @@ function ensureNoteIsPresentInParent(noteId, parentNoteId, prefix) { | ||||
|         return validationResult; | ||||
|     } | ||||
|  | ||||
|     const branch = new Branch({ | ||||
|     const branch = new BBranch({ | ||||
|         noteId: noteId, | ||||
|         parentNoteId: parentNoteId, | ||||
|         prefix: prefix, | ||||
| @@ -162,7 +162,7 @@ function cloneNoteAfter(noteId, afterBranchId) { | ||||
|  | ||||
|     eventChangesService.addNoteReorderingEntityChange(afterNote.parentNoteId); | ||||
|  | ||||
|     const branch = new Branch({ | ||||
|     const branch = new BBranch({ | ||||
|         noteId: noteId, | ||||
|         parentNoteId: afterNote.parentNoteId, | ||||
|         notePosition: afterNote.notePosition + 10, | ||||
|   | ||||
| @@ -8,7 +8,7 @@ const syncMutexService = require('./sync_mutex'); | ||||
| const cls = require('./cls'); | ||||
| const entityChangesService = require('./entity_changes'); | ||||
| const optionsService = require('./options'); | ||||
| const Branch = require('../becca/entities/branch'); | ||||
| const BBranch = require('../becca/entities/bbranch'); | ||||
| const noteRevisionService = require('./note_revisions'); | ||||
| const becca = require("../becca/becca"); | ||||
| const utils = require("../services/utils"); | ||||
| @@ -254,7 +254,7 @@ class ConsistencyChecks { | ||||
|               AND branches.branchId IS NULL | ||||
|         `, ({noteId}) => { | ||||
|             if (this.autoFix) { | ||||
|                 const branch = new Branch({ | ||||
|                 const branch = new BBranch({ | ||||
|                     parentNoteId: 'root', | ||||
|                     noteId: noteId, | ||||
|                     prefix: 'recovered' | ||||
|   | ||||
| @@ -29,7 +29,7 @@ function createNote(parentNote, noteTitle) { | ||||
|     }).note; | ||||
| } | ||||
|  | ||||
| /** @returns {Note} */ | ||||
| /** @returns {BNote} */ | ||||
| function getRootCalendarNote() { | ||||
|     let rootNote; | ||||
|  | ||||
| @@ -62,7 +62,7 @@ function getRootCalendarNote() { | ||||
|     return rootNote; | ||||
| } | ||||
|  | ||||
| /** @returns {Note} */ | ||||
| /** @returns {BNote} */ | ||||
| function getYearNote(dateStr, rootNote = null) { | ||||
|     if (!rootNote) { | ||||
|         rootNote = getRootCalendarNote(); | ||||
| @@ -102,7 +102,7 @@ function getMonthNoteTitle(rootNote, monthNumber, dateObj) { | ||||
|         .replace(/{month}/g, monthName); | ||||
| } | ||||
|  | ||||
| /** @returns {Note} */ | ||||
| /** @returns {BNote} */ | ||||
| function getMonthNote(dateStr, rootNote = null) { | ||||
|     if (!rootNote) { | ||||
|         rootNote = getRootCalendarNote(); | ||||
| @@ -152,7 +152,7 @@ function getDayNoteTitle(rootNote, dayNumber, dateObj) { | ||||
|         .replace(/{weekDay2}/g, weekDay.substr(0, 2)); | ||||
| } | ||||
|  | ||||
| /** @returns {Note} */ | ||||
| /** @returns {BNote} */ | ||||
| function getDayNote(dateStr, rootNote = null) { | ||||
|     if (!rootNote) { | ||||
|         rootNote = getRootCalendarNote(); | ||||
|   | ||||
| @@ -1,6 +1,6 @@ | ||||
| const becca = require("../becca/becca"); | ||||
| const utils = require("./utils"); | ||||
| const EtapiToken = require("../becca/entities/etapi_token"); | ||||
| const BEtapiToken = require("../becca/entities/betapi_token"); | ||||
| const crypto = require("crypto"); | ||||
|  | ||||
| function getTokens() { | ||||
| @@ -15,7 +15,7 @@ function createToken(tokenName) { | ||||
|     const token = utils.randomSecureToken(32); | ||||
|     const tokenHash = getTokenHash(token); | ||||
|  | ||||
|     const etapiToken = new EtapiToken({ | ||||
|     const etapiToken = new BEtapiToken({ | ||||
|         name: tokenName, | ||||
|         tokenHash | ||||
|     }).save(); | ||||
|   | ||||
| @@ -3,7 +3,7 @@ const scriptService = require('./script'); | ||||
| const treeService = require('./tree'); | ||||
| const noteService = require('./notes'); | ||||
| const becca = require('../becca/becca'); | ||||
| const Attribute = require('../becca/entities/attribute'); | ||||
| const BAttribute = require('../becca/entities/battribute'); | ||||
|  | ||||
| function runAttachedRelations(note, relationName, originEntity) { | ||||
|     if (!note) { | ||||
| @@ -177,7 +177,7 @@ eventService.subscribe(eventService.ENTITY_CHANGED, ({ entityName, entity }) => | ||||
|             .some(attr => attr.value === note.noteId); | ||||
|  | ||||
|         if (!hasInverseAttribute) { | ||||
|             new Attribute({ | ||||
|             new BAttribute({ | ||||
|                 noteId: targetNote.noteId, | ||||
|                 type: 'relation', | ||||
|                 name: definition.inverseRelation, | ||||
|   | ||||
| @@ -1,6 +1,6 @@ | ||||
| const becca = require("../becca/becca"); | ||||
| const noteService = require("./notes"); | ||||
| const Attribute = require("../becca/entities/attribute.js"); | ||||
| const BAttribute = require("../becca/entities/battribute"); | ||||
|  | ||||
| const LBTPL_ROOT = "_lbTplRoot"; | ||||
| const LBTPL_BASE = "_lbTplBase"; | ||||
| @@ -317,7 +317,7 @@ function checkHiddenSubtreeRecursively(parentNoteId, item) { | ||||
|         const attrId = note.noteId + "_" + attr.type.charAt(0) + attr.name; | ||||
|  | ||||
|         if (!note.getAttributes().find(attr => attr.attributeId === attrId)) { | ||||
|             new Attribute({ | ||||
|             new BAttribute({ | ||||
|                 attributeId: attrId, | ||||
|                 noteId: note.noteId, | ||||
|                 type: attr.type, | ||||
|   | ||||
| @@ -9,7 +9,7 @@ const imageService = require("../image"); | ||||
| const protectedSessionService = require('../protected_session'); | ||||
| const htmlSanitizer = require("../html_sanitizer"); | ||||
| const attributeService = require("../attributes"); | ||||
| const {sanitizeAttributeName} = require("../sanitize_attribute_name.js"); | ||||
| const {sanitizeAttributeName} = require("../sanitize_attribute_name"); | ||||
|  | ||||
| // date format is e.g. 20181121T193703Z | ||||
| function parseDate(text) { | ||||
|   | ||||
| @@ -8,7 +8,7 @@ const htmlSanitizer = require('../html_sanitizer'); | ||||
| /** | ||||
|  * @param {TaskContext} taskContext | ||||
|  * @param {Buffer} fileBuffer | ||||
|  * @param {Note} parentNote | ||||
|  * @param {BNote} parentNote | ||||
|  * @return {Promise<*[]|*>} | ||||
|  */ | ||||
| async function importOpml(taskContext, fileBuffer, parentNote) { | ||||
|   | ||||
| @@ -1,11 +1,11 @@ | ||||
| "use strict"; | ||||
|  | ||||
| const Attribute = require('../../becca/entities/attribute'); | ||||
| const BAttribute = require('../../becca/entities/battribute'); | ||||
| const utils = require('../../services/utils'); | ||||
| const log = require('../../services/log'); | ||||
| const noteService = require('../../services/notes'); | ||||
| const attributeService = require('../../services/attributes'); | ||||
| const Branch = require('../../becca/entities/branch'); | ||||
| const BBranch = require('../../becca/entities/bbranch'); | ||||
| const path = require('path'); | ||||
| const commonmark = require('commonmark'); | ||||
| const protectedSessionService = require('../protected_session'); | ||||
| @@ -18,7 +18,7 @@ const becca = require("../../becca/becca"); | ||||
| /** | ||||
|  * @param {TaskContext} taskContext | ||||
|  * @param {Buffer} fileBuffer | ||||
|  * @param {Note} importRootNote | ||||
|  * @param {BNote} importRootNote | ||||
|  * @return {Promise<*>} | ||||
|  */ | ||||
| async function importZip(taskContext, fileBuffer, importRootNote) { | ||||
| @@ -369,7 +369,7 @@ async function importZip(taskContext, fileBuffer, importRootNote) { | ||||
|  | ||||
|         if (noteMeta?.isClone) { | ||||
|             if (!becca.getBranchFromChildAndParent(noteId, parentNoteId)) { | ||||
|                 new Branch({ | ||||
|                 new BBranch({ | ||||
|                     noteId, | ||||
|                     parentNoteId, | ||||
|                     isExpanded: noteMeta.isExpanded, | ||||
| @@ -410,7 +410,7 @@ async function importZip(taskContext, fileBuffer, importRootNote) { | ||||
|             note.setContent(content); | ||||
|  | ||||
|             if (!becca.getBranchFromChildAndParent(noteId, parentNoteId)) { | ||||
|                 new Branch({ | ||||
|                 new BBranch({ | ||||
|                     noteId, | ||||
|                     parentNoteId, | ||||
|                     isExpanded: noteMeta.isExpanded, | ||||
| @@ -504,7 +504,7 @@ async function importZip(taskContext, fileBuffer, importRootNote) { | ||||
|     // are already in the database (we don't want to have "broken" relations, not even transitionally) | ||||
|     for (const attr of attributes) { | ||||
|         if (attr.type !== 'relation' || attr.value in becca.notes) { | ||||
|             new Attribute(attr).save(); | ||||
|             new BAttribute(attr).save(); | ||||
|         } | ||||
|         else { | ||||
|             log.info(`Relation not imported since the target note doesn't exist: ${JSON.stringify(attr)}`); | ||||
|   | ||||
| @@ -5,7 +5,7 @@ const sql = require('./sql'); | ||||
| const protectedSession = require("./protected_session"); | ||||
|  | ||||
| /** | ||||
|  * @param {Note} note | ||||
|  * @param {BNote} note | ||||
|  */ | ||||
| function protectNoteRevisions(note) { | ||||
|     for (const revision of note.getNoteRevisions()) { | ||||
|   | ||||
| @@ -14,9 +14,9 @@ const request = require('./request'); | ||||
| const path = require('path'); | ||||
| const url = require('url'); | ||||
| const becca = require('../becca/becca'); | ||||
| const Branch = require('../becca/entities/branch'); | ||||
| const Note = require('../becca/entities/note'); | ||||
| const Attribute = require('../becca/entities/attribute'); | ||||
| const BBranch = require('../becca/entities/bbranch'); | ||||
| const BNote = require('../becca/entities/bnote'); | ||||
| const BAttribute = require('../becca/entities/battribute'); | ||||
| const dayjs = require("dayjs"); | ||||
| const htmlSanitizer = require("./html_sanitizer"); | ||||
| const ValidationError = require("../errors/validation_error"); | ||||
| @@ -54,7 +54,7 @@ function deriveMime(type, mime) { | ||||
| function copyChildAttributes(parentNote, childNote) { | ||||
|     for (const attr of parentNote.getAttributes()) { | ||||
|         if (attr.name.startsWith("child:")) { | ||||
|             new Attribute({ | ||||
|             new BAttribute({ | ||||
|                 noteId: childNote.noteId, | ||||
|                 type: attr.type, | ||||
|                 name: attr.name.substr(6), | ||||
| @@ -130,7 +130,7 @@ function getAndValidateParent(params) { | ||||
|  * - {integer} notePosition - default is last existing notePosition in a parent + 10 | ||||
|  * | ||||
|  * @param params | ||||
|  * @return {{note: Note, branch: Branch}} | ||||
|  * @return {{note: BNote, branch: BBranch}} | ||||
|  */ | ||||
| function createNewNote(params) { | ||||
|     const parentNote = getAndValidateParent(params); | ||||
| @@ -158,7 +158,7 @@ function createNewNote(params) { | ||||
|             // TODO: think about what can happen if the note already exists with the forced ID | ||||
|             //       I guess on DB it's going to be fine, but becca references between entities | ||||
|             //       might get messed up (two Note instance for the same ID existing in the references) | ||||
|             note = new Note({ | ||||
|             note = new BNote({ | ||||
|                 noteId: params.noteId, // optionally can force specific noteId | ||||
|                 title: params.title, | ||||
|                 isProtected: !!params.isProtected, | ||||
| @@ -168,7 +168,7 @@ function createNewNote(params) { | ||||
|  | ||||
|             note.setContent(params.content); | ||||
|  | ||||
|             branch = new Branch({ | ||||
|             branch = new BBranch({ | ||||
|                 noteId: note.noteId, | ||||
|                 parentNoteId: params.parentNoteId, | ||||
|                 notePosition: params.notePosition !== undefined ? params.notePosition : getNewNotePosition(params.parentNoteId), | ||||
| @@ -533,7 +533,7 @@ function saveLinks(note, content) { | ||||
|             && existingLink.name === foundLink.name); | ||||
|  | ||||
|         if (!existingLink) { | ||||
|             const newLink = new Attribute({ | ||||
|             const newLink = new BAttribute({ | ||||
|                 noteId: note.noteId, | ||||
|                 type: 'relation', | ||||
|                 name: foundLink.name, | ||||
| @@ -639,7 +639,7 @@ function undeleteBranch(branchId, deleteId, taskContext) { | ||||
|         return; | ||||
|     } | ||||
|  | ||||
|     new Branch(branch).save(); | ||||
|     new BBranch(branch).save(); | ||||
|  | ||||
|     taskContext.increaseProgressCount(); | ||||
|  | ||||
| @@ -657,7 +657,7 @@ function undeleteBranch(branchId, deleteId, taskContext) { | ||||
|                            OR (type = 'relation' AND value = ?))`, [deleteId, note.noteId, note.noteId]); | ||||
|  | ||||
|         for (const attribute of attributes) { | ||||
|             new Attribute(attribute).save(); | ||||
|             new BAttribute(attribute).save(); | ||||
|         } | ||||
|  | ||||
|         const childBranchIds = sql.getColumn(` | ||||
| @@ -860,7 +860,7 @@ function duplicateSubtreeInner(origNote, origBranch, newParentNoteId, noteIdMapp | ||||
|     const newNoteId = noteIdMapping[origNote.noteId]; | ||||
|  | ||||
|     function createDuplicatedBranch() { | ||||
|         return new Branch({ | ||||
|         return new BBranch({ | ||||
|             noteId: newNoteId, | ||||
|             parentNoteId: newParentNoteId, | ||||
|             // here increasing just by 1 to make sure it's directly after original | ||||
| @@ -869,7 +869,7 @@ function duplicateSubtreeInner(origNote, origBranch, newParentNoteId, noteIdMapp | ||||
|     } | ||||
|  | ||||
|     function createDuplicatedNote() { | ||||
|         const newNote = new Note({ | ||||
|         const newNote = new BNote({ | ||||
|             ...origNote, | ||||
|             noteId: newNoteId, | ||||
|             dateCreated: dateUtils.localNowDateTime(), | ||||
| @@ -886,7 +886,7 @@ function duplicateSubtreeInner(origNote, origBranch, newParentNoteId, noteIdMapp | ||||
|         newNote.setContent(content); | ||||
|  | ||||
|         for (const attribute of origNote.getOwnedAttributes()) { | ||||
|             const attr = new Attribute({ | ||||
|             const attr = new BAttribute({ | ||||
|                 ...attribute, | ||||
|                 attributeId: undefined, | ||||
|                 noteId: newNote.noteId | ||||
|   | ||||
| @@ -71,9 +71,9 @@ function setOption(name, value) { | ||||
|  | ||||
| function createOption(name, value, isSynced) { | ||||
|     // to avoid circular dependency, need to find better solution | ||||
|     const Option = require('../becca/entities/option'); | ||||
|     const BOption = require('../becca/entities/boption'); | ||||
|  | ||||
|     new Option({ | ||||
|     new BOption({ | ||||
|         name: name, | ||||
|         value: value, | ||||
|         isSynced: isSynced | ||||
|   | ||||
| @@ -7,7 +7,7 @@ const sql = require("./sql"); | ||||
| const becca = require("../becca/becca"); | ||||
| const protectedSessionService = require("../services/protected_session"); | ||||
| const hiddenSubtreeService = require("./hidden_subtree"); | ||||
| const helpImportService = require("./user_guide_import.js"); | ||||
| const helpImportService = require("./user_guide_import"); | ||||
|  | ||||
| function getRunAtHours(note) { | ||||
|     try { | ||||
|   | ||||
| @@ -123,7 +123,7 @@ class NoteFlatTextExp extends Expression { | ||||
|      * Returns noteIds which have at least one matching tokens | ||||
|      * | ||||
|      * @param {NoteSet} noteSet | ||||
|      * @return {Note[]} | ||||
|      * @return {BNote[]} | ||||
|      */ | ||||
|     getCandidateNotes(noteSet) { | ||||
|         const candidateNotes = []; | ||||
|   | ||||
| @@ -2,7 +2,7 @@ | ||||
|  | ||||
| class NoteSet { | ||||
|     constructor(notes = []) { | ||||
|         /** @type {Note[]} */ | ||||
|         /** @type {BNote[]} */ | ||||
|         this.notes = notes; | ||||
|         this.noteIdSet = new Set(notes.map(note => note.noteId)); | ||||
|         /** @type {boolean} */ | ||||
|   | ||||
| @@ -18,7 +18,7 @@ const AncestorExp = require("../expressions/ancestor"); | ||||
| const buildComparator = require('./build_comparator'); | ||||
| const ValueExtractor = require('../value_extractor'); | ||||
| const utils = require("../../utils"); | ||||
| const TrueExp = require("../expressions/true.js"); | ||||
| const TrueExp = require("../expressions/true"); | ||||
|  | ||||
| function getFulltext(tokens, searchContext) { | ||||
|     tokens = tokens.map(t => utils.removeDiacritic(t.token)); | ||||
|   | ||||
| @@ -230,7 +230,7 @@ function parseQueryToExpression(query, searchContext) { | ||||
|  | ||||
| /** | ||||
|  * @param {string} query | ||||
|  * @return {Note[]} | ||||
|  * @return {BNote[]} | ||||
|  */ | ||||
| function searchNotes(query, params = {}) { | ||||
|     const searchResults = findResultsWithQuery(query, new SearchContext(params)); | ||||
| @@ -259,7 +259,7 @@ function findResultsWithQuery(query, searchContext) { | ||||
| /** | ||||
|  * @param {string} query | ||||
|  * @param {SearchContext} searchContext | ||||
|  * @return {Note|null} | ||||
|  * @return {BNote|null} | ||||
|  */ | ||||
| function findFirstNoteWithQuery(query, searchContext) { | ||||
|     const searchResults = findResultsWithQuery(query, searchContext); | ||||
|   | ||||
| @@ -5,7 +5,7 @@ const sql = require('./sql'); | ||||
| const utils = require('./utils'); | ||||
| const optionService = require('./options'); | ||||
| const port = require('./port'); | ||||
| const Option = require('../becca/entities/option'); | ||||
| const BOption = require('../becca/entities/boption'); | ||||
| const TaskContext = require('./task_context'); | ||||
| const migrationService = require('./migration'); | ||||
| const cls = require('./cls'); | ||||
| @@ -62,12 +62,12 @@ async function createInitialDatabase() { | ||||
|  | ||||
|         require("../becca/becca_loader").load(); | ||||
|  | ||||
|         const Note = require("../becca/entities/note"); | ||||
|         const Branch = require("../becca/entities/branch"); | ||||
|         const BNote = require("../becca/entities/bnote"); | ||||
|         const BBranch = require("../becca/entities/bbranch"); | ||||
|  | ||||
|         log.info("Creating root note ..."); | ||||
|  | ||||
|         rootNote = new Note({ | ||||
|         rootNote = new BNote({ | ||||
|             noteId: 'root', | ||||
|             title: 'root', | ||||
|             type: 'text', | ||||
| @@ -76,7 +76,7 @@ async function createInitialDatabase() { | ||||
|  | ||||
|         rootNote.setContent(''); | ||||
|  | ||||
|         new Branch({ | ||||
|         new BBranch({ | ||||
|             noteId: 'root', | ||||
|             parentNoteId: 'none', | ||||
|             isExpanded: true, | ||||
| @@ -135,7 +135,7 @@ function createDatabaseForSync(options, syncServerHost = '', syncProxy = '') { | ||||
|  | ||||
|         // document options required for sync to kick off | ||||
|         for (const opt of options) { | ||||
|             new Option(opt).save(); | ||||
|             new BOption(opt).save(); | ||||
|         } | ||||
|     }); | ||||
|  | ||||
|   | ||||
| @@ -2,7 +2,7 @@ | ||||
|  | ||||
| const sql = require('./sql'); | ||||
| const log = require('./log'); | ||||
| const Branch = require('../becca/entities/branch'); | ||||
| const BBranch = require('../becca/entities/bbranch'); | ||||
| const entityChangesService = require('./entity_changes'); | ||||
| const protectedSessionService = require('./protected_session'); | ||||
| const becca = require('../becca/becca'); | ||||
| @@ -270,7 +270,7 @@ function setNoteToParent(noteId, prefix, parentNoteId) { | ||||
|             branch.save(); | ||||
|         } | ||||
|         else { | ||||
|             new Branch({ | ||||
|             new BBranch({ | ||||
|                 noteId: noteId, | ||||
|                 parentNoteId: parentNoteId, | ||||
|                 prefix: prefix | ||||
|   | ||||
| @@ -2,12 +2,12 @@ | ||||
|  | ||||
| const becca = require("../becca/becca"); | ||||
| const fs = require("fs").promises; | ||||
| const Attribute = require('../becca/entities/attribute'); | ||||
| const BAttribute = require('../becca/entities/battribute'); | ||||
| const utils = require('./utils'); | ||||
| const log = require('./log'); | ||||
| const noteService = require('./notes'); | ||||
| const attributeService = require('./attributes'); | ||||
| const Branch = require('../becca/entities/branch'); | ||||
| const BBranch = require('../becca/entities/bbranch'); | ||||
| const path = require('path'); | ||||
| const yauzl = require("yauzl"); | ||||
| const htmlSanitizer = require('./html_sanitizer'); | ||||
| @@ -305,7 +305,7 @@ async function importZip(fileBuffer, importRootNote) { | ||||
|  | ||||
|         if (noteMeta?.isClone) { | ||||
|             if (!becca.getBranchFromChildAndParent(noteId, parentNoteId)) { | ||||
|                 new Branch({ | ||||
|                 new BBranch({ | ||||
|                     noteId, | ||||
|                     parentNoteId, | ||||
|                     isExpanded: noteMeta.isExpanded, | ||||
| @@ -341,7 +341,7 @@ async function importZip(fileBuffer, importRootNote) { | ||||
|             note.setContent(content); | ||||
|  | ||||
|             if (!becca.getBranchFromChildAndParent(noteId, parentNoteId)) { | ||||
|                 new Branch({ | ||||
|                 new BBranch({ | ||||
|                     noteId, | ||||
|                     parentNoteId, | ||||
|                     isExpanded: noteMeta.isExpanded, | ||||
| @@ -415,7 +415,7 @@ async function importZip(fileBuffer, importRootNote) { | ||||
|     // are already in the database (we don't want to have "broken" relations, not even transitionally) | ||||
|     for (const attr of attributes) { | ||||
|         if (attr.type !== 'relation' || attr.value in becca.notes) { | ||||
|             new Attribute(attr).save(); | ||||
|             new BAttribute(attr).save(); | ||||
|         } | ||||
|         else { | ||||
|             log.info(`Relation not imported since the target note doesn't exist: ${JSON.stringify(attr)}`); | ||||
|   | ||||
| @@ -7,7 +7,7 @@ const config = require('./config'); | ||||
| const syncMutexService = require('./sync_mutex'); | ||||
| const protectedSessionService = require('./protected_session'); | ||||
| const becca = require("../becca/becca"); | ||||
| const AbstractEntity = require("../becca/entities/abstract_entity"); | ||||
| const AbstractBeccaEntity = require("../becca/entities/abstract_becca_entity"); | ||||
|  | ||||
| let webSocketServer; | ||||
| let lastSyncedPush = null; | ||||
| @@ -138,7 +138,7 @@ function fillInAdditionalProperties(entityChange) { | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     if (entityChange.entity instanceof AbstractEntity) { | ||||
|     if (entityChange.entity instanceof AbstractBeccaEntity) { | ||||
|         entityChange.entity = entityChange.entity.getPojo(); | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -1,6 +1,6 @@ | ||||
| "use strict"; | ||||
|  | ||||
| const AbstractShacaEntity = require('./abstract_shaca_entity.js'); | ||||
| const AbstractShacaEntity = require('./abstract_shaca_entity'); | ||||
|  | ||||
| class SAttribute extends AbstractShacaEntity { | ||||
|     constructor([attributeId, noteId, type, name, value, isInheritable, position]) { | ||||
|   | ||||
| @@ -1,6 +1,6 @@ | ||||
| "use strict"; | ||||
|  | ||||
| const AbstractShacaEntity = require('./abstract_shaca_entity.js'); | ||||
| const AbstractShacaEntity = require('./abstract_shaca_entity'); | ||||
|  | ||||
| class SBranch extends AbstractShacaEntity { | ||||
|     constructor([branchId, noteId, parentNoteId, prefix, isExpanded]) { | ||||
|   | ||||
| @@ -2,7 +2,7 @@ | ||||
|  | ||||
| const sql = require('../../sql'); | ||||
| const utils = require('../../../services/utils'); | ||||
| const AbstractShacaEntity = require('./abstract_shaca_entity.js'); | ||||
| const AbstractShacaEntity = require('./abstract_shaca_entity'); | ||||
| const escape = require('escape-html'); | ||||
|  | ||||
| const LABEL = 'label'; | ||||
|   | ||||
| @@ -3,9 +3,9 @@ | ||||
| const sql = require('../sql'); | ||||
| const shaca = require('./shaca'); | ||||
| const log = require('../../services/log'); | ||||
| const SNote = require('./entities/snote.js'); | ||||
| const SBranch = require('./entities/sbranch.js'); | ||||
| const SAttribute = require('./entities/sattribute.js'); | ||||
| const SNote = require('./entities/snote'); | ||||
| const SBranch = require('./entities/sbranch'); | ||||
| const SAttribute = require('./entities/sattribute'); | ||||
| const shareRoot = require('../share_root'); | ||||
| const eventService = require("../../services/events"); | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user