@digitalculture/ochre-sdk 0.1.28 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -587,17 +587,15 @@ var componentSchema = import_zod3.z.enum(
587
587
  "iiif-viewer",
588
588
  "image",
589
589
  "image-gallery",
590
- "interactive-chapter-table",
591
590
  "item-gallery",
592
- "menu",
593
- "menu-item",
594
591
  "n-columns",
595
592
  "n-rows",
596
593
  "network-graph",
597
594
  "table",
598
595
  "text",
599
596
  "text-image",
600
- "timeline"
597
+ "timeline",
598
+ "video"
601
599
  ],
602
600
  { message: "Invalid component" }
603
601
  );
@@ -1468,12 +1466,44 @@ async function parseWebElementProperties(componentProperty, elementResource) {
1468
1466
  `Image link not found for the following component: \u201C${componentName}\u201D`
1469
1467
  );
1470
1468
  }
1469
+ let captionLayout = getPropertyValueByLabel(
1470
+ componentProperty.properties,
1471
+ "caption-layout"
1472
+ );
1473
+ if (captionLayout === null) {
1474
+ captionLayout = "bottom";
1475
+ }
1476
+ let imageQuality = getPropertyValueByLabel(
1477
+ componentProperty.properties,
1478
+ "image-quality"
1479
+ );
1480
+ if (imageQuality === null) {
1481
+ imageQuality = "high";
1482
+ }
1483
+ let captionSource = getPropertyValueByLabel(
1484
+ componentProperty.properties,
1485
+ "caption-source"
1486
+ );
1487
+ if (captionSource === null) {
1488
+ captionSource = "name";
1489
+ }
1490
+ let altTextSource = getPropertyValueByLabel(
1491
+ componentProperty.properties,
1492
+ "alt-text-source"
1493
+ );
1494
+ if (altTextSource === null) {
1495
+ altTextSource = "name";
1496
+ }
1471
1497
  properties.image = {
1472
1498
  url: `https://ochre.lib.uchicago.edu/ochre?uuid=${imageLink.uuid}&load`,
1473
1499
  label: imageLink.identification?.label ?? null,
1474
1500
  width: imageLink.image?.width ?? 0,
1475
1501
  height: imageLink.image?.height ?? 0
1476
1502
  };
1503
+ properties.imageQuality = imageQuality;
1504
+ properties.captionLayout = captionLayout;
1505
+ properties.captionSource = captionSource;
1506
+ properties.altTextSource = altTextSource;
1477
1507
  break;
1478
1508
  }
1479
1509
  case "image-gallery": {
@@ -1486,9 +1516,6 @@ async function parseWebElementProperties(componentProperty, elementResource) {
1486
1516
  properties.galleryId = galleryLink.uuid;
1487
1517
  break;
1488
1518
  }
1489
- case "interactive-chapter-table": {
1490
- break;
1491
- }
1492
1519
  case "item-gallery": {
1493
1520
  const galleryLink = links.find((link) => link.category === "tree");
1494
1521
  if (!galleryLink) {
@@ -1499,12 +1526,6 @@ async function parseWebElementProperties(componentProperty, elementResource) {
1499
1526
  properties.galleryId = galleryLink.uuid;
1500
1527
  break;
1501
1528
  }
1502
- case "menu": {
1503
- break;
1504
- }
1505
- case "menu-item": {
1506
- break;
1507
- }
1508
1529
  case "n-columns": {
1509
1530
  const subElements = elementResource.resource ? await parseWebpageResources(
1510
1531
  Array.isArray(elementResource.resource) ? elementResource.resource : [elementResource.resource],
@@ -1588,17 +1609,40 @@ async function parseWebElementProperties(componentProperty, elementResource) {
1588
1609
  )}`
1589
1610
  );
1590
1611
  }
1612
+ let imageQuality = getPropertyValueByLabel(
1613
+ componentProperty.properties,
1614
+ "image-quality"
1615
+ );
1616
+ if (imageQuality === null) {
1617
+ imageQuality = "high";
1618
+ }
1619
+ let captionSource = getPropertyValueByLabel(
1620
+ componentProperty.properties,
1621
+ "caption-source"
1622
+ );
1623
+ if (captionSource === null) {
1624
+ captionSource = "name";
1625
+ }
1626
+ let altTextSource = getPropertyValueByLabel(
1627
+ componentProperty.properties,
1628
+ "alt-text-source"
1629
+ );
1630
+ if (altTextSource === null) {
1631
+ altTextSource = "name";
1632
+ }
1591
1633
  properties.variant = variant;
1592
- properties.layout = layout;
1593
- properties.captionLayout = captionLayout;
1594
- properties.content = document.content;
1595
1634
  properties.image = {
1596
1635
  url: `https://ochre.lib.uchicago.edu/ochre?uuid=${imageLink2.uuid}&preview`,
1597
1636
  label: imageLink2.identification?.label ?? null,
1598
1637
  width: imageLink2.image?.width ?? 0,
1599
1638
  height: imageLink2.image?.height ?? 0
1600
1639
  };
1601
- properties.imageOpacity = null;
1640
+ properties.imageQuality = imageQuality;
1641
+ properties.layout = layout;
1642
+ properties.captionSource = captionSource;
1643
+ properties.captionLayout = captionLayout;
1644
+ properties.altTextSource = altTextSource;
1645
+ properties.content = document.content;
1602
1646
  break;
1603
1647
  }
1604
1648
  case "timeline": {
@@ -1611,12 +1655,31 @@ async function parseWebElementProperties(componentProperty, elementResource) {
1611
1655
  properties.timelineId = timelineLink.uuid;
1612
1656
  break;
1613
1657
  }
1658
+ case "video": {
1659
+ const videoLink = links.find((link) => link.type === "video");
1660
+ if (!videoLink) {
1661
+ throw new Error(
1662
+ `Video link not found for the following component: \u201C${componentName}\u201D`
1663
+ );
1664
+ }
1665
+ let isChaptersDislayed = getPropertyValueByLabel(
1666
+ componentProperty.properties,
1667
+ "chapters-displayed"
1668
+ );
1669
+ if (isChaptersDislayed == null) {
1670
+ isChaptersDislayed = "Yes";
1671
+ }
1672
+ properties.videoId = videoLink.uuid;
1673
+ properties.isChaptersDislayed = isChaptersDislayed === "Yes";
1674
+ break;
1675
+ }
1614
1676
  default: {
1615
1677
  console.warn(
1616
1678
  `Invalid or non-implemented component name \u201C${componentName}\u201D for the following element: \u201C${parseStringContent(
1617
1679
  elementResource.identification.label
1618
1680
  )}\u201D`
1619
1681
  );
1682
+ break;
1620
1683
  }
1621
1684
  }
1622
1685
  return properties;
@@ -1646,9 +1709,49 @@ async function parseWebElement(elementResource, elementProperties) {
1646
1709
  const cssStyle = property.values[0].content;
1647
1710
  cssStyles.push({ label: property.label, value: cssStyle });
1648
1711
  }
1712
+ const titleProperties = elementResourceProperties.find(
1713
+ (property) => property.label === "title"
1714
+ )?.properties;
1715
+ let variant = "default";
1716
+ let isNameDisplayed = false;
1717
+ let isDescriptionDisplayed = false;
1718
+ let isDateDisplayed = false;
1719
+ let isCreatorsDisplayed = false;
1720
+ if (titleProperties) {
1721
+ const titleVariant = getPropertyValueByLabel(titleProperties, "variant");
1722
+ if (titleVariant) {
1723
+ variant = titleVariant;
1724
+ }
1725
+ const titleShow = titleProperties.filter(
1726
+ (property) => property.label === "display"
1727
+ );
1728
+ if (titleShow.length > 0) {
1729
+ isNameDisplayed = titleShow.some(
1730
+ (property) => property.values[0].content === "name"
1731
+ );
1732
+ isDescriptionDisplayed = titleShow.some(
1733
+ (property) => property.values[0].content === "description"
1734
+ );
1735
+ isDateDisplayed = titleShow.some(
1736
+ (property) => property.values[0].content === "date"
1737
+ );
1738
+ isCreatorsDisplayed = titleShow.some(
1739
+ (property) => property.values[0].content === "creators"
1740
+ );
1741
+ }
1742
+ }
1649
1743
  return {
1650
1744
  uuid: elementResource.uuid,
1651
- title: identification.label,
1745
+ title: {
1746
+ label: identification.label,
1747
+ variant,
1748
+ properties: {
1749
+ isNameDisplayed,
1750
+ isDescriptionDisplayed,
1751
+ isDateDisplayed,
1752
+ isCreatorsDisplayed
1753
+ }
1754
+ },
1652
1755
  cssStyles,
1653
1756
  ...properties
1654
1757
  };
@@ -1981,7 +2084,7 @@ async function fetchGallery(uuid, filter, page, perPage) {
1981
2084
  const gallery = {
1982
2085
  identification: galleryIdentification,
1983
2086
  projectIdentification: galleryProjectIdentification,
1984
- resources: Array.isArray(data.result.gallery.resource) ? parseResources(data.result.gallery.resource) : [parseResource(data.result.gallery.resource)],
2087
+ resources: data.result.gallery.resource ? Array.isArray(data.result.gallery.resource) ? parseResources(data.result.gallery.resource) : [parseResource(data.result.gallery.resource)] : [],
1985
2088
  maxLength: data.result.gallery.maxLength
1986
2089
  };
1987
2090
  return gallery;
package/dist/index.d.cts CHANGED
@@ -442,7 +442,16 @@ type WebpageProperties = {
442
442
  */
443
443
  type WebElement = {
444
444
  uuid: string;
445
- title: string;
445
+ title: {
446
+ label: string;
447
+ variant: "default" | "simple";
448
+ properties: {
449
+ isNameDisplayed: boolean;
450
+ isDescriptionDisplayed: boolean;
451
+ isDateDisplayed: boolean;
452
+ isCreatorsDisplayed: boolean;
453
+ };
454
+ };
446
455
  cssStyles: Array<Style>;
447
456
  } & WebElementComponent;
448
457
  /**
@@ -454,6 +463,7 @@ type WebElementComponent = {
454
463
  } | {
455
464
  component: "annotated-image";
456
465
  imageUuid: string;
466
+ isSearchable: boolean;
457
467
  } | {
458
468
  component: "bibliography";
459
469
  bibliographies: Array<Bibliography>;
@@ -476,19 +486,18 @@ type WebElementComponent = {
476
486
  IIIFId: string;
477
487
  } | {
478
488
  component: "image";
479
- image: WebImage;
489
+ variant: "default" | "carousel";
490
+ images: Array<WebImage>;
491
+ imageQuality: "high" | "low";
492
+ captionSource: "name" | "abbreviation" | "description";
493
+ captionLayout: "top" | "bottom" | "suppress";
494
+ altTextSource: "name" | "abbreviation" | "description";
480
495
  } | {
481
496
  component: "image-gallery";
482
497
  galleryId: string;
483
- } | {
484
- component: "interactive-chapter-table";
485
498
  } | {
486
499
  component: "item-gallery";
487
500
  galleryId: string;
488
- } | {
489
- component: "menu";
490
- } | {
491
- component: "menu-item";
492
501
  } | {
493
502
  component: "n-columns";
494
503
  columns: Array<WebElement>;
@@ -507,14 +516,19 @@ type WebElementComponent = {
507
516
  } | {
508
517
  component: "text-image";
509
518
  variant: "title" | "block" | "banner";
519
+ image: WebImage;
520
+ imageQuality: "high" | "low";
510
521
  layout: "image-top" | "image-bottom" | "image-start" | "image-end" | "image-background";
522
+ captionSource: "name" | "abbreviation" | "description";
511
523
  captionLayout: "top" | "bottom" | "suppress";
512
- image: WebImage;
513
- imageOpacity: number | null;
524
+ altTextSource: "name" | "abbreviation" | "description";
514
525
  content: string;
515
526
  } | {
516
527
  component: "timeline";
517
528
  timelineId: string;
529
+ } | {
530
+ component: "video";
531
+ isChaptersDislayed: boolean;
518
532
  };
519
533
  /**
520
534
  * Represents an image used in web elements
package/dist/index.d.ts CHANGED
@@ -442,7 +442,16 @@ type WebpageProperties = {
442
442
  */
443
443
  type WebElement = {
444
444
  uuid: string;
445
- title: string;
445
+ title: {
446
+ label: string;
447
+ variant: "default" | "simple";
448
+ properties: {
449
+ isNameDisplayed: boolean;
450
+ isDescriptionDisplayed: boolean;
451
+ isDateDisplayed: boolean;
452
+ isCreatorsDisplayed: boolean;
453
+ };
454
+ };
446
455
  cssStyles: Array<Style>;
447
456
  } & WebElementComponent;
448
457
  /**
@@ -454,6 +463,7 @@ type WebElementComponent = {
454
463
  } | {
455
464
  component: "annotated-image";
456
465
  imageUuid: string;
466
+ isSearchable: boolean;
457
467
  } | {
458
468
  component: "bibliography";
459
469
  bibliographies: Array<Bibliography>;
@@ -476,19 +486,18 @@ type WebElementComponent = {
476
486
  IIIFId: string;
477
487
  } | {
478
488
  component: "image";
479
- image: WebImage;
489
+ variant: "default" | "carousel";
490
+ images: Array<WebImage>;
491
+ imageQuality: "high" | "low";
492
+ captionSource: "name" | "abbreviation" | "description";
493
+ captionLayout: "top" | "bottom" | "suppress";
494
+ altTextSource: "name" | "abbreviation" | "description";
480
495
  } | {
481
496
  component: "image-gallery";
482
497
  galleryId: string;
483
- } | {
484
- component: "interactive-chapter-table";
485
498
  } | {
486
499
  component: "item-gallery";
487
500
  galleryId: string;
488
- } | {
489
- component: "menu";
490
- } | {
491
- component: "menu-item";
492
501
  } | {
493
502
  component: "n-columns";
494
503
  columns: Array<WebElement>;
@@ -507,14 +516,19 @@ type WebElementComponent = {
507
516
  } | {
508
517
  component: "text-image";
509
518
  variant: "title" | "block" | "banner";
519
+ image: WebImage;
520
+ imageQuality: "high" | "low";
510
521
  layout: "image-top" | "image-bottom" | "image-start" | "image-end" | "image-background";
522
+ captionSource: "name" | "abbreviation" | "description";
511
523
  captionLayout: "top" | "bottom" | "suppress";
512
- image: WebImage;
513
- imageOpacity: number | null;
524
+ altTextSource: "name" | "abbreviation" | "description";
514
525
  content: string;
515
526
  } | {
516
527
  component: "timeline";
517
528
  timelineId: string;
529
+ } | {
530
+ component: "video";
531
+ isChaptersDislayed: boolean;
518
532
  };
519
533
  /**
520
534
  * Represents an image used in web elements
package/dist/index.js CHANGED
@@ -510,17 +510,15 @@ var componentSchema = z3.enum(
510
510
  "iiif-viewer",
511
511
  "image",
512
512
  "image-gallery",
513
- "interactive-chapter-table",
514
513
  "item-gallery",
515
- "menu",
516
- "menu-item",
517
514
  "n-columns",
518
515
  "n-rows",
519
516
  "network-graph",
520
517
  "table",
521
518
  "text",
522
519
  "text-image",
523
- "timeline"
520
+ "timeline",
521
+ "video"
524
522
  ],
525
523
  { message: "Invalid component" }
526
524
  );
@@ -1391,12 +1389,44 @@ async function parseWebElementProperties(componentProperty, elementResource) {
1391
1389
  `Image link not found for the following component: \u201C${componentName}\u201D`
1392
1390
  );
1393
1391
  }
1392
+ let captionLayout = getPropertyValueByLabel(
1393
+ componentProperty.properties,
1394
+ "caption-layout"
1395
+ );
1396
+ if (captionLayout === null) {
1397
+ captionLayout = "bottom";
1398
+ }
1399
+ let imageQuality = getPropertyValueByLabel(
1400
+ componentProperty.properties,
1401
+ "image-quality"
1402
+ );
1403
+ if (imageQuality === null) {
1404
+ imageQuality = "high";
1405
+ }
1406
+ let captionSource = getPropertyValueByLabel(
1407
+ componentProperty.properties,
1408
+ "caption-source"
1409
+ );
1410
+ if (captionSource === null) {
1411
+ captionSource = "name";
1412
+ }
1413
+ let altTextSource = getPropertyValueByLabel(
1414
+ componentProperty.properties,
1415
+ "alt-text-source"
1416
+ );
1417
+ if (altTextSource === null) {
1418
+ altTextSource = "name";
1419
+ }
1394
1420
  properties.image = {
1395
1421
  url: `https://ochre.lib.uchicago.edu/ochre?uuid=${imageLink.uuid}&load`,
1396
1422
  label: imageLink.identification?.label ?? null,
1397
1423
  width: imageLink.image?.width ?? 0,
1398
1424
  height: imageLink.image?.height ?? 0
1399
1425
  };
1426
+ properties.imageQuality = imageQuality;
1427
+ properties.captionLayout = captionLayout;
1428
+ properties.captionSource = captionSource;
1429
+ properties.altTextSource = altTextSource;
1400
1430
  break;
1401
1431
  }
1402
1432
  case "image-gallery": {
@@ -1409,9 +1439,6 @@ async function parseWebElementProperties(componentProperty, elementResource) {
1409
1439
  properties.galleryId = galleryLink.uuid;
1410
1440
  break;
1411
1441
  }
1412
- case "interactive-chapter-table": {
1413
- break;
1414
- }
1415
1442
  case "item-gallery": {
1416
1443
  const galleryLink = links.find((link) => link.category === "tree");
1417
1444
  if (!galleryLink) {
@@ -1422,12 +1449,6 @@ async function parseWebElementProperties(componentProperty, elementResource) {
1422
1449
  properties.galleryId = galleryLink.uuid;
1423
1450
  break;
1424
1451
  }
1425
- case "menu": {
1426
- break;
1427
- }
1428
- case "menu-item": {
1429
- break;
1430
- }
1431
1452
  case "n-columns": {
1432
1453
  const subElements = elementResource.resource ? await parseWebpageResources(
1433
1454
  Array.isArray(elementResource.resource) ? elementResource.resource : [elementResource.resource],
@@ -1511,17 +1532,40 @@ async function parseWebElementProperties(componentProperty, elementResource) {
1511
1532
  )}`
1512
1533
  );
1513
1534
  }
1535
+ let imageQuality = getPropertyValueByLabel(
1536
+ componentProperty.properties,
1537
+ "image-quality"
1538
+ );
1539
+ if (imageQuality === null) {
1540
+ imageQuality = "high";
1541
+ }
1542
+ let captionSource = getPropertyValueByLabel(
1543
+ componentProperty.properties,
1544
+ "caption-source"
1545
+ );
1546
+ if (captionSource === null) {
1547
+ captionSource = "name";
1548
+ }
1549
+ let altTextSource = getPropertyValueByLabel(
1550
+ componentProperty.properties,
1551
+ "alt-text-source"
1552
+ );
1553
+ if (altTextSource === null) {
1554
+ altTextSource = "name";
1555
+ }
1514
1556
  properties.variant = variant;
1515
- properties.layout = layout;
1516
- properties.captionLayout = captionLayout;
1517
- properties.content = document.content;
1518
1557
  properties.image = {
1519
1558
  url: `https://ochre.lib.uchicago.edu/ochre?uuid=${imageLink2.uuid}&preview`,
1520
1559
  label: imageLink2.identification?.label ?? null,
1521
1560
  width: imageLink2.image?.width ?? 0,
1522
1561
  height: imageLink2.image?.height ?? 0
1523
1562
  };
1524
- properties.imageOpacity = null;
1563
+ properties.imageQuality = imageQuality;
1564
+ properties.layout = layout;
1565
+ properties.captionSource = captionSource;
1566
+ properties.captionLayout = captionLayout;
1567
+ properties.altTextSource = altTextSource;
1568
+ properties.content = document.content;
1525
1569
  break;
1526
1570
  }
1527
1571
  case "timeline": {
@@ -1534,12 +1578,31 @@ async function parseWebElementProperties(componentProperty, elementResource) {
1534
1578
  properties.timelineId = timelineLink.uuid;
1535
1579
  break;
1536
1580
  }
1581
+ case "video": {
1582
+ const videoLink = links.find((link) => link.type === "video");
1583
+ if (!videoLink) {
1584
+ throw new Error(
1585
+ `Video link not found for the following component: \u201C${componentName}\u201D`
1586
+ );
1587
+ }
1588
+ let isChaptersDislayed = getPropertyValueByLabel(
1589
+ componentProperty.properties,
1590
+ "chapters-displayed"
1591
+ );
1592
+ if (isChaptersDislayed == null) {
1593
+ isChaptersDislayed = "Yes";
1594
+ }
1595
+ properties.videoId = videoLink.uuid;
1596
+ properties.isChaptersDislayed = isChaptersDislayed === "Yes";
1597
+ break;
1598
+ }
1537
1599
  default: {
1538
1600
  console.warn(
1539
1601
  `Invalid or non-implemented component name \u201C${componentName}\u201D for the following element: \u201C${parseStringContent(
1540
1602
  elementResource.identification.label
1541
1603
  )}\u201D`
1542
1604
  );
1605
+ break;
1543
1606
  }
1544
1607
  }
1545
1608
  return properties;
@@ -1569,9 +1632,49 @@ async function parseWebElement(elementResource, elementProperties) {
1569
1632
  const cssStyle = property.values[0].content;
1570
1633
  cssStyles.push({ label: property.label, value: cssStyle });
1571
1634
  }
1635
+ const titleProperties = elementResourceProperties.find(
1636
+ (property) => property.label === "title"
1637
+ )?.properties;
1638
+ let variant = "default";
1639
+ let isNameDisplayed = false;
1640
+ let isDescriptionDisplayed = false;
1641
+ let isDateDisplayed = false;
1642
+ let isCreatorsDisplayed = false;
1643
+ if (titleProperties) {
1644
+ const titleVariant = getPropertyValueByLabel(titleProperties, "variant");
1645
+ if (titleVariant) {
1646
+ variant = titleVariant;
1647
+ }
1648
+ const titleShow = titleProperties.filter(
1649
+ (property) => property.label === "display"
1650
+ );
1651
+ if (titleShow.length > 0) {
1652
+ isNameDisplayed = titleShow.some(
1653
+ (property) => property.values[0].content === "name"
1654
+ );
1655
+ isDescriptionDisplayed = titleShow.some(
1656
+ (property) => property.values[0].content === "description"
1657
+ );
1658
+ isDateDisplayed = titleShow.some(
1659
+ (property) => property.values[0].content === "date"
1660
+ );
1661
+ isCreatorsDisplayed = titleShow.some(
1662
+ (property) => property.values[0].content === "creators"
1663
+ );
1664
+ }
1665
+ }
1572
1666
  return {
1573
1667
  uuid: elementResource.uuid,
1574
- title: identification.label,
1668
+ title: {
1669
+ label: identification.label,
1670
+ variant,
1671
+ properties: {
1672
+ isNameDisplayed,
1673
+ isDescriptionDisplayed,
1674
+ isDateDisplayed,
1675
+ isCreatorsDisplayed
1676
+ }
1677
+ },
1575
1678
  cssStyles,
1576
1679
  ...properties
1577
1680
  };
@@ -1904,7 +2007,7 @@ async function fetchGallery(uuid, filter, page, perPage) {
1904
2007
  const gallery = {
1905
2008
  identification: galleryIdentification,
1906
2009
  projectIdentification: galleryProjectIdentification,
1907
- resources: Array.isArray(data.result.gallery.resource) ? parseResources(data.result.gallery.resource) : [parseResource(data.result.gallery.resource)],
2010
+ resources: data.result.gallery.resource ? Array.isArray(data.result.gallery.resource) ? parseResources(data.result.gallery.resource) : [parseResource(data.result.gallery.resource)] : [],
1908
2011
  maxLength: data.result.gallery.maxLength
1909
2012
  };
1910
2013
  return gallery;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digitalculture/ochre-sdk",
3
- "version": "0.1.28",
3
+ "version": "0.2.0",
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",