ochre-sdk 1.3.26 → 1.3.27
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/fetchers/item.d.mts +9 -4
- package/dist/fetchers/item.mjs +1 -1
- package/dist/parsers/website/components.d.mts +2 -6
- package/dist/parsers/website/components.mjs +10 -5
- package/dist/parsers/website/index.d.mts +1 -1
- package/dist/parsers/website/index.mjs +7 -6
- package/dist/parsers/website/properties.d.mts +3 -3
- package/dist/parsers/website/properties.mjs +19 -10
- package/dist/parsers/website/reader.d.mts +1 -2
- package/dist/parsers/website/reader.mjs +6 -9
- package/dist/types/website.d.mts +11 -4
- package/package.json +1 -1
package/dist/fetchers/item.d.mts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { FetchBaseOptions, FetchLanguages } from "../parsers/helpers.mjs";
|
|
2
2
|
import { ContainedItemCategoryFromOption, ContainedItemCategoryOption, Item, ItemCategory, ItemCategoryFromOption, ItemCategoryOption, ItemCategoryWithEmbeddedItems, ItemContainerCategory, ItemWithoutEmbeddedItems } from "../types/index.mjs";
|
|
3
|
+
import { Website } from "../types/website.mjs";
|
|
4
|
+
type FetchItemOptions<TLanguages extends ReadonlyArray<string> | undefined> = FetchBaseOptions<TLanguages> & {
|
|
5
|
+
website?: Pick<Website, "properties"> | null;
|
|
6
|
+
};
|
|
3
7
|
type FetchItemResult<TItem> = Promise<{
|
|
4
8
|
item: TItem;
|
|
5
9
|
error: null;
|
|
@@ -19,26 +23,27 @@ single category when it is known, or an array when the item may be any
|
|
|
19
23
|
category in that list.
|
|
20
24
|
@param options.containedItemCategory - The category of items inside the OCHRE item to fetch. Only valid for Trees and Sets. Tree accepts one category; Set accepts one category or an array.
|
|
21
25
|
@param options.shouldOmitEmbeddedItems - Whether to omit the embedded item hierarchy when fetching a recursive item category. Ignored when the fetched item does not expose recursive embedded items.
|
|
26
|
+
@param options.website - The website the item is shown in, whose page and component settings a resource's view starts from, as the website's own pages do
|
|
22
27
|
@param options.languages - Language codes to parse. Inline arrays preserve literal types automatically.
|
|
23
28
|
@param options.fetch - Custom fetch function to use instead of the default fetch
|
|
24
29
|
@returns An object containing the parsed item
|
|
25
30
|
*/
|
|
26
|
-
export declare function fetchItem<const TContainedItemCategory extends ContainedItemCategoryOption<ItemContainerCategory> | undefined = undefined, const TLanguages extends ReadonlyArray<string> | undefined = undefined>(uuid: string, options?:
|
|
31
|
+
export declare function fetchItem<const TContainedItemCategory extends ContainedItemCategoryOption<ItemContainerCategory> | undefined = undefined, const TLanguages extends ReadonlyArray<string> | undefined = undefined>(uuid: string, options?: FetchItemOptions<TLanguages> & {
|
|
27
32
|
category?: undefined;
|
|
28
33
|
containedItemCategory?: TContainedItemCategory;
|
|
29
34
|
shouldOmitEmbeddedItems?: false;
|
|
30
35
|
}): FetchItemResult<Item<ItemCategory, ContainedItemCategoryFromOption<ItemCategory, TContainedItemCategory>, FetchLanguages<TLanguages>>>;
|
|
31
|
-
export declare function fetchItem<const TContainedItemCategory extends ContainedItemCategoryOption<ItemContainerCategory> | undefined = undefined, const TLanguages extends ReadonlyArray<string> | undefined = undefined>(uuid: string, options:
|
|
36
|
+
export declare function fetchItem<const TContainedItemCategory extends ContainedItemCategoryOption<ItemContainerCategory> | undefined = undefined, const TLanguages extends ReadonlyArray<string> | undefined = undefined>(uuid: string, options: FetchItemOptions<TLanguages> & {
|
|
32
37
|
category?: undefined;
|
|
33
38
|
containedItemCategory?: TContainedItemCategory;
|
|
34
39
|
shouldOmitEmbeddedItems?: true;
|
|
35
40
|
}): FetchItemResult<ItemWithoutEmbeddedItems<ItemCategoryWithEmbeddedItems, ContainedItemCategoryFromOption<ItemContainerCategory, TContainedItemCategory>, FetchLanguages<TLanguages>> | Item<Exclude<ItemCategory, ItemCategoryWithEmbeddedItems>, never, FetchLanguages<TLanguages>>>;
|
|
36
|
-
export declare function fetchItem<const TCategory extends ItemCategoryOption, const TContainedItemCategory extends ContainedItemCategoryOption<ItemCategoryFromOption<TCategory>> | undefined = undefined, const TLanguages extends ReadonlyArray<string> | undefined = undefined>(uuid: string, options:
|
|
41
|
+
export declare function fetchItem<const TCategory extends ItemCategoryOption, const TContainedItemCategory extends ContainedItemCategoryOption<ItemCategoryFromOption<TCategory>> | undefined = undefined, const TLanguages extends ReadonlyArray<string> | undefined = undefined>(uuid: string, options: FetchItemOptions<TLanguages> & {
|
|
37
42
|
category: TCategory;
|
|
38
43
|
containedItemCategory?: TContainedItemCategory;
|
|
39
44
|
shouldOmitEmbeddedItems?: false;
|
|
40
45
|
}): FetchItemResult<Item<ItemCategoryFromOption<TCategory>, ContainedItemCategoryFromOption<ItemCategoryFromOption<TCategory>, TContainedItemCategory>, FetchLanguages<TLanguages>>>;
|
|
41
|
-
export declare function fetchItem<const TCategory extends ItemCategoryOption, const TContainedItemCategory extends ContainedItemCategoryOption<Extract<ItemCategoryFromOption<TCategory>, ItemCategoryWithEmbeddedItems>> | undefined = undefined, const TLanguages extends ReadonlyArray<string> | undefined = undefined>(uuid: string, options:
|
|
46
|
+
export declare function fetchItem<const TCategory extends ItemCategoryOption, const TContainedItemCategory extends ContainedItemCategoryOption<Extract<ItemCategoryFromOption<TCategory>, ItemCategoryWithEmbeddedItems>> | undefined = undefined, const TLanguages extends ReadonlyArray<string> | undefined = undefined>(uuid: string, options: FetchItemOptions<TLanguages> & {
|
|
42
47
|
category: TCategory;
|
|
43
48
|
containedItemCategory?: TContainedItemCategory;
|
|
44
49
|
shouldOmitEmbeddedItems: true;
|
package/dist/fetchers/item.mjs
CHANGED
|
@@ -85,7 +85,7 @@ async function fetchItem(uuid, options) {
|
|
|
85
85
|
category: options?.category,
|
|
86
86
|
containedItemCategory: options?.containedItemCategory,
|
|
87
87
|
languages,
|
|
88
|
-
parseResourceView: (view, context) => parseWebpageView(view, { languages: context.metadata.languages }, context)
|
|
88
|
+
parseResourceView: (view, context) => parseWebpageView(view, { languages: context.metadata.languages }, context, options?.website ?? null)
|
|
89
89
|
});
|
|
90
90
|
assertItemCategoryAllowed(parsedItem.category, options?.containedItemCategory);
|
|
91
91
|
return {
|
|
@@ -2,13 +2,9 @@ import { ParserOptions } from "../helpers.mjs";
|
|
|
2
2
|
import { WebsitePresentationReader } from "./reader.mjs";
|
|
3
3
|
import { WebsitePageSlugs } from "./slug.mjs";
|
|
4
4
|
import { Identification, ItemLinks, SimplifiedProperty } from "../../types/index.mjs";
|
|
5
|
-
import { WebElement, WebElementComponent, WebTitle } from "../../types/website.mjs";
|
|
5
|
+
import { WebElement, WebElementComponent, WebTitle, Website } from "../../types/website.mjs";
|
|
6
6
|
import { XMLWebsiteResource } from "../../xml/types.mjs";
|
|
7
|
-
|
|
8
|
-
The component settings a website gives every element of a component, keyed
|
|
9
|
-
by component name, each reader falling back to the enclosing website's
|
|
10
|
-
*/
|
|
11
|
-
export type WebComponentDefaults<T extends ReadonlyArray<string>> = ReadonlyMap<WebElementComponent["component"], WebsitePresentationReader<T>>;
|
|
7
|
+
export type WebComponentDefaults<T extends ReadonlyArray<string>> = Website<T>["properties"]["componentDefaults"];
|
|
12
8
|
/**
|
|
13
9
|
What the element parsers read from the enclosing website
|
|
14
10
|
|
|
@@ -128,16 +128,21 @@ component starts from
|
|
|
128
128
|
function parseComponentDefaults(websiteReader, parent) {
|
|
129
129
|
const elementReaders = websiteReader.nestedAllByValue("customize-special", "element");
|
|
130
130
|
if (elementReaders.length === 0) return parent;
|
|
131
|
-
const defaults =
|
|
131
|
+
const defaults = { ...parent };
|
|
132
132
|
for (const component of componentSchema.options) for (const elementReader of elementReaders) {
|
|
133
|
-
const
|
|
134
|
-
if (
|
|
135
|
-
defaults
|
|
133
|
+
const componentProperties = elementReader.propertyByValue("component", component)?.properties;
|
|
134
|
+
if (componentProperties != null && componentProperties.length > 0) {
|
|
135
|
+
defaults[component] = [componentProperties, ...parent[component] ?? []];
|
|
136
136
|
break;
|
|
137
137
|
}
|
|
138
138
|
}
|
|
139
139
|
return defaults;
|
|
140
140
|
}
|
|
141
|
+
function componentDefaultsReader(layers) {
|
|
142
|
+
let reader = null;
|
|
143
|
+
for (const layer of layers.toReversed()) reader = websitePresentationReader(layer, reader);
|
|
144
|
+
return reader;
|
|
145
|
+
}
|
|
141
146
|
const THREE_D_VIEWER_COMPONENT_DEFAULTS = {
|
|
142
147
|
isInteractive: true,
|
|
143
148
|
isControlsDisplayed: true
|
|
@@ -713,7 +718,7 @@ function parseWebElementProperties(componentProperty, elementResource, options,
|
|
|
713
718
|
const component = componentNameResult.output;
|
|
714
719
|
return WEB_ELEMENT_COMPONENT_PARSERS[component]({
|
|
715
720
|
componentProperty,
|
|
716
|
-
componentReader: websitePresentationReader(componentProperty.properties, context.componentDefaults
|
|
721
|
+
componentReader: websitePresentationReader(componentProperty.properties, componentDefaultsReader(context.componentDefaults[component] ?? [])),
|
|
717
722
|
elementResource,
|
|
718
723
|
websiteLinks: parseLinks(elementResource.links, options),
|
|
719
724
|
options,
|
|
@@ -3,7 +3,7 @@ import { Webpage, Website } from "../../types/website.mjs";
|
|
|
3
3
|
import { XMLWebsiteData, XMLWebsiteResource } from "../../xml/types.mjs";
|
|
4
4
|
export declare function parseWebpageView<T extends ReadonlyArray<string>>(view: {
|
|
5
5
|
resource?: Array<XMLWebsiteResource>;
|
|
6
|
-
} | undefined, options: ParserOptions<T>, context: Pick<Website<T>, "belongsTo" | "metadata">): Webpage<T> | null;
|
|
6
|
+
} | undefined, options: ParserOptions<T>, context: Pick<Website<T>, "belongsTo" | "metadata">, website: Pick<Website<T>, "properties"> | null): Webpage<T> | null;
|
|
7
7
|
export declare function parseWebsite<const T extends ReadonlyArray<string> = ReadonlyArray<string>>(data: XMLWebsiteData, options?: {
|
|
8
8
|
languages?: T;
|
|
9
9
|
}): Website<T>;
|
|
@@ -4,7 +4,7 @@ import { parseMetadataLanguages, resolveDefaultLanguage, resolveLanguages } from
|
|
|
4
4
|
import { parseComponentDefaults, parseWebElement, parseWebTitle } from "./components.mjs";
|
|
5
5
|
import { findWebsiteLink, parseWebsiteLinkTarget, webImageFromLink } from "./links.mjs";
|
|
6
6
|
import { formatXMLWebsiteResourceMetadata } from "./messages.mjs";
|
|
7
|
-
import {
|
|
7
|
+
import { WEBPAGE_PROPERTY_LABELS, parseWebsiteProperties, resolveWebpageSettings } from "./properties.mjs";
|
|
8
8
|
import { websitePresentationReader } from "./reader.mjs";
|
|
9
9
|
import { cleanWebsitePageSlug } from "./slug.mjs";
|
|
10
10
|
import { emptyResponsiveStyles, parseResponsiveCssStyles } from "./styles.mjs";
|
|
@@ -65,7 +65,7 @@ function createWebpage(resource, slug, options, context) {
|
|
|
65
65
|
items: [],
|
|
66
66
|
segments: [],
|
|
67
67
|
properties: {
|
|
68
|
-
...context.parentProperties?.page
|
|
68
|
+
...resolveWebpageSettings(context.parentProperties?.page),
|
|
69
69
|
isDisplayedInNavbar: true,
|
|
70
70
|
redirect: null,
|
|
71
71
|
backgroundImage: null,
|
|
@@ -114,12 +114,13 @@ Parses walked page nodes into an array of Webpage objects
|
|
|
114
114
|
function parseWebpages(pages, options, context) {
|
|
115
115
|
return Array.from(pages, (page) => parseWebpage(page, options, context));
|
|
116
116
|
}
|
|
117
|
-
function parseWebpageView(view, options, context) {
|
|
117
|
+
function parseWebpageView(view, options, context, website) {
|
|
118
118
|
const pages = readWebsitePages(view?.resource, options);
|
|
119
119
|
return parseWebpages(pages, options, {
|
|
120
120
|
...context,
|
|
121
121
|
pageSlugs: collectWebsitePageSlugs(pages, options),
|
|
122
|
-
|
|
122
|
+
parentProperties: website?.properties,
|
|
123
|
+
componentDefaults: website?.properties.componentDefaults ?? {}
|
|
123
124
|
})[0] ?? null;
|
|
124
125
|
}
|
|
125
126
|
function parseWebsiteSegments(segments, options, context) {
|
|
@@ -304,7 +305,7 @@ function parseWebsiteTree(websiteTree, options, context, type, slugPrefix) {
|
|
|
304
305
|
componentDefaults: parseComponentDefaults(websiteReader, context.componentDefaults)
|
|
305
306
|
};
|
|
306
307
|
const sidebar = parseSidebar(resources, options, treeContext);
|
|
307
|
-
const properties = parseWebsiteProperties(websiteReader, websiteTree, sidebar, options, context.parentProperties ?? null);
|
|
308
|
+
const properties = parseWebsiteProperties(websiteReader, websiteTree, sidebar, options, context.parentProperties ?? null, treeContext.componentDefaults);
|
|
308
309
|
const license = parseLicense(websiteTree.availability) ?? context.parentLicense ?? null;
|
|
309
310
|
const pageContext = {
|
|
310
311
|
...treeContext,
|
|
@@ -347,7 +348,7 @@ function parseWebsite(data, options) {
|
|
|
347
348
|
abbreviation: rawOchre.belongsTo
|
|
348
349
|
},
|
|
349
350
|
metadata: parseMetadata(rawOchre, parserOptions, defaultLanguage),
|
|
350
|
-
componentDefaults:
|
|
351
|
+
componentDefaults: {}
|
|
351
352
|
}, "website");
|
|
352
353
|
const styleLabels = new Map((rawOchre.styleLabels?.styleLabel ?? []).map((styleLabel) => [styleLabel.valueUuid, parseRequiredContentLike(styleLabel, parserOptions)]));
|
|
353
354
|
for (const stylesheet of website.properties.options.stylesheets.properties) if (stylesheet.category === "propertyValue") stylesheet.label = styleLabels.get(stylesheet.uuid) ?? null;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ParserOptions } from "../helpers.mjs";
|
|
2
2
|
import { WebsitePresentationReader } from "./reader.mjs";
|
|
3
|
-
import { WebSidebar, Website } from "../../types/website.mjs";
|
|
3
|
+
import { WebSidebar, Webpage, Website } from "../../types/website.mjs";
|
|
4
4
|
import { XMLWebsiteTree } from "../../xml/types.mjs";
|
|
5
|
-
export declare
|
|
5
|
+
export declare function resolveWebpageSettings(page: Website["properties"]["page"] | undefined): Pick<Webpage["properties"], keyof Website["properties"]["page"]>;
|
|
6
6
|
export declare const WEBPAGE_PROPERTY_LABELS: {
|
|
7
7
|
readonly width: "width";
|
|
8
8
|
readonly variant: "variant";
|
|
@@ -16,4 +16,4 @@ Parses raw website properties into a standardized Website properties structure
|
|
|
16
16
|
@param websiteReader - Reader over the website's "presentation" properties
|
|
17
17
|
@returns Parsed WebsiteProperties object
|
|
18
18
|
*/
|
|
19
|
-
export declare function parseWebsiteProperties<T extends ReadonlyArray<string>>(websiteReader: WebsitePresentationReader<T>, websiteTree: XMLWebsiteTree, sidebar: WebSidebar<T> | null, options: ParserOptions<T>, parent: Website<T>["properties"] | null): Website<T>["properties"];
|
|
19
|
+
export declare function parseWebsiteProperties<T extends ReadonlyArray<string>>(websiteReader: WebsitePresentationReader<T>, websiteTree: XMLWebsiteTree, sidebar: WebSidebar<T> | null, options: ParserOptions<T>, parent: Website<T>["properties"] | null, componentDefaults: Website<T>["properties"]["componentDefaults"]): Website<T>["properties"];
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import { parseWebsiteOptions } from "./options.mjs";
|
|
2
2
|
import { parseStylesheets } from "./styles.mjs";
|
|
3
3
|
// src/parsers/website/properties.ts
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
4
|
+
function resolveWebpageSettings(page) {
|
|
5
|
+
return {
|
|
6
|
+
width: page?.width ?? "default",
|
|
7
|
+
variant: page?.variant ?? "default",
|
|
8
|
+
isBreadcrumbsDisplayed: page?.isBreadcrumbsDisplayed ?? false,
|
|
9
|
+
isSidebarDisplayed: page?.isSidebarDisplayed ?? true,
|
|
10
|
+
isNavbarSearchBarDisplayed: page?.isNavbarSearchBarDisplayed ?? true
|
|
11
|
+
};
|
|
12
|
+
}
|
|
11
13
|
const WEBPAGE_PROPERTY_LABELS = {
|
|
12
14
|
width: "width",
|
|
13
15
|
variant: "variant",
|
|
@@ -21,7 +23,7 @@ Parses raw website properties into a standardized Website properties structure
|
|
|
21
23
|
@param websiteReader - Reader over the website's "presentation" properties
|
|
22
24
|
@returns Parsed WebsiteProperties object
|
|
23
25
|
*/
|
|
24
|
-
function parseWebsiteProperties(websiteReader, websiteTree, sidebar, options, parent) {
|
|
26
|
+
function parseWebsiteProperties(websiteReader, websiteTree, sidebar, options, parent, componentDefaults) {
|
|
25
27
|
const returnProperties = {
|
|
26
28
|
type: parent?.type ?? "traditional",
|
|
27
29
|
status: parent?.status ?? "development",
|
|
@@ -52,7 +54,14 @@ function parseWebsiteProperties(websiteReader, websiteTree, sidebar, options, pa
|
|
|
52
54
|
items: parent?.footer.items ?? null
|
|
53
55
|
},
|
|
54
56
|
sidebar: sidebar ?? parent?.sidebar ?? null,
|
|
55
|
-
page: {
|
|
57
|
+
page: {
|
|
58
|
+
width: parent?.page.width ?? null,
|
|
59
|
+
variant: parent?.page.variant ?? null,
|
|
60
|
+
isBreadcrumbsDisplayed: parent?.page.isBreadcrumbsDisplayed ?? null,
|
|
61
|
+
isSidebarDisplayed: parent?.page.isSidebarDisplayed ?? null,
|
|
62
|
+
isNavbarSearchBarDisplayed: parent?.page.isNavbarSearchBarDisplayed ?? null
|
|
63
|
+
},
|
|
64
|
+
componentDefaults,
|
|
56
65
|
itemPage: {
|
|
57
66
|
isMainContentDisplayed: parent?.itemPage.isMainContentDisplayed ?? true,
|
|
58
67
|
description: {
|
|
@@ -170,4 +179,4 @@ function parseWebsiteProperties(websiteReader, websiteTree, sidebar, options, pa
|
|
|
170
179
|
}
|
|
171
180
|
return returnProperties;
|
|
172
181
|
}
|
|
173
|
-
export {
|
|
182
|
+
export { WEBPAGE_PROPERTY_LABELS, parseWebsiteProperties, resolveWebpageSettings };
|
|
@@ -27,7 +27,6 @@ export declare class WebsitePresentationReader<T extends LanguageCodes> {
|
|
|
27
27
|
private readonly sourceProperties;
|
|
28
28
|
private readonly fallback;
|
|
29
29
|
constructor(sourceProperties: ReadonlyArray<SimplifiedProperty<T>>, fallback?: WebsitePresentationReader<T> | null);
|
|
30
|
-
private propertyByValue;
|
|
31
30
|
/**
|
|
32
31
|
Overwrite one field from a labeled OCHRE property
|
|
33
32
|
|
|
@@ -36,6 +35,7 @@ export declare class WebsitePresentationReader<T extends LanguageCodes> {
|
|
|
36
35
|
coming from the target rather than from a type argument.
|
|
37
36
|
*/
|
|
38
37
|
private readOne;
|
|
38
|
+
propertyByValue(label: string, value: WebsitePropertyContent<T>): SimplifiedProperty<T> | null;
|
|
39
39
|
property(label: string): SimplifiedProperty<T> | null;
|
|
40
40
|
requiredProperty(label: string, message: string): SimplifiedProperty<T>;
|
|
41
41
|
valueNode(label: string): PropertyValueContent<T> | null;
|
|
@@ -79,7 +79,6 @@ export declare class WebsitePresentationReader<T extends LanguageCodes> {
|
|
|
79
79
|
nested(label: string): WebsitePresentationReader<T>;
|
|
80
80
|
nestedByValue(label: string, value: WebsitePropertyContent<T>): WebsitePresentationReader<T>;
|
|
81
81
|
nestedAllByValue(label: string, value: WebsitePropertyContent<T>): Array<WebsitePresentationReader<T>>;
|
|
82
|
-
withFallback(fallback: WebsitePresentationReader<T> | null): WebsitePresentationReader<T>;
|
|
83
82
|
get size(): number;
|
|
84
83
|
}
|
|
85
84
|
export declare function websitePresentationReader<T extends LanguageCodes>(properties: ReadonlyArray<SimplifiedProperty<T>>, fallback?: WebsitePresentationReader<T> | null): WebsitePresentationReader<T>;
|
|
@@ -24,12 +24,6 @@ var WebsitePresentationReader = class WebsitePresentationReader {
|
|
|
24
24
|
this.sourceProperties = sourceProperties;
|
|
25
25
|
this.fallback = fallback;
|
|
26
26
|
}
|
|
27
|
-
propertyByValue(label, value) {
|
|
28
|
-
return getProperty(this.sourceProperties, {
|
|
29
|
-
label,
|
|
30
|
-
valueContent: value
|
|
31
|
-
}) ?? this.fallback?.propertyByValue(label, value) ?? null;
|
|
32
|
-
}
|
|
33
27
|
/**
|
|
34
28
|
Overwrite one field from a labeled OCHRE property
|
|
35
29
|
|
|
@@ -40,6 +34,12 @@ var WebsitePresentationReader = class WebsitePresentationReader {
|
|
|
40
34
|
readOne(target, key, label) {
|
|
41
35
|
target[key] = this.valueOr(label, target[key]);
|
|
42
36
|
}
|
|
37
|
+
propertyByValue(label, value) {
|
|
38
|
+
return getProperty(this.sourceProperties, {
|
|
39
|
+
label,
|
|
40
|
+
valueContent: value
|
|
41
|
+
}) ?? this.fallback?.propertyByValue(label, value) ?? null;
|
|
42
|
+
}
|
|
43
43
|
property(label) {
|
|
44
44
|
return getProperty(this.sourceProperties, { label }) ?? this.fallback?.property(label) ?? null;
|
|
45
45
|
}
|
|
@@ -137,9 +137,6 @@ var WebsitePresentationReader = class WebsitePresentationReader {
|
|
|
137
137
|
}) != null) readers.push(new WebsitePresentationReader(property.properties));
|
|
138
138
|
return readers.length === 0 && this.fallback != null ? this.fallback.nestedAllByValue(label, value) : readers;
|
|
139
139
|
}
|
|
140
|
-
withFallback(fallback) {
|
|
141
|
-
return new WebsitePresentationReader(this.sourceProperties, fallback);
|
|
142
|
-
}
|
|
143
140
|
get size() {
|
|
144
141
|
return this.sourceProperties.length + (this.fallback?.size ?? 0);
|
|
145
142
|
}
|
package/dist/types/website.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { MultilingualString } from "../parsers/multilingual.mjs";
|
|
2
|
-
import { Bibliography, Identification, ItemCategory, LanguageCodes, License, Metadata, Person, QueryablePropertyValueDataType } from "./index.mjs";
|
|
2
|
+
import { Bibliography, Identification, ItemCategory, LanguageCodes, License, Metadata, Person, QueryablePropertyValueDataType, SimplifiedProperty } from "./index.mjs";
|
|
3
3
|
import { Prettify } from "./utilities.mjs";
|
|
4
4
|
/**
|
|
5
5
|
Represents a context tree level item with a variable and value
|
|
@@ -193,10 +193,17 @@ export type Website<T extends LanguageCodes = LanguageCodes> = {
|
|
|
193
193
|
};
|
|
194
194
|
sidebar: WebSidebar<T> | null;
|
|
195
195
|
/**
|
|
196
|
-
The
|
|
197
|
-
overrides by setting the property itself
|
|
196
|
+
The settings every page of the website starts from, which a page
|
|
197
|
+
overrides by setting the property itself, each null when the website
|
|
198
|
+
leaves it unset
|
|
198
199
|
*/
|
|
199
|
-
page:
|
|
200
|
+
page: { [K in "width" | "variant" | "isBreadcrumbsDisplayed" | "isSidebarDisplayed" | "isNavbarSearchBarDisplayed"]: Webpage<T>["properties"][K] | null; };
|
|
201
|
+
/**
|
|
202
|
+
The settings every element of a component starts from, keyed by
|
|
203
|
+
component name: the "component" properties of this website, then of each
|
|
204
|
+
enclosing one, which an element overrides by setting the property itself
|
|
205
|
+
*/
|
|
206
|
+
componentDefaults: Partial<Record<WebElementComponentName, Array<Array<SimplifiedProperty<T>>>>>;
|
|
200
207
|
itemPage: {
|
|
201
208
|
isMainContentDisplayed: boolean;
|
|
202
209
|
description: WebSectionDisplay;
|