ochre-sdk 0.21.0 → 0.21.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.d.mts CHANGED
@@ -771,6 +771,28 @@ type Scope = {
771
771
  type: string;
772
772
  identification: Identification;
773
773
  };
774
+ /**
775
+ * Represents a stylesheet item with its UUID and category
776
+ */
777
+ type StylesheetCategory = Extract<DataCategory, "propertyVariable" | "propertyValue">;
778
+ type StylesheetItem = {
779
+ uuid: string;
780
+ category: "propertyVariable";
781
+ styles: {
782
+ default: Array<Style>;
783
+ tablet: Array<Style>;
784
+ mobile: Array<Style>;
785
+ };
786
+ } | {
787
+ uuid: string;
788
+ category: "propertyValue";
789
+ variableUuid: string;
790
+ styles: {
791
+ default: Array<Style>;
792
+ tablet: Array<Style>;
793
+ mobile: Array<Style>;
794
+ };
795
+ };
774
796
  /**
775
797
  * Represents the OCHRE website type
776
798
  */
@@ -818,6 +840,7 @@ type Website = {
818
840
  };
819
841
  footer: {
820
842
  isDisplayed: boolean;
843
+ logoUuid: string | null;
821
844
  items: Array<WebElement | WebBlock> | null;
822
845
  };
823
846
  sidebar: {
@@ -850,6 +873,9 @@ type Website = {
850
873
  labels: {
851
874
  title: string | null;
852
875
  };
876
+ stylesheets: {
877
+ properties: Array<StylesheetItem>;
878
+ };
853
879
  };
854
880
  };
855
881
  };
@@ -1477,4 +1503,4 @@ declare const DEFAULT_PAGE_SIZE = 48;
1477
1503
  */
1478
1504
  declare function flattenItemProperties<T extends DataCategory = DataCategory, U extends DataCategory | Array<DataCategory> = (T extends "tree" ? Exclude<DataCategory, "tree"> : T extends "set" ? Array<DataCategory> : never)>(item: Item<T, U>): Item<T, U>;
1479
1505
  //#endregion
1480
- export { ApiVersion, Bibliography, Concept, Context, ContextItem, ContextNode, Coordinate, DEFAULT_API_VERSION, DEFAULT_PAGE_SIZE, Data, DataCategory, Event, FileFormat, Gallery, Identification, Image, ImageMap, ImageMapArea, Interpretation, Item, LevelContext, LevelContextItem, License, Link, Metadata, Note, Observation, Period, Person, Property, PropertyContexts, PropertyValue, PropertyValueContent, PropertyValueContentType, PropertyValueQueryItem, PropertyVariable, Query, QueryGroup, QueryLeaf, Resource, Scope, Section, Set, SetAttributeValueQueryItem, SetItemsSort, SetItemsSortDirection, SpatialUnit, Style, Text, Tree, WebBlock, WebBlockLayout, WebElement, WebElementComponent, WebImage, WebSegment, WebSegmentItem, WebTitle, Webpage, Website, WebsiteType, fetchGallery, fetchItem, fetchSetItems, fetchSetPropertyValues, fetchWebsite, filterProperties, flattenItemProperties, getLeafPropertyValues, getPropertyByLabel, getPropertyByLabelAndValue, getPropertyByLabelAndValues, getPropertyByUuid, getPropertyValueByLabel, getPropertyValueByUuid, getPropertyValuesByLabel, getPropertyValuesByUuid, getUniqueProperties, getUniquePropertyLabels };
1506
+ export { ApiVersion, Bibliography, Concept, Context, ContextItem, ContextNode, Coordinate, DEFAULT_API_VERSION, DEFAULT_PAGE_SIZE, Data, DataCategory, Event, FileFormat, Gallery, Identification, Image, ImageMap, ImageMapArea, Interpretation, Item, LevelContext, LevelContextItem, License, Link, Metadata, Note, Observation, Period, Person, Property, PropertyContexts, PropertyValue, PropertyValueContent, PropertyValueContentType, PropertyValueQueryItem, PropertyVariable, Query, QueryGroup, QueryLeaf, Resource, Scope, Section, Set, SetAttributeValueQueryItem, SetItemsSort, SetItemsSortDirection, SpatialUnit, Style, StylesheetCategory, StylesheetItem, Text, Tree, WebBlock, WebBlockLayout, WebElement, WebElementComponent, WebImage, WebSegment, WebSegmentItem, WebTitle, Webpage, Website, WebsiteType, fetchGallery, fetchItem, fetchSetItems, fetchSetPropertyValues, fetchWebsite, filterProperties, flattenItemProperties, getLeafPropertyValues, getPropertyByLabel, getPropertyByLabelAndValue, getPropertyByLabelAndValues, getPropertyByUuid, getPropertyValueByLabel, getPropertyValueByUuid, getPropertyValuesByLabel, getPropertyValuesByUuid, getUniqueProperties, getUniquePropertyLabels };
package/dist/index.mjs CHANGED
@@ -3809,6 +3809,37 @@ function parseAllOptionContexts(options) {
3809
3809
  prominent: handleContexts(options.prominentContexts)
3810
3810
  };
3811
3811
  }
3812
+ function parseStylesheets(styles) {
3813
+ return styles.map((style) => {
3814
+ const defaultStyles = [];
3815
+ for (const [label, value] of Object.entries(style)) {
3816
+ if (label === "variableUuid" || label === "valueUuid" || label === "category" || label === "content") continue;
3817
+ defaultStyles.push({
3818
+ label,
3819
+ value: parseFakeString(value)
3820
+ });
3821
+ }
3822
+ const stylesByViewport = {
3823
+ default: defaultStyles,
3824
+ tablet: [],
3825
+ mobile: []
3826
+ };
3827
+ if (style.category === "propertyValue" || style.valueUuid != null) {
3828
+ if (style.valueUuid == null) throw new Error(`Stylesheet property value "${style.variableUuid}" is missing a value UUID`);
3829
+ return {
3830
+ uuid: style.valueUuid,
3831
+ category: "propertyValue",
3832
+ variableUuid: style.variableUuid,
3833
+ styles: stylesByViewport
3834
+ };
3835
+ }
3836
+ return {
3837
+ uuid: style.variableUuid,
3838
+ category: "propertyVariable",
3839
+ styles: stylesByViewport
3840
+ };
3841
+ });
3842
+ }
3812
3843
  /**
3813
3844
  * Parses raw web element properties into a standardized WebElementComponent structure
3814
3845
  *
@@ -4884,6 +4915,7 @@ function parseWebsiteProperties(properties, websiteTree, sidebar) {
4884
4915
  },
4885
4916
  footer: {
4886
4917
  isDisplayed: true,
4918
+ logoUuid: null,
4887
4919
  items: null
4888
4920
  },
4889
4921
  sidebar,
@@ -4902,7 +4934,8 @@ function parseWebsiteProperties(properties, websiteTree, sidebar) {
4902
4934
  options: {
4903
4935
  contexts: null,
4904
4936
  scopes: null,
4905
- labels: { title: null }
4937
+ labels: { title: null },
4938
+ stylesheets: { properties: [] }
4906
4939
  }
4907
4940
  };
4908
4941
  const contactProperty = getPropertyByLabel(websiteProperties, "contact");
@@ -4916,7 +4949,7 @@ function parseWebsiteProperties(properties, websiteTree, sidebar) {
4916
4949
  }
4917
4950
  returnProperties.theme.isThemeToggleDisplayed = getPropertyValueByLabel(websiteProperties, "supports-theme-toggle") ?? true;
4918
4951
  returnProperties.theme.defaultTheme = getPropertyValueByLabel(websiteProperties, "default-theme") ?? "system";
4919
- returnProperties.icon.logoUuid = getPropertyByLabel(websiteProperties, "logo")?.values[0]?.uuid ?? null;
4952
+ returnProperties.icon.logoUuid = getPropertyByLabel(websiteProperties, "navbar-logo")?.values[0]?.uuid ?? null;
4920
4953
  returnProperties.icon.faviconUuid = getPropertyByLabel(websiteProperties, "favicon-ico")?.values[0]?.uuid ?? null;
4921
4954
  returnProperties.icon.appleTouchIconUuid = getPropertyByLabel(websiteProperties, "favicon-img")?.values[0]?.uuid ?? null;
4922
4955
  returnProperties.navbar.isDisplayed = getPropertyValueByLabel(websiteProperties, "navbar-displayed") ?? true;
@@ -4925,6 +4958,7 @@ function parseWebsiteProperties(properties, websiteTree, sidebar) {
4925
4958
  returnProperties.navbar.isProjectDisplayed = getPropertyValueByLabel(websiteProperties, "navbar-project-displayed") ?? true;
4926
4959
  returnProperties.navbar.searchBarBoundElementUuid = getPropertyByLabel(websiteProperties, "bound-element-navbar-search-bar")?.values[0]?.uuid ?? null;
4927
4960
  returnProperties.footer.isDisplayed = getPropertyValueByLabel(websiteProperties, "footer-displayed") ?? true;
4961
+ returnProperties.footer.logoUuid = getPropertyByLabel(websiteProperties, "footer-logo")?.values[0]?.uuid ?? null;
4928
4962
  const itemPageTypeProperty = getPropertyByLabelAndValue(websiteProperties, "page-type", "item-page");
4929
4963
  if (itemPageTypeProperty !== null) {
4930
4964
  returnProperties.itemPage.isMainContentDisplayed = getPropertyValueByLabel(itemPageTypeProperty.properties, "item-page-main-content-displayed") ?? true;
@@ -4950,6 +4984,7 @@ function parseWebsiteProperties(properties, websiteTree, sidebar) {
4950
4984
  returnProperties.options.labels.title = labelNotes.find((note) => note.title === "Title label")?.content ?? null;
4951
4985
  }
4952
4986
  }
4987
+ if ("styleOptions" in websiteTree && websiteTree.styleOptions != null) returnProperties.options.stylesheets.properties = parseStylesheets(ensureArray(websiteTree.styleOptions.style));
4953
4988
  return returnProperties;
4954
4989
  }
4955
4990
  function parseContexts(contexts) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ochre-sdk",
3
- "version": "0.21.0",
3
+ "version": "0.21.2",
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",
@@ -51,7 +51,7 @@
51
51
  "bumpp": "^11.0.1",
52
52
  "eslint": "^10.1.0",
53
53
  "prettier": "^3.8.1",
54
- "tsdown": "^0.21.4",
54
+ "tsdown": "^0.21.5",
55
55
  "typescript": "^6.0.2"
56
56
  },
57
57
  "scripts": {