ochre-sdk 1.3.11 → 1.3.13
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 +1 -4
- package/dist/constants.mjs +3 -0
- package/dist/fetchers/item-locations.d.mts +41 -0
- package/dist/fetchers/item-locations.mjs +99 -0
- package/dist/fetchers/map-layers.d.mts +30 -0
- package/dist/fetchers/map-layers.mjs +161 -0
- package/dist/fetchers/website.mjs +10 -1
- package/dist/index.d.mts +4 -3
- package/dist/index.mjs +3 -2
- package/dist/parsers/index.d.mts +3 -2
- package/dist/parsers/index.mjs +17 -8
- package/dist/parsers/website/components.mjs +8 -3
- package/dist/parsers/website/index.mjs +5 -2
- package/dist/parsers/website/styles.d.mts +2 -2
- package/dist/parsers/website/styles.mjs +1 -0
- package/dist/schemas.d.mts +13 -4
- package/dist/schemas.mjs +8 -6
- package/dist/types/index.d.mts +30 -1
- package/dist/types/website.d.mts +5 -3
- package/dist/xml/schemas.d.mts +329 -10
- package/dist/xml/schemas.mjs +39 -17
- package/dist/xml/types.d.mts +36 -3
- package/package.json +3 -3
- package/dist/fetchers/set/item-locations.d.mts +0 -35
- package/dist/fetchers/set/item-locations.mjs +0 -83
package/README.md
CHANGED
|
@@ -66,10 +66,7 @@ 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
|
-
- `
|
|
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
|
+
- `fetchItemLocations(params, options)` fetches the identification, coordinates, and chosen property values of every Set or Tree item matching a query without paging. You can pass `setScopeUuids`, `treeScopeUuids`, or both. Each item lists the scope Sets and Trees it belongs to; this allows a map to draw one layer per Set or Tree while a list pages through the same query.
|
|
73
70
|
- `fetchTreeItems(params, containedItemCategories, options)` is the same for a
|
|
74
71
|
Tree, and is how to read a Tree too large to fetch whole. Items nested under
|
|
75
72
|
headings come back flat, in document order.
|
package/dist/constants.mjs
CHANGED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { ItemLocation, Query } from "../types/index.mjs";
|
|
2
|
+
import { FetchBaseOptions, FetchLanguages } from "../parsers/helpers.mjs";
|
|
3
|
+
//#region src/fetchers/item-locations.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Fetches the location of every Set or Tree item that matches a query, without paging
|
|
6
|
+
*
|
|
7
|
+
* Each item carries only its identification, the scope Sets and Trees it
|
|
8
|
+
* belongs to, its publication date, its coordinates, optionally its map
|
|
9
|
+
* polygons, and the values of the requested property variables (inherited
|
|
10
|
+
* values included), which is what a map needs to draw, color and group every
|
|
11
|
+
* match into layers while a list pages through the same query with
|
|
12
|
+
* {@link fetchSetItems} or {@link fetchTreeItems}.
|
|
13
|
+
*
|
|
14
|
+
* @param parameters - The parameters for the fetch
|
|
15
|
+
* @param parameters.setScopeUuids - The Set scope UUIDs to search within
|
|
16
|
+
* @param parameters.treeScopeUuids - The Tree scope UUIDs to search within
|
|
17
|
+
* @param parameters.queries - Recursive query tree used to filter matching items
|
|
18
|
+
* @param parameters.propertyVariableUuids - The property variables whose values each item should carry
|
|
19
|
+
* @param parameters.isMapDataIncluded - Whether each item should carry its map polygons
|
|
20
|
+
* @param options - Options for the fetch
|
|
21
|
+
* @param options.fetch - The fetch function to use
|
|
22
|
+
* @returns The item locations, or an error if the fetch/parse fails
|
|
23
|
+
*/
|
|
24
|
+
export declare function fetchItemLocations<const TLanguages extends ReadonlyArray<string> | undefined = undefined>(parameters: {
|
|
25
|
+
setScopeUuids?: Array<string>;
|
|
26
|
+
treeScopeUuids?: Array<string>;
|
|
27
|
+
queries?: Query | null;
|
|
28
|
+
propertyVariableUuids?: Array<string>;
|
|
29
|
+
isMapDataIncluded?: boolean;
|
|
30
|
+
}, options?: FetchBaseOptions<TLanguages>): Promise<{
|
|
31
|
+
totalCount: number;
|
|
32
|
+
items: Array<ItemLocation<FetchLanguages<TLanguages>>>;
|
|
33
|
+
error: null;
|
|
34
|
+
detailedError: null;
|
|
35
|
+
} | {
|
|
36
|
+
totalCount: null;
|
|
37
|
+
items: null;
|
|
38
|
+
error: string;
|
|
39
|
+
detailedError: string;
|
|
40
|
+
}>;
|
|
41
|
+
//#endregion
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { normalizeItemCategory } from "../categories.mjs";
|
|
2
|
+
import { getErrorOutput } from "../errors.mjs";
|
|
3
|
+
import { requestOchre } from "./request.mjs";
|
|
4
|
+
import { itemLocationsParametersSchema } from "../schemas.mjs";
|
|
5
|
+
import { parseRequiredContentLike } from "../parsers/helpers.mjs";
|
|
6
|
+
import { parseRequestedLanguages, resolveContentLanguages } from "../parsers/languages.mjs";
|
|
7
|
+
import { parseCoordinates, parseIdentification, parseSpatialUnitMapData } from "../parsers/index.mjs";
|
|
8
|
+
import { XMLItemLocationsData } from "../xml/schemas.mjs";
|
|
9
|
+
import { getContentLanguage, stringLiteral } from "../xquery.mjs";
|
|
10
|
+
import { compileContainerItemsQuery } from "../query.mjs";
|
|
11
|
+
import * as v from "valibot";
|
|
12
|
+
//#region src/fetchers/item-locations.ts
|
|
13
|
+
async function fetchItemLocations(parameters, options) {
|
|
14
|
+
try {
|
|
15
|
+
const { setScopeUuids, treeScopeUuids, belongsToCollectionScopeUuids, queries, propertyVariableUuids, isMapDataIncluded } = v.parse(itemLocationsParametersSchema, parameters);
|
|
16
|
+
const scopes = [{
|
|
17
|
+
container: "set",
|
|
18
|
+
scopeUuids: setScopeUuids
|
|
19
|
+
}, {
|
|
20
|
+
container: "tree",
|
|
21
|
+
scopeUuids: treeScopeUuids
|
|
22
|
+
}].filter(({ scopeUuids }) => scopeUuids.length > 0);
|
|
23
|
+
const outputs = await Promise.all(scopes.map(async ({ container, scopeUuids }) => requestOchre({
|
|
24
|
+
xquery: compileContainerItemsQuery({
|
|
25
|
+
container,
|
|
26
|
+
scopeUuids,
|
|
27
|
+
belongsToCollectionScopeUuids,
|
|
28
|
+
queries,
|
|
29
|
+
contentLanguage: getContentLanguage(options),
|
|
30
|
+
body: ({ items }) => ` let $propertyVariableUuids := (${Array.from(propertyVariableUuids, (uuid) => stringLiteral(uuid)).join(", ")})
|
|
31
|
+
|
|
32
|
+
return <items totalCount="{count(${items})}">{
|
|
33
|
+
for $item in ${items}
|
|
34
|
+
return <itemLocation uuid="{$item/@uuid}" category="{local-name($item)}" scopeUuid="{$item/ancestor::${container}[1]/@uuid}">{
|
|
35
|
+
${container === "tree" ? "($item/@publicationDateTime, $item/ancestor::tree[1]/@publicationDateTime)[1]" : "$item/@publicationDateTime"},
|
|
36
|
+
$item/identification,
|
|
37
|
+
$item/coordinates,${isMapDataIncluded ? "\n $item/mapData," : ""}
|
|
38
|
+
for $value in $item//properties//property[label/@uuid = $propertyVariableUuids]/value[@uuid]
|
|
39
|
+
return <value variable="{$value/../label/@uuid}" uuid="{$value/@uuid}">{$value/content}</value>
|
|
40
|
+
}</itemLocation>
|
|
41
|
+
}</items>`
|
|
42
|
+
}),
|
|
43
|
+
schema: XMLItemLocationsData,
|
|
44
|
+
label: `OCHRE ${container === "set" ? "Set" : "Tree"} item locations`,
|
|
45
|
+
options
|
|
46
|
+
})));
|
|
47
|
+
const languages = resolveContentLanguages(outputs.map((output) => output.result.ochre.items), parseRequestedLanguages(options?.languages));
|
|
48
|
+
let totalCount = 0;
|
|
49
|
+
for (const output of outputs) totalCount += output.result.ochre.items.totalCount;
|
|
50
|
+
const itemsByUuid = /* @__PURE__ */ new Map();
|
|
51
|
+
const itemLocations = outputs.flatMap((output) => output.result.ochre.items.itemLocation ?? []);
|
|
52
|
+
for (const itemLocation of itemLocations) {
|
|
53
|
+
const category = normalizeItemCategory(itemLocation.category);
|
|
54
|
+
const existing = itemsByUuid.get(itemLocation.uuid);
|
|
55
|
+
if (existing != null) {
|
|
56
|
+
if (!existing.scopeUuids.includes(itemLocation.scopeUuid)) existing.scopeUuids.push(itemLocation.scopeUuid);
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
if (category == null) continue;
|
|
60
|
+
const propertyValues = [];
|
|
61
|
+
const seenPropertyValues = /* @__PURE__ */ new Set();
|
|
62
|
+
const values = itemLocation.value ?? [];
|
|
63
|
+
for (const value of values) {
|
|
64
|
+
const key = `${value.variable}:${value.uuid}`;
|
|
65
|
+
if (seenPropertyValues.has(key)) continue;
|
|
66
|
+
seenPropertyValues.add(key);
|
|
67
|
+
propertyValues.push({
|
|
68
|
+
variableUuid: value.variable,
|
|
69
|
+
valueUuid: value.uuid,
|
|
70
|
+
label: parseRequiredContentLike(value, { languages })
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
itemsByUuid.set(itemLocation.uuid, {
|
|
74
|
+
uuid: itemLocation.uuid,
|
|
75
|
+
category,
|
|
76
|
+
scopeUuids: [itemLocation.scopeUuid],
|
|
77
|
+
publicationDateTime: itemLocation.publicationDateTime ?? null,
|
|
78
|
+
identification: parseIdentification(itemLocation.identification, { languages }),
|
|
79
|
+
coordinates: parseCoordinates(itemLocation.coordinates, { languages }),
|
|
80
|
+
mapData: parseSpatialUnitMapData(itemLocation.mapData),
|
|
81
|
+
propertyValues
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
return {
|
|
85
|
+
totalCount,
|
|
86
|
+
items: itemsByUuid.values().toArray(),
|
|
87
|
+
error: null,
|
|
88
|
+
detailedError: null
|
|
89
|
+
};
|
|
90
|
+
} catch (error) {
|
|
91
|
+
return {
|
|
92
|
+
totalCount: null,
|
|
93
|
+
items: null,
|
|
94
|
+
...getErrorOutput(error, "Failed to fetch item locations")
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
//#endregion
|
|
99
|
+
export { fetchItemLocations };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { MapLayer } from "../types/index.mjs";
|
|
2
|
+
import { FetchBaseOptions, FetchLanguages } from "../parsers/helpers.mjs";
|
|
3
|
+
//#region src/fetchers/map-layers.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Fetches the layers a map draws from the Sets and Trees it links to
|
|
6
|
+
*
|
|
7
|
+
* A linked Set holding only Sets, Trees and Resources is a layer list: each
|
|
8
|
+
* linked Set or Tree becomes an OCHRE layer and each webpage Resource whose
|
|
9
|
+
* href points at a geospatial web service becomes a service layer. Any other
|
|
10
|
+
* linked Set or Tree is drawn as one OCHRE layer itself. The variant is
|
|
11
|
+
* `"arcgis"` when any service layer is present, else `"maplibre-gl"`.
|
|
12
|
+
*
|
|
13
|
+
* @param uuids - The UUIDs of the Sets and Trees the map links to, in order
|
|
14
|
+
* @param options - Options for the fetch
|
|
15
|
+
* @param options.languages - Language codes to parse
|
|
16
|
+
* @param options.fetch - The fetch function to use
|
|
17
|
+
* @returns The map variant and layers, or an error if the fetch/parse fails
|
|
18
|
+
*/
|
|
19
|
+
export declare function fetchMapLayers<const TLanguages extends ReadonlyArray<string> | undefined = undefined>(uuids: Array<string>, options?: FetchBaseOptions<TLanguages>): Promise<{
|
|
20
|
+
variant: "maplibre-gl" | "arcgis";
|
|
21
|
+
layers: Array<MapLayer<FetchLanguages<TLanguages>>>;
|
|
22
|
+
error: null;
|
|
23
|
+
detailedError: null;
|
|
24
|
+
} | {
|
|
25
|
+
variant: null;
|
|
26
|
+
layers: null;
|
|
27
|
+
error: string;
|
|
28
|
+
detailedError: string;
|
|
29
|
+
}>;
|
|
30
|
+
//#endregion
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { getErrorOutput } from "../errors.mjs";
|
|
2
|
+
import { requestOchre } from "./request.mjs";
|
|
3
|
+
import { uuidSchema } from "../schemas.mjs";
|
|
4
|
+
import { parseRequestedLanguages, resolveContentLanguages } from "../parsers/languages.mjs";
|
|
5
|
+
import { parseIdentification } from "../parsers/index.mjs";
|
|
6
|
+
import { XMLMapSourcesData } from "../xml/schemas.mjs";
|
|
7
|
+
import { OCHRE_RESPONSE_PADDING, compileOchreQuery, getContentLanguage, stringLiteral } from "../xquery.mjs";
|
|
8
|
+
import * as v from "valibot";
|
|
9
|
+
//#region src/fetchers/map-layers.ts
|
|
10
|
+
const REGEX_TILE_TEMPLATE_LEVEL = /\{(?:level|z)\}/i;
|
|
11
|
+
const REGEX_TILE_TEMPLATE_ROW = /\{(?:row|y)\}/i;
|
|
12
|
+
const REGEX_TILE_TEMPLATE_COLUMN = /\{(?:col|x)\}/i;
|
|
13
|
+
const REGEX_UNSUPPORTED_HOST = /(?:^|\.)google\.[a-z.]+$/i;
|
|
14
|
+
const REGEX_PORTAL_ITEM_PATH = /\/home\/(?:item|webmap\/viewer)\.html$/i;
|
|
15
|
+
const REGEX_PORTAL_ITEM_ID = /^[\da-f]{32}$/i;
|
|
16
|
+
const REGEX_WMTS_CAPABILITIES = /\/WMTSCapabilities\.xml$/i;
|
|
17
|
+
const REGEX_WMS_PATH = /\/wms(?:\/|$)/i;
|
|
18
|
+
const REGEX_FEATURE_SERVER = /\/FeatureServer(?:\/\d+)?\/?$/i;
|
|
19
|
+
const REGEX_MAP_SERVER = /\/MapServer(?:\/\d+)?\/?$/i;
|
|
20
|
+
const REGEX_IMAGE_SERVER = /\/ImageServer\/?$/i;
|
|
21
|
+
const REGEX_TRAILING_SLASH = /\/$/;
|
|
22
|
+
const REGEX_ARCGIS_SOAP_SERVICES = /\/arcgis\/services\//i;
|
|
23
|
+
/**
|
|
24
|
+
* Classify the href of a webpage Resource as a geospatial web service
|
|
25
|
+
* @param href - The Resource href
|
|
26
|
+
* @returns The service layer, or null when the href names no supported service
|
|
27
|
+
*/
|
|
28
|
+
function parseServiceLayer(href) {
|
|
29
|
+
const trimmedHref = href.trim();
|
|
30
|
+
const url = URL.parse(trimmedHref);
|
|
31
|
+
if (url == null || REGEX_UNSUPPORTED_HOST.test(url.hostname)) return null;
|
|
32
|
+
if (REGEX_TILE_TEMPLATE_LEVEL.test(trimmedHref) && REGEX_TILE_TEMPLATE_ROW.test(trimmedHref) && REGEX_TILE_TEMPLATE_COLUMN.test(trimmedHref)) return {
|
|
33
|
+
type: "web-tile",
|
|
34
|
+
url: trimmedHref
|
|
35
|
+
};
|
|
36
|
+
let service = null;
|
|
37
|
+
for (const [key, value] of url.searchParams) if (key.toLowerCase() === "service") service = value.toLowerCase();
|
|
38
|
+
const itemId = url.searchParams.get("webmap") ?? (REGEX_PORTAL_ITEM_PATH.test(url.pathname) ? url.searchParams.get("id") : null);
|
|
39
|
+
if (itemId != null && REGEX_PORTAL_ITEM_ID.test(itemId)) return {
|
|
40
|
+
type: "arcgis-item",
|
|
41
|
+
itemId,
|
|
42
|
+
portalUrl: url.origin
|
|
43
|
+
};
|
|
44
|
+
const baseUrl = `${url.origin}${url.pathname.replace(REGEX_TRAILING_SLASH, "")}`;
|
|
45
|
+
const restUrl = baseUrl.replace(REGEX_ARCGIS_SOAP_SERVICES, "/arcgis/rest/services/");
|
|
46
|
+
if (service === "wmts") return {
|
|
47
|
+
type: "wmts",
|
|
48
|
+
url: baseUrl
|
|
49
|
+
};
|
|
50
|
+
if (REGEX_WMTS_CAPABILITIES.test(url.pathname)) return {
|
|
51
|
+
type: "wmts",
|
|
52
|
+
url: trimmedHref
|
|
53
|
+
};
|
|
54
|
+
if (service === "wms" || REGEX_WMS_PATH.test(url.pathname)) return {
|
|
55
|
+
type: "wms",
|
|
56
|
+
url: baseUrl
|
|
57
|
+
};
|
|
58
|
+
if (REGEX_FEATURE_SERVER.test(url.pathname)) return {
|
|
59
|
+
type: "arcgis-feature",
|
|
60
|
+
url: restUrl
|
|
61
|
+
};
|
|
62
|
+
if (REGEX_MAP_SERVER.test(url.pathname)) return {
|
|
63
|
+
type: "arcgis-map",
|
|
64
|
+
url: restUrl
|
|
65
|
+
};
|
|
66
|
+
if (REGEX_IMAGE_SERVER.test(url.pathname)) return {
|
|
67
|
+
type: "arcgis-image",
|
|
68
|
+
url: restUrl
|
|
69
|
+
};
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Build the layer a Set, Tree or Resource of a map's layer list stands for
|
|
74
|
+
* @param member - The linked Set, Tree or Resource
|
|
75
|
+
* @param languages - The languages to parse
|
|
76
|
+
* @returns The layer, or null when a Resource names no supported service
|
|
77
|
+
*/
|
|
78
|
+
function parseMapLayer(member, languages) {
|
|
79
|
+
const { label } = parseIdentification(member.identification, { languages });
|
|
80
|
+
if (member.category === "set" || member.category === "tree") return {
|
|
81
|
+
type: member.category === "set" ? "ochre-set" : "ochre-tree",
|
|
82
|
+
uuid: member.uuid,
|
|
83
|
+
label,
|
|
84
|
+
wkid: member.WKID ?? null
|
|
85
|
+
};
|
|
86
|
+
const service = "href" in member && member.href != null ? parseServiceLayer(member.href) : null;
|
|
87
|
+
return service == null ? null : {
|
|
88
|
+
...service,
|
|
89
|
+
uuid: member.uuid,
|
|
90
|
+
label
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
async function fetchMapLayers(uuids, options) {
|
|
94
|
+
try {
|
|
95
|
+
const parsedUuids = v.parse(v.pipe(v.array(uuidSchema), v.minLength(1, "At least one map link UUID is required")), uuids);
|
|
96
|
+
const output = await requestOchre({
|
|
97
|
+
xquery: compileOchreQuery({
|
|
98
|
+
contentLanguage: getContentLanguage(options),
|
|
99
|
+
body: () => `<ochre>${OCHRE_RESPONSE_PADDING}<mapSources>{
|
|
100
|
+
for $uuid in (${parsedUuids.map((uuid) => stringLiteral(uuid)).join(", ")})
|
|
101
|
+
let $set := fn:collection("ochre/set")/ochre[@uuid = $uuid]/set
|
|
102
|
+
let $source := if (exists($set)) then $set else fn:collection("ochre/tree")/ochre[@uuid = $uuid]/tree
|
|
103
|
+
let $members := $set/items/*
|
|
104
|
+
let $layers := $members[self::set or self::tree or self::resource]
|
|
105
|
+
where exists($source)
|
|
106
|
+
return <mapSource uuid="{$uuid}" category="{local-name($source[1])}">{
|
|
107
|
+
$source[1]/@WKID,
|
|
108
|
+
$source[1]/identification,
|
|
109
|
+
if (exists($members) and count($layers) = count($members))
|
|
110
|
+
then
|
|
111
|
+
for $layer in $layers
|
|
112
|
+
let $layerUuid := $layer/@uuid/string()
|
|
113
|
+
return <mapLayer uuid="{$layerUuid}" category="{local-name($layer)}">{
|
|
114
|
+
$layer/@type,
|
|
115
|
+
$layer/@href,
|
|
116
|
+
if (local-name($layer) = "set")
|
|
117
|
+
then fn:collection("ochre/set")/ochre[@uuid = $layerUuid]/set[1]/@WKID
|
|
118
|
+
else (),
|
|
119
|
+
$layer/identification
|
|
120
|
+
}</mapLayer>
|
|
121
|
+
else ()
|
|
122
|
+
}</mapSource>
|
|
123
|
+
}</mapSources></ochre>`
|
|
124
|
+
}),
|
|
125
|
+
schema: XMLMapSourcesData,
|
|
126
|
+
label: "OCHRE map layers",
|
|
127
|
+
options
|
|
128
|
+
});
|
|
129
|
+
const languages = resolveContentLanguages(output.result.ochre.mapSources, parseRequestedLanguages(options?.languages));
|
|
130
|
+
const layers = [];
|
|
131
|
+
const layerUuids = /* @__PURE__ */ new Set();
|
|
132
|
+
const sources = output.result.ochre.mapSources.mapSource ?? [];
|
|
133
|
+
for (const source of sources) {
|
|
134
|
+
const sourceLayers = [];
|
|
135
|
+
const members = source.mapLayer ?? [source];
|
|
136
|
+
for (const member of members) {
|
|
137
|
+
const layer = parseMapLayer(member, languages);
|
|
138
|
+
if (layer != null) sourceLayers.push(layer);
|
|
139
|
+
}
|
|
140
|
+
const mapServerUrls = sourceLayers.flatMap((layer) => layer.type === "arcgis-map" ? [`${layer.url}/`] : []);
|
|
141
|
+
for (const layer of sourceLayers) if (!(layer.type === "wmts" && mapServerUrls.some((url) => layer.url.startsWith(url))) && !layerUuids.has(layer.uuid)) {
|
|
142
|
+
layerUuids.add(layer.uuid);
|
|
143
|
+
layers.push(layer);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
return {
|
|
147
|
+
variant: layers.some((layer) => layer.type !== "ochre-set" && layer.type !== "ochre-tree") ? "arcgis" : "maplibre-gl",
|
|
148
|
+
layers,
|
|
149
|
+
error: null,
|
|
150
|
+
detailedError: null
|
|
151
|
+
};
|
|
152
|
+
} catch (error) {
|
|
153
|
+
return {
|
|
154
|
+
variant: null,
|
|
155
|
+
layers: null,
|
|
156
|
+
...getErrorOutput(error, "Failed to fetch map layers")
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
//#endregion
|
|
161
|
+
export { fetchMapLayers };
|
|
@@ -29,7 +29,16 @@ function buildXQuery(abbreviation) {
|
|
|
29
29
|
return compileOchreQuery({ body: ({ omitSupplemental }) => `let $ochre := collection("ochre/tree")/ochre[tree/identification/abbreviation/content/string = ${stringLiteral(abbreviation)}][1]
|
|
30
30
|
return
|
|
31
31
|
if (empty($ochre)) then <ochre>${OCHRE_RESPONSE_PADDING}</ochre>
|
|
32
|
-
else element ochre {
|
|
32
|
+
else element ochre {
|
|
33
|
+
$ochre/@*,
|
|
34
|
+
${omitSupplemental("$ochre/node()")},
|
|
35
|
+
<styleLabels>{
|
|
36
|
+
for $style in $ochre/tree/styleOptions/style[@valueUuid]
|
|
37
|
+
let $value := (doc()/ochre[@uuidBelongsTo = $ochre/@uuidBelongsTo]//property[label/@uuid = $style/@variableUuid]/value[@uuid = $style/@valueUuid][content])[1]
|
|
38
|
+
where exists($value)
|
|
39
|
+
return <styleLabel valueUuid="{$style/@valueUuid}">{$value/content}</styleLabel>
|
|
40
|
+
}</styleLabels>
|
|
41
|
+
}` });
|
|
33
42
|
}
|
|
34
43
|
/**
|
|
35
44
|
* Fetches and parses a website configuration from the OCHRE API.
|
package/dist/index.d.mts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
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, WebRelationVariant, 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,
|
|
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, ItemLocation, ItemPayloadKind, ItemProperty, ItemWithoutEmbeddedItems, LanguageCodes, License, MapLayer, 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";
|
|
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
|
+
import { fetchItemLocations } from "./fetchers/item-locations.mjs";
|
|
8
9
|
import { fetchItemOcrData } from "./fetchers/item-ocr-data.mjs";
|
|
9
10
|
import { fetchItem } from "./fetchers/item.mjs";
|
|
10
|
-
import {
|
|
11
|
+
import { fetchMapLayers } from "./fetchers/map-layers.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";
|
|
@@ -17,4 +18,4 @@ import { PropertyOptions, PropertySelector, getLeafPropertyValues, getProperty,
|
|
|
17
18
|
import { flattenItemProperties } from "./helpers.mjs";
|
|
18
19
|
import { OCHRE_LANGUAGES, OchreLanguage, OchreLanguageCode, OchreLanguageKind, OchreLanguageStandard, getOchreLanguage, getOchreLanguageCode, isOchreLanguageCode } from "./languages.mjs";
|
|
19
20
|
import { defineLanguages } from "./parsers/languages.mjs";
|
|
20
|
-
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, OCHRE_LANGUAGES, type Observation, type OchreLanguage, type OchreLanguageCode, type OchreLanguageKind, type OchreLanguageStandard, 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
|
|
21
|
+
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 ItemLocation, type ItemPayloadKind, type ItemProperty, type ItemWithoutEmbeddedItems, type LanguageCodes, type License, type MapLayer, type Metadata, type MultilingualOptions, MultilingualString, type MultilingualStringEntries, type MultilingualStringEntry, type MultilingualStringInput, type MultilingualStringJSON, type MultilingualStringObject, type MultilingualStringText, type Note, OCHRE_LANGUAGES, type Observation, type OchreLanguage, type OchreLanguageCode, type OchreLanguageKind, type OchreLanguageStandard, 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 WebRelationVariant, 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, fetchItemLocations, fetchItemOcrData, fetchMapLayers, fetchSetItems, fetchSetPropertyValues, fetchTreeItems, fetchWebsite, fetchWebsiteMetadata, flattenItemProperties, getLeafPropertyValues, getOchreLanguage, getOchreLanguageCode, getProperty, getPropertyValue, getPropertyValues, getUniqueProperties, getUniquePropertyVariableLabels, isOchreLanguageCode, isPropertyMatchingFilter, normalizePropertyVariableLabel };
|
package/dist/index.mjs
CHANGED
|
@@ -7,12 +7,13 @@ import { defineLanguages } from "./parsers/languages.mjs";
|
|
|
7
7
|
import { fetchGallery } from "./fetchers/gallery.mjs";
|
|
8
8
|
import { fetchItemChildren } from "./fetchers/item-children.mjs";
|
|
9
9
|
import { fetchItemLinks } from "./fetchers/item-links.mjs";
|
|
10
|
+
import { fetchItemLocations } from "./fetchers/item-locations.mjs";
|
|
10
11
|
import { fetchItemOcrData } from "./fetchers/item-ocr-data.mjs";
|
|
11
12
|
import { fetchItem } from "./fetchers/item.mjs";
|
|
12
|
-
import {
|
|
13
|
+
import { fetchMapLayers } from "./fetchers/map-layers.mjs";
|
|
13
14
|
import { fetchSetItems } from "./fetchers/set/items.mjs";
|
|
14
15
|
import { fetchSetPropertyValues } from "./fetchers/set/property-values.mjs";
|
|
15
16
|
import { fetchTreeItems } from "./fetchers/tree/items.mjs";
|
|
16
17
|
import { fetchWebsiteMetadata } from "./fetchers/website-metadata.mjs";
|
|
17
18
|
import { fetchWebsite } from "./fetchers/website.mjs";
|
|
18
|
-
export { DEFAULT_PAGE_SIZE, MultilingualString, OCHRE_LANGUAGES, defineLanguages, fetchGallery, fetchItem, fetchItemChildren, fetchItemLinks, fetchItemOcrData,
|
|
19
|
+
export { DEFAULT_PAGE_SIZE, MultilingualString, OCHRE_LANGUAGES, defineLanguages, fetchGallery, fetchItem, fetchItemChildren, fetchItemLinks, fetchItemLocations, fetchItemOcrData, fetchMapLayers, fetchSetItems, fetchSetPropertyValues, fetchTreeItems, fetchWebsite, fetchWebsiteMetadata, flattenItemProperties, getLeafPropertyValues, getOchreLanguage, getOchreLanguageCode, getProperty, getPropertyValue, getPropertyValues, getUniqueProperties, getUniquePropertyVariableLabels, isOchreLanguageCode, isPropertyMatchingFilter, normalizePropertyVariableLabel };
|
package/dist/parsers/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Webpage } from "../types/website.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";
|
|
2
|
+
import { Bibliography, ContainedItemCategoryFromOption, ContainedItemCategoryOption, Coordinates, Gallery, Identification, Item, ItemCategory, ItemCategoryFromOption, ItemCategoryOption, ItemContainerCategory, ItemLinks, Metadata, Note, Person, Property, Resource, SetItem, SetItemCategory, SimplifiedProperty, SpatialUnit } from "../types/index.mjs";
|
|
3
|
+
import { XMLBibliography, XMLCoordinates, XMLData, XMLDataItem, XMLGalleryData, XMLIdentification, XMLItemLinks, XMLLink, XMLMetadata, XMLNote, XMLPerson, XMLProperty, XMLResource, XMLSetItems, XMLSimplifiedProperty, XMLSpatialUnit } 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"];
|
|
@@ -22,6 +22,7 @@ export declare function parseBibliographyList<T extends ReadonlyArray<string>>(r
|
|
|
22
22
|
bibliography: Array<XMLBibliography>;
|
|
23
23
|
} | undefined, options: ParserOptions<T>): Array<Bibliography<T, "embedded">>;
|
|
24
24
|
export declare function parsePersonList<T extends ReadonlyArray<string>>(rawPersons: Array<XMLPerson> | undefined, options: ParserOptions<T>): Array<Person<T, "embedded">>;
|
|
25
|
+
export declare function parseSpatialUnitMapData(mapData: XMLSpatialUnit["mapData"]): SpatialUnit<ReadonlyArray<string>, "embedded">["mapData"];
|
|
25
26
|
export declare function parseMetadata<T extends ReadonlyArray<string>>(rawOchre: {
|
|
26
27
|
uuidBelongsTo: string;
|
|
27
28
|
metadata: XMLMetadata;
|
package/dist/parsers/index.mjs
CHANGED
|
@@ -351,13 +351,22 @@ function parseCoordinatesSource(source, options) {
|
|
|
351
351
|
}
|
|
352
352
|
function parseCoordinate(coordinate, options) {
|
|
353
353
|
switch (coordinate.type) {
|
|
354
|
-
case "point":
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
354
|
+
case "point": {
|
|
355
|
+
const [x, y, z] = (coordinate.rawValue ?? "").split(",").map((part) => part.trim() === "" ? NaN : Number(part));
|
|
356
|
+
return {
|
|
357
|
+
type: "point",
|
|
358
|
+
latitude: coordinate.latitude,
|
|
359
|
+
longitude: coordinate.longitude,
|
|
360
|
+
altitude: coordinate.altitude ?? null,
|
|
361
|
+
crs: x != null && y != null && coordinate.WKID != null && coordinate.WKID !== 4326 && Number.isFinite(x) && Number.isFinite(y) ? {
|
|
362
|
+
wkid: coordinate.WKID,
|
|
363
|
+
x,
|
|
364
|
+
y,
|
|
365
|
+
z: z != null && Number.isFinite(z) ? z : null
|
|
366
|
+
} : null,
|
|
367
|
+
source: parseCoordinatesSource(coordinate.source, options)
|
|
368
|
+
};
|
|
369
|
+
}
|
|
361
370
|
case "plane": return {
|
|
362
371
|
type: "plane",
|
|
363
372
|
minimum: {
|
|
@@ -1229,4 +1238,4 @@ function parseItem(rawData, options) {
|
|
|
1229
1238
|
};
|
|
1230
1239
|
}
|
|
1231
1240
|
//#endregion
|
|
1232
|
-
export { getParserOptions, parseBibliographyList, parseCoordinates, parseGallery, parseIdentification, parseItem, parseLinkedItems, parseLinks, parseMetadata, parseNotes, parsePersonList, parseProperties, parseSetItems, parseSimplifiedProperties, parseStringLike };
|
|
1241
|
+
export { getParserOptions, parseBibliographyList, parseCoordinates, parseGallery, parseIdentification, parseItem, parseLinkedItems, parseLinks, parseMetadata, parseNotes, parsePersonList, parseProperties, parseSetItems, parseSimplifiedProperties, parseSpatialUnitMapData, parseStringLike };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { normalizeItemCategory } from "../../categories.mjs";
|
|
1
2
|
import { componentSchema } from "../../schemas.mjs";
|
|
2
3
|
import { parseXMLContent, transformPermanentIdentificationUrlToItemLink } from "../string.mjs";
|
|
3
4
|
import { parseStringContent } from "../helpers.mjs";
|
|
@@ -134,6 +135,8 @@ function parseAdvancedSearchComponent(parameters) {
|
|
|
134
135
|
const boundElementPropertyUuid = componentReader.uuid("bound-element");
|
|
135
136
|
const href = parseWebsiteLinkTarget(componentReader.valueNode("link-to"), pageSlugs);
|
|
136
137
|
if (boundElementPropertyUuid == null && href == null) throw new Error(formatComponentError("Bound element or href not found", "advanced-search", elementResource), { cause: componentProperty });
|
|
138
|
+
const prominentPropertyVariable = componentReader.valueNode("prominent-property-variable");
|
|
139
|
+
if (prominentPropertyVariable != null && (prominentPropertyVariable.uuid == null || normalizeItemCategory(prominentPropertyVariable.category ?? void 0) !== "propertyVariable")) throw new Error(formatComponentError("Prominent property variable must link to a property variable", "advanced-search", elementResource), { cause: prominentPropertyVariable });
|
|
137
140
|
const filter = { ...ADVANCED_SEARCH_FILTER_DEFAULTS };
|
|
138
141
|
componentReader.readAll(filter, {
|
|
139
142
|
sidebarSort: "filter-sidebar-sort",
|
|
@@ -144,6 +147,7 @@ function parseAdvancedSearchComponent(parameters) {
|
|
|
144
147
|
component: "advanced-search",
|
|
145
148
|
boundElementUuid: boundElementPropertyUuid,
|
|
146
149
|
href,
|
|
150
|
+
prominentPropertyVariableUuid: prominentPropertyVariable?.uuid ?? null,
|
|
147
151
|
filter,
|
|
148
152
|
options: parseWebsiteOptions(elementResource.options, options)
|
|
149
153
|
};
|
|
@@ -432,8 +436,9 @@ const MAP_COMPONENT_DEFAULTS = {
|
|
|
432
436
|
};
|
|
433
437
|
function parseMapComponent(parameters) {
|
|
434
438
|
const { componentProperty, componentReader, elementResource, websiteLinks } = parameters;
|
|
435
|
-
const
|
|
436
|
-
|
|
439
|
+
const linkUuids = [];
|
|
440
|
+
for (const link of websiteLinks) if (link.category === "set" || link.category === "tree") linkUuids.push(link.uuid);
|
|
441
|
+
if (linkUuids.length === 0) throw new Error(formatComponentError("Map link not found", "map", elementResource), { cause: componentProperty });
|
|
437
442
|
const properties = { ...MAP_COMPONENT_DEFAULTS };
|
|
438
443
|
componentReader.readAll(properties, {
|
|
439
444
|
isInteractive: "is-interactive",
|
|
@@ -452,7 +457,7 @@ function parseMapComponent(parameters) {
|
|
|
452
457
|
if (maximumBoundsProperty !== null) maximumBounds = parseBounds(String(maximumBoundsProperty));
|
|
453
458
|
return {
|
|
454
459
|
component: "map",
|
|
455
|
-
|
|
460
|
+
linkUuids,
|
|
456
461
|
boundElementUuid: componentReader.uuid("bound-element"),
|
|
457
462
|
customBasemap,
|
|
458
463
|
initialBounds,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { cleanObject, parseLicense } from "../helpers.mjs";
|
|
1
|
+
import { cleanObject, parseLicense, parseRequiredContentLike } from "../helpers.mjs";
|
|
2
2
|
import { parseMetadataLanguages, resolveDefaultLanguage, resolveLanguages } from "../languages.mjs";
|
|
3
3
|
import { parseIdentification, parseLinks, parseMetadata, parsePersonList, parseSimplifiedProperties } from "../index.mjs";
|
|
4
4
|
import { findWebsiteLink, parseWebsiteLinkTarget, webImageFromLink } from "./links.mjs";
|
|
@@ -306,13 +306,16 @@ function parseWebsite(data, options) {
|
|
|
306
306
|
};
|
|
307
307
|
const websiteTree = rawOchre.tree[0];
|
|
308
308
|
if (websiteTree == null) throw new Error("Website tree not found", { cause: data });
|
|
309
|
-
|
|
309
|
+
const website = parseWebsiteTree(websiteTree, parserOptions, {
|
|
310
310
|
belongsTo: {
|
|
311
311
|
uuid: rawOchre.uuidBelongsTo,
|
|
312
312
|
abbreviation: rawOchre.belongsTo
|
|
313
313
|
},
|
|
314
314
|
metadata: parseMetadata(rawOchre, parserOptions, defaultLanguage)
|
|
315
315
|
}, "website");
|
|
316
|
+
const styleLabels = new Map((rawOchre.styleLabels?.styleLabel ?? []).map((styleLabel) => [styleLabel.valueUuid, parseRequiredContentLike(styleLabel, parserOptions)]));
|
|
317
|
+
for (const stylesheet of website.properties.options.stylesheets.properties) if (stylesheet.category === "propertyValue") stylesheet.label = styleLabels.get(stylesheet.uuid) ?? null;
|
|
318
|
+
return website;
|
|
316
319
|
}
|
|
317
320
|
//#endregion
|
|
318
321
|
export { parseWebpageView, parseWebsite };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ResponsiveStyles, StylesheetItem } from "../../types/website.mjs";
|
|
2
|
-
import { SimplifiedProperty } from "../../types/index.mjs";
|
|
2
|
+
import { LanguageCodes, SimplifiedProperty } from "../../types/index.mjs";
|
|
3
3
|
import { XMLWebsiteStyle } from "../../xml/types.mjs";
|
|
4
4
|
//#region src/parsers/website/styles.d.ts
|
|
5
5
|
/**
|
|
@@ -24,5 +24,5 @@ export declare function emptyResponsiveStyles(): ResponsiveStyles;
|
|
|
24
24
|
* @returns The parsed stylesheet items
|
|
25
25
|
* @internal
|
|
26
26
|
*/
|
|
27
|
-
export declare function parseStylesheets(styles: Array<XMLWebsiteStyle>): Array<StylesheetItem
|
|
27
|
+
export declare function parseStylesheets<T extends LanguageCodes>(styles: Array<XMLWebsiteStyle>): Array<StylesheetItem<T>>;
|
|
28
28
|
//#endregion
|
package/dist/schemas.d.mts
CHANGED
|
@@ -100,15 +100,24 @@ export declare const setItemsParametersSchema: v.ObjectSchema<{
|
|
|
100
100
|
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">]>;
|
|
101
101
|
}, undefined>;
|
|
102
102
|
/**
|
|
103
|
-
* Schema for validating the parameters of the
|
|
103
|
+
* Schema for validating the parameters of the item locations fetching function
|
|
104
104
|
* @internal
|
|
105
105
|
*/
|
|
106
|
-
export declare const
|
|
107
|
-
readonly setScopeUuids: v.
|
|
106
|
+
export declare const itemLocationsParametersSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
107
|
+
readonly setScopeUuids: v.OptionalSchema<v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.CheckAction<string, "Invalid pseudo-UUID">]>, undefined>, readonly []>;
|
|
108
|
+
readonly treeScopeUuids: v.OptionalSchema<v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.CheckAction<string, "Invalid pseudo-UUID">]>, undefined>, readonly []>;
|
|
108
109
|
readonly belongsToCollectionScopeUuids: v.OptionalSchema<v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.CheckAction<string, "Invalid pseudo-UUID">]>, undefined>, readonly []>;
|
|
109
110
|
readonly queries: v.OptionalSchema<v.NullableSchema<v.GenericSchema<unknown, Query>, undefined>, null>;
|
|
110
111
|
readonly propertyVariableUuids: v.OptionalSchema<v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.CheckAction<string, "Invalid pseudo-UUID">]>, undefined>, readonly []>;
|
|
111
|
-
|
|
112
|
+
readonly isMapDataIncluded: v.OptionalSchema<v.BooleanSchema<undefined>, false>;
|
|
113
|
+
}, undefined>, v.CheckAction<{
|
|
114
|
+
setScopeUuids: string[];
|
|
115
|
+
treeScopeUuids: string[];
|
|
116
|
+
belongsToCollectionScopeUuids: string[];
|
|
117
|
+
queries: Query | null;
|
|
118
|
+
propertyVariableUuids: string[];
|
|
119
|
+
isMapDataIncluded: boolean;
|
|
120
|
+
}, "At least one Set or Tree scope UUID is required">]>;
|
|
112
121
|
export declare const treeItemsParametersSchema: v.ObjectSchema<{
|
|
113
122
|
readonly belongsToCollectionScopeUuids: v.OptionalSchema<v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.CheckAction<string, "Invalid pseudo-UUID">]>, undefined>, readonly []>;
|
|
114
123
|
readonly queries: v.OptionalSchema<v.NullableSchema<v.GenericSchema<unknown, Query>, undefined>, null>;
|