ochre-sdk 1.3.12 → 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 +4 -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 +4 -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/dist/xml/types.d.mts
CHANGED
|
@@ -139,6 +139,8 @@ export type XMLCoordinate = {
|
|
|
139
139
|
latitude: number;
|
|
140
140
|
longitude: number;
|
|
141
141
|
altitude?: number;
|
|
142
|
+
WKID?: number;
|
|
143
|
+
rawValue?: string;
|
|
142
144
|
source?: XMLCoordinatesSource;
|
|
143
145
|
} | {
|
|
144
146
|
type: "plane";
|
|
@@ -887,23 +889,49 @@ export type XMLSetItemsData = {
|
|
|
887
889
|
};
|
|
888
890
|
};
|
|
889
891
|
};
|
|
890
|
-
export type
|
|
892
|
+
export type XMLItemLocation = {
|
|
891
893
|
uuid: string;
|
|
892
894
|
category: string;
|
|
895
|
+
scopeUuid: string;
|
|
893
896
|
publicationDateTime?: Date;
|
|
894
897
|
identification: XMLIdentification;
|
|
895
898
|
coordinates?: XMLCoordinates;
|
|
899
|
+
mapData?: XMLSpatialUnit["mapData"];
|
|
896
900
|
value?: Array<{
|
|
897
901
|
variable: string;
|
|
898
902
|
uuid: string;
|
|
899
903
|
} & XMLContent>;
|
|
900
904
|
};
|
|
901
|
-
export type
|
|
905
|
+
export type XMLItemLocationsData = {
|
|
902
906
|
result: {
|
|
903
907
|
ochre: {
|
|
904
908
|
items: {
|
|
905
909
|
totalCount: number;
|
|
906
|
-
itemLocation?: Array<
|
|
910
|
+
itemLocation?: Array<XMLItemLocation>;
|
|
911
|
+
};
|
|
912
|
+
};
|
|
913
|
+
};
|
|
914
|
+
};
|
|
915
|
+
export type XMLMapLayer = {
|
|
916
|
+
uuid: string;
|
|
917
|
+
category: string;
|
|
918
|
+
type?: string;
|
|
919
|
+
href?: string;
|
|
920
|
+
WKID?: number;
|
|
921
|
+
identification: XMLIdentification;
|
|
922
|
+
};
|
|
923
|
+
export type XMLMapSource = {
|
|
924
|
+
uuid: string;
|
|
925
|
+
category: string;
|
|
926
|
+
WKID?: number;
|
|
927
|
+
identification: XMLIdentification;
|
|
928
|
+
mapLayer?: Array<XMLMapLayer>;
|
|
929
|
+
};
|
|
930
|
+
export type XMLMapSourcesData = {
|
|
931
|
+
result: {
|
|
932
|
+
ochre: {
|
|
933
|
+
mapSources: {
|
|
934
|
+
mapSource?: Array<XMLMapSource>;
|
|
907
935
|
};
|
|
908
936
|
};
|
|
909
937
|
};
|
|
@@ -930,6 +958,11 @@ export type XMLWebsiteData = {
|
|
|
930
958
|
metadata: XMLMetadata;
|
|
931
959
|
persistentUrl?: string;
|
|
932
960
|
tree: Array<XMLWebsiteTree>;
|
|
961
|
+
styleLabels?: {
|
|
962
|
+
styleLabel?: Array<{
|
|
963
|
+
valueUuid: string;
|
|
964
|
+
} & XMLContent>;
|
|
965
|
+
};
|
|
933
966
|
};
|
|
934
967
|
};
|
|
935
968
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ochre-sdk",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.13",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "Node.js library for working with OCHRE (Online Cultural and Historical Research Environment) data",
|
|
@@ -66,8 +66,8 @@
|
|
|
66
66
|
"scripts": {
|
|
67
67
|
"dev": "tsdown src/index.ts --watch",
|
|
68
68
|
"build": "tsdown",
|
|
69
|
-
"lint": "knip && eslint
|
|
70
|
-
"lint:fix": "knip --fix && eslint --
|
|
69
|
+
"lint": "knip && eslint .",
|
|
70
|
+
"lint:fix": "knip --fix && eslint --fix .",
|
|
71
71
|
"format": "oxfmt --check",
|
|
72
72
|
"format:fix": "oxfmt",
|
|
73
73
|
"check-types": "tsc --noEmit",
|
|
@@ -1,35 +0,0 @@
|
|
|
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 publication date, 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
|
|
@@ -1,83 +0,0 @@
|
|
|
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 { getContentLanguage, 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
|
-
contentLanguage: getContentLanguage(options),
|
|
23
|
-
body: ({ items }) => ` let $propertyVariableUuids := (${Array.from(propertyVariableUuids, (uuid) => stringLiteral(uuid)).join(", ")})
|
|
24
|
-
|
|
25
|
-
return <items totalCount="{count(${items})}">{
|
|
26
|
-
for $item in ${items}
|
|
27
|
-
return <itemLocation uuid="{$item/@uuid}" category="{local-name($item)}">{
|
|
28
|
-
$item/@publicationDateTime,
|
|
29
|
-
$item/identification,
|
|
30
|
-
$item/coordinates,
|
|
31
|
-
for $value in $item//properties//property[label/@uuid = $propertyVariableUuids]/value[@uuid]
|
|
32
|
-
return <value variable="{$value/../label/@uuid}" uuid="{$value/@uuid}">{$value/content}</value>
|
|
33
|
-
}</itemLocation>
|
|
34
|
-
}</items>`
|
|
35
|
-
}),
|
|
36
|
-
schema: XMLSetItemLocationsData,
|
|
37
|
-
label: "OCHRE Set item locations",
|
|
38
|
-
options
|
|
39
|
-
});
|
|
40
|
-
const languages = resolveContentLanguages(output.result.ochre.items, parseRequestedLanguages(options?.languages));
|
|
41
|
-
const itemsByUuid = /* @__PURE__ */ new Map();
|
|
42
|
-
const itemLocations = output.result.ochre.items.itemLocation ?? [];
|
|
43
|
-
for (const itemLocation of itemLocations) {
|
|
44
|
-
const category = normalizeItemCategory(itemLocation.category);
|
|
45
|
-
if (category == null || itemsByUuid.has(itemLocation.uuid)) continue;
|
|
46
|
-
const propertyValues = [];
|
|
47
|
-
const seenPropertyValues = /* @__PURE__ */ new Set();
|
|
48
|
-
const values = itemLocation.value ?? [];
|
|
49
|
-
for (const value of values) {
|
|
50
|
-
const key = `${value.variable}:${value.uuid}`;
|
|
51
|
-
if (seenPropertyValues.has(key)) continue;
|
|
52
|
-
seenPropertyValues.add(key);
|
|
53
|
-
propertyValues.push({
|
|
54
|
-
variableUuid: value.variable,
|
|
55
|
-
valueUuid: value.uuid,
|
|
56
|
-
label: parseRequiredContentLike(value, { languages })
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
itemsByUuid.set(itemLocation.uuid, {
|
|
60
|
-
uuid: itemLocation.uuid,
|
|
61
|
-
category,
|
|
62
|
-
publicationDateTime: itemLocation.publicationDateTime ?? null,
|
|
63
|
-
identification: parseIdentification(itemLocation.identification, { languages }),
|
|
64
|
-
coordinates: parseCoordinates(itemLocation.coordinates, { languages }),
|
|
65
|
-
propertyValues
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
return {
|
|
69
|
-
totalCount: output.result.ochre.items.totalCount,
|
|
70
|
-
items: itemsByUuid.values().toArray(),
|
|
71
|
-
error: null,
|
|
72
|
-
detailedError: null
|
|
73
|
-
};
|
|
74
|
-
} catch (error) {
|
|
75
|
-
return {
|
|
76
|
-
totalCount: null,
|
|
77
|
-
items: null,
|
|
78
|
-
...getErrorOutput(error, "Failed to fetch Set item locations")
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
//#endregion
|
|
83
|
-
export { fetchSetItemLocations };
|