ochre-sdk 1.0.75 → 1.0.76

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
@@ -1,5 +1,5 @@
1
1
  import { MultilingualOptions, MultilingualString, MultilingualStringEntries, MultilingualStringEntry, MultilingualStringInput, MultilingualStringJSON, MultilingualStringObject, MultilingualStringText } from "./parsers/multilingual.mjs";
2
- import { AccordionWebBlock, ContextTree, ContextTreeFilterLevel, ContextTreeLevel, ContextTreeLevelItem, ProtectedWebsite, Scope, Style, StylesheetCategory, StylesheetItem, WebAccordionItem, WebBlock, WebBlockByLayout, WebBlockItem, WebBlockLayout, WebElement, WebElementComponent, WebElementComponentName, WebElementComponentOf, WebElementOf, WebImage, WebSidebar, WebTitle, Webpage, Website, WebsiteMetadata, WebsitePropertyQuery, WebsitePropertyQueryNode, WebsiteSegment, WebsiteType } from "./types/website.mjs";
2
+ import { AccordionWebBlock, ContextTree, ContextTreeFilterLevel, ContextTreeFilterVariant, ContextTreeLevel, ContextTreeLevelItem, ProtectedWebsite, Scope, Style, StylesheetCategory, StylesheetItem, WebAccordionItem, WebBlock, WebBlockByLayout, WebBlockItem, WebBlockLayout, WebElement, WebElementComponent, WebElementComponentName, WebElementComponentOf, WebElementOf, WebImage, WebOptions, WebSidebar, WebTitle, Webpage, Website, WebsiteMetadata, WebsitePropertyQuery, WebsitePropertyQueryNode, WebsiteSegment, WebsiteType } from "./types/website.mjs";
3
3
  import { AnyBibliography, AnyConcept, AnyItem, AnyPeriod, AnyPerson, AnyPropertyValue, AnyPropertyVariable, AnyResource, AnySet, AnySpatialUnit, AnyText, AnyTree, BaseItem, BaseItemLink, BelongsTo, Bibliography, BibliographyEntryInfo, BibliographyItemLink, BibliographySourceDocument, Concept, ConceptItemLink, ContainedItemCategory, ContainedItemCategoryFromOption, ContainedItemCategoryOption, Context, ContextItem, ContextItemCategory, ContextNode, Coordinates, CoordinatesSource, DictionaryUnitItemLink, EmbeddedBibliography, EmbeddedConcept, EmbeddedItem, EmbeddedPeriod, EmbeddedPerson, EmbeddedPropertyValue, EmbeddedPropertyVariable, EmbeddedResource, EmbeddedSet, EmbeddedSpatialUnit, EmbeddedText, EmbeddedTree, Event, Gallery, Heading, HeadingItemCategory, Identification, Image, ImageMap, ImageMapArea, Interpretation, Item, ItemCategory, ItemCategoryFromOption, ItemCategoryOption, ItemCategoryWithEmbeddedItems, ItemContainerCategory, ItemLink, ItemLinkCategory, ItemLinks, ItemPayloadKind, ItemProperty, ItemWithoutEmbeddedItems, LanguageCodes, License, Metadata, Note, Observation, OcrString, Period, PeriodItemLink, Person, PersonItemLink, Prettify, Property, PropertyLike, PropertyRelation, PropertyValue, PropertyValueContent, PropertyValueDataType, PropertyValueItemLink, PropertyValueQueryItem, PropertyVariable, PropertyVariableItemLink, Query, QueryGroup, QueryLeaf, QueryablePropertyValueDataType, RecursiveItemCategory, Resource, ResourceItemLink, Section, Set, SetAttributeValueQueryItem, SetBibliography, SetConcept, SetItem, SetItemCategory, SetItemLink, SetItemProperty, SetItemSimplifiedProperty, SetItemsSort, SetItemsSortDirection, SetPeriod, SetResource, SetSpatialUnit, SetTree, SimplifiedProperty, SpatialUnit, SpatialUnitItemLink, Text, TextItemLink, TopLevelItem, Tree, TreeItemCategory, TreeItemLink } from "./types/index.mjs";
4
4
  import { fetchGallery } from "./fetchers/gallery.mjs";
5
5
  import { fetchItemChildren } from "./fetchers/item-children.mjs";
@@ -12,4 +12,4 @@ import { fetchWebsiteMetadata } from "./fetchers/website-metadata.mjs";
12
12
  import { fetchWebsite } from "./fetchers/website.mjs";
13
13
  import { PropertyOptions, filterProperties, getLeafPropertyValues, getPropertyByVariableLabel, getPropertyByVariableLabelAndValue, getPropertyByVariableLabelAndValueContent, getPropertyByVariableLabelAndValueContents, getPropertyByVariableLabelAndValues, getPropertyByVariableUuid, getPropertyValueByVariableLabel, getPropertyValueByVariableUuid, getPropertyValueContentByVariableLabel, getPropertyValueContentByVariableUuid, getPropertyValueContentsByVariableUuid, getPropertyValuesByVariableLabel, getPropertyValuesByVariableUuid, getUniqueProperties, getUniquePropertyVariableLabels } from "./getters.mjs";
14
14
  import { DEFAULT_PAGE_SIZE, flattenItemProperties } from "./helpers.mjs";
15
- export { type AccordionWebBlock, type AnyBibliography, type AnyConcept, type AnyItem, type AnyPeriod, type AnyPerson, type AnyPropertyValue, type AnyPropertyVariable, type AnyResource, type AnySet, type AnySpatialUnit, type AnyText, type AnyTree, type BaseItem, type BaseItemLink, type BelongsTo, type Bibliography, type BibliographyEntryInfo, type BibliographyItemLink, type BibliographySourceDocument, type Concept, type ConceptItemLink, type ContainedItemCategory, type ContainedItemCategoryFromOption, type ContainedItemCategoryOption, type Context, type ContextItem, type ContextItemCategory, type ContextNode, type ContextTree, type ContextTreeFilterLevel, type ContextTreeLevel, type ContextTreeLevelItem, type Coordinates, type CoordinatesSource, DEFAULT_PAGE_SIZE, type DictionaryUnitItemLink, type EmbeddedBibliography, type EmbeddedConcept, type EmbeddedItem, type EmbeddedPeriod, type EmbeddedPerson, type EmbeddedPropertyValue, type EmbeddedPropertyVariable, type EmbeddedResource, type EmbeddedSet, type EmbeddedSpatialUnit, type EmbeddedText, type EmbeddedTree, type Event, type Gallery, type Heading, type HeadingItemCategory, type Identification, type Image, type ImageMap, type ImageMapArea, type Interpretation, type Item, type ItemCategory, type ItemCategoryFromOption, type ItemCategoryOption, type ItemCategoryWithEmbeddedItems, type ItemContainerCategory, type ItemLink, type ItemLinkCategory, type ItemLinks, type ItemPayloadKind, type ItemProperty, type ItemWithoutEmbeddedItems, type LanguageCodes, type License, type Metadata, type MultilingualOptions, MultilingualString, type MultilingualStringEntries, type MultilingualStringEntry, type MultilingualStringInput, type MultilingualStringJSON, type MultilingualStringObject, type MultilingualStringText, type Note, type Observation, type OcrString, type Period, type PeriodItemLink, type Person, type PersonItemLink, type Prettify, type Property, type PropertyLike, PropertyOptions, type PropertyRelation, type PropertyValue, type PropertyValueContent, type PropertyValueDataType, type PropertyValueItemLink, type PropertyValueQueryItem, type PropertyVariable, type PropertyVariableItemLink, type ProtectedWebsite, type Query, type QueryGroup, type QueryLeaf, type QueryablePropertyValueDataType, type RecursiveItemCategory, type Resource, type ResourceItemLink, type Scope, type Section, type Set, type SetAttributeValueQueryItem, type SetBibliography, type SetConcept, type SetItem, type SetItemCategory, type SetItemLink, type SetItemProperty, type SetItemSimplifiedProperty, type SetItemsSort, type SetItemsSortDirection, type SetPeriod, type SetResource, type SetSpatialUnit, type SetTree, type SimplifiedProperty, type SpatialUnit, type SpatialUnitItemLink, type Style, type StylesheetCategory, type StylesheetItem, type Text, type TextItemLink, type TopLevelItem, type Tree, type TreeItemCategory, type TreeItemLink, type WebAccordionItem, type WebBlock, type WebBlockByLayout, type WebBlockItem, type WebBlockLayout, type WebElement, type WebElementComponent, type WebElementComponentName, type WebElementComponentOf, type WebElementOf, type WebImage, type WebSidebar, type WebTitle, type Webpage, type Website, type WebsiteMetadata, type WebsitePropertyQuery, type WebsitePropertyQueryNode, type WebsiteSegment, type WebsiteType, defineLanguages, fetchGallery, fetchItem, fetchItemChildren, fetchItemLinks, fetchItemOcrData, fetchSetItems, fetchSetPropertyValues, fetchWebsite, fetchWebsiteMetadata, filterProperties, flattenItemProperties, getLeafPropertyValues, getPropertyByVariableLabel, getPropertyByVariableLabelAndValue, getPropertyByVariableLabelAndValueContent, getPropertyByVariableLabelAndValueContents, getPropertyByVariableLabelAndValues, getPropertyByVariableUuid, getPropertyValueByVariableLabel, getPropertyValueByVariableUuid, getPropertyValueContentByVariableLabel, getPropertyValueContentByVariableUuid, getPropertyValueContentsByVariableUuid, getPropertyValuesByVariableLabel, getPropertyValuesByVariableUuid, getUniqueProperties, getUniquePropertyVariableLabels, withLanguages };
15
+ export { type AccordionWebBlock, type AnyBibliography, type AnyConcept, type AnyItem, type AnyPeriod, type AnyPerson, type AnyPropertyValue, type AnyPropertyVariable, type AnyResource, type AnySet, type AnySpatialUnit, type AnyText, type AnyTree, type BaseItem, type BaseItemLink, type BelongsTo, type Bibliography, type BibliographyEntryInfo, type BibliographyItemLink, type BibliographySourceDocument, type Concept, type ConceptItemLink, type ContainedItemCategory, type ContainedItemCategoryFromOption, type ContainedItemCategoryOption, type Context, type ContextItem, type ContextItemCategory, type ContextNode, type ContextTree, type ContextTreeFilterLevel, type ContextTreeFilterVariant, type ContextTreeLevel, type ContextTreeLevelItem, type Coordinates, type CoordinatesSource, DEFAULT_PAGE_SIZE, type DictionaryUnitItemLink, type EmbeddedBibliography, type EmbeddedConcept, type EmbeddedItem, type EmbeddedPeriod, type EmbeddedPerson, type EmbeddedPropertyValue, type EmbeddedPropertyVariable, type EmbeddedResource, type EmbeddedSet, type EmbeddedSpatialUnit, type EmbeddedText, type EmbeddedTree, type Event, type Gallery, type Heading, type HeadingItemCategory, type Identification, type Image, type ImageMap, type ImageMapArea, type Interpretation, type Item, type ItemCategory, type ItemCategoryFromOption, type ItemCategoryOption, type ItemCategoryWithEmbeddedItems, type ItemContainerCategory, type ItemLink, type ItemLinkCategory, type ItemLinks, type ItemPayloadKind, type ItemProperty, type ItemWithoutEmbeddedItems, type LanguageCodes, type License, type Metadata, type MultilingualOptions, MultilingualString, type MultilingualStringEntries, type MultilingualStringEntry, type MultilingualStringInput, type MultilingualStringJSON, type MultilingualStringObject, type MultilingualStringText, type Note, type Observation, type OcrString, type Period, type PeriodItemLink, type Person, type PersonItemLink, type Prettify, type Property, type PropertyLike, PropertyOptions, type PropertyRelation, type PropertyValue, type PropertyValueContent, type PropertyValueDataType, type PropertyValueItemLink, type PropertyValueQueryItem, type PropertyVariable, type PropertyVariableItemLink, type ProtectedWebsite, type Query, type QueryGroup, type QueryLeaf, type QueryablePropertyValueDataType, type RecursiveItemCategory, type Resource, type ResourceItemLink, type Scope, type Section, type Set, type SetAttributeValueQueryItem, type SetBibliography, type SetConcept, type SetItem, type SetItemCategory, type SetItemLink, type SetItemProperty, type SetItemSimplifiedProperty, type SetItemsSort, type SetItemsSortDirection, type SetPeriod, type SetResource, type SetSpatialUnit, type SetTree, type SimplifiedProperty, type SpatialUnit, type SpatialUnitItemLink, type Style, type StylesheetCategory, type StylesheetItem, type Text, type TextItemLink, type TopLevelItem, type Tree, type TreeItemCategory, type TreeItemLink, type WebAccordionItem, type WebBlock, type WebBlockByLayout, type WebBlockItem, type WebBlockLayout, type WebElement, type WebElementComponent, type WebElementComponentName, type WebElementComponentOf, type WebElementOf, type WebImage, type WebOptions, type WebSidebar, type WebTitle, type Webpage, type Website, type WebsiteMetadata, type WebsitePropertyQuery, type WebsitePropertyQueryNode, type WebsiteSegment, type WebsiteType, defineLanguages, fetchGallery, fetchItem, fetchItemChildren, fetchItemLinks, fetchItemOcrData, fetchSetItems, fetchSetPropertyValues, fetchWebsite, fetchWebsiteMetadata, filterProperties, flattenItemProperties, getLeafPropertyValues, getPropertyByVariableLabel, getPropertyByVariableLabelAndValue, getPropertyByVariableLabelAndValueContent, getPropertyByVariableLabelAndValueContents, getPropertyByVariableLabelAndValues, getPropertyByVariableUuid, getPropertyValueByVariableLabel, getPropertyValueByVariableUuid, getPropertyValueContentByVariableLabel, getPropertyValueContentByVariableUuid, getPropertyValueContentsByVariableUuid, getPropertyValuesByVariableLabel, getPropertyValuesByVariableUuid, getUniqueProperties, getUniquePropertyVariableLabels, withLanguages };
@@ -351,7 +351,8 @@ function parseWebElementProperties(componentProperty, elementResource, options,
351
351
  properties = {
352
352
  component: "advanced-search",
353
353
  boundElementUuid: boundElementPropertyUuid,
354
- href
354
+ href,
355
+ options: parseWebsiteOptions(elementResource.options, options)
355
356
  };
356
357
  break;
357
358
  }
@@ -1363,6 +1364,7 @@ function parseFilterContexts(filterContextLevels, options) {
1363
1364
  for (const filterContextLevel of filterContextLevels) for (const contextItemToParse of filterContextLevel.context) filterContextTreeLevels.push({
1364
1365
  ...parseContextItem(contextItemToParse, options),
1365
1366
  filterType: contextItemToParse.filterType ?? "property",
1367
+ filterVariant: contextItemToParse.filterVariant ?? null,
1366
1368
  ...parseFilterContextDisplay(contextItemToParse.filterOption)
1367
1369
  });
1368
1370
  return filterContextTreeLevels;
@@ -16,6 +16,10 @@ type ContextTreeLevel<T extends LanguageCodes = LanguageCodes> = {
16
16
  identification: Identification<T>;
17
17
  type: string;
18
18
  };
19
+ /**
20
+ * Represents the input control a filter context level is rendered with
21
+ */
22
+ type ContextTreeFilterVariant = "checkbox" | "chip" | "range" | "tile" | "toggle";
19
23
  /**
20
24
  * Represents a filter context tree level with a context item
21
25
  */
@@ -24,6 +28,7 @@ type ContextTreeFilterLevel<T extends LanguageCodes = LanguageCodes> = {
24
28
  identification: Identification<T>;
25
29
  type: string;
26
30
  filterType: "property" | "coordinates" | "bibliography" | "period";
31
+ filterVariant: ContextTreeFilterVariant | null;
27
32
  isInlineDisplayed: boolean;
28
33
  isSidebarDisplayed: boolean;
29
34
  isSidebarOpen: boolean;
@@ -49,6 +54,17 @@ type Scope<T extends LanguageCodes = LanguageCodes> = {
49
54
  type: string;
50
55
  identification: Identification<T>;
51
56
  };
57
+ /**
58
+ * Represents the parsed OCHRE "options" block shared by the website itself and
59
+ * by every web element component that supports it
60
+ */
61
+ type WebOptions<T extends LanguageCodes = LanguageCodes> = {
62
+ scopes: Array<Scope<T>> | null;
63
+ contextTree: ContextTree<T> | null;
64
+ labels: {
65
+ title: MultilingualString<T> | null;
66
+ };
67
+ };
52
68
  /**
53
69
  * Represents a stylesheet item with its UUID and category
54
70
  */
@@ -188,16 +204,11 @@ type Website<T extends LanguageCodes = LanguageCodes> = {
188
204
  isPersistentIdentifierDisplayed: boolean;
189
205
  iiifViewer: "universal-viewer" | "clover";
190
206
  };
191
- options: {
192
- contextTree: ContextTree<T> | null;
193
- scopes: Array<Scope<T>> | null;
194
- labels: {
195
- title: MultilingualString<T> | null;
196
- };
207
+ options: Prettify<WebOptions<T> & {
197
208
  stylesheets: {
198
209
  properties: Array<StylesheetItem>;
199
210
  };
200
- };
211
+ }>;
201
212
  };
202
213
  };
203
214
  type WebsiteSegment<T extends LanguageCodes = LanguageCodes> = Website<T> & {
@@ -285,6 +296,7 @@ type WebElementComponent<T extends LanguageCodes = LanguageCodes> = {
285
296
  component: "advanced-search";
286
297
  boundElementUuid: string | null;
287
298
  href: string | null;
299
+ options: WebOptions<T>;
288
300
  } | {
289
301
  component: "annotated-document";
290
302
  linkUuid: string;
@@ -353,13 +365,7 @@ type WebElementComponent<T extends LanguageCodes = LanguageCodes> = {
353
365
  isLimitedToLeafPropertyValues: boolean;
354
366
  sidebarSort: "default" | "alphabetical";
355
367
  };
356
- options: {
357
- scopes: Array<Scope<T>> | null;
358
- contextTree: ContextTree<T> | null;
359
- labels: {
360
- title: MultilingualString<T> | null;
361
- };
362
- };
368
+ options: WebOptions<T>;
363
369
  } | {
364
370
  component: "empty-space";
365
371
  height: string | null;
@@ -418,13 +424,7 @@ type WebElementComponent<T extends LanguageCodes = LanguageCodes> = {
418
424
  startIcon: string | null;
419
425
  endIcon: string | null;
420
426
  }>;
421
- options: {
422
- scopes: Array<Scope<T>> | null;
423
- contextTree: ContextTree<T> | null;
424
- labels: {
425
- title: MultilingualString<T> | null;
426
- };
427
- };
427
+ options: WebOptions<T>;
428
428
  collectionProperties: Prettify<Partial<Omit<Extract<WebElementComponent<T>, {
429
429
  component: "collection";
430
430
  }>, "component" | "linkUuids" | "options" | "image"> & {
@@ -563,4 +563,4 @@ type ProtectedWebsite<T extends LanguageCodes = LanguageCodes> = {
563
563
  };
564
564
  };
565
565
  //#endregion
566
- export { AccordionWebBlock, ContextTree, ContextTreeFilterLevel, ContextTreeLevel, ContextTreeLevelItem, ProtectedWebsite, Scope, Style, StylesheetCategory, StylesheetItem, WebAccordionItem, WebBlock, WebBlockByLayout, WebBlockItem, WebBlockLayout, WebElement, WebElementComponent, WebElementComponentName, WebElementComponentOf, WebElementOf, WebImage, WebSidebar, WebTitle, Webpage, Website, WebsiteMetadata, WebsitePropertyQuery, WebsitePropertyQueryNode, WebsiteSegment, WebsiteType };
566
+ export { AccordionWebBlock, ContextTree, ContextTreeFilterLevel, ContextTreeFilterVariant, ContextTreeLevel, ContextTreeLevelItem, ProtectedWebsite, Scope, Style, StylesheetCategory, StylesheetItem, WebAccordionItem, WebBlock, WebBlockByLayout, WebBlockItem, WebBlockLayout, WebElement, WebElementComponent, WebElementComponentName, WebElementComponentOf, WebElementOf, WebImage, WebOptions, WebSidebar, WebTitle, Webpage, Website, WebsiteMetadata, WebsitePropertyQuery, WebsitePropertyQueryNode, WebsiteSegment, WebsiteType };
@@ -737,7 +737,14 @@ const XMLWebsiteFilterContextItem = v.object({
737
737
  "sidebar-displayed-closed",
738
738
  "sidebar-displayed-open",
739
739
  "inline-sidebar-hidden"
740
- ], "XMLWebsiteFilterContextItem: filterOption is invalid"))
740
+ ], "XMLWebsiteFilterContextItem: filterOption is invalid")),
741
+ filterVariant: v.optional(v.picklist([
742
+ "checkbox",
743
+ "chip",
744
+ "range",
745
+ "tile",
746
+ "toggle"
747
+ ], "XMLWebsiteFilterContextItem: filterVariant is invalid"))
741
748
  }, "XMLWebsiteFilterContextItem: Shape error");
742
749
  const XMLWebsiteContext = v.object({ context: v.array(XMLWebsiteContextItem) }, "XMLWebsiteContext: Shape error");
743
750
  const XMLWebsiteFilterContext = v.object({ context: v.array(XMLWebsiteFilterContextItem) }, "XMLWebsiteFilterContext: Shape error");
@@ -690,6 +690,7 @@ type XMLWebsiteContextItem = {
690
690
  type XMLWebsiteFilterContextItem = XMLWebsiteContextItem & {
691
691
  filterType?: "property" | "coordinates" | "bibliography" | "period";
692
692
  filterOption?: "inline-displayed" | "inline-sidebar-displayed-closed" | "inline-sidebar-displayed-open" | "sidebar-displayed-closed" | "sidebar-displayed-open" | "inline-sidebar-hidden";
693
+ filterVariant?: "checkbox" | "chip" | "range" | "tile" | "toggle";
693
694
  };
694
695
  type XMLWebsiteContext = {
695
696
  context: Array<XMLWebsiteContextItem>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ochre-sdk",
3
- "version": "1.0.75",
3
+ "version": "1.0.76",
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",
@@ -47,17 +47,17 @@
47
47
  "dependencies": {
48
48
  "date-fns": "^4.4.0",
49
49
  "fast-equals": "^6.0.2",
50
- "fast-xml-parser": "^5.10.1",
50
+ "fast-xml-parser": "^5.11.0",
51
51
  "valibot": "^1.4.2"
52
52
  },
53
53
  "devDependencies": {
54
54
  "@antfu/eslint-config": "^9.3.0",
55
55
  "@types/node": "^24.13.3",
56
- "bumpp": "^12.2.0",
57
- "eslint": "^10.8.0",
56
+ "bumpp": "^12.2.1",
57
+ "eslint": "^10.8.1",
58
58
  "eslint-plugin-erasable-syntax-only": "^0.4.2",
59
- "knip": "^6.32.0",
60
- "oxfmt": "^0.62.0",
59
+ "knip": "^6.32.2",
60
+ "oxfmt": "^0.63.0",
61
61
  "tsdown": "^0.22.14",
62
62
  "typescript": "^6.0.3",
63
63
  "vitest": "^4.1.10"