@digitalculture/ochre-sdk 0.2.5 → 0.2.6

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.cjs CHANGED
@@ -59,6 +59,7 @@ __export(index_exports, {
59
59
  parseObservations: () => parseObservations,
60
60
  parsePeriod: () => parsePeriod,
61
61
  parsePeriods: () => parsePeriods,
62
+ parsePerson: () => parsePerson,
62
63
  parsePersons: () => parsePersons,
63
64
  parseProperties: () => parseProperties,
64
65
  parseResource: () => parseResource,
@@ -716,17 +717,20 @@ function parseLicense(license) {
716
717
  url: license.license.target
717
718
  };
718
719
  }
720
+ function parsePerson(person) {
721
+ return {
722
+ uuid: person.uuid,
723
+ publicationDateTime: person.publicationDateTime != null ? new Date(person.publicationDateTime) : null,
724
+ type: person.type ?? null,
725
+ date: person.date != null ? new Date(person.date) : null,
726
+ identification: person.identification ? parseIdentification(person.identification) : null,
727
+ content: person.content != null ? parseFakeString(person.content) : null
728
+ };
729
+ }
719
730
  function parsePersons(persons) {
720
731
  const returnPersons = [];
721
732
  for (const person of persons) {
722
- returnPersons.push({
723
- uuid: person.uuid,
724
- publicationDateTime: person.publicationDateTime != null ? new Date(person.publicationDateTime) : null,
725
- type: person.type ?? null,
726
- date: person.date != null ? new Date(person.date) : null,
727
- identification: person.identification ? parseIdentification(person.identification) : null,
728
- content: person.content != null ? parseFakeString(person.content) : null
729
- });
733
+ returnPersons.push(parsePerson(person));
730
734
  }
731
735
  return returnPersons;
732
736
  }
@@ -795,7 +799,11 @@ function parseImage(image) {
795
799
  identification: image.identification ? parseIdentification(image.identification) : null,
796
800
  url: image.href ?? (image.htmlImgSrcPrefix == null && image.content != null ? parseFakeString(image.content) : null),
797
801
  htmlPrefix: image.htmlImgSrcPrefix ?? null,
798
- content: image.htmlImgSrcPrefix != null && image.content != null ? parseFakeString(image.content) : null
802
+ content: image.htmlImgSrcPrefix != null && image.content != null ? parseFakeString(image.content) : null,
803
+ widthPreview: image.widthPreview ?? null,
804
+ heightPreview: image.heightPreview ?? null,
805
+ width: image.width ?? null,
806
+ height: image.height ?? null
799
807
  };
800
808
  }
801
809
  function parseNotes(notes, language = "eng") {
@@ -1049,6 +1057,7 @@ function parseTree(tree) {
1049
1057
  let concepts = [];
1050
1058
  let periods = [];
1051
1059
  let bibliographies = [];
1060
+ let persons = [];
1052
1061
  if (typeof tree.items !== "string" && "resource" in tree.items) {
1053
1062
  resources = parseResources(
1054
1063
  Array.isArray(tree.items.resource) ? tree.items.resource : [tree.items.resource]
@@ -1074,6 +1083,11 @@ function parseTree(tree) {
1074
1083
  Array.isArray(tree.items.bibliography) ? tree.items.bibliography : [tree.items.bibliography]
1075
1084
  );
1076
1085
  }
1086
+ if (typeof tree.items !== "string" && "person" in tree.items) {
1087
+ persons = parsePersons(
1088
+ Array.isArray(tree.items.person) ? tree.items.person : [tree.items.person]
1089
+ );
1090
+ }
1077
1091
  const returnTree = {
1078
1092
  uuid: tree.uuid,
1079
1093
  category: "tree",
@@ -1089,7 +1103,8 @@ function parseTree(tree) {
1089
1103
  spatialUnits,
1090
1104
  concepts,
1091
1105
  periods,
1092
- bibliographies
1106
+ bibliographies,
1107
+ persons
1093
1108
  },
1094
1109
  properties: tree.properties ? parseProperties(
1095
1110
  Array.isArray(tree.properties.property) ? tree.properties.property : [tree.properties.property]
@@ -1103,6 +1118,7 @@ function parseSet(set) {
1103
1118
  let concepts = [];
1104
1119
  let periods = [];
1105
1120
  let bibliographies = [];
1121
+ let persons = [];
1106
1122
  if (typeof set.items !== "string" && "resource" in set.items) {
1107
1123
  resources = parseResources(
1108
1124
  Array.isArray(set.items.resource) ? set.items.resource : [set.items.resource],
@@ -1131,6 +1147,11 @@ function parseSet(set) {
1131
1147
  Array.isArray(set.items.bibliography) ? set.items.bibliography : [set.items.bibliography]
1132
1148
  );
1133
1149
  }
1150
+ if (typeof set.items !== "string" && "person" in set.items) {
1151
+ persons = parsePersons(
1152
+ Array.isArray(set.items.person) ? set.items.person : [set.items.person]
1153
+ );
1154
+ }
1134
1155
  return {
1135
1156
  uuid: set.uuid,
1136
1157
  category: "set",
@@ -1150,7 +1171,8 @@ function parseSet(set) {
1150
1171
  spatialUnits,
1151
1172
  concepts,
1152
1173
  periods,
1153
- bibliographies
1174
+ bibliographies,
1175
+ persons
1154
1176
  }
1155
1177
  };
1156
1178
  }
@@ -1482,6 +1504,15 @@ async function parseWebElementProperties(componentProperty, elementResource) {
1482
1504
  `Image link not found for the following component: \u201C${componentName}\u201D`
1483
1505
  );
1484
1506
  }
1507
+ const images = [];
1508
+ for (const imageLink of imageLinks) {
1509
+ images.push({
1510
+ url: `https://ochre.lib.uchicago.edu/ochre?uuid=${imageLink.uuid}&load`,
1511
+ label: imageLink.identification?.label ?? null,
1512
+ width: imageLink.image?.width ?? 0,
1513
+ height: imageLink.image?.height ?? 0
1514
+ });
1515
+ }
1485
1516
  let captionLayout = getPropertyValueByLabel(
1486
1517
  componentProperty.properties,
1487
1518
  "caption-layout"
@@ -1510,20 +1541,40 @@ async function parseWebElementProperties(componentProperty, elementResource) {
1510
1541
  if (altTextSource === null) {
1511
1542
  altTextSource = "name";
1512
1543
  }
1513
- const images = [];
1514
- for (const imageLink of imageLinks) {
1515
- images.push({
1516
- url: `https://ochre.lib.uchicago.edu/ochre?uuid=${imageLink.uuid}&load`,
1517
- label: imageLink.identification?.label ?? null,
1518
- width: imageLink.image?.width ?? 0,
1519
- height: imageLink.image?.height ?? 0
1520
- });
1544
+ const carousel = images.length > 1 ? {
1545
+ secondsPerImage: 5,
1546
+ isFullWidth: false,
1547
+ isFullHeight: false
1548
+ } : null;
1549
+ if (carousel !== null) {
1550
+ const carouselSecondsPerImage = getPropertyValueByLabel(
1551
+ componentProperty.properties,
1552
+ "carousel-seconds-per-image"
1553
+ );
1554
+ if (carouselSecondsPerImage !== null) {
1555
+ carousel.secondsPerImage = Number.parseFloat(carouselSecondsPerImage);
1556
+ }
1557
+ const carouselIsFullWidth = getPropertyValueByLabel(
1558
+ componentProperty.properties,
1559
+ "carousel-full-width"
1560
+ );
1561
+ if (carouselIsFullWidth !== null) {
1562
+ carousel.isFullWidth = carouselIsFullWidth === "Yes";
1563
+ }
1564
+ const carouselIsFullHeight = getPropertyValueByLabel(
1565
+ componentProperty.properties,
1566
+ "carousel-full-height"
1567
+ );
1568
+ if (carouselIsFullHeight !== null) {
1569
+ carousel.isFullHeight = carouselIsFullHeight === "Yes";
1570
+ }
1521
1571
  }
1522
1572
  properties.images = images;
1523
1573
  properties.imageQuality = imageQuality;
1524
1574
  properties.captionLayout = captionLayout;
1525
1575
  properties.captionSource = captionSource;
1526
1576
  properties.altTextSource = altTextSource;
1577
+ properties.carousel = carousel;
1527
1578
  break;
1528
1579
  }
1529
1580
  case "image-gallery": {
@@ -2307,6 +2358,7 @@ async function fetchWebsite(abbreviation) {
2307
2358
  parseObservations,
2308
2359
  parsePeriod,
2309
2360
  parsePeriods,
2361
+ parsePerson,
2310
2362
  parsePersons,
2311
2363
  parseProperties,
2312
2364
  parseResource,
package/dist/index.d.cts CHANGED
@@ -11,7 +11,7 @@ type Data = {
11
11
  };
12
12
  publicationDateTime: Date;
13
13
  metadata: Metadata;
14
- item: Tree | Set | Resource | SpatialUnit | Concept;
14
+ item: Tree | Set | Resource | SpatialUnit | Concept | Period | Bibliography | Person;
15
15
  };
16
16
  /**
17
17
  * Basic identification information used across multiple types
@@ -100,6 +100,10 @@ type Image = {
100
100
  url: string | null;
101
101
  htmlPrefix: string | null;
102
102
  content: string | null;
103
+ widthPreview: number | null;
104
+ heightPreview: number | null;
105
+ width: number | null;
106
+ height: number | null;
103
107
  };
104
108
  /**
105
109
  * Represents a link to another item with optional image and bibliographic references
@@ -288,6 +292,7 @@ type Set = {
288
292
  concepts: Array<NestedConcept>;
289
293
  periods: Array<Period>;
290
294
  bibliographies: Array<Bibliography>;
295
+ persons: Array<Person>;
291
296
  };
292
297
  };
293
298
  /**
@@ -377,6 +382,7 @@ type Tree = {
377
382
  concepts: Array<Concept>;
378
383
  periods: Array<Period>;
379
384
  bibliographies: Array<Bibliography>;
385
+ persons: Array<Person>;
380
386
  };
381
387
  properties: Array<Property>;
382
388
  };
@@ -493,6 +499,11 @@ type WebElementComponent = {
493
499
  captionSource: "name" | "abbreviation" | "description";
494
500
  captionLayout: "top" | "bottom" | "suppress";
495
501
  altTextSource: "name" | "abbreviation" | "description";
502
+ carousel: {
503
+ secondsPerImage: number;
504
+ isFullWidth: boolean;
505
+ isFullHeight: boolean;
506
+ } | null;
496
507
  } | {
497
508
  component: "image-gallery";
498
509
  galleryId: string;
@@ -733,6 +744,7 @@ type OchreData = {
733
744
  | { concept: OchreConcept }
734
745
  | { period: OchrePeriod }
735
746
  | { bibliography: OchreBibliography }
747
+ | { person: OchrePerson }
736
748
  );
737
749
  };
738
750
 
@@ -776,7 +788,8 @@ type OchreTree = {
776
788
  | { spatialUnit: OchreSpatialUnit | Array<OchreSpatialUnit> }
777
789
  | { concept: OchreConcept | Array<OchreConcept> }
778
790
  | { period: OchrePeriod | Array<OchrePeriod> }
779
- | { bibliography: OchreBibliography | Array<OchreBibliography> };
791
+ | { bibliography: OchreBibliography | Array<OchreBibliography> }
792
+ | { person: OchrePerson | Array<OchrePerson> };
780
793
  properties?: { property: OchreProperty | Array<OchreProperty> };
781
794
  };
782
795
 
@@ -800,7 +813,8 @@ type OchreSet = {
800
813
  | { spatialUnit: OchreSpatialUnit | Array<OchreSpatialUnit> }
801
814
  | { concept: OchreConcept | Array<OchreConcept> }
802
815
  | { period: OchrePeriod | Array<OchrePeriod> }
803
- | { bibliography: OchreBibliography | Array<OchreBibliography> };
816
+ | { bibliography: OchreBibliography | Array<OchreBibliography> }
817
+ | { person: OchrePerson | Array<OchrePerson> };
804
818
  };
805
819
 
806
820
  /**
@@ -980,6 +994,10 @@ type OchreImage = {
980
994
  href?: string;
981
995
  htmlImgSrcPrefix?: string;
982
996
  content?: FakeString;
997
+ widthPreview?: number;
998
+ heightPreview?: number;
999
+ width?: number;
1000
+ height?: number;
983
1001
  };
984
1002
 
985
1003
  /**
@@ -1531,7 +1549,14 @@ declare function parseLicense(license: OchreLicense): License | null;
1531
1549
  /**
1532
1550
  * Parses raw person data into the standardized Person type
1533
1551
  *
1534
- * @param persons - Raw person data from OCHRE format
1552
+ * @param person - Raw person data from OCHRE format
1553
+ * @returns Parsed Person object
1554
+ */
1555
+ declare function parsePerson(person: OchrePerson): Person;
1556
+ /**
1557
+ * Parses raw person data into the standardized Person type
1558
+ *
1559
+ * @param persons - Array of raw person data from OCHRE format
1535
1560
  * @returns Array of parsed Person objects
1536
1561
  */
1537
1562
  declare function parsePersons(persons: Array<OchrePerson>): Array<Person>;
@@ -1777,4 +1802,4 @@ declare function trimEndLineBreaks(string: string): string;
1777
1802
  */
1778
1803
  declare function parseStringContent(content: OchreStringContent, language?: string): string;
1779
1804
 
1780
- export { type Bibliography, type Concept, type Context, type ContextItem, type ContextNode, type Coordinates, type Data, type Document, type Event, type Footnote, type Gallery, type Identification, type Image, type ImageMap, type ImageMapArea, type Interpretation, type License, type Link, type Metadata, type NestedConcept, type NestedResource, type NestedSpatialUnit, type Note, type Observation, type Period, type Person, type Property, type PropertyValue, type PropertyValueType, type Resource, type Set, type SpatialUnit, type Style, type Tree, type WebElement, type WebElementComponent, type WebImage, type Webpage, type WebpageProperties, type Website, type WebsiteProperties, fetchBibliography, fetchByUuid, fetchConcept, fetchGallery, fetchPeriod, fetchResource, fetchSet, fetchSpatialUnit, fetchTree, fetchWebsite, filterProperties, getAllPropertyLabels, getPropertyByLabel, getPropertyValueByLabel, getPropertyValuesByLabel, parseBibliographies, parseBibliography, parseConcept, parseConcepts, parseContext, parseCoordinates, parseDocument, parseEmailAndUrl, parseEvents, parseFakeString, parseIdentification, parseImage, parseImageMap, parseInterpretations, parseLanguages, parseLicense, parseLink, parseLinks, parseMetadata, parseNotes, parseObservation, parseObservations, parsePeriod, parsePeriods, parsePersons, parseProperties, parseResource, parseResources, parseSet, parseSpatialUnit, parseSpatialUnits, parseStringContent, parseStringDocumentItem, parseStringItem, parseTree, parseWebsite, trimEndLineBreaks };
1805
+ export { type Bibliography, type Concept, type Context, type ContextItem, type ContextNode, type Coordinates, type Data, type Document, type Event, type Footnote, type Gallery, type Identification, type Image, type ImageMap, type ImageMapArea, type Interpretation, type License, type Link, type Metadata, type NestedConcept, type NestedResource, type NestedSpatialUnit, type Note, type Observation, type Period, type Person, type Property, type PropertyValue, type PropertyValueType, type Resource, type Set, type SpatialUnit, type Style, type Tree, type WebElement, type WebElementComponent, type WebImage, type Webpage, type WebpageProperties, type Website, type WebsiteProperties, fetchBibliography, fetchByUuid, fetchConcept, fetchGallery, fetchPeriod, fetchResource, fetchSet, fetchSpatialUnit, fetchTree, fetchWebsite, filterProperties, getAllPropertyLabels, getPropertyByLabel, getPropertyValueByLabel, getPropertyValuesByLabel, parseBibliographies, parseBibliography, parseConcept, parseConcepts, parseContext, parseCoordinates, parseDocument, parseEmailAndUrl, parseEvents, parseFakeString, parseIdentification, parseImage, parseImageMap, parseInterpretations, parseLanguages, parseLicense, parseLink, parseLinks, parseMetadata, parseNotes, parseObservation, parseObservations, parsePeriod, parsePeriods, parsePerson, parsePersons, parseProperties, parseResource, parseResources, parseSet, parseSpatialUnit, parseSpatialUnits, parseStringContent, parseStringDocumentItem, parseStringItem, parseTree, parseWebsite, trimEndLineBreaks };
package/dist/index.d.ts CHANGED
@@ -11,7 +11,7 @@ type Data = {
11
11
  };
12
12
  publicationDateTime: Date;
13
13
  metadata: Metadata;
14
- item: Tree | Set | Resource | SpatialUnit | Concept;
14
+ item: Tree | Set | Resource | SpatialUnit | Concept | Period | Bibliography | Person;
15
15
  };
16
16
  /**
17
17
  * Basic identification information used across multiple types
@@ -100,6 +100,10 @@ type Image = {
100
100
  url: string | null;
101
101
  htmlPrefix: string | null;
102
102
  content: string | null;
103
+ widthPreview: number | null;
104
+ heightPreview: number | null;
105
+ width: number | null;
106
+ height: number | null;
103
107
  };
104
108
  /**
105
109
  * Represents a link to another item with optional image and bibliographic references
@@ -288,6 +292,7 @@ type Set = {
288
292
  concepts: Array<NestedConcept>;
289
293
  periods: Array<Period>;
290
294
  bibliographies: Array<Bibliography>;
295
+ persons: Array<Person>;
291
296
  };
292
297
  };
293
298
  /**
@@ -377,6 +382,7 @@ type Tree = {
377
382
  concepts: Array<Concept>;
378
383
  periods: Array<Period>;
379
384
  bibliographies: Array<Bibliography>;
385
+ persons: Array<Person>;
380
386
  };
381
387
  properties: Array<Property>;
382
388
  };
@@ -493,6 +499,11 @@ type WebElementComponent = {
493
499
  captionSource: "name" | "abbreviation" | "description";
494
500
  captionLayout: "top" | "bottom" | "suppress";
495
501
  altTextSource: "name" | "abbreviation" | "description";
502
+ carousel: {
503
+ secondsPerImage: number;
504
+ isFullWidth: boolean;
505
+ isFullHeight: boolean;
506
+ } | null;
496
507
  } | {
497
508
  component: "image-gallery";
498
509
  galleryId: string;
@@ -733,6 +744,7 @@ type OchreData = {
733
744
  | { concept: OchreConcept }
734
745
  | { period: OchrePeriod }
735
746
  | { bibliography: OchreBibliography }
747
+ | { person: OchrePerson }
736
748
  );
737
749
  };
738
750
 
@@ -776,7 +788,8 @@ type OchreTree = {
776
788
  | { spatialUnit: OchreSpatialUnit | Array<OchreSpatialUnit> }
777
789
  | { concept: OchreConcept | Array<OchreConcept> }
778
790
  | { period: OchrePeriod | Array<OchrePeriod> }
779
- | { bibliography: OchreBibliography | Array<OchreBibliography> };
791
+ | { bibliography: OchreBibliography | Array<OchreBibliography> }
792
+ | { person: OchrePerson | Array<OchrePerson> };
780
793
  properties?: { property: OchreProperty | Array<OchreProperty> };
781
794
  };
782
795
 
@@ -800,7 +813,8 @@ type OchreSet = {
800
813
  | { spatialUnit: OchreSpatialUnit | Array<OchreSpatialUnit> }
801
814
  | { concept: OchreConcept | Array<OchreConcept> }
802
815
  | { period: OchrePeriod | Array<OchrePeriod> }
803
- | { bibliography: OchreBibliography | Array<OchreBibliography> };
816
+ | { bibliography: OchreBibliography | Array<OchreBibliography> }
817
+ | { person: OchrePerson | Array<OchrePerson> };
804
818
  };
805
819
 
806
820
  /**
@@ -980,6 +994,10 @@ type OchreImage = {
980
994
  href?: string;
981
995
  htmlImgSrcPrefix?: string;
982
996
  content?: FakeString;
997
+ widthPreview?: number;
998
+ heightPreview?: number;
999
+ width?: number;
1000
+ height?: number;
983
1001
  };
984
1002
 
985
1003
  /**
@@ -1531,7 +1549,14 @@ declare function parseLicense(license: OchreLicense): License | null;
1531
1549
  /**
1532
1550
  * Parses raw person data into the standardized Person type
1533
1551
  *
1534
- * @param persons - Raw person data from OCHRE format
1552
+ * @param person - Raw person data from OCHRE format
1553
+ * @returns Parsed Person object
1554
+ */
1555
+ declare function parsePerson(person: OchrePerson): Person;
1556
+ /**
1557
+ * Parses raw person data into the standardized Person type
1558
+ *
1559
+ * @param persons - Array of raw person data from OCHRE format
1535
1560
  * @returns Array of parsed Person objects
1536
1561
  */
1537
1562
  declare function parsePersons(persons: Array<OchrePerson>): Array<Person>;
@@ -1777,4 +1802,4 @@ declare function trimEndLineBreaks(string: string): string;
1777
1802
  */
1778
1803
  declare function parseStringContent(content: OchreStringContent, language?: string): string;
1779
1804
 
1780
- export { type Bibliography, type Concept, type Context, type ContextItem, type ContextNode, type Coordinates, type Data, type Document, type Event, type Footnote, type Gallery, type Identification, type Image, type ImageMap, type ImageMapArea, type Interpretation, type License, type Link, type Metadata, type NestedConcept, type NestedResource, type NestedSpatialUnit, type Note, type Observation, type Period, type Person, type Property, type PropertyValue, type PropertyValueType, type Resource, type Set, type SpatialUnit, type Style, type Tree, type WebElement, type WebElementComponent, type WebImage, type Webpage, type WebpageProperties, type Website, type WebsiteProperties, fetchBibliography, fetchByUuid, fetchConcept, fetchGallery, fetchPeriod, fetchResource, fetchSet, fetchSpatialUnit, fetchTree, fetchWebsite, filterProperties, getAllPropertyLabels, getPropertyByLabel, getPropertyValueByLabel, getPropertyValuesByLabel, parseBibliographies, parseBibliography, parseConcept, parseConcepts, parseContext, parseCoordinates, parseDocument, parseEmailAndUrl, parseEvents, parseFakeString, parseIdentification, parseImage, parseImageMap, parseInterpretations, parseLanguages, parseLicense, parseLink, parseLinks, parseMetadata, parseNotes, parseObservation, parseObservations, parsePeriod, parsePeriods, parsePersons, parseProperties, parseResource, parseResources, parseSet, parseSpatialUnit, parseSpatialUnits, parseStringContent, parseStringDocumentItem, parseStringItem, parseTree, parseWebsite, trimEndLineBreaks };
1805
+ export { type Bibliography, type Concept, type Context, type ContextItem, type ContextNode, type Coordinates, type Data, type Document, type Event, type Footnote, type Gallery, type Identification, type Image, type ImageMap, type ImageMapArea, type Interpretation, type License, type Link, type Metadata, type NestedConcept, type NestedResource, type NestedSpatialUnit, type Note, type Observation, type Period, type Person, type Property, type PropertyValue, type PropertyValueType, type Resource, type Set, type SpatialUnit, type Style, type Tree, type WebElement, type WebElementComponent, type WebImage, type Webpage, type WebpageProperties, type Website, type WebsiteProperties, fetchBibliography, fetchByUuid, fetchConcept, fetchGallery, fetchPeriod, fetchResource, fetchSet, fetchSpatialUnit, fetchTree, fetchWebsite, filterProperties, getAllPropertyLabels, getPropertyByLabel, getPropertyValueByLabel, getPropertyValuesByLabel, parseBibliographies, parseBibliography, parseConcept, parseConcepts, parseContext, parseCoordinates, parseDocument, parseEmailAndUrl, parseEvents, parseFakeString, parseIdentification, parseImage, parseImageMap, parseInterpretations, parseLanguages, parseLicense, parseLink, parseLinks, parseMetadata, parseNotes, parseObservation, parseObservations, parsePeriod, parsePeriods, parsePerson, parsePersons, parseProperties, parseResource, parseResources, parseSet, parseSpatialUnit, parseSpatialUnits, parseStringContent, parseStringDocumentItem, parseStringItem, parseTree, parseWebsite, trimEndLineBreaks };
package/dist/index.js CHANGED
@@ -639,17 +639,20 @@ function parseLicense(license) {
639
639
  url: license.license.target
640
640
  };
641
641
  }
642
+ function parsePerson(person) {
643
+ return {
644
+ uuid: person.uuid,
645
+ publicationDateTime: person.publicationDateTime != null ? new Date(person.publicationDateTime) : null,
646
+ type: person.type ?? null,
647
+ date: person.date != null ? new Date(person.date) : null,
648
+ identification: person.identification ? parseIdentification(person.identification) : null,
649
+ content: person.content != null ? parseFakeString(person.content) : null
650
+ };
651
+ }
642
652
  function parsePersons(persons) {
643
653
  const returnPersons = [];
644
654
  for (const person of persons) {
645
- returnPersons.push({
646
- uuid: person.uuid,
647
- publicationDateTime: person.publicationDateTime != null ? new Date(person.publicationDateTime) : null,
648
- type: person.type ?? null,
649
- date: person.date != null ? new Date(person.date) : null,
650
- identification: person.identification ? parseIdentification(person.identification) : null,
651
- content: person.content != null ? parseFakeString(person.content) : null
652
- });
655
+ returnPersons.push(parsePerson(person));
653
656
  }
654
657
  return returnPersons;
655
658
  }
@@ -718,7 +721,11 @@ function parseImage(image) {
718
721
  identification: image.identification ? parseIdentification(image.identification) : null,
719
722
  url: image.href ?? (image.htmlImgSrcPrefix == null && image.content != null ? parseFakeString(image.content) : null),
720
723
  htmlPrefix: image.htmlImgSrcPrefix ?? null,
721
- content: image.htmlImgSrcPrefix != null && image.content != null ? parseFakeString(image.content) : null
724
+ content: image.htmlImgSrcPrefix != null && image.content != null ? parseFakeString(image.content) : null,
725
+ widthPreview: image.widthPreview ?? null,
726
+ heightPreview: image.heightPreview ?? null,
727
+ width: image.width ?? null,
728
+ height: image.height ?? null
722
729
  };
723
730
  }
724
731
  function parseNotes(notes, language = "eng") {
@@ -972,6 +979,7 @@ function parseTree(tree) {
972
979
  let concepts = [];
973
980
  let periods = [];
974
981
  let bibliographies = [];
982
+ let persons = [];
975
983
  if (typeof tree.items !== "string" && "resource" in tree.items) {
976
984
  resources = parseResources(
977
985
  Array.isArray(tree.items.resource) ? tree.items.resource : [tree.items.resource]
@@ -997,6 +1005,11 @@ function parseTree(tree) {
997
1005
  Array.isArray(tree.items.bibliography) ? tree.items.bibliography : [tree.items.bibliography]
998
1006
  );
999
1007
  }
1008
+ if (typeof tree.items !== "string" && "person" in tree.items) {
1009
+ persons = parsePersons(
1010
+ Array.isArray(tree.items.person) ? tree.items.person : [tree.items.person]
1011
+ );
1012
+ }
1000
1013
  const returnTree = {
1001
1014
  uuid: tree.uuid,
1002
1015
  category: "tree",
@@ -1012,7 +1025,8 @@ function parseTree(tree) {
1012
1025
  spatialUnits,
1013
1026
  concepts,
1014
1027
  periods,
1015
- bibliographies
1028
+ bibliographies,
1029
+ persons
1016
1030
  },
1017
1031
  properties: tree.properties ? parseProperties(
1018
1032
  Array.isArray(tree.properties.property) ? tree.properties.property : [tree.properties.property]
@@ -1026,6 +1040,7 @@ function parseSet(set) {
1026
1040
  let concepts = [];
1027
1041
  let periods = [];
1028
1042
  let bibliographies = [];
1043
+ let persons = [];
1029
1044
  if (typeof set.items !== "string" && "resource" in set.items) {
1030
1045
  resources = parseResources(
1031
1046
  Array.isArray(set.items.resource) ? set.items.resource : [set.items.resource],
@@ -1054,6 +1069,11 @@ function parseSet(set) {
1054
1069
  Array.isArray(set.items.bibliography) ? set.items.bibliography : [set.items.bibliography]
1055
1070
  );
1056
1071
  }
1072
+ if (typeof set.items !== "string" && "person" in set.items) {
1073
+ persons = parsePersons(
1074
+ Array.isArray(set.items.person) ? set.items.person : [set.items.person]
1075
+ );
1076
+ }
1057
1077
  return {
1058
1078
  uuid: set.uuid,
1059
1079
  category: "set",
@@ -1073,7 +1093,8 @@ function parseSet(set) {
1073
1093
  spatialUnits,
1074
1094
  concepts,
1075
1095
  periods,
1076
- bibliographies
1096
+ bibliographies,
1097
+ persons
1077
1098
  }
1078
1099
  };
1079
1100
  }
@@ -1405,6 +1426,15 @@ async function parseWebElementProperties(componentProperty, elementResource) {
1405
1426
  `Image link not found for the following component: \u201C${componentName}\u201D`
1406
1427
  );
1407
1428
  }
1429
+ const images = [];
1430
+ for (const imageLink of imageLinks) {
1431
+ images.push({
1432
+ url: `https://ochre.lib.uchicago.edu/ochre?uuid=${imageLink.uuid}&load`,
1433
+ label: imageLink.identification?.label ?? null,
1434
+ width: imageLink.image?.width ?? 0,
1435
+ height: imageLink.image?.height ?? 0
1436
+ });
1437
+ }
1408
1438
  let captionLayout = getPropertyValueByLabel(
1409
1439
  componentProperty.properties,
1410
1440
  "caption-layout"
@@ -1433,20 +1463,40 @@ async function parseWebElementProperties(componentProperty, elementResource) {
1433
1463
  if (altTextSource === null) {
1434
1464
  altTextSource = "name";
1435
1465
  }
1436
- const images = [];
1437
- for (const imageLink of imageLinks) {
1438
- images.push({
1439
- url: `https://ochre.lib.uchicago.edu/ochre?uuid=${imageLink.uuid}&load`,
1440
- label: imageLink.identification?.label ?? null,
1441
- width: imageLink.image?.width ?? 0,
1442
- height: imageLink.image?.height ?? 0
1443
- });
1466
+ const carousel = images.length > 1 ? {
1467
+ secondsPerImage: 5,
1468
+ isFullWidth: false,
1469
+ isFullHeight: false
1470
+ } : null;
1471
+ if (carousel !== null) {
1472
+ const carouselSecondsPerImage = getPropertyValueByLabel(
1473
+ componentProperty.properties,
1474
+ "carousel-seconds-per-image"
1475
+ );
1476
+ if (carouselSecondsPerImage !== null) {
1477
+ carousel.secondsPerImage = Number.parseFloat(carouselSecondsPerImage);
1478
+ }
1479
+ const carouselIsFullWidth = getPropertyValueByLabel(
1480
+ componentProperty.properties,
1481
+ "carousel-full-width"
1482
+ );
1483
+ if (carouselIsFullWidth !== null) {
1484
+ carousel.isFullWidth = carouselIsFullWidth === "Yes";
1485
+ }
1486
+ const carouselIsFullHeight = getPropertyValueByLabel(
1487
+ componentProperty.properties,
1488
+ "carousel-full-height"
1489
+ );
1490
+ if (carouselIsFullHeight !== null) {
1491
+ carousel.isFullHeight = carouselIsFullHeight === "Yes";
1492
+ }
1444
1493
  }
1445
1494
  properties.images = images;
1446
1495
  properties.imageQuality = imageQuality;
1447
1496
  properties.captionLayout = captionLayout;
1448
1497
  properties.captionSource = captionSource;
1449
1498
  properties.altTextSource = altTextSource;
1499
+ properties.carousel = carousel;
1450
1500
  break;
1451
1501
  }
1452
1502
  case "image-gallery": {
@@ -2229,6 +2279,7 @@ export {
2229
2279
  parseObservations,
2230
2280
  parsePeriod,
2231
2281
  parsePeriods,
2282
+ parsePerson,
2232
2283
  parsePersons,
2233
2284
  parseProperties,
2234
2285
  parseResource,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digitalculture/ochre-sdk",
3
- "version": "0.2.5",
3
+ "version": "0.2.6",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "description": "Node.js library for working with OCHRE (Online Cultural and Historical Research Environment) data",
@@ -58,7 +58,7 @@
58
58
  },
59
59
  "scripts": {
60
60
  "dev": "tsup src/index.ts --watch",
61
- "build:ochre-sdk": "tsup",
61
+ "build": "tsup",
62
62
  "lint": "eslint .",
63
63
  "lint:fix": "eslint . --fix",
64
64
  "format": "prettier --check .",
@@ -66,7 +66,7 @@
66
66
  "check-types": "tsc --noEmit",
67
67
  "check-exports": "attw --pack .",
68
68
  "test": "vitest run",
69
- "ci": "pnpm run build:ochre-sdk && pnpm run lint && pnpm run format && pnpm run check-types && pnpm run check-exports && pnpm run test",
69
+ "ci": "pnpm run build && pnpm run lint && pnpm run format && pnpm run check-types && pnpm run check-exports && pnpm run test",
70
70
  "changeset": "changeset add",
71
71
  "release": "changeset version && changeset publish"
72
72
  }