free-use-bible-api 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -32,6 +32,21 @@ export class FreeUseBibleApi {
32
32
  false
33
33
  );
34
34
  }
35
+ /**
36
+ * Gets the complete content of a specific Bible translation, using the simplified chapter format.
37
+ *
38
+ * The results of this endpoint are very large, so the response is not cached.
39
+ * @param translation The ID of the translation to get the complete content for.
40
+ * @param endpoint The API endpoint to use for the request. If not provided, the default endpoint will be used.
41
+ */
42
+ async getSimpleCompleteTranslation(translation, endpoint) {
43
+ const encodedTranslation = encodeURIComponent(translation);
44
+ return this._getJson(
45
+ `api/${encodedTranslation}/complete.simple.json`,
46
+ endpoint,
47
+ false
48
+ );
49
+ }
35
50
  /**
36
51
  * Gets the list of available Bible commentaries from the API.
37
52
  * @param endpoint The API endpoint to use for the request. If not provided, the default endpoint will be used.
@@ -72,7 +87,7 @@ export class FreeUseBibleApi {
72
87
  async getCommentaryBooks(commentary, endpoint) {
73
88
  const encodedCommentary = encodeURIComponent(commentary);
74
89
  return this._getJson(
75
- `api/${encodedCommentary}/books.json`,
90
+ `api/c/${encodedCommentary}/books.json`,
76
91
  endpoint
77
92
  );
78
93
  }
@@ -104,6 +119,98 @@ export class FreeUseBibleApi {
104
119
  endpoint
105
120
  );
106
121
  }
122
+ /**
123
+ * Gets the word-level annotations (Strong's numbers and related source data) for a specific chapter of a specific book for a specific Bible translation.
124
+ *
125
+ * Only some translations have word-level annotations. This request will fail for chapters that don't have any.
126
+ * Use `getChapterWords()` to get the annotations for a chapter that you have already loaded, which returns null instead of failing.
127
+ * @param translation The ID of the translation to get the annotations for.
128
+ * @param book The ID of the book to get the annotations for.
129
+ * @param chapter The chapter number to get the annotations for.
130
+ * @param endpoint The API endpoint to use for the request. If not provided, the default endpoint will be used.
131
+ */
132
+ async getTranslationBookChapterWords(translation, book, chapter, endpoint) {
133
+ const encodedTranslation = encodeURIComponent(translation);
134
+ const encodedBook = encodeURIComponent(book);
135
+ const encodedChapter = encodeURIComponent(String(chapter));
136
+ return this._getJson(
137
+ `api/${encodedTranslation}/${encodedBook}/${encodedChapter}.words.json`,
138
+ endpoint
139
+ );
140
+ }
141
+ /**
142
+ * Gets the word-level annotations for the given chapter, if it has any.
143
+ * @param chapter The chapter to get the annotations for.
144
+ * @param endpoint The API endpoint to use for the request. If not provided, the default endpoint will be used.
145
+ * @returns The annotations for the chapter, or null if the chapter doesn't have any.
146
+ */
147
+ async getChapterWords(chapter, endpoint) {
148
+ if (!chapter.thisChapterWordsLink) {
149
+ return null;
150
+ }
151
+ return this._getJson(
152
+ chapter.thisChapterWordsLink,
153
+ endpoint
154
+ );
155
+ }
156
+ /**
157
+ * Gets the content of a specific chapter of a specific book for a specific Bible translation, using the simplified chapter format.
158
+ *
159
+ * In the simplified format, each verse's content is a single string instead of a list of formatted content, and footnotes, inline headings, the Words of Jesus, and poetry are represented as offset ranges into that string.
160
+ * @param translation The ID of the translation to get the chapter for.
161
+ * @param book The ID of the book to get the chapter for.
162
+ * @param chapter The chapter number to get.
163
+ * @param endpoint The API endpoint to use for the request. If not provided, the default endpoint will be used.
164
+ */
165
+ async getSimpleTranslationBookChapter(translation, book, chapter, endpoint) {
166
+ const encodedTranslation = encodeURIComponent(translation);
167
+ const encodedBook = encodeURIComponent(book);
168
+ const encodedChapter = encodeURIComponent(String(chapter));
169
+ return this._getJson(
170
+ `api/${encodedTranslation}/${encodedBook}/${encodedChapter}.simple.json`,
171
+ endpoint
172
+ );
173
+ }
174
+ /**
175
+ * Gets the word-level annotations (Strong's numbers and related source data) for a specific chapter of a specific book for a specific Bible translation, with their offsets remapped onto the text of each simplified verse.
176
+ *
177
+ * Use this instead of `getTranslationBookChapterWords()` when working with the simplified chapter format, since the offsets in the regular annotations are anchored to a verse's content array instead of its plain text.
178
+ * Use `getSimpleChapterWords()` to get the annotations for a simplified chapter that you have already loaded, which returns null instead of failing.
179
+ * @param translation The ID of the translation to get the annotations for.
180
+ * @param book The ID of the book to get the annotations for.
181
+ * @param chapter The chapter number to get the annotations for.
182
+ * @param endpoint The API endpoint to use for the request. If not provided, the default endpoint will be used.
183
+ */
184
+ async getSimpleTranslationBookChapterWords(translation, book, chapter, endpoint) {
185
+ const encodedTranslation = encodeURIComponent(translation);
186
+ const encodedBook = encodeURIComponent(book);
187
+ const encodedChapter = encodeURIComponent(String(chapter));
188
+ return this._getJson(
189
+ `api/${encodedTranslation}/${encodedBook}/${encodedChapter}.words.simple.json`,
190
+ endpoint
191
+ );
192
+ }
193
+ async getSimpleChapter(chapter, endpoint) {
194
+ if (!chapter.simpleChapterApiLink) {
195
+ return null;
196
+ }
197
+ return this._getJson(chapter.simpleChapterApiLink, endpoint);
198
+ }
199
+ /**
200
+ * Gets the word-level annotations for the given simplified chapter, if it has any.
201
+ * @param chapter The simplified chapter to get the annotations for.
202
+ * @param endpoint The API endpoint to use for the request. If not provided, the default endpoint will be used.
203
+ * @returns The annotations for the chapter, or null if the chapter doesn't have any.
204
+ */
205
+ async getSimpleChapterWords(chapter, endpoint) {
206
+ if (!chapter.thisChapterWordsLink) {
207
+ return null;
208
+ }
209
+ return this._getJson(
210
+ chapter.thisChapterWordsLink,
211
+ endpoint
212
+ );
213
+ }
107
214
  /**
108
215
  * Gets the content of a specific chapter of a specific book for a specific Bible commentary.
109
216
  * @param commentary The ID of the commentary to get the chapter for.
@@ -116,7 +223,23 @@ export class FreeUseBibleApi {
116
223
  const encodedBook = encodeURIComponent(book);
117
224
  const encodedChapter = encodeURIComponent(String(chapter));
118
225
  return this._getJson(
119
- `api/${encodedCommentary}/${encodedBook}/${encodedChapter}.json`,
226
+ `api/c/${encodedCommentary}/${encodedBook}/${encodedChapter}.json`,
227
+ endpoint
228
+ );
229
+ }
230
+ /**
231
+ * Gets the content of a specific chapter of a specific book for a specific Bible commentary, using the simplified chapter format.
232
+ * @param commentary The ID of the commentary to get the chapter for.
233
+ * @param book The ID of the book to get the chapter for.
234
+ * @param chapter The chapter number to get.
235
+ * @param endpoint The API endpoint to use for the request. If not provided, the default endpoint will be used.
236
+ */
237
+ async getSimpleCommentaryBookChapter(commentary, book, chapter, endpoint) {
238
+ const encodedCommentary = encodeURIComponent(commentary);
239
+ const encodedBook = encodeURIComponent(book);
240
+ const encodedChapter = encodeURIComponent(String(chapter));
241
+ return this._getJson(
242
+ `api/c/${encodedCommentary}/${encodedBook}/${encodedChapter}.simple.json`,
120
243
  endpoint
121
244
  );
122
245
  }
@@ -237,6 +360,86 @@ ${content.trim()}`;
237
360
  }
238
361
  return content.trim();
239
362
  }
363
+ /**
364
+ * Gets the verse text for the given simplified chapter.
365
+ * By default, the returned text includes markers for verse numbers and a reference to the chapter, but these can be omitted by passing options to the `options` parameter.
366
+ * @param chapter The simplified chapter to get the text for.
367
+ * @param options Options for getting the chapter text.
368
+ */
369
+ getSimpleChapterVerseText(chapter, options = {}) {
370
+ let content = "";
371
+ for (let chapterContent of chapter.chapter.content) {
372
+ if (chapterContent.type === "verse") {
373
+ if (!options.omitVerseNumbers) {
374
+ content += `[${chapterContent.number}] `;
375
+ }
376
+ content += chapterContent.text.trim() + " ";
377
+ } else if (chapterContent.type === "line_break") {
378
+ content = content.trim() + "\n";
379
+ }
380
+ }
381
+ if (!options.omitReference) {
382
+ content = `${this.formatReference(chapter.book, {
383
+ chapter: chapter.chapter.number
384
+ })}
385
+ ${content.trim()}`;
386
+ }
387
+ return content.trim();
388
+ }
389
+ /**
390
+ * Gets the text that the given word-level annotation applies to.
391
+ *
392
+ * Annotations are anchored to a range of characters in a single item of the verse's content,
393
+ * so that the ranges stay correct for verses whose content is split into multiple items,
394
+ * such as poem lines and the words of Jesus.
395
+ * @param verse The verse that the annotation is in.
396
+ * @param word The annotation to get the text for.
397
+ * @returns The annotated text, or an empty string if the annotation doesn't point at any text.
398
+ */
399
+ getWordText(verse, word) {
400
+ const content = verse.content[word.contentIndex];
401
+ if (typeof content === "string") {
402
+ return content.slice(word.start, word.end);
403
+ } else if (typeof content === "object" && content !== null && "text" in content) {
404
+ return content.text.slice(word.start, word.end);
405
+ }
406
+ return "";
407
+ }
408
+ /**
409
+ * Gets the word-level annotations for the given verse, paired with the text that each one applies to.
410
+ * @param verse The verse to get the annotations for.
411
+ * @param words The annotations for the chapter that the verse is in.
412
+ * @returns The annotations for the verse, in the order that they occur. Empty if the verse has no annotations.
413
+ */
414
+ getVerseWords(verse, words) {
415
+ const verseWords = words.verses[verse.number.toString()] ?? [];
416
+ return verseWords.map((word) => ({
417
+ ...word,
418
+ text: this.getWordText(verse, word)
419
+ }));
420
+ }
421
+ /**
422
+ * Gets the text that the given simplified word-level annotation applies to.
423
+ * @param verse The simplified verse that the annotation is in.
424
+ * @param word The annotation to get the text for.
425
+ * @returns The annotated text.
426
+ */
427
+ getSimpleWordText(verse, word) {
428
+ return verse.text.slice(word.start, word.end);
429
+ }
430
+ /**
431
+ * Gets the word-level annotations for the given simplified verse, paired with the text that each one applies to.
432
+ * @param verse The simplified verse to get the annotations for.
433
+ * @param words The simplified annotations for the chapter that the verse is in.
434
+ * @returns The annotations for the verse, in the order that they occur. Empty if the verse has no annotations.
435
+ */
436
+ getSimpleVerseWords(verse, words) {
437
+ const verseWords = words.verses[verse.number.toString()] ?? [];
438
+ return verseWords.map((word) => ({
439
+ ...word,
440
+ text: this.getSimpleWordText(verse, word)
441
+ }));
442
+ }
240
443
  _getJson(path, endpoint, useCache = true) {
241
444
  const url = this._buildUrl(path, endpoint);
242
445
  const existing = this._responseCache.get(url);
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../FreeUseBibleApi.ts"],
4
- "sourcesContent": ["import type {\r\n ApiAvailableDatasets,\r\n ApiAvailableTranslations,\r\n ApiCommentaryBook,\r\n ApiCommentaryBookChapter,\r\n ApiDatasetBook,\r\n ApiDatasetBookChapter,\r\n ApiDatasetBooks,\r\n ApiTranslationBook,\r\n ApiTranslationBookChapter,\r\n ApiTranslationBooks,\r\n ApiTranslationComplete,\r\n ChapterVerse,\r\n TranslationChapterReference,\r\n} from './types.gen.js';\r\n\r\n/**\r\n * Options for the FreeUseBibleApi class.\r\n */\r\nexport interface FreeUseBibleApiOptions {\r\n /**\r\n * The API endpoint to use for the requests. If not provided, the default endpoint will be used.\r\n */\r\n endpoint?: string;\r\n\r\n /**\r\n * Whether to cache responses in memory.\r\n *\r\n * Defaults to `true`.\r\n */\r\n useCache?: boolean;\r\n}\r\n\r\n/**\r\n * Options for the `getChapterText` method.\r\n */\r\nexport interface GetChapterTextOptions {\r\n /**\r\n * Whether to omit verse numbers from the returned text.\r\n * Defaults to `false`.\r\n */\r\n omitVerseNumbers?: boolean;\r\n\r\n /**\r\n * Whether to omit the chapter reference from the returned text.\r\n */\r\n omitReference?: boolean;\r\n}\r\n\r\n/**\r\n * Options for the `getVerseText` method.\r\n */\r\nexport interface GetVerseTextOptions {\r\n /**\r\n * Whether to omit the chapter reference from the returned text.\r\n */\r\n omitReference?: boolean;\r\n}\r\n\r\n/**\r\n * A reference to a specific verse in a Bible translation, commentary, or dataset.\r\n */\r\nexport interface VerseReference {\r\n /**\r\n * The chapter number of the reference. This should be a positive integer.\r\n */\r\n chapter: number;\r\n\r\n /**\r\n * The verse number of the reference.\r\n *\r\n * If omitted, then the reference refers to the entire chapter rather than a specific verse.\r\n */\r\n verse?: number;\r\n\r\n /**\r\n * The ending verse number of the reference, for references that span multiple verses. This should be greater than or equal to the `verse` property if it is provided.\r\n */\r\n endVerse?: number;\r\n\r\n /**\r\n * The ending chapter number of the reference, for references that span multiple chapters. This should be greater than or equal to the `chapter` property if it is provided.\r\n */\r\n endChapter?: number;\r\n}\r\n\r\n/**\r\n * A client for interacting with the [Free Use Bible API](https://bible.helloao.org/).\r\n *\r\n * This API provides access to a large collection of Bible translations, commentaries, and datasets that are free to use.\r\n */\r\nexport class FreeUseBibleApi {\r\n endpoint: string = 'https://bible.helloao.org/';\r\n private _responseCache = new Map<string, Promise<unknown>>();\r\n private _useCache: boolean = true;\r\n\r\n constructor(options?: FreeUseBibleApiOptions) {\r\n this.endpoint = options?.endpoint ?? this.endpoint;\r\n this._useCache = options?.useCache ?? this._useCache;\r\n }\r\n\r\n /**\r\n * Gets the list of available Bible translations from the API.\r\n * @param endpoint The API endpoint to use for the request. If not provided, the default endpoint will be used.\r\n */\r\n async getAvailableTranslations(\r\n endpoint?: string\r\n ): Promise<ApiAvailableTranslations> {\r\n return this._getJson<ApiAvailableTranslations>(\r\n 'api/available_translations.json',\r\n endpoint\r\n );\r\n }\r\n\r\n /**\r\n * Gets the complete content of a specific Bible translation.\r\n *\r\n * The results of this endpoint are very large, so the response is not cached.\r\n * @param translation The ID of the translation to get the complete content for.\r\n * @param endpoint The API endpoint to use for the request. If not provided, the default endpoint will be used.\r\n */\r\n async getCompleteTranslation(\r\n translation: string,\r\n endpoint?: string\r\n ): Promise<ApiTranslationComplete> {\r\n const encodedTranslation = encodeURIComponent(translation);\r\n return this._getJson<ApiTranslationComplete>(\r\n `api/${encodedTranslation}/complete.json`,\r\n endpoint,\r\n false\r\n );\r\n }\r\n\r\n /**\r\n * Gets the list of available Bible commentaries from the API.\r\n * @param endpoint The API endpoint to use for the request. If not provided, the default endpoint will be used.\r\n */\r\n async getAvailableCommentaries(\r\n endpoint?: string\r\n ): Promise<ApiAvailableTranslations> {\r\n return this._getJson<ApiAvailableTranslations>(\r\n 'api/available_commentaries.json',\r\n endpoint\r\n );\r\n }\r\n\r\n /**\r\n * Gets the list of available datasets from the API.\r\n * @param endpoint The API endpoint to use for the request. If not provided, the default endpoint will be used.\r\n */\r\n async getAvailableDatasets(\r\n endpoint?: string\r\n ): Promise<ApiAvailableDatasets> {\r\n return this._getJson<ApiAvailableDatasets>(\r\n 'api/available_datasets.json',\r\n endpoint\r\n );\r\n }\r\n\r\n /**\r\n * Gets the list of books for a given Bible translation.\r\n * @param translation The ID of the translation to get the books for.\r\n * @param endpoint The API endpoint to use for the request. If not provided, the default endpoint will be used.\r\n */\r\n async getTranslationBooks(\r\n translation: string,\r\n endpoint?: string\r\n ): Promise<ApiTranslationBooks> {\r\n const encodedTranslation = encodeURIComponent(translation);\r\n return this._getJson<ApiTranslationBooks>(\r\n `api/${encodedTranslation}/books.json`,\r\n endpoint\r\n );\r\n }\r\n\r\n /**\r\n * Gets the list of books for a given Bible commentary.\r\n * @param commentary The ID of the commentary to get the books for.\r\n * @param endpoint The API endpoint to use for the request. If not provided, the default endpoint will be used.\r\n */\r\n async getCommentaryBooks(\r\n commentary: string,\r\n endpoint?: string\r\n ): Promise<ApiTranslationBooks> {\r\n const encodedCommentary = encodeURIComponent(commentary);\r\n return this._getJson<ApiTranslationBooks>(\r\n `api/${encodedCommentary}/books.json`,\r\n endpoint\r\n );\r\n }\r\n\r\n /**\r\n * Gets the list of books for a given dataset.\r\n * @param dataset The ID of the dataset to get the books for.\r\n * @param endpoint The API endpoint to use for the request. If not provided, the default endpoint will be used.\r\n */\r\n async getDatasetBooks(\r\n dataset: string,\r\n endpoint?: string\r\n ): Promise<ApiDatasetBooks> {\r\n const encodedDataset = encodeURIComponent(dataset);\r\n return this._getJson<ApiDatasetBooks>(\r\n `api/d/${encodedDataset}/books.json`,\r\n endpoint\r\n );\r\n }\r\n\r\n /**\r\n * Gets the content of a specific chapter of a specific book for a specific Bible translation.\r\n * @param translation The ID of the translation to get the chapter for.\r\n * @param book The ID of the book to get the chapter for.\r\n * @param chapter The chapter number to get.\r\n * @param endpoint The API endpoint to use for the request. If not provided, the default endpoint will be used.\r\n */\r\n async getTranslationBookChapter(\r\n translation: string,\r\n book: string,\r\n chapter: number | string,\r\n endpoint?: string\r\n ): Promise<ApiTranslationBookChapter> {\r\n const encodedTranslation = encodeURIComponent(translation);\r\n const encodedBook = encodeURIComponent(book);\r\n const encodedChapter = encodeURIComponent(String(chapter));\r\n return this._getJson<ApiTranslationBookChapter>(\r\n `api/${encodedTranslation}/${encodedBook}/${encodedChapter}.json`,\r\n endpoint\r\n );\r\n }\r\n\r\n /**\r\n * Gets the content of a specific chapter of a specific book for a specific Bible commentary.\r\n * @param commentary The ID of the commentary to get the chapter for.\r\n * @param book The ID of the book to get the chapter for.\r\n * @param chapter The chapter number to get.\r\n * @param endpoint The API endpoint to use for the request. If not provided, the default endpoint will be used.\r\n */\r\n async getCommentaryBookChapter(\r\n commentary: string,\r\n book: string,\r\n chapter: number | string,\r\n endpoint?: string\r\n ): Promise<ApiTranslationBookChapter> {\r\n const encodedCommentary = encodeURIComponent(commentary);\r\n const encodedBook = encodeURIComponent(book);\r\n const encodedChapter = encodeURIComponent(String(chapter));\r\n return this._getJson<ApiTranslationBookChapter>(\r\n `api/${encodedCommentary}/${encodedBook}/${encodedChapter}.json`,\r\n endpoint\r\n );\r\n }\r\n\r\n /**\r\n * Gets the content of a specific chapter of a specific book for a specific dataset.\r\n * @param dataset The ID of the dataset to get the chapter for.\r\n * @param book The ID of the book to get the chapter for.\r\n * @param chapter The chapter number to get.\r\n * @param endpoint The API endpoint to use for the request. If not provided, the default endpoint will be used.\r\n */\r\n async getDatasetBookChapter(\r\n dataset: string,\r\n book: string,\r\n chapter: number | string,\r\n endpoint?: string\r\n ): Promise<ApiDatasetBookChapter> {\r\n const encodedDataset = encodeURIComponent(dataset);\r\n const encodedBook = encodeURIComponent(book);\r\n const encodedChapter = encodeURIComponent(String(chapter));\r\n return this._getJson<ApiDatasetBookChapter>(\r\n `api/d/${encodedDataset}/${encodedBook}/${encodedChapter}.json`,\r\n endpoint\r\n );\r\n }\r\n\r\n /**\r\n * Gets the next chapter for a given chapter, if available.\r\n * @param chapter The chapter to get the next chapter for.\r\n * @param endpoint The API endpoint to use for the request. If not provided, the default endpoint will be used.\r\n * @returns The next chapter, or null if there is no next chapter.\r\n */\r\n getNextChapter(\r\n chapter: ApiCommentaryBookChapter,\r\n endpoint?: string\r\n ): Promise<ApiCommentaryBookChapter | null>;\r\n /**\r\n * Gets the next chapter for a given chapter, if available.\r\n * @param chapter The chapter to get the next chapter for.\r\n * @param endpoint The API endpoint to use for the request. If not provided, the default endpoint will be used.\r\n * @returns The next chapter, or null if there is no next chapter.\r\n */\r\n getNextChapter(\r\n chapter: ApiTranslationBookChapter,\r\n endpoint?: string\r\n ): Promise<ApiTranslationBookChapter | null>;\r\n /**\r\n * Gets the next chapter for a given chapter, if available.\r\n * @param chapter The chapter to get the next chapter for.\r\n * @param endpoint The API endpoint to use for the request. If not provided, the default endpoint will be used.\r\n * @returns The next chapter, or null if there is no next chapter.\r\n */\r\n getNextChapter(\r\n chapter: ApiDatasetBookChapter,\r\n endpoint?: string\r\n ): Promise<ApiDatasetBookChapter | null>;\r\n async getNextChapter(\r\n chapter:\r\n | ApiTranslationBookChapter\r\n | ApiCommentaryBookChapter\r\n | ApiDatasetBookChapter,\r\n endpoint?: string\r\n ): Promise<\r\n | ApiTranslationBookChapter\r\n | ApiCommentaryBookChapter\r\n | ApiDatasetBookChapter\r\n | null\r\n > {\r\n if (!chapter.nextChapterApiLink) {\r\n return null;\r\n }\r\n return this._getJson<\r\n | ApiTranslationBookChapter\r\n | ApiCommentaryBookChapter\r\n | ApiDatasetBookChapter\r\n >(chapter.nextChapterApiLink, endpoint);\r\n }\r\n\r\n /**\r\n * Gets the previous chapter for a given chapter, if available.\r\n * @param chapter The chapter to get the previous chapter for.\r\n * @param endpoint The API endpoint to use for the request. If not provided, the default endpoint will be used.\r\n * @returns The previous chapter, or null if there is no previous chapter.\r\n */\r\n getPreviousChapter(\r\n chapter: ApiCommentaryBookChapter,\r\n endpoint?: string\r\n ): Promise<ApiCommentaryBookChapter | null>;\r\n /**\r\n * Gets the previous chapter for a given chapter, if available.\r\n * @param chapter The chapter to get the previous chapter for.\r\n * @param endpoint The API endpoint to use for the request. If not provided, the default endpoint will be used.\r\n * @returns The previous chapter, or null if there is no previous chapter.\r\n */\r\n getPreviousChapter(\r\n chapter: ApiTranslationBookChapter,\r\n endpoint?: string\r\n ): Promise<ApiTranslationBookChapter | null>;\r\n /**\r\n * Gets the previous chapter for a given chapter, if available.\r\n * @param chapter The chapter to get the previous chapter for.\r\n * @param endpoint The API endpoint to use for the request. If not provided, the default endpoint will be used.\r\n * @returns The previous chapter, or null if there is no previous chapter.\r\n */\r\n getPreviousChapter(\r\n chapter: ApiDatasetBookChapter,\r\n endpoint?: string\r\n ): Promise<ApiDatasetBookChapter | null>;\r\n async getPreviousChapter(\r\n chapter:\r\n | ApiTranslationBookChapter\r\n | ApiCommentaryBookChapter\r\n | ApiDatasetBookChapter,\r\n endpoint?: string\r\n ): Promise<\r\n | ApiTranslationBookChapter\r\n | ApiCommentaryBookChapter\r\n | ApiDatasetBookChapter\r\n | null\r\n > {\r\n if (!chapter.previousChapterApiLink) {\r\n return null;\r\n }\r\n return this._getJson<\r\n | ApiTranslationBookChapter\r\n | ApiCommentaryBookChapter\r\n | ApiDatasetBookChapter\r\n >(chapter.previousChapterApiLink, endpoint);\r\n }\r\n\r\n /**\r\n * Gets the first chapter for a given book, if available.\r\n * @param book The book to get the first chapter for.\r\n * @param endpoint The API endpoint to use for the request. If not provided, the default endpoint will be used.\r\n * @returns The first chapter, or null if there is no first chapter.\r\n */\r\n getFirstChapter(\r\n book: ApiCommentaryBook,\r\n endpoint?: string\r\n ): Promise<ApiCommentaryBookChapter | null>;\r\n /**\r\n * Gets the first chapter for a given book, if available.\r\n * @param book The book to get the first chapter for.\r\n * @param endpoint The API endpoint to use for the request. If not provided, the default endpoint will be used.\r\n * @returns The first chapter, or null if there is no first chapter.\r\n */\r\n getFirstChapter(\r\n book: ApiTranslationBook,\r\n endpoint?: string\r\n ): Promise<ApiTranslationBookChapter>;\r\n /**\r\n * Gets the first chapter for a given book, if available.\r\n * @param book The book to get the first chapter for.\r\n * @param endpoint The API endpoint to use for the request. If not provided, the default endpoint will be used.\r\n * @returns The first chapter, or null if there is no first chapter.\r\n */\r\n getFirstChapter(\r\n book: ApiDatasetBook,\r\n endpoint?: string\r\n ): Promise<ApiDatasetBookChapter>;\r\n async getFirstChapter(\r\n book: ApiTranslationBook | ApiCommentaryBook | ApiDatasetBook,\r\n endpoint?: string\r\n ): Promise<\r\n | ApiTranslationBookChapter\r\n | ApiCommentaryBookChapter\r\n | ApiDatasetBookChapter\r\n | null\r\n > {\r\n if (!book.firstChapterApiLink) {\r\n return null;\r\n }\r\n return this._getJson<\r\n | ApiTranslationBookChapter\r\n | ApiCommentaryBookChapter\r\n | ApiDatasetBookChapter\r\n >(book.firstChapterApiLink, endpoint);\r\n }\r\n\r\n /**\r\n * Gets the last chapter for a given book, if available.\r\n * @param book The book to get the last chapter for.\r\n * @param endpoint The API endpoint to use for the request. If not provided, the default endpoint will be used.\r\n * @returns The last chapter, or null if there is no last chapter.\r\n */\r\n getLastChapter(\r\n book: ApiCommentaryBook,\r\n endpoint?: string\r\n ): Promise<ApiCommentaryBookChapter | null>;\r\n /**\r\n * Gets the last chapter for a given book, if available.\r\n * @param book The book to get the last chapter for.\r\n * @param endpoint The API endpoint to use for the request. If not provided, the default endpoint will be used.\r\n * @returns The last chapter, or null if there is no last chapter.\r\n */\r\n getLastChapter(\r\n book: ApiTranslationBook,\r\n endpoint?: string\r\n ): Promise<ApiTranslationBookChapter>;\r\n /**\r\n * Gets the last chapter for a given book, if available.\r\n * @param book The book to get the last chapter for.\r\n * @param endpoint The API endpoint to use for the request. If not provided, the default endpoint will be used.\r\n * @returns The last chapter, or null if there is no last chapter.\r\n */\r\n getLastChapter(\r\n book: ApiDatasetBook,\r\n endpoint?: string\r\n ): Promise<ApiDatasetBookChapter>;\r\n async getLastChapter(\r\n book: ApiTranslationBook | ApiCommentaryBook | ApiDatasetBook,\r\n endpoint?: string\r\n ): Promise<\r\n | ApiTranslationBookChapter\r\n | ApiCommentaryBookChapter\r\n | ApiDatasetBookChapter\r\n | null\r\n > {\r\n if (!book.lastChapterApiLink) {\r\n return null;\r\n }\r\n return this._getJson<\r\n | ApiTranslationBookChapter\r\n | ApiCommentaryBookChapter\r\n | ApiDatasetBookChapter\r\n >(book.lastChapterApiLink, endpoint);\r\n }\r\n\r\n /**\r\n * Formats a verse reference as a human-readable string.\r\n *\r\n * e.g. Genesis 1:1-2, John 3:16, Exodus 20-22, etc.\r\n *\r\n * @param book The book that the reference is for.\r\n * @param reference The reference to format.\r\n */\r\n formatReference(\r\n book: ApiTranslationBook,\r\n reference: VerseReference\r\n ): string {\r\n const bookName = book.name;\r\n const chapter = reference.chapter;\r\n const verse = reference.verse;\r\n const endChapter = reference.endChapter;\r\n const endVerse = reference.endVerse;\r\n\r\n let referenceStr = `${bookName} ${chapter}`;\r\n if (endChapter) {\r\n referenceStr += `-${endChapter}`;\r\n } else if (verse) {\r\n referenceStr += `:${verse}`;\r\n if (endVerse) {\r\n referenceStr += `-${endVerse}`;\r\n }\r\n }\r\n return referenceStr;\r\n }\r\n\r\n /**\r\n * Gets the text for a verse.\r\n * @param verse The verse to get the text for.\r\n * @param options Options for getting the verse text.\r\n */\r\n getVerseText(verse: ChapterVerse): string {\r\n let content = '';\r\n for (let part of verse.content) {\r\n if (typeof part === 'string') {\r\n content += part;\r\n } else if (typeof part === 'object' && 'text' in part) {\r\n if (part.poem) {\r\n content += '\\n';\r\n for (let i = 0; i < part.poem; i++) {\r\n content += '\\t';\r\n }\r\n }\r\n content += part.text;\r\n } else if (typeof part === 'object' && 'lineBreak' in part) {\r\n content += '\\n';\r\n } else if (typeof part === 'object') {\r\n content += ' ';\r\n }\r\n }\r\n return content.trim();\r\n }\r\n\r\n /**\r\n * Gets the verse text for the given chapter.\r\n * By default, the returned text includes markers for verse numbers and a reference to the chapter, but these can be omitted by passing options to the `options` parameter.\r\n * @param chapter The chapter to get the text for.\r\n * @param options Options for getting the chapter text.\r\n */\r\n getChapterVerseText(\r\n chapter: ApiTranslationBookChapter,\r\n options: GetChapterTextOptions = {}\r\n ): string {\r\n let content = '';\r\n for (let chapterContent of chapter.chapter.content) {\r\n if (chapterContent.type === 'verse') {\r\n if (!options.omitVerseNumbers) {\r\n content += `[${chapterContent.number}] `;\r\n }\r\n content += this.getVerseText(chapterContent) + ' ';\r\n } else if (chapterContent.type === 'line_break') {\r\n content = content.trim() + '\\n';\r\n }\r\n }\r\n\r\n if (!options.omitReference) {\r\n content = `${this.formatReference(chapter.book, {\r\n chapter: chapter.chapter.number,\r\n })}\\n${content.trim()}`;\r\n }\r\n\r\n return content.trim();\r\n }\r\n\r\n private _getJson<T>(\r\n path: string,\r\n endpoint: string | undefined,\r\n useCache: boolean = true\r\n ): Promise<T> {\r\n const url = this._buildUrl(path, endpoint);\r\n const existing = this._responseCache.get(url) as Promise<T> | undefined;\r\n if (existing) {\r\n return existing;\r\n }\r\n\r\n const request: Promise<T> = fetch(url)\r\n .then(async (response) => {\r\n if (response.status < 200 || response.status >= 300) {\r\n throw new Error(\r\n `Failed request to ${url}. Status: ${response.status} ${response.statusText}`\r\n );\r\n }\r\n return await response.json();\r\n })\r\n .catch((error) => {\r\n this._responseCache.delete(url);\r\n throw error;\r\n });\r\n\r\n if (this._useCache && useCache) {\r\n this._responseCache.set(url, request);\r\n }\r\n return request;\r\n }\r\n\r\n private _buildUrl(path: string, endpoint?: string): string {\r\n if (/^https?:\\/\\//i.test(path)) {\r\n return path;\r\n }\r\n\r\n const baseEndpoint = endpoint ?? this.endpoint;\r\n return new URL(path, baseEndpoint).href;\r\n }\r\n}\r\n"],
5
- "mappings": ";AA2FO,aAAM,gBAAgB;AAAA,EACzB,WAAmB;AAAA,EACX,iBAAiB,oBAAI,IAA8B;AAAA,EACnD,YAAqB;AAAA,EAE7B,YAAY,SAAkC;AAC1C,SAAK,WAAW,SAAS,YAAY,KAAK;AAC1C,SAAK,YAAY,SAAS,YAAY,KAAK;AAAA,EAC/C;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,yBACF,UACiC;AACjC,WAAO,KAAK;AAAA,MACR;AAAA,MACA;AAAA,IACJ;AAAA,EACJ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,MAAM,uBACF,aACA,UAC+B;AAC/B,UAAM,qBAAqB,mBAAmB,WAAW;AACzD,WAAO,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Q,eAAe;AACxB,gBAAU,GAAG,KAAK,gBAAgB,QAAQ,MAAM;AAAA,QAC5C,SAAS,QAAQ,QAAQ;AAAA,MAC7B,CAAC,CAAC;AAAA,EAAK,QAAQ,KAAK,CAAC;AAAA,IACzB;AAEA,WAAO,QAAQ,KAAK;AAAA,EACxB;AAAA,EAEQ,SACJ,MACA,UACA,WAAoB,MACV;AACV,UAAM,MAAM,KAAK,UAAU,MAAM,QAAQ;AACzC,UAAM,WAAW,KAAK,eAAe,IAAI,GAAG;AAC5C,QAAI,UAAU;AACV,aAAO;AAAA,IACX;AAEA,UAAM,UAAsB,MAAM,GAAG,EAChC,KAAK,OAAO,aAAa;AACtB,UAAI,SAAS,SAAS,OAAO,SAAS,UAAU,KAAK;AACjD,cAAM,IAAI;AAAA,UACN,qBAAqB,GAAG,aAAa,SAAS,MAAM,IAAI,SAAS,UAAU;AAAA,QAC/E;AAAA,MACJ;AACA,aAAO,MAAM,SAAS,KAAK;AAAA,IAC/B,CAAC,EACA,MAAM,CAAC,UAAU;AACd,WAAK,eAAe,OAAO,GAAG;AAC9B,YAAM;AAAA,IACV,CAAC;AAEL,QAAI,KAAK,aAAa,UAAU;AAC5B,WAAK,eAAe,IAAI,KAAK,OAAO;AAAA,IACxC;AACA,WAAO;AAAA,EACX;AAAA,EAEQ,UAAU,MAAc,UAA2B;AACvD,QAAI,gBAAgB,KAAK,IAAI,GAAG;AAC5B,aAAO;AAAA,IACX;AAEA,UAAM,eAAe,YAAY,KAAK;AACtC,WAAO,IAAI,IAAI,MAAM,YAAY,EAAE;AAAA,EACvC;AACJ;",
4
+ "sourcesContent": ["import type {\r\n ApiAvailableDatasets,\r\n ApiAvailableTranslations,\r\n ApiCommentaryBook,\r\n ApiCommentaryBookChapter,\r\n ApiDatasetBook,\r\n ApiDatasetBookChapter,\r\n ApiDatasetBooks,\r\n ApiSimpleCommentaryBookChapter,\r\n ApiSimpleTranslationBookChapter,\r\n ApiSimpleTranslationBookChapterWords,\r\n ApiSimpleTranslationComplete,\r\n ApiTranslationBook,\r\n ApiTranslationBookChapter,\r\n ApiTranslationBookChapterWords,\r\n ApiTranslationBooks,\r\n ApiTranslationComplete,\r\n ChapterVerse,\r\n ChapterWord,\r\n SimpleChapterVerse,\r\n SimpleChapterWord,\r\n TranslationChapterReference,\r\n} from './types.gen.js';\r\n\r\n/**\r\n * Options for the FreeUseBibleApi class.\r\n */\r\nexport interface FreeUseBibleApiOptions {\r\n /**\r\n * The API endpoint to use for the requests. If not provided, the default endpoint will be used.\r\n */\r\n endpoint?: string;\r\n\r\n /**\r\n * Whether to cache responses in memory.\r\n *\r\n * Defaults to `true`.\r\n */\r\n useCache?: boolean;\r\n}\r\n\r\n/**\r\n * Options for the `getChapterText` method.\r\n */\r\nexport interface GetChapterTextOptions {\r\n /**\r\n * Whether to omit verse numbers from the returned text.\r\n * Defaults to `false`.\r\n */\r\n omitVerseNumbers?: boolean;\r\n\r\n /**\r\n * Whether to omit the chapter reference from the returned text.\r\n */\r\n omitReference?: boolean;\r\n}\r\n\r\n/**\r\n * Options for the `getVerseText` method.\r\n */\r\nexport interface GetVerseTextOptions {\r\n /**\r\n * Whether to omit the chapter reference from the returned text.\r\n */\r\n omitReference?: boolean;\r\n}\r\n\r\n/**\r\n * A word-level annotation, paired with the text of the verse that it covers.\r\n */\r\nexport interface AnnotatedWord extends ChapterWord {\r\n /**\r\n * The text that the annotation applies to.\r\n */\r\n text: string;\r\n}\r\n\r\n/**\r\n * A word-level annotation in a simplified chapter, paired with the text of the verse that it covers.\r\n */\r\nexport interface SimpleAnnotatedWord extends SimpleChapterWord {\r\n /**\r\n * The text that the annotation applies to.\r\n */\r\n text: string;\r\n}\r\n\r\n/**\r\n * A reference to a specific verse in a Bible translation, commentary, or dataset.\r\n */\r\nexport interface VerseReference {\r\n /**\r\n * The chapter number of the reference. This should be a positive integer.\r\n */\r\n chapter: number;\r\n\r\n /**\r\n * The verse number of the reference.\r\n *\r\n * If omitted, then the reference refers to the entire chapter rather than a specific verse.\r\n */\r\n verse?: number;\r\n\r\n /**\r\n * The ending verse number of the reference, for references that span multiple verses. This should be greater than or equal to the `verse` property if it is provided.\r\n */\r\n endVerse?: number;\r\n\r\n /**\r\n * The ending chapter number of the reference, for references that span multiple chapters. This should be greater than or equal to the `chapter` property if it is provided.\r\n */\r\n endChapter?: number;\r\n}\r\n\r\n/**\r\n * A client for interacting with the [Free Use Bible API](https://bible.helloao.org/).\r\n *\r\n * This API provides access to a large collection of Bible translations, commentaries, and datasets that are free to use.\r\n */\r\nexport class FreeUseBibleApi {\r\n endpoint: string = 'https://bible.helloao.org/';\r\n private _responseCache = new Map<string, Promise<unknown>>();\r\n private _useCache: boolean = true;\r\n\r\n constructor(options?: FreeUseBibleApiOptions) {\r\n this.endpoint = options?.endpoint ?? this.endpoint;\r\n this._useCache = options?.useCache ?? this._useCache;\r\n }\r\n\r\n /**\r\n * Gets the list of available Bible translations from the API.\r\n * @param endpoint The API endpoint to use for the request. If not provided, the default endpoint will be used.\r\n */\r\n async getAvailableTranslations(\r\n endpoint?: string\r\n ): Promise<ApiAvailableTranslations> {\r\n return this._getJson<ApiAvailableTranslations>(\r\n 'api/available_translations.json',\r\n endpoint\r\n );\r\n }\r\n\r\n /**\r\n * Gets the complete content of a specific Bible translation.\r\n *\r\n * The results of this endpoint are very large, so the response is not cached.\r\n * @param translation The ID of the translation to get the complete content for.\r\n * @param endpoint The API endpoint to use for the request. If not provided, the default endpoint will be used.\r\n */\r\n async getCompleteTranslation(\r\n translation: string,\r\n endpoint?: string\r\n ): Promise<ApiTranslationComplete> {\r\n const encodedTranslation = encodeURIComponent(translation);\r\n return this._getJson<ApiTranslationComplete>(\r\n `api/${encodedTranslation}/complete.json`,\r\n endpoint,\r\n false\r\n );\r\n }\r\n\r\n /**\r\n * Gets the complete content of a specific Bible translation, using the simplified chapter format.\r\n *\r\n * The results of this endpoint are very large, so the response is not cached.\r\n * @param translation The ID of the translation to get the complete content for.\r\n * @param endpoint The API endpoint to use for the request. If not provided, the default endpoint will be used.\r\n */\r\n async getSimpleCompleteTranslation(\r\n translation: string,\r\n endpoint?: string\r\n ): Promise<ApiSimpleTranslationComplete> {\r\n const encodedTranslation = encodeURIComponent(translation);\r\n return this._getJson<ApiSimpleTranslationComplete>(\r\n `api/${encodedTranslation}/complete.simple.json`,\r\n endpoint,\r\n false\r\n );\r\n }\r\n\r\n /**\r\n * Gets the list of available Bible commentaries from the API.\r\n * @param endpoint The API endpoint to use for the request. If not provided, the default endpoint will be used.\r\n */\r\n async getAvailableCommentaries(\r\n endpoint?: string\r\n ): Promise<ApiAvailableTranslations> {\r\n return this._getJson<ApiAvailableTranslations>(\r\n 'api/available_commentaries.json',\r\n endpoint\r\n );\r\n }\r\n\r\n /**\r\n * Gets the list of available datasets from the API.\r\n * @param endpoint The API endpoint to use for the request. If not provided, the default endpoint will be used.\r\n */\r\n async getAvailableDatasets(\r\n endpoint?: string\r\n ): Promise<ApiAvailableDatasets> {\r\n return this._getJson<ApiAvailableDatasets>(\r\n 'api/available_datasets.json',\r\n endpoint\r\n );\r\n }\r\n\r\n /**\r\n * Gets the list of books for a given Bible translation.\r\n * @param translation The ID of the translation to get the books for.\r\n * @param endpoint The API endpoint to use for the request. If not provided, the default endpoint will be used.\r\n */\r\n async getTranslationBooks(\r\n translation: string,\r\n endpoint?: string\r\n ): Promise<ApiTranslationBooks> {\r\n const encodedTranslation = encodeURIComponent(translation);\r\n return this._getJson<ApiTranslationBooks>(\r\n `api/${encodedTranslation}/books.json`,\r\n endpoint\r\n );\r\n }\r\n\r\n /**\r\n * Gets the list of books for a given Bible commentary.\r\n * @param commentary The ID of the commentary to get the books for.\r\n * @param endpoint The API endpoint to use for the request. If not provided, the default endpoint will be used.\r\n */\r\n async getCommentaryBooks(\r\n commentary: string,\r\n endpoint?: string\r\n ): Promise<ApiTranslationBooks> {\r\n const encodedCommentary = encodeURIComponent(commentary);\r\n return this._getJson<ApiTranslationBooks>(\r\n `api/c/${encodedCommentary}/books.json`,\r\n endpoint\r\n );\r\n }\r\n\r\n /**\r\n * Gets the list of books for a given dataset.\r\n * @param dataset The ID of the dataset to get the books for.\r\n * @param endpoint The API endpoint to use for the request. If not provided, the default endpoint will be used.\r\n */\r\n async getDatasetBooks(\r\n dataset: string,\r\n endpoint?: string\r\n ): Promise<ApiDatasetBooks> {\r\n const encodedDataset = encodeURIComponent(dataset);\r\n return this._getJson<ApiDatasetBooks>(\r\n `api/d/${encodedDataset}/books.json`,\r\n endpoint\r\n );\r\n }\r\n\r\n /**\r\n * Gets the content of a specific chapter of a specific book for a specific Bible translation.\r\n * @param translation The ID of the translation to get the chapter for.\r\n * @param book The ID of the book to get the chapter for.\r\n * @param chapter The chapter number to get.\r\n * @param endpoint The API endpoint to use for the request. If not provided, the default endpoint will be used.\r\n */\r\n async getTranslationBookChapter(\r\n translation: string,\r\n book: string,\r\n chapter: number | string,\r\n endpoint?: string\r\n ): Promise<ApiTranslationBookChapter> {\r\n const encodedTranslation = encodeURIComponent(translation);\r\n const encodedBook = encodeURIComponent(book);\r\n const encodedChapter = encodeURIComponent(String(chapter));\r\n return this._getJson<ApiTranslationBookChapter>(\r\n `api/${encodedTranslation}/${encodedBook}/${encodedChapter}.json`,\r\n endpoint\r\n );\r\n }\r\n\r\n /**\r\n * Gets the word-level annotations (Strong's numbers and related source data) for a specific chapter of a specific book for a specific Bible translation.\r\n *\r\n * Only some translations have word-level annotations. This request will fail for chapters that don't have any.\r\n * Use `getChapterWords()` to get the annotations for a chapter that you have already loaded, which returns null instead of failing.\r\n * @param translation The ID of the translation to get the annotations for.\r\n * @param book The ID of the book to get the annotations for.\r\n * @param chapter The chapter number to get the annotations for.\r\n * @param endpoint The API endpoint to use for the request. If not provided, the default endpoint will be used.\r\n */\r\n async getTranslationBookChapterWords(\r\n translation: string,\r\n book: string,\r\n chapter: number | string,\r\n endpoint?: string\r\n ): Promise<ApiTranslationBookChapterWords> {\r\n const encodedTranslation = encodeURIComponent(translation);\r\n const encodedBook = encodeURIComponent(book);\r\n const encodedChapter = encodeURIComponent(String(chapter));\r\n return this._getJson<ApiTranslationBookChapterWords>(\r\n `api/${encodedTranslation}/${encodedBook}/${encodedChapter}.words.json`,\r\n endpoint\r\n );\r\n }\r\n\r\n /**\r\n * Gets the word-level annotations for the given chapter, if it has any.\r\n * @param chapter The chapter to get the annotations for.\r\n * @param endpoint The API endpoint to use for the request. If not provided, the default endpoint will be used.\r\n * @returns The annotations for the chapter, or null if the chapter doesn't have any.\r\n */\r\n async getChapterWords(\r\n chapter: ApiTranslationBookChapter,\r\n endpoint?: string\r\n ): Promise<ApiTranslationBookChapterWords | null> {\r\n if (!chapter.thisChapterWordsLink) {\r\n return null;\r\n }\r\n return this._getJson<ApiTranslationBookChapterWords>(\r\n chapter.thisChapterWordsLink,\r\n endpoint\r\n );\r\n }\r\n\r\n /**\r\n * Gets the content of a specific chapter of a specific book for a specific Bible translation, using the simplified chapter format.\r\n *\r\n * In the simplified format, each verse's content is a single string instead of a list of formatted content, and footnotes, inline headings, the Words of Jesus, and poetry are represented as offset ranges into that string.\r\n * @param translation The ID of the translation to get the chapter for.\r\n * @param book The ID of the book to get the chapter for.\r\n * @param chapter The chapter number to get.\r\n * @param endpoint The API endpoint to use for the request. If not provided, the default endpoint will be used.\r\n */\r\n async getSimpleTranslationBookChapter(\r\n translation: string,\r\n book: string,\r\n chapter: number | string,\r\n endpoint?: string\r\n ): Promise<ApiSimpleTranslationBookChapter> {\r\n const encodedTranslation = encodeURIComponent(translation);\r\n const encodedBook = encodeURIComponent(book);\r\n const encodedChapter = encodeURIComponent(String(chapter));\r\n return this._getJson<ApiSimpleTranslationBookChapter>(\r\n `api/${encodedTranslation}/${encodedBook}/${encodedChapter}.simple.json`,\r\n endpoint\r\n );\r\n }\r\n\r\n /**\r\n * Gets the word-level annotations (Strong's numbers and related source data) for a specific chapter of a specific book for a specific Bible translation, with their offsets remapped onto the text of each simplified verse.\r\n *\r\n * Use this instead of `getTranslationBookChapterWords()` when working with the simplified chapter format, since the offsets in the regular annotations are anchored to a verse's content array instead of its plain text.\r\n * Use `getSimpleChapterWords()` to get the annotations for a simplified chapter that you have already loaded, which returns null instead of failing.\r\n * @param translation The ID of the translation to get the annotations for.\r\n * @param book The ID of the book to get the annotations for.\r\n * @param chapter The chapter number to get the annotations for.\r\n * @param endpoint The API endpoint to use for the request. If not provided, the default endpoint will be used.\r\n */\r\n async getSimpleTranslationBookChapterWords(\r\n translation: string,\r\n book: string,\r\n chapter: number | string,\r\n endpoint?: string\r\n ): Promise<ApiSimpleTranslationBookChapterWords> {\r\n const encodedTranslation = encodeURIComponent(translation);\r\n const encodedBook = encodeURIComponent(book);\r\n const encodedChapter = encodeURIComponent(String(chapter));\r\n return this._getJson<ApiSimpleTranslationBookChapterWords>(\r\n `api/${encodedTranslation}/${encodedBook}/${encodedChapter}.words.simple.json`,\r\n endpoint\r\n );\r\n }\r\n\r\n /**\r\n * Gets the simplified version of a given chapter, if available.\r\n * @param chapter The chapter to get the simplified version of.\r\n * @param endpoint The API endpoint to use for the request. If not provided, the default endpoint will be used.\r\n * @returns The simplified chapter, or null if simplified chapters aren't available for it.\r\n */\r\n getSimpleChapter(\r\n chapter: ApiCommentaryBookChapter,\r\n endpoint?: string\r\n ): Promise<ApiSimpleCommentaryBookChapter | null>;\r\n /**\r\n * Gets the simplified version of a given chapter, if available.\r\n * @param chapter The chapter to get the simplified version of.\r\n * @param endpoint The API endpoint to use for the request. If not provided, the default endpoint will be used.\r\n * @returns The simplified chapter, or null if simplified chapters aren't available for it.\r\n */\r\n getSimpleChapter(\r\n chapter: ApiTranslationBookChapter,\r\n endpoint?: string\r\n ): Promise<ApiSimpleTranslationBookChapter | null>;\r\n async getSimpleChapter(\r\n chapter: ApiTranslationBookChapter | ApiCommentaryBookChapter,\r\n endpoint?: string\r\n ): Promise<\r\n ApiSimpleTranslationBookChapter | ApiSimpleCommentaryBookChapter | null\r\n > {\r\n if (!chapter.simpleChapterApiLink) {\r\n return null;\r\n }\r\n return this._getJson<\r\n ApiSimpleTranslationBookChapter | ApiSimpleCommentaryBookChapter\r\n >(chapter.simpleChapterApiLink, endpoint);\r\n }\r\n\r\n /**\r\n * Gets the word-level annotations for the given simplified chapter, if it has any.\r\n * @param chapter The simplified chapter to get the annotations for.\r\n * @param endpoint The API endpoint to use for the request. If not provided, the default endpoint will be used.\r\n * @returns The annotations for the chapter, or null if the chapter doesn't have any.\r\n */\r\n async getSimpleChapterWords(\r\n chapter: ApiSimpleTranslationBookChapter,\r\n endpoint?: string\r\n ): Promise<ApiSimpleTranslationBookChapterWords | null> {\r\n if (!chapter.thisChapterWordsLink) {\r\n return null;\r\n }\r\n return this._getJson<ApiSimpleTranslationBookChapterWords>(\r\n chapter.thisChapterWordsLink,\r\n endpoint\r\n );\r\n }\r\n\r\n /**\r\n * Gets the content of a specific chapter of a specific book for a specific Bible commentary.\r\n * @param commentary The ID of the commentary to get the chapter for.\r\n * @param book The ID of the book to get the chapter for.\r\n * @param chapter The chapter number to get.\r\n * @param endpoint The API endpoint to use for the request. If not provided, the default endpoint will be used.\r\n */\r\n async getCommentaryBookChapter(\r\n commentary: string,\r\n book: string,\r\n chapter: number | string,\r\n endpoint?: string\r\n ): Promise<ApiTranslationBookChapter> {\r\n const encodedCommentary = encodeURIComponent(commentary);\r\n const encodedBook = encodeURIComponent(book);\r\n const encodedChapter = encodeURIComponent(String(chapter));\r\n return this._getJson<ApiTranslationBookChapter>(\r\n `api/c/${encodedCommentary}/${encodedBook}/${encodedChapter}.json`,\r\n endpoint\r\n );\r\n }\r\n\r\n /**\r\n * Gets the content of a specific chapter of a specific book for a specific Bible commentary, using the simplified chapter format.\r\n * @param commentary The ID of the commentary to get the chapter for.\r\n * @param book The ID of the book to get the chapter for.\r\n * @param chapter The chapter number to get.\r\n * @param endpoint The API endpoint to use for the request. If not provided, the default endpoint will be used.\r\n */\r\n async getSimpleCommentaryBookChapter(\r\n commentary: string,\r\n book: string,\r\n chapter: number | string,\r\n endpoint?: string\r\n ): Promise<ApiSimpleCommentaryBookChapter> {\r\n const encodedCommentary = encodeURIComponent(commentary);\r\n const encodedBook = encodeURIComponent(book);\r\n const encodedChapter = encodeURIComponent(String(chapter));\r\n return this._getJson<ApiSimpleCommentaryBookChapter>(\r\n `api/c/${encodedCommentary}/${encodedBook}/${encodedChapter}.simple.json`,\r\n endpoint\r\n );\r\n }\r\n\r\n /**\r\n * Gets the content of a specific chapter of a specific book for a specific dataset.\r\n * @param dataset The ID of the dataset to get the chapter for.\r\n * @param book The ID of the book to get the chapter for.\r\n * @param chapter The chapter number to get.\r\n * @param endpoint The API endpoint to use for the request. If not provided, the default endpoint will be used.\r\n */\r\n async getDatasetBookChapter(\r\n dataset: string,\r\n book: string,\r\n chapter: number | string,\r\n endpoint?: string\r\n ): Promise<ApiDatasetBookChapter> {\r\n const encodedDataset = encodeURIComponent(dataset);\r\n const encodedBook = encodeURIComponent(book);\r\n const encodedChapter = encodeURIComponent(String(chapter));\r\n return this._getJson<ApiDatasetBookChapter>(\r\n `api/d/${encodedDataset}/${encodedBook}/${encodedChapter}.json`,\r\n endpoint\r\n );\r\n }\r\n\r\n /**\r\n * Gets the next chapter for a given chapter, if available.\r\n * @param chapter The chapter to get the next chapter for.\r\n * @param endpoint The API endpoint to use for the request. If not provided, the default endpoint will be used.\r\n * @returns The next chapter, or null if there is no next chapter.\r\n */\r\n getNextChapter(\r\n chapter: ApiCommentaryBookChapter,\r\n endpoint?: string\r\n ): Promise<ApiCommentaryBookChapter | null>;\r\n /**\r\n * Gets the next chapter for a given chapter, if available.\r\n * @param chapter The chapter to get the next chapter for.\r\n * @param endpoint The API endpoint to use for the request. If not provided, the default endpoint will be used.\r\n * @returns The next chapter, or null if there is no next chapter.\r\n */\r\n getNextChapter(\r\n chapter: ApiTranslationBookChapter,\r\n endpoint?: string\r\n ): Promise<ApiTranslationBookChapter | null>;\r\n /**\r\n * Gets the next chapter for a given chapter, if available.\r\n * @param chapter The chapter to get the next chapter for.\r\n * @param endpoint The API endpoint to use for the request. If not provided, the default endpoint will be used.\r\n * @returns The next chapter, or null if there is no next chapter.\r\n */\r\n getNextChapter(\r\n chapter: ApiDatasetBookChapter,\r\n endpoint?: string\r\n ): Promise<ApiDatasetBookChapter | null>;\r\n /**\r\n * Gets the next chapter for a given chapter, if available.\r\n * @param chapter The chapter to get the next chapter for.\r\n * @param endpoint The API endpoint to use for the request. If not provided, the default endpoint will be used.\r\n * @returns The next chapter, or null if there is no next chapter.\r\n */\r\n getNextChapter(\r\n chapter: ApiSimpleCommentaryBookChapter,\r\n endpoint?: string\r\n ): Promise<ApiSimpleCommentaryBookChapter | null>;\r\n /**\r\n * Gets the next chapter for a given chapter, if available.\r\n * @param chapter The chapter to get the next chapter for.\r\n * @param endpoint The API endpoint to use for the request. If not provided, the default endpoint will be used.\r\n * @returns The next chapter, or null if there is no next chapter.\r\n */\r\n getNextChapter(\r\n chapter: ApiSimpleTranslationBookChapter,\r\n endpoint?: string\r\n ): Promise<ApiSimpleTranslationBookChapter | null>;\r\n async getNextChapter(\r\n chapter:\r\n | ApiTranslationBookChapter\r\n | ApiCommentaryBookChapter\r\n | ApiDatasetBookChapter\r\n | ApiSimpleTranslationBookChapter\r\n | ApiSimpleCommentaryBookChapter,\r\n endpoint?: string\r\n ): Promise<\r\n | ApiTranslationBookChapter\r\n | ApiCommentaryBookChapter\r\n | ApiDatasetBookChapter\r\n | ApiSimpleTranslationBookChapter\r\n | ApiSimpleCommentaryBookChapter\r\n | null\r\n > {\r\n if (!chapter.nextChapterApiLink) {\r\n return null;\r\n }\r\n return this._getJson<\r\n | ApiTranslationBookChapter\r\n | ApiCommentaryBookChapter\r\n | ApiDatasetBookChapter\r\n | ApiSimpleTranslationBookChapter\r\n | ApiSimpleCommentaryBookChapter\r\n >(chapter.nextChapterApiLink, endpoint);\r\n }\r\n\r\n /**\r\n * Gets the previous chapter for a given chapter, if available.\r\n * @param chapter The chapter to get the previous chapter for.\r\n * @param endpoint The API endpoint to use for the request. If not provided, the default endpoint will be used.\r\n * @returns The previous chapter, or null if there is no previous chapter.\r\n */\r\n getPreviousChapter(\r\n chapter: ApiCommentaryBookChapter,\r\n endpoint?: string\r\n ): Promise<ApiCommentaryBookChapter | null>;\r\n /**\r\n * Gets the previous chapter for a given chapter, if available.\r\n * @param chapter The chapter to get the previous chapter for.\r\n * @param endpoint The API endpoint to use for the request. If not provided, the default endpoint will be used.\r\n * @returns The previous chapter, or null if there is no previous chapter.\r\n */\r\n getPreviousChapter(\r\n chapter: ApiTranslationBookChapter,\r\n endpoint?: string\r\n ): Promise<ApiTranslationBookChapter | null>;\r\n /**\r\n * Gets the previous chapter for a given chapter, if available.\r\n * @param chapter The chapter to get the previous chapter for.\r\n * @param endpoint The API endpoint to use for the request. If not provided, the default endpoint will be used.\r\n * @returns The previous chapter, or null if there is no previous chapter.\r\n */\r\n getPreviousChapter(\r\n chapter: ApiDatasetBookChapter,\r\n endpoint?: string\r\n ): Promise<ApiDatasetBookChapter | null>;\r\n /**\r\n * Gets the previous chapter for a given chapter, if available.\r\n * @param chapter The chapter to get the previous chapter for.\r\n * @param endpoint The API endpoint to use for the request. If not provided, the default endpoint will be used.\r\n * @returns The previous chapter, or null if there is no previous chapter.\r\n */\r\n getPreviousChapter(\r\n chapter: ApiSimpleCommentaryBookChapter,\r\n endpoint?: string\r\n ): Promise<ApiSimpleCommentaryBookChapter | null>;\r\n /**\r\n * Gets the previous chapter for a given chapter, if available.\r\n * @param chapter The chapter to get the previous chapter for.\r\n * @param endpoint The API endpoint to use for the request. If not provided, the default endpoint will be used.\r\n * @returns The previous chapter, or null if there is no previous chapter.\r\n */\r\n getPreviousChapter(\r\n chapter: ApiSimpleTranslationBookChapter,\r\n endpoint?: string\r\n ): Promise<ApiSimpleTranslationBookChapter | null>;\r\n async getPreviousChapter(\r\n chapter:\r\n | ApiTranslationBookChapter\r\n | ApiCommentaryBookChapter\r\n | ApiDatasetBookChapter\r\n | ApiSimpleTranslationBookChapter\r\n | ApiSimpleCommentaryBookChapter,\r\n endpoint?: string\r\n ): Promise<\r\n | ApiTranslationBookChapter\r\n | ApiCommentaryBookChapter\r\n | ApiDatasetBookChapter\r\n | ApiSimpleTranslationBookChapter\r\n | ApiSimpleCommentaryBookChapter\r\n | null\r\n > {\r\n if (!chapter.previousChapterApiLink) {\r\n return null;\r\n }\r\n return this._getJson<\r\n | ApiTranslationBookChapter\r\n | ApiCommentaryBookChapter\r\n | ApiDatasetBookChapter\r\n | ApiSimpleTranslationBookChapter\r\n | ApiSimpleCommentaryBookChapter\r\n >(chapter.previousChapterApiLink, endpoint);\r\n }\r\n\r\n /**\r\n * Gets the first chapter for a given book, if available.\r\n * @param book The book to get the first chapter for.\r\n * @param endpoint The API endpoint to use for the request. If not provided, the default endpoint will be used.\r\n * @returns The first chapter, or null if there is no first chapter.\r\n */\r\n getFirstChapter(\r\n book: ApiCommentaryBook,\r\n endpoint?: string\r\n ): Promise<ApiCommentaryBookChapter | null>;\r\n /**\r\n * Gets the first chapter for a given book, if available.\r\n * @param book The book to get the first chapter for.\r\n * @param endpoint The API endpoint to use for the request. If not provided, the default endpoint will be used.\r\n * @returns The first chapter, or null if there is no first chapter.\r\n */\r\n getFirstChapter(\r\n book: ApiTranslationBook,\r\n endpoint?: string\r\n ): Promise<ApiTranslationBookChapter>;\r\n /**\r\n * Gets the first chapter for a given book, if available.\r\n * @param book The book to get the first chapter for.\r\n * @param endpoint The API endpoint to use for the request. If not provided, the default endpoint will be used.\r\n * @returns The first chapter, or null if there is no first chapter.\r\n */\r\n getFirstChapter(\r\n book: ApiDatasetBook,\r\n endpoint?: string\r\n ): Promise<ApiDatasetBookChapter>;\r\n async getFirstChapter(\r\n book: ApiTranslationBook | ApiCommentaryBook | ApiDatasetBook,\r\n endpoint?: string\r\n ): Promise<\r\n | ApiTranslationBookChapter\r\n | ApiCommentaryBookChapter\r\n | ApiDatasetBookChapter\r\n | null\r\n > {\r\n if (!book.firstChapterApiLink) {\r\n return null;\r\n }\r\n return this._getJson<\r\n | ApiTranslationBookChapter\r\n | ApiCommentaryBookChapter\r\n | ApiDatasetBookChapter\r\n >(book.firstChapterApiLink, endpoint);\r\n }\r\n\r\n /**\r\n * Gets the last chapter for a given book, if available.\r\n * @param book The book to get the last chapter for.\r\n * @param endpoint The API endpoint to use for the request. If not provided, the default endpoint will be used.\r\n * @returns The last chapter, or null if there is no last chapter.\r\n */\r\n getLastChapter(\r\n book: ApiCommentaryBook,\r\n endpoint?: string\r\n ): Promise<ApiCommentaryBookChapter | null>;\r\n /**\r\n * Gets the last chapter for a given book, if available.\r\n * @param book The book to get the last chapter for.\r\n * @param endpoint The API endpoint to use for the request. If not provided, the default endpoint will be used.\r\n * @returns The last chapter, or null if there is no last chapter.\r\n */\r\n getLastChapter(\r\n book: ApiTranslationBook,\r\n endpoint?: string\r\n ): Promise<ApiTranslationBookChapter>;\r\n /**\r\n * Gets the last chapter for a given book, if available.\r\n * @param book The book to get the last chapter for.\r\n * @param endpoint The API endpoint to use for the request. If not provided, the default endpoint will be used.\r\n * @returns The last chapter, or null if there is no last chapter.\r\n */\r\n getLastChapter(\r\n book: ApiDatasetBook,\r\n endpoint?: string\r\n ): Promise<ApiDatasetBookChapter>;\r\n async getLastChapter(\r\n book: ApiTranslationBook | ApiCommentaryBook | ApiDatasetBook,\r\n endpoint?: string\r\n ): Promise<\r\n | ApiTranslationBookChapter\r\n | ApiCommentaryBookChapter\r\n | ApiDatasetBookChapter\r\n | null\r\n > {\r\n if (!book.lastChapterApiLink) {\r\n return null;\r\n }\r\n return this._getJson<\r\n | ApiTranslationBookChapter\r\n | ApiCommentaryBookChapter\r\n | ApiDatasetBookChapter\r\n >(book.lastChapterApiLink, endpoint);\r\n }\r\n\r\n /**\r\n * Formats a verse reference as a human-readable string.\r\n *\r\n * e.g. Genesis 1:1-2, John 3:16, Exodus 20-22, etc.\r\n *\r\n * @param book The book that the reference is for.\r\n * @param reference The reference to format.\r\n */\r\n formatReference(\r\n book: ApiTranslationBook,\r\n reference: VerseReference\r\n ): string {\r\n const bookName = book.name;\r\n const chapter = reference.chapter;\r\n const verse = reference.verse;\r\n const endChapter = reference.endChapter;\r\n const endVerse = reference.endVerse;\r\n\r\n let referenceStr = `${bookName} ${chapter}`;\r\n if (endChapter) {\r\n referenceStr += `-${endChapter}`;\r\n } else if (verse) {\r\n referenceStr += `:${verse}`;\r\n if (endVerse) {\r\n referenceStr += `-${endVerse}`;\r\n }\r\n }\r\n return referenceStr;\r\n }\r\n\r\n /**\r\n * Gets the text for a verse.\r\n * @param verse The verse to get the text for.\r\n * @param options Options for getting the verse text.\r\n */\r\n getVerseText(verse: ChapterVerse): string {\r\n let content = '';\r\n for (let part of verse.content) {\r\n if (typeof part === 'string') {\r\n content += part;\r\n } else if (typeof part === 'object' && 'text' in part) {\r\n if (part.poem) {\r\n content += '\\n';\r\n for (let i = 0; i < part.poem; i++) {\r\n content += '\\t';\r\n }\r\n }\r\n content += part.text;\r\n } else if (typeof part === 'object' && 'lineBreak' in part) {\r\n content += '\\n';\r\n } else if (typeof part === 'object') {\r\n content += ' ';\r\n }\r\n }\r\n return content.trim();\r\n }\r\n\r\n /**\r\n * Gets the verse text for the given chapter.\r\n * By default, the returned text includes markers for verse numbers and a reference to the chapter, but these can be omitted by passing options to the `options` parameter.\r\n * @param chapter The chapter to get the text for.\r\n * @param options Options for getting the chapter text.\r\n */\r\n getChapterVerseText(\r\n chapter: ApiTranslationBookChapter,\r\n options: GetChapterTextOptions = {}\r\n ): string {\r\n let content = '';\r\n for (let chapterContent of chapter.chapter.content) {\r\n if (chapterContent.type === 'verse') {\r\n if (!options.omitVerseNumbers) {\r\n content += `[${chapterContent.number}] `;\r\n }\r\n content += this.getVerseText(chapterContent) + ' ';\r\n } else if (chapterContent.type === 'line_break') {\r\n content = content.trim() + '\\n';\r\n }\r\n }\r\n\r\n if (!options.omitReference) {\r\n content = `${this.formatReference(chapter.book, {\r\n chapter: chapter.chapter.number,\r\n })}\\n${content.trim()}`;\r\n }\r\n\r\n return content.trim();\r\n }\r\n\r\n /**\r\n * Gets the verse text for the given simplified chapter.\r\n * By default, the returned text includes markers for verse numbers and a reference to the chapter, but these can be omitted by passing options to the `options` parameter.\r\n * @param chapter The simplified chapter to get the text for.\r\n * @param options Options for getting the chapter text.\r\n */\r\n getSimpleChapterVerseText(\r\n chapter: ApiSimpleTranslationBookChapter,\r\n options: GetChapterTextOptions = {}\r\n ): string {\r\n let content = '';\r\n for (let chapterContent of chapter.chapter.content) {\r\n if (chapterContent.type === 'verse') {\r\n if (!options.omitVerseNumbers) {\r\n content += `[${chapterContent.number}] `;\r\n }\r\n content += chapterContent.text.trim() + ' ';\r\n } else if (chapterContent.type === 'line_break') {\r\n content = content.trim() + '\\n';\r\n }\r\n }\r\n\r\n if (!options.omitReference) {\r\n content = `${this.formatReference(chapter.book, {\r\n chapter: chapter.chapter.number,\r\n })}\\n${content.trim()}`;\r\n }\r\n\r\n return content.trim();\r\n }\r\n\r\n /**\r\n * Gets the text that the given word-level annotation applies to.\r\n *\r\n * Annotations are anchored to a range of characters in a single item of the verse's content,\r\n * so that the ranges stay correct for verses whose content is split into multiple items,\r\n * such as poem lines and the words of Jesus.\r\n * @param verse The verse that the annotation is in.\r\n * @param word The annotation to get the text for.\r\n * @returns The annotated text, or an empty string if the annotation doesn't point at any text.\r\n */\r\n getWordText(verse: ChapterVerse, word: ChapterWord): string {\r\n const content = verse.content[word.contentIndex];\r\n\r\n if (typeof content === 'string') {\r\n return content.slice(word.start, word.end);\r\n } else if (\r\n typeof content === 'object' &&\r\n content !== null &&\r\n 'text' in content\r\n ) {\r\n return content.text.slice(word.start, word.end);\r\n }\r\n\r\n // Line breaks, inline headings, and footnote references have no text of their own.\r\n return '';\r\n }\r\n\r\n /**\r\n * Gets the word-level annotations for the given verse, paired with the text that each one applies to.\r\n * @param verse The verse to get the annotations for.\r\n * @param words The annotations for the chapter that the verse is in.\r\n * @returns The annotations for the verse, in the order that they occur. Empty if the verse has no annotations.\r\n */\r\n getVerseWords(\r\n verse: ChapterVerse,\r\n words: ApiTranslationBookChapterWords\r\n ): AnnotatedWord[] {\r\n const verseWords = words.verses[verse.number.toString()] ?? [];\r\n\r\n return verseWords.map((word) => ({\r\n ...word,\r\n text: this.getWordText(verse, word),\r\n }));\r\n }\r\n\r\n /**\r\n * Gets the text that the given simplified word-level annotation applies to.\r\n * @param verse The simplified verse that the annotation is in.\r\n * @param word The annotation to get the text for.\r\n * @returns The annotated text.\r\n */\r\n getSimpleWordText(\r\n verse: SimpleChapterVerse,\r\n word: SimpleChapterWord\r\n ): string {\r\n return verse.text.slice(word.start, word.end);\r\n }\r\n\r\n /**\r\n * Gets the word-level annotations for the given simplified verse, paired with the text that each one applies to.\r\n * @param verse The simplified verse to get the annotations for.\r\n * @param words The simplified annotations for the chapter that the verse is in.\r\n * @returns The annotations for the verse, in the order that they occur. Empty if the verse has no annotations.\r\n */\r\n getSimpleVerseWords(\r\n verse: SimpleChapterVerse,\r\n words: ApiSimpleTranslationBookChapterWords\r\n ): SimpleAnnotatedWord[] {\r\n const verseWords = words.verses[verse.number.toString()] ?? [];\r\n\r\n return verseWords.map((word) => ({\r\n ...word,\r\n text: this.getSimpleWordText(verse, word),\r\n }));\r\n }\r\n\r\n private _getJson<T>(\r\n path: string,\r\n endpoint: string | undefined,\r\n useCache: boolean = true\r\n ): Promise<T> {\r\n const url = this._buildUrl(path, endpoint);\r\n const existing = this._responseCache.get(url) as Promise<T> | undefined;\r\n if (existing) {\r\n return existing;\r\n }\r\n\r\n const request: Promise<T> = fetch(url)\r\n .then(async (response) => {\r\n if (response.status < 200 || response.status >= 300) {\r\n throw new Error(\r\n `Failed request to ${url}. Status: ${response.status} ${response.statusText}`\r\n );\r\n }\r\n return await response.json();\r\n })\r\n .catch((error) => {\r\n this._responseCache.delete(url);\r\n throw error;\r\n });\r\n\r\n if (this._useCache && useCache) {\r\n this._responseCache.set(url, request);\r\n }\r\n return request;\r\n }\r\n\r\n private _buildUrl(path: string, endpoint?: string): string {\r\n if (/^https?:\\/\\//i.test(path)) {\r\n return path;\r\n }\r\n\r\n const baseEndpoint = endpoint ?? this.endpoint;\r\n return new URL(path, baseEndpoint).href;\r\n }\r\n}\r\n"],
5
+ "mappings": ";AAuHO,aAAM,gBAAgB;AAAA,EACzB,WAAmB;AAAA,EACX,iBAAiB,oBAAI,IAA8B;AAAA,EACnD,YAAqB;AAAA,EAE7B,YAAY,SAAkC;AAC1C,SAAK,WAAW,SAAS,YAAY,KAAK;AAC1C,SAAK,YAAY,SAAS,YAAY,KAAK;AAAA,EAC/C;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,yBACF,UACiC;AACjC,WAAO,KAAK;AAAA,MACR;AAAA,MACA;AAAA,IACJ;AAAA,EACJ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,MAAM,uBACF,aACA,UAC+B;AAC/B,UAAM,qBAAqB,mBAAmB,WAAW;AACzD,WAAO,KAAK;AAAA,MACR,OAAO,kBAAkB;AAAA,MACzB;AAAA,MACA;AAAA,IACJ;AAAA,EACJ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,MAAM,6BACF,aACA,UACqC;AACrC,UAAM,qBAAqB,mBAAmB,WAAW;AACzD,WAAO,KAAK;AAAA,MACR,OAAO,kBAAkB;AAAA,MACzB;AAAA,MACA;AAAA,IACJ;AAAA,EACJ;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,yBACF,UACiC;AACjC,WAAO,KAAK;AAAA,MACR;AAAA,MACA;AAAA,IACJ;AAAA,EACJ;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,qBACF,UAC6B;AAC7B,WAAO,KAAK;AAAA,MACR;AAAA,MACA;AAAA,IACJ;AAAA,EACJ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,oBACF,aACA,UAC4B;AAC5B,UAAM,qBAAqB,mBAAmB,WAAW;AACzD,WAAO,KAAK;AAAA,MACR,OAAO,kBAAkB;AAAA,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;AAC5B,WAAK,eAAe,IAAI,KAAK,OAAO;AAAA,IACxC;AACA,WAAO;AAAA,EACX;AAAA,EAEQ,UAAU,MAAc,UAA2B;AACvD,QAAI,gBAAgB,KAAK,IAAI,GAAG;AAC5B,aAAO;AAAA,IACX;AAEA,UAAM,eAAe,YAAY,KAAK;AACtC,WAAO,IAAI,IAAI,MAAM,YAAY,EAAE;AAAA,EACvC;AACJ;",
6
6
  "names": []
7
7
  }
@@ -1,4 +1,4 @@
1
- import type { ApiAvailableDatasets, ApiAvailableTranslations, ApiCommentaryBook, ApiCommentaryBookChapter, ApiDatasetBook, ApiDatasetBookChapter, ApiDatasetBooks, ApiTranslationBook, ApiTranslationBookChapter, ApiTranslationBooks, ApiTranslationComplete, ChapterVerse } from './types.gen.js';
1
+ import type { ApiAvailableDatasets, ApiAvailableTranslations, ApiCommentaryBook, ApiCommentaryBookChapter, ApiDatasetBook, ApiDatasetBookChapter, ApiDatasetBooks, ApiSimpleCommentaryBookChapter, ApiSimpleTranslationBookChapter, ApiSimpleTranslationBookChapterWords, ApiSimpleTranslationComplete, ApiTranslationBook, ApiTranslationBookChapter, ApiTranslationBookChapterWords, ApiTranslationBooks, ApiTranslationComplete, ChapterVerse, ChapterWord, SimpleChapterVerse, SimpleChapterWord } from './types.gen.js';
2
2
  /**
3
3
  * Options for the FreeUseBibleApi class.
4
4
  */
@@ -37,6 +37,24 @@ export interface GetVerseTextOptions {
37
37
  */
38
38
  omitReference?: boolean;
39
39
  }
40
+ /**
41
+ * A word-level annotation, paired with the text of the verse that it covers.
42
+ */
43
+ export interface AnnotatedWord extends ChapterWord {
44
+ /**
45
+ * The text that the annotation applies to.
46
+ */
47
+ text: string;
48
+ }
49
+ /**
50
+ * A word-level annotation in a simplified chapter, paired with the text of the verse that it covers.
51
+ */
52
+ export interface SimpleAnnotatedWord extends SimpleChapterWord {
53
+ /**
54
+ * The text that the annotation applies to.
55
+ */
56
+ text: string;
57
+ }
40
58
  /**
41
59
  * A reference to a specific verse in a Bible translation, commentary, or dataset.
42
60
  */
@@ -83,6 +101,14 @@ export declare class FreeUseBibleApi {
83
101
  * @param endpoint The API endpoint to use for the request. If not provided, the default endpoint will be used.
84
102
  */
85
103
  getCompleteTranslation(translation: string, endpoint?: string): Promise<ApiTranslationComplete>;
104
+ /**
105
+ * Gets the complete content of a specific Bible translation, using the simplified chapter format.
106
+ *
107
+ * The results of this endpoint are very large, so the response is not cached.
108
+ * @param translation The ID of the translation to get the complete content for.
109
+ * @param endpoint The API endpoint to use for the request. If not provided, the default endpoint will be used.
110
+ */
111
+ getSimpleCompleteTranslation(translation: string, endpoint?: string): Promise<ApiSimpleTranslationComplete>;
86
112
  /**
87
113
  * Gets the list of available Bible commentaries from the API.
88
114
  * @param endpoint The API endpoint to use for the request. If not provided, the default endpoint will be used.
@@ -119,6 +145,66 @@ export declare class FreeUseBibleApi {
119
145
  * @param endpoint The API endpoint to use for the request. If not provided, the default endpoint will be used.
120
146
  */
121
147
  getTranslationBookChapter(translation: string, book: string, chapter: number | string, endpoint?: string): Promise<ApiTranslationBookChapter>;
148
+ /**
149
+ * Gets the word-level annotations (Strong's numbers and related source data) for a specific chapter of a specific book for a specific Bible translation.
150
+ *
151
+ * Only some translations have word-level annotations. This request will fail for chapters that don't have any.
152
+ * Use `getChapterWords()` to get the annotations for a chapter that you have already loaded, which returns null instead of failing.
153
+ * @param translation The ID of the translation to get the annotations for.
154
+ * @param book The ID of the book to get the annotations for.
155
+ * @param chapter The chapter number to get the annotations for.
156
+ * @param endpoint The API endpoint to use for the request. If not provided, the default endpoint will be used.
157
+ */
158
+ getTranslationBookChapterWords(translation: string, book: string, chapter: number | string, endpoint?: string): Promise<ApiTranslationBookChapterWords>;
159
+ /**
160
+ * Gets the word-level annotations for the given chapter, if it has any.
161
+ * @param chapter The chapter to get the annotations for.
162
+ * @param endpoint The API endpoint to use for the request. If not provided, the default endpoint will be used.
163
+ * @returns The annotations for the chapter, or null if the chapter doesn't have any.
164
+ */
165
+ getChapterWords(chapter: ApiTranslationBookChapter, endpoint?: string): Promise<ApiTranslationBookChapterWords | null>;
166
+ /**
167
+ * Gets the content of a specific chapter of a specific book for a specific Bible translation, using the simplified chapter format.
168
+ *
169
+ * In the simplified format, each verse's content is a single string instead of a list of formatted content, and footnotes, inline headings, the Words of Jesus, and poetry are represented as offset ranges into that string.
170
+ * @param translation The ID of the translation to get the chapter for.
171
+ * @param book The ID of the book to get the chapter for.
172
+ * @param chapter The chapter number to get.
173
+ * @param endpoint The API endpoint to use for the request. If not provided, the default endpoint will be used.
174
+ */
175
+ getSimpleTranslationBookChapter(translation: string, book: string, chapter: number | string, endpoint?: string): Promise<ApiSimpleTranslationBookChapter>;
176
+ /**
177
+ * Gets the word-level annotations (Strong's numbers and related source data) for a specific chapter of a specific book for a specific Bible translation, with their offsets remapped onto the text of each simplified verse.
178
+ *
179
+ * Use this instead of `getTranslationBookChapterWords()` when working with the simplified chapter format, since the offsets in the regular annotations are anchored to a verse's content array instead of its plain text.
180
+ * Use `getSimpleChapterWords()` to get the annotations for a simplified chapter that you have already loaded, which returns null instead of failing.
181
+ * @param translation The ID of the translation to get the annotations for.
182
+ * @param book The ID of the book to get the annotations for.
183
+ * @param chapter The chapter number to get the annotations for.
184
+ * @param endpoint The API endpoint to use for the request. If not provided, the default endpoint will be used.
185
+ */
186
+ getSimpleTranslationBookChapterWords(translation: string, book: string, chapter: number | string, endpoint?: string): Promise<ApiSimpleTranslationBookChapterWords>;
187
+ /**
188
+ * Gets the simplified version of a given chapter, if available.
189
+ * @param chapter The chapter to get the simplified version of.
190
+ * @param endpoint The API endpoint to use for the request. If not provided, the default endpoint will be used.
191
+ * @returns The simplified chapter, or null if simplified chapters aren't available for it.
192
+ */
193
+ getSimpleChapter(chapter: ApiCommentaryBookChapter, endpoint?: string): Promise<ApiSimpleCommentaryBookChapter | null>;
194
+ /**
195
+ * Gets the simplified version of a given chapter, if available.
196
+ * @param chapter The chapter to get the simplified version of.
197
+ * @param endpoint The API endpoint to use for the request. If not provided, the default endpoint will be used.
198
+ * @returns The simplified chapter, or null if simplified chapters aren't available for it.
199
+ */
200
+ getSimpleChapter(chapter: ApiTranslationBookChapter, endpoint?: string): Promise<ApiSimpleTranslationBookChapter | null>;
201
+ /**
202
+ * Gets the word-level annotations for the given simplified chapter, if it has any.
203
+ * @param chapter The simplified chapter to get the annotations for.
204
+ * @param endpoint The API endpoint to use for the request. If not provided, the default endpoint will be used.
205
+ * @returns The annotations for the chapter, or null if the chapter doesn't have any.
206
+ */
207
+ getSimpleChapterWords(chapter: ApiSimpleTranslationBookChapter, endpoint?: string): Promise<ApiSimpleTranslationBookChapterWords | null>;
122
208
  /**
123
209
  * Gets the content of a specific chapter of a specific book for a specific Bible commentary.
124
210
  * @param commentary The ID of the commentary to get the chapter for.
@@ -127,6 +213,14 @@ export declare class FreeUseBibleApi {
127
213
  * @param endpoint The API endpoint to use for the request. If not provided, the default endpoint will be used.
128
214
  */
129
215
  getCommentaryBookChapter(commentary: string, book: string, chapter: number | string, endpoint?: string): Promise<ApiTranslationBookChapter>;
216
+ /**
217
+ * Gets the content of a specific chapter of a specific book for a specific Bible commentary, using the simplified chapter format.
218
+ * @param commentary The ID of the commentary to get the chapter for.
219
+ * @param book The ID of the book to get the chapter for.
220
+ * @param chapter The chapter number to get.
221
+ * @param endpoint The API endpoint to use for the request. If not provided, the default endpoint will be used.
222
+ */
223
+ getSimpleCommentaryBookChapter(commentary: string, book: string, chapter: number | string, endpoint?: string): Promise<ApiSimpleCommentaryBookChapter>;
130
224
  /**
131
225
  * Gets the content of a specific chapter of a specific book for a specific dataset.
132
226
  * @param dataset The ID of the dataset to get the chapter for.
@@ -156,6 +250,20 @@ export declare class FreeUseBibleApi {
156
250
  * @returns The next chapter, or null if there is no next chapter.
157
251
  */
158
252
  getNextChapter(chapter: ApiDatasetBookChapter, endpoint?: string): Promise<ApiDatasetBookChapter | null>;
253
+ /**
254
+ * Gets the next chapter for a given chapter, if available.
255
+ * @param chapter The chapter to get the next chapter for.
256
+ * @param endpoint The API endpoint to use for the request. If not provided, the default endpoint will be used.
257
+ * @returns The next chapter, or null if there is no next chapter.
258
+ */
259
+ getNextChapter(chapter: ApiSimpleCommentaryBookChapter, endpoint?: string): Promise<ApiSimpleCommentaryBookChapter | null>;
260
+ /**
261
+ * Gets the next chapter for a given chapter, if available.
262
+ * @param chapter The chapter to get the next chapter for.
263
+ * @param endpoint The API endpoint to use for the request. If not provided, the default endpoint will be used.
264
+ * @returns The next chapter, or null if there is no next chapter.
265
+ */
266
+ getNextChapter(chapter: ApiSimpleTranslationBookChapter, endpoint?: string): Promise<ApiSimpleTranslationBookChapter | null>;
159
267
  /**
160
268
  * Gets the previous chapter for a given chapter, if available.
161
269
  * @param chapter The chapter to get the previous chapter for.
@@ -177,6 +285,20 @@ export declare class FreeUseBibleApi {
177
285
  * @returns The previous chapter, or null if there is no previous chapter.
178
286
  */
179
287
  getPreviousChapter(chapter: ApiDatasetBookChapter, endpoint?: string): Promise<ApiDatasetBookChapter | null>;
288
+ /**
289
+ * Gets the previous chapter for a given chapter, if available.
290
+ * @param chapter The chapter to get the previous chapter for.
291
+ * @param endpoint The API endpoint to use for the request. If not provided, the default endpoint will be used.
292
+ * @returns The previous chapter, or null if there is no previous chapter.
293
+ */
294
+ getPreviousChapter(chapter: ApiSimpleCommentaryBookChapter, endpoint?: string): Promise<ApiSimpleCommentaryBookChapter | null>;
295
+ /**
296
+ * Gets the previous chapter for a given chapter, if available.
297
+ * @param chapter The chapter to get the previous chapter for.
298
+ * @param endpoint The API endpoint to use for the request. If not provided, the default endpoint will be used.
299
+ * @returns The previous chapter, or null if there is no previous chapter.
300
+ */
301
+ getPreviousChapter(chapter: ApiSimpleTranslationBookChapter, endpoint?: string): Promise<ApiSimpleTranslationBookChapter | null>;
180
302
  /**
181
303
  * Gets the first chapter for a given book, if available.
182
304
  * @param book The book to get the first chapter for.
@@ -241,6 +363,45 @@ export declare class FreeUseBibleApi {
241
363
  * @param options Options for getting the chapter text.
242
364
  */
243
365
  getChapterVerseText(chapter: ApiTranslationBookChapter, options?: GetChapterTextOptions): string;
366
+ /**
367
+ * Gets the verse text for the given simplified chapter.
368
+ * By default, the returned text includes markers for verse numbers and a reference to the chapter, but these can be omitted by passing options to the `options` parameter.
369
+ * @param chapter The simplified chapter to get the text for.
370
+ * @param options Options for getting the chapter text.
371
+ */
372
+ getSimpleChapterVerseText(chapter: ApiSimpleTranslationBookChapter, options?: GetChapterTextOptions): string;
373
+ /**
374
+ * Gets the text that the given word-level annotation applies to.
375
+ *
376
+ * Annotations are anchored to a range of characters in a single item of the verse's content,
377
+ * so that the ranges stay correct for verses whose content is split into multiple items,
378
+ * such as poem lines and the words of Jesus.
379
+ * @param verse The verse that the annotation is in.
380
+ * @param word The annotation to get the text for.
381
+ * @returns The annotated text, or an empty string if the annotation doesn't point at any text.
382
+ */
383
+ getWordText(verse: ChapterVerse, word: ChapterWord): string;
384
+ /**
385
+ * Gets the word-level annotations for the given verse, paired with the text that each one applies to.
386
+ * @param verse The verse to get the annotations for.
387
+ * @param words The annotations for the chapter that the verse is in.
388
+ * @returns The annotations for the verse, in the order that they occur. Empty if the verse has no annotations.
389
+ */
390
+ getVerseWords(verse: ChapterVerse, words: ApiTranslationBookChapterWords): AnnotatedWord[];
391
+ /**
392
+ * Gets the text that the given simplified word-level annotation applies to.
393
+ * @param verse The simplified verse that the annotation is in.
394
+ * @param word The annotation to get the text for.
395
+ * @returns The annotated text.
396
+ */
397
+ getSimpleWordText(verse: SimpleChapterVerse, word: SimpleChapterWord): string;
398
+ /**
399
+ * Gets the word-level annotations for the given simplified verse, paired with the text that each one applies to.
400
+ * @param verse The simplified verse to get the annotations for.
401
+ * @param words The simplified annotations for the chapter that the verse is in.
402
+ * @returns The annotations for the verse, in the order that they occur. Empty if the verse has no annotations.
403
+ */
404
+ getSimpleVerseWords(verse: SimpleChapterVerse, words: ApiSimpleTranslationBookChapterWords): SimpleAnnotatedWord[];
244
405
  private _getJson;
245
406
  private _buildUrl;
246
407
  }