@digitalculture/ochre-sdk 0.12.2 → 0.12.4
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.d.mts +23 -25
- package/dist/index.mjs +14 -8
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -545,29 +545,26 @@ type Website = {
|
|
|
545
545
|
mobile: Array<Style>;
|
|
546
546
|
};
|
|
547
547
|
} | null;
|
|
548
|
-
properties:
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
supportsThemeToggle: boolean;
|
|
569
|
-
defaultTheme: "light" | "dark" | null;
|
|
570
|
-
logoUrl: string | null;
|
|
548
|
+
properties: {
|
|
549
|
+
type: "traditional" | "digital-collection" | "plum" | "cedar" | "elm" | "maple" | "oak" | "palm";
|
|
550
|
+
privacy: "public" | "password" | "private";
|
|
551
|
+
status: "development" | "preview" | "production";
|
|
552
|
+
contact: {
|
|
553
|
+
name: string;
|
|
554
|
+
email: string | null;
|
|
555
|
+
} | null;
|
|
556
|
+
isHeaderDisplayed: boolean;
|
|
557
|
+
headerVariant: "default" | "floating" | "inline";
|
|
558
|
+
headerAlignment: "start" | "center" | "end";
|
|
559
|
+
isHeaderProjectDisplayed: boolean;
|
|
560
|
+
isFooterDisplayed: boolean;
|
|
561
|
+
isSidebarDisplayed: boolean;
|
|
562
|
+
headerSearchButtonPageSlug: string | null;
|
|
563
|
+
iiifViewer: "universal-viewer" | "clover";
|
|
564
|
+
supportsThemeToggle: boolean;
|
|
565
|
+
defaultTheme: "light" | "dark" | null;
|
|
566
|
+
logoUrl: string | null;
|
|
567
|
+
};
|
|
571
568
|
};
|
|
572
569
|
type Webpage = {
|
|
573
570
|
title: string;
|
|
@@ -657,10 +654,11 @@ type WebElementComponent = {
|
|
|
657
654
|
image: WebImage | null;
|
|
658
655
|
} | {
|
|
659
656
|
component: "collection";
|
|
660
|
-
|
|
657
|
+
collectionIds: Array<string>;
|
|
661
658
|
variant: "full" | "highlights";
|
|
662
659
|
itemVariant: "detailed" | "card" | "tile";
|
|
663
660
|
paginationVariant: "default" | "numeric";
|
|
661
|
+
isSearchDisplayed: boolean;
|
|
664
662
|
isSortDisplayed: boolean;
|
|
665
663
|
isFilterDisplayed: boolean;
|
|
666
664
|
filterSort: "default" | "alphabetical";
|
|
@@ -1191,4 +1189,4 @@ declare function filterProperties(property: Property, filter: {
|
|
|
1191
1189
|
value: string | number | boolean | Date;
|
|
1192
1190
|
}, options?: PropertyOptions): boolean;
|
|
1193
1191
|
//#endregion
|
|
1194
|
-
export { Bibliography, Concept, Context, ContextItem, ContextNode, Coordinates, CoordinatesItem, Data, DataCategory, Event, Gallery, Identification, Image, ImageMap, ImageMapArea, Interpretation, LevelContext, LevelContextItem, License, Link, Metadata, Note, Observation, Period, Person, Property, PropertyQueryItem, PropertyValue, PropertyValueContent, PropertyValueContentType, Resource, Set, SpatialUnit, Style, Tree, UuidMetadata, WebBlock, WebBlockLayout, WebElement, WebElementComponent, WebImage, WebTitle, Webpage, WebpageProperties, Website,
|
|
1192
|
+
export { Bibliography, Concept, Context, ContextItem, ContextNode, Coordinates, CoordinatesItem, Data, DataCategory, Event, Gallery, Identification, Image, ImageMap, ImageMapArea, Interpretation, LevelContext, LevelContextItem, License, Link, Metadata, Note, Observation, Period, Person, Property, PropertyQueryItem, PropertyValue, PropertyValueContent, PropertyValueContentType, Resource, Set, SpatialUnit, Style, Tree, UuidMetadata, WebBlock, WebBlockLayout, WebElement, WebElementComponent, WebImage, WebTitle, Webpage, WebpageProperties, Website, fetchByUuidMetadata, fetchGallery, fetchItem, fetchPropertyQuery, fetchWebsite, filterProperties, getPropertyByLabel, getPropertyByUuid, getPropertyValueByLabel, getPropertyValueByUuid, getPropertyValuesByLabel, getPropertyValuesByUuid, getUniqueProperties, getUniquePropertyLabels };
|
package/dist/index.mjs
CHANGED
|
@@ -1783,14 +1783,17 @@ function parseWebElementProperties(componentProperty, elementResource) {
|
|
|
1783
1783
|
break;
|
|
1784
1784
|
}
|
|
1785
1785
|
case "collection": {
|
|
1786
|
-
const
|
|
1787
|
-
if (
|
|
1786
|
+
const collectionLinks = links.filter((link) => link.category === "set");
|
|
1787
|
+
if (collectionLinks.length === 0) throw new Error(`Collection links not found for the following component: “${componentName}”`);
|
|
1788
1788
|
let variant = getPropertyValueByLabel(componentProperty.properties, "variant");
|
|
1789
1789
|
variant ??= "full";
|
|
1790
1790
|
let itemVariant = getPropertyValueByLabel(componentProperty.properties, "item-variant");
|
|
1791
1791
|
itemVariant ??= "detailed";
|
|
1792
1792
|
let paginationVariant = getPropertyValueByLabel(componentProperty.properties, "pagination-variant");
|
|
1793
1793
|
paginationVariant ??= "default";
|
|
1794
|
+
let isSearchDisplayed = false;
|
|
1795
|
+
const isSearchDisplayedProperty = getPropertyValueByLabel(componentProperty.properties, "search-displayed");
|
|
1796
|
+
if (isSearchDisplayedProperty !== null) isSearchDisplayed = isSearchDisplayedProperty === true;
|
|
1794
1797
|
let isSortDisplayed = false;
|
|
1795
1798
|
const isSortDisplayedProperty = getPropertyValueByLabel(componentProperty.properties, "sort-displayed");
|
|
1796
1799
|
if (isSortDisplayedProperty !== null) isSortDisplayed = isSortDisplayedProperty === true;
|
|
@@ -1842,10 +1845,11 @@ function parseWebElementProperties(componentProperty, elementResource) {
|
|
|
1842
1845
|
prominent: parseContexts(prominentContextsRaw)
|
|
1843
1846
|
};
|
|
1844
1847
|
}
|
|
1845
|
-
properties.
|
|
1848
|
+
properties.collectionIds = collectionLinks.map((link) => link.uuid);
|
|
1846
1849
|
properties.variant = variant;
|
|
1847
1850
|
properties.itemVariant = itemVariant;
|
|
1848
1851
|
properties.paginationVariant = paginationVariant;
|
|
1852
|
+
properties.isSearchDisplayed = isSearchDisplayed;
|
|
1849
1853
|
properties.isSortDisplayed = isSortDisplayed;
|
|
1850
1854
|
properties.isFilterDisplayed = isFilterDisplayed;
|
|
1851
1855
|
properties.filterSort = filterSort;
|
|
@@ -2560,7 +2564,7 @@ function parseWebBlock(blockResource) {
|
|
|
2560
2564
|
return returnBlock;
|
|
2561
2565
|
}
|
|
2562
2566
|
/**
|
|
2563
|
-
* Parses raw website properties into a standardized
|
|
2567
|
+
* Parses raw website properties into a standardized Website properties structure
|
|
2564
2568
|
*
|
|
2565
2569
|
* @param properties - Array of raw website properties in OCHRE format
|
|
2566
2570
|
* @returns Parsed WebsiteProperties object
|
|
@@ -2611,6 +2615,7 @@ function parseWebsiteProperties(properties) {
|
|
|
2611
2615
|
if (footerProperty) isFooterDisplayed = footerProperty.content === true;
|
|
2612
2616
|
const sidebarProperty = websiteProperties.find((property) => property.label === "sidebar-visible")?.values[0];
|
|
2613
2617
|
if (sidebarProperty) isSidebarDisplayed = sidebarProperty.content === true;
|
|
2618
|
+
const headerSearchButtonPageSlug = websiteProperties.find((property) => property.label === "navbar-search-button-page")?.values[0]?.content?.toString() ?? null;
|
|
2614
2619
|
const iiifViewerProperty = websiteProperties.find((property) => property.label === "iiif-viewer")?.values[0];
|
|
2615
2620
|
if (iiifViewerProperty) iiifViewer = iiifViewerProperty.content;
|
|
2616
2621
|
const supportsThemeToggleProperty = websiteProperties.find((property) => property.label === "supports-theme-toggle")?.values[0];
|
|
@@ -2629,6 +2634,7 @@ function parseWebsiteProperties(properties) {
|
|
|
2629
2634
|
isHeaderProjectDisplayed,
|
|
2630
2635
|
isFooterDisplayed,
|
|
2631
2636
|
isSidebarDisplayed,
|
|
2637
|
+
headerSearchButtonPageSlug,
|
|
2632
2638
|
iiifViewer,
|
|
2633
2639
|
supportsThemeToggle,
|
|
2634
2640
|
defaultTheme,
|
|
@@ -3123,12 +3129,12 @@ const V2_ABBREVIATIONS = new Set(["bengali-song"]);
|
|
|
3123
3129
|
*/
|
|
3124
3130
|
async function fetchWebsite(abbreviation, options) {
|
|
3125
3131
|
try {
|
|
3126
|
-
const customFetch = options?.customFetch;
|
|
3127
|
-
const isVersion2 = options?.isVersion2 ?? false;
|
|
3128
3132
|
const cleanAbbreviation = abbreviation.trim().toLocaleLowerCase("en-US");
|
|
3133
|
+
const customFetch = options?.customFetch;
|
|
3134
|
+
const isVersion2 = V2_ABBREVIATIONS.has(cleanAbbreviation) ? true : options?.isVersion2 ?? false;
|
|
3129
3135
|
let metadata = null;
|
|
3130
3136
|
let tree = null;
|
|
3131
|
-
if (
|
|
3137
|
+
if (isVersion2) {
|
|
3132
3138
|
const response = await (customFetch ?? fetch)(`https://ochre.lib.uchicago.edu/ochre/v2/ochre.php?xquery=${encodeURIComponent(`collection('ochre/tree')/ochre[tree/identification/abbreviation/content/string='${cleanAbbreviation}']`)}&format=json&lang="*"`);
|
|
3133
3139
|
if (!response.ok) throw new Error("Failed to fetch website");
|
|
3134
3140
|
const data = await response.json();
|
|
@@ -3146,7 +3152,7 @@ async function fetchWebsite(abbreviation, options) {
|
|
|
3146
3152
|
tree = result.ochre.tree;
|
|
3147
3153
|
}
|
|
3148
3154
|
const projectIdentification = metadata.project?.identification ? parseIdentification(metadata.project.identification) : null;
|
|
3149
|
-
return [null, parseWebsite(tree, projectIdentification?.label ?? "", metadata.project?.identification.website ?? null, { isVersion2
|
|
3155
|
+
return [null, parseWebsite(tree, projectIdentification?.label ?? "", metadata.project?.identification.website ?? null, { isVersion2 })];
|
|
3150
3156
|
} catch (error) {
|
|
3151
3157
|
console.error(error);
|
|
3152
3158
|
return [error instanceof Error ? error.message : "Unknown error", null];
|
package/package.json
CHANGED