ochre-sdk 0.22.10 → 0.22.12
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/index.d.mts +35 -36
- package/dist/index.mjs +24 -34
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -756,36 +756,44 @@ type Query = QueryLeaf | QueryGroup;
|
|
|
756
756
|
//#endregion
|
|
757
757
|
//#region src/types/website.d.ts
|
|
758
758
|
/**
|
|
759
|
-
* Represents a level
|
|
759
|
+
* Represents a context tree level item with a variable and value
|
|
760
760
|
*/
|
|
761
|
-
type
|
|
761
|
+
type ContextTreeLevelItem = {
|
|
762
762
|
variableUuid: string;
|
|
763
763
|
valueUuid: string | null;
|
|
764
764
|
};
|
|
765
765
|
/**
|
|
766
|
-
* Represents a level
|
|
766
|
+
* Represents a context tree level with a context item
|
|
767
767
|
*/
|
|
768
|
-
type
|
|
769
|
-
context: Array<
|
|
768
|
+
type ContextTreeLevel = {
|
|
769
|
+
context: Array<ContextTreeLevelItem>;
|
|
770
770
|
identification: Identification;
|
|
771
771
|
type: string;
|
|
772
772
|
};
|
|
773
773
|
/**
|
|
774
|
-
* Represents
|
|
774
|
+
* Represents a filter context tree level with a context item
|
|
775
775
|
*/
|
|
776
|
-
type
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
776
|
+
type ContextTreeFilterLevel = {
|
|
777
|
+
context: Array<ContextTreeLevelItem>;
|
|
778
|
+
identification: Identification;
|
|
779
|
+
type: string;
|
|
780
|
+
filterType: "property" | "coordinates" | "bibliography" | "period";
|
|
781
|
+
isInlineDisplayed: boolean;
|
|
782
|
+
isSidebarDisplayed: boolean;
|
|
783
|
+
isSidebarOpen: boolean;
|
|
784
|
+
};
|
|
785
|
+
/**
|
|
786
|
+
* Represents a context tree with levels grouped by behavior
|
|
787
|
+
*/
|
|
788
|
+
type ContextTree = {
|
|
789
|
+
flatten: Array<ContextTreeLevel>;
|
|
790
|
+
suppress: Array<ContextTreeLevel>;
|
|
791
|
+
filter: Array<ContextTreeFilterLevel>;
|
|
792
|
+
sort: Array<ContextTreeLevel>;
|
|
793
|
+
detail: Array<ContextTreeLevel>;
|
|
794
|
+
download: Array<ContextTreeLevel>;
|
|
795
|
+
label: Array<ContextTreeLevel>;
|
|
796
|
+
prominent: Array<ContextTreeLevel>;
|
|
789
797
|
};
|
|
790
798
|
/**
|
|
791
799
|
* Represents a scope with its UUID, type and identification
|
|
@@ -907,7 +915,7 @@ type Website = {
|
|
|
907
915
|
iiifViewer: "universal-viewer" | "clover";
|
|
908
916
|
};
|
|
909
917
|
options: {
|
|
910
|
-
|
|
918
|
+
contextTree: ContextTree | null;
|
|
911
919
|
scopes: Array<Scope> | null;
|
|
912
920
|
labels: {
|
|
913
921
|
title: string | null;
|
|
@@ -1049,11 +1057,10 @@ type WebElementComponent = {
|
|
|
1049
1057
|
uuid: string;
|
|
1050
1058
|
label: string;
|
|
1051
1059
|
}> | null;
|
|
1052
|
-
variant: "
|
|
1060
|
+
variant: "slide" | "table" | "card" | "tile" | "showcase";
|
|
1053
1061
|
paginationVariant: "default" | "numeric";
|
|
1054
1062
|
loadingVariant: "spinner" | "skeleton" | "animation" | "none";
|
|
1055
|
-
|
|
1056
|
-
imageQuality: "high" | "low";
|
|
1063
|
+
imageLayout: "top" | "bottom" | "start" | "end" | null;
|
|
1057
1064
|
isSortDisplayed: boolean;
|
|
1058
1065
|
isUsingQueryParams: boolean;
|
|
1059
1066
|
filter: {
|
|
@@ -1066,12 +1073,8 @@ type WebElementComponent = {
|
|
|
1066
1073
|
sidebarSort: "default" | "alphabetical";
|
|
1067
1074
|
};
|
|
1068
1075
|
options: {
|
|
1069
|
-
attributeFilters: {
|
|
1070
|
-
bibliographies: boolean;
|
|
1071
|
-
periods: boolean;
|
|
1072
|
-
};
|
|
1073
1076
|
scopes: Array<Scope> | null;
|
|
1074
|
-
|
|
1077
|
+
contextTree: ContextTree | null;
|
|
1075
1078
|
labels: {
|
|
1076
1079
|
title: string | null;
|
|
1077
1080
|
};
|
|
@@ -1135,12 +1138,8 @@ type WebElementComponent = {
|
|
|
1135
1138
|
endIcon: string | null;
|
|
1136
1139
|
}>;
|
|
1137
1140
|
options: {
|
|
1138
|
-
attributeFilters: {
|
|
1139
|
-
bibliographies: boolean;
|
|
1140
|
-
periods: boolean;
|
|
1141
|
-
};
|
|
1142
1141
|
scopes: Array<Scope> | null;
|
|
1143
|
-
|
|
1142
|
+
contextTree: ContextTree | null;
|
|
1144
1143
|
labels: {
|
|
1145
1144
|
title: string | null;
|
|
1146
1145
|
};
|
|
@@ -1158,9 +1157,9 @@ type WebElementComponent = {
|
|
|
1158
1157
|
loadingVariant: Extract<WebElementComponent, {
|
|
1159
1158
|
component: "collection";
|
|
1160
1159
|
}>["loadingVariant"];
|
|
1161
|
-
|
|
1160
|
+
imageLayout: Extract<WebElementComponent, {
|
|
1162
1161
|
component: "collection";
|
|
1163
|
-
}>["
|
|
1162
|
+
}>["imageLayout"];
|
|
1164
1163
|
};
|
|
1165
1164
|
} | {
|
|
1166
1165
|
component: "search-bar";
|
|
@@ -1594,4 +1593,4 @@ declare const DEFAULT_PAGE_SIZE = 48;
|
|
|
1594
1593
|
*/
|
|
1595
1594
|
declare function flattenItemProperties<T extends DataCategory = DataCategory, U extends DataCategory | Array<DataCategory> = (T extends "tree" ? Exclude<DataCategory, "tree"> : T extends "set" ? Array<DataCategory> : never)>(item: Item<T, U>): Item<T, U>;
|
|
1596
1595
|
//#endregion
|
|
1597
|
-
export { ApiVersion, Bibliography, Concept, Context, ContextItem, ContextNode, Coordinate, DEFAULT_API_VERSION, DEFAULT_PAGE_SIZE, Data, DataCategory, Event, FileFormat, Gallery, Identification, Image, ImageMap, ImageMapArea, Interpretation, Item,
|
|
1596
|
+
export { ApiVersion, Bibliography, Concept, Context, ContextItem, ContextNode, ContextTree, ContextTreeFilterLevel, ContextTreeLevel, ContextTreeLevelItem, Coordinate, DEFAULT_API_VERSION, DEFAULT_PAGE_SIZE, Data, DataCategory, Event, FileFormat, Gallery, Identification, Image, ImageMap, ImageMapArea, Interpretation, Item, License, Link, Metadata, Note, Observation, Period, Person, Property, PropertyValue, PropertyValueContent, PropertyValueContentType, PropertyValueQueryItem, PropertyVariable, Query, QueryGroup, QueryLeaf, Resource, Scope, Section, Set, SetAttributeValueQueryItem, SetItemsSort, SetItemsSortDirection, SpatialUnit, Style, StylesheetCategory, StylesheetItem, Text, Tree, WebBlock, WebBlockLayout, WebElement, WebElementComponent, WebImage, WebSegment, WebSegmentItem, WebTitle, Webpage, Website, WebsitePropertyQuery, WebsitePropertyQueryNode, WebsiteType, fetchGallery, fetchItem, fetchSetItems, fetchSetPropertyValues, fetchWebsite, filterProperties, flattenItemProperties, getLeafPropertyValues, getPropertyByLabel, getPropertyByLabelAndValue, getPropertyByLabelAndValueContent, getPropertyByLabelAndValueContents, getPropertyByLabelAndValues, getPropertyByUuid, getPropertyValueByLabel, getPropertyValueByUuid, getPropertyValueContentByLabel, getPropertyValueContentByUuid, getPropertyValueContentsByUuid, getPropertyValuesByLabel, getPropertyValuesByUuid, getUniqueProperties, getUniquePropertyLabels };
|
package/dist/index.mjs
CHANGED
|
@@ -3912,13 +3912,11 @@ function parseWebElementProperties(componentProperty, elementResource) {
|
|
|
3912
3912
|
if (setLinks.every((link) => link.uuid === null)) throw new Error(`Set links not found for the following component: “${componentName}”`);
|
|
3913
3913
|
const displayedProperties = getPropertyByLabel(componentProperty.properties, "use-property");
|
|
3914
3914
|
let variant = getPropertyValueContentByLabel(componentProperty.properties, "variant");
|
|
3915
|
-
variant ??= "
|
|
3915
|
+
variant ??= "slide";
|
|
3916
3916
|
let paginationVariant = getPropertyValueContentByLabel(componentProperty.properties, "pagination-variant");
|
|
3917
3917
|
paginationVariant ??= "default";
|
|
3918
3918
|
let loadingVariant = getPropertyValueContentByLabel(componentProperty.properties, "loading-variant");
|
|
3919
3919
|
loadingVariant ??= "skeleton";
|
|
3920
|
-
let imageQuality = getPropertyValueContentByLabel(componentProperty.properties, "image-quality");
|
|
3921
|
-
imageQuality ??= "low";
|
|
3922
3920
|
let isUsingQueryParams = getPropertyValueContentByLabel(componentProperty.properties, "is-using-query-params");
|
|
3923
3921
|
isUsingQueryParams ??= false;
|
|
3924
3922
|
let isFilterResultsBarDisplayed = getPropertyValueContentByLabel(componentProperty.properties, "filter-results-bar-displayed");
|
|
@@ -3937,23 +3935,19 @@ function parseWebElementProperties(componentProperty, elementResource) {
|
|
|
3937
3935
|
isFilterSidebarDisplayed ??= false;
|
|
3938
3936
|
let filterSidebarSort = getPropertyValueContentByLabel(componentProperty.properties, "filter-sidebar-sort");
|
|
3939
3937
|
filterSidebarSort ??= "default";
|
|
3940
|
-
let
|
|
3941
|
-
|
|
3938
|
+
let imageLayout = getPropertyValueContentByLabel(componentProperty.properties, "image-layout");
|
|
3939
|
+
imageLayout ??= "start";
|
|
3942
3940
|
const options = {
|
|
3943
|
-
attributeFilters: {
|
|
3944
|
-
bibliographies: elementResource.options?.filterBibliography ?? false,
|
|
3945
|
-
periods: elementResource.options?.filterPeriods ?? false
|
|
3946
|
-
},
|
|
3947
3941
|
scopes: elementResource.options?.scopes != null ? ensureArray(elementResource.options.scopes.scope).map((scope) => ({
|
|
3948
3942
|
uuid: scope.uuid.content,
|
|
3949
3943
|
type: scope.uuid.type,
|
|
3950
3944
|
identification: parseIdentification(scope.identification)
|
|
3951
3945
|
})) : null,
|
|
3952
|
-
|
|
3946
|
+
contextTree: null,
|
|
3953
3947
|
labels: { title: null }
|
|
3954
3948
|
};
|
|
3955
3949
|
if ("options" in elementResource && elementResource.options) {
|
|
3956
|
-
options.
|
|
3950
|
+
options.contextTree = parseAllOptionContexts(elementResource.options);
|
|
3957
3951
|
if ("notes" in elementResource.options && elementResource.options.notes) {
|
|
3958
3952
|
const labelNotes = parseNotes(ensureArray(elementResource.options.notes.note));
|
|
3959
3953
|
options.labels.title = labelNotes.find((note) => note.title === "Title label")?.content ?? null;
|
|
@@ -3969,8 +3963,7 @@ function parseWebElementProperties(componentProperty, elementResource) {
|
|
|
3969
3963
|
variant,
|
|
3970
3964
|
paginationVariant,
|
|
3971
3965
|
loadingVariant,
|
|
3972
|
-
|
|
3973
|
-
imageQuality,
|
|
3966
|
+
imageLayout,
|
|
3974
3967
|
isUsingQueryParams,
|
|
3975
3968
|
isSortDisplayed,
|
|
3976
3969
|
filter: {
|
|
@@ -4205,20 +4198,16 @@ function parseWebElementProperties(componentProperty, elementResource) {
|
|
|
4205
4198
|
}
|
|
4206
4199
|
if (items.length === 0) throw new Error(`No queries found for the following component: “${componentName}”`);
|
|
4207
4200
|
const options = {
|
|
4208
|
-
attributeFilters: {
|
|
4209
|
-
bibliographies: elementResource.options?.filterBibliography ?? false,
|
|
4210
|
-
periods: elementResource.options?.filterPeriods ?? false
|
|
4211
|
-
},
|
|
4212
4201
|
scopes: elementResource.options?.scopes != null ? ensureArray(elementResource.options.scopes.scope).map((scope) => ({
|
|
4213
4202
|
uuid: scope.uuid.content,
|
|
4214
4203
|
type: scope.uuid.type,
|
|
4215
4204
|
identification: parseIdentification(scope.identification)
|
|
4216
4205
|
})) : null,
|
|
4217
|
-
|
|
4206
|
+
contextTree: null,
|
|
4218
4207
|
labels: { title: null }
|
|
4219
4208
|
};
|
|
4220
4209
|
if ("options" in elementResource && elementResource.options) {
|
|
4221
|
-
options.
|
|
4210
|
+
options.contextTree = parseAllOptionContexts(elementResource.options);
|
|
4222
4211
|
if ("notes" in elementResource.options && elementResource.options.notes) {
|
|
4223
4212
|
const labelNotes = parseNotes(ensureArray(elementResource.options.notes.note));
|
|
4224
4213
|
options.labels.title = labelNotes.find((note) => note.title === "Title label")?.content ?? null;
|
|
@@ -4226,13 +4215,13 @@ function parseWebElementProperties(componentProperty, elementResource) {
|
|
|
4226
4215
|
}
|
|
4227
4216
|
const displayedProperties = getPropertyByLabel(componentProperty.properties, "use-property");
|
|
4228
4217
|
let variant = getPropertyValueContentByLabel(componentProperty.properties, "variant");
|
|
4229
|
-
variant ??= "
|
|
4218
|
+
variant ??= "slide";
|
|
4230
4219
|
let paginationVariant = getPropertyValueContentByLabel(componentProperty.properties, "pagination-variant");
|
|
4231
4220
|
paginationVariant ??= "default";
|
|
4232
4221
|
let loadingVariant = getPropertyValueContentByLabel(componentProperty.properties, "loading-variant");
|
|
4233
4222
|
loadingVariant ??= "skeleton";
|
|
4234
|
-
let
|
|
4235
|
-
|
|
4223
|
+
let imageLayout = getPropertyValueContentByLabel(componentProperty.properties, "image-layout");
|
|
4224
|
+
imageLayout ??= "start";
|
|
4236
4225
|
properties = {
|
|
4237
4226
|
component: "query",
|
|
4238
4227
|
linkUuids: setLinks.map((link) => link.uuid).filter((uuid) => uuid !== null),
|
|
@@ -4246,7 +4235,7 @@ function parseWebElementProperties(componentProperty, elementResource) {
|
|
|
4246
4235
|
variant,
|
|
4247
4236
|
paginationVariant,
|
|
4248
4237
|
loadingVariant,
|
|
4249
|
-
|
|
4238
|
+
imageLayout
|
|
4250
4239
|
}
|
|
4251
4240
|
};
|
|
4252
4241
|
break;
|
|
@@ -4872,7 +4861,7 @@ function parseWebsiteProperties(properties, websiteTree, sidebar) {
|
|
|
4872
4861
|
iiifViewer: "universal-viewer"
|
|
4873
4862
|
},
|
|
4874
4863
|
options: {
|
|
4875
|
-
|
|
4864
|
+
contextTree: null,
|
|
4876
4865
|
scopes: null,
|
|
4877
4866
|
labels: { title: null },
|
|
4878
4867
|
stylesheets: { properties: [] }
|
|
@@ -4918,7 +4907,7 @@ function parseWebsiteProperties(properties, websiteTree, sidebar) {
|
|
|
4918
4907
|
type: scope.uuid.type,
|
|
4919
4908
|
identification: parseIdentification(scope.identification)
|
|
4920
4909
|
})) : null;
|
|
4921
|
-
returnProperties.options.
|
|
4910
|
+
returnProperties.options.contextTree = parseAllOptionContexts(websiteTree.options);
|
|
4922
4911
|
if ("notes" in websiteTree.options && websiteTree.options.notes != null) {
|
|
4923
4912
|
const labelNotes = parseNotes(ensureArray(websiteTree.options.notes.note));
|
|
4924
4913
|
returnProperties.options.labels.title = labelNotes.find((note) => note.title === "Title label")?.content ?? null;
|
|
@@ -4928,7 +4917,7 @@ function parseWebsiteProperties(properties, websiteTree, sidebar) {
|
|
|
4928
4917
|
return returnProperties;
|
|
4929
4918
|
}
|
|
4930
4919
|
function parseContextItem(contextItemToParse) {
|
|
4931
|
-
const levelsToParse = ensureArray(contextItemToParse.levels.level);
|
|
4920
|
+
const levelsToParse = contextItemToParse.levels != null ? ensureArray(contextItemToParse.levels.level) : [];
|
|
4932
4921
|
let type = "";
|
|
4933
4922
|
return {
|
|
4934
4923
|
context: levelsToParse.map((level) => {
|
|
@@ -4987,18 +4976,19 @@ function parseFilterContextDisplay(filterOption) {
|
|
|
4987
4976
|
};
|
|
4988
4977
|
}
|
|
4989
4978
|
}
|
|
4990
|
-
function parseContexts(
|
|
4991
|
-
const
|
|
4992
|
-
for (const
|
|
4993
|
-
return
|
|
4979
|
+
function parseContexts(contextLevels) {
|
|
4980
|
+
const contextTreeLevels = [];
|
|
4981
|
+
for (const contextLevel of contextLevels) for (const contextItemToParse of ensureArray(contextLevel.context)) contextTreeLevels.push(parseContextItem(contextItemToParse));
|
|
4982
|
+
return contextTreeLevels;
|
|
4994
4983
|
}
|
|
4995
|
-
function parseFilterContexts(
|
|
4996
|
-
const
|
|
4997
|
-
for (const
|
|
4984
|
+
function parseFilterContexts(filterContextLevels) {
|
|
4985
|
+
const filterContextTreeLevels = [];
|
|
4986
|
+
for (const filterContextLevel of filterContextLevels) for (const contextItemToParse of ensureArray(filterContextLevel.context)) filterContextTreeLevels.push({
|
|
4998
4987
|
...parseContextItem(contextItemToParse),
|
|
4988
|
+
filterType: contextItemToParse.filterType,
|
|
4999
4989
|
...parseFilterContextDisplay(contextItemToParse.filterOption)
|
|
5000
4990
|
});
|
|
5001
|
-
return
|
|
4991
|
+
return filterContextTreeLevels;
|
|
5002
4992
|
}
|
|
5003
4993
|
function parseWebsite(websiteTree, metadata, belongsTo, { version = 2 } = {}) {
|
|
5004
4994
|
if (!websiteTree.properties) throw new Error("Website properties not found");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ochre-sdk",
|
|
3
|
-
"version": "0.22.
|
|
3
|
+
"version": "0.22.12",
|
|
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",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"eslint": "^10.2.0",
|
|
56
56
|
"prettier": "^3.8.3",
|
|
57
57
|
"tsdown": "^0.21.9",
|
|
58
|
-
"typescript": "^6.0.
|
|
58
|
+
"typescript": "^6.0.3",
|
|
59
59
|
"vitest": "^4.1.4"
|
|
60
60
|
},
|
|
61
61
|
"scripts": {
|