@helloao/tools 0.0.6 → 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 +366 -0
- package/dist/cjs/generation/api.cjs.map +7 -0
- package/dist/cjs/generation/audio.cjs +83 -0
- package/dist/cjs/generation/audio.cjs.map +7 -0
- package/dist/cjs/generation/book-order.cjs +508 -0
- package/dist/cjs/generation/book-order.cjs.map +7 -0
- package/dist/cjs/generation/common-types.cjs +17 -0
- package/dist/cjs/generation/common-types.cjs.map +7 -0
- package/dist/cjs/generation/dataset.cjs +238 -0
- package/dist/cjs/generation/dataset.cjs.map +7 -0
- package/dist/cjs/generation/index.cjs +51 -0
- package/dist/cjs/generation/index.cjs.map +7 -0
- package/dist/cjs/index.cjs +45 -0
- package/dist/cjs/index.cjs.map +7 -0
- package/dist/cjs/parser/codex-parser.cjs +187 -0
- package/dist/cjs/parser/codex-parser.cjs.map +7 -0
- 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 +50 -0
- package/dist/cjs/parser/index.cjs.map +7 -0
- package/dist/cjs/parser/iterators.cjs +204 -0
- package/dist/cjs/parser/iterators.cjs.map +7 -0
- package/dist/cjs/parser/types.cjs +17 -0
- package/dist/cjs/parser/types.cjs.map +7 -0
- package/dist/cjs/parser/usfm-parser.cjs +791 -0
- package/dist/cjs/parser/usfm-parser.cjs.map +7 -0
- package/dist/cjs/parser/usx-parser.cjs +483 -0
- package/dist/cjs/parser/usx-parser.cjs.map +7 -0
- package/dist/cjs/utils.cjs +237 -0
- package/dist/cjs/utils.cjs.map +7 -0
- package/dist/esm/generation/api.js +320 -0
- package/dist/esm/generation/api.js.map +7 -0
- package/dist/esm/generation/audio.js +53 -0
- package/dist/esm/generation/audio.js.map +7 -0
- package/dist/esm/generation/book-order.js +478 -0
- package/dist/esm/generation/book-order.js.map +7 -0
- package/dist/esm/generation/common-types.js +2 -0
- package/dist/esm/generation/common-types.js.map +7 -0
- package/dist/esm/generation/dataset.js +212 -0
- package/dist/esm/generation/dataset.js.map +7 -0
- package/dist/esm/generation/index.js +8 -0
- package/dist/esm/generation/index.js.map +7 -0
- package/dist/esm/index.js +6 -0
- package/dist/esm/index.js.map +7 -0
- package/dist/esm/parser/codex-parser.js +151 -0
- package/dist/esm/parser/codex-parser.js.map +7 -0
- 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 +9 -0
- package/dist/esm/parser/index.js.map +7 -0
- package/dist/esm/parser/iterators.js +152 -0
- package/dist/esm/parser/iterators.js.map +7 -0
- package/dist/esm/parser/types.js +2 -0
- package/dist/esm/parser/types.js.map +7 -0
- package/dist/esm/parser/usfm-parser.js +749 -0
- package/dist/esm/parser/usfm-parser.js.map +7 -0
- package/dist/esm/parser/usx-parser.js +459 -0
- package/dist/esm/parser/usx-parser.js.map +7 -0
- package/dist/esm/utils.js +201 -0
- package/dist/esm/utils.js.map +7 -0
- package/{generation → dist/types/generation}/api.d.ts +148 -2
- package/{generation → dist/types/generation}/audio.d.ts +1 -1
- package/{generation → dist/types/generation}/common-types.d.ts +121 -24
- package/{generation → dist/types/generation}/dataset.d.ts +23 -1
- package/dist/types/generation/index.d.ts +7 -0
- package/dist/types/index.d.ts +5 -0
- package/{parser → dist/types/parser}/codex-parser.d.ts +51 -8
- package/dist/types/parser/commentary-csv-parser.d.ts +12 -0
- package/dist/types/parser/index.d.ts +8 -0
- package/{parser → dist/types/parser}/types.d.ts +28 -1
- package/{parser → dist/types/parser}/usfm-parser.d.ts +1 -1
- package/{parser → dist/types/parser}/usx-parser.d.ts +3 -3
- package/{utils.d.ts → dist/types/utils.d.ts} +6 -0
- package/package.json +27 -4
- package/generation/api.js +0 -187
- package/generation/api.spec.d.ts +0 -2
- package/generation/api.spec.js +0 -620
- package/generation/audio.js +0 -60
- package/generation/audio.spec.d.ts +0 -2
- package/generation/audio.spec.js +0 -36
- package/generation/book-order.js +0 -494
- package/generation/book-order.spec.d.ts +0 -2
- package/generation/book-order.spec.js +0 -8
- package/generation/common-types.js +0 -2
- package/generation/dataset.js +0 -106
- package/generation/index.d.ts +0 -7
- package/generation/index.js +0 -38
- package/index.d.ts +0 -5
- package/index.js +0 -32
- package/parser/codex-parser.js +0 -160
- package/parser/codex-parser.spec.d.ts +0 -2
- package/parser/codex-parser.spec.js +0 -645
- package/parser/index.d.ts +0 -7
- package/parser/index.js +0 -35
- package/parser/iterators.js +0 -222
- package/parser/iterators.spec.d.ts +0 -2
- package/parser/iterators.spec.js +0 -174
- package/parser/types.js +0 -2
- package/parser/usfm-parser.js +0 -840
- package/parser/usfm-parser.spec.d.ts +0 -2
- package/parser/usfm-parser.spec.js +0 -1593
- package/parser/usx-parser.js +0 -486
- package/parser/usx-parser.spec.d.ts +0 -2
- package/parser/usx-parser.spec.js +0 -1260
- package/utils.js +0 -73
- package/utils.spec.d.ts +0 -2
- package/utils.spec.js +0 -42
- /package/{generation → dist/types/generation}/book-order.d.ts +0 -0
- /package/{parser → dist/types/parser}/iterators.d.ts +0 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../parser/usx-parser.ts"],
|
|
4
|
+
"sourcesContent": ["import {\n Chapter,\n ChapterContent,\n Footnote,\n FootnoteReference,\n ParseTree,\n Verse,\n Text,\n HebrewSubtitle,\n InlineLineBreak,\n InlineHeading,\n} from './types.js';\nimport {\n iterateAll,\n children,\n RewindableIterator,\n isParent,\n} from './iterators.js';\n\nenum NodeType {\n Text = 3,\n}\n\n/**\n * The version of the parser.\n * Used to determine whether input files need to be re-parsed.\n */\nexport const PARSER_VERSION = '2';\n\n/**\n * Defines a class that is able to parse USX content.\n */\nexport class USXParser {\n private _domParser: DOMParser;\n private _noteCounter: number = 0;\n\n constructor(domParser: DOMParser) {\n this._domParser = domParser;\n }\n\n /**\n * Parses the specified USX content.\n *\n * @param usx The USX content to parse.\n * @returns The parse tree that was generated.\n */\n public parse(usx: string): ParseTree {\n const parser = this._domParser;\n const doc = parser.parseFromString(usx, 'application/xml');\n const usxElement = doc.documentElement;\n\n let root: ParseTree = {\n type: 'root',\n content: [],\n };\n\n const bookElement = usxElement.querySelector('book[code]');\n\n if (!bookElement) {\n throw new Error('The USX content does not contain a book element.');\n }\n\n const bookCode = bookElement.getAttribute('code') || '';\n\n if (!bookCode) {\n throw new Error(\n 'The book element does not contain a code attribute.'\n );\n }\n\n root.id = bookCode;\n\n const header = usxElement.querySelector('para[style=\"h\"]');\n if (header) {\n root.header = header.textContent || '';\n }\n\n const titles = usxElement.querySelectorAll(\n 'para[style=\"mt1\"], para[style=\"mt2\"], para[style=\"mt3\"]'\n );\n // const title2 = usxElement.querySelector('para[style=\"mt2\"]');\n // const title3 = usxElement.querySelector('para[style=\"mt3\"]');\n\n if (titles.length > 0) {\n root.title = [...titles]\n .map((t) => t.textContent)\n .filter((t) => t)\n .join(' ');\n }\n\n for (let content of this.iterateRootContent(usxElement)) {\n root.content.push(content);\n }\n\n return root;\n }\n\n *iterateRootContent(\n usxElement: Element\n ): Generator<ParseTree['content'][0]> {\n const iterator = iterateAll(usxElement);\n while (true) {\n const { done, value: child } = iterator.next();\n if (done) {\n break;\n }\n\n if (!(child instanceof Element)) {\n continue;\n }\n\n if (child.nodeName === 'chapter') {\n if (child.hasAttribute('eid')) {\n continue;\n }\n\n const chapter: Chapter = {\n type: 'chapter',\n number: parseInt(child.getAttribute('number') || '0', 10),\n content: [],\n footnotes: [],\n };\n\n for (let content of this.iterateChapterContent(\n chapter,\n iterator\n )) {\n chapter.content.push(content);\n }\n\n yield chapter;\n } else if (child.nodeName === 'para') {\n const style = child.getAttribute('style');\n if (\n style === 's1' ||\n style === 's2' ||\n style === 's3' ||\n style === 's4'\n ) {\n yield {\n type: 'heading',\n content: child.textContent ? [child.textContent] : [],\n };\n }\n }\n }\n }\n\n *iterateChapterContent(\n chapter: Chapter,\n nodes: RewindableIterator<Node>\n ): IterableIterator<ChapterContent> {\n while (true) {\n const { done, value: element } = nodes.next();\n if (done) {\n break;\n }\n\n if (!(element instanceof Element)) {\n continue;\n }\n\n if (element.nodeName === 'chapter') {\n break;\n } else if (element.nodeName === 'para') {\n const style = element.getAttribute('style');\n if (\n style === 's1' ||\n style === 's2' ||\n style === 's3' ||\n style === 's4'\n ) {\n yield {\n type: 'heading',\n content: element.textContent\n ? [element.textContent]\n : [],\n };\n } else if (style === 'b') {\n yield {\n type: 'line_break',\n };\n } else if (style === 'd') {\n yield* this.parseHebrewSubtitle(element, chapter, nodes);\n }\n } else if (element.nodeName === 'verse') {\n if (element.hasAttribute('eid')) {\n continue;\n }\n\n yield this.parseVerse(element, chapter, nodes);\n }\n }\n }\n\n *iterateVerseContent(\n chapter: Chapter,\n verse: Verse,\n nodes: RewindableIterator<Node>\n ): IterableIterator<string | FootnoteReference | Text | InlineLineBreak> {\n let lastParent: Element | null = null;\n while (true) {\n const { done, value: node } = nodes.next();\n if (done) {\n break;\n }\n\n if (node.nodeName === 'verse') {\n break;\n }\n\n const parent = node.parentElement!;\n let poem: number | null = null;\n let descriptive: boolean | null = null;\n\n if (parent.nodeName === 'para') {\n const style = parent.getAttribute('style');\n if (\n style === 'q1' ||\n style === 'q2' ||\n style === 'q3' ||\n style === 'q4'\n ) {\n poem =\n style === 'q1'\n ? 1\n : style === 'q2'\n ? 2\n : style === 'q3'\n ? 3\n : 4;\n\n // Send explicit line breaks\n // if we are in a new paragraph but the previous paragraph had the same poem style\n if (parent.previousElementSibling?.nodeName === 'para') {\n const previousStyle =\n parent.previousElementSibling?.getAttribute(\n 'style'\n );\n if (previousStyle === style && lastParent !== parent) {\n lastParent = parent;\n yield {\n lineBreak: true,\n };\n }\n }\n } else if (style === 'd') {\n descriptive = true;\n }\n }\n\n for (let content of this.iterateNodeTextContent(\n nodes,\n node,\n chapter,\n verse\n )) {\n if (poem !== null || descriptive !== null) {\n if (typeof content === 'string') {\n let text: Text = {\n text: content,\n };\n\n if (poem !== null) {\n text.poem = poem;\n }\n\n if (descriptive !== null) {\n text.descriptive = true;\n }\n\n yield text;\n } else {\n let text:\n | InlineLineBreak\n | InlineHeading\n | FootnoteReference\n | Text = {\n ...content,\n };\n\n if ('text' in text) {\n if (poem !== null) {\n text.poem = poem;\n }\n\n if (descriptive !== null) {\n text.descriptive = true;\n }\n }\n yield text;\n }\n } else {\n yield content;\n }\n }\n }\n }\n\n parseVerse(\n element: Element,\n chapter: Chapter,\n nodes: RewindableIterator<Node>\n ): Verse {\n const verse: Verse = {\n type: 'verse',\n number: parseInt(element.getAttribute('number') || '0', 10),\n content: [],\n };\n\n for (let content of this.iterateVerseContent(chapter, verse, nodes)) {\n addOrJoin(verse.content, content);\n }\n\n trimContent(verse.content);\n return verse;\n }\n\n *parseHebrewSubtitle(\n para: Element,\n chapter: Chapter,\n nodes: RewindableIterator<Node>\n ): IterableIterator<HebrewSubtitle | Verse> {\n const subtitle: HebrewSubtitle = {\n type: 'hebrew_subtitle',\n content: [],\n };\n\n for (let content of this.iterateHebrewSubtitleContent(\n para,\n chapter,\n nodes\n )) {\n if (typeof content === 'object' && 'number' in content) {\n yield content;\n continue;\n }\n addOrJoin(subtitle.content, content);\n }\n\n trimContent(subtitle.content);\n if (subtitle.content.length > 0) {\n yield subtitle;\n }\n }\n\n *iterateHebrewSubtitleContent(\n element: Element,\n chapter: Chapter,\n nodes: RewindableIterator<Node>\n ): IterableIterator<\n Verse | string | Text | FootnoteReference | InlineLineBreak\n > {\n while (true) {\n const { done, value: node } = nodes.next();\n if (done) {\n break;\n }\n\n if (!isParent(node, element)) {\n nodes.rewind(1);\n break;\n }\n\n if (node instanceof Element && node.nodeName === 'verse') {\n yield this.parseVerse(node, chapter, nodes);\n } else {\n yield* this.iterateNodeTextContent(nodes, node, chapter);\n }\n }\n }\n\n *iterateNodeTextContent(\n nodes: RewindableIterator<Node>,\n node: Node,\n chapter: Chapter,\n verse?: Verse\n ): IterableIterator<string | Text | FootnoteReference | InlineLineBreak> {\n if (node instanceof Element && node.nodeName === 'note') {\n yield* this.iterateNote(nodes, node, chapter, verse);\n } else if (node instanceof Element && node.nodeName === 'char') {\n yield* this.iterateChar(nodes, node);\n } else if (\n node instanceof Element &&\n node.nodeName === 'para' &&\n node.getAttribute('style') === 'b'\n ) {\n for (let _ of children(nodes, node)) {\n // iterate through all the children to prevent iterating over them multiple times\n }\n yield {\n lineBreak: true,\n };\n } else if (node.nodeType === NodeType.Text) {\n yield node.textContent || '';\n }\n }\n\n *iterateCharContent(char: Element): IterableIterator<string | Text> {\n const style = char.getAttribute('style');\n const text = trimText(char.textContent || '');\n if (style === 'wj') {\n yield {\n text,\n wordsOfJesus: true,\n };\n } else {\n yield text;\n }\n }\n\n *iterateNote(\n nodes: RewindableIterator<Node>,\n node: Element,\n chapter: Chapter,\n verse?: Verse\n ): IterableIterator<FootnoteReference> {\n const style = node.getAttribute('style');\n if (style === 'f') {\n const verseReferenceRegex = /^[0-9]{1,3}:[0-9]{1,3}/;\n\n let text = '';\n for (let child of children(nodes, node)) {\n if (child.nodeType === NodeType.Text) {\n text += child.textContent || '';\n }\n }\n\n text = text.trim();\n if (verseReferenceRegex.test(text)) {\n text = text.replace(verseReferenceRegex, '').trim();\n }\n\n const note: Footnote = {\n noteId: this._noteCounter++,\n caller: node.getAttribute('caller') || null,\n text,\n reference: {\n chapter: chapter.number,\n verse: verse?.number ?? 0,\n },\n };\n\n chapter.footnotes.push(note);\n\n yield {\n noteId: note.noteId,\n };\n } else {\n for (let _ of children(nodes, node)) {\n // iterate through all the children\n // so that we don't end up with duplicates\n }\n }\n }\n\n *iterateChar(\n nodes: RewindableIterator<Node>,\n node: Element\n ): IterableIterator<string | Text> {\n const style = node.getAttribute('style');\n let text = '';\n\n for (let char of children(nodes, node)) {\n if (char.nodeType === NodeType.Text) {\n text += char.textContent || '';\n }\n }\n\n if (style === 'wj') {\n yield {\n text,\n wordsOfJesus: true,\n };\n } else {\n yield text;\n }\n\n // if (!parentChar(node) && !parentNote(node)) {\n // yield *iterateCharContent(node);\n // }\n }\n}\n\n// Taken from https://github.com/gracious-tech/fetch/blob/1576cc4eafb32bf347a09332094cf17c2231c90c/converters/usx-to-json/src/elements.ts#L16\nconst ignoredParaStyles = new Set([\n // <para> Identification [exclude all] - Running headings & table of contents\n 'ide', // See https://github.com/schierlm/BibleMultiConverter/issues/67\n 'rem', // Remarks (valid in schema though missed in docs)\n 'h',\n 'h1',\n 'h2',\n 'h3',\n 'h4',\n 'toc1',\n 'toc2',\n 'toc3',\n 'toca1',\n 'toca2',\n 'toca3',\n\n /* <para> Introductions [exclude all] - Introductionary (non-biblical) content\n Which might be helpful in a printed book, but intro material in apps is usually bad UX,\n and users that really care can research a translations methodology themselves\n */\n 'imt',\n 'imt1',\n 'imt2',\n 'imt3',\n 'imt4',\n 'is',\n 'is1',\n 'is2',\n 'is3',\n 'is4',\n 'ip',\n 'ipi',\n 'im',\n 'imi',\n 'ipq',\n 'imq',\n 'ipr',\n 'iq',\n 'iq1',\n 'iq2',\n 'iq3',\n 'iq4',\n 'ib',\n 'ili',\n 'ili1',\n 'ili2',\n 'ili3',\n 'ili4',\n 'iot',\n 'io',\n 'io1',\n 'io2',\n 'io3',\n 'io4',\n 'iex',\n 'imte',\n 'ie',\n\n /* <para> Headings [exclude some] - Exclude book & chapter headings but keep section headings\n Not excluded: ms# | mr | s# | sr | d | sp | sd#\n */\n 'mt',\n 'mt1',\n 'mt2',\n 'mt3',\n 'mt4',\n 'mte',\n 'mte1',\n 'mte2',\n 'mte3',\n 'mte4',\n 'cl',\n 'cd', // Non-biblical chapter summary, more than heading\n 'r', // Parallels to be provided by external data\n]);\n\nfunction* iterateCharContent(char: Element): IterableIterator<string | Text> {\n const style = char.getAttribute('style');\n const text = trimText(char.textContent || '');\n if (style === 'wj') {\n yield {\n text,\n wordsOfJesus: true,\n };\n } else {\n yield text;\n }\n}\n\nfunction trimText(text: string): string {\n return text.replace(/\\s+/g, ' ');\n}\n\nfunction trimContent<T extends string | unknown>(content: T[]): T[] {\n for (let i = 0; i < content.length; i++) {\n const value = content[i];\n if (typeof value === 'string') {\n content[i] = trimText(value as string).trim() as T;\n if (content[i] === '') {\n content.splice(i, 1);\n i--;\n continue;\n }\n } else if (isVerseText(value)) {\n value.text = trimText(value.text).trim();\n if (value.text === '') {\n content.splice(i, 1);\n i--;\n continue;\n }\n }\n }\n return content;\n}\n\nfunction addOrJoin(array: (string | unknown)[], value: string | unknown) {\n if (array.length === 0) {\n array.push(value);\n } else {\n const last = array[array.length - 1];\n if (typeof last === 'string' && typeof value === 'string') {\n array[array.length - 1] = last + value;\n } else if (\n isVerseText(last) &&\n isVerseText(value) &&\n hasSameFormatting(last, value)\n ) {\n last.text += value.text;\n } else {\n array.push(value);\n }\n }\n}\n\nfunction isVerseText(value: unknown): value is Text {\n return typeof value === 'object' && value !== null && 'text' in value;\n}\n\nfunction hasSameFormatting(a: Text, b: Text): boolean {\n return a.poem === b.poem && a.wordsOfJesus === b.wordsOfJesus;\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAYA,uBAKO;AAEP,IAAK,WAAL,kBAAKA,cAAL;AACI,EAAAA,oBAAA,UAAO,KAAP;AADC,SAAAA;AAAA,GAAA;AAQE,MAAM,iBAAiB;AAKvB,MAAM,UAAU;AAAA,EACX;AAAA,EACA,eAAuB;AAAA,EAE/B,YAAY,WAAsB;AAC9B,SAAK,aAAa;AAAA,EACtB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQO,MAAM,KAAwB;AACjC,UAAM,SAAS,KAAK;AACpB,UAAM,MAAM,OAAO,gBAAgB,KAAK,iBAAiB;AACzD,UAAM,aAAa,IAAI;AAEvB,QAAI,OAAkB;AAAA,MAClB,MAAM;AAAA,MACN,SAAS,CAAC;AAAA,IACd;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;AAAA,IACvB,OAAO;AACH,YAAM,KAAK,KAAK;AAAA,IACpB;AAAA,EACJ;AACJ;AAEA,SAAS,YAAY,OAA+B;AAChD,SAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,UAAU;AACpE;AAEA,SAAS,kBAAkB,GAAS,GAAkB;AAClD,SAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,iBAAiB,EAAE;AACrD;",
|
|
6
|
+
"names": ["NodeType"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var utils_exports = {};
|
|
20
|
+
__export(utils_exports, {
|
|
21
|
+
getBookId: () => getBookId,
|
|
22
|
+
getFirstNonEmpty: () => getFirstNonEmpty,
|
|
23
|
+
getTranslationId: () => getTranslationId,
|
|
24
|
+
isEmptyOrWhitespace: () => isEmptyOrWhitespace,
|
|
25
|
+
normalizeLanguage: () => normalizeLanguage,
|
|
26
|
+
parseVerseReference: () => parseVerseReference
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(utils_exports);
|
|
29
|
+
function normalizeLanguage(language) {
|
|
30
|
+
return language;
|
|
31
|
+
}
|
|
32
|
+
const TRANSLATION_ID_MAP = /* @__PURE__ */ new Map([
|
|
33
|
+
["eng_bsb", "BSB"],
|
|
34
|
+
["arb_nav", "ARBNAV"],
|
|
35
|
+
["eng_webp", "ENGWEBP"],
|
|
36
|
+
["hin_irv", "HINIRV"],
|
|
37
|
+
["hbo_mas", "HBOMAS"]
|
|
38
|
+
]);
|
|
39
|
+
function getTranslationId(translationId) {
|
|
40
|
+
return TRANSLATION_ID_MAP.get(translationId) ?? translationId;
|
|
41
|
+
}
|
|
42
|
+
function isEmptyOrWhitespace(str) {
|
|
43
|
+
return !str || /^\s*$/.test(str);
|
|
44
|
+
}
|
|
45
|
+
function getFirstNonEmpty(...values) {
|
|
46
|
+
for (let value of values) {
|
|
47
|
+
if (!isEmptyOrWhitespace(value)) {
|
|
48
|
+
return value;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
throw new Error("All values are empty or whitespace!");
|
|
52
|
+
}
|
|
53
|
+
function parseVerseReference(text) {
|
|
54
|
+
const match = text.match(/^\s*([0-9A-Za-z\s]+)\s+(\d+):(\d+)/);
|
|
55
|
+
if (!match) {
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
const [reference, book, chapterStr, verseStr] = match;
|
|
59
|
+
const chapter = parseInt(chapterStr);
|
|
60
|
+
const verse = parseInt(verseStr);
|
|
61
|
+
if (isNaN(chapter) || isNaN(verse)) {
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
if (reference.length !== text.length) {
|
|
65
|
+
return {
|
|
66
|
+
book: getBookId(book) ?? book,
|
|
67
|
+
chapter,
|
|
68
|
+
verse,
|
|
69
|
+
content: text.substring(reference.length).trim()
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
return {
|
|
73
|
+
book: getBookId(book) ?? book,
|
|
74
|
+
chapter,
|
|
75
|
+
verse
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
const BOOK_ID_MAP = /* @__PURE__ */ new Map([
|
|
79
|
+
["gen", "GEN"],
|
|
80
|
+
["genesis", "GEN"],
|
|
81
|
+
["exo", "EXO"],
|
|
82
|
+
["exodus", "EXO"],
|
|
83
|
+
["lev", "LEV"],
|
|
84
|
+
["lev", "LEV"],
|
|
85
|
+
["laviticus", "LEV"],
|
|
86
|
+
["num", "NUM"],
|
|
87
|
+
["numbers", "NUM"],
|
|
88
|
+
["deu", "DEU"],
|
|
89
|
+
["deuteronomy", "DEU"],
|
|
90
|
+
["jos", "JOS"],
|
|
91
|
+
["joshua", "JOS"],
|
|
92
|
+
["jdg", "JDG"],
|
|
93
|
+
["judges", "JDG"],
|
|
94
|
+
["rut", "RUT"],
|
|
95
|
+
["ruth", "RUT"],
|
|
96
|
+
["1sa", "1SA"],
|
|
97
|
+
["1samuel", "1SA"],
|
|
98
|
+
["2sa", "2SA"],
|
|
99
|
+
["2samuel", "2SA"],
|
|
100
|
+
["1ki", "1KI"],
|
|
101
|
+
["1kings", "1KI"],
|
|
102
|
+
["2ki", "2KI"],
|
|
103
|
+
["2kings", "2KI"],
|
|
104
|
+
["1ch", "1CH"],
|
|
105
|
+
["1chronicles", "1CH"],
|
|
106
|
+
["chronicles1", "1CH"],
|
|
107
|
+
["2ch", "2CH"],
|
|
108
|
+
["2chronicles", "2CH"],
|
|
109
|
+
["chronicles2", "2CH"],
|
|
110
|
+
["ezr", "EZR"],
|
|
111
|
+
["ezra", "EZR"],
|
|
112
|
+
["neh", "NEH"],
|
|
113
|
+
["nehemiah", "NEH"],
|
|
114
|
+
["est", "EST"],
|
|
115
|
+
["ester", "EST"],
|
|
116
|
+
["job", "JOB"],
|
|
117
|
+
["psa", "PSA"],
|
|
118
|
+
["psalms", "PSA"],
|
|
119
|
+
["psalm", "PSA"],
|
|
120
|
+
["pro", "PRO"],
|
|
121
|
+
["proverbs", "PRO"],
|
|
122
|
+
["ecc", "ECC"],
|
|
123
|
+
["ecclesiastes", "ECC"],
|
|
124
|
+
["sng", "SNG"],
|
|
125
|
+
["songofsolomon", "SNG"],
|
|
126
|
+
["isa", "ISA"],
|
|
127
|
+
["isaiah", "ISA"],
|
|
128
|
+
["jer", "JER"],
|
|
129
|
+
["jeremiah", "JER"],
|
|
130
|
+
["lam", "LAM"],
|
|
131
|
+
["lamentations", "LAM"],
|
|
132
|
+
["ezk", "EZK"],
|
|
133
|
+
["ezekiel", "EZK"],
|
|
134
|
+
["dan", "DAN"],
|
|
135
|
+
["daniel", "DAN"],
|
|
136
|
+
["hos", "HOS"],
|
|
137
|
+
["hosea", "HOS"],
|
|
138
|
+
["jol", "JOL"],
|
|
139
|
+
["joel", "JOL"],
|
|
140
|
+
["amo", "AMO"],
|
|
141
|
+
["amos", "AMO"],
|
|
142
|
+
["oba", "OBA"],
|
|
143
|
+
["obadiah", "OBA"],
|
|
144
|
+
["jon", "JON"],
|
|
145
|
+
["jonah", "JON"],
|
|
146
|
+
["mic", "MIC"],
|
|
147
|
+
["micah", "MIC"],
|
|
148
|
+
["nam", "NAM"],
|
|
149
|
+
["nahum", "NAM"],
|
|
150
|
+
["hab", "HAB"],
|
|
151
|
+
["habakkuk", "HAB"],
|
|
152
|
+
["zep", "ZEP"],
|
|
153
|
+
["zepaniah", "ZEP"],
|
|
154
|
+
["hag", "HAG"],
|
|
155
|
+
["haggai", "HAG"],
|
|
156
|
+
["zec", "ZEC"],
|
|
157
|
+
["zechariah", "ZEC"],
|
|
158
|
+
["mal", "MAL"],
|
|
159
|
+
["malachi", "MAL"],
|
|
160
|
+
["mat", "MAT"],
|
|
161
|
+
["matthew", "MAT"],
|
|
162
|
+
["mrk", "MRK"],
|
|
163
|
+
["mark", "MRK"],
|
|
164
|
+
["luk", "LUK"],
|
|
165
|
+
["luke", "LUK"],
|
|
166
|
+
["jhn", "JHN"],
|
|
167
|
+
["john", "JHN"],
|
|
168
|
+
["act", "ACT"],
|
|
169
|
+
["acts", "ACT"],
|
|
170
|
+
["rom", "ROM"],
|
|
171
|
+
["romans", "ROM"],
|
|
172
|
+
["1co", "1CO"],
|
|
173
|
+
["1corinthians", "1CO"],
|
|
174
|
+
["2co", "2CO"],
|
|
175
|
+
["2corinthians", "2CO"],
|
|
176
|
+
["gal", "GAL"],
|
|
177
|
+
["galatians", "GAL"],
|
|
178
|
+
["eph", "EPH"],
|
|
179
|
+
["ephesians", "EPH"],
|
|
180
|
+
["php", "PHP"],
|
|
181
|
+
["philippians", "PHP"],
|
|
182
|
+
["col", "COL"],
|
|
183
|
+
["colossians", "COL"],
|
|
184
|
+
["1th", "1TH"],
|
|
185
|
+
["1thessalonians", "1TH"],
|
|
186
|
+
["2th", "2TH"],
|
|
187
|
+
["2thessalonians", "2TH"],
|
|
188
|
+
["1ti", "1TI"],
|
|
189
|
+
["1timothy", "1TI"],
|
|
190
|
+
["2ti", "2TI"],
|
|
191
|
+
["2timothy", "2TI"],
|
|
192
|
+
["tit", "TIT"],
|
|
193
|
+
["titus", "TIT"],
|
|
194
|
+
["phm", "PHM"],
|
|
195
|
+
["philemon", "PHM"],
|
|
196
|
+
["heb", "HEB"],
|
|
197
|
+
["hebrews", "HEB"],
|
|
198
|
+
["jas", "JAS"],
|
|
199
|
+
["james", "JAS"],
|
|
200
|
+
["1pe", "1PE"],
|
|
201
|
+
["1peter", "1PE"],
|
|
202
|
+
["2pe", "2PE"],
|
|
203
|
+
["2peter", "2PE"],
|
|
204
|
+
["1jn", "1JN"],
|
|
205
|
+
["1john", "1JN"],
|
|
206
|
+
["2jn", "2JN"],
|
|
207
|
+
["2john", "2JN"],
|
|
208
|
+
["3jn", "3JN"],
|
|
209
|
+
["3john", "3JN"],
|
|
210
|
+
["jud", "JUD"],
|
|
211
|
+
["jude", "JUD"],
|
|
212
|
+
["rev", "REV"],
|
|
213
|
+
["revelation", "REV"]
|
|
214
|
+
]);
|
|
215
|
+
function getBookId(book) {
|
|
216
|
+
const bookLower = book.toLowerCase().replaceAll(/\s+/g, "");
|
|
217
|
+
const id = BOOK_ID_MAP.get(bookLower);
|
|
218
|
+
if (id) {
|
|
219
|
+
return id;
|
|
220
|
+
}
|
|
221
|
+
for (let [key, id2] of BOOK_ID_MAP) {
|
|
222
|
+
if (bookLower.startsWith(key)) {
|
|
223
|
+
return id2;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
return null;
|
|
227
|
+
}
|
|
228
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
229
|
+
0 && (module.exports = {
|
|
230
|
+
getBookId,
|
|
231
|
+
getFirstNonEmpty,
|
|
232
|
+
getTranslationId,
|
|
233
|
+
isEmptyOrWhitespace,
|
|
234
|
+
normalizeLanguage,
|
|
235
|
+
parseVerseReference
|
|
236
|
+
});
|
|
237
|
+
//# sourceMappingURL=utils.cjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../utils.ts"],
|
|
4
|
+
"sourcesContent": ["/**\r\n * Normalizes the given language code into a ISO 639 code.\r\n * @param language The language code to normalize.\r\n */\r\nexport function normalizeLanguage(language: string): string {\r\n return language;\r\n}\r\n\r\n/**\r\n * The map of translation IDs from fetch.bible to their translation ID in the API.\r\n */\r\nconst TRANSLATION_ID_MAP: Map<string, string> = new Map([\r\n ['eng_bsb', 'BSB'],\r\n ['arb_nav', 'ARBNAV'],\r\n ['eng_webp', 'ENGWEBP'],\r\n ['hin_irv', 'HINIRV'],\r\n ['hbo_mas', 'HBOMAS'],\r\n]);\r\n\r\n/**\r\n * Gets the ID of the translation.\r\n * @param translation The translation to get the ID for.\r\n */\r\nexport function getTranslationId(translationId: string): string {\r\n return TRANSLATION_ID_MAP.get(translationId) ?? translationId;\r\n}\r\n\r\nexport function isEmptyOrWhitespace(str: string | null | undefined): boolean {\r\n return !str || /^\\s*$/.test(str);\r\n}\r\n\r\nexport function getFirstNonEmpty<T extends string>(...values: T[]): T {\r\n for (let value of values) {\r\n if (!isEmptyOrWhitespace(value)) {\r\n return value;\r\n }\r\n }\r\n\r\n throw new Error('All values are empty or whitespace!');\r\n}\r\n\r\nexport interface VerseRef {\r\n book: string;\r\n chapter: number;\r\n verse: number;\r\n\r\n /**\r\n * The rest of the content of the verse.\r\n */\r\n content?: string;\r\n}\r\n\r\n/**\r\n * Parses the given verse reference.\r\n * Formatted like \"GEN 1:1\".\r\n *\r\n * @param text The reference to parse.\r\n */\r\nexport function parseVerseReference(text: string): VerseRef | null {\r\n const match = text.match(/^\\s*([0-9A-Za-z\\s]+)\\s+(\\d+):(\\d+)/);\r\n\r\n if (!match) {\r\n return null;\r\n }\r\n\r\n const [reference, book, chapterStr, verseStr] = match;\r\n\r\n const chapter = parseInt(chapterStr);\r\n const verse = parseInt(verseStr);\r\n\r\n if (isNaN(chapter) || isNaN(verse)) {\r\n return null;\r\n }\r\n\r\n if (reference.length !== text.length) {\r\n return {\r\n book: getBookId(book) ?? book,\r\n chapter,\r\n verse,\r\n content: text.substring(reference.length).trim(),\r\n };\r\n }\r\n\r\n return {\r\n book: getBookId(book) ?? book,\r\n chapter,\r\n verse,\r\n };\r\n}\r\n\r\n/**\r\n * Defines a map that maps the book ID to the numerical order of the book.\r\n */\r\nconst BOOK_ID_MAP: Map<string, string> = new Map([\r\n ['gen', 'GEN'],\r\n ['genesis', 'GEN'],\r\n ['exo', 'EXO'],\r\n ['exodus', 'EXO'],\r\n ['lev', 'LEV'],\r\n ['lev', 'LEV'],\r\n ['laviticus', 'LEV'],\r\n ['num', 'NUM'],\r\n ['numbers', 'NUM'],\r\n ['deu', 'DEU'],\r\n ['deuteronomy', 'DEU'],\r\n ['jos', 'JOS'],\r\n ['joshua', 'JOS'],\r\n ['jdg', 'JDG'],\r\n ['judges', 'JDG'],\r\n ['rut', 'RUT'],\r\n ['ruth', 'RUT'],\r\n ['1sa', '1SA'],\r\n ['1samuel', '1SA'],\r\n ['2sa', '2SA'],\r\n ['2samuel', '2SA'],\r\n ['1ki', '1KI'],\r\n ['1kings', '1KI'],\r\n ['2ki', '2KI'],\r\n ['2kings', '2KI'],\r\n ['1ch', '1CH'],\r\n ['1chronicles', '1CH'],\r\n ['chronicles1', '1CH'],\r\n ['2ch', '2CH'],\r\n ['2chronicles', '2CH'],\r\n ['chronicles2', '2CH'],\r\n ['ezr', 'EZR'],\r\n ['ezra', 'EZR'],\r\n ['neh', 'NEH'],\r\n ['nehemiah', 'NEH'],\r\n ['est', 'EST'],\r\n ['ester', 'EST'],\r\n ['job', 'JOB'],\r\n ['psa', 'PSA'],\r\n ['psalms', 'PSA'],\r\n ['psalm', 'PSA'],\r\n ['pro', 'PRO'],\r\n ['proverbs', 'PRO'],\r\n ['ecc', 'ECC'],\r\n ['ecclesiastes', 'ECC'],\r\n ['sng', 'SNG'],\r\n ['songofsolomon', 'SNG'],\r\n ['isa', 'ISA'],\r\n ['isaiah', 'ISA'],\r\n ['jer', 'JER'],\r\n ['jeremiah', 'JER'],\r\n ['lam', 'LAM'],\r\n ['lamentations', 'LAM'],\r\n ['ezk', 'EZK'],\r\n ['ezekiel', 'EZK'],\r\n ['dan', 'DAN'],\r\n ['daniel', 'DAN'],\r\n ['hos', 'HOS'],\r\n ['hosea', 'HOS'],\r\n ['jol', 'JOL'],\r\n ['joel', 'JOL'],\r\n ['amo', 'AMO'],\r\n ['amos', 'AMO'],\r\n ['oba', 'OBA'],\r\n ['obadiah', 'OBA'],\r\n ['jon', 'JON'],\r\n ['jonah', 'JON'],\r\n ['mic', 'MIC'],\r\n ['micah', 'MIC'],\r\n ['nam', 'NAM'],\r\n ['nahum', 'NAM'],\r\n ['hab', 'HAB'],\r\n ['habakkuk', 'HAB'],\r\n ['zep', 'ZEP'],\r\n ['zepaniah', 'ZEP'],\r\n ['hag', 'HAG'],\r\n ['haggai', 'HAG'],\r\n ['zec', 'ZEC'],\r\n ['zechariah', 'ZEC'],\r\n ['mal', 'MAL'],\r\n ['malachi', 'MAL'],\r\n ['mat', 'MAT'],\r\n ['matthew', 'MAT'],\r\n ['mrk', 'MRK'],\r\n ['mark', 'MRK'],\r\n ['luk', 'LUK'],\r\n ['luke', 'LUK'],\r\n ['jhn', 'JHN'],\r\n ['john', 'JHN'],\r\n ['act', 'ACT'],\r\n ['acts', 'ACT'],\r\n ['rom', 'ROM'],\r\n ['romans', 'ROM'],\r\n ['1co', '1CO'],\r\n ['1corinthians', '1CO'],\r\n ['2co', '2CO'],\r\n ['2corinthians', '2CO'],\r\n ['gal', 'GAL'],\r\n ['galatians', 'GAL'],\r\n ['eph', 'EPH'],\r\n ['ephesians', 'EPH'],\r\n ['php', 'PHP'],\r\n ['philippians', 'PHP'],\r\n ['col', 'COL'],\r\n ['colossians', 'COL'],\r\n ['1th', '1TH'],\r\n ['1thessalonians', '1TH'],\r\n ['2th', '2TH'],\r\n ['2thessalonians', '2TH'],\r\n ['1ti', '1TI'],\r\n ['1timothy', '1TI'],\r\n ['2ti', '2TI'],\r\n ['2timothy', '2TI'],\r\n ['tit', 'TIT'],\r\n ['titus', 'TIT'],\r\n ['phm', 'PHM'],\r\n ['philemon', 'PHM'],\r\n ['heb', 'HEB'],\r\n ['hebrews', 'HEB'],\r\n ['jas', 'JAS'],\r\n ['james', 'JAS'],\r\n ['1pe', '1PE'],\r\n ['1peter', '1PE'],\r\n ['2pe', '2PE'],\r\n ['2peter', '2PE'],\r\n ['1jn', '1JN'],\r\n ['1john', '1JN'],\r\n ['2jn', '2JN'],\r\n ['2john', '2JN'],\r\n ['3jn', '3JN'],\r\n ['3john', '3JN'],\r\n ['jud', 'JUD'],\r\n ['jude', 'JUD'],\r\n ['rev', 'REV'],\r\n ['revelation', 'REV'],\r\n]);\r\n\r\n/**\r\n * Gets the ID of the given book.\r\n * Returns null if the ID could not be found.\r\n * @param book The name/ID of the book.\r\n */\r\nexport function getBookId(book: string): string | null {\r\n const bookLower = book.toLowerCase().replaceAll(/\\s+/g, '');\r\n\r\n const id = BOOK_ID_MAP.get(bookLower);\r\n if (id) {\r\n return id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AK;AAAA,EACb,CAAC,SAAS,KAAK;AAAA,EACf,CAAC,OAAO,KAAK;AAAA,EACb,CAAC,UAAU,KAAK;AAAA,EAChB,CAAC,OAAO,KAAK;AAAA,EACb,CAAC,UAAU,KAAK;AAAA,EAChB,CAAC,OAAO,KAAK;AAAA,EACb,CAAC,SAAS,KAAK;AAAA,EACf,CAAC,OAAO,KAAK;AAAA,EACb,CAAC,SAAS,KAAK;AAAA,EACf,CAAC,OAAO,KAAK;AAAA,EACb,CAAC,SAAS,KAAK;AAAA,EACf,CAAC,OAAO,KAAK;AAAA,EACb,CAAC,QAAQ,KAAK;AAAA,EACd,CAAC,OAAO,KAAK;AAAA,EACb,CAAC,cAAc,KAAK;AACxB,CAAC;AAOM,SAAS,UAAU,MAA6B;AACnD,QAAM,YAAY,KAAK,YAAY,EAAE,WAAW,QAAQ,EAAE;AAE1D,QAAM,KAAK,YAAY,IAAI,SAAS;AACpC,MAAI,IAAI;AACJ,WAAO;AAAA,EACX;AAEA,WAAS,CAAC,KAAKA,GAAE,KAAK,aAAa;AAC/B,QAAI,UAAU,WAAW,GAAG,GAAG;AAC3B,aAAOA;AAAA,IACX;AAAA,EACJ;AAEA,SAAO;AACX;",
|
|
6
|
+
"names": ["id"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
export function generateApiForDataset(dataset, options = {}) {
|
|
3
|
+
const { useCommonName, pathPrefix } = options;
|
|
4
|
+
const apiPathPrefix = pathPrefix ? pathPrefix : "";
|
|
5
|
+
let api = {
|
|
6
|
+
availableTranslations: {
|
|
7
|
+
translations: []
|
|
8
|
+
},
|
|
9
|
+
translationBooks: [],
|
|
10
|
+
translationBookChapters: [],
|
|
11
|
+
translationBookChapterAudio: [],
|
|
12
|
+
availableCommentaries: {
|
|
13
|
+
commentaries: []
|
|
14
|
+
},
|
|
15
|
+
commentaryBookChapters: [],
|
|
16
|
+
commentaryBooks: [],
|
|
17
|
+
pathPrefix: apiPathPrefix
|
|
18
|
+
};
|
|
19
|
+
const getNativeName = options.getNativeName;
|
|
20
|
+
const getEnglishName = options.getEnglishName;
|
|
21
|
+
for (let { books, ...translation } of dataset.translations) {
|
|
22
|
+
const apiTranslation = {
|
|
23
|
+
...translation,
|
|
24
|
+
availableFormats: ["json"],
|
|
25
|
+
listOfBooksApiLink: listOfBooksApiLink(
|
|
26
|
+
translation.id,
|
|
27
|
+
apiPathPrefix
|
|
28
|
+
),
|
|
29
|
+
numberOfBooks: books.length,
|
|
30
|
+
totalNumberOfChapters: 0,
|
|
31
|
+
totalNumberOfVerses: 0,
|
|
32
|
+
languageName: getNativeName ? getNativeName(translation.language) ?? void 0 : void 0,
|
|
33
|
+
languageEnglishName: getEnglishName ? getEnglishName(translation.language) ?? void 0 : void 0
|
|
34
|
+
};
|
|
35
|
+
const translationBooks = {
|
|
36
|
+
translation: apiTranslation,
|
|
37
|
+
books: []
|
|
38
|
+
};
|
|
39
|
+
let translationChapters = [];
|
|
40
|
+
for (let { chapters, ...book } of books) {
|
|
41
|
+
const apiBook = {
|
|
42
|
+
...book,
|
|
43
|
+
firstChapterApiLink: bookChapterApiLink(
|
|
44
|
+
translation.id,
|
|
45
|
+
getBookLink(book),
|
|
46
|
+
1,
|
|
47
|
+
"json",
|
|
48
|
+
apiPathPrefix
|
|
49
|
+
),
|
|
50
|
+
lastChapterApiLink: bookChapterApiLink(
|
|
51
|
+
translation.id,
|
|
52
|
+
getBookLink(book),
|
|
53
|
+
chapters.length,
|
|
54
|
+
"json",
|
|
55
|
+
apiPathPrefix
|
|
56
|
+
),
|
|
57
|
+
numberOfChapters: chapters.length,
|
|
58
|
+
totalNumberOfVerses: 0
|
|
59
|
+
};
|
|
60
|
+
for (let { chapter, thisChapterAudioLinks } of chapters) {
|
|
61
|
+
const audio = {};
|
|
62
|
+
const apiBookChapter = {
|
|
63
|
+
translation: apiTranslation,
|
|
64
|
+
book: apiBook,
|
|
65
|
+
chapter,
|
|
66
|
+
thisChapterLink: bookChapterApiLink(
|
|
67
|
+
translation.id,
|
|
68
|
+
getBookLink(book),
|
|
69
|
+
chapter.number,
|
|
70
|
+
"json",
|
|
71
|
+
apiPathPrefix
|
|
72
|
+
),
|
|
73
|
+
thisChapterAudioLinks: audio,
|
|
74
|
+
nextChapterApiLink: null,
|
|
75
|
+
nextChapterAudioLinks: null,
|
|
76
|
+
previousChapterApiLink: null,
|
|
77
|
+
previousChapterAudioLinks: null,
|
|
78
|
+
numberOfVerses: 0
|
|
79
|
+
};
|
|
80
|
+
for (let reader in thisChapterAudioLinks) {
|
|
81
|
+
if (options.generateAudioFiles) {
|
|
82
|
+
const apiAudio = {
|
|
83
|
+
chapter: apiBookChapter,
|
|
84
|
+
link: bookChapterAudioApiLink(
|
|
85
|
+
translation.id,
|
|
86
|
+
getBookLink(book),
|
|
87
|
+
chapter.number,
|
|
88
|
+
reader,
|
|
89
|
+
apiPathPrefix
|
|
90
|
+
),
|
|
91
|
+
originalUrl: thisChapterAudioLinks[reader]
|
|
92
|
+
};
|
|
93
|
+
audio[reader] = apiAudio.link;
|
|
94
|
+
api.translationBookChapterAudio.push(apiAudio);
|
|
95
|
+
} else {
|
|
96
|
+
audio[reader] = thisChapterAudioLinks[reader];
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
for (let c of chapter.content) {
|
|
100
|
+
if (c.type === "verse") {
|
|
101
|
+
apiBookChapter.numberOfVerses++;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
apiBook.totalNumberOfVerses += apiBookChapter.numberOfVerses;
|
|
105
|
+
translationChapters.push(apiBookChapter);
|
|
106
|
+
api.translationBookChapters.push(apiBookChapter);
|
|
107
|
+
}
|
|
108
|
+
translationBooks.books.push(apiBook);
|
|
109
|
+
apiTranslation.totalNumberOfChapters += apiBook.numberOfChapters;
|
|
110
|
+
apiTranslation.totalNumberOfVerses += apiBook.totalNumberOfVerses;
|
|
111
|
+
}
|
|
112
|
+
for (let i = 0; i < translationChapters.length; i++) {
|
|
113
|
+
if (i > 0) {
|
|
114
|
+
translationChapters[i].previousChapterApiLink = bookChapterApiLink(
|
|
115
|
+
translation.id,
|
|
116
|
+
getBookLink(translationChapters[i - 1].book),
|
|
117
|
+
translationChapters[i - 1].chapter.number,
|
|
118
|
+
"json",
|
|
119
|
+
apiPathPrefix
|
|
120
|
+
);
|
|
121
|
+
translationChapters[i].previousChapterAudioLinks = translationChapters[i - 1].thisChapterAudioLinks;
|
|
122
|
+
}
|
|
123
|
+
if (i < translationChapters.length - 1) {
|
|
124
|
+
translationChapters[i].nextChapterApiLink = bookChapterApiLink(
|
|
125
|
+
translation.id,
|
|
126
|
+
getBookLink(translationChapters[i + 1].book),
|
|
127
|
+
translationChapters[i + 1].chapter.number,
|
|
128
|
+
"json",
|
|
129
|
+
apiPathPrefix
|
|
130
|
+
);
|
|
131
|
+
translationChapters[i].nextChapterAudioLinks = translationChapters[i + 1].thisChapterAudioLinks;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
api.availableTranslations.translations.push(apiTranslation);
|
|
135
|
+
api.translationBooks.push(translationBooks);
|
|
136
|
+
}
|
|
137
|
+
for (let { books, ...commentary } of dataset.commentaries) {
|
|
138
|
+
const apiCommentary = {
|
|
139
|
+
...commentary,
|
|
140
|
+
availableFormats: ["json"],
|
|
141
|
+
listOfBooksApiLink: listOfCommentaryBooksApiLink(
|
|
142
|
+
commentary.id,
|
|
143
|
+
apiPathPrefix
|
|
144
|
+
),
|
|
145
|
+
numberOfBooks: books.length,
|
|
146
|
+
totalNumberOfChapters: 0,
|
|
147
|
+
totalNumberOfVerses: 0,
|
|
148
|
+
languageName: getNativeName ? getNativeName(commentary.language) ?? void 0 : void 0,
|
|
149
|
+
languageEnglishName: getEnglishName ? getEnglishName(commentary.language) ?? void 0 : void 0
|
|
150
|
+
};
|
|
151
|
+
const commentaryBooks = {
|
|
152
|
+
commentary: apiCommentary,
|
|
153
|
+
books: []
|
|
154
|
+
};
|
|
155
|
+
let commentaryChapters = [];
|
|
156
|
+
for (let { chapters, ...book } of books) {
|
|
157
|
+
const apiBook = {
|
|
158
|
+
...book,
|
|
159
|
+
firstChapterApiLink: bookCommentaryChapterApiLink(
|
|
160
|
+
commentary.id,
|
|
161
|
+
getBookLink(book),
|
|
162
|
+
1,
|
|
163
|
+
"json",
|
|
164
|
+
apiPathPrefix
|
|
165
|
+
),
|
|
166
|
+
lastChapterApiLink: bookCommentaryChapterApiLink(
|
|
167
|
+
commentary.id,
|
|
168
|
+
getBookLink(book),
|
|
169
|
+
chapters.length,
|
|
170
|
+
"json",
|
|
171
|
+
apiPathPrefix
|
|
172
|
+
),
|
|
173
|
+
numberOfChapters: chapters.length,
|
|
174
|
+
totalNumberOfVerses: 0
|
|
175
|
+
};
|
|
176
|
+
for (let { chapter } of chapters) {
|
|
177
|
+
const apiBookChapter = {
|
|
178
|
+
commentary: apiCommentary,
|
|
179
|
+
book: apiBook,
|
|
180
|
+
chapter,
|
|
181
|
+
thisChapterLink: bookCommentaryChapterApiLink(
|
|
182
|
+
commentary.id,
|
|
183
|
+
getBookLink(book),
|
|
184
|
+
chapter.number,
|
|
185
|
+
"json",
|
|
186
|
+
apiPathPrefix
|
|
187
|
+
),
|
|
188
|
+
nextChapterApiLink: null,
|
|
189
|
+
previousChapterApiLink: null,
|
|
190
|
+
numberOfVerses: 0
|
|
191
|
+
};
|
|
192
|
+
for (let c of chapter.content) {
|
|
193
|
+
if (c.type === "verse") {
|
|
194
|
+
apiBookChapter.numberOfVerses++;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
apiBook.totalNumberOfVerses += apiBookChapter.numberOfVerses;
|
|
198
|
+
commentaryChapters.push(apiBookChapter);
|
|
199
|
+
api.commentaryBookChapters.push(apiBookChapter);
|
|
200
|
+
}
|
|
201
|
+
commentaryBooks.books.push(apiBook);
|
|
202
|
+
apiCommentary.totalNumberOfChapters += apiBook.numberOfChapters;
|
|
203
|
+
apiCommentary.totalNumberOfVerses += apiBook.totalNumberOfVerses;
|
|
204
|
+
}
|
|
205
|
+
for (let i = 0; i < commentaryChapters.length; i++) {
|
|
206
|
+
if (i > 0) {
|
|
207
|
+
commentaryChapters[i].previousChapterApiLink = bookCommentaryChapterApiLink(
|
|
208
|
+
commentary.id,
|
|
209
|
+
getBookLink(commentaryChapters[i - 1].book),
|
|
210
|
+
commentaryChapters[i - 1].chapter.number,
|
|
211
|
+
"json",
|
|
212
|
+
apiPathPrefix
|
|
213
|
+
);
|
|
214
|
+
}
|
|
215
|
+
if (i < commentaryChapters.length - 1) {
|
|
216
|
+
commentaryChapters[i].nextChapterApiLink = bookCommentaryChapterApiLink(
|
|
217
|
+
commentary.id,
|
|
218
|
+
getBookLink(commentaryChapters[i + 1].book),
|
|
219
|
+
commentaryChapters[i + 1].chapter.number,
|
|
220
|
+
"json",
|
|
221
|
+
apiPathPrefix
|
|
222
|
+
);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
api.availableCommentaries.commentaries.push(apiCommentary);
|
|
226
|
+
api.commentaryBooks.push(commentaryBooks);
|
|
227
|
+
}
|
|
228
|
+
return api;
|
|
229
|
+
function getBookLink(book) {
|
|
230
|
+
return useCommonName ? book.commonName : book.id;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
export function generateFilesForApi(api) {
|
|
234
|
+
let files = [];
|
|
235
|
+
files.push(
|
|
236
|
+
jsonFile(
|
|
237
|
+
`${api.pathPrefix}/api/available_translations.json`,
|
|
238
|
+
api.availableTranslations,
|
|
239
|
+
true
|
|
240
|
+
)
|
|
241
|
+
);
|
|
242
|
+
for (let translationBooks of api.translationBooks) {
|
|
243
|
+
files.push(
|
|
244
|
+
jsonFile(
|
|
245
|
+
translationBooks.translation.listOfBooksApiLink,
|
|
246
|
+
translationBooks
|
|
247
|
+
)
|
|
248
|
+
);
|
|
249
|
+
}
|
|
250
|
+
for (let bookChapter of api.translationBookChapters) {
|
|
251
|
+
files.push(jsonFile(bookChapter.thisChapterLink, bookChapter));
|
|
252
|
+
}
|
|
253
|
+
for (let audio of api.translationBookChapterAudio) {
|
|
254
|
+
files.push(downloadedFile(audio.link, audio.originalUrl));
|
|
255
|
+
}
|
|
256
|
+
files.push(
|
|
257
|
+
jsonFile(
|
|
258
|
+
`${api.pathPrefix}/api/available_commentaries.json`,
|
|
259
|
+
api.availableCommentaries,
|
|
260
|
+
true
|
|
261
|
+
)
|
|
262
|
+
);
|
|
263
|
+
for (let commentaryBooks of api.commentaryBooks) {
|
|
264
|
+
files.push(
|
|
265
|
+
jsonFile(
|
|
266
|
+
commentaryBooks.commentary.listOfBooksApiLink,
|
|
267
|
+
commentaryBooks
|
|
268
|
+
)
|
|
269
|
+
);
|
|
270
|
+
}
|
|
271
|
+
for (let bookChapter of api.commentaryBookChapters) {
|
|
272
|
+
files.push(jsonFile(bookChapter.thisChapterLink, bookChapter));
|
|
273
|
+
}
|
|
274
|
+
return files;
|
|
275
|
+
}
|
|
276
|
+
export async function* generateOutputFilesFromDatasets(datasets, options) {
|
|
277
|
+
for await (let dataset of datasets) {
|
|
278
|
+
const api = generateApiForDataset(dataset, options);
|
|
279
|
+
const files = generateFilesForApi(api);
|
|
280
|
+
yield files;
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
export function listOfBooksApiLink(translationId, prefix = "") {
|
|
284
|
+
return `${prefix}/api/${translationId}/books.json`;
|
|
285
|
+
}
|
|
286
|
+
export function listOfCommentaryBooksApiLink(commentaryId, prefix = "") {
|
|
287
|
+
return `${prefix}/api/c/${commentaryId}/books.json`;
|
|
288
|
+
}
|
|
289
|
+
export function bookChapterApiLink(translationId, commonName, chapterNumber, extension, prefix = "") {
|
|
290
|
+
return `${prefix}/api/${translationId}/${replaceSpacesWithUnderscores(
|
|
291
|
+
commonName
|
|
292
|
+
)}/${chapterNumber}.${extension}`;
|
|
293
|
+
}
|
|
294
|
+
export function bookCommentaryChapterApiLink(translationId, commonName, chapterNumber, extension, prefix = "") {
|
|
295
|
+
return `${prefix}/api/c/${translationId}/${replaceSpacesWithUnderscores(
|
|
296
|
+
commonName
|
|
297
|
+
)}/${chapterNumber}.${extension}`;
|
|
298
|
+
}
|
|
299
|
+
export function bookChapterAudioApiLink(translationId, bookId, chapterNumber, reader, prefix = "") {
|
|
300
|
+
return `${prefix}/api/${translationId}/${replaceSpacesWithUnderscores(
|
|
301
|
+
bookId
|
|
302
|
+
)}/${chapterNumber}.${reader}.mp3`;
|
|
303
|
+
}
|
|
304
|
+
export function jsonFile(path, content, mergable) {
|
|
305
|
+
return {
|
|
306
|
+
path,
|
|
307
|
+
content,
|
|
308
|
+
mergable
|
|
309
|
+
};
|
|
310
|
+
}
|
|
311
|
+
export function downloadedFile(path, url) {
|
|
312
|
+
return {
|
|
313
|
+
path,
|
|
314
|
+
content: () => fetch(url).then((response) => response.body)
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
export function replaceSpacesWithUnderscores(str) {
|
|
318
|
+
return str.replace(/[<>:"/\\|?*\s]/g, "_");
|
|
319
|
+
}
|
|
320
|
+
//# sourceMappingURL=api.js.map
|