ochre-sdk 0.20.2 → 0.20.3
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 +5 -1
- package/dist/index.mjs +20 -9
- package/package.json +2 -4
package/dist/index.d.mts
CHANGED
|
@@ -656,6 +656,7 @@ type Query = {
|
|
|
656
656
|
isCaseSensitive: boolean;
|
|
657
657
|
language: string;
|
|
658
658
|
operator?: "AND" | "OR";
|
|
659
|
+
isNegated?: boolean;
|
|
659
660
|
} | {
|
|
660
661
|
target: "propertyValue";
|
|
661
662
|
dataType: "date" | "dateTime";
|
|
@@ -666,6 +667,7 @@ type Query = {
|
|
|
666
667
|
isCaseSensitive: boolean;
|
|
667
668
|
language: string;
|
|
668
669
|
operator?: "AND" | "OR";
|
|
670
|
+
isNegated?: boolean;
|
|
669
671
|
} | {
|
|
670
672
|
target: "propertyValue";
|
|
671
673
|
dataType: "date" | "dateTime";
|
|
@@ -676,6 +678,7 @@ type Query = {
|
|
|
676
678
|
isCaseSensitive: boolean;
|
|
677
679
|
language: string;
|
|
678
680
|
operator?: "AND" | "OR";
|
|
681
|
+
isNegated?: boolean;
|
|
679
682
|
} | {
|
|
680
683
|
target: "title" | "description" | "image" | "periods" | "bibliography";
|
|
681
684
|
value: string;
|
|
@@ -683,6 +686,7 @@ type Query = {
|
|
|
683
686
|
isCaseSensitive: boolean;
|
|
684
687
|
language: string;
|
|
685
688
|
operator?: "AND" | "OR";
|
|
689
|
+
isNegated?: boolean;
|
|
686
690
|
};
|
|
687
691
|
//#endregion
|
|
688
692
|
//#region src/types/website.d.ts
|
|
@@ -1193,7 +1197,7 @@ declare function fetchItem<T extends DataCategory = DataCategory, U extends Data
|
|
|
1193
1197
|
* @param params.setScopeUuids - The Set scope UUIDs to filter by
|
|
1194
1198
|
* @param params.belongsToCollectionScopeUuids - The collection scope UUIDs to filter by
|
|
1195
1199
|
* @param params.propertyVariableUuids - The property variable UUIDs to filter by
|
|
1196
|
-
* @param params.queries - Ordered queries to combine with AND/OR
|
|
1200
|
+
* @param params.queries - Ordered queries to combine with AND/OR and optional NOT via negation
|
|
1197
1201
|
* @param params.page - The page number (1-indexed)
|
|
1198
1202
|
* @param params.pageSize - The number of items per page
|
|
1199
1203
|
* @param itemCategories - The categories of the items to fetch
|
package/dist/index.mjs
CHANGED
|
@@ -787,7 +787,8 @@ const setItemsParamsSchema = z.object({
|
|
|
787
787
|
matchMode: z.enum(["includes", "exact"]),
|
|
788
788
|
isCaseSensitive: z.boolean(),
|
|
789
789
|
language: z.string().default("eng"),
|
|
790
|
-
operator: z.enum(["AND", "OR"]).optional()
|
|
790
|
+
operator: z.enum(["AND", "OR"]).optional(),
|
|
791
|
+
isNegated: z.boolean().optional().default(false)
|
|
791
792
|
}).strict(),
|
|
792
793
|
z.object({
|
|
793
794
|
target: z.literal("propertyValue"),
|
|
@@ -798,7 +799,8 @@ const setItemsParamsSchema = z.object({
|
|
|
798
799
|
matchMode: z.enum(["includes", "exact"]),
|
|
799
800
|
isCaseSensitive: z.boolean(),
|
|
800
801
|
language: z.string().default("eng"),
|
|
801
|
-
operator: z.enum(["AND", "OR"]).optional()
|
|
802
|
+
operator: z.enum(["AND", "OR"]).optional(),
|
|
803
|
+
isNegated: z.boolean().optional().default(false)
|
|
802
804
|
}).strict(),
|
|
803
805
|
z.object({
|
|
804
806
|
target: z.literal("propertyValue"),
|
|
@@ -809,7 +811,8 @@ const setItemsParamsSchema = z.object({
|
|
|
809
811
|
matchMode: z.enum(["includes", "exact"]),
|
|
810
812
|
isCaseSensitive: z.boolean(),
|
|
811
813
|
language: z.string().default("eng"),
|
|
812
|
-
operator: z.enum(["AND", "OR"]).optional()
|
|
814
|
+
operator: z.enum(["AND", "OR"]).optional(),
|
|
815
|
+
isNegated: z.boolean().optional().default(false)
|
|
813
816
|
}).strict(),
|
|
814
817
|
z.object({
|
|
815
818
|
target: z.enum([
|
|
@@ -823,7 +826,8 @@ const setItemsParamsSchema = z.object({
|
|
|
823
826
|
matchMode: z.enum(["includes", "exact"]),
|
|
824
827
|
isCaseSensitive: z.boolean(),
|
|
825
828
|
language: z.string().default("eng"),
|
|
826
|
-
operator: z.enum(["AND", "OR"]).optional()
|
|
829
|
+
operator: z.enum(["AND", "OR"]).optional(),
|
|
830
|
+
isNegated: z.boolean().optional().default(false)
|
|
827
831
|
}).strict()
|
|
828
832
|
])).default([]),
|
|
829
833
|
page: z.number().min(1, "Page must be positive").default(1),
|
|
@@ -2181,12 +2185,19 @@ function buildQueryPredicate(query) {
|
|
|
2181
2185
|
}
|
|
2182
2186
|
}
|
|
2183
2187
|
/**
|
|
2188
|
+
* Build a boolean query clause for an XQuery string.
|
|
2189
|
+
*/
|
|
2190
|
+
function buildBooleanQueryClause(query) {
|
|
2191
|
+
const baseClause = `(${buildQueryPredicate(query)})`;
|
|
2192
|
+
return query.isNegated ? `not(${baseClause})` : baseClause;
|
|
2193
|
+
}
|
|
2194
|
+
/**
|
|
2184
2195
|
* Build an XQuery string to fetch Set items from the OCHRE API
|
|
2185
2196
|
* @param params - The parameters for the fetch
|
|
2186
2197
|
* @param params.setScopeUuids - An array of Set scope UUIDs to filter by
|
|
2187
2198
|
* @param params.belongsToCollectionScopeUuids - An array of collection scope UUIDs to filter by
|
|
2188
2199
|
* @param params.propertyVariableUuids - An array of property variable UUIDs to filter by
|
|
2189
|
-
* @param params.queries - Ordered queries to combine with AND/OR
|
|
2200
|
+
* @param params.queries - Ordered queries to combine with AND/OR and optional NOT via negation
|
|
2190
2201
|
* @param params.page - The page number (1-indexed)
|
|
2191
2202
|
* @param params.pageSize - The number of items per page
|
|
2192
2203
|
* @param options - Options for the fetch
|
|
@@ -2200,9 +2211,9 @@ function buildXQuery$1(params, options) {
|
|
|
2200
2211
|
const endPosition = page * pageSize;
|
|
2201
2212
|
const setScopeFilter = `/set[(${setScopeUuids.map((uuid) => `@uuid="${uuid}"`).join(" or ")})]/items/*`;
|
|
2202
2213
|
const queryFilters = queries.map((query, index) => {
|
|
2203
|
-
const
|
|
2204
|
-
if (index === 0) return
|
|
2205
|
-
return `${query.operator === "OR" ? "or" : "and"} ${
|
|
2214
|
+
const clause = buildBooleanQueryClause(query);
|
|
2215
|
+
if (index === 0) return clause;
|
|
2216
|
+
return `${query.operator === "OR" ? "or" : "and"} ${clause}`;
|
|
2206
2217
|
}).join(" ");
|
|
2207
2218
|
const filterPredicates = [];
|
|
2208
2219
|
if (belongsToCollectionScopeUuids.length > 0) {
|
|
@@ -2235,7 +2246,7 @@ function buildXQuery$1(params, options) {
|
|
|
2235
2246
|
* @param params.setScopeUuids - The Set scope UUIDs to filter by
|
|
2236
2247
|
* @param params.belongsToCollectionScopeUuids - The collection scope UUIDs to filter by
|
|
2237
2248
|
* @param params.propertyVariableUuids - The property variable UUIDs to filter by
|
|
2238
|
-
* @param params.queries - Ordered queries to combine with AND/OR
|
|
2249
|
+
* @param params.queries - Ordered queries to combine with AND/OR and optional NOT via negation
|
|
2239
2250
|
* @param params.page - The page number (1-indexed)
|
|
2240
2251
|
* @param params.pageSize - The number of items per page
|
|
2241
2252
|
* @param itemCategories - The categories of the items to fetch
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ochre-sdk",
|
|
3
|
-
"version": "0.20.
|
|
3
|
+
"version": "0.20.3",
|
|
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",
|
|
@@ -52,8 +52,7 @@
|
|
|
52
52
|
"eslint": "^10.0.2",
|
|
53
53
|
"prettier": "^3.8.1",
|
|
54
54
|
"tsdown": "^0.20.3",
|
|
55
|
-
"typescript": "^5.9.3"
|
|
56
|
-
"vitest": "^4.0.18"
|
|
55
|
+
"typescript": "^5.9.3"
|
|
57
56
|
},
|
|
58
57
|
"scripts": {
|
|
59
58
|
"dev": "tsdown src/index.ts --watch",
|
|
@@ -65,7 +64,6 @@
|
|
|
65
64
|
"format": "prettier --cache --check .",
|
|
66
65
|
"format:fix": "prettier --cache --write --list-different .",
|
|
67
66
|
"check-types": "tsc --noEmit",
|
|
68
|
-
"test": "vitest run",
|
|
69
67
|
"release": "bumpp"
|
|
70
68
|
}
|
|
71
69
|
}
|