@digitalculture/ochre-sdk 0.12.11 → 0.12.13

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 CHANGED
@@ -559,36 +559,53 @@ type Website = {
559
559
  isHeaderProjectDisplayed: boolean;
560
560
  isFooterDisplayed: boolean;
561
561
  isSidebarDisplayed: boolean;
562
- headerSearchButtonPageSlug: string | null;
563
- iiifViewer: "universal-viewer" | "clover";
562
+ headerSearchBarPageSlug: string | null;
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
  };
583
+ /**
584
+ * Represents a webpage with its title, slug, properties, items and subpages
585
+ */
569
586
  type Webpage = {
570
587
  title: string;
571
588
  slug: string;
572
- properties: WebpageProperties;
589
+ properties: {
590
+ displayedInHeader: boolean;
591
+ width: "full" | "large" | "narrow" | "default";
592
+ variant: "default" | "no-background";
593
+ backgroundImageUrl: string | null;
594
+ isBreadcrumbsDisplayed: boolean;
595
+ isSidebarDisplayed: boolean;
596
+ isHeaderSearchBarDisplayed: boolean;
597
+ cssStyles: {
598
+ default: Array<Style>;
599
+ tablet: Array<Style>;
600
+ mobile: Array<Style>;
601
+ };
602
+ };
573
603
  items: Array<WebElement | WebBlock>;
574
604
  webpages: Array<Webpage>;
575
605
  };
576
606
  /**
577
- * Properties for configuring webpage display and styling
607
+ * Represents a title with its label and variant
578
608
  */
579
- type WebpageProperties = {
580
- displayedInHeader: boolean;
581
- width: "full" | "large" | "narrow" | "default";
582
- variant: "default" | "no-background";
583
- backgroundImageUrl: string | null;
584
- isBreadcrumbsDisplayed: boolean;
585
- isSidebarDisplayed: boolean;
586
- cssStyles: {
587
- default: Array<Style>;
588
- tablet: Array<Style>;
589
- mobile: Array<Style>;
590
- };
591
- };
592
609
  type WebTitle = {
593
610
  label: string;
594
611
  variant: "default" | "simple";
@@ -667,7 +684,7 @@ type WebElementComponent = {
667
684
  isFilterDisplayed: boolean;
668
685
  filterSort: "default" | "alphabetical";
669
686
  search: {
670
- isInputDisplayed: boolean;
687
+ isUsingQueryParams: boolean;
671
688
  isResultsBarDisplayed: boolean;
672
689
  isMapDisplayed: boolean;
673
690
  };
@@ -1204,4 +1221,4 @@ declare function filterProperties(property: Property, filter: {
1204
1221
  value: string | number | boolean | Date;
1205
1222
  }, options?: PropertyOptions): boolean;
1206
1223
  //#endregion
1207
- 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 };
1224
+ 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, Website, fetchByUuidMetadata, fetchGallery, fetchItem, fetchPropertyQuery, fetchWebsite, filterProperties, getPropertyByLabel, getPropertyByUuid, getPropertyValueByLabel, getPropertyValueByUuid, getPropertyValuesByLabel, getPropertyValuesByUuid, getUniqueProperties, getUniquePropertyLabels };
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 isInputDisplayed = false;
1805
- const isInputDisplayedProperty = getPropertyValueByLabel(componentProperty.properties, "input-displayed");
1806
- if (isInputDisplayedProperty !== null) isInputDisplayed = isInputDisplayedProperty === true;
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
- isInputDisplayed,
1869
+ isUsingQueryParams,
1870
1870
  isResultsBarDisplayed,
1871
1871
  isMapDisplayed
1872
1872
  };
@@ -2257,6 +2257,7 @@ function parseWebpage(webpageResource) {
2257
2257
  let variant = "default";
2258
2258
  let isSidebarDisplayed = true;
2259
2259
  let isBreadcrumbsDisplayed = false;
2260
+ let isHeaderSearchBarDisplayed = true;
2260
2261
  const webpageSubProperties = webpageProperties.find((property) => property.label === "presentation" && property.values[0]?.content === "page")?.properties;
2261
2262
  if (webpageSubProperties) {
2262
2263
  const headerProperty = webpageSubProperties.find((property) => property.label === "header")?.values[0];
@@ -2265,10 +2266,12 @@ function parseWebpage(webpageResource) {
2265
2266
  if (widthProperty) width = widthProperty.content;
2266
2267
  const variantProperty = webpageSubProperties.find((property) => property.label === "variant")?.values[0];
2267
2268
  if (variantProperty) variant = variantProperty.content;
2268
- const isSidebarDisplayedProperty = webpageSubProperties.find((property) => property.label === "sidebar-visible")?.values[0];
2269
+ const isSidebarDisplayedProperty = webpageSubProperties.find((property) => property.label === "sidebar-displayed")?.values[0];
2269
2270
  if (isSidebarDisplayedProperty) isSidebarDisplayed = isSidebarDisplayedProperty.content === true;
2270
- const isBreadcrumbsDisplayedProperty = webpageSubProperties.find((property) => property.label === "breadcrumbs-visible")?.values[0];
2271
+ const isBreadcrumbsDisplayedProperty = webpageSubProperties.find((property) => property.label === "breadcrumbs-displayed")?.values[0];
2271
2272
  if (isBreadcrumbsDisplayedProperty) isBreadcrumbsDisplayed = isBreadcrumbsDisplayedProperty.content === true;
2273
+ const isHeaderSearchBarDisplayedProperty = webpageSubProperties.find((property) => property.label === "header-search-bar-displayed")?.values[0];
2274
+ if (isHeaderSearchBarDisplayedProperty) isHeaderSearchBarDisplayed = isHeaderSearchBarDisplayedProperty.content === true;
2272
2275
  }
2273
2276
  const cssStyleSubProperties = webpageProperties.find((property) => property.label === "presentation" && property.values[0]?.content === "css")?.properties;
2274
2277
  const cssStyles = [];
@@ -2299,6 +2302,7 @@ function parseWebpage(webpageResource) {
2299
2302
  backgroundImageUrl: imageLink ? `https://ochre.lib.uchicago.edu/ochre?uuid=${imageLink.uuid}&load` : null,
2300
2303
  isSidebarDisplayed,
2301
2304
  isBreadcrumbsDisplayed,
2305
+ isHeaderSearchBarDisplayed,
2302
2306
  cssStyles: {
2303
2307
  default: cssStyles,
2304
2308
  tablet: cssStylesTablet,
@@ -2601,7 +2605,7 @@ function parseWebBlock(blockResource) {
2601
2605
  * @param properties - Array of raw website properties in OCHRE format
2602
2606
  * @returns Parsed WebsiteProperties object
2603
2607
  */
2604
- function parseWebsiteProperties(properties) {
2608
+ function parseWebsiteProperties(properties, websiteTree) {
2605
2609
  const websiteProperties = parseProperties(properties).find((property) => property.label === "presentation")?.properties;
2606
2610
  if (!websiteProperties) throw new Error("Presentation property not found");
2607
2611
  let type = websiteProperties.find((property) => property.label === "webUI")?.values[0]?.content;
@@ -2635,19 +2639,19 @@ function parseWebsiteProperties(properties) {
2635
2639
  let iiifViewer = "universal-viewer";
2636
2640
  let supportsThemeToggle = true;
2637
2641
  let defaultTheme = null;
2638
- const headerProperty = websiteProperties.find((property) => property.label === "navbar-visible")?.values[0];
2642
+ const headerProperty = websiteProperties.find((property) => property.label === "navbar-displayed")?.values[0];
2639
2643
  if (headerProperty) isHeaderDisplayed = headerProperty.content === true;
2640
2644
  const headerVariantProperty = websiteProperties.find((property) => property.label === "navbar-variant")?.values[0];
2641
2645
  if (headerVariantProperty) headerVariant = headerVariantProperty.content;
2642
2646
  const headerAlignmentProperty = websiteProperties.find((property) => property.label === "navbar-alignment")?.values[0];
2643
2647
  if (headerAlignmentProperty) headerAlignment = headerAlignmentProperty.content;
2644
- const isHeaderProjectDisplayedProperty = websiteProperties.find((property) => property.label === "navbar-project-visible")?.values[0];
2648
+ const isHeaderProjectDisplayedProperty = websiteProperties.find((property) => property.label === "navbar-project-displayed")?.values[0];
2645
2649
  if (isHeaderProjectDisplayedProperty) isHeaderProjectDisplayed = isHeaderProjectDisplayedProperty.content === true;
2646
- const footerProperty = websiteProperties.find((property) => property.label === "footer-visible")?.values[0];
2650
+ const footerProperty = websiteProperties.find((property) => property.label === "footer-displayed")?.values[0];
2647
2651
  if (footerProperty) isFooterDisplayed = footerProperty.content === true;
2648
- const sidebarProperty = websiteProperties.find((property) => property.label === "sidebar-visible")?.values[0];
2652
+ const sidebarProperty = websiteProperties.find((property) => property.label === "sidebar-displayed")?.values[0];
2649
2653
  if (sidebarProperty) isSidebarDisplayed = sidebarProperty.content === true;
2650
- const headerSearchButtonPageSlug = websiteProperties.find((property) => property.label === "navbar-search-button-page")?.values[0]?.content?.toString() ?? null;
2654
+ const headerSearchBarPageSlug = websiteProperties.find((property) => property.label === "navbar-search-bar-page")?.values[0]?.content?.toString() ?? null;
2651
2655
  const iiifViewerProperty = websiteProperties.find((property) => property.label === "iiif-viewer")?.values[0];
2652
2656
  if (iiifViewerProperty) iiifViewer = iiifViewerProperty.content;
2653
2657
  const supportsThemeToggleProperty = websiteProperties.find((property) => property.label === "supports-theme-toggle")?.values[0];
@@ -2655,6 +2659,36 @@ function parseWebsiteProperties(properties) {
2655
2659
  const defaultThemeProperty = websiteProperties.find((property) => property.label === "default-theme")?.values[0];
2656
2660
  if (defaultThemeProperty) defaultTheme = defaultThemeProperty.content;
2657
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
+ }
2658
2692
  return {
2659
2693
  type: validatedType,
2660
2694
  privacy: validatedPrivacy,
@@ -2666,11 +2700,14 @@ function parseWebsiteProperties(properties) {
2666
2700
  isHeaderProjectDisplayed,
2667
2701
  isFooterDisplayed,
2668
2702
  isSidebarDisplayed,
2669
- headerSearchButtonPageSlug,
2670
- iiifViewer,
2703
+ headerSearchBarPageSlug,
2671
2704
  supportsThemeToggle,
2672
2705
  defaultTheme,
2673
- 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
+ }
2674
2711
  };
2675
2712
  }
2676
2713
  function parseContexts(contexts) {
@@ -2709,7 +2746,7 @@ function parseContexts(contexts) {
2709
2746
  }
2710
2747
  function parseWebsite(websiteTree, projectName, website, { isVersion2 = false } = {}) {
2711
2748
  if (!websiteTree.properties) throw new Error("Website properties not found");
2712
- 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);
2713
2750
  if (typeof websiteTree.items === "string" || !("resource" in websiteTree.items)) throw new Error("Website pages not found");
2714
2751
  const resources = Array.isArray(websiteTree.items.resource) ? websiteTree.items.resource : [websiteTree.items.resource];
2715
2752
  const pages = parseWebpages(resources);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digitalculture/ochre-sdk",
3
- "version": "0.12.11",
3
+ "version": "0.12.13",
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",