@helloao/tools 0.0.10 → 0.0.12

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.
Files changed (49) hide show
  1. package/dist/cjs/generation/api.cjs +69 -1
  2. package/dist/cjs/generation/api.cjs.map +2 -2
  3. package/dist/cjs/generation/common-types.cjs.map +1 -1
  4. package/dist/cjs/generation/dataset.cjs +59 -42
  5. package/dist/cjs/generation/dataset.cjs.map +3 -3
  6. package/dist/cjs/index.cjs +3 -0
  7. package/dist/cjs/index.cjs.map +2 -2
  8. package/dist/cjs/log.cjs +50 -0
  9. package/dist/cjs/log.cjs.map +7 -0
  10. package/dist/cjs/parser/codex-parser.cjs +15 -12
  11. package/dist/cjs/parser/codex-parser.cjs.map +2 -2
  12. package/dist/cjs/parser/commentary-csv-parser.cjs.map +2 -2
  13. package/dist/cjs/parser/iterators.cjs +17 -6
  14. package/dist/cjs/parser/iterators.cjs.map +2 -2
  15. package/dist/cjs/parser/tyndale-xml-parser.cjs +212 -0
  16. package/dist/cjs/parser/tyndale-xml-parser.cjs.map +7 -0
  17. package/dist/cjs/parser/types.cjs.map +1 -1
  18. package/dist/cjs/parser/usfm-parser.cjs +4 -2
  19. package/dist/cjs/parser/usfm-parser.cjs.map +2 -2
  20. package/dist/cjs/utils.cjs +26 -4
  21. package/dist/cjs/utils.cjs.map +2 -2
  22. package/dist/esm/generation/api.js +65 -1
  23. package/dist/esm/generation/api.js.map +2 -2
  24. package/dist/esm/generation/dataset.js +60 -43
  25. package/dist/esm/generation/dataset.js.map +2 -2
  26. package/dist/esm/index.js +2 -1
  27. package/dist/esm/index.js.map +2 -2
  28. package/dist/esm/log.js +20 -0
  29. package/dist/esm/log.js.map +7 -0
  30. package/dist/esm/parser/codex-parser.js +15 -12
  31. package/dist/esm/parser/codex-parser.js.map +2 -2
  32. package/dist/esm/parser/commentary-csv-parser.js.map +2 -2
  33. package/dist/esm/parser/iterators.js +17 -6
  34. package/dist/esm/parser/iterators.js.map +2 -2
  35. package/dist/esm/parser/tyndale-xml-parser.js +184 -0
  36. package/dist/esm/parser/tyndale-xml-parser.js.map +7 -0
  37. package/dist/esm/parser/usfm-parser.js +4 -2
  38. package/dist/esm/parser/usfm-parser.js.map +2 -2
  39. package/dist/esm/utils.js +26 -4
  40. package/dist/esm/utils.js.map +2 -2
  41. package/dist/types/generation/api.d.ts +76 -1
  42. package/dist/types/generation/common-types.d.ts +32 -2
  43. package/dist/types/generation/dataset.d.ts +17 -3
  44. package/dist/types/index.d.ts +2 -1
  45. package/dist/types/log.d.ts +23 -0
  46. package/dist/types/parser/tyndale-xml-parser.d.ts +8 -0
  47. package/dist/types/parser/types.d.ts +25 -0
  48. package/dist/types/utils.d.ts +8 -0
  49. package/package.json +35 -13
@@ -28,6 +28,8 @@ __export(api_exports, {
28
28
  jsonFile: () => jsonFile,
29
29
  listOfBooksApiLink: () => listOfBooksApiLink,
30
30
  listOfCommentaryBooksApiLink: () => listOfCommentaryBooksApiLink,
31
+ profileCommentaryApiLink: () => profileCommentaryApiLink,
32
+ profilesCommentaryApiLink: () => profilesCommentaryApiLink,
31
33
  replaceSpacesWithUnderscores: () => replaceSpacesWithUnderscores
32
34
  });
33
35
  module.exports = __toCommonJS(api_exports);
@@ -46,6 +48,8 @@ function generateApiForDataset(dataset, options = {}) {
46
48
  },
47
49
  commentaryBookChapters: [],
48
50
  commentaryBooks: [],
51
+ commentaryProfiles: [],
52
+ commentaryProfileContents: [],
49
53
  pathPrefix: apiPathPrefix
50
54
  };
51
55
  const getNativeName = options.getNativeName;
@@ -166,7 +170,7 @@ function generateApiForDataset(dataset, options = {}) {
166
170
  api.availableTranslations.translations.push(apiTranslation);
167
171
  api.translationBooks.push(translationBooks);
168
172
  }
169
- for (let { books, ...commentary } of dataset.commentaries) {
173
+ for (let { books, profiles, ...commentary } of dataset.commentaries) {
170
174
  const apiCommentary = {
171
175
  ...commentary,
172
176
  availableFormats: ["json"],
@@ -174,9 +178,15 @@ function generateApiForDataset(dataset, options = {}) {
174
178
  commentary.id,
175
179
  apiPathPrefix
176
180
  ),
181
+ listOfProfilesApiLink: profilesCommentaryApiLink(
182
+ commentary.id,
183
+ "json",
184
+ apiPathPrefix
185
+ ),
177
186
  numberOfBooks: books.length,
178
187
  totalNumberOfChapters: 0,
179
188
  totalNumberOfVerses: 0,
189
+ totalNumberOfProfiles: 0,
180
190
  languageName: getNativeName ? getNativeName(commentary.language) ?? void 0 : void 0,
181
191
  languageEnglishName: getEnglishName ? getEnglishName(commentary.language) ?? void 0 : void 0
182
192
  };
@@ -184,6 +194,10 @@ function generateApiForDataset(dataset, options = {}) {
184
194
  commentary: apiCommentary,
185
195
  books: []
186
196
  };
197
+ const commentaryProfiles = {
198
+ commentary: apiCommentary,
199
+ profiles: []
200
+ };
187
201
  let commentaryChapters = [];
188
202
  for (let { chapters, ...book } of books) {
189
203
  const apiBook = {
@@ -234,6 +248,36 @@ function generateApiForDataset(dataset, options = {}) {
234
248
  apiCommentary.totalNumberOfChapters += apiBook.numberOfChapters;
235
249
  apiCommentary.totalNumberOfVerses += apiBook.totalNumberOfVerses;
236
250
  }
251
+ if (profiles) {
252
+ for (let profile of profiles) {
253
+ const apiProfile = {
254
+ id: profile.id,
255
+ reference: profile.reference,
256
+ subject: profile.subject,
257
+ thisProfileLink: profileCommentaryApiLink(
258
+ commentary.id,
259
+ profile.id,
260
+ "json",
261
+ apiPathPrefix
262
+ ),
263
+ referenceChapterLink: profile.reference ? bookCommentaryChapterApiLink(
264
+ commentary.id,
265
+ profile.reference.book,
266
+ profile.reference.chapter,
267
+ "json",
268
+ apiPathPrefix
269
+ ) : null
270
+ };
271
+ const apiProfileContent = {
272
+ commentary: apiCommentary,
273
+ profile: apiProfile,
274
+ content: profile.content
275
+ };
276
+ apiCommentary.totalNumberOfProfiles += 1;
277
+ commentaryProfiles.profiles.push(apiProfile);
278
+ api.commentaryProfileContents.push(apiProfileContent);
279
+ }
280
+ }
237
281
  for (let i = 0; i < commentaryChapters.length; i++) {
238
282
  if (i > 0) {
239
283
  commentaryChapters[i].previousChapterApiLink = bookCommentaryChapterApiLink(
@@ -256,6 +300,7 @@ function generateApiForDataset(dataset, options = {}) {
256
300
  }
257
301
  api.availableCommentaries.commentaries.push(apiCommentary);
258
302
  api.commentaryBooks.push(commentaryBooks);
303
+ api.commentaryProfiles.push(commentaryProfiles);
259
304
  }
260
305
  return api;
261
306
  function getBookLink(book) {
@@ -300,6 +345,19 @@ function generateFilesForApi(api) {
300
345
  )
301
346
  );
302
347
  }
348
+ for (let commentaryProfiles of api.commentaryProfiles) {
349
+ files.push(
350
+ jsonFile(
351
+ commentaryProfiles.commentary.listOfProfilesApiLink,
352
+ commentaryProfiles
353
+ )
354
+ );
355
+ }
356
+ for (let profileContent of api.commentaryProfileContents) {
357
+ files.push(
358
+ jsonFile(profileContent.profile.thisProfileLink, profileContent)
359
+ );
360
+ }
303
361
  for (let bookChapter of api.commentaryBookChapters) {
304
362
  files.push(jsonFile(bookChapter.thisChapterLink, bookChapter));
305
363
  }
@@ -333,6 +391,14 @@ function bookChapterAudioApiLink(translationId, bookId, chapterNumber, reader, p
333
391
  bookId
334
392
  )}/${chapterNumber}.${reader}.mp3`;
335
393
  }
394
+ function profilesCommentaryApiLink(translationId, extension, prefix = "") {
395
+ return `${prefix}/api/c/${translationId}/profiles.${extension}`;
396
+ }
397
+ function profileCommentaryApiLink(translationId, profileId, extension, prefix = "") {
398
+ return `${prefix}/api/c/${translationId}/profiles/${replaceSpacesWithUnderscores(
399
+ profileId
400
+ )}.${extension}`;
401
+ }
336
402
  function jsonFile(path, content, mergable) {
337
403
  return {
338
404
  path,
@@ -361,6 +427,8 @@ function replaceSpacesWithUnderscores(str) {
361
427
  jsonFile,
362
428
  listOfBooksApiLink,
363
429
  listOfCommentaryBooksApiLink,
430
+ profileCommentaryApiLink,
431
+ profilesCommentaryApiLink,
364
432
  replaceSpacesWithUnderscores
365
433
  });
366
434
  //# sourceMappingURL=api.cjs.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../generation/api.ts"],
4
- "sourcesContent": ["import {\r\n Commentary,\r\n CommentaryBook,\r\n CommentaryBookChapter,\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 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 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 * 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 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 * 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 a translation book that is used in the API.\r\n */\r\nexport interface ApiTranslationBook extends TranslationBook {\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 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 link to the first chapter of the book.\r\n */\r\n firstChapterApiLink: string;\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 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\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 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 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: books.length,\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 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 apiBook: ApiTranslationBook = {\r\n ...book,\r\n firstChapterApiLink: bookChapterApiLink(\r\n translation.id,\r\n getBookLink(book),\r\n 1,\r\n 'json',\r\n apiPathPrefix\r\n ),\r\n lastChapterApiLink: bookChapterApiLink(\r\n translation.id,\r\n getBookLink(book),\r\n chapters.length,\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 apiTranslation.totalNumberOfChapters += apiBook.numberOfChapters;\r\n apiTranslation.totalNumberOfVerses += apiBook.totalNumberOfVerses;\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, ...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 numberOfBooks: books.length,\r\n totalNumberOfChapters: 0,\r\n totalNumberOfVerses: 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 let commentaryChapters: ApiCommentaryBookChapter[] = [];\r\n\r\n for (let { chapters, ...book } of books) {\r\n const apiBook: ApiCommentaryBook = {\r\n ...book,\r\n firstChapterApiLink: bookCommentaryChapterApiLink(\r\n commentary.id,\r\n getBookLink(book),\r\n 1,\r\n 'json',\r\n apiPathPrefix\r\n ),\r\n lastChapterApiLink: bookCommentaryChapterApiLink(\r\n commentary.id,\r\n getBookLink(book),\r\n chapters.length,\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 } 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 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 }\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 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\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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA6ZO,SAAS,sBACZ,SACA,UAA8B,CAAC,GACtB;AACT,QAAM,EAAE,eAAe,WAAW,IAAI;AACtC,QAAM,gBAAgB,aAAa,aAAa;AACh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AiB,IACX;AACN,SAAO,GAAG,MAAM,QAAQ,aAAa;AACzC;AAOO,SAAS,6BACZ,cACA,SAAiB,IACX;AACN,SAAO,GAAG,MAAM,UAAU,YAAY;AAC1C;AASO,SAAS,mBACZ,eACA,YACA,eACA,WACA,SAAiB,IACnB;AACE,SAAO,GAAG,MAAM,QAAQ,aAAa,IAAI;AAAA,IACrC;AAAA,EACJ,CAAC,IAAI,aAAa,IAAI,SAAS;AACnC;AASO,SAAS,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,SAAS,wBACZ,eACA,QACA,eACA,QACA,SAAiB,IACnB;AACE,SAAO,GAAG,MAAM,QAAQ,aAAa,IAAI;AAAA,IACrC;AAAA,EACJ,CAAC,IAAI,aAAa,IAAI,MAAM;AAChC;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;",
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 * 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 link to the first chapter of the book.\r\n */\r\n firstChapterApiLink: string;\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 link to the first chapter of the book.\r\n */\r\n firstChapterApiLink: string;\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 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 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: books.length,\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 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 apiBook: ApiTranslationBook = {\r\n ...book,\r\n firstChapterApiLink: bookChapterApiLink(\r\n translation.id,\r\n getBookLink(book),\r\n 1,\r\n 'json',\r\n apiPathPrefix\r\n ),\r\n lastChapterApiLink: bookChapterApiLink(\r\n translation.id,\r\n getBookLink(book),\r\n chapters.length,\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 apiTranslation.totalNumberOfChapters += apiBook.numberOfChapters;\r\n apiTranslation.totalNumberOfVerses += apiBook.totalNumberOfVerses;\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 apiBook: ApiCommentaryBook = {\r\n ...book,\r\n firstChapterApiLink: bookCommentaryChapterApiLink(\r\n commentary.id,\r\n getBookLink(book),\r\n 1,\r\n 'json',\r\n apiPathPrefix\r\n ),\r\n lastChapterApiLink: bookCommentaryChapterApiLink(\r\n commentary.id,\r\n getBookLink(book),\r\n chapters.length,\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 } 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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAseO,SAAS,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,EACh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;AACE,SAAO,GAAG,MAAM,QAAQ,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
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../generation/common-types.ts"],
4
- "sourcesContent": ["/**\r\n * Defines an interface that contains information about a input file.\r\n */\r\nexport type InputFile = InputTranslationFile | InputCommentaryFile;\r\n\r\nexport interface InputFileBase {\r\n name?: string;\r\n content: string;\r\n sha256?: string;\r\n}\r\n\r\nexport type InputFileMetadata =\r\n | InputTranslationMetadata\r\n | InputCommentaryMetadata;\r\n\r\nexport interface InputTranslationFile extends InputFileBase {\r\n fileType: 'usfm' | 'usx' | 'json';\r\n metadata: InputTranslationMetadata;\r\n}\r\n\r\nexport interface InputCommentaryFile extends InputFileBase {\r\n fileType: 'commentary/csv';\r\n metadata: InputCommentaryMetadata;\r\n}\r\n\r\nexport type OutputFileContent = object | ReadableStream;\r\n\r\n/**\r\n * Defines an interface that contains information about a output file.\r\n */\r\nexport interface OutputFile {\r\n /**\r\n * The path that the file should be stored at.\r\n */\r\n path: string;\r\n\r\n /**\r\n * The content of the file.\r\n */\r\n content: OutputFileContent | (() => Promise<OutputFileContent>);\r\n\r\n /**\r\n * Whether the file can be merged with files of the same name but from other datasets.\r\n */\r\n mergable?: boolean;\r\n}\r\n\r\nexport interface MetadataBase {\r\n /**\r\n * The name of the translation.\r\n */\r\n name: string;\r\n\r\n /**\r\n * The english name of the translation.\r\n */\r\n englishName: string;\r\n\r\n /**\r\n * The website for the translation.\r\n */\r\n website: string;\r\n\r\n /**\r\n * The URL that the license for the translation can be found.\r\n */\r\n licenseUrl: string;\r\n\r\n /**\r\n * The ISO 639 letter language tag that the translation is primarily in.\r\n */\r\n language: string;\r\n\r\n /**\r\n * The direction that the text is written in.\r\n */\r\n direction: 'ltr' | 'rtl';\r\n}\r\n\r\n/**\r\n * The metadata for a translation that is input into the generator.\r\n */\r\nexport interface InputTranslationMetadata extends MetadataBase {\r\n /**\r\n * The ID of the translation.\r\n */\r\n id: string;\r\n\r\n /**\r\n * The short name for the translation.\r\n */\r\n shortName?: string;\r\n}\r\n\r\n/**\r\n * The metadata for a translation that is input into the generator.\r\n */\r\nexport interface InputCommentaryMetadata extends MetadataBase {\r\n /**\r\n * The ID of the commentary.\r\n */\r\n id: string;\r\n}\r\n\r\n/**\r\n * Defines an interface that contains information about a translation.\r\n */\r\nexport interface Translation {\r\n /**\r\n * The ID of the translation.\r\n */\r\n id: string;\r\n\r\n /**\r\n * The name of the translation.\r\n */\r\n name: string;\r\n\r\n /**\r\n * The website for the translation.\r\n */\r\n website: string;\r\n\r\n /**\r\n * The URL that the license for the translation can be found.\r\n */\r\n licenseUrl: string;\r\n\r\n /**\r\n * The short name for the translation.\r\n */\r\n shortName?: string;\r\n\r\n /**\r\n * The English name for the translation.\r\n */\r\n englishName: string;\r\n\r\n /**\r\n * The ISO 639 3-letter language tag that the translation is primarily in.\r\n */\r\n language: string;\r\n\r\n /**\r\n * The direction that the language is written in.\r\n * \"ltr\" indicates that the text is written from the left side of the page to the right.\r\n * \"rtl\" indicates that the text is written from the right side of the page to the left.\r\n */\r\n textDirection: 'ltr' | 'rtl';\r\n}\r\n\r\n/**\r\n * Defines an interface that contains information about a commentary.\r\n */\r\nexport interface Commentary {\r\n /**\r\n * The ID of the commentary.\r\n */\r\n id: string;\r\n\r\n /**\r\n * The name of the commentary.\r\n */\r\n name: string;\r\n\r\n /**\r\n * The website for the commentary.\r\n */\r\n website: string;\r\n\r\n /**\r\n * The URL that the license for the commentary can be found.\r\n */\r\n licenseUrl: string;\r\n\r\n /**\r\n * The english name for the commentary.\r\n */\r\n englishName: string;\r\n\r\n /**\r\n * The ISO 639 3-letter language tag that the translation is primarily in.\r\n */\r\n language: string;\r\n\r\n /**\r\n * The direction that the language is written in.\r\n * \"ltr\" indicates that the text is written from the left side of the page to the right.\r\n * \"rtl\" indicates that the text is written from the right side of the page to the left.\r\n */\r\n textDirection: 'ltr' | 'rtl';\r\n}\r\n\r\n/**\r\n * Defines an interface that contains information about a book.\r\n */\r\nexport interface TranslationBook {\r\n /**\r\n * The ID of the book. Should match the USFM book ID.\r\n */\r\n id: string;\r\n\r\n /**\r\n * The name that the translation provided for the book.\r\n */\r\n name: string;\r\n\r\n /**\r\n * The common name for the book.\r\n */\r\n commonName: string;\r\n\r\n /**\r\n * The title of the book.\r\n * This is usually a more descriptive version of the book name.\r\n * If not available, then one was not provided by the translation.\r\n */\r\n title: string | null;\r\n\r\n /**\r\n * The numerical order of the book in the translation.\r\n */\r\n order: number;\r\n}\r\n\r\n/**\r\n * Defines an interface that contains information about a book in a commentary.\r\n */\r\nexport interface CommentaryBook {\r\n /**\r\n * The ID of the book. Should match the USFM book ID.\r\n */\r\n id: string;\r\n\r\n /**\r\n * The name that the commentary provided for the book.\r\n */\r\n name: string;\r\n\r\n /**\r\n * The common name for the book.\r\n */\r\n commonName: string;\r\n\r\n /**\r\n * The commentary's introduction for the book.\r\n */\r\n introduction?: string;\r\n\r\n /**\r\n * The order of the book in the Bible.\r\n */\r\n order: number;\r\n}\r\n\r\n/**\r\n * Defines an interface that contains information about a book chapter.\r\n */\r\nexport interface TranslationBookChapter {\r\n /**\r\n * The information for the chapter.\r\n */\r\n chapter: ChapterData;\r\n\r\n /**\r\n * The links to different audio versions for the chapter.\r\n */\r\n thisChapterAudioLinks: TranslationBookChapterAudioLinks;\r\n}\r\n\r\n/**\r\n * Defines an interface that contains information about a book chapter in a commentary.\r\n */\r\nexport interface CommentaryBookChapter {\r\n /**\r\n * The information for the chapter.\r\n */\r\n chapter: CommentaryChapterData;\r\n}\r\n\r\n/**\r\n * Defines an interface that contains the audio links for a book chapter.\r\n */\r\nexport interface TranslationBookChapterAudioLinks {\r\n /**\r\n * The reader for the chapter and the URL link to the audio file.\r\n */\r\n [reader: string]: string;\r\n}\r\n\r\n/**\r\n * Defines an interface that represents data in a chapter.\r\n */\r\nexport interface ChapterData {\r\n /**\r\n * The number of the chapter.\r\n */\r\n number: number;\r\n\r\n /**\r\n * The content of the chapter.\r\n */\r\n content: ChapterContent[];\r\n\r\n /**\r\n * The list of footnotes for the chapter.\r\n */\r\n footnotes: ChapterFootnote[];\r\n}\r\n\r\n/**\r\n * Defines an interface that represents data in a chapter in a commentary.\r\n */\r\nexport interface CommentaryChapterData {\r\n /**\r\n * The number of the chapter.\r\n */\r\n number: number;\r\n\r\n /**\r\n * The introduction that the commentary provided to the chapter.\r\n * Not all commentaries provide an introduction to a chapter.\r\n */\r\n introduction?: string;\r\n\r\n /**\r\n * The content of the chapter.\r\n */\r\n content: ChapterVerse[];\r\n}\r\n\r\n/**\r\n * A union type that represents a single piece of chapter content.\r\n * A piece of chapter content can be one of the following things:\r\n * - A heading.\r\n * - A line break.\r\n * - A verse.\r\n * - A Hebrew Subtitle.\r\n */\r\nexport type ChapterContent =\r\n | ChapterHeading\r\n | ChapterLineBreak\r\n | ChapterVerse\r\n | ChapterHebrewSubtitle;\r\n\r\n/**\r\n * A heading in a chapter.\r\n */\r\nexport interface ChapterHeading {\r\n /**\r\n * Indicates that the content represents a heading.\r\n */\r\n type: 'heading';\r\n\r\n /**\r\n * The content for the heading.\r\n * If multiple strings are included in the array, they should be concatenated with a space.\r\n */\r\n content: string[];\r\n}\r\n\r\n/**\r\n * A line break in a chapter.\r\n */\r\nexport interface ChapterLineBreak {\r\n /**\r\n * Indicates that the content represents a line break.\r\n */\r\n type: 'line_break';\r\n}\r\n\r\n/**\r\n * A Hebrew Subtitle in a chapter.\r\n * These are often used included as informational content that appeared in the original manuscripts.\r\n * For example, Psalms 49 has the Hebrew Subtitle \"To the choirmaster. A Psalm of the Sons of Korah.\"\r\n */\r\nexport interface ChapterHebrewSubtitle {\r\n /**\r\n * Indicates that the content represents a Hebrew Subtitle.\r\n */\r\n type: 'hebrew_subtitle';\r\n\r\n /**\r\n * The list of content that is contained in the subtitle.\r\n * Each element in the list could be a string, formatted text, or a footnote reference.\r\n */\r\n content: (string | FormattedText | VerseFootnoteReference)[];\r\n}\r\n\r\n/**\r\n * A verse in a chapter.\r\n */\r\nexport interface ChapterVerse {\r\n /**\r\n * Indicates that the content is a verse.\r\n */\r\n type: 'verse';\r\n\r\n /**\r\n * The number of the verse.\r\n */\r\n number: number;\r\n\r\n /**\r\n * The list of content for the verse.\r\n * Each element in the list could be a string, formatted text, or a footnote reference.\r\n */\r\n content: (\r\n | string\r\n | FormattedText\r\n | InlineHeading\r\n | InlineLineBreak\r\n | VerseFootnoteReference\r\n )[];\r\n}\r\n\r\n/**\r\n * Formatted text. That is, text that is formated in a particular manner.\r\n */\r\nexport interface FormattedText {\r\n /**\r\n * The text that is formatted.\r\n */\r\n text: string;\r\n\r\n /**\r\n * Whether the text represents a poem.\r\n * The number indicates the level of indent.\r\n *\r\n * Common in Psalms.\r\n */\r\n poem?: number;\r\n\r\n /**\r\n * Whether the text represents the Words of Jesus.\r\n */\r\n wordsOfJesus?: boolean;\r\n}\r\n\r\n/**\r\n * Defines an interface that represents a heading that is embedded in a verse.\r\n */\r\nexport interface InlineHeading {\r\n /**\r\n * The text of the heading.\r\n */\r\n heading: string;\r\n}\r\n\r\n/**\r\n * Defines an interface that represents a line break that is embedded in a verse.\r\n */\r\nexport interface InlineLineBreak {\r\n lineBreak: true;\r\n}\r\n\r\n/**\r\n * A footnote reference in a verse or a Hebrew Subtitle.\r\n */\r\nexport interface VerseFootnoteReference {\r\n /**\r\n * The ID of the note.\r\n */\r\n noteId: number;\r\n}\r\n\r\n/**\r\n * Information about a footnote.\r\n */\r\nexport interface ChapterFootnote {\r\n /**\r\n * The ID of the note that is referenced.\r\n */\r\n noteId: number;\r\n\r\n /**\r\n * The text of the footnote.\r\n */\r\n text: string;\r\n\r\n /**\r\n * The verse reference for the footnote.\r\n */\r\n reference?: {\r\n chapter: number;\r\n verse: number;\r\n };\r\n\r\n /**\r\n * The caller that should be used for the footnote.\r\n * For footnotes, a \"caller\" is the character that is used in the text to reference to footnote.\r\n *\r\n * For example, in the text:\r\n * Hello (a) World\r\n *\r\n * ----\r\n * (a) This is a footnote.\r\n *\r\n * The \"(a)\" is the caller.\r\n *\r\n * If \"+\", then the caller should be autogenerated.\r\n * If null, then the caller should be empty.\r\n * If a string, then the caller should be that string.\r\n */\r\n caller: '+' | string | null;\r\n}\r\n"],
4
+ "sourcesContent": ["import { VerseRef } from '../utils.js';\n\n/**\n * Defines an interface that contains information about a input file.\n */\nexport type InputFile = InputTranslationFile | InputCommentaryFile;\n\nexport interface InputFileBase {\n name?: string;\n content: string;\n sha256?: string;\n}\n\nexport type InputFileMetadata =\n | InputTranslationMetadata\n | InputCommentaryMetadata;\n\nexport interface InputTranslationFile extends InputFileBase {\n fileType: 'usfm' | 'usx' | 'json';\n metadata: InputTranslationMetadata;\n}\n\nexport interface InputCommentaryFile extends InputFileBase {\n fileType: 'commentary/csv' | 'commentary/tyndale-xml';\n metadata: InputCommentaryMetadata;\n}\n\nexport type OutputFileContent = object | ReadableStream;\n\n/**\n * Defines an interface that contains information about a output file.\n */\nexport interface OutputFile {\n /**\n * The path that the file should be stored at.\n */\n path: string;\n\n /**\n * The content of the file.\n */\n content: OutputFileContent | (() => Promise<OutputFileContent>);\n\n /**\n * Whether the file can be merged with files of the same name but from other datasets.\n */\n mergable?: boolean;\n}\n\nexport interface MetadataBase {\n /**\n * The name of the translation.\n */\n name: string;\n\n /**\n * The english name of the translation.\n */\n englishName: string;\n\n /**\n * The website for the translation.\n */\n website: string;\n\n /**\n * The URL that the license for the translation can be found.\n */\n licenseUrl: string;\n\n /**\n * The ISO 639 letter language tag that the translation is primarily in.\n */\n language: string;\n\n /**\n * The direction that the text is written in.\n */\n direction: 'ltr' | 'rtl';\n}\n\n/**\n * The metadata for a translation that is input into the generator.\n */\nexport interface InputTranslationMetadata extends MetadataBase {\n /**\n * The ID of the translation.\n */\n id: string;\n\n /**\n * The short name for the translation.\n */\n shortName: string;\n}\n\n/**\n * The metadata for a translation that is input into the generator.\n */\nexport interface InputCommentaryMetadata extends MetadataBase {\n /**\n * The ID of the commentary.\n */\n id: string;\n}\n\n/**\n * Defines an interface that contains information about a translation.\n */\nexport interface Translation {\n /**\n * The ID of the translation.\n */\n id: string;\n\n /**\n * The name of the translation.\n */\n name: string;\n\n /**\n * The website for the translation.\n */\n website: string;\n\n /**\n * The URL that the license for the translation can be found.\n */\n licenseUrl: string;\n\n /**\n * The API-added notes for the license.\n */\n licenseNotes?: string | null;\n\n /**\n * The short name for the translation.\n */\n shortName?: string;\n\n /**\n * The English name for the translation.\n */\n englishName: string;\n\n /**\n * The ISO 639 3-letter language tag that the translation is primarily in.\n */\n language: string;\n\n /**\n * The direction that the language is written in.\n * \"ltr\" indicates that the text is written from the left side of the page to the right.\n * \"rtl\" indicates that the text is written from the right side of the page to the left.\n */\n textDirection: 'ltr' | 'rtl';\n}\n\n/**\n * Defines an interface that contains information about a commentary.\n */\nexport interface Commentary {\n /**\n * The ID of the commentary.\n */\n id: string;\n\n /**\n * The name of the commentary.\n */\n name: string;\n\n /**\n * The website for the commentary.\n */\n website: string;\n\n /**\n * The URL that the license for the commentary can be found.\n */\n licenseUrl: string;\n\n /**\n * The API-added notes for the license.\n */\n licenseNotes?: string | null;\n\n /**\n * The english name for the commentary.\n */\n englishName: string;\n\n /**\n * The ISO 639 3-letter language tag that the translation is primarily in.\n */\n language: string;\n\n /**\n * The direction that the language is written in.\n * \"ltr\" indicates that the text is written from the left side of the page to the right.\n * \"rtl\" indicates that the text is written from the right side of the page to the left.\n */\n textDirection: 'ltr' | 'rtl';\n}\n\n/**\n * Defines an interface that contains information about a book.\n */\nexport interface TranslationBook {\n /**\n * The ID of the book. Should match the USFM book ID.\n */\n id: string;\n\n /**\n * The name that the translation provided for the book.\n */\n name: string;\n\n /**\n * The common name for the book.\n */\n commonName: string;\n\n /**\n * The title of the book.\n * This is usually a more descriptive version of the book name.\n * If not available, then one was not provided by the translation.\n */\n title: string | null;\n\n /**\n * The numerical order of the book in the translation.\n */\n order: number;\n}\n\n/**\n * Defines an interface that contains information about a book in a commentary.\n */\nexport interface CommentaryBook {\n /**\n * The ID of the book. Should match the USFM book ID.\n */\n id: string;\n\n /**\n * The name that the commentary provided for the book.\n */\n name: string;\n\n /**\n * The common name for the book.\n */\n commonName: string;\n\n /**\n * The commentary's introduction for the book.\n */\n introduction?: string;\n\n /**\n * The summary of the commentary's introduction for the book.\n */\n introductionSummary?: string;\n\n /**\n * The order of the book in the Bible.\n */\n order: number;\n}\n\n/**\n * Defines an interface that contains information about a profile in a commentary.\n */\nexport interface CommentaryProfile {\n /**\n * The ID of the profile.\n */\n id: string;\n\n /**\n * The subject of the profile.\n */\n subject: string;\n\n /**\n * The Bible reference that the profile is associated with.\n */\n reference: VerseRef | null;\n}\n\n/**\n * Defines an interface that contains information about a book chapter.\n */\nexport interface TranslationBookChapter {\n /**\n * The information for the chapter.\n */\n chapter: ChapterData;\n\n /**\n * The links to different audio versions for the chapter.\n */\n thisChapterAudioLinks: TranslationBookChapterAudioLinks;\n}\n\n/**\n * Defines an interface that contains information about a book chapter in a commentary.\n */\nexport interface CommentaryBookChapter {\n /**\n * The information for the chapter.\n */\n chapter: CommentaryChapterData;\n}\n\n/**\n * Defines an interface that contains the audio links for a book chapter.\n */\nexport interface TranslationBookChapterAudioLinks {\n /**\n * The reader for the chapter and the URL link to the audio file.\n */\n [reader: string]: string;\n}\n\n/**\n * Defines an interface that represents data in a chapter.\n */\nexport interface ChapterData {\n /**\n * The number of the chapter.\n */\n number: number;\n\n /**\n * The content of the chapter.\n */\n content: ChapterContent[];\n\n /**\n * The list of footnotes for the chapter.\n */\n footnotes: ChapterFootnote[];\n}\n\n/**\n * Defines an interface that represents data in a chapter in a commentary.\n */\nexport interface CommentaryChapterData {\n /**\n * The number of the chapter.\n */\n number: number;\n\n /**\n * The introduction that the commentary provided to the chapter.\n * Not all commentaries provide an introduction to a chapter.\n */\n introduction?: string;\n\n /**\n * The content of the chapter.\n */\n content: ChapterVerse[];\n}\n\n/**\n * A union type that represents a single piece of chapter content.\n * A piece of chapter content can be one of the following things:\n * - A heading.\n * - A line break.\n * - A verse.\n * - A Hebrew Subtitle.\n */\nexport type ChapterContent =\n | ChapterHeading\n | ChapterLineBreak\n | ChapterVerse\n | ChapterHebrewSubtitle;\n\n/**\n * A heading in a chapter.\n */\nexport interface ChapterHeading {\n /**\n * Indicates that the content represents a heading.\n */\n type: 'heading';\n\n /**\n * The content for the heading.\n * If multiple strings are included in the array, they should be concatenated with a space.\n */\n content: string[];\n}\n\n/**\n * A line break in a chapter.\n */\nexport interface ChapterLineBreak {\n /**\n * Indicates that the content represents a line break.\n */\n type: 'line_break';\n}\n\n/**\n * A Hebrew Subtitle in a chapter.\n * These are often used included as informational content that appeared in the original manuscripts.\n * For example, Psalms 49 has the Hebrew Subtitle \"To the choirmaster. A Psalm of the Sons of Korah.\"\n */\nexport interface ChapterHebrewSubtitle {\n /**\n * Indicates that the content represents a Hebrew Subtitle.\n */\n type: 'hebrew_subtitle';\n\n /**\n * The list of content that is contained in the subtitle.\n * Each element in the list could be a string, formatted text, or a footnote reference.\n */\n content: (string | FormattedText | VerseFootnoteReference)[];\n}\n\n/**\n * A verse in a chapter.\n */\nexport interface ChapterVerse {\n /**\n * Indicates that the content is a verse.\n */\n type: 'verse';\n\n /**\n * The number of the verse.\n */\n number: number;\n\n /**\n * The list of content for the verse.\n * Each element in the list could be a string, formatted text, or a footnote reference.\n */\n content: (\n | string\n | FormattedText\n | InlineHeading\n | InlineLineBreak\n | VerseFootnoteReference\n )[];\n}\n\n/**\n * Formatted text. That is, text that is formated in a particular manner.\n */\nexport interface FormattedText {\n /**\n * The text that is formatted.\n */\n text: string;\n\n /**\n * Whether the text represents a poem.\n * The number indicates the level of indent.\n *\n * Common in Psalms.\n */\n poem?: number;\n\n /**\n * Whether the text represents the Words of Jesus.\n */\n wordsOfJesus?: boolean;\n}\n\n/**\n * Defines an interface that represents a heading that is embedded in a verse.\n */\nexport interface InlineHeading {\n /**\n * The text of the heading.\n */\n heading: string;\n}\n\n/**\n * Defines an interface that represents a line break that is embedded in a verse.\n */\nexport interface InlineLineBreak {\n lineBreak: true;\n}\n\n/**\n * A footnote reference in a verse or a Hebrew Subtitle.\n */\nexport interface VerseFootnoteReference {\n /**\n * The ID of the note.\n */\n noteId: number;\n}\n\n/**\n * Information about a footnote.\n */\nexport interface ChapterFootnote {\n /**\n * The ID of the note that is referenced.\n */\n noteId: number;\n\n /**\n * The text of the footnote.\n */\n text: string;\n\n /**\n * The verse reference for the footnote.\n */\n reference?: {\n chapter: number;\n verse: number;\n };\n\n /**\n * The caller that should be used for the footnote.\n * For footnotes, a \"caller\" is the character that is used in the text to reference to footnote.\n *\n * For example, in the text:\n * Hello (a) World\n *\n * ----\n * (a) This is a footnote.\n *\n * The \"(a)\" is the caller.\n *\n * If \"+\", then the caller should be autogenerated.\n * If null, then the caller should be empty.\n * If a string, then the caller should be that string.\n */\n caller: '+' | string | null;\n}\n"],
5
5
  "mappings": ";;;;;;;;;;;;;;AAAA;AAAA;",
6
6
  "names": []
7
7
  }
@@ -28,7 +28,10 @@ var import_lodash = require("lodash");
28
28
  var import_audio = require("./audio.js");
29
29
  var import_codex_parser = require("../parser/codex-parser.js");
30
30
  var import_commentary_csv_parser = require("../parser/commentary-csv-parser.js");
31
- function generateDataset(files, parser = new globalThis.DOMParser()) {
31
+ var import_tyndale_xml_parser = require("../parser/tyndale-xml-parser.js");
32
+ var import_log = require("../log.js");
33
+ function generateDataset(files, parser = new globalThis.DOMParser(), bookMap) {
34
+ const logger = (0, import_log.getLogger)();
32
35
  let output = {
33
36
  translations: [],
34
37
  commentaries: []
@@ -37,6 +40,7 @@ function generateDataset(files, parser = new globalThis.DOMParser()) {
37
40
  let usxParser = new import_usx_parser.USXParser(parser);
38
41
  let codexParser = new import_codex_parser.CodexParser();
39
42
  let csvCommentaryParser = new import_commentary_csv_parser.CommentaryCsvParser();
43
+ let tyndaleXmlParser = new import_tyndale_xml_parser.TyndaleXmlParser(parser);
40
44
  let parsedTranslations = /* @__PURE__ */ new Map();
41
45
  let parsedCommentaries = /* @__PURE__ */ new Map();
42
46
  const unknownLanguages = /* @__PURE__ */ new Set();
@@ -51,8 +55,10 @@ function generateDataset(files, parser = new globalThis.DOMParser()) {
51
55
  parser2 = codexParser;
52
56
  } else if (file.fileType === "commentary/csv") {
53
57
  parser2 = csvCommentaryParser;
58
+ } else if (file.fileType === "commentary/tyndale-xml") {
59
+ parser2 = tyndaleXmlParser;
54
60
  } else {
55
- console.warn(
61
+ logger.warn(
56
62
  "[generate] File does not have a valid type!",
57
63
  file.name
58
64
  );
@@ -65,7 +71,7 @@ function generateDataset(files, parser = new globalThis.DOMParser()) {
65
71
  addCommentaryTree(file, parsed);
66
72
  }
67
73
  } catch (err) {
68
- console.error(
74
+ logger.error(
69
75
  `[generate] Error occurred while parsing ${file.name}`,
70
76
  err
71
77
  );
@@ -74,7 +80,7 @@ function generateDataset(files, parser = new globalThis.DOMParser()) {
74
80
  function addTranslationTree(file, parsed) {
75
81
  const id = parsed.id;
76
82
  if (!id) {
77
- console.warn(
83
+ logger.warn(
78
84
  "[generate] File does not have a valid book ID!",
79
85
  file.name,
80
86
  id
@@ -83,28 +89,10 @@ function generateDataset(files, parser = new globalThis.DOMParser()) {
83
89
  }
84
90
  const order = import_book_order.bookOrderMap.get(id);
85
91
  if (typeof order !== "number") {
86
- console.warn("[generate] Book does not have an order!", id);
92
+ logger.warn("[generate] Book does not have an order!", id);
87
93
  return;
88
94
  }
89
- const bookMap = import_book_order.bookIdMap.get(file.metadata.language);
90
- if (!bookMap) {
91
- if (!unknownLanguages.has(file.metadata.language)) {
92
- console.warn(
93
- "[generate] File does not have a known language!",
94
- file.name,
95
- file.metadata.language
96
- );
97
- unknownLanguages.add(file.metadata.language);
98
- }
99
- }
100
- const bookName = bookMap?.get(id);
101
- if (!!bookMap && !bookName) {
102
- console.warn(
103
- "[generate] Book name not found for ID!",
104
- file.name,
105
- id
106
- );
107
- }
95
+ const bookName = getBookNames(file, file.metadata, id);
108
96
  let translation = parsedTranslations.get(file.metadata.id);
109
97
  if (!translation) {
110
98
  translation = {
@@ -115,16 +103,12 @@ function generateDataset(files, parser = new globalThis.DOMParser()) {
115
103
  output.translations.push(translation);
116
104
  parsedTranslations.set(file.metadata.id, translation);
117
105
  }
118
- const name = parsed.header ?? bookName?.commonName ?? parsed.title;
106
+ const name = parsed.header ?? bookName?.bookName?.commonName ?? parsed.title;
119
107
  if (!name) {
120
- console.warn(
121
- "[generate] Book does not have a name!",
122
- file.name,
123
- id
124
- );
108
+ logger.warn("[generate] Book does not have a name!", file.name, id);
125
109
  return;
126
110
  }
127
- const commonName = bookName?.commonName ?? parsed.header ?? parsed.title ?? id;
111
+ const commonName = bookName?.bookName?.commonName ?? parsed.header ?? parsed.title ?? id;
128
112
  const book = {
129
113
  id,
130
114
  name,
@@ -159,15 +143,16 @@ function generateDataset(files, parser = new globalThis.DOMParser()) {
159
143
  commentary = {
160
144
  ...(0, import_lodash.omit)(file.metadata, "direction"),
161
145
  textDirection: file.metadata.direction,
162
- books: []
146
+ books: [],
147
+ profiles: []
163
148
  };
164
149
  output.commentaries.push(commentary);
165
150
  parsedCommentaries.set(file.metadata.id, commentary);
166
151
  }
167
152
  for (let parsedBook of parsed.books) {
168
153
  let book = commentary.books.find((b) => b.id === parsedBook.book);
169
- if (book && book.introduction) {
170
- console.warn(
154
+ if (book && book.introduction && parsedBook.introduction) {
155
+ logger.warn(
171
156
  "[generate] Book already exists in commentary!",
172
157
  file.name,
173
158
  parsedBook.book
@@ -187,6 +172,9 @@ function generateDataset(files, parser = new globalThis.DOMParser()) {
187
172
  if (parsedBook.introduction) {
188
173
  book.introduction = parsedBook.introduction;
189
174
  }
175
+ if (parsedBook.introductionSummary && !book.introductionSummary) {
176
+ book.introductionSummary = parsedBook.introductionSummary;
177
+ }
190
178
  for (let chapter of parsedBook.chapters) {
191
179
  let data = {
192
180
  number: chapter.number,
@@ -202,23 +190,52 @@ function generateDataset(files, parser = new globalThis.DOMParser()) {
202
190
  book.chapters = (0, import_lodash.sortBy)(book.chapters, (c) => c.chapter.number);
203
191
  commentary.books.push(book);
204
192
  }
193
+ if (parsed.profiles) {
194
+ for (let profile of parsed.profiles) {
195
+ const existing = commentary.profiles.find(
196
+ (p) => p.id === profile.id
197
+ );
198
+ if (existing) {
199
+ logger.warn(
200
+ "[generate] Profile already exists in commentary!",
201
+ file.name,
202
+ profile.id
203
+ );
204
+ continue;
205
+ }
206
+ const datasetProfile = {
207
+ id: profile.id,
208
+ subject: profile.subject,
209
+ reference: profile.reference,
210
+ content: profile.content
211
+ };
212
+ commentary.profiles.push(datasetProfile);
213
+ }
214
+ }
205
215
  commentary.books = (0, import_lodash.sortBy)(commentary.books, (b) => b.order);
216
+ commentary.profiles = (0, import_lodash.sortBy)(commentary.profiles, (p) => p.id);
206
217
  }
207
218
  function getBookNames(file, metadata, id) {
208
- const bookMap = import_book_order.bookIdMap.get(metadata.language);
209
219
  if (!bookMap) {
210
- if (!unknownLanguages.has(metadata.language)) {
211
- console.warn(
212
- "[generate] File does not have a known language!",
213
- file.name,
214
- metadata.language
220
+ bookMap = import_book_order.bookIdMap.get(metadata.language);
221
+ if (!bookMap) {
222
+ if (!unknownLanguages.has(metadata.language)) {
223
+ logger.warn(
224
+ "[generate] File does not have a known language!",
225
+ file.name,
226
+ metadata.language
227
+ );
228
+ unknownLanguages.add(metadata.language);
229
+ }
230
+ logger.warn(
231
+ "[generate] Using English book map for unknown language! This might result in outputting english book names."
215
232
  );
216
- unknownLanguages.add(metadata.language);
233
+ bookMap = import_book_order.bookIdMap.get("en");
217
234
  }
218
235
  }
219
236
  const bookName = bookMap?.get(id);
220
237
  if (!!bookMap && !bookName) {
221
- console.warn(
238
+ logger.warn(
222
239
  "[generate] Book name not found for ID!",
223
240
  file.name,
224
241
  id