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: Convert blob.js
Elian Dorancb14d4d8f9d7
diff --git a/src/services/blob.js b/src/services/blob.tssimilarity index 74%rename from src/services/blob.jsrename to src/services/blob.tsindex 9b2cfa6ddb..85917f9bb3 100644--- a/src/services/blob.js+++ b/src/services/blob.ts@@ -1,9 +1,9 @@-const becca = require('../becca/becca.js');-const NotFoundError = require('../errors/not_found_error.js');-const protectedSessionService = require('./protected_session.js');-const utils = require('./utils');+import becca = require('../becca/becca.js');+import NotFoundError = require('../errors/not_found_error');+import protectedSessionService = require('./protected_session');+import utils = require('./utils');-function getBlobPojo(entityName, entityId) {+function getBlobPojo(entityName: string, entityId: string) {const entity = becca.getEntity(entityName, entityId);if (!entity) {throw new NotFoundError(`Entity ${entityName} '${entityId}' was not found.`);@@ -25,7 +25,7 @@ function getBlobPojo(entityName, entityId) {return pojo;}-function processContent(content, isProtected, isStringContent) {+function processContent(content: Buffer | string | null, isProtected: boolean, isStringContent: boolean) {if (isProtected) {if (protectedSessionService.isProtectedSessionAvailable()) {content = content === null ? null : protectedSessionService.decrypt(content);@@ -48,7 +48,7 @@ function processContent(content, isProtected, isStringContent) {}}-function calculateContentHash({blobId, content}) {+function calculateContentHash({blobId, content}: { blobId: string, content: Buffer }) {return utils.hash(`${blobId}|${content.toString()}`);}