UNPKG

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.

139 lines (136 loc) 7.24 kB
import { Bible, Book, PassageOptions, PassageAndFums, PassageWithDetails } from './api-bible.js'; import { BOOK_IDs } from './book-ids.js'; import { BaseEphremError } from './utils.js'; import 'env-paths'; declare class BookIdNotFoundError extends BaseEphremError { context: { bibleId: string; bookId: string; }; constructor(bookId: string, bibleId: string); } declare class FallbackBibleNotFoundError extends BaseEphremError { context: { fallbackBibleAbbreviation: string | undefined; input: string; }; constructor(input: string, fallbackBibleAbbreviation: string | undefined); } declare class UnknownBibleAbbreviationError extends BaseEphremError { context: { bibleAbbreviation: string; mappingFile: string; }; constructor(bibleAbbreviation: string, mappingFile: string); } declare class InvalidReferenceError extends BaseEphremError { context: { input: string; }; constructor(input: string); } declare class BibleNotAvailableError extends BaseEphremError { context: { bibleId: string; }; constructor(bibleId: string); } declare class BookNotInBibleError extends BaseEphremError { context: { availableBookIds: string[]; bibleName: string; bibleNameLocal: string; bookId: string; input: string; }; constructor(input: string, bookId: string, availableBookIds: string[], bibleName: string, bibleNameLocal: string); } type VoteTally = Record<string, number>; interface ChaptersAndVerses { readonly chapterEnd?: string; readonly chapterStart: string; readonly verseEnd?: string; readonly verseStart?: string; } interface ReferenceWithoutBible extends ChaptersAndVerses { readonly bookId: keyof typeof BOOK_IDs; } interface Reference extends ReferenceWithoutBible { readonly bibleId: string; } /** * Retrieves the Bible ID from the specified Bible abbreviation. * @param bibleAbbreviation The abbreviation of the Bible to retrieve the ID for. * @returns A promise that resolves to the Bible ID or undefined if not found. */ declare const getBibleIdFromAbbreviation: (bibleAbbreviation: string) => Promise<string | undefined>; /** * Retrieves the details of a Bible from the specified Bible ID. * @param bibleId The ID of the Bible to retrieve. * @returns A promise that resolves to the Bible details or undefined if not found. */ declare const getBibleDetails: (bibleId: string) => Promise<Bible | undefined>; /** * Retrieves the details of a book from the specified Bible. * @param bookId The ID of the book to retrieve. * @param bibleId The ID of the Bible to search within. * @returns A promise that resolves to the book details or undefined if not found. */ declare const getBookDetails: (bookId: string, bibleId: string) => Promise<Book | undefined>; /** * Retrieves the USFM book ID based on the provided book name and optional Bible ID. * @param bookName The name of the book to retrieve the ID for. * @param [bibleId] An optional Bible ID to narrow down the search. * @returns A promise that resolves to the book ID or undefined if not found. */ declare const getBookId: (bookName: string, bibleId?: string) => Promise<keyof typeof BOOK_IDs | undefined>; /** * Parses a reference from the input string and returns a Reference object. * @param input The input string containing the reference to be parsed. * @param [fallbackBibleAbbreviation] An optional fallback Bible abbreviation. * @returns A promise that resolves to a Reference object or undefined if the book ID is not found. * @throws {InvalidReferenceError} If the input reference is invalid. * @throws {FallbackBibleNotFoundError} If no fallback Bible abbreviation is provided when needed. * @throws {UnknownBibleAbbreviationError} If the Bible abbreviation is not found in the mapping file. * @throws {BookNotInBibleError} If the book is not found in the specified Bible. */ declare const parseReference: (input: string, fallbackBibleAbbreviation?: string) => Promise<Reference | undefined>; declare const getPassageId: (reference: ReferenceWithoutBible) => string; /** * Fetches a passage from the API.Bible service based on the provided reference and options. * @param reference The reference object containing the book, chapter, and verse details. * @param passageOptions The options for fetching the passage. * @returns A promise that resolves to the passage and FUMS response. */ declare const getPassageFromReference: (reference: Reference, passageOptions: PassageOptions) => Promise<PassageAndFums>; /** * Fetches a passage from the API.Bible service based on the provided input and options. * @param input The input string containing the reference to the passage. * @param passageOptions Options for fetching the passage. * @param [fallbackBibleAbbreviation] An optional fallback Bible abbreviation. * @returns A promise that resolves to the passage and FUMS response. * @throws {InvalidReferenceError} If the reference is invalid. */ declare const getPassage: (input: string, passageOptions: PassageOptions, fallbackBibleAbbreviation?: string) => Promise<PassageAndFums>; declare const _getPassageWithDetails: (passageAndFums: PassageAndFums, reference: Reference) => Promise<PassageWithDetails>; /** * Fetches a passage with detailed information (about the Bible and the Book) from the API.Bible service based on the provided input and options. * @param input The input string containing the reference to the passage. * @param passageOptions Options for fetching the passage. * @param [fallbackBibleAbbreviation] An optional fallback Bible abbreviation. * @returns A promise that resolves to the passage with detailed information. * @throws {InvalidReferenceError} If the reference is invalid. * @throws {BookIdNotFoundError} If the book ID is not found in the Bible. */ declare const getPassageWithDetails: (input: string, passageOptions: PassageOptions, fallbackBibleAbbreviation?: string) => Promise<PassageWithDetails>; /** * Fetches a passage with detailed information (about the Bible and the Book) from the API.Bible service based on the provided reference and options. * @param reference The reference object containing the book, chapter, and verse details. * @param passageOptions The options for fetching the passage. * @returns A promise that resolves to the passage with detailed information. * @throws {InvalidReferenceError} If the reference is invalid. * @throws {BookIdNotFoundError} If the book ID is not found in the Bible. * @throws {BibleNotAvailableError} If the Bible is not available. */ declare const getPassageWithDetailsFromReference: (reference: Reference, passageOptions: PassageOptions) => Promise<PassageWithDetails>; export { BibleNotAvailableError, BookIdNotFoundError, BookNotInBibleError, type ChaptersAndVerses, FallbackBibleNotFoundError, InvalidReferenceError, type Reference, type ReferenceWithoutBible, UnknownBibleAbbreviationError, type VoteTally, _getPassageWithDetails, getBibleDetails, getBibleIdFromAbbreviation, getBookDetails, getBookId, getPassage, getPassageFromReference, getPassageId, getPassageWithDetails, getPassageWithDetailsFromReference, parseReference };