@digitalculture/ochre-sdk 0.17.11 → 0.17.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 +11 -2
- package/dist/index.mjs +17 -6
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -494,7 +494,10 @@ type PropertyValueContentType = "string" | "integer" | "decimal" | "boolean" | "
|
|
|
494
494
|
* Represents a property value with type information
|
|
495
495
|
*/
|
|
496
496
|
type PropertyValueContent<T extends PropertyValueContentType> = {
|
|
497
|
-
|
|
497
|
+
hierarchy: {
|
|
498
|
+
isLeaf: boolean;
|
|
499
|
+
level: number | null;
|
|
500
|
+
};
|
|
498
501
|
content: (T extends "integer" ? number : T extends "decimal" ? number : T extends "time" ? number : T extends "boolean" ? boolean : string) | null;
|
|
499
502
|
dataType: T;
|
|
500
503
|
label: string | null;
|
|
@@ -1396,5 +1399,11 @@ declare const DEFAULT_API_VERSION = 2;
|
|
|
1396
1399
|
* @returns The item with the properties flattened
|
|
1397
1400
|
*/
|
|
1398
1401
|
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>;
|
|
1402
|
+
/**
|
|
1403
|
+
* Get the leaf property values from an array of property values
|
|
1404
|
+
* @param propertyValues - The array of property values to get the leaf property values from
|
|
1405
|
+
* @returns The array of leaf property values
|
|
1406
|
+
*/
|
|
1407
|
+
declare function getLeafPropertyValues<T extends PropertyValueContentType = PropertyValueContentType>(propertyValues: Array<PropertyValueContent<T>>): Array<PropertyValueContent<T>>;
|
|
1399
1408
|
//#endregion
|
|
1400
|
-
export { ApiVersion, Bibliography, Concept, Context, ContextItem, ContextNode, Coordinate, DEFAULT_API_VERSION, Data, DataCategory, Event, FileFormat, Gallery, Identification, Image, ImageMap, ImageMapArea, Interpretation, Item, LevelContext, LevelContextItem, License, Link, Metadata, Note, Observation, Period, Person, Property, PropertyContexts, PropertyQueryItem, PropertyValue, PropertyValueContent, PropertyValueContentType, Resource, Scope, Section, Set, SpatialUnit, Style, Text, Tree, UuidMetadata, WebBlock, WebBlockLayout, WebElement, WebElementComponent, WebImage, WebTitle, Webpage, Website, fetchByUuidMetadata, fetchGallery, fetchItem, fetchItemsByPropertyValues, fetchPropertyValuesByPropertyVariables, fetchWebsite, filterProperties, flattenItemProperties, getPropertyByLabel, getPropertyByUuid, getPropertyValueByLabel, getPropertyValueByUuid, getPropertyValuesByLabel, getPropertyValuesByUuid, getUniqueProperties, getUniquePropertyLabels };
|
|
1409
|
+
export { ApiVersion, Bibliography, Concept, Context, ContextItem, ContextNode, Coordinate, DEFAULT_API_VERSION, Data, DataCategory, Event, FileFormat, Gallery, Identification, Image, ImageMap, ImageMapArea, Interpretation, Item, LevelContext, LevelContextItem, License, Link, Metadata, Note, Observation, Period, Person, Property, PropertyContexts, PropertyQueryItem, PropertyValue, PropertyValueContent, PropertyValueContentType, Resource, Scope, Section, Set, SpatialUnit, Style, Text, Tree, UuidMetadata, WebBlock, WebBlockLayout, WebElement, WebElementComponent, WebImage, WebTitle, Webpage, Website, fetchByUuidMetadata, fetchGallery, fetchItem, fetchItemsByPropertyValues, fetchPropertyValuesByPropertyVariables, fetchWebsite, filterProperties, flattenItemProperties, getLeafPropertyValues, getPropertyByLabel, getPropertyByUuid, getPropertyValueByLabel, getPropertyValueByUuid, getPropertyValuesByLabel, getPropertyValuesByUuid, getUniqueProperties, getUniquePropertyLabels };
|
package/dist/index.mjs
CHANGED
|
@@ -1011,6 +1011,14 @@ function flattenItemProperties(item) {
|
|
|
1011
1011
|
properties: collectPropertiesFromSubNodes()
|
|
1012
1012
|
};
|
|
1013
1013
|
}
|
|
1014
|
+
/**
|
|
1015
|
+
* Get the leaf property values from an array of property values
|
|
1016
|
+
* @param propertyValues - The array of property values to get the leaf property values from
|
|
1017
|
+
* @returns The array of leaf property values
|
|
1018
|
+
*/
|
|
1019
|
+
function getLeafPropertyValues(propertyValues) {
|
|
1020
|
+
return propertyValues.filter((value) => value.hierarchy.isLeaf);
|
|
1021
|
+
}
|
|
1014
1022
|
|
|
1015
1023
|
//#endregion
|
|
1016
1024
|
//#region src/utils/parse.ts
|
|
@@ -1446,7 +1454,10 @@ function parseProperty(property, language = "eng") {
|
|
|
1446
1454
|
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
|
|
1447
1455
|
content = parseFakeString(value);
|
|
1448
1456
|
return {
|
|
1449
|
-
|
|
1457
|
+
hierarchy: {
|
|
1458
|
+
isLeaf: true,
|
|
1459
|
+
level: null
|
|
1460
|
+
},
|
|
1450
1461
|
content,
|
|
1451
1462
|
label: null,
|
|
1452
1463
|
dataType: "string",
|
|
@@ -1502,7 +1513,10 @@ function parseProperty(property, language = "eng") {
|
|
|
1502
1513
|
break;
|
|
1503
1514
|
}
|
|
1504
1515
|
return {
|
|
1505
|
-
|
|
1516
|
+
hierarchy: {
|
|
1517
|
+
isLeaf: value.inherited == null || !value.inherited,
|
|
1518
|
+
level: value.i ?? null
|
|
1519
|
+
},
|
|
1506
1520
|
content,
|
|
1507
1521
|
dataType: parsedType,
|
|
1508
1522
|
isUncertain: value.isUncertain ?? false,
|
|
@@ -1519,9 +1533,6 @@ function parseProperty(property, language = "eng") {
|
|
|
1519
1533
|
slug: value.slug ?? null
|
|
1520
1534
|
};
|
|
1521
1535
|
}
|
|
1522
|
-
}).toSorted((a, b) => {
|
|
1523
|
-
if (a.hierarchyLevel != null && b.hierarchyLevel != null) return b.hierarchyLevel - a.hierarchyLevel;
|
|
1524
|
-
return 0;
|
|
1525
1536
|
});
|
|
1526
1537
|
return {
|
|
1527
1538
|
uuid: property.label.uuid,
|
|
@@ -3888,4 +3899,4 @@ async function fetchWebsite(abbreviation, options) {
|
|
|
3888
3899
|
}
|
|
3889
3900
|
|
|
3890
3901
|
//#endregion
|
|
3891
|
-
export { DEFAULT_API_VERSION, fetchByUuidMetadata, fetchGallery, fetchItem, fetchItemsByPropertyValues, fetchPropertyValuesByPropertyVariables, fetchWebsite, filterProperties, flattenItemProperties, getPropertyByLabel, getPropertyByUuid, getPropertyValueByLabel, getPropertyValueByUuid, getPropertyValuesByLabel, getPropertyValuesByUuid, getUniqueProperties, getUniquePropertyLabels };
|
|
3902
|
+
export { DEFAULT_API_VERSION, fetchByUuidMetadata, fetchGallery, fetchItem, fetchItemsByPropertyValues, fetchPropertyValuesByPropertyVariables, fetchWebsite, filterProperties, flattenItemProperties, getLeafPropertyValues, getPropertyByLabel, getPropertyByUuid, getPropertyValueByLabel, getPropertyValueByUuid, getPropertyValuesByLabel, getPropertyValuesByUuid, getUniqueProperties, getUniquePropertyLabels };
|
package/package.json
CHANGED