@helloao/tools 0.0.13 → 0.0.14
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.
- package/dist/cjs/generation/api.cjs +16 -8
- package/dist/cjs/generation/api.cjs.map +2 -2
- package/dist/cjs/utils.cjs +6 -4
- package/dist/cjs/utils.cjs.map +2 -2
- package/dist/esm/generation/api.js +16 -8
- package/dist/esm/generation/api.js.map +2 -2
- package/dist/esm/utils.js +6 -4
- package/dist/esm/utils.js.map +2 -2
- package/dist/types/generation/api.d.ts +26 -2
- package/package.json +1 -1
|
@@ -86,19 +86,23 @@ function generateApiForDataset(dataset, options = {}) {
|
|
|
86
86
|
};
|
|
87
87
|
let translationChapters = [];
|
|
88
88
|
for (let { chapters, ...book } of books) {
|
|
89
|
+
const firstChapterNumber = chapters[0].chapter.number;
|
|
90
|
+
const lastChapterNumber = chapters[chapters.length - 1].chapter.number;
|
|
89
91
|
const apiBook = {
|
|
90
92
|
...book,
|
|
93
|
+
firstChapterNumber,
|
|
91
94
|
firstChapterApiLink: bookChapterApiLink(
|
|
92
95
|
translation.id,
|
|
93
96
|
getBookLink(book),
|
|
94
|
-
|
|
97
|
+
firstChapterNumber,
|
|
95
98
|
"json",
|
|
96
99
|
apiPathPrefix
|
|
97
100
|
),
|
|
101
|
+
lastChapterNumber,
|
|
98
102
|
lastChapterApiLink: bookChapterApiLink(
|
|
99
103
|
translation.id,
|
|
100
104
|
getBookLink(book),
|
|
101
|
-
|
|
105
|
+
lastChapterNumber,
|
|
102
106
|
"json",
|
|
103
107
|
apiPathPrefix
|
|
104
108
|
),
|
|
@@ -223,22 +227,26 @@ function generateApiForDataset(dataset, options = {}) {
|
|
|
223
227
|
};
|
|
224
228
|
let commentaryChapters = [];
|
|
225
229
|
for (let { chapters, ...book } of books) {
|
|
230
|
+
const firstChapterNumber = chapters[0]?.chapter.number ?? null;
|
|
231
|
+
const lastChapterNumber = chapters[chapters.length - 1]?.chapter.number ?? null;
|
|
226
232
|
const apiBook = {
|
|
227
233
|
...book,
|
|
228
|
-
|
|
234
|
+
firstChapterNumber,
|
|
235
|
+
firstChapterApiLink: firstChapterNumber ? bookCommentaryChapterApiLink(
|
|
229
236
|
commentary.id,
|
|
230
237
|
getBookLink(book),
|
|
231
|
-
|
|
238
|
+
firstChapterNumber,
|
|
232
239
|
"json",
|
|
233
240
|
apiPathPrefix
|
|
234
|
-
),
|
|
235
|
-
|
|
241
|
+
) : null,
|
|
242
|
+
lastChapterNumber,
|
|
243
|
+
lastChapterApiLink: lastChapterNumber ? bookCommentaryChapterApiLink(
|
|
236
244
|
commentary.id,
|
|
237
245
|
getBookLink(book),
|
|
238
|
-
|
|
246
|
+
lastChapterNumber,
|
|
239
247
|
"json",
|
|
240
248
|
apiPathPrefix
|
|
241
|
-
),
|
|
249
|
+
) : null,
|
|
242
250
|
numberOfChapters: chapters.length,
|
|
243
251
|
totalNumberOfVerses: 0
|
|
244
252
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../generation/api.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n Commentary,\n CommentaryBook,\n CommentaryBookChapter,\n CommentaryProfile,\n OutputFile,\n Translation,\n TranslationBook,\n TranslationBookChapter,\n TranslationBookChapterAudioLinks,\n} from './common-types.js';\nimport { DatasetOutput } from './dataset.js';\n\n/**\n * Defines the output of the API generation.\n */\nexport interface ApiOutput {\n /**\n * The list of available translations.\n * This maps to the /api/available-translations.json endpoint.\n */\n availableTranslations: ApiAvailableTranslations;\n\n /**\n * The list of books for each translation.\n * This maps to the /api/:translationId/books.json endpoint.\n */\n translationBooks: ApiTranslationBooks[];\n\n /**\n * The list of chapters for each book.\n * This maps to the following endpoints:\n * - /api/:translationId/:bookId/:chapterNumber.json\n * - /api/:translationId/:bookCommonName/:chapterNumber.json\n */\n translationBookChapters: ApiTranslationBookChapter[];\n\n /**\n * The list of audio files.\n * This maps to the following endpoints:\n * - /api/:translationId/:bookId/:chapterNumber.:reader.mp3\n */\n translationBookChapterAudio: ApiTranslationBookChapterAudio[];\n\n /**\n * The list of available commentaries.\n * This maps to the /api/available-commentaries.json endpoint.\n */\n availableCommentaries: ApiAvailableCommentaries;\n\n /**\n * The list of books for each commentary.\n * This maps to the /api/c/:commentaryId/books.json endpoint.\n */\n commentaryBooks: ApiCommentaryBooks[];\n\n /**\n * The list of profiles for each commentary.\n * This maps to the /api/c/:commentaryId/profiles.json endpoint.\n */\n commentaryProfiles: ApiCommentaryProfiles[];\n\n /**\n * The list of chapters for each commentary book.\n * This maps to the following endpoint:\n * - /api/c/:commentaryId/:bookId/:chapterNumber.json\n */\n commentaryBookChapters: ApiCommentaryBookChapter[];\n\n /**\n * The list of individual profiles for each commentary.\n * This maps to the following endpoint:\n * - /api/c/:commentaryId/profiles/:profileId.json\n */\n commentaryProfileContents: ApiCommentaryProfileContent[];\n\n /**\n * The path prefix that the API should use.\n */\n pathPrefix: string;\n}\n\n/**\n * The list of available translations.\n * Maps to the /api/available-translations.json endpoint.\n */\nexport interface ApiAvailableTranslations {\n /**\n * The list of translations.\n */\n translations: ApiTranslation[];\n}\n\n/**\n * The list of available commentaries.\n * Maps to the /api/available-commentaries.json endpoint.\n */\nexport interface ApiAvailableCommentaries {\n /**\n * The list of commentaries.\n */\n commentaries: ApiCommentary[];\n}\n\n/**\n * Defines a translation that is used in the API.\n */\nexport interface ApiTranslation extends Translation {\n /**\n * The API link for the list of available books for this translation.\n */\n listOfBooksApiLink: string;\n\n /**\n * The available list of formats.\n */\n availableFormats: ('json' | 'usfm')[];\n\n /**\n * The number of books that are contained in this translation.\n *\n * Complete translations should have the same number of books as the Bible (66).\n */\n numberOfBooks: number;\n\n /**\n * The total number of chapters that are contained in this translation.\n *\n * Complete translations should have the same number of chapters as the Bible (1,189).\n */\n totalNumberOfChapters: number;\n\n /**\n * The total number of verses that are contained in this translation.\n *\n * Complete translations should have the same number of verses as the Bible (around 31,102 - some translations exclude verses based on the aparent likelyhood of existing in the original source texts).\n */\n totalNumberOfVerses: number;\n\n /**\n * The total number of apocryphal books that are contained in this translation.\n */\n numberOfApocryphalBooks?: number;\n\n /**\n * The total number of apocryphal chapters that are contained in this translation.\n */\n totalNumberOfApocryphalChapters?: number;\n\n /**\n * the total number of apocryphal verses that are contained in this translation.\n */\n totalNumberOfApocryphalVerses?: number;\n\n /**\n * Gets the name of the language that the translation is in.\n * Null or undefined if the name of the language is not known.\n */\n languageName?: string;\n\n /**\n * Gets the name of the language in English.\n * Null or undefined if the language doesn't have an english name.\n */\n languageEnglishName?: string;\n}\n\n/**\n * Defines a commentary that is used in the API.\n */\nexport interface ApiCommentary extends Commentary {\n /**\n * The API link for the list of available books for this translation.\n */\n listOfBooksApiLink: string;\n\n /**\n * The API link for the list of available profiles for this commentary.\n */\n listOfProfilesApiLink: string;\n\n /**\n * The available list of formats.\n */\n availableFormats: ('json' | 'usfm')[];\n\n /**\n * The number of books that are contained in this commentary.\n *\n * Complete commentaries should have the same number of books as the Bible (66).\n */\n numberOfBooks: number;\n\n /**\n * The total number of chapters that are contained in this translation.\n *\n * Complete commentaries should have the same number of chapters as the Bible (1,189).\n */\n totalNumberOfChapters: number;\n\n /**\n * The total number of verses that are contained in this commentary.\n *\n * Complete commentaries should have the same number of verses as the Bible (around 31,102 - some commentaries exclude verses based on the aparent likelyhood of existing in the original source texts).\n */\n totalNumberOfVerses: number;\n\n /**\n * The total number of profiles that are contained in this commentary.\n *\n * Profiles are used to provide additional information about people and people groups that are mentioned in the Bible.\n */\n totalNumberOfProfiles: number;\n\n /**\n * Gets the name of the language that the commentary is in.\n * Null or undefined if the name of the language is not known.\n */\n languageName?: string;\n\n /**\n * Gets the name of the language in English.\n * Null or undefined if the language doesn't have an english name.\n */\n languageEnglishName?: string;\n}\n\n/**\n * Defines an interface that contains information about the books that are available for a translation.\n */\nexport interface ApiTranslationBooks {\n /**\n * The translation information for the books.\n */\n translation: ApiTranslation;\n\n /**\n * The list of books that are available for the translation.\n */\n books: ApiTranslationBook[];\n}\n\n/**\n * Defines an interface that contains information about the books that are available for a commentary.\n */\nexport interface ApiCommentaryBooks {\n /**\n * The commentary information for the books.\n */\n commentary: ApiCommentary;\n\n /**\n * The list of books that are available for the commentary.\n */\n books: ApiCommentaryBook[];\n}\n\n/**\n * Defines an interface that contains information about the profiles that are available for a commentary.\n */\nexport interface ApiCommentaryProfiles {\n /**\n * The commentary information for the books.\n */\n commentary: ApiCommentary;\n\n /**\n * The list of profiles that are available for the commentary.\n */\n profiles: ApiCommentaryProfile[];\n}\n\n/**\n * Defines an interface that contains information about a profile.\n */\nexport interface ApiCommentaryProfile extends CommentaryProfile {\n /**\n * The link to this profile.\n */\n thisProfileLink: string;\n\n /**\n * The link to the chapter that this profile references in the commentary.\n */\n referenceChapterLink: string | null;\n}\n\n/**\n * Defines a translation book that is used in the API.\n */\nexport interface ApiTranslationBook extends TranslationBook {\n /**\n * The link to the first chapter of the book.\n */\n firstChapterApiLink: string;\n\n /**\n * The link to the last chapter of the book.\n */\n lastChapterApiLink: string;\n\n /**\n * The number of chapters that the book contains.\n */\n numberOfChapters: number;\n\n /**\n * The number of verses that the book contains.\n */\n totalNumberOfVerses: number;\n}\n\n/**\n * Defines a commentary book that is used in the API.\n */\nexport interface ApiCommentaryBook extends CommentaryBook {\n /**\n * The link to the first chapter of the book.\n */\n firstChapterApiLink: string;\n\n /**\n * The link to the last chapter of the book.\n */\n lastChapterApiLink: string;\n\n /**\n * The number of chapters that the book contains.\n */\n numberOfChapters: number;\n\n /**\n * The number of verses that the book contains.\n */\n totalNumberOfVerses: number;\n}\n\n/**\n * Defines an interface that contains information about a book chapter.\n */\nexport interface ApiTranslationBookChapter extends TranslationBookChapter {\n /**\n * The translation information for the book chapter.\n */\n translation: ApiTranslation;\n\n /**\n * The book information for the book chapter.\n */\n book: ApiTranslationBook;\n\n /**\n * The link to this chapter.\n */\n thisChapterLink: string;\n\n /**\n * The link to the next chapter.\n * Null if this is the last chapter in the translation.\n */\n nextChapterApiLink: string | null;\n\n /**\n * The links to the audio versions for the next chapter.\n * Null if this is the last chapter in the translation.\n */\n nextChapterAudioLinks: TranslationBookChapterAudioLinks | null;\n\n /**\n * The link to the previous chapter.\n * Null if this is the first chapter in the translation.\n */\n previousChapterApiLink: string | null;\n\n /**\n * The links to the audio versions for the previous chapter.\n * Null if this is the first chapter in the translation.\n */\n previousChapterAudioLinks: TranslationBookChapterAudioLinks | null;\n\n /**\n * The number of verses that the chapter contains.\n */\n numberOfVerses: number;\n}\n\n/**\n * Defines an interface that contains information about a book chapter.\n */\nexport interface ApiCommentaryBookChapter extends CommentaryBookChapter {\n /**\n * The commentary information for the book chapter.\n */\n commentary: ApiCommentary;\n\n /**\n * The book information for the book chapter.\n */\n book: ApiCommentaryBook;\n\n /**\n * The link to this chapter.\n */\n thisChapterLink: string;\n\n /**\n * The link to the next chapter.\n * Null if this is the last chapter in the translation.\n */\n nextChapterApiLink: string | null;\n\n /**\n * The link to the previous chapter.\n * Null if this is the first chapter in the translation.\n */\n previousChapterApiLink: string | null;\n\n /**\n * The number of verses that the chapter contains.\n */\n numberOfVerses: number;\n}\n\nexport interface ApiTranslationBookChapterAudio {\n /**\n * The chapter that the audio is for.\n */\n chapter: ApiTranslationBookChapter;\n\n /**\n * The link that the audio should be placed at.\n */\n link: string;\n\n /**\n * The original URL of the audio.\n */\n originalUrl: string;\n}\n\nexport interface ApiCommentaryProfileContent {\n /**\n * The commentary information for the profile.\n */\n commentary: ApiCommentary;\n\n /**\n * The information about the profile.\n */\n profile: ApiCommentaryProfile;\n\n /**\n * The content of the profile.\n */\n content: string[];\n}\n\n/**\n * The options for generating the API.\n */\nexport interface GenerateApiOptions {\n /**\n * Whether to use the common name for the book chapter API link. If false, then book IDs are used.\n * Audio URLs will always use the book ID.\n * Defaults to false.\n */\n useCommonName?: boolean;\n\n /**\n * Whether to replace the audio URLs in the dataset with ones that are hosted locally.\n * If true, then the audio URLs in the dataset will be replaced with ones that reference files hosted by the API itself.\n * If false, then the audio URLs in the dataset will be left as is.\n * Defaults to false.\n */\n generateAudioFiles?: boolean;\n\n /**\n * Gets the english name of the given language.\n * If not provided, then the english name for the language will be unknown and omitted.\n * @param language The language to get the english name for.\n */\n getEnglishName?: (language: string) => string | null | undefined;\n\n /**\n * Gets the native name of the given language.\n * If not provided, then the native name for the language will be unknown and omitted.\n * @param language The language to get the native name for.\n */\n getNativeName?: (language: string) => string | null | undefined;\n\n /**\n * The prefix that should be added to paths that are generated.\n */\n pathPrefix?: string;\n}\n\n/**\n * Generates the API output for the given dataset.\n * @param dataset The dataset to generate the API for.\n * @param options The options for generating the API.\n */\nexport function generateApiForDataset(\n dataset: DatasetOutput,\n options: GenerateApiOptions = {}\n): ApiOutput {\n const { useCommonName, pathPrefix } = options;\n const apiPathPrefix = pathPrefix ? pathPrefix : '';\n let api: ApiOutput = {\n availableTranslations: {\n translations: [],\n },\n translationBooks: [],\n translationBookChapters: [],\n translationBookChapterAudio: [],\n availableCommentaries: {\n commentaries: [],\n },\n commentaryBookChapters: [],\n commentaryBooks: [],\n commentaryProfiles: [],\n commentaryProfileContents: [],\n pathPrefix: apiPathPrefix,\n };\n\n const getNativeName = options.getNativeName;\n const getEnglishName = options.getEnglishName;\n\n for (let { books, ...translation } of dataset.translations) {\n let numberOfBooks = 0;\n let numberOfApocryphalBooks = 0;\n\n for (let book of books) {\n if (book.isApocryphal) {\n numberOfApocryphalBooks++;\n } else {\n numberOfBooks++;\n }\n }\n\n const apiTranslation: ApiTranslation = {\n ...translation,\n availableFormats: ['json'],\n listOfBooksApiLink: listOfBooksApiLink(\n translation.id,\n apiPathPrefix\n ),\n numberOfBooks,\n totalNumberOfChapters: 0,\n totalNumberOfVerses: 0,\n languageName: getNativeName\n ? (getNativeName(translation.language) ?? undefined)\n : undefined,\n languageEnglishName: getEnglishName\n ? (getEnglishName(translation.language) ?? undefined)\n : undefined,\n };\n\n if (numberOfApocryphalBooks > 0) {\n apiTranslation.numberOfApocryphalBooks = numberOfApocryphalBooks;\n }\n\n const translationBooks: ApiTranslationBooks = {\n translation: apiTranslation,\n books: [],\n };\n\n let translationChapters: ApiTranslationBookChapter[] = [];\n\n for (let { chapters, ...book } of books) {\n const apiBook: ApiTranslationBook = {\n ...book,\n firstChapterApiLink: bookChapterApiLink(\n translation.id,\n getBookLink(book),\n 1,\n 'json',\n apiPathPrefix\n ),\n lastChapterApiLink: bookChapterApiLink(\n translation.id,\n getBookLink(book),\n chapters.length,\n 'json',\n apiPathPrefix\n ),\n numberOfChapters: chapters.length,\n totalNumberOfVerses: 0,\n };\n\n for (let { chapter, thisChapterAudioLinks } of chapters) {\n const audio: TranslationBookChapterAudioLinks = {};\n const apiBookChapter: ApiTranslationBookChapter = {\n translation: apiTranslation,\n book: apiBook,\n chapter: chapter,\n thisChapterLink: bookChapterApiLink(\n translation.id,\n getBookLink(book),\n chapter.number,\n 'json',\n apiPathPrefix\n ),\n thisChapterAudioLinks: audio,\n nextChapterApiLink: null,\n nextChapterAudioLinks: null,\n previousChapterApiLink: null,\n previousChapterAudioLinks: null,\n numberOfVerses: 0,\n };\n\n for (let reader in thisChapterAudioLinks) {\n if (options.generateAudioFiles) {\n const apiAudio: ApiTranslationBookChapterAudio = {\n chapter: apiBookChapter,\n link: bookChapterAudioApiLink(\n translation.id,\n getBookLink(book),\n chapter.number,\n reader,\n apiPathPrefix\n ),\n originalUrl: thisChapterAudioLinks[reader],\n };\n audio[reader] = apiAudio.link;\n api.translationBookChapterAudio.push(apiAudio);\n } else {\n audio[reader] = thisChapterAudioLinks[reader];\n }\n }\n\n for (let c of chapter.content) {\n if (c.type === 'verse') {\n apiBookChapter.numberOfVerses++;\n }\n }\n\n apiBook.totalNumberOfVerses += apiBookChapter.numberOfVerses;\n\n translationChapters.push(apiBookChapter);\n api.translationBookChapters.push(apiBookChapter);\n }\n\n translationBooks.books.push(apiBook);\n\n if (apiBook.isApocryphal) {\n if (!apiTranslation.totalNumberOfApocryphalChapters) {\n apiTranslation.totalNumberOfApocryphalChapters = 0;\n }\n if (!apiTranslation.totalNumberOfApocryphalVerses) {\n apiTranslation.totalNumberOfApocryphalVerses = 0;\n }\n apiTranslation.totalNumberOfApocryphalChapters +=\n apiBook.numberOfChapters;\n apiTranslation.totalNumberOfApocryphalVerses +=\n apiBook.totalNumberOfVerses;\n } else {\n apiTranslation.totalNumberOfChapters +=\n apiBook.numberOfChapters;\n apiTranslation.totalNumberOfVerses +=\n apiBook.totalNumberOfVerses;\n }\n }\n\n for (let i = 0; i < translationChapters.length; i++) {\n if (i > 0) {\n translationChapters[i].previousChapterApiLink =\n bookChapterApiLink(\n translation.id,\n getBookLink(translationChapters[i - 1].book),\n translationChapters[i - 1].chapter.number,\n 'json',\n apiPathPrefix\n );\n translationChapters[i].previousChapterAudioLinks =\n translationChapters[i - 1].thisChapterAudioLinks;\n }\n\n if (i < translationChapters.length - 1) {\n translationChapters[i].nextChapterApiLink = bookChapterApiLink(\n translation.id,\n getBookLink(translationChapters[i + 1].book),\n translationChapters[i + 1].chapter.number,\n 'json',\n apiPathPrefix\n );\n translationChapters[i].nextChapterAudioLinks =\n translationChapters[i + 1].thisChapterAudioLinks;\n }\n }\n\n api.availableTranslations.translations.push(apiTranslation);\n api.translationBooks.push(translationBooks);\n }\n\n for (let { books, profiles, ...commentary } of dataset.commentaries) {\n const apiCommentary: ApiCommentary = {\n ...commentary,\n availableFormats: ['json'],\n listOfBooksApiLink: listOfCommentaryBooksApiLink(\n commentary.id,\n apiPathPrefix\n ),\n listOfProfilesApiLink: profilesCommentaryApiLink(\n commentary.id,\n 'json',\n apiPathPrefix\n ),\n numberOfBooks: books.length,\n totalNumberOfChapters: 0,\n totalNumberOfVerses: 0,\n totalNumberOfProfiles: 0,\n languageName: getNativeName\n ? (getNativeName(commentary.language) ?? undefined)\n : undefined,\n languageEnglishName: getEnglishName\n ? (getEnglishName(commentary.language) ?? undefined)\n : undefined,\n };\n\n const commentaryBooks: ApiCommentaryBooks = {\n commentary: apiCommentary,\n books: [],\n };\n\n const commentaryProfiles: ApiCommentaryProfiles = {\n commentary: apiCommentary,\n profiles: [],\n };\n\n let commentaryChapters: ApiCommentaryBookChapter[] = [];\n\n for (let { chapters, ...book } of books) {\n const apiBook: ApiCommentaryBook = {\n ...book,\n firstChapterApiLink: bookCommentaryChapterApiLink(\n commentary.id,\n getBookLink(book),\n 1,\n 'json',\n apiPathPrefix\n ),\n lastChapterApiLink: bookCommentaryChapterApiLink(\n commentary.id,\n getBookLink(book),\n chapters.length,\n 'json',\n apiPathPrefix\n ),\n numberOfChapters: chapters.length,\n totalNumberOfVerses: 0,\n };\n\n for (let { chapter } of chapters) {\n const apiBookChapter: ApiCommentaryBookChapter = {\n commentary: apiCommentary,\n book: apiBook,\n chapter: chapter,\n thisChapterLink: bookCommentaryChapterApiLink(\n commentary.id,\n getBookLink(book),\n chapter.number,\n 'json',\n apiPathPrefix\n ),\n nextChapterApiLink: null,\n previousChapterApiLink: null,\n numberOfVerses: 0,\n };\n\n for (let c of chapter.content) {\n if (c.type === 'verse') {\n apiBookChapter.numberOfVerses++;\n }\n }\n\n apiBook.totalNumberOfVerses += apiBookChapter.numberOfVerses;\n\n commentaryChapters.push(apiBookChapter);\n api.commentaryBookChapters.push(apiBookChapter);\n }\n\n commentaryBooks.books.push(apiBook);\n\n apiCommentary.totalNumberOfChapters += apiBook.numberOfChapters;\n apiCommentary.totalNumberOfVerses += apiBook.totalNumberOfVerses;\n }\n\n if (profiles) {\n for (let profile of profiles) {\n const apiProfile: ApiCommentaryProfile = {\n id: profile.id,\n reference: profile.reference,\n subject: profile.subject,\n thisProfileLink: profileCommentaryApiLink(\n commentary.id,\n profile.id,\n 'json',\n apiPathPrefix\n ),\n referenceChapterLink: profile.reference\n ? bookCommentaryChapterApiLink(\n commentary.id,\n profile.reference.book,\n profile.reference.chapter,\n 'json',\n apiPathPrefix\n )\n : null,\n };\n\n const apiProfileContent: ApiCommentaryProfileContent = {\n commentary: apiCommentary,\n profile: apiProfile,\n content: profile.content,\n };\n\n apiCommentary.totalNumberOfProfiles += 1;\n commentaryProfiles.profiles.push(apiProfile);\n api.commentaryProfileContents.push(apiProfileContent);\n }\n }\n\n for (let i = 0; i < commentaryChapters.length; i++) {\n if (i > 0) {\n commentaryChapters[i].previousChapterApiLink =\n bookCommentaryChapterApiLink(\n commentary.id,\n getBookLink(commentaryChapters[i - 1].book),\n commentaryChapters[i - 1].chapter.number,\n 'json',\n apiPathPrefix\n );\n // commentaryChapters[i].previousChapterAudioLinks =\n // commentaryChapters[i - 1].thisChapterAudioLinks;\n }\n\n if (i < commentaryChapters.length - 1) {\n commentaryChapters[i].nextChapterApiLink =\n bookCommentaryChapterApiLink(\n commentary.id,\n getBookLink(commentaryChapters[i + 1].book),\n commentaryChapters[i + 1].chapter.number,\n 'json',\n apiPathPrefix\n );\n // commentaryChapters[i].nextChapterAudioLinks =\n // commentaryChapters[i + 1].thisChapterAudioLinks;\n }\n }\n\n api.availableCommentaries.commentaries.push(apiCommentary);\n api.commentaryBooks.push(commentaryBooks);\n api.commentaryProfiles.push(commentaryProfiles);\n }\n\n return api;\n\n function getBookLink(book: TranslationBook | CommentaryBook): string {\n return useCommonName ? book.commonName : book.id;\n }\n}\n\n/**\n * Generates the output files for the given API.\n * @param api The API that the files should be generated for.\n */\nexport function generateFilesForApi(api: ApiOutput): OutputFile[] {\n let files: OutputFile[] = [];\n\n files.push(\n jsonFile(\n `${api.pathPrefix}/api/available_translations.json`,\n api.availableTranslations,\n true\n )\n );\n for (let translationBooks of api.translationBooks) {\n files.push(\n jsonFile(\n translationBooks.translation.listOfBooksApiLink,\n translationBooks\n )\n );\n }\n\n for (let bookChapter of api.translationBookChapters) {\n files.push(jsonFile(bookChapter.thisChapterLink, bookChapter));\n }\n\n for (let audio of api.translationBookChapterAudio) {\n files.push(downloadedFile(audio.link, audio.originalUrl));\n }\n\n files.push(\n jsonFile(\n `${api.pathPrefix}/api/available_commentaries.json`,\n api.availableCommentaries,\n true\n )\n );\n for (let commentaryBooks of api.commentaryBooks) {\n files.push(\n jsonFile(\n commentaryBooks.commentary.listOfBooksApiLink,\n commentaryBooks\n )\n );\n }\n\n for (let commentaryProfiles of api.commentaryProfiles) {\n files.push(\n jsonFile(\n commentaryProfiles.commentary.listOfProfilesApiLink,\n commentaryProfiles\n )\n );\n }\n\n for (let profileContent of api.commentaryProfileContents) {\n files.push(\n jsonFile(profileContent.profile.thisProfileLink, profileContent)\n );\n }\n\n for (let bookChapter of api.commentaryBookChapters) {\n files.push(jsonFile(bookChapter.thisChapterLink, bookChapter));\n }\n\n // for (let audio of api.translationBookChapterAudio) {\n // files.push(downloadedFile(audio.link, audio.originalUrl));\n // }\n\n return files;\n}\n\n/**\n * Generates the output files for the given datasets.\n * @param datasets The datasets to generate the output files for.\n * @param options The options for generating the API files.\n */\nexport async function* generateOutputFilesFromDatasets(\n datasets: AsyncIterable<DatasetOutput>,\n options?: GenerateApiOptions\n): AsyncGenerator<OutputFile[]> {\n for await (let dataset of datasets) {\n const api = generateApiForDataset(dataset, options);\n const files = generateFilesForApi(api);\n\n yield files;\n }\n}\n\n/**\n * Gets the API Link for the list of books endpoint for a translation.\n * @param translationId The ID of the translation.\n * @returns\n */\nexport function listOfBooksApiLink(\n translationId: string,\n prefix: string = ''\n): string {\n return `${prefix}/api/${translationId}/books.json`;\n}\n\n/**\n * Gets the API Link for the list of books endpoint for a commentary.\n * @param commentaryId The ID of the commentary.\n * @returns\n */\nexport function listOfCommentaryBooksApiLink(\n commentaryId: string,\n prefix: string = ''\n): string {\n return `${prefix}/api/c/${commentaryId}/books.json`;\n}\n\n/**\n * Getes the API link for a book chapter.\n * @param translationId The ID of the translation.\n * @param commonName The name of the book.\n * @param chapterNumber The number of the book.\n * @param extension The extension of the file.\n */\nexport function bookChapterApiLink(\n translationId: string,\n commonName: string,\n chapterNumber: number,\n extension: string,\n prefix: string = ''\n) {\n return `${prefix}/api/${translationId}/${replaceSpacesWithUnderscores(\n commonName\n )}/${chapterNumber}.${extension}`;\n}\n\n/**\n * Getes the API link for a book chapter.\n * @param translationId The ID of the translation.\n * @param commonName The name of the book.\n * @param chapterNumber The number of the book.\n * @param extension The extension of the file.\n */\nexport function bookCommentaryChapterApiLink(\n translationId: string,\n commonName: string,\n chapterNumber: number,\n extension: string,\n prefix: string = ''\n) {\n return `${prefix}/api/c/${translationId}/${replaceSpacesWithUnderscores(\n commonName\n )}/${chapterNumber}.${extension}`;\n}\n\nexport function bookChapterAudioApiLink(\n translationId: string,\n bookId: string,\n chapterNumber: number,\n reader: string,\n prefix: string = ''\n) {\n return `${prefix}/api/${translationId}/${replaceSpacesWithUnderscores(\n bookId\n )}/${chapterNumber}.${reader}.mp3`;\n}\n\n/**\n * Gets the API link for a profile.\n * @param translationId The ID of the translation.\n * @param profileId The ID of the profile.\n * @param extension The extension of the file.\n */\nexport function profilesCommentaryApiLink(\n translationId: string,\n extension: string,\n prefix: string = ''\n) {\n return `${prefix}/api/c/${translationId}/profiles.${extension}`;\n}\n\n/**\n * Gets the API link for a profile.\n * @param translationId The ID of the translation.\n * @param profileId The ID of the profile.\n * @param extension The extension of the file.\n */\nexport function profileCommentaryApiLink(\n translationId: string,\n profileId: string,\n extension: string,\n prefix: string = ''\n) {\n return `${prefix}/api/c/${translationId}/profiles/${replaceSpacesWithUnderscores(\n profileId\n )}.${extension}`;\n}\n\nexport function jsonFile(\n path: string,\n content: any,\n mergable?: boolean\n): OutputFile {\n return {\n path,\n content,\n mergable,\n };\n}\n\nexport function downloadedFile(path: string, url: string): OutputFile {\n return {\n path,\n content: () => fetch(url).then((response) => response.body),\n };\n}\n\nexport function replaceSpacesWithUnderscores(str: string): string {\n return str.replace(/[<>:\"/\\\\|?*\\s]/g, '_');\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
4
|
+
"sourcesContent": ["import {\r\n Commentary,\r\n CommentaryBook,\r\n CommentaryBookChapter,\r\n CommentaryProfile,\r\n OutputFile,\r\n Translation,\r\n TranslationBook,\r\n TranslationBookChapter,\r\n TranslationBookChapterAudioLinks,\r\n} from './common-types.js';\r\nimport { DatasetOutput } from './dataset.js';\r\n\r\n/**\r\n * Defines the output of the API generation.\r\n */\r\nexport interface ApiOutput {\r\n /**\r\n * The list of available translations.\r\n * This maps to the /api/available-translations.json endpoint.\r\n */\r\n availableTranslations: ApiAvailableTranslations;\r\n\r\n /**\r\n * The list of books for each translation.\r\n * This maps to the /api/:translationId/books.json endpoint.\r\n */\r\n translationBooks: ApiTranslationBooks[];\r\n\r\n /**\r\n * The list of chapters for each book.\r\n * This maps to the following endpoints:\r\n * - /api/:translationId/:bookId/:chapterNumber.json\r\n * - /api/:translationId/:bookCommonName/:chapterNumber.json\r\n */\r\n translationBookChapters: ApiTranslationBookChapter[];\r\n\r\n /**\r\n * The list of audio files.\r\n * This maps to the following endpoints:\r\n * - /api/:translationId/:bookId/:chapterNumber.:reader.mp3\r\n */\r\n translationBookChapterAudio: ApiTranslationBookChapterAudio[];\r\n\r\n /**\r\n * The list of available commentaries.\r\n * This maps to the /api/available-commentaries.json endpoint.\r\n */\r\n availableCommentaries: ApiAvailableCommentaries;\r\n\r\n /**\r\n * The list of books for each commentary.\r\n * This maps to the /api/c/:commentaryId/books.json endpoint.\r\n */\r\n commentaryBooks: ApiCommentaryBooks[];\r\n\r\n /**\r\n * The list of profiles for each commentary.\r\n * This maps to the /api/c/:commentaryId/profiles.json endpoint.\r\n */\r\n commentaryProfiles: ApiCommentaryProfiles[];\r\n\r\n /**\r\n * The list of chapters for each commentary book.\r\n * This maps to the following endpoint:\r\n * - /api/c/:commentaryId/:bookId/:chapterNumber.json\r\n */\r\n commentaryBookChapters: ApiCommentaryBookChapter[];\r\n\r\n /**\r\n * The list of individual profiles for each commentary.\r\n * This maps to the following endpoint:\r\n * - /api/c/:commentaryId/profiles/:profileId.json\r\n */\r\n commentaryProfileContents: ApiCommentaryProfileContent[];\r\n\r\n /**\r\n * The path prefix that the API should use.\r\n */\r\n pathPrefix: string;\r\n}\r\n\r\n/**\r\n * The list of available translations.\r\n * Maps to the /api/available-translations.json endpoint.\r\n */\r\nexport interface ApiAvailableTranslations {\r\n /**\r\n * The list of translations.\r\n */\r\n translations: ApiTranslation[];\r\n}\r\n\r\n/**\r\n * The list of available commentaries.\r\n * Maps to the /api/available-commentaries.json endpoint.\r\n */\r\nexport interface ApiAvailableCommentaries {\r\n /**\r\n * The list of commentaries.\r\n */\r\n commentaries: ApiCommentary[];\r\n}\r\n\r\n/**\r\n * Defines a translation that is used in the API.\r\n */\r\nexport interface ApiTranslation extends Translation {\r\n /**\r\n * The API link for the list of available books for this translation.\r\n */\r\n listOfBooksApiLink: string;\r\n\r\n /**\r\n * The available list of formats.\r\n */\r\n availableFormats: ('json' | 'usfm')[];\r\n\r\n /**\r\n * The number of books that are contained in this translation.\r\n *\r\n * Complete translations should have the same number of books as the Bible (66).\r\n */\r\n numberOfBooks: number;\r\n\r\n /**\r\n * The total number of chapters that are contained in this translation.\r\n *\r\n * Complete translations should have the same number of chapters as the Bible (1,189).\r\n */\r\n totalNumberOfChapters: number;\r\n\r\n /**\r\n * The total number of verses that are contained in this translation.\r\n *\r\n * Complete translations should have the same number of verses as the Bible (around 31,102 - some translations exclude verses based on the aparent likelyhood of existing in the original source texts).\r\n */\r\n totalNumberOfVerses: number;\r\n\r\n /**\r\n * The total number of apocryphal books that are contained in this translation.\r\n */\r\n numberOfApocryphalBooks?: number;\r\n\r\n /**\r\n * The total number of apocryphal chapters that are contained in this translation.\r\n */\r\n totalNumberOfApocryphalChapters?: number;\r\n\r\n /**\r\n * the total number of apocryphal verses that are contained in this translation.\r\n */\r\n totalNumberOfApocryphalVerses?: number;\r\n\r\n /**\r\n * Gets the name of the language that the translation is in.\r\n * Null or undefined if the name of the language is not known.\r\n */\r\n languageName?: string;\r\n\r\n /**\r\n * Gets the name of the language in English.\r\n * Null or undefined if the language doesn't have an english name.\r\n */\r\n languageEnglishName?: string;\r\n}\r\n\r\n/**\r\n * Defines a commentary that is used in the API.\r\n */\r\nexport interface ApiCommentary extends Commentary {\r\n /**\r\n * The API link for the list of available books for this translation.\r\n */\r\n listOfBooksApiLink: string;\r\n\r\n /**\r\n * The API link for the list of available profiles for this commentary.\r\n */\r\n listOfProfilesApiLink: string;\r\n\r\n /**\r\n * The available list of formats.\r\n */\r\n availableFormats: ('json' | 'usfm')[];\r\n\r\n /**\r\n * The number of books that are contained in this commentary.\r\n *\r\n * Complete commentaries should have the same number of books as the Bible (66).\r\n */\r\n numberOfBooks: number;\r\n\r\n /**\r\n * The total number of chapters that are contained in this translation.\r\n *\r\n * Complete commentaries should have the same number of chapters as the Bible (1,189).\r\n */\r\n totalNumberOfChapters: number;\r\n\r\n /**\r\n * The total number of verses that are contained in this commentary.\r\n *\r\n * Complete commentaries should have the same number of verses as the Bible (around 31,102 - some commentaries exclude verses based on the aparent likelyhood of existing in the original source texts).\r\n */\r\n totalNumberOfVerses: number;\r\n\r\n /**\r\n * The total number of profiles that are contained in this commentary.\r\n *\r\n * Profiles are used to provide additional information about people and people groups that are mentioned in the Bible.\r\n */\r\n totalNumberOfProfiles: number;\r\n\r\n /**\r\n * Gets the name of the language that the commentary is in.\r\n * Null or undefined if the name of the language is not known.\r\n */\r\n languageName?: string;\r\n\r\n /**\r\n * Gets the name of the language in English.\r\n * Null or undefined if the language doesn't have an english name.\r\n */\r\n languageEnglishName?: string;\r\n}\r\n\r\n/**\r\n * Defines an interface that contains information about the books that are available for a translation.\r\n */\r\nexport interface ApiTranslationBooks {\r\n /**\r\n * The translation information for the books.\r\n */\r\n translation: ApiTranslation;\r\n\r\n /**\r\n * The list of books that are available for the translation.\r\n */\r\n books: ApiTranslationBook[];\r\n}\r\n\r\n/**\r\n * Defines an interface that contains information about the books that are available for a commentary.\r\n */\r\nexport interface ApiCommentaryBooks {\r\n /**\r\n * The commentary information for the books.\r\n */\r\n commentary: ApiCommentary;\r\n\r\n /**\r\n * The list of books that are available for the commentary.\r\n */\r\n books: ApiCommentaryBook[];\r\n}\r\n\r\n/**\r\n * Defines an interface that contains information about the profiles that are available for a commentary.\r\n */\r\nexport interface ApiCommentaryProfiles {\r\n /**\r\n * The commentary information for the books.\r\n */\r\n commentary: ApiCommentary;\r\n\r\n /**\r\n * The list of profiles that are available for the commentary.\r\n */\r\n profiles: ApiCommentaryProfile[];\r\n}\r\n\r\n/**\r\n * Defines an interface that contains information about a profile.\r\n */\r\nexport interface ApiCommentaryProfile extends CommentaryProfile {\r\n /**\r\n * The link to this profile.\r\n */\r\n thisProfileLink: string;\r\n\r\n /**\r\n * The link to the chapter that this profile references in the commentary.\r\n */\r\n referenceChapterLink: string | null;\r\n}\r\n\r\n/**\r\n * Defines a translation book that is used in the API.\r\n */\r\nexport interface ApiTranslationBook extends TranslationBook {\r\n /**\r\n * The number of the first chapter in the book.\r\n */\r\n firstChapterNumber: number;\r\n\r\n /**\r\n * The link to the first chapter of the book.\r\n */\r\n firstChapterApiLink: string;\r\n\r\n /**\r\n * The number of the last chapter in the book.\r\n */\r\n lastChapterNumber: number;\r\n\r\n /**\r\n * The link to the last chapter of the book.\r\n */\r\n lastChapterApiLink: string;\r\n\r\n /**\r\n * The number of chapters that the book contains.\r\n */\r\n numberOfChapters: number;\r\n\r\n /**\r\n * The number of verses that the book contains.\r\n */\r\n totalNumberOfVerses: number;\r\n}\r\n\r\n/**\r\n * Defines a commentary book that is used in the API.\r\n */\r\nexport interface ApiCommentaryBook extends CommentaryBook {\r\n /**\r\n * The number of the first chapter in the book.\r\n *\r\n * Null if the comentary book has no chapters.\r\n */\r\n firstChapterNumber: number | null;\r\n\r\n /**\r\n * The link to the first chapter of the book.\r\n *\r\n * Null if the comentary book has no chapters.\r\n */\r\n firstChapterApiLink: string | null;\r\n\r\n /**\r\n * The number of the last chapter in the book.\r\n *\r\n * Null if the comentary book has no chapters.\r\n */\r\n lastChapterNumber: number | null;\r\n\r\n /**\r\n * The link to the last chapter of the book.\r\n *\r\n * Null if the comentary book has no chapters.\r\n */\r\n lastChapterApiLink: string | null;\r\n\r\n /**\r\n * The number of chapters that the book contains.\r\n */\r\n numberOfChapters: number;\r\n\r\n /**\r\n * The number of verses that the book contains.\r\n */\r\n totalNumberOfVerses: number;\r\n}\r\n\r\n/**\r\n * Defines an interface that contains information about a book chapter.\r\n */\r\nexport interface ApiTranslationBookChapter extends TranslationBookChapter {\r\n /**\r\n * The translation information for the book chapter.\r\n */\r\n translation: ApiTranslation;\r\n\r\n /**\r\n * The book information for the book chapter.\r\n */\r\n book: ApiTranslationBook;\r\n\r\n /**\r\n * The link to this chapter.\r\n */\r\n thisChapterLink: string;\r\n\r\n /**\r\n * The link to the next chapter.\r\n * Null if this is the last chapter in the translation.\r\n */\r\n nextChapterApiLink: string | null;\r\n\r\n /**\r\n * The links to the audio versions for the next chapter.\r\n * Null if this is the last chapter in the translation.\r\n */\r\n nextChapterAudioLinks: TranslationBookChapterAudioLinks | null;\r\n\r\n /**\r\n * The link to the previous chapter.\r\n * Null if this is the first chapter in the translation.\r\n */\r\n previousChapterApiLink: string | null;\r\n\r\n /**\r\n * The links to the audio versions for the previous chapter.\r\n * Null if this is the first chapter in the translation.\r\n */\r\n previousChapterAudioLinks: TranslationBookChapterAudioLinks | null;\r\n\r\n /**\r\n * The number of verses that the chapter contains.\r\n */\r\n numberOfVerses: number;\r\n}\r\n\r\n/**\r\n * Defines an interface that contains information about a book chapter.\r\n */\r\nexport interface ApiCommentaryBookChapter extends CommentaryBookChapter {\r\n /**\r\n * The commentary information for the book chapter.\r\n */\r\n commentary: ApiCommentary;\r\n\r\n /**\r\n * The book information for the book chapter.\r\n */\r\n book: ApiCommentaryBook;\r\n\r\n /**\r\n * The link to this chapter.\r\n */\r\n thisChapterLink: string;\r\n\r\n /**\r\n * The link to the next chapter.\r\n * Null if this is the last chapter in the translation.\r\n */\r\n nextChapterApiLink: string | null;\r\n\r\n /**\r\n * The link to the previous chapter.\r\n * Null if this is the first chapter in the translation.\r\n */\r\n previousChapterApiLink: string | null;\r\n\r\n /**\r\n * The number of verses that the chapter contains.\r\n */\r\n numberOfVerses: number;\r\n}\r\n\r\nexport interface ApiTranslationBookChapterAudio {\r\n /**\r\n * The chapter that the audio is for.\r\n */\r\n chapter: ApiTranslationBookChapter;\r\n\r\n /**\r\n * The link that the audio should be placed at.\r\n */\r\n link: string;\r\n\r\n /**\r\n * The original URL of the audio.\r\n */\r\n originalUrl: string;\r\n}\r\n\r\nexport interface ApiCommentaryProfileContent {\r\n /**\r\n * The commentary information for the profile.\r\n */\r\n commentary: ApiCommentary;\r\n\r\n /**\r\n * The information about the profile.\r\n */\r\n profile: ApiCommentaryProfile;\r\n\r\n /**\r\n * The content of the profile.\r\n */\r\n content: string[];\r\n}\r\n\r\n/**\r\n * The options for generating the API.\r\n */\r\nexport interface GenerateApiOptions {\r\n /**\r\n * Whether to use the common name for the book chapter API link. If false, then book IDs are used.\r\n * Audio URLs will always use the book ID.\r\n * Defaults to false.\r\n */\r\n useCommonName?: boolean;\r\n\r\n /**\r\n * Whether to replace the audio URLs in the dataset with ones that are hosted locally.\r\n * If true, then the audio URLs in the dataset will be replaced with ones that reference files hosted by the API itself.\r\n * If false, then the audio URLs in the dataset will be left as is.\r\n * Defaults to false.\r\n */\r\n generateAudioFiles?: boolean;\r\n\r\n /**\r\n * Gets the english name of the given language.\r\n * If not provided, then the english name for the language will be unknown and omitted.\r\n * @param language The language to get the english name for.\r\n */\r\n getEnglishName?: (language: string) => string | null | undefined;\r\n\r\n /**\r\n * Gets the native name of the given language.\r\n * If not provided, then the native name for the language will be unknown and omitted.\r\n * @param language The language to get the native name for.\r\n */\r\n getNativeName?: (language: string) => string | null | undefined;\r\n\r\n /**\r\n * The prefix that should be added to paths that are generated.\r\n */\r\n pathPrefix?: string;\r\n}\r\n\r\n/**\r\n * Generates the API output for the given dataset.\r\n * @param dataset The dataset to generate the API for.\r\n * @param options The options for generating the API.\r\n */\r\nexport function generateApiForDataset(\r\n dataset: DatasetOutput,\r\n options: GenerateApiOptions = {}\r\n): ApiOutput {\r\n const { useCommonName, pathPrefix } = options;\r\n const apiPathPrefix = pathPrefix ? pathPrefix : '';\r\n let api: ApiOutput = {\r\n availableTranslations: {\r\n translations: [],\r\n },\r\n translationBooks: [],\r\n translationBookChapters: [],\r\n translationBookChapterAudio: [],\r\n availableCommentaries: {\r\n commentaries: [],\r\n },\r\n commentaryBookChapters: [],\r\n commentaryBooks: [],\r\n commentaryProfiles: [],\r\n commentaryProfileContents: [],\r\n pathPrefix: apiPathPrefix,\r\n };\r\n\r\n const getNativeName = options.getNativeName;\r\n const getEnglishName = options.getEnglishName;\r\n\r\n for (let { books, ...translation } of dataset.translations) {\r\n let numberOfBooks = 0;\r\n let numberOfApocryphalBooks = 0;\r\n\r\n for (let book of books) {\r\n if (book.isApocryphal) {\r\n numberOfApocryphalBooks++;\r\n } else {\r\n numberOfBooks++;\r\n }\r\n }\r\n\r\n const apiTranslation: ApiTranslation = {\r\n ...translation,\r\n availableFormats: ['json'],\r\n listOfBooksApiLink: listOfBooksApiLink(\r\n translation.id,\r\n apiPathPrefix\r\n ),\r\n numberOfBooks,\r\n totalNumberOfChapters: 0,\r\n totalNumberOfVerses: 0,\r\n languageName: getNativeName\r\n ? (getNativeName(translation.language) ?? undefined)\r\n : undefined,\r\n languageEnglishName: getEnglishName\r\n ? (getEnglishName(translation.language) ?? undefined)\r\n : undefined,\r\n };\r\n\r\n if (numberOfApocryphalBooks > 0) {\r\n apiTranslation.numberOfApocryphalBooks = numberOfApocryphalBooks;\r\n }\r\n\r\n const translationBooks: ApiTranslationBooks = {\r\n translation: apiTranslation,\r\n books: [],\r\n };\r\n\r\n let translationChapters: ApiTranslationBookChapter[] = [];\r\n\r\n for (let { chapters, ...book } of books) {\r\n const firstChapterNumber = chapters[0].chapter.number;\r\n const lastChapterNumber =\r\n chapters[chapters.length - 1].chapter.number;\r\n const apiBook: ApiTranslationBook = {\r\n ...book,\r\n firstChapterNumber,\r\n firstChapterApiLink: bookChapterApiLink(\r\n translation.id,\r\n getBookLink(book),\r\n firstChapterNumber,\r\n 'json',\r\n apiPathPrefix\r\n ),\r\n lastChapterNumber,\r\n lastChapterApiLink: bookChapterApiLink(\r\n translation.id,\r\n getBookLink(book),\r\n lastChapterNumber,\r\n 'json',\r\n apiPathPrefix\r\n ),\r\n numberOfChapters: chapters.length,\r\n totalNumberOfVerses: 0,\r\n };\r\n\r\n for (let { chapter, thisChapterAudioLinks } of chapters) {\r\n const audio: TranslationBookChapterAudioLinks = {};\r\n const apiBookChapter: ApiTranslationBookChapter = {\r\n translation: apiTranslation,\r\n book: apiBook,\r\n chapter: chapter,\r\n thisChapterLink: bookChapterApiLink(\r\n translation.id,\r\n getBookLink(book),\r\n chapter.number,\r\n 'json',\r\n apiPathPrefix\r\n ),\r\n thisChapterAudioLinks: audio,\r\n nextChapterApiLink: null,\r\n nextChapterAudioLinks: null,\r\n previousChapterApiLink: null,\r\n previousChapterAudioLinks: null,\r\n numberOfVerses: 0,\r\n };\r\n\r\n for (let reader in thisChapterAudioLinks) {\r\n if (options.generateAudioFiles) {\r\n const apiAudio: ApiTranslationBookChapterAudio = {\r\n chapter: apiBookChapter,\r\n link: bookChapterAudioApiLink(\r\n translation.id,\r\n getBookLink(book),\r\n chapter.number,\r\n reader,\r\n apiPathPrefix\r\n ),\r\n originalUrl: thisChapterAudioLinks[reader],\r\n };\r\n audio[reader] = apiAudio.link;\r\n api.translationBookChapterAudio.push(apiAudio);\r\n } else {\r\n audio[reader] = thisChapterAudioLinks[reader];\r\n }\r\n }\r\n\r\n for (let c of chapter.content) {\r\n if (c.type === 'verse') {\r\n apiBookChapter.numberOfVerses++;\r\n }\r\n }\r\n\r\n apiBook.totalNumberOfVerses += apiBookChapter.numberOfVerses;\r\n\r\n translationChapters.push(apiBookChapter);\r\n api.translationBookChapters.push(apiBookChapter);\r\n }\r\n\r\n translationBooks.books.push(apiBook);\r\n\r\n if (apiBook.isApocryphal) {\r\n if (!apiTranslation.totalNumberOfApocryphalChapters) {\r\n apiTranslation.totalNumberOfApocryphalChapters = 0;\r\n }\r\n if (!apiTranslation.totalNumberOfApocryphalVerses) {\r\n apiTranslation.totalNumberOfApocryphalVerses = 0;\r\n }\r\n apiTranslation.totalNumberOfApocryphalChapters +=\r\n apiBook.numberOfChapters;\r\n apiTranslation.totalNumberOfApocryphalVerses +=\r\n apiBook.totalNumberOfVerses;\r\n } else {\r\n apiTranslation.totalNumberOfChapters +=\r\n apiBook.numberOfChapters;\r\n apiTranslation.totalNumberOfVerses +=\r\n apiBook.totalNumberOfVerses;\r\n }\r\n }\r\n\r\n for (let i = 0; i < translationChapters.length; i++) {\r\n if (i > 0) {\r\n translationChapters[i].previousChapterApiLink =\r\n bookChapterApiLink(\r\n translation.id,\r\n getBookLink(translationChapters[i - 1].book),\r\n translationChapters[i - 1].chapter.number,\r\n 'json',\r\n apiPathPrefix\r\n );\r\n translationChapters[i].previousChapterAudioLinks =\r\n translationChapters[i - 1].thisChapterAudioLinks;\r\n }\r\n\r\n if (i < translationChapters.length - 1) {\r\n translationChapters[i].nextChapterApiLink = bookChapterApiLink(\r\n translation.id,\r\n getBookLink(translationChapters[i + 1].book),\r\n translationChapters[i + 1].chapter.number,\r\n 'json',\r\n apiPathPrefix\r\n );\r\n translationChapters[i].nextChapterAudioLinks =\r\n translationChapters[i + 1].thisChapterAudioLinks;\r\n }\r\n }\r\n\r\n api.availableTranslations.translations.push(apiTranslation);\r\n api.translationBooks.push(translationBooks);\r\n }\r\n\r\n for (let { books, profiles, ...commentary } of dataset.commentaries) {\r\n const apiCommentary: ApiCommentary = {\r\n ...commentary,\r\n availableFormats: ['json'],\r\n listOfBooksApiLink: listOfCommentaryBooksApiLink(\r\n commentary.id,\r\n apiPathPrefix\r\n ),\r\n listOfProfilesApiLink: profilesCommentaryApiLink(\r\n commentary.id,\r\n 'json',\r\n apiPathPrefix\r\n ),\r\n numberOfBooks: books.length,\r\n totalNumberOfChapters: 0,\r\n totalNumberOfVerses: 0,\r\n totalNumberOfProfiles: 0,\r\n languageName: getNativeName\r\n ? (getNativeName(commentary.language) ?? undefined)\r\n : undefined,\r\n languageEnglishName: getEnglishName\r\n ? (getEnglishName(commentary.language) ?? undefined)\r\n : undefined,\r\n };\r\n\r\n const commentaryBooks: ApiCommentaryBooks = {\r\n commentary: apiCommentary,\r\n books: [],\r\n };\r\n\r\n const commentaryProfiles: ApiCommentaryProfiles = {\r\n commentary: apiCommentary,\r\n profiles: [],\r\n };\r\n\r\n let commentaryChapters: ApiCommentaryBookChapter[] = [];\r\n\r\n for (let { chapters, ...book } of books) {\r\n const firstChapterNumber = chapters[0]?.chapter.number ?? null;\r\n const lastChapterNumber =\r\n chapters[chapters.length - 1]?.chapter.number ?? null;\r\n const apiBook: ApiCommentaryBook = {\r\n ...book,\r\n firstChapterNumber,\r\n firstChapterApiLink: firstChapterNumber\r\n ? bookCommentaryChapterApiLink(\r\n commentary.id,\r\n getBookLink(book),\r\n firstChapterNumber,\r\n 'json',\r\n apiPathPrefix\r\n )\r\n : null,\r\n lastChapterNumber,\r\n lastChapterApiLink: lastChapterNumber\r\n ? bookCommentaryChapterApiLink(\r\n commentary.id,\r\n getBookLink(book),\r\n lastChapterNumber,\r\n 'json',\r\n apiPathPrefix\r\n )\r\n : null,\r\n numberOfChapters: chapters.length,\r\n totalNumberOfVerses: 0,\r\n };\r\n\r\n for (let { chapter } of chapters) {\r\n const apiBookChapter: ApiCommentaryBookChapter = {\r\n commentary: apiCommentary,\r\n book: apiBook,\r\n chapter: chapter,\r\n thisChapterLink: bookCommentaryChapterApiLink(\r\n commentary.id,\r\n getBookLink(book),\r\n chapter.number,\r\n 'json',\r\n apiPathPrefix\r\n ),\r\n nextChapterApiLink: null,\r\n previousChapterApiLink: null,\r\n numberOfVerses: 0,\r\n };\r\n\r\n for (let c of chapter.content) {\r\n if (c.type === 'verse') {\r\n apiBookChapter.numberOfVerses++;\r\n }\r\n }\r\n\r\n apiBook.totalNumberOfVerses += apiBookChapter.numberOfVerses;\r\n\r\n commentaryChapters.push(apiBookChapter);\r\n api.commentaryBookChapters.push(apiBookChapter);\r\n }\r\n\r\n commentaryBooks.books.push(apiBook);\r\n\r\n apiCommentary.totalNumberOfChapters += apiBook.numberOfChapters;\r\n apiCommentary.totalNumberOfVerses += apiBook.totalNumberOfVerses;\r\n }\r\n\r\n if (profiles) {\r\n for (let profile of profiles) {\r\n const apiProfile: ApiCommentaryProfile = {\r\n id: profile.id,\r\n reference: profile.reference,\r\n subject: profile.subject,\r\n thisProfileLink: profileCommentaryApiLink(\r\n commentary.id,\r\n profile.id,\r\n 'json',\r\n apiPathPrefix\r\n ),\r\n referenceChapterLink: profile.reference\r\n ? bookCommentaryChapterApiLink(\r\n commentary.id,\r\n profile.reference.book,\r\n profile.reference.chapter,\r\n 'json',\r\n apiPathPrefix\r\n )\r\n : null,\r\n };\r\n\r\n const apiProfileContent: ApiCommentaryProfileContent = {\r\n commentary: apiCommentary,\r\n profile: apiProfile,\r\n content: profile.content,\r\n };\r\n\r\n apiCommentary.totalNumberOfProfiles += 1;\r\n commentaryProfiles.profiles.push(apiProfile);\r\n api.commentaryProfileContents.push(apiProfileContent);\r\n }\r\n }\r\n\r\n for (let i = 0; i < commentaryChapters.length; i++) {\r\n if (i > 0) {\r\n commentaryChapters[i].previousChapterApiLink =\r\n bookCommentaryChapterApiLink(\r\n commentary.id,\r\n getBookLink(commentaryChapters[i - 1].book),\r\n commentaryChapters[i - 1].chapter.number,\r\n 'json',\r\n apiPathPrefix\r\n );\r\n // commentaryChapters[i].previousChapterAudioLinks =\r\n // commentaryChapters[i - 1].thisChapterAudioLinks;\r\n }\r\n\r\n if (i < commentaryChapters.length - 1) {\r\n commentaryChapters[i].nextChapterApiLink =\r\n bookCommentaryChapterApiLink(\r\n commentary.id,\r\n getBookLink(commentaryChapters[i + 1].book),\r\n commentaryChapters[i + 1].chapter.number,\r\n 'json',\r\n apiPathPrefix\r\n );\r\n // commentaryChapters[i].nextChapterAudioLinks =\r\n // commentaryChapters[i + 1].thisChapterAudioLinks;\r\n }\r\n }\r\n\r\n api.availableCommentaries.commentaries.push(apiCommentary);\r\n api.commentaryBooks.push(commentaryBooks);\r\n api.commentaryProfiles.push(commentaryProfiles);\r\n }\r\n\r\n return api;\r\n\r\n function getBookLink(book: TranslationBook | CommentaryBook): string {\r\n return useCommonName ? book.commonName : book.id;\r\n }\r\n}\r\n\r\n/**\r\n * Generates the output files for the given API.\r\n * @param api The API that the files should be generated for.\r\n */\r\nexport function generateFilesForApi(api: ApiOutput): OutputFile[] {\r\n let files: OutputFile[] = [];\r\n\r\n files.push(\r\n jsonFile(\r\n `${api.pathPrefix}/api/available_translations.json`,\r\n api.availableTranslations,\r\n true\r\n )\r\n );\r\n for (let translationBooks of api.translationBooks) {\r\n files.push(\r\n jsonFile(\r\n translationBooks.translation.listOfBooksApiLink,\r\n translationBooks\r\n )\r\n );\r\n }\r\n\r\n for (let bookChapter of api.translationBookChapters) {\r\n files.push(jsonFile(bookChapter.thisChapterLink, bookChapter));\r\n }\r\n\r\n for (let audio of api.translationBookChapterAudio) {\r\n files.push(downloadedFile(audio.link, audio.originalUrl));\r\n }\r\n\r\n files.push(\r\n jsonFile(\r\n `${api.pathPrefix}/api/available_commentaries.json`,\r\n api.availableCommentaries,\r\n true\r\n )\r\n );\r\n for (let commentaryBooks of api.commentaryBooks) {\r\n files.push(\r\n jsonFile(\r\n commentaryBooks.commentary.listOfBooksApiLink,\r\n commentaryBooks\r\n )\r\n );\r\n }\r\n\r\n for (let commentaryProfiles of api.commentaryProfiles) {\r\n files.push(\r\n jsonFile(\r\n commentaryProfiles.commentary.listOfProfilesApiLink,\r\n commentaryProfiles\r\n )\r\n );\r\n }\r\n\r\n for (let profileContent of api.commentaryProfileContents) {\r\n files.push(\r\n jsonFile(profileContent.profile.thisProfileLink, profileContent)\r\n );\r\n }\r\n\r\n for (let bookChapter of api.commentaryBookChapters) {\r\n files.push(jsonFile(bookChapter.thisChapterLink, bookChapter));\r\n }\r\n\r\n // for (let audio of api.translationBookChapterAudio) {\r\n // files.push(downloadedFile(audio.link, audio.originalUrl));\r\n // }\r\n\r\n return files;\r\n}\r\n\r\n/**\r\n * Generates the output files for the given datasets.\r\n * @param datasets The datasets to generate the output files for.\r\n * @param options The options for generating the API files.\r\n */\r\nexport async function* generateOutputFilesFromDatasets(\r\n datasets: AsyncIterable<DatasetOutput>,\r\n options?: GenerateApiOptions\r\n): AsyncGenerator<OutputFile[]> {\r\n for await (let dataset of datasets) {\r\n const api = generateApiForDataset(dataset, options);\r\n const files = generateFilesForApi(api);\r\n\r\n yield files;\r\n }\r\n}\r\n\r\n/**\r\n * Gets the API Link for the list of books endpoint for a translation.\r\n * @param translationId The ID of the translation.\r\n * @returns\r\n */\r\nexport function listOfBooksApiLink(\r\n translationId: string,\r\n prefix: string = ''\r\n): string {\r\n return `${prefix}/api/${translationId}/books.json`;\r\n}\r\n\r\n/**\r\n * Gets the API Link for the list of books endpoint for a commentary.\r\n * @param commentaryId The ID of the commentary.\r\n * @returns\r\n */\r\nexport function listOfCommentaryBooksApiLink(\r\n commentaryId: string,\r\n prefix: string = ''\r\n): string {\r\n return `${prefix}/api/c/${commentaryId}/books.json`;\r\n}\r\n\r\n/**\r\n * Getes the API link for a book chapter.\r\n * @param translationId The ID of the translation.\r\n * @param commonName The name of the book.\r\n * @param chapterNumber The number of the book.\r\n * @param extension The extension of the file.\r\n */\r\nexport function bookChapterApiLink(\r\n translationId: string,\r\n commonName: string,\r\n chapterNumber: number,\r\n extension: string,\r\n prefix: string = ''\r\n) {\r\n return `${prefix}/api/${translationId}/${replaceSpacesWithUnderscores(\r\n commonName\r\n )}/${chapterNumber}.${extension}`;\r\n}\r\n\r\n/**\r\n * Getes the API link for a book chapter.\r\n * @param translationId The ID of the translation.\r\n * @param commonName The name of the book.\r\n * @param chapterNumber The number of the book.\r\n * @param extension The extension of the file.\r\n */\r\nexport function bookCommentaryChapterApiLink(\r\n translationId: string,\r\n commonName: string,\r\n chapterNumber: number,\r\n extension: string,\r\n prefix: string = ''\r\n) {\r\n return `${prefix}/api/c/${translationId}/${replaceSpacesWithUnderscores(\r\n commonName\r\n )}/${chapterNumber}.${extension}`;\r\n}\r\n\r\nexport function bookChapterAudioApiLink(\r\n translationId: string,\r\n bookId: string,\r\n chapterNumber: number,\r\n reader: string,\r\n prefix: string = ''\r\n) {\r\n return `${prefix}/api/${translationId}/${replaceSpacesWithUnderscores(\r\n bookId\r\n )}/${chapterNumber}.${reader}.mp3`;\r\n}\r\n\r\n/**\r\n * Gets the API link for a profile.\r\n * @param translationId The ID of the translation.\r\n * @param profileId The ID of the profile.\r\n * @param extension The extension of the file.\r\n */\r\nexport function profilesCommentaryApiLink(\r\n translationId: string,\r\n extension: string,\r\n prefix: string = ''\r\n) {\r\n return `${prefix}/api/c/${translationId}/profiles.${extension}`;\r\n}\r\n\r\n/**\r\n * Gets the API link for a profile.\r\n * @param translationId The ID of the translation.\r\n * @param profileId The ID of the profile.\r\n * @param extension The extension of the file.\r\n */\r\nexport function profileCommentaryApiLink(\r\n translationId: string,\r\n profileId: string,\r\n extension: string,\r\n prefix: string = ''\r\n) {\r\n return `${prefix}/api/c/${translationId}/profiles/${replaceSpacesWithUnderscores(\r\n profileId\r\n )}.${extension}`;\r\n}\r\n\r\nexport function jsonFile(\r\n path: string,\r\n content: any,\r\n mergable?: boolean\r\n): OutputFile {\r\n return {\r\n path,\r\n content,\r\n mergable,\r\n };\r\n}\r\n\r\nexport function downloadedFile(path: string, url: string): OutputFile {\r\n return {\r\n path,\r\n content: () => fetch(url).then((response) => response.body),\r\n };\r\n}\r\n\r\nexport function replaceSpacesWithUnderscores(str: string): string {\r\n return str.replace(/[<>:\"/\\\\|?*\\s]/g, '_');\r\n}\r\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAA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Q,aAAa,IAAI;AAAA,IACrC;AAAA,EACJ,CAAC,IAAI,aAAa,IAAI,MAAM;AAChC;AAQO,SAAS,0BACZ,eACA,WACA,SAAiB,IACnB;AACE,SAAO,GAAG,MAAM,UAAU,aAAa,aAAa,SAAS;AACjE;AAQO,SAAS,yBACZ,eACA,WACA,WACA,SAAiB,IACnB;AACE,SAAO,GAAG,MAAM,UAAU,aAAa,aAAa;AAAA,IAChD;AAAA,EACJ,CAAC,IAAI,SAAS;AAClB;AAEO,SAAS,SACZ,MACA,SACA,UACU;AACV,SAAO;AAAA,IACH;AAAA,IACA;AAAA,IACA;AAAA,EACJ;AACJ;AAEO,SAAS,eAAe,MAAc,KAAyB;AAClE,SAAO;AAAA,IACH;AAAA,IACA,SAAS,MAAM,MAAM,GAAG,EAAE,KAAK,CAAC,aAAa,SAAS,IAAI;AAAA,EAC9D;AACJ;AAEO,SAAS,6BAA6B,KAAqB;AAC9D,SAAO,IAAI,QAAQ,mBAAmB,GAAG;AAC7C;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/cjs/utils.cjs
CHANGED
|
@@ -250,14 +250,16 @@ function getBookId(book) {
|
|
|
250
250
|
return null;
|
|
251
251
|
}
|
|
252
252
|
const KNOWN_SKIPPED_VERSES = /* @__PURE__ */ new Set([
|
|
253
|
+
"MAT 12:47",
|
|
253
254
|
"MAT 17:21",
|
|
254
255
|
"MAT 18:11",
|
|
255
256
|
"MAT 23:14",
|
|
256
|
-
"
|
|
257
|
-
"
|
|
258
|
-
"
|
|
259
|
-
"
|
|
257
|
+
"MRK 7:16",
|
|
258
|
+
"MRK 9:44",
|
|
259
|
+
"MRK 9:46",
|
|
260
|
+
"MRK 11:26",
|
|
260
261
|
"LUK 17:36",
|
|
262
|
+
"LUK 23:17",
|
|
261
263
|
"JHN 5:4",
|
|
262
264
|
"ACT 8:37",
|
|
263
265
|
"ACT 15:34",
|
package/dist/cjs/utils.cjs.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../utils.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Normalizes the given language code into a ISO 639 code.\n * @param language The language code to normalize.\n */\nexport function normalizeLanguage(language: string): string {\n return language;\n}\n\n/**\n * The map of translation IDs from fetch.bible to their translation ID in the API.\n */\nconst TRANSLATION_ID_MAP: Map<string, string> = new Map([\n ['eng_bsb', 'BSB'],\n ['arb_nav', 'ARBNAV'],\n ['eng_webp', 'ENGWEBP'],\n ['hin_irv', 'HINIRV'],\n ['hbo_mas', 'HBOMAS'],\n ['eng_drv', 'eng_dra'],\n]);\n\n/**\n * Gets the ID of the translation.\n * @param translation The translation to get the ID for.\n */\nexport function getTranslationId(translationId: string): string {\n return TRANSLATION_ID_MAP.get(translationId) ?? translationId;\n}\n\nexport function isEmptyOrWhitespace(str: string | null | undefined): boolean {\n return !str || /^\\s*$/.test(str);\n}\n\nexport function getFirstNonEmpty<T extends string>(...values: T[]): T {\n for (let value of values) {\n if (!isEmptyOrWhitespace(value)) {\n return value;\n }\n }\n\n throw new Error('All values are empty or whitespace!');\n}\n\nexport interface VerseRef {\n book: string;\n chapter: number;\n verse: number;\n\n /**\n * The rest of the content of the verse.\n */\n content?: string;\n\n /**\n * The chapter that the verse reference ends at.\n */\n endChapter?: number;\n\n /**\n * The verse that the verse reference ends at.\n */\n endVerse?: number;\n}\n\n/**\n * Parses the given verse reference.\n * Formatted like \"GEN 1:1\".\n *\n * @param text The reference to parse.\n */\nexport function parseVerseReference(text: string): VerseRef | null {\n const match = text.match(\n /^\\s*([0-9A-Za-z\\s]+)[\\s\\.]+(\\d+)[:\\.](\\d+)(?:-([0-9]+)(?:[\\s:\\.]([0-9]+))?)?/\n );\n\n if (!match) {\n return null;\n }\n\n const [reference, book, chapterStr, verseStr, endChapterStr, endVerseStr] =\n match;\n\n const chapter = parseInt(chapterStr);\n const verse = parseInt(verseStr);\n\n let endChapter = endChapterStr ? parseInt(endChapterStr) : undefined;\n let endVerse = endVerseStr ? parseInt(endVerseStr) : undefined;\n\n if (endChapter && !endVerse) {\n endVerse = endChapter;\n endChapter = undefined;\n }\n\n if (isNaN(chapter) || isNaN(verse)) {\n return null;\n }\n\n if (reference.length !== text.length) {\n return {\n book: getBookId(book) ?? book,\n chapter,\n verse,\n content: text.substring(reference.length).trim(),\n endChapter,\n endVerse,\n };\n }\n\n return {\n book: getBookId(book) ?? book,\n chapter,\n verse,\n endChapter,\n endVerse,\n };\n}\n\n/**\n * Defines a map that maps the book ID to the USFM Book identifier.\n */\nconst BOOK_ID_MAP: Map<string, string> = new Map([\n ['gen', 'GEN'],\n ['genesis', 'GEN'],\n ['exo', 'EXO'],\n ['exodus', 'EXO'],\n ['lev', 'LEV'],\n ['lev', 'LEV'],\n ['laviticus', 'LEV'],\n ['num', 'NUM'],\n ['numbers', 'NUM'],\n ['deu', 'DEU'],\n ['deuteronomy', 'DEU'],\n ['jos', 'JOS'],\n ['joshua', 'JOS'],\n ['jdg', 'JDG'],\n ['judges', 'JDG'],\n ['rut', 'RUT'],\n ['ruth', 'RUT'],\n ['1sa', '1SA'],\n ['1samuel', '1SA'],\n ['2sa', '2SA'],\n ['2samuel', '2SA'],\n ['1ki', '1KI'],\n ['1kings', '1KI'],\n ['1kgs', '1KI'],\n ['2ki', '2KI'],\n ['2kings', '2KI'],\n ['2kgs', '2KI'],\n ['1ch', '1CH'],\n ['1chronicles', '1CH'],\n ['chronicles1', '1CH'],\n ['2ch', '2CH'],\n ['2chronicles', '2CH'],\n ['chronicles2', '2CH'],\n ['ezr', 'EZR'],\n ['ezra', 'EZR'],\n ['neh', 'NEH'],\n ['nehemiah', 'NEH'],\n ['est', 'EST'],\n ['ester', 'EST'],\n ['job', 'JOB'],\n ['ps', 'PSA'],\n ['psa', 'PSA'],\n ['psalms', 'PSA'],\n ['psalm', 'PSA'],\n ['pr', 'PRO'],\n ['pro', 'PRO'],\n ['proverbs', 'PRO'],\n ['ecc', 'ECC'],\n ['ecclesiastes', 'ECC'],\n ['eccl', 'ECC'],\n ['sng', 'SNG'],\n ['song', 'SNG'],\n ['songofsolomon', 'SNG'],\n ['isa', 'ISA'],\n ['isaiah', 'ISA'],\n ['jer', 'JER'],\n ['jeremiah', 'JER'],\n ['lam', 'LAM'],\n ['lamentations', 'LAM'],\n ['ezk', 'EZK'],\n ['ezekiel', 'EZK'],\n ['ezek', 'EZK'],\n ['dan', 'DAN'],\n ['daniel', 'DAN'],\n ['hos', 'HOS'],\n ['hosea', 'HOS'],\n ['jol', 'JOL'],\n ['joel', 'JOL'],\n ['amo', 'AMO'],\n ['amos', 'AMO'],\n ['oba', 'OBA'],\n ['obadiah', 'OBA'],\n ['jon', 'JON'],\n ['jonah', 'JON'],\n ['mic', 'MIC'],\n ['micah', 'MIC'],\n ['nam', 'NAM'],\n ['nahum', 'NAM'],\n ['nah', 'NAM'],\n ['hab', 'HAB'],\n ['habakkuk', 'HAB'],\n ['zep', 'ZEP'],\n ['zepaniah', 'ZEP'],\n ['hag', 'HAG'],\n ['haggai', 'HAG'],\n ['zec', 'ZEC'],\n ['zechariah', 'ZEC'],\n ['mal', 'MAL'],\n ['malachi', 'MAL'],\n ['mat', 'MAT'],\n ['matthew', 'MAT'],\n ['mrk', 'MRK'],\n ['mark', 'MRK'],\n ['luk', 'LUK'],\n ['luke', 'LUK'],\n ['jhn', 'JHN'],\n ['john', 'JHN'],\n ['act', 'ACT'],\n ['acts', 'ACT'],\n ['rom', 'ROM'],\n ['romans', 'ROM'],\n ['1co', '1CO'],\n ['1corinthians', '1CO'],\n ['2co', '2CO'],\n ['2corinthians', '2CO'],\n ['gal', 'GAL'],\n ['galatians', 'GAL'],\n ['eph', 'EPH'],\n ['ephesians', 'EPH'],\n ['php', 'PHP'],\n ['philippians', 'PHP'],\n ['phil', 'PHP'],\n ['col', 'COL'],\n ['colossians', 'COL'],\n ['1th', '1TH'],\n ['1thessalonians', '1TH'],\n ['2th', '2TH'],\n ['2thessalonians', '2TH'],\n ['1ti', '1TI'],\n ['1timothy', '1TI'],\n ['2ti', '2TI'],\n ['2timothy', '2TI'],\n ['tit', 'TIT'],\n ['titus', 'TIT'],\n ['phm', 'PHM'],\n ['philemon', 'PHM'],\n ['phlm', 'PHM'],\n ['heb', 'HEB'],\n ['hebrews', 'HEB'],\n ['jas', 'JAS'],\n ['james', 'JAS'],\n ['1pe', '1PE'],\n ['1peter', '1PE'],\n ['2pe', '2PE'],\n ['2peter', '2PE'],\n ['1jn', '1JN'],\n ['1john', '1JN'],\n ['2jn', '2JN'],\n ['2john', '2JN'],\n ['3jn', '3JN'],\n ['3john', '3JN'],\n ['jud', 'JUD'],\n ['jude', 'JUD'],\n ['rev', 'REV'],\n ['revelation', 'REV'],\n]);\n\n/**\n * Gets the ID of the given book.\n * Returns null if the ID could not be found.\n * @param book The name/ID of the book.\n */\nexport function getBookId(book: string): string | null {\n const bookLower = book.toLowerCase().replaceAll(/\\s+/g, '');\n\n const id = BOOK_ID_MAP.get(bookLower);\n if (id) {\n return id;\n }\n\n for (let [key, id] of BOOK_ID_MAP) {\n if (bookLower.startsWith(key)) {\n return id;\n }\n }\n\n return null;\n}\n\n/**\n * A brief list of verses which may appear in some older translations\n * but are not present in more modern translations.\n */\nexport const KNOWN_SKIPPED_VERSES = new Set([\n 'MAT 17:21',\n 'MAT 18:11',\n 'MAT 23:14',\n '
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAIO,SAAS,kBAAkB,UAA0B;AACxD,SAAO;AACX;AAKA,MAAM,qBAA0C,oBAAI,IAAI;AAAA,EACpD,CAAC,WAAW,KAAK;AAAA,EACjB,CAAC,WAAW,QAAQ;AAAA,EACpB,CAAC,YAAY,SAAS;AAAA,EACtB,CAAC,WAAW,QAAQ;AAAA,EACpB,CAAC,WAAW,QAAQ;AAAA,EACpB,CAAC,WAAW,SAAS;AACzB,CAAC;AAMM,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,EACb,CAAC,WAAW,KAAK;AAAA,EACjB,CAAC,OAAO,KAAK;AAAA,EACb,CAAC,SAAS,KAAK;AAAA,EACf,CAAC,OAAO,KAAK;AAAA,EACb,CAAC,UAAU,KAAK;AAAA,EAChB,CAAC,OAAO,KAAK;AAAA,EACb,CAAC,UAAU,KAAK;AAAA,EAChB,CAAC,OAAO,KAAK;AAAA,EACb,CAAC,SAAS,KAAK;AAAA,EACf,CAAC,OAAO,KAAK;AAAA,EACb,CAAC,SAAS,KAAK;AAAA,EACf,CAAC,OAAO,KAAK;AAAA,EACb,CAAC,SAAS,KAAK;AAAA,EACf,CAAC,OAAO,KAAK;AAAA,EACb,CAAC,QAAQ,KAAK;AAAA,EACd,CAAC,OAAO,KAAK;AAAA,EACb,CAAC,cAAc,KAAK;AACxB,CAAC;AAOM,SAAS,UAAU,MAA6B;AACnD,QAAM,YAAY,KAAK,YAAY,EAAE,WAAW,QAAQ,EAAE;AAE1D,QAAM,KAAK,YAAY,IAAI,SAAS;AACpC,MAAI,IAAI;AACJ,WAAO;AAAA,EACX;AAEA,WAAS,CAAC,KAAKA,GAAE,KAAK,aAAa;AAC/B,QAAI,UAAU,WAAW,GAAG,GAAG;AAC3B,aAAOA;AAAA,IACX;AAAA,EACJ;AAEA,SAAO;AACX;AAMO,MAAM,uBAAuB,oBAAI,IAAI;AAAA,EACxC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACJ,CAAC;",
|
|
4
|
+
"sourcesContent": ["/**\n * Normalizes the given language code into a ISO 639 code.\n * @param language The language code to normalize.\n */\nexport function normalizeLanguage(language: string): string {\n return language;\n}\n\n/**\n * The map of translation IDs from fetch.bible to their translation ID in the API.\n */\nconst TRANSLATION_ID_MAP: Map<string, string> = new Map([\n ['eng_bsb', 'BSB'],\n ['arb_nav', 'ARBNAV'],\n ['eng_webp', 'ENGWEBP'],\n ['hin_irv', 'HINIRV'],\n ['hbo_mas', 'HBOMAS'],\n ['eng_drv', 'eng_dra'],\n]);\n\n/**\n * Gets the ID of the translation.\n * @param translation The translation to get the ID for.\n */\nexport function getTranslationId(translationId: string): string {\n return TRANSLATION_ID_MAP.get(translationId) ?? translationId;\n}\n\nexport function isEmptyOrWhitespace(str: string | null | undefined): boolean {\n return !str || /^\\s*$/.test(str);\n}\n\nexport function getFirstNonEmpty<T extends string>(...values: T[]): T {\n for (let value of values) {\n if (!isEmptyOrWhitespace(value)) {\n return value;\n }\n }\n\n throw new Error('All values are empty or whitespace!');\n}\n\nexport interface VerseRef {\n book: string;\n chapter: number;\n verse: number;\n\n /**\n * The rest of the content of the verse.\n */\n content?: string;\n\n /**\n * The chapter that the verse reference ends at.\n */\n endChapter?: number;\n\n /**\n * The verse that the verse reference ends at.\n */\n endVerse?: number;\n}\n\n/**\n * Parses the given verse reference.\n * Formatted like \"GEN 1:1\".\n *\n * @param text The reference to parse.\n */\nexport function parseVerseReference(text: string): VerseRef | null {\n const match = text.match(\n /^\\s*([0-9A-Za-z\\s]+)[\\s\\.]+(\\d+)[:\\.](\\d+)(?:-([0-9]+)(?:[\\s:\\.]([0-9]+))?)?/\n );\n\n if (!match) {\n return null;\n }\n\n const [reference, book, chapterStr, verseStr, endChapterStr, endVerseStr] =\n match;\n\n const chapter = parseInt(chapterStr);\n const verse = parseInt(verseStr);\n\n let endChapter = endChapterStr ? parseInt(endChapterStr) : undefined;\n let endVerse = endVerseStr ? parseInt(endVerseStr) : undefined;\n\n if (endChapter && !endVerse) {\n endVerse = endChapter;\n endChapter = undefined;\n }\n\n if (isNaN(chapter) || isNaN(verse)) {\n return null;\n }\n\n if (reference.length !== text.length) {\n return {\n book: getBookId(book) ?? book,\n chapter,\n verse,\n content: text.substring(reference.length).trim(),\n endChapter,\n endVerse,\n };\n }\n\n return {\n book: getBookId(book) ?? book,\n chapter,\n verse,\n endChapter,\n endVerse,\n };\n}\n\n/**\n * Defines a map that maps the book ID to the USFM Book identifier.\n */\nconst BOOK_ID_MAP: Map<string, string> = new Map([\n ['gen', 'GEN'],\n ['genesis', 'GEN'],\n ['exo', 'EXO'],\n ['exodus', 'EXO'],\n ['lev', 'LEV'],\n ['lev', 'LEV'],\n ['laviticus', 'LEV'],\n ['num', 'NUM'],\n ['numbers', 'NUM'],\n ['deu', 'DEU'],\n ['deuteronomy', 'DEU'],\n ['jos', 'JOS'],\n ['joshua', 'JOS'],\n ['jdg', 'JDG'],\n ['judges', 'JDG'],\n ['rut', 'RUT'],\n ['ruth', 'RUT'],\n ['1sa', '1SA'],\n ['1samuel', '1SA'],\n ['2sa', '2SA'],\n ['2samuel', '2SA'],\n ['1ki', '1KI'],\n ['1kings', '1KI'],\n ['1kgs', '1KI'],\n ['2ki', '2KI'],\n ['2kings', '2KI'],\n ['2kgs', '2KI'],\n ['1ch', '1CH'],\n ['1chronicles', '1CH'],\n ['chronicles1', '1CH'],\n ['2ch', '2CH'],\n ['2chronicles', '2CH'],\n ['chronicles2', '2CH'],\n ['ezr', 'EZR'],\n ['ezra', 'EZR'],\n ['neh', 'NEH'],\n ['nehemiah', 'NEH'],\n ['est', 'EST'],\n ['ester', 'EST'],\n ['job', 'JOB'],\n ['ps', 'PSA'],\n ['psa', 'PSA'],\n ['psalms', 'PSA'],\n ['psalm', 'PSA'],\n ['pr', 'PRO'],\n ['pro', 'PRO'],\n ['proverbs', 'PRO'],\n ['ecc', 'ECC'],\n ['ecclesiastes', 'ECC'],\n ['eccl', 'ECC'],\n ['sng', 'SNG'],\n ['song', 'SNG'],\n ['songofsolomon', 'SNG'],\n ['isa', 'ISA'],\n ['isaiah', 'ISA'],\n ['jer', 'JER'],\n ['jeremiah', 'JER'],\n ['lam', 'LAM'],\n ['lamentations', 'LAM'],\n ['ezk', 'EZK'],\n ['ezekiel', 'EZK'],\n ['ezek', 'EZK'],\n ['dan', 'DAN'],\n ['daniel', 'DAN'],\n ['hos', 'HOS'],\n ['hosea', 'HOS'],\n ['jol', 'JOL'],\n ['joel', 'JOL'],\n ['amo', 'AMO'],\n ['amos', 'AMO'],\n ['oba', 'OBA'],\n ['obadiah', 'OBA'],\n ['jon', 'JON'],\n ['jonah', 'JON'],\n ['mic', 'MIC'],\n ['micah', 'MIC'],\n ['nam', 'NAM'],\n ['nahum', 'NAM'],\n ['nah', 'NAM'],\n ['hab', 'HAB'],\n ['habakkuk', 'HAB'],\n ['zep', 'ZEP'],\n ['zepaniah', 'ZEP'],\n ['hag', 'HAG'],\n ['haggai', 'HAG'],\n ['zec', 'ZEC'],\n ['zechariah', 'ZEC'],\n ['mal', 'MAL'],\n ['malachi', 'MAL'],\n ['mat', 'MAT'],\n ['matthew', 'MAT'],\n ['mrk', 'MRK'],\n ['mark', 'MRK'],\n ['luk', 'LUK'],\n ['luke', 'LUK'],\n ['jhn', 'JHN'],\n ['john', 'JHN'],\n ['act', 'ACT'],\n ['acts', 'ACT'],\n ['rom', 'ROM'],\n ['romans', 'ROM'],\n ['1co', '1CO'],\n ['1corinthians', '1CO'],\n ['2co', '2CO'],\n ['2corinthians', '2CO'],\n ['gal', 'GAL'],\n ['galatians', 'GAL'],\n ['eph', 'EPH'],\n ['ephesians', 'EPH'],\n ['php', 'PHP'],\n ['philippians', 'PHP'],\n ['phil', 'PHP'],\n ['col', 'COL'],\n ['colossians', 'COL'],\n ['1th', '1TH'],\n ['1thessalonians', '1TH'],\n ['2th', '2TH'],\n ['2thessalonians', '2TH'],\n ['1ti', '1TI'],\n ['1timothy', '1TI'],\n ['2ti', '2TI'],\n ['2timothy', '2TI'],\n ['tit', 'TIT'],\n ['titus', 'TIT'],\n ['phm', 'PHM'],\n ['philemon', 'PHM'],\n ['phlm', 'PHM'],\n ['heb', 'HEB'],\n ['hebrews', 'HEB'],\n ['jas', 'JAS'],\n ['james', 'JAS'],\n ['1pe', '1PE'],\n ['1peter', '1PE'],\n ['2pe', '2PE'],\n ['2peter', '2PE'],\n ['1jn', '1JN'],\n ['1john', '1JN'],\n ['2jn', '2JN'],\n ['2john', '2JN'],\n ['3jn', '3JN'],\n ['3john', '3JN'],\n ['jud', 'JUD'],\n ['jude', 'JUD'],\n ['rev', 'REV'],\n ['revelation', 'REV'],\n]);\n\n/**\n * Gets the ID of the given book.\n * Returns null if the ID could not be found.\n * @param book The name/ID of the book.\n */\nexport function getBookId(book: string): string | null {\n const bookLower = book.toLowerCase().replaceAll(/\\s+/g, '');\n\n const id = BOOK_ID_MAP.get(bookLower);\n if (id) {\n return id;\n }\n\n for (let [key, id] of BOOK_ID_MAP) {\n if (bookLower.startsWith(key)) {\n return id;\n }\n }\n\n return null;\n}\n\n/**\n * A brief list of verses which may appear in some older translations\n * but are not present in more modern translations.\n */\nexport const KNOWN_SKIPPED_VERSES = new Set([\n 'MAT 12:47',\n 'MAT 17:21',\n 'MAT 18:11',\n 'MAT 23:14',\n 'MRK 7:16',\n 'MRK 9:44',\n 'MRK 9:46',\n 'MRK 11:26',\n 'LUK 17:36',\n 'LUK 23:17',\n 'JHN 5:4',\n 'ACT 8:37',\n 'ACT 15:34',\n 'ACT 24:7',\n 'ACT 28:29',\n 'ROM 16:24',\n]);\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAIO,SAAS,kBAAkB,UAA0B;AACxD,SAAO;AACX;AAKA,MAAM,qBAA0C,oBAAI,IAAI;AAAA,EACpD,CAAC,WAAW,KAAK;AAAA,EACjB,CAAC,WAAW,QAAQ;AAAA,EACpB,CAAC,YAAY,SAAS;AAAA,EACtB,CAAC,WAAW,QAAQ;AAAA,EACpB,CAAC,WAAW,QAAQ;AAAA,EACpB,CAAC,WAAW,SAAS;AACzB,CAAC;AAMM,SAAS,iBAAiB,eAA+B;AAC5D,SAAO,mBAAmB,IAAI,aAAa,KAAK;AACpD;AAEO,SAAS,oBAAoB,KAAyC;AACzE,SAAO,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AAK;AAAA,EACb,CAAC,UAAU,KAAK;AAAA,EAChB,CAAC,OAAO,KAAK;AAAA,EACb,CAAC,UAAU,KAAK;AAAA,EAChB,CAAC,OAAO,KAAK;AAAA,EACb,CAAC,SAAS,KAAK;AAAA,EACf,CAAC,OAAO,KAAK;AAAA,EACb,CAAC,SAAS,KAAK;AAAA,EACf,CAAC,OAAO,KAAK;AAAA,EACb,CAAC,SAAS,KAAK;AAAA,EACf,CAAC,OAAO,KAAK;AAAA,EACb,CAAC,QAAQ,KAAK;AAAA,EACd,CAAC,OAAO,KAAK;AAAA,EACb,CAAC,cAAc,KAAK;AACxB,CAAC;AAOM,SAAS,UAAU,MAA6B;AACnD,QAAM,YAAY,KAAK,YAAY,EAAE,WAAW,QAAQ,EAAE;AAE1D,QAAM,KAAK,YAAY,IAAI,SAAS;AACpC,MAAI,IAAI;AACJ,WAAO;AAAA,EACX;AAEA,WAAS,CAAC,KAAKA,GAAE,KAAK,aAAa;AAC/B,QAAI,UAAU,WAAW,GAAG,GAAG;AAC3B,aAAOA;AAAA,IACX;AAAA,EACJ;AAEA,SAAO;AACX;AAMO,MAAM,uBAAuB,oBAAI,IAAI;AAAA,EACxC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACJ,CAAC;",
|
|
6
6
|
"names": ["id"]
|
|
7
7
|
}
|
|
@@ -52,19 +52,23 @@ export function generateApiForDataset(dataset, options = {}) {
|
|
|
52
52
|
};
|
|
53
53
|
let translationChapters = [];
|
|
54
54
|
for (let { chapters, ...book } of books) {
|
|
55
|
+
const firstChapterNumber = chapters[0].chapter.number;
|
|
56
|
+
const lastChapterNumber = chapters[chapters.length - 1].chapter.number;
|
|
55
57
|
const apiBook = {
|
|
56
58
|
...book,
|
|
59
|
+
firstChapterNumber,
|
|
57
60
|
firstChapterApiLink: bookChapterApiLink(
|
|
58
61
|
translation.id,
|
|
59
62
|
getBookLink(book),
|
|
60
|
-
|
|
63
|
+
firstChapterNumber,
|
|
61
64
|
"json",
|
|
62
65
|
apiPathPrefix
|
|
63
66
|
),
|
|
67
|
+
lastChapterNumber,
|
|
64
68
|
lastChapterApiLink: bookChapterApiLink(
|
|
65
69
|
translation.id,
|
|
66
70
|
getBookLink(book),
|
|
67
|
-
|
|
71
|
+
lastChapterNumber,
|
|
68
72
|
"json",
|
|
69
73
|
apiPathPrefix
|
|
70
74
|
),
|
|
@@ -189,22 +193,26 @@ export function generateApiForDataset(dataset, options = {}) {
|
|
|
189
193
|
};
|
|
190
194
|
let commentaryChapters = [];
|
|
191
195
|
for (let { chapters, ...book } of books) {
|
|
196
|
+
const firstChapterNumber = chapters[0]?.chapter.number ?? null;
|
|
197
|
+
const lastChapterNumber = chapters[chapters.length - 1]?.chapter.number ?? null;
|
|
192
198
|
const apiBook = {
|
|
193
199
|
...book,
|
|
194
|
-
|
|
200
|
+
firstChapterNumber,
|
|
201
|
+
firstChapterApiLink: firstChapterNumber ? bookCommentaryChapterApiLink(
|
|
195
202
|
commentary.id,
|
|
196
203
|
getBookLink(book),
|
|
197
|
-
|
|
204
|
+
firstChapterNumber,
|
|
198
205
|
"json",
|
|
199
206
|
apiPathPrefix
|
|
200
|
-
),
|
|
201
|
-
|
|
207
|
+
) : null,
|
|
208
|
+
lastChapterNumber,
|
|
209
|
+
lastChapterApiLink: lastChapterNumber ? bookCommentaryChapterApiLink(
|
|
202
210
|
commentary.id,
|
|
203
211
|
getBookLink(book),
|
|
204
|
-
|
|
212
|
+
lastChapterNumber,
|
|
205
213
|
"json",
|
|
206
214
|
apiPathPrefix
|
|
207
|
-
),
|
|
215
|
+
) : null,
|
|
208
216
|
numberOfChapters: chapters.length,
|
|
209
217
|
totalNumberOfVerses: 0
|
|
210
218
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../generation/api.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n Commentary,\n CommentaryBook,\n CommentaryBookChapter,\n CommentaryProfile,\n OutputFile,\n Translation,\n TranslationBook,\n TranslationBookChapter,\n TranslationBookChapterAudioLinks,\n} from './common-types.js';\nimport { DatasetOutput } from './dataset.js';\n\n/**\n * Defines the output of the API generation.\n */\nexport interface ApiOutput {\n /**\n * The list of available translations.\n * This maps to the /api/available-translations.json endpoint.\n */\n availableTranslations: ApiAvailableTranslations;\n\n /**\n * The list of books for each translation.\n * This maps to the /api/:translationId/books.json endpoint.\n */\n translationBooks: ApiTranslationBooks[];\n\n /**\n * The list of chapters for each book.\n * This maps to the following endpoints:\n * - /api/:translationId/:bookId/:chapterNumber.json\n * - /api/:translationId/:bookCommonName/:chapterNumber.json\n */\n translationBookChapters: ApiTranslationBookChapter[];\n\n /**\n * The list of audio files.\n * This maps to the following endpoints:\n * - /api/:translationId/:bookId/:chapterNumber.:reader.mp3\n */\n translationBookChapterAudio: ApiTranslationBookChapterAudio[];\n\n /**\n * The list of available commentaries.\n * This maps to the /api/available-commentaries.json endpoint.\n */\n availableCommentaries: ApiAvailableCommentaries;\n\n /**\n * The list of books for each commentary.\n * This maps to the /api/c/:commentaryId/books.json endpoint.\n */\n commentaryBooks: ApiCommentaryBooks[];\n\n /**\n * The list of profiles for each commentary.\n * This maps to the /api/c/:commentaryId/profiles.json endpoint.\n */\n commentaryProfiles: ApiCommentaryProfiles[];\n\n /**\n * The list of chapters for each commentary book.\n * This maps to the following endpoint:\n * - /api/c/:commentaryId/:bookId/:chapterNumber.json\n */\n commentaryBookChapters: ApiCommentaryBookChapter[];\n\n /**\n * The list of individual profiles for each commentary.\n * This maps to the following endpoint:\n * - /api/c/:commentaryId/profiles/:profileId.json\n */\n commentaryProfileContents: ApiCommentaryProfileContent[];\n\n /**\n * The path prefix that the API should use.\n */\n pathPrefix: string;\n}\n\n/**\n * The list of available translations.\n * Maps to the /api/available-translations.json endpoint.\n */\nexport interface ApiAvailableTranslations {\n /**\n * The list of translations.\n */\n translations: ApiTranslation[];\n}\n\n/**\n * The list of available commentaries.\n * Maps to the /api/available-commentaries.json endpoint.\n */\nexport interface ApiAvailableCommentaries {\n /**\n * The list of commentaries.\n */\n commentaries: ApiCommentary[];\n}\n\n/**\n * Defines a translation that is used in the API.\n */\nexport interface ApiTranslation extends Translation {\n /**\n * The API link for the list of available books for this translation.\n */\n listOfBooksApiLink: string;\n\n /**\n * The available list of formats.\n */\n availableFormats: ('json' | 'usfm')[];\n\n /**\n * The number of books that are contained in this translation.\n *\n * Complete translations should have the same number of books as the Bible (66).\n */\n numberOfBooks: number;\n\n /**\n * The total number of chapters that are contained in this translation.\n *\n * Complete translations should have the same number of chapters as the Bible (1,189).\n */\n totalNumberOfChapters: number;\n\n /**\n * The total number of verses that are contained in this translation.\n *\n * Complete translations should have the same number of verses as the Bible (around 31,102 - some translations exclude verses based on the aparent likelyhood of existing in the original source texts).\n */\n totalNumberOfVerses: number;\n\n /**\n * The total number of apocryphal books that are contained in this translation.\n */\n numberOfApocryphalBooks?: number;\n\n /**\n * The total number of apocryphal chapters that are contained in this translation.\n */\n totalNumberOfApocryphalChapters?: number;\n\n /**\n * the total number of apocryphal verses that are contained in this translation.\n */\n totalNumberOfApocryphalVerses?: number;\n\n /**\n * Gets the name of the language that the translation is in.\n * Null or undefined if the name of the language is not known.\n */\n languageName?: string;\n\n /**\n * Gets the name of the language in English.\n * Null or undefined if the language doesn't have an english name.\n */\n languageEnglishName?: string;\n}\n\n/**\n * Defines a commentary that is used in the API.\n */\nexport interface ApiCommentary extends Commentary {\n /**\n * The API link for the list of available books for this translation.\n */\n listOfBooksApiLink: string;\n\n /**\n * The API link for the list of available profiles for this commentary.\n */\n listOfProfilesApiLink: string;\n\n /**\n * The available list of formats.\n */\n availableFormats: ('json' | 'usfm')[];\n\n /**\n * The number of books that are contained in this commentary.\n *\n * Complete commentaries should have the same number of books as the Bible (66).\n */\n numberOfBooks: number;\n\n /**\n * The total number of chapters that are contained in this translation.\n *\n * Complete commentaries should have the same number of chapters as the Bible (1,189).\n */\n totalNumberOfChapters: number;\n\n /**\n * The total number of verses that are contained in this commentary.\n *\n * Complete commentaries should have the same number of verses as the Bible (around 31,102 - some commentaries exclude verses based on the aparent likelyhood of existing in the original source texts).\n */\n totalNumberOfVerses: number;\n\n /**\n * The total number of profiles that are contained in this commentary.\n *\n * Profiles are used to provide additional information about people and people groups that are mentioned in the Bible.\n */\n totalNumberOfProfiles: number;\n\n /**\n * Gets the name of the language that the commentary is in.\n * Null or undefined if the name of the language is not known.\n */\n languageName?: string;\n\n /**\n * Gets the name of the language in English.\n * Null or undefined if the language doesn't have an english name.\n */\n languageEnglishName?: string;\n}\n\n/**\n * Defines an interface that contains information about the books that are available for a translation.\n */\nexport interface ApiTranslationBooks {\n /**\n * The translation information for the books.\n */\n translation: ApiTranslation;\n\n /**\n * The list of books that are available for the translation.\n */\n books: ApiTranslationBook[];\n}\n\n/**\n * Defines an interface that contains information about the books that are available for a commentary.\n */\nexport interface ApiCommentaryBooks {\n /**\n * The commentary information for the books.\n */\n commentary: ApiCommentary;\n\n /**\n * The list of books that are available for the commentary.\n */\n books: ApiCommentaryBook[];\n}\n\n/**\n * Defines an interface that contains information about the profiles that are available for a commentary.\n */\nexport interface ApiCommentaryProfiles {\n /**\n * The commentary information for the books.\n */\n commentary: ApiCommentary;\n\n /**\n * The list of profiles that are available for the commentary.\n */\n profiles: ApiCommentaryProfile[];\n}\n\n/**\n * Defines an interface that contains information about a profile.\n */\nexport interface ApiCommentaryProfile extends CommentaryProfile {\n /**\n * The link to this profile.\n */\n thisProfileLink: string;\n\n /**\n * The link to the chapter that this profile references in the commentary.\n */\n referenceChapterLink: string | null;\n}\n\n/**\n * Defines a translation book that is used in the API.\n */\nexport interface ApiTranslationBook extends TranslationBook {\n /**\n * The link to the first chapter of the book.\n */\n firstChapterApiLink: string;\n\n /**\n * The link to the last chapter of the book.\n */\n lastChapterApiLink: string;\n\n /**\n * The number of chapters that the book contains.\n */\n numberOfChapters: number;\n\n /**\n * The number of verses that the book contains.\n */\n totalNumberOfVerses: number;\n}\n\n/**\n * Defines a commentary book that is used in the API.\n */\nexport interface ApiCommentaryBook extends CommentaryBook {\n /**\n * The link to the first chapter of the book.\n */\n firstChapterApiLink: string;\n\n /**\n * The link to the last chapter of the book.\n */\n lastChapterApiLink: string;\n\n /**\n * The number of chapters that the book contains.\n */\n numberOfChapters: number;\n\n /**\n * The number of verses that the book contains.\n */\n totalNumberOfVerses: number;\n}\n\n/**\n * Defines an interface that contains information about a book chapter.\n */\nexport interface ApiTranslationBookChapter extends TranslationBookChapter {\n /**\n * The translation information for the book chapter.\n */\n translation: ApiTranslation;\n\n /**\n * The book information for the book chapter.\n */\n book: ApiTranslationBook;\n\n /**\n * The link to this chapter.\n */\n thisChapterLink: string;\n\n /**\n * The link to the next chapter.\n * Null if this is the last chapter in the translation.\n */\n nextChapterApiLink: string | null;\n\n /**\n * The links to the audio versions for the next chapter.\n * Null if this is the last chapter in the translation.\n */\n nextChapterAudioLinks: TranslationBookChapterAudioLinks | null;\n\n /**\n * The link to the previous chapter.\n * Null if this is the first chapter in the translation.\n */\n previousChapterApiLink: string | null;\n\n /**\n * The links to the audio versions for the previous chapter.\n * Null if this is the first chapter in the translation.\n */\n previousChapterAudioLinks: TranslationBookChapterAudioLinks | null;\n\n /**\n * The number of verses that the chapter contains.\n */\n numberOfVerses: number;\n}\n\n/**\n * Defines an interface that contains information about a book chapter.\n */\nexport interface ApiCommentaryBookChapter extends CommentaryBookChapter {\n /**\n * The commentary information for the book chapter.\n */\n commentary: ApiCommentary;\n\n /**\n * The book information for the book chapter.\n */\n book: ApiCommentaryBook;\n\n /**\n * The link to this chapter.\n */\n thisChapterLink: string;\n\n /**\n * The link to the next chapter.\n * Null if this is the last chapter in the translation.\n */\n nextChapterApiLink: string | null;\n\n /**\n * The link to the previous chapter.\n * Null if this is the first chapter in the translation.\n */\n previousChapterApiLink: string | null;\n\n /**\n * The number of verses that the chapter contains.\n */\n numberOfVerses: number;\n}\n\nexport interface ApiTranslationBookChapterAudio {\n /**\n * The chapter that the audio is for.\n */\n chapter: ApiTranslationBookChapter;\n\n /**\n * The link that the audio should be placed at.\n */\n link: string;\n\n /**\n * The original URL of the audio.\n */\n originalUrl: string;\n}\n\nexport interface ApiCommentaryProfileContent {\n /**\n * The commentary information for the profile.\n */\n commentary: ApiCommentary;\n\n /**\n * The information about the profile.\n */\n profile: ApiCommentaryProfile;\n\n /**\n * The content of the profile.\n */\n content: string[];\n}\n\n/**\n * The options for generating the API.\n */\nexport interface GenerateApiOptions {\n /**\n * Whether to use the common name for the book chapter API link. If false, then book IDs are used.\n * Audio URLs will always use the book ID.\n * Defaults to false.\n */\n useCommonName?: boolean;\n\n /**\n * Whether to replace the audio URLs in the dataset with ones that are hosted locally.\n * If true, then the audio URLs in the dataset will be replaced with ones that reference files hosted by the API itself.\n * If false, then the audio URLs in the dataset will be left as is.\n * Defaults to false.\n */\n generateAudioFiles?: boolean;\n\n /**\n * Gets the english name of the given language.\n * If not provided, then the english name for the language will be unknown and omitted.\n * @param language The language to get the english name for.\n */\n getEnglishName?: (language: string) => string | null | undefined;\n\n /**\n * Gets the native name of the given language.\n * If not provided, then the native name for the language will be unknown and omitted.\n * @param language The language to get the native name for.\n */\n getNativeName?: (language: string) => string | null | undefined;\n\n /**\n * The prefix that should be added to paths that are generated.\n */\n pathPrefix?: string;\n}\n\n/**\n * Generates the API output for the given dataset.\n * @param dataset The dataset to generate the API for.\n * @param options The options for generating the API.\n */\nexport function generateApiForDataset(\n dataset: DatasetOutput,\n options: GenerateApiOptions = {}\n): ApiOutput {\n const { useCommonName, pathPrefix } = options;\n const apiPathPrefix = pathPrefix ? pathPrefix : '';\n let api: ApiOutput = {\n availableTranslations: {\n translations: [],\n },\n translationBooks: [],\n translationBookChapters: [],\n translationBookChapterAudio: [],\n availableCommentaries: {\n commentaries: [],\n },\n commentaryBookChapters: [],\n commentaryBooks: [],\n commentaryProfiles: [],\n commentaryProfileContents: [],\n pathPrefix: apiPathPrefix,\n };\n\n const getNativeName = options.getNativeName;\n const getEnglishName = options.getEnglishName;\n\n for (let { books, ...translation } of dataset.translations) {\n let numberOfBooks = 0;\n let numberOfApocryphalBooks = 0;\n\n for (let book of books) {\n if (book.isApocryphal) {\n numberOfApocryphalBooks++;\n } else {\n numberOfBooks++;\n }\n }\n\n const apiTranslation: ApiTranslation = {\n ...translation,\n availableFormats: ['json'],\n listOfBooksApiLink: listOfBooksApiLink(\n translation.id,\n apiPathPrefix\n ),\n numberOfBooks,\n totalNumberOfChapters: 0,\n totalNumberOfVerses: 0,\n languageName: getNativeName\n ? (getNativeName(translation.language) ?? undefined)\n : undefined,\n languageEnglishName: getEnglishName\n ? (getEnglishName(translation.language) ?? undefined)\n : undefined,\n };\n\n if (numberOfApocryphalBooks > 0) {\n apiTranslation.numberOfApocryphalBooks = numberOfApocryphalBooks;\n }\n\n const translationBooks: ApiTranslationBooks = {\n translation: apiTranslation,\n books: [],\n };\n\n let translationChapters: ApiTranslationBookChapter[] = [];\n\n for (let { chapters, ...book } of books) {\n const apiBook: ApiTranslationBook = {\n ...book,\n firstChapterApiLink: bookChapterApiLink(\n translation.id,\n getBookLink(book),\n 1,\n 'json',\n apiPathPrefix\n ),\n lastChapterApiLink: bookChapterApiLink(\n translation.id,\n getBookLink(book),\n chapters.length,\n 'json',\n apiPathPrefix\n ),\n numberOfChapters: chapters.length,\n totalNumberOfVerses: 0,\n };\n\n for (let { chapter, thisChapterAudioLinks } of chapters) {\n const audio: TranslationBookChapterAudioLinks = {};\n const apiBookChapter: ApiTranslationBookChapter = {\n translation: apiTranslation,\n book: apiBook,\n chapter: chapter,\n thisChapterLink: bookChapterApiLink(\n translation.id,\n getBookLink(book),\n chapter.number,\n 'json',\n apiPathPrefix\n ),\n thisChapterAudioLinks: audio,\n nextChapterApiLink: null,\n nextChapterAudioLinks: null,\n previousChapterApiLink: null,\n previousChapterAudioLinks: null,\n numberOfVerses: 0,\n };\n\n for (let reader in thisChapterAudioLinks) {\n if (options.generateAudioFiles) {\n const apiAudio: ApiTranslationBookChapterAudio = {\n chapter: apiBookChapter,\n link: bookChapterAudioApiLink(\n translation.id,\n getBookLink(book),\n chapter.number,\n reader,\n apiPathPrefix\n ),\n originalUrl: thisChapterAudioLinks[reader],\n };\n audio[reader] = apiAudio.link;\n api.translationBookChapterAudio.push(apiAudio);\n } else {\n audio[reader] = thisChapterAudioLinks[reader];\n }\n }\n\n for (let c of chapter.content) {\n if (c.type === 'verse') {\n apiBookChapter.numberOfVerses++;\n }\n }\n\n apiBook.totalNumberOfVerses += apiBookChapter.numberOfVerses;\n\n translationChapters.push(apiBookChapter);\n api.translationBookChapters.push(apiBookChapter);\n }\n\n translationBooks.books.push(apiBook);\n\n if (apiBook.isApocryphal) {\n if (!apiTranslation.totalNumberOfApocryphalChapters) {\n apiTranslation.totalNumberOfApocryphalChapters = 0;\n }\n if (!apiTranslation.totalNumberOfApocryphalVerses) {\n apiTranslation.totalNumberOfApocryphalVerses = 0;\n }\n apiTranslation.totalNumberOfApocryphalChapters +=\n apiBook.numberOfChapters;\n apiTranslation.totalNumberOfApocryphalVerses +=\n apiBook.totalNumberOfVerses;\n } else {\n apiTranslation.totalNumberOfChapters +=\n apiBook.numberOfChapters;\n apiTranslation.totalNumberOfVerses +=\n apiBook.totalNumberOfVerses;\n }\n }\n\n for (let i = 0; i < translationChapters.length; i++) {\n if (i > 0) {\n translationChapters[i].previousChapterApiLink =\n bookChapterApiLink(\n translation.id,\n getBookLink(translationChapters[i - 1].book),\n translationChapters[i - 1].chapter.number,\n 'json',\n apiPathPrefix\n );\n translationChapters[i].previousChapterAudioLinks =\n translationChapters[i - 1].thisChapterAudioLinks;\n }\n\n if (i < translationChapters.length - 1) {\n translationChapters[i].nextChapterApiLink = bookChapterApiLink(\n translation.id,\n getBookLink(translationChapters[i + 1].book),\n translationChapters[i + 1].chapter.number,\n 'json',\n apiPathPrefix\n );\n translationChapters[i].nextChapterAudioLinks =\n translationChapters[i + 1].thisChapterAudioLinks;\n }\n }\n\n api.availableTranslations.translations.push(apiTranslation);\n api.translationBooks.push(translationBooks);\n }\n\n for (let { books, profiles, ...commentary } of dataset.commentaries) {\n const apiCommentary: ApiCommentary = {\n ...commentary,\n availableFormats: ['json'],\n listOfBooksApiLink: listOfCommentaryBooksApiLink(\n commentary.id,\n apiPathPrefix\n ),\n listOfProfilesApiLink: profilesCommentaryApiLink(\n commentary.id,\n 'json',\n apiPathPrefix\n ),\n numberOfBooks: books.length,\n totalNumberOfChapters: 0,\n totalNumberOfVerses: 0,\n totalNumberOfProfiles: 0,\n languageName: getNativeName\n ? (getNativeName(commentary.language) ?? undefined)\n : undefined,\n languageEnglishName: getEnglishName\n ? (getEnglishName(commentary.language) ?? undefined)\n : undefined,\n };\n\n const commentaryBooks: ApiCommentaryBooks = {\n commentary: apiCommentary,\n books: [],\n };\n\n const commentaryProfiles: ApiCommentaryProfiles = {\n commentary: apiCommentary,\n profiles: [],\n };\n\n let commentaryChapters: ApiCommentaryBookChapter[] = [];\n\n for (let { chapters, ...book } of books) {\n const apiBook: ApiCommentaryBook = {\n ...book,\n firstChapterApiLink: bookCommentaryChapterApiLink(\n commentary.id,\n getBookLink(book),\n 1,\n 'json',\n apiPathPrefix\n ),\n lastChapterApiLink: bookCommentaryChapterApiLink(\n commentary.id,\n getBookLink(book),\n chapters.length,\n 'json',\n apiPathPrefix\n ),\n numberOfChapters: chapters.length,\n totalNumberOfVerses: 0,\n };\n\n for (let { chapter } of chapters) {\n const apiBookChapter: ApiCommentaryBookChapter = {\n commentary: apiCommentary,\n book: apiBook,\n chapter: chapter,\n thisChapterLink: bookCommentaryChapterApiLink(\n commentary.id,\n getBookLink(book),\n chapter.number,\n 'json',\n apiPathPrefix\n ),\n nextChapterApiLink: null,\n previousChapterApiLink: null,\n numberOfVerses: 0,\n };\n\n for (let c of chapter.content) {\n if (c.type === 'verse') {\n apiBookChapter.numberOfVerses++;\n }\n }\n\n apiBook.totalNumberOfVerses += apiBookChapter.numberOfVerses;\n\n commentaryChapters.push(apiBookChapter);\n api.commentaryBookChapters.push(apiBookChapter);\n }\n\n commentaryBooks.books.push(apiBook);\n\n apiCommentary.totalNumberOfChapters += apiBook.numberOfChapters;\n apiCommentary.totalNumberOfVerses += apiBook.totalNumberOfVerses;\n }\n\n if (profiles) {\n for (let profile of profiles) {\n const apiProfile: ApiCommentaryProfile = {\n id: profile.id,\n reference: profile.reference,\n subject: profile.subject,\n thisProfileLink: profileCommentaryApiLink(\n commentary.id,\n profile.id,\n 'json',\n apiPathPrefix\n ),\n referenceChapterLink: profile.reference\n ? bookCommentaryChapterApiLink(\n commentary.id,\n profile.reference.book,\n profile.reference.chapter,\n 'json',\n apiPathPrefix\n )\n : null,\n };\n\n const apiProfileContent: ApiCommentaryProfileContent = {\n commentary: apiCommentary,\n profile: apiProfile,\n content: profile.content,\n };\n\n apiCommentary.totalNumberOfProfiles += 1;\n commentaryProfiles.profiles.push(apiProfile);\n api.commentaryProfileContents.push(apiProfileContent);\n }\n }\n\n for (let i = 0; i < commentaryChapters.length; i++) {\n if (i > 0) {\n commentaryChapters[i].previousChapterApiLink =\n bookCommentaryChapterApiLink(\n commentary.id,\n getBookLink(commentaryChapters[i - 1].book),\n commentaryChapters[i - 1].chapter.number,\n 'json',\n apiPathPrefix\n );\n // commentaryChapters[i].previousChapterAudioLinks =\n // commentaryChapters[i - 1].thisChapterAudioLinks;\n }\n\n if (i < commentaryChapters.length - 1) {\n commentaryChapters[i].nextChapterApiLink =\n bookCommentaryChapterApiLink(\n commentary.id,\n getBookLink(commentaryChapters[i + 1].book),\n commentaryChapters[i + 1].chapter.number,\n 'json',\n apiPathPrefix\n );\n // commentaryChapters[i].nextChapterAudioLinks =\n // commentaryChapters[i + 1].thisChapterAudioLinks;\n }\n }\n\n api.availableCommentaries.commentaries.push(apiCommentary);\n api.commentaryBooks.push(commentaryBooks);\n api.commentaryProfiles.push(commentaryProfiles);\n }\n\n return api;\n\n function getBookLink(book: TranslationBook | CommentaryBook): string {\n return useCommonName ? book.commonName : book.id;\n }\n}\n\n/**\n * Generates the output files for the given API.\n * @param api The API that the files should be generated for.\n */\nexport function generateFilesForApi(api: ApiOutput): OutputFile[] {\n let files: OutputFile[] = [];\n\n files.push(\n jsonFile(\n `${api.pathPrefix}/api/available_translations.json`,\n api.availableTranslations,\n true\n )\n );\n for (let translationBooks of api.translationBooks) {\n files.push(\n jsonFile(\n translationBooks.translation.listOfBooksApiLink,\n translationBooks\n )\n );\n }\n\n for (let bookChapter of api.translationBookChapters) {\n files.push(jsonFile(bookChapter.thisChapterLink, bookChapter));\n }\n\n for (let audio of api.translationBookChapterAudio) {\n files.push(downloadedFile(audio.link, audio.originalUrl));\n }\n\n files.push(\n jsonFile(\n `${api.pathPrefix}/api/available_commentaries.json`,\n api.availableCommentaries,\n true\n )\n );\n for (let commentaryBooks of api.commentaryBooks) {\n files.push(\n jsonFile(\n commentaryBooks.commentary.listOfBooksApiLink,\n commentaryBooks\n )\n );\n }\n\n for (let commentaryProfiles of api.commentaryProfiles) {\n files.push(\n jsonFile(\n commentaryProfiles.commentary.listOfProfilesApiLink,\n commentaryProfiles\n )\n );\n }\n\n for (let profileContent of api.commentaryProfileContents) {\n files.push(\n jsonFile(profileContent.profile.thisProfileLink, profileContent)\n );\n }\n\n for (let bookChapter of api.commentaryBookChapters) {\n files.push(jsonFile(bookChapter.thisChapterLink, bookChapter));\n }\n\n // for (let audio of api.translationBookChapterAudio) {\n // files.push(downloadedFile(audio.link, audio.originalUrl));\n // }\n\n return files;\n}\n\n/**\n * Generates the output files for the given datasets.\n * @param datasets The datasets to generate the output files for.\n * @param options The options for generating the API files.\n */\nexport async function* generateOutputFilesFromDatasets(\n datasets: AsyncIterable<DatasetOutput>,\n options?: GenerateApiOptions\n): AsyncGenerator<OutputFile[]> {\n for await (let dataset of datasets) {\n const api = generateApiForDataset(dataset, options);\n const files = generateFilesForApi(api);\n\n yield files;\n }\n}\n\n/**\n * Gets the API Link for the list of books endpoint for a translation.\n * @param translationId The ID of the translation.\n * @returns\n */\nexport function listOfBooksApiLink(\n translationId: string,\n prefix: string = ''\n): string {\n return `${prefix}/api/${translationId}/books.json`;\n}\n\n/**\n * Gets the API Link for the list of books endpoint for a commentary.\n * @param commentaryId The ID of the commentary.\n * @returns\n */\nexport function listOfCommentaryBooksApiLink(\n commentaryId: string,\n prefix: string = ''\n): string {\n return `${prefix}/api/c/${commentaryId}/books.json`;\n}\n\n/**\n * Getes the API link for a book chapter.\n * @param translationId The ID of the translation.\n * @param commonName The name of the book.\n * @param chapterNumber The number of the book.\n * @param extension The extension of the file.\n */\nexport function bookChapterApiLink(\n translationId: string,\n commonName: string,\n chapterNumber: number,\n extension: string,\n prefix: string = ''\n) {\n return `${prefix}/api/${translationId}/${replaceSpacesWithUnderscores(\n commonName\n )}/${chapterNumber}.${extension}`;\n}\n\n/**\n * Getes the API link for a book chapter.\n * @param translationId The ID of the translation.\n * @param commonName The name of the book.\n * @param chapterNumber The number of the book.\n * @param extension The extension of the file.\n */\nexport function bookCommentaryChapterApiLink(\n translationId: string,\n commonName: string,\n chapterNumber: number,\n extension: string,\n prefix: string = ''\n) {\n return `${prefix}/api/c/${translationId}/${replaceSpacesWithUnderscores(\n commonName\n )}/${chapterNumber}.${extension}`;\n}\n\nexport function bookChapterAudioApiLink(\n translationId: string,\n bookId: string,\n chapterNumber: number,\n reader: string,\n prefix: string = ''\n) {\n return `${prefix}/api/${translationId}/${replaceSpacesWithUnderscores(\n bookId\n )}/${chapterNumber}.${reader}.mp3`;\n}\n\n/**\n * Gets the API link for a profile.\n * @param translationId The ID of the translation.\n * @param profileId The ID of the profile.\n * @param extension The extension of the file.\n */\nexport function profilesCommentaryApiLink(\n translationId: string,\n extension: string,\n prefix: string = ''\n) {\n return `${prefix}/api/c/${translationId}/profiles.${extension}`;\n}\n\n/**\n * Gets the API link for a profile.\n * @param translationId The ID of the translation.\n * @param profileId The ID of the profile.\n * @param extension The extension of the file.\n */\nexport function profileCommentaryApiLink(\n translationId: string,\n profileId: string,\n extension: string,\n prefix: string = ''\n) {\n return `${prefix}/api/c/${translationId}/profiles/${replaceSpacesWithUnderscores(\n profileId\n )}.${extension}`;\n}\n\nexport function jsonFile(\n path: string,\n content: any,\n mergable?: boolean\n): OutputFile {\n return {\n path,\n content,\n mergable,\n };\n}\n\nexport function downloadedFile(path: string, url: string): OutputFile {\n return {\n path,\n content: () => fetch(url).then((response) => response.body),\n };\n}\n\nexport function replaceSpacesWithUnderscores(str: string): string {\n return str.replace(/[<>:\"/\\\\|?*\\s]/g, '_');\n}\n"],
|
|
5
|
-
"mappings": ";
|
|
4
|
+
"sourcesContent": ["import {\r\n Commentary,\r\n CommentaryBook,\r\n CommentaryBookChapter,\r\n CommentaryProfile,\r\n OutputFile,\r\n Translation,\r\n TranslationBook,\r\n TranslationBookChapter,\r\n TranslationBookChapterAudioLinks,\r\n} from './common-types.js';\r\nimport { DatasetOutput } from './dataset.js';\r\n\r\n/**\r\n * Defines the output of the API generation.\r\n */\r\nexport interface ApiOutput {\r\n /**\r\n * The list of available translations.\r\n * This maps to the /api/available-translations.json endpoint.\r\n */\r\n availableTranslations: ApiAvailableTranslations;\r\n\r\n /**\r\n * The list of books for each translation.\r\n * This maps to the /api/:translationId/books.json endpoint.\r\n */\r\n translationBooks: ApiTranslationBooks[];\r\n\r\n /**\r\n * The list of chapters for each book.\r\n * This maps to the following endpoints:\r\n * - /api/:translationId/:bookId/:chapterNumber.json\r\n * - /api/:translationId/:bookCommonName/:chapterNumber.json\r\n */\r\n translationBookChapters: ApiTranslationBookChapter[];\r\n\r\n /**\r\n * The list of audio files.\r\n * This maps to the following endpoints:\r\n * - /api/:translationId/:bookId/:chapterNumber.:reader.mp3\r\n */\r\n translationBookChapterAudio: ApiTranslationBookChapterAudio[];\r\n\r\n /**\r\n * The list of available commentaries.\r\n * This maps to the /api/available-commentaries.json endpoint.\r\n */\r\n availableCommentaries: ApiAvailableCommentaries;\r\n\r\n /**\r\n * The list of books for each commentary.\r\n * This maps to the /api/c/:commentaryId/books.json endpoint.\r\n */\r\n commentaryBooks: ApiCommentaryBooks[];\r\n\r\n /**\r\n * The list of profiles for each commentary.\r\n * This maps to the /api/c/:commentaryId/profiles.json endpoint.\r\n */\r\n commentaryProfiles: ApiCommentaryProfiles[];\r\n\r\n /**\r\n * The list of chapters for each commentary book.\r\n * This maps to the following endpoint:\r\n * - /api/c/:commentaryId/:bookId/:chapterNumber.json\r\n */\r\n commentaryBookChapters: ApiCommentaryBookChapter[];\r\n\r\n /**\r\n * The list of individual profiles for each commentary.\r\n * This maps to the following endpoint:\r\n * - /api/c/:commentaryId/profiles/:profileId.json\r\n */\r\n commentaryProfileContents: ApiCommentaryProfileContent[];\r\n\r\n /**\r\n * The path prefix that the API should use.\r\n */\r\n pathPrefix: string;\r\n}\r\n\r\n/**\r\n * The list of available translations.\r\n * Maps to the /api/available-translations.json endpoint.\r\n */\r\nexport interface ApiAvailableTranslations {\r\n /**\r\n * The list of translations.\r\n */\r\n translations: ApiTranslation[];\r\n}\r\n\r\n/**\r\n * The list of available commentaries.\r\n * Maps to the /api/available-commentaries.json endpoint.\r\n */\r\nexport interface ApiAvailableCommentaries {\r\n /**\r\n * The list of commentaries.\r\n */\r\n commentaries: ApiCommentary[];\r\n}\r\n\r\n/**\r\n * Defines a translation that is used in the API.\r\n */\r\nexport interface ApiTranslation extends Translation {\r\n /**\r\n * The API link for the list of available books for this translation.\r\n */\r\n listOfBooksApiLink: string;\r\n\r\n /**\r\n * The available list of formats.\r\n */\r\n availableFormats: ('json' | 'usfm')[];\r\n\r\n /**\r\n * The number of books that are contained in this translation.\r\n *\r\n * Complete translations should have the same number of books as the Bible (66).\r\n */\r\n numberOfBooks: number;\r\n\r\n /**\r\n * The total number of chapters that are contained in this translation.\r\n *\r\n * Complete translations should have the same number of chapters as the Bible (1,189).\r\n */\r\n totalNumberOfChapters: number;\r\n\r\n /**\r\n * The total number of verses that are contained in this translation.\r\n *\r\n * Complete translations should have the same number of verses as the Bible (around 31,102 - some translations exclude verses based on the aparent likelyhood of existing in the original source texts).\r\n */\r\n totalNumberOfVerses: number;\r\n\r\n /**\r\n * The total number of apocryphal books that are contained in this translation.\r\n */\r\n numberOfApocryphalBooks?: number;\r\n\r\n /**\r\n * The total number of apocryphal chapters that are contained in this translation.\r\n */\r\n totalNumberOfApocryphalChapters?: number;\r\n\r\n /**\r\n * the total number of apocryphal verses that are contained in this translation.\r\n */\r\n totalNumberOfApocryphalVerses?: number;\r\n\r\n /**\r\n * Gets the name of the language that the translation is in.\r\n * Null or undefined if the name of the language is not known.\r\n */\r\n languageName?: string;\r\n\r\n /**\r\n * Gets the name of the language in English.\r\n * Null or undefined if the language doesn't have an english name.\r\n */\r\n languageEnglishName?: string;\r\n}\r\n\r\n/**\r\n * Defines a commentary that is used in the API.\r\n */\r\nexport interface ApiCommentary extends Commentary {\r\n /**\r\n * The API link for the list of available books for this translation.\r\n */\r\n listOfBooksApiLink: string;\r\n\r\n /**\r\n * The API link for the list of available profiles for this commentary.\r\n */\r\n listOfProfilesApiLink: string;\r\n\r\n /**\r\n * The available list of formats.\r\n */\r\n availableFormats: ('json' | 'usfm')[];\r\n\r\n /**\r\n * The number of books that are contained in this commentary.\r\n *\r\n * Complete commentaries should have the same number of books as the Bible (66).\r\n */\r\n numberOfBooks: number;\r\n\r\n /**\r\n * The total number of chapters that are contained in this translation.\r\n *\r\n * Complete commentaries should have the same number of chapters as the Bible (1,189).\r\n */\r\n totalNumberOfChapters: number;\r\n\r\n /**\r\n * The total number of verses that are contained in this commentary.\r\n *\r\n * Complete commentaries should have the same number of verses as the Bible (around 31,102 - some commentaries exclude verses based on the aparent likelyhood of existing in the original source texts).\r\n */\r\n totalNumberOfVerses: number;\r\n\r\n /**\r\n * The total number of profiles that are contained in this commentary.\r\n *\r\n * Profiles are used to provide additional information about people and people groups that are mentioned in the Bible.\r\n */\r\n totalNumberOfProfiles: number;\r\n\r\n /**\r\n * Gets the name of the language that the commentary is in.\r\n * Null or undefined if the name of the language is not known.\r\n */\r\n languageName?: string;\r\n\r\n /**\r\n * Gets the name of the language in English.\r\n * Null or undefined if the language doesn't have an english name.\r\n */\r\n languageEnglishName?: string;\r\n}\r\n\r\n/**\r\n * Defines an interface that contains information about the books that are available for a translation.\r\n */\r\nexport interface ApiTranslationBooks {\r\n /**\r\n * The translation information for the books.\r\n */\r\n translation: ApiTranslation;\r\n\r\n /**\r\n * The list of books that are available for the translation.\r\n */\r\n books: ApiTranslationBook[];\r\n}\r\n\r\n/**\r\n * Defines an interface that contains information about the books that are available for a commentary.\r\n */\r\nexport interface ApiCommentaryBooks {\r\n /**\r\n * The commentary information for the books.\r\n */\r\n commentary: ApiCommentary;\r\n\r\n /**\r\n * The list of books that are available for the commentary.\r\n */\r\n books: ApiCommentaryBook[];\r\n}\r\n\r\n/**\r\n * Defines an interface that contains information about the profiles that are available for a commentary.\r\n */\r\nexport interface ApiCommentaryProfiles {\r\n /**\r\n * The commentary information for the books.\r\n */\r\n commentary: ApiCommentary;\r\n\r\n /**\r\n * The list of profiles that are available for the commentary.\r\n */\r\n profiles: ApiCommentaryProfile[];\r\n}\r\n\r\n/**\r\n * Defines an interface that contains information about a profile.\r\n */\r\nexport interface ApiCommentaryProfile extends CommentaryProfile {\r\n /**\r\n * The link to this profile.\r\n */\r\n thisProfileLink: string;\r\n\r\n /**\r\n * The link to the chapter that this profile references in the commentary.\r\n */\r\n referenceChapterLink: string | null;\r\n}\r\n\r\n/**\r\n * Defines a translation book that is used in the API.\r\n */\r\nexport interface ApiTranslationBook extends TranslationBook {\r\n /**\r\n * The number of the first chapter in the book.\r\n */\r\n firstChapterNumber: number;\r\n\r\n /**\r\n * The link to the first chapter of the book.\r\n */\r\n firstChapterApiLink: string;\r\n\r\n /**\r\n * The number of the last chapter in the book.\r\n */\r\n lastChapterNumber: number;\r\n\r\n /**\r\n * The link to the last chapter of the book.\r\n */\r\n lastChapterApiLink: string;\r\n\r\n /**\r\n * The number of chapters that the book contains.\r\n */\r\n numberOfChapters: number;\r\n\r\n /**\r\n * The number of verses that the book contains.\r\n */\r\n totalNumberOfVerses: number;\r\n}\r\n\r\n/**\r\n * Defines a commentary book that is used in the API.\r\n */\r\nexport interface ApiCommentaryBook extends CommentaryBook {\r\n /**\r\n * The number of the first chapter in the book.\r\n *\r\n * Null if the comentary book has no chapters.\r\n */\r\n firstChapterNumber: number | null;\r\n\r\n /**\r\n * The link to the first chapter of the book.\r\n *\r\n * Null if the comentary book has no chapters.\r\n */\r\n firstChapterApiLink: string | null;\r\n\r\n /**\r\n * The number of the last chapter in the book.\r\n *\r\n * Null if the comentary book has no chapters.\r\n */\r\n lastChapterNumber: number | null;\r\n\r\n /**\r\n * The link to the last chapter of the book.\r\n *\r\n * Null if the comentary book has no chapters.\r\n */\r\n lastChapterApiLink: string | null;\r\n\r\n /**\r\n * The number of chapters that the book contains.\r\n */\r\n numberOfChapters: number;\r\n\r\n /**\r\n * The number of verses that the book contains.\r\n */\r\n totalNumberOfVerses: number;\r\n}\r\n\r\n/**\r\n * Defines an interface that contains information about a book chapter.\r\n */\r\nexport interface ApiTranslationBookChapter extends TranslationBookChapter {\r\n /**\r\n * The translation information for the book chapter.\r\n */\r\n translation: ApiTranslation;\r\n\r\n /**\r\n * The book information for the book chapter.\r\n */\r\n book: ApiTranslationBook;\r\n\r\n /**\r\n * The link to this chapter.\r\n */\r\n thisChapterLink: string;\r\n\r\n /**\r\n * The link to the next chapter.\r\n * Null if this is the last chapter in the translation.\r\n */\r\n nextChapterApiLink: string | null;\r\n\r\n /**\r\n * The links to the audio versions for the next chapter.\r\n * Null if this is the last chapter in the translation.\r\n */\r\n nextChapterAudioLinks: TranslationBookChapterAudioLinks | null;\r\n\r\n /**\r\n * The link to the previous chapter.\r\n * Null if this is the first chapter in the translation.\r\n */\r\n previousChapterApiLink: string | null;\r\n\r\n /**\r\n * The links to the audio versions for the previous chapter.\r\n * Null if this is the first chapter in the translation.\r\n */\r\n previousChapterAudioLinks: TranslationBookChapterAudioLinks | null;\r\n\r\n /**\r\n * The number of verses that the chapter contains.\r\n */\r\n numberOfVerses: number;\r\n}\r\n\r\n/**\r\n * Defines an interface that contains information about a book chapter.\r\n */\r\nexport interface ApiCommentaryBookChapter extends CommentaryBookChapter {\r\n /**\r\n * The commentary information for the book chapter.\r\n */\r\n commentary: ApiCommentary;\r\n\r\n /**\r\n * The book information for the book chapter.\r\n */\r\n book: ApiCommentaryBook;\r\n\r\n /**\r\n * The link to this chapter.\r\n */\r\n thisChapterLink: string;\r\n\r\n /**\r\n * The link to the next chapter.\r\n * Null if this is the last chapter in the translation.\r\n */\r\n nextChapterApiLink: string | null;\r\n\r\n /**\r\n * The link to the previous chapter.\r\n * Null if this is the first chapter in the translation.\r\n */\r\n previousChapterApiLink: string | null;\r\n\r\n /**\r\n * The number of verses that the chapter contains.\r\n */\r\n numberOfVerses: number;\r\n}\r\n\r\nexport interface ApiTranslationBookChapterAudio {\r\n /**\r\n * The chapter that the audio is for.\r\n */\r\n chapter: ApiTranslationBookChapter;\r\n\r\n /**\r\n * The link that the audio should be placed at.\r\n */\r\n link: string;\r\n\r\n /**\r\n * The original URL of the audio.\r\n */\r\n originalUrl: string;\r\n}\r\n\r\nexport interface ApiCommentaryProfileContent {\r\n /**\r\n * The commentary information for the profile.\r\n */\r\n commentary: ApiCommentary;\r\n\r\n /**\r\n * The information about the profile.\r\n */\r\n profile: ApiCommentaryProfile;\r\n\r\n /**\r\n * The content of the profile.\r\n */\r\n content: string[];\r\n}\r\n\r\n/**\r\n * The options for generating the API.\r\n */\r\nexport interface GenerateApiOptions {\r\n /**\r\n * Whether to use the common name for the book chapter API link. If false, then book IDs are used.\r\n * Audio URLs will always use the book ID.\r\n * Defaults to false.\r\n */\r\n useCommonName?: boolean;\r\n\r\n /**\r\n * Whether to replace the audio URLs in the dataset with ones that are hosted locally.\r\n * If true, then the audio URLs in the dataset will be replaced with ones that reference files hosted by the API itself.\r\n * If false, then the audio URLs in the dataset will be left as is.\r\n * Defaults to false.\r\n */\r\n generateAudioFiles?: boolean;\r\n\r\n /**\r\n * Gets the english name of the given language.\r\n * If not provided, then the english name for the language will be unknown and omitted.\r\n * @param language The language to get the english name for.\r\n */\r\n getEnglishName?: (language: string) => string | null | undefined;\r\n\r\n /**\r\n * Gets the native name of the given language.\r\n * If not provided, then the native name for the language will be unknown and omitted.\r\n * @param language The language to get the native name for.\r\n */\r\n getNativeName?: (language: string) => string | null | undefined;\r\n\r\n /**\r\n * The prefix that should be added to paths that are generated.\r\n */\r\n pathPrefix?: string;\r\n}\r\n\r\n/**\r\n * Generates the API output for the given dataset.\r\n * @param dataset The dataset to generate the API for.\r\n * @param options The options for generating the API.\r\n */\r\nexport function generateApiForDataset(\r\n dataset: DatasetOutput,\r\n options: GenerateApiOptions = {}\r\n): ApiOutput {\r\n const { useCommonName, pathPrefix } = options;\r\n const apiPathPrefix = pathPrefix ? pathPrefix : '';\r\n let api: ApiOutput = {\r\n availableTranslations: {\r\n translations: [],\r\n },\r\n translationBooks: [],\r\n translationBookChapters: [],\r\n translationBookChapterAudio: [],\r\n availableCommentaries: {\r\n commentaries: [],\r\n },\r\n commentaryBookChapters: [],\r\n commentaryBooks: [],\r\n commentaryProfiles: [],\r\n commentaryProfileContents: [],\r\n pathPrefix: apiPathPrefix,\r\n };\r\n\r\n const getNativeName = options.getNativeName;\r\n const getEnglishName = options.getEnglishName;\r\n\r\n for (let { books, ...translation } of dataset.translations) {\r\n let numberOfBooks = 0;\r\n let numberOfApocryphalBooks = 0;\r\n\r\n for (let book of books) {\r\n if (book.isApocryphal) {\r\n numberOfApocryphalBooks++;\r\n } else {\r\n numberOfBooks++;\r\n }\r\n }\r\n\r\n const apiTranslation: ApiTranslation = {\r\n ...translation,\r\n availableFormats: ['json'],\r\n listOfBooksApiLink: listOfBooksApiLink(\r\n translation.id,\r\n apiPathPrefix\r\n ),\r\n numberOfBooks,\r\n totalNumberOfChapters: 0,\r\n totalNumberOfVerses: 0,\r\n languageName: getNativeName\r\n ? (getNativeName(translation.language) ?? undefined)\r\n : undefined,\r\n languageEnglishName: getEnglishName\r\n ? (getEnglishName(translation.language) ?? undefined)\r\n : undefined,\r\n };\r\n\r\n if (numberOfApocryphalBooks > 0) {\r\n apiTranslation.numberOfApocryphalBooks = numberOfApocryphalBooks;\r\n }\r\n\r\n const translationBooks: ApiTranslationBooks = {\r\n translation: apiTranslation,\r\n books: [],\r\n };\r\n\r\n let translationChapters: ApiTranslationBookChapter[] = [];\r\n\r\n for (let { chapters, ...book } of books) {\r\n const firstChapterNumber = chapters[0].chapter.number;\r\n const lastChapterNumber =\r\n chapters[chapters.length - 1].chapter.number;\r\n const apiBook: ApiTranslationBook = {\r\n ...book,\r\n firstChapterNumber,\r\n firstChapterApiLink: bookChapterApiLink(\r\n translation.id,\r\n getBookLink(book),\r\n firstChapterNumber,\r\n 'json',\r\n apiPathPrefix\r\n ),\r\n lastChapterNumber,\r\n lastChapterApiLink: bookChapterApiLink(\r\n translation.id,\r\n getBookLink(book),\r\n lastChapterNumber,\r\n 'json',\r\n apiPathPrefix\r\n ),\r\n numberOfChapters: chapters.length,\r\n totalNumberOfVerses: 0,\r\n };\r\n\r\n for (let { chapter, thisChapterAudioLinks } of chapters) {\r\n const audio: TranslationBookChapterAudioLinks = {};\r\n const apiBookChapter: ApiTranslationBookChapter = {\r\n translation: apiTranslation,\r\n book: apiBook,\r\n chapter: chapter,\r\n thisChapterLink: bookChapterApiLink(\r\n translation.id,\r\n getBookLink(book),\r\n chapter.number,\r\n 'json',\r\n apiPathPrefix\r\n ),\r\n thisChapterAudioLinks: audio,\r\n nextChapterApiLink: null,\r\n nextChapterAudioLinks: null,\r\n previousChapterApiLink: null,\r\n previousChapterAudioLinks: null,\r\n numberOfVerses: 0,\r\n };\r\n\r\n for (let reader in thisChapterAudioLinks) {\r\n if (options.generateAudioFiles) {\r\n const apiAudio: ApiTranslationBookChapterAudio = {\r\n chapter: apiBookChapter,\r\n link: bookChapterAudioApiLink(\r\n translation.id,\r\n getBookLink(book),\r\n chapter.number,\r\n reader,\r\n apiPathPrefix\r\n ),\r\n originalUrl: thisChapterAudioLinks[reader],\r\n };\r\n audio[reader] = apiAudio.link;\r\n api.translationBookChapterAudio.push(apiAudio);\r\n } else {\r\n audio[reader] = thisChapterAudioLinks[reader];\r\n }\r\n }\r\n\r\n for (let c of chapter.content) {\r\n if (c.type === 'verse') {\r\n apiBookChapter.numberOfVerses++;\r\n }\r\n }\r\n\r\n apiBook.totalNumberOfVerses += apiBookChapter.numberOfVerses;\r\n\r\n translationChapters.push(apiBookChapter);\r\n api.translationBookChapters.push(apiBookChapter);\r\n }\r\n\r\n translationBooks.books.push(apiBook);\r\n\r\n if (apiBook.isApocryphal) {\r\n if (!apiTranslation.totalNumberOfApocryphalChapters) {\r\n apiTranslation.totalNumberOfApocryphalChapters = 0;\r\n }\r\n if (!apiTranslation.totalNumberOfApocryphalVerses) {\r\n apiTranslation.totalNumberOfApocryphalVerses = 0;\r\n }\r\n apiTranslation.totalNumberOfApocryphalChapters +=\r\n apiBook.numberOfChapters;\r\n apiTranslation.totalNumberOfApocryphalVerses +=\r\n apiBook.totalNumberOfVerses;\r\n } else {\r\n apiTranslation.totalNumberOfChapters +=\r\n apiBook.numberOfChapters;\r\n apiTranslation.totalNumberOfVerses +=\r\n apiBook.totalNumberOfVerses;\r\n }\r\n }\r\n\r\n for (let i = 0; i < translationChapters.length; i++) {\r\n if (i > 0) {\r\n translationChapters[i].previousChapterApiLink =\r\n bookChapterApiLink(\r\n translation.id,\r\n getBookLink(translationChapters[i - 1].book),\r\n translationChapters[i - 1].chapter.number,\r\n 'json',\r\n apiPathPrefix\r\n );\r\n translationChapters[i].previousChapterAudioLinks =\r\n translationChapters[i - 1].thisChapterAudioLinks;\r\n }\r\n\r\n if (i < translationChapters.length - 1) {\r\n translationChapters[i].nextChapterApiLink = bookChapterApiLink(\r\n translation.id,\r\n getBookLink(translationChapters[i + 1].book),\r\n translationChapters[i + 1].chapter.number,\r\n 'json',\r\n apiPathPrefix\r\n );\r\n translationChapters[i].nextChapterAudioLinks =\r\n translationChapters[i + 1].thisChapterAudioLinks;\r\n }\r\n }\r\n\r\n api.availableTranslations.translations.push(apiTranslation);\r\n api.translationBooks.push(translationBooks);\r\n }\r\n\r\n for (let { books, profiles, ...commentary } of dataset.commentaries) {\r\n const apiCommentary: ApiCommentary = {\r\n ...commentary,\r\n availableFormats: ['json'],\r\n listOfBooksApiLink: listOfCommentaryBooksApiLink(\r\n commentary.id,\r\n apiPathPrefix\r\n ),\r\n listOfProfilesApiLink: profilesCommentaryApiLink(\r\n commentary.id,\r\n 'json',\r\n apiPathPrefix\r\n ),\r\n numberOfBooks: books.length,\r\n totalNumberOfChapters: 0,\r\n totalNumberOfVerses: 0,\r\n totalNumberOfProfiles: 0,\r\n languageName: getNativeName\r\n ? (getNativeName(commentary.language) ?? undefined)\r\n : undefined,\r\n languageEnglishName: getEnglishName\r\n ? (getEnglishName(commentary.language) ?? undefined)\r\n : undefined,\r\n };\r\n\r\n const commentaryBooks: ApiCommentaryBooks = {\r\n commentary: apiCommentary,\r\n books: [],\r\n };\r\n\r\n const commentaryProfiles: ApiCommentaryProfiles = {\r\n commentary: apiCommentary,\r\n profiles: [],\r\n };\r\n\r\n let commentaryChapters: ApiCommentaryBookChapter[] = [];\r\n\r\n for (let { chapters, ...book } of books) {\r\n const firstChapterNumber = chapters[0]?.chapter.number ?? null;\r\n const lastChapterNumber =\r\n chapters[chapters.length - 1]?.chapter.number ?? null;\r\n const apiBook: ApiCommentaryBook = {\r\n ...book,\r\n firstChapterNumber,\r\n firstChapterApiLink: firstChapterNumber\r\n ? bookCommentaryChapterApiLink(\r\n commentary.id,\r\n getBookLink(book),\r\n firstChapterNumber,\r\n 'json',\r\n apiPathPrefix\r\n )\r\n : null,\r\n lastChapterNumber,\r\n lastChapterApiLink: lastChapterNumber\r\n ? bookCommentaryChapterApiLink(\r\n commentary.id,\r\n getBookLink(book),\r\n lastChapterNumber,\r\n 'json',\r\n apiPathPrefix\r\n )\r\n : null,\r\n numberOfChapters: chapters.length,\r\n totalNumberOfVerses: 0,\r\n };\r\n\r\n for (let { chapter } of chapters) {\r\n const apiBookChapter: ApiCommentaryBookChapter = {\r\n commentary: apiCommentary,\r\n book: apiBook,\r\n chapter: chapter,\r\n thisChapterLink: bookCommentaryChapterApiLink(\r\n commentary.id,\r\n getBookLink(book),\r\n chapter.number,\r\n 'json',\r\n apiPathPrefix\r\n ),\r\n nextChapterApiLink: null,\r\n previousChapterApiLink: null,\r\n numberOfVerses: 0,\r\n };\r\n\r\n for (let c of chapter.content) {\r\n if (c.type === 'verse') {\r\n apiBookChapter.numberOfVerses++;\r\n }\r\n }\r\n\r\n apiBook.totalNumberOfVerses += apiBookChapter.numberOfVerses;\r\n\r\n commentaryChapters.push(apiBookChapter);\r\n api.commentaryBookChapters.push(apiBookChapter);\r\n }\r\n\r\n commentaryBooks.books.push(apiBook);\r\n\r\n apiCommentary.totalNumberOfChapters += apiBook.numberOfChapters;\r\n apiCommentary.totalNumberOfVerses += apiBook.totalNumberOfVerses;\r\n }\r\n\r\n if (profiles) {\r\n for (let profile of profiles) {\r\n const apiProfile: ApiCommentaryProfile = {\r\n id: profile.id,\r\n reference: profile.reference,\r\n subject: profile.subject,\r\n thisProfileLink: profileCommentaryApiLink(\r\n commentary.id,\r\n profile.id,\r\n 'json',\r\n apiPathPrefix\r\n ),\r\n referenceChapterLink: profile.reference\r\n ? bookCommentaryChapterApiLink(\r\n commentary.id,\r\n profile.reference.book,\r\n profile.reference.chapter,\r\n 'json',\r\n apiPathPrefix\r\n )\r\n : null,\r\n };\r\n\r\n const apiProfileContent: ApiCommentaryProfileContent = {\r\n commentary: apiCommentary,\r\n profile: apiProfile,\r\n content: profile.content,\r\n };\r\n\r\n apiCommentary.totalNumberOfProfiles += 1;\r\n commentaryProfiles.profiles.push(apiProfile);\r\n api.commentaryProfileContents.push(apiProfileContent);\r\n }\r\n }\r\n\r\n for (let i = 0; i < commentaryChapters.length; i++) {\r\n if (i > 0) {\r\n commentaryChapters[i].previousChapterApiLink =\r\n bookCommentaryChapterApiLink(\r\n commentary.id,\r\n getBookLink(commentaryChapters[i - 1].book),\r\n commentaryChapters[i - 1].chapter.number,\r\n 'json',\r\n apiPathPrefix\r\n );\r\n // commentaryChapters[i].previousChapterAudioLinks =\r\n // commentaryChapters[i - 1].thisChapterAudioLinks;\r\n }\r\n\r\n if (i < commentaryChapters.length - 1) {\r\n commentaryChapters[i].nextChapterApiLink =\r\n bookCommentaryChapterApiLink(\r\n commentary.id,\r\n getBookLink(commentaryChapters[i + 1].book),\r\n commentaryChapters[i + 1].chapter.number,\r\n 'json',\r\n apiPathPrefix\r\n );\r\n // commentaryChapters[i].nextChapterAudioLinks =\r\n // commentaryChapters[i + 1].thisChapterAudioLinks;\r\n }\r\n }\r\n\r\n api.availableCommentaries.commentaries.push(apiCommentary);\r\n api.commentaryBooks.push(commentaryBooks);\r\n api.commentaryProfiles.push(commentaryProfiles);\r\n }\r\n\r\n return api;\r\n\r\n function getBookLink(book: TranslationBook | CommentaryBook): string {\r\n return useCommonName ? book.commonName : book.id;\r\n }\r\n}\r\n\r\n/**\r\n * Generates the output files for the given API.\r\n * @param api The API that the files should be generated for.\r\n */\r\nexport function generateFilesForApi(api: ApiOutput): OutputFile[] {\r\n let files: OutputFile[] = [];\r\n\r\n files.push(\r\n jsonFile(\r\n `${api.pathPrefix}/api/available_translations.json`,\r\n api.availableTranslations,\r\n true\r\n )\r\n );\r\n for (let translationBooks of api.translationBooks) {\r\n files.push(\r\n jsonFile(\r\n translationBooks.translation.listOfBooksApiLink,\r\n translationBooks\r\n )\r\n );\r\n }\r\n\r\n for (let bookChapter of api.translationBookChapters) {\r\n files.push(jsonFile(bookChapter.thisChapterLink, bookChapter));\r\n }\r\n\r\n for (let audio of api.translationBookChapterAudio) {\r\n files.push(downloadedFile(audio.link, audio.originalUrl));\r\n }\r\n\r\n files.push(\r\n jsonFile(\r\n `${api.pathPrefix}/api/available_commentaries.json`,\r\n api.availableCommentaries,\r\n true\r\n )\r\n );\r\n for (let commentaryBooks of api.commentaryBooks) {\r\n files.push(\r\n jsonFile(\r\n commentaryBooks.commentary.listOfBooksApiLink,\r\n commentaryBooks\r\n )\r\n );\r\n }\r\n\r\n for (let commentaryProfiles of api.commentaryProfiles) {\r\n files.push(\r\n jsonFile(\r\n commentaryProfiles.commentary.listOfProfilesApiLink,\r\n commentaryProfiles\r\n )\r\n );\r\n }\r\n\r\n for (let profileContent of api.commentaryProfileContents) {\r\n files.push(\r\n jsonFile(profileContent.profile.thisProfileLink, profileContent)\r\n );\r\n }\r\n\r\n for (let bookChapter of api.commentaryBookChapters) {\r\n files.push(jsonFile(bookChapter.thisChapterLink, bookChapter));\r\n }\r\n\r\n // for (let audio of api.translationBookChapterAudio) {\r\n // files.push(downloadedFile(audio.link, audio.originalUrl));\r\n // }\r\n\r\n return files;\r\n}\r\n\r\n/**\r\n * Generates the output files for the given datasets.\r\n * @param datasets The datasets to generate the output files for.\r\n * @param options The options for generating the API files.\r\n */\r\nexport async function* generateOutputFilesFromDatasets(\r\n datasets: AsyncIterable<DatasetOutput>,\r\n options?: GenerateApiOptions\r\n): AsyncGenerator<OutputFile[]> {\r\n for await (let dataset of datasets) {\r\n const api = generateApiForDataset(dataset, options);\r\n const files = generateFilesForApi(api);\r\n\r\n yield files;\r\n }\r\n}\r\n\r\n/**\r\n * Gets the API Link for the list of books endpoint for a translation.\r\n * @param translationId The ID of the translation.\r\n * @returns\r\n */\r\nexport function listOfBooksApiLink(\r\n translationId: string,\r\n prefix: string = ''\r\n): string {\r\n return `${prefix}/api/${translationId}/books.json`;\r\n}\r\n\r\n/**\r\n * Gets the API Link for the list of books endpoint for a commentary.\r\n * @param commentaryId The ID of the commentary.\r\n * @returns\r\n */\r\nexport function listOfCommentaryBooksApiLink(\r\n commentaryId: string,\r\n prefix: string = ''\r\n): string {\r\n return `${prefix}/api/c/${commentaryId}/books.json`;\r\n}\r\n\r\n/**\r\n * Getes the API link for a book chapter.\r\n * @param translationId The ID of the translation.\r\n * @param commonName The name of the book.\r\n * @param chapterNumber The number of the book.\r\n * @param extension The extension of the file.\r\n */\r\nexport function bookChapterApiLink(\r\n translationId: string,\r\n commonName: string,\r\n chapterNumber: number,\r\n extension: string,\r\n prefix: string = ''\r\n) {\r\n return `${prefix}/api/${translationId}/${replaceSpacesWithUnderscores(\r\n commonName\r\n )}/${chapterNumber}.${extension}`;\r\n}\r\n\r\n/**\r\n * Getes the API link for a book chapter.\r\n * @param translationId The ID of the translation.\r\n * @param commonName The name of the book.\r\n * @param chapterNumber The number of the book.\r\n * @param extension The extension of the file.\r\n */\r\nexport function bookCommentaryChapterApiLink(\r\n translationId: string,\r\n commonName: string,\r\n chapterNumber: number,\r\n extension: string,\r\n prefix: string = ''\r\n) {\r\n return `${prefix}/api/c/${translationId}/${replaceSpacesWithUnderscores(\r\n commonName\r\n )}/${chapterNumber}.${extension}`;\r\n}\r\n\r\nexport function bookChapterAudioApiLink(\r\n translationId: string,\r\n bookId: string,\r\n chapterNumber: number,\r\n reader: string,\r\n prefix: string = ''\r\n) {\r\n return `${prefix}/api/${translationId}/${replaceSpacesWithUnderscores(\r\n bookId\r\n )}/${chapterNumber}.${reader}.mp3`;\r\n}\r\n\r\n/**\r\n * Gets the API link for a profile.\r\n * @param translationId The ID of the translation.\r\n * @param profileId The ID of the profile.\r\n * @param extension The extension of the file.\r\n */\r\nexport function profilesCommentaryApiLink(\r\n translationId: string,\r\n extension: string,\r\n prefix: string = ''\r\n) {\r\n return `${prefix}/api/c/${translationId}/profiles.${extension}`;\r\n}\r\n\r\n/**\r\n * Gets the API link for a profile.\r\n * @param translationId The ID of the translation.\r\n * @param profileId The ID of the profile.\r\n * @param extension The extension of the file.\r\n */\r\nexport function profileCommentaryApiLink(\r\n translationId: string,\r\n profileId: string,\r\n extension: string,\r\n prefix: string = ''\r\n) {\r\n return `${prefix}/api/c/${translationId}/profiles/${replaceSpacesWithUnderscores(\r\n profileId\r\n )}.${extension}`;\r\n}\r\n\r\nexport function jsonFile(\r\n path: string,\r\n content: any,\r\n mergable?: boolean\r\n): OutputFile {\r\n return {\r\n path,\r\n content,\r\n mergable,\r\n };\r\n}\r\n\r\nexport function downloadedFile(path: string, url: string): OutputFile {\r\n return {\r\n path,\r\n content: () => fetch(url).then((response) => response.body),\r\n };\r\n}\r\n\r\nexport function replaceSpacesWithUnderscores(str: string): string {\r\n return str.replace(/[<>:\"/\\\\|?*\\s]/g, '_');\r\n}\r\n"],
|
|
5
|
+
"mappings": ";AAihBO,gBAAS,sBACZ,SACA,UAA8B,CAAC,GACtB;AACT,QAAM,EAAE,eAAe,WAAW,IAAI;AACtC,QAAM,gBAAgB,aAAa,aAAa;AAChD,MAAI,MAAiB;AAAA,IACjB,uBAAuB;AAAA,MACnB,cAAc,CAAC;AAAA,IACnB;AAAA,IACA,kBAAkB,CAAC;AAAA,IACnB,yBAAyB,CAAC;AAAA,IAC1B,6BAA6B,CAAC;AAAA,IAC9B,uBAAuB;AAAA,MACnB,cAAc,CAAC;AAAA,IACnB;AAAA,IACA,wBAAwB,CAAC;AAAA,IACzB,iBAAiB,CAAC;AAAA,IAClB,oBAAoB,CAAC;AAAA,IACrB,2BAA2B,CAAC;AAAA,IAC5B,YAAY;AAAA,EAChB;AAEA,QAAM,gBAAgB,QAAQ;AAC9B,QAAM,iBAAiB,QAAQ;AAE/B,WAAS,EAAE,OAAO,GAAG,YAAY,KAAK,QAAQ,cAAc;AACxD,QAAI,gBAAgB;AACpB,QAAI,0BAA0B;AAE9B,aAAS,QAAQ,OAAO;AACpB,UAAI,KAAK,cAAc;AACnB;AAAA,MACJ,OAAO;AACH;AAAA,MACJ;AAAA,IACJ;AAEA,UAAM,iBAAiC;AAAA,MACnC,GAAG;AAAA,MACH,kBAAkB,CAAC,MAAM;AAAA,MACzB,oBAAoB;AAAA,QAChB,YAAY;AAAA,QACZ;A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,SAAiB,IACnB;AACE,SAAO,GAAG,MAAM,QAAQ,aAAa,IAAI;AAAA,IACrC;AAAA,EACJ,CAAC,IAAI,aAAa,IAAI,SAAS;AACnC;AASO,gBAAS,6BACZ,eACA,YACA,eACA,WACA,SAAiB,IACnB;AACE,SAAO,GAAG,MAAM,UAAU,aAAa,IAAI;AAAA,IACvC;AAAA,EACJ,CAAC,IAAI,aAAa,IAAI,SAAS;AACnC;AAEO,gBAAS,wBACZ,eACA,QACA,eACA,QACA,SAAiB,IACnB;AACE,SAAO,GAAG,MAAM,QAAQ,aAAa,IAAI;AAAA,IACrC;AAAA,EACJ,CAAC,IAAI,aAAa,IAAI,MAAM;AAChC;AAQO,gBAAS,0BACZ,eACA,WACA,SAAiB,IACnB;AACE,SAAO,GAAG,MAAM,UAAU,aAAa,aAAa,SAAS;AACjE;AAQO,gBAAS,yBACZ,eACA,WACA,WACA,SAAiB,IACnB;AACE,SAAO,GAAG,MAAM,UAAU,aAAa,aAAa;AAAA,IAChD;AAAA,EACJ,CAAC,IAAI,SAAS;AAClB;AAEO,gBAAS,SACZ,MACA,SACA,UACU;AACV,SAAO;AAAA,IACH;AAAA,IACA;AAAA,IACA;AAAA,EACJ;AACJ;AAEO,gBAAS,eAAe,MAAc,KAAyB;AAClE,SAAO;AAAA,IACH;AAAA,IACA,SAAS,MAAM,MAAM,GAAG,EAAE,KAAK,CAAC,aAAa,SAAS,IAAI;AAAA,EAC9D;AACJ;AAEO,gBAAS,6BAA6B,KAAqB;AAC9D,SAAO,IAAI,QAAQ,mBAAmB,GAAG;AAC7C;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/esm/utils.js
CHANGED
|
@@ -222,14 +222,16 @@ export function getBookId(book) {
|
|
|
222
222
|
return null;
|
|
223
223
|
}
|
|
224
224
|
export const KNOWN_SKIPPED_VERSES = /* @__PURE__ */ new Set([
|
|
225
|
+
"MAT 12:47",
|
|
225
226
|
"MAT 17:21",
|
|
226
227
|
"MAT 18:11",
|
|
227
228
|
"MAT 23:14",
|
|
228
|
-
"
|
|
229
|
-
"
|
|
230
|
-
"
|
|
231
|
-
"
|
|
229
|
+
"MRK 7:16",
|
|
230
|
+
"MRK 9:44",
|
|
231
|
+
"MRK 9:46",
|
|
232
|
+
"MRK 11:26",
|
|
232
233
|
"LUK 17:36",
|
|
234
|
+
"LUK 23:17",
|
|
233
235
|
"JHN 5:4",
|
|
234
236
|
"ACT 8:37",
|
|
235
237
|
"ACT 15:34",
|
package/dist/esm/utils.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../utils.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Normalizes the given language code into a ISO 639 code.\n * @param language The language code to normalize.\n */\nexport function normalizeLanguage(language: string): string {\n return language;\n}\n\n/**\n * The map of translation IDs from fetch.bible to their translation ID in the API.\n */\nconst TRANSLATION_ID_MAP: Map<string, string> = new Map([\n ['eng_bsb', 'BSB'],\n ['arb_nav', 'ARBNAV'],\n ['eng_webp', 'ENGWEBP'],\n ['hin_irv', 'HINIRV'],\n ['hbo_mas', 'HBOMAS'],\n ['eng_drv', 'eng_dra'],\n]);\n\n/**\n * Gets the ID of the translation.\n * @param translation The translation to get the ID for.\n */\nexport function getTranslationId(translationId: string): string {\n return TRANSLATION_ID_MAP.get(translationId) ?? translationId;\n}\n\nexport function isEmptyOrWhitespace(str: string | null | undefined): boolean {\n return !str || /^\\s*$/.test(str);\n}\n\nexport function getFirstNonEmpty<T extends string>(...values: T[]): T {\n for (let value of values) {\n if (!isEmptyOrWhitespace(value)) {\n return value;\n }\n }\n\n throw new Error('All values are empty or whitespace!');\n}\n\nexport interface VerseRef {\n book: string;\n chapter: number;\n verse: number;\n\n /**\n * The rest of the content of the verse.\n */\n content?: string;\n\n /**\n * The chapter that the verse reference ends at.\n */\n endChapter?: number;\n\n /**\n * The verse that the verse reference ends at.\n */\n endVerse?: number;\n}\n\n/**\n * Parses the given verse reference.\n * Formatted like \"GEN 1:1\".\n *\n * @param text The reference to parse.\n */\nexport function parseVerseReference(text: string): VerseRef | null {\n const match = text.match(\n /^\\s*([0-9A-Za-z\\s]+)[\\s\\.]+(\\d+)[:\\.](\\d+)(?:-([0-9]+)(?:[\\s:\\.]([0-9]+))?)?/\n );\n\n if (!match) {\n return null;\n }\n\n const [reference, book, chapterStr, verseStr, endChapterStr, endVerseStr] =\n match;\n\n const chapter = parseInt(chapterStr);\n const verse = parseInt(verseStr);\n\n let endChapter = endChapterStr ? parseInt(endChapterStr) : undefined;\n let endVerse = endVerseStr ? parseInt(endVerseStr) : undefined;\n\n if (endChapter && !endVerse) {\n endVerse = endChapter;\n endChapter = undefined;\n }\n\n if (isNaN(chapter) || isNaN(verse)) {\n return null;\n }\n\n if (reference.length !== text.length) {\n return {\n book: getBookId(book) ?? book,\n chapter,\n verse,\n content: text.substring(reference.length).trim(),\n endChapter,\n endVerse,\n };\n }\n\n return {\n book: getBookId(book) ?? book,\n chapter,\n verse,\n endChapter,\n endVerse,\n };\n}\n\n/**\n * Defines a map that maps the book ID to the USFM Book identifier.\n */\nconst BOOK_ID_MAP: Map<string, string> = new Map([\n ['gen', 'GEN'],\n ['genesis', 'GEN'],\n ['exo', 'EXO'],\n ['exodus', 'EXO'],\n ['lev', 'LEV'],\n ['lev', 'LEV'],\n ['laviticus', 'LEV'],\n ['num', 'NUM'],\n ['numbers', 'NUM'],\n ['deu', 'DEU'],\n ['deuteronomy', 'DEU'],\n ['jos', 'JOS'],\n ['joshua', 'JOS'],\n ['jdg', 'JDG'],\n ['judges', 'JDG'],\n ['rut', 'RUT'],\n ['ruth', 'RUT'],\n ['1sa', '1SA'],\n ['1samuel', '1SA'],\n ['2sa', '2SA'],\n ['2samuel', '2SA'],\n ['1ki', '1KI'],\n ['1kings', '1KI'],\n ['1kgs', '1KI'],\n ['2ki', '2KI'],\n ['2kings', '2KI'],\n ['2kgs', '2KI'],\n ['1ch', '1CH'],\n ['1chronicles', '1CH'],\n ['chronicles1', '1CH'],\n ['2ch', '2CH'],\n ['2chronicles', '2CH'],\n ['chronicles2', '2CH'],\n ['ezr', 'EZR'],\n ['ezra', 'EZR'],\n ['neh', 'NEH'],\n ['nehemiah', 'NEH'],\n ['est', 'EST'],\n ['ester', 'EST'],\n ['job', 'JOB'],\n ['ps', 'PSA'],\n ['psa', 'PSA'],\n ['psalms', 'PSA'],\n ['psalm', 'PSA'],\n ['pr', 'PRO'],\n ['pro', 'PRO'],\n ['proverbs', 'PRO'],\n ['ecc', 'ECC'],\n ['ecclesiastes', 'ECC'],\n ['eccl', 'ECC'],\n ['sng', 'SNG'],\n ['song', 'SNG'],\n ['songofsolomon', 'SNG'],\n ['isa', 'ISA'],\n ['isaiah', 'ISA'],\n ['jer', 'JER'],\n ['jeremiah', 'JER'],\n ['lam', 'LAM'],\n ['lamentations', 'LAM'],\n ['ezk', 'EZK'],\n ['ezekiel', 'EZK'],\n ['ezek', 'EZK'],\n ['dan', 'DAN'],\n ['daniel', 'DAN'],\n ['hos', 'HOS'],\n ['hosea', 'HOS'],\n ['jol', 'JOL'],\n ['joel', 'JOL'],\n ['amo', 'AMO'],\n ['amos', 'AMO'],\n ['oba', 'OBA'],\n ['obadiah', 'OBA'],\n ['jon', 'JON'],\n ['jonah', 'JON'],\n ['mic', 'MIC'],\n ['micah', 'MIC'],\n ['nam', 'NAM'],\n ['nahum', 'NAM'],\n ['nah', 'NAM'],\n ['hab', 'HAB'],\n ['habakkuk', 'HAB'],\n ['zep', 'ZEP'],\n ['zepaniah', 'ZEP'],\n ['hag', 'HAG'],\n ['haggai', 'HAG'],\n ['zec', 'ZEC'],\n ['zechariah', 'ZEC'],\n ['mal', 'MAL'],\n ['malachi', 'MAL'],\n ['mat', 'MAT'],\n ['matthew', 'MAT'],\n ['mrk', 'MRK'],\n ['mark', 'MRK'],\n ['luk', 'LUK'],\n ['luke', 'LUK'],\n ['jhn', 'JHN'],\n ['john', 'JHN'],\n ['act', 'ACT'],\n ['acts', 'ACT'],\n ['rom', 'ROM'],\n ['romans', 'ROM'],\n ['1co', '1CO'],\n ['1corinthians', '1CO'],\n ['2co', '2CO'],\n ['2corinthians', '2CO'],\n ['gal', 'GAL'],\n ['galatians', 'GAL'],\n ['eph', 'EPH'],\n ['ephesians', 'EPH'],\n ['php', 'PHP'],\n ['philippians', 'PHP'],\n ['phil', 'PHP'],\n ['col', 'COL'],\n ['colossians', 'COL'],\n ['1th', '1TH'],\n ['1thessalonians', '1TH'],\n ['2th', '2TH'],\n ['2thessalonians', '2TH'],\n ['1ti', '1TI'],\n ['1timothy', '1TI'],\n ['2ti', '2TI'],\n ['2timothy', '2TI'],\n ['tit', 'TIT'],\n ['titus', 'TIT'],\n ['phm', 'PHM'],\n ['philemon', 'PHM'],\n ['phlm', 'PHM'],\n ['heb', 'HEB'],\n ['hebrews', 'HEB'],\n ['jas', 'JAS'],\n ['james', 'JAS'],\n ['1pe', '1PE'],\n ['1peter', '1PE'],\n ['2pe', '2PE'],\n ['2peter', '2PE'],\n ['1jn', '1JN'],\n ['1john', '1JN'],\n ['2jn', '2JN'],\n ['2john', '2JN'],\n ['3jn', '3JN'],\n ['3john', '3JN'],\n ['jud', 'JUD'],\n ['jude', 'JUD'],\n ['rev', 'REV'],\n ['revelation', 'REV'],\n]);\n\n/**\n * Gets the ID of the given book.\n * Returns null if the ID could not be found.\n * @param book The name/ID of the book.\n */\nexport function getBookId(book: string): string | null {\n const bookLower = book.toLowerCase().replaceAll(/\\s+/g, '');\n\n const id = BOOK_ID_MAP.get(bookLower);\n if (id) {\n return id;\n }\n\n for (let [key, id] of BOOK_ID_MAP) {\n if (bookLower.startsWith(key)) {\n return id;\n }\n }\n\n return null;\n}\n\n/**\n * A brief list of verses which may appear in some older translations\n * but are not present in more modern translations.\n */\nexport const KNOWN_SKIPPED_VERSES = new Set([\n 'MAT 17:21',\n 'MAT 18:11',\n 'MAT 23:14',\n '
|
|
5
|
-
"mappings": ";AAIO,gBAAS,kBA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AAAA,EACA;AAAA,EACA;AACJ,CAAC;",
|
|
4
|
+
"sourcesContent": ["/**\n * Normalizes the given language code into a ISO 639 code.\n * @param language The language code to normalize.\n */\nexport function normalizeLanguage(language: string): string {\n return language;\n}\n\n/**\n * The map of translation IDs from fetch.bible to their translation ID in the API.\n */\nconst TRANSLATION_ID_MAP: Map<string, string> = new Map([\n ['eng_bsb', 'BSB'],\n ['arb_nav', 'ARBNAV'],\n ['eng_webp', 'ENGWEBP'],\n ['hin_irv', 'HINIRV'],\n ['hbo_mas', 'HBOMAS'],\n ['eng_drv', 'eng_dra'],\n]);\n\n/**\n * Gets the ID of the translation.\n * @param translation The translation to get the ID for.\n */\nexport function getTranslationId(translationId: string): string {\n return TRANSLATION_ID_MAP.get(translationId) ?? translationId;\n}\n\nexport function isEmptyOrWhitespace(str: string | null | undefined): boolean {\n return !str || /^\\s*$/.test(str);\n}\n\nexport function getFirstNonEmpty<T extends string>(...values: T[]): T {\n for (let value of values) {\n if (!isEmptyOrWhitespace(value)) {\n return value;\n }\n }\n\n throw new Error('All values are empty or whitespace!');\n}\n\nexport interface VerseRef {\n book: string;\n chapter: number;\n verse: number;\n\n /**\n * The rest of the content of the verse.\n */\n content?: string;\n\n /**\n * The chapter that the verse reference ends at.\n */\n endChapter?: number;\n\n /**\n * The verse that the verse reference ends at.\n */\n endVerse?: number;\n}\n\n/**\n * Parses the given verse reference.\n * Formatted like \"GEN 1:1\".\n *\n * @param text The reference to parse.\n */\nexport function parseVerseReference(text: string): VerseRef | null {\n const match = text.match(\n /^\\s*([0-9A-Za-z\\s]+)[\\s\\.]+(\\d+)[:\\.](\\d+)(?:-([0-9]+)(?:[\\s:\\.]([0-9]+))?)?/\n );\n\n if (!match) {\n return null;\n }\n\n const [reference, book, chapterStr, verseStr, endChapterStr, endVerseStr] =\n match;\n\n const chapter = parseInt(chapterStr);\n const verse = parseInt(verseStr);\n\n let endChapter = endChapterStr ? parseInt(endChapterStr) : undefined;\n let endVerse = endVerseStr ? parseInt(endVerseStr) : undefined;\n\n if (endChapter && !endVerse) {\n endVerse = endChapter;\n endChapter = undefined;\n }\n\n if (isNaN(chapter) || isNaN(verse)) {\n return null;\n }\n\n if (reference.length !== text.length) {\n return {\n book: getBookId(book) ?? book,\n chapter,\n verse,\n content: text.substring(reference.length).trim(),\n endChapter,\n endVerse,\n };\n }\n\n return {\n book: getBookId(book) ?? book,\n chapter,\n verse,\n endChapter,\n endVerse,\n };\n}\n\n/**\n * Defines a map that maps the book ID to the USFM Book identifier.\n */\nconst BOOK_ID_MAP: Map<string, string> = new Map([\n ['gen', 'GEN'],\n ['genesis', 'GEN'],\n ['exo', 'EXO'],\n ['exodus', 'EXO'],\n ['lev', 'LEV'],\n ['lev', 'LEV'],\n ['laviticus', 'LEV'],\n ['num', 'NUM'],\n ['numbers', 'NUM'],\n ['deu', 'DEU'],\n ['deuteronomy', 'DEU'],\n ['jos', 'JOS'],\n ['joshua', 'JOS'],\n ['jdg', 'JDG'],\n ['judges', 'JDG'],\n ['rut', 'RUT'],\n ['ruth', 'RUT'],\n ['1sa', '1SA'],\n ['1samuel', '1SA'],\n ['2sa', '2SA'],\n ['2samuel', '2SA'],\n ['1ki', '1KI'],\n ['1kings', '1KI'],\n ['1kgs', '1KI'],\n ['2ki', '2KI'],\n ['2kings', '2KI'],\n ['2kgs', '2KI'],\n ['1ch', '1CH'],\n ['1chronicles', '1CH'],\n ['chronicles1', '1CH'],\n ['2ch', '2CH'],\n ['2chronicles', '2CH'],\n ['chronicles2', '2CH'],\n ['ezr', 'EZR'],\n ['ezra', 'EZR'],\n ['neh', 'NEH'],\n ['nehemiah', 'NEH'],\n ['est', 'EST'],\n ['ester', 'EST'],\n ['job', 'JOB'],\n ['ps', 'PSA'],\n ['psa', 'PSA'],\n ['psalms', 'PSA'],\n ['psalm', 'PSA'],\n ['pr', 'PRO'],\n ['pro', 'PRO'],\n ['proverbs', 'PRO'],\n ['ecc', 'ECC'],\n ['ecclesiastes', 'ECC'],\n ['eccl', 'ECC'],\n ['sng', 'SNG'],\n ['song', 'SNG'],\n ['songofsolomon', 'SNG'],\n ['isa', 'ISA'],\n ['isaiah', 'ISA'],\n ['jer', 'JER'],\n ['jeremiah', 'JER'],\n ['lam', 'LAM'],\n ['lamentations', 'LAM'],\n ['ezk', 'EZK'],\n ['ezekiel', 'EZK'],\n ['ezek', 'EZK'],\n ['dan', 'DAN'],\n ['daniel', 'DAN'],\n ['hos', 'HOS'],\n ['hosea', 'HOS'],\n ['jol', 'JOL'],\n ['joel', 'JOL'],\n ['amo', 'AMO'],\n ['amos', 'AMO'],\n ['oba', 'OBA'],\n ['obadiah', 'OBA'],\n ['jon', 'JON'],\n ['jonah', 'JON'],\n ['mic', 'MIC'],\n ['micah', 'MIC'],\n ['nam', 'NAM'],\n ['nahum', 'NAM'],\n ['nah', 'NAM'],\n ['hab', 'HAB'],\n ['habakkuk', 'HAB'],\n ['zep', 'ZEP'],\n ['zepaniah', 'ZEP'],\n ['hag', 'HAG'],\n ['haggai', 'HAG'],\n ['zec', 'ZEC'],\n ['zechariah', 'ZEC'],\n ['mal', 'MAL'],\n ['malachi', 'MAL'],\n ['mat', 'MAT'],\n ['matthew', 'MAT'],\n ['mrk', 'MRK'],\n ['mark', 'MRK'],\n ['luk', 'LUK'],\n ['luke', 'LUK'],\n ['jhn', 'JHN'],\n ['john', 'JHN'],\n ['act', 'ACT'],\n ['acts', 'ACT'],\n ['rom', 'ROM'],\n ['romans', 'ROM'],\n ['1co', '1CO'],\n ['1corinthians', '1CO'],\n ['2co', '2CO'],\n ['2corinthians', '2CO'],\n ['gal', 'GAL'],\n ['galatians', 'GAL'],\n ['eph', 'EPH'],\n ['ephesians', 'EPH'],\n ['php', 'PHP'],\n ['philippians', 'PHP'],\n ['phil', 'PHP'],\n ['col', 'COL'],\n ['colossians', 'COL'],\n ['1th', '1TH'],\n ['1thessalonians', '1TH'],\n ['2th', '2TH'],\n ['2thessalonians', '2TH'],\n ['1ti', '1TI'],\n ['1timothy', '1TI'],\n ['2ti', '2TI'],\n ['2timothy', '2TI'],\n ['tit', 'TIT'],\n ['titus', 'TIT'],\n ['phm', 'PHM'],\n ['philemon', 'PHM'],\n ['phlm', 'PHM'],\n ['heb', 'HEB'],\n ['hebrews', 'HEB'],\n ['jas', 'JAS'],\n ['james', 'JAS'],\n ['1pe', '1PE'],\n ['1peter', '1PE'],\n ['2pe', '2PE'],\n ['2peter', '2PE'],\n ['1jn', '1JN'],\n ['1john', '1JN'],\n ['2jn', '2JN'],\n ['2john', '2JN'],\n ['3jn', '3JN'],\n ['3john', '3JN'],\n ['jud', 'JUD'],\n ['jude', 'JUD'],\n ['rev', 'REV'],\n ['revelation', 'REV'],\n]);\n\n/**\n * Gets the ID of the given book.\n * Returns null if the ID could not be found.\n * @param book The name/ID of the book.\n */\nexport function getBookId(book: string): string | null {\n const bookLower = book.toLowerCase().replaceAll(/\\s+/g, '');\n\n const id = BOOK_ID_MAP.get(bookLower);\n if (id) {\n return id;\n }\n\n for (let [key, id] of BOOK_ID_MAP) {\n if (bookLower.startsWith(key)) {\n return id;\n }\n }\n\n return null;\n}\n\n/**\n * A brief list of verses which may appear in some older translations\n * but are not present in more modern translations.\n */\nexport const KNOWN_SKIPPED_VERSES = new Set([\n 'MAT 12:47',\n 'MAT 17:21',\n 'MAT 18:11',\n 'MAT 23:14',\n 'MRK 7:16',\n 'MRK 9:44',\n 'MRK 9:46',\n 'MRK 11:26',\n 'LUK 17:36',\n 'LUK 23:17',\n 'JHN 5:4',\n 'ACT 8:37',\n 'ACT 15:34',\n 'ACT 24:7',\n 'ACT 28:29',\n 'ROM 16:24',\n]);\n"],
|
|
5
|
+
"mappings": ";AAIO,gBAAS,kBAAkB,UAA0B;AACxD,SAAO;AACX;AAKA,MAAM,qBAA0C,oBAAI,IAAI;AAAA,EACpD,CAAC,WAAW,KAAK;AAAA,EACjB,CAAC,WAAW,QAAQ;AAAA,EACpB,CAAC,YAAY,SAAS;AAAA,EACtB,CAAC,WAAW,QAAQ;A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CAAC,YAAY,KAAK;AAAA,EAClB,CAAC,QAAQ,KAAK;AAAA,EACd,CAAC,OAAO,KAAK;AAAA,EACb,CAAC,WAAW,KAAK;AAAA,EACjB,CAAC,OAAO,KAAK;AAAA,EACb,CAAC,SAAS,KAAK;AAAA,EACf,CAAC,OAAO,KAAK;AAAA,EACb,CAAC,UAAU,KAAK;AAAA,EAChB,CAAC,OAAO,KAAK;AAAA,EACb,CAAC,UAAU,KAAK;AAAA,EAChB,CAAC,OAAO,KAAK;AAAA,EACb,CAAC,SAAS,KAAK;AAAA,EACf,CAAC,OAAO,KAAK;AAAA,EACb,CAAC,SAAS,KAAK;AAAA,EACf,CAAC,OAAO,KAAK;AAAA,EACb,CAAC,SAAS,KAAK;AAAA,EACf,CAAC,OAAO,KAAK;AAAA,EACb,CAAC,QAAQ,KAAK;AAAA,EACd,CAAC,OAAO,KAAK;AAAA,EACb,CAAC,cAAc,KAAK;AACxB,CAAC;AAOM,gBAAS,UAAU,MAA6B;AACnD,QAAM,YAAY,KAAK,YAAY,EAAE,WAAW,QAAQ,EAAE;AAE1D,QAAM,KAAK,YAAY,IAAI,SAAS;AACpC,MAAI,IAAI;AACJ,WAAO;AAAA,EACX;AAEA,WAAS,CAAC,KAAKA,GAAE,KAAK,aAAa;AAC/B,QAAI,UAAU,WAAW,GAAG,GAAG;AAC3B,aAAOA;AAAA,IACX;AAAA,EACJ;AAEA,SAAO;AACX;AAMO,aAAM,uBAAuB,oBAAI,IAAI;AAAA,EACxC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACJ,CAAC;",
|
|
6
6
|
"names": ["id"]
|
|
7
7
|
}
|
|
@@ -239,10 +239,18 @@ export interface ApiCommentaryProfile extends CommentaryProfile {
|
|
|
239
239
|
* Defines a translation book that is used in the API.
|
|
240
240
|
*/
|
|
241
241
|
export interface ApiTranslationBook extends TranslationBook {
|
|
242
|
+
/**
|
|
243
|
+
* The number of the first chapter in the book.
|
|
244
|
+
*/
|
|
245
|
+
firstChapterNumber: number;
|
|
242
246
|
/**
|
|
243
247
|
* The link to the first chapter of the book.
|
|
244
248
|
*/
|
|
245
249
|
firstChapterApiLink: string;
|
|
250
|
+
/**
|
|
251
|
+
* The number of the last chapter in the book.
|
|
252
|
+
*/
|
|
253
|
+
lastChapterNumber: number;
|
|
246
254
|
/**
|
|
247
255
|
* The link to the last chapter of the book.
|
|
248
256
|
*/
|
|
@@ -260,14 +268,30 @@ export interface ApiTranslationBook extends TranslationBook {
|
|
|
260
268
|
* Defines a commentary book that is used in the API.
|
|
261
269
|
*/
|
|
262
270
|
export interface ApiCommentaryBook extends CommentaryBook {
|
|
271
|
+
/**
|
|
272
|
+
* The number of the first chapter in the book.
|
|
273
|
+
*
|
|
274
|
+
* Null if the comentary book has no chapters.
|
|
275
|
+
*/
|
|
276
|
+
firstChapterNumber: number | null;
|
|
263
277
|
/**
|
|
264
278
|
* The link to the first chapter of the book.
|
|
279
|
+
*
|
|
280
|
+
* Null if the comentary book has no chapters.
|
|
265
281
|
*/
|
|
266
|
-
firstChapterApiLink: string;
|
|
282
|
+
firstChapterApiLink: string | null;
|
|
283
|
+
/**
|
|
284
|
+
* The number of the last chapter in the book.
|
|
285
|
+
*
|
|
286
|
+
* Null if the comentary book has no chapters.
|
|
287
|
+
*/
|
|
288
|
+
lastChapterNumber: number | null;
|
|
267
289
|
/**
|
|
268
290
|
* The link to the last chapter of the book.
|
|
291
|
+
*
|
|
292
|
+
* Null if the comentary book has no chapters.
|
|
269
293
|
*/
|
|
270
|
-
lastChapterApiLink: string;
|
|
294
|
+
lastChapterApiLink: string | null;
|
|
271
295
|
/**
|
|
272
296
|
* The number of chapters that the book contains.
|
|
273
297
|
*/
|