cocoda-sdk 3.2.1 → 3.2.2

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.
@@ -1419,8 +1419,10 @@ var OccurrencesApiProvider = class extends BaseProvider {
1419
1419
  }
1420
1420
  async getMappings(config) {
1421
1421
  const occurrences = await this.getOccurrences(config);
1422
- const fromScheme = import_get.default(config, "from.inScheme[0]") || config.fromScheme;
1423
- const toScheme = import_get.default(config, "to.inScheme[0]") || config.toScheme;
1422
+ const from = config.from;
1423
+ const fromScheme = import_get.default(from, "inScheme[0]") || config.fromScheme;
1424
+ const to = config.to;
1425
+ const toScheme = import_get.default(to, "inScheme[0]") || config.toScheme;
1424
1426
  const mappings = [];
1425
1427
  for (let occurrence of occurrences) {
1426
1428
  if (!occurrence) {
@@ -1441,7 +1443,7 @@ var OccurrencesApiProvider = class extends BaseProvider {
1441
1443
  mapping.to = { memberSet: [] };
1442
1444
  }
1443
1445
  mapping.toScheme = import_get.default(occurrence, "memberSet[1].inScheme[0]");
1444
- if (fromScheme && mapping.fromScheme && !import_jskos_tools4.default.compare(mapping.fromScheme, fromScheme) || toScheme && mapping.toScheme && !import_jskos_tools4.default.compare(mapping.toScheme, toScheme)) {
1446
+ if (from && import_jskos_tools4.default.compare(from, import_get.default(mapping, "to.memberSet[0]")) || to && import_jskos_tools4.default.compare(to, import_get.default(mapping, "from.memberSet[0]"))) {
1445
1447
  [mapping.from, mapping.fromScheme, mapping.to, mapping.toScheme] = [mapping.to, mapping.toScheme, mapping.from, mapping.fromScheme];
1446
1448
  }
1447
1449
  if (!mapping.fromScheme && fromScheme) {
@@ -1453,14 +1455,12 @@ var OccurrencesApiProvider = class extends BaseProvider {
1453
1455
  mapping.type = [import_jskos_tools4.default.defaultMappingType.uri];
1454
1456
  mapping._occurrence = occurrence;
1455
1457
  mapping = import_jskos_tools4.default.addMappingIdentifiers(mapping);
1456
- if (occurrence.database) {
1457
- mapping.creator = [occurrence.database];
1458
- }
1459
1458
  mappings.push(mapping);
1460
1459
  }
1460
+ mappings._url = occurrences._url;
1461
1461
  return mappings;
1462
1462
  }
1463
- async getOccurrences({ from, to, concepts, ...config }) {
1463
+ async getOccurrences({ from, to, concepts, threshold = 0, ...config }) {
1464
1464
  let promises = [];
1465
1465
  concepts = (concepts || []).concat([from, to]).filter((c) => !!c);
1466
1466
  for (let concept of concepts) {
@@ -1484,17 +1484,7 @@ var OccurrencesApiProvider = class extends BaseProvider {
1484
1484
  params: {
1485
1485
  member: uri,
1486
1486
  scheme: "*",
1487
- threshold: 5
1488
- }
1489
- }));
1490
- }
1491
- if (uris.length > 1) {
1492
- let urisString = uris.join(" ");
1493
- promises.push(this._getOccurrences({
1494
- ...config,
1495
- params: {
1496
- member: urisString,
1497
- threshold: 5
1487
+ threshold
1498
1488
  }
1499
1489
  }));
1500
1490
  }
@@ -1518,7 +1508,9 @@ var OccurrencesApiProvider = class extends BaseProvider {
1518
1508
  delete occurrences[value];
1519
1509
  });
1520
1510
  occurrences = occurrences.filter((o) => o != null);
1521
- return occurrences.sort((a, b) => parseInt(b.count || 0) - parseInt(a.count || 0));
1511
+ occurrences = occurrences.sort((a, b) => parseInt(b.count || 0) - parseInt(a.count || 0));
1512
+ occurrences._url = results.map((result) => result._url);
1513
+ return occurrences;
1522
1514
  }
1523
1515
  async _getOccurrences(config) {
1524
1516
  let resultsFromCache = this._cache.find((item) => {