mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
server-ts: Fix most errors in bnote
This commit is contained in:
parent
f9ba8ca87d
commit
9aec3390dd
@ -31,9 +31,9 @@ abstract class AbstractBeccaEntity<T extends AbstractBeccaEntity<T>> {
|
||||
|
||||
protected utcDateCreated?: string;
|
||||
protected utcDateModified?: string;
|
||||
protected dateCreated?: string;
|
||||
protected dateModified?: string;
|
||||
protected isProtected?: boolean;
|
||||
protected isDeleted?: boolean;
|
||||
protected isSynced?: boolean;
|
||||
|
||||
protected blobId?: string;
|
||||
@ -92,6 +92,8 @@ abstract class AbstractBeccaEntity<T extends AbstractBeccaEntity<T>> {
|
||||
|
||||
abstract getPojo(): {};
|
||||
|
||||
abstract get isDeleted(): boolean;
|
||||
|
||||
/**
|
||||
* Saves entity - executes SQL, but doesn't commit the transaction on its own
|
||||
*/
|
||||
|
@ -7,25 +7,28 @@ import sql = require('../../services/sql');
|
||||
import protectedSessionService = require('../../services/protected_session');
|
||||
import log = require('../../services/log');
|
||||
import { AttachmentRow } from './rows';
|
||||
import BNote = require('./bnote');
|
||||
import BBranch = require('./bbranch');
|
||||
|
||||
const attachmentRoleToNoteTypeMapping = {
|
||||
'image': 'image'
|
||||
};
|
||||
|
||||
interface ContentOpts {
|
||||
// FIXME: Found in bnote.ts, to check if it's actually used and not a typo.
|
||||
forceSave?: boolean;
|
||||
|
||||
/** will also save this BAttachment entity */
|
||||
forceFullSave: boolean;
|
||||
forceFullSave?: boolean;
|
||||
/** override frontend heuristics on when to reload, instruct to reload */
|
||||
forceFrontendReload: boolean;
|
||||
forceFrontendReload?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Attachment represent data related/attached to the note. Conceptually similar to attributes, but intended for
|
||||
* larger amounts of data and generally not accessible to the user.
|
||||
*
|
||||
* @extends AbstractBeccaEntity
|
||||
*/
|
||||
class BAttachment extends AbstractBeccaEntity {
|
||||
class BAttachment extends AbstractBeccaEntity<BAttachment> {
|
||||
static get entityName() { return "attachments"; }
|
||||
static get primaryKeyName() { return "attachmentId"; }
|
||||
static get hashedProperties() { return ["attachmentId", "ownerId", "role", "mime", "title", "blobId", "utcDateScheduledForErasureSince"]; }
|
||||
@ -39,7 +42,7 @@ class BAttachment extends AbstractBeccaEntity {
|
||||
title: string;
|
||||
type?: keyof typeof attachmentRoleToNoteTypeMapping;
|
||||
position?: number;
|
||||
blobId: string;
|
||||
blobId?: string;
|
||||
isProtected?: boolean;
|
||||
dateModified?: string;
|
||||
utcDateScheduledForErasureSince?: string;
|
||||
|
@ -10,10 +10,8 @@ import { AttributeRow, AttributeType } from './rows.js';
|
||||
/**
|
||||
* Attribute is an abstract concept which has two real uses - label (key - value pair)
|
||||
* and relation (representing named relationship between source and target note)
|
||||
*
|
||||
* @extends AbstractBeccaEntity
|
||||
*/
|
||||
class BAttribute extends AbstractBeccaEntity {
|
||||
class BAttribute extends AbstractBeccaEntity<BAttribute> {
|
||||
static get entityName() { return "attributes"; }
|
||||
static get primaryKeyName() { return "attributeId"; }
|
||||
static get hashedProperties() { return ["attributeId", "noteId", "type", "name", "value", "isInheritable"]; }
|
||||
|
@ -15,10 +15,8 @@ import { BranchRow } from './rows.js';
|
||||
*
|
||||
* Note that you should not rely on the branch's identity, since it can change easily with a note's move.
|
||||
* Always check noteId instead.
|
||||
*
|
||||
* @extends AbstractBeccaEntity
|
||||
*/
|
||||
class BBranch extends AbstractBeccaEntity {
|
||||
class BBranch extends AbstractBeccaEntity<BBranch> {
|
||||
static get entityName() { return "branches"; }
|
||||
static get primaryKeyName() { return "branchId"; }
|
||||
// notePosition is not part of hash because it would produce a lot of updates in case of reordering
|
||||
@ -27,7 +25,7 @@ class BBranch extends AbstractBeccaEntity {
|
||||
branchId?: string;
|
||||
noteId!: string;
|
||||
parentNoteId!: string;
|
||||
prefix!: string;
|
||||
prefix!: string | null;
|
||||
notePosition!: number;
|
||||
isExpanded!: boolean;
|
||||
utcDateModified?: string;
|
||||
|
@ -2,8 +2,8 @@
|
||||
|
||||
import { EtapiTokenRow } from "./rows";
|
||||
|
||||
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');
|
||||
|
||||
/**
|
||||
* EtapiToken is an entity representing token used to authenticate against Trilium REST API from client applications.
|
||||
@ -13,10 +13,8 @@ const AbstractBeccaEntity = require('./abstract_becca_entity.js');
|
||||
*
|
||||
* The format user is presented with is "<etapiTokenId>_<tokenHash>". This is also called "authToken" to distinguish it
|
||||
* from tokenHash and token.
|
||||
*
|
||||
* @extends AbstractBeccaEntity
|
||||
*/
|
||||
class BEtapiToken extends AbstractBeccaEntity {
|
||||
class BEtapiToken extends AbstractBeccaEntity<BEtapiToken> {
|
||||
static get entityName() { return "etapi_tokens"; }
|
||||
static get primaryKeyName() { return "etapiTokenId"; }
|
||||
static get hashedProperties() { return ["etapiTokenId", "name", "tokenHash", "utcDateCreated", "utcDateModified", "isDeleted"]; }
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -11,7 +11,7 @@ import { AttachmentRow, RevisionRow } from './rows';
|
||||
|
||||
interface ContentOpts {
|
||||
/** will also save this BRevision entity */
|
||||
forceSave: boolean;
|
||||
forceSave?: boolean;
|
||||
}
|
||||
|
||||
interface GetByIdOpts {
|
||||
@ -22,7 +22,7 @@ interface GetByIdOpts {
|
||||
* Revision represents a snapshot of note's title and content at some point in the past.
|
||||
* It's used for seamless note versioning.
|
||||
*/
|
||||
class BRevision extends AbstractBeccaEntity {
|
||||
class BRevision extends AbstractBeccaEntity<BRevision> {
|
||||
static get entityName() { return "revisions"; }
|
||||
static get primaryKeyName() { return "revisionId"; }
|
||||
static get hashedProperties() { return ["revisionId", "noteId", "title", "isProtected", "dateLastEdited", "dateCreated",
|
||||
@ -113,7 +113,7 @@ class BRevision extends AbstractBeccaEntity {
|
||||
}
|
||||
}
|
||||
|
||||
setContent(content: any, opts: ContentOpts) {
|
||||
setContent(content: any, opts: ContentOpts = {}) {
|
||||
this._setContent(content, opts);
|
||||
}
|
||||
|
||||
@ -200,4 +200,4 @@ class BRevision extends AbstractBeccaEntity {
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = BRevision;
|
||||
export = BRevision;
|
||||
|
@ -2,30 +2,31 @@
|
||||
|
||||
export interface AttachmentRow {
|
||||
attachmentId?: string;
|
||||
ownerId: string;
|
||||
ownerId?: string;
|
||||
role: string;
|
||||
mime: string;
|
||||
title?: string;
|
||||
position?: number;
|
||||
blobId: string;
|
||||
blobId?: string;
|
||||
isProtected?: boolean;
|
||||
dateModified?: string;
|
||||
utcDateModified?: string;
|
||||
utcDateScheduledForErasureSince?: string;
|
||||
contentLength?: number;
|
||||
content?: string;
|
||||
}
|
||||
|
||||
export interface RevisionRow {
|
||||
revisionId: string;
|
||||
revisionId?: string;
|
||||
noteId: string;
|
||||
type: string;
|
||||
mime: string;
|
||||
isProtected: boolean;
|
||||
isProtected?: boolean;
|
||||
title: string;
|
||||
blobId: string;
|
||||
dateLastEdited: string;
|
||||
blobId?: string;
|
||||
dateLastEdited?: string;
|
||||
dateCreated: string;
|
||||
utcDateLastEdited: string;
|
||||
utcDateLastEdited?: string;
|
||||
utcDateCreated: string;
|
||||
utcDateModified: string;
|
||||
contentLength?: number;
|
||||
@ -71,7 +72,7 @@ export interface AttributeRow {
|
||||
position: number;
|
||||
value: string;
|
||||
isInheritable: boolean;
|
||||
utcDateModified: string;
|
||||
utcDateModified?: string;
|
||||
}
|
||||
|
||||
export interface BranchRow {
|
||||
@ -82,4 +83,24 @@ export interface BranchRow {
|
||||
notePosition: number;
|
||||
isExpanded: boolean;
|
||||
utcDateModified?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* There are many different Note types, some of which are entirely opaque to the
|
||||
* end user. Those types should be used only for checking against, they are
|
||||
* not for direct use.
|
||||
*/
|
||||
export type NoteType = ("file" | "image" | "search" | "noteMap" | "launcher" | "doc" | "contentWidget" | "text" | "relationMap" | "render" | "canvas" | "mermaid" | "book" | "webView" | "code");
|
||||
|
||||
export interface NoteRow {
|
||||
noteId: string;
|
||||
title: string;
|
||||
type: NoteType;
|
||||
mime: string;
|
||||
isProtected: boolean;
|
||||
blobId: string;
|
||||
dateCreated: string;
|
||||
dateModified: string;
|
||||
utcDateCreated: string;
|
||||
utcDateModified: string;
|
||||
}
|
@ -10,10 +10,10 @@ class TaskContext {
|
||||
private taskId: string;
|
||||
private taskType: string | null;
|
||||
private data: {} | null;
|
||||
private noteDeletionHandlerTriggered: boolean;
|
||||
private progressCount: number;
|
||||
private lastSentCountTs: number;
|
||||
|
||||
noteDeletionHandlerTriggered: boolean;
|
||||
|
||||
constructor(taskId: string, taskType: string | null = null, data: {} | null = {}) {
|
||||
this.taskId = taskId;
|
||||
this.taskType = taskType;
|
||||
|
@ -12,7 +12,7 @@ function newEntityId() {
|
||||
return randomString(12);
|
||||
}
|
||||
|
||||
function randomString(length: number) {
|
||||
function randomString(length: number): string {
|
||||
return randtoken.generate(length);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user