ochre-sdk 0.20.19 → 0.20.20

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 +8 -7
  2. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -2341,15 +2341,10 @@ function buildXQuery$1(params, options) {
2341
2341
  if (queryFilters.length > 0) filterPredicates.push(`(${queryFilters})`);
2342
2342
  const itemFilters = filterPredicates.length > 0 ? `[${filterPredicates.join(" and ")}]` : "";
2343
2343
  const orderedItemsClause = buildOrderedItemsClause(sort);
2344
- return `<ochre>{${`let $rawItems := ${version === 2 ? "doc()" : "input()"}/ochre
2344
+ return `<ochre>{${`let $items := ${version === 2 ? "doc()" : "input()"}/ochre
2345
2345
  ${setScopeFilter}
2346
2346
  ${itemFilters}
2347
2347
 
2348
- let $items :=
2349
- for $item at $position in $rawItems
2350
- where empty($rawItems[position() lt $position][@uuid = $item/@uuid])
2351
- return $item
2352
-
2353
2348
  let $totalCount := count($items)
2354
2349
  ${orderedItemsClause}
2355
2350
 
@@ -2445,11 +2440,17 @@ async function fetchSetItems(params, itemCategories, options) {
2445
2440
  const trees = parseTrees(Array.isArray(data.result.ochre.items.tree) ? data.result.ochre.items.tree : [data.result.ochre.items.tree]);
2446
2441
  items.push(...trees);
2447
2442
  }
2443
+ const itemsByUuid = /* @__PURE__ */ new Map();
2444
+ for (const item of items) {
2445
+ if (itemsByUuid.has(item.uuid)) throw new Error(`Duplicate item UUID: ${item.uuid}`);
2446
+ itemsByUuid.set(item.uuid, item);
2447
+ }
2448
+ const uniqueItems = [...itemsByUuid.values()];
2448
2449
  return {
2449
2450
  totalCount: data.result.ochre.items.totalCount,
2450
2451
  page: data.result.ochre.items.page,
2451
2452
  pageSize: data.result.ochre.items.pageSize,
2452
- items,
2453
+ items: uniqueItems,
2453
2454
  error: null
2454
2455
  };
2455
2456
  } catch (error) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ochre-sdk",
3
- "version": "0.20.19",
3
+ "version": "0.20.20",
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",