@digitalculture/ochre-sdk 0.2.0 → 0.2.2
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 +31 -20
- package/dist/index.d.cts +4 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +31 -20
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1327,7 +1327,7 @@ async function parseWebElementProperties(componentProperty, elementResource) {
|
|
|
1327
1327
|
const links = elementResource.links ? parseLinks(
|
|
1328
1328
|
Array.isArray(elementResource.links) ? elementResource.links : [elementResource.links]
|
|
1329
1329
|
) : [];
|
|
1330
|
-
const
|
|
1330
|
+
const imageLinks = links.filter((link) => link.type === "image");
|
|
1331
1331
|
let document = elementResource.document ? parseDocument(elementResource.document.content) : null;
|
|
1332
1332
|
if (document === null) {
|
|
1333
1333
|
const documentLink = links.find((link) => link.type === "internalDocument");
|
|
@@ -1350,19 +1350,16 @@ async function parseWebElementProperties(componentProperty, elementResource) {
|
|
|
1350
1350
|
break;
|
|
1351
1351
|
}
|
|
1352
1352
|
case "annotated-image": {
|
|
1353
|
-
if (
|
|
1353
|
+
if (imageLinks.length === 0) {
|
|
1354
1354
|
throw new Error(
|
|
1355
1355
|
`Image link not found for the following component: \u201C${componentName}\u201D`
|
|
1356
1356
|
);
|
|
1357
1357
|
}
|
|
1358
|
-
|
|
1358
|
+
const isSearchable = getPropertyValueByLabel(
|
|
1359
1359
|
componentProperty.properties,
|
|
1360
1360
|
"is-searchable"
|
|
1361
1361
|
) === "Yes";
|
|
1362
|
-
|
|
1363
|
-
isSearchable = false;
|
|
1364
|
-
}
|
|
1365
|
-
properties.imageUuid = imageLink.uuid;
|
|
1362
|
+
properties.imageUuid = imageLinks[0].uuid;
|
|
1366
1363
|
properties.isSearchable = isSearchable;
|
|
1367
1364
|
break;
|
|
1368
1365
|
}
|
|
@@ -1461,7 +1458,7 @@ async function parseWebElementProperties(componentProperty, elementResource) {
|
|
|
1461
1458
|
break;
|
|
1462
1459
|
}
|
|
1463
1460
|
case "image": {
|
|
1464
|
-
if (
|
|
1461
|
+
if (imageLinks.length === 0) {
|
|
1465
1462
|
throw new Error(
|
|
1466
1463
|
`Image link not found for the following component: \u201C${componentName}\u201D`
|
|
1467
1464
|
);
|
|
@@ -1494,12 +1491,16 @@ async function parseWebElementProperties(componentProperty, elementResource) {
|
|
|
1494
1491
|
if (altTextSource === null) {
|
|
1495
1492
|
altTextSource = "name";
|
|
1496
1493
|
}
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1494
|
+
const images = [];
|
|
1495
|
+
for (const imageLink of imageLinks) {
|
|
1496
|
+
images.push({
|
|
1497
|
+
url: `https://ochre.lib.uchicago.edu/ochre?uuid=${imageLink.uuid}&load`,
|
|
1498
|
+
label: imageLink.identification?.label ?? null,
|
|
1499
|
+
width: imageLink.image?.width ?? 0,
|
|
1500
|
+
height: imageLink.image?.height ?? 0
|
|
1501
|
+
});
|
|
1502
|
+
}
|
|
1503
|
+
properties.images = images;
|
|
1503
1504
|
properties.imageQuality = imageQuality;
|
|
1504
1505
|
properties.captionLayout = captionLayout;
|
|
1505
1506
|
properties.captionSource = captionSource;
|
|
@@ -1513,7 +1514,12 @@ async function parseWebElementProperties(componentProperty, elementResource) {
|
|
|
1513
1514
|
`Image gallery link not found for the following component: \u201C${componentName}\u201D`
|
|
1514
1515
|
);
|
|
1515
1516
|
}
|
|
1517
|
+
const isSearchable = getPropertyValueByLabel(
|
|
1518
|
+
componentProperty.properties,
|
|
1519
|
+
"is-searchable"
|
|
1520
|
+
) === "Yes";
|
|
1516
1521
|
properties.galleryId = galleryLink.uuid;
|
|
1522
|
+
properties.isSearchable = isSearchable;
|
|
1517
1523
|
break;
|
|
1518
1524
|
}
|
|
1519
1525
|
case "item-gallery": {
|
|
@@ -1523,7 +1529,12 @@ async function parseWebElementProperties(componentProperty, elementResource) {
|
|
|
1523
1529
|
`Item gallery link not found for the following component: \u201C${componentName}\u201D`
|
|
1524
1530
|
);
|
|
1525
1531
|
}
|
|
1532
|
+
const isSearchable = getPropertyValueByLabel(
|
|
1533
|
+
componentProperty.properties,
|
|
1534
|
+
"is-searchable"
|
|
1535
|
+
) === "Yes";
|
|
1526
1536
|
properties.galleryId = galleryLink.uuid;
|
|
1537
|
+
properties.isSearchable = isSearchable;
|
|
1527
1538
|
break;
|
|
1528
1539
|
}
|
|
1529
1540
|
case "n-columns": {
|
|
@@ -1599,10 +1610,10 @@ async function parseWebElementProperties(componentProperty, elementResource) {
|
|
|
1599
1610
|
if (captionLayout === null) {
|
|
1600
1611
|
captionLayout = "bottom";
|
|
1601
1612
|
}
|
|
1602
|
-
const
|
|
1613
|
+
const imageLink = links.find(
|
|
1603
1614
|
(link) => link.type === "image" || link.type === "IIIF"
|
|
1604
1615
|
);
|
|
1605
|
-
if (!
|
|
1616
|
+
if (!imageLink) {
|
|
1606
1617
|
throw new Error(
|
|
1607
1618
|
`Image link not found for the following component: \u201C${componentName}\u201D: ${JSON.stringify(
|
|
1608
1619
|
links
|
|
@@ -1632,10 +1643,10 @@ async function parseWebElementProperties(componentProperty, elementResource) {
|
|
|
1632
1643
|
}
|
|
1633
1644
|
properties.variant = variant;
|
|
1634
1645
|
properties.image = {
|
|
1635
|
-
url: `https://ochre.lib.uchicago.edu/ochre?uuid=${
|
|
1636
|
-
label:
|
|
1637
|
-
width:
|
|
1638
|
-
height:
|
|
1646
|
+
url: `https://ochre.lib.uchicago.edu/ochre?uuid=${imageLink.uuid}&preview`,
|
|
1647
|
+
label: imageLink.identification?.label ?? null,
|
|
1648
|
+
width: imageLink.image?.width ?? 0,
|
|
1649
|
+
height: imageLink.image?.height ?? 0
|
|
1639
1650
|
};
|
|
1640
1651
|
properties.imageQuality = imageQuality;
|
|
1641
1652
|
properties.layout = layout;
|
package/dist/index.d.cts
CHANGED
|
@@ -478,9 +478,10 @@ type WebElementComponent = {
|
|
|
478
478
|
label: string;
|
|
479
479
|
} | {
|
|
480
480
|
component: "collection";
|
|
481
|
+
collectionId: string;
|
|
481
482
|
variant: "full" | "highlights";
|
|
482
483
|
layout: "image-top" | "image-bottom" | "image-start" | "image-end";
|
|
483
|
-
|
|
484
|
+
isSearchable: boolean;
|
|
484
485
|
} | {
|
|
485
486
|
component: "iiif-viewer";
|
|
486
487
|
IIIFId: string;
|
|
@@ -495,9 +496,11 @@ type WebElementComponent = {
|
|
|
495
496
|
} | {
|
|
496
497
|
component: "image-gallery";
|
|
497
498
|
galleryId: string;
|
|
499
|
+
isSearchable: boolean;
|
|
498
500
|
} | {
|
|
499
501
|
component: "item-gallery";
|
|
500
502
|
galleryId: string;
|
|
503
|
+
isSearchable: boolean;
|
|
501
504
|
} | {
|
|
502
505
|
component: "n-columns";
|
|
503
506
|
columns: Array<WebElement>;
|
package/dist/index.d.ts
CHANGED
|
@@ -478,9 +478,10 @@ type WebElementComponent = {
|
|
|
478
478
|
label: string;
|
|
479
479
|
} | {
|
|
480
480
|
component: "collection";
|
|
481
|
+
collectionId: string;
|
|
481
482
|
variant: "full" | "highlights";
|
|
482
483
|
layout: "image-top" | "image-bottom" | "image-start" | "image-end";
|
|
483
|
-
|
|
484
|
+
isSearchable: boolean;
|
|
484
485
|
} | {
|
|
485
486
|
component: "iiif-viewer";
|
|
486
487
|
IIIFId: string;
|
|
@@ -495,9 +496,11 @@ type WebElementComponent = {
|
|
|
495
496
|
} | {
|
|
496
497
|
component: "image-gallery";
|
|
497
498
|
galleryId: string;
|
|
499
|
+
isSearchable: boolean;
|
|
498
500
|
} | {
|
|
499
501
|
component: "item-gallery";
|
|
500
502
|
galleryId: string;
|
|
503
|
+
isSearchable: boolean;
|
|
501
504
|
} | {
|
|
502
505
|
component: "n-columns";
|
|
503
506
|
columns: Array<WebElement>;
|
package/dist/index.js
CHANGED
|
@@ -1250,7 +1250,7 @@ async function parseWebElementProperties(componentProperty, elementResource) {
|
|
|
1250
1250
|
const links = elementResource.links ? parseLinks(
|
|
1251
1251
|
Array.isArray(elementResource.links) ? elementResource.links : [elementResource.links]
|
|
1252
1252
|
) : [];
|
|
1253
|
-
const
|
|
1253
|
+
const imageLinks = links.filter((link) => link.type === "image");
|
|
1254
1254
|
let document = elementResource.document ? parseDocument(elementResource.document.content) : null;
|
|
1255
1255
|
if (document === null) {
|
|
1256
1256
|
const documentLink = links.find((link) => link.type === "internalDocument");
|
|
@@ -1273,19 +1273,16 @@ async function parseWebElementProperties(componentProperty, elementResource) {
|
|
|
1273
1273
|
break;
|
|
1274
1274
|
}
|
|
1275
1275
|
case "annotated-image": {
|
|
1276
|
-
if (
|
|
1276
|
+
if (imageLinks.length === 0) {
|
|
1277
1277
|
throw new Error(
|
|
1278
1278
|
`Image link not found for the following component: \u201C${componentName}\u201D`
|
|
1279
1279
|
);
|
|
1280
1280
|
}
|
|
1281
|
-
|
|
1281
|
+
const isSearchable = getPropertyValueByLabel(
|
|
1282
1282
|
componentProperty.properties,
|
|
1283
1283
|
"is-searchable"
|
|
1284
1284
|
) === "Yes";
|
|
1285
|
-
|
|
1286
|
-
isSearchable = false;
|
|
1287
|
-
}
|
|
1288
|
-
properties.imageUuid = imageLink.uuid;
|
|
1285
|
+
properties.imageUuid = imageLinks[0].uuid;
|
|
1289
1286
|
properties.isSearchable = isSearchable;
|
|
1290
1287
|
break;
|
|
1291
1288
|
}
|
|
@@ -1384,7 +1381,7 @@ async function parseWebElementProperties(componentProperty, elementResource) {
|
|
|
1384
1381
|
break;
|
|
1385
1382
|
}
|
|
1386
1383
|
case "image": {
|
|
1387
|
-
if (
|
|
1384
|
+
if (imageLinks.length === 0) {
|
|
1388
1385
|
throw new Error(
|
|
1389
1386
|
`Image link not found for the following component: \u201C${componentName}\u201D`
|
|
1390
1387
|
);
|
|
@@ -1417,12 +1414,16 @@ async function parseWebElementProperties(componentProperty, elementResource) {
|
|
|
1417
1414
|
if (altTextSource === null) {
|
|
1418
1415
|
altTextSource = "name";
|
|
1419
1416
|
}
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1417
|
+
const images = [];
|
|
1418
|
+
for (const imageLink of imageLinks) {
|
|
1419
|
+
images.push({
|
|
1420
|
+
url: `https://ochre.lib.uchicago.edu/ochre?uuid=${imageLink.uuid}&load`,
|
|
1421
|
+
label: imageLink.identification?.label ?? null,
|
|
1422
|
+
width: imageLink.image?.width ?? 0,
|
|
1423
|
+
height: imageLink.image?.height ?? 0
|
|
1424
|
+
});
|
|
1425
|
+
}
|
|
1426
|
+
properties.images = images;
|
|
1426
1427
|
properties.imageQuality = imageQuality;
|
|
1427
1428
|
properties.captionLayout = captionLayout;
|
|
1428
1429
|
properties.captionSource = captionSource;
|
|
@@ -1436,7 +1437,12 @@ async function parseWebElementProperties(componentProperty, elementResource) {
|
|
|
1436
1437
|
`Image gallery link not found for the following component: \u201C${componentName}\u201D`
|
|
1437
1438
|
);
|
|
1438
1439
|
}
|
|
1440
|
+
const isSearchable = getPropertyValueByLabel(
|
|
1441
|
+
componentProperty.properties,
|
|
1442
|
+
"is-searchable"
|
|
1443
|
+
) === "Yes";
|
|
1439
1444
|
properties.galleryId = galleryLink.uuid;
|
|
1445
|
+
properties.isSearchable = isSearchable;
|
|
1440
1446
|
break;
|
|
1441
1447
|
}
|
|
1442
1448
|
case "item-gallery": {
|
|
@@ -1446,7 +1452,12 @@ async function parseWebElementProperties(componentProperty, elementResource) {
|
|
|
1446
1452
|
`Item gallery link not found for the following component: \u201C${componentName}\u201D`
|
|
1447
1453
|
);
|
|
1448
1454
|
}
|
|
1455
|
+
const isSearchable = getPropertyValueByLabel(
|
|
1456
|
+
componentProperty.properties,
|
|
1457
|
+
"is-searchable"
|
|
1458
|
+
) === "Yes";
|
|
1449
1459
|
properties.galleryId = galleryLink.uuid;
|
|
1460
|
+
properties.isSearchable = isSearchable;
|
|
1450
1461
|
break;
|
|
1451
1462
|
}
|
|
1452
1463
|
case "n-columns": {
|
|
@@ -1522,10 +1533,10 @@ async function parseWebElementProperties(componentProperty, elementResource) {
|
|
|
1522
1533
|
if (captionLayout === null) {
|
|
1523
1534
|
captionLayout = "bottom";
|
|
1524
1535
|
}
|
|
1525
|
-
const
|
|
1536
|
+
const imageLink = links.find(
|
|
1526
1537
|
(link) => link.type === "image" || link.type === "IIIF"
|
|
1527
1538
|
);
|
|
1528
|
-
if (!
|
|
1539
|
+
if (!imageLink) {
|
|
1529
1540
|
throw new Error(
|
|
1530
1541
|
`Image link not found for the following component: \u201C${componentName}\u201D: ${JSON.stringify(
|
|
1531
1542
|
links
|
|
@@ -1555,10 +1566,10 @@ async function parseWebElementProperties(componentProperty, elementResource) {
|
|
|
1555
1566
|
}
|
|
1556
1567
|
properties.variant = variant;
|
|
1557
1568
|
properties.image = {
|
|
1558
|
-
url: `https://ochre.lib.uchicago.edu/ochre?uuid=${
|
|
1559
|
-
label:
|
|
1560
|
-
width:
|
|
1561
|
-
height:
|
|
1569
|
+
url: `https://ochre.lib.uchicago.edu/ochre?uuid=${imageLink.uuid}&preview`,
|
|
1570
|
+
label: imageLink.identification?.label ?? null,
|
|
1571
|
+
width: imageLink.image?.width ?? 0,
|
|
1572
|
+
height: imageLink.image?.height ?? 0
|
|
1562
1573
|
};
|
|
1563
1574
|
properties.imageQuality = imageQuality;
|
|
1564
1575
|
properties.layout = layout;
|
package/package.json
CHANGED