ochre-sdk 1.0.46 โ†’ 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.
@@ -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 ctsQueries = getCtsQueriesWithoutExactStringPropertyQueries(queries);
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 searchedItemsClause = itemsQueryExpression == null ? `let $searchedItems := ${baseItemsExpression}` : `let $query := ${itemsQueryExpression}
198
- let $searchedItems := cts:search(${baseItemsExpression}, $query)`;
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>{
@@ -301,8 +301,7 @@ var MultilingualString = class MultilingualString {
301
301
  * Check if the multilingual string has any content
302
302
  */
303
303
  hasContent() {
304
- const contentEntries = Object.values(this._content);
305
- for (const entries of contentEntries) for (const entry of entries ?? []) if (entry.text.trim().length > 0 || entry.richText.trim().length > 0) return true;
304
+ for (const language of this._availableLanguages) for (const entry of this._content[language] ?? []) if (entry.text.trim().length > 0 || entry.richText.trim().length > 0) return true;
306
305
  return false;
307
306
  }
308
307
  /**
@@ -636,7 +636,7 @@ function parseWebElementProperties(componentProperty, elementResource, options,
636
636
  const queryVariant = componentReader.valueOr("query-variant", "submit");
637
637
  const boundElementUuid = componentReader.uuid("bound-element");
638
638
  const href = parseWebsiteLinkTarget(componentReader.valueNode("link-to"), context);
639
- if (!boundElementUuid && !href) throw new Error(formatComponentError("Bound element or href not found", componentName, elementResource), { cause: componentProperty });
639
+ if (boundElementUuid === null && href === null) throw new Error(formatComponentError("Bound element or href not found", componentName, elementResource), { cause: componentProperty });
640
640
  properties = {
641
641
  component: "search-bar",
642
642
  queryVariant,
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
- valueFilters: [buildValueNotInheritedQuery()],
376
- contentQueryExpression: buildValueContentInnerQuery({
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.46",
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.1",
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 . --fix",
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",