server-ts: Port becca/becca_service

This commit is contained in:
Elian Doran 2024-02-17 20:30:21 +02:00
parent 3b7812f829
commit 9f99b4282a
No known key found for this signature in database
6 changed files with 14 additions and 14 deletions

View File

@ -1,10 +1,10 @@
"use strict";
const becca = require('./becca');
const cls = require('../services/cls');
const log = require('../services/log');
import becca = require('./becca');
import cls = require('../services/cls');
import log = require('../services/log');
function isNotePathArchived(notePath) {
function isNotePathArchived(notePath: string[]) {
const noteId = notePath[notePath.length - 1];
const note = becca.notes[noteId];
@ -24,9 +24,9 @@ function isNotePathArchived(notePath) {
return false;
}
function getNoteTitle(childNoteId, parentNoteId) {
function getNoteTitle(childNoteId: string, parentNoteId?: string) {
const childNote = becca.notes[childNoteId];
const parentNote = becca.notes[parentNoteId];
const parentNote = parentNoteId ? becca.notes[parentNoteId] : null;
if (!childNote) {
log.info(`Cannot find note '${childNoteId}'`);
@ -40,7 +40,7 @@ function getNoteTitle(childNoteId, parentNoteId) {
return `${(branch && branch.prefix) ? `${branch.prefix} - ` : ''}${title}`;
}
function getNoteTitleArrayForPath(notePathArray) {
function getNoteTitleArrayForPath(notePathArray: string[]) {
if (!notePathArray || !Array.isArray(notePathArray)) {
throw new Error(`${notePathArray} is not an array.`);
}
@ -76,13 +76,13 @@ function getNoteTitleArrayForPath(notePathArray) {
return titles;
}
function getNoteTitleForPath(notePathArray) {
function getNoteTitleForPath(notePathArray: string[]) {
const titles = getNoteTitleArrayForPath(notePathArray);
return titles.join(' / ');
}
module.exports = {
export = {
getNoteTitle,
getNoteTitleForPath,
isNotePathArchived

View File

@ -1,6 +1,6 @@
"use strict";
const beccaService = require('../../becca/becca_service.js');
const beccaService = require('../../becca/becca_service');
const searchService = require('../../services/search/services/search.js');
const log = require('../../services/log');
const utils = require('../../services/utils');

View File

@ -1,6 +1,6 @@
"use strict";
const beccaService = require('../../becca/becca_service.js');
const beccaService = require('../../becca/becca_service');
const revisionService = require('../../services/revisions');
const utils = require('../../services/utils');
const sql = require('../../services/sql');

View File

@ -14,7 +14,7 @@ class NoteFlatTextExp extends Expression {
execute(inputNoteSet, executionContext, searchContext) {
// has deps on SQL which breaks unit test so needs to be dynamically required
const beccaService = require('../../../becca/becca_service.js');
const beccaService = require('../../../becca/becca_service');
const resultNoteSet = new NoteSet();
/**

View File

@ -1,6 +1,6 @@
"use strict";
const beccaService = require('../../becca/becca_service.js');
const beccaService = require('../../becca/becca_service');
const becca = require('../../becca/becca');
class SearchResult {

View File

@ -7,7 +7,7 @@ const parse = require('./parse.js');
const SearchResult = require('../search_result.js');
const SearchContext = require('../search_context.js');
const becca = require('../../../becca/becca');
const beccaService = require('../../../becca/becca_service.js');
const beccaService = require('../../../becca/becca_service');
const utils = require('../../utils');
const log = require('../../log');
const hoistedNoteService = require('../../hoisted_note.js');