UNPKG

@surgbc/egw-writings-shared

Version:

Shared utilities, types, and database schema for EGW Writings MCP servers

167 lines (166 loc) 3.88 kB
import { EGWAuthManager } from './auth.js'; export interface Language { code: string; name: string; direction: string; } export interface Folder { folder_id: number; name: string; add_class: string; nbooks: number; naudiobooks: number; sort: number; children?: Folder[]; } export interface Book { book_id: number; code: string; lang: string; type: string; subtype: string; title: string; first_para: string; author: string; description: string; npages: number; isbn?: string; publisher: string; pub_year: string; buy_link?: string; folder_id: number; folder_color_group: string; cover: { small: string; large: string; }; files: { mp3?: string; pdf: string; epub: string; mobi: string; }; download: string; last_modified: string; permission_required: string; sort: number; is_audiobook: boolean; cite: string; original_book?: string; translated_into: string[]; nelements: number; } export interface Chapter { id: number; title: string; bookId: number; order: number; paragraphCount: number; } export interface Paragraph { para_id: string; id_prev?: string; id_next?: string; refcode_1: string; refcode_2: string; refcode_3: string; refcode_4: string; refcode_short: string; refcode_long: string; element_type: string; element_subtype: string; content: string; puborder: number; translations: any[]; } export interface SearchHit { index: number; lang: string; para_id: string; pub_code: string; pub_name: string; refcode_long: string; refcode_short: string; pub_year: string; snippet: string; weight: number; group: string; } export interface SearchResult { next: string | null; previous: string | null; total: number; count: number; results: SearchHit[]; } export declare class EGWApiClient { private client; private authManager; private baseUrl; constructor(authManager: EGWAuthManager, baseUrl?: string); /** * Add delay between requests to be respectful */ private delay; /** * Get available languages */ getLanguages(): Promise<Language[]>; /** * Get folders for a language */ getFolders(languageCode: string): Promise<Folder[]>; /** * Get books in a folder */ getBooksByFolder(folderId: number): Promise<Book[]>; /** * Get book information */ getBook(bookId: number): Promise<Book>; /** * Get book table of contents */ getBookToc(bookId: number): Promise<Chapter[]>; /** * Get chapter content */ getChapter(bookId: number, chapterId: number): Promise<Paragraph[]>; /** * Get specific paragraph */ getParagraph(bookId: number, paragraphId: string): Promise<Paragraph>; /** * Search content (using Android app parameters) */ search(query: string, options?: { lang?: string[]; folder?: number[]; pubnr?: number[]; limit?: number; offset?: number; highlight?: string; trans?: string; }): Promise<SearchResult>; /** * Get search suggestions (using Android app parameters) */ getSearchSuggestions(query: string): Promise<string[]>; /** * Download book as ZIP */ downloadBook(bookId: number): Promise<Buffer>; /** * Get user information */ getUserInfo(): Promise<any>; /** * Test API connectivity and authentication */ testConnection(): Promise<boolean>; /** * Get API status and basic info */ getApiStatus(): Promise<any>; } export declare const createApiClient: (authManager: EGWAuthManager) => EGWApiClient;