ochre-sdk 1.3.12 → 1.3.14
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/categories.d.mts +1 -3
- package/dist/categories.mjs +1 -2
- package/dist/constants.d.mts +1 -3
- package/dist/constants.mjs +14 -4
- package/dist/errors.d.mts +0 -2
- package/dist/errors.mjs +1 -2
- package/dist/fetchers/container-items.d.mts +1 -3
- package/dist/fetchers/container-items.mjs +1 -2
- package/dist/fetchers/gallery.d.mts +1 -3
- package/dist/fetchers/gallery.mjs +1 -2
- package/dist/fetchers/item-children.d.mts +0 -2
- package/dist/fetchers/item-children.mjs +1 -2
- package/dist/fetchers/item-links.d.mts +1 -3
- package/dist/fetchers/item-links.mjs +1 -2
- package/dist/fetchers/item-locations.d.mts +39 -0
- package/dist/fetchers/item-locations.mjs +98 -0
- package/dist/fetchers/item-ocr-data.d.mts +1 -3
- package/dist/fetchers/item-ocr-data.mjs +1 -2
- package/dist/fetchers/item.d.mts +0 -2
- package/dist/fetchers/item.mjs +1 -2
- package/dist/fetchers/map-layers.d.mts +28 -0
- package/dist/fetchers/map-layers.mjs +160 -0
- package/dist/fetchers/request.d.mts +1 -3
- package/dist/fetchers/request.mjs +1 -2
- package/dist/fetchers/set/items.d.mts +0 -2
- package/dist/fetchers/set/items.mjs +1 -2
- package/dist/fetchers/set/property-values.d.mts +1 -3
- package/dist/fetchers/set/property-values.mjs +1 -2
- package/dist/fetchers/tree/items.d.mts +0 -2
- package/dist/fetchers/tree/items.mjs +1 -2
- package/dist/fetchers/website-metadata.d.mts +1 -3
- package/dist/fetchers/website-metadata.mjs +1 -2
- package/dist/fetchers/website.d.mts +1 -3
- package/dist/fetchers/website.mjs +11 -3
- package/dist/getters.d.mts +0 -2
- package/dist/getters.mjs +1 -2
- package/dist/helpers.d.mts +0 -2
- package/dist/helpers.mjs +1 -2
- package/dist/index.d.mts +4 -3
- package/dist/index.mjs +3 -2
- package/dist/languages.d.mts +1 -3
- package/dist/languages.mjs +1 -2
- package/dist/ocr.d.mts +1 -3
- package/dist/ocr.mjs +1 -2
- package/dist/parsers/helpers.d.mts +1 -3
- package/dist/parsers/helpers.mjs +1 -2
- package/dist/parsers/index.d.mts +3 -4
- package/dist/parsers/index.mjs +28 -10
- package/dist/parsers/languages.d.mts +1 -3
- package/dist/parsers/languages.mjs +1 -2
- package/dist/parsers/mdx.d.mts +1 -3
- package/dist/parsers/mdx.mjs +1 -2
- package/dist/parsers/multilingual.d.mts +0 -2
- package/dist/parsers/multilingual.mjs +1 -2
- package/dist/parsers/property-token.d.mts +0 -2
- package/dist/parsers/property-token.mjs +1 -2
- package/dist/parsers/string.d.mts +1 -3
- package/dist/parsers/string.mjs +1 -2
- package/dist/parsers/website/bounds.d.mts +1 -3
- package/dist/parsers/website/bounds.mjs +1 -2
- package/dist/parsers/website/components.d.mts +0 -2
- package/dist/parsers/website/components.mjs +5 -5
- package/dist/parsers/website/index.d.mts +1 -3
- package/dist/parsers/website/index.mjs +6 -4
- package/dist/parsers/website/links.d.mts +1 -3
- package/dist/parsers/website/links.mjs +1 -2
- package/dist/parsers/website/messages.d.mts +1 -3
- package/dist/parsers/website/messages.mjs +1 -2
- package/dist/parsers/website/options.d.mts +1 -3
- package/dist/parsers/website/options.mjs +1 -2
- package/dist/parsers/website/properties.d.mts +1 -3
- package/dist/parsers/website/properties.mjs +1 -2
- package/dist/parsers/website/reader.d.mts +0 -2
- package/dist/parsers/website/reader.mjs +1 -2
- package/dist/parsers/website/slug.d.mts +1 -3
- package/dist/parsers/website/slug.mjs +1 -2
- package/dist/parsers/website/styles.d.mts +2 -4
- package/dist/parsers/website/styles.mjs +2 -2
- package/dist/parsers/website/walk.d.mts +1 -3
- package/dist/parsers/website/walk.mjs +1 -2
- package/dist/query.d.mts +0 -2
- package/dist/query.mjs +1 -2
- package/dist/reflection.d.mts +1 -3
- package/dist/reflection.mjs +1 -2
- package/dist/schemas.d.mts +14 -7
- package/dist/schemas.mjs +9 -8
- package/dist/types/index.d.mts +41 -3
- package/dist/types/utilities.d.mts +1 -3
- package/dist/types/website.d.mts +5 -6
- package/dist/xml/dates.d.mts +1 -3
- package/dist/xml/dates.mjs +1 -2
- package/dist/xml/metadata.d.mts +1 -3
- package/dist/xml/metadata.mjs +1 -2
- package/dist/xml/schemas.d.mts +351 -13
- package/dist/xml/schemas.mjs +53 -19
- package/dist/xml/types.d.mts +47 -6
- package/dist/xquery.d.mts +1 -3
- package/dist/xquery.mjs +1 -2
- package/package.json +9 -8
- package/dist/fetchers/set/item-locations.d.mts +0 -35
- package/dist/fetchers/set/item-locations.mjs +0 -83
package/dist/xml/schemas.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import { readArrayProperty } from "../reflection.mjs";
|
|
|
2
2
|
import { isPseudoUuid } from "../schemas.mjs";
|
|
3
3
|
import { parseDateTime } from "./dates.mjs";
|
|
4
4
|
import * as v from "valibot";
|
|
5
|
-
|
|
5
|
+
// src/xml/schemas.ts
|
|
6
6
|
function getXMLStringPayload(value) {
|
|
7
7
|
return typeof value === "string" ? value : value.payload ?? null;
|
|
8
8
|
}
|
|
@@ -191,6 +191,8 @@ const XMLCoordinate = v.variant("type", [v.object({
|
|
|
191
191
|
latitude: XMLNumber,
|
|
192
192
|
longitude: XMLNumber,
|
|
193
193
|
altitude: XMLOptionalNumber,
|
|
194
|
+
WKID: XMLOptionalNumber,
|
|
195
|
+
rawValue: v.optional(v.string("XMLCoordinates: rawValue is string and optional")),
|
|
194
196
|
source: v.optional(XMLCoordinatesSource)
|
|
195
197
|
}, "XMLCoordinates: Shape error"), v.object({
|
|
196
198
|
type: v.literal("plane", "XMLCoordinates: type is plane"),
|
|
@@ -205,6 +207,10 @@ const XMLCoordinate = v.variant("type", [v.object({
|
|
|
205
207
|
source: v.optional(XMLCoordinatesSource)
|
|
206
208
|
}, "XMLCoordinates: Shape error")], "XMLCoordinates: Shape error");
|
|
207
209
|
const XMLCoordinates = v.object({ coord: v.array(XMLCoordinate) }, "XMLCoordinates: Shape error");
|
|
210
|
+
const XMLMapData = v.optional(v.object({ geoJSON: v.object({
|
|
211
|
+
multiPolygon: v.object({ payload: v.string("XMLMapData: multiPolygon is string and required") }),
|
|
212
|
+
EPSG: XMLNumber
|
|
213
|
+
}) }, "XMLMapData: mapData is object with geoJSON"));
|
|
208
214
|
const XMLImage = v.object({
|
|
209
215
|
publicationDateTime: v.optional(customDateTime("XMLImage: publicationDateTime is not a valid datetime")),
|
|
210
216
|
identification: v.optional(XMLIdentification),
|
|
@@ -215,6 +221,16 @@ const XMLImage = v.object({
|
|
|
215
221
|
fileSize: XMLOptionalNumber,
|
|
216
222
|
payload: v.optional(v.string("XMLImage: payload is string and optional"))
|
|
217
223
|
}, "XMLImage: Shape error");
|
|
224
|
+
const XMLDownloadOptions = v.object({ option: v.array(v.object({
|
|
225
|
+
type: v.picklist([
|
|
226
|
+
"highQualityImage",
|
|
227
|
+
"iiifManifest",
|
|
228
|
+
"document",
|
|
229
|
+
"ocr"
|
|
230
|
+
], "XMLDownloadOptions: type is highQualityImage, iiifManifest, document, or ocr"),
|
|
231
|
+
href: v.pipe(v.string("XMLDownloadOptions: href is string and required"), v.url("XMLDownloadOptions: href is not a valid URL")),
|
|
232
|
+
fileFormat: v.string("XMLDownloadOptions: fileFormat is string and required")
|
|
233
|
+
}, "XMLDownloadOptions: option is object with type, href, and fileFormat")) }, "XMLDownloadOptions: Shape error");
|
|
218
234
|
const XMLImageMapArea = v.object({
|
|
219
235
|
uuid: v.pipe(v.string("XMLImageMapArea: uuid is string and required"), v.check(isPseudoUuid, "XMLImageMapArea: uuid is not a valid pseudo-UUID")),
|
|
220
236
|
publicationDateTime: v.optional(customDateTime("XMLImageMapArea: publicationDateTime is not a valid datetime")),
|
|
@@ -481,6 +497,7 @@ const XMLBibliography = v.object({
|
|
|
481
497
|
publicationDateTime: v.optional(customDateTime("XMLBibliography: publicationDateTime is not a valid datetime"))
|
|
482
498
|
}, "XMLBibliography: sourceDocument is object with uuid and payload")),
|
|
483
499
|
image: v.optional(XMLImage),
|
|
500
|
+
downloadOptions: v.optional(XMLDownloadOptions),
|
|
484
501
|
publicationInfo: v.optional(v.object({
|
|
485
502
|
publishers: v.optional(v.union([v.object({ publisher: v.array(v.lazy(() => XMLPerson)) }), v.object({ publishers: v.object({ person: v.array(v.lazy(() => XMLPerson)) }) })])),
|
|
486
503
|
startDate: v.optional(v.object({
|
|
@@ -550,6 +567,7 @@ const XMLObservation = v.object({
|
|
|
550
567
|
v.lazy(() => XMLDataItem),
|
|
551
568
|
v.array(v.union([v.lazy(() => XMLLink), v.lazy(() => XMLDataItem)]))
|
|
552
569
|
])),
|
|
570
|
+
downloadOptions: v.optional(XMLDownloadOptions),
|
|
553
571
|
notes: v.optional(v.object({ note: v.array(XMLNote) })),
|
|
554
572
|
properties: v.optional(v.object({ property: v.array(XMLProperty) })),
|
|
555
573
|
bibliographies: v.optional(v.object({ bibliography: v.array(XMLBibliography) }))
|
|
@@ -558,10 +576,7 @@ const XMLSpatialUnit = v.object({
|
|
|
558
576
|
...XMLBaseItem.entries,
|
|
559
577
|
image: v.optional(XMLImage),
|
|
560
578
|
coordinates: v.optional(XMLCoordinates),
|
|
561
|
-
mapData:
|
|
562
|
-
multiPolygon: v.object({ payload: v.string("XMLSpatialUnit: multiPolygon is string and required") }),
|
|
563
|
-
EPSG: XMLNumber
|
|
564
|
-
}) }, "XMLSpatialUnit: mapData is object with geoJSON")),
|
|
579
|
+
mapData: XMLMapData,
|
|
565
580
|
observations: v.optional(v.object({ observation: v.array(XMLObservation) })),
|
|
566
581
|
observation: v.optional(v.array(XMLObservation)),
|
|
567
582
|
properties: v.optional(v.object({ property: v.array(XMLProperty) })),
|
|
@@ -644,6 +659,7 @@ const XMLResource = v.object({
|
|
|
644
659
|
width: XMLOptionalNumber,
|
|
645
660
|
image: v.optional(XMLImage),
|
|
646
661
|
imagemap: v.optional(XMLImageMap),
|
|
662
|
+
downloadOptions: v.optional(XMLDownloadOptions),
|
|
647
663
|
document: XMLOptionalContent,
|
|
648
664
|
coordinates: v.optional(XMLCoordinates),
|
|
649
665
|
periods: v.optional(v.object({ period: v.array(XMLPeriod) })),
|
|
@@ -928,21 +944,39 @@ const XMLSetItems = v.intersect([XMLItemLinks, v.object({
|
|
|
928
944
|
pageSize: XMLNumber
|
|
929
945
|
}, "XMLSetItems: Shape error")]);
|
|
930
946
|
const XMLSetItemsData = v.object({ result: v.object({ ochre: v.object({ items: XMLSetItems }, "XMLSetItemsData: ochre") }) }, "XMLSetItemsData: Shape error");
|
|
931
|
-
const
|
|
932
|
-
uuid: v.string("
|
|
933
|
-
category: v.string("
|
|
934
|
-
|
|
947
|
+
const XMLItemLocation = v.object({
|
|
948
|
+
uuid: v.string("XMLItemLocation: uuid is string and required"),
|
|
949
|
+
category: v.string("XMLItemLocation: category is string and required"),
|
|
950
|
+
scopeUuid: v.string("XMLItemLocation: scopeUuid is string and required"),
|
|
951
|
+
publicationDateTime: v.optional(customDateTime("XMLItemLocation: publicationDateTime is not a valid datetime")),
|
|
935
952
|
identification: XMLIdentification,
|
|
936
953
|
coordinates: v.optional(XMLCoordinates),
|
|
954
|
+
mapData: XMLMapData,
|
|
937
955
|
value: v.optional(v.array(v.intersect([v.object({
|
|
938
|
-
variable: v.string("
|
|
939
|
-
uuid: v.string("
|
|
940
|
-
}, "
|
|
941
|
-
}, "
|
|
942
|
-
const
|
|
956
|
+
variable: v.string("XMLItemLocation: value variable is string and required"),
|
|
957
|
+
uuid: v.string("XMLItemLocation: value uuid is string and required")
|
|
958
|
+
}, "XMLItemLocation: value is object with variable and uuid"), XMLContent])))
|
|
959
|
+
}, "XMLItemLocation: Shape error");
|
|
960
|
+
const XMLItemLocationsData = v.object({ result: v.object({ ochre: v.object({ items: v.object({
|
|
943
961
|
totalCount: XMLNumber,
|
|
944
|
-
itemLocation: v.optional(v.array(
|
|
945
|
-
}, "
|
|
962
|
+
itemLocation: v.optional(v.array(XMLItemLocation, "XMLItemLocationsData: itemLocation is array of XMLItemLocation"))
|
|
963
|
+
}, "XMLItemLocationsData: items is object with totalCount") }, "XMLItemLocationsData: ochre") }) }, "XMLItemLocationsData: Shape error");
|
|
964
|
+
const XMLMapLayer = v.object({
|
|
965
|
+
uuid: v.string("XMLMapLayer: uuid is string and required"),
|
|
966
|
+
category: v.string("XMLMapLayer: category is string and required"),
|
|
967
|
+
type: v.optional(v.string("XMLMapLayer: type is string and optional")),
|
|
968
|
+
href: v.optional(v.string("XMLMapLayer: href is string and optional")),
|
|
969
|
+
WKID: XMLOptionalNumber,
|
|
970
|
+
identification: XMLIdentification
|
|
971
|
+
}, "XMLMapLayer: Shape error");
|
|
972
|
+
const XMLMapSource = v.object({
|
|
973
|
+
uuid: v.string("XMLMapSource: uuid is string and required"),
|
|
974
|
+
category: v.string("XMLMapSource: category is string and required"),
|
|
975
|
+
WKID: XMLOptionalNumber,
|
|
976
|
+
identification: XMLIdentification,
|
|
977
|
+
mapLayer: v.optional(v.array(XMLMapLayer, "XMLMapSource: mapLayer is array of XMLMapLayer"))
|
|
978
|
+
}, "XMLMapSource: Shape error");
|
|
979
|
+
const XMLMapSourcesData = v.object({ result: v.object({ ochre: v.object({ mapSources: v.object({ mapSource: v.optional(v.array(XMLMapSource, "XMLMapSourcesData: mapSource is array of XMLMapSource")) }, "XMLMapSourcesData: mapSources is object") }, "XMLMapSourcesData: ochre") }) }, "XMLMapSourcesData: Shape error");
|
|
946
980
|
const XMLData = v.object({ result: v.object({ ochre: v.intersect([v.object({
|
|
947
981
|
uuid: v.pipe(v.string("XMLData: uuid is string and required"), v.check(isPseudoUuid, "XMLData: uuid is not a valid pseudo-UUID")),
|
|
948
982
|
belongsTo: v.string("XMLData: belongsTo is string and required"),
|
|
@@ -958,7 +992,7 @@ const XMLWebsiteData = v.object({ result: v.object({ ochre: v.object({
|
|
|
958
992
|
publicationDateTime: customDateTime("XMLWebsiteData: publicationDateTime is not a valid datetime"),
|
|
959
993
|
metadata: XMLMetadata,
|
|
960
994
|
persistentUrl: v.optional(v.pipe(v.string("XMLWebsiteData: persistentUrl is string and optional"), v.url("XMLWebsiteData: persistentUrl is not a valid URL"))),
|
|
961
|
-
tree: v.array(XMLWebsiteTree)
|
|
995
|
+
tree: v.array(XMLWebsiteTree),
|
|
996
|
+
styleLabels: v.optional(v.object({ styleLabel: v.optional(v.array(v.intersect([v.object({ valueUuid: v.string("XMLWebsiteData: styleLabel valueUuid is string and required") }, "XMLWebsiteData: styleLabel is object with valueUuid"), XMLContent]))) }))
|
|
962
997
|
}, "XMLWebsiteData: ochre is object with website tree") }, "XMLWebsiteData: result is object with ochre") }, "XMLWebsiteData: Shape error");
|
|
963
|
-
|
|
964
|
-
export { XMLData, XMLDataItem, XMLGalleryData, XMLItemLinksData, XMLLink, XMLSetItemLocationsData, XMLSetItemsData, XMLWebsiteData };
|
|
998
|
+
export { XMLData, XMLDataItem, XMLGalleryData, XMLItemLinksData, XMLItemLocationsData, XMLLink, XMLMapSourcesData, XMLSetItemsData, XMLWebsiteData };
|
package/dist/xml/types.d.mts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/xml/types.d.ts
|
|
2
1
|
export type XMLItemCategory = "tree" | "bibliography" | "spatialUnit" | "concept" | "period" | "person" | "propertyVariable" | "variable" | "propertyValue" | "value" | "text" | "resource" | "set";
|
|
3
2
|
export type XMLRecursiveItemCategory = Exclude<XMLItemCategory, "tree" | "person" | "propertyVariable" | "propertyValue" | "set">;
|
|
4
3
|
/**
|
|
@@ -139,6 +138,8 @@ export type XMLCoordinate = {
|
|
|
139
138
|
latitude: number;
|
|
140
139
|
longitude: number;
|
|
141
140
|
altitude?: number;
|
|
141
|
+
WKID?: number;
|
|
142
|
+
rawValue?: string;
|
|
142
143
|
source?: XMLCoordinatesSource;
|
|
143
144
|
} | {
|
|
144
145
|
type: "plane";
|
|
@@ -165,6 +166,13 @@ export type XMLImage = {
|
|
|
165
166
|
fileSize?: number;
|
|
166
167
|
payload?: string;
|
|
167
168
|
};
|
|
169
|
+
export type XMLDownloadOptions = {
|
|
170
|
+
option: Array<{
|
|
171
|
+
type: "highQualityImage" | "iiifManifest" | "document" | "ocr";
|
|
172
|
+
href: string;
|
|
173
|
+
fileFormat: string;
|
|
174
|
+
}>;
|
|
175
|
+
};
|
|
168
176
|
export type XMLImageMapArea = {
|
|
169
177
|
uuid: string;
|
|
170
178
|
publicationDateTime?: Date;
|
|
@@ -254,6 +262,7 @@ export type XMLBibliography = Partial<XMLBaseItem> & {
|
|
|
254
262
|
publicationDateTime?: Date;
|
|
255
263
|
};
|
|
256
264
|
image?: XMLImage;
|
|
265
|
+
downloadOptions?: XMLDownloadOptions;
|
|
257
266
|
publicationInfo?: {
|
|
258
267
|
publishers?: {
|
|
259
268
|
publisher: Array<XMLPerson>;
|
|
@@ -432,6 +441,7 @@ export type XMLObservation = {
|
|
|
432
441
|
};
|
|
433
442
|
links?: XMLLink;
|
|
434
443
|
reverseLinks?: XMLLink | XMLDataItem | Array<XMLLink | XMLDataItem>;
|
|
444
|
+
downloadOptions?: XMLDownloadOptions;
|
|
435
445
|
notes?: {
|
|
436
446
|
note: Array<XMLNote>;
|
|
437
447
|
};
|
|
@@ -544,6 +554,7 @@ export type XMLResource = XMLBaseItem & {
|
|
|
544
554
|
width?: number;
|
|
545
555
|
image?: XMLImage;
|
|
546
556
|
imagemap?: XMLImageMap;
|
|
557
|
+
downloadOptions?: XMLDownloadOptions;
|
|
547
558
|
document?: XMLContent;
|
|
548
559
|
coordinates?: XMLCoordinates;
|
|
549
560
|
periods?: {
|
|
@@ -887,23 +898,49 @@ export type XMLSetItemsData = {
|
|
|
887
898
|
};
|
|
888
899
|
};
|
|
889
900
|
};
|
|
890
|
-
export type
|
|
901
|
+
export type XMLItemLocation = {
|
|
891
902
|
uuid: string;
|
|
892
903
|
category: string;
|
|
904
|
+
scopeUuid: string;
|
|
893
905
|
publicationDateTime?: Date;
|
|
894
906
|
identification: XMLIdentification;
|
|
895
907
|
coordinates?: XMLCoordinates;
|
|
908
|
+
mapData?: XMLSpatialUnit["mapData"];
|
|
896
909
|
value?: Array<{
|
|
897
910
|
variable: string;
|
|
898
911
|
uuid: string;
|
|
899
912
|
} & XMLContent>;
|
|
900
913
|
};
|
|
901
|
-
export type
|
|
914
|
+
export type XMLItemLocationsData = {
|
|
902
915
|
result: {
|
|
903
916
|
ochre: {
|
|
904
917
|
items: {
|
|
905
918
|
totalCount: number;
|
|
906
|
-
itemLocation?: Array<
|
|
919
|
+
itemLocation?: Array<XMLItemLocation>;
|
|
920
|
+
};
|
|
921
|
+
};
|
|
922
|
+
};
|
|
923
|
+
};
|
|
924
|
+
export type XMLMapLayer = {
|
|
925
|
+
uuid: string;
|
|
926
|
+
category: string;
|
|
927
|
+
type?: string;
|
|
928
|
+
href?: string;
|
|
929
|
+
WKID?: number;
|
|
930
|
+
identification: XMLIdentification;
|
|
931
|
+
};
|
|
932
|
+
export type XMLMapSource = {
|
|
933
|
+
uuid: string;
|
|
934
|
+
category: string;
|
|
935
|
+
WKID?: number;
|
|
936
|
+
identification: XMLIdentification;
|
|
937
|
+
mapLayer?: Array<XMLMapLayer>;
|
|
938
|
+
};
|
|
939
|
+
export type XMLMapSourcesData = {
|
|
940
|
+
result: {
|
|
941
|
+
ochre: {
|
|
942
|
+
mapSources: {
|
|
943
|
+
mapSource?: Array<XMLMapSource>;
|
|
907
944
|
};
|
|
908
945
|
};
|
|
909
946
|
};
|
|
@@ -930,8 +967,12 @@ export type XMLWebsiteData = {
|
|
|
930
967
|
metadata: XMLMetadata;
|
|
931
968
|
persistentUrl?: string;
|
|
932
969
|
tree: Array<XMLWebsiteTree>;
|
|
970
|
+
styleLabels?: {
|
|
971
|
+
styleLabel?: Array<{
|
|
972
|
+
valueUuid: string;
|
|
973
|
+
} & XMLContent>;
|
|
974
|
+
};
|
|
933
975
|
};
|
|
934
976
|
};
|
|
935
977
|
};
|
|
936
|
-
export type XMLHeadingItemCategory = Exclude<XMLItemCategory, "tree" | "bibliography" | "spatialUnit" | "concept" | "period">;
|
|
937
|
-
//#endregion
|
|
978
|
+
export type XMLHeadingItemCategory = Exclude<XMLItemCategory, "tree" | "bibliography" | "spatialUnit" | "concept" | "period">;
|
package/dist/xquery.d.mts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/xquery.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* Build a string literal for an XQuery string
|
|
4
3
|
* @param value - The string value to escape
|
|
@@ -74,5 +73,4 @@ export declare function compileOchreQuery(parameters: {
|
|
|
74
73
|
declarations?: ReadonlyArray<string>;
|
|
75
74
|
body: (context: OchreQueryContext) => string;
|
|
76
75
|
contentLanguage?: OchreContentLanguage | null;
|
|
77
|
-
}): string;
|
|
78
|
-
//#endregion
|
|
76
|
+
}): string;
|
package/dist/xquery.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DEFAULT_LANGUAGES } from "./constants.mjs";
|
|
2
|
-
|
|
2
|
+
// src/xquery.ts
|
|
3
3
|
/**
|
|
4
4
|
* Build a string literal for an XQuery string
|
|
5
5
|
* @param value - The string value to escape
|
|
@@ -137,5 +137,4 @@ ${contentLanguage == null ? bodyExpression : `local:select-language((
|
|
|
137
137
|
${bodyExpression}
|
|
138
138
|
), ${stringLiteral(contentLanguage.language)}, ${stringLiteral(contentLanguage.fallbackLanguage)})`}`;
|
|
139
139
|
}
|
|
140
|
-
//#endregion
|
|
141
140
|
export { OCHRE_RESPONSE_PADDING, compileOchreQuery, getContentLanguage, stringLiteral };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ochre-sdk",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.14",
|
|
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",
|
|
@@ -45,7 +45,8 @@
|
|
|
45
45
|
"dist"
|
|
46
46
|
],
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"
|
|
48
|
+
"@nodable/entities": "^3.1.0",
|
|
49
|
+
"fast-equals": "^6.2.1",
|
|
49
50
|
"fast-xml-parser": "^5.11.2",
|
|
50
51
|
"valibot": "^1.5.0"
|
|
51
52
|
},
|
|
@@ -53,21 +54,21 @@
|
|
|
53
54
|
"@antfu/eslint-config": "^9.5.1",
|
|
54
55
|
"@types/node": "^24.19.2",
|
|
55
56
|
"bumpp": "^12.3.0",
|
|
56
|
-
"eslint": "^10.
|
|
57
|
+
"eslint": "^10.13.0",
|
|
57
58
|
"eslint-plugin-erasable-syntax-only": "^0.7.2",
|
|
58
59
|
"eslint-plugin-slop": "^0.1.3",
|
|
59
60
|
"eslint-plugin-sonarjs": "^4.2.2",
|
|
60
|
-
"knip": "^6.
|
|
61
|
-
"oxfmt": "^0.
|
|
61
|
+
"knip": "^6.42.1",
|
|
62
|
+
"oxfmt": "^0.74.0",
|
|
62
63
|
"tsdown": "^0.23.1",
|
|
63
64
|
"typescript": "^6.0.3",
|
|
64
|
-
"vitest": "^5.0.
|
|
65
|
+
"vitest": "^5.0.5"
|
|
65
66
|
},
|
|
66
67
|
"scripts": {
|
|
67
68
|
"dev": "tsdown src/index.ts --watch",
|
|
68
69
|
"build": "tsdown",
|
|
69
|
-
"lint": "knip && eslint
|
|
70
|
-
"lint:fix": "knip --fix && eslint --
|
|
70
|
+
"lint": "knip && eslint .",
|
|
71
|
+
"lint:fix": "knip --fix && eslint --fix .",
|
|
71
72
|
"format": "oxfmt --check",
|
|
72
73
|
"format:fix": "oxfmt",
|
|
73
74
|
"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 };
|