ochre-sdk 1.1.6 → 1.2.1
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/README.md +8 -0
- package/dist/constants.mjs +1 -0
- package/dist/fetchers/container-items.mjs +12 -0
- package/dist/fetchers/set/item-locations.d.mts +35 -0
- package/dist/fetchers/set/item-locations.mjs +80 -0
- package/dist/index.d.mts +3 -2
- package/dist/index.mjs +2 -1
- package/dist/parsers/index.d.mts +3 -2
- package/dist/parsers/index.mjs +1 -1
- package/dist/parsers/website/components.mjs +2 -0
- package/dist/schemas.d.mts +20 -0
- package/dist/schemas.mjs +17 -1
- package/dist/types/index.d.mts +25 -0
- package/dist/types/website.d.mts +1 -0
- package/dist/xml/schemas.d.mts +1651 -180
- package/dist/xml/schemas.mjs +22 -7
- package/dist/xml/types.d.mts +21 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -66,6 +66,10 @@ present and `error` is `null`; on failure, the parsed value is `null` and
|
|
|
66
66
|
style, collection, and item-page configuration.
|
|
67
67
|
- `fetchSetItems(params, containedItemCategories, options)` fetches paginated
|
|
68
68
|
Set search results with typed query and sort support.
|
|
69
|
+
- `fetchSetItemLocations(params, options)` fetches the identification,
|
|
70
|
+
coordinates and chosen property values of every Set item matching a query,
|
|
71
|
+
without paging, for drawing all results on a map while a list pages through
|
|
72
|
+
them.
|
|
69
73
|
- `fetchTreeItems(params, containedItemCategories, options)` is the same for a
|
|
70
74
|
Tree, and is how to read a Tree too large to fetch whole. Items nested under
|
|
71
75
|
headings come back flat, in document order.
|
|
@@ -152,6 +156,10 @@ const result = await fetchSetItems(
|
|
|
152
156
|
Use `fetchSetPropertyValues` with the same query shape when you need facet data
|
|
153
157
|
for a filtered result set.
|
|
154
158
|
|
|
159
|
+
Sort by distance from a point with `{ target: "distance", latitude, longitude }`.
|
|
160
|
+
Items are ordered by their first point, or the center of their first plane, and
|
|
161
|
+
items without coordinates come last.
|
|
162
|
+
|
|
155
163
|
`fetchTreeItems` takes the same `Query` tree and the same sort options, because
|
|
156
164
|
both fetchers compile the same query model against their container's searchable
|
|
157
165
|
path. The difference is what the payload carries: OCHRE publishes Tree items as
|
package/dist/constants.mjs
CHANGED
|
@@ -88,6 +88,18 @@ function buildOrderedItemsClause(sort) {
|
|
|
88
88
|
let $sortKey := ${`string-join($item/identification/label/content[@xml:lang=${stringLiteral(sort.language ?? "eng")}]/string, "")`}
|
|
89
89
|
stable order by ${buildStringOrderByClause(direction)}
|
|
90
90
|
return $item`;
|
|
91
|
+
if (sort.target === "distance") {
|
|
92
|
+
const longitudeScale = Math.cos(sort.latitude * Math.PI / 180);
|
|
93
|
+
return `let $orderedItems :=
|
|
94
|
+
for $item at $position in $items
|
|
95
|
+
let $point := ($item/coordinates/coord[@type = "point"][@latitude castable as xs:double][@longitude castable as xs:double])[1]
|
|
96
|
+
let $plane := ($item/coordinates/coord[@type = "plane"][minimum/@latitude castable as xs:double][minimum/@longitude castable as xs:double][maximum/@latitude castable as xs:double][maximum/@longitude castable as xs:double])[1]
|
|
97
|
+
let $latitude := if (exists($point)) then xs:double($point/@latitude) else if (exists($plane)) then (xs:double($plane/minimum/@latitude) + xs:double($plane/maximum/@latitude)) div 2 else ()
|
|
98
|
+
let $longitude := if (exists($point)) then xs:double($point/@longitude) else if (exists($plane)) then (xs:double($plane/minimum/@longitude) + xs:double($plane/maximum/@longitude)) div 2 else ()
|
|
99
|
+
let $sortKey := if (exists($latitude)) then ($latitude - ${sort.latitude}) * ($latitude - ${sort.latitude}) + ($longitude - ${sort.longitude}) * ($longitude - ${sort.longitude}) * ${longitudeScale * longitudeScale} else ()
|
|
100
|
+
stable order by ${buildTypedOrderByClause(direction)}
|
|
101
|
+
return $item`;
|
|
102
|
+
}
|
|
91
103
|
if (sort.target === "date") return `let $orderedItems :=
|
|
92
104
|
for $item at $position in $items
|
|
93
105
|
let $sortKey := string(($item/@date, $item/interpretations/interpretation/@date)[1])
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Query, SetItemLocation } from "../../types/index.mjs";
|
|
2
|
+
import { FetchBaseOptions, FetchLanguages } from "../../parsers/helpers.mjs";
|
|
3
|
+
//#region src/fetchers/set/item-locations.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Fetches the location of every Set item that matches a query, without paging
|
|
6
|
+
*
|
|
7
|
+
* Each item carries only its identification, its coordinates and the values of
|
|
8
|
+
* the requested property variables (inherited values included), which is what a
|
|
9
|
+
* map needs to draw and colour every match while a list pages through the same
|
|
10
|
+
* query with {@link fetchSetItems}.
|
|
11
|
+
*
|
|
12
|
+
* @param parameters - The parameters for the fetch
|
|
13
|
+
* @param parameters.setScopeUuids - The Set scope UUIDs to filter by
|
|
14
|
+
* @param parameters.queries - Recursive query tree used to filter matching items
|
|
15
|
+
* @param parameters.propertyVariableUuids - The property variables whose values each item should carry
|
|
16
|
+
* @param options - Options for the fetch
|
|
17
|
+
* @param options.fetch - The fetch function to use
|
|
18
|
+
* @returns The item locations, or an error if the fetch/parse fails
|
|
19
|
+
*/
|
|
20
|
+
export declare function fetchSetItemLocations<const TLanguages extends ReadonlyArray<string> | undefined = undefined>(parameters: {
|
|
21
|
+
setScopeUuids: Array<string>;
|
|
22
|
+
queries?: Query | null;
|
|
23
|
+
propertyVariableUuids?: Array<string>;
|
|
24
|
+
}, options?: FetchBaseOptions<TLanguages>): Promise<{
|
|
25
|
+
totalCount: number;
|
|
26
|
+
items: Array<SetItemLocation<FetchLanguages<TLanguages>>>;
|
|
27
|
+
error: null;
|
|
28
|
+
detailedError: null;
|
|
29
|
+
} | {
|
|
30
|
+
totalCount: null;
|
|
31
|
+
items: null;
|
|
32
|
+
error: string;
|
|
33
|
+
detailedError: string;
|
|
34
|
+
}>;
|
|
35
|
+
//#endregion
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { normalizeItemCategory } from "../../categories.mjs";
|
|
2
|
+
import { getErrorOutput } from "../../errors.mjs";
|
|
3
|
+
import { requestOchre } from "../request.mjs";
|
|
4
|
+
import { setItemLocationsParametersSchema } from "../../schemas.mjs";
|
|
5
|
+
import { parseRequiredContentLike } from "../../parsers/helpers.mjs";
|
|
6
|
+
import { parseRequestedLanguages, resolveContentLanguages } from "../../parsers/languages.mjs";
|
|
7
|
+
import { parseCoordinates, parseIdentification } from "../../parsers/index.mjs";
|
|
8
|
+
import { XMLSetItemLocationsData } from "../../xml/schemas.mjs";
|
|
9
|
+
import { stringLiteral } from "../../xquery.mjs";
|
|
10
|
+
import { compileContainerItemsQuery } from "../../query.mjs";
|
|
11
|
+
import * as v from "valibot";
|
|
12
|
+
//#region src/fetchers/set/item-locations.ts
|
|
13
|
+
async function fetchSetItemLocations(parameters, options) {
|
|
14
|
+
try {
|
|
15
|
+
const { setScopeUuids, belongsToCollectionScopeUuids, queries, propertyVariableUuids } = v.parse(setItemLocationsParametersSchema, parameters);
|
|
16
|
+
const output = await requestOchre({
|
|
17
|
+
xquery: compileContainerItemsQuery({
|
|
18
|
+
container: "set",
|
|
19
|
+
scopeUuids: setScopeUuids,
|
|
20
|
+
belongsToCollectionScopeUuids,
|
|
21
|
+
queries,
|
|
22
|
+
body: ({ items }) => ` let $propertyVariableUuids := (${Array.from(propertyVariableUuids, (uuid) => stringLiteral(uuid)).join(", ")})
|
|
23
|
+
|
|
24
|
+
return <items totalCount="{count(${items})}">{
|
|
25
|
+
for $item in ${items}
|
|
26
|
+
return <itemLocation uuid="{$item/@uuid}" category="{local-name($item)}">{
|
|
27
|
+
$item/identification,
|
|
28
|
+
$item/coordinates,
|
|
29
|
+
for $value in $item//properties//property[label/@uuid = $propertyVariableUuids]/value[@uuid]
|
|
30
|
+
return <value variable="{$value/../label/@uuid}" uuid="{$value/@uuid}">{$value/content}</value>
|
|
31
|
+
}</itemLocation>
|
|
32
|
+
}</items>`
|
|
33
|
+
}),
|
|
34
|
+
schema: XMLSetItemLocationsData,
|
|
35
|
+
label: "OCHRE Set item locations",
|
|
36
|
+
options
|
|
37
|
+
});
|
|
38
|
+
const languages = resolveContentLanguages(output.result.ochre.items, parseRequestedLanguages(options?.languages));
|
|
39
|
+
const itemsByUuid = /* @__PURE__ */ new Map();
|
|
40
|
+
const itemLocations = output.result.ochre.items.itemLocation ?? [];
|
|
41
|
+
for (const itemLocation of itemLocations) {
|
|
42
|
+
const category = normalizeItemCategory(itemLocation.category);
|
|
43
|
+
if (category == null || itemsByUuid.has(itemLocation.uuid)) continue;
|
|
44
|
+
const propertyValues = [];
|
|
45
|
+
const seenPropertyValues = /* @__PURE__ */ new Set();
|
|
46
|
+
const values = itemLocation.value ?? [];
|
|
47
|
+
for (const value of values) {
|
|
48
|
+
const key = `${value.variable}:${value.uuid}`;
|
|
49
|
+
if (seenPropertyValues.has(key)) continue;
|
|
50
|
+
seenPropertyValues.add(key);
|
|
51
|
+
propertyValues.push({
|
|
52
|
+
variableUuid: value.variable,
|
|
53
|
+
valueUuid: value.uuid,
|
|
54
|
+
label: parseRequiredContentLike(value, { languages })
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
itemsByUuid.set(itemLocation.uuid, {
|
|
58
|
+
uuid: itemLocation.uuid,
|
|
59
|
+
category,
|
|
60
|
+
identification: parseIdentification(itemLocation.identification, { languages }),
|
|
61
|
+
coordinates: parseCoordinates(itemLocation.coordinates, { languages }),
|
|
62
|
+
propertyValues
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
return {
|
|
66
|
+
totalCount: output.result.ochre.items.totalCount,
|
|
67
|
+
items: itemsByUuid.values().toArray(),
|
|
68
|
+
error: null,
|
|
69
|
+
detailedError: null
|
|
70
|
+
};
|
|
71
|
+
} catch (error) {
|
|
72
|
+
return {
|
|
73
|
+
totalCount: null,
|
|
74
|
+
items: null,
|
|
75
|
+
...getErrorOutput(error, "Failed to fetch Set item locations")
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
//#endregion
|
|
80
|
+
export { fetchSetItemLocations };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { MultilingualOptions, MultilingualString, MultilingualStringEntries, MultilingualStringEntry, MultilingualStringInput, MultilingualStringJSON, MultilingualStringObject, MultilingualStringText } from "./parsers/multilingual.mjs";
|
|
2
2
|
import { AccordionWebBlock, ContextTree, ContextTreeFilterLevel, ContextTreeFilterVariant, ContextTreeLevel, ContextTreeLevelItem, ProtectedWebsite, ResponsiveStyles, Scope, Style, StylesheetCategory, StylesheetItem, WebAccordionItem, WebBlock, WebBlockByLayout, WebBlockItem, WebBlockLayout, WebElement, WebElementComponent, WebElementComponentName, WebElementComponentOf, WebElementOf, WebIiifViewer, WebImage, WebLoadingVariant, WebOptions, WebSectionDisplay, WebSectionVariant, WebSidebar, WebTitle, Webpage, Website, WebsiteMetadata, WebsitePrivacy, WebsitePropertyQuery, WebsitePropertyQueryNode, WebsiteSegment, WebsiteType } from "./types/website.mjs";
|
|
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, 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, SetStyle, SetStyleProperty, SetTree, SimplifiedProperty, SpatialUnit, SpatialUnitItemLink, Text, TextItemLink, TopLevelItem, Tree, TreeItemCategory, TreeItemLink } from "./types/index.mjs";
|
|
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, 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, SetItemLocation, SetItemProperty, SetItemSimplifiedProperty, SetItemsSort, SetItemsSortDirection, SetPeriod, SetResource, SetSpatialUnit, SetStyle, SetStyleProperty, SetTree, SimplifiedProperty, SpatialUnit, SpatialUnitItemLink, Text, TextItemLink, TopLevelItem, Tree, TreeItemCategory, TreeItemLink } from "./types/index.mjs";
|
|
4
4
|
import { DEFAULT_PAGE_SIZE } from "./constants.mjs";
|
|
5
5
|
import { fetchGallery } from "./fetchers/gallery.mjs";
|
|
6
6
|
import { fetchItemChildren } from "./fetchers/item-children.mjs";
|
|
7
7
|
import { fetchItemLinks } from "./fetchers/item-links.mjs";
|
|
8
8
|
import { fetchItemOcrData } from "./fetchers/item-ocr-data.mjs";
|
|
9
9
|
import { fetchItem } from "./fetchers/item.mjs";
|
|
10
|
+
import { fetchSetItemLocations } from "./fetchers/set/item-locations.mjs";
|
|
10
11
|
import { fetchSetItems } from "./fetchers/set/items.mjs";
|
|
11
12
|
import { fetchSetPropertyValues } from "./fetchers/set/property-values.mjs";
|
|
12
13
|
import { fetchTreeItems } from "./fetchers/tree/items.mjs";
|
|
@@ -15,4 +16,4 @@ import { fetchWebsite } from "./fetchers/website.mjs";
|
|
|
15
16
|
import { PropertyOptions, PropertySelector, getLeafPropertyValues, getProperty, getPropertyValue, getPropertyValues, getUniqueProperties, getUniquePropertyVariableLabels, isPropertyMatchingFilter, normalizePropertyVariableLabel } from "./getters.mjs";
|
|
16
17
|
import { flattenItemProperties } from "./helpers.mjs";
|
|
17
18
|
import { defineLanguages } from "./parsers/languages.mjs";
|
|
18
|
-
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 Property, type PropertyLike, type PropertyOptions, type PropertyRelation, type PropertySelector, 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 ResponsiveStyles, 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 SetStyle, type SetStyleProperty, 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 WebIiifViewer, type WebImage, type WebLoadingVariant, type WebOptions, type WebSectionDisplay, type WebSectionVariant, type WebSidebar, type WebTitle, type Webpage, type Website, type WebsiteMetadata, type WebsitePrivacy, type WebsitePropertyQuery, type WebsitePropertyQueryNode, type WebsiteSegment, type WebsiteType, defineLanguages, fetchGallery, fetchItem, fetchItemChildren, fetchItemLinks, fetchItemOcrData, fetchSetItems, fetchSetPropertyValues, fetchTreeItems, fetchWebsite, fetchWebsiteMetadata, flattenItemProperties, getLeafPropertyValues, getProperty, getPropertyValue, getPropertyValues, getUniqueProperties, getUniquePropertyVariableLabels, isPropertyMatchingFilter, normalizePropertyVariableLabel };
|
|
19
|
+
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 Property, type PropertyLike, type PropertyOptions, type PropertyRelation, type PropertySelector, 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 ResponsiveStyles, type Scope, type Section, type Set, type SetAttributeValueQueryItem, type SetBibliography, type SetConcept, type SetItem, type SetItemCategory, type SetItemLink, type SetItemLocation, type SetItemProperty, type SetItemSimplifiedProperty, type SetItemsSort, type SetItemsSortDirection, type SetPeriod, type SetResource, type SetSpatialUnit, type SetStyle, type SetStyleProperty, 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 WebIiifViewer, type WebImage, type WebLoadingVariant, type WebOptions, type WebSectionDisplay, type WebSectionVariant, type WebSidebar, type WebTitle, type Webpage, type Website, type WebsiteMetadata, type WebsitePrivacy, type WebsitePropertyQuery, type WebsitePropertyQueryNode, type WebsiteSegment, type WebsiteType, defineLanguages, fetchGallery, fetchItem, fetchItemChildren, fetchItemLinks, fetchItemOcrData, fetchSetItemLocations, fetchSetItems, fetchSetPropertyValues, fetchTreeItems, fetchWebsite, fetchWebsiteMetadata, flattenItemProperties, getLeafPropertyValues, getProperty, getPropertyValue, getPropertyValues, getUniqueProperties, getUniquePropertyVariableLabels, isPropertyMatchingFilter, normalizePropertyVariableLabel };
|
package/dist/index.mjs
CHANGED
|
@@ -8,9 +8,10 @@ import { fetchItemChildren } from "./fetchers/item-children.mjs";
|
|
|
8
8
|
import { fetchItemLinks } from "./fetchers/item-links.mjs";
|
|
9
9
|
import { fetchItemOcrData } from "./fetchers/item-ocr-data.mjs";
|
|
10
10
|
import { fetchItem } from "./fetchers/item.mjs";
|
|
11
|
+
import { fetchSetItemLocations } from "./fetchers/set/item-locations.mjs";
|
|
11
12
|
import { fetchSetItems } from "./fetchers/set/items.mjs";
|
|
12
13
|
import { fetchSetPropertyValues } from "./fetchers/set/property-values.mjs";
|
|
13
14
|
import { fetchTreeItems } from "./fetchers/tree/items.mjs";
|
|
14
15
|
import { fetchWebsiteMetadata } from "./fetchers/website-metadata.mjs";
|
|
15
16
|
import { fetchWebsite } from "./fetchers/website.mjs";
|
|
16
|
-
export { DEFAULT_PAGE_SIZE, MultilingualString, defineLanguages, fetchGallery, fetchItem, fetchItemChildren, fetchItemLinks, fetchItemOcrData, fetchSetItems, fetchSetPropertyValues, fetchTreeItems, fetchWebsite, fetchWebsiteMetadata, flattenItemProperties, getLeafPropertyValues, getProperty, getPropertyValue, getPropertyValues, getUniqueProperties, getUniquePropertyVariableLabels, isPropertyMatchingFilter, normalizePropertyVariableLabel };
|
|
17
|
+
export { DEFAULT_PAGE_SIZE, MultilingualString, defineLanguages, fetchGallery, fetchItem, fetchItemChildren, fetchItemLinks, fetchItemOcrData, fetchSetItemLocations, fetchSetItems, fetchSetPropertyValues, fetchTreeItems, fetchWebsite, fetchWebsiteMetadata, flattenItemProperties, getLeafPropertyValues, getProperty, getPropertyValue, getPropertyValues, getUniqueProperties, getUniquePropertyVariableLabels, isPropertyMatchingFilter, normalizePropertyVariableLabel };
|
package/dist/parsers/index.d.mts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { Webpage } from "../types/website.mjs";
|
|
2
|
-
import { Bibliography, ContainedItemCategoryFromOption, ContainedItemCategoryOption, Gallery, Identification, Item, ItemCategory, ItemCategoryFromOption, ItemCategoryOption, ItemContainerCategory, ItemLinks, Metadata, Note, Person, Property, Resource, SetItem, SetItemCategory, SimplifiedProperty } from "../types/index.mjs";
|
|
3
|
-
import { XMLBibliography, XMLData, XMLDataItem, XMLGalleryData, XMLIdentification, XMLItemLinks, XMLLink, XMLMetadata, XMLNote, XMLPerson, XMLProperty, XMLResource, XMLSetItems, XMLSimplifiedProperty } from "../xml/types.mjs";
|
|
2
|
+
import { Bibliography, ContainedItemCategoryFromOption, ContainedItemCategoryOption, Coordinates, Gallery, Identification, Item, ItemCategory, ItemCategoryFromOption, ItemCategoryOption, ItemContainerCategory, ItemLinks, Metadata, Note, Person, Property, Resource, SetItem, SetItemCategory, SimplifiedProperty } from "../types/index.mjs";
|
|
3
|
+
import { XMLBibliography, XMLCoordinates, XMLData, XMLDataItem, XMLGalleryData, XMLIdentification, XMLItemLinks, XMLLink, XMLMetadata, XMLNote, XMLPerson, XMLProperty, XMLResource, XMLSetItems, XMLSimplifiedProperty } from "../xml/types.mjs";
|
|
4
4
|
import { ParserOptions, getParserOptions, parseStringLike } from "./helpers.mjs";
|
|
5
5
|
//#region src/parsers/index.d.ts
|
|
6
6
|
export type RawOchre = XMLData["result"]["ochre"];
|
|
7
7
|
type ResourceViewParser<T extends ReadonlyArray<string>> = (view: XMLResource["view"], context: Pick<Resource<T, "topLevel">, "belongsTo" | "metadata">) => Webpage<T> | null;
|
|
8
8
|
type SetItemCategoryFromCategories<T extends ReadonlyArray<SetItemCategory> | undefined> = T extends ReadonlyArray<infer U> ? Extract<U, SetItemCategory> : SetItemCategory;
|
|
9
9
|
export declare function parseIdentification<T extends ReadonlyArray<string>>(rawIdentification: XMLIdentification, options: ParserOptions<T>): Identification<T>;
|
|
10
|
+
export declare function parseCoordinates<T extends ReadonlyArray<string>>(rawCoordinates: XMLCoordinates | undefined, options: ParserOptions<T>): Array<Coordinates<T>>;
|
|
10
11
|
export declare function parseNotes<T extends ReadonlyArray<string>>(rawNotes: {
|
|
11
12
|
note: Array<XMLNote>;
|
|
12
13
|
} | undefined, options: ParserOptions<T>): Array<Note<T>>;
|
package/dist/parsers/index.mjs
CHANGED
|
@@ -1229,4 +1229,4 @@ function parseItem(rawData, options) {
|
|
|
1229
1229
|
};
|
|
1230
1230
|
}
|
|
1231
1231
|
//#endregion
|
|
1232
|
-
export { getParserOptions, parseBibliographyList, parseGallery, parseIdentification, parseItem, parseLinkedItems, parseLinks, parseMetadata, parseNotes, parsePersonList, parseProperties, parseSetItems, parseSimplifiedProperties, parseStringLike };
|
|
1232
|
+
export { getParserOptions, parseBibliographyList, parseCoordinates, parseGallery, parseIdentification, parseItem, parseLinkedItems, parseLinks, parseMetadata, parseNotes, parsePersonList, parseProperties, parseSetItems, parseSimplifiedProperties, parseStringLike };
|
|
@@ -233,6 +233,7 @@ function parseButtonComponent(parameters) {
|
|
|
233
233
|
const COLLECTION_FILTER_DEFAULTS = {
|
|
234
234
|
isResultsBarDisplayed: false,
|
|
235
235
|
isInputDisplayed: false,
|
|
236
|
+
isMapDisplayed: false,
|
|
236
237
|
isLimitedToInputFilter: false,
|
|
237
238
|
isLimitedToLeafPropertyValues: false,
|
|
238
239
|
isSidebarDisplayed: false,
|
|
@@ -247,6 +248,7 @@ function parseCollectionComponent(parameters) {
|
|
|
247
248
|
componentReader.readAll(filter, {
|
|
248
249
|
isResultsBarDisplayed: "filter-results-bar-displayed",
|
|
249
250
|
isInputDisplayed: "filter-input-displayed",
|
|
251
|
+
isMapDisplayed: "filter-map-displayed",
|
|
250
252
|
isLimitedToInputFilter: "filter-limit-to-input-filter",
|
|
251
253
|
isLimitedToLeafPropertyValues: "filter-limit-to-leaf-property-values",
|
|
252
254
|
isSidebarDisplayed: "filter-sidebar-displayed",
|
package/dist/schemas.d.mts
CHANGED
|
@@ -83,6 +83,11 @@ export declare const setItemsParametersSchema: v.ObjectSchema<{
|
|
|
83
83
|
readonly dataType: v.PicklistSchema<readonly ["string", "integer", "decimal", "boolean", "date", "dateTime", "time", "IDREF"], undefined>;
|
|
84
84
|
readonly direction: v.OptionalSchema<v.PicklistSchema<["asc", "desc"], undefined>, "asc">;
|
|
85
85
|
readonly language: v.GenericSchema<unknown, string>;
|
|
86
|
+
}, undefined>, v.StrictObjectSchema<{
|
|
87
|
+
readonly target: v.LiteralSchema<"distance", undefined>;
|
|
88
|
+
readonly latitude: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, -90, undefined>, v.MaxValueAction<number, 90, undefined>]>;
|
|
89
|
+
readonly longitude: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, -180, undefined>, v.MaxValueAction<number, 180, undefined>]>;
|
|
90
|
+
readonly direction: v.OptionalSchema<v.PicklistSchema<["asc", "desc"], undefined>, "asc">;
|
|
86
91
|
}, undefined>], undefined>, {
|
|
87
92
|
readonly target: "none";
|
|
88
93
|
}>;
|
|
@@ -90,6 +95,16 @@ export declare const setItemsParametersSchema: v.ObjectSchema<{
|
|
|
90
95
|
readonly pageSize: v.OptionalSchema<v.GenericSchema<unknown, number>, 48>;
|
|
91
96
|
readonly setScopeUuids: v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.CheckAction<string, "Invalid pseudo-UUID">]>, undefined>, v.MinLengthAction<string[], 1, "At least one set scope UUID is required">]>;
|
|
92
97
|
}, undefined>;
|
|
98
|
+
/**
|
|
99
|
+
* Schema for validating the parameters of the Set item locations fetching function
|
|
100
|
+
* @internal
|
|
101
|
+
*/
|
|
102
|
+
export declare const setItemLocationsParametersSchema: v.ObjectSchema<{
|
|
103
|
+
readonly setScopeUuids: v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.CheckAction<string, "Invalid pseudo-UUID">]>, undefined>, v.MinLengthAction<string[], 1, "At least one set scope UUID is required">]>;
|
|
104
|
+
readonly belongsToCollectionScopeUuids: v.OptionalSchema<v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.CheckAction<string, "Invalid pseudo-UUID">]>, undefined>, readonly []>;
|
|
105
|
+
readonly queries: v.OptionalSchema<v.NullableSchema<v.GenericSchema<unknown, Query>, undefined>, null>;
|
|
106
|
+
readonly propertyVariableUuids: v.OptionalSchema<v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.CheckAction<string, "Invalid pseudo-UUID">]>, undefined>, readonly []>;
|
|
107
|
+
}, undefined>;
|
|
93
108
|
export declare const treeItemsParametersSchema: v.ObjectSchema<{
|
|
94
109
|
readonly belongsToCollectionScopeUuids: v.OptionalSchema<v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.CheckAction<string, "Invalid pseudo-UUID">]>, undefined>, readonly []>;
|
|
95
110
|
readonly queries: v.OptionalSchema<v.NullableSchema<v.GenericSchema<unknown, Query>, undefined>, null>;
|
|
@@ -108,6 +123,11 @@ export declare const treeItemsParametersSchema: v.ObjectSchema<{
|
|
|
108
123
|
readonly dataType: v.PicklistSchema<readonly ["string", "integer", "decimal", "boolean", "date", "dateTime", "time", "IDREF"], undefined>;
|
|
109
124
|
readonly direction: v.OptionalSchema<v.PicklistSchema<["asc", "desc"], undefined>, "asc">;
|
|
110
125
|
readonly language: v.GenericSchema<unknown, string>;
|
|
126
|
+
}, undefined>, v.StrictObjectSchema<{
|
|
127
|
+
readonly target: v.LiteralSchema<"distance", undefined>;
|
|
128
|
+
readonly latitude: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, -90, undefined>, v.MaxValueAction<number, 90, undefined>]>;
|
|
129
|
+
readonly longitude: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MinValueAction<number, -180, undefined>, v.MaxValueAction<number, 180, undefined>]>;
|
|
130
|
+
readonly direction: v.OptionalSchema<v.PicklistSchema<["asc", "desc"], undefined>, "asc">;
|
|
111
131
|
}, undefined>], undefined>, {
|
|
112
132
|
readonly target: "none";
|
|
113
133
|
}>;
|
package/dist/schemas.mjs
CHANGED
|
@@ -214,6 +214,12 @@ const setItemsSortSchema = v.optional(v.variant("target", [
|
|
|
214
214
|
]),
|
|
215
215
|
direction: sortDirectionSchema,
|
|
216
216
|
language: defaultString("eng")
|
|
217
|
+
}),
|
|
218
|
+
v.strictObject({
|
|
219
|
+
target: v.literal("distance"),
|
|
220
|
+
latitude: v.pipe(v.number(), v.minValue(-90), v.maxValue(90)),
|
|
221
|
+
longitude: v.pipe(v.number(), v.minValue(-180), v.maxValue(180)),
|
|
222
|
+
direction: sortDirectionSchema
|
|
217
223
|
})
|
|
218
224
|
]), { target: "none" });
|
|
219
225
|
/**
|
|
@@ -258,9 +264,19 @@ const setItemsParametersSchema = v.object({
|
|
|
258
264
|
setScopeUuids: v.pipe(v.array(uuidSchema), v.minLength(1, "At least one set scope UUID is required")),
|
|
259
265
|
...containerItemsParametersEntries
|
|
260
266
|
});
|
|
267
|
+
/**
|
|
268
|
+
* Schema for validating the parameters of the Set item locations fetching function
|
|
269
|
+
* @internal
|
|
270
|
+
*/
|
|
271
|
+
const setItemLocationsParametersSchema = v.object({
|
|
272
|
+
setScopeUuids: v.pipe(v.array(uuidSchema), v.minLength(1, "At least one set scope UUID is required")),
|
|
273
|
+
belongsToCollectionScopeUuids: v.optional(v.array(uuidSchema), []),
|
|
274
|
+
queries: setQueriesSchema,
|
|
275
|
+
propertyVariableUuids: v.optional(v.array(uuidSchema), [])
|
|
276
|
+
});
|
|
261
277
|
const treeItemsParametersSchema = v.object({
|
|
262
278
|
treeScopeUuids: v.pipe(v.array(uuidSchema), v.minLength(1, "At least one tree scope UUID is required")),
|
|
263
279
|
...containerItemsParametersEntries
|
|
264
280
|
});
|
|
265
281
|
//#endregion
|
|
266
|
-
export { componentSchema, gallerySchema, isPseudoUuid, iso639_3Schema, itemOcrDataParametersSchema, renderOptionsSchema, setItemsParametersSchema, setPropertyValuesParametersSchema, treeItemsParametersSchema, uuidSchema };
|
|
282
|
+
export { componentSchema, gallerySchema, isPseudoUuid, iso639_3Schema, itemOcrDataParametersSchema, renderOptionsSchema, setItemLocationsParametersSchema, setItemsParametersSchema, setPropertyValuesParametersSchema, treeItemsParametersSchema, uuidSchema };
|
package/dist/types/index.d.mts
CHANGED
|
@@ -564,6 +564,21 @@ export type SetPeriod<T extends LanguageCodes = LanguageCodes> = Prettify<Omit<W
|
|
|
564
564
|
export type SetResource<T extends LanguageCodes = LanguageCodes> = Prettify<Omit<WithSetItemProperties<Resource<T, "embedded">, T>, "items">>;
|
|
565
565
|
export type SetTree<T extends LanguageCodes = LanguageCodes> = Prettify<Omit<WithSetItemProperties<Tree<TreeItemCategory, T, "embedded">, T>, "items">>;
|
|
566
566
|
export type SetItem<U extends SetItemCategory = SetItemCategory, T extends LanguageCodes = LanguageCodes> = U extends "tree" ? SetTree<T> : U extends "bibliography" ? SetBibliography<T> : U extends "concept" ? SetConcept<T> : U extends "spatialUnit" ? SetSpatialUnit<T> : U extends "period" ? SetPeriod<T> : U extends "person" ? WithSetItemProperties<Person<T, "embedded">, T> : U extends "propertyVariable" ? PropertyVariable<T, "embedded"> : U extends "propertyValue" ? WithSetItemProperties<PropertyValue<T, "embedded">, T> : U extends "resource" ? SetResource<T> : U extends "text" ? Text<T, "embedded"> : U extends "set" ? Omit<WithSetItemProperties<Set<SetItemCategory, T, "embedded">, T>, "items"> : never;
|
|
567
|
+
/**
|
|
568
|
+
* The location of a Set item, without its properties, for drawing and ordering
|
|
569
|
+
* every match of a query at once
|
|
570
|
+
*/
|
|
571
|
+
export type SetItemLocation<T extends LanguageCodes = LanguageCodes> = {
|
|
572
|
+
uuid: string;
|
|
573
|
+
category: SetItemCategory;
|
|
574
|
+
identification: Identification<T>;
|
|
575
|
+
coordinates: Array<Coordinates<T>>;
|
|
576
|
+
propertyValues: Array<{
|
|
577
|
+
variableUuid: string;
|
|
578
|
+
valueUuid: string;
|
|
579
|
+
label: MultilingualString<T>;
|
|
580
|
+
}>;
|
|
581
|
+
};
|
|
567
582
|
/**
|
|
568
583
|
* Person in OCHRE
|
|
569
584
|
*/
|
|
@@ -812,6 +827,16 @@ export type SetItemsSort = {
|
|
|
812
827
|
dataType: QueryablePropertyValueDataType;
|
|
813
828
|
direction?: SetItemsSortDirection;
|
|
814
829
|
language?: string;
|
|
830
|
+
} |
|
|
831
|
+
/**
|
|
832
|
+
* Sort on the distance from a point, using an item's first point or, failing
|
|
833
|
+
* that, the center of its first plane. Items without coordinates sort last.
|
|
834
|
+
*/
|
|
835
|
+
{
|
|
836
|
+
target: "distance";
|
|
837
|
+
latitude: number;
|
|
838
|
+
longitude: number;
|
|
839
|
+
direction?: SetItemsSortDirection;
|
|
815
840
|
};
|
|
816
841
|
/**
|
|
817
842
|
* Represents a leaf query for Set items
|
package/dist/types/website.d.mts
CHANGED
|
@@ -355,6 +355,7 @@ export type WebElementComponent<T extends LanguageCodes = LanguageCodes> = {
|
|
|
355
355
|
isSidebarDisplayed: boolean;
|
|
356
356
|
isResultsBarDisplayed: boolean;
|
|
357
357
|
isInputDisplayed: boolean;
|
|
358
|
+
isMapDisplayed: boolean;
|
|
358
359
|
isLimitedToInputFilter: boolean;
|
|
359
360
|
isLimitedToLeafPropertyValues: boolean;
|
|
360
361
|
sidebarSort: "default" | "alphabetical";
|