ochre-sdk 0.20.27 → 0.20.29

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.
Files changed (2) hide show
  1. package/dist/index.mjs +10 -16
  2. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -2507,12 +2507,12 @@ function buildPropertyStringIncludesGroupMember(query) {
2507
2507
  const propertyValue = query.propertyValues[0] ?? "";
2508
2508
  if (propertyVariables.length > 0) predicateParts.push(buildPropertyLabelPredicate(propertyVariables));
2509
2509
  return {
2510
- rawPredicate: `.//properties//property[${buildAndPredicate([...predicateParts, buildRawStringMatchPredicate({
2510
+ rawPredicate: buildPropertyPredicateExpression([...predicateParts, buildRawStringMatchPredicate({
2511
2511
  valueExpression,
2512
2512
  value: propertyValue,
2513
2513
  matchMode: "includes",
2514
2514
  isCaseSensitive: query.isCaseSensitive
2515
- })])}]`,
2515
+ })]),
2516
2516
  buildCandidateTermQuery: (termExpression) => buildPropertyStringCandidateBranch({
2517
2517
  termExpression,
2518
2518
  isCaseSensitive: query.isCaseSensitive,
@@ -2658,6 +2658,11 @@ function buildPropertyValueAttributePredicate(params) {
2658
2658
  for (const propertyValue of propertyValues) valuePredicates.push(`value[@${attributeName}=${stringLiteral(propertyValue)}]`);
2659
2659
  return buildOrPredicate(valuePredicates);
2660
2660
  }
2661
+ function buildPropertyPredicateExpression(propertyPredicates) {
2662
+ let propertyExpression = ".//properties//property";
2663
+ for (const propertyPredicate of propertyPredicates) propertyExpression += `[${propertyPredicate}]`;
2664
+ return propertyExpression;
2665
+ }
2661
2666
  function buildPropertyStringValueClause(params) {
2662
2667
  const { query, version, queryKey } = params;
2663
2668
  const propertyContentNodesExpression = query.matchMode === "includes" && version === 2 ? `value[not(@inherited="true")]/content[@xml:lang="${query.language}"]` : `value/content[@xml:lang="${query.language}"]`;
@@ -2743,7 +2748,7 @@ function buildPropertyClause(params) {
2743
2748
  }
2744
2749
  return {
2745
2750
  declarations,
2746
- predicate: `.//properties//property[${buildAndPredicate(predicateParts)}]`,
2751
+ predicate: buildPropertyPredicateExpression(predicateParts),
2747
2752
  candidateQueryVar
2748
2753
  };
2749
2754
  }
@@ -3014,15 +3019,7 @@ function buildXQuery$1(params, options) {
3014
3019
  if (compiledQueryPlan.predicate.length > 0) filterPredicates.push(`(${compiledQueryPlan.predicate})`);
3015
3020
  const itemFilters = filterPredicates.length > 0 ? `[${filterPredicates.join(" and ")}]` : "";
3016
3021
  const orderedItemsClause = buildOrderedItemsClause(sort);
3017
- return `<ochre>{${`${queryFilterDeclarations}let $rawItems := ${compiledQueryPlan.itemsExpression}${itemFilters}
3018
- let $items :=
3019
- for $item at $position in $rawItems
3020
- let $itemUuid := string($item/@uuid)
3021
- where not(
3022
- some $previous in subsequence($rawItems, 1, $position - 1)
3023
- satisfies string($previous/@uuid) = $itemUuid
3024
- )
3025
- return $item
3022
+ return `<ochre>{${`${queryFilterDeclarations}let $items := ${compiledQueryPlan.itemsExpression}${itemFilters}
3026
3023
 
3027
3024
  let $totalCount := count($items)
3028
3025
  ${orderedItemsClause}
@@ -3123,10 +3120,7 @@ async function fetchSetItems(params, itemCategories, options) {
3123
3120
  items.push(...trees);
3124
3121
  }
3125
3122
  const itemsByUuid = /* @__PURE__ */ new Map();
3126
- for (const item of items) {
3127
- if (itemsByUuid.has(item.uuid)) throw new Error(`Duplicate item UUID: ${item.uuid}`);
3128
- itemsByUuid.set(item.uuid, item);
3129
- }
3123
+ for (const item of items) if (!itemsByUuid.has(item.uuid)) itemsByUuid.set(item.uuid, item);
3130
3124
  const uniqueItems = [...itemsByUuid.values()];
3131
3125
  return {
3132
3126
  totalCount: data.result.ochre.items.totalCount,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ochre-sdk",
3
- "version": "0.20.27",
3
+ "version": "0.20.29",
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",