@youversion/platform-core 1.1.0 → 1.2.0
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/.turbo/turbo-build.log +7 -7
- package/CHANGELOG.md +10 -0
- package/dist/index.cjs +6 -2
- package/dist/index.d.cts +18 -3
- package/dist/index.d.ts +18 -3
- package/dist/index.js +6 -2
- package/package.json +1 -1
- package/src/__tests__/MockBibles.ts +14 -25
- package/src/__tests__/bible.test.ts +11 -0
- package/src/bible.ts +6 -2
- package/src/schemas/book.ts +12 -0
- package/src/types/index.ts +1 -1
- package/src/types/book.ts +0 -116
- package/src/types/chapter.ts +0 -5
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @youversion/platform-core@1.
|
|
2
|
+
> @youversion/platform-core@1.2.0 build /home/runner/work/platform-sdk-react/platform-sdk-react/packages/core
|
|
3
3
|
> tsup src/index.ts --format cjs,esm --dts
|
|
4
4
|
|
|
5
5
|
[34mCLI[39m Building entry: src/index.ts
|
|
@@ -8,11 +8,11 @@
|
|
|
8
8
|
[34mCLI[39m Target: es2022
|
|
9
9
|
[34mCJS[39m Build start
|
|
10
10
|
[34mESM[39m Build start
|
|
11
|
-
[32mCJS[39m [1mdist/index.cjs [22m[32m42.
|
|
11
|
+
[32mCJS[39m [1mdist/index.cjs [22m[32m42.87 KB[39m
|
|
12
12
|
[32mCJS[39m ⚡️ Build success in 31ms
|
|
13
|
-
[32mESM[39m [1mdist/index.js [22m[
|
|
14
|
-
[32mESM[39m ⚡️ Build success in
|
|
13
|
+
[32mESM[39m [1mdist/index.js [22m[32m41.06 KB[39m
|
|
14
|
+
[32mESM[39m ⚡️ Build success in 32ms
|
|
15
15
|
[34mDTS[39m Build start
|
|
16
|
-
[32mDTS[39m ⚡️ Build success in
|
|
17
|
-
[32mDTS[39m [1mdist/index.d.cts [22m[32m32.
|
|
18
|
-
[32mDTS[39m [1mdist/index.d.ts [22m[32m32.
|
|
16
|
+
[32mDTS[39m ⚡️ Build success in 1751ms
|
|
17
|
+
[32mDTS[39m [1mdist/index.d.cts [22m[32m32.80 KB[39m
|
|
18
|
+
[32mDTS[39m [1mdist/index.d.ts [22m[32m32.80 KB[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# @youversion/platform-core
|
|
2
2
|
|
|
3
|
+
## 1.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- a8a5dd7: feat: Add intro metadata to BibleBook
|
|
8
|
+
- Added optional `intro` field to BibleBook schema for retrieving book introduction metadata
|
|
9
|
+
- The intro field includes `id`, `passage_id`, and `title` properties when available
|
|
10
|
+
- Simplified type definitions by removing duplicate type files and using Zod schemas as single source of truth
|
|
11
|
+
- Updated Bible mocks and tests to cover the new intro field
|
|
12
|
+
|
|
3
13
|
## 1.1.0
|
|
4
14
|
|
|
5
15
|
### Minor Changes
|
package/dist/index.cjs
CHANGED
|
@@ -232,7 +232,9 @@ var BibleClient = class {
|
|
|
232
232
|
* Fetches all books for a given Bible version.
|
|
233
233
|
* @param versionId The version ID.
|
|
234
234
|
* @param canon Optional canon filter ("old_testament", 'new_testament', 'deuterocanon').
|
|
235
|
-
* @returns An array of BibleBook objects.
|
|
235
|
+
* @returns An array of BibleBook objects. Each book may include an optional `intro` field
|
|
236
|
+
* containing metadata (id, passage_id, title) for the book's introduction when
|
|
237
|
+
* available in the Bible version.
|
|
236
238
|
*/
|
|
237
239
|
async getBooks(versionId, canon) {
|
|
238
240
|
this.versionIdSchema.parse(versionId);
|
|
@@ -244,7 +246,9 @@ var BibleClient = class {
|
|
|
244
246
|
* Fetches a specific book by USFM code for a given version.
|
|
245
247
|
* @param versionId The version ID.
|
|
246
248
|
* @param book The Book Identifier code of the book.
|
|
247
|
-
* @returns The requested BibleBook object
|
|
249
|
+
* @returns The requested BibleBook object, which may include an optional `intro` field
|
|
250
|
+
* containing metadata (id, passage_id, title) for the book's introduction when
|
|
251
|
+
* available. Use the `passage_id` with `getPassage()` to fetch intro content.
|
|
248
252
|
*/
|
|
249
253
|
async getBook(versionId, book) {
|
|
250
254
|
this.versionIdSchema.parse(versionId);
|
package/dist/index.d.cts
CHANGED
|
@@ -23,6 +23,12 @@ declare const CanonSchema: z.ZodEnum<{
|
|
|
23
23
|
deuterocanon: "deuterocanon";
|
|
24
24
|
}>;
|
|
25
25
|
type Canon = Readonly<z.infer<typeof CanonSchema>>;
|
|
26
|
+
declare const BibleBookIntroSchema: z.ZodObject<{
|
|
27
|
+
id: z.ZodString;
|
|
28
|
+
passage_id: z.ZodString;
|
|
29
|
+
title: z.ZodString;
|
|
30
|
+
}, z.core.$strip>;
|
|
31
|
+
type BibleBookIntro = Readonly<z.infer<typeof BibleBookIntroSchema>>;
|
|
26
32
|
declare const BookUsfmSchema: z.ZodUnion<readonly [...z.ZodLiteral<"GEN" | "EXO" | "LEV" | "NUM" | "DEU" | "JOS" | "JDG" | "RUT" | "1SA" | "2SA" | "1KI" | "2KI" | "1CH" | "2CH" | "EZR" | "NEH" | "EST" | "JOB" | "PSA" | "PRO" | "ECC" | "SNG" | "ISA" | "JER" | "LAM" | "EZK" | "DAN" | "HOS" | "JOL" | "AMO" | "OBA" | "JON" | "MIC" | "NAM" | "HAB" | "ZEP" | "HAG" | "ZEC" | "MAL" | "MAT" | "MRK" | "LUK" | "JHN" | "ACT" | "ROM" | "1CO" | "2CO" | "GAL" | "EPH" | "PHP" | "COL" | "1TH" | "2TH" | "1TI" | "2TI" | "TIT" | "PHM" | "HEB" | "JAS" | "1PE" | "2PE" | "1JN" | "2JN" | "3JN" | "JUD" | "REV" | "TOB" | "JDT" | "ESG" | "WIS" | "SIR" | "BAR" | "LJE" | "S3Y" | "SUS" | "BEL" | "1MA" | "2MA" | "3MA" | "4MA" | "1ES" | "2ES" | "MAN" | "PS2" | "ODA" | "PSS" | "3ES" | "EZA" | "5EZ" | "6EZ" | "DAG" | "PS3" | "2BA" | "LBA" | "JUB" | "ENO" | "1MQ" | "2MQ" | "3MQ" | "REP" | "4BA" | "LAO" | "LKA">[], z.ZodType<string & {}, unknown, z.core.$ZodTypeInternals<string & {}, unknown>>]>;
|
|
27
33
|
type BookUsfm = z.infer<typeof BookUsfmSchema>;
|
|
28
34
|
declare const BibleBookSchema: z.ZodObject<{
|
|
@@ -35,6 +41,11 @@ declare const BibleBookSchema: z.ZodObject<{
|
|
|
35
41
|
new_testament: "new_testament";
|
|
36
42
|
deuterocanon: "deuterocanon";
|
|
37
43
|
}>;
|
|
44
|
+
intro: z.ZodOptional<z.ZodObject<{
|
|
45
|
+
id: z.ZodString;
|
|
46
|
+
passage_id: z.ZodString;
|
|
47
|
+
title: z.ZodString;
|
|
48
|
+
}, z.core.$strip>>;
|
|
38
49
|
chapters: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
39
50
|
id: z.ZodString;
|
|
40
51
|
passage_id: z.ZodString;
|
|
@@ -337,14 +348,18 @@ declare class BibleClient {
|
|
|
337
348
|
* Fetches all books for a given Bible version.
|
|
338
349
|
* @param versionId The version ID.
|
|
339
350
|
* @param canon Optional canon filter ("old_testament", 'new_testament', 'deuterocanon').
|
|
340
|
-
* @returns An array of BibleBook objects.
|
|
351
|
+
* @returns An array of BibleBook objects. Each book may include an optional `intro` field
|
|
352
|
+
* containing metadata (id, passage_id, title) for the book's introduction when
|
|
353
|
+
* available in the Bible version.
|
|
341
354
|
*/
|
|
342
355
|
getBooks(versionId: number, canon?: CANON): Promise<Collection<BibleBook>>;
|
|
343
356
|
/**
|
|
344
357
|
* Fetches a specific book by USFM code for a given version.
|
|
345
358
|
* @param versionId The version ID.
|
|
346
359
|
* @param book The Book Identifier code of the book.
|
|
347
|
-
* @returns The requested BibleBook object
|
|
360
|
+
* @returns The requested BibleBook object, which may include an optional `intro` field
|
|
361
|
+
* containing metadata (id, passage_id, title) for the book's introduction when
|
|
362
|
+
* available. Use the `passage_id` with `getPassage()` to fetch intro content.
|
|
348
363
|
*/
|
|
349
364
|
getBook(versionId: number, book: string): Promise<BibleBook>;
|
|
350
365
|
/**
|
|
@@ -706,4 +721,4 @@ declare const BOOK_IDS: readonly ["GEN", "EXO", "LEV", "NUM", "DEU", "JOS", "JDG
|
|
|
706
721
|
*/
|
|
707
722
|
declare const BOOK_CANON: Record<BookUsfm, Canon>;
|
|
708
723
|
|
|
709
|
-
export { ApiClient, type ApiConfig, type AuthenticationScopes, type AuthenticationState, BOOK_CANON, BOOK_IDS, type BibleBook, type BibleChapter, BibleClient, type BibleIndex, type BibleIndexBook, type BibleIndexChapter, type BibleIndexVerse, type BiblePassage, type BibleVerse, type BibleVersion, type CANON, type Collection, type CreateHighlight, type DeleteHighlightOptions, type GetHighlightsOptions, type GetLanguagesOptions, type Highlight, type HighlightColor, HighlightsClient, type Language, LanguagesClient, MemoryStorageStrategy, SessionStorageStrategy, SignInWithYouVersionPermission, type SignInWithYouVersionPermissionValues, SignInWithYouVersionResult, type StorageStrategy, type User, type VOTD, YouVersionAPI, YouVersionAPIUsers, YouVersionPlatformConfiguration, YouVersionUserInfo, type YouVersionUserInfoJSON };
|
|
724
|
+
export { ApiClient, type ApiConfig, type AuthenticationScopes, type AuthenticationState, BOOK_CANON, BOOK_IDS, type BibleBook, type BibleBookIntro, type BibleChapter, BibleClient, type BibleIndex, type BibleIndexBook, type BibleIndexChapter, type BibleIndexVerse, type BiblePassage, type BibleVerse, type BibleVersion, type CANON, type Collection, type CreateHighlight, type DeleteHighlightOptions, type GetHighlightsOptions, type GetLanguagesOptions, type Highlight, type HighlightColor, HighlightsClient, type Language, LanguagesClient, MemoryStorageStrategy, SessionStorageStrategy, SignInWithYouVersionPermission, type SignInWithYouVersionPermissionValues, SignInWithYouVersionResult, type StorageStrategy, type User, type VOTD, YouVersionAPI, YouVersionAPIUsers, YouVersionPlatformConfiguration, YouVersionUserInfo, type YouVersionUserInfoJSON };
|
package/dist/index.d.ts
CHANGED
|
@@ -23,6 +23,12 @@ declare const CanonSchema: z.ZodEnum<{
|
|
|
23
23
|
deuterocanon: "deuterocanon";
|
|
24
24
|
}>;
|
|
25
25
|
type Canon = Readonly<z.infer<typeof CanonSchema>>;
|
|
26
|
+
declare const BibleBookIntroSchema: z.ZodObject<{
|
|
27
|
+
id: z.ZodString;
|
|
28
|
+
passage_id: z.ZodString;
|
|
29
|
+
title: z.ZodString;
|
|
30
|
+
}, z.core.$strip>;
|
|
31
|
+
type BibleBookIntro = Readonly<z.infer<typeof BibleBookIntroSchema>>;
|
|
26
32
|
declare const BookUsfmSchema: z.ZodUnion<readonly [...z.ZodLiteral<"GEN" | "EXO" | "LEV" | "NUM" | "DEU" | "JOS" | "JDG" | "RUT" | "1SA" | "2SA" | "1KI" | "2KI" | "1CH" | "2CH" | "EZR" | "NEH" | "EST" | "JOB" | "PSA" | "PRO" | "ECC" | "SNG" | "ISA" | "JER" | "LAM" | "EZK" | "DAN" | "HOS" | "JOL" | "AMO" | "OBA" | "JON" | "MIC" | "NAM" | "HAB" | "ZEP" | "HAG" | "ZEC" | "MAL" | "MAT" | "MRK" | "LUK" | "JHN" | "ACT" | "ROM" | "1CO" | "2CO" | "GAL" | "EPH" | "PHP" | "COL" | "1TH" | "2TH" | "1TI" | "2TI" | "TIT" | "PHM" | "HEB" | "JAS" | "1PE" | "2PE" | "1JN" | "2JN" | "3JN" | "JUD" | "REV" | "TOB" | "JDT" | "ESG" | "WIS" | "SIR" | "BAR" | "LJE" | "S3Y" | "SUS" | "BEL" | "1MA" | "2MA" | "3MA" | "4MA" | "1ES" | "2ES" | "MAN" | "PS2" | "ODA" | "PSS" | "3ES" | "EZA" | "5EZ" | "6EZ" | "DAG" | "PS3" | "2BA" | "LBA" | "JUB" | "ENO" | "1MQ" | "2MQ" | "3MQ" | "REP" | "4BA" | "LAO" | "LKA">[], z.ZodType<string & {}, unknown, z.core.$ZodTypeInternals<string & {}, unknown>>]>;
|
|
27
33
|
type BookUsfm = z.infer<typeof BookUsfmSchema>;
|
|
28
34
|
declare const BibleBookSchema: z.ZodObject<{
|
|
@@ -35,6 +41,11 @@ declare const BibleBookSchema: z.ZodObject<{
|
|
|
35
41
|
new_testament: "new_testament";
|
|
36
42
|
deuterocanon: "deuterocanon";
|
|
37
43
|
}>;
|
|
44
|
+
intro: z.ZodOptional<z.ZodObject<{
|
|
45
|
+
id: z.ZodString;
|
|
46
|
+
passage_id: z.ZodString;
|
|
47
|
+
title: z.ZodString;
|
|
48
|
+
}, z.core.$strip>>;
|
|
38
49
|
chapters: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
39
50
|
id: z.ZodString;
|
|
40
51
|
passage_id: z.ZodString;
|
|
@@ -337,14 +348,18 @@ declare class BibleClient {
|
|
|
337
348
|
* Fetches all books for a given Bible version.
|
|
338
349
|
* @param versionId The version ID.
|
|
339
350
|
* @param canon Optional canon filter ("old_testament", 'new_testament', 'deuterocanon').
|
|
340
|
-
* @returns An array of BibleBook objects.
|
|
351
|
+
* @returns An array of BibleBook objects. Each book may include an optional `intro` field
|
|
352
|
+
* containing metadata (id, passage_id, title) for the book's introduction when
|
|
353
|
+
* available in the Bible version.
|
|
341
354
|
*/
|
|
342
355
|
getBooks(versionId: number, canon?: CANON): Promise<Collection<BibleBook>>;
|
|
343
356
|
/**
|
|
344
357
|
* Fetches a specific book by USFM code for a given version.
|
|
345
358
|
* @param versionId The version ID.
|
|
346
359
|
* @param book The Book Identifier code of the book.
|
|
347
|
-
* @returns The requested BibleBook object
|
|
360
|
+
* @returns The requested BibleBook object, which may include an optional `intro` field
|
|
361
|
+
* containing metadata (id, passage_id, title) for the book's introduction when
|
|
362
|
+
* available. Use the `passage_id` with `getPassage()` to fetch intro content.
|
|
348
363
|
*/
|
|
349
364
|
getBook(versionId: number, book: string): Promise<BibleBook>;
|
|
350
365
|
/**
|
|
@@ -706,4 +721,4 @@ declare const BOOK_IDS: readonly ["GEN", "EXO", "LEV", "NUM", "DEU", "JOS", "JDG
|
|
|
706
721
|
*/
|
|
707
722
|
declare const BOOK_CANON: Record<BookUsfm, Canon>;
|
|
708
723
|
|
|
709
|
-
export { ApiClient, type ApiConfig, type AuthenticationScopes, type AuthenticationState, BOOK_CANON, BOOK_IDS, type BibleBook, type BibleChapter, BibleClient, type BibleIndex, type BibleIndexBook, type BibleIndexChapter, type BibleIndexVerse, type BiblePassage, type BibleVerse, type BibleVersion, type CANON, type Collection, type CreateHighlight, type DeleteHighlightOptions, type GetHighlightsOptions, type GetLanguagesOptions, type Highlight, type HighlightColor, HighlightsClient, type Language, LanguagesClient, MemoryStorageStrategy, SessionStorageStrategy, SignInWithYouVersionPermission, type SignInWithYouVersionPermissionValues, SignInWithYouVersionResult, type StorageStrategy, type User, type VOTD, YouVersionAPI, YouVersionAPIUsers, YouVersionPlatformConfiguration, YouVersionUserInfo, type YouVersionUserInfoJSON };
|
|
724
|
+
export { ApiClient, type ApiConfig, type AuthenticationScopes, type AuthenticationState, BOOK_CANON, BOOK_IDS, type BibleBook, type BibleBookIntro, type BibleChapter, BibleClient, type BibleIndex, type BibleIndexBook, type BibleIndexChapter, type BibleIndexVerse, type BiblePassage, type BibleVerse, type BibleVersion, type CANON, type Collection, type CreateHighlight, type DeleteHighlightOptions, type GetHighlightsOptions, type GetLanguagesOptions, type Highlight, type HighlightColor, HighlightsClient, type Language, LanguagesClient, MemoryStorageStrategy, SessionStorageStrategy, SignInWithYouVersionPermission, type SignInWithYouVersionPermissionValues, SignInWithYouVersionResult, type StorageStrategy, type User, type VOTD, YouVersionAPI, YouVersionAPIUsers, YouVersionPlatformConfiguration, YouVersionUserInfo, type YouVersionUserInfoJSON };
|
package/dist/index.js
CHANGED
|
@@ -193,7 +193,9 @@ var BibleClient = class {
|
|
|
193
193
|
* Fetches all books for a given Bible version.
|
|
194
194
|
* @param versionId The version ID.
|
|
195
195
|
* @param canon Optional canon filter ("old_testament", 'new_testament', 'deuterocanon').
|
|
196
|
-
* @returns An array of BibleBook objects.
|
|
196
|
+
* @returns An array of BibleBook objects. Each book may include an optional `intro` field
|
|
197
|
+
* containing metadata (id, passage_id, title) for the book's introduction when
|
|
198
|
+
* available in the Bible version.
|
|
197
199
|
*/
|
|
198
200
|
async getBooks(versionId, canon) {
|
|
199
201
|
this.versionIdSchema.parse(versionId);
|
|
@@ -205,7 +207,9 @@ var BibleClient = class {
|
|
|
205
207
|
* Fetches a specific book by USFM code for a given version.
|
|
206
208
|
* @param versionId The version ID.
|
|
207
209
|
* @param book The Book Identifier code of the book.
|
|
208
|
-
* @returns The requested BibleBook object
|
|
210
|
+
* @returns The requested BibleBook object, which may include an optional `intro` field
|
|
211
|
+
* containing metadata (id, passage_id, title) for the book's introduction when
|
|
212
|
+
* available. Use the `passage_id` with `getPassage()` to fetch intro content.
|
|
209
213
|
*/
|
|
210
214
|
async getBook(versionId, book) {
|
|
211
215
|
this.versionIdSchema.parse(versionId);
|
package/package.json
CHANGED
|
@@ -1,36 +1,13 @@
|
|
|
1
1
|
import { mockGenesisChapters } from './MockChapters';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
id: 'GEN',
|
|
5
|
-
title: 'Genesis',
|
|
6
|
-
full_title: 'The First Book of Moses, Called Genesis',
|
|
7
|
-
abbreviation: 'Gen',
|
|
8
|
-
canon: 'old_testament',
|
|
9
|
-
chapters: mockGenesisChapters,
|
|
10
|
-
};
|
|
11
|
-
export const mockBibleBooks = [
|
|
3
|
+
const baseBibleBooks = [
|
|
12
4
|
{
|
|
13
5
|
id: 'GEN',
|
|
14
6
|
title: 'Genesis',
|
|
15
7
|
full_title: 'The First Book of Moses, Called Genesis',
|
|
16
8
|
abbreviation: 'Gen',
|
|
17
9
|
canon: 'old_testament',
|
|
18
|
-
chapters:
|
|
19
|
-
const chapterNumber = i + 1;
|
|
20
|
-
return {
|
|
21
|
-
id: chapterNumber.toString(),
|
|
22
|
-
passage_id: `GEN.${chapterNumber}`,
|
|
23
|
-
title: chapterNumber.toString(),
|
|
24
|
-
verses: Array.from({ length: 31 }, (_, j) => {
|
|
25
|
-
const verseNumber = j + 1;
|
|
26
|
-
return {
|
|
27
|
-
id: verseNumber.toString(),
|
|
28
|
-
passage_id: `GEN.${chapterNumber}.${verseNumber}`,
|
|
29
|
-
title: verseNumber.toString(),
|
|
30
|
-
};
|
|
31
|
-
}),
|
|
32
|
-
};
|
|
33
|
-
}),
|
|
10
|
+
chapters: mockGenesisChapters,
|
|
34
11
|
},
|
|
35
12
|
{
|
|
36
13
|
id: 'EXO',
|
|
@@ -1528,3 +1505,15 @@ export const mockBibleBooks = [
|
|
|
1528
1505
|
}),
|
|
1529
1506
|
},
|
|
1530
1507
|
];
|
|
1508
|
+
|
|
1509
|
+
const addIntro = <T extends { id: string }>(book: T) => ({
|
|
1510
|
+
...book,
|
|
1511
|
+
intro: {
|
|
1512
|
+
id: 'INTRO',
|
|
1513
|
+
passage_id: `${book.id}.INTRO`,
|
|
1514
|
+
title: 'Intro',
|
|
1515
|
+
},
|
|
1516
|
+
});
|
|
1517
|
+
|
|
1518
|
+
export const mockBibleBooks = baseBibleBooks.map(addIntro);
|
|
1519
|
+
export const mockBibleGenesis = mockBibleBooks[0];
|
|
@@ -77,6 +77,11 @@ describe('BibleClient', () => {
|
|
|
77
77
|
expect(books.data[0]).toHaveProperty('title', 'Genesis');
|
|
78
78
|
expect(books.data[0]).toHaveProperty('full_title', 'The First Book of Moses, Called Genesis');
|
|
79
79
|
expect(books.data[0]).toHaveProperty('abbreviation', 'Gen');
|
|
80
|
+
expect(books.data[0]?.intro).toEqual({
|
|
81
|
+
id: 'INTRO',
|
|
82
|
+
passage_id: 'GEN.INTRO',
|
|
83
|
+
title: 'Intro',
|
|
84
|
+
});
|
|
80
85
|
expect(books.data[0]).toHaveProperty('canon', 'old_testament');
|
|
81
86
|
expect(books.data[0]?.chapters).toHaveLength(50);
|
|
82
87
|
});
|
|
@@ -93,6 +98,12 @@ describe('BibleClient', () => {
|
|
|
93
98
|
expect(book).toHaveProperty('id', 'GEN');
|
|
94
99
|
expect(book).toHaveProperty('title', 'Genesis');
|
|
95
100
|
expect(book).toHaveProperty('abbreviation', 'Gen');
|
|
101
|
+
expect(book).toHaveProperty('intro');
|
|
102
|
+
expect(book.intro).toEqual({
|
|
103
|
+
id: 'INTRO',
|
|
104
|
+
passage_id: 'GEN.INTRO',
|
|
105
|
+
title: 'Intro',
|
|
106
|
+
});
|
|
96
107
|
expect(book).toHaveProperty('canon', 'old_testament');
|
|
97
108
|
});
|
|
98
109
|
|
package/src/bible.ts
CHANGED
|
@@ -82,7 +82,9 @@ export class BibleClient {
|
|
|
82
82
|
* Fetches all books for a given Bible version.
|
|
83
83
|
* @param versionId The version ID.
|
|
84
84
|
* @param canon Optional canon filter ("old_testament", 'new_testament', 'deuterocanon').
|
|
85
|
-
* @returns An array of BibleBook objects.
|
|
85
|
+
* @returns An array of BibleBook objects. Each book may include an optional `intro` field
|
|
86
|
+
* containing metadata (id, passage_id, title) for the book's introduction when
|
|
87
|
+
* available in the Bible version.
|
|
86
88
|
*/
|
|
87
89
|
async getBooks(versionId: number, canon?: CANON): Promise<Collection<BibleBook>> {
|
|
88
90
|
this.versionIdSchema.parse(versionId);
|
|
@@ -95,7 +97,9 @@ export class BibleClient {
|
|
|
95
97
|
* Fetches a specific book by USFM code for a given version.
|
|
96
98
|
* @param versionId The version ID.
|
|
97
99
|
* @param book The Book Identifier code of the book.
|
|
98
|
-
* @returns The requested BibleBook object
|
|
100
|
+
* @returns The requested BibleBook object, which may include an optional `intro` field
|
|
101
|
+
* containing metadata (id, passage_id, title) for the book's introduction when
|
|
102
|
+
* available. Use the `passage_id` with `getPassage()` to fetch intro content.
|
|
99
103
|
*/
|
|
100
104
|
async getBook(versionId: number, book: string): Promise<BibleBook> {
|
|
101
105
|
this.versionIdSchema.parse(versionId);
|
package/src/schemas/book.ts
CHANGED
|
@@ -5,6 +5,16 @@ import { BibleChapterSchema } from './chapter';
|
|
|
5
5
|
export const CanonSchema = z.enum(['old_testament', 'new_testament', 'deuterocanon']);
|
|
6
6
|
export type Canon = Readonly<z.infer<typeof CanonSchema>>;
|
|
7
7
|
|
|
8
|
+
export const BibleBookIntroSchema = z.object({
|
|
9
|
+
/** Intro identifier */
|
|
10
|
+
id: z.string(),
|
|
11
|
+
/** Intro passage identifier */
|
|
12
|
+
passage_id: z.string(),
|
|
13
|
+
/** Intro title */
|
|
14
|
+
title: z.string(),
|
|
15
|
+
});
|
|
16
|
+
export type BibleBookIntro = Readonly<z.infer<typeof BibleBookIntroSchema>>;
|
|
17
|
+
|
|
8
18
|
// https://github.com/colinhacks/zod/discussions/4934#discussioncomment-13858053
|
|
9
19
|
export const BookUsfmSchema = z.union([
|
|
10
20
|
...BOOK_IDS.map((id) => z.literal(id)),
|
|
@@ -23,6 +33,8 @@ export const BibleBookSchema = z.object({
|
|
|
23
33
|
abbreviation: z.string().optional(),
|
|
24
34
|
/** Canonical section (new_testament, old_testament, deuterocanon) */
|
|
25
35
|
canon: CanonSchema,
|
|
36
|
+
/** Intro metadata (optional) */
|
|
37
|
+
intro: BibleBookIntroSchema.optional(),
|
|
26
38
|
/** Array of chapter identifiers (e.g., ["GEN.1", "GEN.2", "GEN.3"]) */
|
|
27
39
|
chapters: z.array(BibleChapterSchema).optional(),
|
|
28
40
|
});
|
package/src/types/index.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Re-export all schema-derived types from schemas
|
|
2
2
|
export type { BibleVersion } from '../schemas/version';
|
|
3
|
-
export type { BibleBook, CANON } from '../schemas/book';
|
|
3
|
+
export type { BibleBook, BibleBookIntro, CANON } from '../schemas/book';
|
|
4
4
|
export type { BibleChapter } from '../schemas/chapter';
|
|
5
5
|
export type { BibleVerse } from '../schemas/verse';
|
|
6
6
|
export type { BiblePassage } from '../schemas/passage';
|
package/src/types/book.ts
DELETED
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
export type BibleBook = Readonly<{
|
|
2
|
-
id: BOOK_ID; // Book identifier (USFM)
|
|
3
|
-
title: string;
|
|
4
|
-
abbreviation?: string; // Book name abbreviation if provided by publisher
|
|
5
|
-
canon: CANON;
|
|
6
|
-
// eslint-disable-next-line @typescript-eslint/array-type -- Array<> syntax required for template literal type to represent chapter references
|
|
7
|
-
chapters?: Array<`${BOOK_ID}.${number | `INTRO${number}`}`>; // Ordered list of chapter ids for given Bible and book (e.g., ["GEN.1", "GEN.2", "3JN.INTRO1", "3JN.1"])
|
|
8
|
-
}>;
|
|
9
|
-
|
|
10
|
-
export type BOOK_ID =
|
|
11
|
-
| 'GEN'
|
|
12
|
-
| 'EXO'
|
|
13
|
-
| 'LEV'
|
|
14
|
-
| 'NUM'
|
|
15
|
-
| 'DEU'
|
|
16
|
-
| 'JOS'
|
|
17
|
-
| 'JDG'
|
|
18
|
-
| 'RUT'
|
|
19
|
-
| '1SA'
|
|
20
|
-
| '2SA'
|
|
21
|
-
| '1KI'
|
|
22
|
-
| '2KI'
|
|
23
|
-
| '1CH'
|
|
24
|
-
| '2CH'
|
|
25
|
-
| 'EZR'
|
|
26
|
-
| 'NEH'
|
|
27
|
-
| 'EST'
|
|
28
|
-
| 'JOB'
|
|
29
|
-
| 'PSA'
|
|
30
|
-
| 'PRO'
|
|
31
|
-
| 'ECC'
|
|
32
|
-
| 'SNG'
|
|
33
|
-
| 'ISA'
|
|
34
|
-
| 'JER'
|
|
35
|
-
| 'LAM'
|
|
36
|
-
| 'EZK'
|
|
37
|
-
| 'DAN'
|
|
38
|
-
| 'HOS'
|
|
39
|
-
| 'JOL'
|
|
40
|
-
| 'AMO'
|
|
41
|
-
| 'OBA'
|
|
42
|
-
| 'JON'
|
|
43
|
-
| 'MIC'
|
|
44
|
-
| 'NAM'
|
|
45
|
-
| 'HAB'
|
|
46
|
-
| 'ZEP'
|
|
47
|
-
| 'HAG'
|
|
48
|
-
| 'ZEC'
|
|
49
|
-
| 'MAL'
|
|
50
|
-
| 'MAT'
|
|
51
|
-
| 'MRK'
|
|
52
|
-
| 'LUK'
|
|
53
|
-
| 'JHN'
|
|
54
|
-
| 'ACT'
|
|
55
|
-
| 'ROM'
|
|
56
|
-
| '1CO'
|
|
57
|
-
| '2CO'
|
|
58
|
-
| 'GAL'
|
|
59
|
-
| 'EPH'
|
|
60
|
-
| 'PHP'
|
|
61
|
-
| 'COL'
|
|
62
|
-
| '1TH'
|
|
63
|
-
| '2TH'
|
|
64
|
-
| '1TI'
|
|
65
|
-
| '2TI'
|
|
66
|
-
| 'TIT'
|
|
67
|
-
| 'PHM'
|
|
68
|
-
| 'HEB'
|
|
69
|
-
| 'JAS'
|
|
70
|
-
| '1PE'
|
|
71
|
-
| '2PE'
|
|
72
|
-
| '1JN'
|
|
73
|
-
| '2JN'
|
|
74
|
-
| '3JN'
|
|
75
|
-
| 'JUD'
|
|
76
|
-
| 'REV'
|
|
77
|
-
| 'TOB'
|
|
78
|
-
| 'JDT'
|
|
79
|
-
| 'ESG'
|
|
80
|
-
| 'WIS'
|
|
81
|
-
| 'SIR'
|
|
82
|
-
| 'BAR'
|
|
83
|
-
| 'LJE'
|
|
84
|
-
| 'S3Y'
|
|
85
|
-
| 'SUS'
|
|
86
|
-
| 'BEL'
|
|
87
|
-
| '1MA'
|
|
88
|
-
| '2MA'
|
|
89
|
-
| '3MA'
|
|
90
|
-
| '4MA'
|
|
91
|
-
| '1ES'
|
|
92
|
-
| '2ES'
|
|
93
|
-
| 'MAN'
|
|
94
|
-
| 'PS2'
|
|
95
|
-
| 'ODA'
|
|
96
|
-
| 'PSS'
|
|
97
|
-
| '3ES'
|
|
98
|
-
| 'EZA'
|
|
99
|
-
| '5EZ'
|
|
100
|
-
| '6EZ'
|
|
101
|
-
| 'DAG'
|
|
102
|
-
| 'PS3'
|
|
103
|
-
| '2BA'
|
|
104
|
-
| 'LBA'
|
|
105
|
-
| 'JUB'
|
|
106
|
-
| 'ENO'
|
|
107
|
-
| '1MQ'
|
|
108
|
-
| '2MQ'
|
|
109
|
-
| '3MQ'
|
|
110
|
-
| 'REP'
|
|
111
|
-
| '4BA'
|
|
112
|
-
| 'LAO'
|
|
113
|
-
| 'LKA'
|
|
114
|
-
| (string & {});
|
|
115
|
-
|
|
116
|
-
export type CANON = 'old_testament' | 'new_testament' | 'deuterocanon';
|