waha-shared 1.0.1 → 1.0.3
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/README.md +2 -2
- package/dist/data/bibleAudios.d.ts +8 -0
- package/dist/data/bibleAudios.js +8 -0
- package/dist/data/bibleAudios.json +394 -0
- package/dist/data/bibleResources/bibleBooks.d.ts +3 -0
- package/dist/data/bibleResources/bibleBooks.js +7 -0
- package/dist/data/bibleResources/bibleBooks.json +6071 -0
- package/dist/data/bibleResources/bibleChaptersList.d.ts +2 -0
- package/dist/data/bibleResources/bibleChaptersList.js +8 -0
- package/dist/data/bibleResources/bibleChaptersList.json +1191 -0
- package/dist/data/bibleStatuses.d.ts +7 -0
- package/dist/data/bibleStatuses.js +8 -0
- package/dist/data/bibleStatuses.json +9196 -0
- package/dist/data/bibleTexts.d.ts +16 -0
- package/dist/data/bibleTexts.js +8 -0
- package/dist/data/bibleTexts.json +527 -0
- package/dist/data/countryResources/areas.d.ts +3 -0
- package/dist/data/countryResources/areas.js +7 -0
- package/dist/data/countryResources/areas.json +74 -0
- package/dist/data/countryResources/countries.d.ts +3 -0
- package/dist/data/countryResources/countries.js +7 -0
- package/dist/data/countryResources/countries.json +3362 -0
- package/dist/data/foundationsCurriculums.d.ts +5 -0
- package/dist/data/foundationsCurriculums.js +8 -0
- package/dist/data/foundationsCurriculums.json +130 -0
- package/dist/data/languageResources/countriesAndLanguages.d.ts +13 -0
- package/dist/data/languageResources/countriesAndLanguages.js +7 -0
- package/dist/data/languageResources/countriesAndLanguages.json +11718 -0
- package/dist/data/languageResources/phoneLanguages.d.ts +11 -0
- package/dist/data/languageResources/phoneLanguages.js +7 -0
- package/dist/data/languageResources/phoneLanguages.json +1532 -0
- package/dist/data/languages.d.ts +45 -0
- package/dist/data/languages.js +8 -0
- package/dist/data/languages.json +7045 -0
- package/dist/data/mediaDurations.d.ts +6 -0
- package/dist/data/mediaDurations.js +8 -0
- package/dist/data/mediaDurations.json +32364 -0
- package/dist/data/notification.d.ts +16 -0
- package/dist/data/notification.js +8 -0
- package/dist/data/notification.json +69 -0
- package/dist/data/numeralMaps.d.ts +13 -0
- package/dist/data/numeralMaps.js +8 -0
- package/dist/data/numeralMaps.json +26 -0
- package/dist/data/questions.d.ts +8 -0
- package/dist/data/questions.js +8 -0
- package/dist/data/questions.json +317 -0
- package/dist/data/questionsCurriculums.d.ts +8 -0
- package/dist/data/questionsCurriculums.js +8 -0
- package/dist/data/questionsCurriculums.json +753 -0
- package/dist/data/releaseNotes.d.ts +6 -0
- package/dist/data/releaseNotes.js +8 -0
- package/dist/data/releaseNotes.json +2381 -0
- package/dist/data/screenshots.d.ts +5 -0
- package/dist/data/screenshots.js +8 -0
- package/dist/data/screenshots.json +17 -0
- package/dist/data/sets.d.ts +14 -0
- package/dist/data/sets.js +8 -0
- package/dist/data/sets.json +12258 -0
- package/dist/data/specialIds.d.ts +18 -0
- package/dist/data/specialIds.js +7 -0
- package/dist/data/specialIds.json +72 -0
- package/dist/data/topicsCurriculums.d.ts +5 -0
- package/dist/data/topicsCurriculums.js +8 -0
- package/dist/data/topicsCurriculums.json +131 -0
- package/dist/data/typescript/appTranslations.d.ts +915 -0
- package/dist/data/typescript/appTranslations.js +315 -0
- package/dist/data/typescript/areas.d.ts +18 -0
- package/dist/data/typescript/areas.js +42 -0
- package/dist/data/typescript/aslTimestamps.d.ts +43 -0
- package/dist/data/typescript/aslTimestamps.js +31 -0
- package/dist/data/typescript/bibleAudioAvailableChapters.d.ts +3 -0
- package/dist/data/typescript/bibleAudioAvailableChapters.js +36 -0
- package/dist/data/typescript/bibleAudios.d.ts +21 -0
- package/dist/data/typescript/bibleAudios.js +23 -0
- package/dist/data/typescript/bibleBookNames.d.ts +3 -0
- package/dist/data/typescript/bibleBookNames.js +98 -0
- package/dist/data/typescript/bibleBooks.d.ts +69 -0
- package/dist/data/typescript/bibleBooks.js +56 -0
- package/dist/data/typescript/bibleChapters.d.ts +49 -0
- package/dist/data/typescript/bibleChapters.js +29 -0
- package/dist/data/typescript/bibleStatuses.d.ts +28 -0
- package/dist/data/typescript/bibleStatuses.js +39 -0
- package/dist/data/typescript/bibleTextAvailableChapters.d.ts +3 -0
- package/dist/data/typescript/bibleTextAvailableChapters.js +36 -0
- package/dist/data/typescript/bibleTexts.d.ts +53 -0
- package/dist/data/typescript/bibleTexts.js +54 -0
- package/dist/data/typescript/clones.d.ts +36 -0
- package/dist/data/typescript/clones.js +28 -0
- package/dist/data/typescript/countries.d.ts +98 -0
- package/dist/data/typescript/countries.js +149 -0
- package/dist/data/typescript/foundationsCurriculums.d.ts +12 -0
- package/dist/data/typescript/foundationsCurriculums.js +12 -0
- package/dist/data/typescript/introductionTranslations.d.ts +202 -0
- package/dist/data/typescript/introductionTranslations.js +53 -0
- package/dist/data/typescript/languages.d.ts +148 -0
- package/dist/data/typescript/languages.js +302 -0
- package/dist/data/typescript/mediaDurations.d.ts +23 -0
- package/dist/data/typescript/mediaDurations.js +72 -0
- package/dist/data/typescript/notification.d.ts +45 -0
- package/dist/data/typescript/notification.js +176 -0
- package/dist/data/typescript/numeralMaps.d.ts +58 -0
- package/dist/data/typescript/numeralMaps.js +71 -0
- package/dist/data/typescript/questionTranslations.d.ts +3 -0
- package/dist/data/typescript/questionTranslations.js +5 -0
- package/dist/data/typescript/questions.d.ts +21 -0
- package/dist/data/typescript/questions.js +18 -0
- package/dist/data/typescript/questionsCurriculums.d.ts +27 -0
- package/dist/data/typescript/questionsCurriculums.js +19 -0
- package/dist/data/typescript/releaseNotes.d.ts +15 -0
- package/dist/data/typescript/releaseNotes.js +9 -0
- package/dist/data/typescript/screenshots.d.ts +12 -0
- package/dist/data/typescript/screenshots.js +49 -0
- package/dist/data/typescript/setTranslations.d.ts +27 -0
- package/dist/data/typescript/setTranslations.js +32 -0
- package/dist/data/typescript/sets.d.ts +49 -0
- package/dist/data/typescript/sets.js +88 -0
- package/dist/data/typescript/topicsCurriculums.d.ts +12 -0
- package/dist/data/typescript/topicsCurriculums.js +12 -0
- package/dist/data/youtube/videos.d.ts +2 -0
- package/dist/data/youtube/videos.js +7 -0
- package/dist/data/youtube/videos.json +262 -0
- package/dist/functions/activeCampaign.d.ts +8 -0
- package/dist/functions/activeCampaign.js +97 -0
- package/dist/functions/bibleChapterUtils.d.ts +15 -0
- package/dist/functions/bibleChapterUtils.js +231 -0
- package/dist/functions/crowdin.d.ts +24 -0
- package/dist/functions/crowdin.js +34 -0
- package/dist/functions/languages.d.ts +24 -0
- package/dist/functions/languages.js +212 -0
- package/dist/functions/scripturePassages.d.ts +47 -0
- package/dist/functions/scripturePassages.js +261 -0
- package/dist/functions/sets.d.ts +30 -0
- package/dist/functions/sets.js +371 -0
- package/dist/translations/appTranslations.d.ts +306 -0
- package/dist/translations/appTranslations.js +8 -0
- package/dist/translations/appTranslations.json +10239 -0
- package/dist/translations/introductionTranslations.d.ts +43 -0
- package/dist/translations/introductionTranslations.js +8 -0
- package/dist/translations/introductionTranslations.json +422 -0
- package/dist/translations/questionTranslations.d.ts +2 -0
- package/dist/translations/questionTranslations.js +8 -0
- package/dist/translations/questionTranslations.json +1472 -0
- package/dist/translations/setTranslations.d.ts +10 -0
- package/dist/translations/setTranslations.js +8 -0
- package/dist/translations/setTranslations.json +30257 -0
- package/dist/types/analytics.d.ts +119 -0
- package/dist/types/analytics.js +2 -0
- package/dist/types/completions.d.ts +8 -0
- package/dist/types/completions.js +2 -0
- package/dist/types/feedback.d.ts +60 -0
- package/dist/types/feedback.js +27 -0
- package/dist/types/languages.d.ts +31 -0
- package/dist/types/languages.js +2 -0
- package/dist/types/notifications.d.ts +128 -0
- package/dist/types/notifications.js +30 -0
- package/dist/types/sets.d.ts +70 -0
- package/dist/types/sets.js +10 -0
- package/dist/types/users.d.ts +765 -0
- package/dist/types/users.js +137 -0
- package/package.json +2 -2
- package/.DS_Store +0 -0
- package/__init__.py +0 -0
- package/copy.ts +0 -37
- package/data/README.md +0 -45
- package/data/__init__.py +0 -0
- package/data/aslTimestamps.json +0 -192788
- package/data/bibleAudios.json +0 -394
- package/data/bibleAudios.ts +0 -4
- package/data/bibleResources/audioBibleLicenses.json +0 -6235
- package/data/bibleResources/bibleBooks.json +0 -6071
- package/data/bibleResources/bibleBooks.ts +0 -4
- package/data/bibleResources/bibleChaptersList.json +0 -1191
- package/data/bibleResources/bibleChaptersList.ts +0 -4
- package/data/bibleResources/textBibleLicenses.json +0 -14603
- package/data/bibleStatuses.json +0 -9196
- package/data/bibleStatuses.ts +0 -4
- package/data/bibleTexts.json +0 -527
- package/data/bibleTexts.ts +0 -4
- package/data/clones.json +0 -13
- package/data/countryResources/areas.json +0 -74
- package/data/countryResources/areas.ts +0 -4
- package/data/countryResources/countries.json +0 -3362
- package/data/countryResources/countries.ts +0 -4
- package/data/foundationsCurriculums.json +0 -130
- package/data/foundationsCurriculums.ts +0 -4
- package/data/languageResources/countriesAndLanguages.json +0 -11718
- package/data/languageResources/countriesAndLanguages.ts +0 -16
- package/data/languageResources/crowdinLanguages.json +0 -2172
- package/data/languageResources/iosVoiceOverLanguages.json +0 -64
- package/data/languageResources/iso6933LanguageCodes.json +0 -7927
- package/data/languageResources/mmsLanguages.json +0 -28164
- package/data/languageResources/phoneLanguages.json +0 -1532
- package/data/languageResources/phoneLanguages.ts +0 -14
- package/data/languages.json +0 -7045
- package/data/languages.ts +0 -4
- package/data/mediaDurations.json +0 -32364
- package/data/mediaDurations.ts +0 -4
- package/data/notification.json +0 -69
- package/data/notification.ts +0 -4
- package/data/numeralMaps.json +0 -26
- package/data/numeralMaps.ts +0 -4
- package/data/orphanedBibleTexts.json +0 -2747
- package/data/questions.json +0 -317
- package/data/questions.ts +0 -4
- package/data/questionsCurriculums.json +0 -753
- package/data/questionsCurriculums.ts +0 -4
- package/data/releaseNotes.json +0 -2381
- package/data/releaseNotes.ts +0 -4
- package/data/schemas/appTranslations.schema.json +0 -802
- package/data/schemas/areas.schema.json +0 -76
- package/data/schemas/aslTimestamps.schema.json +0 -59
- package/data/schemas/bibleAudios.schema.json +0 -37
- package/data/schemas/bibleBooks.schema.json +0 -112
- package/data/schemas/bibleChapters.schema.json +0 -61
- package/data/schemas/bibleStatuses.schema.json +0 -41
- package/data/schemas/bibleTexts.schema.json +0 -60
- package/data/schemas/clones.schema.json +0 -63
- package/data/schemas/countries.schema.json +0 -84
- package/data/schemas/foundationsCurriculums.schema.json +0 -20
- package/data/schemas/introductionTranslations.schema.json +0 -101
- package/data/schemas/languages.schema.json +0 -365
- package/data/schemas/mediaDurations.schema.json +0 -41
- package/data/schemas/notification.schema.json +0 -111
- package/data/schemas/numeralMaps.schema.json +0 -57
- package/data/schemas/questionTranslations.schema.json +0 -20
- package/data/schemas/questions.schema.json +0 -29
- package/data/schemas/questionsCurriculums.schema.json +0 -34
- package/data/schemas/releaseNotes.schema.json +0 -21
- package/data/schemas/screenshots.schema.json +0 -23
- package/data/schemas/setTranslations.schema.json +0 -70
- package/data/schemas/sets.schema.json +0 -109
- package/data/schemas/topicsCurriculums.schema.json +0 -20
- package/data/screenshots.json +0 -17
- package/data/screenshots.ts +0 -4
- package/data/sets.json +0 -12258
- package/data/sets.ts +0 -4
- package/data/specialIds.json +0 -72
- package/data/specialIds.ts +0 -19
- package/data/timings/som.json +0 -9150
- package/data/topicsCurriculums.json +0 -131
- package/data/topicsCurriculums.ts +0 -4
- package/data/typescript/appTranslations.ts +0 -322
- package/data/typescript/areas.ts +0 -45
- package/data/typescript/aslTimestamps.ts +0 -36
- package/data/typescript/bibleAudioAvailableChapters.ts +0 -35
- package/data/typescript/bibleAudios.ts +0 -32
- package/data/typescript/bibleBookNames.ts +0 -97
- package/data/typescript/bibleBooks.ts +0 -63
- package/data/typescript/bibleChapters.ts +0 -40
- package/data/typescript/bibleStatuses.ts +0 -54
- package/data/typescript/bibleTextAvailableChapters.ts +0 -35
- package/data/typescript/bibleTexts.ts +0 -63
- package/data/typescript/clones.ts +0 -35
- package/data/typescript/countries.ts +0 -152
- package/data/typescript/foundationsCurriculums.ts +0 -15
- package/data/typescript/introductionTranslations.ts +0 -60
- package/data/typescript/languages.ts +0 -369
- package/data/typescript/mediaDurations.ts +0 -89
- package/data/typescript/notification.ts +0 -189
- package/data/typescript/numeralMaps.ts +0 -74
- package/data/typescript/questionTranslations.ts +0 -6
- package/data/typescript/questions.ts +0 -25
- package/data/typescript/questionsCurriculums.ts +0 -26
- package/data/typescript/releaseNotes.ts +0 -10
- package/data/typescript/screenshots.ts +0 -52
- package/data/typescript/setTranslations.ts +0 -39
- package/data/typescript/sets.ts +0 -105
- package/data/typescript/topicsCurriculums.ts +0 -15
- package/data/youtube/playlists.json +0 -28
- package/data/youtube/videos.json +0 -262
- package/data/youtube/videos.ts +0 -2
- package/functions/activeCampaign.ts +0 -127
- package/functions/bibleChapterUtils.ts +0 -241
- package/functions/crowdin.ts +0 -51
- package/functions/languages.ts +0 -284
- package/functions/scripturePassages.ts +0 -368
- package/functions/sets.ts +0 -495
- package/translations/appTranslations.json +0 -10239
- package/translations/appTranslations.ts +0 -4
- package/translations/introductionTranslations.json +0 -422
- package/translations/introductionTranslations.ts +0 -4
- package/translations/questionTranslations.json +0 -1472
- package/translations/questionTranslations.ts +0 -4
- package/translations/setTranslations.json +0 -30257
- package/translations/setTranslations.ts +0 -4
- package/translations/spokenQuestionTranslations.json +0 -1472
- package/types/analytics.ts +0 -147
- package/types/completions.ts +0 -9
- package/types/feedback.ts +0 -27
- package/types/languages.ts +0 -37
- package/types/notifications.ts +0 -37
- package/types/sets.ts +0 -84
- package/types/users.ts +0 -162
|
@@ -1,368 +0,0 @@
|
|
|
1
|
-
import bibleStatuses from '../data/bibleStatuses'
|
|
2
|
-
import {
|
|
3
|
-
bibleChapters,
|
|
4
|
-
type BibleChapters,
|
|
5
|
-
} from '../data/typescript/bibleChapters'
|
|
6
|
-
import { numerals } from '../functions/languages'
|
|
7
|
-
import type { LanguageInfo } from '../types/languages'
|
|
8
|
-
|
|
9
|
-
type BibleChapter = BibleChapters[number]
|
|
10
|
-
|
|
11
|
-
export interface ScripturePassage {
|
|
12
|
-
passageId: string
|
|
13
|
-
bibleId: string
|
|
14
|
-
header: string
|
|
15
|
-
verses: BibleChapter['verses'][number][]
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Parses a verse range string like "GEN.1.1-GEN.1.25" or "JHN.3.16" Returns the
|
|
20
|
-
* start and end verse IDs
|
|
21
|
-
*/
|
|
22
|
-
function parseVerseRange(passageId: string): {
|
|
23
|
-
startBook: string
|
|
24
|
-
startChapter: string
|
|
25
|
-
startVerse: string
|
|
26
|
-
endBook: string
|
|
27
|
-
endChapter: string
|
|
28
|
-
endVerse: string
|
|
29
|
-
} {
|
|
30
|
-
// Handle single verse: "GEN.1.1" -> "GEN.1.1-GEN.1.1"
|
|
31
|
-
const parts = passageId.includes('-')
|
|
32
|
-
? passageId.split('-')
|
|
33
|
-
: [passageId, passageId]
|
|
34
|
-
|
|
35
|
-
const [startBook, startChapter, startVerse] = parts[0].split('.')
|
|
36
|
-
const [endBook, endChapter, endVerse] = parts[1].split('.')
|
|
37
|
-
|
|
38
|
-
return {
|
|
39
|
-
startBook,
|
|
40
|
-
startChapter,
|
|
41
|
-
startVerse,
|
|
42
|
-
endBook,
|
|
43
|
-
endChapter,
|
|
44
|
-
endVerse,
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/** Extracts verses from a chapter based on verse numbers */
|
|
49
|
-
function extractVersesFromChapter(
|
|
50
|
-
chapter: BibleChapter,
|
|
51
|
-
startVerse: number,
|
|
52
|
-
endVerse: number
|
|
53
|
-
): BibleChapter['verses'][number][] {
|
|
54
|
-
const verses = chapter.verses.filter((verse) => {
|
|
55
|
-
const verseIdPart = verse.verseId.split('.')[2]
|
|
56
|
-
|
|
57
|
-
// Handle verse ranges (e.g., "7-9")
|
|
58
|
-
if (verseIdPart.includes('-')) {
|
|
59
|
-
const [rangeStart, rangeEnd] = verseIdPart
|
|
60
|
-
.split('-')
|
|
61
|
-
.map((v) => parseInt(v))
|
|
62
|
-
// Check if the requested range overlaps with this verse range
|
|
63
|
-
return rangeEnd >= startVerse && rangeStart <= endVerse
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
// Handle single verse numbers
|
|
67
|
-
const verseNum = parseInt(verseIdPart)
|
|
68
|
-
return verseNum >= startVerse && verseNum <= endVerse
|
|
69
|
-
})
|
|
70
|
-
|
|
71
|
-
return verses
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* Condenses a list of USFM passage IDs into a readable string format. Groups
|
|
76
|
-
* consecutive passages from the same book together.
|
|
77
|
-
*
|
|
78
|
-
* @example
|
|
79
|
-
* ["GEN.1.1-GEN.1.25"] -> "Genesis 1: 1-25"
|
|
80
|
-
* ["GEN.1.1-GEN.1.25", "GEN.2.4-GEN.2.7", "EXO.3.3-EXO.3.25"] -> "Genesis 1: 1-25, 2: 4-7, Exodus 3: 3-25"
|
|
81
|
-
* ["JHN.1.1"] -> "John 1: 1"
|
|
82
|
-
*/
|
|
83
|
-
export function getPassagesString(
|
|
84
|
-
passageIds: string[] | undefined,
|
|
85
|
-
language: LanguageInfo
|
|
86
|
-
): string {
|
|
87
|
-
if (!passageIds || passageIds.length === 0) return ''
|
|
88
|
-
|
|
89
|
-
const parts: string[] = []
|
|
90
|
-
let currentBook: string | null = null
|
|
91
|
-
|
|
92
|
-
for (const passageId of passageIds) {
|
|
93
|
-
const { startBook, startChapter, startVerse, endChapter, endVerse } =
|
|
94
|
-
parseVerseRange(passageId)
|
|
95
|
-
|
|
96
|
-
let bookName: string | undefined =
|
|
97
|
-
// American sign language should use English book names.
|
|
98
|
-
language.languageId === 'ase'
|
|
99
|
-
? bibleStatuses.BSB.bookNames[startBook]
|
|
100
|
-
: language.bible.bookNames[startBook]
|
|
101
|
-
if (!bookName) {
|
|
102
|
-
bookName = language.bibleFallback?.bookNames[startBook]
|
|
103
|
-
if (!bookName) continue
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
// New book - include book name
|
|
107
|
-
if (currentBook !== startBook) {
|
|
108
|
-
currentBook = startBook
|
|
109
|
-
|
|
110
|
-
// Same chapter
|
|
111
|
-
if (startChapter === endChapter) {
|
|
112
|
-
if (startVerse === endVerse) {
|
|
113
|
-
parts.push(`${bookName} ${startChapter}: ${startVerse}`)
|
|
114
|
-
} else {
|
|
115
|
-
parts.push(`${bookName} ${startChapter}: ${startVerse}-${endVerse}`)
|
|
116
|
-
}
|
|
117
|
-
} else {
|
|
118
|
-
// Different chapters
|
|
119
|
-
parts.push(
|
|
120
|
-
`${bookName} ${startChapter}: ${startVerse}-${endChapter}: ${endVerse}`
|
|
121
|
-
)
|
|
122
|
-
}
|
|
123
|
-
} else {
|
|
124
|
-
// Same book - omit book name
|
|
125
|
-
if (startChapter === endChapter) {
|
|
126
|
-
if (startVerse === endVerse) {
|
|
127
|
-
parts.push(`${startChapter}: ${startVerse}`)
|
|
128
|
-
} else {
|
|
129
|
-
parts.push(`${startChapter}: ${startVerse}-${endVerse}`)
|
|
130
|
-
}
|
|
131
|
-
} else {
|
|
132
|
-
// Different chapters
|
|
133
|
-
parts.push(`${startChapter}: ${startVerse}-${endChapter}: ${endVerse}`)
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
return numerals(parts.join(', '), language.script)
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
export interface GetChapterParams {
|
|
142
|
-
chapterId: string
|
|
143
|
-
bibleId: string
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
export type GetChapter = (
|
|
147
|
-
params: GetChapterParams
|
|
148
|
-
) => Promise<BibleChapter | undefined>
|
|
149
|
-
|
|
150
|
-
interface GetScripturePassageParams {
|
|
151
|
-
bibleId: string
|
|
152
|
-
bibleFallbackId: string | undefined
|
|
153
|
-
passageId: string
|
|
154
|
-
getChapter: GetChapter
|
|
155
|
-
languageInfo: LanguageInfo
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
/**
|
|
159
|
-
* Gets a scripture passage by extracting verses from chapters This is the core
|
|
160
|
-
* parsing logic, independent of the data source
|
|
161
|
-
*/
|
|
162
|
-
async function getScripturePassage({
|
|
163
|
-
bibleId,
|
|
164
|
-
bibleFallbackId,
|
|
165
|
-
passageId,
|
|
166
|
-
getChapter,
|
|
167
|
-
languageInfo,
|
|
168
|
-
}: GetScripturePassageParams): Promise<ScripturePassage | undefined> {
|
|
169
|
-
try {
|
|
170
|
-
const {
|
|
171
|
-
startBook,
|
|
172
|
-
startChapter,
|
|
173
|
-
startVerse,
|
|
174
|
-
endBook,
|
|
175
|
-
endChapter,
|
|
176
|
-
endVerse,
|
|
177
|
-
} = parseVerseRange(passageId)
|
|
178
|
-
|
|
179
|
-
const startVerseNum = parseInt(startVerse)
|
|
180
|
-
const endVerseNum = parseInt(endVerse)
|
|
181
|
-
|
|
182
|
-
// Same chapter - simple case
|
|
183
|
-
if (startBook === endBook && startChapter === endChapter) {
|
|
184
|
-
const chapterId = `${startBook}.${startChapter}`
|
|
185
|
-
let chapter = await getChapter({ chapterId, bibleId })
|
|
186
|
-
|
|
187
|
-
if (!chapter && bibleFallbackId)
|
|
188
|
-
chapter = await getChapter({ chapterId, bibleId: bibleFallbackId })
|
|
189
|
-
|
|
190
|
-
if (!chapter) {
|
|
191
|
-
console.warn(
|
|
192
|
-
`Chapter not found: ${bibleId}.${chapterId} for passage ${passageId}`
|
|
193
|
-
)
|
|
194
|
-
return
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
const verses = extractVersesFromChapter(
|
|
198
|
-
chapter,
|
|
199
|
-
startVerseNum,
|
|
200
|
-
endVerseNum
|
|
201
|
-
)
|
|
202
|
-
|
|
203
|
-
if (verses.length === 0) {
|
|
204
|
-
console.warn(`No verses found for passage ${passageId}`)
|
|
205
|
-
return
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
return {
|
|
209
|
-
passageId,
|
|
210
|
-
bibleId,
|
|
211
|
-
header: getPassagesString([passageId], languageInfo),
|
|
212
|
-
verses,
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
// Multi-chapter passage (rare but possible)
|
|
217
|
-
// Example: GEN.1.26-GEN.2.3
|
|
218
|
-
const chapters: BibleChapter[] = []
|
|
219
|
-
|
|
220
|
-
// Get all chapters in the range
|
|
221
|
-
const startChapterNum = parseInt(startChapter)
|
|
222
|
-
const endChapterNum = parseInt(endChapter)
|
|
223
|
-
|
|
224
|
-
for (let i = startChapterNum; i <= endChapterNum; i++) {
|
|
225
|
-
const chapterId = `${startBook}.${i}`
|
|
226
|
-
let chapter = await getChapter({ chapterId, bibleId })
|
|
227
|
-
if (!chapter && bibleFallbackId)
|
|
228
|
-
chapter = await getChapter({ chapterId, bibleId: bibleFallbackId })
|
|
229
|
-
|
|
230
|
-
if (chapter) {
|
|
231
|
-
chapters.push(chapter)
|
|
232
|
-
} else {
|
|
233
|
-
console.warn(`Missing chapter in range: ${bibleId}.${chapterId}`)
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
if (chapters.length === 0) {
|
|
238
|
-
return
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
// Extract verses from each chapter
|
|
242
|
-
const allVerses: BibleChapter['verses'][number][] = []
|
|
243
|
-
|
|
244
|
-
chapters.forEach((chapter, index) => {
|
|
245
|
-
if (index === 0) {
|
|
246
|
-
// First chapter - from startVerse to end
|
|
247
|
-
const lastVerse = Math.max(
|
|
248
|
-
...chapter.verses.map((v) => parseInt(v.verseId.split('.')[2]))
|
|
249
|
-
)
|
|
250
|
-
allVerses.push(
|
|
251
|
-
...extractVersesFromChapter(chapter, startVerseNum, lastVerse)
|
|
252
|
-
)
|
|
253
|
-
} else if (index === chapters.length - 1) {
|
|
254
|
-
// Last chapter - from beginning to endVerse
|
|
255
|
-
allVerses.push(...extractVersesFromChapter(chapter, 1, endVerseNum))
|
|
256
|
-
} else {
|
|
257
|
-
// Middle chapters - all verses
|
|
258
|
-
allVerses.push(...chapter.verses)
|
|
259
|
-
}
|
|
260
|
-
})
|
|
261
|
-
|
|
262
|
-
return {
|
|
263
|
-
passageId,
|
|
264
|
-
bibleId,
|
|
265
|
-
header: getPassagesString([passageId], languageInfo),
|
|
266
|
-
verses: allVerses,
|
|
267
|
-
}
|
|
268
|
-
} catch (error) {
|
|
269
|
-
console.error(
|
|
270
|
-
`Error getting scripture passage ${passageId} in ${bibleId}`,
|
|
271
|
-
error
|
|
272
|
-
)
|
|
273
|
-
return
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
interface GetLessonScriptureParams {
|
|
278
|
-
bibleId: string
|
|
279
|
-
bibleFallbackId: string | undefined
|
|
280
|
-
passageIds: string[]
|
|
281
|
-
getChapter: (params: GetChapterParams) => Promise<BibleChapter | undefined>
|
|
282
|
-
languageInfo: LanguageInfo
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
/**
|
|
286
|
-
* Gets multiple scripture passages efficiently (Future optimization: could
|
|
287
|
-
* batch the chapter fetches)
|
|
288
|
-
*/
|
|
289
|
-
export async function getLessonScripture(
|
|
290
|
-
params: GetLessonScriptureParams
|
|
291
|
-
): Promise<Array<ScripturePassage | undefined>> {
|
|
292
|
-
const passages = await Promise.all(
|
|
293
|
-
params.passageIds.map((passageId) =>
|
|
294
|
-
getScripturePassage({ ...params, passageId })
|
|
295
|
-
)
|
|
296
|
-
)
|
|
297
|
-
return passages
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
export function parseBibleSnapshot(
|
|
301
|
-
snapshot: any,
|
|
302
|
-
bible: string
|
|
303
|
-
): BibleChapters {
|
|
304
|
-
const validChapters: BibleChapters = []
|
|
305
|
-
|
|
306
|
-
if (!snapshot) {
|
|
307
|
-
console.warn('No snapshot for', bible)
|
|
308
|
-
return []
|
|
309
|
-
} else if (snapshot.empty) {
|
|
310
|
-
console.warn('Empty snapshot for', bible)
|
|
311
|
-
return []
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
for (const doc of snapshot.docs) {
|
|
315
|
-
const chapterParse = bibleChapters.element.safeParse(doc.data())
|
|
316
|
-
if (!chapterParse.success) {
|
|
317
|
-
console.warn(
|
|
318
|
-
'Skipping invalid bible chapter document',
|
|
319
|
-
doc.id,
|
|
320
|
-
chapterParse.error.issues.map(
|
|
321
|
-
(i) => `${i.path.join('.')}: ${i.message}`
|
|
322
|
-
)
|
|
323
|
-
)
|
|
324
|
-
} else {
|
|
325
|
-
validChapters.push(chapterParse.data)
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
if (validChapters.length === 0) {
|
|
330
|
-
console.warn('No valid chapters for', bible)
|
|
331
|
-
return []
|
|
332
|
-
} else {
|
|
333
|
-
return validChapters
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
/**
|
|
338
|
-
* Converts a verse number to a superscript string. This is useful for
|
|
339
|
-
* displaying verse numbers in a more visually appealing way. For example, "1"
|
|
340
|
-
* becomes "¹", "2" becomes "²", etc
|
|
341
|
-
*
|
|
342
|
-
* @param num The verse number to convert to superscript.
|
|
343
|
-
* @returns The superscript string representation of the verse number.
|
|
344
|
-
*/
|
|
345
|
-
export function verseToSuperscript(num: string | undefined) {
|
|
346
|
-
const superscriptObj = {
|
|
347
|
-
'0': '⁰',
|
|
348
|
-
'1': '¹',
|
|
349
|
-
'2': '²',
|
|
350
|
-
'3': '³',
|
|
351
|
-
'4': '⁴',
|
|
352
|
-
'5': '⁵',
|
|
353
|
-
'6': '⁶',
|
|
354
|
-
'7': '⁷',
|
|
355
|
-
'8': '⁸',
|
|
356
|
-
'9': '⁹',
|
|
357
|
-
'-': '⁻',
|
|
358
|
-
}
|
|
359
|
-
if (!num) return ''
|
|
360
|
-
return num
|
|
361
|
-
.split('')
|
|
362
|
-
.map((digit) => {
|
|
363
|
-
if (digit in superscriptObj)
|
|
364
|
-
return superscriptObj[digit as keyof typeof superscriptObj]
|
|
365
|
-
else return digit
|
|
366
|
-
})
|
|
367
|
-
.join('')
|
|
368
|
-
}
|