ochre-sdk 1.3.0 → 1.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/fetchers/set/item-locations.d.mts +1 -1
- package/dist/fetchers/set/item-locations.mjs +2 -0
- package/dist/fetchers/set/property-values.mjs +28 -36
- package/dist/types/index.d.mts +5 -0
- package/dist/xml/schemas.d.mts +1 -0
- package/dist/xml/schemas.mjs +1 -0
- package/dist/xml/types.d.mts +1 -0
- package/package.json +1 -1
|
@@ -4,7 +4,7 @@ import { FetchBaseOptions, FetchLanguages } from "../../parsers/helpers.mjs";
|
|
|
4
4
|
/**
|
|
5
5
|
* Fetches the location of every Set item that matches a query, without paging
|
|
6
6
|
*
|
|
7
|
-
* Each item carries only its identification, its coordinates and the values of
|
|
7
|
+
* Each item carries only its identification, its publication date, its coordinates and the values of
|
|
8
8
|
* the requested property variables (inherited values included), which is what a
|
|
9
9
|
* map needs to draw and colour every match while a list pages through the same
|
|
10
10
|
* query with {@link fetchSetItems}.
|
|
@@ -24,6 +24,7 @@ async function fetchSetItemLocations(parameters, options) {
|
|
|
24
24
|
return <items totalCount="{count(${items})}">{
|
|
25
25
|
for $item in ${items}
|
|
26
26
|
return <itemLocation uuid="{$item/@uuid}" category="{local-name($item)}">{
|
|
27
|
+
$item/@publicationDateTime,
|
|
27
28
|
$item/identification,
|
|
28
29
|
$item/coordinates,
|
|
29
30
|
for $value in $item//properties//property[label/@uuid = $propertyVariableUuids]/value[@uuid]
|
|
@@ -57,6 +58,7 @@ async function fetchSetItemLocations(parameters, options) {
|
|
|
57
58
|
itemsByUuid.set(itemLocation.uuid, {
|
|
58
59
|
uuid: itemLocation.uuid,
|
|
59
60
|
category,
|
|
61
|
+
publicationDateTime: itemLocation.publicationDateTime ?? null,
|
|
60
62
|
identification: parseIdentification(itemLocation.identification, { languages }),
|
|
61
63
|
coordinates: parseCoordinates(itemLocation.coordinates, { languages }),
|
|
62
64
|
propertyValues
|
|
@@ -124,12 +124,13 @@ const propertyValueQueryItemSchema = v.pipe(v.object({
|
|
|
124
124
|
const attributeValueQueryItemSchema = v.pipe(v.object({
|
|
125
125
|
attributeType: v.picklist(["bibliographies", "periods"]),
|
|
126
126
|
count: countSchema,
|
|
127
|
-
|
|
128
|
-
|
|
127
|
+
key: v.optional(v.string()),
|
|
128
|
+
content: v.optional(v.array(propertyValueLabelContentSchema))
|
|
129
129
|
}), v.transform((value) => ({
|
|
130
130
|
attributeType: value.attributeType,
|
|
131
131
|
count: value.count,
|
|
132
|
-
content: value.
|
|
132
|
+
content: value.key != null && value.key !== "" ? value.key : null,
|
|
133
|
+
label: parsePropertyValueLabel(value.content, value.key)
|
|
133
134
|
})));
|
|
134
135
|
/**
|
|
135
136
|
* Schema for the property values OCHRE API response
|
|
@@ -327,45 +328,35 @@ let $property-values :=
|
|
|
327
328
|
)`);
|
|
328
329
|
returnedSequences.push("$property-values");
|
|
329
330
|
}
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
let
|
|
331
|
+
for (const [attributeType, attributePath] of [["bibliographies", "bibliographies/bibliography"], ["periods", "periods/period"]]) {
|
|
332
|
+
if (!attributes[attributeType]) continue;
|
|
333
|
+
queryBlocks.push(`let $${attributeType}-counts := map:map()
|
|
334
|
+
let $${attributeType}-labels := map:map()
|
|
335
|
+
let $_${attributeType}-aggregation := xdmp:eager(
|
|
333
336
|
for $item in ${items}
|
|
334
337
|
let $seen := map:map()
|
|
335
338
|
return
|
|
336
|
-
for $
|
|
337
|
-
let $label :=
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
return <attributeValue attributeType="bibliographies" count="{map:get($bibliography-counts, $label)}" content="{$label}" />
|
|
347
|
-
)`);
|
|
348
|
-
returnedSequences.push("$bibliography-values");
|
|
349
|
-
}
|
|
350
|
-
if (attributes.periods) {
|
|
351
|
-
queryBlocks.push(`let $period-counts := map:map()
|
|
352
|
-
let $_period-aggregation := xdmp:eager(
|
|
353
|
-
for $item in ${items}
|
|
354
|
-
let $seen := map:map()
|
|
355
|
-
return
|
|
356
|
-
for $period in $item/periods/period${notSupplemental}
|
|
357
|
-
let $label := string-join($period/identification/label/content[@xml:lang=${languageLiteral}]//text(), "")
|
|
358
|
-
where string-length($label) gt 0
|
|
359
|
-
return local:add-attribute-facet($period-counts, $seen, $label)
|
|
339
|
+
for $attribute in $item/${attributePath}${notSupplemental}
|
|
340
|
+
let $label := $attribute/identification/label
|
|
341
|
+
let $key := string-join($label/content[@xml:lang=${languageLiteral}]//text(), "")
|
|
342
|
+
where string-length($key) gt 0
|
|
343
|
+
return (
|
|
344
|
+
if (empty(map:get($${attributeType}-labels, $key)))
|
|
345
|
+
then map:put($${attributeType}-labels, $key, local:value-label-content($label))
|
|
346
|
+
else (),
|
|
347
|
+
local:add-attribute-facet($${attributeType}-counts, $seen, $key)
|
|
348
|
+
)
|
|
360
349
|
)
|
|
361
350
|
|
|
362
|
-
let
|
|
351
|
+
let $${attributeType}-values :=
|
|
363
352
|
(
|
|
364
|
-
$
|
|
365
|
-
for $
|
|
366
|
-
return <attributeValue attributeType="
|
|
353
|
+
$_${attributeType}-aggregation,
|
|
354
|
+
for $key in map:keys($${attributeType}-counts)
|
|
355
|
+
return <attributeValue attributeType="${attributeType}" count="{map:get($${attributeType}-counts, $key)}" key="{$key}">{
|
|
356
|
+
map:get($${attributeType}-labels, $key)
|
|
357
|
+
}</attributeValue>
|
|
367
358
|
)`);
|
|
368
|
-
returnedSequences.push(
|
|
359
|
+
returnedSequences.push(`$${attributeType}-values`);
|
|
369
360
|
}
|
|
370
361
|
return queryBlocks;
|
|
371
362
|
}
|
|
@@ -426,7 +417,8 @@ function collectAttributeValues(parsedAttributeValues) {
|
|
|
426
417
|
if (attributeValue.content == null || attributeValue.content === "") continue;
|
|
427
418
|
attributeValuesByType[attributeValue.attributeType].push({
|
|
428
419
|
count: attributeValue.count,
|
|
429
|
-
content: attributeValue.content
|
|
420
|
+
content: attributeValue.content,
|
|
421
|
+
label: attributeValue.label
|
|
430
422
|
});
|
|
431
423
|
}
|
|
432
424
|
return attributeValuesByType;
|
package/dist/types/index.d.mts
CHANGED
|
@@ -571,6 +571,7 @@ export type SetItem<U extends SetItemCategory = SetItemCategory, T extends Langu
|
|
|
571
571
|
export type SetItemLocation<T extends LanguageCodes = LanguageCodes> = {
|
|
572
572
|
uuid: string;
|
|
573
573
|
category: SetItemCategory;
|
|
574
|
+
publicationDateTime: Date | null;
|
|
574
575
|
identification: Identification<T>;
|
|
575
576
|
coordinates: Array<Coordinates<T>>;
|
|
576
577
|
propertyValues: Array<{
|
|
@@ -794,10 +795,14 @@ export type PropertyValueQueryItem = {
|
|
|
794
795
|
};
|
|
795
796
|
/**
|
|
796
797
|
* Represents a grouped Set attribute value query item
|
|
798
|
+
*
|
|
799
|
+
* `content` is the label in the requested language, which facet queries match
|
|
800
|
+
* on; `label` carries the label in every language for display.
|
|
797
801
|
*/
|
|
798
802
|
export type SetAttributeValueQueryItem = {
|
|
799
803
|
count: number;
|
|
800
804
|
content: string;
|
|
805
|
+
label: MultilingualString | null;
|
|
801
806
|
};
|
|
802
807
|
/**
|
|
803
808
|
* Represents sorting direction for Set items
|
package/dist/xml/schemas.d.mts
CHANGED
|
@@ -4119,6 +4119,7 @@ export declare const XMLSetItemLocationsData: v.ObjectSchema<{
|
|
|
4119
4119
|
readonly itemLocation: v.OptionalSchema<v.ArraySchema<v.ObjectSchema<{
|
|
4120
4120
|
readonly uuid: v.StringSchema<"XMLSetItemLocation: uuid is string and required">;
|
|
4121
4121
|
readonly category: v.StringSchema<"XMLSetItemLocation: category is string and required">;
|
|
4122
|
+
readonly publicationDateTime: v.OptionalSchema<v.GenericSchema<unknown, Date>, undefined>;
|
|
4122
4123
|
readonly identification: v.ObjectSchema<{
|
|
4123
4124
|
readonly label: v.UnionSchema<[v.ObjectSchema<{
|
|
4124
4125
|
readonly content: v.ArraySchema<v.ObjectSchema<{
|
package/dist/xml/schemas.mjs
CHANGED
|
@@ -931,6 +931,7 @@ const XMLSetItemsData = v.object({ result: v.object({ ochre: v.object({ items: X
|
|
|
931
931
|
const XMLSetItemLocation = v.object({
|
|
932
932
|
uuid: v.string("XMLSetItemLocation: uuid is string and required"),
|
|
933
933
|
category: v.string("XMLSetItemLocation: category is string and required"),
|
|
934
|
+
publicationDateTime: v.optional(customDateTime("XMLSetItemLocation: publicationDateTime is not a valid datetime")),
|
|
934
935
|
identification: XMLIdentification,
|
|
935
936
|
coordinates: v.optional(XMLCoordinates),
|
|
936
937
|
value: v.optional(v.array(v.intersect([v.object({
|
package/dist/xml/types.d.mts
CHANGED