@digitalculture/ochre-sdk 0.5.0 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -567,6 +567,7 @@ var componentSchema = import_zod3.z.enum(
567
567
  "button",
568
568
  "collection",
569
569
  "empty-space",
570
+ "iframe",
570
571
  "iiif-viewer",
571
572
  "image",
572
573
  "image-gallery",
@@ -725,6 +726,7 @@ function parseLink(linkRaw) {
725
726
  const returnLink = {
726
727
  category: "resource" in linkRaw ? "resource" : "concept" in linkRaw ? "concept" : "set" in linkRaw ? "set" : "person" in linkRaw ? "person" : "tree" in linkRaw ? "tree" : "bibliography" in linkRaw ? "bibliography" : "epigraphicUnit" in linkRaw ? "epigraphicUnit" : null,
727
728
  content: "content" in link ? link.content != null ? parseFakeString(link.content) : null : null,
729
+ href: "href" in link && link.href != null ? link.href : null,
728
730
  uuid: link.uuid,
729
731
  type: link.type ?? null,
730
732
  identification: link.identification ? parseIdentification(link.identification) : null,
@@ -1408,9 +1410,7 @@ async function parseWebElementProperties(componentProperty, elementResource) {
1408
1410
  componentProperty.properties,
1409
1411
  "layout"
1410
1412
  );
1411
- if (layout === null) {
1412
- layout = "long";
1413
- }
1413
+ layout ??= "long";
1414
1414
  properties.bibliographies = bibliographyLink.bibliographies;
1415
1415
  properties.layout = layout;
1416
1416
  break;
@@ -1430,9 +1430,7 @@ async function parseWebElementProperties(componentProperty, elementResource) {
1430
1430
  componentProperty.properties,
1431
1431
  "variant"
1432
1432
  );
1433
- if (variant === null) {
1434
- variant = "default";
1435
- }
1433
+ variant ??= "default";
1436
1434
  let isExternal = false;
1437
1435
  let href = getPropertyValueByLabel(
1438
1436
  componentProperty.properties,
@@ -1463,16 +1461,12 @@ async function parseWebElementProperties(componentProperty, elementResource) {
1463
1461
  componentProperty.properties,
1464
1462
  "variant"
1465
1463
  );
1466
- if (variant === null) {
1467
- variant = "full";
1468
- }
1464
+ variant ??= "full";
1469
1465
  let layout = getPropertyValueByLabel(
1470
1466
  componentProperty.properties,
1471
1467
  "layout"
1472
1468
  );
1473
- if (layout === null) {
1474
- layout = "image-start";
1475
- }
1469
+ layout ??= "image-start";
1476
1470
  const collectionLink = links.find((link) => link.category === "set");
1477
1471
  if (!collectionLink) {
1478
1472
  throw new Error(
@@ -1497,6 +1491,16 @@ async function parseWebElementProperties(componentProperty, elementResource) {
1497
1491
  properties.width = width;
1498
1492
  break;
1499
1493
  }
1494
+ case "iframe": {
1495
+ const url = links.find((link) => link.type === "webpage")?.href;
1496
+ if (!url) {
1497
+ throw new Error(
1498
+ `URL not found for the following component: \u201C${componentName}\u201D`
1499
+ );
1500
+ }
1501
+ properties.url = url;
1502
+ break;
1503
+ }
1500
1504
  case "iiif-viewer": {
1501
1505
  const manifestLink = links.find((link) => link.type === "IIIF");
1502
1506
  if (!manifestLink) {
@@ -1526,16 +1530,12 @@ async function parseWebElementProperties(componentProperty, elementResource) {
1526
1530
  componentProperty.properties,
1527
1531
  "variant"
1528
1532
  );
1529
- if (variant === null) {
1530
- variant = "default";
1531
- }
1533
+ variant ??= "default";
1532
1534
  let captionLayout = getPropertyValueByLabel(
1533
1535
  componentProperty.properties,
1534
1536
  "layout-caption"
1535
1537
  );
1536
- if (captionLayout === null) {
1537
- captionLayout = "bottom";
1538
- }
1538
+ captionLayout ??= "bottom";
1539
1539
  let width = null;
1540
1540
  const widthProperty = getPropertyValueByLabel(
1541
1541
  componentProperty.properties,
@@ -1572,23 +1572,17 @@ async function parseWebElementProperties(componentProperty, elementResource) {
1572
1572
  componentProperty.properties,
1573
1573
  "image-quality"
1574
1574
  );
1575
- if (imageQuality === null) {
1576
- imageQuality = "high";
1577
- }
1575
+ imageQuality ??= "high";
1578
1576
  let captionSource = getPropertyValueByLabel(
1579
1577
  componentProperty.properties,
1580
1578
  "caption-source"
1581
1579
  );
1582
- if (captionSource === null) {
1583
- captionSource = "name";
1584
- }
1580
+ captionSource ??= "name";
1585
1581
  let altTextSource = getPropertyValueByLabel(
1586
1582
  componentProperty.properties,
1587
1583
  "alt-text-source"
1588
1584
  );
1589
- if (altTextSource === null) {
1590
- altTextSource = "name";
1591
- }
1585
+ altTextSource ??= "name";
1592
1586
  let isTransparentBackground = false;
1593
1587
  const isTransparentBackgroundProperty = getPropertyValueByLabel(
1594
1588
  componentProperty.properties,
@@ -1709,9 +1703,7 @@ async function parseWebElementProperties(componentProperty, elementResource) {
1709
1703
  componentProperty.properties,
1710
1704
  "variant"
1711
1705
  );
1712
- if (variant === null) {
1713
- variant = "block";
1714
- }
1706
+ variant ??= "block";
1715
1707
  const heading = getPropertyValueByLabel(
1716
1708
  componentProperty.properties,
1717
1709
  "heading"
@@ -1731,23 +1723,17 @@ async function parseWebElementProperties(componentProperty, elementResource) {
1731
1723
  componentProperty.properties,
1732
1724
  "variant"
1733
1725
  );
1734
- if (variant === null) {
1735
- variant = "block";
1736
- }
1726
+ variant ??= "block";
1737
1727
  let layout = getPropertyValueByLabel(
1738
1728
  componentProperty.properties,
1739
1729
  "layout"
1740
1730
  );
1741
- if (layout === null) {
1742
- layout = "image-start";
1743
- }
1731
+ layout ??= "image-start";
1744
1732
  let captionLayout = getPropertyValueByLabel(
1745
1733
  componentProperty.properties,
1746
1734
  "layout-caption"
1747
1735
  );
1748
- if (captionLayout === null) {
1749
- captionLayout = "bottom";
1750
- }
1736
+ captionLayout ??= "bottom";
1751
1737
  const imageLink = links.find(
1752
1738
  (link) => link.type === "image" || link.type === "IIIF"
1753
1739
  );
@@ -1762,23 +1748,17 @@ async function parseWebElementProperties(componentProperty, elementResource) {
1762
1748
  componentProperty.properties,
1763
1749
  "image-quality"
1764
1750
  );
1765
- if (imageQuality === null) {
1766
- imageQuality = "high";
1767
- }
1751
+ imageQuality ??= "high";
1768
1752
  let captionSource = getPropertyValueByLabel(
1769
1753
  componentProperty.properties,
1770
1754
  "caption-source"
1771
1755
  );
1772
- if (captionSource === null) {
1773
- captionSource = "name";
1774
- }
1756
+ captionSource ??= "name";
1775
1757
  let altTextSource = getPropertyValueByLabel(
1776
1758
  componentProperty.properties,
1777
1759
  "alt-text-source"
1778
1760
  );
1779
- if (altTextSource === null) {
1780
- altTextSource = "name";
1781
- }
1761
+ altTextSource ??= "name";
1782
1762
  properties.variant = variant;
1783
1763
  properties.image = {
1784
1764
  url: `https://ochre.lib.uchicago.edu/ochre?uuid=${imageLink.uuid}&preview`,
@@ -1815,9 +1795,7 @@ async function parseWebElementProperties(componentProperty, elementResource) {
1815
1795
  componentProperty.properties,
1816
1796
  "chapters-displayed"
1817
1797
  );
1818
- if (isChaptersDislayed == null) {
1819
- isChaptersDislayed = "Yes";
1820
- }
1798
+ isChaptersDislayed ??= "Yes";
1821
1799
  properties.videoId = videoLink.uuid;
1822
1800
  properties.isChaptersDislayed = isChaptersDislayed === "Yes";
1823
1801
  break;
@@ -2199,9 +2177,7 @@ function parseWebsiteProperties(properties) {
2199
2177
  let privacy = websiteProperties.find(
2200
2178
  (property) => property.label === "privacy"
2201
2179
  )?.values[0]?.content;
2202
- if (privacy == null) {
2203
- privacy = "public";
2204
- }
2180
+ privacy ??= "public";
2205
2181
  const result = websiteSchema.safeParse({
2206
2182
  type,
2207
2183
  status,
package/dist/index.d.cts CHANGED
@@ -115,6 +115,7 @@ type Link = {
115
115
  category: "resource" | "concept" | "set" | "tree" | "person" | "bibliography" | "epigraphicUnit" | null;
116
116
  identification: Identification | null;
117
117
  content: string | null;
118
+ href: string | null;
118
119
  image: {
119
120
  isInline: boolean;
120
121
  heightPreview: number;
@@ -507,6 +508,9 @@ type WebElementComponent = {
507
508
  component: "empty-space";
508
509
  height: string | null;
509
510
  width: string | null;
511
+ } | {
512
+ component: "iframe";
513
+ url: string;
510
514
  } | {
511
515
  component: "iiif-viewer";
512
516
  IIIFId: string;
package/dist/index.d.ts CHANGED
@@ -115,6 +115,7 @@ type Link = {
115
115
  category: "resource" | "concept" | "set" | "tree" | "person" | "bibliography" | "epigraphicUnit" | null;
116
116
  identification: Identification | null;
117
117
  content: string | null;
118
+ href: string | null;
118
119
  image: {
119
120
  isInline: boolean;
120
121
  heightPreview: number;
@@ -507,6 +508,9 @@ type WebElementComponent = {
507
508
  component: "empty-space";
508
509
  height: string | null;
509
510
  width: string | null;
511
+ } | {
512
+ component: "iframe";
513
+ url: string;
510
514
  } | {
511
515
  component: "iiif-viewer";
512
516
  IIIFId: string;
package/dist/index.js CHANGED
@@ -490,6 +490,7 @@ var componentSchema = z3.enum(
490
490
  "button",
491
491
  "collection",
492
492
  "empty-space",
493
+ "iframe",
493
494
  "iiif-viewer",
494
495
  "image",
495
496
  "image-gallery",
@@ -648,6 +649,7 @@ function parseLink(linkRaw) {
648
649
  const returnLink = {
649
650
  category: "resource" in linkRaw ? "resource" : "concept" in linkRaw ? "concept" : "set" in linkRaw ? "set" : "person" in linkRaw ? "person" : "tree" in linkRaw ? "tree" : "bibliography" in linkRaw ? "bibliography" : "epigraphicUnit" in linkRaw ? "epigraphicUnit" : null,
650
651
  content: "content" in link ? link.content != null ? parseFakeString(link.content) : null : null,
652
+ href: "href" in link && link.href != null ? link.href : null,
651
653
  uuid: link.uuid,
652
654
  type: link.type ?? null,
653
655
  identification: link.identification ? parseIdentification(link.identification) : null,
@@ -1331,9 +1333,7 @@ async function parseWebElementProperties(componentProperty, elementResource) {
1331
1333
  componentProperty.properties,
1332
1334
  "layout"
1333
1335
  );
1334
- if (layout === null) {
1335
- layout = "long";
1336
- }
1336
+ layout ??= "long";
1337
1337
  properties.bibliographies = bibliographyLink.bibliographies;
1338
1338
  properties.layout = layout;
1339
1339
  break;
@@ -1353,9 +1353,7 @@ async function parseWebElementProperties(componentProperty, elementResource) {
1353
1353
  componentProperty.properties,
1354
1354
  "variant"
1355
1355
  );
1356
- if (variant === null) {
1357
- variant = "default";
1358
- }
1356
+ variant ??= "default";
1359
1357
  let isExternal = false;
1360
1358
  let href = getPropertyValueByLabel(
1361
1359
  componentProperty.properties,
@@ -1386,16 +1384,12 @@ async function parseWebElementProperties(componentProperty, elementResource) {
1386
1384
  componentProperty.properties,
1387
1385
  "variant"
1388
1386
  );
1389
- if (variant === null) {
1390
- variant = "full";
1391
- }
1387
+ variant ??= "full";
1392
1388
  let layout = getPropertyValueByLabel(
1393
1389
  componentProperty.properties,
1394
1390
  "layout"
1395
1391
  );
1396
- if (layout === null) {
1397
- layout = "image-start";
1398
- }
1392
+ layout ??= "image-start";
1399
1393
  const collectionLink = links.find((link) => link.category === "set");
1400
1394
  if (!collectionLink) {
1401
1395
  throw new Error(
@@ -1420,6 +1414,16 @@ async function parseWebElementProperties(componentProperty, elementResource) {
1420
1414
  properties.width = width;
1421
1415
  break;
1422
1416
  }
1417
+ case "iframe": {
1418
+ const url = links.find((link) => link.type === "webpage")?.href;
1419
+ if (!url) {
1420
+ throw new Error(
1421
+ `URL not found for the following component: \u201C${componentName}\u201D`
1422
+ );
1423
+ }
1424
+ properties.url = url;
1425
+ break;
1426
+ }
1423
1427
  case "iiif-viewer": {
1424
1428
  const manifestLink = links.find((link) => link.type === "IIIF");
1425
1429
  if (!manifestLink) {
@@ -1449,16 +1453,12 @@ async function parseWebElementProperties(componentProperty, elementResource) {
1449
1453
  componentProperty.properties,
1450
1454
  "variant"
1451
1455
  );
1452
- if (variant === null) {
1453
- variant = "default";
1454
- }
1456
+ variant ??= "default";
1455
1457
  let captionLayout = getPropertyValueByLabel(
1456
1458
  componentProperty.properties,
1457
1459
  "layout-caption"
1458
1460
  );
1459
- if (captionLayout === null) {
1460
- captionLayout = "bottom";
1461
- }
1461
+ captionLayout ??= "bottom";
1462
1462
  let width = null;
1463
1463
  const widthProperty = getPropertyValueByLabel(
1464
1464
  componentProperty.properties,
@@ -1495,23 +1495,17 @@ async function parseWebElementProperties(componentProperty, elementResource) {
1495
1495
  componentProperty.properties,
1496
1496
  "image-quality"
1497
1497
  );
1498
- if (imageQuality === null) {
1499
- imageQuality = "high";
1500
- }
1498
+ imageQuality ??= "high";
1501
1499
  let captionSource = getPropertyValueByLabel(
1502
1500
  componentProperty.properties,
1503
1501
  "caption-source"
1504
1502
  );
1505
- if (captionSource === null) {
1506
- captionSource = "name";
1507
- }
1503
+ captionSource ??= "name";
1508
1504
  let altTextSource = getPropertyValueByLabel(
1509
1505
  componentProperty.properties,
1510
1506
  "alt-text-source"
1511
1507
  );
1512
- if (altTextSource === null) {
1513
- altTextSource = "name";
1514
- }
1508
+ altTextSource ??= "name";
1515
1509
  let isTransparentBackground = false;
1516
1510
  const isTransparentBackgroundProperty = getPropertyValueByLabel(
1517
1511
  componentProperty.properties,
@@ -1632,9 +1626,7 @@ async function parseWebElementProperties(componentProperty, elementResource) {
1632
1626
  componentProperty.properties,
1633
1627
  "variant"
1634
1628
  );
1635
- if (variant === null) {
1636
- variant = "block";
1637
- }
1629
+ variant ??= "block";
1638
1630
  const heading = getPropertyValueByLabel(
1639
1631
  componentProperty.properties,
1640
1632
  "heading"
@@ -1654,23 +1646,17 @@ async function parseWebElementProperties(componentProperty, elementResource) {
1654
1646
  componentProperty.properties,
1655
1647
  "variant"
1656
1648
  );
1657
- if (variant === null) {
1658
- variant = "block";
1659
- }
1649
+ variant ??= "block";
1660
1650
  let layout = getPropertyValueByLabel(
1661
1651
  componentProperty.properties,
1662
1652
  "layout"
1663
1653
  );
1664
- if (layout === null) {
1665
- layout = "image-start";
1666
- }
1654
+ layout ??= "image-start";
1667
1655
  let captionLayout = getPropertyValueByLabel(
1668
1656
  componentProperty.properties,
1669
1657
  "layout-caption"
1670
1658
  );
1671
- if (captionLayout === null) {
1672
- captionLayout = "bottom";
1673
- }
1659
+ captionLayout ??= "bottom";
1674
1660
  const imageLink = links.find(
1675
1661
  (link) => link.type === "image" || link.type === "IIIF"
1676
1662
  );
@@ -1685,23 +1671,17 @@ async function parseWebElementProperties(componentProperty, elementResource) {
1685
1671
  componentProperty.properties,
1686
1672
  "image-quality"
1687
1673
  );
1688
- if (imageQuality === null) {
1689
- imageQuality = "high";
1690
- }
1674
+ imageQuality ??= "high";
1691
1675
  let captionSource = getPropertyValueByLabel(
1692
1676
  componentProperty.properties,
1693
1677
  "caption-source"
1694
1678
  );
1695
- if (captionSource === null) {
1696
- captionSource = "name";
1697
- }
1679
+ captionSource ??= "name";
1698
1680
  let altTextSource = getPropertyValueByLabel(
1699
1681
  componentProperty.properties,
1700
1682
  "alt-text-source"
1701
1683
  );
1702
- if (altTextSource === null) {
1703
- altTextSource = "name";
1704
- }
1684
+ altTextSource ??= "name";
1705
1685
  properties.variant = variant;
1706
1686
  properties.image = {
1707
1687
  url: `https://ochre.lib.uchicago.edu/ochre?uuid=${imageLink.uuid}&preview`,
@@ -1738,9 +1718,7 @@ async function parseWebElementProperties(componentProperty, elementResource) {
1738
1718
  componentProperty.properties,
1739
1719
  "chapters-displayed"
1740
1720
  );
1741
- if (isChaptersDislayed == null) {
1742
- isChaptersDislayed = "Yes";
1743
- }
1721
+ isChaptersDislayed ??= "Yes";
1744
1722
  properties.videoId = videoLink.uuid;
1745
1723
  properties.isChaptersDislayed = isChaptersDislayed === "Yes";
1746
1724
  break;
@@ -2122,9 +2100,7 @@ function parseWebsiteProperties(properties) {
2122
2100
  let privacy = websiteProperties.find(
2123
2101
  (property) => property.label === "privacy"
2124
2102
  )?.values[0]?.content;
2125
- if (privacy == null) {
2126
- privacy = "public";
2127
- }
2103
+ privacy ??= "public";
2128
2104
  const result = websiteSchema.safeParse({
2129
2105
  type,
2130
2106
  status,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digitalculture/ochre-sdk",
3
- "version": "0.5.0",
3
+ "version": "0.5.1",
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",
@@ -41,16 +41,15 @@
41
41
  ],
42
42
  "dependencies": {
43
43
  "iso-639-3": "^3.0.1",
44
- "uuid": "^11.1.0",
45
44
  "zod": "^3.24.2"
46
45
  },
47
46
  "devDependencies": {
48
- "@antfu/eslint-config": "^4.10.1",
47
+ "@antfu/eslint-config": "^4.11.0",
49
48
  "@arethetypeswrong/cli": "^0.17.4",
50
49
  "@changesets/cli": "^2.28.1",
51
50
  "@total-typescript/ts-reset": "^0.6.1",
52
- "@types/node": "^22.13.10",
53
- "eslint": "^9.22.0",
51
+ "@types/node": "^22.13.14",
52
+ "eslint": "^9.23.0",
54
53
  "eslint-plugin-unused-imports": "^4.1.4",
55
54
  "prettier": "^3.5.3",
56
55
  "tsup": "^8.4.0",