ochre-sdk 0.22.11 → 0.22.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
@@ -756,36 +756,44 @@ type Query = QueryLeaf | QueryGroup;
756
756
  //#endregion
757
757
  //#region src/types/website.d.ts
758
758
  /**
759
- * Represents a level context item with a variable and value
759
+ * Represents a context tree level item with a variable and value
760
760
  */
761
- type LevelContextItem = {
761
+ type ContextTreeLevelItem = {
762
762
  variableUuid: string;
763
763
  valueUuid: string | null;
764
764
  };
765
765
  /**
766
- * Represents a level context with a context item
766
+ * Represents a context tree level with a context item
767
767
  */
768
- type LevelContext = {
769
- context: Array<LevelContextItem>;
768
+ type ContextTreeLevel = {
769
+ context: Array<ContextTreeLevelItem>;
770
770
  identification: Identification;
771
771
  type: string;
772
772
  };
773
773
  /**
774
- * Represents property contexts with its levels
774
+ * Represents a filter context tree level with a context item
775
775
  */
776
- type PropertyContexts = {
777
- flatten: Array<LevelContext>;
778
- suppress: Array<LevelContext>;
779
- filter: Array<LevelContext & {
780
- isInlineDisplayed: boolean;
781
- isSidebarDisplayed: boolean;
782
- isSidebarOpen: boolean;
783
- }>;
784
- sort: Array<LevelContext>;
785
- detail: Array<LevelContext>;
786
- download: Array<LevelContext>;
787
- label: Array<LevelContext>;
788
- prominent: Array<LevelContext>;
776
+ type ContextTreeFilterLevel = {
777
+ context: Array<ContextTreeLevelItem>;
778
+ identification: Identification;
779
+ type: string;
780
+ filterType: "property" | "coordinates" | "bibliography" | "period";
781
+ isInlineDisplayed: boolean;
782
+ isSidebarDisplayed: boolean;
783
+ isSidebarOpen: boolean;
784
+ };
785
+ /**
786
+ * Represents a context tree with levels grouped by behavior
787
+ */
788
+ type ContextTree = {
789
+ flatten: Array<ContextTreeLevel>;
790
+ suppress: Array<ContextTreeLevel>;
791
+ filter: Array<ContextTreeFilterLevel>;
792
+ sort: Array<ContextTreeLevel>;
793
+ detail: Array<ContextTreeLevel>;
794
+ download: Array<ContextTreeLevel>;
795
+ label: Array<ContextTreeLevel>;
796
+ prominent: Array<ContextTreeLevel>;
789
797
  };
790
798
  /**
791
799
  * Represents a scope with its UUID, type and identification
@@ -907,7 +915,7 @@ type Website = {
907
915
  iiifViewer: "universal-viewer" | "clover";
908
916
  };
909
917
  options: {
910
- contexts: PropertyContexts | null;
918
+ contextTree: ContextTree | null;
911
919
  scopes: Array<Scope> | null;
912
920
  labels: {
913
921
  title: string | null;
@@ -1058,25 +1066,14 @@ type WebElementComponent = {
1058
1066
  filter: {
1059
1067
  isSidebarDisplayed: boolean;
1060
1068
  isResultsBarDisplayed: boolean;
1061
- isMapDisplayed: boolean;
1062
1069
  isInputDisplayed: boolean;
1063
1070
  isLimitedToInputFilter: boolean;
1064
1071
  isLimitedToLeafPropertyValues: boolean;
1065
1072
  sidebarSort: "default" | "alphabetical";
1066
1073
  };
1067
1074
  options: {
1068
- attributeFilters: {
1069
- bibliographies: {
1070
- enabled: boolean;
1071
- isOpenByDefault: boolean;
1072
- };
1073
- periods: {
1074
- enabled: boolean;
1075
- isOpenByDefault: boolean;
1076
- };
1077
- };
1078
1075
  scopes: Array<Scope> | null;
1079
- contexts: PropertyContexts | null;
1076
+ contextTree: ContextTree | null;
1080
1077
  labels: {
1081
1078
  title: string | null;
1082
1079
  };
@@ -1140,12 +1137,8 @@ type WebElementComponent = {
1140
1137
  endIcon: string | null;
1141
1138
  }>;
1142
1139
  options: {
1143
- attributeFilters: {
1144
- bibliographies: boolean;
1145
- periods: boolean;
1146
- };
1147
1140
  scopes: Array<Scope> | null;
1148
- contexts: PropertyContexts | null;
1141
+ contextTree: ContextTree | null;
1149
1142
  labels: {
1150
1143
  title: string | null;
1151
1144
  };
@@ -1599,4 +1592,4 @@ declare const DEFAULT_PAGE_SIZE = 48;
1599
1592
  */
1600
1593
  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>;
1601
1594
  //#endregion
1602
- 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, WebsitePropertyQuery, WebsitePropertyQueryNode, WebsiteType, fetchGallery, fetchItem, fetchSetItems, fetchSetPropertyValues, fetchWebsite, filterProperties, flattenItemProperties, getLeafPropertyValues, getPropertyByLabel, getPropertyByLabelAndValue, getPropertyByLabelAndValueContent, getPropertyByLabelAndValueContents, getPropertyByLabelAndValues, getPropertyByUuid, getPropertyValueByLabel, getPropertyValueByUuid, getPropertyValueContentByLabel, getPropertyValueContentByUuid, getPropertyValueContentsByUuid, getPropertyValuesByLabel, getPropertyValuesByUuid, getUniqueProperties, getUniquePropertyLabels };
1595
+ export { ApiVersion, Bibliography, Concept, Context, ContextItem, ContextNode, ContextTree, ContextTreeFilterLevel, ContextTreeLevel, ContextTreeLevelItem, Coordinate, DEFAULT_API_VERSION, DEFAULT_PAGE_SIZE, Data, DataCategory, Event, FileFormat, Gallery, Identification, Image, ImageMap, ImageMapArea, Interpretation, Item, License, Link, Metadata, Note, Observation, Period, Person, Property, 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, WebsitePropertyQuery, WebsitePropertyQueryNode, WebsiteType, fetchGallery, fetchItem, fetchSetItems, fetchSetPropertyValues, fetchWebsite, filterProperties, flattenItemProperties, getLeafPropertyValues, getPropertyByLabel, getPropertyByLabelAndValue, getPropertyByLabelAndValueContent, getPropertyByLabelAndValueContents, getPropertyByLabelAndValues, getPropertyByUuid, getPropertyValueByLabel, getPropertyValueByUuid, getPropertyValueContentByLabel, getPropertyValueContentByUuid, getPropertyValueContentsByUuid, getPropertyValuesByLabel, getPropertyValuesByUuid, getUniqueProperties, getUniquePropertyLabels };
package/dist/index.mjs CHANGED
@@ -3921,8 +3921,6 @@ function parseWebElementProperties(componentProperty, elementResource) {
3921
3921
  isUsingQueryParams ??= false;
3922
3922
  let isFilterResultsBarDisplayed = getPropertyValueContentByLabel(componentProperty.properties, "filter-results-bar-displayed");
3923
3923
  isFilterResultsBarDisplayed ??= false;
3924
- let isFilterMapDisplayed = getPropertyValueContentByLabel(componentProperty.properties, "filter-map-displayed");
3925
- isFilterMapDisplayed ??= false;
3926
3924
  let isFilterInputDisplayed = getPropertyValueContentByLabel(componentProperty.properties, "filter-input-displayed");
3927
3925
  isFilterInputDisplayed ??= false;
3928
3926
  let isFilterLimitedToInputFilter = getPropertyValueContentByLabel(componentProperty.properties, "filter-limit-to-input-filter");
@@ -3938,26 +3936,16 @@ function parseWebElementProperties(componentProperty, elementResource) {
3938
3936
  let imageLayout = getPropertyValueContentByLabel(componentProperty.properties, "image-layout");
3939
3937
  imageLayout ??= "start";
3940
3938
  const options = {
3941
- attributeFilters: {
3942
- bibliographies: {
3943
- enabled: elementResource.options?.filterBibliography ?? false,
3944
- isOpenByDefault: false
3945
- },
3946
- periods: {
3947
- enabled: elementResource.options?.filterPeriods ?? false,
3948
- isOpenByDefault: false
3949
- }
3950
- },
3951
3939
  scopes: elementResource.options?.scopes != null ? ensureArray(elementResource.options.scopes.scope).map((scope) => ({
3952
3940
  uuid: scope.uuid.content,
3953
3941
  type: scope.uuid.type,
3954
3942
  identification: parseIdentification(scope.identification)
3955
3943
  })) : null,
3956
- contexts: null,
3944
+ contextTree: null,
3957
3945
  labels: { title: null }
3958
3946
  };
3959
3947
  if ("options" in elementResource && elementResource.options) {
3960
- options.contexts = parseAllOptionContexts(elementResource.options);
3948
+ options.contextTree = parseAllOptionContexts(elementResource.options);
3961
3949
  if ("notes" in elementResource.options && elementResource.options.notes) {
3962
3950
  const labelNotes = parseNotes(ensureArray(elementResource.options.notes.note));
3963
3951
  options.labels.title = labelNotes.find((note) => note.title === "Title label")?.content ?? null;
@@ -3979,7 +3967,6 @@ function parseWebElementProperties(componentProperty, elementResource) {
3979
3967
  filter: {
3980
3968
  isSidebarDisplayed: isFilterSidebarDisplayed,
3981
3969
  isResultsBarDisplayed: isFilterResultsBarDisplayed,
3982
- isMapDisplayed: isFilterMapDisplayed,
3983
3970
  isInputDisplayed: isFilterInputDisplayed,
3984
3971
  isLimitedToInputFilter: isFilterLimitedToInputFilter,
3985
3972
  isLimitedToLeafPropertyValues: isFilterLimitedToLeafPropertyValues,
@@ -4208,20 +4195,16 @@ function parseWebElementProperties(componentProperty, elementResource) {
4208
4195
  }
4209
4196
  if (items.length === 0) throw new Error(`No queries found for the following component: “${componentName}”`);
4210
4197
  const options = {
4211
- attributeFilters: {
4212
- bibliographies: elementResource.options?.filterBibliography ?? false,
4213
- periods: elementResource.options?.filterPeriods ?? false
4214
- },
4215
4198
  scopes: elementResource.options?.scopes != null ? ensureArray(elementResource.options.scopes.scope).map((scope) => ({
4216
4199
  uuid: scope.uuid.content,
4217
4200
  type: scope.uuid.type,
4218
4201
  identification: parseIdentification(scope.identification)
4219
4202
  })) : null,
4220
- contexts: null,
4203
+ contextTree: null,
4221
4204
  labels: { title: null }
4222
4205
  };
4223
4206
  if ("options" in elementResource && elementResource.options) {
4224
- options.contexts = parseAllOptionContexts(elementResource.options);
4207
+ options.contextTree = parseAllOptionContexts(elementResource.options);
4225
4208
  if ("notes" in elementResource.options && elementResource.options.notes) {
4226
4209
  const labelNotes = parseNotes(ensureArray(elementResource.options.notes.note));
4227
4210
  options.labels.title = labelNotes.find((note) => note.title === "Title label")?.content ?? null;
@@ -4875,7 +4858,7 @@ function parseWebsiteProperties(properties, websiteTree, sidebar) {
4875
4858
  iiifViewer: "universal-viewer"
4876
4859
  },
4877
4860
  options: {
4878
- contexts: null,
4861
+ contextTree: null,
4879
4862
  scopes: null,
4880
4863
  labels: { title: null },
4881
4864
  stylesheets: { properties: [] }
@@ -4921,7 +4904,7 @@ function parseWebsiteProperties(properties, websiteTree, sidebar) {
4921
4904
  type: scope.uuid.type,
4922
4905
  identification: parseIdentification(scope.identification)
4923
4906
  })) : null;
4924
- returnProperties.options.contexts = parseAllOptionContexts(websiteTree.options);
4907
+ returnProperties.options.contextTree = parseAllOptionContexts(websiteTree.options);
4925
4908
  if ("notes" in websiteTree.options && websiteTree.options.notes != null) {
4926
4909
  const labelNotes = parseNotes(ensureArray(websiteTree.options.notes.note));
4927
4910
  returnProperties.options.labels.title = labelNotes.find((note) => note.title === "Title label")?.content ?? null;
@@ -4931,7 +4914,7 @@ function parseWebsiteProperties(properties, websiteTree, sidebar) {
4931
4914
  return returnProperties;
4932
4915
  }
4933
4916
  function parseContextItem(contextItemToParse) {
4934
- const levelsToParse = ensureArray(contextItemToParse.levels.level);
4917
+ const levelsToParse = contextItemToParse.levels != null ? ensureArray(contextItemToParse.levels.level) : [];
4935
4918
  let type = "";
4936
4919
  return {
4937
4920
  context: levelsToParse.map((level) => {
@@ -4990,18 +4973,19 @@ function parseFilterContextDisplay(filterOption) {
4990
4973
  };
4991
4974
  }
4992
4975
  }
4993
- function parseContexts(contexts) {
4994
- const contextsParsed = [];
4995
- for (const mainContext of contexts) for (const contextItemToParse of ensureArray(mainContext.context)) contextsParsed.push(parseContextItem(contextItemToParse));
4996
- return contextsParsed;
4976
+ function parseContexts(contextLevels) {
4977
+ const contextTreeLevels = [];
4978
+ for (const contextLevel of contextLevels) for (const contextItemToParse of ensureArray(contextLevel.context)) contextTreeLevels.push(parseContextItem(contextItemToParse));
4979
+ return contextTreeLevels;
4997
4980
  }
4998
- function parseFilterContexts(contexts) {
4999
- const contextsParsed = [];
5000
- for (const mainContext of contexts) for (const contextItemToParse of ensureArray(mainContext.context)) contextsParsed.push({
4981
+ function parseFilterContexts(filterContextLevels) {
4982
+ const filterContextTreeLevels = [];
4983
+ for (const filterContextLevel of filterContextLevels) for (const contextItemToParse of ensureArray(filterContextLevel.context)) filterContextTreeLevels.push({
5001
4984
  ...parseContextItem(contextItemToParse),
4985
+ filterType: contextItemToParse.filterType,
5002
4986
  ...parseFilterContextDisplay(contextItemToParse.filterOption)
5003
4987
  });
5004
- return contextsParsed;
4988
+ return filterContextTreeLevels;
5005
4989
  }
5006
4990
  function parseWebsite(websiteTree, metadata, belongsTo, { version = 2 } = {}) {
5007
4991
  if (!websiteTree.properties) throw new Error("Website properties not found");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ochre-sdk",
3
- "version": "0.22.11",
3
+ "version": "0.22.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",
@@ -55,7 +55,7 @@
55
55
  "eslint": "^10.2.0",
56
56
  "prettier": "^3.8.3",
57
57
  "tsdown": "^0.21.9",
58
- "typescript": "^6.0.2",
58
+ "typescript": "^6.0.3",
59
59
  "vitest": "^4.1.4"
60
60
  },
61
61
  "scripts": {