ochre-sdk 0.22.11 → 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 +31 -37
- package/dist/index.mjs +16 -29
- 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;
|
|
@@ -1065,18 +1073,8 @@ type WebElementComponent = {
|
|
|
1065
1073
|
sidebarSort: "default" | "alphabetical";
|
|
1066
1074
|
};
|
|
1067
1075
|
options: {
|
|
1068
|
-
attributeFilters: {
|
|
1069
|
-
bibliographies: {
|
|
1070
|
-
enabled: boolean;
|
|
1071
|
-
isOpenByDefault: boolean;
|
|
1072
|
-
};
|
|
1073
|
-
periods: {
|
|
1074
|
-
enabled: boolean;
|
|
1075
|
-
isOpenByDefault: boolean;
|
|
1076
|
-
};
|
|
1077
|
-
};
|
|
1078
1076
|
scopes: Array<Scope> | null;
|
|
1079
|
-
|
|
1077
|
+
contextTree: ContextTree | null;
|
|
1080
1078
|
labels: {
|
|
1081
1079
|
title: string | null;
|
|
1082
1080
|
};
|
|
@@ -1140,12 +1138,8 @@ type WebElementComponent = {
|
|
|
1140
1138
|
endIcon: string | null;
|
|
1141
1139
|
}>;
|
|
1142
1140
|
options: {
|
|
1143
|
-
attributeFilters: {
|
|
1144
|
-
bibliographies: boolean;
|
|
1145
|
-
periods: boolean;
|
|
1146
|
-
};
|
|
1147
1141
|
scopes: Array<Scope> | null;
|
|
1148
|
-
|
|
1142
|
+
contextTree: ContextTree | null;
|
|
1149
1143
|
labels: {
|
|
1150
1144
|
title: string | null;
|
|
1151
1145
|
};
|
|
@@ -1599,4 +1593,4 @@ declare const DEFAULT_PAGE_SIZE = 48;
|
|
|
1599
1593
|
*/
|
|
1600
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>;
|
|
1601
1595
|
//#endregion
|
|
1602
|
-
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
|
@@ -3938,26 +3938,16 @@ function parseWebElementProperties(componentProperty, elementResource) {
|
|
|
3938
3938
|
let imageLayout = getPropertyValueContentByLabel(componentProperty.properties, "image-layout");
|
|
3939
3939
|
imageLayout ??= "start";
|
|
3940
3940
|
const options = {
|
|
3941
|
-
attributeFilters: {
|
|
3942
|
-
bibliographies: {
|
|
3943
|
-
enabled: elementResource.options?.filterBibliography ?? false,
|
|
3944
|
-
isOpenByDefault: false
|
|
3945
|
-
},
|
|
3946
|
-
periods: {
|
|
3947
|
-
enabled: elementResource.options?.filterPeriods ?? false,
|
|
3948
|
-
isOpenByDefault: false
|
|
3949
|
-
}
|
|
3950
|
-
},
|
|
3951
3941
|
scopes: elementResource.options?.scopes != null ? ensureArray(elementResource.options.scopes.scope).map((scope) => ({
|
|
3952
3942
|
uuid: scope.uuid.content,
|
|
3953
3943
|
type: scope.uuid.type,
|
|
3954
3944
|
identification: parseIdentification(scope.identification)
|
|
3955
3945
|
})) : null,
|
|
3956
|
-
|
|
3946
|
+
contextTree: null,
|
|
3957
3947
|
labels: { title: null }
|
|
3958
3948
|
};
|
|
3959
3949
|
if ("options" in elementResource && elementResource.options) {
|
|
3960
|
-
options.
|
|
3950
|
+
options.contextTree = parseAllOptionContexts(elementResource.options);
|
|
3961
3951
|
if ("notes" in elementResource.options && elementResource.options.notes) {
|
|
3962
3952
|
const labelNotes = parseNotes(ensureArray(elementResource.options.notes.note));
|
|
3963
3953
|
options.labels.title = labelNotes.find((note) => note.title === "Title label")?.content ?? null;
|
|
@@ -4208,20 +4198,16 @@ function parseWebElementProperties(componentProperty, elementResource) {
|
|
|
4208
4198
|
}
|
|
4209
4199
|
if (items.length === 0) throw new Error(`No queries found for the following component: “${componentName}”`);
|
|
4210
4200
|
const options = {
|
|
4211
|
-
attributeFilters: {
|
|
4212
|
-
bibliographies: elementResource.options?.filterBibliography ?? false,
|
|
4213
|
-
periods: elementResource.options?.filterPeriods ?? false
|
|
4214
|
-
},
|
|
4215
4201
|
scopes: elementResource.options?.scopes != null ? ensureArray(elementResource.options.scopes.scope).map((scope) => ({
|
|
4216
4202
|
uuid: scope.uuid.content,
|
|
4217
4203
|
type: scope.uuid.type,
|
|
4218
4204
|
identification: parseIdentification(scope.identification)
|
|
4219
4205
|
})) : null,
|
|
4220
|
-
|
|
4206
|
+
contextTree: null,
|
|
4221
4207
|
labels: { title: null }
|
|
4222
4208
|
};
|
|
4223
4209
|
if ("options" in elementResource && elementResource.options) {
|
|
4224
|
-
options.
|
|
4210
|
+
options.contextTree = parseAllOptionContexts(elementResource.options);
|
|
4225
4211
|
if ("notes" in elementResource.options && elementResource.options.notes) {
|
|
4226
4212
|
const labelNotes = parseNotes(ensureArray(elementResource.options.notes.note));
|
|
4227
4213
|
options.labels.title = labelNotes.find((note) => note.title === "Title label")?.content ?? null;
|
|
@@ -4875,7 +4861,7 @@ function parseWebsiteProperties(properties, websiteTree, sidebar) {
|
|
|
4875
4861
|
iiifViewer: "universal-viewer"
|
|
4876
4862
|
},
|
|
4877
4863
|
options: {
|
|
4878
|
-
|
|
4864
|
+
contextTree: null,
|
|
4879
4865
|
scopes: null,
|
|
4880
4866
|
labels: { title: null },
|
|
4881
4867
|
stylesheets: { properties: [] }
|
|
@@ -4921,7 +4907,7 @@ function parseWebsiteProperties(properties, websiteTree, sidebar) {
|
|
|
4921
4907
|
type: scope.uuid.type,
|
|
4922
4908
|
identification: parseIdentification(scope.identification)
|
|
4923
4909
|
})) : null;
|
|
4924
|
-
returnProperties.options.
|
|
4910
|
+
returnProperties.options.contextTree = parseAllOptionContexts(websiteTree.options);
|
|
4925
4911
|
if ("notes" in websiteTree.options && websiteTree.options.notes != null) {
|
|
4926
4912
|
const labelNotes = parseNotes(ensureArray(websiteTree.options.notes.note));
|
|
4927
4913
|
returnProperties.options.labels.title = labelNotes.find((note) => note.title === "Title label")?.content ?? null;
|
|
@@ -4931,7 +4917,7 @@ function parseWebsiteProperties(properties, websiteTree, sidebar) {
|
|
|
4931
4917
|
return returnProperties;
|
|
4932
4918
|
}
|
|
4933
4919
|
function parseContextItem(contextItemToParse) {
|
|
4934
|
-
const levelsToParse = ensureArray(contextItemToParse.levels.level);
|
|
4920
|
+
const levelsToParse = contextItemToParse.levels != null ? ensureArray(contextItemToParse.levels.level) : [];
|
|
4935
4921
|
let type = "";
|
|
4936
4922
|
return {
|
|
4937
4923
|
context: levelsToParse.map((level) => {
|
|
@@ -4990,18 +4976,19 @@ function parseFilterContextDisplay(filterOption) {
|
|
|
4990
4976
|
};
|
|
4991
4977
|
}
|
|
4992
4978
|
}
|
|
4993
|
-
function parseContexts(
|
|
4994
|
-
const
|
|
4995
|
-
for (const
|
|
4996
|
-
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;
|
|
4997
4983
|
}
|
|
4998
|
-
function parseFilterContexts(
|
|
4999
|
-
const
|
|
5000
|
-
for (const
|
|
4984
|
+
function parseFilterContexts(filterContextLevels) {
|
|
4985
|
+
const filterContextTreeLevels = [];
|
|
4986
|
+
for (const filterContextLevel of filterContextLevels) for (const contextItemToParse of ensureArray(filterContextLevel.context)) filterContextTreeLevels.push({
|
|
5001
4987
|
...parseContextItem(contextItemToParse),
|
|
4988
|
+
filterType: contextItemToParse.filterType,
|
|
5002
4989
|
...parseFilterContextDisplay(contextItemToParse.filterOption)
|
|
5003
4990
|
});
|
|
5004
|
-
return
|
|
4991
|
+
return filterContextTreeLevels;
|
|
5005
4992
|
}
|
|
5006
4993
|
function parseWebsite(websiteTree, metadata, belongsTo, { version = 2 } = {}) {
|
|
5007
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": {
|