@helloao/tools 0.3.0 → 0.4.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.
@@ -6,6 +6,10 @@ import {
6
6
  CommentaryProfileSchema,
7
7
  DatasetBookChapterSchema,
8
8
  DatasetBookSchema,
9
+ DatasetEventSchema,
10
+ DatasetPeopleGroupSchema,
11
+ DatasetPersonSchema,
12
+ DatasetPlaceSchema,
9
13
  DatasetSchema,
10
14
  TranslationSchema,
11
15
  TranslationBookSchema,
@@ -22,6 +26,7 @@ import {
22
26
  simplifyCommentaryChapter
23
27
  } from "./simple.js";
24
28
  import { BookIdSchema } from "../utils.js";
29
+ import { bookOrderMap } from "./book-order.js";
25
30
  export const ApiAvailableTranslationsSchema = z.object({
26
31
  /**
27
32
  * The list of translations.
@@ -100,6 +105,62 @@ export const ApiDatasetSchema = DatasetSchema.extend({
100
105
  */
101
106
  languageEnglishName: z.string().optional().meta({
102
107
  description: "Gets the name of the language in English. Null or undefined if the language doesn't have an english name."
108
+ }),
109
+ /**
110
+ * The API link for the list of people for this dataset.
111
+ * Omitted if the dataset doesn't contain people.
112
+ */
113
+ listOfPeopleApiLink: z.string().optional().meta({
114
+ description: "The API link for the list of people for this dataset. Relative to the API origin. Omitted if the dataset doesn't contain people."
115
+ }),
116
+ /**
117
+ * The API link for the list of places for this dataset.
118
+ * Omitted if the dataset doesn't contain places.
119
+ */
120
+ listOfPlacesApiLink: z.string().optional().meta({
121
+ description: "The API link for the list of places for this dataset. Relative to the API origin. Omitted if the dataset doesn't contain places."
122
+ }),
123
+ /**
124
+ * The API link for the list of events for this dataset.
125
+ * Omitted if the dataset doesn't contain events.
126
+ */
127
+ listOfEventsApiLink: z.string().optional().meta({
128
+ description: "The API link for the list of events for this dataset. Relative to the API origin. Omitted if the dataset doesn't contain events."
129
+ }),
130
+ /**
131
+ * The API link for the list of people groups for this dataset.
132
+ * Omitted if the dataset doesn't contain people groups.
133
+ */
134
+ listOfPeopleGroupsApiLink: z.string().optional().meta({
135
+ description: "The API link for the list of people groups for this dataset. Relative to the API origin. Omitted if the dataset doesn't contain people groups."
136
+ }),
137
+ /**
138
+ * The total number of people that are contained in this dataset.
139
+ * Omitted if the dataset doesn't contain people.
140
+ */
141
+ totalNumberOfPeople: z.number().optional().meta({
142
+ description: "The total number of people that are contained in this dataset. Omitted if the dataset doesn't contain people."
143
+ }),
144
+ /**
145
+ * The total number of places that are contained in this dataset.
146
+ * Omitted if the dataset doesn't contain places.
147
+ */
148
+ totalNumberOfPlaces: z.number().optional().meta({
149
+ description: "The total number of places that are contained in this dataset. Omitted if the dataset doesn't contain places."
150
+ }),
151
+ /**
152
+ * The total number of events that are contained in this dataset.
153
+ * Omitted if the dataset doesn't contain events.
154
+ */
155
+ totalNumberOfEvents: z.number().optional().meta({
156
+ description: "The total number of events that are contained in this dataset. Omitted if the dataset doesn't contain events."
157
+ }),
158
+ /**
159
+ * The total number of people groups that are contained in this dataset.
160
+ * Omitted if the dataset doesn't contain people groups.
161
+ */
162
+ totalNumberOfPeopleGroups: z.number().optional().meta({
163
+ description: "The total number of people groups that are contained in this dataset. Omitted if the dataset doesn't contain people groups."
103
164
  })
104
165
  }).meta({
105
166
  id: "ApiDataset",
@@ -210,23 +271,37 @@ export const ApiTranslationCompleteSchema = z.object({
210
271
  id: "ApiTranslationComplete",
211
272
  description: "Defines the complete translation download data. Maps to the /api/:translationId/complete.json endpoint."
212
273
  });
213
- export const TranslationCompleteChapterSchema = TranslationBookChapterSchema.extend({
274
+ export const TranslationCompleteChapterSchema = TranslationBookChapterSchema.omit({ thisChapterWords: true }).extend({
214
275
  /**
215
276
  * The number of verses that the chapter contains.
216
277
  */
217
278
  numberOfVerses: z.number().meta({
218
279
  description: "The number of verses that the chapter contains."
280
+ }),
281
+ /**
282
+ * The link to the word-level annotations for the chapter.
283
+ * Omitted if the chapter doesn't have any word-level annotations.
284
+ */
285
+ thisChapterWordsLink: z.string().optional().meta({
286
+ description: "The link to the word-level annotations for this chapter. Relative to the API origin. Omitted if the chapter doesn't have any word-level annotations."
219
287
  })
220
288
  }).meta({
221
289
  id: "TranslationCompleteChapter",
222
290
  description: "A chapter in the complete translation download."
223
291
  });
224
- export const SimpleTranslationCompleteChapterSchema = SimpleTranslationBookChapterSchema.extend({
292
+ export const SimpleTranslationCompleteChapterSchema = SimpleTranslationBookChapterSchema.omit({ thisChapterWords: true }).extend({
225
293
  /**
226
294
  * The number of verses that the chapter contains.
227
295
  */
228
296
  numberOfVerses: z.number().meta({
229
297
  description: "The number of verses that the chapter contains."
298
+ }),
299
+ /**
300
+ * The link to the word-level annotations for the chapter.
301
+ * Omitted if the chapter doesn't have any word-level annotations.
302
+ */
303
+ thisChapterWordsLink: z.string().optional().meta({
304
+ description: "The link to the word-level annotations for this chapter. Relative to the API origin. Omitted if the chapter doesn't have any word-level annotations."
230
305
  })
231
306
  }).meta({
232
307
  id: "SimpleTranslationCompleteChapter",
@@ -401,6 +476,571 @@ export const ApiDatasetBooksSchema = z.object({
401
476
  id: "ApiDatasetBooks",
402
477
  description: "Defines an interface that contains information about the books that are available for a dataset."
403
478
  });
479
+ export const ApiDatasetPersonSummarySchema = z.object({
480
+ /**
481
+ * The ID of the person.
482
+ */
483
+ id: z.string().meta({
484
+ description: "The ID of the person."
485
+ }),
486
+ /**
487
+ * The name of the person.
488
+ */
489
+ name: z.string().meta({
490
+ description: "The name of the person."
491
+ }),
492
+ /**
493
+ * Whether the name of the person is a proper name.
494
+ */
495
+ isProperName: z.boolean().optional().meta({
496
+ description: "Whether the name of the person is a proper name."
497
+ }),
498
+ /**
499
+ * The gender of the person.
500
+ */
501
+ gender: z.string().optional().meta({
502
+ description: "The gender of the person."
503
+ }),
504
+ /**
505
+ * The number of Bible references that mention the person.
506
+ */
507
+ numberOfReferences: z.number().meta({
508
+ description: "The number of Bible references that mention the person."
509
+ }),
510
+ /**
511
+ * The API link for the person.
512
+ */
513
+ thisPersonApiLink: z.string().meta({
514
+ description: "The API link for the person. Relative to the API origin."
515
+ })
516
+ }).meta({
517
+ id: "ApiDatasetPersonSummary",
518
+ description: "Defines a summary of a person in a dataset."
519
+ });
520
+ export const ApiDatasetPeopleSchema = z.object({
521
+ /**
522
+ * The dataset information for the people.
523
+ */
524
+ dataset: z.lazy(() => ApiDatasetSchema).meta({
525
+ description: "The dataset information for the people."
526
+ }),
527
+ /**
528
+ * The list of people that are available for the dataset.
529
+ */
530
+ people: z.array(ApiDatasetPersonSummarySchema).meta({
531
+ description: "The list of people that are available for the dataset."
532
+ })
533
+ }).meta({
534
+ id: "ApiDatasetPeople",
535
+ description: "The list of people in a dataset. Maps to the /api/d/:datasetId/people.json endpoint."
536
+ });
537
+ export const ApiDatasetPersonSchema = z.object({
538
+ /**
539
+ * The dataset information for the person.
540
+ */
541
+ dataset: z.lazy(() => ApiDatasetSchema).meta({
542
+ description: "The dataset information for the person."
543
+ }),
544
+ /**
545
+ * The information about the person.
546
+ */
547
+ person: DatasetPersonSchema.meta({
548
+ description: "The information about the person."
549
+ }),
550
+ /**
551
+ * The API link for this person.
552
+ */
553
+ thisPersonApiLink: z.string().meta({
554
+ description: "The API link for this person. Relative to the API origin."
555
+ })
556
+ }).meta({
557
+ id: "ApiDatasetPerson",
558
+ description: "The information about a person in a dataset. Maps to the /api/d/:datasetId/people/:personId.json endpoint."
559
+ });
560
+ export const ApiDatasetPlaceSummarySchema = z.object({
561
+ /**
562
+ * The ID of the place.
563
+ */
564
+ id: z.string().meta({
565
+ description: "The ID of the place."
566
+ }),
567
+ /**
568
+ * The name of the place.
569
+ */
570
+ name: z.string().meta({
571
+ description: "The name of the place."
572
+ }),
573
+ /**
574
+ * The type of geographical feature that the place is.
575
+ */
576
+ featureType: z.string().optional().meta({
577
+ description: 'The type of geographical feature that the place is. For example, "City", "Region", "Mountain", "Water", etc.'
578
+ }),
579
+ /**
580
+ * The latitude of the place.
581
+ */
582
+ latitude: z.number().optional().meta({
583
+ description: "The latitude of the place."
584
+ }),
585
+ /**
586
+ * The longitude of the place.
587
+ */
588
+ longitude: z.number().optional().meta({
589
+ description: "The longitude of the place."
590
+ }),
591
+ /**
592
+ * The number of Bible references that mention the place.
593
+ */
594
+ numberOfReferences: z.number().meta({
595
+ description: "The number of Bible references that mention the place."
596
+ }),
597
+ /**
598
+ * The API link for the place.
599
+ */
600
+ thisPlaceApiLink: z.string().meta({
601
+ description: "The API link for the place. Relative to the API origin."
602
+ })
603
+ }).meta({
604
+ id: "ApiDatasetPlaceSummary",
605
+ description: "Defines a summary of a place in a dataset."
606
+ });
607
+ export const ApiDatasetPlacesSchema = z.object({
608
+ /**
609
+ * The dataset information for the places.
610
+ */
611
+ dataset: z.lazy(() => ApiDatasetSchema).meta({
612
+ description: "The dataset information for the places."
613
+ }),
614
+ /**
615
+ * The list of places that are available for the dataset.
616
+ */
617
+ places: z.array(ApiDatasetPlaceSummarySchema).meta({
618
+ description: "The list of places that are available for the dataset."
619
+ })
620
+ }).meta({
621
+ id: "ApiDatasetPlaces",
622
+ description: "The list of places in a dataset. Maps to the /api/d/:datasetId/places.json endpoint."
623
+ });
624
+ export const ApiDatasetPlaceSchema = z.object({
625
+ /**
626
+ * The dataset information for the place.
627
+ */
628
+ dataset: z.lazy(() => ApiDatasetSchema).meta({
629
+ description: "The dataset information for the place."
630
+ }),
631
+ /**
632
+ * The information about the place.
633
+ */
634
+ place: DatasetPlaceSchema.meta({
635
+ description: "The information about the place."
636
+ }),
637
+ /**
638
+ * The API link for this place.
639
+ */
640
+ thisPlaceApiLink: z.string().meta({
641
+ description: "The API link for this place. Relative to the API origin."
642
+ })
643
+ }).meta({
644
+ id: "ApiDatasetPlace",
645
+ description: "The information about a place in a dataset. Maps to the /api/d/:datasetId/places/:placeId.json endpoint."
646
+ });
647
+ export const ApiDatasetEventSummarySchema = z.object({
648
+ /**
649
+ * The ID of the event.
650
+ */
651
+ id: z.string().meta({
652
+ description: "The ID of the event."
653
+ }),
654
+ /**
655
+ * The name of the event.
656
+ */
657
+ name: z.string().meta({
658
+ description: "The name of the event."
659
+ }),
660
+ /**
661
+ * The date that the event started at.
662
+ */
663
+ startDate: z.string().optional().meta({
664
+ description: "The date that the event started at. Negative numbers are years BC. Positive numbers are years AD. More specific dates use the `YYYY-MM-DD` format."
665
+ }),
666
+ /**
667
+ * The number of Bible references that describe the event.
668
+ */
669
+ numberOfReferences: z.number().meta({
670
+ description: "The number of Bible references that describe the event."
671
+ }),
672
+ /**
673
+ * The API link for the event.
674
+ */
675
+ thisEventApiLink: z.string().meta({
676
+ description: "The API link for the event. Relative to the API origin."
677
+ })
678
+ }).meta({
679
+ id: "ApiDatasetEventSummary",
680
+ description: "Defines a summary of an event in a dataset."
681
+ });
682
+ export const ApiDatasetEventsSchema = z.object({
683
+ /**
684
+ * The dataset information for the events.
685
+ */
686
+ dataset: z.lazy(() => ApiDatasetSchema).meta({
687
+ description: "The dataset information for the events."
688
+ }),
689
+ /**
690
+ * The list of events that are available for the dataset.
691
+ */
692
+ events: z.array(ApiDatasetEventSummarySchema).meta({
693
+ description: "The list of events that are available for the dataset."
694
+ })
695
+ }).meta({
696
+ id: "ApiDatasetEvents",
697
+ description: "The list of events in a dataset. Maps to the /api/d/:datasetId/events.json endpoint."
698
+ });
699
+ export const ApiDatasetEventSchema = z.object({
700
+ /**
701
+ * The dataset information for the event.
702
+ */
703
+ dataset: z.lazy(() => ApiDatasetSchema).meta({
704
+ description: "The dataset information for the event."
705
+ }),
706
+ /**
707
+ * The information about the event.
708
+ */
709
+ event: DatasetEventSchema.meta({
710
+ description: "The information about the event."
711
+ }),
712
+ /**
713
+ * The API link for this event.
714
+ */
715
+ thisEventApiLink: z.string().meta({
716
+ description: "The API link for this event. Relative to the API origin."
717
+ })
718
+ }).meta({
719
+ id: "ApiDatasetEvent",
720
+ description: "The information about an event in a dataset. Maps to the /api/d/:datasetId/events/:eventId.json endpoint."
721
+ });
722
+ export const ApiDatasetPeopleGroupSummarySchema = z.object({
723
+ /**
724
+ * The ID of the people group.
725
+ */
726
+ id: z.string().meta({
727
+ description: "The ID of the people group."
728
+ }),
729
+ /**
730
+ * The name of the people group.
731
+ */
732
+ name: z.string().meta({
733
+ description: "The name of the people group."
734
+ }),
735
+ /**
736
+ * The number of people that are members of the people group.
737
+ */
738
+ numberOfMembers: z.number().meta({
739
+ description: "The number of people that are members of the people group."
740
+ }),
741
+ /**
742
+ * The API link for the people group.
743
+ */
744
+ thisPeopleGroupApiLink: z.string().meta({
745
+ description: "The API link for the people group. Relative to the API origin."
746
+ })
747
+ }).meta({
748
+ id: "ApiDatasetPeopleGroupSummary",
749
+ description: "Defines a summary of a people group in a dataset."
750
+ });
751
+ export const ApiDatasetPeopleGroupsSchema = z.object({
752
+ /**
753
+ * The dataset information for the people groups.
754
+ */
755
+ dataset: z.lazy(() => ApiDatasetSchema).meta({
756
+ description: "The dataset information for the people groups."
757
+ }),
758
+ /**
759
+ * The list of people groups that are available for the dataset.
760
+ */
761
+ groups: z.array(ApiDatasetPeopleGroupSummarySchema).meta({
762
+ description: "The list of people groups that are available for the dataset."
763
+ })
764
+ }).meta({
765
+ id: "ApiDatasetPeopleGroups",
766
+ description: "The list of people groups in a dataset. Maps to the /api/d/:datasetId/groups.json endpoint."
767
+ });
768
+ export const ApiDatasetPeopleGroupSchema = z.object({
769
+ /**
770
+ * The dataset information for the people group.
771
+ */
772
+ dataset: z.lazy(() => ApiDatasetSchema).meta({
773
+ description: "The dataset information for the people group."
774
+ }),
775
+ /**
776
+ * The information about the people group.
777
+ */
778
+ group: DatasetPeopleGroupSchema.meta({
779
+ description: "The information about the people group."
780
+ }),
781
+ /**
782
+ * The API link for this people group.
783
+ */
784
+ thisPeopleGroupApiLink: z.string().meta({
785
+ description: "The API link for this people group. Relative to the API origin."
786
+ })
787
+ }).meta({
788
+ id: "ApiDatasetPeopleGroup",
789
+ description: "The information about a people group in a dataset. Maps to the /api/d/:datasetId/groups/:groupId.json endpoint."
790
+ });
791
+ export const ApiDatasetChapterPersonSchema = z.object({
792
+ /**
793
+ * The ID of the person.
794
+ */
795
+ id: z.string().meta({
796
+ description: "The ID of the person."
797
+ }),
798
+ /**
799
+ * The name of the person.
800
+ */
801
+ name: z.string().meta({
802
+ description: "The name of the person."
803
+ }),
804
+ /**
805
+ * Whether the name of the person is a proper name.
806
+ */
807
+ isProperName: z.boolean().optional().meta({
808
+ description: "Whether the name of the person is a proper name."
809
+ }),
810
+ /**
811
+ * The gender of the person.
812
+ */
813
+ gender: z.string().optional().meta({
814
+ description: "The gender of the person."
815
+ }),
816
+ /**
817
+ * The year that the person was born.
818
+ * Negative numbers are years BC. Positive numbers are years AD.
819
+ */
820
+ birthYear: z.number().optional().meta({
821
+ description: "The year that the person was born. Negative numbers are years BC. Positive numbers are years AD."
822
+ }),
823
+ /**
824
+ * The year that the person died.
825
+ * Negative numbers are years BC. Positive numbers are years AD.
826
+ */
827
+ deathYear: z.number().optional().meta({
828
+ description: "The year that the person died. Negative numbers are years BC. Positive numbers are years AD."
829
+ }),
830
+ /**
831
+ * The API link for the person.
832
+ */
833
+ apiLink: z.string().meta({
834
+ description: "The API link for the person. Relative to the API origin."
835
+ }),
836
+ /**
837
+ * The numbers of the verses in the chapter that mention the person.
838
+ * Sorted in ascending order.
839
+ */
840
+ verses: z.array(z.number()).meta({
841
+ description: "The numbers of the verses in the chapter that mention the person. Sorted in ascending order."
842
+ })
843
+ }).meta({
844
+ id: "ApiDatasetChapterPerson",
845
+ description: "Defines a person that appears in a chapter of a dataset."
846
+ });
847
+ export const ApiDatasetChapterPlaceSchema = z.object({
848
+ /**
849
+ * The ID of the place.
850
+ */
851
+ id: z.string().meta({
852
+ description: "The ID of the place."
853
+ }),
854
+ /**
855
+ * The name of the place.
856
+ */
857
+ name: z.string().meta({
858
+ description: "The name of the place."
859
+ }),
860
+ /**
861
+ * The type of geographical feature that the place is.
862
+ */
863
+ featureType: z.string().optional().meta({
864
+ description: 'The type of geographical feature that the place is. For example, "City", "Region", "Mountain", "Water", etc.'
865
+ }),
866
+ /**
867
+ * The latitude of the place.
868
+ */
869
+ latitude: z.number().optional().meta({
870
+ description: "The latitude of the place."
871
+ }),
872
+ /**
873
+ * The longitude of the place.
874
+ */
875
+ longitude: z.number().optional().meta({
876
+ description: "The longitude of the place."
877
+ }),
878
+ /**
879
+ * The API link for the place.
880
+ */
881
+ apiLink: z.string().meta({
882
+ description: "The API link for the place. Relative to the API origin."
883
+ }),
884
+ /**
885
+ * The numbers of the verses in the chapter that mention the place.
886
+ * Sorted in ascending order.
887
+ */
888
+ verses: z.array(z.number()).meta({
889
+ description: "The numbers of the verses in the chapter that mention the place. Sorted in ascending order."
890
+ })
891
+ }).meta({
892
+ id: "ApiDatasetChapterPlace",
893
+ description: "Defines a place that appears in a chapter of a dataset."
894
+ });
895
+ export const ApiDatasetChapterEventSchema = z.object({
896
+ /**
897
+ * The ID of the event.
898
+ */
899
+ id: z.string().meta({
900
+ description: "The ID of the event."
901
+ }),
902
+ /**
903
+ * The name of the event.
904
+ */
905
+ name: z.string().meta({
906
+ description: "The name of the event."
907
+ }),
908
+ /**
909
+ * The date that the event started at.
910
+ */
911
+ startDate: z.string().optional().meta({
912
+ description: "The date that the event started at. Negative numbers are years BC. Positive numbers are years AD. More specific dates use the `YYYY-MM-DD` format."
913
+ }),
914
+ /**
915
+ * The API link for the event.
916
+ */
917
+ apiLink: z.string().meta({
918
+ description: "The API link for the event. Relative to the API origin."
919
+ }),
920
+ /**
921
+ * The numbers of the verses in the chapter that describe the event.
922
+ * Sorted in ascending order.
923
+ */
924
+ verses: z.array(z.number()).meta({
925
+ description: "The numbers of the verses in the chapter that describe the event. Sorted in ascending order."
926
+ })
927
+ }).meta({
928
+ id: "ApiDatasetChapterEvent",
929
+ description: "Defines an event that appears in a chapter of a dataset."
930
+ });
931
+ export const ApiDatasetEntityChapterDataSchema = z.object({
932
+ /**
933
+ * The number of the chapter.
934
+ */
935
+ number: z.number().meta({
936
+ description: "The number of the chapter."
937
+ }),
938
+ /**
939
+ * The people that appear in the chapter.
940
+ * Sorted by the first verse that they appear in.
941
+ */
942
+ people: z.array(ApiDatasetChapterPersonSchema).meta({
943
+ description: "The people that appear in the chapter. Sorted by the first verse that they appear in."
944
+ }),
945
+ /**
946
+ * The places that appear in the chapter.
947
+ * Sorted by the first verse that they appear in.
948
+ */
949
+ places: z.array(ApiDatasetChapterPlaceSchema).meta({
950
+ description: "The places that appear in the chapter. Sorted by the first verse that they appear in."
951
+ }),
952
+ /**
953
+ * The events that appear in the chapter.
954
+ * Sorted by the first verse that they appear in.
955
+ */
956
+ events: z.array(ApiDatasetChapterEventSchema).meta({
957
+ description: "The events that appear in the chapter. Sorted by the first verse that they appear in."
958
+ })
959
+ }).meta({
960
+ id: "ApiDatasetEntityChapterData",
961
+ description: "Defines the entity data for a chapter in a dataset. Contains the people, places, and events that appear in the chapter."
962
+ });
963
+ export const ApiDatasetEntityBookChapterSchema = z.object({
964
+ /**
965
+ * The dataset information for the book chapter.
966
+ */
967
+ dataset: z.lazy(() => ApiDatasetSchema).meta({
968
+ description: "The dataset information for the book chapter."
969
+ }),
970
+ /**
971
+ * The book information for the book chapter.
972
+ */
973
+ book: z.lazy(() => ApiDatasetBookSchema).meta({
974
+ description: "The book information for the book chapter."
975
+ }),
976
+ /**
977
+ * The entity data for the chapter.
978
+ */
979
+ chapter: ApiDatasetEntityChapterDataSchema.meta({
980
+ description: "The entity data for the chapter."
981
+ }),
982
+ /**
983
+ * The link to this chapter.
984
+ */
985
+ thisChapterLink: z.string().meta({
986
+ description: "The link to this chapter. Relative to the API origin."
987
+ }),
988
+ /**
989
+ * The reference for this chapter.
990
+ */
991
+ thisChapterReference: z.lazy(() => DatasetChapterReferenceSchema).meta({
992
+ description: "The reference for this chapter."
993
+ }),
994
+ /**
995
+ * The link to the next chapter.
996
+ * Null if this is the last chapter in the dataset.
997
+ */
998
+ nextChapterApiLink: z.string().nullable().meta({
999
+ description: "The link to the next chapter. Relative to the API origin. Null if this is the last chapter in the dataset."
1000
+ }),
1001
+ /**
1002
+ * The reference for the next chapter.
1003
+ * Null if this is the last chapter in the dataset.
1004
+ */
1005
+ nextChapterReference: z.lazy(() => DatasetChapterReferenceSchema).nullable().meta({
1006
+ description: "The reference for the next chapter. Null if this is the last chapter in the dataset."
1007
+ }),
1008
+ /**
1009
+ * The link to the previous chapter.
1010
+ * Null if this is the first chapter in the dataset.
1011
+ */
1012
+ previousChapterApiLink: z.string().nullable().meta({
1013
+ description: "The link to the previous chapter. Relative to the API origin. Null if this is the first chapter in the dataset."
1014
+ }),
1015
+ /**
1016
+ * The reference for the previous chapter.
1017
+ * Null if this is the first chapter in the dataset.
1018
+ */
1019
+ previousChapterReference: z.lazy(() => DatasetChapterReferenceSchema).nullable().meta({
1020
+ description: "The reference for the previous chapter. Null if this is the first chapter in the dataset."
1021
+ }),
1022
+ /**
1023
+ * The number of people that appear in the chapter.
1024
+ */
1025
+ numberOfPeople: z.number().meta({
1026
+ description: "The number of people that appear in the chapter."
1027
+ }),
1028
+ /**
1029
+ * The number of places that appear in the chapter.
1030
+ */
1031
+ numberOfPlaces: z.number().meta({
1032
+ description: "The number of places that appear in the chapter."
1033
+ }),
1034
+ /**
1035
+ * The number of events that appear in the chapter.
1036
+ */
1037
+ numberOfEvents: z.number().meta({
1038
+ description: "The number of events that appear in the chapter."
1039
+ })
1040
+ }).meta({
1041
+ id: "ApiDatasetEntityBookChapter",
1042
+ description: "The entities (people, places, and events) that appear in a chapter of a book for a dataset. Maps to the /api/d/:datasetId/:bookId/:chapterNumber.json endpoint for datasets that contain entities."
1043
+ });
404
1044
  export const ApiCommentaryProfilesSchema = z.object({
405
1045
  /**
406
1046
  * The commentary information for the books.
@@ -1148,12 +1788,19 @@ export function generateApiForDataset(dataset, options = {}) {
1148
1788
  };
1149
1789
  if (generateSimpleChapterFiles) {
1150
1790
  api.simpleTranslationBookChapters = [];
1151
- api.simpleTranslationBookChapterWords = [];
1152
1791
  api.simpleCommentaryBookChapters = [];
1153
1792
  }
1793
+ if (generateSimpleChapterFiles || options.generateCompleteTranslationFiles) {
1794
+ api.simpleTranslationBookChapterWords = [];
1795
+ }
1154
1796
  const getNativeName = options.getNativeName;
1155
1797
  const getEnglishName = options.getEnglishName;
1156
1798
  for (let { books, ...translation } of dataset.translations) {
1799
+ let hasSimpleWords2 = function(chapter) {
1800
+ const words = simplifiedChapters.get(chapter)?.words;
1801
+ return !!words && Object.keys(words).length > 0;
1802
+ };
1803
+ var hasSimpleWords = hasSimpleWords2;
1157
1804
  let numberOfBooks = 0;
1158
1805
  let numberOfApocryphalBooks = 0;
1159
1806
  for (let book of books) {
@@ -1396,72 +2043,74 @@ export function generateApiForDataset(dataset, options = {}) {
1396
2043
  );
1397
2044
  }
1398
2045
  }
1399
- if (api.simpleTranslationBookChapters) {
1400
- let hasSimpleWords2 = function(chapter) {
1401
- const words = simplifiedChapters.get(chapter)?.words;
1402
- return !!words && Object.keys(words).length > 0;
1403
- };
1404
- var hasSimpleWords = hasSimpleWords2;
1405
- const simpleChapterLink = (chapter) => bookChapterApiLink(
1406
- translation.id,
1407
- getBookLink(chapter.book),
1408
- chapter.chapter.number,
1409
- SIMPLE_JSON_EXTENSION,
1410
- apiPathPrefix
1411
- );
1412
- const simpleWordsLink = (chapter) => hasSimpleWords2(chapter) ? bookChapterWordsApiLink(
1413
- translation.id,
1414
- getBookLink(chapter.book),
1415
- chapter.chapter.number,
1416
- apiPathPrefix,
1417
- SIMPLE_JSON_EXTENSION
1418
- ) : void 0;
2046
+ const simpleChapterLink = (chapter) => bookChapterApiLink(
2047
+ translation.id,
2048
+ getBookLink(chapter.book),
2049
+ chapter.chapter.number,
2050
+ SIMPLE_JSON_EXTENSION,
2051
+ apiPathPrefix
2052
+ );
2053
+ const simpleWordsLink = (chapter) => hasSimpleWords2(chapter) ? bookChapterWordsApiLink(
2054
+ translation.id,
2055
+ getBookLink(chapter.book),
2056
+ chapter.chapter.number,
2057
+ apiPathPrefix,
2058
+ SIMPLE_JSON_EXTENSION
2059
+ ) : void 0;
2060
+ if (api.simpleTranslationBookChapters || api.simpleTranslationBookChapterWords) {
1419
2061
  for (let i = 0; i < translationChapters.length; i++) {
1420
2062
  const currentChapter = translationChapters[i];
1421
- const {
1422
- chapter,
1423
- simpleChapterApiLink,
1424
- thisChapterWordsLink,
1425
- nextChapterWordsLink,
1426
- previousChapterWordsLink,
1427
- ...rest
1428
- } = currentChapter;
1429
2063
  const previousChapter = translationChapters[i - 1];
1430
2064
  const nextChapter = translationChapters[i + 1];
1431
2065
  const simplified = simplifiedChapters.get(currentChapter);
1432
- const simpleChapter = {
1433
- ...rest,
1434
- chapter: simplified.chapter,
1435
- thisChapterLink: simpleChapterLink(currentChapter),
1436
- fullChapterApiLink: rest.thisChapterLink,
1437
- previousChapterApiLink: previousChapter ? simpleChapterLink(previousChapter) : null,
1438
- nextChapterApiLink: nextChapter ? simpleChapterLink(nextChapter) : null
1439
- };
2066
+ let simpleChapter;
2067
+ if (api.simpleTranslationBookChapters) {
2068
+ const {
2069
+ chapter,
2070
+ simpleChapterApiLink,
2071
+ thisChapterWordsLink,
2072
+ nextChapterWordsLink,
2073
+ previousChapterWordsLink,
2074
+ ...rest
2075
+ } = currentChapter;
2076
+ simpleChapter = {
2077
+ ...rest,
2078
+ chapter: simplified.chapter,
2079
+ thisChapterLink: simpleChapterLink(currentChapter),
2080
+ fullChapterApiLink: rest.thisChapterLink,
2081
+ previousChapterApiLink: previousChapter ? simpleChapterLink(previousChapter) : null,
2082
+ nextChapterApiLink: nextChapter ? simpleChapterLink(nextChapter) : null
2083
+ };
2084
+ }
1440
2085
  const thisWordsLink = simpleWordsLink(currentChapter);
1441
2086
  if (thisWordsLink) {
1442
- simpleChapter.thisChapterWordsLink = thisWordsLink;
2087
+ if (simpleChapter) {
2088
+ simpleChapter.thisChapterWordsLink = thisWordsLink;
2089
+ }
1443
2090
  api.simpleTranslationBookChapterWords?.push({
1444
2091
  translationId: translation.id,
1445
2092
  bookId: currentChapter.book.id,
1446
2093
  chapterNumber: currentChapter.chapter.number,
1447
- thisChapterLink: simpleChapter.thisChapterLink,
1448
- nextChapterLink: simpleChapter.nextChapterApiLink,
1449
- previousChapterLink: simpleChapter.previousChapterApiLink,
2094
+ thisChapterLink: simpleChapter?.thisChapterLink ?? currentChapter.thisChapterLink,
2095
+ nextChapterLink: simpleChapter?.nextChapterApiLink ?? currentChapter.nextChapterApiLink,
2096
+ previousChapterLink: simpleChapter?.previousChapterApiLink ?? currentChapter.previousChapterApiLink,
1450
2097
  thisChapterWordsLink: thisWordsLink,
1451
2098
  nextChapterWordsLink: nextChapter ? simpleWordsLink(nextChapter) ?? null : null,
1452
2099
  previousChapterWordsLink: previousChapter ? simpleWordsLink(previousChapter) ?? null : null,
1453
2100
  verses: simplified.words
1454
2101
  });
1455
2102
  }
1456
- const nextWordsLink = nextChapter ? simpleWordsLink(nextChapter) : void 0;
1457
- if (nextWordsLink) {
1458
- simpleChapter.nextChapterWordsLink = nextWordsLink;
1459
- }
1460
- const previousWordsLink = previousChapter ? simpleWordsLink(previousChapter) : void 0;
1461
- if (previousWordsLink) {
1462
- simpleChapter.previousChapterWordsLink = previousWordsLink;
2103
+ if (simpleChapter) {
2104
+ const nextWordsLink = nextChapter ? simpleWordsLink(nextChapter) : void 0;
2105
+ if (nextWordsLink) {
2106
+ simpleChapter.nextChapterWordsLink = nextWordsLink;
2107
+ }
2108
+ const previousWordsLink = previousChapter ? simpleWordsLink(previousChapter) : void 0;
2109
+ if (previousWordsLink) {
2110
+ simpleChapter.previousChapterWordsLink = previousWordsLink;
2111
+ }
2112
+ api.simpleTranslationBookChapters.push(simpleChapter);
1463
2113
  }
1464
- api.simpleTranslationBookChapters.push(simpleChapter);
1465
2114
  }
1466
2115
  }
1467
2116
  for (let { reader, verses, apiBookChapter } of pendingAudioTimings) {
@@ -1530,16 +2179,16 @@ export function generateApiForDataset(dataset, options = {}) {
1530
2179
  books: completeBooks.map(
1531
2180
  ({ book, chapters }) => completeBook(
1532
2181
  book,
1533
- chapters.map((ch) => {
1534
- const words = rawWordsByChapter.get(ch);
1535
- return {
1536
- ...completeChapter(ch),
1537
- // The complete files also contain the word annotations
1538
- // themselves rather than links to them.
1539
- ...words ? { thisChapterWords: words } : {},
1540
- chapter: ch.chapter
1541
- };
1542
- })
2182
+ chapters.map((ch) => ({
2183
+ ...completeChapter(ch),
2184
+ // The complete files link to the word annotations
2185
+ // rather than embedding them, same as the regular
2186
+ // per-chapter endpoint.
2187
+ ...ch.thisChapterWordsLink ? {
2188
+ thisChapterWordsLink: ch.thisChapterWordsLink
2189
+ } : {},
2190
+ chapter: ch.chapter
2191
+ }))
1543
2192
  )
1544
2193
  )
1545
2194
  };
@@ -1551,10 +2200,10 @@ export function generateApiForDataset(dataset, options = {}) {
1551
2200
  book,
1552
2201
  chapters.map((ch) => {
1553
2202
  const simplified = simplifiedChapters.get(ch);
1554
- const hasWords = Object.keys(simplified.words).length > 0;
2203
+ const wordsLink = simpleWordsLink(ch);
1555
2204
  return {
1556
2205
  ...completeChapter(ch),
1557
- ...hasWords ? { thisChapterWords: simplified.words } : {},
2206
+ ...wordsLink ? { thisChapterWordsLink: wordsLink } : {},
1558
2207
  chapter: simplified.chapter
1559
2208
  };
1560
2209
  })
@@ -1756,7 +2405,14 @@ export function generateApiForDataset(dataset, options = {}) {
1756
2405
  api.commentaryBooks.push(commentaryBooks);
1757
2406
  api.commentaryProfiles.push(commentaryProfiles);
1758
2407
  }
1759
- for (let { books, ...datasetInfo } of dataset.datasets ?? []) {
2408
+ for (let {
2409
+ books,
2410
+ people,
2411
+ places,
2412
+ events,
2413
+ peopleGroups,
2414
+ ...datasetInfo
2415
+ } of dataset.datasets ?? []) {
1760
2416
  const apiDataset = {
1761
2417
  ...datasetInfo,
1762
2418
  availableFormats: ["json"],
@@ -1881,6 +2537,447 @@ export function generateApiForDataset(dataset, options = {}) {
1881
2537
  };
1882
2538
  }
1883
2539
  }
2540
+ const linkEntityRef = (collection, ref) => ref ? {
2541
+ ...ref,
2542
+ type: collection,
2543
+ apiLink: datasetEntityApiLink(
2544
+ datasetInfo.id,
2545
+ collection,
2546
+ ref.id,
2547
+ "json",
2548
+ apiPathPrefix
2549
+ )
2550
+ } : void 0;
2551
+ const linkEntityRefs = (collection, refs) => refs?.map((ref) => linkEntityRef(collection, ref));
2552
+ if (people) {
2553
+ const datasetPeople = {
2554
+ dataset: apiDataset,
2555
+ people: []
2556
+ };
2557
+ for (let person of people) {
2558
+ const thisPersonApiLink = datasetEntityApiLink(
2559
+ datasetInfo.id,
2560
+ "people",
2561
+ person.id,
2562
+ "json",
2563
+ apiPathPrefix
2564
+ );
2565
+ datasetPeople.people.push({
2566
+ id: person.id,
2567
+ name: person.name,
2568
+ isProperName: person.isProperName,
2569
+ gender: person.gender,
2570
+ numberOfReferences: person.references.length,
2571
+ thisPersonApiLink
2572
+ });
2573
+ const apiPerson = {
2574
+ dataset: apiDataset,
2575
+ person: {
2576
+ ...person,
2577
+ birthPlace: linkEntityRef("places", person.birthPlace),
2578
+ deathPlace: linkEntityRef("places", person.deathPlace),
2579
+ father: linkEntityRefs("people", person.father),
2580
+ mother: linkEntityRefs("people", person.mother),
2581
+ partners: linkEntityRefs("people", person.partners),
2582
+ children: linkEntityRefs("people", person.children),
2583
+ siblings: linkEntityRefs("people", person.siblings),
2584
+ halfSiblingsSameMother: linkEntityRefs(
2585
+ "people",
2586
+ person.halfSiblingsSameMother
2587
+ ),
2588
+ halfSiblingsSameFather: linkEntityRefs(
2589
+ "people",
2590
+ person.halfSiblingsSameFather
2591
+ ),
2592
+ memberOf: linkEntityRefs("groups", person.memberOf),
2593
+ events: linkEntityRefs("events", person.events)
2594
+ },
2595
+ thisPersonApiLink
2596
+ };
2597
+ if (!api.datasetPeopleContents) {
2598
+ api.datasetPeopleContents = [];
2599
+ }
2600
+ api.datasetPeopleContents.push(apiPerson);
2601
+ }
2602
+ apiDataset.listOfPeopleApiLink = listOfDatasetEntitiesApiLink(
2603
+ datasetInfo.id,
2604
+ "people",
2605
+ "json",
2606
+ apiPathPrefix
2607
+ );
2608
+ apiDataset.totalNumberOfPeople = people.length;
2609
+ if (!api.datasetPeople) {
2610
+ api.datasetPeople = [];
2611
+ }
2612
+ api.datasetPeople.push(datasetPeople);
2613
+ }
2614
+ if (places) {
2615
+ const datasetPlaces = {
2616
+ dataset: apiDataset,
2617
+ places: []
2618
+ };
2619
+ for (let place of places) {
2620
+ const thisPlaceApiLink = datasetEntityApiLink(
2621
+ datasetInfo.id,
2622
+ "places",
2623
+ place.id,
2624
+ "json",
2625
+ apiPathPrefix
2626
+ );
2627
+ datasetPlaces.places.push({
2628
+ id: place.id,
2629
+ name: place.name,
2630
+ featureType: place.featureType,
2631
+ latitude: place.latitude,
2632
+ longitude: place.longitude,
2633
+ numberOfReferences: place.references.length,
2634
+ thisPlaceApiLink
2635
+ });
2636
+ const apiPlace = {
2637
+ dataset: apiDataset,
2638
+ place: {
2639
+ ...place,
2640
+ rootPlace: linkEntityRef("places", place.rootPlace),
2641
+ duplicateOf: linkEntityRef("places", place.duplicateOf),
2642
+ people: linkEntityRefs("people", place.people),
2643
+ peopleBorn: linkEntityRefs("people", place.peopleBorn),
2644
+ peopleDied: linkEntityRefs("people", place.peopleDied),
2645
+ events: linkEntityRefs("events", place.events)
2646
+ },
2647
+ thisPlaceApiLink
2648
+ };
2649
+ if (!api.datasetPlaceContents) {
2650
+ api.datasetPlaceContents = [];
2651
+ }
2652
+ api.datasetPlaceContents.push(apiPlace);
2653
+ }
2654
+ apiDataset.listOfPlacesApiLink = listOfDatasetEntitiesApiLink(
2655
+ datasetInfo.id,
2656
+ "places",
2657
+ "json",
2658
+ apiPathPrefix
2659
+ );
2660
+ apiDataset.totalNumberOfPlaces = places.length;
2661
+ if (!api.datasetPlaces) {
2662
+ api.datasetPlaces = [];
2663
+ }
2664
+ api.datasetPlaces.push(datasetPlaces);
2665
+ }
2666
+ if (events) {
2667
+ const datasetEvents = {
2668
+ dataset: apiDataset,
2669
+ events: []
2670
+ };
2671
+ for (let event of events) {
2672
+ const thisEventApiLink = datasetEntityApiLink(
2673
+ datasetInfo.id,
2674
+ "events",
2675
+ event.id,
2676
+ "json",
2677
+ apiPathPrefix
2678
+ );
2679
+ datasetEvents.events.push({
2680
+ id: event.id,
2681
+ name: event.name,
2682
+ startDate: event.startDate,
2683
+ numberOfReferences: event.references.length,
2684
+ thisEventApiLink
2685
+ });
2686
+ const apiEvent = {
2687
+ dataset: apiDataset,
2688
+ event: {
2689
+ ...event,
2690
+ participants: linkEntityRefs(
2691
+ "people",
2692
+ event.participants
2693
+ ),
2694
+ locations: linkEntityRefs("places", event.locations),
2695
+ groups: linkEntityRefs("groups", event.groups),
2696
+ partOf: linkEntityRef("events", event.partOf),
2697
+ predecessor: linkEntityRef("events", event.predecessor)
2698
+ },
2699
+ thisEventApiLink
2700
+ };
2701
+ if (!api.datasetEventContents) {
2702
+ api.datasetEventContents = [];
2703
+ }
2704
+ api.datasetEventContents.push(apiEvent);
2705
+ }
2706
+ apiDataset.listOfEventsApiLink = listOfDatasetEntitiesApiLink(
2707
+ datasetInfo.id,
2708
+ "events",
2709
+ "json",
2710
+ apiPathPrefix
2711
+ );
2712
+ apiDataset.totalNumberOfEvents = events.length;
2713
+ if (!api.datasetEvents) {
2714
+ api.datasetEvents = [];
2715
+ }
2716
+ api.datasetEvents.push(datasetEvents);
2717
+ }
2718
+ if (peopleGroups) {
2719
+ const datasetPeopleGroups = {
2720
+ dataset: apiDataset,
2721
+ groups: []
2722
+ };
2723
+ for (let group of peopleGroups) {
2724
+ const thisPeopleGroupApiLink = datasetEntityApiLink(
2725
+ datasetInfo.id,
2726
+ "groups",
2727
+ group.id,
2728
+ "json",
2729
+ apiPathPrefix
2730
+ );
2731
+ datasetPeopleGroups.groups.push({
2732
+ id: group.id,
2733
+ name: group.name,
2734
+ numberOfMembers: group.members?.length ?? 0,
2735
+ thisPeopleGroupApiLink
2736
+ });
2737
+ const apiGroup = {
2738
+ dataset: apiDataset,
2739
+ group: {
2740
+ ...group,
2741
+ members: linkEntityRefs("people", group.members),
2742
+ events: linkEntityRefs("events", group.events)
2743
+ },
2744
+ thisPeopleGroupApiLink
2745
+ };
2746
+ if (!api.datasetPeopleGroupContents) {
2747
+ api.datasetPeopleGroupContents = [];
2748
+ }
2749
+ api.datasetPeopleGroupContents.push(apiGroup);
2750
+ }
2751
+ apiDataset.listOfPeopleGroupsApiLink = listOfDatasetEntitiesApiLink(
2752
+ datasetInfo.id,
2753
+ "groups",
2754
+ "json",
2755
+ apiPathPrefix
2756
+ );
2757
+ apiDataset.totalNumberOfPeopleGroups = peopleGroups.length;
2758
+ if (!api.datasetPeopleGroups) {
2759
+ api.datasetPeopleGroups = [];
2760
+ }
2761
+ api.datasetPeopleGroups.push(datasetPeopleGroups);
2762
+ }
2763
+ if (books.length <= 0 && (people || places || events)) {
2764
+ let addEntityVerses2 = function(collection, references, createEntry) {
2765
+ for (let reference of references) {
2766
+ let bookChapters = chapterMap.get(reference.book);
2767
+ if (!bookChapters) {
2768
+ bookChapters = /* @__PURE__ */ new Map();
2769
+ chapterMap.set(reference.book, bookChapters);
2770
+ }
2771
+ let chapterEntities = bookChapters.get(reference.chapter);
2772
+ if (!chapterEntities) {
2773
+ chapterEntities = {
2774
+ people: /* @__PURE__ */ new Map(),
2775
+ places: /* @__PURE__ */ new Map(),
2776
+ events: /* @__PURE__ */ new Map()
2777
+ };
2778
+ bookChapters.set(reference.chapter, chapterEntities);
2779
+ }
2780
+ const entry = createEntry();
2781
+ const entities = chapterEntities[collection];
2782
+ let existing = entities.get(entry.id);
2783
+ if (!existing) {
2784
+ existing = { ...entry, verses: [] };
2785
+ entities.set(entry.id, existing);
2786
+ }
2787
+ const endVerse = reference.endVerse ?? reference.verse;
2788
+ for (let verse = reference.verse; verse <= endVerse; verse++) {
2789
+ existing.verses.push(verse);
2790
+ }
2791
+ }
2792
+ }, sortEntities2 = function(entities) {
2793
+ const list = [...entities.values()];
2794
+ for (let entity of list) {
2795
+ entity.verses.sort((a, b) => a - b);
2796
+ }
2797
+ return list.sort(
2798
+ (a, b) => a.verses[0] - b.verses[0] || a.id.localeCompare(b.id)
2799
+ );
2800
+ };
2801
+ var addEntityVerses = addEntityVerses2, sortEntities = sortEntities2;
2802
+ const chapterMap = /* @__PURE__ */ new Map();
2803
+ for (let person of people ?? []) {
2804
+ addEntityVerses2(
2805
+ "people",
2806
+ person.references,
2807
+ () => ({
2808
+ id: person.id,
2809
+ name: person.name,
2810
+ isProperName: person.isProperName,
2811
+ gender: person.gender,
2812
+ birthYear: person.birthYear,
2813
+ deathYear: person.deathYear,
2814
+ apiLink: datasetEntityApiLink(
2815
+ datasetInfo.id,
2816
+ "people",
2817
+ person.id,
2818
+ "json",
2819
+ apiPathPrefix
2820
+ )
2821
+ })
2822
+ );
2823
+ }
2824
+ for (let place of places ?? []) {
2825
+ addEntityVerses2(
2826
+ "places",
2827
+ place.references,
2828
+ () => ({
2829
+ id: place.id,
2830
+ name: place.name,
2831
+ featureType: place.featureType,
2832
+ latitude: place.latitude,
2833
+ longitude: place.longitude,
2834
+ apiLink: datasetEntityApiLink(
2835
+ datasetInfo.id,
2836
+ "places",
2837
+ place.id,
2838
+ "json",
2839
+ apiPathPrefix
2840
+ )
2841
+ })
2842
+ );
2843
+ }
2844
+ for (let event of events ?? []) {
2845
+ addEntityVerses2(
2846
+ "events",
2847
+ event.references,
2848
+ () => ({
2849
+ id: event.id,
2850
+ name: event.name,
2851
+ startDate: event.startDate,
2852
+ apiLink: datasetEntityApiLink(
2853
+ datasetInfo.id,
2854
+ "events",
2855
+ event.id,
2856
+ "json",
2857
+ apiPathPrefix
2858
+ )
2859
+ })
2860
+ );
2861
+ }
2862
+ const sortedBooks = [...chapterMap.keys()].sort(
2863
+ (a, b) => (bookOrderMap.get(a) ?? 9999) - (bookOrderMap.get(b) ?? 9999)
2864
+ );
2865
+ const entityChapters = [];
2866
+ for (let bookId of sortedBooks) {
2867
+ const bookChapters = chapterMap.get(bookId);
2868
+ const chapterNumbers = [...bookChapters.keys()].sort(
2869
+ (a, b) => a - b
2870
+ );
2871
+ const firstChapterNumber = chapterNumbers[0];
2872
+ const lastChapterNumber = chapterNumbers[chapterNumbers.length - 1];
2873
+ const apiBook = {
2874
+ id: bookId,
2875
+ order: bookOrderMap.get(bookId) ?? 9999,
2876
+ firstChapterNumber,
2877
+ firstChapterApiLink: bookDatasetChapterApiLink(
2878
+ datasetInfo.id,
2879
+ bookId,
2880
+ firstChapterNumber,
2881
+ "json",
2882
+ apiPathPrefix
2883
+ ),
2884
+ firstChapterReference: {
2885
+ datasetId: datasetInfo.id,
2886
+ book: bookId,
2887
+ chapter: firstChapterNumber
2888
+ },
2889
+ lastChapterNumber,
2890
+ lastChapterApiLink: bookDatasetChapterApiLink(
2891
+ datasetInfo.id,
2892
+ bookId,
2893
+ lastChapterNumber,
2894
+ "json",
2895
+ apiPathPrefix
2896
+ ),
2897
+ lastChapterReference: {
2898
+ datasetId: datasetInfo.id,
2899
+ book: bookId,
2900
+ chapter: lastChapterNumber
2901
+ },
2902
+ numberOfChapters: chapterNumbers.length,
2903
+ totalNumberOfVerses: 0,
2904
+ totalNumberOfReferences: 0
2905
+ };
2906
+ for (let chapterNumber of chapterNumbers) {
2907
+ const chapterEntities = bookChapters.get(chapterNumber);
2908
+ const chapterPeople = sortEntities2(chapterEntities.people);
2909
+ const chapterPlaces = sortEntities2(chapterEntities.places);
2910
+ const chapterEvents = sortEntities2(chapterEntities.events);
2911
+ const distinctVerses = /* @__PURE__ */ new Set();
2912
+ let numberOfReferences = 0;
2913
+ for (let list of [
2914
+ chapterPeople,
2915
+ chapterPlaces,
2916
+ chapterEvents
2917
+ ]) {
2918
+ for (let entity of list) {
2919
+ numberOfReferences += entity.verses.length;
2920
+ for (let verse of entity.verses) {
2921
+ distinctVerses.add(verse);
2922
+ }
2923
+ }
2924
+ }
2925
+ apiBook.totalNumberOfVerses += distinctVerses.size;
2926
+ apiBook.totalNumberOfReferences += numberOfReferences;
2927
+ const apiChapter = {
2928
+ dataset: apiDataset,
2929
+ book: apiBook,
2930
+ chapter: {
2931
+ number: chapterNumber,
2932
+ people: chapterPeople,
2933
+ places: chapterPlaces,
2934
+ events: chapterEvents
2935
+ },
2936
+ thisChapterLink: bookDatasetChapterApiLink(
2937
+ datasetInfo.id,
2938
+ bookId,
2939
+ chapterNumber,
2940
+ "json",
2941
+ apiPathPrefix
2942
+ ),
2943
+ thisChapterReference: {
2944
+ datasetId: datasetInfo.id,
2945
+ book: bookId,
2946
+ chapter: chapterNumber
2947
+ },
2948
+ nextChapterApiLink: null,
2949
+ nextChapterReference: null,
2950
+ previousChapterApiLink: null,
2951
+ previousChapterReference: null,
2952
+ numberOfPeople: chapterPeople.length,
2953
+ numberOfPlaces: chapterPlaces.length,
2954
+ numberOfEvents: chapterEvents.length
2955
+ };
2956
+ entityChapters.push(apiChapter);
2957
+ }
2958
+ datasetBooks.books.push(apiBook);
2959
+ apiDataset.totalNumberOfChapters += apiBook.numberOfChapters;
2960
+ apiDataset.totalNumberOfVerses += apiBook.totalNumberOfVerses;
2961
+ apiDataset.totalNumberOfReferences += apiBook.totalNumberOfReferences;
2962
+ }
2963
+ apiDataset.numberOfBooks = datasetBooks.books.length;
2964
+ for (let i = 0; i < entityChapters.length; i++) {
2965
+ if (i > 0) {
2966
+ entityChapters[i].previousChapterApiLink = entityChapters[i - 1].thisChapterLink;
2967
+ entityChapters[i].previousChapterReference = entityChapters[i - 1].thisChapterReference;
2968
+ }
2969
+ if (i < entityChapters.length - 1) {
2970
+ entityChapters[i].nextChapterApiLink = entityChapters[i + 1].thisChapterLink;
2971
+ entityChapters[i].nextChapterReference = entityChapters[i + 1].thisChapterReference;
2972
+ }
2973
+ }
2974
+ if (entityChapters.length > 0) {
2975
+ if (!api.datasetEntityBookChapters) {
2976
+ api.datasetEntityBookChapters = [];
2977
+ }
2978
+ api.datasetEntityBookChapters.push(...entityChapters);
2979
+ }
2980
+ }
1884
2981
  if (!api.availableDatasets) {
1885
2982
  api.availableDatasets = {
1886
2983
  datasets: []
@@ -2009,6 +3106,44 @@ export function generateFilesForApi(api) {
2009
3106
  );
2010
3107
  }
2011
3108
  }
3109
+ for (let entityChapter of api.datasetEntityBookChapters ?? []) {
3110
+ files.push(jsonFile(entityChapter.thisChapterLink, entityChapter));
3111
+ }
3112
+ for (let datasetPeople of api.datasetPeople ?? []) {
3113
+ files.push(
3114
+ jsonFile(datasetPeople.dataset.listOfPeopleApiLink, datasetPeople)
3115
+ );
3116
+ }
3117
+ for (let person of api.datasetPeopleContents ?? []) {
3118
+ files.push(jsonFile(person.thisPersonApiLink, person));
3119
+ }
3120
+ for (let datasetPlaces of api.datasetPlaces ?? []) {
3121
+ files.push(
3122
+ jsonFile(datasetPlaces.dataset.listOfPlacesApiLink, datasetPlaces)
3123
+ );
3124
+ }
3125
+ for (let place of api.datasetPlaceContents ?? []) {
3126
+ files.push(jsonFile(place.thisPlaceApiLink, place));
3127
+ }
3128
+ for (let datasetEvents of api.datasetEvents ?? []) {
3129
+ files.push(
3130
+ jsonFile(datasetEvents.dataset.listOfEventsApiLink, datasetEvents)
3131
+ );
3132
+ }
3133
+ for (let event of api.datasetEventContents ?? []) {
3134
+ files.push(jsonFile(event.thisEventApiLink, event));
3135
+ }
3136
+ for (let datasetPeopleGroups of api.datasetPeopleGroups ?? []) {
3137
+ files.push(
3138
+ jsonFile(
3139
+ datasetPeopleGroups.dataset.listOfPeopleGroupsApiLink,
3140
+ datasetPeopleGroups
3141
+ )
3142
+ );
3143
+ }
3144
+ for (let group of api.datasetPeopleGroupContents ?? []) {
3145
+ files.push(jsonFile(group.thisPeopleGroupApiLink, group));
3146
+ }
2012
3147
  return files;
2013
3148
  }
2014
3149
  export async function* generateOutputFilesFromDatasets(datasets, options) {
@@ -2030,6 +3165,14 @@ export function listOfCommentaryBooksApiLink(commentaryId, prefix = "") {
2030
3165
  export function listOfDatasetBooksApiLink(datasetId, prefix = "") {
2031
3166
  return `${prefix}/api/d/${datasetId}/books.json`;
2032
3167
  }
3168
+ export function listOfDatasetEntitiesApiLink(datasetId, collection, extension = "json", prefix = "") {
3169
+ return `${prefix}/api/d/${datasetId}/${collection}.${extension}`;
3170
+ }
3171
+ export function datasetEntityApiLink(datasetId, collection, entityId, extension = "json", prefix = "") {
3172
+ return `${prefix}/api/d/${datasetId}/${collection}/${replaceSpacesWithUnderscores(
3173
+ entityId
3174
+ )}.${extension}`;
3175
+ }
2033
3176
  export const SIMPLE_JSON_EXTENSION = "simple.json";
2034
3177
  export function bookChapterApiLink(translationId, commonName, chapterNumber, extension, prefix = "") {
2035
3178
  return `${prefix}/api/${translationId}/${replaceSpacesWithUnderscores(