chore(client/ts): port zpetne_odkazy

This commit is contained in:
Elian Doran
2025-01-19 21:45:20 +02:00
parent 32fc5def77
commit 20584f622d
2 changed files with 36 additions and 16 deletions

View File

@@ -6,6 +6,12 @@ import type BNote from "../../becca/entities/bnote.js";
import type BAttribute from "../../becca/entities/battribute.js";
import type { Request } from "express";
interface Backlink {
noteId: string;
relationName?: string;
excerpts?: string[];
}
function buildDescendantCountMap(noteIdsToCount: string[]) {
if (!Array.isArray(noteIdsToCount)) {
throw new Error("noteIdsToCount: type error");
@@ -325,7 +331,7 @@ function findExcerpts(sourceNote: BNote, referencedNoteId: string) {
return excerpts;
}
function getFilteredBacklinks(note: BNote) {
function getFilteredBacklinks(note: BNote): BAttribute[] {
return (
note
.getTargetRelations()
@@ -344,7 +350,7 @@ function getBacklinkCount(req: Request) {
};
}
function getBacklinks(req: Request) {
function getBacklinks(req: Request): Backlink[] {
const { noteId } = req.params;
const note = becca.getNoteOrThrow(noteId);