ochre-sdk 0.20.7 → 0.20.10
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 +3 -9
- package/dist/index.mjs +115 -138
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -951,7 +951,7 @@ type WebElementComponent = {
|
|
|
951
951
|
isResultsBarDisplayed: boolean;
|
|
952
952
|
isMapDisplayed: boolean;
|
|
953
953
|
isInputDisplayed: boolean;
|
|
954
|
-
|
|
954
|
+
isLimitedToInputFilter: boolean;
|
|
955
955
|
isLimitedToLeafPropertyValues: boolean;
|
|
956
956
|
sidebarSort: "default" | "alphabetical";
|
|
957
957
|
};
|
|
@@ -1231,12 +1231,6 @@ declare function fetchSetItems<U extends Array<DataCategory> = Array<DataCategor
|
|
|
1231
1231
|
}>;
|
|
1232
1232
|
//#endregion
|
|
1233
1233
|
//#region src/utils/fetchers/set/property-values-by-property-variables.d.ts
|
|
1234
|
-
type SetPropertyValuesByPropertyVariablesTitleQueryInput = {
|
|
1235
|
-
value: string;
|
|
1236
|
-
matchMode: "includes" | "exact";
|
|
1237
|
-
isCaseSensitive: boolean;
|
|
1238
|
-
language?: string;
|
|
1239
|
-
};
|
|
1240
1234
|
/**
|
|
1241
1235
|
* Fetches and parses Set property values by property variables from the OCHRE API
|
|
1242
1236
|
*
|
|
@@ -1244,7 +1238,7 @@ type SetPropertyValuesByPropertyVariablesTitleQueryInput = {
|
|
|
1244
1238
|
* @param params.setScopeUuids - An array of set scope UUIDs to filter by
|
|
1245
1239
|
* @param params.belongsToCollectionScopeUuids - The collection scope UUIDs to filter by
|
|
1246
1240
|
* @param params.propertyVariableUuids - The property variable UUIDs to query by
|
|
1247
|
-
* @param params.
|
|
1241
|
+
* @param params.queries - Ordered queries to combine with AND/OR and optional NOT via negation
|
|
1248
1242
|
* @param params.isLimitedToLeafPropertyValues - Whether to limit the property values to leaf property values
|
|
1249
1243
|
* @param options - Options for the fetch
|
|
1250
1244
|
* @param options.fetch - The fetch function to use
|
|
@@ -1255,7 +1249,7 @@ declare function fetchSetPropertyValuesByPropertyVariables(params: {
|
|
|
1255
1249
|
setScopeUuids: Array<string>;
|
|
1256
1250
|
belongsToCollectionScopeUuids: Array<string>;
|
|
1257
1251
|
propertyVariableUuids: Array<string>;
|
|
1258
|
-
|
|
1252
|
+
queries?: Array<Query>;
|
|
1259
1253
|
isLimitedToLeafPropertyValues?: boolean;
|
|
1260
1254
|
}, options?: {
|
|
1261
1255
|
fetch?: (input: string | URL | globalThis.Request, init?: RequestInit) => Promise<Response>;
|
package/dist/index.mjs
CHANGED
|
@@ -760,87 +760,70 @@ const boundsSchema = z.string().transform((str, ctx) => {
|
|
|
760
760
|
}
|
|
761
761
|
}).pipe(z.tuple([z.tuple([z.number(), z.number()]), z.tuple([z.number(), z.number()])], { message: "Must contain exactly 2 coordinate pairs" }));
|
|
762
762
|
/**
|
|
763
|
-
*
|
|
763
|
+
* Shared schema for Set queries
|
|
764
764
|
* @internal
|
|
765
765
|
*/
|
|
766
|
-
const
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
766
|
+
const setQuerySchema = z.union([
|
|
767
|
+
z.object({
|
|
768
|
+
target: z.literal("propertyValue"),
|
|
769
|
+
dataType: z.enum([
|
|
770
|
+
"string",
|
|
771
|
+
"integer",
|
|
772
|
+
"decimal",
|
|
773
|
+
"boolean",
|
|
774
|
+
"time",
|
|
775
|
+
"IDREF"
|
|
776
|
+
]),
|
|
771
777
|
value: z.string(),
|
|
772
778
|
matchMode: z.enum(["includes", "exact"]),
|
|
773
779
|
isCaseSensitive: z.boolean(),
|
|
774
|
-
language: z.string().default("eng")
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
})
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
z.
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
z.
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
z.
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
operator: z.enum(["AND", "OR"]).optional(),
|
|
822
|
-
isNegated: z.boolean().optional().default(false)
|
|
823
|
-
}).strict(),
|
|
824
|
-
z.object({
|
|
825
|
-
target: z.enum([
|
|
826
|
-
"title",
|
|
827
|
-
"description",
|
|
828
|
-
"image",
|
|
829
|
-
"periods",
|
|
830
|
-
"bibliography"
|
|
831
|
-
]),
|
|
832
|
-
value: z.string(),
|
|
833
|
-
matchMode: z.enum(["includes", "exact"]),
|
|
834
|
-
isCaseSensitive: z.boolean(),
|
|
835
|
-
language: z.string().default("eng"),
|
|
836
|
-
operator: z.enum(["AND", "OR"]).optional(),
|
|
837
|
-
isNegated: z.boolean().optional().default(false)
|
|
838
|
-
}).strict()
|
|
839
|
-
])).default([]),
|
|
840
|
-
page: z.number().min(1, "Page must be positive").default(1),
|
|
841
|
-
pageSize: z.number().min(1, "Page size must be positive").default(DEFAULT_PAGE_SIZE)
|
|
842
|
-
}).superRefine((value, ctx) => {
|
|
843
|
-
for (const [index, query] of value.queries.entries()) {
|
|
780
|
+
language: z.string().default("eng"),
|
|
781
|
+
operator: z.enum(["AND", "OR"]).optional(),
|
|
782
|
+
isNegated: z.boolean().optional().default(false)
|
|
783
|
+
}).strict(),
|
|
784
|
+
z.object({
|
|
785
|
+
target: z.literal("propertyValue"),
|
|
786
|
+
dataType: z.enum(["date", "dateTime"]),
|
|
787
|
+
value: z.string(),
|
|
788
|
+
from: z.string(),
|
|
789
|
+
to: z.string().optional(),
|
|
790
|
+
matchMode: z.enum(["includes", "exact"]),
|
|
791
|
+
isCaseSensitive: z.boolean(),
|
|
792
|
+
language: z.string().default("eng"),
|
|
793
|
+
operator: z.enum(["AND", "OR"]).optional(),
|
|
794
|
+
isNegated: z.boolean().optional().default(false)
|
|
795
|
+
}).strict(),
|
|
796
|
+
z.object({
|
|
797
|
+
target: z.literal("propertyValue"),
|
|
798
|
+
dataType: z.enum(["date", "dateTime"]),
|
|
799
|
+
value: z.string(),
|
|
800
|
+
from: z.string().optional(),
|
|
801
|
+
to: z.string(),
|
|
802
|
+
matchMode: z.enum(["includes", "exact"]),
|
|
803
|
+
isCaseSensitive: z.boolean(),
|
|
804
|
+
language: z.string().default("eng"),
|
|
805
|
+
operator: z.enum(["AND", "OR"]).optional(),
|
|
806
|
+
isNegated: z.boolean().optional().default(false)
|
|
807
|
+
}).strict(),
|
|
808
|
+
z.object({
|
|
809
|
+
target: z.enum([
|
|
810
|
+
"title",
|
|
811
|
+
"description",
|
|
812
|
+
"image",
|
|
813
|
+
"periods",
|
|
814
|
+
"bibliography"
|
|
815
|
+
]),
|
|
816
|
+
value: z.string(),
|
|
817
|
+
matchMode: z.enum(["includes", "exact"]),
|
|
818
|
+
isCaseSensitive: z.boolean(),
|
|
819
|
+
language: z.string().default("eng"),
|
|
820
|
+
operator: z.enum(["AND", "OR"]).optional(),
|
|
821
|
+
isNegated: z.boolean().optional().default(false)
|
|
822
|
+
}).strict()
|
|
823
|
+
]);
|
|
824
|
+
const setQueriesSchema = z.array(setQuerySchema).default([]);
|
|
825
|
+
function validateSetQueriesOperators(queries, ctx) {
|
|
826
|
+
for (const [index, query] of queries.entries()) {
|
|
844
827
|
if (index === 0 && query.operator != null) ctx.addIssue({
|
|
845
828
|
code: "custom",
|
|
846
829
|
path: [
|
|
@@ -860,6 +843,29 @@ const setItemsParamsSchema = z.object({
|
|
|
860
843
|
message: "Query rules after the first must include an operator"
|
|
861
844
|
});
|
|
862
845
|
}
|
|
846
|
+
}
|
|
847
|
+
/**
|
|
848
|
+
* Schema for validating the parameters for the Set property values by property variables fetching function
|
|
849
|
+
* @internal
|
|
850
|
+
*/
|
|
851
|
+
const setPropertyValuesByPropertyVariablesParamsSchema = z.object({
|
|
852
|
+
setScopeUuids: z.array(uuidSchema).min(1, "At least one set scope UUID is required"),
|
|
853
|
+
belongsToCollectionScopeUuids: z.array(uuidSchema).default([]),
|
|
854
|
+
propertyVariableUuids: z.array(uuidSchema).min(1, "At least one property variable UUID is required"),
|
|
855
|
+
queries: setQueriesSchema,
|
|
856
|
+
isLimitedToLeafPropertyValues: z.boolean().default(false)
|
|
857
|
+
}).superRefine((value, ctx) => {
|
|
858
|
+
validateSetQueriesOperators(value.queries, ctx);
|
|
859
|
+
});
|
|
860
|
+
const setItemsParamsSchema = z.object({
|
|
861
|
+
setScopeUuids: z.array(uuidSchema).min(1, "At least one set scope UUID is required"),
|
|
862
|
+
belongsToCollectionScopeUuids: z.array(uuidSchema).default([]),
|
|
863
|
+
propertyVariableUuids: z.array(uuidSchema).default([]),
|
|
864
|
+
queries: setQueriesSchema,
|
|
865
|
+
page: z.number().min(1, "Page must be positive").default(1),
|
|
866
|
+
pageSize: z.number().min(1, "Page size must be positive").default(DEFAULT_PAGE_SIZE)
|
|
867
|
+
}).superRefine((value, ctx) => {
|
|
868
|
+
validateSetQueriesOperators(value.queries, ctx);
|
|
863
869
|
});
|
|
864
870
|
|
|
865
871
|
//#endregion
|
|
@@ -2105,17 +2111,11 @@ async function fetchItem(uuid, category, itemCategories, options) {
|
|
|
2105
2111
|
}
|
|
2106
2112
|
|
|
2107
2113
|
//#endregion
|
|
2108
|
-
//#region src/utils/fetchers/set/
|
|
2114
|
+
//#region src/utils/fetchers/set/query-helpers.ts
|
|
2109
2115
|
/**
|
|
2110
2116
|
* Build a string match predicate for an XQuery string
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
* @param params.value - The value to match
|
|
2114
|
-
* @param params.matchMode - The match mode (includes or exact)
|
|
2115
|
-
* @param params.isCaseSensitive - Whether to match case-sensitively
|
|
2116
|
-
* @returns The string match predicate
|
|
2117
|
-
*/
|
|
2118
|
-
function buildStringMatchPredicate$1(params) {
|
|
2117
|
+
*/
|
|
2118
|
+
function buildStringMatchPredicate(params) {
|
|
2119
2119
|
const { path, value, matchMode, isCaseSensitive } = params;
|
|
2120
2120
|
const comparedPath = isCaseSensitive ? path : `lower-case(${path})`;
|
|
2121
2121
|
const comparedValueLiteral = stringLiteral(isCaseSensitive ? value : value.toLowerCase());
|
|
@@ -2134,8 +2134,6 @@ function buildDateRangePredicate(params) {
|
|
|
2134
2134
|
}
|
|
2135
2135
|
/**
|
|
2136
2136
|
* Build a property value predicate for an XQuery string
|
|
2137
|
-
* @param query - The propertyValue query
|
|
2138
|
-
* @returns The property value predicate
|
|
2139
2137
|
*/
|
|
2140
2138
|
function buildPropertyValuePredicate(query) {
|
|
2141
2139
|
if (query.dataType === "IDREF") return `.//properties//property[value[@uuid=${stringLiteral(query.value)}]]`;
|
|
@@ -2144,7 +2142,7 @@ function buildPropertyValuePredicate(query) {
|
|
|
2144
2142
|
to: query.to
|
|
2145
2143
|
})}]`;
|
|
2146
2144
|
if (query.dataType === "time" || query.dataType === "integer" || query.dataType === "decimal" || query.dataType === "boolean") return `.//properties//property[value[@rawValue=${stringLiteral(query.value)}]]`;
|
|
2147
|
-
return `.//properties//property[${buildStringMatchPredicate
|
|
2145
|
+
return `.//properties//property[${buildStringMatchPredicate({
|
|
2148
2146
|
path: `string-join(value/content[@xml:lang="${query.language}"]/string, "")`,
|
|
2149
2147
|
value: query.value,
|
|
2150
2148
|
matchMode: query.matchMode,
|
|
@@ -2153,36 +2151,34 @@ function buildPropertyValuePredicate(query) {
|
|
|
2153
2151
|
}
|
|
2154
2152
|
/**
|
|
2155
2153
|
* Build a query predicate for an XQuery string
|
|
2156
|
-
* @param query - The query to build the predicate for
|
|
2157
|
-
* @returns The query predicate
|
|
2158
2154
|
*/
|
|
2159
2155
|
function buildQueryPredicate(query) {
|
|
2160
2156
|
switch (query.target) {
|
|
2161
|
-
case "title": return buildStringMatchPredicate
|
|
2157
|
+
case "title": return buildStringMatchPredicate({
|
|
2162
2158
|
path: `string-join(identification/label/content[@xml:lang="${query.language}"]/string, "")`,
|
|
2163
2159
|
value: query.value,
|
|
2164
2160
|
matchMode: query.matchMode,
|
|
2165
2161
|
isCaseSensitive: query.isCaseSensitive
|
|
2166
2162
|
});
|
|
2167
|
-
case "description": return buildStringMatchPredicate
|
|
2163
|
+
case "description": return buildStringMatchPredicate({
|
|
2168
2164
|
path: `string-join(description/content[@xml:lang="${query.language}"]/string, "")`,
|
|
2169
2165
|
value: query.value,
|
|
2170
2166
|
matchMode: query.matchMode,
|
|
2171
2167
|
isCaseSensitive: query.isCaseSensitive
|
|
2172
2168
|
});
|
|
2173
|
-
case "periods": return buildStringMatchPredicate
|
|
2169
|
+
case "periods": return buildStringMatchPredicate({
|
|
2174
2170
|
path: `string-join(periods/period/identification/label/content[@xml:lang="${query.language}"]/string, "")`,
|
|
2175
2171
|
value: query.value,
|
|
2176
2172
|
matchMode: query.matchMode,
|
|
2177
2173
|
isCaseSensitive: query.isCaseSensitive
|
|
2178
2174
|
});
|
|
2179
|
-
case "bibliography": return buildStringMatchPredicate
|
|
2175
|
+
case "bibliography": return buildStringMatchPredicate({
|
|
2180
2176
|
path: `string-join(bibliographies/bibliography/identification/label/content[@xml:lang="${query.language}"]/string, "")`,
|
|
2181
2177
|
value: query.value,
|
|
2182
2178
|
matchMode: query.matchMode,
|
|
2183
2179
|
isCaseSensitive: query.isCaseSensitive
|
|
2184
2180
|
});
|
|
2185
|
-
case "image": return buildStringMatchPredicate
|
|
2181
|
+
case "image": return buildStringMatchPredicate({
|
|
2186
2182
|
path: `string-join(image/identification/label/content[@xml:lang="${query.language}"]/string, "")`,
|
|
2187
2183
|
value: query.value,
|
|
2188
2184
|
matchMode: query.matchMode,
|
|
@@ -2199,6 +2195,19 @@ function buildBooleanQueryClause(query) {
|
|
|
2199
2195
|
return query.isNegated ? `not(${baseClause})` : baseClause;
|
|
2200
2196
|
}
|
|
2201
2197
|
/**
|
|
2198
|
+
* Build query filters for an XQuery string.
|
|
2199
|
+
*/
|
|
2200
|
+
function buildQueryFilters(queries) {
|
|
2201
|
+
return queries.map((query, index) => {
|
|
2202
|
+
const clause = buildBooleanQueryClause(query);
|
|
2203
|
+
if (index === 0) return clause;
|
|
2204
|
+
return `${query.operator === "OR" ? "or" : "and"} ${clause}`;
|
|
2205
|
+
}).join(" ");
|
|
2206
|
+
}
|
|
2207
|
+
|
|
2208
|
+
//#endregion
|
|
2209
|
+
//#region src/utils/fetchers/set/items.ts
|
|
2210
|
+
/**
|
|
2202
2211
|
* Build an XQuery string to fetch Set items from the OCHRE API
|
|
2203
2212
|
* @param params - The parameters for the fetch
|
|
2204
2213
|
* @param params.setScopeUuids - An array of Set scope UUIDs to filter by
|
|
@@ -2217,11 +2226,7 @@ function buildXQuery$1(params, options) {
|
|
|
2217
2226
|
const startPosition = (page - 1) * pageSize + 1;
|
|
2218
2227
|
const endPosition = page * pageSize;
|
|
2219
2228
|
const setScopeFilter = `/set[(${setScopeUuids.map((uuid) => `@uuid="${uuid}"`).join(" or ")})]/items/*`;
|
|
2220
|
-
const queryFilters = queries
|
|
2221
|
-
const clause = buildBooleanQueryClause(query);
|
|
2222
|
-
if (index === 0) return clause;
|
|
2223
|
-
return `${query.operator === "OR" ? "or" : "and"} ${clause}`;
|
|
2224
|
-
}).join(" ");
|
|
2229
|
+
const queryFilters = buildQueryFilters(queries);
|
|
2225
2230
|
const filterPredicates = [];
|
|
2226
2231
|
if (belongsToCollectionScopeUuids.length > 0) {
|
|
2227
2232
|
const belongsToCollectionScopeValues = belongsToCollectionScopeUuids.map((uuid) => `@uuid="${uuid}"`).join(" or ");
|
|
@@ -2397,35 +2402,6 @@ function aggregatePropertyValues(values) {
|
|
|
2397
2402
|
});
|
|
2398
2403
|
}
|
|
2399
2404
|
/**
|
|
2400
|
-
* Build a string match predicate for an XQuery string
|
|
2401
|
-
* @param params - The parameters for the predicate
|
|
2402
|
-
* @param params.path - The path to the string
|
|
2403
|
-
* @param params.value - The value to match
|
|
2404
|
-
* @param params.matchMode - The match mode (includes or exact)
|
|
2405
|
-
* @param params.isCaseSensitive - Whether to match case-sensitively
|
|
2406
|
-
* @returns The string match predicate
|
|
2407
|
-
*/
|
|
2408
|
-
function buildStringMatchPredicate(params) {
|
|
2409
|
-
const { path, value, matchMode, isCaseSensitive } = params;
|
|
2410
|
-
const comparedPath = isCaseSensitive ? path : `lower-case(${path})`;
|
|
2411
|
-
const comparedValueLiteral = stringLiteral(isCaseSensitive ? value : value.toLowerCase());
|
|
2412
|
-
if (matchMode === "includes") return `contains(${comparedPath}, ${comparedValueLiteral})`;
|
|
2413
|
-
return `${comparedPath} = ${comparedValueLiteral}`;
|
|
2414
|
-
}
|
|
2415
|
-
/**
|
|
2416
|
-
* Build a title predicate for an XQuery string
|
|
2417
|
-
* @param titleQuery - The title query
|
|
2418
|
-
* @returns The title predicate
|
|
2419
|
-
*/
|
|
2420
|
-
function buildTitlePredicate(titleQuery) {
|
|
2421
|
-
return buildStringMatchPredicate({
|
|
2422
|
-
path: `string-join(identification/label/content[@xml:lang="${titleQuery.language}"]/string, "")`,
|
|
2423
|
-
value: titleQuery.value,
|
|
2424
|
-
matchMode: titleQuery.matchMode,
|
|
2425
|
-
isCaseSensitive: titleQuery.isCaseSensitive
|
|
2426
|
-
});
|
|
2427
|
-
}
|
|
2428
|
-
/**
|
|
2429
2405
|
* Schema for a single property value query item in the OCHRE API response
|
|
2430
2406
|
*/
|
|
2431
2407
|
const propertyValueQueryItemSchema = z.object({
|
|
@@ -2482,7 +2458,7 @@ const responseSchema = z.object({ result: z.union([z.object({ ochre: z.object({
|
|
|
2482
2458
|
* @param params.setScopeUuids - An array of set scope UUIDs to filter by
|
|
2483
2459
|
* @param params.belongsToCollectionScopeUuids - An array of collection scope UUIDs to filter by
|
|
2484
2460
|
* @param params.propertyVariableUuids - An array of property variable UUIDs to fetch
|
|
2485
|
-
* @param params.
|
|
2461
|
+
* @param params.queries - Ordered queries to combine with AND/OR and optional NOT via negation
|
|
2486
2462
|
* @param params.isLimitedToLeafPropertyValues - Whether to limit the property values to leaf property values
|
|
2487
2463
|
* @param options - Options for the fetch
|
|
2488
2464
|
* @param options.version - The version of the OCHRE API to use
|
|
@@ -2490,16 +2466,17 @@ const responseSchema = z.object({ result: z.union([z.object({ ochre: z.object({
|
|
|
2490
2466
|
*/
|
|
2491
2467
|
function buildXQuery(params, options) {
|
|
2492
2468
|
const version = options?.version ?? DEFAULT_API_VERSION;
|
|
2493
|
-
const { setScopeUuids, belongsToCollectionScopeUuids, propertyVariableUuids,
|
|
2469
|
+
const { setScopeUuids, belongsToCollectionScopeUuids, propertyVariableUuids, queries, isLimitedToLeafPropertyValues } = params;
|
|
2494
2470
|
let setScopeFilter = "/set/items/*";
|
|
2495
2471
|
if (setScopeUuids.length > 0) setScopeFilter = `/set[(${setScopeUuids.map((uuid) => `@uuid="${uuid}"`).join(" or ")})]/items/*`;
|
|
2496
2472
|
const propertyVariableFilters = propertyVariableUuids.map((uuid) => `@uuid="${uuid}"`).join(" or ");
|
|
2473
|
+
const queryFilters = buildQueryFilters(queries);
|
|
2497
2474
|
const filterPredicates = [];
|
|
2498
2475
|
if (belongsToCollectionScopeUuids.length > 0) {
|
|
2499
2476
|
const belongsToCollectionScopeValues = belongsToCollectionScopeUuids.map((uuid) => `@uuid="${uuid}"`).join(" or ");
|
|
2500
2477
|
filterPredicates.push(`.//properties[property[label/@uuid="${BELONGS_TO_COLLECTION_UUID}" and value/(${belongsToCollectionScopeValues})]]`);
|
|
2501
2478
|
}
|
|
2502
|
-
if (
|
|
2479
|
+
if (queryFilters.length > 0) filterPredicates.push(`(${queryFilters})`);
|
|
2503
2480
|
const itemFilters = filterPredicates.length > 0 ? `[${filterPredicates.join(" and ")}]` : "";
|
|
2504
2481
|
return `<ochre>{${`let $items := ${version === 2 ? "doc()" : "input()"}/ochre
|
|
2505
2482
|
${setScopeFilter}
|
|
@@ -2522,7 +2499,7 @@ function buildXQuery(params, options) {
|
|
|
2522
2499
|
* @param params.setScopeUuids - An array of set scope UUIDs to filter by
|
|
2523
2500
|
* @param params.belongsToCollectionScopeUuids - The collection scope UUIDs to filter by
|
|
2524
2501
|
* @param params.propertyVariableUuids - The property variable UUIDs to query by
|
|
2525
|
-
* @param params.
|
|
2502
|
+
* @param params.queries - Ordered queries to combine with AND/OR and optional NOT via negation
|
|
2526
2503
|
* @param params.isLimitedToLeafPropertyValues - Whether to limit the property values to leaf property values
|
|
2527
2504
|
* @param options - Options for the fetch
|
|
2528
2505
|
* @param options.fetch - The fetch function to use
|
|
@@ -2532,12 +2509,12 @@ function buildXQuery(params, options) {
|
|
|
2532
2509
|
async function fetchSetPropertyValuesByPropertyVariables(params, options) {
|
|
2533
2510
|
try {
|
|
2534
2511
|
const version = options?.version ?? DEFAULT_API_VERSION;
|
|
2535
|
-
const { setScopeUuids, belongsToCollectionScopeUuids, propertyVariableUuids,
|
|
2512
|
+
const { setScopeUuids, belongsToCollectionScopeUuids, propertyVariableUuids, queries, isLimitedToLeafPropertyValues } = setPropertyValuesByPropertyVariablesParamsSchema.parse(params);
|
|
2536
2513
|
const xquery = buildXQuery({
|
|
2537
2514
|
setScopeUuids,
|
|
2538
2515
|
belongsToCollectionScopeUuids,
|
|
2539
2516
|
propertyVariableUuids,
|
|
2540
|
-
|
|
2517
|
+
queries,
|
|
2541
2518
|
isLimitedToLeafPropertyValues
|
|
2542
2519
|
}, { version });
|
|
2543
2520
|
const response = await (options?.fetch ?? fetch)(version === 2 ? `https://ochre.lib.uchicago.edu/ochre/v2/ochre.php?xquery=${encodeURIComponent(xquery)}&format=json&lang="*"` : `https://ochre.lib.uchicago.edu/ochre?xquery=${encodeURIComponent(xquery)}&format=json&lang="*"`);
|
|
@@ -3071,8 +3048,8 @@ function parseWebElementProperties(componentProperty, elementResource) {
|
|
|
3071
3048
|
isFilterMapDisplayed ??= false;
|
|
3072
3049
|
let isFilterInputDisplayed = getPropertyValueByLabel(componentProperty.properties, "filter-input-displayed");
|
|
3073
3050
|
isFilterInputDisplayed ??= false;
|
|
3074
|
-
let
|
|
3075
|
-
|
|
3051
|
+
let isFilterLimitedToInputFilter = getPropertyValueByLabel(componentProperty.properties, "filter-limit-to-input-filter");
|
|
3052
|
+
isFilterLimitedToInputFilter ??= false;
|
|
3076
3053
|
let isFilterLimitedToLeafPropertyValues = getPropertyValueByLabel(componentProperty.properties, "filter-limit-to-leaf-property-values");
|
|
3077
3054
|
isFilterLimitedToLeafPropertyValues ??= false;
|
|
3078
3055
|
let isSortDisplayed = getPropertyValueByLabel(componentProperty.properties, "sort-displayed");
|
|
@@ -3122,7 +3099,7 @@ function parseWebElementProperties(componentProperty, elementResource) {
|
|
|
3122
3099
|
isResultsBarDisplayed: isFilterResultsBarDisplayed,
|
|
3123
3100
|
isMapDisplayed: isFilterMapDisplayed,
|
|
3124
3101
|
isInputDisplayed: isFilterInputDisplayed,
|
|
3125
|
-
|
|
3102
|
+
isLimitedToInputFilter: isFilterLimitedToInputFilter,
|
|
3126
3103
|
isLimitedToLeafPropertyValues: isFilterLimitedToLeafPropertyValues,
|
|
3127
3104
|
sidebarSort: filterSidebarSort
|
|
3128
3105
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ochre-sdk",
|
|
3
|
-
"version": "0.20.
|
|
3
|
+
"version": "0.20.10",
|
|
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",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"@antfu/eslint-config": "^7.6.1",
|
|
50
|
-
"@types/node": "^24.10.
|
|
50
|
+
"@types/node": "^24.10.15",
|
|
51
51
|
"bumpp": "^10.4.1",
|
|
52
52
|
"eslint": "^10.0.2",
|
|
53
53
|
"prettier": "^3.8.1",
|