@youversion/platform-core 1.11.0 → 1.12.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/dist/index.js CHANGED
@@ -152,229 +152,13 @@ var ApiClient = class {
152
152
  };
153
153
 
154
154
  // src/bible.ts
155
- import { z } from "zod";
156
- var BibleClient = class {
157
- client;
158
- // Validation schemas
159
- versionIdSchema = z.number().int().positive("Version ID must be a positive integer");
160
- bookSchema = z.string().trim().min(3, "Book ID must be exactly 3 characters").max(3, "Book ID must be exactly 3 characters");
161
- chapterSchema = z.number().int("Chapter must be an integer").positive("Chapter must be a positive integer");
162
- verseSchema = z.number().int("Verse must be an integer").positive("Verse must be a positive integer");
163
- languageRangesSchema = z.string().trim().min(1, "Language ranges must be a non-empty string");
164
- booleanSchema = z.boolean();
165
- /**
166
- * Creates a new BibleClient instance.
167
- * @param client The API client to use for requests.
168
- */
169
- constructor(client) {
170
- this.client = client;
171
- }
172
- /**
173
- * Fetches a collection of Bible versions filtered by language ranges.
174
- *
175
- * @param language_ranges - One or more language codes or ranges to filter the versions (required).
176
- * @param license_id - Optional license ID to filter versions by license.
177
- * @returns A promise that resolves to a collection of BibleVersion objects.
178
- */
179
- async getVersions(language_ranges, license_id, options) {
180
- const languageRangeArray = Array.isArray(language_ranges) ? language_ranges : [language_ranges];
181
- const parsedLanguageRanges = z.array(this.languageRangesSchema).nonempty("At least one language range is required").parse(languageRangeArray);
182
- const params = {
183
- "language_ranges[]": parsedLanguageRanges
184
- };
185
- if (license_id !== void 0) {
186
- params.license_id = license_id;
187
- }
188
- if (options?.page_size !== void 0) {
189
- const pageSizeSchema = z.number().int().positive();
190
- pageSizeSchema.parse(options.page_size);
191
- params.page_size = options.page_size;
192
- }
193
- if (options?.page_token !== void 0) {
194
- params.page_token = options.page_token;
195
- }
196
- return this.client.get(`/v1/bibles`, params);
197
- }
198
- /**
199
- * Fetches a Bible version by its ID.
200
- * @param id The version ID.
201
- * @returns The requested BibleVersion object.
202
- */
203
- async getVersion(id) {
204
- this.versionIdSchema.parse(id);
205
- return this.client.get(`/v1/bibles/${id}`);
206
- }
207
- /**
208
- * Fetches all books for a given Bible version.
209
- * @param versionId The version ID.
210
- * @param canon Optional canon filter ("old_testament", 'new_testament', 'deuterocanon').
211
- * @returns An array of BibleBook objects. Each book may include an optional `intro` field
212
- * containing metadata (id, passage_id, title) for the book's introduction when
213
- * available in the Bible version.
214
- */
215
- async getBooks(versionId, canon) {
216
- this.versionIdSchema.parse(versionId);
217
- return this.client.get(`/v1/bibles/${versionId}/books`, {
218
- ...canon && { canon }
219
- });
220
- }
221
- /**
222
- * Fetches a specific book by USFM code for a given version.
223
- * @param versionId The version ID.
224
- * @param book The Book Identifier code of the book.
225
- * @returns The requested BibleBook object, which may include an optional `intro` field
226
- * containing metadata (id, passage_id, title) for the book's introduction when
227
- * available. Use the `passage_id` with `getPassage()` to fetch intro content.
228
- */
229
- async getBook(versionId, book) {
230
- this.versionIdSchema.parse(versionId);
231
- this.bookSchema.parse(book);
232
- return this.client.get(`/v1/bibles/${versionId}/books/${book}`);
233
- }
234
- /**
235
- * Fetches all chapters for a specific book in a version.
236
- * @param versionId The version ID.
237
- * @param book The Book Identifier code of the book.
238
- * @returns An array of BibleChapter objects.
239
- */
240
- async getChapters(versionId, book) {
241
- this.versionIdSchema.parse(versionId);
242
- this.bookSchema.parse(book);
243
- return this.client.get(
244
- `/v1/bibles/${versionId}/books/${book}/chapters`
245
- );
246
- }
247
- /**
248
- * Fetches a specific chapter for a book in a version.
249
- * @param versionId The version ID.
250
- * @param book The Book Identifier code of the book (3 characters, e.g., "MAT").
251
- * @param chapter The chapter number
252
- * @returns The requested BibleChapter object.
253
- */
254
- async getChapter(versionId, book, chapter) {
255
- this.versionIdSchema.parse(versionId);
256
- this.bookSchema.parse(book);
257
- this.chapterSchema.parse(chapter);
258
- return this.client.get(
259
- `/v1/bibles/${versionId}/books/${book}/chapters/${chapter}`
260
- );
261
- }
262
- /**
263
- * Fetches all verses for a specific chapter in a book and version.
264
- * @param versionId The version ID.
265
- * @param book The Book Identifier code of the book (3 characters, e.g., "MAT").
266
- * @param chapter The chapter number.
267
- * @returns An array of BibleVerse objects.
268
- */
269
- async getVerses(versionId, book, chapter) {
270
- this.versionIdSchema.parse(versionId);
271
- this.bookSchema.parse(book);
272
- this.chapterSchema.parse(chapter);
273
- return this.client.get(
274
- `/v1/bibles/${versionId}/books/${book}/chapters/${chapter}/verses`
275
- );
276
- }
277
- /**
278
- * Fetches a specific verse from a chapter, book, and version.
279
- * @param versionId The version ID.
280
- * @param book The Book Identifier code of the book (3 characters, e.g., "MAT").
281
- * @param chapter The chapter number.
282
- * @param verse The verse number.
283
- * @returns The requested BibleVerse object.
284
- */
285
- async getVerse(versionId, book, chapter, verse) {
286
- this.versionIdSchema.parse(versionId);
287
- this.bookSchema.parse(book);
288
- this.chapterSchema.parse(chapter);
289
- this.verseSchema.parse(verse);
290
- return this.client.get(
291
- `/v1/bibles/${versionId}/books/${book}/chapters/${chapter}/verses/${verse}`
292
- );
293
- }
294
- /**
295
- * Fetches a passage (range of verses) from the Bible using the passages endpoint.
296
- * This is the new API format that returns HTML-formatted content.
297
- * @param versionId The version ID.
298
- * @param usfm The USFM reference (e.g., "JHN.3.1-2", "GEN.1", "JHN.3.16").
299
- * @param format The format to return ("html" or "text", default: "html").
300
- * @param include_headings Whether to include headings in the content.
301
- * @param include_notes Whether to include notes in the content.
302
- * @returns The requested BiblePassage object with HTML content.
303
- * @example
304
- * ```ts
305
- * // Get a single verse
306
- * const verse = await bibleClient.getPassage(111, "JHN.3.16");
307
- *
308
- * // Get a range of verses
309
- * const verses = await bibleClient.getPassage(111, "JHN.3.1-5");
310
- *
311
- * // Get an entire chapter
312
- * const chapter = await bibleClient.getPassage(111, "GEN.1");
313
- * ```
314
- */
315
- async getPassage(versionId, usfm, format = "html", include_headings, include_notes) {
316
- this.versionIdSchema.parse(versionId);
317
- if (include_headings !== void 0) {
318
- this.booleanSchema.parse(include_headings);
319
- }
320
- if (include_notes !== void 0) {
321
- this.booleanSchema.parse(include_notes);
322
- }
323
- const params = {
324
- format
325
- };
326
- if (include_headings !== void 0) {
327
- params.include_headings = include_headings;
328
- }
329
- if (include_notes !== void 0) {
330
- params.include_notes = include_notes;
331
- }
332
- return this.client.get(`/v1/bibles/${versionId}/passages/${usfm}`, params);
333
- }
334
- /**
335
- * Fetches the indexing structure for a Bible version.
336
- * @param versionId The version ID.
337
- * @returns The BibleIndex object containing full hierarchy of books, chapters, and verses.
338
- */
339
- async getIndex(versionId) {
340
- this.versionIdSchema.parse(versionId);
341
- return this.client.get(`/v1/bibles/${versionId}/index`);
342
- }
343
- /**
344
- * Fetches the verse of the day calendar for an entire year.
345
- * @returns A collection of VOTD objects for all days of the year.
346
- */
347
- async getAllVOTDs() {
348
- return this.client.get(`/v1/verse_of_the_days`);
349
- }
350
- /**
351
- * Fetches the passage_id for the Verse Of The Day.
352
- * @param day The day of the year (1-366).
353
- * @returns The day of the year and the passage_id for that day of the year
354
- * @example
355
- * ```ts
356
- * // Get the passageId for the verse of the first day of the year.
357
- * const passageId = await bibleClient.getVOTD(1);
358
- *
359
- * // Get the passageId for the verse of the 100th day of the year.
360
- * const passageId = await bibleClient.getVOTD(100);
361
- * ```
362
- */
363
- async getVOTD(day) {
364
- const daySchema = z.number().int().min(1).max(366);
365
- daySchema.parse(day);
366
- return this.client.get(`/v1/verse_of_the_days/${day}`);
367
- }
368
- };
369
-
370
- // src/languages.ts
371
- import { z as z13 } from "zod";
155
+ import { z as z12 } from "zod";
372
156
 
373
157
  // src/schemas/bible-index.ts
374
- import { z as z5 } from "zod";
158
+ import { z as z4 } from "zod";
375
159
 
376
160
  // src/schemas/book.ts
377
- import { z as z4 } from "zod";
161
+ import { z as z3 } from "zod";
378
162
 
379
163
  // src/utils/constants.ts
380
164
  var BOOK_IDS = [
@@ -592,212 +376,450 @@ var BOOK_CANON = {
592
376
  };
593
377
 
594
378
  // src/schemas/chapter.ts
595
- import { z as z3 } from "zod";
379
+ import { z as z2 } from "zod";
596
380
 
597
381
  // src/schemas/verse.ts
598
- import { z as z2 } from "zod";
599
- var BibleVerseSchema = z2.object({
382
+ import { z } from "zod";
383
+ var BibleVerseSchema = z.object({
600
384
  /** Verse identifier (e.g., "1") */
601
- id: z2.string(),
385
+ id: z.string(),
602
386
  /** Passage identifier (e.g., "MAT.1.1") */
603
- passage_id: z2.string(),
387
+ passage_id: z.string(),
604
388
  /** Verse Number (e.g., "1") */
605
- title: z2.string()
389
+ title: z.string()
606
390
  });
607
391
 
608
392
  // src/schemas/chapter.ts
609
- var BibleChapterSchema = z3.object({
393
+ var BibleChapterSchema = z2.object({
610
394
  /** Chapter identifier (e.g., "1") */
611
- id: z3.string(),
395
+ id: z2.string(),
612
396
  /** Passage identifier (e.g., "MAT.1") */
613
- passage_id: z3.string(),
397
+ passage_id: z2.string(),
614
398
  /** Chapter title (e.g., "1") */
615
- title: z3.string(),
399
+ title: z2.string(),
616
400
  /** Array of verses */
617
- verses: z3.array(BibleVerseSchema).optional()
401
+ verses: z2.array(BibleVerseSchema).optional()
618
402
  });
619
403
 
620
404
  // src/schemas/book.ts
621
- var CanonSchema = z4.enum(["old_testament", "new_testament", "deuterocanon"]);
622
- var BibleBookIntroSchema = z4.object({
405
+ var CanonSchema = z3.enum(["old_testament", "new_testament", "deuterocanon"]);
406
+ var BibleBookIntroSchema = z3.object({
623
407
  /** Intro identifier */
624
- id: z4.string(),
408
+ id: z3.string(),
625
409
  /** Intro passage identifier */
626
- passage_id: z4.string(),
410
+ passage_id: z3.string(),
627
411
  /** Intro title */
628
- title: z4.string()
412
+ title: z3.string()
629
413
  });
630
- var BookUsfmSchema = z4.union([
631
- ...BOOK_IDS.map((id) => z4.literal(id)),
632
- z4.string().length(3)
414
+ var BookUsfmSchema = z3.union([
415
+ ...BOOK_IDS.map((id) => z3.literal(id)),
416
+ z3.string().length(3)
633
417
  ]);
634
- var BibleBookSchema = z4.object({
418
+ var BibleBookSchema = z3.object({
635
419
  /** Book identifier (e.g., "MAT") */
636
420
  id: BookUsfmSchema,
637
421
  /** Book title (e.g., "Genesis") */
638
- title: z4.string(),
422
+ title: z3.string(),
639
423
  /** Full Book title (e.g., "The First Book of Moses, Commonly Called Genesis") */
640
- full_title: z4.string(),
424
+ full_title: z3.string(),
641
425
  /** Book abbreviation (e.g., "Gen") */
642
- abbreviation: z4.string().optional(),
426
+ abbreviation: z3.string().optional(),
643
427
  /** Canonical section (new_testament, old_testament, deuterocanon) */
644
428
  canon: CanonSchema,
645
429
  /** Intro metadata (optional) */
646
430
  intro: BibleBookIntroSchema.optional(),
647
431
  /** Array of chapter identifiers (e.g., ["GEN.1", "GEN.2", "GEN.3"]) */
648
- chapters: z4.array(BibleChapterSchema).optional()
432
+ chapters: z3.array(BibleChapterSchema).optional()
649
433
  });
650
434
 
651
435
  // src/schemas/bible-index.ts
652
- var BibleIndexVerseSchema = z5.object({
436
+ var BibleIndexVerseSchema = z4.object({
653
437
  /** Verse identifier */
654
- id: z5.string(),
438
+ id: z4.string(),
655
439
  /** Verse title */
656
- title: z5.string()
440
+ title: z4.string()
657
441
  });
658
- var BibleIndexChapterSchema = z5.object({
442
+ var BibleIndexChapterSchema = z4.object({
659
443
  /** Chapter identifier */
660
- id: z5.string(),
444
+ id: z4.string(),
661
445
  /** Chapter title */
662
- title: z5.string(),
446
+ title: z4.string(),
663
447
  /** Array of verses in this chapter */
664
- verses: z5.array(BibleIndexVerseSchema)
448
+ verses: z4.array(BibleIndexVerseSchema)
665
449
  });
666
- var BibleIndexBookSchema = z5.object({
450
+ var BibleIndexBookSchema = z4.object({
667
451
  /** Book identifier */
668
452
  id: BookUsfmSchema,
669
453
  /** Book title */
670
- title: z5.string(),
454
+ title: z4.string(),
671
455
  /** Full book title */
672
- full_title: z5.string(),
456
+ full_title: z4.string(),
673
457
  /** Book abbreviation */
674
- abbreviation: z5.string(),
458
+ abbreviation: z4.string(),
675
459
  /** Canonical section */
676
460
  canon: CanonSchema,
677
461
  /** Array of chapters in this book */
678
- chapters: z5.array(BibleIndexChapterSchema)
462
+ chapters: z4.array(BibleIndexChapterSchema)
679
463
  });
680
- var _BibleIndexSchema = z5.object({
464
+ var _BibleIndexSchema = z4.object({
681
465
  /** Text direction (e.g., "ltr") */
682
- text_direction: z5.string(),
466
+ text_direction: z4.string(),
683
467
  /** Array of books with chapters and verses */
684
- books: z5.array(BibleIndexBookSchema)
468
+ books: z4.array(BibleIndexBookSchema)
685
469
  });
686
470
 
687
471
  // src/schemas/collection.ts
688
- import { z as z6 } from "zod";
472
+ import { z as z5 } from "zod";
689
473
 
690
474
  // src/schemas/highlight.ts
691
- import { z as z7 } from "zod";
692
- var _HighlightSchema = z7.object({
475
+ import { z as z6 } from "zod";
476
+ var _HighlightSchema = z6.object({
693
477
  /** Bible version identifier */
694
- version_id: z7.number().int().positive(),
478
+ version_id: z6.number().int().positive(),
695
479
  /** Passage identifier (e.g., "MAT.1.1") */
696
- passage_id: z7.string(),
480
+ passage_id: z6.string(),
697
481
  /** Hex color code (6 digits, no #) */
698
- color: z7.string().regex(/^[0-9a-f]{6}$/)
482
+ color: z6.string().regex(/^[0-9a-f]{6}$/)
699
483
  });
700
- var _CreateHighlightSchema = z7.object({
484
+ var _CreateHighlightSchema = z6.object({
701
485
  /** Bible version identifier */
702
- version_id: z7.number().int().positive(),
486
+ version_id: z6.number().int().positive(),
703
487
  /** Passage identifier (e.g., "MAT.1.1") */
704
- passage_id: z7.string(),
488
+ passage_id: z6.string(),
705
489
  /** Hex color code (6 digits, no #) */
706
- color: z7.string().regex(/^[0-9a-f]{6}$/)
490
+ color: z6.string().regex(/^[0-9a-f]{6}$/)
707
491
  });
708
492
 
709
493
  // src/schemas/language.ts
710
- import { z as z8 } from "zod";
711
- var LanguageSchema = z8.object({
494
+ import { z as z7 } from "zod";
495
+ var LanguageSchema = z7.object({
712
496
  /** BCP 47 language identifier (e.g., "en") */
713
- id: z8.string().regex(/^[a-z]{2,3}(?:-[A-Z][a-z]{3})?$/, "BCP 47 id limited to language or language+script"),
497
+ id: z7.string().regex(/^[a-z]{2,3}(?:-[A-Z][a-z]{3})?$/, "BCP 47 id limited to language or language+script"),
714
498
  /** ISO 639 language code */
715
- language: z8.string().regex(/^[a-z]{2,3}$/, "ISO 639 canonical language subtag"),
499
+ language: z7.string().regex(/^[a-z]{2,3}$/, "ISO 639 canonical language subtag"),
716
500
  /** ISO 15924 script code (e.g., "Latn") */
717
- script: z8.string().regex(/^[A-Z][a-z]{3}$/, 'Script must match ISO 15924 format (e.g., "Latn")').nullable().optional(),
501
+ script: z7.string().regex(/^[A-Z][a-z]{3}$/, 'Script must match ISO 15924 format (e.g., "Latn")').nullable().optional(),
718
502
  /** Script name (e.g., "Latin") */
719
- script_name: z8.string().nullable().optional(),
503
+ script_name: z7.string().nullable().optional(),
720
504
  /** Language aliases */
721
- aliases: z8.array(z8.string()).optional(),
505
+ aliases: z7.array(z7.string()).optional(),
722
506
  /** Display names for different locales */
723
- display_names: z8.record(z8.string(), z8.string()).optional(),
507
+ display_names: z7.record(z7.string(), z7.string()).optional(),
724
508
  /** Available scripts for this language (e.g., ["Cyrl", "Latn"]) */
725
- scripts: z8.array(z8.string().regex(/^[A-Z][a-z]{3}$/, "ISO 15924 script code")).optional(),
509
+ scripts: z7.array(z7.string().regex(/^[A-Z][a-z]{3}$/, "ISO 15924 script code")).optional(),
726
510
  /** Language variants (e.g., ["1996", "fonipa"]) */
727
- variants: z8.array(z8.string()).optional(),
511
+ variants: z7.array(z7.string()).optional(),
728
512
  /** ISO 3166-1 alpha-2 country codes (e.g., ["RS", "BA", "ME"]) */
729
- countries: z8.array(z8.string().regex(/^[A-Z]{2}$/, "ISO 3166-1 alpha-2 country code")).optional(),
513
+ countries: z7.array(z7.string().regex(/^[A-Z]{2}$/, "ISO 3166-1 alpha-2 country code")).optional(),
730
514
  /** Text direction (ltr or rtl) */
731
- text_direction: z8.enum(["ltr", "rtl"]).optional(),
515
+ text_direction: z7.enum(["ltr", "rtl"]).optional(),
732
516
  /** Writing population count */
733
- writing_population: z8.number().int().optional(),
517
+ writing_population: z7.number().int().optional(),
734
518
  /** Speaking population count */
735
- speaking_population: z8.number().int().optional(),
519
+ speaking_population: z7.number().int().optional(),
736
520
  /** Default Bible version ID for this language */
737
- default_bible_id: z8.number().int().nullable().optional()
521
+ default_bible_id: z7.number().int().nullable().optional()
738
522
  });
739
523
 
740
524
  // src/schemas/passage.ts
741
- import { z as z9 } from "zod";
742
- var BiblePassageSchema = z9.object({
525
+ import { z as z8 } from "zod";
526
+ var BiblePassageSchema = z8.object({
743
527
  /** Passage identifier (e.g., "MAT.1.1") */
744
- id: z9.string(),
528
+ id: z8.string(),
745
529
  /** Passage content text */
746
- content: z9.string(),
530
+ content: z8.string(),
747
531
  /** Human-readable reference (e.g., "Matthew 1:1") */
748
- reference: z9.string()
532
+ reference: z8.string()
749
533
  });
750
534
 
751
535
  // src/schemas/version.ts
752
- import { z as z10 } from "zod";
753
- var BibleVersionSchema = z10.object({
536
+ import { z as z9 } from "zod";
537
+ var BibleVersionSchema = z9.object({
754
538
  /** Bible version identifier */
755
- id: z10.number().int(),
539
+ id: z9.number().int(),
756
540
  /** Bible version abbreviation */
757
- abbreviation: z10.string(),
541
+ abbreviation: z9.string(),
758
542
  /** Long copyright text */
759
- promotional_content: z10.string().nullable().optional(),
543
+ promotional_content: z9.string().nullable().optional(),
760
544
  /** Short copyright text */
761
- copyright: z10.string().nullable().optional(),
545
+ copyright: z9.string().nullable().optional(),
762
546
  /** Bible information text */
763
- info: z10.string().nullable().optional(),
547
+ info: z9.string().nullable().optional(),
764
548
  /** Publisher URL */
765
- publisher_url: z10.url().nullable().optional(),
549
+ publisher_url: z9.url().nullable().optional(),
766
550
  /** Language tag (e.g., "en") */
767
- language_tag: z10.string(),
551
+ language_tag: z9.string(),
768
552
  /** Localized abbreviation */
769
- localized_abbreviation: z10.string(),
553
+ localized_abbreviation: z9.string(),
770
554
  /** Localized title */
771
- localized_title: z10.string(),
555
+ localized_title: z9.string(),
772
556
  /** Organization ID of publisher */
773
- organization_id: z10.string().nullable().optional(),
557
+ organization_id: z9.string().nullable().optional(),
774
558
  /** Full title */
775
- title: z10.string(),
559
+ title: z9.string(),
776
560
  /** Array of book identifiers (e.g., ["GEN", "EXO", "LEV"]) */
777
- books: z10.array(BookUsfmSchema),
561
+ books: z9.array(BookUsfmSchema),
778
562
  /** YouVersion deep link URL */
779
- youversion_deep_link: z10.url()
563
+ youversion_deep_link: z9.url()
780
564
  });
781
565
 
782
566
  // src/schemas/votd.ts
783
- import { z as z11 } from "zod";
784
- var VOTDSchema = z11.object({
567
+ import { z as z10 } from "zod";
568
+ var VOTDSchema = z10.object({
785
569
  /** Day of year (1-366) */
786
- day: z11.number().int().min(1).max(366),
570
+ day: z10.number().int().min(1).max(366),
787
571
  /** Passage identifier (e.g., "JHN.3.16") */
788
- passage_id: z11.string()
572
+ passage_id: z10.string()
789
573
  });
790
574
 
791
575
  // src/schemas/user.ts
792
- import { z as z12 } from "zod";
793
- var _UserSchema = z12.object({
794
- avatar_url: z12.string(),
795
- first_name: z12.string(),
796
- id: z12.uuid(),
797
- last_name: z12.string()
576
+ import { z as z11 } from "zod";
577
+ var _UserSchema = z11.object({
578
+ avatar_url: z11.string(),
579
+ first_name: z11.string(),
580
+ id: z11.uuid(),
581
+ last_name: z11.string()
798
582
  });
799
583
 
584
+ // src/bible.ts
585
+ var BibleClient = class _BibleClient {
586
+ client;
587
+ // Validation schemas
588
+ static versionIdSchema = z12.number().int().positive("Version ID must be a positive integer");
589
+ static bookSchema = z12.string().trim().min(3, "Book ID must be exactly 3 characters").max(3, "Book ID must be exactly 3 characters");
590
+ static chapterSchema = z12.number().int("Chapter must be an integer").positive("Chapter must be a positive integer");
591
+ static verseSchema = z12.number().int("Verse must be an integer").positive("Verse must be a positive integer");
592
+ static languageRangesSchema = z12.string().trim().min(1, "Language ranges must be a non-empty string");
593
+ static booleanSchema = z12.boolean();
594
+ static GetVersionsOptionsSchema = z12.object({
595
+ page_size: z12.union([z12.number().int().positive(), z12.literal("*")]).optional(),
596
+ page_token: z12.string().optional(),
597
+ fields: z12.array(BibleVersionSchema.keyof()).optional(),
598
+ all_available: z12.boolean().optional()
599
+ }).optional().refine(
600
+ (data) => {
601
+ if (data?.page_size === "*") {
602
+ return data.fields && data.fields.length >= 1 && data.fields.length <= 3;
603
+ }
604
+ return true;
605
+ },
606
+ {
607
+ message: 'page_size="*" required 1-3 fields to be specified',
608
+ path: ["page_size", "fields"]
609
+ }
610
+ );
611
+ /**
612
+ * Creates a new BibleClient instance.
613
+ * @param client The API client to use for requests.
614
+ */
615
+ constructor(client) {
616
+ this.client = client;
617
+ }
618
+ /**
619
+ * Fetches a collection of Bible versions filtered by language ranges.
620
+ *
621
+ * @param language_ranges - One or more language codes or ranges to filter the versions (required).
622
+ * @param license_id - Optional license ID to filter versions by license.
623
+ * @returns A promise that resolves to a collection of BibleVersion objects.
624
+ */
625
+ async getVersions(language_ranges, license_id, options) {
626
+ const languageRangeArray = Array.isArray(language_ranges) ? language_ranges : [language_ranges];
627
+ const parsedLanguageRanges = z12.array(_BibleClient.languageRangesSchema).nonempty("At least one language range is required").parse(languageRangeArray);
628
+ const params = {
629
+ "language_ranges[]": parsedLanguageRanges
630
+ };
631
+ if (license_id) {
632
+ params.license_id = license_id;
633
+ }
634
+ _BibleClient.GetVersionsOptionsSchema.parse(options);
635
+ if (options?.page_size) {
636
+ params.page_size = options.page_size;
637
+ }
638
+ if (options?.fields) {
639
+ params["fields[]"] = options.fields;
640
+ }
641
+ if (options?.page_token) {
642
+ params.page_token = options.page_token;
643
+ }
644
+ if (options?.all_available) {
645
+ params.all_available = "true";
646
+ }
647
+ return this.client.get(`/v1/bibles`, params);
648
+ }
649
+ /**
650
+ * Fetches a Bible version by its ID.
651
+ * @param id The version ID.
652
+ * @returns The requested BibleVersion object.
653
+ */
654
+ async getVersion(id) {
655
+ _BibleClient.versionIdSchema.parse(id);
656
+ return this.client.get(`/v1/bibles/${id}`);
657
+ }
658
+ /**
659
+ * Fetches all books for a given Bible version.
660
+ * @param versionId The version ID.
661
+ * @param canon Optional canon filter ("old_testament", 'new_testament', 'deuterocanon').
662
+ * @returns An array of BibleBook objects. Each book may include an optional `intro` field
663
+ * containing metadata (id, passage_id, title) for the book's introduction when
664
+ * available in the Bible version.
665
+ */
666
+ async getBooks(versionId, canon) {
667
+ _BibleClient.versionIdSchema.parse(versionId);
668
+ return this.client.get(`/v1/bibles/${versionId}/books`, {
669
+ ...canon && { canon }
670
+ });
671
+ }
672
+ /**
673
+ * Fetches a specific book by USFM code for a given version.
674
+ * @param versionId The version ID.
675
+ * @param book The Book Identifier code of the book.
676
+ * @returns The requested BibleBook object, which may include an optional `intro` field
677
+ * containing metadata (id, passage_id, title) for the book's introduction when
678
+ * available. Use the `passage_id` with `getPassage()` to fetch intro content.
679
+ */
680
+ async getBook(versionId, book) {
681
+ _BibleClient.versionIdSchema.parse(versionId);
682
+ _BibleClient.bookSchema.parse(book);
683
+ return this.client.get(`/v1/bibles/${versionId}/books/${book}`);
684
+ }
685
+ /**
686
+ * Fetches all chapters for a specific book in a version.
687
+ * @param versionId The version ID.
688
+ * @param book The Book Identifier code of the book.
689
+ * @returns An array of BibleChapter objects.
690
+ */
691
+ async getChapters(versionId, book) {
692
+ _BibleClient.versionIdSchema.parse(versionId);
693
+ _BibleClient.bookSchema.parse(book);
694
+ return this.client.get(
695
+ `/v1/bibles/${versionId}/books/${book}/chapters`
696
+ );
697
+ }
698
+ /**
699
+ * Fetches a specific chapter for a book in a version.
700
+ * @param versionId The version ID.
701
+ * @param book The Book Identifier code of the book (3 characters, e.g., "MAT").
702
+ * @param chapter The chapter number
703
+ * @returns The requested BibleChapter object.
704
+ */
705
+ async getChapter(versionId, book, chapter) {
706
+ _BibleClient.versionIdSchema.parse(versionId);
707
+ _BibleClient.bookSchema.parse(book);
708
+ _BibleClient.chapterSchema.parse(chapter);
709
+ return this.client.get(
710
+ `/v1/bibles/${versionId}/books/${book}/chapters/${chapter}`
711
+ );
712
+ }
713
+ /**
714
+ * Fetches all verses for a specific chapter in a book and version.
715
+ * @param versionId The version ID.
716
+ * @param book The Book Identifier code of the book (3 characters, e.g., "MAT").
717
+ * @param chapter The chapter number.
718
+ * @returns An array of BibleVerse objects.
719
+ */
720
+ async getVerses(versionId, book, chapter) {
721
+ _BibleClient.versionIdSchema.parse(versionId);
722
+ _BibleClient.bookSchema.parse(book);
723
+ _BibleClient.chapterSchema.parse(chapter);
724
+ return this.client.get(
725
+ `/v1/bibles/${versionId}/books/${book}/chapters/${chapter}/verses`
726
+ );
727
+ }
728
+ /**
729
+ * Fetches a specific verse from a chapter, book, and version.
730
+ * @param versionId The version ID.
731
+ * @param book The Book Identifier code of the book (3 characters, e.g., "MAT").
732
+ * @param chapter The chapter number.
733
+ * @param verse The verse number.
734
+ * @returns The requested BibleVerse object.
735
+ */
736
+ async getVerse(versionId, book, chapter, verse) {
737
+ _BibleClient.versionIdSchema.parse(versionId);
738
+ _BibleClient.bookSchema.parse(book);
739
+ _BibleClient.chapterSchema.parse(chapter);
740
+ _BibleClient.verseSchema.parse(verse);
741
+ return this.client.get(
742
+ `/v1/bibles/${versionId}/books/${book}/chapters/${chapter}/verses/${verse}`
743
+ );
744
+ }
745
+ /**
746
+ * Fetches a passage (range of verses) from the Bible using the passages endpoint.
747
+ * This is the new API format that returns HTML-formatted content.
748
+ * @param versionId The version ID.
749
+ * @param usfm The USFM reference (e.g., "JHN.3.1-2", "GEN.1", "JHN.3.16").
750
+ * @param format The format to return ("html" or "text", default: "html").
751
+ * @param include_headings Whether to include headings in the content.
752
+ * @param include_notes Whether to include notes in the content.
753
+ * @returns The requested BiblePassage object with HTML content.
754
+ * @example
755
+ * ```ts
756
+ * // Get a single verse
757
+ * const verse = await bibleClient.getPassage(111, "JHN.3.16");
758
+ *
759
+ * // Get a range of verses
760
+ * const verses = await bibleClient.getPassage(111, "JHN.3.1-5");
761
+ *
762
+ * // Get an entire chapter
763
+ * const chapter = await bibleClient.getPassage(111, "GEN.1");
764
+ * ```
765
+ */
766
+ async getPassage(versionId, usfm, format = "html", include_headings, include_notes) {
767
+ _BibleClient.versionIdSchema.parse(versionId);
768
+ if (include_headings !== void 0) {
769
+ _BibleClient.booleanSchema.parse(include_headings);
770
+ }
771
+ if (include_notes !== void 0) {
772
+ _BibleClient.booleanSchema.parse(include_notes);
773
+ }
774
+ const params = {
775
+ format
776
+ };
777
+ if (include_headings !== void 0) {
778
+ params.include_headings = include_headings;
779
+ }
780
+ if (include_notes !== void 0) {
781
+ params.include_notes = include_notes;
782
+ }
783
+ return this.client.get(`/v1/bibles/${versionId}/passages/${usfm}`, params);
784
+ }
785
+ /**
786
+ * Fetches the indexing structure for a Bible version.
787
+ * @param versionId The version ID.
788
+ * @returns The BibleIndex object containing full hierarchy of books, chapters, and verses.
789
+ */
790
+ async getIndex(versionId) {
791
+ _BibleClient.versionIdSchema.parse(versionId);
792
+ return this.client.get(`/v1/bibles/${versionId}/index`);
793
+ }
794
+ /**
795
+ * Fetches the verse of the day calendar for an entire year.
796
+ * @returns A collection of VOTD objects for all days of the year.
797
+ */
798
+ async getAllVOTDs() {
799
+ return this.client.get(`/v1/verse_of_the_days`);
800
+ }
801
+ /**
802
+ * Fetches the passage_id for the Verse Of The Day.
803
+ * @param day The day of the year (1-366).
804
+ * @returns The day of the year and the passage_id for that day of the year
805
+ * @example
806
+ * ```ts
807
+ * // Get the passageId for the verse of the first day of the year.
808
+ * const passageId = await bibleClient.getVOTD(1);
809
+ *
810
+ * // Get the passageId for the verse of the 100th day of the year.
811
+ * const passageId = await bibleClient.getVOTD(100);
812
+ * ```
813
+ */
814
+ async getVOTD(day) {
815
+ const daySchema = z12.number().int().min(1).max(366);
816
+ daySchema.parse(day);
817
+ return this.client.get(`/v1/verse_of_the_days/${day}`);
818
+ }
819
+ };
820
+
800
821
  // src/languages.ts
822
+ import { z as z13 } from "zod";
801
823
  var LanguagesClient = class _LanguagesClient {
802
824
  client;
803
825
  static languageIdSchema = z13.string().trim().min(1, "Language ID must be a non-empty string").regex(