@helloao/tools 0.0.9 → 0.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/generation/api.cjs +126 -0
- package/dist/cjs/generation/api.cjs.map +2 -2
- package/dist/cjs/generation/common-types.cjs.map +1 -1
- package/dist/cjs/generation/dataset.cjs +159 -79
- package/dist/cjs/generation/dataset.cjs.map +2 -2
- package/dist/cjs/parser/codex-parser.cjs +77 -66
- package/dist/cjs/parser/codex-parser.cjs.map +2 -2
- package/dist/cjs/parser/commentary-csv-parser.cjs +133 -0
- package/dist/cjs/parser/commentary-csv-parser.cjs.map +7 -0
- package/dist/cjs/parser/index.cjs +3 -1
- package/dist/cjs/parser/index.cjs.map +2 -2
- package/dist/cjs/parser/types.cjs.map +1 -1
- package/dist/cjs/parser/usx-parser.cjs +13 -1
- package/dist/cjs/parser/usx-parser.cjs.map +2 -2
- package/dist/cjs/utils.cjs +155 -3
- package/dist/cjs/utils.cjs.map +3 -3
- package/dist/esm/generation/api.js +122 -0
- package/dist/esm/generation/api.js.map +2 -2
- package/dist/esm/generation/dataset.js +159 -79
- package/dist/esm/generation/dataset.js.map +2 -2
- package/dist/esm/parser/codex-parser.js +71 -64
- package/dist/esm/parser/codex-parser.js.map +2 -2
- package/dist/esm/parser/commentary-csv-parser.js +107 -0
- package/dist/esm/parser/commentary-csv-parser.js.map +7 -0
- package/dist/esm/parser/index.js +1 -0
- package/dist/esm/parser/index.js.map +2 -2
- package/dist/esm/parser/usx-parser.js +13 -1
- package/dist/esm/parser/usx-parser.js.map +2 -2
- package/dist/esm/utils.js +153 -3
- package/dist/esm/utils.js.map +3 -3
- package/dist/types/generation/api.d.ts +147 -1
- package/dist/types/generation/common-types.d.ts +121 -24
- package/dist/types/generation/dataset.d.ts +23 -1
- package/dist/types/parser/codex-parser.d.ts +50 -7
- package/dist/types/parser/commentary-csv-parser.d.ts +12 -0
- package/dist/types/parser/index.d.ts +1 -0
- package/dist/types/parser/types.d.ts +28 -1
- package/dist/types/parser/usx-parser.d.ts +1 -1
- package/dist/types/utils.d.ts +6 -0
- package/package.json +3 -2
|
@@ -20,12 +20,14 @@ var api_exports = {};
|
|
|
20
20
|
__export(api_exports, {
|
|
21
21
|
bookChapterApiLink: () => bookChapterApiLink,
|
|
22
22
|
bookChapterAudioApiLink: () => bookChapterAudioApiLink,
|
|
23
|
+
bookCommentaryChapterApiLink: () => bookCommentaryChapterApiLink,
|
|
23
24
|
downloadedFile: () => downloadedFile,
|
|
24
25
|
generateApiForDataset: () => generateApiForDataset,
|
|
25
26
|
generateFilesForApi: () => generateFilesForApi,
|
|
26
27
|
generateOutputFilesFromDatasets: () => generateOutputFilesFromDatasets,
|
|
27
28
|
jsonFile: () => jsonFile,
|
|
28
29
|
listOfBooksApiLink: () => listOfBooksApiLink,
|
|
30
|
+
listOfCommentaryBooksApiLink: () => listOfCommentaryBooksApiLink,
|
|
29
31
|
replaceSpacesWithUnderscores: () => replaceSpacesWithUnderscores
|
|
30
32
|
});
|
|
31
33
|
module.exports = __toCommonJS(api_exports);
|
|
@@ -39,6 +41,11 @@ function generateApiForDataset(dataset, options = {}) {
|
|
|
39
41
|
translationBooks: [],
|
|
40
42
|
translationBookChapters: [],
|
|
41
43
|
translationBookChapterAudio: [],
|
|
44
|
+
availableCommentaries: {
|
|
45
|
+
commentaries: []
|
|
46
|
+
},
|
|
47
|
+
commentaryBookChapters: [],
|
|
48
|
+
commentaryBooks: [],
|
|
42
49
|
pathPrefix: apiPathPrefix
|
|
43
50
|
};
|
|
44
51
|
const getNativeName = options.getNativeName;
|
|
@@ -159,6 +166,97 @@ function generateApiForDataset(dataset, options = {}) {
|
|
|
159
166
|
api.availableTranslations.translations.push(apiTranslation);
|
|
160
167
|
api.translationBooks.push(translationBooks);
|
|
161
168
|
}
|
|
169
|
+
for (let { books, ...commentary } of dataset.commentaries) {
|
|
170
|
+
const apiCommentary = {
|
|
171
|
+
...commentary,
|
|
172
|
+
availableFormats: ["json"],
|
|
173
|
+
listOfBooksApiLink: listOfCommentaryBooksApiLink(
|
|
174
|
+
commentary.id,
|
|
175
|
+
apiPathPrefix
|
|
176
|
+
),
|
|
177
|
+
numberOfBooks: books.length,
|
|
178
|
+
totalNumberOfChapters: 0,
|
|
179
|
+
totalNumberOfVerses: 0,
|
|
180
|
+
languageName: getNativeName ? getNativeName(commentary.language) ?? void 0 : void 0,
|
|
181
|
+
languageEnglishName: getEnglishName ? getEnglishName(commentary.language) ?? void 0 : void 0
|
|
182
|
+
};
|
|
183
|
+
const commentaryBooks = {
|
|
184
|
+
commentary: apiCommentary,
|
|
185
|
+
books: []
|
|
186
|
+
};
|
|
187
|
+
let commentaryChapters = [];
|
|
188
|
+
for (let { chapters, ...book } of books) {
|
|
189
|
+
const apiBook = {
|
|
190
|
+
...book,
|
|
191
|
+
firstChapterApiLink: bookCommentaryChapterApiLink(
|
|
192
|
+
commentary.id,
|
|
193
|
+
getBookLink(book),
|
|
194
|
+
1,
|
|
195
|
+
"json",
|
|
196
|
+
apiPathPrefix
|
|
197
|
+
),
|
|
198
|
+
lastChapterApiLink: bookCommentaryChapterApiLink(
|
|
199
|
+
commentary.id,
|
|
200
|
+
getBookLink(book),
|
|
201
|
+
chapters.length,
|
|
202
|
+
"json",
|
|
203
|
+
apiPathPrefix
|
|
204
|
+
),
|
|
205
|
+
numberOfChapters: chapters.length,
|
|
206
|
+
totalNumberOfVerses: 0
|
|
207
|
+
};
|
|
208
|
+
for (let { chapter } of chapters) {
|
|
209
|
+
const apiBookChapter = {
|
|
210
|
+
commentary: apiCommentary,
|
|
211
|
+
book: apiBook,
|
|
212
|
+
chapter,
|
|
213
|
+
thisChapterLink: bookCommentaryChapterApiLink(
|
|
214
|
+
commentary.id,
|
|
215
|
+
getBookLink(book),
|
|
216
|
+
chapter.number,
|
|
217
|
+
"json",
|
|
218
|
+
apiPathPrefix
|
|
219
|
+
),
|
|
220
|
+
nextChapterApiLink: null,
|
|
221
|
+
previousChapterApiLink: null,
|
|
222
|
+
numberOfVerses: 0
|
|
223
|
+
};
|
|
224
|
+
for (let c of chapter.content) {
|
|
225
|
+
if (c.type === "verse") {
|
|
226
|
+
apiBookChapter.numberOfVerses++;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
apiBook.totalNumberOfVerses += apiBookChapter.numberOfVerses;
|
|
230
|
+
commentaryChapters.push(apiBookChapter);
|
|
231
|
+
api.commentaryBookChapters.push(apiBookChapter);
|
|
232
|
+
}
|
|
233
|
+
commentaryBooks.books.push(apiBook);
|
|
234
|
+
apiCommentary.totalNumberOfChapters += apiBook.numberOfChapters;
|
|
235
|
+
apiCommentary.totalNumberOfVerses += apiBook.totalNumberOfVerses;
|
|
236
|
+
}
|
|
237
|
+
for (let i = 0; i < commentaryChapters.length; i++) {
|
|
238
|
+
if (i > 0) {
|
|
239
|
+
commentaryChapters[i].previousChapterApiLink = bookCommentaryChapterApiLink(
|
|
240
|
+
commentary.id,
|
|
241
|
+
getBookLink(commentaryChapters[i - 1].book),
|
|
242
|
+
commentaryChapters[i - 1].chapter.number,
|
|
243
|
+
"json",
|
|
244
|
+
apiPathPrefix
|
|
245
|
+
);
|
|
246
|
+
}
|
|
247
|
+
if (i < commentaryChapters.length - 1) {
|
|
248
|
+
commentaryChapters[i].nextChapterApiLink = bookCommentaryChapterApiLink(
|
|
249
|
+
commentary.id,
|
|
250
|
+
getBookLink(commentaryChapters[i + 1].book),
|
|
251
|
+
commentaryChapters[i + 1].chapter.number,
|
|
252
|
+
"json",
|
|
253
|
+
apiPathPrefix
|
|
254
|
+
);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
api.availableCommentaries.commentaries.push(apiCommentary);
|
|
258
|
+
api.commentaryBooks.push(commentaryBooks);
|
|
259
|
+
}
|
|
162
260
|
return api;
|
|
163
261
|
function getBookLink(book) {
|
|
164
262
|
return useCommonName ? book.commonName : book.id;
|
|
@@ -187,6 +285,24 @@ function generateFilesForApi(api) {
|
|
|
187
285
|
for (let audio of api.translationBookChapterAudio) {
|
|
188
286
|
files.push(downloadedFile(audio.link, audio.originalUrl));
|
|
189
287
|
}
|
|
288
|
+
files.push(
|
|
289
|
+
jsonFile(
|
|
290
|
+
`${api.pathPrefix}/api/available_commentaries.json`,
|
|
291
|
+
api.availableCommentaries,
|
|
292
|
+
true
|
|
293
|
+
)
|
|
294
|
+
);
|
|
295
|
+
for (let commentaryBooks of api.commentaryBooks) {
|
|
296
|
+
files.push(
|
|
297
|
+
jsonFile(
|
|
298
|
+
commentaryBooks.commentary.listOfBooksApiLink,
|
|
299
|
+
commentaryBooks
|
|
300
|
+
)
|
|
301
|
+
);
|
|
302
|
+
}
|
|
303
|
+
for (let bookChapter of api.commentaryBookChapters) {
|
|
304
|
+
files.push(jsonFile(bookChapter.thisChapterLink, bookChapter));
|
|
305
|
+
}
|
|
190
306
|
return files;
|
|
191
307
|
}
|
|
192
308
|
async function* generateOutputFilesFromDatasets(datasets, options) {
|
|
@@ -199,11 +315,19 @@ async function* generateOutputFilesFromDatasets(datasets, options) {
|
|
|
199
315
|
function listOfBooksApiLink(translationId, prefix = "") {
|
|
200
316
|
return `${prefix}/api/${translationId}/books.json`;
|
|
201
317
|
}
|
|
318
|
+
function listOfCommentaryBooksApiLink(commentaryId, prefix = "") {
|
|
319
|
+
return `${prefix}/api/c/${commentaryId}/books.json`;
|
|
320
|
+
}
|
|
202
321
|
function bookChapterApiLink(translationId, commonName, chapterNumber, extension, prefix = "") {
|
|
203
322
|
return `${prefix}/api/${translationId}/${replaceSpacesWithUnderscores(
|
|
204
323
|
commonName
|
|
205
324
|
)}/${chapterNumber}.${extension}`;
|
|
206
325
|
}
|
|
326
|
+
function bookCommentaryChapterApiLink(translationId, commonName, chapterNumber, extension, prefix = "") {
|
|
327
|
+
return `${prefix}/api/c/${translationId}/${replaceSpacesWithUnderscores(
|
|
328
|
+
commonName
|
|
329
|
+
)}/${chapterNumber}.${extension}`;
|
|
330
|
+
}
|
|
207
331
|
function bookChapterAudioApiLink(translationId, bookId, chapterNumber, reader, prefix = "") {
|
|
208
332
|
return `${prefix}/api/${translationId}/${replaceSpacesWithUnderscores(
|
|
209
333
|
bookId
|
|
@@ -229,12 +353,14 @@ function replaceSpacesWithUnderscores(str) {
|
|
|
229
353
|
0 && (module.exports = {
|
|
230
354
|
bookChapterApiLink,
|
|
231
355
|
bookChapterAudioApiLink,
|
|
356
|
+
bookCommentaryChapterApiLink,
|
|
232
357
|
downloadedFile,
|
|
233
358
|
generateApiForDataset,
|
|
234
359
|
generateFilesForApi,
|
|
235
360
|
generateOutputFilesFromDatasets,
|
|
236
361
|
jsonFile,
|
|
237
362
|
listOfBooksApiLink,
|
|
363
|
+
listOfCommentaryBooksApiLink,
|
|
238
364
|
replaceSpacesWithUnderscores
|
|
239
365
|
});
|
|
240
366
|
//# 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 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 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 * 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 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 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 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\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 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 return api;\r\n\r\n function getBookLink(book: TranslationBook): 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 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 * 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\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;
|
|
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;A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"],
|
|
4
|
-
"sourcesContent": ["/**\r\n * Defines an interface that contains information about a input file.\r\n */\r\nexport interface InputFile {\r\n name?: string;\r\n metadata: ParseTreeMetadata;\r\n content: string;\r\n sha256?: string;\r\n fileType: 'usfm' | 'usx' | 'json';\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\n/**\r\n * Defines an interface that contains metadata for a parse tree.\r\n */\r\nexport interface ParseTreeMetadata {\r\n /**\r\n * Information about the translation.\r\n */\r\n translation: InputTranslationMetadata;\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 {\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 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 short name for the translation.\r\n */\r\n shortName?: 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 * 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 book.\r\n */\r\nexport interface TranslationBook {\r\n /**\r\n * The ID of the book.\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 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 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 * 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 = ChapterHeading | ChapterLineBreak | ChapterVerse | 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: (string | FormattedText | InlineHeading | InlineLineBreak | VerseFootnoteReference)[];\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}"],
|
|
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"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;;;;AAAA;AAAA;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|