ochre-sdk 1.0.2 → 1.0.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 +8 -25
- package/dist/index.mjs +40 -129
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1319,6 +1319,7 @@ type WebsiteType = "traditional" | "digital-collection" | "plum" | "cedar" | "el
|
|
|
1319
1319
|
*/
|
|
1320
1320
|
type Website<T extends LanguageCodes = LanguageCodes> = {
|
|
1321
1321
|
uuid: string;
|
|
1322
|
+
type: "website" | "segment";
|
|
1322
1323
|
belongsTo: {
|
|
1323
1324
|
uuid: string;
|
|
1324
1325
|
abbreviation: string;
|
|
@@ -1328,7 +1329,7 @@ type Website<T extends LanguageCodes = LanguageCodes> = {
|
|
|
1328
1329
|
identification: Identification<T>;
|
|
1329
1330
|
creators: Array<Person<T, "embedded">>;
|
|
1330
1331
|
license: License | null;
|
|
1331
|
-
items: Array<Webpage<T
|
|
1332
|
+
items: Array<Webpage<T>>;
|
|
1332
1333
|
properties: {
|
|
1333
1334
|
type: WebsiteType;
|
|
1334
1335
|
status: "development" | "preview" | "production";
|
|
@@ -1399,6 +1400,9 @@ type Website<T extends LanguageCodes = LanguageCodes> = {
|
|
|
1399
1400
|
};
|
|
1400
1401
|
};
|
|
1401
1402
|
};
|
|
1403
|
+
type WebsiteSegment<T extends LanguageCodes = LanguageCodes> = Website<T> & {
|
|
1404
|
+
type: "segment";
|
|
1405
|
+
};
|
|
1402
1406
|
/**
|
|
1403
1407
|
* Represents a webpage with its title, slug, properties, items and subpages
|
|
1404
1408
|
*/
|
|
@@ -1408,7 +1412,8 @@ type Webpage<T extends LanguageCodes = LanguageCodes> = {
|
|
|
1408
1412
|
title: MultilingualString<T>;
|
|
1409
1413
|
slug: string;
|
|
1410
1414
|
publicationDateTime: Date | null;
|
|
1411
|
-
items: Array<
|
|
1415
|
+
items: Array<WebElement<T> | WebBlock<T>>;
|
|
1416
|
+
segments: Array<WebsiteSegment<T>>;
|
|
1412
1417
|
properties: {
|
|
1413
1418
|
width: "full" | "large" | "narrow" | "default";
|
|
1414
1419
|
variant: "default" | "no-background";
|
|
@@ -1425,28 +1430,6 @@ type Webpage<T extends LanguageCodes = LanguageCodes> = {
|
|
|
1425
1430
|
};
|
|
1426
1431
|
webpages: Array<Webpage<T>>;
|
|
1427
1432
|
};
|
|
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
1433
|
/**
|
|
1451
1434
|
* Represents a title with its label and variant
|
|
1452
1435
|
*/
|
|
@@ -1960,4 +1943,4 @@ declare const DEFAULT_PAGE_SIZE = 48;
|
|
|
1960
1943
|
*/
|
|
1961
1944
|
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
1945
|
//#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,
|
|
1946
|
+
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
|
@@ -5885,7 +5885,11 @@ function normalizeWebsiteResources(resources) {
|
|
|
5885
5885
|
return normalized;
|
|
5886
5886
|
}
|
|
5887
5887
|
const SEGMENT_UNIQUE_SLUG_PREFIX_REGEX = /^\$[^-]*-/;
|
|
5888
|
-
|
|
5888
|
+
function prefixSlug(slug, slugPrefix) {
|
|
5889
|
+
if (slugPrefix == null || slugPrefix === "") return slug;
|
|
5890
|
+
if (slug === "") return slugPrefix;
|
|
5891
|
+
return `${slugPrefix}/${slug}`;
|
|
5892
|
+
}
|
|
5889
5893
|
function formatXMLWebsiteResourceMetadata(resource) {
|
|
5890
5894
|
const metadata = [`label “${parseStringContent(resource.identification.label)}”`, `uuid “${resource.uuid}”`];
|
|
5891
5895
|
if (resource.slug != null) metadata.push(`slug “${resource.slug}”`);
|
|
@@ -6556,43 +6560,12 @@ function parseWebElement(elementResource, options) {
|
|
|
6556
6560
|
};
|
|
6557
6561
|
}
|
|
6558
6562
|
/**
|
|
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
6563
|
* Parses raw webpage data into a standardized Webpage structure
|
|
6591
6564
|
*
|
|
6592
6565
|
* @param webpageResource - Raw webpage resource data in OCHRE format
|
|
6593
6566
|
* @returns Parsed Webpage object
|
|
6594
6567
|
*/
|
|
6595
|
-
function parseWebpage(webpageResource, options, slugPrefix) {
|
|
6568
|
+
function parseWebpage(webpageResource, options, context, slugPrefix) {
|
|
6596
6569
|
const webpageProperties = webpageResource.properties ? parseSimplifiedProperties(webpageResource.properties, options) : [];
|
|
6597
6570
|
const webpageReader = websitePresentationReader(webpageProperties);
|
|
6598
6571
|
if (webpageReader.value("presentation") !== "page") return null;
|
|
@@ -6603,9 +6576,10 @@ function parseWebpage(webpageResource, options, slugPrefix) {
|
|
|
6603
6576
|
uuid: webpageResource.uuid,
|
|
6604
6577
|
type: "page",
|
|
6605
6578
|
title: identification.label,
|
|
6606
|
-
slug:
|
|
6579
|
+
slug: prefixSlug(slug, slugPrefix),
|
|
6607
6580
|
publicationDateTime: webpageResource.publicationDateTime ?? null,
|
|
6608
6581
|
items: [],
|
|
6582
|
+
segments: [],
|
|
6609
6583
|
properties: {
|
|
6610
6584
|
width: "default",
|
|
6611
6585
|
variant: "default",
|
|
@@ -6629,11 +6603,6 @@ function parseWebpage(webpageResource, options, slugPrefix) {
|
|
|
6629
6603
|
const resourceType = websitePresentationReader(resource.properties != null ? parseSimplifiedProperties(resource.properties, options) : []).value("presentation");
|
|
6630
6604
|
if (resourceType === null) continue;
|
|
6631
6605
|
switch (resourceType) {
|
|
6632
|
-
case "segment": {
|
|
6633
|
-
const segment = parseWebSegment(resource, options);
|
|
6634
|
-
if (segment) items.push(segment);
|
|
6635
|
-
break;
|
|
6636
|
-
}
|
|
6637
6606
|
case "element": {
|
|
6638
6607
|
const element = parseWebElement(resource, options);
|
|
6639
6608
|
items.push(element);
|
|
@@ -6647,7 +6616,8 @@ function parseWebpage(webpageResource, options, slugPrefix) {
|
|
|
6647
6616
|
}
|
|
6648
6617
|
}
|
|
6649
6618
|
returnWebpage.items = items;
|
|
6650
|
-
returnWebpage.webpages =
|
|
6619
|
+
returnWebpage.webpages = parseWebpages(webpageResources, options, context, slugPrefix == null ? void 0 : returnWebpage.slug);
|
|
6620
|
+
returnWebpage.segments = parseWebsiteSegments(webpageResource.resource, context, options, returnWebpage.slug);
|
|
6651
6621
|
const pageReader = webpageReader.nestedByValue("presentation", "page");
|
|
6652
6622
|
if (pageReader.size > 0) {
|
|
6653
6623
|
returnWebpage.properties.isDisplayedInNavbar = pageReader.valueOr("displayed-in-navbar", true);
|
|
@@ -6674,86 +6644,21 @@ function parseWebpage(webpageResource, options, slugPrefix) {
|
|
|
6674
6644
|
* @param webpageResources - Array of raw webpage resources in OCHRE format
|
|
6675
6645
|
* @returns Array of parsed Webpage objects
|
|
6676
6646
|
*/
|
|
6677
|
-
function parseWebpages(webpageResources, options, slugPrefix) {
|
|
6647
|
+
function parseWebpages(webpageResources, options, context, slugPrefix) {
|
|
6678
6648
|
const returnPages = [];
|
|
6679
6649
|
for (const webpageResource of webpageResources) {
|
|
6680
|
-
const webpage = parseWebpage(webpageResource, options, slugPrefix);
|
|
6650
|
+
const webpage = parseWebpage(webpageResource, options, context, slugPrefix);
|
|
6681
6651
|
if (webpage !== null) returnPages.push(webpage);
|
|
6682
6652
|
}
|
|
6683
6653
|
return returnPages;
|
|
6684
6654
|
}
|
|
6685
|
-
|
|
6686
|
-
|
|
6687
|
-
|
|
6688
|
-
|
|
6689
|
-
|
|
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);
|
|
6655
|
+
function parseWebsiteSegments(resources, context, options, slugPrefix) {
|
|
6656
|
+
const segments = [];
|
|
6657
|
+
for (const resource of resources ?? []) {
|
|
6658
|
+
if (!("segments" in resource)) continue;
|
|
6659
|
+
for (const tree of resource.segments.tree) segments.push(parseWebsiteTree(tree, context, "segment", options, slugPrefix));
|
|
6755
6660
|
}
|
|
6756
|
-
return
|
|
6661
|
+
return segments;
|
|
6757
6662
|
}
|
|
6758
6663
|
/**
|
|
6759
6664
|
* Parses raw sidebar data into a standardized Sidebar structure
|
|
@@ -7131,6 +7036,25 @@ function parseFilterContexts(filterContextLevels, options) {
|
|
|
7131
7036
|
});
|
|
7132
7037
|
return filterContextTreeLevels;
|
|
7133
7038
|
}
|
|
7039
|
+
function parseWebsiteTree(websiteTree, context, type, options, slugPrefix) {
|
|
7040
|
+
if (!websiteTree.properties) throw new Error(`Website properties not found (website uuid “${websiteTree.uuid}”)`);
|
|
7041
|
+
if (type === "website" && websiteTree.items?.resource == null) throw new Error(`Website pages not found (website uuid “${websiteTree.uuid}”)`);
|
|
7042
|
+
const resources = normalizeWebsiteResources(websiteTree.items?.resource);
|
|
7043
|
+
const sidebar = parseSidebar(resources, options);
|
|
7044
|
+
const properties = parseWebsiteProperties(websiteTree.properties.property, websiteTree, sidebar, options);
|
|
7045
|
+
return {
|
|
7046
|
+
uuid: websiteTree.uuid,
|
|
7047
|
+
type,
|
|
7048
|
+
belongsTo: context.belongsTo,
|
|
7049
|
+
metadata: context.metadata,
|
|
7050
|
+
publicationDateTime: websiteTree.publicationDateTime ?? null,
|
|
7051
|
+
identification: parseIdentification(websiteTree.identification, options),
|
|
7052
|
+
creators: websiteTree.creators ? parsePersonList(websiteTree.creators.creator, options) : [],
|
|
7053
|
+
license: parseLicense(websiteTree.availability),
|
|
7054
|
+
items: parseWebpages(resources, options, context, slugPrefix),
|
|
7055
|
+
properties
|
|
7056
|
+
};
|
|
7057
|
+
}
|
|
7134
7058
|
function parseWebsite(data, options) {
|
|
7135
7059
|
const rawOchre = data.result.ochre;
|
|
7136
7060
|
const metadataLanguages = parseMetadataLanguages(rawOchre);
|
|
@@ -7139,26 +7063,13 @@ function parseWebsite(data, options) {
|
|
|
7139
7063
|
const defaultLanguage = resolveDefaultLanguage(rawOchre, languages);
|
|
7140
7064
|
const websiteTree = rawOchre.tree[0];
|
|
7141
7065
|
if (websiteTree == null) throw new Error("Website tree not found");
|
|
7142
|
-
|
|
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,
|
|
7066
|
+
return parseWebsiteTree(websiteTree, {
|
|
7150
7067
|
belongsTo: {
|
|
7151
7068
|
uuid: rawOchre.uuidBelongsTo,
|
|
7152
7069
|
abbreviation: rawOchre.belongsTo
|
|
7153
7070
|
},
|
|
7154
|
-
metadata: parseMetadata(rawOchre, parserOptions, defaultLanguage)
|
|
7155
|
-
|
|
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
|
-
};
|
|
7071
|
+
metadata: parseMetadata(rawOchre, parserOptions, defaultLanguage)
|
|
7072
|
+
}, "website", parserOptions);
|
|
7162
7073
|
}
|
|
7163
7074
|
//#endregion
|
|
7164
7075
|
//#region src/fetchers/website.ts
|