ochre-sdk 0.21.8 → 0.22.1
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 +66 -18
- package/dist/index.mjs +361 -261
- package/package.json +6 -3
package/dist/index.mjs
CHANGED
|
@@ -2157,7 +2157,7 @@ async function fetchItem(uuid, category, itemCategories, options) {
|
|
|
2157
2157
|
}
|
|
2158
2158
|
}
|
|
2159
2159
|
//#endregion
|
|
2160
|
-
//#region src/utils/
|
|
2160
|
+
//#region src/utils/query.ts
|
|
2161
2161
|
const CTS_INCLUDES_STOP_WORDS = [
|
|
2162
2162
|
"and",
|
|
2163
2163
|
"at",
|
|
@@ -3779,7 +3779,63 @@ async function fetchSetPropertyValues(params, options) {
|
|
|
3779
3779
|
}
|
|
3780
3780
|
//#endregion
|
|
3781
3781
|
//#region src/utils/getters.ts
|
|
3782
|
-
const DEFAULT_OPTIONS = {
|
|
3782
|
+
const DEFAULT_OPTIONS = {
|
|
3783
|
+
includeNestedProperties: false,
|
|
3784
|
+
limitToLeafPropertyValues: true
|
|
3785
|
+
};
|
|
3786
|
+
/**
|
|
3787
|
+
* Searches for a property in an array of properties
|
|
3788
|
+
* @param properties - The array of properties to search through
|
|
3789
|
+
* @param options - The options for the search
|
|
3790
|
+
* @param findDirectResult - A function to find the direct result
|
|
3791
|
+
* @param transformNestedResult - A function to transform the nested result
|
|
3792
|
+
* @returns The result of the search, or null if not found
|
|
3793
|
+
*/
|
|
3794
|
+
function searchPropertyResult(properties, options, findDirectResult, transformNestedResult) {
|
|
3795
|
+
const directResult = findDirectResult(properties);
|
|
3796
|
+
if (directResult !== null) return directResult;
|
|
3797
|
+
if (options.includeNestedProperties) for (const property of properties) {
|
|
3798
|
+
const nestedResult = searchPropertyResult(property.properties, options, findDirectResult, transformNestedResult);
|
|
3799
|
+
if (nestedResult !== null) {
|
|
3800
|
+
const transformedResult = transformNestedResult != null ? transformNestedResult(nestedResult) : nestedResult;
|
|
3801
|
+
if (transformedResult !== null) return transformedResult;
|
|
3802
|
+
}
|
|
3803
|
+
}
|
|
3804
|
+
return null;
|
|
3805
|
+
}
|
|
3806
|
+
function getPropertyValuesResult(values, limitToLeafPropertyValues, copyValuesWhenUnfiltered) {
|
|
3807
|
+
if (limitToLeafPropertyValues) return getLeafPropertyValues(values);
|
|
3808
|
+
if (copyValuesWhenUnfiltered) return values.map((value) => value);
|
|
3809
|
+
return values;
|
|
3810
|
+
}
|
|
3811
|
+
function clonePropertyValues(values) {
|
|
3812
|
+
return values.map((value) => ({
|
|
3813
|
+
...value,
|
|
3814
|
+
content: value.content
|
|
3815
|
+
}));
|
|
3816
|
+
}
|
|
3817
|
+
function getNormalizedProperty(property, limitToLeafPropertyValues, transformValues) {
|
|
3818
|
+
if (!limitToLeafPropertyValues) return property;
|
|
3819
|
+
const values = getLeafPropertyValues(property.values);
|
|
3820
|
+
return {
|
|
3821
|
+
...property,
|
|
3822
|
+
values: transformValues != null ? transformValues(values) : values
|
|
3823
|
+
};
|
|
3824
|
+
}
|
|
3825
|
+
function getFirstPropertyValueResult(values, limitToLeafPropertyValues) {
|
|
3826
|
+
if (limitToLeafPropertyValues) return getLeafPropertyValues(values)[0] ?? null;
|
|
3827
|
+
return values[0] ?? null;
|
|
3828
|
+
}
|
|
3829
|
+
function getFirstPropertyValueContentResult(values, limitToLeafPropertyValues) {
|
|
3830
|
+
if (limitToLeafPropertyValues) return getLeafPropertyValues(values)[0]?.content ?? null;
|
|
3831
|
+
return values[0]?.content ?? null;
|
|
3832
|
+
}
|
|
3833
|
+
function visitProperties(properties, includeNestedProperties, visit) {
|
|
3834
|
+
for (const property of properties) {
|
|
3835
|
+
visit(property);
|
|
3836
|
+
if (includeNestedProperties) visitProperties(property.properties, includeNestedProperties, visit);
|
|
3837
|
+
}
|
|
3838
|
+
}
|
|
3783
3839
|
/**
|
|
3784
3840
|
* Finds a property by its UUID in an array of properties
|
|
3785
3841
|
*
|
|
@@ -3790,15 +3846,7 @@ const DEFAULT_OPTIONS = { includeNestedProperties: false };
|
|
|
3790
3846
|
*/
|
|
3791
3847
|
function getPropertyByUuid(properties, uuid, options = DEFAULT_OPTIONS) {
|
|
3792
3848
|
const { includeNestedProperties } = options;
|
|
3793
|
-
|
|
3794
|
-
if (property) return property;
|
|
3795
|
-
if (includeNestedProperties) {
|
|
3796
|
-
for (const property of properties) if (property.properties.length > 0) {
|
|
3797
|
-
const nestedResult = getPropertyByUuid(property.properties, uuid, { includeNestedProperties });
|
|
3798
|
-
if (nestedResult) return nestedResult;
|
|
3799
|
-
}
|
|
3800
|
-
}
|
|
3801
|
-
return null;
|
|
3849
|
+
return searchPropertyResult(properties, { includeNestedProperties }, (currentProperties) => currentProperties.find((property) => property.uuid === uuid) ?? null);
|
|
3802
3850
|
}
|
|
3803
3851
|
/**
|
|
3804
3852
|
* Retrieves all values for a property with the given UUID
|
|
@@ -3809,16 +3857,28 @@ function getPropertyByUuid(properties, uuid, options = DEFAULT_OPTIONS) {
|
|
|
3809
3857
|
* @returns Array of property values as strings, or null if property not found
|
|
3810
3858
|
*/
|
|
3811
3859
|
function getPropertyValuesByUuid(properties, uuid, options = DEFAULT_OPTIONS) {
|
|
3812
|
-
const { includeNestedProperties } = options;
|
|
3813
|
-
|
|
3814
|
-
|
|
3815
|
-
|
|
3816
|
-
|
|
3817
|
-
|
|
3818
|
-
|
|
3819
|
-
|
|
3820
|
-
|
|
3821
|
-
|
|
3860
|
+
const { includeNestedProperties, limitToLeafPropertyValues } = options;
|
|
3861
|
+
return searchPropertyResult(properties, { includeNestedProperties }, (currentProperties) => {
|
|
3862
|
+
const property = currentProperties.find((currentProperty) => currentProperty.uuid === uuid) ?? null;
|
|
3863
|
+
if (property == null) return null;
|
|
3864
|
+
return getPropertyValuesResult(property.values, limitToLeafPropertyValues, true);
|
|
3865
|
+
}, (nestedResult) => getPropertyValuesResult(nestedResult, limitToLeafPropertyValues, true));
|
|
3866
|
+
}
|
|
3867
|
+
/**
|
|
3868
|
+
* Retrieves all value contents for a property with the given UUID
|
|
3869
|
+
*
|
|
3870
|
+
* @param properties - Array of properties to search through
|
|
3871
|
+
* @param uuid - The UUID to search for
|
|
3872
|
+
* @param options - Search options, including whether to include nested properties
|
|
3873
|
+
* @returns Array of property value contents as strings, or null if property not found
|
|
3874
|
+
*/
|
|
3875
|
+
function getPropertyValueContentsByUuid(properties, uuid, options = DEFAULT_OPTIONS) {
|
|
3876
|
+
const { includeNestedProperties, limitToLeafPropertyValues } = options;
|
|
3877
|
+
return searchPropertyResult(properties, { includeNestedProperties }, (currentProperties) => {
|
|
3878
|
+
const property = currentProperties.find((currentProperty) => currentProperty.uuid === uuid) ?? null;
|
|
3879
|
+
if (property == null) return null;
|
|
3880
|
+
return getPropertyValuesResult(property.values, limitToLeafPropertyValues, false).map((value) => value.content);
|
|
3881
|
+
});
|
|
3822
3882
|
}
|
|
3823
3883
|
/**
|
|
3824
3884
|
* Gets the first value of a property with the given UUID
|
|
@@ -3829,16 +3889,34 @@ function getPropertyValuesByUuid(properties, uuid, options = DEFAULT_OPTIONS) {
|
|
|
3829
3889
|
* @returns The first property value as string, or null if property not found
|
|
3830
3890
|
*/
|
|
3831
3891
|
function getPropertyValueByUuid(properties, uuid, options = DEFAULT_OPTIONS) {
|
|
3832
|
-
const { includeNestedProperties } = options;
|
|
3833
|
-
|
|
3834
|
-
|
|
3835
|
-
|
|
3836
|
-
|
|
3837
|
-
|
|
3838
|
-
|
|
3839
|
-
|
|
3840
|
-
}
|
|
3841
|
-
|
|
3892
|
+
const { includeNestedProperties, limitToLeafPropertyValues } = options;
|
|
3893
|
+
return searchPropertyResult(properties, { includeNestedProperties }, (currentProperties) => {
|
|
3894
|
+
const values = getPropertyValuesByUuid(currentProperties, uuid, {
|
|
3895
|
+
includeNestedProperties: false,
|
|
3896
|
+
limitToLeafPropertyValues
|
|
3897
|
+
});
|
|
3898
|
+
if (values === null || values.length === 0) return null;
|
|
3899
|
+
return getFirstPropertyValueResult(values, limitToLeafPropertyValues);
|
|
3900
|
+
}, (nestedResult) => getFirstPropertyValueResult([nestedResult], limitToLeafPropertyValues));
|
|
3901
|
+
}
|
|
3902
|
+
/**
|
|
3903
|
+
* Gets the first value content of a property with the given UUID
|
|
3904
|
+
*
|
|
3905
|
+
* @param properties - Array of properties to search through
|
|
3906
|
+
* @param uuid - The UUID to search for
|
|
3907
|
+
* @param options - Search options, including whether to include nested properties
|
|
3908
|
+
* @returns The first property value content as string, or null if property not found
|
|
3909
|
+
*/
|
|
3910
|
+
function getPropertyValueContentByUuid(properties, uuid, options = DEFAULT_OPTIONS) {
|
|
3911
|
+
const { includeNestedProperties, limitToLeafPropertyValues } = options;
|
|
3912
|
+
return searchPropertyResult(properties, { includeNestedProperties }, (currentProperties) => {
|
|
3913
|
+
const values = getPropertyValuesByUuid(currentProperties, uuid, {
|
|
3914
|
+
includeNestedProperties: false,
|
|
3915
|
+
limitToLeafPropertyValues
|
|
3916
|
+
});
|
|
3917
|
+
if (values === null || values.length === 0) return null;
|
|
3918
|
+
return getFirstPropertyValueContentResult(values, limitToLeafPropertyValues);
|
|
3919
|
+
});
|
|
3842
3920
|
}
|
|
3843
3921
|
/**
|
|
3844
3922
|
* Finds a property by its label in an array of properties
|
|
@@ -3850,15 +3928,7 @@ function getPropertyValueByUuid(properties, uuid, options = DEFAULT_OPTIONS) {
|
|
|
3850
3928
|
*/
|
|
3851
3929
|
function getPropertyByLabel(properties, label, options = DEFAULT_OPTIONS) {
|
|
3852
3930
|
const { includeNestedProperties } = options;
|
|
3853
|
-
|
|
3854
|
-
if (property) return property;
|
|
3855
|
-
if (includeNestedProperties) {
|
|
3856
|
-
for (const property of properties) if (property.properties.length > 0) {
|
|
3857
|
-
const nestedResult = getPropertyByLabel(property.properties, label, { includeNestedProperties });
|
|
3858
|
-
if (nestedResult) return nestedResult;
|
|
3859
|
-
}
|
|
3860
|
-
}
|
|
3861
|
-
return null;
|
|
3931
|
+
return searchPropertyResult(properties, { includeNestedProperties }, (currentProperties) => currentProperties.find((property) => property.label === label) ?? null);
|
|
3862
3932
|
}
|
|
3863
3933
|
/**
|
|
3864
3934
|
* Finds a property by its label and all values in an array of properties
|
|
@@ -3870,16 +3940,29 @@ function getPropertyByLabel(properties, label, options = DEFAULT_OPTIONS) {
|
|
|
3870
3940
|
* @returns The matching Property object, or null if not found or all values do not match
|
|
3871
3941
|
*/
|
|
3872
3942
|
function getPropertyByLabelAndValues(properties, label, values, options = DEFAULT_OPTIONS) {
|
|
3873
|
-
const { includeNestedProperties } = options;
|
|
3874
|
-
|
|
3875
|
-
|
|
3876
|
-
|
|
3877
|
-
|
|
3878
|
-
|
|
3879
|
-
|
|
3880
|
-
|
|
3881
|
-
|
|
3882
|
-
|
|
3943
|
+
const { includeNestedProperties, limitToLeafPropertyValues } = options;
|
|
3944
|
+
return searchPropertyResult(properties, { includeNestedProperties }, (currentProperties) => {
|
|
3945
|
+
const property = currentProperties.find((currentProperty) => currentProperty.label === label && deepEqual(currentProperty.values, values)) ?? null;
|
|
3946
|
+
if (property == null) return null;
|
|
3947
|
+
return getNormalizedProperty(property, limitToLeafPropertyValues);
|
|
3948
|
+
}, (nestedResult) => getNormalizedProperty(nestedResult, limitToLeafPropertyValues));
|
|
3949
|
+
}
|
|
3950
|
+
/**
|
|
3951
|
+
* Finds a property by its label and all values in an array of properties
|
|
3952
|
+
*
|
|
3953
|
+
* @param properties - Array of properties to search through
|
|
3954
|
+
* @param label - The label to search for
|
|
3955
|
+
* @param valueContents - The value contents to search for
|
|
3956
|
+
* @param options - Search options, including whether to include nested properties
|
|
3957
|
+
* @returns The matching Property object, or null if not found or all values do not match
|
|
3958
|
+
*/
|
|
3959
|
+
function getPropertyByLabelAndValueContents(properties, label, valueContents, options = DEFAULT_OPTIONS) {
|
|
3960
|
+
const { includeNestedProperties, limitToLeafPropertyValues } = options;
|
|
3961
|
+
return searchPropertyResult(properties, { includeNestedProperties }, (currentProperties) => {
|
|
3962
|
+
const property = currentProperties.find((currentProperty) => currentProperty.label === label && deepEqual(currentProperty.values.map((value) => value.content), valueContents)) ?? null;
|
|
3963
|
+
if (property == null) return null;
|
|
3964
|
+
return getNormalizedProperty(property, limitToLeafPropertyValues, clonePropertyValues);
|
|
3965
|
+
}, (nestedResult) => getNormalizedProperty(nestedResult, limitToLeafPropertyValues));
|
|
3883
3966
|
}
|
|
3884
3967
|
/**
|
|
3885
3968
|
* Finds a property by its label and value in an array of properties
|
|
@@ -3891,16 +3974,29 @@ function getPropertyByLabelAndValues(properties, label, values, options = DEFAUL
|
|
|
3891
3974
|
* @returns The matching Property object, or null if not found or value does not match
|
|
3892
3975
|
*/
|
|
3893
3976
|
function getPropertyByLabelAndValue(properties, label, value, options = DEFAULT_OPTIONS) {
|
|
3894
|
-
const { includeNestedProperties } = options;
|
|
3895
|
-
|
|
3896
|
-
|
|
3897
|
-
|
|
3898
|
-
|
|
3899
|
-
|
|
3900
|
-
|
|
3901
|
-
|
|
3902
|
-
|
|
3903
|
-
|
|
3977
|
+
const { includeNestedProperties, limitToLeafPropertyValues } = options;
|
|
3978
|
+
return searchPropertyResult(properties, { includeNestedProperties }, (currentProperties) => {
|
|
3979
|
+
const property = currentProperties.find((currentProperty) => currentProperty.label === label && currentProperty.values.some((candidateValue) => deepEqual(candidateValue, value))) ?? null;
|
|
3980
|
+
if (property == null) return null;
|
|
3981
|
+
return getNormalizedProperty(property, limitToLeafPropertyValues);
|
|
3982
|
+
}, (nestedResult) => getNormalizedProperty(nestedResult, limitToLeafPropertyValues));
|
|
3983
|
+
}
|
|
3984
|
+
/**
|
|
3985
|
+
* Finds a property by its label and value content in an array of properties
|
|
3986
|
+
*
|
|
3987
|
+
* @param properties - Array of properties to search through
|
|
3988
|
+
* @param label - The label to search for
|
|
3989
|
+
* @param valueContent - The value content to search for
|
|
3990
|
+
* @param options - Search options, including whether to include nested properties
|
|
3991
|
+
* @returns The matching Property object, or null if not found or value content does not match
|
|
3992
|
+
*/
|
|
3993
|
+
function getPropertyByLabelAndValueContent(properties, label, valueContent, options = DEFAULT_OPTIONS) {
|
|
3994
|
+
const { includeNestedProperties, limitToLeafPropertyValues } = options;
|
|
3995
|
+
return searchPropertyResult(properties, { includeNestedProperties }, (currentProperties) => {
|
|
3996
|
+
const property = currentProperties.find((currentProperty) => currentProperty.label === label && currentProperty.values.some((value) => deepEqual(value.content, valueContent))) ?? null;
|
|
3997
|
+
if (property == null) return null;
|
|
3998
|
+
return getNormalizedProperty(property, limitToLeafPropertyValues);
|
|
3999
|
+
}, (nestedResult) => getNormalizedProperty(nestedResult, limitToLeafPropertyValues));
|
|
3904
4000
|
}
|
|
3905
4001
|
/**
|
|
3906
4002
|
* Retrieves all values for a property with the given label
|
|
@@ -3911,16 +4007,12 @@ function getPropertyByLabelAndValue(properties, label, value, options = DEFAULT_
|
|
|
3911
4007
|
* @returns Array of property values as strings, or null if property not found
|
|
3912
4008
|
*/
|
|
3913
4009
|
function getPropertyValuesByLabel(properties, label, options = DEFAULT_OPTIONS) {
|
|
3914
|
-
const { includeNestedProperties } = options;
|
|
3915
|
-
|
|
3916
|
-
|
|
3917
|
-
|
|
3918
|
-
|
|
3919
|
-
|
|
3920
|
-
if (nestedResult) return nestedResult;
|
|
3921
|
-
}
|
|
3922
|
-
}
|
|
3923
|
-
return null;
|
|
4010
|
+
const { includeNestedProperties, limitToLeafPropertyValues } = options;
|
|
4011
|
+
return searchPropertyResult(properties, { includeNestedProperties }, (currentProperties) => {
|
|
4012
|
+
const property = currentProperties.find((currentProperty) => currentProperty.label === label) ?? null;
|
|
4013
|
+
if (property == null) return null;
|
|
4014
|
+
return getPropertyValuesResult(property.values, limitToLeafPropertyValues, false);
|
|
4015
|
+
}, (nestedResult) => getPropertyValuesResult(nestedResult, limitToLeafPropertyValues, false));
|
|
3924
4016
|
}
|
|
3925
4017
|
/**
|
|
3926
4018
|
* Gets the first value of a property with the given label
|
|
@@ -3931,16 +4023,34 @@ function getPropertyValuesByLabel(properties, label, options = DEFAULT_OPTIONS)
|
|
|
3931
4023
|
* @returns The first property value as string, or null if property not found
|
|
3932
4024
|
*/
|
|
3933
4025
|
function getPropertyValueByLabel(properties, label, options = DEFAULT_OPTIONS) {
|
|
3934
|
-
const { includeNestedProperties } = options;
|
|
3935
|
-
|
|
3936
|
-
|
|
3937
|
-
|
|
3938
|
-
|
|
3939
|
-
|
|
3940
|
-
|
|
3941
|
-
|
|
3942
|
-
}
|
|
3943
|
-
|
|
4026
|
+
const { includeNestedProperties, limitToLeafPropertyValues } = options;
|
|
4027
|
+
return searchPropertyResult(properties, { includeNestedProperties }, (currentProperties) => {
|
|
4028
|
+
const values = getPropertyValuesByLabel(currentProperties, label, {
|
|
4029
|
+
includeNestedProperties: false,
|
|
4030
|
+
limitToLeafPropertyValues
|
|
4031
|
+
});
|
|
4032
|
+
if (values === null || values.length === 0) return null;
|
|
4033
|
+
return getFirstPropertyValueResult(values, limitToLeafPropertyValues);
|
|
4034
|
+
}, (nestedResult) => getFirstPropertyValueResult([nestedResult], limitToLeafPropertyValues));
|
|
4035
|
+
}
|
|
4036
|
+
/**
|
|
4037
|
+
* Gets the first value content of a property with the given label
|
|
4038
|
+
*
|
|
4039
|
+
* @param properties - Array of properties to search through
|
|
4040
|
+
* @param label - The label to search for
|
|
4041
|
+
* @param options - Search options, including whether to include nested properties
|
|
4042
|
+
* @returns The first property value content as string, or null if property not found
|
|
4043
|
+
*/
|
|
4044
|
+
function getPropertyValueContentByLabel(properties, label, options = DEFAULT_OPTIONS) {
|
|
4045
|
+
const { includeNestedProperties, limitToLeafPropertyValues } = options;
|
|
4046
|
+
return searchPropertyResult(properties, { includeNestedProperties }, (currentProperties) => {
|
|
4047
|
+
const values = getPropertyValuesByLabel(currentProperties, label, {
|
|
4048
|
+
includeNestedProperties: false,
|
|
4049
|
+
limitToLeafPropertyValues
|
|
4050
|
+
});
|
|
4051
|
+
if (values === null || values.length === 0) return null;
|
|
4052
|
+
return getFirstPropertyValueContentResult(values, limitToLeafPropertyValues);
|
|
4053
|
+
});
|
|
3944
4054
|
}
|
|
3945
4055
|
/**
|
|
3946
4056
|
* Gets all unique properties from an array of properties
|
|
@@ -3950,19 +4060,13 @@ function getPropertyValueByLabel(properties, label, options = DEFAULT_OPTIONS) {
|
|
|
3950
4060
|
* @returns Array of unique properties
|
|
3951
4061
|
*/
|
|
3952
4062
|
function getUniqueProperties(properties, options = DEFAULT_OPTIONS) {
|
|
3953
|
-
const { includeNestedProperties } = options;
|
|
4063
|
+
const { includeNestedProperties, limitToLeafPropertyValues } = options;
|
|
3954
4064
|
const uniqueProperties = new Array();
|
|
3955
|
-
|
|
3956
|
-
if (uniqueProperties.some((p) => p.uuid === property.uuid))
|
|
4065
|
+
visitProperties(properties, includeNestedProperties, (property) => {
|
|
4066
|
+
if (uniqueProperties.some((p) => p.uuid === property.uuid)) return;
|
|
3957
4067
|
uniqueProperties.push(property);
|
|
3958
|
-
|
|
3959
|
-
|
|
3960
|
-
for (const property of nestedProperties) {
|
|
3961
|
-
if (uniqueProperties.some((p) => p.uuid === property.uuid)) continue;
|
|
3962
|
-
uniqueProperties.push(property);
|
|
3963
|
-
}
|
|
3964
|
-
}
|
|
3965
|
-
}
|
|
4068
|
+
});
|
|
4069
|
+
if (limitToLeafPropertyValues) return uniqueProperties.map((property) => getNormalizedProperty(property, limitToLeafPropertyValues));
|
|
3966
4070
|
return uniqueProperties;
|
|
3967
4071
|
}
|
|
3968
4072
|
/**
|
|
@@ -3975,17 +4079,10 @@ function getUniqueProperties(properties, options = DEFAULT_OPTIONS) {
|
|
|
3975
4079
|
function getUniquePropertyLabels(properties, options = DEFAULT_OPTIONS) {
|
|
3976
4080
|
const { includeNestedProperties } = options;
|
|
3977
4081
|
const uniquePropertyLabels = new Array();
|
|
3978
|
-
|
|
3979
|
-
if (uniquePropertyLabels.includes(property.label))
|
|
4082
|
+
visitProperties(properties, includeNestedProperties, (property) => {
|
|
4083
|
+
if (uniquePropertyLabels.includes(property.label)) return;
|
|
3980
4084
|
uniquePropertyLabels.push(property.label);
|
|
3981
|
-
|
|
3982
|
-
const nestedProperties = getUniquePropertyLabels(property.properties, { includeNestedProperties: true });
|
|
3983
|
-
for (const property of nestedProperties) {
|
|
3984
|
-
if (uniquePropertyLabels.includes(property)) continue;
|
|
3985
|
-
uniquePropertyLabels.push(property);
|
|
3986
|
-
}
|
|
3987
|
-
}
|
|
3988
|
-
}
|
|
4085
|
+
});
|
|
3989
4086
|
return uniquePropertyLabels;
|
|
3990
4087
|
}
|
|
3991
4088
|
/**
|
|
@@ -4007,25 +4104,28 @@ function getLeafPropertyValues(propertyValues) {
|
|
|
4007
4104
|
* @returns True if the property matches the filter criteria, false otherwise
|
|
4008
4105
|
*/
|
|
4009
4106
|
function filterProperties(property, filter, options = DEFAULT_OPTIONS) {
|
|
4010
|
-
const { includeNestedProperties } = options;
|
|
4107
|
+
const { includeNestedProperties, limitToLeafPropertyValues } = options;
|
|
4011
4108
|
if (filter.label.toLocaleLowerCase("en-US") === "all fields" || property.label.toLocaleLowerCase("en-US") === filter.label.toLocaleLowerCase("en-US")) {
|
|
4012
4109
|
let isFound = property.values.some((value) => {
|
|
4013
4110
|
if (value.content === null) return false;
|
|
4014
4111
|
if (typeof value.content === "string") {
|
|
4015
|
-
if (typeof filter.value !== "string") return false;
|
|
4016
|
-
return value.content.toLocaleLowerCase("en-US").includes(filter.value.toLocaleLowerCase("en-US"));
|
|
4112
|
+
if (typeof filter.value.content !== "string") return false;
|
|
4113
|
+
return value.content.toLocaleLowerCase("en-US").includes(filter.value.content.toLocaleLowerCase("en-US"));
|
|
4017
4114
|
}
|
|
4018
4115
|
if (typeof value.content === "number") {
|
|
4019
|
-
if (typeof filter.value !== "number") return false;
|
|
4020
|
-
return value.content === filter.value;
|
|
4116
|
+
if (typeof filter.value.content !== "number") return false;
|
|
4117
|
+
return value.content === filter.value.content;
|
|
4021
4118
|
}
|
|
4022
4119
|
if (typeof value.content === "boolean") {
|
|
4023
|
-
if (typeof filter.value !== "boolean") return false;
|
|
4024
|
-
return value.content === filter.value;
|
|
4120
|
+
if (typeof filter.value.content !== "boolean") return false;
|
|
4121
|
+
return value.content === filter.value.content;
|
|
4025
4122
|
}
|
|
4026
4123
|
return false;
|
|
4027
4124
|
});
|
|
4028
|
-
if (!isFound && includeNestedProperties) isFound = property.properties.some((
|
|
4125
|
+
if (!isFound && includeNestedProperties) isFound = property.properties.some((nestedProperty) => filterProperties(nestedProperty, filter, {
|
|
4126
|
+
includeNestedProperties: true,
|
|
4127
|
+
limitToLeafPropertyValues
|
|
4128
|
+
}));
|
|
4029
4129
|
return isFound;
|
|
4030
4130
|
}
|
|
4031
4131
|
return false;
|
|
@@ -4042,7 +4142,7 @@ const TRAILING_SLASH_REGEX = /\/$/;
|
|
|
4042
4142
|
* @returns Array of CSS styles
|
|
4043
4143
|
*/
|
|
4044
4144
|
function parseCssStylesFromProperties(properties, cssVariant) {
|
|
4045
|
-
const cssProperties =
|
|
4145
|
+
const cssProperties = getPropertyByLabelAndValueContent(properties, "presentation", cssVariant != null ? `css-${cssVariant}` : "css")?.properties ?? [];
|
|
4046
4146
|
const styles = [];
|
|
4047
4147
|
for (const property of cssProperties) {
|
|
4048
4148
|
const value = property.values[0]?.content?.toString();
|
|
@@ -4153,9 +4253,9 @@ function parseWebElementProperties(componentProperty, elementResource) {
|
|
|
4153
4253
|
case "3d-viewer": {
|
|
4154
4254
|
const resourceLink = links.find((link) => link.category === "resource" && link.fileFormat === "model/obj");
|
|
4155
4255
|
if (resourceLink?.uuid == null) throw new Error(`Resource link not found for the following component: “${componentName}”`);
|
|
4156
|
-
let isInteractive =
|
|
4256
|
+
let isInteractive = getPropertyValueContentByLabel(componentProperty.properties, "is-interactive");
|
|
4157
4257
|
isInteractive ??= true;
|
|
4158
|
-
let isControlsDisplayed =
|
|
4258
|
+
let isControlsDisplayed = getPropertyValueContentByLabel(componentProperty.properties, "controls-displayed");
|
|
4159
4259
|
isControlsDisplayed ??= true;
|
|
4160
4260
|
properties = {
|
|
4161
4261
|
component: "3d-viewer",
|
|
@@ -4190,13 +4290,13 @@ function parseWebElementProperties(componentProperty, elementResource) {
|
|
|
4190
4290
|
case "annotated-image": {
|
|
4191
4291
|
const imageLinks = links.filter((link) => link.type === "image" || link.type === "IIIF");
|
|
4192
4292
|
if (imageLinks.length === 0 || imageLinks[0].uuid == null) throw new Error(`Image link not found for the following component: “${componentName}”`);
|
|
4193
|
-
let isFilterInputDisplayed =
|
|
4293
|
+
let isFilterInputDisplayed = getPropertyValueContentByLabel(componentProperty.properties, "filter-input-displayed");
|
|
4194
4294
|
isFilterInputDisplayed ??= true;
|
|
4195
|
-
let isOptionsDisplayed =
|
|
4295
|
+
let isOptionsDisplayed = getPropertyValueContentByLabel(componentProperty.properties, "options-displayed");
|
|
4196
4296
|
isOptionsDisplayed ??= true;
|
|
4197
|
-
let isAnnotationHighlightsDisplayed =
|
|
4297
|
+
let isAnnotationHighlightsDisplayed = getPropertyValueContentByLabel(componentProperty.properties, "annotation-highlights-displayed");
|
|
4198
4298
|
isAnnotationHighlightsDisplayed ??= true;
|
|
4199
|
-
let isAnnotationTooltipsDisplayed =
|
|
4299
|
+
let isAnnotationTooltipsDisplayed = getPropertyValueContentByLabel(componentProperty.properties, "annotation-tooltips-displayed");
|
|
4200
4300
|
isAnnotationTooltipsDisplayed ??= true;
|
|
4201
4301
|
properties = {
|
|
4202
4302
|
component: "annotated-image",
|
|
@@ -4211,11 +4311,11 @@ function parseWebElementProperties(componentProperty, elementResource) {
|
|
|
4211
4311
|
case "audio-player": {
|
|
4212
4312
|
const audioLink = links.find((link) => link.type === "audio");
|
|
4213
4313
|
if (audioLink?.uuid == null) throw new Error(`Audio link not found for the following component: “${componentName}”`);
|
|
4214
|
-
let isSpeedControlsDisplayed =
|
|
4314
|
+
let isSpeedControlsDisplayed = getPropertyValueContentByLabel(componentProperty.properties, "speed-controls-displayed");
|
|
4215
4315
|
isSpeedControlsDisplayed ??= true;
|
|
4216
|
-
let isVolumeControlsDisplayed =
|
|
4316
|
+
let isVolumeControlsDisplayed = getPropertyValueContentByLabel(componentProperty.properties, "volume-controls-displayed");
|
|
4217
4317
|
isVolumeControlsDisplayed ??= true;
|
|
4218
|
-
let isSeekBarDisplayed =
|
|
4318
|
+
let isSeekBarDisplayed = getPropertyValueContentByLabel(componentProperty.properties, "seek-bar-displayed");
|
|
4219
4319
|
isSeekBarDisplayed ??= true;
|
|
4220
4320
|
properties = {
|
|
4221
4321
|
component: "audio-player",
|
|
@@ -4230,9 +4330,9 @@ function parseWebElementProperties(componentProperty, elementResource) {
|
|
|
4230
4330
|
const itemLinks = links.filter((link) => link.category !== "bibliography");
|
|
4231
4331
|
const bibliographyLink = links.find((link) => link.category === "bibliography");
|
|
4232
4332
|
if (itemLinks.length === 0 && bibliographyLink?.bibliographies == null) throw new Error(`No links found for the following component: “${componentName}”`);
|
|
4233
|
-
let layout =
|
|
4333
|
+
let layout = getPropertyValueContentByLabel(componentProperty.properties, "layout");
|
|
4234
4334
|
layout ??= "long";
|
|
4235
|
-
let isSourceDocumentDisplayed =
|
|
4335
|
+
let isSourceDocumentDisplayed = getPropertyValueContentByLabel(componentProperty.properties, "source-document-displayed");
|
|
4236
4336
|
isSourceDocumentDisplayed ??= true;
|
|
4237
4337
|
properties = {
|
|
4238
4338
|
component: "bibliography",
|
|
@@ -4244,7 +4344,7 @@ function parseWebElementProperties(componentProperty, elementResource) {
|
|
|
4244
4344
|
break;
|
|
4245
4345
|
}
|
|
4246
4346
|
case "button": {
|
|
4247
|
-
let variant =
|
|
4347
|
+
let variant = getPropertyValueContentByLabel(componentProperty.properties, "variant");
|
|
4248
4348
|
variant ??= "default";
|
|
4249
4349
|
let isExternal = false;
|
|
4250
4350
|
const navigateToProperty = getPropertyByLabel(componentProperty.properties, "navigate-to");
|
|
@@ -4255,9 +4355,9 @@ function parseWebElementProperties(componentProperty, elementResource) {
|
|
|
4255
4355
|
if (href === null) throw new Error(`Properties “navigate-to” or “link-to” not found for the following component: “${componentName}”`);
|
|
4256
4356
|
else isExternal = true;
|
|
4257
4357
|
}
|
|
4258
|
-
let startIcon =
|
|
4358
|
+
let startIcon = getPropertyValueContentByLabel(componentProperty.properties, "start-icon");
|
|
4259
4359
|
startIcon ??= null;
|
|
4260
|
-
let endIcon =
|
|
4360
|
+
let endIcon = getPropertyValueContentByLabel(componentProperty.properties, "end-icon");
|
|
4261
4361
|
endIcon ??= null;
|
|
4262
4362
|
let image = null;
|
|
4263
4363
|
const imageLink = links.find((link) => link.type === "image" || link.type === "IIIF");
|
|
@@ -4285,33 +4385,33 @@ function parseWebElementProperties(componentProperty, elementResource) {
|
|
|
4285
4385
|
const setLinks = links.filter((link) => link.category === "set");
|
|
4286
4386
|
if (setLinks.every((link) => link.uuid === null)) throw new Error(`Set links not found for the following component: “${componentName}”`);
|
|
4287
4387
|
const displayedProperties = getPropertyByLabel(componentProperty.properties, "use-property");
|
|
4288
|
-
let variant =
|
|
4289
|
-
variant ??= "
|
|
4290
|
-
let
|
|
4291
|
-
itemVariant ??= "detailed";
|
|
4292
|
-
let paginationVariant = getPropertyValueByLabel(componentProperty.properties, "pagination-variant");
|
|
4388
|
+
let variant = getPropertyValueContentByLabel(componentProperty.properties, "variant");
|
|
4389
|
+
variant ??= "detailed";
|
|
4390
|
+
let paginationVariant = getPropertyValueContentByLabel(componentProperty.properties, "pagination-variant");
|
|
4293
4391
|
paginationVariant ??= "default";
|
|
4294
|
-
let
|
|
4392
|
+
let loadingVariant = getPropertyValueContentByLabel(componentProperty.properties, "loading-variant");
|
|
4393
|
+
loadingVariant ??= "spinner";
|
|
4394
|
+
let imageQuality = getPropertyValueContentByLabel(componentProperty.properties, "image-quality");
|
|
4295
4395
|
imageQuality ??= "low";
|
|
4296
|
-
let isUsingQueryParams =
|
|
4396
|
+
let isUsingQueryParams = getPropertyValueContentByLabel(componentProperty.properties, "is-using-query-params");
|
|
4297
4397
|
isUsingQueryParams ??= false;
|
|
4298
|
-
let isFilterResultsBarDisplayed =
|
|
4398
|
+
let isFilterResultsBarDisplayed = getPropertyValueContentByLabel(componentProperty.properties, "filter-results-bar-displayed");
|
|
4299
4399
|
isFilterResultsBarDisplayed ??= false;
|
|
4300
|
-
let isFilterMapDisplayed =
|
|
4400
|
+
let isFilterMapDisplayed = getPropertyValueContentByLabel(componentProperty.properties, "filter-map-displayed");
|
|
4301
4401
|
isFilterMapDisplayed ??= false;
|
|
4302
|
-
let isFilterInputDisplayed =
|
|
4402
|
+
let isFilterInputDisplayed = getPropertyValueContentByLabel(componentProperty.properties, "filter-input-displayed");
|
|
4303
4403
|
isFilterInputDisplayed ??= false;
|
|
4304
|
-
let isFilterLimitedToInputFilter =
|
|
4404
|
+
let isFilterLimitedToInputFilter = getPropertyValueContentByLabel(componentProperty.properties, "filter-limit-to-input-filter");
|
|
4305
4405
|
isFilterLimitedToInputFilter ??= false;
|
|
4306
|
-
let isFilterLimitedToLeafPropertyValues =
|
|
4406
|
+
let isFilterLimitedToLeafPropertyValues = getPropertyValueContentByLabel(componentProperty.properties, "filter-limit-to-leaf-property-values");
|
|
4307
4407
|
isFilterLimitedToLeafPropertyValues ??= false;
|
|
4308
|
-
let isSortDisplayed =
|
|
4408
|
+
let isSortDisplayed = getPropertyValueContentByLabel(componentProperty.properties, "sort-displayed");
|
|
4309
4409
|
isSortDisplayed ??= false;
|
|
4310
|
-
let isFilterSidebarDisplayed =
|
|
4410
|
+
let isFilterSidebarDisplayed = getPropertyValueContentByLabel(componentProperty.properties, "filter-sidebar-displayed");
|
|
4311
4411
|
isFilterSidebarDisplayed ??= false;
|
|
4312
|
-
let filterSidebarSort =
|
|
4412
|
+
let filterSidebarSort = getPropertyValueContentByLabel(componentProperty.properties, "filter-sidebar-sort");
|
|
4313
4413
|
filterSidebarSort ??= "default";
|
|
4314
|
-
let layout =
|
|
4414
|
+
let layout = getPropertyValueContentByLabel(componentProperty.properties, "layout");
|
|
4315
4415
|
layout ??= "image-start";
|
|
4316
4416
|
const options = {
|
|
4317
4417
|
attributeFilters: {
|
|
@@ -4341,8 +4441,8 @@ function parseWebElementProperties(componentProperty, elementResource) {
|
|
|
4341
4441
|
label: value.content?.toString() ?? ""
|
|
4342
4442
|
})) ?? null,
|
|
4343
4443
|
variant,
|
|
4344
|
-
itemVariant,
|
|
4345
4444
|
paginationVariant,
|
|
4445
|
+
loadingVariant,
|
|
4346
4446
|
layout,
|
|
4347
4447
|
imageQuality,
|
|
4348
4448
|
isUsingQueryParams,
|
|
@@ -4361,8 +4461,8 @@ function parseWebElementProperties(componentProperty, elementResource) {
|
|
|
4361
4461
|
break;
|
|
4362
4462
|
}
|
|
4363
4463
|
case "empty-space": {
|
|
4364
|
-
const height =
|
|
4365
|
-
const width =
|
|
4464
|
+
const height = getPropertyValueContentByLabel(componentProperty.properties, "height");
|
|
4465
|
+
const width = getPropertyValueContentByLabel(componentProperty.properties, "width");
|
|
4366
4466
|
properties = {
|
|
4367
4467
|
component: "empty-space",
|
|
4368
4468
|
height: height?.toString() ?? null,
|
|
@@ -4373,9 +4473,9 @@ function parseWebElementProperties(componentProperty, elementResource) {
|
|
|
4373
4473
|
case "entries": {
|
|
4374
4474
|
const entriesLink = links.find((link) => link.category === "tree" || link.category === "set");
|
|
4375
4475
|
if (entriesLink?.uuid == null) throw new Error(`Entries link not found for the following component: “${componentName}”`);
|
|
4376
|
-
let variant =
|
|
4476
|
+
let variant = getPropertyValueContentByLabel(componentProperty.properties, "variant");
|
|
4377
4477
|
variant ??= "entry";
|
|
4378
|
-
let isFilterInputDisplayed =
|
|
4478
|
+
let isFilterInputDisplayed = getPropertyValueContentByLabel(componentProperty.properties, "filter-input-displayed");
|
|
4379
4479
|
isFilterInputDisplayed ??= false;
|
|
4380
4480
|
properties = {
|
|
4381
4481
|
component: "entries",
|
|
@@ -4388,8 +4488,8 @@ function parseWebElementProperties(componentProperty, elementResource) {
|
|
|
4388
4488
|
case "iframe": {
|
|
4389
4489
|
const href = links.find((link) => link.type === "webpage")?.href;
|
|
4390
4490
|
if (!href) throw new Error(`URL not found for the following component: “${componentName}”`);
|
|
4391
|
-
const height =
|
|
4392
|
-
const width =
|
|
4491
|
+
const height = getPropertyValueContentByLabel(componentProperty.properties, "height");
|
|
4492
|
+
const width = getPropertyValueContentByLabel(componentProperty.properties, "width");
|
|
4393
4493
|
properties = {
|
|
4394
4494
|
component: "iframe",
|
|
4395
4495
|
href: transformPermanentIdentificationUrl(href),
|
|
@@ -4401,7 +4501,7 @@ function parseWebElementProperties(componentProperty, elementResource) {
|
|
|
4401
4501
|
case "iiif-viewer": {
|
|
4402
4502
|
const manifestLink = links.find((link) => link.type === "IIIF");
|
|
4403
4503
|
if (manifestLink?.uuid == null) throw new Error(`Manifest link not found for the following component: “${componentName}”`);
|
|
4404
|
-
let variant =
|
|
4504
|
+
let variant = getPropertyValueContentByLabel(componentProperty.properties, "variant");
|
|
4405
4505
|
variant ??= "universal-viewer";
|
|
4406
4506
|
properties = {
|
|
4407
4507
|
component: "iiif-viewer",
|
|
@@ -4412,7 +4512,7 @@ function parseWebElementProperties(componentProperty, elementResource) {
|
|
|
4412
4512
|
}
|
|
4413
4513
|
case "image": {
|
|
4414
4514
|
if (links.length === 0) throw new Error(`No links found for the following component: “${componentName}”`);
|
|
4415
|
-
let imageQuality =
|
|
4515
|
+
let imageQuality = getPropertyValueContentByLabel(componentProperty.properties, "image-quality");
|
|
4416
4516
|
imageQuality ??= "high";
|
|
4417
4517
|
const images = [];
|
|
4418
4518
|
for (const link of links) {
|
|
@@ -4426,40 +4526,40 @@ function parseWebElementProperties(componentProperty, elementResource) {
|
|
|
4426
4526
|
quality: imageQuality
|
|
4427
4527
|
});
|
|
4428
4528
|
}
|
|
4429
|
-
let variant =
|
|
4529
|
+
let variant = getPropertyValueContentByLabel(componentProperty.properties, "variant");
|
|
4430
4530
|
variant ??= "default";
|
|
4431
|
-
let captionLayout =
|
|
4531
|
+
let captionLayout = getPropertyValueContentByLabel(componentProperty.properties, "layout-caption");
|
|
4432
4532
|
captionLayout ??= "bottom";
|
|
4433
4533
|
let width = null;
|
|
4434
|
-
const widthProperty =
|
|
4534
|
+
const widthProperty = getPropertyValueContentByLabel(componentProperty.properties, "width");
|
|
4435
4535
|
if (widthProperty !== null) {
|
|
4436
4536
|
if (typeof widthProperty === "number") width = widthProperty;
|
|
4437
4537
|
else if (typeof widthProperty === "string") width = Number.parseFloat(widthProperty);
|
|
4438
4538
|
}
|
|
4439
4539
|
let height = null;
|
|
4440
|
-
const heightProperty =
|
|
4540
|
+
const heightProperty = getPropertyValueContentByLabel(componentProperty.properties, "height");
|
|
4441
4541
|
if (heightProperty !== null) {
|
|
4442
4542
|
if (typeof heightProperty === "number") height = heightProperty;
|
|
4443
4543
|
else if (typeof heightProperty === "string") height = Number.parseFloat(heightProperty);
|
|
4444
4544
|
}
|
|
4445
|
-
let isFullWidth =
|
|
4545
|
+
let isFullWidth = getPropertyValueContentByLabel(componentProperty.properties, "is-full-width");
|
|
4446
4546
|
isFullWidth ??= true;
|
|
4447
|
-
let isFullHeight =
|
|
4547
|
+
let isFullHeight = getPropertyValueContentByLabel(componentProperty.properties, "is-full-height");
|
|
4448
4548
|
isFullHeight ??= true;
|
|
4449
|
-
let captionSource =
|
|
4549
|
+
let captionSource = getPropertyValueContentByLabel(componentProperty.properties, "source-caption");
|
|
4450
4550
|
captionSource ??= "name";
|
|
4451
|
-
let altTextSource =
|
|
4551
|
+
let altTextSource = getPropertyValueContentByLabel(componentProperty.properties, "alt-text-source");
|
|
4452
4552
|
altTextSource ??= "name";
|
|
4453
|
-
let isTransparentBackground =
|
|
4553
|
+
let isTransparentBackground = getPropertyValueContentByLabel(componentProperty.properties, "is-transparent");
|
|
4454
4554
|
isTransparentBackground ??= false;
|
|
4455
|
-
let isCover =
|
|
4555
|
+
let isCover = getPropertyValueContentByLabel(componentProperty.properties, "is-cover");
|
|
4456
4556
|
isCover ??= false;
|
|
4457
4557
|
const variantProperty = getPropertyByLabel(componentProperty.properties, "variant");
|
|
4458
4558
|
let carouselOptions = null;
|
|
4459
4559
|
if (images.length > 1) {
|
|
4460
4560
|
let secondsPerImage = 5;
|
|
4461
4561
|
if (variantProperty?.values[0].content === "carousel") {
|
|
4462
|
-
const secondsPerImageProperty =
|
|
4562
|
+
const secondsPerImageProperty = getPropertyValueContentByLabel(variantProperty.properties, "seconds-per-image");
|
|
4463
4563
|
if (secondsPerImageProperty !== null) {
|
|
4464
4564
|
if (typeof secondsPerImageProperty === "number") secondsPerImage = secondsPerImageProperty;
|
|
4465
4565
|
else if (typeof secondsPerImageProperty === "string") secondsPerImage = Number.parseFloat(secondsPerImageProperty);
|
|
@@ -4469,9 +4569,9 @@ function parseWebElementProperties(componentProperty, elementResource) {
|
|
|
4469
4569
|
}
|
|
4470
4570
|
let heroOptions = null;
|
|
4471
4571
|
if (variantProperty?.values[0].content === "hero") {
|
|
4472
|
-
let isBackgroundImageDisplayed =
|
|
4572
|
+
let isBackgroundImageDisplayed = getPropertyValueContentByLabel(variantProperty.properties, "background-image-displayed");
|
|
4473
4573
|
isBackgroundImageDisplayed ??= true;
|
|
4474
|
-
let isDocumentDisplayed =
|
|
4574
|
+
let isDocumentDisplayed = getPropertyValueContentByLabel(variantProperty.properties, "document-displayed");
|
|
4475
4575
|
isDocumentDisplayed ??= true;
|
|
4476
4576
|
heroOptions = {
|
|
4477
4577
|
isBackgroundImageDisplayed,
|
|
@@ -4500,7 +4600,7 @@ function parseWebElementProperties(componentProperty, elementResource) {
|
|
|
4500
4600
|
case "image-gallery": {
|
|
4501
4601
|
const galleryLink = links.find((link) => link.category === "tree" || link.category === "set");
|
|
4502
4602
|
if (galleryLink?.uuid == null) throw new Error(`Image gallery link not found for the following component: “${componentName}”`);
|
|
4503
|
-
let isFilterInputDisplayed =
|
|
4603
|
+
let isFilterInputDisplayed = getPropertyValueContentByLabel(componentProperty.properties, "filter-input-displayed");
|
|
4504
4604
|
isFilterInputDisplayed ??= true;
|
|
4505
4605
|
properties = {
|
|
4506
4606
|
component: "image-gallery",
|
|
@@ -4512,23 +4612,23 @@ function parseWebElementProperties(componentProperty, elementResource) {
|
|
|
4512
4612
|
case "map": {
|
|
4513
4613
|
const mapLink = links.find((link) => link.category === "set" || link.category === "tree");
|
|
4514
4614
|
if (mapLink?.uuid == null) throw new Error(`Map link not found for the following component: “${componentName}”`);
|
|
4515
|
-
let isInteractive =
|
|
4615
|
+
let isInteractive = getPropertyValueContentByLabel(componentProperty.properties, "is-interactive");
|
|
4516
4616
|
isInteractive ??= true;
|
|
4517
|
-
let isClustered =
|
|
4617
|
+
let isClustered = getPropertyValueContentByLabel(componentProperty.properties, "is-clustered");
|
|
4518
4618
|
isClustered ??= false;
|
|
4519
|
-
let isUsingPins =
|
|
4619
|
+
let isUsingPins = getPropertyValueContentByLabel(componentProperty.properties, "is-using-pins");
|
|
4520
4620
|
isUsingPins ??= false;
|
|
4521
|
-
let customBasemap =
|
|
4621
|
+
let customBasemap = getPropertyValueContentByLabel(componentProperty.properties, "custom-basemap");
|
|
4522
4622
|
customBasemap ??= null;
|
|
4523
4623
|
let initialBounds = null;
|
|
4524
|
-
const initialBoundsProperty =
|
|
4624
|
+
const initialBoundsProperty = getPropertyValueContentByLabel(componentProperty.properties, "initial-bounds");
|
|
4525
4625
|
if (initialBoundsProperty !== null) initialBounds = parseBounds(String(initialBoundsProperty));
|
|
4526
4626
|
let maximumBounds = null;
|
|
4527
|
-
const maximumBoundsProperty =
|
|
4627
|
+
const maximumBoundsProperty = getPropertyValueContentByLabel(componentProperty.properties, "maximum-bounds");
|
|
4528
4628
|
if (maximumBoundsProperty !== null) maximumBounds = parseBounds(String(maximumBoundsProperty));
|
|
4529
|
-
let isControlsDisplayed =
|
|
4629
|
+
let isControlsDisplayed = getPropertyValueContentByLabel(componentProperty.properties, "controls-displayed");
|
|
4530
4630
|
isControlsDisplayed ??= false;
|
|
4531
|
-
let isFullHeight =
|
|
4631
|
+
let isFullHeight = getPropertyValueContentByLabel(componentProperty.properties, "is-full-height");
|
|
4532
4632
|
isFullHeight ??= false;
|
|
4533
4633
|
properties = {
|
|
4534
4634
|
component: "map",
|
|
@@ -4551,7 +4651,7 @@ function parseWebElementProperties(componentProperty, elementResource) {
|
|
|
4551
4651
|
if (componentProperty.properties.length === 0) throw new Error(`Query properties not found for the following component: “${componentName}”`);
|
|
4552
4652
|
for (const queryItem of componentProperty.properties) {
|
|
4553
4653
|
const querySubProperties = queryItem.properties;
|
|
4554
|
-
const label =
|
|
4654
|
+
const label = getPropertyValueContentByLabel(querySubProperties, "query-prompt");
|
|
4555
4655
|
if (label === null) continue;
|
|
4556
4656
|
const queries = (getPropertyByLabel(querySubProperties, "use-property")?.values.filter((value) => value.uuid !== null) ?? []).map((propertyVariable) => {
|
|
4557
4657
|
if (propertyVariable.uuid === null) throw new Error(`Property variable UUID not found for the following component: “${componentName}”`);
|
|
@@ -4566,9 +4666,9 @@ function parseWebElementProperties(componentProperty, elementResource) {
|
|
|
4566
4666
|
language: "eng"
|
|
4567
4667
|
};
|
|
4568
4668
|
});
|
|
4569
|
-
let startIcon =
|
|
4669
|
+
let startIcon = getPropertyValueContentByLabel(querySubProperties, "start-icon");
|
|
4570
4670
|
startIcon ??= null;
|
|
4571
|
-
let endIcon =
|
|
4671
|
+
let endIcon = getPropertyValueContentByLabel(querySubProperties, "end-icon");
|
|
4572
4672
|
endIcon ??= null;
|
|
4573
4673
|
items.push({
|
|
4574
4674
|
label,
|
|
@@ -4599,11 +4699,11 @@ function parseWebElementProperties(componentProperty, elementResource) {
|
|
|
4599
4699
|
}
|
|
4600
4700
|
}
|
|
4601
4701
|
const displayedProperties = getPropertyByLabel(componentProperty.properties, "use-property");
|
|
4602
|
-
let
|
|
4603
|
-
|
|
4604
|
-
let paginationVariant =
|
|
4702
|
+
let variant = getPropertyValueContentByLabel(componentProperty.properties, "variant");
|
|
4703
|
+
variant ??= "detailed";
|
|
4704
|
+
let paginationVariant = getPropertyValueContentByLabel(componentProperty.properties, "pagination-variant");
|
|
4605
4705
|
paginationVariant ??= "default";
|
|
4606
|
-
let layout =
|
|
4706
|
+
let layout = getPropertyValueContentByLabel(componentProperty.properties, "layout");
|
|
4607
4707
|
layout ??= "image-start";
|
|
4608
4708
|
properties = {
|
|
4609
4709
|
component: "query",
|
|
@@ -4614,7 +4714,7 @@ function parseWebElementProperties(componentProperty, elementResource) {
|
|
|
4614
4714
|
uuid: value.uuid,
|
|
4615
4715
|
label: value.content?.toString() ?? ""
|
|
4616
4716
|
})) ?? null,
|
|
4617
|
-
|
|
4717
|
+
variant,
|
|
4618
4718
|
paginationVariant,
|
|
4619
4719
|
layout
|
|
4620
4720
|
};
|
|
@@ -4631,15 +4731,15 @@ function parseWebElementProperties(componentProperty, elementResource) {
|
|
|
4631
4731
|
}
|
|
4632
4732
|
case "search-bar": {
|
|
4633
4733
|
let queryVariant = null;
|
|
4634
|
-
queryVariant =
|
|
4734
|
+
queryVariant = getPropertyValueContentByLabel(componentProperty.properties, "query-variant");
|
|
4635
4735
|
queryVariant ??= "submit";
|
|
4636
4736
|
const boundElementUuid = getPropertyByLabel(componentProperty.properties, "bound-element")?.values[0]?.uuid ?? null;
|
|
4637
4737
|
const linkToProperty = getPropertyByLabel(componentProperty.properties, "link-to");
|
|
4638
4738
|
const href = linkToProperty?.values[0]?.href != null ? transformPermanentIdentificationUrl(linkToProperty.values[0].href) : linkToProperty?.values[0]?.slug ?? null;
|
|
4639
4739
|
if (!boundElementUuid && !href) throw new Error(`Bound element or href not found for the following component: “${componentName}”`);
|
|
4640
|
-
let placeholder =
|
|
4740
|
+
let placeholder = getPropertyValueContentByLabel(componentProperty.properties, "placeholder-text");
|
|
4641
4741
|
placeholder ??= null;
|
|
4642
|
-
let baseFilterQueries =
|
|
4742
|
+
let baseFilterQueries = getPropertyValueContentByLabel(componentProperty.properties, "base-filter-queries");
|
|
4643
4743
|
baseFilterQueries ??= null;
|
|
4644
4744
|
properties = {
|
|
4645
4745
|
component: "search-bar",
|
|
@@ -4660,7 +4760,7 @@ function parseWebElementProperties(componentProperty, elementResource) {
|
|
|
4660
4760
|
if (variantProperty !== null) {
|
|
4661
4761
|
variantName = variantProperty.values[0].content;
|
|
4662
4762
|
if (variantName === "paragraph" || variantName === "label" || variantName === "heading" || variantName === "display") {
|
|
4663
|
-
let size =
|
|
4763
|
+
let size = getPropertyValueContentByLabel(variantProperty.properties, "size");
|
|
4664
4764
|
size ??= "md";
|
|
4665
4765
|
variant = {
|
|
4666
4766
|
name: variantName,
|
|
@@ -4668,7 +4768,7 @@ function parseWebElementProperties(componentProperty, elementResource) {
|
|
|
4668
4768
|
};
|
|
4669
4769
|
} else variant = { name: variantName };
|
|
4670
4770
|
} else variant = { name: variantName };
|
|
4671
|
-
let headingLevel =
|
|
4771
|
+
let headingLevel = getPropertyValueContentByLabel(componentProperty.properties, "heading-level");
|
|
4672
4772
|
headingLevel ??= null;
|
|
4673
4773
|
properties = {
|
|
4674
4774
|
component: "text",
|
|
@@ -4690,7 +4790,7 @@ function parseWebElementProperties(componentProperty, elementResource) {
|
|
|
4690
4790
|
case "video": {
|
|
4691
4791
|
const videoLink = links.find((link) => link.type === "video");
|
|
4692
4792
|
if (videoLink?.uuid == null) throw new Error(`Video link not found for the following component: “${componentName}”`);
|
|
4693
|
-
let isChaptersDisplayed =
|
|
4793
|
+
let isChaptersDisplayed = getPropertyValueContentByLabel(componentProperty.properties, "chapters-displayed");
|
|
4694
4794
|
isChaptersDisplayed ??= true;
|
|
4695
4795
|
properties = {
|
|
4696
4796
|
component: "video",
|
|
@@ -4718,14 +4818,14 @@ function parseWebTitle(properties, identification, overrides) {
|
|
|
4718
4818
|
isCountDisplayed: overrides?.isCountDisplayed ?? false
|
|
4719
4819
|
}
|
|
4720
4820
|
};
|
|
4721
|
-
const titleProperties =
|
|
4821
|
+
const titleProperties = getPropertyByLabelAndValueContent(properties, "presentation", "title")?.properties ?? [];
|
|
4722
4822
|
if (titleProperties.length > 0) {
|
|
4723
|
-
title.variant =
|
|
4724
|
-
title.properties.isNameDisplayed =
|
|
4725
|
-
title.properties.isDescriptionDisplayed =
|
|
4726
|
-
title.properties.isDateDisplayed =
|
|
4727
|
-
title.properties.isCreatorsDisplayed =
|
|
4728
|
-
title.properties.isCountDisplayed =
|
|
4823
|
+
title.variant = getPropertyValueContentByLabel(titleProperties, "variant") ?? "default";
|
|
4824
|
+
title.properties.isNameDisplayed = getPropertyValueContentByLabel(titleProperties, "name-displayed") ?? false;
|
|
4825
|
+
title.properties.isDescriptionDisplayed = getPropertyValueContentByLabel(titleProperties, "description-displayed") ?? false;
|
|
4826
|
+
title.properties.isDateDisplayed = getPropertyValueContentByLabel(titleProperties, "date-displayed") ?? false;
|
|
4827
|
+
title.properties.isCreatorsDisplayed = getPropertyValueContentByLabel(titleProperties, "creators-displayed") ?? false;
|
|
4828
|
+
title.properties.isCountDisplayed = getPropertyValueContentByLabel(titleProperties, "count-displayed") ?? false;
|
|
4729
4829
|
}
|
|
4730
4830
|
return title;
|
|
4731
4831
|
}
|
|
@@ -4746,7 +4846,7 @@ function parseWebElement(elementResource) {
|
|
|
4746
4846
|
const cssStyles = parseResponsiveCssStyles(elementProperties);
|
|
4747
4847
|
const title = parseWebTitle(elementProperties, identification, {
|
|
4748
4848
|
isNameDisplayed: properties.component === "annotated-image" || properties.component === "annotated-document" || properties.component === "collection",
|
|
4749
|
-
isCountDisplayed: properties.component === "collection"
|
|
4849
|
+
isCountDisplayed: properties.component === "collection"
|
|
4750
4850
|
});
|
|
4751
4851
|
return {
|
|
4752
4852
|
uuid: elementResource.uuid,
|
|
@@ -4766,7 +4866,7 @@ function parseWebElement(elementResource) {
|
|
|
4766
4866
|
const parseWebpageResources = (webpageResources, type) => {
|
|
4767
4867
|
const returnElements = [];
|
|
4768
4868
|
for (const resource of webpageResources) {
|
|
4769
|
-
if (
|
|
4869
|
+
if (getPropertyByLabelAndValueContent(resource.properties ? parseProperties(ensureArray(resource.properties.property)) : [], "presentation", type) === null) continue;
|
|
4770
4870
|
switch (type) {
|
|
4771
4871
|
case "element": {
|
|
4772
4872
|
const element = parseWebElement(resource);
|
|
@@ -4795,7 +4895,7 @@ const parseWebpageResources = (webpageResources, type) => {
|
|
|
4795
4895
|
*/
|
|
4796
4896
|
function parseWebpage(webpageResource, slugPrefix) {
|
|
4797
4897
|
const webpageProperties = webpageResource.properties ? parseProperties(ensureArray(webpageResource.properties.property)) : [];
|
|
4798
|
-
if (webpageProperties.length === 0 ||
|
|
4898
|
+
if (webpageProperties.length === 0 || getPropertyValueContentByLabel(webpageProperties, "presentation") !== "page") return null;
|
|
4799
4899
|
const identification = parseIdentification(webpageResource.identification);
|
|
4800
4900
|
const slug = webpageResource.slug?.replace(SEGMENT_UNIQUE_SLUG_PREFIX_REGEX, "") ?? null;
|
|
4801
4901
|
if (slug == null) throw new Error(`Slug not found for page “${identification.label}”`);
|
|
@@ -4826,7 +4926,7 @@ function parseWebpage(webpageResource, slugPrefix) {
|
|
|
4826
4926
|
const webpageResources = webpageResource.resource != null ? ensureArray(webpageResource.resource) : [];
|
|
4827
4927
|
const items = [];
|
|
4828
4928
|
for (const resource of webpageResources) {
|
|
4829
|
-
const resourceType =
|
|
4929
|
+
const resourceType = getPropertyValueContentByLabel(resource.properties != null ? parseProperties(ensureArray(resource.properties.property)) : [], "presentation");
|
|
4830
4930
|
if (resourceType === null) continue;
|
|
4831
4931
|
switch (resourceType) {
|
|
4832
4932
|
case "segment": {
|
|
@@ -4848,14 +4948,14 @@ function parseWebpage(webpageResource, slugPrefix) {
|
|
|
4848
4948
|
}
|
|
4849
4949
|
returnWebpage.items = items;
|
|
4850
4950
|
returnWebpage.webpages = webpageResource.resource != null ? parseWebpageResources(ensureArray(webpageResource.resource), "page") : [];
|
|
4851
|
-
const webpageSubProperties =
|
|
4951
|
+
const webpageSubProperties = getPropertyByLabelAndValueContent(webpageProperties, "presentation", "page")?.properties ?? [];
|
|
4852
4952
|
if (webpageSubProperties.length > 0) {
|
|
4853
|
-
returnWebpage.properties.isDisplayedInNavbar =
|
|
4854
|
-
returnWebpage.properties.width =
|
|
4855
|
-
returnWebpage.properties.variant =
|
|
4856
|
-
returnWebpage.properties.isSidebarDisplayed =
|
|
4857
|
-
returnWebpage.properties.isBreadcrumbsDisplayed =
|
|
4858
|
-
returnWebpage.properties.isNavbarSearchBarDisplayed =
|
|
4953
|
+
returnWebpage.properties.isDisplayedInNavbar = getPropertyValueContentByLabel(webpageSubProperties, "displayed-in-navbar") ?? true;
|
|
4954
|
+
returnWebpage.properties.width = getPropertyValueContentByLabel(webpageSubProperties, "width") ?? "default";
|
|
4955
|
+
returnWebpage.properties.variant = getPropertyValueContentByLabel(webpageSubProperties, "variant") ?? "default";
|
|
4956
|
+
returnWebpage.properties.isSidebarDisplayed = getPropertyValueContentByLabel(webpageSubProperties, "sidebar-displayed") ?? true;
|
|
4957
|
+
returnWebpage.properties.isBreadcrumbsDisplayed = getPropertyValueContentByLabel(webpageSubProperties, "breadcrumbs-displayed") ?? false;
|
|
4958
|
+
returnWebpage.properties.isNavbarSearchBarDisplayed = getPropertyValueContentByLabel(webpageSubProperties, "navbar-search-bar-displayed") ?? true;
|
|
4859
4959
|
}
|
|
4860
4960
|
if (imageLink?.uuid != null) returnWebpage.properties.backgroundImage = {
|
|
4861
4961
|
uuid: imageLink.uuid,
|
|
@@ -4890,7 +4990,7 @@ function parseWebpages(webpageResources, slugPrefix) {
|
|
|
4890
4990
|
*/
|
|
4891
4991
|
function parseWebSegment(segmentResource, slugPrefix) {
|
|
4892
4992
|
const webpageProperties = segmentResource.properties ? parseProperties(ensureArray(segmentResource.properties.property)) : [];
|
|
4893
|
-
if (webpageProperties.length === 0 ||
|
|
4993
|
+
if (webpageProperties.length === 0 || getPropertyValueContentByLabel(webpageProperties, "presentation") !== "segment") return null;
|
|
4894
4994
|
const identification = parseIdentification(segmentResource.identification);
|
|
4895
4995
|
const slug = segmentResource.identification.abbreviation != null ? parseFakeStringOrContent(segmentResource.identification.abbreviation) : null;
|
|
4896
4996
|
if (slug == null) throw new Error(`Slug not found for segment “${identification.label}”`);
|
|
@@ -4927,7 +5027,7 @@ function parseSegments(segmentResources, slugPrefix) {
|
|
|
4927
5027
|
*/
|
|
4928
5028
|
function parseWebSegmentItem(segmentItemResource, slugPrefix) {
|
|
4929
5029
|
const webpageProperties = segmentItemResource.properties ? parseProperties(ensureArray(segmentItemResource.properties.property)) : [];
|
|
4930
|
-
if (webpageProperties.length === 0 ||
|
|
5030
|
+
if (webpageProperties.length === 0 || getPropertyValueContentByLabel(webpageProperties, "presentation") !== "segment-item") return null;
|
|
4931
5031
|
const identification = parseIdentification(segmentItemResource.identification);
|
|
4932
5032
|
const slug = segmentItemResource.identification.abbreviation != null ? parseFakeStringOrContent(segmentItemResource.identification.abbreviation) : null;
|
|
4933
5033
|
if (slug == null) throw new Error(`Slug not found for segment item “${identification.label}”`);
|
|
@@ -4986,7 +5086,7 @@ function parseSidebar(resources) {
|
|
|
4986
5086
|
};
|
|
4987
5087
|
const sidebarResource = resources.find((resource) => {
|
|
4988
5088
|
const resourceProperties = resource.properties ? parseProperties(ensureArray(resource.properties.property)) : [];
|
|
4989
|
-
return
|
|
5089
|
+
return getPropertyValueContentByLabel(resourceProperties, "presentation") === "element" && getPropertyValueContentByLabel(resourceProperties[0]?.properties ?? [], "component") === "sidebar";
|
|
4990
5090
|
});
|
|
4991
5091
|
if (sidebarResource != null) {
|
|
4992
5092
|
title.label = parseFakeStringOrContent(sidebarResource.identification.label);
|
|
@@ -5002,17 +5102,17 @@ function parseSidebar(resources) {
|
|
|
5002
5102
|
cssStyles.mobile = parsedCssStyles.mobile;
|
|
5003
5103
|
const titleProperties = sidebarBaseProperties.find((property) => property.label === "presentation" && property.values[0].content === "title")?.properties;
|
|
5004
5104
|
if (titleProperties) {
|
|
5005
|
-
const titleVariant =
|
|
5105
|
+
const titleVariant = getPropertyValueContentByLabel(titleProperties, "variant");
|
|
5006
5106
|
if (titleVariant) title.variant = titleVariant;
|
|
5007
|
-
title.properties.isNameDisplayed =
|
|
5008
|
-
title.properties.isDescriptionDisplayed =
|
|
5009
|
-
title.properties.isDateDisplayed =
|
|
5010
|
-
title.properties.isCreatorsDisplayed =
|
|
5011
|
-
title.properties.isCountDisplayed =
|
|
5107
|
+
title.properties.isNameDisplayed = getPropertyValueContentByLabel(titleProperties, "name-displayed") === true;
|
|
5108
|
+
title.properties.isDescriptionDisplayed = getPropertyValueContentByLabel(titleProperties, "description-displayed") === true;
|
|
5109
|
+
title.properties.isDateDisplayed = getPropertyValueContentByLabel(titleProperties, "date-displayed") === true;
|
|
5110
|
+
title.properties.isCreatorsDisplayed = getPropertyValueContentByLabel(titleProperties, "creators-displayed") === true;
|
|
5111
|
+
title.properties.isCountDisplayed = getPropertyValueContentByLabel(titleProperties, "count-displayed") === true;
|
|
5012
5112
|
}
|
|
5013
5113
|
const sidebarResources = sidebarResource.resource ? ensureArray(sidebarResource.resource) : [];
|
|
5014
5114
|
for (const resource of sidebarResources) {
|
|
5015
|
-
const resourceType =
|
|
5115
|
+
const resourceType = getPropertyValueContentByLabel(resource.properties ? parseProperties(ensureArray(resource.properties.property)) : [], "presentation");
|
|
5016
5116
|
if (resourceType === null) continue;
|
|
5017
5117
|
switch (resourceType) {
|
|
5018
5118
|
case "element": {
|
|
@@ -5049,7 +5149,7 @@ function parseWebElementForAccordion(elementResource) {
|
|
|
5049
5149
|
const childResources = elementResource.resource ? ensureArray(elementResource.resource) : [];
|
|
5050
5150
|
const items = [];
|
|
5051
5151
|
for (const resource of childResources) {
|
|
5052
|
-
const resourceType =
|
|
5152
|
+
const resourceType = getPropertyValueContentByLabel(resource.properties ? parseProperties(ensureArray(resource.properties.property)) : [], "presentation");
|
|
5053
5153
|
if (resourceType === null) continue;
|
|
5054
5154
|
switch (resourceType) {
|
|
5055
5155
|
case "element": {
|
|
@@ -5098,33 +5198,33 @@ function parseWebBlock(blockResource) {
|
|
|
5098
5198
|
mobile: []
|
|
5099
5199
|
}
|
|
5100
5200
|
};
|
|
5101
|
-
const blockMainProperties =
|
|
5201
|
+
const blockMainProperties = getPropertyByLabelAndValueContent(blockProperties, "presentation", "block")?.properties ?? [];
|
|
5102
5202
|
if (blockMainProperties.length > 0) {
|
|
5103
|
-
returnBlock.properties.default.layout =
|
|
5104
|
-
returnBlock.properties.default.wrap =
|
|
5203
|
+
returnBlock.properties.default.layout = getPropertyValueContentByLabel(blockMainProperties, "layout") ?? "vertical";
|
|
5204
|
+
returnBlock.properties.default.wrap = getPropertyValueContentByLabel(blockMainProperties, "wrap") ?? "nowrap";
|
|
5105
5205
|
if (returnBlock.properties.default.layout === "accordion") {
|
|
5106
|
-
returnBlock.properties.default.isAccordionEnabled =
|
|
5107
|
-
returnBlock.properties.default.isAccordionExpandedByDefault =
|
|
5108
|
-
returnBlock.properties.default.isAccordionSidebarDisplayed =
|
|
5206
|
+
returnBlock.properties.default.isAccordionEnabled = getPropertyValueContentByLabel(blockMainProperties, "accordion-enabled") ?? true;
|
|
5207
|
+
returnBlock.properties.default.isAccordionExpandedByDefault = getPropertyValueContentByLabel(blockMainProperties, "accordion-expanded") ?? true;
|
|
5208
|
+
returnBlock.properties.default.isAccordionSidebarDisplayed = getPropertyValueContentByLabel(blockMainProperties, "accordion-sidebar-displayed") ?? false;
|
|
5109
5209
|
}
|
|
5110
|
-
returnBlock.properties.default.spacing =
|
|
5111
|
-
returnBlock.properties.default.gap =
|
|
5210
|
+
returnBlock.properties.default.spacing = getPropertyValueContentByLabel(blockMainProperties, "spacing") ?? null;
|
|
5211
|
+
returnBlock.properties.default.gap = getPropertyValueContentByLabel(blockMainProperties, "gap") ?? null;
|
|
5112
5212
|
const tabletOverwriteProperty = getPropertyByLabel(blockMainProperties, "overwrite-tablet");
|
|
5113
5213
|
if (tabletOverwriteProperty !== null) {
|
|
5114
5214
|
const tabletOverwriteProperties = tabletOverwriteProperty.properties;
|
|
5115
5215
|
const propertiesTablet = {
|
|
5116
|
-
layout:
|
|
5117
|
-
wrap:
|
|
5118
|
-
spacing:
|
|
5119
|
-
gap:
|
|
5216
|
+
layout: getPropertyValueContentByLabel(tabletOverwriteProperties, "layout") ?? void 0,
|
|
5217
|
+
wrap: getPropertyValueContentByLabel(tabletOverwriteProperties, "wrap") ?? void 0,
|
|
5218
|
+
spacing: getPropertyValueContentByLabel(tabletOverwriteProperties, "spacing") ?? void 0,
|
|
5219
|
+
gap: getPropertyValueContentByLabel(tabletOverwriteProperties, "gap") ?? void 0,
|
|
5120
5220
|
isAccordionEnabled: void 0,
|
|
5121
5221
|
isAccordionExpandedByDefault: void 0,
|
|
5122
5222
|
isAccordionSidebarDisplayed: void 0
|
|
5123
5223
|
};
|
|
5124
5224
|
if (propertiesTablet.layout === "accordion" || returnBlock.properties.default.layout === "accordion") {
|
|
5125
|
-
propertiesTablet.isAccordionEnabled =
|
|
5126
|
-
propertiesTablet.isAccordionExpandedByDefault =
|
|
5127
|
-
propertiesTablet.isAccordionSidebarDisplayed =
|
|
5225
|
+
propertiesTablet.isAccordionEnabled = getPropertyValueContentByLabel(tabletOverwriteProperties, "accordion-enabled") ?? void 0;
|
|
5226
|
+
propertiesTablet.isAccordionExpandedByDefault = getPropertyValueContentByLabel(tabletOverwriteProperties, "accordion-expanded") ?? void 0;
|
|
5227
|
+
propertiesTablet.isAccordionSidebarDisplayed = getPropertyValueContentByLabel(tabletOverwriteProperties, "accordion-sidebar-displayed") ?? void 0;
|
|
5128
5228
|
}
|
|
5129
5229
|
const cleanedPropertiesTablet = cleanObject(propertiesTablet);
|
|
5130
5230
|
if (Object.keys(cleanedPropertiesTablet).length > 0) returnBlock.properties.tablet = cleanedPropertiesTablet;
|
|
@@ -5133,18 +5233,18 @@ function parseWebBlock(blockResource) {
|
|
|
5133
5233
|
if (mobileOverwriteProperty !== null) {
|
|
5134
5234
|
const mobileOverwriteProperties = mobileOverwriteProperty.properties;
|
|
5135
5235
|
const propertiesMobile = {
|
|
5136
|
-
layout:
|
|
5137
|
-
wrap:
|
|
5138
|
-
spacing:
|
|
5139
|
-
gap:
|
|
5236
|
+
layout: getPropertyValueContentByLabel(mobileOverwriteProperties, "layout") ?? void 0,
|
|
5237
|
+
wrap: getPropertyValueContentByLabel(mobileOverwriteProperties, "wrap") ?? void 0,
|
|
5238
|
+
spacing: getPropertyValueContentByLabel(mobileOverwriteProperties, "spacing") ?? void 0,
|
|
5239
|
+
gap: getPropertyValueContentByLabel(mobileOverwriteProperties, "gap") ?? void 0,
|
|
5140
5240
|
isAccordionEnabled: void 0,
|
|
5141
5241
|
isAccordionExpandedByDefault: void 0,
|
|
5142
5242
|
isAccordionSidebarDisplayed: void 0
|
|
5143
5243
|
};
|
|
5144
5244
|
if (propertiesMobile.layout === "accordion" || returnBlock.properties.default.layout === "accordion") {
|
|
5145
|
-
propertiesMobile.isAccordionEnabled =
|
|
5146
|
-
propertiesMobile.isAccordionExpandedByDefault =
|
|
5147
|
-
propertiesMobile.isAccordionSidebarDisplayed =
|
|
5245
|
+
propertiesMobile.isAccordionEnabled = getPropertyValueContentByLabel(mobileOverwriteProperties, "accordion-enabled") ?? void 0;
|
|
5246
|
+
propertiesMobile.isAccordionExpandedByDefault = getPropertyValueContentByLabel(mobileOverwriteProperties, "accordion-expanded") ?? void 0;
|
|
5247
|
+
propertiesMobile.isAccordionSidebarDisplayed = getPropertyValueContentByLabel(mobileOverwriteProperties, "accordion-sidebar-displayed") ?? void 0;
|
|
5148
5248
|
}
|
|
5149
5249
|
const cleanedPropertiesMobile = cleanObject(propertiesMobile);
|
|
5150
5250
|
if (Object.keys(cleanedPropertiesMobile).length > 0) returnBlock.properties.mobile = cleanedPropertiesMobile;
|
|
@@ -5155,9 +5255,9 @@ function parseWebBlock(blockResource) {
|
|
|
5155
5255
|
const accordionItems = [];
|
|
5156
5256
|
for (const resource of blockResources) {
|
|
5157
5257
|
const resourceProperties = resource.properties ? parseProperties(ensureArray(resource.properties.property)) : [];
|
|
5158
|
-
const resourceType =
|
|
5258
|
+
const resourceType = getPropertyValueContentByLabel(resourceProperties, "presentation");
|
|
5159
5259
|
if (resourceType !== "element") throw new Error(`Accordion only accepts elements, but got “${resourceType}” for the following resource: “${parseStringContent(resource.identification.label)}”`);
|
|
5160
|
-
const componentType =
|
|
5260
|
+
const componentType = getPropertyValueContentByLabel(getPropertyByLabel(resourceProperties, "presentation")?.properties ?? [], "component");
|
|
5161
5261
|
if (componentType !== "text") throw new Error(`Accordion only accepts text components, but got “${componentType}” for the following resource: “${parseStringContent(resource.identification.label)}”`);
|
|
5162
5262
|
const element = parseWebElementForAccordion(resource);
|
|
5163
5263
|
accordionItems.push(element);
|
|
@@ -5166,7 +5266,7 @@ function parseWebBlock(blockResource) {
|
|
|
5166
5266
|
} else {
|
|
5167
5267
|
const blockItems = [];
|
|
5168
5268
|
for (const resource of blockResources) {
|
|
5169
|
-
const resourceType =
|
|
5269
|
+
const resourceType = getPropertyValueContentByLabel(resource.properties ? parseProperties(ensureArray(resource.properties.property)) : [], "presentation");
|
|
5170
5270
|
if (resourceType === null) continue;
|
|
5171
5271
|
switch (resourceType) {
|
|
5172
5272
|
case "element": {
|
|
@@ -5194,11 +5294,11 @@ function parseWebBlock(blockResource) {
|
|
|
5194
5294
|
*/
|
|
5195
5295
|
function parseWebsiteProperties(properties, websiteTree, sidebar) {
|
|
5196
5296
|
const websiteProperties = getPropertyByLabel(parseProperties(properties), "presentation")?.properties ?? [];
|
|
5197
|
-
let type =
|
|
5297
|
+
let type = getPropertyValueContentByLabel(websiteProperties, "webUI");
|
|
5198
5298
|
type ??= "traditional";
|
|
5199
|
-
let status =
|
|
5299
|
+
let status = getPropertyValueContentByLabel(websiteProperties, "status");
|
|
5200
5300
|
status ??= "development";
|
|
5201
|
-
let privacy =
|
|
5301
|
+
let privacy = getPropertyValueContentByLabel(websiteProperties, "privacy");
|
|
5202
5302
|
privacy ??= "public";
|
|
5203
5303
|
const returnProperties = {
|
|
5204
5304
|
type,
|
|
@@ -5256,30 +5356,30 @@ function parseWebsiteProperties(properties, websiteTree, sidebar) {
|
|
|
5256
5356
|
};
|
|
5257
5357
|
else throw new Error(`Contact property must be in the format “name;email”, but got “${contactProperty.values[0]?.content}”`);
|
|
5258
5358
|
}
|
|
5259
|
-
returnProperties.theme.isThemeToggleDisplayed =
|
|
5260
|
-
returnProperties.theme.defaultTheme =
|
|
5359
|
+
returnProperties.theme.isThemeToggleDisplayed = getPropertyValueContentByLabel(websiteProperties, "supports-theme-toggle") ?? true;
|
|
5360
|
+
returnProperties.theme.defaultTheme = getPropertyValueContentByLabel(websiteProperties, "default-theme") ?? "system";
|
|
5261
5361
|
returnProperties.icon.logoUuid = getPropertyByLabel(websiteProperties, "navbar-logo")?.values[0]?.uuid ?? null;
|
|
5262
5362
|
returnProperties.icon.faviconUuid = getPropertyByLabel(websiteProperties, "favicon-ico")?.values[0]?.uuid ?? null;
|
|
5263
5363
|
returnProperties.icon.appleTouchIconUuid = getPropertyByLabel(websiteProperties, "favicon-img")?.values[0]?.uuid ?? null;
|
|
5264
|
-
returnProperties.navbar.isDisplayed =
|
|
5265
|
-
returnProperties.navbar.variant =
|
|
5266
|
-
returnProperties.navbar.alignment =
|
|
5267
|
-
returnProperties.navbar.isProjectDisplayed =
|
|
5364
|
+
returnProperties.navbar.isDisplayed = getPropertyValueContentByLabel(websiteProperties, "navbar-displayed") ?? true;
|
|
5365
|
+
returnProperties.navbar.variant = getPropertyValueContentByLabel(websiteProperties, "navbar-variant") ?? "default";
|
|
5366
|
+
returnProperties.navbar.alignment = getPropertyValueContentByLabel(websiteProperties, "navbar-alignment") ?? "start";
|
|
5367
|
+
returnProperties.navbar.isProjectDisplayed = getPropertyValueContentByLabel(websiteProperties, "navbar-project-displayed") ?? true;
|
|
5268
5368
|
returnProperties.navbar.searchBarBoundElementUuid = getPropertyByLabel(websiteProperties, "bound-element-navbar-search-bar")?.values[0]?.uuid ?? null;
|
|
5269
|
-
returnProperties.footer.isDisplayed =
|
|
5369
|
+
returnProperties.footer.isDisplayed = getPropertyValueContentByLabel(websiteProperties, "footer-displayed") ?? true;
|
|
5270
5370
|
returnProperties.footer.logoUuid = getPropertyByLabel(websiteProperties, "footer-logo")?.values[0]?.uuid ?? null;
|
|
5271
|
-
const itemPageTypeProperty =
|
|
5371
|
+
const itemPageTypeProperty = getPropertyByLabelAndValueContent(websiteProperties, "page-type", "item-page");
|
|
5272
5372
|
if (itemPageTypeProperty !== null) {
|
|
5273
|
-
returnProperties.itemPage.isMainContentDisplayed =
|
|
5274
|
-
returnProperties.itemPage.isDescriptionDisplayed =
|
|
5275
|
-
returnProperties.itemPage.isDocumentDisplayed =
|
|
5276
|
-
returnProperties.itemPage.isNotesDisplayed =
|
|
5277
|
-
returnProperties.itemPage.isEventsDisplayed =
|
|
5278
|
-
returnProperties.itemPage.isPeriodsDisplayed =
|
|
5279
|
-
returnProperties.itemPage.isPropertiesDisplayed =
|
|
5280
|
-
returnProperties.itemPage.isBibliographyDisplayed =
|
|
5281
|
-
returnProperties.itemPage.isPropertyValuesGrouped =
|
|
5282
|
-
returnProperties.itemPage.iiifViewer =
|
|
5373
|
+
returnProperties.itemPage.isMainContentDisplayed = getPropertyValueContentByLabel(itemPageTypeProperty.properties, "item-page-main-content-displayed") ?? true;
|
|
5374
|
+
returnProperties.itemPage.isDescriptionDisplayed = getPropertyValueContentByLabel(itemPageTypeProperty.properties, "item-page-description-displayed") ?? true;
|
|
5375
|
+
returnProperties.itemPage.isDocumentDisplayed = getPropertyValueContentByLabel(itemPageTypeProperty.properties, "item-page-document-displayed") ?? true;
|
|
5376
|
+
returnProperties.itemPage.isNotesDisplayed = getPropertyValueContentByLabel(itemPageTypeProperty.properties, "item-page-notes-displayed") ?? true;
|
|
5377
|
+
returnProperties.itemPage.isEventsDisplayed = getPropertyValueContentByLabel(itemPageTypeProperty.properties, "item-page-events-displayed") ?? true;
|
|
5378
|
+
returnProperties.itemPage.isPeriodsDisplayed = getPropertyValueContentByLabel(itemPageTypeProperty.properties, "item-page-periods-displayed") ?? true;
|
|
5379
|
+
returnProperties.itemPage.isPropertiesDisplayed = getPropertyValueContentByLabel(itemPageTypeProperty.properties, "item-page-properties-displayed") ?? true;
|
|
5380
|
+
returnProperties.itemPage.isBibliographyDisplayed = getPropertyValueContentByLabel(itemPageTypeProperty.properties, "item-page-bibliography-displayed") ?? true;
|
|
5381
|
+
returnProperties.itemPage.isPropertyValuesGrouped = getPropertyValueContentByLabel(itemPageTypeProperty.properties, "item-page-property-values-grouped") ?? true;
|
|
5382
|
+
returnProperties.itemPage.iiifViewer = getPropertyValueContentByLabel(itemPageTypeProperty.properties, "item-page-iiif-viewer") ?? "universal-viewer";
|
|
5283
5383
|
}
|
|
5284
5384
|
if ("options" in websiteTree && websiteTree.options) {
|
|
5285
5385
|
returnProperties.options.scopes = websiteTree.options.scopes != null ? ensureArray(websiteTree.options.scopes.scope).map((scope) => ({
|
|
@@ -5420,4 +5520,4 @@ async function fetchWebsite(abbreviation, options) {
|
|
|
5420
5520
|
}
|
|
5421
5521
|
}
|
|
5422
5522
|
//#endregion
|
|
5423
|
-
export { DEFAULT_API_VERSION, DEFAULT_PAGE_SIZE, fetchGallery, fetchItem, fetchSetItems, fetchSetPropertyValues, fetchWebsite, filterProperties, flattenItemProperties, getLeafPropertyValues, getPropertyByLabel, getPropertyByLabelAndValue, getPropertyByLabelAndValues, getPropertyByUuid, getPropertyValueByLabel, getPropertyValueByUuid, getPropertyValuesByLabel, getPropertyValuesByUuid, getUniqueProperties, getUniquePropertyLabels };
|
|
5523
|
+
export { DEFAULT_API_VERSION, DEFAULT_PAGE_SIZE, fetchGallery, fetchItem, fetchSetItems, fetchSetPropertyValues, fetchWebsite, filterProperties, flattenItemProperties, getLeafPropertyValues, getPropertyByLabel, getPropertyByLabelAndValue, getPropertyByLabelAndValueContent, getPropertyByLabelAndValueContents, getPropertyByLabelAndValues, getPropertyByUuid, getPropertyValueByLabel, getPropertyValueByUuid, getPropertyValueContentByLabel, getPropertyValueContentByUuid, getPropertyValueContentsByUuid, getPropertyValuesByLabel, getPropertyValuesByUuid, getUniqueProperties, getUniquePropertyLabels };
|