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