ochre-sdk 1.0.47 โ 1.0.48
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/fetchers/set/items.mjs +3 -50
- package/dist/query.mjs +13 -9
- package/package.json +4 -26
|
@@ -124,48 +124,6 @@ function buildOrderedItemsClause(sort) {
|
|
|
124
124
|
})}
|
|
125
125
|
return $item`;
|
|
126
126
|
}
|
|
127
|
-
function isExactStringPropertyQuery(query) {
|
|
128
|
-
return "target" in query && query.target === "property" && query.dataType === "string" && query.value != null && query.matchMode === "exact" && query.isNegated !== true;
|
|
129
|
-
}
|
|
130
|
-
function getCtsQueriesWithoutExactStringPropertyQueries(queries) {
|
|
131
|
-
if (queries == null) return null;
|
|
132
|
-
if ("target" in queries) return isExactStringPropertyQuery(queries) ? null : queries;
|
|
133
|
-
if ("or" in queries) return queries;
|
|
134
|
-
const filteredChildren = [];
|
|
135
|
-
for (const childQuery of queries.and) {
|
|
136
|
-
const filteredChildQuery = getCtsQueriesWithoutExactStringPropertyQueries(childQuery);
|
|
137
|
-
if (filteredChildQuery != null) filteredChildren.push(filteredChildQuery);
|
|
138
|
-
}
|
|
139
|
-
if (filteredChildren.length === 0) return null;
|
|
140
|
-
return filteredChildren.length === 1 ? filteredChildren[0] ?? null : { and: filteredChildren };
|
|
141
|
-
}
|
|
142
|
-
function buildExactStringPropertyPredicate(query) {
|
|
143
|
-
const propertyPredicates = [];
|
|
144
|
-
const value = stringLiteral(query.value);
|
|
145
|
-
if (query.propertyVariable != null) propertyPredicates.push(`label/@uuid = ${stringLiteral(query.propertyVariable)}`);
|
|
146
|
-
if (query.propertyRelation != null) propertyPredicates.push(`label/@relation = ${stringLiteral(query.propertyRelation)}`);
|
|
147
|
-
propertyPredicates.push(`value[
|
|
148
|
-
not(@inherited = "true")
|
|
149
|
-
and (
|
|
150
|
-
content[@xml:lang = ${stringLiteral(query.language)}]/string = ${value}
|
|
151
|
-
or @rawValue = ${value}
|
|
152
|
-
or (not(content) and text() = ${value})
|
|
153
|
-
)
|
|
154
|
-
]`);
|
|
155
|
-
return `.//properties/property[${propertyPredicates.join(" and ")}]`;
|
|
156
|
-
}
|
|
157
|
-
function buildExactStringPropertyXPathFilterExpression(queries) {
|
|
158
|
-
if (queries == null) return null;
|
|
159
|
-
if ("target" in queries) return isExactStringPropertyQuery(queries) ? buildExactStringPropertyPredicate(queries) : null;
|
|
160
|
-
if ("or" in queries) return null;
|
|
161
|
-
const childExpressions = [];
|
|
162
|
-
for (const childQuery of queries.and) {
|
|
163
|
-
const childExpression = buildExactStringPropertyXPathFilterExpression(childQuery);
|
|
164
|
-
if (childExpression != null) childExpressions.push(childExpression);
|
|
165
|
-
}
|
|
166
|
-
if (childExpressions.length === 0) return null;
|
|
167
|
-
return childExpressions.join(" and ");
|
|
168
|
-
}
|
|
169
127
|
/**
|
|
170
128
|
* Build an XQuery string to fetch Set items from the OCHRE API
|
|
171
129
|
* @param params - The parameters for the fetch
|
|
@@ -183,9 +141,7 @@ function buildXQuery(params) {
|
|
|
183
141
|
const startPosition = (page - 1) * pageSize + 1;
|
|
184
142
|
const setScopeDeclaration = `declare variable $setScopeUuids := (${setScopeUuids.map((uuid) => stringLiteral(uuid)).join(", ")});`;
|
|
185
143
|
const baseItemsExpression = "doc()/ochre/set[@uuid = $setScopeUuids]/items/*";
|
|
186
|
-
const
|
|
187
|
-
const exactStringPropertyXPathFilterExpression = buildExactStringPropertyXPathFilterExpression(queries);
|
|
188
|
-
const compiledQueryPlan = buildQueryPlan({ queries: ctsQueries });
|
|
144
|
+
const compiledQueryPlan = buildQueryPlan({ queries });
|
|
189
145
|
const itemsQueryExpressions = [];
|
|
190
146
|
const belongsToCollectionQueryExpression = buildBelongsToCollectionQueryExpression(belongsToCollectionScopeUuids, BELONGS_TO_COLLECTION_UUID);
|
|
191
147
|
if (compiledQueryPlan.queryExpression != null) itemsQueryExpressions.push(compiledQueryPlan.queryExpression);
|
|
@@ -194,11 +150,8 @@ function buildXQuery(params) {
|
|
|
194
150
|
const orderedItemsClause = buildOrderedItemsClause(sort);
|
|
195
151
|
const xqueryDeclarations = ["xquery version \"1.0-ml\";", setScopeDeclaration];
|
|
196
152
|
if (compiledQueryPlan.prolog !== "") xqueryDeclarations.push(compiledQueryPlan.prolog);
|
|
197
|
-
const
|
|
198
|
-
let $
|
|
199
|
-
const itemsClause = exactStringPropertyXPathFilterExpression == null ? `${searchedItemsClause}
|
|
200
|
-
let $items := $searchedItems` : `${searchedItemsClause}
|
|
201
|
-
let $items := $searchedItems[${exactStringPropertyXPathFilterExpression}]`;
|
|
153
|
+
const itemsClause = itemsQueryExpression == null ? `let $items := ${baseItemsExpression}` : `let $query := ${itemsQueryExpression}
|
|
154
|
+
let $items := cts:search(${baseItemsExpression}, $query)`;
|
|
202
155
|
return `${xqueryDeclarations.join("\n\n")}
|
|
203
156
|
|
|
204
157
|
<ochre>{
|
package/dist/query.mjs
CHANGED
|
@@ -227,13 +227,6 @@ function buildPropertyLabelQuery(propertyVariable) {
|
|
|
227
227
|
value: propertyVariable
|
|
228
228
|
});
|
|
229
229
|
}
|
|
230
|
-
function buildValueNotInheritedQuery() {
|
|
231
|
-
return buildNotCtsQueryExpression(buildPlainElementAttributeValueQueryExpression({
|
|
232
|
-
elementName: "value",
|
|
233
|
-
attributeName: "inherited",
|
|
234
|
-
value: "true"
|
|
235
|
-
}));
|
|
236
|
-
}
|
|
237
230
|
function buildValueNotIdRefQuery() {
|
|
238
231
|
return buildNotCtsQueryExpression(buildPlainElementAttributeValueQueryExpression({
|
|
239
232
|
elementName: "value",
|
|
@@ -264,6 +257,14 @@ function buildValueContentInnerQuery(params) {
|
|
|
264
257
|
isCaseSensitive
|
|
265
258
|
}));
|
|
266
259
|
}
|
|
260
|
+
function buildValueContentExactInnerQuery(params) {
|
|
261
|
+
const { language, value, isCaseSensitive } = params;
|
|
262
|
+
return buildNestedElementQuery(["content"], buildAndCtsQueryExpressionInternal([buildContentLanguageQuery(language), buildCtsElementValueQueryExpression({
|
|
263
|
+
elementName: "string",
|
|
264
|
+
value,
|
|
265
|
+
isCaseSensitive
|
|
266
|
+
})]));
|
|
267
|
+
}
|
|
267
268
|
function buildValueDirectTextInnerQuery(params) {
|
|
268
269
|
const { value, matchMode, isCaseSensitive } = params;
|
|
269
270
|
const directTextQuery = matchMode === "exact" ? buildCtsElementValueQueryExpression({
|
|
@@ -372,8 +373,11 @@ function buildPropertyStringQueryExpression(params) {
|
|
|
372
373
|
return buildPropertyTextMatchQueryExpression({
|
|
373
374
|
propertyVariable,
|
|
374
375
|
propertyRelation,
|
|
375
|
-
|
|
376
|
-
|
|
376
|
+
contentQueryExpression: matchMode === "exact" ? buildValueContentExactInnerQuery({
|
|
377
|
+
language,
|
|
378
|
+
value,
|
|
379
|
+
isCaseSensitive
|
|
380
|
+
}) : buildValueContentInnerQuery({
|
|
377
381
|
language,
|
|
378
382
|
value,
|
|
379
383
|
matchMode,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ochre-sdk",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.48",
|
|
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",
|
|
@@ -44,28 +44,6 @@
|
|
|
44
44
|
"files": [
|
|
45
45
|
"dist"
|
|
46
46
|
],
|
|
47
|
-
"changelogithub": {
|
|
48
|
-
"types": {
|
|
49
|
-
"feat": {
|
|
50
|
-
"title": "๐ Features"
|
|
51
|
-
},
|
|
52
|
-
"fix": {
|
|
53
|
-
"title": "๐ Bug Fixes"
|
|
54
|
-
},
|
|
55
|
-
"refactor": {
|
|
56
|
-
"title": "๐ง Refactors"
|
|
57
|
-
},
|
|
58
|
-
"test": {
|
|
59
|
-
"title": "๐งช Tests"
|
|
60
|
-
},
|
|
61
|
-
"docs": {
|
|
62
|
-
"title": "๐ Documentation"
|
|
63
|
-
},
|
|
64
|
-
"chore": {
|
|
65
|
-
"title": "๐งน Chores"
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
},
|
|
69
47
|
"dependencies": {
|
|
70
48
|
"date-fns": "^4.4.0",
|
|
71
49
|
"fast-equals": "^6.0.0",
|
|
@@ -74,7 +52,7 @@
|
|
|
74
52
|
},
|
|
75
53
|
"devDependencies": {
|
|
76
54
|
"@antfu/eslint-config": "^9.0.0",
|
|
77
|
-
"@types/node": "^24.13.
|
|
55
|
+
"@types/node": "^24.13.2",
|
|
78
56
|
"bumpp": "^11.1.0",
|
|
79
57
|
"eslint": "^10.4.1",
|
|
80
58
|
"knip": "^6.16.1",
|
|
@@ -86,8 +64,8 @@
|
|
|
86
64
|
"scripts": {
|
|
87
65
|
"dev": "tsdown src/index.ts --watch",
|
|
88
66
|
"build": "tsdown",
|
|
89
|
-
"lint": "knip; eslint .",
|
|
90
|
-
"lint:fix": "knip --fix; eslint
|
|
67
|
+
"lint": "knip; eslint --concurrency auto .",
|
|
68
|
+
"lint:fix": "knip --fix; eslint --concurrency auto --fix .",
|
|
91
69
|
"format": "oxfmt --check",
|
|
92
70
|
"format:fix": "oxfmt",
|
|
93
71
|
"check-types": "tsc --noEmit",
|