@digitalculture/ochre-sdk 0.12.12 → 0.12.14
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 +16 -2
- package/dist/index.mjs +42 -9
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -560,10 +560,24 @@ type Website = {
|
|
|
560
560
|
isFooterDisplayed: boolean;
|
|
561
561
|
isSidebarDisplayed: boolean;
|
|
562
562
|
headerSearchBarPageSlug: string | null;
|
|
563
|
-
iiifViewer: "universal-viewer" | "clover";
|
|
564
563
|
supportsThemeToggle: boolean;
|
|
565
564
|
defaultTheme: "light" | "dark" | null;
|
|
566
565
|
logoUrl: string | null;
|
|
566
|
+
itemPage: {
|
|
567
|
+
iiifViewer: "universal-viewer" | "clover";
|
|
568
|
+
options: {
|
|
569
|
+
contexts: {
|
|
570
|
+
flatten: Array<LevelContext>;
|
|
571
|
+
suppress: Array<LevelContext>;
|
|
572
|
+
filter: Array<LevelContext>;
|
|
573
|
+
sort: Array<LevelContext>;
|
|
574
|
+
detail: Array<LevelContext>;
|
|
575
|
+
download: Array<LevelContext>;
|
|
576
|
+
label: Array<LevelContext>;
|
|
577
|
+
prominent: Array<LevelContext>;
|
|
578
|
+
};
|
|
579
|
+
};
|
|
580
|
+
};
|
|
567
581
|
};
|
|
568
582
|
};
|
|
569
583
|
/**
|
|
@@ -670,7 +684,7 @@ type WebElementComponent = {
|
|
|
670
684
|
isFilterDisplayed: boolean;
|
|
671
685
|
filterSort: "default" | "alphabetical";
|
|
672
686
|
search: {
|
|
673
|
-
|
|
687
|
+
isUsingQueryParams: boolean;
|
|
674
688
|
isResultsBarDisplayed: boolean;
|
|
675
689
|
isMapDisplayed: boolean;
|
|
676
690
|
};
|
package/dist/index.mjs
CHANGED
|
@@ -1801,9 +1801,9 @@ function parseWebElementProperties(componentProperty, elementResource) {
|
|
|
1801
1801
|
itemVariant ??= "detailed";
|
|
1802
1802
|
let paginationVariant = getPropertyValueByLabel(componentProperty.properties, "pagination-variant");
|
|
1803
1803
|
paginationVariant ??= "default";
|
|
1804
|
-
let
|
|
1805
|
-
const
|
|
1806
|
-
if (
|
|
1804
|
+
let isUsingQueryParams = false;
|
|
1805
|
+
const isUsingQueryParamsProperty = getPropertyValueByLabel(componentProperty.properties, "is-using-query-params");
|
|
1806
|
+
if (isUsingQueryParamsProperty !== null) isUsingQueryParams = isUsingQueryParamsProperty === true;
|
|
1807
1807
|
let isResultsBarDisplayed = false;
|
|
1808
1808
|
const isResultsBarDisplayedProperty = getPropertyValueByLabel(componentProperty.properties, "results-bar-displayed");
|
|
1809
1809
|
if (isResultsBarDisplayedProperty !== null) isResultsBarDisplayed = isResultsBarDisplayedProperty === true;
|
|
@@ -1866,7 +1866,7 @@ function parseWebElementProperties(componentProperty, elementResource) {
|
|
|
1866
1866
|
properties.itemVariant = itemVariant;
|
|
1867
1867
|
properties.paginationVariant = paginationVariant;
|
|
1868
1868
|
properties.search = {
|
|
1869
|
-
|
|
1869
|
+
isUsingQueryParams,
|
|
1870
1870
|
isResultsBarDisplayed,
|
|
1871
1871
|
isMapDisplayed
|
|
1872
1872
|
};
|
|
@@ -2605,7 +2605,7 @@ function parseWebBlock(blockResource) {
|
|
|
2605
2605
|
* @param properties - Array of raw website properties in OCHRE format
|
|
2606
2606
|
* @returns Parsed WebsiteProperties object
|
|
2607
2607
|
*/
|
|
2608
|
-
function parseWebsiteProperties(properties) {
|
|
2608
|
+
function parseWebsiteProperties(properties, websiteTree) {
|
|
2609
2609
|
const websiteProperties = parseProperties(properties).find((property) => property.label === "presentation")?.properties;
|
|
2610
2610
|
if (!websiteProperties) throw new Error("Presentation property not found");
|
|
2611
2611
|
let type = websiteProperties.find((property) => property.label === "webUI")?.values[0]?.content;
|
|
@@ -2659,6 +2659,36 @@ function parseWebsiteProperties(properties) {
|
|
|
2659
2659
|
const defaultThemeProperty = websiteProperties.find((property) => property.label === "default-theme")?.values[0];
|
|
2660
2660
|
if (defaultThemeProperty) defaultTheme = defaultThemeProperty.content;
|
|
2661
2661
|
const { type: validatedType, status: validatedStatus, privacy: validatedPrivacy } = result.data;
|
|
2662
|
+
let contexts = {
|
|
2663
|
+
flatten: [],
|
|
2664
|
+
suppress: [],
|
|
2665
|
+
filter: [],
|
|
2666
|
+
sort: [],
|
|
2667
|
+
detail: [],
|
|
2668
|
+
download: [],
|
|
2669
|
+
label: [],
|
|
2670
|
+
prominent: []
|
|
2671
|
+
};
|
|
2672
|
+
if ("options" in websiteTree && websiteTree.options) {
|
|
2673
|
+
const flattenContextsRaw = websiteTree.options.flattenContexts != null ? Array.isArray(websiteTree.options.flattenContexts) ? websiteTree.options.flattenContexts : [websiteTree.options.flattenContexts] : [];
|
|
2674
|
+
const suppressContextsRaw = websiteTree.options.suppressContexts != null ? Array.isArray(websiteTree.options.suppressContexts) ? websiteTree.options.suppressContexts : [websiteTree.options.suppressContexts] : [];
|
|
2675
|
+
const filterContextsRaw = websiteTree.options.filterContexts != null ? Array.isArray(websiteTree.options.filterContexts) ? websiteTree.options.filterContexts : [websiteTree.options.filterContexts] : [];
|
|
2676
|
+
const sortContextsRaw = websiteTree.options.sortContexts != null ? Array.isArray(websiteTree.options.sortContexts) ? websiteTree.options.sortContexts : [websiteTree.options.sortContexts] : [];
|
|
2677
|
+
const detailContextsRaw = websiteTree.options.detailContexts != null ? Array.isArray(websiteTree.options.detailContexts) ? websiteTree.options.detailContexts : [websiteTree.options.detailContexts] : [];
|
|
2678
|
+
const downloadContextsRaw = websiteTree.options.downloadContexts != null ? Array.isArray(websiteTree.options.downloadContexts) ? websiteTree.options.downloadContexts : [websiteTree.options.downloadContexts] : [];
|
|
2679
|
+
const labelContextsRaw = websiteTree.options.labelContexts != null ? Array.isArray(websiteTree.options.labelContexts) ? websiteTree.options.labelContexts : [websiteTree.options.labelContexts] : [];
|
|
2680
|
+
const prominentContextsRaw = websiteTree.options.prominentContexts != null ? Array.isArray(websiteTree.options.prominentContexts) ? websiteTree.options.prominentContexts : [websiteTree.options.prominentContexts] : [];
|
|
2681
|
+
contexts = {
|
|
2682
|
+
flatten: parseContexts(flattenContextsRaw),
|
|
2683
|
+
suppress: parseContexts(suppressContextsRaw),
|
|
2684
|
+
filter: parseContexts(filterContextsRaw),
|
|
2685
|
+
sort: parseContexts(sortContextsRaw),
|
|
2686
|
+
detail: parseContexts(detailContextsRaw),
|
|
2687
|
+
download: parseContexts(downloadContextsRaw),
|
|
2688
|
+
label: parseContexts(labelContextsRaw),
|
|
2689
|
+
prominent: parseContexts(prominentContextsRaw)
|
|
2690
|
+
};
|
|
2691
|
+
}
|
|
2662
2692
|
return {
|
|
2663
2693
|
type: validatedType,
|
|
2664
2694
|
privacy: validatedPrivacy,
|
|
@@ -2671,10 +2701,13 @@ function parseWebsiteProperties(properties) {
|
|
|
2671
2701
|
isFooterDisplayed,
|
|
2672
2702
|
isSidebarDisplayed,
|
|
2673
2703
|
headerSearchBarPageSlug,
|
|
2674
|
-
iiifViewer,
|
|
2675
2704
|
supportsThemeToggle,
|
|
2676
2705
|
defaultTheme,
|
|
2677
|
-
logoUrl: logoUuid !== null ? `https://ochre.lib.uchicago.edu/ochre?uuid=${logoUuid}&load` : null
|
|
2706
|
+
logoUrl: logoUuid !== null ? `https://ochre.lib.uchicago.edu/ochre?uuid=${logoUuid}&load` : null,
|
|
2707
|
+
itemPage: {
|
|
2708
|
+
iiifViewer,
|
|
2709
|
+
options: { contexts }
|
|
2710
|
+
}
|
|
2678
2711
|
};
|
|
2679
2712
|
}
|
|
2680
2713
|
function parseContexts(contexts) {
|
|
@@ -2713,7 +2746,7 @@ function parseContexts(contexts) {
|
|
|
2713
2746
|
}
|
|
2714
2747
|
function parseWebsite(websiteTree, projectName, website, { isVersion2 = false } = {}) {
|
|
2715
2748
|
if (!websiteTree.properties) throw new Error("Website properties not found");
|
|
2716
|
-
const properties = parseWebsiteProperties(Array.isArray(websiteTree.properties.property) ? websiteTree.properties.property : [websiteTree.properties.property]);
|
|
2749
|
+
const properties = parseWebsiteProperties(Array.isArray(websiteTree.properties.property) ? websiteTree.properties.property : [websiteTree.properties.property], websiteTree);
|
|
2717
2750
|
if (typeof websiteTree.items === "string" || !("resource" in websiteTree.items)) throw new Error("Website pages not found");
|
|
2718
2751
|
const resources = Array.isArray(websiteTree.items.resource) ? websiteTree.items.resource : [websiteTree.items.resource];
|
|
2719
2752
|
const pages = parseWebpages(resources);
|
|
@@ -3133,7 +3166,7 @@ const KNOWN_ABBREVIATIONS = {
|
|
|
3133
3166
|
ssmc: "8ff977dd-d440-40f5-ad93-8ad7e2d39e74",
|
|
3134
3167
|
"sosc-core-at-smart": "db26c953-9b2a-4691-a909-5e8726b531d7"
|
|
3135
3168
|
};
|
|
3136
|
-
const V2_ABBREVIATIONS = new Set(
|
|
3169
|
+
const V2_ABBREVIATIONS = /* @__PURE__ */ new Set();
|
|
3137
3170
|
/**
|
|
3138
3171
|
* Fetches and parses a website configuration from the OCHRE API
|
|
3139
3172
|
*
|
package/package.json
CHANGED