Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
server-ts: Port boption
Elian Doran768aaf2d7835
diff --git a/src/becca/becca-interface.ts b/src/becca/becca-interface.tsindex 294442cbbb..312f6be18a 100644--- a/src/becca/becca-interface.ts+++ b/src/becca/becca-interface.ts@@ -1,6 +1,8 @@import sql = require('../services/sql');import NoteSet = require('../services/search/note_set');import NotFoundError = require('../errors/not_found_error');+import BOption = require('./entities/boption');+import BNote = require('./entities/bnote');/*** Becca is a backend cache of all notes, branches, and attributes.@@ -8,6 +10,7 @@ import NotFoundError = require('../errors/not_found_error');*/class Becca {notes!: Record<string, BNote>;+ options!: Record<string, BOption>;constructor() {this.reset();@@ -24,7 +27,6 @@ class Becca {this.attributes = {};/** @type {Object.<String, BAttribute[]>} Points from attribute type-name to list of attributes */this.attributeIndex = {};- /** @type {Object.<String, BOption>} */this.options = {};/** @type {Object.<String, BEtapiToken>} */this.etapiTokens = {};diff --git a/src/becca/entities/bnote.ts b/src/becca/entities/bnote.tsindex 5cfded718e..f72a83916d 100644--- a/src/becca/entities/bnote.ts+++ b/src/becca/entities/bnote.ts@@ -1725,4 +1725,4 @@ class BNote extends AbstractBeccaEntity {}}-module.exports = BNote;+export = BNote;diff --git a/src/becca/entities/boption.js b/src/becca/entities/boption.tssimilarity index 72%rename from src/becca/entities/boption.jsrename to src/becca/entities/boption.tsindex 7fa121ccc3..ebfd951d13 100644--- a/src/becca/entities/boption.js+++ b/src/becca/entities/boption.ts@@ -1,33 +1,33 @@"use strict";-const dateUtils = require('../../services/date_utils');-const AbstractBeccaEntity = require('./abstract_becca_entity.js');+import dateUtils = require('../../services/date_utils');+import AbstractBeccaEntity = require('./abstract_becca_entity.js');+import { OptionRow } from './rows';/*** Option represents a name-value pair, either directly configurable by the user or some system property.- *- * @extends AbstractBeccaEntity*/class BOption extends AbstractBeccaEntity {static get entityName() { return "options"; }static get primaryKeyName() { return "name"; }static get hashedProperties() { return ["name", "value"]; }- constructor(row) {+ name!: string;+ value!: string;+ isSynced!: boolean;+ utcDateModified!: string;++ constructor(row: OptionRow) {super();this.updateFromRow(row);this.becca.options[this.name] = this;}- updateFromRow(row) {- /** @type {string} */+ updateFromRow(row: OptionRow) {this.name = row.name;- /** @type {string} */this.value = row.value;- /** @type {boolean} */this.isSynced = !!row.isSynced;- /** @type {string} */this.utcDateModified = row.utcDateModified;}@@ -47,4 +47,4 @@ class BOption extends AbstractBeccaEntity {}}-module.exports = BOption;+export = BOption;diff --git a/src/becca/entities/rows.ts b/src/becca/entities/rows.tsindex 5793ee7ab4..2f583d092d 100644--- a/src/becca/entities/rows.ts+++ b/src/becca/entities/rows.ts@@ -1,3 +1,5 @@+// FIXME: Booleans should probably be numbers instead (as SQLite does not have booleans.);+export interface AttachmentRow {attachmentId?: string;ownerId: string;@@ -34,3 +36,10 @@ export interface RecentNoteRow {notePath: string;utcDateCreated?: string;}++export interface OptionRow {+ name: string;+ value: string;+ isSynced: boolean;+ utcDateModified: string;+}\ No newline at end of file