ephrem
Version:
Ephrem is a light-weight API wrapper for API.Bible, built using NodeJS and Typescript. Ephrem validates bible references and fetches scripture text corresponding to the references.
134 lines (131 loc) • 5 kB
TypeScript
import { BaseEphremError } from './utils.js';
import 'env-paths';
declare const BIBLES_DATA_PATH: string;
declare const ABB_TO_ID_MAPPING_PATH: string;
declare const BOOKS_DATA_PATH: string;
declare const NAMES_TO_BIBLES_PATH: string;
declare class ApiBibleKeyNotFoundError extends BaseEphremError {
constructor();
}
declare const hasApiBibleKey: () => boolean;
declare class InvalidLanguageIDError extends BaseEphremError {
context: {
languageId: string;
};
constructor(languageId: string);
}
declare class BiblesNotAvailableError extends BaseEphremError {
context: {
languageId: string;
};
constructor(languageId: string);
}
declare class BiblesFetchError extends BaseEphremError {
statusCode: number | undefined;
statusText: string | undefined;
context: {
languageId: string;
statusCode: number | undefined;
statusText: string | undefined;
};
constructor(message: string, languageId: string, statusCode: number | undefined, statusText: string | undefined);
}
declare class BooksFetchError extends BaseEphremError {
statusCode: number | undefined;
statusText: string | undefined;
context: {
bibleId: string;
statusCode: number | undefined;
statusText: string | undefined;
};
constructor(message: string, bibleId: string, statusCode: number | undefined, statusText: string | undefined);
}
declare class PassageFetchError extends BaseEphremError {
statusCode: number | undefined;
statusText: string | undefined;
context: {
bibleId: string;
passageId: string;
passageOptions: PassageOptions;
statusCode: number | undefined;
statusText: string | undefined;
};
constructor(message: string, passageId: string, bibleId: string, passageOptions: PassageOptions, statusCode: number | undefined, statusText: string | undefined);
}
type ScriptDirection = "LTR" | "RTL";
interface Language {
readonly id: string;
readonly name: string;
readonly nameLocal: string;
readonly script: string;
readonly scriptDirection: ScriptDirection;
}
interface Bible {
readonly abbreviation: string;
readonly abbreviationLocal: string;
readonly dblId: string;
readonly description: string;
readonly descriptionLocal: string;
readonly id: string;
readonly language: Language;
readonly name: string;
readonly nameLocal: string;
readonly [key: string]: unknown;
}
interface Book {
readonly abbreviation: string;
readonly bibleId: string;
readonly id: string;
readonly name: string;
readonly nameLong: string;
}
interface PassageOptions {
readonly contentType?: "html" | "json" | "text";
readonly includeChapterNumbers?: boolean;
readonly includeNotes?: boolean;
readonly includeTitles?: boolean;
readonly includeVerseNumbers?: boolean;
readonly includeVerseSpans?: boolean;
}
interface Passage {
readonly content: string;
readonly copyright: string;
readonly id: string;
readonly [key: string]: unknown;
readonly reference: string;
}
interface Fums {
readonly fums: string;
readonly [key: string]: unknown;
}
interface PassageAndFums {
readonly data: Passage;
readonly meta: Fums;
readonly [key: string]: unknown;
}
interface PassageWithDetails {
readonly bible: Bible;
readonly book: Book;
readonly fums: Fums;
readonly passage: Passage;
}
type BookName = string;
type BibleId = string;
type BookId = string;
type BibleAbbreviation = string;
type BooksAndBibles = Record<BookName, Record<BibleId, BookId>>;
type BiblesMap = Record<BibleAbbreviation, BibleId>;
/**
* Sets up the Ephrem environment by fetching and writing Bible and book data from API.Bible.
* @param languageIds An array of language IDs (ISO-639-3; lower case) to fetch Bibles for.
* @returns A promise that resolves to the path where the data is stored.
*/
declare const setupEphrem: (languageIds: string[]) => Promise<string>;
declare const getPassageFromApi: (passageId: string, bibleId: string, passageOptions: PassageOptions) => Promise<PassageAndFums>;
/**
* Bible abbreviations mapping file can be used to customize the abbreviations/labels that can be used to refer to a Bible.
* This function returns the path to the Bible abbreviations mapping file.
* @returns The file path to the Bible abbreviations mapping file.
*/
declare const getBibleAbbreviationsFilepath: () => string;
export { ABB_TO_ID_MAPPING_PATH, ApiBibleKeyNotFoundError, BIBLES_DATA_PATH, BOOKS_DATA_PATH, type Bible, type BibleId, BiblesFetchError, type BiblesMap, BiblesNotAvailableError, type Book, type BookId, type BooksAndBibles, BooksFetchError, type Fums, InvalidLanguageIDError, type Language, NAMES_TO_BIBLES_PATH, type Passage, type PassageAndFums, PassageFetchError, type PassageOptions, type PassageWithDetails, type ScriptDirection, getBibleAbbreviationsFilepath, getPassageFromApi, hasApiBibleKey, setupEphrem };