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.
@@ -36,8 +36,10 @@ class OccurrencesApiProvider extends BaseProvider {
36
36
  }
37
37
  async getMappings(config) {
38
38
  const occurrences = await this.getOccurrences(config);
39
- const fromScheme = _.get(config, "from.inScheme[0]") || config.fromScheme;
40
- const toScheme = _.get(config, "to.inScheme[0]") || config.toScheme;
39
+ const from = config.from;
40
+ const fromScheme = _.get(from, "inScheme[0]") || config.fromScheme;
41
+ const to = config.to;
42
+ const toScheme = _.get(to, "inScheme[0]") || config.toScheme;
41
43
  const mappings = [];
42
44
  for (let occurrence of occurrences) {
43
45
  if (!occurrence) {
@@ -58,7 +60,7 @@ class OccurrencesApiProvider extends BaseProvider {
58
60
  mapping.to = { memberSet: [] };
59
61
  }
60
62
  mapping.toScheme = _.get(occurrence, "memberSet[1].inScheme[0]");
61
- if (fromScheme && mapping.fromScheme && !jskos.compare(mapping.fromScheme, fromScheme) || toScheme && mapping.toScheme && !jskos.compare(mapping.toScheme, toScheme)) {
63
+ if (from && jskos.compare(from, _.get(mapping, "to.memberSet[0]")) || to && jskos.compare(to, _.get(mapping, "from.memberSet[0]"))) {
62
64
  [mapping.from, mapping.fromScheme, mapping.to, mapping.toScheme] = [mapping.to, mapping.toScheme, mapping.from, mapping.fromScheme];
63
65
  }
64
66
  if (!mapping.fromScheme && fromScheme) {
@@ -70,14 +72,12 @@ class OccurrencesApiProvider extends BaseProvider {
70
72
  mapping.type = [jskos.defaultMappingType.uri];
71
73
  mapping._occurrence = occurrence;
72
74
  mapping = jskos.addMappingIdentifiers(mapping);
73
- if (occurrence.database) {
74
- mapping.creator = [occurrence.database];
75
- }
76
75
  mappings.push(mapping);
77
76
  }
77
+ mappings._url = occurrences._url;
78
78
  return mappings;
79
79
  }
80
- async getOccurrences({ from, to, concepts, ...config }) {
80
+ async getOccurrences({ from, to, concepts, threshold = 0, ...config }) {
81
81
  let promises = [];
82
82
  concepts = (concepts || []).concat([from, to]).filter((c) => !!c);
83
83
  for (let concept of concepts) {
@@ -101,17 +101,7 @@ class OccurrencesApiProvider extends BaseProvider {
101
101
  params: {
102
102
  member: uri,
103
103
  scheme: "*",
104
- threshold: 5
105
- }
106
- }));
107
- }
108
- if (uris.length > 1) {
109
- let urisString = uris.join(" ");
110
- promises.push(this._getOccurrences({
111
- ...config,
112
- params: {
113
- member: urisString,
114
- threshold: 5
104
+ threshold
115
105
  }
116
106
  }));
117
107
  }
@@ -135,7 +125,9 @@ class OccurrencesApiProvider extends BaseProvider {
135
125
  delete occurrences[value];
136
126
  });
137
127
  occurrences = occurrences.filter((o) => o != null);
138
- return occurrences.sort((a, b) => parseInt(b.count || 0) - parseInt(a.count || 0));
128
+ occurrences = occurrences.sort((a, b) => parseInt(b.count || 0) - parseInt(a.count || 0));
129
+ occurrences._url = results.map((result) => result._url);
130
+ return occurrences;
139
131
  }
140
132
  async _getOccurrences(config) {
141
133
  let resultsFromCache = this._cache.find((item) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cocoda-sdk",
3
- "version": "3.2.1",
3
+ "version": "3.2.2",
4
4
  "description": "SDK for Cocoda",
5
5
  "main": "dist/cjs/index.cjs",
6
6
  "module": "dist/esm/index.js",