ochre-sdk 0.20.0 → 0.20.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 +9 -1
- package/dist/index.mjs +36 -8
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -647,7 +647,15 @@ type PropertyValueQueryItem = {
|
|
|
647
647
|
* Represents a query for Set items
|
|
648
648
|
*/
|
|
649
649
|
type Query = {
|
|
650
|
-
target: "
|
|
650
|
+
target: "propertyValue";
|
|
651
|
+
dataType: Exclude<PropertyValueContentType, "coordinate">;
|
|
652
|
+
value: string;
|
|
653
|
+
matchMode: "includes" | "exact";
|
|
654
|
+
isCaseSensitive: boolean;
|
|
655
|
+
language: string;
|
|
656
|
+
operator?: "AND" | "OR";
|
|
657
|
+
} | {
|
|
658
|
+
target: "title" | "description" | "image" | "periods" | "bibliography";
|
|
651
659
|
value: string;
|
|
652
660
|
matchMode: "includes" | "exact";
|
|
653
661
|
isCaseSensitive: boolean;
|
package/dist/index.mjs
CHANGED
|
@@ -772,21 +772,37 @@ const setItemsParamsSchema = z.object({
|
|
|
772
772
|
setScopeUuids: z.array(uuidSchema).min(1, "At least one set scope UUID is required"),
|
|
773
773
|
belongsToCollectionScopeUuids: z.array(uuidSchema).default([]),
|
|
774
774
|
propertyVariableUuids: z.array(uuidSchema).default([]),
|
|
775
|
-
queries: z.array(z.object({
|
|
775
|
+
queries: z.array(z.discriminatedUnion("target", [z.object({
|
|
776
|
+
target: z.literal("propertyValue"),
|
|
777
|
+
dataType: z.enum([
|
|
778
|
+
"string",
|
|
779
|
+
"integer",
|
|
780
|
+
"decimal",
|
|
781
|
+
"boolean",
|
|
782
|
+
"date",
|
|
783
|
+
"dateTime",
|
|
784
|
+
"time",
|
|
785
|
+
"IDREF"
|
|
786
|
+
]),
|
|
787
|
+
value: z.string(),
|
|
788
|
+
matchMode: z.enum(["includes", "exact"]),
|
|
789
|
+
isCaseSensitive: z.boolean(),
|
|
790
|
+
language: z.string().default("eng"),
|
|
791
|
+
operator: z.enum(["AND", "OR"]).optional()
|
|
792
|
+
}), z.object({
|
|
776
793
|
target: z.enum([
|
|
777
794
|
"title",
|
|
778
795
|
"description",
|
|
779
796
|
"image",
|
|
780
797
|
"periods",
|
|
781
|
-
"bibliography"
|
|
782
|
-
"propertyValue"
|
|
798
|
+
"bibliography"
|
|
783
799
|
]),
|
|
784
800
|
value: z.string(),
|
|
785
801
|
matchMode: z.enum(["includes", "exact"]),
|
|
786
802
|
isCaseSensitive: z.boolean(),
|
|
787
803
|
language: z.string().default("eng"),
|
|
788
804
|
operator: z.enum(["AND", "OR"]).optional()
|
|
789
|
-
})).default([]),
|
|
805
|
+
})])).default([]),
|
|
790
806
|
page: z.number().min(1, "Page must be positive").default(1),
|
|
791
807
|
pageSize: z.number().min(1, "Page size must be positive").default(DEFAULT_PAGE_SIZE)
|
|
792
808
|
}).superRefine((value, ctx) => {
|
|
@@ -2073,6 +2089,21 @@ function buildStringMatchPredicate(params) {
|
|
|
2073
2089
|
return `${comparedPath} = ${comparedValueLiteral}`;
|
|
2074
2090
|
}
|
|
2075
2091
|
/**
|
|
2092
|
+
* Build a property value predicate for an XQuery string
|
|
2093
|
+
* @param query - The propertyValue query
|
|
2094
|
+
* @returns The property value predicate
|
|
2095
|
+
*/
|
|
2096
|
+
function buildPropertyValuePredicate(query) {
|
|
2097
|
+
if (query.dataType === "IDREF") return `.//properties//property[value[@uuid=${stringLiteral(query.value)}]]`;
|
|
2098
|
+
if (query.dataType === "date" || query.dataType === "dateTime" || query.dataType === "time" || query.dataType === "integer" || query.dataType === "decimal" || query.dataType === "boolean") return `.//properties//property[value[@rawValue=${stringLiteral(query.value)}]]`;
|
|
2099
|
+
return `.//properties//property[${buildStringMatchPredicate({
|
|
2100
|
+
path: `string-join(value/content[@xml:lang="${query.language}"]/string, "")`,
|
|
2101
|
+
value: query.value,
|
|
2102
|
+
matchMode: query.matchMode,
|
|
2103
|
+
isCaseSensitive: query.isCaseSensitive
|
|
2104
|
+
})}]`;
|
|
2105
|
+
}
|
|
2106
|
+
/**
|
|
2076
2107
|
* Build a query predicate for an XQuery string
|
|
2077
2108
|
* @param query - The query to build the predicate for
|
|
2078
2109
|
* @returns The query predicate
|
|
@@ -2105,10 +2136,7 @@ function buildQueryPredicate(query) {
|
|
|
2105
2136
|
path: `string-join(image/identification/label/content[@xml:lang="${query.language}"]/string, "")`,
|
|
2106
2137
|
...stringMatchParams
|
|
2107
2138
|
});
|
|
2108
|
-
case "propertyValue": return
|
|
2109
|
-
path: `string-join(value/content[@xml:lang="${query.language}"]/string, "")`,
|
|
2110
|
-
...stringMatchParams
|
|
2111
|
-
})}]`;
|
|
2139
|
+
case "propertyValue": return buildPropertyValuePredicate(query);
|
|
2112
2140
|
}
|
|
2113
2141
|
}
|
|
2114
2142
|
/**
|