hadith-collections
Version:
A comprehensive npm package for searching and browsing hadith collections with Arabic and English support
164 lines (144 loc) • 3.97 kB
TypeScript
export interface Collection {
id: number;
type: string;
title: string;
short_description?: string;
numbering_source: string;
has_volumes: number;
has_books: number;
has_chapters: number;
status: string;
title_en: string;
short_description_en?: string;
numbering_source_en: string;
last_updated?: string;
}
export interface Book {
id: number;
collection_id: number;
display_number: number;
order_in_collection: number;
title: string;
intro?: string;
hadith_start: number;
hadith_end: number;
hadith_count?: number;
title_en: string;
intro_en?: string;
}
export interface Chapter {
id: number;
collection_id: number;
book_id: number;
number: number;
title: string;
intro: string;
ending: string;
title_en: string;
intro_en: string;
ending_en: string;
}
export interface Hadith {
urn: string;
collection_id: number;
book_id?: number;
chapter_id?: number;
display_number?: number;
order_in_book?: number;
narrator_prefix?: string;
content: string;
narrator_postfix?: string;
narrator_prefix_diacless?: string;
content_diacless?: string;
narrator_postfix_diacless?: string;
comments?: string;
grades?: string;
narrators?: string;
related_hadiths?: string;
}
export interface EnglishHadith {
arabic_urn: string;
urn: string;
collection_id: number;
narrator_prefix?: string;
content: string;
narrator_postfix?: string;
comments?: string;
grades?: string;
reference?: string;
}
export interface Scholar {
id: number;
famous_name?: string;
born_on?: string;
died_on?: string;
lived_in?: string;
nick_name?: string;
}
export interface CollectionStats {
collection_id?: number;
book_count?: number;
chapter_count?: number;
collection_count?: number;
total_books?: number;
total_chapters?: number;
}
export interface SearchOptions {
collectionId?: number | null;
bookId?: number | null;
chapterId?: number | null;
limit?: number;
offset?: number;
searchInDiacless?: boolean;
}
export interface GetHadithsOptions {
limit?: number;
offset?: number;
bookId?: number | null;
chapterId?: number | null;
}
export interface SearchResults {
arabic: Hadith[];
english: EnglishHadith[];
total: number;
}
export interface DatabaseInfo {
version: string;
database_path: string;
collections: Array<{
id: number;
title: string;
title_en: string;
status: string;
}>;
statistics: CollectionStats;
}
export declare class HadithDB {
constructor(dbPath?: string | null);
connect(): Promise<void>;
close(): Promise<void>;
// Collection methods
getCollections(): Promise<Collection[]>;
getCollection(collectionId: number): Promise<Collection | null>;
getCollectionStats(collectionId?: number | null): Promise<CollectionStats>;
// Book methods
getBooks(collectionId: number): Promise<Book[]>;
getBook(collectionId: number, bookId: number): Promise<Book | null>;
// Chapter methods
getChapters(collectionId: number, bookId: number): Promise<Chapter[]>;
getChapter(collectionId: number, bookId: number, chapterId: number): Promise<Chapter | null>;
// Hadith retrieval methods
getHadithsByCollection(collectionId: number, options?: GetHadithsOptions): Promise<Hadith[]>;
getEnglishHadithsByCollection(collectionId: number, options?: GetHadithsOptions): Promise<EnglishHadith[]>;
getHadithByUrn(urn: string): Promise<Hadith | null>;
getEnglishHadithByUrn(urn: string): Promise<EnglishHadith | null>;
// Search methods
searchArabic(query: string, options?: SearchOptions): Promise<Hadith[]>;
searchEnglish(query: string, options?: SearchOptions): Promise<EnglishHadith[]>;
search(query: string, options?: SearchOptions): Promise<SearchResults>;
// Utility methods
getRandomHadith(collectionId?: number | null): Promise<Hadith | null>;
getScholars(): Promise<Scholar[]>;
getInfo(): Promise<DatabaseInfo>;
}
export default HadithDB;