ochre-sdk 0.20.24 → 0.20.25
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 +4 -4
- package/dist/index.mjs +10 -10
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1268,9 +1268,9 @@ declare function fetchSetItems<U extends Array<DataCategory> = Array<DataCategor
|
|
|
1268
1268
|
error: string;
|
|
1269
1269
|
}>;
|
|
1270
1270
|
//#endregion
|
|
1271
|
-
//#region src/utils/fetchers/set/property-values
|
|
1271
|
+
//#region src/utils/fetchers/set/property-values.d.ts
|
|
1272
1272
|
/**
|
|
1273
|
-
* Fetches and parses Set property values
|
|
1273
|
+
* Fetches and parses Set property values from the OCHRE API
|
|
1274
1274
|
*
|
|
1275
1275
|
* @param params - The parameters for the fetch
|
|
1276
1276
|
* @param params.setScopeUuids - An array of set scope UUIDs to filter by
|
|
@@ -1285,7 +1285,7 @@ declare function fetchSetItems<U extends Array<DataCategory> = Array<DataCategor
|
|
|
1285
1285
|
* @returns Parsed Set property values and requested attribute values.
|
|
1286
1286
|
* Returns empty arrays/objects when no matches are found, and null outputs on fetch/parse errors.
|
|
1287
1287
|
*/
|
|
1288
|
-
declare function
|
|
1288
|
+
declare function fetchSetPropertyValues(params: {
|
|
1289
1289
|
setScopeUuids: Array<string>;
|
|
1290
1290
|
queries?: Array<Query>;
|
|
1291
1291
|
attributes?: {
|
|
@@ -1470,4 +1470,4 @@ declare const DEFAULT_PAGE_SIZE = 48;
|
|
|
1470
1470
|
*/
|
|
1471
1471
|
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>;
|
|
1472
1472
|
//#endregion
|
|
1473
|
-
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, LevelContext, LevelContextItem, License, Link, Metadata, Note, Observation, Period, Person, Property, PropertyContexts, PropertyValue, PropertyValueContent, PropertyValueContentType, PropertyValueQueryItem, PropertyVariable, Query, Resource, Scope, Section, Set, SetAttributeValueQueryItem, SetItemsSort, SetItemsSortDirection, SpatialUnit, Style, Text, Tree, WebBlock, WebBlockLayout, WebElement, WebElementComponent, WebImage, WebSegment, WebSegmentItem, WebTitle, Webpage, Website, WebsiteType, fetchGallery, fetchItem, fetchSetItems,
|
|
1473
|
+
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, LevelContext, LevelContextItem, License, Link, Metadata, Note, Observation, Period, Person, Property, PropertyContexts, PropertyValue, PropertyValueContent, PropertyValueContentType, PropertyValueQueryItem, PropertyVariable, Query, Resource, Scope, Section, Set, SetAttributeValueQueryItem, SetItemsSort, SetItemsSortDirection, SpatialUnit, Style, Text, Tree, WebBlock, WebBlockLayout, WebElement, WebElementComponent, WebImage, WebSegment, WebSegmentItem, WebTitle, Webpage, Website, WebsiteType, fetchGallery, fetchItem, fetchSetItems, fetchSetPropertyValues, fetchWebsite, filterProperties, flattenItemProperties, getLeafPropertyValues, getPropertyByLabel, getPropertyByLabelAndValue, getPropertyByLabelAndValues, getPropertyByUuid, getPropertyValueByLabel, getPropertyValueByUuid, getPropertyValuesByLabel, getPropertyValuesByUuid, getUniqueProperties, getUniquePropertyLabels };
|
package/dist/index.mjs
CHANGED
|
@@ -861,10 +861,10 @@ function validateSetQueriesOperators(queries, ctx) {
|
|
|
861
861
|
});
|
|
862
862
|
}
|
|
863
863
|
/**
|
|
864
|
-
* Schema for validating the parameters for the Set property values
|
|
864
|
+
* Schema for validating the parameters for the Set property values fetching function
|
|
865
865
|
* @internal
|
|
866
866
|
*/
|
|
867
|
-
const
|
|
867
|
+
const setPropertyValuesParamsSchema = z.object({
|
|
868
868
|
setScopeUuids: z.array(uuidSchema).min(1, "At least one set scope UUID is required"),
|
|
869
869
|
belongsToCollectionScopeUuids: z.array(uuidSchema).default([]),
|
|
870
870
|
queries: setQueriesSchema,
|
|
@@ -2807,7 +2807,7 @@ async function fetchSetItems(params, itemCategories, options) {
|
|
|
2807
2807
|
}
|
|
2808
2808
|
}
|
|
2809
2809
|
//#endregion
|
|
2810
|
-
//#region src/utils/fetchers/set/property-values
|
|
2810
|
+
//#region src/utils/fetchers/set/property-values.ts
|
|
2811
2811
|
function parsePropertyValueLabel(content) {
|
|
2812
2812
|
if (content == null || content === "") return null;
|
|
2813
2813
|
if (typeof content === "object") return parseStringContent({ content });
|
|
@@ -2944,14 +2944,14 @@ const attributeValueQueryItemSchema = z.object({
|
|
|
2944
2944
|
content: val.content != null && val.content !== "" ? val.content : null
|
|
2945
2945
|
}));
|
|
2946
2946
|
/**
|
|
2947
|
-
* Schema for the property values
|
|
2947
|
+
* Schema for the property values OCHRE API response
|
|
2948
2948
|
*/
|
|
2949
2949
|
const responseSchema = z.object({ result: z.union([z.object({ ochre: z.object({
|
|
2950
2950
|
propertyValue: z.union([propertyValueQueryItemSchema, z.array(propertyValueQueryItemSchema)]).optional(),
|
|
2951
2951
|
attributeValue: z.union([attributeValueQueryItemSchema, z.array(attributeValueQueryItemSchema)]).optional()
|
|
2952
2952
|
}) }), z.array(z.unknown()).length(0)]) });
|
|
2953
2953
|
/**
|
|
2954
|
-
* Build an XQuery string to fetch property values
|
|
2954
|
+
* Build an XQuery string to fetch property values from the OCHRE API
|
|
2955
2955
|
* @param params - The parameters for the fetch
|
|
2956
2956
|
* @param params.setScopeUuids - An array of set scope UUIDs to filter by
|
|
2957
2957
|
* @param params.belongsToCollectionScopeUuids - An array of collection scope UUIDs to filter by
|
|
@@ -3020,7 +3020,7 @@ ${queryBlocks.join("\n\n")}
|
|
|
3020
3020
|
return (${returnedSequences.join(", ")})`}}</ochre>`;
|
|
3021
3021
|
}
|
|
3022
3022
|
/**
|
|
3023
|
-
* Fetches and parses Set property values
|
|
3023
|
+
* Fetches and parses Set property values from the OCHRE API
|
|
3024
3024
|
*
|
|
3025
3025
|
* @param params - The parameters for the fetch
|
|
3026
3026
|
* @param params.setScopeUuids - An array of set scope UUIDs to filter by
|
|
@@ -3035,10 +3035,10 @@ return (${returnedSequences.join(", ")})`}}</ochre>`;
|
|
|
3035
3035
|
* @returns Parsed Set property values and requested attribute values.
|
|
3036
3036
|
* Returns empty arrays/objects when no matches are found, and null outputs on fetch/parse errors.
|
|
3037
3037
|
*/
|
|
3038
|
-
async function
|
|
3038
|
+
async function fetchSetPropertyValues(params, options) {
|
|
3039
3039
|
try {
|
|
3040
3040
|
const version = options?.version ?? 2;
|
|
3041
|
-
const { setScopeUuids, belongsToCollectionScopeUuids, queries, attributes, isLimitedToLeafPropertyValues } =
|
|
3041
|
+
const { setScopeUuids, belongsToCollectionScopeUuids, queries, attributes, isLimitedToLeafPropertyValues } = setPropertyValuesParamsSchema.parse(params);
|
|
3042
3042
|
const xquery = buildXQuery({
|
|
3043
3043
|
setScopeUuids,
|
|
3044
3044
|
belongsToCollectionScopeUuids,
|
|
@@ -3100,7 +3100,7 @@ async function fetchSetPropertyValuesByPropertyVariables(params, options) {
|
|
|
3100
3100
|
propertyValues: null,
|
|
3101
3101
|
propertyValuesByPropertyVariableUuid: null,
|
|
3102
3102
|
attributeValues: null,
|
|
3103
|
-
error: error instanceof Error ? error.message : "Failed to fetch property values
|
|
3103
|
+
error: error instanceof Error ? error.message : "Failed to fetch property values"
|
|
3104
3104
|
};
|
|
3105
3105
|
}
|
|
3106
3106
|
}
|
|
@@ -4700,4 +4700,4 @@ async function fetchWebsite(abbreviation, options) {
|
|
|
4700
4700
|
}
|
|
4701
4701
|
}
|
|
4702
4702
|
//#endregion
|
|
4703
|
-
export { DEFAULT_API_VERSION, DEFAULT_PAGE_SIZE, fetchGallery, fetchItem, fetchSetItems,
|
|
4703
|
+
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 };
|