ochre-sdk 1.0.2 → 1.0.4

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
@@ -404,6 +404,7 @@ type ImageMapArea = {
404
404
  publicationDateTime: Date | null;
405
405
  type: string;
406
406
  title: string;
407
+ slug: string | null;
407
408
  items: Array<{
408
409
  shape: "rectangle";
409
410
  coords: [number, number, number, number];
@@ -1319,6 +1320,7 @@ type WebsiteType = "traditional" | "digital-collection" | "plum" | "cedar" | "el
1319
1320
  */
1320
1321
  type Website<T extends LanguageCodes = LanguageCodes> = {
1321
1322
  uuid: string;
1323
+ type: "website" | "segment";
1322
1324
  belongsTo: {
1323
1325
  uuid: string;
1324
1326
  abbreviation: string;
@@ -1328,7 +1330,7 @@ type Website<T extends LanguageCodes = LanguageCodes> = {
1328
1330
  identification: Identification<T>;
1329
1331
  creators: Array<Person<T, "embedded">>;
1330
1332
  license: License | null;
1331
- items: Array<Webpage<T> | WebSegment<T>>;
1333
+ items: Array<Webpage<T>>;
1332
1334
  properties: {
1333
1335
  type: WebsiteType;
1334
1336
  status: "development" | "preview" | "production";
@@ -1399,6 +1401,9 @@ type Website<T extends LanguageCodes = LanguageCodes> = {
1399
1401
  };
1400
1402
  };
1401
1403
  };
1404
+ type WebsiteSegment<T extends LanguageCodes = LanguageCodes> = Website<T> & {
1405
+ type: "segment";
1406
+ };
1402
1407
  /**
1403
1408
  * Represents a webpage with its title, slug, properties, items and subpages
1404
1409
  */
@@ -1408,7 +1413,8 @@ type Webpage<T extends LanguageCodes = LanguageCodes> = {
1408
1413
  title: MultilingualString<T>;
1409
1414
  slug: string;
1410
1415
  publicationDateTime: Date | null;
1411
- items: Array<WebSegment<T> | WebElement<T> | WebBlock<T>>;
1416
+ items: Array<WebElement<T> | WebBlock<T>>;
1417
+ segments: Array<WebsiteSegment<T>>;
1412
1418
  properties: {
1413
1419
  width: "full" | "large" | "narrow" | "default";
1414
1420
  variant: "default" | "no-background";
@@ -1425,28 +1431,6 @@ type Webpage<T extends LanguageCodes = LanguageCodes> = {
1425
1431
  };
1426
1432
  webpages: Array<Webpage<T>>;
1427
1433
  };
1428
- /**
1429
- * Represents a web segment
1430
- */
1431
- type WebSegment<T extends LanguageCodes = LanguageCodes> = {
1432
- uuid: string;
1433
- type: "segment";
1434
- title: MultilingualString<T>;
1435
- slug: string;
1436
- publicationDateTime: Date | null;
1437
- items: Array<WebSegmentItem<T>>;
1438
- };
1439
- /**
1440
- * Represents a web segment item
1441
- */
1442
- type WebSegmentItem<T extends LanguageCodes = LanguageCodes> = {
1443
- uuid: string;
1444
- type: "segment-item";
1445
- title: MultilingualString<T>;
1446
- slug: string;
1447
- publicationDateTime: Date | null;
1448
- items: Array<Webpage<T> | WebSegment<T>>;
1449
- };
1450
1434
  /**
1451
1435
  * Represents a title with its label and variant
1452
1436
  */
@@ -1960,4 +1944,4 @@ declare const DEFAULT_PAGE_SIZE = 48;
1960
1944
  */
1961
1945
  declare function flattenItemProperties<U extends ItemCategory = ItemCategory, V extends ContainedItemCategory<U> = ContainedItemCategory<U>, T extends LanguageCodes = LanguageCodes, W extends ItemPayloadKind = "topLevel">(item: Item<U, V, T, W>): FlattenedItem<Item<U, V, T, W>, T>;
1962
1946
  //#endregion
1963
- export { AccordionWebBlock, 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, ContextTree, ContextTreeFilterLevel, ContextTreeLevel, ContextTreeLevelItem, Coordinates, CoordinatesSource, DEFAULT_PAGE_SIZE, DictionaryUnitItemLink, EmbeddedBibliography, EmbeddedConcept, EmbeddedItem, EmbeddedPeriod, EmbeddedPerson, EmbeddedPropertyValue, EmbeddedPropertyVariable, EmbeddedResource, EmbeddedSet, EmbeddedSpatialUnit, EmbeddedText, EmbeddedTree, Event, Gallery, Heading, HeadingItemCategory, Identification, Image, ImageMap, ImageMapArea, Interpretation, Item, ItemCategory, ItemContainerCategory, ItemLink, ItemLinkCategory, ItemLinks, ItemPayloadKind, ItemProperty, LanguageCodes, License, Metadata, type MultilingualOptions, MultilingualString, type MultilingualStringEntries, type MultilingualStringEntry, type MultilingualStringInput, type MultilingualStringJSON, type MultilingualStringObject, type MultilingualStringText, Note, Observation, Period, PeriodItemLink, Person, PersonItemLink, Property, PropertyLike, PropertyOptions, PropertyValue, PropertyValueContent, PropertyValueDataType, PropertyValueItemLink, PropertyValueQueryItem, PropertyVariable, PropertyVariableItemLink, Query, QueryGroup, QueryLeaf, QueryablePropertyValueDataType, RecursiveItemCategory, Resource, ResourceItemLink, Scope, Section, Set, SetAttributeValueQueryItem, SetBibliography, SetConcept, SetItem, SetItemCategory, SetItemLink, SetItemProperty, SetItemSimplifiedProperty, SetItemsSort, SetItemsSortDirection, SetPeriod, SetResource, SetSpatialUnit, SetTree, SimplifiedProperty, SpatialUnit, SpatialUnitItemLink, Style, StylesheetCategory, StylesheetItem, Text, TextItemLink, TopLevelItem, Tree, TreeItemCategory, TreeItemLink, WebBlock, WebBlockByLayout, WebBlockLayout, WebElement, WebElementComponent, WebElementComponentName, WebElementComponentOf, WebElementOf, WebImage, WebSegment, WebSegmentItem, WebTitle, Webpage, Website, WebsitePropertyQuery, WebsitePropertyQueryNode, WebsiteType, defineLanguages, fetchGallery, fetchItem, fetchItemLinks, fetchSetItems, fetchSetPropertyValues, fetchWebsite, filterProperties, flattenItemProperties, getLeafPropertyValues, getPropertyByVariableLabel, getPropertyByVariableLabelAndValue, getPropertyByVariableLabelAndValueContent, getPropertyByVariableLabelAndValueContents, getPropertyByVariableLabelAndValues, getPropertyByVariableUuid, getPropertyValueByVariableLabel, getPropertyValueByVariableUuid, getPropertyValueContentByVariableLabel, getPropertyValueContentByVariableUuid, getPropertyValueContentsByVariableUuid, getPropertyValuesByVariableLabel, getPropertyValuesByVariableUuid, getUniqueProperties, getUniquePropertyVariableLabels, withLanguages };
1947
+ export { AccordionWebBlock, 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, ContextTree, ContextTreeFilterLevel, ContextTreeLevel, ContextTreeLevelItem, Coordinates, CoordinatesSource, DEFAULT_PAGE_SIZE, DictionaryUnitItemLink, EmbeddedBibliography, EmbeddedConcept, EmbeddedItem, EmbeddedPeriod, EmbeddedPerson, EmbeddedPropertyValue, EmbeddedPropertyVariable, EmbeddedResource, EmbeddedSet, EmbeddedSpatialUnit, EmbeddedText, EmbeddedTree, Event, Gallery, Heading, HeadingItemCategory, Identification, Image, ImageMap, ImageMapArea, Interpretation, Item, ItemCategory, ItemContainerCategory, ItemLink, ItemLinkCategory, ItemLinks, ItemPayloadKind, ItemProperty, LanguageCodes, License, Metadata, type MultilingualOptions, MultilingualString, type MultilingualStringEntries, type MultilingualStringEntry, type MultilingualStringInput, type MultilingualStringJSON, type MultilingualStringObject, type MultilingualStringText, Note, Observation, Period, PeriodItemLink, Person, PersonItemLink, Property, PropertyLike, PropertyOptions, PropertyValue, PropertyValueContent, PropertyValueDataType, PropertyValueItemLink, PropertyValueQueryItem, PropertyVariable, PropertyVariableItemLink, Query, QueryGroup, QueryLeaf, QueryablePropertyValueDataType, RecursiveItemCategory, Resource, ResourceItemLink, Scope, Section, Set, SetAttributeValueQueryItem, SetBibliography, SetConcept, SetItem, SetItemCategory, SetItemLink, SetItemProperty, SetItemSimplifiedProperty, SetItemsSort, SetItemsSortDirection, SetPeriod, SetResource, SetSpatialUnit, SetTree, SimplifiedProperty, SpatialUnit, SpatialUnitItemLink, Style, StylesheetCategory, StylesheetItem, Text, TextItemLink, TopLevelItem, Tree, TreeItemCategory, TreeItemLink, WebBlock, WebBlockByLayout, WebBlockLayout, WebElement, WebElementComponent, WebElementComponentName, WebElementComponentOf, WebElementOf, WebImage, WebTitle, Webpage, Website, WebsitePropertyQuery, WebsitePropertyQueryNode, WebsiteSegment, WebsiteType, defineLanguages, fetchGallery, fetchItem, fetchItemLinks, fetchSetItems, fetchSetPropertyValues, fetchWebsite, filterProperties, flattenItemProperties, getLeafPropertyValues, getPropertyByVariableLabel, getPropertyByVariableLabelAndValue, getPropertyByVariableLabelAndValueContent, getPropertyByVariableLabelAndValueContents, getPropertyByVariableLabelAndValues, getPropertyByVariableUuid, getPropertyValueByVariableLabel, getPropertyValueByVariableUuid, getPropertyValueContentByVariableLabel, getPropertyValueContentByVariableUuid, getPropertyValueContentsByVariableUuid, getPropertyValuesByVariableLabel, getPropertyValuesByVariableUuid, getUniqueProperties, getUniquePropertyVariableLabels, withLanguages };
package/dist/index.mjs CHANGED
@@ -1788,6 +1788,7 @@ function parseImageMapArea(area) {
1788
1788
  publicationDateTime: area.publicationDateTime,
1789
1789
  type: area.type,
1790
1790
  title: area.title,
1791
+ slug: area.slug ?? null,
1791
1792
  items: shape === "rectangle" ? [{
1792
1793
  shape,
1793
1794
  coords: [
@@ -2909,6 +2910,7 @@ const XMLImageMapArea = v.object({
2909
2910
  publicationDateTime: customDateTime("XMLImageMapArea: publicationDateTime is not a valid datetime"),
2910
2911
  type: v.string("XMLImageMapArea: type is string and required"),
2911
2912
  title: v.string("XMLImageMapArea: title is string and required"),
2913
+ slug: v.optional(v.string("XMLImageMapArea: slug is string and optional")),
2912
2914
  shape: v.picklist([
2913
2915
  "rect",
2914
2916
  "circle",
@@ -5885,7 +5887,11 @@ function normalizeWebsiteResources(resources) {
5885
5887
  return normalized;
5886
5888
  }
5887
5889
  const SEGMENT_UNIQUE_SLUG_PREFIX_REGEX = /^\$[^-]*-/;
5888
- const TRAILING_SLASH_REGEX = /\/$/;
5890
+ function prefixSlug(slug, slugPrefix) {
5891
+ if (slugPrefix == null || slugPrefix === "") return slug;
5892
+ if (slug === "") return slugPrefix;
5893
+ return `${slugPrefix}/${slug}`;
5894
+ }
5889
5895
  function formatXMLWebsiteResourceMetadata(resource) {
5890
5896
  const metadata = [`label “${parseStringContent(resource.identification.label)}”`, `uuid “${resource.uuid}”`];
5891
5897
  if (resource.slug != null) metadata.push(`slug “${resource.slug}”`);
@@ -6556,43 +6562,12 @@ function parseWebElement(elementResource, options) {
6556
6562
  };
6557
6563
  }
6558
6564
  /**
6559
- * Parses raw webpage resources into standardized WebElement or Webpage objects
6560
- *
6561
- * @param webpageResources - Array of raw webpage resources in OCHRE format
6562
- * @param type - Type of resource to parse ("element" or "page")
6563
- * @returns Array of parsed WebElement or Webpage objects
6564
- */
6565
- const parseWebpageResources = (webpageResources, type, options) => {
6566
- const returnElements = [];
6567
- for (const resource of webpageResources) {
6568
- if (websitePresentationReader(resource.properties ? parseSimplifiedProperties(resource.properties, options) : []).propertyByValue("presentation", type) === null) continue;
6569
- switch (type) {
6570
- case "element": {
6571
- const element = parseWebElement(resource, options);
6572
- returnElements.push(element);
6573
- break;
6574
- }
6575
- case "page": {
6576
- const webpage = parseWebpage(resource, options);
6577
- if (webpage) returnElements.push(webpage);
6578
- break;
6579
- }
6580
- case "block": {
6581
- const block = parseWebBlock(resource, options);
6582
- if (block) returnElements.push(block);
6583
- break;
6584
- }
6585
- }
6586
- }
6587
- return returnElements;
6588
- };
6589
- /**
6590
6565
  * Parses raw webpage data into a standardized Webpage structure
6591
6566
  *
6592
6567
  * @param webpageResource - Raw webpage resource data in OCHRE format
6593
6568
  * @returns Parsed Webpage object
6594
6569
  */
6595
- function parseWebpage(webpageResource, options, slugPrefix) {
6570
+ function parseWebpage(webpageResource, options, context, slugPrefix) {
6596
6571
  const webpageProperties = webpageResource.properties ? parseSimplifiedProperties(webpageResource.properties, options) : [];
6597
6572
  const webpageReader = websitePresentationReader(webpageProperties);
6598
6573
  if (webpageReader.value("presentation") !== "page") return null;
@@ -6603,9 +6578,10 @@ function parseWebpage(webpageResource, options, slugPrefix) {
6603
6578
  uuid: webpageResource.uuid,
6604
6579
  type: "page",
6605
6580
  title: identification.label,
6606
- slug: slugPrefix != null ? `${slugPrefix}/${slug}`.replace(TRAILING_SLASH_REGEX, "") : slug,
6581
+ slug: prefixSlug(slug, slugPrefix),
6607
6582
  publicationDateTime: webpageResource.publicationDateTime ?? null,
6608
6583
  items: [],
6584
+ segments: [],
6609
6585
  properties: {
6610
6586
  width: "default",
6611
6587
  variant: "default",
@@ -6629,11 +6605,6 @@ function parseWebpage(webpageResource, options, slugPrefix) {
6629
6605
  const resourceType = websitePresentationReader(resource.properties != null ? parseSimplifiedProperties(resource.properties, options) : []).value("presentation");
6630
6606
  if (resourceType === null) continue;
6631
6607
  switch (resourceType) {
6632
- case "segment": {
6633
- const segment = parseWebSegment(resource, options);
6634
- if (segment) items.push(segment);
6635
- break;
6636
- }
6637
6608
  case "element": {
6638
6609
  const element = parseWebElement(resource, options);
6639
6610
  items.push(element);
@@ -6647,7 +6618,8 @@ function parseWebpage(webpageResource, options, slugPrefix) {
6647
6618
  }
6648
6619
  }
6649
6620
  returnWebpage.items = items;
6650
- returnWebpage.webpages = webpageResource.resource != null ? parseWebpageResources(normalizeWebsiteResources(webpageResource.resource), "page", options) : [];
6621
+ returnWebpage.webpages = parseWebpages(webpageResources, options, context, slugPrefix == null ? void 0 : returnWebpage.slug);
6622
+ returnWebpage.segments = parseWebsiteSegments(webpageResource.resource, context, options, returnWebpage.slug);
6651
6623
  const pageReader = webpageReader.nestedByValue("presentation", "page");
6652
6624
  if (pageReader.size > 0) {
6653
6625
  returnWebpage.properties.isDisplayedInNavbar = pageReader.valueOr("displayed-in-navbar", true);
@@ -6674,86 +6646,25 @@ function parseWebpage(webpageResource, options, slugPrefix) {
6674
6646
  * @param webpageResources - Array of raw webpage resources in OCHRE format
6675
6647
  * @returns Array of parsed Webpage objects
6676
6648
  */
6677
- function parseWebpages(webpageResources, options, slugPrefix) {
6649
+ function parseWebpages(webpageResources, options, context, slugPrefix) {
6678
6650
  const returnPages = [];
6679
6651
  for (const webpageResource of webpageResources) {
6680
- const webpage = parseWebpage(webpageResource, options, slugPrefix);
6652
+ const webpage = parseWebpage(webpageResource, options, context, slugPrefix);
6681
6653
  if (webpage !== null) returnPages.push(webpage);
6682
6654
  }
6683
6655
  return returnPages;
6684
6656
  }
6685
- /**
6686
- * Parses raw segment resource into a standardized WebSegment object
6687
- *
6688
- * @param segmentResource - Raw segment resource in OCHRE format
6689
- * @returns Parsed WebSegment object
6690
- */
6691
- function parseWebSegment(segmentResource, options, slugPrefix) {
6692
- if (websitePresentationReader(segmentResource.properties ? parseSimplifiedProperties(segmentResource.properties, options) : []).value("presentation") !== "segment") return null;
6693
- const identification = parseIdentification(segmentResource.identification, options);
6694
- const slug = segmentResource.identification.abbreviation != null ? parseStringContent(segmentResource.identification.abbreviation, options) : null;
6695
- if (slug == null) throw new Error(`Slug not found for segment (${formatXMLWebsiteResourceMetadata(segmentResource)})`);
6696
- const returnSegment = {
6697
- uuid: segmentResource.uuid,
6698
- type: "segment",
6699
- title: identification.label,
6700
- slug,
6701
- publicationDateTime: segmentResource.publicationDateTime ?? null,
6702
- items: []
6703
- };
6704
- returnSegment.items = parseWebSegmentItems(segmentResource.resource ? normalizeWebsiteResources(segmentResource.resource) : [], options, slugPrefix != null ? `${slugPrefix}/${slug}`.replace(TRAILING_SLASH_REGEX, "") : slug);
6705
- return returnSegment;
6706
- }
6707
- /**
6708
- * Parses raw segment resources into an array of WebSegment objects
6709
- *
6710
- * @param segmentResources - Array of raw segment resources in OCHRE format
6711
- * @returns Array of parsed WebSegment objects
6712
- */
6713
- function parseSegments(segmentResources, options, slugPrefix) {
6714
- const returnSegments = [];
6715
- for (const segmentResource of segmentResources) {
6716
- const segment = parseWebSegment(segmentResource, options, slugPrefix);
6717
- if (segment !== null) returnSegments.push(segment);
6718
- }
6719
- return returnSegments;
6720
- }
6721
- /**
6722
- * Parses raw segment item into a standardized WebSegmentItem object
6723
- *
6724
- * @param segmentItemResource - Raw segment item resource in OCHRE format
6725
- * @returns Parsed WebSegmentItem object
6726
- */
6727
- function parseWebSegmentItem(segmentItemResource, options, slugPrefix) {
6728
- if (websitePresentationReader(segmentItemResource.properties ? parseSimplifiedProperties(segmentItemResource.properties, options) : []).value("presentation") !== "segment-item") return null;
6729
- const identification = parseIdentification(segmentItemResource.identification, options);
6730
- const slug = segmentItemResource.identification.abbreviation != null ? parseStringContent(segmentItemResource.identification.abbreviation, options) : null;
6731
- if (slug == null) throw new Error(`Slug not found for segment item (${formatXMLWebsiteResourceMetadata(segmentItemResource)})`);
6732
- const returnSegmentItem = {
6733
- uuid: segmentItemResource.uuid,
6734
- type: "segment-item",
6735
- title: identification.label,
6736
- slug,
6737
- publicationDateTime: segmentItemResource.publicationDateTime ?? null,
6738
- items: []
6739
- };
6740
- const resources = segmentItemResource.resource ? normalizeWebsiteResources(segmentItemResource.resource) : [];
6741
- returnSegmentItem.items.push(...parseWebpages(resources, options, slugPrefix != null ? `${slugPrefix}/${slug}`.replace(TRAILING_SLASH_REGEX, "") : slug), ...parseSegments(resources, options, slugPrefix != null ? `${slugPrefix}/${slug}`.replace(TRAILING_SLASH_REGEX, "") : slug));
6742
- return returnSegmentItem;
6743
- }
6744
- /**
6745
- * Parses raw segment items into an array of WebSegmentItem objects
6746
- *
6747
- * @param segmentItems - Array of raw segment items in OCHRE format
6748
- * @returns Array of parsed WebSegmentItem objects
6749
- */
6750
- function parseWebSegmentItems(segmentItems, options, slugPrefix) {
6751
- const returnItems = [];
6752
- for (const segmentItem of segmentItems) {
6753
- const segmentItemParsed = parseWebSegmentItem(segmentItem, options, slugPrefix);
6754
- if (segmentItemParsed !== null) returnItems.push(segmentItemParsed);
6657
+ function parseWebsiteSegments(resources, context, options, slugPrefix) {
6658
+ const segments = [];
6659
+ for (const resource of resources ?? []) {
6660
+ if (!("segments" in resource)) continue;
6661
+ for (const tree of resource.segments.tree) {
6662
+ const segmentSlug = tree.identification.abbreviation == null ? null : parseStringContent(tree.identification.abbreviation, options);
6663
+ if (segmentSlug == null) throw new Error(`Slug not found for segment website (website uuid “${tree.uuid}”)`);
6664
+ segments.push(parseWebsiteTree(tree, context, "segment", options, prefixSlug(segmentSlug, slugPrefix)));
6665
+ }
6755
6666
  }
6756
- return returnItems;
6667
+ return segments;
6757
6668
  }
6758
6669
  /**
6759
6670
  * Parses raw sidebar data into a standardized Sidebar structure
@@ -7131,6 +7042,25 @@ function parseFilterContexts(filterContextLevels, options) {
7131
7042
  });
7132
7043
  return filterContextTreeLevels;
7133
7044
  }
7045
+ function parseWebsiteTree(websiteTree, context, type, options, slugPrefix) {
7046
+ if (!websiteTree.properties) throw new Error(`Website properties not found (website uuid “${websiteTree.uuid}”)`);
7047
+ if (type === "website" && websiteTree.items?.resource == null) throw new Error(`Website pages not found (website uuid “${websiteTree.uuid}”)`);
7048
+ const resources = normalizeWebsiteResources(websiteTree.items?.resource);
7049
+ const sidebar = parseSidebar(resources, options);
7050
+ const properties = parseWebsiteProperties(websiteTree.properties.property, websiteTree, sidebar, options);
7051
+ return {
7052
+ uuid: websiteTree.uuid,
7053
+ type,
7054
+ belongsTo: context.belongsTo,
7055
+ metadata: context.metadata,
7056
+ publicationDateTime: websiteTree.publicationDateTime ?? null,
7057
+ identification: parseIdentification(websiteTree.identification, options),
7058
+ creators: websiteTree.creators ? parsePersonList(websiteTree.creators.creator, options) : [],
7059
+ license: parseLicense(websiteTree.availability),
7060
+ items: parseWebpages(resources, options, context, slugPrefix),
7061
+ properties
7062
+ };
7063
+ }
7134
7064
  function parseWebsite(data, options) {
7135
7065
  const rawOchre = data.result.ochre;
7136
7066
  const metadataLanguages = parseMetadataLanguages(rawOchre);
@@ -7139,26 +7069,13 @@ function parseWebsite(data, options) {
7139
7069
  const defaultLanguage = resolveDefaultLanguage(rawOchre, languages);
7140
7070
  const websiteTree = rawOchre.tree[0];
7141
7071
  if (websiteTree == null) throw new Error("Website tree not found");
7142
- if (!websiteTree.properties) throw new Error(`Website properties not found (website uuid “${websiteTree.uuid}”)`);
7143
- if (websiteTree.items?.resource == null) throw new Error(`Website pages not found (website uuid “${websiteTree.uuid}”)`);
7144
- const resources = normalizeWebsiteResources(websiteTree.items.resource);
7145
- const items = [...parseWebpages(resources, parserOptions), ...parseSegments(resources, parserOptions)];
7146
- const sidebar = parseSidebar(resources, parserOptions);
7147
- const properties = parseWebsiteProperties(websiteTree.properties.property, websiteTree, sidebar, parserOptions);
7148
- return {
7149
- uuid: websiteTree.uuid,
7072
+ return parseWebsiteTree(websiteTree, {
7150
7073
  belongsTo: {
7151
7074
  uuid: rawOchre.uuidBelongsTo,
7152
7075
  abbreviation: rawOchre.belongsTo
7153
7076
  },
7154
- metadata: parseMetadata(rawOchre, parserOptions, defaultLanguage),
7155
- publicationDateTime: websiteTree.publicationDateTime ?? null,
7156
- identification: parseIdentification(websiteTree.identification, parserOptions),
7157
- creators: websiteTree.creators ? parsePersonList(websiteTree.creators.creator, parserOptions) : [],
7158
- license: parseLicense(websiteTree.availability),
7159
- items,
7160
- properties
7161
- };
7077
+ metadata: parseMetadata(rawOchre, parserOptions, defaultLanguage)
7078
+ }, "website", parserOptions);
7162
7079
  }
7163
7080
  //#endregion
7164
7081
  //#region src/fetchers/website.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ochre-sdk",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
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",