@youversion/platform-core 1.1.0 → 1.2.1
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 +8 -8
- package/CHANGELOG.md +18 -0
- package/dist/index.cjs +12 -6
- package/dist/index.d.cts +21 -6
- package/dist/index.d.ts +21 -6
- package/dist/index.js +12 -6
- package/package.json +1 -1
- package/src/__tests__/MockBibles.ts +14 -25
- package/src/__tests__/{MockLangauges.ts → MockLanguages.ts} +3 -3
- package/src/__tests__/bible.test.ts +11 -0
- package/src/__tests__/handlers.ts +1 -1
- package/src/__tests__/languages.test.ts +9 -8
- package/src/bible.ts +6 -2
- package/src/languages.ts +7 -6
- 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.1
|
|
2
|
+
> @youversion/platform-core@1.2.1 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
|
-
[
|
|
12
|
-
[
|
|
13
|
-
[
|
|
14
|
-
[
|
|
11
|
+
[32mESM[39m [1mdist/index.js [22m[32m41.09 KB[39m
|
|
12
|
+
[32mESM[39m ⚡️ Build success in 34ms
|
|
13
|
+
[32mCJS[39m [1mdist/index.cjs [22m[32m42.90 KB[39m
|
|
14
|
+
[32mCJS[39m ⚡️ Build success in 34ms
|
|
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 2020ms
|
|
17
|
+
[32mDTS[39m [1mdist/index.d.cts [22m[32m32.78 KB[39m
|
|
18
|
+
[32mDTS[39m [1mdist/index.d.ts [22m[32m32.78 KB[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @youversion/platform-core
|
|
2
2
|
|
|
3
|
+
## 1.2.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- e845974: fix: make country parameter optional for getLanguages
|
|
8
|
+
|
|
9
|
+
The country parameter is now optional when fetching languages, allowing developers to retrieve all available languages without filtering by country. This improves developer experience by providing a more flexible API while maintaining backward compatibility for existing code that provides a country filter.
|
|
10
|
+
|
|
11
|
+
## 1.2.0
|
|
12
|
+
|
|
13
|
+
### Minor Changes
|
|
14
|
+
|
|
15
|
+
- a8a5dd7: feat: Add intro metadata to BibleBook
|
|
16
|
+
- Added optional `intro` field to BibleBook schema for retrieving book introduction metadata
|
|
17
|
+
- The intro field includes `id`, `passage_id`, and `title` properties when available
|
|
18
|
+
- Simplified type definitions by removing duplicate type files and using Zod schemas as single source of truth
|
|
19
|
+
- Updated Bible mocks and tests to cover the new intro field
|
|
20
|
+
|
|
3
21
|
## 1.1.0
|
|
4
22
|
|
|
5
23
|
### 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);
|
|
@@ -405,13 +409,15 @@ var LanguagesClient = class {
|
|
|
405
409
|
}
|
|
406
410
|
/**
|
|
407
411
|
* Fetches a collection of languages supported in the Platform.
|
|
408
|
-
* @param options Query parameters for pagination and filtering
|
|
412
|
+
* @param options Query parameters for pagination and filtering.
|
|
409
413
|
* @returns A collection of Language objects.
|
|
410
414
|
*/
|
|
411
|
-
async getLanguages(options) {
|
|
415
|
+
async getLanguages(options = {}) {
|
|
412
416
|
const params = {};
|
|
413
|
-
|
|
414
|
-
|
|
417
|
+
if (options.country !== void 0) {
|
|
418
|
+
const country = this.countrySchema.parse(options.country);
|
|
419
|
+
params.country = country;
|
|
420
|
+
}
|
|
415
421
|
if (options.page_size !== void 0) {
|
|
416
422
|
const pageSizeSchema = import_zod2.z.number().int().positive();
|
|
417
423
|
pageSizeSchema.parse(options.page_size);
|
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
|
/**
|
|
@@ -434,7 +449,7 @@ declare class BibleClient {
|
|
|
434
449
|
type GetLanguagesOptions = {
|
|
435
450
|
page_size?: number;
|
|
436
451
|
page_token?: string;
|
|
437
|
-
country
|
|
452
|
+
country?: string;
|
|
438
453
|
};
|
|
439
454
|
/**
|
|
440
455
|
* Client for interacting with Languages API endpoints.
|
|
@@ -450,10 +465,10 @@ declare class LanguagesClient {
|
|
|
450
465
|
constructor(client: ApiClient);
|
|
451
466
|
/**
|
|
452
467
|
* Fetches a collection of languages supported in the Platform.
|
|
453
|
-
* @param options Query parameters for pagination and filtering
|
|
468
|
+
* @param options Query parameters for pagination and filtering.
|
|
454
469
|
* @returns A collection of Language objects.
|
|
455
470
|
*/
|
|
456
|
-
getLanguages(options
|
|
471
|
+
getLanguages(options?: GetLanguagesOptions): Promise<Collection<Language>>;
|
|
457
472
|
/**
|
|
458
473
|
* Fetches details about a specific language in the Platform.
|
|
459
474
|
* @param languageId The BCP 47 language code (optionally including script, e.g., "en" or "sr-Latn").
|
|
@@ -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
|
/**
|
|
@@ -434,7 +449,7 @@ declare class BibleClient {
|
|
|
434
449
|
type GetLanguagesOptions = {
|
|
435
450
|
page_size?: number;
|
|
436
451
|
page_token?: string;
|
|
437
|
-
country
|
|
452
|
+
country?: string;
|
|
438
453
|
};
|
|
439
454
|
/**
|
|
440
455
|
* Client for interacting with Languages API endpoints.
|
|
@@ -450,10 +465,10 @@ declare class LanguagesClient {
|
|
|
450
465
|
constructor(client: ApiClient);
|
|
451
466
|
/**
|
|
452
467
|
* Fetches a collection of languages supported in the Platform.
|
|
453
|
-
* @param options Query parameters for pagination and filtering
|
|
468
|
+
* @param options Query parameters for pagination and filtering.
|
|
454
469
|
* @returns A collection of Language objects.
|
|
455
470
|
*/
|
|
456
|
-
getLanguages(options
|
|
471
|
+
getLanguages(options?: GetLanguagesOptions): Promise<Collection<Language>>;
|
|
457
472
|
/**
|
|
458
473
|
* Fetches details about a specific language in the Platform.
|
|
459
474
|
* @param languageId The BCP 47 language code (optionally including script, e.g., "en" or "sr-Latn").
|
|
@@ -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);
|
|
@@ -366,13 +370,15 @@ var LanguagesClient = class {
|
|
|
366
370
|
}
|
|
367
371
|
/**
|
|
368
372
|
* Fetches a collection of languages supported in the Platform.
|
|
369
|
-
* @param options Query parameters for pagination and filtering
|
|
373
|
+
* @param options Query parameters for pagination and filtering.
|
|
370
374
|
* @returns A collection of Language objects.
|
|
371
375
|
*/
|
|
372
|
-
async getLanguages(options) {
|
|
376
|
+
async getLanguages(options = {}) {
|
|
373
377
|
const params = {};
|
|
374
|
-
|
|
375
|
-
|
|
378
|
+
if (options.country !== void 0) {
|
|
379
|
+
const country = this.countrySchema.parse(options.country);
|
|
380
|
+
params.country = country;
|
|
381
|
+
}
|
|
376
382
|
if (options.page_size !== void 0) {
|
|
377
383
|
const pageSizeSchema = z2.number().int().positive();
|
|
378
384
|
pageSizeSchema.parse(options.page_size);
|
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];
|
|
@@ -76,8 +76,8 @@ export const mockLanguages: Language[] = [
|
|
|
76
76
|
speaking_population: 8000000,
|
|
77
77
|
default_bible_version_id: null,
|
|
78
78
|
},
|
|
79
|
-
// Add more languages to
|
|
80
|
-
...Array.from({ length:
|
|
79
|
+
// Add more languages to exceed the maximum page size and exercise pagination
|
|
80
|
+
...Array.from({ length: 120 }, (_, i) => ({
|
|
81
81
|
id: `lang${i + 1}`,
|
|
82
82
|
language: `lang${i + 1}`,
|
|
83
83
|
script: 'Latn',
|
|
@@ -86,7 +86,7 @@ export const mockLanguages: Language[] = [
|
|
|
86
86
|
display_names: {},
|
|
87
87
|
scripts: ['Latn'],
|
|
88
88
|
variants: [],
|
|
89
|
-
countries: ['US'],
|
|
89
|
+
countries: i % 2 === 0 ? ['US', 'CA'] : ['BR'],
|
|
90
90
|
text_direction: 'ltr' as const,
|
|
91
91
|
writing_population: 1000000,
|
|
92
92
|
speaking_population: 1000000,
|
|
@@ -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
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { http, HttpResponse } from 'msw';
|
|
2
2
|
import type { Collection, Highlight, Language } from '../types';
|
|
3
|
-
import { mockLanguages } from './
|
|
3
|
+
import { mockLanguages } from './MockLanguages';
|
|
4
4
|
import { mockVersions, mockVersionKJV } from './MockVersions';
|
|
5
5
|
import { mockBibleGenesis, mockBibleBooks } from './MockBibles';
|
|
6
6
|
import { mockChapterGenesis1, mockGenesisChapters } from './MockChapters';
|
|
@@ -17,22 +17,23 @@ describe('LanguagesClient', () => {
|
|
|
17
17
|
});
|
|
18
18
|
|
|
19
19
|
describe('getLanguages', () => {
|
|
20
|
-
it('should fetch languages
|
|
21
|
-
const languages = await languagesClient.getLanguages({
|
|
20
|
+
it('should fetch languages without country filter', async () => {
|
|
21
|
+
const languages = await languagesClient.getLanguages({ page_size: 99 });
|
|
22
22
|
|
|
23
23
|
const { success } = LanguageSchema.safeParse(languages.data[0]);
|
|
24
24
|
expect(success).toBe(true);
|
|
25
|
-
expect(languages.data).toHaveLength(
|
|
26
|
-
expect(languages.
|
|
25
|
+
expect(languages.data).toHaveLength(99);
|
|
26
|
+
expect(languages.next_page_token).not.toBeNull();
|
|
27
27
|
});
|
|
28
28
|
|
|
29
|
-
it('should fetch languages with
|
|
30
|
-
const languages = await languagesClient.getLanguages({ country: 'US', page_size:
|
|
29
|
+
it('should fetch languages with country filter', async () => {
|
|
30
|
+
const languages = await languagesClient.getLanguages({ country: 'US', page_size: 20 });
|
|
31
31
|
|
|
32
32
|
const { success } = LanguageSchema.safeParse(languages.data[0]);
|
|
33
33
|
expect(success).toBe(true);
|
|
34
|
-
expect(languages.data).toHaveLength(
|
|
35
|
-
expect(languages.
|
|
34
|
+
expect(languages.data).toHaveLength(20);
|
|
35
|
+
expect(languages.data.every((language) => language.countries?.includes('US'))).toBe(true);
|
|
36
|
+
expect(languages.next_page_token).not.toBeNull();
|
|
36
37
|
});
|
|
37
38
|
|
|
38
39
|
it('should throw an error for invalid country code - empty string', async () => {
|
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/languages.ts
CHANGED
|
@@ -8,7 +8,7 @@ import type { Collection, Language } from './types';
|
|
|
8
8
|
export type GetLanguagesOptions = {
|
|
9
9
|
page_size?: number;
|
|
10
10
|
page_token?: string;
|
|
11
|
-
country
|
|
11
|
+
country?: string; // ISO 3166-1 alpha-2 country code
|
|
12
12
|
};
|
|
13
13
|
|
|
14
14
|
/**
|
|
@@ -41,15 +41,16 @@ export class LanguagesClient {
|
|
|
41
41
|
|
|
42
42
|
/**
|
|
43
43
|
* Fetches a collection of languages supported in the Platform.
|
|
44
|
-
* @param options Query parameters for pagination and filtering
|
|
44
|
+
* @param options Query parameters for pagination and filtering.
|
|
45
45
|
* @returns A collection of Language objects.
|
|
46
46
|
*/
|
|
47
|
-
async getLanguages(options: GetLanguagesOptions): Promise<Collection<Language>> {
|
|
47
|
+
async getLanguages(options: GetLanguagesOptions = {}): Promise<Collection<Language>> {
|
|
48
48
|
const params: Record<string, string | number> = {};
|
|
49
49
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
50
|
+
if (options.country !== undefined) {
|
|
51
|
+
const country = this.countrySchema.parse(options.country);
|
|
52
|
+
params.country = country;
|
|
53
|
+
}
|
|
53
54
|
|
|
54
55
|
if (options.page_size !== undefined) {
|
|
55
56
|
const pageSizeSchema = z.number().int().positive();
|
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';
|