mirror of
https://github.com/zadam/trilium.git
synced 2025-11-17 18:50:41 +01:00
server-ts: Port share/routes
This commit is contained in:
@@ -8,10 +8,10 @@ import { Blob } from '../../../services/blob-interface';
|
||||
|
||||
class SAttachment extends AbstractShacaEntity {
|
||||
private attachmentId: string;
|
||||
private ownerId: string;
|
||||
ownerId: string;
|
||||
title: string;
|
||||
role: string;
|
||||
private mime: string;
|
||||
mime: string;
|
||||
private blobId: string;
|
||||
/** used for caching of images */
|
||||
private utcDateModified: string;
|
||||
|
||||
@@ -7,7 +7,7 @@ class SBranch extends AbstractShacaEntity {
|
||||
|
||||
private branchId: string;
|
||||
private noteId: string;
|
||||
private parentNoteId: string;
|
||||
parentNoteId: string;
|
||||
private prefix: string;
|
||||
private isExpanded: boolean;
|
||||
isHidden: boolean;
|
||||
|
||||
@@ -17,7 +17,7 @@ const isCredentials = (attr: SAttribute) => attr.type === 'label' && attr.name =
|
||||
|
||||
class SNote extends AbstractShacaEntity {
|
||||
noteId: string;
|
||||
private title: string;
|
||||
title: string;
|
||||
type: string;
|
||||
mime: string;
|
||||
private blobId: string;
|
||||
@@ -223,6 +223,29 @@ class SNote extends AbstractShacaEntity {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Error in case of invalid JSON
|
||||
*/
|
||||
getJsonContent(): any | null {
|
||||
const content = this.getContent();
|
||||
|
||||
if (typeof content !== "string" || !content || !content.trim()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return JSON.parse(content);
|
||||
}
|
||||
|
||||
/** @returns valid object or null if the content cannot be parsed as JSON */
|
||||
getJsonContentSafely() {
|
||||
try {
|
||||
return this.getJsonContent();
|
||||
}
|
||||
catch (e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
hasAttribute(type: string, name: string) {
|
||||
return !!this.getAttributes().find(attr => attr.type === type && attr.name === name);
|
||||
}
|
||||
|
||||
@@ -10,10 +10,10 @@ export default class Shaca {
|
||||
childParentToBranch!: Record<string, SBranch>;
|
||||
private attributes!: Record<string, SAttribute>;
|
||||
attachments!: Record<string, SAttachment>;
|
||||
private aliasToNote!: Record<string, SNote>;
|
||||
private shareRootNote!: SNote | null;
|
||||
aliasToNote!: Record<string, SNote>;
|
||||
shareRootNote!: SNote | null;
|
||||
/** true if the index of all shared subtrees is enabled */
|
||||
private shareIndexEnabled!: boolean;
|
||||
shareIndexEnabled!: boolean;
|
||||
loaded!: boolean;
|
||||
|
||||
constructor() {
|
||||
|
||||
Reference in New Issue
Block a user