chore(prettier): fix all files

This commit is contained in:
Elian Doran
2025-01-09 18:07:02 +02:00
parent 19ee861699
commit 4cbb529fd4
571 changed files with 23226 additions and 23940 deletions

View File

@@ -10,16 +10,16 @@ import TaskContext from "../../services/task_context.js";
import becca from "../../becca/becca.js";
import ValidationError from "../../errors/validation_error.js";
import blobService from "../../services/blob.js";
import { Request } from 'express';
import { Request } from "express";
import BBranch from "../../becca/entities/bbranch.js";
import { AttributeRow } from '../../becca/entities/rows.js';
import { AttributeRow } from "../../becca/entities/rows.js";
function getNote(req: Request) {
return becca.getNoteOrThrow(req.params.noteId);
}
function getNoteBlob(req: Request) {
return blobService.getBlobPojo('notes', req.params.noteId);
return blobService.getBlobPojo("notes", req.params.noteId);
}
function getNoteMetadata(req: Request) {
@@ -29,7 +29,7 @@ function getNoteMetadata(req: Request) {
dateCreated: note.dateCreated,
utcDateCreated: note.utcDateCreated,
dateModified: note.dateModified,
utcDateModified: note.utcDateModified,
utcDateModified: note.utcDateModified
};
}
@@ -56,8 +56,8 @@ function createNote(req: Request) {
}
function updateNoteData(req: Request) {
const {content, attachments} = req.body;
const {noteId} = req.params;
const { content, attachments } = req.body;
const { noteId } = req.params;
return noteService.updateNoteData(noteId, content, attachments);
}
@@ -65,8 +65,8 @@ function updateNoteData(req: Request) {
function deleteNote(req: Request) {
const noteId = req.params.noteId;
const taskId = req.query.taskId;
const eraseNotes = req.query.eraseNotes === 'true';
const last = req.query.last === 'true';
const eraseNotes = req.query.eraseNotes === "true";
const last = req.query.last === "true";
// note how deleteId is separate from taskId - single taskId produces separate deleteId for each "top level" deleted note
const deleteId = utils.randomString(10);
@@ -76,7 +76,7 @@ function deleteNote(req: Request) {
if (typeof taskId !== "string") {
throw new ValidationError("Missing or incorrect type for task ID.");
}
const taskContext = TaskContext.getInstance(taskId, 'deleteNotes');
const taskContext = TaskContext.getInstance(taskId, "deleteNotes");
note.deleteNote(deleteId, taskContext);
@@ -90,7 +90,7 @@ function deleteNote(req: Request) {
}
function undeleteNote(req: Request) {
const taskContext = TaskContext.getInstance(utils.randomString(10), 'undeleteNotes');
const taskContext = TaskContext.getInstance(utils.randomString(10), "undeleteNotes");
noteService.undeleteNote(req.params.noteId, taskContext);
@@ -99,11 +99,11 @@ function undeleteNote(req: Request) {
function sortChildNotes(req: Request) {
const noteId = req.params.noteId;
const {sortBy, sortDirection, foldersFirst, sortNatural, sortLocale} = req.body;
const { sortBy, sortDirection, foldersFirst, sortNatural, sortLocale } = req.body;
log.info(`Sorting '${noteId}' children with ${sortBy} ${sortDirection}, foldersFirst=${foldersFirst}, sortNatural=${sortNatural}, sortLocale=${sortLocale}`);
const reverse = sortDirection === 'desc';
const reverse = sortDirection === "desc";
treeService.sortNotes(noteId, sortBy, reverse, foldersFirst, sortNatural, sortLocale);
}
@@ -114,7 +114,7 @@ function protectNote(req: Request) {
const protect = !!parseInt(req.params.isProtected);
const includingSubTree = !!parseInt(req.query?.subtree as string);
const taskContext = new TaskContext(utils.randomString(10), 'protectNotes', {protect});
const taskContext = new TaskContext(utils.randomString(10), "protectNotes", { protect });
noteService.protectNoteRecursively(note, protect, includingSubTree, taskContext);
@@ -123,8 +123,8 @@ function protectNote(req: Request) {
function setNoteTypeMime(req: Request) {
// can't use [] destructuring because req.params is not iterable
const {noteId} = req.params;
const {type, mime} = req.body;
const { noteId } = req.params;
const { type, mime } = req.body;
const note = becca.getNoteOrThrow(noteId);
note.type = type;
@@ -160,7 +160,7 @@ function changeTitle(req: Request) {
}
function duplicateSubtree(req: Request) {
const {noteId, parentNoteId} = req.params;
const { noteId, parentNoteId } = req.params;
return noteService.duplicateSubtree(noteId, parentNoteId);
}
@@ -174,7 +174,7 @@ function eraseUnusedAttachmentsNow() {
}
function getDeleteNotesPreview(req: Request) {
const {branchIdsToDelete, deleteAllClones} = req.body;
const { branchIdsToDelete, deleteAllClones } = req.body;
const noteIdsToBeDeleted = new Set<string>();
const strongBranchCountToDelete: Record<string, number> = {}; // noteId => count
@@ -216,12 +216,16 @@ function getDeleteNotesPreview(req: Request) {
sql.fillParamList(noteIdsToBeDeleted);
// FIXME: No need to do this in database, can be done with becca data
brokenRelations = sql.getRows<AttributeRow>(`
brokenRelations = sql
.getRows<AttributeRow>(
`
SELECT attr.noteId, attr.name, attr.value
FROM attributes attr
JOIN param_list ON param_list.paramId = attr.value
WHERE attr.isDeleted = 0
AND attr.type = 'relation'`).filter(attr => attr.noteId && !noteIdsToBeDeleted.has(attr.noteId));
AND attr.type = 'relation'`
)
.filter((attr) => attr.noteId && !noteIdsToBeDeleted.has(attr.noteId));
}
return {
@@ -231,7 +235,7 @@ function getDeleteNotesPreview(req: Request) {
}
function forceSaveRevision(req: Request) {
const {noteId} = req.params;
const { noteId } = req.params;
const note = becca.getNoteOrThrow(noteId);
if (!note.isContentAvailable()) {
@@ -242,7 +246,7 @@ function forceSaveRevision(req: Request) {
}
function convertNoteToAttachment(req: Request) {
const {noteId} = req.params;
const { noteId } = req.params;
const note = becca.getNoteOrThrow(noteId);
return {