@digitalculture/ochre-sdk 0.12.2 → 0.12.3

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
@@ -545,29 +545,26 @@ type Website = {
545
545
  mobile: Array<Style>;
546
546
  };
547
547
  } | null;
548
- properties: WebsiteProperties;
549
- };
550
- /**
551
- * Properties for configuring website display and styling
552
- */
553
- type WebsiteProperties = {
554
- type: "traditional" | "digital-collection" | "plum" | "cedar" | "elm" | "maple" | "oak" | "palm";
555
- privacy: "public" | "password" | "private";
556
- status: "development" | "preview" | "production";
557
- contact: {
558
- name: string;
559
- email: string | null;
560
- } | null;
561
- isHeaderDisplayed: boolean;
562
- headerVariant: "default" | "floating" | "inline";
563
- headerAlignment: "start" | "center" | "end";
564
- isHeaderProjectDisplayed: boolean;
565
- isFooterDisplayed: boolean;
566
- isSidebarDisplayed: boolean;
567
- iiifViewer: "universal-viewer" | "clover";
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;
@@ -661,6 +658,7 @@ type WebElementComponent = {
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, WebsiteProperties, fetchByUuidMetadata, fetchGallery, fetchItem, fetchPropertyQuery, fetchWebsite, filterProperties, getPropertyByLabel, getPropertyByUuid, getPropertyValueByLabel, getPropertyValueByUuid, getPropertyValuesByLabel, getPropertyValuesByUuid, getUniqueProperties, getUniquePropertyLabels };
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
@@ -1791,6 +1791,9 @@ function parseWebElementProperties(componentProperty, elementResource) {
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;
@@ -1846,6 +1849,7 @@ function parseWebElementProperties(componentProperty, elementResource) {
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 WebsiteProperties structure
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 (V2_ABBREVIATIONS.has(cleanAbbreviation) || isVersion2) {
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: true })];
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digitalculture/ochre-sdk",
3
- "version": "0.12.2",
3
+ "version": "0.12.3",
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",