adding chat features, admin features and bug fixes

This commit is contained in:
Matthias Hochmeister
2026-03-12 08:16:34 +01:00
parent 7b14e3d5ba
commit 31f1414e06
43 changed files with 2610 additions and 16 deletions

View File

@@ -151,4 +151,59 @@ async function searchPages(query: string): Promise<BookStackSearchResult[]> {
}
}
export default { getRecentPages, searchPages };
export interface BookStackPageDetail {
id: number;
name: string;
slug: string;
book_id: number;
book_slug: string;
chapter_id: number;
html: string;
created_at: string;
updated_at: string;
url: string;
book?: { name: string };
createdBy?: { name: string };
updatedBy?: { name: string };
}
async function getPageById(id: number): Promise<BookStackPageDetail> {
const { bookstack } = environment;
if (!bookstack.url || !isValidServiceUrl(bookstack.url)) {
throw new Error('BOOKSTACK_URL is not configured or is not a valid service URL');
}
try {
const response = await axios.get(
`${bookstack.url}/api/pages/${id}`,
{ headers: buildHeaders() },
);
const page = response.data;
return {
id: page.id,
name: page.name,
slug: page.slug,
book_id: page.book_id,
book_slug: page.book_slug ?? '',
chapter_id: page.chapter_id ?? 0,
html: page.html ?? '',
created_at: page.created_at,
updated_at: page.updated_at,
url: `${bookstack.url}/books/${page.book_slug}/page/${page.slug}`,
book: page.book,
createdBy: page.created_by,
updatedBy: page.updated_by,
};
} catch (error) {
if (axios.isAxiosError(error)) {
logger.error('BookStack getPageById failed', {
status: error.response?.status,
statusText: error.response?.statusText,
});
}
logger.error('BookStackService.getPageById failed', { error });
throw new Error('Failed to fetch BookStack page');
}
}
export default { getRecentPages, searchPages, getPageById };