free-use-bible-api 0.2.0 → 0.4.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
  }
@@ -88,6 +103,115 @@ export class FreeUseBibleApi {
88
103
  endpoint
89
104
  );
90
105
  }
106
+ /**
107
+ * Gets the list of people for a given dataset.
108
+ * @param dataset The ID of the dataset to get the people for.
109
+ * @param endpoint The endpoint to use for the request. If not provided, then the default endpoint will be used.
110
+ */
111
+ async getDatasetPeople(dataset, endpoint) {
112
+ const encodedDataset = encodeURIComponent(dataset);
113
+ return this._getJson(
114
+ `api/d/${encodedDataset}/people.json`,
115
+ endpoint
116
+ );
117
+ }
118
+ /**
119
+ * Gets the information about a specific person for a given dataset.
120
+ * Includes the Bible references that mention the person and their relationships
121
+ * to other people, places, events, and people groups.
122
+ * @param dataset The ID of the dataset to get the person for.
123
+ * @param person The ID of the person to get.
124
+ * @param endpoint The endpoint to use for the request. If not provided, then the default endpoint will be used.
125
+ */
126
+ async getDatasetPerson(dataset, person, endpoint) {
127
+ const encodedDataset = encodeURIComponent(dataset);
128
+ const encodedPerson = encodeURIComponent(person);
129
+ return this._getJson(
130
+ `api/d/${encodedDataset}/people/${encodedPerson}.json`,
131
+ endpoint
132
+ );
133
+ }
134
+ /**
135
+ * Gets the list of places for a given dataset.
136
+ * @param dataset The ID of the dataset to get the places for.
137
+ * @param endpoint The endpoint to use for the request. If not provided, then the default endpoint will be used.
138
+ */
139
+ async getDatasetPlaces(dataset, endpoint) {
140
+ const encodedDataset = encodeURIComponent(dataset);
141
+ return this._getJson(
142
+ `api/d/${encodedDataset}/places.json`,
143
+ endpoint
144
+ );
145
+ }
146
+ /**
147
+ * Gets the information about a specific place for a given dataset.
148
+ * Includes the Bible references that mention the place and its related people and events.
149
+ * @param dataset The ID of the dataset to get the place for.
150
+ * @param place The ID of the place to get.
151
+ * @param endpoint The endpoint to use for the request. If not provided, then the default endpoint will be used.
152
+ */
153
+ async getDatasetPlace(dataset, place, endpoint) {
154
+ const encodedDataset = encodeURIComponent(dataset);
155
+ const encodedPlace = encodeURIComponent(place);
156
+ return this._getJson(
157
+ `api/d/${encodedDataset}/places/${encodedPlace}.json`,
158
+ endpoint
159
+ );
160
+ }
161
+ /**
162
+ * Gets the list of events for a given dataset.
163
+ * @param dataset The ID of the dataset to get the events for.
164
+ * @param endpoint The endpoint to use for the request. If not provided, then the default endpoint will be used.
165
+ */
166
+ async getDatasetEvents(dataset, endpoint) {
167
+ const encodedDataset = encodeURIComponent(dataset);
168
+ return this._getJson(
169
+ `api/d/${encodedDataset}/events.json`,
170
+ endpoint
171
+ );
172
+ }
173
+ /**
174
+ * Gets the information about a specific event for a given dataset.
175
+ * Includes the Bible references that describe the event and its related people, places, and people groups.
176
+ * @param dataset The ID of the dataset to get the event for.
177
+ * @param event The ID of the event to get.
178
+ * @param endpoint The endpoint to use for the request. If not provided, then the default endpoint will be used.
179
+ */
180
+ async getDatasetEvent(dataset, event, endpoint) {
181
+ const encodedDataset = encodeURIComponent(dataset);
182
+ const encodedEvent = encodeURIComponent(event);
183
+ return this._getJson(
184
+ `api/d/${encodedDataset}/events/${encodedEvent}.json`,
185
+ endpoint
186
+ );
187
+ }
188
+ /**
189
+ * Gets the list of people groups for a given dataset.
190
+ * @param dataset The ID of the dataset to get the people groups for.
191
+ * @param endpoint The endpoint to use for the request. If not provided, then the default endpoint will be used.
192
+ */
193
+ async getDatasetPeopleGroups(dataset, endpoint) {
194
+ const encodedDataset = encodeURIComponent(dataset);
195
+ return this._getJson(
196
+ `api/d/${encodedDataset}/groups.json`,
197
+ endpoint
198
+ );
199
+ }
200
+ /**
201
+ * Gets the information about a specific people group for a given dataset.
202
+ * Includes the members of the group and the events that the group participated in.
203
+ * @param dataset The ID of the dataset to get the people group for.
204
+ * @param group The ID of the people group to get.
205
+ * @param endpoint The endpoint to use for the request. If not provided, then the default endpoint will be used.
206
+ */
207
+ async getDatasetPeopleGroup(dataset, group, endpoint) {
208
+ const encodedDataset = encodeURIComponent(dataset);
209
+ const encodedGroup = encodeURIComponent(group);
210
+ return this._getJson(
211
+ `api/d/${encodedDataset}/groups/${encodedGroup}.json`,
212
+ endpoint
213
+ );
214
+ }
91
215
  /**
92
216
  * Gets the content of a specific chapter of a specific book for a specific Bible translation.
93
217
  * @param translation The ID of the translation to get the chapter for.
@@ -104,6 +228,86 @@ export class FreeUseBibleApi {
104
228
  endpoint
105
229
  );
106
230
  }
231
+ /**
232
+ * 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.
233
+ *
234
+ * Only some translations have word-level annotations. This request will fail for chapters that don't have any.
235
+ * Use `getChapterWords()` to get the annotations for a chapter that you have already loaded, which returns null instead of failing.
236
+ * @param translation The ID of the translation to get the annotations for.
237
+ * @param book The ID of the book to get the annotations for.
238
+ * @param chapter The chapter number to get the annotations for.
239
+ * @param endpoint The API endpoint to use for the request. If not provided, the default endpoint will be used.
240
+ */
241
+ async getTranslationBookChapterWords(translation, book, chapter, endpoint) {
242
+ const encodedTranslation = encodeURIComponent(translation);
243
+ const encodedBook = encodeURIComponent(book);
244
+ const encodedChapter = encodeURIComponent(String(chapter));
245
+ return this._getJson(
246
+ `api/${encodedTranslation}/${encodedBook}/${encodedChapter}.words.json`,
247
+ endpoint
248
+ );
249
+ }
250
+ async getChapterWords(chapter, endpoint) {
251
+ if (!chapter.thisChapterWordsLink) {
252
+ return null;
253
+ }
254
+ return this._getJson(
255
+ chapter.thisChapterWordsLink,
256
+ endpoint
257
+ );
258
+ }
259
+ /**
260
+ * Gets the content of a specific chapter of a specific book for a specific Bible translation, using the simplified chapter format.
261
+ *
262
+ * 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.
263
+ * @param translation The ID of the translation to get the chapter for.
264
+ * @param book The ID of the book to get the chapter for.
265
+ * @param chapter The chapter number to get.
266
+ * @param endpoint The API endpoint to use for the request. If not provided, the default endpoint will be used.
267
+ */
268
+ async getSimpleTranslationBookChapter(translation, book, chapter, endpoint) {
269
+ const encodedTranslation = encodeURIComponent(translation);
270
+ const encodedBook = encodeURIComponent(book);
271
+ const encodedChapter = encodeURIComponent(String(chapter));
272
+ return this._getJson(
273
+ `api/${encodedTranslation}/${encodedBook}/${encodedChapter}.simple.json`,
274
+ endpoint
275
+ );
276
+ }
277
+ /**
278
+ * 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.
279
+ *
280
+ * 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.
281
+ * Use `getSimpleChapterWords()` to get the annotations for a simplified chapter that you have already loaded, which returns null instead of failing.
282
+ * @param translation The ID of the translation to get the annotations for.
283
+ * @param book The ID of the book to get the annotations for.
284
+ * @param chapter The chapter number to get the annotations for.
285
+ * @param endpoint The API endpoint to use for the request. If not provided, the default endpoint will be used.
286
+ */
287
+ async getSimpleTranslationBookChapterWords(translation, book, chapter, endpoint) {
288
+ const encodedTranslation = encodeURIComponent(translation);
289
+ const encodedBook = encodeURIComponent(book);
290
+ const encodedChapter = encodeURIComponent(String(chapter));
291
+ return this._getJson(
292
+ `api/${encodedTranslation}/${encodedBook}/${encodedChapter}.words.simple.json`,
293
+ endpoint
294
+ );
295
+ }
296
+ async getSimpleChapter(chapter, endpoint) {
297
+ if (!chapter.simpleChapterApiLink) {
298
+ return null;
299
+ }
300
+ return this._getJson(chapter.simpleChapterApiLink, endpoint);
301
+ }
302
+ async getSimpleChapterWords(chapter, endpoint) {
303
+ if (!chapter.thisChapterWordsLink) {
304
+ return null;
305
+ }
306
+ return this._getJson(
307
+ chapter.thisChapterWordsLink,
308
+ endpoint
309
+ );
310
+ }
107
311
  /**
108
312
  * Gets the content of a specific chapter of a specific book for a specific Bible commentary.
109
313
  * @param commentary The ID of the commentary to get the chapter for.
@@ -116,12 +320,32 @@ export class FreeUseBibleApi {
116
320
  const encodedBook = encodeURIComponent(book);
117
321
  const encodedChapter = encodeURIComponent(String(chapter));
118
322
  return this._getJson(
119
- `api/${encodedCommentary}/${encodedBook}/${encodedChapter}.json`,
323
+ `api/c/${encodedCommentary}/${encodedBook}/${encodedChapter}.json`,
324
+ endpoint
325
+ );
326
+ }
327
+ /**
328
+ * Gets the content of a specific chapter of a specific book for a specific Bible commentary, using the simplified chapter format.
329
+ * @param commentary The ID of the commentary to get the chapter for.
330
+ * @param book The ID of the book to get the chapter for.
331
+ * @param chapter The chapter number to get.
332
+ * @param endpoint The API endpoint to use for the request. If not provided, the default endpoint will be used.
333
+ */
334
+ async getSimpleCommentaryBookChapter(commentary, book, chapter, endpoint) {
335
+ const encodedCommentary = encodeURIComponent(commentary);
336
+ const encodedBook = encodeURIComponent(book);
337
+ const encodedChapter = encodeURIComponent(String(chapter));
338
+ return this._getJson(
339
+ `api/c/${encodedCommentary}/${encodedBook}/${encodedChapter}.simple.json`,
120
340
  endpoint
121
341
  );
122
342
  }
123
343
  /**
124
344
  * Gets the content of a specific chapter of a specific book for a specific dataset.
345
+ *
346
+ * For cross reference datasets, this is the list of cross references for each verse
347
+ * in the chapter. For entity datasets (such as "theographic"), this is the people,
348
+ * places, and events that appear in the chapter.
125
349
  * @param dataset The ID of the dataset to get the chapter for.
126
350
  * @param book The ID of the book to get the chapter for.
127
351
  * @param chapter The chapter number to get.
@@ -237,6 +461,86 @@ ${content.trim()}`;
237
461
  }
238
462
  return content.trim();
239
463
  }
464
+ /**
465
+ * Gets the verse text for the given simplified chapter.
466
+ * 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.
467
+ * @param chapter The simplified chapter to get the text for.
468
+ * @param options Options for getting the chapter text.
469
+ */
470
+ getSimpleChapterVerseText(chapter, options = {}) {
471
+ let content = "";
472
+ for (let chapterContent of chapter.chapter.content) {
473
+ if (chapterContent.type === "verse") {
474
+ if (!options.omitVerseNumbers) {
475
+ content += `[${chapterContent.number}] `;
476
+ }
477
+ content += chapterContent.text.trim() + " ";
478
+ } else if (chapterContent.type === "line_break") {
479
+ content = content.trim() + "\n";
480
+ }
481
+ }
482
+ if (!options.omitReference) {
483
+ content = `${this.formatReference(chapter.book, {
484
+ chapter: chapter.chapter.number
485
+ })}
486
+ ${content.trim()}`;
487
+ }
488
+ return content.trim();
489
+ }
490
+ /**
491
+ * Gets the text that the given word-level annotation applies to.
492
+ *
493
+ * Annotations are anchored to a range of characters in a single item of the verse's content,
494
+ * so that the ranges stay correct for verses whose content is split into multiple items,
495
+ * such as poem lines and the words of Jesus.
496
+ * @param verse The verse that the annotation is in.
497
+ * @param word The annotation to get the text for.
498
+ * @returns The annotated text, or an empty string if the annotation doesn't point at any text.
499
+ */
500
+ getWordText(verse, word) {
501
+ const content = verse.content[word.contentIndex];
502
+ if (typeof content === "string") {
503
+ return content.slice(word.start, word.end);
504
+ } else if (typeof content === "object" && content !== null && "text" in content) {
505
+ return content.text.slice(word.start, word.end);
506
+ }
507
+ return "";
508
+ }
509
+ /**
510
+ * Gets the word-level annotations for the given verse, paired with the text that each one applies to.
511
+ * @param verse The verse to get the annotations for.
512
+ * @param words The annotations for the chapter that the verse is in.
513
+ * @returns The annotations for the verse, in the order that they occur. Empty if the verse has no annotations.
514
+ */
515
+ getVerseWords(verse, words) {
516
+ const verseWords = words.verses[verse.number.toString()] ?? [];
517
+ return verseWords.map((word) => ({
518
+ ...word,
519
+ text: this.getWordText(verse, word)
520
+ }));
521
+ }
522
+ /**
523
+ * Gets the text that the given simplified word-level annotation applies to.
524
+ * @param verse The simplified verse that the annotation is in.
525
+ * @param word The annotation to get the text for.
526
+ * @returns The annotated text.
527
+ */
528
+ getSimpleWordText(verse, word) {
529
+ return verse.text.slice(word.start, word.end);
530
+ }
531
+ /**
532
+ * Gets the word-level annotations for the given simplified verse, paired with the text that each one applies to.
533
+ * @param verse The simplified verse to get the annotations for.
534
+ * @param words The simplified annotations for the chapter that the verse is in.
535
+ * @returns The annotations for the verse, in the order that they occur. Empty if the verse has no annotations.
536
+ */
537
+ getSimpleVerseWords(verse, words) {
538
+ const verseWords = words.verses[verse.number.toString()] ?? [];
539
+ return verseWords.map((word) => ({
540
+ ...word,
541
+ text: this.getSimpleWordText(verse, word)
542
+ }));
543
+ }
240
544
  _getJson(path, endpoint, useCache = true) {
241
545
  const url = this._buildUrl(path, endpoint);
242
546
  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,KA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,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 ApiDatasetEntityBookChapter,\r\n ApiDatasetEvent,\r\n ApiDatasetEvents,\r\n ApiDatasetPeople,\r\n ApiDatasetPeopleGroup,\r\n ApiDatasetPeopleGroups,\r\n ApiDatasetPerson,\r\n ApiDatasetPlace,\r\n ApiDatasetPlaces,\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 SimpleTranslationCompleteChapter,\r\n TranslationChapterReference,\r\n TranslationCompleteChapter,\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 list of people for a given dataset.\r\n * @param dataset The ID of the dataset to get the people for.\r\n * @param endpoint The endpoint to use for the request. If not provided, then the default endpoint will be used.\r\n */\r\n async getDatasetPeople(\r\n dataset: string,\r\n endpoint?: string\r\n ): Promise<ApiDatasetPeople> {\r\n const encodedDataset = encodeURIComponent(dataset);\r\n return this._getJson<ApiDatasetPeople>(\r\n `api/d/${encodedDataset}/people.json`,\r\n endpoint\r\n );\r\n }\r\n\r\n /**\r\n * Gets the information about a specific person for a given dataset.\r\n * Includes the Bible references that mention the person and their relationships\r\n * to other people, places, events, and people groups.\r\n * @param dataset The ID of the dataset to get the person for.\r\n * @param person The ID of the person to get.\r\n * @param endpoint The endpoint to use for the request. If not provided, then the default endpoint will be used.\r\n */\r\n async getDatasetPerson(\r\n dataset: string,\r\n person: string,\r\n endpoint?: string\r\n ): Promise<ApiDatasetPerson> {\r\n const encodedDataset = encodeURIComponent(dataset);\r\n const encodedPerson = encodeURIComponent(person);\r\n return this._getJson<ApiDatasetPerson>(\r\n `api/d/${encodedDataset}/people/${encodedPerson}.json`,\r\n endpoint\r\n );\r\n }\r\n\r\n /**\r\n * Gets the list of places for a given dataset.\r\n * @param dataset The ID of the dataset to get the places for.\r\n * @param endpoint The endpoint to use for the request. If not provided, then the default endpoint will be used.\r\n */\r\n async getDatasetPlaces(\r\n dataset: string,\r\n endpoint?: string\r\n ): Promise<ApiDatasetPlaces> {\r\n const encodedDataset = encodeURIComponent(dataset);\r\n return this._getJson<ApiDatasetPlaces>(\r\n `api/d/${encodedDataset}/places.json`,\r\n endpoint\r\n );\r\n }\r\n\r\n /**\r\n * Gets the information about a specific place for a given dataset.\r\n * Includes the Bible references that mention the place and its related people and events.\r\n * @param dataset The ID of the dataset to get the place for.\r\n * @param place The ID of the place to get.\r\n * @param endpoint The endpoint to use for the request. If not provided, then the default endpoint will be used.\r\n */\r\n async getDatasetPlace(\r\n dataset: string,\r\n place: string,\r\n endpoint?: string\r\n ): Promise<ApiDatasetPlace> {\r\n const encodedDataset = encodeURIComponent(dataset);\r\n const encodedPlace = encodeURIComponent(place);\r\n return this._getJson<ApiDatasetPlace>(\r\n `api/d/${encodedDataset}/places/${encodedPlace}.json`,\r\n endpoint\r\n );\r\n }\r\n\r\n /**\r\n * Gets the list of events for a given dataset.\r\n * @param dataset The ID of the dataset to get the events for.\r\n * @param endpoint The endpoint to use for the request. If not provided, then the default endpoint will be used.\r\n */\r\n async getDatasetEvents(\r\n dataset: string,\r\n endpoint?: string\r\n ): Promise<ApiDatasetEvents> {\r\n const encodedDataset = encodeURIComponent(dataset);\r\n return this._getJson<ApiDatasetEvents>(\r\n `api/d/${encodedDataset}/events.json`,\r\n endpoint\r\n );\r\n }\r\n\r\n /**\r\n * Gets the information about a specific event for a given dataset.\r\n * Includes the Bible references that describe the event and its related people, places, and people groups.\r\n * @param dataset The ID of the dataset to get the event for.\r\n * @param event The ID of the event to get.\r\n * @param endpoint The endpoint to use for the request. If not provided, then the default endpoint will be used.\r\n */\r\n async getDatasetEvent(\r\n dataset: string,\r\n event: string,\r\n endpoint?: string\r\n ): Promise<ApiDatasetEvent> {\r\n const encodedDataset = encodeURIComponent(dataset);\r\n const encodedEvent = encodeURIComponent(event);\r\n return this._getJson<ApiDatasetEvent>(\r\n `api/d/${encodedDataset}/events/${encodedEvent}.json`,\r\n endpoint\r\n );\r\n }\r\n\r\n /**\r\n * Gets the list of people groups for a given dataset.\r\n * @param dataset The ID of the dataset to get the people groups for.\r\n * @param endpoint The endpoint to use for the request. If not provided, then the default endpoint will be used.\r\n */\r\n async getDatasetPeopleGroups(\r\n dataset: string,\r\n endpoint?: string\r\n ): Promise<ApiDatasetPeopleGroups> {\r\n const encodedDataset = encodeURIComponent(dataset);\r\n return this._getJson<ApiDatasetPeopleGroups>(\r\n `api/d/${encodedDataset}/groups.json`,\r\n endpoint\r\n );\r\n }\r\n\r\n /**\r\n * Gets the information about a specific people group for a given dataset.\r\n * Includes the members of the group and the events that the group participated in.\r\n * @param dataset The ID of the dataset to get the people group for.\r\n * @param group The ID of the people group to get.\r\n * @param endpoint The endpoint to use for the request. If not provided, then the default endpoint will be used.\r\n */\r\n async getDatasetPeopleGroup(\r\n dataset: string,\r\n group: string,\r\n endpoint?: string\r\n ): Promise<ApiDatasetPeopleGroup> {\r\n const encodedDataset = encodeURIComponent(dataset);\r\n const encodedGroup = encodeURIComponent(group);\r\n return this._getJson<ApiDatasetPeopleGroup>(\r\n `api/d/${encodedDataset}/groups/${encodedGroup}.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 getChapterWords(\r\n chapter: ApiTranslationBookChapter,\r\n endpoint?: string\r\n ): Promise<ApiTranslationBookChapterWords | null>;\r\n /**\r\n * Gets the word-level annotations for the given chapter of a complete translation download, 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 getChapterWords(\r\n chapter: TranslationCompleteChapter,\r\n endpoint?: string\r\n ): Promise<ApiTranslationBookChapterWords | null>;\r\n async getChapterWords(\r\n chapter: ApiTranslationBookChapter | TranslationCompleteChapter,\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 getSimpleChapterWords(\r\n chapter: ApiSimpleTranslationBookChapter,\r\n endpoint?: string\r\n ): Promise<ApiSimpleTranslationBookChapterWords | null>;\r\n /**\r\n * Gets the word-level annotations for the given chapter of a simplified complete translation download, 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 getSimpleChapterWords(\r\n chapter: SimpleTranslationCompleteChapter,\r\n endpoint?: string\r\n ): Promise<ApiSimpleTranslationBookChapterWords | null>;\r\n async getSimpleChapterWords(\r\n chapter:\r\n | ApiSimpleTranslationBookChapter\r\n | SimpleTranslationCompleteChapter,\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 *\r\n * For cross reference datasets, this is the list of cross references for each verse\r\n * in the chapter. For entity datasets (such as \"theographic\"), this is the people,\r\n * places, and events that appear in the chapter.\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 | ApiDatasetEntityBookChapter> {\r\n const encodedDataset = encodeURIComponent(dataset);\r\n const encodedBook = encodeURIComponent(book);\r\n const encodedChapter = encodeURIComponent(String(chapter));\r\n return this._getJson<\r\n ApiDatasetBookChapter | ApiDatasetEntityBookChapter\r\n >(\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": ";AAkIO,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,UA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